DevTestingPizza / NativeUI

UI library for Grand Theft Auto V, ported to CitizenFX
MIT License
7 stars 1 forks source link

Bug: BigMessage TRANSITION_OUT #4

Closed d0p3t closed 5 years ago

d0p3t commented 5 years ago

Expected behavior: When a BigMessage timer has run out, it transitions out of the screen. Current behavior: Transition out never happens

Cause: When the "TRANSITION_OUT" function is called, the scaleform instantly gets disposed

if (_start != 0 && Game.GameTime - _start > _timer)
{
    _sc.CallFunction("TRANSITION_OUT");
    _start = 0;
    Dispose();
}

Fix: To fix this, we must add a _hasAnimatedOut condition and extend the _timer

if (_start != 0 && Game.GameTime - _start > _timer)
{
    if (!_hasAnimatedOut)
    {
        _sc.CallFunction("TRANSITION_OUT");
        _hasAnimatedOut = true;
        _timer += 750;
    }
    else
    {
        _start = 0;
        Dispose();
        _sc = null;
    }
}

The _hasAnimatedOut bool should be initialized as false every time a message method is called. For example:

public async void ShowColoredShard(string msg, string desc, HudColor textColor, HudColor bgColor, int time = 5000)
{
    await Load();
    _start = Game.GameTime;
    _sc.CallFunction("SHOW_SHARD_CENTERED_MP_MESSAGE", msg, desc, (int)bgColor, (int)textColor);
    _timer = time;
    _hasAnimatedOut = false;
}

Source: https://github.com/SonnyMontana/ragemp-cops-and-robbers/blob/ef5eff1f1301e2db113dd10ae72cc577dc50a1f4/client_packages/gamemode/scaleform_messages/BigMessage.js#L33

I thought I'd let you know ahead of time. Perhaps you want to fix this yourself or I can provide a PR on the weekend (too into my gamemode for the contest at the moment 😄 )

TomGrobbe commented 5 years ago

PR it I guess. I don’t use that stuff myself. And if I need it I’ll probably write my own proper functions for it anyway in the resource that I need it in lol