[Scummvm-cvs-logs] SF.net SVN: scummvm:[48693] scummvm/trunk/engines/sci

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Sat Apr 17 22:43:10 CEST 2010


Revision: 48693
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48693&view=rev
Author:   m_kiewitz
Date:     2010-04-17 20:43:09 +0000 (Sat, 17 Apr 2010)

Log Message:
-----------
SCI: key presses of extended chars (umlauts, etc.) will now get ignored in games that don't support them (which is all non-multilingual games)

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/event.cpp
    scummvm/trunk/engines/sci/event.h
    scummvm/trunk/engines/sci/resource.cpp
    scummvm/trunk/engines/sci/resource.h
    scummvm/trunk/engines/sci/sci.cpp

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2010-04-17 17:23:30 UTC (rev 48692)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2010-04-17 20:43:09 UTC (rev 48693)
@@ -945,7 +945,7 @@
 
 	// Create a new EngineState object
 	retval = new EngineState(s->_voc, s->_segMan);
-	retval->_event = new SciEvent();
+	retval->_event = s->_event;
 
 	// Copy some old data
 	retval->_soundCmd = s->_soundCmd;

Modified: scummvm/trunk/engines/sci/event.cpp
===================================================================
--- scummvm/trunk/engines/sci/event.cpp	2010-04-17 17:23:30 UTC (rev 48692)
+++ scummvm/trunk/engines/sci/event.cpp	2010-04-17 20:43:09 UTC (rev 48693)
@@ -36,7 +36,11 @@
 
 #define SCANCODE_ROWS_NR 3
 
-SciEvent::SciEvent() {
+SciEvent::SciEvent(ResourceManager *resMan)
+	: _resMan(resMan) {
+
+	// Check, if font of current game includes extended chars
+	_fontIsExtended = _resMan->detectFontExtended();
 }
 
 SciEvent::~SciEvent() {
@@ -167,6 +171,17 @@
 				// Directly accept most common keys without conversion
 				input.type = SCI_EVENT_KEYBOARD;
 				if ((input.character >= 0x80) && (input.character <= 0xFF)) {
+					// If there is no extended font, we will just clear the current event
+					//  Sierra SCI actually accepted those characters, but didn't display them inside textedit-controls
+					//  because the characters were missing inside the font(s)
+					//  We filter them out for non-multilingual games because of that
+					if (!_fontIsExtended) {
+						input.type = SCI_EVENT_NONE;
+						input.character = 0;
+						input.data = 0;
+						input.modifiers = 0;
+						return input;
+					}
 					// we get 8859-1 character, we need dos (cp850/437) character for multilingual sci01 games
 					// TODO: check, if we get 8859-1 on all platforms
 					input.character = codepagemap_88591toDOS[input.character & 0x7f];

Modified: scummvm/trunk/engines/sci/event.h
===================================================================
--- scummvm/trunk/engines/sci/event.h	2010-04-17 17:23:30 UTC (rev 48692)
+++ scummvm/trunk/engines/sci/event.h	2010-04-17 20:43:09 UTC (rev 48693)
@@ -113,7 +113,7 @@
 
 class SciEvent {
 public:
-	SciEvent();
+	SciEvent(ResourceManager *resMan);
 	~SciEvent();
 
 	sciEvent get(unsigned int mask);
@@ -126,6 +126,9 @@
 	int numlockify (int c);
 	sciEvent getFromScummVM();
 
+	ResourceManager *_resMan;
+
+	bool _fontIsExtended;
 	Common::List<sciEvent> _events;
 };
 

Modified: scummvm/trunk/engines/sci/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource.cpp	2010-04-17 17:23:30 UTC (rev 48692)
+++ scummvm/trunk/engines/sci/resource.cpp	2010-04-17 20:43:09 UTC (rev 48693)
@@ -1979,6 +1979,19 @@
 #endif
 }
 
+bool ResourceManager::detectFontExtended() {
+
+	Resource *res = findResource(ResourceId(kResourceTypeFont, 0), 0);
+	if (res) {
+		if (res->size >= 4) {
+			uint16 numChars = READ_LE_UINT16(res->data + 2);
+			if (numChars > 0x80)
+				return true;
+		}
+	}
+	return false;
+}
+
 // Functions below are based on PD code by Brian Provinciano (SCI Studio)
 bool ResourceManager::hasOldScriptHeader() {
 	Resource *res = findResource(ResourceId(kResourceTypeScript, 0), 0);

Modified: scummvm/trunk/engines/sci/resource.h
===================================================================
--- scummvm/trunk/engines/sci/resource.h	2010-04-17 17:23:30 UTC (rev 48692)
+++ scummvm/trunk/engines/sci/resource.h	2010-04-17 20:43:09 UTC (rev 48693)
@@ -265,6 +265,8 @@
 	void addNewGMPatch(const Common::String &gameId);
 
 	bool detectHires();
+	// Detects, if standard font of current game includes extended characters (>0x80)
+	bool detectFontExtended();
 
 protected:
 	// Maximum number of bytes to allow being allocated for resources

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2010-04-17 17:23:30 UTC (rev 48692)
+++ scummvm/trunk/engines/sci/sci.cpp	2010-04-17 20:43:09 UTC (rev 48693)
@@ -181,7 +181,7 @@
 	_features = new GameFeatures(segMan, _kernel);
 
 	_gamestate = new EngineState(_vocabulary, segMan);
-	_gamestate->_event = new SciEvent();
+	_gamestate->_event = new SciEvent(_resMan);
 
 	if (script_init_engine(_gamestate))
 		return Common::kUnknownError;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list