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  LOG(fmt::format("[RoR|ErrorPopupDialog] {}: {}", title.asUTF8(), err.asUTF8()));
46  Ogre::UTFString infoText = _L("An internal error occured in Rigs of Rods.\n\nTechnical details below: \n\n");
47  return ErrorUtils::ShowMsgBox(_L("FATAL ERROR"), infoText + err, 0);
48 }
49 
50 int ErrorUtils::ShowInfo(Ogre::UTFString title, Ogre::UTFString err)
51 {
52  return ErrorUtils::ShowMsgBox(title, err, 1);
53 }
54 
55 int ErrorUtils::ShowMsgBox(Ogre::UTFString title, Ogre::UTFString err, int type)
56 {
57  // we might call the ErrorUtils::ShowMsgBox without having ogre created yet!
58  //LOG("message box: " + title + ": " + err);
59 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
60  int mtype = MB_ICONERROR;
61  if (type == 1)
62  mtype = MB_ICONINFORMATION;
63  MessageBoxW(NULL, err.asWStr_c_str(), title.asWStr_c_str(), MB_OK | mtype | MB_TOPMOST);
64 #elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
65  printf("\n\n%s: %s\n\n", title.asUTF8_c_str(), err.asUTF8_c_str());
66 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
67  printf("\n\n%s: %s\n\n", title.asUTF8_c_str(), err.asUTF8_c_str());
68  //CFOptionFlags flgs;
69  //CFUserNotificationDisplayAlert(0, kCFUserNotificationStopAlertLevel, NULL, NULL, NULL, T("A network error occured"), T("Bad server port."), NULL, NULL, NULL, &flgs);
70 #endif
71  return 0;
72 }
format
Truck file format(technical spec)
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:55
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:50