fixes for menu and game strings
git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@113 4df4b0f3-56ce-47cb-b001-ed939b7d65a6
This commit is contained in:
@@ -300,6 +300,7 @@ unsigned int xstart,ystart;
|
|||||||
|
|
||||||
void CGraphics::drawCharacter(int x, int y, int f)
|
void CGraphics::drawCharacter(int x, int y, int f)
|
||||||
{
|
{
|
||||||
|
assert(f >= 0 && f < 256);
|
||||||
unsigned char xa,ya;
|
unsigned char xa,ya;
|
||||||
|
|
||||||
for(ya=0;ya<8;ya++)
|
for(ya=0;ya<8;ya++)
|
||||||
@@ -596,12 +597,11 @@ int c;
|
|||||||
void CGraphics::drawFont(const std::string& text, int xoff, int yoff, int highlight)
|
void CGraphics::drawFont(const std::string& text, int xoff, int yoff, int highlight)
|
||||||
{
|
{
|
||||||
unsigned int i,x=xoff,y;
|
unsigned int i,x=xoff,y;
|
||||||
int c;
|
|
||||||
|
|
||||||
y = yoff;
|
y = yoff;
|
||||||
for(i=0;i<text.size();i++)
|
for(i=0;i<text.size();i++)
|
||||||
{
|
{
|
||||||
c = text[i];
|
unsigned char c = text[i];
|
||||||
if (c!=13)
|
if (c!=13)
|
||||||
{
|
{
|
||||||
if (highlight) c|=128;
|
if (highlight) c|=128;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include "StringUtils.h"
|
#include "StringUtils.h"
|
||||||
|
#include "Debug.h"
|
||||||
|
|
||||||
extern CPlayer *Player;
|
extern CPlayer *Player;
|
||||||
|
|
||||||
@@ -751,15 +752,14 @@ unsigned int i;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load strings from file *fname ("strings.dat")
|
// load strings from file *fname ("strings.dat")
|
||||||
char loadstrings(const char *fname)
|
char loadstrings(const std::string& fname)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char state;
|
char state;
|
||||||
char stName[80];
|
std::string stName;
|
||||||
char stString[1024];
|
std::string stString;
|
||||||
char stAttr[80];
|
char stAttr[80];
|
||||||
int i,c;
|
int i,c;
|
||||||
int nameIndex, stringIndex;
|
|
||||||
int attrIndex=0;
|
int attrIndex=0;
|
||||||
int waitChar, gotoState;
|
int waitChar, gotoState;
|
||||||
char highlight;
|
char highlight;
|
||||||
@@ -769,8 +769,8 @@ char highlight;
|
|||||||
#define STSTATE_READSTRING 2
|
#define STSTATE_READSTRING 2
|
||||||
#define STSTATE_READATTR 3
|
#define STSTATE_READATTR 3
|
||||||
|
|
||||||
g_pLogFile->ftextOut("loadstrings(): Opening string file '%s'.<br>", fname);
|
g_pLogFile->ftextOut("loadstrings(): Opening string file '%s'.<br>", fname.c_str());
|
||||||
fp = fopen(fname, "rb");
|
fp = fopen(fname.c_str(), "rb");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
g_pLogFile->ftextOut("loadstrings(): String file unable to open.<br>");
|
g_pLogFile->ftextOut("loadstrings(): String file unable to open.<br>");
|
||||||
@@ -786,8 +786,6 @@ g_pLogFile->ftextOut("loadstrings(): Opening string file '%s'.<br>", fname);
|
|||||||
strings[i].numAttributes = 0;
|
strings[i].numAttributes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
nameIndex = 0;
|
|
||||||
stringIndex = 0;
|
|
||||||
numStrings = 0;
|
numStrings = 0;
|
||||||
highlight = 0;
|
highlight = 0;
|
||||||
|
|
||||||
@@ -844,13 +842,11 @@ g_pLogFile->ftextOut("loadstrings(): Opening string file '%s'.<br>", fname);
|
|||||||
// read in the string name until we get to ']'
|
// read in the string name until we get to ']'
|
||||||
if (c != ']')
|
if (c != ']')
|
||||||
{
|
{
|
||||||
stName[nameIndex] = c;
|
stName += (char)c;
|
||||||
nameIndex++;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stName[nameIndex] = 0; //null-terminate
|
highlight = 0;
|
||||||
highlight = 0;
|
|
||||||
// read any attributes until the CR
|
// read any attributes until the CR
|
||||||
state = STSTATE_READATTR;
|
state = STSTATE_READATTR;
|
||||||
attrIndex = 0;
|
attrIndex = 0;
|
||||||
@@ -864,63 +860,59 @@ g_pLogFile->ftextOut("loadstrings(): Opening string file '%s'.<br>", fname);
|
|||||||
// you can put [ and ] in the string by using \( and \).
|
// you can put [ and ] in the string by using \( and \).
|
||||||
// set a highlight (change font color to the +128 font) with \H
|
// set a highlight (change font color to the +128 font) with \H
|
||||||
// stop highlighting with \h
|
// stop highlighting with \h
|
||||||
if (stringIndex>0 && stString[stringIndex-1]=='\\'+(highlight*128))
|
if (stString.size()>0 && stString[stString.size()-1]==char('\\'+(highlight*128)))
|
||||||
{ // delimiter detected
|
{ // delimiter detected
|
||||||
if (c=='(')
|
if (c=='(')
|
||||||
{
|
{
|
||||||
stString[stringIndex - 1] = '[' + (highlight*128);
|
stString[stString.size()-1] = '[' + (highlight*128);
|
||||||
}
|
}
|
||||||
else if (c==')')
|
else if (c==')')
|
||||||
{
|
{
|
||||||
stString[stringIndex - 1] = ']' + (highlight*128);
|
stString[stString.size()-1] = ']' + (highlight*128);
|
||||||
}
|
}
|
||||||
else if (c=='H')
|
else if (c=='H')
|
||||||
{
|
{
|
||||||
highlight = 1;
|
highlight = 1;
|
||||||
stringIndex--;
|
stString.erase(stString.size()-1);
|
||||||
}
|
}
|
||||||
else if (c=='h')
|
else if (c=='h')
|
||||||
{
|
{
|
||||||
highlight = 0;
|
highlight = 0;
|
||||||
stringIndex--;
|
stString.erase(stString.size()-1);
|
||||||
}
|
}
|
||||||
else if (c=='\\')
|
else if (c=='\\')
|
||||||
{
|
{
|
||||||
stString[stringIndex - 1] = '\\' + (highlight*128);
|
stString[stString.size() - 1] = '\\' + (highlight*128);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // normal non-delimited char
|
{ // normal non-delimited char
|
||||||
stString[stringIndex] = c;
|
stString += (char)c + ((highlight && c!=0 && c!=13) ? 128 : 0);
|
||||||
if (highlight && c!=0 && c!=13)
|
|
||||||
{
|
|
||||||
stString[stringIndex] += 128;
|
|
||||||
}
|
|
||||||
stringIndex++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stString[stringIndex-1] = 0; //null-terminate (cutting off final CR)
|
// HexDump(GetConstIterator(stName), printOnLogger<notes>, 0);
|
||||||
|
// HexDump(GetConstIterator(stString), printOnLogger<notes>, 0);
|
||||||
|
// notes.flush();
|
||||||
/* save the string to the strings[] structure */
|
/* save the string to the strings[] structure */
|
||||||
|
|
||||||
// copy the string info to the newly malloc()'d memory area
|
// copy the string info to the newly malloc()'d memory area
|
||||||
strings[numStrings].name = stName;
|
strings[numStrings].name = stName;
|
||||||
strings[numStrings].stringptr = stString;
|
strings[numStrings].stringptr = stString;
|
||||||
|
stName = "";
|
||||||
|
stString = "";
|
||||||
|
|
||||||
numStrings++;
|
numStrings++;
|
||||||
// read the name of the next string
|
// read the name of the next string
|
||||||
state = STSTATE_READNAME;
|
state = STSTATE_READNAME;
|
||||||
nameIndex = 0;
|
|
||||||
stringIndex = 0;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} while(1);
|
} while(1);
|
||||||
|
|
||||||
g_pLogFile->ftextOut("loadstrings(): loaded %d strings from '%s'.<br>", numStrings, fname);
|
g_pLogFile->ftextOut("loadstrings(): loaded %d strings from '%s'.<br>", numStrings, fname.c_str());
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -949,13 +941,17 @@ int NumStringsFreed;
|
|||||||
return NumStringsFreed;
|
return NumStringsFreed;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *MissingString = "MISSING STRING!";
|
static void dumpstrings() {
|
||||||
|
notes << "Available strings: ";
|
||||||
|
for(int i=0;i<numStrings;i++)
|
||||||
|
notes << strings[i].name << ", ";
|
||||||
|
notes << endl;
|
||||||
|
}
|
||||||
|
|
||||||
// returns a pointer to the string with name 'name'
|
// returns a pointer to the string with name 'name'
|
||||||
std::string getstring(const std::string& name)
|
std::string getstring(const std::string& name)
|
||||||
{
|
{
|
||||||
int i;
|
for(int i=0;i<numStrings;i++)
|
||||||
for(i=0;i<numStrings;i++)
|
|
||||||
{
|
{
|
||||||
if (name == strings[i].name)
|
if (name == strings[i].name)
|
||||||
{
|
{
|
||||||
@@ -963,7 +959,9 @@ int i;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return MissingString;
|
//dumpstrings();
|
||||||
|
|
||||||
|
return "UNKNOWN '" + name + "' STRING";
|
||||||
}
|
}
|
||||||
|
|
||||||
// because windows and linux read files differently, these is to function to get them correctly
|
// because windows and linux read files differently, these is to function to get them correctly
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
char loadstrings(const char *fname);
|
char loadstrings(const std::string& fname);
|
||||||
unsigned int fgeti(FILE *fp);
|
unsigned int fgeti(FILE *fp);
|
||||||
unsigned long fgetl(FILE *fp);
|
unsigned long fgetl(FILE *fp);
|
||||||
std::string formatPathString(const std::string& path);
|
std::string formatPathString(const std::string& path);
|
||||||
|
|||||||
Reference in New Issue
Block a user