Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: python3 LanguageBinCreator/json_to_bin.py

- name: Build Plugin
run: make
run: make DEVMODE=0

- name: Package Plugin
run: |
Expand Down
3 changes: 3 additions & 0 deletions Sources/Helpers/Address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ namespace CTRPluginFramework {
return;
}
}

//if none was found, its a dynamic address, so just set it
SetAddressData(address);
};

void Address::SetAddressData(u32 address) {
Expand Down
15 changes: 6 additions & 9 deletions Sources/Helpers/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,16 +282,11 @@ namespace CTRPluginFramework {
}
}

bool IsFaceCutOutSpaceFree(u8 buildingID) {
bool IsFaceCutOutSpaceFree() {
ACNL_BuildingData *building = Building::GetSaveData();
if(!building) {
return false;
}

if (buildingID != 0xDC && buildingID != 0xDD) { //Not a face cutout standee
return false;
}

for (int i = 0; i < 8; ++i) {
if (building->Stands[i].xCoord == -1 && building->Stands[i].yCoord == -1) { //Empty stand found
return true;
Expand Down Expand Up @@ -351,9 +346,11 @@ namespace CTRPluginFramework {
return;
}

if (!IsFaceCutOutSpaceFree(buildingID)) {
OSDExtras::Notify(TextID::BUILDING_MOD_NO_DESIGN_STAND_FREE, Color::Red);
return;
if (buildingID == 0xDC || buildingID == 0xDD) {
if (!IsFaceCutOutSpaceFree()) {
OSDExtras::Notify(TextID::BUILDING_MOD_NO_DESIGN_STAND_FREE, Color::Red);
return;
}
}

u32 x, y;
Expand Down
46 changes: 43 additions & 3 deletions Sources/LibCtrpfExtras/OSDExtras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,58 @@ namespace CTRPluginFramework {
return Notify(Language::getInstance()->get(textID), foreground, background);
}

std::vector<std::string> SplitText(const std::string& text, int maxWidth) {
std::vector<std::string> lines;
std::string remaining = text;

while (!remaining.empty()) {
std::string current = remaining;

bool isFirstLine = lines.empty();
std::string prefix = isFirstLine ? "" : "...";
std::string suffix = "";

//Always expect a new line
suffix = "...";

while (!current.empty()) {
std::string candidate = prefix + current + suffix;

if (ScreenExtras::SystemFontSize(candidate.c_str()) <= maxWidth) {
break;
}

current.pop_back();
}

//If everything fits, no suffix needed
if (current.size() == remaining.size()) {
suffix = "";
}

lines.push_back(prefix + current + suffix);

remaining.erase(0, current.size());
}

return lines;
}

int OSDExtras::Notify(const std::string &text, const Color &foreground, const Color &background) {
auto lines = SplitText(text, 375);

Lock();

if (Notifications.size() >= 50) {
if (Notifications.size() + lines.size() > 50) {
Unlock();
return -1;
}

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

Unlock();

return 0;
}

Expand Down