Skip to content

Commit

Permalink
Version 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
PetitFrapo committed Mar 26, 2024
1 parent 2ac8f7f commit b9832b3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v1.1.1

* Adjusted the scale of the buttons to work with any resolution.

# v1.1.0

* Merged RayDeeUx's pull request to optimize the code and add cross-platform.
Expand Down
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"android": "2.205",
"win": "2.204"
},
"version": "v1.1.0",
"version": "v1.1.1",
"id": "petitfrapo.nomoregrayfilter",
"name": "NoMoreGrayFilter",
"developer": "PetitFrapo",
Expand Down
19 changes: 13 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,35 @@ class $modify(CreatorLayer) {
return false;
};

// Get the menu.
auto menu = this->getChildByID("creator-buttons-menu");

// Get the correct scale for the resolution.
auto scaleToUse = getChildOfType<CCSprite>(getChildOfType<CCMenuItemSpriteExtra>(menu, 0), 0)->getScale();

// Create the sprites for the buttons.
auto sprev = CCSprite::createWithSpriteFrameName("GJ_eventBtn_001.png");
sprev->setScale(.75f);
sprev->setScale(scaleToUse);

auto sprmap = CCSprite::createWithSpriteFrameName("GJ_mapBtn_001.png");
sprmap->setScale(.75f);
sprmap->setScale(scaleToUse);

auto sprvers = CCSprite::createWithSpriteFrameName("GJ_versusBtn_001.png");
sprvers->setScale(.75f);

auto menu = this->getChildByID("creator-buttons-menu");
sprvers->setScale(scaleToUse);

// Create a map to associate an ID with its button.
std::map<std::string, CCMenuItemSpriteExtra*> idsToBtns = {
{ "event-button", CCMenuItemSpriteExtra::create(sprev, this, menu_selector(CreatorLayer::onEventLevel)) },
{ "map-button", CCMenuItemSpriteExtra::create(sprmap, this, menu_selector(CreatorLayer::onAdventureMap)) },
{ "versus-button", CCMenuItemSpriteExtra::create(sprvers, this, menu_selector(CreatorLayer::onMultiplayer)) }
};

// Iterate on the map to create the buttons and put them on the menu.
for (auto pair = idsToBtns.begin(); pair != idsToBtns.end(); pair++) {
auto id = pair->first.c_str();
auto superExpertLoaded = ((strcmp("versus-button", id) == 0) && (Loader::get()->isModLoaded("xanii.super_expert")));

if (!menu->getChildByID(id)) continue; // avoid crash if child not found
if (!menu->getChildByID(id)) continue; // Avoid crash if child not found.

auto btn = menu->getChildByID(id);
auto evx = btn->getPositionX();
Expand Down

0 comments on commit b9832b3

Please sign in to comment.