Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated add weather changer and time changer and force lighting flash #79

Merged
merged 19 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/game/frontend/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace YimMenu
UIManager::AddSubmenu(std::make_shared<Submenus::Teleport>());
UIManager::AddSubmenu(std::make_shared<Submenus::Network>());
UIManager::AddSubmenu(std::make_shared<Submenus::Players>());
UIManager::AddSubmenu(std::make_shared<Submenus::World>());
UIManager::AddSubmenu(std::make_shared<Submenus::Settings>());
UIManager::AddSubmenu(std::make_shared<Submenus::Debug>());

Expand Down Expand Up @@ -131,4 +132,4 @@ namespace YimMenu
Menu::Font::g_ChildTitleFont = IO.Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(Fonts::MainFont), sizeof(Fonts::MainFont), Menu::Font::g_ChildTitleFontSize, &FontCfg);
UIManager::SetOptionsFont(Menu::Font::g_OptionsFont);
}
}
}
60 changes: 60 additions & 0 deletions src/game/frontend/submenus/World/weather.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a #pragma once here

#include "core/commands/LoopedCommand.hpp"
#include "game/features/Features.hpp"
#include "game/rdr/Enums.hpp"
#include "game/rdr/Natives.hpp"

inline const char* WeatherTypes[]{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe turn this into an unordered_map and i don't believe the inlining is required I could be wrong though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Keep the array
  2. Inline is required (not here in this specific case but it's a good thing to remember due to how header files work)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I will remeber the inlining. I am curious, why would an array be better here? I guess an array and unordered_map are pretty close to the same thing.


"BLIZZARD",
"CLOUDS",
"DRIZZLE",
"FOG",
"GROUNDBLIZZARD",
"HAIL",
"HIGHPRESSURE",
"HURRICANE",
"MISTY",
"OVERCAST",
"OVERCASTDARK",
"RAIN",
"SANDSTORM",
"SHOWER",
"SLEET",
"SNOW",
"SNOWLIGHT",
"SUNNY",
"THUNDER",
"THUNDERSTORM",
"WHITEOUT",
};

void ChangeWeather(const char* weather)
{
MISC::_SET_OVERRIDE_WEATHER(MISC::GET_HASH_KEY(weather));
}
void ChangeTime(int H = 12, int M = 0, int S = 0, int transition = 0, bool freeze = false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

turn into a command

Copy link
Contributor Author

@theofficialhackclean theofficialhackclean Mar 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well not everything needs to be a command for example where you play the animations you could say to make the a command so yeah i think that is fine i put every thing else as a command because i thought it was right but i don't think that the time changer has to be a command or change weather has to it can be one but at the end it doesn't have too

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do agree here, because there are not methods to pass arguments to commands(minutes, hours, etc) so that makes sense.

{
NETWORK::_NETWORK_CLOCK_TIME_OVERRIDE(H, M, S, transition, freeze);
}

namespace yimmenu
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YimMenu

{
namespace Features
{
class forcelighting: public Command
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ForceLightning <- correct case and correct spelling

{
public:
using Command::Command;

virtual void OnCall() override
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont known how this native works, but if it only works once, you could turn this into a looped command to make it happen more than just once per button press. just an idea tho

{
MISC::FORCE_LIGHTNING_FLASH();
}

};


static forcelighting _forcelighting{"forcelighting", "force lighting", "spawn lighting "};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ForceLightning

}
}
76 changes: 76 additions & 0 deletions src/game/frontend/submenus/world.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#include "world.hpp"
#include "game/backend/FiberPool.hpp"
#include "core/commands/Commands.hpp"
#include "core/commands/HotkeySystem.hpp"
#include "core/commands/LoopedCommand.hpp"
#include "game/features/World/weather.hpp"
#include "game/frontend/items/Items.hpp"
#include "game/backend/ScriptMgr.hpp"

#include <game/rdr/Natives.hpp>
#include <imgui.h> // Include for ImGui
#include <memory> // Include for std::make_shared
#include "features.hpp"

namespace yimmenu::Submenus
{
World::World() :
Submenu::Submenu("World")
{
auto main = std::make_shared<Category>("Main");
auto weather = std::make_shared<Category>("Weather");




main->AddItem(std::make_shared<ImGuiItem>([] {
static std::string hour, minute, second;
InputTextWithHint("Hour", "Enter Hour", &hour).Draw();
InputTextWithHint("Minute", "Enter Minute", &minute).Draw();
InputTextWithHint("Second", "Enter Second", &second).Draw();
if (ImGui::Button("Change Time"))
{
int h = std::stoi(hour);
int m = std::stoi(minute);
int s = std::stoi(second);
FiberPool::Push([=] {
ChangeTime(h, m, s);
});
}
}));



weather->AddItem(std::make_shared<ImGuiItem>([] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a good idea to mention that this is purely local

static const char* current_weather = WeatherTypes[0]; // Default weather
if (ImGui::BeginCombo("Weather Types", current_weather))
{
for (auto& weather_type : WeatherTypes)
{
bool is_selected = (current_weather == weather_type);
if (ImGui::Selectable(weather_type, is_selected))
{
current_weather = weather_type;
FiberPool::Push([=] {

ChangeWeather(weather_type);
});
}
if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
}));


main->AddItem(std::make_shared<CommandItem>("forcelighting"_J));
AddCategory(std::move(main));
AddCategory(std::move(weather));




}

}
11 changes: 11 additions & 0 deletions src/game/frontend/submenus/world.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once
#include "core/frontend/manager/UIManager.hpp"

namespace yimmenu::Submenus
{
class World : public Submenu
{
public:
World();
};
}