Skip to content

Commit

Permalink
Fix timezone display in config menu
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-r-elp committed May 18, 2024
1 parent 47d4d38 commit d4d6433
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
4 changes: 2 additions & 2 deletions include/ClockViewController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "custom-types/shared/coroutine.hpp"
#include "HMUI/ViewController.hpp"
#include "UnityEngine/Color.hpp"
#include "TMPro/TextMeshProUGUI.hpp"
#include "HMUI/CurvedTextMeshPro.hpp"
#include "bsml/shared/BSML/Components/ModalColorPicker.hpp"
//#include "questui/shared/BeatSaberUI.hpp"
//#include "TMPro/TextMeshProUGUI.hpp"
Expand All @@ -13,7 +13,7 @@ DECLARE_CLASS_CODEGEN(ClockMod, ClockViewController, HMUI::ViewController,
DECLARE_OVERRIDE_METHOD(void, DidDeactivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidDeactivate", 2), bool removedFromHierarchy, bool systemScreenDisabling);

DECLARE_INSTANCE_FIELD(BSML::ModalColorPicker*, ColorPicker);
DECLARE_INSTANCE_FIELD(TMPro::TextMeshProUGUI*, TimeInfo);
DECLARE_INSTANCE_FIELD(HMUI::CurvedTextMeshPro*, TimeInfo);

custom_types::Helpers::Coroutine UpdateTimeText();
bool SettingsOpen;
Expand Down
22 changes: 8 additions & 14 deletions src/ClockViewContoller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ using namespace ClockMod;
using namespace UnityEngine;
using namespace HMUI;

#if defined(REGISTER_FUNCTION) || defined(DEFINE_CLASS)
#error Outdated custom-types
#elif !defined(DEFINE_TYPE)
#error Custom-types macro missing, make sure you have ran: 'qpm-rust restore' and that you have a compatible version of custom-types
#if !defined(DEFINE_TYPE)
#error Custom-types macro missing, make sure you have ran: 'qpm restore' and that you have a compatible version of custom-types
#endif

DEFINE_TYPE(ClockMod, ClockViewController);
Expand All @@ -50,7 +48,7 @@ namespace ClockMod {
strftime(UTCtime, sizeof(UTCtime), std::string("\r\n Current Time in UTC - " + ClockUpdater::getTimeFormat()).c_str(), ClockUpdater::getInstance()->getTimeInfoUTC());
//strftime(UTCtime, sizeof(UTCtime), std::string("\r\n Current Time in UTC - " + ClockUpdater::getTimeFormat()).c_str(), gmtime(ClockUpdater::getInstance()->getRawTime()));
if (TimeInfo && SettingsOpen)
TimeInfo->set_text(il2cpp_utils::newcsstr(std::string(timeInformation) + UTCtime));
TimeInfo->set_text(std::string(timeInformation) + UTCtime);
co_yield reinterpret_cast<System::Collections::IEnumerator*>(UnityEngine::WaitForSecondsRealtime::New_ctor(0.1));
}
co_return;
Expand All @@ -70,23 +68,19 @@ namespace ClockMod {
char timeInformation[45];
std::string timeFormat = "Your Timezone - %Z\nUTC offset - %z";
strftime(timeInformation, sizeof(timeInformation), timeFormat.c_str(), instance->getTimeInfo());
// Doesnt currently work in bsml. It isnt recognized as a layoutelement for the container. Also the user can just view the time on the normal time label from this mod
// TimeInfo = BSML::Lite::CreateText(parent, timeInformation, TMPro::FontStyles::Normal);

//lastChangedColor = getModConfig().ClockColor.GetValue();
// We have to specify sizeDelta here otherwise things will overlap
TimeInfo = BSML::Lite::CreateText(parent, std::string(timeInformation), TMPro::FontStyles::Normal, {0,0}, {0,15});
// TimeInfo = BSML::Lite::CreateText(parent, std::string(timeInformation), TMPro::FontStyles::Normal);

ColorPicker = BSML::Lite::CreateColorPickerModal(parent, getModConfig().ClockColor.GetName(), getModConfig().ClockColor.GetValue(),
[instance](UnityEngine::Color value) {
//lastChangedColor = value;
getModConfig().ClockColor.SetValue(value);
},
[instance] {
instance->SetColor(getModConfig().ClockColor.GetValue());
//getModConfig().ClockColor.SetValue(lastChangedColor);
},
[instance](UnityEngine::Color value) {
instance->SetColor(value);
//getModConfig().ClockColor.SetValue(value);
instance->SetColor(value);
}
);
}
Expand Down Expand Up @@ -119,7 +113,7 @@ namespace ClockMod {
}
void ClockViewController::DidDeactivate(bool removedFromHierarchy, bool systemScreenDisabling) {
SettingsOpen = false;
//StopAllCoroutines();
StopAllCoroutines();
//Config.InSettings = false;
}
}

0 comments on commit d4d6433

Please sign in to comment.