Beiträge von derWeise
-
-
Danke Syntax für deinen Tipp, aber die beiden anderen IsARABIC müssen auch noch auskommentiert werden damit das so aussieht
und
jetzt öffnet sich auch das kleine Fenster mit den gespeicherten Acc's, auswählen kann ich den auch er sagt mir auch, dass ich den Account ausgewählt habe nur leider ist der Laden Button ohne funtion... könntest du mir da bitte nochmal behilflich sein?
Syserr sagt leider nichts und im Ladefenster nach der Charauswahl bleibe ich immer noch hängen und bekomme diesen fehler
Code- 0330 21:46:10692 :: Traceback (most recent call last):
- 0330 21:46:10692 :: File "networkModule.py", line 234, in SetGamePhase
- 0330 21:46:10692 :: File "system.py", line 138, in __pack_import
- 0330 21:46:10692 :: ImportError
- 0330 21:46:10692 :: :
- 0330 21:46:10692 :: No module named game
- 0330 21:46:10692 ::
-
hat leider beides nicht geholfen
-
hey
ich wollte ein save login interface (Bitte melden Sie sich an, um diesen Link zu sehen.) in Fliege V3 einbauen und stoße nun auf 2 Fehler, ich hoffe ihr könnt mir helfen
Info: der Save Button funktioniert und es wird auch was in den User Ordner im Client gespeichert und der Laden Button spuckt auch keinen fehler aus wenn ich diesen drücke
Wenn ich auf Auswählen drücke: der Auswählen Button ist im Code unter OnClickLoadInfoButton definiert.
Bitte melden Sie sich an, um diesen Anhang zu sehen.bekomme ich folgenden Fehlercode:
Code- 0327 22:01:37295 :: Traceback (most recent call last):
- 0327 22:01:37295 :: File "ui.py", line 1430, in CallEvent
- 0327 22:01:37295 :: File "ui.py", line 58, in __call__
- 0327 22:01:37295 :: File "ui.py", line 40, in __call__
- 0327 22:01:37296 :: File "introLogin.py", line 1403, in __OnClickLoadInfoButton
- 0327 22:01:37296 :: File "uiSelectCredentials.py", line 98, in Open
- 0327 22:01:37296 :: File "uiSelectCredentials.py", line 93, in Show
- 0327 22:01:37296 :: File "uiSelectCredentials.py", line 132, in __Load
- 0327 22:01:37296 :: AttributeError
- 0327 22:01:37296 :: :
- 0327 22:01:37296 :: 'module' object has no attribute 'IsARABIC'
- 0327 22:01:37296 ::
hier ist meine ui.py
Code- import app
- import ime
- import grp
- import snd
- import wndMgr
- import item
- import skill
- import localeInfo
- import dbg
- # MARK_BUG_FIX
- import guild
- # END_OF_MARK_BUG_FIX
- from _weakref import proxy
- BACKGROUND_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 1.0)
- DARK_COLOR = grp.GenerateColor(0.2, 0.2, 0.2, 1.0)
- BRIGHT_COLOR = grp.GenerateColor(0.7, 0.7, 0.7, 1.0)
- SELECT_COLOR = grp.GenerateColor(0.0, 0.0, 0.5, 0.3)
- WHITE_COLOR = grp.GenerateColor(1.0, 1.0, 1.0, 0.5)
- HALF_WHITE_COLOR = grp.GenerateColor(1.0, 1.0, 1.0, 0.2)
- createToolTipWindowDict = {}
- def RegisterCandidateWindowClass(codePage, candidateWindowClass):
- EditLine.candidateWindowClassDict[codePage]=candidateWindowClass
- def RegisterToolTipWindow(type, createToolTipWindow):
- createToolTipWindowDict[type]=createToolTipWindow
- app.SetDefaultFontName(localeInfo.UI_DEF_FONT)
- class __mem_func__:
- class __noarg_call__:
- def __init__(self, cls, obj, func):
- self.cls=cls
- self.obj=proxy(obj)
- self.func=proxy(func)
- def __call__(self, *arg):
- return self.func(self.obj)
- class __arg_call__:
- def __init__(self, cls, obj, func):
- self.cls=cls
- self.obj=proxy(obj)
- self.func=proxy(func)
- def __call__(self, *arg):
- return self.func(self.obj, *arg)
- def __init__(self, mfunc):
- if mfunc.im_func.func_code.co_argcount>1:
- self.call=__mem_func__.__arg_call__(mfunc.im_class, mfunc.im_self, mfunc.im_func)
- else:
- self.call=__mem_func__.__noarg_call__(mfunc.im_class, mfunc.im_self, mfunc.im_func)
- def __call__(self, *arg):
- return self.call(*arg)
- class Window(object):
- def NoneMethod(cls):
- pass
- NoneMethod = classmethod(NoneMethod)
- def __init__(self, layer = "UI"):
- self.hWnd = None
- self.parentWindow = 0
- self.onMouseLeftButtonUpEvent = None
- self.RegisterWindow(layer)
- self.Hide()
- self.onMouseLeftButtonUpEventArgs = None
- self.overFunc = None
- self.overArgs = None
- self.overOutFunc = None
- self.overOutArgs = None
- if app.ENABLE_TARGET_INFO:
- self.mouseLeftButtonDownEvent = None
- self.mouseLeftButtonDownArgs = None
- self.mouseLeftButtonUpEvent = None
- self.mouseLeftButtonUpArgs = None
- self.mouseLeftButtonDoubleClickEvent = None
- self.mouseRightButtonDownEvent = None
- self.mouseRightButtonDownArgs = None
- self.moveWindowEvent = None
- self.renderEvent = None
- self.renderArgs = None
- self.baseX = 0
- self.baseY = 0
- self.SetWindowName("NONAME_Window")
- def __del__(self):
- wndMgr.Destroy(self.hWnd)
- self.onMouseLeftButtonUpEventArgs = None
- self.overFunc = None
- self.overArgs = None
- self.overOutFunc = None
- self.overOutArgs = None
- def RegisterWindow(self, layer):
- self.hWnd = wndMgr.Register(self, layer)
- def Destroy(self):
- pass
- def GetWindowHandle(self):
- return self.hWnd
- def AddFlag(self, style):
- wndMgr.AddFlag(self.hWnd, style)
- def IsRTL(self):
- return wndMgr.IsRTL(self.hWnd)
- def SetWindowName(self, Name):
- wndMgr.SetName(self.hWnd, Name)
- def GetWindowName(self):
- return wndMgr.GetName(self.hWnd)
- if app.ENABLE_TARGET_INFO:
- def SetParent(self, parent):
- if parent:
- wndMgr.SetParent(self.hWnd, parent.hWnd)
- else:
- wndMgr.SetParent(self.hWnd, 0)
- def SetAttachParent(self, parent):
- wndMgr.SetAttachParent(self.hWnd, parent.hWnd)
- else:
- def SetParent(self, parent):
- wndMgr.SetParent(self.hWnd, parent.hWnd)
- def SetParentProxy(self, parent):
- self.parentWindow=proxy(parent)
- wndMgr.SetParent(self.hWnd, parent.hWnd)
- def GetParentProxy(self):
- return self.parentWindow
- def SetPickAlways(self):
- wndMgr.SetPickAlways(self.hWnd)
- def SetWindowHorizontalAlignLeft(self):
- wndMgr.SetWindowHorizontalAlign(self.hWnd, wndMgr.HORIZONTAL_ALIGN_LEFT)
- def SetWindowHorizontalAlignCenter(self):
- wndMgr.SetWindowHorizontalAlign(self.hWnd, wndMgr.HORIZONTAL_ALIGN_CENTER)
- def SetWindowHorizontalAlignRight(self):
- wndMgr.SetWindowHorizontalAlign(self.hWnd, wndMgr.HORIZONTAL_ALIGN_RIGHT)
- def SetWindowVerticalAlignTop(self):
- wndMgr.SetWindowVerticalAlign(self.hWnd, wndMgr.VERTICAL_ALIGN_TOP)
- def SetWindowVerticalAlignCenter(self):
- wndMgr.SetWindowVerticalAlign(self.hWnd, wndMgr.VERTICAL_ALIGN_CENTER)
- def SetWindowVerticalAlignBottom(self):
- wndMgr.SetWindowVerticalAlign(self.hWnd, wndMgr.VERTICAL_ALIGN_BOTTOM)
- def SetTop(self):
- wndMgr.SetTop(self.hWnd)
- def Show(self):
- wndMgr.Show(self.hWnd)
- def Hide(self):
- wndMgr.Hide(self.hWnd)
- if app.ENABLE_TARGET_INFO:
- def SetVisible(self, is_show):
- if is_show:
- self.Show()
- else:
- self.Hide()
- def Lock(self):
- wndMgr.Lock(self.hWnd)
- def Unlock(self):
- wndMgr.Unlock(self.hWnd)
- def IsShow(self):
- return wndMgr.IsShow(self.hWnd)
- def UpdateRect(self):
- wndMgr.UpdateRect(self.hWnd)
- def SetSize(self, width, height):
- wndMgr.SetWindowSize(self.hWnd, width, height)
- def GetWidth(self):
- return wndMgr.GetWindowWidth(self.hWnd)
- def GetHeight(self):
- return wndMgr.GetWindowHeight(self.hWnd)
- def GetLocalPosition(self):
- return wndMgr.GetWindowLocalPosition(self.hWnd)
- if app.ENABLE_TARGET_INFO:
- def GetLeft(self):
- x, y = self.GetLocalPosition()
- return x
- def GetGlobalLeft(self):
- x, y = self.GetGlobalPosition()
- return x
- def GetTop(self):
- x, y = self.GetLocalPosition()
- return y
- def GetGlobalTop(self):
- x, y = self.GetGlobalPosition()
- return y
- def GetRight(self):
- return self.GetLeft() + self.GetWidth()
- def GetBottom(self):
- return self.GetTop() + self.GetHeight()
- def GetGlobalPosition(self):
- return wndMgr.GetWindowGlobalPosition(self.hWnd)
- def GetMouseLocalPosition(self):
- return wndMgr.GetMouseLocalPosition(self.hWnd)
- def GetRect(self):
- return wndMgr.GetWindowRect(self.hWnd)
- if app.ENABLE_TARGET_INFO:
- def SetLeft(self, x):
- wndMgr.SetWindowPosition(self.hWnd, x, self.GetTop())
- def SetPosition(self, x, y):
- wndMgr.SetWindowPosition(self.hWnd, x, y)
- def SetCenterPosition(self, x = 0, y = 0):
- self.SetPosition((wndMgr.GetScreenWidth() - self.GetWidth()) / 2 + x, (wndMgr.GetScreenHeight() - self.GetHeight()) / 2 + y)
- if app.ENABLE_TARGET_INFO:
- def SavePosition(self):
- self.baseX = self.GetLeft()
- self.baseY = self.GetTop()
- def UpdatePositionByScale(self, scale):
- self.SetPosition(self.baseX * scale, self.baseY * scale)
- def IsFocus(self):
- return wndMgr.IsFocus(self.hWnd)
- def SetFocus(self):
- wndMgr.SetFocus(self.hWnd)
- def KillFocus(self):
- wndMgr.KillFocus(self.hWnd)
- def GetChildCount(self):
- return wndMgr.GetChildCount(self.hWnd)
- def IsIn(self):
- return wndMgr.IsIn(self.hWnd)
- if app.ENABLE_TARGET_INFO:
- def IsInPosition(self):
- xMouse, yMouse = wndMgr.GetMousePosition()
- x, y = self.GetGlobalPosition()
- return xMouse >= x and xMouse < x + self.GetWidth() and yMouse >= y and yMouse < y + self.GetHeight()
- def SetMouseLeftButtonDownEvent(self, event, *args):
- self.mouseLeftButtonDownEvent = event
- self.mouseLeftButtonDownArgs = args
- def OnMouseLeftButtonDown(self):
- if self.mouseLeftButtonDownEvent:
- apply(self.mouseLeftButtonDownEvent, self.mouseLeftButtonDownArgs)
- if app.ENABLE_TARGET_INFO:
- def SetMouseLeftButtonUpEvent(self, event, *args):
- self.mouseLeftButtonUpEvent = event
- self.mouseLeftButtonUpArgs = args
- else:
- def SetOnMouseLeftButtonUpEvent(self, event):
- self.onMouseLeftButtonUpEvent = event
- if app.ENABLE_TARGET_INFO:
- def SetMouseLeftButtonDoubleClickEvent(self, event):
- self.mouseLeftButtonDoubleClickEvent = event
- def OnMouseLeftButtonDoubleClick(self):
- if self.mouseLeftButtonDoubleClickEvent:
- self.mouseLeftButtonDoubleClickEvent()
- def SetMouseRightButtonDownEvent(self, event, *args):
- self.mouseRightButtonDownEvent = event
- self.mouseRightButtonDownArgs = args
- def OnMouseRightButtonDown(self):
- if self.mouseRightButtonDownEvent:
- apply(self.mouseRightButtonDownEvent, self.mouseRightButtonDownArgs)
- def SetMoveWindowEvent(self, event):
- self.moveWindowEvent = event
- def OnMoveWindow(self, x, y):
- if self.moveWindowEvent:
- self.moveWindowEvent(x, y)
- def SAFE_SetOverInEvent(self, func, *args):
- self.overFunc = __mem_func__(func)
- self.overArgs = args
- def SetOverInEvent(self, func, *args):
- self.overFunc = func
- self.overArgs = args
- def SAFE_SetOverOutEvent(self, func, *args):
- self.overOutFunc = __mem_func__(func)
- self.overOutArgs = args
- def SetOverOutEvent(self, func, *args):
- self.overOutFunc = func
- self.overOutArgs = args
- def SAFE_SetRenderEvent(self, event, *args):
- self.renderEvent = __mem_func__(event)
- self.renderArgs = args
- def ClearRenderEvent(self):
- self.renderEvent = None
- self.renderArgs = None
- def OnRender(self):
- if self.renderEvent:
- apply(self.renderEvent, self.renderArgs)
- def OnMouseLeftButtonUp(self):
- if self.onMouseLeftButtonUpEvent:
- self.onMouseLeftButtonUpEvent()
- def OnMouseWheel(self, nLen):
- pass
- def OnMouseOverIn(self):
- if self.overFunc:
- apply(self.overFunc, self.overArgs )
- def OnMouseOverOut(self):
- if self.overOutFunc:
- apply(self.overOutFunc, self.overOutArgs )
- def SetOverEvent(self, func, *args):
- self.overFunc = func
- self.overArgs = args
- def SetOverOutEvent(self, func, *args):
- self.overOutFunc = func
- self.overOutArgs = args
- class ListBoxEx(Window):
- class Item(Window):
- def __init__(self):
- Window.__init__(self)
- def __del__(self):
- Window.__del__(self)
- def SetParent(self, parent):
- Window.SetParent(self, parent)
- self.parent=proxy(parent)
- def OnMouseLeftButtonDown(self):
- self.parent.SelectItem(self)
- def OnRender(self):
- if self.parent.GetSelectedItem()==self:
- self.OnSelectedRender()
- def OnSelectedRender(self):
- x, y = self.GetGlobalPosition()
- grp.SetColor(grp.GenerateColor(0.0, 0.0, 0.7, 0.7))
- grp.RenderBar(x, y, self.GetWidth(), self.GetHeight())
- def __init__(self):
- Window.__init__(self)
- self.viewItemCount=10
- self.basePos=0
- self.itemHeight=16
- self.itemStep=20
- self.selItem=0
- self.itemList=[]
- self.onSelectItemEvent = lambda *arg: None
- self.itemWidth=100
- self.scrollBar=None
- self.__UpdateSize()
- def __del__(self):
- Window.__del__(self)
- def __UpdateSize(self):
- height=self.itemStep*self.__GetViewItemCount()
- self.SetSize(self.itemWidth, height)
- def IsEmpty(self):
- if len(self.itemList)==0:
- return 1
- return 0
- def SetItemStep(self, itemStep):
- self.itemStep=itemStep
- self.__UpdateSize()
- def SetItemSize(self, itemWidth, itemHeight):
- self.itemWidth=itemWidth
- self.itemHeight=itemHeight
- self.__UpdateSize()
- def SetViewItemCount(self, viewItemCount):
- self.viewItemCount=viewItemCount
- def SetSelectEvent(self, event):
- self.onSelectItemEvent = event
- def SetBasePos(self, basePos):
- for oldItem in self.itemList[self.basePos:self.basePos+self.viewItemCount]:
- oldItem.Hide()
- self.basePos=basePos
- pos=basePos
- for newItem in self.itemList[self.basePos:self.basePos+self.viewItemCount]:
- (x, y)=self.GetItemViewCoord(pos, newItem.GetWidth())
- newItem.SetPosition(x, y)
- newItem.Show()
- pos+=1
- def GetItemIndex(self, argItem):
- return self.itemList.index(argItem)
- def GetSelectedItem(self):
- return self.selItem
- def SelectIndex(self, index):
- if index >= len(self.itemList) or index < 0:
- self.selItem = None
- return
- try:
- self.selItem=self.itemList[index]
- except:
- pass
- def SelectItem(self, selItem):
- self.selItem=selItem
- self.onSelectItemEvent(selItem)
- def RemoveAllItems(self):
- self.selItem=None
- self.itemList=[]
- if self.scrollBar:
- self.scrollBar.SetPos(0)
- def RemoveItem(self, delItem):
- if delItem==self.selItem:
- self.selItem=None
- self.itemList.remove(delItem)
- def AppendItem(self, newItem):
- newItem.SetParent(self)
- newItem.SetSize(self.itemWidth, self.itemHeight)
- newItem.OnMouseWheel = self.OnMouseWheel
- pos=len(self.itemList)
- if self.__IsInViewRange(pos):
- (x, y)=self.GetItemViewCoord(pos, newItem.GetWidth())
- newItem.SetPosition(x, y)
- newItem.Show()
- else:
- newItem.Hide()
- self.itemList.append(newItem)
- def OnMouseWheel(self, nLen):
- if self.scrollBar:
- self.scrollBar.OnMouseWheel(nLen)
- def SetScrollBar(self, scrollBar):
- scrollBar.SetScrollEvent(__mem_func__(self.__OnScroll))
- self.scrollBar=scrollBar
- def __OnScroll(self):
- self.SetBasePos(int(self.scrollBar.GetPos()*self.__GetScrollLen()))
- def __GetScrollLen(self):
- scrollLen=self.__GetItemCount()-self.__GetViewItemCount()
- if scrollLen<0:
- return 0
- return scrollLen
- def __GetViewItemCount(self):
- return self.viewItemCount
- def __GetItemCount(self):
- return len(self.itemList)
- def GetItemViewCoord(self, pos, itemWidth):
- return (0, (pos-self.basePos)*self.itemStep)
- def __IsInViewRange(self, pos):
- if pos<self.basePos:
- return 0
- if pos>=self.basePos+self.viewItemCount:
- return 0
- return 1
- if app.ENABLE_TARGET_INFO:
- class ListBoxExNew(Window):
- class Item(Window):
- def __init__(self):
- Window.__init__(self)
- self.realWidth = 0
- self.realHeight = 0
- self.removeTop = 0
- self.removeBottom = 0
- self.SetWindowName("NONAME_ListBoxExNew_Item")
- def __del__(self):
- Window.__del__(self)
- def SetParent(self, parent):
- Window.SetParent(self, parent)
- self.parent=proxy(parent)
- def SetSize(self, width, height):
- self.realWidth = width
- self.realHeight = height
- Window.SetSize(self, width, height)
- def SetRemoveTop(self, height):
- self.removeTop = height
- self.RefreshHeight()
- def SetRemoveBottom(self, height):
- self.removeBottom = height
- self.RefreshHeight()
- def SetCurrentHeight(self, height):
- Window.SetSize(self, self.GetWidth(), height)
- def GetCurrentHeight(self):
- return Window.GetHeight(self)
- def ResetCurrentHeight(self):
- self.removeTop = 0
- self.removeBottom = 0
- self.RefreshHeight()
- def RefreshHeight(self):
- self.SetCurrentHeight(self.GetHeight() - self.removeTop - self.removeBottom)
- def GetHeight(self):
- return self.realHeight
- def __init__(self, stepSize, viewSteps):
- Window.__init__(self)
- self.viewItemCount=10
- self.basePos=0
- self.baseIndex=0
- self.maxSteps=0
- self.viewSteps = viewSteps
- self.stepSize = stepSize
- self.itemList=[]
- self.scrollBar=None
- self.SetWindowName("NONAME_ListBoxEx")
- def __del__(self):
- Window.__del__(self)
- def IsEmpty(self):
- if len(self.itemList)==0:
- return 1
- return 0
- def __CheckBasePos(self, pos):
- self.viewItemCount = 0
- start_pos = pos
- height = 0
- while height < self.GetHeight():
- if pos >= len(self.itemList):
- return start_pos == 0
- height += self.itemList[pos].GetHeight()
- pos += 1
- self.viewItemCount += 1
- return height == self.GetHeight()
- def SetBasePos(self, basePos, forceRefresh = TRUE):
- if forceRefresh == FALSE and self.basePos == basePos:
- return
- for oldItem in self.itemList[self.baseIndex:self.baseIndex+self.viewItemCount]:
- oldItem.ResetCurrentHeight()
- oldItem.Hide()
- self.basePos=basePos
- baseIndex = 0
- while basePos > 0:
- basePos -= self.itemList[baseIndex].GetHeight() / self.stepSize
- if basePos < 0:
- self.itemList[baseIndex].SetRemoveTop(self.stepSize * abs(basePos))
- break
- baseIndex += 1
- self.baseIndex = baseIndex
- stepCount = 0
- self.viewItemCount = 0
- while baseIndex < len(self.itemList):
- stepCount += self.itemList[baseIndex].GetCurrentHeight() / self.stepSize
- self.viewItemCount += 1
- if stepCount > self.viewSteps:
- self.itemList[baseIndex].SetRemoveBottom(self.stepSize * (stepCount - self.viewSteps))
- break
- elif stepCount == self.viewSteps:
- break
- baseIndex += 1
- y = 0
- for newItem in self.itemList[self.baseIndex:self.baseIndex+self.viewItemCount]:
- newItem.SetPosition(0, y)
- newItem.Show()
- y += newItem.GetCurrentHeight()
- def GetItemIndex(self, argItem):
- return self.itemList.index(argItem)
- def GetSelectedItem(self):
- return self.selItem
- def GetSelectedItemIndex(self):
- return self.selItemIdx
- def RemoveAllItems(self):
- self.itemList=[]
- self.maxSteps=0
- if self.scrollBar:
- self.scrollBar.SetPos(0)
- def RemoveItem(self, delItem):
- self.maxSteps -= delItem.GetHeight() / self.stepSize
- self.itemList.remove(delItem)
- def AppendItem(self, newItem):
- if newItem.GetHeight() % self.stepSize != 0:
- import dbg
- dbg.TraceError("Invalid AppendItem height %d stepSize %d" % (newItem.GetHeight(), self.stepSize))
- return
- self.maxSteps += newItem.GetHeight() / self.stepSize
- newItem.SetParent(self)
- self.itemList.append(newItem)
- def SetScrollBar(self, scrollBar):
- scrollBar.SetScrollEvent(__mem_func__(self.__OnScroll))
- self.scrollBar=scrollBar
- def __OnScroll(self):
- self.SetBasePos(int(self.scrollBar.GetPos()*self.__GetScrollLen()), FALSE)
- def __GetScrollLen(self):
- scrollLen=self.maxSteps-self.viewSteps
- if scrollLen<0:
- return 0
- return scrollLen
- def __GetViewItemCount(self):
- return self.viewItemCount
- def __GetItemCount(self):
- return len(self.itemList)
- def GetViewItemCount(self):
- return self.viewItemCount
- def GetItemCount(self):
- return len(self.itemList)
- class CandidateListBox(ListBoxEx):
- HORIZONTAL_MODE = 0
- VERTICAL_MODE = 1
- class Item(ListBoxEx.Item):
- def __init__(self, text):
- ListBoxEx.Item.__init__(self)
- self.textBox=TextLine()
- self.textBox.SetParent(self)
- self.textBox.SetText(text)
- self.textBox.Show()
- def __del__(self):
- ListBoxEx.Item.__del__(self)
- def __init__(self, mode = HORIZONTAL_MODE):
- ListBoxEx.__init__(self)
- self.itemWidth=32
- self.itemHeight=32
- self.mode = mode
- def __del__(self):
- ListBoxEx.__del__(self)
- def SetMode(self, mode):
- self.mode = mode
- def AppendItem(self, newItem):
- ListBoxEx.AppendItem(self, newItem)
- def GetItemViewCoord(self, pos):
- if self.mode == self.HORIZONTAL_MODE:
- return ((pos-self.basePos)*self.itemStep, 0)
- elif self.mode == self.VERTICAL_MODE:
- return (0, (pos-self.basePos)*self.itemStep)
- class TextLine(Window):
- def __init__(self):
- Window.__init__(self)
- self.max = 0
- self.SetFontName(localeInfo.UI_DEF_FONT)
- def __del__(self):
- Window.__del__(self)
- def RegisterWindow(self, layer):
- self.hWnd = wndMgr.RegisterTextLine(self, layer)
- def SetMax(self, max):
- wndMgr.SetMax(self.hWnd, max)
- def SetLimitWidth(self, width):
- wndMgr.SetLimitWidth(self.hWnd, width)
- def SetMultiLine(self):
- wndMgr.SetMultiLine(self.hWnd, TRUE)
- def SetHorizontalAlignArabic(self):
- wndMgr.SetHorizontalAlign(self.hWnd, wndMgr.TEXT_HORIZONTAL_ALIGN_ARABIC)
- def SetHorizontalAlignLeft(self):
- wndMgr.SetHorizontalAlign(self.hWnd, wndMgr.TEXT_HORIZONTAL_ALIGN_LEFT)
- def SetHorizontalAlignRight(self):
- wndMgr.SetHorizontalAlign(self.hWnd, wndMgr.TEXT_HORIZONTAL_ALIGN_RIGHT)
- def SetHorizontalAlignCenter(self):
- wndMgr.SetHorizontalAlign(self.hWnd, wndMgr.TEXT_HORIZONTAL_ALIGN_CENTER)
- def SetVerticalAlignTop(self):
- wndMgr.SetVerticalAlign(self.hWnd, wndMgr.TEXT_VERTICAL_ALIGN_TOP)
- def SetVerticalAlignBottom(self):
- wndMgr.SetVerticalAlign(self.hWnd, wndMgr.TEXT_VERTICAL_ALIGN_BOTTOM)
- def SetVerticalAlignCenter(self):
- wndMgr.SetVerticalAlign(self.hWnd, wndMgr.TEXT_VERTICAL_ALIGN_CENTER)
- def SetSecret(self, Value=TRUE):
- wndMgr.SetSecret(self.hWnd, Value)
- def SetOutline(self, Value=TRUE):
- wndMgr.SetOutline(self.hWnd, Value)
- def SetFeather(self, value=TRUE):
- wndMgr.SetFeather(self.hWnd, value)
- def SetFontName(self, fontName):
- wndMgr.SetFontName(self.hWnd, fontName)
- def SetDefaultFontName(self):
- wndMgr.SetFontName(self.hWnd, localeInfo.UI_DEF_FONT)
- def SetFontColor(self, red, green, blue):
- wndMgr.SetFontColor(self.hWnd, red, green, blue)
- def SetPackedFontColor(self, color):
- wndMgr.SetFontColor(self.hWnd, color)
- def SetText(self, text):
- wndMgr.SetText(self.hWnd, text)
- def GetText(self):
- return wndMgr.GetText(self.hWnd)
- def GetTextSize(self):
- return wndMgr.GetTextSize(self.hWnd)
- class EmptyCandidateWindow(Window):
- def __init__(self):
- Window.__init__(self)
- def __del__(self):
- Window.__init__(self)
- def Load(self):
- pass
- def SetCandidatePosition(self, x, y, textCount):
- pass
- def Clear(self):
- pass
- def Append(self, text):
- pass
- def Refresh(self):
- pass
- def Select(self):
- pass
- class EditLine(TextLine):
- candidateWindowClassDict = {}
- def __init__(self):
- TextLine.__init__(self)
- self.eventReturn = Window.NoneMethod
- self.eventEscape = Window.NoneMethod
- self.eventTab = None
- self.numberMode = FALSE
- self.useIME = TRUE
- self.bCodePage = FALSE
- self.candidateWindowClass = None
- self.candidateWindow = None
- self.SetCodePage(app.GetDefaultCodePage())
- self.readingWnd = ReadingWnd()
- self.readingWnd.Hide()
- def __del__(self):
- TextLine.__del__(self)
- self.eventReturn = Window.NoneMethod
- self.eventEscape = Window.NoneMethod
- self.eventTab = None
- def SetCodePage(self, codePage):
- candidateWindowClass=EditLine.candidateWindowClassDict.get(codePage, EmptyCandidateWindow)
- self.__SetCandidateClass(candidateWindowClass)
- def __SetCandidateClass(self, candidateWindowClass):
- if self.candidateWindowClass==candidateWindowClass:
- return
- self.candidateWindowClass = candidateWindowClass
- self.candidateWindow = self.candidateWindowClass()
- self.candidateWindow.Load()
- self.candidateWindow.Hide()
- def RegisterWindow(self, layer):
- self.hWnd = wndMgr.RegisterTextLine(self, layer)
- def SAFE_SetReturnEvent(self, event):
- self.eventReturn = __mem_func__(event)
- def SetReturnEvent(self, event):
- self.eventReturn = event
- def SetEscapeEvent(self, event):
- self.eventEscape = event
- def SetTabEvent(self, event):
- self.eventTab = event
- def SetMax(self, max):
- self.max = max
- wndMgr.SetMax(self.hWnd, self.max)
- ime.SetMax(self.max)
- self.SetUserMax(self.max)
- def SetUserMax(self, max):
- self.userMax = max
- ime.SetUserMax(self.userMax)
- def SetNumberMode(self):
- self.numberMode = TRUE
- #def AddExceptKey(self, key):
- # ime.AddExceptKey(key)
- #def ClearExceptKey(self):
- # ime.ClearExceptKey()
- def SetIMEFlag(self, flag):
- self.useIME = flag
- def SetText(self, text):
- wndMgr.SetText(self.hWnd, text)
- if self.IsFocus():
- ime.SetText(text)
- def Enable(self):
- wndMgr.ShowCursor(self.hWnd)
- def Disable(self):
- wndMgr.HideCursor(self.hWnd)
- def SetEndPosition(self):
- ime.MoveEnd()
- def OnSetFocus(self):
- Text = self.GetText()
- ime.SetText(Text)
- ime.SetMax(self.max)
- ime.SetUserMax(self.userMax)
- ime.SetCursorPosition(-1)
- if self.numberMode:
- ime.SetNumberMode()
- else:
- ime.SetStringMode()
- ime.EnableCaptureInput()
- if self.useIME:
- ime.EnableIME()
- else:
- ime.DisableIME()
- wndMgr.ShowCursor(self.hWnd, TRUE)
- def OnKillFocus(self):
- self.SetText(ime.GetText(self.bCodePage))
- self.OnIMECloseCandidateList()
- self.OnIMECloseReadingWnd()
- ime.DisableIME()
- ime.DisableCaptureInput()
- wndMgr.HideCursor(self.hWnd)
- def OnIMEChangeCodePage(self):
- self.SetCodePage(ime.GetCodePage())
- def OnIMEOpenCandidateList(self):
- self.candidateWindow.Show()
- self.candidateWindow.Clear()
- self.candidateWindow.Refresh()
- gx, gy = self.GetGlobalPosition()
- self.candidateWindow.SetCandidatePosition(gx, gy, len(self.GetText()))
- return TRUE
- def OnIMECloseCandidateList(self):
- self.candidateWindow.Hide()
- return TRUE
- def OnIMEOpenReadingWnd(self):
- gx, gy = self.GetGlobalPosition()
- textlen = len(self.GetText())-2
- reading = ime.GetReading()
- readinglen = len(reading)
- self.readingWnd.SetReadingPosition( gx + textlen*6-24-readinglen*6, gy )
- self.readingWnd.SetText(reading)
- if ime.GetReadingError() == 0:
- self.readingWnd.SetTextColor(0xffffffff)
- else:
- self.readingWnd.SetTextColor(0xffff0000)
- self.readingWnd.SetSize(readinglen * 6 + 4, 19)
- self.readingWnd.Show()
- return TRUE
- def OnIMECloseReadingWnd(self):
- self.readingWnd.Hide()
- return TRUE
- def OnIMEUpdate(self):
- snd.PlaySound("sound/ui/type.wav")
- TextLine.SetText(self, ime.GetText(self.bCodePage))
- def OnIMETab(self):
- if self.eventTab:
- self.eventTab()
- return TRUE
- return FALSE
- def OnIMEReturn(self):
- snd.PlaySound("sound/ui/click.wav")
- self.eventReturn()
- return TRUE
- def OnPressEscapeKey(self):
- self.eventEscape()
- return TRUE
- def OnKeyDown(self, key):
- if app.DIK_F1 == key:
- return FALSE
- if app.DIK_F2 == key:
- return FALSE
- if app.DIK_F3 == key:
- return FALSE
- if app.DIK_F4 == key:
- return FALSE
- if app.DIK_LALT == key:
- return FALSE
- if app.DIK_SYSRQ == key:
- return FALSE
- if app.DIK_LCONTROL == key:
- return FALSE
- if app.DIK_V == key:
- if app.IsPressed(app.DIK_LCONTROL):
- ime.PasteTextFromClipBoard()
- return TRUE
- def OnKeyUp(self, key):
- if app.DIK_F1 == key:
- return FALSE
- if app.DIK_F2 == key:
- return FALSE
- if app.DIK_F3 == key:
- return FALSE
- if app.DIK_F4 == key:
- return FALSE
- if app.DIK_LALT == key:
- return FALSE
- if app.DIK_SYSRQ == key:
- return FALSE
- if app.DIK_LCONTROL == key:
- return FALSE
- return TRUE
- def OnIMEKeyDown(self, key):
- # Left
- if app.VK_LEFT == key:
- ime.MoveLeft()
- return TRUE
- # Right
- if app.VK_RIGHT == key:
- ime.MoveRight()
- return TRUE
- # Home
- if app.VK_HOME == key:
- ime.MoveHome()
- return TRUE
- # End
- if app.VK_END == key:
- ime.MoveEnd()
- return TRUE
- # Delete
- if app.VK_DELETE == key:
- ime.Delete()
- TextLine.SetText(self, ime.GetText(self.bCodePage))
- return TRUE
- return TRUE
- #def OnMouseLeftButtonDown(self):
- # self.SetFocus()
- def OnMouseLeftButtonDown(self):
- if FALSE == self.IsIn():
- return FALSE
- self.SetFocus()
- PixelPosition = wndMgr.GetCursorPosition(self.hWnd)
- ime.SetCursorPosition(PixelPosition)
- class MarkBox(Window):
- def __init__(self, layer = "UI"):
- Window.__init__(self, layer)
- def __del__(self):
- Window.__del__(self)
- def RegisterWindow(self, layer):
- self.hWnd = wndMgr.RegisterMarkBox(self, layer)
- def Load(self):
- wndMgr.MarkBox_Load(self.hWnd)
- def SetScale(self, scale):
- wndMgr.MarkBox_SetScale(self.hWnd, scale)
- def SetIndex(self, guildID):
- MarkID = guild.GuildIDToMarkID(guildID)
- wndMgr.MarkBox_SetImageFilename(self.hWnd, guild.GetMarkImageFilenameByMarkID(MarkID))
- wndMgr.MarkBox_SetIndex(self.hWnd, guild.GetMarkIndexByMarkID(MarkID))
- def SetAlpha(self, alpha):
- wndMgr.MarkBox_SetDiffuseColor(self.hWnd, 1.0, 1.0, 1.0, alpha)
- class ImageBox(Window):
- def __init__(self, layer = "UI"):
- Window.__init__(self, layer)
- self.eventDict={}
- self.eventFunc = {
- "MOUSE_LEFT_BUTTON_UP" : None,
- "MOUSE_LEFT_BUTTON_DOWN" : None,
- "MOUSE_RIGHT_BUTTON_UP" : None,
- "MOUSE_RIGHT_BUTTON_DOWN" : None,
- "MOUSE_OVER_IN" : None,
- "MOUSE_OVER_OUT" : None
- }
- self.eventArgs = {
- "MOUSE_LEFT_BUTTON_UP" : None,
- "MOUSE_LEFT_BUTTON_DOWN" : None,
- "MOUSE_RIGHT_BUTTON_UP" : None,
- "MOUSE_RIGHT_BUTTON_DOWN" : None,
- "MOUSE_OVER_IN" : None,
- "MOUSE_OVER_OUT" : None
- }
- def __del__(self):
- Window.__del__(self)
- self.eventFunc = None
- self.eventArgs = None
- def RegisterWindow(self, layer):
- self.hWnd = wndMgr.RegisterImageBox(self, layer)
- def LoadImage(self, imageName):
- self.name=imageName
- wndMgr.LoadImage(self.hWnd, imageName)
- if len(self.eventDict)!=0:
- print "LOAD IMAGE", self, self.eventDict
- def SetAlpha(self, alpha):
- wndMgr.SetDiffuseColor(self.hWnd, 1.0, 1.0, 1.0, alpha)
- def SetColor(self, r, g, b, a):
- wndMgr.SetDiffuseColor(self.hWnd, r, g, b, a)
- def GetWidth(self):
- return wndMgr.GetWidth(self.hWnd)
- def GetHeight(self):
- return wndMgr.GetHeight(self.hWnd)
- def SetEvent(self, func, *args) :
- result = self.eventFunc.has_key(args[0])
- if result :
- self.eventFunc[args[0]] = func
- self.eventArgs[args[0]] = args
- else :
- print "[ERROR] ui.py SetEvent, Can`t Find has_key : %s" % args[0]
- def SAFE_SetEvent(self, func, *args):
- result = self.eventFunc.has_key(args[0])
- if result :
- self.eventFunc[args[0]] = __mem_func__(func)
- self.eventArgs[args[0]] = args
- else :
- print "[ERROR] ui.py SAFE_SetEvent, Can`t Find has_key : %s" % args[0]
- def OnMouseLeftButtonUp(self):
- if self.eventFunc["MOUSE_LEFT_BUTTON_UP"] :
- apply(self.eventFunc["MOUSE_LEFT_BUTTON_UP"], self.eventArgs["MOUSE_LEFT_BUTTON_UP"])
- def OnMouseLeftButtonDown(self):
- if self.eventFunc["MOUSE_LEFT_BUTTON_DOWN"] :
- apply(self.eventFunc["MOUSE_LEFT_BUTTON_DOWN"], self.eventArgs["MOUSE_LEFT_BUTTON_DOWN"])
- def OnMouseRightButtonUp(self):
- if self.eventFunc["MOUSE_RIGHT_BUTTON_UP"] :
- apply(self.eventFunc["MOUSE_RIGHT_BUTTON_UP"], self.eventArgs["MOUSE_RIGHT_BUTTON_UP"])
- def OnMouseRightButtonDown(self):
- if self.eventFunc["MOUSE_RIGHT_BUTTON_DOWN"] :
- apply(self.eventFunc["MOUSE_RIGHT_BUTTON_DOWN"], self.eventArgs["MOUSE_RIGHT_BUTTON_DOWN"])
- # def OnMouseOverIn(self) :
- # if self.eventFunc["MOUSE_OVER_IN"] :
- # apply(self.eventFunc["MOUSE_OVER_IN"], self.eventArgs["MOUSE_OVER_IN"])
- # def OnMouseOverOut(self) :
- # if self.eventFunc["MOUSE_OVER_OUT"] :
- # apply(self.eventFunc["MOUSE_OVER_OUT"], self.eventArgs["MOUSE_OVER_OUT"])
- # def SAFE_SetStringEvent(self, event, func,isa=FALSE):
- # if not isa:
- # self.eventDict[event]=__mem_func__(func)
- # else:
- # self.eventDict[event]=func
- def OnMouseOverIn(self):
- try:
- args = self.eventArgs.get("MOUSE_OVER_IN", None)
- if not args:
- self.eventDict["MOUSE_OVER_IN"]()
- else:
- apply(self.eventDict["MOUSE_OVER_IN"], args)
- except KeyError:
- pass
- def OnMouseOverOut(self):
- try:
- args = self.eventArgs.get("MOUSE_OVER_OUT", None)
- if not args:
- self.eventDict["MOUSE_OVER_OUT"]()
- else:
- apply(self.eventDict["MOUSE_OVER_OUT"], args)
- except KeyError:
- pass
- def SAFE_SetStringEvent(self, event, func):
- self.eventDict[event]=__mem_func__(func)
- def SAFE_SetStringEvent(self, event, func, *args):
- self.eventDict[event] =__mem_func__(func)
- self.eventArgs[event] = args
- def SetOnMouseLeftButtonUpEvent(self, event, *args):
- self.eventFunc["MOUSE_LEFT_BUTTON_UP"] = event
- self.eventArgs["MOUSE_LEFT_BUTTON_UP"] = args
- class ExpandedImageBox(ImageBox):
- def __init__(self, layer = "UI"):
- ImageBox.__init__(self, layer)
- def __del__(self):
- ImageBox.__del__(self)
- def RegisterWindow(self, layer):
- self.hWnd = wndMgr.RegisterExpandedImageBox(self, layer)
- def SetScale(self, xScale, yScale):
- wndMgr.SetScale(self.hWnd, xScale, yScale)
- def SetOrigin(self, x, y):
- wndMgr.SetOrigin(self.hWnd, x, y)
- def SetRotation(self, rotation):
- wndMgr.SetRotation(self.hWnd, rotation)
- def SetRenderingMode(self, mode):
- wndMgr.SetRenderingMode(self.hWnd, mode)
- # [0.0, 1.0] 사이의 값만큼 퍼센트로 그리지 않는다.
- def SetRenderingRect(self, left, top, right, bottom):
- wndMgr.SetRenderingRect(self.hWnd, left, top, right, bottom)
- def SetPercentage(self, curValue, maxValue):
- if maxValue:
- self.SetRenderingRect(0.0, 0.0, -1.0 + float(curValue) / float(maxValue), 0.0)
- else:
- self.SetRenderingRect(0.0, 0.0, 0.0, 0.0)
- def GetWidth(self):
- return wndMgr.GetWindowWidth(self.hWnd)
- def GetHeight(self):
- return wndMgr.GetWindowHeight(self.hWnd)
- class AniImageBox(Window):
- def __init__(self, layer = "UI"):
- Window.__init__(self, layer)
- def __del__(self):
- Window.__del__(self)
- def RegisterWindow(self, layer):
- self.hWnd = wndMgr.RegisterAniImageBox(self, layer)
- def SetDelay(self, delay):
- wndMgr.SetDelay(self.hWnd, delay)
- def AppendImage(self, filename):
- wndMgr.AppendImage(self.hWnd, filename)
- def SetPercentage(self, curValue, maxValue):
- wndMgr.SetRenderingRect(self.hWnd, 0.0, 0.0, -1.0 + float(curValue) / float(maxValue), 0.0)
- def OnEndFrame(self):
- pass
- class Button(Window):
- def __init__(self, layer = "UI"):
- Window.__init__(self, layer)
- self.eventFunc = None
- self.eventArgs = None
- self.overFunc = None
- self.overArgs = None
- self.overOutFunc = None
- self.overOutArgs = None
- self.ButtonText = None
- self.ToolTipText = None
- def __del__(self):
- Window.__del__(self)
- self.eventFunc = None
- self.eventArgs = None
- self.overFunc = None
- self.overArgs = None
- self.overOutFunc = None
- self.overOutArgs = None
- def RegisterWindow(self, layer):
- self.hWnd = wndMgr.RegisterButton(self, layer)
- def SetUpVisual(self, filename):
- wndMgr.SetUpVisual(self.hWnd, filename)
- def SetOverVisual(self, filename):
- wndMgr.SetOverVisual(self.hWnd, filename)
- def SetDownVisual(self, filename):
- wndMgr.SetDownVisual(self.hWnd, filename)
- def SetDisableVisual(self, filename):
- wndMgr.SetDisableVisual(self.hWnd, filename)
- def GetUpVisualFileName(self):
- return wndMgr.GetUpVisualFileName(self.hWnd)
- def GetOverVisualFileName(self):
- return wndMgr.GetOverVisualFileName(self.hWnd)
- def GetDownVisualFileName(self):
- return wndMgr.GetDownVisualFileName(self.hWnd)
- def Flash(self):
- wndMgr.Flash(self.hWnd)
- def Enable(self):
- wndMgr.Enable(self.hWnd)
- def Disable(self):
- wndMgr.Disable(self.hWnd)
- def Down(self):
- wndMgr.Down(self.hWnd)
- def SetUp(self):
- wndMgr.SetUp(self.hWnd)
- def SAFE_SetEvent(self, func, *args):
- self.eventFunc = __mem_func__(func)
- self.eventArgs = args
- def SetEvent(self, func, *args):
- self.eventFunc = func
- self.eventArgs = args
- def SetTextColor(self, color):
- if not self.ButtonText:
- return
- self.ButtonText.SetPackedFontColor(color)
- def SetText(self, text, height = 4):
- if not self.ButtonText:
- textLine = TextLine()
- textLine.SetParent(self)
- textLine.SetPosition(self.GetWidth()/2, self.GetHeight()/2)
- textLine.SetVerticalAlignCenter()
- textLine.SetHorizontalAlignCenter()
- textLine.Show()
- self.ButtonText = textLine
- self.ButtonText.SetText(text)
- def SetFormToolTipText(self, type, text, x, y):
- if not self.ToolTipText:
- toolTip=createToolTipWindowDict[type]()
- toolTip.SetParent(self)
- toolTip.SetSize(0, 0)
- toolTip.SetHorizontalAlignCenter()
- toolTip.SetOutline()
- toolTip.Hide()
- toolTip.SetPosition(x + self.GetWidth()/2, y)
- self.ToolTipText=toolTip
- self.ToolTipText.SetText(text)
- def SetToolTipWindow(self, toolTip):
- self.ToolTipText=toolTip
- self.ToolTipText.SetParentProxy(self)
- def SetToolTipText(self, text, x=0, y = -19):
- self.SetFormToolTipText("TEXT", text, x, y)
- def SetToolTipText2(self, text):
- if len(text) > 16:
- x =-46
- y = 2
- else:
- x =-32
- y = 2
- self.SetFormToolTipText("TEXT", text, x, y)
- def CallEvent(self):
- snd.PlaySound("sound/ui/click.wav")
- if self.eventFunc:
- apply(self.eventFunc, self.eventArgs)
- def ShowToolTip(self):
- if self.ToolTipText:
- self.ToolTipText.Show()
- def HideToolTip(self):
- if self.ToolTipText:
- self.ToolTipText.Hide()
- def IsDown(self):
- return wndMgr.IsDown(self.hWnd)
- def OnMouseOverIn(self):
- if self.overFunc:
- apply(self.overFunc, self.overArgs )
- def OnMouseOverOut(self):
- if self.overOutFunc:
- apply(self.overOutFunc, self.overOutArgs )
- def SetOverEvent(self, func, *args):
- self.overFunc = func
- self.overArgs = args
- def SetOverOutEvent(self, func, *args):
- self.overOutFunc = func
- self.overOutArgs = args
- class RadioButton(Button):
- def __init__(self):
- Button.__init__(self)
- def __del__(self):
- Button.__del__(self)
- def RegisterWindow(self, layer):
- self.hWnd = wndMgr.RegisterRadioButton(self, layer)
- class RadioButtonGroup:
- def __init__(self):
- self.buttonGroup = []
- self.selectedBtnIdx = -1
- def __del__(self):
- for button, ue, de in self.buttonGroup:
- button.__del__()
- def Show(self):
- for (button, selectEvent, unselectEvent) in self.buttonGroup:
- button.Show()
- def Hide(self):
- for (button, selectEvent, unselectEvent) in self.buttonGroup:
- button.Hide()
- def SetText(self, idx, text):
- if idx >= len(self.buttonGroup):
- return
- (button, selectEvent, unselectEvent) = self.buttonGroup[idx]
- button.SetText(text)
- def OnClick(self, btnIdx):
- if btnIdx == self.selectedBtnIdx:
- return
- (button, selectEvent, unselectEvent) = self.buttonGroup[self.selectedBtnIdx]
- if unselectEvent:
- unselectEvent()
- button.SetUp()
- self.selectedBtnIdx = btnIdx
- (button, selectEvent, unselectEvent) = self.buttonGroup[btnIdx]
- if selectEvent:
- selectEvent()
- button.Down()
- def AddButton(self, button, selectEvent, unselectEvent):
- i = len(self.buttonGroup)
- button.SetEvent(lambda : self.OnClick(i))
- self.buttonGroup.append([button, selectEvent, unselectEvent])
- button.SetUp()
- def Create(rawButtonGroup):
- radioGroup = RadioButtonGroup()
- for (button, selectEvent, unselectEvent) in rawButtonGroup:
- radioGroup.AddButton(button, selectEvent, unselectEvent)
- radioGroup.OnClick(0)
- return radioGroup
- Create=staticmethod(Create)
- class ToggleButton(Button):
- def __init__(self):
- Button.__init__(self)
- self.eventUp = None
- self.eventDown = None
- def __del__(self):
- Button.__del__(self)
- self.eventUp = None
- self.eventDown = None
- def SetToggleUpEvent(self, event):
- self.eventUp = event
- def SetToggleDownEvent(self, event):
- self.eventDown = event
- def RegisterWindow(self, layer):
- self.hWnd = wndMgr.RegisterToggleButton(self, layer)
- def OnToggleUp(self):
- if self.eventUp:
- self.eventUp()
- def OnToggleDown(self):
- if self.eventDown:
- self.eventDown()
- class DragButton(Button):
- def __init__(self):
- Button.__init__(self)
- self.AddFlag("movable")
- self.callbackEnable = TRUE
- self.eventMove = lambda: None
- def __del__(self):
- Button.__del__(self)
- self.eventMove = lambda: None
- def RegisterWindow(self, layer):
- self.hWnd = wndMgr.RegisterDragButton(self, layer)
- def SetMoveEvent(self, event):
- self.eventMove = event
- def SetRestrictMovementArea(self, x, y, width, height):
- wndMgr.SetRestrictMovementArea(self.hWnd, x, y, width, height)
- def TurnOnCallBack(self):
- self.callbackEnable = TRUE
- def TurnOffCallBack(self):
- self.callbackEnable = FALSE
- def OnMove(self):
- if self.callbackEnable:
- self.eventMove()
- class NumberLine(Window):
- def __init__(self, layer = "UI"):
- Window.__init__(self, layer)
- def __del__(self):
- Window.__del__(self)
- def RegisterWindow(self, layer):
- self.hWnd = wndMgr.RegisterNumberLine(self, layer)
- def SetHorizontalAlignCenter(self):
- wndMgr.SetNumberHorizontalAlignCenter(self.hWnd)
- def SetHorizontalAlignRight(self):
- wndMgr.SetNumberHorizontalAlignRight(self.hWnd)
- def SetPath(self, path):
- wndMgr.SetPath(self.hWnd, path)
- def SetNumber(self, number):
- wndMgr.SetNumber(self.hWnd, number)
- class Box(Window):
- def RegisterWindow(self, layer):
- self.hWnd = wndMgr.RegisterBox(self, layer)
- def SetColor(self, color):
- wndMgr.SetColor(self.hWnd, color)
- class Bar(Window):
- def RegisterWindow(self, layer):
- self.hWnd = wndMgr.RegisterBar(self, layer)
- def SetColor(self, color):
- wndMgr.SetColor(self.hWnd, color)
- class Line(Window):
- def RegisterWindow(self, layer):
- self.hWnd = wndMgr.RegisterLine(self, layer)
- def SetColor(self, color):
- wndMgr.SetColor(self.hWnd, color)
- class SlotBar(Window):
- def __init__(self):
- Window.__init__(self)
- def RegisterWindow(self, layer):
- self.hWnd = wndMgr.RegisterBar3D(self, layer)
- ## Same with SlotBar
- class Bar3D(Window):
- def __init__(self):
- Window.__init__(self)
- def RegisterWindow(self, layer):
- self.hWnd = wndMgr.RegisterBar3D(self, layer)
- def SetColor(self, left, right, center):
- wndMgr.SetColor(self.hWnd, left, right, center)
- class SlotWindow(Window):
- def __init__(self):
- Window.__init__(self)
- self.StartIndex = 0
- self.eventSelectEmptySlot = None
- self.eventSelectItemSlot = None
- self.eventUnselectEmptySlot = None
- self.eventUnselectItemSlot = None
- self.eventUseSlot = None
- self.eventOverInItem = None
- self.eventOverOutItem = None
- self.eventPressedSlotButton = None
- def __del__(self):
- Window.__del__(self)
- self.eventSelectEmptySlot = None
- self.eventSelectItemSlot = None
- self.eventUnselectEmptySlot = None
- self.eventUnselectItemSlot = None
- self.eventUseSlot = None
- self.eventOverInItem = None
- self.eventOverOutItem = None
- self.eventPressedSlotButton = None
- def RegisterWindow(self, layer):
- self.hWnd = wndMgr.RegisterSlotWindow(self, layer)
- def SetSlotStyle(self, style):
- wndMgr.SetSlotStyle(self.hWnd, style)
- def HasSlot(self, slotIndex):
- return wndMgr.HasSlot(self.hWnd, slotIndex)
- def SetSlotBaseImage(self, imageFileName, r, g, b, a):
- wndMgr.SetSlotBaseImage(self.hWnd, imageFileName, r, g, b, a)
- def SetCoverButton(self,\
- slotIndex,\
- upName="d:/ymir work/ui/public/slot_cover_button_01.sub",\
- overName="d:/ymir work/ui/public/slot_cover_button_02.sub",\
- downName="d:/ymir work/ui/public/slot_cover_button_03.sub",\
- disableName="d:/ymir work/ui/public/slot_cover_button_04.sub",\
- LeftButtonEnable = FALSE,\
- RightButtonEnable = TRUE):
- wndMgr.SetCoverButton(self.hWnd, slotIndex, upName, overName, downName, disableName, LeftButtonEnable, RightButtonEnable)
- def EnableCoverButton(self, slotIndex):
- wndMgr.EnableCoverButton(self.hWnd, slotIndex)
- def DisableCoverButton(self, slotIndex):
- wndMgr.DisableCoverButton(self.hWnd, slotIndex)
- def SetAlwaysRenderCoverButton(self, slotIndex, bAlwaysRender = TRUE):
- wndMgr.SetAlwaysRenderCoverButton(self.hWnd, slotIndex, bAlwaysRender)
- def AppendSlotButton(self, upName, overName, downName):
- wndMgr.AppendSlotButton(self.hWnd, upName, overName, downName)
- def ShowSlotButton(self, slotNumber):
- wndMgr.ShowSlotButton(self.hWnd, slotNumber)
- def HideAllSlotButton(self):
- wndMgr.HideAllSlotButton(self.hWnd)
- def AppendRequirementSignImage(self, filename):
- wndMgr.AppendRequirementSignImage(self.hWnd, filename)
- def ShowRequirementSign(self, slotNumber):
- wndMgr.ShowRequirementSign(self.hWnd, slotNumber)
- def HideRequirementSign(self, slotNumber):
- wndMgr.HideRequirementSign(self.hWnd, slotNumber)
- # def ActivateAcceSlot(self, slotNumber):
- # wndMgr.ActivateAcceSlot(self.hWnd, slotNumber)
- # def DeactivateAcceSlot(self, slotNumber):
- # wndMgr.DeactivateAcceSlot(self.hWnd, slotNumber)
- def ActivateSlot(self, slotNumber, r = 1.0, g = 1.0, b = 1.0, a = 1.0):
- wndMgr.ActivateSlot(self.hWnd, slotNumber, r, g, b, a)
- def DeactivateSlot(self, slotNumber):
- wndMgr.DeactivateSlot(self.hWnd, slotNumber)
- def ShowSlotBaseImage(self, slotNumber):
- wndMgr.ShowSlotBaseImage(self.hWnd, slotNumber)
- def HideSlotBaseImage(self, slotNumber):
- wndMgr.HideSlotBaseImage(self.hWnd, slotNumber)
- def SAFE_SetButtonEvent(self, button, state, event):
- if "LEFT"==button:
- if "EMPTY"==state:
- self.eventSelectEmptySlot=__mem_func__(event)
- elif "EXIST"==state:
- self.eventSelectItemSlot=__mem_func__(event)
- elif "ALWAYS"==state:
- self.eventSelectEmptySlot=__mem_func__(event)
- self.eventSelectItemSlot=__mem_func__(event)
- elif "RIGHT"==button:
- if "EMPTY"==state:
- self.eventUnselectEmptySlot=__mem_func__(event)
- elif "EXIST"==state:
- self.eventUnselectItemSlot=__mem_func__(event)
- elif "ALWAYS"==state:
- self.eventUnselectEmptySlot=__mem_func__(event)
- self.eventUnselectItemSlot=__mem_func__(event)
- def SetSelectEmptySlotEvent(self, empty):
- self.eventSelectEmptySlot = empty
- def SetSelectItemSlotEvent(self, item):
- self.eventSelectItemSlot = item
- def SetUnselectEmptySlotEvent(self, empty):
- self.eventUnselectEmptySlot = empty
- def SetUnselectItemSlotEvent(self, item):
- self.eventUnselectItemSlot = item
- def SetUseSlotEvent(self, use):
- self.eventUseSlot = use
- def SetOverInItemEvent(self, event):
- self.eventOverInItem = event
- def SetOverOutItemEvent(self, event):
- self.eventOverOutItem = event
- def SetPressedSlotButtonEvent(self, event):
- self.eventPressedSlotButton = event
- def GetSlotCount(self):
- return wndMgr.GetSlotCount(self.hWnd)
- def SetUseMode(self, flag):
- "TRUE일때만 ItemToItem 이 가능한지 보여준다"
- wndMgr.SetUseMode(self.hWnd, flag)
- def SetUsableItem(self, flag):
- "TRUE면 현재 가리킨 아이템이 ItemToItem 적용 가능하다"
- wndMgr.SetUsableItem(self.hWnd, flag)
- def SetSlotCoolTime(self, slotIndex, coolTime, elapsedTime = 0.0):
- wndMgr.SetSlotCoolTime(self.hWnd, slotIndex, coolTime, elapsedTime)
- def StoreSlotCoolTime(self, key, slotIndex, coolTime, elapsedTime = 0.0):
- wndMgr.StoreSlotCoolTime(self.hWnd, key, slotIndex, coolTime, elapsedTime)
- def RestoreSlotCoolTime(self, key):
- wndMgr.RestoreSlotCoolTime(self.hWnd, key)
- def DisableSlot(self, slotIndex):
- wndMgr.DisableSlot(self.hWnd, slotIndex)
- def EnableSlot(self, slotIndex):
- wndMgr.EnableSlot(self.hWnd, slotIndex)
- def LockSlot(self, slotIndex):
- wndMgr.LockSlot(self.hWnd, slotIndex)
- def UnlockSlot(self, slotIndex):
- wndMgr.UnlockSlot(self.hWnd, slotIndex)
- def RefreshSlot(self):
- wndMgr.RefreshSlot(self.hWnd)
- def ClearSlot(self, slotNumber):
- wndMgr.ClearSlot(self.hWnd, slotNumber)
- def ClearAllSlot(self):
- wndMgr.ClearAllSlot(self.hWnd)
- def AppendSlot(self, index, x, y, width, height):
- wndMgr.AppendSlot(self.hWnd, index, x, y, width, height)
- def SetSlot(self, slotIndex, itemIndex, width, height, icon, diffuseColor = (1.0, 1.0, 1.0, 1.0)):
- wndMgr.SetSlot(self.hWnd, slotIndex, itemIndex, width, height, icon, diffuseColor)
- def SetSlotCount(self, slotNumber, count):
- wndMgr.SetSlotCount(self.hWnd, slotNumber, count)
- def SetSlotCountNew(self, slotNumber, grade, count):
- wndMgr.SetSlotCountNew(self.hWnd, slotNumber, grade, count)
- def SetItemSlot(self, renderingSlotNumber, ItemIndex, ItemCount = 0, diffuseColor = (1.0, 1.0, 1.0, 1.0)):
- if 0 == ItemIndex or None == ItemIndex:
- wndMgr.ClearSlot(self.hWnd, renderingSlotNumber)
- return
- item.SelectItem(ItemIndex)
- itemIcon = item.GetIconImage()
- item.SelectItem(ItemIndex)
- (width, height) = item.GetItemSize()
- wndMgr.SetSlot(self.hWnd, renderingSlotNumber, ItemIndex, width, height, itemIcon, diffuseColor)
- wndMgr.SetSlotCount(self.hWnd, renderingSlotNumber, ItemCount)
- def SetSkillSlot(self, renderingSlotNumber, skillIndex, skillLevel):
- skillIcon = skill.GetIconImage(skillIndex)
- if 0 == skillIcon:
- wndMgr.ClearSlot(self.hWnd, renderingSlotNumber)
- return
- wndMgr.SetSlot(self.hWnd, renderingSlotNumber, skillIndex, 1, 1, skillIcon)
- wndMgr.SetSlotCount(self.hWnd, renderingSlotNumber, skillLevel)
- def SetSkillSlotNew(self, renderingSlotNumber, skillIndex, skillGrade, skillLevel):
- skillIcon = skill.GetIconImageNew(skillIndex, skillGrade)
- if 0 == skillIcon:
- wndMgr.ClearSlot(self.hWnd, renderingSlotNumber)
- return
- wndMgr.SetSlot(self.hWnd, renderingSlotNumber, skillIndex, 1, 1, skillIcon)
- def SetEmotionSlot(self, renderingSlotNumber, emotionIndex):
- import player
- icon = player.GetEmotionIconImage(emotionIndex)
- if 0 == icon:
- wndMgr.ClearSlot(self.hWnd, renderingSlotNumber)
- return
- wndMgr.SetSlot(self.hWnd, renderingSlotNumber, emotionIndex, 1, 1, icon)
- ## Event
- def OnSelectEmptySlot(self, slotNumber):
- if self.eventSelectEmptySlot:
- self.eventSelectEmptySlot(slotNumber)
- def OnSelectItemSlot(self, slotNumber):
- if self.eventSelectItemSlot:
- self.eventSelectItemSlot(slotNumber)
- def OnUnselectEmptySlot(self, slotNumber):
- if self.eventUnselectEmptySlot:
- self.eventUnselectEmptySlot(slotNumber)
- def OnUnselectItemSlot(self, slotNumber):
- if self.eventUnselectItemSlot:
- self.eventUnselectItemSlot(slotNumber)
- def OnUseSlot(self, slotNumber):
- if self.eventUseSlot:
- self.eventUseSlot(slotNumber)
- def OnOverInItem(self, slotNumber):
- if self.eventOverInItem:
- self.eventOverInItem(slotNumber)
- def OnOverOutItem(self):
- if self.eventOverOutItem:
- self.eventOverOutItem()
- def OnPressedSlotButton(self, slotNumber):
- if self.eventPressedSlotButton:
- self.eventPressedSlotButton(slotNumber)
- def GetStartIndex(self):
- return 0
- class GridSlotWindow(SlotWindow):
- def __init__(self):
- SlotWindow.__init__(self)
- self.startIndex = 0
- def __del__(self):
- SlotWindow.__del__(self)
- def RegisterWindow(self, layer):
- self.hWnd = wndMgr.RegisterGridSlotWindow(self, layer)
- def ArrangeSlot(self, StartIndex, xCount, yCount, xSize, ySize, xBlank, yBlank):
- self.startIndex = StartIndex
- wndMgr.ArrangeSlot(self.hWnd, StartIndex, xCount, yCount, xSize, ySize, xBlank, yBlank)
- self.startIndex = StartIndex
- def GetStartIndex(self):
- return self.startIndex
- class TitleBar(Window):
- BLOCK_WIDTH = 32
- BLOCK_HEIGHT = 23
- def __init__(self):
- Window.__init__(self)
- self.AddFlag("attach")
- def __del__(self):
- Window.__del__(self)
- def MakeTitleBar(self, width, color):
- ## 현재 Color는 사용하고 있지 않음
- width = max(64, width)
- imgLeft = ImageBox()
- imgCenter = ExpandedImageBox()
- imgRight = ImageBox()
- imgLeft.AddFlag("not_pick")
- imgCenter.AddFlag("not_pick")
- imgRight.AddFlag("not_pick")
- imgLeft.SetParent(self)
- imgCenter.SetParent(self)
- imgRight.SetParent(self)
- imgLeft.LoadImage("d:/ymir work/ui/pattern/titlebar_left.tga")
- imgCenter.LoadImage("d:/ymir work/ui/pattern/titlebar_center.tga")
- imgRight.LoadImage("d:/ymir work/ui/pattern/titlebar_right.tga")
- imgLeft.Show()
- imgCenter.Show()
- imgRight.Show()
- btnClose = Button()
- btnClose.SetParent(self)
- btnClose.SetUpVisual("d:/ymir work/ui/public/close_button_01.sub")
- btnClose.SetOverVisual("d:/ymir work/ui/public/close_button_02.sub")
- btnClose.SetDownVisual("d:/ymir work/ui/public/close_button_03.sub")
- btnClose.SetToolTipText(localeInfo.UI_CLOSE, 0, -23)
- btnClose.Show()
- self.imgLeft = imgLeft
- self.imgCenter = imgCenter
- self.imgRight = imgRight
- self.btnClose = btnClose
- self.SetWidth(width)
- def SetWidth(self, width):
- self.imgCenter.SetRenderingRect(0.0, 0.0, float((width - self.BLOCK_WIDTH*2) - self.BLOCK_WIDTH) / self.BLOCK_WIDTH, 0.0)
- self.imgCenter.SetPosition(self.BLOCK_WIDTH, 0)
- self.imgRight.SetPosition(width - self.BLOCK_WIDTH, 0)
- self.btnClose.SetPosition(width - self.btnClose.GetWidth() - 3, 3)
- self.SetSize(width, self.BLOCK_HEIGHT)
- def SetCloseEvent(self, event):
- self.btnClose.SetEvent(event)
- def CloseButtonHide(self) :
- self.imgRight.LoadImage("d:/ymir work/ui/pattern/titlebar_right_02.tga")
- self.btnClose.Hide()
- class HorizontalBar(Window):
- BLOCK_WIDTH = 32
- BLOCK_HEIGHT = 17
- def __init__(self):
- Window.__init__(self)
- self.AddFlag("attach")
- def __del__(self):
- Window.__del__(self)
- def Create(self, width):
- width = max(96, width)
- imgLeft = ImageBox()
- imgLeft.SetParent(self)
- imgLeft.AddFlag("not_pick")
- imgLeft.LoadImage("d:/ymir work/ui/pattern/horizontalbar_left.tga")
- imgLeft.Show()
- imgCenter = ExpandedImageBox()
- imgCenter.SetParent(self)
- imgCenter.AddFlag("not_pick")
- imgCenter.LoadImage("d:/ymir work/ui/pattern/horizontalbar_center.tga")
- imgCenter.Show()
- imgRight = ImageBox()
- imgRight.SetParent(self)
- imgRight.AddFlag("not_pick")
- imgRight.LoadImage("d:/ymir work/ui/pattern/horizontalbar_right.tga")
- imgRight.Show()
- self.imgLeft = imgLeft
- self.imgCenter = imgCenter
- self.imgRight = imgRight
- self.SetWidth(width)
- def SetWidth(self, width):
- self.imgCenter.SetRenderingRect(0.0, 0.0, float((width - self.BLOCK_WIDTH*2) - self.BLOCK_WIDTH) / self.BLOCK_WIDTH, 0.0)
- self.imgCenter.SetPosition(self.BLOCK_WIDTH, 0)
- self.imgRight.SetPosition(width - self.BLOCK_WIDTH, 0)
- self.SetSize(width, self.BLOCK_HEIGHT)
- class Gauge(Window):
- SLOT_WIDTH = 16
- SLOT_HEIGHT = 7
- GAUGE_TEMPORARY_PLACE = 12
- GAUGE_WIDTH = 16
- def __init__(self):
- Window.__init__(self)
- self.width = 0
- def __del__(self):
- Window.__del__(self)
- def MakeGauge(self, width, color):
- self.width = max(48, width)
- imgSlotLeft = ImageBox()
- imgSlotLeft.SetParent(self)
- imgSlotLeft.LoadImage("d:/ymir work/ui/pattern/gauge_slot_left.tga")
- imgSlotLeft.Show()
- imgSlotRight = ImageBox()
- imgSlotRight.SetParent(self)
- imgSlotRight.LoadImage("d:/ymir work/ui/pattern/gauge_slot_right.tga")
- imgSlotRight.Show()
- imgSlotRight.SetPosition(width - self.SLOT_WIDTH, 0)
- imgSlotCenter = ExpandedImageBox()
- imgSlotCenter.SetParent(self)
- imgSlotCenter.LoadImage("d:/ymir work/ui/pattern/gauge_slot_center.tga")
- imgSlotCenter.Show()
- imgSlotCenter.SetRenderingRect(0.0, 0.0, float((width - self.SLOT_WIDTH*2) - self.SLOT_WIDTH) / self.SLOT_WIDTH, 0.0)
- imgSlotCenter.SetPosition(self.SLOT_WIDTH, 0)
- imgGauge = ExpandedImageBox()
- imgGauge.SetParent(self)
- imgGauge.LoadImage("d:/ymir work/ui/pattern/gauge_" + color + ".tga")
- imgGauge.Show()
- imgGauge.SetRenderingRect(0.0, 0.0, 0.0, 0.0)
- imgGauge.SetPosition(self.GAUGE_TEMPORARY_PLACE, 0)
- imgSlotLeft.AddFlag("attach")
- imgSlotCenter.AddFlag("attach")
- imgSlotRight.AddFlag("attach")
- self.imgLeft = imgSlotLeft
- self.imgCenter = imgSlotCenter
- self.imgRight = imgSlotRight
- self.imgGauge = imgGauge
- self.SetSize(width, self.SLOT_HEIGHT)
- def SetPercentage(self, curValue, maxValue):
- # PERCENTAGE_MAX_VALUE_ZERO_DIVISION_ERROR
- if maxValue > 0.0:
- percentage = min(1.0, float(curValue)/float(maxValue))
- else:
- percentage = 0.0
- # END_OF_PERCENTAGE_MAX_VALUE_ZERO_DIVISION_ERROR
- gaugeSize = -1.0 + float(self.width - self.GAUGE_TEMPORARY_PLACE*2) * percentage / self.GAUGE_WIDTH
- self.imgGauge.SetRenderingRect(0.0, 0.0, gaugeSize, 0.0)
- class Board(Window):
- CORNER_WIDTH = 32
- CORNER_HEIGHT = 32
- LINE_WIDTH = 128
- LINE_HEIGHT = 128
- LT = 0
- LB = 1
- RT = 2
- RB = 3
- L = 0
- R = 1
- T = 2
- B = 3
- def __init__(self):
- Window.__init__(self)
- self.MakeBoard("d:/ymir work/ui/pattern/Board_Corner_", "d:/ymir work/ui/pattern/Board_Line_")
- self.MakeBase()
- def MakeBoard(self, cornerPath, linePath):
- CornerFileNames = [ cornerPath+dir+".tga" for dir in ("LeftTop", "LeftBottom", "RightTop", "RightBottom", ) ]
- LineFileNames = [ linePath+dir+".tga" for dir in ("Left", "Right", "Top", "Bottom", ) ]
- """
- CornerFileNames = (
- "d:/ymir work/ui/pattern/Board_Corner_LeftTop.tga",
- "d:/ymir work/ui/pattern/Board_Corner_LeftBottom.tga",
- "d:/ymir work/ui/pattern/Board_Corner_RightTop.tga",
- "d:/ymir work/ui/pattern/Board_Corner_RightBottom.tga",
- )
- LineFileNames = (
- "d:/ymir work/ui/pattern/Board_Line_Left.tga",
- "d:/ymir work/ui/pattern/Board_Line_Right.tga",
- "d:/ymir work/ui/pattern/Board_Line_Top.tga",
- "d:/ymir work/ui/pattern/Board_Line_Bottom.tga",
- )
- """
- self.Corners = []
- for fileName in CornerFileNames:
- Corner = ExpandedImageBox()
- Corner.AddFlag("not_pick")
- Corner.LoadImage(fileName)
- Corner.SetParent(self)
- Corner.SetPosition(0, 0)
- Corner.Show()
- self.Corners.append(Corner)
- self.Lines = []
- for fileName in LineFileNames:
- Line = ExpandedImageBox()
- Line.AddFlag("not_pick")
- Line.LoadImage(fileName)
- Line.SetParent(self)
- Line.SetPosition(0, 0)
- Line.Show()
- self.Lines.append(Line)
- self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
- self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
- def MakeBase(self):
- self.Base = ExpandedImageBox()
- self.Base.AddFlag("not_pick")
- self.Base.LoadImage("d:/ymir work/ui/pattern/Board_Base.tga")
- self.Base.SetParent(self)
- self.Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
- self.Base.Show()
- def __del__(self):
- Window.__del__(self)
- def SetSize(self, width, height):
- width = max(self.CORNER_WIDTH*2, width)
- height = max(self.CORNER_HEIGHT*2, height)
- Window.SetSize(self, width, height)
- self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
- self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
- self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
- self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
- self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
- verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
- horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
- self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
- self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
- self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
- self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
- if self.Base:
- self.Base.SetRenderingRect(0, 0, horizontalShowingPercentage, verticalShowingPercentage)
- class BoardWithTitleBar(Board):
- def __init__(self):
- Board.__init__(self)
- titleBar = TitleBar()
- titleBar.SetParent(self)
- titleBar.MakeTitleBar(0, "red")
- titleBar.SetPosition(8, 7)
- titleBar.Show()
- titleName = TextLine()
- titleName.SetParent(titleBar)
- titleName.SetPosition(0, 4)
- titleName.SetWindowHorizontalAlignCenter()
- titleName.SetHorizontalAlignCenter()
- titleName.Show()
- self.titleBar = titleBar
- self.titleName = titleName
- self.SetCloseEvent(self.Hide)
- def __del__(self):
- Board.__del__(self)
- self.titleBar = None
- self.titleName = None
- def SetSize(self, width, height):
- self.titleBar.SetWidth(width - 15)
- #self.pickRestrictWindow.SetSize(width, height - 30)
- Board.SetSize(self, width, height)
- self.titleName.UpdateRect()
- def SetTitleColor(self, color):
- self.titleName.SetPackedFontColor(color)
- def SetTitleName(self, name):
- self.titleName.SetText(name)
- def SetCloseEvent(self, event):
- self.titleBar.SetCloseEvent(event)
- class BorderA(Board):
- CORNER_WIDTH = 16
- CORNER_HEIGHT = 16
- LINE_WIDTH = 16
- LINE_HEIGHT = 16
- BASE_PATH = "d:/ymir work/ui/pattern"
- IMAGES = {
- 'CORNER' : {
- 0 : "border_a_left_top",
- 1 : "border_a_left_bottom",
- 2 : "border_a_right_top",
- 3 : "border_a_right_bottom"
- },
- 'BAR' : {
- 0 : "border_a_left",
- 1 : "border_a_right",
- 2 : "border_a_top",
- 3 : "border_a_bottom"
- },
- 'FILL' : "border_a_center"
- }
- def __init__(self):
- Board.__init__(self)
- def __del__(self):
- Board.__del__(self)
- def SetSize(self, width, height):
- Board.SetSize(self, width, height)
- class ThinBoard(Window):
- CORNER_WIDTH = 16
- CORNER_HEIGHT = 16
- LINE_WIDTH = 16
- LINE_HEIGHT = 16
- BOARD_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 0.51)
- LT = 0
- LB = 1
- RT = 2
- RB = 3
- L = 0
- R = 1
- T = 2
- B = 3
- def __init__(self, layer = "UI"):
- Window.__init__(self, layer)
- CornerFileNames = [ "d:/ymir work/ui/pattern/ThinBoard_Corner_"+dir+".tga" for dir in ["LeftTop","LeftBottom","RightTop","RightBottom"] ]
- LineFileNames = [ "d:/ymir work/ui/pattern/ThinBoard_Line_"+dir+".tga" for dir in ["Left","Right","Top","Bottom"] ]
- self.Corners = []
- for fileName in CornerFileNames:
- Corner = ExpandedImageBox()
- Corner.AddFlag("attach")
- Corner.AddFlag("not_pick")
- Corner.LoadImage(fileName)
- Corner.SetParent(self)
- Corner.SetPosition(0, 0)
- Corner.Show()
- self.Corners.append(Corner)
- self.Lines = []
- for fileName in LineFileNames:
- Line = ExpandedImageBox()
- Line.AddFlag("attach")
- Line.AddFlag("not_pick")
- Line.LoadImage(fileName)
- Line.SetParent(self)
- Line.SetPosition(0, 0)
- Line.Show()
- self.Lines.append(Line)
- Base = Bar()
- Base.SetParent(self)
- Base.AddFlag("attach")
- Base.AddFlag("not_pick")
- Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
- Base.SetColor(self.BOARD_COLOR)
- Base.Show()
- self.Base = Base
- self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
- self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
- def __del__(self):
- Window.__del__(self)
- if app.ENABLE_TARGET_INFO:
- def ShowCorner(self, corner):
- self.Corners[corner].Show()
- self.SetSize(self.GetWidth(), self.GetHeight())
- def HideCorners(self, corner):
- self.Corners[corner].Hide()
- self.SetSize(self.GetWidth(), self.GetHeight())
- def ShowLine(self, line):
- self.Lines[line].Show()
- self.SetSize(self.GetWidth(), self.GetHeight())
- def HideLine(self, line):
- self.Lines[line].Hide()
- self.SetSize(self.GetWidth(), self.GetHeight())
- def SetSize(self, width, height):
- width = max(self.CORNER_WIDTH*2, width)
- height = max(self.CORNER_HEIGHT*2, height)
- Window.SetSize(self, width, height)
- self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
- self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
- self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
- self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
- self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
- verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
- horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
- self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
- self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
- self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
- self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
- self.Base.SetSize(width - self.CORNER_WIDTH*2, height - self.CORNER_HEIGHT*2)
- def ShowInternal(self):
- self.Base.Show()
- for wnd in self.Lines:
- wnd.Show()
- for wnd in self.Corners:
- wnd.Show()
- def HideInternal(self):
- self.Base.Hide()
- for wnd in self.Lines:
- wnd.Hide()
- for wnd in self.Corners:
- wnd.Hide()
- class ThinBoardGold(Window):
- CORNER_WIDTH = 16
- CORNER_HEIGHT = 16
- LINE_WIDTH = 16
- LINE_HEIGHT = 16
- LT = 0
- LB = 1
- RT = 2
- RB = 3
- L = 0
- R = 1
- T = 2
- B = 3
- def __init__(self, layer = "UI"):
- Window.__init__(self, layer)
- CornerFileNames = [ "d:/ymir work/ui/pattern/thinboardgold/ThinBoard_Corner_"+dir+"_Gold.tga" for dir in ["LeftTop","LeftBottom","RightTop","RightBottom"] ]
- LineFileNames = [ "d:/ymir work/ui/pattern/thinboardgold/ThinBoard_Line_"+dir+"_Gold.tga" for dir in ["Left","Right","Top","Bottom"] ]
- self.MakeBase()
- self.Corners = []
- for fileName in CornerFileNames:
- Corner = ExpandedImageBox()
- Corner.AddFlag("attach")
- Corner.AddFlag("not_pick")
- Corner.LoadImage(fileName)
- Corner.SetParent(self)
- Corner.SetPosition(0, 0)
- Corner.Show()
- self.Corners.append(Corner)
- self.Lines = []
- for fileName in LineFileNames:
- Line = ExpandedImageBox()
- Line.AddFlag("attach")
- Line.AddFlag("not_pick")
- Line.LoadImage(fileName)
- Line.SetParent(self)
- Line.SetPosition(0, 0)
- Line.Show()
- self.Lines.append(Line)
- self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
- self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
- def __del__(self):
- Window.__del__(self)
- def SetSize(self, width, height):
- width = max(self.CORNER_WIDTH*2, width)
- height = max(self.CORNER_HEIGHT*2, height)
- Window.SetSize(self, width, height)
- self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
- self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
- self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
- self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
- self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
- verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
- horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
- self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
- self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
- self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
- self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
- #self.Base.GetWidth()
- #self.Base.GetHeight()
- """
- Defalt Width : 128, Height : 128
- 0.0 > 128, 1.0 > 256
- """
- if self.Base:
- self.Base.SetRenderingRect(0, 0, (float(width)-32)/float(self.Base.GetWidth()) - 1.0, (float(height)-32)/float(self.Base.GetHeight()) - 1.0)
- def MakeBase(self):
- self.Base = ExpandedImageBox()
- self.Base.AddFlag("not_pick")
- self.Base.LoadImage("d:/ymir work/ui/pattern/Board_Base.tga")
- self.Base.SetParent(self)
- self.Base.SetPosition(16, 16)
- self.Base.SetAlpha(0.8)
- self.Base.Show()
- def ShowInternal(self):
- self.Base.Show()
- for wnd in self.Lines:
- wnd.Show()
- for wnd in self.Corners:
- wnd.Show()
- def HideInternal(self):
- self.Base.Hide()
- for wnd in self.Lines:
- wnd.Hide()
- for wnd in self.Corners:
- wnd.Hide()
- class ThinBoardCircle(Window):
- CORNER_WIDTH = 4
- CORNER_HEIGHT = 4
- LINE_WIDTH = 4
- LINE_HEIGHT = 4
- BOARD_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 1.0)
- LT = 0
- LB = 1
- RT = 2
- RB = 3
- L = 0
- R = 1
- T = 2
- B = 3
- def __init__(self, layer = "UI"):
- Window.__init__(self, layer)
- CornerFileNames = [ "d:/ymir work/ui/pattern/thinboardcircle/ThinBoard_Corner_"+dir+"_Circle.tga" for dir in ["LeftTop","LeftBottom","RightTop","RightBottom"] ]
- LineFileNames = [ "d:/ymir work/ui/pattern/thinboardcircle/ThinBoard_Line_"+dir+"_Circle.tga" for dir in ["Left","Right","Top","Bottom"] ]
- self.Corners = []
- for fileName in CornerFileNames:
- Corner = ExpandedImageBox()
- Corner.AddFlag("attach")
- Corner.AddFlag("not_pick")
- Corner.LoadImage(fileName)
- Corner.SetParent(self)
- Corner.SetPosition(0, 0)
- Corner.Show()
- self.Corners.append(Corner)
- self.Lines = []
- for fileName in LineFileNames:
- Line = ExpandedImageBox()
- Line.AddFlag("attach")
- Line.AddFlag("not_pick")
- Line.LoadImage(fileName)
- Line.SetParent(self)
- Line.SetPosition(0, 0)
- Line.Show()
- self.Lines.append(Line)
- Base = Bar()
- Base.SetParent(self)
- Base.AddFlag("attach")
- Base.AddFlag("not_pick")
- Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
- Base.SetColor(self.BOARD_COLOR)
- Base.Show()
- self.Base = Base
- self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
- self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
- def __del__(self):
- Window.__del__(self)
- def SetSize(self, width, height):
- width = max(self.CORNER_WIDTH*2, width)
- height = max(self.CORNER_HEIGHT*2, height)
- Window.SetSize(self, width, height)
- self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
- self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
- self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
- self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
- self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
- verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
- horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
- self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
- self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
- self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
- self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
- self.Base.SetSize(width - self.CORNER_WIDTH*2, height - self.CORNER_HEIGHT*2)
- def ShowInternal(self):
- self.Base.Show()
- for wnd in self.Lines:
- wnd.Show()
- for wnd in self.Corners:
- wnd.Show()
- def HideInternal(self):
- self.Base.Hide()
- for wnd in self.Lines:
- wnd.Hide()
- for wnd in self.Corners:
- wnd.Hide()
- class CheckBox(Window):
- def __init__(self):
- Window.__init__(self)
- self.backgroundImage = None
- self.checkImage = None
- self.eventFunc = { "ON_CHECK" : None, "ON_UNCKECK" : None, }
- self.eventArgs = { "ON_CHECK" : None, "ON_UNCKECK" : None, }
- self.CreateElements()
- def __del__(self):
- Window.__del__(self)
- self.backgroundImage = None
- self.checkImage = None
- self.eventFunc = { "ON_CHECK" : None, "ON_UNCKECK" : None, }
- self.eventArgs = { "ON_CHECK" : None, "ON_UNCKECK" : None, }
- def CreateElements(self):
- self.backgroundImage = ImageBox()
- self.backgroundImage.SetParent(self)
- self.backgroundImage.AddFlag("not_pick")
- self.backgroundImage.LoadImage("d:/ymir work/ui/game/refine/checkbox.tga")
- self.backgroundImage.Show()
- self.checkImage = ImageBox()
- self.checkImage.SetParent(self)
- self.checkImage.AddFlag("not_pick")
- self.checkImage.SetPosition(0, -4)
- self.checkImage.LoadImage("d:/ymir work/ui/game/refine/checked.tga")
- self.checkImage.Hide()
- self.textInfo = TextLine()
- self.textInfo.SetParent(self)
- self.textInfo.SetPosition(20, -2)
- self.textInfo.Show()
- self.SetSize(self.backgroundImage.GetWidth() + self.textInfo.GetTextSize()[0], self.backgroundImage.GetHeight() + self.textInfo.GetTextSize()[1])
- def SetTextInfo(self, info):
- if self.textInfo:
- self.textInfo.SetText(info)
- self.SetSize(self.backgroundImage.GetWidth() + self.textInfo.GetTextSize()[0], self.backgroundImage.GetHeight() + self.textInfo.GetTextSize()[1])
- def SetCheckStatus(self, flag):
- if flag:
- self.checkImage.Show()
- else:
- self.checkImage.Hide()
- def GetCheckStatus(self):
- if self.checkImage:
- return self.checkImage.IsShow()
- return False
- def SetEvent(self, func, *args) :
- result = self.eventFunc.has_key(args[0])
- if result :
- self.eventFunc[args[0]] = func
- self.eventArgs[args[0]] = args
- else :
- print "[ERROR] ui.py SetEvent, Can`t Find has_key : %s" % args[0]
- def OnMouseLeftButtonUp(self):
- if self.checkImage:
- if self.checkImage.IsShow():
- self.checkImage.Hide()
- if self.eventFunc["ON_UNCKECK"]:
- apply(self.eventFunc["ON_UNCKECK"], self.eventArgs["ON_UNCKECK"])
- else:
- self.checkImage.Show()
- if self.eventFunc["ON_CHECK"]:
- apply(self.eventFunc["ON_CHECK"], self.eventArgs["ON_CHECK"])
- class ThinBoardGold(Window):
- CORNER_WIDTH = 16
- CORNER_HEIGHT = 16
- LINE_WIDTH = 16
- LINE_HEIGHT = 16
- BOARD_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 0.51)
- LT = 0
- LB = 1
- RT = 2
- RB = 3
- L = 0
- R = 1
- T = 2
- B = 3
- def __init__(self, layer = "UI"):
- Window.__init__(self, layer)
- CornerFileNames = [ "d:/ymir work/ui/pattern/thinboardgold/ThinBoard_Corner_"+dir+".tga" for dir in ["LeftTop_gold", "LeftBottom_gold","RightTop_gold", "RightBottom_gold"]]
- LineFileNames = [ "d:/ymir work/ui/pattern/thinboardgold/ThinBoard_Line_"+dir+".tga" for dir in ["Left_gold", "Right_gold", "Top_gold", "Bottom_gold"]]
- self.Corners = []
- for fileName in CornerFileNames:
- Corner = ExpandedImageBox()
- Corner.AddFlag("attach")
- Corner.AddFlag("not_pick")
- Corner.LoadImage(fileName)
- Corner.SetParent(self)
- Corner.SetPosition(0, 0)
- Corner.Show()
- self.Corners.append(Corner)
- self.Lines = []
- for fileName in LineFileNames:
- Line = ExpandedImageBox()
- Line.AddFlag("attach")
- Line.AddFlag("not_pick")
- Line.LoadImage(fileName)
- Line.SetParent(self)
- Line.SetPosition(0, 0)
- Line.Show()
- self.Lines.append(Line)
- Base = ExpandedImageBox()
- Base.SetParent(self)
- Base.AddFlag("attach")
- Base.AddFlag("not_pick")
- Base.LoadImage("d:/ymir work/ui/pattern/thinboardgold/thinboard_bg_gold.tga")
- Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
- Base.Show()
- self.Base = Base
- self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
- self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
- def __del__(self):
- Window.__del__(self)
- def SetSize(self, width, height):
- width = max(self.CORNER_WIDTH*2, width)
- height = max(self.CORNER_HEIGHT*2, height)
- Window.SetSize(self, width, height)
- self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
- self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
- self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
- self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
- self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
- verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
- horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
- self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
- self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
- self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
- self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
- if self.Base:
- self.Base.SetRenderingRect(0, 0, horizontalShowingPercentage, verticalShowingPercentage)
- def ShowInternal(self):
- self.Base.Show()
- for wnd in self.Lines:
- wnd.Show()
- for wnd in self.Corners:
- wnd.Show()
- def HideInternal(self):
- self.Base.Hide()
- for wnd in self.Lines:
- wnd.Hide()
- for wnd in self.Corners:
- wnd.Hide()
- class ThinBoardCircle(Window):
- CORNER_WIDTH = 4
- CORNER_HEIGHT = 4
- LINE_WIDTH = 4
- LINE_HEIGHT = 4
- BOARD_COLOR = grp.GenerateColor(255.0, 255.0, 255.0, 1.0)
- LT = 0
- LB = 1
- RT = 2
- RB = 3
- L = 0
- R = 1
- T = 2
- B = 3
- def __init__(self, layer = "UI"):
- Window.__init__(self, layer)
- CornerFileNames = [ "d:/ymir work/ui/pattern/thinboardcircle/ThinBoard_Corner_"+dir+".tga" for dir in ["LeftTop_circle","LeftBottom_circle","RightTop_circle","RightBottom_circle"] ]
- LineFileNames = [ "d:/ymir work/ui/pattern/thinboardcircle/ThinBoard_Line_"+dir+".tga" for dir in ["Left_circle","Right_circle","Top_circle","Bottom_circle"] ]
- self.Corners = []
- for fileName in CornerFileNames:
- Corner = ExpandedImageBox()
- Corner.AddFlag("attach")
- Corner.AddFlag("not_pick")
- Corner.LoadImage(fileName)
- Corner.SetParent(self)
- Corner.SetPosition(0, 0)
- Corner.Show()
- self.Corners.append(Corner)
- self.Lines = []
- for fileName in LineFileNames:
- Line = ExpandedImageBox()
- Line.AddFlag("attach")
- Line.AddFlag("not_pick")
- Line.LoadImage(fileName)
- Line.SetParent(self)
- Line.SetPosition(0, 0)
- Line.Show()
- self.Lines.append(Line)
- Base = Bar()
- Base.SetParent(self)
- Base.AddFlag("attach")
- Base.AddFlag("not_pick")
- Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
- Base.SetColor(self.BOARD_COLOR)
- Base.Show()
- self.Base = Base
- self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
- self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
- def __del__(self):
- Window.__del__(self)
- def SetSize(self, width, height):
- width = max(self.CORNER_WIDTH*2, width)
- height = max(self.CORNER_HEIGHT*2, height)
- Window.SetSize(self, width, height)
- self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
- self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
- self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
- self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
- self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
- verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
- horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
- self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
- self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
- self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
- self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
- self.Base.SetSize(width - self.CORNER_WIDTH*2, height - self.CORNER_HEIGHT*2)
- def ShowInternal(self):
- self.Base.Show()
- for wnd in self.Lines:
- wnd.Show()
- for wnd in self.Corners:
- wnd.Show()
- def HideInternal(self):
- self.Base.Hide()
- for wnd in self.Lines:
- wnd.Hide()
- for wnd in self.Corners:
- wnd.Hide()
- class ScrollBar(Window):
- SCROLLBAR_WIDTH = 17
- SCROLLBAR_MIDDLE_HEIGHT = 9
- SCROLLBAR_BUTTON_WIDTH = 17
- SCROLLBAR_BUTTON_HEIGHT = 17
- MIDDLE_BAR_POS = 5
- MIDDLE_BAR_UPPER_PLACE = 3
- MIDDLE_BAR_DOWNER_PLACE = 4
- TEMP_SPACE = MIDDLE_BAR_UPPER_PLACE + MIDDLE_BAR_DOWNER_PLACE
- class MiddleBar(DragButton):
- def __init__(self):
- DragButton.__init__(self)
- self.AddFlag("movable")
- #self.AddFlag("restrict_x")
- def MakeImage(self):
- top = ImageBox()
- top.SetParent(self)
- top.LoadImage("d:/ymir work/ui/pattern/ScrollBar_Top.tga")
- top.SetPosition(0, 0)
- top.AddFlag("not_pick")
- top.Show()
- bottom = ImageBox()
- bottom.SetParent(self)
- bottom.LoadImage("d:/ymir work/ui/pattern/ScrollBar_Bottom.tga")
- bottom.AddFlag("not_pick")
- bottom.Show()
- middle = ExpandedImageBox()
- middle.SetParent(self)
- middle.LoadImage("d:/ymir work/ui/pattern/ScrollBar_Middle.tga")
- middle.SetPosition(0, 4)
- middle.AddFlag("not_pick")
- middle.Show()
- self.top = top
- self.bottom = bottom
- self.middle = middle
- def SetSize(self, height):
- height = max(12, height)
- DragButton.SetSize(self, 10, height)
- self.bottom.SetPosition(0, height-4)
- height -= 4*3
- self.middle.SetRenderingRect(0, 0, 0, float(height)/4.0)
- def __init__(self):
- Window.__init__(self)
- self.pageSize = 1
- self.curPos = 0.0
- self.eventScroll = lambda *arg: None
- self.lockFlag = FALSE
- self.scrollStep = 0.20
- self.CreateScrollBar()
- def __del__(self):
- Window.__del__(self)
- def CreateScrollBar(self):
- barSlot = Bar3D()
- barSlot.SetParent(self)
- barSlot.AddFlag("not_pick")
- barSlot.Show()
- middleBar = self.MiddleBar()
- middleBar.SetParent(self)
- middleBar.SetMoveEvent(__mem_func__(self.OnMove))
- middleBar.Show()
- middleBar.MakeImage()
- middleBar.SetSize(12)
- upButton = Button()
- upButton.SetParent(self)
- upButton.SetEvent(__mem_func__(self.OnUp))
- upButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_up_button_01.sub")
- upButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_up_button_02.sub")
- upButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_up_button_03.sub")
- upButton.Show()
- downButton = Button()
- downButton.SetParent(self)
- downButton.SetEvent(__mem_func__(self.OnDown))
- downButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_down_button_01.sub")
- downButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_down_button_02.sub")
- downButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_down_button_03.sub")
- downButton.Show()
- self.upButton = upButton
- self.downButton = downButton
- self.middleBar = middleBar
- self.barSlot = barSlot
- self.SCROLLBAR_WIDTH = self.upButton.GetWidth()
- self.SCROLLBAR_MIDDLE_HEIGHT = self.middleBar.GetHeight()
- self.SCROLLBAR_BUTTON_WIDTH = self.upButton.GetWidth()
- self.SCROLLBAR_BUTTON_HEIGHT = self.upButton.GetHeight()
- def Destroy(self):
- self.middleBar = None
- self.upButton = None
- self.downButton = None
- self.eventScroll = lambda *arg: None
- def SetScrollEvent(self, event):
- self.eventScroll = event
- def SetMiddleBarSize(self, pageScale):
- realHeight = self.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2
- self.SCROLLBAR_MIDDLE_HEIGHT = int(pageScale * float(realHeight))
- self.middleBar.SetSize(self.SCROLLBAR_MIDDLE_HEIGHT)
- self.pageSize = (self.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2) - self.SCROLLBAR_MIDDLE_HEIGHT - (self.TEMP_SPACE)
- def SetScrollBarSize(self, height):
- self.pageSize = (height - self.SCROLLBAR_BUTTON_HEIGHT*2) - self.SCROLLBAR_MIDDLE_HEIGHT - (self.TEMP_SPACE)
- self.SetSize(self.SCROLLBAR_WIDTH, height)
- self.upButton.SetPosition(0, 0)
- self.downButton.SetPosition(0, height - self.SCROLLBAR_BUTTON_HEIGHT)
- self.middleBar.SetRestrictMovementArea(self.MIDDLE_BAR_POS, self.SCROLLBAR_BUTTON_HEIGHT + self.MIDDLE_BAR_UPPER_PLACE, self.MIDDLE_BAR_POS+2, height - self.SCROLLBAR_BUTTON_HEIGHT*2 - self.TEMP_SPACE)
- self.middleBar.SetPosition(self.MIDDLE_BAR_POS, 0)
- self.UpdateBarSlot()
- def UpdateBarSlot(self):
- self.barSlot.SetPosition(0, self.SCROLLBAR_BUTTON_HEIGHT)
- self.barSlot.SetSize(self.GetWidth() - 2, self.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2 - 2)
- def GetPos(self):
- return self.curPos
- def SetPos(self, pos):
- pos = max(0.0, pos)
- pos = min(1.0, pos)
- newPos = float(self.pageSize) * pos
- self.middleBar.SetPosition(self.MIDDLE_BAR_POS, int(newPos) + self.SCROLLBAR_BUTTON_HEIGHT + self.MIDDLE_BAR_UPPER_PLACE)
- self.OnMove()
- def SetScrollStep(self, step):
- self.scrollStep = step
- def GetScrollStep(self):
- return self.scrollStep
- def OnMouseWheel(self, nLen):
- if nLen > 0:
- self.OnUp()
- else:
- self.OnDown()
- def OnUp(self):
- self.SetPos(self.curPos-self.scrollStep)
- def OnDown(self):
- self.SetPos(self.curPos+self.scrollStep)
- def OnMove(self):
- if self.lockFlag:
- return
- if 0 == self.pageSize:
- return
- (xLocal, yLocal) = self.middleBar.GetLocalPosition()
- self.curPos = float(yLocal - self.SCROLLBAR_BUTTON_HEIGHT - self.MIDDLE_BAR_UPPER_PLACE) / float(self.pageSize)
- self.eventScroll()
- def OnMouseLeftButtonDown(self):
- (xMouseLocalPosition, yMouseLocalPosition) = self.GetMouseLocalPosition()
- pickedPos = yMouseLocalPosition - self.SCROLLBAR_BUTTON_HEIGHT - self.SCROLLBAR_MIDDLE_HEIGHT/2
- newPos = float(pickedPos) / float(self.pageSize)
- self.SetPos(newPos)
- def LockScroll(self):
- self.lockFlag = TRUE
- def UnlockScroll(self):
- self.lockFlag = FALSE
- class ThinScrollBar(ScrollBar):
- def CreateScrollBar(self):
- middleBar = self.MiddleBar()
- middleBar.SetParent(self)
- middleBar.SetMoveEvent(__mem_func__(self.OnMove))
- middleBar.Show()
- middleBar.SetUpVisual("d:/ymir work/ui/public/scrollbar_thin_middle_button_01.sub")
- middleBar.SetOverVisual("d:/ymir work/ui/public/scrollbar_thin_middle_button_02.sub")
- middleBar.SetDownVisual("d:/ymir work/ui/public/scrollbar_thin_middle_button_03.sub")
- upButton = Button()
- upButton.SetParent(self)
- upButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_thin_up_button_01.sub")
- upButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_thin_up_button_02.sub")
- upButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_thin_up_button_03.sub")
- upButton.SetEvent(__mem_func__(self.OnUp))
- upButton.Show()
- downButton = Button()
- downButton.SetParent(self)
- downButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_thin_down_button_01.sub")
- downButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_thin_down_button_02.sub")
- downButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_thin_down_button_03.sub")
- downButton.SetEvent(__mem_func__(self.OnDown))
- downButton.Show()
- self.middleBar = middleBar
- self.upButton = upButton
- self.downButton = downButton
- self.SCROLLBAR_WIDTH = self.upButton.GetWidth()
- self.SCROLLBAR_MIDDLE_HEIGHT = self.middleBar.GetHeight()
- self.SCROLLBAR_BUTTON_WIDTH = self.upButton.GetWidth()
- self.SCROLLBAR_BUTTON_HEIGHT = self.upButton.GetHeight()
- self.MIDDLE_BAR_POS = 0
- self.MIDDLE_BAR_UPPER_PLACE = 0
- self.MIDDLE_BAR_DOWNER_PLACE = 0
- self.TEMP_SPACE = 0
- def UpdateBarSlot(self):
- pass
- class SmallThinScrollBar(ScrollBar):
- def CreateScrollBar(self):
- middleBar = self.MiddleBar()
- middleBar.SetParent(self)
- middleBar.SetMoveEvent(__mem_func__(self.OnMove))
- middleBar.Show()
- middleBar.SetUpVisual("d:/ymir work/ui/public/scrollbar_small_thin_middle_button_01.sub")
- middleBar.SetOverVisual("d:/ymir work/ui/public/scrollbar_small_thin_middle_button_01.sub")
- middleBar.SetDownVisual("d:/ymir work/ui/public/scrollbar_small_thin_middle_button_01.sub")
- upButton = Button()
- upButton.SetParent(self)
- upButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_small_thin_up_button_01.sub")
- upButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_small_thin_up_button_02.sub")
- upButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_small_thin_up_button_03.sub")
- upButton.SetEvent(__mem_func__(self.OnUp))
- upButton.Show()
- downButton = Button()
- downButton.SetParent(self)
- downButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_small_thin_down_button_01.sub")
- downButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_small_thin_down_button_02.sub")
- downButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_small_thin_down_button_03.sub")
- downButton.SetEvent(__mem_func__(self.OnDown))
- downButton.Show()
- self.middleBar = middleBar
- self.upButton = upButton
- self.downButton = downButton
- self.SCROLLBAR_WIDTH = self.upButton.GetWidth()
- self.SCROLLBAR_MIDDLE_HEIGHT = self.middleBar.GetHeight()
- self.SCROLLBAR_BUTTON_WIDTH = self.upButton.GetWidth()
- self.SCROLLBAR_BUTTON_HEIGHT = self.upButton.GetHeight()
- self.MIDDLE_BAR_POS = 0
- self.MIDDLE_BAR_UPPER_PLACE = 0
- self.MIDDLE_BAR_DOWNER_PLACE = 0
- self.TEMP_SPACE = 0
- def UpdateBarSlot(self):
- pass
- class SliderBar(Window):
- def __init__(self):
- Window.__init__(self)
- self.curPos = 1.0
- self.pageSize = 1.0
- self.eventChange = None
- self.__CreateBackGroundImage()
- self.__CreateCursor()
- def __del__(self):
- Window.__del__(self)
- def __CreateBackGroundImage(self):
- img = ImageBox()
- img.SetParent(self)
- img.LoadImage("d:/ymir work/ui/game/windows/sliderbar.sub")
- img.Show()
- self.backGroundImage = img
- ##
- self.SetSize(self.backGroundImage.GetWidth(), self.backGroundImage.GetHeight())
- def __CreateCursor(self):
- cursor = DragButton()
- cursor.AddFlag("movable")
- cursor.AddFlag("restrict_y")
- cursor.SetParent(self)
- cursor.SetMoveEvent(__mem_func__(self.__OnMove))
- cursor.SetUpVisual("d:/ymir work/ui/game/windows/sliderbar_cursor.sub")
- cursor.SetOverVisual("d:/ymir work/ui/game/windows/sliderbar_cursor.sub")
- cursor.SetDownVisual("d:/ymir work/ui/game/windows/sliderbar_cursor.sub")
- cursor.Show()
- self.cursor = cursor
- ##
- self.cursor.SetRestrictMovementArea(0, 0, self.backGroundImage.GetWidth(), 0)
- self.pageSize = self.backGroundImage.GetWidth() - self.cursor.GetWidth()
- def __OnMove(self):
- (xLocal, yLocal) = self.cursor.GetLocalPosition()
- self.curPos = float(xLocal) / float(self.pageSize)
- if self.eventChange:
- self.eventChange()
- def SetSliderPos(self, pos):
- self.curPos = pos
- self.cursor.SetPosition(int(self.pageSize * pos), 0)
- def GetSliderPos(self):
- return self.curPos
- def SetEvent(self, event):
- self.eventChange = event
- def Enable(self):
- self.cursor.Show()
- def Disable(self):
- self.cursor.Hide()
- class ListBox(Window):
- TEMPORARY_PLACE = 3
- def __init__(self, layer = "UI"):
- Window.__init__(self, layer)
- self.overLine = -1
- self.selectedLine = -1
- self.width = 0
- self.height = 0
- self.stepSize = 17
- self.basePos = 0
- self.showLineCount = 0
- self.itemCenterAlign = TRUE
- self.itemList = []
- self.keyDict = {}
- self.textDict = {}
- self.event = lambda *arg: None
- def __del__(self):
- Window.__del__(self)
- def SetWidth(self, width):
- self.SetSize(width, self.height)
- def SetSize(self, width, height):
- Window.SetSize(self, width, height)
- self.width = width
- self.height = height
- def SetTextCenterAlign(self, flag):
- self.itemCenterAlign = flag
- def SetBasePos(self, pos):
- self.basePos = pos
- self._LocateItem()
- def ClearItem(self):
- self.keyDict = {}
- self.textDict = {}
- self.itemList = []
- self.overLine = -1
- self.selectedLine = -1
- def InsertItem(self, number, text):
- self.keyDict[len(self.itemList)] = number
- self.textDict[len(self.itemList)] = text
- textLine = TextLine()
- textLine.SetParent(self)
- textLine.SetText(text)
- textLine.Show()
- if self.itemCenterAlign:
- textLine.SetWindowHorizontalAlignCenter()
- textLine.SetHorizontalAlignCenter()
- self.itemList.append(textLine)
- self._LocateItem()
- def ChangeItem(self, number, text):
- for key, value in self.keyDict.items():
- if value == number:
- self.textDict[key] = text
- if number < len(self.itemList):
- self.itemList[key].SetText(text)
- return
- def LocateItem(self):
- self._LocateItem()
- def _LocateItem(self):
- skipCount = self.basePos
- yPos = 0
- self.showLineCount = 0
- for textLine in self.itemList:
- textLine.Hide()
- if skipCount > 0:
- skipCount -= 1
- continue
- textLine.SetPosition(0, yPos + 3)
- yPos += self.stepSize
- if yPos <= self.GetHeight():
- self.showLineCount += 1
- textLine.Show()
- def ArrangeItem(self):
- self.SetSize(self.width, len(self.itemList) * self.stepSize)
- self._LocateItem()
- def GetViewItemCount(self):
- return int(self.GetHeight() / self.stepSize)
- def GetItemCount(self):
- return len(self.itemList)
- def SetEvent(self, event):
- self.event = event
- def SelectItem(self, line):
- if not self.keyDict.has_key(line):
- return
- if line == self.selectedLine:
- return
- self.selectedLine = line
- self.event(self.keyDict.get(line, 0), self.textDict.get(line, "None"))
- def GetSelectedItem(self):
- return self.keyDict.get(self.selectedLine, 0)
- def OnMouseLeftButtonDown(self):
- if self.overLine < 0:
- return
- def OnMouseLeftButtonUp(self):
- if self.overLine >= 0:
- self.SelectItem(self.overLine+self.basePos)
- def OnUpdate(self):
- self.overLine = -1
- if self.IsIn():
- x, y = self.GetGlobalPosition()
- height = self.GetHeight()
- xMouse, yMouse = wndMgr.GetMousePosition()
- if yMouse - y < height - 1:
- self.overLine = (yMouse - y) / self.stepSize
- if self.overLine < 0:
- self.overLine = -1
- if self.overLine >= len(self.itemList):
- self.overLine = -1
- def OnRender(self):
- xRender, yRender = self.GetGlobalPosition()
- yRender -= self.TEMPORARY_PLACE
- widthRender = self.width
- heightRender = self.height + self.TEMPORARY_PLACE*2
- if -1 != self.overLine:
- grp.SetColor(HALF_WHITE_COLOR)
- grp.RenderBar(xRender + 2, yRender + self.overLine*self.stepSize + 4, self.width - 3, self.stepSize)
- if -1 != self.selectedLine:
- if self.selectedLine >= self.basePos:
- if self.selectedLine - self.basePos < self.showLineCount:
- grp.SetColor(SELECT_COLOR)
- grp.RenderBar(xRender + 2, yRender + (self.selectedLine-self.basePos)*self.stepSize + 4, self.width - 3, self.stepSize)
- class ListBox2(ListBox):
- def __init__(self, *args, **kwargs):
- ListBox.__init__(self, *args, **kwargs)
- self.rowCount = 10
- self.barWidth = 0
- self.colCount = 0
- def SetRowCount(self, rowCount):
- self.rowCount = rowCount
- def SetSize(self, width, height):
- ListBox.SetSize(self, width, height)
- self._RefreshForm()
- def ClearItem(self):
- ListBox.ClearItem(self)
- self._RefreshForm()
- def InsertItem(self, *args, **kwargs):
- ListBox.InsertItem(self, *args, **kwargs)
- self._RefreshForm()
- def OnUpdate(self):
- mpos = wndMgr.GetMousePosition()
- self.overLine = self._CalcPointIndex(mpos)
- def OnRender(self):
- x, y = self.GetGlobalPosition()
- pos = (x + 2, y)
- if -1 != self.overLine:
- grp.SetColor(HALF_WHITE_COLOR)
- self._RenderBar(pos, self.overLine)
- if -1 != self.selectedLine:
- if self.selectedLine >= self.basePos:
- if self.selectedLine - self.basePos < self.showLineCount:
- grp.SetColor(SELECT_COLOR)
- self._RenderBar(pos, self.selectedLine-self.basePos)
- def _CalcPointIndex(self, mpos):
- if self.IsIn():
- px, py = mpos
- gx, gy = self.GetGlobalPosition()
- lx, ly = px - gx, py - gy
- col = lx / self.barWidth
- row = ly / self.stepSize
- idx = col * self.rowCount + row
- if col >= 0 and col < self.colCount:
- if row >= 0 and row < self.rowCount:
- if idx >= 0 and idx < len(self.itemList):
- return idx
- return -1
- def _CalcRenderPos(self, pos, idx):
- x, y = pos
- row = idx % self.rowCount
- col = idx / self.rowCount
- return (x + col * self.barWidth, y + row * self.stepSize)
- def _RenderBar(self, basePos, idx):
- x, y = self._CalcRenderPos(basePos, idx)
- grp.RenderBar(x, y, self.barWidth - 3, self.stepSize)
- def _LocateItem(self):
- pos = (0, self.TEMPORARY_PLACE)
- self.showLineCount = 0
- for textLine in self.itemList:
- x, y = self._CalcRenderPos(pos, self.showLineCount)
- textLine.SetPosition(x, y)
- textLine.Show()
- self.showLineCount += 1
- def _RefreshForm(self):
- if len(self.itemList) % self.rowCount:
- self.colCount = len(self.itemList) / self.rowCount + 1
- else:
- self.colCount = len(self.itemList) / self.rowCount
- if self.colCount:
- self.barWidth = self.width / self.colCount
- else:
- self.barWidth = self.width
- class ComboBox(Window):
- class ListBoxWithBoard(ListBox):
- def __init__(self, layer):
- ListBox.__init__(self, layer)
- def OnRender(self):
- xRender, yRender = self.GetGlobalPosition()
- yRender -= self.TEMPORARY_PLACE
- widthRender = self.width
- heightRender = self.height + self.TEMPORARY_PLACE*2
- grp.SetColor(BACKGROUND_COLOR)
- grp.RenderBar(xRender, yRender, widthRender, heightRender)
- grp.SetColor(DARK_COLOR)
- grp.RenderLine(xRender, yRender, widthRender, 0)
- grp.RenderLine(xRender, yRender, 0, heightRender)
- grp.SetColor(BRIGHT_COLOR)
- grp.RenderLine(xRender, yRender+heightRender, widthRender, 0)
- grp.RenderLine(xRender+widthRender, yRender, 0, heightRender)
- ListBox.OnRender(self)
- def __init__(self):
- Window.__init__(self)
- self.x = 0
- self.y = 0
- self.width = 0
- self.height = 0
- self.isSelected = FALSE
- self.isOver = FALSE
- self.isListOpened = FALSE
- self.event = lambda *arg: None
- self.enable = TRUE
- self.textLine = MakeTextLine(self)
- self.textLine.SetText(localeInfo.UI_ITEM)
- self.listBox = self.ListBoxWithBoard("TOP_MOST")
- self.listBox.SetPickAlways()
- self.listBox.SetParent(self)
- self.listBox.SetEvent(__mem_func__(self.OnSelectItem))
- self.listBox.Hide()
- def __del__(self):
- Window.__del__(self)
- def Destroy(self):
- self.textLine = None
- self.listBox = None
- def SetPosition(self, x, y):
- Window.SetPosition(self, x, y)
- self.x = x
- self.y = y
- self.__ArrangeListBox()
- def SetSize(self, width, height):
- Window.SetSize(self, width, height)
- self.width = width
- self.height = height
- self.textLine.UpdateRect()
- self.__ArrangeListBox()
- def __ArrangeListBox(self):
- self.listBox.SetPosition(0, self.height + 5)
- self.listBox.SetWidth(self.width)
- def Enable(self):
- self.enable = TRUE
- def Disable(self):
- self.enable = FALSE
- self.textLine.SetText("")
- self.CloseListBox()
- def SetEvent(self, event):
- self.event = event
- def ClearItem(self):
- self.CloseListBox()
- self.listBox.ClearItem()
- def InsertItem(self, index, name):
- self.listBox.InsertItem(index, name)
- self.listBox.ArrangeItem()
- def SetCurrentItem(self, text):
- self.textLine.SetText(text)
- def SelectItem(self, key):
- self.listBox.SelectItem(key)
- def OnSelectItem(self, index, name):
- self.CloseListBox()
- self.event(index)
- def CloseListBox(self):
- self.isListOpened = FALSE
- self.listBox.Hide()
- def OnMouseLeftButtonDown(self):
- if not self.enable:
- return
- self.isSelected = TRUE
- def OnMouseLeftButtonUp(self):
- if not self.enable:
- return
- self.isSelected = FALSE
- if self.isListOpened:
- self.CloseListBox()
- else:
- if self.listBox.GetItemCount() > 0:
- self.isListOpened = TRUE
- self.listBox.Show()
- self.__ArrangeListBox()
- def OnUpdate(self):
- if not self.enable:
- return
- if self.IsIn():
- self.isOver = TRUE
- else:
- self.isOver = FALSE
- def OnRender(self):
- self.x, self.y = self.GetGlobalPosition()
- xRender = self.x
- yRender = self.y
- widthRender = self.width
- heightRender = self.height
- grp.SetColor(BACKGROUND_COLOR)
- grp.RenderBar(xRender, yRender, widthRender, heightRender)
- grp.SetColor(DARK_COLOR)
- grp.RenderLine(xRender, yRender, widthRender, 0)
- grp.RenderLine(xRender, yRender, 0, heightRender)
- grp.SetColor(BRIGHT_COLOR)
- grp.RenderLine(xRender, yRender+heightRender, widthRender, 0)
- grp.RenderLine(xRender+widthRender, yRender, 0, heightRender)
- if self.isOver:
- grp.SetColor(HALF_WHITE_COLOR)
- grp.RenderBar(xRender + 2, yRender + 3, self.width - 3, heightRender - 5)
- if self.isSelected:
- grp.SetColor(WHITE_COLOR)
- grp.RenderBar(xRender + 2, yRender + 3, self.width - 3, heightRender - 5)
- class ScriptWindow(Window):
- def __init__(self, layer = "UI"):
- Window.__init__(self, layer)
- self.Children = []
- self.ElementDictionary = {}
- def __del__(self):
- Window.__del__(self)
- def ClearDictionary(self):
- self.Children = []
- self.ElementDictionary = {}
- def InsertChild(self, name, child):
- self.ElementDictionary[name] = child
- def IsChild(self, name):
- return self.ElementDictionary.has_key(name)
- def GetChild(self, name):
- return self.ElementDictionary[name]
- def GetChild2(self, name):
- return self.ElementDictionary.get(name, None)
- class PythonScriptLoader(object):
- BODY_KEY_LIST = ( "x", "y", "width", "height" )
- #####
- DEFAULT_KEY_LIST = ( "type", "x", "y", )
- WINDOW_KEY_LIST = ( "width", "height", )
- IMAGE_KEY_LIST = ( "image", )
- EXPANDED_IMAGE_KEY_LIST = ( "image", )
- ANI_IMAGE_KEY_LIST = ( "images", )
- SLOT_KEY_LIST = ( "width", "height", "slot", )
- CANDIDATE_LIST_KEY_LIST = ( "item_step", "item_xsize", "item_ysize", )
- GRID_TABLE_KEY_LIST = ( "start_index", "x_count", "y_count", "x_step", "y_step", )
- EDIT_LINE_KEY_LIST = ( "width", "height", "input_limit", )
- COMBO_BOX_KEY_LIST = ( "width", "height", "item", )
- TITLE_BAR_KEY_LIST = ( "width", )
- HORIZONTAL_BAR_KEY_LIST = ( "width", )
- BOARD_KEY_LIST = ( "width", "height", )
- BOARD_WITH_TITLEBAR_KEY_LIST = ( "width", "height", "title", )
- BOX_KEY_LIST = ( "width", "height", )
- BAR_KEY_LIST = ( "width", "height", )
- LINE_KEY_LIST = ( "width", "height", )
- SLOTBAR_KEY_LIST = ( "width", "height", )
- GAUGE_KEY_LIST = ( "width", "color", )
- SCROLLBAR_KEY_LIST = ( "size", )
- LIST_BOX_KEY_LIST = ( "width", "height", )
- def __init__(self):
- self.Clear()
- def Clear(self):
- self.ScriptDictionary = { "SCREEN_WIDTH" : wndMgr.GetScreenWidth(), "SCREEN_HEIGHT" : wndMgr.GetScreenHeight() }
- self.InsertFunction = 0
- def LoadScriptFile(self, window, FileName):
- import exception
- import exceptions
- import os
- import errno
- self.Clear()
- print "===== Load Script File : %s" % (FileName)
- try:
- # chr, player 등은 sandbox 내에서 import가 허용되지 않기 때문에,(봇이 악용할 여지가 매우 큼.)
- # 미리 script dictionary에 필요한 상수를 넣어놓는다.
- import chr
- import player
- import app
- self.ScriptDictionary["PLAYER_NAME_MAX_LEN"] = chr.PLAYER_NAME_MAX_LEN
- self.ScriptDictionary["DRAGON_SOUL_EQUIPMENT_SLOT_START"] = player.DRAGON_SOUL_EQUIPMENT_SLOT_START
- self.ScriptDictionary["LOCALE_PATH"] = app.GetLocalePath()
- execfile(FileName, self.ScriptDictionary)
- except IOError, err:
- import sys
- import dbg
- dbg.TraceError("Failed to load script file : %s" % (FileName))
- dbg.TraceError("error : %s" % (err))
- exception.Abort("LoadScriptFile1")
- except RuntimeError,err:
- import sys
- import dbg
- dbg.TraceError("Failed to load script file : %s" % (FileName))
- dbg.TraceError("error : %s" % (err))
- exception.Abort("LoadScriptFile2")
- except:
- import sys
- import dbg
- dbg.TraceError("Failed to load script file : %s" % (FileName))
- exception.Abort("LoadScriptFile!!!!!!!!!!!!!!")
- #####
- Body = self.ScriptDictionary["window"]
- self.CheckKeyList("window", Body, self.BODY_KEY_LIST)
- window.ClearDictionary()
- self.InsertFunction = window.InsertChild
- window.SetPosition(int(Body["x"]), int(Body["y"]))
- window.SetSize(int(Body["width"]), int(Body["height"]))
- if TRUE == Body.has_key("style"):
- for StyleList in Body["style"]:
- window.AddFlag(StyleList)
- self.LoadChildren(window, Body)
- def LoadChildren(self, parent, dicChildren):
- if TRUE == dicChildren.has_key("style"):
- for style in dicChildren["style"]:
- parent.AddFlag(style)
- if FALSE == dicChildren.has_key("children"):
- return FALSE
- Index = 0
- ChildrenList = dicChildren["children"]
- parent.Children = range(len(ChildrenList))
- for ElementValue in ChildrenList:
- try:
- Name = ElementValue["name"]
- except KeyError:
- Name = ElementValue["name"] = "NONAME"
- try:
- Type = ElementValue["type"]
- except KeyError:
- Type = ElementValue["type"] = "window"
- if FALSE == self.CheckKeyList(Name, ElementValue, self.DEFAULT_KEY_LIST):
- del parent.Children[Index]
- continue
- if Type == "window":
- parent.Children[Index] = ScriptWindow()
- parent.Children[Index].SetParent(parent)
- self.LoadElementWindow(parent.Children[Index], ElementValue, parent)
- elif Type == "button":
- parent.Children[Index] = Button()
- parent.Children[Index].SetParent(parent)
- self.LoadElementButton(parent.Children[Index], ElementValue, parent)
- elif Type == "radio_button":
- parent.Children[Index] = RadioButton()
- parent.Children[Index].SetParent(parent)
- self.LoadElementButton(parent.Children[Index], ElementValue, parent)
- elif Type == "toggle_button":
- parent.Children[Index] = ToggleButton()
- parent.Children[Index].SetParent(parent)
- self.LoadElementButton(parent.Children[Index], ElementValue, parent)
- elif Type == "mark":
- parent.Children[Index] = MarkBox()
- parent.Children[Index].SetParent(parent)
- self.LoadElementMark(parent.Children[Index], ElementValue, parent)
- elif Type == "image":
- parent.Children[Index] = ImageBox()
- parent.Children[Index].SetParent(parent)
- self.LoadElementImage(parent.Children[Index], ElementValue, parent)
- elif Type == "expanded_image":
- parent.Children[Index] = ExpandedImageBox()
- parent.Children[Index].SetParent(parent)
- self.LoadElementExpandedImage(parent.Children[Index], ElementValue, parent)
- elif Type == "ani_image":
- parent.Children[Index] = AniImageBox()
- parent.Children[Index].SetParent(parent)
- self.LoadElementAniImage(parent.Children[Index], ElementValue, parent)
- elif Type == "slot":
- parent.Children[Index] = SlotWindow()
- parent.Children[Index].SetParent(parent)
- self.LoadElementSlot(parent.Children[Index], ElementValue, parent)
- elif Type == "candidate_list":
- parent.Children[Index] = CandidateListBox()
- parent.Children[Index].SetParent(parent)
- self.LoadElementCandidateList(parent.Children[Index], ElementValue, parent)
- elif Type == "grid_table":
- parent.Children[Index] = GridSlotWindow()
- parent.Children[Index].SetParent(parent)
- self.LoadElementGridTable(parent.Children[Index], ElementValue, parent)
- elif Type == "text":
- parent.Children[Index] = TextLine()
- parent.Children[Index].SetParent(parent)
- self.LoadElementText(parent.Children[Index], ElementValue, parent)
- elif Type == "editline":
- parent.Children[Index] = EditLine()
- parent.Children[Index].SetParent(parent)
- self.LoadElementEditLine(parent.Children[Index], ElementValue, parent)
- elif Type == "titlebar":
- parent.Children[Index] = TitleBar()
- parent.Children[Index].SetParent(parent)
- self.LoadElementTitleBar(parent.Children[Index], ElementValue, parent)
- elif Type == "horizontalbar":
- parent.Children[Index] = HorizontalBar()
- parent.Children[Index].SetParent(parent)
- self.LoadElementHorizontalBar(parent.Children[Index], ElementValue, parent)
- elif Type == "board":
- parent.Children[Index] = Board()
- parent.Children[Index].SetParent(parent)
- self.LoadElementBoard(parent.Children[Index], ElementValue, parent)
- elif Type == "board_with_titlebar":
- parent.Children[Index] = BoardWithTitleBar()
- parent.Children[Index].SetParent(parent)
- self.LoadElementBoardWithTitleBar(parent.Children[Index], ElementValue, parent)
- elif Type == "thinboard":
- parent.Children[Index] = ThinBoard()
- parent.Children[Index].SetParent(parent)
- self.LoadElementThinBoard(parent.Children[Index], ElementValue, parent)
- elif Type == "thinboard_gold":
- parent.Children[Index] = ThinBoardGold()
- parent.Children[Index].SetParent(parent)
- self.LoadElementThinBoard(parent.Children[Index], ElementValue, parent)
- elif Type == "thinboard_circle":
- parent.Children[Index] = ThinBoardCircle()
- parent.Children[Index].SetParent(parent)
- self.LoadElementThinBoard(parent.Children[Index], ElementValue, parent)
- elif Type == "thinboard_gold":
- parent.Children[Index] = ThinBoardGold()
- parent.Children[Index].SetParent(parent)
- self.LoadElementThinBoardGold(parent.Children[Index], ElementValue, parent)
- elif Type == "thinboard_circle":
- parent.Children[Index] = ThinBoardCircle()
- parent.Children[Index].SetParent(parent)
- self.LoadElementThinBoardCircle(parent.Children[Index], ElementValue, parent)
- elif Type == "box":
- parent.Children[Index] = Box()
- parent.Children[Index].SetParent(parent)
- self.LoadElementBox(parent.Children[Index], ElementValue, parent)
- elif Type == "bar":
- parent.Children[Index] = Bar()
- parent.Children[Index].SetParent(parent)
- self.LoadElementBar(parent.Children[Index], ElementValue, parent)
- elif Type == "line":
- parent.Children[Index] = Line()
- parent.Children[Index].SetParent(parent)
- self.LoadElementLine(parent.Children[Index], ElementValue, parent)
- elif Type == "slotbar":
- parent.Children[Index] = SlotBar()
- parent.Children[Index].SetParent(parent)
- self.LoadElementSlotBar(parent.Children[Index], ElementValue, parent)
- elif Type == "gauge":
- parent.Children[Index] = Gauge()
- parent.Children[Index].SetParent(parent)
- self.LoadElementGauge(parent.Children[Index], ElementValue, parent)
- elif Type == "scrollbar":
- parent.Children[Index] = ScrollBar()
- parent.Children[Index].SetParent(parent)
- self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
- elif Type == "thin_scrollbar":
- parent.Children[Index] = ThinScrollBar()
- parent.Children[Index].SetParent(parent)
- self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
- elif Type == "small_thin_scrollbar":
- parent.Children[Index] = SmallThinScrollBar()
- parent.Children[Index].SetParent(parent)
- self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
- elif Type == "sliderbar":
- parent.Children[Index] = SliderBar()
- parent.Children[Index].SetParent(parent)
- self.LoadElementSliderBar(parent.Children[Index], ElementValue, parent)
- elif Type == "listbox":
- parent.Children[Index] = ListBox()
- parent.Children[Index].SetParent(parent)
- self.LoadElementListBox(parent.Children[Index], ElementValue, parent)
- elif Type == "listbox2":
- parent.Children[Index] = ListBox2()
- parent.Children[Index].SetParent(parent)
- self.LoadElementListBox2(parent.Children[Index], ElementValue, parent)
- elif Type == "listboxex":
- parent.Children[Index] = ListBoxEx()
- parent.Children[Index].SetParent(parent)
- self.LoadElementListBoxEx(parent.Children[Index], ElementValue, parent)
- elif Type == "listbox_scroll":
- parent.Children[Index] = ListBoxScroll()
- parent.Children[Index].SetParent(parent)
- self.LoadElementListBox(parent.Children[Index], ElementValue, parent)
- else:
- Index += 1
- continue
- parent.Children[Index].SetWindowName(Name)
- if 0 != self.InsertFunction:
- self.InsertFunction(Name, parent.Children[Index])
- self.LoadChildren(parent.Children[Index], ElementValue)
- Index += 1
- def CheckKeyList(self, name, value, key_list):
- for DataKey in key_list:
- if FALSE == value.has_key(DataKey):
- print "Failed to find data key", "[" + name + "/" + DataKey + "]"
- return FALSE
- return TRUE
- def LoadDefaultData(self, window, value, parentWindow):
- loc_x = int(value["x"])
- loc_y = int(value["y"])
- if value.has_key("vertical_align"):
- if "center" == value["vertical_align"]:
- window.SetWindowVerticalAlignCenter()
- elif "bottom" == value["vertical_align"]:
- window.SetWindowVerticalAlignBottom()
- if parentWindow.IsRTL():
- loc_x = int(value["x"]) + window.GetWidth()
- if value.has_key("horizontal_align"):
- if "center" == value["horizontal_align"]:
- window.SetWindowHorizontalAlignCenter()
- loc_x = - int(value["x"])
- elif "right" == value["horizontal_align"]:
- window.SetWindowHorizontalAlignLeft()
- loc_x = int(value["x"]) - window.GetWidth()
- ## loc_x = parentWindow.GetWidth() - int(value["x"]) + window.GetWidth()
- else:
- window.SetWindowHorizontalAlignRight()
- if value.has_key("all_align"):
- window.SetWindowVerticalAlignCenter()
- window.SetWindowHorizontalAlignCenter()
- loc_x = - int(value["x"])
- else:
- if value.has_key("horizontal_align"):
- if "center" == value["horizontal_align"]:
- window.SetWindowHorizontalAlignCenter()
- elif "right" == value["horizontal_align"]:
- window.SetWindowHorizontalAlignRight()
- window.SetPosition(loc_x, loc_y)
- window.Show()
- ## Window
- def LoadElementWindow(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.WINDOW_KEY_LIST):
- return FALSE
- window.SetSize(int(value["width"]), int(value["height"]))
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- def LoadElementListBox(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.LIST_BOX_KEY_LIST):
- return FALSE
- if value.has_key("item_align"):
- window.SetTextCenterAlign(value["item_align"])
- window.SetSize(value["width"], value["height"])
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- ## Button
- def LoadElementButton(self, window, value, parentWindow):
- if value.has_key("width") and value.has_key("height"):
- window.SetSize(int(value["width"]), int(value["height"]))
- if TRUE == value.has_key("default_image"):
- window.SetUpVisual(value["default_image"])
- if TRUE == value.has_key("over_image"):
- window.SetOverVisual(value["over_image"])
- if TRUE == value.has_key("down_image"):
- window.SetDownVisual(value["down_image"])
- if TRUE == value.has_key("disable_image"):
- window.SetDisableVisual(value["disable_image"])
- if TRUE == value.has_key("text"):
- if TRUE == value.has_key("text_height"):
- window.SetText(value["text"], value["text_height"])
- else:
- window.SetText(value["text"])
- if value.has_key("text_color"):
- window.SetTextColor(value["text_color"])
- if TRUE == value.has_key("tooltip_text"):
- if TRUE == value.has_key("tooltip_x") and TRUE == value.has_key("tooltip_y"):
- window.SetToolTipText(value["tooltip_text"], int(value["tooltip_x"]), int(value["tooltip_y"]))
- else:
- window.SetToolTipText(value["tooltip_text"])
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- ## Mark
- def LoadElementMark(self, window, value, parentWindow):
- #if FALSE == self.CheckKeyList(value["name"], value, self.MARK_KEY_LIST):
- # return FALSE
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- ## Image
- def LoadElementImage(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.IMAGE_KEY_LIST):
- return FALSE
- window.LoadImage(value["image"])
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- ## AniImage
- def LoadElementAniImage(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.ANI_IMAGE_KEY_LIST):
- return FALSE
- if TRUE == value.has_key("delay"):
- window.SetDelay(value["delay"])
- for image in value["images"]:
- window.AppendImage(image)
- if value.has_key("width") and value.has_key("height"):
- window.SetSize(value["width"], value["height"])
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- ## Expanded Image
- def LoadElementExpandedImage(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.EXPANDED_IMAGE_KEY_LIST):
- return FALSE
- window.LoadImage(value["image"])
- if TRUE == value.has_key("x_origin") and TRUE == value.has_key("y_origin"):
- window.SetOrigin(float(value["x_origin"]), float(value["y_origin"]))
- if TRUE == value.has_key("x_scale") and TRUE == value.has_key("y_scale"):
- window.SetScale(float(value["x_scale"]), float(value["y_scale"]))
- if TRUE == value.has_key("rect"):
- RenderingRect = value["rect"]
- window.SetRenderingRect(RenderingRect[0], RenderingRect[1], RenderingRect[2], RenderingRect[3])
- if TRUE == value.has_key("mode"):
- mode = value["mode"]
- if "MODULATE" == mode:
- window.SetRenderingMode(wndMgr.RENDERING_MODE_MODULATE)
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- ## Slot
- def LoadElementSlot(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.SLOT_KEY_LIST):
- return FALSE
- global_x = int(value["x"])
- global_y = int(value["y"])
- global_width = int(value["width"])
- global_height = int(value["height"])
- window.SetPosition(global_x, global_y)
- window.SetSize(global_width, global_height)
- window.Show()
- r = 1.0
- g = 1.0
- b = 1.0
- a = 1.0
- if TRUE == value.has_key("image_r") and \
- TRUE == value.has_key("image_g") and \
- TRUE == value.has_key("image_b") and \
- TRUE == value.has_key("image_a"):
- r = float(value["image_r"])
- g = float(value["image_g"])
- b = float(value["image_b"])
- a = float(value["image_a"])
- SLOT_ONE_KEY_LIST = ("index", "x", "y", "width", "height")
- for slot in value["slot"]:
- if TRUE == self.CheckKeyList(value["name"] + " - one", slot, SLOT_ONE_KEY_LIST):
- wndMgr.AppendSlot(window.hWnd,
- int(slot["index"]),
- int(slot["x"]),
- int(slot["y"]),
- int(slot["width"]),
- int(slot["height"]))
- if TRUE == value.has_key("image"):
- wndMgr.SetSlotBaseImage(window.hWnd,
- value["image"],
- r, g, b, a)
- return TRUE
- def LoadElementCandidateList(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.CANDIDATE_LIST_KEY_LIST):
- return FALSE
- window.SetPosition(int(value["x"]), int(value["y"]))
- window.SetItemSize(int(value["item_xsize"]), int(value["item_ysize"]))
- window.SetItemStep(int(value["item_step"]))
- window.Show()
- return TRUE
- ## Table
- def LoadElementGridTable(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.GRID_TABLE_KEY_LIST):
- return FALSE
- xBlank = 0
- yBlank = 0
- if TRUE == value.has_key("x_blank"):
- xBlank = int(value["x_blank"])
- if TRUE == value.has_key("y_blank"):
- yBlank = int(value["y_blank"])
- window.SetPosition(int(value["x"]), int(value["y"]))
- window.ArrangeSlot( int(value["start_index"]),
- int(value["x_count"]),
- int(value["y_count"]),
- int(value["x_step"]),
- int(value["y_step"]),
- xBlank,
- yBlank)
- if TRUE == value.has_key("image"):
- r = 1.0
- g = 1.0
- b = 1.0
- a = 1.0
- if TRUE == value.has_key("image_r") and \
- TRUE == value.has_key("image_g") and \
- TRUE == value.has_key("image_b") and \
- TRUE == value.has_key("image_a"):
- r = float(value["image_r"])
- g = float(value["image_g"])
- b = float(value["image_b"])
- a = float(value["image_a"])
- wndMgr.SetSlotBaseImage(window.hWnd, value["image"], r, g, b, a)
- if TRUE == value.has_key("style"):
- if "select" == value["style"]:
- wndMgr.SetSlotStyle(window.hWnd, wndMgr.SLOT_STYLE_SELECT)
- window.Show()
- return TRUE
- ## Text
- def LoadElementText(self, window, value, parentWindow):
- if value.has_key("fontsize"):
- fontSize = value["fontsize"]
- if "LARGE" == fontSize:
- window.SetFontName(localeInfo.UI_DEF_FONT_LARGE)
- elif value.has_key("fontname"):
- fontName = value["fontname"]
- window.SetFontName(fontName)
- if value.has_key("text_horizontal_align"):
- if "left" == value["text_horizontal_align"]:
- window.SetHorizontalAlignLeft()
- elif "center" == value["text_horizontal_align"]:
- window.SetHorizontalAlignCenter()
- elif "right" == value["text_horizontal_align"]:
- window.SetHorizontalAlignRight()
- if value.has_key("text_vertical_align"):
- if "top" == value["text_vertical_align"]:
- window.SetVerticalAlignTop()
- elif "center" == value["text_vertical_align"]:
- window.SetVerticalAlignCenter()
- elif "bottom" == value["text_vertical_align"]:
- window.SetVerticalAlignBottom()
- if value.has_key("all_align"):
- window.SetHorizontalAlignCenter()
- window.SetVerticalAlignCenter()
- window.SetWindowHorizontalAlignCenter()
- window.SetWindowVerticalAlignCenter()
- if value.has_key("r") and value.has_key("g") and value.has_key("b"):
- window.SetFontColor(float(value["r"]), float(value["g"]), float(value["b"]))
- elif value.has_key("color"):
- window.SetPackedFontColor(value["color"])
- else:
- window.SetFontColor(0.8549, 0.8549, 0.8549)
- if value.has_key("outline"):
- if value["outline"]:
- window.SetOutline()
- if TRUE == value.has_key("text"):
- window.SetText(value["text"])
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- ## EditLine
- def LoadElementEditLine(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.EDIT_LINE_KEY_LIST):
- return FALSE
- if value.has_key("secret_flag"):
- window.SetSecret(value["secret_flag"])
- if value.has_key("with_codepage"):
- if value["with_codepage"]:
- window.bCodePage = TRUE
- if value.has_key("only_number"):
- if value["only_number"]:
- window.SetNumberMode()
- if value.has_key("enable_codepage"):
- window.SetIMEFlag(value["enable_codepage"])
- if value.has_key("enable_ime"):
- window.SetIMEFlag(value["enable_ime"])
- if value.has_key("limit_width"):
- window.SetLimitWidth(value["limit_width"])
- if value.has_key("multi_line"):
- if value["multi_line"]:
- window.SetMultiLine()
- window.SetMax(int(value["input_limit"]))
- window.SetSize(int(value["width"]), int(value["height"]))
- self.LoadElementText(window, value, parentWindow)
- return TRUE
- ## TitleBar
- def LoadElementTitleBar(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.TITLE_BAR_KEY_LIST):
- return FALSE
- window.MakeTitleBar(int(value["width"]), value.get("color", "red"))
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- ## HorizontalBar
- def LoadElementHorizontalBar(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.HORIZONTAL_BAR_KEY_LIST):
- return FALSE
- window.Create(int(value["width"]))
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- ## Board
- def LoadElementBoard(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.BOARD_KEY_LIST):
- return FALSE
- window.SetSize(int(value["width"]), int(value["height"]))
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- ## Board With TitleBar
- def LoadElementBoardWithTitleBar(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.BOARD_WITH_TITLEBAR_KEY_LIST):
- return FALSE
- window.SetSize(int(value["width"]), int(value["height"]))
- window.SetTitleName(value["title"])
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- ## ThinBoard
- def LoadElementThinBoard(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.BOARD_KEY_LIST):
- return FALSE
- window.SetSize(int(value["width"]), int(value["height"]))
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- def LoadElementThinBoardGold(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.BOARD_KEY_LIST):
- return FALSE
- window.SetSize(int(value["width"]), int(value["height"]))
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- def LoadElementThinBoardCircle(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.BOARD_KEY_LIST):
- return FALSE
- window.SetSize(int(value["width"]), int(value["height"]))
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- ## Box
- def LoadElementBox(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.BOX_KEY_LIST):
- return FALSE
- if TRUE == value.has_key("color"):
- window.SetColor(value["color"])
- window.SetSize(int(value["width"]), int(value["height"]))
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- ## Bar
- def LoadElementBar(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.BAR_KEY_LIST):
- return FALSE
- if TRUE == value.has_key("color"):
- window.SetColor(value["color"])
- window.SetSize(int(value["width"]), int(value["height"]))
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- ## Line
- def LoadElementLine(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.LINE_KEY_LIST):
- return FALSE
- if TRUE == value.has_key("color"):
- window.SetColor(value["color"])
- window.SetSize(int(value["width"]), int(value["height"]))
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- ## Slot
- def LoadElementSlotBar(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.SLOTBAR_KEY_LIST):
- return FALSE
- window.SetSize(int(value["width"]), int(value["height"]))
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- ## Gauge
- def LoadElementGauge(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.GAUGE_KEY_LIST):
- return FALSE
- window.MakeGauge(value["width"], value["color"])
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- ## ScrollBar
- def LoadElementScrollBar(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.SCROLLBAR_KEY_LIST):
- return FALSE
- window.SetScrollBarSize(value["size"])
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- ## SliderBar
- def LoadElementSliderBar(self, window, value, parentWindow):
- self.LoadDefaultData(window, value, parentWindow)
- return TRUE
- ## ListBox2
- def LoadElementListBox2(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.LIST_BOX_KEY_LIST):
- return FALSE
- window.SetRowCount(value.get("row_count", 10))
- window.SetSize(value["width"], value["height"])
- self.LoadDefaultData(window, value, parentWindow)
- if value.has_key("item_align"):
- window.SetTextCenterAlign(value["item_align"])
- return TRUE
- def LoadElementListBoxEx(self, window, value, parentWindow):
- if FALSE == self.CheckKeyList(value["name"], value, self.LIST_BOX_KEY_LIST):
- return FALSE
- window.SetSize(value["width"], value["height"])
- self.LoadDefaultData(window, value, parentWindow)
- if value.has_key("itemsize_x") and value.has_key("itemsize_y"):
- window.SetItemSize(int(value["itemsize_x"]), int(value["itemsize_y"]))
- if value.has_key("itemstep"):
- window.SetItemStep(int(value["itemstep"]))
- if value.has_key("viewcount"):
- window.SetViewItemCount(int(value["viewcount"]))
- return TRUE
- class ListBoxScroll(ListBox):
- def __init__(self):
- ListBox.__init__(self)
- self.scrollBar = ScrollBar()
- self.scrollBar.SetParent(self)
- self.scrollBar.SetScrollEvent(self.__OnScroll)
- self.scrollBar.Hide()
- def SetSize(self, width, height):
- ListBox.SetSize(self, width - ScrollBar.SCROLLBAR_WIDTH, height)
- Window.SetSize(self, width, height)
- self.scrollBar.SetPosition(width - ScrollBar.SCROLLBAR_WIDTH, 0)
- self.scrollBar.SetScrollBarSize(height)
- def ClearItem(self):
- ListBox.ClearItem(self)
- self.scrollBar.SetPos(0)
- def _LocateItem(self):
- ListBox._LocateItem(self)
- if self.showLineCount < len(self.itemList):
- self.scrollBar.SetMiddleBarSize(float(self.GetViewItemCount())/self.GetItemCount())
- self.scrollBar.Show()
- else:
- self.scrollBar.Hide()
- def __OnScroll(self):
- scrollLen = self.GetItemCount()-self.GetViewItemCount()
- if scrollLen < 0:
- scrollLen = 0
- self.SetBasePos(int(self.scrollBar.GetPos()*scrollLen))
- class ReadingWnd(Bar):
- def __init__(self):
- Bar.__init__(self,"TOP_MOST")
- self.__BuildText()
- self.SetSize(80, 19)
- self.Show()
- def __del__(self):
- Bar.__del__(self)
- def __BuildText(self):
- self.text = TextLine()
- self.text.SetParent(self)
- self.text.SetPosition(4, 3)
- self.text.Show()
- def SetText(self, text):
- self.text.SetText(text)
- def SetReadingPosition(self, x, y):
- xPos = x + 2
- yPos = y - self.GetHeight() - 2
- self.SetPosition(xPos, yPos)
- def SetTextColor(self, color):
- self.text.SetPackedFontColor(color)
- def MakeSlotBar(parent, x, y, width, height):
- slotBar = SlotBar()
- slotBar.SetParent(parent)
- slotBar.SetSize(width, height)
- slotBar.SetPosition(x, y)
- slotBar.Show()
- return slotBar
- def MakeImageBox(parent, name, x, y):
- image = ImageBox()
- image.SetParent(parent)
- image.LoadImage(name)
- image.SetPosition(x, y)
- image.Show()
- return image
- def MakeTextLine(parent):
- textLine = TextLine()
- textLine.SetParent(parent)
- textLine.SetWindowHorizontalAlignCenter()
- textLine.SetWindowVerticalAlignCenter()
- textLine.SetHorizontalAlignCenter()
- textLine.SetVerticalAlignCenter()
- textLine.Show()
- return textLine
- def MakeButton(parent, x, y, tooltipText, path, up, over, down):
- button = Button()
- button.SetParent(parent)
- button.SetPosition(x, y)
- button.SetUpVisual(path + up)
- button.SetOverVisual(path + over)
- button.SetDownVisual(path + down)
- button.SetToolTipText(tooltipText)
- button.Show()
- return button
- def RenderRoundBox(x, y, width, height, color):
- grp.SetColor(color)
- grp.RenderLine(x+2, y, width-3, 0)
- grp.RenderLine(x+2, y+height, width-3, 0)
- grp.RenderLine(x, y+2, 0, height-4)
- grp.RenderLine(x+width, y+1, 0, height-3)
- grp.RenderLine(x, y+2, 2, -2)
- grp.RenderLine(x, y+height-2, 2, 2)
- grp.RenderLine(x+width-2, y, 2, 2)
- grp.RenderLine(x+width-2, y+height, 2, -2)
- def GenerateColor(r, g, b):
- r = float(r) / 255.0
- g = float(g) / 255.0
- b = float(b) / 255.0
- return grp.GenerateColor(r, g, b, 1.0)
- def EnablePaste(flag):
- ime.EnablePaste(flag)
- def GetHyperlink():
- return wndMgr.GetHyperlink()
- RegisterToolTipWindow("TEXT", TextLine)
hier ist die introLogin.py
Code- import dbg
- import app
- import net
- import ui
- import ime
- import snd
- import wndMgr
- import musicInfo
- import serverInfo
- import systemSetting
- import ServerStateChecker
- import localeInfo
- import constInfo
- import uiCommon
- import time
- import serverCommandParser
- import ime
- import uiScriptLocale
- import uiGuild
- import os
- import sys
- import uiTarget
- #--------------------SaveLogin
- import uiSelectCredentials
- import base64
- import _winreg
- import string
- import random
- RUNUP_MATRIX_AUTH = FALSE
- NEWCIBN_PASSPOD_AUTH = FALSE
- LOGIN_DELAY_SEC = 0.0
- SKIP_LOGIN_PHASE = FALSE
- SKIP_LOGIN_PHASE_SUPPORT_CHANNEL = FALSE
- FULL_BACK_IMAGE = FALSE
- PASSPOD_MSG_DICT = {}
- VIRTUAL_KEYBOARD_NUM_KEYS = 46
- VIRTUAL_KEYBOARD_RAND_KEY = TRUE
- def Suffle(src):
- if VIRTUAL_KEYBOARD_RAND_KEY:
- items = [item for item in src]
- itemCount = len(items)
- for oldPos in xrange(itemCount):
- newPos = app.GetRandom(0, itemCount-1)
- items[newPos], items[oldPos] = items[oldPos], items[newPos]
- return "".join(items)
- else:
- return src
- def IsFullBackImage():
- global FULL_BACK_IMAGE
- return FULL_BACK_IMAGE
- def IsLoginDelay():
- global LOGIN_DELAY_SEC
- if LOGIN_DELAY_SEC > 0.0:
- return TRUE
- else:
- return FALSE
- def IsRunupMatrixAuth():
- global RUNUP_MATRIX_AUTH
- return RUNUP_MATRIX_AUTH
- def IsNEWCIBNPassPodAuth():
- global NEWCIBN_PASSPOD_AUTH
- return NEWCIBN_PASSPOD_AUTH
- def GetLoginDelay():
- global LOGIN_DELAY_SEC
- return LOGIN_DELAY_SEC
- app.SetGuildMarkPath("test")
- class ConnectingDialog(ui.ScriptWindow):
- def __init__(self):
- ui.ScriptWindow.__init__(self)
- self.__LoadDialog()
- self.eventTimeOver = lambda *arg: None
- self.eventExit = lambda *arg: None
- def __del__(self):
- ui.ScriptWindow.__del__(self)
- def __LoadDialog(self):
- try:
- PythonScriptLoader = ui.PythonScriptLoader()
- PythonScriptLoader.LoadScriptFile(self, "UIScript/ConnectingDialog.py")
- self.board = self.GetChild("board")
- self.message = self.GetChild("message")
- self.countdownMessage = self.GetChild("countdown_message")
- except:
- import exception
- exception.Abort("ConnectingDialog.LoadDialog.BindObject")
- def Open(self, waitTime):
- curTime = time.clock()
- self.endTime = curTime + waitTime
- self.Lock()
- self.SetCenterPosition()
- self.SetTop()
- self.Show()
- def Close(self):
- self.Unlock()
- self.Hide()
- def Destroy(self):
- self.Hide()
- self.ClearDictionary()
- def SetText(self, text):
- self.message.SetText(text)
- def SetCountDownMessage(self, waitTime):
- self.countdownMessage.SetText("%.0f%s" % (waitTime, localeInfo.SECOND))
- def SAFE_SetTimeOverEvent(self, event):
- self.eventTimeOver = ui.__mem_func__(event)
- def SAFE_SetExitEvent(self, event):
- self.eventExit = ui.__mem_func__(event)
- def OnUpdate(self):
- lastTime = max(0, self.endTime - time.clock())
- if 0 == lastTime:
- self.Close()
- self.eventTimeOver()
- else:
- self.SetCountDownMessage(self.endTime - time.clock())
- def OnPressExitKey(self):
- #self.eventExit()
- return TRUE
- class LoginWindow(ui.ScriptWindow):
- IS_TEST = net.IsTest()
- def __init__(self, stream):
- print "NEW LOGIN WINDOW ----------------------------------------------------------------------------"
- ui.ScriptWindow.__init__(self)
- net.SetPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
- net.SetAccountConnectorHandler(self)
- self.matrixInputChanceCount = 0
- self.lastLoginTime = 0
- self.inputDialog = None
- self.connectingDialog = None
- self.stream=stream
- self.isNowCountDown=FALSE
- self.isStartError=FALSE
- self.xServerBoard = 0
- self.yServerBoard = 0
- self.loadingImage = None
- self.virtualKeyboard = None
- self.virtualKeyboardMode = "ALPHABET"
- self.virtualKeyboardIsUpper = FALSE
- def __del__(self):
- net.ClearPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
- net.SetAccountConnectorHandler(0)
- ui.ScriptWindow.__del__(self)
- print "---------------------------------------------------------------------------- DELETE LOGIN WINDOW"
- def Open(self):
- ServerStateChecker.Create(self)
- print "LOGIN WINDOW OPEN ----------------------------------------------------------------------------"
- self.loginFailureMsgDict={
- #"DEFAULT" : localeInfo.LOGIN_FAILURE_UNKNOWN,
- "ALREADY" : localeInfo.LOGIN_FAILURE_ALREAY,
- "NOID" : localeInfo.LOGIN_FAILURE_NOT_EXIST_ID,
- "WRONGPWD" : localeInfo.LOGIN_FAILURE_WRONG_PASSWORD,
- "FULL" : localeInfo.LOGIN_FAILURE_TOO_MANY_USER,
- "SHUTDOWN" : localeInfo.LOGIN_FAILURE_SHUTDOWN,
- "REPAIR" : localeInfo.LOGIN_FAILURE_REPAIR_ID,
- "BLOCK" : localeInfo.LOGIN_FAILURE_BLOCK_ID,
- "WRONGMAT" : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER,
- "QUIT" : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER_TRIPLE,
- "BESAMEKEY" : localeInfo.LOGIN_FAILURE_BE_SAME_KEY,
- "NOTAVAIL" : localeInfo.LOGIN_FAILURE_NOT_AVAIL,
- "NOBILL" : localeInfo.LOGIN_FAILURE_NOBILL,
- "BLKLOGIN" : localeInfo.LOGIN_FAILURE_BLOCK_LOGIN,
- "WEBBLK" : localeInfo.LOGIN_FAILURE_WEB_BLOCK,
- "BADSCLID" : localeInfo.LOGIN_FAILURE_WRONG_SOCIALID,
- "AGELIMIT" : localeInfo.LOGIN_FAILURE_SHUTDOWN_TIME,
- "WRONGVER" : localeInfo.LOGIN_FAILURE_WRONG_VERSION,
- }
- self.loginFailureFuncDict = {
- "WRONGPWD" : self.__DisconnectAndInputPassword,
- "WRONGMAT" : self.__DisconnectAndInputMatrix,
- "QUIT" : app.Exit,
- "WRONGVER" : app.Exit,
- }
- self.SetSize(wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight())
- self.SetWindowName("LoginWindow")
- if not self.__LoadScript(uiScriptLocale.LOCALE_UISCRIPT_PATH + "LoginWindow.py"):
- dbg.TraceError("LoginWindow.Open - __LoadScript Error")
- return
- self.__LoadLoginInfo("loginInfo.xml")
- if app.loggined:
- self.loginFailureFuncDict = {
- "WRONGPWD" : app.Exit,
- "WRONGMAT" : app.Exit,
- "QUIT" : app.Exit,
- }
- if musicInfo.loginMusic != "":
- snd.SetMusicVolume(systemSetting.GetMusicVolume())
- snd.FadeInMusic("bgm/"+musicInfo.loginMusic)
- snd.SetSoundVolume(systemSetting.GetSoundVolume())
- # pevent key "[" "]"
- ime.AddExceptKey(91)
- ime.AddExceptKey(93)
- self.Show()
- global SKIP_LOGIN_PHASE
- if SKIP_LOGIN_PHASE:
- if self.isStartError:
- self.connectBoard.Hide()
- self.loginBoard.Hide()
- self.serverBoard.Hide()
- self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.__ExitGame)
- return
- if self.loginInfo:
- self.serverBoard.Hide()
- else:
- self.__RefreshServerList()
- self.__OpenServerBoard()
- else:
- connectingIP = self.stream.GetConnectAddr()
- if connectingIP:
- self.__OpenLoginBoard()
- if IsFullBackImage():
- self.GetChild("bg1").Hide()
- self.GetChild("bg2").Show()
- else:
- self.__RefreshServerList()
- self.__OpenServerBoard()
- app.ShowCursor()
- def Close(self):
- if self.connectingDialog:
- self.connectingDialog.Close()
- self.connectingDialog = None
- ServerStateChecker.Initialize(self)
- print "---------------------------------------------------------------------------- CLOSE LOGIN WINDOW "
- if musicInfo.loginMusic != "" and musicInfo.selectMusic != "":
- snd.FadeOutMusic("bgm/"+musicInfo.loginMusic)
- self.idEditLine.SetTabEvent(0)
- self.idEditLine.SetReturnEvent(0)
- self.pwdEditLine.SetReturnEvent(0)
- self.pwdEditLine.SetTabEvent(0)
- self.connectBoard = None
- self.loginBoard = None
- self.idEditLine = None
- self.pwdEditLine = None
- self.inputDialog = None
- self.connectingDialog = None
- self.loadingImage = None
- self.serverBoard = None
- self.serverList = None
- self.channelList = None
- # RUNUP_MATRIX_AUTH
- self.matrixQuizBoard = None
- self.matrixAnswerInput = None
- self.matrixAnswerOK = None
- self.matrixAnswerCancel = None
- # RUNUP_MATRIX_AUTH_END
- # NEWCIBN_PASSPOD_AUTH
- self.passpodBoard = None
- self.passpodAnswerInput = None
- self.passpodAnswerOK = None
- self.passpodAnswerCancel = None
- # NEWCIBN_PASSPOD_AUTH_END
- self.VIRTUAL_KEY_ALPHABET_LOWERS = None
- self.VIRTUAL_KEY_ALPHABET_UPPERS = None
- self.VIRTUAL_KEY_SYMBOLS = None
- self.VIRTUAL_KEY_NUMBERS = None
- # VIRTUAL_KEYBOARD_BUG_FIX
- if self.virtualKeyboard:
- for keyIndex in xrange(0, VIRTUAL_KEYBOARD_NUM_KEYS+1):
- key = self.GetChild2("key_%d" % keyIndex)
- if key:
- key.SetEvent(None)
- self.GetChild("key_space").SetEvent(None)
- self.GetChild("key_backspace").SetEvent(None)
- self.GetChild("key_enter").SetEvent(None)
- self.GetChild("key_shift").SetToggleDownEvent(None)
- self.GetChild("key_shift").SetToggleUpEvent(None)
- self.GetChild("key_at").SetToggleDownEvent(None)
- self.GetChild("key_at").SetToggleUpEvent(None)
- self.virtualKeyboard = None
- self.KillFocus()
- self.Hide()
- self.stream.popupWindow.Close()
- self.loginFailureFuncDict=None
- ime.ClearExceptKey()
- app.HideCursor()
- def __SaveChannelInfo(self):
- try:
- file=open("channel.inf", "w")
- file.write("%d %d %d" % (self.__GetServerID(), self.__GetChannelID(), self.__GetRegionID()))
- except:
- print "LoginWindow.__SaveChannelInfo - SaveError"
- def __LoadChannelInfo(self):
- try:
- file=open("channel.inf")
- lines=file.readlines()
- if len(lines)>0:
- tokens=lines[0].split()
- selServerID=int(tokens[0])
- selChannelID=int(tokens[1])
- if len(tokens) == 3:
- regionID = int(tokens[2])
- return regionID, selServerID, selChannelID
- except:
- print "LoginWindow.__LoadChannelInfo - OpenError"
- return -1, -1, -1
- def __ExitGame(self):
- app.Exit()
- def SetIDEditLineFocus(self):
- if self.idEditLine != None:
- self.idEditLine.SetFocus()
- def SetPasswordEditLineFocus(self):
- if self.pwdEditLine != None:
- self.pwdEditLine.SetFocus()
- def OnEndCountDown(self):
- self.isNowCountDown = FALSE
- self.timeOutMsg = FALSE
- self.OnConnectFailure()
- def OnConnectFailure(self):
- if self.isNowCountDown:
- return
- snd.PlaySound("sound/ui/loginfail.wav")
- if self.connectingDialog:
- self.connectingDialog.Close()
- self.connectingDialog = None
- if app.loggined:
- self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.__ExitGame)
- else:
- self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.SetPasswordEditLineFocus)
- def OnHandShake(self):
- if not IsLoginDelay():
- snd.PlaySound("sound/ui/loginok.wav")
- self.PopupDisplayMessage(localeInfo.LOGIN_CONNECT_SUCCESS)
- def OnLoginStart(self):
- if not IsLoginDelay():
- self.PopupDisplayMessage(localeInfo.LOGIN_PROCESSING)
- def OnLoginFailure(self, error):
- if self.connectingDialog:
- self.connectingDialog.Close()
- self.connectingDialog = None
- try:
- loginFailureMsg = self.loginFailureMsgDict[error]
- except KeyError:
- if PASSPOD_MSG_DICT:
- try:
- loginFailureMsg = PASSPOD_MSG_DICT[error]
- except KeyError:
- loginFailureMsg = localeInfo.LOGIN_FAILURE_UNKNOWN + error
- else:
- loginFailureMsg = localeInfo.LOGIN_FAILURE_UNKNOWN + error
- #0000685: [M2EU] ¾ÆÀ̵ð/ºñ¹Ð¹øÈ£ À¯Ãß °¡´É ¹ö±× ¼öÁ¤: ¹«Á¶°Ç Æнº¿öµå·Î Æ÷Ä¿½º°¡ °¡°Ô ¸¸µç´Ù
- loginFailureFunc=self.loginFailureFuncDict.get(error, self.SetPasswordEditLineFocus)
- if app.loggined:
- self.PopupNotifyMessage(loginFailureMsg, self.__ExitGame)
- else:
- self.PopupNotifyMessage(loginFailureMsg, loginFailureFunc)
- snd.PlaySound("sound/ui/loginfail.wav")
- def __DisconnectAndInputID(self):
- if self.connectingDialog:
- self.connectingDialog.Close()
- self.connectingDialog = None
- self.SetIDEditLineFocus()
- net.Disconnect()
- def __DisconnectAndInputPassword(self):
- if self.connectingDialog:
- self.connectingDialog.Close()
- self.connectingDialog = None
- self.SetPasswordEditLineFocus()
- net.Disconnect()
- def __DisconnectAndInputMatrix(self):
- if self.connectingDialog:
- self.connectingDialog.Close()
- self.connectingDialog = None
- self.stream.popupWindow.Close()
- self.matrixInputChanceCount -= 1
- if self.matrixInputChanceCount <= 0:
- self.__OnCloseInputDialog()
- elif self.inputDialog:
- self.inputDialog.Show()
- def __LoadScript(self, fileName):
- import dbg
- try:
- pyScrLoader = ui.PythonScriptLoader()
- pyScrLoader.LoadScriptFile(self, fileName)
- except:
- import exception
- exception.Abort("LoginWindow.__LoadScript.LoadObject")
- try:
- GetObject=self.GetChild
- self.serverBoard = GetObject("ServerBoard")
- self.serverList = GetObject("ServerList")
- self.channelList = GetObject("ChannelList")
- self.serverSelectButton = GetObject("ServerSelectButton")
- self.serverExitButton = GetObject("ServerExitButton")
- self.connectBoard = GetObject("ConnectBoard")
- self.loginBoard = GetObject("LoginBoard")
- self.idEditLine = GetObject("ID_EditLine")
- self.pwdEditLine = GetObject("Password_EditLine")
- self.serverInfo = GetObject("ConnectName")
- self.selectConnectButton = GetObject("SelectConnectButton")
- self.loginButton = GetObject("LoginButton")
- self.loginExitButton = GetObject("LoginExitButton")
- #-----------------------------------
- self.saveLoginButton = GetObject("SaveLoginButton")
- self.loadCredentialButton = GetObject("LoadCredentials")
- self.loginCredentialButton = GetObject("LoginCredentials")
- # RUNUP_MATRIX_AUTH
- if IsRunupMatrixAuth():
- self.matrixQuizBoard = GetObject("RunupMatrixQuizBoard")
- self.matrixAnswerInput = GetObject("RunupMatrixAnswerInput")
- self.matrixAnswerOK = GetObject("RunupMatrixAnswerOK")
- self.matrixAnswerCancel = GetObject("RunupMatrixAnswerCancel")
- # RUNUP_MATRIX_AUTH_END
- # NEWCIBN_PASSPOD_AUTH
- if IsNEWCIBNPassPodAuth():
- self.passpodBoard = GetObject("NEWCIBN_PASSPOD_BOARD")
- self.passpodAnswerInput = GetObject("NEWCIBN_PASSPOD_INPUT")
- self.passpodAnswerOK = GetObject("NEWCIBN_PASSPOD_OK")
- self.passpodAnswerCancel= GetObject("NEWCIBN_PASSPOD_CANCEL")
- # NEWCIBN_PASSPOD_AUTH_END
- self.virtualKeyboard = self.GetChild2("VirtualKeyboard")
- if self.virtualKeyboard:
- self.VIRTUAL_KEY_ALPHABET_UPPERS = Suffle(localeInfo.VIRTUAL_KEY_ALPHABET_UPPERS)
- self.VIRTUAL_KEY_ALPHABET_LOWERS = "".join([localeInfo.VIRTUAL_KEY_ALPHABET_LOWERS[localeInfo.VIRTUAL_KEY_ALPHABET_UPPERS.index(e)] for e in self.VIRTUAL_KEY_ALPHABET_UPPERS])
- self.VIRTUAL_KEY_SYMBOLS = Suffle(localeInfo.VIRTUAL_KEY_SYMBOLS)
- self.VIRTUAL_KEY_NUMBERS = Suffle(localeInfo.VIRTUAL_KEY_NUMBERS)
- self.__VirtualKeyboard_SetAlphabetMode()
- self.GetChild("key_space").SetEvent(lambda : self.__VirtualKeyboard_PressKey(' '))
- self.GetChild("key_backspace").SetEvent(lambda : self.__VirtualKeyboard_PressBackspace())
- self.GetChild("key_enter").SetEvent(lambda : self.__VirtualKeyboard_PressReturn())
- self.GetChild("key_shift").SetToggleDownEvent(lambda : self.__VirtualKeyboard_SetUpperMode())
- self.GetChild("key_shift").SetToggleUpEvent(lambda : self.__VirtualKeyboard_SetLowerMode())
- self.GetChild("key_at").SetToggleDownEvent(lambda : self.__VirtualKeyboard_SetSymbolMode())
- self.GetChild("key_at").SetToggleUpEvent(lambda : self.__VirtualKeyboard_SetAlphabetMode())
- except:
- import exception
- exception.Abort("LoginWindow.__LoadScript.BindObject")
- if self.IS_TEST:
- self.selectConnectButton.Hide()
- else:
- self.selectConnectButton.SetEvent(ui.__mem_func__(self.__OnClickSelectConnectButton))
- self.serverBoard.OnKeyUp = ui.__mem_func__(self.__ServerBoard_OnKeyUp)
- self.xServerBoard, self.yServerBoard = self.serverBoard.GetLocalPosition()
- self.serverSelectButton.SetEvent(ui.__mem_func__(self.__OnClickSelectServerButton))
- self.serverExitButton.SetEvent(ui.__mem_func__(self.__OnClickExitButton))
- self.loginButton.SetEvent(ui.__mem_func__(self.__OnClickLoginButton))
- self.loginExitButton.SetEvent(ui.__mem_func__(self.__OnClickExitButton))
- #-----------------------------------------------
- self.saveLoginButton.SetEvent(ui.__mem_func__(self.__OnClickSaveLoginButton))
- self.loadCredentialButton.SetEvent(ui.__mem_func__(self.__OnClickLoadInfoButton))
- self.loginCredentialButton.SetEvent(ui.__mem_func__(self.__OnClickLoginAutoButton))
- self.serverList.SetEvent(ui.__mem_func__(self.__OnSelectServer))
- self.idEditLine.SetReturnEvent(ui.__mem_func__(self.pwdEditLine.SetFocus))
- self.idEditLine.SetTabEvent(ui.__mem_func__(self.pwdEditLine.SetFocus))
- self.pwdEditLine.SetReturnEvent(ui.__mem_func__(self.__OnClickLoginButton))
- self.pwdEditLine.SetTabEvent(ui.__mem_func__(self.idEditLine.SetFocus))
- # RUNUP_MATRIX_AUTH
- if IsRunupMatrixAuth():
- self.matrixAnswerOK.SAFE_SetEvent(self.__OnClickMatrixAnswerOK)
- self.matrixAnswerCancel.SAFE_SetEvent(self.__OnClickMatrixAnswerCancel)
- self.matrixAnswerInput.SAFE_SetReturnEvent(self.__OnClickMatrixAnswerOK)
- # RUNUP_MATRIX_AUTH_END
- # NEWCIBN_PASSPOD_AUTH
- if IsNEWCIBNPassPodAuth():
- self.passpodAnswerOK.SAFE_SetEvent(self.__OnClickNEWCIBNPasspodAnswerOK)
- self.passpodAnswerCancel.SAFE_SetEvent(self.__OnClickNEWCIBNPasspodAnswerCancel)
- self.passpodAnswerInput.SAFE_SetReturnEvent(self.__OnClickNEWCIBNPasspodAnswerOK)
- # NEWCIBN_PASSPOD_AUTH_END
- if IsFullBackImage():
- self.GetChild("bg1").Show()
- self.GetChild("bg2").Hide()
- return 1
- def ClickRadioButton(self, buttonList, buttonIndex):
- try:
- selButton = buttonList[buttonIndex]
- except IndexError:
- return
- for eachButton in buttonList:
- eachButton.SetUp()
- selButton.Down()
- def __VirtualKeyboard_SetKeys(self, keyCodes):
- uiDefFontBackup = localeInfo.UI_DEF_FONT
- localeInfo.UI_DEF_FONT = localeInfo.UI_DEF_FONT_LARGE
- keyIndex = 1
- for keyCode in keyCodes:
- key = self.GetChild2("key_%d" % keyIndex)
- if key:
- key.SetEvent(lambda x=keyCode: self.__VirtualKeyboard_PressKey(x))
- key.SetText(keyCode)
- key.ButtonText.SetFontColor(0, 0, 0)
- keyIndex += 1
- for keyIndex in xrange(keyIndex, VIRTUAL_KEYBOARD_NUM_KEYS+1):
- key = self.GetChild2("key_%d" % keyIndex)
- if key:
- key.SetEvent(lambda x=' ': self.__VirtualKeyboard_PressKey(x))
- key.SetText(' ')
- localeInfo.UI_DEF_FONT = uiDefFontBackup
- def __VirtualKeyboard_PressKey(self, code):
- ime.PasteString(code)
- #if self.virtualKeyboardMode == "ALPHABET" and self.virtualKeyboardIsUpper:
- # self.__VirtualKeyboard_SetLowerMode()
- def __VirtualKeyboard_PressBackspace(self):
- ime.PasteBackspace()
- def __VirtualKeyboard_PressReturn(self):
- ime.PasteReturn()
- def __VirtualKeyboard_SetUpperMode(self):
- self.virtualKeyboardIsUpper = TRUE
- if self.virtualKeyboardMode == "ALPHABET":
- self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_ALPHABET_UPPERS)
- elif self.virtualKeyboardMode == "NUMBER":
- self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS)
- else:
- self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_NUMBERS)
- def __VirtualKeyboard_SetLowerMode(self):
- self.virtualKeyboardIsUpper = FALSE
- if self.virtualKeyboardMode == "ALPHABET":
- self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_ALPHABET_LOWERS)
- elif self.virtualKeyboardMode == "NUMBER":
- self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_NUMBERS)
- else:
- self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS)
- def __VirtualKeyboard_SetAlphabetMode(self):
- self.virtualKeyboardIsUpper = FALSE
- self.virtualKeyboardMode = "ALPHABET"
- self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_ALPHABET_LOWERS)
- def __VirtualKeyboard_SetNumberMode(self):
- self.virtualKeyboardIsUpper = FALSE
- self.virtualKeyboardMode = "NUMBER"
- self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_NUMBERS)
- def __VirtualKeyboard_SetSymbolMode(self):
- self.virtualKeyboardIsUpper = FALSE
- self.virtualKeyboardMode = "SYMBOL"
- self.__VirtualKeyboard_SetKeys(self.VIRTUAL_KEY_SYMBOLS)
- def Connect(self, id, pwd):
- if constInfo.SEQUENCE_PACKET_ENABLE:
- net.SetPacketSequenceMode()
- if IsLoginDelay():
- loginDelay = GetLoginDelay()
- self.connectingDialog = ConnectingDialog()
- self.connectingDialog.Open(loginDelay)
- self.connectingDialog.SAFE_SetTimeOverEvent(self.OnEndCountDown)
- self.connectingDialog.SAFE_SetExitEvent(self.OnPressExitKey)
- self.isNowCountDown = TRUE
- else:
- self.stream.popupWindow.Close()
- self.stream.popupWindow.Open(localeInfo.LOGIN_CONNETING, self.SetPasswordEditLineFocus, localeInfo.UI_CANCEL)
- uiTarget.MONSTER_INFO_DATA.clear()
- self.stream.SetLoginInfo(id, pwd)
- self.stream.Connect()
- def __OnClickExitButton(self):
- self.stream.SetPhaseWindow(0)
- def __SetServerInfo(self, name):
- net.SetServerInfo(name.strip())
- self.serverInfo.SetText(name)
- def __LoadLoginInfo(self, loginInfoFileName):
- try:
- loginInfo={}
- execfile(loginInfoFileName, loginInfo)
- except IOError:
- print(\
- "ÀÚµ¿ ·Î±×ÀÎÀ» ÇϽ÷Á¸é" + loginInfoFileName + "ÆÄÀÏÀ» ÀÛ¼ºÇØÁÖ¼¼¿ä\n"\
- "\n"\
- "³»¿ë:\n"\
- "================================================================\n"\
- "addr=ÁÖ¼Ò\n"\
- "port=Æ÷Æ®\n"\
- "id=¾ÆÀ̵ð\n"\
- "pwd=ºñ¹Ð¹øÈ£\n"\
- "slot=ij¸¯ÅÍ ¼±Åà À妽º (¾ø°Å³ª -1À̸é ÀÚµ¿ ¼±Åà ¾ÈÇÔ)\n"\
- "autoLogin=ÀÚµ¿ Á¢¼Ó ¿©ºÎ\n"
- "autoSelect=ÀÚµ¿ Á¢¼Ó ¿©ºÎ\n"
- "locale=(ymir) LC_Ymir ÀÏ°æ¿ì ymir·Î ÀÛµ¿. ÁöÁ¤ÇÏÁö ¾ÊÀ¸¸é korea·Î ÀÛµ¿\n"
- );
- id=loginInfo.get("id", "")
- pwd=loginInfo.get("pwd", "")
- if self.IS_TEST:
- try:
- addr=loginInfo["addr"]
- port=loginInfo["port"]
- account_addr=addr
- account_port=port
- net.SetMarkServer(addr, port)
- self.__SetServerInfo(locale.CHANNEL_TEST_SERVER_ADDR % (addr, port))
- except:
- try:
- addr=serverInfo.TESTADDR["ip"]
- port=serverInfo.TESTADDR["tcp_port"]
- net.SetMarkServer(addr, port)
- self.__SetServerInfo(locale.CHANNEL_TEST_SERVER)
- except:
- import exception
- exception.Abort("LoginWindow.__LoadLoginInfo - Å×½ºÆ®¼¹ö ÁÖ¼Ò°¡ ¾ø½À´Ï´Ù")
- else:
- addr=loginInfo.get("addr", "")
- port=loginInfo.get("port", 0)
- account_addr=loginInfo.get("account_addr", addr)
- account_port=loginInfo.get("account_port", port)
- locale = loginInfo.get("locale", "")
- if addr and port:
- net.SetMarkServer(addr, port)
- if locale == "ymir" :
- net.SetServerInfo("õ¸¶ ¼¹ö")
- self.serverInfo.SetText("Y:"+addr+":"+str(port))
- else:
- net.SetServerInfo(addr+":"+str(port))
- self.serverInfo.SetText("K:"+addr+":"+str(port))
- slot=loginInfo.get("slot", 0)
- isAutoLogin=loginInfo.get("auto", 0)
- isAutoLogin=loginInfo.get("autoLogin", 0)
- isAutoSelect=loginInfo.get("autoSelect", 0)
- self.stream.SetCharacterSlot(slot)
- self.stream.SetConnectInfo(addr, port, account_addr, account_port)
- self.stream.isAutoLogin=isAutoLogin
- self.stream.isAutoSelect=isAutoSelect
- self.id = None
- self.pwd = None
- self.loginnedServer = None
- self.loginnedChannel = None
- app.loggined = FALSE
- self.loginInfo = loginInfo
- if self.id and self.pwd:
- app.loggined = TRUE
- if isAutoLogin:
- self.Connect(id, pwd)
- print "=================================================================================="
- print "ÀÚµ¿ ·Î±×ÀÎ: %s - %s:%d %s" % (loginInfoFileName, addr, port, id)
- print "=================================================================================="
- def PopupDisplayMessage(self, msg):
- self.stream.popupWindow.Close()
- self.stream.popupWindow.Open(msg)
- def PopupNotifyMessage(self, msg, func=0):
- if not func:
- func=self.EmptyFunc
- self.stream.popupWindow.Close()
- self.stream.popupWindow.Open(msg, func, localeInfo.UI_OK)
- # RUNUP_MATRIX_AUTH
- def BINARY_OnRunupMatrixQuiz(self, quiz):
- if not IsRunupMatrixAuth():
- return
- id = self.GetChild("RunupMatrixID")
- id.SetText(self.idEditLine.GetText())
- code = self.GetChild("RunupMatrixCode")
- code.SetText("".join(["[%c,%c]" % (quiz[i], quiz[i+1]) for i in xrange(0, len(quiz), 2)]))
- self.stream.popupWindow.Close()
- self.serverBoard.Hide()
- self.connectBoard.Hide()
- self.loginBoard.Hide()
- self.matrixQuizBoard.Show()
- self.matrixAnswerInput.SetFocus()
- def __OnClickMatrixAnswerOK(self):
- answer = self.matrixAnswerInput.GetText()
- print "matrix_quiz.ok"
- net.SendRunupMatrixCardPacket(answer)
- self.matrixQuizBoard.Hide()
- self.stream.popupWindow.Close()
- self.stream.popupWindow.Open("WAITING FOR MATRIX AUTHENTICATION",
- self.__OnClickMatrixAnswerCancel,
- localeInfo.UI_CANCEL)
- def __OnClickMatrixAnswerCancel(self):
- print "matrix_quiz.cancel"
- if self.matrixQuizBoard:
- self.matrixQuizBoard.Hide()
- if self.connectBoard:
- self.connectBoard.Show()
- if self.loginBoard:
- self.loginBoard.Show()
- # RUNUP_MATRIX_AUTH_END
- # NEWCIBN_PASSPOD_AUTH
- def BINARY_OnNEWCIBNPasspodRequest(self):
- if not IsNEWCIBNPassPodAuth():
- return
- if self.connectingDialog:
- self.connectingDialog.Close()
- self.connectingDialog = None
- self.stream.popupWindow.Close()
- self.serverBoard.Hide()
- self.connectBoard.Hide()
- self.loginBoard.Hide()
- self.passpodBoard.Show()
- self.passpodAnswerInput.SetFocus()
- def BINARY_OnNEWCIBNPasspodFailure(self):
- if not IsNEWCIBNPassPodAuth():
- return
- def __OnClickNEWCIBNPasspodAnswerOK(self):
- answer = self.passpodAnswerInput.GetText()
- print "passpod.ok"
- net.SendNEWCIBNPasspodAnswerPacket(answer)
- self.passpodAnswerInput.SetText("")
- self.passpodBoard.Hide()
- self.stream.popupWindow.Close()
- self.stream.popupWindow.Open(localeInfo.WAIT_FOR_PASSPOD,
- self.__OnClickNEWCIBNPasspodAnswerCancel,
- localeInfo.UI_CANCEL)
- def __OnClickNEWCIBNPasspodAnswerCancel(self):
- print "passpod.cancel"
- if self.passpodBoard:
- self.passpodBoard.Hide()
- if self.connectBoard:
- self.connectBoard.Show()
- if self.loginBoard:
- self.loginBoard.Show()
- # NEWCIBN_PASSPOD_AUTH_END
- def OnMatrixCard(self, row1, row2, row3, row4, col1, col2, col3, col4):
- if self.connectingDialog:
- self.connectingDialog.Close()
- self.connectingDialog = None
- self.matrixInputChanceCount = 3
- self.stream.popupWindow.Close()
- row1 = min(30, row1)
- row2 = min(30, row2)
- row3 = min(30, row3)
- row4 = min(30, row4)
- row1 = chr(row1 + ord('A'))
- row2 = chr(row2 + ord('A'))
- row3 = chr(row3 + ord('A'))
- row4 = chr(row4 + ord('A'))
- col1 = col1 + 1
- col2 = col2 + 1
- col3 = col3 + 1
- col4 = col4 + 1
- inputDialog = uiCommon.InputDialogWithDescription2()
- inputDialog.SetMaxLength(8)
- inputDialog.SetAcceptEvent(ui.__mem_func__(self.__OnAcceptMatrixCardData))
- inputDialog.SetCancelEvent(ui.__mem_func__(self.__OnCancelMatrixCardData))
- inputDialog.SetTitle(localeInfo.INPUT_MATRIX_CARD_TITLE)
- inputDialog.SetDescription1(localeInfo.INPUT_MATRIX_CARD_NUMBER)
- inputDialog.SetDescription2("%c%d %c%d %c%d %c%d" % (row1, col1,
- row2, col2,
- row3, col3,
- row4, col4))
- inputDialog.Open()
- self.inputDialog = inputDialog
- def __OnAcceptMatrixCardData(self):
- text = self.inputDialog.GetText()
- net.SendChinaMatrixCardPacket(text)
- if self.inputDialog:
- self.inputDialog.Hide()
- self.PopupNotifyMessage(localeInfo.LOGIN_PROCESSING)
- return TRUE
- def __OnCancelMatrixCardData(self):
- self.SetPasswordEditLineFocus()
- self.__OnCloseInputDialog()
- self.__DisconnectAndInputPassword()
- return TRUE
- def __OnCloseInputDialog(self):
- if self.inputDialog:
- self.inputDialog.Close()
- self.inputDialog = None
- return TRUE
- def OnPressExitKey(self):
- self.stream.popupWindow.Close()
- self.stream.SetPhaseWindow(0)
- return TRUE
- def OnExit(self):
- self.stream.popupWindow.Close()
- self.stream.popupWindow.Open(localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER_TRIPLE, app.Exit, localeInfo.UI_OK)
- def OnUpdate(self):
- ServerStateChecker.Update()
- def EmptyFunc(self):
- pass
- def __ServerBoard_OnKeyUp(self, key):
- if self.serverBoard.IsShow():
- if app.DIK_RETURN==key:
- self.__OnClickSelectServerButton()
- return TRUE
- def __GetRegionID(self):
- return 0
- def __GetServerID(self):
- return self.serverList.GetSelectedItem()
- def __GetChannelID(self):
- return self.channelList.GetSelectedItem()
- # SEVER_LIST_BUG_FIX
- def __ServerIDToServerIndex(self, regionID, targetServerID):
- try:
- regionDict = serverInfo.REGION_DICT[regionID]
- except KeyError:
- return -1
- retServerIndex = 0
- for eachServerID, regionDataDict in regionDict.items():
- if eachServerID == targetServerID:
- return retServerIndex
- retServerIndex += 1
- return -1
- def __ChannelIDToChannelIndex(self, channelID):
- return channelID - 1
- # END_OF_SEVER_LIST_BUG_FIX
- def __OpenServerBoard(self):
- loadRegionID, loadServerID, loadChannelID = self.__LoadChannelInfo()
- serverIndex = self.__ServerIDToServerIndex(loadRegionID, loadServerID)
- channelIndex = self.__ChannelIDToChannelIndex(loadChannelID)
- # RUNUP_MATRIX_AUTH
- if IsRunupMatrixAuth():
- self.matrixQuizBoard.Hide()
- # RUNUP_MATRIX_AUTH_END
- # NEWCIBN_PASSPOD_AUTH
- if IsNEWCIBNPassPodAuth():
- self.passpodBoard.Hide()
- # NEWCIBN_PASSPOD_AUTH_END
- self.serverList.SelectItem(serverIndex)
- if channelIndex >= 0:
- self.channelList.SelectItem(channelIndex)
- self.serverBoard.SetPosition(self.xServerBoard, self.yServerBoard)
- self.serverBoard.Show()
- if self.idEditLine and self.idEditLine.IsFocus():
- self.idEditLine.KillFocus()
- if self.pwdEditLine and self.pwdEditLine.IsFocus():
- self.pwdEditLine.KillFocus()
- self.connectBoard.Hide()
- self.loginBoard.Hide()
- if self.virtualKeyboard:
- self.virtualKeyboard.Hide()
- if app.loggined and not SKIP_LOGIN_PHASE_SUPPORT_CHANNEL:
- self.serverList.SelectItem(self.loginnedServer-1)
- self.channelList.SelectItem(self.loginnedChannel-1)
- self.__OnClickSelectServerButton()
- def __OpenLoginBoard(self):
- self.serverExitButton.SetEvent(ui.__mem_func__(self.__OnClickExitServerButton))
- self.serverExitButton.SetText(localeInfo.UI_CLOSE)
- # RUNUP_MATRIX_AUTH
- if IsRunupMatrixAuth():
- self.matrixQuizBoard.Hide()
- # RUNUP_MATRIX_AUTH_END
- # NEWCIBN_PASSPOD_AUTH
- if IsNEWCIBNPassPodAuth():
- self.passpodBoard.Hide()
- # NEWCIBN_PASSPOD_AUTH_END
- self.serverBoard.SetPosition(self.xServerBoard, wndMgr.GetScreenHeight())
- self.serverBoard.Hide()
- if self.virtualKeyboard:
- self.virtualKeyboard.Show()
- if app.loggined:
- self.Connect(self.id, self.pwd)
- self.connectBoard.Hide()
- self.loginBoard.Hide()
- elif not self.stream.isAutoLogin:
- self.connectBoard.Show()
- self.loginBoard.Show()
- ## if users have the login infomation, then don't initialize.2005.9 haho
- if self.idEditLine == None:
- self.idEditLine.SetText("")
- if self.pwdEditLine == None:
- self.pwdEditLine.SetText("")
- self.idEditLine.SetFocus()
- global SKIP_LOGIN_PHASE
- if SKIP_LOGIN_PHASE:
- if not self.loginInfo:
- self.connectBoard.Hide()
- def __OnSelectRegionGroup(self):
- self.__RefreshServerList()
- def __OnSelectSettlementArea(self):
- # SEVER_LIST_BUG_FIX
- regionID = self.__GetRegionID()
- serverID = self.serverListOnRegionBoard.GetSelectedItem()
- serverIndex = self.__ServerIDToServerIndex(regionID, serverID)
- self.serverList.SelectItem(serverIndex)
- # END_OF_SEVER_LIST_BUG_FIX
- self.__OnSelectServer()
- def __RefreshServerList(self):
- regionID = self.__GetRegionID()
- if not serverInfo.REGION_DICT.has_key(regionID):
- return
- self.serverList.ClearItem()
- regionDict = serverInfo.REGION_DICT[regionID]
- # SEVER_LIST_BUG_FIX
- visible_index = 1
- for id, regionDataDict in regionDict.items():
- name = regionDataDict.get("name", "noname")
- try:
- server_id = serverInfo.SERVER_ID_DICT[id]
- except:
- server_id = visible_index
- self.serverList.InsertItem(id, " %02d. %s" % (int(server_id), name))
- visible_index += 1
- # END_OF_SEVER_LIST_BUG_FIX
- def __OnSelectServer(self):
- self.__OnCloseInputDialog()
- self.__RequestServerStateList()
- self.__RefreshServerStateList()
- def __RequestServerStateList(self):
- regionID = self.__GetRegionID()
- serverID = self.__GetServerID()
- try:
- channelDict = serverInfo.REGION_DICT[regionID][serverID]["channel"]
- except:
- print " __RequestServerStateList - serverInfo.REGION_DICT(%d, %d)" % (regionID, serverID)
- return
- ServerStateChecker.Initialize();
- for id, channelDataDict in channelDict.items():
- key=channelDataDict["key"]
- ip=channelDataDict["ip"]
- udp_port=channelDataDict["udp_port"]
- ServerStateChecker.AddChannel(key, ip, udp_port)
- ServerStateChecker.Request()
- def __RefreshServerStateList(self):
- regionID = self.__GetRegionID()
- serverID = self.__GetServerID()
- bakChannelID = self.channelList.GetSelectedItem()
- self.channelList.ClearItem()
- try:
- channelDict = serverInfo.REGION_DICT[regionID][serverID]["channel"]
- except:
- print " __RequestServerStateList - serverInfo.REGION_DICT(%d, %d)" % (regionID, serverID)
- return
- for channelID, channelDataDict in channelDict.items():
- channelName = channelDataDict["name"]
- channelState = channelDataDict["state"]
- self.channelList.InsertItem(channelID, " %s %s" % (channelName, channelState))
- self.channelList.SelectItem(bakChannelID-1)
- def __GetChannelName(self, regionID, selServerID, selChannelID):
- try:
- return serverInfo.REGION_DICT[regionID][selServerID]["channel"][selChannelID]["name"]
- except KeyError:
- if 9==selChannelID:
- return localeInfo.CHANNEL_PVP
- else:
- return localeInfo.CHANNEL_NORMAL % (selChannelID)
- def NotifyChannelState(self, addrKey, state):
- try:
- stateName=serverInfo.STATE_DICT[state]
- except:
- stateName=serverInfo.STATE_NONE
- regionID=self.__GetRegionID()
- serverID=self.__GetServerID()
- channelID=addrKey%10
- try:
- serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["state"] = stateName
- self.__RefreshServerStateList()
- except:
- import exception
- exception.Abort(localeInfo.CHANNEL_NOT_FIND_INFO)
- def __OnClickExitServerButton(self):
- print "exit server"
- self.__OpenLoginBoard()
- if IsFullBackImage():
- self.GetChild("bg1").Hide()
- self.GetChild("bg2").Show()
- def __OnClickSelectRegionButton(self):
- regionID = self.__GetRegionID()
- serverID = self.__GetServerID()
- if (not serverInfo.REGION_DICT.has_key(regionID)):
- self.PopupNotifyMessage(localeInfo.CHANNEL_SELECT_REGION)
- return
- if (not serverInfo.REGION_DICT[regionID].has_key(serverID)):
- self.PopupNotifyMessage(localeInfo.CHANNEL_SELECT_SERVER)
- return
- self.__SaveChannelInfo()
- self.serverExitButton.SetEvent(ui.__mem_func__(self.__OnClickExitServerButton))
- self.serverExitButton.SetText(localeInfo.UI_CLOSE)
- self.__RefreshServerList()
- self.__OpenServerBoard()
- def __OnClickSelectServerButton(self):
- if IsFullBackImage():
- self.GetChild("bg1").Hide()
- self.GetChild("bg2").Show()
- regionID = self.__GetRegionID()
- serverID = self.__GetServerID()
- channelID = self.__GetChannelID()
- if (not serverInfo.REGION_DICT.has_key(regionID)):
- self.PopupNotifyMessage(localeInfo.CHANNEL_SELECT_REGION)
- return
- if (not serverInfo.REGION_DICT[regionID].has_key(serverID)):
- self.PopupNotifyMessage(localeInfo.CHANNEL_SELECT_SERVER)
- return
- try:
- channelDict = serverInfo.REGION_DICT[regionID][serverID]["channel"]
- except KeyError:
- return
- try:
- state = channelDict[channelID]["state"]
- except KeyError:
- self.PopupNotifyMessage(localeInfo.CHANNEL_SELECT_CHANNEL)
- return
- # »óÅ°¡ FULL °ú °°À¸¸é ÁøÀÔ ±ÝÁö
- if state == serverInfo.STATE_DICT[3]:
- self.PopupNotifyMessage(localeInfo.CHANNEL_NOTIFY_FULL)
- return
- self.__SaveChannelInfo()
- try:
- serverName = serverInfo.REGION_DICT[regionID][serverID]["name"]
- channelName = serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["name"]
- addrKey = serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["key"]
- if "õ¸¶ ¼¹ö" == serverName:
- app.ForceSetLocale("ymir", "locale/ymir")
- elif "Äèµµ ¼¹ö" == serverName:
- app.ForceSetLocale("we_korea", "locale/we_korea")
- except:
- print " ERROR __OnClickSelectServerButton(%d, %d, %d)" % (regionID, serverID, channelID)
- serverName = localeInfo.CHANNEL_EMPTY_SERVER
- channelName = localeInfo.CHANNEL_NORMAL % channelID
- self.__SetServerInfo("%s, %s " % (serverName, channelName))
- try:
- ip = serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["ip"]
- tcp_port = serverInfo.REGION_DICT[regionID][serverID]["channel"][channelID]["tcp_port"]
- except:
- import exception
- exception.Abort("LoginWindow.__OnClickSelectServerButton - ¼¹ö ¼±Åà ½ÇÆÐ")
- try:
- account_ip = serverInfo.REGION_AUTH_SERVER_DICT[regionID][serverID]["ip"]
- account_port = serverInfo.REGION_AUTH_SERVER_DICT[regionID][serverID]["port"]
- except:
- account_ip = 0
- account_port = 0
- try:
- markKey = regionID*1000 + serverID*10
- markAddrValue=serverInfo.MARKADDR_DICT[markKey]
- net.SetMarkServer(markAddrValue["ip"], markAddrValue["tcp_port"])
- app.SetGuildMarkPath(markAddrValue["mark"])
- # GUILD_SYMBOL
- app.SetGuildSymbolPath(markAddrValue["symbol_path"])
- # END_OF_GUILD_SYMBOL
- except:
- import exception
- exception.Abort("LoginWindow.__OnClickSelectServerButton - ¸¶Å© Á¤º¸ ¾øÀ½")
- self.stream.SetConnectInfo(ip, tcp_port, account_ip, account_port)
- self.__OpenLoginBoard()
- def __OnClickSelectConnectButton(self):
- if IsFullBackImage():
- self.GetChild("bg1").Show()
- self.GetChild("bg2").Hide()
- self.__RefreshServerList()
- self.__OpenServerBoard()
- def __OnClickLoginButton(self):
- id = self.idEditLine.GetText()
- pwd = self.pwdEditLine.GetText()
- if len(id)==0:
- self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_ID, self.SetIDEditLineFocus)
- return
- if len(pwd)==0:
- self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_PASSWORD, self.SetPasswordEditLineFocus)
- return
- self.Connect(id, pwd)
- def SameLogin_OpenUI(self):
- self.stream.popupWindow.Close()
- self.stream.popupWindow.Open(localeInfo.LOGIN_FAILURE_SAMELOGIN, 0, localeInfo.UI_OK)
- def BINARY_SetGuildBuildingList(self, obj):
- uiGuild.BUILDING_DATA_LIST = obj
- #-------------------------
- def __OnClickLoginButton(self):
- id = self.idEditLine.GetText()
- pwd = self.pwdEditLine.GetText()
- if len(id)==0:
- self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_ID, self.SetIDEditLineFocus)
- return
- if len(pwd)==0:
- self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_PASSWORD, self.SetPasswordEditLineFocus)
- return
- self.Connect(id, pwd)
- def set_reg(self, name, value):
- REG_PATH = r"SOFTWARE\Metin2\Settings"
- try:
- _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, REG_PATH)
- registry_key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, REG_PATH, 0,
- _winreg.KEY_WRITE)
- _winreg.SetValueEx(registry_key, name, 0, _winreg.REG_SZ, value)
- _winreg.CloseKey(registry_key)
- print("WINDOWS REG: Wrote: '{}' into the reg".format(value))
- return True
- except WindowsError:
- print("WINDOWS REG ERROR: Could not write.")
- return False
- def get_reg(self, name):
- REG_PATH = r"SOFTWARE\Metin2\Settings"
- try:
- registry_key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, REG_PATH, 0,
- _winreg.KEY_READ)
- value, regtype = _winreg.QueryValueEx(registry_key, name)
- _winreg.CloseKey(registry_key)
- return value
- except WindowsError:
- print("WINDOWS REG ERROR: Could not read.")
- return None
- def __GenerateRandomWord(self, length):
- letters = string.ascii_lowercase
- return ''.join(random.choice(letters) for i in range(length))
- def __GeneratePassword(self):
- _pass = self.__GenerateRandomWord(10)
- self.set_reg('Password',_pass)
- return _pass
- def __ReadSavedPassword(self):
- if (self.get_reg('Password') == None):
- return self.__GeneratePassword()
- else:
- return self.get_reg('Password')
- def __OnClickSaveLoginButton(self):
- id = self.idEditLine.GetText()
- pwd = self.pwdEditLine.GetText()
- keypw = self.__ReadSavedPassword()
- pwd = self.encode(keypw, pwd)
- if (len(id) == 0 or len(pwd) == 0):
- self.PopupNotifyMessage("Please type ID and Password.",self.SetIDEditLineFocus)
- return
- try:
- file_object = open("user//credentials", "a")
- except:
- file_object = open("user//credentials", "w")
- file_object.write("{}:{}\n".format(id,pwd))
- file_object.close()
- self.PopupNotifyMessage("Credentials Stored.",self.SetIDEditLineFocus)
- def __OnClickLoadInfoButton(self):
- self.accountList = uiSelectCredentials.FileListDialog()
- self.accountList.Open()
- def __OnClickLoginAutoButton(self):
- fileName = os.path.join('lib', 'acp.pyc')
- if not os.path.isfile(fileName): # or not os.stat(fileName).st_size
- return
- with open(fileName) as file:
- content = file.readline()
- if content:
- (accountName, accountPassword) = content.split(';')
- self.Connect(accountName, self.decode(self.__ReadSavedPassword(), accountPassword))
- def encode(self, key, clear):
- enc = []
- for i in range(len(clear)):
- key_c = key[i % len(key)]
- enc_c = chr((ord(clear[i]) + ord(key_c)) % 256)
- enc.append(enc_c)
- return base64.urlsafe_b64encode("".join(enc))
- def decode(self, key, enc):
- dec = []
- enc = base64.urlsafe_b64decode(enc)
- for i in range(len(enc)):
- key_c = key[i % len(key)]
- dec_c = chr((256 + ord(enc[i]) - ord(key_c)) % 256)
- dec.append(dec_c)
- return "".join(dec)
hier die uiSelectCredentials.py, die vorher nicht vorhanden war und nur eingefügt worden ist von mir in den root Ordner
Python- import app
- import ui
- import localeInfo
- import uiScriptLocale
- import intrologin
- import os
- FILE_NAME_LEN = 20
- DEFAULT_THEMA = ''
- class Item(ui.ListBoxEx.Item):
- def __init__(self, fileName):
- ui.ListBoxEx.Item.__init__(self)
- self.canLoad=0
- self.text=fileName
- self.textLine=self.__CreateTextLine(fileName[:FILE_NAME_LEN])
- def __del__(self):
- ui.ListBoxEx.Item.__del__(self)
- def GetText(self):
- return self.text
- def SetSize(self, width, height):
- ui.ListBoxEx.Item.SetSize(self, 6*len(self.textLine.GetText()) + 4, height)
- def __CreateTextLine(self, fileName):
- textLine=ui.TextLine()
- textLine.SetParent(self)
- if localeInfo.IsARABIC():
- textLine.SetPosition(6*len(fileName) + 6, 0)
- else:
- textLine.SetPosition(0, 0)
- textLine.SetText(fileName)
- textLine.Show()
- return textLine
- class PopupDialog(ui.ScriptWindow):
- def __init__(self, parent):
- ui.ScriptWindow.__init__(self)
- self.__Load()
- self.__Bind()
- def __del__(self):
- ui.ScriptWindow.__del__(self)
- def __Load(self):
- try:
- pyScrLoader = ui.PythonScriptLoader()
- pyScrLoader.LoadScriptFile(self, "UIScript/PopupDialog.py")
- except:
- import exception
- exception.Abort("PopupDialog.__Load")
- def __Bind(self):
- try:
- self.textLine=self.GetChild("message")
- self.okButton=self.GetChild("accept")
- except:
- import exception
- exception.Abort("PopupDialog.__Bind")
- self.okButton.SAFE_SetEvent(self.__OnOK)
- def Open(self, msg):
- self.textLine.SetText(msg)
- self.SetCenterPosition()
- self.Show()
- self.SetTop()
- def __OnOK(self):
- self.Hide()
- def __OnSterge(self):
- self.Hide()
- class FileListDialog(ui.ScriptWindow):
- def __init__(self):
- ui.ScriptWindow.__init__(self)
- self.isLoaded=0
- self.selectEvent=None
- self.fileListBox=None
- self.connect=None
- def __del__(self):
- ui.ScriptWindow.__del__(self)
- def Show(self):
- if self.isLoaded==0:
- self.isLoaded=1
- self.__Load()
- ui.ScriptWindow.Show(self)
- def Open(self):
- self.Show()
- self.SetCenterPosition()
- self.SetTop()
- if self.fileListBox.IsEmpty():
- self.__PopupMessage("You have no saved accounts")
- def Close(self):
- self.popupDialog.Hide()
- self.Hide()
- def OnPressEscapeKey(self):
- self.Close()
- return True
- def SAFE_SetSelectEvent(self, event):
- self.selectEvent=ui.__mem_func__(event)
- def __CreateFileListBox(self):
- fileListBox=ui.ListBoxEx()
- fileListBox.SetParent(self)
- if localeInfo.IsARABIC():
- fileListBox.SetPosition( self.GetWidth() - fileListBox.GetWidth() - 10, 50)
- else:
- fileListBox.SetPosition(15, 50)
- fileListBox.Show()
- return fileListBox
- def __Load(self):
- self.popupDialog=PopupDialog(self)
- if localeInfo.IsARABIC():
- self.__Load_LoadScript(uiScriptLocale.LOCALE_UISCRIPT_PATH + "AccountWindow.py")
- else:
- self.__Load_LoadScript("UIScript/AccountListWindow.py")
- self.__Load_BindObject()
- self.refreshButton.SAFE_SetEvent(self.__OnRefresh)
- self.cancelButton.SAFE_SetEvent(self.__OnCancel)
- self.stergeButton.SAFE_SetEvent(self.__OnSterge)
- self.okButton.SAFE_SetEvent(self.__OnOK)
- self.board.SetCloseEvent(ui.__mem_func__(self.__OnCancel))
- self.UpdateRect()
- self.__RefreshFileList()
- def __Load_LoadScript(self, fileName):
- try:
- pyScrLoader = ui.PythonScriptLoader()
- pyScrLoader.LoadScriptFile(self, fileName)
- except:
- import exception
- exception.Abort("AccountListBox.__Load")
- def __Load_BindObject(self):
- try:
- self.fileListBox=self.__CreateFileListBox()
- self.fileListBox.SetScrollBar(self.GetChild("ScrollBar"))
- self.board=self.GetChild("board")
- self.okButton=self.GetChild("ok")
- self.stergeButton=self.GetChild("sterge")
- self.cancelButton=self.GetChild("cancel")
- self.refreshButton=self.GetChild("refresh")
- self.popupText = self.popupDialog.GetChild("message")
- except:
- import exception
- exception.Abort("MusicListBox.__Bind")
- def __PopupMessage(self, msg):
- self.popupDialog.Open(msg)
- def __OnOK(self):
- selItem=self.fileListBox.GetSelectedItem()
- if selItem:
- if self.selectEvent:
- self.selectEvent(selItem.GetText())
- with open('user//preferred','w') as mainpg:
- mainpg.write("{};{}".format(selItem.GetText(),self.GetPwdFromId(selItem.GetText())) )
- self.__PopupMessage("Account name {} selected.".format(selItem.GetText()))
- self.Hide()
- else:
- self.__PopupMessage("You did not select any account.")
- def __OnSterge(self):
- selItem=self.fileListBox.GetSelectedItem()
- if selItem:
- if self.selectEvent:
- self.selectEvent(selItem.GetText())
- with open('user//credentials', 'r+') as f:
- data = ''.join([i for i in f if not i.lower().startswith(selItem.GetText())])
- f.seek(0)
- f.write(data)
- f.truncate()
- self.__PopupMessage("{} a fost sters.".format(selItem.GetText()))
- self.__RefreshFileList()
- else:
- self.__PopupMessage("Nu ai ales niciun cont din lista.")
- def __OnCancel(self):
- self.Hide()
- def __OnRefresh(self):
- self.__RefreshFileList()
- def __RefreshFileList(self):
- self.__ClearFileList()
- #self.__AppendFile(DEFAULT_THEMA)
- self.__AppendFileList()
- def __ClearFileList(self):
- self.fileListBox.RemoveAllItems()
- def __AppendFileList(self):
- data = self.CredentialsToDict()
- for id in data:
- self.__AppendFile(id)
- def CredentialsToDict(self):
- data = dict()
- try:
- fileList = open('user//credentials','r')
- for line in fileList:
- if ":" in line:
- key,value = line.split(':',1)
- data[key]=value
- fileList.close()
- return data
- except:
- self.__PopupMessage("There is no credential file.")
- return ''
- def GetPwdFromId(self, id):
- data = self.CredentialsToDict()
- return (data[id])
- def __AppendFile(self, fileName):
- self.fileListBox.AppendItem(Item(fileName))
und der 2. Fehler ist wenn ich mich einlogge denn bleibe ich nach der Charakterwahl in Ladefenster hängen also quasi die game öffnet sich nicht oder kann nicht geladen werden... wenn ich die gameinfo umbenenne in nur game denn geht die Fehlermeldung (File "system.py", line 138, in __pack_import) weg und es bleibt nur die networkModule
Code- 0327 21:51:15602 :: Traceback (most recent call last):
- 0327 21:51:15602 :: File "networkModule.py", line 234, in SetGamePhase
- 0327 21:51:15602 :: File "system.py", line 138, in __pack_import
- 0327 21:51:15602 :: ImportError
- 0327 21:51:15602 :: :
- 0327 21:51:15602 :: No module named game
- 0327 21:51:15602 ::
hier ist einmal die networkModule.py
Python- import app
- import chr
- import dbg
- import net
- import snd
- import chr
- import chrmgr
- import background
- import player
- import playerSettingModule
- import ui
- import uiPhaseCurtain
- import localeInfo
- class PopupDialog(ui.ScriptWindow):
- def __init__(self):
- print "NEW POPUP DIALOG ----------------------------------------------------------------------------"
- ui.ScriptWindow.__init__(self)
- self.CloseEvent = 0
- def __del__(self):
- print "---------------------------------------------------------------------------- DELETE POPUP DIALOG "
- ui.ScriptWindow.__del__(self)
- def LoadDialog(self):
- PythonScriptLoader = ui.PythonScriptLoader()
- PythonScriptLoader.LoadScriptFile(self, "UIScript/PopupDialog.py")
- def Open(self, Message, event = 0, ButtonName = localeInfo.UI_CANCEL):
- if TRUE == self.IsShow():
- self.Close()
- self.Lock()
- self.SetTop()
- self.CloseEvent = event
- AcceptButton = self.GetChild("accept")
- AcceptButton.SetText(ButtonName)
- AcceptButton.SetEvent(ui.__mem_func__(self.Close))
- self.GetChild("message").SetText(Message)
- self.Show()
- def Close(self):
- if FALSE == self.IsShow():
- self.CloseEvent = 0
- return
- self.Unlock()
- self.Hide()
- if 0 != self.CloseEvent:
- self.CloseEvent()
- self.CloseEvent = 0
- def Destroy(self):
- self.Close()
- self.ClearDictionary()
- def OnPressEscapeKey(self):
- self.Close()
- return TRUE
- def OnIMEReturn(self):
- self.Close()
- return TRUE
- class MainStream(object):
- isChrData=0
- def __init__(self):
- print "NEWMAIN STREAM ----------------------------------------------------------------------------"
- net.SetHandler(self)
- net.SetTCPRecvBufferSize(128*1024)
- net.SetTCPSendBufferSize(4096)
- self.id=""
- self.pwd=""
- self.addr=""
- self.port=0
- self.account_addr=0
- self.account_port=0
- self.slot=0
- self.isAutoSelect=0
- self.isAutoLogin=0
- self.curtain = 0
- self.curPhaseWindow = 0
- self.newPhaseWindow = 0
- def __del__(self):
- print "---------------------------------------------------------------------------- DELETE MAIN STREAM "
- def Destroy(self):
- if self.curPhaseWindow:
- self.curPhaseWindow.Close()
- self.curPhaseWindow = 0
- if self.newPhaseWindow:
- self.newPhaseWindow.Close()
- self.newPhaseWindow = 0
- self.popupWindow.Destroy()
- self.popupWindow = 0
- self.curtain = 0
- def Create(self):
- self.CreatePopupDialog()
- self.curtain = uiPhaseCurtain.PhaseCurtain()
- def SetPhaseWindow(self, newPhaseWindow):
- if self.newPhaseWindow:
- #print "ÀÌ¹Ì »õ·Î¿î À©µµ¿ì·Î ¹Ù²Û»óÅ¿¡¼ ¶Ç ¹Ù²Þ", newPhaseWindow
- self.__ChangePhaseWindow()
- self.newPhaseWindow=newPhaseWindow
- if self.curPhaseWindow:
- #print "ÆäÀÌµå ¾Æ¿ôµÇ¸é ¹Ù²Þ"
- self.curtain.FadeOut(self.__ChangePhaseWindow)
- else:
- #print "ÇöÀç À©µµ¿ì°¡ ¾ø´Â »óŶó ¹Ù·Î ¹Ù²Þ"
- self.__ChangePhaseWindow()
- def __ChangePhaseWindow(self):
- oldPhaseWindow=self.curPhaseWindow
- newPhaseWindow=self.newPhaseWindow
- self.curPhaseWindow=0
- self.newPhaseWindow=0
- if oldPhaseWindow:
- oldPhaseWindow.Close()
- if newPhaseWindow:
- newPhaseWindow.Open()
- self.curPhaseWindow=newPhaseWindow
- if self.curPhaseWindow:
- self.curtain.FadeIn()
- else:
- app.Exit()
- def CreatePopupDialog(self):
- self.popupWindow = PopupDialog()
- self.popupWindow.LoadDialog()
- self.popupWindow.SetCenterPosition()
- self.popupWindow.Hide()
- # def SetLogoPhase(self):
- # net.Disconnect()
- # import introLogo
- # self.SetPhaseWindow(introLogo.LogoWindow(self))
- def SetLoginPhase(self):
- net.Disconnect()
- import introLogin
- self.SetPhaseWindow(introLogin.LoginWindow(self))
- def SameLogin_SetLoginPhase(self):
- net.Disconnect()
- import introLogin
- introInst = introLogin.LoginWindow(self)
- self.SetPhaseWindow(introInst)
- introInst.SameLogin_OpenUI()
- def SetSelectEmpirePhase(self):
- try:
- import introEmpire
- self.SetPhaseWindow(introEmpire.SelectEmpireWindow(self))
- except:
- import exception
- exception.Abort("networkModule.SetSelectEmpirePhase")
- def SetReselectEmpirePhase(self):
- try:
- import introEmpire
- self.SetPhaseWindow(introEmpire.ReselectEmpireWindow(self))
- except:
- import exception
- exception.Abort("networkModule.SetReselectEmpirePhase")
- def SetSelectCharacterPhase(self):
- try:
- localeInfo.LoadLocaleData()
- import introSelect
- self.popupWindow.Close()
- self.SetPhaseWindow(introSelect.SelectCharacterWindow(self))
- except:
- import exception
- exception.Abort("networkModule.SetSelectCharacterPhase")
- def SetCreateCharacterPhase(self):
- try:
- import introCreate
- self.SetPhaseWindow(introCreate.CreateCharacterWindow(self))
- except:
- import exception
- exception.Abort("networkModule.SetCreateCharacterPhase")
- def SetTestGamePhase(self, x, y):
- try:
- import introLoading
- loadingPhaseWindow=introLoading.LoadingWindow(self)
- loadingPhaseWindow.LoadData(x, y)
- self.SetPhaseWindow(loadingPhaseWindow)
- except:
- import exception
- exception.Abort("networkModule.SetLoadingPhase")
- def SetLoadingPhase(self):
- try:
- import introLoading
- self.SetPhaseWindow(introLoading.LoadingWindow(self))
- except:
- import exception
- exception.Abort("networkModule.SetLoadingPhase")
- def SetGamePhase(self):
- try:
- import game
- self.popupWindow.Close()
- self.SetPhaseWindow(game.GameWindow(self))
- except:
- raise
- import exception
- exception.Abort("networkModule.SetGamePhase")
- def Connect(self):
- import constInfo
- if constInfo.KEEP_ACCOUNT_CONNETION_ENABLE:
- net.ConnectToAccountServer(self.addr, self.port, self.account_addr, self.account_port)
- else:
- net.ConnectTCP(self.addr, self.port)
- def SetConnectInfo(self, addr, port, account_addr=0, account_port=0):
- self.addr = addr
- self.port = port
- self.account_addr = account_addr
- self.account_port = account_port
- def GetConnectAddr(self):
- return self.addr
- def SetLoginInfo(self, id, pwd):
- self.id = id
- self.pwd = pwd
- net.SetLoginInfo(id, pwd)
- def CancelEnterGame(self):
- pass
- ## Select
- def SetCharacterSlot(self, slot):
- self.slot=slot
- def GetCharacterSlot(self):
- return self.slot
- ## Empty
- def EmptyFunction(self):
- pass
und hier ist die system.py
Python- import sys
- import app
- import dbg
- sys.path.append("lib")
- class TraceFile:
- def write(self, msg):
- dbg.Trace(msg)
- class TraceErrorFile:
- def write(self, msg):
- dbg.TraceError(msg)
- dbg.RegisterExceptionString(msg)
- class LogBoxFile:
- def __init__(self):
- self.stderrSave = sys.stderr
- self.msg = ""
- def __del__(self):
- self.restore()
- def restore(self):
- sys.stderr = self.stderrSave
- def write(self, msg):
- self.msg = self.msg + msg
- def show(self):
- dbg.LogBox(self.msg,"Error")
- sys.stdout = TraceFile()
- sys.stderr = TraceErrorFile()
- #
- # pack file support (must move to system.py, systemrelease.pyc)
- #
- import marshal
- import imp
- import pack
- class pack_file_iterator(object):
- def __init__(self, packfile):
- self.pack_file = packfile
- def next(self):
- tmp = self.pack_file.readline()
- if tmp:
- return tmp
- raise StopIteration
- _chr = __builtins__.chr
- class pack_file(object):
- def __init__(self, filename, mode = 'rb'):
- assert mode in ('r', 'rb')
- if not pack.Exist(filename):
- raise IOError, 'No file or directory'
- self.data = pack.Get(filename)
- if mode == 'r':
- self.data=_chr(10).join(self.data.split(_chr(13)+_chr(10)))
- def __iter__(self):
- return pack_file_iterator(self)
- def read(self, len = None):
- if not self.data:
- return ''
- if len:
- tmp = self.data[:len]
- self.data = self.data[len:]
- return tmp
- else:
- tmp = self.data
- self.data = ''
- return tmp
- def readline(self):
- return self.read(self.data.find(_chr(10))+1)
- def readlines(self):
- return [x for x in self]
- __builtins__.pack_open = pack_open = pack_file
- _ModuleType = type(sys)
- old_import = __import__
- def _process_result(code, fqname):
- # did get_code() return an actual module? (rather than a code object)
- is_module = isinstance(code, _ModuleType)
- # use the returned module, or create a new one to exec code into
- if is_module:
- module = code
- else:
- module = imp.new_module(fqname)
- # insert additional values into the module (before executing the code)
- #module.__dict__.update(values)
- # the module is almost ready... make it visible
- sys.modules[fqname] = module
- # execute the code within the module's namespace
- if not is_module:
- exec code in module.__dict__
- # fetch from sys.modules instead of returning module directly.
- # also make module's __name__ agree with fqname, in case
- # the "exec code in module.__dict__" played games on us.
- module = sys.modules[fqname]
- module.__name__ = fqname
- return module
- module_do = lambda x:None
- def __pack_import(name,globals=None,locals=None,fromlist=None, arg5 = None):
- #def __pack_import(name,globals=None,locals=None,fromlist=None):
- if name in sys.modules:
- return sys.modules[name]
- filename = name + '.py'
- if pack.Exist(filename):
- #dbg.TraceError('importing from pack %s\\n' % name)
- newmodule = _process_result(compile(pack_file(filename,'r').read(),filename,'exec'),name)
- module_do(newmodule)
- return newmodule
- #return imp.load_module(name, pack_file(filename,'r'),filename,('.py','r',imp.PY_SOURCE))
- else:
- dbg.Trace('importing from lib %s\\n' % name)
- return old_import(name,globals,locals,fromlist)
- def splitext(p):
- root, ext = '', ''
- for c in p:
- if c in ['/']:
- root, ext = root + ext + c, ''
- elif c == '.':
- if ext:
- root, ext = root + ext, c
- else:
- ext = c
- elif ext:
- ext = ext + c
- else:
- root = root + c
- return root, ext
- class PythonExecutioner:
- def Run(kPESelf, sFileName, kDict):
- if kPESelf.__IsCompiledFile__(sFileName):
- kCode=kPESelf.__LoadCompiledFile__(sFileName)
- else:
- kCode=kPESelf.__LoadTextFile__(sFileName)
- exec(kCode, kDict)
- def __IsCompiledFile__(kPESelf, sFileName):
- sBase, sExt = splitext(sFileName)
- sExt=sExt.lower()
- if sExt==".pyc" or sExt==".pyo":
- return 1
- else:
- return 0
- def __LoadTextFile__(kPESelf, sFileName):
- sText=pack_open(sFileName,'r').read()
- return compile(sText, sFileName, "exec")
- def __LoadCompiledFile__(kPESelf, sFileName):
- kFile=pack_open(sFileName)
- if kFile.read(4)!=imp.get_magic():
- raise
- kFile.read(4)
- kData=kFile.read()
- return marshal.loads(kData)
- def execfile(fileName, dict):
- kPE=PythonExecutioner()
- kPE.Run(fileName, dict)
- def exec_add_module_do(mod):
- global execfile
- mod.__dict__['execfile'] = execfile
- import __builtin__
- __builtin__.__import__ = __pack_import
- module_do = exec_add_module_do
- """
- #
- # PSYCO installation (must move to system.py, systemrelease.pyc)
- #
- try:
- import psyco
- #from psyco.classes import *
- def bind_me(bindable_list):
- try:
- for x in bindable_list:
- try:
- psyco.bind(x)
- except:
- pass
- except:
- pass
- _prev_psyco_old_module_do = module_do
- def module_bind(module):
- _prev_psyco_old_module_do(module)
- #print 'start binding' + str(module)
- try:
- psyco.bind(module)
- except:
- pass
- for x in module.__dict__.itervalues():
- try:
- psyco.bind(x)
- except:
- pass
- #print 'end binding'
- dbg.Trace("PSYCO installed\\n")
- except Exception, msg:
- bind_me = lambda x:None
- dbg.Trace("No PSYCO support : %s\\n" % msg)
- """
- def GetExceptionString(excTitle):
- (excType, excMsg, excTraceBack)=sys.exc_info()
- excText=""
- excText+=_chr(10)
- import traceback
- traceLineList=traceback.extract_tb(excTraceBack)
- for traceLine in traceLineList:
- if traceLine[3]:
- excText+="%s(line:%d) %s - %s" % (traceLine[0], traceLine[1], traceLine[2], traceLine[3])
- else:
- excText+="%s(line:%d) %s" % (traceLine[0], traceLine[1], traceLine[2])
- excText+=_chr(10)
- excText+=_chr(10)
- excText+="%s - %s:%s" % (excTitle, excType, excMsg)
- excText+=_chr(10)
- return excText
- def ShowException(excTitle):
- excText=GetExceptionString(excTitle)
- dbg.TraceError(excText)
- app.Abort()
- return 0
- def RunMainScript(name):
- try:
- execfile(name, __main__.__dict__)
- except RuntimeError, msg:
- msg = str(msg)
- import locale
- if locale.error:
- msg = locale.error.get(msg, msg)
- dbg.LogBox(msg)
- app.Abort()
- except:
- msg = GetExceptionString("Run")
- dbg.LogBox(msg)
- app.Abort()
- import debugInfo
- debugInfo.SetDebugMode(__DEBUG__)
- loginMark = "-cs"
- app.__COMMAND_LINE__ = __COMMAND_LINE__
- RunMainScript("prototype.py")
ich hoffe mir kann jemand helfen
-
Moin kann mir bitte einer helfen benutze Fliege Files V3
ich habe die Items in die item_proto eingetragen
in item_names sind diese natürlich mit dem richtigen namen dekladiert
Code- item_proto.txt
- 27009 X ITEM_USE USE_SPECIAL 1 NONE ITEM_STACKABLE | LOG NONE NONE 0 0 0 0 0 LIMIT_NONE 0 LIMIT_NONE 0 APPLY_NONE 0 APPLY_NONE 0 APPLY_NONE 0 APPLY_NONE 0 100000 0 30 0 0 0 0 0 0
- 27010 X ITEM_USE USE_SPECIAL 1 NONE ITEM_STACKABLE | LOG NONE NONE 0 0 0 0 0 LIMIT_NONE 0 LIMIT_NONE 0 APPLY_NONE 0 APPLY_NONE 0 APPLY_NONE 0 APPLY_NONE 0 100000 0 30 0 0 0 0 0 0
und ich bekomme nun ein Connection refused
syserr db habe schon versucht in der item_proto was zu ändern aber meine änderungen haben nicht geholfen
syserr Ch1, Ch99, Loginserver
Code- SYSERR: Mar 20 23:51:32 :: socket_connect: HOST localhost:15000, could not connect.
- SYSERR: Mar 20 23:51:35 :: socket_connect: HOST localhost:15000, could not connect.
- SYSERR: Mar 20 23:51:38 :: socket_connect: HOST localhost:15000, could not connect.
- SYSERR: Mar 20 23:51:41 :: socket_connect: HOST localhost:15000, could not connect.
- SYSERR: Mar 20 23:51:44 :: socket_connect: HOST localhost:15000, could not connect.
- SYSERR: Mar 20 23:51:44 :: hupsig: SIGHUP, SIGINT, SIGTERM signal has been received. shutting down.
- SYSERR: Mar 20 23:51:44 :: pid_deinit:
- End of pid
-
Guten Abend,
ich wollte mal fragen ob vielleicht einer weiß wo ich den Code finde von den Server Rates (ich meine nicht /priv_empire).
Mein problem in den Fliege V3 ist, dass ich mit dem Befehl (/priv_empire 0 1 1000 24) nur statt der 1000% nur 200% aktiviert werden also denke ich mal das die Rates irgendwo mit max 200% dekladiert sind.
Ja, die Rates kann man auch bei Navicat in der Mob_proto einstellen, aber ich möchte mir die option gerne offen halten mit priv_empire.
Wenn einer ne lösung für mich hat würde ich mich sehr über eine Antwort freuen.
Schönen Abend
Mit freundlichen Grüßen
-
Leider ohne erfolg.
Ich habe die game und db nochmal einzelnt compiliert und auch nochmal die Dateien in die einzelnen Channel, cores und db gezogen um zu schauen ob es vielleicht an der Verknüpfung liegt aber leider nichts....
Also an den Protos scheint es nicht zu liegen...
Ich habe vor dem bearbeiten noch Sicherheitskopien gemacht und diese jetzt eingefügt... gleiches problem...
-
Moin Moin, ich kann mir leider nicht erklären wodurch dieser fehler entstanden ist und hoffe nun, dass jemand von weiß/ mir hilft wie man diesen fehler wieder weg bekommt.
Ausführliche erklärung vorab was ich geändert habe:
Ich wollte versuchen mein Schwert+9 uppbar zum VMS+0 zu machen deshalb habe ich mir die item_proto.txt/-names.txt/ mob_proto.txt und /-names.txt ausm server geladen, die item_proto geöffnet rüber kopiert in OpenOffice dort bei Schwert+9 /Refined_Vnum 290 für das VMS eingetragen, alles markiert wieder in die item_proto geladen, alle 4 Dateien in den Server gezogen und die vorhandenen ersetzt, für den Client alle 4 Dateien gepackt und die item_proto/mob_proto in den Client gezogen- vorhandene ersetzt, locale gepackt und jetzt der fehler... habe alles wieder rückgängig gemacht aber der Fehler besteht weiterhin...
Ja, ich weiß jetzt auch nur bei item_proto die Refined_Vnum ändern reicht nicht gäbe es ein ausfühliches Howto würde ich mich freuen wenn mir das jemand zukommen lassen könnte im Netz findet man nur schlecht beschriebene oder nur wischi waschi, was kein Anfänger versteht.
Bitte melden Sie sich an, um diesen Anhang zu sehen.
bei der Charauswahl müsste dort eigentlich mein GM stehen... hat gestern alles noch wunderbar funktioniert und in Navicat habe ich bis jetzt noch keine einstellungen gemacht...
Bitte melden Sie sich an, um diesen Anhang zu sehen.
hier kann ich mir jetzt einen neuen Char auswählen
Bitte melden Sie sich an, um diesen Anhang zu sehen.
hier bekomme ich ein standbild
Bitte melden Sie sich an, um diesen Anhang zu sehen.
nadem man im vorherigen Bild auf Esc drückt sehe ich aufeinmal meinen Char aber mit abnormalen werten Level 118527 genau... eigentlich ist der Level 255 und hat ne Rüssi an Spielzeit passt auch nicht
Bitte melden Sie sich an, um diesen Anhang zu sehen.
und nachm Einloggen gibt es nen kick und Empire: EmpireSelectFailed 1 steht im syserr..... bei goggle (war mein erster weg) steht leider nichts über den fehlercode
ich hoffe jemand kann mir bei diesem Problem helfen.
Mit freundlichen Grüßen
-
Moin Moin,
ich habe mal ne frage zum entpacken und packen der item_proto und mob_proto.
Mein problem ist, dass ich die item- und mob_proto der Fliege Files V3 nicht entpacken kann, wenn ich aber die vorhandenen item- und mob_proto.txt serverside packe, in die Locale einfüge und die auch packe denn fehlen Items (habe ich gesehen weil bei der Charauswahl mein Char keine Rüssi mehr an hatte und die Größe der Dateien auch unterschiedlich sind) und ich komme nicht weiter als bis zum Ladefenster nach der Charauswahl....
Könnte es sein, dass Fliege mit Querys gearbeitet hat und deswegen lassen die sich nicht in txt umwandeln?
Ich habe sämtliche dumper und reader ausprobiert, ich habe mir auch die unpacked Clients von Kimetsu (wenn ich die protos entpacke erhalte ich nur leere .txt) ,(wenn ich die vorhandenen .txt packen möchte, bekomme ich eine fehlermeldung (wahrscheinlich, wie ich herausgefunden habe sollen wohl Zeilen fehlen in der item_proto.txt)) und MoonMt2 Returns von 2014/15 (die vorhandene item_proto lässt sich entpacken aber nicht mehr packen wie beim Kimetsu Client).
Ja, damit sich die Zeilen verschieben habe ich in der item_proto.txt auch schon bei ITME_NAME (2. Spalte) überall ein X rein gesetzt, aber es hat sich nicht so verschoben damit es passt..., die lösung kann ja jetzt nicht sein, dass ich 7408 Zeilen durchgehe und am ende noch eine Zahl ran setze wo noch was fehlt.... (ich nutze auch eine Tabelle OpenOffice falls die frage kommt).
Gibt es vielleich sonst eine bessere alternative als mit .txt und den ganzen packern/entpackern zu arbeiten?
Querys sollen veraltet sein wie ich das verstanden habe?
Direkt von serverside zu Clientside dumpen habe ich auch schon gelesen, allerdings ohne anleitung?
Über nette, freundliche und hilfsbereite antworten würde ich mich sehr freuen, ich bin ein Neuling also lasst bitte die hate Antworten und dummen kommentare bei euch und überfliegt einfach dieses Thema wenn ihr nicht helfen wollt.
Vielen dank schonmal im voraus
Mit freundlich Grüßen
-
Vielen Dank für euren schnellen Support
-
Hallo liebe Community,
kann mir bitte jemand helfen diese unnötige Chat info weg zu bekommen bzw. kann mir bitte jemand sagen in welchen Dateien ich den Code löschen muss damit die Info nicht mehr angezeigt wird?
In 3 Dateien habe ich alle Codes mit (Test Server) schön gelöscht und weiter nichts gefunden. Bilder liegen bei.
Bitte melden Sie sich an, um diesen Anhang zu sehen.Bitte melden Sie sich an, um diesen Anhang zu sehen.
In diesen habe ich den Code gefunden