hocclk: format code
use clang format file provided for optimal formatting
This commit is contained in:
@@ -12,9 +12,9 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
@@ -28,53 +28,29 @@
|
||||
#include "base_menu_gui.h"
|
||||
#include "freq_choice_gui.h"
|
||||
#include "value_choice_gui.h"
|
||||
class AppProfileGui : public BaseMenuGui
|
||||
{
|
||||
class AppProfileGui : public BaseMenuGui {
|
||||
protected:
|
||||
std::uint64_t applicationId;
|
||||
HocClkTitleProfileList* profileList;
|
||||
void openFreqChoiceGui(tsl::elm::ListItem* listItem, HocClkProfile profile, HocClkModule module);
|
||||
void addModuleListItem(HocClkProfile profile, HocClkModule module);
|
||||
void addModuleListItemToggle(HocClkProfile profile, HocClkModule module);
|
||||
void openValueChoiceGui(
|
||||
tsl::elm::ListItem* listItem,
|
||||
std::uint32_t currentValue,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
ValueChoiceListener listener,
|
||||
const ValueThresholds& thresholds = ValueThresholds(),
|
||||
bool enableThresholds = false,
|
||||
const std::map<std::uint32_t, std::string>& labels = {},
|
||||
const std::vector<NamedValue>& namedValues = {},
|
||||
bool showDefaultValue = true
|
||||
);
|
||||
std::string formatValueDisplay(
|
||||
std::uint32_t value,
|
||||
const std::vector<NamedValue>& namedValues,
|
||||
const std::string& suffix,
|
||||
std::uint32_t divisor,
|
||||
int decimalPlaces
|
||||
);
|
||||
void addModuleListItemValue(
|
||||
HocClkProfile profile,
|
||||
HocClkModule module,
|
||||
const std::string& categoryName,
|
||||
std::uint32_t min,
|
||||
std::uint32_t max,
|
||||
std::uint32_t step,
|
||||
const std::string& suffix,
|
||||
std::uint32_t divisor,
|
||||
int decimalPlaces,
|
||||
ValueThresholds thresholds,
|
||||
std::vector<NamedValue> namedValues = {},
|
||||
bool showDefaultValue = true
|
||||
);
|
||||
void addGovernorSection(HocClkProfile profile);
|
||||
void addProfileUI(HocClkProfile profile);
|
||||
std::uint64_t applicationId;
|
||||
HocClkTitleProfileList *profileList;
|
||||
void openFreqChoiceGui(tsl::elm::ListItem *listItem, HocClkProfile profile, HocClkModule module);
|
||||
void addModuleListItem(HocClkProfile profile, HocClkModule module);
|
||||
void addModuleListItemToggle(HocClkProfile profile, HocClkModule module);
|
||||
void openValueChoiceGui(tsl::elm::ListItem *listItem, std::uint32_t currentValue, const ValueRange &range, const std::string &categoryName,
|
||||
ValueChoiceListener listener, const ValueThresholds &thresholds = ValueThresholds(), bool enableThresholds = false,
|
||||
const std::map<std::uint32_t, std::string> &labels = {}, const std::vector<NamedValue> &namedValues = {},
|
||||
bool showDefaultValue = true);
|
||||
std::string formatValueDisplay(std::uint32_t value, const std::vector<NamedValue> &namedValues, const std::string &suffix, std::uint32_t divisor,
|
||||
int decimalPlaces);
|
||||
void addModuleListItemValue(HocClkProfile profile, HocClkModule module, const std::string &categoryName, std::uint32_t min, std::uint32_t max,
|
||||
std::uint32_t step, const std::string &suffix, std::uint32_t divisor, int decimalPlaces, ValueThresholds thresholds,
|
||||
std::vector<NamedValue> namedValues = {}, bool showDefaultValue = true);
|
||||
void addGovernorSection(HocClkProfile profile);
|
||||
void addProfileUI(HocClkProfile profile);
|
||||
|
||||
public:
|
||||
AppProfileGui(std::uint64_t applicationId, HocClkTitleProfileList* profileList);
|
||||
~AppProfileGui();
|
||||
void listUI() override;
|
||||
static void changeTo(std::uint64_t applicationId);
|
||||
void update() override;
|
||||
AppProfileGui(std::uint64_t applicationId, HocClkTitleProfileList *profileList);
|
||||
~AppProfileGui();
|
||||
void listUI() override;
|
||||
static void changeTo(std::uint64_t applicationId);
|
||||
void update() override;
|
||||
};
|
||||
@@ -12,7 +12,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
@@ -24,16 +24,18 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "base_gui.h"
|
||||
#include "../elements/base_frame.h"
|
||||
#include "base_gui.h"
|
||||
|
||||
void BaseFrame::draw(tsl::gfx::Renderer* renderer) {
|
||||
|
||||
void BaseFrame::draw(tsl::gfx::Renderer *renderer) {
|
||||
tsl::elm::HeaderOverlayFrame::draw(renderer);
|
||||
this->gui->preDraw(renderer);
|
||||
}
|
||||
|
||||
#include <tesla.hpp>
|
||||
#include <math.h>
|
||||
#include <tesla.hpp>
|
||||
|
||||
|
||||
#define LOGO_Y_REAL 65
|
||||
|
||||
@@ -53,8 +55,8 @@ void BaseFrame::draw(tsl::gfx::Renderer* renderer) {
|
||||
#define VERSION_FONT_SIZE 15
|
||||
|
||||
extern "C" {
|
||||
extern const u8 hoc_rgba[];
|
||||
extern const u32 hoc_rgba_size;
|
||||
extern const u8 hoc_rgba[];
|
||||
extern const u32 hoc_rgba_size;
|
||||
}
|
||||
|
||||
std::string getVersionString() {
|
||||
@@ -66,19 +68,13 @@ std::string getVersionString() {
|
||||
return std::string(buf);
|
||||
}
|
||||
|
||||
static constexpr tsl::Color dynamicLogoRGB1 = tsl::Color( 7, 15, 15, 15);
|
||||
static constexpr tsl::Color dynamicLogoRGB2 = tsl::Color( 2, 8, 11, 15);
|
||||
static constexpr tsl::Color STATIC_TEAL = tsl::Color( 7, 15, 15, 15);
|
||||
static constexpr tsl::Color dynamicLogoRGB1 = tsl::Color(7, 15, 15, 15);
|
||||
static constexpr tsl::Color dynamicLogoRGB2 = tsl::Color(2, 8, 11, 15);
|
||||
static constexpr tsl::Color STATIC_TEAL = tsl::Color(7, 15, 15, 15);
|
||||
const std::string name = " Horizon OC";
|
||||
|
||||
static s32 drawDynamicUltraText(
|
||||
tsl::gfx::Renderer* renderer,
|
||||
s32 startX,
|
||||
s32 y,
|
||||
u32 fontSize,
|
||||
const tsl::Color& staticColor,
|
||||
bool useNotificationMethod = false)
|
||||
{
|
||||
static s32 drawDynamicUltraText(tsl::gfx::Renderer *renderer, s32 startX, s32 y, u32 fontSize, const tsl::Color &staticColor,
|
||||
bool useNotificationMethod = false) {
|
||||
static constexpr double cycleDuration = 1.6;
|
||||
|
||||
s32 currentX = startX;
|
||||
@@ -88,10 +84,10 @@ static s32 drawDynamicUltraText(
|
||||
|
||||
const double waveScale = 2.0 * M_PI / cycleDuration;
|
||||
|
||||
for (size_t i = 0; i < name.size(); i++)
|
||||
{
|
||||
for (size_t i = 0; i < name.size(); i++) {
|
||||
char letter = name[i];
|
||||
if (letter == '\0') break;
|
||||
if (letter == '\0')
|
||||
break;
|
||||
|
||||
double phase = waveScale * (timeNow + i * 0.12);
|
||||
|
||||
@@ -103,15 +99,9 @@ static s32 drawDynamicUltraText(
|
||||
double glow = (cos(phase * 1.5) + 1.0) * 0.5;
|
||||
double brightness = 0.75 + glow * 0.25;
|
||||
|
||||
u8 r = static_cast<u8>(
|
||||
((int)dynamicLogoRGB1.r + ((int)dynamicLogoRGB2.r - (int)dynamicLogoRGB1.r) * blend) * brightness
|
||||
);
|
||||
u8 g = static_cast<u8>(
|
||||
((int)dynamicLogoRGB1.g + ((int)dynamicLogoRGB2.g - (int)dynamicLogoRGB1.g) * blend) * brightness
|
||||
);
|
||||
u8 b = static_cast<u8>(
|
||||
((int)dynamicLogoRGB1.b + ((int)dynamicLogoRGB2.b - (int)dynamicLogoRGB1.b) * blend) * brightness
|
||||
);
|
||||
u8 r = static_cast<u8>(((int)dynamicLogoRGB1.r + ((int)dynamicLogoRGB2.r - (int)dynamicLogoRGB1.r) * blend) * brightness);
|
||||
u8 g = static_cast<u8>(((int)dynamicLogoRGB1.g + ((int)dynamicLogoRGB2.g - (int)dynamicLogoRGB1.g) * blend) * brightness);
|
||||
u8 b = static_cast<u8>(((int)dynamicLogoRGB1.b + ((int)dynamicLogoRGB2.b - (int)dynamicLogoRGB1.b) * blend) * brightness);
|
||||
|
||||
r = std::clamp<u8>(r, 0, 15);
|
||||
g = std::clamp<u8>(g, 0, 15);
|
||||
@@ -137,17 +127,10 @@ static s32 drawDynamicUltraText(
|
||||
return currentX;
|
||||
}
|
||||
|
||||
void BaseGui::preDraw(tsl::gfx::Renderer* renderer) {
|
||||
void BaseGui::preDraw(tsl::gfx::Renderer *renderer) {
|
||||
renderer->drawBitmap(LOGO_X, LOGO_Y_REAL - LOGO_LABEL_FONT_SIZE, LOGO_IMG_W, LOGO_IMG_H, hoc_rgba);
|
||||
|
||||
drawDynamicUltraText(
|
||||
renderer,
|
||||
LOGO_TEXT_X,
|
||||
TEXT_Y,
|
||||
LOGO_LABEL_FONT_SIZE,
|
||||
STATIC_TEAL,
|
||||
false
|
||||
);
|
||||
drawDynamicUltraText(renderer, LOGO_TEXT_X, TEXT_Y, LOGO_LABEL_FONT_SIZE, STATIC_TEAL, false);
|
||||
|
||||
static const std::string versionStr = "Version " + getVersionString() + " \"Gaea\"";
|
||||
static constexpr tsl::Color versionColor(9, 9, 9, 15);
|
||||
@@ -166,14 +149,12 @@ void BaseGui::preDraw(tsl::gfx::Renderer* renderer) {
|
||||
}
|
||||
}
|
||||
|
||||
tsl::elm::Element* BaseGui::createUI()
|
||||
{
|
||||
BaseFrame* rootFrame = new BaseFrame(this, this->headerHeight());
|
||||
tsl::elm::Element *BaseGui::createUI() {
|
||||
BaseFrame *rootFrame = new BaseFrame(this, this->headerHeight());
|
||||
rootFrame->setContent(this->baseUI());
|
||||
return rootFrame;
|
||||
}
|
||||
|
||||
void BaseGui::update()
|
||||
{
|
||||
void BaseGui::update() {
|
||||
this->refresh();
|
||||
}
|
||||
@@ -12,9 +12,9 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
@@ -24,32 +24,36 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tesla.hpp>
|
||||
#include "../elements/base_frame.h"
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <tesla.hpp>
|
||||
#include <vector>
|
||||
|
||||
#include "../style.h"
|
||||
#include "../../ipc.h"
|
||||
#include "../elements/base_frame.h"
|
||||
#include "../style.h"
|
||||
|
||||
class BaseGui : public tsl::Gui
|
||||
{
|
||||
|
||||
class BaseGui : public tsl::Gui {
|
||||
public:
|
||||
BaseGui() {}
|
||||
~BaseGui() {}
|
||||
virtual void preDraw(tsl::gfx::Renderer* renderer);
|
||||
void update() override;
|
||||
tsl::elm::Element* createUI() override;
|
||||
virtual tsl::elm::Element* baseUI() = 0;
|
||||
virtual void refresh() {}
|
||||
virtual u16 headerHeight() const { return HOC_HEADER_HEIGHT; }
|
||||
BaseGui() {
|
||||
}
|
||||
~BaseGui() {
|
||||
}
|
||||
virtual void preDraw(tsl::gfx::Renderer *renderer);
|
||||
void update() override;
|
||||
tsl::elm::Element *createUI() override;
|
||||
virtual tsl::elm::Element *baseUI() = 0;
|
||||
virtual void refresh() {
|
||||
}
|
||||
virtual u16 headerHeight() const {
|
||||
return HOC_HEADER_HEIGHT;
|
||||
}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
extern std::string getVersionString();
|
||||
|
||||
@@ -24,23 +24,24 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "../format.h"
|
||||
#include "base_menu_gui.h"
|
||||
#include "fatal_gui.h"
|
||||
#include "../format.h"
|
||||
|
||||
|
||||
#define TOP_Y_OFFSET 15
|
||||
|
||||
// Cache hardware model to avoid repeated syscalls
|
||||
|
||||
BaseMenuGui::BaseMenuGui() : tempColors{ tsl::Color(0), tsl::Color(0), tsl::Color(0), tsl::Color(0), tsl::Color(0), tsl::Color(0), tsl::Color(0), }
|
||||
{
|
||||
BaseMenuGui::BaseMenuGui()
|
||||
: tempColors{
|
||||
tsl::Color(0), tsl::Color(0), tsl::Color(0), tsl::Color(0), tsl::Color(0), tsl::Color(0), tsl::Color(0),
|
||||
} {
|
||||
tsl::initializeThemeVars();
|
||||
this->context = nullptr;
|
||||
this->lastContextUpdate = 0;
|
||||
this->listElement = nullptr;
|
||||
|
||||
|
||||
// Pre-cache hardware model during initialization
|
||||
IsAula();
|
||||
IsMariko();
|
||||
@@ -51,19 +52,19 @@ BaseMenuGui::BaseMenuGui() : tempColors{ tsl::Color(0), tsl::Color(0), tsl::Colo
|
||||
}
|
||||
|
||||
BaseMenuGui::~BaseMenuGui() {
|
||||
delete this->context; // delete handles nullptr automatically
|
||||
delete this->context; // delete handles nullptr automatically
|
||||
}
|
||||
|
||||
// Fast preDraw - just renders pre-computed strings
|
||||
void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) {
|
||||
void BaseMenuGui::preDraw(tsl::gfx::Renderer *renderer) {
|
||||
BaseGui::preDraw(renderer);
|
||||
|
||||
// All constants pre-calculated and cached
|
||||
const char* labels[] = {
|
||||
"App ID", "Profile", "CPU", "GPU", "MEM", "SoC", "Board", "Skin", "Now", "Avg", "BAT", "PMIC", "Fan", IsAula() || this->context->isUsingRetroSuper ? "OLED" : "LCD", "FPS", "RES"
|
||||
};
|
||||
const char *labels[] = { "App ID", "Profile", "CPU", "GPU", "MEM", "SoC", "Board",
|
||||
"Skin", "Now", "Avg", "BAT", "PMIC", "Fan", IsAula() || this->context->isUsingRetroSuper ? "OLED" : "LCD",
|
||||
"FPS", "RES" };
|
||||
|
||||
static constexpr u32 dataPositions[6] = {63-3+3, 200-1, 344-1-3, 200-1, 342-1, 321-1};
|
||||
static constexpr u32 dataPositions[6] = { 63 - 3 + 3, 200 - 1, 344 - 1 - 3, 200 - 1, 342 - 1, 321 - 1 };
|
||||
|
||||
static u32 labelWidths[10];
|
||||
static bool positionsInitialized = false;
|
||||
@@ -74,14 +75,23 @@ void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) {
|
||||
}
|
||||
positionsInitialized = true;
|
||||
}
|
||||
static u32 positions[10] = {24-1, 310-labelWidths[1], 24-1, 192-labelWidths[3], 332-labelWidths[4], 24-1, 192 - labelWidths[6], 332-labelWidths[7], 192 - labelWidths[8], 332-labelWidths[9]};
|
||||
static u32 positions[10] = { 24 - 1,
|
||||
310 - labelWidths[1],
|
||||
24 - 1,
|
||||
192 - labelWidths[3],
|
||||
332 - labelWidths[4],
|
||||
24 - 1,
|
||||
192 - labelWidths[6],
|
||||
332 - labelWidths[7],
|
||||
192 - labelWidths[8],
|
||||
332 - labelWidths[9] };
|
||||
|
||||
static u32 maxProfileValueWidth = renderer->getTextDimensions("USB Charger", false, SMALL_TEXT_SIZE).first; // longest word
|
||||
static u32 maxProfileValueWidth = renderer->getTextDimensions("USB Charger", false, SMALL_TEXT_SIZE).first; // longest word
|
||||
|
||||
u32 y = 91 + TOP_Y_OFFSET;
|
||||
|
||||
// === TOP SECTION ===
|
||||
renderer->drawRoundedRect(14, 70-1 + TOP_Y_OFFSET, 420, 30+2, 12.0f, renderer->aWithOpacity(tsl::tableBGColor));
|
||||
renderer->drawRoundedRect(14, 70 - 1 + TOP_Y_OFFSET, 420, 30 + 2, 12.0f, renderer->aWithOpacity(tsl::tableBGColor));
|
||||
|
||||
// App ID - use pre-formatted string
|
||||
renderer->drawString(labels[0], false, positions[0], y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
|
||||
@@ -91,7 +101,7 @@ void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) {
|
||||
renderer->drawString(labels[1], false, 423 - maxProfileValueWidth - labelWidths[1] - 9, y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
|
||||
renderer->drawString(displayStrings[1], false, 423 - maxProfileValueWidth, y, SMALL_TEXT_SIZE, tsl::infoTextColor);
|
||||
|
||||
y += 38; // Direct assignment instead of += 38
|
||||
y += 38; // Direct assignment instead of += 38
|
||||
|
||||
// === MAIN DATA SECTION ===
|
||||
renderer->drawRoundedRect(14, 106 + TOP_Y_OFFSET, 420, 156, 10.0f, renderer->aWithOpacity(tsl::tableBGColor));
|
||||
@@ -106,8 +116,7 @@ void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) {
|
||||
renderer->drawString(displayStrings[3], false, dataPositions[1], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU
|
||||
renderer->drawString(displayStrings[4], false, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // MEM
|
||||
|
||||
y += 20; // Direct assignment (129 + 20)
|
||||
|
||||
y += 20; // Direct assignment (129 + 20)
|
||||
|
||||
renderer->drawString(displayStrings[5], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // CPU real
|
||||
renderer->drawString(displayStrings[6], false, dataPositions[1], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU real
|
||||
@@ -119,19 +128,20 @@ void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) {
|
||||
|
||||
// === REAL FREQUENCIES ===
|
||||
|
||||
y += 20; // Direct assignment (149 + 20)
|
||||
y += 20; // Direct assignment (149 + 20)
|
||||
|
||||
// === VOLTAGES ===
|
||||
renderer->drawString(displayStrings[8], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // CPU voltage
|
||||
renderer->drawString(displayStrings[9], false, dataPositions[1], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU voltage
|
||||
renderer->drawString(displayStrings[8], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // CPU voltage
|
||||
renderer->drawString(displayStrings[9], false, dataPositions[1], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU voltage
|
||||
|
||||
renderer->drawStringWithColoredSections(displayStrings[10], false, {""}, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor, tsl::separatorColor);
|
||||
renderer->drawStringWithColoredSections(displayStrings[10], false, { "" }, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor,
|
||||
tsl::separatorColor);
|
||||
|
||||
renderer->drawString(displayStrings[19], false, positions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // CPU Usage
|
||||
renderer->drawString(displayStrings[17], false, positions[3], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU Usage
|
||||
renderer->drawString(displayStrings[18], false, positions[4], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // RAM Usage
|
||||
|
||||
y += 22; // Direct assignment (169 + 22)
|
||||
y += 22; // Direct assignment (169 + 22)
|
||||
|
||||
// === TEMPERATURE SECTION ===
|
||||
// Labels
|
||||
@@ -141,59 +151,57 @@ void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) {
|
||||
|
||||
// Temperatures with color - use pre-computed colors
|
||||
renderer->drawString(displayStrings[11], false, dataPositions[0] - 1, y, SMALL_TEXT_SIZE, tempColors[HocClkThermalSensor_SOC]); // SOC
|
||||
renderer->drawString(displayStrings[12], false, dataPositions[1], y, SMALL_TEXT_SIZE, tempColors[HocClkThermalSensor_PCB]); // PCB
|
||||
renderer->drawString(displayStrings[13], false, dataPositions[2], y, SMALL_TEXT_SIZE, tempColors[HocClkThermalSensor_Skin]); // Skin
|
||||
renderer->drawString(displayStrings[12], false, dataPositions[1], y, SMALL_TEXT_SIZE, tempColors[HocClkThermalSensor_PCB]); // PCB
|
||||
renderer->drawString(displayStrings[13], false, dataPositions[2], y, SMALL_TEXT_SIZE, tempColors[HocClkThermalSensor_Skin]); // Skin
|
||||
|
||||
y += 20; // Direct assignment (191 + 20)
|
||||
y += 20; // Direct assignment (191 + 20)
|
||||
|
||||
renderer->drawString(displayStrings[14], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // SOC voltage
|
||||
renderer->drawString(displayStrings[14], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // SOC voltage
|
||||
|
||||
// Power labels and values
|
||||
renderer->drawString(labels[8], false, positions[8]-1, y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
|
||||
renderer->drawString(labels[8], false, positions[8] - 1, y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
|
||||
renderer->drawString(labels[9], false, positions[9], y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
|
||||
|
||||
renderer->drawString(displayStrings[15], false, dataPositions[3], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // Power now
|
||||
renderer->drawString(displayStrings[16], false, dataPositions[4], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // Power avg
|
||||
|
||||
y+=20;
|
||||
y += 20;
|
||||
|
||||
renderer->drawString(labels[10], false, positions[2], y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
|
||||
|
||||
renderer->drawString(displayStrings[20], false, dataPositions[0], y, SMALL_TEXT_SIZE, tempColors[HocClkThermalSensor_Battery]); // Battery
|
||||
|
||||
renderer->drawString(labels[12], false, positions[3], y, SMALL_TEXT_SIZE, tsl::sectionTextColor); // fan label
|
||||
renderer->drawString(labels[12], false, positions[3], y, SMALL_TEXT_SIZE, tsl::sectionTextColor); // fan label
|
||||
|
||||
renderer->drawString(displayStrings[24], false, dataPositions[1] + 5, y, SMALL_TEXT_SIZE, tsl::infoTextColor); // fan speed
|
||||
renderer->drawString(displayStrings[24], false, dataPositions[1] + 5, y, SMALL_TEXT_SIZE, tsl::infoTextColor); // fan speed
|
||||
|
||||
renderer->drawString(labels[13], false, positions[4] + 4, y, SMALL_TEXT_SIZE, tsl::sectionTextColor); // disp label
|
||||
renderer->drawString(labels[13], false, positions[4] + 4, y, SMALL_TEXT_SIZE, tsl::sectionTextColor); // disp label
|
||||
|
||||
renderer->drawString(displayStrings[25], false, dataPositions[2] + 6, y, SMALL_TEXT_SIZE, tsl::infoTextColor); // disp freq
|
||||
renderer->drawString(displayStrings[25], false, dataPositions[2] + 6, y, SMALL_TEXT_SIZE, tsl::infoTextColor); // disp freq
|
||||
|
||||
y+=20;
|
||||
y += 20;
|
||||
|
||||
renderer->drawString(displayStrings[21], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // Bat voltage
|
||||
renderer->drawString(displayStrings[21], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // Bat voltage
|
||||
renderer->drawString(displayStrings[23], false, positions[2] - 2, y, SMALL_TEXT_SIZE, tsl::infoTextColor); // Bat Age
|
||||
|
||||
if(this->context->isSaltyNXInstalled) {
|
||||
if (this->context->isSaltyNXInstalled) {
|
||||
|
||||
renderer->drawString(labels[15], false, positions[3] + 7, y, SMALL_TEXT_SIZE, tsl::sectionTextColor); // RES label
|
||||
renderer->drawString(displayStrings[27], false, dataPositions[1] + 5, y, SMALL_TEXT_SIZE, tsl::infoTextColor); // RES
|
||||
|
||||
renderer->drawString(labels[14], false, positions[4] + 9, y, SMALL_TEXT_SIZE, tsl::sectionTextColor); // FPS label
|
||||
renderer->drawString(displayStrings[26], false, dataPositions[2] + 6, y, SMALL_TEXT_SIZE, tsl::infoTextColor); // FPS
|
||||
renderer->drawString(labels[15], false, positions[3] + 7, y, SMALL_TEXT_SIZE, tsl::sectionTextColor); // RES label
|
||||
renderer->drawString(displayStrings[27], false, dataPositions[1] + 5, y, SMALL_TEXT_SIZE, tsl::infoTextColor); // RES
|
||||
|
||||
renderer->drawString(labels[14], false, positions[4] + 9, y, SMALL_TEXT_SIZE, tsl::sectionTextColor); // FPS label
|
||||
renderer->drawString(displayStrings[26], false, dataPositions[2] + 6, y, SMALL_TEXT_SIZE, tsl::infoTextColor); // FPS
|
||||
}
|
||||
|
||||
y+=20;
|
||||
y += 20;
|
||||
}
|
||||
|
||||
// Optimized refresh - now does all the string formatting once per second
|
||||
void BaseMenuGui::refresh()
|
||||
{
|
||||
void BaseMenuGui::refresh() {
|
||||
const u64 ticks = armGetSystemTick();
|
||||
// Use cached comparison - 1 billion nanoseconds
|
||||
if (armTicksToNs(ticks - this->lastContextUpdate) <= 1000000000UL) [[likely]] {
|
||||
return; // Early exit for most calls
|
||||
return; // Early exit for most calls
|
||||
}
|
||||
|
||||
this->lastContextUpdate = ticks;
|
||||
@@ -224,22 +232,22 @@ void BaseMenuGui::refresh()
|
||||
strcpy(displayStrings[1], hocclkFormatProfile(context->profile, true));
|
||||
|
||||
// Current frequencies
|
||||
u32 hz = context->freqs[HocClkModule_CPU]; // CPU
|
||||
u32 hz = context->freqs[HocClkModule_CPU]; // CPU
|
||||
sprintf(displayStrings[2], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U);
|
||||
|
||||
hz = context->freqs[HocClkModule_GPU]; // GPU
|
||||
hz = context->freqs[HocClkModule_GPU]; // GPU
|
||||
sprintf(displayStrings[3], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U);
|
||||
|
||||
hz = context->freqs[HocClkModule_MEM]; // MEM
|
||||
hz = context->freqs[HocClkModule_MEM]; // MEM
|
||||
std::uint32_t unit = configList.values[HocClkConfigValue_RamDisplayUnit];
|
||||
std::uint32_t mhz = hz / 1000000U;
|
||||
std::uint32_t mts = mhz * 2;
|
||||
std::uint32_t tenth = (hz / 100000U) % 10U;
|
||||
if(unit == RamDisplayUnit_MTs)
|
||||
if (unit == RamDisplayUnit_MTs)
|
||||
sprintf(displayStrings[4], "%u MT/s", mts);
|
||||
else if(unit == RamDisplayUnit_MHz)
|
||||
else if (unit == RamDisplayUnit_MHz)
|
||||
sprintf(displayStrings[4], "%u.%u MHz", mhz, tenth);
|
||||
else if(unit == RamDisplayUnit_MHzMTs) {
|
||||
else if (unit == RamDisplayUnit_MHzMTs) {
|
||||
hz = context->realFreqs[HocClkModule_MEM];
|
||||
mhz = hz / 1000000U;
|
||||
tenth = (hz / 100000U) % 10U;
|
||||
@@ -247,18 +255,18 @@ void BaseMenuGui::refresh()
|
||||
}
|
||||
|
||||
// Real frequencies
|
||||
hz = context->realFreqs[HocClkModule_CPU]; // CPU
|
||||
hz = context->realFreqs[HocClkModule_CPU]; // CPU
|
||||
sprintf(displayStrings[5], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U);
|
||||
|
||||
hz = context->realFreqs[HocClkModule_GPU]; // GPU
|
||||
hz = context->realFreqs[HocClkModule_GPU]; // GPU
|
||||
sprintf(displayStrings[6], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U);
|
||||
|
||||
hz = context->realFreqs[HocClkModule_MEM]; // MEM
|
||||
hz = context->realFreqs[HocClkModule_MEM]; // MEM
|
||||
unit = configList.values[HocClkConfigValue_RamDisplayUnit];
|
||||
mhz = hz / 1000000U;
|
||||
mts = mhz * 2;
|
||||
tenth = (hz / 100000U) % 10U;
|
||||
if(unit == RamDisplayUnit_MTs || unit == RamDisplayUnit_MHzMTs)
|
||||
if (unit == RamDisplayUnit_MTs || unit == RamDisplayUnit_MHzMTs)
|
||||
sprintf(displayStrings[7], "%u MT/s", mts);
|
||||
else
|
||||
sprintf(displayStrings[7], "%u.%u MHz", mhz, tenth);
|
||||
@@ -267,12 +275,14 @@ void BaseMenuGui::refresh()
|
||||
sprintf(displayStrings[8], "%.1f mV", context->voltages[HocClkVoltage_CPU] / 1000.0);
|
||||
sprintf(displayStrings[9], "%.1f mV", context->voltages[HocClkVoltage_GPU] / 1000.0);
|
||||
|
||||
switch(configList.values[HocClkConfigValue_RAMVoltDisplayMode]) {
|
||||
switch (configList.values[HocClkConfigValue_RAMVoltDisplayMode]) {
|
||||
case RamDisplayMode_VDD2:
|
||||
sprintf(displayStrings[10], "%u.%u mV", context->voltages[HocClkVoltage_EMCVDD2] / 1000U, (context->voltages[HocClkVoltage_EMCVDD2] % 1000U) / 100U);
|
||||
sprintf(displayStrings[10], "%u.%u mV", context->voltages[HocClkVoltage_EMCVDD2] / 1000U,
|
||||
(context->voltages[HocClkVoltage_EMCVDD2] % 1000U) / 100U);
|
||||
break;
|
||||
case RamDisplayMode_VDDQ:
|
||||
sprintf(displayStrings[10], "%u.%u mV", context->voltages[HocClkVoltage_EMCVDDQ] / 1000U, (context->voltages[HocClkVoltage_EMCVDDQ] % 1000U) / 100U);
|
||||
sprintf(displayStrings[10], "%u.%u mV", context->voltages[HocClkVoltage_EMCVDDQ] / 1000U,
|
||||
(context->voltages[HocClkVoltage_EMCVDDQ] % 1000U) / 100U);
|
||||
break;
|
||||
default:
|
||||
strcpy(displayStrings[10], "N/A");
|
||||
@@ -280,15 +290,15 @@ void BaseMenuGui::refresh()
|
||||
}
|
||||
|
||||
// Temperatures and pre-compute colors
|
||||
u32 millis = context->temps[HocClkThermalSensor_SOC]; // SOC
|
||||
u32 millis = context->temps[HocClkThermalSensor_SOC]; // SOC
|
||||
sprintf(displayStrings[11], "%u.%u °C", millis / 1000U, (millis % 1000U) / 100U);
|
||||
tempColors[HocClkThermalSensor_SOC] = tsl::GradientColor(millis * 0.001f);
|
||||
|
||||
millis = context->temps[HocClkThermalSensor_PCB]; // PCB
|
||||
millis = context->temps[HocClkThermalSensor_PCB]; // PCB
|
||||
sprintf(displayStrings[12], "%u.%u °C", millis / 1000U, (millis % 1000U) / 100U);
|
||||
tempColors[HocClkThermalSensor_PCB] = tsl::GradientColor(millis * 0.001f);
|
||||
|
||||
millis = context->temps[HocClkThermalSensor_Skin]; // Skin
|
||||
millis = context->temps[HocClkThermalSensor_Skin]; // Skin
|
||||
sprintf(displayStrings[13], "%u.%u °C", millis / 1000U, (millis % 1000U) / 100U);
|
||||
tempColors[HocClkThermalSensor_Skin] = tsl::GradientColor(millis * 0.001f);
|
||||
|
||||
@@ -296,26 +306,26 @@ void BaseMenuGui::refresh()
|
||||
sprintf(displayStrings[14], "%u mV", context->voltages[HocClkVoltage_SOC] / 1000U);
|
||||
|
||||
// Power
|
||||
sprintf(displayStrings[15], "%d mW", context->power[0]); // Now
|
||||
sprintf(displayStrings[16], "%d mW", context->power[1]); // Avg
|
||||
sprintf(displayStrings[15], "%d mW", context->power[0]); // Now
|
||||
sprintf(displayStrings[16], "%d mW", context->power[1]); // Avg
|
||||
|
||||
sprintf(displayStrings[17], "%u%%", context->partLoad[HocClkPartLoad_GPU] / 10);
|
||||
sprintf(displayStrings[18], "%u%%", context->partLoad[HocClkPartLoad_EMC] / 10);
|
||||
sprintf(displayStrings[19], "%u%%", context->partLoad[HocClkPartLoad_CPUMax] / 10);
|
||||
|
||||
millis = context->temps[HocClkThermalSensor_Battery]; // Battery
|
||||
millis = context->temps[HocClkThermalSensor_Battery]; // Battery
|
||||
sprintf(displayStrings[20], "%u.%u °C", millis / 1000U, (millis % 1000U) / 100U);
|
||||
tempColors[HocClkThermalSensor_Battery] = tsl::GradientColor(millis * 0.001f);
|
||||
|
||||
sprintf(displayStrings[21], "%d mV", context->voltages[HocClkVoltage_Battery]); // BAT AVG
|
||||
sprintf(displayStrings[21], "%d mV", context->voltages[HocClkVoltage_Battery]); // BAT AVG
|
||||
|
||||
sprintf(displayStrings[23], "%u%%", context->partLoad[HocClkPartLoad_BAT] / 1000);
|
||||
|
||||
sprintf(displayStrings[24], "%u%%", context->partLoad[HocClkPartLoad_FAN]);
|
||||
|
||||
sprintf(displayStrings[25], "%u Hz", context->realFreqs[HocClkModule_Display]);
|
||||
if(this->context->isSaltyNXInstalled) {
|
||||
if(context->fps == 254) {
|
||||
if (this->context->isSaltyNXInstalled) {
|
||||
if (context->fps == 254) {
|
||||
strcpy(displayStrings[26], "N/A");
|
||||
} else {
|
||||
memset(displayStrings[26], 0, sizeof(displayStrings[26]));
|
||||
@@ -323,8 +333,8 @@ void BaseMenuGui::refresh()
|
||||
}
|
||||
}
|
||||
|
||||
if(this->context->isSaltyNXInstalled) {
|
||||
if(context->resolutionHeight == 0) {
|
||||
if (this->context->isSaltyNXInstalled) {
|
||||
if (context->resolutionHeight == 0) {
|
||||
strcpy(displayStrings[27], "N/A");
|
||||
} else {
|
||||
memset(displayStrings[27], 0, sizeof(displayStrings[27]));
|
||||
@@ -343,12 +353,10 @@ void BaseMenuGui::refresh()
|
||||
millis = context->temps[HocClkThermalSensor_MEM];
|
||||
sprintf(displayStrings[30], "%u.%u", millis / 1000U, (millis % 1000U) / 100U);
|
||||
tempColors[HocClkThermalSensor_MEM] = tsl::GradientColor(millis * 0.001f);
|
||||
|
||||
}
|
||||
|
||||
tsl::elm::Element* BaseMenuGui::baseUI()
|
||||
{
|
||||
auto* list = new tsl::elm::List();
|
||||
tsl::elm::Element *BaseMenuGui::baseUI() {
|
||||
auto *list = new tsl::elm::List();
|
||||
this->listElement = list;
|
||||
this->listUI();
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
@@ -24,69 +24,66 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../ipc.h"
|
||||
#include "base_gui.h"
|
||||
|
||||
class BaseMenuGui : public BaseGui
|
||||
{
|
||||
class BaseMenuGui : public BaseGui {
|
||||
protected:
|
||||
|
||||
public:
|
||||
// u8 dockedHighestAllowedRefreshRate = 60;
|
||||
HocClkContext* context;
|
||||
std::uint64_t lastContextUpdate;
|
||||
HocClkConfigValueList configList;
|
||||
bool g_hardwareModelCached = false;
|
||||
bool g_isMariko = false;
|
||||
bool g_isAula = false;
|
||||
bool g_isHoag = false;
|
||||
SetSysProductModel HWmodel = SetSysProductModel_Invalid;
|
||||
|
||||
bool IsAula() {
|
||||
if (!g_hardwareModelCached) {
|
||||
setsysGetProductModel(&HWmodel);
|
||||
g_hardwareModelCached = true;
|
||||
}
|
||||
g_isAula = (HWmodel == SetSysProductModel_Aula);
|
||||
return g_isAula;
|
||||
}
|
||||
bool IsHoag() {
|
||||
if (!g_hardwareModelCached) {
|
||||
setsysGetProductModel(&HWmodel);
|
||||
g_hardwareModelCached = true;
|
||||
}
|
||||
g_isHoag = (HWmodel == SetSysProductModel_Hoag);
|
||||
return g_isHoag;
|
||||
}
|
||||
bool IsMariko() {
|
||||
if (!g_hardwareModelCached) {
|
||||
setsysGetProductModel(&HWmodel);
|
||||
g_hardwareModelCached = true;
|
||||
}
|
||||
g_isMariko = (HWmodel == SetSysProductModel_Iowa ||
|
||||
HWmodel == SetSysProductModel_Hoag ||
|
||||
HWmodel == SetSysProductModel_Calcio ||
|
||||
HWmodel == SetSysProductModel_Aula);
|
||||
// u8 dockedHighestAllowedRefreshRate = 60;
|
||||
HocClkContext *context;
|
||||
std::uint64_t lastContextUpdate;
|
||||
HocClkConfigValueList configList;
|
||||
bool g_hardwareModelCached = false;
|
||||
bool g_isMariko = false;
|
||||
bool g_isAula = false;
|
||||
bool g_isHoag = false;
|
||||
SetSysProductModel HWmodel = SetSysProductModel_Invalid;
|
||||
|
||||
return g_isMariko;
|
||||
bool IsAula() {
|
||||
if (!g_hardwareModelCached) {
|
||||
setsysGetProductModel(&HWmodel);
|
||||
g_hardwareModelCached = true;
|
||||
}
|
||||
g_isAula = (HWmodel == SetSysProductModel_Aula);
|
||||
return g_isAula;
|
||||
}
|
||||
bool IsHoag() {
|
||||
if (!g_hardwareModelCached) {
|
||||
setsysGetProductModel(&HWmodel);
|
||||
g_hardwareModelCached = true;
|
||||
}
|
||||
g_isHoag = (HWmodel == SetSysProductModel_Hoag);
|
||||
return g_isHoag;
|
||||
}
|
||||
bool IsMariko() {
|
||||
if (!g_hardwareModelCached) {
|
||||
setsysGetProductModel(&HWmodel);
|
||||
g_hardwareModelCached = true;
|
||||
}
|
||||
g_isMariko = (HWmodel == SetSysProductModel_Iowa || HWmodel == SetSysProductModel_Hoag || HWmodel == SetSysProductModel_Calcio ||
|
||||
HWmodel == SetSysProductModel_Aula);
|
||||
|
||||
bool IsErista() {
|
||||
return !IsMariko();
|
||||
}
|
||||
BaseMenuGui();
|
||||
~BaseMenuGui();
|
||||
void preDraw(tsl::gfx::Renderer* renderer) override;
|
||||
tsl::elm::List* listElement;
|
||||
tsl::elm::Element* baseUI() override;
|
||||
void refresh() override;
|
||||
virtual void listUI() = 0;
|
||||
u16 headerHeight() const override { return HOC_BOX_BOTTOM + 9; }
|
||||
return g_isMariko;
|
||||
}
|
||||
|
||||
bool IsErista() {
|
||||
return !IsMariko();
|
||||
}
|
||||
BaseMenuGui();
|
||||
~BaseMenuGui();
|
||||
void preDraw(tsl::gfx::Renderer *renderer) override;
|
||||
tsl::elm::List *listElement;
|
||||
tsl::elm::Element *baseUI() override;
|
||||
void refresh() override;
|
||||
virtual void listUI() = 0;
|
||||
u16 headerHeight() const override {
|
||||
return HOC_BOX_BOTTOM + 9;
|
||||
}
|
||||
|
||||
private:
|
||||
char displayStrings[48][32]; // Pre-formatted display strings
|
||||
tsl::Color tempColors[HocClkThermalSensor_EnumMax]; // Pre-computed temperature colors
|
||||
char displayStrings[48][32]; // Pre-formatted display strings
|
||||
tsl::Color tempColors[HocClkThermalSensor_EnumMax]; // Pre-computed temperature colors
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,8 +16,9 @@
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#include "misc_gui.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "misc_gui.h"
|
||||
|
||||
std::vector<std::string> ConfigInfoStrings(HocClkConfigValue val, bool isMariko, bool isHoag);
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
@@ -24,45 +24,37 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "fatal_gui.h"
|
||||
|
||||
FatalGui::FatalGui(const std::string message, const std::string info)
|
||||
{
|
||||
FatalGui::FatalGui(const std::string message, const std::string info) {
|
||||
this->message = message;
|
||||
this->info = info;
|
||||
}
|
||||
|
||||
void FatalGui::openWithResultCode(std::string tag, Result rc)
|
||||
{
|
||||
void FatalGui::openWithResultCode(std::string tag, Result rc) {
|
||||
char rcStr[32];
|
||||
std::string info = tag;
|
||||
info.append(rcStr, snprintf(rcStr, sizeof(rcStr), "\n\n[0x%x] %04d-%04d", rc, R_MODULE(rc), R_DESCRIPTION(rc)));
|
||||
|
||||
tsl::changeTo<FatalGui>(
|
||||
"Could not connect to hoc-clk sysmodule.\n\n"
|
||||
"\n"
|
||||
"Please make sure everything is\n\n"
|
||||
"correctly installed and enabled.",
|
||||
info
|
||||
);
|
||||
tsl::changeTo<FatalGui>("Could not connect to hoc-clk sysmodule.\n\n"
|
||||
"\n"
|
||||
"Please make sure everything is\n\n"
|
||||
"correctly installed and enabled.",
|
||||
info);
|
||||
}
|
||||
|
||||
tsl::elm::Element* FatalGui::baseUI()
|
||||
{
|
||||
tsl::elm::CustomDrawer* drawer = new tsl::elm::CustomDrawer([this](tsl::gfx::Renderer* renderer, u16 x, u16 y, u16 w, u16 h) {
|
||||
tsl::elm::Element *FatalGui::baseUI() {
|
||||
tsl::elm::CustomDrawer *drawer = new tsl::elm::CustomDrawer([this](tsl::gfx::Renderer *renderer, u16 x, u16 y, u16 w, u16 h) {
|
||||
renderer->drawString("\uE150", false, 40, 210, 40, TEXT_COLOR);
|
||||
renderer->drawString("Fatal error", false, 100, 210, 30, TEXT_COLOR);
|
||||
|
||||
std::uint32_t txtY = 255;
|
||||
if(!this->message.empty())
|
||||
{
|
||||
if (!this->message.empty()) {
|
||||
txtY += renderer->drawString(this->message.c_str(), false, 40, txtY, 23, TEXT_COLOR).second;
|
||||
txtY += 55;
|
||||
}
|
||||
|
||||
if(!this->info.empty())
|
||||
{
|
||||
if (!this->info.empty()) {
|
||||
renderer->drawString(this->info.c_str(), false, 40, txtY, 18, DESC_COLOR);
|
||||
}
|
||||
});
|
||||
@@ -70,11 +62,10 @@ tsl::elm::Element* FatalGui::baseUI()
|
||||
return drawer;
|
||||
}
|
||||
|
||||
bool FatalGui::handleInput(u64 keysDown, u64 keysHeld, const HidTouchState &touchPos, HidAnalogStickState joyStickPosLeft, HidAnalogStickState joyStickPosRight)
|
||||
{
|
||||
if((keysDown & HidNpadButton_A) == HidNpadButton_A || (keysDown & HidNpadButton_B) == HidNpadButton_B)
|
||||
{
|
||||
while(tsl::Overlay::get()->getCurrentGui() != nullptr) {
|
||||
bool FatalGui::handleInput(u64 keysDown, u64 keysHeld, const HidTouchState &touchPos, HidAnalogStickState joyStickPosLeft,
|
||||
HidAnalogStickState joyStickPosRight) {
|
||||
if ((keysDown & HidNpadButton_A) == HidNpadButton_A || (keysDown & HidNpadButton_B) == HidNpadButton_B) {
|
||||
while (tsl::Overlay::get()->getCurrentGui() != nullptr) {
|
||||
tsl::goBack();
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
@@ -24,23 +24,23 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "base_gui.h"
|
||||
|
||||
class FatalGui : public BaseGui
|
||||
{
|
||||
class FatalGui : public BaseGui {
|
||||
protected:
|
||||
std::string message;
|
||||
std::string info;
|
||||
std::string message;
|
||||
std::string info;
|
||||
|
||||
public:
|
||||
FatalGui(const std::string message, const std::string info);
|
||||
~FatalGui() {}
|
||||
tsl::elm::Element* baseUI() override;
|
||||
bool handleInput(u64 keysDown, u64 keysHeld, const HidTouchState &touchPos, HidAnalogStickState joyStickPosLeft, HidAnalogStickState joyStickPosRight);
|
||||
static void openWithResultCode(std::string tag, Result rc);
|
||||
FatalGui(const std::string message, const std::string info);
|
||||
~FatalGui() {
|
||||
}
|
||||
tsl::elm::Element *baseUI() override;
|
||||
bool handleInput(u64 keysDown, u64 keysHeld, const HidTouchState &touchPos, HidAnalogStickState joyStickPosLeft,
|
||||
HidAnalogStickState joyStickPosRight);
|
||||
static void openWithResultCode(std::string tag, Result rc);
|
||||
};
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
@@ -24,21 +24,13 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "ult_ext.h"
|
||||
#include "freq_choice_gui.h"
|
||||
|
||||
#include "../format.h"
|
||||
#include "fatal_gui.h"
|
||||
#include "freq_choice_gui.h"
|
||||
#include "ult_ext.h"
|
||||
|
||||
FreqChoiceGui::FreqChoiceGui(std::uint32_t selectedHz,
|
||||
std::uint32_t* hzList,
|
||||
std::uint32_t hzCount,
|
||||
HocClkModule module,
|
||||
FreqChoiceListener listener,
|
||||
bool checkMax,
|
||||
std::map<uint32_t, std::string> labels)
|
||||
{
|
||||
FreqChoiceGui::FreqChoiceGui(std::uint32_t selectedHz, std::uint32_t *hzList, std::uint32_t hzCount, HocClkModule module, FreqChoiceListener listener,
|
||||
bool checkMax, std::map<uint32_t, std::string> labels) {
|
||||
this->selectedHz = selectedHz;
|
||||
this->hzList = hzList;
|
||||
this->hzCount = hzCount;
|
||||
@@ -46,18 +38,16 @@ FreqChoiceGui::FreqChoiceGui(std::uint32_t selectedHz,
|
||||
this->listener = listener;
|
||||
this->checkMax = checkMax;
|
||||
this->labels = labels;
|
||||
this->configList = new HocClkConfigValueList {};
|
||||
this->configList = new HocClkConfigValueList{};
|
||||
}
|
||||
|
||||
FreqChoiceGui::~FreqChoiceGui()
|
||||
{
|
||||
FreqChoiceGui::~FreqChoiceGui() {
|
||||
delete this->configList;
|
||||
}
|
||||
|
||||
tsl::elm::ListItem* FreqChoiceGui::createFreqListItem(std::uint32_t hz, bool selected, int safety)
|
||||
{
|
||||
tsl::elm::ListItem *FreqChoiceGui::createFreqListItem(std::uint32_t hz, bool selected, int safety) {
|
||||
std::string text;
|
||||
if(module == HocClkModule_MEM)
|
||||
if (module == HocClkModule_MEM)
|
||||
text = formatListFreqHzMem(hz, (RamDisplayUnit)this->configList->values[HocClkConfigValue_RamDisplayUnit]);
|
||||
else
|
||||
text = formatListFreqHz(hz);
|
||||
@@ -68,35 +58,32 @@ tsl::elm::ListItem* FreqChoiceGui::createFreqListItem(std::uint32_t hz, bool sel
|
||||
rightText = it->second;
|
||||
|
||||
if (selected)
|
||||
const_cast<std::string&>(rightText) = "\uE14B";
|
||||
const_cast<std::string &>(rightText) = "\uE14B";
|
||||
|
||||
tsl::elm::ListItem* listItem =
|
||||
new tsl::elm::ListItem(text, rightText, false);
|
||||
tsl::elm::ListItem *listItem = new tsl::elm::ListItem(text, rightText, false);
|
||||
|
||||
switch (safety)
|
||||
{
|
||||
case 0:
|
||||
listItem->setTextColor(tsl::Color(255, 255, 255, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 255, 255, 255));
|
||||
break;
|
||||
case 1:
|
||||
listItem->setTextColor(tsl::Color(255, 165, 0, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 165, 0, 255));
|
||||
break;
|
||||
case 2:
|
||||
listItem->setTextColor(tsl::Color(255, 0, 0, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 0, 0, 255));
|
||||
break;
|
||||
switch (safety) {
|
||||
case 0:
|
||||
listItem->setTextColor(tsl::Color(255, 255, 255, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 255, 255, 255));
|
||||
break;
|
||||
case 1:
|
||||
listItem->setTextColor(tsl::Color(255, 165, 0, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 165, 0, 255));
|
||||
break;
|
||||
case 2:
|
||||
listItem->setTextColor(tsl::Color(255, 0, 0, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 0, 0, 255));
|
||||
break;
|
||||
}
|
||||
|
||||
// Make annotation grey
|
||||
if (!rightText.empty() && !selected)
|
||||
listItem->setValueColor(tsl::Color(180, 180, 180, 255));
|
||||
else if(selected)
|
||||
else if (selected)
|
||||
listItem->setValueColor(tsl::infoTextColor);
|
||||
|
||||
listItem->setClickListener([this, hz](u64 keys)
|
||||
{
|
||||
listItem->setClickListener([this, hz](u64 keys) {
|
||||
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->listener) {
|
||||
if (this->listener(hz)) {
|
||||
tsl::goBack();
|
||||
@@ -109,8 +96,7 @@ tsl::elm::ListItem* FreqChoiceGui::createFreqListItem(std::uint32_t hz, bool sel
|
||||
return listItem;
|
||||
}
|
||||
|
||||
void FreqChoiceGui::listUI()
|
||||
{
|
||||
void FreqChoiceGui::listUI() {
|
||||
hocclkIpcGetConfigValues(this->configList);
|
||||
|
||||
// Header based on CPU/GPU/MEM module
|
||||
@@ -118,11 +104,9 @@ void FreqChoiceGui::listUI()
|
||||
this->listElement->addItem(new tsl::elm::CategoryHeader(moduleName));
|
||||
|
||||
// Default option
|
||||
this->listElement->addItem(
|
||||
this->createFreqListItem(0, this->selectedHz == 0, 0));
|
||||
this->listElement->addItem(this->createFreqListItem(0, this->selectedHz == 0, 0));
|
||||
|
||||
for (std::uint32_t i = 0; i < this->hzCount; i++)
|
||||
{
|
||||
for (std::uint32_t i = 0; i < this->hzCount; i++) {
|
||||
std::uint32_t hz = this->hzList[i];
|
||||
uint32_t mhz = hz / 1000000;
|
||||
|
||||
@@ -160,17 +144,14 @@ void FreqChoiceGui::listUI()
|
||||
uint32_t danger_cpu;
|
||||
uint32_t danger_gpu;
|
||||
|
||||
if (IsMariko())
|
||||
{
|
||||
if (IsMariko()) {
|
||||
unsafe_cpu = this->configList->values[KipConfigValue_marikoCpuUVHigh] ? 2398 : 1964;
|
||||
unsafe_gpu = 1229;
|
||||
danger_cpu = this->configList->values[KipConfigValue_marikoCpuUVHigh] ? 2500 : 2398;
|
||||
danger_gpu = 1306;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
unsafe_cpu = this->configList->values[KipConfigValue_eristaCpuUV] ? 2092 : 1786;
|
||||
if(this->configList->values[KipConfigValue_eristaGpuUV] == GPUUVLevel_NoUV) {
|
||||
if (this->configList->values[KipConfigValue_eristaGpuUV] == GPUUVLevel_NoUV) {
|
||||
unsafe_gpu = 922;
|
||||
} else {
|
||||
unsafe_gpu = 961;
|
||||
@@ -202,16 +183,9 @@ void FreqChoiceGui::listUI()
|
||||
} else if (moduleName == "mem") {
|
||||
|
||||
safety = 0;
|
||||
|
||||
}
|
||||
|
||||
this->listElement->addItem(
|
||||
this->createFreqListItem(
|
||||
hz,
|
||||
(mhz == this->selectedHz / 1000000),
|
||||
safety
|
||||
)
|
||||
);
|
||||
this->listElement->addItem(this->createFreqListItem(hz, (mhz == this->selectedHz / 1000000), safety));
|
||||
}
|
||||
|
||||
this->listElement->jumpToItem("", "");
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
@@ -24,22 +24,21 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
#include "base_menu_gui.h"
|
||||
|
||||
using FreqChoiceListener = std::function<bool(std::uint32_t hz)>;
|
||||
|
||||
class FreqChoiceGui : public BaseMenuGui
|
||||
{
|
||||
protected:
|
||||
HocClkConfigValueList* configList;
|
||||
class FreqChoiceGui : public BaseMenuGui {
|
||||
protected:
|
||||
HocClkConfigValueList *configList;
|
||||
std::uint32_t selectedHz;
|
||||
std::uint32_t* hzList;
|
||||
std::uint32_t *hzList;
|
||||
std::uint32_t hzCount;
|
||||
HocClkModule module;
|
||||
FreqChoiceListener listener;
|
||||
@@ -47,16 +46,11 @@ protected:
|
||||
|
||||
std::map<uint32_t, std::string> labels;
|
||||
|
||||
tsl::elm::ListItem* createFreqListItem(std::uint32_t hz, bool selected, int safety);
|
||||
tsl::elm::ListItem *createFreqListItem(std::uint32_t hz, bool selected, int safety);
|
||||
|
||||
public:
|
||||
FreqChoiceGui(std::uint32_t selectedHz,
|
||||
std::uint32_t* hzList,
|
||||
std::uint32_t hzCount,
|
||||
HocClkModule module,
|
||||
FreqChoiceListener listener,
|
||||
bool checkMax = true,
|
||||
std::map<uint32_t, std::string> labels = {});
|
||||
public:
|
||||
FreqChoiceGui(std::uint32_t selectedHz, std::uint32_t *hzList, std::uint32_t hzCount, HocClkModule module, FreqChoiceListener listener,
|
||||
bool checkMax = true, std::map<uint32_t, std::string> labels = {});
|
||||
|
||||
~FreqChoiceGui();
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
@@ -25,50 +25,33 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
#include "../../ipc.h"
|
||||
#include "base_menu_gui.h"
|
||||
#include "freq_choice_gui.h"
|
||||
#include <string>
|
||||
#include "value_choice_gui.h"
|
||||
class GlobalOverrideGui : public BaseMenuGui
|
||||
{
|
||||
class GlobalOverrideGui : public BaseMenuGui {
|
||||
protected:
|
||||
std::map<HocClkModule, std::tuple<std::string, std::uint32_t, int>> customFormatModules;
|
||||
tsl::elm::ListItem* listItems[HocClkModule_EnumMax];
|
||||
std::uint32_t listHz[HocClkModule_EnumMax];
|
||||
void openFreqChoiceGui(HocClkModule module);
|
||||
void addGovernorSection();
|
||||
void addModuleListItem(HocClkModule module);
|
||||
void addModuleToggleItem(HocClkModule module);
|
||||
void openValueChoiceGui(
|
||||
tsl::elm::ListItem* listItem,
|
||||
std::uint32_t currentValue,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
ValueChoiceListener listener,
|
||||
const ValueThresholds& thresholds,
|
||||
bool enableThresholds,
|
||||
const std::map<std::uint32_t, std::string>& labels,
|
||||
const std::vector<NamedValue>& namedValues,
|
||||
bool showDefaultValue
|
||||
);
|
||||
void addModuleListItemValue(
|
||||
HocClkModule module,
|
||||
const std::string& categoryName,
|
||||
std::uint32_t min,
|
||||
std::uint32_t max,
|
||||
std::uint32_t step,
|
||||
const std::string& suffix,
|
||||
std::uint32_t divisor,
|
||||
int decimalPlaces,
|
||||
ValueThresholds thresholds = {},
|
||||
const std::vector<NamedValue>& namedValues = {},
|
||||
bool showDefaultValue = true
|
||||
);
|
||||
std::map<HocClkModule, std::tuple<std::string, std::uint32_t, int>> customFormatModules;
|
||||
tsl::elm::ListItem *listItems[HocClkModule_EnumMax];
|
||||
std::uint32_t listHz[HocClkModule_EnumMax];
|
||||
void openFreqChoiceGui(HocClkModule module);
|
||||
void addGovernorSection();
|
||||
void addModuleListItem(HocClkModule module);
|
||||
void addModuleToggleItem(HocClkModule module);
|
||||
void openValueChoiceGui(tsl::elm::ListItem *listItem, std::uint32_t currentValue, const ValueRange &range, const std::string &categoryName,
|
||||
ValueChoiceListener listener, const ValueThresholds &thresholds, bool enableThresholds,
|
||||
const std::map<std::uint32_t, std::string> &labels, const std::vector<NamedValue> &namedValues, bool showDefaultValue);
|
||||
void addModuleListItemValue(HocClkModule module, const std::string &categoryName, std::uint32_t min, std::uint32_t max, std::uint32_t step,
|
||||
const std::string &suffix, std::uint32_t divisor, int decimalPlaces, ValueThresholds thresholds = {},
|
||||
const std::vector<NamedValue> &namedValues = {}, bool showDefaultValue = true);
|
||||
|
||||
public:
|
||||
GlobalOverrideGui();
|
||||
~GlobalOverrideGui() {}
|
||||
void listUI() override;
|
||||
void refresh() override;
|
||||
void setModuleCustomFormat(HocClkModule module, const std::string& suffix, std::uint32_t divisor, int decimalPlaces);
|
||||
GlobalOverrideGui();
|
||||
~GlobalOverrideGui() {
|
||||
}
|
||||
void listUI() override;
|
||||
void refresh() override;
|
||||
void setModuleCustomFormat(HocClkModule module, const std::string &suffix, std::uint32_t divisor, int decimalPlaces);
|
||||
};
|
||||
@@ -16,72 +16,70 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "info_gui.h"
|
||||
#include "ult_ext.h"
|
||||
#include <sstream>
|
||||
|
||||
InfoGui::InfoGui(std::string title, std::vector<std::string> strings)
|
||||
: m_title(std::move(title)), m_strings(std::move(strings)) {}
|
||||
#include "info_gui.h"
|
||||
#include "ult_ext.h"
|
||||
|
||||
static constexpr s32 TEXT_SIZE = 16;
|
||||
static constexpr s32 LINE_H = 22;
|
||||
static constexpr s32 PARA_GAP = 10;
|
||||
static constexpr s32 MARGIN_L = 20;
|
||||
static constexpr s32 MARGIN_R = 35;
|
||||
InfoGui::InfoGui(std::string title, std::vector<std::string> strings) : m_title(std::move(title)), m_strings(std::move(strings)) {
|
||||
}
|
||||
|
||||
static std::vector<std::string> wrapText(const std::string& text, s32 maxWidth)
|
||||
{
|
||||
static constexpr s32 TEXT_SIZE = 16;
|
||||
static constexpr s32 LINE_H = 22;
|
||||
static constexpr s32 PARA_GAP = 10;
|
||||
static constexpr s32 MARGIN_L = 20;
|
||||
static constexpr s32 MARGIN_R = 35;
|
||||
|
||||
static std::vector<std::string> wrapText(const std::string &text, s32 maxWidth) {
|
||||
constexpr float CHAR_W = 10.0f;
|
||||
|
||||
// Preserve leading whitespace as an indent prefix for wrapped continuation lines.
|
||||
std::string indent;
|
||||
for (char c : text) {
|
||||
if (c == ' ') indent += ' ';
|
||||
else break;
|
||||
if (c == ' ')
|
||||
indent += ' ';
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
std::vector<std::string> lines;
|
||||
std::istringstream ss(text);
|
||||
std::string word, line = indent; // seed with indent so first word inherits it
|
||||
std::string word, line = indent; // seed with indent so first word inherits it
|
||||
bool first = true;
|
||||
while (ss >> word) {
|
||||
std::string candidate = (first && !indent.empty()) ? indent + word
|
||||
: line.empty() ? word
|
||||
: line + " " + word;
|
||||
std::string candidate = (first && !indent.empty()) ? indent + word : line.empty() ? word : line + " " + word;
|
||||
first = false;
|
||||
if (static_cast<s32>(candidate.size() * CHAR_W) <= maxWidth)
|
||||
line = std::move(candidate);
|
||||
else {
|
||||
if (!line.empty() && line != indent) lines.push_back(line);
|
||||
if (!line.empty() && line != indent)
|
||||
lines.push_back(line);
|
||||
line = indent + word;
|
||||
}
|
||||
}
|
||||
if (!line.empty() && line != indent) lines.push_back(line);
|
||||
if (lines.empty()) lines.emplace_back("");
|
||||
if (!line.empty() && line != indent)
|
||||
lines.push_back(line);
|
||||
if (lines.empty())
|
||||
lines.emplace_back("");
|
||||
return lines;
|
||||
}
|
||||
|
||||
void InfoGui::listUI()
|
||||
{
|
||||
void InfoGui::listUI() {
|
||||
this->listElement->addItem(new tsl::elm::CategoryHeader(m_title));
|
||||
|
||||
const s32 maxWidth = tsl::cfg::FramebufferWidth - MARGIN_L - MARGIN_R;
|
||||
|
||||
for (const auto& para : m_strings) {
|
||||
for (const auto& lineText : wrapText(para, maxWidth)) {
|
||||
auto* d = new FocusableDrawer(
|
||||
[lineText](tsl::gfx::Renderer* r, s32 x, s32 y, s32 w, s32 h) {
|
||||
r->drawString((lineText + "\n").c_str(), false,
|
||||
x + MARGIN_L, y + LINE_H - 5,
|
||||
TEXT_SIZE, tsl::style::color::ColorText);
|
||||
});
|
||||
for (const auto ¶ : m_strings) {
|
||||
for (const auto &lineText : wrapText(para, maxWidth)) {
|
||||
auto *d = new FocusableDrawer([lineText](tsl::gfx::Renderer *r, s32 x, s32 y, s32 w, s32 h) {
|
||||
r->drawString((lineText + "\n").c_str(), false, x + MARGIN_L, y + LINE_H - 5, TEXT_SIZE, tsl::style::color::ColorText);
|
||||
});
|
||||
d->setBoundaries(0, 0, tsl::cfg::FramebufferWidth, LINE_H);
|
||||
this->listElement->addItem(d, LINE_H);
|
||||
}
|
||||
|
||||
// paragraph gap
|
||||
auto* gap = new tsl::elm::CustomDrawer(
|
||||
[](tsl::gfx::Renderer*, s32, s32, s32, s32) {});
|
||||
auto *gap = new tsl::elm::CustomDrawer([](tsl::gfx::Renderer *, s32, s32, s32, s32) {});
|
||||
gap->setBoundaries(0, 0, tsl::cfg::FramebufferWidth, PARA_GAP);
|
||||
this->listElement->addItem(gap, PARA_GAP);
|
||||
}
|
||||
|
||||
@@ -16,18 +16,18 @@
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#include "base_menu_gui.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class InfoGui : public BaseMenuGui
|
||||
{
|
||||
public:
|
||||
#include "base_menu_gui.h"
|
||||
|
||||
class InfoGui : public BaseMenuGui {
|
||||
public:
|
||||
InfoGui(std::string title, std::vector<std::string> strings);
|
||||
~InfoGui() = default;
|
||||
void listUI() override;
|
||||
|
||||
private:
|
||||
private:
|
||||
std::string m_title;
|
||||
std::vector<std::string> m_strings;
|
||||
};
|
||||
|
||||
@@ -12,140 +12,73 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
std::map<uint32_t, std::string> cpu_freq_label_m = {
|
||||
{612000000, "Sleep Mode"},
|
||||
{1020000000, "Stock"},
|
||||
{1224000000, "Dev OC"},
|
||||
{1785000000, "Boost Mode"},
|
||||
{1963000000, "Safe Max"},
|
||||
{2397000000, "Unsafe Max"},
|
||||
{2703000000, "Absolute Max"},
|
||||
{ 612000000, "Sleep Mode" }, { 1020000000, "Stock" }, { 1224000000, "Dev OC" }, { 1785000000, "Boost Mode" },
|
||||
{ 1963000000, "Safe Max" }, { 2397000000, "Unsafe Max" }, { 2703000000, "Absolute Max" },
|
||||
};
|
||||
|
||||
std::map<uint32_t, std::string> cpu_freq_label_m_uv = {
|
||||
{612000000, "Sleep Mode"},
|
||||
{1020000000, "Stock"},
|
||||
{1224000000, "Dev OC"},
|
||||
{1785000000, "Boost Mode"},
|
||||
{2397000000, "Safe Max"},
|
||||
{2499000000, "Unsafe Max"},
|
||||
{2703000000, "Absolute Max"},
|
||||
{ 612000000, "Sleep Mode" }, { 1020000000, "Stock" }, { 1224000000, "Dev OC" }, { 1785000000, "Boost Mode" },
|
||||
{ 2397000000, "Safe Max" }, { 2499000000, "Unsafe Max" }, { 2703000000, "Absolute Max" },
|
||||
};
|
||||
|
||||
std::map<uint32_t, std::string> cpu_freq_label_e = {
|
||||
{612000000, "Sleep Mode"},
|
||||
{1020000000, "Stock"},
|
||||
{1224000000, "Dev OC"},
|
||||
{1785000000, "Safe Max"},
|
||||
{2091000000, "Unsafe Max"},
|
||||
{2397000000, "Absolute Max"},
|
||||
{ 612000000, "Sleep Mode" }, { 1020000000, "Stock" }, { 1224000000, "Dev OC" },
|
||||
{ 1785000000, "Safe Max" }, { 2091000000, "Unsafe Max" }, { 2397000000, "Absolute Max" },
|
||||
};
|
||||
|
||||
std::map<uint32_t, std::string> cpu_freq_label_e_uv = {
|
||||
{612000000, "Sleep Mode"},
|
||||
{1020000000, "Stock"},
|
||||
{1224000000, "Dev OC"},
|
||||
{1785000000, "Boost Mode"},
|
||||
{2091000000, "Safe Max"},
|
||||
{2193000000, "Unsafe Max"},
|
||||
{2397000000, "Absolute Max"},
|
||||
{ 612000000, "Sleep Mode" }, { 1020000000, "Stock" }, { 1224000000, "Dev OC" }, { 1785000000, "Boost Mode" },
|
||||
{ 2091000000, "Safe Max" }, { 2193000000, "Unsafe Max" }, { 2397000000, "Absolute Max" },
|
||||
};
|
||||
|
||||
|
||||
std::map<uint32_t, std::string> gpu_freq_label_e = {
|
||||
{76800000, "Boost Mode"},
|
||||
{307200000, "Handheld"},
|
||||
{345600000, "Handheld"},
|
||||
{384000000, "Handheld"},
|
||||
{422400000, "Handheld"},
|
||||
{460800000, "Handheld Safe Max"},
|
||||
{768000000, "Docked"},
|
||||
{921600000, "Safe Max"},
|
||||
{960000000, "Unsafe Max"},
|
||||
{1075200000, "Absolute Max"},
|
||||
{ 76800000, "Boost Mode" }, { 307200000, "Handheld" }, { 345600000, "Handheld" }, { 384000000, "Handheld" },
|
||||
{ 422400000, "Handheld" }, { 460800000, "Handheld Safe Max" }, { 768000000, "Docked" }, { 921600000, "Safe Max" },
|
||||
{ 960000000, "Unsafe Max" }, { 1075200000, "Absolute Max" },
|
||||
};
|
||||
|
||||
std::map<uint32_t, std::string> gpu_freq_label_e_uv = {
|
||||
{76800000, "Boost Mode"},
|
||||
{307200000, "Handheld"},
|
||||
{345600000, "Handheld"},
|
||||
{384000000, "Handheld"},
|
||||
{422400000, "Handheld"},
|
||||
{460800000, "Handheld Safe Max"},
|
||||
{768000000, "Docked"},
|
||||
{960000000, "Safe Max"},
|
||||
{1075200000, "Absolute Max"},
|
||||
{ 76800000, "Boost Mode" }, { 307200000, "Handheld" }, { 345600000, "Handheld" },
|
||||
{ 384000000, "Handheld" }, { 422400000, "Handheld" }, { 460800000, "Handheld Safe Max" },
|
||||
{ 768000000, "Docked" }, { 960000000, "Safe Max" }, { 1075200000, "Absolute Max" },
|
||||
};
|
||||
|
||||
std::map<uint32_t, std::string> gpu_freq_label_m = {
|
||||
{76800000, "Boost Mode"},
|
||||
{307200000, "Handheld"},
|
||||
{345600000, "Handheld"},
|
||||
{384000000, "Handheld"},
|
||||
{422400000, "Handheld"},
|
||||
{460800000, "Handheld"},
|
||||
{614400000, "Handheld Safe Max"},
|
||||
{768000000, "Docked"},
|
||||
{998400000, "Safe Max"},
|
||||
{ 76800000, "Boost Mode" }, { 307200000, "Handheld" }, { 345600000, "Handheld" }, { 384000000, "Handheld" }, { 422400000, "Handheld" },
|
||||
{ 460800000, "Handheld" }, { 614400000, "Handheld Safe Max" }, { 768000000, "Docked" }, { 998400000, "Safe Max" },
|
||||
};
|
||||
|
||||
std::map<uint32_t, std::string> gpu_freq_label_m_slt = {
|
||||
{76800000, "Boost Mode"},
|
||||
{307200000, "Handheld"},
|
||||
{345600000, "Handheld"},
|
||||
{384000000, "Handheld"},
|
||||
{422400000, "Handheld"},
|
||||
{460800000, "Handheld"},
|
||||
{614400000, "Handheld Safe Max"},
|
||||
{768000000, "Docked"},
|
||||
{1075200000, "Safe Max"},
|
||||
{1305600000, "Unsafe Max"},
|
||||
{1536000000, "Absolute Max"},
|
||||
{ 76800000, "Boost Mode" }, { 307200000, "Handheld" }, { 345600000, "Handheld" }, { 384000000, "Handheld" },
|
||||
{ 422400000, "Handheld" }, { 460800000, "Handheld" }, { 614400000, "Handheld Safe Max" }, { 768000000, "Docked" },
|
||||
{ 1075200000, "Safe Max" }, { 1305600000, "Unsafe Max" }, { 1536000000, "Absolute Max" },
|
||||
};
|
||||
|
||||
std::map<uint32_t, std::string> gpu_freq_label_m_hiopt = {
|
||||
{76800000, "Boost Mode"},
|
||||
{307200000, "Handheld"},
|
||||
{345600000, "Handheld"},
|
||||
{384000000, "Handheld"},
|
||||
{422400000, "Handheld"},
|
||||
{460800000, "Handheld"},
|
||||
{614400000, "Handheld Safe Max"},
|
||||
{768000000, "Docked"},
|
||||
{1152000000, "Safe Max"},
|
||||
{1305600000, "Unsafe Max"},
|
||||
{1536000000, "Absolute Max"},
|
||||
{ 76800000, "Boost Mode" }, { 307200000, "Handheld" }, { 345600000, "Handheld" }, { 384000000, "Handheld" },
|
||||
{ 422400000, "Handheld" }, { 460800000, "Handheld" }, { 614400000, "Handheld Safe Max" }, { 768000000, "Docked" },
|
||||
{ 1152000000, "Safe Max" }, { 1305600000, "Unsafe Max" }, { 1536000000, "Absolute Max" },
|
||||
};
|
||||
|
||||
std::map<uint32_t, std::string> gpu_freq_label_m_highuv = {
|
||||
{76800000, "Boost Mode"},
|
||||
{307200000, "Handheld"},
|
||||
{384000000, "Handheld"},
|
||||
{460800000, "Handheld"},
|
||||
{614400000, "Handheld Safe Max"},
|
||||
{768000000, "Docked"},
|
||||
{1228800000, "Safe Max"},
|
||||
{1305600000, "Unsafe Max"},
|
||||
{1536000000, "Absolute Max"},
|
||||
{ 76800000, "Boost Mode" }, { 307200000, "Handheld" }, { 384000000, "Handheld" },
|
||||
{ 460800000, "Handheld" }, { 614400000, "Handheld Safe Max" }, { 768000000, "Docked" },
|
||||
{ 1228800000, "Safe Max" }, { 1305600000, "Unsafe Max" }, { 1536000000, "Absolute Max" },
|
||||
};
|
||||
|
||||
std::map<uint32_t, std::string>* marikoUV[5] {
|
||||
&gpu_freq_label_m,
|
||||
&gpu_freq_label_m_slt,
|
||||
&gpu_freq_label_m_hiopt,
|
||||
&gpu_freq_label_m_hiopt,
|
||||
&gpu_freq_label_m_highuv,
|
||||
std::map<uint32_t, std::string> *marikoUV[5]{
|
||||
&gpu_freq_label_m, &gpu_freq_label_m_slt, &gpu_freq_label_m_hiopt, &gpu_freq_label_m_hiopt, &gpu_freq_label_m_highuv,
|
||||
};
|
||||
|
||||
|
||||
std::map<uint32_t, std::string>* eristaUV[3] {
|
||||
std::map<uint32_t, std::string> *eristaUV[3]{
|
||||
&gpu_freq_label_e,
|
||||
&gpu_freq_label_e_uv,
|
||||
&gpu_freq_label_e_uv,
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
@@ -24,25 +24,23 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "main_gui.h"
|
||||
|
||||
#include "fatal_gui.h"
|
||||
#include "app_profile_gui.h"
|
||||
#include "global_override_gui.h"
|
||||
#include "misc_gui.h"
|
||||
#include "about_gui.h"
|
||||
#include "app_profile_gui.h"
|
||||
#include "fatal_gui.h"
|
||||
#include "global_override_gui.h"
|
||||
#include "main_gui.h"
|
||||
#include "misc_gui.h"
|
||||
#include "ult_ext.h"
|
||||
|
||||
tsl::elm::Element* MainGui::baseUI() {
|
||||
auto* list = new BoxClippedList();
|
||||
|
||||
tsl::elm::Element *MainGui::baseUI() {
|
||||
auto *list = new BoxClippedList();
|
||||
this->listElement = list;
|
||||
this->listUI();
|
||||
return list;
|
||||
}
|
||||
|
||||
void MainGui::listUI()
|
||||
{
|
||||
void MainGui::listUI() {
|
||||
// this->enabledToggle = new tsl::elm::ToggleListItem("Enable", false);
|
||||
// enabledToggle->setStateChangedListener([this](bool state) {
|
||||
// Result rc = hocclkIpcSetEnabled(state);
|
||||
@@ -56,10 +54,9 @@ void MainGui::listUI()
|
||||
// });
|
||||
// this->listElement->addItem(this->enabledToggle);
|
||||
|
||||
tsl::elm::ListItem* appProfileItem = new tsl::elm::ListItem("Edit App Profile");
|
||||
tsl::elm::ListItem *appProfileItem = new tsl::elm::ListItem("Edit App Profile");
|
||||
appProfileItem->setClickListener([this](u64 keys) {
|
||||
if((keys & HidNpadButton_A) == HidNpadButton_A && this->context)
|
||||
{
|
||||
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->context) {
|
||||
AppProfileGui::changeTo(this->context->applicationId);
|
||||
return true;
|
||||
}
|
||||
@@ -68,11 +65,9 @@ void MainGui::listUI()
|
||||
});
|
||||
this->listElement->addItem(appProfileItem);
|
||||
|
||||
|
||||
tsl::elm::ListItem* globalProfileItem = new tsl::elm::ListItem("Edit Global Profile");
|
||||
tsl::elm::ListItem *globalProfileItem = new tsl::elm::ListItem("Edit Global Profile");
|
||||
globalProfileItem->setClickListener([this](u64 keys) {
|
||||
if((keys & HidNpadButton_A) == HidNpadButton_A && this->context)
|
||||
{
|
||||
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->context) {
|
||||
AppProfileGui::changeTo(HOCCLK_GLOBAL_PROFILE_TID);
|
||||
return true;
|
||||
}
|
||||
@@ -81,10 +76,9 @@ void MainGui::listUI()
|
||||
});
|
||||
this->listElement->addItem(globalProfileItem);
|
||||
|
||||
tsl::elm::ListItem* globalOverrideItem = new tsl::elm::ListItem("Temporary Overrides");
|
||||
tsl::elm::ListItem *globalOverrideItem = new tsl::elm::ListItem("Temporary Overrides");
|
||||
globalOverrideItem->setClickListener([this](u64 keys) {
|
||||
if((keys & HidNpadButton_A) == HidNpadButton_A && this->context)
|
||||
{
|
||||
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->context) {
|
||||
tsl::changeTo<GlobalOverrideGui>();
|
||||
return true;
|
||||
}
|
||||
@@ -93,12 +87,11 @@ void MainGui::listUI()
|
||||
});
|
||||
this->listElement->addItem(globalOverrideItem);
|
||||
|
||||
//this->listElement->addItem(new tsl::elm::CategoryHeader("Misc"));
|
||||
// this->listElement->addItem(new tsl::elm::CategoryHeader("Misc"));
|
||||
|
||||
tsl::elm::ListItem* miscItem = new tsl::elm::ListItem("Settings");
|
||||
tsl::elm::ListItem *miscItem = new tsl::elm::ListItem("Settings");
|
||||
miscItem->setClickListener([this](u64 keys) {
|
||||
if((keys & HidNpadButton_A) == HidNpadButton_A && this->context)
|
||||
{
|
||||
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->context) {
|
||||
tsl::changeTo<MiscGui>();
|
||||
return true;
|
||||
}
|
||||
@@ -107,10 +100,9 @@ void MainGui::listUI()
|
||||
});
|
||||
this->listElement->addItem(miscItem);
|
||||
|
||||
tsl::elm::ListItem* aboutItem = new tsl::elm::ListItem("About");
|
||||
tsl::elm::ListItem *aboutItem = new tsl::elm::ListItem("About");
|
||||
aboutItem->setClickListener([this](u64 keys) {
|
||||
if((keys & HidNpadButton_A) == HidNpadButton_A && this->context)
|
||||
{
|
||||
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->context) {
|
||||
tsl::changeTo<AboutGui>();
|
||||
return true;
|
||||
}
|
||||
@@ -118,14 +110,12 @@ void MainGui::listUI()
|
||||
return false;
|
||||
});
|
||||
this->listElement->addItem(aboutItem);
|
||||
|
||||
}
|
||||
|
||||
void MainGui::refresh()
|
||||
{
|
||||
void MainGui::refresh() {
|
||||
BaseMenuGui::refresh();
|
||||
//if(this->context)
|
||||
// if(this->context)
|
||||
//{
|
||||
// this->enabledToggle->setState(this->context->enabled);
|
||||
//}
|
||||
// this->enabledToggle->setState(this->context->enabled);
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
@@ -24,18 +24,20 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "base_menu_gui.h"
|
||||
|
||||
class MainGui : public BaseMenuGui
|
||||
{
|
||||
class MainGui : public BaseMenuGui {
|
||||
public:
|
||||
MainGui() {}
|
||||
~MainGui() {}
|
||||
tsl::elm::Element* baseUI() override;
|
||||
void listUI() override;
|
||||
void refresh() override;
|
||||
u16 headerHeight() const override { return HOC_HEADER_HEIGHT - 25; }
|
||||
MainGui() {
|
||||
}
|
||||
~MainGui() {
|
||||
}
|
||||
tsl::elm::Element *baseUI() override;
|
||||
void listUI() override;
|
||||
void refresh() override;
|
||||
u16 headerHeight() const override {
|
||||
return HOC_HEADER_HEIGHT - 25;
|
||||
}
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,67 +16,51 @@
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#include "../../ipc.h"
|
||||
#include "base_menu_gui.h"
|
||||
#include <initializer_list>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../../ipc.h"
|
||||
#include "base_menu_gui.h"
|
||||
#include "freq_choice_gui.h"
|
||||
#include "value_choice_gui.h"
|
||||
#include "info_gui.h"
|
||||
class MiscGui : public BaseMenuGui
|
||||
{
|
||||
public:
|
||||
#include "value_choice_gui.h"
|
||||
#include <initializer_list>
|
||||
#include <unordered_map>
|
||||
class MiscGui : public BaseMenuGui {
|
||||
public:
|
||||
MiscGui();
|
||||
~MiscGui();
|
||||
void listUI() override;
|
||||
void refresh() override;
|
||||
|
||||
protected:
|
||||
HocClkConfigValueList* configList;
|
||||
std::map<HocClkConfigValue, tsl::elm::ListItem*> configButtons;
|
||||
protected:
|
||||
HocClkConfigValueList *configList;
|
||||
std::map<HocClkConfigValue, tsl::elm::ListItem *> configButtons;
|
||||
std::map<HocClkConfigValue, ValueRange> configRanges;
|
||||
std::map<HocClkConfigValue, std::vector<NamedValue>> configNamedValues;
|
||||
std::map<HocClkConfigValue, tsl::elm::ToggleListItem*> configToggles;
|
||||
std::map<HocClkConfigValue, std::tuple<tsl::elm::TrackBar*, tsl::elm::ListItem*, std::vector<uint64_t>>> configTrackbars;
|
||||
std::map<HocClkConfigValue, tsl::elm::ToggleListItem *> configToggles;
|
||||
std::map<HocClkConfigValue, std::tuple<tsl::elm::TrackBar *, tsl::elm::ListItem *, std::vector<uint64_t>>> configTrackbars;
|
||||
std::set<HocClkConfigValue> configButtonSKeys;
|
||||
std::map<HocClkConfigValue, std::string> configButtonSSubtext;
|
||||
std::set<HocClkConfigValue> emcClockConfigs;
|
||||
|
||||
void addConfigToggle(HocClkConfigValue configVal, const char* altName, bool kip = false);
|
||||
void addConfigTrackbar(HocClkConfigValue configVal, const char* altName, const ValueRange& range, bool kip = true);
|
||||
void addMappedConfigTrackbar(HocClkConfigValue configVal, const char* altName,
|
||||
std::vector<u32> vals,
|
||||
std::initializer_list<std::string> names, bool kip = true);
|
||||
void addConfigButton(HocClkConfigValue configVal,
|
||||
const char* altName,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
const ValueThresholds* thresholds,
|
||||
const std::map<uint32_t, std::string>& labels = {},
|
||||
const std::vector<NamedValue>& namedValues = {},
|
||||
bool showDefaultValue = true,
|
||||
bool kip = false);
|
||||
void addConfigToggle(HocClkConfigValue configVal, const char *altName, bool kip = false);
|
||||
void addConfigTrackbar(HocClkConfigValue configVal, const char *altName, const ValueRange &range, bool kip = true);
|
||||
void addMappedConfigTrackbar(HocClkConfigValue configVal, const char *altName, std::vector<u32> vals, std::initializer_list<std::string> names,
|
||||
bool kip = true);
|
||||
void addConfigButton(HocClkConfigValue configVal, const char *altName, const ValueRange &range, const std::string &categoryName,
|
||||
const ValueThresholds *thresholds, const std::map<uint32_t, std::string> &labels = {},
|
||||
const std::vector<NamedValue> &namedValues = {}, bool showDefaultValue = true, bool kip = false);
|
||||
|
||||
void addConfigButtonS(HocClkConfigValue configVal,
|
||||
const char* altName,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
const ValueThresholds* thresholds,
|
||||
const std::map<uint32_t, std::string>& labels = {},
|
||||
const std::vector<NamedValue>& namedValues = {},
|
||||
bool showDefaultValue = true,
|
||||
const char* subText = nullptr,
|
||||
bool kip = false);
|
||||
void addFreqButton(HocClkConfigValue configVal,
|
||||
const char* altName,
|
||||
HocClkModule module,
|
||||
const std::map<uint32_t, std::string>& labels = {});
|
||||
void addConfigButtonS(HocClkConfigValue configVal, const char *altName, const ValueRange &range, const std::string &categoryName,
|
||||
const ValueThresholds *thresholds, const std::map<uint32_t, std::string> &labels = {},
|
||||
const std::vector<NamedValue> &namedValues = {}, bool showDefaultValue = true, const char *subText = nullptr,
|
||||
bool kip = false);
|
||||
void addFreqButton(HocClkConfigValue configVal, const char *altName, HocClkModule module, const std::map<uint32_t, std::string> &labels = {});
|
||||
void updateConfigToggles();
|
||||
|
||||
tsl::elm::ToggleListItem* enabledToggle;
|
||||
tsl::elm::ToggleListItem *enabledToggle;
|
||||
u8 frameCounter = 60;
|
||||
bool shouldSaveKip = false;
|
||||
};
|
||||
|
||||
@@ -12,20 +12,24 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <tesla.hpp>
|
||||
|
||||
#include "../elements/base_frame.h"
|
||||
|
||||
|
||||
class TopAnchoredList : public tsl::elm::List {
|
||||
public:
|
||||
TopAnchoredList() { m_hasSetInitialFocusHack = true; }
|
||||
public:
|
||||
TopAnchoredList() {
|
||||
m_hasSetInitialFocusHack = true;
|
||||
}
|
||||
};
|
||||
class BoxClippedList : public tsl::elm::List {
|
||||
public:
|
||||
void draw(tsl::gfx::Renderer* renderer) override {
|
||||
public:
|
||||
void draw(tsl::gfx::Renderer *renderer) override {
|
||||
renderer->enableScissoring(0, HOC_BOX_BOTTOM, tsl::cfg::FramebufferWidth, tsl::cfg::FramebufferHeight - HOC_BOX_BOTTOM);
|
||||
tsl::elm::List::draw(renderer);
|
||||
renderer->disableScissoring();
|
||||
@@ -33,41 +37,37 @@ public:
|
||||
};
|
||||
|
||||
class CompactCategoryHeader : public tsl::elm::CategoryHeader {
|
||||
public:
|
||||
CompactCategoryHeader(const std::string& text) : tsl::elm::CategoryHeader(text) {}
|
||||
public:
|
||||
CompactCategoryHeader(const std::string &text) : tsl::elm::CategoryHeader(text) {
|
||||
}
|
||||
void layout(u16 parentX, u16 parentY, u16 parentWidth, u16 parentHeight) override {
|
||||
this->setBoundaries(this->getX(), this->getY(), this->getWidth(), 33);
|
||||
}
|
||||
};
|
||||
|
||||
class ImageElement : public tsl::elm::ListItem {
|
||||
private:
|
||||
const uint8_t* imgData;
|
||||
private:
|
||||
const uint8_t *imgData;
|
||||
uint32_t imgWidth, imgHeight;
|
||||
bool visible;
|
||||
|
||||
public:
|
||||
ImageElement(const uint8_t* data, uint32_t w, uint32_t h)
|
||||
: tsl::elm::ListItem(""), imgData(data), imgWidth(w), imgHeight(h), visible(true) {}
|
||||
|
||||
|
||||
public:
|
||||
ImageElement(const uint8_t *data, uint32_t w, uint32_t h) : tsl::elm::ListItem(""), imgData(data), imgWidth(w), imgHeight(h), visible(true) {
|
||||
}
|
||||
|
||||
void setVisible(bool v) {
|
||||
visible = v;
|
||||
}
|
||||
|
||||
|
||||
virtual void draw(tsl::gfx::Renderer *renderer) override {
|
||||
if (!visible) return;
|
||||
|
||||
if (!visible)
|
||||
return;
|
||||
|
||||
// Draw image centered horizontally
|
||||
u16 centerX = this->getX() + (this->getWidth() - imgWidth) / 2;
|
||||
renderer->drawBitmap(
|
||||
centerX,
|
||||
this->getY() + 10,
|
||||
imgWidth,
|
||||
imgHeight,
|
||||
imgData
|
||||
);
|
||||
renderer->drawBitmap(centerX, this->getY() + 10, imgWidth, imgHeight, imgData);
|
||||
}
|
||||
|
||||
|
||||
virtual void layout(u16 parentX, u16 parentY, u16 parentWidth, u16 parentHeight) override {
|
||||
if (!visible) {
|
||||
// Take up no space when hidden
|
||||
@@ -77,37 +77,38 @@ public:
|
||||
tsl::elm::ListItem::layout(parentX, parentY, parentWidth, parentHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual void drawHighlight(tsl::gfx::Renderer *renderer) override {
|
||||
// Do nothing - no highlight
|
||||
}
|
||||
|
||||
|
||||
virtual bool onClick(u64 keys) override {
|
||||
return false; // Non-clickable
|
||||
return false; // Non-clickable
|
||||
}
|
||||
|
||||
virtual Element* requestFocus(Element *oldFocus, tsl::FocusDirection direction) override {
|
||||
return nullptr; // Make it non-focusable
|
||||
|
||||
virtual Element *requestFocus(Element *oldFocus, tsl::FocusDirection direction) override {
|
||||
return nullptr; // Make it non-focusable
|
||||
}
|
||||
};
|
||||
|
||||
class HideableCategoryHeader : public tsl::elm::CategoryHeader {
|
||||
private:
|
||||
private:
|
||||
bool visible;
|
||||
|
||||
public:
|
||||
HideableCategoryHeader(const std::string& title)
|
||||
: tsl::elm::CategoryHeader(title), visible(true) {}
|
||||
|
||||
|
||||
public:
|
||||
HideableCategoryHeader(const std::string &title) : tsl::elm::CategoryHeader(title), visible(true) {
|
||||
}
|
||||
|
||||
void setVisible(bool v) {
|
||||
visible = v;
|
||||
}
|
||||
|
||||
|
||||
virtual void draw(tsl::gfx::Renderer *renderer) override {
|
||||
if (!visible) return;
|
||||
if (!visible)
|
||||
return;
|
||||
tsl::elm::CategoryHeader::draw(renderer);
|
||||
}
|
||||
|
||||
|
||||
virtual void layout(u16 parentX, u16 parentY, u16 parentWidth, u16 parentHeight) override {
|
||||
if (!visible) {
|
||||
this->setBoundaries(parentX, parentY, 0, 0);
|
||||
@@ -118,34 +119,34 @@ public:
|
||||
};
|
||||
|
||||
class FocusableDrawer : public tsl::elm::CustomDrawer {
|
||||
public:
|
||||
template<typename... Args>
|
||||
FocusableDrawer(Args&&... args) : tsl::elm::CustomDrawer(std::forward<Args>(args)...) {
|
||||
public:
|
||||
template <typename... Args> FocusableDrawer(Args &&...args) : tsl::elm::CustomDrawer(std::forward<Args>(args)...) {
|
||||
m_isItem = true;
|
||||
}
|
||||
Element* requestFocus(Element*, tsl::FocusDirection) override {
|
||||
Element *requestFocus(Element *, tsl::FocusDirection) override {
|
||||
return this;
|
||||
}
|
||||
void drawHighlight(tsl::gfx::Renderer*) override {}
|
||||
void drawHighlight(tsl::gfx::Renderer *) override {
|
||||
}
|
||||
};
|
||||
|
||||
class HideableCustomDrawer : public tsl::elm::Element {
|
||||
private:
|
||||
private:
|
||||
bool visible;
|
||||
u32 height;
|
||||
|
||||
public:
|
||||
HideableCustomDrawer(u32 h)
|
||||
: Element(), visible(true), height(h) {}
|
||||
|
||||
|
||||
public:
|
||||
HideableCustomDrawer(u32 h) : Element(), visible(true), height(h) {
|
||||
}
|
||||
|
||||
void setVisible(bool v) {
|
||||
visible = v;
|
||||
}
|
||||
|
||||
|
||||
virtual void draw(tsl::gfx::Renderer *renderer) override {
|
||||
// Empty drawer - just for spacing
|
||||
}
|
||||
|
||||
|
||||
virtual void layout(u16 parentX, u16 parentY, u16 parentWidth, u16 parentHeight) override {
|
||||
if (!visible) {
|
||||
this->setBoundaries(parentX, parentY, 0, 0);
|
||||
@@ -153,8 +154,8 @@ public:
|
||||
this->setBoundaries(parentX, parentY, parentWidth, height);
|
||||
}
|
||||
}
|
||||
|
||||
virtual Element* requestFocus(Element *oldFocus, tsl::FocusDirection direction) override {
|
||||
|
||||
virtual Element *requestFocus(Element *oldFocus, tsl::FocusDirection direction) override {
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
@@ -16,44 +16,27 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "ult_ext.h"
|
||||
#include "value_choice_gui.h"
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
#include "../format.h"
|
||||
#include "fatal_gui.h"
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include "ult_ext.h"
|
||||
#include "value_choice_gui.h"
|
||||
|
||||
ValueChoiceGui::ValueChoiceGui(std::uint32_t selectedValue,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
ValueChoiceListener listener,
|
||||
const ValueThresholds& thresholds,
|
||||
bool enableThresholds,
|
||||
std::map<std::uint32_t, std::string> labels,
|
||||
std::vector<NamedValue> namedValues,
|
||||
bool showDefaultValue,
|
||||
bool showDNO)
|
||||
: selectedValue(selectedValue),
|
||||
range(range),
|
||||
categoryName(categoryName),
|
||||
listener(listener),
|
||||
thresholds(thresholds),
|
||||
enableThresholds(enableThresholds),
|
||||
labels(labels),
|
||||
namedValues(namedValues),
|
||||
showDefaultValue(showDefaultValue),
|
||||
showDNO(showDNO)
|
||||
{
|
||||
ValueChoiceGui::ValueChoiceGui(std::uint32_t selectedValue, const ValueRange &range, const std::string &categoryName, ValueChoiceListener listener,
|
||||
const ValueThresholds &thresholds, bool enableThresholds, std::map<std::uint32_t, std::string> labels,
|
||||
std::vector<NamedValue> namedValues, bool showDefaultValue, bool showDNO)
|
||||
: selectedValue(selectedValue), range(range), categoryName(categoryName), listener(listener), thresholds(thresholds),
|
||||
enableThresholds(enableThresholds), labels(labels), namedValues(namedValues), showDefaultValue(showDefaultValue), showDNO(showDNO) {
|
||||
}
|
||||
|
||||
ValueChoiceGui::~ValueChoiceGui()
|
||||
{
|
||||
ValueChoiceGui::~ValueChoiceGui() {
|
||||
}
|
||||
|
||||
std::string ValueChoiceGui::formatValue(std::uint32_t value)
|
||||
{
|
||||
std::string ValueChoiceGui::formatValue(std::uint32_t value) {
|
||||
std::ostringstream oss;
|
||||
if(showDefaultValue) {
|
||||
if (showDefaultValue) {
|
||||
if (value == 0) {
|
||||
return this->showDNO ? FREQ_DEFAULT_TEXT : VALUE_DEFAULT_TEXT;
|
||||
}
|
||||
@@ -66,12 +49,11 @@ std::string ValueChoiceGui::formatValue(std::uint32_t value)
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
int ValueChoiceGui::getSafetyLevel(std::uint32_t value)
|
||||
{
|
||||
if(thresholds.warning == 0 && thresholds.danger == 0) {
|
||||
int ValueChoiceGui::getSafetyLevel(std::uint32_t value) {
|
||||
if (thresholds.warning == 0 && thresholds.danger == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (value > thresholds.danger) {
|
||||
return 2;
|
||||
}
|
||||
@@ -81,8 +63,7 @@ int ValueChoiceGui::getSafetyLevel(std::uint32_t value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
tsl::elm::ListItem* ValueChoiceGui::createValueListItem(std::uint32_t value, bool selected, int safety)
|
||||
{
|
||||
tsl::elm::ListItem *ValueChoiceGui::createValueListItem(std::uint32_t value, bool selected, int safety) {
|
||||
std::string text = formatValue(value);
|
||||
std::string rightText = "";
|
||||
|
||||
@@ -92,34 +73,32 @@ tsl::elm::ListItem* ValueChoiceGui::createValueListItem(std::uint32_t value, boo
|
||||
}
|
||||
|
||||
if (selected) {
|
||||
const_cast<std::string&>(rightText) = "\uE14B";
|
||||
const_cast<std::string &>(rightText) = "\uE14B";
|
||||
}
|
||||
|
||||
tsl::elm::ListItem* listItem = new tsl::elm::ListItem(text, rightText, false);
|
||||
switch (safety)
|
||||
{
|
||||
case 0:
|
||||
listItem->setTextColor(tsl::Color(255, 255, 255, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 255, 255, 255));
|
||||
break;
|
||||
case 1:
|
||||
listItem->setTextColor(tsl::Color(255, 165, 0, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 165, 0, 255));
|
||||
break;
|
||||
case 2:
|
||||
listItem->setTextColor(tsl::Color(255, 0, 0, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 0, 0, 255));
|
||||
break;
|
||||
tsl::elm::ListItem *listItem = new tsl::elm::ListItem(text, rightText, false);
|
||||
switch (safety) {
|
||||
case 0:
|
||||
listItem->setTextColor(tsl::Color(255, 255, 255, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 255, 255, 255));
|
||||
break;
|
||||
case 1:
|
||||
listItem->setTextColor(tsl::Color(255, 165, 0, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 165, 0, 255));
|
||||
break;
|
||||
case 2:
|
||||
listItem->setTextColor(tsl::Color(255, 0, 0, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 0, 0, 255));
|
||||
break;
|
||||
}
|
||||
|
||||
// Make annotation grey
|
||||
if (!rightText.empty() && !selected)
|
||||
listItem->setValueColor(tsl::Color(180, 180, 180, 255));
|
||||
else if(selected)
|
||||
listItem->setValueColor(tsl::infoTextColor);
|
||||
|
||||
listItem->setClickListener([this, value](u64 keys)
|
||||
{
|
||||
else if (selected)
|
||||
listItem->setValueColor(tsl::infoTextColor);
|
||||
|
||||
listItem->setClickListener([this, value](u64 keys) {
|
||||
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->listener) {
|
||||
if (this->listener(value)) {
|
||||
tsl::goBack();
|
||||
@@ -131,37 +110,34 @@ tsl::elm::ListItem* ValueChoiceGui::createValueListItem(std::uint32_t value, boo
|
||||
return listItem;
|
||||
}
|
||||
|
||||
tsl::elm::ListItem* ValueChoiceGui::createNamedValueListItem(const NamedValue& namedValue, bool selected, int safety)
|
||||
{
|
||||
tsl::elm::ListItem *ValueChoiceGui::createNamedValueListItem(const NamedValue &namedValue, bool selected, int safety) {
|
||||
std::string text = namedValue.name;
|
||||
if (selected) {
|
||||
const_cast<std::string&>(namedValue.rightText) = "\uE14B";
|
||||
const_cast<std::string &>(namedValue.rightText) = "\uE14B";
|
||||
}
|
||||
|
||||
tsl::elm::ListItem* listItem = new tsl::elm::ListItem(text, namedValue.rightText, false);
|
||||
switch (safety)
|
||||
{
|
||||
case 0:
|
||||
listItem->setTextColor(tsl::Color(255, 255, 255, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 255, 255, 255));
|
||||
break;
|
||||
case 1:
|
||||
listItem->setTextColor(tsl::Color(255, 165, 0, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 165, 0, 255));
|
||||
break;
|
||||
case 2:
|
||||
listItem->setTextColor(tsl::Color(255, 0, 0, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 0, 0, 255));
|
||||
break;
|
||||
|
||||
tsl::elm::ListItem *listItem = new tsl::elm::ListItem(text, namedValue.rightText, false);
|
||||
switch (safety) {
|
||||
case 0:
|
||||
listItem->setTextColor(tsl::Color(255, 255, 255, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 255, 255, 255));
|
||||
break;
|
||||
case 1:
|
||||
listItem->setTextColor(tsl::Color(255, 165, 0, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 165, 0, 255));
|
||||
break;
|
||||
case 2:
|
||||
listItem->setTextColor(tsl::Color(255, 0, 0, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 0, 0, 255));
|
||||
break;
|
||||
}
|
||||
|
||||
if (!namedValue.rightText.empty() && !selected)
|
||||
listItem->setValueColor(tsl::Color(180, 180, 180, 255));
|
||||
else if(selected)
|
||||
listItem->setValueColor(tsl::infoTextColor);
|
||||
else if (selected)
|
||||
listItem->setValueColor(tsl::infoTextColor);
|
||||
|
||||
listItem->setClickListener([this, value = namedValue.value](u64 keys)
|
||||
{
|
||||
listItem->setClickListener([this, value = namedValue.value](u64 keys) {
|
||||
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->listener) {
|
||||
if (this->listener(value)) {
|
||||
tsl::goBack();
|
||||
@@ -173,8 +149,7 @@ tsl::elm::ListItem* ValueChoiceGui::createNamedValueListItem(const NamedValue& n
|
||||
return listItem;
|
||||
}
|
||||
|
||||
void ValueChoiceGui::listUI()
|
||||
{
|
||||
void ValueChoiceGui::listUI() {
|
||||
if (!categoryName.empty()) {
|
||||
this->listElement->addItem(new tsl::elm::CategoryHeader(categoryName));
|
||||
}
|
||||
@@ -182,20 +157,19 @@ void ValueChoiceGui::listUI()
|
||||
if (showDefaultValue) {
|
||||
this->listElement->addItem(this->createValueListItem(0, this->selectedValue == 0, 0));
|
||||
}
|
||||
for (const auto& namedValue : namedValues) {
|
||||
for (const auto &namedValue : namedValues) {
|
||||
int safety = enableThresholds ? getSafetyLevel(namedValue.value) : 0;
|
||||
bool selected = (namedValue.value == this->selectedValue);
|
||||
this->listElement->addItem(this->createNamedValueListItem(namedValue, selected, safety));
|
||||
}
|
||||
|
||||
|
||||
if (namedValues.empty()) {
|
||||
for (std::uint32_t value = range.min; value <= range.max; value += range.step)
|
||||
{
|
||||
for (std::uint32_t value = range.min; value <= range.max; value += range.step) {
|
||||
int safety = getSafetyLevel(value);
|
||||
bool selected = (value == this->selectedValue);
|
||||
this->listElement->addItem(this->createValueListItem(value, selected, safety));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this->listElement->jumpToItem("", "\uE14B");
|
||||
}
|
||||
@@ -17,11 +17,12 @@
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#include <list>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base_menu_gui.h"
|
||||
|
||||
using ValueChoiceListener = std::function<bool(std::uint32_t value)>;
|
||||
@@ -34,33 +35,32 @@ struct ValueRange {
|
||||
std::string suffix;
|
||||
std::uint32_t divisor;
|
||||
int decimalPlaces;
|
||||
ValueRange()
|
||||
: min(0), max(0), step(1), suffix(""), divisor(1), decimalPlaces(0) {}
|
||||
ValueRange(std::uint32_t min, std::uint32_t max, std::uint32_t step,
|
||||
const std::string& suffix = "", std::uint32_t divisor = 1, int decimalPlaces = 0)
|
||||
: min(min), max(max), step(step), suffix(suffix),
|
||||
divisor(divisor), decimalPlaces(decimalPlaces) {}
|
||||
ValueRange() : min(0), max(0), step(1), suffix(""), divisor(1), decimalPlaces(0) {
|
||||
}
|
||||
ValueRange(std::uint32_t min, std::uint32_t max, std::uint32_t step, const std::string &suffix = "", std::uint32_t divisor = 1,
|
||||
int decimalPlaces = 0)
|
||||
: min(min), max(max), step(step), suffix(suffix), divisor(divisor), decimalPlaces(decimalPlaces) {
|
||||
}
|
||||
};
|
||||
|
||||
struct ValueThresholds {
|
||||
std::uint32_t warning;
|
||||
std::uint32_t danger;
|
||||
ValueThresholds(std::uint32_t warning = 0, std::uint32_t danger = 0)
|
||||
: warning(warning), danger(danger) {}
|
||||
ValueThresholds(std::uint32_t warning = 0, std::uint32_t danger = 0) : warning(warning), danger(danger) {
|
||||
}
|
||||
};
|
||||
|
||||
struct NamedValue {
|
||||
std::string name;
|
||||
std::uint32_t value;
|
||||
std::string rightText;
|
||||
|
||||
NamedValue(const std::string& name, std::uint32_t value, const std::string& rightText = "")
|
||||
: name(name), value(value), rightText(rightText) {}
|
||||
|
||||
NamedValue(const std::string &name, std::uint32_t value, const std::string &rightText = "") : name(name), value(value), rightText(rightText) {
|
||||
}
|
||||
};
|
||||
|
||||
class ValueChoiceGui : public BaseMenuGui
|
||||
{
|
||||
protected:
|
||||
class ValueChoiceGui : public BaseMenuGui {
|
||||
protected:
|
||||
std::uint32_t selectedValue;
|
||||
ValueRange range;
|
||||
std::string categoryName;
|
||||
@@ -68,47 +68,37 @@ protected:
|
||||
ValueThresholds thresholds;
|
||||
bool enableThresholds;
|
||||
std::map<std::uint32_t, std::string> labels;
|
||||
|
||||
|
||||
std::vector<NamedValue> namedValues;
|
||||
bool showDefaultValue = true;
|
||||
bool showDNO = false;
|
||||
tsl::elm::ListItem* createValueListItem(std::uint32_t value, bool selected, int safety);
|
||||
tsl::elm::ListItem* createNamedValueListItem(const NamedValue& namedValue, bool selected, int safety);
|
||||
tsl::elm::ListItem *createValueListItem(std::uint32_t value, bool selected, int safety);
|
||||
tsl::elm::ListItem *createNamedValueListItem(const NamedValue &namedValue, bool selected, int safety);
|
||||
std::string formatValue(std::uint32_t value);
|
||||
int getSafetyLevel(std::uint32_t value);
|
||||
|
||||
public:
|
||||
ValueChoiceGui(std::uint32_t selectedValue,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
ValueChoiceListener listener,
|
||||
const ValueThresholds& thresholds = ValueThresholds(),
|
||||
bool enableThresholds = false,
|
||||
std::map<std::uint32_t, std::string> labels = {},
|
||||
std::vector<NamedValue> namedValues = {},
|
||||
bool showDefaultValue = true,
|
||||
|
||||
public:
|
||||
ValueChoiceGui(std::uint32_t selectedValue, const ValueRange &range, const std::string &categoryName, ValueChoiceListener listener,
|
||||
const ValueThresholds &thresholds = ValueThresholds(), bool enableThresholds = false,
|
||||
std::map<std::uint32_t, std::string> labels = {}, std::vector<NamedValue> namedValues = {}, bool showDefaultValue = true,
|
||||
bool showDNO = false);
|
||||
~ValueChoiceGui();
|
||||
|
||||
void addNamedValue(const std::string& name, std::uint32_t value, const std::string& rightText = "")
|
||||
{
|
||||
|
||||
void addNamedValue(const std::string &name, std::uint32_t value, const std::string &rightText = "") {
|
||||
namedValues.emplace_back(name, value, rightText);
|
||||
}
|
||||
|
||||
void addNamedValues(const std::vector<NamedValue>& values)
|
||||
{
|
||||
|
||||
void addNamedValues(const std::vector<NamedValue> &values) {
|
||||
namedValues.insert(namedValues.end(), values.begin(), values.end());
|
||||
}
|
||||
|
||||
void clearNamedValues()
|
||||
{
|
||||
|
||||
void clearNamedValues() {
|
||||
namedValues.clear();
|
||||
}
|
||||
|
||||
void setShowDefaultValue(bool show)
|
||||
{
|
||||
|
||||
void setShowDefaultValue(bool show) {
|
||||
showDefaultValue = show;
|
||||
}
|
||||
|
||||
|
||||
void listUI() override;
|
||||
};
|
||||
Reference in New Issue
Block a user