-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChWindows.cpp
More file actions
85 lines (74 loc) · 2.19 KB
/
ChWindows.cpp
File metadata and controls
85 lines (74 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "./ChGameWindow.h"
#include "./ChScriptedWindow.h"
#include "./ChWindow.h"
constexpr const wchar_t *title = L"Chief Client";
constexpr const wchar_t *titleGame = title;
constexpr const wchar_t *titleSocial = L"Social";
constexpr const wchar_t *titleEditor = L"Editor";
constexpr const wchar_t *titleViewer = L"Viewer";
constexpr const wchar_t *titleScripting = L"Scripting";
ChWindow *ChWindows::getWindow(krunker::type type) {
switch (type) {
case krunker::Game:
return game;
case krunker::Social:
return social;
case krunker::Editor:
return editor;
case krunker::Viewer:
return viewer;
case krunker::type::Scripting:
return scripting;
default:
return nullptr;
}
}
ChWindows::ChWindows(ClientFolder &folder, AccountManager &accounts)
: game(new ChGameWindow(folder, accounts, *this, {0.8, 0.8}, titleGame)),
social(new ChScriptedWindow(folder, *this, {0.7, 0.7}, titleSocial)),
editor(new ChScriptedWindow(folder, *this, {0.8, 0.8}, titleEditor)),
viewer(new ChScriptedWindow(folder, *this, {0.8, 0.8}, titleViewer)),
scripting(
new ChScriptedWindow(folder, *this, {0.4, 0.5}, titleScripting)) {}
ChWindows::~ChWindows() {
delete game;
delete social;
delete editor;
delete viewer;
delete scripting;
}
void ChWindows::dispatch() {
game->dispatch();
social->dispatch();
editor->dispatch();
viewer->dispatch();
scripting->dispatch();
}
ChWindow::Status
ChWindows::navigate(UriW uri, ICoreWebView2 *sender,
std::function<void(ChWindow *newWindow)> open,
bool *shown) {
if (uri.host() == L"chief.krunker.io") {
if (shown)
*shown = false;
return ChWindow::Status::Ok;
}
ChWindow *window = getWindow(krunker::identifyType(uri));
if (!window) {
ShellExecute(NULL, L"open", uri.toString().c_str(), L"", L"", SW_SHOW);
if (open)
open(nullptr);
return ChWindow::Status::Ok;
}
return window->show(
uri, sender,
[window, open]() -> void {
if (open)
open(window);
},
shown);
}
bool ChWindows::shouldQuit() {
return !game->open && !social->open && !editor->open && !viewer->open &&
!scripting->open;
}