Skip to content

Commit 60a0f24

Browse files
authored
Merge pull request #49 from Andreas-W/ui_expansions
Allow 32 sidebar buttons
2 parents feae80e + c9ec4da commit 60a0f24

File tree

2 files changed

+43
-23
lines changed

2 files changed

+43
-23
lines changed

GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ class CommandButton : public Overridable
403403
/** Command sets are collections of configurable command buttons. They are used in the
404404
* command context sensitive window in the battle user interface */
405405
//-------------------------------------------------------------------------------------------------
406-
enum { MAX_COMMANDS_PER_SET = 18 }; // user interface max is 14 (but internally it's 18 for script only buttons!)
406+
enum { MAX_COMMANDS_PER_SET = 32 }; // user interface max is 14 (but internally it's 18 for script only buttons!)
407407
enum { MAX_RIGHT_HUD_UPGRADE_CAMEOS = 5};
408408
enum {
409409
MAX_PURCHASE_SCIENCE_RANK_1 = 4,
@@ -412,7 +412,7 @@ enum {
412412
};
413413
enum { MAX_STRUCTURE_INVENTORY_BUTTONS = 10 }; // there are this many physical buttons in "inventory" windows for structures
414414
enum { MAX_BUILD_QUEUE_BUTTONS = 9 };// physical button count for the build queue
415-
enum { MAX_SPECIAL_POWER_SHORTCUTS = 11};
415+
enum { MAX_SPECIAL_POWER_SHORTCUTS = 32};
416416
class CommandSet : public Overridable
417417
{
418418

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,20 @@ const FieldParse CommandSet::m_commandSetFieldParseTable[] =
717717
{ "16", CommandSet::parseCommandButton, (void *)15, offsetof( CommandSet, m_command ) },
718718
{ "17", CommandSet::parseCommandButton, (void *)16, offsetof( CommandSet, m_command ) },
719719
{ "18", CommandSet::parseCommandButton, (void *)17, offsetof( CommandSet, m_command ) },
720+
{ "19", CommandSet::parseCommandButton, (void *)18, offsetof( CommandSet, m_command ) },
721+
{ "20", CommandSet::parseCommandButton, (void *)19, offsetof( CommandSet, m_command ) },
722+
{ "21", CommandSet::parseCommandButton, (void *)20, offsetof( CommandSet, m_command ) },
723+
{ "22", CommandSet::parseCommandButton, (void *)21, offsetof( CommandSet, m_command ) },
724+
{ "23", CommandSet::parseCommandButton, (void *)22, offsetof( CommandSet, m_command ) },
725+
{ "24", CommandSet::parseCommandButton, (void *)23, offsetof( CommandSet, m_command ) },
726+
{ "25", CommandSet::parseCommandButton, (void *)24, offsetof( CommandSet, m_command ) },
727+
{ "26", CommandSet::parseCommandButton, (void *)25, offsetof( CommandSet, m_command ) },
728+
{ "27", CommandSet::parseCommandButton, (void *)26, offsetof( CommandSet, m_command ) },
729+
{ "28", CommandSet::parseCommandButton, (void *)27, offsetof( CommandSet, m_command ) },
730+
{ "29", CommandSet::parseCommandButton, (void *)28, offsetof( CommandSet, m_command ) },
731+
{ "30", CommandSet::parseCommandButton, (void *)29, offsetof( CommandSet, m_command ) },
732+
{ "31", CommandSet::parseCommandButton, (void *)30, offsetof( CommandSet, m_command ) },
733+
{ "32", CommandSet::parseCommandButton, (void *)31, offsetof( CommandSet, m_command ) },
720734
{ NULL, NULL, NULL, 0 } // keep this last
721735

722736
};
@@ -3263,14 +3277,18 @@ void ControlBar::initSpecialPowershortcutBar( Player *player)
32633277
id = TheNameKeyGenerator->nameToKey( windowName.str() );
32643278
m_specialPowerShortcutButtons[ i ] =
32653279
TheWindowManager->winGetWindowFromId( m_specialPowerShortcutParent, id );
3266-
m_specialPowerShortcutButtons[ i ]->winSetStatus( WIN_STATUS_USE_OVERLAY_STATES );
3267-
// Oh god... this is a total hack for shortcut buttons to handle rendering text top left corner...
3268-
m_specialPowerShortcutButtons[ i ]->winSetStatus( WIN_STATUS_SHORTCUT_BUTTON );
32693280

3270-
windowName.format( parentName, i+1 );
3271-
id = TheNameKeyGenerator->nameToKey( windowName.str() );
3272-
m_specialPowerShortcutButtonParents[ i ] =
3273-
TheWindowManager->winGetWindowFromId( m_specialPowerShortcutParent, id );
3281+
if (m_specialPowerShortcutButtons[i] != nullptr) {
3282+
3283+
m_specialPowerShortcutButtons[i]->winSetStatus(WIN_STATUS_USE_OVERLAY_STATES);
3284+
// Oh god... this is a total hack for shortcut buttons to handle rendering text top left corner...
3285+
m_specialPowerShortcutButtons[i]->winSetStatus(WIN_STATUS_SHORTCUT_BUTTON);
3286+
3287+
windowName.format(parentName, i + 1);
3288+
id = TheNameKeyGenerator->nameToKey(windowName.str());
3289+
m_specialPowerShortcutButtonParents[i] =
3290+
TheWindowManager->winGetWindowFromId(m_specialPowerShortcutParent, id);
3291+
}
32743292
} // end for i
32753293

32763294
}
@@ -3480,16 +3498,18 @@ void ControlBar::populateSpecialPowerShortcut( Player *player)
34803498
}
34813499
}
34823500

3483-
// make sure the window is not hidden
3484-
m_specialPowerShortcutButtons[ currentButton ]->winHide( FALSE );
3485-
m_specialPowerShortcutButtonParents[ currentButton ]->winHide( FALSE );
3486-
// enable by default
3487-
m_specialPowerShortcutButtons[ currentButton ]->winEnable( TRUE );
3488-
m_specialPowerShortcutButtonParents[ currentButton ]->winEnable( TRUE );
3489-
3490-
// populate the visible button with data from the command button
3491-
setControlCommand( m_specialPowerShortcutButtons[ currentButton ], commandButton );
3492-
GadgetButtonSetAltSound(m_specialPowerShortcutButtons[ currentButton ], "GUIGenShortcutClick");
3501+
if (m_specialPowerShortcutButtons[currentButton] != nullptr) {
3502+
// make sure the window is not hidden
3503+
m_specialPowerShortcutButtons[currentButton]->winHide(FALSE);
3504+
m_specialPowerShortcutButtonParents[currentButton]->winHide(FALSE);
3505+
// enable by default
3506+
m_specialPowerShortcutButtons[currentButton]->winEnable(TRUE);
3507+
m_specialPowerShortcutButtonParents[currentButton]->winEnable(TRUE);
3508+
3509+
// populate the visible button with data from the command button
3510+
setControlCommand(m_specialPowerShortcutButtons[currentButton], commandButton);
3511+
GadgetButtonSetAltSound(m_specialPowerShortcutButtons[currentButton], "GUIGenShortcutClick");
3512+
}
34933513
currentButton++;
34943514

34953515
} // end else
@@ -3512,7 +3532,7 @@ Bool ControlBar::hasAnyShortcutSelection() const
35123532
const CommandButton *command;
35133533

35143534
win = m_specialPowerShortcutButtons[ i ];
3515-
if( win->winIsHidden() == TRUE )
3535+
if( win == nullptr || win->winIsHidden() == TRUE )
35163536
continue;
35173537

35183538
// get the command from the control
@@ -3574,7 +3594,7 @@ void ControlBar::updateSpecialPowerShortcut( void )
35743594
// get the window
35753595
win = m_specialPowerShortcutButtons[ i ];
35763596

3577-
if( win->winIsHidden() == TRUE )
3597+
if( win==nullptr || win->winIsHidden() == TRUE )
35783598
continue;
35793599
// get the command from the control
35803600
command = (const CommandButton *)GadgetButtonGetData(win);
@@ -3667,7 +3687,7 @@ void ControlBar::drawSpecialPowerShortcutMultiplierText()
36673687
// get the window
36683688
win = m_specialPowerShortcutButtons[ i ];
36693689

3670-
if( win->winIsHidden() == TRUE )
3690+
if( win == nullptr || win->winIsHidden() == TRUE )
36713691
continue;
36723692
// get the command from the control
36733693
command = (const CommandButton *)GadgetButtonGetData(win);
@@ -3746,7 +3766,7 @@ void ControlBar::showSpecialPowerShortcut( void )
37463766
Bool dontAnimate = TRUE;
37473767
for( Int i = 0; i < m_currentlyUsedSpecialPowersButtons; ++i )
37483768
{
3749-
if (m_specialPowerShortcutButtons[i]->winGetUserData())
3769+
if (m_specialPowerShortcutButtons[i] == nullptr || m_specialPowerShortcutButtons[i]->winGetUserData())
37503770
{
37513771
dontAnimate = FALSE;
37523772
break;

0 commit comments

Comments
 (0)