View Issue Details

IDProjectCategoryView StatusLast Update
0000159Volume 2Featurepublic2019-10-12 19:02
ReporterChetAssigned ToChet 
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Product Version 
Target VersionIssue 2Fixed in Version 
Summary0000159: Merge Dex's tray recast timers
DescriptionMerge Dex's tray recast timers.

change the way the client displays unavailable powers, by displaying the remaining cooldown on top of the power icon. Should be available via options.
TagsNo tags attached.
subsystem

Activities

Chet

2019-06-11 00:36

administrator  

0001-Added-cooldown-timer.patch (3,989 bytes)
From 4d37c4eb8eab50ea59abbc706591c7c7aab8aef1 Mon Sep 17 00:00:00 2001
From: DexesTTP
Date: Mon, 27 May 2019 22:25:46 +0200
Subject: [PATCH 1/2] Added cooldown timer

This commit changes the UI of the Powers tray to allow displaying a
white timer on top of the power icon.
This is only done when the power is under cooldown. This can be detected
by checking the value of sc, which is the circle cooldown value, before
the scaling operations are done on it.

The timer is displayed as <digit>.<digit> when the remaining time is
less than 10 seconds, or as mm:ss when the time is over 10 seconds.

The timer is white, horizontally centered on the power icon and
vertically aligned with the top of the icon.
---
 Game/UI/uiTray.c | 54 ++++++++++++++++++++++++++++++++++++++++++------
 Game/UI/uiTray.h |  1 +
 2 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/Game/UI/uiTray.c b/Game/UI/uiTray.c
index 0892b75b..eaf934b9 100644
--- a/Game/UI/uiTray.c
+++ b/Game/UI/uiTray.c
@@ -65,6 +65,7 @@
 #include "character_eval.h"
 #include "uiOptions.h"
 #include "fxutil.h"
+#include "ttFontUtil.h"
 
 U32 g_timeLastPower = 0;
 U32 g_timeLastAttack = 0;
@@ -1057,6 +1058,33 @@ void trayslot_Timer(Entity *e, TrayObj * to, float * sc)
 	}
 }
 
+void trayslot_RemainingTime(Entity *e, TrayObj * to, char * remainingTime)
+{
+	if( to && to->type == kTrayItemType_Power )
+	{
+		PowerRef ppowRef;
+		PowerRechargeTimer * prt;
+
+		ppowRef.buildNum = e->pchar->iCurBuild;
+		ppowRef.power = to->ipow;
+		ppowRef.powerSet = to->iset;
+
+		prt = powerInfo_PowerGetRechargeTimer(e->powerInfo, ppowRef);
+
+		if( prt )
+		{
+			if(prt->rechargeCountdown >= 10.f)
+			{
+				sprintf(remainingTime, "%.0f:%.0f", prt->rechargeCountdown / 60.f, fmod(prt->rechargeCountdown, 60.f));
+			}
+			else
+			{
+				sprintf(remainingTime, "%.1f", prt->rechargeCountdown);
+			}
+		}
+	}
+}
+
 //
 //
 void traySlot_fireFlash( TrayObj * ts, float x, float y, float z )
@@ -1789,12 +1817,14 @@ void trayslot_drawIcon( TrayObj * ts, float xp, float yp, float zp, float scale,
 
 	// this icon will be gotten from differnet sources later
 	AtlasTex *ic = tray_GetIcon(ts, e);
-	int     clr = CLR_WHITE;
-	int		type;
-	int		usable = 1;
-	int     disabled = 0;
-	float	sc = 1.f;
-	CBox	box;
+	int      clr = CLR_WHITE;
+	int		 type;
+	int		 usable = 1;
+	int      disabled = 0;
+	float	 sc = 1.f;
+	bool     isCooldownActive;
+	char 	 remainingTime[20];
+	CBox	 box;
 
 	static AtlasTex * power_ring;
 	static AtlasTex * spin;
@@ -1823,6 +1853,8 @@ void trayslot_drawIcon( TrayObj * ts, float xp, float yp, float zp, float scale,
 		ic = atlasLoadTexture( "Power_Missing.tga" );
 
 	trayslot_Timer( e, ts, &sc );
+	isCooldownActive = sc < 1.0f;
+
 	sc = sc/2 + .5f;
 
 	if( sc < ts->scale )
@@ -1874,6 +1906,16 @@ void trayslot_drawIcon( TrayObj * ts, float xp, float yp, float zp, float scale,
 	// draw the normal icon
 	display_sprite( ic, xp - ic->width*ts->scale*sc*scale/2, yp - ic->width*ts->scale*sc*scale/2, zp + 2, ts->scale*scale*sc, ts->scale*scale*sc, clr );
 
+	if( isCooldownActive )
+	{
+		trayslot_RemainingTime( e, ts, remainingTime );
+
+		// Display the remaining time on screen
+		font( &game_9 );
+		font_color( CLR_WHITE, CLR_WHITE );
+		cprntEx(xp, yp, zp, scale * 1.5, scale * 1.5, (CENTER_X), remainingTime);
+	}
+
 	if( ts->autoPower )
 	{
 		int		autoColor = 0xffffff22;
diff --git a/Game/UI/uiTray.h b/Game/UI/uiTray.h
index 8393a700..869de220 100644
--- a/Game/UI/uiTray.h
+++ b/Game/UI/uiTray.h
@@ -74,6 +74,7 @@ void tray_setSticky( CurTrayType tray, int toggle );
 void tray_toggleSticky( CurTrayType tray );
 
 void trayslot_Timer( Entity *e, TrayObj * to, float * sc );
+void trayslot_RemainingTime( Entity *e, TrayObj * to, char * remainingTime );
 int trayslot_IsActive( Entity *e,  TrayObj * to );
 void tray_Clear(void);
 
-- 
2.21.0.windows.1

0002-Added-UI-option-for-cooldown-timer.patch (7,361 bytes)
From e2a2e7b9cdd7b47041c0189a6dab4e5e71a860d6 Mon Sep 17 00:00:00 2001
From: DexesTTP
Date: Mon, 27 May 2019 23:58:21 +0200
Subject: [PATCH 2/2] Added UI option for cooldown timer

Added an ingame option to show or hide the cooldown timer. This option
appears under the General/Miscellaneous section.
The .pigg files with text in them need to be rebuilt to include the two
new entries "ShowTimer" and "ShowTimerHelp", to have proper explanatory
text of the option. The relevant template files available under Assets/
have been updated.
This option is serialized as a brand new saved bit (bit 11 of section 4)
instead of a repurposed unused bit (like bit 0 of section 2). This is
because this option is minor and can be dropped as needed, whether the
old bits would be more suitable for options required to be serialized
properly regardless of the client.
---
 Common/entity/entPlayer.h                      |  1 +
 Game/UI/uiOptions.c                            |  1 +
 Game/UI/uiOptions_Type.c                       |  1 +
 Game/UI/uiOptions_Type.h                       |  1 +
 Game/UI/uiTray.c                               |  3 ++-
 MapServer/container/containerloadsave.c        |  2 +-
 MapServer/entity/entserver.c                   |  1 +
 MapServer/player/parseClientInput.c            |  1 +
 TestClient/externs.c                           |  2 +-
 11 files changed, 38 insertions(+), 11 deletions(-)

diff --git a/Common/entity/entPlayer.h b/Common/entity/entPlayer.h
index 45c348ec..d9b9486a 100644
--- a/Common/entity/entPlayer.h
+++ b/Common/entity/entPlayer.h
@@ -260,6 +260,7 @@ typedef struct EntPlayer
 	int sgHideButtons;
 	int clicktomove;
 	int disableDrag;
+	int showTimer;
 	int showPetBuffs;
 	int preventPetIconDrag;
 	int showPetControls;
diff --git a/Game/UI/uiOptions.c b/Game/UI/uiOptions.c
index 0de0d18a..92e0459b 100644
--- a/Game/UI/uiOptions.c
+++ b/Game/UI/uiOptions.c
@@ -645,6 +645,7 @@ static GameOptions s_optListGeneral[] =
 	{ kUO_DeclineTeamGifts,         kOptionType_Bool,   "DeclineTeamGifts",    "DeclineTeamGiftsHelp",    NULL, kOptionType_Bool,        NULL,                     NULL,                  "OptionEnabled",  "OptionDisabled" },
 	{ kUO_UseOldTeamUI,				kOptionType_Bool,   "UseOldTeamUI",		   "UseOldTeamUIHelp",		  NULL, kOptionType_Bool,        NULL,                     NULL,                  "OptionEnabled",  "OptionDisabled" },
 	{ kUO_DisableDrag,              kOptionType_Bool,   "LockPowerTray",       "LockPowerTrayHelp",       NULL, kOptionType_Bool,        NULL,                     NULL,                  "OptionEnabled",  "OptionDisabled" },
+	{ kUO_ShowTimer,                kOptionType_Bool,   "ShowTimer",           "ShowTimerHelp",           NULL, kOptionType_Bool,        NULL,                     NULL,                  "OptionEnabled",  "OptionDisabled" },
 	{ kUO_DisableLoadingTips,       kOptionType_Bool,   "DisableLoadingTip",   "DisableLoadingTipsHelp",  NULL, kOptionType_Bool,        NULL,                     NULL,                  "OptionDisabled", "OptionEnabled", },
 	{ kUO_NoXP,						kOptionType_Bool,   "NoXPPrompt",		   "NoXPHelp",	              NULL, kOptionType_Bool,        NULL,                     NULL,				  "OptionNoXP",		"OptionEarnXP" },
 	{ kUO_NoXPExemplar,				kOptionType_Bool,   "NoXPExemplarPrompt",  "NoXPExemplarHelp",	      NULL, kOptionType_Bool,        NULL,                     NULL,				  "OptionNoXPIng",  "OptionEarnXP" },
diff --git a/Game/UI/uiOptions_Type.c b/Game/UI/uiOptions_Type.c
index 769867df..ba9c9216 100644
--- a/Game/UI/uiOptions_Type.c
+++ b/Game/UI/uiOptions_Type.c
@@ -40,6 +40,7 @@ UserOption game_options[] =
 	{ kUO_HideButtons,                 "HideButtons",                 0, 0, 0, 1 },
 	{ kUO_ClickToMove,                 "EnableClickToMove",           0, 0, 0, 1 },
 	{ kUO_DisableDrag,                 "DisableDrag",                 0, 0, 0, 1 },
+	{ kUO_ShowTimer,                   "ShowTimer",	                  0, 0, 0, 1 },
 	{ kUO_ShowPetBuffs,                "gShowPetBuffs",               0, 0, 0, 1 },
 	{ kUO_PreventPetIconDrag,          "PreventPetIconDrag",          0, 0, 0, 1 },
 	//
diff --git a/Game/UI/uiOptions_Type.h b/Game/UI/uiOptions_Type.h
index 2f7519f5..5c86965f 100644
--- a/Game/UI/uiOptions_Type.h
+++ b/Game/UI/uiOptions_Type.h
@@ -143,6 +143,7 @@ typedef enum EUserOptions
 //		 However you will need to take care of serverside netowrking ( entserver.c and parseClientInput.c ) and database saving ( containerloadsave.c )
 
 	kUO_OptionTotal, 
+	kUO_ShowTimer,
 }EUserOptions;
 
 
diff --git a/Game/UI/uiTray.c b/Game/UI/uiTray.c
index eaf934b9..c3bd0c39 100644
--- a/Game/UI/uiTray.c
+++ b/Game/UI/uiTray.c
@@ -1906,7 +1906,8 @@ void trayslot_drawIcon( TrayObj * ts, float xp, float yp, float zp, float scale,
 	// draw the normal icon
 	display_sprite( ic, xp - ic->width*ts->scale*sc*scale/2, yp - ic->width*ts->scale*sc*scale/2, zp + 2, ts->scale*scale*sc, ts->scale*scale*sc, clr );
 
-	if( isCooldownActive )
+	// Draw the cooldown only if the option is enabled in the UI
+	if( isCooldownActive && optionGet(kUO_ShowTimer) )
 	{
 		trayslot_RemainingTime( e, ts, remainingTime );
 
diff --git a/MapServer/container/containerloadsave.c b/MapServer/container/containerloadsave.c
index 163fe21e..1ccd974d 100644
--- a/MapServer/container/containerloadsave.c
+++ b/MapServer/container/containerloadsave.c
@@ -3630,8 +3630,8 @@ uiSetting uiSettings4[] = {
 	{OFFSET2_PTR(Entity, pl,	EntPlayer,	hideStoreAccessButton)			}, // 8
 	{OFFSET2_PTR(Entity, pl,	EntPlayer,	autoFlipSuperPackCards)			}, // 9
 	{OFFSET2_PTR(Entity, pl,	EntPlayer,	hideConvertConfirmPrompt)		}, // 10
+	{OFFSET2_PTR(Entity, pl,	EntPlayer,	showTimer)							  }, // 11
 
- // 11
  // 12
  // 13
  // 14
diff --git a/MapServer/entity/entserver.c b/MapServer/entity/entserver.c
index 219753b4..3879f487 100644
--- a/MapServer/entity/entserver.c
+++ b/MapServer/entity/entserver.c
@@ -1367,6 +1367,7 @@ void sendCharacterToClient( Packet *pak, Entity *e)
 		pktSendBits( pak, 1, e->pl->sgHideButtons );
 		pktSendBits( pak, 1, e->pl->clicktomove );
 		pktSendBits( pak, 1, e->pl->disableDrag );
+		pktSendBits( pak, 1, e->pl->showTimer );
 		pktSendBits( pak, 1, e->pl->showPetBuffs );
 		pktSendBits( pak, 1, e->pl->preventPetIconDrag);
 		pktSendBits( pak, 1, e->pl->showPetControls);
diff --git a/MapServer/player/parseClientInput.c b/MapServer/player/parseClientInput.c
index f0c6442f..3aa49b9b 100644
--- a/MapServer/player/parseClientInput.c
+++ b/MapServer/player/parseClientInput.c
@@ -1685,6 +1685,7 @@ int parseClientInput( Packet *pak, ClientLink *client )
 					pl->sgHideButtons				= pktGetBits( pak, 1 );
 					pl->clicktomove					= pktGetBits( pak, 1 );
 					pl->disableDrag					= pktGetBits( pak, 1 );
+					pl->showTimer					= pktGetBits( pak, 1 );
 					pl->showPetBuffs				= pktGetBits( pak, 1 );
 					pl->preventPetIconDrag			= pktGetBits( pak, 1 );
 					pl->showPetControls				= pktGetBits( pak, 1 );
diff --git a/TestClient/externs.c b/TestClient/externs.c
index d532db8b..68806fbc 100644
--- a/TestClient/externs.c
+++ b/TestClient/externs.c
@@ -972,7 +972,7 @@ bool gLogChat = FALSE;
 bool gDisableDrag;
 bool gHideButtons = FALSE;
 bool gHideHeader = FALSE;
-bool gDisableDrag;
+bool gShowTimer;
 int gShowPetBuffs;
 int gChatDisablePetSay;
 int gChatEnablePetTeamSay;
-- 
2.21.0.windows.1

PullRequestText.md (1,075 bytes)

Chet

2019-06-11 00:50

administrator   ~0000112

https://git.ourodev.com/CoX/Source/pulls/86

Chet

2019-10-12 19:02

administrator   ~0000160

https://git.ourodev.com/CoX/Source/pulls/122

Issue History

Date Modified Username Field Change
2019-06-11 00:04 Chet New Issue
2019-06-11 00:04 Chet Assigned To => Chet
2019-06-11 00:04 Chet Status new => assigned
2019-06-11 00:36 Chet File Added: 0001-Added-cooldown-timer.patch
2019-06-11 00:36 Chet File Added: 0002-Added-UI-option-for-cooldown-timer.patch
2019-06-11 00:36 Chet File Added: PullRequestText.md
2019-06-11 00:50 Chet Note Added: 0000112
2019-10-12 19:02 Chet Note Added: 0000160
2019-10-12 19:02 Chet Status assigned => resolved
2019-10-12 19:02 Chet Resolution open => fixed