Skip to content

Commit

Permalink
added customization when an event starts and ends
Browse files Browse the repository at this point in the history
  • Loading branch information
NinSam committed Jan 2, 2025
1 parent b426265 commit 82be81d
Show file tree
Hide file tree
Showing 7 changed files with 312 additions and 155 deletions.
11 changes: 6 additions & 5 deletions about.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ Adds a <cy>Day</c> & <cb>Night</c> System in the GD menus!

Events:

- Sunrise: 7am-8am (7:00-8:00)
- Normal: 8am-6pm (8:00-18:00)
- Sunset: 6pm-7pm (18:00-19:00)
- Night: 7pm-9pm (19:00-21:00)
- Dark: 9pm-7am (21:00-7:00)
- Sunrise
- Sunset
- Night
- Dark

You can customize when events start and end in the settings.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v1.1.0

- Added customization when an event starts and ends

## v1.0.2

- Added Dark Overlay to LikeItemLayer and RateStarsLayer
Expand Down
150 changes: 149 additions & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"id": "ninsam.day_and_night_system",
"name": "Day & Night System",
"version": "v1.0.2",
"version": "v1.1.0",
"developer": "NinSam",
"description": "Adds a day and night system in the GD menus!",
"dependencies":[
Expand All @@ -27,6 +27,154 @@
},
"settings":{

"time-settings":{
"name": "Customize Time",
"type": "title"
},
"start-sunrise-hr":{
"name": "Start Sunrise Hr",
"type": "int",
"default": 7,
"min": 0,
"max": 24,
"description": "Keep in mind this uses military time. Example: 1pm = 13 <cr>Do not override the values with other events! Example: Sunset 7pm-8pm, Night 6pm-8pm</c>",
"enable-if": "enable-sunrise"
},
"start-sunrise-min":{
"name": "Start Sunrise Min",
"type": "int",
"default": 0,
"min": 0,
"max": 59,
"description": "Keep in mind this uses military time. Example: 1pm = 13 <cr>Do not override the values with other events! Example: Sunset 7pm-8pm, Night 6pm-8pm</c>",
"enable-if": "enable-sunrise"
},
"end-sunrise-hr":{
"name": "End Sunrise Hr",
"type": "int",
"default": 8,
"min": 0,
"max": 24,
"description": "Keep in mind this uses military time. Example: 1pm = 13 <cr>Do not override the values with other events! Example: Sunset 7pm-8pm, Night 6pm-8pm</c>",
"enable-if": "enable-sunrise"
},
"end-sunrise-min":{
"name": "End Sunrise Min",
"type": "int",
"default": 0,
"min": 0,
"max": 59,
"description": "Keep in mind this uses military time. Example: 1pm = 13 <cr>Do not override the values with other events! Example: Sunset 7pm-8pm, Night 6pm-8pm</c>",
"enable-if": "enable-sunrise"
},
"start-sunset-hr":{
"name": "Start Sunset Hr",
"type": "int",
"default": 18,
"min": 0,
"max": 24,
"description": "Keep in mind this uses military time. Example: 1pm = 13 <cr>Do not override the values with other events! Example: Sunset 7pm-8pm, Night 6pm-8pm</c>",
"enable-if": "enable-sunset"
},
"start-sunset-min":{
"name": "Start Sunset Min",
"type": "int",
"default": 0,
"min": 0,
"max": 59,
"description": "Keep in mind this uses military time. Example: 1pm = 13 <cr>Do not override the values with other events! Example: Sunset 7pm-8pm, Night 6pm-8pm</c>",
"enable-if": "enable-sunset"
},
"end-sunset-hr":{
"name": "End Sunset Hr",
"type": "int",
"default": 19,
"min": 0,
"max": 24,
"description": "Keep in mind this uses military time. Example: 1pm = 13 <cr>Do not override the values with other events! Example: Sunset 7pm-8pm, Night 6pm-8pm</c>",
"enable-if": "enable-sunset"
},
"end-sunset-min":{
"name": "End Sunset Min",
"type": "int",
"default": 0,
"min": 0,
"max": 59,
"description": "Keep in mind this uses military time. Example: 1pm = 13 <cr>Do not override the values with other events! Example: Sunset 7pm-8pm, Night 6pm-8pm</c>",
"enable-if": "enable-sunset"
},
"start-night-hr":{
"name": "Start Night Hr",
"type": "int",
"default": 19,
"min": 0,
"max": 24,
"description": "Keep in mind this uses military time. Example: 1pm = 13 <cr>Do not override the values with other events! Example: Sunset 7pm-8pm, Night 6pm-8pm</c>",
"enable-if": "enable-night"
},
"start-night-min":{
"name": "Start Night Min",
"type": "int",
"default": 0,
"min": 0,
"max": 59,
"description": "Keep in mind this uses military time. Example: 1pm = 13 <cr>Do not override the values with other events! Example: Sunset 7pm-8pm, Night 6pm-8pm</c>",
"enable-if": "enable-night"
},
"end-night-hr":{
"name": "End Night Hr",
"type": "int",
"default": 21,
"min": 0,
"max": 24,
"description": "Keep in mind this uses military time. Example: 1pm = 13 <cr>Do not override the values with other events! Example: Sunset 7pm-8pm, Night 6pm-8pm</c>",
"enable-if": "enable-night"
},
"end-night-min":{
"name": "End Night Min",
"type": "int",
"default": 0,
"min": 0,
"max": 59,
"description": "Keep in mind this uses military time. Example: 1pm = 13 <cr>Do not override the values with other events! Example: Sunset 7pm-8pm, Night 6pm-8pm</c>",
"enable-if": "enable-night"
},
"start-dark-hr":{
"name": "Start Dark Hr",
"type": "int",
"default": 21,
"min": 0,
"max": 24,
"description": "Keep in mind this uses military time. Example: 1pm = 13 <cr>Do not override the values with other events! Example: Sunset 7pm-8pm, Night 6pm-8pm</c>",
"enable-if": "enable-dark"
},
"start-dark-min":{
"name": "Start Dark Min",
"type": "int",
"default": 0,
"min": 0,
"max": 59,
"description": "Keep in mind this uses military time. Example: 1pm = 13 <cr>Do not override the values with other events! Example: Sunset 7pm-8pm, Night 6pm-8pm</c>",
"enable-if": "enable-dark"
},
"end-dark-hr":{
"name": "End Dark Hr",
"type": "int",
"default": 7,
"min": 0,
"max": 24,
"description": "Keep in mind this uses military time. Example: 1pm = 13 <cr>Do not override the values with other events! Example: Sunset 7pm-8pm, Night 6pm-8pm</c>",
"enable-if": "enable-dark"
},
"end-dark-min":{
"name": "End Dark Min",
"type": "int",
"default": 0,
"min": 0,
"max": 59,
"description": "Keep in mind this uses military time. Example: 1pm = 13 <cr>Do not override the values with other events! Example: Sunset 7pm-8pm, Night 6pm-8pm</c>",
"enable-if": "enable-dark"
},
"main-settings":{
"name": "Events",
"type": "title"
Expand Down
62 changes: 32 additions & 30 deletions src/EditLevelLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,36 @@ class $modify(EditLevelLayer) {
const int hr = localTime->tm_hour;
const int min = localTime->tm_min;

const int startHr_morning = 7; // start 7am
const int startMin_morning = 0;
const int endHr_morning = 8; // end 8am
const int endMin_morning = 0;

const int startHr_sunset = 18; // start 6pm
const int startMin_sunset = 0;
const int endHr_sunset = 19; // end 7pm
const int endMin_sunset = 0;

const int startHr_night = 19; // start 7pm
const int startMin_night = 0;
const int endHr_night = 21; // end 9pm
const int endMin_night = 0;

const int startHr_fullnight = 21; // start 9pm
const int startMin_fullnight = 0;
const int endHr_fullnight = 24;
const int endMin_fullnight = 0;

// bugfix (idk why it breaks past midnight)

const int startHr_fullnightfix = 0;
const int startMin_fullnightfix = 0;
const int endHr_fullnightfix = 7; // end 7am
const int endMin_fullnightfix = 0;

if ((hr > startHr_morning || (hr == startHr_morning && min >= startMin_morning)) && (hr < endHr_morning || (hr == endHr_morning && min < endMin_morning))){
const int endhrdarkbugfix = 24;
const int endmindarkbugfix = 0;

const int starthrdarkbugfix = 0;
const int startmindarkbugfix = 0;


auto startsunrisehr = Mod::get()->getSettingValue<int64_t>("start-sunrise-hr");
auto startsunrisemin = Mod::get()->getSettingValue<int64_t>("start-sunrise-min");
auto endsunrisehr = Mod::get()->getSettingValue<int64_t>("end-sunrise-hr");
auto endsunrisemin = Mod::get()->getSettingValue<int64_t>("end-sunrise-min");

auto startsunsethr = Mod::get()->getSettingValue<int64_t>("start-sunset-hr");
auto startsunsetmin = Mod::get()->getSettingValue<int64_t>("start-sunset-min");
auto endsunsethr = Mod::get()->getSettingValue<int64_t>("end-sunset-hr");
auto endsunsetmin = Mod::get()->getSettingValue<int64_t>("end-sunset-min");

auto startnighthr = Mod::get()->getSettingValue<int64_t>("start-night-hr");
auto startnightmin = Mod::get()->getSettingValue<int64_t>("start-night-min");
auto endnighthr = Mod::get()->getSettingValue<int64_t>("end-night-hr");
auto endnightmin = Mod::get()->getSettingValue<int64_t>("end-night-min");

auto startdarkhr = Mod::get()->getSettingValue<int64_t>("start-sunset-hr");
auto startdarkmin = Mod::get()->getSettingValue<int64_t>("start-dark-min");
auto enddarkhr = Mod::get()->getSettingValue<int64_t>("end-dark-hr");
auto enddarkmin = Mod::get()->getSettingValue<int64_t>("end-dark-min");

if ((hr > startsunrisehr || (hr == startsunrisehr && min >= startsunrisemin)) && (hr < endsunrisehr || (hr == endsunrisehr && min < endsunrisemin))){

if (Mod::get()->getSettingValue<bool>("enable-sunrise")){

Expand Down Expand Up @@ -80,7 +82,7 @@ class $modify(EditLevelLayer) {
}

}
else if ((hr > startHr_sunset || (hr == startHr_sunset && min >= startMin_sunset)) && (hr < endHr_sunset || (hr == endHr_sunset && min < endMin_sunset))){
else if ((hr > startsunsethr || (hr == startsunsethr && min >= startsunsetmin)) && (hr < endsunsethr || (hr == endsunsethr && min < endsunsetmin))){

if (Mod::get()->getSettingValue<bool>("enable-sunset")){

Expand Down Expand Up @@ -116,7 +118,7 @@ class $modify(EditLevelLayer) {
}

}
else if ((hr > startHr_night || (hr == startHr_night && min >= startMin_night)) && (hr < endHr_night || (hr == endHr_night && min < endMin_night))){
else if ((hr > startnighthr || (hr == startnighthr && min >= startnightmin)) && (hr < endnighthr || (hr == endnighthr && min < endnightmin))){

if (Mod::get()->getSettingValue<bool>("enable-night")){

Expand Down Expand Up @@ -155,7 +157,7 @@ class $modify(EditLevelLayer) {

}
}
else if ((hr > startHr_fullnight || (hr == startHr_fullnight && min >= startMin_fullnight)) && (hr < endHr_fullnight || (hr == endHr_fullnight && min < endMin_fullnight))){
else if ((hr > startdarkhr || (hr == startdarkhr && min >= startdarkmin)) && (hr < endhrdarkbugfix || (hr == endhrdarkbugfix && min < endmindarkbugfix))){

if (Mod::get()->getSettingValue<bool>("enable-dark")){

Expand Down Expand Up @@ -195,7 +197,7 @@ class $modify(EditLevelLayer) {

}
}
else if ((hr > startHr_fullnightfix || (hr == startHr_fullnightfix && min >= startMin_fullnightfix)) && (hr < endHr_fullnightfix || (hr == endHr_fullnightfix && min < endMin_fullnightfix))){
else if ((hr > starthrdarkbugfix || (hr == starthrdarkbugfix && min >= startmindarkbugfix)) && (hr < enddarkhr || (hr == enddarkhr && min < enddarkmin))){

if (Mod::get()->getSettingValue<bool>("enable-dark")){

Expand Down
62 changes: 32 additions & 30 deletions src/LevelAreaLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,36 @@ class $modify(LevelAreaLayer) {
const int hr = localTime->tm_hour;
const int min = localTime->tm_min;

const int startHr_morning = 7; // start 7am
const int startMin_morning = 0;
const int endHr_morning = 8; // end 8am
const int endMin_morning = 0;

const int startHr_sunset = 18; // start 6pm
const int startMin_sunset = 0;
const int endHr_sunset = 19; // end 7pm
const int endMin_sunset = 0;

const int startHr_night = 19; // start 7pm
const int startMin_night = 0;
const int endHr_night = 21; // end 9pm
const int endMin_night = 0;

const int startHr_fullnight = 21; // start 9pm
const int startMin_fullnight = 0;
const int endHr_fullnight = 24;
const int endMin_fullnight = 0;

// bugfix (idk why it breaks past midnight)

const int startHr_fullnightfix = 0;
const int startMin_fullnightfix = 0;
const int endHr_fullnightfix = 7; // end 7am
const int endMin_fullnightfix = 0;

if ((hr > startHr_morning || (hr == startHr_morning && min >= startMin_morning)) && (hr < endHr_morning || (hr == endHr_morning && min < endMin_morning))){
const int endhrdarkbugfix = 24;
const int endmindarkbugfix = 0;

const int starthrdarkbugfix = 0;
const int startmindarkbugfix = 0;


auto startsunrisehr = Mod::get()->getSettingValue<int64_t>("start-sunrise-hr");
auto startsunrisemin = Mod::get()->getSettingValue<int64_t>("start-sunrise-min");
auto endsunrisehr = Mod::get()->getSettingValue<int64_t>("end-sunrise-hr");
auto endsunrisemin = Mod::get()->getSettingValue<int64_t>("end-sunrise-min");

auto startsunsethr = Mod::get()->getSettingValue<int64_t>("start-sunset-hr");
auto startsunsetmin = Mod::get()->getSettingValue<int64_t>("start-sunset-min");
auto endsunsethr = Mod::get()->getSettingValue<int64_t>("end-sunset-hr");
auto endsunsetmin = Mod::get()->getSettingValue<int64_t>("end-sunset-min");

auto startnighthr = Mod::get()->getSettingValue<int64_t>("start-night-hr");
auto startnightmin = Mod::get()->getSettingValue<int64_t>("start-night-min");
auto endnighthr = Mod::get()->getSettingValue<int64_t>("end-night-hr");
auto endnightmin = Mod::get()->getSettingValue<int64_t>("end-night-min");

auto startdarkhr = Mod::get()->getSettingValue<int64_t>("start-sunset-hr");
auto startdarkmin = Mod::get()->getSettingValue<int64_t>("start-dark-min");
auto enddarkhr = Mod::get()->getSettingValue<int64_t>("end-dark-hr");
auto enddarkmin = Mod::get()->getSettingValue<int64_t>("end-dark-min");

if ((hr > startsunrisehr || (hr == startsunrisehr && min >= startsunrisemin)) && (hr < endsunrisehr || (hr == endsunrisehr && min < endsunrisemin))){

if (Mod::get()->getSettingValue<bool>("enable-sunrise")){

Expand Down Expand Up @@ -75,7 +77,7 @@ class $modify(LevelAreaLayer) {
}

}
else if ((hr > startHr_sunset || (hr == startHr_sunset && min >= startMin_sunset)) && (hr < endHr_sunset || (hr == endHr_sunset && min < endMin_sunset))){
else if ((hr > startsunsethr || (hr == startsunsethr && min >= startsunsetmin)) && (hr < endsunsethr || (hr == endsunsethr && min < endsunsetmin))){

if (Mod::get()->getSettingValue<bool>("enable-sunset")){

Expand Down Expand Up @@ -107,7 +109,7 @@ class $modify(LevelAreaLayer) {
}

}
else if ((hr > startHr_night || (hr == startHr_night && min >= startMin_night)) && (hr < endHr_night || (hr == endHr_night && min < endMin_night))){
else if ((hr > startnighthr || (hr == startnighthr && min >= startnightmin)) && (hr < endnighthr || (hr == endnighthr && min < endnightmin))){

if (Mod::get()->getSettingValue<bool>("enable-night")){

Expand Down Expand Up @@ -174,7 +176,7 @@ class $modify(LevelAreaLayer) {
}

}
else if ((hr > startHr_fullnight || (hr == startHr_fullnight && min >= startMin_fullnight)) && (hr < endHr_fullnight || (hr == endHr_fullnight && min < endMin_fullnight))){
else if ((hr > startdarkhr || (hr == startdarkhr && min >= startdarkmin)) && (hr < endhrdarkbugfix || (hr == endhrdarkbugfix && min < endmindarkbugfix))){

if (Mod::get()->getSettingValue<bool>("enable-dark")){

Expand Down Expand Up @@ -240,7 +242,7 @@ class $modify(LevelAreaLayer) {

}
}
else if ((hr > startHr_fullnightfix || (hr == startHr_fullnightfix && min >= startMin_fullnightfix)) && (hr < endHr_fullnightfix || (hr == endHr_fullnightfix && min < endMin_fullnightfix))){
else if ((hr > starthrdarkbugfix || (hr == starthrdarkbugfix && min >= startmindarkbugfix)) && (hr < enddarkhr || (hr == enddarkhr && min < enddarkmin))){

if (Mod::get()->getSettingValue<bool>("enable-dark")){

Expand Down
Loading

0 comments on commit 82be81d

Please sign in to comment.