diff options
| author | Tobia Tesan | 2016-02-28 19:16:18 +0100 | 
|---|---|---|
| committer | Tobia Tesan | 2016-02-29 11:13:54 +0100 | 
| commit | 0dd0c3bea267b0342c86b7a35228d5535cecfd4a (patch) | |
| tree | 06985287f3ef3d16996f2d9772ecffb31f5bbc7a | |
| parent | fb3a8f7899ee8b6955a6a9f5ede17ebb76836b54 (diff) | |
| download | scummvm-rg350-0dd0c3bea267b0342c86b7a35228d5535cecfd4a.tar.gz scummvm-rg350-0dd0c3bea267b0342c86b7a35228d5535cecfd4a.tar.bz2 scummvm-rg350-0dd0c3bea267b0342c86b7a35228d5535cecfd4a.zip | |
WINTERMUTE: Add Error class
| -rw-r--r-- | engines/wintermute/debugger.h | 1 | ||||
| -rw-r--r-- | engines/wintermute/debugger/error.cpp | 137 | ||||
| -rw-r--r-- | engines/wintermute/debugger/error.h | 73 | ||||
| -rw-r--r-- | engines/wintermute/module.mk | 1 | 
4 files changed, 212 insertions, 0 deletions
| diff --git a/engines/wintermute/debugger.h b/engines/wintermute/debugger.h index 625da0ce41..2b31dc0f88 100644 --- a/engines/wintermute/debugger.h +++ b/engines/wintermute/debugger.h @@ -25,6 +25,7 @@  #include "gui/debugger.h" +#define SET_PATH_CMD "set_path"  namespace Wintermute {  class WintermuteEngine; diff --git a/engines/wintermute/debugger/error.cpp b/engines/wintermute/debugger/error.cpp new file mode 100644 index 0000000000..dd6e41c7bc --- /dev/null +++ b/engines/wintermute/debugger/error.cpp @@ -0,0 +1,137 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "error.h" +#include "engines/wintermute/debugger.h" + +namespace Wintermute { + +Error::Error(ErrorLevel errorLevel, +		ErrorCode errorCode, +		Common::String errorExtraString, +		int errorExtraInt) : +			_errorLevel(errorLevel), +			_errorCode(errorCode), +			_errorExtraInt(errorExtraInt), +			_errorExtraString(errorExtraString){} + +Error::Error(ErrorLevel errorLevel, +		ErrorCode errorCode, +		int errorExtraInt) : +			_errorLevel(errorLevel), +			_errorCode(errorCode), +			_errorExtraInt(errorExtraInt), +			_errorExtraString(""){} + +Error::Error(ErrorLevel errorLevel, +		ErrorCode errorCode) : +			_errorLevel(errorLevel), +			_errorCode(errorCode), +			_errorExtraInt(0), +			_errorExtraString(""){} + +Error::Error(ErrorLevel errorLevel, +		ErrorCode errorCode, +		Common::String errorExtraString) : +			_errorLevel(errorLevel), +			_errorCode(errorCode), +			_errorExtraInt(0), +			_errorExtraString(errorExtraString){} + +ErrorLevel Error::getErrorLevel() const { +	return _errorLevel; +} + +ErrorCode Error::getErrorCode() const { +	return _errorCode; +} + +Common::String Error::getErrorLevelStr() const { +	switch (this->_errorLevel) { +	case SUCCESS: +		return "SUCCESS"; +		break; +	case NOTICE: +		return "NOTICE"; +		break; +	case WARNING: +		return "WARNING"; +		break; +	case ERROR: +		return "ERROR"; +		break; +	} +	return "SUCCESS"; +} + +Common::String Error::getErrorDisplayStr() const { + +	Common::String errorStr; + +	switch (this->_errorLevel) { +	case SUCCESS: +		errorStr += "OK!"; +		break; +	case WARNING: +		errorStr += "WARNING: "; +		break; +	case ERROR: +		errorStr += "ERROR: "; +		break; +	case NOTICE: +		errorStr += "NOTICE: "; +		break; +	default: +		// Um... +		break; +	} + +	switch (this->_errorCode) { +	case OK: +		break; +	case NOT_ALLOWED: +		errorStr += "Could not execute requested operation. This is allowed only after a break."; +		break; +	case NO_SUCH_SOURCE: +		errorStr += Common::String::format("Can't find source for %s. Double check you source path.", this->_errorExtraString.c_str()); +		break; +	case NO_SUCH_BYTECODE: +		errorStr += Common::String::format("No such script: %s. Can't find bytecode; double check the script path.", this->_errorExtraString.c_str()); +		break; +	case SOURCE_PATH_NOT_SET: +		errorStr += Common::String("Source path not set. Source won't be displayed. Try 'help " + Common::String(SET_PATH_CMD) + "'."); +		break; +	case NO_SUCH_BREAKPOINT: +		errorStr += Common::String::format("No such breakpoint %d.", this->_errorExtraInt); +		break; +	case WRONG_TYPE: +		errorStr += Common::String::format("Incompatible type: %s.", this->_errorExtraString.c_str()); +		break; +	default: +		errorStr += Common::String::format("Unknown condition %d", this->_errorCode); +		break; +	} + +	return errorStr; +} + +} // End namespace Wintermute diff --git a/engines/wintermute/debugger/error.h b/engines/wintermute/debugger/error.h new file mode 100644 index 0000000000..4e5b973445 --- /dev/null +++ b/engines/wintermute/debugger/error.h @@ -0,0 +1,73 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef ERROR_H_ +#define ERROR_H_ + +#include "common/str.h" + +namespace Wintermute { + +enum ErrorLevel { +    SUCCESS, +    NOTICE, +    WARNING, +    ERROR +}; + +enum ErrorCode { +    OK, +    NO_SUCH_SOURCE, +    COULD_NOT_OPEN, +    NO_SUCH_LINE, +    NOT_ALLOWED, +    NO_SUCH_BYTECODE, +    DUPLICATE_BREAKPOINT, +    NO_SUCH_BREAKPOINT, +    WRONG_TYPE, +    PARSE_ERROR, +    NOT_YET_IMPLEMENTED, +    SOURCE_PATH_NOT_SET, +    ILLEGAL_PATH, +    UNKNOWN_ERROR +}; + + +class Error { +	const ErrorLevel _errorLevel; +	const ErrorCode _errorCode; +	const int _errorExtraInt; +	const Common::String _errorExtraString; +public: +	Error(ErrorLevel, ErrorCode); +	Error(ErrorLevel, ErrorCode, int errorExtraInt); +	Error(ErrorLevel, ErrorCode, Common::String errorExtraString); +	Error(ErrorLevel, ErrorCode, Common::String errorExtraString, int errorExtraInt); +	ErrorLevel getErrorLevel() const; +	ErrorCode getErrorCode() const; +	Common::String getErrorLevelStr() const; +	Common::String getErrorDisplayStr() const; +}; + +} // End of namespace Wintermute + +#endif /* ERROR_H_ */ diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 4c95314a02..514809def9 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -88,6 +88,7 @@ MODULE_OBJS := \  	base/saveload.o \  	base/save_thumb_helper.o \  	base/timer.o \ +	debugger/error.o \  	detection.o \  	math/math_util.o \  	math/matrix4.o \ | 
