Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/UI/AdhocServerScreen.h
10520 views
1
#pragma once
2
3
#include <vector>
4
#include <string>
5
#include <thread>
6
#include <condition_variable>
7
8
#include "Common/UI/View.h"
9
#include "Common/UI/PopupScreens.h"
10
#include "Core/Config.h" // for AdhocServerListEntry!
11
#include "Common/UI/Notice.h"
12
#include "Core/HLE/sceNetAdhoc.h"
13
14
struct AdhocUser {
15
std::string name;
16
std::vector<int> pdp_ports;
17
std::vector<int> ptp_ports;
18
};
19
20
struct AdhocGroup {
21
std::string name;
22
int usercount;
23
std::vector<AdhocUser> users;
24
};
25
26
struct AdhocGame {
27
std::string name;
28
int usercount;
29
std::vector<AdhocGroup> groups;
30
std::vector<std::string> game_ids;
31
};
32
33
// Later, this might also show games-in-progress.
34
// For now, it's just a simple metadata viewer.
35
class AdhocServerInfoScreen : public UI::PopupScreen {
36
public:
37
AdhocServerInfoScreen(const AdhocServerListEntry &entry);
38
39
const char *tag() const override { return "AdhocServerInfo"; }
40
41
protected:
42
bool FillVertical() const override { return false; }
43
UI::Size PopupWidth() const override { return 650; }
44
bool ShowButtons() const override { return true; }
45
46
void CreatePopupContents(UI::ViewGroup *parent) override;
47
void update() override;
48
49
private:
50
AdhocServerListEntry entry_;
51
std::vector<AdhocGame> games_;
52
std::shared_ptr<http::Request> statusRequest_;
53
};
54
55
class AdhocServerScreen : public UI::PopupScreen {
56
public:
57
AdhocServerScreen(std::string *value, std::string_view title);
58
~AdhocServerScreen();
59
60
void CreatePopupContents(UI::ViewGroup *parent) override;
61
62
const char *tag() const override { return "AdhocServer"; }
63
64
bool RecreateParent() const {
65
return recreateParent_;
66
}
67
68
protected:
69
void OnCompleted(DialogResult result) override;
70
bool CanComplete(DialogResult result) override;
71
virtual UI::Size PopupWidth() const override { return 650; }
72
73
void sendMessage(UIMessage message, const char *value) override;
74
75
void dialogFinished(const Screen *screen, DialogResult result) override {
76
RecreateViews();
77
}
78
private:
79
void ResolverThread();
80
81
enum class ResolverState {
82
WAITING,
83
QUEUED,
84
PROGRESS,
85
READY,
86
QUIT,
87
};
88
89
std::string *value_;
90
std::string editValue_;
91
NoticeView *progressView_ = nullptr;
92
93
std::thread resolver_;
94
ResolverState resolverState_ = ResolverState::WAITING;
95
std::mutex resolverLock_;
96
std::condition_variable resolverCond_;
97
std::string toResolve_ = "";
98
bool toResolveResult_ = false;
99
std::string lastResolved_ = "";
100
bool lastResolvedResult_ = false;
101
bool recreateParent_ = false;
102
};
103
104
void AskToEditCurrentServer(int requestToken, ScreenManager *screenManager);
105
bool AdhocServerNameIsCustom();
106
107