mirror of
https://github.com/gwdevhub/gMod.git
synced 2026-07-16 07:29:30 +00:00
uMod2 Alpha Version: known bugs: I disabled the remove device function inside the gui, because something in the event handling goes terrible wrong.
Implemented a some new features.
This commit is contained in:
+202
-173
@@ -24,263 +24,296 @@ along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
uMod_GameInfo::uMod_GameInfo(void)
|
||||
{
|
||||
Checked = NULL;
|
||||
NumberOfChecked = 0;
|
||||
LengthOfChecked = 0;
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
uMod_GameInfo::~uMod_GameInfo(void)
|
||||
{
|
||||
if (Checked!=NULL) delete [] Checked;
|
||||
}
|
||||
|
||||
void uMod_GameInfo::Init(void)
|
||||
{
|
||||
myShowCollPane = false;
|
||||
|
||||
SaveSingleTexture = false;
|
||||
SaveAllTextures = false;
|
||||
myShowSingleTextureString = false;
|
||||
mySupportTPF = false;
|
||||
|
||||
KeyBack = -1;
|
||||
KeySave = -1;
|
||||
KeyNext = -1;
|
||||
FontColour[0]=255;FontColour[1]=0;FontColour[2]=0;
|
||||
TextureColour[0]=0;TextureColour[1]=255;TextureColour[2]=0;
|
||||
NumberOfChecked = 0;
|
||||
FontColour[0]=255;FontColour[1]=0;FontColour[2]=0;FontColour[3]=255;
|
||||
TextureColour[0]=0;TextureColour[1]=255;TextureColour[2]=0;TextureColour[3]=255;
|
||||
|
||||
myUseSizeFilter = false;
|
||||
myHeightMin = 1;
|
||||
myHeightMax = 1;
|
||||
myWidthMin = 1;
|
||||
myWidthMax = 1;
|
||||
myDepthMin = 1;
|
||||
myDepthMax = 1;
|
||||
|
||||
myUseFormatFilter = false;
|
||||
myFormatFilter = 0u;
|
||||
myFileFormat = uMod_D3DXIFF_DDS;
|
||||
|
||||
SavePath.Empty();
|
||||
OpenPath.Empty();
|
||||
Files.Empty();
|
||||
}
|
||||
|
||||
int uMod_GameInfo::SaveToFile( const wxString &file_name)
|
||||
int uMod_GameInfo::SaveToString( wxString &content )
|
||||
{
|
||||
wxFile file;
|
||||
content.Empty();
|
||||
|
||||
//if (!file.Access(name, wxFile::write)) return -1;
|
||||
file.Open(file_name, wxFile::write);
|
||||
if (!file.IsOpened()) {return -1;}
|
||||
wxString temp;
|
||||
|
||||
temp.Printf( "ShowCollPane:%d\n", myShowCollPane);
|
||||
content << temp;
|
||||
|
||||
wxString content;
|
||||
if (SavePath.Len()>0)
|
||||
{
|
||||
content.Printf( L"SavePath:%ls\n", SavePath.wc_str());
|
||||
file.Write( content.char_str(), content.Len());
|
||||
temp.Printf( "SavePath:%ls\n", SavePath.wc_str());
|
||||
content << temp;
|
||||
}
|
||||
|
||||
if (OpenPath.Len()>0)
|
||||
{
|
||||
content.Printf( L"OpenPath:%ls\n", OpenPath.wc_str());
|
||||
file.Write( content.char_str(), content.Len());
|
||||
temp.Printf( "OpenPath:%ls\n", OpenPath.wc_str());
|
||||
content << temp;
|
||||
}
|
||||
|
||||
content.Printf( L"SaveAllTextures:%d\nSaveSingleTexture:%d\n", SaveAllTextures, SaveSingleTexture);
|
||||
file.Write( content.char_str(), content.Len());
|
||||
temp.Printf( "SaveAllTextures:%d\nSaveSingleTexture:%d\n", SaveAllTextures, SaveSingleTexture);
|
||||
content << temp;
|
||||
|
||||
temp.Printf( "ShowSingleTextureString:%d\n", myShowSingleTextureString);
|
||||
content << temp;
|
||||
|
||||
temp.Printf( "SupportTPF:%d\n", mySupportTPF);
|
||||
content << temp;
|
||||
|
||||
if (KeyBack>=0)
|
||||
{
|
||||
content.Printf( L"KeyBack:%d\n", KeyBack);
|
||||
file.Write( content.char_str(), content.Len());
|
||||
temp.Printf( "KeyBack:%d\n", KeyBack);
|
||||
content << temp;
|
||||
}
|
||||
if (KeySave>=0)
|
||||
{
|
||||
content.Printf( L"KeySave:%d\n", KeySave);
|
||||
file.Write( content.char_str(), content.Len());
|
||||
temp.Printf( "KeySave:%d\n", KeySave);
|
||||
content << temp;
|
||||
}
|
||||
if (KeyNext>=0)
|
||||
{
|
||||
content.Printf( L"KeyNext:%d\n", KeyNext);
|
||||
file.Write( content.char_str(), content.Len());
|
||||
temp.Printf( "KeyNext:%d\n", KeyNext);
|
||||
content << temp;
|
||||
}
|
||||
temp.Printf("UseSizeFilter:%d\n", myUseSizeFilter);
|
||||
content << temp;
|
||||
temp.Printf( "Height:%d,%d\n", myHeightMin, myHeightMax);
|
||||
content << temp;
|
||||
temp.Printf( "Width:%d,%d\n", myWidthMin, myWidthMax);
|
||||
content << temp;
|
||||
temp.Printf( "Depth:%d,%d\n", myDepthMin, myDepthMax);
|
||||
content << temp;
|
||||
|
||||
content.Printf( L"FontColour:%d,%d,%d\n", FontColour[0], FontColour[1], FontColour[2]);
|
||||
file.Write( content.char_str(), content.Len());
|
||||
content.Printf( L"TextureColour:%d,%d,%d\n", TextureColour[0], TextureColour[1], TextureColour[2]);
|
||||
file.Write( content.char_str(), content.Len());
|
||||
|
||||
int num = Files.GetCount();
|
||||
|
||||
for (int i=0; i<num; i++)
|
||||
temp.Printf("UseFormatFilter:%d\n", myUseFormatFilter);
|
||||
content << temp;
|
||||
if (myFormatFilter>0u)
|
||||
{
|
||||
if (i<NumberOfChecked)
|
||||
{
|
||||
if (Checked[i]) content.Printf( L"Add_true:%ls\n", Files[i].wc_str());
|
||||
else content.Printf( L"Add_false:%ls\n", Files[i].wc_str());
|
||||
}
|
||||
else content.Printf( L"Add_true:%ls\n", Files[i].wc_str());
|
||||
file.Write( content.char_str(), content.Len());
|
||||
temp.Printf( "FormatFilter:%lu\n", myFormatFilter);
|
||||
content << temp;
|
||||
}
|
||||
if (myFileFormat>0u)
|
||||
{
|
||||
temp.Printf( "FileFormat:%lu\n", myFileFormat);
|
||||
content << temp;
|
||||
}
|
||||
|
||||
file.Close();
|
||||
temp.Printf( L"FontColour:%u,%u,%u,%u\n", FontColour[0], FontColour[1], FontColour[2],FontColour[3]);
|
||||
content << temp;
|
||||
temp.Printf( L"TextureColour:%u,%u,%u,%u\n", TextureColour[0], TextureColour[1], TextureColour[2], TextureColour[3]);
|
||||
content << temp;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uMod_GameInfo::LoadFromFile( const wxString &file_name)
|
||||
int uMod_GameInfo::LoadFromString( const wxString &content)
|
||||
{
|
||||
Init();
|
||||
if (file_name.Len()==0) return -1;
|
||||
|
||||
wxFile file;
|
||||
if (!file.Access(file_name, wxFile::read)) return -1;
|
||||
file.Open(file_name, wxFile::read);
|
||||
if (!file.IsOpened()) {return -1;}
|
||||
|
||||
unsigned len = file.Length();
|
||||
|
||||
unsigned char* buffer;
|
||||
try {buffer = new unsigned char [len+1];}
|
||||
catch (...) {return -1;}
|
||||
|
||||
unsigned int result = file.Read( buffer, len);
|
||||
file.Close();
|
||||
|
||||
if (result != len) {delete [] buffer; return -1;}
|
||||
|
||||
buffer[len]=0;
|
||||
|
||||
wxString content;
|
||||
content = buffer;
|
||||
delete [] buffer;
|
||||
|
||||
wxStringTokenizer token( content, "\n");
|
||||
|
||||
int num = token.CountTokens();
|
||||
|
||||
if (LengthOfChecked<num)
|
||||
{
|
||||
if (Checked!=NULL) delete [] Checked;
|
||||
try {Checked = new bool [num+100];}
|
||||
catch (...) {Checked=NULL;LengthOfChecked=0; return -1;}
|
||||
LengthOfChecked = num+100;
|
||||
}
|
||||
|
||||
wxString line;
|
||||
wxString command;
|
||||
wxString temp;
|
||||
Files.Alloc(num);
|
||||
//Files.Alloc(num);
|
||||
for (int i=0; i<num; i++)
|
||||
{
|
||||
line = token.GetNextToken();
|
||||
command = line.BeforeFirst(':');
|
||||
|
||||
|
||||
if (command == L"Add_true")
|
||||
{
|
||||
Checked[NumberOfChecked++] = true;
|
||||
Files.Add(line.AfterFirst(':'));
|
||||
}
|
||||
else if (command == L"Add_false")
|
||||
{
|
||||
Checked[NumberOfChecked++] = false;
|
||||
Files.Add(line.AfterFirst(':'));
|
||||
}
|
||||
else if (command == L"SavePath") SavePath = line.AfterFirst(':');
|
||||
else if (command == L"OpenPath") OpenPath = line.AfterFirst(':');
|
||||
else if (command == L"SaveAllTextures")
|
||||
if (command == "ShowCollPane")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
if (temp[0]=='0') SaveAllTextures = false;
|
||||
if (temp.Len()>0 && temp[0]=='0') myShowCollPane = false;
|
||||
else myShowCollPane = true;
|
||||
}
|
||||
else if (command == "SavePath") SavePath = line.AfterFirst(':');
|
||||
else if (command == "OpenPath") OpenPath = line.AfterFirst(':');
|
||||
else if (command == "SaveAllTextures")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
if (temp.Len()>0 && temp[0]=='0') SaveAllTextures = false;
|
||||
else SaveAllTextures = true;
|
||||
}
|
||||
else if (command == L"SaveSingleTexture")
|
||||
else if (command == "SaveSingleTexture")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
if (temp[0]=='0') SaveSingleTexture = false;
|
||||
if (temp.Len()>0 && temp[0]=='0') SaveSingleTexture = false;
|
||||
else SaveSingleTexture = true;
|
||||
}
|
||||
else if (command == L"KeyBack")
|
||||
else if (command == "ShowSingleTextureString")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
if (temp.Len()>0 && temp[0]=='0') myShowSingleTextureString = false;
|
||||
else myShowSingleTextureString = true;
|
||||
}
|
||||
else if (command == "SupportTPF")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
if (temp.Len()>0 && temp[0]=='0') mySupportTPF = false;
|
||||
else mySupportTPF = true;
|
||||
}
|
||||
else if (command == "KeyBack")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
long key;
|
||||
if (temp.ToLong( &key)) KeyBack = key;
|
||||
else KeyBack = -1;
|
||||
}
|
||||
else if (command == L"KeySave")
|
||||
else if (command == "KeySave")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
long key;
|
||||
if (temp.ToLong( &key)) KeySave = key;
|
||||
else KeySave = -1;
|
||||
}
|
||||
else if (command == L"KeyNext")
|
||||
else if (command == "KeyNext")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
long key;
|
||||
if (temp.ToLong( &key)) KeyNext = key;
|
||||
else KeyNext = -1;
|
||||
}
|
||||
else if (command == L"FontColour")
|
||||
else if (command == "UseSizeFilter")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
temp = temp.BeforeFirst(',');
|
||||
long colour;
|
||||
if (temp.ToLong( &colour)) FontColour[0] = colour;
|
||||
else FontColour[0] = 255;
|
||||
temp = line.AfterFirst(':');
|
||||
temp = temp.AfterFirst(',');
|
||||
temp = temp.BeforeFirst(',');
|
||||
if (temp.ToLong( &colour)) FontColour[1] = colour;
|
||||
else FontColour[1] = 0;
|
||||
temp = line.AfterFirst(':');
|
||||
temp = temp.AfterLast(',');
|
||||
if (temp.ToLong( &colour)) FontColour[2] = colour;
|
||||
else FontColour[2] = 0;
|
||||
if (temp.Len()>0 && temp[0]=='0') myUseSizeFilter = false;
|
||||
else myUseSizeFilter = true;
|
||||
}
|
||||
else if (command == L"TextureColour")
|
||||
else if (command == "Height")
|
||||
{
|
||||
line = line.AfterFirst(':');
|
||||
temp = line.Before(',');
|
||||
long val;
|
||||
if (temp.ToLong( &val)) myHeightMin = val;
|
||||
else myHeightMin = 1;
|
||||
temp = line.After(',');
|
||||
if (temp.ToLong( &val)) myHeightMax = val;
|
||||
else myHeightMax = 1;
|
||||
}
|
||||
else if (command == "Width")
|
||||
{
|
||||
line = line.AfterFirst(':');
|
||||
temp = line.Before(',');
|
||||
long val;
|
||||
if (temp.ToLong( &val)) myWidthMin = val;
|
||||
else myWidthMin = 1;
|
||||
temp = line.After(',');
|
||||
if (temp.ToLong( &val)) myWidthMax = val;
|
||||
else myWidthMax = 1;
|
||||
}
|
||||
else if (command == "Depth")
|
||||
{
|
||||
line = line.AfterFirst(':');
|
||||
temp = line.Before(',');
|
||||
long val;
|
||||
if (temp.ToLong( &val)) myDepthMin = val;
|
||||
else myDepthMin = 1;
|
||||
temp = line.After(',');
|
||||
if (temp.ToLong( &val)) myDepthMax = val;
|
||||
else myDepthMax = 1;
|
||||
}
|
||||
else if (command == "UseFormatFilter")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
temp = temp.BeforeFirst(',');
|
||||
long colour;
|
||||
if (temp.ToLong( &colour)) TextureColour[0] = colour;
|
||||
else TextureColour[0] = 0;
|
||||
temp = line.AfterFirst(':');
|
||||
temp = temp.AfterFirst(',');
|
||||
temp = temp.BeforeFirst(',');
|
||||
if (temp.ToLong( &colour)) TextureColour[1] = colour;
|
||||
else TextureColour[1] = 255;
|
||||
temp = line.AfterFirst(':');
|
||||
temp = temp.AfterLast(',');
|
||||
if (temp.ToLong( &colour)) TextureColour[2] = colour;
|
||||
else TextureColour[2] = 0;
|
||||
if (temp.Len()>0 && temp[0]=='0') myUseFormatFilter = false;
|
||||
else myUseFormatFilter = true;
|
||||
}
|
||||
else if (command == "FormatFilter")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
unsigned long val;
|
||||
if (temp.ToULong( &val)) myFormatFilter = val;
|
||||
else myFormatFilter = 0u;
|
||||
}
|
||||
else if (command == "FileFormat")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
unsigned long val;
|
||||
if (temp.ToULong( &val)) myFileFormat = val;
|
||||
else myFileFormat = 0u;
|
||||
}
|
||||
else if (command == "ShowSingleTextureString")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
if (temp.Len()>0 && temp[0]=='0') myShowSingleTextureString = false;
|
||||
else myShowSingleTextureString = true;
|
||||
}
|
||||
else if (command == "FontColour")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
|
||||
/*
|
||||
if (NumberOfChecked>=LengthOfChecked)
|
||||
{
|
||||
bool *t_bool;
|
||||
try {t_bool = new bool [LengthOfChecked+100];}
|
||||
catch (...) {return -1;}
|
||||
for (int i=0; i<LengthOfChecked; i++) t_bool[i]=Checked[i];
|
||||
delete [] Checked;
|
||||
Checked = t_bool;
|
||||
LengthOfChecked +=100;
|
||||
wxStringTokenizer col( temp, ",");
|
||||
|
||||
int num_col = col.CountTokens();
|
||||
for (int i=0; i<num_col && i<4; i++)
|
||||
{
|
||||
temp = col.GetNextToken();
|
||||
long colour;
|
||||
if (temp.ToLong( &colour)) FontColour[i] = colour;
|
||||
}
|
||||
}
|
||||
else if (command == "TextureColour")
|
||||
{
|
||||
temp = line.AfterFirst(':');
|
||||
|
||||
wxStringTokenizer col( temp, ",");
|
||||
|
||||
int num_col = col.CountTokens();
|
||||
for (int i=0; i<num_col && i<4; i++)
|
||||
{
|
||||
temp = col.GetNextToken();
|
||||
long colour;
|
||||
if (temp.ToLong( &colour)) TextureColour[i] = colour;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uMod_GameInfo::GetChecked( bool* array, int num) const
|
||||
{
|
||||
for (int i=0; i<num && i<NumberOfChecked; i++) array[i] = Checked[i];
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uMod_GameInfo::SetChecked( bool* array, int num)
|
||||
{
|
||||
if (num>LengthOfChecked)
|
||||
if (SaveAllTextures && SaveSingleTexture)
|
||||
{
|
||||
if (Checked!=NULL) delete [] Checked;
|
||||
try {Checked = new bool [num+100];}
|
||||
catch (...) {Checked=NULL; LengthOfChecked = 0; return -1;}
|
||||
LengthOfChecked = num+100;
|
||||
SaveAllTextures = false;
|
||||
SaveSingleTexture = false;
|
||||
}
|
||||
for (int i=0; i<num; i++) Checked[i] = array[i];
|
||||
NumberOfChecked = num;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int uMod_GameInfo::SetSaveSingleTexture(bool val)
|
||||
{
|
||||
SaveSingleTexture = val;
|
||||
@@ -293,18 +326,10 @@ int uMod_GameInfo::SetSaveAllTextures(bool val)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void uMod_GameInfo::SetFiles(const wxArrayString &files)
|
||||
{
|
||||
Files = files;
|
||||
}
|
||||
|
||||
void uMod_GameInfo::GetFiles( wxArrayString &files) const
|
||||
{
|
||||
files = Files;
|
||||
}
|
||||
|
||||
uMod_GameInfo& uMod_GameInfo::operator = (const uMod_GameInfo &rhs)
|
||||
{
|
||||
myShowCollPane = rhs.myShowCollPane;
|
||||
|
||||
SaveSingleTexture = rhs.SaveSingleTexture;
|
||||
SaveAllTextures = rhs.SaveAllTextures;
|
||||
|
||||
@@ -312,21 +337,25 @@ uMod_GameInfo& uMod_GameInfo::operator = (const uMod_GameInfo &rhs)
|
||||
KeySave = rhs.KeySave;
|
||||
KeyNext = rhs.KeyNext;
|
||||
|
||||
if (LengthOfChecked<rhs.LengthOfChecked)
|
||||
{
|
||||
if (Checked!=NULL) delete [] Checked;
|
||||
Checked = new bool [rhs.LengthOfChecked];
|
||||
LengthOfChecked = rhs.LengthOfChecked;
|
||||
}
|
||||
NumberOfChecked = rhs.NumberOfChecked;
|
||||
for (int i=0; i<NumberOfChecked; i++) Checked[i] = rhs.Checked[i];
|
||||
myUseSizeFilter = rhs.myUseSizeFilter;
|
||||
myHeightMin = rhs.myHeightMin;
|
||||
myHeightMax = rhs.myHeightMax;
|
||||
myWidthMin = rhs.myWidthMin;
|
||||
myWidthMax = rhs.myWidthMax;
|
||||
myDepthMin = rhs.myDepthMin;
|
||||
myDepthMax = rhs.myDepthMax;
|
||||
|
||||
myUseFormatFilter = rhs.myUseFormatFilter;
|
||||
myFormatFilter = rhs.myFormatFilter;
|
||||
myFileFormat = rhs.myFileFormat;
|
||||
|
||||
myShowSingleTextureString = rhs.myShowSingleTextureString;
|
||||
|
||||
for (int i=0; i<4; i++) FontColour[i]=rhs.FontColour[i];
|
||||
for (int i=0; i<4; i++) TextureColour[i]=rhs.TextureColour[i];
|
||||
|
||||
SavePath = rhs.SavePath;
|
||||
OpenPath = rhs.OpenPath;
|
||||
Files = rhs.Files;
|
||||
|
||||
for (int i=0; i<3; i++) FontColour[i]=rhs.FontColour[i];
|
||||
for (int i=0; i<3; i++) TextureColour[i]=rhs.TextureColour[i];
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user