Guest User

Untitled

a guest
Apr 21st, 2020
44
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import chr
  2. import grp
  3. import app
  4. import net
  5. import snd
  6. import wndMgr
  7. import event
  8. import systemSetting
  9. import localeInfo
  10.  
  11. import ui
  12. import networkModule
  13. import math
  14. import snd
  15. import musicInfo
  16. import playerSettingModule
  17. import uiScriptLocale
  18. import uiToolTip
  19.  
  20. LOCALE_PATH = "uiscript/"+uiScriptLocale.CODEPAGE+"_"
  21.  
  22. MAN         = 0
  23. WOMAN       = 1
  24. GENDER_LIST = (MAN, WOMAN)
  25. SHAPE0      = 0
  26. SHAPE1      = 1
  27. PAGE_COUNT  = 2
  28. if app.ENABLE_WOLFMAN_CHARACTER:
  29.     SLOT_COUNT  = (5, 4)
  30. else:
  31.     SLOT_COUNT  = (4, 4)
  32. BASE_CHR_ID = 3
  33.  
  34. def GetRealID(page):
  35.     realIdx = 0
  36.     for i in xrange(len(SLOT_COUNT)):
  37.         if i>=page:
  38.             break
  39.         realIdx+=SLOT_COUNT[i]
  40.     return realIdx
  41.  
  42. def GetRealIDnSlot(page, slot):
  43.     realIdx = 0
  44.     for i in xrange(len(SLOT_COUNT)):
  45.         if i>=page:
  46.             break
  47.         realIdx+=SLOT_COUNT[i]
  48.     # import dbg
  49.     # dbg.TraceError("page(%d) slot(%d)=real(%d)+=%d"%(page, slot, realIdx, realIdx+slot))
  50.     return realIdx + slot
  51.  
  52. class CreateCharacterWindow(ui.Window):
  53.  
  54.     if app.ENABLE_WOLFMAN_CHARACTER:
  55.         SLOT_ROTATION = [[135.0, 207.0, 279.0, 351.0, 63.0], [135.0, 225.0, 315.0, 45.0]]
  56.     else:
  57.         SLOT_ROTATION = [[135.0, 225.0, 315.0, 45.0], [135.0, 225.0, 315.0, 45.0]]
  58.  
  59.  
  60.     CREATE_STAT_POINT = 0
  61.  
  62.     STAT_CON = 0
  63.     STAT_INT = 1
  64.     STAT_STR = 2
  65.     STAT_DEX = 3
  66.  
  67.     STAT_DESCRIPTION =  {
  68.                             STAT_CON : localeInfo.STAT_TOOLTIP_CON,
  69.                             STAT_INT : localeInfo.STAT_TOOLTIP_INT,
  70.                             STAT_STR : localeInfo.STAT_TOOLTIP_STR,
  71.                             STAT_DEX : localeInfo.STAT_TOOLTIP_DEX,
  72.                         }
  73.  
  74.     START_STAT =    (  ## CON INT STR DEX
  75.                         [ 4, 3, 6, 3, ], ## Warrior
  76.                         [ 3, 3, 4, 6, ], ## Assassin
  77.                         [ 3, 5, 5, 3, ], ## Sura
  78.                         [ 4, 6, 3, 3, ], ## Shaman
  79.                         [ 4, 3, 6, 3, ], ## Warrior
  80.                         [ 3, 3, 4, 6, ], ## Assassin
  81.                         [ 3, 5, 5, 3, ], ## Sura
  82.                         [ 4, 6, 3, 3, ], ## Shaman
  83.                     )
  84.     if app.ENABLE_WOLFMAN_CHARACTER:
  85.         tmpStartStat = list(START_STAT)
  86.         tmpStartStat.insert(GetRealIDnSlot(MAN, 5-1), [ 6, 2, 2, 6, ])
  87.         START_STAT = tuple(tmpStartStat)
  88.  
  89.     DESCRIPTION_FILE_NAME = (
  90.         uiScriptLocale.JOBDESC_WARRIOR_PATH,
  91.         uiScriptLocale.JOBDESC_ASSASSIN_PATH,
  92.         uiScriptLocale.JOBDESC_SURA_PATH,
  93.         uiScriptLocale.JOBDESC_SHAMAN_PATH,
  94.     )
  95.     if app.ENABLE_WOLFMAN_CHARACTER:
  96.         DESCRIPTION_FILE_NAME += (uiScriptLocale.JOBDESC_WOLFMAN_PATH,)
  97.  
  98.  
  99.     class DescriptionBox(ui.Window):
  100.         def __init__(self):
  101.             ui.Window.__init__(self)
  102.             self.descIndex = 0
  103.         def __del__(self):
  104.             ui.Window.__del__(self)
  105.         def SetIndex(self, index):
  106.             self.descIndex = index
  107.         def OnRender(self):
  108.             event.RenderEventSet(self.descIndex)
  109.  
  110.     class CharacterRenderer(ui.Window):
  111.         def OnRender(self):
  112.             grp.ClearDepthBuffer()
  113.             grp.SetGameRenderState()
  114.             grp.PushState()
  115.             grp.SetOmniLight()
  116.  
  117.             screenWidth = wndMgr.GetScreenWidth()
  118.             screenHeight = wndMgr.GetScreenHeight()
  119.             newScreenWidth = float(screenWidth - 270)
  120.             newScreenHeight = float(screenHeight)
  121.  
  122.             grp.SetViewport(270.0/screenWidth, 0.0, newScreenWidth/screenWidth, newScreenHeight/screenHeight)
  123.  
  124.             app.SetCenterPosition(0.0, 0.0, 0.0)
  125.             app.SetCamera(1550.0, 15.0, 180.0, 95.0)
  126.             grp.SetPerspective(10.0, newScreenWidth/newScreenHeight, 1000.0, 3000.0)
  127.  
  128.             (x, y) = app.GetCursorPosition()
  129.             grp.SetCursorPosition(x, y)
  130.  
  131.             chr.Deform()
  132.             chr.Render()
  133.  
  134.             grp.RestoreViewport()
  135.             grp.PopState()
  136.             grp.SetInterfaceRenderState()
  137.  
  138.     def __init__(self, stream):
  139.         print "NEW CREATE WINDOW ----------------------------------------------------------------------------"
  140.         ui.Window.__init__(self)
  141.         net.SetPhaseWindow(net.PHASE_WINDOW_CREATE, self)
  142.  
  143.         self.stream=stream
  144.  
  145.     def __del__(self):
  146.         print "---------------------------------------------------------------------------- DELETE CREATE WINDOW"
  147.  
  148.         net.SetPhaseWindow(net.PHASE_WINDOW_CREATE, 0)
  149.         ui.Window.__del__(self)
  150.  
  151.     def Open(self):
  152.         print "OPEN CREATE WINDOW ----------------------------------------------------------------------------"
  153.  
  154.         playerSettingModule.LoadGameData("INIT")
  155.  
  156.         self.reservingRaceIndex = -1
  157.         self.reservingShapeIndex = -1
  158.         self.reservingStartTime = 0
  159.         self.stat = [0, 0, 0, 0]
  160.  
  161.         self.gender = 0
  162.         self.slot = -1
  163.         #
  164.         self.instanceIDs = []
  165.         if app.ENABLE_WOLFMAN_CHARACTER:
  166.             self.shapeList = [
  167.                 [0, 0, 0, 0, 0],
  168.                 [0, 0, 0, 0]]
  169.         else:
  170.             self.shapeList = [
  171.                 [0, 0, 0, 0],
  172.                 [0, 0, 0, 0]]
  173.  
  174.         self.descIndex = 0
  175.  
  176.         try:
  177.             dlgBoard = ui.ScriptWindow()
  178.             pythonScriptLoader = ui.PythonScriptLoader()
  179.             pythonScriptLoader.LoadScriptFile(dlgBoard, uiScriptLocale.LOCALE_UISCRIPT_PATH + "createcharacterwindow.py")
  180.  
  181.         except:
  182.             import exception
  183.             exception.Abort("CreateCharacterWindow.Open.LoadObject")
  184.  
  185.         try:
  186.             getChild = dlgBoard.GetChild
  187.  
  188.             self.NameList = {}
  189.             self.NameList[MAN] = []
  190.             self.NameList[MAN].append(getChild("name_warrior"))
  191.             self.NameList[MAN].append(getChild("name_assassin"))
  192.             self.NameList[MAN].append(getChild("name_sura"))
  193.             self.NameList[MAN].append(getChild("name_shaman"))
  194.             if app.ENABLE_WOLFMAN_CHARACTER:
  195.                 self.NameList[MAN].append(getChild("name_wolfman"))
  196.             self.NameList[WOMAN] = []
  197.             self.NameList[WOMAN].append(getChild("name_warrior"))
  198.             self.NameList[WOMAN].append(getChild("name_assassin"))
  199.             self.NameList[WOMAN].append(getChild("name_sura"))
  200.             self.NameList[WOMAN].append(getChild("name_shaman"))
  201.  
  202.             self.GaugeList = []
  203.             self.GaugeList.append(getChild("hth_gauge"))
  204.             self.GaugeList.append(getChild("int_gauge"))
  205.             self.GaugeList.append(getChild("str_gauge"))
  206.             self.GaugeList.append(getChild("dex_gauge"))
  207.  
  208.             self.btnCreate = getChild("create_button")
  209.             self.btnCancel = getChild("cancel_button")
  210.             self.btnPrev = getChild("prev_button")
  211.             self.btnNext = getChild("next_button")
  212.             self.btnLeft = getChild("left_button")
  213.             self.btnRight = getChild("right_button")
  214.             self.textBoard = getChild("text_board")
  215.  
  216.             self.genderButtonList = []
  217.             self.genderButtonList.append(getChild("gender_button_01"))
  218.             self.genderButtonList.append(getChild("gender_button_02"))
  219.  
  220.             self.shapeButtonList = []
  221.             self.shapeButtonList.append(getChild("shape_button_01"))
  222.             self.shapeButtonList.append(getChild("shape_button_02"))
  223.  
  224.             self.editCharacterName = getChild("character_name_value")
  225.  
  226.             self.statValue = []
  227.             self.statValue.append(getChild("hth_value"))
  228.             self.statValue.append(getChild("int_value"))
  229.             self.statValue.append(getChild("str_value"))
  230.             self.statValue.append(getChild("dex_value"))
  231.  
  232.             getChild("hth_button").ShowToolTip = lambda arg=self.STAT_CON: self.OverInStatButton(arg)
  233.             getChild("hth_button").HideToolTip = lambda arg=self.STAT_CON: self.OverOutStatButton()
  234.             getChild("int_button").ShowToolTip = lambda arg=self.STAT_INT: self.OverInStatButton(arg)
  235.             getChild("int_button").HideToolTip = lambda arg=self.STAT_INT: self.OverOutStatButton()
  236.             getChild("str_button").ShowToolTip = lambda arg=self.STAT_STR: self.OverInStatButton(arg)
  237.             getChild("str_button").HideToolTip = lambda arg=self.STAT_STR: self.OverOutStatButton()
  238.             getChild("dex_button").ShowToolTip = lambda arg=self.STAT_DEX: self.OverInStatButton(arg)
  239.             getChild("dex_button").HideToolTip = lambda arg=self.STAT_DEX: self.OverOutStatButton()
  240.  
  241.             getChild("hth_button").Hide()
  242.             getChild("int_button").Hide()
  243.             getChild("str_button").Hide()
  244.             getChild("dex_button").Hide()
  245.  
  246.             self.backGround = getChild("BackGround")
  247.  
  248.         except:
  249.             import exception
  250.             exception.Abort("CreateCharacterWindow.Open.BindObject")
  251.  
  252.         self.btnCreate.SetEvent(ui.__mem_func__(self.CreateCharacter))
  253.         self.btnCancel.SetEvent(ui.__mem_func__(self.CancelCreate))
  254.         self.btnPrev.SetEvent(ui.__mem_func__(self.PrevDescriptionPage))
  255.         self.btnNext.SetEvent(ui.__mem_func__(self.NextDescriptionPage))
  256.         self.btnLeft.SetEvent(ui.__mem_func__(self.__DecreaseSlotIndex))
  257.         self.btnRight.SetEvent(ui.__mem_func__(self.__IncreaseSlotIndex))
  258.  
  259.         self.genderButtonList[0].SetEvent(ui.__mem_func__(self.__SelectGender), MAN)
  260.         self.genderButtonList[1].SetEvent(ui.__mem_func__(self.__SelectGender), WOMAN)
  261.  
  262.         self.shapeButtonList[0].SetEvent(ui.__mem_func__(self.__SelectShape), SHAPE0)
  263.         self.shapeButtonList[1].SetEvent(ui.__mem_func__(self.__SelectShape), SHAPE1)
  264.         self.editCharacterName.SetReturnEvent(ui.__mem_func__(self.CreateCharacter))
  265.         self.editCharacterName.SetEscapeEvent(ui.__mem_func__(self.CancelCreate))
  266.         self.dlgBoard = dlgBoard
  267.  
  268.         self.curRotation    = [] + self.SLOT_ROTATION[self.gender]
  269.         self.destRotation   = [] + self.SLOT_ROTATION[self.gender]
  270.         self.curNameAlpha   = [0.0, 0.0, 0.0, 0.0, 0.0]
  271.         self.destNameAlpha  = [0.0, 0.0, 0.0, 0.0, 0.0]
  272.         self.curGauge       = [0.0, 0.0, 0.0, 0.0]
  273.         self.destGauge      = [0.0, 0.0, 0.0, 0.0]
  274.  
  275.         self.descriptionBox = self.DescriptionBox()
  276.         self.descriptionBox.Show()
  277.  
  278.         self.chrRenderer = self.CharacterRenderer()
  279.         self.chrRenderer.SetParent(self.backGround)
  280.         self.chrRenderer.Show()
  281.  
  282.         self.toolTip = uiToolTip.ToolTip()
  283.         self.toolTip.ClearToolTip()
  284.  
  285.         if self.editCharacterName == None:
  286.             self.editCharacterName.SetText("")
  287.  
  288.         self.EnableWindow()
  289.         self.__SelectSlot(0)
  290.  
  291.         app.SetCamera(500.0, 10.0, 180.0, 95.0)
  292.  
  293.         self.__MakeCharacter(MAN, 0, playerSettingModule.RACE_WARRIOR_M)
  294.         self.__MakeCharacter(MAN, 1, playerSettingModule.RACE_ASSASSIN_M)
  295.         self.__MakeCharacter(MAN, 2, playerSettingModule.RACE_SURA_M)
  296.         self.__MakeCharacter(MAN, 3, playerSettingModule.RACE_SHAMAN_M)
  297.         if app.ENABLE_WOLFMAN_CHARACTER:
  298.             self.__MakeCharacter(MAN, 4, playerSettingModule.RACE_WOLFMAN_M)
  299.  
  300.         self.__MakeCharacter(WOMAN, 0, playerSettingModule.RACE_WARRIOR_W)
  301.         self.__MakeCharacter(WOMAN, 1, playerSettingModule.RACE_ASSASSIN_W)
  302.         self.__MakeCharacter(WOMAN, 2, playerSettingModule.RACE_SURA_W)
  303.         self.__MakeCharacter(WOMAN, 3, playerSettingModule.RACE_SHAMAN_W)
  304.  
  305.         self.__SelectGender(app.GetRandom(MAN, WOMAN))
  306.         self.__SelectShape(0)
  307.         self.__SelectSlot(app.GetRandom(0, SLOT_COUNT[self.gender]-1))
  308.  
  309.         self.dlgBoard.Show()
  310.         self.Show()
  311.  
  312.         if musicInfo.createMusic != "":
  313.             snd.SetMusicVolume(systemSetting.GetMusicVolume()*2)
  314.             snd.FadeInMusic("BGM/"+musicInfo.createMusic)
  315.  
  316.         app.ShowCursor()
  317.  
  318.     def Close(self):
  319.         print "---------------------------------------------------------------------------- CLOSE CREATE WINDOW"
  320.  
  321.         self.editCharacterName.Enable()
  322.         self.dlgBoard.ClearDictionary()
  323.         self.stream=0
  324.         self.shapeButtonList = []
  325.         self.genderButtonList = []
  326.         self.btnCreate = 0
  327.         self.btnCancel = 0
  328.         self.btnPrev = 0
  329.         self.btnNext = 0
  330.         self.btnLeft = 0
  331.         self.btnRight = 0
  332.         self.textBoard = 0
  333.         self.editCharacterName = 0
  334.         self.backGround = None
  335.  
  336.         if musicInfo.createMusic != "":
  337.             snd.FadeOutMusic("BGM/"+musicInfo.createMusic)
  338.  
  339.         for id in self.instanceIDs:
  340.             chr.DeleteInstance(id)
  341.  
  342.         self.dlgBoard.Hide()
  343.         self.Hide()
  344.  
  345.         app.HideCursor()
  346.         event.Destroy()
  347.  
  348.     def EnableWindow(self):
  349.         self.reservingRaceIndex = -1
  350.         self.reservingShapeIndex = -1
  351.         self.btnCreate.Enable()
  352.         self.btnCancel.Enable()
  353.         self.btnPrev.Enable()
  354.         self.btnNext.Enable()
  355.         self.btnLeft.Enable()
  356.         self.btnRight.Enable()
  357.         self.editCharacterName.SetFocus()
  358.         self.editCharacterName.Enable()
  359.         for page in xrange(PAGE_COUNT):
  360.             for slot in xrange(SLOT_COUNT[page]):
  361.                 chr_id = self.__GetSlotChrID(page, slot)
  362.                 chr.SelectInstance(chr_id)
  363.                 chr.BlendLoopMotion(chr.MOTION_INTRO_WAIT, 0.1)
  364.  
  365.     def DisableWindow(self):
  366.         self.btnCreate.Disable()
  367.         self.btnCancel.Disable()
  368.         self.btnPrev.Disable()
  369.         self.btnNext.Disable()
  370.         self.btnLeft.Disable()
  371.         self.btnRight.Disable()
  372.         self.editCharacterName.Disable()
  373.  
  374.         self.btnCreate.SetUp()
  375.  
  376.     ## Manage Character
  377.     def __GetSlotChrID(self, page, slot):
  378.         return BASE_CHR_ID + GetRealIDnSlot(page, slot)
  379.  
  380.     def __MakeCharacter(self, page, slot, race):
  381.  
  382.         chr_id = self.__GetSlotChrID(page, slot)
  383.  
  384.         chr.CreateInstance(chr_id)
  385.         chr.SelectInstance(chr_id)
  386.         chr.SetVirtualID(chr_id)
  387.         #
  388.         self.instanceIDs.append(chr_id)
  389.  
  390.         chr.SetRace(race)
  391.         chr.SetArmor(0)
  392.         chr.SetHair(0)
  393.  
  394.         chr.Refresh()
  395.         chr.SetMotionMode(chr.MOTION_MODE_GENERAL)
  396.         chr.SetLoopMotion(chr.MOTION_INTRO_WAIT)
  397.  
  398.         chr.SetRotation(0.0)
  399.         chr.Hide()
  400.  
  401.     def __SelectGender(self, gender):
  402.         for button in self.genderButtonList:
  403.             button.SetUp()
  404.  
  405.         self.genderButtonList[gender].Down()
  406.  
  407.         old_gender = self.gender
  408.         self.gender = gender
  409.  
  410.         for v1 in GENDER_LIST:
  411.             for i in xrange(SLOT_COUNT[v1]):
  412.                 chr.SelectInstance(self.__GetSlotChrID(v1, i))
  413.                 if v1==self.gender:
  414.                     chr.Show()
  415.                 else:
  416.                     chr.Hide()
  417.         self.__ResetNameList(old_gender)
  418.         if self.slot >= SLOT_COUNT[self.gender]:
  419.             # self.NameList[self.slot].SetAlpha(0.0)
  420.             self.__SelectSlot(app.GetRandom(0, SLOT_COUNT[self.gender]-1))
  421.             return # the scene will be already updated, so return or double updated scene
  422.         self.__UpdateScene()
  423.  
  424.     def __SelectShape(self, shape):
  425.         self.shapeList[self.gender][self.slot] = shape
  426.  
  427.         for button in self.shapeButtonList:
  428.             button.SetUp()
  429.  
  430.         self.shapeButtonList[shape].Down()
  431.  
  432.         chr_id = self.__GetSlotChrID(self.gender, self.slot)
  433.         chr.SelectInstance(chr_id)
  434.         chr.ChangeShape(shape)
  435.         chr.SetMotionMode(chr.MOTION_MODE_GENERAL)
  436.         chr.SetLoopMotion(chr.MOTION_INTRO_WAIT)
  437.  
  438.     def GetSlotIndex(self):
  439.         return self.slot
  440.  
  441.     def RefreshStat(self):
  442.         statSummary = self.stat[0] + self.stat[1] + self.stat[2] + self.stat[3]
  443.         self.destGauge =    (
  444.                                 float(self.stat[0])/float(statSummary),
  445.                                 float(self.stat[1])/float(statSummary),
  446.                                 float(self.stat[2])/float(statSummary),
  447.                                 float(self.stat[3])/float(statSummary),
  448.                             )
  449.  
  450.         for i in xrange(4):
  451.             self.statValue[i].SetText(str(self.stat[i]))
  452.  
  453.     def __ResetNameList(self, old_gender):
  454.         for i in xrange(SLOT_COUNT[old_gender]):
  455.             self.destNameAlpha[i] = 0.0
  456.             # self.curNameAlpha[i] += (self.destNameAlpha[i] - self.curNameAlpha[i]) / 10.0
  457.             self.NameList[old_gender][i].SetAlpha(0.0)
  458.  
  459.     def __UpdateScene(self):
  460.         for i in xrange(SLOT_COUNT[self.gender]):
  461.             self.destNameAlpha[i] = 0.0
  462.  
  463.         self.destNameAlpha[self.slot] = 1.0
  464.  
  465.         for i in xrange(SLOT_COUNT[self.gender]):
  466.             self.destRotation[(i+self.slot)%SLOT_COUNT[self.gender]] = self.SLOT_ROTATION[self.gender][i]
  467.  
  468.         if self.IsShow():
  469.             snd.PlaySound("sound/ui/click.wav")
  470.  
  471.         event.ClearEventSet(self.descIndex)
  472.         self.descIndex = event.RegisterEventSet(self.DESCRIPTION_FILE_NAME[self.slot])
  473.  
  474.         if localeInfo.IsARABIC():
  475.             event.SetEventSetWidth(self.descIndex, 170)
  476.  
  477.         chr_id = self.__GetSlotChrID(self.gender, self.slot)
  478.         if chr.HasInstance(chr_id):
  479.             chr.SelectInstance(chr_id)
  480.             self.__SelectShape(self.shapeList[self.gender][self.slot])
  481.  
  482.     def __SelectSlot(self, slot):
  483.  
  484.         if slot < 0:
  485.             return
  486.  
  487.         if slot >= SLOT_COUNT[self.gender]:
  488.             return
  489.  
  490.         if self.slot == slot:
  491.             return
  492.  
  493.         self.slot = slot
  494.         self.ResetStat()
  495.        
  496.         for i in xrange(SLOT_COUNT[self.gender]):
  497.             self.destNameAlpha[i] = 0.0
  498.  
  499.         self.destNameAlpha[slot] = 1.0
  500.  
  501.         for i in xrange(SLOT_COUNT[self.gender]):
  502.             self.destRotation[(i+self.slot)%(SLOT_COUNT[self.gender])] = self.SLOT_ROTATION[self.gender][i]
  503.        
  504.         #
  505.         self.__UpdateScene()
  506.  
  507.     def CreateCharacter(self):
  508.  
  509.         if -1 != self.reservingRaceIndex:
  510.             return
  511.  
  512.         textName = self.editCharacterName.GetText()
  513.         if FALSE == self.__CheckCreateCharacter(textName):
  514.             return
  515.         if musicInfo.selectMusic != "":
  516.             snd.FadeLimitOutMusic("BGM/"+musicInfo.selectMusic, (systemSetting.GetMusicVolume()/5.0)*0.05)
  517.  
  518.         self.DisableWindow()
  519.  
  520.  
  521.         chr_id = self.__GetSlotChrID(self.gender, self.slot)
  522.  
  523.         chr.SelectInstance(chr_id)
  524.  
  525.         self.reservingRaceIndex = chr.GetRace()
  526.  
  527.         self.reservingShapeIndex = self.shapeList[self.gender][self.slot]
  528.         self.reservingStartTime = app.GetTime()
  529.  
  530.         for eachSlot in xrange(SLOT_COUNT[self.gender]):
  531.  
  532.             sel_id = self.__GetSlotChrID(self.gender, eachSlot)
  533.  
  534.             chr.SelectInstance(sel_id)
  535.  
  536.             if eachSlot == self.slot:
  537.                 chr.PushOnceMotion(chr.MOTION_INTRO_SELECTED)
  538.             else:
  539.                 chr.PushOnceMotion(chr.MOTION_INTRO_NOT_SELECTED)
  540.  
  541.     def CancelCreate(self):
  542.         self.stream.SetSelectCharacterPhase()
  543.  
  544.     def __DecreaseSlotIndex(self):
  545.         slotIndex = (self.GetSlotIndex() - 1 + SLOT_COUNT[self.gender]) % SLOT_COUNT[self.gender]
  546.         self.__SelectSlot(slotIndex)
  547.  
  548.     def __IncreaseSlotIndex(self):
  549.         slotIndex = (self.GetSlotIndex() + 1) % SLOT_COUNT[self.gender]
  550.         self.__SelectSlot(slotIndex)
  551.  
  552.     def PrevDescriptionPage(self):
  553.         if True == event.IsWait(self.descIndex):
  554.             if event.GetVisibleStartLine(self.descIndex)-5 >= 0:
  555.                 event.SetVisibleStartLine(self.descIndex, event.GetVisibleStartLine(self.descIndex)-5)
  556.                 event.Skip(self.descIndex)
  557.         else:
  558.             event.Skip(self.descIndex)
  559.  
  560.     def NextDescriptionPage(self):
  561.         if True == event.IsWait(self.descIndex):
  562.             event.SetVisibleStartLine(self.descIndex, event.GetVisibleStartLine(self.descIndex)+5)
  563.             event.Skip(self.descIndex)
  564.         else:
  565.             event.Skip(self.descIndex)
  566.  
  567.     def __CheckCreateCharacter(self, name):
  568.         if len(name) == 0:
  569.             self.PopupMessage(localeInfo.CREATE_INPUT_NAME, self.EnableWindow)
  570.             return False
  571.  
  572.         if name.find(localeInfo.CREATE_GM_NAME)!=-1:
  573.             self.PopupMessage(localeInfo.CREATE_ERROR_GM_NAME, self.EnableWindow)
  574.             return False
  575.  
  576.         if net.IsInsultIn(name):
  577.             self.PopupMessage(localeInfo.CREATE_ERROR_INSULT_NAME, self.EnableWindow)
  578.             return False
  579.  
  580.         return True
  581.  
  582.     def ResetStat(self):
  583.         realIdx = GetRealIDnSlot(self.gender, self.slot)
  584.         for i in xrange(4):
  585.             self.stat[i] = self.START_STAT[realIdx][i]
  586.         self.lastStatPoint = self.CREATE_STAT_POINT
  587.         self.RefreshStat()
  588.  
  589.     ## Event
  590.     def OnCreateSuccess(self):
  591.         self.stream.SetSelectCharacterPhase()
  592.  
  593.     def OnCreateFailure(self, type):
  594.         if 1 == type:
  595.             self.PopupMessage(localeInfo.CREATE_EXIST_SAME_NAME, self.EnableWindow)
  596.         else:
  597.             self.PopupMessage(localeInfo.CREATE_FAILURE, self.EnableWindow)
  598.  
  599.     def OnKeyDown(self, key):
  600.         for i in xrange(SLOT_COUNT[self.gender]):
  601.             if key == 2+i:
  602.                 self.__SelectSlot(i)
  603.  
  604.         if 203 == key:
  605.             self.__DecreaseSlotIndex()
  606.         if 205 == key:
  607.             self.__IncreaseSlotIndex()
  608.  
  609.         if 59 == key:
  610.             self.__SelectGender(MAN_PAGE)
  611.         if 60 == key:
  612.             self.__SelectGender(WOMAN_PAGE)
  613.  
  614.         return True
  615.  
  616.     def OnUpdate(self):
  617.         chr.Update()
  618.  
  619.         (xposEventSet, yposEventSet) = self.textBoard.GetGlobalPosition()
  620.         event.UpdateEventSet(self.descIndex, xposEventSet+7, -(yposEventSet+7))
  621.         self.descriptionBox.SetIndex(self.descIndex)
  622.  
  623.         for i in xrange(SLOT_COUNT[self.gender]):
  624.             self.curNameAlpha[i] += (self.destNameAlpha[i] - self.curNameAlpha[i]) / 10.0
  625.             self.NameList[self.gender][i].SetAlpha(self.curNameAlpha[i])
  626.  
  627.         for i in xrange(4):
  628.             self.curGauge[i] += (self.destGauge[i] - self.curGauge[i]) / 10.0
  629.             if abs(self.curGauge[i] - self.destGauge[i]) < 0.005:
  630.                 self.curGauge[i] = self.destGauge[i]
  631.             self.GaugeList[i].SetPercentage(self.curGauge[i], 1.0)
  632.  
  633.         for page in xrange(PAGE_COUNT):
  634.             for i in xrange(SLOT_COUNT[page]):
  635.                 chr.SelectInstance(self.__GetSlotChrID(page, i))
  636.  
  637.                 distance = 50.0
  638.                 rotRadian = self.curRotation[i] * (math.pi*2) / 360.0
  639.                 x = distance*math.sin(rotRadian) + distance*math.cos(rotRadian)
  640.                 y = distance*math.cos(rotRadian) - distance*math.sin(rotRadian)
  641.                 chr.SetPixelPosition(int(x), int(y), 30)
  642.  
  643.                 if abs(self.destRotation[i] - self.curRotation[i]) < 1.0:
  644.                     self.curRotation[i] = self.destRotation[i]
  645.  
  646.                 dir = app.GetRotatingDirection(self.destRotation[i], self.curRotation[i])
  647.                 rot = app.GetDegreeDifference(self.destRotation[i], self.curRotation[i])
  648.  
  649.                 if app.DEGREE_DIRECTION_RIGHT == dir:
  650.                     self.curRotation[i] += rot / 10.0
  651.                 elif app.DEGREE_DIRECTION_LEFT == dir:
  652.                     self.curRotation[i] -= rot / 10.0
  653.  
  654.                 self.curRotation[i] = (self.curRotation[i] + 360.0) % 360.0
  655.  
  656.         ###########################################################
  657.         if -1 != self.reservingRaceIndex:
  658.             if app.GetTime() - self.reservingStartTime >= 1.5:
  659.  
  660.                 chrSlot=self.stream.GetCharacterSlot()
  661.                 textName = self.editCharacterName.GetText()
  662.                 raceIndex = self.reservingRaceIndex
  663.                 shapeIndex = self.reservingShapeIndex
  664.  
  665.                 startStat = self.START_STAT[self.reservingRaceIndex]
  666.                 statCon = self.stat[0] - startStat[0]
  667.                 statInt = self.stat[1] - startStat[1]
  668.                 statStr = self.stat[2] - startStat[2]
  669.                 statDex = self.stat[3] - startStat[3]
  670.  
  671.                 net.SendCreateCharacterPacket(chrSlot, textName, raceIndex, shapeIndex, statCon, statInt, statStr, statDex)
  672.  
  673.                 self.reservingRaceIndex = -1
  674.  
  675.         ###########################################################
  676.  
  677.     def EmptyFunc(self):
  678.         pass
  679.  
  680.     def PopupMessage(self, msg, func=0):
  681.         if not func:
  682.             func=self.EmptyFunc
  683.  
  684.         self.stream.popupWindow.Close()
  685.         self.stream.popupWindow.Open(msg, func, localeInfo.UI_OK)
  686.  
  687.     def OnPressExitKey(self):
  688.         self.CancelCreate()
  689.         return True
  690.  
  691.     def OverInStatButton(self, stat):
  692.         if not self.STAT_DESCRIPTION.has_key(stat):
  693.             return
  694.  
  695.         self.toolTip.ClearToolTip()
  696.         self.toolTip.AppendTextLine(self.STAT_DESCRIPTION[stat])
  697.         self.toolTip.Show()
  698.  
  699.     def OverOutStatButton(self):
  700.         self.toolTip.Hide()
  701.  
  702. if __name__ == "__main__":
  703.  
  704.     import app
  705.     import wndMgr
  706.     import systemSetting
  707.     import mouseModule
  708.     import networkModule
  709.  
  710.     app.SetMouseHandler(mouseModule.mouseController)
  711.     app.SetHairColorEnable(True)
  712.     wndMgr.SetMouseHandler(mouseModule.mouseController)
  713.     wndMgr.SetScreenSize(systemSetting.GetWidth(), systemSetting.GetHeight())
  714.     app.Create(localeInfo.APP_TITLE, systemSetting.GetWidth(), systemSetting.GetHeight(), 1)
  715.     mouseModule.mouseController.Create()
  716.  
  717.     mainStream = networkModule.MainStream()
  718.     mainStream.Create()
  719.  
  720.     test = CreateCharacterWindow(mainStream)
  721.     test.Open()
  722.  
  723.     app.Loop()
RAW Paste Data