Skip to content

Commit

Permalink
beta 1
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSillyDoggo committed Feb 23, 2024
1 parent 2451aee commit 633c547
Show file tree
Hide file tree
Showing 4 changed files with 464 additions and 6 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build Geode Mod

on:
workflow_dispatch:
push:
branches:
- '**'

jobs:
build:
strategy:
fail-fast: false
matrix:
config:
- name: Windows
os: windows-latest
target: Win32
- name: Android32
os: ubuntu-latest
target: Android32
- name: Android64
os: ubuntu-latest
target: Android64
#- name: macOS
# os: macos-latest


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

steps:
- uses: actions/checkout@v3

- name: Build the mod
uses: geode-sdk/build-geode-mod@main
with:
bindings: 'TheSillyDoggo/bindings'
combine: true
sdk: nightly
target: ${{ matrix.config.target }}

package:
name: Package builds
runs-on: ubuntu-latest
needs: ['build']

steps:
- uses: geode-sdk/build-geode-mod@combine
id: build

- uses: actions/upload-artifact@v3
with:
name: Build Output
path: ${{ steps.build.outputs.build-output }}
16 changes: 14 additions & 2 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
{
"geode": "2.0.0-beta.9",
"version": "v1.0.0",
"geode": "2.0.0",
"version": "v0.0.1",
"gd": {
"win": "2.204",
"mac": "2.200",
"android": "*"
},
"id": "thesillydoggo.comment_emojis",
"name": "Comment Emojis",
"dependencies": [
{
"id": "geode.node-ids",
"version": "v1.6.1",
"importance": "required"
}
],
"developer": "TheSillyDoggo",
"description": "geometry dash sex real ?! (not faek)"
}
241 changes: 241 additions & 0 deletions src/CCLabelBMFontExt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
#pragma once

#include <Geode/Geode.hpp>
#include <Geode/modify/CCNode.hpp>
#include <Geode/modify/CCLabelBMFont.hpp>

using namespace geode::prelude;

std::vector<std::pair<std::string, std::string>> emojis = {
std::pair("auto", "diffIcon_auto_btn_001.png"),
std::pair("na", "diffIcon_00_btn_001.png"),
std::pair("easy", "diffIcon_01_btn_001.png"),
std::pair("normal", "diffIcon_02_btn_001.png"),
std::pair("hard", "diffIcon_03_btn_001.png"),
std::pair("harder", "diffIcon_04_btn_001.png"),
std::pair("insane", "diffIcon_05_btn_001.png"),
std::pair("easydemon", "diffIcon_07_btn_001.png"),
std::pair("mediumdemon", "diffIcon_08_btn_001.png"),
std::pair("harddemon", "diffIcon_06_btn_001.png"),
std::pair("insanedemon", "diffIcon_09_btn_001.png"),
std::pair("extremedemon", "diffIcon_10_btn_001.png"),

std::pair("star", "GJ_starsIcon_001.png"),

std::pair("orb", "currencyOrb_001.png"),
std::pair("orbs", "currencyOrbIcon_001.png"),

std::pair("diamond", "diamond_small01_001.png"),
std::pair("diamonds", "currencyDiamondIcon_001.png"),

std::pair("like", "GJ_likesIcon_001.png"),
std::pair("dislike", "GJ_dislikesIcon_001.png"),

std::pair("check", "GJ_completesIcon_001.png"),
std::pair("cross", "GJ_deleteIcon_001.png"),

std::pair("locked", "GJLargeLock_001.png"),
std::pair("lockedgray", "GJ_lockGray_001.png"),
std::pair("unlocked", "GJ_lock_open_001.png"),

std::pair("goldcoin", "GJ_coinsIcon_001.png"),
std::pair("uncollectedusercoin", "GJ_coinsIcon_gray_001.png"),
std::pair("usercoin", "GJ_coinsIcon2_001.png"),
std::pair("points", "GJ_pointsIcon_001.png"),

std::pair("mod", "modBadge_01_001.png"),
std::pair("eldermod", "modBadge_02_001.png"),
std::pair("leaderboardmod", "modBadge_03_001.png"),
};

enum LabelPartType
{
Text,
Emoji
};

struct LabelPart
{
LabelPartType type = LabelPartType::Text;
std::string extra = "";

LabelPart(LabelPartType type, std::string ext)
{
this->type = type;
this->extra = geode::utils::string::toLower(ext);
}

std::string fileNameForEmoji()
{
if (type == LabelPartType::Text)
return "";

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

return "";
}
};

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

std::string font = "";
std::string text = "";

float maxX;

virtual void updateLabel() // copying types from normal label
{
parts.clear();

std::string s;
bool inEmoji = false;

for (size_t i = 0; i < text.size(); i++)
{
if (text[i] == ' ')
{
parts.push_back(LabelPart(LabelPartType::Text, s));

inEmoji = false;

s = " ";

continue;
}

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

inEmoji = !inEmoji;

s = "";

continue; // press start reference no way
}

s = s + text[i];
}

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

float pos = 0;
float wid = 0;
int yPos = 0;
float height = 0;


float commentHeight = CCLabelBMFont::create("l", font.c_str())->getContentHeight();

for (size_t i = 0; i < parts.size(); i++)
{
auto seg = parts[i];
log::info("type: {}, extra: {}, filename: {}", seg.type == LabelPartType::Emoji ? "Emoji" : "Text", seg.extra, seg.fileNameForEmoji());

if (seg.type == LabelPartType::Text)
{
auto lbl = CCLabelBMFont::create(seg.extra.c_str(), font.c_str(), 99999);
lbl->setAnchorPoint(ccp(0, 0));
lbl->setPosition(ccp(pos, -20 * yPos));
this->addChild(lbl);

height = std::max<float>(height, lbl->getScaledContentSize().height);
pos += lbl->getScaledContentSize().width;
wid = std::max<float>(wid, pos);
}
else if (seg.type == LabelPartType::Emoji)
{
auto emoji = CCSprite::createWithSpriteFrameName(seg.fileNameForEmoji().c_str());

if (!emoji)
continue;

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

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

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

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

this->setContentSize(ccp(wid, height));
}

virtual void setFont(const char *newString, bool update = true)
{
font = std::string(newString);

if (update)
updateLabel();
}

virtual void setString(const char *newString, bool update = true)
{
text = std::string(newString);

if (update)
updateLabel();
}

virtual void setMaxX(float max, bool update = true)
{
maxX = max;

if (update)
updateLabel();
}

void limitLabelWidth(float width, float defaultScale, float minScale)
{
this->setScale(clampf(width / this->getContentSize().width, minScale, defaultScale));
}

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

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

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

this->updateLabel();

return true;
}

static CCLabelBMFontExt* create(const char* text, const char* font)
{
CCLabelBMFontExt* pRet = new CCLabelBMFontExt();
if (pRet && pRet->init(text, font)) {
pRet->autorelease();
return pRet;
} else {
delete pRet;
return nullptr;
}
}
};
Loading

0 comments on commit 633c547

Please sign in to comment.