TShelby

Metin2 | Cool Notify Friends | Python

Jun 23rd, 2019
944
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.13 KB | None | 0 0
  1. ''' Is not a very great code, but is honest work. '''
  2.  
  3. ### 0.1 Root / uiMessenger.py:
  4.  
  5. # 1. Search:
  6.  
  7.     def OnLogin(self, groupIndex ...
  8.    
  9. # 1. After:
  10.  
  11.         member.Online()
  12.         self.OnRefreshList()
  13.        
  14. # 1. Add:
  15.  
  16.         if not name in constInfo.ALREADY_NOTIFY_LIST:
  17.             self.onlinePopup = uiCommon.OnlinePopup()
  18.             self.onlinePopup.SetUserName(name)
  19.             self.onlinePopup.SetEvent(ui.__mem_func__(self.OpenWhisper), "MOUSE_LEFT_BUTTON_UP", name)
  20.             self.onlinePopup.SlideIn()
  21.        
  22.             constInfo.ALREADY_NOTIFY_LIST.append(name) 
  23.            
  24.            
  25. ### 0.2 Root / constInfo.py:
  26.  
  27. # 2. Add:
  28.  
  29. ALREADY_NOTIFY_LIST = []
  30.  
  31. ### 0.3 Root / ui.py
  32.  
  33. # 3 Search:
  34.  
  35. class Board(Window):
  36.  
  37.     (....)
  38.  
  39. # 3 REPLACE this class with:
  40.  
  41. class Board(Window):
  42.     CORNER_WIDTH = 32
  43.     CORNER_HEIGHT = 32
  44.     LINE_WIDTH = 128
  45.     LINE_HEIGHT = 128
  46.  
  47.     LT = 0
  48.     LB = 1
  49.     RT = 2
  50.     RB = 3
  51.     L = 0
  52.     R = 1
  53.     T = 2
  54.     B = 3
  55.    
  56.     BASE_PATH = "d:/ymir work/ui/pattern"
  57.     IMAGES = {
  58.         'CORNER' : {
  59.             0 : "Board_Corner_LeftTop",
  60.             1 : "Board_Corner_LeftBottom",
  61.             2 : "Board_Corner_RightTop",
  62.             3 : "Board_Corner_RightBottom"
  63.         },
  64.         'BAR' : {
  65.             0 : "Board_Line_Left",
  66.             1 : "Board_Line_Right",
  67.             2 : "Board_Line_Top",
  68.             3 : "Board_Line_Bottom"
  69.         },
  70.         'FILL' : "Board_Base"
  71.     }
  72.  
  73.     def __init__(self, layer = "UI"):
  74.         Window.__init__(self, layer)
  75.         self.skipMaxCheck = False
  76.  
  77.         self.MakeBoard()
  78.        
  79.     def MakeBoard(self):
  80.         CornerFileNames = [ ]
  81.         LineFileNames = [ ]
  82.        
  83.         for imageDictKey in (['CORNER', 'BAR']):
  84.             for x in xrange(len(self.IMAGES[imageDictKey])):
  85.                 if imageDictKey == "CORNER":
  86.                     CornerFileNames.append("%s/%s.tga" % (self.BASE_PATH, self.IMAGES[imageDictKey][x]))
  87.                 elif imageDictKey == "BAR":
  88.                     LineFileNames.append("%s/%s.tga" % (self.BASE_PATH, self.IMAGES[imageDictKey][x]))
  89.        
  90.         self.Corners = []
  91.         for fileName in CornerFileNames:
  92.             Corner = ExpandedImageBox()
  93.             Corner.AddFlag("not_pick")
  94.             Corner.LoadImage(fileName)
  95.             Corner.SetParent(self)
  96.             Corner.SetPosition(0, 0)
  97.             Corner.Show()
  98.             self.Corners.append(Corner)
  99.  
  100.         self.Lines = []
  101.         for fileName in LineFileNames:
  102.             Line = ExpandedImageBox()
  103.             Line.AddFlag("not_pick")
  104.             Line.LoadImage(fileName)
  105.             Line.SetParent(self)
  106.             Line.SetPosition(0, 0)
  107.             Line.Show()
  108.             self.Lines.append(Line)
  109.  
  110.         self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
  111.         self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
  112.  
  113.         self.Base = ExpandedImageBox()
  114.         self.Base.AddFlag("not_pick")
  115.         self.Base.LoadImage("%s/%s.tga" % (self.BASE_PATH, self.IMAGES['FILL']))
  116.         self.Base.SetParent(self)
  117.         self.Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
  118.         self.Base.Show()
  119.  
  120.     def __del__(self):
  121.         Window.__del__(self)
  122.  
  123.     def SetSize(self, width, height):
  124.         if not self.skipMaxCheck:
  125.             width = max(self.CORNER_WIDTH*2, width)
  126.             height = max(self.CORNER_HEIGHT*2, height)
  127.            
  128.         Window.SetSize(self, width, height)
  129.  
  130.         self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
  131.         self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
  132.         self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
  133.         self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
  134.         self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
  135.  
  136.         verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
  137.         horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
  138.         self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  139.         self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  140.         self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  141.         self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  142.  
  143.         if self.Base:
  144.             self.Base.SetRenderingRect(0, 0, horizontalShowingPercentage, verticalShowingPercentage)
  145.            
  146. # 3 AFTER CLASS BOARD ADD THIS CLASS:
  147.  
  148. class BorderB(Board):
  149.     CORNER_WIDTH = 16
  150.     CORNER_HEIGHT = 16
  151.     LINE_WIDTH = 16
  152.     LINE_HEIGHT = 16
  153.    
  154.     BASE_PATH = "d:/ymir work/ui/pattern"
  155.  
  156.     IMAGES = {
  157.         'CORNER' : {
  158.             0 : "border_b_left_top",
  159.             1 : "border_b_left_bottom",
  160.             2 : "border_b_right_top",
  161.             3 : "border_b_right_bottom"
  162.         },
  163.         'BAR' : {
  164.             0 : "border_b_left",
  165.             1 : "border_b_right",
  166.             2 : "border_b_top",
  167.             3 : "border_b_bottom"
  168.         },
  169.         'FILL' : "border_b_center"
  170.     }
  171.    
  172.     def __init__(self):
  173.         Board.__init__(self)
  174.            
  175.         self.eventFunc = {
  176.             "MOUSE_LEFT_BUTTON_UP" : None,
  177.         }
  178.         self.eventArgs = {
  179.             "MOUSE_LEFT_BUTTON_UP" : None,
  180.         }
  181.  
  182.     def __del__(self):
  183.         Board.__del__(self)
  184.         self.eventFunc = None
  185.         self.eventArgs = None
  186.  
  187.     def SetSize(self, width, height):
  188.         Board.SetSize(self, width, height)
  189.        
  190.     def SetEvent(self, func, *args) :
  191.         result = self.eventFunc.has_key(args[0])       
  192.         if result :
  193.             self.eventFunc[args[0]] = func
  194.             self.eventArgs[args[0]] = args
  195.         else :
  196.             print "[ERROR] ui.py SetEvent, Can`t Find has_key : %s" % args[0]
  197.            
  198.     def OnMouseLeftButtonUp(self):
  199.         if self.eventFunc["MOUSE_LEFT_BUTTON_UP"] :
  200.             apply(self.eventFunc["MOUSE_LEFT_BUTTON_UP"], self.eventArgs["MOUSE_LEFT_BUTTON_UP"])
  201.            
  202.            
  203.            
  204. ### 0.4 Root / uiCommon.py
  205.  
  206. # 4 Add this to the end of file:
  207.  
  208.  
  209. ### (Check if you have in this file import app )
  210.  
  211. class OnlinePopup(ui.BorderB):
  212.     def __init__(self):
  213.         ui.BorderB.__init__(self)
  214.        
  215.         self.isActiveSlide = False
  216.         self.isActiveSlideOut = False
  217.         self.endTime = 0
  218.         self.wndWidth = 0
  219.  
  220.         self.textLine = ui.TextLine()
  221.         self.textLine.SetParent(self)
  222.         self.textLine.SetWindowHorizontalAlignCenter()
  223.         self.textLine.SetWindowVerticalAlignCenter()
  224.         self.textLine.SetHorizontalAlignCenter()
  225.         self.textLine.SetVerticalAlignCenter()
  226.         self.textLine.SetPosition(13, 0)
  227.         self.textLine.Show()
  228.        
  229.         self.onlineImage = ui.ImageBox()
  230.         self.onlineImage.SetParent(self)
  231.         self.onlineImage.SetPosition(8, 8)
  232.         self.onlineImage.LoadImage("d:/ymir work/ui/game/windows/messenger_list_online.sub")
  233.         self.onlineImage.Show()
  234.        
  235.     def __del__(self):
  236.         ui.BorderB.__del__(self)
  237.  
  238.     def SlideIn(self):
  239.         self.SetTop()
  240.         self.Show()
  241.        
  242.         self.isActiveSlide = True
  243.         self.endTime = app.GetGlobalTimeStamp() + 5
  244.  
  245.     def Close(self):
  246.         self.Hide()
  247.  
  248.     def Destroy(self):
  249.         self.Close()
  250.  
  251.     def SetUserName(self, name):
  252.         self.textLine.SetText("Jucatorul %s este online." % str(name))
  253.        
  254.         self.wndWidth = self.textLine.GetTextSize()[0] + 40
  255.         self.SetSize(self.wndWidth, 25)
  256.         self.SetPosition(-self.wndWidth, wndMgr.GetScreenHeight() - 200)
  257.        
  258.     def OnUpdate(self):
  259.         if self.isActiveSlide and self.isActiveSlide == True:
  260.             x, y = self.GetLocalPosition()
  261.             if x < 0:
  262.                 self.SetPosition(x + 4, y)
  263.                
  264.         if self.endTime - app.GetGlobalTimeStamp() <= 0 and self.isActiveSlideOut == False and self.isActiveSlide == True:
  265.             self.isActiveSlide = False
  266.             self.isActiveSlideOut = True
  267.                
  268.         if self.isActiveSlideOut and self.isActiveSlideOut == True:
  269.             x, y = self.GetLocalPosition()
  270.             if x > -(self.wndWidth):
  271.                 self.SetPosition(x - 4, y)
  272.                
  273.             if x <= -(self.wndWidth):
  274.                 self.isActiveSlideOut = False
  275.                 self.Close()
  276.  
  277.  
  278. ######## Please write in topic If i forgot something. ########
Advertisement
Add Comment
Please, Sign In to add comment