-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c417363
commit f54cc1d
Showing
5 changed files
with
216 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "section.hpp" | ||
#include <Geode/loader/Dirs.hpp> | ||
#include <filesystem> | ||
|
||
SettingNode *SettingSectionValue::createNode( float width ) { | ||
return SettingSectionNode::create( this, width ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#pragma once | ||
#include <Geode/loader/SettingNode.hpp> | ||
|
||
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<CustomSetting>()->json->get<std::string>( "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<CustomSetting>()->json->get<int>( "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<CCMenuItemSpriteExtra *>( sender ); | ||
if ( node == nullptr ) return; | ||
FLAlertLayer::create( nullptr, | ||
Mod::get()->getSettingDefinition( node->getID() )->get<CustomSetting>()->json->get<std::string>( "name" ).c_str(), | ||
Mod::get()->getSettingDefinition( node->getID() )->get<CustomSetting>()->json->get<std::string>( "description" ).c_str(), | ||
"OK", | ||
nullptr, | ||
Mod::get()->getSettingDefinition( node->getID() )->get<CustomSetting>()->json->get<int>( "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; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "Geode/modify/Modify.hpp" | ||
#include <Geode/Geode.hpp> | ||
#include <Geode/modify/PlayLayer.hpp> | ||
|
||
using namespace geode::prelude; | ||
|
||
struct TrailPulseSize : Modify<TrailPulseSize, PlayLayer> { | ||
void postUpdate( float p0 ) { | ||
PlayLayer::postUpdate( p0 ); | ||
|
||
float pulse_size = Mod::get()->getSettingValue<double>( "wave-pulse-size" ); | ||
float trail_size = Mod::get()->getSettingValue<double>( "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; | ||
} | ||
}; |