Skip to content

Commit

Permalink
beta 1
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSillyDoggo committed Feb 25, 2024
1 parent f445df4 commit 7efc007
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 22 deletions.
Binary file added emojis/other/GJ_dislikesIcon_001.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/car.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/fireinthehole.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/whadahell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"geode": "2.0.0",
"version": "v0.0.1",
"version": "v1.0.0-beta.1",
"gd": {
"win": "2.204",
"mac": "2.200",
Expand Down
103 changes: 89 additions & 14 deletions src/CCLabelBMFontExt.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ std::vector<std::pair<std::string, std::string>> emojis = {
std::pair("diamonds", "currencyDiamondIcon_001.png"),

std::pair("like", "GJ_likesIcon_001.png"),
std::pair("dislike", "GJ_dislikesIcon_001.png"),
std::pair("dislike", "GJ_dislikesIcon_001.png"_spr), // rob i genuinely hate you for making it this differetn size it is size size different

std::pair("check", "GJ_completesIcon_001.png"),
std::pair("cross", "GJ_deleteIcon_001.png"),
Expand All @@ -55,7 +55,26 @@ std::vector<std::pair<std::string, std::string>> emojis = {
std::pair("leaderboardmod", "modBadge_03_001.png"),

//other
_Emoji("amogus"),
_Emoji("bruh"),
_Emoji("carlos"),
_Emoji("clueless"),
_Emoji("despair"),
_Emoji("despair2"),
_Emoji("ned"),
std::pair("pusab?", "pusab.png"_spr),
_Emoji("robsmile"),
_Emoji("sip"),
_Emoji("splat"),
_Emoji("teehee"),
_Emoji("trollface"),
_Emoji("true"),
_Emoji("walter"),
_Emoji("wha"),
_Emoji("whadahell"),
_Emoji("youshould"),
_Emoji("car"),
_Emoji("fireinthehole"),

//discord
_Emoji("shushing_face"),
Expand All @@ -80,6 +99,8 @@ std::vector<std::pair<std::string, std::string>> emojis = {
_Emoji("speaking_head"),
};

#include "EmojiInfoLayer.h"

enum LabelPartType
{
Text,
Expand Down Expand Up @@ -110,9 +131,14 @@ struct LabelPart

return "";
}

bool isValid()
{
return (CCSpriteFrameCache::get()->spriteFrameByName(fileNameForEmoji().c_str()));
}
};

class CCLabelBMFontExt : public CCNode
class CCLabelBMFontExt : public CCMenu
{
public:
std::vector<LabelPart> parts;
Expand All @@ -122,6 +148,13 @@ class CCLabelBMFontExt : public CCNode

float maxX;

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

EmojiInfoLayer::addToScene(str);
}

virtual void updateLabel() // copying types from normal label
{
parts.clear();
Expand All @@ -133,18 +166,38 @@ class CCLabelBMFontExt : public CCNode
{
if (text[i] == ' ')
{
s = s + " ";

parts.push_back(LabelPart(LabelPartType::Text, s));

inEmoji = false;

s = " ";
s = "";

continue;
}

if (text[i] == ':')
{
parts.push_back(LabelPart(inEmoji ? LabelPartType::Emoji : LabelPartType::Text, s));
if (inEmoji)
{
auto part = LabelPart(LabelPartType::Emoji, s);

if (!part.isValid())
{
part.type = LabelPartType::Text;
s = ":" + s + ":";
part.extra = s;
}
else
{

}

parts.push_back(part);
}
else
parts.push_back(LabelPart(inEmoji ? LabelPartType::Emoji : LabelPartType::Text, s));

inEmoji = !inEmoji;

Expand All @@ -156,8 +209,13 @@ class CCLabelBMFontExt : public CCNode
s = s + text[i];
}

//if (s != "")
//parts.push_back(LabelPart(LabelPartType::Text, s));
if (s != "")
{
if (inEmoji)
s = ":" + s;

parts.push_back(LabelPart(LabelPartType::Text, s));
}

float pos = 0;
float wid = 0;
Expand Down Expand Up @@ -193,6 +251,7 @@ class CCLabelBMFontExt : public CCNode
yPos++;

lbl->setPosition(ccp(pos, -20 * yPos));
pos += lbl->getScaledContentSize().width + 2 - 0.75f;
}
}
}
Expand All @@ -203,14 +262,16 @@ class CCLabelBMFontExt : public CCNode
if (!emoji)
continue;

emoji->setAnchorPoint(ccp(0, 0));
emoji->setPosition(ccp(pos + 2, -20 * yPos));
this->addChild(emoji);

emoji->setScale(commentHeight / emoji->getContentHeight());

auto emojiBtn = CCMenuItemSpriteExtra::create(emoji, this, menu_selector(CCLabelBMFontExt::onEmoji));
emojiBtn->setID(seg.extra);

emojiBtn->setPosition(ccp(pos + 2, -20 * yPos) + (emojiBtn->getScaledContentSize() / 2));
this->addChild(emojiBtn);

height = std::max<float>(height, emoji->getScaledContentSize().height);
pos += emoji->getScaledContentSize().width + 2 - 0.75f;
pos += emojiBtn->getScaledContentSize().width + 2 - 0.75f;
wid = std::max<float>(wid, pos);

if (maxX != 0)
Expand All @@ -221,13 +282,14 @@ class CCLabelBMFontExt : public CCNode
pos = 0;
yPos++;

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

this->setContentSize(ccp(wid, height));
this->setContentSize(ccp(wid, /*height*/20 * (yPos + 1)));
}

virtual void setFont(const char *newString, bool update = true)
Expand Down Expand Up @@ -259,18 +321,31 @@ class CCLabelBMFontExt : public CCNode
this->setScale(clampf(width / this->getContentSize().width, minScale, defaultScale));
}

void limitLabelHeight(float height, float defaultScale, float minScale, bool alignScale = true)
{
this->setScale(clampf(height / this->getContentSize().height, minScale, defaultScale));

if (alignScale)
setMaxX(this->maxX / this->getScale());

log::info("f: {}", height / this->getContentSize().height);
}

bool init(const char* text, const char* font)
{
if (!CCNode::init())
if (!CCMenu::init())
return false;

this->setAnchorPoint(ccp(0.5f, 0.5f));
this->ignoreAnchorPointForPosition(false);

this->setFont(font, false);
this->setString(text, false);

this->updateLabel();

handleTouchPriority(this);

return true;
}

Expand Down
91 changes: 91 additions & 0 deletions src/EmojiInfoLayer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#pragma once

#include <Geode/Geode.hpp>
#include <Geode/utils/web.hpp>
#include <Geode/ui/TextInput.hpp>

using namespace geode::prelude;

#include "CCLabelBMFontExt.h"

class EmojiInfoLayer : public CCLayerColor
{
public:

virtual void keyBackClicked()
{
onClose(nullptr);
}

void onClose(CCObject*)
{
CCTouchDispatcher::get()->removeDelegate(this);

this->removeFromParent();
}

bool init(std::string emoji)
{
if (!CCLayerColor::init())
return false;

this->setKeypadEnabled(true);

auto panel = CCScale9Sprite::create("GJ_square01.png");
panel->setContentSize(ccp(240, 250));
this->addChildAtPosition(panel, Anchor::Center);

auto title = CCLabelBMFont::create((std::string(":") + emoji + std::string(":")).c_str(), "bigFont.fnt");
title->setScale(0.65f);
this->addChildAtPosition(title, Anchor::Center, ccp(0, 70 + 38));

std::string ss;

for (size_t i = 0; i < emojis.size(); i++)
{
if (emojis[i].first == emoji)
{
ss = emojis[i].second;
break;
}
}

auto spr = CCSprite::createWithSpriteFrameName(ss.c_str());
spr->setScale(2);
this->addChildAtPosition(spr, Anchor::Center);

auto menu = CCMenu::create();

auto ok = CCMenuItemSpriteExtra::create(ButtonSprite::create("OK"), this, menu_selector(EmojiInfoLayer::onClose));
menu->addChildAtPosition(ok, Anchor::Center, ccp(0, -63 - 39));

this->addChild(menu);

this->runAction(CCFadeTo::create(0.5f, 125));
this->ignoreAnchorPointForPosition(true);

CCTouchDispatcher::get()->addTargetedDelegate(this, -169, true);
CCTouchDispatcher::get()->addTargetedDelegate(menu, -170, true);

return true;
}

static EmojiInfoLayer* create(std::string emoji)
{
EmojiInfoLayer* pRet = new EmojiInfoLayer();
if (pRet && pRet->init(emoji)) {
pRet->autorelease();
return pRet;
} else {
delete pRet;
return nullptr;
}
}

static void addToScene(std::string emoji)
{
auto pRet = EmojiInfoLayer::create(emoji);

CCScene::get()->addChild(pRet, CCScene::get()->getHighestChildZ() + 1);
}
};
26 changes: 19 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ class $modify (CommentCell)
if (lbl2)
{
lbl2->setPosition(txt->getPosition());
lbl2->setAnchorPoint(txt->getAnchorPoint());
lbl2->setMaxX(310);
lbl2->setAnchorPoint(ccp(0, 0));
lbl2->setMaxX(310, true);
lbl2->limitLabelHeight(50, 1.0f, 0.1f);

as<CCLayerColor*>(this->getChildren()->objectAtIndex(1))->addChild(lbl2);
}
Expand Down Expand Up @@ -127,12 +128,20 @@ class $modify (ShareCommentLayerExt, ShareCommentLayer)
bg->setPosition(ccp(0, 0));
menu->addChild(bg);

auto scroll = ScrollLayer::create(menu->getContentSize() + ccp(-20, -20));
scroll->setPosition(ccp(10, 10));
menu->addChild(scroll);

int x = 0;
int y = 0;

int rowCount = 7;
int rowCount = 8;

float size = (scroll->getContentWidth() - 10 - 10) / (rowCount - 1);

float size = (menu->getContentWidth() - 20 - 20) / (rowCount - 1);
auto m = CCMenu::create();
m->setPosition(ccp(0, 0));
m->setContentHeight(9999);

for (size_t i = 0; i < emojis.size(); i++)
{
Expand All @@ -145,8 +154,9 @@ class $modify (ShareCommentLayerExt, ShareCommentLayer)
auto btn = CCMenuItemSpriteExtra::create(spr, this, menu_selector(ShareCommentLayerExt::onSelectEmoji));
btn->setID(emojis[i].first);

btn->setPosition(ccp( (size * x) + 20, (size * y) + 20));
menu->addChild(btn);
btn->setPosition(ccp( (size * x) + 10, (size * y) + 10));
//menu->addChild(btn);
m->addChild(btn);

x++;

Expand All @@ -157,7 +167,9 @@ class $modify (ShareCommentLayerExt, ShareCommentLayer)
}
}
}


scroll->m_contentLayer->addChild(m);
scroll->m_contentLayer->setContentHeight(size * y + (10 + 10));

this->addChild(menu);

Expand Down

0 comments on commit 7efc007

Please sign in to comment.