mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2024-11-20 00:46:34 +00:00
help-related fixes
This commit is contained in:
parent
257c122b63
commit
766d6e546c
2 changed files with 56 additions and 16 deletions
|
@ -3,6 +3,7 @@
|
|||
#include <list>
|
||||
#include <cstdint>
|
||||
#include <tesla.hpp>
|
||||
#include "gui_help.hpp"
|
||||
#include "gui_sublist.hpp"
|
||||
#include "cpp_utils.hpp"
|
||||
|
||||
|
@ -93,12 +94,14 @@ public:
|
|||
using FlagType = detail::FlagTypeT<T>;
|
||||
|
||||
private:
|
||||
T m_mask;
|
||||
FlagType* m_value;
|
||||
T m_mask;
|
||||
FlagType* m_value;
|
||||
std::string m_name;
|
||||
std::string m_help;
|
||||
|
||||
public:
|
||||
BitFlagToggleListItem(const std::string& text, T mask, FlagType* value)
|
||||
: tsl::elm::ToggleListItem(text, (mask & *value) != 0, "\uE14B", "\uE14C"), m_mask(mask), m_value(value)
|
||||
BitFlagToggleListItem(const std::string& text, T mask, FlagType* value, std::string name = "", std::string help = "")
|
||||
: tsl::elm::ToggleListItem(text, (mask & *value) != 0, "\uE14B", "\uE14C"), m_mask(mask), m_value(value), m_name(name), m_help(help)
|
||||
{
|
||||
setStateChangedListener([this](bool v) {
|
||||
if(v)
|
||||
|
@ -120,7 +123,11 @@ public:
|
|||
return ListItem::onClick(keys);
|
||||
}
|
||||
else if(keys & KEY_Y)
|
||||
{}
|
||||
{
|
||||
if (m_help != "") {
|
||||
tsl::changeTo<GuiHelp>(m_name, m_help);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
virtual void setState(bool state) override
|
||||
|
@ -140,13 +147,17 @@ class SetToggleListItem : public tsl::elm::ListItem
|
|||
{
|
||||
std::vector<tsl::elm::ToggleListItem*> m_itemsOn;
|
||||
std::vector<tsl::elm::ToggleListItem*> m_itemsOff;
|
||||
std::string m_name;
|
||||
std::string m_help;
|
||||
|
||||
public:
|
||||
SetToggleListItem(std::vector<tsl::elm::ToggleListItem*> itemsOn,
|
||||
std::vector<tsl::elm::ToggleListItem*> itemsOff,
|
||||
const std::string& text,
|
||||
const std::string& value = "")
|
||||
: tsl::elm::ListItem(text, value), m_itemsOn(std::move(itemsOn)), m_itemsOff(std::move(itemsOff))
|
||||
const std::string name = "",
|
||||
const std::string help = "",
|
||||
const std::string& value = "")
|
||||
: tsl::elm::ListItem(text, value), m_itemsOn(std::move(itemsOn)), m_itemsOff(std::move(itemsOff)), m_name(name), m_help(help)
|
||||
{
|
||||
setClickListener([this](u64 keys) -> bool {
|
||||
if(keys & KEY_A)
|
||||
|
@ -161,6 +172,12 @@ public:
|
|||
}
|
||||
return true;
|
||||
}
|
||||
else if(keys & KEY_Y)
|
||||
{
|
||||
if (m_help != "") {
|
||||
tsl::changeTo<GuiHelp>(m_name, m_help);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ static struct TrainingModpackMenu
|
|||
DefensiveFlags DEFENSIVE_STATE = DefensiveFlags::All;
|
||||
DelayFlags OOS_OFFSET = DelayFlags::None;
|
||||
DelayFlags REACTION_TIME = DelayFlags::None;
|
||||
OnOffFlags MASH_IN_NEUTRAL = OnOffFlags::None;
|
||||
OnOffFlags MASH_IN_NEUTRAL = OnOffFlag::Off;
|
||||
BoolFlags FAST_FALL = BoolFlags::None;
|
||||
DelayFlags FAST_FALL_DELAY = DelayFlags::None;
|
||||
BoolFlags FALLING_AERIALS = BoolFlags::None;
|
||||
|
@ -271,6 +271,29 @@ public:
|
|||
FsFileSystem m_fs;
|
||||
};
|
||||
|
||||
class OverlayFrameWithHelp : public tsl::elm::OverlayFrame
|
||||
{
|
||||
public:
|
||||
OverlayFrameWithHelp(const std::string& title, const std::string& subtitle) : tsl::elm::OverlayFrame(title, subtitle)
|
||||
{}
|
||||
|
||||
virtual void draw(tsl::gfx::Renderer* renderer) override
|
||||
{
|
||||
renderer->fillScreen(a(tsl::style::color::ColorFrameBackground));
|
||||
renderer->drawRect(tsl::cfg::FramebufferWidth - 1, 0, 1, tsl::cfg::FramebufferHeight, a(0xF222));
|
||||
|
||||
renderer->drawString(this->m_title.c_str(), false, 20, 50, 30, a(tsl::style::color::ColorText));
|
||||
renderer->drawString(this->m_subtitle.c_str(), false, 20, 70, 15, a(tsl::style::color::ColorDescription));
|
||||
|
||||
renderer->drawRect(15, tsl::cfg::FramebufferHeight - 73, tsl::cfg::FramebufferWidth - 30, 1, a(tsl::style::color::ColorText));
|
||||
|
||||
renderer->drawString("\uE0E1 Back \uE0E0 OK \uE0E3 Help", false, 30, 693, 23, a(tsl::style::color::ColorText));
|
||||
|
||||
if (this->m_contentElement != nullptr)
|
||||
this->m_contentElement->frame(renderer);
|
||||
}
|
||||
};
|
||||
|
||||
namespace
|
||||
{
|
||||
template<typename T> tsl::elm::ListItem* createBitFlagOption(T* option, const std::string& name, const std::string& help, GuiMain* guiMain)
|
||||
|
@ -281,16 +304,16 @@ template<typename T> tsl::elm::ListItem* createBitFlagOption(T* option, const st
|
|||
item->setClickListener([name, help, option, guiMain](u64 keys) -> bool {
|
||||
if(keys & KEY_A)
|
||||
{
|
||||
tsl::changeTo<GuiLambda>([option, name]() -> tsl::elm::Element* {
|
||||
tsl::changeTo<GuiLambda>([option, name, help]() -> tsl::elm::Element* {
|
||||
auto toggleList = new tsl::elm::List();
|
||||
std::vector<tsl::elm::ToggleListItem*> items;
|
||||
for(auto& [flag, str] : detail::EnumArray<FlagType>::values)
|
||||
{
|
||||
items.emplace_back(new BitFlagToggleListItem<FlagType>(str, flag, option));
|
||||
items.emplace_back(new BitFlagToggleListItem<FlagType>(str, flag, option, name, help));
|
||||
}
|
||||
|
||||
auto allOff = new SetToggleListItem({}, items, "None");
|
||||
auto allOn = new SetToggleListItem(items, {}, "All");
|
||||
auto allOff = new SetToggleListItem({}, items, "None", name, help);
|
||||
auto allOn = new SetToggleListItem(items, {}, "All", name, help);
|
||||
|
||||
toggleList->addItem(allOn);
|
||||
toggleList->addItem(allOff);
|
||||
|
@ -300,7 +323,7 @@ template<typename T> tsl::elm::ListItem* createBitFlagOption(T* option, const st
|
|||
toggleList->addItem(it);
|
||||
}
|
||||
|
||||
auto frame = new tsl::elm::OverlayFrame(name, "");
|
||||
auto frame = new OverlayFrameWithHelp(name, "Press \uE0E3 for help with these options.");
|
||||
frame->setContent(toggleList);
|
||||
return frame;
|
||||
}, guiMain);
|
||||
|
@ -320,7 +343,7 @@ tsl::elm::Element* GuiMain::createUI()
|
|||
{
|
||||
char buffer[256];
|
||||
snprintf(buffer, 256, "Version %s", VERSION);
|
||||
tsl::elm::OverlayFrame* rootFrame = new tsl::elm::OverlayFrame("Training Modpack", buffer);
|
||||
OverlayFrameWithHelp* rootFrame = new OverlayFrameWithHelp("Training Modpack", buffer);
|
||||
|
||||
auto list = new tsl::elm::List();
|
||||
|
||||
|
@ -372,7 +395,7 @@ tsl::elm::Element* GuiMain::createUI()
|
|||
|
||||
list->addItem(createBitFlagOption(&menu.MASH_STATE, "Mash Toggles", mash_help, this));
|
||||
list->addItem(createBitFlagOption(&menu.FOLLOW_UP, "Followup Toggles", follow_up_help, this));
|
||||
list->addItem(new BitFlagToggleListItem<OnOffFlags::Type>("Mash In Neutral", OnOffFlag::On, &menu.MASH_IN_NEUTRAL));
|
||||
list->addItem(new BitFlagToggleListItem<OnOffFlags::Type>("Mash In Neutral", OnOffFlag::On, &menu.MASH_IN_NEUTRAL, "Mash In Neutral", mash_neutral_help));
|
||||
|
||||
list->addItem(new tsl::elm::CategoryHeader("Left Stick", true));
|
||||
|
||||
|
@ -422,7 +445,7 @@ tsl::elm::Element* GuiMain::createUI()
|
|||
|
||||
list->addItem(new tsl::elm::CategoryHeader("Miscellaneous", true));
|
||||
|
||||
list->addItem(new BitFlagToggleListItem<OnOffFlags::Type>("Hitbox Visualization", OnOffFlag::On, &menu.HITBOX_VIS));
|
||||
list->addItem(new BitFlagToggleListItem<OnOffFlags::Type>("Hitbox Visualization", OnOffFlag::On, &menu.HITBOX_VIS, "Hitbox Visualization", hitbox_help));
|
||||
|
||||
ClickableListItem* saveStateItem = new ClickableListItem(
|
||||
"Save States", empty_items, nullptr, "saveStates", 0, "Save States", save_states_help);
|
||||
|
|
Loading…
Reference in a new issue