This commit is contained in:
Daveo 2000-08-29 16:26:01 +00:00
commit 47aee91ef4
396 changed files with 32003 additions and 0 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,97 @@
/*=========================================================================
KANJICLASS.CPP
Author: Gary Liddon @
Created:
Project:
Purpose:
Copyright (c) 1998 G R Liddon
===========================================================================*/
#ifndef __KANJI_CLASS__
#define __KANJI_CLASS__
/*----------------------------------------------------------------------
Includes
-------- */
/* Std Lib
------- */
#include <vector>
/* Glib
---- */
#include <gtypes.h>
#include <gobject.hpp>
/* Local
----- */
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
class KanjiClass : GObject
{
public:
enum KanjiFontSize
{
FONT_SIZE_11,
FONT_SIZE_13,
FONT_SIZE_15,
};
private:
std::vector<u8> m_kanjiHit;
void initialise(void);
void addKanjiHit(uint hi,uint lo);
bool getKanjiHit(uint hi,uint lo);
void clearKanjiHit(uint hi,uint lo);
int findKanjiIndex(u16 kan) const;
static void saveKanjiLbm(char const * fileName,KanjiFontSize k,u16 kan);
public:
KanjiClass(void);
void addStr(u8 const * newStr);
int howManyKanjiChars(void);
void saveKanjiLbms(char const * dir,KanjiFontSize k = KanjiClass::FONT_SIZE_11);
void saveKanjiLbmNames(char const * dir,char const *name);
void saveKanjiTable(char const *name);
static void writeEnglishFontLbms(char const * dir,KanjiFontSize k = KanjiClass::FONT_SIZE_11,char const * repFile= NULL);
};
/*----------------------------------------------------------------------
Globals
------- */
/* Vars
---- */
/* Data
---- */
/* Functions
--------- */
/*---------------------------------------------------------------------- */
#endif /* XYZ */
/*===========================================================================
end */

299
Utils/transtext/main.cpp Normal file
View file

@ -0,0 +1,299 @@
/*=========================================================================
MAIN.CPP
Author: Gary Liddon @ Fareham
Created: 3rd March 1999
Project: Theme Park World Playstation
Purpose: Main module for Folio
Copyright (c) 1998 G R Liddon
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
/* Std Lib
------- */
#include <vector>
#include <conio.h>
#include <sys/stat.h>
#include <sys/utime.h>
#include <fcntl.h>
#include <io.h>
/* Glib
---- */
#include <misc.hpp>
#include <gfname.hpp>
#include <gstring.hpp>
#include <pcre.h>
/* tplib
---- */
#include <trans.h>
#include <lang.h>
#include <script.h>
/* local
---- */
#include "kanjiclass.h"
/*----------------------------------------------------------------------
Version info
1.0 - 1.2 GL Initial working version
1.3 GL Longer line length (now 4096)
1.4 GL Added comments to file
1.5 GL Changed it so that \n are now returns
1.6 GL Added a slew of stuff to handle kanji
1.7 GL Chganged format of kanji table
1.8 GL Removed bug with kanji frame lookup
1.9 GL added -s so user can specify the size of output font
1.91 GL Transtext also writes out an ID text file (id.dat)
1.92 GL fixed bug with output kanji table being too short
/*----------------------------------------------------------------------
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
using namespace std;
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
static void usage(void);
static char * cycleCommands(char *String,int Num);
/*----------------------------------------------------------------------
Vars
---- */
static const float version=1.92f;
static GString fileWithTranslations;
static GString headerFile;
static GString outDir;
static GString g_japKanjiFile;
static GString g_japLbmDir;
static GString g_englishLbmsDir;
static GString g_japLbmListFile;
static int g_fontSize=0;
/*----------------------------------------------------------------------
Data
---- */
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
int main(int argc, char ** argv)
{
cerr<<"GRLiddon() TRANSTEXT text translation stuphh "<<version<<endl;
cerr<<"Copyright (c) 1999 G R Liddon. All rights reserved"<<endl<<endl;
if (argc==1)
usage();
else
{
CommandLine(argc,argv,cycleCommands);
if (g_englishLbmsDir)
{
KanjiClass::writeEnglishFontLbms(g_englishLbmsDir,KanjiClass::KanjiFontSize(g_fontSize));
}
if (fileWithTranslations)
{
AllTextDatabases myDatabases;
myDatabases.readTranslationFile(fileWithTranslations);
if (outDir)
myDatabases.write(outDir);
if (headerFile)
myDatabases.writeHeaderFile(headerFile);
/* Do some kanji jiggery pokery */
if (g_japKanjiFile || g_japLbmDir || g_japLbmListFile)
{
TextDatabase * jDataBase;
int numOfStrings;
KanjiClass kClass;
jDataBase=myDatabases.getTextDataBase(JAPANESE);
numOfStrings=jDataBase->getNumOfStrings();
for (int f=0;f<numOfStrings;f++)
kClass.addStr((u8 const*)jDataBase->getText(f));
if (g_japLbmDir)
{
if (g_fontSize >=0 && g_fontSize < 3)
kClass.saveKanjiLbms(g_japLbmDir,KanjiClass::KanjiFontSize(g_fontSize));
else
GObject::Error(ERR_FATAL,"illegal font size parameter");
}
if (g_japKanjiFile)
kClass.saveKanjiTable(g_japKanjiFile);
if (g_japLbmListFile && g_japLbmDir)
kClass.saveKanjiLbmNames(g_japLbmDir,g_japLbmListFile);
cout<<"text uses "<<kClass.howManyKanjiChars()<<endl;
}
}
else
GObject::Error(ERR_FATAL,"you must define a translation file");
}
return(0);
}
/*----------------------------------------------------------------------
Function: void Usage(void)
Notes: Usage of the util
---------------------------------------------------------------------- */
void usage(void)
{
cout<<"Usage: TRANSTEXT <in file> [ switches.. ]\n";
cout<<"Switches:\n"<<endl;
cout<<"-o:<dir> Dir to save translation strings to"<<endl;
cout<<"-e:<dir> Dir write ascii images to"<<endl;
cout<<"-h:<file> File to save lang enums to"<<endl;
cout<<endl;
cout<<"-d:<dir> Dir to save kanji lbms to"<<endl;
cout<<"-j:<file> File to save kanji table to"<<endl;
cout<<"-p:<file> File to save list of saved lbms to"<<endl;
cout<<endl;
cout<<"-s:<0|1|2> Set the size of the output font"<<endl;
cout<<endl;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
---------------------------------------------------------------------- */
GString getFileString(char const * Switch)
{
pcre * MyPattern;
int Matches;
const int NumOfOffsets=20;
int Offsets[NumOfOffsets];
char const * ErrTxt;
int ErrNum;
char SwitchText[100];
MyPattern=pcre_compile("^-.:(.*)",0,&ErrTxt,&ErrNum,NULL);
Matches=pcre_exec(MyPattern,NULL,Switch,strlen(Switch),0,Offsets,NumOfOffsets);
if (Matches != 2)
GObject::Error(ERR_FATAL,"Ill formatted switch %s",Switch);
memcpy(SwitchText,&Switch[Offsets[2]],Offsets[3]-Offsets[2]);
SwitchText[Offsets[3]-Offsets[2]]=0;
return(GString(SwitchText));
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
---------------------------------------------------------------------- */
bool getPlusMinus(char const * Switch)
{
pcre * MyPattern;
int Matches;
const int NumOfOffsets=20;
int Offsets[NumOfOffsets];
char const * ErrTxt;
int ErrNum;
MyPattern=pcre_compile("^-.([+|-])",0,&ErrTxt,&ErrNum,NULL);
Matches=pcre_exec(MyPattern,NULL,Switch,strlen(Switch),0,Offsets,NumOfOffsets);
if (Matches != 2)
GObject::Error(ERR_FATAL,"Ill formatted switch %s",Switch);
return(Switch[Offsets[2]]=='+');
}
/*----------------------------------------------------------------------
Function: char *CycleCommands(char *String,int Num)
Purpose: Callback to cycle through command line items
Params: String = Text of item
Num = Item number
---------------------------------------------------------------------- */
char * cycleCommands(char * cmdString,int num)
{
if (cmdString[0]=='-' || cmdString[0]=='/')
{
switch (cmdString[1])
{
case 'e':
g_englishLbmsDir=getFileString(cmdString);
break;
case 'h':
headerFile=getFileString(cmdString);
break;
case 'o':
outDir=getFileString(cmdString);
break;
case 'j':
g_japKanjiFile=getFileString(cmdString);
break;
case 'd':
g_japLbmDir=getFileString(cmdString);
break;
case 'p':
g_japLbmListFile=getFileString(cmdString);
break;
case 's':
g_fontSize=atoi(getFileString(cmdString));
break;
default:
GObject::Error(ERR_FATAL,"unknown switch %s",cmdString);
break;
}
}
else
{
if (fileWithTranslations)
GObject::Error(ERR_FATAL,"translation file already defined as %s",(char const *)fileWithTranslations);
else
fileWithTranslations=cmdString;
}
return(cmdString);
}
/*===========================================================================
end */

336
Utils/transtext/script.cpp Normal file
View file

@ -0,0 +1,336 @@
/*=========================================================================
FILENAME.CPP
Author: Gary Liddon @
Created:
Project:
Purpose:
Copyright (c) 1998 G R Liddon
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
#include "script.h"
/* Std Lib
------- */
/* Glib
---- */
/* Local
----- */
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
using namespace std;
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
const int DEFAULT_LINE_LENGTH=8192;
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
/*----------------------------------------------------------------------
Data
---- */
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
ScriptFile::ScriptFile(void)
{
m_isOpen=false;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
ScriptFile::~ScriptFile(void)
{
close();
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void ScriptFile::close(void)
{
if (m_isOpen)
m_inStream.close();
m_isOpen=false;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void ScriptFile::open(char const * fileName)
{
if (m_isOpen)
close();
m_inStream.open(fileName,ios::binary|ios::in);
if (m_inStream)
{
m_fileName=fileName;
}
else
GObject::Error(ERR_FATAL,"unable to open script file %s",fileName);
m_isOpen=true;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void ScriptFile::scriptError(void)
{
GObject::Error(ERR_FATAL,"Ill formatted script file %s, line %d",(char const *)m_fileName,m_lineCount);
}
/*----------------------------------------------------------------------
Function: ak
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void ScriptFile::checkIsOpen(void)
{
if (!m_isOpen)
GObject::Error(ERR_FATAL,"file operation needed by ScriptFile but no file is open");
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
bool ScriptFile::getNextNonBlankLine(char * line,int lineLen)
{
checkIsOpen();
do
{
if (m_inStream.eof())
return(false);
m_inStream.getline(line,lineLen);
int lineLength;
lineLength=strlen(line);
for (int f=0;f<lineLength;f++)
{
if (line[f] == ';')
line[f]=0;
}
if (strlen(line))
line[strlen(line)-1]=0;
m_lineCount++;
// stripTrailingSpace(line);
}
while (!strlen(line));
return(true);
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
bool ScriptFile::nextLineIsCommand(void)
{
checkIsOpen();
bool retVal;
streampos thisPos;
const int lineLength=DEFAULT_LINE_LENGTH;
char line[lineLength];
int oldLineCount;
oldLineCount=m_lineCount;
retVal=false;
thisPos=m_inStream.tellg();
if (getNextNonBlankLine(line,lineLength))
{
stripTrailingSpace(line);
retVal=isCommand(line);
}
m_inStream.seekg(thisPos);
m_lineCount=oldLineCount;
return(retVal);
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
GString ScriptFile::peekNextCommand(void)
{
checkIsOpen();
GString retStr;
if (nextLineIsCommand())
{
const int lineLength=DEFAULT_LINE_LENGTH;
char line[lineLength];
int oldLineCount;
streampos thisPos;
oldLineCount=m_lineCount;
thisPos=m_inStream.tellg();
getNextNonBlankLine(line,lineLength);
stripTrailingSpace(line);
retStr=getCommandString(line);
m_inStream.seekg(thisPos);
m_lineCount=oldLineCount;
}
return(retStr);
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void ScriptFile::stripTrailingSpace(char * line)
{
if (strlen(line))
{
bool done=false;
for (int f=strlen(line)-1;f<=0 && !done ;f--)
{
if ((!isspace(line[f])) )
done=true;
else
line[f]=0;
}
}
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
GString ScriptFile::getCommandString(char * com)
{
char * newStr;
newStr=strdup(com);
newStr[strlen(newStr)-1]=0;
GString retStr(&newStr[1]);
free(newStr);
return(retStr);
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
bool ScriptFile::isCommand(char * line)
{
return ((line[0]=='[') && (line[strlen(line)-1]==']'));
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
GString ScriptFile::getNextLine(void)
{
const int lineLength=DEFAULT_LINE_LENGTH;
char line[lineLength];
getNextNonBlankLine(line,lineLength);
return(line);
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
bool ScriptFile::eof(void)
{
checkIsOpen();
return(m_inStream.eof());
}
/*===========================================================================
end */

95
Utils/transtext/script.h Normal file
View file

@ -0,0 +1,95 @@
/*=========================================================================
FILENAME.CPP
Author: Gary Liddon @
Created:
Project:
Purpose:
Copyright (c) 1998 G R Liddon
===========================================================================*/
#ifndef __SCRIPT_H__
#define __SCRIPT_H__
/*----------------------------------------------------------------------
Includes
-------- */
/* Std Lib
------- */
#include <fstream>
/* Glib
---- */
#include <gstring.hpp>
/* Local
----- */
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
class ScriptFile
{
private:
std::ifstream m_inStream;
bool m_isOpen;
GString m_fileName;
int m_lineCount;
void scriptError(void);
bool getNextNonBlankLine(char * Line,int LineLen);
void stripTrailingSpace(char * Line);
GString getCommandString(char * Com);
bool isCommand(char * Line);
void checkIsOpen(void);
protected:
bool eof(void);
GString peekNextCommand(void);
bool nextLineIsCommand(void);
GString getNextLine(void);
void open(char const * fileName);
void close(void);
public:
ScriptFile(void);
~ScriptFile(void);
};
/*----------------------------------------------------------------------
Globals
------- */
/* Vars
---- */
/* Data
---- */
/* Functions
--------- */
/*---------------------------------------------------------------------- */
#endif /* __SCRIPT_H__ */
/*===========================================================================
end */

View file

@ -0,0 +1,108 @@
# Microsoft Developer Studio Project File - Name="transtext" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=transtext - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "transtext.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "transtext.mak" CFG="transtext - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "transtext - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "transtext - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""$/TP2psx/utils/transtext", JNXBAAAA"
# PROP Scc_LocalPath "."
CPP=xicl6.exe
RSC=rc.exe
!IF "$(CFG)" == "transtext - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\glibdev\glib\include" /I "..\..\glibdev\glib\include\pc" /I "..\tplib" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib win32lib.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\glibdev\glib\lib\win32lib\release" /libpath:"..\tplib\release"
!ELSEIF "$(CFG)" == "transtext - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\glibdev\glib\include" /I "..\..\glibdev\glib\include\pc" /I "..\tplib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib win32lib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\glibdev\glib\lib\win32lib\debug" /libpath:"..\tplib\debug"
!ENDIF
# Begin Target
# Name "transtext - Win32 Release"
# Name "transtext - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\kanjiclass.cpp
# End Source File
# Begin Source File
SOURCE=.\main.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\kanjiclass.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View file

@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "transtext"=.\transtext.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################