Files
crown/Update/UpdateWindow.h
T
admin aa59132330 Rewrite Update module and update client/server sources
Update: drop Qt dependency, rewrite as pure Win32 using v142 toolset. Replace Update.ui/qrc and miniz-based Zip with Api/Crypto/Http/Json/Unzip/UpdateWindow modules.

CrownClient/CrownServer: update Verify and main sources, retarget x64 configs to v142 (VS2019) with SDK 10.0.19041.0, fix VMProtect SDK paths.
2026-10-17 16:31:54 +08:00

87 lines
2.1 KiB
C++

#pragma once
#include <windows.h>
#include <string>
#include "Worker.h"
namespace Gdiplus {
class Graphics;
}
namespace updater {
// 工作线程 -> UI 线程的状态投递结构,由窗口负责释放
struct UiState {
int percent = 0;
std::wstring status;
bool finished = false;
bool success = false;
};
class UpdateWindow {
public:
UpdateWindow();
~UpdateWindow();
UpdateWindow(const UpdateWindow&) = delete;
UpdateWindow& operator=(const UpdateWindow&) = delete;
bool Create(HINSTANCE instance, const UpdateOptions& options);
int MessageLoop();
private:
// 完整包模式下先让用户选安装目录,之后再切到更新进度
enum class Phase { PickDir, Updating };
static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT HandleMessage(UINT msg, WPARAM wParam, LPARAM lParam);
void OnPaint();
void DrawPickPanel(Gdiplus::Graphics& graphics);
void DrawProgressPanel(Gdiplus::Graphics& graphics);
void OnState(const UiState& state);
void RequestClose();
void Invalidate();
// 目录选择阶段
bool BrowseFolder();
void StartUpdate();
void StartWorker(const UpdateOptions& options);
bool HitCloseButton(int x, int y) const;
bool HitBrowseButton(int x, int y) const;
bool HitInstallButton(int x, int y) const;
bool HitCancelButton(int x, int y) const;
bool HitAnyButton(int x, int y) const;
void UpdateHover(int x, int y);
HWND hwnd_ = nullptr;
HINSTANCE instance_ = nullptr;
Worker worker_;
Phase phase_ = Phase::Updating;
UpdateOptions options_;
std::wstring installDir_;
bool started_ = false;
int percent_ = 0;
std::wstring status_;
bool finished_ = false;
bool success_ = false;
bool closing_ = false;
int closeState_ = 0; // 0 普通 1 悬停 2 按下
int browseState_ = 0;
int installState_ = 0;
int cancelState_ = 0;
int pressed_ = 0; // 0 无 1 关闭 2 浏览 3 安装 4 取消
bool tracking_ = false;
struct RenderContext;
RenderContext* render_ = nullptr;
};
}