Browse Source

- reworked CMake build
- added filesystem
- added zip support
- removed system folder

Denis Muratshin 12 years ago
parent
commit
1a5f96a7c7
95 changed files with 4688 additions and 775 deletions
  1. 5 0
      .hg_archival.txt
  2. 1 0
      .hgignore
  3. 30 115
      CMakeLists.txt
  4. 14 0
      change_log.txt
  5. BIN
      doc.zip
  6. 15 0
      examples/CMakeLists.txt
  7. 5 11
      examples/Demo/CMakeLists.txt
  8. 55 0
      examples/Demo/data/demo/big.bmfc
  9. BIN
      examples/Demo/data/demo/button.png
  10. BIN
      examples/Demo/data/demo/eng.txt
  11. 6 0
      examples/Demo/data/demo/fonts.xml
  12. BIN
      examples/Demo/data/demo/loading.png
  13. BIN
      examples/Demo/data/demo/logo2.png
  14. 55 0
      examples/Demo/data/demo/main.bmfc
  15. 9 0
      examples/Demo/data/demo/res_ui.xml
  16. 2 2
      examples/Demo/prepare_res.bat
  17. 2 2
      examples/Demo/prepare_res_etc1.bat
  18. 2 2
      examples/Demo/prepare_res_pvrtc.bat
  19. 86 0
      examples/Demo/src/TestDrag.h
  20. 1 1
      examples/Demo/src/TestManageRes.h
  21. 21 25
      examples/Demo/src/TestUserShader.h
  22. 1 0
      examples/Demo/src/entry_point.cpp
  23. 13 3
      examples/Demo/src/example.cpp
  24. 1 0
      examples/Demo/src/example.h
  25. 18 0
      examples/DemoBox2D/CMakeLists.txt
  26. 11 0
      examples/GameTemplate/CMakeLists.txt
  27. 11 0
      examples/GameTemplate/src/entry_point.cpp
  28. 9 0
      examples/HelloWorld/CMakeLists.txt
  29. 1 1
      examples/HelloWorld/data/development.icf
  30. 1 0
      examples/HelloWorld/src/entry_point.cpp
  31. 9 0
      examples/HelloWorld/src/example.cpp
  32. 2 0
      examples/HelloWorld/src/example.h
  33. 15 0
      examples/Match3/CMakeLists.txt
  34. 4 4
      examples/Match3/src/gameframe.cpp
  35. 2 2
      examples/Match3/src/jewels.cpp
  36. BIN
      oxygine/SDL/android/SDLTests.zip
  37. 6 7
      oxygine/SDL/android/jni/Android.mk
  38. 48 27
      oxygine/SDL/win32/oxygine_vs2010.vcxproj
  39. 299 233
      oxygine/SDL/win32/oxygine_vs2010.vcxproj.filters
  40. 5 0
      oxygine/marmalade/oxygine-framework.mkf
  41. 5 0
      oxygine/marmalade/oxygine.mkf
  42. 19 4
      oxygine/src/Actor.cpp
  43. 2 2
      oxygine/src/Actor.h
  44. 6 1
      oxygine/src/AnimationFrame.h
  45. 1 1
      oxygine/src/ClipRectActor.cpp
  46. 6 3
      oxygine/src/Clock.cpp
  47. 21 18
      oxygine/src/DebugActor.cpp
  48. 61 33
      oxygine/src/Draggable.cpp
  49. 7 1
      oxygine/src/Draggable.h
  50. 2 0
      oxygine/src/EventDispatcher.h
  51. 1 2
      oxygine/src/Input.cpp
  52. 4 1
      oxygine/src/Input.h
  53. 2 2
      oxygine/src/MemoryTexture.cpp
  54. 1 1
      oxygine/src/MemoryTexture.h
  55. 85 0
      oxygine/src/core/FileSystem.cpp
  56. 52 0
      oxygine/src/core/FileSystem.h
  57. 2 2
      oxygine/src/core/NativeTexture.cpp
  58. 1 1
      oxygine/src/core/Object.cpp
  59. 223 0
      oxygine/src/core/STDFileSystem.cpp
  60. 20 0
      oxygine/src/core/STDFileSystem.h
  61. 221 0
      oxygine/src/core/ZipFileSystem.cpp
  62. 68 0
      oxygine/src/core/ZipFileSystem.h
  63. 172 0
      oxygine/src/core/file.cpp
  64. 87 0
      oxygine/src/core/file.h
  65. 3 75
      oxygine/src/core/files_io.h
  66. 2 2
      oxygine/src/core/gl/NativeTextureGLES.cpp
  67. 27 105
      oxygine/src/core/gl/VideoDriverGLES20.cpp
  68. 6 2
      oxygine/src/core/gl/VideoDriverGLES20.h
  69. 17 16
      oxygine/src/core/gl/oxgl.h
  70. 139 0
      oxygine/src/core/log.cpp
  71. 30 0
      oxygine/src/core/log.h
  72. 3 30
      oxygine/src/core/logging.h
  73. 1 1
      oxygine/src/core/ox_debug.h
  74. 1 1
      oxygine/src/core/oxygine.cpp
  75. 2 2
      oxygine/src/core/oxygine.h
  76. 3 0
      oxygine/src/core/system_data.cpp
  77. 7 0
      oxygine/src/core/system_data.h
  78. 10 3
      oxygine/src/math/Rect.h
  79. 1 0
      oxygine/src/math/vector2.h
  80. 178 0
      oxygine/src/minizip/ioapi.c
  81. 75 0
      oxygine/src/minizip/ioapi.h
  82. 219 0
      oxygine/src/minizip/ioapi_mem.c
  83. 8 0
      oxygine/src/minizip/ioapi_mem.h
  84. 1701 0
      oxygine/src/minizip/unzip.c
  85. 360 0
      oxygine/src/minizip/unzip.h
  86. 2 2
      oxygine/src/oxygine-framework.h
  87. 1 1
      oxygine/src/res/ResAtlas.h
  88. 1 1
      oxygine/src/res/ResBuffer.h
  89. 1 1
      oxygine/src/res/ResFontBM.cpp
  90. 1 1
      oxygine/src/res/ResStarlingAtlas.cpp
  91. 5 5
      oxygine/src/res/Resources.cpp
  92. 1 1
      oxygine/src/utils/ImageUtils.h
  93. 1 1
      oxygine/src/utils/stringUtils.cpp
  94. 47 17
      oxygine/system_data/build.py
  95. 1 1
      readme.SDL2

+ 5 - 0
.hg_archival.txt

@@ -0,0 +1,5 @@
+repo: b6d71054df5712e643a0685bc3ba54b123db5729
+node: a30d4ad4f27c82fbc3bf6f7f5a2cfb492d0893f7
+branch: default
+latesttag: null
+latesttagdistance: 176

+ 1 - 0
.hgignore

@@ -78,5 +78,6 @@ examples/Match3/build_match3_src_vc11/
 
 oxygine-framework.zip
 examples/TutorialResources/build_tutorialresources_vc11/
+oxygine/system_data/system.zip
 syntax: regexp
 ^build/

+ 30 - 115
CMakeLists.txt

@@ -1,122 +1,50 @@
 cmake_minimum_required (VERSION 2.6)
-set(CMAKE_LEGACY_CYGWIN_WIN32 0)
-
 project (OXYGINE)
 
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${OXYGINE_SOURCE_DIR}/cmake/)
-
-
-set(OXYGINE_ROOT_SRC ${OXYGINE_SOURCE_DIR}/oxygine/src/)
-
-set(FLASCC ${CYGWIN})
-
-if (FLASCC)
-	message(STATUS fcc)
-else(FLASCC)
-	message(STATUS notfcc)
-	set(OXYGINE_DEFINITIONS	
-		-DOXYGINE_SDL
-		-D_CRT_SECURE_NO_WARNINGS)
-	find_package(SDL2)
-	file(GLOB OXYGINE_SOURCES
-		${OXYGINE_SOURCE_DIR}/oxygine/greenlets/src/*.c)
-endif(FLASCC) 
+#SDL2
+set(SDL2_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../sdl/include)
+set(SDL2_LIBRARIES sdl2)
 
+set(OXYGINE_DEFINITIONS	
+	-DOXYGINE_SDL
+	-D_CRT_SECURE_NO_WARNINGS)
 
+set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/oxygine/greenlets/src/*.c)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/oxygine/greenlets/src/)
 
-set(INCLUDED_FOLDERS 
-	.
-	pugixml
-	closure
-	core
-	math	
-	utils	
-	res)
 
-set(NOT_INCLUDED_FOLDERS
-	dev_tools
-	text_utils	
-	winnie_alloc)
-
-if (FLASCC)
-	set(NOT_INCLUDED_FOLDERS 
-		${NOT_INCLUDED_FOLDERS}
-		core/stage3d)
-else(FLASCC)
-	set(NOT_INCLUDED_FOLDERS 
-		${NOT_INCLUDED_FOLDERS}
-		core/gl)
-endif(FLASCC)
-
-set(FOLDERS ${INCLUDED_FOLDERS} ${NOT_INCLUDED_FOLDERS})
-set(OXYGINE_INCLUDE_DIRS ${OXYGINE_ROOT_SRC})
+set(THIRD_PARTY ${CMAKE_CURRENT_SOURCE_DIR}/oxygine/third_party/win32)
 
+set(OXYGINE_ROOT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/oxygine/src)
+set(FOLDERS . closure minizip core core/gl dev_tools minizip math pugixml res text_utils utils winnie_alloc)
 foreach(F ${FOLDERS})
-	file(GLOB CPP ${OXYGINE_ROOT_SRC}/${F}/*.cpp)
-	file(GLOB HDR ${OXYGINE_ROOT_SRC}/${F}/*.h)
-
-	set(OXYGINE_SOURCES ${OXYGINE_SOURCES} ${CPP} ${HDR})
-	list(FIND NOT_INCLUDED_FOLDERS ${F} DONT_INCLUDE)
-
-	#if (DONT_INCLUDE EQUAL -1)		
-	#	set(OXYGINE_INCLUDE_DIRS ${OXYGINE_INCLUDE_DIRS} ${OXYGINE_ROOT_SRC}/${F})
-	#endif()
-
-	source_group(src\\${F} FILES ${CPP} ${HDR})
+	file(GLOB FLS #RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/
+		${OXYGINE_ROOT_SRC}/${F}/*.cpp
+		${OXYGINE_ROOT_SRC}/${F}/*.c
+		${OXYGINE_ROOT_SRC}/${F}/*.h)
+	set(SOURCES ${SOURCES} ${FLS})
+	source_group(${F} FILES ${FLS})
 endforeach(F)
 
 
-if (WIN32)
-	find_package(OPENGL)
-	set(THIRD_PARTY ${OXYGINE_SOURCE_DIR}/oxygine/third_party/win32)
-endif(WIN32)
 
-if (APPLE)
-	find_library(OpenGL_LIBRARY OpenGL)
-	mark_as_advanced(OpenGL_LIBRARY)
-	
-	set(THIRD_PARTY ${OXYGINE_SOURCE_DIR}/oxygine/third_party/macosx)
-	set(OXYGINE_INCLUDE_DIRS ${OXYGINE_INCLUDE_DIRS} /System/Library/Frameworks)	
-	set(OPENGL_LIBRARIES ${OPENGL_LIBRARIES} ${OpenGL_LIBRARY})
-endif(APPLE)
+set(OXYGINE_INCLUDE_DIRS 
+	${OXYGINE_ROOT_SRC}
+	${SDL2_INCLUDE_DIRS}
+	${THIRD_PARTY}/glew
+	${THIRD_PARTY}/zlib)
 
+include_directories(${OXYGINE_INCLUDE_DIRS})
 
-include_directories(
-	${SDL2_INCLUDE_DIRS}
-	${OXYGINE_SOURCE_DIR}/oxygine/greenlets/src/
-	${OXYGINE_INCLUDE_DIRS}
-)
 
-if (THIRD_PARTY)
-	include_directories(
+find_package(OPENGL)
+include_directories(
 		${THIRD_PARTY}/libjpeg
 		${THIRD_PARTY}/libpng
-		${THIRD_PARTY}/zlib
-		${THIRD_PARTY}/glew
-	)
-else(THIRD_PARTY)	
-	include_directories(
-		${FLASCC_SDK_DIR}/usr/include/libpng15
-	)
-	set(OXYGINE_LIBRARY_DIRS
-		${OXYGINE_LIBRARY_DIRS}
-		${FLASCC_SDK_DIR}/usr/lib)
-endif(THIRD_PARTY)
-
-
-set(OXYGINE_INCLUDE_DIRS 
-	${FLASCC_SDK_DIR}/usr/include/libpng15
-	${THIRD_PARTY}/glew
-	${OXYGINE_INCLUDE_DIRS} 
-	${THIRD_PARTY}/zlib
-	${SDL2_INCLUDE_DIRS}
-	PARENT_SCOPE)
+		)
 
 add_definitions(${OXYGINE_DEFINITIONS})
-
-
-add_library(oxygine STATIC ${OXYGINE_SOURCES})
-
+add_library(oxygine STATIC ${SOURCES})
 
 
 set(OXYGINE_LIBRARY_DIRS
@@ -124,7 +52,6 @@ set(OXYGINE_LIBRARY_DIRS
 	${OXYGINE_SOURCE_DIR}/libs
 	${THIRD_PARTY}/libraries)
 
-
 set(STATIC_LIB_NAMES 
 	libpng
 	libjpeg
@@ -145,21 +72,10 @@ set(OXYGINE_CORE_LIBS
 	${OXYGINE_CORE_LIBS}
 	${OPENGL_LIBRARIES}
 	oxygine
+	glew32
 )
 
 
-if (WIN32)
-	set(OXYGINE_CORE_LIBS 
-		${OXYGINE_CORE_LIBS}
-		glew32)
-endif(WIN32)
-
-if (APPLE)
-endif(APPLE)
-
-
-#export variables to parent scope
-
 set(OXYGINE_LIBRARY_DIRS
 	${OXYGINE_LIBRARY_DIRS}
 	PARENT_SCOPE)
@@ -172,8 +88,7 @@ set(OXYGINE_DEFINITIONS
 	${OXYGINE_DEFINITIONS}
 	PARENT_SCOPE)
 
-set(OXYGINE_SOURCES
-	${OXYGINE_SOURCES}
+set(OXYGINE_INCLUDE_DIRS
+	${OXYGINE_INCLUDE_DIRS}
 	PARENT_SCOPE)
 
-

+ 14 - 0
change_log.txt

@@ -0,0 +1,14 @@
+Updates between v1.02 and v 1.03
+=================
+- reworked CMake build
+- added filesystem
+- added zip support
+- removed system folder
+
+
+
+Updates between v1.01 and v 1.02
+=================
+- Headers "files_ui.h" and "logging.h" were deprecated. Replace all includes with "file.h" and "log.h"
+- Optimized shaders loading
+

BIN
doc.zip


+ 15 - 0
examples/CMakeLists.txt

@@ -0,0 +1,15 @@
+cmake_minimum_required (VERSION 2.6)
+project (EXAMPLES)
+
+add_subdirectory(../ oxygine-framework)
+
+add_definitions(${OXYGINE_DEFINITIONS})
+include_directories(${OXYGINE_INCLUDE_DIRS})
+link_directories(${OXYGINE_LIBRARY_DIRS})
+
+
+add_subdirectory(demo)
+add_subdirectory(HelloWorld)
+add_subdirectory(Match3)
+add_subdirectory(GameTemplate)
+add_subdirectory(DemoBox2D)

+ 5 - 11
examples/Demo/CMakeLists.txt

@@ -1,16 +1,10 @@
 cmake_minimum_required (VERSION 2.6)
 project (DEMO)
 
-#add oxygine-framework/oxygine as child project
-add_subdirectory(../../ oxygine)
+add_executable(demo 
+	src/entry_point.cpp
+	src/example.h	
+	src/example.cpp
+	src/test.cpp)
 
-add_definitions(${OXYGINE_DEFINITIONS})
-include_directories(${OXYGINE_INCLUDE_DIRS})
-link_directories(${OXYGINE_LIBRARY_DIRS})
-
-set(SRC src/entry_point.cpp
-		src/example.cpp
-		src/test.cpp)
-
-add_executable(demo ${SRC})
 target_link_libraries(demo ${OXYGINE_CORE_LIBS})

+ 55 - 0
examples/Demo/data/demo/big.bmfc

@@ -0,0 +1,55 @@
+# AngelCode Bitmap Font Generator configuration file
+fileVersion=1
+
+# font settings
+fontName=Arial
+fontFile=
+charSet=177
+fontSize=-26
+aa=1
+scaleH=100
+useSmoothing=1
+isBold=1
+isItalic=1
+useUnicode=1
+disableBoxChars=1
+outputInvalidCharGlyph=0
+dontIncludeKerningPairs=0
+useHinting=0
+renderFromOutline=1
+useClearType=0
+
+# character alignment
+paddingDown=0
+paddingUp=0
+paddingRight=0
+paddingLeft=0
+spacingHoriz=1
+spacingVert=1
+useFixedHeight=1
+forceZero=1
+
+# output file
+outWidth=512
+outHeight=256
+outBitDepth=32
+fontDescFormat=1
+fourChnlPacked=0
+textureFormat=png
+textureCompression=0
+alphaChnl=0
+redChnl=0
+greenChnl=0
+blueChnl=0
+invA=0
+invR=0
+invG=0
+invB=0
+
+# outline
+outlineThickness=2
+
+# selected chars
+chars=160
+
+# imported icon images

BIN
examples/Demo/data/demo/button.png


BIN
examples/Demo/data/demo/eng.txt


+ 6 - 0
examples/Demo/data/demo/fonts.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<resources>
+	<set path = "demo" />
+	<bmfc_font file="main.bmfc" chars="eng.txt"/>	
+	<bmfc_font file="big.bmfc" chars="eng.txt"/>
+</resources>

BIN
examples/Demo/data/demo/loading.png


BIN
examples/Demo/data/demo/logo2.png


+ 55 - 0
examples/Demo/data/demo/main.bmfc

@@ -0,0 +1,55 @@
+# AngelCode Bitmap Font Generator configuration file
+fileVersion=1
+
+# font settings
+fontName=Arial
+fontFile=
+charSet=177
+fontSize=-16
+aa=1
+scaleH=100
+useSmoothing=1
+isBold=1
+isItalic=0
+useUnicode=1
+disableBoxChars=1
+outputInvalidCharGlyph=0
+dontIncludeKerningPairs=0
+useHinting=0
+renderFromOutline=1
+useClearType=0
+
+# character alignment
+paddingDown=0
+paddingUp=0
+paddingRight=0
+paddingLeft=0
+spacingHoriz=1
+spacingVert=1
+useFixedHeight=1
+forceZero=1
+
+# output file
+outWidth=512
+outHeight=256
+outBitDepth=32
+fontDescFormat=1
+fourChnlPacked=0
+textureFormat=png
+textureCompression=0
+alphaChnl=1
+redChnl=0
+greenChnl=0
+blueChnl=0
+invA=0
+invR=0
+invG=0
+invB=0
+
+# outline
+outlineThickness=0
+
+# selected chars
+chars=160
+
+# imported icon images

+ 9 - 0
examples/Demo/data/demo/res_ui.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<resources>
+	<set path = "demo" />
+	<atlas>
+		<image file="loading.png"/>		
+		<image file="logo2.png"/>		
+		<image file="button.png" cols = "3" />	
+	</atlas>	
+</resources>

+ 2 - 2
examples/Demo/prepare_res.bat

@@ -1,3 +1,3 @@
 python ..\..\tools\process_xml2.py -x xmls/res.xml --src_data data --dest_data data/ext
-python ..\..\tools\process_xml2.py -x xmls/res_ui.xml --src_data data --dest_data data/ext
-python ..\..\tools\process_xml2.py -x xmls/fonts.xml --src_data data --dest_data data/ext
+python ..\..\tools\process_xml2.py -x demo/res_ui.xml --src_data data --dest_data data/ext
+python ..\..\tools\process_xml2.py -x demo/fonts.xml --src_data data --dest_data data/ext

+ 2 - 2
examples/Demo/prepare_res_etc1.bat

@@ -1,3 +1,3 @@
 python ..\..\tools\process_xml2.py -x xmls/res.xml --src_data data --dest_data data/ext --compress etc1
-python ..\..\tools\process_xml2.py -x xmls/res_ui.xml --src_data data --dest_data data/ext --compress etc1
-python ..\..\tools\process_xml2.py -x xmls/fonts.xml --src_data data --dest_data data/ext --compress etc1
+python ..\..\tools\process_xml2.py -x demo/res_ui.xml --src_data data --dest_data data/ext --compress etc1
+python ..\..\tools\process_xml2.py -x demo/fonts.xml --src_data data --dest_data data/ext --compress etc1

+ 2 - 2
examples/Demo/prepare_res_pvrtc.bat

@@ -1,3 +1,3 @@
 python ..\..\tools\process_xml2.py -x xmls/res.xml --src_data data --dest_data data/ext --compress pvrtc
-python ..\..\tools\process_xml2.py -x xmls/res_ui.xml --src_data data --dest_data data/ext --compress pvrtc
-python ..\..\tools\process_xml2.py -x xmls/fonts.xml --src_data data --dest_data data/ext --compress pvrtc
+python ..\..\tools\process_xml2.py -x demo/res_ui.xml --src_data data --dest_data data/ext --compress pvrtc
+python ..\..\tools\process_xml2.py -x demo/fonts.xml --src_data data --dest_data data/ext --compress pvrtc

+ 86 - 0
examples/Demo/src/TestDrag.h

@@ -60,3 +60,89 @@ public:
 		actor->setColor(Color(255,255,255,255));
 	}
 };
+
+
+class Drag2Test: public Test
+{
+public:
+	spSprite basket;
+	spSprite ball;
+	spSprite dragging;
+
+	timeMS timeLeft;
+	const PointerState *touchedBy;
+	Draggable drag;
+	
+	Drag2Test():touchedBy(0), timeLeft(0)
+	{
+		basket = initActor(new Sprite,
+			arg_name = "basket",
+			arg_resAnim = resources.getResAnim("batterfly"),
+			arg_attachTo= content,
+			arg_x = content->getWidth() * 3 / 4,
+			arg_y = content->getHeight() / 2);
+
+		ball = initActor(new Sprite,
+			arg_name = "ball",
+			arg_resAnim = resources.getResAnim("batterfly"),
+			arg_attachTo= content,
+			arg_x = content->getWidth() * 1 / 4,
+			arg_y = content->getHeight() / 2);
+
+		ball->addEventListener(TouchEvent::TOUCH_DOWN, CLOSURE(this,  &Drag2Test::ballTouchDown));
+		ball->addEventListener(TouchEvent::TOUCH_UP, CLOSURE(this,  &Drag2Test::ballTouchUp));
+		content->addEventListener(TouchEvent::TOUCH_UP, CLOSURE(this, &Drag2Test::touchUp));
+	}
+
+	
+	void ballTouchUp(Event *event)
+	{
+		touchedBy = 0;
+	}
+
+	void touchUp(Event *event)
+	{
+		if (!dragging)
+			return;
+		if (event->currentTarget.get() != content)
+			return;
+
+		dragging->setColor(Color(0xffffffff));
+		spTween t;
+		if (event->target == basket)
+			t = dragging->addTween(Actor::TweenPosition(basket->getPosition()), 500);
+		else
+			t = dragging->addTween(Actor::TweenPosition(ball->getPosition()), 500);
+		t->setDetachActor(true);
+		dragging = 0;
+	}
+
+
+	void ballTouchDown(Event* ev)
+	{
+		TouchEvent *te = safeCast<TouchEvent*>(ev);
+		touchedBy = te->getPointer();
+		timeLeft = 500;		
+	}
+
+	void doUpdate(const UpdateState &us)
+	{
+		if (!timeLeft)
+			return;
+		if (!touchedBy)
+			return;
+
+		timeLeft -= us.dt;
+		if (timeLeft <= 0)
+		{
+			timeLeft = 0;
+			dragging = initActor(ball->clone(),
+				arg_name = "dragging",
+				arg_attachTo = ball->getParent(),
+				arg_color = Color(0xff0000ff),
+				arg_input = false);
+			drag.start(touchedBy, dragging.get(), dragging->getSize()/2);
+		}
+	}
+private:
+};

+ 1 - 1
examples/Demo/src/TestManageRes.h

@@ -24,7 +24,7 @@ public:
 			spSprite sprite = new Sprite;
 			sprite->setAnimFrame(ra);
 			sprite->addTween(createTween(TweenAnim(ra), 500, -1));
-			sprite->setPosition((int)scalar::randFloat(50.0f, getWidth() - 100.0f), (int)scalar::randFloat(50.0f, getHeight() - 100.0f));
+			sprite->setPosition(scalar::randFloat(50.0f, getWidth() - 100.0f), scalar::randFloat(50.0f, getHeight() - 100.0f));
 			sprite->attachTo(content);	
 
 			if (ra->isName("bg"))

+ 21 - 25
examples/Demo/src/TestUserShader.h

@@ -52,9 +52,26 @@ private:
 class TestUserShader: public Test
 {
 public:
-	TestUserShader()
+	UberShaderProgram *_shader;
+	TestUserShader():_shader(0)
 	{
 		addButton("test", "test");			
+
+		VideoDriverGLES20 *driver = (VideoDriverGLES20*)IVideoDriver::instance;
+
+		_shader = new UberShaderProgram(driver->getShaderBody(), 
+			"#define MODIFY_BASE\n"
+			"uniform lowp float interp;"
+			"lowp vec4 modify_base(lowp vec4 base)\n"
+			"{\n"
+			"lowp float c = (base.r + base.g + base.b)/3.0;\n"
+			"return mix(vec4(c, c, c, base.a), base, interp);\n"
+			"}\n");
+	}
+
+	~TestUserShader()
+	{
+		delete _shader;
 	}
 
 	void clicked(string id)
@@ -70,11 +87,11 @@ public:
 
 
 		//Point size = content->getSize().cast<Point>();
-		Matrix view = makeViewMatrix(size.x, size.y, true);
+		Matrix view = makeViewMatrix((int)size.x, (int)size.y, true);
 		rs.renderer->setViewTransform(view);
 
 		Matrix proj;
-		Matrix::orthoLH(proj, (float)size.x, (float)size.y, 0.0f, 1.0f);
+		Matrix::orthoLH(proj, size.x, size.y, 0.0f, 1.0f);
 		rs.renderer->setProjTransform(proj);
 
 		Rect vp(Point(0, 0), size.cast<Point>());
@@ -97,29 +114,8 @@ public:
 		sprite->setAnimFrame(frame);		
 
 
-		
-		//sprite->setAnimFrame(resources.getResAnim("t2p"));
 		sprite->attachTo(content);
-
-
-		VideoDriverGLES20 *driver = (VideoDriverGLES20*)IVideoDriver::instance;
-
-		UberShaderProgram *sh = new UberShaderProgram("system/shader.glsl", 
-			"#define MODIFY_BASE\n"
-			"uniform lowp float interp;"
-			"lowp vec4 modify_base(lowp vec4 base)\n"
-			"{\n"
-			"lowp float c = (base.r + base.g + base.b)/3.0;\n"
-			"return mix(vec4(c, c, c, base.a), base, interp);\n"
-			"}\n");
-
-		//sprite->addTween(TweenAnim(resources.getResAnim("bg")), 400, -1);
-
-		
-		//shaderProgram p = VideoDriverGLES20::createProgram(driver->getVertexShader(), fs);
-		sprite->setShaderProgram(sh);
-		
-
+		sprite->setShaderProgram(_shader);
 		sprite->addTween(ShaderSprite::TweenVal(1), 5000, -1, true);
 	}
 };

+ 1 - 0
examples/Demo/src/entry_point.cpp

@@ -14,6 +14,7 @@ Rect viewport;
 
 int mainloop()
 {
+	example_update();
 	//update our rootActor
 	//Actor::update would be called also for children
 	RootActor::instance->update();

+ 13 - 3
examples/Demo/src/example.cpp

@@ -43,6 +43,7 @@ public:
 		addButton("text", "Text");
 		addButton("progress_bar", "Progress Bar");
 		addButton("drag", "Drag and Drop");
+		addButton("drag2", "Drag and Drop2");
 		addButton("perf", "Performance");
 		addButton("manage_res", "Manage Resources");
 		addButton("texture_format", "Textures Format");
@@ -71,6 +72,10 @@ public:
 		{
 			RootActor::instance->addChild(new DragTest);
 		}
+		if (id == "drag2")
+		{
+			RootActor::instance->addChild(new Drag2Test);
+		}
 		if (id == "manage_res")
 		{
 			RootActor::instance->addChild(new ManageResTest);
@@ -132,11 +137,11 @@ void example_init()
 
 	//load xml file with resources definition
 	resources.loadXML("xmls/res.xml");
-	resourcesUI.loadXML("xmls/res_ui.xml");
-	resourcesUI.loadXML("xmls/fonts.xml");
+	resourcesUI.loadXML("demo/res_ui.xml");
+	resourcesUI.loadXML("demo/fonts.xml");
 
 	spSprite sp = initActor(new Sprite, 
-		arg_resAnim = resources.getResAnim("logo2"),
+		arg_resAnim = resourcesUI.getResAnim("logo2"),
 		arg_attachTo = getRoot(),
 		arg_priority = 10,
 		arg_alpha = 128
@@ -149,6 +154,11 @@ void example_init()
 	RootActor::instance->addChild(_tests);
 }
 
+void example_update()
+{
+
+}
+
 void example_destroy()
 {
 	_tests->detach();

+ 1 - 0
examples/Demo/src/example.h

@@ -1,5 +1,6 @@
 void example_init();
 void example_destroy();
+void example_update();
 
 const int VirtualWidth = 960;
 const int VirtualHeight = 640;

+ 18 - 0
examples/DemoBox2D/CMakeLists.txt

@@ -0,0 +1,18 @@
+cmake_minimum_required (VERSION 2.6)
+project (DEMOBOX2D)
+
+file(GLOB_RECURSE BOX2DSRC
+		box2d/*.cpp
+		box2d/*.h)
+
+include_directories(box2d)
+
+add_executable(demobox2d 
+	${BOX2DSRC}
+	src/entry_point.cpp
+	src/example.h 
+	src/example.cpp)
+
+source_group(box2d FILES ${BOX2DSRC})
+
+target_link_libraries(demobox2d ${OXYGINE_CORE_LIBS})

+ 11 - 0
examples/GameTemplate/CMakeLists.txt

@@ -0,0 +1,11 @@
+cmake_minimum_required (VERSION 2.6)
+project (GAMETEMPLATE)
+
+
+file(GLOB SRC
+		src/*.cpp
+		src/*.h)
+
+add_executable(gametemplate ${SRC})
+
+target_link_libraries(gametemplate ${OXYGINE_CORE_LIBS})

+ 11 - 0
examples/GameTemplate/src/entry_point.cpp

@@ -128,4 +128,15 @@ int main(int argc, char* argv[])
 	run();
 	return 0;
 }
+#endif
+
+#ifdef OXYGINE_SDL
+extern "C"
+{
+	int SDL_main(int argc, char* argv[])
+	{
+		run();
+		return 0;
+	}
+};
 #endif

+ 9 - 0
examples/HelloWorld/CMakeLists.txt

@@ -0,0 +1,9 @@
+cmake_minimum_required (VERSION 2.6)
+project (HELLOWORLD)
+
+add_executable(helloworld 
+	src/entry_point.cpp
+	src/example.h 
+	src/example.cpp)
+
+target_link_libraries(helloworld ${OXYGINE_CORE_LIBS})

+ 1 - 1
examples/HelloWorld/data/development.icf

@@ -36,7 +36,7 @@ DeviceUniqueIDInt              = Type=int, Default="01234567890", Value = "01234
 FileTotalStorageSize           = Type=int, Min=0.000000, Max=2147483648.000000, Default="67108864", Value = "67108864"
 FileUseSeparateRomRam          = Type=bool, Default="true", Value = "true"
 FileUseTotalStorageSize        = Type=bool, Default="false", Value = "false"
-GLAPI                          = Type=string, Allowed="None" "GLES 1.0 Common-Lite Profile from Imagination POWERVR(TM)" "GLES 1.1 Common-Lite Profile from Imagination POWERVR(TM)" "GLES 1.0 Common Profile from Imagination POWERVR(TM)" "GLES 1.1 Common Profile from Imagination POWERVR(TM)" "GLES 2.0 from Imagination POWERVR(TM)" "Obey [S3E] SysGlesVersion .icf setting" "GLES 1.1 Common Profile from Qualcomm Snapdragon(TM)" "GLES 2.0 from Qualcomm Snapdragon(TM)" "GLES 2.0 ANGLE" "GLES 2.0 ANGLE DirectX 11", Default="Obey [S3E] SysGlesVersion .icf setting", Value = "Obey [S3E] SysGlesVersion .icf setting"
+GLAPI                          = Type=string, Allowed="None" "GLES 1.0 Common-Lite Profile from Imagination POWERVR(TM)" "GLES 1.1 Common-Lite Profile from Imagination POWERVR(TM)" "GLES 1.0 Common Profile from Imagination POWERVR(TM)" "GLES 1.1 Common Profile from Imagination POWERVR(TM)" "GLES 2.0 from Imagination POWERVR(TM)" "Obey [S3E] SysGlesVersion .icf setting" "GLES 1.1 Common Profile from Qualcomm Snapdragon(TM)" "GLES 2.0 from Qualcomm Snapdragon(TM)" "GLES 2.0 ANGLE", Default="Obey [S3E] SysGlesVersion .icf setting", Value = "Obey [S3E] SysGlesVersion .icf setting"
 GLDontUseHiddenWindow          = Type=bool, Default="false", Value = "false"
 GLTerminateOnSuspend           = Type=bool, Default="false", Value = "false"
 GLUsePVRVFrame                 = Type=bool, Default="false", Value = "false"

+ 1 - 0
examples/HelloWorld/src/entry_point.cpp

@@ -14,6 +14,7 @@ Rect viewport;
 
 int mainloop()
 {
+	example_update();
 	//update our rootActor
 	//Actor::update would be called also for children
 	RootActor::instance->update();

+ 9 - 0
examples/HelloWorld/src/example.cpp

@@ -115,6 +115,10 @@ void example_init()
 	//load xml file with resources definition
 	gameResources.loadXML("res.xml");
 
+	file::handle h = file::open("test", "wb");
+	file::close(h);
+
+
 	//lets create our client code simple actor
 	//prefix 'sp' here means it is intrusive Smart Pointer
 	//it would be deleted automatically when you lost ref to it	
@@ -123,6 +127,11 @@ void example_init()
 	RootActor::instance->addChild(actor);
 }
 
+void example_update()
+{
+	
+}
+
 void example_destroy()
 {
 	gameResources.free();

+ 2 - 0
examples/HelloWorld/src/example.h

@@ -1,5 +1,7 @@
 void example_init();
 void example_destroy();
+void example_update();
+
 
 const int VirtualWidth = 480;
 const int VirtualHeight = 320;

+ 15 - 0
examples/Match3/CMakeLists.txt

@@ -0,0 +1,15 @@
+cmake_minimum_required (VERSION 2.6)
+project (MATCH3)
+
+add_executable(match3 
+	src/entry_point.cpp
+	src/example.h	
+	src/example.cpp
+	src/gameframe.h
+	src/gameframe.cpp
+	src/jewels.h
+	src/jewels.cpp
+	src/shared.h
+	src/shared.cpp)
+
+target_link_libraries(match3 ${OXYGINE_CORE_LIBS})

+ 4 - 4
examples/Match3/src/gameframe.cpp

@@ -147,7 +147,7 @@ bool Field::FindSolutions()
 	for(int i=0; i<FIELD_SIZE-1; i++)
 		for(int j=0; j<FIELD_SIZE; j++)
 		{
-			int16 points;
+			int points;
 			ForceSwap(jewels[i][j],jewels[i+1][j]);
 			points = CheckJewel(Point(i,j),true);
 			if (points>0) 
@@ -165,7 +165,7 @@ bool Field::FindSolutions()
 		for(int i=0; i<FIELD_SIZE; i++)
 			for(int j=0; j<FIELD_SIZE-1; j++)
 			{
-				int16 points;
+				int points;
 				ForceSwap(jewels[i][j],jewels[i][j+1]);
 				points = CheckJewel(Point(i,j),true);
 				if (points>0) 
@@ -195,7 +195,7 @@ bool Field::FindSolutions()
 }
 
 
-int32 compareVariants(const TFieldVariants* left, const TFieldVariants* right)
+int compareVariants(const TFieldVariants* left, const TFieldVariants* right)
 {
 	return left->points > right->points;
 }
@@ -245,7 +245,7 @@ bool Field::CheckField()
 	for (int i=0; i<FIELD_SIZE; i++)
 		for (int j=0; j<FIELD_SIZE; j++)
 		{
-			int16 points = CheckJewel(Point(i,j),true);
+			int points = CheckJewel(Point(i,j),true);
 			if (points>0)
 			{
 				variants.push_back(new TFieldVariants(Point(i,j),points));

+ 2 - 2
examples/Match3/src/jewels.cpp

@@ -39,8 +39,8 @@ void Jewel::SetSelected()
 	setPosition(Vector2(getPosition().x+JEWEL_SIZE/2, getPosition().y+JEWEL_SIZE/2));
 	setAnchor(Vector2(0.5f,0.5f));
 
-	tween->add(createTween(Sprite::TweenRotation(M_PI * 0.1f), 100))
-		->add(createTween(Sprite::TweenRotation(M_PI * (-0.1f)), 400,-1,true));
+	tween->add(createTween(Sprite::TweenRotation(MATH_PI * 0.1f), 100))
+		->add(createTween(Sprite::TweenRotation(MATH_PI  * (-0.1f)), 400,-1,true));
 
 
 	addTween(tween);

BIN
oxygine/SDL/android/SDLTests.zip


+ 6 - 7
oxygine/SDL/android/jni/Android.mk

@@ -9,7 +9,11 @@ LOCAL_SRC_FILES := \
 				$(subst $(LOCAL_PATH)/,, \
 				$(wildcard $(LOCAL_PATH)/closure/*.cpp) \
 				$(wildcard $(LOCAL_PATH)/core/*.cpp) \
-				$(wildcard $(LOCAL_PATH)/core/gl/*.cpp) \
+				$(LOCAL_PATH)/core/gl/NativeTextureGLES.cpp \
+				$(LOCAL_PATH)/core/gl/oxgl.cpp \
+				$(LOCAL_PATH)/core/gl/VertexDeclarationGL.cpp \
+				$(LOCAL_PATH)/core/gl/VideoDriverGL.cpp \
+				$(LOCAL_PATH)/core/gl/VideoDriverGLES20.cpp \
 				$(wildcard $(LOCAL_PATH)/math/*.cpp) \
 				$(wildcard $(LOCAL_PATH)/pugixml/*.cpp) \
 				$(wildcard $(LOCAL_PATH)/res/*.cpp) \
@@ -17,6 +21,7 @@ LOCAL_SRC_FILES := \
 				$(wildcard $(LOCAL_PATH)/dev_tools/*.cpp) \
 				$(wildcard $(LOCAL_PATH)/utils/*.cpp) \
 				$(wildcard $(LOCAL_PATH)/winnie_alloc/*.cpp) \
+				$(wildcard $(LOCAL_PATH)/minizip/*.c) \
 				$(wildcard $(LOCAL_PATH)/*.cpp) \
 				$(wildcard $(LOCAL_PATH)/../greenlets/src*.c) \
 				)
@@ -31,12 +36,6 @@ OXYGINE_ROOT := $(OXYGINE)/../
 THIRD_PARTY := $(OXYGINE_ROOT)/third_party/android/
 
 LOCAL_C_INCLUDES := $(OXYGINE)/ \
-					$(OXYGINE)/closure/ \
-					$(OXYGINE)/core/ \
-					$(OXYGINE)/math/ \
-					$(OXYGINE)/pugixml/ \
-					$(OXYGINE)/res/ \
-					$(OXYGINE)/utils/ \
 					$(OXYGINE)/../greenlets/src/ \
 					$(SDL_PATH) \
 					$(THIRD_PARTY)/libjpeg/ \

+ 48 - 27
oxygine/SDL/win32/oxygine_vs2010.vcxproj

@@ -100,17 +100,30 @@
     <ClCompile Include="..\..\src\ClipRectActor.cpp" />
     <ClCompile Include="..\..\src\Clock.cpp" />
     <ClCompile Include="..\..\src\ColorRectSprite.cpp" />
+    <ClCompile Include="..\..\src\core\coroutines.cpp" />
+    <ClCompile Include="..\..\src\core\file.cpp" />
+    <ClCompile Include="..\..\src\core\FileSystem.cpp" />
     <ClCompile Include="..\..\src\core\gl\NativeTextureGLES.cpp" />
     <ClCompile Include="..\..\src\core\gl\oxgl.cpp" />
     <ClCompile Include="..\..\src\core\gl\VertexDeclarationGL.cpp" />
     <ClCompile Include="..\..\src\core\gl\VideoDriverGL.cpp" />
     <ClCompile Include="..\..\src\core\gl\VideoDriverGLES11.cpp" />
     <ClCompile Include="..\..\src\core\gl\VideoDriverGLES20.cpp" />
-    <ClCompile Include="..\..\src\core\logging.cpp" />
+    <ClCompile Include="..\..\src\core\ImageData.cpp" />
+    <ClCompile Include="..\..\src\core\ImageDataOperations.cpp" />
+    <ClCompile Include="..\..\src\core\log.cpp" />
     <ClCompile Include="..\..\src\core\Mem2Native.cpp" />
+    <ClCompile Include="..\..\src\core\memory_pool.cpp" />
     <ClCompile Include="..\..\src\core\Mutex.cpp" />
     <ClCompile Include="..\..\src\core\NativeTexture.cpp" />
+    <ClCompile Include="..\..\src\core\Object.cpp" />
+    <ClCompile Include="..\..\src\core\oxygine.cpp" />
+    <ClCompile Include="..\..\src\core\Renderer.cpp" />
+    <ClCompile Include="..\..\src\core\STDFileSystem.cpp" />
+    <ClCompile Include="..\..\src\core\system_data.cpp" />
+    <ClCompile Include="..\..\src\core\Texture.cpp" />
     <ClCompile Include="..\..\src\core\VideoDriver.cpp" />
+    <ClCompile Include="..\..\src\core\ZipFileSystem.cpp" />
     <ClCompile Include="..\..\src\DebugActor.cpp" />
     <ClCompile Include="..\..\src\dev_tools\DeveloperMenu.cpp" />
     <ClCompile Include="..\..\src\dev_tools\TexturesInspector.cpp" />
@@ -122,7 +135,11 @@
     <ClCompile Include="..\..\src\EventDispatcher.cpp" />
     <ClCompile Include="..\..\src\Font.cpp" />
     <ClCompile Include="..\..\src\Input.cpp" />
+    <ClCompile Include="..\..\src\MaskedSprite.cpp" />
     <ClCompile Include="..\..\src\MemoryTexture.cpp" />
+    <ClCompile Include="..\..\src\minizip\ioapi.c" />
+    <ClCompile Include="..\..\src\minizip\ioapi_mem.c" />
+    <ClCompile Include="..\..\src\minizip\unzip.c" />
     <ClCompile Include="..\..\src\Multithreading.cpp" />
     <ClCompile Include="..\..\src\PointerState.cpp" />
     <ClCompile Include="..\..\src\ProgressBar.cpp" />
@@ -143,20 +160,11 @@
     <ClCompile Include="..\..\src\text_utils\TextBuilder.cpp" />
     <ClCompile Include="..\..\src\Tweener.cpp" />
     <ClCompile Include="..\..\src\utils\stringUtils.cpp" />
-    <ClCompile Include="..\..\src\VisualStyle.cpp" />
-    <ClCompile Include="..\..\src\core\coroutines.cpp" />
-    <ClCompile Include="..\..\src\core\files_io.cpp" />
-    <ClCompile Include="..\..\src\core\ImageData.cpp" />
-    <ClCompile Include="..\..\src\core\ImageDataOperations.cpp" />
-    <ClCompile Include="..\..\src\core\memory_pool.cpp" />
-    <ClCompile Include="..\..\src\core\Object.cpp" />
-    <ClCompile Include="..\..\src\core\oxygine.cpp" />
-    <ClCompile Include="..\..\src\core\Renderer.cpp" />
-    <ClCompile Include="..\..\src\core\Texture.cpp" />
     <ClCompile Include="..\..\src\math\AffineTransform.cpp" />
     <ClCompile Include="..\..\src\pugixml\pugixml.cpp" />
     <ClCompile Include="..\..\src\utils\AtlasTool.cpp" />
     <ClCompile Include="..\..\src\utils\ImageUtils.cpp" />
+    <ClCompile Include="..\..\src\VisualStyle.cpp" />
     <ClCompile Include="..\..\src\winnie_alloc\system_alloc.cpp" />
     <ClCompile Include="..\..\src\winnie_alloc\winnie_alloc.cpp" />
     <ClCompile Include="..\..\greenlets\src\greenlet.c" />
@@ -170,17 +178,39 @@
     <ClInclude Include="..\..\src\ClipRectActor.h" />
     <ClInclude Include="..\..\src\Clock.h" />
     <ClInclude Include="..\..\src\ColorRectSprite.h" />
+    <ClInclude Include="..\..\src\core\coroutines.h" />
+    <ClInclude Include="..\..\src\core\file.h" />
+    <ClInclude Include="..\..\src\core\FileSystem.h" />
+    <ClInclude Include="..\..\src\core\files_io.h" />
     <ClInclude Include="..\..\src\core\gl\NativeTextureGLES.h" />
     <ClInclude Include="..\..\src\core\gl\oxgl.h" />
     <ClInclude Include="..\..\src\core\gl\VertexDeclarationGL.h" />
     <ClInclude Include="..\..\src\core\gl\VideoDriverGL.h" />
     <ClInclude Include="..\..\src\core\gl\VideoDriverGLES11.h" />
     <ClInclude Include="..\..\src\core\gl\VideoDriverGLES20.h" />
+    <ClInclude Include="..\..\src\core\ImageData.h" />
+    <ClInclude Include="..\..\src\core\ImageDataOperations.h" />
+    <ClInclude Include="..\..\src\core\intrusive_ptr.h" />
+    <ClInclude Include="..\..\src\core\log.h" />
     <ClInclude Include="..\..\src\core\logging.h" />
     <ClInclude Include="..\..\src\core\Mem2Native.h" />
+    <ClInclude Include="..\..\src\core\memory_pool.h" />
     <ClInclude Include="..\..\src\core\Mutex.h" />
     <ClInclude Include="..\..\src\core\NativeTexture.h" />
+    <ClInclude Include="..\..\src\core\Object.h" />
+    <ClInclude Include="..\..\src\core\oxygine.h" />
+    <ClInclude Include="..\..\src\core\ox_debug.h" />
+    <ClInclude Include="..\..\src\core\pixel.h" />
+    <ClInclude Include="..\..\src\core\ref_counter.h" />
+    <ClInclude Include="..\..\src\core\Renderer.h" />
+    <ClInclude Include="..\..\src\core\ShaderProgram.h" />
+    <ClInclude Include="..\..\src\core\STDFileSystem.h" />
+    <ClInclude Include="..\..\src\core\system_data.h" />
+    <ClInclude Include="..\..\src\core\Texture.h" />
+    <ClInclude Include="..\..\src\core\vertex.h" />
+    <ClInclude Include="..\..\src\core\VertexDeclaration.h" />
     <ClInclude Include="..\..\src\core\VideoDriver.h" />
+    <ClInclude Include="..\..\src\core\ZipFileSystem.h" />
     <ClInclude Include="..\..\src\DebugActor.h" />
     <ClInclude Include="..\..\src\dev_tools\DeveloperMenu.h" />
     <ClInclude Include="..\..\src\dev_tools\TexturesInspector.h" />
@@ -191,14 +221,19 @@
     <ClInclude Include="..\..\src\Draggable.h" />
     <ClInclude Include="..\..\src\Event.h" />
     <ClInclude Include="..\..\src\EventDispatcher.h" />
-    <ClInclude Include="..\..\src\EventState.h" />
     <ClInclude Include="..\..\src\Font.h" />
     <ClInclude Include="..\..\src\InitActor.h" />
     <ClInclude Include="..\..\src\Input.h" />
+    <ClInclude Include="..\..\src\MaskedSprite.h" />
     <ClInclude Include="..\..\src\MemoryTexture.h" />
+    <ClInclude Include="..\..\src\minizip\ioapi.h" />
+    <ClInclude Include="..\..\src\minizip\ioapi_mem.h" />
+    <ClInclude Include="..\..\src\minizip\unzip.h" />
     <ClInclude Include="..\..\src\Multithreading.h" />
+    <ClInclude Include="..\..\src\oxygine-framework.h" />
     <ClInclude Include="..\..\src\PointerState.h" />
     <ClInclude Include="..\..\src\ProgressBar.h" />
+    <ClInclude Include="..\..\src\RenderState.h" />
     <ClInclude Include="..\..\src\res\CreateResourceContext.h" />
     <ClInclude Include="..\..\src\res\ResAnim.h" />
     <ClInclude Include="..\..\src\res\ResAtlas.h" />
@@ -211,7 +246,6 @@
     <ClInclude Include="..\..\src\RootActor.h" />
     <ClInclude Include="..\..\src\SlidingActor.h" />
     <ClInclude Include="..\..\src\Sprite.h" />
-    <ClInclude Include="..\..\src\stringUtils.h" />
     <ClInclude Include="..\..\src\TextActor.h" />
     <ClInclude Include="..\..\src\TextStyle.h" />
     <ClInclude Include="..\..\src\text_utils\Aligner.h" />
@@ -220,21 +254,8 @@
     <ClInclude Include="..\..\src\Tweener.h" />
     <ClInclude Include="..\..\src\UpdateState.h" />
     <ClInclude Include="..\..\src\utils\stringUtils.h" />
-    <ClInclude Include="..\..\src\VisualStyle.h" />
     <ClInclude Include="..\..\src\closure\closure.h" />
     <ClInclude Include="..\..\src\closure\closure_impl.h" />
-    <ClInclude Include="..\..\src\core\coroutines.h" />
-    <ClInclude Include="..\..\src\core\files_io.h" />
-    <ClInclude Include="..\..\src\core\ImageData.h" />
-    <ClInclude Include="..\..\src\core\ImageDataOperations.h" />
-    <ClInclude Include="..\..\src\core\intrusive_ptr.h" />
-    <ClInclude Include="..\..\src\core\memory_pool.h" />
-    <ClInclude Include="..\..\src\core\Object.h" />
-    <ClInclude Include="..\..\src\core\oxygine.h" />
-    <ClInclude Include="..\..\src\core\pixel.h" />
-    <ClInclude Include="..\..\src\core\ref_counter.h" />
-    <ClInclude Include="..\..\src\core\Renderer.h" />
-    <ClInclude Include="..\..\src\core\Texture.h" />
     <ClInclude Include="..\..\src\math\AffineTransform.h" />
     <ClInclude Include="..\..\src\math\Color.h" />
     <ClInclude Include="..\..\src\math\matrix.h" />
@@ -248,6 +269,7 @@
     <ClInclude Include="..\..\src\utils\AtlasTool.h" />
     <ClInclude Include="..\..\src\utils\ImageUtils.h" />
     <ClInclude Include="..\..\src\utils\intrusive_list.h" />
+    <ClInclude Include="..\..\src\VisualStyle.h" />
     <ClInclude Include="..\..\src\winnie_alloc\system_alloc.h" />
     <ClInclude Include="..\..\src\winnie_alloc\winnie_alloc.h" />
     <ClInclude Include="..\..\src\winnie_alloc\winnie_alloc_config.h" />
@@ -255,7 +277,6 @@
     <ClInclude Include="..\..\greenlets\src\slp_platformselect.h" />
   </ItemGroup>
   <ItemGroup>
-    <None Include="..\..\src\license.txt" />
     <None Include="ReadMe.txt" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

+ 299 - 233
oxygine/SDL/win32/oxygine_vs2010.vcxproj.filters

@@ -40,80 +40,11 @@
     <Filter Include="src\gl">
       <UniqueIdentifier>{b8f36a93-6b35-4120-adb9-ac1ae693b774}</UniqueIdentifier>
     </Filter>
+    <Filter Include="src\minizip">
+      <UniqueIdentifier>{164d853c-2678-421b-982f-073d6b5ebb1d}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="..\..\src\Actor.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\Button.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\Clock.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\ColorRectSprite.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\DebugActor.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\Font.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\Input.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\MemoryTexture.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\PointerState.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\ProgressBar.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\RootActor.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\Sprite.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\TextActor.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\Tweener.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\VisualStyle.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\core\coroutines.cpp">
-      <Filter>src\core</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\core\files_io.cpp">
-      <Filter>src\core</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\core\ImageData.cpp">
-      <Filter>src\core</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\core\ImageDataOperations.cpp">
-      <Filter>src\core</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\core\memory_pool.cpp">
-      <Filter>src\core</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\core\Object.cpp">
-      <Filter>src\core</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\core\oxygine.cpp">
-      <Filter>src\core</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\core\Renderer.cpp">
-      <Filter>src\core</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\core\Texture.cpp">
-      <Filter>src\core</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\src\math\AffineTransform.cpp">
       <Filter>src\math</Filter>
     </ClCompile>
@@ -159,45 +90,6 @@
     <ClCompile Include="..\..\src\utils\stringUtils.cpp">
       <Filter>src\utils</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\src\Blocking.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\ClipRectActor.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\core\logging.cpp">
-      <Filter>src\core</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\core\NativeTexture.cpp">
-      <Filter>src\core</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\core\Mem2Native.cpp">
-      <Filter>src\core</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\core\Mutex.cpp">
-      <Filter>src\core</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\core\VideoDriver.cpp">
-      <Filter>src\core</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\Multithreading.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\Draggable.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\SlidingActor.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\AnimationFrame.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\Box9Sprite.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\src\EventDispatcher.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\src\res\ResStarlingAtlas.cpp">
       <Filter>src\res</Filter>
     </ClCompile>
@@ -246,110 +138,149 @@
     <ClCompile Include="..\..\src\core\gl\VideoDriverGL.cpp">
       <Filter>src\gl</Filter>
     </ClCompile>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="..\..\src\Actor.h">
+    <ClCompile Include="..\..\src\core\coroutines.cpp">
+      <Filter>src\core</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\core\file.cpp">
+      <Filter>src\core</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\core\FileSystem.cpp">
+      <Filter>src\core</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\core\ImageData.cpp">
+      <Filter>src\core</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\core\ImageDataOperations.cpp">
+      <Filter>src\core</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\core\log.cpp">
+      <Filter>src\core</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\core\Mem2Native.cpp">
+      <Filter>src\core</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\core\memory_pool.cpp">
+      <Filter>src\core</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\core\Mutex.cpp">
+      <Filter>src\core</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\core\NativeTexture.cpp">
+      <Filter>src\core</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\core\Object.cpp">
+      <Filter>src\core</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\core\oxygine.cpp">
+      <Filter>src\core</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\core\Renderer.cpp">
+      <Filter>src\core</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\core\STDFileSystem.cpp">
+      <Filter>src\core</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\core\system_data.cpp">
+      <Filter>src\core</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\core\Texture.cpp">
+      <Filter>src\core</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\core\VideoDriver.cpp">
+      <Filter>src\core</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\core\ZipFileSystem.cpp">
+      <Filter>src\core</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\minizip\ioapi.c">
+      <Filter>src\minizip</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\minizip\ioapi_mem.c">
+      <Filter>src\minizip</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\minizip\unzip.c">
+      <Filter>src\minizip</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\Actor.cpp">
       <Filter>src</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\AnimationFrame.h">
+    </ClCompile>
+    <ClCompile Include="..\..\src\AnimationFrame.cpp">
       <Filter>src</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\Button.h">
+    </ClCompile>
+    <ClCompile Include="..\..\src\Blocking.cpp">
       <Filter>src</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\Clock.h">
+    </ClCompile>
+    <ClCompile Include="..\..\src\Box9Sprite.cpp">
       <Filter>src</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\ColorRectSprite.h">
+    </ClCompile>
+    <ClCompile Include="..\..\src\Button.cpp">
       <Filter>src</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\DebugActor.h">
+    </ClCompile>
+    <ClCompile Include="..\..\src\ClipRectActor.cpp">
       <Filter>src</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\EventState.h">
+    </ClCompile>
+    <ClCompile Include="..\..\src\Clock.cpp">
       <Filter>src</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\Font.h">
+    </ClCompile>
+    <ClCompile Include="..\..\src\ColorRectSprite.cpp">
       <Filter>src</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\Input.h">
+    </ClCompile>
+    <ClCompile Include="..\..\src\DebugActor.cpp">
       <Filter>src</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\MemoryTexture.h">
+    </ClCompile>
+    <ClCompile Include="..\..\src\Draggable.cpp">
       <Filter>src</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\PointerState.h">
+    </ClCompile>
+    <ClCompile Include="..\..\src\EventDispatcher.cpp">
       <Filter>src</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\ProgressBar.h">
+    </ClCompile>
+    <ClCompile Include="..\..\src\Font.cpp">
       <Filter>src</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\RootActor.h">
+    </ClCompile>
+    <ClCompile Include="..\..\src\Input.cpp">
       <Filter>src</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\Sprite.h">
+    </ClCompile>
+    <ClCompile Include="..\..\src\MaskedSprite.cpp">
       <Filter>src</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\stringUtils.h">
+    </ClCompile>
+    <ClCompile Include="..\..\src\MemoryTexture.cpp">
       <Filter>src</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\TextActor.h">
+    </ClCompile>
+    <ClCompile Include="..\..\src\Multithreading.cpp">
       <Filter>src</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\TextStyle.h">
+    </ClCompile>
+    <ClCompile Include="..\..\src\PointerState.cpp">
       <Filter>src</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\Tweener.h">
+    </ClCompile>
+    <ClCompile Include="..\..\src\ProgressBar.cpp">
       <Filter>src</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\UpdateState.h">
+    </ClCompile>
+    <ClCompile Include="..\..\src\RootActor.cpp">
       <Filter>src</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\VisualStyle.h">
+    </ClCompile>
+    <ClCompile Include="..\..\src\SlidingActor.cpp">
       <Filter>src</Filter>
-    </ClInclude>
+    </ClCompile>
+    <ClCompile Include="..\..\src\Sprite.cpp">
+      <Filter>src</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\TextActor.cpp">
+      <Filter>src</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\Tweener.cpp">
+      <Filter>src</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\VisualStyle.cpp">
+      <Filter>src</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
     <ClInclude Include="..\..\src\closure\closure.h">
       <Filter>src\closure</Filter>
     </ClInclude>
     <ClInclude Include="..\..\src\closure\closure_impl.h">
       <Filter>src\closure</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\core\coroutines.h">
-      <Filter>src\core</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\core\files_io.h">
-      <Filter>src\core</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\core\ImageData.h">
-      <Filter>src\core</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\core\ImageDataOperations.h">
-      <Filter>src\core</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\core\intrusive_ptr.h">
-      <Filter>src\core</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\core\memory_pool.h">
-      <Filter>src\core</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\core\Object.h">
-      <Filter>src\core</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\core\oxygine.h">
-      <Filter>src\core</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\core\pixel.h">
-      <Filter>src\core</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\core\ref_counter.h">
-      <Filter>src\core</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\core\Renderer.h">
-      <Filter>src\core</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\src\core\Texture.h">
-      <Filter>src\core</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\src\math\AffineTransform.h">
       <Filter>src\math</Filter>
     </ClInclude>
@@ -431,101 +362,236 @@
     <ClInclude Include="..\..\src\utils\stringUtils.h">
       <Filter>src\utils</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\Blocking.h">
-      <Filter>src</Filter>
+    <ClInclude Include="..\..\src\res\ResStarlingAtlas.h">
+      <Filter>src\res</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\ClipRectActor.h">
-      <Filter>src</Filter>
+    <ClInclude Include="..\..\src\text_utils\Aligner.h">
+      <Filter>src\text</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\core\logging.h">
+    <ClInclude Include="..\..\src\text_utils\Node.h">
+      <Filter>src\text</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\text_utils\TextBuilder.h">
+      <Filter>src\text</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\dev_tools\DeveloperMenu.h">
+      <Filter>src\dev_tools</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\dev_tools\TexturesInspector.h">
+      <Filter>src\dev_tools</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\dev_tools\TreeInspector.h">
+      <Filter>src\dev_tools</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\dev_tools\TreeInspectorLine.h">
+      <Filter>src\dev_tools</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\dev_tools\TreeInspectorPage.h">
+      <Filter>src\dev_tools</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\dev_tools\TreeInspectorPreview.h">
+      <Filter>src\dev_tools</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\gl\NativeTextureGLES.h">
+      <Filter>src\gl</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\gl\oxgl.h">
+      <Filter>src\gl</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\gl\VideoDriverGLES11.h">
+      <Filter>src\gl</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\gl\VideoDriverGLES20.h">
+      <Filter>src\gl</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\gl\VertexDeclarationGL.h">
+      <Filter>src\gl</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\gl\VideoDriverGL.h">
+      <Filter>src\gl</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\coroutines.h">
       <Filter>src\core</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\core\NativeTexture.h">
+    <ClInclude Include="..\..\src\core\file.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\files_io.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\FileSystem.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\ImageData.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\ImageDataOperations.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\intrusive_ptr.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\log.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\logging.h">
       <Filter>src\core</Filter>
     </ClInclude>
     <ClInclude Include="..\..\src\core\Mem2Native.h">
       <Filter>src\core</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\core\memory_pool.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
     <ClInclude Include="..\..\src\core\Mutex.h">
       <Filter>src\core</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\core\NativeTexture.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\Object.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\ox_debug.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\oxygine.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\pixel.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\ref_counter.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\Renderer.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\ShaderProgram.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\STDFileSystem.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\system_data.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\Texture.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\vertex.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\core\VertexDeclaration.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
     <ClInclude Include="..\..\src\core\VideoDriver.h">
       <Filter>src\core</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\Multithreading.h">
+    <ClInclude Include="..\..\src\core\ZipFileSystem.h">
+      <Filter>src\core</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\minizip\ioapi.h">
+      <Filter>src\minizip</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\minizip\ioapi_mem.h">
+      <Filter>src\minizip</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\minizip\unzip.h">
+      <Filter>src\minizip</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\Actor.h">
       <Filter>src</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\Draggable.h">
+    <ClInclude Include="..\..\src\AnimationFrame.h">
       <Filter>src</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\SlidingActor.h">
+    <ClInclude Include="..\..\src\Blocking.h">
       <Filter>src</Filter>
     </ClInclude>
     <ClInclude Include="..\..\src\Box9Sprite.h">
       <Filter>src</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\Button.h">
+      <Filter>src</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\ClipRectActor.h">
+      <Filter>src</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\Clock.h">
+      <Filter>src</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\ColorRectSprite.h">
+      <Filter>src</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\DebugActor.h">
+      <Filter>src</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\Draggable.h">
+      <Filter>src</Filter>
+    </ClInclude>
     <ClInclude Include="..\..\src\Event.h">
       <Filter>src</Filter>
     </ClInclude>
     <ClInclude Include="..\..\src\EventDispatcher.h">
       <Filter>src</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\Font.h">
+      <Filter>src</Filter>
+    </ClInclude>
     <ClInclude Include="..\..\src\InitActor.h">
       <Filter>src</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\res\ResStarlingAtlas.h">
-      <Filter>src\res</Filter>
+    <ClInclude Include="..\..\src\Input.h">
+      <Filter>src</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\text_utils\Aligner.h">
-      <Filter>src\text</Filter>
+    <ClInclude Include="..\..\src\MaskedSprite.h">
+      <Filter>src</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\text_utils\Node.h">
-      <Filter>src\text</Filter>
+    <ClInclude Include="..\..\src\MemoryTexture.h">
+      <Filter>src</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\text_utils\TextBuilder.h">
-      <Filter>src\text</Filter>
+    <ClInclude Include="..\..\src\Multithreading.h">
+      <Filter>src</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\dev_tools\DeveloperMenu.h">
-      <Filter>src\dev_tools</Filter>
+    <ClInclude Include="..\..\src\oxygine-framework.h">
+      <Filter>src</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\dev_tools\TexturesInspector.h">
-      <Filter>src\dev_tools</Filter>
+    <ClInclude Include="..\..\src\PointerState.h">
+      <Filter>src</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\dev_tools\TreeInspector.h">
-      <Filter>src\dev_tools</Filter>
+    <ClInclude Include="..\..\src\ProgressBar.h">
+      <Filter>src</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\dev_tools\TreeInspectorLine.h">
-      <Filter>src\dev_tools</Filter>
+    <ClInclude Include="..\..\src\RenderState.h">
+      <Filter>src</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\dev_tools\TreeInspectorPage.h">
-      <Filter>src\dev_tools</Filter>
+    <ClInclude Include="..\..\src\RootActor.h">
+      <Filter>src</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\dev_tools\TreeInspectorPreview.h">
-      <Filter>src\dev_tools</Filter>
+    <ClInclude Include="..\..\src\SlidingActor.h">
+      <Filter>src</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\core\gl\NativeTextureGLES.h">
-      <Filter>src\gl</Filter>
+    <ClInclude Include="..\..\src\Sprite.h">
+      <Filter>src</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\core\gl\oxgl.h">
-      <Filter>src\gl</Filter>
+    <ClInclude Include="..\..\src\TextActor.h">
+      <Filter>src</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\core\gl\VideoDriverGLES11.h">
-      <Filter>src\gl</Filter>
+    <ClInclude Include="..\..\src\TextStyle.h">
+      <Filter>src</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\core\gl\VideoDriverGLES20.h">
-      <Filter>src\gl</Filter>
+    <ClInclude Include="..\..\src\Tweener.h">
+      <Filter>src</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\core\gl\VertexDeclarationGL.h">
-      <Filter>src\gl</Filter>
+    <ClInclude Include="..\..\src\UpdateState.h">
+      <Filter>src</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\core\gl\VideoDriverGL.h">
-      <Filter>src\gl</Filter>
+    <ClInclude Include="..\..\src\VisualStyle.h">
+      <Filter>src</Filter>
     </ClInclude>
   </ItemGroup>
   <ItemGroup>
-    <None Include="..\..\src\license.txt">
-      <Filter>src</Filter>
-    </None>
     <None Include="ReadMe.txt" />
   </ItemGroup>
 </Project>

+ 5 - 0
oxygine/marmalade/oxygine-framework.mkf

@@ -32,6 +32,11 @@ files
 	(../src/text_utils)
 	"*.h"
 	"*.cpp"	
+
+	[src/minizip]
+	(../src/minizip)
+	"*.h"
+	"*.c"	
 		
 	[src/utils]
 	(../src/utils)

+ 5 - 0
oxygine/marmalade/oxygine.mkf

@@ -37,6 +37,11 @@ files
 	(../src/pugixml)
 	"*.hpp"
 	"*.cpp"	
+
+	[src/minizip]
+	(../src/minizip)
+	"*.h"
+	"*.c"	
 	
 	[src/text_utils]
 	(../src/text_utils)

+ 19 - 4
oxygine/src/Actor.cpp

@@ -271,7 +271,7 @@ namespace oxygine
 					{
 						setPressed(0);			
 						//it is event from ROOT, convert to local space
-						Vector2 lp = convert_global2local(this, RootActor::instance, me->localPosition);
+						Vector2 lp = convert_global2local(this, getRoot(), me->localPosition);
 						if (isDescendant(act))
 						{
 							TouchEvent e(TouchEvent::CLICK, true, lp);
@@ -1051,15 +1051,25 @@ namespace oxygine
 		}
 	}
 
-	Vector2 convert_global2local(spActor child, spActor parent, Vector2 pos)
+	Vector2 convert_global2local_(Actor *child, Actor *parent, Vector2 pos)
 	{
 		if (child->getParent() && child->getParent() != parent)
 			pos = convert_global2local(child->getParent(), parent, pos);
+		/*
+		Actor *p = child->getParent();
+		if (p && child != parent)
+			pos = convert_global2local(p, parent, pos);
+			*/
 		pos = child->global2local(pos);
 		return pos;
 	}
 
-	Vector2 convert_local2global(spActor child, spActor parent, Vector2 pos)
+	Vector2 convert_global2local(spActor child, spActor parent, const Vector2 &pos)
+	{
+		return convert_global2local_(child.get(), parent.get(), pos);
+	}
+
+	Vector2 convert_local2global_(Actor* child, Actor* parent, Vector2 pos)
 	{
 		while(child && child != parent)
 		{
@@ -1070,6 +1080,11 @@ namespace oxygine
 		return pos;
 	}
 
+	Vector2 convert_local2global(spActor child, spActor parent, const Vector2 &pos)
+	{
+		return convert_local2global_(child.get(), parent.get(), pos);
+	}
+
 	Vector2 convert_local2root(spActor actor, const Vector2 &pos, spActor root)
 	{
 		if (!root)
@@ -1081,7 +1096,7 @@ namespace oxygine
 	{
 		if (!root)
 			root = getRoot();
-		return convert_global2local(actor, getRoot(), pos);
+		return convert_global2local(actor, root, pos);
 	}
 
 	Renderer::transform getGlobalTransform(spActor child)

+ 2 - 2
oxygine/src/Actor.h

@@ -314,8 +314,8 @@ namespace oxygine
 		RectF calcDestRectF(const RectF &destRect, const Vector2 &size) const;
 	};
 
-	Vector2 convert_global2local(spActor child, spActor parent, Vector2 pos);//deprecated, use convert_root2local
-	Vector2 convert_local2global(spActor child, spActor parent, Vector2 pos);//deprecated, use convert_local2root
+	Vector2 convert_global2local(spActor child, spActor parent, const Vector2 &pos);//deprecated, use convert_root2local
+	Vector2 convert_local2global(spActor child, spActor parent, const Vector2 &pos);//deprecated, use convert_local2root
 
 	Vector2 convert_local2root(spActor child, const Vector2 &pos, spActor root = 0);
 	Vector2 convert_root2local(spActor child, const Vector2 &pos, spActor root = 0);

+ 6 - 1
oxygine/src/AnimationFrame.h

@@ -28,8 +28,13 @@ namespace oxygine
 		AnimationFrame clip(const RectF &rect) const;
 		AnimationFrame flip(bool vertical, bool horizontal) const;
 
-		/**Returns size of frame in pixels*/
+		/**Returns size of frame in pixels*/		
+		const Vector2&	getSize() const {return _frameSize;}
+		float			getWidth() const {return _frameSize.x;}
+		float			getHeight() const {return _frameSize.x;}
+		//deprecated, use getSize
 		const Vector2&	getFrameSize() const {return _frameSize;}
+
 		ResAnim*		getResAnim() const {return _resAnim;} 
 		const RectF&	getSrcRect() const {return _srcRect;}
 		const RectF&	getDestRect() const {return _destRect;}

+ 1 - 1
oxygine/src/ClipRectActor.cpp

@@ -1,6 +1,6 @@
 #include "ClipRectActor.h"
 #include "RootActor.h"
-#include "core/logging.h"
+#include "core/log.h"
 #include "RenderState.h"
 
 namespace oxygine

+ 6 - 3
oxygine/src/Clock.cpp

@@ -53,14 +53,16 @@ namespace oxygine
 	void Clock::update(timeMS globalTime)
 	{
 		timeMS time = globalTime;
-		const timeMS neg = -1; 
+		const double neg = -1; 
 		if (time == neg)
 			time = getTimeMS();
 
 		if (_lastUpdateTime == neg)
 			_lastUpdateTime = time;
 		
-		int dt =  int(time - _lastUpdateTime);
+		double dt = (time - _lastUpdateTime) * _multiplier;
+		if (dt < 1 && dt > 0)
+			dt = 1;
 
 		if (dt > 100)
 			dt = 100;
@@ -68,7 +70,8 @@ namespace oxygine
 		if (_counter > 0)
 			dt = 0;//todo destTime == srcTime ??
 
-		_destTime += dt * _multiplier;
+		//log::messageln("dt: %x %d", this, dt);
+		_destTime += dt;
 
 		_lastUpdateTime = time;
 

+ 21 - 18
oxygine/src/DebugActor.cpp

@@ -1,28 +1,30 @@
 #include <sstream>
 
-#include "initActor.h"
-
-#include "DebugActor.h"
-#include "core/Renderer.h"
-#include "RootActor.h"
-
-#include "TextActor.h"
-#include "ColorRectSprite.h"
-
-
 #include "res/ResAnim.h"
-#include "Button.h"
 #include "res/Resources.h"
-#include "Event.h"
 
 #include "utils/stringUtils.h"
+
 #include "core/NativeTexture.h"
+#include "core/ZipFileSystem.h"
+#include "core/system_data.h"
+#include "core/Renderer.h"
 
-#include "RenderState.h"
 #include "dev_tools/DeveloperMenu.h"
 #include "dev_tools/TreeInspector.h"
 #include "dev_tools/TexturesInspector.h"
 
+#include "DebugActor.h"
+#include "RootActor.h"
+#include "TextActor.h"
+#include "ColorRectSprite.h"
+#include "Button.h"
+#include "Event.h"
+#include "RenderState.h"
+#include "initActor.h"
+
+
+
 #ifdef __S3E__
 #include "s3eMemory.h"
 #endif
@@ -41,13 +43,14 @@ namespace oxygine
 		if (resSystem)
 			return;
 
+		file::ZipFileSystem zp;
+		zp.setPrefix("system/");
+		zp.add(system_data, system_size);
 
+		file::mount(&zp);
 		resSystem = new Resources;
 		resSystem->loadXML("system/res.xml", 0, true, false, "system");
-		if (resSystem->getResFont("system")->getAttribute("version").as_int() != 7)
-		{
-			OX_ASSERT(!"PLEASE UPDATE 'data/system' folder. Copy it from 'oxygine-framework/oxygine/system_data/data/' to 'YOUR_APP/data/'");
-		}
+		file::unmount(&zp);
 
 		//log::messageln("initialized DebugActor");
 	}
@@ -314,7 +317,7 @@ namespace oxygine
 	void DebugActor::onDAEvent(Event *ev)
 	{
 		TouchEvent *t = safeCast<TouchEvent*>(ev);
-		Vector2 loc = convert_global2local(this, RootActor::instance, t->localPosition);
+		Vector2 loc = convert_global2local(this, getRoot(), t->localPosition);
 		setAlpha(isOn(loc) ? 64 : 255);
 	}
 

+ 61 - 33
oxygine/src/Draggable.cpp

@@ -58,7 +58,8 @@ namespace oxygine
 		_dragPos(0,0), 
 		_clientIsParent(false), 
 		_dragEnabled(true),
-		_pressed(false)
+		_pressed(false), 
+		_singleDrag(false)
 	{
 
 	}
@@ -70,7 +71,7 @@ namespace oxygine
 
 	void Draggable::destroy()
 	{
-		if (_actor)
+		if (_actor && !_singleDrag)
 		{
 			if (RootActor::instance)
 				RootActor::instance->removeEventListeners(this);
@@ -81,6 +82,7 @@ namespace oxygine
 
 	void Draggable::init(Actor *actor)
 	{
+		_singleDrag = false;
 		_actor = actor;
 		_dragClient = actor;
 
@@ -88,6 +90,61 @@ namespace oxygine
 		actor->addEventListener(TouchEvent::TOUCH_UP, CLOSURE(this, &Draggable::onEvent));
 	}
 
+	void Draggable::start(const PointerState *pointer, Actor *actor, const Vector2 &localPosition)
+	{
+		_singleDrag = true;
+		_actor = actor;
+		_dragClient = actor;
+
+		getRoot()->addEventListener(TouchEvent::TOUCH_UP, CLOSURE(this, &Draggable::onEvent));
+		
+		Vector2 src = pointer->getPosition().cast<Vector2>();
+		Vector2 pos = convert_root2local(actor->getParent(), src);
+		actor->setPosition(pos - localPosition);
+
+		startDrag(localPosition);
+	}
+
+	void Draggable::startDrag(const Vector2 &localCenter)
+	{
+		_pressed = true;
+		_dragPos = localCenter;
+		_clientPos = _dragClient->getPosition();
+
+		//why I did add it?
+		//event->stopPropagation();
+
+		getRoot()->addEventListener(TouchEvent::MOVE, CLOSURE(this, &Draggable::onEvent));
+	}
+
+	void Draggable::onMove(const Vector2 &position)
+	{
+		if (_pressed && _dragEnabled)
+		{
+			Actor *client = _dragClient;
+
+
+			Vector2 localPos = convert_root2local(client, position);
+
+			Vector2 dragOffset = localPos - _dragPos;
+
+			Vector2 converted = convertPosUp(client, client->getParent(), dragOffset, true);
+			//printVec("dragOffset", dragOffset);
+			//printVec("converted", converted);
+			Vector2 np;
+			bool _clientIsParent = true;
+			if (!_clientIsParent)
+				np = _clientPos + dragOffset;
+			else 
+				np = client->getPosition() + converted;
+
+			client->setPosition(np);
+
+
+			snapClient2Bounds();
+		}
+	}
+
 	void Draggable::onEvent(Event *event)
 	{
 		//if (event->currentTarget.get() != _actor)
@@ -98,14 +155,7 @@ namespace oxygine
 		{
 		case TouchEvent::TOUCH_DOWN:
 			{
-				_pressed = true;
-				_dragPos = te->localPosition;
-				_clientPos = _dragClient->getPosition();
-
-				//why I did add it?
-				//event->stopPropagation();
-
-				RootActor::instance->addEventListener(TouchEvent::MOVE, CLOSURE(this, &Draggable::onEvent));
+				startDrag(te->localPosition);
 			}
 			break;
 		case TouchEvent::TOUCH_UP:
@@ -117,29 +167,7 @@ namespace oxygine
 
 		case TouchEvent::MOVE:
 			{
-				if (_pressed && _dragEnabled)
-				{
-					Actor *client = _dragClient;
-
-					Vector2 localPos = convert_global2local(client, safeSpCast<Actor>(te->currentTarget), te->localPosition);
-
-					Vector2 dragOffset = localPos - _dragPos;
-
-					Vector2 converted = convertPosUp(client, client->getParent(), dragOffset, true);
-					//printVec("dragOffset", dragOffset);
-					//printVec("converted", converted);
-					Vector2 np;
-					bool _clientIsParent = true;
-					if (!_clientIsParent)
-						np = _clientPos + dragOffset;
-					else 
-						np = client->getPosition() + converted;
-
-					client->setPosition(np);
-
-
-					snapClient2Bounds();
-				}
+				onMove(te->localPosition);
 			}
 			break;
 		}

+ 7 - 1
oxygine/src/Draggable.h

@@ -13,8 +13,9 @@ namespace oxygine
 		Draggable();
 		~Draggable();
 
-
 		void init(Actor *actor);
+		void start(const PointerState *pointer, Actor *actor, const Vector2 &localCenter);
+
 		void destroy();
 
 		Actor*			getDragClient() const {return _dragClient;}
@@ -28,15 +29,20 @@ namespace oxygine
 		/**sets destination drag client. Default value is Actor attached to DragHandler*/
 		void setDragClient(Actor *actor);
 		void snapClient2Bounds();
+
 	protected:
 		Actor *getClient();
 		void onEvent(Event *event);
+		void startDrag(const Vector2 &localPos);
 
 		void onDrag(TouchEvent *es);
+		void onMove(const Vector2 &position);
 
 		Actor *_dragClient;
 		Actor *_actor;
 
+		bool _singleDrag;
+
 		RectF _bounds;
 		Vector2 _dragPos;
 		Vector2 _clientPos;

+ 2 - 0
oxygine/src/EventDispatcher.h

@@ -14,6 +14,8 @@ namespace oxygine
 	class Event//: public Object
 	{
 	public:
+		enum {COMPLETE = makefourcc('_', 'E', 'C', 'M')};
+
 		enum Phase
 		{
 			phase_capturing = 1,

+ 1 - 2
oxygine/src/Input.cpp

@@ -1,6 +1,6 @@
 #include "Input.h"
 #include "RootActor.h"
-#include "core/logging.h"
+#include "core/log.h"
 
 namespace oxygine
 {
@@ -70,7 +70,6 @@ namespace oxygine
 		_pointerMouse.init(MAX_TOUCHES + 1);
 		for (int i = 0; i < MAX_TOUCHES; ++i)
 			_pointers[i].init(i + 1);
-
 		memset(_ids, 0, sizeof(_ids));
 	}
 

+ 4 - 1
oxygine/src/Input.h

@@ -23,7 +23,7 @@ namespace oxygine
 
 		void cleanup();
 
-		/**id should be in range (1, MAX_TOUCHES)*/
+		/**id should be in range [1, MAX_TOUCHES]*/
 		PointerState *getTouchByIndex(int index);
 
 #ifndef __S3E__
@@ -35,7 +35,10 @@ namespace oxygine
 		//internal:
 		PointerState _pointers[MAX_TOUCHES];
 		PointerState _pointerMouse;
+
 		int _ids[MAX_TOUCHES];
+
+
 		void sendPointerButtonEvent(MouseButton button, int x, int y, int type, PointerState *);
 		void sendPointerMotionEvent(int x, int y, PointerState *);
 		void sendPointerWheelEvent(int scroll, PointerState *);

+ 2 - 2
oxygine/src/MemoryTexture.cpp

@@ -1,8 +1,8 @@
 #include "MemoryTexture.h"
 #include "math/Rect.h"
 #include "core/ImageDataOperations.h"
-#include "core/files_io.h"
-#include "core/logging.h"
+#include "core/file.h"
+#include "core/log.h"
 
 extern "C"
 {

+ 1 - 1
oxygine/src/MemoryTexture.h

@@ -2,7 +2,7 @@
 #include "core/Texture.h"
 #include "core/oxygine.h"
 #include "math/Rect.h"
-#include "core/files_io.h"
+#include "core/file.h"
 
 namespace oxygine
 {

+ 85 - 0
oxygine/src/core/FileSystem.cpp

@@ -0,0 +1,85 @@
+#include "FileSystem.h"
+namespace oxygine
+{
+	namespace file
+	{
+		FileSystem::FileSystem()
+		{
+			_prefix[0] = 0;
+		}
+
+		FileSystem::~FileSystem()
+		{
+
+		}
+
+		void FileSystem::setPrefix(const char *str)
+		{
+			strcpy(_prefix, str);
+		}
+
+		bool FileSystem::isExists(const char *file)
+		{
+			for (filesystems::reverse_iterator i = _filesystems.rbegin(); i != _filesystems.rend(); ++i)
+			{
+				FileSystem *fs = *i;
+				if (fs->_isExists(file))
+					return true;
+			}
+
+			return _isExists(file);
+		}
+
+		bool starts_with(const char *string, const char *prefix)
+		{
+			while(*prefix)
+			{
+				if(*prefix++ != *string++)
+					return false;
+			}
+
+			return true;
+		}
+
+		FileSystem::status FileSystem::open(const char *file, const char *mode, error_policy ep, fileHandle *&fh)
+		{
+			if (!starts_with(file, _prefix))
+				return status_error;
+			//file += strlen(_prefix);
+			for (filesystems::reverse_iterator i = _filesystems.rbegin(); i != _filesystems.rend(); ++i)
+			{
+				FileSystem *fs = *i;
+				status st = fs->open(file, mode, ep, fh);
+				if (st == status_ok)
+					return st;
+			}
+
+			return _open(file, mode, ep, fh);
+		}
+
+		void FileSystem::mount(FileSystem *fs)
+		{
+			filesystems::iterator i = find(_filesystems.begin(), _filesystems.end(), fs);
+			OX_ASSERT(i == _filesystems.end());
+			_filesystems.push_back(fs);
+		}
+
+		void FileSystem::unmount(FileSystem *fs)
+		{
+			filesystems::iterator i = find(_filesystems.begin(), _filesystems.end(), fs);
+			if (i != _filesystems.end())
+			{
+				_filesystems.erase(i);
+			}
+		}
+
+		bool FileSystem::_isExists(const char *file)
+		{
+			fileHandle *fh = 0;
+			status s = _open(file, "rb", ep_ignore_error, fh);
+			if (fh)
+				fh->release();
+			return s == status_ok;
+		}
+	}
+}

+ 52 - 0
oxygine/src/core/FileSystem.h

@@ -0,0 +1,52 @@
+#pragma once
+#include "Object.h"
+
+namespace oxygine
+{
+	namespace file
+	{
+		class fileHandle: public ObjectBase
+		{
+		public:
+			virtual void release() = 0;
+			virtual unsigned int read(void *dest, unsigned int size) = 0;
+			virtual unsigned int write(const void *src, unsigned int size) = 0;
+			virtual unsigned int getSize() const = 0;
+		};
+
+
+		class FileSystem
+		{
+		public:
+			enum status
+			{
+				status_error,
+				status_ok,
+			};
+
+			FileSystem();
+			~FileSystem();
+
+			void setPrefix(const char *str);
+
+			bool isExists(const char *file);
+
+			status open(const char *file, const char *mode, error_policy ep, fileHandle *&fh);
+
+			void mount(FileSystem *fs);
+			void unmount(FileSystem *fs);
+
+		protected:
+			virtual status _open(const char *file, const char *mode, error_policy ep, fileHandle*&) = 0;
+			virtual bool _isExists(const char *file);
+
+			char _prefix[32];
+
+			typedef vector<FileSystem*> filesystems;
+			filesystems _filesystems;
+		};
+
+		void mount(FileSystem *fs);
+		void unmount(FileSystem *fs);
+	}
+}

+ 2 - 2
oxygine/src/core/NativeTexture.cpp

@@ -3,8 +3,8 @@
 #include "NativeTexture.h"
 #include "MemoryTexture.h"
 #include "ImageDataOperations.h"
-#include "files_io.h"
-#include "logging.h"
+#include "file.h"
+#include "log.h"
 
 /*
 #define DEC_FUNC(proc, name) proc name = 0;

+ 1 - 1
oxygine/src/core/Object.cpp

@@ -2,7 +2,7 @@
 #include "oxygine.h"
 #include <typeinfo>
 #include <stdio.h>
-#include "logging.h"
+#include "log.h"
 #include "Mutex.h"
 #include "utils/stringUtils.h"
 

+ 223 - 0
oxygine/src/core/STDFileSystem.cpp

@@ -0,0 +1,223 @@
+#include <string>
+#include "STDFileSystem.h"
+#include "oxygine.h"
+#include "log.h"
+#include "utils/stringUtils.h"
+#include "Object.h"
+#include "file.h"
+#ifdef __APPLE__
+#include <unistd.h>
+#endif
+
+
+
+//#define LOGD(...) oxygine::log::messageln(__VA_ARGS__)
+#define LOGD(...) 
+
+#if __S3E__
+#define USE_S3E_FILE
+#include "IwAutoFile.h"
+#include "s3eFile.h"	
+
+typedef s3eFile oxHandle;
+
+#define oxFileOpen_ s3eFileOpen
+#define oxFileClose_ s3eFileClose
+#define oxFileSeek s3eFileSeek
+#define oxFileTell s3eFileTell
+#define oxFileWrite s3eFileWrite
+#define	ox_FILESEEK_END S3E_FILESEEK_END
+#define	ox_FILESEEK_SET S3E_FILESEEK_SET
+
+#define oxFileRead s3eFileRead
+#define oxExists(name) s3eFileCheckExists(name)
+
+#elif OXYGINE_SDL
+#ifdef WIN32
+#include <direct.h>
+#endif
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include "SDL_rwops.h"	
+
+typedef SDL_RWops oxHandle;
+//todo remove s3e
+#define oxFileOpen_ SDL_RWFromFile
+#define oxFileClose_ SDL_RWclose
+#define oxFileSeek SDL_RWseek
+#define oxFileTell SDL_RWtell
+#define oxFileWrite(ptr, size, n, handle) SDL_RWwrite(handle, ptr, size, n)
+#define	ox_FILESEEK_END RW_SEEK_END
+#define	ox_FILESEEK_SET RW_SEEK_SET
+
+bool sdlExists(const char *name)
+{
+	//return true;
+	LOGD("check file exists: %s___", name);
+	oxHandle* h = oxFileOpen_(name, "rb");
+	LOGD("check ");
+	if (h)
+		oxFileClose_(h);
+	LOGD("check file exists: %s %d", name, (int)(h != 0));
+	return h != 0;
+}
+#define oxExists(name) sdlExists(name)
+#define oxFileRead(ptr, size, n, handle) SDL_RWread(handle, ptr, size, n)
+
+#else
+
+#ifdef WIN32
+#include <direct.h>
+#endif
+
+#define USE_STDIO
+#include <stdio.h>
+#include <sys/stat.h>	
+
+typedef FILE oxHandle;
+
+//todo remove s3e
+#define oxFileOpen_ fopen
+#define oxFileClose_ fclose
+#define oxFileSeek fseek
+#define oxFileTell ftell
+#define oxFileWrite fwrite
+#define	ox_FILESEEK_END SEEK_END
+#define	ox_FILESEEK_SET SEEK_SET
+
+#define oxExists(name) (true)
+#define oxFileRead(ptr, size, n, handle) fread(ptr, size, n, handle)
+
+#endif//__S3E__
+
+
+//#define LOGD(...) {}
+
+namespace oxygine
+{
+	namespace file
+	{
+		using namespace std;
+
+		int _openedFiles = 0;
+		oxHandle* oxFileOpen(const char* filename, const char* mode)
+		{
+			oxHandle *h = oxFileOpen_(filename, mode);
+			if (h)
+				_openedFiles++;
+			return h;
+		}
+
+		void oxFileClose(oxHandle* file)
+		{
+			if (file)
+				_openedFiles--;
+			oxFileClose_(file);
+		}
+
+
+		class STDFileSystem;
+
+		class fileHandleSTD:public fileHandle
+		{
+		public:
+			fileHandleSTD(oxHandle* fh):_handle(fh)
+			{
+			}
+
+			void release()
+			{
+				oxFileClose(_handle);
+				delete this;
+			}
+
+			unsigned int read(void *dest, unsigned int size)
+			{
+				return oxFileRead(dest, 1, size, _handle);
+			}
+
+			unsigned int write(const void *src, unsigned int size)
+			{
+				return oxFileWrite(src,1, size, _handle);
+			}
+
+			virtual unsigned int getSize() const
+			{
+				oxFileSeek(_handle, 0, ox_FILESEEK_END);
+				unsigned int size  = oxFileTell(_handle);
+				oxFileSeek(_handle, 0, ox_FILESEEK_SET);
+
+				return size;
+			}
+
+		private:
+			oxHandle* _handle;
+		};
+
+		STDFileSystem::STDFileSystem()
+		{
+#ifdef WIN32
+			mkdir("../data-ram");
+#endif
+		}
+
+		void STDFileSystem::setExtendedFolder(const char *folder)
+		{
+			_extended = folder;
+			_extended += "/";
+			char norm[512];
+			path::normalize(_extended.c_str(), norm);
+			_extended = norm;
+		}
+
+
+		FileSystem::status STDFileSystem::_open(const char *file, const char *mode, error_policy ep, fileHandle*& fh)
+		{
+			bool write = mode[0] == 'w' || mode[0] == 'W';
+			oxHandle* h = 0;
+			if (!_extended.empty() && !write)
+			{
+				string path = _extended + file;
+				if (oxExists(path.c_str()))
+					h = oxFileOpen(path.c_str(), mode);
+			}
+
+			if (!h)
+			{
+#ifdef WIN32
+				char name[255];
+				safe_sprintf(name, "../data-ram/%s", file);
+				h = oxFileOpen(name, mode);
+#endif
+			}
+
+			if (!h)
+			{
+				h = oxFileOpen(file, mode);
+			}
+
+			if (!h)
+				return status_error;
+			
+			fh = new fileHandleSTD(h);
+			return status_ok;
+		}
+
+		bool STDFileSystem::_isExists(const char *file)
+		{
+#if __S3E__
+			string path = _extended + file;
+			s3eBool res = s3eFileCheckExists(path.c_str());			
+			if (res == S3E_FALSE)
+				res = s3eFileCheckExists(file);
+			return res == S3E_TRUE;
+#else
+			handle f = file::open(file, "r", ep_ignore_error);
+			autoClose h(f);
+			return f != 0;
+#endif
+
+		}
+	}
+}

+ 20 - 0
oxygine/src/core/STDFileSystem.h

@@ -0,0 +1,20 @@
+#pragma once
+#include "FileSystem.h"
+namespace oxygine
+{
+	namespace file
+	{
+		class STDFileSystem: public FileSystem
+		{
+		public:
+			STDFileSystem();
+			void setExtendedFolder(const char *folder);
+
+		protected:
+			string _extended;
+
+			status _open(const char *file_, const char *mode, error_policy ep, fileHandle*& fh);
+			bool _isExists(const char *file);
+		};
+	}	
+}

+ 221 - 0
oxygine/src/core/ZipFileSystem.cpp

@@ -0,0 +1,221 @@
+#include <string.h>
+#include <map>
+#include "../minizip/ioapi_mem.h"
+#include "core/ZipFileSystem.h"
+#include "core/Object.h"
+#include "utils/stringUtils.h"
+//#include "utils/utils.h"
+
+#ifdef __S3E__
+#include "s3eFile.h"
+#endif
+
+using namespace oxygine;
+using namespace std;
+namespace oxygine
+{
+namespace file
+{
+	bool sortFiles (const file_entry &ob1, const file_entry &ob2)
+	{
+		return strcmp_cns(ob1.name, ob2.name) < 0;
+	}
+
+	bool readEntry(const file_entry *entry, file::buffer &bf)
+	{
+		bf.data.resize(0);
+		int r = unzGoToFilePos(entry->zp, const_cast<unz_file_pos*>(&entry->pos));
+		OX_ASSERT(r == UNZ_OK);
+
+		unz_file_info file_info;
+		r = unzGetCurrentFileInfo(entry->zp, &file_info, 0, 0, 0, 0, 0, 0);
+		OX_ASSERT(r == UNZ_OK);
+
+		unzOpenCurrentFile(entry->zp);		
+
+		bf.data.resize(file_info.uncompressed_size);
+		r = unzReadCurrentFile(entry->zp, &bf.data.front(), bf.data.size());
+		OX_ASSERT(r == file_info.uncompressed_size);
+
+		unzCloseCurrentFile(entry->zp);
+		return true;
+	}
+
+	Zips::Zips():_sort(false)
+	{
+
+	}
+
+	Zips::~Zips()
+	{
+		reset();
+	}
+
+	void Zips::add(unzFile zp)
+	{
+		_zps.push_back(zp);
+
+		do 
+		{
+			unz_file_pos pos;
+			unzGetFilePos(zp, &pos);
+
+			file_entry entry;				
+			unzGetCurrentFileInfo(zp, 0, entry.name, sizeof(entry.name) - 1, 0, 0, 0, 0);
+			entry.pos = pos;
+			entry.zp = zp;
+
+			strcpy(entry.name, entry.name);
+
+			_files.push_back(entry);
+
+		} while (unzGoToNextFile(zp) != UNZ_END_OF_LIST_OF_FILE);
+
+		_sort = true;
+	}
+
+	void Zips::add(const unsigned char* data, unsigned int size)
+	{
+		zlib_filefunc_def ff;
+		fill_memory_filefunc(&ff);
+		char str[255];
+		safe_sprintf(str, "%x+%x", data, size);
+		unzFile zp = unzOpen2(str, &ff);
+		OX_ASSERT(zp);
+		if (!zp)
+			return;
+
+		add(zp);
+	}
+
+	void Zips::add(const char *name)
+	{
+		unzFile zp = unzOpen(name);
+		OX_ASSERT(zp);
+		if (!zp)
+			return;
+
+		add(zp);
+	}
+
+	void Zips::update()
+	{
+		sort(_files.begin(), _files.end(), sortFiles);
+		log::messageln("ZipFS, total files: %d", _files.size());
+	}
+
+	bool Zips::read(const char *name, file::buffer &bf)
+	{
+		const file_entry *entry = getEntry(name);
+		if (!entry)
+			return false;
+		return readEntry(entry, bf);
+	}
+
+	void Zips::reset()
+	{
+		for (zips::iterator i = _zps.begin(); i != _zps.end(); ++i)
+		{
+			unzFile f = *i;
+			unzClose(f);
+		}
+
+		_zps.resize(0);
+		_files.resize(0);
+	}
+
+
+	bool findEntry (const file_entry &g, const char *name)
+	{
+		return strcmp_cns(g.name, name) < 0;
+	}
+
+	const file_entry *Zips::getEntry(const char *name)
+	{
+		if (_sort)
+		{
+			update();
+			_sort = false;
+		}
+
+		files::const_iterator it = lower_bound(_files.begin(), _files.end(), name, findEntry);
+		if (it != _files.end())
+		{
+			const file_entry &g = *it;
+			if (!strcmp_cns(g.name, name))
+				return &g;
+		}
+
+		return 0;
+	}
+	
+	class fileHandleZip: public fileHandle
+	{
+	public:
+
+		fileHandleZip(const file_entry *entry):_entry(entry)
+		{
+			int r = 0;
+			r = unzGoToFilePos(entry->zp, const_cast<unz_file_pos*>(&entry->pos));
+			OX_ASSERT(r == UNZ_OK);
+			r = unzOpenCurrentFile(entry->zp);
+			OX_ASSERT(r == UNZ_OK);
+		}
+
+		void release()
+		{
+			unzCloseCurrentFile(_entry->zp);
+			delete this;
+		}
+
+		unsigned int read(void *dest, unsigned int size)
+		{
+			return unzReadCurrentFile(_entry->zp, dest, size);
+		}
+
+		unsigned int write(const void *src, unsigned int size)
+		{
+			return 0;
+		}
+
+		unsigned int getSize() const
+		{
+			unz_file_info file_info;
+			int res = unzGetCurrentFileInfo(_entry->zp, &file_info, 0, 0, 0, 0, 0, 0);
+			return file_info.uncompressed_size;
+		}
+
+		const file_entry *_entry;
+		
+	};
+
+
+	void ZipFileSystem::add(const char *zip)
+	{
+		_zips.add(zip);
+	}
+
+	void ZipFileSystem::add(const unsigned char* data, unsigned int size)
+	{
+		_zips.add(data, size);
+	}
+
+	void ZipFileSystem::reset()
+	{
+		_zips.reset();
+	}
+
+	FileSystem::status ZipFileSystem::_open(const char *file, const char *mode, error_policy ep, file::fileHandle *&fh)
+	{
+		const file_entry *entry = _zips.getEntry(file);
+		if (entry)
+		{
+			fh = new fileHandleZip(entry);
+			return status_ok;
+		}
+
+		handleErrorPolicy(ep, "can't find zip file entry: %s", file);
+		return status_error;
+	}
+}
+}

+ 68 - 0
oxygine/src/core/ZipFileSystem.h

@@ -0,0 +1,68 @@
+#pragma once
+#include <vector>
+#include "FileSystem.h"
+#include "minizip/unzip.h"
+#include "core/file.h"
+using namespace std;
+using namespace oxygine;
+
+namespace oxygine
+{
+namespace file
+{
+	struct file_entry
+	{
+		unzFile zp;
+		char name[128];
+		unz_file_pos pos;
+	};
+
+	class Zips
+	{
+	public:
+		Zips();
+		~Zips();
+
+		void reset();
+
+		void add(const char *name);
+		void add(const unsigned char* data, unsigned int size);
+		
+		void update();
+
+		bool read(const char *name, file::buffer &bf);
+
+		const file_entry *getEntry(const char *name);
+
+	private:
+		void add(unzFile zp);
+
+		bool _sort;
+
+		typedef vector<file_entry> files;
+		files _files;
+
+		typedef vector<unzFile> zips;
+		zips _zps;
+	};
+
+	bool read(file_entry *entry, file::buffer &bf);
+
+
+	class ZipFileSystem: public FileSystem
+	{
+	public:
+		ZipFileSystem(){}
+
+		void add(const char *zip);
+		void add(const unsigned char* data, unsigned int size);
+		void reset();
+
+	protected:
+
+		Zips _zips;
+
+		status _open(const char *file, const char *mode, error_policy ep, file::fileHandle *&fh);
+	};
+}
+}

+ 172 - 0
oxygine/src/core/file.cpp

@@ -0,0 +1,172 @@
+#include <string>
+#include "STDFileSystem.h"
+#include "file.h"
+#include "oxygine.h"
+#include "log.h"
+#include "utils/stringUtils.h"
+#include "Object.h"
+
+#if defined(__APPLE__) || defined(ANDROID)
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#endif
+
+#ifdef __S3E__
+#include <s3eFile.h>
+#else
+#if WIN32
+#include <direct.h>
+#endif
+#endif
+
+
+
+//#define LOGD(...) oxygine::log::messageln(__VA_ARGS__)
+#define LOGD(...) 
+
+
+//#define LOGD(...) {}
+
+namespace oxygine
+{
+	namespace file
+	{
+		string _additionalFolder;
+		STDFileSystem _nfs;
+
+		void mount(FileSystem *fs)
+		{
+			_nfs.mount(fs);
+		}
+
+		void unmount(FileSystem *fs)
+		{
+			_nfs.unmount(fs);
+		}
+
+		handle open(const char *file_, const char *mode, error_policy ep)
+		{
+			//OX_ASSERT(_openedFiles == 0);
+			LOGD("open file: %s %s %d", file_, mode, _openedFiles);
+			char file[512];
+			path::normalize(file_, file);
+			LOGD("q1");
+
+
+			fileHandle *fh = 0;
+			_nfs.open(file, mode, ep_ignore_error, fh);
+
+			LOGD("q3");
+
+			if (!fh)
+			{
+				handleErrorPolicy(ep, "can't open file: %s", file);
+			}
+
+			return fh;
+		}
+
+		void close(handle h)
+		{
+			LOGD("close file %x", fh);
+			fileHandle *fh = (fileHandle *)h;
+			fh->release();
+		}
+
+		void deleteFile(const char *path)
+		{
+#if __S3E__
+			s3eFileDelete(path);
+#else
+			log::warning("not implemented");
+#endif
+		}
+
+		void rename(const char *src, const char *dest)
+		{
+#if __S3E__
+			s3eFileRename(src, dest);
+#else
+			log::warning("not implemented");
+#endif			
+		}
+
+		unsigned int read(handle h, void *dest, unsigned int destSize)
+		{			
+			fileHandle *fh = (fileHandle *)h;
+			OX_ASSERT(fh && dest);
+			LOGD("read file %x %d", fh, destSize);
+
+			return fh->read(dest, destSize);
+		}
+
+		void read(const char *file, buffer &dest, error_policy ep)
+		{
+			dest.data.resize(0);
+
+			autoClose ac(open(file, "rb", ep));
+			if (ac.getHandle())
+			{
+				read(ac.getHandle(), dest);
+			}
+		}
+
+		unsigned int read(handle fh_, buffer &dest)
+		{
+			fileHandle *fh = (fileHandle*)fh_;
+
+			unsigned int size  = fh->getSize();
+			dest.data.resize(size);
+			unsigned int t = fh->read(&dest.data[0], size);
+			LOGD("read file %x %d", fh, t);
+			return t;
+		}
+
+		void write(handle fh_, const void *data, unsigned int size)
+		{
+			fileHandle *fh = (fileHandle*)fh_;
+			fh->write(data, size);
+		}
+
+		
+
+		bool exists(const char *file)
+		{
+			return _nfs.isExists(file);
+		}
+
+		void makeDirectory(const char *path)
+		{
+#if __S3E__
+			s3eFileMakeDirectory(path);
+#elif WIN32
+			mkdir(path);
+#else
+			mkdir(path, 0777);
+#endif
+		}
+
+		void deleteDirectory(const char *path)
+		{
+#if __S3E__
+			s3eFileDeleteDirectory(path);
+#else
+			rmdir(path);
+#endif
+		}
+
+		void write(const char *file, const buffer &data, error_policy ep)
+		{
+			autoClose ac(open(file, "w", ep));
+			if (!ac.getHandle())
+				return;
+			write(ac.getHandle(), data.getData(), data.getSize());
+		}
+
+		void setExtendedFolder(const char *folder)
+		{
+			_nfs.setExtendedFolder(folder);			
+		}
+	}
+}

+ 87 - 0
oxygine/src/core/file.h

@@ -0,0 +1,87 @@
+#pragma once
+#include <vector>
+#include "Object.h"
+#include "oxygine.h"
+
+namespace oxygine
+{
+	/**Input/Output files api.*/
+
+	/**
+	some notes:
+	setExtendedFolder could be used as hook for High Definition art assets.
+		If file is missing in additional folder it would be searched from root resources folder.
+		here is folders structure example:
+	root:
+		images/ \n
+		atlasses\ \n
+		xmls/ \n
+		fonts/ \n
+		HD/images/ \n
+		  /fonts/ \n
+		if you want use HD resources you should add setAdditionalFolder("HD");
+	*/
+
+	namespace file
+	{
+		class buffer
+		{
+		public:		
+			const void *getData() const {if (data.empty()) return 0; return &data[0];}
+			unsigned int getSize() const {return (unsigned int)data.size();}
+
+			typedef std::vector<unsigned char> buff;
+			buff data;
+		};
+
+		typedef void* handle;
+
+		/**Opens file for reading (mode = "r") or writing (mode = "w"). If file is missing returns zero.*/
+		handle open(const char *file, const char *mode, error_policy ep = ep_show_error);
+
+		/**Closes opened file handle*/
+		void close(handle);
+
+		/**Reads bytes into user memory*/
+		unsigned int read(handle, void *dest, unsigned int size);
+
+		/**Reads bytes into destination buffer. Clears existing buffer*/
+		void read(const char *file, buffer &dest, error_policy ep = ep_show_error);
+
+		/**Reads bytes into destination buffer*/
+		unsigned int read(handle, buffer &dest);
+
+		/**Writes bytes to file*/
+		void write(handle, const void *data, unsigned int size);
+
+		/**Writes bytes to file*/
+		void write(const char *file, const buffer &data, error_policy ep = ep_show_error);
+
+		/**Is file exists?*/
+		bool exists(const char *file);
+
+		void deleteFile(const char *path);
+		void rename(const char *src, const char *dest);
+		void makeDirectory(const char *path);
+		void deleteDirectory(const char *path);
+
+		/**setExtendedFolder sets additional "hook" folder where files would be searched initially.*/
+		void setExtendedFolder(const char *folder);
+
+		class autoClose
+		{
+		public:
+			autoClose(handle h):_handle(h){}
+			~autoClose(){if (_handle) close(_handle);}
+
+			handle getHandle() const {return _handle;}
+
+		private:
+			//non copyable
+			autoClose(const autoClose&);			
+			const autoClose& operator=(const autoClose&);	
+
+			handle _handle;
+		};
+	}
+}

+ 3 - 75
oxygine/src/core/files_io.h

@@ -1,75 +1,3 @@
-#pragma once
-#include <vector>
-#include "oxygine.h"
-
-namespace oxygine
-{
-	/**Input/Output files api.*/
-
-	/**
-	some notes:
-	setExtendedFolder could be used as hook for High Definition art assets.
-		If file is missing in additional folder it would be searched from root resources folder.
-		here is folders structure example:
-	root:
-		images/ \n
-		atlasses\ \n
-		xmls/ \n
-		fonts/ \n
-		HD/images/ \n
-		  /fonts/ \n
-		if you want use HD resources you should add setAdditionalFolder("HD");
-	*/
-
-	namespace file
-	{
-		class buffer
-		{
-		public:		
-			const void *getData() const {if (data.empty()) return 0; return &data[0];}
-			unsigned int getSize() const {return (unsigned int)data.size();}
-
-			typedef std::vector<unsigned char> buff;
-			buff data;
-		};
-
-		typedef void* handle;
-
-		/**Opens file for reading (mode = "r") or writing (mode = "w"). If file is missing returns zero.*/
-		handle open(const char *file, const char *mode, error_policy ep = ep_show_error);
-		/**Closes opened file handle*/
-		void close(handle);
-		/**Reads bytes into user memory*/
-		unsigned int read(handle, void *dest, unsigned int size);
-		/**Reads bytes into destination buffer. Clears existing buffer*/
-		void read(const char *file, buffer &dest, error_policy ep = ep_show_error);
-		/**Reads bytes into destination buffer*/
-		unsigned int read(handle, buffer &dest);
-		/**Writes bytes to file*/
-		void write(handle, const void *data, unsigned int size);
-		/**Writes bytes to file*/
-		void write(const char *file, const buffer &data, error_policy ep = ep_show_error);
-		/**Is file exists?*/
-		bool exists(const char *file);
-
-		void deleteFile(const char *path);
-		void rename(const char *src, const char *dest);
-		void makeDirectory(const char *path);
-		void deleteDirectory(const char *path);
-
-		/**setExtendedFolder sets additional "hook" folder where files would be searched initially.*/
-		void setExtendedFolder(const char *folder);
-
-		class autoClose
-		{
-		public:
-			autoClose(handle h):_handle(h){}
-			~autoClose(){if (_handle) close(_handle);}
-
-			handle getHandle() const {return _handle;}
-
-		private:
-			handle _handle;
-		};
-	}
-}
+//file.h header was deprecated
+//include file.h directly
+#include "file.h"

+ 2 - 2
oxygine/src/core/gl/NativeTextureGLES.cpp

@@ -5,8 +5,8 @@
 #include "../oxygine.h"
 #include "../NativeTexture.h"
 #include "../ImageDataOperations.h"
-#include "../files_io.h"
-#include "../logging.h"
+#include "../file.h"
+#include "../log.h"
 
 
 namespace oxygine

+ 27 - 105
oxygine/src/core/gl/VideoDriverGLES20.cpp

@@ -4,9 +4,10 @@
 #include "math/Color.h"
 #include "utils/stringUtils.h"
 #include "../vertex.h"
-#include "../files_io.h"
-#include "../logging.h"
-
+#include "../file.h"
+#include "../log.h"
+#include "../ZipFileSystem.h"
+#include "../system_data.h"
 
 
 #ifdef __ANDROID__
@@ -36,16 +37,26 @@ namespace oxygine
 		}
 	}
 
-	
 
-	UberShaderProgram::UberShaderProgram(const char *fileName, const char *prepend, const char *append)		
+
+	UberShaderProgram::UberShaderProgram(const file::buffer &baseShader, const char *prepend, const char *append)		
 	{
-		file::read(fileName, _data);
+		_data.data = baseShader.data;
+
 		_data.data.insert(_data.data.begin(), prepend, prepend + strlen(prepend));
 		_data.data.insert(_data.data.end(), append, append + strlen(append));
 		_data.data.push_back(0);
 	}
 
+	UberShaderProgram::~UberShaderProgram()
+	{
+		for (int i = 0; i < SIZE; ++i)
+		{
+			shader &s = _shaders[i];
+			delete s.program;
+		}
+	}
+
 
 
 	UberShaderProgram::shader *UberShaderProgram::getShaderProgram(int flags)
@@ -151,110 +162,19 @@ namespace oxygine
 		return p;
 	}
 
-	/*
-	unsigned int VideoDriverGLES20::createShader(unsigned int type, const char* data, const char *prepend, const char *append)
-	{
-		GLuint shader = glCreateShader(type);
-
-		const char *sources[3];
-		const char **ptr = &sources[0];
-		if (prepend)
-		{
-			*ptr = prepend;
-			ptr++;
-		}
-
-		*ptr = data;
-		ptr++;
-
-		if (append)
-		{
-			*ptr = append;
-			ptr++;
-		}
-
-		int num = ptr - sources;
-		glShaderSource(shader, num, sources, 0);
-		glCompileShader(shader);
-		printShaderInfoLog(shader);
-
-		return shader;
-	}
-
-
-	unsigned int VideoDriverGLES20::createProgram(int vs, int fs)
-	{
-		int p = glCreateProgram();
-		glAttachShader(p, vs);
-		glAttachShader(p, fs);
-		
-		const VertexDeclarationGL *decl = VertexDeclarationGL::getDeclaration(VERTEX_PCT2);
-		for (int i = 0; i < decl->numElements; ++i)		
-			glBindAttribLocation(p, decl->elements[i].index, decl->elements[i].name);
-
-		glLinkProgram(p);
-
-		return p;
-	}
-	*/
-
 	VideoDriverGLES20::VideoDriverGLES20():_blend(blend_default), 
-		_currentProgram(0), _us("system/shader.glsl")
+		_currentProgram(0)
 	{
-		file::buffer bf;
-		file::read("system/shader.glsl", bf);
-		bf.data.push_back(0);
-		const char* data = (const char*)bf.getData();
-
-		//ShaderProgram *s = us.getShaderProgram(UberShader::ALPHA_PREMULTIPLY);
-
-		/*
-		_vshader = createShader(GL_VERTEX_SHADER, data,
-			"#define program_main_vs main\n"
-			"#define VS\n", 0
-			);
-
-		_fshaderSplit = createShader(GL_FRAGMENT_SHADER, data, 
-			"#define program_main_ps main\n"
-			"#define SEPARATE_ALPHA\n"
-			"#define ALPHA_PREMULTIPLY\n"
-			"#define PS\n", 0);
-
-		_fshaderMain = createShader(GL_FRAGMENT_SHADER, data, 
-			"#define program_main_ps main\n"
-			"#define PS\n", 0);
-
-		_fshaderPremultiply = createShader(GL_FRAGMENT_SHADER, data, 
-			"#define program_main_ps main\n"
-			"#define ALPHA_PREMULTIPLY\n"
-			"#define PS\n", 0);
-
-			*/
-		/*
-
-		_splitShaderProgram = us.getShaderProgram(UberShader::SEPARATE_ALPHA | UberShader::ALPHA_PREMULTIPLY);
-		_mainShaderProgram = us.getShaderProgram(0);		
-		_premultiplyShaderProgram = us.getShaderProgram(UberShader::ALPHA_PREMULTIPLY);
-
-		_currentShaderProgram = _mainShaderProgram;
-		_currentShaderProgram->program->bind();
-		*/
+		_matrixVP.identity();
+		file::Zips zp;
+		zp.add(system_data, system_size);
+		zp.read("system/shader.glsl", _shaderBody);
+		_us = UberShaderProgram(_shaderBody);
 	}
 
 	VideoDriverGLES20::~VideoDriverGLES20()
 	{
 		glUseProgram(0);
-		/*
-
-		glDeleteProgram(_mainShaderProgram);
-		glDeleteProgram(_splitShaderProgram);
-		glDeleteProgram(_premultiplyShaderProgram);
-
-		glDeleteShader(_vshader);
-		glDeleteShader(_fshaderMain);
-		glDeleteShader(_fshaderSplit);		
-		glDeleteShader(_fshaderPremultiply);		
-		*/
 	}
 
 	spNativeTexture VideoDriverGLES20::createTexture()
@@ -297,7 +217,8 @@ namespace oxygine
 		OX_ASSERT(alpha_location != -1);
 		if (alpha_location != -1)
 			glUniform1i(alpha_location, SAMPLER - GL_TEXTURE0);
-	}	
+	}
+
 	void VideoDriverGLES20::drawBatch(const batch &b)
 	{		
 		const VertexDeclarationGL *decl = static_cast<const VertexDeclarationGL*>(b.vdecl);
@@ -340,7 +261,8 @@ namespace oxygine
 				glEnable(GL_BLEND);
 			else
 				glDisable(GL_BLEND);
-		}		
+		}
+
 		UberShaderProgram *program = b.program;
 		if (program)		
 		{

+ 6 - 2
oxygine/src/core/gl/VideoDriverGLES20.h

@@ -1,7 +1,7 @@
 #pragma once
 #include "VideoDriverGL.h"
 #include "../ShaderProgram.h"
-#include "../files_io.h"
+#include "../file.h"
 
 namespace oxygine
 {
@@ -67,7 +67,9 @@ namespace oxygine
 		};
 		typedef Closure<void (ShaderProgramGL *)> ShaderUniformsCallback;
 
-		UberShaderProgram(const char *fileName, const char *prepend="", const char *append = "");
+		UberShaderProgram(){}
+		UberShaderProgram(const file::buffer &baseShader, const char *prepend="", const char *append = "");
+		~UberShaderProgram();
 
 		void setShaderUniformsCallback(ShaderUniformsCallback cb){_cb = cb;}
 
@@ -91,6 +93,7 @@ namespace oxygine
 		~VideoDriverGLES20();
 
 		spNativeTexture createTexture();
+		const file::buffer& getShaderBody() const {return _shaderBody;}
 
 		void begin(const Matrix &proj, const Matrix &view, const Rect &viewport, const Color *clearColor);
 
@@ -101,6 +104,7 @@ namespace oxygine
 		void updateConstants();
 		void setProgram(ShaderProgramGL *p);
 		void bindTexture(int sampler, const char *id, void* handle);
+		file::buffer _shaderBody;
 		UberShaderProgram _us;
 
 		ShaderProgramGL *_currentProgram;

+ 17 - 16
oxygine/src/core/gl/oxgl.h

@@ -21,27 +21,28 @@
 		#define GL_ETC1_RGB8_OES                                        0x8D64
 
 	#elif __ANDROID__
-		#include "GLES/gl.h"
+		#include "GLES2/gl2.h"
 		#define GL_GLEXT_PROTOTYPES 
-		#include "GLES/glext.h"
-
-		#define glGenFramebuffers			glGenFramebuffersOES
-		#define glBindFramebuffer			glBindFramebufferOES
-		#define glFramebufferTexture2D		glFramebufferTexture2DOES
-		#define glDeleteFramebuffers		glDeleteFramebuffersOES
-		#define glCheckFramebufferStatus	glCheckFramebufferStatusOES
-
-		#define GL_FRAMEBUFFER				GL_FRAMEBUFFER_OES
-		#define GL_FRAMEBUFFER_BINDING		GL_FRAMEBUFFER_BINDING_OES
-		#define GL_COLOR_ATTACHMENT0		GL_COLOR_ATTACHMENT0_OES
-		#define GL_FRAMEBUFFER_COMPLETE		GL_FRAMEBUFFER_COMPLETE_OES 
-
+		#include "GLES2/gl2ext.h"
+
+		#define glGenFramebuffers			glGenFramebuffers
+		#define glBindFramebuffer			glBindFramebuffer
+		#define glFramebufferTexture2D		glFramebufferTexture2D
+		#define glDeleteFramebuffers		glDeleteFramebuffers
+		#define glCheckFramebufferStatus	glCheckFramebufferStatus
+
+		/*
+		#define GL_FRAMEBUFFER				GL_FRAMEBUFFER
+		#define GL_FRAMEBUFFER_BINDING		GL_FRAMEBUFFER_BINDING
+		#define GL_COLOR_ATTACHMENT0		GL_COLOR_ATTACHMENT0
+		#define GL_FRAMEBUFFER_COMPLETE		GL_FRAMEBUFFER_COMPLETE
+		*/
 #elif __APPLE__
     #define GL_ETC1_RGB8_OES                                        0x8D64
     #include <OpenGLES/ES2/gl.h>
     #include <OpenGLES/ES2/glext.h>
-#include <OpenGLES/ES1/gl.h>
-#include <OpenGLES/ES1/glext.h>
+	#include <OpenGLES/ES1/gl.h>
+	#include <OpenGLES/ES1/glext.h>
 #endif
 
 	void initGLExtensions();

+ 139 - 0
oxygine/src/core/log.cpp

@@ -0,0 +1,139 @@
+#include "log.h"
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+
+
+
+
+#if defined(ANDROID)
+#include <android/log.h>
+#define  LOG_TAG    "SDL"
+#define  LOGD(...)  __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
+
+#else
+#ifdef WIN32
+#include <Windows.h>
+#define LOGD(...) OutputDebugStringA(__VA_ARGS__)
+#else
+#define LOGD(...) printf(__VA_ARGS__)
+#endif
+#endif
+
+
+
+namespace oxygine
+{
+	bool _enabled = true;
+	FILE *fh = 0;
+
+	const int SIZE = 512;
+	namespace log
+	{
+		void enable()
+		{
+			_enabled = true;
+		}
+
+		void disable()
+		{
+			_enabled = false;
+		}
+
+		void out(const char *str)
+		{
+			if (!_enabled)
+				return;
+
+			//if (!fh)
+			//	fh = fopen("log.txt", "w");
+			//fprintf(fh, str);
+			//fflush(fh);
+			LOGD(str);
+		}
+
+		void out_line(char *str, int i)
+		{
+			//if (i != -1)
+			//	strcpy(str + i, "\n");
+			out(str);
+			out("\n");
+			//LOGD(str);
+		}
+
+		void out_line_prefix(const char *pref, const char* format, va_list args)
+		{
+			char buff[SIZE] = {0};
+			strcpy(buff, pref);
+			
+			int len = strlen(buff);
+			int i = vsnprintf(buff + len, sizeof(buff) - len, format, args);
+						
+			out_line(buff, i + len);
+		}
+
+		void out_prefix(const char *pref, const char* format, va_list args)
+		{
+			char buff[SIZE] = {0};
+			strcpy(buff, pref);
+
+			int len = strlen(buff);
+			int i = vsnprintf(buff + len, sizeof(buff) - len, format, args);
+
+			out(buff);
+		}
+
+		void message(const char *format, ...)
+		{
+			va_list args;
+			va_start(args, format);
+			message_va(format, args);
+			va_end(args);
+		}
+
+		void message_va(const char *format, va_list args)
+		{
+			out_prefix("", format, args);
+		}
+
+		void warning(const char *format, ...)
+		{
+			va_list args;
+			va_start(args, format);
+			warning_va(format, args);
+			va_end(args);
+		}
+
+		void warning_va(const char *format, va_list args)
+		{
+			out_line_prefix("warning: ", format, args);
+		}
+
+		void error(const char *format, ...)
+		{
+			va_list args;
+			va_start(args, format);
+			error_va(format, args);
+			va_end(args);
+		}
+
+		void error_va(const char *format, va_list args)
+		{
+			out_line_prefix("error: ", format, args);
+		}
+
+		void messageln(const char *format, ...)
+		{
+			va_list args;
+			va_start(args, format);
+			messageln_va(format, args);
+			va_end(args);
+		}
+
+		void messageln_va(const char *format, va_list args)
+		{
+			out_line_prefix("", format, args);
+		}
+	}
+}

+ 30 - 0
oxygine/src/core/log.h

@@ -0,0 +1,30 @@
+#pragma once
+#include <stdarg.h>
+namespace oxygine
+{
+	/***/
+	namespace log
+	{
+		void enable();
+		void disable();
+
+		void out(const char *str);
+
+		//outputs message without end line
+		void message(const char *format, ...);
+		void message_va(const char *format, va_list args);
+
+		//outputs message with end line
+		void messageln(const char *format, ...);
+		void messageln_va(const char *format, va_list args);
+		
+
+		//outputs message as warning, has end line
+		void warning(const char *format, ...);
+		void warning_va(const char *format, va_list args);
+
+		//outputs message as error, has end line
+		void error(const char *format, ...);
+		void error_va(const char *format, va_list args);
+	}
+}

+ 3 - 30
oxygine/src/core/logging.h

@@ -1,30 +1,3 @@
-#pragma once
-#include <stdarg.h>
-namespace oxygine
-{
-	/***/
-	namespace log
-	{
-		void enable();
-		void disable();
-
-		void out(const char *str);
-
-		//outputs message without end line
-		void message(const char *format, ...);
-		void message_va(const char *format, va_list args);
-
-		//outputs message with end line
-		void messageln(const char *format, ...);
-		void messageln_va(const char *format, va_list args);
-		
-
-		//outputs message as warning, has end line
-		void warning(const char *format, ...);
-		void warning_va(const char *format, va_list args);
-
-		//outputs message as error, has end line
-		void error(const char *format, ...);
-		void error_va(const char *format, va_list args);
-	}
-}
+//log.h header was deprecated
+//include log.h directly
+#include "log.h"

+ 1 - 1
oxygine/src/core/ox_debug.h

@@ -1,6 +1,6 @@
 #pragma once
 #include <assert.h>
-#include "logging.h"
+#include "log.h"
 
 #ifdef __S3E__
 #ifdef IW_DEBUG

+ 1 - 1
oxygine/src/core/oxygine.cpp

@@ -1,7 +1,7 @@
 #include "oxygine.h"
 #include <stdio.h>
 #include "Renderer.h"
-#include "logging.h"
+#include "log.h"
 #include "winnie_alloc/winnie_alloc.h"
 #include "VideoDriver.h"
 

+ 2 - 2
oxygine/src/core/oxygine.h

@@ -6,7 +6,7 @@
 #include "math/vector3.h"
 #include "math/vector4.h"
 #include "math/matrix.h"
-#include "logging.h"
+#include "log.h"
 #include "ox_debug.h"
 
 #ifndef __S3E__
@@ -29,7 +29,7 @@ namespace oxygine
 	void *fastAlloc(size_t size);
 	void fastFree(void *data);
 
-	typedef unsigned int timeMS;
+	typedef int timeMS;
 
 
 

File diff suppressed because it is too large
+ 3 - 0
oxygine/src/core/system_data.cpp


+ 7 - 0
oxygine/src/core/system_data.h

@@ -0,0 +1,7 @@
+
+#pragma once
+#ifndef SYSTEM_DATA
+#define SYSTEM_DATA
+extern unsigned int system_size;
+extern const unsigned char system_data[];
+#endif

+ 10 - 3
oxygine/src/math/Rect.h

@@ -26,9 +26,16 @@ namespace oxygine
 
 		bool isEmpty()const
 		{
-			if (size.x > 0 && size.y > 0)
-				return false;
-			return true;
+			if (size.x <= 0 || size.y <= 0)
+				return true;
+			return false;
+		}
+
+		bool isIntersecting(const RectT &r) const
+		{
+			RectT l = *this;
+			l.clip(r);
+			return !l.isEmpty();
 		}
 
 		bool pointIn(const point2 &p) const

+ 1 - 0
oxygine/src/math/vector2.h

@@ -54,6 +54,7 @@ namespace oxygine
 
 		void normalize() { normalize( *this, *this ); };
 		void normalizeTo( T len ) { normalize(); *this *= len; };
+		VectorT2 normalized() const {VectorT2 t = *this; t.normalize(); return t;}
 
 		float distance( const VectorT2 & v ) const { return VectorT2( x - v.x, y - v.y ).length();	};
 		T dot(const VectorT2 &vr) const	{return dot(*this, vr);}

+ 178 - 0
oxygine/src/minizip/ioapi.c

@@ -0,0 +1,178 @@
+/* ioapi.c -- IO base function header for compress/uncompress .zip
+   files using zlib + zip or unzip API
+
+   Version 1.01h, December 28th, 2009
+
+   Copyright (C) 1998-2009 Gilles Vollant
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "zlib.h"
+#include "ioapi.h"
+
+
+
+/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
+
+#ifndef SEEK_CUR
+#define SEEK_CUR    1
+#endif
+
+#ifndef SEEK_END
+#define SEEK_END    2
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET    0
+#endif
+
+voidpf ZCALLBACK fopen_file_func OF((
+   voidpf opaque,
+   const char* filename,
+   int mode));
+
+uLong ZCALLBACK fread_file_func OF((
+   voidpf opaque,
+   voidpf stream,
+   void* buf,
+   uLong size));
+
+uLong ZCALLBACK fwrite_file_func OF((
+   voidpf opaque,
+   voidpf stream,
+   const void* buf,
+   uLong size));
+
+long ZCALLBACK ftell_file_func OF((
+   voidpf opaque,
+   voidpf stream));
+
+long ZCALLBACK fseek_file_func OF((
+   voidpf opaque,
+   voidpf stream,
+   uLong offset,
+   int origin));
+
+int ZCALLBACK fclose_file_func OF((
+   voidpf opaque,
+   voidpf stream));
+
+int ZCALLBACK ferror_file_func OF((
+   voidpf opaque,
+   voidpf stream));
+
+
+voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
+   voidpf opaque;
+   const char* filename;
+   int mode;
+{
+    FILE* file = NULL;
+    const char* mode_fopen = NULL;
+    if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
+        mode_fopen = "rb";
+    else
+    if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
+        mode_fopen = "r+b";
+    else
+    if (mode & ZLIB_FILEFUNC_MODE_CREATE)
+        mode_fopen = "wb";
+
+    if ((filename!=NULL) && (mode_fopen != NULL))
+        file = fopen(filename, mode_fopen);
+    return file;
+}
+
+
+uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
+   voidpf opaque;
+   voidpf stream;
+   void* buf;
+   uLong size;
+{
+    uLong ret;
+    ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
+    return ret;
+}
+
+
+uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size)
+   voidpf opaque;
+   voidpf stream;
+   const void* buf;
+   uLong size;
+{
+    uLong ret;
+    ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
+    return ret;
+}
+
+long ZCALLBACK ftell_file_func (opaque, stream)
+   voidpf opaque;
+   voidpf stream;
+{
+    long ret;
+    ret = ftell((FILE *)stream);
+    return ret;
+}
+
+long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
+   voidpf opaque;
+   voidpf stream;
+   uLong offset;
+   int origin;
+{
+    int fseek_origin=0;
+    long ret;
+    switch (origin)
+    {
+    case ZLIB_FILEFUNC_SEEK_CUR :
+        fseek_origin = SEEK_CUR;
+        break;
+    case ZLIB_FILEFUNC_SEEK_END :
+        fseek_origin = SEEK_END;
+        break;
+    case ZLIB_FILEFUNC_SEEK_SET :
+        fseek_origin = SEEK_SET;
+        break;
+    default: return -1;
+    }
+    ret = 0;
+    if (fseek((FILE *)stream, offset, fseek_origin) != 0)
+        ret = -1;
+    return ret;
+}
+
+int ZCALLBACK fclose_file_func (opaque, stream)
+   voidpf opaque;
+   voidpf stream;
+{
+    int ret;
+    ret = fclose((FILE *)stream);
+    return ret;
+}
+
+int ZCALLBACK ferror_file_func (opaque, stream)
+   voidpf opaque;
+   voidpf stream;
+{
+    int ret;
+    ret = ferror((FILE *)stream);
+    return ret;
+}
+
+void fill_fopen_filefunc (pzlib_filefunc_def)
+  zlib_filefunc_def* pzlib_filefunc_def;
+{
+    pzlib_filefunc_def->zopen_file = fopen_file_func;
+    pzlib_filefunc_def->zread_file = fread_file_func;
+    pzlib_filefunc_def->zwrite_file = fwrite_file_func;
+    pzlib_filefunc_def->ztell_file = ftell_file_func;
+    pzlib_filefunc_def->zseek_file = fseek_file_func;
+    pzlib_filefunc_def->zclose_file = fclose_file_func;
+    pzlib_filefunc_def->zerror_file = ferror_file_func;
+    pzlib_filefunc_def->opaque = NULL;
+}

+ 75 - 0
oxygine/src/minizip/ioapi.h

@@ -0,0 +1,75 @@
+/* ioapi.h -- IO base function header for compress/uncompress .zip
+   files using zlib + zip or unzip API
+
+   Version 1.01h, December 28th, 2009
+
+   Copyright (C) 1998-2009 Gilles Vollant
+*/
+
+#ifndef _ZLIBIOAPI_H
+#define _ZLIBIOAPI_H
+
+
+#define ZLIB_FILEFUNC_SEEK_CUR (1)
+#define ZLIB_FILEFUNC_SEEK_END (2)
+#define ZLIB_FILEFUNC_SEEK_SET (0)
+
+#define ZLIB_FILEFUNC_MODE_READ      (1)
+#define ZLIB_FILEFUNC_MODE_WRITE     (2)
+#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
+
+#define ZLIB_FILEFUNC_MODE_EXISTING (4)
+#define ZLIB_FILEFUNC_MODE_CREATE   (8)
+
+
+#ifndef ZCALLBACK
+
+#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
+#define ZCALLBACK CALLBACK
+#else
+#define ZCALLBACK
+#endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
+typedef uLong  (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
+typedef uLong  (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
+typedef long   (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
+typedef long   (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
+typedef int    (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
+typedef int    (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
+
+typedef struct zlib_filefunc_def_s
+{
+    open_file_func      zopen_file;
+    read_file_func      zread_file;
+    write_file_func     zwrite_file;
+    tell_file_func      ztell_file;
+    seek_file_func      zseek_file;
+    close_file_func     zclose_file;
+    testerror_file_func zerror_file;
+    voidpf              opaque;
+} zlib_filefunc_def;
+
+
+
+void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
+
+#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
+#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
+#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
+#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
+#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
+#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+

+ 219 - 0
oxygine/src/minizip/ioapi_mem.c

@@ -0,0 +1,219 @@
+/* ioapi_mem.c -- IO base function header for compress/uncompress .zip
+   files using zlib + zip or unzip API
+
+   This version of ioapi is designed to access memory rather than files.
+   We do use a region of memory to put data in to and take it out of. We do
+   not have auto-extending buffers and do not inform anyone else that the
+   data has been written. It is really intended for accessing a zip archive
+   embedded in an application such that I can write an installer with no
+   external files. Creation of archives has not been attempted, although
+   parts of the framework are present.
+
+   Based on Unzip ioapi.c version 0.22, May 19th, 2003
+
+   Copyright (C) 1998-2003 Gilles Vollant
+             (C) 2003 Justin Fletcher
+
+   This file is under the same license as the Unzip tool it is distributed
+   with.
+*/
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "zlib.h"
+#include "ioapi.h"
+
+
+
+voidpf ZCALLBACK fopen_mem_func OF((
+   voidpf opaque,
+   const char* filename,
+   int mode));
+
+uLong ZCALLBACK fread_mem_func OF((
+   voidpf opaque,
+   voidpf stream,
+   void* buf,
+   uLong size));
+
+uLong ZCALLBACK fwrite_mem_func OF((
+   voidpf opaque,
+   voidpf stream,
+   const void* buf,
+   uLong size));
+
+long ZCALLBACK ftell_mem_func OF((
+   voidpf opaque,
+   voidpf stream));
+
+long ZCALLBACK fseek_mem_func OF((
+   voidpf opaque,
+   voidpf stream,
+   uLong offset,
+   int origin));
+
+int ZCALLBACK fclose_mem_func OF((
+   voidpf opaque,
+   voidpf stream));
+
+int ZCALLBACK ferror_mem_func OF((
+   voidpf opaque,
+   voidpf stream));
+
+
+typedef struct ourmemory_s {
+  char *base; /* Base of the region of memory we're using */
+  uLong size; /* Size of the region of memory we're using */
+  uLong limit; /* Furthest we've written */
+  uLong cur_offset; /* Current offset in the area */
+} ourmemory_t;
+
+voidpf ZCALLBACK fopen_mem_func (opaque, filename, mode)
+   voidpf opaque;
+   const char* filename;
+   int mode;
+{
+    ourmemory_t *mem = malloc(sizeof(*mem));
+    if (mem==NULL)
+      return NULL; /* Can't allocate space, so failed */
+
+    /* Filenames are specified in the form :
+     *    <hex base of zip file>+<hex size of zip file>
+     * This may not work where memory addresses are longer than the
+     * size of an int and therefore may need addressing for 64bit
+     * architectures
+     */
+    if (sscanf(filename,"%x+%x",&mem->base,&mem->size)!=2)
+      return NULL;
+
+    if (mode & ZLIB_FILEFUNC_MODE_CREATE)
+      mem->limit=0; /* When writing we start with 0 bytes written */
+    else
+      mem->limit=mem->size;
+
+    mem->cur_offset = 0;
+
+    return mem;
+}
+
+
+uLong ZCALLBACK fread_mem_func (opaque, stream, buf, size)
+   voidpf opaque;
+   voidpf stream;
+   void* buf;
+   uLong size;
+{
+    ourmemory_t *mem = (ourmemory_t *)stream;
+
+    if (size > mem->size - mem->cur_offset)
+      size = mem->size - mem->cur_offset;
+
+    memcpy(buf, mem->base + mem->cur_offset, size);
+    mem->cur_offset+=size;
+
+    return size;
+}
+
+
+uLong ZCALLBACK fwrite_mem_func (opaque, stream, buf, size)
+   voidpf opaque;
+   voidpf stream;
+   const void* buf;
+   uLong size;
+{
+    ourmemory_t *mem = (ourmemory_t *)stream;
+
+    if (size > mem->size - mem->cur_offset)
+      size = mem->size - mem->cur_offset;
+
+    memcpy(mem->base + mem->cur_offset, buf, size);
+    mem->cur_offset+=size;
+    if (mem->cur_offset > mem->limit)
+      mem->limit = mem->cur_offset;
+
+    return size;
+}
+
+long ZCALLBACK ftell_mem_func (opaque, stream)
+   voidpf opaque;
+   voidpf stream;
+{
+    ourmemory_t *mem = (ourmemory_t *)stream;
+
+    return mem->cur_offset;
+}
+
+long ZCALLBACK fseek_mem_func (opaque, stream, offset, origin)
+   voidpf opaque;
+   voidpf stream;
+   uLong offset;
+   int origin;
+{
+    ourmemory_t *mem = (ourmemory_t *)stream;
+    uLong new_pos;
+    switch (origin)
+    {
+    case ZLIB_FILEFUNC_SEEK_CUR :
+        new_pos = mem->cur_offset + offset;
+        break;
+    case ZLIB_FILEFUNC_SEEK_END :
+        new_pos = mem->limit + offset;
+        break;
+    case ZLIB_FILEFUNC_SEEK_SET :
+        new_pos = offset;
+        break;
+    default: return -1;
+    }
+
+    if (new_pos > mem->size)
+      return 1; /* Failed to seek that far */
+
+    if (new_pos > mem->limit)
+      memset(mem->base + mem->limit, 0, new_pos - mem->limit);
+
+    mem->cur_offset = new_pos;
+    return 0;
+}
+
+int ZCALLBACK fclose_mem_func (opaque, stream)
+   voidpf opaque;
+   voidpf stream;
+{
+    ourmemory_t *mem = (ourmemory_t *)stream;
+
+    /* Note that once we've written to the buffer we don't tell anyone
+       about it here. Probably the opaque handle could be used to inform
+       some other component of how much data was written.
+
+       This, and other aspects of writing through this interface, has
+       not been tested.
+     */
+
+    free (mem);
+    return 0;
+}
+
+int ZCALLBACK ferror_mem_func (opaque, stream)
+   voidpf opaque;
+   voidpf stream;
+{
+    ourmemory_t *mem = (ourmemory_t *)stream;
+    /* We never return errors */
+    return 0;
+}
+
+void fill_memory_filefunc (pzlib_filefunc_def)
+  zlib_filefunc_def* pzlib_filefunc_def;
+{
+    pzlib_filefunc_def->zopen_file = fopen_mem_func;
+    pzlib_filefunc_def->zread_file = fread_mem_func;
+    pzlib_filefunc_def->zwrite_file = fwrite_mem_func;
+    pzlib_filefunc_def->ztell_file = ftell_mem_func;
+    pzlib_filefunc_def->zseek_file = fseek_mem_func;
+    pzlib_filefunc_def->zclose_file = fclose_mem_func;
+    pzlib_filefunc_def->zerror_file = ferror_mem_func;
+    pzlib_filefunc_def->opaque = NULL;
+}

+ 8 - 0
oxygine/src/minizip/ioapi_mem.h

@@ -0,0 +1,8 @@
+#ifndef _ZLIBIOAPI_MEM_H
+#define _ZLIBIOAPI_MEM_H
+#include "unzip.h"
+extern "C" 
+{
+	void fill_memory_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
+}
+#endif

+ 1701 - 0
oxygine/src/minizip/unzip.c

@@ -0,0 +1,1701 @@
+/* unzip.c -- IO for uncompress .zip files using zlib
+   Version 1.01h, December 28th, 2009
+
+   Copyright (C) 1998-2009 Gilles Vollant
+
+   Read unzip.h for more info
+*/
+
+/* Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of
+compatibility with older software. The following is from the original crypt.c. Code
+woven in by Terry Thorsen 1/2003.
+*/
+/*
+  Copyright (c) 1990-2000 Info-ZIP.  All rights reserved.
+
+  See the accompanying file LICENSE, version 2000-Apr-09 or later
+  (the contents of which are also included in zip.h) for terms of use.
+  If, for some reason, all these files are missing, the Info-ZIP license
+  also may be found at:  ftp://ftp.info-zip.org/pub/infozip/license.html
+*/
+/*
+  crypt.c (full version) by Info-ZIP.      Last revised:  [see crypt.h]
+
+  The encryption/decryption parts of this source code (as opposed to the
+  non-echoing password parts) were originally written in Europe.  The
+  whole source package can be freely distributed, including from the USA.
+  (Prior to January 2000, re-export from the US was a violation of US law.)
+ */
+
+/*
+  This encryption code is a direct transcription of the algorithm from
+  Roger Schlafly, described by Phil Katz in the file appnote.txt.  This
+  file (appnote.txt) is distributed with the PKZIP program (even in the
+  version without encryption capabilities).
+ */
+
+#define  NOUNCRYPT
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "zlib.h"
+#include "unzip.h"
+
+#ifdef STDC
+#  include <stddef.h>
+#  include <string.h>
+#  include <stdlib.h>
+#endif
+#ifdef NO_ERRNO_H
+    extern int errno;
+#else
+#   include <errno.h>
+#endif
+
+
+#ifndef local
+#  define local static
+#endif
+/* compile with -Dlocal if your debugger can't find static symbols */
+
+
+#ifndef CASESENSITIVITYDEFAULT_NO
+#  if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES)
+#    define CASESENSITIVITYDEFAULT_NO
+#  endif
+#endif
+
+
+#ifndef UNZ_BUFSIZE
+#define UNZ_BUFSIZE (16384)
+#endif
+
+#ifndef UNZ_MAXFILENAMEINZIP
+#define UNZ_MAXFILENAMEINZIP (256)
+#endif
+
+#ifndef ALLOC
+# define ALLOC(size) (malloc(size))
+#endif
+#ifndef TRYFREE
+# define TRYFREE(p) {if (p) free(p);}
+#endif
+
+#define SIZECENTRALDIRITEM (0x2e)
+#define SIZEZIPLOCALHEADER (0x1e)
+
+
+
+
+const char unz_copyright[] =
+   " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
+
+/* unz_file_info_interntal contain internal info about a file in zipfile*/
+typedef struct unz_file_info_internal_s
+{
+    uLong offset_curfile;/* relative offset of local header 4 bytes */
+} unz_file_info_internal;
+
+
+/* file_in_zip_read_info_s contain internal information about a file in zipfile,
+    when reading and decompress it */
+typedef struct
+{
+    char  *read_buffer;         /* internal buffer for compressed data */
+    z_stream stream;            /* zLib stream structure for inflate */
+#ifdef HAVE_BZIP2
+    bz_stream bstream;          /* bzLib stream structure for bziped */
+#endif
+
+    uLong pos_in_zipfile;       /* position in byte on the zipfile, for fseek*/
+    uLong stream_initialised;   /* flag set if stream structure is initialised*/
+
+    uLong offset_local_extrafield;/* offset of the local extra field */
+    uInt  size_local_extrafield;/* size of the local extra field */
+    uLong pos_local_extrafield;   /* position in the local extra field in read*/
+
+    uLong crc32;                /* crc32 of all data uncompressed */
+    uLong crc32_wait;           /* crc32 we must obtain after decompress all */
+    uLong rest_read_compressed; /* number of byte to be decompressed */
+    uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/
+    zlib_filefunc_def z_filefunc;
+    voidpf filestream;        /* io structore of the zipfile */
+    uLong compression_method;   /* compression method (0==store) */
+    uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
+    int   raw;
+} file_in_zip_read_info_s;
+
+
+/* unz_s contain internal information about the zipfile
+*/
+typedef struct
+{
+    zlib_filefunc_def z_filefunc;
+    voidpf filestream;        /* io structore of the zipfile */
+    unz_global_info gi;       /* public global information */
+    uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
+    uLong num_file;             /* number of the current file in the zipfile*/
+    uLong pos_in_central_dir;   /* pos of the current file in the central dir*/
+    uLong current_file_ok;      /* flag about the usability of the current file*/
+    uLong central_pos;          /* position of the beginning of the central dir*/
+
+    uLong size_central_dir;     /* size of the central directory  */
+    uLong offset_central_dir;   /* offset of start of central directory with
+                                   respect to the starting disk number */
+
+    unz_file_info cur_file_info; /* public info about the current file in zip*/
+    unz_file_info_internal cur_file_info_internal; /* private info about it*/
+    file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current
+                                        file if we are decompressing it */
+    int encrypted;
+#    ifndef NOUNCRYPT
+    unsigned long keys[3];     /* keys defining the pseudo-random sequence */
+    const unsigned long* pcrc_32_tab;
+#    endif
+} unz_s;
+
+
+#ifndef NOUNCRYPT
+#include "crypt.h"
+#endif
+
+/* ===========================================================================
+     Read a byte from a gz_stream; update next_in and avail_in. Return EOF
+   for end of file.
+   IN assertion: the stream s has been sucessfully opened for reading.
+*/
+
+
+local int unzlocal_getByte OF((
+    const zlib_filefunc_def* pzlib_filefunc_def,
+    voidpf filestream,
+    int *pi));
+
+local int unzlocal_getByte(pzlib_filefunc_def,filestream,pi)
+    const zlib_filefunc_def* pzlib_filefunc_def;
+    voidpf filestream;
+    int *pi;
+{
+    unsigned char c;
+    int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1);
+    if (err==1)
+    {
+        *pi = (int)c;
+        return UNZ_OK;
+    }
+    else
+    {
+        if (ZERROR(*pzlib_filefunc_def,filestream))
+            return UNZ_ERRNO;
+        else
+            return UNZ_EOF;
+    }
+}
+
+
+/* ===========================================================================
+   Reads a long in LSB order from the given gz_stream. Sets
+*/
+local int unzlocal_getShort OF((
+    const zlib_filefunc_def* pzlib_filefunc_def,
+    voidpf filestream,
+    uLong *pX));
+
+local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX)
+    const zlib_filefunc_def* pzlib_filefunc_def;
+    voidpf filestream;
+    uLong *pX;
+{
+    uLong x ;
+    int i = 0;
+    int err;
+
+    err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
+    x = (uLong)i;
+
+    if (err==UNZ_OK)
+        err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
+    x += ((uLong)i)<<8;
+
+    if (err==UNZ_OK)
+        *pX = x;
+    else
+        *pX = 0;
+    return err;
+}
+
+local int unzlocal_getLong OF((
+    const zlib_filefunc_def* pzlib_filefunc_def,
+    voidpf filestream,
+    uLong *pX));
+
+local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX)
+    const zlib_filefunc_def* pzlib_filefunc_def;
+    voidpf filestream;
+    uLong *pX;
+{
+    uLong x ;
+    int i = 0;
+    int err;
+
+    err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
+    x = (uLong)i;
+
+    if (err==UNZ_OK)
+        err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
+    x += ((uLong)i)<<8;
+
+    if (err==UNZ_OK)
+        err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
+    x += ((uLong)i)<<16;
+
+    if (err==UNZ_OK)
+        err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
+    x += ((uLong)i)<<24;
+
+    if (err==UNZ_OK)
+        *pX = x;
+    else
+        *pX = 0;
+    return err;
+}
+
+
+/* My own strcmpi / strcasecmp */
+local int strcmpcasenosensitive_internal (fileName1,fileName2)
+    const char* fileName1;
+    const char* fileName2;
+{
+    for (;;)
+    {
+        char c1=*(fileName1++);
+        char c2=*(fileName2++);
+        if ((c1>='a') && (c1<='z'))
+            c1 -= 0x20;
+        if ((c2>='a') && (c2<='z'))
+            c2 -= 0x20;
+        if (c1=='\0')
+            return ((c2=='\0') ? 0 : -1);
+        if (c2=='\0')
+            return 1;
+        if (c1<c2)
+            return -1;
+        if (c1>c2)
+            return 1;
+    }
+}
+
+
+#ifdef  CASESENSITIVITYDEFAULT_NO
+#define CASESENSITIVITYDEFAULTVALUE 2
+#else
+#define CASESENSITIVITYDEFAULTVALUE 1
+#endif
+
+#ifndef STRCMPCASENOSENTIVEFUNCTION
+#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
+#endif
+
+/*
+   Compare two filename (fileName1,fileName2).
+   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
+   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
+                                                                or strcasecmp)
+   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
+        (like 1 on Unix, 2 on Windows)
+
+*/
+extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity)
+    const char* fileName1;
+    const char* fileName2;
+    int iCaseSensitivity;
+{
+    if (iCaseSensitivity==0)
+        iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
+
+    if (iCaseSensitivity==1)
+        return strcmp(fileName1,fileName2);
+
+    return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
+}
+
+#ifndef BUFREADCOMMENT
+#define BUFREADCOMMENT (0x400)
+#endif
+
+/*
+  Locate the Central directory of a zipfile (at the end, just before
+    the global comment)
+*/
+local uLong unzlocal_SearchCentralDir OF((
+    const zlib_filefunc_def* pzlib_filefunc_def,
+    voidpf filestream));
+
+local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream)
+    const zlib_filefunc_def* pzlib_filefunc_def;
+    voidpf filestream;
+{
+    unsigned char* buf;
+    uLong uSizeFile;
+    uLong uBackRead;
+    uLong uMaxBack=0xffff; /* maximum size of global comment */
+    uLong uPosFound=0;
+
+    if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
+        return 0;
+
+
+    uSizeFile = ZTELL(*pzlib_filefunc_def,filestream);
+
+    if (uMaxBack>uSizeFile)
+        uMaxBack = uSizeFile;
+
+    buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
+    if (buf==NULL)
+        return 0;
+
+    uBackRead = 4;
+    while (uBackRead<uMaxBack)
+    {
+        uLong uReadSize,uReadPos ;
+        int i;
+        if (uBackRead+BUFREADCOMMENT>uMaxBack)
+            uBackRead = uMaxBack;
+        else
+            uBackRead+=BUFREADCOMMENT;
+        uReadPos = uSizeFile-uBackRead ;
+
+        uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
+                     (BUFREADCOMMENT+4) : (uSizeFile-uReadPos);
+        if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
+            break;
+
+        if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
+            break;
+
+        for (i=(int)uReadSize-3; (i--)>0;)
+            if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
+                ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
+            {
+                uPosFound = uReadPos+i;
+                break;
+            }
+
+        if (uPosFound!=0)
+            break;
+    }
+    TRYFREE(buf);
+    return uPosFound;
+}
+
+/*
+  Open a Zip file. path contain the full pathname (by example,
+     on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer
+     "zlib/zlib114.zip".
+     If the zipfile cannot be opened (file doesn't exist or in not valid), the
+       return value is NULL.
+     Else, the return value is a unzFile Handle, usable with other function
+       of this unzip package.
+*/
+extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def)
+    const char *path;
+    zlib_filefunc_def* pzlib_filefunc_def;
+{
+    unz_s us;
+    unz_s *s;
+    uLong central_pos,uL;
+
+    uLong number_disk;          /* number of the current dist, used for
+                                   spaning ZIP, unsupported, always 0*/
+    uLong number_disk_with_CD;  /* number the the disk with central dir, used
+                                   for spaning ZIP, unsupported, always 0*/
+    uLong number_entry_CD;      /* total number of entries in
+                                   the central dir
+                                   (same than number_entry on nospan) */
+
+    int err=UNZ_OK;
+
+    if (unz_copyright[0]!=' ')
+        return NULL;
+
+    if (pzlib_filefunc_def==NULL)
+        fill_fopen_filefunc(&us.z_filefunc);
+    else
+        us.z_filefunc = *pzlib_filefunc_def;
+
+    us.filestream= (*(us.z_filefunc.zopen_file))(us.z_filefunc.opaque,
+                                                 path,
+                                                 ZLIB_FILEFUNC_MODE_READ |
+                                                 ZLIB_FILEFUNC_MODE_EXISTING);
+    if (us.filestream==NULL)
+        return NULL;
+
+    central_pos = unzlocal_SearchCentralDir(&us.z_filefunc,us.filestream);
+    if (central_pos==0)
+        err=UNZ_ERRNO;
+
+    if (ZSEEK(us.z_filefunc, us.filestream,
+                                      central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
+        err=UNZ_ERRNO;
+
+    /* the signature, already checked */
+    if (unzlocal_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
+        err=UNZ_ERRNO;
+
+    /* number of this disk */
+    if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
+        err=UNZ_ERRNO;
+
+    /* number of the disk with the start of the central directory */
+    if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
+        err=UNZ_ERRNO;
+
+    /* total number of entries in the central dir on this disk */
+    if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK)
+        err=UNZ_ERRNO;
+
+    /* total number of entries in the central dir */
+    if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if ((number_entry_CD!=us.gi.number_entry) ||
+        (number_disk_with_CD!=0) ||
+        (number_disk!=0))
+        err=UNZ_BADZIPFILE;
+
+    /* size of the central directory */
+    if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK)
+        err=UNZ_ERRNO;
+
+    /* offset of start of central directory with respect to the
+          starting disk number */
+    if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK)
+        err=UNZ_ERRNO;
+
+    /* zipfile comment length */
+    if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
+        (err==UNZ_OK))
+        err=UNZ_BADZIPFILE;
+
+    if (err!=UNZ_OK)
+    {
+        ZCLOSE(us.z_filefunc, us.filestream);
+        return NULL;
+    }
+
+    us.byte_before_the_zipfile = central_pos -
+                            (us.offset_central_dir+us.size_central_dir);
+    us.central_pos = central_pos;
+    us.pfile_in_zip_read = NULL;
+    us.encrypted = 0;
+
+
+    s=(unz_s*)ALLOC(sizeof(unz_s));
+    if (s!=NULL)
+    {
+        *s=us;
+        unzGoToFirstFile((unzFile)s);
+    }
+    return (unzFile)s;
+}
+
+
+extern unzFile ZEXPORT unzOpen (path)
+    const char *path;
+{
+    return unzOpen2(path, NULL);
+}
+
+/*
+  Close a ZipFile opened with unzipOpen.
+  If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
+    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
+  return UNZ_OK if there is no problem. */
+extern int ZEXPORT unzClose (file)
+    unzFile file;
+{
+    unz_s* s;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz_s*)file;
+
+    if (s->pfile_in_zip_read!=NULL)
+        unzCloseCurrentFile(file);
+
+    ZCLOSE(s->z_filefunc, s->filestream);
+    TRYFREE(s);
+    return UNZ_OK;
+}
+
+
+/*
+  Write info about the ZipFile in the *pglobal_info structure.
+  No preparation of the structure is needed
+  return UNZ_OK if there is no problem. */
+extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info)
+    unzFile file;
+    unz_global_info *pglobal_info;
+{
+    unz_s* s;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz_s*)file;
+    *pglobal_info=s->gi;
+    return UNZ_OK;
+}
+
+
+/*
+   Translate date/time from Dos format to tm_unz (readable more easilty)
+*/
+local void unzlocal_DosDateToTmuDate (ulDosDate, ptm)
+    uLong ulDosDate;
+    tm_unz* ptm;
+{
+    uLong uDate;
+    uDate = (uLong)(ulDosDate>>16);
+    ptm->tm_mday = (uInt)(uDate&0x1f) ;
+    ptm->tm_mon =  (uInt)((((uDate)&0x1E0)/0x20)-1) ;
+    ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
+
+    ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
+    ptm->tm_min =  (uInt) ((ulDosDate&0x7E0)/0x20) ;
+    ptm->tm_sec =  (uInt) (2*(ulDosDate&0x1f)) ;
+}
+
+/*
+  Get Info about the current file in the zipfile, with internal only info
+*/
+local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file,
+                                                  unz_file_info *pfile_info,
+                                                  unz_file_info_internal
+                                                  *pfile_info_internal,
+                                                  char *szFileName,
+                                                  uLong fileNameBufferSize,
+                                                  void *extraField,
+                                                  uLong extraFieldBufferSize,
+                                                  char *szComment,
+                                                  uLong commentBufferSize));
+
+local int unzlocal_GetCurrentFileInfoInternal (file,
+                                              pfile_info,
+                                              pfile_info_internal,
+                                              szFileName, fileNameBufferSize,
+                                              extraField, extraFieldBufferSize,
+                                              szComment,  commentBufferSize)
+    unzFile file;
+    unz_file_info *pfile_info;
+    unz_file_info_internal *pfile_info_internal;
+    char *szFileName;
+    uLong fileNameBufferSize;
+    void *extraField;
+    uLong extraFieldBufferSize;
+    char *szComment;
+    uLong commentBufferSize;
+{
+    unz_s* s;
+    unz_file_info file_info;
+    unz_file_info_internal file_info_internal;
+    int err=UNZ_OK;
+    uLong uMagic;
+    long lSeek=0;
+
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz_s*)file;
+    if (ZSEEK(s->z_filefunc, s->filestream,
+              s->pos_in_central_dir+s->byte_before_the_zipfile,
+              ZLIB_FILEFUNC_SEEK_SET)!=0)
+        err=UNZ_ERRNO;
+
+
+    /* we check the magic */
+    if (err==UNZ_OK)
+    {
+        if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
+            err=UNZ_ERRNO;
+        else if (uMagic!=0x02014b50)
+            err=UNZ_BADZIPFILE;
+    }
+
+    if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);
+
+    if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    lSeek+=file_info.size_filename;
+    if ((err==UNZ_OK) && (szFileName!=NULL))
+    {
+        uLong uSizeRead ;
+        if (file_info.size_filename<fileNameBufferSize)
+        {
+            *(szFileName+file_info.size_filename)='\0';
+            uSizeRead = file_info.size_filename;
+        }
+        else
+            uSizeRead = fileNameBufferSize;
+
+        if ((file_info.size_filename>0) && (fileNameBufferSize>0))
+            if (ZREAD(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead)
+                err=UNZ_ERRNO;
+        lSeek -= uSizeRead;
+    }
+
+
+    if ((err==UNZ_OK) && (extraField!=NULL))
+    {
+        uLong uSizeRead ;
+        if (file_info.size_file_extra<extraFieldBufferSize)
+            uSizeRead = file_info.size_file_extra;
+        else
+            uSizeRead = extraFieldBufferSize;
+
+        if (lSeek!=0)
+        {
+            if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
+                lSeek=0;
+            else
+                err=UNZ_ERRNO;
+        }
+
+        if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
+            if (ZREAD(s->z_filefunc, s->filestream,extraField,uSizeRead)!=uSizeRead)
+                err=UNZ_ERRNO;
+        lSeek += file_info.size_file_extra - uSizeRead;
+    }
+    else
+        lSeek+=file_info.size_file_extra;
+
+
+    if ((err==UNZ_OK) && (szComment!=NULL))
+    {
+        uLong uSizeRead ;
+        if (file_info.size_file_comment<commentBufferSize)
+        {
+            *(szComment+file_info.size_file_comment)='\0';
+            uSizeRead = file_info.size_file_comment;
+        }
+        else
+            uSizeRead = commentBufferSize;
+
+        if (lSeek!=0)
+        {
+            if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
+                lSeek=0;
+            else
+                err=UNZ_ERRNO;
+        }
+
+        if ((file_info.size_file_comment>0) && (commentBufferSize>0))
+            if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead)
+                err=UNZ_ERRNO;
+        lSeek+=file_info.size_file_comment - uSizeRead;
+    }
+    else
+        lSeek+=file_info.size_file_comment;
+
+    if ((err==UNZ_OK) && (pfile_info!=NULL))
+        *pfile_info=file_info;
+
+    if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
+        *pfile_info_internal=file_info_internal;
+
+    return err;
+}
+
+
+
+/*
+  Write info about the ZipFile in the *pglobal_info structure.
+  No preparation of the structure is needed
+  return UNZ_OK if there is no problem.
+*/
+extern int ZEXPORT unzGetCurrentFileInfo (file,
+                                          pfile_info,
+                                          szFileName, fileNameBufferSize,
+                                          extraField, extraFieldBufferSize,
+                                          szComment,  commentBufferSize)
+    unzFile file;
+    unz_file_info *pfile_info;
+    char *szFileName;
+    uLong fileNameBufferSize;
+    void *extraField;
+    uLong extraFieldBufferSize;
+    char *szComment;
+    uLong commentBufferSize;
+{
+    return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,
+                                                szFileName,fileNameBufferSize,
+                                                extraField,extraFieldBufferSize,
+                                                szComment,commentBufferSize);
+}
+
+/*
+  Set the current file of the zipfile to the first file.
+  return UNZ_OK if there is no problem
+*/
+extern int ZEXPORT unzGoToFirstFile (file)
+    unzFile file;
+{
+    int err=UNZ_OK;
+    unz_s* s;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz_s*)file;
+    s->pos_in_central_dir=s->offset_central_dir;
+    s->num_file=0;
+    err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
+                                             &s->cur_file_info_internal,
+                                             NULL,0,NULL,0,NULL,0);
+    s->current_file_ok = (err == UNZ_OK);
+    return err;
+}
+
+/*
+  Set the current file of the zipfile to the next file.
+  return UNZ_OK if there is no problem
+  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
+*/
+extern int ZEXPORT unzGoToNextFile (file)
+    unzFile file;
+{
+    unz_s* s;
+    int err;
+
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz_s*)file;
+    if (!s->current_file_ok)
+        return UNZ_END_OF_LIST_OF_FILE;
+    if (s->gi.number_entry != 0xffff)    /* 2^16 files overflow hack */
+      if (s->num_file+1==s->gi.number_entry)
+        return UNZ_END_OF_LIST_OF_FILE;
+
+    s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
+            s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
+    s->num_file++;
+    err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
+                                               &s->cur_file_info_internal,
+                                               NULL,0,NULL,0,NULL,0);
+    s->current_file_ok = (err == UNZ_OK);
+    return err;
+}
+
+
+/*
+  Try locate the file szFileName in the zipfile.
+  For the iCaseSensitivity signification, see unzipStringFileNameCompare
+
+  return value :
+  UNZ_OK if the file is found. It becomes the current file.
+  UNZ_END_OF_LIST_OF_FILE if the file is not found
+*/
+extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity)
+    unzFile file;
+    const char *szFileName;
+    int iCaseSensitivity;
+{
+    unz_s* s;
+    int err;
+
+    /* We remember the 'current' position in the file so that we can jump
+     * back there if we fail.
+     */
+    unz_file_info cur_file_infoSaved;
+    unz_file_info_internal cur_file_info_internalSaved;
+    uLong num_fileSaved;
+    uLong pos_in_central_dirSaved;
+
+
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+
+    if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
+        return UNZ_PARAMERROR;
+
+    s=(unz_s*)file;
+    if (!s->current_file_ok)
+        return UNZ_END_OF_LIST_OF_FILE;
+
+    /* Save the current state */
+    num_fileSaved = s->num_file;
+    pos_in_central_dirSaved = s->pos_in_central_dir;
+    cur_file_infoSaved = s->cur_file_info;
+    cur_file_info_internalSaved = s->cur_file_info_internal;
+
+    err = unzGoToFirstFile(file);
+
+    while (err == UNZ_OK)
+    {
+        char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
+        err = unzGetCurrentFileInfo(file,NULL,
+                                    szCurrentFileName,sizeof(szCurrentFileName)-1,
+                                    NULL,0,NULL,0);
+        if (err == UNZ_OK)
+        {
+            if (unzStringFileNameCompare(szCurrentFileName,
+                                            szFileName,iCaseSensitivity)==0)
+                return UNZ_OK;
+            err = unzGoToNextFile(file);
+        }
+    }
+
+    /* We failed, so restore the state of the 'current file' to where we
+     * were.
+     */
+    s->num_file = num_fileSaved ;
+    s->pos_in_central_dir = pos_in_central_dirSaved ;
+    s->cur_file_info = cur_file_infoSaved;
+    s->cur_file_info_internal = cur_file_info_internalSaved;
+    return err;
+}
+
+
+/*
+///////////////////////////////////////////
+// Contributed by Ryan Haksi (mailto://[email protected])
+// I need random access
+//
+// Further optimization could be realized by adding an ability
+// to cache the directory in memory. The goal being a single
+// comprehensive file read to put the file I need in a memory.
+*/
+
+/*
+typedef struct unz_file_pos_s
+{
+    uLong pos_in_zip_directory;   // offset in file
+    uLong num_of_file;            // # of file
+} unz_file_pos;
+*/
+
+extern int ZEXPORT unzGetFilePos(file, file_pos)
+    unzFile file;
+    unz_file_pos* file_pos;
+{
+    unz_s* s;
+
+    if (file==NULL || file_pos==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz_s*)file;
+    if (!s->current_file_ok)
+        return UNZ_END_OF_LIST_OF_FILE;
+
+    file_pos->pos_in_zip_directory  = s->pos_in_central_dir;
+    file_pos->num_of_file           = s->num_file;
+
+    return UNZ_OK;
+}
+
+extern int ZEXPORT unzGoToFilePos(file, file_pos)
+    unzFile file;
+    unz_file_pos* file_pos;
+{
+    unz_s* s;
+    int err;
+
+    if (file==NULL || file_pos==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz_s*)file;
+
+    /* jump to the right spot */
+    s->pos_in_central_dir = file_pos->pos_in_zip_directory;
+    s->num_file           = file_pos->num_of_file;
+
+    /* set the current file */
+    err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
+                                               &s->cur_file_info_internal,
+                                               NULL,0,NULL,0,NULL,0);
+    /* return results */
+    s->current_file_ok = (err == UNZ_OK);
+    return err;
+}
+
+/*
+// Unzip Helper Functions - should be here?
+///////////////////////////////////////////
+*/
+
+/*
+  Read the local header of the current zipfile
+  Check the coherency of the local header and info in the end of central
+        directory about this file
+  store in *piSizeVar the size of extra info in local header
+        (filename and size of extra field data)
+*/
+local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
+                                                    poffset_local_extrafield,
+                                                    psize_local_extrafield)
+    unz_s* s;
+    uInt* piSizeVar;
+    uLong *poffset_local_extrafield;
+    uInt  *psize_local_extrafield;
+{
+    uLong uMagic,uData,uFlags;
+    uLong size_filename;
+    uLong size_extra_field;
+    int err=UNZ_OK;
+
+    *piSizeVar = 0;
+    *poffset_local_extrafield = 0;
+    *psize_local_extrafield = 0;
+
+    if (ZSEEK(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile +
+                                s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0)
+        return UNZ_ERRNO;
+
+
+    if (err==UNZ_OK)
+    {
+        if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
+            err=UNZ_ERRNO;
+        else if (uMagic!=0x04034b50)
+            err=UNZ_BADZIPFILE;
+    }
+
+    if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
+        err=UNZ_ERRNO;
+/*
+    else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
+        err=UNZ_BADZIPFILE;
+*/
+    if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)
+        err=UNZ_ERRNO;
+
+    if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
+        err=UNZ_ERRNO;
+    else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
+        err=UNZ_BADZIPFILE;
+
+    if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
+/* #ifdef HAVE_BZIP2 */
+                         (s->cur_file_info.compression_method!=Z_BZIP2ED) &&
+/* #endif */
+                         (s->cur_file_info.compression_method!=Z_DEFLATED))
+        err=UNZ_BADZIPFILE;
+
+    if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */
+        err=UNZ_ERRNO;
+
+    if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */
+        err=UNZ_ERRNO;
+    else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) &&
+                              ((uFlags & 8)==0))
+        err=UNZ_BADZIPFILE;
+
+    if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */
+        err=UNZ_ERRNO;
+    else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) &&
+                              ((uFlags & 8)==0))
+        err=UNZ_BADZIPFILE;
+
+    if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */
+        err=UNZ_ERRNO;
+    else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) &&
+                              ((uFlags & 8)==0))
+        err=UNZ_BADZIPFILE;
+
+
+    if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK)
+        err=UNZ_ERRNO;
+    else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
+        err=UNZ_BADZIPFILE;
+
+    *piSizeVar += (uInt)size_filename;
+
+    if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK)
+        err=UNZ_ERRNO;
+    *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
+                                    SIZEZIPLOCALHEADER + size_filename;
+    *psize_local_extrafield = (uInt)size_extra_field;
+
+    *piSizeVar += (uInt)size_extra_field;
+
+    return err;
+}
+
+/*
+  Open for reading data the current file in the zipfile.
+  If there is no error and the file is opened, the return value is UNZ_OK.
+*/
+extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
+    unzFile file;
+    int* method;
+    int* level;
+    int raw;
+    const char* password;
+{
+    int err=UNZ_OK;
+    uInt iSizeVar;
+    unz_s* s;
+    file_in_zip_read_info_s* pfile_in_zip_read_info;
+    uLong offset_local_extrafield;  /* offset of the local extra field */
+    uInt  size_local_extrafield;    /* size of the local extra field */
+#    ifndef NOUNCRYPT
+    char source[12];
+#    else
+    if (password != NULL)
+        return UNZ_PARAMERROR;
+#    endif
+
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz_s*)file;
+    if (!s->current_file_ok)
+        return UNZ_PARAMERROR;
+
+    if (s->pfile_in_zip_read != NULL)
+        unzCloseCurrentFile(file);
+
+    if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar,
+                &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
+        return UNZ_BADZIPFILE;
+
+    pfile_in_zip_read_info = (file_in_zip_read_info_s*)
+                                        ALLOC(sizeof(file_in_zip_read_info_s));
+    if (pfile_in_zip_read_info==NULL)
+        return UNZ_INTERNALERROR;
+
+    pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);
+    pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
+    pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
+    pfile_in_zip_read_info->pos_local_extrafield=0;
+    pfile_in_zip_read_info->raw=raw;
+
+    if (pfile_in_zip_read_info->read_buffer==NULL)
+    {
+        TRYFREE(pfile_in_zip_read_info);
+        return UNZ_INTERNALERROR;
+    }
+
+    pfile_in_zip_read_info->stream_initialised=0;
+
+    if (method!=NULL)
+        *method = (int)s->cur_file_info.compression_method;
+
+    if (level!=NULL)
+    {
+        *level = 6;
+        switch (s->cur_file_info.flag & 0x06)
+        {
+          case 6 : *level = 1; break;
+          case 4 : *level = 2; break;
+          case 2 : *level = 9; break;
+        }
+    }
+
+    if ((s->cur_file_info.compression_method!=0) &&
+/* #ifdef HAVE_BZIP2 */
+        (s->cur_file_info.compression_method!=Z_BZIP2ED) &&
+/* #endif */
+        (s->cur_file_info.compression_method!=Z_DEFLATED))
+        err=UNZ_BADZIPFILE;
+
+    pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
+    pfile_in_zip_read_info->crc32=0;
+    pfile_in_zip_read_info->compression_method =
+            s->cur_file_info.compression_method;
+    pfile_in_zip_read_info->filestream=s->filestream;
+    pfile_in_zip_read_info->z_filefunc=s->z_filefunc;
+    pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
+
+    pfile_in_zip_read_info->stream.total_out = 0;
+
+    if ((s->cur_file_info.compression_method==Z_BZIP2ED) &&
+        (!raw))
+    {
+#ifdef HAVE_BZIP2
+      pfile_in_zip_read_info->bstream.bzalloc = (void *(*) (void *, int, int))0;
+      pfile_in_zip_read_info->bstream.bzfree = (free_func)0;
+      pfile_in_zip_read_info->bstream.opaque = (voidpf)0;
+      pfile_in_zip_read_info->bstream.state = (voidpf)0;
+
+      pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
+      pfile_in_zip_read_info->stream.zfree = (free_func)0;
+      pfile_in_zip_read_info->stream.opaque = (voidpf)0;
+      pfile_in_zip_read_info->stream.next_in = (voidpf)0;
+      pfile_in_zip_read_info->stream.avail_in = 0;
+
+      err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0);
+      if (err == Z_OK)
+        pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED;
+      else
+      {
+        TRYFREE(pfile_in_zip_read_info);
+        return err;
+      }
+#else
+      pfile_in_zip_read_info->raw=1;
+#endif
+    }
+    else
+    if ((s->cur_file_info.compression_method==Z_DEFLATED) &&
+        (!raw))
+    {
+      pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
+      pfile_in_zip_read_info->stream.zfree = (free_func)0;
+      pfile_in_zip_read_info->stream.opaque = (voidpf)0;
+      pfile_in_zip_read_info->stream.next_in = (voidpf)0;
+      pfile_in_zip_read_info->stream.avail_in = 0;
+
+      err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
+      if (err == Z_OK)
+        pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
+      else
+      {
+        TRYFREE(pfile_in_zip_read_info);
+        return err;
+      }
+        /* windowBits is passed < 0 to tell that there is no zlib header.
+         * Note that in this case inflate *requires* an extra "dummy" byte
+         * after the compressed stream in order to complete decompression and
+         * return Z_STREAM_END.
+         * In unzip, i don't wait absolutely Z_STREAM_END because I known the
+         * size of both compressed and uncompressed data
+         */
+    }
+    pfile_in_zip_read_info->rest_read_compressed =
+            s->cur_file_info.compressed_size ;
+    pfile_in_zip_read_info->rest_read_uncompressed =
+            s->cur_file_info.uncompressed_size ;
+
+
+    pfile_in_zip_read_info->pos_in_zipfile =
+            s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
+              iSizeVar;
+
+    pfile_in_zip_read_info->stream.avail_in = (uInt)0;
+
+    s->pfile_in_zip_read = pfile_in_zip_read_info;
+
+    s->encrypted = 0;
+
+#    ifndef NOUNCRYPT
+    if (password != NULL)
+    {
+        int i;
+        s->pcrc_32_tab = get_crc_table();
+        init_keys(password,s->keys,s->pcrc_32_tab);
+        if (ZSEEK(s->z_filefunc, s->filestream,
+                  s->pfile_in_zip_read->pos_in_zipfile +
+                     s->pfile_in_zip_read->byte_before_the_zipfile,
+                  SEEK_SET)!=0)
+            return UNZ_INTERNALERROR;
+        if(ZREAD(s->z_filefunc, s->filestream,source, 12)<12)
+            return UNZ_INTERNALERROR;
+
+        for (i = 0; i<12; i++)
+            zdecode(s->keys,s->pcrc_32_tab,source[i]);
+
+        s->pfile_in_zip_read->pos_in_zipfile+=12;
+        s->encrypted=1;
+    }
+#    endif
+
+
+    return UNZ_OK;
+}
+
+extern int ZEXPORT unzOpenCurrentFile (file)
+    unzFile file;
+{
+    return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
+}
+
+extern int ZEXPORT unzOpenCurrentFilePassword (file, password)
+    unzFile file;
+    const char* password;
+{
+    return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
+}
+
+extern int ZEXPORT unzOpenCurrentFile2 (file,method,level,raw)
+    unzFile file;
+    int* method;
+    int* level;
+    int raw;
+{
+    return unzOpenCurrentFile3(file, method, level, raw, NULL);
+}
+
+/*
+  Read bytes from the current file.
+  buf contain buffer where data must be copied
+  len the size of buf.
+
+  return the number of byte copied if somes bytes are copied
+  return 0 if the end of file was reached
+  return <0 with error code if there is an error
+    (UNZ_ERRNO for IO error, or zLib error for uncompress error)
+*/
+extern int ZEXPORT unzReadCurrentFile  (file, buf, len)
+    unzFile file;
+    voidp buf;
+    unsigned len;
+{
+    int err=UNZ_OK;
+    uInt iRead = 0;
+    unz_s* s;
+    file_in_zip_read_info_s* pfile_in_zip_read_info;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz_s*)file;
+    pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+    if (pfile_in_zip_read_info==NULL)
+        return UNZ_PARAMERROR;
+
+
+    if ((pfile_in_zip_read_info->read_buffer == NULL))
+        return UNZ_END_OF_LIST_OF_FILE;
+    if (len==0)
+        return 0;
+
+    pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
+
+    pfile_in_zip_read_info->stream.avail_out = (uInt)len;
+
+    if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
+        (!(pfile_in_zip_read_info->raw)))
+        pfile_in_zip_read_info->stream.avail_out =
+            (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
+
+    if ((len>pfile_in_zip_read_info->rest_read_compressed+
+           pfile_in_zip_read_info->stream.avail_in) &&
+         (pfile_in_zip_read_info->raw))
+        pfile_in_zip_read_info->stream.avail_out =
+            (uInt)pfile_in_zip_read_info->rest_read_compressed+
+            pfile_in_zip_read_info->stream.avail_in;
+
+    while (pfile_in_zip_read_info->stream.avail_out>0)
+    {
+        if ((pfile_in_zip_read_info->stream.avail_in==0) &&
+            (pfile_in_zip_read_info->rest_read_compressed>0))
+        {
+            uInt uReadThis = UNZ_BUFSIZE;
+            if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
+                uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
+            if (uReadThis == 0)
+                return UNZ_EOF;
+            if (ZSEEK(pfile_in_zip_read_info->z_filefunc,
+                      pfile_in_zip_read_info->filestream,
+                      pfile_in_zip_read_info->pos_in_zipfile +
+                         pfile_in_zip_read_info->byte_before_the_zipfile,
+                         ZLIB_FILEFUNC_SEEK_SET)!=0)
+                return UNZ_ERRNO;
+            if (ZREAD(pfile_in_zip_read_info->z_filefunc,
+                      pfile_in_zip_read_info->filestream,
+                      pfile_in_zip_read_info->read_buffer,
+                      uReadThis)!=uReadThis)
+                return UNZ_ERRNO;
+
+
+#            ifndef NOUNCRYPT
+            if(s->encrypted)
+            {
+                uInt i;
+                for(i=0;i<uReadThis;i++)
+                  pfile_in_zip_read_info->read_buffer[i] =
+                      zdecode(s->keys,s->pcrc_32_tab,
+                              pfile_in_zip_read_info->read_buffer[i]);
+            }
+#            endif
+
+
+            pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
+
+            pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
+
+            pfile_in_zip_read_info->stream.next_in =
+                (Bytef*)pfile_in_zip_read_info->read_buffer;
+            pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
+        }
+
+        if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw))
+        {
+            uInt uDoCopy,i ;
+
+            if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
+                (pfile_in_zip_read_info->rest_read_compressed == 0))
+                return (iRead==0) ? UNZ_EOF : iRead;
+
+            if (pfile_in_zip_read_info->stream.avail_out <
+                            pfile_in_zip_read_info->stream.avail_in)
+                uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
+            else
+                uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
+
+            for (i=0;i<uDoCopy;i++)
+                *(pfile_in_zip_read_info->stream.next_out+i) =
+                        *(pfile_in_zip_read_info->stream.next_in+i);
+
+            pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
+                                pfile_in_zip_read_info->stream.next_out,
+                                uDoCopy);
+            pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
+            pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
+            pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
+            pfile_in_zip_read_info->stream.next_out += uDoCopy;
+            pfile_in_zip_read_info->stream.next_in += uDoCopy;
+            pfile_in_zip_read_info->stream.total_out += uDoCopy;
+            iRead += uDoCopy;
+        }
+        else
+        if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED)
+        {
+#ifdef HAVE_BZIP2
+            uLong uTotalOutBefore,uTotalOutAfter;
+            const Bytef *bufBefore;
+            uLong uOutThis;
+
+            pfile_in_zip_read_info->bstream.next_in        = pfile_in_zip_read_info->stream.next_in;
+            pfile_in_zip_read_info->bstream.avail_in       = pfile_in_zip_read_info->stream.avail_in;
+            pfile_in_zip_read_info->bstream.total_in_lo32  = pfile_in_zip_read_info->stream.total_in;
+            pfile_in_zip_read_info->bstream.total_in_hi32  = 0;
+            pfile_in_zip_read_info->bstream.next_out       = pfile_in_zip_read_info->stream.next_out;
+            pfile_in_zip_read_info->bstream.avail_out      = pfile_in_zip_read_info->stream.avail_out;
+            pfile_in_zip_read_info->bstream.total_out_lo32 = pfile_in_zip_read_info->stream.total_out;
+            pfile_in_zip_read_info->bstream.total_out_hi32 = 0;
+
+            uTotalOutBefore = pfile_in_zip_read_info->bstream.total_out_lo32;
+            bufBefore = pfile_in_zip_read_info->bstream.next_out;
+
+            err=BZ2_bzDecompress(&pfile_in_zip_read_info->bstream);
+
+            uTotalOutAfter = pfile_in_zip_read_info->bstream.total_out_lo32;
+            uOutThis = uTotalOutAfter-uTotalOutBefore;
+
+            pfile_in_zip_read_info->crc32 =
+                crc32(pfile_in_zip_read_info->crc32,bufBefore,
+                        (uInt)(uOutThis));
+
+            pfile_in_zip_read_info->rest_read_uncompressed -=
+                uOutThis;
+
+            iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
+
+            pfile_in_zip_read_info->stream.next_in   = pfile_in_zip_read_info->bstream.next_in;
+            pfile_in_zip_read_info->stream.avail_in  = pfile_in_zip_read_info->bstream.avail_in;
+            pfile_in_zip_read_info->stream.total_in  = pfile_in_zip_read_info->bstream.total_in_lo32;
+            pfile_in_zip_read_info->stream.next_out  = pfile_in_zip_read_info->bstream.next_out;
+            pfile_in_zip_read_info->stream.avail_out = pfile_in_zip_read_info->bstream.avail_out;
+            pfile_in_zip_read_info->stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32;
+
+            if (err==BZ_STREAM_END)
+                return (iRead==0) ? UNZ_EOF : iRead;
+            if (err!=BZ_OK)
+                break;
+#endif
+        }
+        else
+        {
+            uLong uTotalOutBefore,uTotalOutAfter;
+            const Bytef *bufBefore;
+            uLong uOutThis;
+            int flush=Z_SYNC_FLUSH;
+
+            uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
+            bufBefore = pfile_in_zip_read_info->stream.next_out;
+
+            /*
+            if ((pfile_in_zip_read_info->rest_read_uncompressed ==
+                     pfile_in_zip_read_info->stream.avail_out) &&
+                (pfile_in_zip_read_info->rest_read_compressed == 0))
+                flush = Z_FINISH;
+            */
+            err=inflate(&pfile_in_zip_read_info->stream,flush);
+
+            if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL))
+              err = Z_DATA_ERROR;
+
+            uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
+            uOutThis = uTotalOutAfter-uTotalOutBefore;
+
+            pfile_in_zip_read_info->crc32 =
+                crc32(pfile_in_zip_read_info->crc32,bufBefore,
+                        (uInt)(uOutThis));
+
+            pfile_in_zip_read_info->rest_read_uncompressed -=
+                uOutThis;
+
+            iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
+
+            if (err==Z_STREAM_END)
+                return (iRead==0) ? UNZ_EOF : iRead;
+            if (err!=Z_OK)
+                break;
+        }
+    }
+
+    if (err==Z_OK)
+        return iRead;
+    return err;
+}
+
+
+/*
+  Give the current position in uncompressed data
+*/
+extern z_off_t ZEXPORT unztell (file)
+    unzFile file;
+{
+    unz_s* s;
+    file_in_zip_read_info_s* pfile_in_zip_read_info;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz_s*)file;
+    pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+    if (pfile_in_zip_read_info==NULL)
+        return UNZ_PARAMERROR;
+
+    return (z_off_t)pfile_in_zip_read_info->stream.total_out;
+}
+
+
+/*
+  return 1 if the end of file was reached, 0 elsewhere
+*/
+extern int ZEXPORT unzeof (file)
+    unzFile file;
+{
+    unz_s* s;
+    file_in_zip_read_info_s* pfile_in_zip_read_info;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz_s*)file;
+    pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+    if (pfile_in_zip_read_info==NULL)
+        return UNZ_PARAMERROR;
+
+    if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
+        return 1;
+    else
+        return 0;
+}
+
+
+
+/*
+  Read extra field from the current file (opened by unzOpenCurrentFile)
+  This is the local-header version of the extra field (sometimes, there is
+    more info in the local-header version than in the central-header)
+
+  if buf==NULL, it return the size of the local extra field that can be read
+
+  if buf!=NULL, len is the size of the buffer, the extra header is copied in
+    buf.
+  the return value is the number of bytes copied in buf, or (if <0)
+    the error code
+*/
+extern int ZEXPORT unzGetLocalExtrafield (file,buf,len)
+    unzFile file;
+    voidp buf;
+    unsigned len;
+{
+    unz_s* s;
+    file_in_zip_read_info_s* pfile_in_zip_read_info;
+    uInt read_now;
+    uLong size_to_read;
+
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz_s*)file;
+    pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+    if (pfile_in_zip_read_info==NULL)
+        return UNZ_PARAMERROR;
+
+    size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
+                pfile_in_zip_read_info->pos_local_extrafield);
+
+    if (buf==NULL)
+        return (int)size_to_read;
+
+    if (len>size_to_read)
+        read_now = (uInt)size_to_read;
+    else
+        read_now = (uInt)len ;
+
+    if (read_now==0)
+        return 0;
+
+    if (ZSEEK(pfile_in_zip_read_info->z_filefunc,
+              pfile_in_zip_read_info->filestream,
+              pfile_in_zip_read_info->offset_local_extrafield +
+              pfile_in_zip_read_info->pos_local_extrafield,
+              ZLIB_FILEFUNC_SEEK_SET)!=0)
+        return UNZ_ERRNO;
+
+    if (ZREAD(pfile_in_zip_read_info->z_filefunc,
+              pfile_in_zip_read_info->filestream,
+              buf,read_now)!=read_now)
+        return UNZ_ERRNO;
+
+    return (int)read_now;
+}
+
+/*
+  Close the file in zip opened with unzipOpenCurrentFile
+  Return UNZ_CRCERROR if all the file was read but the CRC is not good
+*/
+extern int ZEXPORT unzCloseCurrentFile (file)
+    unzFile file;
+{
+    int err=UNZ_OK;
+
+    unz_s* s;
+    file_in_zip_read_info_s* pfile_in_zip_read_info;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz_s*)file;
+    pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+    if (pfile_in_zip_read_info==NULL)
+        return UNZ_PARAMERROR;
+
+
+    if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) &&
+        (!pfile_in_zip_read_info->raw))
+    {
+        if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
+            err=UNZ_CRCERROR;
+    }
+
+
+    TRYFREE(pfile_in_zip_read_info->read_buffer);
+    pfile_in_zip_read_info->read_buffer = NULL;
+    if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED)
+        inflateEnd(&pfile_in_zip_read_info->stream);
+#ifdef HAVE_BZIP2
+    else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED)
+        BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream);
+#endif
+
+    pfile_in_zip_read_info->stream_initialised = 0;
+    TRYFREE(pfile_in_zip_read_info);
+
+    s->pfile_in_zip_read=NULL;
+
+    return err;
+}
+
+
+/*
+  Get the global comment string of the ZipFile, in the szComment buffer.
+  uSizeBuf is the size of the szComment buffer.
+  return the number of byte copied or an error code <0
+*/
+extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf)
+    unzFile file;
+    char *szComment;
+    uLong uSizeBuf;
+{
+    unz_s* s;
+    uLong uReadThis ;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz_s*)file;
+
+    uReadThis = uSizeBuf;
+    if (uReadThis>s->gi.size_comment)
+        uReadThis = s->gi.size_comment;
+
+    if (ZSEEK(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0)
+        return UNZ_ERRNO;
+
+    if (uReadThis>0)
+    {
+      *szComment='\0';
+      if (ZREAD(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis)
+        return UNZ_ERRNO;
+    }
+
+    if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
+        *(szComment+s->gi.size_comment)='\0';
+    return (int)uReadThis;
+}
+
+/* Additions by RX '2004 */
+extern uLong ZEXPORT unzGetOffset (file)
+    unzFile file;
+{
+    unz_s* s;
+
+    if (file==NULL)
+          return 0;
+    s=(unz_s*)file;
+    if (!s->current_file_ok)
+      return 0;
+    if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff)
+      if (s->num_file==s->gi.number_entry)
+         return 0;
+    return s->pos_in_central_dir;
+}
+
+extern int ZEXPORT unzSetOffset (file, pos)
+        unzFile file;
+        uLong pos;
+{
+    unz_s* s;
+    int err;
+
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz_s*)file;
+
+    s->pos_in_central_dir = pos;
+    s->num_file = s->gi.number_entry;      /* hack */
+    err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
+                                              &s->cur_file_info_internal,
+                                              NULL,0,NULL,0,NULL,0);
+    s->current_file_ok = (err == UNZ_OK);
+    return err;
+}

+ 360 - 0
oxygine/src/minizip/unzip.h

@@ -0,0 +1,360 @@
+/* unzip.h -- IO for uncompress .zip files using zlib
+   Version 1.01h, December 28th, 2009
+
+   Copyright (C) 1998-2009 Gilles Vollant
+
+   This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
+     WinZip, InfoZip tools and compatible.
+
+   Multi volume ZipFile (span) are not supported.
+   Encryption compatible with pkzip 2.04g only supported
+   Old compressions used by old PKZip 1.x are not supported
+
+
+   I WAIT FEEDBACK at mail [email protected]
+   Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
+
+   Condition of use and distribution are the same than zlib :
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+
+
+*/
+
+/* for more info about .ZIP format, see
+      http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
+      http://www.info-zip.org/pub/infozip/doc/
+   PkWare has also a specification at :
+      ftp://ftp.pkware.com/probdesc.zip
+*/
+
+#ifndef _unz_H
+#define _unz_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _ZLIB_H
+#include "zlib.h"
+#endif
+
+#ifndef _ZLIBIOAPI_H
+#include "ioapi.h"
+#endif
+
+#ifdef HAVE_BZIP2
+#include "bzlib.h"
+#endif
+
+#define Z_BZIP2ED 12
+
+#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
+/* like the STRICT of WIN32, we define a pointer that cannot be converted
+    from (void*) without cast */
+typedef struct TagunzFile__ { int unused; } unzFile__;
+typedef unzFile__ *unzFile;
+#else
+typedef voidp unzFile;
+#endif
+
+
+#define UNZ_OK                          (0)
+#define UNZ_END_OF_LIST_OF_FILE         (-100)
+#define UNZ_ERRNO                       (Z_ERRNO)
+#define UNZ_EOF                         (0)
+#define UNZ_PARAMERROR                  (-102)
+#define UNZ_BADZIPFILE                  (-103)
+#define UNZ_INTERNALERROR               (-104)
+#define UNZ_CRCERROR                    (-105)
+
+/* tm_unz contain date/time info */
+typedef struct tm_unz_s
+{
+    uInt tm_sec;            /* seconds after the minute - [0,59] */
+    uInt tm_min;            /* minutes after the hour - [0,59] */
+    uInt tm_hour;           /* hours since midnight - [0,23] */
+    uInt tm_mday;           /* day of the month - [1,31] */
+    uInt tm_mon;            /* months since January - [0,11] */
+    uInt tm_year;           /* years - [1980..2044] */
+} tm_unz;
+
+/* unz_global_info structure contain global data about the ZIPfile
+   These data comes from the end of central dir */
+typedef struct unz_global_info_s
+{
+    uLong number_entry;         /* total number of entries in
+                       the central dir on this disk */
+    uLong size_comment;         /* size of the global comment of the zipfile */
+} unz_global_info;
+
+
+/* unz_file_info contain information about a file in the zipfile */
+typedef struct unz_file_info_s
+{
+    uLong version;              /* version made by                 2 bytes */
+    uLong version_needed;       /* version needed to extract       2 bytes */
+    uLong flag;                 /* general purpose bit flag        2 bytes */
+    uLong compression_method;   /* compression method              2 bytes */
+    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */
+    uLong crc;                  /* crc-32                          4 bytes */
+    uLong compressed_size;      /* compressed size                 4 bytes */
+    uLong uncompressed_size;    /* uncompressed size               4 bytes */
+    uLong size_filename;        /* filename length                 2 bytes */
+    uLong size_file_extra;      /* extra field length              2 bytes */
+    uLong size_file_comment;    /* file comment length             2 bytes */
+
+    uLong disk_num_start;       /* disk number start               2 bytes */
+    uLong internal_fa;          /* internal file attributes        2 bytes */
+    uLong external_fa;          /* external file attributes        4 bytes */
+
+    tm_unz tmu_date;
+} unz_file_info;
+
+extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
+                                                 const char* fileName2,
+                                                 int iCaseSensitivity));
+/*
+   Compare two filename (fileName1,fileName2).
+   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
+   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
+                                or strcasecmp)
+   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
+    (like 1 on Unix, 2 on Windows)
+*/
+
+
+extern unzFile ZEXPORT unzOpen OF((const char *path));
+/*
+  Open a Zip file. path contain the full pathname (by example,
+     on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
+     "zlib/zlib113.zip".
+     If the zipfile cannot be opened (file don't exist or in not valid), the
+       return value is NULL.
+     Else, the return value is a unzFile Handle, usable with other function
+       of this unzip package.
+*/
+
+extern unzFile ZEXPORT unzOpen2 OF((const char *path,
+                                    zlib_filefunc_def* pzlib_filefunc_def));
+/*
+   Open a Zip file, like unzOpen, but provide a set of file low level API
+      for read/write the zip file (see ioapi.h)
+*/
+
+extern int ZEXPORT unzClose OF((unzFile file));
+/*
+  Close a ZipFile opened with unzipOpen.
+  If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
+    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
+  return UNZ_OK if there is no problem. */
+
+extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
+                                        unz_global_info *pglobal_info));
+/*
+  Write info about the ZipFile in the *pglobal_info structure.
+  No preparation of the structure is needed
+  return UNZ_OK if there is no problem. */
+
+
+extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
+                                           char *szComment,
+                                           uLong uSizeBuf));
+/*
+  Get the global comment string of the ZipFile, in the szComment buffer.
+  uSizeBuf is the size of the szComment buffer.
+  return the number of byte copied or an error code <0
+*/
+
+
+/***************************************************************************/
+/* Unzip package allow you browse the directory of the zipfile */
+
+extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
+/*
+  Set the current file of the zipfile to the first file.
+  return UNZ_OK if there is no problem
+*/
+
+extern int ZEXPORT unzGoToNextFile OF((unzFile file));
+/*
+  Set the current file of the zipfile to the next file.
+  return UNZ_OK if there is no problem
+  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
+*/
+
+extern int ZEXPORT unzLocateFile OF((unzFile file,
+                     const char *szFileName,
+                     int iCaseSensitivity));
+/*
+  Try locate the file szFileName in the zipfile.
+  For the iCaseSensitivity signification, see unzStringFileNameCompare
+
+  return value :
+  UNZ_OK if the file is found. It becomes the current file.
+  UNZ_END_OF_LIST_OF_FILE if the file is not found
+*/
+
+
+/* ****************************************** */
+/* Ryan supplied functions */
+/* unz_file_info contain information about a file in the zipfile */
+typedef struct unz_file_pos_s
+{
+    uLong pos_in_zip_directory;   /* offset in zip file directory */
+    uLong num_of_file;            /* # of file */
+} unz_file_pos;
+
+extern int ZEXPORT unzGetFilePos(
+    unzFile file,
+    unz_file_pos* file_pos);
+
+extern int ZEXPORT unzGoToFilePos(
+    unzFile file,
+    unz_file_pos* file_pos);
+
+/* ****************************************** */
+
+extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
+                         unz_file_info *pfile_info,
+                         char *szFileName,
+                         uLong fileNameBufferSize,
+                         void *extraField,
+                         uLong extraFieldBufferSize,
+                         char *szComment,
+                         uLong commentBufferSize));
+/*
+  Get Info about the current file
+  if pfile_info!=NULL, the *pfile_info structure will contain somes info about
+        the current file
+  if szFileName!=NULL, the filemane string will be copied in szFileName
+            (fileNameBufferSize is the size of the buffer)
+  if extraField!=NULL, the extra field information will be copied in extraField
+            (extraFieldBufferSize is the size of the buffer).
+            This is the Central-header version of the extra field
+  if szComment!=NULL, the comment string of the file will be copied in szComment
+            (commentBufferSize is the size of the buffer)
+*/
+
+/***************************************************************************/
+/* for reading the content of the current zipfile, you can open it, read data
+   from it, and close it (you can close it before reading all the file)
+   */
+
+extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
+/*
+  Open for reading data the current file in the zipfile.
+  If there is no error, the return value is UNZ_OK.
+*/
+
+extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
+                                                  const char* password));
+/*
+  Open for reading data the current file in the zipfile.
+  password is a crypting password
+  If there is no error, the return value is UNZ_OK.
+*/
+
+extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
+                                           int* method,
+                                           int* level,
+                                           int raw));
+/*
+  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
+    if raw==1
+  *method will receive method of compression, *level will receive level of
+     compression
+  note : you can set level parameter as NULL (if you did not want known level,
+         but you CANNOT set method parameter as NULL
+*/
+
+extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
+                                           int* method,
+                                           int* level,
+                                           int raw,
+                                           const char* password));
+/*
+  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
+    if raw==1
+  *method will receive method of compression, *level will receive level of
+     compression
+  note : you can set level parameter as NULL (if you did not want known level,
+         but you CANNOT set method parameter as NULL
+*/
+
+
+extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
+/*
+  Close the file in zip opened with unzOpenCurrentFile
+  Return UNZ_CRCERROR if all the file was read but the CRC is not good
+*/
+
+extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
+                      voidp buf,
+                      unsigned len));
+/*
+  Read bytes from the current file (opened by unzOpenCurrentFile)
+  buf contain buffer where data must be copied
+  len the size of buf.
+
+  return the number of byte copied if somes bytes are copied
+  return 0 if the end of file was reached
+  return <0 with error code if there is an error
+    (UNZ_ERRNO for IO error, or zLib error for uncompress error)
+*/
+
+extern z_off_t ZEXPORT unztell OF((unzFile file));
+/*
+  Give the current position in uncompressed data
+*/
+
+extern int ZEXPORT unzeof OF((unzFile file));
+/*
+  return 1 if the end of file was reached, 0 elsewhere
+*/
+
+extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
+                                             voidp buf,
+                                             unsigned len));
+/*
+  Read extra field from the current file (opened by unzOpenCurrentFile)
+  This is the local-header version of the extra field (sometimes, there is
+    more info in the local-header version than in the central-header)
+
+  if buf==NULL, it return the size of the local extra field
+
+  if buf!=NULL, len is the size of the buffer, the extra header is copied in
+    buf.
+  the return value is the number of bytes copied in buf, or (if <0)
+    the error code
+*/
+
+/***************************************************************************/
+
+/* Get the current file offset */
+extern uLong ZEXPORT unzGetOffset (unzFile file);
+
+/* Set the current file offset */
+extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _unz_H */

+ 2 - 2
oxygine/src/oxygine-framework.h

@@ -40,11 +40,11 @@
 
 //core/
 #include "core/coroutines.h"
-#include "core/files_io.h"
+#include "core/file.h"
 #include "core/ImageData.h"
 #include "core/ImageDataOperations.h"
 #include "core/intrusive_ptr.h"
-#include "core/logging.h"
+#include "core/log.h"
 #include "core/Mem2Native.h"
 #include "core/memory_pool.h"
 #include "core/Mutex.h"

+ 1 - 1
oxygine/src/res/ResAtlas.h

@@ -1,5 +1,5 @@
 #pragma once
-#include "core/files_io.h"
+#include "core/file.h"
 #include <map>
 #include "Resource.h"
 #include "ResAnim.h"

+ 1 - 1
oxygine/src/res/ResBuffer.h

@@ -1,6 +1,6 @@
 #pragma once
 #include "Resource.h"
-#include "core/files_io.h"
+#include "core/file.h"
 #include <vector>
 
 namespace oxygine

+ 1 - 1
oxygine/src/res/ResFontBM.cpp

@@ -5,7 +5,7 @@
 #include "MemoryTexture.h"
 #include "core/NativeTexture.h"
 #include "core/VideoDriver.h"
-#include "core/files_io.h"
+#include "core/file.h"
 #include "CreateResourceContext.h"
 #include "utils/stringUtils.h"
 #include "core/Mem2Native.h"

+ 1 - 1
oxygine/src/res/ResStarlingAtlas.cpp

@@ -1,6 +1,6 @@
 #include "ResStarlingAtlas.h"
 #include "CreateResourceContext.h"
-#include "core/files_io.h"
+#include "core/file.h"
 #include "ResAnim.h"
 #include "Resources.h"
 #include "core/VideoDriver.h"

+ 5 - 5
oxygine/src/res/Resources.cpp

@@ -1,10 +1,10 @@
 #include "Resources.h"
 #include "Resource.h"
 #include "pugixml/pugixml.hpp"
-#include "core/files_io.h"
+#include "core/file.h"
 #include <algorithm>
 
-#include "core/logging.h"
+#include "core/log.h"
 
 #include <stdio.h>
 #include "CreateResourceContext.h"
@@ -13,7 +13,7 @@
 #include "ResFont.h"
 #include "utils/stringUtils.h"
 
-#include "core/logging.h"
+#include "core/log.h"
 #include <stdarg.h>
 
 //#define FS_LOG(...) log::warning(__VA_ARGS__)
@@ -160,8 +160,7 @@ namespace oxygine
 		string ox = prebuilt_folder + "meta.xml";
 		const char *ox_file = ox.c_str();
 
-			
-
+		
 		FS_LOG("step2");
 
 		if (file::exists(ox_file))
@@ -176,6 +175,7 @@ namespace oxygine
 			OX_ASSERT(fb.data.size()  && "can't find xml file");
 			return;
 		}
+
 		pugi::xml_document *doc = new pugi::xml_document();
 		_docs.push_back(doc);
 

+ 1 - 1
oxygine/src/utils/ImageUtils.h

@@ -1,5 +1,5 @@
 #pragma once
-#include "core/files_io.h"
+#include "core/file.h"
 namespace oxygine
 {
 	class ImageData;

+ 1 - 1
oxygine/src/utils/stringUtils.cpp

@@ -2,7 +2,7 @@
 #include <string.h>
 #include <algorithm>
 #include "core/oxygine.h"
-#include "core/logging.h"
+#include "core/log.h"
 
 #ifdef __S3E__
 #include "IwUTF8.h"

+ 47 - 17
oxygine/system_data/build.py

@@ -1,24 +1,54 @@
 import os
 import shutil
+import zipfile
+
 shutil.rmtree("data", True)
 shutil.copytree("original", "data")
 os.system("..\\..\\tools\\process_xml2.py -x system\\res.xml --src_data data --dest_data data\\system")
 shutil.rmtree("data/system/anims/")
 
-d = ["..\\..\\examples\\Demo\\data",
-     "..\\..\\examples\\DemoBox2D\\data",
-     "..\\..\\examples\\GameTemplate\\data",
-     "..\\..\\examples\\HelloWorld\\data",
-     "..\\..\\examples\\Match3\\data",
-     "..\\..\\..\\oxygine-movieclip\\examples\\example1\\data",
-     "..\\..\\..\\oxygine-frame\\examples\\example1\\data",
-     "..\\..\\..\\oxygine-frame\\examples\\example2\\data",
-     "..\\..\\..\\oxygine-sound\\test\\data",
-     "..\\..\\..\\oxygine-pipeline\\example\\game\\runnable\\data",
-     ]
-for dest in d:
-    s = dest + "\\system"
-    shutil.rmtree(s, True)
-    print s
-    shutil.copytree("data\\system", s)
-    
+def recursive_zip(zipf, directory, folder = ""):
+    for item in os.listdir(directory):
+        if os.path.isfile(os.path.join(directory, item)):
+            zipf.write(os.path.join(directory, item), folder + os.sep + item)
+        elif os.path.isdir(os.path.join(directory, item)):
+            recursive_zip(zipf, os.path.join(directory, item), folder + os.sep + item)
+      
+      
+import cStringIO
+data = cStringIO.StringIO()
+with zipfile.ZipFile(data, "w", zipfile.ZIP_DEFLATED) as zp:
+    recursive_zip(zp, "data")
+
+fmtH = """
+#pragma once
+#ifndef %(MODULE)s_DATA
+#define %(MODULE)s_DATA
+extern unsigned int %(module)s_size;
+extern const unsigned char %(module)s_data[];
+#endif
+"""
+
+fmtCPP = """
+#include "%(HEADER)s"
+unsigned int %(module)s_size = %(SIZE)d;
+const unsigned char %(module)s_data[] = {%(DATA)s};
+
+"""
+
+def gen(module, data):
+    st = ",".join("0x{:02x}".format(ord(c)) for c in data)
+    MODULE = module.upper()
+    SIZE = len(data)
+    DATA = st
+    args = {"MODULE":MODULE, "SIZE":SIZE, "DATA":DATA, "module":module, "HEADER":module + "_data.h"}
+    return (fmtH % args, fmtCPP % args, )
+    
+rs = gen("system", data.getvalue())
+with open("../../oxygine/src/core/system_data.h", "w") as fh:
+    fh.write(rs[0])
+with open("../../oxygine/src/core/system_data.cpp", "w") as fh:
+    fh.write(rs[1])
+
+with open("system.zip", "wb") as zp:
+    zp.write(data.getvalue())

+ 1 - 1
readme.SDL2

@@ -15,7 +15,7 @@ How to build and run Oxygine on Windows with CMake and Visual Studio (tested wit
 - goto examples/Demo
 - create folder "build"
 - generate solution with cmake (from oxygine-framework/examples/demo/build folder):
-  cmake .. -G"Visual Studio 10"
+  cmake ..
 - open solution. select project Demo and set it "as startup project"
 - set working directory for Demo project to: 
    oxygine-framework\examples\Demo\data\

Some files were not shown because too many files changed in this diff