- 5
- Posts
- 2
- Years
- Seen Nov 11, 2023
Hello, I would like to display the current time while you are in the start menu. So far I have I managed to display the time. However, it is stuck on the time you open the menu. A second problem is when speeding the game up, it no longer displays the correct time, as more game time has passed compared to regular time. Does someone know how to solve this?
This is what I have done so far:
Basicly everything happens in src/start_menu.c
at the top of the file i added
then, in the EWRAM section, underneath sBattlePyramidFloorWindowId I added:
next, under sPyramidFloorWindowTemplate_1:
next for the actual code for displaying the time box, underneath static void ShowPyramidFloorWindow(void):
then in the function RemoveExtraStartMenuWindows, I added:
and finally in InitStartMenuStep in case 3:
I also added strings in src/strings.c and include/strings.h
in src.strings.c I replaced an unused string with const u8 gText_StartMenuTime[] = _(" {STR_VAR_1}:{STR_VAR_2}:{STR_VAR_3}");
and in include/strings.h I added extern const u8 gText_StartMenuTime[];
Hopefully someone could help me with this, thanks in advance!
This is what I have done so far:
Spoiler:
Basicly everything happens in src/start_menu.c
at the top of the file i added
Code:
#include "rtc.h"
Code:
EWRAM_DATA static u8 sStartMenuTimeWindowId = 0;
Code:
static const struct WindowTemplate sStartMenuTimeWindowTemplate = {0, 1, 1, 0xA, 2, 0xF, 8};
Code:
static void ShowTimeWindow(void)
{
sStartMenuTimeWindowId = AddWindow(&sStartMenuTimeWindowTemplate);
PutWindowTilemap(sStartMenuTimeWindowId);
DrawStdWindowFrame(sStartMenuTimeWindowId, FALSE);
ConvertIntToDecimalStringN(gStringVar1, gLocalTime.hours, STR_CONV_MODE_LEADING_ZEROS, 2);
ConvertIntToDecimalStringN(gStringVar2, gLocalTime.minutes, STR_CONV_MODE_LEADING_ZEROS, 2);
ConvertIntToDecimalStringN(gStringVar3, gLocalTime.seconds, STR_CONV_MODE_LEADING_ZEROS, 2);
StringExpandPlaceholders(gStringVar4, gText_StartMenuTime);
AddTextPrinterParameterized(sStartMenuTimeWindowId, FONT_NORMAL, gStringVar4, 0, 1, TEXT_SKIP_DRAW, NULL);
CopyWindowToVram(sStartMenuTimeWindowId, COPYWIN_GFX);
}
Code:
if(!GetSafariZoneFlag() && !InBattlePyramid())
{
ClearStdWindowAndFrameToTransparent(sStartMenuTimeWindowId, FALSE);
RemoveWindow(sStartMenuTimeWindowId);
}
Code:
if (!GetSafariZoneFlag() && !InBattlePyramid())
ShowTimeWindow();
in src.strings.c I replaced an unused string with const u8 gText_StartMenuTime[] = _(" {STR_VAR_1}:{STR_VAR_2}:{STR_VAR_3}");
and in include/strings.h I added extern const u8 gText_StartMenuTime[];
Hopefully someone could help me with this, thanks in advance!