MCPcopy Create free account
hub / github.com/JRickey/BattleShip / DrawFlagArray8

Function DrawFlagArray8

port/gui/UIWidgets.cpp:1109–1133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1107}
1108
1109void DrawFlagArray8(const std::string& name, uint8_t& flags, Colors color) {
1110 ImGui::PushID(name.c_str());
1111 for (int8_t flagIndex = 0; flagIndex < 8; flagIndex++) {
1112 if ((flagIndex % 8) != 0) {
1113 ImGui::SameLine();
1114 }
1115 ImGui::PushID(flagIndex);
1116 uint8_t bitMask = 1 << flagIndex;
1117 bool flag = (flags & bitMask) != 0;
1118 PushStyleCheckbox(color);
1119 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4.0f, 3.0f));
1120 std::string id = fmt::format("##{}{}", name, flagIndex);
1121 if (ImGui::Checkbox(id.c_str(), &flag)) {
1122 if (flag) {
1123 flags |= bitMask;
1124 } else {
1125 flags &= ~bitMask;
1126 }
1127 }
1128 ImGui::PopStyleVar();
1129 PopStyleCheckbox();
1130 ImGui::PopID();
1131 }
1132 ImGui::PopID();
1133}
1134
1135void DrawFlagArray8Mask(const std::string& name, uint8_t& flags, Colors color) {
1136 ImGui::PushID(name.c_str());

Callers

nothing calls this directly

Calls 3

PushStyleCheckboxFunction · 0.85
CheckboxFunction · 0.85
PopStyleCheckboxFunction · 0.85

Tested by

no test coverage detected