Advertisement
Guest User

Untitled

a guest
Jan 31st, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 36.52 KB | None | 0 0
  1. import ui
  2. import grp
  3. import chat
  4. import wndMgr
  5. import net
  6. import app
  7. import ime
  8. import localeInfo
  9. import colorInfo
  10. import constInfo
  11. import systemSetting
  12.  
  13. ENABLE_CHAT_COMMAND = True
  14. ENABLE_LAST_SENTENCE_STACK = True
  15. ENABLE_INSULT_CHECK = True
  16.  
  17. if localeInfo.IsHONGKONG():
  18.     ENABLE_LAST_SENTENCE_STACK = True
  19.  
  20. if localeInfo.IsEUROPE():
  21.     ENABLE_CHAT_COMMAND = False
  22.  
  23. if localeInfo.IsCANADA():
  24.     ENABLE_LAST_SENTENCE_STACK = False
  25.  
  26. chatInputSetList = []
  27. def InsertChatInputSetWindow(wnd):
  28.     global chatInputSetList
  29.     chatInputSetList.append(wnd)
  30. def RefreshChatMode():
  31.     global chatInputSetList
  32.     map(lambda wnd:wnd.OnRefreshChatMode(), chatInputSetList)
  33. def DestroyChatInputSetWindow():
  34.     global chatInputSetList
  35.     chatInputSetList = []
  36.  
  37. ## ChatModeButton
  38. class ChatModeButton(ui.Window):
  39.  
  40.     OUTLINE_COLOR = grp.GenerateColor(1.0, 1.0, 1.0, 1.0)
  41.     OVER_COLOR = grp.GenerateColor(1.0, 1.0, 1.0, 0.3)
  42.     BUTTON_STATE_UP = 0
  43.     BUTTON_STATE_OVER = 1
  44.     BUTTON_STATE_DOWN = 2
  45.  
  46.     def __init__(self):
  47.         ui.Window.__init__(self)
  48.         self.state = None
  49.         self.buttonText = None
  50.         self.event = None
  51.         self.SetWindowName("ChatModeButton")
  52.  
  53.         net.EnableChatInsultFilter(ENABLE_INSULT_CHECK)
  54.  
  55.     def __del__(self):
  56.         ui.Window.__del__(self)
  57.  
  58.     def SAFE_SetEvent(self, event):
  59.         self.event=ui.__mem_func__(event)
  60.  
  61.     def SetText(self, text):
  62.         if None == self.buttonText:
  63.             textLine = ui.TextLine()
  64.             textLine.SetParent(self)
  65.             textLine.SetWindowHorizontalAlignCenter()
  66.             textLine.SetWindowVerticalAlignCenter()
  67.             textLine.SetVerticalAlignCenter()
  68.             textLine.SetHorizontalAlignCenter()
  69.             textLine.SetPackedFontColor(self.OUTLINE_COLOR)
  70.             textLine.Show()
  71.             self.buttonText = textLine
  72.  
  73.         self.buttonText.SetText(text)
  74.  
  75.     def SetSize(self, width, height):
  76.         self.width = width
  77.         self.height = height
  78.         ui.Window.SetSize(self, width, height)
  79.  
  80.     def OnMouseOverIn(self):
  81.         self.state = self.BUTTON_STATE_OVER
  82.  
  83.     def OnMouseOverOut(self):
  84.         self.state = self.BUTTON_STATE_UP
  85.  
  86.     def OnMouseLeftButtonDown(self):
  87.         self.state = self.BUTTON_STATE_DOWN
  88.  
  89.     def OnMouseLeftButtonUp(self):
  90.         self.state = self.BUTTON_STATE_UP
  91.         if self.IsIn():
  92.             self.state = self.BUTTON_STATE_OVER
  93.  
  94.         if None != self.event:
  95.             self.event()
  96.  
  97.     def OnRender(self):
  98.  
  99.         (x, y) = self.GetGlobalPosition()
  100.  
  101.         grp.SetColor(self.OUTLINE_COLOR)
  102.         grp.RenderRoundBox(x, y, self.width, self.height)
  103.  
  104.         if self.state >= self.BUTTON_STATE_OVER:
  105.             grp.RenderRoundBox(x+1, y, self.width-2, self.height)
  106.             grp.RenderRoundBox(x, y+1, self.width, self.height-2)
  107.  
  108.             if self.BUTTON_STATE_DOWN == self.state:
  109.                 grp.SetColor(self.OVER_COLOR)
  110.                 grp.RenderBar(x+1, y+1, self.width-2, self.height-2)
  111.  
  112. ## ChatLine
  113. class ChatLine(ui.EditLine):
  114.     if app.ENABLE_TRADE_CHAT:
  115.         CHAT_MODE_NAME = {  chat.CHAT_TYPE_TALKING : locale.CHAT_NORMAL,
  116.                             chat.CHAT_TYPE_PARTY : locale.CHAT_PARTY,
  117.                             chat.CHAT_TYPE_GUILD : locale.CHAT_GUILD,
  118.                             chat.CHAT_TYPE_SHOUT : locale.CHAT_SHOUT,
  119.                             chat.CHAT_TYPE_SHOUT_TRADE : "Trade Chat", }
  120.     else:
  121.         CHAT_MODE_NAME = {  chat.CHAT_TYPE_TALKING : locale.CHAT_NORMAL,
  122.                             chat.CHAT_TYPE_PARTY : locale.CHAT_PARTY,
  123.                             chat.CHAT_TYPE_GUILD : locale.CHAT_GUILD,
  124.                             chat.CHAT_TYPE_SHOUT : locale.CHAT_SHOUT,}
  125.  
  126.     def __init__(self):
  127.         ui.EditLine.__init__(self)
  128.         self.SetWindowName("Chat Line")
  129.         self.lastShoutTime = 0
  130.         if app.ENABLE_TRADE_CHAT:
  131.             self.lastTradeShoutTime = 0
  132.         self.eventEscape = lambda *arg: None
  133.         self.eventReturn = lambda *arg: None
  134.         self.eventTab = None
  135.         self.chatMode = chat.CHAT_TYPE_TALKING
  136.         self.bCodePage = True
  137.  
  138.         self.overTextLine = ui.TextLine()
  139.         self.overTextLine.SetParent(self)
  140.         self.overTextLine.SetPosition(-1, 0)
  141.         self.overTextLine.SetFontColor(1.0, 1.0, 0.0)
  142.         self.overTextLine.SetOutline()
  143.         self.overTextLine.Hide()
  144.  
  145.         self.lastSentenceStack = []
  146.         self.lastSentencePos = 0
  147.  
  148.     def SetChatMode(self, mode):
  149.         self.chatMode = mode
  150.  
  151.     def GetChatMode(self):
  152.         return self.chatMode
  153.  
  154.     if app.ENABLE_TRADE_CHAT:
  155.         def ChangeChatMode(self):
  156.             if chat.CHAT_TYPE_TALKING == self.GetChatMode():
  157.                 self.SetChatMode(chat.CHAT_TYPE_PARTY)
  158.                 self.SetText("#")
  159.                 self.SetEndPosition()
  160.  
  161.             elif chat.CHAT_TYPE_PARTY == self.GetChatMode():
  162.                 self.SetChatMode(chat.CHAT_TYPE_GUILD)
  163.                 self.SetText("%")
  164.                 self.SetEndPosition()
  165.  
  166.             elif chat.CHAT_TYPE_GUILD == self.GetChatMode():
  167.                 self.SetChatMode(chat.CHAT_TYPE_SHOUT)
  168.                 self.SetText("!")
  169.                 self.SetEndPosition()
  170.                
  171.             elif chat.CHAT_TYPE_SHOUT == self.GetChatMode():
  172.                 self.SetChatMode(chat.CHAT_TYPE_SHOUT_TRADE)
  173.                 self.SetText("$")
  174.                 self.SetEndPosition()
  175.  
  176.             elif chat.CHAT_TYPE_SHOUT_TRADE == self.GetChatMode():
  177.                 self.SetChatMode(chat.CHAT_TYPE_TALKING)
  178.                 self.SetText("")
  179.  
  180.             self.__CheckChatMark()
  181.     else:
  182.         def ChangeChatMode(self):
  183.             if chat.CHAT_TYPE_TALKING == self.GetChatMode():
  184.                 self.SetChatMode(chat.CHAT_TYPE_PARTY)
  185.                 self.SetText("#")
  186.                 self.SetEndPosition()
  187.  
  188.             elif chat.CHAT_TYPE_PARTY == self.GetChatMode():
  189.                 self.SetChatMode(chat.CHAT_TYPE_GUILD)
  190.                 self.SetText("%")
  191.                 self.SetEndPosition()
  192.  
  193.             elif chat.CHAT_TYPE_GUILD == self.GetChatMode():
  194.                 self.SetChatMode(chat.CHAT_TYPE_SHOUT)
  195.                 self.SetText("!")
  196.                 self.SetEndPosition()
  197.  
  198.             elif chat.CHAT_TYPE_SHOUT == self.GetChatMode():
  199.                 self.SetChatMode(chat.CHAT_TYPE_TALKING)
  200.                 self.SetText("")
  201.  
  202.             self.__CheckChatMark()
  203.  
  204.     def GetCurrentChatModeName(self):
  205.         try:
  206.             return self.CHAT_MODE_NAME[self.chatMode]
  207.         except:
  208.             import exception
  209.             exception.Abort("ChatLine.GetCurrentChatModeName")
  210.  
  211.     def SAFE_SetEscapeEvent(self, event):
  212.         self.eventReturn = ui.__mem_func__(event)
  213.  
  214.     def SAFE_SetReturnEvent(self, event):
  215.         self.eventEscape = ui.__mem_func__(event)
  216.  
  217.     def SAFE_SetTabEvent(self, event):
  218.         self.eventTab = ui.__mem_func__(event)
  219.  
  220.     def SetTabEvent(self, event):
  221.         self.eventTab = event
  222.  
  223.     def OpenChat(self):
  224.         self.SetFocus()
  225.         self.__ResetChat()
  226.  
  227.     def __ClearChat(self):
  228.         self.SetText("")
  229.         self.lastSentencePos = 0
  230.  
  231.     if app.ENABLE_TRADE_CHAT:
  232.         def __ResetChat(self):
  233.             if chat.CHAT_TYPE_PARTY == self.GetChatMode():
  234.                 self.SetText("#")
  235.                 self.SetEndPosition()
  236.             elif chat.CHAT_TYPE_GUILD == self.GetChatMode():
  237.                 self.SetText("%")
  238.                 self.SetEndPosition()
  239.             elif chat.CHAT_TYPE_SHOUT == self.GetChatMode():
  240.                 self.SetText("!")
  241.                 self.SetEndPosition()
  242.             elif chat.CHAT_TYPE_SHOUT_TRADE == self.GetChatMode():
  243.                 self.SetText("$")
  244.                 self.SetEndPosition()
  245.             else:
  246.                 self.__ClearChat()
  247.  
  248.             self.__CheckChatMark()
  249.     else:
  250.         def __ResetChat(self):
  251.             if chat.CHAT_TYPE_PARTY == self.GetChatMode():
  252.                 self.SetText("#")
  253.                 self.SetEndPosition()
  254.             elif chat.CHAT_TYPE_GUILD == self.GetChatMode():
  255.                 self.SetText("%")
  256.                 self.SetEndPosition()
  257.             elif chat.CHAT_TYPE_SHOUT == self.GetChatMode():
  258.                 self.SetText("!")
  259.                 self.SetEndPosition()
  260.             else:
  261.                 self.__ClearChat()
  262.  
  263.             self.__CheckChatMark()
  264.        
  265.  
  266.     def __SendChatPacket(self, text, type):
  267. #       if text[0] == '/':
  268. #           if ENABLE_CHAT_COMMAND or constInfo.CONSOLE_ENABLE:
  269. #               pass
  270. #           else:
  271. #               return
  272.  
  273.         if net.IsChatInsultIn(text):
  274.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.CHAT_INSULT_STRING)
  275.         else:
  276.             net.SendChatPacket(text, type)
  277.        
  278.     def __SendPartyChatPacket(self, text):
  279.  
  280.         if 1 == len(text):
  281.             self.RunCloseEvent()
  282.             return
  283.  
  284.         self.__SendChatPacket(text[1:], chat.CHAT_TYPE_PARTY)
  285.         self.__ResetChat()
  286.  
  287.     def __SendGuildChatPacket(self, text):
  288.  
  289.         if 1 == len(text):
  290.             self.RunCloseEvent()
  291.             return
  292.  
  293.         self.__SendChatPacket(text[1:], chat.CHAT_TYPE_GUILD)
  294.         self.__ResetChat()
  295.  
  296.     def __SendGuildChatPacket(self, text):
  297.  
  298.         if 1 == len(text):
  299.             self.RunCloseEvent()
  300.             return
  301.  
  302.         self.__SendChatPacket(text[1:], chat.CHAT_TYPE_GUILD)
  303.         self.__ResetChat()
  304.  
  305.     def __SendShoutChatPacket(self, text):
  306.  
  307.         if 1 == len(text):
  308.             self.RunCloseEvent()
  309.             return
  310.  
  311.         if app.GetTime() < self.lastShoutTime + 15:
  312.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.CHAT_SHOUT_LIMIT)
  313.             self.__ResetChat()
  314.             return
  315.  
  316.         self.__SendChatPacket(text[1:], chat.CHAT_TYPE_SHOUT)
  317.         self.__ResetChat()
  318.  
  319.         self.lastShoutTime = app.GetTime()
  320.        
  321.     if app.ENABLE_TRADE_CHAT:
  322.         def __SendTradeShoutChatPacket(self, text):
  323.            
  324.  
  325.             if 1 == len(text):
  326.                 self.RunCloseEvent()
  327.                 return
  328.  
  329.             if app.GetTime() < self.lastTradeShoutTime + 15:
  330.                 chat.AppendChat(chat.CHAT_TYPE_INFO, locale.CHAT_SHOUT_LIMIT)
  331.                 self.__ResetChat()
  332.                 return
  333.  
  334.             self.__SendChatPacket(text[1:], chat.CHAT_TYPE_SHOUT_TRADE)
  335.             self.__ResetChat()
  336.  
  337.             self.lastTradeShoutTime = app.GetTime()
  338.    
  339.     def __SendTalkingChatPacket(self, text):
  340.         self.__SendChatPacket(text, chat.CHAT_TYPE_TALKING)
  341.         self.__ResetChat()
  342.  
  343.     def OnIMETab(self):
  344.         #if None != self.eventTab:
  345.         #   self.eventTab()
  346.         #return True
  347.         return False
  348.  
  349.     def OnIMEUpdate(self):
  350.         ui.EditLine.OnIMEUpdate(self)
  351.         self.__CheckChatMark()
  352.  
  353.     if app.ENABLE_TRADE_CHAT:
  354.         def __CheckChatMark(self):
  355.  
  356.             self.overTextLine.Hide()
  357.  
  358.             text = self.GetText()
  359.             if len(text) > 0:
  360.                 if '#' == text[0]:
  361.                     self.overTextLine.SetText("#")
  362.                     self.overTextLine.Show()
  363.                 elif '%' == text[0]:
  364.                     self.overTextLine.SetText("%")
  365.                     self.overTextLine.Show()
  366.                 elif '!' == text[0]:
  367.                     self.overTextLine.SetText("!")
  368.                     self.overTextLine.Show()
  369.                 elif '$' == text[0]:
  370.                     self.overTextLine.SetText("$")
  371.                     self.overTextLine.Show()
  372.     else:      
  373.         def __CheckChatMark(self):
  374.  
  375.             self.overTextLine.Hide()
  376.  
  377.             text = self.GetText()
  378.             if len(text) > 0:
  379.                 if '#' == text[0]:
  380.                     self.overTextLine.SetText("#")
  381.                     self.overTextLine.Show()
  382.                 elif '%' == text[0]:
  383.                     self.overTextLine.SetText("%")
  384.                     self.overTextLine.Show()
  385.                 elif '!' == text[0]:
  386.                     self.overTextLine.SetText("!")
  387.                     self.overTextLine.Show()
  388.  
  389.     def OnIMEKeyDown(self, key):
  390.         # LAST_SENTENCE_STACK
  391.         if app.VK_UP == key:
  392.             self.__PrevLastSentenceStack()
  393.             return True
  394.  
  395.         if app.VK_DOWN == key:
  396.             self.__NextLastSentenceStack()             
  397.             return True        
  398.         # END_OF_LAST_SENTENCE_STACK
  399.  
  400.         ui.EditLine.OnIMEKeyDown(self, key)
  401.  
  402.     # LAST_SENTENCE_STACK
  403.     def __PrevLastSentenceStack(self):
  404.         global ENABLE_LAST_SENTENCE_STACK
  405.         if not ENABLE_LAST_SENTENCE_STACK:
  406.             return
  407.  
  408.         if self.lastSentenceStack and self.lastSentencePos < len(self.lastSentenceStack):
  409.             self.lastSentencePos += 1
  410.             lastSentence = self.lastSentenceStack[-self.lastSentencePos]
  411.             self.SetText(lastSentence)             
  412.             self.SetEndPosition()          
  413.  
  414.     def __NextLastSentenceStack(self):
  415.         global ENABLE_LAST_SENTENCE_STACK
  416.         if not ENABLE_LAST_SENTENCE_STACK:
  417.             return
  418.  
  419.         if self.lastSentenceStack and self.lastSentencePos > 1:
  420.             self.lastSentencePos -= 1
  421.             lastSentence = self.lastSentenceStack[-self.lastSentencePos]
  422.             self.SetText(lastSentence)             
  423.             self.SetEndPosition()          
  424.  
  425.     def __PushLastSentenceStack(self, text):       
  426.         global ENABLE_LAST_SENTENCE_STACK
  427.         if not ENABLE_LAST_SENTENCE_STACK:
  428.             return
  429.  
  430.         if len(text) <= 0:
  431.             return
  432.            
  433.         LAST_SENTENCE_STACK_SIZE = 32
  434.         if len(self.lastSentenceStack) > LAST_SENTENCE_STACK_SIZE:
  435.             self.lastSentenceStack.pop(0)
  436.  
  437.         self.lastSentenceStack.append(text)
  438.     # END_OF_LAST_SENTENCE_STACK
  439.  
  440.     def OnIMEReturn(self):
  441.         text = self.GetText()
  442.         textLen=len(text)
  443.  
  444.         # LAST_SENTENCE_STACK
  445.         self.__PushLastSentenceStack(text)
  446.         # END_OF_LAST_SENTENCE_STACK
  447.                
  448.         textSpaceCount=text.count(' ')
  449.  
  450.         if app.ENABLE_TRADE_CHAT:
  451.             if (textLen > 0) and (textLen != textSpaceCount):
  452.                 if '#' == text[0]:
  453.                     self.__SendPartyChatPacket(text)
  454.                 elif '%' == text[0]:
  455.                     self.__SendGuildChatPacket(text)
  456.                 elif '!' == text[0]:
  457.                     self.__SendShoutChatPacket(text)
  458.                 elif '$' == text[0]:
  459.                     self.__SendTradeShoutChatPacket(text)
  460.                 else:
  461.                     self.__SendTalkingChatPacket(text)
  462.             else:
  463.                 self.__ClearChat()
  464.                 self.eventReturn()
  465.  
  466.         else:
  467.             if (textLen > 0) and (textLen != textSpaceCount):
  468.                 if '#' == text[0]:
  469.                     self.__SendPartyChatPacket(text)
  470.                 elif '%' == text[0]:
  471.                     self.__SendGuildChatPacket(text)
  472.                 elif '!' == text[0]:
  473.                     self.__SendShoutChatPacket(text)
  474.                 else:
  475.                     self.__SendTalkingChatPacket(text)
  476.             else:
  477.                 self.__ClearChat()
  478.                 self.eventReturn()
  479.  
  480.         return True
  481.  
  482.     def OnPressEscapeKey(self):
  483.         self.__ClearChat()
  484.         self.eventEscape()
  485.         return True
  486.  
  487.     def RunCloseEvent(self):
  488.         self.eventEscape()
  489.  
  490.     def BindInterface(self, interface):
  491.         self.interface = interface
  492.  
  493.     def OnMouseLeftButtonDown(self):
  494.         hyperlink = ui.GetHyperlink()
  495.         if hyperlink:
  496.             if app.IsPressed(app.DIK_LALT):
  497.                 link = chat.GetLinkFromHyperlink(hyperlink)
  498.                 ime.PasteString(link)
  499.             else:
  500.                 self.interface.MakeHyperlinkTooltip(hyperlink)
  501.         else:
  502.             ui.EditLine.OnMouseLeftButtonDown(self)
  503.  
  504. class ChatInputSet(ui.Window):
  505.  
  506.     CHAT_OUTLINE_COLOR = grp.GenerateColor(1.0, 1.0, 1.0, 1.0)
  507.  
  508.     def __init__(self):
  509.         ui.Window.__init__(self)
  510.         self.SetWindowName("ChatInputSet")
  511.  
  512.         InsertChatInputSetWindow(self)
  513.         self.__Create()
  514.  
  515.     def __del__(self):
  516.         ui.Window.__del__(self)
  517.  
  518.     def __Create(self):
  519.         chatModeButton = ChatModeButton()
  520.         chatModeButton.SetParent(self)
  521.         chatModeButton.SetSize(40, 17)
  522.         chatModeButton.SetText(localeInfo.CHAT_NORMAL)
  523.         chatModeButton.SetPosition(7, 2)
  524.         chatModeButton.SAFE_SetEvent(self.OnChangeChatMode)
  525.         self.chatModeButton = chatModeButton
  526.  
  527.         chatLine = ChatLine()
  528.         chatLine.SetParent(self)
  529.         chatLine.SetMax(512)
  530.         chatLine.SetUserMax(76)
  531.         chatLine.SetText("")
  532.         chatLine.SAFE_SetTabEvent(self.OnChangeChatMode)
  533.         chatLine.x = 0
  534.         chatLine.y = 0
  535.         chatLine.width = 0
  536.         chatLine.height = 0
  537.         self.chatLine = chatLine
  538.  
  539.         btnSend = ui.Button()
  540.         btnSend.SetParent(self)
  541.         btnSend.SetUpVisual("d:/ymir work/ui/game/taskbar/Send_Chat_Button_01.sub")
  542.         btnSend.SetOverVisual("d:/ymir work/ui/game/taskbar/Send_Chat_Button_02.sub")
  543.         btnSend.SetDownVisual("d:/ymir work/ui/game/taskbar/Send_Chat_Button_03.sub")
  544.         btnSend.SetToolTipText(localeInfo.CHAT_SEND_CHAT)
  545.         btnSend.SAFE_SetEvent(self.chatLine.OnIMEReturn)
  546.         self.btnSend = btnSend
  547.  
  548.     def Destroy(self):
  549.         self.chatModeButton = None
  550.         self.chatLine = None
  551.         self.btnSend = None
  552.  
  553.     def Open(self):
  554.         self.chatLine.Show()
  555.         self.chatLine.SetPosition(57, 5)
  556.         self.chatLine.SetFocus()
  557.         self.chatLine.OpenChat()
  558.  
  559.         self.chatModeButton.SetPosition(7, 2)
  560.         self.chatModeButton.Show()
  561.  
  562.         self.btnSend.Show()
  563.         self.Show()
  564.  
  565.         self.RefreshPosition()
  566.         return True
  567.  
  568.     def Close(self):
  569.         self.chatLine.KillFocus()
  570.         self.chatLine.Hide()
  571.         self.chatModeButton.Hide()
  572.         self.btnSend.Hide()
  573.         self.Hide()
  574.         return True
  575.  
  576.     def SetEscapeEvent(self, event):
  577.         self.chatLine.SetEscapeEvent(event)
  578.  
  579.     def SetReturnEvent(self, event):
  580.         self.chatLine.SetReturnEvent(event)
  581.  
  582.     def OnChangeChatMode(self):
  583.         RefreshChatMode()
  584.  
  585.     def OnRefreshChatMode(self):
  586.         self.chatLine.ChangeChatMode()
  587.         self.chatModeButton.SetText(self.chatLine.GetCurrentChatModeName())
  588.  
  589.     def SetChatFocus(self):
  590.         self.chatLine.SetFocus()
  591.  
  592.     def KillChatFocus(self):
  593.         self.chatLine.KillFocus()
  594.  
  595.     def SetChatMax(self, max):
  596.         self.chatLine.SetUserMax(max)
  597.  
  598.     def RefreshPosition(self):
  599.         if localeInfo.IsARABIC():
  600.             self.chatLine.SetSize(self.GetWidth() - 93, 18)
  601.         else:
  602.             self.chatLine.SetSize(self.GetWidth() - 93, 13)
  603.  
  604.         self.btnSend.SetPosition(self.GetWidth() - 25, 2)
  605.  
  606.         (self.chatLine.x, self.chatLine.y, self.chatLine.width, self.chatLine.height) = self.chatLine.GetRect()
  607.  
  608.     def BindInterface(self, interface):
  609.         self.chatLine.BindInterface(interface)
  610.  
  611.     def OnRender(self):
  612.         (x, y, width, height) = self.chatLine.GetRect()
  613.         ui.RenderRoundBox(x-4, y-3, width+7, height+4, self.CHAT_OUTLINE_COLOR)
  614.  
  615. ## ChatWindow
  616. class ChatWindow(ui.Window):
  617.  
  618.     BOARD_START_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 0.0)
  619.     BOARD_END_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 0.8)
  620.     BOARD_MIDDLE_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 0.5)
  621.     CHAT_OUTLINE_COLOR = grp.GenerateColor(1.0, 1.0, 1.0, 1.0)
  622.  
  623.     EDIT_LINE_HEIGHT = 25
  624.     CHAT_WINDOW_WIDTH = 600
  625.    
  626.     class ChatBackBoard(ui.Window):
  627.         def __init__(self):
  628.             ui.Window.__init__(self)
  629.         def __del__(self):
  630.             ui.Window.__del__(self)
  631.  
  632.     class ChatButton(ui.DragButton):
  633.  
  634.         def __init__(self):
  635.             ui.DragButton.__init__(self)
  636.             self.AddFlag("float")
  637.             self.AddFlag("movable")
  638.             self.AddFlag("restrict_x")
  639.             self.topFlag = False
  640.             self.SetWindowName("ChatWindow:ChatButton")
  641.        
  642.  
  643.         def __del__(self):
  644.             ui.DragButton.__del__(self)
  645.  
  646.         def SetOwner(self, owner):
  647.             self.owner = owner
  648.  
  649.         def OnMouseOverIn(self):
  650.             app.SetCursor(app.VSIZE)
  651.  
  652.         def OnMouseOverOut(self):
  653.             app.SetCursor(app.NORMAL)
  654.  
  655.         def OnTop(self):
  656.             if True == self.topFlag:
  657.                 return
  658.  
  659.             self.topFlag = True
  660.             self.owner.SetTop()
  661.             self.topFlag = False
  662.  
  663.     def __init__(self):
  664.         ui.Window.__init__(self)
  665.         self.AddFlag("float")
  666.  
  667.         self.SetWindowName("ChatWindow")
  668.         self.__RegisterChatColorDict()
  669.  
  670.         self.boardState = chat.BOARD_STATE_VIEW
  671.         self.chatID = chat.CreateChatSet(chat.CHAT_SET_CHAT_WINDOW)
  672.         chat.SetBoardState(self.chatID, chat.BOARD_STATE_VIEW)
  673.  
  674.         self.xBar = 0
  675.         self.yBar = 0
  676.         self.widthBar = 0
  677.         self.heightBar = 0
  678.         self.curHeightBar = 0
  679.         self.visibleLineCount = 0
  680.         self.scrollBarPos = 1.0
  681.         self.scrollLock = False
  682.  
  683.         chatInputSet = ChatInputSet()
  684.         chatInputSet.SetParent(self)
  685.         chatInputSet.SetEscapeEvent(ui.__mem_func__(self.CloseChat))
  686.         chatInputSet.SetReturnEvent(ui.__mem_func__(self.CloseChat))
  687.         chatInputSet.SetSize(550, 25)
  688.         self.chatInputSet = chatInputSet
  689.  
  690.         btnSendWhisper = ui.Button()
  691.         btnSendWhisper.SetParent(self)
  692.         btnSendWhisper.SetUpVisual("d:/ymir work/ui/game/taskbar/Send_Whisper_Button_01.sub")
  693.         btnSendWhisper.SetOverVisual("d:/ymir work/ui/game/taskbar/Send_Whisper_Button_02.sub")
  694.         btnSendWhisper.SetDownVisual("d:/ymir work/ui/game/taskbar/Send_Whisper_Button_03.sub")
  695.         btnSendWhisper.SetToolTipText(localeInfo.CHAT_SEND_MEMO)
  696.         btnSendWhisper.Hide()
  697.         self.btnSendWhisper = btnSendWhisper
  698.  
  699.         btnChatLog = ui.Button()
  700.         btnChatLog.SetParent(self)
  701.         btnChatLog.SetUpVisual("d:/ymir work/ui/game/taskbar/Open_Chat_Log_Button_01.sub")
  702.         btnChatLog.SetOverVisual("d:/ymir work/ui/game/taskbar/Open_Chat_Log_Button_02.sub")
  703.         btnChatLog.SetDownVisual("d:/ymir work/ui/game/taskbar/Open_Chat_Log_Button_03.sub")
  704.         btnChatLog.SetToolTipText(localeInfo.CHAT_LOG)
  705.         btnChatLog.Hide()
  706.         self.btnChatLog = btnChatLog
  707.  
  708.         btnChatSizing = self.ChatButton()
  709.         btnChatSizing.SetOwner(self)
  710.         btnChatSizing.SetMoveEvent(ui.__mem_func__(self.Refresh))
  711.         btnChatSizing.Hide()
  712.         self.btnChatSizing = btnChatSizing
  713.  
  714.         imgChatBarLeft = ui.ImageBox()
  715.         imgChatBarLeft.SetParent(self.btnChatSizing)
  716.         imgChatBarLeft.AddFlag("not_pick")
  717.         imgChatBarLeft.LoadImage("d:/ymir work/ui/pattern/chat_bar_left.tga")
  718.         imgChatBarLeft.Show()
  719.         self.imgChatBarLeft = imgChatBarLeft
  720.         imgChatBarRight = ui.ImageBox()
  721.         imgChatBarRight.SetParent(self.btnChatSizing)
  722.         imgChatBarRight.AddFlag("not_pick")
  723.         imgChatBarRight.LoadImage("d:/ymir work/ui/pattern/chat_bar_right.tga")
  724.         imgChatBarRight.Show()
  725.         self.imgChatBarRight = imgChatBarRight
  726.         imgChatBarMiddle = ui.ExpandedImageBox()
  727.         imgChatBarMiddle.SetParent(self.btnChatSizing)
  728.         imgChatBarMiddle.AddFlag("not_pick")
  729.         imgChatBarMiddle.LoadImage("d:/ymir work/ui/pattern/chat_bar_middle.tga")
  730.         imgChatBarMiddle.Show()
  731.         self.imgChatBarMiddle = imgChatBarMiddle
  732.  
  733.         scrollBar = ui.ScrollBar()
  734.         scrollBar.AddFlag("float")
  735.         scrollBar.SetScrollEvent(ui.__mem_func__(self.OnScroll))
  736.         self.scrollBar = scrollBar
  737.  
  738.         self.Refresh()
  739.         self.chatInputSet.RefreshPosition() # RTL 시 위치를 제대로 잡으려면 위치 갱신이 필요하다
  740.    
  741.     def __del__(self):
  742.         ui.Window.__del__(self)
  743.  
  744.     if app.ENABLE_TRADE_CHAT:
  745.         CHAT_COLOR_DICT = {
  746.             chat.CHAT_TYPE_TALKING : colorInfo.CHAT_RGB_TALK,
  747.             chat.CHAT_TYPE_INFO : colorInfo.CHAT_RGB_INFO,
  748.             chat.CHAT_TYPE_NOTICE : colorInfo.CHAT_RGB_NOTICE,
  749.             chat.CHAT_TYPE_PARTY : colorInfo.CHAT_RGB_PARTY,
  750.             chat.CHAT_TYPE_GUILD : colorInfo.CHAT_RGB_GUILD,
  751.             chat.CHAT_TYPE_COMMAND : colorInfo.CHAT_RGB_COMMAND,
  752.             chat.CHAT_TYPE_SHOUT : colorInfo.CHAT_RGB_SHOUT,
  753.             chat.CHAT_TYPE_WHISPER : colorInfo.CHAT_RGB_WHISPER,
  754.             chat.CHAT_TYPE_SHOUT_TRADE : colorInfo.CHAT_RGB_TRADE,
  755.         }
  756.  
  757.     else:
  758.         CHAT_COLOR_DICT = {
  759.             chat.CHAT_TYPE_TALKING : colorInfo.CHAT_RGB_TALK,
  760.             chat.CHAT_TYPE_INFO : colorInfo.CHAT_RGB_INFO,
  761.             chat.CHAT_TYPE_NOTICE : colorInfo.CHAT_RGB_NOTICE,
  762.             chat.CHAT_TYPE_PARTY : colorInfo.CHAT_RGB_PARTY,
  763.             chat.CHAT_TYPE_GUILD : colorInfo.CHAT_RGB_GUILD,
  764.             chat.CHAT_TYPE_COMMAND : colorInfo.CHAT_RGB_COMMAND,
  765.             chat.CHAT_TYPE_SHOUT : colorInfo.CHAT_RGB_SHOUT,
  766.             chat.CHAT_TYPE_WHISPER : colorInfo.CHAT_RGB_WHISPER,
  767.     }
  768.  
  769.         for colorItem in CHAT_COLOR_DICT.items():
  770.             type=colorItem[0]
  771.             rgb=colorItem[1]
  772.             chat.SetChatColor(type, rgb[0], rgb[1], rgb[2])
  773.  
  774.     def Destroy(self):
  775.         self.chatInputSet.Destroy()
  776.         self.chatInputSet = None
  777.  
  778.         self.btnSendWhisper = 0
  779.         self.btnChatLog = 0
  780.         self.btnChatSizing = 0
  781.  
  782.     ################
  783.     ## Open & Close
  784.     def OpenChat(self):
  785.         self.SetSize(self.CHAT_WINDOW_WIDTH, 25)
  786.         chat.SetBoardState(self.chatID, chat.BOARD_STATE_EDIT)
  787.         self.boardState = chat.BOARD_STATE_EDIT
  788.  
  789.         (x, y, width, height) = self.GetRect()
  790.         (btnX, btnY) = self.btnChatSizing.GetGlobalPosition()
  791.  
  792.         if localeInfo.IsARABIC():
  793.             chat.SetPosition(self.chatID, x + width - 10, y)
  794.         else:  
  795.             chat.SetPosition(self.chatID, x + 10, y)
  796.  
  797.         chat.SetHeight(self.chatID, y - btnY - self.EDIT_LINE_HEIGHT + 100)
  798.  
  799.         if self.IsShow():
  800.             self.btnChatSizing.Show()
  801.  
  802.         self.Refresh()
  803.  
  804.         self.btnSendWhisper.SetPosition(self.GetWidth() - 50, 2)
  805.         self.btnSendWhisper.Show()
  806.  
  807.         self.btnChatLog.SetPosition(self.GetWidth() - 25, 2)
  808.         self.btnChatLog.Show()
  809.  
  810.         self.chatInputSet.Open()
  811.         self.chatInputSet.SetTop()
  812.         self.SetTop()
  813.  
  814.     def CloseChat(self):
  815.         chat.SetBoardState(self.chatID, chat.BOARD_STATE_VIEW)
  816.         self.boardState = chat.BOARD_STATE_VIEW
  817.  
  818.         (x, y, width, height) = self.GetRect()
  819.  
  820.         if localeInfo.IsARABIC():
  821.             chat.SetPosition(self.chatID, x + width - 10, y + self.EDIT_LINE_HEIGHT)
  822.         else:
  823.             chat.SetPosition(self.chatID, x + 10, y + self.EDIT_LINE_HEIGHT)
  824.  
  825.         self.SetSize(self.CHAT_WINDOW_WIDTH, 0)
  826.  
  827.         self.chatInputSet.Close()
  828.         self.btnSendWhisper.Hide()
  829.         self.btnChatLog.Hide()
  830.         self.btnChatSizing.Hide()
  831.        
  832.         self.Refresh()
  833.  
  834.     def SetSendWhisperEvent(self, event):
  835.         self.btnSendWhisper.SetEvent(event)
  836.  
  837.     def SetOpenChatLogEvent(self, event):
  838.         self.btnChatLog.SetEvent(event)
  839.  
  840.     def IsEditMode(self):
  841.         if chat.BOARD_STATE_EDIT == self.boardState:
  842.             return True
  843.  
  844.         return False
  845.  
  846.     def __RefreshSizingBar(self):
  847.         (x, y, width, height) = self.GetRect()
  848.         gxChat, gyChat = self.btnChatSizing.GetGlobalPosition()
  849.         self.btnChatSizing.SetPosition(x, gyChat)
  850.         self.btnChatSizing.SetSize(width, 22)
  851.         self.imgChatBarLeft.SetPosition(0, 0)
  852.         self.imgChatBarRight.SetPosition(width - 64, 0)
  853.         self.imgChatBarMiddle.SetPosition(64, 0)
  854.         self.imgChatBarMiddle.SetRenderingRect(0.0, 0.0, float(width - 128) / 64.0 - 1.0, 0.0)
  855.  
  856.     def SetPosition(self, x, y):
  857.         ui.Window.SetPosition(self, x, y)
  858.         self.__RefreshSizingBar()
  859.  
  860.     def SetSize(self, width, height):
  861.         ui.Window.SetSize(self, width, height)
  862.         self.__RefreshSizingBar()
  863.  
  864.     def SetHeight(self, height):
  865.         gxChat, gyChat = self.btnChatSizing.GetGlobalPosition()
  866.         self.btnChatSizing.SetPosition(gxChat, wndMgr.GetScreenHeight() - height)
  867.  
  868.     ###########
  869.     ## Refresh
  870.     def Refresh(self):
  871.         if self.boardState == chat.BOARD_STATE_EDIT:
  872.             self.RefreshBoardEditState()
  873.         elif self.boardState == chat.BOARD_STATE_VIEW:
  874.             self.RefreshBoardViewState()
  875.  
  876.     def RefreshBoardEditState(self):
  877.  
  878.         (x, y, width, height) = self.GetRect()
  879.         (btnX, btnY) = self.btnChatSizing.GetGlobalPosition()
  880.  
  881.         self.xBar = x
  882.         self.yBar = btnY
  883.         self.widthBar = width
  884.         self.heightBar = y - btnY + self.EDIT_LINE_HEIGHT
  885.         self.curHeightBar = self.heightBar
  886.  
  887.         if localeInfo.IsARABIC():
  888.             chat.SetPosition(self.chatID, x + width - 10, y)
  889.         else:
  890.             chat.SetPosition(self.chatID, x + 10, y)
  891.  
  892.         chat.SetHeight(self.chatID, y - btnY - self.EDIT_LINE_HEIGHT)
  893.         chat.ArrangeShowingChat(self.chatID)
  894.  
  895.         if btnY > y:
  896.             self.btnChatSizing.SetPosition(btnX, y)
  897.             self.heightBar = self.EDIT_LINE_HEIGHT
  898.  
  899.     def RefreshBoardViewState(self):
  900.         (x, y, width, height) = self.GetRect()
  901.         (btnX, btnY) = self.btnChatSizing.GetGlobalPosition()
  902.         textAreaHeight = self.visibleLineCount * chat.GetLineStep(self.chatID)
  903.  
  904.         if localeInfo.IsARABIC():
  905.             chat.SetPosition(self.chatID, x + width - 10, y + self.EDIT_LINE_HEIGHT)
  906.         else:
  907.             chat.SetPosition(self.chatID, x + 10, y + self.EDIT_LINE_HEIGHT)
  908.  
  909.         chat.SetHeight(self.chatID, y - btnY - self.EDIT_LINE_HEIGHT + 100)
  910.  
  911.         if self.boardState == chat.BOARD_STATE_EDIT:
  912.             textAreaHeight += 45
  913.         elif self.visibleLineCount != 0:
  914.             textAreaHeight += 10 + 10
  915.        
  916.         self.xBar = x
  917.         self.yBar = y + self.EDIT_LINE_HEIGHT - textAreaHeight
  918.         self.widthBar = width
  919.         self.heightBar = textAreaHeight
  920.  
  921.         self.scrollBar.Hide()
  922.  
  923.     ##########
  924.     ## Render
  925.     def OnUpdate(self):
  926.         if self.boardState == chat.BOARD_STATE_EDIT:
  927.             chat.Update(self.chatID)
  928.         elif self.boardState == chat.BOARD_STATE_VIEW:
  929.             if systemSetting.IsViewChat():
  930.                 chat.Update(self.chatID)
  931.  
  932.     def OnRender(self):
  933.         if chat.GetVisibleLineCount(self.chatID) != self.visibleLineCount:
  934.             self.visibleLineCount = chat.GetVisibleLineCount(self.chatID)
  935.             self.Refresh()
  936.  
  937.         if self.curHeightBar != self.heightBar:
  938.             self.curHeightBar += (self.heightBar - self.curHeightBar) / 10
  939.  
  940.         if self.boardState == chat.BOARD_STATE_EDIT:
  941.             grp.SetColor(self.BOARD_MIDDLE_COLOR)
  942.             grp.RenderBar(self.xBar, self.yBar + (self.heightBar - self.curHeightBar) + 10, self.widthBar, self.curHeightBar)
  943.             chat.Render(self.chatID)
  944.         elif self.boardState == chat.BOARD_STATE_VIEW:
  945.             if systemSetting.IsViewChat():
  946.                 grp.RenderGradationBar(self.xBar, self.yBar + (self.heightBar - self.curHeightBar), self.widthBar, self.curHeightBar, self.BOARD_START_COLOR, self.BOARD_END_COLOR)
  947.                 chat.Render(self.chatID)
  948.  
  949.     ##########
  950.     ## Event
  951.     def OnTop(self):
  952.         self.btnChatSizing.SetTop()
  953.         self.scrollBar.SetTop()
  954.  
  955.     def OnScroll(self):
  956.         if not self.scrollLock:
  957.             self.scrollBarPos = self.scrollBar.GetPos()
  958.  
  959.         lineCount = chat.GetLineCount(self.chatID)
  960.         visibleLineCount = chat.GetVisibleLineCount(self.chatID)
  961.         endLine = visibleLineCount + int(float(lineCount - visibleLineCount) * self.scrollBarPos)
  962.  
  963.         chat.SetEndPos(self.chatID, self.scrollBarPos)
  964.  
  965.     def OnChangeChatMode(self):
  966.         self.chatInputSet.OnChangeChatMode()
  967.  
  968.     def SetChatFocus(self):
  969.         self.chatInputSet.SetChatFocus()           
  970.  
  971.     def BindInterface(self, interface):
  972.         self.chatInputSet.BindInterface(interface)
  973.  
  974. ## ChatLogWindow
  975. class ChatLogWindow(ui.Window):
  976.  
  977.     BLOCK_WIDTH = 32
  978.    
  979. class ChatLine(ui.EditLine):
  980.     if app.ENABLE_TRADE_CHAT:
  981.         CHAT_MODE_NAME = ( locale.CHAT_NORMAL, locale.CHAT_PARTY, locale.CHAT_GUILD, locale.CHAT_SHOUT, locale.CHAT_INFORMATION, locale.CHAT_NOTICE, "Trade Chat", )
  982.         CHAT_MODE_INDEX = ( chat.CHAT_TYPE_TALKING,
  983.                             chat.CHAT_TYPE_PARTY,
  984.                             chat.CHAT_TYPE_GUILD,
  985.                             chat.CHAT_TYPE_SHOUT,
  986.                             chat.CHAT_TYPE_INFO,
  987.                             chat.CHAT_TYPE_NOTICE,
  988.                             chat.CHAT_TYPE_SHOUT_TRADE, )
  989.     else:
  990.         CHAT_MODE_NAME = ( locale.CHAT_NORMAL, locale.CHAT_PARTY, locale.CHAT_GUILD, locale.CHAT_SHOUT, locale.CHAT_INFORMATION, locale.CHAT_NOTICE, )
  991.         CHAT_MODE_INDEX = ( chat.CHAT_TYPE_TALKING,
  992.                             chat.CHAT_TYPE_PARTY,
  993.                             chat.CHAT_TYPE_GUILD,
  994.                             chat.CHAT_TYPE_SHOUT,
  995.                             chat.CHAT_TYPE_INFO,
  996.                             chat.CHAT_TYPE_NOTICE, )
  997.  
  998.     CHAT_LOG_WINDOW_MINIMUM_WIDTH = 450
  999.     CHAT_LOG_WINDOW_MINIMUM_HEIGHT = 120
  1000.  
  1001.     class ResizeButton(ui.DragButton):
  1002.  
  1003.         def __init__(self):
  1004.             ui.DragButton.__init__(self)
  1005.  
  1006.         def __del__(self):
  1007.             ui.DragButton.__del__(self)
  1008.  
  1009.         def OnMouseOverIn(self):
  1010.             app.SetCursor(app.HVSIZE)
  1011.  
  1012.         def OnMouseOverOut(self):
  1013.             app.SetCursor(app.NORMAL)
  1014.  
  1015.     def __init__(self):
  1016.  
  1017.         self.allChatMode = True
  1018.         self.chatInputSet = None
  1019.  
  1020.         ui.Window.__init__(self)
  1021.         self.AddFlag("float")
  1022.         self.AddFlag("movable")
  1023.         self.SetWindowName("ChatLogWindow")
  1024.         self.__CreateChatInputSet()
  1025.         self.__CreateWindow()
  1026.         self.__CreateButton()
  1027.         self.__CreateScrollBar()
  1028.  
  1029.         self.chatID = chat.CreateChatSet(chat.CHAT_SET_LOG_WINDOW)
  1030.         chat.SetBoardState(self.chatID, chat.BOARD_STATE_LOG)
  1031.         for i in self.CHAT_MODE_INDEX:
  1032.             chat.EnableChatMode(self.chatID, i)
  1033.  
  1034.         self.SetPosition(20, 20)
  1035.         self.SetSize(self.CHAT_LOG_WINDOW_MINIMUM_WIDTH, self.CHAT_LOG_WINDOW_MINIMUM_HEIGHT)
  1036.         self.btnSizing.SetPosition(self.CHAT_LOG_WINDOW_MINIMUM_WIDTH-self.btnSizing.GetWidth(), self.CHAT_LOG_WINDOW_MINIMUM_HEIGHT-self.btnSizing.GetHeight()+2)
  1037.  
  1038.         self.OnResize()
  1039.  
  1040.     def __CreateChatInputSet(self):
  1041.         chatInputSet = ChatInputSet()
  1042.         chatInputSet.SetParent(self)
  1043.         chatInputSet.SetEscapeEvent(ui.__mem_func__(self.Close))
  1044.         chatInputSet.SetWindowVerticalAlignBottom()
  1045.         chatInputSet.Open()
  1046.         self.chatInputSet = chatInputSet
  1047.  
  1048.     def __CreateWindow(self):
  1049.         imgLeft = ui.ImageBox()
  1050.         imgLeft.AddFlag("not_pick")
  1051.         imgLeft.SetParent(self)            
  1052.  
  1053.         imgCenter = ui.ExpandedImageBox()
  1054.         imgCenter.AddFlag("not_pick")
  1055.         imgCenter.SetParent(self)
  1056.        
  1057.         imgRight = ui.ImageBox()
  1058.         imgRight.AddFlag("not_pick")
  1059.         imgRight.SetParent(self)           
  1060.        
  1061.         if localeInfo.IsARABIC():
  1062.             imgLeft.LoadImage("locale/ae/ui/pattern/titlebar_left.tga")
  1063.             imgCenter.LoadImage("locale/ae/ui/pattern/titlebar_center.tga")
  1064.             imgRight.LoadImage("locale/ae/ui/pattern/titlebar_right.tga")
  1065.         else:
  1066.             imgLeft.LoadImage("d:/ymir work/ui/pattern/chatlogwindow_titlebar_left.tga")
  1067.             imgCenter.LoadImage("d:/ymir work/ui/pattern/chatlogwindow_titlebar_middle.tga")
  1068.             imgRight.LoadImage("d:/ymir work/ui/pattern/chatlogwindow_titlebar_right.tga")     
  1069.  
  1070.         imgLeft.Show()
  1071.         imgCenter.Show()
  1072.         imgRight.Show()
  1073.  
  1074.         btnClose = ui.Button()
  1075.         btnClose.SetParent(self)
  1076.         btnClose.SetUpVisual("d:/ymir work/ui/public/close_button_01.sub")
  1077.         btnClose.SetOverVisual("d:/ymir work/ui/public/close_button_02.sub")
  1078.         btnClose.SetDownVisual("d:/ymir work/ui/public/close_button_03.sub")
  1079.         btnClose.SetToolTipText(localeInfo.UI_CLOSE, 0, -23)
  1080.         btnClose.SetEvent(ui.__mem_func__(self.Close))
  1081.         btnClose.Show()
  1082.  
  1083.         btnSizing = self.ResizeButton()
  1084.         btnSizing.SetParent(self)
  1085.         btnSizing.SetMoveEvent(ui.__mem_func__(self.OnResize))
  1086.         btnSizing.SetSize(16, 16)
  1087.         btnSizing.Show()
  1088.  
  1089.         titleName = ui.TextLine()
  1090.         titleName.SetParent(self)
  1091.        
  1092.         if localeInfo.IsARABIC():
  1093.             titleName.SetPosition(self.GetWidth()-20, 6)
  1094.         else:
  1095.             titleName.SetPosition(20, 6)
  1096.            
  1097.         titleName.SetText(localeInfo.CHAT_LOG_TITLE)
  1098.         titleName.Show()
  1099.  
  1100.         self.imgLeft = imgLeft
  1101.         self.imgCenter = imgCenter
  1102.         self.imgRight = imgRight
  1103.         self.btnClose = btnClose
  1104.         self.btnSizing = btnSizing
  1105.         self.titleName = titleName
  1106.  
  1107.     def __CreateButton(self):
  1108.    
  1109.         if localeInfo.IsARABIC():
  1110.             bx = 20
  1111.         else:
  1112.             bx = 13
  1113.  
  1114.         btnAll = ui.RadioButton()
  1115.         btnAll.SetParent(self)
  1116.         btnAll.SetPosition(bx, 24)
  1117.         btnAll.SetUpVisual("d:/ymir work/ui/public/xsmall_button_01.sub")
  1118.         btnAll.SetOverVisual("d:/ymir work/ui/public/xsmall_button_02.sub")
  1119.         btnAll.SetDownVisual("d:/ymir work/ui/public/xsmall_button_03.sub")
  1120.         btnAll.SetText(localeInfo.CHAT_ALL)
  1121.         btnAll.SetEvent(ui.__mem_func__(self.ToggleAllChatMode))
  1122.         btnAll.Down()
  1123.         btnAll.Show()
  1124.         self.btnAll = btnAll
  1125.  
  1126.         x = bx + 48
  1127.         i = 0
  1128.         self.modeButtonList = []
  1129.         for name in self.CHAT_MODE_NAME:
  1130.             btn = ui.ToggleButton()
  1131.             btn.SetParent(self)
  1132.             btn.SetPosition(x, 24)
  1133.             btn.SetUpVisual("d:/ymir work/ui/public/xsmall_button_01.sub")
  1134.             btn.SetOverVisual("d:/ymir work/ui/public/xsmall_button_02.sub")
  1135.             btn.SetDownVisual("d:/ymir work/ui/public/xsmall_button_03.sub")
  1136.             btn.SetText(name)
  1137.             btn.Show()
  1138.  
  1139.             mode = self.CHAT_MODE_INDEX[i]
  1140.             btn.SetToggleUpEvent(lambda arg=mode: self.ToggleChatMode(arg))
  1141.             btn.SetToggleDownEvent(lambda arg=mode: self.ToggleChatMode(arg))
  1142.             self.modeButtonList.append(btn)
  1143.  
  1144.             x += 48
  1145.             i += 1
  1146.  
  1147.     def __CreateScrollBar(self):
  1148.         scrollBar = ui.SmallThinScrollBar()
  1149.         scrollBar.SetParent(self)
  1150.         scrollBar.Show()
  1151.         scrollBar.SetScrollEvent(ui.__mem_func__(self.OnScroll))
  1152.         self.scrollBar = scrollBar
  1153.         self.scrollBarPos = 1.0
  1154.  
  1155.     def __del__(self):
  1156.         ui.Window.__del__(self)
  1157.  
  1158.     def Destroy(self):
  1159.         self.imgLeft = None
  1160.         self.imgCenter = None
  1161.         self.imgRight = None
  1162.         self.btnClose = None
  1163.         self.btnSizing = None
  1164.         self.modeButtonList = []
  1165.         self.scrollBar = None
  1166.         self.chatInputSet = None
  1167.  
  1168.     def ToggleAllChatMode(self):
  1169.         if self.allChatMode:
  1170.             return
  1171.  
  1172.         self.allChatMode = True
  1173.  
  1174.         for i in self.CHAT_MODE_INDEX:
  1175.             chat.EnableChatMode(self.chatID, i)
  1176.         for btn in self.modeButtonList:
  1177.             btn.SetUp()
  1178.  
  1179.     def ToggleChatMode(self, mode):
  1180.         if self.allChatMode:
  1181.             self.allChatMode = False
  1182.             for i in self.CHAT_MODE_INDEX:
  1183.                 chat.DisableChatMode(self.chatID, i)
  1184.             chat.EnableChatMode(self.chatID, mode)
  1185.             self.btnAll.SetUp()
  1186.  
  1187.         else:
  1188.             chat.ToggleChatMode(self.chatID, mode)
  1189.  
  1190.     def SetSize(self, width, height):
  1191.         self.imgCenter.SetRenderingRect(0.0, 0.0, float((width - self.BLOCK_WIDTH*2) - self.BLOCK_WIDTH) / self.BLOCK_WIDTH, 0.0)
  1192.         self.imgCenter.SetPosition(self.BLOCK_WIDTH, 0)
  1193.         self.imgRight.SetPosition(width - self.BLOCK_WIDTH, 0)
  1194.        
  1195.         if localeInfo.IsARABIC():
  1196.             self.titleName.SetPosition(self.GetWidth()-20, 3)
  1197.             self.btnClose.SetPosition(3, 3)
  1198.             self.scrollBar.SetPosition(1, 45)
  1199.         else:
  1200.             self.btnClose.SetPosition(width - self.btnClose.GetWidth() - 5, 5)         
  1201.             self.scrollBar.SetPosition(width - 15, 45)
  1202.            
  1203.         self.scrollBar.SetScrollBarSize(height - 45 - 12)
  1204.         self.scrollBar.SetPos(self.scrollBarPos)
  1205.         ui.Window.SetSize(self, width, height)
  1206.  
  1207.     def Open(self):
  1208.         self.OnResize()
  1209.         self.chatInputSet.SetChatFocus()
  1210.         self.Show()
  1211.  
  1212.     def Close(self):
  1213.         if self.chatInputSet:
  1214.             self.chatInputSet.KillChatFocus()
  1215.         self.Hide()
  1216.  
  1217.     def OnResize(self):
  1218.         x, y = self.btnSizing.GetLocalPosition()
  1219.         width = self.btnSizing.GetWidth()
  1220.         height = self.btnSizing.GetHeight()
  1221.  
  1222.         if x < self.CHAT_LOG_WINDOW_MINIMUM_WIDTH - width:
  1223.             self.btnSizing.SetPosition(self.CHAT_LOG_WINDOW_MINIMUM_WIDTH - width, y)
  1224.             return
  1225.         if y < self.CHAT_LOG_WINDOW_MINIMUM_HEIGHT - height:
  1226.             self.btnSizing.SetPosition(x, self.CHAT_LOG_WINDOW_MINIMUM_HEIGHT - height)
  1227.             return
  1228.  
  1229.         self.scrollBar.LockScroll()
  1230.         self.SetSize(x + width, y + height)
  1231.         self.scrollBar.UnlockScroll()
  1232.  
  1233.         if localeInfo.IsARABIC():
  1234.             self.chatInputSet.SetPosition(20, 25)
  1235.         else:
  1236.             self.chatInputSet.SetPosition(0, 25)
  1237.            
  1238.         self.chatInputSet.SetSize(self.GetWidth() - 20, 20)
  1239.         self.chatInputSet.RefreshPosition()
  1240.         self.chatInputSet.SetChatMax(self.GetWidth() / 8)
  1241.  
  1242.     def OnScroll(self):
  1243.         self.scrollBarPos = self.scrollBar.GetPos()
  1244.  
  1245.         lineCount = chat.GetLineCount(self.chatID)
  1246.         visibleLineCount = chat.GetVisibleLineCount(self.chatID)
  1247.         endLine = visibleLineCount + int(float(lineCount - visibleLineCount) * self.scrollBarPos)
  1248.  
  1249.         chat.SetEndPos(self.chatID, self.scrollBarPos)
  1250.  
  1251.     def OnRender(self):
  1252.         (x, y, width, height) = self.GetRect()
  1253.        
  1254.         if localeInfo.IsARABIC():
  1255.             grp.SetColor(0x77000000)
  1256.             grp.RenderBar(x+2, y+45, 13, height-45)
  1257.            
  1258.             grp.SetColor(0x77000000)
  1259.             grp.RenderBar(x, y, width, height)
  1260.             grp.SetColor(0x77000000)
  1261.             grp.RenderBox(x, y, width-2, height)
  1262.             grp.SetColor(0x77000000)
  1263.             grp.RenderBox(x+1, y+1, width-2, height)
  1264.  
  1265.             grp.SetColor(0xff989898)
  1266.             grp.RenderLine(x+width-13, y+height-1, 11, -11)
  1267.             grp.RenderLine(x+width-9, y+height-1, 7, -7)
  1268.             grp.RenderLine(x+width-5, y+height-1, 3, -3)
  1269.         else:
  1270.             grp.SetColor(0x77000000)
  1271.             grp.RenderBar(x+width-15, y+45, 13, height-45)
  1272.  
  1273.             grp.SetColor(0x77000000)
  1274.             grp.RenderBar(x, y, width, height)
  1275.             grp.SetColor(0x77000000)
  1276.             grp.RenderBox(x, y, width-2, height)
  1277.             grp.SetColor(0x77000000)
  1278.             grp.RenderBox(x+1, y+1, width-2, height)
  1279.  
  1280.             grp.SetColor(0xff989898)
  1281.             grp.RenderLine(x+width-13, y+height-1, 11, -11)
  1282.             grp.RenderLine(x+width-9, y+height-1, 7, -7)
  1283.             grp.RenderLine(x+width-5, y+height-1, 3, -3)
  1284.  
  1285.         #####
  1286.  
  1287.         chat.ArrangeShowingChat(self.chatID)
  1288.  
  1289.         if localeInfo.IsARABIC():
  1290.             chat.SetPosition(self.chatID, x + width - 10, y + height - 25)
  1291.         else:
  1292.             chat.SetPosition(self.chatID, x + 10, y + height - 25)
  1293.  
  1294.         chat.SetHeight(self.chatID, height - 45 - 25)
  1295.         chat.Update(self.chatID)
  1296.         chat.Render(self.chatID)
  1297.  
  1298.     def OnPressEscapeKey(self):
  1299.         self.Close()
  1300.         return True
  1301.  
  1302.     def BindInterface(self, interface):
  1303.         self.interface = interface
  1304.        
  1305.     def OnMouseLeftButtonDown(self):
  1306.         hyperlink = ui.GetHyperlink()
  1307.         if hyperlink:
  1308.             if app.IsPressed(app.DIK_LALT):
  1309.                 link = chat.GetLinkFromHyperlink(hyperlink)
  1310.                 ime.PasteString(link)
  1311.             else:
  1312.                 self.interface.MakeHyperlinkTooltip(hyperlink)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement