Game clock improvements (by Moa)

Before Patch:
Render region for the Game Time and Tooltip region for this region had different x/y coordinate formulas which resulted in missplaced ToolTip on screen resolutions higher then 3.

There where 4 different definitions of Clock position: INTERFACE_CLOCK_X, INTERFACE_CLOCK_TM_X, CLOCK_X, CLOCK_REGION_START_X. Also there where 2 different definitions of the region: CLOCK_STRING_WIDTH, CLOCK_REGION_WIDTH.

Pause Box had a fixed position on screen regardless of resolution mode or screen size.

Two different kinds of defines for the Font where used: CLOCKFONT and CLOCK_FONT

After Patch:
Only 2 different coords are existant for rendering the clock, of which 1 is currently redundant as it is off screen for NIV. The later can be used once the Teampanel in tactical screen can handle the clock while showing the inventory (currently the clock is not rendered when NIV is used), this however requires new graphics for 6/8/10 squatsizes. Once a new location for this case is determined simply update the RenderTEAMPanel(BOOLEAN) accordingly with new if clause for NIV (Offset of LOCATION_NAME_TM_X can be used, or what everis convinient).

Also 2 boundary boxes of the region are present, one for the actual area 66*14 (CLOCK_AREA_WIDTH) and one for a little gap of currently 1 pixel for the mouse region (CLOCK_REGION_OFFSET_X) the later one is kindof not neccessary since the String gets now centered in the Area. But maybe someone will make a mod with small render area but large mouseregion for the clock, who knows :)

Pause Box is now rendered in the center of the screen as intended.

Only one font for the clock! There was no need for a different define, also the CLOCKFONT.sti is not in GameFolder so I changed that and use the COMP font.

All globals are now located in Game Clock.cpp but still get initialized in Interface Panels.cpp since the init function in Game Clock.cpp is called too early and no globals for screen size and resolution are known at this point.


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6316 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2013-08-25 13:38:21 +00:00
parent 127dbc2f90
commit 3375414e51
9 changed files with 71 additions and 58 deletions
+33 -18
View File
@@ -3,7 +3,7 @@
#else
#include "sgp.h"
#include "Game Clock.h"
#include "Font Control.h"
#include "Font.h"
#include "render dirty.h"
#include "Timer Control.h"
#include "overhead.h"
@@ -60,6 +60,14 @@ BOOLEAN gfJustFinishedAPause = FALSE;
// clock mouse region
MOUSE_REGION gClockMouseRegion;
MOUSE_REGION gClockScreenMaskMouseRegion;
// Moa: Clock koords moved from Interface Panels.cpp
INT16 INTERFACE_CLOCK_X;
INT16 INTERFACE_CLOCK_Y;
// CHRISL: Added new "TM" variables to allow team and inventory screens to place the clock independantly of each other
INT16 INTERFACE_CLOCK_TM_X;
INT16 INTERFACE_CLOCK_TM_Y;
void AdvanceClock( UINT8 ubWarpCode );
extern BOOLEAN fMapScreenBottomDirty;
@@ -68,9 +76,6 @@ extern BOOLEAN fMapScreenBottomDirty;
#define SECONDS_PER_COMPRESSION 1 // 1/2 minute passes every 1 second of real time
#define SECONDS_PER_COMPRESSION_IN_RTCOMBAT 10
#define SECONDS_PER_COMPRESSION_IN_TBCOMBAT 10
#define CLOCK_STRING_HEIGHT 13
#define CLOCK_STRING_WIDTH 66
#define CLOCK_FONT COMPFONT
//These contain all of the information about the game time, rate of time, etc.
@@ -303,11 +308,12 @@ BOOLEAN HasTimeCompressOccured( void )
return( fTimeCompressHasOccured );
}
//
// \brief renders WORLDTIMESTR or pPausedGameText[0] centered into a box located at sX, sY (top left coords)
//
void RenderClock( INT16 sX, INT16 sY )
{
SetFont( CLOCK_FONT );
SetFont( CLOCKFONT );
SetFontBackground( FONT_MCOLOR_BLACK );
#ifdef CRIPPLED_VERSION
@@ -333,15 +339,18 @@ void RenderClock( INT16 sX, INT16 sY )
}
// Erase first!
RestoreExternBackgroundRect(sX, sY, CLOCK_STRING_WIDTH, CLOCK_STRING_HEIGHT );
RestoreExternBackgroundRect(sX, sY, CLOCK_AREA_WIDTH, CLOCK_AREA_HEIGHT );
INT16 centeredX,centeredY;
if( ( gfPauseDueToPlayerGamePause == FALSE ) )
{
mprintf( sX + (CLOCK_STRING_WIDTH - StringPixLength( WORLDTIMESTR, CLOCK_FONT ))/2, sY, WORLDTIMESTR );
FindFontCenterCoordinates(sX, sY, CLOCK_AREA_WIDTH, CLOCK_AREA_HEIGHT, WORLDTIMESTR, CLOCKFONT, &centeredX, &centeredY);
mprintf( centeredX, centeredY, WORLDTIMESTR );
}
else
{
mprintf( sX + (CLOCK_STRING_WIDTH - StringPixLength( pPausedGameText[ 0 ], CLOCK_FONT ))/2, sY, pPausedGameText[ 0 ] );
FindFontCenterCoordinates(sX, sY, CLOCK_AREA_WIDTH, CLOCK_AREA_HEIGHT, pPausedGameText[ 0 ], CLOCKFONT, &centeredX, &centeredY);
mprintf( centeredX, centeredY, pPausedGameText[ 0 ] );
}
}
@@ -1038,17 +1047,20 @@ BOOLEAN LoadGameClock( HWFILE hFile )
return( TRUE );
}
//
// \brief Creates MOUSE_REGION for FastHelpText and PauseOfClockBtnCallback() centered around a box located at sX, sY (top left coords).
//
void CreateMouseRegionForPauseOfClock( INT16 sX, INT16 sY )
{
if( fClockMouseRegionCreated == FALSE )
{
INT16 sXVal = sX;
INT16 sYVal = sY;
// create a mouse region for pausing of game clock
MSYS_DefineRegion( &gClockMouseRegion, (UINT16)( sXVal ), (UINT16)( sYVal ),(UINT16)( sX + CLOCK_REGION_WIDTH ), (UINT16)( sY + CLOCK_REGION_HEIGHT), MSYS_PRIORITY_HIGHEST,
MSYS_NO_CURSOR, MSYS_NO_CALLBACK, PauseOfClockBtnCallback );
MSYS_DefineRegion( &gClockMouseRegion,
(UINT16)( sX - CLOCK_REGION_OFFSET_X ),
(UINT16)( sY - CLOCK_REGION_OFFSET_Y ),
(UINT16)( sX + CLOCK_AREA_WIDTH + CLOCK_REGION_OFFSET_X),
(UINT16)( sY + CLOCK_AREA_HEIGHT + CLOCK_REGION_OFFSET_Y),
MSYS_PRIORITY_HIGHEST, MSYS_NO_CURSOR, MSYS_NO_CALLBACK, PauseOfClockBtnCallback );
fClockMouseRegionCreated = TRUE;
@@ -1184,8 +1196,11 @@ void RenderPausedGameBox( void )
{
if( ( gfPauseDueToPlayerGamePause == TRUE ) && ( gfGamePaused == TRUE ) && ( iPausedPopUpBox != -1 ) )
{
RenderMercPopUpBoxFromIndex( iPausedPopUpBox, ( INT16 )( 320 - usPausedActualWidth / 2 ), ( INT16 )( 200 - usPausedActualHeight / 2 ), FRAME_BUFFER );
InvalidateRegion( ( INT16 )( 320 - usPausedActualWidth / 2 ), ( INT16 )( 200 - usPausedActualHeight / 2 ), ( INT16 )( 320 - usPausedActualWidth / 2 + usPausedActualWidth ), ( INT16 )( 200 - usPausedActualHeight / 2 + usPausedActualHeight ) );
//Moa: centered PausedGameBox to Screen
//RenderMercPopUpBoxFromIndex( iPausedPopUpBox, ( INT16 )( 320 - usPausedActualWidth / 2 ), ( INT16 )( 200 - usPausedActualHeight / 2 ), FRAME_BUFFER );
//InvalidateRegion( ( INT16 )( 320 - usPausedActualWidth / 2 ), ( INT16 )( 200 - usPausedActualHeight / 2 ), ( INT16 )( 320 - usPausedActualWidth / 2 + usPausedActualWidth ), ( INT16 )( 200 - usPausedActualHeight / 2 + usPausedActualHeight ) );
RenderMercPopUpBoxFromIndex( iPausedPopUpBox, ( INT16 )( (SCREEN_WIDTH - usPausedActualWidth) / 2 ), ( INT16 )( (SCREEN_HEIGHT - usPausedActualHeight) / 2 ), FRAME_BUFFER );
InvalidateRegion( ( INT16 )( (SCREEN_WIDTH - usPausedActualWidth) / 2 ), ( INT16 )( (SCREEN_HEIGHT - usPausedActualHeight) / 2 ), ( INT16 )( (SCREEN_WIDTH - usPausedActualWidth) / 2 + usPausedActualWidth ), ( INT16 )( (SCREEN_HEIGHT - usPausedActualHeight) / 2 + usPausedActualHeight ) );
}
// reset we've just finished a pause by the player