fs2port/port/include/title.h
2026-05-13 21:32:05 -05:00

82 lines
2.4 KiB
C

// Pre-flight title / config screen.
//
// FS2's boot sequence prompts the user at runtime: first for display
// mode (color vs B&W via "WHAT DISPLAY ARE YOU USING? A or B"), then
// for game mode (demo vs regular flight). The scenery-disk versions
// add a city/region pick step. The port consolidates all of those
// pre-sim choices into one config menu plus the in-flight `F7` edit
// toggle.
#ifndef TITLE_H
#define TITLE_H
#include <stdbool.h>
#include <stdint.h>
#include <SDL.h>
#include "framebuffer.h"
#include "sceneryData.h"
#include "timeOfDay.h"
typedef enum TitleModeE {
TITLE_MODE_FREE_FLIGHT = 0,
TITLE_MODE_DEMO = 1,
TITLE_MODE_SLEW = 2,
TITLE_MODE_WW1_ACE = 3,
TITLE_MODE_COUNT
} TitleModeE;
typedef enum TitleDisplayE {
TITLE_DISPLAY_COLOR = 0,
TITLE_DISPLAY_BW = 1,
TITLE_DISPLAY_COUNT
} TitleDisplayE;
typedef enum TitleTimeOfDayE {
TITLE_TOD_DAY = 0,
TITLE_TOD_TWILIGHT = 1,
TITLE_TOD_NIGHT = 2,
TITLE_TOD_COUNT
} TitleTimeOfDayE;
// One row in the menu. Acts on `value` (a small uint with `optionCount`
// possible settings). The selected row's value can be cycled with
// left/right arrows; Enter on START commits and quits the menu.
typedef enum TitleRowE {
TITLE_ROW_MODE = 0,
TITLE_ROW_REGION,
TITLE_ROW_DISPLAY,
TITLE_ROW_TIME,
TITLE_ROW_REALITY,
TITLE_ROW_START,
TITLE_ROW_QUIT,
TITLE_ROW_COUNT
} TitleRowE;
typedef struct TitleStateT {
TitleRowE cursor; // current row
TitleModeE mode; // TITLE_ROW_MODE value
SceneryRegionE region; // TITLE_ROW_REGION value (= SCENERY_FS2_1..)
TitleDisplayE display; // TITLE_ROW_DISPLAY value
TitleTimeOfDayE timeOfDay; // TITLE_ROW_TIME value
bool realityMode; // TITLE_ROW_REALITY value
bool done; // user pressed START (= Enter on START row)
bool quit; // user picked QUIT
} TitleStateT;
void titleInit(TitleStateT *t);
// Process a single SDL key event. Returns true once `done` is set
// (the caller should then consume the selections and exit the title
// loop) or once `quit` is set.
bool titleHandleKey(TitleStateT *t, const SDL_Event *ev);
// Render the title screen into the framebuffer.
void titleDraw(const TitleStateT *t, FramebufferT *fb);
#endif