Skip to content

Commit

Permalink
fgsd
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSillyDoggo committed Feb 28, 2024
1 parent 135de4a commit 53d1323
Show file tree
Hide file tree
Showing 11 changed files with 254 additions and 5 deletions.
Binary file added emojis/discord/clown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added emojis/discord/divine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added emojis/discord/eggplant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added emojis/discord/gd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added emojis/discord/rattledash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added emojis/discord/sob.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added emojis/other/mayo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added emojis/other/mrmkr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added emojis/other/soggy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
240 changes: 236 additions & 4 deletions src/CCLabelBMFontExt.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include <Geode/modify/CCNode.hpp>
#include <Geode/modify/CCLabelBMFont.hpp>

#include <iostream>
#include <regex>
#include <string>

using namespace geode::prelude;

std::pair<std::string, std::string> _Emoji(std::string name)
Expand Down Expand Up @@ -82,6 +86,11 @@ std::vector<std::pair<std::string, std::string>> emojis = {
_Emoji("dabmeup"),
_Emoji("fireinthehole"),
_Emoji("xcreatorgoal"),
_Emoji("soggy"),
_Emoji("mayo"),
_Emoji("divine"),
_Emoji("rattledash"),
_Emoji("gd"),

//discord
_Emoji("100"),
Expand All @@ -105,14 +114,20 @@ std::vector<std::pair<std::string, std::string>> emojis = {
_Emoji("skull"),
_Emoji("smiling_imp"),
_Emoji("speaking_head"),
_Emoji("sob"),
_Emoji("eggplant"),
_Emoji("clown"),
};

#include "EmojiInfoLayer.h"

enum LabelPartType
{
Text,
Emoji
Emoji,
Username,
Url,
Level
};

struct LabelPart
Expand Down Expand Up @@ -156,6 +171,19 @@ class CCLabelBMFontExt : public CCMenu

float maxX;

bool isUrl(std::string str) {
std::regex pattern("^(https?://)?[\\w\\-]+(\\.[\\w\\-]+)+[/\\w\\-\\.,@?^=%&:/~\\+#]*");

return std::regex_match(str, pattern);
}

bool isLevel(std::string str)
{
std::regex pattern("^[0-9]+$");

return std::regex_match(str, pattern);
}

void onEmoji(CCObject* sender)
{
#ifndef GEODE_IS_MACOS
Expand All @@ -165,6 +193,58 @@ class CCLabelBMFontExt : public CCMenu
#endif
}

void onUsername(CCObject* sender)
{
auto str = as<CCNode*>(sender)->getID();

log::info("username: {}", str);

auto search = GJSearchObject::create(SearchType::Users, str.c_str());
auto browser = LevelBrowserLayer::create(search);

auto scene = CCScene::create();
scene->addChild(browser);

CCDirector::get()->pushScene(CCTransitionFade::create(0.5f, scene));

//usernameForUserID()
}

void onLevel(CCObject* sender)
{
auto str = as<CCNode*>(sender)->getID();

log::info("level: {}", str);

auto search = GJSearchObject::create(SearchType::Search, str.c_str());
auto browser = LevelBrowserLayer::create(search);

auto scene = CCScene::create();
scene->addChild(browser);

CCDirector::get()->pushScene(CCTransitionFade::create(0.5f, scene));

//usernameForUserID()
}

void onUrl(CCObject* sender)
{
auto str = as<CCNode*>(sender)->getID();

log::info("url: {}", str);

geode::createQuickPopup(
"Hold Up!",
"Links are spooky! Are you sure you want to go to\n<cy>" + str + "</c>?",
"Cancel", "Yes",
[str](FLAlertLayer*, bool btn2) {
if (btn2) {
geode::utils::web::openLinkInBrowser(str);
}
}
);
}

virtual void updateLabel() // copying types from normal label
{
parts.clear();
Expand All @@ -178,7 +258,7 @@ class CCLabelBMFontExt : public CCMenu
{
s = s + " ";

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

inEmoji = false;

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

inEmoji = !inEmoji;

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

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

float pos = 0;
Expand Down Expand Up @@ -301,6 +381,158 @@ class CCLabelBMFontExt : public CCMenu
}
}
}
else if (seg.type == LabelPartType::Username)
{
auto n = CCNode::create();

auto lbl = CCLabelBMFont::create(seg.extra.c_str(), font.c_str(), 99999);
lbl->setColor(ccc3(127, 244, 244));
lbl->setAnchorPoint(ccp(0, 0));

n->addChild(lbl);
n->setContentSize(lbl->getContentSize());

auto n2 = CCNode::create();

auto lbl2 = CCLabelBMFont::create(seg.extra.c_str(), font.c_str(), 99999);
lbl2->setOpacity(150);
lbl2->setAnchorPoint(ccp(0, 0));

n2->addChild(lbl2);
n2->setContentSize(lbl2->getContentSize());

auto btn = CCMenuItemSprite::create(n, n2, this, menu_selector(CCLabelBMFontExt::onUsername));
btn->setID(seg.extra.substr(1));
btn->setPosition(ccp(pos, -20 * yPos));
btn->setAnchorPoint(ccp(0, 0));

this->addChild(btn);

height = std::max<float>(height, lbl->getScaledContentSize().height);
pos += lbl->getScaledContentSize().width;
wid = std::max<float>(wid, pos);

if (maxX != 0)
{
if (pos > maxX)
{
wid = std::max<float>(wid, pos);
pos = 0;
yPos++;

lbl->setPosition(ccp(pos, -20 * yPos));
pos += lbl->getScaledContentSize().width + 2 - 0.75f;
}
}
}
else if (seg.type == LabelPartType::Url)
{
auto n = CCNode::create();

auto lbl = CCLabelBMFont::create(seg.extra.c_str(), font.c_str(), 99999);
lbl->setColor(ccc3(127, 244, 244));
lbl->setAnchorPoint(ccp(0, 0));

auto line = CCLayerColor::create();
line->setColor(lbl->getColor());
line->setOpacity(255);
line->ignoreAnchorPointForPosition(false);
line->setAnchorPoint(ccp(0, 0));
line->setPosition(ccp(0, -1));
line->setContentWidth(lbl->getContentWidth());
line->setContentHeight(1);

n->addChild(line);
n->addChild(lbl);
n->setContentSize(lbl->getContentSize());

auto n2 = CCNode::create();

auto lbl2 = CCLabelBMFont::create(seg.extra.c_str(), font.c_str(), 99999);
lbl2->setOpacity(150);
lbl2->setAnchorPoint(ccp(0, 0));

auto line2 = CCLayerColor::create();
line2->setColor(lbl2->getColor());
line2->setOpacity(150);
line2->ignoreAnchorPointForPosition(false);
line2->setAnchorPoint(ccp(0, 0));
line2->setPosition(ccp(0, -1));
line2->setContentWidth(lbl->getContentWidth());
line2->setContentHeight(1);

n2->addChild(line2);
n2->addChild(lbl2);
n2->setContentSize(lbl2->getContentSize());

auto btn = CCMenuItemSprite::create(n, n2, this, menu_selector(CCLabelBMFontExt::onUrl));
btn->setID(seg.extra);
btn->setPosition(ccp(pos, -20 * yPos));
btn->setAnchorPoint(ccp(0, 0));

this->addChild(btn);

height = std::max<float>(height, lbl->getScaledContentSize().height);
pos += lbl->getScaledContentSize().width;
wid = std::max<float>(wid, pos);

if (maxX != 0)
{
if (pos > maxX)
{
wid = std::max<float>(wid, pos);
pos = 0;
yPos++;

lbl->setPosition(ccp(pos, -20 * yPos));
pos += lbl->getScaledContentSize().width + 2 - 0.75f;
}
}
}
else if (seg.type == LabelPartType::Level)
{
auto n = CCNode::create();

auto lbl = CCLabelBMFont::create(seg.extra.c_str(), font.c_str(), 99999);
lbl->setColor(ccc3(127, 244, 244));
lbl->setAnchorPoint(ccp(0, 0));

n->addChild(lbl);
n->setContentSize(lbl->getContentSize());

auto n2 = CCNode::create();

auto lbl2 = CCLabelBMFont::create(seg.extra.c_str(), font.c_str(), 99999);
lbl2->setOpacity(150);
lbl2->setAnchorPoint(ccp(0, 0));

n2->addChild(lbl2);
n2->setContentSize(lbl2->getContentSize());

auto btn = CCMenuItemSprite::create(n, n2, this, menu_selector(CCLabelBMFontExt::onLevel));
btn->setID(seg.extra);
btn->setPosition(ccp(pos, -20 * yPos));
btn->setAnchorPoint(ccp(0, 0));

this->addChild(btn);

height = std::max<float>(height, lbl->getScaledContentSize().height);
pos += lbl->getScaledContentSize().width;
wid = std::max<float>(wid, pos);

if (maxX != 0)
{
if (pos > maxX)
{
wid = std::max<float>(wid, pos);
pos = 0;
yPos++;

lbl->setPosition(ccp(pos, -20 * yPos));
pos += lbl->getScaledContentSize().width + 2 - 0.75f;
}
}
}
}

CCArrayExt<CCNode*> objects = this->getChildren();
Expand Down
19 changes: 18 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,28 @@ using namespace geode::prelude;

class $modify (CommentCell)
{
CCLabelBMFontExt* label = nullptr;

void onUnhide(cocos2d::CCObject* sender)
{

}

void loadFromComment(GJComment* p0)
{
CommentCell::loadFromComment(p0);

if (auto txt = as<CCLayerColor*>(this->getChildren()->objectAtIndex(1))->getChildByID("comment-text-label"))
{
txt->setVisible(false);

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

if (p0->m_isSpam)
lbl2->setString("Comment flagged as spam");

m_fields->label = lbl2;

if (lbl2)
{
lbl2->setPosition(txt->getPosition());
Expand All @@ -39,6 +51,11 @@ class $modify (CommentCell)

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

if (p0->m_isSpam)
lbl2->setString("Comment flagged as spam");

m_fields->label = lbl2;

if (lbl2)
{
if (this->m_accountComment)
Expand Down

0 comments on commit 53d1323

Please sign in to comment.