HideUI.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include "HideUI.h"
  2. namespace cheat {
  3. static void onUpdate_4(app::GameManager* __this, app::MethodInfo* method);
  4. HideUI::HideUI() : Function() {
  5. f_Enabled = config::getValue("functions:HideUI", "enabled", false);
  6. f_Hotkey = Hotkey("functions:HideUI");
  7. HookManager::install(app::GameManager_Update, onUpdate_4);
  8. }
  9. HideUI& HideUI::getInstance() {
  10. static HideUI instance;
  11. return instance;
  12. }
  13. void HideUI::GUI() {
  14. ConfigCheckbox(_("HIDE_UI_TITLE"), f_Enabled, _("HIDE_UI_DESCRIPTION"));
  15. if (f_Enabled.getValue()) {
  16. ImGui::Indent();
  17. f_Hotkey.Draw();
  18. ImGui::Unindent();
  19. }
  20. }
  21. void HideUI::Outer() {
  22. if (f_Hotkey.IsPressed())
  23. f_Enabled.setValue(!f_Enabled.getValue());
  24. }
  25. void HideUI::Status() {
  26. if (f_Enabled.getValue())
  27. ImGui::Text(_("HIDE_UI_TITLE"));
  28. }
  29. std::string HideUI::getModule() {
  30. return _("MODULE_VISUALS");
  31. }
  32. app::GameObject* ui_camera{};
  33. void onUpdate_4(app::GameManager* __this, app::MethodInfo* method) {
  34. auto& hideUI = HideUI::getInstance();
  35. if (hideUI.f_Enabled.getValue()) {
  36. if (ui_camera == nullptr)
  37. ui_camera = app::GameObject_Find(string_to_il2cppi("/UICamera"));
  38. if (ui_camera->fields._.m_CachedPtr != nullptr)
  39. app::GameObject_SetActive(ui_camera, false);
  40. }
  41. else {
  42. if (ui_camera) {
  43. if (ui_camera->fields._.m_CachedPtr != nullptr)
  44. app::GameObject_SetActive(ui_camera, true);
  45. ui_camera = nullptr;
  46. }
  47. }
  48. CALL_ORIGIN(onUpdate_4, __this, method);
  49. }
  50. }