Skip to content

Commit f938a30

Browse files
committed
stuff
1 parent 9b0f4af commit f938a30

File tree

10 files changed

+115
-26
lines changed

10 files changed

+115
-26
lines changed
1.08 KB
Loading

src/Client/CategoryNode.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,14 @@ void CategoryNode::updateUI()
7878
{
7979
auto n = node.second;
8080

81-
float x = (n->getTag() % 2 == 0) ? 85 : (showScrollbar ? 252 : 260);
81+
bool right = (n->getTag() % 2 != 0);
82+
float usWidth = showScrollbar ? getContentWidth() - scrollbar->getScaledContentWidth() + 2.5f : getContentWidth();
83+
84+
float x = right ? 85 : (showScrollbar ? 252 : 260);
8285
float y = floor(n->getTag() / 2);
8386

84-
n->setPosition(ccp(x, height2 - (y * 28) + 6));
87+
n->setAnchorPoint(ccp(right ? 1 : 0, 0.5f));
88+
n->setPosition(ccp(right ? usWidth - 2.5f : 2.5f, height2 - (y * 28) + 6));
8589
}
8690

8791
scroll->moveToTop();

src/Client/InputModuleNode.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,17 @@ void InputModuleNode::setup()
2727

2828
this->scheduleUpdate();
2929

30-
auto label = AdvLabelBMFont::createWithString(fmt::format("{}{}", mod->getName(), mod->appendColon() ? ":" : "").c_str(), "bigFont.fnt");
30+
label = AdvLabelBMFont::createWithString(fmt::format("{}{}", mod->getName(), mod->appendColon() ? ":" : "").c_str(), "bigFont.fnt");
3131
label->setAnchorPoint(ccp(0, 0.5f));
3232
label->limitLabelWidth(75, 0.5f, 0);
3333

34-
input = BetterInputNode::create(90 + (75 - label->getScaledContentWidth()), mod->getPlaceholderString());
34+
input = BetterInputNode::create(getContentWidth() - 4 - label->getScaledContentWidth() - 15, mod->getPlaceholderString());
35+
input->setContentHeight(getContentHeight() - 2.5f * 2);
36+
input->setAnchorPoint(ccp(1, 0.5f));
3537
input->setMaxChars(mod->getMaxCharCount());
3638
input->setCharFilter(mod->getStringFilter());
3739
input->setString(mod->getString());
3840
input->setDelegate(this);
39-
input->setScale(0.775f);
4041
input->setAnchorPoint(ccp(1, 0.5f));
4142

4243
if (mod->getStringFilter() == "1234567890")
@@ -57,11 +58,11 @@ void InputModuleNode::setup()
5758
hint->setAnchorPoint(ccp(1, 0));
5859
hint->setZOrder(3);
5960

60-
this->addChildAtPosition(hint, Anchor::BottomRight, ccp(-10, (getContentHeight() - input->getScaledContentHeight()) / 2));
61+
this->addChildAtPosition(hint, Anchor::BottomRight, ccp(-2.5f, (getContentHeight() - input->getScaledContentHeight()) / 2));
6162
}
6263

6364
this->addChildAtPosition(label, Anchor::Left, ccp(4, 0));
64-
this->addChildAtPosition(input, Anchor::Right, ccp(-10, 0));
65+
this->addChildAtPosition(input, Anchor::Right, ccp(-2.5f, 0));
6566
}
6667

6768
void InputModuleNode::textChanged(CCTextInputNode* p0)

src/Client/ModuleNode.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,20 @@ void ModuleNode::updateAllNodes(ModuleNode* except)
285285
ModuleNode::~ModuleNode()
286286
{
287287
nodes.erase(std::find(nodes.begin(), nodes.end(), this));
288+
}
289+
290+
void ModuleNode::draw()
291+
{
292+
#ifndef QOLMOD_GUI_DEBUG
293+
return;
294+
#endif
295+
296+
ccDrawSolidRect(ccp(0, 0), getContentSize(), ccc4f(1, 0, 0, 1));
297+
298+
if (label)
299+
{
300+
auto bb = label->boundingBox();
301+
302+
ccDrawSolidRect(ccp(bb.getMinX(), bb.getMinY()), ccp(bb.getMaxX(), bb.getMaxY()), ccc4f(0, 0, 1, 1));
303+
}
288304
}

src/Client/ModuleNode.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ class ModuleNode : public CCMenu
3535
void onUpdateLabelColour(float dt);
3636

3737
virtual void updateNode();
38+
virtual void draw();
3839
bool init(Module* module);
3940
};

src/Client/SubCategoryNode.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "SubCategoryNode.hpp"
22
#include "../Localisation/LocalisationManager.hpp"
3+
#include "../Utils/RealtimeAction.hpp"
34

45
void SubCategoryNode::updateUI()
56
{
@@ -34,6 +35,8 @@ bool SubCategoryNode::init()
3435
if (!CategoryNode::init())
3536
return false;
3637

38+
this->scheduleUpdate();
39+
3740
float height = 25;
3841

3942
selectSubMenu = CCMenu::create();
@@ -101,4 +104,34 @@ void SubCategoryNode::onSelectSub(CCObject* sender)
101104
selectedSub[getID()] = static_cast<CCNode*>(sender)->getID();
102105

103106
updateUI();
107+
}
108+
109+
void SubCategoryNode::update(float dt)
110+
{
111+
for (auto btn : normalBtns)
112+
{
113+
bool sel = btn.second->m_bSelected || (btn.first == selectedSub[getID()]);
114+
float opacity = sel ? 125 : 100;
115+
116+
if (!categoryBtnsSelCheck.contains(btn.second))
117+
{
118+
categoryBtnsSelCheck.emplace(btn.second, sel);
119+
120+
static_cast<CategoryTabSprite*>(btn.second->getNormalImage())->background->setOpacity(opacity);
121+
static_cast<CategoryTabSprite*>(btn.second->getSelectedImage())->background->setOpacity(opacity);
122+
}
123+
else
124+
{
125+
if (categoryBtnsSelCheck[btn.second] != sel)
126+
{
127+
categoryBtnsSelCheck[btn.second] = sel;
128+
129+
static_cast<CategoryTabSprite*>(btn.second->getNormalImage())->background->stopAllActions();
130+
static_cast<CategoryTabSprite*>(btn.second->getSelectedImage())->background->stopAllActions();
131+
132+
static_cast<CategoryTabSprite*>(btn.second->getNormalImage())->background->runAction(RealtimeAction::create(CCFadeTo::create(0.1f, opacity)));
133+
static_cast<CategoryTabSprite*>(btn.second->getSelectedImage())->background->runAction(RealtimeAction::create(CCFadeTo::create(0.1f, opacity)));
134+
}
135+
}
136+
}
104137
}

src/Client/SubCategoryNode.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class SubCategoryNode : public CategoryNode
99
CCMenu* selectSubMenu = nullptr;
1010
std::unordered_map<std::string, CategoryTabSprite*> normalSprs = {};
1111
std::unordered_map<std::string, CCMenuItemSpriteExtra*> normalBtns = {};
12+
std::unordered_map<CCMenuItemSpriteExtra*, bool> categoryBtnsSelCheck = {};
1213
std::unordered_map<std::string, CategoryNode*> categoryNodes = {};
1314
static inline std::unordered_map<std::string, std::string> selectedSub = {};
1415

@@ -22,4 +23,5 @@ class SubCategoryNode : public CategoryNode
2223
virtual void updateUI();
2324

2425
bool init();
26+
virtual void update(float dt);
2527
};

src/GUI/AndroidUI.cpp

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
#include "BetterInputNode.hpp"
1212
#include "BlurLayer.hpp"
1313
#include "FloatingButton/FloatingUIManager.hpp"
14+
#include "EasyBG.hpp"
1415

1516
bool AndroidUI::setup()
1617
{
1718
this->addChild(CCBlurLayer::create(), -3);
19+
this->scheduleUpdate();
1820

1921
rt = CCRenderTexture::create(getContentWidth(), getContentHeight());
2022
rt->getSprite()->setBlendFunc(this->getBlendFunc());
@@ -102,22 +104,19 @@ void AndroidUI::populateModules()
102104

103105
void AndroidUI::populateTabs()
104106
{
105-
auto bg = CCScale9Sprite::create("square02b_small.png");
106-
bg->setContentSize(ccp(110, m_size.height - 10 * 2) / 0.5f);
107+
auto bg = EasyBG::create();
108+
bg->setContentSize(ccp(110, m_size.height - 10 * 2));
107109
bg->setAnchorPoint(ccp(0, 0.5f));
108-
bg->setScale(0.5f);
109-
bg->setColor(ccc3(0, 0, 0));
110-
bg->setOpacity(100);
111110

112111
tabsMenu = CCMenu::create();
113-
tabsMenu->setContentSize((bg->getContentSize() / 2) + ccp(0, -10));
112+
tabsMenu->setContentSize((bg->getContentSize()) + ccp(0, -5));
114113
tabsMenu->setAnchorPoint(ccp(0, 0.5f));
115114
tabsMenu->ignoreAnchorPointForPosition(false);
116-
tabsMenu->setLayout(ColumnLayout::create()->setAxisReverse(true)->setAxisAlignment(AxisAlignment::End)->setCrossAxisOverflow(true)->setAutoScale(false)->setGap(3.5f));
115+
tabsMenu->setLayout(ColumnLayout::create()->setAxisReverse(true)->setAxisAlignment(AxisAlignment::End)->setCrossAxisOverflow(true)->setAutoScale(false)->setGap(2.5f));
117116
tabsMenu->getLayout()->ignoreInvisibleChildren(true);
118117

119118
m_mainLayer->addChildAtPosition(bg, Anchor::Left, ccp(10, 0));
120-
m_mainLayer->addChildAtPosition(tabsMenu, Anchor::Left, ccp(10 + 5, 0));
119+
m_mainLayer->addChildAtPosition(tabsMenu, Anchor::Left, ccp(10 + 2.5f, 0));
121120

122121
for (auto category : categoryOrders)
123122
{
@@ -131,13 +130,13 @@ void AndroidUI::populateTabs()
131130
tabsMenu->addChild(geode::SpacerNode::create());
132131

133132
// TODO: Bottom row
134-
/*
133+
135134
bottomTabsContainer = CCMenu::create();
136135
bottomTabsContainer->ignoreAnchorPointForPosition(false);
137-
bottomTabsContainer->setContentSize(ccp(100, 20));
138-
bottomTabsContainer->setLayout(AxisLayout::create()->setAutoScale(false)->setAxisAlignment(AxisAlignment::Even));
136+
bottomTabsContainer->setContentSize(ccp(105, 20));
137+
bottomTabsContainer->setLayout(AxisLayout::create()->setAutoScale(false)->setAxisAlignment(AxisAlignment::Between));
139138
tabsMenu->addChild(bottomTabsContainer);
140-
*/
139+
141140

142141
continue;
143142
}
@@ -172,16 +171,16 @@ void AndroidUI::addTab(std::string name, std::string id, std::string sprite)
172171
auto sprHeld = CategoryTabSprite::create(CategoryTabType::Text, name, sprite);
173172
sprHeld->updateSelection(CategorySelectionType::Hovered);
174173

175-
sprNormal->setContentSize(ccp(100, 20));
176-
sprHeld->setContentSize(ccp(100, 20));
174+
sprNormal->setContentSize(ccp(105, 20));
175+
sprHeld->setContentSize(ccp(105, 20));
177176

178177
if (bottomTabsContainer)
179178
{
180179
sprNormal->label->setString("");
181-
sprNormal->setContentSize(ccp((100 - 5 * 2) / 3, 20));
180+
sprNormal->setContentSize(ccp((105 - 2.5f) / 2, 20));
182181

183182
sprHeld->label->setString("");
184-
sprHeld->setContentSize(ccp((100 - 5 * 2) / 3, 20));
183+
sprHeld->setContentSize(ccp((105 - 2.5f) / 2, 20));
185184
}
186185

187186
auto btn = CCMenuItemSpriteExtra::create(sprNormal, this, menu_selector(AndroidUI::onSelectTab));
@@ -409,4 +408,34 @@ void AndroidUI::visit()
409408
rt->setPosition(getContentSize() / 2);
410409
rt->getSprite()->setOpacity(drawOpacity->getOpacity());
411410
rt->visit();
411+
}
412+
413+
void AndroidUI::update(float dt)
414+
{
415+
for (auto btn : categoryBtns)
416+
{
417+
bool sel = btn.second->m_bSelected || (btn.second == categoryBtns[selectedCategory]);
418+
float opacity = sel ? 125 : 100;
419+
420+
if (!categoryBtnsSelCheck.contains(btn.second))
421+
{
422+
categoryBtnsSelCheck.emplace(btn.second, sel);
423+
424+
static_cast<CategoryTabSprite*>(btn.second->getNormalImage())->background->setOpacity(opacity);
425+
static_cast<CategoryTabSprite*>(btn.second->getSelectedImage())->background->setOpacity(opacity);
426+
}
427+
else
428+
{
429+
if (categoryBtnsSelCheck[btn.second] != sel)
430+
{
431+
categoryBtnsSelCheck[btn.second] = sel;
432+
433+
static_cast<CategoryTabSprite*>(btn.second->getNormalImage())->background->stopAllActions();
434+
static_cast<CategoryTabSprite*>(btn.second->getSelectedImage())->background->stopAllActions();
435+
436+
static_cast<CategoryTabSprite*>(btn.second->getNormalImage())->background->runAction(RealtimeAction::create(CCFadeTo::create(0.1f, opacity)));
437+
static_cast<CategoryTabSprite*>(btn.second->getSelectedImage())->background->runAction(RealtimeAction::create(CCFadeTo::create(0.1f, opacity)));
438+
}
439+
}
440+
}
412441
}

src/GUI/AndroidUI.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class AndroidUI : public geode::Popup<>
3636
CCLayerColor* drawOpacity = nullptr;
3737
std::map<std::string, CategoryNode*> categories = {};
3838
std::map<std::string, CCMenuItemSpriteExtra*> categoryBtns = {};
39+
std::map<CCMenuItemSpriteExtra*, bool> categoryBtnsSelCheck = {};
3940
std::map<std::string, CategoryTabSprite*> categorySprs = {};
4041
// static to keep between reopens
4142
static inline std::string selectedCategory = "Level";
@@ -78,6 +79,7 @@ class AndroidUI : public geode::Popup<>
7879
void close();
7980
virtual bool setup();
8081
virtual void visit();
82+
virtual void update(float dt);
8183
};
8284

8385
class QOLModUIOpenEvent : public geode::Event

src/GUI/CategoryTabSprite.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ bool CategoryTabSprite::init(CategoryTabType type, std::string name, std::string
2121
if (!CCNode::init())
2222
return false;
2323

24-
outline = CCScale9Sprite::create("GJ_square07.png");
25-
outline->setScale(0.5f);
24+
outline = CCScale9Sprite::create("squareOverlay.png"_spr);
2625

2726
background = CCScale9Sprite::create("square02b_small.png");
2827
background->setColor(ccc3(0, 0, 0));
2928
background->setOpacity(100);
3029
background->setScale(0.5f);
3130

31+
outline->setScale(0.6f);
32+
3233
if (!icon.empty())
3334
{
3435
if (sprite = CCSprite::create(icon.c_str()); sprite)
@@ -94,7 +95,7 @@ void CategoryTabSprite::setContentSize(const CCSize& contentSize)
9495
label->limitLabelWidth((this->getContentWidth() - 7.5f) / 0.5f, 0.75f, 0.1f);
9596
label->setScale(label->getScale() / 2);
9697

97-
outline->setContentSize(contentSize * 2);
98+
outline->setContentSize(contentSize / 0.6f);
9899
background->setContentSize(contentSize * 2);
99100

100101
if (sprite && label->getContentWidth() != 0)

0 commit comments

Comments
 (0)