Advertisement
deadx2

Untitled

Aug 16th, 2017
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 24.02 KB | None | 0 0
  1. import dbg
  2. import uimg
  3. import snd
  4. import systemSetting
  5. import net
  6. import chat
  7. import app
  8. import localemg
  9. import constInfo
  10. import chrmgr
  11. import player
  12. import uiPrivateShopBuilder # ±čÁŘČŁ
  13. import interfaceModule # ±čÁŘČŁ
  14.  
  15. import uiSelectMusic
  16. import background
  17. import musicInfo
  18.  
  19. blockMode = 0
  20. viewChatMode = 0
  21.  
  22. MUSIC_FILENAME_MAX_LEN = 25
  23.  
  24. MOBILE = FALSE
  25.  
  26. if localemg.IsYMIR():
  27.     MOBILE = TRUE
  28.  
  29.  
  30. class OptionDialog(uimg.ScriptWindow):
  31.  
  32.     def __init__(self):
  33.         uimg.ScriptWindow.__init__(self)
  34.         self.__Initialize()
  35.         self.__Load()
  36.         self.RefreshViewChat()
  37.         self.RefreshAlwaysShowName()
  38.         self.RefreshShowDamage()
  39.         self.RefreshShowSalesText()
  40.  
  41.     def __del__(self):
  42.         uimg.ScriptWindow.__del__(self)
  43.         print " -------------------------------------- DELETE GAME OPTION DIALOG"
  44.  
  45.     def __Initialize(self):
  46.         self.titleBar = 0
  47.         self.nameColorModeButtonList = []
  48.         self.viewTargetBoardButtonList = []
  49.         self.pvpModeButtonDict = {}
  50.         self.blockButtonList = []
  51.         self.blockTextList = []
  52.        
  53.        
  54.         self.changeMusicButton = 0
  55.         self.selectMusicFile = 0
  56.         self.ctrlMusicVolume = 0
  57.         self.ctrlSoundVolume = 0
  58.         self.musicListDlg = 0
  59.         self.tilingApplyButton = 0
  60.         self.cameraModeButtonList = []
  61.         self.fogModeButtonList = []
  62.         self.tilingModeButtonList = []
  63.         self.ctrlShadowQuality = 0
  64.        
  65.         self.PagesTextColor = []
  66.         self.PagesButtons = []
  67.        
  68.         self.PageList = ["OpcjeGracza", "OpcjeOgolne", "OpcjeGrafiki", "OpcjeDzwiekow"]
  69.         self.NapisyPrzyciskowOn = ["|cfff8d090Gracz","|cfff8d090Ogólne","|cfff8d090Grafika","|cfff8d090Dźwiek"]
  70.         self.NapisyPrzyciskowOff = ["Gracz","Ogólne","Grafika","Dźwiek"]
  71.        
  72.         self.viewChatButtonList = []
  73.         self.alwaysShowNameButtonList = []
  74.         self.showDamageButtonList = []
  75.         self.showsalesTextButtonList = []
  76.  
  77.     def Destroy(self):
  78.         self.ClearDictionary()
  79.  
  80.         self.__Initialize()
  81.         print " -------------------------------------- DESTROY GAME OPTION DIALOG"
  82.    
  83.     def __Load_LoadScript(self, fileName):
  84.         try:
  85.             pyScriptLoader = uimg.PythonScriptLoader()
  86.             pyScriptLoader.LoadScriptFile(self, fileName)
  87.         except:
  88.             import exception
  89.             exception.Abort("OptionDialog.__Load_LoadScript")
  90.  
  91.     def __Load_BindObject(self):
  92.         try:
  93.             GetObject = self.GetChild
  94.             self.titleBar = GetObject("titlebar")
  95.            
  96.             ## GAME OPTION
  97.             self.nameColorModeButtonList.append(GetObject("name_color_normal"))
  98.             self.nameColorModeButtonList.append(GetObject("name_color_empire"))
  99.             self.viewTargetBoardButtonList.append(GetObject("target_board_no_view"))
  100.             self.viewTargetBoardButtonList.append(GetObject("target_board_view"))
  101.             self.pvpModeButtonDict[player.PK_MODE_PEACE] = GetObject("pvp_peace")
  102.             self.pvpModeButtonDict[player.PK_MODE_REVENGE] = GetObject("pvp_revenge")
  103.             self.pvpModeButtonDict[player.PK_MODE_GUILD] = GetObject("pvp_guild")
  104.             self.pvpModeButtonDict[player.PK_MODE_FREE] = GetObject("pvp_free")
  105.             self.blockButtonList.append(GetObject("block_exchange_button"))
  106.             self.blockButtonList.append(GetObject("block_party_button"))
  107.             self.blockButtonList.append(GetObject("block_guild_button"))
  108.             self.blockButtonList.append(GetObject("block_whisper_button"))
  109.             self.blockButtonList.append(GetObject("block_friend_button"))
  110.             self.blockButtonList.append(GetObject("block_party_request_button"))
  111.            
  112.             ## SYSTEM OPTION
  113.             self.selectMusicFile = GetObject("bgm_file")
  114.             self.changeMusicButton = GetObject("bgm_button")
  115.             self.ctrlMusicVolume = GetObject("music_volume_controller")
  116.             self.ctrlSoundVolume = GetObject("sound_volume_controller")        
  117.             self.cameraModeButtonList.append(GetObject("camera_short"))
  118.             self.cameraModeButtonList.append(GetObject("camera_long"))
  119.             self.fogModeButtonList.append(GetObject("fog_level0"))
  120.             self.fogModeButtonList.append(GetObject("fog_level1"))
  121.             self.fogModeButtonList.append(GetObject("fog_level2"))
  122.             self.tilingModeButtonList.append(GetObject("tiling_cpu"))
  123.             self.tilingModeButtonList.append(GetObject("tiling_gpu"))
  124.             self.tilingApplyButton=GetObject("tiling_apply")
  125.             #self.ctrlShadowQuality = GetObject("shadow_bar")
  126.            
  127.            
  128.             self.blockTextList.append(GetObject("BlockText1"))
  129.             self.blockTextList.append(GetObject("BlockText2"))
  130.             self.blockTextList.append(GetObject("BlockText3"))
  131.             self.blockTextList.append(GetObject("BlockText4"))
  132.             self.blockTextList.append(GetObject("BlockText5"))
  133.             self.blockTextList.append(GetObject("BlockText6"))
  134.            
  135.             self.PagesTextColor.append(GetObject("Button1_Name"))
  136.             self.PagesTextColor.append(GetObject("Button2_Name"))
  137.             self.PagesTextColor.append(GetObject("Button3_Name"))
  138.             self.PagesTextColor.append(GetObject("Button4_Name"))
  139.            
  140.             self.PagesButtons.append(GetObject("Zakladka_01"))
  141.             self.PagesButtons.append(GetObject("Zakladka_02"))
  142.             self.PagesButtons.append(GetObject("Zakladka_03"))
  143.             self.PagesButtons.append(GetObject("Zakladka_04"))
  144.            
  145.             self.GetChild("Zakladka_01").SetEvent(lambda page="OpcjeGracza": self.PokazStrone(page))
  146.             self.GetChild("Zakladka_02").SetEvent(lambda page="OpcjeOgolne": self.PokazStrone(page))
  147.             self.GetChild("Zakladka_03").SetEvent(lambda page="OpcjeGrafiki": self.PokazStrone(page))
  148.             self.GetChild("Zakladka_04").SetEvent(lambda page="OpcjeDzwiekow": self.PokazStrone(page))
  149.            
  150.             self.viewChatButtonList.append(GetObject("view_chat_on_button"))
  151.             self.viewChatButtonList.append(GetObject("view_chat_off_button"))
  152.             self.alwaysShowNameButtonList.append(GetObject("always_show_name_on_button"))
  153.             self.alwaysShowNameButtonList.append(GetObject("always_show_name_off_button"))
  154.             self.showDamageButtonList.append(GetObject("show_damage_on_button"))
  155.             self.showDamageButtonList.append(GetObject("show_damage_off_button"))
  156.             self.showsalesTextButtonList.append(GetObject("salestext_on_button"))
  157.             self.showsalesTextButtonList.append(GetObject("salestext_off_button"))
  158.             self.ctrlShopNamesRange = GetObject("salestext_range_controller")
  159.            
  160.             self.GetChild("OpcjeGracza").Show()
  161.             self.GetChild("OpcjeOgolne").Hide()
  162.             self.GetChild("OpcjeGrafiki").Hide()
  163.             self.GetChild("OpcjeDzwiekow").Hide()
  164.  
  165.             global MOBILE
  166.             if MOBILE:
  167.                 self.inputMobileButton = GetObject("input_mobile_button")
  168.                 self.deleteMobileButton = GetObject("delete_mobile_button")
  169.  
  170.  
  171.         except:
  172.             import exception
  173.             exception.Abort("OptionDialog.__Load_BindObject")
  174.  
  175.     def __Load(self):
  176.         global MOBILE
  177.         if MOBILE:
  178.             self.__Load_LoadScript("uiscript/gameoptiondialog_formobile.py")
  179.         else:
  180.             self.__Load_LoadScript("uiscript/gameoptiondialog.py")
  181.  
  182.         self.__Load_BindObject()
  183.  
  184.         self.SetCenterPosition()
  185.  
  186.         self.titleBar.SetCloseEvent(uimg.__mem_func__(self.Close))
  187.  
  188.         ## GAME OPTION
  189.         self.nameColorModeButtonList[0].SAFE_SetEvent(self.__OnClickNameColorModeNormalButton)
  190.         self.nameColorModeButtonList[1].SAFE_SetEvent(self.__OnClickNameColorModeEmpireButton)
  191.         self.viewTargetBoardButtonList[0].SAFE_SetEvent(self.__OnClickTargetBoardViewButton)
  192.         self.viewTargetBoardButtonList[1].SAFE_SetEvent(self.__OnClickTargetBoardNoViewButton)
  193.         self.pvpModeButtonDict[player.PK_MODE_PEACE].SAFE_SetEvent(self.__OnClickPvPModePeaceButton)
  194.         self.pvpModeButtonDict[player.PK_MODE_REVENGE].SAFE_SetEvent(self.__OnClickPvPModeRevengeButton)
  195.         self.pvpModeButtonDict[player.PK_MODE_GUILD].SAFE_SetEvent(self.__OnClickPvPModeGuildButton)
  196.         self.pvpModeButtonDict[player.PK_MODE_FREE].SAFE_SetEvent(self.__OnClickPvPModeFreeButton)
  197.         self.blockButtonList[0].SetToggleUpEvent(self.__OnClickBlockExchangeButton)
  198.         self.blockButtonList[1].SetToggleUpEvent(self.__OnClickBlockPartyButton)
  199.         self.blockButtonList[2].SetToggleUpEvent(self.__OnClickBlockGuildButton)
  200.         self.blockButtonList[3].SetToggleUpEvent(self.__OnClickBlockWhisperButton)
  201.         self.blockButtonList[4].SetToggleUpEvent(self.__OnClickBlockFriendButton)
  202.         self.blockButtonList[5].SetToggleUpEvent(self.__OnClickBlockPartyRequest)
  203.         self.blockButtonList[0].SetToggleDownEvent(self.__OnClickBlockExchangeButton)
  204.         self.blockButtonList[1].SetToggleDownEvent(self.__OnClickBlockPartyButton)
  205.         self.blockButtonList[2].SetToggleDownEvent(self.__OnClickBlockGuildButton)
  206.         self.blockButtonList[3].SetToggleDownEvent(self.__OnClickBlockWhisperButton)
  207.         self.blockButtonList[4].SetToggleDownEvent(self.__OnClickBlockFriendButton)
  208.         self.blockButtonList[5].SetToggleDownEvent(self.__OnClickBlockPartyRequest)
  209.         self.viewChatButtonList[0].SAFE_SetEvent(self.__OnClickViewChatOnButton)
  210.         self.viewChatButtonList[1].SAFE_SetEvent(self.__OnClickViewChatOffButton)
  211.         self.alwaysShowNameButtonList[0].SAFE_SetEvent(self.__OnClickAlwaysShowNameOnButton)
  212.         self.alwaysShowNameButtonList[1].SAFE_SetEvent(self.__OnClickAlwaysShowNameOffButton)
  213.         self.showDamageButtonList[0].SAFE_SetEvent(self.__OnClickShowDamageOnButton)
  214.         self.showDamageButtonList[1].SAFE_SetEvent(self.__OnClickShowDamageOffButton)
  215.         self.showsalesTextButtonList[0].SAFE_SetEvent(self.__OnClickSalesTextOnButton)
  216.         self.showsalesTextButtonList[1].SAFE_SetEvent(self.__OnClickSalesTextOffButton)
  217.  
  218.         ## SYSTEM OPTION
  219.         self.ctrlMusicVolume.SetSliderPos(float(systemSetting.GetMusicVolume()))
  220.         self.ctrlMusicVolume.SetEvent(uimg.__mem_func__(self.OnChangeMusicVolume))
  221.         self.ctrlSoundVolume.SetSliderPos(float(systemSetting.GetSoundVolume()) / 5.0)
  222.         self.ctrlSoundVolume.SetEvent(uimg.__mem_func__(self.OnChangeSoundVolume))
  223.         #self.ctrlShadowQuality.SetSliderPos(float(systemSetting.GetShadowLevel()) / 5.0)
  224.         #self.ctrlShadowQuality.SetEvent(uimg.__mem_func__(self.OnChangeShadowQuality))
  225.         self.changeMusicButton.SAFE_SetEvent(self.__OnClickChangeMusicButton)
  226.         self.cameraModeButtonList[0].SAFE_SetEvent(self.__OnClickCameraModeShortButton)
  227.         self.cameraModeButtonList[1].SAFE_SetEvent(self.__OnClickCameraModeLongButton)
  228.         self.fogModeButtonList[0].SAFE_SetEvent(self.__OnClickFogModeLevel0Button)
  229.         self.fogModeButtonList[1].SAFE_SetEvent(self.__OnClickFogModeLevel1Button)
  230.         self.fogModeButtonList[2].SAFE_SetEvent(self.__OnClickFogModeLevel2Button)
  231.         self.tilingModeButtonList[0].SAFE_SetEvent(self.__OnClickTilingModeCPUButton)
  232.         self.tilingModeButtonList[1].SAFE_SetEvent(self.__OnClickTilingModeGPUButton)
  233.         self.tilingApplyButton.SAFE_SetEvent(self.__OnClickTilingApplyButton)
  234.         self.__SetCurTilingMode()
  235.  
  236.         self.ctrlShopNamesRange.SetSliderPos(float(uiPrivateShopBuilder.GetShopNamesRange()))
  237.         self.ctrlShopNamesRange.SetEvent(uimg.__mem_func__(self.OnChangeShopNamesRange))
  238.  
  239.         self.__ClickRadioButton(self.nameColorModeButtonList, constInfo.GET_CHRNAME_COLOR_INDEX())
  240.         self.__ClickRadioButton(self.viewTargetBoardButtonList, constInfo.GET_VIEW_OTHER_EMPIRE_PLAYER_TARGET_BOARD())
  241.         self.__SetPeacePKMode()
  242.  
  243.         self.JakasFunkcja(self.fogModeButtonList, constInfo.GET_FOG_LEVEL_INDEX())
  244.         self.JakasFunkcja(self.cameraModeButtonList, constInfo.GET_CAMERA_MAX_DISTANCE_INDEX())
  245.  
  246.         if musicInfo.fieldMusic==musicInfo.METIN2THEMA:
  247.             self.selectMusicFile.SetText("|cffa08784" + uiSelectMusic.DEFAULT_THEMA)
  248.         else:
  249.             self.selectMusicFile.SetText("|cffa08784" + musicInfo.fieldMusic[:MUSIC_FILENAME_MAX_LEN])
  250.  
  251.         #global MOBILE
  252.         if MOBILE:
  253.             self.inputMobileButton.SetEvent(uimg.__mem_func__(self.__OnChangeMobilePhoneNumber))
  254.             self.deleteMobileButton.SetEvent(uimg.__mem_func__(self.__OnDeleteMobilePhoneNumber))
  255.  
  256.     def OnChangeShopNamesRange(self):
  257.         pos = self.ctrlShopNamesRange.GetSliderPos()
  258.         uiPrivateShopBuilder.SetShopNamesRange(pos)
  259.         if systemSetting.IsShowSalesText():
  260.             uiPrivateShopBuilder.UpdateADBoard()
  261.  
  262.     def __ClickRadioButton(self, buttonList, buttonIndex):
  263.         try:
  264.             selButton=buttonList[buttonIndex]
  265.         except IndexError:
  266.             return
  267.  
  268.         for eachButton in buttonList:
  269.             eachButton.SetUp()
  270.  
  271.         selButton.Down()
  272.        
  273.     def PokazStrone(self, page):
  274.         for i in xrange(len(self.PageList)):
  275.             if page == self.PageList[i]:
  276.                 self.GetChild(page).Show()
  277.                 self.PagesTextColor[i].SetText(self.NapisyPrzyciskowOn[i])
  278.                 self.PagesButtons[i].SetUpVisual("illumina/buttons/chrbutton_big_a.tga")
  279.             else:
  280.                 self.GetChild(self.PageList[i]).Hide()
  281.                 self.PagesTextColor[i].SetText(self.NapisyPrzyciskowOff[i])
  282.                 self.PagesButtons[i].SetUpVisual("illumina/buttons/chrbutton_big_n.tga")
  283.        
  284.        
  285.     def JakasFunkcja(self, buttonList, buttonIndex):
  286.         try:
  287.             selButton=buttonList[buttonIndex]
  288.         except IndexError:
  289.             return
  290.  
  291.         for eachButton in buttonList:
  292.             eachButton.SetUp()
  293.  
  294.         selButton.Down()
  295.  
  296.  
  297.     def __SetTilingMode(self, index):
  298.         self.JakasFunkcja(self.tilingModeButtonList, index)
  299.         self.tilingMode=index
  300.  
  301.     def __SetCameraMode(self, index):
  302.         constInfo.SET_CAMERA_MAX_DISTANCE_INDEX(index)
  303.         self.JakasFunkcja(self.cameraModeButtonList, index)
  304.  
  305.     def __SetFogLevel(self, index):
  306.         constInfo.SET_FOG_LEVEL_INDEX(index)
  307.         self.JakasFunkcja(self.fogModeButtonList, index)
  308.  
  309.     def __SetNameColorMode(self, index):
  310.         constInfo.SET_CHRNAME_COLOR_INDEX(index)
  311.         self.__ClickRadioButton(self.nameColorModeButtonList, index)
  312.  
  313.     def __SetTargetBoardViewMode(self, flag):
  314.         constInfo.SET_VIEW_OTHER_EMPIRE_PLAYER_TARGET_BOARD(flag)
  315.         self.__ClickRadioButton(self.viewTargetBoardButtonList, flag)
  316.  
  317.     def __OnClickNameColorModeNormalButton(self):
  318.         self.__SetNameColorMode(0)
  319.  
  320.     def __OnClickNameColorModeEmpireButton(self):
  321.         self.__SetNameColorMode(1)
  322.  
  323.     def __OnClickTargetBoardViewButton(self):
  324.         self.__SetTargetBoardViewMode(0)
  325.  
  326.     def __OnClickTargetBoardNoViewButton(self):
  327.         self.__SetTargetBoardViewMode(1)
  328.  
  329.     def __OnClickCameraModeShortButton(self):
  330.         self.__SetCameraMode(0)
  331.  
  332.     def __OnClickCameraModeLongButton(self):
  333.         self.__SetCameraMode(1)
  334.  
  335.     def __OnClickFogModeLevel0Button(self):
  336.         self.__SetFogLevel(0)
  337.  
  338.     def __OnClickFogModeLevel1Button(self):
  339.         self.__SetFogLevel(1)
  340.  
  341.     def __OnClickFogModeLevel2Button(self):
  342.         self.__SetFogLevel(2)
  343.  
  344.     def __OnClickBlockExchangeButton(self):
  345.         self.RefreshBlock()
  346.         global blockMode
  347.         net.SendChatPacket("/setblockmode " + str(blockMode ^ player.BLOCK_EXCHANGE))
  348.     def __OnClickBlockPartyButton(self):
  349.         self.RefreshBlock()
  350.         global blockMode
  351.         net.SendChatPacket("/setblockmode " + str(blockMode ^ player.BLOCK_PARTY))
  352.     def __OnClickBlockGuildButton(self):
  353.         self.RefreshBlock()
  354.         global blockMode
  355.         net.SendChatPacket("/setblockmode " + str(blockMode ^ player.BLOCK_GUILD))
  356.     def __OnClickBlockWhisperButton(self):
  357.         self.RefreshBlock()
  358.         global blockMode
  359.         net.SendChatPacket("/setblockmode " + str(blockMode ^ player.BLOCK_WHISPER))
  360.     def __OnClickBlockFriendButton(self):
  361.         self.RefreshBlock()
  362.         global blockMode
  363.         net.SendChatPacket("/setblockmode " + str(blockMode ^ player.BLOCK_FRIEND))
  364.     def __OnClickBlockPartyRequest(self):
  365.         self.RefreshBlock()
  366.         global blockMode
  367.         net.SendChatPacket("/setblockmode " + str(blockMode ^ player.BLOCK_PARTY_REQUEST))
  368.  
  369.     def __OnClickViewChatOnButton(self):
  370.         global viewChatMode
  371.         viewChatMode = 1
  372.         systemSetting.SetViewChatFlag(viewChatMode)
  373.         self.RefreshViewChat()
  374.     def __OnClickViewChatOffButton(self):
  375.         global viewChatMode
  376.         viewChatMode = 0
  377.         systemSetting.SetViewChatFlag(viewChatMode)
  378.         self.RefreshViewChat()
  379.  
  380.     def __OnClickAlwaysShowNameOnButton(self):
  381.         systemSetting.SetAlwaysShowNameFlag(TRUE)
  382.         self.RefreshAlwaysShowName()
  383.  
  384.     def __OnClickAlwaysShowNameOffButton(self):
  385.         systemSetting.SetAlwaysShowNameFlag(FALSE)
  386.         self.RefreshAlwaysShowName()
  387.  
  388.     def __OnClickShowDamageOnButton(self):
  389.         systemSetting.SetShowDamageFlag(TRUE)
  390.         self.RefreshShowDamage()
  391.  
  392.     def __OnClickShowDamageOffButton(self):
  393.         systemSetting.SetShowDamageFlag(FALSE)
  394.         self.RefreshShowDamage()
  395.        
  396.     def __OnClickSalesTextOnButton(self):
  397.         systemSetting.SetShowSalesTextFlag(TRUE)
  398.         self.RefreshShowSalesText()
  399.         uiPrivateShopBuilder.UpdateADBoard()
  400.        
  401.     def __OnClickSalesTextOffButton(self):
  402.         systemSetting.SetShowSalesTextFlag(FALSE)
  403.         self.RefreshShowSalesText()    
  404.        
  405.     def __CheckPvPProtectedLevelPlayer(self):  
  406.         if player.GetStatus(player.LEVEL)<constInfo.PVPMODE_PROTECTED_LEVEL:
  407.             self.__SetPeacePKMode()
  408.             chat.AppendChat(chat.CHAT_TYPE_INFO, localemg.OPTION_PVPMODE_PROTECT % (constInfo.PVPMODE_PROTECTED_LEVEL))
  409.             return 1
  410.  
  411.         return 0
  412.  
  413.     def __SetPKMode(self, mode):
  414.         for btn in self.pvpModeButtonDict.values():
  415.             btn.SetUp()
  416.         if self.pvpModeButtonDict.has_key(mode):
  417.             self.pvpModeButtonDict[mode].Down()
  418.  
  419.     def __SetPeacePKMode(self):
  420.         self.__SetPKMode(player.PK_MODE_PEACE)
  421.  
  422.     def __RefreshPVPButtonList(self):
  423.         self.__SetPKMode(player.GetPKMode())
  424.  
  425.     def __OnClickPvPModePeaceButton(self):
  426.         if self.__CheckPvPProtectedLevelPlayer():
  427.             return
  428.  
  429.         self.__RefreshPVPButtonList()
  430.  
  431.         if constInfo.PVPMODE_ENABLE:
  432.             net.SendChatPacket("/pkmode 0", chat.CHAT_TYPE_TALKING)
  433.         else:
  434.             chat.AppendChat(chat.CHAT_TYPE_INFO, localemg.OPTION_PVPMODE_NOT_SUPPORT)
  435.  
  436.     def __OnClickPvPModeRevengeButton(self):
  437.         if self.__CheckPvPProtectedLevelPlayer():
  438.             return
  439.  
  440.         self.__RefreshPVPButtonList()
  441.  
  442.         if constInfo.PVPMODE_ENABLE:
  443.             net.SendChatPacket("/pkmode 1", chat.CHAT_TYPE_TALKING)
  444.         else:
  445.             chat.AppendChat(chat.CHAT_TYPE_INFO, localemg.OPTION_PVPMODE_NOT_SUPPORT)
  446.  
  447.     def __OnClickPvPModeFreeButton(self):
  448.         if self.__CheckPvPProtectedLevelPlayer():
  449.             return
  450.  
  451.         self.__RefreshPVPButtonList()
  452.  
  453.         if constInfo.PVPMODE_ENABLE:
  454.             net.SendChatPacket("/pkmode 2", chat.CHAT_TYPE_TALKING)
  455.         else:
  456.             chat.AppendChat(chat.CHAT_TYPE_INFO, localemg.OPTION_PVPMODE_NOT_SUPPORT)
  457.  
  458.     def __OnClickPvPModeGuildButton(self):
  459.         if self.__CheckPvPProtectedLevelPlayer():
  460.             return
  461.  
  462.         self.__RefreshPVPButtonList()
  463.  
  464.         if 0 == player.GetGuildID():
  465.             chat.AppendChat(chat.CHAT_TYPE_INFO, localemg.OPTION_PVPMODE_CANNOT_SET_GUILD_MODE)
  466.             return
  467.  
  468.         if constInfo.PVPMODE_ENABLE:
  469.             net.SendChatPacket("/pkmode 4", chat.CHAT_TYPE_TALKING)
  470.         else:
  471.             chat.AppendChat(chat.CHAT_TYPE_INFO, localemg.OPTION_PVPMODE_NOT_SUPPORT)
  472.  
  473.     def OnChangePKMode(self):
  474.         self.__RefreshPVPButtonList()
  475.  
  476.     def __OnChangeMobilePhoneNumber(self):
  477.         global MOBILE
  478.         if not MOBILE:
  479.             return
  480.  
  481.         import uiCommon
  482.         inputDialog = uiCommon.InputDialog()
  483.         inputDialog.SetTitle(localemg.MESSENGER_INPUT_MOBILE_PHONE_NUMBER_TITLE)
  484.         inputDialog.SetMaxLength(13)
  485.         inputDialog.SetAcceptEvent(uimg.__mem_func__(self.OnInputMobilePhoneNumber))
  486.         inputDialog.SetCancelEvent(uimg.__mem_func__(self.OnCloseInputDialog))
  487.         inputDialog.Open()
  488.         self.inputDialog = inputDialog
  489.  
  490.     def __OnDeleteMobilePhoneNumber(self):
  491.         global MOBILE
  492.         if not MOBILE:
  493.             return
  494.  
  495.         import uiCommon
  496.         questionDialog = uiCommon.QuestionDialog()
  497.         questionDialog.SetText(localemg.MESSENGER_DO_YOU_DELETE_PHONE_NUMBER)
  498.         questionDialog.SetAcceptEvent(uimg.__mem_func__(self.OnDeleteMobile))
  499.         questionDialog.SetCancelEvent(uimg.__mem_func__(self.OnCloseQuestionDialog))
  500.         questionDialog.Open()
  501.         self.questionDialog = questionDialog
  502.  
  503.     def OnInputMobilePhoneNumber(self):
  504.         global MOBILE
  505.         if not MOBILE:
  506.             return
  507.  
  508.         text = self.inputDialog.GetText()
  509.  
  510.         if not text:
  511.             return
  512.  
  513.         text.replace('-', '')
  514.         net.SendChatPacket("/mobile " + text)
  515.         self.OnCloseInputDialog()
  516.         return TRUE
  517.  
  518.     def OnInputMobileAuthorityCode(self):
  519.         global MOBILE
  520.         if not MOBILE:
  521.             return
  522.  
  523.         text = self.inputDialog.GetText()
  524.         net.SendChatPacket("/mobile_auth " + text)
  525.         self.OnCloseInputDialog()
  526.         return TRUE
  527.  
  528.     def OnDeleteMobile(self):
  529.         global MOBILE
  530.         if not MOBILE:
  531.             return
  532.  
  533.         net.SendChatPacket("/mobile")
  534.         self.OnCloseQuestionDialog()
  535.         return TRUE
  536.  
  537.     def OnCloseInputDialog(self):
  538.         self.inputDialog.Close()
  539.         self.inputDialog = None
  540.         return TRUE
  541.  
  542.     def OnCloseQuestionDialog(self):
  543.         self.questionDialog.Close()
  544.         self.questionDialog = None
  545.         return TRUE
  546.  
  547.     def OnPressEscapeKey(self):
  548.         self.Close()
  549.         return TRUE
  550.  
  551.     def RefreshMobile(self):
  552.         global MOBILE
  553.         if not MOBILE:
  554.             return
  555.  
  556.         if player.HasMobilePhoneNumber():
  557.             self.inputMobileButton.Hide()
  558.             self.deleteMobileButton.Show()
  559.         else:
  560.             self.inputMobileButton.Show()
  561.             self.deleteMobileButton.Hide()
  562.  
  563.     def OnMobileAuthority(self):
  564.         global MOBILE
  565.         if not MOBILE:
  566.             return
  567.  
  568.         import uiCommon
  569.         inputDialog = uiCommon.InputDialogWithDescription()
  570.         inputDialog.SetTitle(localemg.MESSENGER_INPUT_MOBILE_AUTHORITY_TITLE)
  571.         inputDialog.SetDescription(localemg.MESSENGER_INPUT_MOBILE_AUTHORITY_DESCRIPTION)
  572.         inputDialog.SetAcceptEvent(uimg.__mem_func__(self.OnInputMobileAuthorityCode))
  573.         inputDialog.SetCancelEvent(uimg.__mem_func__(self.OnCloseInputDialog))
  574.         inputDialog.SetMaxLength(4)
  575.         inputDialog.SetBoardWidth(310)
  576.         inputDialog.Open()
  577.         self.inputDialog = inputDialog
  578.  
  579.     def RefreshBlock(self):
  580.         global blockMode
  581.         for i in xrange(len(self.blockButtonList)):
  582.             if 0 != (blockMode & (1 << i)):
  583.                 self.blockButtonList[i].Down()
  584.                 self.blockTextList[i].SetPackedFontColor(0x77c3a777)
  585.             else:
  586.                 self.blockButtonList[i].SetUp()
  587.                 self.blockTextList[i].SetPackedFontColor(0x77847b71)
  588.  
  589.     def RefreshViewChat(self):
  590.         if systemSetting.IsViewChat():
  591.             self.viewChatButtonList[0].Down()
  592.             self.viewChatButtonList[1].SetUp()
  593.         else:
  594.             self.viewChatButtonList[0].SetUp()
  595.             self.viewChatButtonList[1].Down()
  596.  
  597.     def RefreshAlwaysShowName(self):
  598.         if systemSetting.IsAlwaysShowName():
  599.             self.alwaysShowNameButtonList[0].Down()
  600.             self.alwaysShowNameButtonList[1].SetUp()
  601.         else:
  602.             self.alwaysShowNameButtonList[0].SetUp()
  603.             self.alwaysShowNameButtonList[1].Down()
  604.  
  605.     def RefreshShowDamage(self):
  606.         if systemSetting.IsShowDamage():
  607.             self.showDamageButtonList[0].Down()
  608.             self.showDamageButtonList[1].SetUp()
  609.         else:
  610.             self.showDamageButtonList[0].SetUp()
  611.             self.showDamageButtonList[1].Down()
  612.            
  613.     def RefreshShowSalesText(self):
  614.         if systemSetting.IsShowSalesText():
  615.             self.showsalesTextButtonList[0].Down()
  616.             self.showsalesTextButtonList[1].SetUp()
  617.         else:
  618.             self.showsalesTextButtonList[0].SetUp()
  619.             self.showsalesTextButtonList[1].Down()
  620.  
  621.  
  622.  
  623.     def __OnClickTilingModeCPUButton(self):
  624.         self.__NotifyChatLine(localemg.SYSTEM_OPTION_CPU_TILING_1)
  625.         self.__NotifyChatLine(localemg.SYSTEM_OPTION_CPU_TILING_2)
  626.         self.__NotifyChatLine(localemg.SYSTEM_OPTION_CPU_TILING_3)
  627.         self.__SetTilingMode(0)
  628.  
  629.     def __OnClickTilingModeGPUButton(self):
  630.         self.__NotifyChatLine(localemg.SYSTEM_OPTION_GPU_TILING_1)
  631.         self.__NotifyChatLine(localemg.SYSTEM_OPTION_GPU_TILING_2)
  632.         self.__NotifyChatLine(localemg.SYSTEM_OPTION_GPU_TILING_3)
  633.         self.__SetTilingMode(1)
  634.  
  635.     def __OnClickTilingApplyButton(self):
  636.         self.__NotifyChatLine(localemg.SYSTEM_OPTION_TILING_EXIT)
  637.         if 0==self.tilingMode:
  638.             background.EnableSoftwareTiling(1)
  639.         else:
  640.             background.EnableSoftwareTiling(0)
  641.  
  642.         net.ExitGame()
  643.  
  644.     def __NotifyChatLine(self, text):
  645.         chat.AppendChat(chat.CHAT_TYPE_INFO, text)
  646.  
  647.     def __OnClickChangeMusicButton(self):
  648.         if not self.musicListDlg:
  649.            
  650.             self.musicListDlg=uiSelectMusic.FileListDialog()
  651.             self.musicListDlg.SAFE_SetSelectEvent(self.__OnChangeMusic)
  652.  
  653.         self.musicListDlg.Open()
  654.  
  655.  
  656.     def __SetTilingMode(self, index):
  657.         self.__ClickRadioButton(self.tilingModeButtonList, index)
  658.         self.tilingMode=index
  659.  
  660.     def __SetCameraMode(self, index):
  661.         constInfo.SET_CAMERA_MAX_DISTANCE_INDEX(index)
  662.         self.__ClickRadioButton(self.cameraModeButtonList, index)
  663.  
  664.     def __SetFogLevel(self, index):
  665.         constInfo.SET_FOG_LEVEL_INDEX(index)
  666.         self.__ClickRadioButton(self.fogModeButtonList, index)
  667.  
  668.     def __OnClickCameraModeShortButton(self):
  669.         self.__SetCameraMode(0)
  670.  
  671.     def __OnClickCameraModeLongButton(self):
  672.         self.__SetCameraMode(1)
  673.  
  674.     def __OnClickFogModeLevel0Button(self):
  675.         self.__SetFogLevel(0)
  676.  
  677.     def __OnClickFogModeLevel1Button(self):
  678.         self.__SetFogLevel(1)
  679.  
  680.     def __OnClickFogModeLevel2Button(self):
  681.         self.__SetFogLevel(2)
  682.  
  683.     def __OnChangeMusic(self, fileName):
  684.         self.selectMusicFile.SetText("|cffa08784" + fileName[:MUSIC_FILENAME_MAX_LEN])
  685.  
  686.         if musicInfo.fieldMusic != "":
  687.             snd.FadeOutMusic("BGM/"+ musicInfo.fieldMusic)
  688.  
  689.         if fileName==uiSelectMusic.DEFAULT_THEMA:
  690.             musicInfo.fieldMusic=musicInfo.METIN2THEMA
  691.         else:
  692.             musicInfo.fieldMusic=fileName
  693.  
  694.         musicInfo.SaveLastPlayFieldMusic()
  695.        
  696.         if musicInfo.fieldMusic != "":
  697.             snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
  698.  
  699.     def OnChangeMusicVolume(self):
  700.         pos = self.ctrlMusicVolume.GetSliderPos()
  701.         snd.SetMusicVolume(pos * net.GetFieldMusicVolume())
  702.         systemSetting.SetMusicVolume(pos)
  703.  
  704.     def OnChangeSoundVolume(self):
  705.         pos = self.ctrlSoundVolume.GetSliderPos()
  706.         snd.SetSoundVolumef(pos)
  707.         systemSetting.SetSoundVolumef(pos)
  708.  
  709.     def OnChangeShadowQuality(self):
  710.         pos = self.ctrlShadowQuality.GetSliderPos()
  711.         systemSetting.SetShadowLevel(int(pos / 0.2))
  712.  
  713.     def OnCloseInputDialog(self):
  714.         self.inputDialog.Close()
  715.         self.inputDialog = None
  716.         return True
  717.  
  718.     def OnCloseQuestionDialog(self):
  719.         self.questionDialog.Close()
  720.         self.questionDialog = None
  721.         return True
  722.  
  723.     def OnBlockMode(self, mode):
  724.         global blockMode
  725.         blockMode = mode
  726.         self.RefreshBlock()
  727.  
  728.     def __SetCurTilingMode(self):
  729.         if background.IsSoftwareTiling():
  730.             self.__SetTilingMode(0)
  731.         else:
  732.             self.__SetTilingMode(1)
  733.  
  734.     def Show(self):
  735.         self.RefreshMobile()
  736.         self.RefreshBlock()
  737.         uimg.ScriptWindow.Show(self)
  738.  
  739.     def Close(self):
  740.         self.Hide()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement