From 6eed189855643af33462c71a219f2a22aae30ce6 Mon Sep 17 00:00:00 2001 From: MusicalProgrammer Date: Tue, 5 Nov 2019 20:47:06 -0500 Subject: [PATCH] Added an error message if a level fails to load. --- DataModelInstance.cpp | 7 +++++++ ErrorFunctions.cpp | 16 ++++++++++++++++ ErrorFunctions.h | 4 +++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/DataModelInstance.cpp b/DataModelInstance.cpp index af669e1..4ac99a0 100644 --- a/DataModelInstance.cpp +++ b/DataModelInstance.cpp @@ -5,6 +5,7 @@ #include #include #include +#include "ErrorFunctions.h" using namespace std; using namespace rapidxml; @@ -410,6 +411,12 @@ bool DataModelInstance::load(const char* filename, bool clearObjects) name = tname; return true; } + else + { + std::stringstream msg; + msg << "Failed to load file:" << std::endl << filename << std::endl << strerror(errno); + MessageBoxStr(msg.str()); + } } bool DataModelInstance::readXMLFileStream(std::ifstream* file) diff --git a/ErrorFunctions.cpp b/ErrorFunctions.cpp index bc8d5f8..86beba2 100644 --- a/ErrorFunctions.cpp +++ b/ErrorFunctions.cpp @@ -1,6 +1,8 @@ +#include #include "ErrorFunctions.h" #include "Globals.h" + void OnError(int err, std::string msg) { //g_usableApp->window()->setInputCaptureCount(0); @@ -10,4 +12,18 @@ void OnError(int err, std::string msg) //clearInstances(); MessageBox(NULL, emsg.c_str(), title.c_str(), MB_OK); exit(err); +} + + +void MessageBoxStr(std::string msg) +{ + std::string title = g_PlaceholderName; + MessageBox(NULL, msg.c_str(), title.c_str(), MB_OK); +} + +void MessageBoxStream(std::stringstream msg) +{ + std::string strMsg = msg.str(); + std::string title = g_PlaceholderName; + MessageBox(NULL, strMsg.c_str(), title.c_str(), MB_OK); } \ No newline at end of file diff --git a/ErrorFunctions.h b/ErrorFunctions.h index e3a838d..c82c54a 100644 --- a/ErrorFunctions.h +++ b/ErrorFunctions.h @@ -1,4 +1,6 @@ #pragma once #include -void OnError(int err, std::string msg = ""); \ No newline at end of file +void OnError(int err, std::string msg = ""); +void MessageBoxStr(std::string msg); +void MessageBoxStream(std::stringstream msg); \ No newline at end of file