mirror of
https://github.com/gwdevhub/gMod.git
synced 2026-07-24 03:56:34 +00:00
fab93611c1
- OTM_TextureClient::MergeUpdate: force reload does now switch the correct texture (previously it lead to a crash) - OTM_TextureClient::MergeUpdate: volume and cube textures are now loaded (if they were not loaded before) - OTM_TextureServer: if textures were added more than once, they could not be deleted correctly - OTM_Sender::SendTextures: if texture were loaded, but get unloaded due to a rearranging of the list, they are now marked correctly as unloaded Improvements: - OTM keeps in mind the actual window position - added a MORE_TEXTURES flag for the pipe comunication: if more data is written to the pipe, than the size of the buffer, the Mainloop of the OTM_TextureServer will wait for the rest of the date before it prepare an update for the OTM_TextureClient. - added the last missing texture formats of D3DFORMAT (except two formats)
130 lines
2.9 KiB
C++
130 lines
2.9 KiB
C++
/*
|
|
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;
|
|
XPos = -1;
|
|
YPos = -1;
|
|
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;
|
|
}
|
|
else if (command == "x_pos")
|
|
{
|
|
long x;
|
|
if (value.ToLong( &x)) XPos=x;
|
|
}
|
|
else if (command == "y_pos")
|
|
{
|
|
long y;
|
|
if (value.ToLong( &y)) YPos=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);
|
|
|
|
content.Printf("x_pos:%d\n", XPos);
|
|
file.Write( content.wc_str(), content.Len()*2);
|
|
|
|
content.Printf("y_pos:%d\n", YPos);
|
|
file.Write( content.wc_str(), content.Len()*2);
|
|
file.Close();
|
|
|
|
return 0;
|
|
}
|
|
|
|
|