[Scummvm-git-logs] scummvm master -> 4029f328337f50a7d017ccd4979e414f490de942

dreammaster dreammaster at scummvm.org
Sat Dec 31 09:15:48 CET 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
4029f32833 TITANIC: Convert CEditControlMsg _mode to an enum


Commit: 4029f328337f50a7d017ccd4979e414f490de942
    https://github.com/scummvm/scummvm/commit/4029f328337f50a7d017ccd4979e414f490de942
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-12-31T03:15:38-05:00

Commit Message:
TITANIC: Convert CEditControlMsg _mode to an enum

Changed paths:
    engines/titanic/game/missiveomat.cpp
    engines/titanic/gfx/edit_control.cpp
    engines/titanic/messages/messages.h


diff --git a/engines/titanic/game/missiveomat.cpp b/engines/titanic/game/missiveomat.cpp
index b11e602..da9c82b 100644
--- a/engines/titanic/game/missiveomat.cpp
+++ b/engines/titanic/game/missiveomat.cpp
@@ -92,13 +92,13 @@ bool CMissiveOMat::KeyCharMsg(CKeyCharMsg *msg) {
 			return true;
 
 		playSound("z#228.wav");
-		editMsg._mode = 6;
+		editMsg._mode = EDIT_6;
 		editMsg._param = msg->_key;
 		editMsg.execute(loginControl);
 
 		if (editMsg._param == 1000) {
 			// Get the username
-			editMsg._mode = 3;
+			editMsg._mode = EDIT_3;
 			editMsg.execute(loginControl);
 			_username = editMsg._text;
 			_username.toLowercase();
@@ -108,9 +108,9 @@ bool CMissiveOMat::KeyCharMsg(CKeyCharMsg *msg) {
 				loadFrame(2);
 				_mode = MMODE_PASSWORD;
 
-				editMsg._mode = 1;
+				editMsg._mode = EDIT_CLEAR;
 				editMsg.execute(loginControl);
-				editMsg._mode = 10;
+				editMsg._mode = EDIT_10;
 				editMsg._param = 24;
 				editMsg.execute(loginControl);
 			}
@@ -122,13 +122,13 @@ bool CMissiveOMat::KeyCharMsg(CKeyCharMsg *msg) {
 			return true;
 
 		playSound("z#228.wav");
-		editMsg._mode = 6;
+		editMsg._mode = EDIT_6;
 		editMsg._param = msg->_key;
 		editMsg.execute(loginControl);
 
 		if (editMsg._param == 1000) {
 			// Get the password
-			editMsg._mode = 3;
+			editMsg._mode = EDIT_3;
 			editMsg.execute(loginControl);
 			_password = editMsg._text;
 			_password.toLowercase();
@@ -159,21 +159,21 @@ bool CMissiveOMat::KeyCharMsg(CKeyCharMsg *msg) {
 				// Credentials were valid, so log in
 				_mode = MMODE_LOGGED_IN;
 				loadFrame(4);
-				editMsg._mode = 1;
+				editMsg._mode = EDIT_CLEAR;
 				editMsg.execute(loginControl);
 
 				getTextCursor()->hide();
-				editMsg._mode = 13;
+				editMsg._mode = EDIT_13;
 				editMsg.execute(loginControl);
 
-				editMsg._mode = 12;
+				editMsg._mode = EDIT_12;
 				editMsg.execute(welcome);
 
-				editMsg._mode = 2;
+				editMsg._mode = EDIT_SET_TEXT;
 				editMsg._text = _welcomeMessages[_account];
 				editMsg.execute(welcome);
 
-				editMsg._mode = 12;
+				editMsg._mode = EDIT_12;
 				editMsg._text = "MissiveOMat OK Button";
 				editMsg.execute(welcome);
 				editMsg.execute(scrollUp);
@@ -183,7 +183,7 @@ bool CMissiveOMat::KeyCharMsg(CKeyCharMsg *msg) {
 				loadFrame(3);
 				addTimer(1500);
 
-				editMsg._mode = 1;
+				editMsg._mode = EDIT_CLEAR;
 				editMsg.execute(loginControl);
 
 				getTextCursor()->hide();
@@ -206,7 +206,7 @@ bool CMissiveOMat::TimerMsg(CTimerMsg *msg) {
 
 		CTreeItem *loginControl = findRoom()->findByName("MissiveOMat Login Control");
 		CEditControlMsg editMsg;
-		editMsg._mode = 10;
+		editMsg._mode = EDIT_10;
 		editMsg._param = 8;
 		editMsg.execute(loginControl);
 	}
@@ -305,21 +305,21 @@ bool CMissiveOMat::MissiveOMatActionMsg(CMissiveOMatActionMsg *msg) {
 		CEditControlMsg editMsg;
 
 		for (int idx = 0; idx < 7; ++idx) {
-			editMsg._mode = 0;
+			editMsg._mode = EDIT_INIT;
 			editMsg._param = 12;
 			editMsg.execute(WIDGETS[idx]);
-			editMsg._mode = 1;
+			editMsg._mode = EDIT_CLEAR;
 			editMsg.execute(WIDGETS[idx]);
-			editMsg._mode = 13;
+			editMsg._mode = EDIT_13;
 			editMsg.execute(WIDGETS[idx]);
 		}
 
-		editMsg._mode = 12;
+		editMsg._mode = EDIT_12;
 		editMsg.execute("MissiveOMat Login Control");
-		editMsg._mode = 10;
+		editMsg._mode = EDIT_10;
 		editMsg._param = 8;
 		editMsg.execute("MissiveOMat Login Control");
-		editMsg._mode = 8;
+		editMsg._mode = EDIT_8;
 		editMsg.execute("MissiveOMat Login Control");
 
 		_username.clear();
@@ -336,7 +336,7 @@ bool CMissiveOMat::MissiveOMatActionMsg(CMissiveOMatActionMsg *msg) {
 
 bool CMissiveOMat::LeaveViewMsg(CLeaveViewMsg *msg) {
 	CEditControlMsg editMsg;
-	editMsg._mode = 9;
+	editMsg._mode = EDIT_9;
 	editMsg.execute("MissiveOMat Login Control");
 	petShowCursor();
 
diff --git a/engines/titanic/gfx/edit_control.cpp b/engines/titanic/gfx/edit_control.cpp
index c9b87c9..857a27d 100644
--- a/engines/titanic/gfx/edit_control.cpp
+++ b/engines/titanic/gfx/edit_control.cpp
@@ -72,7 +72,7 @@ void CEditControl::load(SimpleFile *file) {
 
 bool CEditControl::EditControlMsg(CEditControlMsg *msg) {
 	switch (msg->_mode) {
-	case 0: {
+	case EDIT_INIT: {
 		// WORKAROUND: Fix original bug where MissiveOMat username & password
 		// text weren't initialised after the first time you use the MissiveOMat
 		_editHeight = _bounds.height();
@@ -82,11 +82,11 @@ bool CEditControl::EditControlMsg(CEditControlMsg *msg) {
 		setTextFontNumber(_fontNumber);
 
 		CEditControlMsg ctlMsg;
-		ctlMsg._mode = 10;
+		ctlMsg._mode = EDIT_10;
 		ctlMsg._param = _fieldD4;
 		ctlMsg.execute(this);
 
-		ctlMsg._mode = 11;
+		ctlMsg._mode = EDIT_11;
 		ctlMsg._textR = _textR;
 		ctlMsg._textG = _textG;
 		ctlMsg._textB = _textB;
@@ -94,39 +94,39 @@ bool CEditControl::EditControlMsg(CEditControlMsg *msg) {
 		break;
 	}
 
-	case 1: {
+	case EDIT_CLEAR: {
 		_text = "";
 		CEditControlMsg ctlMsg;
-		ctlMsg._mode = 14;
+		ctlMsg._mode = EDIT_14;
 		ctlMsg.execute(this);
 		break;
 	}
 
-	case 2: {
+	case EDIT_SET_TEXT: {
 		_text = msg->_text;
 		CEditControlMsg ctlMsg;
-		ctlMsg._mode = 14;
+		ctlMsg._mode = EDIT_14;
 		ctlMsg.execute(this);
 		break;
 	}
 
-	case 3:
+	case EDIT_3:
 		msg->_text = _text;
 		break;
 
-	case 4:
+	case EDIT_4:
 		msg->_param = _text.size();
 		break;
 
-	case 5:
+	case EDIT_5:
 		_maxTextChars = msg->_param;
 		break;
 
-	case 6:
+	case EDIT_6:
 		if (msg->_param == 8 && !_text.empty()) {
 			_text = _text.left(_text.size() - 1);
 			CEditControlMsg ctlMsg;
-			ctlMsg._mode = 14;
+			ctlMsg._mode = EDIT_14;
 			ctlMsg.execute(this);
 		} else if (msg->_param == 13) {
 			msg->_param = 1000;
@@ -136,32 +136,32 @@ bool CEditControl::EditControlMsg(CEditControlMsg *msg) {
 			_text += c;
 
 			CEditControlMsg ctlMsg;
-			ctlMsg._mode = 14;
+			ctlMsg._mode = EDIT_14;
 			ctlMsg.execute(this);
 		}
 		break;
 
-	case 7:
+	case EDIT_7:
 		setTextFontNumber(msg->_param);
 		break;
 
-	case 8:
+	case EDIT_8:
 		if (!_fieldBC) {
 			_fieldBC = true;
 			CEditControlMsg ctlMsg;
-			ctlMsg._mode = 14;
+			ctlMsg._mode = EDIT_14;
 			ctlMsg.execute(this);
 		}
 		break;
 
-	case 9:
+	case EDIT_9:
 		if (_fieldBC) {
 			_fieldBC = false;
 			getTextCursor()->hide();
 		}
 		break;
 
-	case 10: {
+	case EDIT_10: {
 		setTextHasBorders((msg->_param & 1) != 0);
 		if (msg->_param & 4)
 			_fieldF0 = 1;
@@ -172,24 +172,24 @@ bool CEditControl::EditControlMsg(CEditControlMsg *msg) {
 
 		_isPassword = (msg->_param & 0x10) != 0;
 		CEditControlMsg ctlMsg;
-		ctlMsg._mode = 14;
+		ctlMsg._mode = EDIT_14;
 		ctlMsg.execute(this);
 		break;
 	}
 
-	case 11:
+	case EDIT_11:
 		setTextColor(msg->_textR, msg->_textG, msg->_textB);
 		break;
 
-	case 12:
+	case EDIT_12:
 		setVisible(true);
 		break;
 
-	case 13:
+	case EDIT_13:
 		setVisible(false);
 		break;
 
-	case 14: {
+	case EDIT_14: {
 		makeDirty();
 		CString str = _isPassword ? CString('*', _text.size()) : _text;
 		setText(str);
diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h
index 22069c9..f7019ec 100644
--- a/engines/titanic/messages/messages.h
+++ b/engines/titanic/messages/messages.h
@@ -149,9 +149,27 @@ public:
 	virtual bool isLeaveViewMsg() const;
 };
 
+enum EditControlAction {
+	EDIT_INIT = 0,
+	EDIT_CLEAR = 1,
+	EDIT_SET_TEXT = 2,
+	EDIT_3 = 3,
+	EDIT_4 = 4,
+	EDIT_5 = 5,
+	EDIT_6 = 6,
+	EDIT_7 = 7,
+	EDIT_8 = 8,
+	EDIT_9 = 9,
+	EDIT_10 = 10,
+	EDIT_11 = 11,
+	EDIT_12 = 12,
+	EDIT_13 = 13,
+	EDIT_14 = 14
+};
+
 class CEditControlMsg : public CMessage {
 public:
-	int _mode;
+	EditControlAction _mode;
 	int _param;
 	CString _text;
 	byte _textR;
@@ -159,7 +177,7 @@ public:
 	byte _textB;
 public:
 	CLASSDEF;
-	CEditControlMsg() : _mode(0), _param(0), _textR(0), _textG(0), _textB(0) {}
+	CEditControlMsg() : _mode(EDIT_INIT), _param(0), _textR(0), _textG(0), _textB(0) {}
 
 	static bool isSupportedBy(const CTreeItem *item) {
 		return CMessage::supports(item, _type);





More information about the Scummvm-git-logs mailing list