mirror of
https://github.com/gwdevhub/gMod.git
synced 2026-07-21 01:49:31 +00:00
BugFix:
- append '\0' at the end of game name (dll injection) - Release() fake texture (if force reload) instead of calling RemoveTexture(..) Improvements: - template support, you can now have more than one template set one of them as default. - update function will only update the texture if this is needed or the reload button is pressed. - textures will also be removed, if they are removed from the package list.
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
This file is part of OpenTexMod.
|
||||
|
||||
|
||||
OpenTexMod 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.
|
||||
|
||||
OpenTexMod 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 OpenTexMod. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "OTM_Main.h"
|
||||
|
||||
|
||||
|
||||
AddTextureClass::AddTextureClass(void)
|
||||
{
|
||||
Num = 0;
|
||||
Textures = NULL;
|
||||
Size = NULL;
|
||||
Hash = NULL;
|
||||
WasAdded = NULL;
|
||||
Len=0;
|
||||
|
||||
Add = false;
|
||||
Force = false;
|
||||
Loaded = false;
|
||||
OwnMemory = false;
|
||||
}
|
||||
|
||||
AddTextureClass::~AddTextureClass(void)
|
||||
{
|
||||
ReleaseMemory();
|
||||
}
|
||||
|
||||
int AddTextureClass::ReleaseMemory(void)
|
||||
{
|
||||
if (OwnMemory)
|
||||
{
|
||||
if (Size!=NULL) delete [] Size;
|
||||
if (Hash!=NULL) delete [] Hash;
|
||||
if (WasAdded!=NULL) delete [] WasAdded;
|
||||
|
||||
|
||||
if (Textures!=NULL)
|
||||
{
|
||||
for (unsigned int i=0; i<Num && i<Len; i++) if (Textures[i]!=NULL) delete [] Textures[i];
|
||||
delete [] Textures;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AddTextureClass::SetSize(int num)
|
||||
{
|
||||
Num = 0;
|
||||
if (GetMemory( Size, num, 0u)) return -1;
|
||||
if (GetMemory( Hash, num)) return -1;
|
||||
if (GetMemory( WasAdded, num, false)) return -1;
|
||||
if (GetMemory( Textures, num, (char*)0)) return -1;
|
||||
|
||||
OwnMemory = true;
|
||||
Len = num;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AddTextureClass::InheriteMemory(AddTextureClass &tex)
|
||||
{
|
||||
if (!tex.OwnMemory)
|
||||
{
|
||||
if (SetSize(tex.Len)) return -1;
|
||||
for (unsigned int i=0u; i<tex.Len; i++) Hash[i] = tex.Hash[i];
|
||||
for (unsigned int i=0u; i<tex.Len; i++) WasAdded[i] = tex.WasAdded[i];
|
||||
for (unsigned int i=0u; i<tex.Len; i++) Size[i] = tex.Size[i];
|
||||
for (unsigned int i=0u; i<tex.Num; i++) if (tex.Textures[i]!=NULL && tex.Size[i]>0)
|
||||
{
|
||||
if (GetMemory( Textures[i], tex.Size[i])) return -1;
|
||||
for (unsigned int j=0u; j<tex.Size[i]; j++) Textures[i][j] = tex.Textures[i][j];
|
||||
Size[i] = tex.Size[i];
|
||||
}
|
||||
Len = tex.Len;
|
||||
Num = tex.Num;
|
||||
}
|
||||
else
|
||||
{
|
||||
ReleaseMemory();
|
||||
Hash = tex.Hash;
|
||||
WasAdded = tex.WasAdded;
|
||||
Size = tex.Size;
|
||||
Textures = tex.Textures;
|
||||
Len = tex.Len;
|
||||
Num = tex.Num;
|
||||
OwnMemory = true;
|
||||
tex.OwnMemory = false;
|
||||
}
|
||||
Add = tex.Add;
|
||||
Force = tex.Force;
|
||||
Loaded = tex.Loaded;
|
||||
|
||||
File = tex.File;
|
||||
Comment = tex.Comment;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
This file is part of OpenTexMod.
|
||||
|
||||
|
||||
OpenTexMod 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.
|
||||
|
||||
OpenTexMod 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 OpenTexMod. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef OTM_ADDTEXTURE_H_
|
||||
#define OTM_ADDTEXTURE_H_
|
||||
|
||||
#include "OTM_Main.h"
|
||||
|
||||
class AddTextureClass
|
||||
{
|
||||
public:
|
||||
AddTextureClass(void);
|
||||
~AddTextureClass(void);
|
||||
int ReleaseMemory(void);
|
||||
|
||||
int SetSize(int num);
|
||||
int InheriteMemory(AddTextureClass &tex);
|
||||
|
||||
unsigned int Num;
|
||||
char **Textures;
|
||||
unsigned int *Size;
|
||||
unsigned long *Hash;
|
||||
bool *WasAdded;
|
||||
unsigned int Len;
|
||||
|
||||
bool Add;
|
||||
bool Force;
|
||||
bool Loaded;
|
||||
bool OwnMemory;
|
||||
wxString File;
|
||||
wxString Comment;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* OTM_ADDTEXTURE_H_ */
|
||||
+82
-115
@@ -1,53 +1,26 @@
|
||||
/*
|
||||
This file is part of OpenTexMod.
|
||||
|
||||
|
||||
#include "OTM_File.h"
|
||||
OpenTexMod 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.
|
||||
|
||||
OpenTexMod 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 OpenTexMod. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "OTM_Main.h"
|
||||
#include "unzip.h"
|
||||
|
||||
|
||||
AddTextureClass::AddTextureClass(void)
|
||||
{
|
||||
Num = 0;
|
||||
Textures = NULL;
|
||||
Size = NULL;
|
||||
Hash = NULL;
|
||||
Force = NULL;
|
||||
Add = NULL;
|
||||
Len=0;
|
||||
}
|
||||
|
||||
void AddTextureClass::SetSize(int num)
|
||||
{
|
||||
Num = 0;
|
||||
Force = new bool[num];
|
||||
Add = new bool[num];
|
||||
Size = new unsigned int[num];
|
||||
for (int i=0; i<num; i++) Size[i] = 0u;
|
||||
Hash = new unsigned long[num];
|
||||
Textures = new char*[num];
|
||||
for (int i=0; i<num; i++) Textures[i] = NULL;
|
||||
|
||||
Len = num;
|
||||
}
|
||||
|
||||
AddTextureClass::~AddTextureClass(void)
|
||||
{
|
||||
if (Force!=NULL) delete [] Force;
|
||||
if (Add!=NULL) delete [] Add;
|
||||
if (Size!=NULL) delete [] Size;
|
||||
if (Hash!=NULL) delete [] Hash;
|
||||
|
||||
if (Textures!=NULL)
|
||||
{
|
||||
for (unsigned int i=0; i<Num && i<Len; i++) if (Textures[i]!=NULL) delete [] Textures[i];
|
||||
delete [] Textures;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
OTM_File::OTM_File(OTM_Language &lang) : Language(lang)
|
||||
OTM_File::OTM_File(void)
|
||||
{
|
||||
Loaded=false;
|
||||
XORed=false;
|
||||
@@ -56,7 +29,7 @@ OTM_File::OTM_File(OTM_Language &lang) : Language(lang)
|
||||
FileLen=0u;
|
||||
}
|
||||
|
||||
OTM_File::OTM_File(OTM_Language &lang, const wxString &file) : Language(lang)
|
||||
OTM_File::OTM_File(const wxString &file)
|
||||
{
|
||||
Loaded=false;
|
||||
XORed=false;
|
||||
@@ -97,34 +70,38 @@ int OTM_File::GetComment( wxString &tool_tip)
|
||||
}
|
||||
else if (file_type == L"dds")
|
||||
{
|
||||
tool_tip = Language.NoComment;
|
||||
tool_tip = Language->NoComment;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OTM_File::GetContent( AddTextureClass *tex, bool add, bool force)
|
||||
int OTM_File::GetContent( AddTextureClass &tex, bool add)
|
||||
{
|
||||
wxString file_type = FileName.AfterLast( '.');
|
||||
if (file_type == L"zip")
|
||||
{
|
||||
AddZip( tex, add, force, false);
|
||||
AddZip( tex, add, false);
|
||||
}
|
||||
else if (file_type == L"tpf")
|
||||
{
|
||||
AddZip( tex, add, force, true);
|
||||
AddZip( tex, add, true);
|
||||
}
|
||||
else if (file_type == L"dds")
|
||||
{
|
||||
AddFile( tex, add, force);
|
||||
AddFile( tex, add);
|
||||
}
|
||||
else
|
||||
{
|
||||
LastError << Language.Error_FileNotSupported;
|
||||
LastError << Language->Error_FileNotSupported;
|
||||
LastError << "\n" << FileName;
|
||||
}
|
||||
if (LastError.Len()>0) return -1;
|
||||
else return 0;
|
||||
else
|
||||
{
|
||||
if (add) tex.Loaded = true;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int OTM_File::ReadFile(void)
|
||||
@@ -133,23 +110,23 @@ int OTM_File::ReadFile(void)
|
||||
XORed=false;
|
||||
|
||||
wxFile dat;
|
||||
if (!dat.Access(FileName, wxFile::read)) {LastError << Language.Error_FileOpen <<"\n" << FileName; return -1;}
|
||||
if (!dat.Access(FileName, wxFile::read)) {LastError << Language->Error_FileOpen <<"\n" << FileName; return -1;}
|
||||
dat.Open(FileName, wxFile::read);
|
||||
if (!dat.IsOpened()) {LastError << Language.Error_FileOpen <<"\n" << FileName; return -1;}
|
||||
if (!dat.IsOpened()) {LastError << Language->Error_FileOpen <<"\n" << FileName; return -1;}
|
||||
FileLen = dat.Length();
|
||||
if (FileLen==0) {LastError << Language.Error_FileOpen <<"\n" << FileName; return -1;}
|
||||
if (FileLen==0) {LastError << Language->Error_FileOpen <<"\n" << FileName; return -1;}
|
||||
|
||||
if (FileLen>=MemoryLength)
|
||||
{
|
||||
if (FileInMemory!=NULL) delete [] FileInMemory;
|
||||
try {FileInMemory = new char [FileLen+1];}
|
||||
catch (...) {FileInMemory=NULL; MemoryLength=0; FileLen=0; LastError << Language.Error_Memory; return -1;}
|
||||
catch (...) {FileInMemory=NULL; MemoryLength=0; FileLen=0; LastError << Language->Error_Memory; return -1;}
|
||||
MemoryLength = FileLen+1;
|
||||
}
|
||||
unsigned int result = dat.Read( FileInMemory, FileLen);
|
||||
dat.Close();
|
||||
|
||||
if (result != FileLen) {FileLen=0; LastError << Language.Error_FileRead<<"\n" << FileName; return -1;}
|
||||
if (result != FileLen) {FileLen=0; LastError << Language->Error_FileRead<<"\n" << FileName; return -1;}
|
||||
FileInMemory[FileLen]=0;
|
||||
|
||||
Loaded = true;
|
||||
@@ -206,7 +183,7 @@ int OTM_File::GetCommentZip( wxString &tool_tip)
|
||||
if (int ret = ReadFile()) return ret;
|
||||
|
||||
HZIP ZIP_Handle = OpenZip( FileInMemory, FileLen, NULL);
|
||||
if (ZIP_Handle==NULL) {tool_tip = Language.NoComment; LastError << Language.Error_Unzip; return -1;}
|
||||
if (ZIP_Handle==NULL) {tool_tip = Language->NoComment; LastError << Language->Error_Unzip; return -1;}
|
||||
|
||||
ZIPENTRY ze;
|
||||
int index;
|
||||
@@ -216,15 +193,15 @@ int OTM_File::GetCommentZip( wxString &tool_tip)
|
||||
char* comment;
|
||||
int len = ze.unc_size;
|
||||
try {comment=new char[len+1];}
|
||||
catch(...) {tool_tip = Language.NoComment; LastError << Language.Error_Memory; return -1;}
|
||||
catch(...) {tool_tip = Language->NoComment; LastError << Language->Error_Memory; return -1;}
|
||||
ZRESULT zr = UnzipItem( ZIP_Handle, index, comment, len);
|
||||
|
||||
if (zr!=ZR_OK && zr!=ZR_MORE) {delete [] comment; tool_tip = Language.NoComment; LastError << Language.Error_Unzip <<"\nZIP:" << L"Comment.txt"; return -1;}
|
||||
if (zr!=ZR_OK && zr!=ZR_MORE) {delete [] comment; tool_tip = Language->NoComment; LastError << Language->Error_Unzip <<"\nZIP:" << L"Comment.txt"; return -1;}
|
||||
comment[len]=0;
|
||||
tool_tip = comment;
|
||||
delete [] comment;
|
||||
}
|
||||
else tool_tip = Language.NoComment;
|
||||
else tool_tip = Language->NoComment;
|
||||
|
||||
CloseZip(ZIP_Handle);
|
||||
return 0;
|
||||
@@ -236,7 +213,7 @@ int OTM_File::GetCommentTpf( wxString &tool_tip)
|
||||
|
||||
UnXOR();
|
||||
tool_tip = &FileInMemory[FileLen];
|
||||
tool_tip.Prepend( Language.Author);
|
||||
tool_tip.Prepend( Language->Author);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -248,34 +225,32 @@ int OTM_File::GetCommentTpf( wxString &tool_tip)
|
||||
|
||||
|
||||
|
||||
int OTM_File::AddFile( AddTextureClass *tex, bool add, bool force)
|
||||
int OTM_File::AddFile( AddTextureClass &tex, bool add)
|
||||
{
|
||||
tex->SetSize(1);
|
||||
tex.SetSize(1);
|
||||
unsigned long temp_hash;
|
||||
|
||||
wxString name = FileName.AfterLast( '_');
|
||||
name = name.BeforeLast( '.');
|
||||
if (!name.ToULong( &temp_hash, 16)) {LastError << Language.Error_Hash <<"\n" << FileName << "\n"; return -1;} // return if hash could not be extracted
|
||||
if (!name.ToULong( &temp_hash, 16)) {LastError << Language->Error_Hash <<"\n" << FileName << "\n"; return -1;} // return if hash could not be extracted
|
||||
|
||||
if (add)
|
||||
{
|
||||
if (int ret = ReadFile()) return ret;
|
||||
|
||||
try {tex->Textures[0] = new char[FileLen];}
|
||||
catch (...) {tex->Textures[0]=NULL; LastError << Language.Error_Memory; return -1;}
|
||||
for (unsigned int i=0; i<FileLen; i++) tex->Textures[0][i] = FileInMemory[i];
|
||||
tex->Size[0] = FileLen;
|
||||
try {tex.Textures[0] = new char[FileLen];}
|
||||
catch (...) {tex.Textures[0]=NULL; LastError << Language->Error_Memory; return -1;}
|
||||
for (unsigned int i=0; i<FileLen; i++) tex.Textures[0][i] = FileInMemory[i];
|
||||
tex.Size[0] = FileLen;
|
||||
}
|
||||
else {tex->Size[0] = 0; tex->Textures[0] = NULL;}
|
||||
else {tex.Size[0] = 0; tex.Textures[0] = NULL;}
|
||||
|
||||
tex->Num = 1;
|
||||
tex->Add[0] = add;
|
||||
tex->Force[0] = force;
|
||||
tex->Hash[0] = temp_hash;
|
||||
tex.Num = 1;
|
||||
tex.Hash[0] = temp_hash;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OTM_File::AddZip( AddTextureClass *tex, bool add, bool force, bool tpf)
|
||||
int OTM_File::AddZip( AddTextureClass &tex, bool add, bool tpf)
|
||||
{
|
||||
if (int ret = ReadFile()) return ret;
|
||||
|
||||
@@ -290,16 +265,16 @@ int OTM_File::AddZip( AddTextureClass *tex, bool add, bool force, bool tpf)
|
||||
0x77, 0x6E, 0x46, 0x47, 0x77, 0x49, 0x0C, 0x4B,
|
||||
0x46, 0x6F, '\0'};
|
||||
|
||||
return AddContent( pw, tex, add, force);
|
||||
return AddContent( pw, tex, add);
|
||||
}
|
||||
else
|
||||
{
|
||||
return AddContent( NULL, tex, add, force);
|
||||
return AddContent( NULL, tex, add);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int OTM_File::AddContent( const char* pw, AddTextureClass *tex, bool add, bool force)
|
||||
int OTM_File::AddContent( const char* pw, AddTextureClass &tex, bool add)
|
||||
{
|
||||
// Thats is really nasty code, but atm I am happy that it works. I should try an other unzip api,
|
||||
// This one seems to behave very strange.
|
||||
@@ -313,7 +288,7 @@ int OTM_File::AddContent( const char* pw, AddTextureClass *tex, bool add, bool f
|
||||
//
|
||||
|
||||
HZIP ZIP_Handle = OpenZip( FileInMemory, FileLen, pw);
|
||||
if (ZIP_Handle==NULL) {LastError << Language.Error_Unzip; return -1;}
|
||||
if (ZIP_Handle==NULL) {LastError << Language->Error_Unzip; return -1;}
|
||||
|
||||
ZIPENTRY ze;
|
||||
int index;
|
||||
@@ -323,7 +298,7 @@ int OTM_File::AddContent( const char* pw, AddTextureClass *tex, bool add, bool f
|
||||
char* def;
|
||||
int len = ze.unc_size;
|
||||
try {def=new char[len+1];}
|
||||
catch(...) {LastError << Language.Error_Memory; return -1;}
|
||||
catch(...) {LastError << Language->Error_Memory; return -1;}
|
||||
ZRESULT zr = UnzipItem( ZIP_Handle, index, def, len);
|
||||
|
||||
if (zr!=ZR_OK && zr!=ZR_MORE) {delete [] def; return -1;}
|
||||
@@ -334,7 +309,7 @@ int OTM_File::AddContent( const char* pw, AddTextureClass *tex, bool add, bool f
|
||||
int num = token.CountTokens();
|
||||
|
||||
|
||||
tex->SetSize(num);
|
||||
tex.SetSize(num);
|
||||
|
||||
unsigned long temp_hash;
|
||||
int count = 0;
|
||||
@@ -345,7 +320,7 @@ int OTM_File::AddContent( const char* pw, AddTextureClass *tex, bool add, bool f
|
||||
{
|
||||
entry = token.GetNextToken();
|
||||
file = entry.BeforeFirst( '|');
|
||||
if (!file.ToULong( &temp_hash, 16)) {LastError << Language.Error_Hash <<"\nTPF:" << entry << "\n"; continue;}
|
||||
if (!file.ToULong( &temp_hash, 16)) {LastError << Language->Error_Hash <<"\nTPF:" << entry << "\n"; continue;}
|
||||
|
||||
file = entry.AfterFirst( '|');
|
||||
file.Replace( "\r", "");
|
||||
@@ -357,60 +332,56 @@ int OTM_File::AddContent( const char* pw, AddTextureClass *tex, bool add, bool f
|
||||
FindZipItem( ZIP_Handle, file.wc_str(), false, &index, &ze); // look for texture
|
||||
if (index>=0)
|
||||
{
|
||||
try {tex->Textures[count] = new char[ze.unc_size];}
|
||||
try {tex.Textures[count] = new char[ze.unc_size];}
|
||||
catch(...)
|
||||
{
|
||||
tex->Textures[count] = NULL;
|
||||
LastError << Language.Error_Memory;
|
||||
tex.Textures[count] = NULL;
|
||||
LastError << Language->Error_Memory;
|
||||
continue;
|
||||
}
|
||||
|
||||
ZRESULT rz = UnzipItem( ZIP_Handle, index, tex->Textures[count], ze.unc_size);
|
||||
ZRESULT rz = UnzipItem( ZIP_Handle, index, tex.Textures[count], ze.unc_size);
|
||||
if (rz!=ZR_OK && rz!=ZR_MORE)
|
||||
{
|
||||
delete [] tex->Textures[count];
|
||||
LastError << Language.Error_Unzip <<"\nTPF:" << file << "\n";
|
||||
tex->Textures[count] = NULL;
|
||||
delete [] tex.Textures[count];
|
||||
LastError << Language->Error_Unzip <<"\nTPF:" << file << "\n";
|
||||
tex.Textures[count] = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
tex->Hash[count] = temp_hash;
|
||||
tex->Add[count] = true;
|
||||
tex->Size[count] = ze.unc_size;
|
||||
tex->Force[count] = force;
|
||||
tex.Hash[count] = temp_hash;
|
||||
tex.Size[count] = ze.unc_size;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LastError << Language.Error_Unzip <<"\nTPF:" << file << "\n";
|
||||
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
|
||||
{
|
||||
tex->Hash[count] = temp_hash;
|
||||
tex->Add[count] = false;
|
||||
tex->Size[count] = 0;
|
||||
tex->Force[count] = force;
|
||||
tex.Hash[count] = temp_hash;
|
||||
tex.Size[count] = 0;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
delete [] def;
|
||||
tex->Num = count;
|
||||
tex.Num = count;
|
||||
}
|
||||
else // texmod.def is not present in the zip file
|
||||
{
|
||||
CloseZip(ZIP_Handle); //somehow we need to close and to reopen the zip handle, otherwise the program crashes
|
||||
ZIP_Handle = OpenZip( FileInMemory, FileLen, pw);
|
||||
if (ZIP_Handle==NULL) {LastError << Language.Error_Unzip; return -1;}
|
||||
if (ZIP_Handle==NULL) {LastError << Language->Error_Unzip; return -1;}
|
||||
wxString name;
|
||||
wxString file;
|
||||
GetZipItem( ZIP_Handle, -1, &ze); //ask for number of entries
|
||||
int num = ze.index;
|
||||
|
||||
tex->SetSize(num);
|
||||
tex.SetSize(num);
|
||||
int count = 0;
|
||||
unsigned long temp_hash;
|
||||
for (int i=0; i<num; i++)
|
||||
@@ -431,7 +402,7 @@ int OTM_File::AddContent( const char* pw, AddTextureClass *tex, bool add, bool f
|
||||
{
|
||||
delete [] buffer;
|
||||
buffer = NULL;
|
||||
LastError << Language.Error_Unzip <<"\nZIP:" << file << "\n";
|
||||
LastError << Language->Error_Unzip <<"\nZIP:" << file << "\n";
|
||||
}
|
||||
|
||||
file = ze.name;
|
||||
@@ -443,30 +414,26 @@ int OTM_File::AddContent( const char* pw, AddTextureClass *tex, bool add, bool f
|
||||
name = file.AfterLast( '_');
|
||||
name = name.BeforeLast( '.');
|
||||
|
||||
if (!name.ToULong( &temp_hash, 16)) {LastError << Language.Error_Hash <<"\nZIP:" << file << "\n"; continue;} //if hash could not be extracted
|
||||
if (!name.ToULong( &temp_hash, 16)) {LastError << Language->Error_Hash <<"\nZIP:" << file << "\n"; continue;} //if hash could not be extracted
|
||||
|
||||
if (add)
|
||||
{
|
||||
if (buffer==NULL) continue;
|
||||
|
||||
tex->Textures[count] = buffer;
|
||||
tex->Hash[count] = temp_hash;
|
||||
tex->Add[count] = true;
|
||||
tex->Size[count] = len;//ze.unc_size;
|
||||
tex->Force[count] = force;
|
||||
tex.Textures[count] = buffer;
|
||||
tex.Hash[count] = temp_hash;
|
||||
tex.Size[count] = len;//ze.unc_size;
|
||||
count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (buffer!=NULL) delete [] buffer;
|
||||
tex->Hash[count] = temp_hash;
|
||||
tex->Add[count] = false;
|
||||
tex->Size[count] = 0;
|
||||
tex->Force[count] = force;
|
||||
tex.Hash[count] = temp_hash;
|
||||
tex.Size[count] = 0;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
tex->Num = count;
|
||||
tex.Num = count;
|
||||
}
|
||||
|
||||
CloseZip(ZIP_Handle);
|
||||
|
||||
+24
-26
@@ -1,38 +1,37 @@
|
||||
/*
|
||||
This file is part of OpenTexMod.
|
||||
|
||||
|
||||
OpenTexMod 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.
|
||||
|
||||
OpenTexMod 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 OpenTexMod. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef OTM_FILE_H_
|
||||
#define OTM_FILE_H_
|
||||
|
||||
|
||||
class AddTextureClass
|
||||
{
|
||||
public:
|
||||
AddTextureClass(void);
|
||||
void SetSize(int num);
|
||||
~AddTextureClass(void);
|
||||
|
||||
unsigned int Num;
|
||||
char **Textures;
|
||||
unsigned int *Size;
|
||||
unsigned long *Hash;
|
||||
bool *Add;
|
||||
bool *Force;
|
||||
|
||||
unsigned int Len;
|
||||
};
|
||||
#include "OTM_Main.h"
|
||||
#include "unzip.h"
|
||||
|
||||
|
||||
class OTM_File
|
||||
{
|
||||
public:
|
||||
OTM_File(OTM_Language &lang);
|
||||
OTM_File(OTM_Language &lang, const wxString &file);
|
||||
OTM_File(void);
|
||||
OTM_File(const wxString &file);
|
||||
~OTM_File(void);
|
||||
|
||||
bool FileSupported(void);
|
||||
|
||||
int GetComment( wxString &tool_tip);
|
||||
int GetContent( AddTextureClass *tex, bool add, bool force);
|
||||
int GetContent( AddTextureClass &tex, bool add);
|
||||
|
||||
int SetFile(const wxString &file) {FileName=file;Loaded=false; return 0;}
|
||||
wxString GetFile(void) {return FileName;}
|
||||
@@ -47,11 +46,10 @@ private:
|
||||
int GetCommentZip( wxString &tool_tip);
|
||||
int GetCommentTpf( wxString &tool_tip);
|
||||
|
||||
int AddFile( AddTextureClass *tex, bool add, bool force);
|
||||
int AddZip( AddTextureClass *tex, bool add, bool force, bool tpf);
|
||||
int AddContent( const char* pw, AddTextureClass *tex, bool add, bool force);
|
||||
int AddFile( AddTextureClass &tex, bool add);
|
||||
int AddZip( AddTextureClass &tex, bool add, bool tpf);
|
||||
int AddContent( const char* pw, AddTextureClass &tex, bool add);
|
||||
|
||||
OTM_Language &Language;
|
||||
wxString FileName;
|
||||
bool Loaded;
|
||||
bool XORed;
|
||||
|
||||
+297
-64
@@ -36,14 +36,24 @@ BEGIN_EVENT_TABLE(OTM_Frame, wxFrame)
|
||||
EVT_BUTTON(ID_Button_Open, OTM_Frame::OnButtonOpen)
|
||||
EVT_BUTTON(ID_Button_Path, OTM_Frame::OnButtonPath)
|
||||
EVT_BUTTON(ID_Button_Update, OTM_Frame::OnButtonUpdate)
|
||||
EVT_BUTTON(ID_Button_Save, OTM_Frame::OnButtonSave)
|
||||
EVT_BUTTON(ID_Button_Reload, OTM_Frame::OnButtonReload)
|
||||
|
||||
EVT_MENU(ID_Menu_Lang, OTM_Frame::OnMenuLanguage)
|
||||
EVT_MENU(ID_Menu_Help, OTM_Frame::OnMenuHelp)
|
||||
EVT_MENU(ID_Menu_About, OTM_Frame::OnMenuAbout)
|
||||
EVT_MENU(ID_Menu_Acknowledgement, OTM_Frame::OnMenuAcknowledgement)
|
||||
|
||||
|
||||
EVT_MENU(ID_Menu_AddGame, OTM_Frame::OnMenuAddGame)
|
||||
EVT_MENU(ID_Menu_DeleteGame, OTM_Frame::OnMenuDeleteGame)
|
||||
|
||||
EVT_MENU(ID_Menu_LoadTemplate, OTM_Frame::OnMenuOpenTemplate)
|
||||
EVT_MENU(ID_Menu_SaveTemplate, OTM_Frame::OnMenuSaveTemplate)
|
||||
EVT_MENU(ID_Menu_SaveTemplateAs, OTM_Frame::OnMenuSaveTemplateAs)
|
||||
EVT_MENU(ID_Menu_SetDefaultTemplate, OTM_Frame::OnMenuSetDefaultTemplate)
|
||||
|
||||
EVT_MENU(ID_Menu_Lang, OTM_Frame::OnMenuLanguage)
|
||||
EVT_MENU(ID_Menu_Exit, OTM_Frame::OnMenuExit)
|
||||
|
||||
EVT_COMMAND (ID_Add_Game, OTM_EVENT_TYPE, OTM_Frame::OnAddGame)
|
||||
EVT_COMMAND (ID_Delete_Game, OTM_EVENT_TYPE, OTM_Frame::OnDeleteGame)
|
||||
END_EVENT_TABLE()
|
||||
@@ -56,15 +66,20 @@ MyApp::~MyApp(void)
|
||||
if (CheckForSingleRun!=NULL) CloseHandle( CheckForSingleRun);
|
||||
}
|
||||
|
||||
|
||||
bool MyApp::OnInit(void)
|
||||
{
|
||||
OTM_Settings set;
|
||||
set.Load();
|
||||
|
||||
Language = new OTM_Language(set.Language);
|
||||
CheckForSingleRun = CreateMutex( NULL, true, L"Global\\OTM_CheckForSingleRun");
|
||||
if (ERROR_ALREADY_EXISTS == GetLastError())
|
||||
{
|
||||
wxMessageBox( L"An instance of OpenTexMod already exists.", "ERROR", wxOK|wxICON_ERROR);
|
||||
wxMessageBox( Language->Error_AlreadyRunning, "ERROR", wxOK|wxICON_ERROR);
|
||||
return false;
|
||||
}
|
||||
OTM_Frame *frame = new OTM_Frame( OTM_VERSION, wxDefaultPosition, wxSize(600,400));
|
||||
OTM_Frame *frame = new OTM_Frame( OTM_VERSION, wxDefaultPosition, wxSize(set.XSize,set.YSize));
|
||||
SetTopWindow( frame );
|
||||
|
||||
return true;
|
||||
@@ -82,19 +97,27 @@ OTM_Frame::OTM_Frame(const wxString& title, const wxPoint& pos, const wxSize& si
|
||||
|
||||
MenuBar = new wxMenuBar;
|
||||
//MenuMain = new wxMenu;
|
||||
MenuGame = new wxMenu;
|
||||
MenuMain = new wxMenu;
|
||||
MenuHelp = new wxMenu;
|
||||
|
||||
|
||||
MenuGame->Append( ID_Menu_AddGame, Language.MenuAddGame );
|
||||
MenuGame->Append( ID_Menu_DeleteGame, Language.MenuDeleteGame );
|
||||
MenuMain->Append( ID_Menu_AddGame, Language->MenuAddGame );
|
||||
MenuMain->Append( ID_Menu_DeleteGame, Language->MenuDeleteGame );
|
||||
MenuMain->AppendSeparator();
|
||||
MenuMain->Append( ID_Menu_LoadTemplate, Language->MenuLoadTemplate );
|
||||
MenuMain->Append( ID_Menu_SaveTemplate, Language->MenuSaveTemplate );
|
||||
MenuMain->Append( ID_Menu_SaveTemplateAs, Language->MenuSaveTemplateAs );
|
||||
MenuMain->Append( ID_Menu_SetDefaultTemplate, Language->MenuSetDefaultTemplate );
|
||||
MenuMain->AppendSeparator();
|
||||
MenuMain->Append( ID_Menu_Lang, Language->MenuLanguage );
|
||||
MenuMain->Append( ID_Menu_Exit, Language->MenuExit );
|
||||
|
||||
MenuHelp->Append( ID_Menu_Lang, Language.MenuLanguage );
|
||||
MenuHelp->Append( ID_Menu_Help, Language.MenuHelp );
|
||||
MenuHelp->Append( ID_Menu_About, Language.MenuAbout );
|
||||
MenuHelp->Append( ID_Menu_Help, Language->MenuHelp );
|
||||
MenuHelp->Append( ID_Menu_About, Language->MenuAbout );
|
||||
MenuHelp->Append( ID_Menu_Acknowledgement, Language->MenuAcknowledgement );
|
||||
|
||||
MenuBar->Append( MenuGame, Language.MainMenuGame );
|
||||
MenuBar->Append( MenuHelp, Language.MainMenuHelp );
|
||||
MenuBar->Append( MenuMain, Language->MainMenuMain );
|
||||
MenuBar->Append( MenuHelp, Language->MainMenuHelp );
|
||||
|
||||
SetMenuBar(MenuBar);
|
||||
|
||||
@@ -102,19 +125,20 @@ OTM_Frame::OTM_Frame(const wxString& title, const wxPoint& pos, const wxSize& si
|
||||
MainSizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
Notebook = new wxNotebook( this, wxID_ANY);
|
||||
Notebook->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENU));
|
||||
MainSizer->Add( (wxWindow*) Notebook, 1, wxEXPAND , 0 );
|
||||
|
||||
ButtonSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
OpenButton = new wxButton( this, ID_Button_Open, Language.ButtonOpen, wxDefaultPosition, wxSize(100,24));
|
||||
DirectoryButton = new wxButton( this, ID_Button_Path, Language.ButtonDirectory, wxDefaultPosition, wxSize(100,24));
|
||||
UpdateButton = new wxButton( this, ID_Button_Update, Language.ButtonUpdate, wxDefaultPosition, wxSize(100,24));
|
||||
SaveButton = new wxButton( this, ID_Button_Save, Language.ButtonSave, wxDefaultPosition, wxSize(100,24));
|
||||
OpenButton = new wxButton( this, ID_Button_Open, Language->ButtonOpen, wxDefaultPosition, wxSize(100,24));
|
||||
DirectoryButton = new wxButton( this, ID_Button_Path, Language->ButtonDirectory, wxDefaultPosition, wxSize(100,24));
|
||||
UpdateButton = new wxButton( this, ID_Button_Update, Language->ButtonUpdate, wxDefaultPosition, wxSize(100,24));
|
||||
ReloadButton = new wxButton( this, ID_Button_Reload, Language->ButtonReload, wxDefaultPosition, wxSize(100,24));
|
||||
|
||||
ButtonSizer->Add( (wxWindow*) OpenButton, 1, wxEXPAND, 0);
|
||||
ButtonSizer->Add( (wxWindow*) DirectoryButton, 1, wxEXPAND, 0);
|
||||
ButtonSizer->Add( (wxWindow*) UpdateButton, 1, wxEXPAND, 0);
|
||||
ButtonSizer->Add( (wxWindow*) SaveButton, 1, wxEXPAND, 0);
|
||||
ButtonSizer->Add( (wxWindow*) ReloadButton, 1, wxEXPAND, 0);
|
||||
MainSizer->Add( ButtonSizer, 0, wxEXPAND , 0 );
|
||||
|
||||
|
||||
@@ -125,8 +149,9 @@ OTM_Frame::OTM_Frame(const wxString& title, const wxPoint& pos, const wxSize& si
|
||||
Clients = NULL;
|
||||
if (GetMemory( Clients, MaxNumberOfGames))
|
||||
{
|
||||
wxMessageBox( Language.Error_Memory, "ERROR", wxOK|wxICON_ERROR);
|
||||
wxMessageBox( Language->Error_Memory, "ERROR", wxOK|wxICON_ERROR);
|
||||
}
|
||||
LoadTemplate();
|
||||
|
||||
Show( true );
|
||||
|
||||
@@ -142,7 +167,7 @@ OTM_Frame::OTM_Frame(const wxString& title, const wxPoint& pos, const wxSize& si
|
||||
wchar_t *error_msg;
|
||||
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &error_msg, 0, NULL );
|
||||
wxString temp = Language.Error_DLLNotFound;
|
||||
wxString temp = Language->Error_DLLNotFound;
|
||||
temp << "\n" << OTM_d3d9_dll;
|
||||
temp << "\n" << error_msg << "Code: " << error;
|
||||
wxMessageBox( temp, "ERROR", wxOK);
|
||||
@@ -154,7 +179,7 @@ OTM_Frame::OTM_Frame(const wxString& title, const wxPoint& pos, const wxSize& si
|
||||
wchar_t *error_msg;
|
||||
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &error_msg, 0, NULL );
|
||||
wxString temp = Language.Error_DLLNotFound;
|
||||
wxString temp = Language->Error_DLLNotFound;
|
||||
temp << "\n" << OTM_d3d9_dll;
|
||||
temp << "\n" << error_msg << "Code: " << error;
|
||||
wxMessageBox(temp, "ERROR", wxOK|wxICON_ERROR);
|
||||
@@ -180,6 +205,11 @@ OTM_Frame::~OTM_Frame(void)
|
||||
}
|
||||
|
||||
if (Clients!=NULL) delete [] Clients;
|
||||
|
||||
OTM_Settings set;
|
||||
set.Language = Language->GetCurrentLanguage();
|
||||
GetSize( &set.XSize, &set.YSize);
|
||||
set.Save();
|
||||
}
|
||||
|
||||
int OTM_Frame::KillServer(void)
|
||||
@@ -212,7 +242,7 @@ void OTM_Frame::OnAddGame( wxCommandEvent &event)
|
||||
{
|
||||
if (GetMoreMemory( Clients, MaxNumberOfGames, MaxNumberOfGames+10))
|
||||
{
|
||||
wxMessageBox( Language.Error_Memory, "ERROR", wxOK|wxICON_ERROR);
|
||||
wxMessageBox( Language->Error_Memory, "ERROR", wxOK|wxICON_ERROR);
|
||||
return;
|
||||
}
|
||||
MaxNumberOfGames += 10;
|
||||
@@ -228,13 +258,24 @@ void OTM_Frame::OnAddGame( wxCommandEvent &event)
|
||||
client->Create();
|
||||
client->Run();
|
||||
|
||||
OTM_GamePage *page = new OTM_GamePage( Notebook, name, client->Pipe, Language);
|
||||
wxString save_file;
|
||||
int num = SaveFile_Exe.GetCount();
|
||||
for (int i=0; i<num; i++) if (name==SaveFile_Exe[i])
|
||||
{
|
||||
save_file = SaveFile_Name[i];
|
||||
break;
|
||||
}
|
||||
|
||||
OTM_GamePage *page = new OTM_GamePage( Notebook, name, save_file, client->Pipe);
|
||||
if (page->LastError.Len()>0)
|
||||
{
|
||||
wxMessageBox(page->LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
delete page;
|
||||
return;
|
||||
}
|
||||
name = name.AfterLast('\\');
|
||||
name = name.AfterLast('/');
|
||||
name = name.BeforeLast('.');
|
||||
Notebook->AddPage( page, name, true);
|
||||
|
||||
Clients[NumberOfGames] = client;
|
||||
@@ -260,7 +301,7 @@ void OTM_Frame::OnClose(wxCloseEvent& event)
|
||||
{
|
||||
if (event.CanVeto() && NumberOfGames>0)
|
||||
{
|
||||
if (wxMessageBox(Language.ExitGameAnyway, "ERROR", wxYES_NO|wxICON_ERROR)!=wxYES) {event.Veto(); return;}
|
||||
if (wxMessageBox(Language->ExitGameAnyway, "ERROR", wxYES_NO|wxICON_ERROR)!=wxYES) {event.Veto(); return;}
|
||||
}
|
||||
event.Skip();
|
||||
Destroy();
|
||||
@@ -273,8 +314,8 @@ void OTM_Frame::OnButtonOpen(wxCommandEvent& WXUNUSED(event))
|
||||
if (page==NULL) return;
|
||||
|
||||
|
||||
//wxString file_name = wxFileSelector( Language.ChooseFile, page->GetOpenPath(), "", "*.*", "textures (*.dds)|*.dds|zip (*.zip)|*.zip|tpf (*.tpf)|*.tpf", wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
||||
wxString file_name = wxFileSelector( Language.ChooseFile, page->GetOpenPath(), "", "", "", wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
||||
//wxString file_name = wxFileSelector( Language->ChooseFile, page->GetOpenPath(), "", "*.*", "textures (*.dds)|*.dds|zip (*.zip)|*.zip|tpf (*.tpf)|*.tpf", wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
||||
wxString file_name = wxFileSelector( Language->ChooseFile, page->GetOpenPath(), "", "", "", wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
||||
if ( !file_name.empty() )
|
||||
{
|
||||
page->SetOpenPath(file_name.BeforeLast( '/'));
|
||||
@@ -292,7 +333,7 @@ void OTM_Frame::OnButtonPath(wxCommandEvent& WXUNUSED(event))
|
||||
OTM_GamePage *page = (OTM_GamePage*) Notebook->GetCurrentPage();
|
||||
if (page==NULL) return;
|
||||
|
||||
wxString dir = wxDirSelector( Language.ChooseDir, page->GetSavePath());
|
||||
wxString dir = wxDirSelector( Language->ChooseDir, page->GetSavePath());
|
||||
if ( !dir.empty() )
|
||||
{
|
||||
page->SetSavePath( dir);
|
||||
@@ -311,44 +352,148 @@ void OTM_Frame::OnButtonUpdate(wxCommandEvent& WXUNUSED(event))
|
||||
}
|
||||
}
|
||||
|
||||
void OTM_Frame::OnButtonSave(wxCommandEvent& WXUNUSED(event))
|
||||
void OTM_Frame::OnButtonReload(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if (Notebook->GetPageCount()==0) return;
|
||||
OTM_GamePage *page = (OTM_GamePage*) Notebook->GetCurrentPage();
|
||||
if (page==NULL) return;
|
||||
if (page->SaveToFile())
|
||||
if (page->ReloadGame())
|
||||
{
|
||||
wxMessageBox(page->LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
page->LastError.Empty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void OTM_Frame::OnMenuOpenTemplate(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if (Notebook->GetPageCount()==0) return;
|
||||
OTM_GamePage *page = (OTM_GamePage*) Notebook->GetCurrentPage();
|
||||
if (page==NULL) return;
|
||||
|
||||
|
||||
//wxString file_name = wxFileSelector( Language->ChooseFile, page->GetOpenPath(), "", "*.*", "textures (*.dds)|*.dds|zip (*.zip)|*.zip|tpf (*.tpf)|*.tpf", wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
||||
wxString file_name = wxFileSelector( Language->ChooseFile, wxGetCwd(), "", "", "", wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
||||
if ( !file_name.empty() )
|
||||
{
|
||||
if (page->LoadTemplate( file_name))
|
||||
{
|
||||
wxMessageBox(page->LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
page->LastError.Empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OTM_Frame::OnMenuSaveTemplate(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if (Notebook->GetPageCount()==0) return;
|
||||
OTM_GamePage *page = (OTM_GamePage*) Notebook->GetCurrentPage();
|
||||
if (page==NULL) return;
|
||||
|
||||
wxString file_name = page->GetTemplateName();
|
||||
|
||||
if ( file_name.empty() )
|
||||
{
|
||||
wxString dir = wxGetCwd();
|
||||
dir << "/templates";
|
||||
file_name = wxFileSelector( Language->ChooseFile, dir, "", "*.txt", "text (*.txt)|*.txt", wxFD_SAVE | wxFD_OVERWRITE_PROMPT, this);
|
||||
}
|
||||
if ( !file_name.empty() )
|
||||
{
|
||||
if (page->SaveTemplate(file_name))
|
||||
{
|
||||
wxMessageBox(page->LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
page->LastError.Empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OTM_Frame::OnMenuSaveTemplateAs(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if (Notebook->GetPageCount()==0) return;
|
||||
OTM_GamePage *page = (OTM_GamePage*) Notebook->GetCurrentPage();
|
||||
if (page==NULL) return;
|
||||
|
||||
|
||||
wxString dir = wxGetCwd();
|
||||
dir << "/templates";
|
||||
wxString file_name = wxFileSelector( Language->ChooseFile, dir, "", "*.txt", "text (*.txt)|*.txt", wxFD_SAVE | wxFD_OVERWRITE_PROMPT, this);
|
||||
if ( !file_name.empty() )
|
||||
{
|
||||
if (page->SaveTemplate(file_name))
|
||||
{
|
||||
wxMessageBox(page->LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
page->LastError.Empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OTM_Frame::OnMenuSetDefaultTemplate(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if (Notebook->GetPageCount()==0) return;
|
||||
OTM_GamePage *page = (OTM_GamePage*) Notebook->GetCurrentPage();
|
||||
if (page==NULL) return;
|
||||
|
||||
wxString exe = page->GetExeName();
|
||||
wxString file = page->GetTemplateName();
|
||||
|
||||
int num = SaveFile_Exe.GetCount();
|
||||
bool hit = false;
|
||||
for (int i=0; i<num; i++) if (SaveFile_Exe[i]==exe)
|
||||
{
|
||||
SaveFile_Name[i] = file;
|
||||
hit = true;
|
||||
break;
|
||||
}
|
||||
if (!hit)
|
||||
{
|
||||
SaveFile_Exe.Add(exe);
|
||||
SaveFile_Name.Add(file);
|
||||
}
|
||||
if (SaveTemplate())
|
||||
{
|
||||
wxMessageBox(LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
LastError.Empty();
|
||||
}
|
||||
}
|
||||
|
||||
void OTM_Frame::OnMenuLanguage(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxArrayString lang;
|
||||
Language.GetLanguages( lang);
|
||||
wxString choice = wxGetSingleChoice( Language.SelectLanguage, Language.SelectLanguage, lang);
|
||||
Language->GetLanguages( lang);
|
||||
wxString choice = wxGetSingleChoice( Language->SelectLanguage, Language->SelectLanguage, lang);
|
||||
if (choice.Len()>0)
|
||||
{
|
||||
if (Language.LoadLanguage(choice))
|
||||
if (Language->LoadLanguage(choice))
|
||||
{
|
||||
wxMessageBox(Language.LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
Language.LastError.Empty();
|
||||
wxMessageBox(Language->LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
Language->LastError.Empty();
|
||||
return;
|
||||
}
|
||||
MenuBar->SetMenuLabel( 0, Language.MainMenuGame);
|
||||
MenuGame->SetLabel( ID_Menu_AddGame, Language.MenuAddGame);
|
||||
MenuGame->SetLabel( ID_Menu_DeleteGame, Language.MenuDeleteGame);
|
||||
MenuBar->SetMenuLabel( 0, Language->MainMenuMain);
|
||||
MenuMain->SetLabel( ID_Menu_AddGame, Language->MenuAddGame);
|
||||
MenuMain->SetLabel( ID_Menu_DeleteGame, Language->MenuDeleteGame);
|
||||
|
||||
MenuBar->SetMenuLabel( 1, Language.MainMenuHelp);
|
||||
MenuHelp->SetLabel( ID_Menu_Lang, Language.MenuLanguage);
|
||||
MenuHelp->SetLabel( ID_Menu_Help, Language.MenuHelp);
|
||||
MenuHelp->SetLabel( ID_Menu_About, Language.MenuAbout);
|
||||
MenuMain->SetLabel( ID_Menu_LoadTemplate, Language->MenuLoadTemplate );
|
||||
MenuMain->SetLabel( ID_Menu_SaveTemplate, Language->MenuSaveTemplate );
|
||||
MenuMain->SetLabel( ID_Menu_SaveTemplateAs, Language->MenuSaveTemplateAs );
|
||||
MenuMain->SetLabel( ID_Menu_SetDefaultTemplate, Language->MenuSetDefaultTemplate );
|
||||
|
||||
OpenButton->SetLabel( Language.ButtonOpen);
|
||||
DirectoryButton->SetLabel( Language.ButtonDirectory);
|
||||
UpdateButton->SetLabel( Language.ButtonUpdate);
|
||||
SaveButton->SetLabel( Language.ButtonSave);
|
||||
MenuMain->SetLabel( ID_Menu_Lang, Language->MenuLanguage);
|
||||
MenuMain->SetLabel( ID_Menu_Exit, Language->MenuExit );
|
||||
|
||||
MenuBar->SetMenuLabel( 1, Language->MainMenuHelp);
|
||||
MenuHelp->SetLabel( ID_Menu_Help, Language->MenuHelp);
|
||||
MenuHelp->SetLabel( ID_Menu_About, Language->MenuAbout);
|
||||
MenuHelp->SetLabel( ID_Menu_Acknowledgement, Language->MenuAcknowledgement);
|
||||
|
||||
|
||||
OpenButton->SetLabel( Language->ButtonOpen);
|
||||
DirectoryButton->SetLabel( Language->ButtonDirectory);
|
||||
UpdateButton->SetLabel( Language->ButtonUpdate);
|
||||
ReloadButton->SetLabel( Language->ButtonReload);
|
||||
|
||||
int num = Notebook->GetPageCount();
|
||||
for (int i=0; i<num; i++)
|
||||
@@ -359,17 +504,22 @@ void OTM_Frame::OnMenuLanguage(wxCommandEvent& WXUNUSED(event))
|
||||
}
|
||||
}
|
||||
|
||||
void OTM_Frame::OnMenuExit(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
void OTM_Frame::OnMenuHelp(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxString help;
|
||||
if (Language.GetHelpMessage( help))
|
||||
if (Language->GetHelpMessage( help))
|
||||
{
|
||||
wxMessageBox(Language.LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
Language.LastError.Empty();
|
||||
wxMessageBox(Language->LastError, "ERROR", wxOK|wxICON_ERROR);
|
||||
Language->LastError.Empty();
|
||||
return;
|
||||
}
|
||||
|
||||
wxMessageBox( help, Language.MenuHelp, wxOK);
|
||||
wxMessageBox( help, Language->MenuHelp, wxOK);
|
||||
}
|
||||
|
||||
void OTM_Frame::OnMenuAbout(wxCommandEvent& WXUNUSED(event))
|
||||
@@ -377,14 +527,24 @@ void OTM_Frame::OnMenuAbout(wxCommandEvent& WXUNUSED(event))
|
||||
wxString msg;
|
||||
msg << OTM_VERSION << " by ROTA\nhttp://code.google.com/p/texmod/";
|
||||
wxMessageBox( msg, "Info", wxOK);
|
||||
};
|
||||
}
|
||||
|
||||
void OTM_Frame::OnMenuAcknowledgement(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxString title;
|
||||
title << OTM_VERSION << " by ROTA";
|
||||
wxString msg;
|
||||
msg << "EvilAlex for translation into Russian and bug fixing";
|
||||
wxMessageBox( msg, title, wxOK);
|
||||
}
|
||||
|
||||
|
||||
void OTM_Frame::OnMenuAddGame(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxString file_name = wxFileSelector( Language.ChooseGame, "", "", "exe", "binary (*.exe)|*.exe", wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
||||
wxString file_name = wxFileSelector( Language->ChooseGame, "", "", "exe", "binary (*.exe)|*.exe", wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
||||
if ( !file_name.empty() )
|
||||
{
|
||||
file_name = file_name.AfterLast('\\');
|
||||
//file_name = file_name.AfterLast('\\');
|
||||
|
||||
wxArrayString array;
|
||||
if (GetHookedGames( array)) array.Empty();
|
||||
@@ -392,7 +552,7 @@ void OTM_Frame::OnMenuAddGame(wxCommandEvent& WXUNUSED(event))
|
||||
int num = array.GetCount();
|
||||
for (int i=0; i<num; i++) if (array[i] == file_name)
|
||||
{
|
||||
wxMessageBox(Language.GameAlreadyAdded, "ERROR", wxOK|wxICON_ERROR);
|
||||
wxMessageBox(Language->GameAlreadyAdded, "ERROR", wxOK|wxICON_ERROR);
|
||||
return;
|
||||
}
|
||||
array.Add(file_name);
|
||||
@@ -415,7 +575,7 @@ void OTM_Frame::OnMenuDeleteGame(wxCommandEvent& WXUNUSED(event))
|
||||
LastError.Empty();
|
||||
return;
|
||||
}
|
||||
wxGetSelectedChoices( selections, Language.DeleteGame, Language.DeleteGame, array);
|
||||
wxGetSelectedChoices( selections, Language->DeleteGame, Language->DeleteGame, array);
|
||||
|
||||
int num = selections.GetCount();
|
||||
for (int i=0; i<num; i++)
|
||||
@@ -440,25 +600,27 @@ int OTM_Frame::GetHookedGames( wxArrayString &array)
|
||||
wchar_t *app_path = _wgetenv( L"APPDATA");
|
||||
name.Printf("%ls\\%ls\\%ls", app_path, OTM_APP_DIR, OTM_APP_DX9);
|
||||
|
||||
if (!file.Access(name, wxFile::read)) {LastError << Language.Error_FileOpen << "\n" << name; return -1;}
|
||||
if (!file.Access(name, wxFile::read)) {LastError << Language->Error_FileOpen << "\n" << name; return -1;}
|
||||
file.Open(name, wxFile::read);
|
||||
if (!file.IsOpened()) {LastError << Language.Error_FileOpen << "\n" << name ; return -1;}
|
||||
if (!file.IsOpened()) {LastError << Language->Error_FileOpen << "\n" << name ; return -1;}
|
||||
|
||||
unsigned len = file.Length();
|
||||
|
||||
unsigned char* buffer;
|
||||
try {buffer = new unsigned char [len+1];}
|
||||
catch (...) {LastError << Language.Error_Memory; return -1;}
|
||||
try {buffer = new unsigned char [len+2];}
|
||||
catch (...) {LastError << Language->Error_Memory; return -1;}
|
||||
|
||||
unsigned int result = file.Read( buffer, len);
|
||||
file.Close();
|
||||
|
||||
if (result != len) {delete [] buffer; LastError << Language.Error_FileRead<<"\n" << name; return -1;}
|
||||
if (result != len) {delete [] buffer; LastError << Language->Error_FileRead<<"\n" << name; return -1;}
|
||||
|
||||
buffer[len]=0;
|
||||
wchar_t *buff = (wchar_t*)buffer;
|
||||
len/=2;
|
||||
buff[len]=0;
|
||||
|
||||
wxString content;
|
||||
content = buffer;
|
||||
content = buff;
|
||||
delete [] buffer;
|
||||
|
||||
wxStringTokenizer token( content, "\n");
|
||||
@@ -471,8 +633,6 @@ int OTM_Frame::GetHookedGames( wxArrayString &array)
|
||||
{
|
||||
array.Add( token.GetNextToken());
|
||||
}
|
||||
|
||||
file.Close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -490,15 +650,88 @@ int OTM_Frame::SetHookedGames( const wxArrayString &array)
|
||||
|
||||
name.Printf("%ls\\%ls\\%ls", app_path, OTM_APP_DIR, OTM_APP_DX9);
|
||||
file.Open(name, wxFile::write);
|
||||
if (!file.IsOpened()) {LastError << Language.Error_FileOpen << "\n" << name ; return -1;}
|
||||
if (!file.IsOpened()) {LastError << Language->Error_FileOpen << "\n" << name ; return -1;}
|
||||
wxString content;
|
||||
|
||||
//wchar_t code = 0xFFFE;
|
||||
//file.Write( content.wc_str(), 2);
|
||||
|
||||
int num = array.GetCount();
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
content = array[i];
|
||||
content << "\n";
|
||||
file.Write( content.char_str(), content.Len());
|
||||
file.Write( content.wc_str(), content.Len()*2);
|
||||
}
|
||||
file.Close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define SAVE_FILE "OTM_SaveFiles.txt"
|
||||
|
||||
int OTM_Frame::LoadTemplate(void)
|
||||
{
|
||||
wxFile file;
|
||||
if (!file.Access(SAVE_FILE, wxFile::read)) {LastError << Language->Error_FileOpen << "\n" << SAVE_FILE; return -1;}
|
||||
file.Open(SAVE_FILE, wxFile::read);
|
||||
if (!file.IsOpened()) {LastError << Language->Error_FileOpen << "\n" << SAVE_FILE ; return -1;}
|
||||
|
||||
unsigned len = file.Length();
|
||||
|
||||
unsigned char* buffer;
|
||||
try {buffer = new unsigned char [len+2];}
|
||||
catch (...) {LastError << Language->Error_Memory; return -1;}
|
||||
|
||||
unsigned int result = file.Read( buffer, len);
|
||||
file.Close();
|
||||
|
||||
if (result != len) {delete [] buffer; LastError << Language->Error_FileRead<<"\n" << SAVE_FILE; return -1;}
|
||||
|
||||
wchar_t *buff = (wchar_t*)buffer;
|
||||
len/=2;
|
||||
buff[len]=0;
|
||||
|
||||
wxString content;
|
||||
content = buff;
|
||||
delete [] buffer;
|
||||
|
||||
wxStringTokenizer token( content, "\n");
|
||||
|
||||
int num = token.CountTokens();
|
||||
|
||||
SaveFile_Exe.Empty();
|
||||
SaveFile_Exe.Alloc(num+10);
|
||||
SaveFile_Name.Empty();
|
||||
SaveFile_Name.Alloc(num+10);
|
||||
|
||||
wxString line;
|
||||
wxString exe;
|
||||
wxString name;
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
line = token.GetNextToken();
|
||||
exe = line.BeforeFirst('|');
|
||||
name = line.AfterFirst('|');
|
||||
name.Replace("\r","");
|
||||
SaveFile_Exe.Add( exe);
|
||||
SaveFile_Name.Add( name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OTM_Frame::SaveTemplate(void)
|
||||
{
|
||||
wxFile file;
|
||||
file.Open(SAVE_FILE, wxFile::write);
|
||||
if (!file.IsOpened()) {LastError << Language->Error_FileOpen << "\n" << SAVE_FILE ; return -1;}
|
||||
wxString content;
|
||||
|
||||
int num = SaveFile_Exe.GetCount();
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
content = SaveFile_Exe[i];
|
||||
content << "|" << SaveFile_Name[i] << "\n";
|
||||
file.Write( content.wc_str(), content.Len()*2);
|
||||
}
|
||||
file.Close();
|
||||
return 0;
|
||||
|
||||
+23
-8
@@ -40,34 +40,42 @@ public:
|
||||
void OnButtonOpen(wxCommandEvent& WXUNUSED(event));
|
||||
void OnButtonPath(wxCommandEvent& WXUNUSED(event));
|
||||
void OnButtonUpdate(wxCommandEvent& WXUNUSED(event));
|
||||
void OnButtonSave(wxCommandEvent& WXUNUSED(event));
|
||||
void OnButtonReload(wxCommandEvent& WXUNUSED(event));
|
||||
|
||||
|
||||
void OnMenuLanguage(wxCommandEvent& WXUNUSED(event));
|
||||
void OnMenuHelp(wxCommandEvent& WXUNUSED(event));
|
||||
void OnMenuAbout(wxCommandEvent& WXUNUSED(event));
|
||||
void OnMenuAddGame(wxCommandEvent& WXUNUSED(event));
|
||||
void OnMenuDeleteGame(wxCommandEvent& WXUNUSED(event));
|
||||
|
||||
void OnMenuOpenTemplate(wxCommandEvent& WXUNUSED(event));
|
||||
void OnMenuSaveTemplate(wxCommandEvent& WXUNUSED(event));
|
||||
void OnMenuSaveTemplateAs(wxCommandEvent& WXUNUSED(event));
|
||||
void OnMenuSetDefaultTemplate(wxCommandEvent& WXUNUSED(event));
|
||||
void OnMenuLanguage(wxCommandEvent& WXUNUSED(event));
|
||||
|
||||
void OnMenuExit(wxCommandEvent& WXUNUSED(event));
|
||||
|
||||
void OnMenuHelp(wxCommandEvent& WXUNUSED(event));
|
||||
void OnMenuAbout(wxCommandEvent& WXUNUSED(event));
|
||||
void OnMenuAcknowledgement(wxCommandEvent& WXUNUSED(event));
|
||||
|
||||
private:
|
||||
int KillServer(void);
|
||||
int GetHookedGames( wxArrayString &array);
|
||||
int SetHookedGames( const wxArrayString &array);
|
||||
|
||||
|
||||
OTM_Server *Server;
|
||||
|
||||
OTM_Language Language;
|
||||
wxNotebook *Notebook;
|
||||
|
||||
|
||||
wxButton *OpenButton;
|
||||
wxButton *DirectoryButton;
|
||||
wxButton *UpdateButton;
|
||||
wxButton *SaveButton;
|
||||
wxButton *ReloadButton;
|
||||
|
||||
|
||||
wxMenuBar *MenuBar;
|
||||
wxMenu *MenuGame;
|
||||
wxMenu *MenuMain;
|
||||
wxMenu *MenuHelp;
|
||||
|
||||
wxBoxSizer *MainSizer;
|
||||
@@ -77,6 +85,12 @@ private:
|
||||
int NumberOfGames;
|
||||
int MaxNumberOfGames;
|
||||
OTM_Client **Clients;
|
||||
|
||||
int LoadTemplate(void);
|
||||
int SaveTemplate(void);
|
||||
wxArrayString SaveFile_Exe;
|
||||
wxArrayString SaveFile_Name;
|
||||
|
||||
HMODULE H_DX9_DLL;
|
||||
|
||||
wxString LastError;
|
||||
@@ -89,6 +103,7 @@ class MyApp : public wxApp
|
||||
public:
|
||||
virtual ~MyApp();
|
||||
virtual bool OnInit();
|
||||
|
||||
private:
|
||||
HANDLE CheckForSingleRun;
|
||||
};
|
||||
|
||||
@@ -22,10 +22,8 @@ along with OpenTexMod. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
OTM_GameInfo::OTM_GameInfo(const wxString &name)
|
||||
OTM_GameInfo::OTM_GameInfo(void)
|
||||
{
|
||||
Name = name;
|
||||
|
||||
Checked = NULL;
|
||||
NumberOfChecked = 0;
|
||||
LengthOfChecked = 0;
|
||||
@@ -56,12 +54,10 @@ void OTM_GameInfo::Init(void)
|
||||
|
||||
int OTM_GameInfo::SaveToFile( const wxString &file_name)
|
||||
{
|
||||
wxString name;
|
||||
name << "OTM_GameSave_" << file_name << ".txt";
|
||||
wxFile file;
|
||||
|
||||
//if (!file.Access(name, wxFile::write)) return -1;
|
||||
file.Open(name, wxFile::write);
|
||||
file.Open(file_name, wxFile::write);
|
||||
if (!file.IsOpened()) {return -1;}
|
||||
|
||||
wxString content;
|
||||
@@ -122,13 +118,11 @@ int OTM_GameInfo::SaveToFile( const wxString &file_name)
|
||||
int OTM_GameInfo::LoadFromFile( const wxString &file_name)
|
||||
{
|
||||
Init();
|
||||
if (file_name.Len()==0) return -1;
|
||||
|
||||
wxString name;
|
||||
name << "OTM_GameSave_" << file_name << ".txt";
|
||||
wxFile file;
|
||||
|
||||
if (!file.Access(name, wxFile::read)) return -1;
|
||||
file.Open(name, wxFile::read);
|
||||
if (!file.Access(file_name, wxFile::read)) return -1;
|
||||
file.Open(file_name, wxFile::read);
|
||||
if (!file.IsOpened()) {return -1;}
|
||||
|
||||
unsigned len = file.Length();
|
||||
|
||||
@@ -27,15 +27,12 @@ along with OpenTexMod. If not, see <http://www.gnu.org/licenses/>.
|
||||
class OTM_GameInfo
|
||||
{
|
||||
public:
|
||||
OTM_GameInfo(const wxString &name);
|
||||
OTM_GameInfo(void);
|
||||
~OTM_GameInfo(void);
|
||||
void Init(void);
|
||||
|
||||
wxString Name;
|
||||
|
||||
int SaveToFile() {return SaveToFile( Name);}
|
||||
int SaveToFile( const wxString &file_name);
|
||||
int LoadFromFile() {return LoadFromFile( Name);}
|
||||
int LoadFromFile( const wxString &file_name);
|
||||
|
||||
int GetChecked( bool* array, int num) const;
|
||||
|
||||
+201
-133
@@ -19,8 +19,15 @@ along with OpenTexMod. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "OTM_Main.h"
|
||||
|
||||
|
||||
OTM_GamePage::OTM_GamePage( wxNotebook *parent, const wxString &name, PipeStruct &pipe, OTM_Language &lang) : wxPanel(parent), Language(lang), Game(name), GameOld(name), Sender(pipe, lang)
|
||||
OTM_GamePage::OTM_GamePage( wxNotebook *parent, const wxString &exe, const wxString &save, PipeStruct &pipe)
|
||||
: wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL), Sender(pipe)
|
||||
{
|
||||
ExeName = exe;
|
||||
TemplateName = save;
|
||||
|
||||
//SetBackgroundColour( *wxLIGHT_GREY);
|
||||
//SetBackgroundColour( wxColour( "LIGHT GREY"));
|
||||
|
||||
CheckBoxHSizers = NULL;
|
||||
CheckButtonUp = NULL;
|
||||
CheckButtonDown = NULL;
|
||||
@@ -29,22 +36,27 @@ OTM_GamePage::OTM_GamePage( wxNotebook *parent, const wxString &name, PipeStruct
|
||||
|
||||
MainSizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
|
||||
TemplateFile = new wxTextCtrl(this, wxID_ANY, Language->TextCtrlTemplate, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
|
||||
MainSizer->Add( (wxWindow*) TemplateFile, 0, wxEXPAND, 0);
|
||||
MainSizer->AddSpacer(10);
|
||||
|
||||
SizerKeys[0] = new wxBoxSizer(wxHORIZONTAL);
|
||||
SizerKeys[1] = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
TextKeyBack = new wxTextCtrl(this, wxID_ANY, Language.KeyBack, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
|
||||
TextKeyBack = new wxTextCtrl(this, wxID_ANY, Language->KeyBack, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
|
||||
SizerKeys[0]->Add( (wxWindow*) TextKeyBack, 1, wxEXPAND, 0);
|
||||
ChoiceKeyBack = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Language.KeyStrings);
|
||||
ChoiceKeyBack = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Language->KeyStrings);
|
||||
SizerKeys[1]->Add( (wxWindow*) ChoiceKeyBack, 1, wxEXPAND, 0);
|
||||
|
||||
TextKeySave = new wxTextCtrl(this, wxID_ANY, Language.KeySave, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
|
||||
TextKeySave = new wxTextCtrl(this, wxID_ANY, Language->KeySave, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
|
||||
SizerKeys[0]->Add( (wxWindow*) TextKeySave, 1, wxEXPAND, 0);
|
||||
ChoiceKeySave = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Language.KeyStrings);
|
||||
ChoiceKeySave = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Language->KeyStrings);
|
||||
SizerKeys[1]->Add( (wxWindow*) ChoiceKeySave, 1, wxEXPAND, 0);
|
||||
|
||||
TextKeyNext = new wxTextCtrl(this, wxID_ANY, Language.KeyNext, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
|
||||
TextKeyNext = new wxTextCtrl(this, wxID_ANY, Language->KeyNext, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
|
||||
SizerKeys[0]->Add( (wxWindow*) TextKeyNext, 1, wxEXPAND, 0);
|
||||
ChoiceKeyNext = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Language.KeyStrings);
|
||||
ChoiceKeyNext = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Language->KeyStrings);
|
||||
SizerKeys[1]->Add( (wxWindow*) ChoiceKeyNext, 1, wxEXPAND, 0);
|
||||
|
||||
MainSizer->Add( SizerKeys[0], 0, wxEXPAND, 0);
|
||||
@@ -52,14 +64,14 @@ OTM_GamePage::OTM_GamePage( wxNotebook *parent, const wxString &name, PipeStruct
|
||||
|
||||
|
||||
FontColourSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
FontColour[0] = new wxTextCtrl(this, wxID_ANY, Language.FontColour, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
|
||||
FontColour[0] = new wxTextCtrl(this, wxID_ANY, Language->FontColour, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
|
||||
FontColour[1] = new wxTextCtrl(this, wxID_ANY, "255", wxDefaultPosition, wxDefaultSize);
|
||||
FontColour[2] = new wxTextCtrl(this, wxID_ANY, "0", wxDefaultPosition, wxDefaultSize);
|
||||
FontColour[3] = new wxTextCtrl(this, wxID_ANY, "0", wxDefaultPosition, wxDefaultSize);
|
||||
for (int i=0; i<4; i++) FontColourSizer->Add( (wxWindow*) FontColour[i], 1, wxEXPAND, 0);
|
||||
|
||||
TextureColourSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
TextureColour[0] = new wxTextCtrl(this, wxID_ANY, Language.TextureColour, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
|
||||
TextureColour[0] = new wxTextCtrl(this, wxID_ANY, Language->TextureColour, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
|
||||
TextureColour[1] = new wxTextCtrl(this, wxID_ANY, "0", wxDefaultPosition, wxDefaultSize);
|
||||
TextureColour[2] = new wxTextCtrl(this, wxID_ANY, "255", wxDefaultPosition, wxDefaultSize);
|
||||
TextureColour[3] = new wxTextCtrl(this, wxID_ANY, "0", wxDefaultPosition, wxDefaultSize);
|
||||
@@ -69,104 +81,33 @@ OTM_GamePage::OTM_GamePage( wxNotebook *parent, const wxString &name, PipeStruct
|
||||
MainSizer->Add( FontColourSizer, 0, wxEXPAND, 0);
|
||||
MainSizer->Add( TextureColourSizer, 0, wxEXPAND, 0);
|
||||
|
||||
SaveSingleTexture = new wxCheckBox( this, -1, Language.CheckBoxSaveSingleTexture);
|
||||
SaveSingleTexture = new wxCheckBox( this, -1, Language->CheckBoxSaveSingleTexture);
|
||||
MainSizer->Add( (wxWindow*) SaveSingleTexture, 0, wxEXPAND, 0);
|
||||
|
||||
SaveAllTextures = new wxCheckBox( this, -1, Language.CheckBoxSaveAllTextures);
|
||||
SaveAllTextures = new wxCheckBox( this, -1, Language->CheckBoxSaveAllTextures);
|
||||
MainSizer->Add( (wxWindow*) SaveAllTextures, 0, wxEXPAND, 0);
|
||||
|
||||
SavePath = new wxTextCtrl(this, wxID_ANY, Language.TextCtrlSavePath, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
|
||||
SavePath = new wxTextCtrl(this, wxID_ANY, Language->TextCtrlSavePath, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
|
||||
MainSizer->Add( (wxWindow*) SavePath, 0, wxEXPAND, 0);
|
||||
|
||||
MainSizer->AddSpacer(10);
|
||||
|
||||
NumberOfEntry = 0;
|
||||
MaxNumberOfEntry = 1024;
|
||||
if (GetMemory( CheckBoxes, MaxNumberOfEntry)) {LastError = Language->Error_Memory; return;}
|
||||
if (GetMemory( CheckBoxHSizers, MaxNumberOfEntry)) {LastError = Language->Error_Memory; return ;}
|
||||
if (GetMemory( CheckButtonUp, MaxNumberOfEntry)) {LastError = Language->Error_Memory; return;}
|
||||
if (GetMemory( CheckButtonDown, MaxNumberOfEntry)) {LastError = Language->Error_Memory; return;}
|
||||
if (GetMemory( CheckButtonDelete, MaxNumberOfEntry)) {LastError = Language->Error_Memory; return;}
|
||||
SavePath->SetValue(Language->TextCtrlSavePath);
|
||||
|
||||
if (Game.LoadFromFile())
|
||||
{
|
||||
NumberOfEntry = 0;
|
||||
MaxNumberOfEntry = 1024;
|
||||
if (GetMemory( CheckBoxes, MaxNumberOfEntry)) {LastError = Language.Error_Memory; return;}
|
||||
if (GetMemory( CheckBoxHSizers, MaxNumberOfEntry)) {LastError = Language.Error_Memory; return ;}
|
||||
if (GetMemory( CheckButtonUp, MaxNumberOfEntry)) {LastError = Language.Error_Memory; return;}
|
||||
if (GetMemory( CheckButtonDown, MaxNumberOfEntry)) {LastError = Language.Error_Memory; return;}
|
||||
if (GetMemory( CheckButtonDelete, MaxNumberOfEntry)) {LastError = Language.Error_Memory; return;}
|
||||
|
||||
SavePath->SetValue(Language.TextCtrlSavePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
wxArrayString comments;
|
||||
if (Sender.Send( Game, GameOld, &comments)==0) GameOld = Game;
|
||||
|
||||
int key = Game.GetKeyBack();
|
||||
if (key>=0) ChoiceKeyBack->SetSelection( key);
|
||||
key = Game.GetKeySave();
|
||||
if (key>=0) ChoiceKeySave->SetSelection( key);
|
||||
key = Game.GetKeyNext();
|
||||
if (key>=0) ChoiceKeyNext->SetSelection( key);
|
||||
|
||||
int colour[3];
|
||||
Game.GetFontColour( colour);
|
||||
SetColour( &FontColour[1], colour);
|
||||
Game.GetTextureColour( colour);
|
||||
SetColour( &TextureColour[1], colour);
|
||||
|
||||
SaveSingleTexture->SetValue( Game.GetSaveSingleTexture());
|
||||
SaveAllTextures->SetValue( Game.GetSaveAllTextures());
|
||||
|
||||
wxString save_path = Language.TextCtrlSavePath;
|
||||
save_path << Game.GetSavePath();
|
||||
SavePath->SetValue(save_path);
|
||||
|
||||
NumberOfEntry = Game.GetNumberOfFiles();
|
||||
Files.Alloc(NumberOfEntry+100);
|
||||
|
||||
Game.GetFiles( Files);
|
||||
|
||||
NumberOfEntry = Files.GetCount();
|
||||
MaxNumberOfEntry = ((NumberOfEntry/1024)+1)*1024;
|
||||
|
||||
bool *checked = NULL;
|
||||
if (GetMemory( checked, NumberOfEntry)) {LastError = Language.Error_Memory; return;}
|
||||
Game.GetChecked( checked, NumberOfEntry);
|
||||
|
||||
if (GetMemory( CheckBoxes, MaxNumberOfEntry)) {LastError = Language.Error_Memory; return;}
|
||||
if (GetMemory( CheckBoxHSizers, MaxNumberOfEntry)) {LastError = Language.Error_Memory; return ;}
|
||||
if (GetMemory( CheckButtonUp, MaxNumberOfEntry)) {LastError = Language.Error_Memory; return;}
|
||||
if (GetMemory( CheckButtonDown, MaxNumberOfEntry)) {LastError = Language.Error_Memory; return;}
|
||||
if (GetMemory( CheckButtonDelete, MaxNumberOfEntry)) {LastError = Language.Error_Memory; return;}
|
||||
|
||||
for (int i=0; i<NumberOfEntry; i++)
|
||||
{
|
||||
CheckBoxHSizers[i] = new wxBoxSizer(wxHORIZONTAL);
|
||||
CheckBoxes[i] = new wxCheckBox( this, -1, Files[i]);
|
||||
CheckBoxes[i]->SetValue( checked[i]);
|
||||
CheckBoxes[i]->SetToolTip( comments[i]);
|
||||
|
||||
wchar_t button_txt[2];
|
||||
button_txt[0] = 8657;
|
||||
button_txt[1] = 0;
|
||||
|
||||
CheckButtonUp[i] = new wxButton( this, ID_Button_Texture+3*i, button_txt, wxDefaultPosition, wxSize(24,24));
|
||||
Bind( wxEVT_COMMAND_BUTTON_CLICKED, &OTM_GamePage::OnButtonUp, this, ID_Button_Texture+3*i);
|
||||
|
||||
button_txt[0] = 8659;
|
||||
CheckButtonDown[i] = new wxButton( this, ID_Button_Texture+3*i+1, button_txt, wxDefaultPosition, wxSize(24,24));
|
||||
Bind( wxEVT_COMMAND_BUTTON_CLICKED, &OTM_GamePage::OnButtonDown, this, ID_Button_Texture+3*i+1);
|
||||
|
||||
CheckButtonDelete[i] = new wxButton( this, ID_Button_Texture+3*i+2, L"X", wxDefaultPosition, wxSize(24,24));
|
||||
Bind( wxEVT_COMMAND_BUTTON_CLICKED, &OTM_GamePage::OnButtonDelete, this, ID_Button_Texture+3*i+2);
|
||||
|
||||
CheckBoxHSizers[i]->Add( (wxWindow*) CheckBoxes[i], 1, wxEXPAND, 0);
|
||||
CheckBoxHSizers[i]->Add( (wxWindow*) CheckButtonUp[i], 0, wxEXPAND, 0);
|
||||
CheckBoxHSizers[i]->Add( (wxWindow*) CheckButtonDown[i], 0, wxEXPAND, 0);
|
||||
CheckBoxHSizers[i]->Add( (wxWindow*) CheckButtonDelete[i], 0, wxEXPAND, 0);
|
||||
|
||||
MainSizer->Add( CheckBoxHSizers[i], 0, wxEXPAND, 0);
|
||||
}
|
||||
delete [] checked;
|
||||
}
|
||||
SetSizer(MainSizer);
|
||||
|
||||
SetScrollRate(0, 20);
|
||||
MainSizer->FitInside(this);
|
||||
|
||||
if (TemplateName.Len()>0) LoadTemplate(TemplateName);
|
||||
}
|
||||
|
||||
OTM_GamePage::~OTM_GamePage(void)
|
||||
@@ -187,8 +128,8 @@ OTM_GamePage::~OTM_GamePage(void)
|
||||
|
||||
int OTM_GamePage::SetSavePath( const wxString &path)
|
||||
{
|
||||
wxString save_path = path;
|
||||
save_path.Prepend(Language.TextCtrlSavePath);
|
||||
wxString save_path = Language->TextCtrlSavePath;
|
||||
save_path << path;
|
||||
SavePath->SetValue(save_path);
|
||||
Game.SetSavePath( path);
|
||||
return 0;
|
||||
@@ -199,15 +140,15 @@ int OTM_GamePage::AddTexture( const wxString &file_name)
|
||||
{
|
||||
if (NumberOfEntry>=MaxNumberOfEntry)
|
||||
{
|
||||
if (GetMoreMemory( CheckBoxes, MaxNumberOfEntry, MaxNumberOfEntry+1024)) {LastError = Language.Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckBoxHSizers, MaxNumberOfEntry, MaxNumberOfEntry+1024)) {LastError = Language.Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckButtonUp, MaxNumberOfEntry, MaxNumberOfEntry+1024)) {LastError = Language.Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckButtonDown, MaxNumberOfEntry, MaxNumberOfEntry+1024)) {LastError = Language.Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckButtonDelete, MaxNumberOfEntry, MaxNumberOfEntry+1024)) {LastError = Language.Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckBoxes, MaxNumberOfEntry, MaxNumberOfEntry+1024)) {LastError = Language->Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckBoxHSizers, MaxNumberOfEntry, MaxNumberOfEntry+1024)) {LastError = Language->Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckButtonUp, MaxNumberOfEntry, MaxNumberOfEntry+1024)) {LastError = Language->Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckButtonDown, MaxNumberOfEntry, MaxNumberOfEntry+1024)) {LastError = Language->Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckButtonDelete, MaxNumberOfEntry, MaxNumberOfEntry+1024)) {LastError = Language->Error_Memory; return -1;}
|
||||
MaxNumberOfEntry+=1024;
|
||||
}
|
||||
OTM_File file( Language, file_name);
|
||||
if (!file.FileSupported()) {LastError << Language.Error_FileNotSupported << "\n" << file_name; return -1;}
|
||||
OTM_File file( file_name);
|
||||
if (!file.FileSupported()) {LastError << Language->Error_FileNotSupported << "\n" << file_name; return -1;}
|
||||
|
||||
wxString tool_tip;
|
||||
file.GetComment( tool_tip);
|
||||
@@ -239,8 +180,9 @@ int OTM_GamePage::AddTexture( const wxString &file_name)
|
||||
Files.Add( file_name);
|
||||
NumberOfEntry++;
|
||||
MainSizer->Layout();
|
||||
MainSizer->FitInside(this);
|
||||
|
||||
return 0;
|
||||
return UpdateGame();
|
||||
}
|
||||
|
||||
int OTM_GamePage::GetSettings(void)
|
||||
@@ -249,16 +191,16 @@ int OTM_GamePage::GetSettings(void)
|
||||
int key_save = ChoiceKeySave->GetSelection();
|
||||
int key_next = ChoiceKeyNext->GetSelection();
|
||||
|
||||
if (key_back==key_save && key_back!=wxNOT_FOUND) {LastError << Language.Error_KeyTwice; return 1;}
|
||||
if (key_back==key_next && key_back!=wxNOT_FOUND) {LastError << Language.Error_KeyTwice; return 1;}
|
||||
if (key_save==key_next && key_save!=wxNOT_FOUND) {LastError << Language.Error_KeyTwice; return 1;}
|
||||
if (key_back==key_save && key_back!=wxNOT_FOUND) {LastError << Language->Error_KeyTwice; return 1;}
|
||||
if (key_back==key_next && key_back!=wxNOT_FOUND) {LastError << Language->Error_KeyTwice; return 1;}
|
||||
if (key_save==key_next && key_save!=wxNOT_FOUND) {LastError << Language->Error_KeyTwice; return 1;}
|
||||
|
||||
bool save_single = SaveSingleTexture->GetValue();
|
||||
bool save_all = SaveAllTextures->GetValue();
|
||||
wxString path = Game.GetSavePath();
|
||||
if ( (save_single || save_all) && path.Len()==0) {LastError << Language.Error_NoSavePath; return 1;}
|
||||
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 ( 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);
|
||||
@@ -283,7 +225,7 @@ int OTM_GamePage::GetSettings(void)
|
||||
Game.SetFiles( Files);
|
||||
|
||||
bool *checked = NULL;
|
||||
if (GetMemory( checked, NumberOfEntry)) {LastError = Language.Error_Memory; return -1;}
|
||||
if (GetMemory( checked, NumberOfEntry)) {LastError = Language->Error_Memory; return -1;}
|
||||
for (int i=0; i<NumberOfEntry; i++) checked[i] = CheckBoxes[i]->GetValue();
|
||||
Game.SetChecked( checked, NumberOfEntry);
|
||||
delete [] checked;
|
||||
@@ -295,9 +237,9 @@ int OTM_GamePage::UpdateGame(void)
|
||||
{
|
||||
if (int ret = GetSettings()) return ret;
|
||||
|
||||
if (int ret = Sender.Send( Game, GameOld))
|
||||
if (int ret = Sender.Send( Game, GameOld, false))
|
||||
{
|
||||
LastError = Language.Error_Send;
|
||||
LastError = Language->Error_Send;
|
||||
LastError << "\n" << Sender.LastError;
|
||||
Sender.LastError.Empty();
|
||||
return ret;
|
||||
@@ -307,15 +249,150 @@ int OTM_GamePage::UpdateGame(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OTM_GamePage::SaveToFile( const wxString &file_name)
|
||||
|
||||
int OTM_GamePage::ReloadGame(void)
|
||||
{
|
||||
if (int ret = GetSettings()) return ret;
|
||||
|
||||
if (int ret = Sender.Send( Game, GameOld, true))
|
||||
{
|
||||
LastError = Language->Error_Send;
|
||||
LastError << "\n" << Sender.LastError;
|
||||
Sender.LastError.Empty();
|
||||
return ret;
|
||||
}
|
||||
|
||||
GameOld = Game;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OTM_GamePage::SaveTemplate( const wxString &file_name)
|
||||
{
|
||||
if (int ret = GetSettings()) return ret;
|
||||
if (int ret = Game.SaveToFile( file_name))
|
||||
{
|
||||
LastError = Language.Error_SaveFile;
|
||||
LastError = Language->Error_SaveFile;
|
||||
LastError <<"\n" << file_name;
|
||||
return ret;
|
||||
}
|
||||
TemplateName = file_name;
|
||||
wxString path;
|
||||
path = Language->TextCtrlTemplate;
|
||||
path << TemplateName;
|
||||
TemplateFile->SetValue( path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OTM_GamePage::LoadTemplate( const wxString &file_name)
|
||||
{
|
||||
if (Game.LoadFromFile(file_name)) return -1;
|
||||
TemplateName = file_name;
|
||||
wxArrayString comments;
|
||||
|
||||
if (Sender.Send( Game, GameOld, true, &comments)==0) GameOld = Game;
|
||||
|
||||
wxString path;
|
||||
path = Language->TextCtrlTemplate;
|
||||
path << TemplateName;
|
||||
TemplateFile->SetValue( path);
|
||||
|
||||
int key = Game.GetKeyBack();
|
||||
if (key>=0) ChoiceKeyBack->SetSelection( key);
|
||||
key = Game.GetKeySave();
|
||||
if (key>=0) ChoiceKeySave->SetSelection( key);
|
||||
key = Game.GetKeyNext();
|
||||
if (key>=0) ChoiceKeyNext->SetSelection( key);
|
||||
|
||||
int colour[3];
|
||||
Game.GetFontColour( colour);
|
||||
SetColour( &FontColour[1], colour);
|
||||
Game.GetTextureColour( colour);
|
||||
SetColour( &TextureColour[1], colour);
|
||||
|
||||
SaveSingleTexture->SetValue( Game.GetSaveSingleTexture());
|
||||
SaveAllTextures->SetValue( Game.GetSaveAllTextures());
|
||||
|
||||
path = Language->TextCtrlSavePath;
|
||||
path << Game.GetSavePath();
|
||||
SavePath->SetValue( path);
|
||||
|
||||
int new_NumberOfEntry = Game.GetNumberOfFiles();
|
||||
|
||||
Game.GetFiles( Files);
|
||||
|
||||
if (new_NumberOfEntry>=MaxNumberOfEntry)
|
||||
{
|
||||
MaxNumberOfEntry = ((NumberOfEntry/1024)+1)*1024;
|
||||
if (GetMoreMemory( CheckBoxes, NumberOfEntry, MaxNumberOfEntry)) {LastError = Language->Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckBoxHSizers, NumberOfEntry, MaxNumberOfEntry)) {LastError = Language->Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckButtonUp, NumberOfEntry, MaxNumberOfEntry)) {LastError = Language->Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckButtonDown, NumberOfEntry, MaxNumberOfEntry)) {LastError = Language->Error_Memory; return -1;}
|
||||
if (GetMoreMemory( CheckButtonDelete, NumberOfEntry, MaxNumberOfEntry)) {LastError = Language->Error_Memory; return -1;}
|
||||
}
|
||||
|
||||
bool *checked = NULL;
|
||||
if (GetMemory( checked, new_NumberOfEntry)) {LastError = Language->Error_Memory; return -1;}
|
||||
Game.GetChecked( checked, new_NumberOfEntry);
|
||||
|
||||
|
||||
for (int i=0; i<NumberOfEntry && i<new_NumberOfEntry; i++)
|
||||
{
|
||||
CheckBoxes[i]->SetLabel( Files[i]);
|
||||
CheckBoxes[i]->SetValue( checked[i]);
|
||||
CheckBoxes[i]->SetToolTip( comments[i]);
|
||||
}
|
||||
|
||||
for (int i=new_NumberOfEntry; i<NumberOfEntry; i++)
|
||||
{
|
||||
Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &OTM_GamePage::OnButtonUp, this, ID_Button_Texture+3*i);
|
||||
Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &OTM_GamePage::OnButtonDown, this, ID_Button_Texture+3*i+1);
|
||||
Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &OTM_GamePage::OnButtonDelete, this, ID_Button_Texture+3*i+2);
|
||||
|
||||
|
||||
CheckBoxHSizers[i]->Detach( (wxWindow*) CheckBoxes[i]);
|
||||
CheckBoxHSizers[i]->Detach( (wxWindow*) CheckButtonUp[i]);
|
||||
CheckBoxHSizers[i]->Detach( (wxWindow*) CheckButtonDown[i]);
|
||||
CheckBoxHSizers[i]->Detach( (wxWindow*) CheckButtonDelete[i]);
|
||||
|
||||
MainSizer->Detach( CheckBoxHSizers[i]);
|
||||
|
||||
delete CheckBoxes[i];
|
||||
delete CheckButtonUp[i];
|
||||
delete CheckButtonDown[i];
|
||||
delete CheckButtonDelete[i];
|
||||
delete CheckBoxHSizers[i];
|
||||
}
|
||||
for (int i=NumberOfEntry; i<new_NumberOfEntry; i++)
|
||||
{
|
||||
CheckBoxHSizers[i] = new wxBoxSizer(wxHORIZONTAL);
|
||||
CheckBoxes[i] = new wxCheckBox( this, -1, Files[i]);
|
||||
CheckBoxes[i]->SetValue( checked[i]);
|
||||
CheckBoxes[i]->SetToolTip( comments[i]);
|
||||
|
||||
wchar_t button_txt[2];
|
||||
button_txt[0] = 8657;
|
||||
button_txt[1] = 0;
|
||||
|
||||
CheckButtonUp[i] = new wxButton( this, ID_Button_Texture+3*i, button_txt, wxDefaultPosition, wxSize(24,24));
|
||||
Bind( wxEVT_COMMAND_BUTTON_CLICKED, &OTM_GamePage::OnButtonUp, this, ID_Button_Texture+3*i);
|
||||
|
||||
button_txt[0] = 8659;
|
||||
CheckButtonDown[i] = new wxButton( this, ID_Button_Texture+3*i+1, button_txt, wxDefaultPosition, wxSize(24,24));
|
||||
Bind( wxEVT_COMMAND_BUTTON_CLICKED, &OTM_GamePage::OnButtonDown, this, ID_Button_Texture+3*i+1);
|
||||
|
||||
CheckButtonDelete[i] = new wxButton( this, ID_Button_Texture+3*i+2, L"X", wxDefaultPosition, wxSize(24,24));
|
||||
Bind( wxEVT_COMMAND_BUTTON_CLICKED, &OTM_GamePage::OnButtonDelete, this, ID_Button_Texture+3*i+2);
|
||||
|
||||
CheckBoxHSizers[i]->Add( (wxWindow*) CheckBoxes[i], 1, wxEXPAND, 0);
|
||||
CheckBoxHSizers[i]->Add( (wxWindow*) CheckButtonUp[i], 0, wxEXPAND, 0);
|
||||
CheckBoxHSizers[i]->Add( (wxWindow*) CheckButtonDown[i], 0, wxEXPAND, 0);
|
||||
CheckBoxHSizers[i]->Add( (wxWindow*) CheckButtonDelete[i], 0, wxEXPAND, 0);
|
||||
|
||||
MainSizer->Add( CheckBoxHSizers[i], 0, wxEXPAND, 0);
|
||||
}
|
||||
delete [] checked;
|
||||
NumberOfEntry = new_NumberOfEntry;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -421,32 +498,23 @@ void OTM_GamePage::OnButtonDelete(wxCommandEvent& event)
|
||||
MainSizer->Detach( CheckBoxHSizers[NumberOfEntry]);
|
||||
|
||||
delete CheckBoxes[NumberOfEntry];
|
||||
CheckBoxes[NumberOfEntry] = NULL;
|
||||
|
||||
delete CheckButtonUp[NumberOfEntry];
|
||||
CheckButtonUp[NumberOfEntry] = NULL;
|
||||
|
||||
delete CheckButtonDown[NumberOfEntry];
|
||||
CheckButtonDown[NumberOfEntry] = NULL;
|
||||
|
||||
delete CheckButtonDelete[NumberOfEntry];
|
||||
CheckButtonDelete[NumberOfEntry] = NULL;
|
||||
|
||||
delete CheckBoxHSizers[NumberOfEntry];
|
||||
CheckBoxHSizers[NumberOfEntry] = NULL;
|
||||
}
|
||||
|
||||
|
||||
int OTM_GamePage::UpdateLanguage(void)
|
||||
{
|
||||
TextKeyBack->SetValue( Language.KeyBack);
|
||||
TextKeySave->SetValue( Language.KeySave);
|
||||
TextKeyNext->SetValue( Language.KeyNext);
|
||||
FontColour[0]->SetValue( Language.FontColour);
|
||||
TextureColour[0]->SetValue( Language.TextureColour);
|
||||
SaveAllTextures->SetLabel( Language.CheckBoxSaveAllTextures);
|
||||
SaveSingleTexture->SetLabel( Language.CheckBoxSaveSingleTexture);
|
||||
wxString temp = Language.TextCtrlSavePath;
|
||||
TextKeyBack->SetValue( Language->KeyBack);
|
||||
TextKeySave->SetValue( Language->KeySave);
|
||||
TextKeyNext->SetValue( Language->KeyNext);
|
||||
FontColour[0]->SetValue( Language->FontColour);
|
||||
TextureColour[0]->SetValue( Language->TextureColour);
|
||||
SaveAllTextures->SetLabel( Language->CheckBoxSaveAllTextures);
|
||||
SaveSingleTexture->SetLabel( Language->CheckBoxSaveSingleTexture);
|
||||
wxString temp = Language->TextCtrlSavePath;
|
||||
temp << Game.GetSavePath();
|
||||
SavePath->SetValue( temp);
|
||||
return 0;
|
||||
|
||||
+12
-7
@@ -22,22 +22,23 @@ along with OpenTexMod. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define OTM_GAMEPAGE_H_
|
||||
#include "OTM_Main.h"
|
||||
|
||||
|
||||
// this page is opened if a game is started.
|
||||
class OTM_GamePage : public wxPanel
|
||||
class OTM_GamePage : public wxScrolledWindow
|
||||
{
|
||||
public:
|
||||
OTM_GamePage( wxNotebook *parent, const wxString &name, PipeStruct &pipe, OTM_Language &lang);
|
||||
OTM_GamePage( wxNotebook *parent, const wxString &exe, const wxString &save, PipeStruct &pipe);
|
||||
virtual ~OTM_GamePage(void);
|
||||
|
||||
int AddTexture( const wxString &file_name);
|
||||
|
||||
int UpdateGame(void);
|
||||
int ReloadGame(void);
|
||||
|
||||
int SaveToFile() {return SaveToFile(Game.Name);}
|
||||
int SaveToFile( const wxString &file_name);
|
||||
//int LoadFromFile( const wxString &file_name) {return Game->LoadFromFile( file_name);}
|
||||
int SaveTemplate( const wxString &file_name);
|
||||
int LoadTemplate( const wxString &file_name);
|
||||
|
||||
wxString GetExeName(void) {return ExeName;}
|
||||
wxString GetTemplateName(void) {return TemplateName;}
|
||||
|
||||
int SetOpenPath(const wxString &path) {return Game.SetOpenPath(path);}
|
||||
wxString GetOpenPath(void) {return Game.GetOpenPath();}
|
||||
@@ -60,6 +61,9 @@ private:
|
||||
int SetColour( wxTextCtrl** txt, int *colour);
|
||||
int GetColour( wxTextCtrl* txt, int def);
|
||||
|
||||
wxString ExeName;
|
||||
wxString TemplateName;
|
||||
|
||||
wxBoxSizer *SizerKeys[2];
|
||||
wxTextCtrl *TextKeyBack;
|
||||
wxTextCtrl *TextKeySave;
|
||||
@@ -74,6 +78,8 @@ private:
|
||||
wxTextCtrl *TextureColour[4];
|
||||
|
||||
wxBoxSizer *MainSizer;
|
||||
|
||||
wxTextCtrl *TemplateFile;
|
||||
wxCheckBox *SaveAllTextures;
|
||||
wxCheckBox *SaveSingleTexture;
|
||||
wxTextCtrl *SavePath;
|
||||
@@ -87,7 +93,6 @@ private:
|
||||
int NumberOfEntry;
|
||||
int MaxNumberOfEntry;
|
||||
|
||||
OTM_Language &Language;
|
||||
|
||||
wxArrayString Files;
|
||||
OTM_GameInfo Game;
|
||||
|
||||
+103
-43
@@ -20,15 +20,23 @@ along with OpenTexMod. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "OTM_Main.h"
|
||||
|
||||
OTM_Language *Language = NULL;
|
||||
|
||||
OTM_Language::OTM_Language(void)
|
||||
{
|
||||
if (LoadCurrentLanguage()) {LoadDefault(); CurrentLanguage = "English"; LastError.Empty();}
|
||||
LoadDefault();
|
||||
LoadKeys();
|
||||
}
|
||||
|
||||
#define LAST_USED_LANGUAGE_FILE "OTM_LastUsedLanguage.txt"
|
||||
OTM_Language::OTM_Language(const wxString &name)
|
||||
{
|
||||
LoadLanguage(name);
|
||||
LoadKeys();
|
||||
LastError.Empty();
|
||||
}
|
||||
|
||||
//#define LAST_USED_LANGUAGE_FILE "OTM_LastUsedLanguage.txt"
|
||||
/*
|
||||
int OTM_Language::LoadCurrentLanguage(void)
|
||||
{
|
||||
wxFile file;
|
||||
@@ -62,12 +70,15 @@ int OTM_Language::SaveCurrentLanguage(void)
|
||||
file.Write( CurrentLanguage.char_str(), CurrentLanguage.Len());
|
||||
return 0;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
int OTM_Language::GetLanguages(wxArrayString &lang)
|
||||
{
|
||||
wxArrayString files;
|
||||
wxDir::GetAllFiles( wxGetCwd(), &files, "OTM_LanguagePack_*.txt");
|
||||
wxString dir = wxGetCwd();
|
||||
dir << "/languages";
|
||||
wxDir::GetAllFiles( dir, &files, "OTM_LanguagePack_*.txt");
|
||||
wxDir::GetAllFiles( dir, &files, "OTM_LanguagePackU_*.txt");
|
||||
lang.Empty();
|
||||
lang.Alloc(files.GetCount()+1);
|
||||
lang.Add("English");
|
||||
@@ -93,29 +104,45 @@ int OTM_Language::GetHelpMessage(wxString &help)
|
||||
file << "README_" << CurrentLanguage << ".txt";
|
||||
|
||||
wxFile dat;
|
||||
if (!dat.Access(file, wxFile::read))
|
||||
{
|
||||
file.Empty();
|
||||
file << "README_" << CurrentLanguage << ".txt";
|
||||
if (!dat.Access(file, wxFile::read)) {LastError << Error_FileOpen <<"\n" << file; return -1;}
|
||||
}
|
||||
dat.Open(file, wxFile::read);
|
||||
if (!dat.IsOpened()) {LastError << Error_FileOpen <<"\n" << file; return -1;}
|
||||
unsigned len = dat.Length();
|
||||
bool utf16=false;
|
||||
if (!dat.Access(file, wxFile::read))
|
||||
{
|
||||
file.Empty();
|
||||
file << "READMEU_" << CurrentLanguage << ".txt";
|
||||
utf16=true;
|
||||
if (!dat.Access(file, wxFile::read))
|
||||
{
|
||||
utf16=false;
|
||||
file = "README_English.txt";
|
||||
if (!dat.Access(file, wxFile::read)) {LastError << Error_FileOpen <<"\n" << file; return -1;}
|
||||
}
|
||||
}
|
||||
dat.Open(file, wxFile::read);
|
||||
if (!dat.IsOpened()) {LastError << Error_FileOpen <<"\n" << file; return -1;}
|
||||
unsigned len = dat.Length();
|
||||
|
||||
unsigned char* buffer;
|
||||
try {buffer = new unsigned char [len+1];}
|
||||
catch (...) {LastError << Error_Memory; return -1;}
|
||||
unsigned char* buffer;
|
||||
try {buffer = new unsigned char [len+2];}
|
||||
catch (...) {LastError << Error_Memory; return -1;}
|
||||
|
||||
unsigned int result = dat.Read( buffer, len);
|
||||
dat.Close();
|
||||
unsigned int result = dat.Read( buffer, len);
|
||||
dat.Close();
|
||||
|
||||
if (result != len) {delete [] buffer; LastError << Error_FileRead<<"\n" << file; return -1;}
|
||||
if (result != len) {delete [] buffer; LastError << Error_FileRead<<"\n" << file; return -1;}
|
||||
|
||||
buffer[len]=0;
|
||||
help=buffer;
|
||||
|
||||
return 0;
|
||||
if (utf16)
|
||||
{
|
||||
wchar_t *buf = (wchar_t*) buffer;
|
||||
len/=2;
|
||||
buf[len]=0;
|
||||
help=buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[len]=0;
|
||||
help=buffer;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -126,26 +153,29 @@ if ( command == #target ) \
|
||||
target = msg; \
|
||||
} else
|
||||
|
||||
int OTM_Language::LoadLanguage(const wxString &name, bool save)
|
||||
int OTM_Language::LoadLanguage(const wxString &name)
|
||||
{
|
||||
LoadDefault();
|
||||
if (name=="English")
|
||||
{
|
||||
if (wxFile::Exists(LAST_USED_LANGUAGE_FILE)) wxRemoveFile(LAST_USED_LANGUAGE_FILE);
|
||||
return 0;
|
||||
}
|
||||
if (name=="English") return 0;
|
||||
|
||||
wxString file_name;
|
||||
file_name << "OTM_LanguagePack_" << name << ".txt";
|
||||
file_name << "languages/OTM_LanguagePack_" << name << ".txt";
|
||||
|
||||
bool utf16=false;
|
||||
wxFile dat;
|
||||
if (!dat.Access(file_name, wxFile::read)) {LastError << Error_FileOpen <<"\n" << file_name; return -1;}
|
||||
if (!dat.Access(file_name, wxFile::read))
|
||||
{
|
||||
utf16=true;
|
||||
file_name.Empty();
|
||||
file_name << "languages/OTM_LanguagePackU_" << name << ".txt";
|
||||
if (!dat.Access(file_name, wxFile::read)){LastError << Error_FileOpen <<"\n" << file_name; return -1;}
|
||||
}
|
||||
dat.Open(file_name, wxFile::read);
|
||||
if (!dat.IsOpened()) {LastError << Error_FileOpen <<"\n" << file_name; return -1;}
|
||||
unsigned len = dat.Length();
|
||||
|
||||
unsigned char* buffer;
|
||||
try {buffer = new unsigned char [len+1];}
|
||||
try {buffer = new unsigned char [len+2];}
|
||||
catch (...) {LastError << Error_Memory; return -1;}
|
||||
|
||||
unsigned int result = dat.Read( buffer, len);
|
||||
@@ -153,10 +183,24 @@ int OTM_Language::LoadLanguage(const wxString &name, bool save)
|
||||
|
||||
if (result != len) {delete [] buffer; LastError << Error_FileRead<<"\n" << file_name; return -1;}
|
||||
|
||||
buffer[len]=0;
|
||||
CurrentLanguage = name;
|
||||
wxString content;
|
||||
|
||||
wxStringTokenizer token( buffer, "|");
|
||||
if (utf16)
|
||||
{
|
||||
wchar_t *buf = (wchar_t*) buffer;
|
||||
len/=2;
|
||||
buf[len]=0;
|
||||
if (buf[0]==0XFEFF || buf[0]==0XFFFE) content=&buf[1]; //get rid of the BOM
|
||||
else content=buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[len]=0;
|
||||
content = buffer;
|
||||
}
|
||||
|
||||
wxStringTokenizer token( content, "|");
|
||||
int num = token.CountTokens();
|
||||
wxString entry;
|
||||
wxString command;
|
||||
@@ -165,7 +209,7 @@ int OTM_Language::LoadLanguage(const wxString &name, bool save)
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
entry = token.GetNextToken();
|
||||
|
||||
if (entry[0]=='#') continue;
|
||||
command = entry.BeforeFirst(':');
|
||||
command.Replace( "\r", "");
|
||||
command.Replace( "\n", "");
|
||||
@@ -177,16 +221,23 @@ int OTM_Language::LoadLanguage(const wxString &name, bool save)
|
||||
CheckEntry( command, msg, MenuLanguage)
|
||||
CheckEntry( command, msg, MenuHelp)
|
||||
CheckEntry( command, msg, MenuAbout)
|
||||
CheckEntry( command, msg, MenuAcknowledgement)
|
||||
CheckEntry( command, msg, MenuAddGame)
|
||||
CheckEntry( command, msg, MenuDeleteGame)
|
||||
CheckEntry( command, msg, MainMenuGame)
|
||||
CheckEntry( command, msg, MenuLoadTemplate)
|
||||
CheckEntry( command, msg, MenuSaveTemplate)
|
||||
CheckEntry( command, msg, MenuSaveTemplateAs)
|
||||
CheckEntry( command, msg, MenuSetDefaultTemplate)
|
||||
CheckEntry( command, msg, MenuExit)
|
||||
CheckEntry( command, msg, MainMenuMain)
|
||||
CheckEntry( command, msg, MainMenuHelp)
|
||||
CheckEntry( command, msg, ButtonOpen)
|
||||
CheckEntry( command, msg, ButtonDirectory)
|
||||
CheckEntry( command, msg, ButtonUpdate)
|
||||
CheckEntry( command, msg, ButtonSave)
|
||||
CheckEntry( command, msg, ButtonReload)
|
||||
CheckEntry( command, msg, ChooseFile)
|
||||
CheckEntry( command, msg, ChooseDir)
|
||||
CheckEntry( command, msg, TextCtrlTemplate)
|
||||
CheckEntry( command, msg, CheckBoxSaveSingleTexture)
|
||||
CheckEntry( command, msg, CheckBoxSaveAllTextures)
|
||||
CheckEntry( command, msg, TextCtrlSavePath)
|
||||
@@ -198,6 +249,7 @@ int OTM_Language::LoadLanguage(const wxString &name, bool save)
|
||||
CheckEntry( command, msg, Error_FileNotSupported)
|
||||
CheckEntry( command, msg, Error_FktNotFound)
|
||||
CheckEntry( command, msg, Error_DLLNotFound)
|
||||
CheckEntry( command, msg, Error_AlreadyRunning)
|
||||
CheckEntry( command, msg, Error_Send)
|
||||
CheckEntry( command, msg, Error_KeyTwice)
|
||||
CheckEntry( command, msg, Error_NoSavePath)
|
||||
@@ -221,8 +273,6 @@ int OTM_Language::LoadLanguage(const wxString &name, bool save)
|
||||
}
|
||||
|
||||
delete [] buffer;
|
||||
|
||||
if (save) SaveCurrentLanguage();
|
||||
return 0;
|
||||
}
|
||||
#undef CheckEntry
|
||||
@@ -230,23 +280,32 @@ int OTM_Language::LoadLanguage(const wxString &name, bool save)
|
||||
|
||||
int OTM_Language::LoadDefault(void)
|
||||
{
|
||||
CurrentLanguage="English";
|
||||
|
||||
MenuLanguage = "Change Language";
|
||||
MenuHelp = "Help";
|
||||
MenuAbout = "About";
|
||||
MenuAcknowledgement = "Acknowledgement";
|
||||
MenuAddGame = "Add game";
|
||||
MenuDeleteGame = "Delete Game";
|
||||
MenuLoadTemplate = "Load template";
|
||||
MenuSaveTemplate = "Save template";
|
||||
MenuSaveTemplateAs = "Save template as ...";
|
||||
MenuSetDefaultTemplate = "Set template as default";
|
||||
MenuExit = "Exit";
|
||||
|
||||
MainMenuGame = "Game";
|
||||
MainMenuMain = "Main";
|
||||
MainMenuHelp = "Help";
|
||||
|
||||
ButtonOpen = "Open texture";
|
||||
ButtonOpen = "Open texture/package";
|
||||
ButtonDirectory = "Set save directory";
|
||||
ButtonUpdate = "Update";
|
||||
ButtonSave = "save settings";
|
||||
ButtonReload = "Update (reload)";
|
||||
|
||||
ChooseFile = "Choose a texture file";
|
||||
ChooseFile = "Choose a file";
|
||||
ChooseDir = "Choose a directory";
|
||||
|
||||
TextCtrlTemplate = "Template: ";
|
||||
CheckBoxSaveSingleTexture = "Save single texture";
|
||||
CheckBoxSaveAllTextures = "Save all textures";
|
||||
TextCtrlSavePath = "Save path:";
|
||||
@@ -263,6 +322,7 @@ int OTM_Language::LoadDefault(void)
|
||||
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_AlreadyRunning = "An other instance of OpenTexMod is already running.";
|
||||
|
||||
Error_Send = "Could not send to game.";
|
||||
Error_KeyTwice = "You have assigned the same key twice.";
|
||||
|
||||
+15
-7
@@ -25,29 +25,38 @@ class OTM_Language
|
||||
{
|
||||
public:
|
||||
OTM_Language(void);
|
||||
OTM_Language(const wxString &name);
|
||||
|
||||
|
||||
int LoadLanguage(const wxString &name, bool save=true);
|
||||
int LoadLanguage(const wxString &name);
|
||||
int GetLanguages(wxArrayString &lang);
|
||||
int GetHelpMessage(wxString &help);
|
||||
wxString GetCurrentLanguage(void) {return CurrentLanguage;}
|
||||
|
||||
wxString MenuLanguage;
|
||||
wxString MenuHelp;
|
||||
wxString MenuAbout;
|
||||
wxString MenuAcknowledgement;
|
||||
wxString MenuAddGame;
|
||||
wxString MenuDeleteGame;
|
||||
wxString MenuLoadTemplate;
|
||||
wxString MenuSaveTemplate;
|
||||
wxString MenuSaveTemplateAs;
|
||||
wxString MenuSetDefaultTemplate;
|
||||
wxString MenuExit;
|
||||
|
||||
wxString MainMenuGame;
|
||||
wxString MainMenuMain;
|
||||
wxString MainMenuHelp;
|
||||
|
||||
wxString ButtonOpen;
|
||||
wxString ButtonDirectory;
|
||||
wxString ButtonUpdate;
|
||||
wxString ButtonSave;
|
||||
wxString ButtonReload;
|
||||
|
||||
wxString ChooseFile;
|
||||
wxString ChooseDir;
|
||||
|
||||
wxString TextCtrlTemplate;
|
||||
wxString CheckBoxSaveSingleTexture;
|
||||
wxString CheckBoxSaveAllTextures;
|
||||
wxString TextCtrlSavePath;
|
||||
@@ -64,6 +73,8 @@ public:
|
||||
wxString Error_FileNotSupported;
|
||||
wxString Error_FktNotFound;
|
||||
wxString Error_DLLNotFound;
|
||||
wxString Error_AlreadyRunning;
|
||||
|
||||
wxString Error_Send;
|
||||
wxString Error_KeyTwice;
|
||||
wxString Error_NoSavePath;
|
||||
@@ -93,9 +104,6 @@ public:
|
||||
wxString LastError;
|
||||
|
||||
private:
|
||||
int LoadCurrentLanguage(void);
|
||||
int SaveCurrentLanguage(void);
|
||||
|
||||
int LoadDefault(void);
|
||||
int LoadKeys(void);
|
||||
|
||||
@@ -103,7 +111,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
extern OTM_Language *Language;
|
||||
|
||||
|
||||
#endif /* OTM_LANGUAGE_H_ */
|
||||
|
||||
+11
-3
@@ -79,14 +79,20 @@ enum
|
||||
ID_Button_Open = wxID_HIGHEST,
|
||||
ID_Button_Path,
|
||||
ID_Button_Update,
|
||||
ID_Button_Save,
|
||||
ID_Menu_Pref,
|
||||
ID_Menu_Quit,
|
||||
ID_Button_Reload,
|
||||
//ID_Button_Save,
|
||||
//ID_Menu_Pref,
|
||||
ID_Menu_Exit,
|
||||
ID_Menu_Lang,
|
||||
ID_Menu_Help,
|
||||
ID_Menu_About,
|
||||
ID_Menu_Acknowledgement,
|
||||
ID_Menu_AddGame,
|
||||
ID_Menu_DeleteGame,
|
||||
ID_Menu_LoadTemplate,
|
||||
ID_Menu_SaveTemplate,
|
||||
ID_Menu_SaveTemplateAs,
|
||||
ID_Menu_SetDefaultTemplate,
|
||||
ID_Add_Game,
|
||||
ID_Delete_Game,
|
||||
ID_Button_Texture, //this entry must be the last!!
|
||||
@@ -95,6 +101,8 @@ enum
|
||||
#define ABORT_SERVER L"OTM_Abort_Server"
|
||||
#define OTM_d3d9_dll L"OTM_d3d9.dll"
|
||||
|
||||
#include "OTM_AddTexture.h"
|
||||
#include "OTM_Settings.h"
|
||||
#include "OTM_Language.h"
|
||||
#include "OTM_Event.h"
|
||||
#include "OTM_Client.h"
|
||||
|
||||
+181
-66
@@ -20,8 +20,11 @@ along with OpenTexMod. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "OTM_Main.h"
|
||||
|
||||
OTM_Sender::OTM_Sender(PipeStruct &pipe, OTM_Language &lang) : Pipe(pipe), Language(lang)
|
||||
|
||||
OTM_Sender::OTM_Sender(PipeStruct &pipe) : Pipe(pipe)
|
||||
{
|
||||
OldTextures = NULL;
|
||||
OldTexturesNum = 0;
|
||||
try {Buffer = new char[BIG_BUFSIZE];}
|
||||
catch (...) {Buffer=NULL;}
|
||||
}
|
||||
@@ -32,25 +35,25 @@ OTM_Sender::~OTM_Sender(void)
|
||||
}
|
||||
|
||||
|
||||
int OTM_Sender::Send( const OTM_GameInfo &game, const OTM_GameInfo &game_old, wxArrayString *comments)
|
||||
int OTM_Sender::Send( const OTM_GameInfo &game, const OTM_GameInfo &game_old, bool force, wxArrayString *comments)
|
||||
{
|
||||
LastError.Empty();
|
||||
int key = game.GetKeyBack();
|
||||
if (key>=0 && key!=game_old.GetKeyBack())
|
||||
{
|
||||
key = Language.KeyValues[key];
|
||||
key = Language->KeyValues[key];
|
||||
SendKey( key, CONTROL_KEY_BACK);
|
||||
}
|
||||
key = game.GetKeySave();
|
||||
if (key>=0 && key!=game_old.GetKeySave())
|
||||
{
|
||||
key = Language.KeyValues[key];
|
||||
key = Language->KeyValues[key];
|
||||
SendKey( key, CONTROL_KEY_SAVE);
|
||||
}
|
||||
key = game.GetKeyNext();
|
||||
if (key>=0 && key!=game_old.GetKeyNext())
|
||||
{
|
||||
key = Language.KeyValues[key];
|
||||
key = Language->KeyValues[key];
|
||||
SendKey( key, CONTROL_KEY_NEXT);
|
||||
}
|
||||
|
||||
@@ -80,8 +83,7 @@ int OTM_Sender::Send( const OTM_GameInfo &game, const OTM_GameInfo &game_old, wx
|
||||
if (path!=game_old.GetSavePath()) SendPath(path);
|
||||
|
||||
|
||||
// the rest of this function is not optimized !!
|
||||
if (game.GetNumberOfFiles()<=0)
|
||||
if (game.GetNumberOfFiles()<=0 && OldTexturesNum==0 && OldTextures==NULL)
|
||||
{
|
||||
if (LastError.Len()>0) return 1;
|
||||
else return 0;
|
||||
@@ -91,34 +93,145 @@ int OTM_Sender::Send( const OTM_GameInfo &game, const OTM_GameInfo &game_old, wx
|
||||
|
||||
game.GetFiles( files);
|
||||
int num = files.GetCount();
|
||||
if (comments!=NULL)
|
||||
bool *checked = NULL;
|
||||
if (num>0)
|
||||
{
|
||||
if (GetMemory(checked, num)) {LastError << Language->Error_Memory; return -1;}
|
||||
game.GetChecked( checked, num);
|
||||
}
|
||||
|
||||
AddTextureClass *tex = NULL;//new AddTextureClass[num+OldTexturesNum];
|
||||
if (GetMemory( tex, num+OldTexturesNum)) {LastError << Language->Error_Memory; return -1;}
|
||||
wxString comment;
|
||||
|
||||
if (force || OldTexturesNum==0 || OldTextures==NULL)
|
||||
{
|
||||
//reload everything
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
OTM_File file( files[i]);
|
||||
file.GetComment(comment);
|
||||
tex[i].Comment = comment;
|
||||
|
||||
tex[i].Add = checked[i];
|
||||
tex[i].Force = true;
|
||||
tex[i].File = files[i];
|
||||
if (file.GetContent( tex[i], checked[i]))
|
||||
{
|
||||
LastError << file.LastError;
|
||||
file.LastError.Empty();
|
||||
}
|
||||
}
|
||||
|
||||
// append all packages, which was added but (maybe) are no longer in the list
|
||||
int append = 0;
|
||||
if (OldTexturesNum>0 && OldTextures!=NULL)
|
||||
{
|
||||
for (int i=0; i<OldTexturesNum; i++)
|
||||
{
|
||||
if (OldTextures[i].Add)
|
||||
{
|
||||
bool del = true;
|
||||
for (int j=0; j<num; j++) if (OldTextures[i].File==tex[j].File) {del=false; break;}
|
||||
if (del)
|
||||
{
|
||||
tex[num+append].InheriteMemory(OldTextures[i]);
|
||||
tex[num+append].Add = false;
|
||||
tex[num+append].Force = true;
|
||||
append++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SendTextures( num+append, tex);
|
||||
}
|
||||
else
|
||||
{
|
||||
//search for same packages to avoid reload from disk
|
||||
|
||||
//first step: maybe the order did not change
|
||||
int pos = 0;
|
||||
bool *hit=NULL;
|
||||
if (GetMemory( hit, OldTexturesNum, false)) {LastError << Language->Error_Memory; return -1;}
|
||||
for (int i=0; i<num && i<OldTexturesNum; i++)
|
||||
{
|
||||
if (OldTextures[i].File == files[i])
|
||||
{
|
||||
tex[i].InheriteMemory(OldTextures[i]);
|
||||
tex[i].Force = false;
|
||||
hit[i] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//second step: if the order changed -> looking brute force
|
||||
for (int i=pos; i<num; i++) for (int j=pos; j<OldTexturesNum; j++)
|
||||
{
|
||||
if (!hit[j] && OldTextures[j].File == files[i])
|
||||
{
|
||||
tex[i].InheriteMemory(OldTextures[j]);
|
||||
tex[i].Force = false;
|
||||
hit[j] = true;
|
||||
}
|
||||
}
|
||||
|
||||
//next step, set Add to true or false and load packages, which are not loaded
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
tex[i].Add = checked[i];
|
||||
|
||||
if (tex[i].Len==0 || (tex[i].Add && !tex[i].Loaded) )
|
||||
{
|
||||
OTM_File file( files[i]);
|
||||
file.GetComment(comment);
|
||||
tex[i].Comment = comment;
|
||||
|
||||
tex[i].Add = checked[i];
|
||||
tex[i].Force = true;
|
||||
tex[i].File = files[i];
|
||||
file.GetContent( tex[i], tex[i].Add);
|
||||
}
|
||||
}
|
||||
|
||||
// append all packages, which was added but are no longer in the list
|
||||
int append = 0;
|
||||
if (OldTexturesNum!=0 && OldTextures!=NULL)
|
||||
{
|
||||
for (int j=pos; j<OldTexturesNum; j++)
|
||||
{
|
||||
if (!hit[j] && OldTextures[j].Add)
|
||||
{
|
||||
bool del = true;
|
||||
for (int i=pos; i<num; i++) if (OldTextures[j].File==tex[i].File) {del=false; break;}
|
||||
if (del)
|
||||
{
|
||||
tex[num+append].InheriteMemory(OldTextures[j]);
|
||||
tex[num+append].Add = false;
|
||||
tex[num+append].Force = true;
|
||||
append++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SendTextures( num+append, tex);
|
||||
}
|
||||
if (checked!=NULL) delete [] checked;
|
||||
|
||||
if (comments!=NULL && num>0)
|
||||
{
|
||||
comments->Empty();
|
||||
comments->Alloc(num);
|
||||
for (int i=0; i<num; i++) comments->Add(tex[i].Comment);
|
||||
}
|
||||
bool *checked = new bool [num];
|
||||
game.GetChecked( checked, num);
|
||||
|
||||
AddTextureClass *tex = new AddTextureClass[num];
|
||||
wxString comment;
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
OTM_File file( Language, files[i]);
|
||||
if (comments!=NULL)
|
||||
{
|
||||
file.GetComment(comment);
|
||||
comments->Add(comment);
|
||||
}
|
||||
if (file.GetContent( &tex[i], checked[i], true))
|
||||
{
|
||||
LastError << file.LastError;
|
||||
file.LastError.Empty();
|
||||
}
|
||||
}
|
||||
SendTextures( num, tex);
|
||||
if (OldTextures!=NULL) delete [] OldTextures;
|
||||
|
||||
delete [] checked;
|
||||
delete [] tex;
|
||||
OldTexturesNum = num;
|
||||
OldTextures = tex;
|
||||
|
||||
if (LastError.Len()>0) return 1;
|
||||
else return 0;
|
||||
@@ -149,54 +262,56 @@ int OTM_Sender::SendSaveSingleTexture(bool val)
|
||||
}
|
||||
|
||||
|
||||
|
||||
int OTM_Sender::SendTextures(unsigned int num, AddTextureClass *tex)
|
||||
{
|
||||
if (Buffer==NULL) return (RETURN_NO_MEMORY);
|
||||
|
||||
int count = 0;
|
||||
for (unsigned int i=0u; i<num; i++) count+=tex[i].Num;
|
||||
unsigned long *hash = new unsigned long[count];
|
||||
count = 0;
|
||||
|
||||
MsgStruct *msg;
|
||||
int pos = 0;
|
||||
for (unsigned int i=0u; i<num; i++) for (unsigned int j=0u; j<tex[i].Num; j++)
|
||||
{
|
||||
bool hit = false;
|
||||
unsigned long temp_hash = tex[i].Hash[j];
|
||||
for (int h=0; h<count; h++) if (temp_hash == hash[h]) {hit= true; break;}
|
||||
if (hit) continue;
|
||||
|
||||
if (tex[i].Size[j]+sizeof(MsgStruct)+pos>BIG_BUFSIZE)
|
||||
if (tex[i].Force || !tex[i].Add || !tex[i].WasAdded[j])
|
||||
// if force==true we must update
|
||||
// tex[i].Add!=true we can always remove, cause removing does take time in the render thread
|
||||
// if tex[i].Add==true and WasAdded[j]!=true this texture was not loaded but should be loaded, so maybe we can load it now
|
||||
{
|
||||
if (int ret = SendToGame( Buffer, pos)) return ret;
|
||||
pos = 0;
|
||||
}
|
||||
bool hit = false;
|
||||
unsigned long temp_hash = tex[i].Hash[j];
|
||||
for (unsigned int ii=0u; ii<i && !hit; ii++) for (unsigned int jj=0u; jj<tex[ii].Num && !hit; jj++) if (temp_hash==tex[ii].Hash[jj]) hit=true;
|
||||
for (unsigned int jj=0u; jj<j && !hit; jj++) if (temp_hash==tex[i].Hash[jj]) hit=true;
|
||||
if (hit) continue;
|
||||
|
||||
hash[count++] = temp_hash;
|
||||
unsigned int size = tex[i].Size[j];
|
||||
msg = (MsgStruct*) &Buffer[pos];
|
||||
msg->Hash = temp_hash;
|
||||
msg->Value = size;
|
||||
pos += sizeof(MsgStruct);
|
||||
|
||||
if (tex[i].Add[j])
|
||||
{
|
||||
if (tex[i].Force[j]) msg->Control = CONTROL_FORCE_RELOAD_TEXTURE_DATA;
|
||||
else msg->Control = CONTROL_ADD_TEXTURE_DATA;
|
||||
|
||||
char* temp = tex[i].Textures[j];
|
||||
if (temp!=NULL)
|
||||
if (tex[i].Size[j]+sizeof(MsgStruct)+pos>BIG_BUFSIZE)
|
||||
{
|
||||
for (unsigned int l=0; l<size; l++) Buffer[pos+l] = temp[l];
|
||||
pos+=size;
|
||||
if (int ret = SendToGame( Buffer, pos)) return ret;
|
||||
pos = 0;
|
||||
}
|
||||
unsigned int size = tex[i].Size[j];
|
||||
msg = (MsgStruct*) &Buffer[pos];
|
||||
msg->Hash = temp_hash;
|
||||
msg->Value = size;
|
||||
pos += sizeof(MsgStruct);
|
||||
|
||||
if (tex[i].Add)
|
||||
{
|
||||
msg->Control = CONTROL_FORCE_RELOAD_TEXTURE_DATA; //we always force because whether force==true
|
||||
//or Add==true && WasAdded[j]!=true which means it is loaded the first time, or in previous loads it could not be loaded
|
||||
//because an other texture was send with the same hash, in all cases forcing is the best choice (atm)
|
||||
char* temp = tex[i].Textures[j];
|
||||
if (temp!=NULL)
|
||||
{
|
||||
for (unsigned int l=0; l<size; l++) Buffer[pos+l] = temp[l];
|
||||
pos+=size;
|
||||
}
|
||||
tex[i].WasAdded[j] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg->Control = CONTROL_REMOVE_TEXTURE;
|
||||
tex[i].WasAdded[j] = false;
|
||||
}
|
||||
}
|
||||
else msg->Control = CONTROL_REMOVE_TEXTURE;
|
||||
}
|
||||
delete [] hash;
|
||||
|
||||
if (pos) if (int ret = SendToGame( Buffer, pos)) return ret;
|
||||
|
||||
if (LastError.Len()>0) return 1;
|
||||
@@ -252,10 +367,10 @@ int OTM_Sender::SendToGame( void *msg, unsigned long len)
|
||||
if (len==0) return (RETURN_BAD_ARGUMENT);
|
||||
unsigned long num;
|
||||
|
||||
if (Pipe.Out==INVALID_HANDLE_VALUE) {LastError << Language.Error_NoPipe; return -1;}
|
||||
if (Pipe.Out==INVALID_HANDLE_VALUE) {LastError << Language->Error_NoPipe; return -1;}
|
||||
bool ret = WriteFile( Pipe.Out, (const void*) msg, len, &num, NULL);
|
||||
if (!ret || len!=num) {LastError << Language.Error_WritePipe; return -1;}
|
||||
if (!FlushFileBuffers(Pipe.Out)) {LastError << Language.Error_FlushPipe; return -1;}
|
||||
if (!ret || len!=num) {LastError << Language->Error_WritePipe; return -1;}
|
||||
if (!FlushFileBuffers(Pipe.Out)) {LastError << Language->Error_FlushPipe; return -1;}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ along with OpenTexMod. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef OTM_SENDER_H_
|
||||
#define OTM_SENDER_H_
|
||||
|
||||
#include "OTM_Main.h"
|
||||
|
||||
|
||||
@@ -27,10 +28,10 @@ along with OpenTexMod. If not, see <http://www.gnu.org/licenses/>.
|
||||
class OTM_Sender
|
||||
{
|
||||
public:
|
||||
OTM_Sender(PipeStruct &pipe, OTM_Language &lang);
|
||||
OTM_Sender(PipeStruct &pipe);
|
||||
~OTM_Sender(void);
|
||||
|
||||
int Send( const OTM_GameInfo &game, const OTM_GameInfo &game_old, wxArrayString *comments=NULL);
|
||||
int Send( const OTM_GameInfo &game, const OTM_GameInfo &game_old, bool force=false, wxArrayString *comments=NULL);
|
||||
|
||||
wxString LastError;
|
||||
|
||||
@@ -54,7 +55,8 @@ private:
|
||||
int AddContent( char* buffer, unsigned int len, const char* pw, AddTextureClass *tex, bool add, bool force);
|
||||
|
||||
PipeStruct &Pipe;
|
||||
OTM_Language &Language;
|
||||
AddTextureClass *OldTextures;
|
||||
int OldTexturesNum;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
This file is part of OpenTexMod.
|
||||
|
||||
|
||||
OpenTexMod 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.
|
||||
|
||||
OpenTexMod 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 OpenTexMod. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "OTM_Main.h"
|
||||
|
||||
|
||||
OTM_Settings::OTM_Settings(void)
|
||||
{
|
||||
XSize=600;
|
||||
YSize=400;
|
||||
Language="English";
|
||||
}
|
||||
|
||||
#define SETTINGS_FILE "OTM_Settings.txt"
|
||||
|
||||
int OTM_Settings::Load(void)
|
||||
{
|
||||
wxFile file;
|
||||
|
||||
if (!file.Access(SETTINGS_FILE, wxFile::read)) {return -1;}
|
||||
file.Open(SETTINGS_FILE, wxFile::read);
|
||||
if (!file.IsOpened()) return -1;
|
||||
|
||||
unsigned len = file.Length();
|
||||
|
||||
unsigned char* buffer;
|
||||
try {buffer = new unsigned char [len+2];}
|
||||
catch (...) {return -1;}
|
||||
|
||||
unsigned int result = file.Read( buffer, len);
|
||||
file.Close();
|
||||
|
||||
if (result != len) {delete [] buffer; return -1;}
|
||||
|
||||
wchar_t *buff = (wchar_t*)buffer;
|
||||
len/=2;
|
||||
buff[len]=0;
|
||||
|
||||
wxString content;
|
||||
content = buff;
|
||||
delete [] buffer;
|
||||
|
||||
wxStringTokenizer token( content, "\n");
|
||||
|
||||
int num = token.CountTokens();
|
||||
wxString line;
|
||||
wxString command;
|
||||
wxString value;
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
line = token.GetNextToken();
|
||||
command = line.BeforeFirst(':');
|
||||
value = line.AfterFirst(':');
|
||||
value.Replace( "\r", "");
|
||||
value.Replace( "\n", "");
|
||||
if (command == "Lang") Language = value;
|
||||
else if (command == "x_size")
|
||||
{
|
||||
long x;
|
||||
if (value.ToLong( &x)) XSize=x;
|
||||
}
|
||||
else if (command == "y_size")
|
||||
{
|
||||
long y;
|
||||
if (value.ToLong( &y)) YSize=y;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OTM_Settings::Save(void)
|
||||
{
|
||||
wxFile file;
|
||||
file.Open(SETTINGS_FILE, wxFile::write);
|
||||
if (!file.IsOpened()) return -1;
|
||||
|
||||
wxString content;
|
||||
|
||||
content = "Lang:";
|
||||
content << Language << "\n";
|
||||
file.Write( content.wc_str(), content.Len()*2);
|
||||
|
||||
content.Printf("x_size:%d\n", XSize);
|
||||
file.Write( content.wc_str(), content.Len()*2);
|
||||
|
||||
content.Printf("y_size:%d\n", YSize);
|
||||
file.Write( content.wc_str(), content.Len()*2);
|
||||
file.Close();
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
This file is part of OpenTexMod.
|
||||
|
||||
|
||||
OpenTexMod 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.
|
||||
|
||||
OpenTexMod 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 OpenTexMod. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef OTM_SETTINGS_H_
|
||||
#define OTM_SETTINGS_H_
|
||||
|
||||
|
||||
#include "OTM_Main.h"
|
||||
|
||||
class OTM_Settings
|
||||
{
|
||||
public:
|
||||
OTM_Settings(void);
|
||||
|
||||
|
||||
int XSize, YSize;
|
||||
wxString Language;
|
||||
|
||||
int Load(void);
|
||||
int Save(void);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* OTM_SETTINGS_H_ */
|
||||
@@ -18,7 +18,7 @@ darauf hinweisen.
|
||||
|
||||
Was kann OpenTexMod alpha V0.9?
|
||||
|
||||
-einzelne Texturen aus einem Spiel extrahieren und speichern (Die Zieltextur kann im Spiel geändert werden)
|
||||
-einzelne Texturen aus einem Spiel extrahieren und speichern (Die Zieltextur kann im Spiel geändert werden.)
|
||||
-alle Texturen aus einem Spiel extrahieren und speichern
|
||||
-Texturen in ein Spiel laden und Zieltexturen ersetzen
|
||||
-Support von zip-Dateien
|
||||
@@ -63,7 +63,7 @@ Wie bekomme ich OpenTexMod zum laufen?
|
||||
Es gibt zwei Wege wie OpenTexMod sich in die DirectX Verbindung einklinken kann:
|
||||
|
||||
1) (bevorzugt) Füge die Spiel-exe über das Menü Spiele->"Spiel hinzufügen" hinzu.
|
||||
Wenn du Steam verwendest, lies weiter unten nach.
|
||||
Für Steam siehe unten.
|
||||
|
||||
2) Kopiere die d3d9.dll (vom OpenTexMod Verzeichnis) in das Spiele Verzeichnis.
|
||||
Einige Spiele laden eine dll zuerst aus dem eigenen Verzeichnis bevor sie im
|
||||
@@ -77,12 +77,17 @@ OpenTexMod zu starten.
|
||||
Wenn das Spiel startet und alles glatt läuft, öffnet sich sofort ein neuer Tab in OpenTexMod.
|
||||
In diesem Tab kannst du nun das Spiel modden. Drücke den "Update" Button um
|
||||
die Einstellungen an das Spiel zu senden. Du kannst deine aktuellen Einstellungen auch
|
||||
speichern. Sie werden dann automatisch geladen und an das Spiel gesendet, wenn du
|
||||
dieses Spiel das nächste Mal startest.
|
||||
als ein Template speichern. Ein Template kann auch als Standard eingestellt werden.
|
||||
Es wird dann automatisch geladen und an das Spiel gesendet, wenn
|
||||
dieses Spiel das nächste Mal gestartet wird.
|
||||
|
||||
Um einen Mod zu laden, musst du das Häkchen vor den Namen setzen. Wenn du
|
||||
den Mod entladen willst, entferne das Häkchen und klicke auf "Update". Zurzeit
|
||||
werden die Mods nicht aus dem Spiel entladen, wenn du den "X" Button drückst.
|
||||
den Mod entladen willst, entferne das Häkchen und klicke auf "Update".
|
||||
|
||||
Der Update Button lädt nur Veränderungen (wenn Pakete aus der Liste entfernt
|
||||
wurden, du die Häkchen verändert hast oder sich die Reihenfolge geändert hat)
|
||||
Der "neu laden" Button erzwingt das Neuladen von Festplatte (z.B. wenn du die
|
||||
Texturen verändert hast).
|
||||
|
||||
Weil verschiedene Mods die gleiche Ziel-Textur verändern könnten, wird nur die
|
||||
Mod-Textur des ersten Mods berücksichtigt. Die Aktion dieses Mods (also Laden oder
|
||||
@@ -92,15 +97,6 @@ Ziel-Textur machen sollen.
|
||||
|
||||
Wie bekommt man OpenTexMod mit Steam zum Laufen?
|
||||
|
||||
OpenTexMod schaut auf den Namen der ausgeführten Spiel-Datei, nicht nach dem Verzeichnis.
|
||||
OpenTexMod schaut auf den Namen und auf das Verzeichnis der ausgeführten Spiel-exe.
|
||||
Daher solltest du nicht die steam.exe sondern die Spiel.exe hinzufügen.
|
||||
z.B.: Steam\SteamApps\acoount_name\portal\hl2.exe
|
||||
BTW: Dies würde auch alle anderen HalfLife 2 Spiele betreffen.
|
||||
|
||||
Wenn du deine Spiele-exe nicht finden kannst, schau im TaskManager nach und:
|
||||
1) füge sie per Hand hinzu: editiere unter Windows 7
|
||||
C:\Users\user_name\AppData\Roaming\OpenTexMod\OTM_DX9.txt
|
||||
oder:
|
||||
2) erstelle irgendwo eine Datei mit dem Namen der Spiele-exe und füge diese
|
||||
mithilfe des Menüs in OpenTexMod hinzu, anschließend kannst du diese
|
||||
Datei löschen.
|
||||
z.B.: C:\Steam\SteamApps\acoount_name\portal\hl2.exe
|
||||
@@ -57,8 +57,7 @@ How to get OpenTexMod work?
|
||||
There are two ways how OpenTexMod can intercept the DirectX connection:
|
||||
|
||||
1) (recommended) Add the games-binary through the menu Games->"Add game"
|
||||
If you want to get it work with steam, don't add the steam.exe but rather the game.exe.
|
||||
Once you have added the game, OpenTexMod will keep it in mind on further program start.
|
||||
For Steam see below.
|
||||
|
||||
2) Copy the d3d9.dll (from the OpenTexMod directory) into the game directory.
|
||||
Some games load a dll first from their own directory before they look up the system directory.
|
||||
@@ -71,12 +70,16 @@ the game through OpenTexMod.
|
||||
|
||||
If the game starts and all works fine, a new tab opens immediately in OpenTexMod.
|
||||
In this tab you can now mod the game. Press the "update" button to commit
|
||||
the changes to the game. You can also save your current settings. They will be loaded
|
||||
and committed automatically when you start the same game the next time.
|
||||
the changes to the game. You can also save your current settings as a template.
|
||||
One template can be set as default for a game, which will be loaded and
|
||||
and committed automatically when you start this game the next time.
|
||||
|
||||
To load a mod, you must set the check mark of the file. If you wish to unload a mod,
|
||||
just remove the check mark and click on update again. At the moment pressing the
|
||||
X button of a file will remove it from the list but won't unload the mod from the game.
|
||||
just remove the check mark and click on update again.
|
||||
|
||||
Clicking on update will only update the differences (if packages have been
|
||||
removed from the list, you toggled check marks or changed the order). The reload
|
||||
button forces to reload from disk (if you have edited the texture itself).
|
||||
|
||||
Due to the fact that different mods can modify the same target texture, only the
|
||||
mod-texture of the first file in the list is taken into account. The action of this file
|
||||
@@ -84,17 +87,8 @@ mod-texture of the first file in the list is taken into account. The action of t
|
||||
to do with their mod-textures.
|
||||
|
||||
|
||||
How to get OpenTexMod work together with steam?
|
||||
How to get OpenTexMod work together with Steam?
|
||||
|
||||
OpenTexMod looks only for the name of the executed binary and not of their working directory.
|
||||
OpenTexMod looks for the name and the path of the executed binary.
|
||||
Thus you shall not add the steam.exe but rather the game.exe
|
||||
e.g.: Steam\SteamApps\acoount_name\portal\hl2.exe
|
||||
This would also inject into all other HalfLife 2 games.
|
||||
|
||||
If you can't find your target binary, just look into the task manager for the binary
|
||||
and:
|
||||
1) add it by your self : edit under Windows 7
|
||||
C:\Users\user_name\AppData\Roaming\OpenTexMod\OTM_DX9.txt
|
||||
or:
|
||||
2) add somewhere on your disk an empty file with the name of the binary and
|
||||
add this file through the menu of OpenTexMod, afterwards you can delete this file.
|
||||
e.g.: C:\Steam\SteamApps\acoount_name\portal\hl2.exe
|
||||
@@ -0,0 +1,137 @@
|
||||
If you have created a language package and would like to add to the officially download, please send it to me.
|
||||
Email address and support can be found at http://code.google.com/p/texmod/
|
||||
|
||||
|
||||
The file name must match the wildcard OTM_LanguagePack_NAMEOFLANGUAGE.txt
|
||||
Format of an entry is divided into 3 parts: 1) Keyword directly followed by a colon, 2) message, and 3) end symbol "|"
|
||||
Restriction of the the message: do not use "|" within a message!!
|
||||
|
||||
You can also use utf-16LE encoding, but you have to label the file as OTM_LanguagePackU_NAMEOFLANGUAGE.txt
|
||||
|
||||
comments must start with an "#" and must end with |
|
||||
|
||||
e.g.
|
||||
|
||||
#
|
||||
|
||||
this is a comment
|
||||
|
||||
|
|
||||
|
||||
Example:
|
||||
|
||||
Keyword:
|
||||
|
||||
Message1 line1
|
||||
Message1 line2
|
||||
|
||||
|
|
||||
|
||||
Keyword2:Message2|
|
||||
Keyword3:Message3 line1
|
||||
Message3 line2|
|
||||
|
||||
|
||||
There is no need to include all keywords, since English is loaded each time as default and afterwards the entries are replaced.
|
||||
English itself is compiled into the OTM_GUI.exe, thus there exists no OTM_LanguagePack_English.txt.
|
||||
|
||||
The following list is an example of how an English package would look like (maybe not all keywords are present).
|
||||
|
||||
MenuHelp:
|
||||
Help|
|
||||
MenuAbout:
|
||||
About|
|
||||
MenuAcknowledgement:Acknowledgement|
|
||||
MenuAddGame:
|
||||
Add game|
|
||||
MenuDeleteGame:
|
||||
Delete Game|
|
||||
MenuLoadTemplate:Load template|
|
||||
MenuSaveTemplate:Save template|
|
||||
MenuSaveTemplateAs:Save template as ...|
|
||||
MenuSetDefaultTemplate:Set template as default|
|
||||
MenuExit:Exit|
|
||||
MainMenuMain:Main|
|
||||
MainMenuHelp:
|
||||
Help|
|
||||
ButtonOpen:
|
||||
Open texture|
|
||||
ButtonDirectory:
|
||||
save directory|
|
||||
ButtonUpdate:
|
||||
Update|
|
||||
ButtonReload:Update (reload)|
|
||||
ChooseFile:Choose a file|
|
||||
ChooseDir:
|
||||
Choose a directory|
|
||||
CheckBoxSaveSingleTexture:
|
||||
Save single texture|
|
||||
TextCtrlTemplate:Template: |
|
||||
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.
|
||||
Exit anyway?|
|
||||
NoComment:
|
||||
No comment.|
|
||||
Author:
|
||||
Author: |
|
||||
Error_FileNotSupported:
|
||||
This file type is not supported:|
|
||||
Error_DLLNotFound:
|
||||
Could not load the dll.
|
||||
The dll injection won't work.
|
||||
This might happen if D3DX9_43.dll is not installed on your system.
|
||||
Please install the newest DirectX End-User Runtime Web Installer.|
|
||||
Error_FktNotFound:
|
||||
Could not load function out of dll.
|
||||
The dll injection won't work.|
|
||||
Error_AlreadyRunning:An other instance of OpenTexMod is already running.|
|
||||
Error_Send:
|
||||
Could not send to game.|
|
||||
Error_KeyTwice:
|
||||
You assigned a 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):|
|
||||
Binary file not shown.
Binary file not shown.
+2
-2
@@ -44,7 +44,7 @@ UNICODE = 1
|
||||
MSLU = 0
|
||||
|
||||
# Type of compiled binaries [debug,release]
|
||||
BUILD = debug
|
||||
BUILD = release
|
||||
|
||||
# The target processor architecture must be specified when it is not X86.
|
||||
# This does not affect the compiler output, so you still need to make sure
|
||||
@@ -63,7 +63,7 @@ DEBUG_INFO = 1
|
||||
# Value of wxDEBUG_LEVEL. The default value is the same as 1 and means that all
|
||||
# but expensive assert checks are enabled, use 0 to completely remove debugging
|
||||
# code. [0,1,default]
|
||||
DEBUG_FLAG = 1
|
||||
DEBUG_FLAG = 0
|
||||
|
||||
# Link against debug (e.g. msvcrtd.dll) or release (msvcrt.dll) RTL?
|
||||
# Default is to use debug CRT if and only if BUILD==debug. [0,1,default]
|
||||
|
||||
@@ -38,7 +38,9 @@ MINIMAL_OBJECTS = \
|
||||
$(OBJS)\OTM_Server.o \
|
||||
$(OBJS)\OTM_Client.o \
|
||||
$(OBJS)\OTM_File.o \
|
||||
$(OBJS)\OTM_Sender.o \
|
||||
$(OBJS)\OTM_Sender.o \
|
||||
$(OBJS)\OTM_Settings.o \
|
||||
$(OBJS)\OTM_AddTexture.o \
|
||||
$(OBJS)\OTM_Language.o
|
||||
|
||||
### Conditionally set variables: ###
|
||||
@@ -261,6 +263,12 @@ $(OBJS)\OTM_File.o: ./OTM_File.cpp
|
||||
$(OBJS)\OTM_Sender.o: ./OTM_Sender.cpp
|
||||
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\OTM_Settings.o: ./OTM_Settings.cpp
|
||||
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\OTM_AddTexture.o: ./OTM_AddTexture.cpp
|
||||
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\OTM_Language.o: ./OTM_Language.cpp
|
||||
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
|
||||
@@ -41,6 +41,8 @@ MINIMAL_OBJECTS = \
|
||||
$(OBJS)\OTM_Client.obj \
|
||||
$(OBJS)\OTM_File.obj \
|
||||
$(OBJS)\OTM_Sender.obj \
|
||||
$(OBJS)\OTM_Settings.obj \
|
||||
$(OBJS)\OTM_AddTexture.obj \
|
||||
$(OBJS)\OTM_Language.obj
|
||||
MINIMAL_RESOURCES = \
|
||||
$(OBJS)\OTM_GUI.res
|
||||
@@ -385,5 +387,11 @@ $(OBJS)\OTM_File.obj: .\OTM_File.cpp
|
||||
$(OBJS)\OTM_Sender.obj: .\OTM_Sender.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\OTM_Sender.cpp
|
||||
|
||||
$(OBJS)\OTM_Settings.obj: .\OTM_Settings.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\OTM_Settings.cpp
|
||||
|
||||
$(OBJS)\OTM_AddTexture.obj: .\OTM_AddTexture.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\OTM_AddTexture.cpp
|
||||
|
||||
$(OBJS)\OTM_Language.obj: .\OTM_Language.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\OTM_Language.cpp
|
||||
|
||||
Reference in New Issue
Block a user