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

Function DrawFlagArray16

port/gui/UIWidgets.cpp:1083–1107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1081}
1082
1083void DrawFlagArray16(const std::string& name, uint16_t& flags, Colors color) {
1084 ImGui::PushID(name.c_str());
1085 for (int16_t flagIndex = 0; flagIndex < 16; flagIndex++) {
1086 if ((flagIndex % 8) != 0) {
1087 ImGui::SameLine();
1088 }
1089 ImGui::PushID(flagIndex);
1090 uint16_t bitMask = 1 << flagIndex;
1091 bool flag = (flags & bitMask) != 0;
1092 PushStyleCheckbox(color);
1093 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4.0f, 3.0f));
1094 std::string id = fmt::format("##{}{}", name, flagIndex);
1095 if (ImGui::Checkbox(id.c_str(), &flag)) {
1096 if (flag) {
1097 flags |= bitMask;
1098 } else {
1099 flags &= ~bitMask;
1100 }
1101 }
1102 ImGui::PopStyleVar();
1103 PopStyleCheckbox();
1104 ImGui::PopID();
1105 }
1106 ImGui::PopID();
1107}
1108
1109void DrawFlagArray8(const std::string& name, uint8_t& flags, Colors color) {
1110 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