- Fixed console bug when toggled in editor mode and restored previous functionality

- Updated nuklear to version 4.00.2
- Fixed other formating mistakes
dev
Shariq Shah 7 years ago
parent 7339ad6834
commit 6980186a4b
  1. 10
      README.md
  2. 24355
      include/common/nuklear.h
  3. 33
      src/libsymmetry/console.c
  4. 29
      src/libsymmetry/editor.c
  5. 214
      src/libsymmetry/game.c
  6. 5
      todo.txt

@ -42,6 +42,13 @@ This will generate a visual studio 2017 solution in the *build/vs2017* folder wh
make all make all
``` ```
This will build the debug configuration by default and it's output will be in *build/gmake/debug* folder. You can then run the game by,
```bash
cd debug
./Symmetry
```
## License ## License
All the code in this repository is under GPLv3, see LICENSE for more information All the code in this repository is under GPLv3, see LICENSE for more information
@ -127,6 +134,9 @@ All the code in this repository is under GPLv3, see LICENSE for more information
variant value like, health or ammo etc. But, how to save/load all of that? variant value like, health or ammo etc. But, how to save/load all of that?
- ### Materials - ### Materials
*TODO* *TODO*
- ### Mesh/Geometry - ### Mesh/Geometry
*TODO* *TODO*

File diff suppressed because it is too large Load Diff

@ -69,7 +69,6 @@ void console_update(struct Console* console, struct Gui_State* gui_state, float
*context->current->layout->offset_y = (nk_uint)context->current->layout->at_y; *context->current->layout->offset_y = (nk_uint)context->current->layout->at_y;
console->scroll_to_bottom = false; console->scroll_to_bottom = false;
} }
nk_group_end(context); nk_group_end(context);
} }
@ -108,28 +107,28 @@ int console_filter(const struct nk_text_edit *box, nk_rune unicode)
void console_on_log_message(struct Console* console, const char* message, va_list args) void console_on_log_message(struct Console* console, const char* message, va_list args)
{ {
/* if(++console->current_message_index >= MAX_CONSOLE_MESSAGES) */ if(++console->current_message_index >= MAX_CONSOLE_MESSAGES)
/* console->current_message_index = 0; */ console->current_message_index = 0;
/* vsnprintf(console->console_messages[console->current_message_index].message, MAX_CONSOLE_MESSAGE_LEN, message, args); */ vsnprintf(console->console_messages[console->current_message_index].message, MAX_CONSOLE_MESSAGE_LEN, message, args);
/* console->console_messages[console->current_message_index].type = CMT_MESSAGE; */ console->console_messages[console->current_message_index].type = CMT_MESSAGE;
/* console->scroll_to_bottom = true; */ console->scroll_to_bottom = true;
} }
void console_on_log_warning(struct Console* console, const char* warning_message, va_list args) void console_on_log_warning(struct Console* console, const char* warning_message, va_list args)
{ {
/* if(++console->current_message_index >= MAX_CONSOLE_MESSAGES) */ if(++console->current_message_index >= MAX_CONSOLE_MESSAGES)
/* console->current_message_index = 0; */ console->current_message_index = 0;
/* vsnprintf(console->console_messages[console->current_message_index].message, MAX_CONSOLE_MESSAGE_LEN, warning_message, args); */ vsnprintf(console->console_messages[console->current_message_index].message, MAX_CONSOLE_MESSAGE_LEN, warning_message, args);
/* console->console_messages[console->current_message_index].type = CMT_WARNING; */ console->console_messages[console->current_message_index].type = CMT_WARNING;
/* console->scroll_to_bottom = true; */ console->scroll_to_bottom = true;
} }
void console_on_log_error(struct Console* console, const char* context, const char* error, va_list args) void console_on_log_error(struct Console* console, const char* context, const char* error, va_list args)
{ {
/* if(++console->current_message_index >= MAX_CONSOLE_MESSAGES) */ if(++console->current_message_index >= MAX_CONSOLE_MESSAGES)
/* console->current_message_index = 0; */ console->current_message_index = 0;
/* int loc = snprintf(console->console_messages[console->current_message_index].message, MAX_CONSOLE_MESSAGE_LEN, "(%s)", context); */ int loc = snprintf(console->console_messages[console->current_message_index].message, MAX_CONSOLE_MESSAGE_LEN, "(%s)", context);
/* vsnprintf(console->console_messages[console->current_message_index].message + loc, MAX_CONSOLE_MESSAGE_LEN - loc, error, args); */ vsnprintf(console->console_messages[console->current_message_index].message + loc, MAX_CONSOLE_MESSAGE_LEN - loc, error, args);
/* console->console_messages[console->current_message_index].type = CMT_ERROR; */ console->console_messages[console->current_message_index].type = CMT_ERROR;
/* console->scroll_to_bottom = true; */ console->scroll_to_bottom = true;
} }

@ -199,6 +199,7 @@ void editor_update(float dt)
if(nk_begin(context, "Editor", nk_recti(0, 0, win_width, win_height), NK_WINDOW_NO_SCROLLBAR | NK_WINDOW_BACKGROUND)) if(nk_begin(context, "Editor", nk_recti(0, 0, win_width, win_height), NK_WINDOW_NO_SCROLLBAR | NK_WINDOW_BACKGROUND))
{ {
context->style.window.fixed_background = default_background; context->style.window.fixed_background = default_background;
/* Top Panel */ /* Top Panel */
nk_layout_row_dynamic(context, editor_state.top_panel_height + 10.f, 1); nk_layout_row_dynamic(context, editor_state.top_panel_height + 10.f, 1);
nk_group_begin(context, "Menubar", NK_WINDOW_NO_SCROLLBAR); nk_group_begin(context, "Menubar", NK_WINDOW_NO_SCROLLBAR);
@ -220,11 +221,11 @@ void editor_update(float dt)
if(nk_button_label(context, "Render Settings")) if(nk_button_label(context, "Render Settings"))
editor_state.renderer_settings_window = !editor_state.renderer_settings_window; editor_state.renderer_settings_window = !editor_state.renderer_settings_window;
if(nk_button_label(context, "Save config")) if(nk_button_label(context, "Save config"))
platform->config.save("config.cfg", DIRT_USER); platform->config.save("config.symtres", DIRT_USER);
nk_spacing(context, 1); nk_spacing(context, 1);
nk_labelf(context, NK_TEXT_ALIGN_RIGHT | NK_TEXT_ALIGN_MIDDLE, "FPS : %.d", fps); nk_labelf(context, NK_TEXT_ALIGN_RIGHT | NK_TEXT_ALIGN_MIDDLE, "FPS : %.d", fps);
nk_group_end(context);
} }
nk_group_end(context);
static float main_editor_ratios[] = { 0.2f, 0.6f, 0.2f }; static float main_editor_ratios[] = { 0.2f, 0.6f, 0.2f };
nk_layout_row(context, NK_DYNAMIC, win_height - editor_state.top_panel_height, sizeof(main_editor_ratios) / sizeof(float), main_editor_ratios); nk_layout_row(context, NK_DYNAMIC, win_height - editor_state.top_panel_height, sizeof(main_editor_ratios) / sizeof(float), main_editor_ratios);
@ -301,7 +302,7 @@ void editor_update(float dt)
nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Position", NK_TEXT_ALIGN_CENTERED); nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Position", NK_TEXT_ALIGN_CENTERED);
vec3 abs_pos = { 0.f, 0.f, 0.f }; vec3 abs_pos = { 0.f, 0.f, 0.f };
transform_get_absolute_position(entity, &abs_pos); transform_get_absolute_position(entity, &abs_pos);
if(editor_widget_v3(context, &abs_pos, "Px", "Py", "Pz", -FLT_MAX, FLT_MAX, 5.f, 1.f, row_height)) transform_set_position(entity, &abs_pos); if(editor_widget_v3(context, &abs_pos, "#X", "#Y", "#Z", -FLT_MAX, FLT_MAX, 5.f, 1.f, row_height)) transform_set_position(entity, &abs_pos);
nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Rotation", NK_TEXT_ALIGN_CENTERED); nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Rotation", NK_TEXT_ALIGN_CENTERED);
quat abs_rot = { 0.f, 0.f, 0.f, 1.f }; quat abs_rot = { 0.f, 0.f, 0.f, 1.f };
@ -312,9 +313,9 @@ void editor_update(float dt)
rot_angles.z = TO_DEGREES(quat_get_roll(&abs_rot)); rot_angles.z = TO_DEGREES(quat_get_roll(&abs_rot));
vec3 curr_rot = { rot_angles.x, rot_angles.y, rot_angles.z }; vec3 curr_rot = { rot_angles.x, rot_angles.y, rot_angles.z };
nk_layout_row_dynamic(context, row_height, 1); nk_property_float(context, "Rx", -FLT_MAX, &curr_rot.x, FLT_MAX, 5.f, 1.f); nk_layout_row_dynamic(context, row_height, 1); nk_property_float(context, "#X", -FLT_MAX, &curr_rot.x, FLT_MAX, 5.f, 1.f);
nk_layout_row_dynamic(context, row_height, 1); nk_property_float(context, "Ry", -FLT_MAX, &curr_rot.y, FLT_MAX, 5.f, 1.f); nk_layout_row_dynamic(context, row_height, 1); nk_property_float(context, "#Y", -FLT_MAX, &curr_rot.y, FLT_MAX, 5.f, 1.f);
nk_layout_row_dynamic(context, row_height, 1); nk_property_float(context, "Rz", -FLT_MAX, &curr_rot.z, FLT_MAX, 5.f, 1.f); nk_layout_row_dynamic(context, row_height, 1); nk_property_float(context, "#Z", -FLT_MAX, &curr_rot.z, FLT_MAX, 5.f, 1.f);
vec3 delta = { 0.f, 0.f, 0.f }; vec3 delta = { 0.f, 0.f, 0.f };
vec3_sub(&delta, &rot_angles, &curr_rot); vec3_sub(&delta, &rot_angles, &curr_rot);
@ -331,7 +332,7 @@ void editor_update(float dt)
nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Scale", NK_TEXT_ALIGN_CENTERED); nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Scale", NK_TEXT_ALIGN_CENTERED);
vec3 abs_scale = { 0.f, 0.f, 0.f }; vec3 abs_scale = { 0.f, 0.f, 0.f };
transform_get_absolute_scale(entity, &abs_scale); transform_get_absolute_scale(entity, &abs_scale);
if(editor_widget_v3(context, &abs_scale, "SX", "SY", "SZ", 0.1f, FLT_MAX, 1.f, 0.1f, row_height)) if(editor_widget_v3(context, &abs_scale, "#X", "#Y", "#Z", 0.1f, FLT_MAX, 1.f, 0.1f, row_height))
{ {
entity->transform.scale = abs_scale; entity->transform.scale = abs_scale;
transform_update_transmat(entity); transform_update_transmat(entity);
@ -550,12 +551,12 @@ void editor_update(float dt)
void editor_camera_update(float dt) void editor_camera_update(float dt)
{ {
struct Camera* editor_camera = &game_state_get()->scene->cameras[CAM_EDITOR]; struct Camera* editor_camera = &game_state_get()->scene->cameras[CAM_EDITOR];
static float total_up_down_rot = 0.f;
float move_speed = editor_state.camera_move_speed, turn_speed = editor_state.camera_turn_speed; float move_speed = editor_state.camera_move_speed, turn_speed = editor_state.camera_turn_speed;
vec3 offset = {0, 0, 0};
float turn_up_down = 0.f; float turn_up_down = 0.f;
float turn_left_right = 0.f; float turn_left_right = 0.f;
float max_up_down = 60.f; float max_up_down = 60.f;
static float total_up_down_rot = 0.f; vec3 offset = { 0, 0, 0 };
vec3 rot_axis_up_down = { 1, 0, 0 }; vec3 rot_axis_up_down = { 1, 0, 0 };
vec3 rot_axis_left_right = { 0, 1, 0 }; vec3 rot_axis_left_right = { 0, 1, 0 };
@ -668,7 +669,10 @@ void editor_widget_color_combov3(struct nk_context* context, vec3* color, int wi
col_mode = nk_option_label(context, "RGB", col_mode == COL_RGB) ? COL_RGB : col_mode; col_mode = nk_option_label(context, "RGB", col_mode == COL_RGB) ? COL_RGB : col_mode;
col_mode = nk_option_label(context, "HSV", col_mode == COL_HSV) ? COL_HSV : col_mode; col_mode = nk_option_label(context, "HSV", col_mode == COL_HSV) ? COL_HSV : col_mode;
nk_layout_row_dynamic(context, 120, 1); nk_layout_row_dynamic(context, 120, 1);
temp_color = nk_color_picker(context, temp_color, NK_RGB); struct nk_colorf temp_colorf = nk_color_cf(temp_color);
temp_colorf = nk_color_picker(context, temp_colorf, NK_RGB);
temp_color = nk_rgba_cf(temp_colorf);
nk_layout_row_dynamic(context, 25, 1); nk_layout_row_dynamic(context, 25, 1);
if(col_mode == COL_RGB) if(col_mode == COL_RGB)
{ {
@ -702,7 +706,10 @@ void editor_widget_color_combov4(struct nk_context* context, vec4* color, int wi
col_mode = nk_option_label(context, "RGB", col_mode == COL_RGB) ? COL_RGB : col_mode; col_mode = nk_option_label(context, "RGB", col_mode == COL_RGB) ? COL_RGB : col_mode;
col_mode = nk_option_label(context, "HSV", col_mode == COL_HSV) ? COL_HSV : col_mode; col_mode = nk_option_label(context, "HSV", col_mode == COL_HSV) ? COL_HSV : col_mode;
nk_layout_row_dynamic(context, 120, 1); nk_layout_row_dynamic(context, 120, 1);
temp_color = nk_color_picker(context, temp_color, NK_RGBA); struct nk_colorf temp_colorf = nk_color_cf(temp_color);
temp_colorf = nk_color_picker(context, temp_colorf, NK_RGBA);
temp_color = nk_rgba_cf(temp_colorf);
nk_layout_row_dynamic(context, 25, 1); nk_layout_row_dynamic(context, 25, 1);
if(col_mode == COL_RGB) if(col_mode == COL_RGB)
{ {

@ -540,7 +540,7 @@ void game_update(float dt, bool* window_should_close)
} }
//game_debug(dt); //game_debug(dt);
//debug_gui(dt); //game_debug_gui(dt);
console_update(game_state->console, gui_state_get(), dt); console_update(game_state->console, gui_state_get(), dt);
scene_update(game_state->scene, dt); scene_update(game_state->scene, dt);
if(game_state->game_mode == GAME_MODE_GAME) if(game_state->game_mode == GAME_MODE_GAME)
@ -590,7 +590,7 @@ void game_debug_gui(float dt)
if(scale_left) window_flags |= NK_WINDOW_SCALE_LEFT; if(scale_left) window_flags |= NK_WINDOW_SCALE_LEFT;
if(minimizable) window_flags |= NK_WINDOW_MINIMIZABLE; if(minimizable) window_flags |= NK_WINDOW_MINIMIZABLE;
if (nk_begin(ctx, "Overview", nk_rect(70, 70, 400, 600), window_flags)) if(nk_begin(ctx, "Overview", nk_rect(10, 10, 400, 600), window_flags))
{ {
if(show_menu) if(show_menu)
{ {
@ -599,11 +599,12 @@ void game_debug_gui(float dt)
static nk_size mprog = 60; static nk_size mprog = 60;
static int mslider = 10; static int mslider = 10;
static int mcheck = nk_true; static int mcheck = nk_true;
nk_menubar_begin(ctx); nk_menubar_begin(ctx);
nk_layout_row_begin(ctx, NK_STATIC, 25, 4);
/* menu #1 */
nk_layout_row_begin(ctx, NK_STATIC, 25, 5);
nk_layout_row_push(ctx, 45); nk_layout_row_push(ctx, 45);
if (nk_menu_begin_label(ctx, "Menu", NK_TEXT_LEFT, nk_vec2(120, 200))) if(nk_menu_begin_label(ctx, "MENU", NK_TEXT_LEFT, nk_vec2(120, 200)))
{ {
static size_t prog = 40; static size_t prog = 40;
static int slider = 10; static int slider = 10;
@ -618,6 +619,63 @@ void game_debug_gui(float dt)
nk_checkbox_label(ctx, "check", &check); nk_checkbox_label(ctx, "check", &check);
nk_menu_end(ctx); nk_menu_end(ctx);
} }
/* menu #2 */
nk_layout_row_push(ctx, 60);
if(nk_menu_begin_label(ctx, "ADVANCED", NK_TEXT_LEFT, nk_vec2(200, 600)))
{
enum menu_state { MENU_NONE, MENU_FILE, MENU_EDIT, MENU_VIEW, MENU_CHART };
static enum menu_state menu_state = MENU_NONE;
enum nk_collapse_states state;
state = (menu_state == MENU_FILE) ? NK_MAXIMIZED : NK_MINIMIZED;
if(nk_tree_state_push(ctx, NK_TREE_TAB, "FILE", &state)) {
menu_state = MENU_FILE;
nk_menu_item_label(ctx, "New", NK_TEXT_LEFT);
nk_menu_item_label(ctx, "Open", NK_TEXT_LEFT);
nk_menu_item_label(ctx, "Save", NK_TEXT_LEFT);
nk_menu_item_label(ctx, "Close", NK_TEXT_LEFT);
nk_menu_item_label(ctx, "Exit", NK_TEXT_LEFT);
nk_tree_pop(ctx);
}
else menu_state = (menu_state == MENU_FILE) ? MENU_NONE : menu_state;
state = (menu_state == MENU_EDIT) ? NK_MAXIMIZED : NK_MINIMIZED;
if(nk_tree_state_push(ctx, NK_TREE_TAB, "EDIT", &state)) {
menu_state = MENU_EDIT;
nk_menu_item_label(ctx, "Copy", NK_TEXT_LEFT);
nk_menu_item_label(ctx, "Delete", NK_TEXT_LEFT);
nk_menu_item_label(ctx, "Cut", NK_TEXT_LEFT);
nk_menu_item_label(ctx, "Paste", NK_TEXT_LEFT);
nk_tree_pop(ctx);
}
else menu_state = (menu_state == MENU_EDIT) ? MENU_NONE : menu_state;
state = (menu_state == MENU_VIEW) ? NK_MAXIMIZED : NK_MINIMIZED;
if(nk_tree_state_push(ctx, NK_TREE_TAB, "VIEW", &state)) {
menu_state = MENU_VIEW;
nk_menu_item_label(ctx, "About", NK_TEXT_LEFT);
nk_menu_item_label(ctx, "Options", NK_TEXT_LEFT);
nk_menu_item_label(ctx, "Customize", NK_TEXT_LEFT);
nk_tree_pop(ctx);
}
else menu_state = (menu_state == MENU_VIEW) ? MENU_NONE : menu_state;
state = (menu_state == MENU_CHART) ? NK_MAXIMIZED : NK_MINIMIZED;
if(nk_tree_state_push(ctx, NK_TREE_TAB, "CHART", &state)) {
size_t i = 0;
const float values[] = { 26.0f,13.0f,30.0f,15.0f,25.0f,10.0f,20.0f,40.0f,12.0f,8.0f,22.0f,28.0f };
menu_state = MENU_CHART;
nk_layout_row_dynamic(ctx, 150, 1);
nk_chart_begin(ctx, NK_CHART_COLUMN, NK_LEN(values), 0, 50);
for(i = 0; i < NK_LEN(values); ++i)
nk_chart_push(ctx, values[i]);
nk_chart_end(ctx);
nk_tree_pop(ctx);
}
else menu_state = (menu_state == MENU_CHART) ? MENU_NONE : menu_state;
nk_menu_end(ctx);
}
/* menu widgets */
nk_layout_row_push(ctx, 70); nk_layout_row_push(ctx, 70);
nk_progress(ctx, &mprog, 100, NK_MODIFIABLE); nk_progress(ctx, &mprog, 100, NK_MODIFIABLE);
nk_slider_int(ctx, 0, &mslider, 16, 1); nk_slider_int(ctx, 0, &mslider, 16, 1);
@ -636,7 +694,8 @@ void game_debug_gui(float dt)
nk_label(ctx, "By Micha Mettke", NK_TEXT_LEFT); nk_label(ctx, "By Micha Mettke", NK_TEXT_LEFT);
nk_label(ctx, "nuklear is licensed under the public domain License.", NK_TEXT_LEFT); nk_label(ctx, "nuklear is licensed under the public domain License.", NK_TEXT_LEFT);
nk_popup_end(ctx); nk_popup_end(ctx);
} else show_app_about = nk_false; }
else show_app_about = nk_false;
} }
/* window flags */ /* window flags */
@ -730,14 +789,13 @@ void game_debug_gui(float dt)
option = nk_option_label(ctx, "optionB", option == B) ? B : option; option = nk_option_label(ctx, "optionB", option == B) ? B : option;
option = nk_option_label(ctx, "optionC", option == C) ? C : option; option = nk_option_label(ctx, "optionC", option == C) ? C : option;
nk_layout_row(ctx, NK_STATIC, 30, 2, ratio); nk_layout_row(ctx, NK_STATIC, 30, 2, ratio);
nk_labelf(ctx, NK_TEXT_LEFT, "Slider int"); nk_labelf(ctx, NK_TEXT_LEFT, "Slider int");
nk_slider_int(ctx, 0, &int_slider, 10, 1); nk_slider_int(ctx, 0, &int_slider, 10, 1);
nk_label(ctx, "Slider float", NK_TEXT_LEFT); nk_label(ctx, "Slider float", NK_TEXT_LEFT);
nk_slider_float(ctx, 0, &float_slider, 5.0, 0.5f); nk_slider_float(ctx, 0, &float_slider, 5.0, 0.5f);
nk_labelf(ctx, NK_TEXT_LEFT, "Progressbar" , prog_value); nk_labelf(ctx, NK_TEXT_LEFT, "Progressbar: %zu", prog_value);
nk_progress(ctx, &prog_value, 100, NK_MODIFIABLE); nk_progress(ctx, &prog_value, 100, NK_MODIFIABLE);
nk_layout_row(ctx, NK_STATIC, 25, 2, ratio); nk_layout_row(ctx, NK_STATIC, 25, 2, ratio);
@ -762,6 +820,33 @@ void game_debug_gui(float dt)
nk_tree_pop(ctx); nk_tree_pop(ctx);
} }
if(nk_tree_push(ctx, NK_TREE_NODE, "Inactive", NK_MINIMIZED))
{
static int inactive = 1;
nk_layout_row_dynamic(ctx, 30, 1);
nk_checkbox_label(ctx, "Inactive", &inactive);
nk_layout_row_static(ctx, 30, 80, 1);
if(inactive) {
struct nk_style_button button;
button = ctx->style.button;
ctx->style.button.normal = nk_style_item_color(nk_rgb(40, 40, 40));
ctx->style.button.hover = nk_style_item_color(nk_rgb(40, 40, 40));
ctx->style.button.active = nk_style_item_color(nk_rgb(40, 40, 40));
ctx->style.button.border_color = nk_rgb(60, 60, 60);
ctx->style.button.text_background = nk_rgb(60, 60, 60);
ctx->style.button.text_normal = nk_rgb(60, 60, 60);
ctx->style.button.text_hover = nk_rgb(60, 60, 60);
ctx->style.button.text_active = nk_rgb(60, 60, 60);
nk_button_label(ctx, "button");
ctx->style.button = button;
}
else if(nk_button_label(ctx, "button"))
fprintf(stdout, "button pressed\n");
nk_tree_pop(ctx);
}
if(nk_tree_push(ctx, NK_TREE_NODE, "Selectable", NK_MINIMIZED)) if(nk_tree_push(ctx, NK_TREE_NODE, "Selectable", NK_MINIMIZED))
{ {
if(nk_tree_push(ctx, NK_TREE_NODE, "List", NK_MINIMIZED)) if(nk_tree_push(ctx, NK_TREE_NODE, "List", NK_MINIMIZED))
@ -828,7 +913,7 @@ void game_debug_gui(float dt)
static int check_values[5]; static int check_values[5];
static float position[3]; static float position[3];
static struct nk_color combo_color = { 130, 50, 50, 255 }; static struct nk_color combo_color = { 130, 50, 50, 255 };
static struct nk_color combo_color2 = {130, 180, 50, 255}; static struct nk_colorf combo_color2 = { 0.509f, 0.705f, 0.2f, 1.0f };
static size_t prog_a = 20, prog_b = 40, prog_c = 10, prog_d = 90; static size_t prog_a = 20, prog_b = 40, prog_c = 10, prog_d = 90;
static const char *weapons[] = { "Fist","Pistol","Shotgun","Plasma","BFG" }; static const char *weapons[] = { "Fist","Pistol","Shotgun","Plasma","BFG" };
@ -837,7 +922,7 @@ void game_debug_gui(float dt)
/* default combobox */ /* default combobox */
nk_layout_row_static(ctx, 25, 200, 1); nk_layout_row_static(ctx, 25, 200, 1);
current_weapon = nk_combo(ctx, weapons, LEN(weapons), current_weapon, 25, nk_vec2(200,200)); current_weapon = nk_combo(ctx, weapons, NK_LEN(weapons), current_weapon, 25, nk_vec2(200, 200));
/* slider color combobox */ /* slider color combobox */
if(nk_combo_begin_color(ctx, combo_color, nk_vec2(200, 200))) { if(nk_combo_begin_color(ctx, combo_color, nk_vec2(200, 200))) {
@ -853,9 +938,8 @@ void game_debug_gui(float dt)
combo_color.a = (nk_byte)nk_slide_int(ctx, 0, combo_color.a, 255, 5); combo_color.a = (nk_byte)nk_slide_int(ctx, 0, combo_color.a, 255, 5);
nk_combo_end(ctx); nk_combo_end(ctx);
} }
/* complex color combobox */ /* complex color combobox */
if (nk_combo_begin_color(ctx, combo_color2, nk_vec2(200,400))) { if(nk_combo_begin_color(ctx, nk_rgb_cf(combo_color2), nk_vec2(200, 400))) {
enum color_mode { COL_RGB, COL_HSV }; enum color_mode { COL_RGB, COL_HSV };
static int col_mode = COL_RGB; static int col_mode = COL_RGB;
#ifndef DEMO_DO_NOT_USE_COLOR_PICKER #ifndef DEMO_DO_NOT_USE_COLOR_PICKER
@ -869,22 +953,22 @@ void game_debug_gui(float dt)
nk_layout_row_dynamic(ctx, 25, 1); nk_layout_row_dynamic(ctx, 25, 1);
if(col_mode == COL_RGB) { if(col_mode == COL_RGB) {
combo_color2.r = (nk_byte)nk_propertyi(ctx, "#R:", 0, combo_color2.r, 255, 1,1); combo_color2.r = nk_propertyf(ctx, "#R:", 0, combo_color2.r, 1.0f, 0.01f, 0.005f);
combo_color2.g = (nk_byte)nk_propertyi(ctx, "#G:", 0, combo_color2.g, 255, 1,1); combo_color2.g = nk_propertyf(ctx, "#G:", 0, combo_color2.g, 1.0f, 0.01f, 0.005f);
combo_color2.b = (nk_byte)nk_propertyi(ctx, "#B:", 0, combo_color2.b, 255, 1,1); combo_color2.b = nk_propertyf(ctx, "#B:", 0, combo_color2.b, 1.0f, 0.01f, 0.005f);
combo_color2.a = (nk_byte)nk_propertyi(ctx, "#A:", 0, combo_color2.a, 255, 1,1); combo_color2.a = nk_propertyf(ctx, "#A:", 0, combo_color2.a, 1.0f, 0.01f, 0.005f);
} else { }
nk_byte tmp[4]; else {
nk_color_hsva_bv(tmp, combo_color2); float hsva[4];
tmp[0] = (nk_byte)nk_propertyi(ctx, "#H:", 0, tmp[0], 255, 1,1); nk_colorf_hsva_fv(hsva, combo_color2);
tmp[1] = (nk_byte)nk_propertyi(ctx, "#S:", 0, tmp[1], 255, 1,1); hsva[0] = nk_propertyf(ctx, "#H:", 0, hsva[0], 1.0f, 0.01f, 0.05f);
tmp[2] = (nk_byte)nk_propertyi(ctx, "#V:", 0, tmp[2], 255, 1,1); hsva[1] = nk_propertyf(ctx, "#S:", 0, hsva[1], 1.0f, 0.01f, 0.05f);
tmp[3] = (nk_byte)nk_propertyi(ctx, "#A:", 0, tmp[3], 255, 1,1); hsva[2] = nk_propertyf(ctx, "#V:", 0, hsva[2], 1.0f, 0.01f, 0.05f);
combo_color2 = nk_hsva_bv(tmp); hsva[3] = nk_propertyf(ctx, "#A:", 0, hsva[3], 1.0f, 0.01f, 0.05f);
combo_color2 = nk_hsva_colorfv(hsva);
} }
nk_combo_end(ctx); nk_combo_end(ctx);
} }
/* progressbar combobox */ /* progressbar combobox */
sum = prog_a + prog_b + prog_c + prog_d; sum = prog_a + prog_b + prog_c + prog_d;
sprintf(buffer, "%lu", sum); sprintf(buffer, "%lu", sum);
@ -925,8 +1009,8 @@ void game_debug_gui(float dt)
size_t i = 0; size_t i = 0;
static const float values[] = { 26.0f,13.0f,30.0f,15.0f,25.0f,10.0f,20.0f,40.0f, 12.0f, 8.0f, 22.0f, 28.0f, 5.0f }; static const float values[] = { 26.0f,13.0f,30.0f,15.0f,25.0f,10.0f,20.0f,40.0f, 12.0f, 8.0f, 22.0f, 28.0f, 5.0f };
nk_layout_row_dynamic(ctx, 150, 1); nk_layout_row_dynamic(ctx, 150, 1);
nk_chart_begin(ctx, NK_CHART_COLUMN, LEN(values), 0, 50); nk_chart_begin(ctx, NK_CHART_COLUMN, NK_LEN(values), 0, 50);
for (i = 0; i < LEN(values); ++i) { for(i = 0; i < NK_LEN(values); ++i) {
nk_flags res = nk_chart_push(ctx, values[i]); nk_flags res = nk_chart_push(ctx, values[i]);
if(res & NK_CHART_CLICKED) { if(res & NK_CHART_CLICKED) {
chart_selection = values[i]; chart_selection = values[i];
@ -968,7 +1052,9 @@ void game_debug_gui(float dt)
if(nk_combo_begin_label(ctx, buffer, nk_vec2(350, 400))) if(nk_combo_begin_label(ctx, buffer, nk_vec2(350, 400)))
{ {
int i = 0; int i = 0;
const char *month[] = {"January", "February", "March", "Apil", "May", "June", "July", "August", "September", "Ocotober", "November", "December"}; const char *month[] = { "January", "February", "March",
"April", "May", "June", "July", "August", "September",
"October", "November", "December" };
const char *week_days[] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" }; const char *week_days[] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
const int month_days[] = { 31,28,31,30,31,30,31,31,30,31,30,31 }; const int month_days[] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
int year = sel_date.tm_year + 1900; int year = sel_date.tm_year + 1900;
@ -984,8 +1070,9 @@ void game_debug_gui(float dt)
if(nk_button_symbol(ctx, NK_SYMBOL_TRIANGLE_LEFT)) { if(nk_button_symbol(ctx, NK_SYMBOL_TRIANGLE_LEFT)) {
if(sel_date.tm_mon == 0) { if(sel_date.tm_mon == 0) {
sel_date.tm_mon = 11; sel_date.tm_mon = 11;
sel_date.tm_year = MAX_NUM(0, sel_date.tm_year-1); sel_date.tm_year = NK_MAX(0, sel_date.tm_year - 1);
} else sel_date.tm_mon--; }
else sel_date.tm_mon--;
} }
nk_layout_row_push(ctx, 0.9f); nk_layout_row_push(ctx, 0.9f);
sprintf(buffer, "%s %d", month[sel_date.tm_mon], year); sprintf(buffer, "%s %d", month[sel_date.tm_mon], year);
@ -995,7 +1082,8 @@ void game_debug_gui(float dt)
if(sel_date.tm_mon == 11) { if(sel_date.tm_mon == 11) {
sel_date.tm_mon = 0; sel_date.tm_mon = 0;
sel_date.tm_year++; sel_date.tm_year++;
} else sel_date.tm_mon++; }
else sel_date.tm_mon++;
} }
nk_layout_row_end(ctx); nk_layout_row_end(ctx);
@ -1010,7 +1098,7 @@ void game_debug_gui(float dt)
/* weekdays */ /* weekdays */
nk_layout_row_dynamic(ctx, 35, 7); nk_layout_row_dynamic(ctx, 35, 7);
for (i = 0; i < (int)LEN(week_days); ++i) for(i = 0; i < (int)NK_LEN(week_days); ++i)
nk_label(ctx, week_days[i], NK_TEXT_CENTERED); nk_label(ctx, week_days[i], NK_TEXT_CENTERED);
/* days */ /* days */
@ -1127,12 +1215,8 @@ void game_debug_gui(float dt)
nk_chart_end(ctx); nk_chart_end(ctx);
} }
if (index != -1) { if(index != -1)
char buffer[NK_MAX_NUMBER_BUFFER]; nk_tooltipf(ctx, "Value: %.2f", (float)cos((float)index*step));
float val = (float)cos((float)index*step);
sprintf(buffer, "Value: %.2f", val);
nk_tooltip(ctx, buffer);
}
if(line_index != -1) { if(line_index != -1) {
nk_layout_row_dynamic(ctx, 20, 1); nk_layout_row_dynamic(ctx, 20, 1);
nk_labelf(ctx, NK_TEXT_LEFT, "Selected value: %.2f", (float)cos((float)index*step)); nk_labelf(ctx, NK_TEXT_LEFT, "Selected value: %.2f", (float)cos((float)index*step));
@ -1152,11 +1236,8 @@ void game_debug_gui(float dt)
} }
nk_chart_end(ctx); nk_chart_end(ctx);
} }
if (index != -1) { if(index != -1)
char buffer[NK_MAX_NUMBER_BUFFER]; nk_tooltipf(ctx, "Value: %.2f", (float)fabs(sin(step * (float)index)));
sprintf(buffer, "Value: %.2f", (float)fabs(sin(step * (float)index)));
nk_tooltip(ctx, buffer);
}
if(col_index != -1) { if(col_index != -1) {
nk_layout_row_dynamic(ctx, 20, 1); nk_layout_row_dynamic(ctx, 20, 1);
nk_labelf(ctx, NK_TEXT_LEFT, "Selected value: %.2f", (float)fabs(sin(step * (float)col_index))); nk_labelf(ctx, NK_TEXT_LEFT, "Selected value: %.2f", (float)fabs(sin(step * (float)col_index)));
@ -1203,7 +1284,7 @@ void game_debug_gui(float dt)
struct nk_rect bounds; struct nk_rect bounds;
/* menu contextual */ /* menu contextual */
nk_layout_row_static(ctx, 30, 150, 1); nk_layout_row_static(ctx, 30, 160, 1);
bounds = nk_widget_bounds(ctx); bounds = nk_widget_bounds(ctx);
nk_label(ctx, "Right click me for menu", NK_TEXT_LEFT); nk_label(ctx, "Right click me for menu", NK_TEXT_LEFT);
@ -1268,7 +1349,8 @@ void game_debug_gui(float dt)
nk_popup_close(ctx); nk_popup_close(ctx);
} }
nk_popup_end(ctx); nk_popup_end(ctx);
} else popup_active = nk_false; }
else popup_active = nk_false;
} }
/* tooltip */ /* tooltip */
@ -1403,11 +1485,41 @@ void game_debug_gui(float dt)
} }
nk_tree_pop(ctx); nk_tree_pop(ctx);
} }
if(nk_tree_push(ctx, NK_TREE_NODE, "Tree", NK_MINIMIZED))
{
static int root_selected = 0;
int sel = root_selected;
if(nk_tree_element_push(ctx, NK_TREE_NODE, "Root", NK_MINIMIZED, &sel)) {
static int selected[8];
int i = 0, node_select = selected[0];
if(sel != root_selected) {
root_selected = sel;
for(i = 0; i < 8; ++i)
selected[i] = sel;
}
if(nk_tree_element_push(ctx, NK_TREE_NODE, "Node", NK_MINIMIZED, &node_select)) {
int j = 0;
static int sel_nodes[4];
if(node_select != selected[0]) {
selected[0] = node_select;
for(i = 0; i < 4; ++i)
sel_nodes[i] = node_select;
}
nk_layout_row_static(ctx, 18, 100, 1);
for(j = 0; j < 4; ++j)
nk_selectable_symbol_label(ctx, NK_SYMBOL_CIRCLE_SOLID, (sel_nodes[j]) ? "Selected" : "Unselected", NK_TEXT_RIGHT, &sel_nodes[j]);
nk_tree_element_pop(ctx);
}
nk_layout_row_static(ctx, 18, 100, 1);
for(i = 1; i < 8; ++i)
nk_selectable_symbol_label(ctx, NK_SYMBOL_CIRCLE_SOLID, (selected[i]) ? "Selected" : "Unselected", NK_TEXT_RIGHT, &selected[i]);
nk_tree_element_pop(ctx);
}
nk_tree_pop(ctx);
}
if(nk_tree_push(ctx, NK_TREE_NODE, "Notebook", NK_MINIMIZED)) if(nk_tree_push(ctx, NK_TREE_NODE, "Notebook", NK_MINIMIZED))
{ {
static int current_tab = 0; static int current_tab = 0;
struct nk_vec2 item_padding;
struct nk_rect bounds; struct nk_rect bounds;
float step = (2 * 3.141592654f) / 32; float step = (2 * 3.141592654f) / 32;
enum chart_type { CHART_LINE, CHART_HISTO, CHART_MIXED }; enum chart_type { CHART_LINE, CHART_HISTO, CHART_MIXED };
@ -1431,7 +1543,8 @@ void game_debug_gui(float dt)
ctx->style.button.normal = ctx->style.button.active; ctx->style.button.normal = ctx->style.button.active;
current_tab = nk_button_label(ctx, names[i]) ? i : current_tab; current_tab = nk_button_label(ctx, names[i]) ? i : current_tab;
ctx->style.button.normal = button_color; ctx->style.button.normal = button_color;
} else current_tab = nk_button_label(ctx, names[i]) ? i: current_tab; }
else current_tab = nk_button_label(ctx, names[i]) ? i : current_tab;
} }
nk_style_pop_float(ctx); nk_style_pop_float(ctx);
@ -1441,6 +1554,7 @@ void game_debug_gui(float dt)
{ {
nk_style_pop_vec2(ctx); nk_style_pop_vec2(ctx);
switch(current_tab) { switch(current_tab) {
default: break;
case CHART_LINE: case CHART_LINE:
nk_layout_row_dynamic(ctx, 100, 1); nk_layout_row_dynamic(ctx, 100, 1);
bounds = nk_widget_bounds(ctx); bounds = nk_widget_bounds(ctx);
@ -1482,7 +1596,8 @@ void game_debug_gui(float dt)
break; break;
} }
nk_group_end(ctx); nk_group_end(ctx);
} else nk_style_pop_vec2(ctx); }
else nk_style_pop_vec2(ctx);
nk_tree_pop(ctx); nk_tree_pop(ctx);
} }
@ -1760,7 +1875,6 @@ void game_debug_gui(float dt)
} }
} }
nk_end(ctx); nk_end(ctx);
//return !nk_window_is_closed(ctx, "Overview");
} }

@ -1,4 +1,5 @@
Todo: Todo:
- Migrate from bitbucket to github and from mercurial back to git
- Add warning to genie build script when running on windows and WindowsSdkVersion cannot be found. This happens when the script is not run from vcvarsall command prompt - Add warning to genie build script when running on windows and WindowsSdkVersion cannot be found. This happens when the script is not run from vcvarsall command prompt
? Rethink/remove the game executable and game library split. ? Rethink/remove the game executable and game library split.
- Refactor all global application state into 'Application_Context' struct. A single global instance of which is available everywhere - Refactor all global application state into 'Application_Context' struct. A single global instance of which is available everywhere
@ -62,9 +63,8 @@ Bugs:
- Better handling of wav format checking at load time - Better handling of wav format checking at load time
- Fix light rotation/direction bugs - Fix light rotation/direction bugs
- Fix lights type not being correctly saved/loaded from file - Fix lights type not being correctly saved/loaded from file
- Console fix bug when enabled in editor mode
- Fix mouse button press/release behaviour by investigating how sdl handles mouse release or by explicitly caching mouse state by using event callbacks recieved when a mousebutton release event is reported by sdl - Fix mouse button press/release behaviour by investigating how sdl handles mouse release or by explicitly caching mouse state by using event callbacks recieved when a mousebutton release event is reported by sdl
- Fix culling
Done: Done:
* Input * Input
@ -190,3 +190,4 @@ Done:
* Implemented screen coordinate to ray conversion and ray-sphere collision * Implemented screen coordinate to ray conversion and ray-sphere collision
* Split todo and readme into two files * Split todo and readme into two files
* Replace all renderer_check_gl calls with GL_CHECK macro * Replace all renderer_check_gl calls with GL_CHECK macro
* Fixed Console bug when enabled in editor mode
Loading…
Cancel
Save