- remove dots, slash and backslash at the beginning of filenames in the texmod.def
- selected language will now be stored
- now one has to set all keys, if save single texture is set to true
This commit is contained in:
code@koerner-de.net
2011-10-06 19:01:26 +00:00
parent 8d4ab8963f
commit d04480d460
6 changed files with 89 additions and 78 deletions
+12 -4
View File
@@ -97,15 +97,15 @@ int OTM_File::GetContent( AddTextureClass *tex, bool add, bool force)
wxString file_type = FileName.AfterLast( '.');
if (file_type == L"zip")
{
AddZip( tex, add, true, false);
AddZip( tex, add, force, false);
}
else if (file_type == L"tpf")
{
AddZip( tex, add, true, true);
AddZip( tex, add, force, true);
}
else if (file_type == L"dds")
{
AddFile( tex, add, true);
AddFile( tex, add, force);
}
else
{
@@ -259,7 +259,7 @@ int OTM_File::AddFile( AddTextureClass *tex, bool add, bool force)
tex->Num = 1;
tex->Add[0] = add;
tex->Force[0] = true;
tex->Force[0] = force;
tex->Hash[0] = temp_hash;
return 0;
}
@@ -339,6 +339,8 @@ int OTM_File::AddContent( const char* pw, AddTextureClass *tex, bool add, bool f
file = entry.AfterFirst( '|');
file.Replace( "\r", "");
while ( (file[0]=='.' && (file[1]=='/' || file[1]=='\\')) || file[0]=='/' || file[0]=='\\') file.Remove(0,1);
if (add)
{
FindZipItem( ZIP_Handle, file.wc_str(), false, &index, &ze); // look for texture
@@ -368,6 +370,12 @@ int OTM_File::AddContent( const char* pw, AddTextureClass *tex, bool add, bool f
count++;
}
}
else
{
LastError << Language.Error_Unzip <<"\nTPF:" << file << "\n";
CloseZip(ZIP_Handle); //somehow we need to close and to reopen the zip handle, otherwise the program crashes
ZIP_Handle = OpenZip( FileInMemory, FileLen, pw);
}
}
else
{
+1
View File
@@ -317,6 +317,7 @@ OTM_GameInfo& OTM_GameInfo::operator = (const OTM_GameInfo &rhs)
KeyBack = rhs.KeyBack;
KeySave = rhs.KeySave;
KeyNext = rhs.KeyNext;
if (LengthOfChecked<rhs.LengthOfChecked)
{
if (Checked!=NULL) delete [] Checked;
+2
View File
@@ -243,6 +243,8 @@ int OTM_GamePage::GetSettings(void)
wxString path = Game.GetSavePath();
if ( (save_single || save_all) && path.Len()==0) {LastError << Language.Error_NoSavePath; return 1;}
if ( save_single && ( key_back==wxNOT_FOUND || key_save==wxNOT_FOUND || key_next==wxNOT_FOUND) ) {LastError << Language.Error_KeyNotSet; return 1;}
if (key_back!=wxNOT_FOUND) Game.SetKeyBack(key_back);
if (key_save!=wxNOT_FOUND) Game.SetKeySave(key_save);
if (key_next!=wxNOT_FOUND) Game.SetKeyNext(key_next);
-1
View File
@@ -79,7 +79,6 @@ private:
wxTextCtrl *SavePath;
wxBoxSizer **CheckBoxHSizers;
//wxBoxSizer *CheckBoxVSizer;
wxButton **CheckButtonUp;
wxButton **CheckButtonDown;
wxButton **CheckButtonDelete;
+72 -71
View File
@@ -21,10 +21,9 @@ along with OpenTexMod. If not, see <http://www.gnu.org/licenses/>.
#include "OTM_Main.h"
OTM_Language::OTM_Language(void) : DefaultLanguage("English")
OTM_Language::OTM_Language(void)
{
if (LoadCurrentLanguage()) {CurrentLanguage = DefaultLanguage; LoadDefault();}
else LoadLanguage( CurrentLanguage);
if (LoadCurrentLanguage()) {LoadDefault(); CurrentLanguage = "English"; LastError.Empty();}
LoadKeys();
}
@@ -47,16 +46,16 @@ int OTM_Language::LoadCurrentLanguage(void)
if (result != len) return -1;
buffer[len]=0;
CurrentLanguage = buffer;
wxString lang = buffer;
delete [] buffer;
return 0;
return LoadLanguage( lang, false);
}
int OTM_Language::SaveCurrentLanguage(void)
{
wxFile file;
if (!file.Access( LAST_USED_LANGUAGE_FILE, wxFile::write)) return -1;
//if (!file.Access( LAST_USED_LANGUAGE_FILE, wxFile::write)) return -1;
file.Open( LAST_USED_LANGUAGE_FILE, wxFile::write);
if (!file.IsOpened()) return -1;
@@ -127,10 +126,9 @@ if ( command == #target ) \
target = msg; \
} else
int OTM_Language::LoadLanguage(const wxString &name)
int OTM_Language::LoadLanguage(const wxString &name, bool save)
{
LoadDefault();
CurrentLanguage = name;
if (name=="English")
{
if (wxFile::Exists(LAST_USED_LANGUAGE_FILE)) wxRemoveFile(LAST_USED_LANGUAGE_FILE);
@@ -156,6 +154,7 @@ int OTM_Language::LoadLanguage(const wxString &name)
if (result != len) {delete [] buffer; LastError << Error_FileRead<<"\n" << file_name; return -1;}
buffer[len]=0;
CurrentLanguage = name;
wxStringTokenizer token( buffer, "|");
int num = token.CountTokens();
@@ -202,6 +201,7 @@ int OTM_Language::LoadLanguage(const wxString &name)
CheckEntry( command, msg, Error_Send)
CheckEntry( command, msg, Error_KeyTwice)
CheckEntry( command, msg, Error_NoSavePath)
CheckEntry( command, msg, Error_KeyNotSet)
CheckEntry( command, msg, Error_SaveFile)
CheckEntry( command, msg, Error_NoPipe)
CheckEntry( command, msg, Error_WritePipe)
@@ -222,78 +222,79 @@ int OTM_Language::LoadLanguage(const wxString &name)
delete [] buffer;
SaveCurrentLanguage();
if (save) SaveCurrentLanguage();
return 0;
}
#undef CheckEntry
int OTM_Language::LoadDefault(void)
{
MenuLanguage = "Change Language";
MenuHelp = "Help";
MenuAbout = "About";
MenuAddGame = "Add game";
MenuDeleteGame = "Delete Game";
MainMenuGame = "Game";
MainMenuHelp = "Help";
ButtonOpen = "Open texture";
ButtonDirectory = "Set save directory";
ButtonUpdate = "Update";
ButtonSave = "save settings";
ChooseFile = "Choose a texture file";
ChooseDir = "Choose a directory";
CheckBoxSaveSingleTexture = "Save single texture";
CheckBoxSaveAllTextures = "Save all textures";
TextCtrlSavePath = "Save path:";
SelectLanguage = "Select a language.";
ChooseGame = "Select a game binary.";
DeleteGame = "Select the games to be deleted.";
GameAlreadyAdded = "Game has been already added.";
ExitGameAnyway = "Closing OpenTexMod while a game is running might lead to a crash of the game.\nExit anyway?";
NoComment = "No comment.";
Author = "Author: ";
Error_FileNotSupported = "This file type is not supported:\n";
Error_DLLNotFound = "Could not load the dll.\nThe dll injection won't work.\nThis might happen if D3DX9_43.dll is not installed on your system.\nPlease install the newest DirectX End-User Runtime Web Installer.";
Error_FktNotFound = "Could not load function out of dll.\nThe dll injection won't work.";
Error_Send = "Could not send to game.";
Error_KeyTwice = "You have assigned the same key twice.";
Error_NoSavePath = "You did not set a save path.";
Error_KeyNotSet = "At least one key is not set.";
Error_SaveFile = "Could not save to file.";
Error_NoPipe = "Pipe is not opened.";
Error_WritePipe = "Could not write in pipe.";
Error_FlushPipe = "Could not flush pipe buffer.";
Error_Hash = "Could not find hash, maybe file is not named as *_HASH.dds";
Error_FileOpen = "Could not open file:";
Error_FileRead = "Could not read file:";
Error_Memory = "Could not allocate enough memory.";
Error_Unzip = "Could not unzip.";
Error_ZipEntry = "Could not find zip entry.";
KeyBack = "Back";
KeySave = "Save";
KeyNext = "Next";
FontColour = "Font colour (RGB):";
TextureColour = "Texture colour (RGB):";
return 0;
}
#define AddKey( name, key ) \
{ \
KeyStrings.Add( name ); \
KeyValues.Add( key ); \
}
int OTM_Language::LoadDefault(void)
{
MenuLanguage = L"Change Language";
MenuHelp = L"Help";
MenuAbout = L"About";
MenuAddGame = L"Add game";
MenuDeleteGame = L"Delete Game";
MainMenuGame = L"Game";
MainMenuHelp = L"Help";
ButtonOpen = L"Open texture";
ButtonDirectory = L"Set save directory";
ButtonUpdate = L"Update";
ButtonSave = L"save settings";
ChooseFile = L"Choose a texture file";
ChooseDir = L"Choose a directory";
CheckBoxSaveSingleTexture = L"Save single texture";
CheckBoxSaveAllTextures = L"Save all textures";
TextCtrlSavePath = L"Save path:";
SelectLanguage = L"Select a language.";
ChooseGame = L"Select a game binary.";
DeleteGame = L"Select the games to be deleted.";
GameAlreadyAdded = L"Game has been already added.";
ExitGameAnyway = L"Closing OpenTexMod while a game is running might lead to a crash of the game.\nExit anyway?";
NoComment = L"No comment.";
Author = L"Author: ";
Error_FileNotSupported = L"This file type is not supported:\n";
Error_DLLNotFound = L"Could not load the dll.\nThe dll injection won't work.\nThis might happen if D3DX9_43.dll is not installed on your system.\nPlease install the newest DirectX End-User Runtime Web Installer.";
Error_FktNotFound = L"Could not load function out of dll.\nThe dll injection won't work.";
Error_Send = L"Could not send to game.";
Error_KeyTwice = L"You have assigned the same key twice.";
Error_NoSavePath = L"You did not set a save path.";
Error_SaveFile = L"Could not save to file.";
Error_NoPipe = L"Pipe is not opened.";
Error_WritePipe = L"Could not write in pipe.";
Error_FlushPipe = L"Could not flush pipe buffer.";
Error_Hash = L"Could not find hash, maybe file is not named as *_HASH.dds";
Error_FileOpen = L"Could not open file:";
Error_FileRead = L"Could not read file:";
Error_Memory = L"Could not allocate enough memory.";
Error_Unzip = L"Could not unzip.";
Error_ZipEntry = L"Could not find zip entry.";
KeyBack = L"Back";
KeySave = L"Save";
KeyNext = L"Next";
FontColour = L"Font colour (RGB):";
TextureColour = L"Texture colour (RGB):";
return 0;
}
int OTM_Language::LoadKeys(void)
{
KeyStrings.Empty();
+2 -2
View File
@@ -27,7 +27,7 @@ public:
OTM_Language(void);
int LoadLanguage(const wxString &name);
int LoadLanguage(const wxString &name, bool save=true);
int GetLanguages(wxArrayString &lang);
int GetHelpMessage(wxString &help);
@@ -67,6 +67,7 @@ public:
wxString Error_Send;
wxString Error_KeyTwice;
wxString Error_NoSavePath;
wxString Error_KeyNotSet;
wxString Error_SaveFile;
wxString Error_NoPipe;
wxString Error_WritePipe;
@@ -99,7 +100,6 @@ private:
int LoadKeys(void);
wxString CurrentLanguage;
const wxString DefaultLanguage;
};