mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-27 17:02:55 -04:00
71961dae85
* feat: Status Lighting option * wip: rename to "Enable Controller LED" * wip: setting for all four ports individually * wip: fix detection + code cleanup * wip: increase led speed for dusk preset * wip: use aurora API * bump aurora to 2b07d55 * wip: remove isSupported + fix namespace comment * wip: add value override to BoolButton * Style nit & remove unused * Undo change --------- Co-authored-by: Luke Street <luke@street.dev>
52 lines
1.4 KiB
C++
52 lines
1.4 KiB
C++
#include "bool_button.hpp"
|
|
|
|
#include "Z2AudioLib/Z2SeMgr.h"
|
|
#include "m_Do/m_Do_audio.h"
|
|
|
|
namespace dusk::ui {
|
|
|
|
BoolButton::BoolButton(Rml::Element* parent, Props props)
|
|
: BaseControlledSelectButton(parent,
|
|
{
|
|
.key = std::move(props.key),
|
|
.icon = std::move(props.icon),
|
|
}),
|
|
mGetValue(std::move(props.getValue)), mSetValue(std::move(props.setValue)),
|
|
mIsDisabled(std::move(props.isDisabled)), mIsModified(std::move(props.isModified)),
|
|
mValueOverride(std::move(props.valueOverride)) {}
|
|
|
|
bool BoolButton::modified() const {
|
|
if (mIsModified) {
|
|
return mIsModified();
|
|
}
|
|
return BaseControlledSelectButton::modified();
|
|
}
|
|
|
|
bool BoolButton::disabled() const {
|
|
if (mIsDisabled) {
|
|
return mIsDisabled();
|
|
}
|
|
return BaseControlledSelectButton::disabled();
|
|
}
|
|
|
|
Rml::String BoolButton::format_value() {
|
|
if (mValueOverride) {
|
|
if (std::string value = mValueOverride(); !value.empty()) {
|
|
return value;
|
|
}
|
|
}
|
|
|
|
return mGetValue() ? "On" : "Off";
|
|
}
|
|
|
|
bool BoolButton::handle_nav_command(NavCommand cmd) {
|
|
if (cmd == NavCommand::Confirm || cmd == NavCommand::Left || cmd == NavCommand::Right) {
|
|
const bool newValue = !mGetValue();
|
|
mSetValue(newValue);
|
|
mDoAud_seStartMenu(newValue ? kSoundItemEnable : kSoundItemDisable);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
} // namespace dusk::ui
|