Skip to content

Commit

Permalink
chore: format code
Browse files Browse the repository at this point in the history
i forgot again
  • Loading branch information
FlafyDev committed Apr 6, 2024
1 parent 73df040 commit b2a0ead
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 44 deletions.
14 changes: 8 additions & 6 deletions src/managers/auto_nong_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ void AutoNongManager::loadIndexes() {
if (index.size() < 5)
continue;
log::info("Loading index: {}", index);
geode::utils::web::AsyncWebRequest().fetch(index).bytes().then(
[this, index](const geode::ByteVector &r) {
geode::utils::web::AsyncWebRequest()
.fetch(index)
.bytes()
.then([this, index](const geode::ByteVector &r) {
std::vector<uint8_t> rVec = r;
std::string jsonString = decompressGz(rVec);

Expand Down Expand Up @@ -58,10 +60,10 @@ void AutoNongManager::loadIndexes() {
}
}
}
Loader::get()->queueInMainThread([this, index]() {
log::info("Loaded index: {}", index);
});
}).send();
Loader::get()->queueInMainThread(
[this, index]() { log::info("Loaded index: {}", index); });
})
.send();
}
}

Expand Down
76 changes: 38 additions & 38 deletions src/ui/multi_string_setting.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "multi_string_setting.hpp"
#include "../types/serializable_vector.hpp"
#include <algorithm>
#include <vector>
#include "../types/serializable_vector.hpp"

using namespace geode::prelude;

Expand Down Expand Up @@ -32,8 +32,8 @@ class MultiStringSettingPopup
return true;
}

void onActionButton(CCObject* target) {
auto id = static_cast<CCNode*>(target)->getID();
void onActionButton(CCObject *target) {
auto id = static_cast<CCNode *>(target)->getID();
auto index = std::stoi(id.substr(4));
if (index == m_localValue.size() - 1) {
m_localValue.push_back("");
Expand All @@ -44,7 +44,6 @@ class MultiStringSettingPopup
createList();
}


void createList() {
std::optional<float> previousListPosition = {};
if (m_list != nullptr) {
Expand All @@ -69,36 +68,36 @@ class MultiStringSettingPopup
auto size = this->m_mainLayer->getContentSize();

for (int i = 0; i < m_localValue.size(); i++) {
auto last = i == m_localValue.size() - 1;
auto size2 = CCSize {size.width - 10.f, 40.f};

auto menu = CCMenu::create();
menu->setPosition(0, 0);
// menu->setContentSize(size2);


auto inputNode = TextInput::create(103.f, "Index url", "chatFont.fnt");
inputNode->setScale(1.f);
inputNode->setPosition(size2.width / 2 - 15.f, size2.height / 2);
inputNode->setFilter(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~:/?#[]@!$&'()*+,;=");
inputNode->setMaxCharCount(300);
inputNode->setWidth(size2.width - 60.f);
inputNode->setString(m_localValue[i], false);
inputNode->setCallback([this, i](std::string const &str) {
m_localValue[i] = str;
m_newStringsCallback(m_localValue);
});
menu->addChild(inputNode);

auto spr = last ? CCSprite::create("addIcon.png"_spr)
: CCSprite::createWithSpriteFrameName("GJ_deleteIcon_001.png");
spr->setScale(0.75f);
auto btn = CCMenuItemSpriteExtra::create(spr, this, menu_selector(MultiStringSettingPopup::onActionButton));
btn->setID(fmt::format("btn-{}", i));
btn->setPosition(size2.width - 15.f, size2.height / 2);
menu->addChild(btn);
cells->addObject(menu);
auto last = i == m_localValue.size() - 1;
auto size2 = CCSize{size.width - 10.f, 40.f};

auto menu = CCMenu::create();
menu->setPosition(0, 0);
// menu->setContentSize(size2);

auto inputNode = TextInput::create(103.f, "Index url", "chatFont.fnt");
inputNode->setScale(1.f);
inputNode->setPosition(size2.width / 2 - 15.f, size2.height / 2);
inputNode->setFilter(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~:/?#[]@!$&'()*+,;=");
inputNode->setMaxCharCount(300);
inputNode->setWidth(size2.width - 60.f);
inputNode->setString(m_localValue[i], false);
inputNode->setCallback([this, i](std::string const &str) {
m_localValue[i] = str;
m_newStringsCallback(m_localValue);
});
menu->addChild(inputNode);

auto spr = last ? CCSprite::create("addIcon.png"_spr)
: CCSprite::createWithSpriteFrameName("GJ_deleteIcon_001.png");
spr->setScale(0.75f);
auto btn = CCMenuItemSpriteExtra::create(
spr, this, menu_selector(MultiStringSettingPopup::onActionButton));
btn->setID(fmt::format("btn-{}", i));
btn->setPosition(size2.width - 15.f, size2.height / 2);
menu->addChild(btn);
cells->addObject(menu);
}

auto list = ListView::create(cells, 40.f, size.width - 8.f, size.height - 16.f);
Expand Down Expand Up @@ -139,7 +138,6 @@ class MultiStringSettingPopup
}
};


bool MultiStringSettingNode::init(MultiStringSettingValue *value, float width) {
if (!SettingNode::init(value))
return false;
Expand Down Expand Up @@ -235,16 +233,18 @@ bool MultiStringSettingNode::hasUncommittedChanges() {
}

bool MultiStringSettingNode::hasNonDefaultValue() {
if (m_localValue.size() != m_defaultValue.size()) return true;
if (m_localValue.size() != m_defaultValue.size())
return true;
for (int i = 0; i < m_localValue.size(); i++) {
if (m_localValue[i] != m_defaultValue[i]) return true;
if (m_localValue[i] != m_defaultValue[i])
return true;
}
return false;
}

void MultiStringSettingNode::resetToDefault() {
m_localValue.clear();
for (std::string& str : m_defaultValue) {
for (std::string &str : m_defaultValue) {
m_localValue.push_back(str);
}
updateVisuals();
Expand Down

0 comments on commit b2a0ead

Please sign in to comment.