[Scummvm-cvs-logs] CVS: scummvm/saga interface.cpp,1.114,1.115 interface.h,1.63,1.64

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Tue Jul 12 11:33:27 CEST 2005


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24323

Modified Files:
	interface.cpp interface.h 
Log Message:
Made it possible to terminate dialog windows with Enter. (We could already
terminate them with Esc.) This is so that, for instance, if you type a
savegame name you can press Enter, rather than clicking on the "Save"
button.

I don't know if the original did this as well, but it feels natural to me.


Index: interface.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/interface.cpp,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -d -r1.114 -r1.115
--- interface.cpp	10 Jul 2005 15:25:30 -0000	1.114
+++ interface.cpp	12 Jul 2005 18:31:47 -0000	1.115
@@ -320,6 +320,11 @@
 }
 
 bool Interface::processAscii(uint16 ascii, bool synthetic) {
+	// TODO: Checking for Esc and Enter below is a bit hackish, and
+	// and probably only works with the English version. Maybe we should
+	// add a flag to the button so it can indicate if it's the default or
+	// cancel button?
+
 	int i;
 	PanelButton *panelButton;
 	if (!synthetic)
@@ -330,7 +335,7 @@
 	}
 	switch (_panelMode) {
 	case kPanelNull:
-		if (ascii == 27) {// Esc
+		if (ascii == 27) { // Esc
 			if (_vm->_scene->isInDemo()) {
 				_vm->_scene->skipScene();
 			} else {
@@ -340,48 +345,54 @@
 		}
 		break;
 	case kPanelOption:
-		//TODO: check input dialog keys
-		if (ascii == 27) {// Esc
+		// TODO: check input dialog keys
+		if (ascii == 27 || ascii == 13) { // Esc or Enter
 			ascii = 'c'; //continue
 		}
+
 		for (i = 0; i < _optionPanel.buttonsCount; i++) {
 			panelButton = &_optionPanel.buttons[i];
 			if (panelButton->type == kPanelButtonOption) {
 				if (panelButton->ascii == ascii) {
-					setOption(panelButton);				
+					setOption(panelButton);
 					return true;
 				}
 			}
 		}
 		break;
 	case kPanelSave:
-		if (_textInput) {
-			processTextInput(ascii);
+		if (_textInput && processTextInput(ascii)) {
 			return true;
-		} else {
-			if (ascii == 27) {// Esc
-				ascii = 'c'; //cancel
-			}
-			for (i = 0; i < _savePanel.buttonsCount; i++) {
-				panelButton = &_savePanel.buttons[i];
-				if (panelButton->type == kPanelButtonSave) {
-					if (panelButton->ascii == ascii) {
-						setSave(panelButton);				
-						return true;
-					}
+		}
+
+		if (ascii == 27) { // Esc
+			ascii = 'c'; // cancel
+		} else if (ascii == 13) { // Enter
+			ascii = 's'; // save
+		}
+
+		for (i = 0; i < _savePanel.buttonsCount; i++) {
+			panelButton = &_savePanel.buttons[i];
+			if (panelButton->type == kPanelButtonSave) {
+				if (panelButton->ascii == ascii) {
+					setSave(panelButton);
+					return true;
 				}
 			}
 		}
 		break;
 	case kPanelQuit:
-		if (ascii == 27) {// Esc
-			ascii = 'c'; //cancel
+		if (ascii == 27) { // Esc
+			ascii = 'c'; // cancel
+		} else if (ascii == 13) { // Enter
+			ascii = 'q'; // quit
 		}
+
 		for (i = 0; i < _quitPanel.buttonsCount; i++) {
 			panelButton = &_quitPanel.buttons[i];
 			if (panelButton->type == kPanelButtonQuit) {
 				if (panelButton->ascii == ascii) {
-					setQuit(panelButton);				
+					setQuit(panelButton);
 					return true;
 				}
 			}
@@ -392,7 +403,7 @@
 			panelButton = &_loadPanel.buttons[i];
 			if (panelButton->type == kPanelButtonLoad) {
 				if (panelButton->ascii == ascii) {
-					setLoad(panelButton);				
+					setLoad(panelButton);
 					return true;
 				}
 			}
@@ -827,17 +838,17 @@
 
 	textInputStartRepeat(ascii);
 	switch (ascii) {
-	case(27): // esc
+	case 27: // esc
 		_statusTextInputState = kStatusTextInputAborted;
 		_statusTextInput = false;
 		_vm->_script->wakeUpThreads(kWaitTypeStatusTextInput);
 		break;
-	case(13): // return
+	case 13: // return
 		_statusTextInputState = kStatusTextInputEntered;
 		_statusTextInput = false;
 		_vm->_script->wakeUpThreads(kWaitTypeStatusTextInput);
 		break;
-	case(8): // backspace
+	case 8: // backspace
 		if (_statusTextInputPos == 0) {
 			break;
 		}
@@ -858,7 +869,7 @@
 	setStatusText(_statusTextInputString);
 }
 
-void Interface::processTextInput(uint16 ascii) {
+bool Interface::processTextInput(uint16 ascii) {
 	char ch[2];
 	char tempString[SAVE_TITLE_SIZE];
 	uint tempWidth;
@@ -868,15 +879,17 @@
 	textInputStartRepeat(ascii);
 
 	switch (ascii) {
-	case(27): // esc
+	case 13:
+		return false;
+	case 27: // esc
 		_textInput = false;
 		break;
-	case(8): // backspace
+	case 8: // backspace
 		if (_textInputPos <= 1) {
 			break;
 		}
 		_textInputPos--;
-	case(127): // del
+	case 127: // del
 		if (_textInputPos <= _textInputStringLength) {
 			if (_textInputPos != 1) {
 				strncpy(tempString, _textInputString, _textInputPos - 1);							
@@ -888,12 +901,12 @@
 			_textInputStringLength = strlen(_textInputString);
 		}
 		break;
-	case(276): // left
+	case 276: // left
 		if (_textInputPos > 1) {
 			_textInputPos--;
 		}
 		break;
-	case(275): // right
+	case 275: // right
 		if (_textInputPos <= _textInputStringLength) {
 			_textInputPos++;
 		}
@@ -928,6 +941,7 @@
 		}
 		break;
 	}
+	return true;
 }
 
 void Interface::drawTextInput(Surface *ds, InterfacePanel *panel, PanelButton *panelButton) {
@@ -1578,7 +1592,7 @@
 	byte odl, our, idl, iur;
 
 	switch (kind ) {
-		case( kSlider):
+		case kSlider:
 			cornerColor = 0x8b;
 			frameColor = kITEColorBlack;
 			fillColor = kITEColorLightBlue96;
@@ -1588,7 +1602,7 @@
 			iur = 0x94;
 			solidColor = down ? kITEColorLightBlue94 : kITEColorLightBlue96;
 			break;
-		case( kEdit):
+		case kEdit:
 			cornerColor = kITEColorLightBlue96;
 			frameColor = kITEColorLightBlue96;
 			fillColor = kITEColorLightBlue96;
@@ -1675,13 +1689,13 @@
 
 	textId = panelButton->id;
 	switch(panelButton->id) {
-		case(kTextReadingSpeed):
+		case kTextReadingSpeed:
 			textId = kTextFast;
 			break;			
-		case(kTextMusic):
+		case kTextMusic:
 			textId = kTextOn;
 			break;			
-		case(kTextSound):
+		case kTextSound:
 			textId = kTextOn;
 			break;			
 	}

Index: interface.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/interface.h,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- interface.h	9 Jul 2005 16:23:44 -0000	1.63
+++ interface.h	12 Jul 2005 18:31:48 -0000	1.64
@@ -335,7 +335,7 @@
 	void drawVerbPanelText(Surface *ds, PanelButton *panelButton, int textColor, int textShadowColor);
 	void drawVerbPanel(Surface *backBuffer, PanelButton* panelButton);
 	void calcOptionSaveSlider();
-	void processTextInput(uint16 ascii);
+	bool processTextInput(uint16 ascii);
 	void processStatusTextInput(uint16 ascii);
 	void textInputStartRepeat(uint16 ascii);
 	void textInputRepeat(void);





More information about the Scummvm-git-logs mailing list