Compare commits

...

18 Commits
v0.2 ... master

Author SHA1 Message Date
Damillora 2dba9271a9 fix icon on non-Mac 2017-07-07 14:57:43 +07:00
Damillora 73608d17e1 tweak menu behavior on non-Mac 2017-07-07 14:53:35 +07:00
Damillora 718bae29ab add checks for macOS 2017-07-07 14:44:26 +07:00
Damillora ef12775d84 add million live help 2017-07-04 02:32:21 +07:00
Damillora 18878a20d6 more fix on menus 2017-07-04 02:02:17 +07:00
Damillora 766edbc6c4 fix menu 2017-07-04 01:59:09 +07:00
Damillora f8e0069f77 version bump to 0.3.0 2017-07-04 01:30:22 +07:00
Damillora 8ae84034a8 add file menu for non-mac 2017-07-04 00:25:03 +07:00
Damillora 47a633b65b remove logout from menu 2017-07-04 00:23:45 +07:00
Damillora 03ec4ea171 add project homepage menu in help 2017-07-04 00:19:28 +07:00
Damillora 88445acaee add help menu 2017-07-04 00:16:49 +07:00
Damillora d60baa4da0 handle blur in preference window 2017-07-04 00:07:12 +07:00
Damillora c285f5bee1 just the main window 2017-07-04 00:06:51 +07:00
Damillora 6a53c26cc5 darwin lol 2017-07-04 00:02:52 +07:00
Damillora 74045a0414 burb 2017-07-03 23:58:41 +07:00
Damillora 236c5339ef version bump to 0.3 development 2017-07-03 23:57:04 +07:00
Damillora ed3f79d627 preferences window 2017-07-03 23:56:29 +07:00
Damillora 66a371a0cf add empty preferences windows 2017-07-03 22:55:37 +07:00
7 changed files with 193 additions and 16 deletions

View File

@ -182,5 +182,5 @@ module.exports.navitemplate = function(win){
module.exports.setdock = function(win) {
const dockMenu = Menu.buildFromTemplate(module.exports.navitemplate(win))
app.dock.setMenu(dockMenu);
if(process.platform == 'darwin' ) app.dock.setMenu(dockMenu);
}

29
main.js
View File

@ -9,14 +9,15 @@ require('electron-debug')();
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win
const options = {userAgent: 'Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F27E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.83 Mobile Safari/537.36'};
function createWindow () {
// Create the browser window.
win = new BrowserWindow({width: 480, height: 600,icon: path.join(__dirname, 'ic_launcher.png')})
win = new BrowserWindow({width: 480, height: 600,icon: path.join(__dirname, 'icon.png')})
setdock.setdock(win)
Menu.setApplicationMenu(themenu(win));
if(process.platform == 'darwin') { Menu.setApplicationMenu(themenu(win)); }
else { win.setMenu(themenu(win));
}
// and load the index.html of the app.
win.loadURL('http://pf.gree.net/58737',options);
// Open the DevTools.
@ -35,11 +36,23 @@ function createWindow () {
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow)
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
ipc.on('log-out',function(){
console.log("logging out");
win.webContents.session.clearStorageData({storages: "cookies"});win.loadURL("http://pf.gree.net/58737",options);
});
app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
//if (process.platform !== 'darwin') {
if (process.platform !== 'darwin') {
app.quit()
//}
}
})
app.on('activate', function () {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (win === null) {
createWindow()
}
})

45
menu.js
View File

@ -1,5 +1,7 @@
const { app, Menu } = require('electron');
const { app, Menu,shell } = require('electron');
const navi = require('./dock');
const prefman = require('./preferencemanager');
const ipc = require('electron').ipcMain;
const options = {userAgent: 'Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F27E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.83 Mobile Safari/537.36'};
@ -43,15 +45,37 @@ module.exports = function(win){
{role: 'minimize'},
{role: 'close'}
]
},
{
label: 'Help',
role: 'help',
submenu: [
{
label: "Million Live! Help",
click() { win.loadURL("http://imas.gree-apps.net/app/index.php/help",options)}
},
{
label: "Project Homepage",
click(){shell.openExternal("https://github.com/Damillora/MillionHopes")}
},
{
label: 'About Million Hopes',
click() {
prefman.showAbout();
},
visible: process.platform !== 'darwin'
}
]
}
]
if (process.platform === 'darwin') {
template.unshift({
label: app.getName(),
submenu: [
{role: 'about'},
{label: "Clear Cookies / Log Out",click(){win.webContents.session.clearStorageData({storages: "cookies"});win.loadURL("http://pf.gree.net/58737",options)}},
{label: 'About Million Hopes',click(){prefman.showAbout()}},
{type: 'separator'},
{label: 'Preferences',click(){prefman.showPreferences()}},
{type: 'separator'},
{role: 'services', submenu: []},
{type: 'separator'},
@ -64,7 +88,7 @@ module.exports = function(win){
})
// Edit menu
template[1].submenu.push(
template[2].submenu.push(
{type: 'separator'},
{
label: 'Speech',
@ -83,6 +107,17 @@ module.exports = function(win){
{type: 'separator'},
{role: 'front'}
]
} else
{
template.unshift({
label: "File",
submenu: [
{label: 'Preferences',click(){prefman.showPreferences()}},
{type: 'separator'},
{label: 'Exit', click(){ app.quit() }},
],
visible: process.platform !== 'darwin'
})
}
const themenu = Menu.buildFromTemplate(template);

View File

@ -1,13 +1,15 @@
{
"name": "MillionHopes",
"productName": "Million Hopes",
"version": "0.2.0",
"version": "0.3.1",
"description": "A thin wrapper for the game THE IDOLM@STER: Million Live!, using Electron.",
"main": "main.js",
"devDependencies": {
"electron": "^1.6.11"
},
"dependencies": {
"electron-debug": "^1.2.0"
"electron-debug": "^1.2.0",
"electron-settings": "^3.1.1",
"photonkit": "^0.1.2"
}
}

41
preferencemanager.js Normal file
View File

@ -0,0 +1,41 @@
const {app, Menu, BrowserWindow} = require('electron')
const url = require('url')
const path = require('path')
let preferencesWindow;
require('electron-debug')();
function showPreferences_int(){
if(!preferencesWindow){
preferencesWindow = new BrowserWindow({width: 800, height: 600})
if (process.platform !== 'darwin') preferencesWindow.setMenu(null);
preferencesWindow.loadURL(url.format({
pathname: path.join(__dirname, 'preferences.html'),
protocol: 'file:',
slashes: true
}))
preferencesWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
preferencesWindow = null
})
preferencesWindow.on('blur',() => {
preferencesWindow.close();
})
}
}
module.exports.showPreferences = function(){
showPreferences_int();
preferencesWindow.webContents.on('did-finish-load', function() {
preferencesWindow.webContents.executeJavaScript("document.getElementById('mh-pane-general').click();");
});
}
module.exports.showAbout = function(){
showPreferences_int();
preferencesWindow.webContents.on('did-finish-load', function() {
preferencesWindow.webContents.executeJavaScript("document.getElementById('mh-pane-about').click();");
});
}

57
preferences.html Normal file
View File

@ -0,0 +1,57 @@
<!DOCTYPE html>
<html>
<head>
<title>Million Hopes Preferences</title>
<!-- Stylesheets -->
<link rel="stylesheet" href="./node_modules/photonkit/dist/css/photon.css">
</head>
<body>
<!-- Wrap your entire app inside .window -->
<div class="window">
<!-- .toolbar-header sits at the top of your app -->
<!-- Your app's content goes inside .window-content -->
<div class="window-content">
<div class="padded-more">
<div class="pane-group">
<div class="pane-sm sidebar">
<nav class="nav-group">
<h5 class="nav-group-title">Preferences</h5>
<a id="mh-pane-general" class="nav-group-item active" onclick="genericpane_click(event,'mh-pref-general')">
General
</a>
<a id="mh-pane-account" class="nav-group-item" onclick="genericpane_click(event,'mh-pref-account')">
Account
</a>
<a id="mh-pane-about" class="nav-group-item" onclick="genericpane_click(event,'mh-pref-about')">
About
</a>
</nav>
</div>
<div class="pane padded-more">
<div id="mh-pref-general" class="mh-prefs">
<h5>General preferences</h5>
There aren't any configurable options currently in this tab.
</div>
<div id="mh-pref-account" class="mh-prefs">
<h5>Log out</h5>
<p>Logs you out of Million Live!</p>
<button class="btn btn-default" id="mh-account-logout">Log out</a>
</div>
<div id="mh-pref-about" class="mh-prefs">
<h5>About</h5>
<h3>Million Hopes <script>document.write(require('electron').remote.app.getVersion())</script></h3>
<i>""</i>
<p>A client for the game THE IDOLM@STER: Million Live!, using Electron.</p>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="preferences.js"></script>
</body>
</html>

29
preferences.js Normal file
View File

@ -0,0 +1,29 @@
const ipc = require('electron').ipcRenderer;
function logout_click(){
ipc.send('log-out');
}
function genericpane_click(evt,prefname){
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("mh-prefs");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
// Get all elements with class="tablinks" and remove the class "active"
tablinks = document.getElementsByClassName("nav-group-item");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].classList.remove("active");
}
// Show the current tab, and add an "active" class to the button that opened the tab
document.getElementById(prefname).style.display = "block";
document.getElementById(prefname.replace("pref","pane")).classList.add("active");
const asyncMsgBtn = document.getElementById('mh-account-logout');
asyncMsgBtn.addEventListener('click', function () {
ipc.send('log-out')
})
}