- Expanded militia training to 6x6 square (by Buggler)

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6355 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Wanne
2013-09-04 10:28:12 +00:00
parent 92c04a4f60
commit 89194ff11b
10 changed files with 177 additions and 57 deletions
+125 -21
View File
@@ -309,9 +309,9 @@ UINT16 MAP_MILITIA_BOX_POS_Y;
// the max allowable towns militia in a sector
#define MAP_MILITIA_MAP_X 4
#define MAP_MILITIA_MAP_Y 20
#define MAP_MILITIA_LOWER_ROW_Y 142
#define NUMBER_OF_MILITIA_ICONS_PER_LOWER_ROW 25
#define MILITIA_BOX_ROWS 3
#define MAP_MILITIA_LOWER_ROW_Y 250
#define NUMBER_OF_MILITIA_ICONS_PER_LOWER_ROW 50
#define MILITIA_BOX_ROWS 6
#define MILITIA_BOX_BOX_HEIGHT 36
#define MILITIA_BOX_BOX_WIDTH 42
@@ -323,14 +323,15 @@ UINT16 MAP_MILITIA_BOX_POS_Y;
#define MILITIA_BTN_OFFSET_X 26
#define MILITIA_BTN_HEIGHT 11
#define MILITIA_BOX_WIDTH 133
#define MILITIA_BOX_WIDTH 266
#define MILITIA_BOX_TEXT_OFFSET_Y 4
#define MILITIA_BOX_UNASSIGNED_TEXT_OFFSET_Y 132
#define MILITIA_BOX_UNASSIGNED_TEXT_OFFSET_Y 240
#define MILITIA_BOX_TEXT_TITLE_HEIGHT 13
#define MAP_MILITIA_BOX_AUTO_BOX_X 4
#define MAP_MILITIA_BOX_AUTO_BOX_Y 167
#define MAP_MILITIA_BOX_DONE_BOX_X 67
#define MAP_MILITIA_BOX_AUTO_BOX_X 101
#define MAP_MILITIA_BOX_AUTO_BOX_Y 275
#define MAP_MILITIA_BOX_DONE_BOX_X 164
#define MAP_MILITIA_BOX_REMOVE_BOX_X 38
#define HELI_ICON 0
#define HELI_SHADOW_ICON 1
@@ -344,8 +345,8 @@ UINT16 MAP_MILITIA_BOX_POS_Y;
// the militia box buttons and images
INT32 giMapMilitiaButtonImage[ 5 ];
INT32 giMapMilitiaButton[ 5 ] = { -1, -1, -1, -1, -1 };
INT32 giMapMilitiaButtonImage[ 6 ];
INT32 giMapMilitiaButton[ 6 ] = { -1, -1, -1, -1, -1, -1 };
INT16 gsMilitiaSectorButtonColors[]={
@@ -501,7 +502,7 @@ INT8 bSelectedContractChar = -1;
BOOLEAN fTempPathAlreadyDrawn = FALSE;
// the regions for the mapscreen militia box
MOUSE_REGION gMapScreenMilitiaBoxRegions[ 9 ];
MOUSE_REGION gMapScreenMilitiaBoxRegions[ 36 ];
MOUSE_REGION gMapScreenMilitiaRegion;
// the mine icon
@@ -558,11 +559,13 @@ void DisplayUnallocatedMilitia( void );
BOOLEAN IsThisMilitiaTownSectorAllowable( INT16 sSectorIndexValue );
void DrawTownMilitiaName( void );
void HandleShutDownOfMilitiaPanelIfPeopleOnTheCursor( INT16 sTownValue );
void HandleRemovalOfAllTroopsAmongstSectors( void );
void HandleEveningOutOfTroopsAmongstSectors( void );
void CreateMilitiaPanelBottomButton( void );
void DeleteMilitiaPanelBottomButton( void );
void MilitiaDoneButtonCallback(GUI_BUTTON *btn,INT32 reason);
void MilitiaAutoButtonCallback(GUI_BUTTON *btn,INT32 reason);
void MilitiaRemoveButtonCallback(GUI_BUTTON *btn,INT32 reason);
void MilitiaDisbandYesNoBoxCallback( UINT8 bExitValue ); // HEADROCK HAM 3.6: Disband militia callback
void RenderShadingForUnControlledSectors( void );
void DrawTownMilitiaForcesOnMap( void );
@@ -2048,8 +2051,8 @@ BOOLEAN ShadeMapElemZoomIn(INT16 sMapX, INT16 sMapY, INT32 iColor )
void InitializeMilitiaPopup(void)
{
UINT16 xVal = 400;
UINT16 yVal = 125;
UINT16 xVal = 330;
UINT16 yVal = 25;
if (iResolution >= _640x480 && iResolution < _800x600)
{
@@ -5666,7 +5669,7 @@ void CreateDestroyMilitiaPopUPRegions( void )
if( fShowMilitia && sSelectedMilitiaTown && !gfMilitiaPopupCreated )
{
for( iCounter = 0; iCounter < 9; iCounter++ )
for( iCounter = 0; iCounter < 36; iCounter++ )
{
MSYS_DefineRegion( &gMapScreenMilitiaBoxRegions[ iCounter ], ( INT16 ) ( MAP_MILITIA_BOX_POS_X + MAP_MILITIA_MAP_X + ( iCounter % MILITIA_BOX_ROWS ) * MILITIA_BOX_BOX_WIDTH ), ( INT16 )( MAP_MILITIA_BOX_POS_Y + MAP_MILITIA_MAP_Y + ( iCounter / MILITIA_BOX_ROWS ) * MILITIA_BOX_BOX_HEIGHT ), ( INT16 )( MAP_MILITIA_BOX_POS_X + MAP_MILITIA_MAP_X + ( ( ( iCounter ) % MILITIA_BOX_ROWS ) + 1 ) * MILITIA_BOX_BOX_WIDTH ), ( INT16 )( MAP_MILITIA_BOX_POS_Y + MAP_MILITIA_MAP_Y + ( ( ( iCounter ) / MILITIA_BOX_ROWS ) + 1 ) * MILITIA_BOX_BOX_HEIGHT ), MSYS_PRIORITY_HIGHEST - 3,
MSYS_NO_CURSOR, MilitiaRegionMoveCallback, MilitiaRegionClickCallback );
@@ -5684,7 +5687,7 @@ void CreateDestroyMilitiaPopUPRegions( void )
else if( gfMilitiaPopupCreated && ( !fShowMilitia || !sSelectedMilitiaTown ) )
{
for( iCounter = 0; iCounter < 9; iCounter++ )
for( iCounter = 0; iCounter < 36; iCounter++ )
{
// remove region
MSYS_RemoveRegion( &gMapScreenMilitiaBoxRegions[ iCounter ] );
@@ -5725,7 +5728,7 @@ void RenderIconsPerSectorForSelectedTown( void )
GetVideoObject( &hVObject, guiMilitia );
// render icons for map
for( iCounter = 0; iCounter < 9; iCounter++ )
for( iCounter = 0; iCounter < 36; iCounter++ )
{
// grab current sector value
sCurrentSectorValue = sBaseSectorValue + ( ( iCounter % MILITIA_BOX_ROWS ) + ( iCounter / MILITIA_BOX_ROWS ) * ( 16 ) );
@@ -6157,10 +6160,14 @@ void DrawTownMilitiaName( void )
mprintf( sX, sY, sString );
// might as well show the unassigned string
swprintf( sString, L"%s %s", pTownNames[ sSelectedMilitiaTown ], pMilitiaString[ 1 ] );
swprintf( sString, L"%s", pMilitiaString[ 1 ] );
FindFontCenterCoordinates( MAP_MILITIA_BOX_POS_X, MAP_MILITIA_BOX_POS_Y + MILITIA_BOX_UNASSIGNED_TEXT_OFFSET_Y, MILITIA_BOX_WIDTH, GetFontHeight( FONT10ARIAL ), sString, FONT10ARIAL, &sX, &sY );
mprintf( sX, sY, sString );
// show the amount of unassigned militia
swprintf( sString, L"(%d/%d/%d/%d)", sGreensOnCursor, sRegularsOnCursor, sElitesOnCursor, sGreensOnCursor + sRegularsOnCursor + sElitesOnCursor );
mprintf( MAP_MILITIA_BOX_POS_X + MAP_MILITIA_MAP_X, MAP_MILITIA_BOX_POS_Y + MILITIA_BOX_UNASSIGNED_TEXT_OFFSET_Y, sString );
return;
}
@@ -6261,6 +6268,67 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Map Screen3");
return;
}
void HandleRemovalOfAllTroopsAmongstSectors( void )
{
// even out troops among the town
INT32 iCounter = 0, iNumberUnderControl = 0, iNumberOfGreens = 0, iNumberOfRegulars = 0, iNumberOfElites = 0;
INT32 iNumberLeftOverGreen = 0, iNumberLeftOverRegular = 0, iNumberLeftOverElite = 0;
INT16 sBaseSectorValue = 0, sCurrentSectorValue = 0;
INT16 sSectorX = 0, sSectorY = 0;
// how many sectors in the selected town do we control?
iNumberUnderControl = GetTownSectorsUnderControl( ( INT8 ) sSelectedMilitiaTown );
// if none, there's nothing to be done!
if( !iNumberUnderControl )
{
return;
}
// get the sector value for the upper left corner
sBaseSectorValue = GetBaseSectorForCurrentTown( );
// render icons for map
for( iCounter = 0; iCounter < 36; iCounter++ )
{
// grab current sector value
sCurrentSectorValue = sBaseSectorValue + ( ( iCounter % MILITIA_BOX_ROWS ) + ( iCounter / MILITIA_BOX_ROWS ) * ( 16 ) );
sSectorX = SECTORX( sCurrentSectorValue );
sSectorY = SECTORY( sCurrentSectorValue );
// skip sectors not in the selected town (nearby other towns or wilderness SAM Sites)
if( GetTownIdForSector( sSectorX, sSectorY ) != sSelectedMilitiaTown )
{
continue;
}
if( !StrategicMap[ CALCULATE_STRATEGIC_INDEX( sSectorX, sSectorY ) ].fEnemyControlled )
{
// get number of each
iNumberOfGreens += SectorInfo[ sCurrentSectorValue ].ubNumberOfCivsAtLevel[ GREEN_MILITIA ];
iNumberOfRegulars += SectorInfo[ sCurrentSectorValue ].ubNumberOfCivsAtLevel[ REGULAR_MILITIA ];
iNumberOfElites += SectorInfo[ sCurrentSectorValue ].ubNumberOfCivsAtLevel[ ELITE_MILITIA ];
//zero out all numbers in sectors
SectorInfo[ sCurrentSectorValue ].ubNumberOfCivsAtLevel[ GREEN_MILITIA ] = 0;
SectorInfo[ sCurrentSectorValue ].ubNumberOfCivsAtLevel[ REGULAR_MILITIA ] = 0;
SectorInfo[ sCurrentSectorValue ].ubNumberOfCivsAtLevel[ ELITE_MILITIA ] = 0;
}
}
// now add to those on the cursor
sGreensOnCursor += iNumberOfGreens;
sRegularsOnCursor += iNumberOfRegulars;
sElitesOnCursor += iNumberOfElites;
if( ( sGreensOnCursor > 0 ) || ( sRegularsOnCursor > 0 ) || ( sElitesOnCursor > 0 ) )
SpecifyButtonText( giMapMilitiaButton[ 4 ], pMilitiaButtonString[ 2 ] );
return;
}
void HandleEveningOutOfTroopsAmongstSectors( void )
{
INT32 iMaxMilitiaPerSector = gGameExternalOptions.iMaxMilitiaPerSector;
@@ -6287,7 +6355,7 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Map Screen4");
sBaseSectorValue = GetBaseSectorForCurrentTown( );
// render icons for map
for( iCounter = 0; iCounter < 9; iCounter++ )
for( iCounter = 0; iCounter < 36; iCounter++ )
{
// grab current sector value
sCurrentSectorValue = sBaseSectorValue + ( ( iCounter % MILITIA_BOX_ROWS ) + ( iCounter / MILITIA_BOX_ROWS ) * ( 16 ) );
@@ -6388,6 +6456,8 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Map Screen4");
sRegularsOnCursor = 0;
sElitesOnCursor = 0;
SpecifyButtonText( giMapMilitiaButton[ 4 ], pMilitiaButtonString[ 1 ] );
return;
}
@@ -6398,16 +6468,19 @@ void CreateMilitiaPanelBottomButton( void )
{
giMapMilitiaButtonImage[ 3 ]= LoadButtonImage( "INTERFACE\\militia.sti" ,-1,1,-1,2,-1 );
giMapMilitiaButtonImage[ 4 ]= LoadButtonImage( "INTERFACE\\militia.sti" ,-1,1,-1,2,-1 );
giMapMilitiaButtonImage[ 5 ]= LoadButtonImage( "INTERFACE\\militia.sti" ,-1,1,-1,2,-1 );
}
else if (iResolution < _1024x768)
{
giMapMilitiaButtonImage[ 3 ]= LoadButtonImage( "INTERFACE\\militia_800x600.sti" ,-1,1,-1,2,-1 );
giMapMilitiaButtonImage[ 4 ]= LoadButtonImage( "INTERFACE\\militia_800x600.sti" ,-1,1,-1,2,-1 );
giMapMilitiaButtonImage[ 5 ]= LoadButtonImage( "INTERFACE\\militia_800x600.sti" ,-1,1,-1,2,-1 );
}
else
{
giMapMilitiaButtonImage[ 3 ]= LoadButtonImage( "INTERFACE\\militia_1024x768.sti" ,-1,1,-1,2,-1 );
giMapMilitiaButtonImage[ 4 ]= LoadButtonImage( "INTERFACE\\militia_1024x768.sti" ,-1,1,-1,2,-1 );
giMapMilitiaButtonImage[ 5 ]= LoadButtonImage( "INTERFACE\\militia_1024x768.sti" ,-1,1,-1,2,-1 );
}
giMapMilitiaButton[ 3 ] = QuickCreateButton( giMapMilitiaButtonImage[ 3 ], MAP_MILITIA_BOX_POS_X + MAP_MILITIA_BOX_AUTO_BOX_X, MAP_MILITIA_BOX_POS_Y + MAP_MILITIA_BOX_AUTO_BOX_Y,
@@ -6418,6 +6491,10 @@ void CreateMilitiaPanelBottomButton( void )
BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST - 1,
BtnGenericMouseMoveButtonCallback, (GUI_CALLBACK) MilitiaDoneButtonCallback );
giMapMilitiaButton[ 5 ] = QuickCreateButton( giMapMilitiaButtonImage[ 3 ], MAP_MILITIA_BOX_POS_X + MAP_MILITIA_BOX_REMOVE_BOX_X, MAP_MILITIA_BOX_POS_Y + MAP_MILITIA_BOX_AUTO_BOX_Y,
BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST - 1,
BtnGenericMouseMoveButtonCallback, (GUI_CALLBACK) MilitiaRemoveButtonCallback );
SpecifyButtonFont( giMapMilitiaButton[ 3 ], FONT10ARIAL );
SpecifyButtonUpTextColors( giMapMilitiaButton[ 3 ], FONT_BLACK, FONT_BLACK );
@@ -6427,8 +6504,13 @@ void CreateMilitiaPanelBottomButton( void )
SpecifyButtonUpTextColors( giMapMilitiaButton[ 4 ], FONT_BLACK, FONT_BLACK );
SpecifyButtonDownTextColors( giMapMilitiaButton[ 4 ], FONT_BLACK, FONT_BLACK );
SpecifyButtonFont( giMapMilitiaButton[ 5 ], FONT10ARIAL );
SpecifyButtonUpTextColors( giMapMilitiaButton[ 5 ], FONT_BLACK, FONT_BLACK );
SpecifyButtonDownTextColors( giMapMilitiaButton[ 5 ], FONT_BLACK, FONT_BLACK );
SpecifyButtonText( giMapMilitiaButton[ 3 ], pMilitiaButtonString[ 0 ] );
SpecifyButtonText( giMapMilitiaButton[ 4 ], pMilitiaButtonString[ 1 ] );
SpecifyButtonText( giMapMilitiaButton[ 5 ], pMilitiaButtonString[ 3 ] );
// AUTO button help
SetButtonFastHelpText( giMapMilitiaButton[ 3 ], pMilitiaButtonsHelpText[ 3 ] );
@@ -6451,9 +6533,11 @@ void DeleteMilitiaPanelBottomButton( void )
// delete militia panel bottom
RemoveButton( giMapMilitiaButton[ 3 ] );
RemoveButton( giMapMilitiaButton[ 4 ] );
RemoveButton( giMapMilitiaButton[ 5 ] );
UnloadButtonImage( giMapMilitiaButtonImage[ 3 ] );
UnloadButtonImage( giMapMilitiaButtonImage[ 4 ] );
UnloadButtonImage( giMapMilitiaButtonImage[ 5 ] );
if( sSelectedMilitiaTown != 0 )
{
@@ -6523,6 +6607,26 @@ void MilitiaDoneButtonCallback(GUI_BUTTON *btn,INT32 reason)
return;
}
void MilitiaRemoveButtonCallback(GUI_BUTTON *btn,INT32 reason)
{
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
{
btn->uiFlags|=(BUTTON_CLICKED_ON);
}
else if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
{
if( btn->uiFlags & BUTTON_CLICKED_ON )
{
btn->uiFlags &= ~( BUTTON_CLICKED_ON );
// remove all troops to pool
HandleRemovalOfAllTroopsAmongstSectors( );
fMapPanelDirty = TRUE;
}
}
return;
}
void RenderShadingForUnControlledSectors( void )
{
@@ -6535,7 +6639,7 @@ void RenderShadingForUnControlledSectors( void )
sBaseSectorValue = GetBaseSectorForCurrentTown( );
// render icons for map
for( iCounter = 0; iCounter < 9; iCounter++ )
for( iCounter = 0; iCounter < 36; iCounter++ )
{
// grab current sector value
sCurrentSectorValue = sBaseSectorValue + ( ( iCounter % MILITIA_BOX_ROWS ) + ( iCounter / MILITIA_BOX_ROWS ) * ( 16 ) );
@@ -7390,7 +7494,7 @@ BOOLEAN CanMilitiaAutoDistribute( void )
sBaseSectorValue = GetBaseSectorForCurrentTown( );
// render icons for map
for( iCounter = 0; iCounter < 9; iCounter++ )
for( iCounter = 0; iCounter < 36; iCounter++ )
{
// grab current sector value
sCurrentSectorValue = sBaseSectorValue + ( ( iCounter % MILITIA_BOX_ROWS ) + ( iCounter / MILITIA_BOX_ROWS ) * ( 16 ) );
@@ -7713,7 +7817,7 @@ BOOLEAN CanRedistributeMilitiaInSector( INT16 sClickedSectorX, INT16 sClickedSec
sBaseSectorValue = sBaseSectorList[ bClickedTownId - 1 ];
// render icons for map
for( iCounter = 0; iCounter < 9; iCounter++ )
for( iCounter = 0; iCounter < 36; iCounter++ )
{
// grab current sector value
sCurrentSectorValue = sBaseSectorValue + ( ( iCounter % MILITIA_BOX_ROWS ) + ( iCounter / MILITIA_BOX_ROWS ) * ( 16 ) );