Skip to content

Commit

Permalink
feat(p2p): Show p2p port in the config menu
Browse files Browse the repository at this point in the history
with love to my weblate people
  • Loading branch information
ashquarky committed Nov 17, 2024
1 parent 22bebff commit cc96712
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,22 @@
#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>
#include <sysapp/title.h>
#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;
Expand Down Expand Up @@ -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()));

This comment has been minimized.

Copy link
@ashquarky

ashquarky Nov 21, 2024

Author Member

The use of std::vformat here apparently quadrupled our binary size, adding an extra 400kb of Stuff. Looking into alternatives once #50 merges

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);

Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion src/patches/game_peertopeer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 +
Expand Down
1 change: 1 addition & 0 deletions src/patches/game_peertopeer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
#pragma once

void peertopeer_patch();
unsigned short peertopeer_port();

0 comments on commit cc96712

Please sign in to comment.