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

54 lines
1.8 KiB
C

// In-flight parameter editor (= FS2's edit mode). Lets the user
// modify any aircraft / world / radio parameter that FS2 itself could
// touch via its edit-mode key bindings.
//
// FS2 sets `EditModeFlag = 1` and pauses the integrator; keys then
// route to per-parameter handlers (chunk5 KeyDecrease / KeyIncrease /
// digit entry via InputMode). The port consolidates all editable
// fields into a single list-based UI: up/down picks a field, left/
// right adjusts the value, F7 commits and exits.
#ifndef EDITOR_H
#define EDITOR_H
#include <stdbool.h>
#include <stdint.h>
#include <SDL.h>
#include "aircraft.h"
#include "framebuffer.h"
#include "radios.h"
#include "timeOfDay.h"
#include "wind.h"
typedef struct EditorStateT {
int cursor; // selected field index
bool fastStep; // Shift held -> bigger step per key
} EditorStateT;
void editorInit(EditorStateT *e);
// Handle one SDL event while edit mode is active. Modifies the
// aircraft / radios / tod / wind state directly (= FS2 semantics:
// edits commit immediately, no separate snapshot/restore).
void editorHandleKey(EditorStateT *e,
const SDL_Event *ev,
AircraftT *ac,
RadiosT *radios,
TimeOfDayT *tod,
WindStateT *wind);
// Draw the editor overlay on top of the rendered frame. The overlay
// occupies the upper-left quadrant and lists every editable field
// with its current value; the highlighted row is the one arrow keys
// will modify.
void editorDraw(const EditorStateT *e,
FramebufferT *fb,
const AircraftT *ac,
const RadiosT *radios,
const TimeOfDayT *tod,
const WindStateT *wind);
#endif