Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

DayV-git
Copy link

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 where buttonGeneralPosition has null entries.

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 ));
Copy link

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.

Copy link
Author

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

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We believe in you 🙏

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

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.