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 Feb 4, 2025
1 parent 85747d3 commit 3e85bf0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions mm/2s2h/BenGui/BenInputEditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ void BenInputEditorWindow::DrawButtonLineAddMappingButton(uint8_t port, N64Butto
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 @@ -269,6 +270,7 @@ void BenInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt
.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("%s", mapping->GetPhysicalDeviceName().c_str());
Expand Down Expand Up @@ -310,6 +312,7 @@ void BenInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt
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 @@ -452,6 +455,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 @@ -534,6 +538,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("%s", mapping->GetPhysicalDeviceName().c_str());
Expand Down Expand Up @@ -812,6 +817,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 @@ -995,6 +1001,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 @@ -1074,6 +1081,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 @@ -1471,3 +1479,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);
}
2 changes: 1 addition & 1 deletion mm/2s2h/BenGui/BenInputEditorWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,5 @@ class BenInputEditorWindow : public Ship::GuiWindow {
void DrawSetDefaultsButton(uint8_t portIndex);
void DrawClearAllButton(uint8_t portIndex);

void DrawDeviceToggles(uint8_t portIndex);
void OffsetMappingPopup();
};

0 comments on commit 3e85bf0

Please sign in to comment.