vkdoom_m/src/common/widgets/netstartwindow.h
Magnus Norddahl 426837e7d4 Implement the timer class
Support calling ShowNetStartPane multiple times
2024-01-02 16:55:52 +01:00

47 lines
963 B
C++

#pragma once
#include <zwidget/core/widget.h>
#include <stdexcept>
class TextLabel;
class PushButton;
class Timer;
class NetStartWindow : public Widget
{
public:
static void ShowNetStartPane(const char* message, int maxpos);
static void HideNetStartPane();
static void SetNetStartProgress(int pos);
static bool RunMessageLoop(bool (*timer_callback)(void*), void* userdata);
private:
NetStartWindow();
void SetMessage(const std::string& message, int maxpos);
void SetProgress(int pos);
protected:
void OnClose() override;
void OnGeometryChanged() override;
private:
void OnCallbackTimerExpired();
TextLabel* MessageLabel = nullptr;
TextLabel* ProgressLabel = nullptr;
PushButton* AbortButton = nullptr;
Timer* CallbackTimer = nullptr;
int pos = 0;
int maxpos = 1;
bool (*timer_callback)(void*) = nullptr;
void* userdata = nullptr;
bool exitreason = false;
std::exception_ptr CallbackException;
static NetStartWindow* Instance;
};