Guest User

Untitled

a guest
Dec 22nd, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 24.76 KB | None | 0 0
  1. import app
  2. import grp
  3. import wndMgr
  4. import ui
  5. import os
  6. import sys
  7. import stat
  8. import chrmgr
  9. import imp
  10. import chr
  11. import net
  12. import background
  13. import snd
  14. import net
  15. import player
  16. import localeInfo
  17. import uiScriptLocale
  18.  
  19. class Console(object):
  20.     def __init__(self, output):
  21.         self.dirNameList = []
  22.         self.fileNameList = []
  23.  
  24.         self.output = output       
  25.         self.curPathName = "D:\\Ymir Work\\"
  26.         self.collision = 0
  27.  
  28.         self.bgPartDict = {
  29.             "terrain":background.PART_TERRAIN,
  30.             "object":background.PART_OBJECT,
  31.             "cloud":background.PART_CLOUD,
  32.             "tree":background.PART_TREE,
  33.             "water":background.PART_WATER,
  34.             "sky":background.PART_SKY,
  35.         }
  36.  
  37.         self.bgSortDict = {
  38.             "distance":background.DISTANCE_SORT,
  39.             "texture":background.TEXTURE_SORT,
  40.         }
  41.  
  42.         self.game = 0
  43.  
  44.     def Close(self):
  45.         self.output = 0
  46.  
  47.     def BindGameClass(self, game):
  48.         self.game = game
  49.  
  50.     def Exit(self):
  51.         "Exit Program"
  52.         app.Exit()
  53.  
  54.     def EnablePerformanceTime(self, mode, isEnable):
  55.         app.EnablePerformanceTime(mode, int(isEnable))
  56.  
  57.     def ReloadLocale(self):
  58.         "Reload Locale"
  59.         reload(localeInfo)
  60.         reload(uiScriptLocale)
  61.         self.Print("RELOAD LOCALE")
  62.  
  63.     def ReloadDevel(self):
  64.         "ReloadDevel"
  65.         import consoleModule
  66.         import uiGuild
  67.         import uiInventory
  68.         reload(uiGuild)
  69.         self.Print("ReloadGuild")
  70.         reload(uiInventory)
  71.         self.Print("ReloadInventory")
  72.  
  73.     def ShowPerformanceInfo(self):
  74.         "Shows Performance Info"
  75.         self.Print(app.GetInfo(app.INFO_ACTOR))
  76.         self.Print(app.GetInfo(app.INFO_ITEM))
  77.         self.Print(app.GetInfo(app.INFO_EFFECT))
  78.         self.Print(app.GetInfo(app.INFO_TEXTTAIL))
  79.  
  80.     def Disconnect(self):
  81.         "Disconnect by sending unknown packet"
  82.         net.SendStrangePacket()
  83.  
  84.     def ToggleActorDirectionLine(self):
  85.         "Shows character's direction line"
  86.         chrmgr.ToggleDirectionLine()
  87.  
  88.     def RegisterCharacterEffect(self, effectType, effectFileName):
  89.         "Set character's effect state (state number, bone name, effect filename/number)"
  90.         if effectFileName.isdigit():
  91.             effectFileName = self.GetFileName(int(effectFileName))
  92.  
  93.         effectFullPathFileName = self.GetFullPathName(effectFileName)
  94.         chrmgr.RegisterEffect(chrmgr.EFFECT_STATE+int(effectType), "", effectFullPathFileName)
  95.         self.Print("effect state %d: %s" % (int(effectType), effectFullPathFileName))
  96.  
  97.     def SetCharacterAffect(self, affectType, isVisible):
  98.         "Set character's affect (number, visiblity 1|0)"
  99.         chrmgr.SetAffect(-1, int(affectType), int(isVisible))
  100.         self.Print("affect set %d: %d" % (int(affectType), int(isVisible)))
  101.  
  102.     def SetCharacterEmoticon(self, EmoticonNum):
  103.         "Show emoticon (number)"
  104.         chrmgr.SetEmoticon(-1, int(EmoticonNum))
  105.         self.Print("Emoticon %d: %d" % (int(EmoticonNum), int(isVisible)))
  106.  
  107.     def ShowPickedCharacterInfo(self):
  108.         "Show information of picked character"
  109.         vid=chrmgr.GetPickedVID()
  110.         info=chrmgr.GetVIDInfo(vid)
  111.         self.Print(info)
  112.  
  113.     def ShowCharacterInfo(self, arg):
  114.         "Show information of character (vid)"
  115.         if arg.isdigit():
  116.             vid=int(arg)
  117.         else:
  118.             vid=0
  119.  
  120.         info=chrmgr.GetVIDInfo(vid)
  121.         self.Print(info)
  122.  
  123.     def SetWeaponTraceTexture(self, arg):
  124.         "Sets sword afterimage texture (filename)"
  125.         if arg.isdigit():
  126.             textureFileName = self.GetFileName(int(arg))
  127.         else:
  128.             textureFileName = arg
  129.  
  130.         chr.WeaponTraceSetTexture(textureFileName)
  131.  
  132.     def SetAutoCameraRotationSpeed(self, arg):
  133.         "Auto camera rotation speed (angle per sec)"
  134.         spd=float(arg)
  135.         player.SetAutoCameraRotationSpeed(spd)
  136.  
  137.         self.Print("Auto camera rotation speed: %f" % (spd))
  138.  
  139.     def SetWeaponTraceMode(self, *mode):
  140.         "Sword afterimage mode (0 = Use alpha, 1 = Use texture)"
  141.         if mode and mode[0].isdigit() and int(mode[0]):
  142.             chr.WeaponTraceUseTexture()
  143.         else:
  144.             chr.WeaponTraceUseAlpha()
  145.  
  146.     def SetCollision(self, *mode):
  147.         "Show collison objects (0 | 1)"
  148.         if mode and mode[0].isdigit():
  149.             self.collision = int(mode[0])
  150.         else:
  151.             self.collision = not self.collision    
  152.  
  153.     def SetMovingSpeed(self, arg):
  154.         "Set walking speed"
  155.         chrmgr.SetMovingSpeed(int(arg))
  156.  
  157.     def SetMusicVolume(self, arg):
  158.         "Set BGM volumn (0 ~ 1.0)"
  159.         snd.SetMusicVolume(float(arg))
  160.  
  161.     def SetSoundVolume(self, arg):
  162.         "Set Effect sound volumn (0 ~ 5)"
  163.         snd.SetSoundVolume(int(arg))
  164.  
  165.     def SetSoundScale(self, arg):
  166.         "3D Sound scale (default : 200)"
  167.         snd.SetSoundScale(int(arg))
  168.  
  169.     def SetAmbienceSoundScale(self, arg):
  170.         "3D Ambience sound scale (default : 200)"
  171.         snd.SetAmbienceSoundScale(int(arg))
  172.  
  173.     def SetCoolTime(self):
  174.         "Cooltime toggle"
  175.         flag = player.ToggleCoolTime()
  176.         if flag:
  177.             self.Print("Cooltime will be applied")
  178.         else:
  179.             self.Print("Cooltime disabled")
  180.  
  181.     def SetLevelLimit(self):
  182.         "Sets Level limit"
  183.         flag = player.ToggleLevelLimit()
  184.         if flag:
  185.             self.Print("Level limit will be applied")
  186.         else:
  187.             self.Print("Level limit disabled")
  188.  
  189.     def ShowCursor(self):
  190.         app.ShowCursor()
  191.  
  192.     def HideCursor(self):
  193.         app.HideCursor()
  194.  
  195.     def Print(self, msg):
  196.         self.output.Print(msg)
  197.  
  198.     def RefreshPath(self):
  199.         self.SetPath(self.curPathName)
  200.  
  201.     def SetPath(self, newPathName):
  202.         if '\\'!=newPathName[-1]:
  203.             newPathName=newPathName+'\\'
  204.  
  205.         if os.access(newPathName, os.R_OK)==0:
  206.             self.Print(newPathName+" Cannot find path")
  207.             return
  208.  
  209.         nameList=os.listdir(newPathName)
  210.  
  211.         dirNameList=[]
  212.         fileNameList=[]
  213.         for sName in nameList:
  214.             mode=os.stat(newPathName+sName)[stat.ST_MODE]
  215.             if stat.S_ISDIR(mode):
  216.                 dirNameList.append(sName)
  217.             else:
  218.                 fileNameList.append(sName)
  219.  
  220.         self.curPathName=newPathName
  221.         self.dirNameList=dirNameList
  222.         self.fileNameList=fileNameList
  223.  
  224.         self.ShowPath()
  225.  
  226.     def GetPath(self):
  227.         return self.curPathName
  228.  
  229.     def GetDirName(self, iDir):
  230.         if (len(self.dirNameList)>iDir):
  231.             return self.dirNameList[iDir]
  232.         else:
  233.             print len(self.dirNameList)
  234.             return ""
  235.  
  236.     def GetFileName(self, iFile):  
  237.         if (len(self.fileNameList)>iFile):
  238.             return self.fileNameList[iFile]
  239.         else:
  240.             print len(self.fileNameList)
  241.             return ""
  242.  
  243.     def MoveParentPath(self):
  244.         "Go to Parent directory"
  245.         newPathName=self.GetPath()
  246.  
  247.         lastPos=-1
  248.         if '\\'==newPathName[-1]:
  249.             lastPos=-2
  250.  
  251.         lastPos=newPathName.rfind('\\', 0,  lastPos)
  252.         if 0>lastPos:
  253.             self.Print("Here is root")
  254.             return
  255.  
  256.         newPathName=newPathName[0:lastPos]+'\\'
  257.  
  258.         self.SetPath(newPathName)
  259.  
  260.     def GetFullPathName(self, sPathName):
  261.         sParentPathName=self.GetPath()
  262.  
  263.         if '\\'!=sParentPathName[-1]:
  264.             sParentPathName=sParentPathName+'\\'
  265.  
  266.         return sParentPathName+sPathName
  267.  
  268.     def MoveChildPath(self, directory):
  269.         "[Directory name/number] change to child directory"
  270.         if ""==directory:
  271.             self.Print("You need directory name or number")
  272.             return
  273.  
  274.         if directory.isdigit():
  275.             directory=self.GetDirName(int(directory))
  276.  
  277.         newPathName=self.GetFullPathName(directory)
  278.  
  279.         self.SetPath(newPathName)
  280.  
  281.     def SetHitEffect(self, arg):
  282.         "Sets hit effect"
  283.         if arg.isdigit():
  284.             effectFileName = self.GetFileName(int(arg))
  285.         else:
  286.             effectFileName = arg
  287.  
  288.         effectFullPathFileName=self.GetFullPathName(EffectFileName)
  289.         chrmgr.RegisterEffect(chrmgr.EFFECT_HIT, "", effectFullPathFileName)
  290.  
  291.         self.Print("Hit effect: "+effectFullPathFileName)
  292.  
  293.     def SetStunEffect(self, arg):
  294.         "Sets stun effect"
  295.         if arg.isdigit():
  296.             effectFileName = self.GetFileName(int(arg))
  297.         else:
  298.             effectFileName = arg
  299.  
  300.         effectFullPathFileName = self.GetFullPathName(effectFileName)
  301.         chrmgr.RegisterEffect(chrmgr.EFFECT_STUN, "Bip01 Head", effectFullPathFileName)
  302.  
  303.         self.Print("Stun effect: "+effectFullPathFileName)
  304.  
  305.     def SetDustEffect(self, arg):
  306.         "Sets dirt effect"
  307.         if arg.isdigit():
  308.             effectFileName = self.GetFileName(int(arg))
  309.         else:
  310.             effectFileName = arg
  311.  
  312.         effectFullPathFileName = self.GetFullPathName(effectFileName)
  313.         chrmgr.RegisterEffect(chrmgr.EFFECT_DUST, "", effectFullPathFileName)
  314.  
  315.         self.Print("Dirt effect: "+effectFullPathFileName)
  316.  
  317.     def SetDustGap(self, arg):
  318.         "Sets dirt effect gap"
  319.         if arg.isdigit() == 0:
  320.             self.Print("Dirt effect gap argument must be a number")
  321.         else:
  322.             gap = int(arg)
  323.             chrmgr.SetDustGap(gap)
  324.             self.Print("Dirt effect gap: %d" % (gap))
  325.  
  326.     def ShowBackgroundPart(self, arg):
  327.         "Show background part"
  328.         try:
  329.             background.SetVisiblePart(self.bgPartDict[arg], 1);
  330.         except KeyError:
  331.             self.Print("Unknown part: ", arg);
  332.         except:
  333.             raise
  334.        
  335.     def HideBackgroundPart(self, arg):
  336.         "Hide background part"
  337.         try:
  338.             background.SetVisiblePart(self.bgPartDict[arg], 0);
  339.         except KeyError:
  340.             self.Print("Unknown part: ", arg);
  341.         except:
  342.             raise
  343.  
  344.     def SetShadowLevel(self, arg):
  345.         "Shadow level setting (0~5)"
  346.         if arg.isdigit() == 0:
  347.             self.Print("Shadow setting must be a number")
  348.         else:
  349.             level = int(arg)
  350.  
  351.             if level < 0 or level > 5:
  352.                 self.Print("Shadow level range is 0~5")
  353.             else:
  354.                 background.SetShadowLevel(level)
  355.                 self.Print("Shadow level: %d" % (level))
  356.  
  357.     def SetSplatLimit(self, arg):
  358.         "Splat number limit"
  359.         if arg.isdigit() == 0:
  360.             self.Print("Splat number limit must be a number")
  361.         else:
  362.             limit = int(arg)
  363.  
  364.             background.SetSplatLimit(limit)
  365.             self.Print("Splat number limit: %d" % (limit))
  366.  
  367.     def SelectViewDistanceNum(self, arg):
  368.         "View distance (0~4)"
  369.         if arg.isdigit() == 0:
  370.             self.Print("Enter between 0 to 4")
  371.         else:
  372.             settingnum = int(arg)
  373.  
  374.             if settingnum < 0 or settingnum > 4:
  375.                 self.Print("View distance range is 0 to 4")
  376.  
  377.             else:
  378.                 background.SelectViewDistanceNum(settingnum)
  379.                 self.Print("View distance: %d" % (settingnum))
  380.  
  381.     def SetBGLoading(self, bBGLoading):
  382.         "Background loading (0, 1)"
  383.         bResultBoolean = int(bBGLoading)
  384.  
  385.         if bResultBoolean != 0 and bResultBoolean != 1:
  386.             self.Print("Enter 0 or 1")
  387.         else:
  388.             background.SetBGLoading(bResultBoolean)
  389.             self.Print("Background loading: %d" % (bResultBoolean))
  390.  
  391.     def SetTerrainRenderSort(self, arg):
  392.         "Terrain rendering type"
  393.         try:
  394.             background.SetRenderSort(self.bgSortDict[arg]);
  395.         except KeyError:
  396.             self.Print("Unknown part: ", arg);
  397.         except:
  398.             raise
  399.  
  400.     def SetTransparentTree(self, arg):
  401.         "Tree's leaf transparency"
  402.         bTransparent = int(arg)
  403.         try:
  404.             background.SetTransparentTree(bTransparent);
  405.         except KeyError:
  406.             self.Print("must be 0 or 1: ", bTransparent);
  407.         except:
  408.             raise
  409.  
  410.     def WarpTest(self, warpX, warpY):
  411.         "WarpTest : warp dwX dwY"
  412.         iWarpX = int(warpX)
  413.         iWarpY = int(warpY)
  414.         try:
  415.             background.Destroy()
  416.             background.Initialize()
  417.             background.WarpTest(iWarpX, iWarpY);
  418.             background.RegisterEnvironmentData(0, "d:/ymir work/environment/b3.msenv")
  419.             background.SetEnvironmentData(0)
  420.             background.SetShadowLevel(background.SHADOW_ALL)
  421.         except:
  422.             import exception
  423.             exception.Abort("consoleModule.Console.WarpTest")
  424.  
  425.     def ToggleDebugInfo(self):
  426.         "Show DebugInfo"
  427.         net.ToggleGameDebugInfo()
  428.        
  429.     def ShowPath(self):
  430.         "Show current path"
  431.         self.Print("Current path is "+self.GetPath())
  432.  
  433.     def ShowList(self):
  434.         "Show current path's list"
  435.         self.ShowDirList()
  436.         self.ShowFileList()
  437.  
  438.     def ShowDirList(self):
  439.         "Show current path's child directories"
  440.         self.Print(self.GetPath()+" directories:")
  441.         self.ShowNameList(self.dirNameList)
  442.         self.Print("")
  443.  
  444.     def ShowFileList(self, Filter=[]):
  445.         "Show current path's files (extension filter)"
  446.         self.Print(self.GetPath()+" files:")
  447.         self.ShowNameList(self.fileNameList, Filter)
  448.         self.Print("")
  449.  
  450.     def ShowEffectList(self):
  451.         "Show current path's effect"
  452.         self.Print(self.GetPath()+" effects:")
  453.         self.ShowNameList(self.fileNameList, ["mse"])
  454.         self.Print("")
  455.  
  456.     def ShowWeb(self):
  457.         "ShowWeb"
  458.         if app.IsWebPageMode():
  459.             app.HideWebPage()
  460.         else:
  461.             app.ShowWebPage("http://wiki.metin.co.kr/metin1help/01.htm", (0, 0, 320, 600))
  462.  
  463.     def ShowUI(self):
  464.         "Shows UI"
  465.         self.game.CheckGameButton()
  466.         self.game.interface.ShowDefaultWindows()
  467.         self.game.interface.wndChat.Show()
  468.  
  469.     def HideUI(self):
  470.         "Hides UI"
  471.         self.game.interface.HideAllWindows()
  472.         self.game.interface.wndChat.Hide()
  473.  
  474.     def SetCameraSpeed(self, percentage):
  475.         "Sets camera speed (Default = 100)"
  476.         app.SetCameraSpeed(int(percentage))
  477.  
  478.     def SaveCameraSetting(self, filename):
  479.         "Save current camera attributes (filename)"
  480.         app.SaveCameraSetting(filename)
  481.  
  482.     def LoadCameraSetting(self, filename):
  483.         "Load camera attributes (filename)"
  484.         if not app.LoadCameraSetting(filename):
  485.             self.Print("Could not load camera attribute")
  486.  
  487.     def SetDefaultCamera(self):
  488.         "Return to default camera attribute"
  489.         app.SetDefaultCamera()
  490.  
  491.     def ShowClock(self, second):
  492.         self.game.ShowClock(int(second))
  493.  
  494.     def HideClock(self):
  495.         self.game.HideClock()
  496.  
  497.     def ShowNotice(self):
  498.         app.SetVisibleNotice(TRUE)
  499.         self.Print("Show Notice")
  500.  
  501.     def HideNotice(self):
  502.         app.SetVisibleNotice(FALSE)
  503.         self.Print("Hide Notice")
  504.  
  505.     def SetSight(self, range):
  506.         "Set Force Sight Range"
  507.         app.SetSightRange(int(range))
  508.  
  509.     def SetComboType(self, type):
  510.         chr.testSetComboType(int(type))
  511.  
  512.     def SetSkillGroupFake(self, index):
  513.         """테스트 코드"""
  514.         net.SetSkillGroupFake(int(index))
  515.         self.Print(" SetSkillGroupFake : %d" % int(index))
  516.  
  517.     def SetEmpireLanguageMode(self, mode):
  518.         net.SetEmpireLanguageMode(int(mode))
  519.         self.Print(" SetEmpireLanguageMode : %d" % int(mode))
  520.  
  521.     def SetCharacterRenderModeTypeAdd(self, color):
  522.         vid = player.GetTargetVID()
  523.         print " -> SetCharacterRenderModeTypeAdd", vid, color
  524.         chr.testSetAddRenderMode(vid, int(color,16))
  525.  
  526.     def SetCharacterRenderModeTypeMod(self, color):
  527.         vid = player.GetTargetVID()
  528.         print " -> SetCharacterRenderModeTypeMod", vid, color, int(color,16)
  529.         chr.testSetModulateRenderMode(vid, int(color,16))
  530.  
  531.     def SetCharacterRenderModeTypeAddRGB(self, r, g, b):
  532.         vid = player.GetTargetVID()
  533.         print " -> SetCharacterRenderModeTypeAddRGB", vid, r, g, b
  534.         chr.testSetAddRenderModeRGB(vid, float(r)/255.0, float(g)/255.0, float(b)/255.0)
  535.  
  536.     def SetCharacterRenderModeTypeModRGB(self, r, g, b):
  537.         vid = player.GetTargetVID()
  538.         print " -> SetCharacterRenderModeTypeModRGB", vid, r, g, b
  539.         chr.testSetModulateRenderModeRGB(vid, float(r)/255.0, float(g)/255.0, float(b)/255.0)
  540.  
  541.     def SetCharacterRenderModeSpecular(self, alpha):
  542.         vid = player.GetTargetVID()
  543.         print " -> SetCharacterRenderModeSpecular", vid, alpha
  544.         chr.testSetSpecularRenderMode(vid, float(alpha))
  545.  
  546.     def RestoreCharacterRenderModeType(self):
  547.         vid = player.GetTargetVID()
  548.         chr.testRestoreRenderMode(vid)
  549.  
  550.  
  551.     def ShowNameList(self, lstsName, lstsFilter=None):
  552.         if len(lstsName)==0:
  553.             self.Print("None")
  554.             return
  555.  
  556.         if lstsFilter:
  557.             isFilter=1
  558.         else:
  559.             isFilter=0
  560.  
  561.         sLine=""
  562.         iCol=0
  563.  
  564.         iName=0
  565.         for sName in lstsName:
  566.             if isFilter:
  567.                 iDotPos=sName.rfind('.', 0, -1)
  568.                 if iDotPos<0:
  569.                     iName=iName+1
  570.                     continue
  571.  
  572.                 if (sName[iDotPos+1:] in lstsFilter)==0:
  573.                     iName=iName+1
  574.                     continue
  575.  
  576.             sLine=sLine+"%3d %-15s " % (iName, sName)
  577.  
  578.             if iCol>4:
  579.                 iCol=0
  580.                 self.Print(sLine)
  581.                 sLine=""
  582.  
  583.             iCol=iCol+1
  584.  
  585.             iName=iName+1
  586.  
  587.         if ""!=sLine:
  588.             self.Print(sLine)
  589.  
  590. class ConsoleWindow(ui.Window):
  591.  
  592.     BACK_GROUND_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 0.5)
  593.     EDIT_LINE_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 1.0)
  594.     BUTTON_COLOR = grp.GenerateColor(1.0, 1.0, 1.0, 1.0)
  595.     HEIGHT = 200
  596.     LINE_STEP = 15
  597.     MAX_LINE_COUNT = 50
  598.  
  599.     class ConsoleEditLine(ui.EditLine):
  600.         def __init__(self):
  601.             ui.EditLine.__init__(self)
  602.             self.eventReturn = 0
  603.             self.eventEscape = 0
  604.         def __del__(self):
  605.             ui.EditLine.__del__(self)
  606.  
  607.         def SetReturnEvent(self, event):
  608.             self.eventReturn = event
  609.  
  610.         def SetEscapeEvent(self, event):
  611.             self.eventEscape = event
  612.  
  613.         def OnIMEReturn(self):
  614.             text = self.GetText()
  615.  
  616.             if len(text) > 0:
  617.                 self.eventReturn(text)
  618.  
  619.             else:
  620.                 wndMgr.KillFocus()
  621.                 self.eventEscape()
  622.  
  623.             self.SetText("")
  624.             return TRUE
  625.  
  626.         def OnPressEscapeKey(self):
  627.             self.SetText("")
  628.             wndMgr.KillFocus()
  629.             self.eventEscape()
  630.             return TRUE
  631.  
  632.     class ResizingButton(ui.DragButton):
  633.  
  634.         BUTTON_NORMAL_COLOR = grp.GenerateColor(0.3320, 0.2929, 0.2578, 1.0)
  635.         BUTTON_OVER_COLOR = grp.GenerateColor(0.5320, 0.4929, 0.4578, 1.0)
  636.         BUTTON_LIGHT_OUTLINE_COLOR = grp.GenerateColor(0.6666, 0.6509, 0.6313, 1.0)
  637.         BUTTON_DARK_OUTLINE_COLOR = grp.GenerateColor(0.1647, 0.1450, 0.1294, 1.0)
  638.  
  639.         def __init__(self):
  640.             ui.DragButton.__init__(self)
  641.             self.AddFlag("limit")
  642.             self.AddFlag("restrict_x")
  643.  
  644.         def __del__(self):
  645.             ui.DragButton.__del__(self)
  646.  
  647.     def __init__(self):
  648.         ui.Window.__init__(self)
  649.  
  650.         self.TextList = []
  651.         self.game = 0
  652.         self.Console = Console(self)
  653.  
  654.         self.ResizingButton = self.ResizingButton()
  655.         self.ResizingButton.SetParent(self)
  656.         self.ResizingButton.SetSize(15, 15)
  657.         self.ResizingButton.SetPosition(100, 100)
  658.         self.ResizingButton.Show()
  659.  
  660.         self.EditLine = self.ConsoleEditLine()
  661.         self.EditLine.SetParent(self)
  662.         self.EditLine.SetMax(100)
  663.         self.EditLine.SetFontName(localeInfo.UI_DEF_FONT)
  664.         self.EditLine.SetText("")
  665.         self.EditLine.Show()
  666.  
  667.         from _weakref import ref
  668.  
  669.         self.ResizingButton.SetMoveEvent(lambda s = ref(self): s().UpdatePosition())
  670.         self.EditLine.SetReturnEvent(lambda x,s = ref(self): s().ProcessCommand(x))
  671.         self.EditLine.SetEscapeEvent(lambda s = ref(self): s().CloseWindow())
  672.  
  673.         self.UpdatePosition()
  674.  
  675.         self.functionDict = {}
  676.         self.InitFunction()
  677.  
  678.     def __del__(self):
  679.         ui.Window.__del__(self)
  680.  
  681.     def BindGameClass(self, game):
  682.         self.Console.BindGameClass(game)
  683.  
  684.     def Close(self):
  685.         self.Console.Close()
  686.         self.ResizingButton = 0
  687.         self.EditLine = 0
  688.  
  689.     def SetConsoleSize(self, width, height):
  690.         self.ResizingButton.SetPosition(width-20, height-20)
  691.         self.UpdatePosition()
  692.  
  693.     def OnRender(self):
  694.         grp.SetColor(self.BACK_GROUND_COLOR)
  695.         grp.RenderBar(self.gx, self.gy, self.width, self.height)
  696.    
  697.         grp.SetColor(ConsoleWindow.EDIT_LINE_COLOR)
  698.         grp.RenderBar(self.gxEditLine-2, self.gyEditLine-3, self.width - 40, 17)
  699.  
  700.         grp.SetColor(ConsoleWindow.BUTTON_COLOR)
  701.         grp.RenderBar(self.gxButton-2, self.gyButton-3, self.widthButton, self.heightButton)
  702.  
  703.     def UpdatePosition(self):
  704.  
  705.         self.width = self.GetWidth()
  706.         self.height = self.GetHeight()
  707.         self.widthButton = self.ResizingButton.GetWidth()
  708.         self.heightButton = self.ResizingButton.GetHeight()
  709.         (self.gx, self.gy) = self.GetGlobalPosition()
  710.         (self.gxButton, self.gyButton) = self.ResizingButton.GetGlobalPosition()
  711.  
  712.         self.SetSize(self.gxButton - self.gx + 20, self.gyButton - self.gy + 20)
  713.  
  714.         self.EditLine.SetSize(self.width-30, 16)
  715.         self.EditLine.SetPosition(7, self.height-20)
  716.         (self.gxEditLine, self.gyEditLine) = self.EditLine.GetGlobalPosition()
  717.  
  718.         #####
  719.  
  720.         yPosition = (self.height-20) - self.LINE_STEP
  721.         ItemCount = len(self.TextList)
  722.  
  723.         for i in xrange(ItemCount):
  724.             TextLine = self.TextList[ItemCount-i-1]
  725.  
  726.             TextLine.SetPosition(10, yPosition)
  727.             yPosition -= self.LINE_STEP
  728.  
  729.             if yPosition < 0:
  730.                 TextLine.Hide()
  731.             else:
  732.                 TextLine.Show()
  733.  
  734.     def OpenWindow(self):
  735.  
  736.         self.EditLine.SetFocus()
  737.  
  738.         self.Show()
  739.         self.Console.RefreshPath()
  740.  
  741.     def CloseWindow(self):
  742.         self.Hide()
  743.  
  744.     ## NOTE : 이곳에서 Command를 처리합니다 - [levites]
  745.     def ProcessCommand(self, text):
  746.  
  747.         if '/' == text[0]:
  748.             net.SendChatPacket(text)
  749.             return
  750.  
  751.         Console=self.Console
  752.         Console.Print(">> "+text)
  753.        
  754.         lstsArg=text.split()
  755.        
  756.         if len(lstsArg)==0:
  757.             return
  758.  
  759.         sCmd=lstsArg[0]
  760.  
  761.         if self.functionDict.has_key(sCmd):
  762.             try:
  763.                 self.functionDict[sCmd](self.Console, *lstsArg[1:])
  764.             except Exception, e:
  765.                 Console.Print(str(e))
  766.                 #self.Console.Print(e)
  767.                 #self.Console.Print(self.functionDict[sCmd].__doc__)
  768.         else:
  769.             if sCmd == 'help' or sCmd == 'h':
  770.                 try:
  771.                     k = lstsArg[1]
  772.                     v = self.functionDict[k]
  773.                     argcount = v.im_func.func_code.co_argcount - 1 # -1 for self
  774.                     if v.im_func.func_code.co_flags & 4:
  775.                         argcount+=1
  776.                     argnames = v.im_func.func_code.co_varnames[1:argcount+1]
  777.                     if argcount:
  778.                         Console.Print("%s(%s) : %s" % (k,argcount, v.__doc__))
  779.                         Console.Print("   arg : %s" % argnames)
  780.                     else:
  781.                         Console.Print("%s : %s" % (k,v.__doc__))
  782.                 except:
  783.                     for k,v in self.functionDict.iteritems():
  784.                         argcount = v.im_func.func_code.co_argcount - 1 # -1 for self
  785.                         if v.im_func.func_code.co_flags & 4:
  786.                             argcount+=1
  787.                         if argcount:
  788.                             Console.Print("%s(%s) : %s" % (k,argcount, v.__doc__))
  789.                         else:
  790.                             Console.Print("%s : %s" % (k,v.__doc__))
  791.                     Console.Print("? : All commands list")
  792.                     Console.Print("h : Help for all commands")
  793.                     Console.Print("h blah : Help for blah")
  794.  
  795.                 Console.Print("")
  796.             elif sCmd == '?':
  797.                 list = self.functionDict.keys()
  798.                 list.sort()
  799.                 Console.ShowNameList(list)
  800.             pass
  801.  
  802.     def InitFunction(self):
  803.         #self.AddFunction("help",       Console.PrintHelp)
  804.         #self.AddFunction("?",          Console.PrintHelp)
  805.  
  806.         self.AddFunction("exit",        Console.Exit)
  807.         self.AddFunction("mvol",        Console.SetMusicVolume)
  808.         self.AddFunction("svol",        Console.SetSoundVolume)
  809.         self.AddFunction("snds",        Console.SetSoundScale)
  810.         self.AddFunction("asnds",       Console.SetAmbienceSoundScale)
  811.         self.AddFunction("mspd",        Console.SetMovingSpeed)
  812.         self.AddFunction("pwd",         Console.ShowPath)
  813.         self.AddFunction("ls",          Console.ShowList)
  814.         self.AddFunction("shadow",      Console.SetShadowLevel)
  815.         self.AddFunction("splat",       Console.SetSplatLimit)
  816.         self.AddFunction("distance",    Console.SelectViewDistanceNum)
  817.         self.AddFunction("bgloading",   Console.SetBGLoading)
  818.         self.AddFunction("terrainrender",   Console.SetTerrainRenderSort)
  819.         self.AddFunction("transtree",       Console.SetTransparentTree)
  820.         self.AddFunction("stune",       Console.SetStunEffect)
  821.         self.AddFunction("duste",       Console.SetDustEffect)
  822.         self.AddFunction("dustt",       Console.SetDustGap)
  823.         self.AddFunction("hite",        Console.SetHitEffect)
  824.         self.AddFunction("cd",          Console.MoveChildPath)
  825.         self.AddFunction("up",          Console.MoveParentPath)
  826.         self.AddFunction("lsd",         Console.ShowDirList)
  827.         self.AddFunction("lsf",         Console.ShowFileList)
  828.         self.AddFunction("lse",         Console.ShowEffectList)
  829.         self.AddFunction("show",        Console.ShowBackgroundPart)
  830.         self.AddFunction("hide",        Console.HideBackgroundPart)
  831.         self.AddFunction("debuginfo",   Console.ToggleDebugInfo)
  832.  
  833.         self.AddFunction("collision",   Console.SetCollision)
  834.         self.AddFunction("colli",   Console.SetCollision)
  835.  
  836.         #self.AddFunction("wt", Console.SetWeaponTrace)
  837.         self.AddFunction("wtt", Console.SetWeaponTraceTexture)
  838.         self.AddFunction("wtm", Console.SetWeaponTraceMode)
  839.  
  840.         self.AddFunction("disconnect",  Console.Disconnect)
  841.         self.AddFunction("autorot", Console.SetAutoCameraRotationSpeed)
  842.  
  843.         self.AddFunction("dirline", Console.ToggleActorDirectionLine)
  844.         self.AddFunction("pickc", Console.ShowPickedCharacterInfo)
  845.         self.AddFunction("infoc", Console.ShowCharacterInfo)
  846.         self.AddFunction("regchre", Console.RegisterCharacterEffect)
  847.         self.AddFunction("setchra", Console.SetCharacterAffect)
  848.         self.AddFunction("emoticon", Console.SetCharacterEmoticon)
  849.         self.AddFunction("perfinfo", Console.ShowPerformanceInfo)
  850.         self.AddFunction("reload_locale", Console.ReloadLocale)
  851.         self.AddFunction("re", Console.ReloadDevel)
  852.         self.AddFunction("perftime", Console.EnablePerformanceTime)
  853.         self.AddFunction("cooltime", Console.SetCoolTime)
  854.         self.AddFunction("levellimit", Console.SetLevelLimit)
  855.         self.AddFunction("showcursor", Console.ShowCursor)
  856.         self.AddFunction("hidecursor", Console.HideCursor)
  857.  
  858.         self.AddFunction("warp", Console.WarpTest)
  859.         self.AddFunction("web", Console.ShowWeb)
  860.  
  861.         self.AddFunction("showui", Console.ShowUI)
  862.         self.AddFunction("hideui", Console.HideUI)
  863.  
  864.         self.AddFunction("setcspd", Console.SetCameraSpeed)
  865.         self.AddFunction("savecmr", Console.SaveCameraSetting)
  866.         self.AddFunction("loadcmr", Console.LoadCameraSetting)
  867.         self.AddFunction("setdefcmr", Console.SetDefaultCamera)
  868.  
  869.         self.AddFunction("showclock", Console.ShowClock)
  870.         self.AddFunction("hideclock", Console.HideClock)
  871.  
  872.         self.AddFunction("setsight", Console.SetSight)
  873.  
  874.         self.AddFunction("setcombotype", Console.SetComboType)
  875.         self.AddFunction("setsk_fake", Console.SetSkillGroupFake)
  876.  
  877.         self.AddFunction("trans", Console.SetEmpireLanguageMode)
  878.  
  879.         self.AddFunction("shownotice", Console.ShowNotice)
  880.         self.AddFunction("hidenotice", Console.HideNotice)
  881.  
  882.         self.AddFunction("setrmadd", Console.SetCharacterRenderModeTypeAdd)
  883.         self.AddFunction("setrmmod", Console.SetCharacterRenderModeTypeMod)
  884.         self.AddFunction("setrmaddrgb", Console.SetCharacterRenderModeTypeAddRGB)
  885.         self.AddFunction("setrmmodrgb", Console.SetCharacterRenderModeTypeModRGB)
  886.         self.AddFunction("setspec", Console.SetCharacterRenderModeSpecular)
  887.         self.AddFunction("restorerm", Console.RestoreCharacterRenderModeType)
  888.    
  889.     def AddFunction(self, cmd, func):
  890.         self.functionDict[cmd] = func
  891.  
  892.     def Print(self, text):
  893.         TextLine = ui.TextLine()
  894.         TextLine.SetParent(self)
  895.         TextLine.SetFontName(localeInfo.UI_DEF_FONT)
  896.         TextLine.Show()
  897.         TextLine.SetText(text)
  898.         self.TextList.append(TextLine)
  899.  
  900.         count = len(self.TextList)
  901.         if count > self.MAX_LINE_COUNT:
  902.             for i in xrange(count - self.MAX_LINE_COUNT):
  903.                 del self.TextList[0]
  904.  
  905.         self.UpdatePosition()
Add Comment
Please, Sign In to add comment