Merged from revision: 6812

Reworked Sectory actions menu (CTRL + .) (by Sevenfm)
- Also added support for 16 medium size buttons dialog.
- see: http://www.bears-pit.com/board/ubbthreads.php/topics/329932.html#Post329932

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6813 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Wanne
2014-01-22 13:28:48 +00:00
parent 8cca415daa
commit e3bc68948e
6 changed files with 116 additions and 19 deletions
+86 -6
View File
@@ -76,6 +76,8 @@ CHAR16 gzUserDefinedButton2[ 128 ];
// Flugente: made an array for user-defined buttons
CHAR16 gzUserDefinedButton[ NUM_CUSTOM_BUTTONS ][ 128 ];
// sevenfm: added color for buttons
UINT16 gzUserDefinedButtonColor[ NUM_CUSTOM_BUTTONS ];
INT32 DoMessageBox( UINT8 ubStyle, const STR16 zString, UINT32 uiExitScreen, UINT16 usFlags, MSGBOX_CALLBACK ReturnCallback, SGPRect *pCenteringRect )
{
@@ -231,12 +233,32 @@ INT32 DoMessageBox( UINT8 ubStyle, const STR16 zString, UINT32 uiExitScreen, UIN
if ( usFlags & MSG_BOX_FLAG_GENERIC_FOUR_BUTTONS )
heightincrease = 120;
if ( usFlags & MSG_BOX_FLAG_GENERIC_EIGHT_BUTTONS )
{
if( ubStyle == MSG_BOX_BASIC_MEDIUM_BUTTONS )
heightincrease = 120;
else
heightincrease = 50;
}
if ( usFlags & MSG_BOX_FLAG_GENERIC_SIXTEEN_BUTTONS )
heightincrease = 90;
UINT16 usMBWidth=MSGBOX_DEFAULT_WIDTH;
BOOLEAN bFixedWidth = FALSE;
// sevenfm: custom width for 16-medium-button messagebox
if( usFlags & MSG_BOX_FLAG_GENERIC_SIXTEEN_BUTTONS && ubStyle == MSG_BOX_BASIC_STYLE )
{
usMBWidth = MSGBOX_BUTTON_WIDTH * 4;
bFixedWidth = TRUE;
}
// custom width for 8-large-button messagebox
if( usFlags & MSG_BOX_FLAG_GENERIC_EIGHT_BUTTONS && ubStyle == MSG_BOX_BASIC_MEDIUM_BUTTONS )
{
usMBWidth = MSGBOX_BUTTON_WIDTH * 4;
bFixedWidth = TRUE;
}
// Init message box
gMsgBox.iBoxId = PrepareMercPopupBox( iId, ubMercBoxBackground, ubMercBoxBorder, zString, MSGBOX_DEFAULT_WIDTH, 40, 10, 30 + heightincrease, &usTextBoxWidth, &usTextBoxHeight );
gMsgBox.iBoxId = PrepareMercPopupBox( iId, ubMercBoxBackground, ubMercBoxBorder, zString, usMBWidth, 40, 10, 30 + heightincrease, &usTextBoxWidth, &usTextBoxHeight, bFixedWidth );
if( gMsgBox.iBoxId == -1 )
{
@@ -379,7 +401,7 @@ INT32 DoMessageBox( UINT8 ubStyle, const STR16 zString, UINT32 uiExitScreen, UIN
{
sButtonX = (usTextBoxWidth - 115)/ 2;
sButtonY = usTextBoxHeight - MSGBOX_BUTTON_HEIGHT - 130 - MSGBOX_SMALL_BUTTON_WIDTH - MSGBOX_SMALL_BUTTON_X_SEP;
for ( INT8 j = 0; j < 4; ++j)
{
sButtonY += 35;
@@ -397,11 +419,45 @@ INT32 DoMessageBox( UINT8 ubStyle, const STR16 zString, UINT32 uiExitScreen, UIN
// Create eight numbered buttons
else if ( usFlags & MSG_BOX_FLAG_GENERIC_EIGHT_BUTTONS )
{
if(ubStyle == MSG_BOX_BASIC_MEDIUM_BUTTONS)
{
//sBlankSpace = usTextBoxWidth - MSGBOX_BUTTON_WIDTH * 4 - MSGBOX_SMALL_BUTTON_X_SEP * 3;
sBlankSpace = usTextBoxWidth - MSGBOX_BUTTON_WIDTH * 4 + MSGBOX_SMALL_BUTTON_X_SEP;
sButtonX = sBlankSpace / 2;
sButtonY = usTextBoxHeight - 3*MSGBOX_BUTTON_HEIGHT - heightincrease - 10;
for ( INT8 i = 0; i < 4; ++i)
{
// new row
sButtonY += MSGBOX_SMALL_BUTTON_WIDTH + 5;
// begin from the front
//sButtonX = sBlankSpace / 2 - MSGBOX_BUTTON_WIDTH*2;
sButtonX = sBlankSpace / 2;
for ( INT8 j = 0; j < 2; ++j)
{
INT8 k = 2*i + j;
gMsgBox.uiButton[k] = CreateIconAndTextButton( gMsgBox.iButtonImages, gzUserDefinedButton[k], FONT12ARIAL,
ubFontColor, ubFontShadowColor,
ubFontColor, ubFontShadowColor,
TEXT_CJUSTIFIED,
(INT16)(gMsgBox.sX + sButtonX ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST,
DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)NumberedMsgBoxCallback );
MSYS_SetBtnUserData( gMsgBox.uiButton[k], 0, k+1);
SetButtonCursor(gMsgBox.uiButton[k], usCursor);
ForceButtonUnDirty( gMsgBox.uiButton[k] );
sButtonX += MSGBOX_BUTTON_WIDTH*2;
}
}
}
else
{
sBlankSpace = usTextBoxWidth - MSGBOX_SMALL_BUTTON_WIDTH * 4 - MSGBOX_SMALL_BUTTON_X_SEP * 3;
sButtonX = sBlankSpace / 2;
sButtonY = usTextBoxHeight - MSGBOX_BUTTON_HEIGHT - 10 - heightincrease;
sButtonY -= MSGBOX_SMALL_BUTTON_WIDTH - MSGBOX_SMALL_BUTTON_X_SEP;
for ( INT8 i = 0; i < 2; ++i)
{
// new row
@@ -424,33 +480,57 @@ INT32 DoMessageBox( UINT8 ubStyle, const STR16 zString, UINT32 uiExitScreen, UIN
SetButtonCursor(gMsgBox.uiButton[k], usCursor);
ForceButtonUnDirty( gMsgBox.uiButton[k] );
sButtonX += 75 + MSGBOX_SMALL_BUTTON_WIDTH + MSGBOX_SMALL_BUTTON_X_SEP;
//sButtonX += 75 + MSGBOX_SMALL_BUTTON_WIDTH + MSGBOX_SMALL_BUTTON_X_SEP;
sButtonX += MSGBOX_SMALL_BUTTON_WIDTH + MSGBOX_SMALL_BUTTON_X_SEP;
}
}
}
}
// Create sixteen numbered buttons
else if ( usFlags & MSG_BOX_FLAG_GENERIC_SIXTEEN_BUTTONS )
{
if( ubStyle == MSG_BOX_BASIC_STYLE )
{
sBlankSpace = usTextBoxWidth - MSGBOX_BUTTON_WIDTH * 4;
sButtonX = sBlankSpace / 2;
sButtonY = usTextBoxHeight - 2*MSGBOX_BUTTON_HEIGHT - heightincrease - 10;
}
else
{
sBlankSpace = usTextBoxWidth - MSGBOX_SMALL_BUTTON_WIDTH * 4 - MSGBOX_SMALL_BUTTON_X_SEP * 3;
sButtonX = sBlankSpace / 2;
sButtonY = usTextBoxHeight - MSGBOX_BUTTON_HEIGHT - 10 - heightincrease - 6;
sButtonY -= MSGBOX_SMALL_BUTTON_WIDTH - MSGBOX_SMALL_BUTTON_X_SEP;
}
for ( INT8 i = 0; i < 4; ++i)
{
if( ubStyle == MSG_BOX_BASIC_STYLE )
{
// new row
sButtonY += MSGBOX_BUTTON_HEIGHT+5;
// begin from the front
sButtonX = sBlankSpace / 2 - MSGBOX_BUTTON_WIDTH;
}
else
{
// new row
sButtonY += MSGBOX_SMALL_BUTTON_WIDTH - 2;// + MSGBOX_SMALL_BUTTON_X_SEP;
// begin from the front
sButtonX = sBlankSpace / 2 - MSGBOX_SMALL_BUTTON_WIDTH - MSGBOX_SMALL_BUTTON_X_SEP;
}
for ( INT8 j = 0; j < 4; ++j)
{
INT8 k = 4*i + j;
if( ubStyle == MSG_BOX_BASIC_STYLE )
sButtonX += MSGBOX_BUTTON_WIDTH;
else
sButtonX += MSGBOX_SMALL_BUTTON_WIDTH + MSGBOX_SMALL_BUTTON_X_SEP;
// sevenfm: added color table for 16-button messagebox
gMsgBox.uiButton[k] = CreateIconAndTextButton( gMsgBox.iButtonImages, gzUserDefinedButton[k], FONT12ARIAL,
ubFontColor, ubFontShadowColor,
gzUserDefinedButtonColor[k] ? gzUserDefinedButtonColor[k] : ubFontColor, ubFontShadowColor,
ubFontColor, ubFontShadowColor,
TEXT_CJUSTIFIED,
(INT16)(gMsgBox.sX + sButtonX ), (INT16)(gMsgBox.sY + sButtonY ), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST,
+2
View File
@@ -50,6 +50,8 @@ typedef void (*MSGBOX_CALLBACK)( UINT8 bExitValue );
#define NUM_CUSTOM_BUTTONS 16
extern CHAR16 gzUserDefinedButton[ NUM_CUSTOM_BUTTONS ][ 128 ];
// sevenfm: color for buttons
extern UINT16 gzUserDefinedButtonColor[ NUM_CUSTOM_BUTTONS ];
typedef struct
{
+18 -9
View File
@@ -4853,6 +4853,10 @@ void StartBombMessageBox( SOLDIERTYPE * pSoldier, INT32 sGridNo )
wcscpy( gzUserDefinedButton[14], L"4-C" );
wcscpy( gzUserDefinedButton[15], L"4-D" );
// sevenfm: zero out color values
for( INT32 cnt = 0; cnt< NUM_CUSTOM_BUTTONS; cnt++)
gzUserDefinedButtonColor[cnt] = 0;
if ( HasAttachmentOfClass( &(pSoldier->inv[ HANDPOS ] ), (AC_DETONATOR ) ) )
{
DoMessageBox( MSG_BOX_BASIC_SMALL_BUTTONS, TacticalStr[ CHOOSE_DETONATE_AND_REMOTE_DEFUSE_FREQUENCY_STR ], GAME_SCREEN, MSG_BOX_FLAG_GENERIC_SIXTEEN_BUTTONS, BombMessageBoxCallBack, NULL );
@@ -4894,6 +4898,10 @@ void StartBombMessageBox( SOLDIERTYPE * pSoldier, INT32 sGridNo )
wcscpy( gzUserDefinedButton[13], L"4-B" );
wcscpy( gzUserDefinedButton[14], L"4-C" );
wcscpy( gzUserDefinedButton[15], L"4-D" );
// sevenfm: zero out color values
for( INT32 cnt = 0; cnt< NUM_CUSTOM_BUTTONS; cnt++)
gzUserDefinedButtonColor[cnt] = 0;
// sevenfm: if SHIFT is pressed - plant tripwire with last network settings
if( _KeyDown( SHIFT ) && gubLastTripwire > 0 )
@@ -4912,14 +4920,15 @@ void StartTacticalFunctionSelectionMessageBox( SOLDIERTYPE * pSoldier, INT32 sGr
gpTempSoldier = pSoldier;
gsTempGridNo = sGridNo;
// sevenfm: reorganized buttons order for new dialog
wcscpy( gzUserDefinedButton[0], TacticalStr[ FILL_CANTEEN_STR ] );
wcscpy( gzUserDefinedButton[1], TacticalStr[ CLEAN_ONE_GUN_STR ] );
wcscpy( gzUserDefinedButton[2], TacticalStr[ CLEAN_ALL_GUNS_STR ] );
wcscpy( gzUserDefinedButton[2], TacticalStr[ CLEAN_ONE_GUN_STR ] );
wcscpy( gzUserDefinedButton[3], TacticalStr[ CLEAN_ALL_GUNS_STR ] );
if ( gpTempSoldier->bSoldierFlagMask & (SOLDIER_COVERT_CIV|SOLDIER_COVERT_SOLDIER) )
wcscpy( gzUserDefinedButton[3], TacticalStr[ TAKE_OFF_DISGUISE_STR ] );
wcscpy( gzUserDefinedButton[1], TacticalStr[ TAKE_OFF_DISGUISE_STR ] );
else
wcscpy( gzUserDefinedButton[3], TacticalStr[ TAKE_OFF_CLOTHES_STR ] );
wcscpy( gzUserDefinedButton[1], TacticalStr[ TAKE_OFF_CLOTHES_STR ] );
if ( gGameExternalOptions.fMilitiaUseSectorInventory )
{
@@ -5132,17 +5141,17 @@ void TacticalFunctionSelectionMessageBoxCallBack( UINT8 ubExitValue )
SectorFillCanteens();
break;
case 2:
// undisguise or take off custom clothes
Strip(gpTempSoldier);
break;
case 3:
// clean weapons of selected merc
CleanWeapons(FALSE);
break;
case 3:
case 4:
// clean weapons of entire team
CleanWeapons(TRUE);
break;
case 4:
// undisguise or take off custom clothes
Strip(gpTempSoldier);
break;
case 5:
// militia drops all gear taken from sector inventory
if ( gGameExternalOptions.fMilitiaUseSectorInventory )
+4
View File
@@ -13338,6 +13338,10 @@ void TransformationMenuPopup_Arm( OBJECTTYPE* pObj )
wcscpy( gzUserDefinedButton[14], L"4-C" );
wcscpy( gzUserDefinedButton[15], L"4-D" );
// sevenfm: zero out color values
for( INT32 cnt = 0; cnt< NUM_CUSTOM_BUTTONS; cnt++)
gzUserDefinedButtonColor[cnt] = 0;
if ( HasAttachmentOfClass( gpItemDescObject, (AC_DETONATOR ) ) )
{
DoMessageBox( MSG_BOX_BASIC_SMALL_BUTTONS, TacticalStr[ CHOOSE_DETONATE_AND_REMOTE_DEFUSE_FREQUENCY_STR ], screen, MSG_BOX_FLAG_GENERIC_SIXTEEN_BUTTONS, BombInventoryMessageBoxCallBack, NULL );
+4 -3
View File
@@ -316,7 +316,7 @@ MercPopUpBox * GetPopUpBoxIndex( INT32 iId )
INT32 PrepareMercPopupBox( INT32 iBoxId, UINT8 ubBackgroundIndex, UINT8 ubBorderIndex, STR16 pString,
UINT16 usWidth, UINT16 usMarginX, UINT16 usMarginTopY, UINT16 usMarginBottomY,
UINT16 *pActualWidth, UINT16 *pActualHeight)
UINT16 *pActualWidth, UINT16 *pActualHeight, BOOLEAN bFixedWidth)
{
UINT16 usNumberVerticalPixels, usNumberOfLines;
UINT16 usTextWidth, usHeight;
@@ -391,9 +391,10 @@ INT32 PrepareMercPopupBox( INT32 iBoxId, UINT8 ubBackgroundIndex, UINT8 ubBorder
// reset flags
guiFlags = 0;
usStringPixLength = WFStringPixLength( pString, TEXT_POPUP_FONT);
usStringPixLength = WFStringPixLength( pString, TEXT_POPUP_FONT);
if( usStringPixLength < ( usWidth - ( MERC_TEXT_POPUP_WINDOW_TEXT_OFFSET_X ) * 2 ) )
// sevenfm: change messagbebox width only if bFixedWidth = FALSE
if( !bFixedWidth && ( usStringPixLength < ( usWidth - ( MERC_TEXT_POPUP_WINDOW_TEXT_OFFSET_X ) * 2 ) ) )
{
usWidth = usStringPixLength + MERC_TEXT_POPUP_WINDOW_TEXT_OFFSET_X * 2;
usTextWidth = usWidth - ( MERC_TEXT_POPUP_WINDOW_TEXT_OFFSET_X ) * 2 + 1;
+2 -1
View File
@@ -13,7 +13,8 @@ BOOLEAN InitMercPopupBox( );
// create a pop up box if needed, return id of box..a -1 means couldn't be added
INT32 PrepareMercPopupBox( INT32 iBoxId, UINT8 ubBackgroundIndex, UINT8 ubBorderIndex, STR16 pString, UINT16 usWidth, UINT16 usMarginX, UINT16 usMarginTopY, UINT16 usMarginBottomY, UINT16 *pActualWidth, UINT16 *pActualHeight);
// sevenfm: added bFixedWidth flag. known issue if using this - text caption is not centered
INT32 PrepareMercPopupBox( INT32 iBoxId, UINT8 ubBackgroundIndex, UINT8 ubBorderIndex, STR16 pString, UINT16 usWidth, UINT16 usMarginX, UINT16 usMarginTopY, UINT16 usMarginBottomY, UINT16 *pActualWidth, UINT16 *pActualHeight, BOOLEAN bFixedWidth = FALSE);
// remove the current box