9
9
#include " TMPro/TextMeshProUGUI.hpp"
10
10
#include < ctime>
11
11
#include " GlobalNamespace/OVRPlugin_OVRP_1_1_0.hpp"
12
+ #include " RainbowClock.hpp" // Needed to make the Clock Rainbowy (is that actually a word?)
12
13
using namespace UnityEngine ;
13
14
using namespace TMPro ;
14
15
@@ -24,66 +25,94 @@ std::string getBatteryString(int level)
24
25
else return string_format (" <color=#ff8800>%s</color>" , percent.c_str ());
25
26
}
26
27
27
- // Updates the Clock.
28
+ // RainbowClock, makes the Clock beautiful, yeah really it does.
29
+ std::string RainbowClock::rainbowify (std::string input)
30
+ {
31
+ std::string result = " " ;
28
32
29
- void ClockMod::ClockUpdater::Update () {
30
- time_t rawtime;
31
- char timestr[20 ];
32
- struct tm * timeinfo;
33
- time (&rawtime);
34
- timeinfo = localtime (&rawtime);
35
-
36
- // TODO: Change the clock code to:
37
- // std::string getTimeString(timeInfo);
38
- // std::string result = getTimeString();
39
- //
40
- // if (batterytoggle)
41
- // {
42
- // result += " - ";
43
- // result += getBatteryString(batterylvl);
44
- // }
45
- //
46
- // text->set_text(il2cpp_utils::createcsstr(result));
47
-
48
- // Checks config Settings for 12/24 Hour time and if Show Seconds is toggled on or off.
49
-
50
- if (!getModConfig ().TwelveToggle .GetValue ()) {
51
- if (getModConfig ().SecToggle .GetValue ()) { // Check if seconds should be shown
52
- strftime (timestr, 20 , " %H:%M:%S" , timeinfo);
53
- }
54
- else {
55
- strftime (timestr, 20 , " %H:%M" , timeinfo);
56
- }
57
- }
58
- else { // If set to show 24 Hour Format
59
- if (getModConfig ().SecToggle .GetValue ()) { // Check if seconds should be shown
60
- strftime (timestr, 20 , " %l:%M:%S %p" , timeinfo);
61
- }
62
- else {
63
- strftime (timestr, 20 , " %l:%M %p" , timeinfo);
64
- };
33
+ for (auto c : input)
34
+ {
35
+ result += string_format (" <color=%s>%c</color>" , colors[rainbowIndex].c_str (), c);
36
+ rainbowIndex++;
37
+ rainbowIndex %= colors.size ();
65
38
}
66
39
67
- auto text = get_gameObject ()->GetComponent <TextMeshProUGUI*>();
68
-
69
- // Get current Battery Level
70
- if (getModConfig ().BattToggle .GetValue ()) {
71
- float batterylvl = GlobalNamespace::OVRPlugin::OVRP_1_1_0::ovrp_GetSystemBatteryLevel ();
72
- batterylvl = batterylvl * 100 ;
73
- auto batterylevel = getBatteryString ((int )batterylvl);
74
- std::string tandb = timestr;
75
- tandb += " - " ;
76
- tandb += batterylevel;
77
-
78
- text->set_text (il2cpp_utils::createcsstr (tandb));
79
- }
80
- else {
81
- text->set_text (il2cpp_utils::createcsstr (timestr));
82
- }
83
-
84
- text->set_color (getModConfig ().ClockColor .GetValue ());
85
- text->set_fontSize (getModConfig ().FontSize .GetValue ());
86
- // text->get_transform()->set_position(UnityEngine::Vector3(0 + getModConfig().ClockXOffset.GetValue(), 0.5 + getModConfig().ClockYOffset.GetValue(), 3.85 + getModConfig().ClockZOffset.GetValue()));
87
- if (Config.InMPLobby == false ) {
88
- get_transform ()->GetParent ()->set_position (UnityEngine::Vector3 (getModConfig ().ClockX .GetValue () + getModConfig ().ClockXOffset .GetValue (), getModConfig ().ClockY .GetValue () + getModConfig ().ClockYOffset .GetValue (), getModConfig ().ClockZ .GetValue () + getModConfig ().ClockZOffset .GetValue ())); }
40
+ return result;
41
+ }
42
+
43
+ // Updates the Clock.
44
+ int wait = 0 ; // Sometimes you just need to take a deep breath and slow the fuck down, I'm looking at you ClockUpdater, also probably the dumbest way to slow it down.
45
+
46
+ void ClockMod::ClockUpdater::Update () {
47
+ time_t rawtime;
48
+ char timechar[20 ];
49
+ struct tm * timeinfo;
50
+ time (&rawtime);
51
+ timeinfo = localtime (&rawtime);
52
+
53
+ if (wait == 10 ) {
54
+ wait = 0 ;
55
+
56
+ // std::string timestr; // Added this because I have to declare it
57
+
58
+ // TODO: Change the clock code to:
59
+ // std::string getTimeString(timeInfo);
60
+ // std::string result = getTimeString();
61
+ //
62
+ // if (batterytoggle)
63
+ // {
64
+ // result += " - ";
65
+ // result += getBatteryString(batterylvl);
66
+ // }
67
+ //
68
+ // text->set_text(il2cpp_utils::createcsstr(result));
69
+
70
+ // Checks config Settings for 12/24 Hour time and if Show Seconds is toggled on or off.
71
+
72
+ if (!getModConfig ().TwelveToggle .GetValue ()) {
73
+ if (getModConfig ().SecToggle .GetValue ()) { // Check if seconds should be shown
74
+ strftime (timechar, 20 , " %H:%M:%S" , timeinfo);
75
+ }
76
+ else {
77
+ strftime (timechar, 20 , " %H:%M" , timeinfo);
78
+ }
79
+ }
80
+ else { // If set to show 24 Hour Format
81
+ if (getModConfig ().SecToggle .GetValue ()) { // Check if seconds should be shown
82
+ strftime (timechar, 20 , " %l:%M:%S %p" , timeinfo);
83
+ }
84
+ else {
85
+ strftime (timechar, 20 , " %l:%M %p" , timeinfo);
86
+ };
87
+ }
88
+ std::string timestr = timechar;
89
+ if (getModConfig ().RainbowClock .GetValue ()) {
90
+ timestr = RainbowClock::rainbowify ((std::string)timestr);
91
+ };
92
+ auto text = get_gameObject ()->GetComponent <TextMeshProUGUI*>();
93
+
94
+ // Get current Battery Level
95
+ if (getModConfig ().BattToggle .GetValue ()) {
96
+ float batterylvl = GlobalNamespace::OVRPlugin::OVRP_1_1_0::ovrp_GetSystemBatteryLevel ();
97
+ batterylvl = batterylvl * 100 ;
98
+ auto batterylevel = getBatteryString ((int )batterylvl);
99
+
100
+ std::string tandb = timestr;
101
+ tandb += " - " ;
102
+ tandb += batterylevel;
103
+
104
+ text->set_text (il2cpp_utils::createcsstr (tandb));
105
+ }
106
+ else {
107
+ text->set_text (il2cpp_utils::createcsstr (timestr));
108
+ }
109
+ if (getModConfig ().RainbowClock .GetValue () == false ) {
110
+ text->set_color (getModConfig ().ClockColor .GetValue ());
111
+ };
112
+ text->set_fontSize (getModConfig ().FontSize .GetValue ());
113
+ // text->get_transform()->set_position(UnityEngine::Vector3(0 + getModConfig().ClockXOffset.GetValue(), 0.5 + getModConfig().ClockYOffset.GetValue(), 3.85 + getModConfig().ClockZOffset.GetValue()));
114
+ if (Config.InMPLobby == false ) {
115
+ get_transform ()->GetParent ()->set_position (UnityEngine::Vector3 (getModConfig ().ClockX .GetValue () + getModConfig ().ClockXOffset .GetValue (), getModConfig ().ClockY .GetValue () + getModConfig ().ClockYOffset .GetValue (), getModConfig ().ClockZ .GetValue () + getModConfig ().ClockZOffset .GetValue ()));
116
+ }
117
+ } else { wait = wait + 1 ; }
89
118
}
0 commit comments