11#include " ClockModConfig.hpp"
22#include " ClockUpdater.hpp"
3+ #include " ClockValues.hpp"
34#include " ClockViewController.hpp"
45using namespace ClockMod ;
56
@@ -9,6 +10,7 @@ using namespace ClockMod;
910#include " bsml/shared/BSML/Components/ModalColorPicker.hpp"
1011#include " custom-types/shared/coroutine.hpp"
1112#include " custom-types/shared/macros.hpp"
13+ #include " custom-types/shared/delegate.hpp"
1214
1315#include " HMUI/CurvedTextMeshPro.hpp"
1416#include " HMUI/ScrollView.hpp"
@@ -22,6 +24,8 @@ using namespace ClockMod;
2224#include " UnityEngine/Canvas.hpp"
2325#include " UnityEngine/Color.hpp"
2426#include " UnityEngine/GameObject.hpp"
27+ #include " UnityEngine/UI/Button.hpp"
28+ #include " UnityEngine/UI/LayoutElement.hpp"
2529#include " UnityEngine/WaitForSecondsRealtime.hpp"
2630
2731
@@ -42,11 +46,17 @@ namespace ClockMod {
4246 while (SettingsOpen) {
4347 char timeInformation[45 ];
4448 strftime (timeInformation, sizeof (timeInformation), " Your Timezone - %Z UTC offset - %z" , ClockUpdater::getInstance ()->getTimeInfo ());
49+
4550 char UTCtime[40 ];
46- strftime (UTCtime, sizeof (UTCtime), std::string (" \r\n Current Time in UTC - " + ClockUpdater::getTimeFormat ()).c_str (), ClockUpdater::getInstance ()->getTimeInfoUTC ());
51+ strftime (UTCtime, sizeof (UTCtime), std::string (" \r\n Current Time in UTC - " + ClockUpdater::getTimeFormat ()).c_str (), ClockUpdater::getInstance ()->getTimeInfoUTC ());
4752 // strftime(UTCtime, sizeof(UTCtime), std::string("\r\n Current Time in UTC - " + ClockUpdater::getTimeFormat()).c_str(), gmtime(ClockUpdater::getInstance()->getRawTime()));
53+
54+ std::string sessionTime = " \n Session Time - " + ClockUpdater::getStopwatchString (ClockUpdater::getInstance ()->getSessionTimeSeconds ());
55+ std::string stopwatch1Time = " \n Stopwatch 1 Time - " + ClockUpdater::getStopwatchString (ClockUpdater::getInstance ()->getStopwatch1Seconds ());
56+ std::string stopwatch2Time = " \n Stopwatch 2 Time - " + ClockUpdater::getStopwatchString (ClockUpdater::getInstance ()->getStopwatch2Seconds ());
57+
4858 if (TimeInfo && SettingsOpen)
49- TimeInfo->set_text (std::string (timeInformation) + UTCtime);
59+ TimeInfo->set_text (std::string (timeInformation) + UTCtime + sessionTime + stopwatch1Time + stopwatch2Time );
5060 co_yield reinterpret_cast <System::Collections::IEnumerator*>(UnityEngine::WaitForSecondsRealtime::New_ctor (0.1 ));
5161 }
5262 co_return ;
@@ -67,7 +77,7 @@ namespace ClockMod {
6777 std::string timeFormat = " Your Timezone - %Z\n UTC offset - %z" ;
6878 strftime (timeInformation, sizeof (timeInformation), timeFormat.c_str (), instance->getTimeInfo ());
6979 // We have to specify sizeDelta here otherwise things will overlap
70- TimeInfo = BSML::Lite::CreateText (parent, std::string (timeInformation), TMPro::FontStyles::Normal, {0 ,0 }, {0 ,15 });
80+ TimeInfo = BSML::Lite::CreateText (parent, std::string (timeInformation), TMPro::FontStyles::Normal, {0 ,0 }, {0 ,5 * 6 });
7181 // TimeInfo = BSML::Lite::CreateText(parent, std::string(timeInformation), TMPro::FontStyles::Normal);
7282
7383 ColorPicker = BSML::Lite::CreateColorPickerModal (parent, getModConfig ().ClockColor .GetName (), getModConfig ().ClockColor .GetValue (),
@@ -83,6 +93,38 @@ namespace ClockMod {
8393 );
8494 }
8595
96+ // Could optimize these into a small lambda or #define, but there's only two as of now so it's not that big a deal
97+ auto stopwatch1PauseButton = BSML::Lite::CreateUIButton (parent, getModConfig ().Stopwatch1Paused .GetValue () ? " Start" : " Pause" , {70 , -19.9 }, {-5 , 0 }, nullptr );
98+ stopwatch1PauseButton->GetComponent <UI::LayoutElement*>()->set_ignoreLayout (true );
99+ stopwatch1PauseButton->get_transform ()->set_localScale ({0.9 , 0.9 , 0.9 });
100+ stopwatch1PauseButton->get_onClick ()->AddListener (custom_types::MakeDelegate<Events::UnityAction*>(std::function<void ()>([stopwatch1PauseButton](){
101+ getModConfig ().Stopwatch1Paused .SetValue (!getModConfig ().Stopwatch1Paused .GetValue ());
102+ if (getModConfig ().Stopwatch1Paused .GetValue ()) BSML::Lite::SetButtonText (stopwatch1PauseButton, " Start" );
103+ else BSML::Lite::SetButtonText (stopwatch1PauseButton, " Pause" );
104+ })));
105+ auto stopwatch1ResetButton = BSML::Lite::CreateUIButton (parent, " Reset" , {83.5 , -19.9 }, {-5 , 0 }, nullptr );
106+ stopwatch1ResetButton->GetComponent <UI::LayoutElement*>()->set_ignoreLayout (true );
107+ stopwatch1ResetButton->get_transform ()->set_localScale ({0.9 , 0.9 , 0.9 });
108+ stopwatch1ResetButton->get_onClick ()->AddListener (custom_types::MakeDelegate<Events::UnityAction*>(std::function<void ()>([](){
109+ if (ClockMod::ClockUpdater::getInstance ()) ClockMod::ClockUpdater::getInstance ()->resetStopwatch1 ();
110+ })));
111+
112+ auto stopwatch2PauseButton = BSML::Lite::CreateUIButton (parent, getModConfig ().Stopwatch2Paused .GetValue () ? " Start" : " Pause" , {70 , -25.5 }, {-5 , 0 }, nullptr );
113+ stopwatch2PauseButton->GetComponent <UI::LayoutElement*>()->set_ignoreLayout (true );
114+ stopwatch2PauseButton->get_transform ()->set_localScale ({0.9 , 0.9 , 0.9 });
115+ stopwatch2PauseButton->get_onClick ()->AddListener (custom_types::MakeDelegate<Events::UnityAction*>(std::function<void ()>([stopwatch2PauseButton](){
116+ getModConfig ().Stopwatch2Paused .SetValue (!getModConfig ().Stopwatch2Paused .GetValue ());
117+ if (getModConfig ().Stopwatch2Paused .GetValue ()) BSML::Lite::SetButtonText (stopwatch2PauseButton, " Start" );
118+ else BSML::Lite::SetButtonText (stopwatch2PauseButton, " Pause" );
119+ })));
120+ auto stopwatch2ResetButton = BSML::Lite::CreateUIButton (parent, " Reset" , {83.5 , -25.5 }, {-5 , 0 }, nullptr );
121+ stopwatch2ResetButton->GetComponent <UI::LayoutElement*>()->set_ignoreLayout (true );
122+ stopwatch2ResetButton->get_transform ()->set_localScale ({0.9 , 0.9 , 0.9 });
123+ stopwatch2ResetButton->get_onClick ()->AddListener (custom_types::MakeDelegate<Events::UnityAction*>(std::function<void ()>([](){
124+ if (ClockMod::ClockUpdater::getInstance ()) ClockMod::ClockUpdater::getInstance ()->resetStopwatch2 ();
125+ })));
126+
127+ AddConfigValueDropdownEnum (parent, getModConfig ().ClockType , clockTypeStrs);
86128 AddConfigValueToggle (parent, getModConfig ().InSong );
87129 AddConfigValueToggle (parent, getModConfig ().InReplay );
88130 AddConfigValueToggle (parent, getModConfig ().TwelveToggle );
0 commit comments