Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Adaptor hint and Expose Delete Button in Virtual Space Settings #20

Merged
merged 2 commits into from
Sep 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions source/nijiexpose/windows/spaceedit.d
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,18 @@ private:

string[string][Adaptor] options;

void adaptorDelete(size_t idx) {
// stop source on delete
if (editingZone.sources[idx]) editingZone.sources[idx].stop();
editingZone.sources = editingZone.sources.remove(idx);
}

void adaptorMenu(size_t idx) {
uiImRightClickPopup("AdaptorPopup");

if (uiImBeginPopup("AdaptorPopup")) {
if (uiImMenuItem(__("Delete"))) {

// stop source on delete
if (editingZone.sources[idx]) editingZone.sources[idx].stop();
editingZone.sources = editingZone.sources.remove(idx);
}
if (uiImMenuItem(__("Delete")))
adaptorDelete(idx);
uiImEndPopup();
}
}
Expand All @@ -87,6 +89,21 @@ private:
}
}

/**
this function show hints to help users to configure the adaptor correctly
*/
void adaptorHint(ref Adaptor source) {
/**
for port binding information, we should refer to `facetrack-d/source/ft/adaptors/*.d`
*/

string portHint = "";
if (auto vts = cast(IFMAdaptor) source)
portHint = _("iFacialMocap Adpator would listen on udp port 49983");
if (portHint.length > 0)
uiImLabel(portHint ~ "\n" ~ _("Make sure the port is not blocked by firewall."));
}

void adaptorSelect(size_t i, ref Adaptor source, const(char)* adaptorName) {
if (uiImBeginComboBox("ADAPTOR_COMBO", adaptorName)) {
if (uiImSelectable("VTubeStudio")) {
Expand Down Expand Up @@ -270,6 +287,8 @@ public:
}
}

adaptorHint(source);

if (uiImButton(__("Save Changes"))) {
try {
source.setOptions(options[source]);
Expand All @@ -280,6 +299,10 @@ public:
}
}

// Expose the delete button to make sure users notice it.
uiImSameLine(0, 40);
if (uiImButton(__("Delete")))
adaptorDelete(i);
uiImUnindent();
} else {
adaptorMenu(i);
Expand Down
Loading