Skip to content

Commit

Permalink
[feat] offset mapping popup
Browse files Browse the repository at this point in the history
  • Loading branch information
lightmanLP committed Jan 9, 2025
1 parent 80cc5bd commit e50f36c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions mm/2s2h/BenGui/BenInputEditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ void BenInputEditorWindow::DrawButtonLineAddMappingButton(uint8_t port, CONTROLL
if (ImGui::Button(StringHelper::Sprintf("%s###addButtonMappingButton%d-%d", ICON_FA_PLUS, port, bitmask).c_str(),
ImVec2(SCALE_IMGUI_SIZE(20.0f), 0.0f))) {
ImGui::OpenPopup(popupId.c_str());
OffsetMappingPopup();
};
ImGui::PopStyleVar();

Expand Down Expand Up @@ -279,6 +280,7 @@ void BenInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, CONTROL
.c_str(),
ImVec2(ImGui::CalcTextSize(physicalInputDisplayName.c_str()).x + SCALE_IMGUI_SIZE(12.0f), 0.0f))) {
ImGui::OpenPopup(popupId.c_str());
OffsetMappingPopup();
}
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal | ImGuiHoveredFlags_NoSharedDelay)) {
ImGui::SetTooltip(mapping->GetPhysicalDeviceName().c_str());
Expand Down Expand Up @@ -326,6 +328,7 @@ void BenInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, CONTROL
if (ImGui::Button(StringHelper::Sprintf("%s###editAxisThresholdButton%s", ICON_FA_COG, id.c_str()).c_str(),
ImVec2(ImGui::CalcTextSize(ICON_FA_COG).x + SCALE_IMGUI_SIZE(10.0f), 0.0f))) {
ImGui::OpenPopup(popupId.c_str());
OffsetMappingPopup();
}
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal | ImGuiHoveredFlags_NoSharedDelay)) {
ImGui::SetTooltip("Edit axis threshold");
Expand Down Expand Up @@ -466,6 +469,7 @@ void BenInputEditorWindow::DrawStickDirectionLineAddMappingButton(uint8_t port,
.c_str(),
ImVec2(SCALE_IMGUI_SIZE(20.0f), 0.0f))) {
ImGui::OpenPopup(popupId.c_str());
OffsetMappingPopup();
};
ImGui::PopStyleVar();

Expand Down Expand Up @@ -551,6 +555,7 @@ void BenInputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port,
.c_str(),
ImVec2(ImGui::CalcTextSize(physicalInputDisplayName.c_str()).x + SCALE_IMGUI_SIZE(12.0f), 0.0f))) {
ImGui::OpenPopup(popupId.c_str());
OffsetMappingPopup();
}
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal | ImGuiHoveredFlags_NoSharedDelay)) {
ImGui::SetTooltip(mapping->GetPhysicalDeviceName().c_str());
Expand Down Expand Up @@ -829,6 +834,7 @@ void BenInputEditorWindow::DrawAddRumbleMappingButton(uint8_t port) {
if (ImGui::Button(StringHelper::Sprintf("%s###addRumbleMapping%d", ICON_FA_PLUS, port).c_str(),
ImVec2(SCALE_IMGUI_SIZE(20.0f), SCALE_IMGUI_SIZE(20.0f)))) {
ImGui::OpenPopup(popupId.c_str());
OffsetMappingPopup();
}
ImGui::PopStyleVar();

Expand Down Expand Up @@ -1012,6 +1018,7 @@ void BenInputEditorWindow::DrawAddLEDMappingButton(uint8_t port) {
if (ImGui::Button(StringHelper::Sprintf("%s###addLEDMapping%d", ICON_FA_PLUS, port).c_str(),
ImVec2(SCALE_IMGUI_SIZE(20.0f), SCALE_IMGUI_SIZE(20.0f)))) {
ImGui::OpenPopup(popupId.c_str());
OffsetMappingPopup();
}
ImGui::PopStyleVar();

Expand Down Expand Up @@ -1091,6 +1098,7 @@ void BenInputEditorWindow::DrawAddGyroMappingButton(uint8_t port) {
if (ImGui::Button(StringHelper::Sprintf("%s###addGyroMapping%d", ICON_FA_PLUS, port).c_str(),
ImVec2(SCALE_IMGUI_SIZE(20.0f), SCALE_IMGUI_SIZE(20.0f)))) {
ImGui::OpenPopup(popupId.c_str());
OffsetMappingPopup();
}
ImGui::PopStyleVar();

Expand Down Expand Up @@ -1719,3 +1727,10 @@ void BenInputEditorWindow::DrawFullContents() {
void BenInputEditorWindow::DrawElement() {
DrawFullContents();
}

void BenInputEditorWindow::OffsetMappingPopup() {
const float HORIZONTAL_OFFSET = 10.0f;
ImVec2 pos = ImGui::GetMousePos();
pos.x += HORIZONTAL_OFFSET;
ImGui::SetNextWindowPos(pos);
}
1 change: 1 addition & 0 deletions mm/2s2h/BenGui/BenInputEditorWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,5 @@ class BenInputEditorWindow : public Ship::GuiWindow {

std::map<Ship::ShipDeviceIndex, bool> mDeviceIndexVisiblity;
void DrawDeviceVisibilityButtons();
void OffsetMappingPopup();
};

0 comments on commit e50f36c

Please sign in to comment.