mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Add a "quick-edit" button for the current server host/ip, if it's custom
This was requested by Majin on Discord, whose server changes IP regularly for some reason.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "Common/Net/Resolve.h"
|
||||
#include "Common/UI/Root.h"
|
||||
#include "Common/UI/PopupScreens.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Core/HLE/sceNetAdhoc.h"
|
||||
#include "UI/MiscViews.h"
|
||||
@@ -507,3 +508,56 @@ void AdhocServerScreen::OnCompleted(DialogResult result) {
|
||||
*value_ = StripSpaces(editValue_);
|
||||
}
|
||||
}
|
||||
|
||||
bool AdhocServerNameIsCustom() {
|
||||
for (auto iter : g_Config.vCustomAdhocServerList) {
|
||||
if (iter == g_Config.sProAdhocServer) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (auto iter : g_Config.vCustomAdhocServerListWithRelay) {
|
||||
if (iter == g_Config.sProAdhocServer) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void EditServerName(std::string_view newServerName) {
|
||||
newServerName = StripSpaces(newServerName);
|
||||
if (newServerName != g_Config.sProAdhocServer) {
|
||||
for (auto &name : g_Config.vCustomAdhocServerList) {
|
||||
if (name == g_Config.sProAdhocServer) {
|
||||
name = newServerName;
|
||||
}
|
||||
}
|
||||
for (auto &name : g_Config.vCustomAdhocServerListWithRelay) {
|
||||
if (name == g_Config.sProAdhocServer) {
|
||||
name = newServerName;
|
||||
}
|
||||
}
|
||||
g_Config.sProAdhocServer = newServerName;
|
||||
}
|
||||
}
|
||||
|
||||
void AskToEditCurrentServer(int requestToken, ScreenManager *screenManager) {
|
||||
using namespace UI;
|
||||
auto n = GetI18NCategory(I18NCat::NETWORKING);
|
||||
|
||||
// Choose method depending on platform capabilities.
|
||||
if (System_GetPropertyBool(SYSPROP_HAS_TEXT_INPUT_DIALOG)) {
|
||||
System_InputBoxGetString(requestToken, n->T("Change proAdhocServer Address"), g_Config.sProAdhocServer, false, [](const std::string &enteredValue, int) {
|
||||
EditServerName(enteredValue);
|
||||
});
|
||||
return;
|
||||
}
|
||||
static std::string editText = g_Config.sProAdhocServer;
|
||||
TextEditPopupScreen *popupScreen = new TextEditPopupScreen(&editText, editText, n->T("Change proAdhocServer Address"), 256);
|
||||
if (System_GetPropertyBool(SYSPROP_KEYBOARD_IS_SOFT)) {
|
||||
popupScreen->SetAlignTop(true);
|
||||
}
|
||||
popupScreen->OnChange.Add([](EventParams &e) {
|
||||
EditServerName(editText);
|
||||
});
|
||||
screenManager->push(popupScreen);
|
||||
}
|
||||
|
||||
@@ -54,3 +54,5 @@ private:
|
||||
bool lastResolvedResult_ = false;
|
||||
};
|
||||
|
||||
void AskToEditCurrentServer(int requestToken, ScreenManager *screenManager);
|
||||
bool AdhocServerNameIsCustom();
|
||||
|
||||
@@ -1023,9 +1023,16 @@ void GameSettingsScreen::CreateNetworkingSettings(UI::ViewGroup *networkingSetti
|
||||
|
||||
networkingSettings->Add(new ItemHeader(n->T("Ad Hoc multiplayer")));
|
||||
|
||||
networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sProAdhocServer, n->T("Change proAdhocServer Address"), I18NCat::NONE))->OnClick.Add([=](UI::EventParams &) {
|
||||
LinearLayout *serverRow = networkingSettings->Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
|
||||
serverRow->SetSpacing(0.0f);
|
||||
serverRow->Add(new ChoiceWithValueDisplay(&g_Config.sProAdhocServer, n->T("Change proAdhocServer Address"), I18NCat::NONE, new LinearLayoutParams(1.0f)))->OnClick.Add([=](UI::EventParams &) {
|
||||
screenManager()->push(new AdhocServerScreen(&g_Config.sProAdhocServer, n->T("Ad hoc server address")));
|
||||
});
|
||||
if (AdhocServerNameIsCustom()) {
|
||||
serverRow->Add(new Choice(ImageID("I_EDIT_TEXT"), new LinearLayoutParams(ITEM_HEIGHT, ITEM_HEIGHT)))->OnClick.Add([this](UI::EventParams &) {
|
||||
AskToEditCurrentServer(GetRequesterToken(), screenManager());
|
||||
});
|
||||
}
|
||||
|
||||
static const char *relayModes[] = {"Auto", "Yes", "No"};
|
||||
PopupMultiChoice *relayModePopup = networkingSettings->Add(new PopupMultiChoice(&g_Config.iAdhocServerRelayMode, n->T("Try to use server-provided packet relay"), relayModes, 0, ARRAY_SIZE(relayModes), I18NCat::DIALOG, screenManager()));
|
||||
|
||||
@@ -187,6 +187,7 @@ static const ImageMeta imageIDs[] = {
|
||||
{"I_FILE_SAVE", false},
|
||||
{"I_RADIO_EMPTY", false},
|
||||
{"I_RADIO_SELECTED", false},
|
||||
{"I_EDIT_TEXT", false},
|
||||
};
|
||||
|
||||
static std::string PNGNameFromID(std::string_view id) {
|
||||
|
||||
+19
-10
@@ -7,7 +7,7 @@
|
||||
viewBox="0 0 158.74998 185.20831"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
inkscape:version="1.4 (86a8ad7, 2024-10-11)"
|
||||
inkscape:version="1.4.3 (0d15f75, 2025-12-25)"
|
||||
sodipodi:docname="images.svg"
|
||||
xml:space="preserve"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
@@ -24,15 +24,15 @@
|
||||
inkscape:pagecheckerboard="true"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:document-units="px"
|
||||
inkscape:zoom="1.4142136"
|
||||
inkscape:cx="307.94501"
|
||||
inkscape:cy="348.9572"
|
||||
inkscape:window-width="2560"
|
||||
inkscape:window-height="1377"
|
||||
inkscape:window-x="-8"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:zoom="11.313709"
|
||||
inkscape:cx="261.54111"
|
||||
inkscape:cy="619.73488"
|
||||
inkscape:window-width="3840"
|
||||
inkscape:window-height="2071"
|
||||
inkscape:window-x="-9"
|
||||
inkscape:window-y="-9"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:current-layer="I_EDIT_TEXT"
|
||||
showgrid="false"
|
||||
showguides="true" /><defs
|
||||
id="defs1"><inkscape:path-effect
|
||||
@@ -4672,7 +4672,16 @@
|
||||
d="m 58.47291,54.239577 a 4.2333326,4.2333326 0 0 0 -4.233333,4.23333 4.2333326,4.2333326 0 0 0 4.233333,4.23334 4.2333326,4.2333326 0 0 0 4.233333,-4.23334 4.2333326,4.2333326 0 0 0 -4.233333,-4.23333 z m 0,0.65629 a 3.5771663,3.5771663 0 0 1 3.577042,3.57704 3.5771663,3.5771663 0 0 1 -3.577042,3.57704 3.5771663,3.5771663 0 0 1 -3.577042,-3.57704 3.5771663,3.5771663 0 0 1 3.577042,-3.57704 z m 0,1.46038 a 2.1166663,2.1166663 0 0 0 -2.116667,2.11666 2.1166663,2.1166663 0 0 0 2.116667,2.11667 2.1166663,2.1166663 0 0 0 2.116666,-2.11667 2.1166663,2.1166663 0 0 0 -2.116666,-2.11666 z" /><path
|
||||
id="I_RADIO_EMPTY"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke-width:0;stroke-miterlimit:100;paint-order:stroke fill markers"
|
||||
d="m 69.056242,54.239577 a 4.2333326,4.2333326 0 0 0 -4.233333,4.23333 4.2333326,4.2333326 0 0 0 4.233333,4.23334 4.2333326,4.2333326 0 0 0 4.233332,-4.23334 4.2333326,4.2333326 0 0 0 -4.233332,-4.23333 z m 0,0.65629 a 3.5771663,3.5771663 0 0 1 3.577042,3.57704 3.5771663,3.5771663 0 0 1 -3.577042,3.57704 3.5771663,3.5771663 0 0 1 -3.577042,-3.57704 3.5771663,3.5771663 0 0 1 3.577042,-3.57704 z" /></g><style
|
||||
d="m 69.056242,54.239577 a 4.2333326,4.2333326 0 0 0 -4.233333,4.23333 4.2333326,4.2333326 0 0 0 4.233333,4.23334 4.2333326,4.2333326 0 0 0 4.233332,-4.23334 4.2333326,4.2333326 0 0 0 -4.233332,-4.23333 z m 0,0.65629 a 3.5771663,3.5771663 0 0 1 3.577042,3.57704 3.5771663,3.5771663 0 0 1 -3.577042,3.57704 3.5771663,3.5771663 0 0 1 -3.577042,-3.57704 3.5771663,3.5771663 0 0 1 3.577042,-3.57704 z" /><g
|
||||
id="I_EDIT_TEXT"
|
||||
transform="matrix(0.02470063,0,0,0.02470063,64.778524,154.37321)"
|
||||
style="fill:#ffffff;fill-opacity:1">
|
||||
<path
|
||||
d="M 393.99805,221.04773 435.46,179.506 v 255.468 c 0,34.352 -27.852,62.207 -62.207,62.207 H 62.209 c -34.352,0 -62.207,-27.855 -62.207,-62.207 V 123.932 c 0,-34.355 27.855,-62.211 62.207,-62.211 h 255.453 l -39.9656,39.29839 -235.194672,0 V 458.1964 l 351.496322,0 z M 377.469,56.755 440.436,119.74 461.429,98.754 398.461,35.769 Z M 434.211,0 413.222,20.99 476.19,83.958 497.179,62.969 Z m -262.923,262.987 188.91,-188.953 62.969,62.984 -188.91,188.938 -91.703,28.677 z m 31.308,2.382 10.77,10.953 161.938,-159.184 -10.77,-10.953 z"
|
||||
id="path1-2"
|
||||
style="fill:#ffffff;fill-opacity:1"
|
||||
sodipodi:nodetypes="ccssssssccccccccccccccccccccccccccc" />
|
||||
</g></g><style
|
||||
type="text/css"
|
||||
id="style1">
|
||||
.st0{fill:#000000;}
|
||||
|
||||
|
Before Width: | Height: | Size: 258 KiB After Width: | Height: | Size: 259 KiB |
Reference in New Issue
Block a user