Merge pull request #19875 from hrydgard/online-ui-work

Online: Fix DNS server default, show revival team credits on pause screen
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2025-01-15 09:46:37 +01:00
commit 008aaa8327
17 files changed
+235 -368

No files matched your search

+10 -10
View File
@@ -158,18 +158,18 @@ void Server::SetFallbackHandler(UrlHandlerFunc handler) {
fallback_ = handler;
}
bool Server::Listen(int port, net::DNSType type) {
bool Server::Listen(int port, const char *reason, net::DNSType type) {
bool success = false;
if (type == net::DNSType::ANY || type == net::DNSType::IPV6) {
success = Listen6(port, type == net::DNSType::IPV6);
success = Listen6(port, type == net::DNSType::IPV6, reason);
}
if (!success && (type == net::DNSType::ANY || type == net::DNSType::IPV4)) {
success = Listen4(port);
success = Listen4(port, reason);
}
return success;
}
bool Server::Listen4(int port) {
bool Server::Listen4(int port, const char *reason) {
listener_ = socket(AF_INET, SOCK_STREAM, 0);
if (listener_ < 0)
return false;
@@ -190,7 +190,7 @@ bool Server::Listen4(int port) {
#else
int err = errno;
#endif
ERROR_LOG(Log::IO, "Failed to bind to port %d, error=%d - Bailing (ipv4)", port, err);
ERROR_LOG(Log::IO, "%s: Failed to bind to port %d, error=%d - Bailing (ipv4)", reason, port, err);
closesocket(listener_);
return false;
}
@@ -208,13 +208,13 @@ bool Server::Listen4(int port) {
port = ntohs(server_addr.sin_port);
}
INFO_LOG(Log::IO, "HTTP server started on port %d", port);
INFO_LOG(Log::IO, "HTTP server started on port %d: %s", port, reason);
port_ = port;
return true;
}
bool Server::Listen6(int port, bool ipv6_only) {
bool Server::Listen6(int port, bool ipv6_only, const char *reason) {
#if !PPSSPP_PLATFORM(SWITCH)
listener_ = socket(AF_INET6, SOCK_STREAM, 0);
if (listener_ < 0)
@@ -240,7 +240,7 @@ bool Server::Listen6(int port, bool ipv6_only) {
#else
int err = errno;
#endif
ERROR_LOG(Log::IO, "Failed to bind to port %d, error=%d - Bailing (ipv6)", port, err);
ERROR_LOG(Log::IO, "%s: Failed to bind to port %d, error=%d - Bailing (ipv6)", reason, port, err);
closesocket(listener_);
return false;
}
@@ -258,7 +258,7 @@ bool Server::Listen6(int port, bool ipv6_only) {
port = ntohs(server_addr.sin6_port);
}
INFO_LOG(Log::IO, "HTTP server started on port %d", port);
INFO_LOG(Log::IO, "HTTP server started on port %d: %s", port, reason);
port_ = port;
return true;
@@ -299,7 +299,7 @@ bool Server::RunSlice(double timeout) {
}
bool Server::Run(int port) {
if (!Listen(port)) {
if (!Listen(port, "websocket")) {
return false;
}
+3 -3
View File
@@ -85,7 +85,7 @@ public:
// May run for (significantly) longer than timeout, but won't wait longer than that
// for a new connection to handle.
bool RunSlice(double timeout);
bool Listen(int port, net::DNSType type = net::DNSType::ANY);
bool Listen(int port, const char *reason, net::DNSType type = net::DNSType::ANY);
void Stop();
void RegisterHandler(const char *url_path, UrlHandlerFunc handler);
@@ -101,8 +101,8 @@ public:
}
private:
bool Listen6(int port, bool ipv6_only);
bool Listen4(int port);
bool Listen6(int port, bool ipv6_only, const char *reason);
bool Listen4(int port, const char *reason);
void HandleConnection(int conn_fd);
+128 -6
View File
@@ -20,6 +20,7 @@
#include "Common/Serialize/Serializer.h"
#include "Common/Serialize/SerializeFuncs.h"
#include "Common/StringUtils.h"
#include "Common/Data/Encoding/Utf8.h"
#include "Core/Config.h"
#include "Core/System.h"
#include "Core/CoreTiming.h"
@@ -31,13 +32,8 @@
#include "Core/Util/PPGeDraw.h"
#define FADE_TIME 1.0
const float FONT_SCALE = 0.55f;
PSPDialog::PSPDialog(UtilityDialogType type) : dialogType_(type) {
}
PSPDialog::~PSPDialog() {
}
constexpr float FONT_SCALE = 0.55f;
void PSPDialog::InitCommon() {
UpdateCommon();
@@ -340,3 +336,129 @@ int PSPDialog::GetCancelButton() {
}
return g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? CTRL_CIRCLE : CTRL_CROSS;
}
void PSPDialog::DisplayMessage2(std::string_view text1, std::string_view text2a, std::string_view text2b, std::string_view text3a, std::string_view text3b, bool hasYesNo, bool hasOK) {
auto di = GetI18NCategory(I18NCat::DIALOG);
PPGeStyle buttonStyle = FadedStyle(PPGeAlign::BOX_CENTER, FONT_SCALE);
PPGeStyle messageStyle = FadedStyle(PPGeAlign::BOX_HCENTER, FONT_SCALE);
PPGeStyle messageStyleRight = FadedStyle(PPGeAlign::BOX_RIGHT, FONT_SCALE);
PPGeStyle messageStyleLeft = FadedStyle(PPGeAlign::BOX_LEFT, FONT_SCALE);
std::string text2 = std::string(text2a) + " " + std::string(text2b);
std::string text3 = std::string(text3a) + " " + std::string(text3b);
// Without the scrollbar, we have 350 total pixels.
float WRAP_WIDTH = 300.0f;
if (UTF8StringNonASCIICount(text1) >= (int)text1.size() / 4) {
WRAP_WIDTH = 336.0f;
if (text1.size() > 12) {
messageStyle.scale = 0.6f;
}
}
float totalHeight1 = 0.0f;
PPGeMeasureText(nullptr, &totalHeight1, text1, FONT_SCALE, PPGE_LINE_WRAP_WORD, WRAP_WIDTH);
float totalHeight2 = 0.0f;
if (text2 != " ")
PPGeMeasureText(nullptr, &totalHeight2, text2, FONT_SCALE, PPGE_LINE_USE_ELLIPSIS, WRAP_WIDTH);
float totalHeight3 = 0.0f;
if (text3 != " ")
PPGeMeasureText(nullptr, &totalHeight3, text3, FONT_SCALE, PPGE_LINE_USE_ELLIPSIS, WRAP_WIDTH);
float marginTop = 0.0f;
if (text2 != " " || text3 != " ")
marginTop = 11.0f;
float totalHeight = totalHeight1 + totalHeight2 + totalHeight3 + marginTop;
// The PSP normally only shows about 8 lines at a time.
// For improved UX, we intentionally show part of the next line.
float visibleHeight = std::min(totalHeight, 175.0f);
float h2 = visibleHeight / 2.0f;
float centerY = 135.0f;
float sy = centerY - h2 - 15.0f;
float ey = centerY + h2 + 20.0f;
float buttonY = centerY + h2 + 5.0f;
auto drawSelectionBoxAndAdjust = [&](float x) {
// Box has a fixed size.
float w = 15.0f;
float h = 8.0f;
PPGeDrawRect(x - w, buttonY - h, x + w, buttonY + h, CalcFadedColor(0x6DCFCFCF));
centerY -= h + 5.0f;
sy -= h + 5.0f;
ey = buttonY + h * 2.0f + 5.0f;
};
if (hasYesNo) {
if (yesnoChoice == 1) {
drawSelectionBoxAndAdjust(204.0f);
} else {
drawSelectionBoxAndAdjust(273.0f);
}
PPGeDrawText(di->T("Yes"), 203.0f, buttonY - 1.0f, buttonStyle);
PPGeDrawText(di->T("No"), 272.0f, buttonY - 1.0f, buttonStyle);
if (IsButtonPressed(CTRL_LEFT) && yesnoChoice == 0) {
yesnoChoice = 1;
} else if (IsButtonPressed(CTRL_RIGHT) && yesnoChoice == 1) {
yesnoChoice = 0;
}
buttonY += 8.0f + 5.0f;
}
if (hasOK) {
drawSelectionBoxAndAdjust(240.0f);
PPGeDrawText(di->T("OK"), 239.0f, buttonY - 1.0f, buttonStyle);
buttonY += 8.0f + 5.0f;
}
PPGeScissor(0, (int)(centerY - h2 - 2), 480, (int)(centerY + h2 + 2));
PPGeDrawTextWrapped(text1, 240.0f, centerY - h2 - scrollPos_, WRAP_WIDTH, 0, messageStyle);
if (!text2a.empty()) {
if (!text2b.empty())
PPGeDrawTextWrapped(text2a, 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleRight);
else
PPGeDrawTextWrapped(text2a, 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyle);
}
if (!text2b.empty())
PPGeDrawTextWrapped(text2b, 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleLeft);
if (!text3a.empty()) {
if (!text3b.empty())
PPGeDrawTextWrapped(text3a, 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleRight);
else
PPGeDrawTextWrapped(text3a, 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyle);
}
if (!text3b.empty())
PPGeDrawTextWrapped(text3b, 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleLeft);
PPGeScissorReset();
// Do we need a scrollbar?
if (visibleHeight < totalHeight) {
float scrollSpeed = 5.0f;
float scrollMax = totalHeight - visibleHeight;
float bobHeight = (visibleHeight / totalHeight) * visibleHeight;
float bobOffset = (scrollPos_ / scrollMax) * (visibleHeight - bobHeight);
float bobY1 = centerY - h2 + bobOffset;
PPGeDrawRect(415.0f, bobY1, 420.0f, bobY1 + bobHeight, CalcFadedColor(0xFFCCCCCC));
auto buttonDown = [this](int btn, int& held) {
if (IsButtonPressed(btn)) {
held = 0;
return true;
}
return IsButtonHeld(btn, held, 1, 1);
};
if (buttonDown(CTRL_DOWN, framesDownHeld_) && scrollPos_ < scrollMax) {
scrollPos_ = std::min(scrollMax, scrollPos_ + scrollSpeed);
}
if (buttonDown(CTRL_UP, framesUpHeld_) && scrollPos_ > 0.0f) {
scrollPos_ = std::max(0.0f, scrollPos_ - scrollSpeed);
}
}
PPGeDrawRect(60.0f, sy, 420.0f, sy + 1.0f, CalcFadedColor(0xFFFFFFFF));
PPGeDrawRect(60.0f, ey, 420.0f, ey + 1.0f, CalcFadedColor(0xFFFFFFFF));
}
+14 -11
View File
@@ -48,20 +48,17 @@ struct pspUtilityDialogCommon
s32_le reserved[4]; /** Set to 0 */
};
class PSPDialog
{
class PSPDialog {
public:
PSPDialog(UtilityDialogType type);
virtual ~PSPDialog();
PSPDialog(UtilityDialogType type) : dialogType_(type) {}
virtual ~PSPDialog() {}
virtual int Update(int animSpeed) = 0;
virtual int Shutdown(bool force = false);
virtual void DoState(PointerWrap &p);
virtual pspUtilityDialogCommon *GetCommonParam();
enum DialogStatus
{
enum DialogStatus {
SCE_UTILITY_STATUS_NONE = 0,
SCE_UTILITY_STATUS_INITIALIZE = 1,
SCE_UTILITY_STATUS_RUNNING = 2,
@@ -70,8 +67,7 @@ public:
SCE_UTILITY_STATUS_SCREENSHOT_UNKNOWN = 5,
};
enum DialogStockButton
{
enum DialogStockButton {
DS_BUTTON_NONE = 0x00,
DS_BUTTON_OK = 0x01,
DS_BUTTON_CANCEL = 0x02,
@@ -98,6 +94,7 @@ protected:
bool IsButtonHeld(int checkButton, int &framesHeld, int framesHeldThreshold = 30, int framesHeldRepeatRate = 10);
// The caption override is assumed to have a size of 64 bytes.
void DisplayButtons(int flags, std::string_view caption = "");
void DisplayMessage2(std::string_view text1, std::string_view text2a = "", std::string_view text2b = "", std::string_view text3a = "", std::string_view text3b = "", bool hasYesNo = false, bool hasOK = false);
void ChangeStatus(DialogStatus newStatus, int delayUs);
void ChangeStatusInit(int delayUs);
void ChangeStatusShutdown(int delayUs);
@@ -129,8 +126,14 @@ protected:
ImageID okButtonImg;
ImageID cancelButtonImg;
int okButtonFlag;
int cancelButtonFlag;
int okButtonFlag = 0;
int cancelButtonFlag = 0;
// DisplayMessage2 variables
int yesnoChoice = 0;
float scrollPos_ = 0.0f;
int framesUpHeld_ = 0;
int framesDownHeld_ = 0;
private:
DialogStatus status = SCE_UTILITY_STATUS_NONE;
+1 -6
View File
@@ -78,8 +78,7 @@ private:
void FormatErrorCode(uint32_t code);
void DisplayMessage(const std::string &text, bool hasYesNo = false, bool hasOK = false);
enum Flags
{
enum Flags {
DS_MSG = 0x1,
DS_ERRORMSG = 0x2,
DS_YESNO = 0x4,
@@ -98,9 +97,5 @@ private:
int messageDialogAddr = 0;
char msgText[512];
int yesnoChoice = 0;
float scrollPos_ = 0.0f;
int framesUpHeld_ = 0;
int framesDownHeld_ = 0;
};
+6 -144
View File
@@ -52,13 +52,6 @@ struct ScanInfos {
SceNetAdhocctlScanInfoEmu si;
} PACK;
PSPNetconfDialog::PSPNetconfDialog(UtilityDialogType type) : PSPDialog(type) {
}
PSPNetconfDialog::~PSPNetconfDialog() {
}
int PSPNetconfDialog::Init(u32 paramAddr) {
// Already running
if (ReadStatus() != SCE_UTILITY_STATUS_NONE)
@@ -86,7 +79,6 @@ int PSPNetconfDialog::Init(u32 paramAddr) {
}
void PSPNetconfDialog::DrawBanner() {
PPGeDrawRect(0, 0, 480, 22, CalcFadedColor(0x65636358));
PPGeStyle textStyle = FadedStyle(PPGeAlign::BOX_VCENTER, 0.6f);
@@ -103,134 +95,6 @@ void PSPNetconfDialog::DrawIndicator() {
PPGeDrawImage(456, 248, 20.0f, 20.0f, 1, 10, 1, 10, 10, 10, FadedImageStyle());
}
void PSPNetconfDialog::DisplayMessage(std::string_view text1, std::string_view text2a, std::string_view text2b, std::string_view text3a, std::string_view text3b, bool hasYesNo, bool hasOK) {
auto di = GetI18NCategory(I18NCat::DIALOG);
PPGeStyle buttonStyle = FadedStyle(PPGeAlign::BOX_CENTER, FONT_SCALE);
PPGeStyle messageStyle = FadedStyle(PPGeAlign::BOX_HCENTER, FONT_SCALE);
PPGeStyle messageStyleRight = FadedStyle(PPGeAlign::BOX_RIGHT, FONT_SCALE);
PPGeStyle messageStyleLeft = FadedStyle(PPGeAlign::BOX_LEFT, FONT_SCALE);
std::string text2 = std::string(text2a) + " " + std::string(text2b);
std::string text3 = std::string(text3a) + " " + std::string(text3b);
// Without the scrollbar, we have 350 total pixels.
float WRAP_WIDTH = 300.0f;
if (UTF8StringNonASCIICount(text1) >= (int)text1.size() / 4) {
WRAP_WIDTH = 336.0f;
if (text1.size() > 12) {
messageStyle.scale = 0.6f;
}
}
float totalHeight1 = 0.0f;
PPGeMeasureText(nullptr, &totalHeight1, text1, FONT_SCALE, PPGE_LINE_WRAP_WORD, WRAP_WIDTH);
float totalHeight2 = 0.0f;
if (text2 != " ")
PPGeMeasureText(nullptr, &totalHeight2, text2, FONT_SCALE, PPGE_LINE_USE_ELLIPSIS, WRAP_WIDTH);
float totalHeight3 = 0.0f;
if (text3 != " ")
PPGeMeasureText(nullptr, &totalHeight3, text3, FONT_SCALE, PPGE_LINE_USE_ELLIPSIS, WRAP_WIDTH);
float marginTop = 0.0f;
if (text2 != " " || text3 != " ")
marginTop = 11.0f;
float totalHeight = totalHeight1 + totalHeight2 + totalHeight3 + marginTop;
// The PSP normally only shows about 8 lines at a time.
// For improved UX, we intentionally show part of the next line.
float visibleHeight = std::min(totalHeight, 175.0f);
float h2 = visibleHeight / 2.0f;
float centerY = 135.0f;
float sy = centerY - h2 - 15.0f;
float ey = centerY + h2 + 20.0f;
float buttonY = centerY + h2 + 5.0f;
auto drawSelectionBoxAndAdjust = [&](float x) {
// Box has a fixed size.
float w = 15.0f;
float h = 8.0f;
PPGeDrawRect(x - w, buttonY - h, x + w, buttonY + h, CalcFadedColor(0x6DCFCFCF));
centerY -= h + 5.0f;
sy -= h + 5.0f;
ey = buttonY + h * 2.0f + 5.0f;
};
if (hasYesNo) {
if (yesnoChoice == 1) {
drawSelectionBoxAndAdjust(204.0f);
}
else {
drawSelectionBoxAndAdjust(273.0f);
}
PPGeDrawText(di->T("Yes"), 203.0f, buttonY - 1.0f, buttonStyle);
PPGeDrawText(di->T("No"), 272.0f, buttonY - 1.0f, buttonStyle);
if (IsButtonPressed(CTRL_LEFT) && yesnoChoice == 0) {
yesnoChoice = 1;
}
else if (IsButtonPressed(CTRL_RIGHT) && yesnoChoice == 1) {
yesnoChoice = 0;
}
buttonY += 8.0f + 5.0f;
}
if (hasOK) {
drawSelectionBoxAndAdjust(240.0f);
PPGeDrawText(di->T("OK"), 239.0f, buttonY - 1.0f, buttonStyle);
buttonY += 8.0f + 5.0f;
}
PPGeScissor(0, (int)(centerY - h2 - 2), 480, (int)(centerY + h2 + 2));
PPGeDrawTextWrapped(text1, 240.0f, centerY - h2 - scrollPos_, WRAP_WIDTH, 0, messageStyle);
if (!text2a.empty()) {
if (!text2b.empty())
PPGeDrawTextWrapped(text2a, 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleRight);
else
PPGeDrawTextWrapped(text2a, 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyle);
}
if (!text2b.empty())
PPGeDrawTextWrapped(text2b, 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleLeft);
if (!text3a.empty()) {
if (!text3b.empty())
PPGeDrawTextWrapped(text3a, 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleRight);
else
PPGeDrawTextWrapped(text3a, 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyle);
}
if (!text3b.empty())
PPGeDrawTextWrapped(text3b, 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleLeft);
PPGeScissorReset();
// Do we need a scrollbar?
if (visibleHeight < totalHeight) {
float scrollSpeed = 5.0f;
float scrollMax = totalHeight - visibleHeight;
float bobHeight = (visibleHeight / totalHeight) * visibleHeight;
float bobOffset = (scrollPos_ / scrollMax) * (visibleHeight - bobHeight);
float bobY1 = centerY - h2 + bobOffset;
PPGeDrawRect(415.0f, bobY1, 420.0f, bobY1 + bobHeight, CalcFadedColor(0xFFCCCCCC));
auto buttonDown = [this](int btn, int& held) {
if (IsButtonPressed(btn)) {
held = 0;
return true;
}
return IsButtonHeld(btn, held, 1, 1);
};
if (buttonDown(CTRL_DOWN, framesDownHeld_) && scrollPos_ < scrollMax) {
scrollPos_ = std::min(scrollMax, scrollPos_ + scrollSpeed);
}
if (buttonDown(CTRL_UP, framesUpHeld_) && scrollPos_ > 0.0f) {
scrollPos_ = std::max(0.0f, scrollPos_ - scrollSpeed);
}
}
PPGeDrawRect(60.0f, sy, 420.0f, sy + 1.0f, CalcFadedColor(0xFFFFFFFF));
PPGeDrawRect(60.0f, ey, 420.0f, ey + 1.0f, CalcFadedColor(0xFFFFFFFF));
}
int PSPNetconfDialog::Update(int animSpeed) {
if (ReadStatus() != SCE_UTILITY_STATUS_RUNNING) {
return SCE_ERROR_UTILITY_INVALID_STATUS;
@@ -283,18 +147,16 @@ int PSPNetconfDialog::Update(int animSpeed) {
hideNotice = true;
StartFade(true);
}
}
else {
} else {
PPGeDrawRect(0, 0, 480, 272, CalcFadedColor(0xC0C8B2AC));
DrawBanner();
DrawIndicator();
if (state == PSP_NET_APCTL_STATE_GOT_IP || state == PSP_NET_APCTL_STATE_GETTING_IP) {
DisplayMessage(di->T("ObtainingIP", "Obtaining IP address.\nPlease wait..."), di->T("ConnectionName", "Connection Name"), netApctlInfo.name, di->T("SSID"), netApctlInfo.ssid);
}
else {
DisplayMessage2(di->T("ObtainingIP", "Obtaining IP address.\nPlease wait..."), di->T("ConnectionName", "Connection Name"), netApctlInfo.name, di->T("SSID"), netApctlInfo.ssid);
} else {
// Skipping the Select Connection screen since we only have 1 fake profile
DisplayMessage(di->T("ConnectingAP", "Connecting to the access point.\nPlease wait..."), di->T("ConnectionName", "Connection Name"), netApctlInfo.name, di->T("SSID"), netApctlInfo.ssid);
DisplayMessage2(di->T("ConnectingAP", "Connecting to the access point.\nPlease wait..."), di->T("ConnectionName", "Connection Name"), netApctlInfo.name, di->T("SSID"), netApctlInfo.ssid);
}
DisplayButtons(DS_BUTTON_CANCEL, di->T("Cancel"));
@@ -334,7 +196,7 @@ int PSPNetconfDialog::Update(int animSpeed) {
if (timedout) {
// FIXME: Do we need to show error message?
std::string message(di->T("InternalError", "An internal error has occurred."));
DisplayMessage(message + StringFromFormat("\n(%08X)", connResult));
DisplayMessage2(message + StringFromFormat("\n(%08X)", connResult));
DisplayButtons(DS_BUTTON_CANCEL, di->T("Back"));
}
else {
@@ -342,7 +204,7 @@ int PSPNetconfDialog::Update(int animSpeed) {
if (g_Config.iWlanAdhocChannel == PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC)
channel = "Automatic";
DisplayMessage(di->T("ConnectingPleaseWait", "Connecting.\nPlease wait..."), std::string(di->T("Channel:")) + std::string(" ") + std::string(di->T(channel)));
DisplayMessage2(di->T("ConnectingPleaseWait", "Connecting.\nPlease wait..."), std::string(di->T("Channel:")) + std::string(" ") + std::string(di->T(channel)));
// Only Join mode is showing Cancel button on KHBBS and the button will fade out before the dialog is fading out, probably because it's already connected thus can't be canceled anymore
if (request.netAction == NETCONF_JOIN_ADHOC)
+2 -10
View File
@@ -34,11 +34,9 @@ struct SceUtilityNetconfParam {
int netWifiSpot; // Flag to allow WIFI connections
};
class PSPNetconfDialog: public PSPDialog {
class PSPNetconfDialog : public PSPDialog {
public:
PSPNetconfDialog(UtilityDialogType type);
~PSPNetconfDialog();
PSPNetconfDialog(UtilityDialogType type) : PSPDialog(type) {}
int Init(u32 paramAddr);
int Update(int animSpeed) override;
@@ -52,7 +50,6 @@ protected:
}
private:
void DisplayMessage(std::string_view text1, std::string_view text2a = "", std::string_view text2b = "", std::string_view text3a = "", std::string_view text3b = "", bool hasYesNo = false, bool hasOK = false);
void DrawBanner();
void DrawIndicator();
@@ -61,11 +58,6 @@ private:
int connResult = -1;
bool hideNotice = false;
int yesnoChoice = 0;
float scrollPos_ = 0.0f;
int framesUpHeld_ = 0;
int framesDownHeld_ = 0;
u32 scanInfosAddr = 0;
int scanStep = 0;
u64 startTime = 0;
+2 -140
View File
@@ -30,20 +30,11 @@
#include "Common/Data/Encoding/Utf8.h"
#include "Core/Reporting.h"
static const float FONT_SCALE = 0.65f;
// Needs testing.
const static int NP_INIT_DELAY_US = 200000;
const static int NP_SHUTDOWN_DELAY_US = 501000;
const static int NP_RUNNING_DELAY_US = 1000000; // faked delay to simulate signin process to give chance for players to read the text on the dialog
PSPNpSigninDialog::PSPNpSigninDialog(UtilityDialogType type) : PSPDialog(type) {
}
PSPNpSigninDialog::~PSPNpSigninDialog() {
}
int PSPNpSigninDialog::Init(u32 paramAddr) {
// Already running
if (ReadStatus() != SCE_UTILITY_STATUS_NONE)
@@ -72,7 +63,6 @@ int PSPNpSigninDialog::Init(u32 paramAddr) {
}
void PSPNpSigninDialog::DrawBanner() {
PPGeDrawRect(0, 0, 480, 22, CalcFadedColor(0x65636358));
PPGeStyle textStyle = FadedStyle(PPGeAlign::BOX_VCENTER, 0.6f);
@@ -94,134 +84,6 @@ void PSPNpSigninDialog::DrawLogo() {
PPGeDrawImage(416, 22, 64.0f, 64.0f, 1, 10, 1, 10, 64, 64, FadedImageStyle());
}
void PSPNpSigninDialog::DisplayMessage(std::string_view text1, std::string_view text2a, std::string_view text2b, std::string_view text3a, std::string_view text3b, bool hasYesNo, bool hasOK) {
auto di = GetI18NCategory(I18NCat::DIALOG);
PPGeStyle buttonStyle = FadedStyle(PPGeAlign::BOX_CENTER, FONT_SCALE);
PPGeStyle messageStyle = FadedStyle(PPGeAlign::BOX_HCENTER, FONT_SCALE);
PPGeStyle messageStyleRight = FadedStyle(PPGeAlign::BOX_RIGHT, FONT_SCALE);
PPGeStyle messageStyleLeft = FadedStyle(PPGeAlign::BOX_LEFT, FONT_SCALE);
std::string text2 = std::string(text2a) + " " + std::string(text2b);
std::string text3 = std::string(text3a) + " " + std::string(text3b);
// Without the scrollbar, we have 350 total pixels.
float WRAP_WIDTH = 300.0f;
if (UTF8StringNonASCIICount(text1) >= (int)text1.size() / 4) {
WRAP_WIDTH = 336.0f;
if (text1.size() > 12) {
messageStyle.scale = 0.6f;
}
}
float totalHeight1 = 0.0f;
PPGeMeasureText(nullptr, &totalHeight1, text1, FONT_SCALE, PPGE_LINE_WRAP_WORD, WRAP_WIDTH);
float totalHeight2 = 0.0f;
if (text2 != " ")
PPGeMeasureText(nullptr, &totalHeight2, text2, FONT_SCALE, PPGE_LINE_USE_ELLIPSIS, WRAP_WIDTH);
float totalHeight3 = 0.0f;
if (text3 != " ")
PPGeMeasureText(nullptr, &totalHeight3, text3, FONT_SCALE, PPGE_LINE_USE_ELLIPSIS, WRAP_WIDTH);
float marginTop = 0.0f;
if (text2 != " " || text3 != " ")
marginTop = 11.0f;
float totalHeight = totalHeight1 + totalHeight2 + totalHeight3 + marginTop;
// The PSP normally only shows about 8 lines at a time.
// For improved UX, we intentionally show part of the next line.
float visibleHeight = std::min(totalHeight, 175.0f);
float h2 = visibleHeight / 2.0f;
float centerY = 135.0f;
float sy = centerY - h2 - 15.0f;
float ey = centerY + h2 + 20.0f;
float buttonY = centerY + h2 + 5.0f;
auto drawSelectionBoxAndAdjust = [&](float x) {
// Box has a fixed size.
float w = 15.0f;
float h = 8.0f;
PPGeDrawRect(x - w, buttonY - h, x + w, buttonY + h, CalcFadedColor(0x6DCFCFCF));
centerY -= h + 5.0f;
sy -= h + 5.0f;
ey = buttonY + h * 2.0f + 5.0f;
};
if (hasYesNo) {
if (yesnoChoice == 1) {
drawSelectionBoxAndAdjust(204.0f);
}
else {
drawSelectionBoxAndAdjust(273.0f);
}
PPGeDrawText(di->T("Yes"), 203.0f, buttonY - 1.0f, buttonStyle);
PPGeDrawText(di->T("No"), 272.0f, buttonY - 1.0f, buttonStyle);
if (IsButtonPressed(CTRL_LEFT) && yesnoChoice == 0) {
yesnoChoice = 1;
}
else if (IsButtonPressed(CTRL_RIGHT) && yesnoChoice == 1) {
yesnoChoice = 0;
}
buttonY += 8.0f + 5.0f;
}
if (hasOK) {
drawSelectionBoxAndAdjust(240.0f);
PPGeDrawText(di->T("OK"), 239.0f, buttonY - 1.0f, buttonStyle);
buttonY += 8.0f + 5.0f;
}
PPGeScissor(0, (int)(centerY - h2 - 2), 480, (int)(centerY + h2 + 2));
PPGeDrawTextWrapped(text1, 240.0f, centerY - h2 - scrollPos_, WRAP_WIDTH, 0, messageStyle);
if (!text2a.empty()) {
if (!text2b.empty())
PPGeDrawTextWrapped(text2a, 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleRight);
else
PPGeDrawTextWrapped(text2a, 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyle);
}
if (!text2b.empty())
PPGeDrawTextWrapped(text2b, 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleLeft);
if (!text3a.empty()) {
if (!text3b.empty())
PPGeDrawTextWrapped(text3a, 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleRight);
else
PPGeDrawTextWrapped(text3a, 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyle);
}
if (!text3b.empty())
PPGeDrawTextWrapped(text3b, 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleLeft);
PPGeScissorReset();
// Do we need a scrollbar?
if (visibleHeight < totalHeight) {
float scrollSpeed = 5.0f;
float scrollMax = totalHeight - visibleHeight;
float bobHeight = (visibleHeight / totalHeight) * visibleHeight;
float bobOffset = (scrollPos_ / scrollMax) * (visibleHeight - bobHeight);
float bobY1 = centerY - h2 + bobOffset;
PPGeDrawRect(415.0f, bobY1, 420.0f, bobY1 + bobHeight, CalcFadedColor(0xFFCCCCCC));
auto buttonDown = [this](int btn, int& held) {
if (IsButtonPressed(btn)) {
held = 0;
return true;
}
return IsButtonHeld(btn, held, 1, 1);
};
if (buttonDown(CTRL_DOWN, framesDownHeld_) && scrollPos_ < scrollMax) {
scrollPos_ = std::min(scrollMax, scrollPos_ + scrollSpeed);
}
if (buttonDown(CTRL_UP, framesUpHeld_) && scrollPos_ > 0.0f) {
scrollPos_ = std::max(0.0f, scrollPos_ - scrollSpeed);
}
}
PPGeDrawRect(60.0f, sy, 420.0f, sy + 1.0f, CalcFadedColor(0xFFFFFFFF));
PPGeDrawRect(60.0f, ey, 420.0f, ey + 1.0f, CalcFadedColor(0xFFFFFFFF));
}
int PSPNpSigninDialog::Update(int animSpeed) {
if (ReadStatus() != SCE_UTILITY_STATUS_RUNNING) {
return SCE_ERROR_UTILITY_INVALID_STATUS;
@@ -245,13 +107,13 @@ int PSPNpSigninDialog::Update(int animSpeed) {
// DNAS dialog
if (step >= 2 && now - startTime > NP_RUNNING_DELAY_US) {
DrawLogo();
DisplayMessage(di->T("PleaseWait", "Please wait..."));
DisplayMessage2(di->T("PleaseWait", "Please wait..."));
step++;
}
// Signin dialog
else {
// Skipping the Select Connection screen since we only have 1 fake profile
DisplayMessage(di->T("SigninPleaseWait", "Signing in...\nPlease wait."));
DisplayMessage2(di->T("SigninPleaseWait", "Signing in...\nPlease wait."));
}
DisplayButtons(DS_BUTTON_CANCEL, di->T("Cancel"));
+2 -11
View File
@@ -20,7 +20,6 @@
#include "Core/Dialog/PSPDialog.h"
#include "Core/MemMapHelpers.h"
struct SceUtilityNpSigninParam {
pspUtilityDialogCommon common;
// Initially all zero? Or is there a possibility for one of these unknown to be a buffer to a packet data if it wasn't null?
@@ -30,11 +29,9 @@ struct SceUtilityNpSigninParam {
int unknown3;
};
class PSPNpSigninDialog: public PSPDialog {
class PSPNpSigninDialog : public PSPDialog {
public:
PSPNpSigninDialog(UtilityDialogType type);
~PSPNpSigninDialog();
PSPNpSigninDialog(UtilityDialogType type) : PSPDialog(type) {}
int Init(u32 paramAddr);
int Update(int animSpeed) override;
@@ -48,7 +45,6 @@ protected:
}
private:
void DisplayMessage(std::string_view text1, std::string_view text2a = "", std::string_view text2b = "", std::string_view text3a = "", std::string_view text3b = "", bool hasYesNo = false, bool hasOK = false);
void DrawBanner();
void DrawIndicator();
void DrawLogo();
@@ -57,11 +53,6 @@ private:
u32 requestAddr = 0;
//int npSigninResult = -1;
int yesnoChoice = 0;
float scrollPos_ = 0.0f;
int framesUpHeld_ = 0;
int framesDownHeld_ = 0;
u64 startTime = 0;
int step = 0;
};
+4 -10
View File
@@ -69,7 +69,7 @@
#define SCE_UTILITY_SAVEDATA_ERROR_SIZES_WRONG_UMD (0x801103Ca)
#define SCE_UTILITY_SAVEDATA_ERROR_SIZES_INTERNAL (0x801103Cb)
class PSPSaveDialog: public PSPDialog {
class PSPSaveDialog : public PSPDialog {
public:
PSPSaveDialog(UtilityDialogType type);
~PSPSaveDialog();
@@ -88,7 +88,6 @@ protected:
}
private:
void DisplayBanner(int which);
void DisplaySaveList(bool canMove = true);
void DisplaySaveIcon(bool checkExists);
@@ -101,8 +100,7 @@ private:
void StartIOThread();
void ExecuteNotVisibleIOAction();
enum DisplayState
{
enum DisplayState {
DS_NONE,
DS_SAVE_LIST_CHOICE,
@@ -128,8 +126,7 @@ private:
DS_DELETE_FAILED,
};
enum DialogBanner
{
enum DialogBanner {
DB_NONE,
DB_SAVE,
DB_LOAD,
@@ -145,10 +142,7 @@ private:
u32 requestAddr = 0;
int currentSelectedSave = 0;
int yesnoChoice = 0;
enum SaveIOStatus
{
enum SaveIOStatus {
SAVEIO_NONE,
SAVEIO_PENDING,
SAVEIO_DONE,
+20 -1
View File
@@ -163,6 +163,8 @@ void AfterApctlMipsCall::SetData(int HandlerID, int OldState, int NewState, int
bool LoadDNSForGameID(std::string_view gameID, InfraDNSConfig *dns) {
using namespace json;
*dns = {};
// TODO: Load from cache instead of zip (if possible), and sometimes update it.
size_t jsonSize;
std::unique_ptr<uint8_t[]> data(g_VFS.ReadFile("infra-dns.json", &jsonSize));
@@ -181,7 +183,16 @@ bool LoadDNSForGameID(std::string_view gameID, InfraDNSConfig *dns) {
const JsonGet def = root.getDict("default");
// Load the default DNS.
dns->dns = def.getStringOr("dns", "");;
if (def) {
dns->dns = def.getStringOr("dns", "");
if (def.hasChild("revival_credits", JSON_OBJECT)) {
const JsonGet revived = def.getDict("revival_credits");
if (revived) {
dns->revivalTeam = revived.getStringOr("group", "");
dns->revivalTeamURL = revived.getStringOr("url", "");
}
}
}
const JsonNode *games = root.getArray("games");
for (const JsonNode *iter : games->value) {
@@ -245,6 +256,14 @@ bool LoadDNSForGameID(std::string_view gameID, InfraDNSConfig *dns) {
}
}
if (game.hasChild("revival_credits", JSON_OBJECT)) {
const JsonGet revived = game.getDict("revival_credits");
if (revived) {
dns->revivalTeam = revived.getStringOr("group", "");
dns->revivalTeamURL = revived.getStringOr("url", "");
}
}
// TODO: Check for not working platforms
break;
}
+3
View File
@@ -152,6 +152,9 @@ struct InfraDNSConfig {
std::map<std::string, std::string> fixedDNS;
int score;
std::string comment;
std::string revivalTeam;
std::string revivalTeamURL;
};
extern InfraDNSConfig g_infraDNSConfig;
+1 -2
View File
@@ -127,13 +127,12 @@ int NetResolver_StartNtoA(u32 resolverId, u32 hostnamePtr, u32 inAddrPtr, int ti
Memory::Write_U32(resolvedAddr, inAddrPtr);
return 0;
}
WARN_LOG(Log::sceNet, "Direct DNS lookup of '%s' at DNS server '%s' failed. Trying OS DNS...", hostname.c_str(), g_Config.sInfrastructureDNSServer.c_str());
// Attempt to execute a DNS resolution
if (!net::DNSResolve(hostname, "", &resolved, err)) {
// TODO: Return an error based on the outputted "err" (unfortunately it's already converted to string)
return hleLogError(Log::sceNet, ERROR_NET_RESOLVER_INVALID_HOST, "DNS Error Resolving %s (%s)\n", hostname.c_str(),
return hleLogError(Log::sceNet, ERROR_NET_RESOLVER_INVALID_HOST, "OS DNS Error Resolving %s (%s)\n", hostname.c_str(),
err.c_str());
}
+5 -4
View File
@@ -413,9 +413,9 @@ static void ExecuteWebServer() {
http->SetFallbackHandler(&HandleFallback);
http->RegisterHandler("/debugger", &ForwardDebuggerRequest);
if (!http->Listen(g_Config.iRemoteISOPort)) {
if (!http->Listen(0)) {
ERROR_LOG(Log::FileSystem, "Unable to listen on any port");
if (!http->Listen(g_Config.iRemoteISOPort, "debugger-webserver")) {
if (!http->Listen(0, "debugger-webserver")) {
ERROR_LOG(Log::FileSystem, "Unable to listen on any port (debugger - webserver)");
UpdateStatus(ServerStatus::FINISHED);
return;
}
@@ -454,7 +454,8 @@ bool StartWebServer(WebServerFlags flags) {
case ServerStatus::FINISHED:
serverThread.join();
// Intentional fallthrough.
[[fallthrough]]; // Intentional fallthrough.
case ServerStatus::STOPPED:
serverStatus = ServerStatus::STARTING;
serverFlags = (int)flags;
+16 -1
View File
@@ -43,6 +43,7 @@
#include "Core/HLE/sceDisplay.h"
#include "Core/HLE/sceUmd.h"
#include "Core/HLE/sceNet.h"
#include "Core/HLE/sceNetInet.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
@@ -276,9 +277,10 @@ void GamePauseScreen::update() {
finishNextFrame_ = false;
}
if (netInited != lastNetInited_) {
if (netInited != lastNetInited_ || netInetInited != lastNetInetInited_) {
INFO_LOG(Log::sceNet, "Network status changed, recreating views");
RecreateViews();
lastNetInetInited_ = netInetInited;
lastNetInited_ = netInited;
}
@@ -384,6 +386,19 @@ void GamePauseScreen::CreateViews() {
if (netInited) {
leftColumnItems->Add(new NoticeView(NoticeLevel::INFO, nw->T("Network connected"), ""));
if (!g_infraDNSConfig.revivalTeam.empty() && netInetInited) {
leftColumnItems->Add(new TextView(std::string(nw->T("Infrastructure Mode server by")) + ":"));
leftColumnItems->Add(new TextView(g_infraDNSConfig.revivalTeam));
if (!g_infraDNSConfig.revivalTeamURL.empty()) {
leftColumnItems->Add(new Button(g_infraDNSConfig.revivalTeamURL))->OnClick.Add([](UI::EventParams &e) {
if (!g_infraDNSConfig.revivalTeamURL.empty()) {
System_LaunchUrl(LaunchUrlType::BROWSER_URL, g_infraDNSConfig.revivalTeamURL.c_str());
}
return UI::EVENT_DONE;
});
}
}
}
bool achievementsAllowSavestates = !Achievements::HardcoreModeActive() || g_Config.bAchievementsSaveStateInHardcoreMode;
+1
View File
@@ -65,4 +65,5 @@ private:
UI::Button *playButton_ = nullptr;
bool lastNetInited_ = false;
bool lastNetInetInited_ = false;
};
+17 -9
View File
@@ -1,7 +1,7 @@
{
"comment": "This file contains our built-in DNS used by the Auto mode in Infrastructure. In addition to being shipped, it'll also be hosted on ppsspp.org. Game names below are not important.",
"default": {
"dns": "67.222.156.251",
"dns": "67.222.156.250",
"revival_credits": {
"group": "PS Rewired",
"url": "https://psrewired.com/"
@@ -11,7 +11,7 @@
{
"name": "Medal of Honor: Heroes",
"comment": {
"en_US": "Works, but not on Windows",
"en_US": "Works"
},
"revival_credits": {
"group": "MOHH Revival",
@@ -38,7 +38,7 @@
"ULJM05213",
"ULUS10141",
"NPJH50306"
],
]
},
{
"name": "Medal of Honor 2",
@@ -63,7 +63,7 @@
"ULES00988"
],
"not_working_ids": [
"ULJM05301",
"ULJM05301"
]
},
{
@@ -77,7 +77,7 @@
},
"dns": "145.239.30.230",
"domains": {
"hub.psnexus.net": "145.239.30.230",
"hub.psnexus.net": "145.239.30.230"
},
"other_ids": [
"UCUS98612",
@@ -90,7 +90,7 @@
{
"name": "Wipeout Pulse",
"comment": {
"en_US": "Great",
"en_US": "Great"
},
"revival_credits": {
"group": "The AG Racing Foundation",
@@ -106,12 +106,12 @@
"other_ids": [
"UCKS45078"
],
"not_working_platforms": [],
"not_working_platforms": []
},
{
"name": "Motorstorm: Artic Edge",
"comment": {
"en_US": "Works",
"en_US": "Works"
},
"revival_credits": {
"group": "The AG Racing Foundation",
@@ -129,7 +129,15 @@
"UCAS40266",
"UCKS45124",
"NPJG00047"
],
]
},
{
"name": "Ratchet & Clank - Size Matters",
"dns": "67.222.156.251",
"other_ids": [
"UCES00420",
"UCUS98633"
]
}
]
}