diff --git a/assets/root/game.py b/assets/root/game.py index 84f0745d..8d4747fa 100644 --- a/assets/root/game.py +++ b/assets/root/game.py @@ -33,6 +33,7 @@ import uiAffectShower import uiPlayerGauge import uiCharacter import uiTarget +import uiAutopickup # PRIVATE_SHOP_PRICE_LIST import uiPrivateShopBuilder @@ -2177,6 +2178,7 @@ class GameWindow(ui.ScriptWindow): "PartyRequestDenied" : self.__PartyRequestDenied, "horse_state" : self.__Horse_UpdateState, "hide_horse_state" : self.__Horse_HideState, + "AutoPickupState" : self.__AutoPickupState, "WarUC" : self.__GuildWar_UpdateMemberCount, "test_server" : self.__EnableTestServerFlag, "mall" : self.__InGameShop_Show, @@ -2224,6 +2226,9 @@ class GameWindow(ui.ScriptWindow): def PartyHealReady(self): self.interface.PartyHealReady() + def __AutoPickupState(self, enabled, mode, mask, vip): + uiAutopickup.SetAutoPickupState(int(enabled), int(mode), int(mask), int(vip)) + def AskSafeboxPassword(self): self.interface.AskSafeboxPassword() diff --git a/assets/root/uiAutopickup.py b/assets/root/uiAutopickup.py new file mode 100644 index 00000000..0a290696 --- /dev/null +++ b/assets/root/uiAutopickup.py @@ -0,0 +1,145 @@ +import net +import ui + + +STATE_ENABLED = 0 +STATE_MODE = 0 +STATE_MASK = 31 +STATE_VIP = 0 +OPEN_WINDOWS = [] + +FILTERS = ( + (1, "Weapons"), + (2, "Armor"), + (4, "Yang"), + (8, "Stones"), + (16, "Materials"), +) + + +def SetAutoPickupState(enabled, mode, mask, vip): + global STATE_ENABLED + global STATE_MODE + global STATE_MASK + global STATE_VIP + + STATE_ENABLED = 1 if int(enabled) else 0 + STATE_MODE = 1 if int(mode) else 0 + STATE_MASK = int(mask) & 31 + STATE_VIP = 1 if int(vip) else 0 + + for window in OPEN_WINDOWS: + try: + window.ApplyState() + except: + pass + + +class AutoPickupWindow(ui.BoardWithTitleBar): + def __init__(self): + ui.BoardWithTitleBar.__init__(self) + + OPEN_WINDOWS.append(self) + + self.filterButtons = {} + + self.AddFlag("float") + self.AddFlag("movable") + self.SetSize(280, 248) + self.SetTitleName("Auto Pickup") + self.SetCloseEvent(self.Hide) + + self.__CreateChildren() + self.Hide() + + def __del__(self): + if self in OPEN_WINDOWS: + OPEN_WINDOWS.remove(self) + ui.BoardWithTitleBar.__del__(self) + + def Destroy(self): + if self in OPEN_WINDOWS: + OPEN_WINDOWS.remove(self) + self.ClearDictionary() + self.filterButtons = {} + + def __CreateChildren(self): + self.statusLine = self.__CreateLine(15, 36) + self.rangeLine = self.__CreateLine(15, 56) + self.modeLine = self.__CreateLine(15, 76) + self.noteLine = self.__CreateLine(15, 96) + + self.enableButton = self.__CreateButton(170, 34, 90, "Enable") + self.enableButton.SetEvent(self.__ToggleEnabled) + + self.whitelistButton = self.__CreateButton(15, 118, 118, "Whitelist") + self.whitelistButton.SetEvent(self.__SetMode, 0) + + self.blacklistButton = self.__CreateButton(142, 118, 118, "Blacklist") + self.blacklistButton.SetEvent(self.__SetMode, 1) + + for index, filterData in enumerate(FILTERS): + (bit, label) = filterData + button = self.__CreateButton(15, 150 + index * 18, 245, label) + button.SetEvent(self.__ToggleFilter, bit) + self.filterButtons[bit] = button + + def __CreateLine(self, x, y): + textLine = ui.TextLine() + textLine.SetParent(self) + textLine.SetPosition(x, y) + textLine.SetOutline() + textLine.Show() + return textLine + + def __CreateButton(self, x, y, width, text): + button = ui.Button() + button.SetParent(self) + button.SetPosition(x, y) + button.SetUpVisual("d:/ymir work/ui/public/small_thin_button_01.sub") + button.SetOverVisual("d:/ymir work/ui/public/small_thin_button_02.sub") + button.SetDownVisual("d:/ymir work/ui/public/small_thin_button_03.sub") + button.SetDisableVisual("d:/ymir work/ui/public/small_thin_button_01.sub") + button.SetSize(width, 17) + button.SetText(text) + button.Show() + return button + + def __Send(self, command): + net.SendChatPacket(command, 0) + + def __ToggleEnabled(self): + SetAutoPickupState(0 if STATE_ENABLED else 1, STATE_MODE, STATE_MASK, STATE_VIP) + self.__Send("/autopickup enable %d" % STATE_ENABLED) + + def __SetMode(self, mode): + SetAutoPickupState(STATE_ENABLED, mode, STATE_MASK, STATE_VIP) + self.__Send("/autopickup mode %s" % ("blacklist" if mode else "whitelist")) + + def __ToggleFilter(self, bit): + mask = STATE_MASK ^ bit + SetAutoPickupState(STATE_ENABLED, STATE_MODE, mask, STATE_VIP) + self.__Send("/autopickup mask %d" % STATE_MASK) + + def ApplyState(self): + self.statusLine.SetText("Status: %s" % ("Enabled" if STATE_ENABLED else "Disabled")) + self.rangeLine.SetText("Range: %s" % ("VIP 300 / Free 220" if STATE_VIP else "Free 220")) + self.modeLine.SetText("Mode: %s" % ("Blacklist" if STATE_MODE else "Whitelist")) + self.noteLine.SetText("Only nearby owned drops are valid") + self.enableButton.SetText("Disable" if STATE_ENABLED else "Enable") + + if STATE_MODE == 0: + self.whitelistButton.Down() + self.blacklistButton.SetUp() + else: + self.whitelistButton.SetUp() + self.blacklistButton.Down() + + for (bit, label) in FILTERS: + prefix = "[x]" if (STATE_MASK & bit) else "[ ]" + self.filterButtons[bit].SetText("%s %s" % (prefix, label)) + + def Show(self): + self.__Send("/autopickup sync") + self.ApplyState() + ui.BoardWithTitleBar.Show(self) diff --git a/assets/root/uigameoption.py b/assets/root/uigameoption.py index 56919877..601ababa 100644 --- a/assets/root/uigameoption.py +++ b/assets/root/uigameoption.py @@ -8,6 +8,7 @@ import localeInfo import constInfo import chrmgr import player +import uiAutopickup import uiPrivateShopBuilder # 占쏙옙占쏙옙호 import interfaceModule # 占쏙옙占쏙옙호 @@ -39,8 +40,14 @@ class OptionDialog(ui.ScriptWindow): self.alwaysShowNameButtonList = [] self.showDamageButtonList = [] self.showsalesTextButtonList = [] + self.autoPickupButton = None + self.autoPickupDialog = None def Destroy(self): + if self.autoPickupDialog: + self.autoPickupDialog.Destroy() + self.autoPickupDialog = None + self.ClearDictionary() self.__Initialize() @@ -80,6 +87,7 @@ class OptionDialog(ui.ScriptWindow): self.showDamageButtonList.append(GetObject("show_damage_off_button")) self.showsalesTextButtonList.append(GetObject("salestext_on_button")) self.showsalesTextButtonList.append(GetObject("salestext_off_button")) + self.autoPickupButton = GetObject("autopickup_button") except: import exception @@ -130,6 +138,7 @@ class OptionDialog(ui.ScriptWindow): self.showsalesTextButtonList[0].SAFE_SetEvent(self.__OnClickSalesTextOnButton) self.showsalesTextButtonList[1].SAFE_SetEvent(self.__OnClickSalesTextOffButton) + self.autoPickupButton.SAFE_SetEvent(self.__OnClickAutoPickupButton) self.__ClickRadioButton(self.nameColorModeButtonList, constInfo.GET_CHRNAME_COLOR_INDEX()) self.__ClickRadioButton(self.viewTargetBoardButtonList, constInfo.GET_VIEW_OTHER_EMPIRE_PLAYER_TARGET_BOARD()) @@ -241,6 +250,15 @@ class OptionDialog(ui.ScriptWindow): def __OnClickSalesTextOffButton(self): systemSetting.SetShowSalesTextFlag(False) self.RefreshShowSalesText() + + def __OnClickAutoPickupButton(self): + if not self.autoPickupDialog: + self.autoPickupDialog = uiAutopickup.AutoPickupWindow() + + if self.autoPickupDialog.IsShow(): + self.autoPickupDialog.Hide() + else: + self.autoPickupDialog.Show() def __CheckPvPProtectedLevelPlayer(self): if player.GetStatus(player.LEVEL)