Skip to content

Commit 8cab4c7

Browse files
committed
all changes for now
1 parent acce089 commit 8cab4c7

File tree

13 files changed

+91
-90
lines changed

13 files changed

+91
-90
lines changed

mod.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"geode": "3.9.0",
2+
"geode": "4.0.0-alpha.1",
33
"version": "v1.3.12",
44
"gd": {
5-
"win": "2.206",
6-
"mac": "2.206",
7-
"android": "2.206",
8-
"ios": "2.206"
5+
"win": "2.2074",
6+
"mac": "2.2074",
7+
"android": "2.2074",
8+
"ios": "2.2074"
99
},
1010
"platforms": ["android", "win", "mac"],
1111
"id": "gdutilsdevs.gdutils",

src/MoreLeaderboards/CustomScoreCell.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ class $modify(CustomScoreCell, GJScoreCell) {
3333
// Move child to menu with layout
3434
auto starsLabel = as<CCLabelBMFont*>(layer->getChildByIDRecursive("stars-label"));
3535
starsLabel->setLayoutOptions(
36-
AxisLayoutOptions::create()->setAutoScale(true)->setMinScale(0)->setMaxScale(0.5f)->setScalePriority(1)
36+
AxisLayoutOptions::create()->setAutoScale(true)->setScaleLimits(0, 0.5F)->setScalePriority(1)
3737
);
3838
auto starsIcon = as<CCSprite*>(layer->getChildByIDRecursive("stars-icon"));
3939
starsIcon->setLayoutOptions(
40-
AxisLayoutOptions::create()->setAutoScale(true)->setMinScale(0)->setMaxScale(0.5f)->setScalePriority(1)
40+
AxisLayoutOptions::create()->setAutoScale(true)->setScaleLimits(0, 0.5F)->setScalePriority(1)
4141
);
4242
auto moonsLabel = as<CCLabelBMFont*>(layer->getChildByIDRecursive("moons-label"));
4343
moonsLabel->setLayoutOptions(
44-
AxisLayoutOptions::create()->setAutoScale(true)->setMinScale(0)->setMaxScale(0.5f)->setScalePriority(1)
44+
AxisLayoutOptions::create()->setAutoScale(true)->setScaleLimits(0, 0.5F)->setScalePriority(1)
4545
);
4646
auto moonsIcon = as<CCSprite*>(layer->getChildByIDRecursive("moons-icon"));
4747
moonsIcon->setLayoutOptions(
48-
AxisLayoutOptions::create()->setAutoScale(true)->setMinScale(0)->setMaxScale(0.5f)->setScalePriority(1)
48+
AxisLayoutOptions::create()->setAutoScale(true)->setScaleLimits(0, 0.5F)->setScalePriority(1)
4949
);
5050

5151
// Username control
@@ -62,7 +62,7 @@ class $modify(CustomScoreCell, GJScoreCell) {
6262
(SEL_MenuHandler)&CustomScoreCell::onViewProfile
6363
);
6464
playerNameBtn->setLayoutOptions(
65-
AxisLayoutOptions::create()->setAutoScale(true)->setMinScale(0.5f)->setMaxScale(0.8f)->setScalePriority(1)
65+
AxisLayoutOptions::create()->setAutoScale(true)->setScaleLimits(0.5F, 0.8F)->setScalePriority(1)
6666
);
6767

6868
std::vector<std::string> dataString = MoreLeaderboards::getWords(data_flag, "#");
@@ -431,4 +431,4 @@ class $modify(CustomScoreCell, GJScoreCell) {
431431
layer->updateLayout();
432432
}
433433
}
434-
};
434+
};

src/MoreLeaderboards/MoreLeaderboards.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ std::vector<std::string> MoreLeaderboards::getWords(std::string s, std::string d
4444
class SearchUserLBLayer : public BrownAlertDelegate {
4545
protected:
4646
MoreLeaderboards* m_layer;
47-
InputNode* input_username = InputNode::create(200.0F, "Username", "bigFont.fnt", "", 20);
47+
TextInput* input_username = TextInput::create(200.0F, "Username", "bigFont.fnt");
4848

4949
virtual void setup() {
5050
auto winSize = cocos2d::CCDirector::sharedDirector()->getWinSize();
51+
input_username->setMaxCharCount(20);
52+
input_username->setPlaceholder("");
5153
input_username->setPositionY(10);
5254
this->m_buttonMenu->addChild(input_username);
5355
auto validate_spr = ButtonSprite::create("Search", 60, true, "bigFont.fnt", "GJ_button_01.png", 30, .5F);
@@ -435,7 +437,7 @@ void MoreLeaderboards::startLoadingMods() {
435437
[expect = std::move(expect), then = std::move(then)](web::WebResponse* response) {
436438
const std::lock_guard<std::mutex> lock(lock_var);
437439
if (response->ok()) {
438-
then(response->string().value());
440+
then(response->string().unwrapOrDefault());
439441
} else {
440442
expect("An error occured while sending a request on our server. Please try again later.");
441443
}
@@ -464,7 +466,7 @@ void MoreLeaderboards::startLoadingMore() {
464466

465467
this->retain();
466468

467-
const geode::utils::MiniFunction<void(std::string const&)> expect = [this](std::string const& error) {
469+
const std::function<void(std::string const&)> expect = [this](std::string const& error) {
468470
loading = false;
469471
auto scene = CCDirector::sharedDirector()->getRunningScene();
470472
auto layer = scene->getChildren()->objectAtIndex(0);
@@ -486,7 +488,7 @@ void MoreLeaderboards::startLoadingMore() {
486488
this->release();
487489
};
488490

489-
const geode::utils::MiniFunction<void(std::string const&)> then = [this](std::string const& data) {
491+
const std::function<void(std::string const&)> then = [this](std::string const& data) {
490492
if (data != "-1") {
491493
data_region = data;
492494
SelectRegion::displayedData = MoreLeaderboards::getWords(data, "|");
@@ -552,7 +554,7 @@ void MoreLeaderboards::startLoadingMore() {
552554
break;
553555
}
554556

555-
const geode::utils::MiniFunction<void(std::string const&)> expect = [this](std::string const& error) {
557+
const std::function<void(std::string const&)> expect = [this](std::string const& error) {
556558
loading = false;
557559

558560
auto scene = CCDirector::sharedDirector()->getRunningScene();
@@ -575,7 +577,7 @@ void MoreLeaderboards::startLoadingMore() {
575577
this->release();
576578
};
577579

578-
const geode::utils::MiniFunction<void(std::string const&)> then = [this](std::string const& data) {
580+
const std::function<void(std::string const&)> then = [this](std::string const& data) {
579581
loading = false;
580582

581583
const std::lock_guard<std::mutex> lock(lock_var);
@@ -629,7 +631,7 @@ void MoreLeaderboards::startLoadingMore() {
629631
request.param("type", type).param("page", page).param("country", country_id).param("username", username).param("mod", (modFilter ? "1" : "0")).param("modFilter", modFilterType).get("https://clarifygdps.com/gdutils/moreleaderboards.php").map(
630632
[expect = std::move(expect), then = std::move(then)](web::WebResponse* response) {
631633
if (response->ok()) {
632-
then(response->string().value());
634+
then(response->string().unwrap());
633635
} else {
634636
expect("An error occured while sending a request on our server. Please try again later.");
635637
}
@@ -645,7 +647,7 @@ void MoreLeaderboards::startLoadingMore() {
645647
m_listener.bind([expect = std::move(expect), then = std::move(then)] (web::WebTask::Event* e) {
646648
if (web::WebResponse* res = e->getValue()) {
647649
if (res->ok()) {
648-
then(res->string().value());
650+
then(res->string().unwrap());
649651
} else {
650652
expect("An error occured while sending a request on our server. Please try again later.");
651653
}
@@ -751,8 +753,7 @@ void MoreLeaderboards::loadPageStats() {
751753
page_label->setLayoutOptions(
752754
AxisLayoutOptions::create()
753755
->setAutoScale(true)
754-
->setMinScale(0)
755-
->setMaxScale(0.7f)
756+
->setScaleLimits(0, 0.7F)
756757
->setScalePriority(1)
757758
);
758759
menu_label->addChild(page_label);
@@ -1255,9 +1256,6 @@ void MoreLeaderboards::onTab(CCObject* pSender) {
12551256
if (pSender) {
12561257
MoreLeaderboards::g_tab = static_cast<StatsListType>(pSender->getTag());
12571258
}
1258-
1259-
1260-
12611259
resetInfos();
12621260

12631261
page = 0;
@@ -1293,6 +1291,7 @@ class $modify(LeaderboardsLayer) {
12931291
bool init(LeaderboardState state) {
12941292
if (!LeaderboardsLayer::init(state)) return false;
12951293

1294+
log::info("weee");
12961295
auto menu = CCMenu::create();
12971296

12981297
auto plusSpr = CCSprite::createWithSpriteFrameName("GJ_plusBtn_001.png");

src/MoreLeaderboards/SelectRegion.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ std::vector<std::string> SelectRegion::getWords(std::string s, std::string delim
2828
void SelectRegion::scene(const std::function<void(int)>& callback) {
2929
auto popup = new SelectRegion(callback);
3030

31-
if (popup && popup->init(250.0f, 210.0f)) {
31+
if (popup && popup->initAnchored(250.0f, 210.0f)) {
3232
popup->autorelease();
3333
CCDirector::sharedDirector()->getRunningScene()->addChild(popup);
3434
} else {
@@ -63,4 +63,4 @@ void SelectRegion::loadPage() {
6363
border->setPosition(m_mainLayer->getContentSize() / 2 - border->getContentSize() / 2);
6464
setTouchPriority(100);
6565
m_mainLayer->addChild(border);
66-
}
66+
}

src/Notifications/DailyChest.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ static GJRewardItem* time1 = nullptr;
55
static GJRewardItem* time2 = nullptr;
66

77
void DailyChest::getRewards(unsigned int type) {
8-
GameLevelManager* glm = GameLevelManager::sharedState();
9-
glm->m_GJRewardDelegate = this;
10-
glm->getGJRewards(0);
8+
auto glm = GameLevelManager::sharedState();
9+
if (glm) {
10+
glm->m_GJRewardDelegate = this;
11+
glm->getGJRewards(0);
12+
}
1113
};
1214

1315
void DailyChest::rewardsStatusFinished(int p0) {

src/Notifications/EventsPush.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ void EventsPush::onClickBtn(CCObject* ret) {
324324
180.0F
325325
)->show();
326326
} else {
327-
auto data_result = response->string().value();
327+
auto data_result = response->string().unwrapOrDefault();
328328
if (data_result != "-1") {
329329
auto scene = CCScene::create();
330330
auto layer = LevelInfoLayer::create(EventsPush::convertLevelToJSON(data_result), false);

src/Secret/BadApple.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class $modify(SecretVault, SecretLayer2) {
7373
m_fields->m_menu->setContentSize({ 100, 200 });
7474
m_fields->m_menu->setLayout(
7575
ColumnLayout::create()
76-
->setCrossAxisAlignment(cocos2d::AxisAlignment::Center)
76+
->setCrossAxisAlignment(AxisAlignment::Center)
7777
);
7878
}
7979

@@ -97,8 +97,8 @@ class $modify(SecretVault, SecretLayer2) {
9797
auto menu = CCMenu::create();
9898
menu->setLayout(
9999
RowLayout::create()
100-
->setAxis(cocos2d::Axis::Column)
101-
->setAxisAlignment(cocos2d::AxisAlignment::Center)
100+
->setAxis(Axis::Column)
101+
->setAxisAlignment(AxisAlignment::Center)
102102
->setGap(3)
103103
);
104104

@@ -119,8 +119,7 @@ class $modify(SecretVault, SecretLayer2) {
119119
badappleLabel->setLayoutOptions(
120120
AxisLayoutOptions::create()
121121
->setAutoScale(true)
122-
->setMinScale(0)
123-
->setMaxScale(.4f)
122+
->setScaleLimits(0, 0.4F)
124123
->setScalePriority(1)
125124
);
126125
menu->addChild(badappleLabel);
@@ -137,8 +136,8 @@ class $modify(SecretVault, SecretLayer2) {
137136
auto menu = CCMenu::create();
138137
menu->setLayout(
139138
RowLayout::create()
140-
->setAxis(cocos2d::Axis::Column)
141-
->setAxisAlignment(cocos2d::AxisAlignment::Center)
139+
->setAxis(Axis::Column)
140+
->setAxisAlignment(AxisAlignment::Center)
142141
->setGap(3)
143142
);
144143

@@ -159,8 +158,7 @@ class $modify(SecretVault, SecretLayer2) {
159158
COTELabel->setLayoutOptions(
160159
AxisLayoutOptions::create()
161160
->setAutoScale(true)
162-
->setMinScale(0)
163-
->setMaxScale(.2f)
161+
->setScaleLimits(0, 0.2F)
164162
->setScalePriority(1)
165163
);
166164
menu->addChild(COTELabel);

src/Settings/CustomSettings.hpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#pragma once
2-
#include <Geode/loader/SettingNode.hpp>
32
#include "CreditsBetaMenu.h"
43
#include "CreditsMenu.h"
54
#include <Geode/ui/TextInput.hpp>
@@ -11,13 +10,13 @@ using namespace geode::prelude;
1110

1211
class SettingTestValue : public SettingV3 {
1312
public:
14-
static Result<std::shared_ptr<SettingTestValue>> parse(std::string const& key, std::string const& modID, matjson::Value const& json) {
13+
static Result<std::shared_ptr<SettingV3>> parse(std::string const& key, std::string const& modID, matjson::Value const& json) {
1514
auto res = std::make_shared<SettingTestValue>();
1615
auto root = checkJson(json, "SettingTestValue");
1716
res->init(key, modID, root);
1817
res->parseNameAndDescription(root);
1918
root.checkUnknownKeys();
20-
return root.ok(res);
19+
return root.ok(std::static_pointer_cast<SettingV3>(res));
2120
}
2221

2322
bool load(matjson::Value const& json) override {
@@ -93,8 +92,7 @@ enum class SettingPosEnum : int {
9392

9493
template <>
9594
struct matjson::Serialize<SettingPosEnum> {
96-
static matjson::Value to_json(SettingPosEnum const& value) {
97-
log::info("to_json {}", static_cast<int>(value));
95+
static matjson::Value toJson(SettingPosEnum const& value) {
9896
switch (value) {
9997
case SettingPosEnum::TopLeft:
10098
return 1;
@@ -107,32 +105,33 @@ struct matjson::Serialize<SettingPosEnum> {
107105
return 4;
108106
}
109107
}
110-
static SettingPosEnum from_json(matjson::Value const& value) {
111-
switch (value.as_int()) {
112-
case 1: return SettingPosEnum::TopLeft;
113-
case 2: return SettingPosEnum::TopRight;
114-
case 3: return SettingPosEnum::BottomLeft;
115-
case 4: return SettingPosEnum::BottomRight;
116-
default: throw matjson::JsonException(fmt::format("invalid SettingPosEnum value '{}'", value));
108+
static Result<SettingPosEnum> fromJson(matjson::Value const& value) {
109+
switch (value.asInt().unwrapOrDefault()) {
110+
case 1: return Ok(SettingPosEnum::TopLeft);
111+
case 2: return Ok(SettingPosEnum::TopRight);
112+
case 3: return Ok(SettingPosEnum::BottomLeft);
113+
case 4: return Ok(SettingPosEnum::BottomRight);
114+
default: return Err("Invalid SettingPosEnum value '{}'", value.asInt().unwrapOrDefault());
117115
}
118116
}
119117
static bool is_json(matjson::Value const& json) {
120-
return json.is_number() || json.is_string();
118+
return json.isNumber() || json.isString();
121119
}
122120
};
123121

124122
class SettingPosValue : public SettingBaseValueV3<SettingPosEnum> {
125123
public:
126-
static Result<std::shared_ptr<SettingPosValue>> parse(std::string const& key, std::string const& modID, matjson::Value const& json) {
124+
static Result<std::shared_ptr<SettingV3>> parse(std::string const& key, std::string const& modID, matjson::Value const& json) {
127125
auto res = std::make_shared<SettingPosValue>();
128126
auto root = checkJson(json, "SettingPosValue");
129127
res->parseBaseProperties(key, modID, root);
130128
root.checkUnknownKeys();
131-
return root.ok(res);
129+
return root.ok(std::static_pointer_cast<SettingV3>(res));
132130
}
133131
SettingNodeV3* createNode(float width) override;
134132
};
135133

134+
136135
template <>
137136
struct geode::SettingTypeForValueType<SettingPosEnum> {
138137
using SettingType = SettingPosValue;
@@ -263,13 +262,13 @@ class SettingPosNode : public SettingValueNodeV3<SettingPosValue> {
263262

264263
class SettingCreditsValue : public SettingV3 {
265264
public:
266-
static Result<std::shared_ptr<SettingCreditsValue>> parse(std::string const& key, std::string const& modID, matjson::Value const& json) {
265+
static Result<std::shared_ptr<SettingV3>> parse(std::string const& key, std::string const& modID, matjson::Value const& json) {
267266
auto res = std::make_shared<SettingCreditsValue>();
268267
auto root = checkJson(json, "SettingCreditsValue");
269268
res->init(key, modID, root);
270269
res->parseNameAndDescription(root);
271270
root.checkUnknownKeys();
272-
return root.ok(res);
271+
return root.ok(std::static_pointer_cast<SettingV3>(res));
273272
}
274273

275274
bool load(matjson::Value const& json) override {

src/Styles/NewGJCommentList.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ class $modify(CommentCell) {
278278
m_fields->m_listener.bind([] (web::WebTask::Event* e) {
279279
if (web::WebResponse* res = e->getValue()) {
280280
if (res->ok()) {
281-
result_global = res->string().value();
281+
result_global = res->string().unwrapOrDefault();
282282
}
283283
}
284284
});
@@ -291,4 +291,4 @@ class $modify(CommentCell) {
291291
requestGDUtilsBadges(layer, comment->m_commentID);
292292
}
293293
}
294-
};
294+
};

src/Styles/NewProfilePage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ class $modify(ProfilePage) {
430430
m_fields->m_listener.bind([expect = std::move(expect), then = std::move(then)] (web::WebTask::Event* e) {
431431
if (web::WebResponse* res = e->getValue()) {
432432
if (res->ok()) {
433-
then(res->string().value());
433+
then(res->string().unwrapOrDefault());
434434
} else {
435435
expect("Request failed");
436436
}

0 commit comments

Comments
 (0)