Skip to content

Commit 7057423

Browse files
committed
I love refactoring code
1 parent 42f7ebc commit 7057423

File tree

13 files changed

+306
-225
lines changed

13 files changed

+306
-225
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ jobs:
3434
- uses: actions/checkout@v4
3535

3636
- name: Build the mod
37-
uses: geode-sdk/build-geode-mod@main
37+
uses: hiimjasmine00/build-geode-mod@main
3838
with:
3939
build-config: ${{ matrix.config.build-config || 'Release' }}
4040
export-pdb: true
41+
export-symbols: true
4142
combine: true
4243
target: ${{ matrix.config.target }}
4344

@@ -47,22 +48,10 @@ jobs:
4748
needs: ['build']
4849

4950
steps:
50-
- uses: geode-sdk/build-geode-mod/combine@main
51+
- uses: hiimjasmine00/build-geode-mod/combine@main
5152
id: build
5253

5354
- uses: actions/upload-artifact@v4
5455
with:
5556
name: Build Output
5657
path: ${{ steps.build.outputs.build-output }}
57-
58-
release:
59-
name: Release the mod
60-
runs-on: ubuntu-latest
61-
needs: ['package']
62-
63-
steps:
64-
- uses: actions/checkout@v4
65-
66-
- uses: hiimjustin000/release-geode-mod@main
67-
with:
68-
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release Geode Mod
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
release:
8+
name: Release mod
9+
runs-on: ubuntu-latest
10+
environment:
11+
name: release
12+
url: ${{ steps.mod-release.outputs.url }}
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: hiimjasmine00/release-geode-mod@main
18+
id: mod-release
19+
with:
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
22+
publish:
23+
name: Publish mod
24+
runs-on: ubuntu-latest
25+
needs: ['release']
26+
environment:
27+
name: publish
28+
url: ${{ steps.mod-publish.outputs.url }}
29+
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- uses: hiimjasmine00/release-geode-mod/publish@main
34+
id: mod-publish
35+
with:
36+
token: ${{ secrets.GITHUB_TOKEN }}

CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ set(CMAKE_CXX_STANDARD 20)
33
set(CMAKE_CXX_STANDARD_REQUIRED ON)
44
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")
55
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
6+
set(GEODE_DISABLE_PRECOMPILED_HEADERS ON)
67

7-
project(DeveloperBadges VERSION 1.0.3)
8+
project(DeveloperBadges VERSION 1.1.0)
89

910
add_library(${PROJECT_NAME} SHARED
10-
src/main.cpp
11+
src/hooks/CommentCell.cpp
12+
src/hooks/ProfilePage.cpp
13+
src/DeveloperBadges.cpp
1114
)
1215

1316
if (NOT DEFINED ENV{GEODE_SDK})

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 hiimjustin000
3+
Copyright (c) 2024-2025 hiimjasmine00
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A mod that gives badges to Geode mod developers.
77

88
## Credits
99
- [Brift](https://gdbrowser.com/u/14114548) - Designer of the mod's textures
10-
- [hiimjustin000](https://gdbrowser.com/u/7466002) - Creator of the mod
10+
- [hiimjasmine00](https://gdbrowser.com/u/7466002) - Creator of the mod
1111

1212
## Badges
1313
- Mod Developer

about.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A mod that gives badges to Geode mod developers.
77

88
## Credits
99
- [Brift](user:14114548) - Designer of the mod's textures
10-
- [hiimjustin000](user:7466002) - Creator of the mod
10+
- [hiimjasmine00](user:7466002) - Creator of the mod
1111

1212
## Badges
1313
- Mod Developer

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Developer Badges Changelog
2+
## v1.1.0 (2025-02-06)
3+
- Changed badge loading to load one badge at a time
4+
- Added badge reloading to profiles
5+
26
## v1.0.3 (2024-11-15)
37
- Ported to Geode v4.0.0-beta.1
48

mod.json

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
{
2-
"geode": "4.0.0-beta.1",
2+
"geode": "4.2.0",
33
"gd": {
44
"android": "2.2074",
55
"win": "2.2074",
66
"mac": "2.2074"
77
},
8-
"version": "v1.0.3",
8+
"version": "v1.1.0",
99
"id": "hiimjustin000.developer_badges",
1010
"name": "Developer Badges",
11-
"developer": "hiimjustin000",
11+
"developer": "hiimjasmine00",
1212
"description": "A mod that gives badges to Geode mod developers.",
13-
"dependencies": [
14-
{
15-
"id": "geode.node-ids",
16-
"version": ">=v1.12.0",
17-
"importance": "required"
18-
},
19-
{
20-
"id": "jouca.badgesapi",
21-
"version": ">=v1.1.0",
22-
"importance": "required"
13+
"dependencies": {
14+
"geode.node-ids": ">=v1.12.0",
15+
"jouca.badgesapi": {
16+
"importance": "recommended",
17+
"version": ">=v1.1.0"
2318
}
24-
],
19+
},
2520
"resources": {
2621
"spritesheets": {
2722
"DB_BadgeSheet": [
@@ -85,7 +80,7 @@
8580
},
8681
"links": {
8782
"community": "https://discord.gg/QVKmbvBXA7",
88-
"source": "https://github.com/hiimjustin000/DeveloperBadges",
83+
"source": "https://github.com/hiimjasmine00/DeveloperBadges",
8984
"homepage": "https://www.hiimjustin000.com"
9085
},
9186
"tags": [

src/DeveloperBadges.cpp

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#include "DeveloperBadges.hpp"
2+
#include <Geode/binding/FLAlertLayer.hpp>
3+
#include <Geode/loader/Mod.hpp>
4+
#include <Geode/utils/ranges.hpp>
5+
6+
using namespace geode::prelude;
7+
8+
#define BADGE_URL "https://raw.githubusercontent.com/hiimjasmine00/developer-badges/master/badges/{}.json"
9+
10+
DeveloperBadge DeveloperBadges::badgeForUser(int id) {
11+
auto badge = ranges::find(DEVELOPER_BADGES, [id](const DeveloperBadge& badge) {
12+
return badge.id == id && badge.badge != BadgeType::None;
13+
});
14+
return badge.has_value() ? badge.value() : DeveloperBadge { 0, "", BadgeType::None };
15+
}
16+
17+
ccColor3B DeveloperBadges::getCommentColor(BadgeType badge) {
18+
switch (badge) {
19+
case BadgeType::ModDeveloper: return Mod::get()->getSettingValue<ccColor3B>("mod-developer-color");
20+
case BadgeType::VerifiedDeveloper: return Mod::get()->getSettingValue<ccColor3B>("verified-developer-color");
21+
case BadgeType::IndexStaff: return Mod::get()->getSettingValue<ccColor3B>("index-staff-color");
22+
case BadgeType::LeadDeveloper: return Mod::get()->getSettingValue<ccColor3B>("lead-developer-color");
23+
default: return ccColor3B { 255, 255, 255 };
24+
}
25+
}
26+
27+
void DeveloperBadges::loadBadge(EventListener<web::WebTask>&& listenerRef, int id, std::function<void(const DeveloperBadge&)> callback) {
28+
if (LOADED_IDS.contains(id)) return;
29+
30+
auto&& listener = std::move(listenerRef);
31+
listener.bind([id, callback](web::WebTask::Event* e) {
32+
if (auto res = e->getValue()) {
33+
LOADED_IDS.insert(id);
34+
35+
if (!res->ok() || !res->json().isOk()) return;
36+
37+
auto badge = res->json().unwrapOr(matjson::Value());
38+
if (!badge.isObject()) return;
39+
40+
DeveloperBadge devBadge = {
41+
.id = id,
42+
.name = badge["name"].asString().unwrapOr(""),
43+
.badge = (BadgeType)badge["badge"].asInt().unwrapOr(0)
44+
};
45+
DEVELOPER_BADGES.push_back(devBadge);
46+
callback(devBadge);
47+
}
48+
});
49+
50+
listener.setFilter(web::WebRequest().get(fmt::format(BADGE_URL, id)));
51+
}
52+
53+
void DeveloperBadges::showBadgeInfo(std::string username, BadgeType type) {
54+
auto badgeName = "";
55+
auto badgeDesc = "";
56+
switch (type) {
57+
case BadgeType::ModDeveloper:
58+
badgeName = "Mod Developer";
59+
badgeDesc = "is a <ca>mod developer</c> for <cy>Geode</c>.\n"
60+
"They have created mods that are available on the <cy>Geode mod index</c>.\n"
61+
"They will have to have new mods and mod updates approved by the <cd>index staff</c>";
62+
break;
63+
case BadgeType::VerifiedDeveloper:
64+
badgeName = "Verified Developer";
65+
badgeDesc = "is a <cp>verified mod developer</c> for <cy>Geode</c>.\n"
66+
"They can update their mods on the <cy>Geode mod index</c> without the need for approval.\n"
67+
"They will still have to have new mods approved by the <cd>index staff</c>";
68+
break;
69+
case BadgeType::IndexStaff:
70+
badgeName = "Index Staff";
71+
badgeDesc = "is a member of the <cd>index staff</c> for <cy>Geode</c>.\n"
72+
"They can approve or reject mods uploaded to the <cy>Geode mod index</c>";
73+
break;
74+
case BadgeType::LeadDeveloper:
75+
badgeName = "Lead Developer";
76+
badgeDesc = "is a <co>lead developer</c> of <cy>Geode</c>.\n"
77+
"They are part of the main development team and have significant contributions to the <cy>Geode ecosystem</c>";
78+
break;
79+
default:
80+
badgeName = "";
81+
badgeDesc = "";
82+
break;
83+
}
84+
85+
FLAlertLayer::create(badgeName, fmt::format("<cg>{}</c> {}.", username, badgeDesc), "OK")->show();
86+
}

src/DeveloperBadges.hpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <Geode/utils/web.hpp>
2+
3+
enum class BadgeType {
4+
None,
5+
ModDeveloper,
6+
VerifiedDeveloper,
7+
IndexStaff,
8+
LeadDeveloper
9+
};
10+
11+
struct DeveloperBadge {
12+
int id;
13+
std::string name;
14+
BadgeType badge;
15+
};
16+
17+
class DeveloperBadges {
18+
public:
19+
static inline std::vector<DeveloperBadge> DEVELOPER_BADGES;
20+
static inline std::set<int> LOADED_IDS;
21+
22+
static DeveloperBadge badgeForUser(int);
23+
static cocos2d::ccColor3B getCommentColor(BadgeType);
24+
static void loadBadge(geode::EventListener<geode::utils::web::WebTask>&&, int, std::function<void(const DeveloperBadge&)>);
25+
static void showBadgeInfo(std::string, BadgeType);
26+
};

0 commit comments

Comments
 (0)