A 3d fps game made in OpenGL
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
Symmetry/src/game/console.h

56 lines
1.6 KiB

#ifndef CONSOLE_H
#define CONSOLE_H
#include "../common/hashmap.h"
#include "../common/limits.h"
#include <stdbool.h>
#include <stdarg.h>
struct Gui;
struct Console;
typedef void(*Console_Command_Handler)(struct Console* console, const char* command_text);
enum Console_Message_Type
{
CMT_NONE = 0,
CMT_MESSAGE,
CMT_WARNING,
CMT_ERROR,
CMT_COMMAND,
CMT_MAX
};
struct Console_Message
{
int type;
char message[MAX_CONSOLE_MESSAGE_LEN];
};
struct Console
{
bool visible;
bool scroll_to_bottom;
float text_region_height;
float line_height;
int current_message_index;
int current_history_index;
int current_history_browse_index;
char command_history[MAX_CONSOLE_HISTORY][MAX_CONSOLE_MESSAGE_LEN];
char command_text[MAX_CONSOLE_MESSAGE_LEN];
struct Console_Message messages[MAX_CONSOLE_MESSAGES];
struct Hashmap* commands;
};
void console_init(struct Console* console);
void console_toggle(struct Console* console);
void console_update(struct Console* console, struct Gui* gui_state, float dt);
void console_destroy(struct Console* console);
void console_on_log_message(struct Console* console, const char* message, va_list args);
void console_on_log_warning(struct Console* console, const char* warning_message, va_list args);
void console_on_log_error(struct Console* console, const char* context, const char* error, va_list args);
#endif