Skip to content

Commit

Permalink
Merge pull request #26 from TTF-fog/zoom
Browse files Browse the repository at this point in the history
Toggle for zoom in scroll
  • Loading branch information
FreezeEngine authored Aug 7, 2024
2 parents ca615dc + e158bf6 commit 7e8cafb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 23 deletions.
15 changes: 13 additions & 2 deletions src/Client/Module/Modules/Zoom/Zoom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Zoom : public Module {

public:

Zoom() : Module("Zoom", "Allows you to see distant places.", IDR_MAGNIFY_PNG, "C") {
Zoom() : Module("Zoom", "Allows you to see distant places.", R"(\Flarial\assets\magnify.png)", "C") {

Module::setup();

Expand All @@ -32,6 +32,7 @@ class Zoom : public Module {
if (settings.getSettingByName<bool>("SaveModifier") == nullptr) settings.addSetting("SaveModifier", true);
if (settings.getSettingByName<bool>("hidehand") == nullptr) settings.addSetting("hidehand", true);
if (settings.getSettingByName<bool>("hidemodules") == nullptr) settings.addSetting("hidemodules", false);
if (settings.getSettingByName<bool>("UseScroll") == nullptr) settings.addSetting("UseScroll", true);
//if (settings.getSettingByName<bool>("hidehud") == nullptr) settings.addSetting("hidehud", false);
if (settings.getSettingByName<float>("modifier") == nullptr) settings.addSetting("modifier", 10.0f);
if (settings.getSettingByName<float>("anim") == nullptr) settings.addSetting("anim", 0.20f);
Expand Down Expand Up @@ -150,8 +151,18 @@ class Zoom : public Module {
"alwaysanim")->value))
this->settings.getSettingByName<bool>("alwaysanim")->value = !this->settings.getSettingByName<bool>(
"alwaysanim")->value;
toggleY += Constraints::SpacingConstraint(0.25, textWidth);

FlarialGUI::FlarialTextWithFont(toggleX + Constraints::SpacingConstraint(0.60, textWidth), toggleY,
L"Use Scroll", textWidth * 3.0f, textHeight,
DWRITE_TEXT_ALIGNMENT_LEADING,
Constraints::RelativeConstraint(0.12, "height", true),
DWRITE_FONT_WEIGHT_NORMAL);
if (FlarialGUI::Toggle(7, toggleX, toggleY, this->settings.getSettingByName<bool>(
"UseScroll")->value))
this->settings.getSettingByName<bool>("UseScroll")->value = !this->settings.getSettingByName<bool>(
"UseScroll")->value;
FlarialGUI::UnsetScrollView();

}
};
};
45 changes: 24 additions & 21 deletions src/Client/Module/Modules/Zoom/ZoomListener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,29 +75,32 @@ class ZoomListener : public Listener {
//todo make it so that modules work together
auto fovchanger = ModuleManager::getModule("FOV Changer");
auto upsidedown = ModuleManager::getModule("Upside Down");
if (this->module->settings.getSettingByName<bool>("UseScroll")->value == true) {
if (event.getAction() == MouseAction::ScrollUp) {
if ((fovchanger != nullptr &&
fovchanger->settings.getSettingByName<float>("fovvalue")->value > 180) ||
(upsidedown != nullptr && upsidedown->isEnabled()))
zoomValue += this->module->settings.getSettingByName<float>("modifier")->value;
else zoomValue -= this->module->settings.getSettingByName<float>("modifier")->value;
}
if (event.getAction() != MouseAction::ScrollUp && event.getButton() == MouseButton::Scroll) {
if ((fovchanger != nullptr &&
fovchanger->settings.getSettingByName<float>("fovvalue")->value > 180) ||
(upsidedown != nullptr && upsidedown->isEnabled()))
zoomValue -= this->module->settings.getSettingByName<float>("modifier")->value;
else zoomValue += this->module->settings.getSettingByName<float>("modifier")->value;
}

if (zoomValue < 1) zoomValue = 1;
else if (zoomValue > realFov) zoomValue = realFov;

if (event.getAction() == MouseAction::ScrollUp ||
event.getAction() != MouseAction::ScrollUp && event.getButton() == MouseButton::Scroll) {
event.setButton(MouseButton::None);
event.setAction(MouseAction::Release);

if (event.getAction() == MouseAction::ScrollUp) {
if ((fovchanger != nullptr &&
fovchanger->settings.getSettingByName<float>("fovvalue")->value > 180) ||
(upsidedown != nullptr && upsidedown->isEnabled()))
zoomValue += this->module->settings.getSettingByName<float>("modifier")->value;
else zoomValue -= this->module->settings.getSettingByName<float>("modifier")->value;
}
if (event.getAction() != MouseAction::ScrollUp && event.getButton() == MouseButton::Scroll) {
if ((fovchanger != nullptr &&
fovchanger->settings.getSettingByName<float>("fovvalue")->value > 180) ||
(upsidedown != nullptr && upsidedown->isEnabled()))
zoomValue -= this->module->settings.getSettingByName<float>("modifier")->value;
else zoomValue += this->module->settings.getSettingByName<float>("modifier")->value;
}

if (zoomValue < 1) zoomValue = 1;
else if (zoomValue > realFov) zoomValue = realFov;

if (event.getAction() == MouseAction::ScrollUp ||
event.getAction() != MouseAction::ScrollUp && event.getButton() == MouseButton::Scroll) {
event.setButton(MouseButton::None);
event.setAction(MouseAction::Release);
}
}
}
}
Expand Down

0 comments on commit 7e8cafb

Please sign in to comment.