factored out the EFFv2 saving into EFFImporter
[gemrb.git] / gemrb / GUIScripts / bg1 / GUIOPT.py
blobce3fb104173ac9a9618c6799a5f546356a41b161
1 # -*-python-*-
2 # GemRB - Infinity Engine Emulator
3 # Copyright (C) 2003 The GemRB Project
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 # GUIOPT.py - scripts to control options windows mostly from GUIOPT winpack
23 # GUIOPT:
24 # 0 - Main options window (peacock tail)
25 # 1 - Video options window
26 # 2 - msg win with 1 button
27 # 3 - msg win with 2 buttons
28 # 4 - msg win with 3 buttons
29 # 5 - Audio options window
30 # 6 - Gameplay options window
31 # 8 - Feedback options window
32 # 9 - Autopause options window
35 ###################################################
36 import GemRB
37 import GUICommon
38 import GUICommonWindows
39 import GUISAVE
40 from GUIDefines import *
42 ###################################################
43 OptionsWindow = None
44 SubOptionsWindow = None
45 SubSubOptionsWindow = None
46 GameOptionsWindow = None
47 OldOptionsWindow = None
48 MoviesWindow = None
49 KeysWindow = None
50 HelpTextArea = None
51 HelpTextArea2 = None
53 LoadMsgWindow = None
54 QuitMsgWindow = None
55 hideflag = None
58 def CloseOptionsWindow ():
59 global GameOptionsWindow, OptionsWindow
60 global OldOptionsWindow
62 if GameOptionsWindow == None:
63 return
65 if GameOptionsWindow:
66 GameOptionsWindow.Unload ()
67 if OptionsWindow:
68 OptionsWindow.Unload ()
70 GameOptionsWindow = None
71 GUICommonWindows.SetSelectionChangeHandler (None)
72 GemRB.SetVar ("OtherWindow", -1)
73 GUICommon.GameWindow.SetVisible(WINDOW_VISIBLE)
74 GUICommonWindows.OptionsWindow = OldOptionsWindow
75 OldOptionsWindow = None
76 return
78 def DummyWindow ():
79 return
81 ###################################################
82 def OpenOptionsWindow ():
83 """Open main options window"""
84 global GameOptionsWindow, OptionsWindow
85 global OldOptionsWindow
87 if GUICommon.CloseOtherWindow(OpenOptionsWindow):
88 CloseOptionsWindow()
89 return
91 #hideflag = GemRB.HideGUI ()
92 GUICommon.GameWindow.SetVisible(WINDOW_INVISIBLE)
93 GUICommonWindows.SetSelectionChangeHandler (DummyWindow)
95 GemRB.LoadWindowPack ("GUIOPT", 640, 480)
96 GameOptionsWindow = Window = GemRB.LoadWindow (2)
97 GemRB.SetVar ("OtherWindow", GameOptionsWindow.ID)
98 if OldOptionsWindow == None:
99 OldOptionsWindow = GUICommonWindows.OptionsWindow
100 OptionsWindow = GemRB.LoadWindow (0)
101 GUICommonWindows.SetupMenuWindowControls (OptionsWindow, 0, OpenOptionsWindow)
102 OptionsWindow.SetFrame ()
104 # Load game
105 Button = Window.GetControl (5)
106 Button.SetText (13729)
107 Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenLoadMsgWindow)
109 # Save Game
110 Button = Window.GetControl (6)
111 Button.SetText (13730)
112 Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenSaveMsgWindow)
114 # Quit Game
115 Button = Window.GetControl (10)
116 Button.SetText (13731)
117 Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenQuitMsgWindow)
119 # Graphics
120 Button = Window.GetControl (7)
121 Button.SetText (17162)
122 Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenVideoOptionsWindow)
124 # Audio
125 Button = Window.GetControl (8)
126 Button.SetText (17164)
127 Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenAudioOptionsWindow)
129 # Gameplay
130 Button = Window.GetControl (9)
131 Button.SetText (17165)
132 #Button.SetText (10308)
133 Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenGameplayOptionsWindow)
135 # Return to game
136 Button = Window.GetControl (11)
137 Button.SetText (10308)
138 Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenOptionsWindow)
140 # game version, e.g. v1.1.0000
141 Label = Window.GetControl (0x1000000b)
142 Label.SetText (GEMRB_VERSION)
144 OptionsWindow.SetVisible (WINDOW_VISIBLE)
145 Window.SetVisible (WINDOW_VISIBLE)
146 GUICommonWindows.PortraitWindow.SetVisible (WINDOW_VISIBLE)
147 return
150 ###################################################
151 def CloseVideoOptionsWindow ():
152 global SubOptionsWindow
154 if SubOptionsWindow:
155 SubOptionsWindow.Unload()
156 SubOptionsWindow = None
157 return
159 def OpenVideoOptionsWindow ():
160 """Open video options window"""
161 global SubOptionsWindow, HelpTextArea
163 if SubOptionsWindow:
164 if SubOptionsWindow:
165 SubOptionsWindow.Unload()
166 SubOptionsWindow = None
168 SubOptionsWindow = Window = GemRB.LoadWindow (6)
170 HelpTextArea = OptHelpText ('VideoOptions', Window, 33, 18038)
172 OptDone ('VideoOptions', Window, 21)
173 OptCancel ('VideoOptions', Window, 32)
175 OptSlider ('Brightness', Window, 3, 'Brightness Correction', 4)
176 OptSlider ('Contrast', Window, 22, 'Gamma Correction', 1)
178 OptRadio ('BPP', Window, 5, 37, 'BitsPerPixel', 16)
179 OptRadio ('BPP', Window, 6, 37, 'BitsPerPixel', 24)
180 OptRadio ('BPP', Window, 7, 37, 'BitsPerPixel', 32)
181 OptCheckbox ('FullScreen', Window, 9, 38, 'Full Screen', 1)
183 OptCheckbox ('TransShadow', Window, 51, 50, 'Translucent Shadows', 1)
184 OptCheckbox ('SoftMirrBlt', Window, 40, 44, 'SoftMirrorBlt' ,1)
185 OptCheckbox ('SoftTransBlt', Window, 41, 46, 'SoftSrcKeyBlt' ,1)
186 OptCheckbox ('SoftStandBlt', Window, 42, 48, 'SoftBltFast' ,1)
188 Window.ShowModal (MODAL_SHADOW_GRAY)
191 def DisplayHelpFullScreen ():
192 HelpTextArea.SetText (18000)
193 GemRB.SetFullScreen (GemRB.GetVar("Full Screen"))
195 def DisplayHelpBPP ():
196 HelpTextArea.SetText (17205)
198 def DisplayHelpBrightness ():
199 HelpTextArea.SetText (17203)
200 GemRB.SetGamma (GemRB.GetVar("Brightness Correction"),GemRB.GetVar("Gamma Correction")/2)
202 def DisplayHelpContrast ():
203 HelpTextArea.SetText (17204)
204 GemRB.SetGamma (GemRB.GetVar("Brightness Correction"),GemRB.GetVar("Gamma Correction")/2)
206 def DisplayHelpSoftMirrBlt ():
207 HelpTextArea.SetText (18004)
209 def DisplayHelpSoftTransBlt ():
210 HelpTextArea.SetText (18006)
212 def DisplayHelpSoftStandBlt ():
213 HelpTextArea.SetText (18007)
215 def DisplayHelpTransShadow ():
216 HelpTextArea.SetText (20620)
219 ###################################################
221 def CloseAudioOptionsWindow ():
222 global SubOptionsWindow
224 if SubOptionsWindow:
225 SubOptionsWindow.Unload()
226 SubOptionsWindow = None
227 return
229 def OpenAudioOptionsWindow ():
230 """Open audio options window"""
231 global SubOptionsWindow, HelpTextArea
233 if SubOptionsWindow:
234 if SubOptionsWindow:
235 SubOptionsWindow.Unload ()
236 SubOptionsWindow = None
238 SubOptionsWindow = Window = GemRB.LoadWindow (7)
240 HelpTextArea = OptHelpText ('AudioOptions', Window, 14, 18040)
242 Window.DeleteControl(16)
244 OptDone ('AudioOptions', Window, 24)
245 OptCancel ('AudioOptions', Window, 25)
246 OptButton ('CharacterSounds', Window, 13, 17778)
248 OptSlider ('AmbientVolume', Window, 1, 'Volume Ambients', 10)
249 OptSlider ('SoundFXVolume', Window, 2, 'Volume SFX', 10)
250 OptSlider ('VoiceVolume', Window, 3, 'Volume Voices', 10)
251 OptSlider ('MusicVolume', Window, 4, 'Volume Music', 10)
252 OptSlider ('MovieVolume', Window, 22, 'Volume Movie', 10)
254 OptCheckbox ('CreativeEAX', Window, 26, 28, 'Environmental Audio', 1)
256 Window.ShowModal (MODAL_SHADOW_GRAY)
257 return
259 def DisplayHelpAmbientVolume ():
260 HelpTextArea.SetText (18008)
261 GemRB.UpdateAmbientsVolume ()
263 def DisplayHelpSoundFXVolume ():
264 HelpTextArea.SetText (18009)
266 def DisplayHelpVoiceVolume ():
267 HelpTextArea.SetText (18010)
269 def DisplayHelpMusicVolume ():
270 HelpTextArea.SetText (18011)
271 GemRB.UpdateMusicVolume ()
273 def DisplayHelpMovieVolume ():
274 HelpTextArea.SetText (18012)
276 def DisplayHelpCreativeEAX ():
277 HelpTextArea.SetText (18022)
279 ###################################################
281 def CloseCharacterSoundsWindow ():
282 global SubSubOptionsWindow
284 if SubSubOptionsWindow:
285 SubSubOptionsWindow.Unload ()
286 SubSubOptionsWindow = None
287 return
289 def OpenCharacterSoundsWindow ():
290 """Open character sounds window"""
291 global SubSubOptionsWindow, HelpTextArea2
293 if SubSubOptionsWindow:
294 if SubSubOptionsWindow:
295 SubSubOptionsWindow.Unload ()
296 SubSubOptionsWindow = None
298 SubSubOptionsWindow = Window = GemRB.LoadWindow (12)
300 HelpTextArea2 = OptHelpText ('CharacterSounds', Window, 16, 18041)
302 OptDone ('CharacterSounds', Window, 24)
303 OptCancel ('CharacterSounds', Window, 25)
305 OptCheckbox ('Subtitles', Window, 5, 20, 'Subtitles', 1)
306 OptCheckbox ('AttackSounds', Window, 6, 18, 'Attack Sounds', 1)
307 OptCheckbox ('Footsteps', Window, 7, 19, 'Footsteps', 1)
308 OptRadio ('CommandSounds', Window, 8, 21, 'Command Sounds Frequency', 1)
309 OptRadio ('CommandSounds', Window, 9, 21, 'Command Sounds Frequency', 2)
310 OptRadio ('CommandSounds', Window, 10, 21, 'Command Sounds Frequency', 3)
311 OptRadio ('SelectionSounds', Window, 58, 57, 'Selection Sounds Frequency', 1)
312 OptRadio ('SelectionSounds', Window, 59, 57, 'Selection Sounds Frequency', 2)
313 OptRadio ('SelectionSounds', Window, 60, 57, 'Selection Sounds Frequency', 3)
315 Window.ShowModal (MODAL_SHADOW_GRAY)
317 def DisplayHelpSubtitles ():
318 HelpTextArea2.SetText (18015)
320 def DisplayHelpAttackSounds ():
321 HelpTextArea2.SetText (18013)
323 def DisplayHelpFootsteps ():
324 HelpTextArea2.SetText (18014)
326 def DisplayHelpCommandSounds ():
327 HelpTextArea2.SetText (18016)
329 def DisplayHelpSelectionSounds ():
330 HelpTextArea2.SetText (11352)
332 ###################################################
334 def CloseGameplayOptionsWindow ():
335 global SubOptionsWindow
337 if SubOptionsWindow:
338 SubOptionsWindow.Unload()
339 SubOptionsWindow = None
340 return
342 def OpenGameplayOptionsWindow ():
343 """Open gameplay options window"""
344 global SubOptionsWindow, HelpTextArea
346 if SubOptionsWindow:
347 if SubOptionsWindow:
348 SubOptionsWindow.Unload ()
349 SubOptionsWindow = None
351 SubOptionsWindow = Window = GemRB.LoadWindow (8)
353 HelpTextArea = OptHelpText ('GameplayOptions', Window, 40, 18042)
355 OptDone ('GameplayOptions', Window, 7)
356 OptCancel ('GameplayOptions', Window, 20)
358 OptSlider ('TooltipDelay', Window, 1, 'Tooltips', TOOLTIP_DELAY_FACTOR)
359 OptSlider ('MouseScrollingSpeed', Window, 2, 'Mouse Scroll Speed', 5)
360 OptSlider ('KeyboardScrollingSpeed', Window, 3, 'Keyboard Scroll Speed', 5)
361 OptSlider ('Difficulty', Window, 12, 'Difficulty Level', 0)
363 OptCheckbox ('DitherAlways', Window, 14, 25, 'Always Dither', 1)
364 OptCheckbox ('Gore', Window, 19, 27, 'Gore', 1)
365 OptCheckbox ('Infravision', Window, 42, 44, 'Infravision', 1)
366 OptCheckbox ('Weather', Window, 47, 46, 'Weather', 1)
368 OptButton ('FeedbackOptions', Window, 5, 17163)
369 OptButton ('AutopauseOptions', Window, 6, 17166)
371 Window.ShowModal (MODAL_SHADOW_GRAY)
374 def DisplayHelpTooltipDelay ():
375 HelpTextArea.SetText (18017)
376 GemRB.SetTooltipDelay (GemRB.GetVar ("Tooltips") )
378 def DisplayHelpMouseScrollingSpeed ():
379 HelpTextArea.SetText (18018)
380 GemRB.SetMouseScrollSpeed (GemRB.GetVar ("Mouse Scroll Speed") )
382 def DisplayHelpKeyboardScrollingSpeed ():
383 HelpTextArea.SetText (18019)
385 def DisplayHelpDifficulty ():
386 HelpTextArea.SetText (18020)
388 def DisplayHelpDitherAlways ():
389 HelpTextArea.SetText (18021)
391 def DisplayHelpGore ():
392 HelpTextArea.SetText (18023)
394 def DisplayHelpInfravision ():
395 HelpTextArea.SetText (11797)
397 def DisplayHelpWeather ():
398 HelpTextArea.SetText (20619)
400 def DisplayHelpRestUntilHealed ():
401 HelpTextArea.SetText (2242)
404 ###################################################
405 def CloseFeedbackOptionsWindow ():
406 global SubSubOptionsWindow
408 if SubSubOptionsWindow:
409 SubSubOptionsWindow.Unload ()
410 SubSubOptionsWindow = None
411 return
413 def OpenFeedbackOptionsWindow ():
414 """Open feedback options window"""
415 global SubSubOptionsWindow, HelpTextArea2
417 if SubSubOptionsWindow:
418 if SubSubOptionsWindow:
419 SubSubOptionsWindow.Unload ()
420 SubSubOptionsWindow = None
422 SubSubOptionsWindow = Window = GemRB.LoadWindow (9)
424 HelpTextArea2 = OptHelpText ('FeedbackOptions', Window, 28, 18043)
426 OptDone ('FeedbackOptions', Window, 26)
427 OptCancel ('FeedbackOptions', Window, 27)
429 OptSlider ('MarkerFeedback', Window, 8, 'GUI Feedback Level', 1)
430 OptSlider ('LocatorFeedback', Window, 9, 'Locator Feedback Level', 1)
431 OptCheckbox ('ToHitRolls', Window, 10, 32, 'Rolls', 1)
432 OptCheckbox ('CombatInfo', Window, 11, 33, 'Combat Info', 1)
433 OptCheckbox ('Actions', Window, 12, 34, 'Actions', 1)
434 OptCheckbox ('States', Window, 13, 35, 'State Changes', 1)
435 OptCheckbox ('Selection', Window, 14, 36, 'Selection Text', 1)
436 OptCheckbox ('Miscellaneous', Window, 15, 37, 'Miscellaneous Text', 1)
438 Window.ShowModal (MODAL_SHADOW_GRAY)
441 def DisplayHelpMarkerFeedback ():
442 HelpTextArea.SetText (18024)
444 def DisplayHelpLocatorFeedback ():
445 HelpTextArea.SetText (18025)
447 def DisplayHelpToHitRolls ():
448 HelpTextArea2.SetText (18026)
450 def DisplayHelpCombatInfo ():
451 HelpTextArea2.SetText (18027)
453 def DisplayHelpActions ():
454 HelpTextArea2.SetText (18028)
456 def DisplayHelpStates ():
457 HelpTextArea2.SetText (18029)
459 def DisplayHelpSelection ():
460 HelpTextArea2.SetText (18030)
462 def DisplayHelpMiscellaneous ():
463 HelpTextArea2.SetText (18031)
465 ###################################################
467 def CloseAutopauseOptionsWindow ():
468 global SubSubOptionsWindow
470 if SubSubOptionsWindow:
471 SubSubOptionsWindow.Unload ()
472 SubSubOptionsWindow = None
473 return
475 def OpenAutopauseOptionsWindow ():
476 """Open autopause options window"""
477 global SubSubOptionsWindow, HelpTextArea2
479 if SubSubOptionsWindow:
480 if SubSubOptionsWindow:
481 SubSubOptionsWindow.Unload ()
482 SubSubOptionsWindow = None
484 SubSubOptionsWindow = Window = GemRB.LoadWindow (10)
486 HelpTextArea2 = OptHelpText ('AutopauseOptions', Window, 15, 18044)
488 OptDone ('AutopauseOptions', Window, 11)
489 OptCancel ('AutopauseOptions', Window, 14)
491 OptCheckbox ('CharacterHit', Window, 1, 17, 'Auto Pause State', 1)
492 OptCheckbox ('CharacterInjured', Window, 2, 18, 'Auto Pause State', 2)
493 OptCheckbox ('CharacterDead', Window, 3, 19, 'Auto Pause State', 4)
494 OptCheckbox ('CharacterAttacked', Window, 4, 20, 'Auto Pause State', 8)
495 OptCheckbox ('WeaponUnusable', Window, 5, 21, 'Auto Pause State', 16)
496 OptCheckbox ('TargetGone', Window, 13, 22, 'Auto Pause State', 32)
497 OptCheckbox ('EndOfRound', Window, 25, 24, 'Auto Pause State', 64)
498 if Window.HasControl(26, IE_GUI_BUTTON):
499 OptCheckbox ('EnemySighted', Window, 26, 27, 'Auto Pause State', 128)
501 Window.ShowModal (MODAL_SHADOW_GRAY)
504 def DisplayHelpCharacterHit ():
505 HelpTextArea.SetText (18032)
507 def DisplayHelpCharacterInjured ():
508 HelpTextArea.SetText (18033)
510 def DisplayHelpCharacterDead ():
511 HelpTextArea.SetText (18034)
513 def DisplayHelpCharacterAttacked ():
514 HelpTextArea.SetText (18035)
516 def DisplayHelpWeaponUnusable ():
517 HelpTextArea.SetText (18036)
519 def DisplayHelpTargetGone ():
520 HelpTextArea.SetText (18037)
522 def DisplayHelpEndOfRound ():
523 HelpTextArea.SetText (10640)
525 def DisplayHelpEnemySighted ():
526 HelpTextArea.SetText (23514)
529 ###################################################
531 def OpenSaveMsgWindow ():
532 GemRB.SetVar("QuitAfterSave",0)
533 GUISAVE.OpenSaveWindow ()
534 #save the game without quitting
535 return
537 ###################################################
539 def OpenLoadMsgWindow ():
540 global LoadMsgWindow
542 if LoadMsgWindow:
543 return
545 LoadMsgWindow = Window = GemRB.LoadWindow (4)
547 # Load
548 Button = Window.GetControl (0)
549 Button.SetText (15590)
550 Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, LoadGamePress)
552 # Cancel
553 Button = Window.GetControl (1)
554 Button.SetText (13727)
555 Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, CloseLoadMsgWindow)
557 # Loading a game will destroy ...
558 Text = Window.GetControl (3)
559 Text.SetText (19531)
561 Window.ShowModal (MODAL_SHADOW_GRAY)
563 def CloseLoadMsgWindow ():
564 global LoadMsgWindow
566 if LoadMsgWindow:
567 LoadMsgWindow.Unload ()
568 LoadMsgWindow = None
569 #OptionsWindow.SetVisible (WINDOW_VISIBLE)
570 return
572 def LoadGamePress ():
573 global LoadMsgWindow
575 if LoadMsgWindow:
576 LoadMsgWindow.Unload ()
577 LoadMsgWindow = None
578 GemRB.QuitGame ()
579 OpenOptionsWindow()
580 GemRB.SetNextScript ("GUILOAD")
581 return
583 def SaveGamePress():
584 global QuitMsgWindow
586 if QuitMsgWindow:
587 QuitMsgWindow.Unload ()
588 QuitMsgWindow = None
589 #we need to set a state: quit after save
590 GemRB.SetVar("QuitAfterSave",1)
591 OpenOptionsWindow()
592 GUISAVE.OpenSaveWindow ()
593 return
595 def QuitGamePress():
596 global QuitMsgWindow
598 if QuitMsgWindow:
599 QuitMsgWindow.Unload ()
600 QuitMsgWindow = None
601 GemRB.QuitGame ()
602 OpenOptionsWindow()
603 GemRB.SetNextScript ("Start")
604 return
606 ###################################################
608 def OpenQuitMsgWindow ():
609 global QuitMsgWindow
611 if QuitMsgWindow:
612 return
614 QuitMsgWindow = Window = GemRB.LoadWindow (5)
616 # Save
617 Button = Window.GetControl (0)
618 Button.SetText (15589)
619 Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, SaveGamePress)
621 # Quit Game
622 Button = Window.GetControl (1)
623 Button.SetText (15417)
624 Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, QuitGamePress)
626 # Cancel
627 Button = Window.GetControl (2)
628 Button.SetText (13727)
629 Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, CloseQuitMsgWindow)
631 # Do you wish to save the game ....
632 Text = Window.GetControl (3)
633 Text.SetText (16456) # or ??? - cannot be saved atm
635 Window.ShowModal (MODAL_SHADOW_GRAY)
636 return
638 def CloseQuitMsgWindow ():
639 global QuitMsgWindow
641 if QuitMsgWindow:
642 QuitMsgWindow.Unload ()
643 QuitMsgWindow = None
644 OptionsWindow.SetVisible (WINDOW_VISIBLE)
645 return
648 ###################################################
649 # These functions help to setup controls found
650 # in Video, Audio, Gameplay, Feedback and Autopause
651 # options windows
653 # These controls are usually made from an active
654 # control (button, slider ...) and a label
656 def OptSlider (name, window, slider_id, variable, value):
657 """Standard slider for option windows"""
658 slider = window.GetControl (slider_id)
659 slider.SetVarAssoc (variable, value)
660 slider.SetEvent (IE_GUI_SLIDER_ON_CHANGE, eval("DisplayHelp" + name))
662 #label = window.GetControl (label_id)
663 #label.SetText (label_strref)
664 #label.SetFlags (IE_GUI_BUTTON_NO_IMAGE, OP_SET)
665 #label.SetState (IE_GUI_BUTTON_LOCKED)
666 #label.SetEvent (IE_GUI_MOUSE_ENTER_BUTTON, eval("DisplayHelp" + name))
668 return slider
670 def OptRadio (name, window, button_id, label_id, variable, value):
671 """Standard radio button for option windows"""
673 button = window.GetControl (button_id)
674 button.SetFlags (IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
675 button.SetEvent (IE_GUI_BUTTON_ON_PRESS, eval("DisplayHelp" + name))
676 button.SetVarAssoc (variable, value)
678 label = window.GetControl (label_id)
679 label.SetFlags (IE_GUI_BUTTON_NO_IMAGE, OP_SET)
680 label.SetState (IE_GUI_BUTTON_LOCKED)
682 return button
684 def OptCheckbox (name, window, button_id, label_id, variable, value):
685 """Standard checkbox for option windows"""
687 button = window.GetControl (button_id)
688 button.SetFlags (IE_GUI_BUTTON_CHECKBOX, OP_OR)
689 button.SetState (IE_GUI_BUTTON_SELECTED)
690 button.SetEvent (IE_GUI_BUTTON_ON_PRESS, eval("DisplayHelp" + name))
691 button.SetVarAssoc (variable, value)
692 return button
694 def OptButton (name, window, button_id, button_strref):
695 """Standard subwindow button for option windows"""
696 button = window.GetControl (button_id)
697 button.SetEvent (IE_GUI_BUTTON_ON_PRESS, eval("Open%sWindow" %name))
699 button.SetText (button_strref)
702 def OptDone (name, window, button_id):
703 """Standard `Done' button for option windows"""
704 button = window.GetControl (button_id)
705 button.SetText (11973) # Done
706 button.SetEvent (IE_GUI_BUTTON_ON_PRESS, eval("Close%sWindow" %name))
707 button.SetFlags (IE_GUI_BUTTON_DEFAULT, OP_OR)
709 def OptCancel (name, window, button_id):
710 """Standard `Cancel' button for option windows"""
711 button = window.GetControl (button_id)
712 button.SetText (13727) # Cancel
713 button.SetEvent (IE_GUI_BUTTON_ON_PRESS, eval("Close%sWindow" %name))
714 button.SetFlags (IE_GUI_BUTTON_CANCEL, OP_OR)
716 def OptHelpText (name, window, text_id, text_strref):
717 """Standard textarea with context help for option windows"""
718 text = window.GetControl (text_id)
719 text.SetText (text_strref)
720 return text
723 ###################################################
724 # End of file GUIOPT.py