def CreateRacesSelect(pTopicMenu): pLibraryWindow = GetLibraryWindow() pRaceDatabase = App.g_kLocalizationManager.Load("data/TGL/Races.tgl") i = 0 for race in Races.keys(): if race != "GodShips": if pRaceDatabase and pRaceDatabase.HasString(race): RaceTGS = pRaceDatabase.GetString(race) else: RaceTGS = App.TGString(race) # Setup the event for when this button is clicked pEvent = App.TGIntEvent_Create() pEvent.SetEventType(ET_TOPIC) pEvent.SetInt(i) # store the index so we know which button was clicked. pEvent.SetDestination(pLibraryWindow) pButton = App.STRoundedButton_CreateW(RaceTGS, pEvent, 0.20, 0.02) pButton.SetActivationEvent(pEvent) pTopicMenu.AddChild(pButton) pEvent.SetSource(pButton) i = i + 1 # Other ships pEvent = App.TGIntEvent_Create() pEvent.SetEventType(ET_TOPIC) pEvent.SetInt(99) pEvent.SetDestination(pLibraryWindow) pButton = App.STRoundedButton_CreateW(App.TGString("Minor Races"), pEvent, 0.20, 0.02) pButton.SetActivationEvent(pEvent) pTopicMenu.AddChild(pButton) pEvent.SetSource(pButton) App.g_kLocalizationManager.Unload(pRaceDatabase)
def SelectTopic(pObject, pEvent): SHIP_IMAGE_WIDTH = 0.2515625 SHIP_IMAGE_HEIGHT = 0.2458333 SelectedTopic = pEvent.GetInt() if SelectedTopic: pLibraryWindow = GetLibraryWindow() pLibraryWindow.ScrollToTop() pBodyMenu.KillChildren() if SelectedCategory == 1: FdtnShips = Foundation.shipList myship = FdtnShips[SelectedTopic] g_pShipsDatabase = App.g_kLocalizationManager.Load("data/TGL/Ships.tgl") pShipsHeader = App.TGParagraph_Create("", 0.1, None, "", 0.1, App.TGParagraph.TGPF_WORD_WRAP | App.TGParagraph.TGPF_READ_ONLY) pShipsHeader.SetStringW(g_pShipsDatabase.GetString(myship.GetShipFile())) pBodyMenu.AddChild(pShipsHeader) pIcon = App.TGIcon_Create("ShipIcons", App.SPECIES_UNKNOWN) pIcon.Resize(SHIP_IMAGE_WIDTH, SHIP_IMAGE_HEIGHT) iIconNumber = myship.GetIconNum() pIcon.SetVisible() pIcon.SetIconNum(iIconNumber) pIcon.SizeToArtwork() pBodyMenu.AddChild(pIcon) pShipsText = App.TGParagraph_Create("", 0.3, None, "", 1.0, App.TGParagraph.TGPF_WORD_WRAP | App.TGParagraph.TGPF_READ_ONLY) pShipsText.SetStringW(g_pShipsDatabase.GetString(myship.GetShipFile() + " Description")) pBodyMenu.AddChild(pShipsText) App.g_kLocalizationManager.Unload(g_pShipsDatabase) elif SelectedCategory == 2: FdtnSystems = Foundation.systemList mySystem = FdtnSystems[SelectedTopic] pSystemsDatabase = App.g_kLocalizationManager.Load("data/TGL/Systems.tgl") pSystemsHeader = App.TGParagraph_Create("", 0.1, None, "", 0.1, App.TGParagraph.TGPF_WORD_WRAP | App.TGParagraph.TGPF_READ_ONLY) pSystemsHeader.SetStringW(pSystemsDatabase.GetString(mySystem.name)) pBodyMenu.AddChild(pSystemsHeader) pGraphicsMode = App.GraphicsModeInfo_GetCurrentMode() pcLCARS = pGraphicsMode.GetLcarsString() pIcon = App.TGIcon_Create(pcLCARS, 800) pIcon.Resize(SHIP_IMAGE_WIDTH, SHIP_IMAGE_HEIGHT) pIcon.SetVisible() pIcon.SizeToArtwork() pBodyMenu.AddChild(pIcon) pSystemsText = App.TGParagraph_Create("", 0.3, None, "", 1.0, App.TGParagraph.TGPF_WORD_WRAP | App.TGParagraph.TGPF_READ_ONLY) pSystemsText.SetStringW(pSystemsDatabase.GetString(mySystem.name + " Description")) pBodyMenu.AddChild(pSystemsText) App.g_kLocalizationManager.Unload(pSystemsDatabase) elif SelectedCategory == 3: pRaceDatabase = App.g_kLocalizationManager.Load("data/TGL/Races.tgl") i = 0 iIconNumber = 0 myRace = None for race in Races.keys(): print i, race if race != "GodShips": if SelectedTopic == i: myRace = race iIconNumber = i break elif SelectedTopic == 99: myRace = "Other" iIconNumber = 99 break i = i + 1 pRacesHeader = App.TGParagraph_Create("", 0.1, None, "", 0.1, App.TGParagraph.TGPF_WORD_WRAP | App.TGParagraph.TGPF_READ_ONLY) if pRaceDatabase and pRaceDatabase.HasString(myRace): pRacesHeader.SetStringW(pRaceDatabase.GetString(myRace)) else: pRacesHeader.SetStringW(App.TGString(myRace)) pBodyMenu.AddChild(pRacesHeader) pIcon = App.TGIcon_Create("RacesIcons", App.SPECIES_UNKNOWN) pIcon.Resize(SHIP_IMAGE_WIDTH, SHIP_IMAGE_HEIGHT) pIcon.SetVisible() pIcon.SetIconNum(iIconNumber) pIcon.SizeToArtwork() pBodyMenu.AddChild(pIcon) if pRaceDatabase and pRaceDatabase.HasString(myRace + " Description"): pRacesText = App.TGParagraph_Create("", 0.3, None, "", 1.0, App.TGParagraph.TGPF_WORD_WRAP | App.TGParagraph.TGPF_READ_ONLY) pRacesText.SetStringW(pRaceDatabase.GetString(myRace + " Description")) pBodyMenu.AddChild(pRacesText) App.g_kLocalizationManager.Unload(pRaceDatabase)