Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False data when changing TabView.Visible to current value #125

Closed
nora-soderlund opened this issue Jun 26, 2021 · 2 comments
Closed

False data when changing TabView.Visible to current value #125

nora-soderlund opened this issue Jun 26, 2021 · 2 comments
Labels

Comments

@nora-soderlund
Copy link

nora-soderlund commented Jun 26, 2021

Changing the Visible property of an TabView instance to its current value will falsify some data and more importantly make IsAnyPauseMenuVisible return true, because of the false data, even if it should return false.

This is because the setter of TabView.Visible changes the properties and calls the methods it calls without considering if the visibility has actually changed.

        public bool Visible
        {
            get { return _visible; }
            set
            {
                _visible = value;

                if (value)
                {
                    Shared.NumberOfVisiblePauseMenus++;
                    NumberOfVisiblePauseMenus++;
                    N.SetPlayerControl(Game.LocalPlayer, false, 0);
                    N.AnimPostFxPlay("MinigameTransitionIn", 0, true);
                    if (PauseGame)
                        Game.IsPaused = true;
                }
                else
                {
                    CleanUp();
                    Shared.NumberOfVisiblePauseMenus--;
                    NumberOfVisiblePauseMenus--;
                    if (PauseGame)
                        Game.IsPaused = false;
                }
            }
        }

should be

        public bool Visible
        {
            get { return _visible; }
            set
            {
                // if the value is not changed, then don't change any properties or call any methods to avoid false data
                if(_visible == value)
                    return;

                _visible = value;

                if (value)
                {
                    Shared.NumberOfVisiblePauseMenus++;
                    NumberOfVisiblePauseMenus++;
                    N.SetPlayerControl(Game.LocalPlayer, false, 0);
                    N.AnimPostFxPlay("MinigameTransitionIn", 0, true);
                    if (PauseGame)
                        Game.IsPaused = true;
                }
                else
                {
                    CleanUp();
                    Shared.NumberOfVisiblePauseMenus--;
                    NumberOfVisiblePauseMenus--;
                    if (PauseGame)
                        Game.IsPaused = false;
                }
            }
        }

at https://github.com/alexguirre/RAGENativeUI/blob/master/Source/PauseMenu/TabView.cs#L57

@nora-soderlund
Copy link
Author

Minimal, Reproducible Example of this issue:

TabView tabView = new TabView("Title");

Game.Console.Print("IsAnyPauseMenuVisible: " + TabView.IsAnyPauseMenuVisible.ToString()); // IsAnyPauseMenuVisible: False

tabView.Visible = false;

Game.Console.Print("IsAnyPauseMenuVisible: " + TabView.IsAnyPauseMenuVisible.ToString()); // IsAnyPauseMenuVisible: True

@alexguirre alexguirre added the Bug label Jun 26, 2021
@alexguirre
Copy link
Owner

Thank you for the bug report and the fix. Will push it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants