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

Calling ToolbarControl.SetFalse when the stock button has not been created will call the onTrue callbacks #22

Open
JonnyOThan opened this issue Jul 12, 2024 · 1 comment

Comments

@JonnyOThan
Copy link

	public void SetFalse()
	{
		if (stockButton != null)
		{
			stockButton.SetFalse();
		}
		else
		{
			ToggleButtonActive();
		}

		UpdateToolbarIcon();
	}

I have an event handler on level loaded:

 	Void TUFX.TexturesUnlimitedFXLoader:configGuiEnable ()+0x0 at C:\Users\Jon\source\repos\TUFX\Plugin\TUFX\Addon\TexturesUnlimitedFXLoader.cs:[600:13-600:35]	C#
>	Void ToolbarControl_NS.ToolbarControl:SetButtonActive ()+0x18 at /var/lib/jenkins/workspace/T-Z/ToolbarControl/ToolbarControl/ToolbarControl.cs:845	C#
 	Void ToolbarControl_NS.ToolbarControl:ToggleButtonActive ()+0x1b at /var/lib/jenkins/workspace/T-Z/ToolbarControl/ToolbarControl/ToolbarControl.cs:863	C#
 	Void ToolbarControl_NS.ToolbarControl:SetFalse ()+0x23 at /var/lib/jenkins/workspace/T-Z/ToolbarControl/ToolbarControl/ToolbarControl.cs:429	C#
 	Void TUFX.TexturesUnlimitedFXLoader:CloseConfigGui ()+0x6 at C:\Users\Jon\source\repos\TUFX\Plugin\TUFX\Addon\TexturesUnlimitedFXLoader.cs:[620:13-620:43]	C#
 	Void TUFX.TexturesUnlimitedFXLoader:onLevelLoaded (GameScenes)+0x22 at C:\Users\Jon\source\repos\TUFX\Plugin\TUFX\Addon\TexturesUnlimitedFXLoader.cs:[418:13-418:30]	C#
 	Void EventData`1:Fire (GameScenes)+0xb8 at :-1	C#
 	Boolean <FireLoadedEvent>d__46:MoveNext ()+0x9d at :-1	C#
 	Void UnityEngine.SetupCoroutine:InvokeMoveNext (IEnumerator, IntPtr)+0x27 at :-1	C#

My code:

        internal void CloseConfigGui()
        {
            mainToolbarControl.SetFalse();
        }

In Start():
                mainToolbarControl = gameObject.AddComponent<ToolbarControl>();
				mainToolbarControl.AddToAllToolbars(
                    configGuiEnable,
                    configGuiDisable,
                    ApplicationLauncher.AppScenes.ALWAYS,
					toolbarMainName,
                    toolbarMainName,
                    "TUFX/Assets/TUFX-Icon1",
                    "TUFX/Assets/TUFX-Icon1",
                    toolbarMainName);

I would expect this to either always call the onFalse callback, or at least do nothing if the button state is already "false." But it calls the onTrue callback instead via ToggleButtonActive because SetFalse doesn't check the current state of the button.

@JonnyOThan
Copy link
Author

JonnyOThan commented Jul 12, 2024

Looks like I can work around this by calling SetFalse(true) instead. Perhaps the overload without arguments should be removed? Although since the default parameter value of the other overload is false that would change behavior. Perhaps the one with no arg should just call SetFalse(true).

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

No branches or pull requests

1 participant