-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartup_update_overlay_internal.h
More file actions
114 lines (100 loc) · 3.49 KB
/
Copy pathstartup_update_overlay_internal.h
File metadata and controls
114 lines (100 loc) · 3.49 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#pragma once
#include "startup_update_internal.h"
#include <atomic>
#include <memory>
#include <mutex>
namespace mapupdater::startup {
inline constexpr UINT kMsgOverlayUiRefresh = WM_APP + 0x101;
inline constexpr UINT kMsgOverlayWorkerDone = WM_APP + 0x102;
inline constexpr UINT kMsgOverlayToggle = WM_APP + 0x103;
inline constexpr UINT_PTR kTimerOverlayRefresh = 1;
inline constexpr UINT_PTR kTimerOverlayAutoClose = 2;
inline constexpr UINT_PTR kTimerOverlayDeferredToggle = 3;
inline constexpr int kBtnDownloadId = 1002;
inline constexpr int kBtnCloseId = 1003;
inline constexpr int kBtnLaterId = 1004;
inline constexpr int kBtnCancelId = 1005;
inline constexpr int kOverlayCollapsedWidth = 360;
inline constexpr int kOverlayCollapsedHeight = 58;
inline constexpr int kOverlayExpandedWidth = 560;
inline constexpr int kOverlayExpandedHeight = 350;
struct OverlayDownloadSession {
std::vector<DownloadItem> items;
LatestMapsInfo maps_info;
AppConfig config;
bool autoupdate_mode = false;
std::mutex mutex;
HWND hwnd = nullptr;
HANDLE worker_handle = nullptr;
std::atomic_bool cancel_requested{false};
std::atomic_bool ui_refresh_pending{false};
bool started = false;
bool running = false;
bool finished = false;
bool success = false;
bool canceled = false;
bool close_requested = false;
bool auto_close_armed = false;
size_t current_index = 0;
uint64_t current_downloaded = 0;
uint64_t current_total = 0;
uint64_t current_speed_bps = 0;
uint64_t last_nonzero_speed_bps = 0;
ULONGLONG speed_last_tick_ms = 0;
uint64_t speed_last_downloaded = 0;
uint64_t completed_map_bytes = 0;
uint64_t completed_mpq_bytes = 0;
uint64_t map_downloaded = 0;
uint64_t map_total = 0;
uint64_t mpq_downloaded = 0;
uint64_t mpq_total = 0;
bool map_needed = false;
bool mpq_needed = false;
std::wstring title_text;
std::wstring status_text;
std::wstring detail_text;
std::wstring error_text;
};
struct OverlayWindowContext {
std::shared_ptr<OverlayDownloadSession> session;
HWND hwnd = nullptr;
HWND host_hwnd = nullptr;
HWND title_hwnd = nullptr;
HWND version_hwnd = nullptr;
HWND changelog_hwnd = nullptr;
HWND status_hwnd = nullptr;
HWND detail_hwnd = nullptr;
HWND progress_hwnd = nullptr;
HWND progress_text_hwnd = nullptr;
HWND btn_download_hwnd = nullptr;
HWND btn_later_hwnd = nullptr;
HWND btn_cancel_hwnd = nullptr;
HWND btn_close_hwnd = nullptr;
bool expanded = false;
bool manual_position = false;
bool dragging = false;
bool toggle_visible = false;
bool toggle_tracking = false;
bool toggle_pressed_visual = false;
bool toggle_deferred_pending = false;
bool layout_initialized = false;
bool last_layout_expanded = false;
bool last_layout_show_toggle = false;
RECT toggle_rect = {};
RECT pending_list_rect = {};
RECT downloaded_list_rect = {};
POINT drag_cursor_start_screen = {};
POINT drag_window_start_screen = {};
std::wstring changelog_url;
size_t last_list_current_index = static_cast<size_t>(-1);
bool last_list_started = false;
bool last_list_running = false;
bool last_list_finished = false;
bool last_list_success = false;
bool last_list_canceled = false;
};
void SetOverlayFinishedState(const std::shared_ptr<OverlayDownloadSession> &session, bool success,
bool canceled, const std::wstring &error_text);
void OverlayCloseWorkerHandle(const std::shared_ptr<OverlayDownloadSession> &session);
DWORD WINAPI OverlayDownloadWorkerProc(LPVOID param);
} // namespace mapupdater::startup