Skip to content

Commit

Permalink
[rtx] add 3 new skies - rtx.conf (enable effect light - muzzleflash)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxor4d committed Mar 1, 2024
1 parent 997b113 commit d2696ed
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 66 deletions.
Binary file modified assets-remix/main/xcommon_rtx.iwd
Binary file not shown.
24 changes: 13 additions & 11 deletions assets-remix/rtx.conf

Large diffs are not rendered by default.

Binary file modified assets-remix/zone/english/xcommon_rtx.ff
Binary file not shown.
20 changes: 20 additions & 0 deletions src/components/modules/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,26 @@ namespace components
s_printer.print(str, str_end);
}

void gui::center_horz_begin(const float group_width, float indent)
{
if (group_width != 0.0f)
{
// floorf to ensure no half pixel offsets (image 1px borders)
ImGui::SetCursorPosX(floorf((ImGui::GetWindowWidth() - ImGui::GetCursorPos().x) * 0.5f - (group_width * 0.5f) + indent));
}

ImGui::BeginGroup();
}

void gui::center_horz_end(float& group_width)
{
ImGui::EndGroup();

// only update group width if change is larger then 1px because floorf in 'center_horz_begin' causes a wiggle
const float new_width = ImGui::GetItemRectSize().x;
group_width = abs(group_width - new_width) != 1.0f ? new_width : group_width;
}

void gui::redraw_cursor()
{
float cur_w = (1.0f * game::scrPlaceFull->scaleVirtualToReal[0]) / game::scrPlaceFull->scaleVirtualToFull[0];
Expand Down
3 changes: 3 additions & 0 deletions src/components/modules/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ namespace components
//static void Markdown(const std::string& markdown_);
static void markdown(const char* str, const char* str_end);

static void center_horz_begin(const float group_width, float indent = 4.0f);
static void center_horz_end(float& group_width);

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

// *
Expand Down
132 changes: 79 additions & 53 deletions src/components/modules/rtx/rtx_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,58 +52,95 @@ namespace components
{
ImGui::Indent(8.0f); SPACING(0.0f, 4.0f);

if (ImGui::Button("Hill"))
{
skysphere_spawn(0);
}
const auto sky_valid = skysphere_is_valid();
constexpr auto BUTTON_WIDTH = 100.0f;

ImGui::SameLine();
if (ImGui::Button("Desert"))
static float skygroup01_width = 0.0f;
gui::center_horz_begin(skygroup01_width);
{
skysphere_spawn(1);
}
if (ImGui::Button("Hill", ImVec2(BUTTON_WIDTH, 0)))
{
skysphere_spawn(SKY::CLEAR);
}

ImGui::SameLine();
if (ImGui::Button("City"))
{
skysphere_spawn(2);
}
ImGui::SameLine();
if (ImGui::Button("Desert", ImVec2(BUTTON_WIDTH, 0)))
{
skysphere_spawn(SKY::DESERT);
}

ImGui::SameLine();
if (ImGui::Button("Night"))
{
skysphere_spawn(3);
ImGui::SameLine();
if (ImGui::Button("Night", ImVec2(BUTTON_WIDTH, 0)))
{
skysphere_spawn(SKY::NIGHT);
}

ImGui::SameLine();
if (ImGui::Button("Night 2", ImVec2(BUTTON_WIDTH, 0)))
{
skysphere_spawn(SKY::NIGHT2);
}

gui::center_horz_end(skygroup01_width);
}

ImGui::SameLine();
if (ImGui::Button("Overcast"))
static float skygroup02_width = 0.0f;
gui::center_horz_begin(skygroup02_width);
{
skysphere_spawn(4);
if (ImGui::Button("Overcast", ImVec2(BUTTON_WIDTH, 0)))
{
skysphere_spawn(SKY::OVERCAST);
}

ImGui::SameLine();
if (ImGui::Button("Sunset", ImVec2(BUTTON_WIDTH, 0)))
{
skysphere_spawn(SKY::SUNSET);
}

ImGui::SameLine();
if (ImGui::Button("Galaxy 1", ImVec2(BUTTON_WIDTH, 0)))
{
skysphere_spawn(SKY::GALAXY1);
}

ImGui::SameLine();
if (ImGui::Button("Galaxy 2", ImVec2(BUTTON_WIDTH, 0)))
{
skysphere_spawn(SKY::GALAXY2);
}

gui::center_horz_end(skygroup02_width);
}

ImGui::SameLine();
if (ImGui::Button("Sunset"))
static float skygroup03_width = 0.0f;
gui::center_horz_begin(skygroup03_width);
{
skysphere_spawn(5);
}
SPACING(4.0f, 0);

const auto sky_valid = skysphere_is_valid();
if (!sky_valid)
{
ImGui::TextUnformatted("No valid sky found. Limited settings...");
}

if (!sky_valid)
{
ImGui::TextUnformatted("No valid sky found. Limited settings...");
}
ImGui::PushItemWidth(90.0f);
ImGui::DragFloat("Sky Scale", &skysphere_scale, 0.01f, 1.0f, 10000.0f, "%.0f");
ImGui::PopItemWidth();

ImGui::PushItemWidth(90.0f);
ImGui::DragFloat("Sky Scale", &skysphere_scale, 0.01f, 1.0f, 10000.0f, "%.0f");
ImGui::PopItemWidth();
if (sky_valid)
{
if (dvars::rtx_sky_follow_player)
{
ImGui::SameLine(0, 30.0f);
ImGui::Checkbox("Follow player", &dvars::rtx_sky_follow_player->current.enabled);
}
}
gui::center_horz_end(skygroup03_width);
}

if (sky_valid)
{
if (dvars::rtx_sky_follow_player)
{
ImGui::Checkbox("Follow player", &dvars::rtx_sky_follow_player->current.enabled);
}
SPACING(4.0f, 0);

if (ImGui::DragFloat3("Sphere Origin", rtx_gui::skysphere_model_origin, 1.0f, -360.0f, 360.0f, "%.2f"))
{
Expand Down Expand Up @@ -449,18 +486,14 @@ namespace components
}
}

const char* rtx_gui::skysphere_get_name_for_variant(int variant)
const char* rtx_gui::skysphere_get_name_for_variant(std::uint32_t variant)
{
switch (variant)
if (variant > SKY::COUNT)
{
default:
case 0: return "rtx_skysphere_oceanrock";
case 1: return "rtx_skysphere_desert";
case 2: return "rtx_skysphere_overcast_city";
case 3: return "rtx_skysphere_night";
case 4: return "rtx_skysphere_overcast";
case 5: return "rtx_skysphere_sunset_clouds";
return SKY_STRINGS[SKY::SUNSET];
}

return SKY_STRINGS[variant];
}

bool rtx_gui::skysphere_is_valid()
Expand Down Expand Up @@ -542,14 +575,7 @@ namespace components
}
}

/**
* - [0] 'rtx_skysphere_oceanrock'
* - [1] 'rtx_skysphere_desert'
* - [2] 'rtx_skysphere_overcast_city'
* - [3] 'rtx_skysphere_night'
* - [4] 'rtx_skysphere_overcast'
* - [5] 'rtx_skysphere_sunset_clouds'
*/
// rtx_gui::SKY enum
void rtx_gui::skysphere_spawn(int variant)
{
if (game::clc.demoplaying)
Expand Down
27 changes: 26 additions & 1 deletion src/components/modules/rtx/rtx_gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,31 @@ namespace components

static void gui();

enum SKY : std::uint32_t
{
CLEAR,
DESERT,
GALAXY1,
NIGHT,
OVERCAST,
SUNSET,
GALAXY2,
NIGHT2,
COUNT,
};

static inline constexpr const char* SKY_STRINGS[] =
{
"rtx_skysphere_oceanrock",
"rtx_skysphere_desert",
"rtx_skysphere_galaxy01",
"rtx_skysphere_night",
"rtx_skysphere_overcast",
"rtx_skysphere_sunset_clouds",
"rtx_skysphere_galaxy02",
"rtx_skysphere_night02"
};

static void skysphere_frame();
static bool skysphere_is_valid();
static void skysphere_update_pos();
Expand All @@ -28,7 +53,7 @@ namespace components
static inline int d3d_alpha_blend = 4;

private:
static const char* skysphere_get_name_for_variant(int variant);
static const char* skysphere_get_name_for_variant(std::uint32_t variant);
static inline bool skysphere_spawned = false;
static inline int skysphere_variant = 0;
static inline game::gentity_s* skysphere_model = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/rtx/rtx_map_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace components

if (!flags::has_flag("no_default_sky") && !rtx_gui::skysphere_is_valid())
{
rtx_gui::skysphere_spawn(5); // always spawn sunset
rtx_gui::skysphere_spawn(rtx_gui::SKY::SUNSET); // always spawn sunset
}
}
}
Expand Down

0 comments on commit d2696ed

Please sign in to comment.