mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
53 lines
1.6 KiB
C++
53 lines
1.6 KiB
C++
#include "Common/Net/Resolve.h"
|
|
#include "Common/System/Request.h"
|
|
#include "UI/UploadScreen.h"
|
|
#include "Common/StringUtils.h"
|
|
#include "Core/WebServer.h"
|
|
|
|
UploadScreen::UploadScreen() {
|
|
net::GetLocalIP4List(localIPs_);
|
|
|
|
StartWebServer(WebServerFlags::FILE_UPLOAD);
|
|
}
|
|
|
|
UploadScreen::~UploadScreen() {
|
|
StopWebServer(WebServerFlags::FILE_UPLOAD);
|
|
}
|
|
|
|
void UploadScreen::CreateViews() {
|
|
using namespace UI;
|
|
auto co = GetI18NCategory(I18NCat::NETWORKING);
|
|
root_ = new LinearLayout(ORIENT_VERTICAL);
|
|
LinearLayout *topBar = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
|
|
topBar->Add(new Choice(ImageID("I_NAVIGATE_BACK"), new LinearLayoutParams()))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
|
|
|
|
root_->Add(topBar);
|
|
|
|
if (prevRunning_) {
|
|
root_->Add(new TextView(co->T("On your other device, connect to the same network, then go to this URL:")));
|
|
for (const auto &ip : localIPs_) {
|
|
std::string url = StringFromFormat("http://%s:%d/upload", ip.c_str(), WebServerPort());
|
|
root_->Add(new TextView(url));
|
|
root_->Add(new Choice(ImageID("I_FILE_COPY")))->OnClick.Add([url](UI::EventParams &) {
|
|
System_CopyStringToClipboard(url);
|
|
});
|
|
}
|
|
} else {
|
|
root_->Add(new TextView(co->T("Connecting...")));
|
|
}
|
|
|
|
//infoText->SetTextAlignment(TEXT_ALIGN_CENTER);
|
|
//verticalLayout->AddView(infoText);
|
|
//AddStandardBack(verticalLayout);
|
|
//root_->AddView(verticalLayout);
|
|
}
|
|
|
|
void UploadScreen::update() {
|
|
UIScreen::update();
|
|
bool running = WebServerRunning(WebServerFlags::FILE_UPLOAD);
|
|
if (prevRunning_ != running) {
|
|
prevRunning_ = running;
|
|
RecreateViews();
|
|
}
|
|
}
|