Guest User

introselect.py

a guest
Mar 28th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 21.37 KB | None | 0 0
  1. import chr
  2. import grp
  3. import app
  4. import math
  5. import wndMgr
  6. import snd
  7. import net
  8. import systemSetting
  9. import localeInfo
  10. import chr
  11.  
  12. import ui
  13. import uiScriptLocale
  14. import networkModule
  15. import musicInfo
  16. import playerSettingModule
  17.  
  18. ####################################
  19. # 빠른 실행을 위한 모듈 로딩 분담
  20. ####################################
  21. import uiCommon                    
  22. import uiMapNameShower            
  23. import uiAffectShower              
  24. import uiPlayerGauge              
  25. import uiCharacter                
  26. import uiTarget                    
  27. import consoleModule              
  28. import interfaceModule            
  29. import uiTaskBar                  
  30. import uiInventory
  31.  
  32. ###################################
  33.  
  34. LEAVE_BUTTON_FOR_POTAL = FALSE
  35. NOT_NEED_DELETE_CODE = FALSE
  36. ENABLE_ENGNUM_DELETE_CODE = FALSE
  37.  
  38. if localeInfo.IsJAPAN():
  39.     NOT_NEED_DELETE_CODE = TRUE
  40. elif localeInfo.IsHONGKONG():
  41.     ENABLE_ENGNUM_DELETE_CODE = TRUE
  42. elif localeInfo.IsNEWCIBN() or localeInfo.IsCIBN10():
  43.     ENABLE_ENGNUM_DELETE_CODE = TRUE
  44. elif localeInfo.IsEUROPE():
  45.     ENABLE_ENGNUM_DELETE_CODE = TRUE
  46.  
  47.  
  48. ###################################
  49.  
  50. class SelectCharacterWindow(ui.Window):
  51.  
  52.     # SLOT4
  53.     #SLOT_ROTATION = ( 140.0, 260.0, 20.0 )
  54.     #SLOT_COUNT = 3
  55.     #SLOT_ROTATION = [135.0, 225.0, 315.0, 45.0]
  56.     SLOT_ROTATION = [135.0, 225.0, 315.0, 45.0, 72.0]
  57.     SLOT_COUNT = 5
  58.     CHARACTER_TYPE_COUNT = 4
  59.  
  60.     EMPIRE_NAME = {
  61.         net.EMPIRE_A : localeInfo.EMPIRE_A,
  62.         net.EMPIRE_B : localeInfo.EMPIRE_B,
  63.         net.EMPIRE_C : localeInfo.EMPIRE_C
  64.     }
  65.  
  66.     class CharacterRenderer(ui.Window):
  67.         def OnRender(self):
  68.             grp.ClearDepthBuffer()
  69.  
  70.             grp.SetGameRenderState()
  71.             grp.PushState()
  72.             grp.SetOmniLight()
  73.  
  74.             screenWidth = wndMgr.GetScreenWidth()
  75.             screenHeight = wndMgr.GetScreenHeight()
  76.             newScreenWidth = float(screenWidth - 270)
  77.             newScreenHeight = float(screenHeight)
  78.  
  79.             grp.SetViewport(270.0/screenWidth, 0.0, newScreenWidth/screenWidth, newScreenHeight/screenHeight)
  80.  
  81.             app.SetCenterPosition(0.0, 0.0, 0.0)
  82.             app.SetCamera(1550.0, 15.0, 180.0, 95.0)
  83.             grp.SetPerspective(10.0, newScreenWidth/newScreenHeight, 1000.0, 3000.0)
  84.  
  85.             (x, y) = app.GetCursorPosition()
  86.             grp.SetCursorPosition(x, y)
  87.  
  88.             chr.Deform()
  89.             chr.Render()
  90.  
  91.             grp.RestoreViewport()
  92.             grp.PopState()
  93.             grp.SetInterfaceRenderState()
  94.  
  95.     def __init__(self, stream):
  96.         ui.Window.__init__(self)
  97.         net.SetPhaseWindow(net.PHASE_WINDOW_SELECT, self)
  98.  
  99.         self.stream=stream
  100.         self.slot = self.stream.GetCharacterSlot()
  101.  
  102.         self.openLoadingFlag = FALSE
  103.         self.startIndex = -1
  104.         self.startReservingTime = 0
  105.  
  106.         self.flagDict = {}
  107.         self.curRotation = []
  108.         self.destRotation = []
  109.         for rot in self.SLOT_ROTATION:
  110.             self.curRotation.append(rot)
  111.             self.destRotation.append(rot)
  112.  
  113.         self.curNameAlpha = []
  114.         self.destNameAlpha = []
  115.         for i in xrange(self.CHARACTER_TYPE_COUNT):
  116.             self.curNameAlpha.append(0.0)
  117.             self.destNameAlpha.append(0.0)
  118.  
  119.         self.curGauge = [0.0, 0.0, 0.0, 0.0]
  120.         self.destGauge = [0.0, 0.0, 0.0, 0.0]
  121.  
  122.         self.dlgBoard = 0
  123.         self.changeNameFlag = FALSE
  124.         self.nameInputBoard = None
  125.         self.sendedChangeNamePacket = FALSE
  126.  
  127.         self.startIndex = -1
  128.         self.isLoad = 0
  129.  
  130.     def __del__(self):
  131.         ui.Window.__del__(self)
  132.         net.SetPhaseWindow(net.PHASE_WINDOW_SELECT, 0)
  133.  
  134.     def Open(self):
  135.         if not self.__LoadBoardDialog(uiScriptLocale.LOCALE_UISCRIPT_PATH + "selectcharacterwindow.py"):
  136.             dbg.TraceError("SelectCharacterWindow.Open - __LoadScript Error")
  137.             return
  138.  
  139.         if not self.__LoadQuestionDialog("uiscript/questiondialog.py"):
  140.             return
  141.  
  142.         playerSettingModule.LoadGameData("INIT")
  143.  
  144.         self.InitCharacterBoard()
  145.  
  146.         self.btnStart.Enable()
  147.         self.btnCreate.Enable()
  148.         self.btnDelete.Enable()
  149.         self.btnExit.Enable()
  150.         self.btnLeft.Enable()
  151.         self.btnRight.Enable()
  152.  
  153.         self.dlgBoard.Show()
  154.         self.SetWindowName("SelectCharacterWindow")
  155.         self.Show()
  156.  
  157.         if self.slot>=0:
  158.             self.SelectSlot(self.slot)
  159.  
  160.         if musicInfo.selectMusic != "":
  161.             snd.SetMusicVolume(systemSetting.GetMusicVolume())
  162.             snd.FadeInMusic("BGM/"+musicInfo.selectMusic)
  163.  
  164.         app.SetCenterPosition(0.0, 0.0, 0.0)
  165.         app.SetCamera(1550.0, 15.0, 180.0, 95.0)
  166.  
  167.         self.isLoad=1
  168.         self.Refresh()
  169.  
  170.         if self.stream.isAutoSelect:
  171.             chrSlot=self.stream.GetCharacterSlot()
  172.             self.SelectSlot(chrSlot)
  173.             self.StartGame()
  174.  
  175.         self.HideAllFlag()
  176.         self.SetEmpire(net.GetEmpireID())
  177.  
  178.         app.ShowCursor()
  179.  
  180.     def Close(self):
  181.         if musicInfo.selectMusic != "":
  182.             snd.FadeOutMusic("BGM/"+musicInfo.selectMusic)
  183.  
  184.         self.stream.popupWindow.Close()
  185.  
  186.         if self.dlgBoard:
  187.             self.dlgBoard.ClearDictionary()
  188.  
  189.         self.empireName = None
  190.         self.flagDict = {}
  191.         self.dlgBoard = None
  192.         self.btnStart = None
  193.         self.btnCreate = None
  194.         self.btnDelete = None
  195.         self.btnExit = None
  196.         self.btnLeft = None
  197.         self.btnRight = None
  198.         self.backGround = None
  199.  
  200.         self.dlgQuestion.ClearDictionary()
  201.         self.dlgQuestion = None
  202.         self.dlgQuestionText = None
  203.         self.dlgQuestionAcceptButton = None
  204.         self.dlgQuestionCancelButton = None
  205.         self.privateInputBoard = None
  206.         self.nameInputBoard = None
  207.  
  208.         chr.DeleteInstance(0)
  209.         chr.DeleteInstance(1)
  210.         chr.DeleteInstance(2)
  211.         chr.DeleteInstance(3)
  212.  
  213.         self.Hide()
  214.         self.KillFocus()
  215.  
  216.         app.HideCursor()
  217.  
  218.     def SetEmpire(self, id):
  219.         self.empireName.SetText(self.EMPIRE_NAME.get(id, ""))
  220.         if self.flagDict.has_key(id):
  221.             self.flagDict[id].Show()
  222.        
  223.     def HideAllFlag(self):
  224.         for flag in self.flagDict.values():
  225.             flag.Hide()
  226.  
  227.     def Refresh(self):
  228.         if not self.isLoad:
  229.             return
  230.  
  231.         # SLOT4
  232.         indexArray = (4, 3, 2, 1, 0)
  233.         for index in indexArray:
  234.             id=net.GetAccountCharacterSlotDataInteger(index, net.ACCOUNT_CHARACTER_SLOT_ID)
  235.             race=net.GetAccountCharacterSlotDataInteger(index, net.ACCOUNT_CHARACTER_SLOT_RACE)
  236.             form=net.GetAccountCharacterSlotDataInteger(index, net.ACCOUNT_CHARACTER_SLOT_FORM)
  237.             name=net.GetAccountCharacterSlotDataString(index, net.ACCOUNT_CHARACTER_SLOT_NAME)
  238.             hair=net.GetAccountCharacterSlotDataInteger(index, net.ACCOUNT_CHARACTER_SLOT_HAIR)
  239.  
  240.             if id:
  241.                 self.MakeCharacter(index, id, name, race, form, hair)
  242.                 self.SelectSlot(index)
  243.  
  244.         self.SelectSlot(self.slot)
  245.  
  246.     def GetCharacterSlotID(self, slotIndex):
  247.         return net.GetAccountCharacterSlotDataInteger(slotIndex, net.ACCOUNT_CHARACTER_SLOT_ID)
  248.  
  249.     def __LoadQuestionDialog(self, fileName):
  250.         self.dlgQuestion = ui.ScriptWindow()
  251.  
  252.         try:
  253.             pyScrLoader = ui.PythonScriptLoader()
  254.             pyScrLoader.LoadScriptFile(self.dlgQuestion, fileName)
  255.         except:
  256.             import exception
  257.             exception.Abort("SelectCharacterWindow.LoadQuestionDialog.LoadScript")
  258.  
  259.         try:
  260.             GetObject=self.dlgQuestion.GetChild
  261.             self.dlgQuestionText=GetObject("message")
  262.             self.dlgQuestionAcceptButton=GetObject("accept")
  263.             self.dlgQuestionCancelButton=GetObject("cancel")
  264.         except:
  265.             import exception
  266.             exception.Abort("SelectCharacterWindow.LoadQuestionDialog.BindObject")
  267.  
  268.         self.dlgQuestionText.SetText(localeInfo.SELECT_DO_YOU_DELETE_REALLY)
  269.         self.dlgQuestionAcceptButton.SetEvent(ui.__mem_func__(self.RequestDeleteCharacter))
  270.         self.dlgQuestionCancelButton.SetEvent(ui.__mem_func__(self.dlgQuestion.Hide))
  271.         return 1
  272.  
  273.     def __LoadBoardDialog(self, fileName):
  274.         self.dlgBoard = ui.ScriptWindow()
  275.  
  276.         try:
  277.             pyScrLoader = ui.PythonScriptLoader()
  278.             pyScrLoader.LoadScriptFile(self.dlgBoard, fileName)
  279.         except:
  280.             import exception
  281.             exception.Abort("SelectCharacterWindow.LoadBoardDialog.LoadScript")
  282.  
  283.         try:
  284.             GetObject=self.dlgBoard.GetChild
  285.  
  286.             self.btnStart       = GetObject("start_button")
  287.             self.btnCreate      = GetObject("create_button")
  288.             self.btnDelete      = GetObject("delete_button")
  289.             self.btnExit        = GetObject("exit_button")
  290.  
  291.             self.CharacterName  = GetObject("character_name_value")
  292.             self.CharacterLevel = GetObject("character_level_value")
  293.             self.PlayTime       = GetObject("character_play_time_value")
  294.             self.CharacterHTH   = GetObject("character_hth_value")
  295.             self.CharacterINT   = GetObject("character_int_value")
  296.             self.CharacterSTR   = GetObject("character_str_value")
  297.             self.CharacterDEX   = GetObject("character_dex_value")
  298.             self.GuildName      = GetObject("GuildName")
  299.  
  300.             self.NameList = []
  301.             self.NameList.append(GetObject("name_warrior"))
  302.             self.NameList.append(GetObject("name_assassin"))
  303.             self.NameList.append(GetObject("name_sura"))
  304.             self.NameList.append(GetObject("name_shaman"))
  305.             self.NameList.append(GetObject("name_wolfman"))
  306.  
  307.             self.GaugeList = []
  308.             self.GaugeList.append(GetObject("gauge_hth"))
  309.             self.GaugeList.append(GetObject("gauge_int"))
  310.             self.GaugeList.append(GetObject("gauge_str"))
  311.             self.GaugeList.append(GetObject("gauge_dex"))
  312.  
  313.             self.btnLeft = GetObject("left_button")
  314.             self.btnRight = GetObject("right_button")
  315.  
  316.             self.empireName = GetObject("EmpireName")
  317.             self.flagDict[net.EMPIRE_A] = GetObject("EmpireFlag_A")
  318.             self.flagDict[net.EMPIRE_B] = GetObject("EmpireFlag_B")
  319.             self.flagDict[net.EMPIRE_C] = GetObject("EmpireFlag_C")
  320.  
  321.             self.backGround = GetObject("BackGround")
  322.  
  323.         except:
  324.             import exception
  325.             exception.Abort("SelectCharacterWindow.LoadBoardDialog.BindObject")
  326.  
  327.         for name in self.NameList:
  328.             name.SetAlpha(0.0)
  329.  
  330.         self.btnStart.SetEvent(ui.__mem_func__(self.StartGame))
  331.         self.btnCreate.SetEvent(ui.__mem_func__(self.CreateCharacter))
  332.         self.btnExit.SetEvent(ui.__mem_func__(self.ExitSelect))
  333.  
  334.        
  335.  
  336.         if NOT_NEED_DELETE_CODE:
  337.             self.btnDelete.SetEvent(ui.__mem_func__(self.PopupDeleteQuestion))
  338.         else:
  339.             self.btnDelete.SetEvent(ui.__mem_func__(self.InputPrivateCode))
  340.  
  341.         self.btnLeft.SetEvent(ui.__mem_func__(self.DecreaseSlotIndex))
  342.         self.btnRight.SetEvent(ui.__mem_func__(self.IncreaseSlotIndex))
  343.  
  344.         self.chrRenderer = self.CharacterRenderer()
  345.         self.chrRenderer.SetParent(self.backGround)
  346.         self.chrRenderer.Show()
  347.  
  348.         return 1
  349.  
  350.     def MakeCharacter(self, index, id, name, race, form, hair):
  351.         if 0 == id:
  352.             return
  353.  
  354.         chr.CreateInstance(index)
  355.         chr.SelectInstance(index)
  356.         chr.SetVirtualID(index)
  357.         chr.SetNameString(name)
  358.  
  359.         chr.SetRace(race)
  360.         chr.SetArmor(form)
  361.         chr.SetHair(hair)
  362.  
  363.         chr.Refresh()
  364.         chr.SetMotionMode(chr.MOTION_MODE_GENERAL)
  365.         chr.SetLoopMotion(chr.MOTION_INTRO_WAIT)
  366.  
  367.         chr.SetRotation(0.0)
  368.  
  369.     ## Manage Character
  370.     def StartGame(self):
  371.  
  372.         if self.sendedChangeNamePacket:
  373.             return
  374.  
  375.         if self.changeNameFlag:
  376.             self.OpenChangeNameDialog()
  377.             return
  378.  
  379.         if -1 != self.startIndex:
  380.             return
  381.  
  382.         if musicInfo.selectMusic != "":
  383.             snd.FadeLimitOutMusic("BGM/"+musicInfo.selectMusic, systemSetting.GetMusicVolume()*0.05)
  384.  
  385.         self.btnStart.SetUp()
  386.         self.btnCreate.SetUp()
  387.         self.btnDelete.SetUp()
  388.         self.btnExit.SetUp()
  389.         self.btnLeft.SetUp()
  390.         self.btnRight.SetUp()
  391.  
  392.         self.btnStart.Disable()
  393.         self.btnCreate.Disable()
  394.         self.btnDelete.Disable()
  395.         self.btnExit.Disable()
  396.         self.btnLeft.Disable()
  397.         self.btnRight.Disable()
  398.         self.dlgQuestion.Hide()
  399.  
  400.         self.stream.SetCharacterSlot(self.slot)
  401.  
  402.         self.startIndex = self.slot
  403.         self.startReservingTime = app.GetTime()
  404.  
  405.         for i in xrange(self.SLOT_COUNT):
  406.  
  407.             if FALSE == chr.HasInstance(i):
  408.                 continue
  409.  
  410.             chr.SelectInstance(i)
  411.  
  412.             if i == self.slot:
  413.                 self.slot=self.slot
  414.                 chr.PushOnceMotion(chr.MOTION_INTRO_SELECTED, 0.1)
  415.                 continue
  416.  
  417.             chr.PushOnceMotion(chr.MOTION_INTRO_NOT_SELECTED, 0.1)
  418.  
  419.     def OpenChangeNameDialog(self):
  420.         import uiCommon
  421.         nameInputBoard = uiCommon.InputDialogWithDescription()
  422.         nameInputBoard.SetTitle(localeInfo.SELECT_CHANGE_NAME_TITLE)
  423.         nameInputBoard.SetAcceptEvent(ui.__mem_func__(self.AcceptInputName))
  424.         nameInputBoard.SetCancelEvent(ui.__mem_func__(self.CancelInputName))
  425.         nameInputBoard.SetMaxLength(chr.PLAYER_NAME_MAX_LEN)
  426.         nameInputBoard.SetBoardWidth(200)
  427.         nameInputBoard.SetDescription(localeInfo.SELECT_INPUT_CHANGING_NAME)
  428.         nameInputBoard.Open()
  429.         nameInputBoard.slot = self.slot
  430.         self.nameInputBoard = nameInputBoard
  431.  
  432.     def OnChangeName(self, id, name):
  433.         self.SelectSlot(id)
  434.         self.sendedChangeNamePacket = FALSE
  435.         self.PopupMessage(localeInfo.SELECT_CHANGED_NAME)
  436.  
  437.     def AcceptInputName(self):
  438.         changeName = self.nameInputBoard.GetText()
  439.         if not changeName:
  440.             return
  441.  
  442.         self.sendedChangeNamePacket = TRUE
  443.         net.SendChangeNamePacket(self.nameInputBoard.slot, changeName)
  444.         return self.CancelInputName()
  445.  
  446.     def CancelInputName(self):
  447.         self.nameInputBoard.Close()
  448.         self.nameInputBoard = None
  449.         return TRUE
  450.  
  451.     def OnCreateFailure(self, type):
  452.         self.sendedChangeNamePacket = FALSE
  453.         if 0 == type:
  454.             self.PopupMessage(localeInfo.SELECT_CHANGE_FAILURE_STRANGE_NAME)
  455.         elif 1 == type:
  456.             self.PopupMessage(localeInfo.SELECT_CHANGE_FAILURE_ALREADY_EXIST_NAME)
  457.         elif 100 == type:
  458.             self.PopupMessage(localeInfo.SELECT_CHANGE_FAILURE_STRANGE_INDEX)
  459.  
  460.     def CreateCharacter(self):
  461.         id = self.GetCharacterSlotID(self.slot)
  462.         if 0==id:
  463.             self.stream.SetCharacterSlot(self.slot)
  464.  
  465.             EMPIRE_MODE = 1
  466.  
  467.             if EMPIRE_MODE:
  468.                 if self.__AreAllSlotEmpty():
  469.                     self.stream.SetReselectEmpirePhase()
  470.                 else:
  471.                     self.stream.SetCreateCharacterPhase()
  472.  
  473.             else:
  474.                 self.stream.SetCreateCharacterPhase()
  475.  
  476.     def __AreAllSlotEmpty(self):
  477.         for iSlot in xrange(self.SLOT_COUNT):
  478.             if 0!=net.GetAccountCharacterSlotDataInteger(iSlot, net.ACCOUNT_CHARACTER_SLOT_ID):
  479.                 return 0
  480.         return 1
  481.  
  482.     def PopupDeleteQuestion(self):
  483.         id = self.GetCharacterSlotID(self.slot)
  484.         if 0 == id:
  485.             return
  486.  
  487.         self.dlgQuestion.Show()
  488.         self.dlgQuestion.SetTop()
  489.  
  490.     def RequestDeleteCharacter(self):
  491.         self.dlgQuestion.Hide()
  492.  
  493.         id = self.GetCharacterSlotID(self.slot)
  494.         if 0 == id:
  495.             self.PopupMessage(localeInfo.SELECT_EMPTY_SLOT)
  496.             return
  497.  
  498.         net.SendDestroyCharacterPacket(self.slot, "1234567")
  499.         self.PopupMessage(localeInfo.SELECT_DELEING)
  500.  
  501.     def InputPrivateCode(self):
  502.        
  503.         import uiCommon
  504.         privateInputBoard = uiCommon.InputDialogWithDescription()
  505.         privateInputBoard.SetTitle(localeInfo.INPUT_PRIVATE_CODE_DIALOG_TITLE)
  506.         privateInputBoard.SetAcceptEvent(ui.__mem_func__(self.AcceptInputPrivateCode))
  507.         privateInputBoard.SetCancelEvent(ui.__mem_func__(self.CancelInputPrivateCode))
  508.  
  509.         if ENABLE_ENGNUM_DELETE_CODE:
  510.             pass
  511.         else:
  512.             privateInputBoard.SetNumberMode()
  513.  
  514.         privateInputBoard.SetSecretMode()
  515.         privateInputBoard.SetMaxLength(7)
  516.            
  517.         privateInputBoard.SetBoardWidth(250)
  518.         privateInputBoard.SetDescription(localeInfo.INPUT_PRIVATE_CODE_DIALOG_DESCRIPTION)
  519.         privateInputBoard.Open()
  520.         self.privateInputBoard = privateInputBoard
  521.  
  522.     def AcceptInputPrivateCode(self):
  523.         privateCode = self.privateInputBoard.GetText()
  524.         if not privateCode:
  525.             return
  526.  
  527.         id = self.GetCharacterSlotID(self.slot)
  528.         if 0 == id:
  529.             self.PopupMessage(localeInfo.SELECT_EMPTY_SLOT)
  530.             return
  531.  
  532.         net.SendDestroyCharacterPacket(self.slot, privateCode)
  533.         self.PopupMessage(localeInfo.SELECT_DELEING)
  534.  
  535.         self.CancelInputPrivateCode()
  536.         return TRUE
  537.  
  538.     def CancelInputPrivateCode(self):
  539.         self.privateInputBoard = None
  540.         return TRUE
  541.  
  542.     def OnDeleteSuccess(self, slot):
  543.         self.PopupMessage(localeInfo.SELECT_DELETED)
  544.         self.DeleteCharacter(slot)
  545.  
  546.     def OnDeleteFailure(self):
  547.         self.PopupMessage(localeInfo.SELECT_CAN_NOT_DELETE)
  548.  
  549.     def DeleteCharacter(self, index):
  550.         chr.DeleteInstance(index)
  551.         self.SelectSlot(self.slot)
  552.  
  553.     def ExitSelect(self):
  554.         self.dlgQuestion.Hide()
  555.    
  556.         if LEAVE_BUTTON_FOR_POTAL:
  557.             if app.loggined:
  558.                 self.stream.SetPhaseWindow(0)
  559.             else:
  560.                 self.stream.setloginphase()
  561.         else:
  562.             self.stream.SetLoginPhase()
  563.  
  564.         self.Hide()
  565.  
  566.     def GetSlotIndex(self):
  567.         return self.slot
  568.  
  569.     def DecreaseSlotIndex(self):
  570.         slotIndex = (self.GetSlotIndex() - 1 + self.SLOT_COUNT) % self.SLOT_COUNT
  571.         self.SelectSlot(slotIndex)
  572.  
  573.     def IncreaseSlotIndex(self):
  574.         slotIndex = (self.GetSlotIndex() + 1) % self.SLOT_COUNT
  575.         self.SelectSlot(slotIndex)
  576.  
  577.     def SelectSlot(self, index):
  578.  
  579.         if index < 0:
  580.             return
  581.         if index >= self.SLOT_COUNT:
  582.             return
  583.  
  584.         self.slot = index
  585.  
  586.         chr.SelectInstance(self.slot)
  587.  
  588.         for i in xrange(self.CHARACTER_TYPE_COUNT):
  589.             self.destNameAlpha[i] = 0.0
  590.  
  591.         for i in xrange(self.SLOT_COUNT):
  592.             self.destRotation[(i+self.slot)%self.SLOT_COUNT] = self.SLOT_ROTATION[i]
  593.  
  594.         self.destGauge = [0.0, 0.0, 0.0, 0.0, 0.0]
  595.  
  596.         id=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_ID)
  597.         if 0 != id:
  598.  
  599.             self.btnStart.Show()
  600.             self.btnDelete.Show()
  601.             self.btnCreate.Hide()
  602.  
  603.             playTime=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_PLAYTIME)
  604.             level=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_LEVEL)
  605.             race=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_RACE)
  606.             valueHTH=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_HTH)
  607.             valueINT=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_INT)
  608.             valueSTR=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_STR)
  609.             valueDEX=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_DEX)
  610.             name=net.GetAccountCharacterSlotDataString(self.slot, net.ACCOUNT_CHARACTER_SLOT_NAME)
  611.             guildID=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_GUILD_ID)
  612.             guildName=net.GetAccountCharacterSlotDataString(self.slot, net.ACCOUNT_CHARACTER_SLOT_GUILD_NAME)
  613.             self.changeNameFlag=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_CHANGE_NAME_FLAG)
  614.  
  615.             job = chr.RaceToJob(race)
  616.             if job >= 0 and job < self.CHARACTER_TYPE_COUNT:
  617.                 self.destNameAlpha[job] = 1.0
  618.  
  619.             self.CharacterName.SetText(name)
  620.             self.CharacterLevel.SetText(str(level))
  621.  
  622.             self.PlayTime.SetText(str(playTime))
  623.             self.CharacterHTH.SetText(str(valueHTH))
  624.             self.CharacterINT.SetText(str(valueINT))
  625.             self.CharacterSTR.SetText(str(valueSTR))
  626.             self.CharacterDEX.SetText(str(valueDEX))
  627.  
  628.             if guildName:
  629.                 self.GuildName.SetText(guildName)
  630.             else:
  631.                 self.GuildName.SetText(localeInfo.SELECT_NOT_JOIN_GUILD)
  632.  
  633.             statesSummary = float(valueHTH + valueINT + valueSTR + valueDEX)
  634.             if statesSummary > 0.0:
  635.                 self.destGauge =    [
  636.                                         float(valueHTH) / statesSummary,
  637.                                         float(valueINT) / statesSummary,
  638.                                         float(valueSTR) / statesSummary,
  639.                                         float(valueDEX) / statesSummary
  640.                                     ]
  641.  
  642.         else:
  643.  
  644.             self.InitCharacterBoard()
  645.  
  646.     def InitCharacterBoard(self):
  647.  
  648.         self.btnStart.Hide()
  649.         self.btnDelete.Hide()
  650.         self.btnCreate.Show()
  651.  
  652.         self.CharacterName.SetText("")
  653.         self.CharacterLevel.SetText("")
  654.         self.PlayTime.SetText("")
  655.         self.CharacterHTH.SetText("")
  656.         self.CharacterINT.SetText("")
  657.         self.CharacterSTR.SetText("")
  658.         self.CharacterDEX.SetText("")
  659.         self.GuildName.SetText(localeInfo.SELECT_NOT_JOIN_GUILD)
  660.  
  661.     ## Event
  662.     def OnKeyDown(self, key):
  663.  
  664.         if 1 == key:
  665.             self.ExitSelect()
  666.         if 2 == key:
  667.             self.SelectSlot(0)
  668.         if 3 == key:
  669.             self.SelectSlot(1)
  670.         if 4 == key:
  671.             self.SelectSlot(2)
  672.         if 5 == key:
  673.             self.SelectSlot(3)
  674.         if 6 == key:
  675.             self.SelectSlot(4)
  676.  
  677.         if 28 == key:
  678.  
  679.             id = net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_ID)
  680.             if 0 == id:
  681.                 self.CreateCharacter()
  682.  
  683.             else:
  684.                 self.StartGame()
  685.  
  686.         if 203 == key:
  687.             self.slot = (self.GetSlotIndex() - 1 + self.SLOT_COUNT) % self.SLOT_COUNT
  688.             self.SelectSlot(self.slot)
  689.         if 205 == key:
  690.             self.slot = (self.GetSlotIndex() + 1) % self.SLOT_COUNT
  691.             self.SelectSlot(self.slot)
  692.  
  693.         return TRUE
  694.  
  695.     def OnUpdate(self):
  696.         chr.Update()
  697.  
  698.         for i in xrange(4):
  699.             self.curGauge[i] += (self.destGauge[i] - self.curGauge[i]) / 10.0
  700.             if abs(self.curGauge[i] - self.destGauge[i]) < 0.005:
  701.                 self.curGauge[i] = self.destGauge[i]
  702.             self.GaugeList[i].SetPercentage(self.curGauge[i], 1.0)
  703.  
  704.         for i in xrange(self.CHARACTER_TYPE_COUNT):
  705.             self.curNameAlpha[i] += (self.destNameAlpha[i] - self.curNameAlpha[i]) / 10.0
  706.             self.NameList[i].SetAlpha(self.curNameAlpha[i])
  707.  
  708.         for i in xrange(self.SLOT_COUNT):
  709.  
  710.             if FALSE == chr.HasInstance(i):
  711.                 continue
  712.  
  713.             chr.SelectInstance(i)
  714.  
  715.             distance = 50.0
  716.             rotRadian = self.curRotation[i] * (math.pi*2) / 360.0
  717.             x = distance*math.sin(rotRadian) + distance*math.cos(rotRadian)
  718.             y = distance*math.cos(rotRadian) - distance*math.sin(rotRadian)
  719.             chr.SetPixelPosition(int(x), int(y), 30)
  720.  
  721.             #####
  722.  
  723.             dir = app.GetRotatingDirection(self.destRotation[i], self.curRotation[i])
  724.             rot = app.GetDegreeDifference(self.destRotation[i], self.curRotation[i])
  725.  
  726.             if app.DEGREE_DIRECTION_RIGHT == dir:
  727.                 self.curRotation[i] += rot / 10.0
  728.             elif app.DEGREE_DIRECTION_LEFT == dir:
  729.                 self.curRotation[i] -= rot / 10.0
  730.  
  731.             self.curRotation[i] = (self.curRotation[i] + 360.0) % 360.0
  732.  
  733.         #######################################################
  734.         if -1 != self.startIndex:
  735.  
  736.             ## Temporary
  737.             ## BackGroundLoading이 지원 될때까지 임시로..
  738.             if app.GetTime() - self.startReservingTime > 3.0:
  739.                 if FALSE == self.openLoadingFlag:
  740.                     chrSlot=self.stream.GetCharacterSlot()
  741.                     net.DirectEnter(chrSlot)
  742.                     self.openLoadingFlag = TRUE
  743.  
  744.                     playTime=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_PLAYTIME)
  745.  
  746.                     import player
  747.                     player.SetPlayTime(playTime)
  748.                     import chat
  749.                     chat.Clear() ## 들어갈때 Chat 을 초기화. 임시 Pos.
  750.             ## Temporary
  751.         #######################################################
  752.  
  753.     def EmptyFunc(self):
  754.         pass
  755.  
  756.     def PopupMessage(self, msg, func=0):
  757.         if not func:
  758.             func=self.EmptyFunc
  759.  
  760.         self.stream.popupWindow.Close()
  761.         self.stream.popupWindow.Open(msg, func, localeInfo.UI_OK)
  762.  
  763.     def OnPressExitKey(self):
  764.         self.ExitSelect()
  765.         return TRUE
Advertisement
Add Comment
Please, Sign In to add comment