mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-22 20:59:16 +01:00
Only show active plugins in config menu
This commit is contained in:
parent
68eee522de
commit
9c8177405e
@ -1,7 +1,7 @@
|
|||||||
#include "ConfigRenderer.h"
|
#include "ConfigRenderer.h"
|
||||||
|
|
||||||
void ConfigRenderer::RenderStateMain() const {
|
void ConfigRenderer::RenderStateMain() const {
|
||||||
auto totalElementSize = (int32_t) mConfigs.size();
|
auto totalElementSize = (int32_t) mActiveConfigs.size();
|
||||||
// Calculate the range of items to display
|
// Calculate the range of items to display
|
||||||
int start = std::max(0, mRenderOffset);
|
int start = std::max(0, mRenderOffset);
|
||||||
int end = std::min(start + MAX_BUTTONS_ON_SCREEN, totalElementSize);
|
int end = std::min(start + MAX_BUTTONS_ON_SCREEN, totalElementSize);
|
||||||
@ -11,7 +11,7 @@ void ConfigRenderer::RenderStateMain() const {
|
|||||||
|
|
||||||
uint32_t yOffset = 8 + 24 + 8 + 4;
|
uint32_t yOffset = 8 + 24 + 8 + 4;
|
||||||
for (int32_t i = start; i < end; i++) {
|
for (int32_t i = start; i < end; i++) {
|
||||||
drawConfigEntry(yOffset, mConfigs[i].getConfigInformation(), i == mCursorPos);
|
drawConfigEntry(yOffset, mActiveConfigs[i].get().getConfigInformation(), i == mCursorPos);
|
||||||
yOffset += 42 + 8;
|
yOffset += 42 + 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,21 +65,23 @@ void ConfigRenderer::drawConfigEntry(uint32_t yOffset, const GeneralConfigInform
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConfigSubState ConfigRenderer::UpdateStateMain(const Input &input) {
|
ConfigSubState ConfigRenderer::UpdateStateMain(const Input &input) {
|
||||||
if (mConfigs.empty()) {
|
if (mActiveConfigs.empty()) {
|
||||||
mNeedRedraw = true;
|
mNeedRedraw = true;
|
||||||
return SUB_STATE_ERROR;
|
return SUB_STATE_ERROR;
|
||||||
}
|
}
|
||||||
auto prevSelectedItem = mCursorPos;
|
auto prevSelectedItem = mCursorPos;
|
||||||
|
|
||||||
auto totalElementSize = mConfigs.size();
|
auto totalElementSize = mActiveConfigs.size();
|
||||||
if (input.data.buttons_d & Input::eButtons::BUTTON_DOWN) {
|
if (input.data.buttons_d & Input::eButtons::BUTTON_DOWN) {
|
||||||
mCursorPos++;
|
mCursorPos++;
|
||||||
} else if (input.data.buttons_d & Input::eButtons::BUTTON_UP) {
|
} else if (input.data.buttons_d & Input::eButtons::BUTTON_UP) {
|
||||||
mCursorPos--;
|
mCursorPos--;
|
||||||
|
} else if (input.data.buttons_d & Input::eButtons::BUTTON_X) {
|
||||||
|
mSetActivePluginsMode = !mSetActivePluginsMode;
|
||||||
} else if (input.data.buttons_d & Input::eButtons::BUTTON_A) {
|
} else if (input.data.buttons_d & Input::eButtons::BUTTON_A) {
|
||||||
if (mCursorPos != mCurrentOpen) {
|
if (mCursorPos != mCurrentOpen) {
|
||||||
mCategoryRenderer.reset();
|
mCategoryRenderer.reset();
|
||||||
mCategoryRenderer = make_unique_nothrow<CategoryRenderer>(&(mConfigs[mCursorPos].getConfigInformation()), &(mConfigs[mCursorPos].getConfig()), true);
|
mCategoryRenderer = make_unique_nothrow<CategoryRenderer>(&(mActiveConfigs[mCursorPos].get().getConfigInformation()), &(mActiveConfigs[mCursorPos].get().getConfig()), true);
|
||||||
}
|
}
|
||||||
mNeedRedraw = true;
|
mNeedRedraw = true;
|
||||||
mCurrentOpen = mCursorPos;
|
mCurrentOpen = mCursorPos;
|
||||||
@ -88,8 +90,8 @@ ConfigSubState ConfigRenderer::UpdateStateMain(const Input &input) {
|
|||||||
} else if (input.data.buttons_d & (Input::eButtons::BUTTON_B | Input::eButtons::BUTTON_HOME)) {
|
} else if (input.data.buttons_d & (Input::eButtons::BUTTON_B | Input::eButtons::BUTTON_HOME)) {
|
||||||
mNeedRedraw = true;
|
mNeedRedraw = true;
|
||||||
mCategoryRenderer.reset();
|
mCategoryRenderer.reset();
|
||||||
for (const auto &element : mConfigs) {
|
for (const auto &element : mActiveConfigs) {
|
||||||
CallOnCloseCallback(element.getConfigInformation(), element.getConfig());
|
CallOnCloseCallback(element.get().getConfigInformation(), element.get().getConfig());
|
||||||
}
|
}
|
||||||
return SUB_STATE_RETURN;
|
return SUB_STATE_RETURN;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,13 @@ class ConfigRenderer {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ConfigRenderer(std::vector<ConfigDisplayItem> &&vec) : mConfigs(std::move(vec)) {
|
explicit ConfigRenderer(std::vector<ConfigDisplayItem> &&vec) : mConfigs(std::move(vec)) {
|
||||||
|
std::copy_if(mConfigs.begin(), mConfigs.end(),
|
||||||
|
std::back_inserter(mActiveConfigs),
|
||||||
|
[&](const auto & value) {
|
||||||
|
return value.isActivePlugin();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
~ConfigRenderer() = default;
|
~ConfigRenderer() = default;
|
||||||
|
|
||||||
ConfigSubState Update(Input &input, const WUPSConfigSimplePadData &simpleInputData, const WUPSConfigComplexPadData &complexInputData);
|
ConfigSubState Update(Input &input, const WUPSConfigSimplePadData &simpleInputData, const WUPSConfigComplexPadData &complexInputData);
|
||||||
@ -35,6 +41,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::vector<ConfigDisplayItem> mConfigs;
|
std::vector<ConfigDisplayItem> mConfigs;
|
||||||
|
std::vector<std::reference_wrapper<ConfigDisplayItem>> mActiveConfigs;
|
||||||
std::unique_ptr<CategoryRenderer> mCategoryRenderer = {};
|
std::unique_ptr<CategoryRenderer> mCategoryRenderer = {};
|
||||||
|
|
||||||
State mState = STATE_MAIN;
|
State mState = STATE_MAIN;
|
||||||
|
Loading…
Reference in New Issue
Block a user