Skip to content

Commit c077654

Browse files
author
Adrian Preuß
committed
updating create server view
1 parent 6865ac8 commit c077654

15 files changed

Lines changed: 270 additions & 4 deletions

File tree

Source/Assets/CSS/Style.css

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ body {
1515
}
1616

1717
background {
18+
display: block;
1819
background: url('../Background.jpg') no-repeat 50% 0;
1920
position: absolute;
2021
top: 1px;
@@ -45,6 +46,16 @@ header {
4546
padding: 8px;
4647
}
4748

49+
header h2 {
50+
color: #4b5f83;
51+
padding: 0;
52+
margin: 0;
53+
font-weight: normal;
54+
font-size: 20px;
55+
flex: auto;
56+
display: inline-block;
57+
}
58+
4859
header dragarea {
4960
position: absolute;
5061
top: 0px;
@@ -59,6 +70,10 @@ body[data-overlay="settings"] header dragarea {
5970
left: 290px;
6071
}
6172

73+
body[data-name="Server:Create"] header dragarea {
74+
left: 0px;
75+
}
76+
6277
header button[data-action^="window:"] {
6378
display: block;
6479
position: relative;
@@ -201,4 +216,111 @@ overlay[data-view="settings"] header button i {
201216

202217
overlay[data-view="settings"] header button:hover {
203218
color: #FFFFFF;
219+
}
220+
221+
/* Content */
222+
content {
223+
display: block;
224+
position: absolute;
225+
top: 40px;
226+
left: 1px;
227+
right: 1px;
228+
bottom: 1px;
229+
padding: 10px;
230+
}
231+
232+
/* Content :: Form */
233+
content form {}
234+
235+
content form entry {
236+
display: block;
237+
}
238+
239+
content form entry.buttons {
240+
text-align: right;
241+
padding: 10px 0 0 0;
242+
}
243+
244+
content form entry label {
245+
display: block;
246+
color: #FFFFFF;
247+
font-size: 14px;
248+
}
249+
250+
content form entry input[type="text"], content form entry input[type="password"] {
251+
background: #454545;
252+
border: 1px solid #454545;
253+
padding: 4px;
254+
display: block;
255+
margin: 6px 0 2px 0;
256+
width: 100%;
257+
color: #FFFFFF;
258+
}
259+
260+
content form entry input[type="text"]:hover, content form entry input[type="password"]:hover {
261+
border-color: #FFFFFF;
262+
}
263+
264+
content form entry input[type="text"]:active, content form entry input[type="password"]:active {
265+
border-color: #484848;
266+
}
267+
268+
content form entry button {
269+
border: none;
270+
position: relative;
271+
margin: 0 0 0 0;
272+
text-align: right !important;
273+
color: #DDDDDD;
274+
background: transparent;
275+
cursor: pointer;
276+
}
277+
278+
content form entry button i {
279+
font-size: 16px !important;
280+
vertical-align: middle;
281+
margin: -4px 0 0 0;
282+
}
283+
284+
content form entry button:hover {
285+
color: #FFFFFF;
286+
}
287+
288+
/* Content :: Selection */
289+
content selection {
290+
height: 95px;
291+
max-width: 100%;
292+
-webkit-overflow-scrolling: touch;
293+
overflow-x: auto;
294+
text-align: center;
295+
white-space: nowrap;
296+
display: block;
297+
margin: 0 0 5px 0;
298+
}
299+
300+
content selection ul {
301+
list-style: none;
302+
margin: 0;
303+
padding: 0;
304+
height: 100%;
305+
}
306+
307+
content selection ul li {
308+
float: left;
309+
width: 80px;
310+
height: 100%;
311+
text-align: center;
312+
cursor: pointer;
313+
background-size: 75% auto;
314+
display: inline-block;
315+
background-repeat: no-repeat;
316+
background-position: 50% 50%;
317+
}
318+
319+
content selection ul li.selected {
320+
background-size: 100% auto;
321+
}
322+
323+
content selection ul li.active {
324+
color: #fff;
325+
background: #a03232;
204326
}

Source/Classes/Core.js

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
(function Core() {
2+
var _file_system = require('fs');
3+
var _path = require('path');
4+
var _gui = require('nw.gui');
5+
var _games = {};
6+
27
this.init = function init() {
3-
var gui = require('nw.gui');
4-
var win = gui.Window.get();
8+
var win = _gui.Window.get();
59

610
document.addEventListener('click', function onClick(event) {
711
if(!event) {
@@ -12,6 +16,21 @@
1216

1317
if(typeof(parent) != 'undefined' && typeof(parent.dataset) != 'undefined' && typeof(parent.dataset.action) != 'undefined') {
1418
switch(parent.dataset.action) {
19+
case 'selection':
20+
var name = parent.dataset.name;
21+
var selection = Tools.getClosest(parent, 'selection');
22+
selection.dataset.selected = name;
23+
24+
[].forEach.call(selection.querySelectorAll('li'), function(element) {
25+
if(element.classList.contains('selected')) {
26+
element.classList.remove('selected');
27+
}
28+
});
29+
30+
parent.classList.add('selected');
31+
break;
32+
33+
/* Window */
1534
case 'window:close':
1635
win.close(true);
1736
break
@@ -26,18 +45,62 @@
2645
case 'window:minimize':
2746
win.minimize();
2847
break;
48+
49+
/* Settings */
2950
case 'settings:save':
3051
case 'settings:close':
3152
case 'settings:toggle':
3253
var element = document.querySelector('overlay[data-view="settings"]');
3354
element.classList.toggle('show');
3455
this.checkOverlay();
3556
break;
57+
58+
/* Server */
59+
case 'server:create':
60+
_gui.Window.open('Views/Server/Create.html', {
61+
focus: true,
62+
position: 'center',
63+
width: 300,
64+
height: 375,
65+
frame: false,
66+
resizable: false
67+
});
68+
break;
3669
}
3770
}
3871
}.bind(this));
3972

73+
_games = this.getGames();
74+
4075
this.checkOverlay();
76+
77+
if(document.body.dataset.name == 'Server:Create') {
78+
var selection = document.querySelector('content selection');
79+
var list = document.querySelector('content selection ul');
80+
var games = Object.keys(_games);
81+
var size = 80;
82+
83+
games.forEach(function(name) {
84+
var game = _games[name];
85+
var selected = false;
86+
87+
if(selection.dataset.selected == 'none') {
88+
selection.dataset.selected = name;
89+
selected = true;
90+
}
91+
92+
list.innerHTML += '<li data-action="selection" data-name="' + name + '" style="background-image: url(\'file:///' + game.path.replace(/\\/g, '/') + 'logo.png\');" title="' + game.title + '" class="' + (selected ? 'selected' : '') + '"></li>';
93+
});
94+
95+
list.style.width = (games.length * size) + 'px';
96+
97+
selection.addEventListener('mousewheel', function onScroll(event) {
98+
event = window.event || event;
99+
var delta = Math.max(-1, Math.min(1, (event.wheelDelta || -event.detail)));
100+
selection.scrollLeft -= (delta * size);
101+
event.preventDefault();
102+
}, false);
103+
}
41104
};
42105

43106
this.checkOverlay = function checkOverlay() {
@@ -51,5 +114,18 @@
51114
});
52115
};
53116

117+
this.getGames = function getGames() {
118+
var games = {};
119+
var files = _file_system.readdirSync(process.cwd() + _path.sep + 'Classes' + _path.sep + 'Games' + _path.sep);
120+
121+
files.forEach(function(name) {
122+
var config = require(process.cwd() + _path.sep + 'Classes' + _path.sep + 'Games' + _path.sep + name + _path.sep + 'config.json');
123+
config.path = process.cwd() + _path.sep + 'Classes' + _path.sep + 'Games' + _path.sep + name + _path.sep;
124+
games[name] = config;
125+
});
126+
127+
return games;
128+
};
129+
54130
this.init();
55131
}());
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"title": "Battlefield 1",
3+
"engine": "frostbite3"
4+
}

Source/Classes/Games/BF1/logo.png

68.4 KB
Loading
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"title": "Battlefield 3",
3+
"engine": "frostbite3"
4+
}

Source/Classes/Games/BF3/logo.png

134 KB
Loading
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"title": "Battlefield 4",
3+
"engine": "frostbite3"
4+
}

Source/Classes/Games/BF4/logo.png

156 KB
Loading
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"title": "Battlefield: Bad Company 2",
3+
"engine": "frostbite2"
4+
}
98.5 KB
Loading

0 commit comments

Comments
 (0)