From 3c4ad3d7aed57aafa7a3f3744673f4bf0694b5de Mon Sep 17 00:00:00 2001 From: aixxe Date: Wed, 21 Dec 2016 16:05:36 +0000 Subject: [PATCH] Add 'no sky' via IMaterial::ColorModulate. * Really should move this out of FrameStageNotify. Only keeping it here for demonstration purposes. Might find a better place later. Signed-off-by: aixxe --- src/GUI/Components.cpp | 4 ++++ src/GUI/GUI.cpp | 3 +++ src/GUI/GUI.h | 5 +++++ src/Hooks/FrameStageNotify.cpp | 18 ++++++++++++++++++ 4 files changed, 30 insertions(+) diff --git a/src/GUI/Components.cpp b/src/GUI/Components.cpp index 9a3024b..5d14611 100644 --- a/src/GUI/Components.cpp +++ b/src/GUI/Components.cpp @@ -13,6 +13,10 @@ void GUI::DrawConfigurationWindow() { ImGui::Checkbox("Auto-bunnyhop", &GUI::BunnyHop::Enabled); ImGui::Spacing(); + + ImGui::Checkbox("No sky", &GUI::NoSky::Enabled); + ImGui::ColorEdit3("##No sky color", GUI::NoSky::Color); + ImGui::Spacing(); ImGui::PopItemWidth(); ImGui::End(); diff --git a/src/GUI/GUI.cpp b/src/GUI/GUI.cpp index ecd377b..1cf9c13 100644 --- a/src/GUI/GUI.cpp +++ b/src/GUI/GUI.cpp @@ -4,6 +4,9 @@ bool GUI::IsVisible = false; bool GUI::BunnyHop::Enabled = true; +bool GUI::NoSky::Enabled = true; +float GUI::NoSky::Color[3] = {0, 0, 0.275}; + void GUI::Render() { // Draw various global components. GUI::DrawFramerateCounter(); diff --git a/src/GUI/GUI.h b/src/GUI/GUI.h index 12db6a8..16d9dc0 100644 --- a/src/GUI/GUI.h +++ b/src/GUI/GUI.h @@ -10,6 +10,11 @@ namespace GUI { extern bool Enabled; } + namespace NoSky { + extern bool Enabled; + extern float Color[3]; + } + void DrawFramerateCounter(); void DrawConfigurationWindow(); diff --git a/src/Hooks/FrameStageNotify.cpp b/src/Hooks/FrameStageNotify.cpp index d20aa00..568304d 100644 --- a/src/Hooks/FrameStageNotify.cpp +++ b/src/Hooks/FrameStageNotify.cpp @@ -6,6 +6,24 @@ void Hooks::FrameStageNotify(IBaseClientDLL* thisptr, ClientFrameStage_t stage) // Get the original function and store it statically. static FrameStageNotify_t oFrameStageNotify = clientdll_hook->GetOriginalFunction(35); + // Really should move this somewhere else. Doesn't need to be called this often. + if (stage == ClientFrameStage_t::FRAME_NET_UPDATE_POSTDATAUPDATE_END) { + for (MaterialHandle_t i = matsystem->FirstMaterial(); i != matsystem->InvalidMaterial(); i = matsystem->NextMaterial(i)) { + IMaterial* material = matsystem->GetMaterial(i); + + // No Sky + if (!strcmp(material->GetTextureGroupName(), TEXTURE_GROUP_SKYBOX)) { + if (GUI::NoSky::Enabled) { + material->ColorModulate(GUI::NoSky::Color[0], GUI::NoSky::Color[1], GUI::NoSky::Color[2]); + } else { + material->ColorModulate(1, 1, 1); + } + + continue; + } + } + } + // Call original 'IBaseClientDLL::FrameStageNotify'. oFrameStageNotify(thisptr, stage); } \ No newline at end of file