<commit_before>Strict

Private

Import bono

Public

Class GuiButton Extends GuiBase Implements Touchable
    Private

    Global someButtonPressed:Bool
    Field isPressed:Bool
    Field sprite:Sprite

    Public

    Field trackLeavingMoves:Bool

    Method GetSprite:Sprite()
        Return sprite
    End

    Method SetSprite:Void(sprite:Sprite)
        SetColor(sprite.GetColor())
        SetPosition(sprite.GetPosition())
        SetSize(sprite.GetSize())
        Self.sprite = sprite
    End

    Method RemoveSprite:Void()
        If Not sprite Then Return

        Local oldSprite:Sprite = sprite
        sprite = Null

        SetColor(oldSprite.GetColor().Copy())
        SetPosition(oldSprite.GetPosition().Copy())
        SetSize(oldSprite.GetSize().Copy())
    End

    Method SetColor:Void(newColor:Color)
        LockedWithSprite("SetColor")
        Super.SetColor(newColor)
    End

    Method SetPosition:Void(newPos:Vector2D)
        LockedWithSprite("SetPosition")
        Super.SetPosition(newPos)
    End

    Method SetSize:Void(newSize:Vector2D)
        LockedWithSprite("SetSize")
        Super.SetSize(newSize)
    End

    Method OnRender:Void()
        If sprite Then sprite.OnRender()
    End

    Method Collide:Bool(pos:Vector2D)
        Local realPos:Vector2D = Director.TranslateSpace(pos)

        If sprite Then Return sprite.Collide(realPos)
        Return Super.Collide(realPos)
    End
<commit_msg>keep calling Sprite.OnUpdate even if inside GuiButton<commit_after>Strict

Private

Import bono

Public

Class GuiButton Extends GuiBase Implements Touchable, Updateable
    Private

    Global someButtonPressed:Bool
    Field isPressed:Bool
    Field sprite:Sprite

    Public

    Field trackLeavingMoves:Bool

    Method GetSprite:Sprite()
        Return sprite
    End

    Method SetSprite:Void(sprite:Sprite)
        SetColor(sprite.GetColor())
        SetPosition(sprite.GetPosition())
        SetSize(sprite.GetSize())
        Self.sprite = sprite
    End

    Method RemoveSprite:Void()
        If Not sprite Then Return

        Local oldSprite:Sprite = sprite
        sprite = Null

        SetColor(oldSprite.GetColor().Copy())
        SetPosition(oldSprite.GetPosition().Copy())
        SetSize(oldSprite.GetSize().Copy())
    End

    Method SetColor:Void(newColor:Color)
        LockedWithSprite("SetColor")
        Super.SetColor(newColor)
    End

    Method SetPosition:Void(newPos:Vector2D)
        LockedWithSprite("SetPosition")
        Super.SetPosition(newPos)
    End

    Method SetSize:Void(newSize:Vector2D)
        LockedWithSprite("SetSize")
        Super.SetSize(newSize)
    End

    Method OnUpdate:Void(timer:DeltaTimer)
        If sprite Then sprite.OnUpdate(timer)
    End

    Method OnRender:Void()
        If sprite Then sprite.OnRender()
    End

    Method Collide:Bool(pos:Vector2D)
        Local realPos:Vector2D = Director.TranslateSpace(pos)

        If sprite Then Return sprite.Collide(realPos)
        Return Super.Collide(realPos)
    End

{'fraction_non_alphanumeric': 0.07903439153439154, 'fraction_numerical': 0.0026455026455026454, 'mean_word_length': 2.809823677581864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5491300', 'n_tokens_mistral': 919, 'n_tokens_neox': 910, 'n_words': 184}