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:
code@koerner-de.net
2012-07-15 18:59:03 +00:00
parent d99107a919
commit 0bc7eebede
69 changed files with 7975 additions and 2393 deletions
-284
View File
@@ -1,284 +0,0 @@
# =========================================================================
# This makefile was generated by
# Bakefile 0.2.1 (http://bakefile.sourceforge.net)
# Do not modify, all changes will be overwritten!
# =========================================================================
include config.gcc
# -------------------------------------------------------------------------
# Do not modify the rest of this file!
# -------------------------------------------------------------------------
### Variables: ###
CPPDEPS = -MT$@ -MF$@.d -MD
WX_RELEASE_NODOT = 29
OBJS = \
obj
OBJS_exe = \
bin
WX_DIR = D:\Programme\wxWidgets-2.9.2
LIBDIRNAME = $(WX_DIR)\lib\gcc_$(LIBTYPE_SUFFIX)$(CFG)
SETUPHDIR = \
$(LIBDIRNAME)\$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)
MINIMAL_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG_2) $(__THREADSFLAG) \
$(GCCFLAGS) -DHAVE_W32API_H -D__WXMSW__ $(__WXUNIV_DEFINE_p) \
$(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
$(__THREAD_DEFINE_p) $(__UNICODE_DEFINE_p) $(__MSLU_DEFINE_p) \
$(__GFXCTX_DEFINE_p) -I$(SETUPHDIR) -I$(WX_DIR)\include -W -Wall -Wextra -I. \
$(__DLLFLAG_p) -DNOPCH $(__RTTIFLAG_5) \
$(__EXCEPTIONSFLAG_6) -Wno-ctor-dtor-privacy $(CPPFLAGS) $(CXXFLAGS)
MINIMAL_OBJECTS = \
$(OBJS)\uMod_rc.o \
$(OBJS)\unzip.o \
$(OBJS)\uMod_DirectInjection.o \
$(OBJS)\uMod_GUI.o \
$(OBJS)\uMod_GameInfo.o \
$(OBJS)\uMod_GamePage.o \
$(OBJS)\uMod_Server.o \
$(OBJS)\uMod_Client.o \
$(OBJS)\uMod_File.o \
$(OBJS)\uMod_Sender.o \
$(OBJS)\uMod_Settings.o \
$(OBJS)\uMod_AddTexture.o \
$(OBJS)\uMod_Language.o
### Conditionally set variables: ###
ifeq ($(GCC_VERSION),2.95)
GCCFLAGS = -fvtable-thunks
endif
ifeq ($(USE_GUI),0)
PORTNAME = base
endif
ifeq ($(USE_GUI),1)
PORTNAME = msw
endif
ifeq ($(BUILD),debug)
ifeq ($(DEBUG_FLAG),default)
WXDEBUGFLAG = d
endif
endif
ifeq ($(DEBUG_FLAG),1)
WXDEBUGFLAG = d
endif
ifeq ($(UNICODE),1)
WXUNICODEFLAG = u
endif
ifeq ($(WXUNIV),1)
WXUNIVNAME = univ
endif
ifeq ($(SHARED),1)
WXDLLFLAG = dll
endif
ifeq ($(SHARED),0)
LIBTYPE_SUFFIX = lib
endif
ifeq ($(SHARED),1)
LIBTYPE_SUFFIX = dll
endif
ifeq ($(MONOLITHIC),0)
EXTRALIBS_FOR_BASE =
endif
ifeq ($(MONOLITHIC),1)
EXTRALIBS_FOR_BASE =
endif
ifeq ($(BUILD),debug)
__OPTIMIZEFLAG_2 = -O0 -g
endif
ifeq ($(BUILD),release)
__OPTIMIZEFLAG_2 = -O2
endif
ifeq ($(USE_RTTI),0)
__RTTIFLAG_5 = -fno-rtti
endif
ifeq ($(USE_RTTI),1)
__RTTIFLAG_5 =
endif
ifeq ($(USE_EXCEPTIONS),0)
__EXCEPTIONSFLAG_6 = -fno-exceptions
endif
ifeq ($(USE_EXCEPTIONS),1)
__EXCEPTIONSFLAG_6 =
endif
ifeq ($(WXUNIV),1)
__WXUNIV_DEFINE_p = -D__WXUNIVERSAL__
endif
ifeq ($(WXUNIV),1)
__WXUNIV_DEFINE_p_1 = --define __WXUNIVERSAL__
endif
ifeq ($(BUILD),debug)
ifeq ($(DEBUG_FLAG),default)
__DEBUG_DEFINE_p = -D__WXDEBUG__
endif
endif
ifeq ($(DEBUG_FLAG),1)
__DEBUG_DEFINE_p = -D__WXDEBUG__
endif
ifeq ($(BUILD),debug)
ifeq ($(DEBUG_FLAG),default)
__DEBUG_DEFINE_p_1 = --define __WXDEBUG__
endif
endif
ifeq ($(DEBUG_FLAG),1)
__DEBUG_DEFINE_p_1 = --define __WXDEBUG__
endif
ifeq ($(USE_EXCEPTIONS),0)
__EXCEPTIONS_DEFINE_p = -DwxNO_EXCEPTIONS
endif
ifeq ($(USE_EXCEPTIONS),0)
__EXCEPTIONS_DEFINE_p_1 = --define wxNO_EXCEPTIONS
endif
ifeq ($(USE_RTTI),0)
__RTTI_DEFINE_p = -DwxNO_RTTI
endif
ifeq ($(USE_RTTI),0)
__RTTI_DEFINE_p_1 = --define wxNO_RTTI
endif
ifeq ($(USE_THREADS),0)
__THREAD_DEFINE_p = -DwxNO_THREADS
endif
ifeq ($(USE_THREADS),0)
__THREAD_DEFINE_p_1 = --define wxNO_THREADS
endif
ifeq ($(UNICODE),1)
__UNICODE_DEFINE_p = -D_UNICODE
endif
ifeq ($(UNICODE),1)
__UNICODE_DEFINE_p_1 = --define _UNICODE
endif
ifeq ($(MSLU),1)
__MSLU_DEFINE_p = -DwxUSE_UNICODE_MSLU=1
endif
ifeq ($(MSLU),1)
__MSLU_DEFINE_p_1 = --define wxUSE_UNICODE_MSLU=1
endif
ifeq ($(USE_GDIPLUS),1)
__GFXCTX_DEFINE_p = -DwxUSE_GRAPHICS_CONTEXT=1
endif
ifeq ($(USE_GDIPLUS),1)
__GFXCTX_DEFINE_p_1 = --define wxUSE_GRAPHICS_CONTEXT=1
endif
ifeq ($(SHARED),1)
__DLLFLAG_p = -DWXUSINGDLL
endif
ifeq ($(SHARED),1)
__DLLFLAG_p_1 = --define WXUSINGDLL
endif
ifeq ($(MONOLITHIC),0)
__WXLIB_CORE_p = \
-lwx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core
endif
ifeq ($(MONOLITHIC),0)
__WXLIB_BASE_p = \
-lwxbase$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)
endif
ifeq ($(MONOLITHIC),1)
__WXLIB_MONO_p = \
-lwx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)
endif
ifeq ($(USE_GUI),1)
__LIB_TIFF_p = -lwxtiff$(WXDEBUGFLAG)
endif
ifeq ($(USE_GUI),1)
__LIB_JPEG_p = -lwxjpeg$(WXDEBUGFLAG)
endif
ifeq ($(USE_GUI),1)
__LIB_PNG_p = -lwxpng$(WXDEBUGFLAG)
endif
ifeq ($(MSLU),1)
__UNICOWS_LIB_p = -lunicows
endif
ifeq ($(USE_GDIPLUS),1)
__GDIPLUS_LIB_p = -lgdiplus
endif
ifeq ($(BUILD),debug)
ifeq ($(DEBUG_INFO),default)
__DEBUGINFO = -g
endif
endif
ifeq ($(BUILD),release)
ifeq ($(DEBUG_INFO),default)
__DEBUGINFO =
endif
endif
ifeq ($(DEBUG_INFO),0)
__DEBUGINFO =
endif
ifeq ($(DEBUG_INFO),1)
__DEBUGINFO = -g
endif
ifeq ($(USE_THREADS),0)
__THREADSFLAG =
endif
ifeq ($(USE_THREADS),1)
__THREADSFLAG = -mthreads
endif
all: $(OBJS)
$(OBJS):
-if not exist $(OBJS) mkdir $(OBJS)
all: $(OBJS_exe)
$(OBJS_exe):
-if not exist $(OBJS_exe) mkdir $(OBJS_exe)
### Targets: ###
all: $(OBJS_exe)\uMod.exe
clean:
-if exist $(OBJS)\*.o del $(OBJS)\*.o
-if exist $(OBJS)\*.d del $(OBJS)\*.d
-if exist $(OBJS_exe)\uMod.exe del $(OBJS_exe)\uMod.exe
$(OBJS_exe)\uMod.exe: $(MINIMAL_OBJECTS) $(OBJS)\uMod_rc.o
$(CXX) -o $@ $(MINIMAL_OBJECTS) $(LDFLAGS) $(__DEBUGINFO) $(__THREADSFLAG) -L$(LIBDIRNAME) -Wl,--subsystem,windows -mwindows $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) -lwxzlib$(WXDEBUGFLAG) -lwxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG) -lwxexpat$(WXDEBUGFLAG) $(EXTRALIBS_FOR_BASE) $(__UNICOWS_LIB_p) $(__GDIPLUS_LIB_p) -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lodbc32
$(OBJS)\uMod_rc.o: uMod.rc uMod.ico
windres --use-temp-file -i $< -o $@
$(OBJS)\unzip.o: ./unzip.cpp
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\uMod_DirectInjection.o: ./uMod_DirectInjection.cpp
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\uMod_GUI.o: ./uMod_GUI.cpp
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\uMod_GameInfo.o: ./uMod_GameInfo.cpp
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\uMod_GamePage.o: ./uMod_GamePage.cpp
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\uMod_Server.o: ./uMod_Server.cpp
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\uMod_Client.o: ./uMod_Client.cpp
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\uMod_File.o: ./uMod_File.cpp
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\uMod_Sender.o: ./uMod_Sender.cpp
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\uMod_Settings.o: ./uMod_Settings.cpp
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\uMod_AddTexture.o: ./uMod_AddTexture.cpp
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\uMod_Language.o: ./uMod_Language.cpp
$(CXX) -c -o $@ $(MINIMAL_CXXFLAGS) $(CPPDEPS) $<
.PHONY: all clean
# Dependencies tracking:
-include $(OBJS)/*.d
+47 -15
View File
@@ -18,7 +18,7 @@ OBJS = \
obj
OBJS_exe = \
bin
WX_DIR = D:\Programme\wxWidgets-2.9.2
WX_DIR = D:\Programme\wxWidgets-2.9.3
LIBDIRNAME = \
$(WX_DIR)\lib\$(COMPILER_PREFIX)$(DIR_SUFFIX_CPU)_$(LIBTYPE_SUFFIX)$(CFG)
SETUPHDIR = \
@@ -37,6 +37,7 @@ MINIMAL_OBJECTS = \
$(OBJS)\uMod_DirectInjection.obj \
$(OBJS)\uMod_GUI.obj \
$(OBJS)\uMod_GameInfo.obj \
$(OBJS)\uMod_MiniPanels.obj \
$(OBJS)\uMod_GamePage.obj \
$(OBJS)\uMod_Server.obj \
$(OBJS)\uMod_Client.obj \
@@ -44,10 +45,30 @@ MINIMAL_OBJECTS = \
$(OBJS)\uMod_Sender.obj \
$(OBJS)\uMod_Settings.obj \
$(OBJS)\uMod_AddTexture.obj \
$(OBJS)\uMod_TreeView.obj \
$(OBJS)\uMod_ModElement.obj \
$(OBJS)\uMod_Language.obj
MINIMAL_RESOURCES = \
$(OBJS)\uMod_GUI.res
HEADERS = \
uMod_AddTexture.h \
uMod_Client.h \
uMod_DirectInjection.h \
uMod_Event.h \
uMod_File.h \
uMod_GameInfo.h \
uMod_MiniPanels.h \
uMod_GamePage.h \
uMod_GUI.h \
uMod_Language.h \
uMod_Main.h \
uMod_ModElement.h \
uMod_Sender.h \
uMod_Server.h \
uMod_Settings.h \
uMod_TreeView.h
### Conditionally set variables: ###
!if "$(USE_GUI)" == "0"
@@ -306,6 +327,10 @@ __DLLFLAG_p = /DWXUSINGDLL
__DLLFLAG_p_1 = /d WXUSINGDLL
!endif
!if "$(MONOLITHIC)" == "0"
__WXLIB_ADV_p = \
wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_adv.lib
!endif
!if "$(MONOLITHIC)" == "0"
__WXLIB_CORE_p = \
wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core.lib
!endif
@@ -355,47 +380,54 @@ clean:
$(OBJS_exe)\uMod.exe: $(MINIMAL_OBJECTS) $(OBJS)\uMod_GUI.res
link /NOLOGO /OUT:$@ $(__DEBUGINFO_1) /pdb:"$(OBJS)\uMod_GUI.pdb" $(__DEBUGINFO_2) $(LINK_TARGET_CPU) /LIBPATH:$(LIBDIRNAME) /SUBSYSTEM:WINDOWS $(____CAIRO_LIBDIR_FILENAMES_p) $(LDFLAGS) @<<
$(MINIMAL_OBJECTS) $(MINIMAL_RESOURCES) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__UNICOWS_LIB_p) $(__CAIRO_LIB_p) kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib
$(MINIMAL_OBJECTS) $(MINIMAL_RESOURCES) $(__WXLIB_ADV_p) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__UNICOWS_LIB_p) $(__CAIRO_LIB_p) kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib
<<
$(OBJS)\uMod_GUI.res: uMod.rc
rc /fo$@ /d WIN32 $(____DEBUGRUNTIME_3_p_1) $(__NO_VC_CRTDBG_p_1) /d __WXMSW__ $(__WXUNIV_DEFINE_p_1) $(__DEBUG_DEFINE_p_1) $(__NDEBUG_DEFINE_p_1) $(__EXCEPTIONS_DEFINE_p_1) $(__RTTI_DEFINE_p_1) $(__THREAD_DEFINE_p_1) $(__UNICODE_DEFINE_p_1) $(__MSLU_DEFINE_p_1) /i $(SETUPHDIR) /i . $(__DLLFLAG_p_1) /d _WINDOWS /d NOPCH uMod.rc
#$(OBJS)\display_display.obj: .\display.cpp
# $(CXX) /c /nologo /TP /Fo$@ $(DISPLAY_CXXFLAGS) .\display.cpp
$(OBJS)\unzip.obj: .\unzip.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\unzip.cpp
$(OBJS)\uMod_DirectInjection.obj: .\uMod_DirectInjection.cpp
$(OBJS)\uMod_DirectInjection.obj: .\uMod_DirectInjection.cpp $(HEADERS)
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_DirectInjection.cpp
$(OBJS)\uMod_GUI.obj: .\uMod_GUI.cpp
$(OBJS)\uMod_GUI.obj: .\uMod_GUI.cpp $(HEADERS)
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_GUI.cpp
$(OBJS)\uMod_GameInfo.obj: .\uMod_GameInfo.cpp
$(OBJS)\uMod_GameInfo.obj: .\uMod_GameInfo.cpp $(HEADERS)
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_GameInfo.cpp
$(OBJS)\uMod_GamePage.obj: .\uMod_GamePage.cpp
$(OBJS)\uMod_MiniPanels.obj: .\uMod_MiniPanels.cpp $(HEADERS)
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_MiniPanels.cpp
$(OBJS)\uMod_GamePage.obj: .\uMod_GamePage.cpp $(HEADERS)
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_GamePage.cpp
$(OBJS)\uMod_Server.obj: .\uMod_Server.cpp
$(OBJS)\uMod_Server.obj: .\uMod_Server.cpp $(HEADERS)
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_Server.cpp
$(OBJS)\uMod_Client.obj: .\uMod_Client.cpp
$(OBJS)\uMod_Client.obj: .\uMod_Client.cpp $(HEADERS)
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_Client.cpp
$(OBJS)\uMod_File.obj: .\uMod_File.cpp
$(OBJS)\uMod_File.obj: .\uMod_File.cpp $(HEADERS)
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_File.cpp
$(OBJS)\uMod_Sender.obj: .\uMod_Sender.cpp
$(OBJS)\uMod_Sender.obj: .\uMod_Sender.cpp $(HEADERS)
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_Sender.cpp
$(OBJS)\uMod_Settings.obj: .\uMod_Settings.cpp
$(OBJS)\uMod_Settings.obj: .\uMod_Settings.cpp $(HEADERS)
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_Settings.cpp
$(OBJS)\uMod_AddTexture.obj: .\uMod_AddTexture.cpp
$(OBJS)\uMod_AddTexture.obj: .\uMod_AddTexture.cpp $(HEADERS)
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_AddTexture.cpp
$(OBJS)\uMod_Language.obj: .\uMod_Language.cpp
$(OBJS)\uMod_TreeView.obj: .\uMod_TreeView.cpp $(HEADERS)
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_TreeView.cpp
$(OBJS)\uMod_ModElement.obj: .\uMod_ModElement.cpp $(HEADERS)
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_ModElement.cpp
$(OBJS)\uMod_Language.obj: .\uMod_Language.cpp $(HEADERS)
$(CXX) /c /nologo /TP /Fo$@ $(MINIMAL_CXXFLAGS) .\uMod_Language.cpp
+15 -12
View File
@@ -61,7 +61,7 @@ void* uMod_Client::Entry(void)
{
unsigned int pos=0;
MsgStruct *commands;
bool update_textures = false;
//bool update_textures = false;
while (pos<=size-sizeof(MsgStruct))
{
@@ -72,18 +72,20 @@ void* uMod_Client::Entry(void)
{
case CONTROL_ADD_CLIENT:
{
uMod_Event event( uMod_EVENT_TYPE, ID_Add_Device);
event.SetValue(commands->Value);
event.SetClient(this);
wxPostEvent( MainFrame, event);
uMod_Event *event = new uMod_Event( uMod_EVENT_TYPE, ID_Add_Device);
event->SetValue(commands->Value);
event->SetClient(this);
wxQueueEvent( MainFrame, (wxEvent*) event);
//wxPostEvent( MainFrame, event);
break;
}
case CONTROL_REMOVE_CLIENT:
{
uMod_Event event( uMod_EVENT_TYPE, ID_Delete_Device);
event.SetValue(commands->Value);
event.SetClient(this);
wxPostEvent( MainFrame, event);
uMod_Event *event = new uMod_Event( uMod_EVENT_TYPE, ID_Delete_Device);
event->SetValue(commands->Value);
event->SetClient(this);
wxQueueEvent( MainFrame, (wxEvent*) event);
//wxPostEvent( MainFrame, event);
break;
}
case CONTROL_GAME_EXIT:
@@ -105,9 +107,10 @@ void* uMod_Client::Entry(void)
CloseHandle(Pipe.Out);
Pipe.Out = INVALID_HANDLE_VALUE;
uMod_Event event( uMod_EVENT_TYPE, ID_Delete_Game);
event.SetClient(this);
wxPostEvent( MainFrame, event);
uMod_Event *event = new uMod_Event( uMod_EVENT_TYPE, ID_Delete_Game);
event->SetClient(this);
wxQueueEvent( MainFrame, (wxEvent*) event);
//wxPostEvent( MainFrame, event);
return NULL;
}
+6 -6
View File
@@ -29,20 +29,20 @@ BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EVENT_TYPE( uMod_EVENT_TYPE, -1)
END_DECLARE_EVENT_TYPES()
class uMod_Event : public wxCommandEvent
class uMod_Event : public wxThreadEvent
{
public:
uMod_Event( wxEventType commandType = uMod_EVENT_TYPE, int id = 0 )
: wxCommandEvent(commandType, id) { }
: wxThreadEvent(commandType, id) { }
virtual ~uMod_Event(void) {}
// You *must* copy here the data to be transported
uMod_Event( const uMod_Event &event )
: wxCommandEvent(event)
{ this->SetText( event.GetText());
: wxThreadEvent(event)
{ this->SetText( event.GetText().c_str());
Value=((uMod_Event&)event).GetValue();
PipeIn=((uMod_Event&)event).GetPipeIn(); PipeOut=((uMod_Event&)event).GetPipeOut();
Name=((uMod_Event&)event).GetName();
Name=((uMod_Event&)event).GetName().c_str();
Client=((uMod_Event&)event).GetClient();
}
@@ -59,7 +59,7 @@ public:
uMod_Client * GetClient(void) {return Client;}
void SetValue(int value) {Value=value;}
void SetName( wxString name) {Name=name;}
void SetName( wxString name) {Name=name.c_str();}
void SetPipeIn( HANDLE pipe) {PipeIn=pipe;}
void SetPipeOut( HANDLE pipe) {PipeOut=pipe;}
void SetClient( uMod_Client *client) {Client=client;}
+474 -159
View File
@@ -20,11 +20,19 @@ along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>
#include "unzip.h"
#ifdef __CDT_PARSER__
#define FindZipItem(...) 0
#define UnzipItem(...) 0
#define CloseZip(...) 0
#define GetZipItem(...) 0
#endif
uMod_File::uMod_File(void)
{
Loaded=false;
XORed=false;
FileInMemory=NULL;
FileInMemory=(char*)0;
MemoryLength=0u;
FileLen=0u;
}
@@ -33,7 +41,7 @@ uMod_File::uMod_File(const wxString &file)
{
Loaded=false;
XORed=false;
FileInMemory=NULL;
FileInMemory=(char*)0;
MemoryLength=0u;
FileLen=0u;
SetFile(file);
@@ -42,7 +50,7 @@ uMod_File::uMod_File(const wxString &file)
uMod_File::~uMod_File(void)
{
if (FileInMemory!=NULL) delete [] FileInMemory;
if (FileInMemory!=(char*)0) delete [] FileInMemory;
}
@@ -57,6 +65,14 @@ bool uMod_File::FileSupported(void)
}
bool uMod_File::SingleFile(void)
{
wxString file_type = FileName.AfterLast( '.');
if (file_type == L"dds") return true;
return false;
}
/*
int uMod_File::GetComment( wxString &tool_tip)
{
wxString file_type = FileName.AfterLast( '.');
@@ -103,6 +119,32 @@ int uMod_File::GetContent( AddTextureClass &tex, bool add)
return 0;
}
}
*/
int uMod_File::GetContent( uMod_TreeViewNode* node)
{
wxString file_type = FileName.AfterLast( '.');
if (file_type == L"zip")
{
AddZip( node);
}
else if (file_type == L"tpf")
{
AddTpf( node);
}
else if (file_type == L"dds")
{
AddFile( node);
}
else
{
LastError << Language->Error_FileNotSupported;
LastError << "\n" << FileName;
}
if (LastError.Len()>0) return -1;
return 0;
}
int uMod_File::ReadFile(void)
{
@@ -118,9 +160,9 @@ int uMod_File::ReadFile(void)
if (FileLen>=MemoryLength)
{
if (FileInMemory!=NULL) delete [] FileInMemory;
if (FileInMemory!=(char*)0) delete [] FileInMemory;
try {FileInMemory = new char [FileLen+1];}
catch (...) {FileInMemory=NULL; MemoryLength=0; FileLen=0; LastError << Language->Error_Memory; return -1;}
catch (...) {FileInMemory=(char*)0; MemoryLength=0; FileLen=0; LastError << Language->Error_Memory; return -1;}
MemoryLength = FileLen+1;
}
unsigned int result = dat.Read( FileInMemory, FileLen);
@@ -178,103 +220,244 @@ int uMod_File::UnXOR(void)
int uMod_File::GetCommentZip( wxString &tool_tip)
/*
int uMod_File::AddFile( uMod_TreeViewNode* node)
{
DWORD64 temp_hash;
wxString name = FileName.AfterLast( '_');
name = name.BeforeLast( '.');
if (!name.ToULongLong( &temp_hash, 16)) {LastError << Language->Error_Hash <<"\n" << FileName << "\n"; return -1;} // return if hash could not be extracted
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;}
uMod_TextureElement *texture = new uMod_TextureElement();
ZIPENTRY ze;
int index;
FindZipItem( ZIP_Handle, L"Comment.txt", false, &index, &ze);
if (index>=0) //if Comment.txt is present in the zip file
if (texture->Content().SetSize(FileLen))
{
char* comment;
int len = ze.unc_size;
try {comment=new char[len+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;}
comment[len]=0;
tool_tip = comment;
delete [] comment;
LastError << Language->Error_Memory;
texture->Release();
return -1;
}
else tool_tip = Language->NoComment;
char *data = texture->Content().Data();
CloseZip(ZIP_Handle);
for (unsigned int i=0; i<FileLen; i++) data[i] = FileInMemory[i];
texture->Hash() = temp_hash;
texture->Title() = FileName;
texture->Status() = uMod_TextureElement::Activate;
uMod_ModElement *element = new uMod_ModElement(uMod_ModElement::Group, uMod_ModElement::NONE);
element->Title() = FileName;
node = new uMod_TreeViewNode( (uMod_TreeViewNode*)0, element);
uMod_TreeViewNode *texture_node = new uMod_TreeViewNode( node, texture);
node->Append(texture_node);
texture->Release();
element->Release();
return 0;
}
*/
int uMod_File::AddFile( uMod_TreeViewNode* node)
{
DWORD64 temp_hash;
wxString name = FileName.AfterLast( '_');
name = name.BeforeLast( '.');
if (!name.ToULongLong( &temp_hash, 16)) {LastError << Language->Error_Hash <<"\n" << FileName << "\n"; return -1;} // return if hash could not be extracted
if (int ret = ReadFile()) return ret;
uMod_TextureElement *texture = new uMod_TextureElement();
if (texture->Content().SetSize(FileLen))
{
LastError << Language->Error_Memory;
texture->Release();
return -1;
}
char *data = texture->Content().Data();
for (unsigned int i=0; i<FileLen; i++) data[i] = FileInMemory[i];
texture->Hash() = temp_hash;
texture->File() = FileName;
texture->Status() = uMod_TextureElement::Activate;
uMod_TreeViewNode *texture_node = new uMod_TreeViewNode( node, texture);
node->Append(texture_node);
texture->Release();
return 0;
}
int uMod_File::GetCommentTpf( wxString &tool_tip)
int uMod_File::GetContentTemplate(const wxString &content, uMod_TreeViewNode* node)
{
uMod_TreeViewNode_ArrayPtr list_node;
if (uMod_TreeViewModel::String2Node( content, node, &list_node))
{
LastError << uMod_TreeViewModel::LastError << "\n" << FileName << "\n";
uMod_TreeViewModel::LastError.Empty();
return -1;
}
if (node->myElement->File().IsEmpty())
return GetContentTemplate_SF( list_node, node);
else
return GetContentTemplate_ZIP( list_node, node);
}
int uMod_File::GetContentTemplate_ZIP( const uMod_TreeViewNode_ArrayPtr &list_node, uMod_TreeViewNode* node)
{
SetFile(node->myElement->File());
if (!FileSupported())
{
LastError << Language->Error_FileNotSupported <<"\n" << FileName;
return -1;
}
if (int ret = ReadFile()) return ret;
wxString file_type = FileName.AfterLast( '.');
bool tpf = false;
if (file_type == L"tpf")
{
tpf = true;
UnXOR();
}
const char pw[] = {0x73, 0x2A, 0x63, 0x7D, 0x5F, 0x0A, 0xA6, 0xBD,
0x7D, 0x65, 0x7E, 0x67, 0x61, 0x2A, 0x7F, 0x7F,
0x74, 0x61, 0x67, 0x5B, 0x60, 0x70, 0x45, 0x74,
0x5C, 0x22, 0x74, 0x5D, 0x6E, 0x6A, 0x73, 0x41,
0x77, 0x6E, 0x46, 0x47, 0x77, 0x49, 0x0C, 0x4B,
0x46, 0x6F, '\0'};
ZIPENTRY ze;
int index = -1;
HZIP ZIP_Handle;
if (tpf) ZIP_Handle= OpenZip( FileInMemory, FileLen, pw);
else ZIP_Handle= OpenZip( FileInMemory, FileLen, (const char*)0);
if (ZIP_Handle==(HZIP)0)
{
LastError << Language->Error_Unzip <<"\n" << FileName;
return -1;
}
for (unsigned int i=0; i<list_node.GetCount(); i++)
{
if (list_node[i]->myElement->Type() == uMod_ModElement::Texture)
{
uMod_TextureElement *texture = (uMod_TextureElement*) list_node[i]->myElement;
wxString file = texture->File();
while ( (file[0]=='.' && (file[1]=='/' || file[1]=='\\')) || file[0]=='/' || file[0]=='\\') file.Remove(0,1);
FindZipItem( ZIP_Handle, file.wc_str(), false, &index, &ze); // look for texture
if (index>=0)
{
if (texture->Content().SetSize(ze.unc_size))
{
texture->Comment() = Language->Error_Memory;
continue;
}
char *data = texture->Content().Data();
ZRESULT rz = UnzipItem( ZIP_Handle, index, data, ze.unc_size);
if (rz!=ZR_OK && rz!=ZR_MORE)
{
texture->Content().SetSize(0);
texture->Comment() = Language->Error_Unzip;
texture->Comment() <<" : " << FileName << " ==>> " << file;
}
}
else
{
texture->Content().SetSize(0);
texture->Comment() = Language->Error_Unzip;
texture->Comment() << " : " << FileName << " -> " << file;
CloseZip(ZIP_Handle); //somehow we need to close and to reopen the zip handle, otherwise the program crashes
if (tpf) ZIP_Handle= OpenZip( FileInMemory, FileLen, pw);
else ZIP_Handle= OpenZip( FileInMemory, FileLen, (const char*)0);
}
}
}
CloseZip(ZIP_Handle);
if (node->myChildren.GetCount()==0)
{
LastError << Language->Error_FileIsEmpty << FileName << "\n";
return -1;
}
return 0;
}
int uMod_File::GetContentTemplate_SF( const uMod_TreeViewNode_ArrayPtr &list_node, uMod_TreeViewNode* node)
{
DWORD64 temp_hash;
wxString name;
for (unsigned int i=0; i<list_node.GetCount(); i++)
{
if (list_node[i]->myElement->Type() != uMod_ModElement::Texture) continue;
uMod_TextureElement *texture = (uMod_TextureElement*) list_node[i]->myElement;
SetFile( texture->File());
if (int ret = ReadFile())
{
texture->Comment() = Language->Error_FileRead;
texture->Comment() << " : " << texture->File();
continue;
}
if (texture->Content().SetSize(FileLen))
{
texture->Comment() = Language->Error_Memory;
texture->Comment() << " : " << texture->File();
continue;
}
char *data = texture->Content().Data();
for (unsigned int i=0; i<FileLen; i++) data[i] = FileInMemory[i];
texture->Hash() = temp_hash;
texture->Status() = uMod_TextureElement::Activate;
}
return 0;
}
int uMod_File::AddZip( uMod_TreeViewNode* node)
{
if (int ret = ReadFile()) return ret;
return AddContent( (char*)0, node);
}
int uMod_File::AddTpf( uMod_TreeViewNode* node)
{
if (int ret = ReadFile()) return ret;
UnXOR();
tool_tip = &FileInMemory[FileLen];
tool_tip.Prepend( Language->Author);
return 0;
const char pw[] = {0x73, 0x2A, 0x63, 0x7D, 0x5F, 0x0A, 0xA6, 0xBD,
0x7D, 0x65, 0x7E, 0x67, 0x61, 0x2A, 0x7F, 0x7F,
0x74, 0x61, 0x67, 0x5B, 0x60, 0x70, 0x45, 0x74,
0x5C, 0x22, 0x74, 0x5D, 0x6E, 0x6A, 0x73, 0x41,
0x77, 0x6E, 0x46, 0x47, 0x77, 0x49, 0x0C, 0x4B,
0x46, 0x6F, '\0'};
return AddContent( pw, node);
}
int uMod_File::AddFile( AddTextureClass &tex, bool add)
{
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 (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;
}
else {tex.Size[0] = 0; tex.Textures[0] = NULL;}
tex.Num = 1;
tex.Hash[0] = temp_hash;
return 0;
}
int uMod_File::AddZip( AddTextureClass &tex, bool add, bool tpf)
{
if (int ret = ReadFile()) return ret;
if (tpf)
{
UnXOR();
const char pw[] = {0x73, 0x2A, 0x63, 0x7D, 0x5F, 0x0A, 0xA6, 0xBD,
0x7D, 0x65, 0x7E, 0x67, 0x61, 0x2A, 0x7F, 0x7F,
0x74, 0x61, 0x67, 0x5B, 0x60, 0x70, 0x45, 0x74,
0x5C, 0x22, 0x74, 0x5D, 0x6E, 0x6A, 0x73, 0x41,
0x77, 0x6E, 0x46, 0x47, 0x77, 0x49, 0x0C, 0x4B,
0x46, 0x6F, '\0'};
return AddContent( pw, tex, add);
}
else
{
return AddContent( NULL, tex, add);
}
}
int uMod_File::AddContent( const char* pw, AddTextureClass &tex, bool add)
int uMod_File::AddContent( const char* pw, uMod_TreeViewNode* node)
{
// 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.
@@ -288,7 +471,9 @@ int uMod_File::AddContent( const char* pw, AddTextureClass &tex, bool add)
//
HZIP ZIP_Handle = OpenZip( FileInMemory, FileLen, pw);
if (ZIP_Handle==NULL) {LastError << Language->Error_Unzip; return -1;}
if (ZIP_Handle==(HZIP)0) {LastError << Language->Error_Unzip; return -1;}
node->myElement->File() = FileName;
ZIPENTRY ze;
int index;
@@ -308,11 +493,7 @@ int uMod_File::AddContent( const char* pw, AddTextureClass &tex, bool add)
int num = token.CountTokens();
tex.SetSize(num);
unsigned long temp_hash;
int count = 0;
DWORD64 temp_hash;
wxString entry;
wxString file;
@@ -320,122 +501,256 @@ int uMod_File::AddContent( const char* pw, AddTextureClass &tex, bool add)
{
entry = token.GetNextToken();
file = entry.BeforeFirst( '|');
if (!file.ToULong( &temp_hash, 16)) {LastError << Language->Error_Hash <<"\nTPF:" << entry << "\n"; continue;}
if (!file.ToULongLong( &temp_hash, 16)) {LastError << Language->Error_Hash <<"\nTPF:" << entry << "\n"; continue;}
file = entry.AfterFirst( '|');
file.Replace( "\r", "");
while ( (file[0]=='.' && (file[1]=='/' || file[1]=='\\')) || file[0]=='/' || file[0]=='\\') file.Remove(0,1);
if (add)
FindZipItem( ZIP_Handle, file.wc_str(), false, &index, &ze); // look for texture
if (index>=0)
{
FindZipItem( ZIP_Handle, file.wc_str(), false, &index, &ze); // look for texture
if (index>=0)
{
try {tex.Textures[count] = new char[ze.unc_size];}
catch(...)
{
tex.Textures[count] = NULL;
LastError << Language->Error_Memory;
continue;
}
uMod_TextureElement *texture = new uMod_TextureElement();
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;
}
else
{
tex.Hash[count] = temp_hash;
tex.Size[count] = ze.unc_size;
count++;
}
if (texture->Content().SetSize(ze.unc_size))
{
LastError << Language->Error_Memory;
texture->Release();
continue;
}
char *data = texture->Content().Data();
ZRESULT rz = UnzipItem( ZIP_Handle, index, data, ze.unc_size);
if (rz!=ZR_OK && rz!=ZR_MORE)
{
texture->Release();
LastError << Language->Error_Unzip <<"\nTPF:" << file << "\n";
}
else
{
LastError << Language->Error_Unzip <<"\nTPF:" << file << "\n";
CloseZip(ZIP_Handle); //somehow we need to close and to reopen the zip handle, otherwise the program crashes
ZIP_Handle = OpenZip( FileInMemory, FileLen, pw);
texture->Hash() = temp_hash;
texture->Title() = file;
texture->File() = file;
texture->Status() = uMod_TextureElement::Activate;
uMod_TreeViewNode *node_texture = new uMod_TreeViewNode( node, texture);
node->Append(node_texture);
texture->Release();
}
}
else
{
tex.Hash[count] = temp_hash;
tex.Size[count] = 0;
count++;
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);
}
}
delete [] def;
tex.Num = count;
wxString temp = &FileInMemory[FileLen];
node->myElement->Author() = temp.BeforeFirst('\n');
node->myElement->Author().Replace("\r", "", true);
node->myElement->Author().Replace("\n", "", true);
node->myElement->Comment() = temp.AfterFirst('\n');
node->myElement->Comment().Replace("\r\n", " ; ", true);
node->myElement->Comment().Replace("\n", " ; ", true);
CloseZip(ZIP_Handle);
if (node->myChildren.GetCount()==0)
{
LastError << Language->Error_FileIsEmpty << FileName << "\n";
return -1;
}
return 0;
}
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==(HZIP)0) {LastError << Language->Error_Unzip; return -1;}
FindZipItem( ZIP_Handle, L"content.txt", false, &index, &ze);
if (index>=0) //if content.txt is present in the zip file
{
char* def;
int len = ze.unc_size;
try {def=new char[len+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;}
def[len]=0;
wxString content = def;
uMod_TreeViewNode_ArrayPtr list_node;
if (uMod_TreeViewModel::String2Node( content, node, &list_node))
{
LastError << uMod_TreeViewModel::LastError << "\n" << FileName << "\n";
uMod_TreeViewModel::LastError.Empty();
return -1;
}
// overwrite file information
node->myElement->File() = FileName;
for (unsigned int i=0; i< list_node.GetCount(); i++)
{
if (list_node[i]->myElement->Type() == uMod_ModElement::Texture)
{
uMod_TextureElement *texture = (uMod_TextureElement*) list_node[i]->myElement;
wxString file = texture->File();
while ( (file[0]=='.' && (file[1]=='/' || file[1]=='\\')) || file[0]=='/' || file[0]=='\\') file.Remove(0,1);
FindZipItem( ZIP_Handle, file.wc_str(), false, &index, &ze); // look for texture
if (index>=0)
{
if (texture->Content().SetSize(ze.unc_size))
{
texture->Comment() = Language->Error_Memory;
continue;
}
char *data = texture->Content().Data();
ZRESULT rz = UnzipItem( ZIP_Handle, index, data, ze.unc_size);
if (rz!=ZR_OK && rz!=ZR_MORE)
{
texture->Content().SetSize(0);
texture->Comment() = Language->Error_Unzip;
}
}
else
{
texture->Content().SetSize(0);
texture->Comment() = Language->Error_Unzip;
CloseZip(ZIP_Handle); //somehow we need to close and to reopen the zip handle, otherwise the program crashes
ZIP_Handle = OpenZip( FileInMemory, FileLen, pw);
}
}
}
CloseZip(ZIP_Handle);
if (node->myChildren.GetCount()==0)
{
LastError << Language->Error_FileIsEmpty << FileName << "\n";
return -1;
}
return 0;
}
//we load each dds 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==(HZIP)0) {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);
int count = 0;
unsigned long temp_hash;
DWORD64 temp_hash;
for (int i=0; i<num; i++)
{
if (GetZipItem( ZIP_Handle, i, &ze)!=ZR_OK) continue; //ask for name and size
int len = ze.unc_size;
char *buffer;
try {buffer = new char[len+1];}
catch(...)
uMod_TextureElement *texture = new uMod_TextureElement();
if (texture->Content().SetSize(ze.unc_size))
{
LastError << Language->Error_Memory;
texture->Release();
continue;
}
char *data = texture->Content().Data();
ZRESULT rz = UnzipItem( ZIP_Handle, i, data, len);
if (rz!=ZR_OK && rz!=ZR_MORE)
{
texture->Release();
LastError << Language->Error_Unzip <<"\nZIP:" << FileName << "\n";
continue;
}
ZRESULT rz = UnzipItem( ZIP_Handle, i, buffer, len);
if (rz!=ZR_OK && rz!=ZR_MORE)
file = ze.name;
if (file.Len()==0)
{
delete [] buffer;
buffer = NULL;
LastError << Language->Error_Unzip <<"\nZIP:" << file << "\n";
texture->Release();
continue;
}
file = ze.name;
if (file.Len()==0) continue;
if (file == "Comment.txt") // load comment
{
char *buffer;
try {buffer = new char [len+1];}
catch (...)
{
LastError << Language->Error_Memory;
texture->Release();
continue;
}
for (int i=0; i<len; i++) buffer[i] = data[i];
buffer[len]=0;
node->myElement->Comment() = buffer;
node->myElement->Comment().Replace("\r\n", " ; ", true);
node->myElement->Comment().Replace("\n", " ; ", true);
delete [] buffer;
texture->Release();
continue;
}
name = file.AfterLast( '.');
if (name!="dds") continue; //if this is not texture file, continue
if (name!="dds")
{
texture->Release();
continue;
}
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 (add)
if (!name.ToULongLong( &temp_hash, 16))
{
if (buffer==NULL) continue;
texture->Release();
LastError << Language->Error_Hash <<"\nZIP:" << file << "\n";
continue;
} //if hash could not be extracted
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.Size[count] = 0;
count++;
}
texture->Hash() = temp_hash;
texture->Title() = ze.name;
texture->File() = ze.name;
texture->Status() = uMod_TextureElement::Activate;
uMod_TreeViewNode *node_texture = new uMod_TreeViewNode( node, texture);
node->Append(node_texture);
texture->Release();
}
tex.Num = count;
}
CloseZip(ZIP_Handle);
CloseZip(ZIP_Handle);
if (node->myChildren.GetCount()==0)
{
LastError << Language->Error_FileIsEmpty << FileName << "\n";
return -1;
}
return 0;
}
return 0;
}
+15 -3
View File
@@ -29,9 +29,15 @@ public:
~uMod_File(void);
bool FileSupported(void);
bool SingleFile(void);
//int AddSingleFileToNode( uMod_TreeViewNode* node);
int GetContentTemplate(const wxString &content, uMod_TreeViewNode* node);
/*
int GetComment( wxString &tool_tip);
int GetContent( AddTextureClass &tex, bool add);
*/
int GetContent( uMod_TreeViewNode* node);
int SetFile(const wxString &file) {FileName=file;Loaded=false; return 0;}
wxString GetFile(void) {return FileName;}
@@ -43,12 +49,18 @@ private:
int ReadFile(void);
int UnXOR(void);
/*
int GetCommentZip( wxString &tool_tip);
int GetCommentTpf( wxString &tool_tip);
*/
int AddFile( uMod_TreeViewNode* node);
int AddZip( uMod_TreeViewNode* node);
int AddTpf( uMod_TreeViewNode* node);
int AddFile( AddTextureClass &tex, bool add);
int AddZip( AddTextureClass &tex, bool add, bool tpf);
int AddContent( const char* pw, AddTextureClass &tex, bool add);
int AddContent( const char* pw, uMod_TreeViewNode* node);
int GetContentTemplate_ZIP( const uMod_TreeViewNode_ArrayPtr &list_node, uMod_TreeViewNode* node);
int GetContentTemplate_SF( const uMod_TreeViewNode_ArrayPtr &list_node, uMod_TreeViewNode* node);
wxString FileName;
bool Loaded;
+64 -51
View File
@@ -33,10 +33,10 @@ DEFINE_EVENT_TYPE(uMod_EVENT_TYPE)
BEGIN_EVENT_TABLE(uMod_Frame, wxFrame)
EVT_CLOSE(uMod_Frame::OnClose)
EVT_BUTTON(ID_Button_Open, uMod_Frame::OnButtonOpen)
EVT_BUTTON(ID_Button_Path, uMod_Frame::OnButtonPath)
EVT_BUTTON(ID_Button_Update, uMod_Frame::OnButtonUpdate)
EVT_BUTTON(ID_Button_Reload, uMod_Frame::OnButtonReload)
//EVT_BUTTON(ID_Button_Open, uMod_Frame::OnButtonOpen)
//EVT_BUTTON(ID_Button_Path, uMod_Frame::OnButtonPath)
//EVT_BUTTON(ID_Button_Update, uMod_Frame::OnButtonUpdate)
//EVT_BUTTON(ID_Button_Reload, uMod_Frame::OnButtonReload)
EVT_MENU(ID_Menu_Help, uMod_Frame::OnMenuHelp)
EVT_MENU(ID_Menu_About, uMod_Frame::OnMenuAbout)
@@ -137,23 +137,18 @@ uMod_Frame::uMod_Frame(const wxString& title, uMod_Settings &set)
MainSizer = new wxBoxSizer(wxVERTICAL);
Notebook = new wxNotebook( this, wxID_ANY);
Notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE);
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));
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*) ReloadButton, 1, wxEXPAND, 0);
MainSizer->Add( ButtonSizer, 0, wxEXPAND , 0 );
PipeStruct pipe = {INVALID_HANDLE_VALUE,INVALID_HANDLE_VALUE};
uMod_GamePage *page = new uMod_GamePage( Notebook, "uMod", INVALID_GAME_PAGE, "templates/uMod.txt", pipe);
if (page->LastError.Len()>0)
{
wxMessageBox(page->LastError, "ERROR", wxOK|wxICON_ERROR);
delete page;
}
else Notebook->AddPage( page, page->GetPageName(), true);
SetSizer( MainSizer);
@@ -213,12 +208,22 @@ int uMod_Frame::KillServer(void)
if (pipe == INVALID_HANDLE_VALUE) return -1;
// prepend a zero int value as dummy injection method
const wchar_t *str = ABORT_SERVER;
unsigned int len=0u;
while (str[len]) len++;
len++; //to send also the zero
char *buffer=(char*)0;
GetMemory(buffer, sizeof(int) + len * sizeof(wchar_t));
*((int*) buffer) = 0;
char *p_game = (char*) str;
for (unsigned int i=0; i<len*sizeof(wchar_t); i++) buffer[i+sizeof(int)] = p_game[i];
unsigned long num;
WriteFile( pipe, (const void*) str, len*sizeof(wchar_t), &num, NULL);
//WriteFile( pipe, (const void*) &len, sizeof(int), &num, NULL); //dummy injection method
WriteFile( pipe, (const void*) buffer, len*sizeof(wchar_t)+sizeof(int), &num, NULL);
delete [] buffer;
CloseHandle(pipe);
return 0;
}
@@ -242,6 +247,7 @@ void uMod_Frame::OnAddGame( wxCommandEvent &event)
pipe.In = ((uMod_Event&)event).GetPipeIn();
pipe.Out = ((uMod_Event&)event).GetPipeOut();
int injection_method = ((uMod_Event&)event).GetValue();
uMod_Client *client = new uMod_Client( pipe, this);
client->Create();
@@ -255,7 +261,7 @@ void uMod_Frame::OnAddGame( wxCommandEvent &event)
break;
}
uMod_GamePage *page = new uMod_GamePage( Notebook, name, save_file, client->Pipe);
uMod_GamePage *page = new uMod_GamePage( Notebook, name, injection_method, save_file, client->Pipe);
if (page->LastError.Len()>0)
{
wxMessageBox(page->LastError, "ERROR", wxOK|wxICON_ERROR);
@@ -274,7 +280,7 @@ void uMod_Frame::OnDeleteGame( wxCommandEvent &event)
uMod_Client *client = ((uMod_Event&)event).GetClient();
for (int i=0; i<NumberOfGames; i++) if (Clients[i]==client)
{
Notebook->DeletePage(i);
Notebook->DeletePage(i+1);
Clients[i]->Wait();
delete Clients[i];
NumberOfGames--;
@@ -287,45 +293,60 @@ void uMod_Frame::OnDeleteGame( wxCommandEvent &event)
void uMod_Frame::OnAddDevice( wxCommandEvent &event)
{
uMod_Client *client = ((uMod_Event&)event).GetClient();
for (int i=0; i<NumberOfGames; i++) if (Clients[i]==client)
{
uMod_GamePage *page = (uMod_GamePage*) Notebook->GetPage(i);
uMod_GamePage *page = (uMod_GamePage*) Notebook->GetPage(i+1);
page->AddDXDevice(((uMod_Event&)event).GetValue());
Notebook->SetPageText( i, page->GetPageName());
return;
}
}
void uMod_Frame::OnRemoveDevice( wxCommandEvent &event)
{
/*
uMod_Client *client = ((uMod_Event&)event).GetClient();
for (int i=0; i<NumberOfGames; i++) if (Clients[i]==client)
{
uMod_GamePage *page = (uMod_GamePage*) Notebook->GetPage(i);
wxMessageBox("removed");
uMod_GamePage *page = (uMod_GamePage*) Notebook->GetPage(i+1);
page->RemoveDXDevice(((uMod_Event&)event).GetValue());
Notebook->SetPageText( i, page->GetPageName());
return;
}
*/
}
void uMod_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();
//event.Skip();
Destroy();
}
/*
void uMod_Frame::OnButtonOpen(wxCommandEvent& WXUNUSED(event))
{
if (Notebook->GetPageCount()==0) return;
uMod_GamePage *page = (uMod_GamePage*) Notebook->GetCurrentPage();
if (page==NULL) return;
wxString temp = "D:\\Code\\uMod\\temp\\bf.tpf";
if (page->AddTexture( temp)) wxMessageBox(page->LastError);
temp = "D:\\Code\\uMod\\temp\\tex.zip";
if (page->AddTexture( temp)) wxMessageBox(page->LastError);
temp = "D:\\Code\\uMod\\temp\\test.zip";
if (page->AddTexture( temp)) wxMessageBox(page->LastError);
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);
if ( !file_name.empty() )
@@ -375,7 +396,7 @@ void uMod_Frame::OnButtonReload(wxCommandEvent& WXUNUSED(event))
page->LastError.Empty();
}
}
*/
@@ -431,7 +452,6 @@ void uMod_Frame::OnMenuSaveTemplateAs(wxCommandEvent& WXUNUSED(event))
uMod_GamePage *page = (uMod_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);
@@ -450,6 +470,7 @@ void uMod_Frame::OnMenuSetDefaultTemplate(wxCommandEvent& WXUNUSED(event))
if (Notebook->GetPageCount()==0) return;
uMod_GamePage *page = (uMod_GamePage*) Notebook->GetCurrentPage();
if (page==NULL) return;
if (page == (uMod_GamePage*) Notebook->GetPage(0)) return;
wxString exe = page->GetExeName();
wxString file = page->GetTemplateName();
@@ -508,12 +529,12 @@ void uMod_Frame::OnMenuLanguage(wxCommandEvent& WXUNUSED(event))
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++)
{
@@ -544,23 +565,25 @@ void uMod_Frame::OnMenuHelp(wxCommandEvent& WXUNUSED(event))
void uMod_Frame::OnMenuAbout(wxCommandEvent& WXUNUSED(event))
{
wxString msg;
msg << uMod_VERSION << "\n\nProject members:\n\nROTA (developer)\nKing Brace Blane (PR)\n\nhttp://code.google.com/p/texmod/";
msg << uMod_VERSION << "\n\nProject members:\n\nROTA (developer)\n\nKing Brace Blane (PR)\n\nhttp://code.google.com/p/texmod/";
wxMessageBox( msg, "Info", wxOK);
}
void uMod_Frame::OnMenuAcknowledgement(wxCommandEvent& WXUNUSED(event))
{
wxString msg;
msg << "King Brace Blane and ROTA thank:\n\n";
msg << "ROTA thanks:\n\n";
msg << "RS for coding the original TexMod and for information about the used hashing algorithm\n\n";
msg << "EvilAlex for translation into Russian and bug fixing\n";
msg << "ReRRemi for translation into French";
msg << "\n\n";
//msg << "King Brace Blane for a tutorial video on YouTube and bug fixing";
wxMessageBox( msg, Language->MenuAcknowledgement, wxOK);
}
void uMod_Frame::OnMenuStartGame(wxCommandEvent& event)
{
bool use_cmd = false;
if (event.GetId() == ID_Menu_StartGameCMD) use_cmd = true;
@@ -636,8 +659,8 @@ void uMod_Frame::OnMenuStartGame(wxCommandEvent& event)
wxString dll = wxGetCwd();
//dll.Append( L"\\" uMod_d3d9_DI_dll);
dll.Append( L"\\uMod_d3d10_DI.dll");
dll.Append( L"\\" uMod_d3d9_DI_dll);
//dll.Append( L"\\uMod_d3d10_DI.dll");
Inject(pi.hProcess, dll.wc_str(), "Nothing");
ResumeThread(pi.hThread);
@@ -720,32 +743,23 @@ void uMod_Frame::OnMenuDeleteGame(wxCommandEvent& WXUNUSED(event))
int uMod_Frame::ActivateGamesControl(void)
{
/*
MenuMain->Enable( ID_Menu_LoadTemplate, true);
MenuMain->Enable( ID_Menu_SaveTemplate, true);
MenuMain->Enable( ID_Menu_SaveTemplateAs, true);
*/
MenuMain->Enable( ID_Menu_SetDefaultTemplate, true);
OpenButton->Enable( true);
DirectoryButton->Enable( true);
UpdateButton->Enable( true);
ReloadButton->Enable( true);
return 0;
}
int uMod_Frame::DeactivateGamesControl(void)
{
/*
MenuMain->Enable( ID_Menu_LoadTemplate, false);
MenuMain->Enable( ID_Menu_SaveTemplate, false);
MenuMain->Enable( ID_Menu_SaveTemplateAs, false);
*/
MenuMain->Enable( ID_Menu_SetDefaultTemplate, false);
OpenButton->Enable( false);
DirectoryButton->Enable( false);
UpdateButton->Enable( false);
ReloadButton->Enable( false);
return 0;
}
@@ -963,8 +977,7 @@ void uMod_Frame::InstallHook(void)
{
if (H_DX9_DLL==NULL)
{
//H_DX9_DLL = LoadLibraryW(uMod_d3d9_Hook_dll);
H_DX9_DLL = LoadLibraryW(L"uMod_d3d10_HI.dll");
H_DX9_DLL = LoadLibraryW(uMod_d3d9_Hook_dll);
if (H_DX9_DLL!=NULL)
{
typedef void (*fkt_typ)(void);
+5 -5
View File
@@ -60,12 +60,12 @@ public:
*/
void OnClose(wxCloseEvent& WXUNUSED(event));
/*
void OnButtonOpen(wxCommandEvent& WXUNUSED(event));
void OnButtonPath(wxCommandEvent& WXUNUSED(event));
void OnButtonUpdate(wxCommandEvent& WXUNUSED(event));
void OnButtonReload(wxCommandEvent& WXUNUSED(event));
*/
void OnMenuStartGame( wxCommandEvent &event);
void OnMenuUseHook( wxCommandEvent &event);
@@ -101,19 +101,19 @@ private:
wxNotebook *Notebook;
/*
wxButton *OpenButton;
wxButton *DirectoryButton;
wxButton *UpdateButton;
wxButton *ReloadButton;
*/
wxMenuBar *MenuBar;
wxMenu *MenuMain;
wxMenu *MenuHelp;
wxBoxSizer *MainSizer;
wxBoxSizer *ButtonSizer;
//wxBoxSizer *ButtonSizer;
int NumberOfGames;
+202 -173
View File
@@ -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;
}
+67 -22
View File
@@ -20,6 +20,8 @@ along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>
#ifndef uMod_GAME_H_
#define uMod_GAME_H_
#include "uMod_TreeView.h"
#include "uMod_Main.h"
//this class is intended as a storing object for each game
@@ -32,11 +34,19 @@ public:
void Init(void);
int SaveToFile( const wxString &file_name);
int LoadFromFile( const wxString &file_name);
int SaveToString( wxString &content);
int LoadFromString( const wxString &content);
//int GetActiveTexture( uMod_TextureElement_SortedArrayPtr &texture);
bool &ShowCollPane(void) {return myShowCollPane;}
bool &SupportTPF(void) {return mySupportTPF;}
const bool &SupportTPF(void) const {return mySupportTPF;}
int GetChecked( bool* array, int num) const;
int SetChecked( bool* array, int num);
int SetSaveSingleTexture(bool val);
bool GetSaveSingleTexture(void) const {return SaveSingleTexture;}
@@ -44,13 +54,6 @@ public:
int SetSaveAllTextures(bool val);
bool GetSaveAllTextures(void) const {return SaveAllTextures;}
void SetFiles(const wxArrayString &files);
void GetFiles( wxArrayString &files) const;
//void AddTexture( const wxString &textures);
int GetNumberOfFiles(void) const {return Files.GetCount();}
int SendTextures(void);
int GetKeyBack() const {return KeyBack;}
int SetKeyBack(int key) {KeyBack=key; return 0;}
@@ -61,11 +64,43 @@ public:
int GetKeyNext() const {return KeyNext;}
int SetKeyNext(int key) {KeyNext=key; return 0;}
int SetFontColour(const int *colour) {FontColour[0]=colour[0];FontColour[1]=colour[1];FontColour[2]=colour[2];return 0;}
int GetFontColour(int *colour) const {colour[0]=FontColour[0];colour[1]=FontColour[1];colour[2]=FontColour[2];return 0;}
bool &ShowSingleTextureString() {return myShowSingleTextureString;}
const bool &ShowSingleTextureString() const {return myShowSingleTextureString;}
int SetFontColour(const unsigned char *colour) {FontColour[0]=colour[0];FontColour[1]=colour[1];FontColour[2]=colour[2];FontColour[3]=colour[3];return 0;}
int GetFontColour(unsigned char *colour) const {colour[0]=FontColour[0];colour[1]=FontColour[1];colour[2]=FontColour[2];colour[3]=FontColour[3];return 0;}
int SetTextureColour(const unsigned char *colour) {TextureColour[0]=colour[0];TextureColour[1]=colour[1];TextureColour[2]=colour[2];TextureColour[3]=colour[3];return 0;}
int GetTextureColour(unsigned char *colour) const {colour[0]=TextureColour[0];colour[1]=TextureColour[1];colour[2]=TextureColour[2];colour[3]=TextureColour[3];return 0;}
bool &UseSizeFilter(void) {return myUseSizeFilter;}
const bool &UseSizeFilter(void) const {return myUseSizeFilter;}
int &HeightMin(void) {return myHeightMin;}
const int &HeightMin(void) const {return myHeightMin;}
int &HeightMax(void) {return myHeightMax;}
const int &HeightMax(void) const {return myHeightMax;}
int &WidthMin(void) {return myWidthMin;}
const int &WidthMin(void) const {return myWidthMin;}
int &WidthMax(void) {return myWidthMax;}
const int &WidthMax(void) const {return myWidthMax;}
int &DepthMin(void) {return myDepthMin;}
const int &DepthMin(void) const {return myDepthMin;}
int &DepthMax(void) {return myDepthMax;}
const int &DepthMax(void) const {return myDepthMax;}
bool &UseFormatFilter(void) {return myUseFormatFilter;}
const bool &UseFormatFilter(void) const {return myUseFormatFilter;}
unsigned long &FormatFilter(void) {return myFormatFilter;}
const unsigned long &FormatFilter(void) const {return myFormatFilter;}
unsigned long &FileFormat(void) {return myFileFormat;}
const unsigned long &FileFormat(void) const {return myFileFormat;}
int SetTextureColour(const int *colour) {TextureColour[0]=colour[0];TextureColour[1]=colour[1];TextureColour[2]=colour[2];return 0;}
int GetTextureColour(int *colour) const {colour[0]=TextureColour[0];colour[1]=TextureColour[1];colour[2]=TextureColour[2];return 0;}
int SetOpenPath(const wxString &path) {OpenPath=path; return 0;}
wxString GetOpenPath(void) const {return OpenPath;}
@@ -76,22 +111,32 @@ public:
uMod_GameInfo& operator = (const uMod_GameInfo &rhs);
private:
bool myShowCollPane;
bool *Checked;
int NumberOfChecked;
int LengthOfChecked;
bool mySupportTPF;
bool SaveSingleTexture;
bool SaveAllTextures;
wxArrayString Files;
int KeyBack;
int KeySave;
int KeyNext;
int FontColour[3];
int TextureColour[3];
bool myUseSizeFilter;
int myHeightMin;
int myHeightMax;
int myWidthMin;
int myWidthMax;
int myDepthMin;
int myDepthMax;
bool myUseFormatFilter;
unsigned long myFormatFilter;
unsigned long myFileFormat;
bool myShowSingleTextureString;
unsigned char FontColour[4];
unsigned char TextureColour[4];
wxString OpenPath;
wxString SavePath;
+1122 -398
View File
File diff suppressed because it is too large Load Diff
+156 -30
View File
@@ -23,19 +23,20 @@ along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>
#include "uMod_Main.h"
// this page is opened if a game is started.
class uMod_GamePage : public wxScrolledWindow
class uMod_GamePage : public wxPanel
{
public:
uMod_GamePage( wxNotebook *parent, const wxString &exe, const wxString &save, PipeStruct &pipe);
uMod_GamePage( wxNotebook *parent, const wxString &exe, int injection_method, const wxString &save, PipeStruct &pipe);
virtual ~uMod_GamePage(void);
int AddTexture( const wxString &file_name);
int UpdateGame(void);
int ReloadGame(void);
int SaveTemplate( const wxString &file_name);
int SaveTemplateToString( wxString &content);
int LoadTemplate( const wxString &file_name);
int LoadTemplateFromString( const wxString &content);
wxString GetExeName(void) {return ExeName;}
wxString GetTemplateName(void) {return TemplateName;}
@@ -46,15 +47,86 @@ public:
int SetSavePath(const wxString &path);
wxString GetSavePath(void) {return Game.GetSavePath();}
/**
* User started drag
* @param event
*/
void OnBeginDrag( wxDataViewEvent &event);
/**
* Ask if drop position is valid
* @param event
*/
void OnDropPossible( wxDataViewEvent &event);
/**
* User dropped the item
* @param event
*/
void OnDrop( wxDataViewEvent &event);
void OnButtonUp(wxCommandEvent& WXUNUSED(event));
void OnButtonDown(wxCommandEvent& WXUNUSED(event));
void OnButtonDelete(wxCommandEvent& WXUNUSED(event));
void OnDropFile(wxDropFilesEvent& event);
/**
* Gets called, when the capture texture panel is shown/hidden
* @param WXUNUSED
*/
void OnCollPane(wxCollapsiblePaneEvent& WXUNUSED(event));
/**
* Gets called, when the colour buttons are pressed
* @param event
*/
void OnButtonColour(wxCommandEvent& event);
/**
* Gets called, when one of the check boxes gets checked/unchecked
* @param event
*/
void OnCheckBox(wxCommandEvent& event);
/**
* Gets called, press the button to select the filtered texture formats.
* @param event
*/
void OnButtonFormatFilter(wxCommandEvent& event);
/**
* Gets called, when the save-path button is pressed
* @param event
*/
void OnButtonSavePath(wxCommandEvent& event);
/**
* Gets called by a rigth click in the ViewCtrl
* @param event
*/
void OnContextMenu( wxDataViewEvent &event );
int OpenPackage(void);
/**
* call to change the labels of all items to the actual language
* @return
*/
int UpdateLanguage(void);
/**
* get the actual name of the page (displayed in the tab of the notebook window)
* @return
*/
wxString GetPageName(void);
/**
* The game has created a DirectX device.
* @param version device version (e.g. DX9, DX9Ex, DX10 DX10.1
* @return
*/
int AddDXDevice(int version);
/**
* The game hast destroyed a DirectX device.
* @param version
* @return
*/
int RemoveDXDevice(int version);
@@ -62,42 +134,96 @@ public:
private:
int CounterDX9, CounterDX9EX;
int CounterDX10, CounterDX10EX;
/**
* Set the info text (which injection method is used and which kind of DirectX device is connected)
* @return
*/
int SetInfo(void);
const int InjectionMethod;
int CounterDX9, CounterDX9EX;
int CounterDX10, CounterDX101;
/**
* add a single package (or file)
* @param file_name
* @return
*/
int AddPackage( const wxString &file_name);
/**
* adds multiple packages (or files)
* @param files
* @param num
* @return
*/
int AddPackages(const wxString *files, int num);
/**
* adds multiple packages (or files)
* @param files
* @return
*/
int AddPackages(const wxArrayString &files);
/**
* ask for all values from the various control elements of this panel and updates \a Game
* @return
*/
int GetSettings(void);
int SetColour( wxTextCtrl** txt, int *colour);
int GetColour( wxTextCtrl* txt, int def);
wxString ExeName;
wxString TemplateName;
wxBoxSizer *SizerKeys[2];
wxTextCtrl *TextKeyBack;
wxTextCtrl *TextKeySave;
wxTextCtrl *TextKeyNext;
wxChoice *ChoiceKeyBack;
wxChoice *ChoiceKeySave;
wxChoice *ChoiceKeyNext;
wxBoxSizer *FontColourSizer;
wxTextCtrl *FontColour[4];
wxBoxSizer *TextureColourSizer;
wxTextCtrl *TextureColour[4];
wxBoxSizer *MainSizer;
wxTextCtrl *DX_DLL_Info;
wxTextCtrl *TemplateFile;
wxCheckBox *SaveAllTextures;
wxCollapsiblePane *CollPane;
wxBoxSizer *CollSizer;
wxBoxSizer *TextureSizer;
wxPanel *SingleTexturePanel;
wxBoxSizer *SingleTextureSizer;
wxCheckBox *SaveSingleTexture;
wxCheckBox *ShowSingleTextureString;
uMod_KeyPanel *KeyBack;
uMod_KeyPanel *KeySave;
uMod_KeyPanel *KeyNext;
wxButton *FontColour;
wxButton *TextureColour;
wxPanel *AllTexturePanel;
wxBoxSizer *AllTextureSizer;
wxCheckBox *SaveAllTextures;
wxCheckBox *UseSizeFilter;
uMod_SpinPanel *SpinWidth;
uMod_SpinPanel *SpinHeight;
uMod_SpinPanel *SpinDepth;
wxCheckBox *UseFormatFilter;
wxButton *FormatFilter;
uMod_CheckBoxArray *FileFormats;
wxButton *SavePathButton;
wxTextCtrl *SavePath;
wxBoxSizer **CheckBoxHSizers;
wxButton **CheckButtonUp;
wxButton **CheckButtonDown;
wxButton **CheckButtonDelete;
wxDataViewCtrl *ViewCtrl;
uMod_TreeViewModel *ViewModel;
wxDataViewItem *LastDataViewItem;
wxCheckBox **CheckBoxes;
int NumberOfEntry;
int MaxNumberOfEntry;
@@ -109,7 +235,7 @@ private:
uMod_Sender Sender;
//DECLARE_EVENT_TABLE();
DECLARE_EVENT_TABLE();
};
#endif /* uMod_GAMEPAGE_H_ */
+95 -49
View File
@@ -179,8 +179,8 @@ int uMod_Language::LoadLanguage(const wxString &name)
command.Replace( "\n", "");
msg = entry.AfterFirst(':');
while (msg[0]=='\r' || msg[0]=='\n') msg.Remove(0,1);
while (msg.Last()=='\n' || msg.Last()=='\r') msg.RemoveLast(1);
while (msg.Len()>0 && (msg[0]=='\r' || msg[0]=='\n')) msg.Remove(0,1);
while (msg.Len()>0 && (msg.Last()=='\n' || msg.Last()=='\r')) msg.RemoveLast(1);
CheckEntry( command, msg, MenuLanguage)
CheckEntry( command, msg, MenuHelp)
@@ -198,14 +198,25 @@ int uMod_Language::LoadLanguage(const wxString &name)
CheckEntry( command, msg, MenuExit)
CheckEntry( command, msg, MainMenuMain)
CheckEntry( command, msg, MainMenuHelp)
CheckEntry( command, msg, ButtonOpen)
CheckEntry( command, msg, ButtonDirectory)
CheckEntry( command, msg, MenuOpenPackage)
CheckEntry( command, msg, MenuRemovePackage)
CheckEntry( command, msg, MenuRemoveSelectedPackages)
CheckEntry( command, msg, MenuUpdate)
CheckEntry( command, msg, MenuReload)
CheckEntry( command, msg, MenuSupportTPF)
CheckEntry( command, msg, ButtonUpdate)
CheckEntry( command, msg, ButtonReload)
CheckEntry( command, msg, ButtonDirectory)
CheckEntry( command, msg, ChooseFile)
CheckEntry( command, msg, ChooseDir)
CheckEntry( command, msg, MultipleSingleFiles)
CheckEntry( command, msg, HookInjection)
CheckEntry( command, msg, DirectInjection)
CheckEntry( command, msg, NoInjection)
CheckEntry( command, msg, InvalidGamePage)
CheckEntry( command, msg, TextCtrlTemplate)
CheckEntry( command, msg, CollapseTextureCapture)
CheckEntry( command, msg, CheckBoxSaveSingleTexture)
CheckEntry( command, msg, CheckBoxShowStringSaveSingleTexture)
CheckEntry( command, msg, CheckBoxSaveAllTextures)
CheckEntry( command, msg, TextCtrlSavePath)
CheckEntry( command, msg, SelectLanguage)
@@ -215,12 +226,15 @@ int uMod_Language::LoadLanguage(const wxString &name)
CheckEntry( command, msg, DeleteGame)
CheckEntry( command, msg, GameAlreadyAdded)
CheckEntry( command, msg, ExitGameAnyway)
CheckEntry( command, msg, NoComment)
CheckEntry( command, msg, Title)
CheckEntry( command, msg, Author)
CheckEntry( command, msg, Comment)
CheckEntry( command, msg, SingleTextureNode)
CheckEntry( command, msg, Error_GameIsHooked)
CheckEntry( command, msg, Error_ProcessNotStarted)
CheckEntry( command, msg, Error_RemoveHook)
CheckEntry( command, msg, Error_FileNotSupported)
CheckEntry( command, msg, Error_FileIsEmpty)
CheckEntry( command, msg, Error_FktNotFound)
CheckEntry( command, msg, Error_D3DX9NotFound)
CheckEntry( command, msg, Error_DLLNotFound)
@@ -239,9 +253,15 @@ int uMod_Language::LoadLanguage(const wxString &name)
CheckEntry( command, msg, Error_Memory)
CheckEntry( command, msg, Error_Unzip)
CheckEntry( command, msg, Error_ZipEntry)
CheckEntry( command, msg, CheckBoxUseSizeFilter)
CheckEntry( command, msg, CheckBoxUseFormatFilter)
CheckEntry( command, msg, SetFormatFilter)
CheckEntry( command, msg, KeyBack)
CheckEntry( command, msg, KeySave)
CheckEntry( command, msg, KeyNext)
CheckEntry( command, msg, AskForKey)
CheckEntry( command, msg, KeyNotSet)
CheckEntry( command, msg, UnknownKey)
CheckEntry( command, msg, FontColour)
CheckEntry( command, msg, TextureColour)
{}
@@ -277,16 +297,30 @@ int uMod_Language::LoadDefault(void)
MainMenuMain = "Main";
MainMenuHelp = "Help";
ButtonOpen = "Open texture/package";
ButtonDirectory = "Set save directory";
MenuOpenPackage = "Open texture/package";
MenuRemovePackage = "Remove package";
MenuRemoveSelectedPackages = "Remove selected packages";
MenuUpdate = "Update";
MenuReload = "Update (reload)";
MenuSupportTPF = "Support TPF-Mods";
ButtonUpdate = "Update";
ButtonReload = "Update (reload)";
ButtonDirectory = "Set save directory";
ChooseFile = "Choose a file";
ChooseDir = "Choose a directory";
MultipleSingleFiles = "Multiple single files";
HookInjection = "Hook Injection: ";
DirectInjection = "Direct Injection: ";
NoInjection = "No Injection: ";
InvalidGamePage = "default page";
TextCtrlTemplate = "Template: ";
CollapseTextureCapture = "Capture textures";
CheckBoxSaveSingleTexture = "Save single texture";
CheckBoxShowStringSaveSingleTexture = "Show message in the upper left corner";
CheckBoxSaveAllTextures = "Save all textures";
TextCtrlSavePath = "Save path:";
@@ -299,14 +333,17 @@ int uMod_Language::LoadDefault(void)
DeleteGame = "Select the games to be deleted.";
GameAlreadyAdded = "Game has been already added.";
ExitGameAnyway = "Closing OpenTexMod while a game is running might lead to a crash of the game.\nExit anyway?";
NoComment = "No comment.";
Author = "Author: ";
Title = "Title";
Author = "Author";
Comment = "Comment";
SingleTextureNode = "Single Textures";
Error_GameIsHooked = "The global hook is active and this game will be injected! Please delete the game from the list or disable the hook.";
Error_ProcessNotStarted = "The game could not be started.";
Error_RemoveHook = "Removing the Hook while a game is running might lead to crash.";
Error_FileNotSupported = "This file type is not supported:\n";
Error_FileIsEmpty = "Could not retrieve textures from file:\n";
Error_D3DX9NotFound = "The D3DX9_43.dll (32bit) is not available on your system.\nPlease install the newest DirectX End-User Runtime Installer.";
Error_DLLNotFound = "Could not load the dll.\nThe dll injection won't work.\nThis might happen if D3DX9_43.dll (32bit) 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.";
@@ -327,14 +364,23 @@ int uMod_Language::LoadDefault(void)
Error_Unzip = "Could not unzip.";
Error_ZipEntry = "Could not find zip entry.";
CheckBoxUseSizeFilter = "Use size filter";
CheckBoxUseFormatFilter = "Use texture format filter";
SetFormatFilter = "Set the filter";
WidthSpin = "Width :";
HeightSpin = "Height :";
DepthSpin = "Depth :";
KeyBack = "Back";
KeySave = "Save";
KeyNext = "Next";
AskForKey = "Pleas press a Key.";
KeyNotSet = "Not set";
UnknownKey = "Unknown";
FontColour = "Font colour (RGB):";
TextureColour = "Texture colour (RGB):";
FontColour = "Font colour";
TextureColour = "Texture colour";
return 0;
}
@@ -453,44 +499,44 @@ int uMod_Language::LoadKeys(void)
// * VK_A - VK_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A)
*/
int count = 0x30;
AddKey( "0", count++);
AddKey( "1", count++);
AddKey( "2", count++);
AddKey( "3", count++);
AddKey( "4", count++);
AddKey( "5", count++);
AddKey( "6", count++);
AddKey( "7", count++);
AddKey( "8", count++);
AddKey( "9", count++);
AddKey( "VK_0", count++);
AddKey( "VK_1", count++);
AddKey( "VK_2", count++);
AddKey( "VK_3", count++);
AddKey( "VK_4", count++);
AddKey( "VK_5", count++);
AddKey( "VK_6", count++);
AddKey( "VK_7", count++);
AddKey( "VK_8", count++);
AddKey( "VK_9", count++);
count = 0x41;
AddKey( "a", count++);
AddKey( "b", count++);
AddKey( "c", count++);
AddKey( "d", count++);
AddKey( "e", count++);
AddKey( "f", count++);
AddKey( "g", count++);
AddKey( "h", count++);
AddKey( "i", count++);
AddKey( "j", count++);
AddKey( "k", count++);
AddKey( "l", count++);
AddKey( "m", count++);
AddKey( "n", count++);
AddKey( "o", count++);
AddKey( "p", count++);
AddKey( "q", count++);
AddKey( "r", count++);
AddKey( "s", count++);
AddKey( "t", count++);
AddKey( "u", count++);
AddKey( "v", count++);
AddKey( "w", count++);
AddKey( "x", count++);
AddKey( "y", count++);
AddKey( "z", count++);
AddKey( "VK_A", count++);
AddKey( "VK_B", count++);
AddKey( "VK_C", count++);
AddKey( "VK_D", count++);
AddKey( "VK_E", count++);
AddKey( "VK_F", count++);
AddKey( "VK_G", count++);
AddKey( "VK_H", count++);
AddKey( "VK_I", count++);
AddKey( "VK_J", count++);
AddKey( "VK_K", count++);
AddKey( "VK_L", count++);
AddKey( "VK_M", count++);
AddKey( "VK_N", count++);
AddKey( "VK_O", count++);
AddKey( "VK_P", count++);
AddKey( "VK_Q", count++);
AddKey( "VK_R", count++);
AddKey( "VK_S", count++);
AddKey( "VK_T", count++);
AddKey( "VK_U", count++);
AddKey( "VK_V", count++);
AddKey( "VK_W", count++);
AddKey( "VK_X", count++);
AddKey( "VK_Y", count++);
AddKey( "VK_Z", count++);
/*
+31 -4
View File
@@ -51,16 +51,29 @@ public:
wxString MainMenuMain;
wxString MainMenuHelp;
wxString ButtonOpen;
wxString ButtonDirectory;
wxString MenuOpenPackage;
wxString MenuRemovePackage;
wxString MenuRemoveSelectedPackages;
wxString MenuUpdate;
wxString MenuReload;
wxString MenuSupportTPF;
wxString ButtonUpdate;
wxString ButtonReload;
wxString ButtonDirectory;
wxString ChooseFile;
wxString ChooseDir;
wxString MultipleSingleFiles;
wxString HookInjection;
wxString DirectInjection;
wxString NoInjection;
wxString InvalidGamePage;
wxString TextCtrlTemplate;
wxString CollapseTextureCapture;
wxString CheckBoxSaveSingleTexture;
wxString CheckBoxShowStringSaveSingleTexture;
wxString CheckBoxSaveAllTextures;
wxString TextCtrlSavePath;
@@ -73,14 +86,17 @@ public:
wxString DeleteGame;
wxString GameAlreadyAdded;
wxString ExitGameAnyway;
wxString NoComment;
wxString Title;
wxString Author;
wxString Comment;
wxString SingleTextureNode;
wxString Error_GameIsHooked;
wxString Error_ProcessNotStarted;
wxString Error_RemoveHook;
wxString Error_FileNotSupported;
wxString Error_FileIsEmpty;
wxString Error_FktNotFound;
wxString Error_D3DX9NotFound;
wxString Error_DLLNotFound;
@@ -101,9 +117,20 @@ public:
wxString Error_Unzip;
wxString Error_ZipEntry;
wxString CheckBoxUseSizeFilter;
wxString CheckBoxUseFormatFilter;
wxString SetFormatFilter;
wxString WidthSpin;
wxString HeightSpin;
wxString DepthSpin;
wxString KeyBack;
wxString KeySave;
wxString KeyNext;
wxString AskForKey;
wxString KeyNotSet;
wxString UnknownKey;
wxArrayString KeyStrings;
wxArrayInt KeyValues;
+51 -21
View File
@@ -41,7 +41,11 @@ along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>
#define wxUSE_TEXTCTRL 1
#define wxUSE_CHOICEDLG 1
#define wxUSE_TOOLTIPS 1
#define wxUSE_DATAVIEWCTRL 1
#define wxUSE_COLLPANE 1
#define wxUSE_COLOURDLG 1
#endif
#define wxUSE_SPINCTRL 1
#define WINVER _WIN32_WINNT_WINXP
#define _WIN32_WINNT _WIN32_WINNT_WINXP
@@ -49,22 +53,26 @@ along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>
#define WIN32_LEAN_AND_MEAN
#include "wx\wx.h"
#include "wx\notebook.h"
#include <wx\wx.h>
#include <wx\notebook.h>
#include <wx/file.h>
#include <wx/dir.h>
#include <wx/tokenzr.h>
#include <wx/dynlib.h>
//#include <wx/thread.h>
//#include "wx/checkbox.h"
//#include <wx/msgdlg.h>
//#include <wx/menu.h>
//#include <wx/button.h>
//#include <wx/filedlg.h>
//#include <wx/choice.h>
//#include <wx/textctrl.h>
//#include <wx/choicdlg.h>
#include <wx/dataview.h>
#include <wx/thread.h>
#include <wx/checkbox.h>
#include <wx/msgdlg.h>
#include <wx/menu.h>
#include <wx/button.h>
#include <wx/filedlg.h>
#include <wx/choice.h>
#include <wx/textctrl.h>
#include <wx/choicdlg.h>
#include <wx/collpane.h>
#include <wx/colourdata.h>
#include <wx/colordlg.h>
#include <wx/spinctrl.h>
//#include <windows.h>
#include "../uMod_GlobalDefines.h"
@@ -77,13 +85,7 @@ class uMod_Frame;
#define MAX_TEXTURES 1024
enum
{
ID_Button_Open = wxID_HIGHEST,
ID_Button_Path,
ID_Button_Update,
ID_Button_Reload,
//ID_Button_Save,
//ID_Menu_Pref,
ID_Menu_Exit,
ID_Menu_Exit = wxID_HIGHEST,
ID_Menu_Lang,
ID_Menu_Help,
ID_Menu_About,
@@ -101,15 +103,42 @@ enum
ID_Delete_Game,
ID_Add_Device,
ID_Delete_Device,
ID_Button_Texture, //this entry must be the last!!
ID_OpenPackage,
ID_RemovePackage,
ID_RemoveSelectedPackages,
ID_Update,
ID_Reload,
ID_SupportTPF,
ID_Button_Update,
ID_CollPane,
ID_SaveSingleTexture,
ID_SaveAllTexture,
ID_ShowSingleTextureString,
ID_FontColour,
ID_TextureColour,
ID_KeyPress,
ID_UseSizeFilter,
ID_SpinMin, ID_SpinMax,
ID_UseFormatFilter,
ID_SetFormatFilter,
ID_Button_SavePath,
ID_DataViewCtrl,
ID_ContextMenu,
};
#define ABORT_SERVER L"uMod_Abort_Server"
#define uMod_d3d9_Hook_dll L"uMod_d3d9_HI.dll"
#define uMod_d3d9_DI_dll L"uMod_d3d9_DI.dll"
#include "uMod_AddTexture.h"
#include "uMod_Settings.h"
#include "uMod_ModElement.h"
#include "uMod_TreeView.h"
#include "uMod_AddTexture.h"
#include "uMod_Language.h"
#include "uMod_Event.h"
#include "uMod_Client.h"
@@ -117,6 +146,7 @@ enum
#include "uMod_File.h"
#include "uMod_Sender.h"
#include "uMod_Server.h"
#include "uMod_MiniPanels.h"
#include "uMod_GamePage.h"
#include "uMod_DirectInjection.h"
#include "uMod_GUI.h"
+355
View File
@@ -0,0 +1,355 @@
/*
This file is part of Universal Modding Engine.
Universal Modding Engine 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.
Universal Modding Engine 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 Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "uMod_Main.h"
#ifndef __CDT_PARSER__
BEGIN_EVENT_TABLE(uMod_SpinPanel, wxPanel)
EVT_SPINCTRL(ID_SpinMin, uMod_SpinPanel::OnSpin)
EVT_SPINCTRL(ID_SpinMax, uMod_SpinPanel::OnSpin)
END_EVENT_TABLE()
#endif
uMod_SpinPanel::uMod_SpinPanel(wxWindow *parent, int winid,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name)
: wxPanel( parent, winid, pos, size, style, name)
{
Text = new wxTextCtrl( this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
Min = new wxSpinCtrl ( this, ID_SpinMin, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 65535, 1);
Max = new wxSpinCtrl ( this, ID_SpinMax, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 65535, 1);
Max->SetRange( 1, 65535);
wxBoxSizer* spin_sizer = new wxBoxSizer(wxHORIZONTAL);
spin_sizer->Add( (wxWindow*) Text, 0, wxEXPAND, 0);
spin_sizer->Add( (wxWindow*) Min, 0, wxEXPAND, 0);
spin_sizer->Add( (wxWindow*) new wxTextCtrl(this, wxID_ANY, " -", wxDefaultPosition, wxSize(25,10), wxTE_READONLY), 0, wxEXPAND, 0);
spin_sizer->Add( (wxWindow*) Max, 0, wxEXPAND, 0);
spin_sizer->AddStretchSpacer();
SetSizer(spin_sizer);
}
void uMod_SpinPanel::GetValue( int &min, int &max)
{
min = Min->GetValue();
max = Max->GetValue();
}
void uMod_SpinPanel::SetValue(int min, int max)
{
if (max<min) return;
Min->SetValue( min);
Max->SetValue( max);
}
void uMod_SpinPanel::SetLabel( const wxString &label)
{
Text->SetValue( label);
}
void uMod_SpinPanel::OnSpin(wxSpinEvent& event)
{
int min = Min->GetValue();
int max = Max->GetValue();
if (event.GetId() == ID_SpinMin)
{
if (max<min) Max->SetValue(min);
}
else
{
if (min>max) Min->SetValue(max);
}
}
uMod_CheckBoxArray::uMod_CheckBoxArray(wxWindow *parent, const wxArrayString &choices, int col, int winid,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name)
: wxPanel( parent, winid, pos, size, style, name)
{
if (col>0)
{
wxGridSizer *sizer = new wxGridSizer( col, 0,0);
for (unsigned int i=0; i<choices.GetCount(); i++)
{
wxCheckBox *check_box = new wxCheckBox ( this, wxID_ANY, choices[i], wxDefaultPosition, wxDefaultSize);
CheckBoxes.Add(check_box);
sizer->Add(check_box);
}
SetSizer(sizer);
}
else
{
wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
for (unsigned int i=0; i<choices.GetCount(); i++)
{
wxCheckBox *check_box = new wxCheckBox ( this, wxID_ANY, choices[i], wxDefaultPosition, wxDefaultSize);
CheckBoxes.Add(check_box);
sizer->Add(check_box, 0, wxEXPAND, 0);
}
sizer->AddStretchSpacer();
SetSizer(sizer);
}
}
void uMod_CheckBoxArray::SetChoices(const wxArrayShort &choices)
{
for (unsigned int i=0; i<choices.GetCount() && i<CheckBoxes.GetCount(); i++)
{
if (choices[i]) CheckBoxes[i]->SetValue(true);
else CheckBoxes[i]->SetValue(false);
}
}
void uMod_CheckBoxArray::GetChoices(wxArrayShort &choices)
{
choices.Empty();
for (unsigned int i=0; i<CheckBoxes.GetCount(); i++)
{
if (CheckBoxes[i]->GetValue()) choices.Add(1);
else choices.Add(0);
}
}
void uMod_CheckBoxArray::SetValue( unsigned long val)
{
for (unsigned int i=0; i<CheckBoxes.GetCount(); i++)
{
if (val & 1<<i) CheckBoxes[i]->SetValue(true);
else CheckBoxes[i]->SetValue(false);
}
}
void uMod_CheckBoxArray::GetValue( unsigned long &val)
{
val = 0;
for (unsigned int i=0; i<CheckBoxes.GetCount(); i++)
{
if (CheckBoxes[i]->GetValue()) val |= 1<<i;
}
}
#ifndef __CDT_PARSER__
BEGIN_EVENT_TABLE(uMod_KeyPanel, wxPanel)
EVT_BUTTON(ID_KeyPress, uMod_KeyPanel::OnButton)
END_EVENT_TABLE()
#endif
uMod_KeyPanel::uMod_KeyPanel(wxWindow *parent, const wxString &label, int key, int winid,
const wxPoint& pos, const wxSize& size, long style, const wxString& name)
: wxPanel( parent, winid, pos, size, style, name)
{
myKey = key;
Button = new wxButton( this, ID_KeyPress, label, wxDefaultPosition, wxSize(100,24));
KeyText = new wxTextCtrl( this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add( (wxWindow*) Button, 0, wxEXPAND, 0);
sizer->AddSpacer(10);
sizer->Add( (wxWindow*) KeyText, 0, wxEXPAND, 0);
sizer->AddStretchSpacer();
SetKeyLabel();
SetSizer(sizer);
}
void uMod_KeyPanel::SetLabel(const wxString &label)
{
Button->SetLabel( label);
}
void uMod_KeyPanel::OnButton(wxCommandEvent& WXUNUSED(event))
{
uMod_AskForKey *dialog = new uMod_AskForKey( Language->AskForKey);
dialog->ShowModal();
myKey = dialog->Key();
delete dialog;
SetKeyLabel();
}
void uMod_KeyPanel::SetKeyLabel()
{
wxString temp;
if (myKey<0)
temp = Language->KeyNotSet;
else
{
int index = Language->KeyValues.Index( myKey);
if (index>=0)
temp = Language->KeyStrings[index];
else
temp = Language->UnknownKey;
wxString code;
code.Printf(" (%#X)", myKey);
temp << code;
}
KeyText->SetValue(temp);
}
#ifndef __CDT_PARSER__
BEGIN_EVENT_TABLE(uMod_AskForKey, wxDialog)
//EVT_KEY_UP(uMod_AskForKey::OnKey)
EVT_CHAR_HOOK(uMod_AskForKey::OnKey)
END_EVENT_TABLE()
#endif
uMod_AskForKey::uMod_AskForKey(const wxString &title)
: wxDialog( (wxWindow*)0, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX | wxRESIZE_BORDER)
{
myKey = -1;
}
void uMod_AskForKey::OnKey(wxKeyEvent& event)
{
myKey = event.GetRawKeyCode();//GetKeyCode();
EndModal(0);
}
/*
uMod_TextureFormat::uMod_TextureFormat(wxWindow *parent, const wxString &title)
: wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX | wxRESIZE_BORDER)
{
wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
wxArrayString choices;
choices.Add("R8G8B8");
choices.Add("A8R8G8B8");
choices.Add("X8R8G8B8");
choices.Add("R5G6B");
choices.Add("X1R5G5B5");
choices.Add("A1R5G5B5");
choices.Add("A4R4G4B4");
choices.Add("R3G3B2");
choices.Add("A8");
choices.Add("A8R3G3B2");
choices.Add("X4R4G4B4");
choices.Add("A2B10G10R10");
choices.Add("A8B8G8R8");
choices.Add("X8B8G8R8");
choices.Add("G16R16");
choices.Add("A2R10G10B10");
choices.Add("A16B16G16R16");
choices.Add("A8P8");
choices.Add("P8");
choices.Add("L8");
choices.Add("A8L8");
choices.Add("A4L4");
choices.Add("V8U8");
choices.Add("L6V5U5");
choices.Add("X8L8V8U8");
choices.Add("Q8W8V8U8");
choices.Add("V16U16");
choices.Add("A2W10V10U10");
choices.Add("UYVY");
choices.Add("R8G8_B8G8");
choices.Add("YUY2");
choices.Add("G8R8_G8B8");
choices.Add("DXT1");
choices.Add("DXT2");
choices.Add("DXT3");
choices.Add("DXT4");
choices.Add("DXT5");
choices.Add("D16_LOCKABLE");
choices.Add("D32");
choices.Add("D15S1");
choices.Add("D24S8");
choices.Add("D24X8");
choices.Add("D24X4S4");
choices.Add("D16");
choices.Add("D32F_LOCKABLE");
choices.Add("D24FS8");
choices.Add("D32_LOCKABLE");
choices.Add("S8_LOCKABLE");
choices.Add("L16");
choices.Add("VERTEXDATA");
choices.Add("INDEX16");
choices.Add("INDEX32");
choices.Add("Q16W16V16U16");
choices.Add("MULTI2_ARGB8");
choices.Add("R16F");
choices.Add("G16R16F");
choices.Add("A16B16G16R16F");
choices.Add("R32F");
choices.Add("G32R32F");
choices.Add("A32B32G32R32F");
choices.Add("CxV8U8");
choices.Add("A1");
choices.Add("A2B10G10R10_XR_BIAS");
choices.Add("BINARYBUFFER");
TextureFormats = new uMod_CheckBoxArray( this, choices, 4);
sizer->Add( (wxWindow*) TextureFormats, 0, wxEXPAND, 0);
SetSizer(sizer);
wxArrayInt selections;
wxGetSelectedChoices( selections, Language->DeleteGame, Language->DeleteGame, choices);
}
*/
+174
View File
@@ -0,0 +1,174 @@
/*
This file is part of Universal Modding Engine.
Universal Modding Engine 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.
Universal Modding Engine 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 Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "uMod_Main.h"
#ifndef UMOD_MINIPANELS_H_
#define UMOD_MINIPANELS_H_
class uMod_SpinPanel : public wxPanel
{
public:
uMod_SpinPanel(wxWindow *parent, int winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = wxPanelNameStr);
virtual ~uMod_SpinPanel() {}
/**
* Get the min an max value
* @param[out] min
* @param[out] max
*/
void GetValue( int &min, int &max);
/**
* Set the min and max value
* @param[in] min
* @param[in] max
*/
void SetValue(int min, int max);
/**
* Set the label of the text ctrl
* @param label
* @return
*/
void SetLabel( const wxString &label);
protected:
/**
* Gets called, when one of the spin boxes changes their value
* @param event
*/
void OnSpin(wxSpinEvent& event);
wxTextCtrl *Text;
wxSpinCtrl *Min, *Max;
DECLARE_EVENT_TABLE();
};
WX_DEFINE_ARRAY_PTR( wxCheckBox*, wxCheckBox_Array );
class uMod_CheckBoxArray : public wxPanel
{
public:
uMod_CheckBoxArray(wxWindow *parent, const wxArrayString &choices, int col, int winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = wxPanelNameStr);
virtual ~uMod_CheckBoxArray() {}
void SetChoices(const wxArrayShort &choices);
void GetChoices(wxArrayShort &choices);
void SetValue( unsigned long val);
void GetValue( unsigned long &val);
private:
wxCheckBox_Array CheckBoxes;
};
/**
* this class is a mini panel with a set key button and string beside it which shows the actual set key
*/
class uMod_KeyPanel : public wxPanel
{
public:
uMod_KeyPanel(wxWindow *parent, const wxString &label, int key, int winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = wxPanelNameStr);
virtual ~uMod_KeyPanel() {}
int GetKey() {return myKey;}
void SetKey(int key) {myKey = key; SetKeyLabel();}
/**
* set the label of the button (for changing the language)
* @param label
*/
void SetLabel(const wxString &label);
private:
/**
* called if button was clicked
* @param event
*/
void OnButton(wxCommandEvent& event);
void SetKeyLabel();
wxButton *Button;
wxTextCtrl *KeyText;
int myKey;
DECLARE_EVENT_TABLE();
};
class uMod_AskForKey : public wxDialog
{
public:
uMod_AskForKey(const wxString &title);
virtual ~uMod_AskForKey() {}
int Key() {return myKey;}
private:
/**
* called if a key was hit
* @param event
*/
void OnKey(wxKeyEvent& event);
int myKey;
DECLARE_EVENT_TABLE();
};
/*
class uMod_TextureFormat : public wxDialog
{
public:
uMod_TextureFormat(wxWindow *parent, const wxString &title);
virtual ~uMod_TextureFormat() {}
void SetValue( unsigned long val) {TextureFormats->SetValue(val);}
void GetValue( unsigned long &val) {TextureFormats->GetValue(val);}
private:
uMod_CheckBoxArray *TextureFormats;
};
*/
#endif /* UMOD_MINIPANELS_H_ */
+18
View File
@@ -0,0 +1,18 @@
/*
* uMod_ModElement.cpp
*
* Created on: 26.06.2012
* Author: marts
*/
#include "uMod_Main.h"
int Compare_uMod_TextureElement(uMod_TextureElement* a,uMod_TextureElement* b)
{
if ( a->Hash() < b->Hash()) return -1;
else if ( a->Hash() == b->Hash()) return 0;
else return +1;
}
+165
View File
@@ -0,0 +1,165 @@
/*
This file is part of Universal Modding Engine.
Universal Modding Engine 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.
Universal Modding Engine 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 Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "uMod_Main.h"
#ifndef UMOD_MODELEMEMT_H_
#define UMOD_MODELEMEMT_H_
template <class T>
class uMod_Data
{
public:
uMod_Data(void): myData((T*)0), myLen(0) {}
~uMod_Data() {if (myData!=(T*)0) delete [] myData;}
T* &Data(void) {return myData;}
const T* &Data(void) const {return myData;}
unsigned int &Len(void) {return myLen;}
const unsigned int &Len(void) const {return myLen;}
int SetSize(int size)
{
if (myData!=(T*)0) delete [] myData;
myData = (T*)0;
if (size<=0) return 0;
try {myData = new T[size];}
catch (...) {myData=(T*)0;return -1;}
myLen = size;
return 0;
}
private:
T *myData;
unsigned int myLen;
};
/**
* This class is a representation of one element, to be modified (e.g. one texture)
*/
class uMod_ModElement
{
public:
enum enumType
{
Group,
Texture
};
enum enumStatus
{
Activate,
Deactivate,
NONE
};
uMod_ModElement( enumType t, enumStatus s = NONE) : myType(t), myStatus(s), myCounter(1) {}
virtual ~uMod_ModElement() {}
int AddRef(void) {return ++myCounter;}
int Release(void) {if (--myCounter==0) {delete this;} return myCounter;}
const wxString &File(void) const {return myFile;}
wxString &File(void) {return myFile;}
const wxString &Title(void) const {return myTitle;}
wxString &Title(void) {return myTitle;}
const wxString &Author(void) const {return myAuthor;}
wxString &Author(void) {return myAuthor;}
const wxString &Comment(void) const {return myComment;}
wxString &Comment(void) {return myComment;}
enumType Type(void) const {return myType;}
//void SetType(Type type) {myType = type;}
const enumStatus &Status(void) const {return myStatus;}
enumStatus &Status(void) {return myStatus;}
private:
wxString myFile;
wxString myTitle;
wxString myAuthor;
wxString myComment;
const enumType myType;
enumStatus myStatus;
int myCounter;
private:
/**
* forbid assignment!
* @param rh
* @return
*/
uMod_ModElement operator= (const uMod_ModElement & rh) {(void*) &rh; return *this;}
};
class uMod_TextureElement : public uMod_ModElement
{
public:
uMod_TextureElement() : uMod_ModElement(Texture) {}
virtual ~uMod_TextureElement() {}
uMod_Data<char> &Content(void) {return myContent;}
const DWORD64 &Hash(void) const {return myHash;}
DWORD64 &Hash(void) {return myHash;}
private:
uMod_Data<char> myContent;
DWORD64 myHash;
/**
* forbid assignment!
* @param rh
* @return
*/
uMod_TextureElement operator= (const uMod_TextureElement & rh) {(void*) &rh; return *this;}
};
//WX_DEFINE_ARRAY_PTR( uMod_ModElement*, uMod_ModElement_ArrayPtr );
WX_DEFINE_SORTED_ARRAY( uMod_TextureElement*, uMod_TextureElement_SortedArrayPtr );
int Compare_uMod_TextureElement(uMod_TextureElement* a, uMod_TextureElement* b);
#endif /* UMOD_MODELEMENT_H_ */
+191 -252
View File
@@ -23,45 +23,45 @@ along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>
uMod_Sender::uMod_Sender(PipeStruct &pipe) : Pipe(pipe)
{
OldTextures = NULL;
OldTexturesNum = 0;
try {Buffer = new char[BIG_BUFSIZE];}
catch (...) {Buffer=NULL;}
catch (...) {Buffer=(char*)0;}
OldTextures = (uMod_TextureElement_SortedArrayPtr*)0;
}
uMod_Sender::~uMod_Sender(void)
{
if (Buffer!=NULL) delete [] Buffer;
if (OldTextures!=NULL) delete [] OldTextures;
if (Buffer!=(char*)0) delete [] Buffer;
if (OldTextures != (uMod_TextureElement_SortedArrayPtr*)0)
{
for (unsigned int t=0; t<OldTextures->GetCount(); t++)
{
OldTextures->Item(t)->Release();
}
delete OldTextures;
}
}
int uMod_Sender::Send( const uMod_GameInfo &game, const uMod_GameInfo &game_old, bool force, wxArrayString *comments)
int uMod_Sender::Send( const uMod_GameInfo &game, const uMod_GameInfo &game_old, uMod_TextureElement_SortedArrayPtr* current_textures, bool force)
{
LastError.Empty();
int key = game.GetKeyBack();
if (key>=0 && key!=game_old.GetKeyBack())
{
key = Language->KeyValues[key];
SendKey( key, CONTROL_KEY_BACK);
}
key = game.GetKeySave();
if (key>=0 && key!=game_old.GetKeySave())
{
key = Language->KeyValues[key];
SendKey( key, CONTROL_KEY_SAVE);
}
key = game.GetKeyNext();
if (key>=0 && key!=game_old.GetKeyNext())
{
key = Language->KeyValues[key];
SendKey( key, CONTROL_KEY_NEXT);
}
int colour[3], colour_old[3];
unsigned char colour[4], colour_old[4];
game.GetFontColour( colour);
game_old.GetFontColour( colour_old);
for (int i=0; i<3; i++) if (colour[i]!=colour_old[i])
for (int i=0; i<4; i++) if (colour[i]!=colour_old[i])
{
SendColour( colour, CONTROL_FONT_COLOUR);
break;
@@ -69,182 +69,57 @@ int uMod_Sender::Send( const uMod_GameInfo &game, const uMod_GameInfo &game_old,
game.GetTextureColour( colour);
game_old.GetTextureColour( colour_old);
for (int i=0; i<3; i++) if (colour[i]!=colour_old[i])
for (int i=0; i<4; i++) if (colour[i]!=colour_old[i])
{
SendColour( colour, CONTROL_TEXTURE_COLOUR);
break;
}
SendDWORD64( game.FileFormat(), CONTROL_SAVE_FORMAT);
if ( game.GetSaveSingleTexture() != game_old.GetSaveSingleTexture() ) SendSaveSingleTexture( game.GetSaveSingleTexture());
if ( game.GetSaveAllTextures() != game_old.GetSaveAllTextures() ) SendSaveAllTextures(game.GetSaveAllTextures());
if (game.UseFormatFilter())
SendDWORD64( game.FormatFilter(), CONTROL_FORMAT_FILTER);
else
SendDWORD64( 0u, CONTROL_FORMAT_FILTER);
if (game.UseSizeFilter())
{
SendMinMax( game.WidthMin(), game.WidthMax(), CONTROL_WIDTH_FILTER);
SendMinMax( game.HeightMin(), game.HeightMax(), CONTROL_HEIGHT_FILTER);
SendMinMax( game.DepthMin(), game.DepthMax(), CONTROL_DEPTH_FILTER);
}
else
{
SendMinMax( 0, 0, CONTROL_HEIGHT_FILTER);
SendMinMax( 0, 0, CONTROL_HEIGHT_FILTER);
SendMinMax( 0, 0, CONTROL_HEIGHT_FILTER);
}
SendBool( game.ShowSingleTextureString(), CONTROL_SHOW_STRING);
SendBool( game.GetSaveSingleTexture(), CONTROL_SAVE_SINGLE);
SendBool(game.GetSaveAllTextures(), CONTROL_SAVE_ALL);
SendBool(game.SupportTPF(), CONTROL_SUPPORT_TPF);
wxString path;
path = game.GetSavePath();
if (path!=game_old.GetSavePath()) SendPath(path);
if (game.GetNumberOfFiles()<=0 && OldTexturesNum==0 && OldTextures==NULL)
if ( OldTextures== (uMod_TextureElement_SortedArrayPtr*)0) OldTextures = new uMod_TextureElement_SortedArrayPtr( Compare_uMod_TextureElement );
//uMod_TextureElement_SortedArrayPtr* current_textures = new uMod_TextureElement_SortedArrayPtr( Compare_uMod_TextureElement );
SendTextures( *OldTextures, *current_textures, force);
for (unsigned int t=0; t<OldTextures->GetCount(); t++)
{
if (LastError.Len()>0) return 1;
else return 0;
OldTextures->Item(t)->Release();
}
wxArrayString files;
game.GetFiles( files);
int num = files.GetCount();
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++)
{
uMod_File file( files[i]);
if (file.GetComment(comment))
{
LastError << file.LastError;
file.LastError.Empty();
}
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 (pos=0; pos<num && pos<OldTexturesNum; pos++)
{
if (OldTextures[pos].File == files[pos])
{
tex[pos].InheriteMemory(OldTextures[pos]);
tex[pos].Force = false;
hit[pos] = true;
}
else
{
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) )
{
uMod_File file( files[i]);
if (file.GetComment(comment))
{
LastError << file.LastError;
file.LastError.Empty();
}
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 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 (hit!=NULL) delete [] hit;
}
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);
}
if (OldTextures!=NULL) delete [] OldTextures;
OldTexturesNum = num;
OldTextures = tex;
delete OldTextures;
OldTextures = current_textures;
if (LastError.Len()>0) return 1;
else return 0;
@@ -275,101 +150,132 @@ int uMod_Sender::SendSaveSingleTexture(bool val)
}
int uMod_Sender::SendTextures(unsigned int num, AddTextureClass *tex)
int uMod_Sender::SendTextures(const uMod_TextureElement_SortedArrayPtr &old_tex, const uMod_TextureElement_SortedArrayPtr &new_tex, bool force)
{
if (Buffer==NULL) return (RETURN_NO_MEMORY);
if (Buffer==(char*)0) return (RETURN_NO_MEMORY);
unsigned int old_pos=0;
unsigned int new_pos=0;
MsgStruct *msg;
int pos = 0;
for (unsigned int i=0u; i<num; i++) for (unsigned int j=0u; j<tex[i].Num; j++)
int buffer_pos = 0;
// both arrays are sorted
// we go through both arrays in parallel
while (old_pos<old_tex.GetCount() && new_pos<new_tex.GetCount())
{
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 cost 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 (old_tex[old_pos]->Hash() < new_tex[new_pos]->Hash())
{
bool hit = false; //we send only if this has was not send before
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)
{
tex[i].WasAdded[j]=false; //no matter what is done for this hash before, this texture is not added!
continue;
}
unsigned int size = tex[i].Size[j];
if ((sizeof(MsgStruct) + pos) >=BIG_BUFSIZE) //the buffer is full
{
if (int ret = SendToGame( Buffer, pos)) return ret;
pos = 0;
}
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 is true or not
//if (Add==true && WasAdded[j]!=true) the texture 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)
{
unsigned int l = 0u;
while (l<size)
{
while (pos<BIG_BUFSIZE && l<size) Buffer[pos++] = temp[l++];
if (pos==BIG_BUFSIZE)
{
if (int ret = SendToGame( Buffer, pos)) return ret;
pos = 0;
}
}
}
tex[i].WasAdded[j] = true;
}
else
{
msg->Control = CONTROL_REMOVE_TEXTURE;
tex[i].WasAdded[j] = false;
}
RemoveTexture(old_tex[old_pos], buffer_pos);
old_pos++;
}
else if (tex[i].Add && tex[i].WasAdded[j]) // this texture could be removed, due to a rearranging of the list
else if (old_tex[old_pos]->Hash() < new_tex[new_pos]->Hash())
{
bool hit = false; //we send only if this has was not send before
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)
{
tex[i].WasAdded[j]=false; // due to rearranging this texture is replaced by an other texture
}
AddTexture(new_tex[new_pos], buffer_pos);
new_pos++;
}
else
{
//add if forced or if pointer are not the same, which means that two different textures modify the same target texture
if (force || old_tex[old_pos]!=new_tex[new_pos]) AddTexture( new_tex[new_pos], buffer_pos);
new_pos++;
old_pos++;
}
}
if ((sizeof(MsgStruct) + pos) >=BIG_BUFSIZE) //the buffer is full
// add remaining texture in new_tex
while (new_pos<new_tex.GetCount())
{
if (int ret = SendToGame( Buffer, pos)) return ret;
pos = 0;
AddTexture(new_tex[new_pos], buffer_pos);
new_pos++;
}
msg = (MsgStruct*) &Buffer[pos];
// delete remaining texture in old_tex
while (old_pos<old_tex.GetCount())
{
RemoveTexture(old_tex[old_pos], buffer_pos);
old_pos++;
}
//empty the buffer if it can't hold 1 MsgStruct anymore
if ((sizeof(MsgStruct) + buffer_pos) >=BIG_BUFSIZE) //the buffer is full
{
if (int ret = SendToGame( Buffer, buffer_pos)) return ret;
buffer_pos = 0;
}
msg = (MsgStruct*) &Buffer[buffer_pos];
msg->Control = CONTROL_END_TEXTURES; //End of texture sending
msg->Hash = 0u;
msg->Value = 0;
pos += sizeof(MsgStruct);
if (int ret = SendToGame( Buffer, pos)) return ret;
buffer_pos += sizeof(MsgStruct);
if (int ret = SendToGame( Buffer, buffer_pos)) return ret;
if (LastError.Len()>0) return 1;
else return 0;
}
int uMod_Sender::AddTexture( uMod_TextureElement *tex, int &buffer_pos)
{
MsgStruct *msg;
unsigned int size = tex->Content().Len();
if ((sizeof(MsgStruct) + buffer_pos) >=BIG_BUFSIZE) //the buffer is full
{
if (int ret = SendToGame( Buffer, buffer_pos)) return ret;
buffer_pos = 0;
}
msg = (MsgStruct*) &Buffer[buffer_pos];
msg->Hash = tex->Hash();
msg->Value = size;
msg->Control = CONTROL_FORCE_RELOAD_TEXTURE_DATA;
buffer_pos += sizeof(MsgStruct);
const char* temp = tex->Content().Data();
if (temp!=(char*)0)
{
unsigned int l = 0u;
while (l<size)
{
while (buffer_pos<BIG_BUFSIZE && l<size) Buffer[buffer_pos++] = temp[l++];
if (buffer_pos==BIG_BUFSIZE)
{
if (int ret = SendToGame( Buffer, buffer_pos)) return ret;
buffer_pos = 0;
}
}
}
if (LastError.Len()>0) return 1;
else return 0;
}
int uMod_Sender::RemoveTexture( uMod_TextureElement *tex, int &buffer_pos)
{
MsgStruct *msg;
//empty the buffer if it can't hold 1 MsgStruct anymore
if ((sizeof(MsgStruct) + buffer_pos) >=BIG_BUFSIZE) //the buffer is full
{
if (int ret = SendToGame( Buffer, buffer_pos)) return ret;
buffer_pos = 0;
}
msg = (MsgStruct*) &Buffer[buffer_pos];
msg->Hash = tex->Hash();
msg->Control = CONTROL_REMOVE_TEXTURE;
buffer_pos += sizeof(MsgStruct);
if (LastError.Len()>0) return 1;
else return 0;
}
int uMod_Sender::SendKey(int key, int ctr)
{
if (key<0) key=0;
MsgStruct msg;
msg.Control = ctr;
msg.Value = key;
@@ -380,11 +286,11 @@ int uMod_Sender::SendKey(int key, int ctr)
#define D3DCOLOR_ARGB(a,r,g,b) ((DWORD)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
int uMod_Sender::SendColour( int* colour, int ctr)
int uMod_Sender::SendColour( unsigned char* colour, int ctr)
{
MsgStruct msg;
msg.Control = ctr;
msg.Value = D3DCOLOR_ARGB( 255, colour[0], colour[1], colour[2]);
msg.Value = D3DCOLOR_ARGB( colour[3], colour[0], colour[1], colour[2]);
msg.Hash = 0u;
return SendToGame( (void*) &msg, sizeof(MsgStruct));
@@ -411,6 +317,39 @@ int uMod_Sender::SendPath( const wxString &path)
}
int uMod_Sender::SendBool( bool val, int ctr)
{
MsgStruct msg;
msg.Control = ctr;
if (val) msg.Value = 1;
else msg.Value = 0;
msg.Hash = 0u;
return SendToGame( (void*) &msg, sizeof(MsgStruct));
}
int uMod_Sender::SendDWORD64( DWORD64 val, int ctr)
{
MsgStruct msg;
msg.Control = ctr;
msg.Value = val;
msg.Hash = 0u;
return SendToGame( (void*) &msg, sizeof(MsgStruct));
}
int uMod_Sender::SendMinMax( unsigned long min, unsigned long max, int ctr)
{
DWORD64 u_min = min, u_max = max;
MsgStruct msg;
msg.Control = ctr;
msg.Value = u_min<<32 | u_max;
msg.Hash = 0u;
return SendToGame( (void*) &msg, sizeof(MsgStruct));
}
int uMod_Sender::SendToGame( void *msg, unsigned long len)
{
if (len==0) return (RETURN_BAD_ARGUMENT);
+13 -5
View File
@@ -31,7 +31,7 @@ public:
uMod_Sender(PipeStruct &pipe);
~uMod_Sender(void);
int Send( const uMod_GameInfo &game, const uMod_GameInfo &game_old, bool force=false, wxArrayString *comments=NULL);
int Send( const uMod_GameInfo &game, const uMod_GameInfo &game_old, uMod_TextureElement_SortedArrayPtr* current_textures, bool force=false);
wxString LastError;
@@ -39,13 +39,22 @@ private:
int SendSaveAllTextures(bool val);
int SendSaveSingleTexture(bool val);
int SendTextures(unsigned int num, AddTextureClass *tex);
int SendTextures(const uMod_TextureElement_SortedArrayPtr &old_tex, const uMod_TextureElement_SortedArrayPtr &new_tex, bool force);
int AddTexture( uMod_TextureElement *tex, int &buffer_pos);
int RemoveTexture( uMod_TextureElement *tex, int &buffer_pos);
int SendKey(int key, int ctr);
int SendPath( const wxString &path);
int SendColour( int* colour, int ctr);
int SendColour( unsigned char* colour, int ctr);
int SendBool( bool val, int ctr);
int SendDWORD64( DWORD64 val, int ctr);
int SendMinMax( unsigned long min, unsigned long max, int ctr);
char *Buffer;
int SendToGame( void* msg, unsigned long len);
@@ -55,8 +64,7 @@ private:
int AddContent( char* buffer, unsigned int len, const char* pw, AddTextureClass *tex, bool add, bool force);
PipeStruct &Pipe;
AddTextureClass *OldTextures;
int OldTexturesNum;
uMod_TextureElement_SortedArrayPtr *OldTextures;
};
+19 -17
View File
@@ -42,10 +42,6 @@ void* uMod_Server::Entry(void)
while(1)
{
/*
Beep(300,100);
Beep(600,100);
*/
pipe_in = CreateNamedPipeW(
PIPE_Game2uMod, // pipe name
PIPE_ACCESS_INBOUND, // read access
@@ -74,11 +70,7 @@ void* uMod_Server::Entry(void)
// at first connect to the incoming pipe !!!
fConnected = ConnectNamedPipe(pipe_in, NULL) ?
true : (GetLastError() == ERROR_PIPE_CONNECTED);
/*
Beep(900,100);
Beep(600,100);
Beep(300,100);
*/
if (fConnected)
{
unsigned long num = 0;
@@ -92,15 +84,15 @@ void* uMod_Server::Entry(void)
if (fSuccess)
{
if (num>2)
if (num>4)
{
buffer[num]=0;
buffer[num-1]=0;
wxString name = (wchar_t*) buffer;
int injection_method = * ((int*)buffer);
wxString name = (wchar_t*) &buffer[sizeof(int)];
if (name==abort) // kill this server thread
{
//Beep(1200,300);
CloseHandle(pipe_in);
return NULL;
}
@@ -110,11 +102,13 @@ void* uMod_Server::Entry(void)
true : (GetLastError() == ERROR_PIPE_CONNECTED);
if (fConnected)
{
uMod_Event event( uMod_EVENT_TYPE, ID_Add_Game);
event.SetName(name);
event.SetPipeIn(pipe_in);
event.SetPipeOut(pipe_out);
wxPostEvent( MainFrame, event);
uMod_Event *event = new uMod_Event( uMod_EVENT_TYPE, ID_Add_Game);
event->SetName(name.c_str());
event->SetValue(injection_method);
event->SetPipeIn(pipe_in);
event->SetPipeOut(pipe_out);
wxQueueEvent( MainFrame, (wxEvent*) event);
//wxPostEvent( MainFrame, event);
}
else
{
@@ -123,6 +117,14 @@ void* uMod_Server::Entry(void)
return NULL;
}
}
else
{
wxMessageBox("less than 4 bytes");
}
}
else
{
wxMessageBox("no success");
}
}
else CloseHandle(pipe_in);
+33 -8
View File
@@ -118,6 +118,19 @@ int uMod_Settings::Load(void)
}
}
int width, height;
wxDisplaySize( &width, &height);
if (XSize>width) XSize = width;
if (YSize>height) YSize = height;
if (XSize<50) XSize = 50;
if (YSize<50) YSize = 50;
if (XPos>width-XSize) XPos = width-XSize;
if (YPos>height-YSize) YPos = height-YSize;
if (XPos<0) XPos = 0;
if (YPos<0) YPos = 0;
return 0;
}
@@ -133,17 +146,29 @@ int uMod_Settings::Save(void)
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);
if (XSize>0 && XSize<50000)
{
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);
if (YSize>0 && YSize<50000)
{
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);
if (XPos>0 && XPos<50000)
{
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);
if (YPos>0 && YPos<50000)
{
content.Printf("y_pos:%d\n", YPos);
file.Write( content.wc_str(), content.Len()*2);
}
if (UseHook) content = "UseHook:1\n";
else content = "UseHook:0\n";
+762
View File
@@ -0,0 +1,762 @@
/*
This file is part of Universal Modding Engine.
Universal Modding Engine 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.
Universal Modding Engine 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 Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "uMod_Main.h"
wxString uMod_TreeViewModel::LastError = wxString();
void uMod_TreeViewModel::GetValue( wxVariant &variant,
const wxDataViewItem &item, unsigned int col ) const
{
wxASSERT(item.IsOk());
uMod_TreeViewNode *node = (uMod_TreeViewNode*) item.GetID();
switch (col)
{
case 0:
if (node->myElement->Title().IsEmpty()) variant = node->myElement->File();
else variant = node->myElement->Title();
break;
case 1:
variant = (bool) (node->myElement->Status()==uMod_ModElement::Activate);
break;
case 2:
variant = (bool) (node->myElement->Status()==uMod_ModElement::Deactivate);
break;
case 3:
variant = node->myElement->Author();
break;
case 4:
variant = node->myElement->Comment();
break;
default:
break;
}
}
bool uMod_TreeViewModel::SetValue( const wxVariant &variant,
const wxDataViewItem &item, unsigned int col )
{
wxASSERT(item.IsOk());
if (col<1 || col>2) return false;
uMod_TreeViewNode *node = (uMod_TreeViewNode*) item.GetID();
bool set;
variant.Convert( &set);
uMod_ModElement::enumStatus status = uMod_ModElement::NONE;
if (set)
{
switch (col)
{
case 1:
status = uMod_ModElement::Activate;
break;
case 2:
status = uMod_ModElement::Deactivate;
break;
default:
return false;
break;
}
node->myElement->Status() = status;
}
else
{
if (node->myElement->Type() == uMod_ModElement::Group)
{
node->myElement->Status() = uMod_ModElement::NONE;
}
}
return true;
}
bool uMod_TreeViewModel::IsEnabled( const wxDataViewItem &item,
unsigned int col ) const
{
//only the toggle are enabled
if (col<1 || col >3) return false;
uMod_TreeViewNode *node = (uMod_TreeViewNode*) item.GetID();
//an item is only enabled if no one of the parents is set.
uMod_TreeViewNode *parent = node->GetParent();
while (parent != (uMod_TreeViewNode*)0)
{
if (parent->myElement->Status()!=uMod_ModElement::NONE) return false;
parent = parent->GetParent();
}
return true;
}
wxDataViewItem uMod_TreeViewModel::GetParent( const wxDataViewItem &item ) const
{
// the invisible root node has no parent
if (!item.IsOk())
return wxDataViewItem(0);
uMod_TreeViewNode *node = (uMod_TreeViewNode*) item.GetID();
return wxDataViewItem( (void*) node->GetParent() );
}
bool uMod_TreeViewModel::HasContainerColumns( const wxDataViewItem &WXUNUSED(item) ) const
{
return true;
}
bool uMod_TreeViewModel::IsContainer( const wxDataViewItem &item ) const
{
// the invisble root node can have children
if (!item.IsOk())
return true;
uMod_TreeViewNode *node = (uMod_TreeViewNode*) item.GetID();
return node->IsContainer();
}
unsigned int uMod_TreeViewModel::GetChildren( const wxDataViewItem &parent,
wxDataViewItemArray &array ) const
{
uMod_TreeViewNode *node = (uMod_TreeViewNode*) parent.GetID();
if (!node)
{
unsigned int count = myPackages.GetCount();
for (unsigned int pos = 0; pos < count; pos++)
{
uMod_TreeViewNode *child = myPackages.Item( pos );
array.Add( wxDataViewItem( (void*) child ) );
}
return count;
}
if (node->GetChildCount() == 0)
{
return 0;
}
unsigned int count = node->GetChildren().GetCount();
for (unsigned int pos = 0; pos < count; pos++)
{
uMod_TreeViewNode *child = node->GetChildren().Item( pos );
array.Add( wxDataViewItem( (void*) child ) );
}
return count;
}
int uMod_TreeViewModel::CreateSingleNode()
{
if (SingleTextureNode ==(uMod_TreeViewNode*)0)
{
uMod_ModElement *package = new uMod_ModElement(uMod_ModElement::Group, uMod_ModElement::Activate);
SingleTextureNode = new uMod_TreeViewNode( (uMod_TreeViewNode*)0, package);
package->Release();
package->Title() = Language->SingleTextureNode;
myPackages.Add( SingleTextureNode);
wxDataViewItem child( (void*) SingleTextureNode );
wxDataViewItem parent( (void*) 0 );
ItemAdded( parent, child );
}
return 0;
}
int uMod_TreeViewModel::AddPackage(const wxString &file_name)
{
uMod_File file( file_name);
if (! file.FileSupported())
{
LastError << Language->Error_FileNotSupported << "\n" << file_name;
return -1;
}
bool single_file = file.SingleFile();
uMod_TreeViewNode *node;
if (single_file)
{
CreateSingleNode();
node = SingleTextureNode;
}
else
{
uMod_ModElement *package = new uMod_ModElement(uMod_ModElement::Group, uMod_ModElement::Activate);
node = new uMod_TreeViewNode( (uMod_TreeViewNode*)0, package);
package->Release();
package->File() = file_name;
}
if (int ret = file.GetContent(node))
{
LastError = file.LastError;
if (node != SingleTextureNode) delete node;
return ret;
}
if (node != SingleTextureNode)
{
myPackages.Add( node);
wxDataViewItem child( (void*) node );
wxDataViewItem parent( (void*) 0 );
ItemAdded( parent, child );
}
else if (SingleTextureNode != (uMod_TreeViewNode*)0)
{
wxDataViewItem child( (void*) SingleTextureNode->myChildren.Last() );
wxDataViewItem parent( SingleTextureNode );
ItemAdded( parent, child );
}
return 0;
}
int uMod_TreeViewModel::AddPackages(const wxArrayString &files)
{
LastError.Empty();
uMod_File file;
wxDataViewItemArray added_items;
wxDataViewItemArray added_single_items;
/*
bool single_file = false;
// detect if there are more than one single file
for (unsigned int i=0; i<files.GetCount(); i++)
{
file.SetFile( files[i]);
if (file.SingleFile()) {single_file = true;
}
*/
/*
if (single_files>1)
{
uMod_ModElement *element = new uMod_ModElement(uMod_ModElement::Group, uMod_ModElement::NONE);
element->Title() = Language->MultipleSingleFiles;
single_file_node = new uMod_TreeViewNode( (uMod_TreeViewNode*)0, element);
element->Release();
}
*/
for (unsigned int i=0; i<files.GetCount(); i++)
{
file.SetFile( files[i]);
if (! file.FileSupported())
{
LastError << Language->Error_FileNotSupported << "\n" << files[i] << "\n" ;
continue;
}
if (file.SingleFile())
{
CreateSingleNode();
if (file.GetContent(SingleTextureNode))
{
LastError << file.LastError ;
file.LastError.Empty();
continue;
}
wxDataViewItem child( (void*) SingleTextureNode->myChildren.Last() );
added_single_items.Add( child);
}
else
{
uMod_ModElement *package = new uMod_ModElement(uMod_ModElement::Group, uMod_ModElement::Activate);
uMod_TreeViewNode *node = new uMod_TreeViewNode( (uMod_TreeViewNode*)0, package);
package->Release();
package->File() = files[i];
if (file.GetContent(node))
{
LastError << file.LastError;
delete node;
file.LastError.Empty();
continue;
}
myPackages.Add( node);
wxDataViewItem child( (void*) node );
added_items.Add( child);
}
}
if (added_items.GetCount()>0)
{
wxDataViewItem parent( (void*) 0 );
ItemsAdded( parent, added_items);
}
if (added_single_items.GetCount()>0)
{
wxDataViewItem parent( SingleTextureNode );
ItemsAdded( parent, added_single_items);
}
if (LastError.IsEmpty()) return 0;
else return -1;
}
int uMod_TreeViewModel::AddPackagesFromTemplate(const wxArrayString &packages)
{
LastError.Empty();
uMod_File file;
wxDataViewItemArray added_items;
DeleteAllPackages();
for (unsigned int i=0; i<packages.GetCount(); i++)
{
uMod_ModElement *element = new uMod_ModElement(uMod_ModElement::Group, uMod_ModElement::Activate);
uMod_TreeViewNode *node = new uMod_TreeViewNode( (uMod_TreeViewNode*)0, element);
element->Release();
if (file.GetContentTemplate( packages[i], node))
{
LastError << file.LastError;
file.LastError.Empty();
delete node;
continue;
}
myPackages.Add( node);
wxDataViewItem child( (void*) node );
added_items.Add( child);
if (node->myElement->File().IsEmpty())
{
SingleTextureNode = node;
SingleTextureNode->myElement->Title() = Language->SingleTextureNode;
}
}
if (added_items.GetCount()>0)
{
wxDataViewItem parent( (void*) 0 );
ItemsAdded( parent, added_items);
}
if (LastError.IsEmpty()) return 0;
else return -1;
}
int uMod_TreeViewModel::DeletePackage( const wxDataViewItem &item)
{
uMod_TreeViewNode *node = (uMod_TreeViewNode*) item.GetID();
if (node)
{
if (node->GetParent()== (uMod_TreeViewNode*) 0 )
{
myPackages.Remove( node);
delete node;
if (node == SingleTextureNode) SingleTextureNode = (uMod_TreeViewNode*) 0;
wxDataViewItem parent( (void*) 0 );
ItemDeleted( parent, item );
return 0;
}
return 1;
}
return 2;
}
int uMod_TreeViewModel::DeletePackages( const wxDataViewItemArray &items)
{
int num = items.GetCount();
wxDataViewItemArray deleted_items;
for (int i=0; i<num; i++)
{
uMod_TreeViewNode *node = (uMod_TreeViewNode*) items[i].GetID();
if (node)
{
if (node->GetParent()== (uMod_TreeViewNode*) 0 )
{
myPackages.Remove( node);
delete node;
if (node == SingleTextureNode) SingleTextureNode = (uMod_TreeViewNode*) 0;
deleted_items.Add( items[i]);
}
}
}
wxDataViewItem parent( (void*) 0 );
ItemsDeleted( parent, deleted_items);
return 0;
}
int uMod_TreeViewModel::DeleteAllPackages(void)
{
wxDataViewItemArray deleted_items;
for (unsigned int i=0; i<myPackages.GetCount(); i++)
{
wxDataViewItem child( myPackages[i]);
deleted_items.Add( child);
}
SingleTextureNode = (uMod_TreeViewNode*) 0;
wxDataViewItem parent( (void*) 0 );
ItemsDeleted( parent, deleted_items);
myPackages.Empty();
return 0;
}
int uMod_TreeViewModel::GetActiveTexture( uMod_TextureElement_SortedArrayPtr &texture)
{
texture.Empty();
uMod_TreeViewNode_ArrayPtr buffer; // this array store the "path" to the current group node (parent0->parent1->parent2->current_group)
wxArrayInt counter; // this array store the actual index position for each group in the hierarchy
wxArrayInt active; // this array is need for the inherited active status of parent groups
for (unsigned int p=0; p<myPackages.GetCount(); p++)
{
if (myPackages.Item(p)->myElement->Status()==uMod_ModElement::Deactivate) continue;
if (myPackages.Item(p)->myElement->Type() == uMod_ModElement::Group)
{
buffer.Add(myPackages.Item(p));
counter.Add(0);
if (myPackages.Item(p)->myElement->Status()==uMod_ModElement::Activate) active.Add(1);
else active.Add(0);
while (!buffer.IsEmpty())
{
int pos = buffer.GetCount()-1;
unsigned int index = counter[pos];
if (index < buffer[pos]->myChildren.GetCount()) // it has still childrens
{
if (buffer[pos]->myChildren[index]->myElement->Type() == uMod_ModElement::Group)
{
if ((active[pos]>0) || (buffer[pos]->myChildren[index]->myElement->Status() != uMod_ModElement::Deactivate))
{
buffer.Add(buffer[pos]->myChildren[index]);
counter.Add(0);
if (active[pos]>0 || buffer[pos]->myChildren[index]->myElement->Status()==uMod_ModElement::Activate) active.Add(1);
else active.Add(0);
}
}
else if (buffer[pos]->myChildren[index]->myElement->Type() == uMod_ModElement::Texture)
{
uMod_TextureElement *tex = (uMod_TextureElement*) buffer[pos]->myChildren[index]->myElement;
if (tex->Content().Len()>0 && ((active[pos]>0) || (tex->Status()==uMod_ModElement::Activate)))
{
if( wxNOT_FOUND == texture.Index(tex))
{
texture.Add(tex);
tex->AddRef();
}
}
}
counter[pos]++;
}
else // finished this group
{
buffer.RemoveAt(pos);
counter.RemoveAt(pos);
active.RemoveAt(pos);
}
}
}
else if (myPackages.Item(p)->myElement->Type()==uMod_ModElement::Texture)
{
uMod_TextureElement *tex = (uMod_TextureElement*) myPackages.Item(p)->myElement;
if (tex->Status()==uMod_ModElement::Activate)
if (wxNOT_FOUND == texture.Index(tex))
{
texture.Add(tex);
tex->AddRef();
}
}
}
return 0;
}
int uMod_TreeViewModel::String2Node( const wxString &input, uMod_TreeViewNode* node, uMod_TreeViewNode_ArrayPtr *list_node)
{
if (list_node!=(uMod_TreeViewNode_ArrayPtr*)0) list_node->Empty();
wxStringTokenizer token( input, "\n");
int num = token.CountTokens();
bool found_start = false;
wxString entry;
wxString command;
wxString file;
wxString action;
wxString hash;
uMod_TreeViewNode_ArrayPtr buffer;
buffer.Add(node);
for (int i=0; i<num; i++)
{
entry = token.GetNextToken();
if (entry.Len()==0) continue;
if (entry[0]=='#') continue;
if (entry[0]=='!') continue;
wxStringTokenizer entry_token( entry, "|", wxTOKEN_RET_EMPTY_ALL);
command = entry_token.GetNextToken().Trim(true).Trim(false);
if (!found_start)
{
if (command=="PACKAGE")
{
found_start = true;
node->myElement->File() = entry_token.GetNextToken().Trim(true).Trim(false);
node->myElement->Title() = entry_token.GetNextToken().Trim(true).Trim(false);
action = entry_token.GetNextToken().Trim(true).Trim(false);
if (action=="D") node->myElement->Status() = uMod_ModElement::Deactivate;
else if (action=="A") node->myElement->Status() = uMod_ModElement::Activate;
else node->myElement->Status() = uMod_ModElement::NONE;
node->myElement->Author() = entry_token.GetNextToken().Trim(true).Trim(false);
node->myElement->Comment() = entry_token.GetNextToken().Trim(true).Trim(false);
}
continue;
}
if (command=="BEGIN_GROUP")
{
uMod_ModElement *element = new uMod_ModElement(uMod_ModElement::Group, uMod_ModElement::NONE);
uMod_TreeViewNode *node_group = new uMod_TreeViewNode(buffer.Last(), element);
element->Title() = entry_token.GetNextToken().Trim(true).Trim(false);
action = entry_token.GetNextToken().Trim(true).Trim(false);
if (action=="D") element->Status() = uMod_ModElement::Deactivate;
else if (action=="A") element->Status() = uMod_ModElement::Activate;
else element->Status() = uMod_ModElement::NONE;
element->Author() = entry_token.GetNextToken().Trim(true).Trim(false);
element->Comment() = entry_token.GetNextToken().Trim(true).Trim(false);
if (list_node != (uMod_TreeViewNode_ArrayPtr*)0) list_node->Add(node_group);
// add node to the last group
buffer.Last()->Append( node_group);
element->Release();
//set this group to the last group
buffer.Add( node_group);
}
else if (command=="END_GROUP")
{
if (buffer.GetCount()==0)
{
LastError << "There is an END_GROUP without a previous BEGIN_GROUP";
return -1;
}
buffer.RemoveAt(buffer.GetCount()-1);
}
else if (command=="TEXTURE")
{
if (buffer.GetCount()==0) continue;
file = entry_token.GetNextToken().Trim(true).Trim(false);
hash = entry_token.GetNextToken().Trim(true).Trim(false);
if (file.IsEmpty())
continue;
if (hash.IsEmpty())
continue;
DWORD64 temp_hash;
if (!hash.ToULongLong( &temp_hash, 16))
{
LastError << Language->Error_Hash << "\n";
continue;
}
uMod_TextureElement *texture = new uMod_TextureElement();
texture->File() = file;
texture->Hash() = temp_hash;
texture->Title() = entry_token.GetNextToken().Trim(true).Trim(false);
action = entry_token.GetNextToken().Trim(true).Trim(false);
if (action=="D") texture->Status() = uMod_ModElement::Deactivate;
else texture->Status() = uMod_TextureElement::Activate;
texture->Author() = entry_token.GetNextToken().Trim(true).Trim(false);
texture->Comment() = entry_token.GetNextToken().Trim(true).Trim(false);
uMod_TreeViewNode *node_texture = new uMod_TreeViewNode( buffer.Last(), texture);
if (list_node != (uMod_TreeViewNode_ArrayPtr*)0) list_node->Add(node_texture);
// add node to the last group
buffer.Last()->Append( node_texture);
texture->Release();
}
}
if (!found_start)
{
LastError = "Did not find 'PACKAGE' directive\n";
return -1;
}
return 0;
}
int uMod_TreeViewModel::Node2String( wxString &out, uMod_TreeViewNode* node)
{
if (node==(uMod_TreeViewNode*)0) return -1;
out.Empty();
uMod_TreeViewNode_ArrayPtr buffer; // this array store the "path" to the current group node (parent0->parent1->parent2->current_group)
wxArrayInt counter; // this array store the actual index position for each group in the hierarchy
if (node->myElement->Type() != uMod_ModElement::Group) return -1;
out << "\nPACKAGE|" << node->myElement->File() << "|";
out << node->myElement->Title() << "|";
if (node->myElement->Status() == uMod_ModElement::Activate) out << "A";
else if (node->myElement->Status() == uMod_ModElement::Deactivate) out << "D";
out << "|" << node->myElement->Author();
out << "|" << node->myElement->Comment() << "\n\n";
buffer.Add( node);
counter.Add(0);
/*
if (node->myElement->Type() == uMod_ModElement::Group)
{
buffer.Add(node);
counter.Add(0);
out << "\nBEGIN_GROUP|"<<node->myElement->Title() << "|";
if (node->myElement->Status() == uMod_ModElement::Activate) out << "A";
else if (node->myElement->Status() == uMod_ModElement::Deactivate) out << "D";
out << "|" << node->myElement->Author();
out << "|" << node->myElement->Comment();
out << "\n\n";
*/
while (!buffer.IsEmpty())
{
int pos = buffer.GetCount()-1;
unsigned int index = counter[pos];
if (index < buffer[pos]->myChildren.GetCount()) // it has still childrens
{
if (buffer[pos]->myChildren[index]->myElement->Type() == uMod_ModElement::Group)
{
uMod_TreeViewNode* node_child = buffer[pos]->myChildren[index];
out << "\nBEGIN_GROUP|"<< node_child->myElement->Title() << "|";
if (node_child->myElement->Status() == uMod_ModElement::Activate) out << "A";
else if (node_child->myElement->Status() == uMod_ModElement::Deactivate) out << "D";
out << "|" << node_child->myElement->Author();
out << "|" << node_child->myElement->Comment();
out << "\n";
buffer.Add(node_child);
counter.Add(0);
}
else if (buffer[pos]->myChildren[index]->myElement->Type() == uMod_ModElement::Texture)
{
uMod_TextureElement *tex = (uMod_TextureElement*) buffer[pos]->myChildren[index]->myElement;
out << "TEXTURE|"<< tex->File() << "|" ;
out << wxString::Format("%#llX", tex->Hash()) << "|";
out << tex->Title() << "|";
if (tex->Status() == uMod_ModElement::Deactivate) out << "D";
out << "|" << tex->Author();
out << "|" << tex->Comment();
out << "\n";
}
counter[pos]++;
}
else // finished this group
{
buffer.RemoveAt(pos);
counter.RemoveAt(pos);
if (buffer.GetCount()>0) out << "END_GROUP\n";
}
}
/*
}
else if (node->myElement->Type()==uMod_ModElement::Texture)
{
uMod_TextureElement *tex = (uMod_TextureElement*) node->myElement;
out << "TEXTURE|"<< tex->File() << "|" ;
out << wxString::Format("%#lX", tex->Hash()) << "|";
out << tex->Title() << "|";
if (tex->Status() == uMod_ModElement::Deactivate) out << "D";
out << "|" << tex->Author();
out << "|" << tex->Comment();
out << "\n\n";
}
*/
return 0;
}
/*
bool uMod_TreeViewModel::IsSameNod(uMod_TreeViewNode* a, uMod_TreeViewNode* b)
{
// at first we test for object specific stats
if (a->myElement->Type()==uMod_ModElement::Group && b->myElement->Type()==uMod_ModElement::Group)
{
//title must be the same
if (a->myElement->Title() != b->myElement->Title()) return false;
}
else if (a->myElement->Type()==uMod_ModElement::Texture && b->myElement->Type()==uMod_ModElement::Texture)
{
uMod_TextureElement *tex_a = (uMod_TextureElement*) a->myElement;
uMod_TextureElement *tex_b = (uMod_TextureElement*) b->myElement;
//Hash, Title, and File must be the same
if (tex_a->Hash() != tex_b->Hash()) return false;
if (tex_a->Title() != tex_b->Title()) return false;
if (tex_a->File() != tex_b->File()) return false;
}
else return false; //not the same objects
// now we compare their parents
// the title of their parents must be the same
if (a->GetParent()!=(uMod_TreeViewNode*)0)
{
if (b->GetParent()!=(uMod_TreeViewNode*)0)
{
if (a->GetParent()->myElement->Title() == b->GetParent()->myElement->Title()) return true;
else return false;
}
else return false;
}
else if (b->GetParent()!=(uMod_TreeViewNode*)0) return false;
else return true; //both are root textures
}
*/
+136
View File
@@ -0,0 +1,136 @@
/*
This file is part of Universal Modding Engine.
Universal Modding Engine 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.
Universal Modding Engine 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 Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef uMod_TREEVIEW_H_
#define uMod_TREEVIEW_H_
#include "wx/dataview.h"
#include "uMod_ModElement.h"
class uMod_TreeViewNode;
WX_DEFINE_ARRAY_PTR( uMod_TreeViewNode*, uMod_TreeViewNode_ArrayPtr );
class uMod_TreeViewNode
{
public:
uMod_TreeViewNode( uMod_TreeViewNode* parent, uMod_ModElement *element) : myParent(parent), myElement(element)
{
myElement->AddRef();
}
~uMod_TreeViewNode()
{
// free all our children nodes
size_t count = myChildren.GetCount();
for (size_t i = 0; i < count; i++)
{
uMod_TreeViewNode *child = myChildren[i];
delete child;
}
myElement->Release();
}
bool IsContainer() const {if (myElement->Type() == uMod_ModElement::Group) return true; else return false;}
uMod_TreeViewNode* GetParent() {return myParent;}
uMod_TreeViewNode_ArrayPtr& GetChildren() {return myChildren;}
uMod_TreeViewNode* GetNthChild( unsigned int n ) {return myChildren.Item( n);}
void Insert( uMod_TreeViewNode* child, unsigned int n) {myChildren.Insert( child, n);}
void Append( uMod_TreeViewNode* child ) {myChildren.Add( child );}
unsigned int GetChildCount() const {return myChildren.GetCount();}
public: // public to avoid getters/setters
uMod_ModElement *myElement;
//private:
uMod_TreeViewNode* myParent;
uMod_TreeViewNode_ArrayPtr myChildren;
};
class uMod_TreeViewModel : public wxDataViewModel
{
public:
uMod_TreeViewModel() : SingleTextureNode((uMod_TreeViewNode*)0) {}
virtual ~uMod_TreeViewModel() {}
// implementation of base class virtuals to define model
virtual unsigned int GetColumnCount() const
{
return 5;
}
virtual wxString GetColumnType( unsigned int col ) const
{
(void) col;
return wxT("string");
}
virtual void GetValue( wxVariant &variant,
const wxDataViewItem &item, unsigned int col ) const;
virtual bool SetValue( const wxVariant &variant,
const wxDataViewItem &item, unsigned int col );
virtual bool IsEnabled( const wxDataViewItem &item,
unsigned int col ) const;
virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
virtual bool HasContainerColumns( const wxDataViewItem &item ) const;
virtual bool IsContainer( const wxDataViewItem &item ) const;
virtual unsigned int GetChildren( const wxDataViewItem &parent,
wxDataViewItemArray &array ) const;
// implementation of uMod functions
int CreateSingleNode(void);
int AddPackage(const wxString &file_name);
int AddPackages(const wxArrayString &files);
int AddPackagesFromTemplate(const wxArrayString &packages);
int DeletePackage( const wxDataViewItem &item);
int DeletePackages( const wxDataViewItemArray &item);
int DeleteAllPackages(void);
int GetActiveTexture( uMod_TextureElement_SortedArrayPtr &texture);
static int String2Node( const wxString &input, uMod_TreeViewNode* node, uMod_TreeViewNode_ArrayPtr *list_node = (uMod_TreeViewNode_ArrayPtr*)0);
static int Node2String( wxString &out, uMod_TreeViewNode* node);
// static bool IsSameNod(uMod_TreeViewNode* a, uMod_TreeViewNode* b);
static wxString LastError;
//private:
uMod_TreeViewNode *SingleTextureNode;
uMod_TreeViewNode_ArrayPtr myPackages;
};
#endif /* uMod_TREEVIEW_H_ */