Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sheepdotcom committed Nov 17, 2024
0 parents commit b4ff1c8
Show file tree
Hide file tree
Showing 11 changed files with 357 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
55 changes: 55 additions & 0 deletions .github/workflows/multi-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build Geode Mod

on:
workflow_dispatch:
push:
branches:
- "**"

jobs:
build:
strategy:
fail-fast: false
matrix:
config:
- name: Windows
os: windows-latest

- name: macOS
os: macos-latest

- name: Android32
os: ubuntu-latest
target: Android32

- name: Android64
os: ubuntu-latest
target: Android64

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

steps:
- uses: actions/checkout@v4

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

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

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

- uses: actions/upload-artifact@v4
with:
name: Build Output
path: ${{ steps.build.outputs.build-output }}
64 changes: 64 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

# Macos be like
**/.DS_Store

# Cache files for Sublime Text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache

# Ignore build folders
**/build
# Ignore platform specific build folders
build-*/

# Workspace files are user-specific
*.sublime-workspace

# ILY vscode
**/.vscode

# Local History for Visual Studio Code
.history/

# clangd
.cache/

# Visual Studio
.vs/

# CLion
.idea/
/cmake-build-*/
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.21)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
set(CMAKE_CXX_VISIBILITY_PRESET hidden)

project(CustomGeodeUI VERSION 1.0.0)

add_library(${PROJECT_NAME} SHARED
src/main.cpp
# Add any extra C++ source files here
)

if (NOT DEFINED ENV{GEODE_SDK})
message(FATAL_ERROR "Unable to find Geode SDK! Please define GEODE_SDK environment variable to point to Geode")
else()
message(STATUS "Found Geode: $ENV{GEODE_SDK}")
endif()

add_subdirectory($ENV{GEODE_SDK} ${CMAKE_CURRENT_BINARY_DIR}/geode)

setup_geode_mod(${PROJECT_NAME})
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# CustomGeodeUI
This is where she makes a mod.

<img src="logo.png" width="150" alt="the mod's logo" />

*Update logo.png to change your mod's icon (please)*

## Getting started
We recommend heading over to [the getting started section on our docs](https://docs.geode-sdk.org/getting-started/) for useful info on what to do next.

## Build instructions
For more info, see [our docs](https://docs.geode-sdk.org/getting-started/create-mod#build)
```sh
# Assuming you have the Geode CLI set up already
geode build
```

# Resources
* [Geode SDK Documentation](https://docs.geode-sdk.org/)
* [Geode SDK Source Code](https://github.com/geode-sdk/geode/)
* [Geode CLI](https://github.com/geode-sdk/cli)
* [Bindings](https://github.com/geode-sdk/bindings/)
* [Dev Tools](https://github.com/geode-sdk/DevTools)
3 changes: 3 additions & 0 deletions about.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Template Mod

Edit about.md to change this
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# 1.0.0
- Edit this file to change your mod's changelog.
Binary file added logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"geode": "4.0.0-beta.1",
"gd": {
"win": "2.2074",
"android": "2.2074",
"mac": "2.2074",
"ios": "2.2074"
},
"id": "sheepdotcom.geode-ui-tweaks",
"name": "Geode UI Tweaks",
"version": "v0.0.1",
"developer": "sheepdotcom",
"description": "Tweak the Geode UI a bit more.",
"settings": {
"transparent-lists": {
"name": "Transparent Lists",
"description": "Makes the mod list background transparent. Best used with geode theme enabled.",
"type": "bool",
"default": false
},
"larger-logos": {
"name": "Larger Logos",
"description": "Increases the size of the logos on mod items.",
"type": "bool",
"default": false
}
}
}
157 changes: 157 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#include "Geode/loader/Event.hpp"
#include "Geode/loader/Loader.hpp"
#include <Geode/Geode.hpp>
#include <Geode/ui/GeodeUI.hpp>
#include <Geode/loader/SettingV3.hpp>
#include <Geode/utils/ColorProvider.hpp>

using namespace geode::prelude;

CCNode* modsLayerReference = nullptr;

bool isGeodeTheme(bool forceDisableTheme = false) {
return !forceDisableTheme && Loader::get()->getInstalledMod("geode.loader")->getSettingValue<bool>("enable-geode-theme");
}

void modsLayerModify(CCNode* modsLayer) {
auto mod = Mod::get();
if (auto modListFrame = modsLayer->getChildByID("mod-list-frame")) {
if (auto modList = modListFrame->getChildByID("ModList")) {
auto searchMenu = modList->getChildByID("top-container")->getChildByID("search-menu");
auto searchBG = searchMenu->getChildByID("search-id");
auto frameBG = modListFrame->getChildByID("frame-bg");

if (!searchMenu->getChildByID("search-bg"_spr)) {
auto searchInput = searchMenu->getChildByID("search-input");
auto searchFiltersMenu = searchMenu->getChildByID("search-filters-menu");

auto someBG = CCLayerColor::create(ccColor4B{});
someBG->setPosition(searchMenu->getScaledContentSize() / 2);
someBG->ignoreAnchorPointForPosition(false);
someBG->setScale(0.7f);
someBG->setContentSize(ccp(350.f, 30.f) / someBG->getScale());
someBG->setColor(ccColor3B{0, 0, 0});
someBG->setOpacity(isGeodeTheme() ? 50 : 90);
someBG->setID("search-bg"_spr);

searchMenu->addChild(someBG);
}

auto someBG = searchMenu->getChildByID("search-bg"_spr);

frameBG->setVisible(!mod->getSettingValue<bool>("transparent-lists"));
searchBG->setVisible(!mod->getSettingValue<bool>("transparent-lists"));
someBG->setVisible(mod->getSettingValue<bool>("transparent-lists"));

if (auto scrollLayer = static_cast<ScrollLayer*>(modList->getChildByID("ScrollLayer"))) {
CCObject* obj;
CCARRAY_FOREACH(scrollLayer->m_contentLayer->getChildren(), obj) {
// should be mod items right
auto node = static_cast<CCNode*>(obj);
if (node->getID() == "ModItem") {
if (auto bg = static_cast<CCScale9Sprite*>(node->getChildByID("bg"))) {
if (mod->getSettingValue<bool>("transparent-lists")) {
if ((bg->getColor() == ccColor3B{255, 255, 255} && bg->getOpacity() == 25) || (bg->getColor() == ccColor3B{0, 0, 0} && bg->getOpacity() == 90)) { // Enabled
bg->setOpacity(isGeodeTheme() ? 50 : 90);
bg->setColor(ccColor3B{0, 0, 0});
}
else if (bg->getColor() == ccColor3B{153, 245, 245} && bg->getOpacity() == 25) { // Restart Required
bg->setOpacity(90);
bg->setColor(ccColor3B{245, 27, 27});
}
else if (bg->getColor() == ccColor3B{255, 255, 255} && bg->getOpacity() == 10) { // Disabled
bg->setOpacity(50);
bg->setColor(ccColor3B{205, 205, 205});
}
else if (bg->getColor() == ccColor3B{235, 35, 112} && bg->getOpacity() == 25) { // Error
bg->setOpacity(90);
bg->setColor(ccColor3B{245, 27, 27});
}
}
}
if (auto logoSprite = node->getChildByID("logo-sprite")) {
if (mod->getSettingValue<bool>("larger-logos") && (logoSprite->getScale() == 0.4f || logoSprite->getScale() == 0.6f)) {
logoSprite->setScale(logoSprite->getScale() == 0.6f ? 0.7f : 0.5f);
} else if (!mod->getSettingValue<bool>("larger-logos") && (logoSprite->getScale() == 0.5f || logoSprite->getScale() == 0.7f)) {
logoSprite->setScale(logoSprite->getScale() == 0.7f ? 0.6f : 0.4f);
}
}
}
}
}
}
}
}

#include <Geode/modify/CCLayer.hpp>

class ModsLayer : public CCNode {};

class $modify(CustomModsLayer, CCLayer) {
bool init() {
auto winSize = CCDirector::sharedDirector()->getWinSize();

if (!CCLayer::init()) return false;

if (auto modslayer = typeinfo_cast<ModsLayer*>(this)) {
queueInMainThread([this] {
modsLayerReference = this;
modsLayerModify(this);
});
}

return true;
}
};

#include <Geode/modify/CCDirector.hpp>

class $modify(CCDirector) {
bool replaceScene(CCScene* pScene) {
// No crash when ModsLayer no longer exists
if (CCDirector::sharedDirector()->getRunningScene()->getChildByID("ModsLayer")) {
if (modsLayerReference) {
modsLayerReference = nullptr;
}
}

return CCDirector::replaceScene(pScene);
}
};

#include <Geode/modify/CCScheduler.hpp>

class $modify(CCScheduler) {
void update(float dt) {
if (modsLayerReference) {
modsLayerModify(modsLayerReference);
}
CCScheduler::update(dt);
}
};

/*$execute {
new EventListener<EventFilter<ModItemUIEvent>>(+[](ModItemUIEvent* event) {
auto mod = Mod::get();
auto modItem = event->getItem();
if (auto bg = static_cast<CCScale9Sprite*>(modItem->querySelector("bg"))) {
if (mod->getSettingValue<bool>("transparent-lists")) {
if ((bg->getColor() == ccColor3B{255, 255, 255} && bg->getOpacity() == 25) || (bg->getColor() == ccColor3B{0, 0, 0} && bg->getOpacity() == 90)) {
bg->setOpacity(isGeodeTheme() ? 50 : 90);
bg->setColor(ccColor3B{0, 0, 0});
}
}
}
return ListenerResult::Propagate;
});
new EventListener<EventFilter<ModLogoUIEvent>>(+[](ModLogoUIEvent* event) {
auto logo = event->getSprite();
queueInMainThread([logo] {
auto mod = Mod::get();
if (mod->getSettingValue<bool>("larger-logos")) {
logo->setScale(0.5f);
}
});
return ListenerResult::Propagate;
});
}*/
1 change: 1 addition & 0 deletions support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Edit this file to change your mod's support info, or delete it if you don't need it.

0 comments on commit b4ff1c8

Please sign in to comment.