Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSillyDoggo committed Apr 1, 2024
1 parent 9692f73 commit 1668261
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 88 deletions.
4 changes: 2 additions & 2 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"geode": "2.0.0",
"version": "v1.0.0-beta.6",
"geode": "2.0.0-beta.23",
"version": "v1.0.0-beta.7",
"gd": {
"win": "2.204",
"mac": "2.200",
Expand Down
25 changes: 22 additions & 3 deletions src/CCLabelBMFontExt.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,34 @@ struct LabelPart
}
};

std::string trimEndSpaces(const std::string& str) {
size_t endpos = str.find_last_not_of(" \t");
return (endpos != std::string::npos) ? str.substr(0, endpos + 1) : "";
}

class CCLabelBMFontExt : public CCMenu
{
public:
std::vector<LabelPart> parts;

std::string font = "";
std::string text = "";
ccColor3B colour = ccc3(255, 255, 255);

float maxX;

virtual void setColor(const ccColor3B& color)
{
colour = color;

updateLabel();
}

virtual const ccColor3B& getColor(void)
{
return colour;
}

bool isUrl(std::string str) {
std::regex pattern("^(https?:\\/\\/)?((?:[^\\/:@\\s]+\\.)+)((?:[a-z]{2,})|(?:xn--[a-z0-9\\-]{2,}))(?:\\/\\S*)?$");

Expand Down Expand Up @@ -260,7 +278,7 @@ class CCLabelBMFontExt : public CCMenu
{
s = s + " ";

parts.push_back(LabelPart(isLevel(s) ? LabelPartType::Level : (isUrl(s) ? LabelPartType::Url : (s.starts_with("@") ? LabelPartType::Username : LabelPartType::Text)), s));
parts.push_back(LabelPart(isLevel(trimEndSpaces(s)) ? LabelPartType::Level : (isUrl(trimEndSpaces(s)) ? LabelPartType::Url : (s.starts_with("@") ? LabelPartType::Username : LabelPartType::Text)), s));

inEmoji = false;

Expand Down Expand Up @@ -289,7 +307,7 @@ class CCLabelBMFontExt : public CCMenu
parts.push_back(part);
}
else
parts.push_back(LabelPart(inEmoji ? LabelPartType::Emoji : (isLevel(s) ? LabelPartType::Level : (isUrl(s) ? LabelPartType::Url : (s.starts_with("@") ? LabelPartType::Username : LabelPartType::Text))), s));
parts.push_back(LabelPart(inEmoji ? LabelPartType::Emoji : (isLevel(trimEndSpaces(s)) ? LabelPartType::Level : (isUrl(trimEndSpaces(s)) ? LabelPartType::Url : (s.starts_with("@") ? LabelPartType::Username : LabelPartType::Text))), s));

inEmoji = !inEmoji;

Expand All @@ -306,7 +324,7 @@ class CCLabelBMFontExt : public CCMenu
if (inEmoji)
s = ":" + s;

parts.push_back(LabelPart(isLevel(s) ? LabelPartType::Level : (isUrl(s) ? LabelPartType::Url : (s.starts_with("@") ? LabelPartType::Username : LabelPartType::Text)), s));
parts.push_back(LabelPart(isLevel(trimEndSpaces(s)) ? LabelPartType::Level : (isUrl(trimEndSpaces(s)) ? LabelPartType::Url : (s.starts_with("@") ? LabelPartType::Username : LabelPartType::Text)), s));
}

float pos = 0;
Expand All @@ -328,6 +346,7 @@ class CCLabelBMFontExt : public CCMenu
auto lbl = CCLabelBMFont::create(seg.extra.c_str(), font.c_str(), 99999);
lbl->setAnchorPoint(ccp(0, 0));
lbl->setPosition(ccp(pos, -20 * yPos));
lbl->setColor(colour);
this->addChild(lbl);

height = std::max<float>(height, lbl->getScaledContentSize().height);
Expand Down
94 changes: 11 additions & 83 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <Geode/modify/TextArea.hpp>
#include <Geode/modify/CommentCell.hpp>
#include <Geode/modify/ShareCommentLayer.hpp>
#include <Geode/modify/GJMessagePopup.hpp>
#include <Geode/modify/MenuLayer.hpp>

using namespace geode::prelude;
Expand Down Expand Up @@ -42,6 +43,7 @@ class $modify (CommentCell)
lbl2->setPosition(txt->getPosition());
lbl2->setAnchorPoint(txt->getAnchorPoint());
lbl2->limitLabelWidth(270, 0.7f, 0);
lbl2->setColor(p0->m_color);

as<CCLayerColor*>(this->getChildren()->objectAtIndex(1))->addChild(lbl2);
}
Expand All @@ -54,6 +56,7 @@ class $modify (CommentCell)
txt->setVisible(false);

auto lbl2 = CCLabelBMFontExt::create(p0->m_commentString.c_str(), "chatFont.fnt");
lbl2->setColor(p0->m_color);

if (p0->m_isSpam)
lbl2->setString("Comment flagged as spam");
Expand Down Expand Up @@ -224,13 +227,16 @@ class $modify (ShareCommentLayerExt, ShareCommentLayer)
return true;
}
};

/*class $modify (TextArea)
/*
class $modify (TextArea)
{
void setString(gd::string p0)
{
TextArea::setString(p0);
if (!getChildOfType<GJMessagePopup>(CCScene::get(), 0))
return;
if (auto ml = as<MultilineBitmapFont*>(this->getChildren()->objectAtIndex(0)))
{
CCArrayExt<CCLabelBMFont*> objects = ml->getChildren();
Expand All @@ -245,89 +251,11 @@ class $modify (ShareCommentLayerExt, ShareCommentLayer)
lbl2->setAnchorPoint(obj->getAnchorPoint());
lbl2->setScale(obj->getScale());
ml->addChild(lbl2);
}
}
}
}
};*/

/*
CCSprite* img = nullptr;
class $modify(CCLabelBMFont) {
virtual void draw()
{
CCNode::draw();
//if (typeinfo_cast<CCLabelBMFont*>(this))
if (true)
{
log::info("draw");
lbl2->setTouchPriority(-508);
if (img)
img->draw();
}
}
virtual void updateLabel()
{
CCLabelBMFont::updateLabel();
bool inEmoji = false;
std::stringstream ss;
int emojiPos;
for (size_t i = 0; i < this->getChildrenCount(); i++)
{
auto child = reinterpret_cast<CCSprite*>(this->getChildren()->objectAtIndex(i));
auto chara = this->getString()[i];
if (chara == " "[0])
inEmoji = false;
if (chara == ":"[0])
{
if (inEmoji)
{
auto emojiName = ss.str();
auto old = reinterpret_cast<CCSprite*>(this->getChildren()->objectAtIndex(emojiPos));
//auto img = CCSprite::createWithSpriteFrameName("diamond_small01_001.png");
img = CCSprite::createWithSpriteFrameName("GJ_noteIcon_001.png");
img->setPosition(old->getPosition());
img->setTag(i);
//CCDirector::get()->setNotificationNode(img);
//img->addChild(CCSprite::createWithSpriteFrameName("label_power_001.png")); // wtf why isn't this working
//auto img = CCSprite::create("dialogIcon_013.png");
//img->setPosition(pos);
//this->getParent()->addChild(img);
//old->addChild(img);
//auto layer = CCLayer::create();
//layer->addChild(img);
//CCScene::get()->addChild(layer);
//old->setOpacity(0);
}
else
{
emojiPos = i;
ss.clear();
}
inEmoji = !inEmoji;
}
else
{
if (inEmoji)
{
ss << chara;
ml->addChild(lbl2);
}
}
}
}
};
*/
};*/

0 comments on commit 1668261

Please sign in to comment.