Skip to content

Commit 5cdd5e6

Browse files
authored
Cleanup UI (#2)
* UI Cleanup (and mac action) * Update logo.png * Fix clear search button not disappearing when switching page
1 parent d56f6a8 commit 5cdd5e6

File tree

4 files changed

+83
-28
lines changed

4 files changed

+83
-28
lines changed

.github/workflows/multi-platform.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
- name: Windows
1616
os: windows-latest
1717

18-
#- name: macOS
19-
# os: macos-latest
18+
- name: macOS
19+
os: macos-latest
2020

2121
- name: Android32
2222
os: ubuntu-latest

logo.png

-51.8 KB
Loading

src/SettingsLayer.cpp

Lines changed: 78 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
SearchPopup* SearchPopup::create(SearchCB callback) {
44
auto ret = new SearchPopup();
5-
if (ret && ret->initAnchored(210.f, 180.f, callback)) {
5+
if (ret && ret->initAnchored(210.f, 130.f, callback)) {
66
ret->autorelease();
77
return ret;
88
}
@@ -16,15 +16,15 @@ bool SearchPopup::setup(SearchCB callback) {
1616
this->setTitle("Search");
1717

1818
m_input = TextInput::create(150.f, "Query here");
19-
m_mainLayer->addChildAtPosition(m_input, Anchor::Center);
19+
m_mainLayer->addChildAtPosition(m_input, Anchor::Center, {0, 7.5f});
2020

2121
auto btn = CCMenuItemSpriteExtra::create(
2222
ButtonSprite::create("Search"), this, menu_selector(SearchPopup::onSearch)
2323
);
2424
auto menu = CCMenu::create();
2525
menu->addChild(btn);
2626

27-
m_mainLayer->addChildAtPosition(menu, Anchor::Bottom);
27+
m_mainLayer->addChildAtPosition(menu, Anchor::Bottom, {0, 25});
2828

2929
return true;
3030
}
@@ -72,14 +72,14 @@ bool SettingCell::init(std::string name, std::string gv, SettingCellType type) {
7272
m_toggler = CCMenuItemToggler::createWithStandardSprites(
7373
this,
7474
menu_selector(SettingCell::onCheckboxToggled),
75-
1.f
75+
0.75f
7676
);
7777
m_toggler->toggle(
7878
GameManager::get()->getGameVariable(gv.c_str())
7979
);
8080

8181
spr = CCSprite::createWithSpriteFrameName("GJ_infoIcon_001.png");
82-
spr->setScale(0.75f);
82+
spr->setScale(0.65f);
8383
btn = CCMenuItemSpriteExtra::create(
8484
spr, this, menu_selector(SettingCell::onInfo)
8585
);
@@ -90,16 +90,16 @@ bool SettingCell::init(std::string name, std::string gv, SettingCellType type) {
9090
break;
9191
case FMODDebug:
9292
spr = ButtonSprite::create("Debug", "goldFont.fnt", "GJ_button_05.png");
93-
spr->setScale(0.7f);
93+
spr->setScale(0.5f);
9494
btn = CCMenuItemSpriteExtra::create(
9595
spr, this, menu_selector(SettingCell::onFMODDebug)
9696
);
97-
btn->setPositionX(-20.f);
97+
btn->setPositionX(-10.f);
9898
menu->addChild(btn);
9999
break;
100100
case SongSelect:
101101
spr = CCSprite::createWithSpriteFrameName("GJ_savedSongsBtn_001.png");
102-
spr->setScale(0.7f);
102+
spr->setScale(0.4f);
103103
menu->addChild(CCMenuItemSpriteExtra::create(
104104
spr, this, menu_selector(SettingCell::onSongSelect)
105105
));
@@ -111,9 +111,19 @@ bool SettingCell::init(std::string name, std::string gv, SettingCellType type) {
111111
input->setString(std::to_string(fmodEngine->m_musicOffset));
112112
}
113113
input->setCallback([this, fmodEngine](std::string offset) {
114-
fmodEngine->m_musicOffset = std::stoi(offset);
114+
fmodEngine->m_musicOffset = 0;
115+
116+
std::stringstream ss;
117+
ss << offset;
118+
int num = 0;
119+
ss >> num;
120+
121+
if (ss.good()) {
122+
fmodEngine->m_musicOffset = std::stoi(offset);
123+
}
115124
});
116-
input->setPositionX(-35.f);
125+
input->setPositionX(-25.f);
126+
input->setScale(0.75f);
117127
menu->addChild(input);
118128
break;
119129
case Separator:
@@ -122,7 +132,7 @@ bool SettingCell::init(std::string name, std::string gv, SettingCellType type) {
122132
name.c_str(),
123133
"goldFont.fnt"
124134
);
125-
text->limitLabelWidth(300.f, 1.f, 0.1);
135+
text->limitLabelWidth(300.f, 0.75f, 0.1);
126136
this->addChildAtPosition(text, Anchor::Center);
127137
break;
128138
}
@@ -134,7 +144,7 @@ bool SettingCell::init(std::string name, std::string gv, SettingCellType type) {
134144

135145
this->setContentSize({
136146
365.f,
137-
50.f
147+
30.f
138148
});
139149

140150
return true;
@@ -256,8 +266,9 @@ CCSprite* createCategoryBtnSprite(std::string name, bool isSelected = false) {
256266
);
257267
auto text = CCLabelBMFont::create(name.c_str(), "bigFont.fnt");
258268
text->limitLabelWidth(75.f, 0.7f, 0.1f);
259-
sprite->setScale(0.8f);
269+
sprite->setScale(1.f);
260270
sprite->addChildAtPosition(text, Anchor::Center);
271+
text->setPositionY(text->getPositionY() + 1.5f);
261272
return sprite;
262273
}
263274

@@ -296,7 +307,7 @@ bool SettingsLayer::setup() {
296307

297308
CATEGORY_BTN("Gameplay", SettingPage::Gameplay)
298309
CATEGORY_BTN("Practice", SettingPage::Practice)
299-
CATEGORY_BTN("Perf.", SettingPage::Performance)
310+
CATEGORY_BTN("Performance", SettingPage::Performance)
300311
CATEGORY_BTN("Audio", SettingPage::Audio)
301312
CATEGORY_BTN("Misc", SettingPage::Misc)
302313
CATEGORY_BTN("Keys", SettingPage::Keybinds)
@@ -323,13 +334,40 @@ bool SettingsLayer::setup() {
323334
auto searchBtn = CCMenuItemSpriteExtra::create(
324335
searchBtnSpr, this, menu_selector(SettingsLayer::onSearchBtn)
325336
);
337+
338+
auto searchBtnOffSpr = CCSprite::createWithSpriteFrameName("gj_findBtnOff_001.png");
339+
m_searchClearBtn = CCMenuItemSpriteExtra::create(
340+
searchBtnOffSpr, this, menu_selector(SettingsLayer::onClearSearch)
341+
);
342+
343+
m_searchClearBtn->setVisible(false);
344+
326345
auto searchMenu = CCMenu::create();
346+
searchMenu->setLayout(
347+
RowLayout::create()
348+
->setAxisAlignment(AxisAlignment::Start)
349+
->setAxisReverse(true)
350+
);
351+
searchMenu->setContentSize({70, 35});
352+
searchMenu->setAnchorPoint({1, 0.5});
327353
searchMenu->addChild(searchBtn);
328-
m_mainLayer->addChildAtPosition(searchMenu, Anchor::TopRight);
354+
searchMenu->addChild(m_searchClearBtn);
355+
searchMenu->updateLayout();
356+
m_mainLayer->addChildAtPosition(searchMenu, Anchor::TopRight, {15, 0});
329357

330358
return true;
331359
}
332360

361+
void SettingsLayer::onClearSearch(CCObject* sender) {
362+
363+
auto page = static_cast<SettingPage>(static_cast<CCInteger*>(
364+
m_currentBtn->getUserObject()
365+
)->getValue());
366+
367+
switchPage(page, false, m_currentBtn);
368+
m_searchClearBtn->setVisible(false);
369+
}
370+
333371
void SettingsLayer::onSearchBtn(CCObject* sender) {
334372
SearchPopup::create([this](std::string query) {
335373
auto newList = CCArray::create();
@@ -345,7 +383,12 @@ void SettingsLayer::onSearchBtn(CCObject* sender) {
345383

346384
switchPage(page, false, m_currentBtn);
347385

348-
if (query == "") return;
386+
if (query == "") {
387+
m_searchClearBtn->setVisible(false);
388+
return;
389+
}
390+
391+
m_searchClearBtn->setVisible(true);
349392

350393
for (auto cell : CCArrayExt<SettingCell*>(m_listItems)) {
351394
if (toLower(cell->m_name).find(toLower(query)) != std::string::npos) {
@@ -357,7 +400,7 @@ void SettingsLayer::onSearchBtn(CCObject* sender) {
357400
}
358401

359402
m_listItems = newList;
360-
m_listView->removeFromParent();
403+
m_border->removeFromParent();
361404
this->refreshList();
362405
})->show();
363406
}
@@ -373,7 +416,9 @@ void SettingsLayer::onCategoryBtn(CCObject* sender) {
373416

374417
void SettingsLayer::switchPage(SettingPage page, bool isFirstRun, CCMenuItemSpriteExtra* btn) {
375418
m_listItems = CCArray::create();
376-
419+
if(m_searchClearBtn){
420+
m_searchClearBtn->setVisible(false);
421+
}
377422
#define SETTING(name, gv) m_listItems->addObject( \
378423
SettingCell::create(name, gv) \
379424
);
@@ -447,7 +492,7 @@ void SettingsLayer::switchPage(SettingPage page, bool isFirstRun, CCMenuItemSpri
447492
SEPARATOR("LDM")
448493
SETTING("Auto LDM", "0108")
449494
SETTING("Extra LDM", "0136")
450-
SEPARATOR("Improvements (may cause issues on low end devices)")
495+
SEPARATOR("Enhancements")
451496
SETTING("Increase Max Levels", "0042")
452497
SETTING("Disable Object Alert", "0056")
453498
SETTING("Save Gauntlet Levels", "0127")
@@ -486,7 +531,7 @@ void SettingsLayer::switchPage(SettingPage page, bool isFirstRun, CCMenuItemSpri
486531
break;
487532
}
488533
if (!isFirstRun) {
489-
m_listView->removeFromParent();
534+
m_border->removeFromParent();
490535
}
491536

492537
this->refreshList();
@@ -503,15 +548,24 @@ void SettingsLayer::switchPage(SettingPage page, bool isFirstRun, CCMenuItemSpri
503548
}
504549

505550
void SettingsLayer::refreshList() {
506-
m_listView = ListView::create(m_listItems, 50.f, 365.f, 245.f);
507-
m_listView->ignoreAnchorPointForPosition(false);
551+
ListView* listView = ListView::create(m_listItems, 30.f, 365.f, 245.f);
552+
553+
m_border = Border::create(listView, {0, 0, 0, 75}, {365.f, 245.f});
554+
if(CCScale9Sprite* borderSprite = typeinfo_cast<CCScale9Sprite*>(m_border->getChildByID("geode.loader/border_sprite"))) {
555+
float scaleFactor = 1.5f;
556+
borderSprite->setContentSize(CCSize{borderSprite->getContentSize().width, borderSprite->getContentSize().height + 1} / scaleFactor);
557+
borderSprite->setScale(scaleFactor);
558+
borderSprite->setPositionY(-0.5);
559+
}
560+
m_border->ignoreAnchorPointForPosition(false);
561+
508562
for (auto cell : CCArrayExt<CCNode*>(m_listItems)) {
509563
cell->setContentSize({
510564
365.f,
511-
50.f
565+
30.f
512566
});
513567
cell->updateLayout();
514568
}
515569

516-
m_mainLayer->addChildAtPosition(m_listView, Anchor::Right, ccp(-195.f, 0.f));
570+
m_mainLayer->addChildAtPosition(m_border, Anchor::Right, ccp(-195.f, 0.f));
517571
}

src/SettingsLayer.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ class SettingCell : public CCNode {
5151
class SettingsLayer : public geode::Popup<> {
5252
protected:
5353
CCArray* m_listItems;
54-
ListView* m_listView;
54+
Border* m_border;
5555
CCMenuItemSpriteExtra* m_currentBtn;
56+
CCMenuItemSpriteExtra* m_searchClearBtn;
5657

5758
bool setup() override;
5859
void createSettingCheckbox(
@@ -62,7 +63,7 @@ class SettingsLayer : public geode::Popup<> {
6263
void switchPage(SettingPage, bool, CCMenuItemSpriteExtra*);
6364
void onCategoryBtn(CCObject*);
6465
void onSearchBtn(CCObject*);
65-
66+
void onClearSearch(CCObject*);
6667
void refreshList();
6768
public:
6869
static SettingsLayer* create();

0 commit comments

Comments
 (0)