From f54cc1d9fb5aea6c5b81d1ef316ce5304267a456 Mon Sep 17 00:00:00 2001 From: The Bearodactyl Date: Fri, 7 Jun 2024 13:41:54 -0500 Subject: [PATCH] add some shit --- mod.json | 31 +++++- src/main.cpp | 126 +++++++++++++------------ src/settings/section.cpp | 7 ++ src/settings/section.hpp | 94 ++++++++++++++++++ src/trail_customization/trail_size.cpp | 19 ++++ 5 files changed, 216 insertions(+), 61 deletions(-) create mode 100644 src/settings/section.cpp create mode 100644 src/settings/section.hpp create mode 100644 src/trail_customization/trail_size.cpp diff --git a/mod.json b/mod.json index 9a6ef1a..a91ecd1 100644 --- a/mod.json +++ b/mod.json @@ -8,7 +8,7 @@ "id": "the_bearodactyl.gay-wave-trail", "name": "Gay Wave Trail", "developer": "The Bearodactyl", - "description": "make your wave trail a raging homosexual >:3", + "description": "make your wave trail (and kayla) a raging homosexual >:3", "settings": { "enable": { "name": "Enable the G A E", @@ -27,6 +27,28 @@ }, "description": "the speed of the alphabet mafia\nshould not be underestimated.\n(sets the speed at which the\nwave trail changes color)" }, + "wave-pulse-size": { + "name": "It's pulsing...", + "description": "the wave trail that is.", + "type": "float", + "default": 1, + "min": 0.05, + "max": 5, + "control": { + "slider-step": 0.05 + } + }, + "wave-trail-size": { + "name": "it even left a trail...", + "description": "that of which you can change the size...\noh my fucking sex,\nyou though i was talking about something else", + "type": "float", + "default": 1, + "min": 0.05, + "max": 5, + "control": { + "slider-step": 0.05 + } + }, "saturation": { "name": "HOW GAY ARE YOU???", "type": "float", @@ -56,6 +78,13 @@ "type": "bool", "default": true }, + "gaydient-section": { + "name": "Gaydient Settings", + "type": "custom", + "description": "make kayla gay", + "scale": 300, + "posX": 80 + }, "use-gradient": { "name": "Enable the GAYDIENT", "description": "now with 4 colors! full 256\ncolor rainbow NO MORE\n(enables the usage of\nthe below custom colors\ninstead of a vanilla rainbow)", diff --git a/src/main.cpp b/src/main.cpp index f7e7cfb..4bf4c2b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,10 +3,12 @@ #include #include #include -#include -#include #include +#include +#include "Geode/loader/ModEvent.hpp" +#include "Geode/modify/Modify.hpp" +#include "settings/section.hpp" #include "trail_customization/rainbow_trail.hpp" using namespace geode::prelude; @@ -14,78 +16,82 @@ using namespace cocos2d; float phase; -class $modify(PlayerObject) { - void flashPlayer(float p0, float p1, cocos2d::ccColor3B mainColor, cocos2d::ccColor3B secondColor) {} +struct MyPlayerObject : Modify { + void flashPlayer( float p0, float p1, cocos2d::ccColor3B mainColor, cocos2d::ccColor3B secondColor ) {} }; -class $modify(PlayLayer) { - void postUpdate(float p0) { - PlayLayer::postUpdate(p0); +struct MyPlayLayer : Modify { + void postUpdate( float p0 ) { + PlayLayer::postUpdate( p0 ); - float speed = Mod::get()->getSettingValue("speed"); - float saturation = Mod::get()->getSettingValue("saturation"); + float speed = Mod::get()->getSettingValue( "speed" ); + float saturation = Mod::get()->getSettingValue( "saturation" ); - bool mirror_players = Mod::get()->getSettingValue("mirror-players"); - bool use_gradient = Mod::get()->getSettingValue("use-gradient"); - bool enable = Mod::get()->getSettingValue("enable"); - bool noRegularTrail = Mod::get()->getSettingValue("no-reg-trail"); + bool mirror_players = Mod::get()->getSettingValue( "mirror-players" ); + bool use_gradient = Mod::get()->getSettingValue( "use-gradient" ); + bool enable = Mod::get()->getSettingValue( "enable" ); + bool noRegularTrail = Mod::get()->getSettingValue( "no-reg-trail" ); - auto color1 = Mod::get()->getSettingValue("color-one"); - auto color2 = Mod::get()->getSettingValue("color-two"); - auto color3 = Mod::get()->getSettingValue("color-three"); - auto color4 = Mod::get()->getSettingValue("color-four"); + auto color1 = Mod::get()->getSettingValue( "color-one" ); + auto color2 = Mod::get()->getSettingValue( "color-two" ); + auto color3 = Mod::get()->getSettingValue( "color-three" ); + auto color4 = Mod::get()->getSettingValue( "color-four" ); - if (ColorUtils::owo >= 360) { - ColorUtils::owo = 0; - } else { - ColorUtils::owo += speed / 10; - } + if ( ColorUtils::owo >= 360 ) { + ColorUtils::owo = 0; + } else { + ColorUtils::owo += speed / 10; + } + + phase = fmod( phase + speed, 360.f ); + bool p2 = true; - phase = fmod(phase + speed, 360.f); - bool p2 = true; + _ccColor3B rainbowColor = RainbowTrail::get_rainbow( 0, saturation ); + _ccColor3B rainbowColor2 = RainbowTrail::get_rainbow( 180, saturation ); - _ccColor3B rainbowColor = RainbowTrail::get_rainbow(0, saturation); - _ccColor3B rainbowColor2 = RainbowTrail::get_rainbow(180, saturation); + _ccColor3B gradientColor = RainbowTrail::get_gradient( phase, 0.0f, false, color1, color2, color3, color4 ); + _ccColor3B gradientColor2 = RainbowTrail::get_gradient( phase, 0.0f, false, color4, color3, color2, color1 ); - _ccColor3B gradientColor = RainbowTrail::get_gradient(phase, 0.0f, false, color1, color2, color3, color4); - _ccColor3B gradientColor2 = RainbowTrail::get_gradient(phase, 0.0f, false, color4, color3, color2, color1); + if ( m_player1->m_isDart && noRegularTrail ) { + m_player1->m_regularTrail + ->setVisible( false ); + } + + if ( m_player2->m_isDart && noRegularTrail ) { + m_player2->m_regularTrail + ->setVisible( false ); + } - if (m_player1->m_isDart && noRegularTrail) { - m_player1->m_regularTrail - ->setVisible(false); + if ( enable ) { + if ( ! use_gradient ) { + if ( m_player1->m_waveTrail ) { + m_player1->m_waveTrail + ->setColor( rainbowColor ); } - if (m_player2->m_isDart && noRegularTrail) { - m_player2->m_regularTrail - ->setVisible(false); + if ( m_player2->m_waveTrail ) { + m_player2->m_waveTrail + ->setColor( ! mirror_players + ? rainbowColor2 + : rainbowColor ); + } + } else { + if ( m_player1->m_waveTrail ) { + m_player1->m_waveTrail + ->setColor( gradientColor ); } - if (enable) { - if (!use_gradient) { - if (m_player1->m_waveTrail) { - m_player1->m_waveTrail - ->setColor(rainbowColor); - } - - if (m_player2->m_waveTrail) { - m_player2->m_waveTrail - ->setColor(!mirror_players - ? rainbowColor2 - : rainbowColor); - } - } else { - if (m_player1->m_waveTrail) { - m_player1->m_waveTrail - ->setColor(gradientColor); - } - - if (m_player2->m_waveTrail) { - m_player2->m_waveTrail - ->setColor(!mirror_players - ? gradientColor - : gradientColor2); - } - } + if ( m_player2->m_waveTrail ) { + m_player2->m_waveTrail + ->setColor( ! mirror_players + ? gradientColor + : gradientColor2 ); } + } } + } }; + +$on_mod( Loaded ) { + Mod::get()->addCustomSetting( "gaydient-section", "none" ); +} diff --git a/src/settings/section.cpp b/src/settings/section.cpp new file mode 100644 index 0000000..59898b2 --- /dev/null +++ b/src/settings/section.cpp @@ -0,0 +1,7 @@ +#include "section.hpp" +#include +#include + +SettingNode *SettingSectionValue::createNode( float width ) { + return SettingSectionNode::create( this, width ); +} diff --git a/src/settings/section.hpp b/src/settings/section.hpp new file mode 100644 index 0000000..02b733b --- /dev/null +++ b/src/settings/section.hpp @@ -0,0 +1,94 @@ +#pragma once +#include + +using namespace geode::prelude; + +class SettingSectionValue; + +class SettingSectionValue : public SettingValue { +protected: + std::string m_placeholder; + +public: + SettingSectionValue( std::string const &key, std::string const &modID, std::string const &placeholder ) + : SettingValue( key, modID ), m_placeholder( placeholder ) {} + + bool load( matjson::Value const &json ) override { + return true; + } + bool save( matjson::Value &json ) const override { + return true; + } + SettingNode *createNode( float width ) override; +}; + +class SettingSectionNode : public SettingNode { +protected: + bool init( SettingSectionValue *value, float width ) { + if ( ! SettingNode::init( value ) ) + return false; + this->setContentSize( { width, 40.f } ); + auto menu = CCMenu::create(); + std::string sectionName = Mod::get()->getSettingDefinition( value->getKey() )->get()->json->get( "name" ); + auto infoSpr = CCSprite::createWithSpriteFrameName( "GJ_infoIcon_001.png" ); + infoSpr->setScale( .7F ); + //auto infoBtn + auto infoBtn = CCMenuItemSpriteExtra::create( + infoSpr, + this, + menu_selector( SettingSectionNode::onInfoBtn ) ); + infoBtn->setID( value->getKey() ); + infoBtn->setPositionX( Mod::get()->getSettingDefinition( value->getKey() )->get()->json->get( "posX" ) ); + auto label = CCLabelBMFont::create( sectionName.c_str(), "goldFont.fnt" ); + + label->setScale( .6F ); + menu->setPosition( width / 2, 23.f ); + menu->addChild( label ); + menu->addChild( infoBtn ); + this->addChild( menu ); + return true; + } + + void onInfoBtn( CCObject *sender ) { + // i dont want to deal with template hell + auto node = reinterpret_cast( sender ); + if ( node == nullptr ) return; + FLAlertLayer::create( nullptr, + Mod::get()->getSettingDefinition( node->getID() )->get()->json->get( "name" ).c_str(), + Mod::get()->getSettingDefinition( node->getID() )->get()->json->get( "description" ).c_str(), + "OK", + nullptr, + Mod::get()->getSettingDefinition( node->getID() )->get()->json->get( "scale" ) ) + ->show(); + } + +public: + void commit() override { + // Let the UI know you have committed the value + this->dispatchCommitted(); + } + + // Geode calls this to query if the setting value has been changed, + // and those changes haven't been committed + bool hasUncommittedChanges() override { + return false; + } + + // Geode calls this to query if the setting has a value that is + // different from its default value + bool hasNonDefaultValue() override { + return true; + } + + void resetToDefault() override { + } + static SettingSectionNode *create( SettingSectionValue *value, float width ) { + auto ret = new SettingSectionNode; + if ( ret && ret->init( value, width ) ) { + ret->autorelease(); + return ret; + } + CC_SAFE_DELETE( ret ); + return nullptr; + } +}; diff --git a/src/trail_customization/trail_size.cpp b/src/trail_customization/trail_size.cpp new file mode 100644 index 0000000..9cc101b --- /dev/null +++ b/src/trail_customization/trail_size.cpp @@ -0,0 +1,19 @@ +#include "Geode/modify/Modify.hpp" +#include +#include + +using namespace geode::prelude; + +struct TrailPulseSize : Modify { + void postUpdate( float p0 ) { + PlayLayer::postUpdate( p0 ); + + float pulse_size = Mod::get()->getSettingValue( "wave-pulse-size" ); + float trail_size = Mod::get()->getSettingValue( "wave-trail-size" ); + + this->m_player1->m_waveTrail->m_pulseSize = pulse_size; + this->m_player1->m_waveTrail->m_waveSize = trail_size; + this->m_player2->m_waveTrail->m_pulseSize = pulse_size; + this->m_player2->m_waveTrail->m_waveSize = trail_size; + } +};