Skip to content

Commit b49eca6

Browse files
committed
small fix
changed the target version of the mod and also added an option to change the buttons position to the settings menu
1 parent 85484e5 commit b49eca6

3 files changed

Lines changed: 43 additions & 11 deletions

File tree

mod.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"geode": "2.0.0-beta.9",
2+
"geode": "v2.0.0",
33
"gd": "2.204",
44
"version": "v1.0.0",
55
"id": "abb2k.backup",
@@ -10,17 +10,23 @@
1010
"settings": {
1111
"Auto_Backup": {
1212
"name": "Auto Backup",
13-
"description": "automatically backup the game.",
13+
"description": "Automatically backup the game.",
1414
"type": "bool",
1515
"default": false
1616
},
1717
"Max_Auto_Backups": {
1818
"name": "Max Auto Backups",
19-
"description": "how many backups the mod autosaves before starting to delete old ones for space.",
19+
"description": "How many backups the mod autosaves before starting to delete old ones for space.",
2020
"type": "int",
2121
"default": 1,
2222
"min": 1,
2323
"max": 10
24+
},
25+
"Button_In_Options_Menu": {
26+
"name": "Button In Options Menu",
27+
"description": "Moves the button of the mod to the settings menu.",
28+
"type": "bool",
29+
"default": false
2430
}
2531
}
2632
}

src/BackupsLayer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ bool BackupsLayer::init(float _w, float _h, const char* _spr){
133133

134134
this->setKeypadEnabled(true);
135135
this->setTouchEnabled(true);
136+
this->setTouchPriority(10);
136137

137138
return true;
138139
}

src/main.cpp

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,25 @@
22
#include <Geode/modify/MenuLayer.hpp>
33
#include <BackupsLayer.h>
44
#include <Geode/modify/GameManager.hpp>
5+
#include <Geode/modify/OptionsLayer.hpp>
56

67
class $modify(_MenuLayer, MenuLayer) {
78
bool init() {
89
if (!MenuLayer::init()) return false;
910

10-
auto sprite = CCSprite::createWithSpriteFrameName("GJ_duplicateBtn_001.png");
11+
if (!Mod::get()->getSettingValue<bool>("Button_In_Options_Menu")){
12+
auto sprite = CCSprite::createWithSpriteFrameName("GJ_duplicateBtn_001.png");
1113

12-
auto button = CCMenuItemSpriteExtra::create(sprite, nullptr, this, menu_selector(_MenuLayer::OpenBackupsLayerButton));
13-
button->setZOrder(-1);
14+
auto button = CCMenuItemSpriteExtra::create(sprite, nullptr, this, menu_selector(_MenuLayer::OpenBackupsLayerButton));
15+
button->setZOrder(-1);
1416

15-
auto menu = static_cast<CCMenu*>(this->getChildByID("right-side-menu"));
16-
menu->setPositionY(menu->getPositionY() - sprite->getContentSize().height / 2);
17+
auto menu = static_cast<CCMenu*>(this->getChildByID("right-side-menu"));
18+
menu->setPositionY(menu->getPositionY() - sprite->getContentSize().height / 2);
19+
20+
menu->addChild(button);
21+
menu->updateLayout();
22+
}
1723

18-
menu->addChild(button);
19-
menu->updateLayout();
20-
2124
return true;
2225
}
2326

@@ -26,6 +29,28 @@ class $modify(_MenuLayer, MenuLayer) {
2629
}
2730
};
2831

32+
class $modify(_OptionsLayer, OptionsLayer) {
33+
void customSetup() {
34+
OptionsLayer::customSetup();
35+
36+
if (Mod::get()->getSettingValue<bool>("Button_In_Options_Menu")){
37+
auto sprite = CCSprite::createWithSpriteFrameName("GJ_duplicateBtn_001.png");
38+
39+
auto button = CCMenuItemSpriteExtra::create(sprite, nullptr, this, menu_selector(_OptionsLayer::OpenBackupsLayerButton));
40+
button->setPosition({138, -171});
41+
42+
auto menu = CCMenu::create();
43+
44+
menu->addChild(button);
45+
this->m_listLayer->addChild(menu);
46+
}
47+
}
48+
49+
void OpenBackupsLayerButton(CCObject* target) {
50+
BackupsLayer::create()->show(this);
51+
}
52+
};
53+
2954
class $modify(GameManager) {
3055
void doQuickSave(){
3156
GameManager::doQuickSave();

0 commit comments

Comments
 (0)