SaveTool: use Magnum types.

This commit is contained in:
Guillaume Jacquemin 2021-06-20 14:13:30 +02:00
parent 3172939b53
commit e77f46ecc4
3 changed files with 13 additions and 13 deletions

View file

@ -78,7 +78,7 @@ SaveTool::SaveTool(const Arguments& arguments):
initialiseGui(); initialiseGui();
if((_initEventId = SDL_RegisterEvents(1)) == std::uint32_t(-1)) { if((_initEventId = SDL_RegisterEvents(1)) == UnsignedInt(-1)) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error",
"SDL_RegisterEvents failed in SaveTool::SaveTool(). Exiting...", nullptr); "SDL_RegisterEvents failed in SaveTool::SaveTool(). Exiting...", nullptr);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -219,7 +219,7 @@ void SaveTool::initEvent(SDL_Event& event) {
SDL_InitSubSystem(SDL_INIT_TIMER); SDL_InitSubSystem(SDL_INIT_TIMER);
_mbManager->checkGameState(); _mbManager->checkGameState();
_gameCheckTimerId = SDL_AddTimer(2000, _gameCheckTimerId = SDL_AddTimer(2000,
[](std::uint32_t interval, void* param)->std::uint32_t{ [](UnsignedInt interval, void* param)->UnsignedInt{
static_cast<MassBuilderManager*>(param)->checkGameState(); static_cast<MassBuilderManager*>(param)->checkGameState();
return interval; return interval;
}, },
@ -470,12 +470,12 @@ void SaveTool::drawGameState() {
} }
} }
void SaveTool::drawHelpMarker(const char* text, float wrap_pos) { void SaveTool::drawHelpMarker(const char* text, Float wrap_pos) {
ImGui::TextUnformatted(ICON_FA_QUESTION_CIRCLE); ImGui::TextUnformatted(ICON_FA_QUESTION_CIRCLE);
drawTooltip(text, wrap_pos); drawTooltip(text, wrap_pos);
} }
void SaveTool::drawTooltip(const char* text, float wrap_pos) { void SaveTool::drawTooltip(const char* text, Float wrap_pos) {
if(ImGui::IsItemHovered()){ if(ImGui::IsItemHovered()){
ImGui::BeginTooltip(); ImGui::BeginTooltip();
if(wrap_pos > 0.0f) { if(wrap_pos > 0.0f) {

View file

@ -66,7 +66,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void anyEvent(SDL_Event& event) override; void anyEvent(SDL_Event& event) override;
enum InitStatus: std::int32_t { enum InitStatus: Int {
InitSuccess, InitSuccess,
MbManagerFailure, MbManagerFailure,
ProfileManagerFailure ProfileManagerFailure
@ -101,8 +101,8 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void drawGameState(); void drawGameState();
// Convenience wrappers over ImGui stuff // Convenience wrappers over ImGui stuff
void drawHelpMarker(const char* text, float wrap_pos = 0.0f); void drawHelpMarker(const char* text, Float wrap_pos = 0.0f);
void drawTooltip(const char* text, float wrap_pos = 0.0f); void drawTooltip(const char* text, Float wrap_pos = 0.0f);
template<typename Functor, typename... Args> template<typename Functor, typename... Args>
auto drawUnsafeWidget(Functor func, Args... args) -> bool { auto drawUnsafeWidget(Functor func, Args... args) -> bool {
@ -147,7 +147,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
#endif #endif
std::thread _thread; std::thread _thread;
std::uint32_t _initEventId; UnsignedInt _initEventId;
Containers::Pointer<MassBuilderManager> _mbManager; Containers::Pointer<MassBuilderManager> _mbManager;
SDL_TimerID _gameCheckTimerId; SDL_TimerID _gameCheckTimerId;

View file

@ -31,7 +31,7 @@ static const std::string empty_str = "";
void SaveTool::drawManager() { void SaveTool::drawManager() {
ImGui::SetNextWindowPos({0.0f, ImGui::GetItemRectSize().y}, ImGuiCond_Always); ImGui::SetNextWindowPos({0.0f, ImGui::GetItemRectSize().y}, ImGuiCond_Always);
ImGui::SetNextWindowSize({float(windowSize().x()), float(windowSize().y()) - ImGui::GetItemRectSize().y}, ImGui::SetNextWindowSize({Float(windowSize().x()), Float(windowSize().y()) - ImGui::GetItemRectSize().y},
ImGuiCond_Always); ImGuiCond_Always);
if(!ImGui::Begin("##MainWindow", nullptr, if(!ImGui::Begin("##MainWindow", nullptr,
ImGuiWindowFlags_NoDecoration|ImGuiWindowFlags_NoMove| ImGuiWindowFlags_NoDecoration|ImGuiWindowFlags_NoMove|
@ -62,7 +62,7 @@ void SaveTool::drawManager() {
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::Checkbox("Unsafe mode", &_unsafeMode); ImGui::Checkbox("Unsafe mode", &_unsafeMode);
drawTooltip("Enabling this allows interactions deemed to be unsafe to do while the game is running.", drawTooltip("Enabling this allows interactions deemed to be unsafe to do while the game is running.",
float(windowSize().x()) * 0.35f); Float(windowSize().x()) * 0.35f);
ImGui::EndTable(); ImGui::EndTable();
} }
@ -207,7 +207,7 @@ void SaveTool::drawGeneralInfo() {
drawTooltip("This is the last mission selected in the mission selection screen, not the last mission played.", drawTooltip("This is the last mission selected in the mission selection screen, not the last mission played.",
windowSize().x() * 0.35f); windowSize().x() * 0.35f);
const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing(); const Float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
ImGui::Dummy({ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y - footer_height_to_reserve}); ImGui::Dummy({ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y - footer_height_to_reserve});
ImGui::Separator(); ImGui::Separator();
@ -229,7 +229,7 @@ void SaveTool::drawGeneralInfo() {
ImGui::SameLine(); ImGui::SameLine();
static std::int32_t credits; static Int credits;
if(drawUnsafeWidget([]{ return ImGui::Button("Edit credits"); })) { if(drawUnsafeWidget([]{ return ImGui::Button("Edit credits"); })) {
credits = _currentProfile->credits(); credits = _currentProfile->credits();
ImGui::OpenPopup("int_edit"); ImGui::OpenPopup("int_edit");
@ -315,7 +315,7 @@ void SaveTool::drawResearchInventory() {
drawUnsafeText("%i", _currentProfile->getter()); \ drawUnsafeText("%i", _currentProfile->getter()); \
ImGui::TableSetColumnIndex(2); \ ImGui::TableSetColumnIndex(2); \
ImGui::PushID(#setter); \ ImGui::PushID(#setter); \
static std::int32_t var = _currentProfile->getter(); \ static Int var = _currentProfile->getter(); \
if(drawUnsafeWidget([]{ return ImGui::SmallButton(ICON_FA_EDIT); })) { \ if(drawUnsafeWidget([]{ return ImGui::SmallButton(ICON_FA_EDIT); })) { \
(var) = _currentProfile->getter(); \ (var) = _currentProfile->getter(); \
ImGui::OpenPopup("int_edit"); \ ImGui::OpenPopup("int_edit"); \