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

Moderator: Pocus

Post Reply
PeterTG19
Private First Class - Opel Blitz
Private First Class - Opel Blitz
Posts: 2
Joined: Wed Oct 16, 2019 3:40 am

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

Post 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!
PeterTG19
Private First Class - Opel Blitz
Private First Class - Opel Blitz
Posts: 2
Joined: Wed Oct 16, 2019 3:40 am

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

Post 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;
			}
GodOfNothing
Private First Class - Wehrmacht Inf
Private First Class - Wehrmacht Inf
Posts: 9
Joined: Sat Jun 15, 2019 8:55 pm

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

Post 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.
ChrisH
Lance Corporal - SdKfz 222
Lance Corporal - SdKfz 222
Posts: 22
Joined: Tue Mar 31, 2009 10:58 am

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

Post by ChrisH »

This is a great little patch thanks - makes reshuffling a lot less irritating!
Rooster62
Private First Class - Opel Blitz
Private First Class - Opel Blitz
Posts: 1
Joined: Mon Jan 31, 2022 1:39 pm

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

Post 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.
Post Reply

Return to “MOD”