Files
source/Laptop/mercs Files.cpp
T
Wanne e64d5a2fa6 MERGED source code from development trunk revision 4545 up to latest current revision 4882
Development Trunk: https://ja2svn.dyndns.org/source/ja2/branches/Wanne/JA2%201.13%20MP
A detailed list of all the features (changes) is visible in the history log of the development trunk:

INFO: The source code for the official 2011 release (4870) has been branched here:
https://ja2svn.dyndns.org/source/ja2/branches/JA2_rev.4870_2011

This commit contains the following features:

*** Externalized Vehicles ***
o Now with this feature we can add/remove vehicles
o New XML File: TableData\Vehicles.xml
o Added a new function parameter to lua file Scripts\Overhead lua to set up the helicopter in method: SetUpHelicopterForPlayer()
o Added example mini (Docs\Externalized Vehicles Example.zip) mod which adds 2 additional vehicles (hummer and ice-cream truck to sector A9)

*** Up to 255 save slots ***
- There is a "Next" and "Prev" button where you can scroll through the save slots
- It is now possible to load the automatic save (SAVE_EVERY_N_HOURS) from the load screen. This is the first slot after the quickload slot
- Added the 2 alternate players end turn saves (which can be enabled/disabled in option screen) to the save/load game form

*** New Feature: Externalized emails from Emails.edt to XML***
o This feature can be enabled/disabled in the Source:
--> See email.cpp: If "ReadXMLEmail" == FALSE, then normal way (read from Email.edt) otherwise read from XML files
o 2 new XML files: TableData\Email\EmailMercAvailable.xml and EmailMercLevelUp.xml
o Renamed SenderNamesList.xml to EmailSenderNamesList.xml and moved from TableData folder to TableData\Email folder
o Names for mercenaries are get from the file MercProfiles.xml and different names get from the file EmailSenderNamesList.xml

*** Externalized Hidden Towns (Tixa, Orta) ***
o Now it is possible to add new hidden towns (locations)
o See file: TableData/Map/Cities.xml
o New variable in TableData/Map/Cities.xml
- hiddenTown:   0 = show on strategy map, 1 = Hide on strategy map
- townIcon:     1 = on, 0 = off (This is the icon you see on the strategy map)
- szIconFile:   The path to the sti icon file (eg: interface\prison.sti, interface\my_icon.sti)
- iconPosition: The x,y position of the icon on the strategy map

*** Encyclopedia and Briefing Room, reachable from the laptop ***
o 2 new ja2_options.ini properties: BRIEFING_ROOM, ENCYCLOPEDIA
o demonstration video: http://www.youtube.com/watch?v=7CIXdXWLrAo
o Added Example usage of the Briefing Room
- Extract it in your JA2 1.13 folder and use the latest development executable
- The briefing room can be reached from the laptop. Enter SN5631 for the code and then click the "Exit" button
- See "Info_BriefingRoom.txt" and "BriefingRoom_Mission1.png"

*** Improved interrupt system (IIS) ***
o This system changes the way interrupts work. See: http://www.ja-galaxy-forum.com/board/ubbthreads.php?ubb=showflat&Number=290787#Post290787
o Option system (see ja2_options.ini: IMPROVED_INTERRUPT_SYSTEM)
o A few more settings for the interrupt system in ja2_options.ini
o INFO: Multiplayer games always use the "old" interrupt system, not matter what the user selects in the ja2_options.ini

*** Walking and sidestepping with weapon raised ***
o Enable/disable the walking/sidestepping with raised weapon in ja2_options.ini: ALLOW_WALKING_WITH_WEAPON_RAISED
o You can set an AP/BP modifier when walking/sidestepping with weapon raised in APBPConstants.ini: AP_MODIFIER_WEAPON_READY
o The following feature apply when you walk/sidestep with weapon raised:
-> limited angle of view, but you can see more farther when the weapon has a scope
-> better change for interrupts if you see an enemy
-> less APs and BPs when shooting, because the weapon is already raised
-> It should cost more APs when walking. Maybe you can export the additional AP and BP modifier to the APBPConstants.ini

*** Increase squad size to 8 (800x600) and 8 and 10 (1024x768) ***
o Squad sizes (dependend on the screen resolution) can be selected in the start new game screen
o In a multiplayer game, the squad size will always be 6, because it does not work with more soldiers/squad

*** Added UB-1.13 source code ***
o Merged the UB-1.13 source code (Revision: 4721) from svn: http://subversion.assembla.com/svn/ub-source113
o If you want to build UB-EXE or UB-MapEditor, just enable the 2 defines (JA2UB and JA2UBMAPS) in "builddefines.h"
o The UB-Verion reads from "ja2_UB.ini" instead of "ja2.ini"
o There are 2 new XML files
- Layout\LayoutMainMenu.xml
- MapAction\ActionItems.xml
o There are 2 new LUA-Script files
- Scripts\ExplosionControl.lua
- Scripts\InterfaceDialogue.lua

*** Hide enemy health text / enemy hit count ***
o ja2_options.ini: HIDE_ENEMY_HEALTH_TEXT, HIDE_ENEMY_HIT_COUNT
o both new settings only have effect in a singleplayer game
o see: http://www.ja-galaxy-forum.com/board/ubbthreads.php?ubb=showflat&Number=128840&page=1


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@4885 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2012-01-18 11:19:01 +00:00

940 lines
68 KiB
C++

// WANNE 3 <changed some lines>
#ifdef PRECOMPILEDHEADERS
#include "Laptop All.h"
#else
#include "laptop.h"
#include "mercs Files.h"
#include "mercs.h"
#include "Utilities.h"
#include "WCheck.h"
#include "WordWrap.h"
#include "Cursors.h"
#include "Soldier Profile.h"
#include "stdio.h"
#include "Encrypted File.h"
#include "AimMembers.h"
#include "Game Clock.h"
#include "Soldier Add.h"
#include "OverHead.h"
#include "Game Clock.h"
#include "message.h"
#include "Font.h"
#include "LaptopSave.h"
#include "Text.h"
#include "Speck Quotes.h"
#include "Multi Language Graphic Utils.h"
#include "Quests.h"
#include "Assignments.h"
#include "Input.h"
#include "english.h"
#include "finances.h"
#include "GameSettings.h"
#endif
#include "Cheats.h"
#include "connect.h"
#include "fresh_header.h"
#include "aim.h"
#define MERCBIOFILE "BINARYDATA\\MercBios.edt"
#define MERC_BIO_FONT FONT14ARIAL//FONT12ARIAL
#define MERC_BIO_COLOR FONT_MCOLOR_WHITE
#define MERC_TITLE_FONT FONT14ARIAL
#define MERC_TITLE_COLOR 146
#define MERC_NAME_FONT FONT14ARIAL
#define MERC_NAME_COLOR FONT_MCOLOR_WHITE
#define MERC_STATS_FONT FONT12ARIAL
#define MERC_STATIC_STATS_COLOR 146
#define MERC_DYNAMIC_STATS_COLOR FONT_MCOLOR_WHITE
#define MERC_FILES_PORTRAIT_BOX_X LAPTOP_SCREEN_UL_X + 16
#define MERC_FILES_PORTRAIT_BOX_Y LAPTOP_SCREEN_WEB_UL_Y + 17
#define MERC_FACE_X MERC_FILES_PORTRAIT_BOX_X + 2
#define MERC_FACE_Y MERC_FILES_PORTRAIT_BOX_Y + 2
#define MERC_FACE_WIDTH 106
#define MERC_FACE_HEIGHT 122
#define MERC_FILES_STATS_BOX_X LAPTOP_SCREEN_UL_X + 164
#define MERC_FILES_STATS_BOX_Y MERC_FILES_PORTRAIT_BOX_Y
#define MERC_FILES_BIO_BOX_X MERC_FILES_PORTRAIT_BOX_X
#define MERC_FILES_BIO_BOX_Y LAPTOP_SCREEN_WEB_UL_Y + 155
// OK
#define MERC_FILES_PREV_BUTTON_X iScreenWidthOffset + 128
#define MERC_FILES_PREV_BUTTON_Y iScreenHeightOffset + 380
#define MERC_FILES_HIRE_BUTTON_X MERC_FILES_PREV_BUTTON_X + 103 + 16 //iScreenWidthOffset + 260
#define MERC_FILES_HIRE_BUTTON_Y MERC_FILES_PREV_BUTTON_Y
#define MERC_FILES_BACK_BUTTON_X MERC_FILES_HIRE_BUTTON_X + 103 + 16 //iScreenWidthOffset + 380
#define MERC_FILES_BACK_BUTTON_Y MERC_FILES_PREV_BUTTON_Y
// OK
#define MERC_FILES_NEXT_BUTTON_X iScreenWidthOffset + 485 //490
#define MERC_FILES_NEXT_BUTTON_Y MERC_FILES_PREV_BUTTON_Y
#define MERC_NAME_X MERC_FILES_STATS_BOX_X + 50
#define MERC_NAME_Y MERC_FILES_STATS_BOX_Y + 10
#define MERC_BIO_TEXT_X MERC_FILES_BIO_BOX_X + 5
#define MERC_BIO_TEXT_Y MERC_FILES_BIO_BOX_Y + 10
#define MERC_ADD_BIO_TITLE_X MERC_BIO_TEXT_X
#define MERC_ADD_BIO_TITLE_Y MERC_BIO_TEXT_Y + 100
#define MERC_ADD_BIO_TEXT_X MERC_BIO_TEXT_X
#define MERC_ADD_BIO_TEXT_Y MERC_ADD_BIO_TITLE_Y + 20
#define MERC_BIO_WIDTH 460 - 10
#define MERC_BIO_INFO_TEXT_SIZE 5 * 80 * 2
#define MERC_BIO_ADD_INFO_TEXT_SIZE 2 * 80 * 2
#define MERC_BIO_SIZE 7 * 80 * 2
#define MERC_STATS_FIRST_COL_X MERC_NAME_X
#define MERC_STATS_FIRST_NUM_COL_X MERC_STATS_FIRST_COL_X + 90
#define MERC_STATS_SECOND_COL_X MERC_FILES_STATS_BOX_X + 170
#define MERC_STATS_SECOND_NUM_COL_X MERC_STATS_SECOND_COL_X + 115
#define MERC_SPACE_BN_LINES 15
#define MERC_HEALTH_Y MERC_FILES_STATS_BOX_Y + 30
#define MERC_PORTRAIT_TEXT_OFFSET_Y 110
UINT32 guiPortraitBox;
UINT32 guiStatsBox;
UINT32 guiBioBox;
UINT32 guiMercFace;
UINT32 lguiWeaponBox;
bool NOGEAR;
//
// Buttons
//
// The Prev button
void BtnMercPrevButtonCallback(GUI_BUTTON *btn,INT32 reason);
UINT32 guiPrevButton;
INT32 guiButtonImage;
// The Next button
void BtnMercNextButtonCallback(GUI_BUTTON *btn,INT32 reason);
UINT32 guiNextButton;
// The Hire button
void BtnMercHireButtonCallback(GUI_BUTTON *btn,INT32 reason);
UINT32 guiHireButton;
// The Back button
void BtnMercFilesBackButtonCallback(GUI_BUTTON *btn,INT32 reason);
UINT32 guiMercBackButton;
void BtnMercHireButtonCallbackNOGEAR (GUI_BUTTON *btn,INT32 reason);
UINT32 guiHireButtonNOGEAR;
//****************************
//
// Function Prototypes
//
//****************************
BOOLEAN DisplayMercFace( UINT8 ubMercID);
void LoadAndDisplayMercBio( UINT8 ubMercID );
void DisplayMercsStats( UINT8 ubMercID );
BOOLEAN MercFilesHireMerc(UINT8 ubMercID);
void EnableDisableMercFilesNextPreviousButton( );
//Hotkey Assignment
void HandleMercsFilesKeyBoardInput( );
void GameInitMercsFiles()
{
}
BOOLEAN EnterMercsFiles()
{
VOBJECT_DESC VObjectDesc;
InitMercBackGround();
// load the stats box graphic and add it
VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
GetMLGFilename( VObjectDesc.ImageFile, MLG_STATSBOX );
CHECKF(AddVideoObject(&VObjectDesc, &guiStatsBox));
// load the Portrait box graphic and add it
VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
FilenameForBPP("LAPTOP\\PortraitBox.sti", VObjectDesc.ImageFile);
CHECKF(AddVideoObject(&VObjectDesc, &guiPortraitBox));
// load the bio box graphic and add it
VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
FilenameForBPP("LAPTOP\\BioBox.sti", VObjectDesc.ImageFile);
CHECKF(AddVideoObject(&VObjectDesc, &guiBioBox));
// load the WeaponBox graphic and add it
VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
FilenameForBPP("LAPTOP\\weaponbox.sti", VObjectDesc.ImageFile);
CHECKF(AddVideoObject(&VObjectDesc, &lguiWeaponBox));
// Prev Box button
guiButtonImage = LoadButtonImage("LAPTOP\\BigButtons.sti", -1,0,-1,1,-1 );
guiPrevButton = CreateIconAndTextButton( guiButtonImage, MercInfo[MERC_FILES_PREVIOUS],
FONT12ARIAL,
MERC_BUTTON_UP_COLOR, DEFAULT_SHADOW,
MERC_BUTTON_DOWN_COLOR, DEFAULT_SHADOW,
TEXT_CJUSTIFIED,
MERC_FILES_PREV_BUTTON_X, MERC_FILES_PREV_BUTTON_Y, BUTTON_TOGGLE, MSYS_PRIORITY_HIGH,
DEFAULT_MOVE_CALLBACK, BtnMercPrevButtonCallback);
SetButtonCursor(guiPrevButton, CURSOR_LAPTOP_SCREEN);
SpecifyDisabledButtonStyle( guiPrevButton, DISABLED_STYLE_SHADED);
//Next Button
guiNextButton = CreateIconAndTextButton( guiButtonImage, MercInfo[MERC_FILES_NEXT],
FONT12ARIAL,
MERC_BUTTON_UP_COLOR, DEFAULT_SHADOW,
MERC_BUTTON_DOWN_COLOR, DEFAULT_SHADOW,
TEXT_CJUSTIFIED,
MERC_FILES_NEXT_BUTTON_X, MERC_FILES_NEXT_BUTTON_Y, BUTTON_TOGGLE, MSYS_PRIORITY_HIGH,
DEFAULT_MOVE_CALLBACK, BtnMercNextButtonCallback);
SetButtonCursor(guiNextButton, CURSOR_LAPTOP_SCREEN);
SpecifyDisabledButtonStyle( guiNextButton, DISABLED_STYLE_SHADED);
//Hire button
guiHireButton = CreateIconAndTextButton( guiButtonImage, MercInfo[MERC_FILES_HIRE],
FONT12ARIAL,
MERC_BUTTON_UP_COLOR, DEFAULT_SHADOW,
MERC_BUTTON_DOWN_COLOR, DEFAULT_SHADOW,
TEXT_CJUSTIFIED,
MERC_FILES_HIRE_BUTTON_X, MERC_FILES_HIRE_BUTTON_Y, BUTTON_TOGGLE, MSYS_PRIORITY_HIGH,
DEFAULT_MOVE_CALLBACK, BtnMercHireButtonCallback);
SetButtonCursor(guiHireButton, CURSOR_LAPTOP_SCREEN);
SpecifyDisabledButtonStyle( guiHireButton, DISABLED_STYLE_SHADED);
// WANNE: Button is not really needed, removed!
/*
if (is_networked)
{
//Hire button WITHOUT GEAR
guiHireButtonNOGEAR = CreateIconAndTextButton( guiButtonImage, L"Hire (No Gear)",
FONT12ARIAL,
MERC_BUTTON_UP_COLOR, DEFAULT_SHADOW,
MERC_BUTTON_DOWN_COLOR, DEFAULT_SHADOW,
TEXT_CJUSTIFIED,
MERC_FILES_HIRE_BUTTON_X, MERC_FILES_HIRE_BUTTON_Y+45, BUTTON_TOGGLE, MSYS_PRIORITY_HIGH,
DEFAULT_MOVE_CALLBACK, BtnMercHireButtonCallbackNOGEAR);
SetButtonCursor(guiHireButton, CURSOR_LAPTOP_SCREEN);
SpecifyDisabledButtonStyle( guiHireButton, DISABLED_STYLE_SHADED);
}
*/
//Back button
guiMercBackButton = CreateIconAndTextButton( guiButtonImage, MercInfo[MERC_FILES_HOME],
FONT12ARIAL,
MERC_BUTTON_UP_COLOR, DEFAULT_SHADOW,
MERC_BUTTON_DOWN_COLOR, DEFAULT_SHADOW,
TEXT_CJUSTIFIED,
MERC_FILES_BACK_BUTTON_X, MERC_FILES_BACK_BUTTON_Y, BUTTON_TOGGLE, MSYS_PRIORITY_HIGH,
DEFAULT_MOVE_CALLBACK, BtnMercFilesBackButtonCallback);
SetButtonCursor(guiMercBackButton, CURSOR_LAPTOP_SCREEN);
SpecifyDisabledButtonStyle( guiMercBackButton, DISABLED_STYLE_SHADED);
// RenderMercsFiles();
return( TRUE );
}
void BtnMercHireButtonCallbackNOGEAR (GUI_BUTTON *btn,INT32 reason)
{
NOGEAR=1;
BtnMercHireButtonCallback(btn, reason);
}
void ExitMercsFiles()
{
DeleteVideoObjectFromIndex(guiPortraitBox);
DeleteVideoObjectFromIndex(guiStatsBox);
DeleteVideoObjectFromIndex(guiBioBox);
UnloadButtonImage( guiButtonImage );
RemoveButton( guiPrevButton );
RemoveButton( guiNextButton );
RemoveButton( guiHireButton );
// WANNE: Removed
/*
if (is_networked)
RemoveButton( guiHireButtonNOGEAR );
*/
RemoveButton( guiMercBackButton );
DeleteVideoObjectFromIndex(lguiWeaponBox);//hayden
RemoveMercBackGround();
}
void HandleMercsFiles()
{
HandleMercsFilesKeyBoardInput( );
}
void RenderMercsFiles()
{
HVOBJECT hPixHandle;
DrawMecBackGround();
// Portrait Box
GetVideoObject(&hPixHandle, guiPortraitBox);
BltVideoObject(FRAME_BUFFER, hPixHandle, 0,MERC_FILES_PORTRAIT_BOX_X, MERC_FILES_PORTRAIT_BOX_Y, VO_BLT_SRCTRANSPARENCY,NULL);
// Stats Box
GetVideoObject(&hPixHandle, guiStatsBox);
BltVideoObject(FRAME_BUFFER, hPixHandle, 0,MERC_FILES_STATS_BOX_X, MERC_FILES_STATS_BOX_Y, VO_BLT_SRCTRANSPARENCY,NULL);
// bio box
GetVideoObject(&hPixHandle, guiBioBox);
BltVideoObject(FRAME_BUFFER, hPixHandle, 0,MERC_FILES_BIO_BOX_X+1, MERC_FILES_BIO_BOX_Y, VO_BLT_SRCTRANSPARENCY,NULL);
// WANNE: Removed the background for the items
/*
if(is_networked)//hayden - load bgnd
{
GetVideoObject(&hPixHandle, lguiWeaponBox);
UINT16 uiPosX = IMAGE_OFFSET_X + 6;
for(int x=0; x< 8; x++)
{
BltVideoObject(FRAME_BUFFER, hPixHandle, 0, uiPosX, IMAGE_OFFSET_Y + 296 -30, VO_BLT_SRCTRANSPARENCY,NULL);
uiPosX += 61;
}
}
*/
//Display the mercs face
DisplayMercFace( GetMercIDFromMERCArray( gubCurMercIndex ) );
//Display Mercs Name
DrawTextToScreen(gMercProfiles[ GetMercIDFromMERCArray( gubCurMercIndex ) ].zName, MERC_NAME_X, MERC_NAME_Y, 0, MERC_NAME_FONT, MERC_NAME_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
//Load and display the mercs bio
UINT8 mercID = GetMercIDFromMERCArray( gubCurMercIndex );
if(is_networked)
DisplayMercsInventory(mercID);
if (gConditionsForMercAvailabilityTemp[gubCurMercIndex].MercBio != 255)
{
LoadAndDisplayMercBio( gConditionsForMercAvailabilityTemp[gubCurMercIndex].MercBio );
}
//Display the mercs statistic
DisplayMercsStats( GetMercIDFromMERCArray( gubCurMercIndex ) );
//check to see if the merc is dead if so disable the contact button
if( IsMercDead( GetMercIDFromMERCArray( gubCurMercIndex ) ) )
{
DisableButton( guiHireButton );
DisableButton( guiHireButtonNOGEAR );
}
else if( ( LaptopSaveInfo.gubPlayersMercAccountStatus != MERC_ACCOUNT_VALID ) && ( LaptopSaveInfo.gubPlayersMercAccountStatus != MERC_ACCOUNT_SUSPENDED ) && ( LaptopSaveInfo.gubPlayersMercAccountStatus != MERC_ACCOUNT_VALID_FIRST_WARNING ) )
{
//if the players account is suspended, disable the button
DisableButton( guiHireButton );
DisableButton( guiHireButtonNOGEAR );
}
else
EnableButton( guiHireButton );
EnableButton( guiHireButtonNOGEAR );
//Enable or disable the buttons
EnableDisableMercFilesNextPreviousButton( );
MarkButtonsDirty( );
RenderWWWProgramTitleBar( );
InvalidateRegion(LAPTOP_SCREEN_UL_X,LAPTOP_SCREEN_WEB_UL_Y,LAPTOP_SCREEN_LR_X,LAPTOP_SCREEN_WEB_LR_Y);
}
void BtnMercPrevButtonCallback(GUI_BUTTON *btn,INT32 reason)
{
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
{
btn->uiFlags |= BUTTON_CLICKED_ON;
InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
}
if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
{
if (btn->uiFlags & BUTTON_CLICKED_ON)
{
btn->uiFlags &= (~BUTTON_CLICKED_ON );
if( gubCurMercIndex > 0 )
gubCurMercIndex--;
// WANNE: If current profile has an alternate profile, skip the previous one, because it is the alternate profile,
// otherwise we have both profiles available in MERC!
if (gConditionsForMercAvailability[ gubCurMercIndex ].uiAlternateIndex != 255)
{
gubCurMercIndex--;
}
fReDrawScreenFlag = TRUE;
//Enable or disable the buttons
EnableDisableMercFilesNextPreviousButton( );
InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
}
}
if(reason & MSYS_CALLBACK_REASON_LOST_MOUSE)
{
btn->uiFlags &= (~BUTTON_CLICKED_ON );
InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
}
}
void BtnMercNextButtonCallback(GUI_BUTTON *btn,INT32 reason)
{
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
{
btn->uiFlags |= BUTTON_CLICKED_ON;
InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
}
if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
{
if (btn->uiFlags & BUTTON_CLICKED_ON)
{
btn->uiFlags &= (~BUTTON_CLICKED_ON );
if( gubCurMercIndex <= LaptopSaveInfo.gubLastMercIndex-1 )
gubCurMercIndex++;
// WANNE: If current profile has an alternate profile, skip the next one, because it is the alternate profile,
// otherwise we have both profiles available in MERC!
if (gConditionsForMercAvailability[ gubCurMercIndex ].uiAlternateIndex != 255)
{
gubCurMercIndex++;
}
fReDrawScreenFlag = TRUE;
//Enable or disable the buttons
EnableDisableMercFilesNextPreviousButton( );
InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
}
}
if(reason & MSYS_CALLBACK_REASON_LOST_MOUSE)
{
btn->uiFlags &= (~BUTTON_CLICKED_ON );
InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
}
}
void BtnMercHireButtonCallback(GUI_BUTTON *btn,INT32 reason)
{
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
{
btn->uiFlags |= BUTTON_CLICKED_ON;
InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
}
if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
{
if (btn->uiFlags & BUTTON_CLICKED_ON)
{
btn->uiFlags &= (~BUTTON_CLICKED_ON );
//if the players accont is suspended, go back to the main screen and have Speck inform the players
if( LaptopSaveInfo.gubPlayersMercAccountStatus == MERC_ACCOUNT_SUSPENDED )
{
guiCurrentLaptopMode = LAPTOP_MODE_MERC;
#ifdef JA2UB
// gusMercVideoSpeckSpeech = SPECK_QUOTE_ALTERNATE_OPENING_5_PLAYER_OWES_SPECK_ACCOUNT_SUSPENDED;
#else
gusMercVideoSpeckSpeech = SPECK_QUOTE_ALTERNATE_OPENING_5_PLAYER_OWES_SPECK_ACCOUNT_SUSPENDED;
#endif
gubArrivedFromMercSubSite = MERC_CAME_FROM_HIRE_PAGE;
}
//else try to hire the merc
else if( MercFilesHireMerc( GetMercIDFromMERCArray( gubCurMercIndex ) ) )
{
guiCurrentLaptopMode = LAPTOP_MODE_MERC;
gubArrivedFromMercSubSite = MERC_CAME_FROM_HIRE_PAGE;
//start the merc talking
// HandlePlayerHiringMerc( GetMercIDFromMERCArray( gubCurMercIndex ) );
//We just hired a merc
gfJustHiredAMercMerc = TRUE;
//Display a popup msg box telling the user when and where the merc will arrive
DisplayPopUpBoxExplainingMercArrivalLocationAndTime( /*GetMercIDFromMERCArray( gubCurMercIndex )*/ ); // doesn't take parameters (jonathanl)
}
InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
}
}
if(reason & MSYS_CALLBACK_REASON_LOST_MOUSE)
{
btn->uiFlags &= (~BUTTON_CLICKED_ON );
InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
}
}
BOOLEAN DisplayMercFace( UINT8 ubMercID)
{
HVOBJECT hFaceHandle;
HVOBJECT hPortraitHandle;
STR sFaceLoc = "FACES\\BIGFACES\\";
char sTemp[100];
MERCPROFILESTRUCT *pMerc;
VOBJECT_DESC VObjectDesc;
SOLDIERTYPE *pSoldier=NULL;
// Portrait Frame
GetVideoObject(&hPortraitHandle, guiPortraitBox);
BltVideoObject(FRAME_BUFFER, hPortraitHandle, 0,MERC_FILES_PORTRAIT_BOX_X, MERC_FILES_PORTRAIT_BOX_Y, VO_BLT_SRCTRANSPARENCY,NULL);
pMerc = &gMercProfiles[ ubMercID ];
//See if the merc is currently hired
pSoldier = FindSoldierByProfileID( ubMercID, TRUE );
// load the Face graphic and add it
if (gGameExternalOptions.fReadProfileDataFromXML)
{
// HEADROCK PROFEX: Do not read direct profile number, instead, look inside the profile for a ubFaceIndex value.
sprintf(sTemp, "%s%02d.sti", sFaceLoc, gMercProfiles[ubMercID].ubFaceIndex);
}
else
{
sprintf(sTemp, "%s%02d.sti", sFaceLoc, ubMercID);
}
VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
FilenameForBPP(sTemp, VObjectDesc.ImageFile);
CHECKF(AddVideoObject(&VObjectDesc, &guiMercFace));
//Blt face to screen
GetVideoObject(&hFaceHandle, guiMercFace);
BltVideoObject(FRAME_BUFFER, hFaceHandle, 0,MERC_FACE_X, MERC_FACE_Y, VO_BLT_SRCTRANSPARENCY,NULL);
//if the merc is dead, shadow the face red and put text over top saying the merc is dead
if( IsMercDead( ubMercID ) )
{
//shade the face red, (to signif that he is dead)
hFaceHandle->pShades[ 0 ] = Create16BPPPaletteShaded( hFaceHandle->pPaletteEntry, DEAD_MERC_COLOR_RED, DEAD_MERC_COLOR_GREEN, DEAD_MERC_COLOR_BLUE, TRUE );
//get the face object
GetVideoObject(&hFaceHandle, guiMercFace);
//set the red pallete to the face
SetObjectHandleShade( guiMercFace, 0 );
//Blt face to screen
BltVideoObject(FRAME_BUFFER, hFaceHandle, 0,MERC_FACE_X, MERC_FACE_Y, VO_BLT_SRCTRANSPARENCY,NULL);
DisplayWrappedString(MERC_FACE_X, MERC_FACE_Y+MERC_PORTRAIT_TEXT_OFFSET_Y, MERC_FACE_WIDTH, 2, FONT14ARIAL, 145, MercInfo[MERC_FILES_MERC_IS_DEAD], FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED);
}
else if( ubMercID == FLO && gubFact[ FACT_PC_MARRYING_DARYL_IS_FLO ] )
{
ShadowVideoSurfaceRect( FRAME_BUFFER, MERC_FACE_X, MERC_FACE_Y, MERC_FACE_X + MERC_FACE_WIDTH, MERC_FACE_Y + MERC_FACE_HEIGHT);
DisplayWrappedString( MERC_FACE_X, MERC_FACE_Y+MERC_PORTRAIT_TEXT_OFFSET_Y, MERC_FACE_WIDTH, 2, FONT14ARIAL, 145, pPersonnelDepartedStateStrings[3], FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED );
}
//else if the merc is currently a POW or, the merc was fired as a pow
else if( pMerc->bMercStatus == MERC_FIRED_AS_A_POW || ( pSoldier && pSoldier->bAssignment == ASSIGNMENT_POW ) )
{
ShadowVideoSurfaceRect( FRAME_BUFFER, MERC_FACE_X, MERC_FACE_Y, MERC_FACE_X + MERC_FACE_WIDTH, MERC_FACE_Y + MERC_FACE_HEIGHT);
DisplayWrappedString(MERC_FACE_X, MERC_FACE_Y+MERC_PORTRAIT_TEXT_OFFSET_Y, MERC_FACE_WIDTH, 2, FONT14ARIAL, 145, pPOWStrings[0], FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED);
}
//if the merc is hired already, say it
else if( !IsMercHireable( ubMercID ) && pMerc->bMercStatus == MERC_HIRED_BUT_NOT_ARRIVED_YET || pMerc->bMercStatus > 0 )
{
ShadowVideoSurfaceRect( FRAME_BUFFER, MERC_FACE_X, MERC_FACE_Y, MERC_FACE_X + MERC_FACE_WIDTH, MERC_FACE_Y + MERC_FACE_HEIGHT);
DisplayWrappedString(MERC_FACE_X, MERC_FACE_Y+MERC_PORTRAIT_TEXT_OFFSET_Y, MERC_FACE_WIDTH, 2, FONT14ARIAL, 145, MercInfo[MERC_FILES_ALREADY_HIRED], FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED);
}
//if the merc is away on another assignemnt, say the merc is unavailable
else if( !IsMercHireable( ubMercID ) )
{
ShadowVideoSurfaceRect( FRAME_BUFFER, MERC_FACE_X, MERC_FACE_Y, MERC_FACE_X + MERC_FACE_WIDTH, MERC_FACE_Y + MERC_FACE_HEIGHT);
DisplayWrappedString(MERC_FACE_X, MERC_FACE_Y+MERC_PORTRAIT_TEXT_OFFSET_Y, MERC_FACE_WIDTH, 2, FONT14ARIAL, 145, MercInfo[MERC_FILES_MERC_UNAVAILABLE], FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED);
}
DeleteVideoObjectFromIndex(guiMercFace);
return( TRUE );
}
void LoadAndDisplayMercBio( UINT8 ubMercID )
{
CHAR16 sText[400];
UINT32 uiStartLoc = 0;
//load and display the merc bio
//#ifdef JA2UB
// //Ja25 UB
// if( ubMercID < 17 )
// uiStartLoc = MERC_BIO_SIZE * ubMercID;
// else
// uiStartLoc = MERC_BIO_SIZE * ( ubMercID - 7 );
//#else
uiStartLoc = MERC_BIO_SIZE * ubMercID;
//#endif
LoadEncryptedDataFromFile(MERCBIOFILE, sText, uiStartLoc, MERC_BIO_INFO_TEXT_SIZE);
if( sText[0] != L'쳌' )
{
DisplayWrappedString(MERC_BIO_TEXT_X, MERC_BIO_TEXT_Y, MERC_BIO_WIDTH, 2, MERC_BIO_FONT, MERC_BIO_COLOR, sText, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
}
//load and display the merc's additioanl info (if any)
//#ifdef JA2UB
//Ja25 UB
// if( ubMercID < 17 )
// uiStartLoc = MERC_BIO_SIZE * ubMercID + MERC_BIO_INFO_TEXT_SIZE;
// else
// uiStartLoc = MERC_BIO_SIZE * ( ubMercID - 7 ) + MERC_BIO_INFO_TEXT_SIZE;
//#else
uiStartLoc = MERC_BIO_SIZE * ubMercID + MERC_BIO_INFO_TEXT_SIZE;
//#endif
LoadEncryptedDataFromFile(MERCBIOFILE, sText, uiStartLoc, MERC_BIO_ADD_INFO_TEXT_SIZE);
if( sText[0] != 0 && !is_networked )
{
DrawTextToScreen( MercInfo[ MERC_FILES_ADDITIONAL_INFO ], MERC_ADD_BIO_TITLE_X, MERC_ADD_BIO_TITLE_Y, 0, MERC_TITLE_FONT, MERC_TITLE_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DisplayWrappedString( MERC_ADD_BIO_TEXT_X, MERC_ADD_BIO_TEXT_Y, MERC_BIO_WIDTH, 2, MERC_BIO_FONT, MERC_BIO_COLOR, sText, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
}
}
void DisplayMercsStats( UINT8 ubMercID )
{
UINT16 usPosY, usPosX;
CHAR16 sString[128];
CHAR16 NsString[128];
CHAR16 N2sString[128];
usPosY = MERC_HEALTH_Y;
//Health
DrawTextToScreen(MercInfo[MERC_FILES_HEALTH], MERC_STATS_FIRST_COL_X, usPosY, 0, MERC_STATS_FONT, MERC_STATIC_STATS_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
DrawNumeralsToScreen(gMercProfiles[ ubMercID ].bLife, 3, MERC_STATS_FIRST_NUM_COL_X, MERC_HEALTH_Y, MERC_STATS_FONT, MERC_DYNAMIC_STATS_COLOR);
usPosY += MERC_SPACE_BN_LINES;
//Agility
DrawTextToScreen(MercInfo[MERC_FILES_AGILITY], MERC_STATS_FIRST_COL_X, usPosY, 0, MERC_STATS_FONT, MERC_STATIC_STATS_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
DrawNumeralsToScreen(gMercProfiles[ ubMercID ].bAgility, 3, MERC_STATS_FIRST_NUM_COL_X, usPosY, MERC_STATS_FONT, MERC_DYNAMIC_STATS_COLOR);
usPosY += MERC_SPACE_BN_LINES;
//Dexterity
DrawTextToScreen(MercInfo[MERC_FILES_DEXTERITY], MERC_STATS_FIRST_COL_X, usPosY, 0, MERC_STATS_FONT, MERC_STATIC_STATS_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
DrawNumeralsToScreen(gMercProfiles[ ubMercID ].bDexterity, 3, MERC_STATS_FIRST_NUM_COL_X, usPosY, MERC_STATS_FONT, MERC_DYNAMIC_STATS_COLOR);
usPosY += MERC_SPACE_BN_LINES;
//Strenght
DrawTextToScreen(MercInfo[MERC_FILES_STRENGTH], MERC_STATS_FIRST_COL_X, usPosY, 0, MERC_STATS_FONT, MERC_STATIC_STATS_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
DrawNumeralsToScreen(gMercProfiles[ ubMercID ].bStrength, 3, MERC_STATS_FIRST_NUM_COL_X, usPosY, MERC_STATS_FONT, MERC_DYNAMIC_STATS_COLOR);
usPosY += MERC_SPACE_BN_LINES;
//Leadership
DrawTextToScreen(MercInfo[MERC_FILES_LEADERSHIP], MERC_STATS_FIRST_COL_X, usPosY, 0, MERC_STATS_FONT, MERC_STATIC_STATS_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
DrawNumeralsToScreen(gMercProfiles[ ubMercID ].bLeadership, 3, MERC_STATS_FIRST_NUM_COL_X, usPosY, MERC_STATS_FONT, MERC_DYNAMIC_STATS_COLOR);
usPosY += MERC_SPACE_BN_LINES;
//Wisdom
DrawTextToScreen(MercInfo[MERC_FILES_WISDOM], MERC_STATS_FIRST_COL_X, usPosY, 0, MERC_STATS_FONT, MERC_STATIC_STATS_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
DrawNumeralsToScreen(gMercProfiles[ ubMercID ].bWisdom, 3, MERC_STATS_FIRST_NUM_COL_X, usPosY, MERC_STATS_FONT, MERC_DYNAMIC_STATS_COLOR);
usPosY = MERC_HEALTH_Y;
//Experience Level
DrawTextToScreen(MercInfo[MERC_FILES_EXPLEVEL], MERC_STATS_SECOND_COL_X, usPosY, 0, MERC_STATS_FONT, MERC_STATIC_STATS_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
DrawNumeralsToScreen(gMercProfiles[ ubMercID ].bExpLevel, 3, MERC_STATS_SECOND_NUM_COL_X, usPosY, MERC_STATS_FONT, MERC_DYNAMIC_STATS_COLOR);
usPosY += MERC_SPACE_BN_LINES;
//Marksmanship
DrawTextToScreen(MercInfo[MERC_FILES_MARKSMANSHIP], MERC_STATS_SECOND_COL_X, usPosY, 0, MERC_STATS_FONT, MERC_STATIC_STATS_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
DrawNumeralsToScreen(gMercProfiles[ ubMercID ].bMarksmanship, 3, MERC_STATS_SECOND_NUM_COL_X, usPosY, MERC_STATS_FONT, MERC_DYNAMIC_STATS_COLOR);
usPosY += MERC_SPACE_BN_LINES;
//Mechanical
DrawTextToScreen(MercInfo[MERC_FILES_MECHANICAL], MERC_STATS_SECOND_COL_X, usPosY, 0, MERC_STATS_FONT, MERC_STATIC_STATS_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
DrawNumeralsToScreen(gMercProfiles[ ubMercID ].bMechanical, 3, MERC_STATS_SECOND_NUM_COL_X, usPosY, MERC_STATS_FONT, MERC_DYNAMIC_STATS_COLOR);
usPosY += MERC_SPACE_BN_LINES;
//Explosive
DrawTextToScreen(MercInfo[MERC_FILES_EXPLOSIVE], MERC_STATS_SECOND_COL_X, usPosY, 0, MERC_STATS_FONT, MERC_STATIC_STATS_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
DrawNumeralsToScreen(gMercProfiles[ ubMercID ].bExplosive, 3, MERC_STATS_SECOND_NUM_COL_X, usPosY, MERC_STATS_FONT, MERC_DYNAMIC_STATS_COLOR);
usPosY += MERC_SPACE_BN_LINES;
//Medical
DrawTextToScreen(MercInfo[MERC_FILES_MEDICAL], MERC_STATS_SECOND_COL_X, usPosY, 0, MERC_STATS_FONT, MERC_STATIC_STATS_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
DrawNumeralsToScreen(gMercProfiles[ ubMercID ].bMedical, 3, MERC_STATS_SECOND_NUM_COL_X, usPosY, MERC_STATS_FONT, MERC_DYNAMIC_STATS_COLOR);
usPosY += MERC_SPACE_BN_LINES;
//Daily Salary
DrawTextToScreen( MercInfo[MERC_FILES_SALARY], MERC_STATS_SECOND_COL_X, usPosY, 0, MERC_NAME_FONT, MERC_STATIC_STATS_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
usPosX = MERC_STATS_SECOND_COL_X + StringPixLength(MercInfo[MERC_FILES_SALARY], MERC_NAME_FONT) + 1;
swprintf(sString, L"%d %s", gMercProfiles[ ubMercID ].sSalary, MercInfo[MERC_FILES_PER_DAY]);
swprintf(NsString, L"+ %d gear",gMercProfiles[ ubMercID ].usOptionalGearCost);
swprintf(N2sString, L"== $%d.",gMercProfiles[ ubMercID ].usOptionalGearCost+gMercProfiles[ ubMercID ].sSalary);
DrawTextToScreen( sString, usPosX, usPosY, 95, MERC_NAME_FONT, MERC_DYNAMIC_STATS_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED);
// WANNE: Not needed
/*
if(is_networked && cAllowMercEquipment)
{
DrawTextToScreen( NsString, usPosX, usPosY+MERC_SPACE_BN_LINES, 95, MERC_NAME_FONT, MERC_DYNAMIC_STATS_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED);
DrawTextToScreen( N2sString, usPosX, usPosY+(2*MERC_SPACE_BN_LINES), 95, MERC_NAME_FONT, MERC_DYNAMIC_STATS_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED);
}
*/
}
BOOLEAN MercFilesHireMerc(UINT8 ubMercID)
{
MERC_HIRE_STRUCT HireMercStruct;
INT8 bReturnCode;
INT32 Namount=0;
memset(&HireMercStruct, 0, sizeof(MERC_HIRE_STRUCT));
//if the ALT key is down
if( gfKeyState[ ALT ] && CHEATER_CHEAT_LEVEL( ) )
{
//set the merc to be hireable
gMercProfiles[ ubMercID ].bMercStatus = MERC_OK;
gMercProfiles[ ubMercID ].uiDayBecomesAvailable = 0;
}
//if the merc is away, dont hire
if( !IsMercHireable( ubMercID ) )
{
if( gMercProfiles[ ubMercID ].bMercStatus != MERC_IS_DEAD )
{
guiCurrentLaptopMode = LAPTOP_MODE_MERC;
gusMercVideoSpeckSpeech = SPECK_QUOTE_PLAYER_TRIES_TO_HIRE_ALREADY_HIRED_MERC;
gubArrivedFromMercSubSite = MERC_CAME_FROM_HIRE_PAGE;
}
return(FALSE);
}
HireMercStruct.ubProfileID = ubMercID;
//
// HireMercStruct.fCopyProfileItemsOver = gfBuyEquipment;
//
HireMercStruct.fCopyProfileItemsOver = !NOGEAR;
HireMercStruct.iTotalContractLength = 1;
//Specify where the merc is to appear
HireMercStruct.sSectorX = gsMercArriveSectorX;//13;
HireMercStruct.sSectorY = gsMercArriveSectorY;
HireMercStruct.fUseLandingZoneForArrival = TRUE;
HireMercStruct.uiTimeTillMercArrives = GetMercArrivalTimeOfDay( );// + ubMercID
//Set the time and ID of the last hired merc will arrive
// LaptopSaveInfo.sLastHiredMerc.iIdOfMerc = HireMercStruct.ubProfileID;
// LaptopSaveInfo.sLastHiredMerc.uiArrivalTime = HireMercStruct.uiTimeTillMercArrives;
Namount += gMercProfiles[ ubMercID ].sSalary * (-1);
if(cAllowMercEquipment && NOGEAR==0)
Namount += gMercProfiles[ubMercID].usOptionalGearCost * (-1);
if(is_networked && (Namount*(-1) > LaptopSaveInfo.iCurrentBalance))
{
DoLapTopMessageBox( MSG_BOX_LAPTOP_DEFAULT, sATMText[ 4 ], LAPTOP_SCREEN, MSG_BOX_FLAG_OK, NULL);
return(FALSE);//not enough big ones $$$sATMText
}
bReturnCode = HireMerc( &HireMercStruct );
NOGEAR=0;
//already have limit of mercs on the team
if( bReturnCode == MERC_HIRE_OVER_PLAYER_LIMIT )
{
DoLapTopMessageBox( MSG_BOX_LAPTOP_DEFAULT, MercInfo[ MERC_FILES_HIRE_TO_MANY_PEOPLE_WARNING ], LAPTOP_SCREEN, MSG_BOX_FLAG_OK, NULL);
return(FALSE);
}
else if( bReturnCode == MERC_HIRE_FAILED )
{
//function failed
return(FALSE);
}
else
{
//take off nominal fee: hayden,
if (is_networked)
{
AddTransactionToPlayersBook( HIRED_MERC, ubMercID, GetWorldTotalMin(), Namount );
}
#ifdef JA2UB
//add an entry in the finacial page for the hiring of the merc
AddTransactionToPlayersBook(PAY_SPECK_FOR_MERC, ubMercID, GetWorldTotalMin(), -(INT32)( gMercProfiles[ubMercID].uiWeeklySalary ) );
#endif
//if we succesfully hired the merc
return(TRUE);
}
}
void BtnMercFilesBackButtonCallback(GUI_BUTTON *btn,INT32 reason)
{
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
{
btn->uiFlags |= BUTTON_CLICKED_ON;
InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
}
if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
{
if (btn->uiFlags & BUTTON_CLICKED_ON)
{
btn->uiFlags &= (~BUTTON_CLICKED_ON );
guiCurrentLaptopMode = LAPTOP_MODE_MERC;
gubArrivedFromMercSubSite = MERC_CAME_FROM_HIRE_PAGE;
InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
}
}
if(reason & MSYS_CALLBACK_REASON_LOST_MOUSE)
{
btn->uiFlags &= (~BUTTON_CLICKED_ON );
InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
}
}
void EnableDisableMercFilesNextPreviousButton( )
{
if( gubCurMercIndex <= LaptopSaveInfo.gubLastMercIndex-1 )
EnableButton( guiNextButton );
else
DisableButton( guiNextButton );
if( gubCurMercIndex > 0 )
EnableButton( guiPrevButton );
else
DisableButton( guiPrevButton );
}
void HandleMercsFilesKeyBoardInput( )
{
InputAtom InputEvent;
while (DequeueEvent(&InputEvent) == TRUE)
{
if( InputEvent.usEvent == KEY_DOWN )
{
switch (InputEvent.usParam)
{
case LEFTARROW:
// previous button
if( gubCurMercIndex > 0 )
gubCurMercIndex--;
// WANNE: If current profile has an alternate profile, skip the previous one, because it is the alternate profile,
// otherwise we have both profiles available in MERC!
if (gConditionsForMercAvailability[ gubCurMercIndex ].uiAlternateIndex != 255)
gubCurMercIndex--;
RenderMercsFiles( );
//Enable or disable the buttons
EnableDisableMercFilesNextPreviousButton( );
break;
case RIGHTARROW:
// next button
if( gubCurMercIndex <= LaptopSaveInfo.gubLastMercIndex-1 )
gubCurMercIndex++;
// WANNE: If current profile has an alternate profile, skip the next one, because it is the alternate profile,
// otherwise we have both profiles available in MERC!
if (gConditionsForMercAvailability[ gubCurMercIndex ].uiAlternateIndex != 255)
gubCurMercIndex++;
RenderMercsFiles( );
//Enable or disable the buttons
EnableDisableMercFilesNextPreviousButton( );
break;
case ENTER:
//for no or invalid merc account, do nothing
if( ( LaptopSaveInfo.gubPlayersMercAccountStatus != MERC_ACCOUNT_VALID ) && ( LaptopSaveInfo.gubPlayersMercAccountStatus != MERC_ACCOUNT_SUSPENDED ) && ( LaptopSaveInfo.gubPlayersMercAccountStatus != MERC_ACCOUNT_VALID_FIRST_WARNING ) )
{
//do nothing
}
// hire only if alive
else if( !IsMercDead( GetMercIDFromMERCArray( gubCurMercIndex ) ) )
{
//if the players account is suspended, go back to the main screen and have Speck inform the players
if( LaptopSaveInfo.gubPlayersMercAccountStatus == MERC_ACCOUNT_SUSPENDED )
{
guiCurrentLaptopMode = LAPTOP_MODE_MERC;
#ifdef JA2UB
//gusMercVideoSpeckSpeech = SPECK_QUOTE_ALTERNATE_OPENING_5_PLAYER_OWES_SPECK_ACCOUNT_SUSPENDED;
#else
gusMercVideoSpeckSpeech = SPECK_QUOTE_ALTERNATE_OPENING_5_PLAYER_OWES_SPECK_ACCOUNT_SUSPENDED;
#endif
gubArrivedFromMercSubSite = MERC_CAME_FROM_HIRE_PAGE;
}
//else try to hire the merc
else if( MercFilesHireMerc( GetMercIDFromMERCArray( gubCurMercIndex ) ) )
{
guiCurrentLaptopMode = LAPTOP_MODE_MERC;
gubArrivedFromMercSubSite = MERC_CAME_FROM_HIRE_PAGE;
//start the merc talking
//HandlePlayerHiringMerc( GetMercIDFromMERCArray( gubCurMercIndex ) );
//We just hired a merc
gfJustHiredAMercMerc = TRUE;
//Display a popup msg box telling the user when and where the merc will arrive
DisplayPopUpBoxExplainingMercArrivalLocationAndTime( /*GetMercIDFromMERCArray( gubCurMercIndex )*/ ); // doesn't take parameters (jonathanl)
}
}
break;
default:
HandleKeyBoardShortCutsForLapTop( InputEvent.usEvent, InputEvent.usParam, InputEvent.usKeyState );
break;
}
}
}
}