2023-12-16 17:36:57 +01:00
|
|
|
#pragma once
|
|
|
|
#include "ConfigRendererItemGeneric.h"
|
|
|
|
#include "config/WUPSConfigItem.h"
|
|
|
|
|
|
|
|
class ConfigRendererItem : public ConfigRendererItemGeneric {
|
|
|
|
public:
|
|
|
|
explicit ConfigRendererItem(const WUPSConfigAPIBackend::WUPSConfigItem *item) : mItem(item) {
|
|
|
|
assert(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Draw(uint32_t yOffset, bool isHighlighted) const override {
|
|
|
|
assert(mItem);
|
|
|
|
drawGenericBoxAndText(yOffset, mItem->getDisplayName(), isHighlighted);
|
|
|
|
DrawUtils::setFontSize(24);
|
2024-05-03 11:55:27 +02:00
|
|
|
DrawUtils::print(SCREEN_WIDTH - 16 * 2, yOffset + 8 + 24, mCurItemText.c_str(), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string GetValueToPrint(bool isHighlighted) {
|
|
|
|
return isHighlighted ? mItem->getCurrentValueSelectedDisplay() : mItem->getCurrentValueDisplay();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Update(bool isHighlighted) override {
|
|
|
|
const auto newText = GetValueToPrint(isHighlighted);
|
|
|
|
|
|
|
|
if (mCurItemText != newText) {
|
|
|
|
mNeedsDraw = true;
|
2023-12-16 17:36:57 +01:00
|
|
|
}
|
2024-05-03 11:55:27 +02:00
|
|
|
mCurItemText = newText;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResetNeedsRedraw() override {
|
|
|
|
mNeedsDraw = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] bool NeedsRedraw() const override {
|
|
|
|
return mNeedsDraw;
|
2023-12-16 17:36:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetIsSelected(bool isSelected) override {
|
|
|
|
mItem->onSelected(isSelected);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnButtonPressed(WUPSConfigButtons buttons) override {
|
|
|
|
mItem->onButtonPressed(buttons);
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] bool IsMovementAllowed() const override {
|
|
|
|
return mItem->isMovementAllowed();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnInput(WUPSConfigSimplePadData input) override {
|
|
|
|
mItem->onInput(input);
|
|
|
|
}
|
|
|
|
void OnInputEx(WUPSConfigComplexPadData input) override {
|
|
|
|
mItem->onInputEx(input);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const WUPSConfigAPIBackend::WUPSConfigItem *mItem;
|
2024-05-03 11:55:27 +02:00
|
|
|
std::string mCurItemText;
|
|
|
|
bool mNeedsDraw = true;
|
2023-12-16 17:36:57 +01:00
|
|
|
};
|