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
+12 -10
View File
@@ -1,19 +1,21 @@
#ifndef __WORLD_CLOCK
#define __WORLD_CLOCK
#include "FileMan.h"
// where the time string itself is rendered
#define CLOCK_X (SCREEN_WIDTH - xResSize)/2 + (xResSize - 86)
#define CLOCK_REGION_START_X (CLOCK_X + 2)
#define CLOCK_REGION_WIDTH ((xResSize - 20) - CLOCK_REGION_START_X)
#define CLOCK_Y (SCREEN_HEIGHT - 21)
//Moa: renderable area should match the background area where ClockString gets rendered, !use even numbers!
#define CLOCK_AREA_HEIGHT 14 //hight of renderable area should match the background area where ClockString gets rendered
#define CLOCK_AREA_WIDTH 66 //x boundary
//Clock coords moved from Interface Panels.cpp, gets initialized in InitializeSMPanelCoordsNew()/InitializeSMPanelCoordsOld()
extern INT16 INTERFACE_CLOCK_X; // xPos of Left Top edge of boundary
extern INT16 INTERFACE_CLOCK_Y;
//the mouse region around the clock (bigger), actual region position depends on parameters given to CreateMouseRegionForPauseOfClock(INT16,INT16)
#define CLOCK_REGION_OFFSET_X 1
#define CLOCK_REGION_OFFSET_Y 1
// CHRISL: Added new "TM" variables to allow team and inventory screens to place the clock independantly of each other @see Interface Panels.cpp->InitializeTEAMPanelCoords()
extern INT16 INTERFACE_CLOCK_TM_X;
extern INT16 INTERFACE_CLOCK_TM_Y;
// the mouse region around the clock (bigger)
#define CLOCK_REGION_START_Y (SCREEN_HEIGHT - 24)
#define CLOCK_REGION_HEIGHT ((SCREEN_HEIGHT - 12) - CLOCK_REGION_START_Y)
#define NUM_SEC_IN_DAY 86400
#define NUM_SEC_IN_HOUR 3600
+1 -1
View File
@@ -1542,7 +1542,7 @@ void CreateDestroyMouseRegionMasksForTimeCompressionButtons( void )
MSYS_NO_CURSOR, MSYS_NO_CALLBACK, CompressMaskClickCallback );
// mask over pause game button
MSYS_DefineRegion( &gTimeCompressionMask[ 2 ], xResOffset + (xResSize - 153), (SCREEN_HEIGHT - 24), xResOffset + (xResSize - 153) - 118, (SCREEN_HEIGHT - 13), MSYS_PRIORITY_HIGHEST - 1,
MSYS_DefineRegion( &gTimeCompressionMask[ 2 ], xResOffset + (xResSize - 153), (SCREEN_HEIGHT - 24), xResOffset + (xResSize - 153) + 118, (SCREEN_HEIGHT - 13), MSYS_PRIORITY_HIGHEST - 1,
MSYS_NO_CURSOR, MSYS_NO_CALLBACK, CompressMaskClickCallback );
fCreated = TRUE;
+1 -1
View File
@@ -1168,7 +1168,7 @@ void ExitQuestDebugSystem()
//Create the clock mouse region
CreateMouseRegionForPauseOfClock( CLOCK_REGION_START_X, CLOCK_REGION_START_Y );
CreateMouseRegionForPauseOfClock( INTERFACE_CLOCK_X, INTERFACE_CLOCK_Y );
giHaveSelectedNPC = gNpcListBox.sCurSelectedItem;
giHaveSelectedItem = gItemListBox.sCurSelectedItem;
+2 -2
View File
@@ -5129,7 +5129,7 @@ UINT32 MapScreenHandle(void)
SpecifyButtonDownTextColors( giMapContractButton, CHAR_TEXT_FONT_COLOR, FONT_BLACK );
// create mouse region for pause clock
CreateMouseRegionForPauseOfClock( CLOCK_REGION_START_X, CLOCK_REGION_START_Y );
CreateMouseRegionForPauseOfClock( INTERFACE_CLOCK_X, INTERFACE_CLOCK_Y );
// WANNE: The number of merc we can display in the list, depends on the resolution
if (iResolution >= _640x480 && iResolution < _800x600)
@@ -5641,7 +5641,7 @@ UINT32 MapScreenHandle(void)
// render clock
// WANNE: Renders the clock in the strategy screen
RenderClock(CLOCK_X, CLOCK_Y);
RenderClock(INTERFACE_CLOCK_X, INTERFACE_CLOCK_Y);
#ifdef JA2TESTVERSION
if( !gfWorldLoaded )
+18 -21
View File
@@ -37,7 +37,7 @@
#include "Interface Items.h"
#include "interface control.h"
#include "interface utils.h"
#include "game clock.h"
#include "Game Clock.h"
#include "mapscreen.h"
#include "Soldier Macros.h"
#include "strategicmap.h"
@@ -330,15 +330,11 @@ TEAM_PANEL_SLOTS_TYPE gTeamPanel[ NUM_TEAM_SLOTS ];
* i will work with radar screen to allow moving it. or maby someone else will do it
* any questions? joker
*/
int INTERFACE_CLOCK_X;
int INTERFACE_CLOCK_Y;
int LOCATION_NAME_X;
int LOCATION_NAME_Y;
/* CHRISL: Added new "TM" variables to allow team and inventory screens to place the clock and location name
/* CHRISL: Added new "TM" variables to allow team and inventory screens to place the location name
independantly of each other */
int INTERFACE_CLOCK_TM_X;
int INTERFACE_CLOCK_TM_Y;
int LOCATION_NAME_TM_X;
int LOCATION_NAME_TM_Y;
@@ -1559,8 +1555,13 @@ BOOLEAN InitializeSMPanelCoordsOld()
SM_DONE_X = xResOffset + (xResSize - 97);
SM_MAPSCREEN_X = xResOffset + (xResSize - 51);
INTERFACE_CLOCK_X = xResOffset + (xResSize - 86);
LOCATION_NAME_X = xResOffset + (xResSize - 92);
//dnl INTERFACE_CLOCK_X = xResOffset + (xResSize - 86);
//dnl INTERFACE_CLOCK_Y = ( 119 + INV_INTERFACE_START_Y );
INTERFACE_CLOCK_X = xResOffset + (xResSize - 86);
INTERFACE_CLOCK_Y = SCREEN_HEIGHT - 24;
LOCATION_NAME_X = xResOffset + (xResSize - 92);
LOCATION_NAME_Y = ( 65 + INTERFACE_START_Y );
SM_DONE_Y = ( 4 + INV_INTERFACE_START_Y );
SM_MAPSCREEN_Y = ( 4 + INV_INTERFACE_START_Y );
@@ -1625,10 +1626,6 @@ BOOLEAN InitializeSMPanelCoordsOld()
STATS_TITLE_FONT_COLOR = 6;
STATS_TEXT_FONT_COLOR = 5;
// ow and te clock and location i will put it here
INTERFACE_CLOCK_Y = ( 119 + INV_INTERFACE_START_Y );
LOCATION_NAME_Y = ( 65 + INTERFACE_START_Y );
// Keyring 496/106 on Inventory_Bottom_Panel.sti
KEYRING_X = xResOffset + 496;
KEYRING_Y = (106 + INV_INTERFACE_START_Y);
@@ -1918,8 +1915,13 @@ BOOLEAN InitializeSMPanelCoordsNew()
SM_ZIPPER_Y = ( 39 + INV_INTERFACE_START_Y );
SM_MAPSCREEN_X = xResOffset + (xResSize - 146); // 152
SM_DONE_X = xResOffset + (xResSize - 146); // 152
//dnl INTERFACE_CLOCK_X = xResOffset + (xResSize - 86);
//dnl INTERFACE_CLOCK_Y = ( 119 + INV_INTERFACE_START_Y );
INTERFACE_CLOCK_X = xResOffset + (xResSize - 86);
INTERFACE_CLOCK_Y = SCREEN_HEIGHT - 24;
LOCATION_NAME_X = xResOffset + (xResSize - 92);
LOCATION_NAME_Y = ( 89 + INTERFACE_START_Y );
SM_DONE_Y = ( 118 + INV_INTERFACE_START_Y );
SM_MAPSCREEN_Y = ( 140 + INV_INTERFACE_START_Y );
@@ -1997,10 +1999,6 @@ BOOLEAN InitializeSMPanelCoordsNew()
STATS_TITLE_FONT_COLOR = 6;
STATS_TEXT_FONT_COLOR = 5;
// ow and te clock and location i will put it here
INTERFACE_CLOCK_Y = ( 117 + INV_INTERFACE_START_Y );
LOCATION_NAME_Y = ( 89 + INTERFACE_START_Y );
//Keyring 218/5 on Inventory_Bottom_Panel.sti
KEYRING_X = xResOffset + 219; //209;
KEYRING_Y = (5 + INV_INTERFACE_START_Y);
@@ -5102,8 +5100,11 @@ BOOLEAN InitializeTEAMPanelCoords( )
TM_ENDTURN_X = xResOffset + (xResSize - 131);
TM_ROSTERMODE_X = xResOffset + (xResSize - 131);
TM_DISK_X = xResOffset + (xResSize - 131);
// CHRISL: New definitions for the team panel clock and location coordinates
INTERFACE_CLOCK_TM_X = xResOffset + (xResSize - 86 );
LOCATION_NAME_TM_X = xResOffset + (xResSize - 92 );
INTERFACE_CLOCK_TM_Y = ( 96 + INTERFACE_START_Y );
LOCATION_NAME_TM_X = xResOffset + (xResSize - 92 );
LOCATION_NAME_TM_Y = ( 65 + INTERFACE_START_Y );
TM_ENDTURN_Y = ( 9 + INTERFACE_START_Y );
TM_ROSTERMODE_Y = ( 45 + INTERFACE_START_Y );
@@ -5222,10 +5223,6 @@ BOOLEAN InitializeTEAMPanelCoords( )
sTEAMHandInvXY[10] = ( TM_INV_HAND1STARTX + ( 5 * TM_INV_HAND_SEP )); sTEAMHandInvXY[11] = TM_INV_HAND1STARTY;
// ufff to much copy&paste :D
*/
// CHRISL: New definitions for the team panel clock and location coordinates
INTERFACE_CLOCK_TM_Y = ( 99 + INTERFACE_START_Y );
LOCATION_NAME_TM_Y = ( 65 + INTERFACE_START_Y );
return ( TRUE );
}
+2 -2
View File
@@ -43,8 +43,8 @@ typedef enum
#define SHOW_LOCATOR_NORMAL 1
#define SHOW_LOCATOR_FAST 2
extern int INTERFACE_CLOCK_X;
extern int INTERFACE_CLOCK_Y;
//extern INT16 INTERFACE_CLOCK_X;
//extern INT16 INTERFACE_CLOCK_Y;
extern int LOCATION_NAME_X;
extern int LOCATION_NAME_Y;
-2
View File
@@ -1489,7 +1489,6 @@ void HandleShopKeeperInterface()
}
// CHRISL: If in NIV mode, don't display the clock
//RenderClock( CLOCK_X, CLOCK_Y );
if( UsingNewInventorySystem() == false )
RenderClock( INTERFACE_CLOCK_X, INTERFACE_CLOCK_Y );
// CHRISL: Added X,Y parameters to allow control of TownID string placement.
@@ -1665,7 +1664,6 @@ BOOLEAN RenderShopKeeperInterface()
//Render the clock and the town name
// CHRISL: If in NIV mode, don't display the clock
//RenderClock( CLOCK_X, CLOCK_Y );
if( UsingNewInventorySystem() == false )
RenderClock( INTERFACE_CLOCK_X, INTERFACE_CLOCK_Y );
// CHRISL: Added X,Y parameters to allow control of TownID string placement.
+2 -1
View File
@@ -104,7 +104,8 @@ extern BOOLEAN gfFontsInit;
#define SMALLFONT1 gpSmallFontType1
#define TINYFONT1 gpTinyFontType1
#define FONT12POINT1 gp12PointFont1
#define CLOCKFONT gpClockFont
//#define CLOCKFONT gpClockFont //remove comment if change ok! "FONTS\\CLOCKFONT.sti" does not exist in Data Folder!
#define CLOCKFONT gpCompFont
#define COMPFONT gpCompFont
#define SMALLCOMPFONT gpSmallCompFont
#define FONT10ROMAN gp10PointRoman