Advertisement
Guest User

Untitled

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