mirror of
https://github.com/1dot13/source.git
synced 2026-08-12 14:10:23 +02:00
Merged New Inventory Project into main branch
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1871 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
#include "Strategic Town Loyalty.h"
|
||||
#include "Strategic Mines.h"
|
||||
#include "finances.h"
|
||||
#include "Map Screen Interface Map Inventory.h"
|
||||
#include "Map Screen Interface Map Inventory.h"
|
||||
#include "Strategic.h"
|
||||
#include "Utilities.h"
|
||||
#include "video.h"
|
||||
@@ -78,7 +78,7 @@ void AddItemsInSectorToBox(void);
|
||||
// position town/mine info box on the screen
|
||||
void PositionTownMineInfoBox( void );
|
||||
|
||||
// add the pop up button for the map inventory pop up activation
|
||||
// add the pop up button for the map inventory pop up activation
|
||||
void AddInventoryButtonForMapPopUpBox( void );
|
||||
|
||||
// now remove the above button
|
||||
@@ -98,14 +98,14 @@ void DisplayTownInfo( INT16 sMapX, INT16 sMapY, INT8 bMapZ )
|
||||
// set current sector
|
||||
if( ( bCurrentTownMineSectorX != sMapX ) || ( bCurrentTownMineSectorY != sMapY ) || ( bCurrentTownMineSectorZ != bMapZ ) )
|
||||
{
|
||||
bCurrentTownMineSectorX = ( INT8 )sMapX;
|
||||
bCurrentTownMineSectorY = ( INT8 )sMapY;
|
||||
bCurrentTownMineSectorZ = bMapZ;
|
||||
bCurrentTownMineSectorX = ( INT8 )sMapX;
|
||||
bCurrentTownMineSectorY = ( INT8 )sMapY;
|
||||
bCurrentTownMineSectorZ = bMapZ;
|
||||
}
|
||||
|
||||
//create destroy the box
|
||||
CreateDestroyTownInfoBox( );
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CreateDestroyTownInfoBox( void )
|
||||
@@ -114,7 +114,6 @@ void CreateDestroyTownInfoBox( void )
|
||||
static BOOLEAN fCreated = FALSE;
|
||||
SGPRect pDimensions;
|
||||
SGPPoint pPosition;
|
||||
INT16 sButtonX = 0, sButtonY = 0;
|
||||
INT8 bTownId = 0;
|
||||
|
||||
if( ( fCreated == FALSE ) && ( fShowTownInfo == TRUE ) )
|
||||
@@ -161,7 +160,7 @@ void CreateDestroyTownInfoBox( void )
|
||||
|
||||
|
||||
// set font type
|
||||
SetBoxFont(ghTownMineBox, BLOCKFONT2);
|
||||
SetBoxFont(ghTownMineBox, BLOCKFONT2);
|
||||
|
||||
// set highlight color
|
||||
SetBoxHighLight(ghTownMineBox, FONT_WHITE);
|
||||
@@ -198,7 +197,7 @@ void CreateDestroyTownInfoBox( void )
|
||||
}
|
||||
|
||||
pDimensions.iBottom += BOX_BUTTON_HEIGHT;
|
||||
|
||||
|
||||
SetBoxSize( ghTownMineBox, pDimensions );
|
||||
|
||||
ShowBox( ghTownMineBox );
|
||||
@@ -237,7 +236,7 @@ void CreateDestroyTownInfoBox( void )
|
||||
fCreated = FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -246,7 +245,7 @@ void CreateTownInfoBox( void )
|
||||
{
|
||||
// create basic box
|
||||
CreatePopUpBox(&ghTownMineBox, TownMineDimensions, TownMinePosition, (POPUP_BOX_FLAG_CLIP_TEXT ));
|
||||
|
||||
|
||||
// which buffer will box render to
|
||||
SetBoxBuffer(ghTownMineBox, FRAME_BUFFER);
|
||||
|
||||
@@ -329,7 +328,7 @@ void AddTextToTownBox( void )
|
||||
// town size
|
||||
swprintf( wString, L"%s:", pwTownInfoStrings[ 0 ] );
|
||||
AddMonoString( &hStringHandle, wString );
|
||||
swprintf( wString, L"%d", GetTownSectorSize( ubTownId ) );
|
||||
swprintf( wString, L"%d", GetTownSectorSize( ubTownId ) );
|
||||
AddSecondColumnMonoString( &hStringHandle, wString );
|
||||
|
||||
// main facilities
|
||||
@@ -345,7 +344,7 @@ void AddTextToTownBox( void )
|
||||
// town control
|
||||
swprintf( wString, L"%s:", pwTownInfoStrings[ 2 ] );
|
||||
AddMonoString( &hStringHandle, wString );
|
||||
swprintf( wString, L"%d%%%%", (GetTownSectorsUnderControl( ubTownId ) * 100) / GetTownSectorSize( ubTownId ));
|
||||
swprintf( wString, L"%d%%%%", (GetTownSectorsUnderControl( ubTownId ) * 100) / GetTownSectorSize( ubTownId ));
|
||||
AddSecondColumnMonoString( &hStringHandle, wString );
|
||||
}
|
||||
|
||||
@@ -364,9 +363,9 @@ void AddTextToTownBox( void )
|
||||
if( sMineSector != -1 )
|
||||
{
|
||||
// Associated Mine: Sector
|
||||
swprintf( wString, L"%s:", pwTownInfoStrings[ 4 ] );
|
||||
swprintf( wString, L"%s:", pwTownInfoStrings[ 4 ] );
|
||||
AddMonoString( &hStringHandle, wString );
|
||||
GetShortSectorString( ( INT16 )( sMineSector % MAP_WORLD_X ), ( INT16 )( sMineSector / MAP_WORLD_X ), wString );
|
||||
GetShortSectorString( ( INT16 )( sMineSector % MAP_WORLD_X ), ( INT16 )( sMineSector / MAP_WORLD_X ), wString );
|
||||
AddSecondColumnMonoString( &hStringHandle, wString );
|
||||
}
|
||||
}
|
||||
@@ -461,7 +460,7 @@ void AddTextToMineBox( void )
|
||||
// town control percentage
|
||||
swprintf( wString, L"%s:", pwMineStrings[ 12 ]);
|
||||
AddMonoString( &hStringHandle, wString );
|
||||
swprintf( wString, L"%d%%%%", (GetTownSectorsUnderControl( gMineLocation[ ubMineIndex ].bAssociatedTown ) * 100) / GetTownSectorSize( gMineLocation[ ubMineIndex ].bAssociatedTown ));
|
||||
swprintf( wString, L"%d%%%%", (GetTownSectorsUnderControl( gMineLocation[ ubMineIndex ].bAssociatedTown ) * 100) / GetTownSectorSize( gMineLocation[ ubMineIndex ].bAssociatedTown ));
|
||||
AddSecondColumnMonoString( &hStringHandle, wString );
|
||||
|
||||
ubTown = gMineLocation[ ubMineIndex ].bAssociatedTown;
|
||||
@@ -599,7 +598,7 @@ void AddCommonInfoToBox(void)
|
||||
|
||||
|
||||
// in sector where militia can be trained,
|
||||
// control of the sector matters, display who controls this sector. Map brightness no longer gives this!
|
||||
// control of the sector matters, display who controls this sector. Map brightness no longer gives this!
|
||||
if ( MilitiaTrainingAllowedInSector( bCurrentTownMineSectorX, bCurrentTownMineSectorY, 0 ) && !fUnknownSAMSite )
|
||||
{
|
||||
// controlled:
|
||||
@@ -619,7 +618,7 @@ void AddCommonInfoToBox(void)
|
||||
if (ubMilitiaTotal > 0)
|
||||
{
|
||||
// some militia, show total & their breakdown by level
|
||||
swprintf( wString, L"%d (%d/%d/%d)", ubMilitiaTotal,
|
||||
swprintf( wString, L"%d (%d/%d/%d)", ubMilitiaTotal,
|
||||
MilitiaInSectorOfRank(bCurrentTownMineSectorX, bCurrentTownMineSectorY, GREEN_MILITIA),
|
||||
MilitiaInSectorOfRank(bCurrentTownMineSectorX, bCurrentTownMineSectorY, REGULAR_MILITIA),
|
||||
MilitiaInSectorOfRank(bCurrentTownMineSectorX, bCurrentTownMineSectorY, ELITE_MILITIA));
|
||||
@@ -647,7 +646,7 @@ void AddCommonInfoToBox(void)
|
||||
|
||||
// how many are there, really?
|
||||
ubNumEnemies = NumEnemiesInSector( bCurrentTownMineSectorX, bCurrentTownMineSectorY );
|
||||
|
||||
|
||||
switch ( WhatPlayerKnowsAboutEnemiesInSector( bCurrentTownMineSectorX, bCurrentTownMineSectorY ) )
|
||||
{
|
||||
case KNOWS_NOTHING:
|
||||
@@ -701,10 +700,9 @@ void PositionTownMineInfoBox( void )
|
||||
SGPRect pDimensions;
|
||||
SGPPoint pPosition;
|
||||
INT16 sX =0, sY = 0;
|
||||
INT16 sNewMargin = 0;
|
||||
|
||||
// position the box based on x and y of the selected sector
|
||||
GetScreenXYFromMapXY( bCurrentTownMineSectorX, bCurrentTownMineSectorY, &sX, &sY);
|
||||
GetScreenXYFromMapXY( bCurrentTownMineSectorX, bCurrentTownMineSectorY, &sX, &sY);
|
||||
|
||||
// set box position
|
||||
pPosition.iX = sX;
|
||||
@@ -721,7 +719,7 @@ void PositionTownMineInfoBox( void )
|
||||
|
||||
if( pDimensions.iRight < ( sTotalButtonWidth + 30 ) )
|
||||
{
|
||||
SpecifyBoxMinWidth( ghTownMineBox, ( sTotalButtonWidth + 30 ) );
|
||||
SpecifyBoxMinWidth( ghTownMineBox, ( sTotalButtonWidth + 30 ) );
|
||||
pDimensions.iRight = sTotalButtonWidth + 30;
|
||||
}
|
||||
|
||||
@@ -733,7 +731,7 @@ void PositionTownMineInfoBox( void )
|
||||
|
||||
if( pPosition.iX + pDimensions.iRight > MapScreenRect.iRight )
|
||||
{
|
||||
pPosition.iX = MapScreenRect.iRight - pDimensions.iRight - 5;
|
||||
pPosition.iX = MapScreenRect.iRight - pDimensions.iRight - 5;
|
||||
}
|
||||
|
||||
|
||||
@@ -743,12 +741,12 @@ void PositionTownMineInfoBox( void )
|
||||
pPosition.iY = MapScreenRect.iTop + 5;
|
||||
}
|
||||
|
||||
if( pPosition.iY + pDimensions.iBottom > MapScreenRect.iBottom )
|
||||
if( pPosition.iY + pDimensions.iBottom > MapScreenRect.iBottom )
|
||||
{
|
||||
pPosition.iY = MapScreenRect.iBottom - pDimensions.iBottom - 8;
|
||||
pPosition.iY = MapScreenRect.iBottom - pDimensions.iBottom - 8;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// reset position
|
||||
SetBoxPosition( ghTownMineBox, pPosition );
|
||||
@@ -768,50 +766,50 @@ void AddInventoryButtonForMapPopUpBox( void )
|
||||
INT16 sWidthA = 0, sWidthB = 0, sTotalBoxWidth = 0;
|
||||
HVOBJECT hHandle;
|
||||
|
||||
|
||||
|
||||
// load the button
|
||||
VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
|
||||
FilenameForBPP("INTERFACE\\mapinvbtns.sti", VObjectDesc.ImageFile);
|
||||
AddVideoObject( &VObjectDesc, &uiObject );
|
||||
AddVideoObject( &VObjectDesc, &uiObject );
|
||||
|
||||
// Calculate smily face positions...
|
||||
GetVideoObject( &hHandle, uiObject );
|
||||
pTrav = &(hHandle->pETRLEObject[ 0 ] );
|
||||
|
||||
sWidthA = pTrav->usWidth;
|
||||
|
||||
|
||||
pTrav = &(hHandle->pETRLEObject[ 1 ] );
|
||||
sWidthB = pTrav->usWidth;
|
||||
|
||||
|
||||
sTotalBoxWidth = sTotalButtonWidth;
|
||||
|
||||
GetBoxSize( ghTownMineBox , &pDimensions );
|
||||
GetBoxPosition( ghTownMineBox, &pPosition );
|
||||
|
||||
sX = pPosition.iX + ( pDimensions.iRight - sTotalBoxWidth ) / 3;
|
||||
sY = pPosition.iY + pDimensions.iBottom - ( ( BOX_BUTTON_HEIGHT + 5 ) );
|
||||
sY = pPosition.iY + pDimensions.iBottom - ( ( BOX_BUTTON_HEIGHT + 5 ) );
|
||||
|
||||
guiMapButtonInventoryImage[0] = LoadButtonImage( "INTERFACE\\mapinvbtns.sti" ,-1,0,-1,2,-1 );
|
||||
guiMapButtonInventoryImage[0] = LoadButtonImage( "INTERFACE\\mapinvbtns.sti" ,-1,0,-1,2,-1 );
|
||||
|
||||
guiMapButtonInventory[0] = CreateIconAndTextButton( guiMapButtonInventoryImage[0], pMapPopUpInventoryText[ 0 ], BLOCKFONT2,
|
||||
FONT_WHITE, FONT_BLACK,
|
||||
FONT_WHITE, FONT_BLACK,
|
||||
TEXT_CJUSTIFIED,
|
||||
(INT16)(sX ), (INT16)( sY ), BUTTON_TOGGLE , MSYS_PRIORITY_HIGHEST - 1,
|
||||
DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)MapTownMineInventoryButtonCallBack );
|
||||
|
||||
guiMapButtonInventory[0] = CreateIconAndTextButton( guiMapButtonInventoryImage[0], pMapPopUpInventoryText[ 0 ], BLOCKFONT2,
|
||||
FONT_WHITE, FONT_BLACK,
|
||||
FONT_WHITE, FONT_BLACK,
|
||||
TEXT_CJUSTIFIED,
|
||||
(INT16)(sX ), (INT16)( sY ), BUTTON_TOGGLE , MSYS_PRIORITY_HIGHEST - 1,
|
||||
DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)MapTownMineInventoryButtonCallBack );
|
||||
|
||||
|
||||
sX = sX + sWidthA + ( pDimensions.iRight - sTotalBoxWidth ) / 3;
|
||||
sY = pPosition.iY + pDimensions.iBottom - ( ( BOX_BUTTON_HEIGHT + 5) );
|
||||
|
||||
guiMapButtonInventoryImage[1] = LoadButtonImage( "INTERFACE\\mapinvbtns.sti" ,-1,1,-1,3,-1 );
|
||||
guiMapButtonInventoryImage[1] = LoadButtonImage( "INTERFACE\\mapinvbtns.sti" ,-1,1,-1,3,-1 );
|
||||
|
||||
guiMapButtonInventory[1] = CreateIconAndTextButton( guiMapButtonInventoryImage[1], pMapPopUpInventoryText[ 1 ], BLOCKFONT2,
|
||||
FONT_WHITE, FONT_BLACK,
|
||||
FONT_WHITE, FONT_BLACK,
|
||||
TEXT_CJUSTIFIED,
|
||||
(INT16)(sX ), (INT16)( sY ), BUTTON_TOGGLE , MSYS_PRIORITY_HIGHEST - 1,
|
||||
DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)MapTownMineExitButtonCallBack );
|
||||
guiMapButtonInventory[1] = CreateIconAndTextButton( guiMapButtonInventoryImage[1], pMapPopUpInventoryText[ 1 ], BLOCKFONT2,
|
||||
FONT_WHITE, FONT_BLACK,
|
||||
FONT_WHITE, FONT_BLACK,
|
||||
TEXT_CJUSTIFIED,
|
||||
(INT16)(sX ), (INT16)( sY ), BUTTON_TOGGLE , MSYS_PRIORITY_HIGHEST - 1,
|
||||
DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)MapTownMineExitButtonCallBack );
|
||||
|
||||
// delete video object
|
||||
DeleteVideoObjectFromIndex( uiObject );
|
||||
@@ -832,11 +830,11 @@ void RemoveInventoryButtonForMapPopUpBox( void )
|
||||
|
||||
// get rid of button
|
||||
RemoveButton( guiMapButtonInventory[0] );
|
||||
UnloadButtonImage( guiMapButtonInventoryImage[0] );
|
||||
UnloadButtonImage( guiMapButtonInventoryImage[0] );
|
||||
|
||||
RemoveButton( guiMapButtonInventory[1] );
|
||||
UnloadButtonImage( guiMapButtonInventoryImage[1] );
|
||||
|
||||
UnloadButtonImage( guiMapButtonInventoryImage[1] );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -845,13 +843,13 @@ void MapTownMineInventoryButtonCallBack( GUI_BUTTON *btn, INT32 reason )
|
||||
{
|
||||
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
|
||||
{
|
||||
btn->uiFlags|=(BUTTON_CLICKED_ON);
|
||||
btn->uiFlags|=(BUTTON_CLICKED_ON);
|
||||
}
|
||||
else if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
|
||||
{
|
||||
if (btn->uiFlags & BUTTON_CLICKED_ON)
|
||||
{
|
||||
if (btn->uiFlags & BUTTON_CLICKED_ON)
|
||||
{
|
||||
btn->uiFlags&=~(BUTTON_CLICKED_ON);
|
||||
btn->uiFlags&=~(BUTTON_CLICKED_ON);
|
||||
|
||||
// done
|
||||
fShowMapInventoryPool = TRUE;
|
||||
@@ -866,7 +864,7 @@ void MapTownMineInventoryButtonCallBack( GUI_BUTTON *btn, INT32 reason )
|
||||
ShouldTheHelpScreenComeUp( HELP_SCREEN_MAPSCREEN_SECTOR_INVENTORY, TRUE );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -874,13 +872,13 @@ void MapTownMineExitButtonCallBack( GUI_BUTTON *btn, INT32 reason )
|
||||
{
|
||||
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
|
||||
{
|
||||
btn->uiFlags|=(BUTTON_CLICKED_ON);
|
||||
btn->uiFlags|=(BUTTON_CLICKED_ON);
|
||||
}
|
||||
else if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
|
||||
{
|
||||
if (btn->uiFlags & BUTTON_CLICKED_ON)
|
||||
{
|
||||
if (btn->uiFlags & BUTTON_CLICKED_ON)
|
||||
{
|
||||
btn->uiFlags&=~(BUTTON_CLICKED_ON);
|
||||
btn->uiFlags&=~(BUTTON_CLICKED_ON);
|
||||
|
||||
// done
|
||||
fMapPanelDirty = TRUE;
|
||||
@@ -888,7 +886,7 @@ void MapTownMineExitButtonCallBack( GUI_BUTTON *btn, INT32 reason )
|
||||
fShowTownInfo = FALSE;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -903,17 +901,17 @@ void MinWidthOfTownMineInfoBox( void )
|
||||
|
||||
VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
|
||||
FilenameForBPP("INTERFACE\\mapinvbtns.sti", VObjectDesc.ImageFile);
|
||||
AddVideoObject( &VObjectDesc, &uiObject );
|
||||
AddVideoObject( &VObjectDesc, &uiObject );
|
||||
|
||||
// Calculate smily face positions...
|
||||
GetVideoObject( &hHandle, uiObject );
|
||||
pTrav = &(hHandle->pETRLEObject[ 0 ] );
|
||||
|
||||
sWidthA = pTrav->usWidth;
|
||||
|
||||
|
||||
pTrav = &(hHandle->pETRLEObject[ 1 ] );
|
||||
sWidthB = pTrav->usWidth;
|
||||
|
||||
|
||||
sTotalBoxWidth = sWidthA + sWidthB;
|
||||
sTotalButtonWidth = sTotalBoxWidth;
|
||||
|
||||
@@ -921,4 +919,4 @@ void MinWidthOfTownMineInfoBox( void )
|
||||
DeleteVideoObjectFromIndex( uiObject );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user