mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Network settings: Show proper server name if available
This commit is contained in:
1 parent
420eca98d6
commit
5ef608a12a
3 files changed
+33
-5
No files matched your search
@@ -558,6 +558,18 @@ private:
|
||||
std::string(*translateCallback_)(std::string_view value) = nullptr;
|
||||
};
|
||||
|
||||
class ChoiceWithFixedValueDisplay : public AbstractChoiceWithValueDisplay {
|
||||
public:
|
||||
ChoiceWithFixedValueDisplay(std::string_view value, std::string_view text, LayoutParams *layoutParams = 0)
|
||||
: AbstractChoiceWithValueDisplay(text, layoutParams), sValue_(value) {}
|
||||
private:
|
||||
std::string ValueText(bool *shadow) const override {
|
||||
*shadow = false;
|
||||
return sValue_;
|
||||
}
|
||||
std::string sValue_ = nullptr;
|
||||
};
|
||||
|
||||
enum class FileChooserFileType {
|
||||
WAVE_FILE,
|
||||
};
|
||||
|
||||
@@ -71,6 +71,14 @@ std::vector<AdhocGame> ParseDataJson(std::string_view json) {
|
||||
|
||||
game.usercount = g.HasMember("usercount") ? ParseUserCountValue(g["usercount"]) : 0;
|
||||
|
||||
if (g.HasMember("game_ids") && g["game_ids"].IsArray()) {
|
||||
for (auto& id : g["game_ids"].GetArray()) {
|
||||
if (!id.IsString())
|
||||
continue;
|
||||
game.game_ids.push_back(id.GetString());
|
||||
}
|
||||
}
|
||||
|
||||
if (g.HasMember("groups") && g["groups"].IsArray()) {
|
||||
for (auto& grp : g["groups"].GetArray()) {
|
||||
if (!grp.IsObject())
|
||||
|
||||
@@ -1023,24 +1023,32 @@ void GameSettingsScreen::CreateNetworkingSettings(UI::ViewGroup *networkingSetti
|
||||
|
||||
networkingSettings->Add(new ItemHeader(n->T("Ad Hoc multiplayer")));
|
||||
|
||||
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("Ad hoc server address"), I18NCat::NONE, new LinearLayoutParams(1.0f)))->OnClick.Add([=](UI::EventParams &) {
|
||||
auto launchAdhocServerScreen = [this](UI::EventParams &) {
|
||||
auto n = GetI18NCategory(I18NCat::NETWORKING);
|
||||
screenManager()->push(new AdhocServerScreen(&g_Config.sProAdhocServer, n->T("Ad hoc server address")));
|
||||
});
|
||||
};
|
||||
|
||||
if (AdhocServerNameIsCustom()) {
|
||||
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("Ad hoc server address"), I18NCat::NONE, new LinearLayoutParams(1.0f)))->OnClick.Add(launchAdhocServerScreen);
|
||||
serverRow->Add(new Choice(ImageID("I_EDIT_TEXT"), new LinearLayoutParams(ITEM_HEIGHT, ITEM_HEIGHT)))->OnClick.Add([this](UI::EventParams &) {
|
||||
AskToEditCurrentServer(GetRequesterToken(), screenManager());
|
||||
});
|
||||
} else if (!g_Config.sProAdhocServer.empty()) {
|
||||
AdhocServerListEntry entry;
|
||||
if (AdhocGetServerByHost(g_Config.sProAdhocServer, &entry)) {
|
||||
Choice *status = networkingSettings->Add(new Choice(ApplySafeSubstitutions(n->T("Server status: %1"), g_Config.sProAdhocServer)));
|
||||
networkingSettings->Add(new ChoiceWithFixedValueDisplay(ApplySafeSubstitutions("%1 (%2)", entry.name, entry.host), n->T("Ad hoc server address")))->OnClick.Add(launchAdhocServerScreen);
|
||||
Choice *status = networkingSettings->Add(new Choice(ApplySafeSubstitutions(n->T("Server status: %1"), entry.name)));
|
||||
status->SetIconLeft(ImageID("I_INFO"));
|
||||
status->OnClick.Add([this, entry](UI::EventParams &) {
|
||||
screenManager()->push(new AdhocServerInfoScreen(entry));
|
||||
});
|
||||
} else {
|
||||
networkingSettings->Add(new Choice(n->T("Ad hoc server address"), new LinearLayoutParams(1.0f)))->OnClick.Add(launchAdhocServerScreen);
|
||||
}
|
||||
} else {
|
||||
networkingSettings->Add(new Choice(n->T("Ad hoc server address"), new LinearLayoutParams(1.0f)))->OnClick.Add(launchAdhocServerScreen);
|
||||
}
|
||||
|
||||
static const char *relayModes[] = {"Auto", "Yes", "No"};
|
||||
|
||||
Reference in new issue
Block a user