decouple grid from tile picker and make it toggleable
This commit is contained in:
parent
2af0361ac5
commit
91a4a2079b
28
src/main.cpp
28
src/main.cpp
@ -100,13 +100,15 @@ static SDL_DateTime calendar_time;
|
|||||||
static vec2 mouse_pos;
|
static vec2 mouse_pos;
|
||||||
|
|
||||||
static bool in_editor;
|
static bool in_editor;
|
||||||
|
static bool show_grid = true;
|
||||||
|
|
||||||
static vec2 editor_camera_position;
|
static vec2 editor_camera_position;
|
||||||
static float editor_camera_distance = 30.0f;
|
static float editor_camera_distance = 30.0f;
|
||||||
|
|
||||||
static bool show_demo_window = false;
|
static bool show_demo_window;
|
||||||
static bool show_tile_picker = false;
|
static bool show_tile_picker;
|
||||||
static bool show_settings = false;
|
static bool show_settings;
|
||||||
|
|
||||||
|
|
||||||
#define log_error(...) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
#define log_error(...) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
||||||
|
|
||||||
@ -1825,12 +1827,10 @@ static void update_state_editor() {
|
|||||||
ImGui_ImplSDL3_NewFrame();
|
ImGui_ImplSDL3_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
|
const ImGuiViewport *viewport = ImGui::GetMainViewport();
|
||||||
|
|
||||||
if (ImGui::BeginMainMenuBar()) {
|
if (ImGui::BeginMainMenuBar()) {
|
||||||
if (ImGui::BeginMenu("File")) {
|
if (ImGui::BeginMenu("File")) {
|
||||||
if (ImGui::MenuItem("Save")) {
|
|
||||||
save_map(current_map);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui::MenuItem("Reload")) {
|
if (ImGui::MenuItem("Reload")) {
|
||||||
recreate_tile_textures();
|
recreate_tile_textures();
|
||||||
WGPUBindGroupEntry world_bind_group_entries[] = {
|
WGPUBindGroupEntry world_bind_group_entries[] = {
|
||||||
@ -1849,9 +1849,15 @@ static void update_state_editor() {
|
|||||||
world_bind_group = wgpuDeviceCreateBindGroup(device, &world_bind_group_descriptor);
|
world_bind_group = wgpuDeviceCreateBindGroup(device, &world_bind_group_descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImGui::MenuItem("Save")) {
|
||||||
|
save_map(current_map);
|
||||||
|
}
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
ImGui::MenuItem("Settings", NULL, &show_settings);
|
ImGui::MenuItem("Settings", NULL, &show_settings);
|
||||||
ImGui::MenuItem("Demo Window", NULL, &show_demo_window);
|
ImGui::MenuItem("Demo Window", NULL, &show_demo_window);
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
if (ImGui::MenuItem("Exit")) {
|
if (ImGui::MenuItem("Exit")) {
|
||||||
Running = false;
|
Running = false;
|
||||||
}
|
}
|
||||||
@ -2019,6 +2025,12 @@ static void update_state_editor() {
|
|||||||
selected_tile_kind = -1;
|
selected_tile_kind = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::SetNextWindowPos({ viewport->WorkPos.x + viewport->WorkSize.x - 10.0f, viewport->WorkPos.y + 10.0f }, ImGuiCond_Always, { 1.0f, 0.0f });
|
||||||
|
if (ImGui::Begin("Overlay", NULL, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav)) {
|
||||||
|
ImGui::Checkbox("Grid", &show_grid);
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
|
||||||
if (show_demo_window)
|
if (show_demo_window)
|
||||||
ImGui::ShowDemoWindow(&show_demo_window);
|
ImGui::ShowDemoWindow(&show_demo_window);
|
||||||
}
|
}
|
||||||
@ -2118,7 +2130,7 @@ static void render_editor(WGPURenderPassColorAttachment framebuffer) {
|
|||||||
wgpuRenderPassEncoderDrawIndexed(render_pass_encoder, 6, current_map.size.y * current_map.size.x, 0, 0, 0);
|
wgpuRenderPassEncoderDrawIndexed(render_pass_encoder, 6, current_map.size.y * current_map.size.x, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_tile_picker) { // Draw Grid
|
if (show_grid) { // Draw Grid
|
||||||
ZoneScopedN("Draw Grid");
|
ZoneScopedN("Draw Grid");
|
||||||
|
|
||||||
Uint32 num_grid_cells = current_map.size.y * current_map.size.x;
|
Uint32 num_grid_cells = current_map.size.y * current_map.size.x;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user