Skip to content

Commit

Permalink
cccczxcz
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSillyDoggo committed Dec 19, 2024
1 parent 144e11f commit 0a64da1
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"geode": "4.1.0",
"version": "v1.7.6",
"version": "v1.7.7",
"gd": {
"win": "2.2074",
"android": "2.2074",
Expand Down
31 changes: 26 additions & 5 deletions src/Client/Windows/Labels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,30 @@ void Labels::refreshList()
bg->setContentSize(bg->getContentSize() * 2.5f);
bg->setPositionX(4);

auto name = CCLabelBMFont::create(module->name.c_str(), "bigFont.fnt");
name->setAnchorPoint(ccp(0, 0.5f));
name->setPosition(ccp(10, cell->getContentHeight() / 2));
name->limitLabelWidth(95, 0.4f, 0);
auto nameBack = CCScale9Sprite::create("square02_small.png");
nameBack->setOpacity(100);
nameBack->setContentSize(ccp(120, 18) * 3);
nameBack->setAnchorPoint(ccp(0, 0.5f));
nameBack->setScale(1.0f / 3.0f);
nameBack->setPositionX(6.5f);
nameBack->setPositionY(cell->getContentHeight() / 2);

auto nameInp = TextInput::create(160, "Display Name", "bigFont.fnt");
nameInp->setAnchorPoint(ccp(0, 0.5f));
nameInp->setPosition(ccp(10, cell->getContentHeight() / 2));
nameInp->setScale(0.7f);

nameInp->getBGSprite()->setVisible(false);
nameInp->getInputNode()->m_placeholderLabel->setAnchorPoint(ccp(0, 0.5f));
nameInp->getInputNode()->m_placeholderLabel->setPositionX(-nameInp->getContentWidth() / 2);

nameInp->setString(lbl->name);
nameInp->setCallback([this, lbl](const std::string& str)
{
lbl->name = str;

save();
});

auto m = CCMenu::create();
m->setPosition(ccp(0, 0));
Expand Down Expand Up @@ -397,7 +417,8 @@ void Labels::refreshList()
m->addChild(toggleBtn);

cell->addChild(bg);
cell->addChild(name);
cell->addChild(nameBack);
cell->addChild(nameInp);
cell->addChild(m);

scroll->m_contentLayer->addChild(cell);
Expand Down
2 changes: 1 addition & 1 deletion src/UI/TransAlertLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ bool TransAlertLayer::init(char const* title, const gd::string& desc, char const

bool useTtf = false;

useTtf = !std::regex_match(desc2, std::regex("^[a-zA-Z0-9\\s%:-]*$"));
useTtf = !std::regex_match(desc2, std::regex(ENGLISH_REGEX));

if (useTtf)
{
Expand Down
2 changes: 1 addition & 1 deletion src/UI/TransLabelBMFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void TransLabelBMFont::updateTTFVisible()
}
else
{
useTtf = !std::regex_match(text, std::regex("^[a-zA-Z0-9\\s%:-]*$"));
useTtf = !std::regex_match(text, std::regex(ENGLISH_REGEX));
}

label->setString(text.c_str());
Expand Down
5 changes: 4 additions & 1 deletion src/UI/TransLabelBMFont.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

using namespace geode::prelude;

#define ENGLISH_REGEX "^[a-zA-Z0-9\\s%:-]*$"

// they call this my gender
class TransLabelBMFont : public CCNode
{
Expand All @@ -28,9 +30,10 @@ class TransLabelBMFont : public CCNode
CCLabelTTF* createTTF(std::string font, float fontSize);
void updateTTFVisible();

~TransLabelBMFont();

public:
bool init(std::string text, std::string font);
~TransLabelBMFont();

void limitLabelWidth(float width, float defaultScale, float minScale);

Expand Down

0 comments on commit 0a64da1

Please sign in to comment.