1# GemRB - Infinity Engine Emulator 2# Copyright (C) 2003 The GemRB Project 3# 4# This program is free software; you can redistribute it and/or 5# modify it under the terms of the GNU General Public License 6# as published by the Free Software Foundation; either version 2 7# of the License, or (at your option) any later version. 8# 9# This program is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with this program; if not, write to the Free Software 16# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17# 18# 19import GemRB 20from GUIDefines import * 21from GameCheck import HasTOTSC 22 23ExitButton = 0 24SinglePlayerButton = 0 25MultiPlayerButton = 0 26MoviesButton = 0 27 28def OnLoad(): 29 global ExitButton, MultiPlayerButton, MoviesButton, SinglePlayerButton 30 31 skip_videos = GemRB.GetVar ("SkipIntroVideos") 32 if not skip_videos: 33 GemRB.PlayMovie ('BG4LOGO',1) 34 GemRB.PlayMovie ('TSRLOGO',1) 35 GemRB.PlayMovie ('BILOGO',1) 36 GemRB.PlayMovie ('INFELOGO',1) 37 GemRB.PlayMovie ('INTRO',1) 38 GemRB.SetVar ("SkipIntroVideos", 1) 39 40 #main window 41 StartWindow = GemRB.LoadWindow (0, "START") 42 SinglePlayerButton = StartWindow.GetControl(0) 43 MultiPlayerButton = StartWindow.GetControl(1) 44 MoviesButton = StartWindow.GetControl(2) 45 ExitButton = StartWindow.GetControl(3) 46 47 BackToMain() 48 49 GemRB.LoadMusicPL("Theme.mus") 50 return 51 52def SinglePlayerPress(): 53 54 SinglePlayerButton.SetText(13728) 55 MultiPlayerButton.SetText(13729) 56 MoviesButton.SetText(24110) 57 ExitButton.SetText(15416) 58 MultiPlayerButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, LoadSingle) 59 SinglePlayerButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NewSingle) 60 ExitButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackToMain) 61 ExitButton.MakeEscape() 62 if HasTOTSC(): 63 MoviesButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, MissionPack) 64 else: 65 MoviesButton.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_OR) 66 MoviesButton.SetStatus(IE_GUI_BUTTON_DISABLED) 67 68 return 69 70def MultiPlayerPress(): 71 72 SinglePlayerButton.SetText(11825) 73 MultiPlayerButton.SetText(20642) 74 MoviesButton.SetText(15416) 75 ExitButton.SetText("") 76 SinglePlayerButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, PregenPress) 77 MultiPlayerButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, ConnectPress) 78 MoviesButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackToMain) 79 MoviesButton.MakeEscape() 80 ExitButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, None) 81 ExitButton.SetStatus(IE_GUI_BUTTON_DISABLED) 82 ExitButton.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET) 83 return 84 85def ConnectPress(): 86#well... 87 return 88 89def PregenPress(): 90 GemRB.SetVar("PlayMode",0) #loadgame needs this hack 91 GemRB.SetVar("Slot",1) 92 GemRB.LoadGame(None) 93 GemRB.SetVar("PlayMode",-1) 94 GemRB.SetNextScript("CharGen") 95 return 96 97def LoadSingle(): 98 GemRB.SetVar("PlayMode",0) 99 GemRB.SetToken ("SaveDir", "save") 100 GemRB.SetNextScript("GUILOAD") 101 return 102 103def MissionPack(): 104 GemRB.SetVar("PlayMode",1) 105 GemRB.SetToken ("SaveDir", "mpsave") 106 GemRB.SetNextScript("GUILOAD") 107 return 108 109def NewSingle(): 110 GemRB.SetVar("PlayMode",0) 111 GemRB.SetVar("Slot",1) 112 GemRB.LoadGame(None) 113 GemRB.SetNextScript("CharGen") #temporarily 114 return 115 116def ExitPress(): 117 QuitWindow = GemRB.LoadWindow (3, "START") 118 119 QuitTextArea = QuitWindow.GetControl (0) 120 QuitTextArea.SetText (19532) 121 122 CancelButton = QuitWindow.GetControl (2) 123 CancelButton.SetText (13727) 124 CancelButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, lambda: QuitWindow.Close()) 125 CancelButton.MakeEscape () 126 127 ConfirmButton = QuitWindow.GetControl (1) 128 ConfirmButton.SetText (15417) 129 ConfirmButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, ExitConfirmed) 130 ConfirmButton.MakeDefault () 131 132 QuitWindow.ShowModal (MODAL_SHADOW_GRAY) 133 return 134 135def ExitConfirmed(): 136 GemRB.Quit() 137 return 138 139def MoviesPress(): 140 GemRB.SetNextScript("GUIMOVIE") 141 return 142 143def BackToMain(): 144 SinglePlayerButton.SetStatus(IE_GUI_BUTTON_ENABLED) 145 MultiPlayerButton.SetStatus(IE_GUI_BUTTON_ENABLED) 146 MoviesButton.SetStatus(IE_GUI_BUTTON_ENABLED) 147 ExitButton.SetStatus(IE_GUI_BUTTON_ENABLED) 148 SinglePlayerButton.SetText(15413) 149 MultiPlayerButton.SetText(15414) 150 MoviesButton.SetText(15415) 151 ExitButton.SetText(15417) 152 SinglePlayerButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, SinglePlayerPress) 153 MultiPlayerButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, MultiPlayerPress) 154 MoviesButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, MoviesPress) 155 ExitButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, ExitPress) 156 MoviesButton.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_NAND) 157 ExitButton.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_NAND) 158 ExitButton.MakeEscape() 159 160 return 161