Compare commits
18 Commits
Author | SHA1 | Date |
---|---|---|
Damillora | 2dba9271a9 | |
Damillora | 73608d17e1 | |
Damillora | 718bae29ab | |
Damillora | ef12775d84 | |
Damillora | 18878a20d6 | |
Damillora | 766edbc6c4 | |
Damillora | f8e0069f77 | |
Damillora | 8ae84034a8 | |
Damillora | 47a633b65b | |
Damillora | 03ec4ea171 | |
Damillora | 88445acaee | |
Damillora | d60baa4da0 | |
Damillora | c285f5bee1 | |
Damillora | 6a53c26cc5 | |
Damillora | 74045a0414 | |
Damillora | 236c5339ef | |
Damillora | ed3f79d627 | |
Damillora | 66a371a0cf |
2
dock.js
2
dock.js
|
@ -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
29
main.js
|
@ -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
45
menu.js
|
@ -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);
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();");
|
||||
});
|
||||
}
|
|
@ -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>
|
|
@ -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')
|
||||
})
|
||||
|
||||
}
|
Reference in New Issue