1# -*-python-*- 2# GemRB - Infinity Engine Emulator 3# Copyright (C) 2003 The GemRB Project 4# 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. 9# 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. 14# 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. 18# 19 20# 21import GemRB 22import LoadScreen 23from GUIDefines import * 24from datetime import datetime 25 26QuickLoadSlot = 0 27StartWindow = None; 28 29def OnLoad(): 30 global StartWindow, QuickLoadSlot 31 32 skip_videos = GemRB.GetVar ("SkipIntroVideos") 33 if not skip_videos: 34 GemRB.PlayMovie ('BISLOGO', 1) 35 GemRB.PlayMovie ('WOTC', 1) 36 GemRB.PlayMovie ('NVIDIA', 1) 37 GemRB.PlayMovie ('INTRO', 1) 38 GemRB.SetVar ("SkipIntroVideos", 1) 39 40#main window 41 StartWindow = GemRB.LoadWindow(0, "GUICONN") 42 time = datetime.now() 43 44 # IWD2 has some nice background for the night 45 if time.hour >= 18 or time.hour <= 6: 46 StartWindow.SetBackground ("STARTN"); 47 48 AnimButton = StartWindow.CreateButton (0xfff0001, 57, 333, 100, 100); 49 AnimButton.SetAnimation ("MMTRCHB") 50 AnimButton.SetState (IE_GUI_BUTTON_LOCKED) 51 AnimButton.SetFlags (IE_GUI_BUTTON_ANIMATED|IE_GUI_BUTTON_PLAYALWAYS|IE_GUI_BUTTON_CENTER_PICTURES, OP_OR) 52 53 ProtocolButton = StartWindow.GetControl(0x00) 54 NewGameButton = StartWindow.GetControl(0x02) 55 LoadGameButton = StartWindow.GetControl(0x07) 56 QuickLoadButton = StartWindow.GetControl(0x03) 57 JoinGameButton = StartWindow.GetControl(0x0B) 58 OptionsButton = StartWindow.GetControl(0x08) 59 QuitGameButton = StartWindow.GetControl(0x01) 60 VersionLabel = StartWindow.CreateLabel(0x0fff0000, 0,0,800,30, "REALMS2", "", IE_FONT_SINGLE_LINE | IE_FONT_ALIGN_CENTER) 61 VersionLabel.SetText(GemRB.Version) 62 ProtocolButton.SetStatus(IE_GUI_BUTTON_ENABLED) 63 NewGameButton.SetStatus(IE_GUI_BUTTON_ENABLED) 64 LoadGameButton.SetStatus(IE_GUI_BUTTON_ENABLED) 65 66 GemRB.SetToken ("SaveDir", "mpsave") 67 Games=GemRB.GetSaveGames() 68 69 #looking for the quicksave 70 EnableQuickLoad = IE_GUI_BUTTON_DISABLED 71 for Game in Games: 72 Slotname = Game.GetSaveID() 73 # quick save is 1 74 if Slotname == 1: 75 EnableQuickLoad = IE_GUI_BUTTON_ENABLED 76 QuickLoadSlot = Game 77 break 78 79 QuickLoadButton.SetStatus(EnableQuickLoad) 80 JoinGameButton.SetStatus(IE_GUI_BUTTON_DISABLED) 81 OptionsButton.SetStatus(IE_GUI_BUTTON_ENABLED) 82 QuitGameButton.SetStatus(IE_GUI_BUTTON_ENABLED) 83 LastProtocol = GemRB.GetVar("Last Protocol Used") 84 if LastProtocol == 0: 85 ProtocolButton.SetText(15413) 86 elif LastProtocol == 1: 87 ProtocolButton.SetText(13967) 88 elif LastProtocol == 2: 89 ProtocolButton.SetText(13968) 90 NewGameButton.SetText(13963) 91 LoadGameButton.SetText(13729) 92 QuickLoadButton.SetText(33508) 93 JoinGameButton.SetText(13964) 94 OptionsButton.SetText(13905) 95 QuitGameButton.SetText(13731) 96 QuitGameButton.MakeEscape() 97 NewGameButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NewGamePress) 98 QuitGameButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, QuitPress) 99 ProtocolButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, ProtocolPress) 100 OptionsButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, OptionsPress) 101 LoadGameButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, LoadPress) 102 QuickLoadButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, QuickLoadPress) 103 StartWindow.Focus() 104 GemRB.LoadMusicPL("Theme.mus") 105 106 StartWindow.SetAction(RefreshProtocol, ACTION_WINDOW_FOCUS_GAINED) 107 108 return 109 110def ProtocolPress(): 111 ProtocolWindow = GemRB.LoadWindow(1, "GUICONN") 112 113 #Disabling Unused Buttons in this Window 114 Button = ProtocolWindow.GetControl(2) 115 Button.SetState(IE_GUI_BUTTON_DISABLED) 116 Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_OR) 117 Button = ProtocolWindow.GetControl(3) 118 Button.SetState(IE_GUI_BUTTON_DISABLED) 119 Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_OR) 120 Button = ProtocolWindow.GetControl(9) 121 Button.SetState(IE_GUI_BUTTON_DISABLED) 122 Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_OR) 123 124 SinglePlayerButton = ProtocolWindow.GetControl(10) 125 SinglePlayerButton.SetFlags(IE_GUI_BUTTON_RADIOBUTTON,OP_OR) 126 SinglePlayerButton.SetText(15413) 127 128 IPXButton = ProtocolWindow.GetControl(0) 129 IPXButton.SetFlags(IE_GUI_BUTTON_RADIOBUTTON,OP_OR) 130 IPXButton.SetText(13967) 131 132 TCPIPButton = ProtocolWindow.GetControl(1) 133 TCPIPButton.SetFlags(IE_GUI_BUTTON_RADIOBUTTON,OP_OR) 134 TCPIPButton.SetText(13968) 135 136 SinglePlayerButton.SetVarAssoc("Last Protocol Used", 0) 137 IPXButton.SetVarAssoc("Last Protocol Used", 1) 138 TCPIPButton.SetVarAssoc("Last Protocol Used", 2) 139 140 TextArea = ProtocolWindow.GetControl(7) 141 TextArea.SetText(11316) 142 143 DoneButton = ProtocolWindow.GetControl(6) 144 DoneButton.SetText(11973) 145 DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, lambda: ProtocolWindow.Close()) 146 DoneButton.MakeEscape() 147 148 ProtocolWindow.Focus() 149 return 150 151def RefreshProtocol(win): 152 ProtocolButton = win.GetControl(0) 153 154 LastProtocol = GemRB.GetVar("Last Protocol Used") 155 if LastProtocol == 0: 156 ProtocolButton.SetText(15413) 157 elif LastProtocol == 1: 158 ProtocolButton.SetText(13967) 159 elif LastProtocol == 2: 160 ProtocolButton.SetText(13968) 161 162 return 163 164def LoadPress(): 165 GemRB.SetNextScript("GUILOAD") 166 return 167 168def QuickLoadPress(): 169 global QuickLoadSlot 170 171 LoadScreen.StartLoadScreen() 172 GemRB.LoadGame(QuickLoadSlot) # load & start game 173 GemRB.EnterGame() 174 return 175 176def OptionsPress(): 177 GemRB.SetNextScript("Options") 178 return 179 180def QuitPress(): 181 QuitWindow = GemRB.LoadWindow(22) 182 CancelButton = QuitWindow.GetControl(2) 183 CancelButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, lambda: QuitWindow.Close()) 184 CancelButton.MakeEscape() 185 186 QuitButton = QuitWindow.GetControl(1) 187 QuitButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, lambda: GemRB.Quit()) 188 QuitButton.MakeDefault() 189 190 TextArea = QuitWindow.GetControl(0) 191 CancelButton.SetText(13727) 192 QuitButton.SetText(15417) 193 TextArea.SetText(19532) 194 QuitWindow.ShowModal (MODAL_SHADOW_GRAY) 195 return 196 197def NewGamePress(): 198 StartWindow.Close() 199 GemRB.SetNextScript("SPParty") 200 return 201