mirror of
https://github.com/HarbourMasters/2ship2harkinian.git
synced 2024-11-23 05:59:40 +00:00
Update the labels of flag checkboxes to hex values (#869)
* label weekeventreg by hex mask instead of index * update other flagArrays * consistency * display hex and dec * capitals * oops * oops 2
This commit is contained in:
parent
ce4bf1f4cc
commit
8c8b9ad591
@ -7,6 +7,7 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <libultraship/libultra/types.h>
|
#include <libultraship/libultra/types.h>
|
||||||
#include "2s2h/ShipUtils.h"
|
#include "2s2h/ShipUtils.h"
|
||||||
|
#include <spdlog/fmt/fmt.h>
|
||||||
|
|
||||||
namespace UIWidgets {
|
namespace UIWidgets {
|
||||||
// Automatically adds newlines to break up text longer than a specified number of characters
|
// Automatically adds newlines to break up text longer than a specified number of characters
|
||||||
@ -534,7 +535,7 @@ void DrawFlagArray32(const std::string& name, uint32_t& flags) {
|
|||||||
ImGui::PushID(flagIndex);
|
ImGui::PushID(flagIndex);
|
||||||
uint32_t bitMask = 1 << flagIndex;
|
uint32_t bitMask = 1 << flagIndex;
|
||||||
bool flag = (flags & bitMask) != 0;
|
bool flag = (flags & bitMask) != 0;
|
||||||
std::string label = std::to_string(flagIndex);
|
std::string label = fmt::format("0x{:02X} ({})", flagIndex, flagIndex);
|
||||||
if (UIWidgets::Checkbox(label.c_str(), &flag,
|
if (UIWidgets::Checkbox(label.c_str(), &flag,
|
||||||
{ .tooltip = label.c_str(), .labelPosition = LabelPosition::None })) {
|
{ .tooltip = label.c_str(), .labelPosition = LabelPosition::None })) {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
@ -557,7 +558,7 @@ void DrawFlagArray16(const std::string& name, uint16_t& flags) {
|
|||||||
ImGui::PushID(flagIndex);
|
ImGui::PushID(flagIndex);
|
||||||
uint16_t bitMask = 1 << flagIndex;
|
uint16_t bitMask = 1 << flagIndex;
|
||||||
bool flag = (flags & bitMask) != 0;
|
bool flag = (flags & bitMask) != 0;
|
||||||
std::string label = std::to_string(flagIndex);
|
std::string label = fmt::format("0x{:02X} ({})", flagIndex, flagIndex);
|
||||||
if (UIWidgets::Checkbox(label.c_str(), &flag,
|
if (UIWidgets::Checkbox(label.c_str(), &flag,
|
||||||
{ .tooltip = label.c_str(), .labelPosition = LabelPosition::None })) {
|
{ .tooltip = label.c_str(), .labelPosition = LabelPosition::None })) {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
@ -580,7 +581,30 @@ void DrawFlagArray8(const std::string& name, uint8_t& flags) {
|
|||||||
ImGui::PushID(flagIndex);
|
ImGui::PushID(flagIndex);
|
||||||
uint8_t bitMask = 1 << flagIndex;
|
uint8_t bitMask = 1 << flagIndex;
|
||||||
bool flag = (flags & bitMask) != 0;
|
bool flag = (flags & bitMask) != 0;
|
||||||
std::string label = std::to_string(flagIndex);
|
std::string label = fmt::format("0x{:02X} ({})", flagIndex, flagIndex);
|
||||||
|
if (UIWidgets::Checkbox(label.c_str(), &flag,
|
||||||
|
{ .tooltip = label.c_str(), .labelPosition = LabelPosition::None })) {
|
||||||
|
if (flag) {
|
||||||
|
flags |= bitMask;
|
||||||
|
} else {
|
||||||
|
flags &= ~bitMask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawFlagArray8Mask(const std::string& name, uint8_t& flags) {
|
||||||
|
ImGui::PushID(name.c_str());
|
||||||
|
for (int8_t flagIndex = 0; flagIndex < 8; flagIndex++) {
|
||||||
|
if ((flagIndex % 8) != 0) {
|
||||||
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
ImGui::PushID(flagIndex);
|
||||||
|
uint8_t bitMask = 1 << flagIndex;
|
||||||
|
bool flag = (flags & bitMask) != 0;
|
||||||
|
std::string label = fmt::format("0x{:02X} ({})", bitMask, flagIndex);
|
||||||
if (UIWidgets::Checkbox(label.c_str(), &flag,
|
if (UIWidgets::Checkbox(label.c_str(), &flag,
|
||||||
{ .tooltip = label.c_str(), .labelPosition = LabelPosition::None })) {
|
{ .tooltip = label.c_str(), .labelPosition = LabelPosition::None })) {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
|
@ -417,6 +417,7 @@ namespace UIWidgets {
|
|||||||
void DrawFlagArray32(const std::string& name, uint32_t& flags);
|
void DrawFlagArray32(const std::string& name, uint32_t& flags);
|
||||||
void DrawFlagArray16(const std::string& name, uint16_t& flags);
|
void DrawFlagArray16(const std::string& name, uint16_t& flags);
|
||||||
void DrawFlagArray8(const std::string& name, uint8_t& flags);
|
void DrawFlagArray8(const std::string& name, uint8_t& flags);
|
||||||
|
void DrawFlagArray8Mask(const std::string& name, uint8_t& flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* UIWidgets_hpp */
|
#endif /* UIWidgets_hpp */
|
||||||
|
@ -1722,7 +1722,7 @@ void DrawFlagsTab() {
|
|||||||
ImGui::PushID(i);
|
ImGui::PushID(i);
|
||||||
ImGui::Text("%02d", i);
|
ImGui::Text("%02d", i);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
UIWidgets::DrawFlagArray8("##", gSaveContext.save.saveInfo.weekEventReg[i]);
|
UIWidgets::DrawFlagArray8Mask("##", gSaveContext.save.saveInfo.weekEventReg[i]);
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user