Changeset 166:e4ba22b7a13b for src/mlx/config.py
- Timestamp:
- 05/10/12 18:17:18 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/config.py
r156 r166 20 20 _languageMap = { "en_GB" : "eng", 21 21 "hu_HU" : "hun" } 22 23 #------------------------------------------------------------------------------- 24 25 class Hotkey(object): 26 """A hotkey.""" 27 def __init__(self, ctrl = False, shift = False, key = "0"): 28 """Construct the hotkey.""" 29 self.ctrl = ctrl 30 self.shift = shift 31 self.key = key 32 33 def set(self, s): 34 """Set the hotkey from the given string.""" 35 self.ctrl = "C" in s[:-1] 36 self.shift = "S" in s[:-1] 37 self.key = s[-1] 38 39 def __eq__(self, other): 40 """Check if the given hotkey is equal to the other one.""" 41 return self.ctrl == other.ctrl and self.shift == other.shift and \ 42 self.key == other.key 43 44 def __str__(self): 45 """Construct the hotkey to a string.""" 46 s = "" 47 if self.ctrl: s += "C" 48 if self.shift: s += "S" 49 s += self.key 50 return s 22 51 23 52 #------------------------------------------------------------------------------- … … 44 73 45 74 self._pirepDirectory = None 46 75 76 self._enableSounds = True 77 78 self._pilotControlsSounds = True 79 self._pilotHotkey = Hotkey(ctrl = True, shift = False, key = "0") 80 81 #self._approachCallOuts = False 82 self._speedbrakeAtTD = True 83 84 self._enableChecklists = False 85 self._checklistHotkey = Hotkey(ctrl = True, shift = True, key = "0") 86 47 87 self._autoUpdate = True 48 88 self._updateURL = Config.DEFAULT_UPDATE_URL … … 196 236 self._messageTypeLevels[messageType]!=level: 197 237 self._messageTypeLevels[messageType] = level 238 self._modified = True 239 240 @property 241 def enableSounds(self): 242 """Get whether background sounds are enabled.""" 243 return self._enableSounds 244 245 @enableSounds.setter 246 def enableSounds(self, enableSounds): 247 """Set whether background sounds are enabled.""" 248 if enableSounds!=self._enableSounds: 249 self._enableSounds = enableSounds 250 self._modified = True 251 252 @property 253 def pilotControlsSounds(self): 254 """Get whether the pilot controls the background sounds.""" 255 return self._pilotControlsSounds 256 257 @pilotControlsSounds.setter 258 def pilotControlsSounds(self, pilotControlsSounds): 259 """Set whether the pilot controls the background sounds.""" 260 if pilotControlsSounds!=self._pilotControlsSounds: 261 self._pilotControlsSounds = pilotControlsSounds 262 self._modified = True 263 264 @property 265 def pilotHotkey(self): 266 """Get the pilot's hotkey.""" 267 return self._pilotHotkey 268 269 @pilotHotkey.setter 270 def pilotHotkey(self, pilotHotkey): 271 """Set the pilot's hotkey.""" 272 if pilotHotkey!=self._pilotHotkey: 273 self._pilotHotkey = pilotHotkey 274 self._modified = True 275 276 # @property 277 # def approachCallOuts(self): 278 # """Get whether the approach callouts should be played.""" 279 # return self._approachCallOuts 280 281 # @approachCallOuts.setter 282 # def approachCallOuts(self, approachCallOuts): 283 # """Set whether the approach callouts should be played.""" 284 # if approachCallOuts!=self._approachCallOuts: 285 # self._approachCallOuts = approachCallOuts 286 # self._modified = True 287 288 @property 289 def speedbrakeAtTD(self): 290 """Get whether the speedbrake sounds should be played at touchdown.""" 291 return self._speedbrakeAtTD 292 293 @speedbrakeAtTD.setter 294 def speedbrakeAtTD(self, speedbrakeAtTD): 295 """Set whether the speedbrake sounds should be played at touchdown.""" 296 if speedbrakeAtTD!=self._speedbrakeAtTD: 297 self._speedbrakeAtTD = speedbrakeAtTD 298 self._modified = True 299 300 @property 301 def enableChecklists(self): 302 """Get whether aircraft-specific checklists should be played.""" 303 return self._enableChecklists 304 305 @enableChecklists.setter 306 def enableChecklists(self, enableChecklists): 307 """Get whether aircraft-specific checklists should be played.""" 308 if enableChecklists!=self._enableChecklists: 309 self._enableChecklists = enableChecklists 310 self._modified = True 311 312 @property 313 def checklistHotkey(self): 314 """Get the checklist hotkey.""" 315 return self._checklistHotkey 316 317 @checklistHotkey.setter 318 def checklistHotkey(self, checklistHotkey): 319 """Set the checklist hotkey.""" 320 if checklistHotkey!=self._checklistHotkey: 321 self._checklistHotkey = checklistHotkey 198 322 self._modified = True 199 323 … … 254 378 self._messageTypeLevels[messageType] = \ 255 379 self._getMessageTypeLevel(config, messageType) 380 381 self._enableSounds = self._getBoolean(config, "sounds", 382 "enable", True) 383 self._pilotControlsSounds = self._getBoolean(config, "sounds", 384 "pilotControls", True) 385 self._pilotHotkey.set(self._get(config, "sounds", 386 "pilotHotkey", "C0")) 387 #self._approachCallOuts = self._getBoolean(config, "sounds", 388 # "approachCallOuts", False) 389 self._speedbrakeAtTD = self._getBoolean(config, "sounds", 390 "speedbrakeAtTD", True) 391 392 self._enableChecklists = self._getBoolean(config, "sounds", 393 "enableChecklists", False) 394 self._checklistHotkey.set(self._get(config, "sounds", 395 "checklistHotkey", "CS0")) 256 396 257 397 self._autoUpdate = self._getBoolean(config, "update", "auto", True) … … 298 438 config.set(Config._messageTypesSection, option, 299 439 const.messageLevel2string(level)) 440 441 config.add_section("sounds") 442 config.set("sounds", "enable", 443 "yes" if self._enableSounds else "no") 444 config.set("sounds", "pilotControls", 445 "yes" if self._pilotControlsSounds else "no") 446 config.set("sounds", "pilotHotkey", str(self._pilotHotkey)) 447 #config.set("sounds", "approachCallOuts", 448 # "yes" if self._approachCallOuts else "no") 449 config.set("sounds", "speedbrakeAtTD", 450 "yes" if self._speedbrakeAtTD else "no") 451 452 config.set("sounds", "enableChecklists", 453 "yes" if self._enableChecklists else "no") 454 config.set("sounds", "checklistHotkey", 455 str(self._checklistHotkey)) 300 456 301 457 config.add_section("update")
Note:
See TracChangeset
for help on using the changeset viewer.