Skip to content

Commit 795c2d5

Browse files
authored
Merge pull request #2 from hiimjasmine00/master
Fix newline parsing and main title
2 parents c6c5230 + 95e3e28 commit 795c2d5

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 1.0.3
2+
- Fixed newline parsing
3+
14
# 1.0.2
25
- Updated Geode SDK to 4.6.1
36

mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"id": "alphii.gd-splash-text",
1010
"name": "Splash Text!",
11-
"version": "v1.0.2",
11+
"version": "v1.0.3",
1212
"developer": "Alphii",
1313
"description": "",
1414
"resources": {

src/MenuLayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class $modify(ST_MenuLayer, MenuLayer)
2323

2424
if (!m_fields->m_SplashRead) m_fields->m_SplashRead = new SplashRead("splash.splash");
2525
m_fields->m_SplashStr = m_fields->m_SplashRead->getRandomLine();
26-
auto mainTitle = getChildByID("main-title");
26+
auto mainTitle = getChildByIDRecursive("main-title");
2727

2828
m_fields->m_SplashText = ScalingLabel::create(m_fields->m_SplashStr.c_str(), "goldFont.fnt");
2929
m_fields->m_SplashText->setScale(0.5f / (1.0f + 0.05f * strlen(m_fields->m_SplashText->getLabel()->getString())));

src/SplashRead.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,13 @@ bool SplashRead::loadFile()
4646
}
4747
}
4848

49-
// Non-alphanumeric characters are not allowed, if we see one, we fail.
5049
// Algorithm provided by undefined06855 on Discord and Git
50+
std::string trimmedLine;
51+
trimmedLine.reserve(line.length());
5152
for (int i = 0; i < line.length(); i++)
5253
{
53-
if (line[i] == '\0') continue;
54-
if (line[i] < ' ' || line[i] > '~')
55-
{
56-
log::error("Non-alphanumeric character detected at col {} of line {}", i + 1, lineNum);
57-
return false;
58-
}
54+
if (line[i] == '\0' || line[i] == '\n' || line[i] == '\r' || line[i] < ' ' || line[i] > '~') continue;
55+
trimmedLine += line[i];
5956
}
6057

6158
// If our file stream fails during loading then we gotta return false
@@ -66,7 +63,7 @@ bool SplashRead::loadFile()
6663
}
6764

6865
// Finally we can push back our processed string
69-
m_Lines.push_back(line);
66+
m_Lines.push_back(trimmedLine);
7067
lineNum++;
7168
}
7269

0 commit comments

Comments
 (0)