Skip to content

Commit

Permalink
It's Goin' Down (feat. Nitti)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiimjasmine00 committed Oct 12, 2024
1 parent 8331c40 commit acd48d9
Show file tree
Hide file tree
Showing 13 changed files with 293 additions and 17 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")
set(CMAKE_CXX_VISIBILITY_PRESET hidden)

project(MoreIcons VERSION 1.2.7)
project(MoreIcons VERSION 1.3.0)

add_library(${PROJECT_NAME} SHARED
src/classes/DummyNode.cpp
src/classes/LogCell.cpp
src/classes/LogLayer.cpp
src/hooks/AppDelegate.cpp
src/hooks/CharacterColorPage.cpp
src/hooks/GameManager.cpp
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# More Icons
A mod that loads custom icons.

[YouTube Tutorial](https://youtu.be/s2AM98Yj59k)
[Windows Tutorial](https://youtu.be/Dn0S3DPuq08)\
[Android Tutorial](https://youtu.be/GJKoLUnkyBk)\
[macOS Tutorial](https://youtu.be/1sI4WJE0yqE)

## Adding Icons
To add a custom icon, you need an icon spritesheet (.plist) and an icon atlas (.png). Tools like [GDBrowser's Icon Kit](https://gdbrowser.com/iconkit) can be used to create these spritesheets and atlases, with the "Developer Mode" option enabled in the settings.
Expand Down Expand Up @@ -31,10 +33,11 @@ The spritesheets and atlases should be placed in `(Geometry Dash folder)/geode/c
- spider
- swing
- jetpack
- trail

This can also be done with individual images per icon piece, with the same naming conventions as above. The sprites should be placed in `(Geometry Dash folder)/geode/config/hiimjustin000.more_icons/(gamemode)/(icon name)`, where `(icon name)` is the name of the icon.

If anything goes wrong, the mod will log warnings and errors to the console, which can be checked in `(Geometry Dash folder)/geode/logs`.
If anything goes wrong, the mod will log warnings and errors to the console, which can be checked in the icon kit with a button on the left side of the screen.

## Texture Packs
For adding icons to texture packs, the process is similar to adding icons to the mod. However, you will need the mod "Texture Loader" by Geode Team installed to use these texture packs.
Expand Down
7 changes: 5 additions & 2 deletions about.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# More Icons
A mod that loads custom icons.

[YouTube Tutorial](https://youtu.be/s2AM98Yj59k)
[Windows Tutorial](https://youtu.be/Dn0S3DPuq08)\
[Android Tutorial](https://youtu.be/GJKoLUnkyBk)\
[macOS Tutorial](https://youtu.be/1sI4WJE0yqE)

## Adding Icons
To add a custom icon, you need an icon spritesheet (.plist) and an icon atlas (.png). Tools like [GDBrowser's Icon Kit](https://gdbrowser.com/iconkit) can be used to create these spritesheets and atlases, with the "Developer Mode" option enabled in the settings.
Expand Down Expand Up @@ -31,10 +33,11 @@ The spritesheets and atlases should be placed in `(Geometry Dash folder)/geode/c
- spider
- swing
- jetpack
- trail

This can also be done with individual images per icon piece, with the same naming conventions as above. The sprites should be placed in `(Geometry Dash folder)/geode/config/hiimjustin000.more_icons/(gamemode)/(icon name)`, where `(icon name)` is the name of the icon.

If anything goes wrong, the mod will log warnings and errors to the console, which can be checked in `(Geometry Dash folder)/geode/logs`.
If anything goes wrong, the mod will log warnings and errors to the console, which can be checked in the icon kit with a button on the left side of the screen.

## Texture Packs
For adding icons to texture packs, the process is similar to adding icons to the mod. However, you will need the mod "Texture Loader" by Geode Team installed to use these texture packs.
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# More Icons Changelog
## v1.3.0 (2024-10-12)
- Added ability to view logs and amount of loaded icons in the icon kit
- Changed logs to be more specific
- Updated tutorial links in the mod's description

## v1.2.7 (2024-10-10)
- Fixed plist icons changing names

Expand Down
7 changes: 6 additions & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"win": "2.206",
"mac": "2.206"
},
"version": "v1.2.7",
"version": "v1.3.0",
"id": "hiimjustin000.more_icons",
"name": "More Icons",
"developer": "hiimjustin000",
Expand All @@ -17,6 +17,11 @@
"importance": "required"
}
],
"resources": {
"sprites": [
"resources/*.png"
]
},
"links": {
"community": "https://discord.gg/QVKmbvBXA7",
"source": "https://github.com/hiimjustin000/MoreIcons",
Expand Down
Binary file added resources/MI_moreIcons_001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 42 additions & 7 deletions src/MoreIcons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,26 @@ void MoreIcons::loadIcon(const std::filesystem::path& path, IconType type) {
auto fileQuality = kTextureQualityLow;
if (pathFilename.ends_with("-uhd.png")) {
if (textureQuality != kTextureQualityHigh) {
log::warn("Ignoring too high quality PNG file: {}", subEntryPath.parent_path().filename() / pathFilename);
auto logMessage = fmt::format("{}: Ignoring high-quality PNG file for {} texture quality", subEntryPath.string(),
textureQuality == kTextureQualityMedium ? "medium" : "low");
log::warn("{}", logMessage);
{
std::lock_guard lock(LOG_MUTEX);
LOGS.push_back({ .message = logMessage, .type = LogType::Info });
}
continue;
}

fileQuality = kTextureQualityHigh;
}
else if (pathFilename.ends_with("-hd.png")) {
if (textureQuality != kTextureQualityHigh && textureQuality != kTextureQualityMedium) {
log::warn("Ignoring too high quality PNG file: {}", subEntryPath.parent_path().filename() / pathFilename);
auto logMessage = fmt::format("{}: Ignoring medium-quality PNG file for low texture quality", subEntryPath.string());
log::warn("{}", logMessage);
{
std::lock_guard lock(LOG_MUTEX);
LOGS.push_back({ .message = logMessage, .type = LogType::Info });
}
continue;
}

Expand Down Expand Up @@ -267,15 +278,26 @@ void MoreIcons::loadIcon(const std::filesystem::path& path, IconType type) {
auto fileQuality = kTextureQualityLow;
if (pathFilename.ends_with("-uhd.plist")) {
if (textureQuality != kTextureQualityHigh) {
log::warn("Ignoring too high quality plist file: {}", pathFilename);
auto logMessage = fmt::format("{}: Ignoring high-quality PLIST file for {} texture quality", path.string(),
textureQuality == kTextureQualityMedium ? "medium" : "low");
log::warn("{}", logMessage);
{
std::lock_guard lock(LOG_MUTEX);
LOGS.push_back({ .message = logMessage, .type = LogType::Info });
}
return;
}

fileQuality = kTextureQualityHigh;
}
else if (pathFilename.ends_with("-hd.plist")) {
if (textureQuality != kTextureQualityHigh && textureQuality != kTextureQualityMedium) {
log::warn("Ignoring too high quality plist file: {}", pathFilename);
auto logMessage = fmt::format("{}: Ignoring medium-quality PLIST file for low texture quality", path.string());
log::warn("{}", logMessage);
{
std::lock_guard lock(LOG_MUTEX);
LOGS.push_back({ .message = logMessage, .type = LogType::Info });
}
return;
}

Expand Down Expand Up @@ -317,9 +339,16 @@ void MoreIcons::loadIcon(const std::filesystem::path& path, IconType type) {
}
dict->setObject(frames, "frames");
auto metadata = static_cast<CCDictionary*>(dict->objectForKey("metadata"));
auto fullTexturePath = (path.parent_path() / std::filesystem::path(metadata->valueForKey("textureFileName")->getCString()).filename()).string();
auto texturePath = std::filesystem::path(metadata->valueForKey("textureFileName")->getCString()).filename().string();
auto fullTexturePath = (path.parent_path() / texturePath).string();
if (!std::filesystem::exists(fullTexturePath)) {
log::warn("Texture file not found: {}", fullTexturePath);
auto logMessage = fmt::format("{}: Texture file {} not found", path.string(), texturePath);
log::warn("{}", logMessage);
{
std::lock_guard lock(LOG_MUTEX);
LOGS.push_back({ .message = logMessage, .type = LogType::Error });
if (HIGHEST_SEVERITY < LogType::Error) HIGHEST_SEVERITY = LogType::Error;
}
return;
}

Expand Down Expand Up @@ -388,7 +417,13 @@ void MoreIcons::loadTrail(const std::filesystem::path& path) {
std::string error;
auto tryJson = matjson::parse(bufferStream.str(), error);
if (!error.empty()) {
log::warn("Failed to parse JSON file {}: {}", jsonPath.filename().string(), error);
auto logMessage = fmt::format("{}: Failed to parse JSON file ({})", path.string(), error);
log::warn("{}", logMessage);
{
std::lock_guard lock(LOG_MUTEX);
LOGS.push_back({ .message = logMessage, .type = LogType::Warn });
if (HIGHEST_SEVERITY < LogType::Warn) HIGHEST_SEVERITY = LogType::Warn;
}
json = matjson::Object { { "blend", false }, { "tint", false } };
}
else json = tryJson.value_or(matjson::Object { { "blend", false }, { "tint", false } });
Expand Down
18 changes: 16 additions & 2 deletions src/MoreIcons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ struct ImageData {
bool tint;
};

enum class LogType {
Info,
Warn,
Error
};

struct LogData {
std::string message;
LogType type;
};

// https://github.com/GlobedGD/globed2/blob/v1.6.2/src/util/cocos.cpp#L44
namespace {
template <typename TC>
Expand All @@ -35,7 +46,6 @@ namespace {
void _addSpriteFramesWithDictionary(cocos2d::CCDictionary*, cocos2d::CCTexture2D*);
}


class MoreIcons {
public:
static inline std::vector<std::string> ICONS;
Expand All @@ -54,7 +64,9 @@ class MoreIcons {
static inline std::vector<std::string> TRAIL_DUPLICATES;
static inline std::vector<ImageData> IMAGES;
static inline std::mutex IMAGE_MUTEX;
static inline IconType LOAD_TYPE = IconType::Cube;
static inline std::vector<LogData> LOGS;
static inline std::mutex LOG_MUTEX;
static inline LogType HIGHEST_SEVERITY = LogType::Info;

static bool hasIcon(const std::string& name) {
return !ICONS.empty() && std::find(ICONS.begin(), ICONS.end(), name) != ICONS.end();
Expand Down Expand Up @@ -115,6 +127,8 @@ class MoreIcons {
saveTrails();
TRAIL_INFO.clear();
removeSaved();
LOGS.clear();
HIGHEST_SEVERITY = LogType::Info;
}

static void removeSaved() {
Expand Down
77 changes: 77 additions & 0 deletions src/classes/LogCell.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#include "LogCell.hpp"

using namespace geode::prelude;

LogCell* LogCell::create(LogData const& data, int index, int total, bool dark) {
auto ret = new LogCell();
if (ret->init(data, index, total, dark)) {
ret->autorelease();
return ret;
}
delete ret;
return nullptr;
}

bool LogCell::init(LogData const& data, int index, int total, bool dark) {
if (!CCLayer::init()) return false;

ignoreAnchorPointForPosition(false);

setContentSize({ 400.0f, 70.0f });

m_index = index;
m_total = total;

auto bg = CCLayerColor::create({ 0, 0, 0, 255 }, 400.0f, 70.0f);
if (dark) bg->setColor(index % 2 == 0 ? ccColor3B { 48, 48, 48 } : ccColor3B { 80, 80, 80 });
else bg->setColor(index % 2 == 0 ? ccColor3B { 161, 88, 44 } : ccColor3B { 194, 114, 62 });
bg->ignoreAnchorPointForPosition(false);
if (index == 0) {
bg->setContentSize({ 400.0f, 35.0f });
bg->setPosition(200.0f, 17.5f);
}
else if (index == total - 1) {
bg->setContentSize({ 400.0f, 35.0f });
bg->setPosition(200.0f, 52.5f);
}
else {
bg->setContentSize({ 400.0f, 70.0f });
bg->setPosition(200.0f, 35.0f);
}
addChild(bg, -1);

if (index == 0 || index == total - 1) {
auto bgBg = CCScale9Sprite::create("square02b_001.png", { 0, 0, 80, 80 });
bgBg->setContentSize({ 400.0f, 70.0f });
bgBg->setPosition(200.0f, 35.0f);
bgBg->setColor(bg->getColor());
addChild(bgBg, -2);
}

auto infoFrame = "";
switch (data.type) {
case LogType::Info: infoFrame = "GJ_infoIcon_001.png"; break;
case LogType::Warn: infoFrame = "geode.loader/info-warning.png"; break;
case LogType::Error: infoFrame = "geode.loader/info-alert.png"; break;
}

auto infoIcon = CCSprite::createWithSpriteFrameName(infoFrame);
infoIcon->setPosition({ 20.0f, 35.0f });
addChild(infoIcon);

auto textArea = TextArea::create(data.message, "bigFont.fnt", 0.25f, 350.0f, { 0.0f, 1.0f }, 10.0f, true);
textArea->setContentSize({ textArea->m_width, textArea->m_height * textArea->m_label->m_lines->count() });
textArea->m_label->setPosition({ 0.0f, textArea->getContentHeight() });
textArea->setPosition({ 40.0f, 35.0f });
textArea->setAnchorPoint({ 0.0f, 0.5f });
addChild(textArea);

return true;
}

void LogCell::draw() {
ccDrawColor4B(0, 0, 0, 75);
glLineWidth(2.0f);
if (m_index < m_total - 1) ccDrawLine({ 0.0f, 0.0f }, { 400.0f, 0.0f });
if (m_index > 0) ccDrawLine({ 0.0f, 70.0f }, { 400.0f, 70.0f });
}
12 changes: 12 additions & 0 deletions src/classes/LogCell.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "../MoreIcons.hpp"

class LogCell : public cocos2d::CCLayer {
protected:
int m_index = 0;
int m_total = 0;

bool init(LogData const& data, int index, int total, bool dark);
public:
static LogCell* create(LogData const& data, int index, int total, bool dark);
void draw() override;
};
Loading

0 comments on commit acd48d9

Please sign in to comment.