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# 19#character generation, import (GUICG20) 20import GemRB 21from GUIDefines import * 22import GUICommon 23import CharGenCommon 24 25#import from a character sheet 26ImportWindow = 0 27TextAreaControl = 0 28 29def OnLoad(): 30 global ImportWindow, TextAreaControl 31 32 ImportWindow = GemRB.LoadWindow(20, "GUICG") 33 34 TextAreaControl = ImportWindow.GetControl(4) 35 TextAreaControl.SetText(10963) 36 37 TextAreaControl = ImportWindow.GetControl(2) 38 TextAreaControl.ListResources(CHR_EXPORTS) 39 40 DoneButton = ImportWindow.GetControl(0) 41 DoneButton.SetText (11973) 42 43 DoneButton.SetState(IE_GUI_BUTTON_DISABLED) 44 45 CancelButton = ImportWindow.GetControl(1) 46 CancelButton.SetText (13727) 47 48 DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, DonePress) 49 CancelButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CancelPress) 50 TextAreaControl.SetEvent(IE_GUI_TEXTAREA_ON_SELECT, SelectPress) 51 ImportWindow.ShowModal(MODAL_SHADOW_NONE) 52 return 53 54def SelectPress(): 55 DoneButton = ImportWindow.GetControl(0) 56 DoneButton.SetState(IE_GUI_BUTTON_ENABLED) 57 return 58 59def DonePress(): 60 ImportWindow.Close() 61 FileName = TextAreaControl.QueryText() 62 Slot = GemRB.GetVar("Slot") 63 GemRB.CreatePlayer(FileName, Slot| 0x8000, 1) 64 65 GemRB.SetToken ("CHARNAME", GemRB.GetPlayerName (Slot)) 66 GemRB.SetToken ("SmallPortrait", GemRB.GetPlayerPortrait (Slot, 1)["ResRef"]) 67 GemRB.SetToken ("LargePortrait", GemRB.GetPlayerPortrait (Slot, 0)["ResRef"]) 68 69 GemRB.SetVar ("ImportedChar", 1) 70 CharGenCommon.jumpTo("appearance") 71 return 72 73def CancelPress(): 74 ImportWindow.Close() 75 GemRB.SetNextScript(GemRB.GetToken("NextScript")) 76 return 77