Skip to content

Commit

Permalink
devgui: move ocean tab into shader tab
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxor4d committed Apr 13, 2024
1 parent da3916d commit ea27160
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 52 deletions.
35 changes: 35 additions & 0 deletions src/components/modules/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,41 @@ namespace components
return game::glob::gui.menus[id];
}

/**
* @param title_text text in between separator lines
* @param pre_spacing spacing in front of separator
* @param width 0.0 => full window width
* @param post_spacing spacing applied after separator
* @param thickness thickness of separator line
*/
void gui::title_inside_seperator(const char* title_text, bool pre_spacing, float width, float post_spacing, float thickness)
{
ImGui::BeginGroup();
if (pre_spacing) SPACING(0.0f, 12.0f);
if (width == 0.0f) width = ImGui::GetContentRegionAvail().x - 8.0f;

const float text_spacing = 6.0f;
const auto text_size = ImGui::CalcTextSize(title_text, nullptr, true);
const float first_sep_width = (width * 0.1f);

ImVec2 seperator_pos = ImGui::GetCursorScreenPos();
seperator_pos.y += (text_size.y * 0.5f);

ImGui::GetWindowDrawList()->AddLine(seperator_pos, ImVec2(seperator_pos.x + first_sep_width, seperator_pos.y), ImGui::GetColorU32(ImGuiCol_HeaderActive), thickness);
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + first_sep_width + text_spacing);
ImGui::TextColored(ImGui::ColorConvertU32ToFloat4(ImGui::GetColorU32(ImGuiCol_HeaderActive)), title_text);
ImGui::SameLine(0.0f, text_spacing);

seperator_pos = ImGui::GetCursorScreenPos();
seperator_pos.y += (text_size.y * 0.5f);

const auto second_sep_width = width - text_size.x - first_sep_width - (text_spacing * 2.0f);
ImGui::GetWindowDrawList()->AddLine(seperator_pos, ImVec2(seperator_pos.x + second_sep_width, seperator_pos.y), ImGui::GetColorU32(ImGuiCol_HeaderActive), thickness);

SPACING(0.0f, post_spacing);
ImGui::EndGroup();
}

// *
//
gui::gui()
Expand Down
2 changes: 2 additions & 0 deletions src/components/modules/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ namespace components

static game::gui_menus_t& get_menu(game::GUI_MENUS id);

static void title_inside_seperator(const char* title_text, bool pre_spacing, float width, float post_spacing, float thickness);

// *
// set latched values + modified flag and return value pointer
template <typename T>
Expand Down
19 changes: 9 additions & 10 deletions src/components/modules/gui_devgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,30 +101,29 @@ namespace components
ImGui::EndTabItem();
}

if (components::active.draw_collision && ImGui::BeginTabItem("Collision/Export"))
if (components::active.draw_collision && ImGui::BeginTabItem("Collision"))
{
gui_devgui::menu_tab_collision(menu);
ImGui::EndTabItem();
}

if (!components::active.rtx)
if ((components::active.rtx || components::active.postfx_shaders) && ImGui::BeginTabItem("Shaders"))
{
if (components::active.postfx_shaders && ImGui::BeginTabItem("Shaders"))
if (!components::active.rtx)
{
gui_devgui::menu_tab_shaders(menu);
ImGui::EndTabItem();
}
}

if (ImGui::BeginTabItem("Visuals"))
{
gui_devgui::menu_tab_visuals(menu);
// ------------------
gui::title_inside_seperator("Ocean Shader Settings", false, 0.0f, 20.0f, 2.0f);

ocean::devgui_tab(menu);
ImGui::EndTabItem();
}

if (components::active.ocean && ImGui::BeginTabItem("Ocean"))
if (ImGui::BeginTabItem("Visuals"))
{
ocean::devgui_tab(menu);
gui_devgui::menu_tab_visuals(menu);
ImGui::EndTabItem();
}

Expand Down
8 changes: 4 additions & 4 deletions src/components/modules/ocean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,12 @@ namespace components
{
const float OCEAN_SLIDER_SPEED = 0.01f;

if (ImGui::Button("Dump shader settings"))
if (ImGui::Button("Dump shader settings", ImVec2(ImGui::GetContentRegionAvail().x, 0.0f)))
{
dump_settings();
}

if (ImGui::CollapsingHeader("Vertex + Pixelshader", ImGuiTreeNodeFlags_DefaultOpen))
if (ImGui::CollapsingHeader("Vertex + Pixelshader", ImGuiTreeNodeFlags_None))
{
ImGui::Indent(8.0f); SPACING(0.0f, 4.0f);

Expand All @@ -315,7 +315,7 @@ namespace components
SPACING(0.0f, 4.0f); ImGui::Indent(-8.0f);
}

if (ImGui::CollapsingHeader("Vertexshader", ImGuiTreeNodeFlags_DefaultOpen))
if (ImGui::CollapsingHeader("Vertexshader", ImGuiTreeNodeFlags_None))
{
ImGui::Indent(8.0f); SPACING(0.0f, 4.0f);

Expand All @@ -342,7 +342,7 @@ namespace components
SPACING(0.0f, 4.0f); ImGui::Indent(-8.0f);
}

if (ImGui::CollapsingHeader("Pixelshader", ImGuiTreeNodeFlags_DefaultOpen))
if (ImGui::CollapsingHeader("Pixelshader", ImGuiTreeNodeFlags_None))
{
ImGui::Indent(8.0f); SPACING(0.0f, 4.0f);

Expand Down
41 changes: 3 additions & 38 deletions src/components/modules/rtx/rtx_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,6 @@

namespace components
{
/**
* @param title_text text in between separator lines
* @param pre_spacing spacing in front of separator
* @param width 0.0 => full window width
* @param post_spacing spacing applied after separator
* @param thickness thickness of separator line
*/
void title_inside_seperator(const char* title_text, bool pre_spacing, float width, float post_spacing, float thickness)
{
ImGui::BeginGroup();
if (pre_spacing) SPACING(0.0f, 12.0f);
if (width == 0.0f) width = ImGui::GetContentRegionAvail().x - 8.0f;

const float text_spacing = 6.0f;
const auto text_size = ImGui::CalcTextSize(title_text, nullptr, true);
const float first_sep_width = (width * 0.1f);

ImVec2 seperator_pos = ImGui::GetCursorScreenPos();
seperator_pos.y += (text_size.y * 0.5f);

ImGui::GetWindowDrawList()->AddLine(seperator_pos, ImVec2(seperator_pos.x + first_sep_width, seperator_pos.y), ImGui::GetColorU32(ImGuiCol_HeaderActive), thickness);
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + first_sep_width + text_spacing);
ImGui::TextColored(ImGui::ColorConvertU32ToFloat4(ImGui::GetColorU32(ImGuiCol_HeaderActive)), title_text);
ImGui::SameLine(0.0f, text_spacing);

seperator_pos = ImGui::GetCursorScreenPos();
seperator_pos.y += (text_size.y * 0.5f);

const auto second_sep_width = width - text_size.x - first_sep_width - (text_spacing * 2.0f);
ImGui::GetWindowDrawList()->AddLine(seperator_pos, ImVec2(seperator_pos.x + second_sep_width, seperator_pos.y), ImGui::GetColorU32(ImGuiCol_HeaderActive), thickness);

SPACING(0.0f, post_spacing);
ImGui::EndGroup();
}

void rtx_gui::gui()
{
if (ImGui::CollapsingHeader("General Settings", ImGuiTreeNodeFlags_DefaultOpen))
Expand Down Expand Up @@ -71,7 +36,7 @@ namespace components
"Enabling this setting will disable that limit but might cause instability.");

// -------------------
title_inside_seperator("Material Info", true, 0.0f, true, 2.0f);
gui::title_inside_seperator("Material Info", true, 0.0f, true, 2.0f);

if (dvars::r_showTess) {
ImGui::PushItemWidth(240.0f);
Expand All @@ -88,7 +53,7 @@ namespace components
}

// ------------------
title_inside_seperator("Culling", true, 0.0f, true, 2.0f);
gui::title_inside_seperator("Culling", true, 0.0f, true, 2.0f);

if (rtx::OLD_CULLING_ACTIVE)
{
Expand Down Expand Up @@ -133,7 +98,7 @@ namespace components
}

// ------------------
title_inside_seperator("Dev Settings", true, 0.0f, true, 2.0f);
gui::title_inside_seperator("Dev Settings", true, 0.0f, true, 2.0f);

if (dvars::r_showCellIndex) {
ImGui::Checkbox("Show Cell Indices", &dvars::r_showCellIndex->current.enabled); TT(dvars::r_showCellIndex->description);
Expand Down

0 comments on commit ea27160

Please sign in to comment.