Files
source/Laptop/mercs Files.cpp
T
Wanne 7ca53fadc7 *** MERGED source code from development trunk revision 4890 up to latest current revision 5105 ***
Development Trunk (now obsolete): 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: There will be no further development in the development source trunk, so is obsolete from now on!

This commit contains the following features (bugfixes are not listed):

- New Feature: Show merc ranks in Strategy Screen before merc name
o Toggle on/off in the ingame options screen
o For each experience level (0-10) there are defined rank names in the language specific text files
o Additional language text that is not translated yet is marked with // TODO.Translate

- New Feature: Faster Bobby Ray Shipments
o This feature is selectable in the ja2_options.ini
o When activated Bobby Ray shipments will be really fast
-> Overnight Express: 5 - 7 hours
-> Air Service: 10, 12 or 14 hours
-> Standard Service: 15, 18 or 21 hours
o In a multiplayer game, this feature is disabled (because shipment arrive immediately in the destination sector)

- New Feature: AP cost for manipulating the merc inventory
o This feature is selectable in the start new game screen
o For example, putting a weapon from hand in the backpack costs APs
o The AP costs are defined in the APBPConstants.ini
o In a multiplayer game, this feature is disabled

- New Feature: Added possibility to set individual Gear Kit names
o Set individual names in the optional new tag <mGearKitName> inside the <GEARKIT> root element (File: TableData\MercStartingGear.xml)

- New Feature: Externalized the maximum purchase amount (JA2 vanilla: 10) for Bobby Rays purchases per shipment
o Define the max. amount in the ja2_options.ini: BOBBY_RAY_MAX_PURCHASE_AMOUNT, Range: 10 - 100)
o Nice scrolling bars to scroll through all the purchases

- New Feature: Now it is possible to walk on "water" tiles or handle those tiles like "normal" tiles 
o (instead of showing the swimming animation and counting the APs for swimming), when the soldier is located on the second level (level > 0)

- New Feature: Externalized AIM Veterans laptop site
o Add maximum of 4 pages
o Add  new AIM to veterans page, and remove AIM from veterans page.
o New XML file: OldAIMArchive.xml (language specific XML files: *.OldAIMArchive.xml)

- New Feature: Added possibility to choose from 254 IMP faces
o Modified IMPPortraits.xml
o Added new GameDir folder "IMPFaces" which contains the IMP face portraits
o Moved IMP faces in the new "IMPFaces" folder

- New Feature: ARSP - All Resolution Support Project
o See here: http://www.ja-galaxy-forum.com/board/ubbthreads.php?ubb=showflat&Number=298698&page=1
o Support any kind of screen resolution. This works by choosing the matching full supported resolution (640x480, 800x600, 1024x768) and then centering the graphics
o See ja2.ini for defining the screen resolution

- New Feature: AI Turn Speed Up (FF-MOD)
o see here: http://www.ja-galaxy-forum.com/board/ubbthreads.php?ubb=showflat&Number=298699#Post298699
o When this feature is activated it allows fast enemy turns
o New entry in ja2.ini to enable this feature: HIGHSPEED_TIMER = TRUE
o Turn on/off auto fast turns in ingame options
o New ja2_options.ini settings for fine tuning: [Clock Settings] ini block

- New Feature: "Lock" / "Release" mouse cursor in tactical windowed mode, so the mouse can stay within window boundary
o This is very helpful for doing scrolling with the mouse (by moving the mouse to the window edge) in windowed mode
o You can toggle on/off the feature by pressing CTRL + Z. It is also possible to press CTRL + Y. So the user can decide which fits better :)
o Whenever you toggle on/off a screen message appears on the tactical log to notify the player

- New Feature: Weapon overheating
o Basically, every shot fired from a gun increases its temperature. On higher temperatures, the gun jams more frequently
o On/off toggle in the ingame options
o Graphical thermometer indication on the weapon picture
o New ja2_options.ini section with a few options, Section: [Tactical Weapon Overheating Settings]
o XML changes (New Tags)
--> AmmoTypes.xml: <temperatureModificator>
--> Items.xml: <barrel>, <usOverheatingCooldownFactor>
--> Weapons.xml: <usOverheatingJamThreshold>, <usOverheatingDamageThreshold>, <usOverheatingSingleShotTemperature>
o Added a few barells to Items.xml (end of the file)
o more infos: http://www.ja-galaxy-forum.com/board/ubbthreads.php?ubb=showflat&Number=301059&page=1

- New Feature: Resting weapons on a surfaces
o You can now rest your weapon on crates, low walls, rocks, debris, open windows etc. while you are crouched. Resting will give yu the superior gun handling modifiers from PRONE position.
o A little 'A' on your gun indicates if you are resting it or not.
o Both settings can be turned on and off in Ja2_Options.ini under 'Tactical Gameplay Settings'

- New Feature: Externalized option on whether mercs can exit sector using grid exit in turn based mode
o new ja2_options.ini property: GRID_EXIT_IN_TURNBASED
o This ini setting does not affect leaving sectors on map edges

- Rework/Update: Ammo boxes and Ammo crates
o Ammo crate items added for remaining calibers.  Tweaked prices to correspond to magazines, tweaked capacities and weights to be reasonable (~800 or less).
o Shift-R reload now looks at both boxes and crates in sector items and merc's inventory to reload, and tops off magazines in inventory as well.  Only possible outside of combat.
o Ctrl-Shift-A still creates crates as per usual, with some fixes to ensure all ammo is caught on the first press.
o Shift-A now creates ammo boxes in the same loop.  They mostly behave like crates, but fit in mercs inventories.
o Ammo boxes are available to purchase at BR and tony, sam, etc.  Individual magazines/drums/etc are no longer available.
o Removed ammo crate xml tag.  Added ubMagType tag to Magazines array.  This allows us to differentiate between magazines, bullets, boxes and crates.
o Changed ammo filtering in BR's to display boxes appropriately.  Added back the "Mag:" display (changed text to "Size:")
o Added ja2set.dat.xml file (WF map version in WF maps folder) to be used instead of ja2set.dat file (ja2.ini setting added) For now, if you want to play vanilla instead, just change the setting in the ini (see comments in file).
o Added P4-P9Items image files (up to 5k images each) and tileslots.  1.13 core items will continue to use Guns and P1-P3Items for the foreseeable future.  P4-P9 can be used by customizers/modders to avoid conflicts with Guns/P1-P3 items.  TODO: Need to discuss a strategy for this in the forums.
o Added in Ambient/0.bad and 32.bad to avoid an exception in the code.
o Updated the XML Editor
o Standardized the text on all the ammo items.

- New Multiplayer Feature: Sharing same FOV (field of view) in a coop/team-dm (for friendly teams) game
o You will also see enemies, that your teammate sees

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5108 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2012-03-23 18:46:54 +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 (DequeueSpecificEvent(&InputEvent, KEY_DOWN|KEY_UP|KEY_REPEAT))
{
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;
}
}
}
}