Ejemplo n.º 1
0
def ConfirmedSaveGame(Pos):
    global ConfirmWindow

    Label = ConfirmWindow.GetControl(ctrl_offset[7])
    Slotname = Label.QueryText()
    Slotname = Slotname.replace("/",
                                "|")  # can't have path separators in the name

    # Empty save name. We can get here if user presses Enter key
    if Slotname == "":
        return

    # We have to close floating window first
    CloseConfirmWindow()
    #FIXME: make this work
    #LoadScreen.StartLoadScreen (LoadScreen.LS_TYPE_SAVING)

    CloseSaveWindow()
    GUICommonWindows.CloseTopWindow()

    if Pos < len(Games):
        GemRB.SaveGame(Games[Pos], Slotname, sav_version)
    else:
        GemRB.SaveGame(None, Slotname, sav_version)
    return
Ejemplo n.º 2
0
def QuitGamePress ():
	if GemRB.GetVar("AskAndExit") == 1:
		GemRB.Quit()
		return

	CloseQuitMsgWindow()

	GUICommonWindows.CloseTopWindow ()
	GemRB.QuitGame ()
	GemRB.SetNextScript ("Start")
	return
Ejemplo n.º 3
0
def MoveToNewArea():
    import GUIMA
    travel = GUIMA.WorldMapControl.GetDestinationArea(
        not GameCheck.IsPST())  # no random encounters in pst, AFAIR
    if not travel:
        return

    hours = travel["Distance"]
    GUICommonWindows.CloseTopWindow()
    if GemRB.GetView("WIN_PSTWMAP"):
        GemRB.GetView("WIN_PSTWMAP").Close()
        GemRB.SetVar("Travel", -1)
        GemRB.GamePause(0, 0)

    if travel["Destination"].lower() == GemRB.GetGameString(
            STR_AREANAME).lower():
        return
    elif hours == -1:
        print("Invalid target", travel)
        return

    GemRB.CreateMovement(travel["Destination"], travel["Entrance"],
                         travel["Direction"])

    if hours == 0:
        return

    # distance is stored in hours, but the action needs seconds
    GemRB.ExecuteString("AdvanceTime(%d)" % (hours * 300), 1)

    # ~The journey took <DURATION>.~ but pst has it without the token
    if GameCheck.IsPST():
        # GemRB.DisplayString can only deal with resrefs, so cheat until noticed
        if hours > 1:
            GemRB.Log(
                LOG_MESSAGE, "Actor",
                GemRB.GetString(19261) + str(hours) + " " +
                GemRB.GetString(19313))
        else:
            GemRB.Log(
                LOG_MESSAGE, "Actor",
                GemRB.GetString(19261) + str(hours) + " " +
                GemRB.GetString(19312))
    else:
        time = ""
        GemRB.SetToken("HOUR", str(hours))
        if hours > 1:
            time = GemRB.GetString(10700)
        else:
            time = GemRB.GetString(10701)
        GemRB.SetToken("DURATION", time)
        GemRB.DisplayString(10689, ColorWhite)
Ejemplo n.º 4
0
def DialogStarted ():
	global ContinueWindow

	# try to force-close anything which is open
	GUICommonWindows.CloseTopWindow()
	Container.CloseContainerWindow()

	# opening control size to maximum, enabling dialog window
	CommonWindow.SetGameGUIHidden(False)
	GemRB.GameSetScreenFlags(GS_DIALOG, OP_OR)

	# disable the 1-6 hotkeys, so they'll work for choosing answers
	if GemRB.GetView ("PORTWIN"):
		GUICommonWindows.UpdatePortraitWindow ()

	ContinueWindow = OpenDialogButton(9)
Ejemplo n.º 5
0
def DialogStarted ():
	global ContinueWindow

	GUICommonWindows.CloseTopWindow()
	Container.CloseContainerWindow()

	# opening control size to maximum, enabling dialog window
	CommonWindow.SetGameGUIHidden(False)
	GemRB.GameSetScreenFlags(GS_DIALOG, OP_OR)
	
	# disable the 1-6 hotkeys, so they'll work for choosing answers
	GUICommonWindows.UpdatePortraitWindow ()

	MWin = GemRB.GetView("MSGWIN")
	CloseButton= MWin.GetControl (0)
	CloseButton.SetText ("")
	CloseButton.SetDisabled(True)
	CloseButton.SetFlags (IE_GUI_BUTTON_NO_IMAGE, OP_OR)
Ejemplo n.º 6
0
def CloseMapWindow():
    global WorldMapControl, AreaMapControl

    WorldMapControl = None
    AreaMapControl = None
    GUICommonWindows.CloseTopWindow()
Ejemplo n.º 7
0
def StartTextScreen():
    global TextScreen, TextArea, TableName, Row

    # for easier development
    if GameCheck.IsGemRBDemo() and GemRB.GetVar(
            "SkipIntroVideos") and not GemRB.GetGameVar("completed"):
        GemRB.GamePause(0, 3)
        return

    GemRB.GamePause(1, 3)
    ToggleAmbients(0)

    ID = -1
    MusicName = "*"
    Message = 17556  # default: Paused for chapter text
    TableName = GemRB.GetGameString(STR_TEXTSCREEN)

    #iwd2/bg2 has no separate music
    if GameCheck.IsIWD1():
        if TableName == "":
            MusicName = "chap0"
        else:
            MusicName = "chap1"
        TableName = "chapters"
    elif GameCheck.IsIWD2():
        TableName = "chapters"
    elif GameCheck.IsGemRBDemo():
        #TODO: set MusicName
        TableName = "chapters"

    if TableName == "":
        EndTextScreen()
        return

    if GemRB.HasResource("textscrn", RES_2DA, 1):
        TextTable = GemRB.LoadTable("textscrn", 1)
        if TextTable != None:
            TxtRow = TextTable.GetRowIndex(TableName)
            if TxtRow >= 0:
                ID = TextTable.GetValue(TxtRow, 0)
                MusicName = TextTable.GetValue(TxtRow, 1)
                Message = TextTable.GetValue(TxtRow, 2)

    if Message != "*":
        GemRB.DisplayString(Message, ColorRed)

    Table = GemRB.LoadTable(TableName)
    if GameCheck.IsBG2():
        LoadPic = Table.GetValue(-1, -1)
        if LoadPic.startswith("*"):  # BG2 epilogues
            ID = 63
            LoadPic = LoadPic.replace("*", "")
        else:
            ID = 62
    elif ID == -1:
        #default: try to determine ID from current chapter
        ID = GemRB.GetGameVar("CHAPTER") & 0x7fffffff
        Chapter = ID + 1

    if MusicName != "*":
        GemRB.LoadMusicPL(MusicName + ".mus")
    else:
        GemRB.HardEndPL()

    TextScreen = GemRB.LoadWindow(ID, "GUICHAP")
    TextArea = TextScreen.GetControl(2)
    TextArea.SetFlags(IE_GUI_VIEW_IGNORE_EVENTS, OP_OR)
    TextArea.SetColor(ColorWhitish, TA_COLOR_INITIALS)

    GameWin = GemRB.GetView("GAMEWIN")
    GameWin.SetDisabled(True)

    if GameCheck.IsBG1():
        #these suckers couldn't use a fix row
        FindTextRow(Table)
    elif GameCheck.IsBG2():
        FindTextRow(Table)
        if LoadPic != "":
            if ID == 63:
                #only for BG2 epilogue windows
                PicButton = TextScreen.GetControl(4)
                PicButton.SetPicture(LoadPic)
                PicButton.SetState(IE_GUI_BUTTON_LOCKED)
            else:
                TextScreen.SetBackground(LoadPic)
    else:
        Row = Chapter

    #caption
    Value = Table.GetValue(Row, 0)
    #don't display the fake -1 string (No caption in toscst.2da)
    Label = TextScreen.GetControl(0x10000000)
    if Label and Value != "NONE" and Value > 0:
        Label.SetText(Value)

    #done
    Button = TextScreen.GetControl(0)
    if GameCheck.IsGemRBDemo():
        Button.SetText(84)
    else:
        Button.SetText(11973)
    Button.OnPress(EndTextScreen)
    Button.MakeDefault()

    #replay
    Button = TextScreen.GetControl(3)
    if GameCheck.IsGemRBDemo():
        Button.SetText(85)
    else:
        Button.SetText(16510)
    Button.OnPress(ReplayTextScreen)

    #if this was opened from somewhere other than game control close that window
    import GUICommonWindows
    GUICommonWindows.CloseTopWindow()

    TextScreen.ShowModal(MODAL_SHADOW_NONE)

    ReplayTextScreen()
    return
Ejemplo n.º 8
0
def CloseAll(win):
    win.Close()
    GUICommonWindows.CloseTopWindow()