mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2023-12-30 21:52:56 +00:00
Improved console output: added version constants and message box texts.
This commit is contained in:
parent
31530bef18
commit
8e43d06e84
@ -228,7 +228,7 @@ TPinballComponent* TPinballTable::find_component(LPCSTR componentName)
|
||||
}
|
||||
}
|
||||
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Table cant find:", componentName, nullptr);
|
||||
pb::ShowMessageBox(SDL_MESSAGEBOX_WARNING, "Table cant find:", componentName);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -242,7 +242,7 @@ TPinballComponent* TPinballTable::find_component(int groupIndex)
|
||||
}
|
||||
|
||||
snprintf(Buffer, sizeof Buffer, "%d", groupIndex);
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Table cant find (lh):", Buffer, nullptr);
|
||||
pb::ShowMessageBox(SDL_MESSAGEBOX_WARNING, "Table cant find (lh):", Buffer);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ int loader::error(int errorCode, int captionCode)
|
||||
|
||||
if (!errorText)
|
||||
errorText = loader_errors[index].Message;
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, errorCaption, errorText, nullptr);
|
||||
pb::ShowMessageBox(SDL_MESSAGEBOX_ERROR, errorCaption, errorText);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -678,3 +678,9 @@ std::string pb::make_path_name(const std::string& fileName)
|
||||
{
|
||||
return BasePath + fileName;
|
||||
}
|
||||
|
||||
void pb::ShowMessageBox(Uint32 flags, LPCSTR title, LPCSTR message)
|
||||
{
|
||||
fprintf(flags == SDL_MESSAGEBOX_ERROR ? stderr : stdout, "BL error: %s\n%s\n", title, message);
|
||||
SDL_ShowSimpleMessageBox(flags, title, message, winmain::MainWindow);
|
||||
}
|
||||
|
@ -78,6 +78,7 @@ public:
|
||||
static LPCSTR get_rc_string(Msg uID);
|
||||
static int get_rc_int(Msg uID, int* dst);
|
||||
static std::string make_path_name(const std::string& fileName);
|
||||
static void ShowMessageBox(Uint32 flags, LPCSTR title, LPCSTR message);
|
||||
private:
|
||||
static bool demo_mode;
|
||||
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include "translations.h"
|
||||
#include "font_selection.h"
|
||||
|
||||
constexpr const char* winmain::Version;
|
||||
|
||||
SDL_Window* winmain::MainWindow = nullptr;
|
||||
SDL_Renderer* winmain::Renderer = nullptr;
|
||||
ImGuiIO* winmain::ImIO = nullptr;
|
||||
@ -49,12 +51,17 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
||||
{
|
||||
std::set_new_handler(memalloc_failure);
|
||||
|
||||
printf("Game version: %s\n", Version);
|
||||
printf("Compiled with: SDL %d.%d.%d;", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
|
||||
printf(" SDL_mixer %d.%d.%d;", SDL_MIXER_MAJOR_VERSION, SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL);
|
||||
printf(" ImGui %s\n", IMGUI_VERSION);
|
||||
|
||||
// SDL init
|
||||
SDL_SetMainReady();
|
||||
if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO |
|
||||
SDL_INIT_EVENTS | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) < 0)
|
||||
{
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Could not initialize SDL2", SDL_GetError(), nullptr);
|
||||
pb::ShowMessageBox(SDL_MESSAGEBOX_ERROR, "Could not initialize SDL2", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -71,7 +78,7 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
||||
MainWindow = window;
|
||||
if (!window)
|
||||
{
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Could not create window", SDL_GetError(), nullptr);
|
||||
pb::ShowMessageBox(SDL_MESSAGEBOX_ERROR, "Could not create window", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -89,7 +96,7 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
||||
}
|
||||
if (!renderer)
|
||||
{
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Could not create renderer", SDL_GetError(), window);
|
||||
pb::ShowMessageBox(SDL_MESSAGEBOX_ERROR, "Could not create renderer", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
SDL_RendererInfo rendererInfo{};
|
||||
@ -181,8 +188,7 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
||||
message = message + (path[0] ? path : "working directory") + "\n";
|
||||
}
|
||||
}
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Could not load game data",
|
||||
message.c_str(), window);
|
||||
pb::ShowMessageBox(SDL_MESSAGEBOX_ERROR, "Could not load game data", message.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1036,7 +1042,7 @@ void winmain::memalloc_failure()
|
||||
Sound::Close();
|
||||
const char* caption = pb::get_rc_string(Msg::STRING270);
|
||||
const char* text = pb::get_rc_string(Msg::STRING279);
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, caption, text, MainWindow);
|
||||
pb::ShowMessageBox(SDL_MESSAGEBOX_ERROR, caption, text);
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
@ -1056,7 +1062,7 @@ void winmain::a_dialog()
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::TextUnformatted("Decompiled -> Ported to SDL");
|
||||
ImGui::TextUnformatted("Version 2.0.1");
|
||||
ImGui::Text("Version %s", Version);
|
||||
if (ImGui::SmallButton("Project home: https://github.com/k4zmu2a/SpaceCadetPinball"))
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 14)
|
||||
|
@ -65,6 +65,7 @@ class winmain
|
||||
using TimePoint = std::chrono::time_point<Clock>;
|
||||
|
||||
public:
|
||||
static constexpr const char* Version = "2.1.0 DEV";
|
||||
static bool single_step;
|
||||
static SDL_Window* MainWindow;
|
||||
static SDL_Renderer* Renderer;
|
||||
|
Loading…
Reference in New Issue
Block a user