1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-25 22:18:30 +02:00
VVVVVV/desktop_version/src
Dav999-v 3e36bfd56f Simplify time formatting functions
Here's my notes on all the existing functions and what kind of time
formats they output:

- Game::giventimestring(int hrs, int min, int sec)
	H:MM:SS
	MM:SS

- Game::timestring()
// uses game.hours/minutes/seconds
	H:MM:SS
	MM:SS

- Game::partimestring()
// uses game.timetrialpar (seconds)
	MM:SS

- Game::resulttimestring()
// uses game.timetrialresulttime (sec) + timetrialresultframes (1/30s)
	MM:SS.CC

- Game::timetstring(int t)
// t = seconds
	MM:SS

- Game::timestringcenti(char* buffer, const size_t buffer_size)
// uses game.hours/minutes/seconds/frames
	H:MM:SS.CC
	MM:SS.CC

- UtilityClass::timestring(int t)
// t = frames, 30 frames = 1 second
	S:CC
	M:SS:CC

This is kind of a mess, and there's a lot of functions that do the same
thing except using different variables. For localization, I also want
translators to be able to localize all these time formats - many
languages use the decimal comma instead of the decimal point (12:34,56)
maybe some languages really prefer something like 1時02分11秒44瞬...
Which I don't know to be correct, but it's good to be prepared for it
and not restrict translators arbitrarily to only changing ":" and "."
when we can start making the system better in the first place.

I added a new function, UtilityClass::format_time. This is the place
where all time formats come together, given the number of seconds and
optionally frames. I have simplified the above-mentioned functions
somewhat, but I haven't given them a complete refactor or renaming -
I mainly made sure that they all use the same backend so I can make the
formats consistent and properly localizable.

(And before we start shoving more temporary char buffers everywhere
just to get rid of the std::string's, maybe we need to think of a
globally used working buffer of size SCREEN_WIDTH_CHARS+1, as a
register of sorts, for when any line of text needs to be made or
processed, then printed, and then goes unused. Maybe help.textrow,
or something like that.)

As for this commit, the available time formats are now more consistent
and changed a little in some places. Leading zeroes for the first unit
are now no longer included, time trial results and the Super Gravitron
can now display hours when they went to 60 minutes before, and we now
always use .CC instead of :CC. These are the formats:
- H:MM:SS
- H:MM:SS.CC
- M:SS
- M:SS.CC
- S.CC  (only used when always_minutes=false, for the Gravitrons)

Here's what changes to the current functions:
- Game::partimestring() is removed - it was used in two places, and
  could be replaced by game.timetstring(game.timetrialpar)
- Game::giventimestring(h,m,s) and Game::timestring() are now wrappers
  for the other functions
- The four remaining functions (Game::resulttimestring(),
  Game::timetstring(t), Game::timestringcenti(buffer, buffer_size)
  and UtilityClass::timestring(t)) are now wrappers for the "central
  function", UtilityClass::format_time.
- UtilityClass::twodigits(int t) is now unused so it's also removed.
- I also added int UtilityClass::hms_to_seconds(int h, int m, int s)
2021-12-25 11:38:12 -08:00
..
BinaryBlob.cpp Fix regression with VVV_COMPILEMUSIC aborting 2021-09-23 22:35:52 -07:00
BinaryBlob.h Use fixed-size int types for resourceheader 2021-09-23 22:21:49 -07:00
BlockV.cpp Add setactivityposition(x,y), add new textbox color transparent (#847) 2021-10-13 15:38:51 -07:00
BlockV.h Add setactivityposition(x,y), add new textbox color transparent (#847) 2021-10-13 15:38:51 -07:00
Constants.h Fix SCREEN_HEIGHT_PIXELS being wrong constant 2021-10-01 09:35:28 -07:00
Credits.h Move Misa to C++ credits 2021-08-31 23:22:22 -07:00
CustomLevels.cpp Fix regression with counting out-of-bounds custom entities 2021-10-27 16:49:57 -07:00
CustomLevels.h Remove vmult lookup tables 2021-09-24 16:37:27 -07:00
DeferCallbacks.c Add deferred callbacks to game loop 2021-03-21 02:55:42 -04:00
DeferCallbacks.h Add deferred callbacks to game loop 2021-03-21 02:55:42 -04:00
Editor.cpp Extern gameScreen, remove screenbuffer 2021-12-25 00:29:28 -08:00
Editor.h Use const std::string& where possible in function params 2021-09-06 15:43:59 -07:00
Ent.cpp Untabify every single file 2021-09-06 18:56:39 -07:00
Ent.h Untabify every single file 2021-09-06 18:56:39 -07:00
Entity.cpp Add setactivityposition(x,y), add new textbox color transparent (#847) 2021-10-13 15:38:51 -07:00
Entity.h Add setactivityposition(x,y), add new textbox color transparent (#847) 2021-10-13 15:38:51 -07:00
Enums.h Remove unused game-gamestates 2021-12-18 00:01:32 -08:00
Exit.h Use SDL_NORETURN 2021-09-27 10:32:23 -07:00
FileSystemUtils.cpp Fix -Wformat-security warnings 2021-12-05 10:45:36 -08:00
FileSystemUtils.h Call FS.syncfs on Emscripten (#838) 2021-09-02 13:19:51 -04:00
Finalclass.cpp Replace roomnames/hiddennames/glitchnames with const char* 2021-09-12 21:06:26 -07:00
Finalclass.h Replace roomnames/hiddennames/glitchnames with const char* 2021-09-12 21:06:26 -07:00
Game.cpp Simplify time formatting functions 2021-12-25 11:38:12 -08:00
Game.h Simplify time formatting functions 2021-12-25 11:38:12 -08:00
GlitchrunnerMode.c Split glitchrunner mode into multiple versions 2021-08-05 13:35:21 -04:00
GlitchrunnerMode.h Split glitchrunner mode into multiple versions 2021-08-05 13:35:21 -04:00
GOGNetwork.c Axe NETWORK_[set/get]AchievementProgress() 2021-09-19 21:49:54 -07:00
Graphics.cpp Extern gameScreen, remove screenbuffer 2021-12-25 00:29:28 -08:00
Graphics.h Extern gameScreen, remove screenbuffer 2021-12-25 00:29:28 -08:00
GraphicsResources.cpp Use LoadImage in LoadIcon 2021-12-25 01:29:24 -08:00
GraphicsResources.h Consistently use angle brackets for SDL.h includes 2020-07-19 21:37:40 -04:00
GraphicsUtil.cpp Fix char overflow in Analogue Mode 2021-12-22 21:49:08 -08:00
GraphicsUtil.h Add ClearSurface() 2021-02-25 19:38:25 -05:00
Input.cpp Extern gameScreen, remove screenbuffer 2021-12-25 00:29:28 -08:00
Input.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
KeyPoll.cpp Extern gameScreen, remove screenbuffer 2021-12-25 00:29:28 -08:00
KeyPoll.h Untabify every single file 2021-09-06 18:56:39 -07:00
Labclass.cpp Replace roomnames/hiddennames/glitchnames with const char* 2021-09-12 21:06:26 -07:00
Labclass.h Replace roomnames/hiddennames/glitchnames with const char* 2021-09-12 21:06:26 -07:00
Logic.cpp Remove game.door_left/right/up/down variables 2021-12-17 19:43:29 -08:00
Logic.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
main.cpp Explicitly zero declared struct ScreenSettingss 2021-12-25 00:30:10 -08:00
MakeAndPlay.h Use multiline comments in C files 2021-04-17 00:50:04 -04:00
Map.cpp Remove game.door_left/right/up/down variables 2021-12-17 19:43:29 -08:00
Map.h Remove vmult lookup tables 2021-09-24 16:37:27 -07:00
Maths.h Remove VVV_min/max in favor of SDL_min/max 2021-12-22 16:43:31 -08:00
Music.cpp Music: Do not do fades if not playing 2021-09-10 19:37:33 -07:00
Music.h Move Mix_PausedMusic() call into wrapper function 2021-09-10 19:37:31 -07:00
Network.c Axe NETWORK_[set/get]AchievementProgress() 2021-09-19 21:49:54 -07:00
Network.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
Otherlevel.cpp Fix elephant placement across rooms 2021-12-08 16:25:18 -08:00
Otherlevel.h Replace roomnames/hiddennames/glitchnames with const char* 2021-09-12 21:06:26 -07:00
preloader.cpp Axe RGBflip() in favor of getRGB() 2021-09-11 02:15:20 -07:00
preloader.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
Render.cpp Simplify time formatting functions 2021-12-25 11:38:12 -08:00
Render.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
RenderFixed.cpp Use resumegamemode to track menu animation 2021-09-05 16:59:05 -07:00
RenderFixed.h Remove now-unneeded deltaframe fix when going to in-game settings 2021-03-21 02:55:42 -04:00
Screen.cpp Use LoadImage in LoadIcon 2021-12-25 01:29:24 -08:00
Screen.h De-C++-ify struct ScreenSettings 2021-12-25 00:30:10 -08:00
ScreenSettings.h De-C++-ify struct ScreenSettings 2021-12-25 00:30:10 -08:00
Script.cpp hardreset: Reset ingame_titlemode 2021-12-17 23:39:26 -08:00
Script.h createentity command: Actually have p1/p2/p3/p4 defaults 2021-08-12 00:20:40 -04:00
Scripts.cpp Add message when player is kicked out of Super Gravitron 2021-09-03 12:08:31 -07:00
SoundSystem.cpp Untabify every single file 2021-09-06 18:56:39 -07:00
SoundSystem.h Untabify every single file 2021-09-06 18:56:39 -07:00
Spacestation2.cpp Replace roomnames/hiddennames/glitchnames with const char* 2021-09-12 21:06:26 -07:00
Spacestation2.h Replace roomnames/hiddennames/glitchnames with const char* 2021-09-12 21:06:26 -07:00
SteamNetwork.c Silence GCC warnings about void*-to-function-pointer casts 2021-10-21 01:00:06 -07:00
TempSDLFallthrough.h Use SDL_FALLTHROUGH if available 2021-11-11 23:48:41 -08:00
TerminalScripts.cpp Untabify every single file 2021-09-06 18:56:39 -07:00
Textbox.cpp Rename textbox to textboxes and textbox line to lines 2021-09-12 21:06:27 -07:00
Textbox.h Rename textbox to textboxes and textbox line to lines 2021-09-12 21:06:27 -07:00
ThirdPartyDeps.c Use multiline comments in C files 2021-04-17 00:50:04 -04:00
Tower.cpp Add POS_MOD macro and use for all positive modulos 2021-09-24 17:48:15 -07:00
Tower.h Remove vmult lookup tables 2021-09-24 16:37:27 -07:00
TowerBG.h Untabify every single file 2021-09-06 18:56:39 -07:00
Unused.h Factor out UNUSED macro to header file 2021-05-25 15:23:34 -04:00
UtilityClass.cpp Simplify time formatting functions 2021-12-25 11:38:12 -08:00
UtilityClass.h Simplify time formatting functions 2021-12-25 11:38:12 -08:00
Version.h Don't recompile all files when the commit hash is changed 2020-12-25 20:17:01 -05:00
Version.h.in Don't recompile all files when the commit hash is changed 2020-12-25 20:17:01 -05:00
Vlogging.c Mark all vlog functions with printf attributes 2021-09-27 20:49:09 -07:00
Vlogging.h Mark all vlog functions with printf attributes 2021-09-27 20:49:09 -07:00
WarpClass.cpp Replace roomnames/hiddennames/glitchnames with const char* 2021-09-12 21:06:26 -07:00
WarpClass.h Replace roomnames/hiddennames/glitchnames with const char* 2021-09-12 21:06:26 -07:00
XMLUtils.cpp Move all settings to settings.vvv 2020-11-04 12:06:57 -05:00
XMLUtils.h Move all settings to settings.vvv 2020-11-04 12:06:57 -05:00
Xoshiro.c Replace Gravitron RNG with seeded Xoshiro 2021-08-27 12:28:35 -07:00
Xoshiro.h Replace Gravitron RNG with seeded Xoshiro 2021-08-27 12:28:35 -07:00