Files
source/MainMenuScreen.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

798 lines
25 KiB
C++

#ifdef PRECOMPILEDHEADERS
#include "JA2 All.h"
#include "Encrypted File.h"
#else
#include "sgp.h"
#include "screenids.h"
#include "Timer Control.h"
#include "sys globals.h"
#include "fade screen.h"
#include "sysutil.h"
#include "vobject_blitters.h"
#include "MercTextBox.h"
#include "wcheck.h"
#include "cursors.h"
#include "font control.h"
#include "mainmenuscreen.h"
#include "cursor control.h"
#include "render dirty.h"
#include "music control.h"
#include "GameSettings.h"
#include "GameScreen.h"
#include "SaveLoadScreen.h"
#include "SaveLoadGame.h"
#include "Options Screen.h"
#include "English.h"
#include "Gameloop.h"
#include "Game Init.h"
#include "Utilities.h"
#include "WordWrap.h"
#include "Font Control.h"
#include "text.h"
#include "Multi Language Graphic Utils.h"
#include "Encrypted File.h"
#include "ja2 splash.h"
#include "GameVersion.h"
#endif
#include "mercs.h"
#include "gamesettings.h"
#include "connect.h"
#include "strategic.h"
#include "strategic movement.h"
#include "overhead.h"
#include "init.h"
#include "xml.h"
#include <vfs/Core/vfs.h>
#include <vfs/Core/vfs_profile.h>
#ifdef JA2UB
#include "ub_config.h"
#endif
#define MAINMENU_TEXT_FILE "LoadScreens\\MainMenu.edt"
#define MAINMENU_RECORD_SIZE 80 * 2
// MENU ITEMS
enum
{
NEW_GAME,
NEW_MP_GAME,
LOAD_GAME,
PREFERENCES,
CREDITS,
QUIT,
NUM_MENU_ITEMS
};
UINT32 MAINMENU_Y;
UINT32 MAINMENU_X;
UINT32 MAINMENU_Y_SPACE;
INT32 iMenuImages[ NUM_MENU_ITEMS ];
INT32 iMenuButtons[ NUM_MENU_ITEMS ];
UINT16 gusMainMenuButtonWidths[ NUM_MENU_ITEMS ];
MOUSE_REGION gBackRegion;
INT8 gbHandledMainMenu = 0;
BOOLEAN fInitialRender = FALSE;
BOOLEAN gfMainMenuScreenEntry = FALSE;
BOOLEAN gfMainMenuScreenExit = FALSE;
UINT32 guiMainMenuExitScreen = MAINMENU_SCREEN;
extern BOOLEAN gfLoadGameUponEntry;
void ExitMainMenu( );
void MenuButtonCallback(GUI_BUTTON *btn, INT32 reason);
void HandleMainMenuInput();
void HandleMainMenuScreen();
void DisplayAssignmentText();
void ClearMainMenu();
void HandleHelpScreenInput();
void SelectMainMenuBackGroundRegionCallBack(MOUSE_REGION * pRegion, INT32 iReason );
void SetMainMenuExitScreen( UINT32 uiNewScreen );
void CreateDestroyBackGroundMouseMask( BOOLEAN fCreate );
BOOLEAN CreateDestroyMainMenuButtons( BOOLEAN fCreate );
void RenderMainMenu();
void RestoreButtonBackGrounds();
//Main Menu layout by Jazz
MAIN_MENU_VALUES gMainMenulayout[MAX_MAIN_MENU_IMAGE];
VSURFACE_DESC vs_desc;
extern void InitSightRange(); //lal
UINT32 MainMenuScreenInit( )
{
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Version Label: %S", zVersionLabel ));
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Version #: %s", czVersionNumber ));
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Tracking #: %S", zTrackingNumber ));
return( TRUE );
}
UINT32 MainMenuScreenHandle( )
{
UINT32 cnt;
UINT32 uiTime;
if( guiSplashStartTime + 4000 > GetJA2Clock() )
{
SetCurrentCursorFromDatabase( VIDEO_NO_CURSOR );
SetMusicMode( MUSIC_NONE );
return MAINMENU_SCREEN; //The splash screen hasn't been up long enough yet.
}
if( guiSplashFrameFade )
{
uiTime = GetJA2Clock();
if( guiSplashFrameFade > 2 )
ShadowVideoSurfaceRectUsingLowPercentTable( FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
else if( guiSplashFrameFade > 1 )
ColorFillVideoSurfaceArea( FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0 );
else
{
uiTime = GetJA2Clock();
SetMusicMode( MUSIC_MAIN_MENU );
}
guiSplashFrameFade--;
InvalidateScreen();
EndFrameBufferRender();
SetCurrentCursorFromDatabase( VIDEO_NO_CURSOR );
return MAINMENU_SCREEN;
}
SetCurrentCursorFromDatabase( CURSOR_NORMAL );
if( gfMainMenuScreenEntry )
{
InitMainMenu( );
gfMainMenuScreenEntry = FALSE;
gfMainMenuScreenExit = FALSE;
guiMainMenuExitScreen = MAINMENU_SCREEN;
SetMusicMode( MUSIC_MAIN_MENU );
}
if ( fInitialRender )
{
ClearMainMenu();
RenderMainMenu();
fInitialRender = FALSE;
}
RestoreButtonBackGrounds();
// Render buttons
for ( cnt = 0; cnt < NUM_MENU_ITEMS; cnt++ )
{
MarkAButtonDirty( iMenuButtons[ cnt ] );
}
RenderButtons( );
EndFrameBufferRender( );
HandleMainMenuInput();
HandleMainMenuScreen();
if( gfMainMenuScreenExit )
{
ExitMainMenu( );
gfMainMenuScreenExit = FALSE;
gfMainMenuScreenEntry = TRUE;
}
if( guiMainMenuExitScreen != MAINMENU_SCREEN )
gfMainMenuScreenEntry = TRUE;
return( guiMainMenuExitScreen );
}
UINT32 MainMenuScreenShutdown( )
{
return( FALSE );
}
void HandleMainMenuScreen()
{
if ( gbHandledMainMenu != 0 )
{
// Exit according to handled value!
switch( gbHandledMainMenu )
{
case QUIT:
gfMainMenuScreenExit = TRUE;
gfProgramIsRunning = FALSE;
break;
case NEW_GAME:
break;
case NEW_MP_GAME:
break;
case LOAD_GAME:
// Select the game which is to be restored
guiPreviousOptionScreen = guiCurrentScreen;
guiMainMenuExitScreen = SAVE_LOAD_SCREEN;
gbHandledMainMenu = 0;
gfSaveGame = FALSE;
gfMainMenuScreenExit = TRUE;
break;
case PREFERENCES:
guiPreviousOptionScreen = guiCurrentScreen;
guiMainMenuExitScreen = OPTIONS_SCREEN;
gbHandledMainMenu = 0;
gfMainMenuScreenExit = TRUE;
break;
case CREDITS:
guiMainMenuExitScreen = CREDIT_SCREEN;
gbHandledMainMenu = 0;
gfMainMenuScreenExit = TRUE;
break;
}
}
}
BOOLEAN InitMainMenu( )
{
VOBJECT_DESC VObjectDesc;
//main Menu by JAzz
UINT16 iCounter2;
if(is_networked)
{
is_networked = FALSE;
#ifdef USE_VFS
// remove Multiplayer profile if it exists
vfs::CProfileStack *PS = getVFS()->getProfileStack();
vfs::CVirtualProfile *pProf = PS->getProfile("_MULTIPLAYER");
if( pProf && (pProf == PS->topProfile()) )
{
SGP_THROW_IFFALSE(PS->popProfile(), "Leaving Multiplayer mode : Could not remove \"_MULTIPLAYER\" profile");
}
#endif
// Snap: UN-Init MP save game directory
if ( !InitSaveDir() )
{
//if something didnt work, dont even know how to make error code...//hayden
}
}
//Check to see whatr saved game files exist
InitSaveGameArray();
//Create the background mouse mask
CreateDestroyBackGroundMouseMask( TRUE );
CreateDestroyMainMenuButtons( TRUE );
// load background graphic and add it
//Main Menu by Jazz
for( iCounter2 = 1; iCounter2 < MAX_ELEMENT; iCounter2++ )
{
VObjectDesc.fCreateFlags = VSURFACE_CREATE_FROMFILE;
if (gMainMenulayout[iCounter2].Visible == 1)
{
if (iResolution >= _640x480 && iResolution < _800x600)
{
strcpy(VObjectDesc.ImageFile, gMainMenulayout[iCounter2].FileName);
if( !AddVideoObject( &VObjectDesc, &gMainMenulayout[iCounter2].uiIndex ) )
AssertMsg(0, String( "Missing %s", gMainMenulayout[iCounter2].FileName ) );
}
else if (iResolution < _1024x768)
{
strcpy(VObjectDesc.ImageFile, gMainMenulayout[iCounter2].FileName800x600);
if( !AddVideoObject( &VObjectDesc, &gMainMenulayout[iCounter2].uiIndex ) )
AssertMsg(0, String( "Missing %s", gMainMenulayout[iCounter2].FileName800x600 ) );
}
else
{
strcpy(VObjectDesc.ImageFile, gMainMenulayout[iCounter2].FileName1024x768);
if( !AddVideoObject( &VObjectDesc, &gMainMenulayout[iCounter2].uiIndex ) )
AssertMsg(0, String( "Missing %s", gMainMenulayout[iCounter2].FileName1024x768 ) );
}
}
}
//if there are no saved games, disable the button
if( !IsThereAnySavedGameFiles() )
DisableButton( iMenuButtons[ LOAD_GAME ] );
gbHandledMainMenu = 0;
fInitialRender = TRUE;
SetPendingNewScreen( MAINMENU_SCREEN);
guiMainMenuExitScreen = MAINMENU_SCREEN;
DequeueAllKeyBoardEvents();
return( TRUE );
}
void ExitMainMenu( )
{
UINT32 iCounter2 ;
CreateDestroyBackGroundMouseMask( FALSE );
CreateDestroyMainMenuButtons( FALSE );
for( iCounter2 = 1; iCounter2 < MAX_ELEMENT; iCounter2++ )
{
if (gMainMenulayout[iCounter2].Visible == 1)
{
DeleteVideoObjectFromIndex( gMainMenulayout[iCounter2].uiIndex );
}
}
gMsgBox.uiExitScreen = MAINMENU_SCREEN;
}
// WANNE - MP: This method initializes variables that should be initialized
// differently for single and multiplayer
void InitDependingGameStyleOptions()
{
// Yes, also initialize these ones, because of SP and MP game!
InitStrategicEngine();
InitStrategicMovementCosts();
InitializeFaceGearGraphics();
// WANNE: Initialize again, because if differs from SP to MP game!
LoadGameSettings();
FreeGameExternalOptions();
// Load APBPConstants.ini
LoadGameAPBPConstants();
// Load ja2_options.ini
LoadGameExternalOptions();
// Load new STOMP ini - SANDRO
LoadSkillTraitsExternalSettings();
// HEADROCK HAM 4: CTH constants
LoadCTHConstants();
#ifdef JA2UB
LoadGameUBOptions(); // JA25 UB
#endif
InitSightRange(); //lal
ReStartingGame();
}
// WANNE - MP: In this method we decide if we want to play a single or multiplayer game
void MenuButtonCallback(GUI_BUTTON *btn,INT32 reason)
{
INT8 bID;
bID = (UINT8)btn->UserData[0];
if (!(btn->uiFlags & BUTTON_ENABLED))
return;
if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
{
// handle menu
gbHandledMainMenu = bID;
RenderMainMenu();
if( gbHandledMainMenu == NEW_GAME )
{
giMAXIMUM_NUMBER_OF_PLAYER_SLOTS = CODE_MAXIMUM_NUMBER_OF_PLAYER_SLOTS;
if(is_networked)
{
is_networked = FALSE;
// Snap: UN-Init MP save game directory
if ( !InitSaveDir() )
{
//if something didnt work, dont even know how to make error code...//hayden
}
};
SetMainMenuExitScreen( GAME_INIT_OPTIONS_SCREEN );
}
else if (gbHandledMainMenu == NEW_MP_GAME)
{
is_networked = TRUE;
// WANNE - MP: Only reset this here, because otherwise after a MP game ends and a new starts, we would receive the files again.
fClientReceivedAllFiles = FALSE;
giMAXIMUM_NUMBER_OF_PLAYER_SLOTS = 7;
// Snap: Re-Init MP save game directory
if ( !InitSaveDir() )
{
//if something didnt work, dont even know how to make error code...//hayden
}
// Reload the external gameplay data, because maybe we started a MP game before!
LoadExternalGameplayData(TABLEDATA_DIRECTORY);
SetMainMenuExitScreen( MP_JOIN_SCREEN ); // OJW - 20081129
//SetMainMenuExitScreen( GAME_INIT_OPTIONS_SCREEN );
}
else if( gbHandledMainMenu == LOAD_GAME )
{
giMAXIMUM_NUMBER_OF_PLAYER_SLOTS = CODE_MAXIMUM_NUMBER_OF_PLAYER_SLOTS;
if(is_networked)
{
is_networked = FALSE;
// Snap: UN-Init MP save game directory
if ( !InitSaveDir() )
{
//if something didnt work, dont even know how to make error code...//hayden
}
}
if( gfKeyState[ ALT ] )
gfLoadGameUponEntry = TRUE;
}
InitDependingGameStyleOptions();
btn->uiFlags &= (~BUTTON_CLICKED_ON );
}
if( reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
{
RenderMainMenu();
btn->uiFlags |= BUTTON_CLICKED_ON;
}
}
void MenuButtonMoveCallback(GUI_BUTTON *btn,INT32 reason)
{
if(reason & MSYS_CALLBACK_REASON_LOST_MOUSE)
{
RenderMainMenu();
InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
}
if(reason & MSYS_CALLBACK_REASON_GAIN_MOUSE)
{
RenderMainMenu();
InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
}
}
void HandleMainMenuInput()
{
InputAtom InputEvent;
// Check for esc
while (DequeueSpecificEvent(&InputEvent, KEY_DOWN|KEY_UP|KEY_REPEAT))
{
if( InputEvent.usEvent == KEY_UP )
{
switch( InputEvent.usParam )
{
#ifdef JA2TESTVERSION
case 'q':
gbHandledMainMenu = NEW_GAME;
gfMainMenuScreenExit = TRUE;
SetMainMenuExitScreen( INIT_SCREEN );
break;
case 'i':
SetPendingNewScreen( INTRO_SCREEN );
gfMainMenuScreenExit = TRUE;
break;
#endif
case 'c':
gbHandledMainMenu = LOAD_GAME;
if( gfKeyState[ ALT ] )
gfLoadGameUponEntry = TRUE;
// WANNE: Some initializing was missing when directly loading last savegame
// form main menu with ALT + C
giMAXIMUM_NUMBER_OF_PLAYER_SLOTS = CODE_MAXIMUM_NUMBER_OF_PLAYER_SLOTS;
InitDependingGameStyleOptions();
break;
case 'o':
gbHandledMainMenu = PREFERENCES;
break;
case 's':
gbHandledMainMenu = CREDITS;
break;
}
}
}
}
void HandleHelpScreenInput()
{
InputAtom InputEvent;
// Check for key
while (DequeueSpecificEvent(&InputEvent, KEY_DOWN|KEY_UP|KEY_REPEAT))
{
switch( InputEvent.usEvent )
{
case KEY_UP:
SetMainMenuExitScreen( INIT_SCREEN );
break;
}
}
}
void ClearMainMenu()
{
UINT32 uiDestPitchBYTES;
UINT8 *pDestBuf;
// CLEAR THE FRAME BUFFER
pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES );
memset(pDestBuf, 0, SCREEN_HEIGHT * uiDestPitchBYTES );
UnLockVideoSurface( FRAME_BUFFER );
InvalidateScreen( );
}
void SelectMainMenuBackGroundRegionCallBack(MOUSE_REGION * pRegion, INT32 iReason )
{
if (iReason & MSYS_CALLBACK_REASON_INIT)
{
}
else if(iReason & MSYS_CALLBACK_REASON_LBUTTON_UP)
{
}
else if (iReason & MSYS_CALLBACK_REASON_RBUTTON_UP)
{
}
}
void SetMainMenuExitScreen( UINT32 uiNewScreen )
{
guiMainMenuExitScreen = uiNewScreen;
//REmove the background region
CreateDestroyBackGroundMouseMask( FALSE );
gfMainMenuScreenExit = TRUE;
}
void CreateDestroyBackGroundMouseMask( BOOLEAN fCreate )
{
static BOOLEAN fRegionCreated = FALSE;
if( fCreate )
{
if( fRegionCreated )
return;
// Make a mouse region
MSYS_DefineRegion( &(gBackRegion), 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, MSYS_PRIORITY_HIGHEST,
CURSOR_NORMAL, MSYS_NO_CALLBACK, SelectMainMenuBackGroundRegionCallBack );
// Add region
MSYS_AddRegion(&(gBackRegion) );
fRegionCreated = TRUE;
}
else
{
if( !fRegionCreated )
return;
MSYS_RemoveRegion( &gBackRegion );
fRegionCreated = FALSE;
}
}
BOOLEAN CreateDestroyMainMenuButtons( BOOLEAN fCreate )
{
static BOOLEAN fButtonsCreated = FALSE;
INT32 cnt;
SGPFILENAME filename;
SGPFILENAME filenameMP;
INT16 sSlot;
if (iResolution >= _640x480 && iResolution < _800x600)
{
MAINMENU_X = gMainMenulayout[0].MAINMENU_X;
MAINMENU_Y = gMainMenulayout[0].MAINMENU_Y;
MAINMENU_Y_SPACE = gMainMenulayout[0].MAINMENU_Y_SPACE;
}
else if (iResolution < _1024x768)
{
MAINMENU_X = gMainMenulayout[0].MAINMENU_800x600X + xResOffset;
MAINMENU_Y = gMainMenulayout[0].MAINMENU_800x600Y + yResOffset;
MAINMENU_Y_SPACE = gMainMenulayout[0].MAINMENU_Y_SPACE;
}
else
{
MAINMENU_X = gMainMenulayout[0].MAINMENU_1024x768X + xResOffset;
MAINMENU_Y = gMainMenulayout[0].MAINMENU_1024x768Y + yResOffset;
MAINMENU_Y_SPACE = gMainMenulayout[0].MAINMENU_Y_SPACE;
}
if( fCreate )
{
if( fButtonsCreated )
return( TRUE );
//reset the variable that allows the user to ALT click on the continue save btn to load the save instantly
gfLoadGameUponEntry = FALSE;
// Load button images
GetMLGFilename( filename, MLG_TITLETEXT );
GetMLGFilename( filenameMP, MLG_TITLETEXT_MP );
iMenuImages[ NEW_GAME ] = LoadButtonImage( filename, 0,0, 1, 2 ,-1 );
iMenuImages[ NEW_MP_GAME ] = LoadButtonImage( filenameMP, 0, 0, 1, 2, -1 );
sSlot = 0;
iMenuImages[ LOAD_GAME ] = UseLoadedButtonImage( iMenuImages[ NEW_GAME ] ,6,3,4,5,-1 );
iMenuImages[ PREFERENCES ] = UseLoadedButtonImage( iMenuImages[ NEW_GAME ] ,7,7,8,9,-1 );
iMenuImages[ CREDITS ] = UseLoadedButtonImage( iMenuImages[ NEW_GAME ] ,13,10,11,12,-1 );
iMenuImages[ QUIT ] = UseLoadedButtonImage( iMenuImages[ NEW_GAME ] ,14,14,15,16,-1 );
for ( cnt = 0; cnt < NUM_MENU_ITEMS; cnt++ )
{
switch( cnt )
{
case NEW_GAME: gusMainMenuButtonWidths[cnt] = GetWidthOfButtonPic( (UINT16)iMenuImages[cnt], sSlot ); break;
case NEW_MP_GAME: gusMainMenuButtonWidths[cnt] = GetWidthOfButtonPic( (UINT16)iMenuImages[cnt], 0); break;
case LOAD_GAME: gusMainMenuButtonWidths[cnt] = GetWidthOfButtonPic( (UINT16)iMenuImages[cnt], 3 ); break;
case PREFERENCES: gusMainMenuButtonWidths[cnt] = GetWidthOfButtonPic( (UINT16)iMenuImages[cnt], 7 ); break;
case CREDITS: gusMainMenuButtonWidths[cnt] = GetWidthOfButtonPic( (UINT16)iMenuImages[cnt], 10 ); break;
case QUIT: gusMainMenuButtonWidths[cnt] = GetWidthOfButtonPic( (UINT16)iMenuImages[cnt], 15 ); break;
}
#ifdef TESTFOREIGNFONTS
// iMenuButtons[ cnt ] = QuickCreateButton( iMenuImages[ cnt ], (INT16)((SCREEN_WIDTH / 2) - gusMainMenuButtonWidths[cnt]/2), (INT16)( 0 + ( cnt * 18 ) ),
iMenuButtons[ cnt ] = QuickCreateButton( iMenuImages[ cnt ], (INT16)(MAINMENU_X - gusMainMenuButtonWidths[cnt]/2), (INT16)( 0 + ( cnt * 18 ) ), //(INT16)((SCREEN_WIDTH / 2) - gusMainMenuButtonWidths[cnt]/2)
BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
DEFAULT_MOVE_CALLBACK, MenuButtonCallback );
#else
iMenuButtons[ cnt ] = QuickCreateButton( iMenuImages[ cnt ], (INT16)(MAINMENU_X - gusMainMenuButtonWidths[cnt]/2), (INT16)( MAINMENU_Y + ( cnt * MAINMENU_Y_SPACE ) ),
BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
DEFAULT_MOVE_CALLBACK, MenuButtonCallback );
#endif
if ( iMenuButtons[ cnt ] == -1 )
{
return( FALSE );
}
ButtonList[ iMenuButtons[ cnt ] ]->UserData[0] = cnt;
}
fButtonsCreated = TRUE;
}
else
{
if( !fButtonsCreated )
return( TRUE );
// Delete images/buttons
for ( cnt = 0; cnt < NUM_MENU_ITEMS; cnt++ )
{
RemoveButton( iMenuButtons[ cnt ] );
UnloadButtonImage( iMenuImages[ cnt ] );
}
fButtonsCreated = FALSE;
}
return( TRUE );
}
void RenderMainMenu()
{
HVOBJECT hPixHandle;
UINT32 iCounter2;
//Get and display the background image
for( iCounter2 = 1; iCounter2 < MAX_ELEMENT; iCounter2++ )
{
if (gMainMenulayout[iCounter2].Visible == 1)
{
if (iResolution >= _640x480 && iResolution < _800x600)
{
GetVideoObject(&hPixHandle, gMainMenulayout[iCounter2].uiIndex);
BltVideoObject( guiSAVEBUFFER, hPixHandle, 0, gMainMenulayout[iCounter2].ImagePositionX + xResOffset, gMainMenulayout[iCounter2].ImagePositionY + yResOffset, VO_BLT_SRCTRANSPARENCY,NULL);
BltVideoObject( FRAME_BUFFER, hPixHandle, 0, gMainMenulayout[iCounter2].ImagePositionX + xResOffset, gMainMenulayout[iCounter2].ImagePositionY + yResOffset, VO_BLT_SRCTRANSPARENCY,NULL);
}
else if (iResolution < _1024x768)
{
GetVideoObject(&hPixHandle, gMainMenulayout[iCounter2].uiIndex);
BltVideoObject( guiSAVEBUFFER, hPixHandle, 0, gMainMenulayout[iCounter2].ImagePosition800x600X + xResOffset, gMainMenulayout[iCounter2].ImagePosition800x600Y + yResOffset, VO_BLT_SRCTRANSPARENCY,NULL);
BltVideoObject( FRAME_BUFFER, hPixHandle, 0, gMainMenulayout[iCounter2].ImagePosition800x600X + xResOffset, gMainMenulayout[iCounter2].ImagePosition800x600Y + yResOffset, VO_BLT_SRCTRANSPARENCY,NULL);
}
else
{
GetVideoObject(&hPixHandle, gMainMenulayout[iCounter2].uiIndex);
BltVideoObject( guiSAVEBUFFER, hPixHandle, 0, gMainMenulayout[iCounter2].ImagePosition1024x768X + xResOffset, gMainMenulayout[iCounter2].ImagePosition1024x768Y + yResOffset, VO_BLT_SRCTRANSPARENCY,NULL);
BltVideoObject( FRAME_BUFFER, hPixHandle, 0, gMainMenulayout[iCounter2].ImagePosition1024x768X + xResOffset, gMainMenulayout[iCounter2].ImagePosition1024x768Y + yResOffset, VO_BLT_SRCTRANSPARENCY,NULL);
}
}
}
#ifdef TESTFOREIGNFONTS
DrawTextToScreen( L"LARGEFONT1: "/*gzCopyrightText[ 0 ]*/, 0, 105, 640, LARGEFONT1, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DrawTextToScreen( L"SMALLFONT1: "/*gzCopyrightText[ 0 ]*/, 0, 125, 640, SMALLFONT1, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DrawTextToScreen( L"TINYFONT1: "/*gzCopyrightText[ 0 ]*/, 0, 145, 640, TINYFONT1, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DrawTextToScreen( L"FONT12POINT1: "/*gzCopyrightText[ 0 ]*/, 0, 165, 640, FONT12POINT1, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DrawTextToScreen( L"COMPFONT: "/*gzCopyrightText[ 0 ]*/, 0, 185, 640, COMPFONT, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DrawTextToScreen( L"SMALLCOMPFONT: "/*gzCopyrightText[ 0 ]*/, 0, 205, 640, SMALLCOMPFONT, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DrawTextToScreen( L"FONT10ROMAN: "/*gzCopyrightText[ 0 ]*/, 0, 225, 640, FONT10ROMAN, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DrawTextToScreen( L"FONT12ROMAN: "/*gzCopyrightText[ 0 ]*/, 0, 245, 640, FONT12ROMAN, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DrawTextToScreen( L"FONT14SANSERIF: "/*gzCopyrightText[ 0 ]*/, 0, 255, 640, FONT14SANSERIF, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DrawTextToScreen( L"MILITARYFONT: "/*gzCopyrightText[ 0 ]*/, 0, 265, 640, MILITARYFONT1, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DrawTextToScreen( L"FONT10ARIAL: "/*gzCopyrightText[ 0 ]*/, 0, 285, 640, FONT10ARIAL, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DrawTextToScreen( L"FONT14ARIAL: "/*gzCopyrightText[ 0 ]*/, 0, 305, 640, FONT14ARIAL, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DrawTextToScreen( L"FONT12ARIAL: "/*gzCopyrightText[ 0 ]*/, 0, 325, 640, FONT12ARIAL, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DrawTextToScreen( L"FONT10ARIALBOLD: "/*gzCopyrightText[ 0 ]*/, 0, 345, 640, FONT10ARIALBOLD, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DrawTextToScreen( L"BLOCKFONT: "/*gzCopyrightText[ 0 ]*/, 0, 365, 640, BLOCKFONT, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DrawTextToScreen( L"BLOCKFONT2: "/*gzCopyrightText[ 0 ]*/, 0, 385, 640, BLOCKFONT2, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DrawTextToScreen( L"BLOCKFONT3: "/*gzCopyrightText[ 0 ]*/, 0, 385, 640, BLOCKFONT3, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DrawTextToScreen( L"FONT12ARIALFIXEDWIDTH: "/*gzCopyrightText[ 0 ]*/, 0, 405, 640, FONT12ARIALFIXEDWIDTH, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DrawTextToScreen( L"FONT16ARIAL: "/*gzCopyrightText[ 0 ]*/, 0, 425, 640, FONT16ARIAL, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DrawTextToScreen( L"BLOCKFONTNARROW: "/*gzCopyrightText[ 0 ]*/, 0, 445, 640, BLOCKFONTNARROW, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
DrawTextToScreen( L"FONT14HUMANIST: "/*gzCopyrightText[ 0 ]*/, 0, 465, 640, FONT14HUMANIST, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
#else
DrawTextToScreen( gzCopyrightText[ 0 ], 0, SCREEN_HEIGHT - 20, SCREEN_WIDTH, FONT10ARIAL, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED );
#endif
InvalidateRegion( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
}
void RestoreButtonBackGrounds()
{
UINT8 cnt;
#ifndef TESTFOREIGNFONTS
if (iResolution >= _640x480 && iResolution < _800x600)
{
MAINMENU_Y = gMainMenulayout[0].MAINMENU_Y;
MAINMENU_X = gMainMenulayout[0].MAINMENU_X;
MAINMENU_Y_SPACE = gMainMenulayout[0].MAINMENU_Y_SPACE;
}
else if (iResolution < _1024x768)
{
MAINMENU_Y = gMainMenulayout[0].MAINMENU_800x600Y;
MAINMENU_X = gMainMenulayout[0].MAINMENU_800x600X;
MAINMENU_Y_SPACE = gMainMenulayout[0].MAINMENU_Y_SPACE;
}
else
{
MAINMENU_Y = gMainMenulayout[0].MAINMENU_1024x768Y;
MAINMENU_X = gMainMenulayout[0].MAINMENU_1024x768X;
MAINMENU_Y_SPACE = gMainMenulayout[0].MAINMENU_Y_SPACE;
}
for ( cnt = 0; cnt < NUM_MENU_ITEMS; cnt++ )
{
RestoreExternBackgroundRect( (UINT16)(MAINMENU_X - gusMainMenuButtonWidths[cnt]/2), (INT16)( MAINMENU_Y + ( cnt * MAINMENU_Y_SPACE )-1), (UINT16)(gusMainMenuButtonWidths[cnt]+1), 23 );
}
#endif
}