Enable gamepad navigation for the PrismaUI server browser and install MainMenu input hooks safely. Poll XInput each game-thread tick and forward button/stick changes to the browser (ForwardButtonEvent / ForwardThumbstickEvent), allocate an input-enable layer to suppress vanilla kMenu events while the browser is open, and register polling via the F4SE task interface. Replace direct vtable writes that caused a loading-screen crash with REL::Relocation::write_vfunc on the MainMenu BSInputEventUser secondary vtable and install OnButton/OnThumbstick hooks once at plugin Install(). Add MainMenu API to suppress inputEventHandling and call it when showing/hiding the browser. Also update PrismaUI browser JS to support controller focus for direct-connect, filter activation/cycling, improved controller prompts, and add CSS for focused direct-connect fields. Files touched include plugin/src/F4TMenuInput.cpp, plugin/src/F4TMainMenuInject.cpp, plugin/include headers, PrismaUI view JS/components, styles, and documentation.
58 lines
2.3 KiB
JavaScript
58 lines
2.3 KiB
JavaScript
(function () {
|
|
"use strict";
|
|
|
|
window.CO_DirectConnect = {
|
|
render: function (root, state) {
|
|
var pane = root.querySelector('[data-pane="direct-connect"]');
|
|
if (!pane) return;
|
|
|
|
var container = pane.querySelector(".co-direct-connect");
|
|
if (!container) return;
|
|
|
|
var address = state.directConnect.address || "127.0.0.1";
|
|
var port = state.directConnect.port || "7777";
|
|
var addressFocused = state.directConnectFieldIndex === 0 ? " focused" : "";
|
|
var portFocused = state.directConnectFieldIndex === 1 ? " focused" : "";
|
|
|
|
container.innerHTML =
|
|
'<div class="co-direct-row' + addressFocused + '">' +
|
|
'<label for="co-dc-address">Server Address</label>' +
|
|
'<input class="co-filter-input" id="co-dc-address" type="text" value="' + escapeAttr(address) + '">' +
|
|
"</div>" +
|
|
'<div class="co-direct-row' + portFocused + '">' +
|
|
'<label for="co-dc-port">Port</label>' +
|
|
'<input class="co-filter-input" id="co-dc-port" type="text" value="' + escapeAttr(port) + '">' +
|
|
"</div>" +
|
|
'<button type="button" class="co-btn co-dc-connect">Connect</button>' +
|
|
'<p class="co-detail-desc" style="margin-top:16px;color:var(--co-text-dim);font-size:var(--co-font-sm)">Enter a server address to connect directly without browsing the list.</p>';
|
|
},
|
|
|
|
bind: function (root, onConnect) {
|
|
var pane = root.querySelector('[data-pane="direct-connect"]');
|
|
if (!pane) return;
|
|
|
|
pane.addEventListener("click", function (e) {
|
|
if (!e.target.closest(".co-dc-connect")) return;
|
|
var address = pane.querySelector("#co-dc-address");
|
|
var port = pane.querySelector("#co-dc-port");
|
|
onConnect(address ? address.value : "", port ? port.value : "");
|
|
});
|
|
},
|
|
|
|
getValues: function (root) {
|
|
var pane = root.querySelector('[data-pane="direct-connect"]');
|
|
if (!pane) return { address: "127.0.0.1", port: "7777" };
|
|
var address = pane.querySelector("#co-dc-address");
|
|
var port = pane.querySelector("#co-dc-port");
|
|
return {
|
|
address: address ? address.value : "127.0.0.1",
|
|
port: port ? port.value : "7777"
|
|
};
|
|
}
|
|
};
|
|
|
|
function escapeAttr(value) {
|
|
return String(value).replace(/"/g, """);
|
|
}
|
|
})();
|