-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmainWindow.html
158 lines (144 loc) · 5.5 KB
/
mainWindow.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<!DOCTYPE html>
<html>
<head>
<title>Shoot Em Up Launcher</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
</head>
<body>
<div class='container'>
<h1>Ground Mosh</h1>
<div class="row">
<div class="col-sm-6">
<div class="card">
<div class="card-header">
Configure controls
</div>
<div class="card-body">
<div class='form-group'>
<button id='configure_keyboard_btn' onclick="ipcRenderer.send('create-configure-keyboard-window', null);" class='btn btn-secondary mb-2'>Keyboard</button>
</div>
<div class='form-group'>
<button id='configure_gamepad_btn' onclick="ipcRenderer.send('create-configure-gamepad-window', null);" class='btn btn-secondary mb-2'>Gamepad</button>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="card">
<div class="card-header">
Settings
</div>
<div class="card-body">
<form class='form-group'>
<div>
<div class='form-group'>
<label for='screen_size'>Screen size</label>
<select class='form-control' id='screen_size'>
<option value=''>select</option>
<option value='1280 x 720'>1280 x 720</option>
<option value='1366 x 768'>1366 x 768</option>
<option value='1920 x 1080'>1920 x 1080</option>
<option value='2560 x 1440'>2560 x 1440</option>
</select>
</div>
<div class="form-check">
<input id='fullscreen' class='form-check-input' type='checkbox' autofocus>
<label class="form-check-label" for='fullscreen'>
Fullscreen
</label>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<hr>
<div class="row">
<div class="col-sm-4" algin="right">
<p>Join us!<br>https://discord.gg/fGBbQZ8</p>
</div>
<div class="col-sm-8" algin="right">
<button algin="right" id='play_btn' class='btn btn-primary mb-2 float-right btn-lg'>Play</button>
</div>
</div>
</div>
<script>
const electron = require('electron')
const {ipcRenderer} = electron
const app = require('electron').remote.app
var path = require('path')
const config_file_path = path.normalize(__dirname + '/../../../game/assets/config.json')
window.addEventListener('load', function(){
const fs = require('fs')
const config_json = require(config_file_path)
const fullscreen = config_json.fullscreen.enabled
const screen_size = config_json.screen_size.x + ' x ' + config_json.screen_size.y
document.getElementById('fullscreen').checked = (fullscreen == 'yes')
document.getElementById('screen_size').value = screen_size
})
document.querySelector('#fullscreen').addEventListener('change', function(e){
e.preventDefault()
const fullscreen = document.querySelector('#fullscreen').checked
const fs = require('fs')
const config_json = require(config_file_path)
if(fullscreen)
config_json.fullscreen.enabled = 'yes'
else
config_json.fullscreen.enabled = 'no'
fs.writeFile(config_file_path, JSON.stringify(config_json, null, 2), function writeJSON(err) {
if (err) return console.log(err)
})
})
document.querySelector('#screen_size').addEventListener('change', function(e){
e.preventDefault()
const screen_size = document.querySelector('#screen_size').value
const fs = require('fs')
const config_json = require(config_file_path)
switch(screen_size) {
case '1280 x 720':
config_json.screen_size.x = '1280'
config_json.screen_size.y = '720'
break
case '1366 x 768':
config_json.screen_size.x = '1366'
config_json.screen_size.y = '768'
break
case '1920 x 1080':
config_json.screen_size.x = '1920'
config_json.screen_size.y = '1080'
break
case '2560 x 1440':
config_json.screen_size.x = '2560'
config_json.screen_size.y = '1440'
break
default:
}
fs.writeFile(config_file_path, JSON.stringify(config_json, null, 2), function writeJSON(err) {
if (err) return console.log(err)
})
})
document.querySelector('#play_btn').addEventListener('click', function(){
const { exec } = require('child_process');
if(process.platform == 'linux' )
{
exec('sh run_game.sh', (err, stdout, stderr) => {
if (err) {
console.error(`exec error: ${err}`)
return;
}
});
}
else
{
exec('run_game.bat', (err, stdout, stderr) => {
if (err) {
console.error(`exec error: ${err}`)
return;
}
});
}
})
</script>
</body>
</html>