[Scummvm-cvs-logs] SF.net SVN: scummvm:[36317] scummvm/trunk/engines/cruise

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Sat Feb 14 01:10:51 CET 2009


Revision: 36317
          http://scummvm.svn.sourceforge.net/scummvm/?rev=36317&view=rev
Author:   dreammaster
Date:     2009-02-14 00:10:51 +0000 (Sat, 14 Feb 2009)

Log Message:
-----------
Changed the list of language dependant strings from being hard-coded to dynamically being loaded from the 'delphine.lng' file

Modified Paths:
--------------
    scummvm/trunk/engines/cruise/cruise.cpp
    scummvm/trunk/engines/cruise/cruise.h
    scummvm/trunk/engines/cruise/cruise_main.cpp
    scummvm/trunk/engines/cruise/font.cpp
    scummvm/trunk/engines/cruise/font.h
    scummvm/trunk/engines/cruise/menu.cpp
    scummvm/trunk/engines/cruise/staticres.cpp
    scummvm/trunk/engines/cruise/staticres.h

Modified: scummvm/trunk/engines/cruise/cruise.cpp
===================================================================
--- scummvm/trunk/engines/cruise/cruise.cpp	2009-02-13 23:33:33 UTC (rev 36316)
+++ scummvm/trunk/engines/cruise/cruise.cpp	2009-02-14 00:10:51 UTC (rev 36317)
@@ -75,6 +75,9 @@
 	// Initialize backend
 	initGraphics(320, 200, false);
 
+	if (!loadLanguageStrings())
+		return Common::kUnknownError;
+
 	initialize();
 
 	return Common::kNoError;
@@ -109,4 +112,31 @@
 
 }
 
+bool CruiseEngine::loadLanguageStrings() {
+	Common::File f;
+
+	if (!f.open("DELPHINE.LNG"))
+		return false;
+
+	char *data = (char *)malloc(f.size());
+	f.read(data, f.size());
+	char *ptr = data;
+
+	for (int i = 0; i < MAX_LANGUAGE_STRINGS; ++i) {
+		// Get the start of the next string
+		while (*ptr != '"') ++ptr;
+		const char *v = ++ptr;
+
+		// Find the end of the string, and replace the end '"' with a NULL
+		while (*ptr != '"') ++ptr;
+		*ptr++ = '\0';
+
+		// Add the string to the list
+		_langStrings.push_back(v);
+	}
+
+	f.close();
+	return true;
+}
+
 } // End of namespace Cruise

Modified: scummvm/trunk/engines/cruise/cruise.h
===================================================================
--- scummvm/trunk/engines/cruise/cruise.h	2009-02-13 23:33:33 UTC (rev 36316)
+++ scummvm/trunk/engines/cruise/cruise.h	2009-02-14 00:10:51 UTC (rev 36317)
@@ -40,16 +40,23 @@
 	GType_CRUISE = 1
 };
 
+#define MAX_LANGUAGE_STRINGS 25
+
+enum LangStringId { ID_PAUSED = 0, ID_INVENTORY = 5, ID_PLAYER_MENU = 7,
+	ID_SAVE = 9, ID_LOAD = 10, ID_RESTART = 11, ID_QUIT = 12};
+
 struct CRUISEGameDescription;
 
 class CruiseEngine: public Engine {
 private:
 	void initialize(void);
+	bool loadLanguageStrings();
 	bool makeLoad(char *saveName);
 	void mainLoop(int bootScriptIdx);
 
 	bool _preLoad;
 	Debugger *_debugger;
+	Common::StringList _langStrings;
 
 protected:
 	// Engine APIs
@@ -69,6 +76,7 @@
 	Common::Language getLanguage() const;
 	Common::Platform getPlatform() const;
 	virtual GUI::Debugger *getDebugger() { return _debugger; }
+	const char *langString(LangStringId langId) { return _langStrings[(int)langId].c_str(); }
 
 	bool loadSaveDirectory(void);
 	void makeSystemMenu(void);

Modified: scummvm/trunk/engines/cruise/cruise_main.cpp
===================================================================
--- scummvm/trunk/engines/cruise/cruise_main.cpp	2009-02-13 23:33:33 UTC (rev 36316)
+++ scummvm/trunk/engines/cruise/cruise_main.cpp	2009-02-14 00:10:51 UTC (rev 36317)
@@ -58,21 +58,16 @@
 	memset(rasterPtr, 0, rasterSize);
 }
 
-void drawInfoStringSmallBlackBox(uint8 *string) {
-	//uint8 buffer[256];
-
+void drawInfoStringSmallBlackBox(const char *s) {
 	gfxModuleData_field_90();
 	gfxModuleData_gfxWaitVSync();
 	drawBlackSolidBoxSmall();
 
-	drawString(10, 100, string, gfxModuleData.pPage10, titleColor, 300);
+	drawString(10, 100, (const uint8 *)s, gfxModuleData.pPage10, titleColor, 300);
 
 	gfxModuleData_flip();
 
 	flipScreen();
-
-	while (1)
-		;
 }
 
 void loadPakedFileToMem(int fileIdx, uint8 *buffer) {
@@ -751,8 +746,7 @@
 void buildInventory(int X, int Y) {
 	menuStruct *pMenu;
 
-	const char **sl = getStringList();
-	pMenu = createMenu(X, Y, sl[SL_INVENTORY]);
+	pMenu = createMenu(X, Y, _vm->langString(ID_INVENTORY));
 	menuTable[1] = pMenu;
 
 	if (pMenu == NULL)
@@ -1336,6 +1330,11 @@
 	if (keyboardCode == Common::KEYCODE_x)
 		return 1;
 
+	// Check for Pause 'P' key
+	if (keyboardCode == Common::KEYCODE_p) {
+		drawInfoStringSmallBlackBox(_vm->langString(ID_PAUSED));
+	}
+
 	if (!userEnabled) {
 		return 0;
 	}

Modified: scummvm/trunk/engines/cruise/font.cpp
===================================================================
--- scummvm/trunk/engines/cruise/font.cpp	2009-02-13 23:33:33 UTC (rev 36316)
+++ scummvm/trunk/engines/cruise/font.cpp	2009-02-14 00:10:51 UTC (rev 36317)
@@ -262,7 +262,7 @@
 
 // returns character count and pixel size (via pointer) per line of the string (old: prepareWordRender(int32 param, int32 var1, int16* out2, uint8* ptr3, uint8* string))
 int32 prepareWordRender(int32 inRightBorder_X, int32 wordSpacingWidth,
-                        int16 * strPixelLength, uint8 * ptr3, const uint8 * textString) {
+                        int16 * strPixelLength, uint8 * ptr3, const uint8 *textString) {
 	const uint8 *localString = textString;
 
 	int32 counter = 0;
@@ -315,7 +315,7 @@
 	return counter;
 }
 
-void drawString(int32 x, int32 y, uint8 *string, uint8 *buffer, uint8 color,
+void drawString(int32 x, int32 y, const uint8 *string, uint8 *buffer, uint8 color,
                 int32 inRightBorder_X) {
 	uint8 *fontPtr;
 	uint8 *fontPtr_Data;	// ptr2
@@ -414,7 +414,7 @@
 		int spacesCount = 0;	// si
 		char character = *(string);
 		short int strPixelLength;	// var_16;
-		uint8 *ptrStringEnd;	// var_4        //ok
+		const uint8 *ptrStringEnd;	// var_4        //ok
 		int drawPosPixel_X;	// di
 
 		while (character == ' ') {

Modified: scummvm/trunk/engines/cruise/font.h
===================================================================
--- scummvm/trunk/engines/cruise/font.h	2009-02-13 23:33:33 UTC (rev 36316)
+++ scummvm/trunk/engines/cruise/font.h	2009-02-14 00:10:51 UTC (rev 36317)
@@ -45,7 +45,7 @@
                 int32 drawPosPixel_X, int32 heightOff, int32 height, int32 param4,
                 int32 stringRenderBufferSize, int32 width, int32 charWidth);
 gfxEntryStruct *renderText(int inRightBorder_X, const uint8 *string);
-void drawString(int32 x, int32 y, uint8 * string, uint8 * buffer, uint8 color,
+void drawString(int32 x, int32 y, const uint8 * string, uint8 * buffer, uint8 color,
                 int32 inRightBorder_X);
 
 } // End of namespace Cruise

Modified: scummvm/trunk/engines/cruise/menu.cpp
===================================================================
--- scummvm/trunk/engines/cruise/menu.cpp	2009-02-13 23:33:33 UTC (rev 36316)
+++ scummvm/trunk/engines/cruise/menu.cpp	2009-02-14 00:10:51 UTC (rev 36317)
@@ -23,6 +23,7 @@
  *
  */
 
+#include "cruise/cruise.h"
 #include "cruise/cruise_main.h"
 #include "cruise/staticres.h"
 
@@ -236,19 +237,16 @@
 		    linkedRelation = 0; */
 		freeDisk();
 
-		// Get the correct string set to use
-		const char **sl = getStringList();
-
-		menuTable[0] = createMenu(menuX, menuY, sl[SL_MENU]);
+		menuTable[0] = createMenu(menuX, menuY, _vm->langString(ID_PLAYER_MENU));
 		ASSERT(menuTable[0]);
 
 		//addSelectableMenuEntry(0, 3, menuTable[0], 1, -1, "Save game disk");
 		if (userEnabled) {
-			addSelectableMenuEntry(0, 4, menuTable[0], 1, -1, sl[SL_SAVE]);
+			addSelectableMenuEntry(0, 4, menuTable[0], 1, -1, _vm->langString(ID_SAVE));
 		}
-		addSelectableMenuEntry(0, 5, menuTable[0], 1, -1, sl[SL_LOAD]);
-		addSelectableMenuEntry(0, 6, menuTable[0], 1, -1, sl[SL_RESTART]);
-		addSelectableMenuEntry(0, 7, menuTable[0], 1, -1, sl[SL_QUIT]);
+		addSelectableMenuEntry(0, 5, menuTable[0], 1, -1, _vm->langString(ID_LOAD));
+		addSelectableMenuEntry(0, 6, menuTable[0], 1, -1, _vm->langString(ID_RESTART));
+		addSelectableMenuEntry(0, 7, menuTable[0], 1, -1, _vm->langString(ID_QUIT));
 
 		retourMenu = processMenu(menuTable[0]);
 

Modified: scummvm/trunk/engines/cruise/staticres.cpp
===================================================================
--- scummvm/trunk/engines/cruise/staticres.cpp	2009-02-13 23:33:33 UTC (rev 36316)
+++ scummvm/trunk/engines/cruise/staticres.cpp	2009-02-14 00:10:51 UTC (rev 36317)
@@ -29,22 +29,4 @@
 
 namespace Cruise {
 
-const char *english_strings[] = {
-	"Player Menu", "Save", "Load", "Start again", "Quit", "Inventory"
-};
-const char *french_strings[] = {
-	"Menu Joueur", "Sauvegarde", "Chargement", "Recommencer le jeu", "Quitter", "Inventaire"
-};
-
-const char **getStringList() {
-	switch (_vm->getLanguage()) {
-	case Common::EN_ANY:
-		return english_strings;
-	case Common::FR_FRA:
-		return french_strings;
-	default:
-		error("Unknown language encountered");
-	}
-}
-
 } // End of namespace Cruise

Modified: scummvm/trunk/engines/cruise/staticres.h
===================================================================
--- scummvm/trunk/engines/cruise/staticres.h	2009-02-13 23:33:33 UTC (rev 36316)
+++ scummvm/trunk/engines/cruise/staticres.h	2009-02-14 00:10:51 UTC (rev 36317)
@@ -28,12 +28,6 @@
 
 namespace Cruise {
 
-enum MenuConstants {
-	SL_MENU, SL_SAVE, SL_LOAD, SL_RESTART, SL_QUIT, SL_INVENTORY
-};
-
-const char **getStringList();
-
 } // End of namespace Cruise
 
 #endif


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