Skip to content

Commit 3e0e9df

Browse files
authored
Merge pull request #223 from RedShyGuy/hotfix/3.0.1
Hotfix 3.0.1
2 parents eadd82d + bc1ab10 commit 3e0e9df

File tree

4 files changed

+53
-13
lines changed

4 files changed

+53
-13
lines changed

.github/workflows/c-cpp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
run: python3 LanguageBinCreator/json_to_bin.py
3535

3636
- name: Build Plugin
37-
run: make
37+
run: make DEVMODE=0
3838

3939
- name: Package Plugin
4040
run: |

Sources/Helpers/Address.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ namespace CTRPluginFramework {
6060
return;
6161
}
6262
}
63+
64+
//if none was found, its a dynamic address, so just set it
65+
SetAddressData(address);
6366
};
6467

6568
void Address::SetAddressData(u32 address) {

Sources/Helpers/Game.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -282,16 +282,11 @@ namespace CTRPluginFramework {
282282
}
283283
}
284284

285-
bool IsFaceCutOutSpaceFree(u8 buildingID) {
285+
bool IsFaceCutOutSpaceFree() {
286286
ACNL_BuildingData *building = Building::GetSaveData();
287287
if(!building) {
288288
return false;
289289
}
290-
291-
if (buildingID != 0xDC && buildingID != 0xDD) { //Not a face cutout standee
292-
return false;
293-
}
294-
295290
for (int i = 0; i < 8; ++i) {
296291
if (building->Stands[i].xCoord == -1 && building->Stands[i].yCoord == -1) { //Empty stand found
297292
return true;
@@ -351,9 +346,11 @@ namespace CTRPluginFramework {
351346
return;
352347
}
353348

354-
if (!IsFaceCutOutSpaceFree(buildingID)) {
355-
OSDExtras::Notify(TextID::BUILDING_MOD_NO_DESIGN_STAND_FREE, Color::Red);
356-
return;
349+
if (buildingID == 0xDC || buildingID == 0xDD) {
350+
if (!IsFaceCutOutSpaceFree()) {
351+
OSDExtras::Notify(TextID::BUILDING_MOD_NO_DESIGN_STAND_FREE, Color::Red);
352+
return;
353+
}
357354
}
358355

359356
u32 x, y;

Sources/LibCtrpfExtras/OSDExtras.cpp

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,58 @@ namespace CTRPluginFramework {
8383
return Notify(Language::getInstance()->get(textID), foreground, background);
8484
}
8585

86+
std::vector<std::string> SplitText(const std::string& text, int maxWidth) {
87+
std::vector<std::string> lines;
88+
std::string remaining = text;
89+
90+
while (!remaining.empty()) {
91+
std::string current = remaining;
92+
93+
bool isFirstLine = lines.empty();
94+
std::string prefix = isFirstLine ? "" : "...";
95+
std::string suffix = "";
96+
97+
//Always expect a new line
98+
suffix = "...";
99+
100+
while (!current.empty()) {
101+
std::string candidate = prefix + current + suffix;
102+
103+
if (ScreenExtras::SystemFontSize(candidate.c_str()) <= maxWidth) {
104+
break;
105+
}
106+
107+
current.pop_back();
108+
}
109+
110+
//If everything fits, no suffix needed
111+
if (current.size() == remaining.size()) {
112+
suffix = "";
113+
}
114+
115+
lines.push_back(prefix + current + suffix);
116+
117+
remaining.erase(0, current.size());
118+
}
119+
120+
return lines;
121+
}
122+
86123
int OSDExtras::Notify(const std::string &text, const Color &foreground, const Color &background) {
124+
auto lines = SplitText(text, 375);
125+
87126
Lock();
88127

89-
if (Notifications.size() >= 50) {
128+
if (Notifications.size() + lines.size() > 50) {
90129
Unlock();
91130
return -1;
92131
}
93132

94-
Notifications.push_back(new OSDMessage(text, foreground, background));
133+
for (auto it = lines.rbegin(); it != lines.rend(); ++it) {
134+
Notifications.push_back(new OSDMessage(*it, foreground, background));
135+
}
95136

96137
Unlock();
97-
98138
return 0;
99139
}
100140

0 commit comments

Comments
 (0)