Ticket #9160: gui_changes.patch
File gui_changes.patch, 8.6 KB (added by , 15 years ago) |
---|
-
gui/module.mk
7 7 debugger.o \ 8 8 dialog.o \ 9 9 editable.o \ 10 error.o \ 10 11 EditTextWidget.o \ 11 12 GuiManager.o \ 12 13 launcher.o \ -
gui/error.h
1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef GUI_ERROR_H 24 #define GUI_ERROR_H 25 26 #include "common/error.h" 27 28 namespace GUI { 29 30 /** 31 * Displays an error dialog for some error code. 32 * 33 * @param error error code 34 * @param extraText extra text to be displayed in addition to default string description(optional) 35 */ 36 void displayErrorDialog(Common::Error error, const char *extraText = ""); 37 38 /** 39 * Displays an error dialog for a given message. 40 * 41 * @param text message to be displayed 42 */ 43 void displayErrorDialog(const char *text); 44 45 } // End of namespace GUI 46 47 #endif //GUI_ERROR_H -
gui/error.cpp
1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #include "common/error.h" 24 #include "gui/message.h" 25 #include "gui/error.h" 26 27 namespace GUI { 28 29 void displayErrorDialog(const char *text) { 30 GUI::MessageDialog alert(text); 31 alert.runModal(); 32 } 33 34 void displayErrorDialog(Common::Error error, const char *extraText) { 35 Common::String errorText(extraText); 36 errorText += " "; 37 errorText += Common::errorToString(error); 38 GUI::MessageDialog alert(errorText); 39 alert.runModal(); 40 } 41 42 } // end of namespace GUI -
common/error.h
66 66 kUnknownError ///< Catch-all error, used if no other error code matches 67 67 }; 68 68 69 /** 70 * Maps an error code to equivalent string description. 71 * 72 * @param error error code to be converted 73 * @return a pointer to string description of the error 74 */ 75 const char *errorToString(Error error); 76 69 77 } // End of namespace Common 70 78 71 79 #endif //COMMON_ERROR_H -
common/error.cpp
1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #include "common/error.h" 24 #include "common/util.h" 25 26 namespace Common { 27 28 /** 29 * Error Table: Maps error codes to their default descriptions 30 */ 31 32 struct ErrorMessage { 33 Error error; 34 const char *errMsg; 35 }; 36 37 static const ErrorMessage _errMsgTable[] = { 38 { kInvalidPathError, "Invalid Path" }, 39 { kNoGameDataFoundError, "Game Data not found" }, 40 { kUnsupportedGameidError, "Game Id not supported" }, 41 { kUnsupportedColorMode, "Unsupported Color Mode" }, 42 43 { kReadPermissionDenied, "Read permission denied" }, 44 { kWritePermissionDenied, "Write permission denied" }, 45 46 // The following three overlap a bit with kInvalidPathError and each other. Which to keep? 47 { kPathDoesNotExist, "Path not exists" }, 48 { kPathNotDirectory, "Path not a directory" }, 49 { kPathNotFile, "Path not a file" }, 50 51 { kCreatingFileFailed, "Cannot create file" }, 52 { kReadingFailed, "Reading failed" }, 53 { kWritingFailed, "Writing data failed" }, 54 55 { kUnknownError, "Unknown Error" } 56 }; 57 58 const char *errorToString(Error error) { 59 60 for (int i = 0; i < ARRAYSIZE(_errMsgTable); i++) { 61 if (error == _errMsgTable[i].error) { 62 return _errMsgTable[i].errMsg; 63 } 64 } 65 66 return "Unknown Error"; 67 } 68 69 } // End of namespace Common -
common/module.mk
5 5 config-file.o \ 6 6 config-manager.o \ 7 7 debug.o \ 8 error.o \ 8 9 EventDispatcher.o \ 9 10 EventRecorder.o \ 10 11 file.o \ -
base/main.cpp
49 49 50 50 #include "gui/GuiManager.h" 51 51 #include "gui/message.h" 52 #include "gui/error.h" 52 53 53 54 #include "sound/audiocd.h" 54 55 … … 134 135 135 136 // Check for errors 136 137 if (!engine || err != Common::kNoError) { 137 // TODO: Show an error dialog or so? 138 // TODO: Also take 'err' into consideration... 139 //GUI::MessageDialog alert("ScummVM could not find any game in the specified directory!"); 140 //alert.runModal(); 141 const char *errMsg = 0; 142 switch (err) { 143 case Common::kInvalidPathError: 144 errMsg = "Invalid game path"; 145 break; 146 case Common::kNoGameDataFoundError: 147 errMsg = "Unable to locate game data"; 148 break; 149 default: 150 errMsg = "Unknown error"; 151 } 138 139 // TODO: An errorDialog for this and engine related errors is displayed already in the scummvm_main function 140 // Is a separate dialog here still required? 141 142 //GUI::displayErrorDialog("ScummVM could not find any game in the specified directory!"); 143 const char *errMsg = Common::errorToString(err); 152 144 153 145 warning("%s failed to instantiate engine: %s (target '%s', path '%s')", 154 146 plugin->getName(), … … 391 383 392 384 // Did an error occur ? 393 385 if (result != Common::kNoError) { 394 // TODO: Show an informative error dialog if starting the selected game failed. 386 // Shows an informative error dialog if starting the selected game failed. 387 GUI::displayErrorDialog(result, "Error running game:"); 395 388 } 396 389 397 390 // Quit unless an error occurred, or Return to launcher was requested … … 418 411 // A dialog would be nicer, but we don't have any 419 412 // screen to draw on yet. 420 413 warning("Could not find any engine capable of running the selected game"); 414 GUI::displayErrorDialog("Could not find any engine capable of running the selected game"); 421 415 } 422 416 423 417 // We will destroy the AudioCDManager singleton here to save some memory.