76 lines
1.8 KiB
C
76 lines
1.8 KiB
C
#include <stdbool.h>
|
|
#include <stdlib.h>
|
|
|
|
#include <ncurses.h>
|
|
#include <form.h>
|
|
|
|
#include <l3tde/game/map_editor.h>
|
|
#include <l3tde/game/map_editor/main_menu.h>
|
|
#include <l3tde/game/map_editor/creation_form.h>
|
|
#include <l3tde/game/map_editor/editor.h>
|
|
|
|
static void
|
|
map_editor_render (MapEditorStatus *status);
|
|
static void
|
|
map_editor_handle_input (MapEditorStatus *status);
|
|
|
|
void
|
|
map_editor_init () {
|
|
initscr ();
|
|
start_color ();
|
|
curs_set (0);
|
|
raw ();
|
|
keypad (stdscr, TRUE);
|
|
noecho ();
|
|
}
|
|
|
|
void
|
|
map_editor_loop () {
|
|
MapEditorStatus *status = malloc (sizeof *status);
|
|
status->selected_option = 0;
|
|
status->exit = false;
|
|
status->current_form = SELECT_MAP;
|
|
status->form_creation = NULL;
|
|
status->fields = NULL;
|
|
status->game = NULL;
|
|
while (1) {
|
|
map_editor_render (status);
|
|
map_editor_handle_input (status);
|
|
if (status->exit) break;
|
|
}
|
|
endwin ();
|
|
}
|
|
|
|
static void
|
|
map_editor_handle_input (MapEditorStatus *status) {
|
|
switch (status->current_form) {
|
|
case SELECT_MAP:
|
|
map_editor_main_menu_handle_input (status);
|
|
break;
|
|
case MAP_EDITOR:
|
|
map_editor_editor_handle_input (status);
|
|
break;
|
|
case MAP_CREATION_FORM:
|
|
map_editor_creation_form_handle_input (status);
|
|
break;
|
|
default:
|
|
fprintf (stderr, "Unable to handle input creation form\n");
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
map_editor_render (MapEditorStatus *status) {
|
|
if (status->current_form == SELECT_MAP) {
|
|
map_editor_main_menu_render (status);
|
|
}
|
|
if (status->current_form == MAP_CREATION_FORM) {
|
|
map_editor_creation_form_render (status);
|
|
}
|
|
if (status->current_form == MAP_EDITOR) {
|
|
map_editor_editor_render (status);
|
|
}
|
|
}
|