Skip to content

Commit

Permalink
WIP menu refactor; implement displaying options, controls and keys
Browse files Browse the repository at this point in the history
  • Loading branch information
cxong committed Feb 26, 2013
1 parent 685d309 commit 69b4a3c
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/include/text.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
50 changes: 47 additions & 3 deletions src/mainmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
{
Expand All @@ -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;
Expand Down
15 changes: 14 additions & 1 deletion src/text.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
*/
#include "text.h"

#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "grafx.h"
#include "blit.h"
#include "actors.h" /* for tableFlamed */
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 69b4a3c

Please sign in to comment.