Skip to content

Commit 633bbfb

Browse files
committed
enable new radius cursors and improve parsing
1 parent e7c4847 commit 633bbfb

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,10 @@ friend class Drawable; // for selection/deselection transactions
639639
// INI file parsing
640640
virtual const FieldParse* getFieldParse( void ) const { return s_fieldParseTable; }
641641

642+
// Generic "RadiusCursor" parser: cursor type is the token after the keyword (e.g. "GUARD_AREA"),
643+
// then the RadiusDecalTemplate fields; stores into m_radiusCursors[type].
644+
static void parseRadiusCursor( INI* ini, void* instance, void* store, const void* userData );
645+
642646

643647
//Provides a global way to determine whether or not we can issue orders to what we have selected.
644648
Bool areSelectedObjectsControllable() const;

GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine
3131

3232
#define DEFINE_SHADOW_NAMES
33+
#define DEFINE_RADIUSCURSOR_NAMES
3334

3435
#include "Common/ActionManager.h"
3536
#include "Common/FramePacer.h"
@@ -874,6 +875,10 @@ const FieldParse InGameUI::s_fieldParseTable[] =
874875
{ "DrawRMBScrollAnchor", INI::parseBool, nullptr, offsetof( InGameUI, m_drawRMBScrollAnchor ) },
875876
{ "MoveRMBScrollAnchor", INI::parseBool, nullptr, offsetof( InGameUI, m_moveRMBScrollAnchor ) },
876877

878+
// Generic form: "RadiusCursor <CursorType>" (type named on the header line). The per-cursor keywords
879+
// below are kept for backwards compatibility.
880+
{ "RadiusCursor", InGameUI::parseRadiusCursor, nullptr, 0 },
881+
877882
{ "AttackDamageAreaRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[RADIUSCURSOR_ATTACK_DAMAGE_AREA] ) },
878883
{ "AttackScatterAreaRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[RADIUSCURSOR_ATTACK_SCATTER_AREA] ) },
879884
{ "AttackContinueAreaRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[RADIUSCURSOR_ATTACK_CONTINUE_AREA] ) },
@@ -947,6 +952,34 @@ const FieldParse InGameUI::s_fieldParseTable[] =
947952
{ nullptr, nullptr, nullptr, 0 }
948953
};
949954

955+
//-------------------------------------------------------------------------------------------------
956+
/** Generic radius-cursor parser. INI form: "RadiusCursor <CursorType>" where <CursorType> is a name
957+
from TheRadiusCursorNames (e.g. GUARD_AREA), followed by the RadiusDecalTemplate fields. The parsed
958+
definition is stored in m_radiusCursors[<CursorType>]. */
959+
//-------------------------------------------------------------------------------------------------
960+
/*static*/ void InGameUI::parseRadiusCursor( INI* ini, void* instance, void* /*store*/, const void* /*userData*/ )
961+
{
962+
InGameUI* self = (InGameUI*)instance;
963+
964+
// cursor type is the token right after the "RadiusCursor" keyword (e.g. "GUARD_AREA")
965+
const char* typeName = ini->getNextToken();
966+
if( typeName == nullptr )
967+
{
968+
DEBUG_CRASH(( "RadiusCursor: missing CursorType name on header line" ));
969+
return;
970+
}
971+
972+
Int type = INI::scanIndexList( typeName, TheRadiusCursorNames ); // raises INI_INVALID_DATA if unknown
973+
if( type <= RADIUSCURSOR_NONE || type >= RADIUSCURSOR_COUNT )
974+
{
975+
DEBUG_CRASH(( "RadiusCursor: invalid CursorType '%s'", typeName ));
976+
return;
977+
}
978+
979+
// parse the remaining decal fields into the selected slot (reuse the existing block parser)
980+
RadiusDecalTemplate::parseRadiusDecalTemplate( ini, instance, &self->m_radiusCursors[type], nullptr );
981+
}
982+
950983
//-------------------------------------------------------------------------------------------------
951984
/** Parse MouseCursor entry */
952985
//-------------------------------------------------------------------------------------------------
@@ -1533,6 +1566,10 @@ void InGameUI::setRadiusCursor(RadiusCursorType cursorType, const SpecialPowerTe
15331566
radius = specPowTempl ? specPowTempl->getRadiusCursorRadius() : 0.0f;
15341567
break;
15351568

1569+
default:
1570+
// any other (newer) special-power cursor type: use the SpecialPower's configured radius
1571+
radius = specPowTempl ? specPowTempl->getRadiusCursorRadius() : 0.0f;
1572+
break;
15361573
}
15371574

15381575
// caller can override the SpecialPower-derived size (used by phase-aware ANCHORED_AREA cursors)

0 commit comments

Comments
 (0)