Skip to content

Revamped UI #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d9efda0
First UI Iteration
Alphalaneous May 1, 2025
540d937
Smooth dragging!
Alphalaneous May 1, 2025
1f61e54
Manually position buttons, show pack counts
Alphalaneous May 1, 2025
6497f53
Bounded ScrollLayers
Alphalaneous May 2, 2025
164bfa8
Show alert on where Texture Loader is
Alphalaneous May 2, 2025
806fa63
Update info label on change
Alphalaneous May 2, 2025
60420f9
add some node IDs
Alphalaneous May 2, 2025
a903fb7
Adjust some colors and scales
Alphalaneous May 2, 2025
b6ae762
Added this ID cuz it needed one
Alphalaneous May 2, 2025
3a28454
Move this so it actually is always set
Alphalaneous May 2, 2025
9d38515
Fix targetIdx being reset to 0 if higher than count
Alphalaneous May 3, 2025
b7b1c9f
Fix click without drag
Alphalaneous May 3, 2025
02e787c
Reposition button
Alphalaneous May 7, 2025
f8f207e
Merge branch 'geode-sdk:main' into new-ui
Alphalaneous May 7, 2025
7079548
Add iOS workflow
Alphalaneous May 7, 2025
f259724
Merge branch 'new-ui' of https://github.com/Alphalaneous/textureldr i…
Alphalaneous May 7, 2025
57efc00
Make iOS happy
Alphalaneous May 7, 2025
26fdae3
Slight Tweak
Alphalaneous May 7, 2025
f2db687
Update about.md for new location
Alphalaneous May 7, 2025
4859ec0
Hopefully plays nice on mobile
Alphalaneous May 7, 2025
72604c0
Remake (some of the) method
Alphalaneous May 7, 2025
d54bd89
Show no logo sprite
Alphalaneous May 7, 2025
33189b4
Added scrolling by hovering at bounds
Alphalaneous May 7, 2025
54f0dd5
Small fix
Alphalaneous May 7, 2025
94a13af
Better logo handling
Alphalaneous May 7, 2025
e32a2da
Adjust scroll speed
Alphalaneous May 8, 2025
382d275
Add offset for hover scroll
Alphalaneous May 8, 2025
18c7c7a
Fix lazysprite initWithFile
matcool May 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ jobs:
os: ubuntu-latest
target: Android64

- name: iOS
os: macos-latest
target: iOS

name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}

Expand Down
2 changes: 1 addition & 1 deletion about.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A texture pack manager for Geode.

The UI for the mod can be accessed in the main menu. There you can open the packs folder by clicking on the folder icon.
The UI for the mod can be accessed in <cg>**Graphics Settings**</c> on desktop and regular <cg>**Settings**</c> on mobile. There you can open the packs folder by clicking on the **Textures** button.

You can **drag** on the small plus icon to move packs from available to applied, and back and forth.

Expand Down
3 changes: 3 additions & 0 deletions mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@
},
"api": {
"include": ["include/*.hpp"]
},
"dependencies": {
"geode.node-ids": "1.20.1"
}
}
Binary file modified resources/dragIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions src/BoundedScrollLayer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "BoundedScrollLayer.hpp"
#include <Geode/modify/CCMouseDispatcher.hpp>

#ifndef GEODE_IS_IOS
// a bit hacky but allows for multiple scroll layers at once
class $modify(CCMouseDispatcher) {
bool dispatchScrollMSG(float x, float y) {
for (CCMouseHandler* handler : CCArrayExt<CCMouseHandler*>(m_pMouseHandlers)) {
if (BoundedScrollLayer* scroll = typeinfo_cast<BoundedScrollLayer*>(handler->getDelegate())) {
scroll->m_doScroll = true;
scroll->scrollWheel(x, y);
scroll->m_doScroll = false;
}
}
return CCMouseDispatcher::dispatchScrollMSG(x, y);
}
};
#endif


BoundedScrollLayer* BoundedScrollLayer::create(CCSize const& size) {
auto ret = new BoundedScrollLayer({ 0, 0, size.width, size.height });
ret->autorelease();
return ret;
}

bool BoundedScrollLayer::testLocation(CCPoint point) {
CCPoint mousePoint = convertToNodeSpace({point.x + getPositionX(), point.y + getPositionY()});

if (boundingBox().containsPoint(mousePoint)) {
return true;
}

return false;
}

void BoundedScrollLayer::scrollWheel(float y, float x) {
if (!m_doScroll || !testLocation(getMousePos())) return;

ScrollLayer::scrollWheel(y, x);
}
21 changes: 21 additions & 0 deletions src/BoundedScrollLayer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once

#include <Geode/DefaultInclude.hpp>
#include <cocos2d.h>
#include <Geode/ui/ScrollLayer.hpp>

using namespace geode::prelude;

class BoundedScrollLayer : public ScrollLayer {
protected:
BoundedScrollLayer(CCRect const& rect) : ScrollLayer(rect, true, true) {}

public:
bool m_doScroll = false;
static BoundedScrollLayer* create(
cocos2d::CCSize const& size
);

bool testLocation(CCPoint point);
void scrollWheel(float y, float) override;
};
99 changes: 70 additions & 29 deletions src/PackNode.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
#include "PackNode.hpp"
#include <Geode/binding/CCMenuItemToggler.hpp>
#include <Geode/ui/LazySprite.hpp>
#include "PackManager.hpp"
#include "PackSelectLayer.hpp"
#include "PackSelectPopup.hpp"
#include "PackInfoPopup.hpp"
#include "DragThingy.hpp"

bool PackNode::init(
PackSelectLayer* layer,
PackSelectPopup* layer,
const std::shared_ptr<Pack>& pack,
float width
) {
if (!CCNode::init())
return false;

constexpr float HEIGHT = PackNode::HEIGHT;
constexpr float HEIGHT = PackNode::HEIGHT / .88f;
constexpr float SPACE_FOR_MENU = 50.f;
constexpr float MOVE_OFFSET = 20.f;
constexpr float SPACE_FOR_LOGO = HEIGHT;
Expand All @@ -32,24 +33,31 @@ bool PackNode::init(
auto menu = CCMenu::create();
menu->setPosition(menuPosX, HEIGHT / 2);
menu->setID("pack-button-menu");

auto logo = CCSprite::create((pack->getResourcesPath() / "pack.png").string().c_str());

if (!logo || logo->getUserObject("fallback"_spr)) {
logo = CCSprite::create("noLogo.png"_spr);
if (logo)
menu->setContentSize(this->getContentSize());
menu->setPosition({0, 0});

auto logoSize = CCSize { HEIGHT - PADDING * 2, HEIGHT - PADDING * 2 };
auto logo = LazySprite::create(logoSize, true);
logo->setLoadCallback([this, logo, logoSize](Result<> res) {
if (res.isErr()) {
logo->CCSprite::initWithFile("noLogo.png"_spr);
logo->setOpacity(100);
}
if (logo) {
logo->setPosition({ SPACE_FOR_LOGO / 2 + PADDING, HEIGHT / 2 });
limitNodeSize(logo, { HEIGHT - PADDING * 2, HEIGHT - PADDING * 2 }, 1.f, .1f);
this->addChild(logo);
}
}
limitNodeSize(logo, logoSize, 1.f, .1f);
});
logo->loadFromFile((pack->getResourcesPath() / "pack.png"));
logo->setPosition({ SPACE_FOR_LOGO / 2 + PADDING, HEIGHT / 2 });
this->addChild(logo);

logo->setID("pack-logo");

auto nameLabel = CCLabelBMFont::create(
m_pack->getDisplayName().c_str(), "bigFont.fnt"
);
nameLabel->limitLabelWidth(labelWidth, .65f, .1f);
nameLabel->limitLabelWidth(125.f, 0.40f, 0.1f);
nameLabel->setPositionX(0);
nameLabel->setAnchorPoint({0, 0.5f});
nameLabel->setID("pack-name-text");

auto nameButton = CCMenuItemSpriteExtra::create(
nameLabel, this, menu_selector(PackNode::onView)
Expand All @@ -58,7 +66,10 @@ bool PackNode::init(
PADDING + SPACE_FOR_LOGO + nameLabel->getScaledContentSize().width / 2 - menuPosX,
0
);

nameButton->setID("pack-name-button");
nameButton->setContentWidth(nameLabel->getScaledContentWidth());
nameButton->setEnabled(false);
menu->addChild(nameButton);

auto applyArrowSpr = CCSprite::create("dragIcon.png"_spr);
Expand All @@ -75,27 +86,57 @@ bool PackNode::init(
m_layer->stopDrag();
}
);

if (!m_pack->getInfo().has_value()) {
nameButton->setPosition({40 + nameButton->getContentWidth()/2, this->getContentHeight()/2});
}
else {
PackInfo packInfo = m_pack->getInfo().value();
CCLabelBMFont* extraInfoLabel = CCLabelBMFont::create(fmt::format("{} | {}", packInfo.m_version.toNonVString(), packInfo.m_id).c_str(), "bigFont.fnt");
extraInfoLabel->setColor({165, 165, 165});
extraInfoLabel->limitLabelWidth(125.f, 0.2f, 0.1f);
extraInfoLabel->setScale(0.2f);
extraInfoLabel->setAnchorPoint({0, 0.5f});
extraInfoLabel->setOpacity(165);
extraInfoLabel->setPosition({40, 8});
extraInfoLabel->setZOrder(-1);
extraInfoLabel->setID("extra-info-text");

this->addChild(extraInfoLabel);

CCLabelBMFont* authorLabel = CCLabelBMFont::create(packInfo.m_authors.at(0).c_str(), "goldFont.fnt");
authorLabel->limitLabelWidth(125.f, 0.3f, 0.1f);
authorLabel->setAnchorPoint({0, 0.5f});
authorLabel->setPosition({40.2, 16});
authorLabel->setZOrder(-1);
authorLabel->setScale(0.3f);
authorLabel->setID("author-text");
this->addChild(authorLabel);

nameButton->setPosition({40 + nameButton->getContentWidth()/2, this->getContentHeight() - 9.5f});
}

applyArrowSpr->setAnchorPoint(ccp(0, 0));
dragHandle->addChild(applyArrowSpr);
dragHandle->setContentSize(applyArrowSpr->getScaledContentSize());
dragHandle->setID("apply-pack-button");
dragHandle->setPosition(width - MOVE_OFFSET, HEIGHT / 2.f);
dragHandle->setTouchPriority(-130);

this->addChild(dragHandle);

auto dragBg = CCScale9Sprite::create(
"square02b_001.png", { 0, 0, 80, 80 }
m_draggingBg = CCScale9Sprite::create(
"square02b_001.png"
);
dragBg->setColor({ 0, 0, 0 });
dragBg->setOpacity(90);
const float bgScaling = 0.5f;
dragBg->setContentSize(this->getContentSize() / bgScaling);
dragBg->setScale(bgScaling);
dragBg->setPosition({ width / 2.f, HEIGHT / 2.f });
dragBg->setZOrder(-10);
this->addChild(dragBg);
m_draggingBg = dragBg;
dragBg->setVisible(false);
m_draggingBg->setCapInsets({10, 10, 50, 50});
m_draggingBg->setColor({ 0, 0, 0 });
m_draggingBg->setOpacity(90);
m_draggingBg->setContentSize(this->getContentSize());
m_draggingBg->setPosition({ width / 2.f, HEIGHT / 2.f });
m_draggingBg->setZOrder(-10);
m_draggingBg->setVisible(false);

this->addChild(m_draggingBg);

this->addChild(menu);

Expand All @@ -107,7 +148,7 @@ void PackNode::onView(CCObject*) {
}

PackNode* PackNode::create(
PackSelectLayer* layer,
PackSelectPopup* layer,
const std::shared_ptr<Pack>& pack,
float width
) {
Expand Down
12 changes: 6 additions & 6 deletions src/PackNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

using namespace geode::prelude;

class PackSelectLayer;
class PackSelectPopup;

class PackNode : public CCNode {
protected:
PackSelectLayer* m_layer;
PackSelectPopup* m_layer;
std::shared_ptr<Pack> m_pack;
CCNode* m_draggingBg;
CCScale9Sprite* m_draggingBg;

bool init(
PackSelectLayer* layer,
PackSelectPopup* layer,
const std::shared_ptr<Pack>& pack,
float width
);
Expand All @@ -24,12 +24,12 @@ class PackNode : public CCNode {

public:
static PackNode* create(
PackSelectLayer* layer,
PackSelectPopup* layer,
const std::shared_ptr<Pack>& pack,
float width
);

std::shared_ptr<Pack> getPack() { return m_pack; }

static constexpr float HEIGHT = 35.f;
static constexpr float HEIGHT = 35.f * .88f;
};
Loading