RigsofRods
Soft-body Physics Simulation
ErrorUtils.cpp
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2005-2012 Pierre-Michel Ricordel
4  Copyright 2007-2012 Thomas Fischer
5  Copyright 2013-2020 Petr Ohlidal
6 
7  For more information, see http://www.rigsofrods.org/
8 
9  Rigs of Rods is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License version 3, as
11  published by the Free Software Foundation.
12 
13  Rigs of Rods is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
28 #include "ErrorUtils.h"
29 
30 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
31 #include <windows.h>
32 #include <shlobj.h>
33 #include <shellapi.h> // for ShellExecuteW
34 #define _L
35 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
36 #define _L
37 #elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
38 #include "Language.h"
39 #endif
40 
41 using namespace Ogre;
42 
43 int ErrorUtils::ShowError(Ogre::UTFString title, Ogre::UTFString err)
44 {
45  Ogre::UTFString infoText = _L("An internal error occured in Rigs of Rods.\n\nTechnical details below: \n\n");
46  return ErrorUtils::ShowMsgBox(_L("FATAL ERROR"), infoText + err, 0);
47 }
48 
49 int ErrorUtils::ShowInfo(Ogre::UTFString title, Ogre::UTFString err)
50 {
51  return ErrorUtils::ShowMsgBox(title, err, 1);
52 }
53 
54 int ErrorUtils::ShowMsgBox(Ogre::UTFString title, Ogre::UTFString err, int type)
55 {
56  // we might call the ErrorUtils::ShowMsgBox without having ogre created yet!
57  //LOG("message box: " + title + ": " + err);
58 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
59  int mtype = MB_ICONERROR;
60  if (type == 1)
61  mtype = MB_ICONINFORMATION;
62  MessageBoxW(NULL, err.asWStr_c_str(), title.asWStr_c_str(), MB_OK | mtype | MB_TOPMOST);
63 #elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
64  printf("\n\n%s: %s\n\n", title.asUTF8_c_str(), err.asUTF8_c_str());
65 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
66  printf("\n\n%s: %s\n\n", title.asUTF8_c_str(), err.asUTF8_c_str());
67  //CFOptionFlags flgs;
68  //CFUserNotificationDisplayAlert(0, kCFUserNotificationStopAlertLevel, NULL, NULL, NULL, T("A network error occured"), T("Bad server port."), NULL, NULL, NULL, &flgs);
69 #endif
70  return 0;
71 }
Language.h
ErrorUtils.h
_L
#define _L
Definition: ErrorUtils.cpp:34
ErrorUtils::ShowMsgBox
static int ShowMsgBox(Ogre::UTFString title, Ogre::UTFString err, int type)
shows a generic message box
Definition: ErrorUtils.cpp:54
Ogre
Definition: ExtinguishableFireAffector.cpp:35
ErrorUtils::ShowError
static int ShowError(Ogre::UTFString title, Ogre::UTFString message)
shows a simple error message box
Definition: ErrorUtils.cpp:43
ErrorUtils::ShowInfo
static int ShowInfo(Ogre::UTFString title, Ogre::UTFString message)
shows a simple info message box
Definition: ErrorUtils.cpp:49