Skip to content

Commit 907e82e

Browse files
committed
Attempt to fix #14, and fix other things
1 parent 4010e92 commit 907e82e

19 files changed

Lines changed: 268 additions & 460 deletions

.forgejo/workflows/build.yaml

Lines changed: 21 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,152 +1,63 @@
1-
name: Build Geode Mod (Codeberg)
2-
3-
# Thank you very much to https://github.com/altalk23/Allium
1+
name: Build Geode Mod
42

53
on:
64
workflow_dispatch:
75
push:
86
branches:
97
- "**"
108

11-
env:
12-
MOD_ID: firee.object-workshop
13-
BUILD_CONFIG: RelWithDebInfo
14-
159
jobs:
1610
build:
1711
strategy:
1812
fail-fast: false
1913
matrix:
2014
config:
2115
- name: Windows
22-
target: windows
23-
platform: win
16+
image: windows
17+
target: Win64
2418

2519
# - name: macOS
26-
# target: macos
27-
# platform: macos
20+
# image: macos
21+
# target: MacOS
2822
#
2923
# - name: iOS
30-
# target: ios
31-
# platform: ios
24+
# image: ios
25+
# target: iOS
3226

3327
- name: Android32
34-
target: android
35-
platform: android32
28+
image: android
29+
target: Android32
3630

3731
- name: Android64
38-
target: android
39-
platform: android64
32+
image: android
33+
target: Android64
4034

4135
name: ${{ matrix.config.name }}
4236
runs-on: codeberg-medium
4337
container:
44-
image: prevter/geode-sdk:${{ matrix.config.target }}-latest
38+
image: prevter/geode-sdk:${{ matrix.config.image }}-latest
4539

4640
steps:
4741
- name: Checkout repository
4842
uses: actions/checkout@v4
4943

50-
# rest is taken from Dockerfile
51-
52-
- name: Install SDK & Binaries
53-
run: |
54-
geode sdk update 5.4.1
55-
# geode sdk install-binaries -p ${{ matrix.config.platform }} # commenting this out for now as codeberg is ratelimited by github
56-
curl -L "https://github.com/geode-sdk/geode/releases/download/v5.4.1/geode-v5.4.1-${{ matrix.config.platform }}.zip" -o geode-v5.4.1-${{ matrix.config.platform }}.zip
57-
mkdir -p $GEODE_SDK/bin
58-
mkdir -p $GEODE_SDK/bin/5.4.1
59-
unzip -o geode-v5.4.1-${{ matrix.config.platform }}.zip -d $GEODE_SDK/bin/5.4.1
60-
git clone https://github.com/geode-sdk/bindings --depth=1 /workspace/bindings
61-
62-
- name: Configure & Build
63-
run: |
64-
CMAKE_EXTRA_ARGS=""
65-
if [ ${{ matrix.config.platform }} = "mac" ]; then
66-
CMAKE_EXTRA_ARGS="-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 -DGEODE_DISABLE_PRECOMPILED_HEADERS=OFF"
67-
elif [ ${{ matrix.config.platform }} = "android32" ]; then
68-
CMAKE_EXTRA_ARGS="-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_STL=c++_shared -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-23"
69-
elif [ ${{ matrix.config.platform }} = "android64" ]; then
70-
CMAKE_EXTRA_ARGS="-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_STL=c++_shared -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-23"
71-
elif [ ${{ matrix.config.platform }} = "ios" ]; then
72-
CMAKE_EXTRA_ARGS="-DCMAKE_SYSTEM_NAME=iOS -DGEODE_TARGET_PLATFORM=iOS -DGEODE_DISABLE_PRECOMPILED_HEADERS=OFF"
73-
elif [ ${{ matrix.config.platform }} = "win" ]; then
74-
CMAKE_EXTRA_ARGS="-DHOST_ARCH=x64 -DCMAKE_TOOLCHAIN_FILE=/root/.local/share/Geode/cross-tools/clang-msvc-sdk/clang-msvc.cmake -DSPLAT_DIR=/root/.local/share/Geode/cross-tools/splat"
75-
fi
76-
cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_CONFIG }} -DGEODE_BINDINGS_REPO_PATH=/workspace/bindings -G Ninja $CMAKE_EXTRA_ARGS -DGEODE_DONT_INSTALL_MODS=ON
77-
cmake --build build --config ${{ env.BUILD_CONFIG }} --parallel
78-
79-
mkdir /workspace/out
80-
81-
for file in $(find ./build -name *.geode); do
82-
cp $file "/workspace/out"
83-
done
84-
85-
- name: Upload artifact
86-
uses: https://code.forgejo.org/actions/upload-artifact@v3
44+
- name: Build the mod
45+
uses: https://codeberg.org/geode-sdk/build-geode-mod@main
8746
with:
88-
name: "geode-build-${{ matrix.config.platform }}"
89-
path: /workspace/out/
47+
combine: true
48+
target: ${{ matrix.config.target }}
9049

9150
package:
9251
name: Package builds
93-
runs-on: codeberg-tiny-lazy # note for me: lazy basically means you dont care if it takes a while for the job to start (ref: https://codeberg.org/actions/meta)
52+
# '-lazy' means you don't care if it takes a while for the job to start (ref: https://codeberg.org/actions/meta)
53+
runs-on: codeberg-tiny-lazy
9454
needs: ['build']
9555

9656
steps:
97-
- uses: https://code.forgejo.org/actions/download-artifact@v3
98-
with:
99-
path: ./artifacts
100-
101-
# TODO: Fix this so it gets latest via https://api.github.com/repos/geode-sdk/cli/releases/latest
102-
- name: Download CLI
103-
run: |
104-
curl -L "https://github.com/geode-sdk/cli/releases/download/v3.7.4/geode-cli-v3.7.4-linux.zip" -o cli.zip
105-
unzip cli.zip -d .
106-
chmod +x ./geode
107-
108-
- name: Merge Artifacts
109-
run: |
110-
mkdir -p out
111-
MODS=$(find ./artifacts -name *.geode -type f -printf "%f\n" | sort -u)
112-
for mod in $MODS; do
113-
echo "Merging $mod"
114-
PACKAGE_ARGS=""
115-
if [ -f "./artifacts/geode-build-win/$mod" ]; then
116-
PACKAGE_ARGS="$PACKAGE_ARGS ./artifacts/geode-build-win/$mod"
117-
fi
118-
if [ -f "./artifacts/geode-build-mac/$mod" ]; then
119-
PACKAGE_ARGS="$PACKAGE_ARGS ./artifacts/geode-build-mac/$mod"
120-
fi
121-
if [ -f "./artifacts/geode-build-android32/$mod" ]; then
122-
PACKAGE_ARGS="$PACKAGE_ARGS ./artifacts/geode-build-android32/$mod"
123-
fi
124-
if [ -f "./artifacts/geode-build-android64/$mod" ]; then
125-
PACKAGE_ARGS="$PACKAGE_ARGS ./artifacts/geode-build-android64/$mod"
126-
fi
127-
if [ -f "./artifacts/geode-build-ios/$mod" ]; then
128-
PACKAGE_ARGS="$PACKAGE_ARGS ./artifacts/geode-build-ios/$mod"
129-
fi
130-
ARG_LIST=($PACKAGE_ARGS)
131-
# why does it merge into the first one instead of just an output..
132-
FIRST="${ARG_LIST[0]}"
133-
if [ ${#ARG_LIST[@]} != 1 ]; then
134-
./geode package merge $PACKAGE_ARGS
135-
fi
136-
cp $FIRST out
137-
done
138-
# Copy the .pdb file from windows artifact if it exists
139-
cp ./artifacts/geode-build-win/*.pdb out/ || true
140-
# Copy the .sym files from android artifacts if they exist
141-
cp ./artifacts/geode-build-android32/*.sym out/ || true
142-
cp ./artifacts/geode-build-android64/*.sym out/ || true
143-
# Copy the other debug files from android and macos/ios
144-
cp ./artifacts/geode-build-android32/*.dbg out/ || true
145-
cp ./artifacts/geode-build-android64/*.dbg out/ || true
146-
cp -R ./artifacts/geode-build-mac/*.dSYM out/ || true
147-
cp -R ./artifacts/geode-build-ios/*.dSYM out/ || true
57+
- uses: https://codeberg.org/geode-sdk/build-geode-mod/combine@main
58+
id: build
14859

14960
- uses: https://code.forgejo.org/forgejo/upload-artifact@v3
15061
with:
15162
name: Build Output
152-
path: ./out/
63+
path: ${{ steps.build.outputs.build-output }}

about.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ Thank you to <cj>Midair</c> for the mod idea, <cy>Alphalaneous</c> for the extra
1818
- To upload, click on the <cy>My Objects</c> tab, and make sure that the object you want to upload is in your <co>custom objects</c> (C). Otherwise, you won't be able to <cy>upload an object</c>!
1919

2020
# Authentication Methods
21+
- <cr>Argon</c> is an authentication method <cb>Globed</c> and other mods use. It's recommended to use this option as it's the most reliable. It does a similar method to <cp>DashAuth</c> where it <cy>sends a message to a bot</c> to confirm the authenticity of your <cy>GD account</c>.
2122
- <cp>DashAuth</c> is an authentication method that <cy>sends a message to a bot</c> to confirm the authenticity of your <cy>GD account</c>, similar to how mods like <cb>Globed</c> handles verifying your <cy>GD account</c>. Thanks to <cp>rooot</c> for creating it!
22-
- <cg>GDAuth</c> is an authentication method made by <cg>fig</c> which <cy>sends your GJP</c> (session token for GD) to <cg>fig's server</c> to confirm the authenticity of your <cy>GD account</c>. You should only use this <cy>if you trust fig's server</c>, as this method is like sending your GD account to <cy>fig's server</c>.
2323
- <cy>Do Later</c> is what it says. This will close the menu and open up the <cy>Object Workshop</c>. Although do note that you <cy>will be limited</c> in what features you can use.
2424

2525
If none of the methods satisfy you, or you would like to receive an <cy>authentication token</c> without doing any of these methods, consider <cy>joining the Discord server</c> to ask me to verify you and give an <cy>authentication token</c> to you.

changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# v1.5.0-beta.2
2+
- Added support button on bottom left
3+
- Changed description to remove GDAuth
4+
- Fixed object overwriting when editing an object
5+
- (hopefully) Fixed touch prio issues and compatibility with Better Touch Prio
6+
- Fixed version not matching in user agent
7+
- Fixed colors not rendering properly for ratings
18
# v1.5.0-beta.1 (Beta as it's not finished!)
29
- Ported to Geode v5 (2.208!)
310
- Revamped UI

mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"id": "firee.object-workshop",
1010
"name": "Object Workshop",
11-
"version": "v1.5.0-beta.1",
11+
"version": "v1.5.0-beta.2",
1212
"developer": "Firee",
1313
"description": "Download, upload, or find custom objects made by other creators!",
1414
"resources": {

src/nodes/ComboComponent.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ namespace {
5858
scrollBlock->setScale(0.3f);
5959
scrollBlock->setContentSize({s_width, scrollHeight});
6060
scrollBlock->setZOrder(-100);
61-
scrollBlock->registerWithTouchDispatcher();
6261
scrollBlock->setID("scroll-block"_spr);
6362

6463
auto scrollBlockButton = CCMenuItemSpriteExtra::create(
@@ -84,7 +83,6 @@ namespace {
8483

8584
for (size_t i = 0; auto const& value : m_options) {
8685
auto menu = cocos2d::CCMenu::create();
87-
// menu->registerWithTouchDispatcher();
8886
menu->setContentSize({s_width * 0.3f, 80.f * 0.3f});
8987
auto itemBG = NineSlice::createWithSpriteFrameName("geode.loader/tab-bg.png");
9088
itemBG->setColor({0,0,0});
@@ -112,9 +110,6 @@ namespace {
112110
}
113111
m_scrollLayer->m_contentLayer->updateLayout();
114112
m_scrollLayer->moveToTop();
115-
Loader::get()->queueInMainThread([this]() {
116-
m_scrollLayer->fixTouchPrio();
117-
});
118113
}
119114

120115
void updateLabel() const {
@@ -201,8 +196,6 @@ namespace {
201196
m_callback = std::move(callback);
202197
m_opened = std::move(opened);
203198

204-
this->setUserFlag("alk.better-touch-prio/steals-touch");
205-
206199
this->setContentSize({ width, 28.f });
207200

208201
//m_background = geode::NineSlice::create("square02b_001.png");

src/nodes/ExtPreviewBG.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ bool ExtPreviewBG::init(LevelEditorLayer* editorLayer, std::string data, CCSize
5555
m_clippingNode->setZOrder(1);
5656
this->addChildAtPosition(m_clippingNode, Anchor::Center);
5757

58-
this->registerWithTouchDispatcher();
5958
this->setTouchEnabled(true);
6059
this->setTouchMode(kCCTouchesOneByOne);
6160
this->setMouseEnabled(true);

src/nodes/ItemNode.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include "ItemNode.hpp"
2+
#include "../utils.hpp"
3+
using namespace geode::prelude;
4+
5+
bool ItemNode::init(LevelEditorLayer* editorLayer, gd::string data) {
6+
if (!CCNode::init()) return false;
7+
this->setContentSize({ 32.0f, 32.0f });
8+
auto bg = Build<CCScale9Sprite>::create("square02_small.png").opacity(60).contentSize(this->getContentSize()).parentAtPos(this, Anchor::Center).collect();
9+
CCLayerColor* mask = CCLayerColor::create({255, 255, 255});
10+
mask->setContentSize(bg->getContentSize());
11+
Build<CCClippingNode>::create().contentSize(this->getContentSize()).anchorPoint(0.5f,0.5f).zOrder(1).with([editorLayer, data, mask](auto node) {
12+
auto zData = ZStringView(data);
13+
unsigned int objectCount = std::count(zData.begin(), zData.end(), ';');
14+
if (!zData.empty()) {
15+
auto smartBlock = CCArray::create();
16+
int renderLimit = Mod::get()->getSettingValue<int64_t>("render-objects");
17+
int preRender = Mod::get()->getSettingValue<int64_t>("prerender-objects");
18+
CCSprite* sprite = editorLayer->m_editorUI->spriteFromObjectString(data, false, false, renderLimit, smartBlock, (CCArray *)0x0,(GameObject *)0x0);
19+
editorLayer->updateObjectColors(smartBlock);
20+
sprite->setScale(((node->getContentSize().height - 6) / sprite->getContentSize().height));
21+
if (objectCount >= preRender) {
22+
CCSize contentSize = node->getContentSize();
23+
sprite->setPosition(contentSize / 2);
24+
CCRenderTexture* tex = CCRenderTexture::create(contentSize.width, contentSize.height);
25+
tex->beginWithClear(0, 0, 0, 0);
26+
sprite->visit();
27+
tex->end();
28+
node->addChildAtPosition(tex, Anchor::Center);
29+
} else {
30+
node->addChildAtPosition(sprite, Anchor::Center);
31+
}
32+
node->setStencil(mask);
33+
}
34+
}).parentAtPos(bg, Anchor::Center);
35+
Build<CCSprite>::create("select_outline.png"_spr).scale(0.4f).visible(false).store(m_bgSprBehind).parentAtPos(this, Anchor::Center);
36+
return true;
37+
}

src/nodes/ItemNode.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
class ItemNode : public cocos2d::CCNode {
3+
protected:
4+
cocos2d::CCSprite* m_bgSprBehind;
5+
bool init(LevelEditorLayer* editorLayer, gd::string data);
6+
public:
7+
void toggle(bool state) {
8+
m_bgSprBehind->setVisible(state);
9+
}
10+
static ItemNode* create(LevelEditorLayer* editorLayer, gd::string data) {
11+
auto pRet = new ItemNode();
12+
if (pRet->init(editorLayer, data)) {
13+
pRet->autorelease();
14+
return pRet;
15+
}
16+
delete pRet;
17+
return nullptr;
18+
}
19+
};

src/nodes/ObjectItem.cpp

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,35 @@ CCNode* ObjectItem::createStars(double rating) {
2929
}
3030

3131
ccColor3B ObjectItem::starColor(double rating) {
32-
ccColor3B ratingColor = { 255, 255, 0 };
3332
// yes i used chat jippity because i cant think at 2 am
34-
if (rating != 5.0) {
35-
if (rating >= 5.0) {
36-
// Yellow
37-
ratingColor = {255, 255, 0};
38-
} else if (rating >= 4.0) {
39-
// Green to Yellow
40-
double t = (rating - 4.0);
41-
ratingColor = {static_cast<GLubyte>(255 * t), 255, 0};
42-
} else if (rating >= 3.0) {
43-
// Orange to Green
44-
double t = (rating - 3.0);
45-
ratingColor = {static_cast<GLubyte>(255 * (1 - t)), static_cast<GLubyte>(165 * (1 - t)), 0};
46-
} else if (rating >= 2.0) {
47-
// Reddish Orange to Orange
48-
double t = (rating - 2.0);
49-
ratingColor = {255, static_cast<GLubyte>(70 + 95 * t), 0};
50-
} else {
51-
// Red to Reddish Orange
52-
double t = (rating - 1.0);
53-
ratingColor = {255, static_cast<GLubyte>(70 * t), 0};
54-
}
33+
34+
// Color stops: 1=Red, 2=Reddish Orange, 3=Orange, 4=Green, 5=Yellow
35+
auto lerp = [](GLubyte a, GLubyte b, double t) -> GLubyte {
36+
return static_cast<GLubyte>(a + (b - a) * t);
37+
};
38+
auto lerpColor = [&](ccColor3B a, ccColor3B b, double t) -> ccColor3B {
39+
return { lerp(a.r, b.r, t), lerp(a.g, b.g, t), lerp(a.b, b.b, t) };
40+
};
41+
ccColor3B red = { 255, 0, 0 };
42+
ccColor3B reddishOrange = { 255, 70, 0 };
43+
ccColor3B orange = { 255, 165, 0 };
44+
ccColor3B green = { 0, 255, 0 };
45+
ccColor3B yellow = { 255, 255, 0 };
46+
if (rating >= 5.0) {
47+
return yellow;
48+
} else if (rating >= 4.0) {
49+
return lerpColor(green, yellow, rating - 4.0);
50+
} else if (rating >= 3.0) {
51+
return lerpColor(orange, green, rating - 3.0);
52+
} else if (rating >= 2.0) {
53+
return lerpColor(reddishOrange, orange, rating - 2.0);
54+
} else if (rating >= 1.0) {
55+
return lerpColor(red, reddishOrange, rating - 1.0);
56+
} else if (rating == 0.0) {
57+
return {255, 255, 255};
58+
} else {
59+
return red;
5560
}
56-
return ratingColor;
5761
}
5862

5963
CCMenu* ObjectItem::createClickableStars(CCObject* target, SEL_MenuHandler callback) {

0 commit comments

Comments
 (0)