This repository has been archived by the owner on Jan 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new Draw Distance mod among other things (#279)
* Update Crender Class Used regenny to remove znear and zfar and added new offset for draw distance. i dont know why regenny does the private public thing now. guess its a feature * ReAdd Znear and Zfar Im not 100% sure if these vaules are correct but its the best i could find setting Zfar to 0 seems to break rending in a way that would make me think its Zfar if this is incorrect and someone is able to fix them that would be great Kcamera does use them but luckly currently nothing uses that class so its not overly important * Add DrawDistance Mod * Fix unlimited Zoom mod * Reenable character Window Title mod all prerequirements for this mod to work again where already updated
- Loading branch information
Showing
7 changed files
with
99 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include <imgui.h> | ||
|
||
#include "Kanan.hpp" | ||
#include "DrawDistance.hpp" | ||
|
||
namespace kanan { | ||
|
||
DrawDistance::DrawDistance() | ||
: m_distance { 25000 } | ||
, m_isEnabled { false } | ||
{ } | ||
|
||
void DrawDistance::onFrame() { | ||
auto game = g_kanan->getGame(); | ||
|
||
//get render, if no render return | ||
auto renderer = game->getRenderer(); | ||
if (renderer == nullptr) { | ||
return; | ||
} | ||
//get camera, if no camera return | ||
auto camera = renderer->camera; | ||
if (camera == nullptr) { | ||
return; | ||
} | ||
//get cameraState, if no cameraState return | ||
auto cameraState = camera->state; | ||
if (cameraState == nullptr) { | ||
return; | ||
} | ||
//if enabled set to wanted draw distance | ||
if (m_isEnabled) { | ||
cameraState->drawDistance = m_distance; | ||
} | ||
} | ||
|
||
void DrawDistance::onUI() { | ||
if (ImGui::CollapsingHeader("Draw Distance")) { | ||
ImGui::Checkbox("Enable Draw Distance", &m_isEnabled); | ||
ImGui::Text("This is likely to cause lag if too high"); | ||
ImGui::SliderFloat("Distance", &m_distance, 0.0f, 500000.0f, "%.0f"); | ||
if (ImGui::Button("Reset")) { | ||
m_distance = 25000.0f; | ||
} | ||
} | ||
} | ||
|
||
void DrawDistance::onConfigLoad(const Config& cfg) { | ||
m_distance = cfg.get<float>("DrawDistance.Vaule").value_or(25000.0f); | ||
m_isEnabled = cfg.get<bool>("DrawDistance.Enabled").value_or(m_isEnabled); | ||
} | ||
|
||
void DrawDistance::onConfigSave(Config& cfg) { | ||
cfg.set<float>("DrawDistance.Vaule", m_distance); | ||
cfg.set<bool>("DrawDistance.Enabled", m_isEnabled); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include "Mod.hpp" | ||
|
||
namespace kanan { | ||
class DrawDistance : public Mod { | ||
public: | ||
DrawDistance(); | ||
|
||
void onFrame() override; | ||
|
||
void onUI() override; | ||
|
||
void onConfigLoad(const Config& cfg) override; | ||
void onConfigSave(Config& cfg) override; | ||
|
||
private: | ||
float m_distance; | ||
bool m_isEnabled; | ||
}; | ||
} // namespace kanan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters