ProfileChanger.cpp 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. #include "ProfileChanger.h"
  2. namespace cheat {
  3. static void onUpdate_1(app::GameManager* __this, app::MethodInfo* method);
  4. app::Button_1* ProfilePage(app::MonoInLevelPlayerProfilePage* __this, app::MethodInfo* method);
  5. ProfileChanger::ProfileChanger() : Function() {
  6. f_Enabled = config::getValue("functions:ProfileChanger", "enabled", false);
  7. f_EnabledUid = config::getValue("functions:ProfileChanger:UID", "enabled", false);
  8. f_Uid = config::getValue<std::string>("functions:ProfileChanger:UID", "value", "");
  9. f_UidSize = config::getValue("functions:ProfileChanger:UID", "size", 14);
  10. f_UidPosX = config::getValue("functions:ProfileChanger:UID", "posX", static_cast<float>(app::Screen_get_width(nullptr) * 0.96875f));
  11. f_UidPosY = config::getValue("functions:ProfileChanger:UID", "posY", 0.0f);
  12. f_EnabledName = config::getValue("functions:ProfileChanger:Name", "enabled", false);
  13. f_Name = config::getValue<std::string>("functions:ProfileChanger:Name", "value", "");
  14. f_EnabledLevel = config::getValue("functions:ProfileChanger:Level", "enabled", false);
  15. f_Level = config::getValue<std::string>("functions:ProfileChanger:Level", "value", "");
  16. f_EnabledWorldLevel = config::getValue("functions:ProfileChanger:WorldLevel", "enabled", false);
  17. f_WorldLevel = config::getValue<std::string>("functions:ProfileChanger:WorldLevel", "value", "");
  18. f_EnabledBirthday = config::getValue("functions:ProfileChanger:Birthday", "enabled", false);
  19. f_Birthday = config::getValue<std::string>("functions:ProfileChanger:Birthday", "value", "");
  20. f_EnabledSignature = config::getValue("functions:ProfileChanger:Signature", "enabled", false);
  21. f_Signature = config::getValue<std::string>("functions:ProfileChanger:Signature", "value", "");
  22. f_EnabledExp = config::getValue("functions:ProfileChanger:Exp", "enabled", false);
  23. f_CurrentExp = config::getValue("functions:ProfileChanger:Exp", "current", 1);
  24. f_MaxExp = config::getValue("functions:ProfileChanger:Exp", "max", 1);
  25. f_EnabledExpBar = config::getValue("functions:ProfileChanger:ExpBar", "enabled", false);
  26. f_ExpBar = config::getValue("functions:ProfileChanger:ExpBar", "value", 20.0f);
  27. f_Hotkey = Hotkey("functions:ProfileChanger");
  28. HookManager::install(app::GameManager_Update, onUpdate_1);
  29. HookManager::install(app::ProfilePage, ProfilePage);
  30. }
  31. ProfileChanger& ProfileChanger::getInstance() {
  32. static ProfileChanger instance;
  33. return instance;
  34. }
  35. void ProfileChanger::GUI() {
  36. ConfigCheckbox(_("PROFILE_CHANGER_TITLE"), f_Enabled, _("PROFILE_CHANGER_DESCRIPTION"));
  37. if (f_Enabled.getValue()) {
  38. ImGui::Indent();
  39. ConfigCheckbox(_("UID_TITLE"), f_EnabledUid, _("UID_DESCRIPTION"));
  40. if (f_EnabledUid.getValue()) {
  41. ConfigInputText(_("UID_VALUE_TITLE"), f_Uid);
  42. ConfigSliderInt(_("UID_SIZE_TITLE"), f_UidSize, 1, 500, _("UID_SIZE_DESCRIPTION"));
  43. ConfigSliderFloat(_("UID_POS_X_TITLE"), f_UidPosX, 1.0f, static_cast<float>(app::Screen_get_width(nullptr)), _("UID_POS_X_DESCRIPTION"));
  44. ConfigSliderFloat(_("UID_POS_Y_TITLE"), f_UidPosY, 1.0f, static_cast<float>(app::Screen_get_height(nullptr)), _("UID_POS_Y_DESCRIPTION"));
  45. }
  46. ConfigCheckbox(_("NAME_TITLE"), f_EnabledName, _("NAME_DESCRIPTION"));
  47. if (f_EnabledName.getValue())
  48. ConfigInputText(_("NAME_VALUE_TITLE"), f_Name);
  49. ConfigCheckbox(_("LEVEL_TITLE"), f_EnabledLevel, _("LEVEL_DESCRIPTION"));
  50. if (f_EnabledLevel.getValue())
  51. ConfigInputText(_("LEVEL_VALUE_TITLE"), f_Level);
  52. ConfigCheckbox(_("WORLDLEVEL_TITLE"), f_EnabledWorldLevel, _("WORLDLEVEL_DESCRIPTION"));
  53. if (f_EnabledWorldLevel.getValue())
  54. ConfigInputText(_("WORLDLEVEL_VALUE_TITLE"), f_WorldLevel);
  55. ConfigCheckbox(_("BIRTHDAY_TITLE"), f_EnabledBirthday, _("BIRTHDAY_DESCRIPTION"));
  56. if (f_EnabledBirthday.getValue())
  57. ConfigInputText(_("BIRTHDAY_VALUE_TITLE"), f_Birthday);
  58. ConfigCheckbox(_("SIGNATURE_TITLE"), f_EnabledSignature, _("SIGNATURE_DESCRIPTION"));
  59. if (f_EnabledSignature.getValue())
  60. ConfigInputText(_("SIGNATURE_VALUE_TITLE"), f_Signature);
  61. ConfigCheckbox(_("EXP_TITLE"), f_EnabledExp, _("EXP_DESCRIPTION"));
  62. if (f_EnabledExp.getValue()) {
  63. ConfigDragInt(_("EXP_CURRENT_VALUE_TITLE"), f_CurrentExp, 2, 1, INT32_MAX);
  64. ConfigDragInt(_("EXP_MAX_VALUE_TITLE"), f_MaxExp, 2, 1, INT32_MAX);
  65. }
  66. ConfigCheckbox(_("EXPBAR_TITLE"), f_EnabledExpBar, _("EXPBAR_DESCRIPTION"));
  67. if (f_EnabledExpBar.getValue())
  68. ConfigSliderFloat(_("EXPBAR_VALUE_TITLE"), f_ExpBar, 1.0f, 100.0f);
  69. f_Hotkey.Draw();
  70. ImGui::Unindent();
  71. }
  72. }
  73. void ProfileChanger::Outer() {
  74. if (f_Hotkey.IsPressed())
  75. f_Enabled.setValue(!f_Enabled.getValue());
  76. }
  77. void ProfileChanger::Status() {
  78. if (f_Enabled.getValue())
  79. ImGui::Text(_("PROFILE_CHANGER_TITLE"));
  80. }
  81. std::string ProfileChanger::getModule() {
  82. return _("MODULE_VISUALS");
  83. }
  84. app::GameObject* uidTextObj;
  85. app::Component_1* uidTextComp;
  86. void onUpdate_1(app::GameManager* __this, app::MethodInfo* method) {
  87. auto& profileChanger = ProfileChanger::getInstance();
  88. if (profileChanger.f_Enabled.getValue()) {
  89. if (profileChanger.f_EnabledUid.getValue()) {
  90. std::string value = profileChanger.f_Uid.getValue();
  91. if (uidTextObj == nullptr)
  92. uidTextObj = app::GameObject_Find(string_to_il2cppi("/BetaWatermarkCanvas(Clone)/Panel/TxtUID"));
  93. if (uidTextObj != nullptr && uidTextComp == nullptr)
  94. uidTextComp = app::GameObject_GetComponentByName(uidTextObj, string_to_il2cppi("Text"));
  95. app::Text_set_text(reinterpret_cast<app::Text*>(uidTextComp), string_to_il2cppi(value.empty() ? "" : value));
  96. auto transformWatermark = app::GameObject_get_transform(uidTextObj);
  97. if (transformWatermark) {
  98. app::Vector3 uidPos = { profileChanger.f_UidPosX.getValue(), profileChanger.f_UidPosY.getValue(), 0 };
  99. app::Text_set_alignment(reinterpret_cast<app::Text*>(uidTextComp), app::TextAnchor__Enum::LowerRight);
  100. app::Text_set_horizontalOverflow(reinterpret_cast<app::Text*>(uidTextComp), app::HorizontalWrapMode__Enum::Overflow);
  101. app::Text_set_verticalOverflow(reinterpret_cast<app::Text*>(uidTextComp), app::VerticalWrapMode__Enum::Overflow);
  102. app::Text_set_resizeTextForBestFit(reinterpret_cast<app::Text*>(uidTextComp), false);
  103. app::Text_set_fontSize(reinterpret_cast<app::Text*>(uidTextComp), profileChanger.f_UidSize.getValue());
  104. app::Transform_set_position(transformWatermark, uidPos);
  105. }
  106. }
  107. }
  108. CALL_ORIGIN(onUpdate_1, __this, method);
  109. }
  110. app::Button_1* ProfilePage(app::MonoInLevelPlayerProfilePage* __this, app::MethodInfo* method) {
  111. auto& profileChanger = ProfileChanger::getInstance();
  112. if (profileChanger.f_Enabled.getValue()) {
  113. if (profileChanger.f_EnabledUid.getValue())
  114. app::Text_set_text(__this->fields._playerID, string_to_il2cppi(profileChanger.f_Uid.getValue()));
  115. if (profileChanger.f_EnabledName.getValue())
  116. app::Text_set_text(__this->fields._playerName, string_to_il2cppi(profileChanger.f_Name.getValue()));
  117. if (profileChanger.f_EnabledLevel.getValue())
  118. app::Text_set_text(__this->fields._playerLv, string_to_il2cppi(profileChanger.f_Level.getValue()));
  119. if (profileChanger.f_EnabledWorldLevel.getValue())
  120. app::Text_set_text(__this->fields._playerWorldLv, string_to_il2cppi(profileChanger.f_WorldLevel.getValue()));
  121. if (profileChanger.f_EnabledBirthday.getValue())
  122. app::Text_set_text(__this->fields._playerBirthday, string_to_il2cppi(profileChanger.f_Birthday.getValue()));
  123. if (profileChanger.f_EnabledSignature.getValue())
  124. app::Text_set_text(__this->fields._playerSignature, string_to_il2cppi(profileChanger.f_Signature.getValue()));
  125. if (profileChanger.f_EnabledExp.getValue()) {
  126. std::string CurExpStr = std::to_string(profileChanger.f_CurrentExp.getValue());
  127. std::string MaxExpStr = std::to_string(profileChanger.f_MaxExp.getValue());
  128. app::Text_set_text(__this->fields._playerExp, string_to_il2cppi(CurExpStr + "/" + MaxExpStr));
  129. if (profileChanger.f_EnabledExpBar.getValue()) {
  130. app::Slider_1_set_minValue(__this->fields._playerExpSlider, 1.0f);
  131. app::Slider_1_set_maxValue(__this->fields._playerExpSlider, 100.0f);
  132. app::Slider_1_set_value(__this->fields._playerExpSlider, profileChanger.f_ExpBar.getValue());
  133. }
  134. }
  135. }
  136. return CALL_ORIGIN(ProfilePage, __this, method);
  137. }
  138. }