| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430 |
- /*
- ** Command & Conquer Generals Zero Hour(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- //
- // ParseStr.h
- //
- //
- #ifndef __TRANSDB_H
- #define __TRANSDB_H
- #include "olestring.h"
- #include "list.h"
- #include "bin.h"
- class CBabylonDlg;
- typedef struct
- {
- int numdialog;
- int missing;
- int unresolved;
- int resolved;
- int errors;
- } DLGREPORT;
- typedef struct
- {
- int numlabels;
- int numstrings;
- int missing;
- int retranslate;
- int too_big;
- int errors;
- int bad_format;
- int translated;
- } TRNREPORT;
- typedef enum
- {
-
- PMASK_NONE = 0,
- PMASK_MISSING = 0x00000001,
- PMASK_UNRESOLVED = 0x00000002,
- PMASK_BADFORMAT = 0x00000004,
- PMASK_TOOLONG = 0x00000008,
- PMASK_RETRANSLATE = 0x00000010,
- PMASK_ALL = 0xffffffff
- } PMASK;
- typedef enum
- {
- LANGID_US,
- LANGID_UK,
- LANGID_GERMAN,
- LANGID_FRENCH,
- LANGID_SPANISH,
- LANGID_ITALIAN,
- LANGID_JAPANESE,
- LANGID_JABBER,
- LANGID_KOREAN,
- LANGID_CHINESE,
- LANGID_UNKNOWN
- } LangID;
- typedef struct
- {
- LangID langid;
- char *name;
- char *initials ; // two character identifier
- char *character; // single character identifier
- } LANGINFO;
- LANGINFO* GetLangInfo ( LangID langid );
- char* GetLangName ( LangID langid );
- LANGINFO* GetLangInfo ( int index );
- LANGINFO* GetLangInfo ( char *language );
- class CWaveInfo
- {
- int wave_valid;
- DWORD wave_size_hi;
- DWORD wave_size_lo;
- int missing;
- public:
- CWaveInfo ( void );
- int Valid ( void ) { return wave_valid; };
- DWORD Lo ( void ) { return wave_size_lo; };
- DWORD Hi ( void ) { return wave_size_hi; };
- void SetValid( int new_valid ) { wave_valid = new_valid; };
- void SetLo ( DWORD new_lo ) { wave_size_lo = new_lo; };
- void SetHi ( DWORD new_hi ) { wave_size_hi = new_hi; };
- int Missing ( void ) { return missing; };
- void SetMissing ( int val ) { missing = val; };
- };
- class DBAttribs
- {
- DBAttribs *parent;
- int changed;
- int processed;
- void *match;
- public:
- DBAttribs( void ) { parent = NULL; changed = FALSE; processed = FALSE; match = NULL; };
- void SetParent ( DBAttribs *new_parent ) { parent = new_parent; };
- int IsChanged ( void ) { return changed; };
- void Changed ( void ) { changed = TRUE; if ( parent ) parent->Changed(); };
- void NotChanged ( void ) { changed = FALSE; };
- char ChangedSymbol ( void ) { return changed ? '*' :' '; };
- int IsProcessed ( void ) { return processed; };
- void Processed ( void ) { processed = TRUE; };
- void NotProcessed ( void ) { processed = FALSE; };
- void* Matched ( void ) { return match; };
- void Match ( void* new_match ) { match = new_match; };
- void NotMatched ( void ) { match = NULL; };
- };
- class TransDB;
- class BabylonLabel;
- class BabylonText;
- class Translation : public DBAttribs
- {
- TransDB *db;
- OLEString *text;
- OLEString *comment;
- LangID langid;
- int revision;
- int sent;
- public:
- CWaveInfo WaveInfo;
- Translation ( void );
- ~Translation ( );
- void SetDB ( TransDB *new_db );
- Translation* Clone ( void );
- void SetLangID ( LangID new_id ) { langid = new_id; };
- TransDB* DB ( void ) { return db; };
- void ClearChanges (void) { NotChanged(); };
- void ClearProcessed (void) { NotProcessed(); };
- void ClearMatched (void) { NotMatched(); };
- int Clear ( void ) { return 0;};
- void Set ( OLECHAR *string ) { text->Set ( string ); Changed();};
- void Set ( char *string ) { text->Set ( string ); Changed(); };
- OLECHAR* Get ( void ) { return text->Get (); };
- int Len ( void ) { return text->Len (); };
- char* GetSB ( void ) { return text->GetSB (); };
- void SetComment ( OLECHAR *string ) { comment->Set ( string ); Changed(); };
- void SetComment ( char *string ) { comment->Set ( string ); Changed(); };
- OLECHAR* Comment ( void ) { return comment->Get(); };
- char* CommentSB ( void ) { return comment->GetSB(); };
- int Revision ( void ) { return revision; };
- void SetRevision ( int new_rev ) { revision = new_rev; Changed(); };
- LangID GetLangID ( void ) { return langid; };
- char* Language ( void ) { return GetLangName ( langid );};
- void AddToTree ( CTreeCtrl *tc, HTREEITEM parent, int changes = FALSE );
- int TooLong ( int maxlen );
- int ValidateFormat ( BabylonText *text );
- int IsSent ( void );
- void Sent ( int val );
- };
- class BabylonText : public DBAttribs
- {
- TransDB *db;
- OLEString *text;
- BabylonLabel *label;
- OLEString *wavefile;
- unsigned int line_number;
- List translations;
- int revision;
- int id;
- int retranslate;
- int sent;
- void init ( void );
- public:
- CWaveInfo WaveInfo;
- BabylonText( void );
- ~BabylonText( );
- void AddTranslation ( Translation *trans );
- Translation* FirstTranslation ( ListSearch &sh );
- Translation* NextTranslation ( ListSearch &sh );
- Translation* GetTranslation ( LangID langid );
- void SetDB ( TransDB *new_db );
- void ClearChanges ( void );
- void ClearProcessed ( void );
- void ClearMatched ( void );
- int Clear ( void );
- BabylonText* Clone ( void );
- void Remove ( void );
- void AssignID ( void );
- void Set ( OLECHAR *string );
- void Set ( char *string );
- void SetID ( int new_id ) { id = new_id; Changed(); };
- int ID ( void ) { return id; };
- void LockText ( void ) { text->Lock(); };
- TransDB* DB ( void ) { return db; };
- OLECHAR* Get ( void ) { return text->Get (); } ;
- int Len ( void ) { return text->Len (); };
- char* GetSB ( void ) { return text->GetSB (); } ;
- void SetWave ( OLECHAR *string ) { wavefile->Set ( string ); Changed(); InvalidateAllWaves (); };
- void SetWave ( char *string ) { wavefile->Set ( string ); Changed(); InvalidateAllWaves (); };
- void SetLabel ( BabylonLabel *new_label ) { label = new_label; };
- void SetRetranslate ( int flag = TRUE ) { retranslate = flag;};
- int Retranslate ( void ) { return retranslate; };
- OLECHAR* Wave ( void ) { return wavefile->Get (); } ;
- char* WaveSB ( void ) { return wavefile->GetSB (); } ;
- BabylonLabel* Label ( void ) { return label; } ;
- int Revision ( void ) { return revision; } ;
- void SetRevision ( int new_rev ) { revision = new_rev; Changed(); } ;
- void IncRevision ( void ) { revision++; Changed(); };
- void AddToTree ( CTreeCtrl *tc, HTREEITEM parent, int changes = FALSE );
- int LineNumber ( void ) { return line_number; };
- void SetLineNumber ( int line ) { line_number = line; Changed(); };
- void FormatMetaString ( void ) { text->FormatMetaString (); Changed();};
- int IsDialog ( void );
- int DialogIsPresent ( const char *path, LangID langid = LANGID_US );
- int DialogIsValid ( const char *path, LangID langid = LANGID_US, int check = TRUE );
- int ValidateDialog( const char *path, LangID langid = LANGID_US );
- void InvalidateAllWaves ( void );
- void InvalidateWave ( void );
- void InvalidateWave ( LangID langid );
- int IsSent ( void );
- void Sent ( int val );
-
- };
- class BabylonLabel : public DBAttribs
- {
- TransDB *db;
-
- OLEString *name;
- OLEString *comment;
- OLEString *context;
- OLEString *speaker;
- OLEString *listener;
- unsigned int max_len;
- unsigned int line_number;
- List text;
- void init ( void );
- public:
- BabylonLabel ( void );
- ~BabylonLabel ( );
- int Clear ( void );
- void ClearChanges ( void );
- void ClearProcessed ( void );
- void ClearMatched ( void );
- int AllMatched ( void );
- void Remove ( void );
- void AddText ( BabylonText *new_text );
- void RemoveText ( BabylonText *new_text );
- BabylonText* FirstText ( ListSearch& sh );
- BabylonText* NextText ( ListSearch& sh);
- BabylonText* FindText ( OLECHAR *find_text );
- void SetDB ( TransDB *new_db );
- BabylonLabel* Clone ( void );
- int NumStrings ( void ) { return text.NumItems(); };
- void SetMaxLen ( int max ) { max_len = max; Changed(); };
- int MaxLen ( void ) { return max_len; };
- void SetLineNumber( int line ) { line_number = line; Changed(); };
- int LineNumber ( void ) { return line_number; };
- TransDB* DB ( void ) { return db;};
- void LockName ( void ) { name->Lock(); };
- void SetName ( OLECHAR *string ) { name->Set ( string ); Changed(); };
- void SetName ( char *string ) { name->Set ( string ); Changed(); };
- void SetComment ( OLECHAR *string ) { comment->Set ( string ); Changed(); };
- void SetComment ( char *string ) { comment->Set ( string ); Changed(); };
- void SetContext ( OLECHAR *string ) { context->Set ( string ); Changed(); };
- void SetContext ( char *string ) { context->Set ( string ); Changed(); };
- void SetSpeaker ( char *string ) { speaker->Set ( string ); Changed(); };
- void SetSpeaker ( OLECHAR *string ) { speaker->Set ( string ); Changed(); };
- void SetListener ( char *string ) { listener->Set ( string ); Changed(); };
- void SetListener ( OLECHAR *string ) { listener->Set ( string ); Changed(); };
- OLECHAR* Name ( void ) { return name->Get (); };
- OLECHAR* Comment ( void ) { return comment->Get(); };
- OLECHAR* Context ( void ) { return context->Get(); };
- OLECHAR* Speaker ( void ) { return speaker->Get(); };
- OLECHAR* Listener ( void ) { return listener->Get(); };
- char* NameSB ( void ) { return name->GetSB (); };
- char* CommentSB ( void ) { return comment->GetSB(); };
- char* ContextSB ( void ) { return context->GetSB(); };
- char* SpeakerSB ( void ) { return speaker->GetSB(); };
- char* ListenerSB ( void ) { return listener->GetSB(); };
- void AddToTree ( CTreeCtrl *tc, HTREEITEM parent, int changes = FALSE );
- };
- #define TRANSDB_OPTION_NONE 00000000
- #define TRANSDB_OPTION_DUP_TEXT 00000001 // strings can be dupilcated across labels
- #define TRANSDB_OPTION_MULTI_TEXT 00000002 // labels can have more than 1 string
- const int START_STRING_ID = 10000;
- class TransDB : public DBAttribs
- {
- ListNode node;
- List labels;
- List obsolete;
- Bin *label_bin;
- Bin *text_bin;
- BinID *text_id_bin;
- Bin *obsolete_bin;
- char name[100];
- int num_obsolete;
- int next_string_id;
- int valid;
- int checked_for_errors;
- int last_error_count;
- int flags;
- public:
- TransDB ( char *name = "no name" );
- ~TransDB ( );
- void InvalidateDialog( LangID langid );
- void VerifyDialog( LangID langid, void (*cb) ( void ) = NULL );
- int ReportDialog( DLGREPORT *report, LangID langid, void (*print) ( const char *)= NULL, PMASK pmask= PMASK_ALL );
- int ReportTranslations( TRNREPORT *report, LangID langid, void (*print) ( const char *) = NULL, PMASK pmask = PMASK_ALL );
- void ReportDuplicates ( CBabylonDlg *dlg = NULL );
- void AddLabel ( BabylonLabel *label );
- void AddText ( BabylonText *text );
- void AddObsolete ( BabylonText *text );
- void RemoveLabel ( BabylonLabel *label );
- void RemoveText ( BabylonText *text );
- void RemoveObsolete ( BabylonText *text );
- int Errors ( CBabylonDlg *dlg = NULL );
- int HasErrors ( void ) { return checked_for_errors ? last_error_count != 0 : FALSE; };
- int Warnings ( CBabylonDlg *dlg = NULL );
- int NumLabelsChanged ( void );
- int NumLabels ( void );
- int NumObsolete ( void ) { return num_obsolete; };
- BabylonLabel* FirstLabel ( ListSearch& sh );
- BabylonLabel* NextLabel ( ListSearch& sh);
- BabylonText* FirstObsolete ( ListSearch& sh );
- BabylonText* NextObsolete ( ListSearch& sh);
- BabylonLabel* FindLabel ( OLECHAR *name );
- BabylonText* FindText ( OLECHAR *text );
- BabylonText* FindSubText ( OLECHAR *text, int item = 0 );
- BabylonText* FindText ( int id );
- BabylonText* FindNextText ( void );
- BabylonText* FindObsolete ( OLECHAR *text );
- BabylonText* FindNextObsolete ( void );
- int Clear ( void );
- void ClearChanges ( void );
- void ClearProcessed ( void );
- void ClearMatched ( void );
- TransDB* Next ( void );
- void AddToTree ( CTreeCtrl *tc, HTREEITEM parent, int changes = FALSE, void (*cb) ( void ) = NULL );
- char* Name ( void ) { return name;};
- void EnableIDs ( void ) { next_string_id = START_STRING_ID; };
- int NewID ( void ) { if ( next_string_id != -1) return next_string_id++; else return -1; };
- int ID ( void ) { return next_string_id; };
- void SetID ( int new_id ) { next_string_id = new_id; };
- int IsValid ( void ) { return valid; };
- void InValid ( void ) { valid = FALSE; };
- int DuplicatesAllowed ( void ) { return flags & TRANSDB_OPTION_DUP_TEXT;};
- int MultiTextAllowed ( void ) { return flags & TRANSDB_OPTION_MULTI_TEXT;};
- void AllowDupiclates ( int yes = TRUE) { yes ? flags |= TRANSDB_OPTION_DUP_TEXT : flags &= ~(TRANSDB_OPTION_DUP_TEXT ); };
- void AllowMultiText ( int yes = TRUE) { yes ? flags |= TRANSDB_OPTION_MULTI_TEXT : flags &= ~(TRANSDB_OPTION_MULTI_TEXT ); };
- };
- class DupNode : public ListNode
- {
- BabylonText *original;
- BabylonText *duplicate;
- public:
- DupNode ( BabylonText *dup, BabylonText *orig ) { original = orig; duplicate = dup, SetPriority ( orig->LineNumber ());};
- BabylonText *Duplicate ( void ) { return duplicate; };
- BabylonText *Original ( void ) { return original; };
- };
- extern TransDB* FirstTransDB ( void );
- #endif // __TRANSDB_H
|