Page 1 of 1

[Mini-MOD] Reshuffle build options on build panel open

Posted: Wed Oct 16, 2019 4:01 am
by PeterTG19
With this mod, build options are reshuffled each time the build panel is opened. This is one way to get around the current random build options + reshuffle system, for anyone who feels it's not right.

It's a very simple mod, requiring only 1 additional line of code. Therefore, I'm not going to share the modified file, you'll need to DIY instead. This also avoids potential conflicts with other mods or future updates.

Installation:
  1. Open ...\Data\UI\RegionPanel.BSF in a text editor
  2. Search for "// Click on Order structure button". (Or find the code section shown below.)
  3. Look for the line "RegionPanel_ShowSubpanel("RegStruc");", and
  4. Add the line "Region_Structures_Underway_ResetPreChoice(regionID, FALSE)" above. (By above I mean above the line you found in the previous point.)
Uninstallation: Remove or comment out (add // before it) the line you added.

Explanation:
Build options (prechoices) are reset for the given regionID before the build panel is revealed by the ShowSubpanel routine.

It should look something like this:

Code: Select all

		// Click on Order structure button
		if  (IsUIObject(id, "RegExp_Infra"))
		{
			if (event == 1) // right click
			{
				Region_Structures_SetShuffle(regionID, FALSE);
				Region_Structures_Underway_Set(regionID, 0);
				needsUpdate = REGIONPANEL_UPDATE_ACTION;
			}
			
			// hide/show the list of buildable structures
			if (GetUIObjectVisible("RegStruc") == TRUE)
			{
				SetUIObjectVisible("RegStruc", FALSE);
			}
			else if (MapUI_NumStructureChoices(regionID) > 0)
			{
				Region_Structures_Underway_ResetPreChoice(regionID, FALSE)
				RegionPanel_ShowSubpanel("RegStruc");
				needsUpdate = REGIONPANEL_UPDATE_REFRESH;
			}
		}
Enjoy!

Re: [Mini-MOD] Reshuffle build options on build panel open

Posted: Wed Oct 16, 2019 6:58 am
by PeterTG19
Here's an even better version, in which the reshuffle button reshuffles the building options. No need to close and reopen the building panel.

This requires adding the same line of code, just to a different part of the same file that specifies the action to take when the reshuffle button is pressed, and commenting out the code for the original button action.

Original code (search for "if (IsUIObject(id, "RegStruc_Shuffle") == TRUE)" in RegionPanel.BSF):

Code: Select all

		if (GetUIObjectVisible("RegStruc") == TRUE)
		{
			if (IsUIObject(id, "RegStruc_Shuffle") == TRUE)
			{
				if (Region_Structures_GetShuffle(regionID) == TRUE)
				{
					Region_Structures_SetShuffle(regionID, FALSE);
					// leave the subpanel open
				}
				else
				{
					Region_Structures_SetShuffle(regionID, TRUE);
					SetUIObjectVisible("RegStruc", FALSE);
				}
				needsUpdate = REGIONPANEL_UPDATE_ACTION;
			}
Modded code:

Code: Select all

		if (GetUIObjectVisible("RegStruc") == TRUE)
		{
			if (IsUIObject(id, "RegStruc_Shuffle") == TRUE)
			{
				Region_Structures_Underway_ResetPreChoice(regionID, FALSE)
				// if (Region_Structures_GetShuffle(regionID) == TRUE)
				// {
				//	Region_Structures_SetShuffle(regionID, FALSE);
				//	// leave the subpanel open
				// }
				// else
				// {
				//	Region_Structures_SetShuffle(regionID, TRUE);
				//	SetUIObjectVisible("RegStruc", FALSE);
				// }
				needsUpdate = REGIONPANEL_UPDATE_ACTION;
			}

Re: [Mini-MOD] Reshuffle build options on build panel open

Posted: Fri Feb 12, 2021 6:51 am
by GodOfNothing
Any chance this still works? I used it when game first came out and had no issues. I haven't played in a couple months and just reinstalled with the DLC but unfortunately couldn't get this to work again.

Re: [Mini-MOD] Reshuffle build options on build panel open

Posted: Wed Apr 21, 2021 9:23 pm
by ChrisH
This is a great little patch thanks - makes reshuffling a lot less irritating!

Re: [Mini-MOD] Reshuffle build options on build panel open

Posted: Mon Jan 31, 2022 2:01 pm
by Rooster62
Thanks, PeterTG19!
The mini mod works perfectly yet. You made an easy tutorial for finding and replace the lines.
It's dense - and irritable - to wait for the necessary building. Well: no more.
Thanks a lot.