Jump to content

UI TextLink


Recommended Posts

M2 Download Center

This is the hidden content, please
( Internal )

Hi devs, today i'm going to release a simple TextLink. It works like a button but without a button, only with text. Let's see.

Spoiler

224034875dbfdab37a4a4e8f019173b9dedfef.g

 

It has Close event.

The python code:

Spoiler

class TextLink(ui.Window):

    ## COLORS
    NORMAL_COLOR = grp.GenerateColor(0.7607, 0.7607, 0.7607, 1.0)
    OVER_COLOR = 0xff1457c7
    DOWN_COLOR = 0xff0f3e8c
    
    def __init__(self):
        ui.Window.__init__(self)
        
        self.eventFunc = None
        self.eventArgs = None
        
        self.text = ui.TextLine()
        self.text.SetParent(self)
        self.text.Show()

        self.underline = ui.Line()
        self.underline.SetParent(self)
        self.underline.SetColor(self.NORMAL_COLOR)
        self.underline.Hide()
        
    def __del__(self):
        ui.Window.__del__(self)
        
    def SetText(self, text):
        self.text.SetText(text)
        self.SetSize(self.text.GetTextSize()[0], self.text.GetTextSize()[1])
        self.underline.SetPosition(0, self.text.GetTextSize()[1])
        self.underline.SetWindowHorizontalAlignCenter()
        self.underline.SetSize(self.text.GetTextSize()[0], 0)
        
    def OnMouseOverIn(self):
        self.text.SetPackedFontColor(self.OVER_COLOR)
        self.underline.SetColor(self.OVER_COLOR)
        self.underline.Show()
        
    def OnMouseOverOut(self):
        self.text.SetPackedFontColor(self.NORMAL_COLOR)
        self.underline.Hide()
        
    def OnMouseLeftButtonDown(self):
        self.text.SetPackedFontColor(self.DOWN_COLOR)
        self.underline.SetColor(self.DOWN_COLOR)
        self.underline.Show()
        
    def OnMouseLeftButtonUp(self):
        if self.eventFunc:
            apply(self.eventFunc, self.eventArgs)
        self.OnMouseOverOut()
            
    def SetEvent(self, event, *args):
        self.eventFunc = event
        self.eventArgs = args

Shitty spoiler deletes the tabs. Be carefull about tabs. Or go to pastebin: http://pastebin.com/CkNXmeAm

  • Metin2 Dev 7
  • Lmao 1
  • Love 8
Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.