-
Notifications
You must be signed in to change notification settings - Fork 105
tweak(challenge): Increase max number of general's challenge entry points to 32 #1615
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
base: main
Are you sure you want to change the base?
tweak(challenge): Increase max number of general's challenge entry points to 32 #1615
Conversation
GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ChallengeMenu.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ChallengeMenu.cpp
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ChallengeMenu.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ChallengeMenu.cpp
Outdated
Show resolved
Hide resolved
strButtonName.format("ChallengeMenu.wnd:GeneralPosition%d", i); | ||
buttonGeneralPositionID[i] = TheNameKeyGenerator->nameToKey( strButtonName ); | ||
buttonGeneralPosition[i] = TheWindowManager->winGetWindowFromId( parentMenu, buttonGeneralPositionID[i] ); | ||
DEBUG_ASSERTCRASH(buttonGeneralPosition[i], ("Could not find the ButtonGeneralPosition[%d]",i )); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this implementation can be better. On runtime we can determine the number of generals challenges like so:
NumGenerals = 0;
while (true)
{
strButtonName.format("ChallengeMenu.wnd:GeneralPosition%d", NumGenerals);
NameKey nameKey = TheNameKeyGenerator->nameToKey( strButtonName );
GameWindow* window = TheWindowManager->winGetWindowFromId( parentMenu, nameKey );
++numGenerals;
if (window == NULL)
break;
}
buttonGeneralPositionID = new GameWindow*[NumGenerals];
buttonGeneralPosition = new GameWindow*[NumGenerals];
for (Int i = 0; i < NumGenerals; ++i)
{
strButtonName.format("ChallengeMenu.wnd:GeneralPosition%d", i);
buttonGeneralPositionID[i] = TheNameKeyGenerator->nameToKey( strButtonName );
buttonGeneralPosition[i] = TheWindowManager->winGetWindowFromId( parentMenu, nameKey );
}
This way there needs to be no number cap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I know how to do this properly but will give it a go. Everything else has been fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We believe in you 🙏
Increases maximum number of potential generals challenges (visible on menu) to 32. This allows for mods where the number of player templates is unchanged, but there are variations of general's challenges for each faction.
The choice of 32 was an arbitrary nice number. Current use case would be 15.
Increase of
NUM_GENERALS
is coupled with skipping button logic wherebuttonGeneralPosition
has null entries.