Skip to content

Commit a3f1b87

Browse files
committed
Clean up comments and improve readability in Notifications and UI components
1 parent c0a9680 commit a3f1b87

4 files changed

Lines changed: 21 additions & 50 deletions

File tree

src/notifications/Notifications.as

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/*
21
/*
32
* =============================================================================
43
* @namespace Notifications

src/ui/UI.as

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
* Provides options to toggle UI windows and run tests.
44
*/
55
void RenderMenu() {
6+
// Only show the entry in the Plugins dropdown when it is NOT already shown on the
7+
// main menu bar (RenderMenuMain). This avoids a duplicate "Event Calendar" entry
8+
// while always leaving exactly one way to open the window.
9+
if (S_ShowCalendarInMainMenu) return;
10+
611
// Single top-level menu item that toggles the calendar window.
712
if (UI::MenuItem(Icons::CalendarO + " " + "Event Calendar", "", g_UIState.ShowCalendarWindow)) {
813
g_UIState.ShowCalendarWindow = !g_UIState.ShowCalendarWindow;
@@ -192,46 +197,6 @@ void RenderCalendarGrid() {
192197
UI::EndTable();
193198
}
194199

195-
/*
196-
* Renders the list of events for the currently selected day.
197-
*/
198-
void RenderEventList() {
199-
UI::Text("Events for: " + g_UIState.CalYear + "-" + TimeUtils::Two(g_UIState.CalMonth) + "-" + TimeUtils::Two(g_UIState.SelectedDay));
200-
201-
UI::BeginChild("EventList", vec2(0, -1), true);
202-
if (g_IsLoading) {
203-
UI::TextDisabled("Loading...");
204-
} else if (g_Events.IsEmpty()) {
205-
UI::TextDisabled("No events loaded.");
206-
} else {
207-
bool foundEvent = false;
208-
// Iterate through all events to find ones matching the selected day.
209-
string key = tostring(g_UIState.SelectedDay);
210-
if (g_MonthEventCache.Exists(key)) {
211-
array<EventItem@>@ dayList = cast<array<EventItem@>@>(g_MonthEventCache[key]);
212-
if (dayList !is null) {
213-
// Sort for display
214-
Helpers::SortEventsByStart(dayList);
215-
for (uint i = 0; i < dayList.Length; i++) {
216-
auto@ e = dayList[i];
217-
if (e is null) continue;
218-
int Y, M, D, h, m, s;
219-
TimeUtils::UtcYMDHMSFromMs(e.startMs, Y, M, D, h, m, s);
220-
string tag = e.source.Length > 0 ? ("[" + e.source + "] ") : "";
221-
string dur = e.durationSec > 0 ? (" (" + tostring(e.durationSec/60) + "m)") : "";
222-
UI::Text(Moon::PhaseEmojiForTitleLower(e.title) + " " + TimeUtils::Two(h) + ":" + TimeUtils::Two(m) + " - " + tag + e.title + dur);
223-
}
224-
foundEvent = dayList.Length > 0;
225-
}
226-
}
227-
228-
if (!foundEvent) {
229-
UI::TextDisabled("No events for this day.");
230-
}
231-
}
232-
UI::EndChild();
233-
}
234-
235200
/*
236201
* Renders a small footer at the bottom of the window for status information.
237202
*/

src/utils/Helpers.as

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ namespace Helpers {
185185
while (j >= 0) {
186186
EventItem@ prev = arr[uint(j)];
187187
int64 prevMs = prev is null ? 0 : prev.startMs;
188-
int64 keyMs = key is null ? 0 : key.startMs;
188+
int64 keyMs = key is null ? 0 : key.startMs;
189189
if (prevMs <= keyMs) break;
190190
@arr[uint(j + 1)] = prev;
191191
j--;

src/utils/Utils.as

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,19 @@ namespace Moon {
6565
* @return A color vector (RGBA).
6666
*/
6767
vec4 PhaseColorForTitleLower(const string &in t) {
68-
switch (GetPhaseKind(t)) {
69-
case PhaseKind::PK_NM: return vec4(0.5, 0.5, 0.5, 1.0); // Grey
70-
case PhaseKind::PK_FQ: return vec4(0.6, 0.6, 0.6, 1.0); // Light Grey
71-
case PhaseKind::PK_FM: return vec4(0.7, 0.7, 0.7, 1.0); // Lighter Grey
72-
case PhaseKind::PK_LQ: return vec4(0.4, 0.4, 0.4, 1.0); // Dark Grey
73-
default: return vec4(0.3, 0.3, 0.3, 1.0); // Darkest Grey (Intermediate)
68+
// Brightness follows the real illuminated fraction of the Moon's disc,
69+
// but kept in a mid range so the button text stays readable on every phase
70+
// (a near-white background would hide the light text).
71+
// Full Moon = brightest
72+
// First/Last Qtr = mid
73+
// Intermediate = darker
74+
// New Moon = darkest
75+
switch (GetPhaseKind(t)) {
76+
case PhaseKind::PK_FM: return vec4(0.62, 0.62, 0.62, 1.0); // Full Moon - brightest (still readable)
77+
case PhaseKind::PK_FQ: return vec4(0.52, 0.52, 0.52, 1.0); // First Quarter - mid
78+
case PhaseKind::PK_LQ: return vec4(0.52, 0.52, 0.52, 1.0); // Last Quarter - mid
79+
case PhaseKind::PK_NM: return vec4(0.34, 0.34, 0.34, 1.0); // New Moon - darkest
80+
default: return vec4(0.43, 0.43, 0.43, 1.0); // Intermediate - between new & quarter
7481
}
7582
}
7683

@@ -106,8 +113,8 @@ namespace TimeUtils {
106113
string FriendlyDeltaLong(int64 deltaMs) {
107114
int64 totalSeconds = Math::Abs(deltaMs) / 1000;
108115

109-
int days = int(totalSeconds / 86400); totalSeconds %= 86400;
110-
int hours = int(totalSeconds / 3600); totalSeconds %= 3600;
116+
int days = int(totalSeconds / 86400); totalSeconds %= 86400;
117+
int hours = int(totalSeconds / 3600); totalSeconds %= 3600;
111118
int minutes = int(totalSeconds / 60);
112119
int seconds = int(totalSeconds % 60);
113120

0 commit comments

Comments
 (0)