Added: 12-hour clock in radar and chat

This commit is contained in:
Nimetu 2015-12-13 21:01:56 +02:00
parent e98bc5daee
commit 02b5c3e4ed
6 changed files with 39 additions and 4 deletions

View file

@ -567,7 +567,7 @@
<!-- compass clock -->
<group id="clock"
posref="TL TL"
w="50"
w="70"
h="16"
x="4"
y="-4">

View file

@ -2765,6 +2765,9 @@ This MUST follow the Enum MISSION_DESC::TIconId
<variable entry="UI:SAVE:SHOW_CLOCK"
type="bool"
value="false" />
<variable entry="UI:SAVE:SHOW_CLOCK_12H"
type="bool"
value="false" />
<variable entry="UI:SAVE:SHOW_RETICLE"
type="bool"
value="true" />

View file

@ -1399,12 +1399,20 @@
posparent="cao"
x="0"
y="-12" />
<instance template="tgcw_checkbox"
id="show_clock_12h"
text="uiShowClock12h"
tooltip="uittShowClock12h"
posref="BL TL"
posparent="show_clock"
x="0"
y="-12" />
<instance template="tgcw_checkbox"
id="show_reticle"
text="uiShowReticle"
tooltip="uittShowReticle"
posref="BL TL"
posparent="show_clock"
posparent="show_clock_12h"
x="0"
y="-12" />
</group>
@ -3255,6 +3263,11 @@
widget="boolbut"
link="UI:SAVE:SHOW_CLOCK"
realtime="true" />
<param ui="hud:show_clock_12h:c"
type="db"
widget="boolbut"
link="UI:SAVE:SHOW_CLOCK_12H"
realtime="true" />
<param ui="hud:show_reticle:c"
type="db"
widget="boolbut"

View file

@ -167,6 +167,10 @@ CViewBase *CChatTextManager::createMsgText(const ucstring &cstMsg, NLMISC::CRGBA
ucstring cur_time;
if (showTimestamps())
{
CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:SHOW_CLOCK_12H", false);
if (node && node->getValueBool())
cur_time = CInterfaceManager::getTimestampHuman("[%I:%M:%S %p] ");
else
cur_time = CInterfaceManager::getTimestampHuman();
}

View file

@ -1495,6 +1495,9 @@ void CInterfaceManager::updateFrameEvents()
{
if (pVT->getActive())
{
if (use12hClock())
str = getTimestampHuman("%I:%M %p");
else
str = getTimestampHuman("%H:%M");
pVT->setText(str);
}
@ -3639,6 +3642,14 @@ void CInterfaceManager::CServerToLocalAutoCopy::onLocalChange(ICDBNode *localNod
}
}
// ------------------------------------------------------------------------------------------------
bool CInterfaceManager::use12hClock()
{
CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:SHOW_CLOCK_12H", false);
return (node && node->getValueBool());
}
// ------------------------------------------------------------------------------------------------
char* CInterfaceManager::getTimestampHuman(const char* format /* "[%H:%M:%S] " */)
{

View file

@ -408,6 +408,10 @@ public:
void notifyMailAvailable();
void notifyForumUpdated();
/** Return true if 12-hour clock should be used
*/
static bool use12hClock();
/** Returns a human readable timestamp with the given format.
*/
static char* getTimestampHuman(const char* format = "[%H:%M:%S] ");