Skip to content

Commit

Permalink
all changes for now
Browse files Browse the repository at this point in the history
  • Loading branch information
FireMario211 committed Nov 15, 2024
1 parent acce089 commit 8cab4c7
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 90 deletions.
10 changes: 5 additions & 5 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"geode": "3.9.0",
"geode": "4.0.0-alpha.1",
"version": "v1.3.12",
"gd": {
"win": "2.206",
"mac": "2.206",
"android": "2.206",
"ios": "2.206"
"win": "2.2074",
"mac": "2.2074",
"android": "2.2074",
"ios": "2.2074"
},
"platforms": ["android", "win", "mac"],
"id": "gdutilsdevs.gdutils",
Expand Down
12 changes: 6 additions & 6 deletions src/MoreLeaderboards/CustomScoreCell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ class $modify(CustomScoreCell, GJScoreCell) {
// Move child to menu with layout
auto starsLabel = as<CCLabelBMFont*>(layer->getChildByIDRecursive("stars-label"));
starsLabel->setLayoutOptions(
AxisLayoutOptions::create()->setAutoScale(true)->setMinScale(0)->setMaxScale(0.5f)->setScalePriority(1)
AxisLayoutOptions::create()->setAutoScale(true)->setScaleLimits(0, 0.5F)->setScalePriority(1)
);
auto starsIcon = as<CCSprite*>(layer->getChildByIDRecursive("stars-icon"));
starsIcon->setLayoutOptions(
AxisLayoutOptions::create()->setAutoScale(true)->setMinScale(0)->setMaxScale(0.5f)->setScalePriority(1)
AxisLayoutOptions::create()->setAutoScale(true)->setScaleLimits(0, 0.5F)->setScalePriority(1)
);
auto moonsLabel = as<CCLabelBMFont*>(layer->getChildByIDRecursive("moons-label"));
moonsLabel->setLayoutOptions(
AxisLayoutOptions::create()->setAutoScale(true)->setMinScale(0)->setMaxScale(0.5f)->setScalePriority(1)
AxisLayoutOptions::create()->setAutoScale(true)->setScaleLimits(0, 0.5F)->setScalePriority(1)
);
auto moonsIcon = as<CCSprite*>(layer->getChildByIDRecursive("moons-icon"));
moonsIcon->setLayoutOptions(
AxisLayoutOptions::create()->setAutoScale(true)->setMinScale(0)->setMaxScale(0.5f)->setScalePriority(1)
AxisLayoutOptions::create()->setAutoScale(true)->setScaleLimits(0, 0.5F)->setScalePriority(1)
);

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

std::vector<std::string> dataString = MoreLeaderboards::getWords(data_flag, "#");
Expand Down Expand Up @@ -431,4 +431,4 @@ class $modify(CustomScoreCell, GJScoreCell) {
layer->updateLayout();
}
}
};
};
25 changes: 12 additions & 13 deletions src/MoreLeaderboards/MoreLeaderboards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ std::vector<std::string> MoreLeaderboards::getWords(std::string s, std::string d
class SearchUserLBLayer : public BrownAlertDelegate {
protected:
MoreLeaderboards* m_layer;
InputNode* input_username = InputNode::create(200.0F, "Username", "bigFont.fnt", "", 20);
TextInput* input_username = TextInput::create(200.0F, "Username", "bigFont.fnt");

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

this->retain();

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

const geode::utils::MiniFunction<void(std::string const&)> then = [this](std::string const& data) {
const std::function<void(std::string const&)> then = [this](std::string const& data) {
if (data != "-1") {
data_region = data;
SelectRegion::displayedData = MoreLeaderboards::getWords(data, "|");
Expand Down Expand Up @@ -552,7 +554,7 @@ void MoreLeaderboards::startLoadingMore() {
break;
}

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

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

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

const std::lock_guard<std::mutex> lock(lock_var);
Expand Down Expand Up @@ -629,7 +631,7 @@ void MoreLeaderboards::startLoadingMore() {
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(
[expect = std::move(expect), then = std::move(then)](web::WebResponse* response) {
if (response->ok()) {
then(response->string().value());
then(response->string().unwrap());
} else {
expect("An error occured while sending a request on our server. Please try again later.");
}
Expand All @@ -645,7 +647,7 @@ void MoreLeaderboards::startLoadingMore() {
m_listener.bind([expect = std::move(expect), then = std::move(then)] (web::WebTask::Event* e) {
if (web::WebResponse* res = e->getValue()) {
if (res->ok()) {
then(res->string().value());
then(res->string().unwrap());
} else {
expect("An error occured while sending a request on our server. Please try again later.");
}
Expand Down Expand Up @@ -751,8 +753,7 @@ void MoreLeaderboards::loadPageStats() {
page_label->setLayoutOptions(
AxisLayoutOptions::create()
->setAutoScale(true)
->setMinScale(0)
->setMaxScale(0.7f)
->setScaleLimits(0, 0.7F)
->setScalePriority(1)
);
menu_label->addChild(page_label);
Expand Down Expand Up @@ -1255,9 +1256,6 @@ void MoreLeaderboards::onTab(CCObject* pSender) {
if (pSender) {
MoreLeaderboards::g_tab = static_cast<StatsListType>(pSender->getTag());
}



resetInfos();

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

log::info("weee");
auto menu = CCMenu::create();

auto plusSpr = CCSprite::createWithSpriteFrameName("GJ_plusBtn_001.png");
Expand Down
4 changes: 2 additions & 2 deletions src/MoreLeaderboards/SelectRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ std::vector<std::string> SelectRegion::getWords(std::string s, std::string delim
void SelectRegion::scene(const std::function<void(int)>& callback) {
auto popup = new SelectRegion(callback);

if (popup && popup->init(250.0f, 210.0f)) {
if (popup && popup->initAnchored(250.0f, 210.0f)) {
popup->autorelease();
CCDirector::sharedDirector()->getRunningScene()->addChild(popup);
} else {
Expand Down Expand Up @@ -63,4 +63,4 @@ void SelectRegion::loadPage() {
border->setPosition(m_mainLayer->getContentSize() / 2 - border->getContentSize() / 2);
setTouchPriority(100);
m_mainLayer->addChild(border);
}
}
8 changes: 5 additions & 3 deletions src/Notifications/DailyChest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ static GJRewardItem* time1 = nullptr;
static GJRewardItem* time2 = nullptr;

void DailyChest::getRewards(unsigned int type) {
GameLevelManager* glm = GameLevelManager::sharedState();
glm->m_GJRewardDelegate = this;
glm->getGJRewards(0);
auto glm = GameLevelManager::sharedState();
if (glm) {
glm->m_GJRewardDelegate = this;
glm->getGJRewards(0);
}
};

void DailyChest::rewardsStatusFinished(int p0) {
Expand Down
2 changes: 1 addition & 1 deletion src/Notifications/EventsPush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ void EventsPush::onClickBtn(CCObject* ret) {
180.0F
)->show();
} else {
auto data_result = response->string().value();
auto data_result = response->string().unwrapOrDefault();
if (data_result != "-1") {
auto scene = CCScene::create();
auto layer = LevelInfoLayer::create(EventsPush::convertLevelToJSON(data_result), false);
Expand Down
16 changes: 7 additions & 9 deletions src/Secret/BadApple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class $modify(SecretVault, SecretLayer2) {
m_fields->m_menu->setContentSize({ 100, 200 });
m_fields->m_menu->setLayout(
ColumnLayout::create()
->setCrossAxisAlignment(cocos2d::AxisAlignment::Center)
->setCrossAxisAlignment(AxisAlignment::Center)
);
}

Expand All @@ -97,8 +97,8 @@ class $modify(SecretVault, SecretLayer2) {
auto menu = CCMenu::create();
menu->setLayout(
RowLayout::create()
->setAxis(cocos2d::Axis::Column)
->setAxisAlignment(cocos2d::AxisAlignment::Center)
->setAxis(Axis::Column)
->setAxisAlignment(AxisAlignment::Center)
->setGap(3)
);

Expand All @@ -119,8 +119,7 @@ class $modify(SecretVault, SecretLayer2) {
badappleLabel->setLayoutOptions(
AxisLayoutOptions::create()
->setAutoScale(true)
->setMinScale(0)
->setMaxScale(.4f)
->setScaleLimits(0, 0.4F)
->setScalePriority(1)
);
menu->addChild(badappleLabel);
Expand All @@ -137,8 +136,8 @@ class $modify(SecretVault, SecretLayer2) {
auto menu = CCMenu::create();
menu->setLayout(
RowLayout::create()
->setAxis(cocos2d::Axis::Column)
->setAxisAlignment(cocos2d::AxisAlignment::Center)
->setAxis(Axis::Column)
->setAxisAlignment(AxisAlignment::Center)
->setGap(3)
);

Expand All @@ -159,8 +158,7 @@ class $modify(SecretVault, SecretLayer2) {
COTELabel->setLayoutOptions(
AxisLayoutOptions::create()
->setAutoScale(true)
->setMinScale(0)
->setMaxScale(.2f)
->setScaleLimits(0, 0.2F)
->setScalePriority(1)
);
menu->addChild(COTELabel);
Expand Down
33 changes: 16 additions & 17 deletions src/Settings/CustomSettings.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#pragma once
#include <Geode/loader/SettingNode.hpp>
#include "CreditsBetaMenu.h"
#include "CreditsMenu.h"
#include <Geode/ui/TextInput.hpp>
Expand All @@ -11,13 +10,13 @@ using namespace geode::prelude;

class SettingTestValue : public SettingV3 {
public:
static Result<std::shared_ptr<SettingTestValue>> parse(std::string const& key, std::string const& modID, matjson::Value const& json) {
static Result<std::shared_ptr<SettingV3>> parse(std::string const& key, std::string const& modID, matjson::Value const& json) {
auto res = std::make_shared<SettingTestValue>();
auto root = checkJson(json, "SettingTestValue");
res->init(key, modID, root);
res->parseNameAndDescription(root);
root.checkUnknownKeys();
return root.ok(res);
return root.ok(std::static_pointer_cast<SettingV3>(res));
}

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

template <>
struct matjson::Serialize<SettingPosEnum> {
static matjson::Value to_json(SettingPosEnum const& value) {
log::info("to_json {}", static_cast<int>(value));
static matjson::Value toJson(SettingPosEnum const& value) {
switch (value) {
case SettingPosEnum::TopLeft:
return 1;
Expand All @@ -107,32 +105,33 @@ struct matjson::Serialize<SettingPosEnum> {
return 4;
}
}
static SettingPosEnum from_json(matjson::Value const& value) {
switch (value.as_int()) {
case 1: return SettingPosEnum::TopLeft;
case 2: return SettingPosEnum::TopRight;
case 3: return SettingPosEnum::BottomLeft;
case 4: return SettingPosEnum::BottomRight;
default: throw matjson::JsonException(fmt::format("invalid SettingPosEnum value '{}'", value));
static Result<SettingPosEnum> fromJson(matjson::Value const& value) {
switch (value.asInt().unwrapOrDefault()) {
case 1: return Ok(SettingPosEnum::TopLeft);
case 2: return Ok(SettingPosEnum::TopRight);
case 3: return Ok(SettingPosEnum::BottomLeft);
case 4: return Ok(SettingPosEnum::BottomRight);
default: return Err("Invalid SettingPosEnum value '{}'", value.asInt().unwrapOrDefault());
}
}
static bool is_json(matjson::Value const& json) {
return json.is_number() || json.is_string();
return json.isNumber() || json.isString();
}
};

class SettingPosValue : public SettingBaseValueV3<SettingPosEnum> {
public:
static Result<std::shared_ptr<SettingPosValue>> parse(std::string const& key, std::string const& modID, matjson::Value const& json) {
static Result<std::shared_ptr<SettingV3>> parse(std::string const& key, std::string const& modID, matjson::Value const& json) {
auto res = std::make_shared<SettingPosValue>();
auto root = checkJson(json, "SettingPosValue");
res->parseBaseProperties(key, modID, root);
root.checkUnknownKeys();
return root.ok(res);
return root.ok(std::static_pointer_cast<SettingV3>(res));
}
SettingNodeV3* createNode(float width) override;
};


template <>
struct geode::SettingTypeForValueType<SettingPosEnum> {
using SettingType = SettingPosValue;
Expand Down Expand Up @@ -263,13 +262,13 @@ class SettingPosNode : public SettingValueNodeV3<SettingPosValue> {

class SettingCreditsValue : public SettingV3 {
public:
static Result<std::shared_ptr<SettingCreditsValue>> parse(std::string const& key, std::string const& modID, matjson::Value const& json) {
static Result<std::shared_ptr<SettingV3>> parse(std::string const& key, std::string const& modID, matjson::Value const& json) {
auto res = std::make_shared<SettingCreditsValue>();
auto root = checkJson(json, "SettingCreditsValue");
res->init(key, modID, root);
res->parseNameAndDescription(root);
root.checkUnknownKeys();
return root.ok(res);
return root.ok(std::static_pointer_cast<SettingV3>(res));
}

bool load(matjson::Value const& json) override {
Expand Down
4 changes: 2 additions & 2 deletions src/Styles/NewGJCommentList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class $modify(CommentCell) {
m_fields->m_listener.bind([] (web::WebTask::Event* e) {
if (web::WebResponse* res = e->getValue()) {
if (res->ok()) {
result_global = res->string().value();
result_global = res->string().unwrapOrDefault();
}
}
});
Expand All @@ -291,4 +291,4 @@ class $modify(CommentCell) {
requestGDUtilsBadges(layer, comment->m_commentID);
}
}
};
};
2 changes: 1 addition & 1 deletion src/Styles/NewProfilePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ class $modify(ProfilePage) {
m_fields->m_listener.bind([expect = std::move(expect), then = std::move(then)] (web::WebTask::Event* e) {
if (web::WebResponse* res = e->getValue()) {
if (res->ok()) {
then(res->string().value());
then(res->string().unwrapOrDefault());
} else {
expect("Request failed");
}
Expand Down
Loading

0 comments on commit 8cab4c7

Please sign in to comment.