-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.js
123 lines (116 loc) · 3.66 KB
/
config.js
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
var fs = require('fs');
var config = {
color: {
primaryColor: 'green',
secondaryColor: 'black',
successColor: 'green',
errorColor: 'red',
alertColor: 'yellow',
},
event: {
STATUS: '{bold}{green-fg}STATUS{/}',
ALERT: '{bold}{yellow-fg}ALERT{/}',
ERROR: '{bold}{red-fg}ERROR{/}'
},
imageName: 'ConanSandboxServer-Win64-Test.exe',
exeName: 'ConanSandboxServer.exe',
steamExeName: 'steamcmd.exe',
app_id: '443030',
app_id_news: '440900',
apiKey: 'F8D756B20828053B061B1F5467961F63',
game: {
serverName: {
value: '',
prompt_text: 'Server Name',
initial_value: ''
},
maxPlayers: {
value: '',
prompt_text: 'Maximum Players',
initial_value: '40'
},
port: {
value: '',
prompt_text: 'Game port (UDP)',
initial_value: '7777'
},
queryPort: {
value: '',
prompt_text: 'Steam port (UDP)',
initial_value: '27015'
},
steamCMDDir: {
value: '',
prompt_text: 'SteamCMD Directory',
initial_value: ''
},
serverDir: {
value: '',
prompt_text: 'Server EXE Directory',
initial_value: '',
no_space: true
},
workshopIDs: {
value: '',
prompt_text: 'Workshop IDs (Comma Seperated)',
initial_value: '',
}
},
autoUpdate: false,
autoRestart: false,
needUpdate: false
}
config.save = function() {
var configToSave = {} ;
configToSave.game = {} ;
configToSave.game.serverName = {}
configToSave.game.serverName.value = config.game.serverName.value ;
configToSave.game.maxPlayers = {}
configToSave.game.maxPlayers.value = config.game.maxPlayers.value ;
configToSave.game.port = {}
configToSave.game.port.value = config.game.port.value ;
configToSave.game.queryPort = {}
configToSave.game.queryPort.value = config.game.queryPort.value ;
configToSave.game.steamCMDDir = {}
configToSave.game.steamCMDDir.value = config.game.steamCMDDir.value ;
configToSave.game.serverDir = {}
configToSave.game.serverDir.value = config.game.serverDir.value;
configToSave.game.workshopIDs = {}
configToSave.game.workshopIDs.value = config.game.workshopIDs.value
configToSave.autoUpdate = config.autoUpdate ;
configToSave.autoRestart = config.autoRestart ;
configToSave.needUpdate = config.needUpdate ;
fs.writeFile('config.json', JSON.stringify(configToSave), {flag: 'w'}, function() {
});
}
config.load = function() {
try {
if ( fs.existsSync( 'config.json' ) ) {
var savedConfig = JSON.parse(fs.readFileSync('config.json')) ;
if ( savedConfig.game.serverName )
config.game.serverName.value = savedConfig.game.serverName.value ;
if ( savedConfig.game.maxPlayers )
config.game.maxPlayers.value = savedConfig.game.maxPlayers.value ;
if ( savedConfig.game.port )
config.game.port.value = savedConfig.game.port.value ;
if ( savedConfig.game.queryPort )
config.game.queryPort.value = savedConfig.game.queryPort.value ;
if ( savedConfig.game.steamCMDDir )
config.game.steamCMDDir.value = savedConfig.game.steamCMDDir.value ;
if ( savedConfig.game.serverDir )
config.game.serverDir.value = savedConfig.game.serverDir.value;
if ( savedConfig.game.workshopIDs )
config.game.workshopIDs.value = savedConfig.game.workshopIDs.value;
if ( savedConfig.autoUpdate )
config.autoUpdate = savedConfig.autoUpdate ;
if ( savedConfig.autoRestart )
config.autoRestart = savedConfig.autoRestart ;
if ( savedConfig.needUpdate )
config.needUpdate = savedConfig.needUpdate ;
}
} catch (err) {
fs.unlink('config.json');
}
}
config.load();
module.exports = config ;