Пример #1
0
def OpenReformPartyWindow ():
	global ReformPartyWindow
	global removable_pcs

	GemRB.SetVar ("Selected", 0)
	hideflag = CommonWindow.IsGameGUIHidden()

	if ReformPartyWindow:
		ReformPartyWindow.Unload ()
		ReformPartyWindow = None

		CommonWindow.SetGameGUIHidden(hideflag)
		#re-enabling party size control
		GemRB.GameSetPartySize (MAX_PARTY_SIZE)
		GUICommonWindows.UpdatePortraitWindow()
		return

	ReformPartyWindow = Window = GemRB.LoadWindow (24, GUICommon.GetWindowPack(), WINDOW_HCENTER|WINDOW_BOTTOM)

	# skip exportable party members (usually only the protagonist)
	removable_pcs = []
	for i in range (1, GemRB.GetPartySize()+1):
		if not GemRB.GetPlayerStat (i, IE_MC_FLAGS)&MC_EXPORTABLE:
			removable_pcs.append(i)

	#PC portraits
	PortraitButtons = GUICommonWindows.GetPortraitButtonPairs (Window, 1, "horizontal")
	for j in PortraitButtons:
		Button = PortraitButtons[j]
		Button.SetState (IE_GUI_BUTTON_LOCKED)
		Button.SetFlags (IE_GUI_BUTTON_RADIOBUTTON|IE_GUI_BUTTON_NO_IMAGE|IE_GUI_BUTTON_PICTURE,OP_SET)
		color = {'r' : 0, 'g' : 255, 'b' : 0, 'a' : 255}
		Button.SetBorder (FRAME_PC_SELECTED, color, 0, 0, Button.GetInsetFrame(1,1,2,2))
		if j < len(removable_pcs):
			Button.SetVarAssoc ("Selected", removable_pcs[j])
		Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, UpdateReformWindow)

	# Remove
	Button = Window.GetControl (15)
	Button.SetText (17507)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, RemovePlayer)

	# Done
	Button = Window.GetControl (8)
	Button.SetText (11973)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenReformPartyWindow)

	# if nobody can be removed, just close the window
	if not removable_pcs:
		OpenReformPartyWindow ()
		CommonWindow.SetGameGUIHidden(hideflag)
		return

	UpdateReformWindow ()
	CommonWindow.SetGameGUIHidden(hideflag)

	Window.ShowModal (MODAL_SHADOW_GRAY)
	return
Пример #2
0
def UpdateReformWindow():
    Window = ReformPartyWindow

    select = GemRB.GetVar("Selected")

    need_to_drop = GemRB.GetPartySize() - MAX_PARTY_SIZE
    if need_to_drop < 0:
        need_to_drop = 0

    #excess player number
    Label = Window.GetControl(0x1000000f)
    Label.SetText(str(need_to_drop))

    #done
    Button = Window.GetControl(8)
    if need_to_drop:
        Button.SetState(IE_GUI_BUTTON_DISABLED)
    else:
        Button.SetState(IE_GUI_BUTTON_ENABLED)

    #remove
    Button = Window.GetControl(15)
    if select:
        Button.SetState(IE_GUI_BUTTON_ENABLED)
    else:
        Button.SetState(IE_GUI_BUTTON_DISABLED)

    PortraitButtons = GUICommonWindows.GetPortraitButtonPairs(
        Window, 1, "horizontal")
    for i in PortraitButtons:
        Button = PortraitButtons[i]
        if i + 1 not in removable_pcs:
            Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
            Button.SetState(IE_GUI_BUTTON_LOCKED)

    for i in removable_pcs:
        index = removable_pcs.index(i)
        if index not in PortraitButtons:
            continue  # for saved games with higher party count than the current setup supports
        Button = PortraitButtons[index]
        Button.EnableBorder(FRAME_PC_SELECTED, select == i)
        pic = GemRB.GetPlayerPortrait(i, 1)
        if not pic:
            Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
            Button.SetState(IE_GUI_BUTTON_LOCKED)
            continue
        Button.SetState(IE_GUI_BUTTON_ENABLED)
        Button.SetFlags(
            IE_GUI_BUTTON_PICTURE | IE_GUI_BUTTON_ALIGN_BOTTOM
            | IE_GUI_BUTTON_ALIGN_LEFT, OP_SET)
        Button.SetPicture(pic, "NOPORTSM")
    GUICommonWindows.UpdatePortraitWindow()
    return
Пример #3
0
def OpenReformPartyWindow():
    global removable_pcs

    hideflag = CommonWindow.IsGameGUIHidden()

    Window = GemRB.LoadWindow(24, GUICommon.GetWindowPack(),
                              WINDOW_HCENTER | WINDOW_BOTTOM)
    Window.AddAlias("WIN_REFORM", 0)

    # skip exportable party members (usually only the protagonist)
    removable_pcs = []
    for i in range(1, GemRB.GetPartySize() + 1):
        if not GemRB.GetPlayerStat(i, IE_MC_FLAGS) & MC_EXPORTABLE:
            removable_pcs.append(i)

    #PC portraits
    PortraitButtons = GUICommonWindows.GetPortraitButtonPairs(
        Window, 1, "horizontal")
    for j in PortraitButtons:
        Button = PortraitButtons[j]
        Button.SetState(IE_GUI_BUTTON_LOCKED)
        Button.SetFlags(
            IE_GUI_BUTTON_RADIOBUTTON | IE_GUI_BUTTON_NO_IMAGE
            | IE_GUI_BUTTON_PICTURE, OP_SET)
        color = {'r': 0, 'g': 255, 'b': 0, 'a': 255}
        Button.SetBorder(FRAME_PC_SELECTED, color, 0, 0,
                         Button.GetInsetFrame(1, 1, 2, 2))
        if j < len(removable_pcs):
            Button.SetValue(removable_pcs[j])
        else:
            Button.SetValue(None)

        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS,
                        lambda btn: UpdateReformWindow(Window, btn.Value))

    # Done
    Button = Window.GetControl(8)
    Button.SetText(11973)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, lambda: Window.Close())

    # if nobody can be removed, just close the window
    if not removable_pcs:
        Window.Close()
        CommonWindow.SetGameGUIHidden(hideflag)
        return

    UpdateReformWindow(Window, None)
    CommonWindow.SetGameGUIHidden(hideflag)

    Window.ShowModal(MODAL_SHADOW_GRAY)
    return
Пример #4
0
def OpenReformPartyWindow():
    global ReformPartyWindow, OldActionsWindow, OldMessageWindow
    global removable_pcs

    GemRB.SetVar("Selected", 0)
    hideflag = GemRB.HideGUI()

    if ReformPartyWindow:
        ReformPartyWindow.Unload()
        GemRB.SetVar("ActionsWindow", OldActionsWindow.ID)
        GemRB.SetVar("MessageWindow", OldMessageWindow.ID)
        GemRB.SetVar("OtherWindow", -1)

        OldActionsWindow = None
        OldMessageWindow = None
        ReformPartyWindow = None
        if hideflag:
            GemRB.UnhideGUI()
        #re-enabling party size control
        GemRB.GameSetPartySize(MAX_PARTY_SIZE)
        GUICommonWindows.UpdatePortraitWindow()
        return

    GemRB.LoadWindowPack(GUICommon.GetWindowPack())
    ReformPartyWindow = Window = GemRB.LoadWindow(24)
    GemRB.SetVar("OtherWindow", Window.ID)

    # skip exportable party members (usually only the protagonist)
    removable_pcs = []
    for i in range(1, GemRB.GetPartySize() + 1):
        if not GemRB.GetPlayerStat(i, IE_MC_FLAGS) & MC_EXPORTABLE:
            removable_pcs.append(i)

    #PC portraits
    PortraitButtons = GUICommonWindows.GetPortraitButtonPairs(
        Window, 1, "horizontal")
    for j in PortraitButtons:
        Button = PortraitButtons[j]
        Button.SetState(IE_GUI_BUTTON_LOCKED)
        Button.SetFlags(
            IE_GUI_BUTTON_RADIOBUTTON | IE_GUI_BUTTON_NO_IMAGE
            | IE_GUI_BUTTON_PICTURE, OP_SET)
        Button.SetBorder(FRAME_PC_SELECTED, 1, 1, 2, 2, 0, 255, 0, 255)
        if j < len(removable_pcs):
            Button.SetVarAssoc("Selected", removable_pcs[j])
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, UpdateReformWindow)

    # Remove
    Button = Window.GetControl(15)
    Button.SetText(17507)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, RemovePlayer)

    # Done
    Button = Window.GetControl(8)
    Button.SetText(11973)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenReformPartyWindow)

    OldActionsWindow = GUIClasses.GWindow(GemRB.GetVar("ActionsWindow"))
    OldMessageWindow = GUIClasses.GWindow(GemRB.GetVar("MessageWindow"))
    GemRB.SetVar("ActionsWindow", -1)
    GemRB.SetVar("MessageWindow", -1)

    # if nobody can be removed, just close the window
    if not removable_pcs:
        OpenReformPartyWindow()
        if hideflag:
            GemRB.UnhideGUI()
        return

    UpdateReformWindow()
    if hideflag:
        GemRB.UnhideGUI()
    Window.ShowModal(MODAL_SHADOW_GRAY)
    return