From 69b4a3c7d0d62de0939869e7ab3412ca8acdf688 Mon Sep 17 00:00:00 2001 From: Cong Date: Tue, 26 Feb 2013 22:20:57 +1100 Subject: [PATCH] WIP menu refactor; implement displaying options, controls and keys --- src/include/text.h | 1 + src/mainmenu.c | 50 +++++++++++++++++++++++++++++++++++++++++++--- src/text.c | 15 +++++++++++++- 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/src/include/text.h b/src/include/text.h index ba1f8b881..9ba4ef01c 100644 --- a/src/include/text.h +++ b/src/include/text.h @@ -27,6 +27,7 @@ void CDogsTextString(const char *s); void CDogsTextGoto(int x, int y); void CDogsTextStringAt(int x, int y, const char *s); void CDogsTextIntAt(int x, int y, int i); +void CDogsTextFormatAt(int x, int y, const char *fmt, ...); int CDogsTextCharWidth(int c); int CDogsTextWidth(const char *s); int CDogsTextHeight(void); diff --git a/src/mainmenu.c b/src/mainmenu.c index 08282c4e5..e70260413 100644 --- a/src/mainmenu.c +++ b/src/mainmenu.c @@ -1544,10 +1544,54 @@ void MenuDisplaySubmenus(menu_t *menu, int isCentered) assert(0); break; case MENU_OPTION_TYPE_OPTIONS: - assert(0); + { + int y = yStart; + x += maxWidth + 10; + + CDogsTextStringAt(x, y, gOptions.playersHurt ? "Yes" : "No"); + y += CDogsTextHeight(); + CDogsTextStringAt(x, y, gOptions.displayFPS ? "On" : "Off"); + y += CDogsTextHeight(); + CDogsTextStringAt(x, y, gOptions.displayTime ? "On" : "Off"); + y += CDogsTextHeight(); + CDogsTextIntAt(x, y, gOptions.brightness); + y += CDogsTextHeight(); + CDogsTextStringAt(x, y, gOptions.splitScreenAlways ? "Yes" : "No"); + y += CDogsTextHeight(); + CDogsTextFormatAt(x, y, "%u", gCampaign.seed); + + y += CDogsTextHeight(); + CDogsTextStringAt(x, y, DifficultyStr(gOptions.difficulty)); + y += CDogsTextHeight(); + CDogsTextStringAt(x, y, gOptions.slowmotion ? "Yes" : "No"); + y += CDogsTextHeight(); + CDogsTextFormatAt(x, y, "%u%%", gOptions.density); + y += CDogsTextHeight(); + CDogsTextFormatAt(x, y, "%u%%", gOptions.npcHp); + y += CDogsTextHeight(); + CDogsTextFormatAt(x, y, "%u%%", gOptions.playerHp); + y += CDogsTextHeight(); + CDogsTextStringAt(x, y, Gfx_GetHint(HINT_FULLSCREEN) ? "Yes" : "No"); + y += CDogsTextHeight(); + CDogsTextFormatAt( + x, y, "%dx%d", Gfx_GetHint(HINT_WIDTH), Gfx_GetHint(HINT_HEIGHT)); + y += CDogsTextHeight(); + CDogsTextFormatAt(x, y, "%dx", GrafxGetScale()); + } break; case MENU_OPTION_TYPE_CONTROLS: - assert(0); + { + int y = yStart; + x += maxWidth + 10; + + CDogsTextStringAt(x, y, InputDeviceStr(gPlayer1Data.inputDevice)); + y += CDogsTextHeight(); + CDogsTextStringAt(x, y, InputDeviceStr(gPlayer2Data.inputDevice)); + y += CDogsTextHeight(); + CDogsTextStringAt(x, y, gOptions.swapButtonsJoy1 ? "Yes" : "No"); + y += CDogsTextHeight(); + CDogsTextStringAt(x, y, gOptions.swapButtonsJoy2 ? "Yes" : "No"); + } break; case MENU_OPTION_TYPE_SOUND: { @@ -1562,7 +1606,7 @@ void MenuDisplaySubmenus(menu_t *menu, int isCentered) } break; case MENU_OPTION_TYPE_KEYS: - assert(0); + ShowAllKeys(menu->u.normal.index, -1); break; default: break; diff --git a/src/text.c b/src/text.c index 3504c40e5..1a34ead60 100644 --- a/src/text.c +++ b/src/text.c @@ -21,9 +21,11 @@ */ #include "text.h" -#include +#include #include #include +#include + #include "grafx.h" #include "blit.h" #include "actors.h" /* for tableFlamed */ @@ -119,6 +121,17 @@ void CDogsTextIntAt(int x, int y, int i) CDogsTextString(s); } +void CDogsTextFormatAt(int x, int y, const char *fmt, ...) +{ + char s[256]; + va_list argptr; + va_start(argptr, fmt); + sprintf(s, fmt, argptr); + va_end(argptr); + CDogsTextGoto(x, y); + CDogsTextString(s); +} + void CDogsTextStringWithTableAt(int x, int y, const char *s, TranslationTable * table) {