|
30 | 30 | #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine |
31 | 31 |
|
32 | 32 | #define DEFINE_SHADOW_NAMES |
| 33 | +#define DEFINE_RADIUSCURSOR_NAMES |
33 | 34 |
|
34 | 35 | #include "Common/ActionManager.h" |
35 | 36 | #include "Common/FramePacer.h" |
@@ -874,6 +875,10 @@ const FieldParse InGameUI::s_fieldParseTable[] = |
874 | 875 | { "DrawRMBScrollAnchor", INI::parseBool, nullptr, offsetof( InGameUI, m_drawRMBScrollAnchor ) }, |
875 | 876 | { "MoveRMBScrollAnchor", INI::parseBool, nullptr, offsetof( InGameUI, m_moveRMBScrollAnchor ) }, |
876 | 877 |
|
| 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 | + |
877 | 882 | { "AttackDamageAreaRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[RADIUSCURSOR_ATTACK_DAMAGE_AREA] ) }, |
878 | 883 | { "AttackScatterAreaRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[RADIUSCURSOR_ATTACK_SCATTER_AREA] ) }, |
879 | 884 | { "AttackContinueAreaRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, nullptr, offsetof( InGameUI, m_radiusCursors[RADIUSCURSOR_ATTACK_CONTINUE_AREA] ) }, |
@@ -947,6 +952,34 @@ const FieldParse InGameUI::s_fieldParseTable[] = |
947 | 952 | { nullptr, nullptr, nullptr, 0 } |
948 | 953 | }; |
949 | 954 |
|
| 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 | + |
950 | 983 | //------------------------------------------------------------------------------------------------- |
951 | 984 | /** Parse MouseCursor entry */ |
952 | 985 | //------------------------------------------------------------------------------------------------- |
@@ -1533,6 +1566,10 @@ void InGameUI::setRadiusCursor(RadiusCursorType cursorType, const SpecialPowerTe |
1533 | 1566 | radius = specPowTempl ? specPowTempl->getRadiusCursorRadius() : 0.0f; |
1534 | 1567 | break; |
1535 | 1568 |
|
| 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; |
1536 | 1573 | } |
1537 | 1574 |
|
1538 | 1575 | // caller can override the SpecialPower-derived size (used by phase-aware ANCHORED_AREA cursors) |
|
0 commit comments