struct Console
{
Lt *lt;
- Edit_field *edit_field;
+ Edit_field edit_field;
Console_Log *console_log;
History *history;
Game *game;
}
console->lt = lt;
- console->edit_field = PUSH_LT(
- lt,
- create_edit_field(
- vec(FONT_WIDTH_SCALE, FONT_HEIGHT_SCALE),
- CONSOLE_FOREGROUND),
- destroy_edit_field);
- if (console->edit_field == NULL) {
- RETURN_LT(lt, NULL);
- }
+ console->edit_field.font_size = vec(FONT_WIDTH_SCALE, FONT_HEIGHT_SCALE);
+ console->edit_field.font_color = CONSOLE_FOREGROUND;
console->console_log = PUSH_LT(
lt,
static int console_eval_input(Console *console)
{
- const char *input_text = edit_field_as_text(console->edit_field);
+ const char *input_text = edit_field_as_text(&console->edit_field);
String input = string_nt(input_text);
String command = chop_word(&input);
if (string_equal(command, STRING_LIT(""))) {
- edit_field_clean(console->edit_field);
+ edit_field_clean(&console->edit_field);
return 0;
}
console_log_push_line(console->console_log, "Unknown command", NULL, CONSOLE_ERROR);
}
- edit_field_clean(console->edit_field);
+ edit_field_clean(&console->edit_field);
return 0;
}
case SDLK_UP:
edit_field_replace(
- console->edit_field,
+ &console->edit_field,
history_current(console->history));
history_prev(console->history);
return 0;
case SDLK_p: {
if (event->key.keysym.mod & KMOD_CTRL) {
edit_field_replace(
- console->edit_field, history_current(console->history));
+ &console->edit_field,
+ history_current(console->history));
history_prev(console->history);
return 0;
}
case SDLK_DOWN:
edit_field_replace(
- console->edit_field,
+ &console->edit_field,
history_current(console->history));
history_next(console->history);
return 0;
case SDLK_n: {
if (event->key.keysym.mod & KMOD_CTRL) {
edit_field_replace(
- console->edit_field, history_current(console->history));
+ &console->edit_field, history_current(console->history));
history_next(console->history);
return 0;
}
} break;
}
- return edit_field_event(console->edit_field, event);
+ return edit_field_event(&console->edit_field, event);
}
int console_render(const Console *console,
camera,
vec(0.0f, y));
- if (edit_field_render_screen(console->edit_field,
+ if (edit_field_render_screen(&console->edit_field,
camera,
vec(0.0f, y + CONSOLE_LOG_HEIGHT)) < 0) {
return -1;