Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
ex_gui.c File Reference
#include "nilorea/n_gui.h"
#include "cJSON.h"
+ Include dependency graph for ex_gui.c:

Go to the source code of this file.

Macros

#define ALLEGRO_UNSTABLE   1
 
#define HAVE_CJSON   1
 
#define HEIGHT   900
 
#define NUM_WINDOWS   16
 
#define WIDTH   1280
 

Functions

int main (int argc, char *argv[])
 
void on_button_click (int widget_id, void *user_data)
 
void on_checkbox_toggle (int widget_id, int checked, void *user_data)
 
void on_combobox_select (int widget_id, int index, void *user_data)
 
void on_ghost_toggle (int widget_id, void *user_data)
 
void on_grid_toggle (int widget_id, void *user_data)
 
void on_height_toggle (int widget_id, void *user_data)
 
void on_link_click (int widget_id, const char *link, void *user_data)
 
void on_listbox_select (int widget_id, int index, int selected, void *user_data)
 
void on_login_click (int widget_id, void *user_data)
 
void on_player_toggle (int widget_id, void *user_data)
 
void on_proj_select (int widget_id, void *user_data)
 
void on_quit_click (int widget_id, void *user_data)
 
void on_radiolist_select (int widget_id, int index, void *user_data)
 
void on_scroll (int widget_id, double pos, void *user_data)
 
void on_slider_change (int widget_id, double value, void *user_data)
 
void on_smooth_toggle (int widget_id, void *user_data)
 
void on_text_change (int widget_id, const char *text, void *user_data)
 
void on_window_toggle_click (int widget_id, int entry_index, int tag, void *user_data)
 
void on_windows_menu_open (int widget_id, void *user_data)
 

Variables

static int current_proj = 0
 
ALLEGRO_DISPLAY * display = NULL
 
int DONE = 0
 
static int dropmenu_windows_id = -1
 
int getoptret = 0
 
static int ghost_enabled = 0
 
static int height_mode = 0
 
static int lbl_proj = -1
 
static int lbl_status = -1
 
int log_level = 3
 
static int player_mode = 0
 
static int proj_btn_ids [4] = {-1, -1, -1, -1}
 
static const char * proj_names [] = {"Classic 2:1", "True Isometric", "Military", "Staggered"}
 
static int show_grid = 0
 
static int smooth_height = 0
 
static char theme_file [512] = ""
 
static int win_ids [16]
 
static const char * win_names [16]
 

Macro Definition Documentation

◆ ALLEGRO_UNSTABLE

#define ALLEGRO_UNSTABLE   1

Definition at line 39 of file ex_gui.c.

◆ HAVE_CJSON

#define HAVE_CJSON   1

Definition at line 40 of file ex_gui.c.

◆ HEIGHT

◆ NUM_WINDOWS

#define NUM_WINDOWS   16
Examples
ex_gui.c.

Definition at line 71 of file ex_gui.c.

◆ WIDTH

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 220 of file ex_gui.c.

References current_proj, display, DONE, dropmenu_windows_id, fps_timer, getoptret, ghost_enabled, gui, N_GUI_CTX::gui_offset_x, N_GUI_CTX::gui_offset_y, N_GUI_CTX::gui_scale, HEIGHT, height_mode, lbl_proj, lbl_status, LOG_DEBUG, LOG_ERR, LOG_INFO, log_level, LOG_NOTICE, n_abort(), n_gui_add_button(), n_gui_add_checkbox(), n_gui_add_combobox(), n_gui_add_dropmenu(), n_gui_add_image(), n_gui_add_label(), n_gui_add_label_link(), n_gui_add_listbox(), n_gui_add_radiolist(), n_gui_add_scrollbar(), n_gui_add_slider(), n_gui_add_textarea(), n_gui_add_toggle_button(), n_gui_add_vslider(), n_gui_add_window(), n_gui_add_window_auto(), N_GUI_ALIGN_CENTER, N_GUI_ALIGN_JUSTIFIED, N_GUI_ALIGN_LEFT, N_GUI_ALIGN_RIGHT, N_GUI_AUTOFIT_CENTER, N_GUI_AUTOFIT_WH, n_gui_button_set_keycode(), n_gui_checkbox_set_bitmaps(), n_gui_combobox_add_item(), n_gui_combobox_set_selected(), n_gui_destroy_ctx(), n_gui_detect_dpi_scale(), n_gui_draw(), n_gui_dropmenu_add_entry(), N_GUI_IMAGE_CENTER, N_GUI_IMAGE_FIT, N_GUI_IMAGE_STRETCH, n_gui_label_set_bitmap(), n_gui_label_set_text(), n_gui_listbox_add_item(), n_gui_listbox_set_selected(), n_gui_load_theme_json(), n_gui_make_theme(), n_gui_new_ctx(), n_gui_process_event(), n_gui_radiolist_add_item(), n_gui_radiolist_set_selected(), N_GUI_RESIZE_ADAPTIVE, n_gui_screen_to_virtual(), N_GUI_SCROLLBAR_H, N_GUI_SCROLLBAR_V, N_GUI_SELECT_MULTIPLE, N_GUI_SELECT_SINGLE, n_gui_set_display(), n_gui_set_display_size(), n_gui_set_focus(), n_gui_set_resize_mode(), n_gui_set_virtual_size(), n_gui_set_widget_enabled(), n_gui_set_widget_theme(), n_gui_set_widget_visible(), N_GUI_SHAPE_RECT, N_GUI_SHAPE_ROUNDED, N_GUI_SLIDER_PERCENT, n_gui_slider_set_bitmaps(), N_GUI_SLIDER_VALUE, n_gui_textarea_set_text(), N_GUI_WIN_AUTO_SCROLLBAR, N_GUI_WIN_FIXED_POSITION, N_GUI_WIN_FRAMELESS, N_GUI_WIN_RESIZABLE, N_GUI_WIN_RESIZE_MOVE, N_GUI_WIN_RESIZE_NONE, N_GUI_WIN_RESIZE_SCALE, n_gui_window_apply_autofit(), n_gui_window_autosize(), n_gui_window_set_autofit(), n_gui_window_set_bitmaps(), n_gui_window_set_flags(), n_gui_window_set_resize_policy(), n_log, on_button_click(), on_checkbox_toggle(), on_combobox_select(), on_grid_toggle(), on_height_toggle(), on_link_click(), on_listbox_select(), on_login_click(), on_player_toggle(), on_proj_select(), on_quit_click(), on_radiolist_select(), on_scroll(), on_slider_change(), on_smooth_toggle(), on_text_change(), on_windows_menu_open(), player_mode, proj_btn_ids, proj_names, set_log_file(), set_log_level(), show_grid, smooth_height, theme_file, N_GUI_CTX::virtual_h, N_GUI_CTX::virtual_w, WIDTH, win_ids, and win_names.

+ Here is the call graph for this function:

◆ on_button_click()

void on_button_click ( int  widget_id,
void *  user_data 
)
Examples
ex_gui.c.

Definition at line 79 of file ex_gui.c.

References LOG_NOTICE, and n_log.

Referenced by main().

+ Here is the caller graph for this function:

◆ on_checkbox_toggle()

void on_checkbox_toggle ( int  widget_id,
int  checked,
void *  user_data 
)
Examples
ex_gui.c.

Definition at line 91 of file ex_gui.c.

References LOG_NOTICE, and n_log.

Referenced by main().

+ Here is the caller graph for this function:

◆ on_combobox_select()

void on_combobox_select ( int  widget_id,
int  index,
void *  user_data 
)
Examples
ex_gui.c.

Definition at line 134 of file ex_gui.c.

References LOG_NOTICE, and n_log.

Referenced by main().

+ Here is the caller graph for this function:

◆ on_ghost_toggle()

void on_ghost_toggle ( int  widget_id,
void *  user_data 
)
Examples
ex_gui.c, and ex_gui_isometric.c.

Definition at line 171 of file ex_gui.c.

References ghost_enabled, gui, LOG_NOTICE, n_gui_button_is_toggled(), and n_log.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ on_grid_toggle()

void on_grid_toggle ( int  widget_id,
void *  user_data 
)
Examples
ex_gui.c, and ex_gui_isometric.c.

Definition at line 159 of file ex_gui.c.

References gui, LOG_NOTICE, n_gui_button_is_toggled(), n_log, and show_grid.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ on_height_toggle()

void on_height_toggle ( int  widget_id,
void *  user_data 
)
Examples
ex_gui.c, and ex_gui_isometric.c.

Definition at line 153 of file ex_gui.c.

References gui, height_mode, LOG_NOTICE, n_gui_button_is_toggled(), and n_log.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ on_link_click()

void on_link_click ( int  widget_id,
const char *  link,
void *  user_data 
)
Examples
ex_gui.c.

Definition at line 140 of file ex_gui.c.

References LOG_NOTICE, and n_log.

Referenced by main(), and n_gui_add_label_link().

+ Here is the caller graph for this function:

◆ on_listbox_select()

void on_listbox_select ( int  widget_id,
int  index,
int  selected,
void *  user_data 
)
Examples
ex_gui.c.

Definition at line 122 of file ex_gui.c.

References LOG_NOTICE, and n_log.

Referenced by main().

+ Here is the caller graph for this function:

◆ on_login_click()

void on_login_click ( int  widget_id,
void *  user_data 
)
Examples
ex_gui.c.

Definition at line 116 of file ex_gui.c.

References LOG_NOTICE, and n_log.

Referenced by main().

+ Here is the caller graph for this function:

◆ on_player_toggle()

void on_player_toggle ( int  widget_id,
void *  user_data 
)
Examples
ex_gui.c, and ex_gui_isometric.c.

Definition at line 147 of file ex_gui.c.

References gui, LOG_NOTICE, n_gui_button_is_toggled(), n_log, and player_mode.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ on_proj_select()

void on_proj_select ( int  widget_id,
void *  user_data 
)
Examples
ex_gui.c, and ex_gui_isometric.c.

Definition at line 178 of file ex_gui.c.

References current_proj, gui, LOG_NOTICE, n_gui_button_set_toggled(), n_log, proj_btn_ids, and proj_names.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ on_quit_click()

void on_quit_click ( int  widget_id,
void *  user_data 
)
Examples
ex_gui.c.

Definition at line 109 of file ex_gui.c.

References done.

Referenced by main().

+ Here is the caller graph for this function:

◆ on_radiolist_select()

void on_radiolist_select ( int  widget_id,
int  index,
void *  user_data 
)
Examples
ex_gui.c.

Definition at line 128 of file ex_gui.c.

References LOG_NOTICE, and n_log.

Referenced by main().

+ Here is the caller graph for this function:

◆ on_scroll()

void on_scroll ( int  widget_id,
double  pos,
void *  user_data 
)
Examples
ex_gui.c.

Definition at line 103 of file ex_gui.c.

References LOG_NOTICE, and n_log.

Referenced by main(), and n_gui_add_scrollbar().

+ Here is the caller graph for this function:

◆ on_slider_change()

void on_slider_change ( int  widget_id,
double  value,
void *  user_data 
)
Examples
ex_gui.c.

Definition at line 85 of file ex_gui.c.

References LOG_NOTICE, and n_log.

Referenced by main().

+ Here is the caller graph for this function:

◆ on_smooth_toggle()

void on_smooth_toggle ( int  widget_id,
void *  user_data 
)
Examples
ex_gui.c, and ex_gui_isometric.c.

Definition at line 165 of file ex_gui.c.

References gui, LOG_NOTICE, n_gui_button_is_toggled(), n_log, and smooth_height.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ on_text_change()

void on_text_change ( int  widget_id,
const char *  text,
void *  user_data 
)
Examples
ex_gui.c.

Definition at line 97 of file ex_gui.c.

References LOG_NOTICE, and n_log.

Referenced by main().

+ Here is the caller graph for this function:

◆ on_window_toggle_click()

void on_window_toggle_click ( int  widget_id,
int  entry_index,
int  tag,
void *  user_data 
)
Examples
ex_gui.c.

Definition at line 194 of file ex_gui.c.

References gui, LOG_NOTICE, n_gui_toggle_window(), and n_log.

Referenced by on_windows_menu_open().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ on_windows_menu_open()

void on_windows_menu_open ( int  widget_id,
void *  user_data 
)
Examples
ex_gui.c.

Definition at line 203 of file ex_gui.c.

References gui, n_gui_dropmenu_add_dynamic_entry(), n_gui_dropmenu_clear_dynamic(), N_GUI_ID_MAX, n_gui_window_is_open(), NUM_WINDOWS, on_window_toggle_click(), win_ids, and win_names.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ current_proj

int current_proj = 0
static
Examples
ex_gui.c, and ex_gui_isometric.c.

Definition at line 59 of file ex_gui.c.

Referenced by main(), on_proj_select(), and on_proj_select().

◆ display

ALLEGRO_DISPLAY* display = NULL

Definition at line 45 of file ex_gui.c.

◆ DONE

int DONE = 0

Definition at line 47 of file ex_gui.c.

◆ dropmenu_windows_id

int dropmenu_windows_id = -1
static
Examples
ex_gui.c.

Definition at line 76 of file ex_gui.c.

Referenced by main().

◆ getoptret

int getoptret = 0

Definition at line 48 of file ex_gui.c.

◆ ghost_enabled

int ghost_enabled = 0
static
Examples
ex_gui.c, and ex_gui_isometric.c.

Definition at line 58 of file ex_gui.c.

Referenced by main(), on_ghost_toggle(), and on_ghost_toggle().

◆ height_mode

int height_mode = 0
static
Examples
ex_gui.c, and ex_gui_isometric.c.

Definition at line 55 of file ex_gui.c.

Referenced by main(), on_height_toggle(), on_height_toggle(), and on_player_toggle().

◆ lbl_proj

int lbl_proj = -1
static
Examples
ex_gui.c.

Definition at line 65 of file ex_gui.c.

Referenced by main().

◆ lbl_status

int lbl_status = -1
static
Examples
ex_gui.c, and ex_gui_network.c.

Definition at line 64 of file ex_gui.c.

Referenced by main(), and main().

◆ log_level

int log_level = 3

Definition at line 49 of file ex_gui.c.

◆ player_mode

int player_mode = 0
static
Examples
ex_gui.c, and ex_gui_isometric.c.

Definition at line 54 of file ex_gui.c.

Referenced by iso_map_draw(), main(), on_height_toggle(), on_player_toggle(), and on_player_toggle().

◆ proj_btn_ids

int proj_btn_ids[4] = {-1, -1, -1, -1}
static
Examples
ex_gui.c.

Definition at line 68 of file ex_gui.c.

Referenced by main(), and on_proj_select().

◆ proj_names

const char* proj_names[] = {"Classic 2:1", "True Isometric", "Military", "Staggered"}
static
Examples
ex_gui.c.

Definition at line 61 of file ex_gui.c.

Referenced by main(), and on_proj_select().

◆ show_grid

int show_grid = 0
static
Examples
ex_gui.c, and ex_gui_isometric.c.

Definition at line 56 of file ex_gui.c.

Referenced by main(), on_grid_toggle(), and on_grid_toggle().

◆ smooth_height

int smooth_height = 0
static
Examples
ex_gui.c, and ex_gui_isometric.c.

Definition at line 57 of file ex_gui.c.

Referenced by interpolate_height_at_clamped(), main(), on_smooth_toggle(), and on_smooth_toggle().

◆ theme_file

char theme_file[512] = ""
static
Examples
ex_gui.c.

Definition at line 51 of file ex_gui.c.

Referenced by main().

◆ win_ids

int win_ids[16]
static
Examples
ex_gui.c.

Definition at line 72 of file ex_gui.c.

Referenced by main(), and on_windows_menu_open().

◆ win_names

const char* win_names[16]
static
Examples
ex_gui.c.

Definition at line 73 of file ex_gui.c.

Referenced by main(), and on_windows_menu_open().