|
1
|
|
|
# |
|
2
|
|
|
# Copyright 2001 - 2016 Ludek Smid [http://www.ospace.net/] |
|
3
|
|
|
# |
|
4
|
|
|
# This file is part of Outer Space. |
|
5
|
|
|
# |
|
6
|
|
|
# Outer Space is free software; you can redistribute it and/or modify |
|
7
|
|
|
# it under the terms of the GNU General Public License as published by |
|
8
|
|
|
# the Free Software Foundation; either version 2 of the License, or |
|
9
|
|
|
# (at your option) any later version. |
|
10
|
|
|
# |
|
11
|
|
|
# Outer Space is distributed in the hope that it will be useful, |
|
12
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14
|
|
|
# GNU General Public License for more details. |
|
15
|
|
|
# |
|
16
|
|
|
# You should have received a copy of the GNU General Public License |
|
17
|
|
|
# along with Outer Space; if not, write to the Free Software |
|
18
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
19
|
|
|
# |
|
20
|
|
|
|
|
21
|
|
|
import os |
|
22
|
|
|
import os.path |
|
23
|
|
|
import gettext |
|
24
|
|
|
import re |
|
25
|
|
|
|
|
26
|
|
|
import pygame |
|
27
|
|
|
import pygameui as ui |
|
28
|
|
|
from osci import client, gdata, res |
|
29
|
|
|
import ige.ospace.Const as Const |
|
30
|
|
|
from ige import log |
|
31
|
|
|
import resources |
|
32
|
|
|
|
|
33
|
|
|
from ChangePasswordDlg import ChangePasswordDlg |
|
34
|
|
|
|
|
35
|
|
|
class OptionsDlg: |
|
36
|
|
|
"""Displays options dialog. |
|
37
|
|
|
|
|
38
|
|
|
Dialog can change display flags, display resolution, client language |
|
39
|
|
|
and proxy settings. |
|
40
|
|
|
Proxy can have one of following formats: |
|
41
|
|
|
http://username:password@host:port |
|
42
|
|
|
http://username@host:port |
|
43
|
|
|
http://host:port |
|
44
|
|
|
http://host |
|
45
|
|
|
where port must be integer value. |
|
46
|
|
|
Options are saved to file imediately, after users press OK button. |
|
47
|
|
|
""" |
|
48
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
def __init__(self, app): |
|
51
|
|
|
self.app = app |
|
52
|
|
|
self.changePasswordDlg = ChangePasswordDlg(app) |
|
53
|
|
|
self.languages = {} |
|
54
|
|
|
self.languages['en']=_('English') |
|
55
|
|
|
self.languages['cs']=_('Czech') |
|
56
|
|
|
self.languages['fr']=_('French') |
|
57
|
|
|
self.languages['de']=_('German') |
|
58
|
|
|
self.resolutions = ["FULLSCREEN", "800x600", "1024x768", "1280x800", "1280x1024", "1366x768", "1440x900","1400x1050","1600x900","1680x1050","1600x1200","1920x1080","1920x1200"] |
|
59
|
|
|
self.curLang = gdata.config.client.language |
|
60
|
|
|
self.createUI() |
|
61
|
|
|
|
|
62
|
|
|
def display(self, caller = None, message = None): |
|
63
|
|
|
self.caller = caller |
|
64
|
|
|
if message is not None: |
|
65
|
|
|
self.win.setStatus(message) |
|
66
|
|
|
self.show() |
|
67
|
|
|
# show window |
|
68
|
|
|
if not self.win.visible: |
|
69
|
|
|
self.win.show() |
|
70
|
|
|
|
|
71
|
|
|
def hide(self): |
|
72
|
|
|
self.win.setStatus(_("Ready.")) |
|
73
|
|
|
self.win.hide() |
|
74
|
|
|
|
|
75
|
|
|
def update(self): |
|
76
|
|
|
if self.win.visible: |
|
77
|
|
|
self.show() |
|
78
|
|
|
|
|
79
|
|
|
def show(self): |
|
80
|
|
|
# reading resolution info |
|
81
|
|
|
if gdata.config.display.resolution != None: |
|
82
|
|
|
resolution = gdata.config.display.resolution |
|
83
|
|
|
self.win.vResolution2.text = resolution |
|
84
|
|
|
|
|
85
|
|
|
self.win.vResolution.text = _("Select Mode") |
|
86
|
|
|
self.win.vResolution.action = "onSelectResolution" |
|
87
|
|
|
|
|
88
|
|
|
# reading client language |
|
89
|
|
|
if gdata.config.client.language != None: |
|
90
|
|
|
lang = gdata.config.client.language |
|
91
|
|
|
try: |
|
92
|
|
|
self.win.vLangSel.text = self.languages[lang] |
|
93
|
|
|
except: |
|
94
|
|
|
self.win.vLangSel.text = lang |
|
95
|
|
|
|
|
96
|
|
|
# reading proxy settings |
|
97
|
|
|
if gdata.config.proxy.http != None: |
|
98
|
|
|
proxy = gdata.config.proxy.http |
|
99
|
|
|
m = re.match('^http://(.*?):(.*?)@(.*?):(\d+)', proxy) |
|
100
|
|
|
host = '' |
|
101
|
|
|
port = '' |
|
102
|
|
|
username = '' |
|
103
|
|
|
password = '' |
|
104
|
|
|
if m == None: |
|
105
|
|
|
m = re.match('^http://(.*?)@(.*?):(\d+)', proxy) |
|
106
|
|
|
if m == None: |
|
107
|
|
|
m = re.match('^http://(.*?):(\d+)', proxy) |
|
108
|
|
|
if m == None: |
|
109
|
|
|
m = re.match('^http://(.*?)', proxy) |
|
110
|
|
|
if m != None: |
|
111
|
|
|
host = m.group(1) |
|
112
|
|
|
else: |
|
113
|
|
|
host = m.group(1) |
|
114
|
|
|
port = m.group(2) |
|
115
|
|
|
else: |
|
116
|
|
|
username = m.group(1) |
|
117
|
|
|
host = m.group(2) |
|
118
|
|
|
port = m.group(3) |
|
119
|
|
|
else: |
|
120
|
|
|
username = m.group(1) |
|
121
|
|
|
password = m.group(2) |
|
122
|
|
|
host = m.group(3) |
|
123
|
|
|
port = m.group(4) |
|
124
|
|
|
|
|
125
|
|
|
self.win.vProxyHost.text = host |
|
126
|
|
|
self.win.vProxyPort.text = port |
|
127
|
|
|
self.win.vProxyUsername.text = username |
|
128
|
|
|
self.win.vProxyPassword.text = password |
|
129
|
|
|
|
|
130
|
|
|
self.win.vTheme.text = _("Select Theme") |
|
131
|
|
|
self.win.vTheme2.text = gdata.config.client.theme |
|
132
|
|
|
self.win.vTheme.action = "onSelectTheme" |
|
133
|
|
|
|
|
134
|
|
|
# reading defaults |
|
135
|
|
|
if gdata.config.defaults.reportfinalization != None: |
|
136
|
|
|
val = gdata.config.defaults.reportfinalization |
|
137
|
|
|
self.win.vReportFin.checked = val == 'yes' |
|
138
|
|
|
|
|
139
|
|
|
if gdata.config.defaults.showredirects != None: |
|
140
|
|
|
val = gdata.config.defaults.showredirects |
|
141
|
|
|
self.win.vRedirects.checked = val == 'yes' |
|
142
|
|
|
|
|
143
|
|
|
if gdata.config.defaults.showcoords != None: |
|
144
|
|
|
val = gdata.config.defaults.showcoords |
|
145
|
|
|
self.win.vCoords.checked = val == 'yes' |
|
146
|
|
|
|
|
147
|
|
|
if gdata.config.defaults.highlights != None: |
|
148
|
|
|
val = gdata.config.defaults.highlights |
|
149
|
|
|
self.win.vHighlights.checked = val == 'yes' |
|
150
|
|
|
|
|
151
|
|
|
if gdata.config.defaults.displayhelp != None: |
|
152
|
|
|
val = gdata.config.defaults.displayhelp |
|
153
|
|
|
self.win.vDisplayHelp.checked = val == 'yes' |
|
154
|
|
|
|
|
155
|
|
|
if gdata.config.defaults.showminimap != None: |
|
156
|
|
|
val = gdata.config.defaults.showminimap |
|
157
|
|
|
self.win.vShowMinimap.checked = val == 'yes' |
|
158
|
|
|
|
|
159
|
|
|
if gdata.config.defaults.showgatesystems != None: |
|
160
|
|
|
val = gdata.config.defaults.showgatesystems |
|
161
|
|
|
self.win.vShowGateSystems.checked = val == 'yes' |
|
162
|
|
|
|
|
163
|
|
|
if gdata.config.defaults.showmapgrid != None: |
|
164
|
|
|
val = gdata.config.defaults.showmapgrid |
|
165
|
|
|
self.win.vShowMapGrid.checked = val == 'yes' |
|
166
|
|
|
|
|
167
|
|
|
if gdata.config.defaults.showmapscanners != None: |
|
168
|
|
|
val = gdata.config.defaults.showmapscanners |
|
169
|
|
|
self.win.vShowMapScanners.checked = val == 'yes' |
|
170
|
|
|
|
|
171
|
|
|
if gdata.config.defaults.showfleetlines != None: |
|
172
|
|
|
val = gdata.config.defaults.showfleetlines |
|
173
|
|
|
self.win.vShowMapFleetLines.checked = val == 'yes' |
|
174
|
|
|
|
|
175
|
|
|
if gdata.config.defaults.alternateviewmode != None: |
|
176
|
|
|
val = gdata.config.defaults.alternateviewmode |
|
177
|
|
|
self.win.vShowAlternateView.checked = val == 'yes' |
|
178
|
|
|
|
|
179
|
|
|
if gdata.config.defaults.showPlayerZones != None: |
|
180
|
|
|
val = gdata.config.defaults.showplayerzones |
|
181
|
|
|
self.win.vShowPlayerZones.checked = val == 'yes' |
|
182
|
|
|
|
|
183
|
|
|
# login defaults |
|
184
|
|
|
self.win.vAutoLogin.enabled = False |
|
185
|
|
|
if gdata.savePassword: |
|
186
|
|
|
self.win.vSavePassword.enabled = True |
|
187
|
|
|
self.win.vSavePassword.checked = True |
|
188
|
|
|
self.win.vAutoLogin.enabled = True |
|
189
|
|
|
elif (gdata.config.game.lastpasswordcrypted != None) and (gdata.config.game.lastpasswordcrypted != ''): |
|
190
|
|
|
self.win.vSavePassword.enabled = True |
|
191
|
|
|
self.win.vSavePassword.checked = False |
|
192
|
|
|
else: |
|
193
|
|
|
self.win.vSavePassword.enabled = False |
|
194
|
|
|
self.win.vSavePassword.checked = False |
|
195
|
|
|
|
|
196
|
|
|
if gdata.config.game.autologin != None: |
|
197
|
|
|
val = gdata.config.game.autologin |
|
198
|
|
|
if self.win.vAutoLogin.enabled: |
|
199
|
|
|
self.win.vAutoLogin.checked = val == 'yes' |
|
200
|
|
|
|
|
201
|
|
|
# sounds/music |
|
202
|
|
|
if gdata.config.defaults.sound != None: |
|
203
|
|
|
val = gdata.config.defaults.sound |
|
204
|
|
|
else: |
|
205
|
|
|
val = "no" |
|
206
|
|
|
self.win.vSoundEnabled.checked = val == "yes" |
|
207
|
|
|
self.win.vSoundVolume.slider.min = 0 |
|
208
|
|
|
self.win.vSoundVolume.slider.max = 110 |
|
209
|
|
|
if gdata.config.defaults.soundvolume != None: |
|
210
|
|
|
val = float(gdata.config.defaults.soundvolume) |
|
211
|
|
|
else: |
|
212
|
|
|
val = 100 |
|
213
|
|
|
self.win.vSoundVolume.slider.position = val |
|
214
|
|
|
# disabled because of a bug in pygame |
|
215
|
|
|
self.win.vSoundEnabled.enabled = False |
|
216
|
|
|
self.win.vSoundVolume.enabled = False |
|
217
|
|
|
|
|
218
|
|
|
if gdata.config.defaults.music != None: |
|
219
|
|
|
val = gdata.config.defaults.music |
|
220
|
|
|
else: |
|
221
|
|
|
val = "no" |
|
222
|
|
|
self.win.vMusicEnabled.checked = val == "yes" |
|
223
|
|
|
self.win.vMusicVolume.slider.min = 0 |
|
224
|
|
|
self.win.vMusicVolume.slider.max = 110 |
|
225
|
|
|
if gdata.config.defaults.musicvolume != None: |
|
226
|
|
|
val = float(gdata.config.defaults.musicvolume) |
|
227
|
|
|
else: |
|
228
|
|
|
val = 100 |
|
229
|
|
|
self.win.vMusicVolume.slider.position = val |
|
230
|
|
|
# disabled because of a bug in pygame |
|
231
|
|
|
self.win.vMusicEnabled.enabled = False |
|
232
|
|
|
self.win.vMusicVolume.enabled = False |
|
233
|
|
|
|
|
234
|
|
|
self.win.vChangePassword.enabled = client.db is not None |
|
235
|
|
|
|
|
236
|
|
|
def onCancel(self, widget, action, data): |
|
237
|
|
|
self.hide() |
|
238
|
|
|
if self.caller: |
|
239
|
|
|
self.caller.display() |
|
240
|
|
|
|
|
241
|
|
|
def onOK(self, widget, action, data): |
|
242
|
|
|
# set client language |
|
243
|
|
|
gdata.config.client.language = self.curLang |
|
244
|
|
|
|
|
245
|
|
|
# set proxy |
|
246
|
|
|
host = self.win.vProxyHost.text |
|
247
|
|
|
port = self.win.vProxyPort.text |
|
248
|
|
|
username = self.win.vProxyUsername.text |
|
249
|
|
|
password = self.win.vProxyPassword.text |
|
250
|
|
|
|
|
251
|
|
|
proxy = '' |
|
252
|
|
|
# host must be always present |
|
253
|
|
|
if len(host) > 0: |
|
254
|
|
|
proxy += host |
|
255
|
|
|
if len(port) > 0: |
|
256
|
|
|
proxy += ':' |
|
257
|
|
|
proxy += port |
|
258
|
|
|
if len(password) > 0 and len(username): |
|
259
|
|
|
proxy = username + ':' + password + '@' + proxy |
|
260
|
|
|
elif len(username) > 0: |
|
261
|
|
|
proxy = username + '@' + proxy |
|
262
|
|
|
|
|
263
|
|
|
if len(proxy) > 0: |
|
264
|
|
|
proxy = 'http://' + proxy |
|
265
|
|
|
|
|
266
|
|
|
if len(proxy) > 0: |
|
267
|
|
|
gdata.config.proxy.http = proxy |
|
268
|
|
|
else: |
|
269
|
|
|
# if host not present, delete proxy section |
|
270
|
|
|
gdata.config.proxy = None |
|
271
|
|
|
|
|
272
|
|
|
# defaults |
|
273
|
|
|
gdata.config.defaults.reportfinalization = 'yes' if self.win.vReportFin.checked else 'no' |
|
274
|
|
|
gdata.config.defaults.showredirects = 'yes' if self.win.vRedirects.checked else 'no' |
|
275
|
|
|
gdata.config.defaults.showcoords = 'yes' if self.win.vCoords.checked else 'no' |
|
276
|
|
|
gdata.config.defaults.highlights = 'yes' if self.win.vHighlights.checked else 'no' |
|
277
|
|
|
gdata.config.defaults.displayhelp = 'yes' if self.win.vDisplayHelp.checked else 'no' |
|
278
|
|
|
gdata.config.defaults.showminimap = 'yes' if self.win.vShowMinimap.checked else 'no' |
|
279
|
|
|
gdata.config.defaults.showgatesystems = 'yes' if self.win.vShowGateSystems.checked else 'no' |
|
280
|
|
|
gdata.config.defaults.showmapgrid = 'yes' if self.win.vShowMapGrid.checked else 'no' |
|
281
|
|
|
gdata.config.defaults.showmapscanners = 'yes' if self.win.vShowMapScanners.checked else 'no' |
|
282
|
|
|
gdata.config.defaults.showfleetlines = 'yes' if self.win.vShowMapFleetLines.checked else 'no' |
|
283
|
|
|
gdata.config.defaults.alternateviewmode = 'yes' if self.win.vShowAlternateView.checked else 'no' |
|
284
|
|
|
gdata.config.defaults.showplayerzones = 'yes' if self.win.vShowPlayerZones.checked else 'no' |
|
285
|
|
|
|
|
286
|
|
|
gdata.config.defaults.sound = 'yes' if self.win.vSoundEnabled.checked else 'no' |
|
287
|
|
|
gdata.config.defaults.soundvolume = self.win.vSoundVolume.slider.position |
|
288
|
|
|
gdata.config.defaults.music = 'yes' if self.win.vMusicEnabled.checked else 'no' |
|
289
|
|
|
gdata.config.defaults.musicvolume = self.win.vMusicVolume.slider.position |
|
290
|
|
|
|
|
291
|
|
|
gdata.config.game.autologin = 'yes' if self.win.vAutoLogin.checked else 'no' |
|
292
|
|
|
|
|
293
|
|
|
if self.win.vSavePassword.checked: |
|
294
|
|
|
gdata.savePassword = True |
|
295
|
|
|
else: |
|
296
|
|
|
gdata.savePassword = False |
|
297
|
|
|
gdata.config.game.lastpasswordcrypted = None |
|
298
|
|
|
|
|
299
|
|
|
ui.SkinableTheme.enableMusic(self.win.vMusicEnabled.checked) |
|
300
|
|
|
ui.SkinableTheme.enableSound(self.win.vSoundEnabled.checked) |
|
301
|
|
|
|
|
302
|
|
|
self.hide() |
|
303
|
|
|
if self.caller: |
|
304
|
|
|
self.caller.display() # Redisplay login dlg |
|
305
|
|
|
elif gdata.mainGameDlg: |
|
306
|
|
|
gdata.mainGameDlg.update(configUpdated=True) # redraw screen (highlights etc) |
|
307
|
|
|
|
|
308
|
|
|
def onSelectTheme(self, widget, action, data): |
|
309
|
|
|
items = [] |
|
310
|
|
|
themeDir = resources.get("themes") |
|
311
|
|
|
for term in os.listdir(themeDir): |
|
312
|
|
|
if os.path.isfile(os.path.join(themeDir, term, "config.ini")) and not term.startswith("."): |
|
313
|
|
|
item = ui.Item(term, tTheme = term) |
|
314
|
|
|
items.append(item) |
|
315
|
|
|
self.twin.vThemes.items = items |
|
316
|
|
|
self.twin.vThemes.itemsChanged() |
|
317
|
|
|
self.twin.show() |
|
318
|
|
|
|
|
319
|
|
|
def onThemeCancel(self, widget, action, data): |
|
320
|
|
|
self.twin.hide() |
|
321
|
|
|
|
|
322
|
|
|
def onThemeSelected(self, widget, action, data): |
|
323
|
|
|
self.recipientObjID = [] |
|
324
|
|
|
text = "" |
|
325
|
|
|
if not self.twin.vThemes.selection: |
|
326
|
|
|
return |
|
327
|
|
|
curTheme = self.twin.vThemes.selection[0].tTheme |
|
328
|
|
|
# set theme for ui |
|
329
|
|
|
ui.SkinableTheme.setSkin(os.path.join(resources.get("themes"), curTheme)) |
|
330
|
|
|
res.prepareUIIcons(ui.SkinableTheme.themeIcons) |
|
331
|
|
|
ui.SkinableTheme.loadMusic(gdata.config.defaults.mymusic) |
|
332
|
|
|
ui.SkinableTheme.playMusic() |
|
333
|
|
|
# update foreground colors |
|
334
|
|
|
gdata.sevColors[gdata.CRI] = (ui.SkinableTheme.themeCritical) |
|
335
|
|
|
gdata.sevColors[gdata.MAJ] = (ui.SkinableTheme.themeMajor) |
|
336
|
|
|
gdata.sevColors[gdata.MIN] = (ui.SkinableTheme.themeMinor) |
|
337
|
|
|
gdata.sevColors[gdata.NONE] = (ui.SkinableTheme.themeNone) |
|
338
|
|
|
gdata.sevColors[gdata.DISABLED] = (ui.SkinableTheme.themeDisabled) |
|
339
|
|
|
# all OK? (no exception) -> store settings |
|
340
|
|
|
gdata.config.client.theme = curTheme |
|
341
|
|
|
self.win.vTheme2.text = curTheme |
|
342
|
|
|
self.twin.hide() |
|
343
|
|
|
|
|
344
|
|
|
def onSelectLanguage(self, widget, action, data): |
|
345
|
|
|
items = [] |
|
346
|
|
|
items.append(ui.Item(self.languages['en'],tLanguage = 'en')) |
|
347
|
|
|
langDir = resources.get('translations') |
|
348
|
|
|
for term in os.listdir(langDir): |
|
349
|
|
|
if os.path.isfile(os.path.join(langDir, term,"LC_MESSAGES", "OSPACE.mo")) and not term.startswith("."): |
|
350
|
|
|
if self.languages.has_key(term): |
|
351
|
|
|
item = ui.Item(self.languages[term], tLanguage = term) |
|
352
|
|
|
else: |
|
353
|
|
|
item = ui.Item(term, tLanguage = term) |
|
354
|
|
|
items.append(item) |
|
355
|
|
|
self.lwin.vLanguages.items = items |
|
356
|
|
|
self.lwin.vLanguages.itemsChanged() |
|
357
|
|
|
self.lwin.show() |
|
358
|
|
|
|
|
359
|
|
|
def onLanguageCancel(self, widget, action, data): |
|
360
|
|
|
self.lwin.hide() |
|
361
|
|
|
|
|
362
|
|
|
def onLanguageSelected(self, widget, action, data): |
|
363
|
|
|
self.recipientObjID = [] |
|
364
|
|
|
text = "" |
|
365
|
|
|
if not self.lwin.vLanguages.selection: |
|
366
|
|
|
return |
|
367
|
|
|
self.curLang = self.lwin.vLanguages.selection[0].tLanguage |
|
368
|
|
|
self.lwin.hide() |
|
369
|
|
|
if self.curLang == 'en': |
|
370
|
|
|
tran = gettext.NullTranslations() |
|
371
|
|
|
else: |
|
372
|
|
|
tran = gettext.translation('OSPACE', resources.get('translations'), languages = [self.curLang]) |
|
373
|
|
|
tran.install(unicode = 1) |
|
374
|
|
|
try: |
|
375
|
|
|
self.win.vLangSel.text = self.languages[self.curLang] |
|
376
|
|
|
except: |
|
377
|
|
|
self.win.vLangSel.text = self.curLang |
|
378
|
|
|
self.win.setStatus(_("You should restart client to change the language.")) |
|
379
|
|
|
|
|
380
|
|
|
|
|
381
|
|
|
def onSelectResolution(self, widget, action, data): |
|
382
|
|
|
items = [] |
|
383
|
|
|
for mode in self.resolutions: |
|
384
|
|
|
items.append(ui.Item(mode,tRes = mode)) |
|
385
|
|
|
self.reswin.vResolutions.items = items |
|
386
|
|
|
self.reswin.vResolutions.itemsChanged() |
|
387
|
|
|
self.reswin.show() |
|
388
|
|
|
|
|
389
|
|
|
def onResolutionCancel(self, widget, action, data): |
|
390
|
|
|
self.reswin.hide() |
|
391
|
|
|
|
|
392
|
|
|
def onResolutionSelected(self, widget, action, data): |
|
393
|
|
|
if not self.reswin.vResolutions.selection: |
|
394
|
|
|
return |
|
395
|
|
|
curMode = self.reswin.vResolutions.selection[0].tRes |
|
396
|
|
|
if curMode != "FULLSCREEN": |
|
397
|
|
|
try: |
|
398
|
|
|
width,height = curMode.split('x') |
|
399
|
|
|
except: |
|
400
|
|
|
self.win.setStatus(_("The mode you selected is not properly formatted.")) |
|
401
|
|
|
gdata.config.display.resolution = curMode |
|
402
|
|
|
self.win.vResolution2.text = curMode |
|
403
|
|
|
self.reswin.hide() |
|
404
|
|
|
self.win.setStatus(_("You have to restart client to change the resolution.")) |
|
405
|
|
|
|
|
406
|
|
|
def onChangeMusicVolume(self, widget, action, data): |
|
407
|
|
|
ui.SkinableTheme.setMusicVolume(float(self.win.vMusicVolume.slider.position) / 100.0) |
|
408
|
|
|
|
|
409
|
|
|
def onChangeSoundVolume(self, widget, action, data): |
|
410
|
|
|
ui.SkinableTheme.enableSound(self.win.vSoundEnabled.checked) |
|
411
|
|
|
ui.SkinableTheme.setVolume(self.win.vSoundVolume.slider.position / 100.0) |
|
412
|
|
|
|
|
413
|
|
|
def onChangeSavePassword(self, widget, action, data): |
|
414
|
|
|
if self.win.vSavePassword.checked: |
|
415
|
|
|
self.win.vAutoLogin.enabled = True |
|
416
|
|
|
else: |
|
417
|
|
|
self.win.vAutoLogin.enabled = False |
|
418
|
|
|
self.win.vAutoLogin.checked = False |
|
419
|
|
|
|
|
420
|
|
|
def onChangePassword(self, widget, action, data): |
|
421
|
|
|
self.changePasswordDlg.display(self) |
|
422
|
|
|
|
|
423
|
|
|
def createUI(self): |
|
424
|
|
|
screenWidth, screenHeight = gdata.scrnSize |
|
425
|
|
|
# size of dialog in layout metrics (for SimpleGridLM) |
|
426
|
|
|
cols = 33 |
|
427
|
|
|
rows = 18 |
|
428
|
|
|
# dialog width and height in pixels |
|
429
|
|
|
width = cols * 20 + 5 |
|
430
|
|
|
height = rows * 20 + 4 |
|
431
|
|
|
#creating dialog window |
|
432
|
|
|
self.win = ui.Window(self.app, |
|
433
|
|
|
modal = 1, |
|
434
|
|
|
escKeyClose = 1, |
|
435
|
|
|
movable = 0, |
|
436
|
|
|
title = _("Options"), |
|
437
|
|
|
rect = ui.Rect((screenWidth - width) / 2, (screenHeight - height) / 2, width, height), |
|
438
|
|
|
layoutManager = ui.SimpleGridLM(), |
|
439
|
|
|
tabChange = True |
|
440
|
|
|
) |
|
441
|
|
|
self.win.subscribeAction('*', self) |
|
442
|
|
|
# first row is window title |
|
443
|
|
|
rows -= 1 |
|
444
|
|
|
|
|
445
|
|
|
# Resolution |
|
446
|
|
|
ui.Title(self.win, layout = (1, 1, 5, 1), text = _('Resolution'), |
|
447
|
|
|
align = ui.ALIGN_NONE, font = 'normal-bold') |
|
448
|
|
|
|
|
449
|
|
|
ui.Button(self.win, layout = (1, 2, 5, 1), id = "vResolution", align = ui.ALIGN_W) |
|
450
|
|
|
ui.ActiveLabel(self.win, layout = (1, 3, 5, 1), id = "vResolution2") |
|
451
|
|
|
width = 304 # 15 * 20 + 4 |
|
452
|
|
|
height = 264 # 13 * 20 + 4 |
|
453
|
|
|
self.reswin = ui.Window(self.app, |
|
454
|
|
|
modal = 1, |
|
455
|
|
|
escKeyClose = 1, |
|
456
|
|
|
titleOnly = 0, |
|
457
|
|
|
movable = 0, |
|
458
|
|
|
title = _("Select resolution"), |
|
459
|
|
|
rect = ui.Rect((screenWidth - width) / 2, (screenHeight - height) / 2, width, height), |
|
460
|
|
|
layoutManager = ui.SimpleGridLM(), |
|
461
|
|
|
) |
|
462
|
|
|
self.reswin.subscribeAction('*', self) |
|
463
|
|
|
# rename |
|
464
|
|
|
ui.Listbox(self.reswin, layout = (0, 0, 15, 11), id = 'vResolutions', columnLabels = 0, |
|
465
|
|
|
columns = ((None, 'text', 0, ui.ALIGN_W),), multiselection = 0) |
|
466
|
|
|
# status bar + submit/cancel |
|
467
|
|
|
ui.TitleButton(self.reswin, layout = (10, 11, 5, 1), text = _("Select"), action = 'onResolutionSelected') |
|
468
|
|
|
ui.TitleButton(self.reswin, layout = (5, 11, 5, 1), text = _("Cancel"), action = 'onResolutionCancel') |
|
469
|
|
|
ui.Title(self.reswin, id = 'vStatusBar', layout = (0, 11, 5, 1), align = ui.ALIGN_W) |
|
470
|
|
|
|
|
471
|
|
|
# Languages |
|
472
|
|
|
ui.Title(self.win, layout = (1, 5, 5, 1), text = _('Language'), |
|
473
|
|
|
align = ui.ALIGN_NONE, font = 'normal-bold') |
|
474
|
|
|
try: |
|
475
|
|
|
longLang = self.languages[self.curLang] |
|
476
|
|
|
except: |
|
477
|
|
|
longLang = self.curLang |
|
478
|
|
|
ui.Button(self.win, layout = (1, 6, 5, 1), text = longLang, id = 'vLangSel', action = 'onSelectLanguage') |
|
479
|
|
|
lcols = 12 |
|
480
|
|
|
lrows = 6 |
|
481
|
|
|
width = lcols * 20 + 4 |
|
482
|
|
|
height = lrows * 20 + 4 |
|
483
|
|
|
self.lwin = ui.Window(self.app, |
|
484
|
|
|
modal = 1, |
|
485
|
|
|
escKeyClose = 1, |
|
486
|
|
|
titleOnly = 0, |
|
487
|
|
|
movable = 0, |
|
488
|
|
|
title = _("Select language"), |
|
489
|
|
|
rect = ui.Rect((screenWidth - width) / 2, (screenHeight - height) / 2, width, height), |
|
490
|
|
|
layoutManager = ui.SimpleGridLM(), |
|
491
|
|
|
) |
|
492
|
|
|
self.lwin.subscribeAction('*', self) |
|
493
|
|
|
# rename |
|
494
|
|
|
ui.Listbox(self.lwin, layout = (0, 0, lcols, lrows-2), id = 'vLanguages', columnLabels = 0, |
|
495
|
|
|
columns = ((None, 'text', 0, ui.ALIGN_W),), multiselection = 0, sortedBy=('text', 1)) |
|
496
|
|
|
# status bar + submit/cancel |
|
497
|
|
|
ui.TitleButton(self.lwin, layout = (lcols-5, lrows-2, 5, 1), text = _("Select"), action = 'onLanguageSelected') |
|
498
|
|
|
ui.TitleButton(self.lwin, layout = (lcols-10, lrows-2, 5, 1), text = _("Cancel"), action = 'onLanguageCancel') |
|
499
|
|
|
ui.Title(self.lwin, id = 'vStatusBar', layout = (0, lrows-2, lcols-10, 1), align = ui.ALIGN_W) |
|
500
|
|
|
|
|
501
|
|
|
# Theme |
|
502
|
|
|
ui.Title(self.win, layout = (1, 9, 5, 1), text = _('Themes'), |
|
503
|
|
|
align = ui.ALIGN_NONE, font = 'normal-bold') |
|
504
|
|
|
ui.Button(self.win, layout = (1, 10, 5, 1), id = "vTheme", align = ui.ALIGN_W) |
|
505
|
|
|
ui.ActiveLabel(self.win, layout = (1, 11, 5, 1), id = "vTheme2") |
|
506
|
|
|
width = 304 # 15 * 20 + 4 |
|
507
|
|
|
height = 264 # 13 * 20 + 4 |
|
508
|
|
|
self.twin = ui.Window(self.app, |
|
509
|
|
|
modal = 1, |
|
510
|
|
|
escKeyClose = 1, |
|
511
|
|
|
titleOnly = 0, |
|
512
|
|
|
movable = 0, |
|
513
|
|
|
title = _("Select theme"), |
|
514
|
|
|
rect = ui.Rect((screenWidth - width) / 2, (screenHeight - height) / 2, width, height), |
|
515
|
|
|
layoutManager = ui.SimpleGridLM(), |
|
516
|
|
|
) |
|
517
|
|
|
self.twin.subscribeAction('*', self) |
|
518
|
|
|
|
|
519
|
|
|
# rename |
|
520
|
|
|
ui.Listbox(self.twin, layout = (0, 0, 15, 11), id = 'vThemes', columnLabels = 0, |
|
521
|
|
|
columns = ((None, 'text', 0, ui.ALIGN_W),), multiselection = 0, sortedBy=('text', 1)) |
|
522
|
|
|
# status bar + submit/cancel |
|
523
|
|
|
ui.TitleButton(self.twin, layout = (10, 11, 5, 1), text = _("Select"), action = 'onThemeSelected') |
|
524
|
|
|
ui.TitleButton(self.twin, layout = (5, 11, 5, 1), text = _("Cancel"), action = 'onThemeCancel') |
|
525
|
|
|
ui.Title(self.twin, id = 'vStatusBar', layout = (0, 11, 5, 1), align = ui.ALIGN_W) |
|
526
|
|
|
|
|
527
|
|
|
# Defaults |
|
528
|
|
|
ui.Title(self.win, layout = (7, 7, 25, 1), text = _('Default settings'), |
|
529
|
|
|
align = ui.ALIGN_NONE, font = 'normal-bold') |
|
530
|
|
|
ui.Check(self.win, layout = (7, 8, 8, 1), text = _('Report finalization'), id = 'vReportFin', |
|
531
|
|
|
checked = 0) |
|
532
|
|
|
ui.Check(self.win, layout = (15, 8, 8, 1), text = _('Display help/tooltip'), id = 'vDisplayHelp', |
|
533
|
|
|
checked = 1) |
|
534
|
|
|
ui.Check(self.win, layout = (23, 8, 9, 1), text = _('Show coordinates'), id = 'vCoords', |
|
535
|
|
|
checked = 1) |
|
536
|
|
|
ui.Check(self.win, layout = (7 ,9 ,8 ,1), text = _('Players highlight'), id = 'vHighlights', |
|
537
|
|
|
checked = 1) |
|
538
|
|
|
ui.Check(self.win, layout = (15, 9, 8, 1), text = _('Show minimap'), id = 'vShowMinimap', |
|
539
|
|
|
checked = 1) |
|
540
|
|
|
ui.Check(self.win, layout = (23, 9, 8, 1), text = _('Show gate systems'), id = 'vShowGateSystems', |
|
541
|
|
|
checked = 1) |
|
542
|
|
|
ui.Check(self.win, layout = (7, 10, 8, 1), text = _('Show redirects'), id = 'vRedirects', |
|
543
|
|
|
checked = 1, tooltipTitle = _('Starmap hotkey:'), tooltip = _('CTRL-R')) |
|
544
|
|
|
ui.Check(self.win, layout = (15, 10, 8, 1), text = _('Show map grid'), id = 'vShowMapGrid', |
|
545
|
|
|
checked = 1, tooltipTitle = _('Starmap hotkey'), tooltip = _('CTRL-G')) |
|
546
|
|
|
ui.Check(self.win, layout = (23, 10, 8, 1), text = _('Alternate system info'), id = 'vShowAlternateView', |
|
547
|
|
|
checked = 0, tooltipTitle = _('Starmap hotkey'), tooltip = _('CTRL-A')) |
|
548
|
|
|
ui.Check(self.win, layout = (7, 11, 8, 1), text = _('Show map scanners'), id = 'vShowMapScanners', |
|
549
|
|
|
checked = 1, tooltipTitle = _('Starmap hotkey'), tooltip = _('CTRL-S')) |
|
550
|
|
|
ui.Check(self.win, layout = (15, 11, 8, 1), text = _('Show fleet lines'), id = 'vShowMapFleetLines', |
|
551
|
|
|
checked = 1, tooltipTitle = _('Starmap hotkey'), tooltip = _('CTRL-L')) |
|
552
|
|
|
ui.Check(self.win, layout = (23, 11, 8, 1), text = _('Show player zones'), id = 'vShowPlayerZones', |
|
553
|
|
|
checked = 0, tooltipTitle = _('Starmap hotkey'), tooltip = _('CTRL-P')) |
|
554
|
|
|
|
|
555
|
|
|
# Login settings |
|
556
|
|
|
ui.Title(self.win, layout = (7,13, 15, 1), text = _('Login settings'), |
|
557
|
|
|
align = ui.ALIGN_NONE, font = 'normal-bold') |
|
558
|
|
|
ui.Check(self.win, layout = (15,14,8,1), text = _('Auto-login'), id = 'vAutoLogin', |
|
559
|
|
|
checked = 0) |
|
560
|
|
|
ui.Check(self.win, layout = (7,14,8,1), text = _('Remember password'), id = 'vSavePassword', |
|
561
|
|
|
checked = 0, action = "onChangeSavePassword") |
|
562
|
|
|
ui.Button(self.win, layout = (23.5, 13, 9, 1), id = "vChangePassword", text = _("Change password"), action = 'onChangePassword', align = ui.ALIGN_NONE) |
|
563
|
|
|
|
|
564
|
|
|
# proxy settings |
|
565
|
|
|
ui.Title(self.win, layout = (13, 1, 9, 1), text = _('Proxy'), font = 'normal-bold') |
|
566
|
|
|
ui.Label(self.win, layout = (13, 2, 4, 1), text = _('Host:'), align = ui.ALIGN_E) |
|
567
|
|
|
ui.Entry(self.win, layout = (17, 2, 5, 1), id = 'vProxyHost', align = ui.ALIGN_W, orderNo = 1) |
|
568
|
|
|
ui.Label(self.win, layout = (13, 3, 4, 1), text = _('Port:'), align = ui.ALIGN_E) |
|
569
|
|
|
ui.Entry(self.win, layout = (17, 3, 5, 1), id = 'vProxyPort', align = ui.ALIGN_W, orderNo = 2) |
|
570
|
|
|
ui.Label(self.win, layout = (13, 4, 4, 1), text = _('Username:'), align = ui.ALIGN_E) |
|
571
|
|
|
ui.Entry(self.win, layout = (17, 4, 5, 1), id = 'vProxyUsername', align = ui.ALIGN_W, orderNo = 3) |
|
572
|
|
|
ui.Label(self.win, layout = (13, 5, 4, 1), text = _('Password:'), align = ui.ALIGN_E) |
|
573
|
|
|
ui.Entry(self.win, layout = (17, 5, 5, 1), id = 'vProxyPassword', align = ui.ALIGN_W, orderNo = 4) |
|
574
|
|
|
|
|
575
|
|
|
# sound options |
|
576
|
|
|
ui.Title(self.win, layout = (23, 1, 9, 1), text = _('Sound / Music'), font = 'normal-bold') |
|
577
|
|
|
ui.Check(self.win, layout = (23, 2, 9, 1), text = _('Sounds'), id = 'vSoundEnabled', |
|
578
|
|
|
checked = 1) |
|
579
|
|
|
ui.Scrollbar(self.win, layout = (23, 3, 9, 1), id = 'vSoundVolume', |
|
580
|
|
|
action = "onChangeSoundVolume") |
|
581
|
|
|
ui.Check(self.win, layout = (23, 4, 9, 1), text = _('Music'), id = 'vMusicEnabled', |
|
582
|
|
|
checked = 1) |
|
583
|
|
|
ui.Scrollbar(self.win, layout = (23, 5, 9, 1), id = 'vMusicVolume', |
|
584
|
|
|
action = "onChangeMusicVolume") |
|
585
|
|
|
|
|
586
|
|
|
# dialog bottom line |
|
587
|
|
|
ui.Title(self.win, layout = (0, rows - 1, cols - 10, 1)) |
|
588
|
|
|
ui.TitleButton(self.win, layout = (cols - 10, rows - 1, 5, 1), text = _("Cancel"), action = 'onCancel') |
|
589
|
|
|
ui.TitleButton(self.win, layout = (cols - 5, rows - 1, 5, 1), text = _("OK"), action = 'onOK') |
|
590
|
|
|
|