- Mesaj
- 4.070
- Çözümler
- 408
- Beğeni
- 4.312
- Puan
- 1.849
- Ticaret Puanı
- 0
Merhabalar, bir gui içinde over-click-right click vs. işlevini kullanmak istiyorum fakat nedense olmadı bir türlü.
Herhangi bir syserr falan mevcut değil ancak oyun içinde de hiç bir tepki olmuyor. Over veya tıklama işlevi vb. hiç bir etki yok.
İlgili olabileceğini düşündüğüm kodları şöyle vereyim:
Kendi eklediğim ve çalışmayan tanım satırları:
ui.py class ImageBox:
ui.py class ExpandedImageBox:
ui.py class Window:
Herhangi bir syserr falan mevcut değil ancak oyun içinde de hiç bir tepki olmuyor. Over veya tıklama işlevi vb. hiç bir etki yok.
İlgili olabileceğini düşündüğüm kodları şöyle vereyim:
Kendi eklediğim ve çalışmayan tanım satırları:
Python:
self.deneme = ui.MakeImageBox(self.deneme2, MAIN_PATH + "right_side/{}_slot.tga".format(size), 0, 0)
self.deneme.SAFE_SetStringEvent("MOUSE_OVER_IN", self.OnHoverr)
self.deneme.SAFE_SetStringEvent("MOUSE_OVER_OUT", self.OnOutt)
self.deneme.SAFE_SetStringEvent("MOUSE_CLICK", self.OnMouseLeftButtonDown)
self.deneme.SAFE_SetStringEvent("MOUSE_RCLICK", self.OnMouseRightButtonDown)
ui.py class ImageBox:
Python:
class ImageBox(Window):
def __init__(self, layer = "UI"):
Window.__init__(self, layer)
self.name=""
self.argDict={}
self.eventDict={}
self.eventFunc = {"mouse_rclick" : None, "mouse_click" : None, "mouse_over_in" : None, "mouse_over_out" : None}
self.eventArgs = {"mouse_rclick" : None, "mouse_click" : 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 GetWidth(self):
return wndMgr.GetWidth(self.hWnd)
def GetHeight(self):
return wndMgr.GetHeight(self.hWnd)
def SAFE_SetStringEvent(self, event, func, *args):
self.eventDict[event]=(__mem_func__(func), args)
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 OnMouseLeftButtonDown(self) :
if self.eventFunc["mouse_click"] :
apply(self.eventFunc["mouse_click"], self.eventArgs["mouse_click"])
else:
try:
apply(self.eventDict["MOUSE_CLICK"][0], self.eventDict["MOUSE_CLICK"][1])
except KeyError:
pass
def OnMouseRightButtonDown(self) :
if self.eventFunc["mouse_rclick"] :
apply(self.eventFunc["mouse_rclick"], self.eventArgs["mouse_rclick"])
else:
try:
apply(self.eventDict["MOUSE_RCLICK"][0], self.eventDict["MOUSE_RCLICK"][1])
except KeyError:
pass
def OnMouseOverIn(self) :
if self.eventFunc["mouse_over_in"] :
apply(self.eventFunc["mouse_over_in"], self.eventArgs["mouse_over_in"])
else:
try:
apply(self.eventDict["MOUSE_OVER_IN"][0], self.eventDict["MOUSE_OVER_IN"][1])
except KeyError:
pass
def OnMouseOverOut(self) :
if self.eventFunc["mouse_over_out"] :
apply(self.eventFunc["mouse_over_out"], self.eventArgs["mouse_over_out"])
else :
try:
apply(self.eventDict["MOUSE_OVER_OUT"][0], self.eventDict["MOUSE_OVER_OUT"][1])
except KeyError:
pass
if app.ENABLE_PRIVATE_SHOP_SEARCH_SYSTEM:
def LeftRightReverse(self):
wndMgr.LeftRightReverseImageBox(self.hWnd)
def SetCoolTime(self, time, elapsedTime = 0.0):
wndMgr.SetCoolTimeImageBox(self.hWnd, time, elapsedTime)
def IsInCoolTime(self):
return wndMgr.IsInCoolTime(self.hWnd)
def SetStartCoolTime(self, time):
wndMgr.SetStartCoolTimeImageBox(self.hWnd, time)
ui.py class ExpandedImageBox:
Python:
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)
ui.py class Window:
Python:
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()
def __del__(self):
wndMgr.Destroy(self.hWnd)
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)
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)
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)
def GetGlobalPosition(self):
return wndMgr.GetWindowGlobalPosition(self.hWnd)
def GetMouseLocalPosition(self):
return wndMgr.GetMouseLocalPosition(self.hWnd)
def GetRect(self):
return wndMgr.GetWindowRect(self.hWnd)
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)
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)
def SetOnMouseLeftButtonUpEvent(self, event):
self.onMouseLeftButtonUpEvent = event
def OnMouseLeftButtonUp(self):
if self.onMouseLeftButtonUpEvent:
self.onMouseLeftButtonUpEvent()
def OnMouseRightButtonDown(self):
if self.mouseRightButtonDownEvent:
apply(self.mouseRightButtonDownEvent, self.mouseRightButtonDownArgs)