feat(p2p): Show p2p port in the config menu
Some checks failed
Inkay-CI / build-inkay (push) Has been cancelled

with love to my weblate people
This commit is contained in:
Ash Logan 2024-11-17 23:58:10 +11:00
parent 22bebff027
commit cc967126fe
5 changed files with 14 additions and 1 deletions

View File

@ -20,11 +20,13 @@
#include "wut_extra.h"
#include "utils/logger.h"
#include "utils/sysconfig.h"
#include "patches/game_peertopeer.h"
#include <wups.h>
#include <wups/storage.h>
#include <wups/config_api.h>
#include <wups/config/WUPSConfigItemBoolean.h>
#include <wups/config/WUPSConfigItemStub.h>
#include <coreinit/title.h>
#include <coreinit/launch.h>
@ -32,6 +34,8 @@
#include <sysapp/launch.h>
#include <nn/act.h>
#include <format>
bool Config::connect_to_network = true;
bool Config::need_relaunch = false;
bool Config::unregister_task_item_pressed = false;
@ -174,6 +178,12 @@ static WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHa
res = network_cat->add(std::move(*connect_item), err);
if (!res) return report_error(err);
{
std::string multiplayer_port_text = std::vformat(strings.multiplayer_port_display, std::make_format_args(peertopeer_port()));
res = network_cat->add(WUPSConfigItemStub::Create(multiplayer_port_text), err);
if (!res) return report_error(err);
}
res = root.add(std::move(*network_cat), err);
if (!res) return report_error(err);

View File

@ -35,6 +35,7 @@ struct config_strings {
std::string_view need_menu_action;
std::string_view using_nintendo_network;
std::string_view using_pretendo_network;
std::string_view multiplayer_port_display;
};
config_strings get_config_strings(nn::swkbd::LanguageType language);

View File

@ -8,3 +8,4 @@
,.need_menu_action = "From WiiU menu only"
,.using_nintendo_network = "Using Nintendo Network"
,.using_pretendo_network = "Using Pretendo Network"
,.multiplayer_port_display = "Using UDP port {} for multiplayer"

View File

@ -27,7 +27,7 @@ static inline int digit(char a) {
return a - '0';
}
static unsigned short peertopeer_port() {
unsigned short peertopeer_port() {
const char * serial = get_console_serial();
unsigned short port = 50000 +

View File

@ -14,3 +14,4 @@
#pragma once
void peertopeer_patch();
unsigned short peertopeer_port();