Skip to content

Commit 2076016

Browse files
committed
New update
1 parent e69a973 commit 2076016

File tree

11 files changed

+335
-179
lines changed

11 files changed

+335
-179
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,29 @@ add some special flair to your splashes.
3939
| \_\_PLAYER\_USERNAME\_\_ | The GD account username of the user |
4040
| \_\_RANDOM\_\_ | Random number between 0 and 100 |
4141

42+
## Keywords (Date Range)
43+
The most recent addition to the family! There are currently only two keywords.
44+
These keywords denote the start and end of a *date range*. A date range is a selection
45+
of splashes that will only appear when the system clock of the user is within the
46+
specified range of dates where the date represents midnight of the specified day.
47+
48+
For example:
49+
```
50+
.DATERANGE 01-01 01-02
51+
This splash can only appear on New Years!
52+
./DATERANGE
53+
```
54+
55+
Currently `.(/)DATERANGE` is the only keyword.
56+
It is specified by using a dot (.) to indicate it is a keyword, then the keyword
57+
itself (DATERANGE), when you want to end use of a date range, use the `DATERANGE`
58+
keyword with a leading slash `./DATERANGE`. Additionally, you can nest date ranges
59+
so only when the user is within *all* ranges can the splash appear.
60+
61+
> [!NOTE]
62+
> For date ranges where the start of the range is *after* the end of the range,
63+
> the end of the range is assumed to be in the following year. So, `09-01 01-01`
64+
> is implcitily `09-01-CurrentYear 09-01-NextYear`
65+
4266
# Contributing
4367
If you want to make this project better, just make a PR! :D

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 1.4.0
2+
- Added Date Ranges to splashes.
3+
- Added new festive Christmas splashes (In effect Dec. 15-25).
4+
- Added new happy New Years splashes (In effect Jan. 1).
5+
- Added new joyous Valentine's Day splashes (In effect Feb. 14).
6+
17
# 1.3.0
28
- Added option to disable default splashes.
39

mod.json

Lines changed: 66 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,75 @@
11
{
2-
"geode": "4.6.1",
3-
"gd": {
4-
"win": "2.2074",
5-
"android": "2.2074",
6-
"mac": "2.2074",
7-
"ios": "2.2074"
8-
},
9-
"id": "alphii.gd-splash-text",
10-
"name": "Splash Text!",
11-
"version": "v1.3.0",
12-
"developer": "Alphii",
13-
"description": "Minecraft-style splashes in the main menu!",
14-
"tags": ["enhancement", "offline"],
15-
"links": {
16-
"community": "https://discord.gg/tVPtwJexSX",
17-
"source": "https://github.com/AlphiiGD/Splash-Text"
18-
},
19-
"resources": {
20-
"files": [
21-
"resources/*.splash"
22-
]
23-
},
24-
"settings": {
25-
"extra-splash-file": {
26-
"type": "file",
27-
"name": "Extra Splashes",
28-
"platforms": ["android", "win", "mac"],
29-
"description": "Additional splash texts, one per line. Restart your game to apply. See more info about writing these on the GitHub page!",
30-
"default": {
31-
"win": "",
32-
"mac": "",
33-
"android": ""
34-
},
35-
"control": {
36-
"dialog": "open",
37-
"filters": [
38-
{
39-
"files": ["*.splash", "*.txt", "*.text"],
40-
"description": "Splash files."
41-
}
42-
]
43-
}
44-
},
45-
"splash-rotation": {
46-
"type": "float",
47-
"name": "Splash Text Rotation",
48-
"description": "The rotation for the splash in the main menu. Default is -20",
49-
"default": -20,
50-
"min": -180,
51-
"max": 180,
52-
"control": {
53-
"slider": true
54-
}
55-
},
2+
"geode": "4.10.0",
3+
"gd": {
4+
"win": "2.2074",
5+
"android": "2.2074",
6+
"mac": "2.2074",
7+
"ios": "2.2074"
8+
},
9+
"id": "alphii.gd-splash-text",
10+
"name": "Splash Text!",
11+
"version": "v1.4.0",
12+
"developer": "Alphii",
13+
"description": "Minecraft-style splashes in the main menu!",
14+
"tags": ["enhancement", "offline"],
15+
"links": {
16+
"community": "https://discord.gg/tVPtwJexSX",
17+
"source": "https://github.com/AlphiiGD/Splash-Text"
18+
},
19+
"resources": {
20+
"files": [
21+
"resources/*.splash"
22+
]
23+
},
24+
"settings": {
25+
"extra-splash-file": {
26+
"type": "file",
27+
"name": "Extra Splashes",
28+
"platforms": ["android", "win", "mac"],
29+
"description": "Additional splash texts, one per line. Restart your game to apply. See more info about writing these on the GitHub page!",
30+
"default": {
31+
"win": "",
32+
"mac": "",
33+
"android": ""
34+
},
35+
"control": {
36+
"dialog": "open",
37+
"filters": [
38+
{
39+
"files": ["*.splash", "*.txt", "*.text"],
40+
"description": "Splash files."
41+
}
42+
]
43+
}
44+
},
45+
"splash-rotation": {
46+
"type": "float",
47+
"name": "Splash Text Rotation",
48+
"description": "The rotation for the splash in the main menu. Default is -20",
49+
"default": -20,
50+
"min": -180,
51+
"max": 180,
52+
"control": {
53+
"slider": true
54+
}
55+
},
56+
"scaling-speed": {
57+
"type": "float",
58+
"name": "Splash Text Scaling Speed",
59+
"description": "The speed at which the splash text scales in the main menu. Default is 1",
60+
"default": 1,
61+
"min": 0.1,
62+
"max": 5,
63+
"control": {
64+
"slider": true
65+
}
66+
},
5667
"disable-default-splash": {
5768
"type": "bool",
5869
"name": "Disable Default Splashes",
5970
"platforms": ["win", "android", "mac"],
6071
"description": "Disabled the build-in splashes from appearing. Useful if you want only your custom splashes to appear. Requires restart.",
6172
"default": false
6273
}
63-
}
74+
}
6475
}

resources/splash.splash

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,18 @@ Fire in the hole!
9898
Glubfub!
9999
The chicken is ready!
100100
Rock Lobster!
101-
Gimmie! Gimmie! Gimmie!
101+
Gimmie! Gimmie! Gimmie!
102+
103+
.DATERANGE 12-15 12-26
104+
Ho! Ho! Ho!
105+
Merry Christmas!
106+
./DATERANGE
107+
108+
.DATERANGE 2-14 2-15
109+
I LOVE YOU!
110+
Will you be my Valentine?
111+
./DATERANGE
112+
113+
.DATERANGE 01-01 01-02
114+
This splash can only appear on New Years!
115+
./DATERANGE

src/DateRange.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include "DateRange.hpp"
2+
3+
geode::Result<> DateRange::parse(const std::string& str, size_t start)
4+
{
5+
std::istringstream istrs(str.substr(start));
6+
istrs
7+
>> std::chrono::parse("%m-%d", m_Start)
8+
>> std::ws
9+
>> std::chrono::parse("%m-%d", m_End);
10+
11+
if (istrs.fail()) return geode::Err("Stringstream failed!");
12+
if (!m_Start.ok()) return geode::Err("Start not OK!");
13+
if (!m_End.ok()) return geode::Err("End not OK!");
14+
return geode::Ok();
15+
}
16+
17+
bool DateRange::inRange(const std::chrono::year_month_day& currentDate) const
18+
{
19+
auto year = currentDate.year();
20+
std::chrono::sys_days current(currentDate);
21+
std::chrono::sys_days start(year / m_Start);
22+
if (m_Start > m_End) year++; // Allow wrapping to the next year
23+
std::chrono::sys_days end(year / m_End);
24+
25+
geode::log::error("Current Date: {}\nStart: {}\nEnd: {}", current, start, end);
26+
27+
return current >= start && current <= end;
28+
}

src/DateRange.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <Geode/Geode.hpp>
2+
3+
class DateRange
4+
{
5+
private:
6+
std::chrono::month_day m_Start;
7+
std::chrono::month_day m_End;
8+
public:
9+
geode::Result<> parse(const std::string& str, size_t start = 0);
10+
bool inRange(const std::chrono::year_month_day& currentDate) const;
11+
inline const std::chrono::month_day& getStart() const { return m_Start; }
12+
inline const std::chrono::month_day& getEnd() const { return m_End; }
13+
};

src/MenuLayer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ class $modify(ST_MenuLayer, MenuLayer)
4343
m_fields->m_SplashStr = m_fields->m_SplashRead->getRandomLine();
4444
auto mainTitle = getChildByIDRecursive("main-title");
4545

46-
m_fields->m_SplashText = ScalingLabel::create(m_fields->m_SplashStr.c_str(), "goldFont.fnt");
46+
float scaleSpeed = Mod::get()->getSettingValue<float>("scaling-speed");
47+
m_fields->m_SplashText = ScalingLabel::create(m_fields->m_SplashStr.c_str(), "goldFont.fnt", scaleSpeed);
4748

4849
// The scale here is an inverse scaling function for text used pretty often for UI.
4950
m_fields->m_SplashText->setScale(0.5f / (1.0f + 0.05f * strlen(m_fields->m_SplashText->getLabel()->getString())));

src/ScalingLabel.cpp

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using namespace geode::prelude;
44

55
ScalingLabel::ScalingLabel(std::string text, std::string fntFile, float scalingFactor)
6-
: m_Text(text), m_FntFile(fntFile), m_ScalingFactor(scalingFactor)
6+
: m_Text(text), m_FntFile(fntFile), m_ScalingFactor(scalingFactor), m_Time(0.0f)
77
{
88
}
99

@@ -22,22 +22,9 @@ bool ScalingLabel::init()
2222

2323
void ScalingLabel::update(float dt)
2424
{
25-
if (m_ShouldShrink)
26-
{
27-
m_Label->setScale(m_Label->getScale() - m_ScalingFactor * dt);
28-
if (m_Label->getScale() <= 0.7f)
29-
{
30-
m_ShouldShrink = false;
31-
}
32-
}
33-
else
34-
{
35-
m_Label->setScale(m_Label->getScale() + m_ScalingFactor * dt);
36-
if (m_Label->getScale() >= 1.3f)
37-
{
38-
m_ShouldShrink = true;
39-
}
40-
}
25+
m_Time += dt * m_ScalingFactor;
26+
float newScale = 1.0f + std::sin(m_Time * 3.0f) * 0.3f; // https://www.desmos.com/calculator/gcf3iidbr6
27+
m_Label->setScale(newScale);
4128
}
4229

4330
ScalingLabel* ScalingLabel::create(std::string text, std::string fntFile, float scalingFactor)

src/ScalingLabel.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class ScalingLabel : public CCNode
88
{
99
private:
1010
float m_ScalingFactor;
11+
float m_Time;
1112
bool m_ShouldShrink;
1213
std::string m_Text;
1314
std::string m_FntFile;

0 commit comments

Comments
 (0)