diff --git a/.editorconfig b/.editorconfig
index e19bc342..ce053634 100755
--- a/.editorconfig
+++ b/.editorconfig
@@ -30,26 +30,8 @@ indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true
-[src/{endian,rapidjson}/**]
-indent_size = unset
-indent_style = unset
-insert_final_newline = unset
-trim_trailing_whitespace = unset
-
[src/Game/{fsa,stlastar}.h]
indent_size = unset
indent_style = unset
insert_final_newline = unset
trim_trailing_whitespace = unset
-
-[src/SFML/dr_wav.h]
-indent_size = unset
-indent_style = unset
-insert_final_newline = unset
-trim_trailing_whitespace = unset
-
-[src/Utils/{iterator_tpl.h,re.*}]
-indent_size = unset
-indent_style = unset
-insert_final_newline = unset
-trim_trailing_whitespace = unset
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 6b095db1..f1cda04d 100755
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -72,7 +72,7 @@ jobs:
- name: MSBuild DGEngine
run: |
vcpkg integrate install
- msbuild Project.vcxproj /p:Configuration="Release Static NoMovie" /p:Platform=Win32
+ msbuild DGEngine.vcxproj /p:Configuration="Release Static NoMovie" /p:Platform=Win32
- name: Create DGEngine.zip
run: 7z a DGEngine.zip "./Release Static NoMovie/*.exe" LICENSE.* README.* main.json gamefiles*
diff --git a/.gitignore b/.gitignore
index d8d22709..c4819301 100755
--- a/.gitignore
+++ b/.gitignore
@@ -28,6 +28,7 @@
/Debug NoDiabloFormatSupport
/Debug NoMovie
/DGEngine
+/DGEngine.dir
/DIABDAT
/DIABDAT.*
/FFMPEG*
@@ -47,7 +48,6 @@
/obj
/PhysicsFS
/portable
-/Project.dir
/Release
/Release NoMovie
/Release Static
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0b61edbb..bad5c713 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.12.4 FATAL_ERROR)
project(DGEngine)
+add_subdirectory(DGEngine.core)
+
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
add_definitions(-Wall -stdlib=libc++)
@@ -16,8 +18,6 @@ endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules")
-option(MOVIE_SUPPORT "Enable Movie support" TRUE)
-option(FALLBACK_TO_LOWERCASE "Enable falling back to all lowercase names if file is not found" TRUE)
option(DIABLO_FORMAT_SUPPORT "Enable Diablo 1-2 file format support" TRUE)
option(MPQ_SUPPORT "Enable physfs MPQ support" TRUE)
option(INTERNAL_STORMLIB "Use internal StormLib for MPQ support" TRUE)
@@ -30,148 +30,31 @@ endif()
find_package(PhysFS REQUIRED)
find_package(SFML 2.5 REQUIRED system window graphics network audio)
-include_directories(./src)
+include_directories(src)
set(SOURCE_FILES
src/Main.cpp
- src/Alignment.h
- src/Anchor.h
- src/Animation.cpp
- src/Animation.h
- src/AnimationInfo.h
- src/AnimationType.h
- src/AudioSource.h
- src/BaseAnimation.cpp
- src/BaseAnimation.h
- src/BindableText.cpp
- src/BindableText.h
- src/BindingFlags.h
- src/BitmapButton.cpp
- src/BitmapButton.h
- src/BitmapFont.cpp
- src/BitmapFont.h
- src/BitmapText.cpp
- src/BitmapText.h
- src/BlendMode.h
- src/Button.cpp
- src/Button.h
- src/CachedImagePack.cpp
- src/CachedImagePack.h
- src/Circle.cpp
- src/Circle.h
- src/CmdLineUtils.cpp
- src/CmdLineUtils.h
- src/DrawableText.h
+ src/CmdLineUtils2.cpp
+ src/CmdLineUtils2.h
src/Dun.cpp
src/Dun.h
- src/Event.cpp
- src/Event.h
- src/EventManager.h
- src/FadeInOut.cpp
- src/FadeInOut.h
- src/FileBytes.h
- src/FileUtils.cpp
- src/FileUtils.h
- src/Font.h
- src/Formula.cpp
- src/Formula.h
- src/Formulas.h
- src/FreeTypeFont.h
- src/Game.cpp
- src/Game.h
- src/GameConstants.h
- src/GameUtils.cpp
- src/GameUtils.h
- src/GameUtilsGame.cpp
- src/GameUtilsGame.h
- src/IfCondition.cpp
- src/IfCondition.h
- src/IgnoreResource.h
- src/Image.cpp
- src/Image.h
- src/ImageUtils.cpp
- src/ImageUtils.h
- src/InputEvent.cpp
- src/InputEvent.h
- src/InputText.cpp
- src/InputText.h
- src/LoadingScreen.cpp
- src/LoadingScreen.h
- src/Menu.cpp
- src/Menu.h
- src/Movie2.cpp
- src/Movie2.h
- src/Palette.cpp
- src/Palette.h
- src/Panel.cpp
- src/Panel.h
+ src/Game2.cpp
+ src/Game2.h
+ src/GameUtils2.cpp
+ src/GameUtils2.h
src/Pcx.cpp
src/Pcx.h
- src/Queryable.h
- src/Rectangle.cpp
- src/Rectangle.h
- src/ResourceManager.cpp
- src/ResourceManager.h
- src/Scrollable.cpp
- src/Scrollable.h
- src/Shader.h
- src/ShaderManager.cpp
- src/ShaderManager.h
- src/Shape.cpp
- src/Shape.h
- src/StreamReader.h
- src/StringButton.cpp
- src/StringButton.h
- src/StringText.cpp
- src/StringText.h
- src/Text.cpp
- src/Text.h
- src/TextureInfo.h
- src/TextUtils.cpp
- src/TextUtils.h
+ src/RegisterHooks.cpp
+ src/RegisterHooks.h
+ src/ShaderManager2.cpp
+ src/ShaderManager2.h
src/TileSet.cpp
src/TileSet.h
- src/UIObject.cpp
- src/UIObject.h
- src/Variable.cpp
- src/Variable.h
- src/VarOrPredicate.h
- src/Actions/ActAction.h
- src/Actions/ActAnimation.h
- src/Actions/ActAudio.h
- src/Actions/ActButton.h
- src/Actions/ActCondition.h
- src/Actions/ActCursor.h
- src/Actions/ActDrawable.h
- src/Actions/ActEvent.h
- src/Actions/ActFade.h
- src/Actions/ActFocus.h
- src/Actions/ActFont.h
- src/Actions/ActGame.h
- src/Actions/ActImage.h
- src/Actions/ActInputText.h
- src/Actions/ActIO.h
- src/Actions/Action.h
- src/Actions/ActiontList.h
src/Actions/ActItem.h
src/Actions/ActLevel.h
src/Actions/ActLevelObject.h
- src/Actions/ActLoad.h
- src/Actions/ActLoadingScreen.h
- src/Actions/ActMenu.h
- src/Actions/ActMount.h
- src/Actions/ActMovie.h
- src/Actions/ActPalette.h
src/Actions/ActPlayer.h
src/Actions/ActQuest.h
- src/Actions/ActRandom.h
- src/Actions/ActResource.h
- src/Actions/ActScrollable.h
- src/Actions/ActShader.h
- src/Actions/ActSound.h
- src/Actions/ActText.h
- src/Actions/ActVariable.h
- src/Actions/ActVisibility.h
src/Game/Classifier.cpp
src/Game/Classifier.h
src/Game/Classifiers.h
@@ -224,228 +107,70 @@ set(SOURCE_FILES
src/Game/SimpleLevelObjectClass.h
src/Game/Spell.cpp
src/Game/Spell.h
+ src/Game/stlastar.h
src/Game/TextureLevelLayer.cpp
src/Game/TextureLevelLayer.h
src/Game/TilesetLevelLayer.cpp
src/Game/TilesetLevelLayer.h
- src/Game/stlastar.h
src/Game/Save/SaveItem.cpp
src/Game/Save/SaveItem.h
src/Game/Save/SaveLevel.cpp
src/Game/Save/SaveLevel.h
src/Game/Save/SavePlayer.cpp
src/Game/Save/SavePlayer.h
- src/Game/Save/SaveProperties.h
src/Game/Save/SaveSimpleLevelObject.cpp
src/Game/Save/SaveSimpleLevelObject.h
- src/Game/Save/SaveUtils.cpp
- src/Game/Save/SaveUtils.h
- src/ImageContainers/ImageContainer.h
- src/ImageContainers/SimpleImageContainer.cpp
- src/ImageContainers/SimpleImageContainer.h
- src/Json/JsonParser.h
- src/Json/JsonUtils.cpp
- src/Json/JsonUtils.h
- src/Parser/ParseAction.cpp
- src/Parser/ParseAction.h
- src/Parser/ParseActionGame.cpp
- src/Parser/ParseActionGame.h
- src/Parser/ParseAnimation.cpp
- src/Parser/ParseAnimation.h
- src/Parser/ParseAudio.cpp
- src/Parser/ParseAudio.h
- src/Parser/ParseAudioCommon.cpp
- src/Parser/ParseAudioCommon.h
- src/Parser/ParseButton.cpp
- src/Parser/ParseButton.h
- src/Parser/ParseCircle.cpp
- src/Parser/ParseCircle.h
- src/Parser/ParseCondition.cpp
- src/Parser/ParseCondition.h
- src/Parser/ParseCursor.cpp
- src/Parser/ParseCursor.h
- src/Parser/ParseEvent.cpp
- src/Parser/ParseEvent.h
- src/Parser/ParseFile.cpp
- src/Parser/ParseFile.h
- src/Parser/ParseFileBytes.cpp
- src/Parser/ParseFileBytes.h
- src/Parser/ParseFileGame.cpp
- src/Parser/ParseFileGame.h
- src/Parser/ParseFont.cpp
- src/Parser/ParseFont.h
- src/Parser/ParseIcon.cpp
- src/Parser/ParseIcon.h
- src/Parser/ParseImage.cpp
- src/Parser/ParseImage.h
- src/Parser/ParseImageContainer.cpp
- src/Parser/ParseImageContainer.h
- src/Parser/ParseInputEvent.cpp
- src/Parser/ParseInputEvent.h
- src/Parser/ParseInputText.cpp
- src/Parser/ParseInputText.h
- src/Parser/ParseLoadingScreen.cpp
- src/Parser/ParseLoadingScreen.h
- src/Parser/ParseMenu.cpp
- src/Parser/ParseMenu.h
- src/Parser/ParseMenuButton.cpp
- src/Parser/ParseMenuButton.h
- src/Parser/ParseMountFile.cpp
- src/Parser/ParseMountFile.h
- src/Parser/ParseMovie.cpp
- src/Parser/ParseMovie.h
- src/Parser/ParsePalette.cpp
- src/Parser/ParsePalette.h
- src/Parser/ParsePanel.cpp
- src/Parser/ParsePanel.h
- src/Parser/ParsePredicate.cpp
- src/Parser/ParsePredicate.h
- src/Parser/ParsePredicateGame.cpp
- src/Parser/ParsePredicateGame.h
- src/Parser/Parser.cpp
- src/Parser/Parser.h
- src/Parser/ParseRectangle.cpp
- src/Parser/ParseRectangle.h
- src/Parser/ParserProperties.h
- src/Parser/ParseScrollable.cpp
- src/Parser/ParseScrollable.h
- src/Parser/ParseShader.cpp
- src/Parser/ParseShader.h
- src/Parser/ParseShape.cpp
- src/Parser/ParseShape.h
- src/Parser/ParseSound.cpp
- src/Parser/ParseSound.h
- src/Parser/ParseText.cpp
- src/Parser/ParseText.h
- src/Parser/ParseTexture.cpp
- src/Parser/ParseTexture.h
- src/Parser/ParseTexturePack.cpp
- src/Parser/ParseTexturePack.h
- src/Parser/ParseVariable.cpp
- src/Parser/ParseVariable.h
- src/Parser/Game/ParseClassifier.cpp
- src/Parser/Game/ParseClassifier.h
- src/Parser/Game/ParseItem.cpp
- src/Parser/Game/ParseItem.h
- src/Parser/Game/ParseItemClass.cpp
- src/Parser/Game/ParseItemClass.h
- src/Parser/Game/ParseLevel.cpp
- src/Parser/Game/ParseLevel.h
- src/Parser/Game/ParseLevelObject.cpp
- src/Parser/Game/ParseLevelObject.h
- src/Parser/Game/ParseLevelObjectClass.cpp
- src/Parser/Game/ParseLevelObjectClass.h
- src/Parser/Game/ParsePlayer.cpp
- src/Parser/Game/ParsePlayer.h
- src/Parser/Game/ParsePlayerClass.cpp
- src/Parser/Game/ParsePlayerClass.h
- src/Parser/Game/ParseQuest.cpp
- src/Parser/Game/ParseQuest.h
- src/Parser/Game/ParseSpell.cpp
- src/Parser/Game/ParseSpell.h
- src/Parser/Utils/ParseUtils.cpp
- src/Parser/Utils/ParseUtils.h
+ src/Parser/ParseAction2.cpp
+ src/Parser/ParseAction2.h
+ src/Parser/ParseClassifier.cpp
+ src/Parser/ParseClassifier.h
+ src/Parser/ParseFile2.cpp
+ src/Parser/ParseFile2.h
+ src/Parser/ParseItem.cpp
+ src/Parser/ParseItem.h
+ src/Parser/ParseItemClass.cpp
+ src/Parser/ParseItemClass.h
+ src/Parser/ParseLevel.cpp
+ src/Parser/ParseLevel.h
+ src/Parser/ParseLevelObject.cpp
+ src/Parser/ParseLevelObject.h
+ src/Parser/ParseLevelObjectClass.cpp
+ src/Parser/ParseLevelObjectClass.h
+ src/Parser/ParsePanel2.cpp
+ src/Parser/ParsePanel2.h
+ src/Parser/ParsePlayer.cpp
+ src/Parser/ParsePlayer.h
+ src/Parser/ParsePlayerClass.cpp
+ src/Parser/ParsePlayerClass.h
+ src/Parser/ParsePredicate2.cpp
+ src/Parser/ParsePredicate2.h
+ src/Parser/ParseQuest.cpp
+ src/Parser/ParseQuest.h
+ src/Parser/ParseSpell.cpp
+ src/Parser/ParseSpell.h
+ src/Parser/ParseTexture2.cpp
+ src/Parser/ParseTexture2.h
+ src/Parser/ParseTexturePack2.cpp
+ src/Parser/ParseTexturePack2.h
src/Parser/Utils/ParseUtilsGameKey.cpp
src/Parser/Utils/ParseUtilsGameKey.h
src/Parser/Utils/ParseUtilsGameVal.cpp
src/Parser/Utils/ParseUtilsGameVal.h
- src/Parser/Utils/ParseUtilsIdx.cpp
- src/Parser/Utils/ParseUtilsIdx.h
- src/Parser/Utils/ParseUtilsKey.cpp
- src/Parser/Utils/ParseUtilsKey.h
- src/Parser/Utils/ParseUtilsVal.cpp
- src/Parser/Utils/ParseUtilsVal.h
- src/Predicates/Predicate.h
- src/Predicates/PredIO.h
src/Predicates/PredItem.h
src/Predicates/PredLevelObject.h
src/Predicates/PredPlayer.h
- src/SFML/CompositeSprite.cpp
- src/SFML/CompositeSprite.h
- src/SFML/dr_wav.h
src/SFML/GradientCircle.cpp
src/SFML/GradientCircle.h
- src/SFML/Image2.h
- src/SFML/Music2.cpp
- src/SFML/Music2.h
- src/SFML/MusicLoops.cpp
- src/SFML/MusicLoops.h
- src/SFML/PhysFSStream.cpp
- src/SFML/PhysFSStream.h
- src/SFML/SFMLUtils.cpp
- src/SFML/SFMLUtils.h
- src/SFML/Sprite2.cpp
- src/SFML/Sprite2.h
- src/SFML/Text2.cpp
- src/SFML/Text2.h
- src/SFML/VertexArray2.cpp
- src/SFML/VertexArray2.h
- src/SFML/VertexShape.cpp
- src/SFML/VertexShape.h
- src/SFML/View2.cpp
- src/SFML/View2.h
- src/SFML/Wave2.cpp
- src/SFML/Wave2.h
- src/TexturePacks/BitmapFontTexturePack.cpp
- src/TexturePacks/BitmapFontTexturePack.h
- src/TexturePacks/CachedTexturePack.cpp
- src/TexturePacks/CachedTexturePack.h
- src/TexturePacks/CompositeTexturePack.cpp
- src/TexturePacks/CompositeTexturePack.h
- src/TexturePacks/IndexedTexturePack.cpp
- src/TexturePacks/IndexedTexturePack.h
- src/TexturePacks/RectTexturePack.cpp
- src/TexturePacks/RectTexturePack.h
- src/TexturePacks/SimpleTexturePack.cpp
- src/TexturePacks/SimpleTexturePack.h
- src/TexturePacks/StackedTexturePack.cpp
- src/TexturePacks/StackedTexturePack.h
- src/TexturePacks/TexturePack.cpp
- src/TexturePacks/TexturePack.h
- src/Utils/EasedValue.h
- src/Utils/EasingFunctions.h
- src/Utils/ElapsedTime.h
- src/Utils/FixedArray.h
- src/Utils/FixedMap.h
- src/Utils/Helper2D.h
- src/Utils/iterator_tpl.h
- src/Utils/LRUCache.h
- src/Utils/Number.h
- src/Utils/NumberVector.h
- src/Utils/PairXY.h
- src/Utils/re.c
- src/Utils/re.h
- src/Utils/Regex.h
- src/Utils/ReverseIterable.h
- src/Utils/UnorderedStringMap.h
- src/Utils/Utils.cpp
- src/Utils/Utils.h
- src/Utils/Vector2D.h
+ src/TexturePacks/CachedTexturePack2.cpp
+ src/TexturePacks/CachedTexturePack2.h
+ src/TexturePacks/CompositeTexturePack2.cpp
+ src/TexturePacks/CompositeTexturePack2.h
+ src/TexturePacks/IndexedTexturePack2.cpp
+ src/TexturePacks/IndexedTexturePack2.h
+ src/TexturePacks/StackedTexturePack2.cpp
+ src/TexturePacks/StackedTexturePack2.h
)
-if(FFmpeg_FOUND)
- SET(SOURCE_FILES ${SOURCE_FILES}
- src/sfeMovie/AudioStream.cpp
- src/sfeMovie/AudioStream.hpp
- src/sfeMovie/Demuxer.cpp
- src/sfeMovie/Demuxer.hpp
- src/sfeMovie/Movie.cpp
- src/sfeMovie/Movie.hpp
- src/sfeMovie/MovieImpl.cpp
- src/sfeMovie/MovieImpl.hpp
- src/sfeMovie/Stream.cpp
- src/sfeMovie/Stream.hpp
- src/sfeMovie/StreamSelection.hpp
- src/sfeMovie/Timer.cpp
- src/sfeMovie/Timer.hpp
- src/sfeMovie/TimerPriorities.hpp
- src/sfeMovie/VideoStream.cpp
- src/sfeMovie/VideoStream.hpp
- )
-else()
- add_definitions(-DDGENGINE_MOVIE_STUB)
-endif()
-
if(DIABLO_FORMAT_SUPPORT)
add_definitions(-DDGENGINE_DIABLO_FORMAT_SUPPORT)
@@ -466,6 +191,8 @@ if(DIABLO_FORMAT_SUPPORT)
src/ImageContainers/DCCImageContainer.h
src/ImageContainers/DT1ImageContainer.cpp
src/ImageContainers/DT1ImageContainer.h
+ src/Parser/ParseImageContainer2.cpp
+ src/Parser/ParseImageContainer2.h
)
if(MPQ_SUPPORT)
@@ -505,11 +232,17 @@ if(DIABLO_FORMAT_SUPPORT)
endif()
endif()
-if(FALLBACK_TO_LOWERCASE)
- add_definitions(-DDGENGINE_FALLBACK_TO_LOWERCASE)
+add_executable(${PROJECT_NAME} ${SOURCE_FILES})
+
+if(FFmpeg_FOUND)
+ include_directories(${FFmpeg_INCLUDES})
+ target_link_libraries(${PROJECT_NAME} ${FFmpeg_LIBRARIES})
endif()
-add_executable(${PROJECT_NAME} ${SOURCE_FILES})
+include_directories(${PHYSFS_INCLUDE_DIRS} ${SFML_INCLUDE_DIR})
+target_link_libraries(${PROJECT_NAME} ${PHYSFS_LIBRARY} ${SFML_LIBRARIES})
+
+target_link_libraries(${PROJECT_NAME} DGEngine.core)
if(DIABLO_FORMAT_SUPPORT AND MPQ_SUPPORT)
if(EXTERNAL_STORMLIB)
@@ -520,13 +253,5 @@ if(DIABLO_FORMAT_SUPPORT AND MPQ_SUPPORT)
endif()
endif()
-if(FFmpeg_FOUND)
- include_directories(${FFmpeg_INCLUDES})
- target_link_libraries(${PROJECT_NAME} ${FFmpeg_LIBRARIES})
-endif()
-
-include_directories(${PHYSFS_INCLUDE_DIRS} ${SFML_INCLUDE_DIR})
-target_link_libraries(${PROJECT_NAME} ${PHYSFS_LIBRARY} ${SFML_LIBRARIES})
-
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
diff --git a/DGEngine.core/.editorconfig b/DGEngine.core/.editorconfig
new file mode 100644
index 00000000..68920355
--- /dev/null
+++ b/DGEngine.core/.editorconfig
@@ -0,0 +1,49 @@
+root = true
+
+[CMakeLists.txt]
+charset = utf-8
+end_of_line = lf
+indent_size = 4
+indent_style = space
+insert_final_newline = true
+
+[gamefiles**.json]
+charset = utf-8
+end_of_line = lf
+indent_size = 2
+indent_style = space
+insert_final_newline = false
+
+[gamefiles**.{frag,vert}]
+charset = utf-8
+end_of_line = lf
+indent_size = 4
+indent_style = tab
+insert_final_newline = false
+trim_trailing_whitespace = true
+
+[src/**]
+charset = utf-8
+end_of_line = lf
+indent_size = 4
+indent_style = tab
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[src/{endian,rapidjson}/**]
+indent_size = unset
+indent_style = unset
+insert_final_newline = unset
+trim_trailing_whitespace = unset
+
+[src/SFML/dr_wav.h]
+indent_size = unset
+indent_style = unset
+insert_final_newline = unset
+trim_trailing_whitespace = unset
+
+[src/Utils/{iterator_tpl.h,re.*}]
+indent_size = unset
+indent_style = unset
+insert_final_newline = unset
+trim_trailing_whitespace = unset
diff --git a/DGEngine.core/.gitattributes b/DGEngine.core/.gitattributes
new file mode 100644
index 00000000..b50db06d
--- /dev/null
+++ b/DGEngine.core/.gitattributes
@@ -0,0 +1,30 @@
+* text=auto
+*.bin binary
+*.bmp binary
+*.c text
+*.c++ text
+*.cc text
+*.cmake text
+*.cpp text
+*.cxx text
+*.filters text eol=crlf
+*.gif binary
+*.h text
+*.h++ text
+*.hh text
+*.hpp text
+*.ico binary
+*.jpeg binary
+*.jpg binary
+*.json text
+*.md text
+*.mk text
+*.png binary
+*.props text eol=crlf
+*.sln text eol=crlf
+*.ttf binary
+*.txt text
+*.vcxitems text eol=crlf
+*.vcxproj text eol=crlf
+*.xml text
+LICENSE text
diff --git a/DGEngine.core/.github/workflows/main.yml b/DGEngine.core/.github/workflows/main.yml
new file mode 100644
index 00000000..05fe047a
--- /dev/null
+++ b/DGEngine.core/.github/workflows/main.yml
@@ -0,0 +1,75 @@
+name: CI
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+
+jobs:
+ build_linux:
+ name: linux build
+ runs-on: ubuntu-20.04
+ steps:
+ - name: Checkout DGEngine.core
+ uses: actions/checkout@v2
+
+ - name: Restore cached dependencies
+ id: cache-linux
+ uses: actions/cache@v1
+ with:
+ path: /home/runner/work/sfml
+ key: cache-linux
+
+ - name: Install dependencies
+ run: sudo apt install -yq --no-install-suggests --no-install-recommends libx11-dev libxrandr-dev libxi-dev libudev-dev libgl1-mesa-dev libalut-dev libvorbis-dev libflac-dev libphysfs-dev > /dev/null
+
+ - name: CMake + make SFML
+ if: steps.cache-linux.outputs.cache-hit != 'true'
+ run: |
+ git clone -q --depth=1 --branch=2.5.x https://github.com/SFML/SFML.git /home/runner/work/sfml > /dev/null
+ git -C /home/runner/work/sfml pull > /dev/null
+ cd /home/runner/work/sfml
+ export CC=/usr/bin/gcc-11
+ export CXX=/usr/bin/g++-11
+ cmake /home/runner/work/sfml/CMakeLists.txt
+ sudo make install
+
+ - name: Install SFML
+ if: steps.cache-linux.outputs.cache-hit == 'true'
+ run: |
+ cd /home/runner/work/sfml
+ sudo make install
+
+ - name: CMake + make DGEngine.core
+ run: |
+ export CC=/usr/bin/gcc-11
+ export CXX=/usr/bin/g++-11
+ cmake CMakeLists.txt
+ make
+
+ build_windows:
+ name: windows build
+ runs-on: windows-2019
+ steps:
+ - name: Checkout DGEngine.core
+ uses: actions/checkout@v2
+
+ - name: Restore cached dependencies
+ id: cache-windows
+ uses: actions/cache@v1
+ with:
+ path: C:/vcpkg/installed
+ key: cache-windows
+
+ - name: Install dependencies
+ if: steps.cache-windows.outputs.cache-hit != 'true'
+ run: vcpkg install physfs:x86-windows-static sfml:x86-windows-static
+
+ - name: Setup MSBuild
+ uses: microsoft/setup-msbuild@v1.0.2
+
+ - name: MSBuild DGEngine.core
+ run: |
+ vcpkg integrate install
+ msbuild DGEngine.core.vcxproj /p:Configuration="Release Static NoMovie" /p:Platform=Win32
diff --git a/DGEngine.core/.gitignore b/DGEngine.core/.gitignore
new file mode 100644
index 00000000..6ccc9943
--- /dev/null
+++ b/DGEngine.core/.gitignore
@@ -0,0 +1,30 @@
+/*.cbp
+/*.db
+/*.depend
+/*.dll
+/*.exe
+/*.layout
+/*.opendb
+/*.vcxproj.filters
+/*.vcxproj.user
+/*.zip
+/.svn
+/.vs
+/bin
+/CMakeCache.txt
+/CMakeFiles
+/cmake_install.cmake
+/Debug
+/Debug Clang
+/Debug Code Analysis
+/Debug NoMovie
+/DGEngine.core
+/DGEngine.core.dir
+/Makefile
+/obj
+/portable
+/Release
+/Release NoMovie
+/Release Static
+/Release Static NoMovie
+/x64
diff --git a/DGEngine.core/BUILD.txt b/DGEngine.core/BUILD.txt
new file mode 100644
index 00000000..2ca7cc14
--- /dev/null
+++ b/DGEngine.core/BUILD.txt
@@ -0,0 +1,58 @@
+* Windows
+
+To compile in Windows, you can use CMake or the Visual Studio 2019 project.
+
+The easiest way to get the required dependencies is to use vcpkg.
+
+vcpkg install physfs:x86-windows sfml:x86-windows ffmpeg:x86-windows
+vcpkg install physfs:x86-windows-static sfml:x86-windows-static ffmpeg:x86-windows-static
+vcpkg install physfs:x64-windows sfml:x64-windows ffmpeg:x64-windows
+vcpkg install physfs:x64-windows-static sfml:x64-windows-static ffmpeg:x64-windows-static
+
+There is a custom vcpkg triplet that links ffmpeg dynamically.
+
+vcpkg install physfs:x86-windows-static sfml:x86-windows-static ffmpeg:x86-windows-static --overlay-triplets=vcpkg/triplets
+vcpkg install physfs:x64-windows-static sfml:x64-windows-static ffmpeg:x64-windows-static --overlay-triplets=vcpkg/triplets
+
+/PhysicsFS - https://icculus.org/physfs
+ version >= 2.1
+
+/SFML - https://www.sfml-dev.org/
+ SFML 2.5.0
+
+/FFmpeg - https://ffmpeg.zeranoe.com/builds/
+ Get both shared and dev packages (version 3.x or 4.x)
+
+If you want to skip movie playback support, use the preprocessor define
+USE_SFML_MOVIE_STUB which uses a stub class that does nothing instead.
+
+* Linux
+
+To compile in Linux (Ubuntu), you need gcc or clang with C++20 support
+and to have both PhysicsFS >= 2.1 and SFML >= 2.5 installed.
+
+sudo apt install libphysfs-dev
+sudo apt install libsfml-dev
+
+Optional (for movie support) FFmpeg:
+
+sudo apt install libavdevice-dev libavformat-dev libavfilter-dev libavcodec-dev libswscale-dev libavutil-dev
+
+Movie support is enabled by default (CMake), unless FFmpeg isn't found.
+In CMake, set MOVIE_SUPPORT to FALSE to skip movie support.
+
+* CMake
+
+A CMake project file is provided. Movie support is enabled by default.
+It will generate a project to compile on the target platform.
+
+cmake CMakeLists.txt
+cmake CMakeLists.txt -DMOVIE_SUPPORT:BOOL=FALSE
+
+Both PhysicsFS and SFML must be installed.
+FFmpeg is also required for movie support.
+
+All the CMake properties and default values:
+
+MOVIE_SUPPORT (TRUE) Enable Movie support
+FALLBACK_TO_LOWERCASE (TRUE) Enable falling back to all lowercase names if file is not found
diff --git a/DGEngine.core/CMakeLists.txt b/DGEngine.core/CMakeLists.txt
new file mode 100644
index 00000000..1b0de8aa
--- /dev/null
+++ b/DGEngine.core/CMakeLists.txt
@@ -0,0 +1,350 @@
+cmake_minimum_required(VERSION 3.12.4 FATAL_ERROR)
+
+project(DGEngine.core VERSION 1.0.0)
+
+if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
+ add_definitions(-Wall -stdlib=libc++)
+elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.0)
+ message(FATAL_ERROR "GCC version must be at least 11!")
+ endif()
+ if(NOT BEOS)
+ add_definitions(-Wall)
+ endif()
+endif()
+
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules")
+
+option(MOVIE_SUPPORT "Enable Movie support" TRUE)
+option(FALLBACK_TO_LOWERCASE "Enable falling back to all lowercase names if file is not found" TRUE)
+
+if(MOVIE_SUPPORT)
+ find_package(FFmpeg COMPONENTS avcodec avformat avutil swscale)
+endif()
+find_package(PhysFS REQUIRED)
+find_package(SFML 2.5 REQUIRED system window graphics network audio)
+
+include_directories(src)
+
+set(SOURCE_FILES
+ src/Alignment.h
+ src/Anchor.h
+ src/Animation.cpp
+ src/Animation.h
+ src/AnimationInfo.h
+ src/AnimationType.h
+ src/AudioSource.h
+ src/BaseAnimation.cpp
+ src/BaseAnimation.h
+ src/BindableText.cpp
+ src/BindableText.h
+ src/BindingFlags.h
+ src/BitmapButton.cpp
+ src/BitmapButton.h
+ src/BitmapFont.cpp
+ src/BitmapFont.h
+ src/BitmapText.cpp
+ src/BitmapText.h
+ src/BlendMode.h
+ src/Button.cpp
+ src/Button.h
+ src/CachedImagePack.cpp
+ src/CachedImagePack.h
+ src/Circle.cpp
+ src/Circle.h
+ src/CmdLineUtils.cpp
+ src/CmdLineUtils.h
+ src/DrawableText.h
+ src/Event.cpp
+ src/Event.h
+ src/EventManager.h
+ src/FadeInOut.cpp
+ src/FadeInOut.h
+ src/FileBytes.h
+ src/FileUtils.cpp
+ src/FileUtils.h
+ src/Font.h
+ src/Formula.cpp
+ src/Formula.h
+ src/Formulas.h
+ src/FreeTypeFont.h
+ src/Game.cpp
+ src/Game.h
+ src/GameUtils.cpp
+ src/GameUtils.h
+ src/Hooks.cpp
+ src/Hooks.h
+ src/IfCondition.cpp
+ src/IfCondition.h
+ src/IgnoreResource.h
+ src/Image.cpp
+ src/Image.h
+ src/ImageUtils.cpp
+ src/ImageUtils.h
+ src/InputEvent.cpp
+ src/InputEvent.h
+ src/InputText.cpp
+ src/InputText.h
+ src/LoadingScreen.cpp
+ src/LoadingScreen.h
+ src/Menu.cpp
+ src/Menu.h
+ src/Movie2.cpp
+ src/Movie2.h
+ src/Palette.cpp
+ src/Palette.h
+ src/Panel.cpp
+ src/Panel.h
+ src/Queryable.h
+ src/Rectangle.cpp
+ src/Rectangle.h
+ src/ResourceManager.cpp
+ src/ResourceManager.h
+ src/Scrollable.cpp
+ src/Scrollable.h
+ src/Shader.h
+ src/ShaderManager.cpp
+ src/ShaderManager.h
+ src/Shape.cpp
+ src/Shape.h
+ src/StreamReader.h
+ src/StringButton.cpp
+ src/StringButton.h
+ src/StringText.cpp
+ src/StringText.h
+ src/Text.cpp
+ src/Text.h
+ src/TextureInfo.h
+ src/TextUtils.cpp
+ src/TextUtils.h
+ src/UIObject.cpp
+ src/UIObject.h
+ src/Variable.cpp
+ src/Variable.h
+ src/VarOrPredicate.h
+ src/Actions/ActAction.h
+ src/Actions/ActAnimation.h
+ src/Actions/ActAudio.h
+ src/Actions/ActButton.h
+ src/Actions/ActCondition.h
+ src/Actions/ActCursor.h
+ src/Actions/ActDrawable.h
+ src/Actions/ActEvent.h
+ src/Actions/ActFade.h
+ src/Actions/ActFocus.h
+ src/Actions/ActFont.h
+ src/Actions/ActGame.h
+ src/Actions/ActImage.h
+ src/Actions/ActInputText.h
+ src/Actions/ActIO.h
+ src/Actions/Action.h
+ src/Actions/ActiontList.h
+ src/Actions/ActLoad.h
+ src/Actions/ActLoadingScreen.h
+ src/Actions/ActMenu.h
+ src/Actions/ActMount.h
+ src/Actions/ActMovie.h
+ src/Actions/ActPalette.h
+ src/Actions/ActRandom.h
+ src/Actions/ActResource.h
+ src/Actions/ActScrollable.h
+ src/Actions/ActShader.h
+ src/Actions/ActSound.h
+ src/Actions/ActText.h
+ src/Actions/ActVariable.h
+ src/Actions/ActVisibility.h
+ src/Game/Save/SaveProperties.h
+ src/Game/Save/SaveUtils.cpp
+ src/Game/Save/SaveUtils.h
+ src/ImageContainers/ImageContainer.h
+ src/ImageContainers/SimpleImageContainer.cpp
+ src/ImageContainers/SimpleImageContainer.h
+ src/Json/JsonParser.h
+ src/Json/JsonUtils.cpp
+ src/Json/JsonUtils.h
+ src/Parser/ParseAction.cpp
+ src/Parser/ParseAction.h
+ src/Parser/ParseAnimation.cpp
+ src/Parser/ParseAnimation.h
+ src/Parser/ParseAudio.cpp
+ src/Parser/ParseAudio.h
+ src/Parser/ParseAudioCommon.cpp
+ src/Parser/ParseAudioCommon.h
+ src/Parser/ParseButton.cpp
+ src/Parser/ParseButton.h
+ src/Parser/ParseCircle.cpp
+ src/Parser/ParseCircle.h
+ src/Parser/ParseCondition.cpp
+ src/Parser/ParseCondition.h
+ src/Parser/ParseCursor.cpp
+ src/Parser/ParseCursor.h
+ src/Parser/ParseEvent.cpp
+ src/Parser/ParseEvent.h
+ src/Parser/ParseFile.cpp
+ src/Parser/ParseFile.h
+ src/Parser/ParseFileBytes.cpp
+ src/Parser/ParseFileBytes.h
+ src/Parser/ParseFont.cpp
+ src/Parser/ParseFont.h
+ src/Parser/ParseIcon.cpp
+ src/Parser/ParseIcon.h
+ src/Parser/ParseImage.cpp
+ src/Parser/ParseImage.h
+ src/Parser/ParseImageContainer.cpp
+ src/Parser/ParseImageContainer.h
+ src/Parser/ParseInputEvent.cpp
+ src/Parser/ParseInputEvent.h
+ src/Parser/ParseInputText.cpp
+ src/Parser/ParseInputText.h
+ src/Parser/ParseLoadingScreen.cpp
+ src/Parser/ParseLoadingScreen.h
+ src/Parser/ParseMenu.cpp
+ src/Parser/ParseMenu.h
+ src/Parser/ParseMenuButton.cpp
+ src/Parser/ParseMenuButton.h
+ src/Parser/ParseMountFile.cpp
+ src/Parser/ParseMountFile.h
+ src/Parser/ParseMovie.cpp
+ src/Parser/ParseMovie.h
+ src/Parser/ParsePalette.cpp
+ src/Parser/ParsePalette.h
+ src/Parser/ParsePanel.cpp
+ src/Parser/ParsePanel.h
+ src/Parser/ParsePredicate.cpp
+ src/Parser/ParsePredicate.h
+ src/Parser/Parser.cpp
+ src/Parser/Parser.h
+ src/Parser/ParseRectangle.cpp
+ src/Parser/ParseRectangle.h
+ src/Parser/ParserProperties.h
+ src/Parser/ParseScrollable.cpp
+ src/Parser/ParseScrollable.h
+ src/Parser/ParseShader.cpp
+ src/Parser/ParseShader.h
+ src/Parser/ParseShape.cpp
+ src/Parser/ParseShape.h
+ src/Parser/ParseSound.cpp
+ src/Parser/ParseSound.h
+ src/Parser/ParseText.cpp
+ src/Parser/ParseText.h
+ src/Parser/ParseTexture.cpp
+ src/Parser/ParseTexture.h
+ src/Parser/ParseTexturePack.cpp
+ src/Parser/ParseTexturePack.h
+ src/Parser/ParseVariable.cpp
+ src/Parser/ParseVariable.h
+ src/Parser/Utils/ParseUtils.cpp
+ src/Parser/Utils/ParseUtils.h
+ src/Parser/Utils/ParseUtilsIdx.cpp
+ src/Parser/Utils/ParseUtilsIdx.h
+ src/Parser/Utils/ParseUtilsKey.cpp
+ src/Parser/Utils/ParseUtilsKey.h
+ src/Parser/Utils/ParseUtilsVal.cpp
+ src/Parser/Utils/ParseUtilsVal.h
+ src/Predicates/Predicate.h
+ src/Predicates/PredIO.h
+ src/SFML/CompositeSprite.cpp
+ src/SFML/CompositeSprite.h
+ src/SFML/dr_wav.h
+ src/SFML/Image2.h
+ src/SFML/Music2.cpp
+ src/SFML/Music2.h
+ src/SFML/MusicLoops.cpp
+ src/SFML/MusicLoops.h
+ src/SFML/PhysFSStream.cpp
+ src/SFML/PhysFSStream.h
+ src/SFML/SFMLUtils.cpp
+ src/SFML/SFMLUtils.h
+ src/SFML/Sprite2.cpp
+ src/SFML/Sprite2.h
+ src/SFML/Surface.cpp
+ src/SFML/Surface.h
+ src/SFML/Text2.cpp
+ src/SFML/Text2.h
+ src/SFML/VertexArray2.cpp
+ src/SFML/VertexArray2.h
+ src/SFML/VertexShape.cpp
+ src/SFML/VertexShape.h
+ src/SFML/View2.cpp
+ src/SFML/View2.h
+ src/SFML/Wave2.cpp
+ src/SFML/Wave2.h
+ src/TexturePacks/BitmapFontTexturePack.cpp
+ src/TexturePacks/BitmapFontTexturePack.h
+ src/TexturePacks/CachedTexturePack.cpp
+ src/TexturePacks/CachedTexturePack.h
+ src/TexturePacks/CompositeTexturePack.cpp
+ src/TexturePacks/CompositeTexturePack.h
+ src/TexturePacks/IndexedTexturePack.cpp
+ src/TexturePacks/IndexedTexturePack.h
+ src/TexturePacks/RectTexturePack.cpp
+ src/TexturePacks/RectTexturePack.h
+ src/TexturePacks/SimpleTexturePack.cpp
+ src/TexturePacks/SimpleTexturePack.h
+ src/TexturePacks/StackedTexturePack.cpp
+ src/TexturePacks/StackedTexturePack.h
+ src/TexturePacks/TexturePack.cpp
+ src/TexturePacks/TexturePack.h
+ src/Utils/EasedValue.h
+ src/Utils/EasingFunctions.h
+ src/Utils/ElapsedTime.h
+ src/Utils/FixedArray.h
+ src/Utils/FixedMap.h
+ src/Utils/Helper2D.h
+ src/Utils/iterator_tpl.h
+ src/Utils/LRUCache.h
+ src/Utils/Number.h
+ src/Utils/NumberVector.h
+ src/Utils/PairXY.h
+ src/Utils/re.c
+ src/Utils/re.h
+ src/Utils/Regex.h
+ src/Utils/ReverseIterable.h
+ src/Utils/UnorderedStringMap.h
+ src/Utils/Utils.cpp
+ src/Utils/Utils.h
+ src/Utils/Vector2D.h
+)
+
+if(FFmpeg_FOUND)
+ SET(SOURCE_FILES ${SOURCE_FILES}
+ src/sfeMovie/AudioStream.cpp
+ src/sfeMovie/AudioStream.hpp
+ src/sfeMovie/Demuxer.cpp
+ src/sfeMovie/Demuxer.hpp
+ src/sfeMovie/Movie.cpp
+ src/sfeMovie/Movie.hpp
+ src/sfeMovie/MovieImpl.cpp
+ src/sfeMovie/MovieImpl.hpp
+ src/sfeMovie/Stream.cpp
+ src/sfeMovie/Stream.hpp
+ src/sfeMovie/StreamSelection.hpp
+ src/sfeMovie/Timer.cpp
+ src/sfeMovie/Timer.hpp
+ src/sfeMovie/TimerPriorities.hpp
+ src/sfeMovie/VideoStream.cpp
+ src/sfeMovie/VideoStream.hpp
+ )
+else()
+ add_definitions(-DDGENGINE_MOVIE_STUB)
+endif()
+
+if(FALLBACK_TO_LOWERCASE)
+ add_definitions(-DDGENGINE_FALLBACK_TO_LOWERCASE)
+endif()
+
+add_library(${PROJECT_NAME} ${SOURCE_FILES})
+
+target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
+
+if(FFmpeg_FOUND)
+ include_directories(${FFmpeg_INCLUDES})
+ target_link_libraries(${PROJECT_NAME} ${FFmpeg_LIBRARIES})
+endif()
+
+include_directories(${PHYSFS_INCLUDE_DIRS} ${SFML_INCLUDE_DIR})
+target_link_libraries(${PROJECT_NAME} ${PHYSFS_LIBRARY} ${SFML_LIBRARIES})
+
+set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20)
+set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
diff --git a/Project.vcxproj b/DGEngine.core/DGEngine.core.vcxproj
similarity index 70%
rename from Project.vcxproj
rename to DGEngine.core/DGEngine.core.vcxproj
index ff50ff01..212c0194 100644
--- a/Project.vcxproj
+++ b/DGEngine.core/DGEngine.core.vcxproj
@@ -17,14 +17,6 @@
Debug Code Analysis
x64
-
- Debug NoDiabloFormatSupport
- Win32
-
-
- Debug NoDiabloFormatSupport
- x64
-
Debug NoMovie
Win32
@@ -85,90 +77,27 @@
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
@@ -179,7 +108,6 @@
-
@@ -194,7 +122,6 @@
-
@@ -206,15 +133,9 @@
-
-
-
-
- true
-
@@ -254,12 +175,12 @@
true
-
+
@@ -267,33 +188,6 @@
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
@@ -306,7 +200,6 @@
-
@@ -330,17 +223,12 @@
-
-
-
-
-
@@ -362,9 +250,6 @@
-
- true
-
@@ -372,69 +257,13 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
@@ -444,18 +273,7 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -466,7 +284,6 @@
-
@@ -481,7 +298,6 @@
-
@@ -494,16 +310,11 @@
-
-
-
-
-
@@ -557,30 +368,22 @@
-
-
- true
-
-
-
- true
-
-
+
@@ -589,21 +392,6 @@
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
@@ -618,7 +406,6 @@
-
@@ -644,123 +431,111 @@
- {B30255A6-E921-4847-9FB1-26842AB465A4}
+ {1B91743F-9C8A-4E06-9950-31D959E5622E}
DGEngine
- DGEngine
+ DGEngine.core
10.0
- Application
+ StaticLibrary
true
v142
MultiByte
- Application
- true
- v142
- MultiByte
-
-
- Application
- true
- v142
- MultiByte
-
-
- Application
+ StaticLibrary
true
v142
MultiByte
- Application
+ StaticLibrary
true
v142
MultiByte
- Application
+ StaticLibrary
true
v142
MultiByte
- Application
+ StaticLibrary
true
v142
MultiByte
- Application
+ StaticLibrary
true
v142
MultiByte
- Application
+ StaticLibrary
true
ClangCL
MultiByte
- Application
+ StaticLibrary
true
ClangCL
MultiByte
- Application
+ StaticLibrary
false
v142
true
MultiByte
- Application
+ StaticLibrary
false
v142
true
MultiByte
- Application
+ StaticLibrary
false
v142
true
MultiByte
- Application
+ StaticLibrary
false
v142
true
MultiByte
- Application
+ StaticLibrary
false
v142
MultiByte
true
- Application
+ StaticLibrary
false
v142
MultiByte
true
- Application
+ StaticLibrary
false
v142
MultiByte
true
- Application
+ StaticLibrary
false
v142
MultiByte
@@ -775,12 +550,6 @@
-
-
-
-
-
-
@@ -825,64 +594,58 @@
- Project.dir\$(Platform)\$(Configuration)\
+ DGEngine.core.dir\$(Platform)\$(Configuration)\
- Project.dir\$(Platform)\$(Configuration)\
-
-
- Project.dir\$(Platform)\$(Configuration)\
-
-
- Project.dir\$(Platform)\$(Configuration)\
+ DGEngine.core.dir\$(Platform)\$(Configuration)\
- Project.dir\$(Platform)\$(Configuration)\
+ DGEngine.core.dir\$(Platform)\$(Configuration)\
NativeRecommendedRules.ruleset
true
true
- Project.dir\$(Platform)\$(Configuration)\
+ DGEngine.core.dir\$(Platform)\$(Configuration)\
NativeRecommendedRules.ruleset
true
true
- Project.dir\$(Platform)\$(Configuration)\
+ DGEngine.core.dir\$(Platform)\$(Configuration)\
- Project.dir\$(Platform)\$(Configuration)\
+ DGEngine.core.dir\$(Platform)\$(Configuration)\
- Project.dir\$(Platform)\$(Configuration)\
+ DGEngine.core.dir\$(Platform)\$(Configuration)\
- Project.dir\$(Platform)\$(Configuration)\
+ DGEngine.core.dir\$(Platform)\$(Configuration)\
- Project.dir\$(Platform)\$(Configuration)\
+ DGEngine.core.dir\$(Platform)\$(Configuration)\
- Project.dir\$(Platform)\$(Configuration)\
+ DGEngine.core.dir\$(Platform)\$(Configuration)\
- Project.dir\$(Platform)\$(Configuration)\
+ DGEngine.core.dir\$(Platform)\$(Configuration)\
- Project.dir\$(Platform)\$(Configuration)\
+ DGEngine.core.dir\$(Platform)\$(Configuration)\
- Project.dir\$(Platform)\$(Configuration)\
+ DGEngine.core.dir\$(Platform)\$(Configuration)\
- Project.dir\$(Platform)\$(Configuration)\
+ DGEngine.core.dir\$(Platform)\$(Configuration)\
- Project.dir\$(Platform)\$(Configuration)\
+ DGEngine.core.dir\$(Platform)\$(Configuration)\
- Project.dir\$(Platform)\$(Configuration)\
+ DGEngine.core.dir\$(Platform)\$(Configuration)\
true
@@ -904,7 +667,7 @@
4250;4996
stdcpplatest
Disabled
- DGENGINE_DIABLO_FORMAT_SUPPORT;PHYSFS_DYNAMIC_STORMLIB;PHYSFS_INTERNAL_STORMLIB;PHYSFS_MPQ_SUPPORT;%(PreprocessorDefinitions)
+ %(PreprocessorDefinitions)
true
Level3
@@ -920,37 +683,7 @@
4250;4996
stdcpplatest
Disabled
- DGENGINE_DIABLO_FORMAT_SUPPORT;PHYSFS_DYNAMIC_STORMLIB;PHYSFS_INTERNAL_STORMLIB;PHYSFS_MPQ_SUPPORT;%(PreprocessorDefinitions)
- true
- Level3
-
-
- DebugFastLink
-
-
-
-
- .\src;%(AdditionalIncludeDirectories)
- true
- false
- 4250;4996
- stdcpplatest
- Disabled
- true
- Level3
-
-
- DebugFastLink
-
-
-
-
- .\src;%(AdditionalIncludeDirectories)
- true
- false
- 4250;4996
- stdcpplatest
- Disabled
+ %(PreprocessorDefinitions)
true
Level3
@@ -967,7 +700,7 @@
true
stdcpplatest
Disabled
- DGENGINE_DIABLO_FORMAT_SUPPORT;PHYSFS_DYNAMIC_STORMLIB;PHYSFS_INTERNAL_STORMLIB;PHYSFS_MPQ_SUPPORT;%(PreprocessorDefinitions)
+ %(PreprocessorDefinitions)
true
Level3
@@ -984,7 +717,7 @@
true
stdcpplatest
Disabled
- DGENGINE_DIABLO_FORMAT_SUPPORT;PHYSFS_DYNAMIC_STORMLIB;PHYSFS_INTERNAL_STORMLIB;PHYSFS_MPQ_SUPPORT;%(PreprocessorDefinitions)
+ %(PreprocessorDefinitions)
true
Level3
@@ -1000,7 +733,7 @@
4250;4996
stdcpplatest
Disabled
- DGENGINE_DIABLO_FORMAT_SUPPORT;DGENGINE_MOVIE_STUB;PHYSFS_DYNAMIC_STORMLIB;PHYSFS_INTERNAL_STORMLIB;PHYSFS_MPQ_SUPPORT;%(PreprocessorDefinitions)
+ DGENGINE_MOVIE_STUB;%(PreprocessorDefinitions)
true
Level3
@@ -1016,7 +749,7 @@
4250;4996
stdcpplatest
Disabled
- DGENGINE_DIABLO_FORMAT_SUPPORT;DGENGINE_MOVIE_STUB;PHYSFS_DYNAMIC_STORMLIB;PHYSFS_INTERNAL_STORMLIB;PHYSFS_MPQ_SUPPORT;%(PreprocessorDefinitions)
+ DGENGINE_MOVIE_STUB;%(PreprocessorDefinitions)
true
Level3
@@ -1031,7 +764,7 @@
false
stdcpplatest
Disabled
- DGENGINE_DIABLO_FORMAT_SUPPORT;DGENGINE_MOVIE_STUB;PHYSFS_DYNAMIC_STORMLIB;PHYSFS_INTERNAL_STORMLIB;PHYSFS_MPQ_SUPPORT;%(PreprocessorDefinitions)
+ DGENGINE_MOVIE_STUB;%(PreprocessorDefinitions)
true
false
Level3
@@ -1048,7 +781,7 @@
false
stdcpplatest
Disabled
- DGENGINE_DIABLO_FORMAT_SUPPORT;DGENGINE_MOVIE_STUB;PHYSFS_DYNAMIC_STORMLIB;PHYSFS_INTERNAL_STORMLIB;PHYSFS_MPQ_SUPPORT;%(PreprocessorDefinitions)
+ DGENGINE_MOVIE_STUB;%(PreprocessorDefinitions)
true
false
Level3
@@ -1069,7 +802,7 @@
true
stdcpplatest
Full
- DGENGINE_DIABLO_FORMAT_SUPPORT;PHYSFS_DYNAMIC_STORMLIB;PHYSFS_INTERNAL_STORMLIB;PHYSFS_MPQ_SUPPORT;%(PreprocessorDefinitions)
+ %(PreprocessorDefinitions)
true
Level3
@@ -1090,7 +823,7 @@
true
stdcpplatest
Full
- DGENGINE_DIABLO_FORMAT_SUPPORT;PHYSFS_DYNAMIC_STORMLIB;PHYSFS_INTERNAL_STORMLIB;PHYSFS_MPQ_SUPPORT;%(PreprocessorDefinitions)
+ %(PreprocessorDefinitions)
true
Level3
@@ -1111,7 +844,7 @@
true
stdcpplatest
Full
- DGENGINE_DIABLO_FORMAT_SUPPORT;DGENGINE_MOVIE_STUB;PHYSFS_DYNAMIC_STORMLIB;PHYSFS_INTERNAL_STORMLIB;PHYSFS_MPQ_SUPPORT;%(PreprocessorDefinitions)
+ DGENGINE_MOVIE_STUB;%(PreprocessorDefinitions)
true
Level3
@@ -1132,7 +865,7 @@
true
stdcpplatest
Full
- DGENGINE_DIABLO_FORMAT_SUPPORT;DGENGINE_MOVIE_STUB;PHYSFS_DYNAMIC_STORMLIB;PHYSFS_INTERNAL_STORMLIB;PHYSFS_MPQ_SUPPORT;%(PreprocessorDefinitions)
+ DGENGINE_MOVIE_STUB;%(PreprocessorDefinitions)
true
Level3
@@ -1153,7 +886,7 @@
true
stdcpplatest
Full
- DGENGINE_DIABLO_FORMAT_SUPPORT;PHYSFS_DYNAMIC_STORMLIB;PHYSFS_INTERNAL_STORMLIB;PHYSFS_MPQ_SUPPORT;SFML_STATIC;%(PreprocessorDefinitions)
+ SFML_STATIC;%(PreprocessorDefinitions)
MultiThreaded
true
Level3
@@ -1176,7 +909,7 @@
true
stdcpplatest
Full
- DGENGINE_DIABLO_FORMAT_SUPPORT;PHYSFS_DYNAMIC_STORMLIB;PHYSFS_INTERNAL_STORMLIB;PHYSFS_MPQ_SUPPORT;SFML_STATIC;%(PreprocessorDefinitions)
+ SFML_STATIC;%(PreprocessorDefinitions)
MultiThreaded
true
Level3
@@ -1199,7 +932,7 @@
true
stdcpplatest
Full
- DGENGINE_DIABLO_FORMAT_SUPPORT;DGENGINE_MOVIE_STUB;PHYSFS_DYNAMIC_STORMLIB;PHYSFS_INTERNAL_STORMLIB;PHYSFS_MPQ_SUPPORT;SFML_STATIC;%(PreprocessorDefinitions)
+ DGENGINE_MOVIE_STUB;SFML_STATIC;%(PreprocessorDefinitions)
MultiThreaded
true
Level3
@@ -1222,7 +955,7 @@
true
stdcpplatest
Full
- DGENGINE_DIABLO_FORMAT_SUPPORT;DGENGINE_MOVIE_STUB;PHYSFS_DYNAMIC_STORMLIB;PHYSFS_INTERNAL_STORMLIB;PHYSFS_MPQ_SUPPORT;SFML_STATIC;%(PreprocessorDefinitions)
+ DGENGINE_MOVIE_STUB;SFML_STATIC;%(PreprocessorDefinitions)
MultiThreaded
true
Level3
diff --git a/DGEngine.core/LICENSE.Zlib.txt b/DGEngine.core/LICENSE.Zlib.txt
new file mode 100644
index 00000000..7a7fdf50
--- /dev/null
+++ b/DGEngine.core/LICENSE.Zlib.txt
@@ -0,0 +1,17 @@
+Copyright (c) 2020 DGEngine core
+
+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 acknowledgement 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.
diff --git a/DGEngine.core/LICENSE.txt b/DGEngine.core/LICENSE.txt
new file mode 100644
index 00000000..18b99320
--- /dev/null
+++ b/DGEngine.core/LICENSE.txt
@@ -0,0 +1,58 @@
+DGEngine uses the zLib license.
+
+A part of the BitmapFont class is based on a bitmap font implementation for SDL
+by Lazy Foo' Productions. The license is incompatible with GPL like licenses.
+
+http://lazyfoo.net
+
+dr_wav uses the MIT-0 license.
+
+https://github.com/mackron/dr_libs
+
+endian uses the BSD license.
+
+https://github.com/steinwurf/endian
+
+PhysFS uses the zlib license.
+
+https://icculus.org/physfs/
+
+RapidJSON uses the MIT license.
+
+https://github.com/Tencent/rapidjson
+
+Simple Iterator Template implementation by VinÃcius Garcia uses the MIT license.
+
+https://github.com/VinGarcia/Simple-Iterator-Template
+
+SFML Animation class based on an implementation by Maximilian Wagenbach.
+It uses the zlib/png license.
+
+SFML PhysFS class based on an implementation by Oscar Triano.
+It uses the zlib/png license.
+
+https://github.com/SFML/SFML/wiki/Source:-SFML-PhysFS
+
+sfeMovie uses the LGPL v2.1 license.
+
+https://github.com/Yalir/sfeMovie
+
+SFML uses the zlib/png license.
+
+https://github.com/SFML/SFML
+
+tiny-regex-c is public domain.
+
+https://github.com/kokke/tiny-regex-c
+
+Other SFML code snippets were taken from the wiki
+and should have a permissive license.
+
+FindFFmpeg.cmake was taken from Dolphin that uses the GPL v2 license.
+https://github.com/dolphin-emu/dolphin
+
+Small utility functions (string manipulation, etc) were taken from stackoverflow
+which use the cc by-sa 3.0 license with attribution required. I will update
+those functions in the future and point out the original authors in the next commits.
+
+If you feel there is a problem with licensing, contact me.
diff --git a/DGEngine.core/README.md b/DGEngine.core/README.md
new file mode 100644
index 00000000..7f89b751
--- /dev/null
+++ b/DGEngine.core/README.md
@@ -0,0 +1,48 @@
+# DGEngine core
+
+DGEngine core is a 2D game engine.
+
+### Example
+
+Here is a simple example on how to use DGEngine core:
+
+```cpp
+#include "CmdLineUtils.h"
+#include "FileUtils.h"
+#include "Game.h"
+#include
+
+int main(int argc, char* argv[])
+{
+ FileUtils::initPhysFS(argv[0]);
+
+ try
+ {
+ Game game;
+
+ if (CmdLineUtils::processCmdLine(argc, (const char**)argv) == false)
+ {
+ if (argc == 2)
+ {
+ game.load(argv[1], "main.json");
+ }
+ else if (argc == 3)
+ {
+ game.load(argv[1], argv[2]);
+ }
+ else
+ {
+ game.load(".", "main.json");
+ }
+ game.play();
+ }
+ }
+ catch (std::exception& ex)
+ {
+ std::cerr << ex.what();
+ }
+
+ FileUtils::deinitPhysFS();
+ return 0;
+}
+```
diff --git a/DGEngine.core/cmake_modules/FindFFmpeg.cmake b/DGEngine.core/cmake_modules/FindFFmpeg.cmake
new file mode 100644
index 00000000..af7711f6
--- /dev/null
+++ b/DGEngine.core/cmake_modules/FindFFmpeg.cmake
@@ -0,0 +1,165 @@
+# FindFFmpeg
+# ----------
+#
+# Find the native FFmpeg includes and libraries
+#
+# This module defines the following variables:
+#
+# FFmpeg_INCLUDE_: where to find .h
+# FFmpeg_LIBRARY_: where to find the library
+# FFmpeg_INCLUDES: aggregate all the include paths
+# FFmpeg_LIBRARIES: aggregate all the paths to the libraries
+# FFmpeg_FOUND: True if all components have been found
+#
+# This module defines the following targets, which are prefered over variables:
+#
+# FFmpeg::: Target to use directly, with include path,
+# library and dependencies set up. If you are using a static build, you are
+# responsible for adding any external dependencies (such as zlib, bzlib...).
+#
+# can be one of:
+# avcodec
+# avdevice
+# avfilter
+# avformat
+# postproc
+# swresample
+# swscale
+#
+
+set(_FFmpeg_ALL_COMPONENTS
+ avcodec
+ avdevice
+ avfilter
+ avformat
+ avutil
+ postproc
+ swresample
+ swscale
+)
+
+set(_FFmpeg_DEPS_avcodec avutil)
+set(_FFmpeg_DEPS_avdevice avcodec avformat avutil)
+set(_FFmpeg_DEPS_avfilter avutil)
+set(_FFmpeg_DEPS_avformat avcodec avutil)
+set(_FFmpeg_DEPS_postproc avutil)
+set(_FFmpeg_DEPS_swresample avutil)
+set(_FFmpeg_DEPS_swscale avutil)
+
+function(find_ffmpeg LIBNAME)
+ if(DEFINED ENV{FFMPEG_DIR})
+ set(FFMPEG_DIR $ENV{FFMPEG_DIR})
+ endif()
+
+ if(FFMPEG_DIR)
+ list(APPEND INCLUDE_PATHS
+ ${FFMPEG_DIR}
+ ${FFMPEG_DIR}/ffmpeg
+ ${FFMPEG_DIR}/lib${LIBNAME}
+ ${FFMPEG_DIR}/include/lib${LIBNAME}
+ ${FFMPEG_DIR}/include/ffmpeg
+ ${FFMPEG_DIR}/include
+ NO_DEFAULT_PATH
+ NO_CMAKE_FIND_ROOT_PATH
+ )
+ list(APPEND LIB_PATHS
+ ${FFMPEG_DIR}
+ ${FFMPEG_DIR}/lib
+ ${FFMPEG_DIR}/lib${LIBNAME}
+ NO_DEFAULT_PATH
+ NO_CMAKE_FIND_ROOT_PATH
+ )
+ else()
+ list(APPEND INCLUDE_PATHS
+ /usr/local/include/ffmpeg
+ /usr/local/include/lib${LIBNAME}
+ /usr/include/ffmpeg
+ /usr/include/lib${LIBNAME}
+ /usr/include/ffmpeg/lib${LIBNAME}
+ )
+
+ list(APPEND LIB_PATHS
+ /usr/local/lib
+ /usr/lib
+ )
+ endif()
+
+ find_path(FFmpeg_INCLUDE_${LIBNAME} lib${LIBNAME}/${LIBNAME}.h
+ HINTS ${INCLUDE_PATHS}
+ )
+
+ find_library(FFmpeg_LIBRARY_${LIBNAME} ${LIBNAME}
+ HINTS ${LIB_PATHS}
+ )
+
+ if(NOT FFMPEG_DIR AND (NOT FFmpeg_LIBRARY_${LIBNAME} OR NOT FFmpeg_INCLUDE_${LIBNAME}))
+ # Didn't find it in the usual paths, try pkg-config
+ find_package(PkgConfig QUIET)
+ pkg_check_modules(FFmpeg_PKGCONFIG_${LIBNAME} QUIET lib${LIBNAME})
+
+ find_path(FFmpeg_INCLUDE_${LIBNAME} lib${LIBNAME}/${LIBNAME}.h
+ ${FFmpeg_PKGCONFIG_${LIBNAME}_INCLUDE_DIRS}
+ )
+
+ find_library(FFmpeg_LIBRARY_${LIBNAME} ${LIBNAME}
+ ${FFmpeg_PKGCONFIG_${LIBNAME}_LIBRARY_DIRS}
+ )
+ endif()
+
+ if(FFmpeg_INCLUDE_${LIBNAME} AND FFmpeg_LIBRARY_${LIBNAME})
+ set(FFmpeg_INCLUDE_${LIBNAME} "${FFmpeg_INCLUDE_${LIBNAME}}" PARENT_SCOPE)
+ set(FFmpeg_LIBRARY_${LIBNAME} "${FFmpeg_LIBRARY_${LIBNAME}}" PARENT_SCOPE)
+ set(FFmpeg_${c}_FOUND TRUE PARENT_SCOPE)
+ if(NOT FFmpeg_FIND_QUIETLY)
+ message("-- Found ${LIBNAME}: ${FFmpeg_INCLUDE_${LIBNAME}} ${FFmpeg_LIBRARY_${LIBNAME}}")
+ endif()
+ endif()
+endfunction()
+
+foreach(c ${_FFmpeg_ALL_COMPONENTS})
+ find_ffmpeg(${c})
+endforeach()
+
+foreach(c ${_FFmpeg_ALL_COMPONENTS})
+ if(FFmpeg_${c}_FOUND)
+ list(APPEND FFmpeg_INCLUDES ${FFmpeg_INCLUDE_${c}})
+ list(APPEND FFmpeg_LIBRARIES ${FFmpeg_LIBRARY_${c}})
+
+ add_library(FFmpeg::${c} IMPORTED UNKNOWN)
+ set_target_properties(FFmpeg::${c} PROPERTIES
+ IMPORTED_LOCATION ${FFmpeg_LIBRARY_${c}}
+ INTERFACE_INCLUDE_DIRECTORIES ${FFmpeg_INCLUDE_${c}}
+ )
+ if(_FFmpeg_DEPS_${c})
+ set(deps)
+ foreach(dep ${_FFmpeg_DEPS_${c}})
+ list(APPEND deps FFmpeg::${dep})
+ endforeach()
+
+ set_target_properties(FFmpeg::${c} PROPERTIES
+ INTERFACE_LINK_LIBRARIES "${deps}"
+ )
+ unset(deps)
+ endif()
+ endif()
+endforeach()
+
+if(FFmpeg_INCLUDES)
+ list(REMOVE_DUPLICATES FFmpeg_INCLUDES)
+endif()
+
+foreach(c ${FFmpeg_FIND_COMPONENTS})
+ list(APPEND _FFmpeg_REQUIRED_VARS FFmpeg_INCLUDE_${c} FFmpeg_LIBRARY_${c})
+endforeach()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(FFmpeg
+ REQUIRED_VARS ${_FFmpeg_REQUIRED_VARS}
+ HANDLE_COMPONENTS
+)
+
+foreach(c ${_FFmpeg_ALL_COMPONENTS})
+ unset(_FFmpeg_DEPS_${c})
+endforeach()
+unset(_FFmpeg_ALL_COMPONENTS)
+unset(_FFmpeg_REQUIRED_VARS)
diff --git a/DGEngine.core/cmake_modules/FindSFML.cmake b/DGEngine.core/cmake_modules/FindSFML.cmake
new file mode 100644
index 00000000..871f8662
--- /dev/null
+++ b/DGEngine.core/cmake_modules/FindSFML.cmake
@@ -0,0 +1,368 @@
+# This script locates the SFML library
+# ------------------------------------
+#
+# Usage
+# -----
+#
+# When you try to locate the SFML libraries, you must specify which modules you want to use (system, window, graphics, network, audio, main).
+# If none is given, the SFML_LIBRARIES variable will be empty and you'll end up linking to nothing.
+# example:
+# find_package(SFML COMPONENTS graphics window system) // find the graphics, window and system modules
+#
+# You can enforce a specific version, either MAJOR.MINOR or only MAJOR.
+# If nothing is specified, the version won't be checked (i.e. any version will be accepted).
+# example:
+# find_package(SFML COMPONENTS ...) // no specific version required
+# find_package(SFML 2 COMPONENTS ...) // any 2.x version
+# find_package(SFML 2.4 COMPONENTS ...) // version 2.4 or greater
+#
+# By default, the dynamic libraries of SFML will be found. To find the static ones instead,
+# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...).
+# Since you have to link yourself all the SFML dependencies when you link it statically, the following
+# additional variables are defined: SFML_XXX_DEPENDENCIES and SFML_DEPENDENCIES (see their detailed
+# description below).
+# In case of static linking, the SFML_STATIC macro will also be defined by this script.
+# example:
+# set(SFML_STATIC_LIBRARIES TRUE)
+# find_package(SFML 2 COMPONENTS network system)
+#
+# On Mac OS X if SFML_STATIC_LIBRARIES is not set to TRUE then by default CMake will search for frameworks unless
+# CMAKE_FIND_FRAMEWORK is set to "NEVER" for example. Please refer to CMake documentation for more details.
+# Moreover, keep in mind that SFML frameworks are only available as release libraries unlike dylibs which
+# are available for both release and debug modes.
+#
+# If SFML is not installed in a standard path, you can use the SFML_ROOT CMake (or environment) variable
+# to tell CMake where SFML is.
+#
+# Output
+# ------
+#
+# This script defines the following variables:
+# - For each specified module XXX (system, window, graphics, network, audio, main):
+# - SFML_XXX_LIBRARY_DEBUG: the name of the debug library of the xxx module (set to SFML_XXX_LIBRARY_RELEASE is no debug version is found)
+# - SFML_XXX_LIBRARY_RELEASE: the name of the release library of the xxx module (set to SFML_XXX_LIBRARY_DEBUG is no release version is found)
+# - SFML_XXX_LIBRARY: the name of the library to link to for the xxx module (includes both debug and optimized names if necessary)
+# - SFML_XXX_FOUND: true if either the debug or release library of the xxx module is found
+# - SFML_XXX_DEPENDENCIES: the list of libraries the module depends on, in case of static linking
+# - SFML_LIBRARIES: the list of all libraries corresponding to the required modules
+# - SFML_FOUND: true if all the required modules are found
+# - SFML_INCLUDE_DIR: the path where SFML headers are located (the directory containing the SFML/Config.hpp file)
+# - SFML_DEPENDENCIES: the list of libraries SFML depends on, in case of static linking
+#
+# example:
+# find_package(SFML 2 COMPONENTS system window graphics audio REQUIRED)
+# include_directories(${SFML_INCLUDE_DIR})
+# add_executable(myapp ...)
+# target_link_libraries(myapp ${SFML_LIBRARIES})
+
+# define the SFML_STATIC macro if static build was chosen
+if(SFML_STATIC_LIBRARIES)
+ add_definitions(-DSFML_STATIC)
+endif()
+
+# define the list of search paths for headers and libraries
+set(FIND_SFML_PATHS
+ ${SFML_ROOT}
+ $ENV{SFML_ROOT}
+ ~/Library/Frameworks
+ /Library/Frameworks
+ /usr/local
+ /usr
+ /sw
+ /opt/local
+ /opt/csw
+ /opt)
+
+# find the SFML include directory
+find_path(SFML_INCLUDE_DIR SFML/Config.hpp
+ PATH_SUFFIXES include
+ PATHS ${FIND_SFML_PATHS})
+
+# check the version number
+set(SFML_VERSION_OK TRUE)
+if(SFML_FIND_VERSION AND SFML_INCLUDE_DIR)
+ # extract the major and minor version numbers from SFML/Config.hpp
+ # we have to handle framework a little bit differently:
+ if("${SFML_INCLUDE_DIR}" MATCHES "SFML.framework")
+ set(SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/Headers/Config.hpp")
+ else()
+ set(SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/SFML/Config.hpp")
+ endif()
+ FILE(READ "${SFML_CONFIG_HPP_INPUT}" SFML_CONFIG_HPP_CONTENTS)
+ STRING(REGEX REPLACE ".*#define SFML_VERSION_MAJOR ([0-9]+).*" "\\1" SFML_VERSION_MAJOR "${SFML_CONFIG_HPP_CONTENTS}")
+ STRING(REGEX REPLACE ".*#define SFML_VERSION_MINOR ([0-9]+).*" "\\1" SFML_VERSION_MINOR "${SFML_CONFIG_HPP_CONTENTS}")
+ STRING(REGEX REPLACE ".*#define SFML_VERSION_PATCH ([0-9]+).*" "\\1" SFML_VERSION_PATCH "${SFML_CONFIG_HPP_CONTENTS}")
+ if (NOT "${SFML_VERSION_PATCH}" MATCHES "^[0-9]+$")
+ set(SFML_VERSION_PATCH 0)
+ endif()
+ math(EXPR SFML_REQUESTED_VERSION "${SFML_FIND_VERSION_MAJOR} * 10000 + ${SFML_FIND_VERSION_MINOR} * 100 + ${SFML_FIND_VERSION_PATCH}")
+
+ # if we could extract them, compare with the requested version number
+ if (SFML_VERSION_MAJOR)
+ # transform version numbers to an integer
+ math(EXPR SFML_VERSION "${SFML_VERSION_MAJOR} * 10000 + ${SFML_VERSION_MINOR} * 100 + ${SFML_VERSION_PATCH}")
+
+ # compare them
+ if(SFML_VERSION LESS SFML_REQUESTED_VERSION)
+ set(SFML_VERSION_OK FALSE)
+ endif()
+ else()
+ # SFML version is < 2.0
+ if (SFML_REQUESTED_VERSION GREATER 10900)
+ set(SFML_VERSION_OK FALSE)
+ set(SFML_VERSION_MAJOR 1)
+ set(SFML_VERSION_MINOR x)
+ set(SFML_VERSION_PATCH x)
+ endif()
+ endif()
+endif()
+
+# find the requested modules
+set(SFML_FOUND TRUE) # will be set to false if one of the required modules is not found
+foreach(FIND_SFML_COMPONENT ${SFML_FIND_COMPONENTS})
+ string(TOLOWER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_LOWER)
+ string(TOUPPER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_UPPER)
+ set(FIND_SFML_COMPONENT_NAME sfml-${FIND_SFML_COMPONENT_LOWER})
+
+ # no suffix for sfml-main, it is always a static library
+ if(FIND_SFML_COMPONENT_LOWER STREQUAL "main")
+ # release library
+ find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE
+ NAMES ${FIND_SFML_COMPONENT_NAME}
+ PATH_SUFFIXES lib64 lib
+ PATHS ${FIND_SFML_PATHS})
+
+ # debug library
+ find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG
+ NAMES ${FIND_SFML_COMPONENT_NAME}-d
+ PATH_SUFFIXES lib64 lib
+ PATHS ${FIND_SFML_PATHS})
+ else()
+ # static release library
+ find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE
+ NAMES ${FIND_SFML_COMPONENT_NAME}-s
+ PATH_SUFFIXES lib64 lib
+ PATHS ${FIND_SFML_PATHS})
+
+ # static debug library
+ find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG
+ NAMES ${FIND_SFML_COMPONENT_NAME}-s-d
+ PATH_SUFFIXES lib64 lib
+ PATHS ${FIND_SFML_PATHS})
+
+ # dynamic release library
+ find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE
+ NAMES ${FIND_SFML_COMPONENT_NAME}
+ PATH_SUFFIXES lib64 lib
+ PATHS ${FIND_SFML_PATHS})
+
+ # dynamic debug library
+ find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG
+ NAMES ${FIND_SFML_COMPONENT_NAME}-d
+ PATH_SUFFIXES lib64 lib
+ PATHS ${FIND_SFML_PATHS})
+
+ # choose the entries that fit the requested link type
+ if(SFML_STATIC_LIBRARIES)
+ if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE)
+ set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE})
+ endif()
+ if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG)
+ set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG})
+ endif()
+ else()
+ if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE)
+ set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE})
+ endif()
+ if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG)
+ set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG})
+ endif()
+ endif()
+ endif()
+
+ if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG OR SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
+ # library found
+ set(SFML_${FIND_SFML_COMPONENT_UPPER}_FOUND TRUE)
+
+ # if both are found, set SFML_XXX_LIBRARY to contain both
+ if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG AND SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
+ set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY debug ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG}
+ optimized ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
+ endif()
+
+ # if only one debug/release variant is found, set the other to be equal to the found one
+ if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG AND NOT SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
+ # debug and not release
+ set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG})
+ set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG})
+ endif()
+ if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE AND NOT SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG)
+ # release and not debug
+ set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
+ set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
+ endif()
+ else()
+ # library not found
+ set(SFML_FOUND FALSE)
+ set(SFML_${FIND_SFML_COMPONENT_UPPER}_FOUND FALSE)
+ set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY "")
+ set(FIND_SFML_MISSING "${FIND_SFML_MISSING} SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY")
+ endif()
+
+ # mark as advanced
+ MARK_AS_ADVANCED(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY
+ SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE
+ SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG
+ SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE
+ SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG
+ SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE
+ SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG)
+
+ # add to the global list of libraries
+ set(SFML_LIBRARIES ${SFML_LIBRARIES} "${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY}")
+endforeach()
+
+# in case of static linking, we must also define the list of all the dependencies of SFML libraries
+if(SFML_STATIC_LIBRARIES)
+
+ # detect the OS
+ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
+ set(FIND_SFML_OS_WINDOWS 1)
+ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+ set(FIND_SFML_OS_LINUX 1)
+ elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
+ set(FIND_SFML_OS_FREEBSD 1)
+ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ set(FIND_SFML_OS_MACOSX 1)
+ endif()
+
+ # start with an empty list
+ set(SFML_DEPENDENCIES)
+ set(FIND_SFML_DEPENDENCIES_NOTFOUND)
+
+ # macro that searches for a 3rd-party library
+ macro(find_sfml_dependency output friendlyname)
+ # No lookup in environment variables (PATH on Windows), as they may contain wrong library versions
+ find_library(${output} NAMES ${ARGN} PATHS ${FIND_SFML_PATHS} PATH_SUFFIXES lib NO_SYSTEM_ENVIRONMENT_PATH)
+ if(${${output}} STREQUAL "${output}-NOTFOUND")
+ unset(output)
+ set(FIND_SFML_DEPENDENCIES_NOTFOUND "${FIND_SFML_DEPENDENCIES_NOTFOUND} ${friendlyname}")
+ endif()
+ endmacro()
+
+ # sfml-system
+ list(FIND SFML_FIND_COMPONENTS "system" FIND_SFML_SYSTEM_COMPONENT)
+ if(NOT ${FIND_SFML_SYSTEM_COMPONENT} EQUAL -1)
+
+ # update the list -- these are only system libraries, no need to find them
+ if(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD OR FIND_SFML_OS_MACOSX)
+ set(SFML_SYSTEM_DEPENDENCIES "pthread")
+ endif()
+ if(FIND_SFML_OS_LINUX)
+ set(SFML_SYSTEM_DEPENDENCIES ${SFML_SYSTEM_DEPENDENCIES} "rt")
+ endif()
+ if(FIND_SFML_OS_WINDOWS)
+ set(SFML_SYSTEM_DEPENDENCIES "winmm")
+ endif()
+ set(SFML_DEPENDENCIES ${SFML_SYSTEM_DEPENDENCIES} ${SFML_DEPENDENCIES})
+ endif()
+
+ # sfml-network
+ list(FIND SFML_FIND_COMPONENTS "network" FIND_SFML_NETWORK_COMPONENT)
+ if(NOT ${FIND_SFML_NETWORK_COMPONENT} EQUAL -1)
+
+ # update the list -- these are only system libraries, no need to find them
+ if(FIND_SFML_OS_WINDOWS)
+ set(SFML_NETWORK_DEPENDENCIES "ws2_32")
+ endif()
+ set(SFML_DEPENDENCIES ${SFML_NETWORK_DEPENDENCIES} ${SFML_DEPENDENCIES})
+ endif()
+
+ # sfml-window
+ list(FIND SFML_FIND_COMPONENTS "window" FIND_SFML_WINDOW_COMPONENT)
+ if(NOT ${FIND_SFML_WINDOW_COMPONENT} EQUAL -1)
+
+ # find libraries
+ if(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD)
+ find_sfml_dependency(X11_LIBRARY "X11" X11)
+ find_sfml_dependency(LIBXCB_LIBRARIES "XCB" xcb libxcb)
+ find_sfml_dependency(X11_XCB_LIBRARY "X11-xcb" X11-xcb libX11-xcb)
+ find_sfml_dependency(XCB_RANDR_LIBRARY "xcb-randr" xcb-randr libxcb-randr)
+ find_sfml_dependency(XCB_IMAGE_LIBRARY "xcb-image" xcb-image libxcb-image)
+ endif()
+
+ if(FIND_SFML_OS_LINUX)
+ find_sfml_dependency(UDEV_LIBRARIES "UDev" udev libudev)
+ endif()
+
+ # update the list
+ if(FIND_SFML_OS_WINDOWS)
+ set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "opengl32" "winmm" "gdi32")
+ elseif(FIND_SFML_OS_LINUX)
+ set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "GL" ${X11_LIBRARY} ${LIBXCB_LIBRARIES} ${X11_XCB_LIBRARY} ${XCB_RANDR_LIBRARY} ${XCB_IMAGE_LIBRARY} ${UDEV_LIBRARIES})
+ elseif(FIND_SFML_OS_FREEBSD)
+ set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "GL" ${X11_LIBRARY} ${LIBXCB_LIBRARIES} ${X11_XCB_LIBRARY} ${XCB_RANDR_LIBRARY} ${XCB_IMAGE_LIBRARY} "usbhid")
+ elseif(FIND_SFML_OS_MACOSX)
+ set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "-framework OpenGL -framework Foundation -framework AppKit -framework IOKit -framework Carbon")
+ endif()
+ set(SFML_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} ${SFML_DEPENDENCIES})
+ endif()
+
+ # sfml-graphics
+ list(FIND SFML_FIND_COMPONENTS "graphics" FIND_SFML_GRAPHICS_COMPONENT)
+ if(NOT ${FIND_SFML_GRAPHICS_COMPONENT} EQUAL -1)
+
+ # find libraries
+ find_sfml_dependency(FREETYPE_LIBRARY "FreeType" freetype)
+ find_sfml_dependency(JPEG_LIBRARY "libjpeg" jpeg)
+
+ # update the list
+ set(SFML_GRAPHICS_DEPENDENCIES ${FREETYPE_LIBRARY} ${JPEG_LIBRARY})
+ set(SFML_DEPENDENCIES ${SFML_GRAPHICS_DEPENDENCIES} ${SFML_DEPENDENCIES})
+ endif()
+
+ # sfml-audio
+ list(FIND SFML_FIND_COMPONENTS "audio" FIND_SFML_AUDIO_COMPONENT)
+ if(NOT ${FIND_SFML_AUDIO_COMPONENT} EQUAL -1)
+
+ # find libraries
+ find_sfml_dependency(OPENAL_LIBRARY "OpenAL" openal openal32)
+ find_sfml_dependency(OGG_LIBRARY "Ogg" ogg)
+ find_sfml_dependency(VORBIS_LIBRARY "Vorbis" vorbis)
+ find_sfml_dependency(VORBISFILE_LIBRARY "VorbisFile" vorbisfile)
+ find_sfml_dependency(VORBISENC_LIBRARY "VorbisEnc" vorbisenc)
+ find_sfml_dependency(FLAC_LIBRARY "FLAC" FLAC)
+
+ # update the list
+ set(SFML_AUDIO_DEPENDENCIES ${OPENAL_LIBRARY} ${FLAC_LIBRARY} ${VORBISENC_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY})
+ set(SFML_DEPENDENCIES ${SFML_DEPENDENCIES} ${SFML_AUDIO_DEPENDENCIES})
+ endif()
+
+endif()
+
+# handle errors
+if(NOT SFML_VERSION_OK)
+ # SFML version not ok
+ set(FIND_SFML_ERROR "SFML found but version too low (requested: ${SFML_FIND_VERSION}, found: ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR}.${SFML_VERSION_PATCH})")
+ set(SFML_FOUND FALSE)
+elseif(SFML_STATIC_LIBRARIES AND FIND_SFML_DEPENDENCIES_NOTFOUND)
+ set(FIND_SFML_ERROR "SFML found but some of its dependencies are missing (${FIND_SFML_DEPENDENCIES_NOTFOUND})")
+ set(SFML_FOUND FALSE)
+elseif(NOT SFML_FOUND)
+ # include directory or library not found
+ set(FIND_SFML_ERROR "Could NOT find SFML (missing: ${FIND_SFML_MISSING})")
+endif()
+if (NOT SFML_FOUND)
+ if(SFML_FIND_REQUIRED)
+ # fatal error
+ message(FATAL_ERROR ${FIND_SFML_ERROR})
+ elseif(NOT SFML_FIND_QUIETLY)
+ # error but continue
+ message("${FIND_SFML_ERROR}")
+ endif()
+endif()
+
+# handle success
+if(SFML_FOUND AND NOT SFML_FIND_QUIETLY)
+ message(STATUS "Found SFML ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR}.${SFML_VERSION_PATCH} in ${SFML_INCLUDE_DIR}")
+endif()
diff --git a/src/Actions/ActAction.h b/DGEngine.core/src/Actions/ActAction.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActAction.h
rename to DGEngine.core/src/Actions/ActAction.h
diff --git a/src/Actions/ActAnimation.h b/DGEngine.core/src/Actions/ActAnimation.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActAnimation.h
rename to DGEngine.core/src/Actions/ActAnimation.h
diff --git a/src/Actions/ActAudio.h b/DGEngine.core/src/Actions/ActAudio.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActAudio.h
rename to DGEngine.core/src/Actions/ActAudio.h
diff --git a/src/Actions/ActButton.h b/DGEngine.core/src/Actions/ActButton.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActButton.h
rename to DGEngine.core/src/Actions/ActButton.h
diff --git a/src/Actions/ActCondition.h b/DGEngine.core/src/Actions/ActCondition.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActCondition.h
rename to DGEngine.core/src/Actions/ActCondition.h
diff --git a/src/Actions/ActCursor.h b/DGEngine.core/src/Actions/ActCursor.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActCursor.h
rename to DGEngine.core/src/Actions/ActCursor.h
diff --git a/src/Actions/ActDrawable.h b/DGEngine.core/src/Actions/ActDrawable.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActDrawable.h
rename to DGEngine.core/src/Actions/ActDrawable.h
diff --git a/src/Actions/ActEvent.h b/DGEngine.core/src/Actions/ActEvent.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActEvent.h
rename to DGEngine.core/src/Actions/ActEvent.h
diff --git a/src/Actions/ActFade.h b/DGEngine.core/src/Actions/ActFade.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActFade.h
rename to DGEngine.core/src/Actions/ActFade.h
diff --git a/src/Actions/ActFocus.h b/DGEngine.core/src/Actions/ActFocus.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActFocus.h
rename to DGEngine.core/src/Actions/ActFocus.h
diff --git a/src/Actions/ActFont.h b/DGEngine.core/src/Actions/ActFont.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActFont.h
rename to DGEngine.core/src/Actions/ActFont.h
diff --git a/src/Actions/ActGame.h b/DGEngine.core/src/Actions/ActGame.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActGame.h
rename to DGEngine.core/src/Actions/ActGame.h
diff --git a/src/Actions/ActIO.h b/DGEngine.core/src/Actions/ActIO.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActIO.h
rename to DGEngine.core/src/Actions/ActIO.h
diff --git a/src/Actions/ActImage.h b/DGEngine.core/src/Actions/ActImage.h
old mode 100755
new mode 100644
similarity index 97%
rename from src/Actions/ActImage.h
rename to DGEngine.core/src/Actions/ActImage.h
index 2bce1edb..cc3b2f56
--- a/src/Actions/ActImage.h
+++ b/DGEngine.core/src/Actions/ActImage.h
@@ -183,11 +183,11 @@ class ActImageSetTextureFromPack : public Action
private:
std::string id;
std::string idTexturePack;
- size_t textureIdx;
+ uint32_t textureIdx;
public:
ActImageSetTextureFromPack(const std::string_view id_,
- const std::string_view idTexturePack_, size_t textureIdx_)
+ const std::string_view idTexturePack_, uint32_t textureIdx_)
: id(id_), idTexturePack(idTexturePack_), textureIdx(textureIdx_) {}
bool execute(Game& game) override
@@ -214,11 +214,11 @@ class ActImageSetTextureFromQueryable : public Action
private:
std::string id;
std::string query;
- size_t textureIdx;
+ uint32_t textureIdx;
public:
ActImageSetTextureFromQueryable(const std::string_view id_,
- const std::string_view query_, size_t textureIdx_)
+ const std::string_view query_, uint32_t textureIdx_)
: id(id_), query(query_), textureIdx(textureIdx_) {}
bool execute(Game& game) override
diff --git a/src/Actions/ActInputText.h b/DGEngine.core/src/Actions/ActInputText.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActInputText.h
rename to DGEngine.core/src/Actions/ActInputText.h
diff --git a/src/Actions/ActLoad.h b/DGEngine.core/src/Actions/ActLoad.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActLoad.h
rename to DGEngine.core/src/Actions/ActLoad.h
diff --git a/src/Actions/ActLoadingScreen.h b/DGEngine.core/src/Actions/ActLoadingScreen.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActLoadingScreen.h
rename to DGEngine.core/src/Actions/ActLoadingScreen.h
diff --git a/src/Actions/ActMenu.h b/DGEngine.core/src/Actions/ActMenu.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActMenu.h
rename to DGEngine.core/src/Actions/ActMenu.h
diff --git a/src/Actions/ActMount.h b/DGEngine.core/src/Actions/ActMount.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActMount.h
rename to DGEngine.core/src/Actions/ActMount.h
diff --git a/src/Actions/ActMovie.h b/DGEngine.core/src/Actions/ActMovie.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActMovie.h
rename to DGEngine.core/src/Actions/ActMovie.h
diff --git a/src/Actions/ActPalette.h b/DGEngine.core/src/Actions/ActPalette.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActPalette.h
rename to DGEngine.core/src/Actions/ActPalette.h
diff --git a/src/Actions/ActRandom.h b/DGEngine.core/src/Actions/ActRandom.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActRandom.h
rename to DGEngine.core/src/Actions/ActRandom.h
diff --git a/src/Actions/ActResource.h b/DGEngine.core/src/Actions/ActResource.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActResource.h
rename to DGEngine.core/src/Actions/ActResource.h
diff --git a/src/Actions/ActScrollable.h b/DGEngine.core/src/Actions/ActScrollable.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActScrollable.h
rename to DGEngine.core/src/Actions/ActScrollable.h
diff --git a/src/Actions/ActShader.h b/DGEngine.core/src/Actions/ActShader.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActShader.h
rename to DGEngine.core/src/Actions/ActShader.h
diff --git a/src/Actions/ActSound.h b/DGEngine.core/src/Actions/ActSound.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActSound.h
rename to DGEngine.core/src/Actions/ActSound.h
diff --git a/src/Actions/ActText.h b/DGEngine.core/src/Actions/ActText.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActText.h
rename to DGEngine.core/src/Actions/ActText.h
diff --git a/src/Actions/ActVariable.h b/DGEngine.core/src/Actions/ActVariable.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActVariable.h
rename to DGEngine.core/src/Actions/ActVariable.h
diff --git a/src/Actions/ActVisibility.h b/DGEngine.core/src/Actions/ActVisibility.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActVisibility.h
rename to DGEngine.core/src/Actions/ActVisibility.h
diff --git a/src/Actions/Action.h b/DGEngine.core/src/Actions/Action.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/Action.h
rename to DGEngine.core/src/Actions/Action.h
diff --git a/src/Actions/ActiontList.h b/DGEngine.core/src/Actions/ActiontList.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Actions/ActiontList.h
rename to DGEngine.core/src/Actions/ActiontList.h
diff --git a/src/Alignment.h b/DGEngine.core/src/Alignment.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Alignment.h
rename to DGEngine.core/src/Alignment.h
diff --git a/src/Anchor.h b/DGEngine.core/src/Anchor.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Anchor.h
rename to DGEngine.core/src/Anchor.h
diff --git a/src/Animation.cpp b/DGEngine.core/src/Animation.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/Animation.cpp
rename to DGEngine.core/src/Animation.cpp
diff --git a/src/Animation.h b/DGEngine.core/src/Animation.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Animation.h
rename to DGEngine.core/src/Animation.h
diff --git a/src/AnimationInfo.h b/DGEngine.core/src/AnimationInfo.h
similarity index 100%
rename from src/AnimationInfo.h
rename to DGEngine.core/src/AnimationInfo.h
diff --git a/src/AnimationType.h b/DGEngine.core/src/AnimationType.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/AnimationType.h
rename to DGEngine.core/src/AnimationType.h
diff --git a/src/AudioSource.h b/DGEngine.core/src/AudioSource.h
old mode 100755
new mode 100644
similarity index 94%
rename from src/AudioSource.h
rename to DGEngine.core/src/AudioSource.h
index abc2f1c5..717fce44
--- a/src/AudioSource.h
+++ b/DGEngine.core/src/AudioSource.h
@@ -24,7 +24,7 @@ struct SoundFileLoops
typedef std::variant<
std::shared_ptr,
- std::shared_ptr,
+ std::shared_ptr,
std::shared_ptr,
std::shared_ptr>
AudioSource;
diff --git a/src/BaseAnimation.cpp b/DGEngine.core/src/BaseAnimation.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/BaseAnimation.cpp
rename to DGEngine.core/src/BaseAnimation.cpp
diff --git a/src/BaseAnimation.h b/DGEngine.core/src/BaseAnimation.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/BaseAnimation.h
rename to DGEngine.core/src/BaseAnimation.h
diff --git a/src/BindableText.cpp b/DGEngine.core/src/BindableText.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/BindableText.cpp
rename to DGEngine.core/src/BindableText.cpp
diff --git a/src/BindableText.h b/DGEngine.core/src/BindableText.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/BindableText.h
rename to DGEngine.core/src/BindableText.h
diff --git a/src/BindingFlags.h b/DGEngine.core/src/BindingFlags.h
similarity index 100%
rename from src/BindingFlags.h
rename to DGEngine.core/src/BindingFlags.h
diff --git a/src/BitmapButton.cpp b/DGEngine.core/src/BitmapButton.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/BitmapButton.cpp
rename to DGEngine.core/src/BitmapButton.cpp
diff --git a/src/BitmapButton.h b/DGEngine.core/src/BitmapButton.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/BitmapButton.h
rename to DGEngine.core/src/BitmapButton.h
diff --git a/src/BitmapFont.cpp b/DGEngine.core/src/BitmapFont.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/BitmapFont.cpp
rename to DGEngine.core/src/BitmapFont.cpp
diff --git a/src/BitmapFont.h b/DGEngine.core/src/BitmapFont.h
old mode 100755
new mode 100644
similarity index 95%
rename from src/BitmapFont.h
rename to DGEngine.core/src/BitmapFont.h
index 47c954d5..bca03cf8
--- a/src/BitmapFont.h
+++ b/DGEngine.core/src/BitmapFont.h
@@ -12,7 +12,7 @@ class TexturePack;
class BitmapFont
{
-private:
+protected:
std::shared_ptr texturePack;
std::shared_ptr palette;
sf::Color defaultColor{ sf::Color::White };
@@ -32,6 +32,7 @@ class BitmapFont
public:
BitmapFont(const std::shared_ptr& texturePack_,
int16_t newLine_, int16_t space_, int16_t tab_);
+ virtual ~BitmapFont() = default;
int getNewLine() const noexcept { return newLine; }
@@ -51,7 +52,7 @@ class BitmapFont
const std::string_view text, sf::Color color, int horizSpaceOffset,
int vertSpaceOffset, float sizeX, HorizontalAlign align) const;
- void draw(const VertexArray2& vertexText,
+ virtual void draw(const VertexArray2& vertexText,
const sf::Vector2f& pos, const sf::Vector2f& size,
GameShader* spriteShader, sf::RenderTarget& target) const;
};
diff --git a/src/BitmapText.cpp b/DGEngine.core/src/BitmapText.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/BitmapText.cpp
rename to DGEngine.core/src/BitmapText.cpp
diff --git a/src/BitmapText.h b/DGEngine.core/src/BitmapText.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/BitmapText.h
rename to DGEngine.core/src/BitmapText.h
diff --git a/src/BlendMode.h b/DGEngine.core/src/BlendMode.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/BlendMode.h
rename to DGEngine.core/src/BlendMode.h
diff --git a/src/Button.cpp b/DGEngine.core/src/Button.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/Button.cpp
rename to DGEngine.core/src/Button.cpp
diff --git a/src/Button.h b/DGEngine.core/src/Button.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Button.h
rename to DGEngine.core/src/Button.h
diff --git a/src/CachedImagePack.cpp b/DGEngine.core/src/CachedImagePack.cpp
old mode 100755
new mode 100644
similarity index 83%
rename from src/CachedImagePack.cpp
rename to DGEngine.core/src/CachedImagePack.cpp
index 2242c0dc..096f4cb3
--- a/src/CachedImagePack.cpp
+++ b/DGEngine.core/src/CachedImagePack.cpp
@@ -7,14 +7,13 @@ CachedImagePack::CachedImagePack(const ImageContainer* imgContainer_,
{
cache.resize(imgContainer_->size());
- if (isIndexed == false &&
- palette == nullptr)
+ if (isIndexed == false && palette == nullptr)
{
isIndexed = true;
}
}
-sf::Image& CachedImagePack::operator[] (size_t index)
+sf::Image& CachedImagePack::operator[] (uint32_t index)
{
assert(index < imgContainer->size());
if (cache[index].has_value() == false)
diff --git a/src/CachedImagePack.h b/DGEngine.core/src/CachedImagePack.h
old mode 100755
new mode 100644
similarity index 78%
rename from src/CachedImagePack.h
rename to DGEngine.core/src/CachedImagePack.h
index 38246505..1ad7a17b
--- a/src/CachedImagePack.h
+++ b/DGEngine.core/src/CachedImagePack.h
@@ -19,11 +19,11 @@ class CachedImagePack
CachedImagePack(const ImageContainer* imgContainer_,
const std::shared_ptr& palette_, bool isIndexed_ = false);
- sf::Image& get(size_t index) { return (*this)[index]; }
+ sf::Image& get(uint32_t index) { return (*this)[index]; }
- sf::Image& operator[] (size_t index);
+ sf::Image& operator[] (uint32_t index);
const std::shared_ptr& getPalette() const noexcept { return palette; }
bool IsIndexed() const noexcept { return isIndexed; }
- size_t size() const noexcept { return imgContainer->size(); }
+ uint32_t size() const noexcept { return imgContainer->size(); }
};
diff --git a/src/Circle.cpp b/DGEngine.core/src/Circle.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/Circle.cpp
rename to DGEngine.core/src/Circle.cpp
diff --git a/src/Circle.h b/DGEngine.core/src/Circle.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Circle.h
rename to DGEngine.core/src/Circle.h
diff --git a/DGEngine.core/src/CmdLineUtils.cpp b/DGEngine.core/src/CmdLineUtils.cpp
new file mode 100644
index 00000000..c33766ad
--- /dev/null
+++ b/DGEngine.core/src/CmdLineUtils.cpp
@@ -0,0 +1,48 @@
+#include "CmdLineUtils.h"
+#include "GameUtils.h"
+#include "FileUtils.h"
+#include "Utils/Utils.h"
+
+namespace CmdLineUtils
+{
+ bool processCmdLine(int argc, const char* argv[])
+ {
+ if (argc < 4)
+ {
+ // no export options
+ return false;
+ }
+
+ auto mountFiles = Utils::splitString({ argv[2] }, '|');
+ size_t numMountedFiles = 0;
+
+ for (const auto& mountFile : mountFiles)
+ {
+ if (FileUtils::mount(mountFile, "", false) == true)
+ {
+ numMountedFiles++;
+ }
+ }
+ if (numMountedFiles == 0)
+ {
+ return true;
+ }
+
+ auto commandStr = Utils::splitStringIn2(std::string_view(argv[1]), ':');
+
+ switch (str2int16(commandStr.first))
+ {
+ case str2int16("--export"):
+ {
+ if (FileUtils::exists(argv[3]) == true)
+ {
+ FileUtils::exportFile(argv[3], argv[4]);
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ return true;
+ }
+}
diff --git a/src/CmdLineUtils.h b/DGEngine.core/src/CmdLineUtils.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/CmdLineUtils.h
rename to DGEngine.core/src/CmdLineUtils.h
diff --git a/src/DrawableText.h b/DGEngine.core/src/DrawableText.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/DrawableText.h
rename to DGEngine.core/src/DrawableText.h
diff --git a/src/Event.cpp b/DGEngine.core/src/Event.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/Event.cpp
rename to DGEngine.core/src/Event.cpp
diff --git a/src/Event.h b/DGEngine.core/src/Event.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Event.h
rename to DGEngine.core/src/Event.h
diff --git a/src/EventManager.h b/DGEngine.core/src/EventManager.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/EventManager.h
rename to DGEngine.core/src/EventManager.h
diff --git a/src/FadeInOut.cpp b/DGEngine.core/src/FadeInOut.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/FadeInOut.cpp
rename to DGEngine.core/src/FadeInOut.cpp
diff --git a/src/FadeInOut.h b/DGEngine.core/src/FadeInOut.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/FadeInOut.h
rename to DGEngine.core/src/FadeInOut.h
diff --git a/src/FileBytes.h b/DGEngine.core/src/FileBytes.h
similarity index 100%
rename from src/FileBytes.h
rename to DGEngine.core/src/FileBytes.h
diff --git a/src/FileUtils.cpp b/DGEngine.core/src/FileUtils.cpp
old mode 100755
new mode 100644
similarity index 89%
rename from src/FileUtils.cpp
rename to DGEngine.core/src/FileUtils.cpp
index 8f1a63c4..7606efa6
--- a/src/FileUtils.cpp
+++ b/DGEngine.core/src/FileUtils.cpp
@@ -1,13 +1,11 @@
#include "FileUtils.h"
#include
#include
-#include
#include
+#include "Hooks.h"
+#include
#include "SFML/PhysFSStream.h"
#include "Utils/Utils.h"
-#ifdef PHYSFS_MPQ_SUPPORT
-#include "PhysFSArchiverMPQ.h"
-#endif
namespace FileUtils
{
@@ -17,9 +15,10 @@ namespace FileUtils
deinitPhysFS();
if (PHYSFS_init(mainArgv0) != 0)
{
-#ifdef PHYSFS_MPQ_SUPPORT
- PHYSFS_registerArchiver(&PHYSFS_Archiver_MPQ);
-#endif
+ if (Hooks::RegisterArchivers != nullptr)
+ {
+ Hooks::RegisterArchivers();
+ }
PHYSFS_permitSymbolicLinks(1);
}
}
@@ -51,22 +50,13 @@ namespace FileUtils
return true;
}
}
-#ifdef PHYSFS_MPQ_SUPPORT
- path = path.replace_extension(".mpq");
- if (std::filesystem::exists(path) == true)
- {
- return true;
- }
-#endif
- path = path.replace_extension(".zip");
- if (std::filesystem::exists(path) == true)
- {
- return true;
- }
- path = path.replace_extension(".7z");
- if (std::filesystem::exists(path) == true)
+ for (const auto& ext : Hooks::ArchiveExtensions)
{
- return true;
+ path = path.replace_extension(ext);
+ if (std::filesystem::exists(path) == true)
+ {
+ return true;
+ }
}
}
catch (std::exception&) {}
@@ -94,22 +84,13 @@ namespace FileUtils
return true;
}
}
-#ifdef PHYSFS_MPQ_SUPPORT
- path = path.replace_extension(".mpq");
- if (PHYSFS_mount((const char*)path.u8string().c_str(), mountPoint.data(), append) != 0)
- {
- return true;
- }
-#endif
- path = path.replace_extension(".zip");
- if (PHYSFS_mount((const char*)path.u8string().c_str(), mountPoint.data(), append) != 0)
- {
- return true;
- }
- path = path.replace_extension(".7z");
- if (PHYSFS_mount((const char*)path.u8string().c_str(), mountPoint.data(), append) != 0)
+ for (const auto& ext : Hooks::ArchiveExtensions)
{
- return true;
+ path = path.replace_extension(ext);
+ if (PHYSFS_mount((const char*)path.u8string().c_str(), mountPoint.data(), append) != 0)
+ {
+ return true;
+ }
}
}
catch (std::exception&) {}
@@ -135,22 +116,13 @@ namespace FileUtils
return true;
}
}
-#ifdef PHYSFS_MPQ_SUPPORT
- path = path.replace_extension(".mpq");
- if (PHYSFS_unmount((const char*)path.u8string().c_str()) != 0)
+ for (const auto& ext : Hooks::ArchiveExtensions)
{
- return true;
- }
-#endif
- path = path.replace_extension(".zip");
- if (PHYSFS_unmount((const char*)path.u8string().c_str()) != 0)
- {
- return true;
- }
- path = path.replace_extension(".7z");
- if (PHYSFS_unmount((const char*)path.u8string().c_str()) != 0)
- {
- return true;
+ path = path.replace_extension(ext);
+ if (PHYSFS_unmount((const char*)path.u8string().c_str()) != 0)
+ {
+ return true;
+ }
}
}
catch (std::exception&) {}
diff --git a/src/FileUtils.h b/DGEngine.core/src/FileUtils.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/FileUtils.h
rename to DGEngine.core/src/FileUtils.h
diff --git a/src/Font.h b/DGEngine.core/src/Font.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Font.h
rename to DGEngine.core/src/Font.h
diff --git a/src/Formula.cpp b/DGEngine.core/src/Formula.cpp
similarity index 100%
rename from src/Formula.cpp
rename to DGEngine.core/src/Formula.cpp
diff --git a/src/Formula.h b/DGEngine.core/src/Formula.h
similarity index 100%
rename from src/Formula.h
rename to DGEngine.core/src/Formula.h
diff --git a/src/Formulas.h b/DGEngine.core/src/Formulas.h
similarity index 100%
rename from src/Formulas.h
rename to DGEngine.core/src/Formulas.h
diff --git a/src/FreeTypeFont.h b/DGEngine.core/src/FreeTypeFont.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/FreeTypeFont.h
rename to DGEngine.core/src/FreeTypeFont.h
diff --git a/src/Game.cpp b/DGEngine.core/src/Game.cpp
old mode 100755
new mode 100644
similarity index 88%
rename from src/Game.cpp
rename to DGEngine.core/src/Game.cpp
index 4ee4f22c..3e3b926d
--- a/src/Game.cpp
+++ b/DGEngine.core/src/Game.cpp
@@ -2,8 +2,7 @@
#include "Button.h"
#include "FileUtils.h"
#include "Formula.h"
-#include "Game/Level.h"
-#include "GameConstants.h"
+#include "Hooks.h"
#include "Image.h"
#include "Json/JsonUtils.h"
#include
@@ -14,6 +13,15 @@
#include "Utils/ReverseIterable.h"
#include "Utils/Utils.h"
+uint32_t Game::DefaultSizeX{ 640 };
+uint32_t Game::DefaultSizeY{ 480 };
+
+uint32_t Game::MinSizeX{ 640 };
+uint32_t Game::MinSizeY{ 480 };
+
+uint32_t Game::RefSizeX{ 640 };
+uint32_t Game::RefSizeY{ 480 };
+
Game::Game()
{
static std::once_flag initWave2;
@@ -33,10 +41,10 @@ void Game::reset()
{
gameSprite = {};
- refSize = { DGENGINE_REF_SIZE_X, DGENGINE_REF_SIZE_Y };
- minSize = { DGENGINE_MIN_SIZE_X, DGENGINE_MIN_SIZE_Y };
- size = { DGENGINE_DEFAULT_SIZE_X, DGENGINE_DEFAULT_SIZE_Y };
- drawRegionSize = { DGENGINE_DEFAULT_SIZE_X, DGENGINE_DEFAULT_SIZE_Y };
+ refSize = { RefSizeX, RefSizeY };
+ minSize = { MinSizeX, MinSizeY };
+ size = { DefaultSizeX, DefaultSizeY };
+ drawRegionSize = { DefaultSizeX, DefaultSizeY };
oldDrawRegionSize = {};
maxHeight = { 0 };
framerate = { 0 };
@@ -81,7 +89,14 @@ void Game::reset()
version = {};
resourceManager = {};
- resourceManager.Shaders().init();
+ if (Hooks::InitializeShaderManager != nullptr)
+ {
+ Hooks::InitializeShaderManager(resourceManager.Shaders());
+ }
+ else
+ {
+ ShaderManager::init(resourceManager.Shaders());
+ }
resourceManager.Shaders().init(shaders);
variables = {};
@@ -141,7 +156,7 @@ void Game::WindowSize(sf::Vector2u size_)
void Game::RefSize(const sf::Vector2u& size_)
{
- if (size_.x >= DGENGINE_REF_SIZE_X && size_.y >= DGENGINE_REF_SIZE_Y)
+ if (size_.x >= RefSizeX && size_.y >= RefSizeY)
{
refSize = size_;
}
@@ -150,7 +165,7 @@ void Game::RefSize(const sf::Vector2u& size_)
void Game::MinSize(const sf::Vector2u& size_)
{
bool needsUpdate = false;
- if (size_.x >= DGENGINE_MIN_SIZE_X && size_.y >= DGENGINE_MIN_SIZE_Y)
+ if (size_.x >= MinSizeX && size_.y >= MinSizeY)
{
minSize = size_;
if (window.isOpen() == true)
@@ -1109,67 +1124,79 @@ bool Game::getProperty(const std::string_view prop, Variable& var) const
return getVariableNoToken(prop.substr(1), var);
}
auto props = Utils::splitStringIn2(prop, '.');
- switch (str2int16(props.first))
+ return getProperty(props.first, props.second, var);
+}
+
+bool Game::getProperty(const std::string_view prop1, const std::string_view prop2, Variable& var) const
+{
+ switch (str2int16(prop1))
{
case str2int16("$"):
case str2int16("eval"):
- var = Variable((int64_t)Formula::evalString(props.second, *this));
+ var = Variable((int64_t)Formula::evalString(prop2, *this));
return true;
case str2int16("evalMin"):
- var = Variable((int64_t)Formula::evalMinString(props.second, *this));
+ var = Variable((int64_t)Formula::evalMinString(prop2, *this));
return true;
case str2int16("evalMax"):
- var = Variable((int64_t)Formula::evalMaxString(props.second, *this));
+ var = Variable((int64_t)Formula::evalMaxString(prop2, *this));
return true;
case str2int16("$f"):
case str2int16("evalf"):
- var = Variable(Formula::evalString(props.second, *this));
+ var = Variable(Formula::evalString(prop2, *this));
return true;
case str2int16("evalMinf"):
- var = Variable(Formula::evalMinString(props.second, *this));
+ var = Variable(Formula::evalMinString(prop2, *this));
return true;
case str2int16("evalMaxf"):
- var = Variable(Formula::evalMaxString(props.second, *this));
+ var = Variable(Formula::evalMaxString(prop2, *this));
return true;
case str2int16("game"):
+ {
+ if (prop2.size() > 1)
+ {
+ return getGameProperty(prop2, var);
+ }
break;
+ }
default:
{
const UIObject* uiObject = nullptr;
- if (props.first == "currentLevel")
+ if (prop1 == "currentLevel")
{
- uiObject = resourceManager.getCurrentLevel();
+ uiObject = resourceManager.getCurrentLevel();
}
- else if (props.first == "focus")
+ else if (prop1 == "focus")
{
uiObject = resourceManager.getFocused();
}
else
{
- uiObject = resourceManager.getDrawable(props.first);
+ uiObject = resourceManager.getDrawable(prop1);
}
if (uiObject != nullptr)
{
- return uiObject->getProperty(props.second, var);
+ return uiObject->getProperty(prop2, var);
}
- return false;
- }
+ break;
}
- if (props.second.size() <= 1)
- {
- return false;
}
- return getGameProperty(props.second, var);
+ return false;
}
bool Game::getGameProperty(const std::string_view prop, Variable& var) const
{
auto props = Utils::splitStringIn2(prop, '.');
- switch (str2int16(props.first))
+ return getGameProperty(props.first, props.second, var);
+}
+
+bool Game::getGameProperty(const std::string_view prop1, const std::string_view prop2, Variable& var) const
+{
+ switch (str2int16(prop1))
{
case str2int16("cursor"):
{
- if (props.second == "x")
+ if (prop2 == "x")
{
var = Variable((int64_t)mousePositioni.x);
}
@@ -1186,56 +1213,53 @@ bool Game::getGameProperty(const std::string_view prop, Variable& var) const
var = Variable((int64_t)gamma);
break;
case str2int16("hasAudio"):
- var = Variable(resourceManager.hasAudioSource(props.second));
+ var = Variable(resourceManager.hasAudioSource(prop2));
break;
case str2int16("hasDrawable"):
- var = Variable(resourceManager.hasDrawable(props.second));
+ var = Variable(resourceManager.hasDrawable(prop2));
break;
case str2int16("hasEvent"):
- var = Variable(eventManager.exists(props.second));
+ var = Variable(eventManager.exists(prop2));
break;
case str2int16("hasFont"):
- var = Variable(resourceManager.hasFont(props.second));
+ var = Variable(resourceManager.hasFont(prop2));
break;
case str2int16("hasGameShader"):
var = Variable(shaders.hasGameShader());
break;
case str2int16("hasImageContainer"):
- var = Variable(resourceManager.hasImageContainer(props.second));
+ var = Variable(resourceManager.hasImageContainer(prop2));
break;
case str2int16("hasPalette"):
- var = Variable(resourceManager.hasPalette(props.second));
+ var = Variable(resourceManager.hasPalette(prop2));
break;
case str2int16("hasResource"):
- var = Variable(resourceManager.resourceExists(props.second));
+ var = Variable(resourceManager.resourceExists(prop2));
break;
case str2int16("hasShader"):
- var = Variable(resourceManager.Shaders().has(props.second));
+ var = Variable(resourceManager.Shaders().has(prop2));
break;
case str2int16("hasSong"):
- var = Variable(resourceManager.hasSong(props.second));
+ var = Variable(resourceManager.hasSong(prop2));
break;
case str2int16("hasSpriteShader"):
var = Variable(shaders.hasSpriteShader());
break;
case str2int16("hasTexture"):
- var = Variable(resourceManager.hasTexture(props.second));
+ var = Variable(resourceManager.hasTexture(prop2));
break;
case str2int16("hasTexturePack"):
- var = Variable(resourceManager.hasTexturePack(props.second));
+ var = Variable(resourceManager.hasTexturePack(prop2));
break;
case str2int16("keepAR"):
var = Variable(keepAR);
break;
- case str2int16("maxLights"):
- var = Variable((int64_t)LevelMap::MaxLights());
- break;
case str2int16("maxWindowHeight"):
var = Variable((int64_t)maxHeight);
break;
case str2int16("minSize"):
{
- if (props.second == "x")
+ if (prop2 == "x")
{
var = Variable((int64_t)minSize.x);
}
@@ -1247,7 +1271,7 @@ bool Game::getGameProperty(const std::string_view prop, Variable& var) const
}
case str2int16("openGL"):
{
- switch (str2int16(props.second))
+ switch (str2int16(prop2))
{
case str2int16("antialiasingLevel"):
var = Variable((int64_t)getOpenGLAntialiasingLevel());
@@ -1289,7 +1313,7 @@ bool Game::getGameProperty(const std::string_view prop, Variable& var) const
break;
case str2int16("refSize"):
{
- if (props.second == "x")
+ if (prop2 == "x")
{
var = Variable((int64_t)refSize.x);
}
@@ -1304,7 +1328,7 @@ bool Game::getGameProperty(const std::string_view prop, Variable& var) const
break;
case str2int16("size"):
{
- if (props.second == "x")
+ if (prop2 == "x")
{
var = Variable((int64_t)size.x);
}
@@ -1367,14 +1391,6 @@ void Game::setGameProperty(const std::string_view prop, const Variable& val)
}
}
break;
- case str2int16("maxLights"):
- {
- if (std::holds_alternative(val) == true)
- {
- LevelMap::MaxLights((size_t)std::get(val));
- }
- }
- break;
case str2int16("maxWindowHeight"):
{
if (std::holds_alternative(val) == true)
@@ -1438,28 +1454,31 @@ const Queryable* Game::getQueryable(const std::string_view prop) const
return this;
}
auto props = Utils::splitStringIn2(prop, '.');
- if (props.first.empty() == true ||
- props.first == "game")
+ return getQueryable(props.first, props.second);
+}
+
+const Queryable* Game::getQueryable(const std::string_view prop1, const std::string_view prop2) const
+{
+ if (prop1.empty() == true || prop1 == "game")
{
return this;
}
const Queryable* queryable = nullptr;
- if (props.first == "currentLevel")
+ if (prop1 == "currentLevel")
{
- queryable = resourceManager.getCurrentLevel();
+ queryable = resourceManager.getCurrentLevel();
}
- else if (props.first == "focus")
+ else if (prop1 == "focus")
{
queryable = resourceManager.getFocused();
}
else
{
- queryable = resourceManager.getDrawable(props.first);
+ queryable = resourceManager.getDrawable(prop1);
}
- if (queryable != nullptr &&
- props.second.empty() == false)
+ if (queryable != nullptr && prop2.empty() == false)
{
- return queryable->getQueryable(props.second);
+ return queryable->getQueryable(prop2);
}
return queryable;
}
@@ -1467,59 +1486,50 @@ const Queryable* Game::getQueryable(const std::string_view prop) const
std::vector> Game::getQueryableList(
const std::string_view prop) const
{
- std::vector> queriableList;
-
- if (prop.empty() == true)
+ std::vector> queryableList;
+ if (prop.empty() == false)
{
- return queriableList;
+ auto props = Utils::splitStringIn2(prop, '.');
+ getQueryableList(props.first, props.second, queryableList);
}
- auto props = Utils::splitStringIn2(prop, '.');
- if (props.first.empty() == false)
+ return queryableList;
+}
+
+bool Game::getQueryableList(const std::string_view prop1, const std::string_view prop2,
+ std::vector>& queryableList) const
+{
+ if (prop1.empty() == false)
{
- if (props.first == "game")
+ if (prop1 == "game")
{
- auto props2 = Utils::splitStringIn2(props.second, '.');
- if (props2.first == "saveDirs")
+ auto props = Utils::splitStringIn2(prop2, '.');
+ if (props.first == "saveDirs")
{
for (const auto& dir : FileUtils::getSaveDirList())
{
- queriableList.push_back({ dir });
+ queryableList.push_back({ dir });
}
+ return true;
}
- else if (props2.first == "dirs")
+ else if (props.first == "dirs")
{
- for (const auto& dir : FileUtils::geDirList(props2.second, ""))
+ for (const auto& dir : FileUtils::geDirList(props.second, ""))
{
- queriableList.push_back({ dir });
+ queryableList.push_back({ dir });
}
+ return true;
}
- else if (props2.first == "files")
+ else if (props.first == "files")
{
- for (const auto& dir : FileUtils::getFileList(props2.second, "", false))
+ for (const auto& dir : FileUtils::getFileList(props.second, "", false))
{
- queriableList.push_back({ dir });
+ queryableList.push_back({ dir });
}
- }
- }
- else
- {
- Level* level = nullptr;
- if (props.first == "currentLevel")
- {
- level = resourceManager.getCurrentLevel();
- }
- else
- {
- level = resourceManager.getDrawable(props.first);
- }
- if (level != nullptr &&
- props.second.empty() == false)
- {
- return level->getQueryableList(props.second);
+ return true;
}
}
}
- return queriableList;
+ return false;
}
void Game::setShader(const std::string_view id, GameShader* shader) noexcept
diff --git a/src/Game.h b/DGEngine.core/src/Game.h
old mode 100755
new mode 100644
similarity index 93%
rename from src/Game.h
rename to DGEngine.core/src/Game.h
index c651fe8d..2cf111dd
--- a/src/Game.h
+++ b/DGEngine.core/src/Game.h
@@ -15,7 +15,17 @@
class Game : public sf::NonCopyable, public Queryable
{
-private:
+public:
+ static uint32_t DefaultSizeX;
+ static uint32_t DefaultSizeY;
+
+ static uint32_t MinSizeX;
+ static uint32_t MinSizeY;
+
+ static uint32_t RefSizeX;
+ static uint32_t RefSizeY;
+
+protected:
sf::RenderWindow window;
sf::RenderTexture gameTexture;
sf::Sprite gameSprite;
@@ -127,7 +137,7 @@ class Game : public sf::NonCopyable, public Queryable
public:
Game();
- ~Game();
+ virtual ~Game();
void load(const std::string_view gamefilePath, const std::string_view mainFile);
void init();
@@ -318,11 +328,25 @@ class Game : public sf::NonCopyable, public Queryable
std::shared_ptr getQueryAction(const std::string_view prop) const;
bool getProperty(const std::string_view prop, Variable& var) const override;
+
+ virtual bool getProperty(const std::string_view prop1,
+ const std::string_view prop2, Variable& var) const;
+
bool getGameProperty(const std::string_view prop, Variable& var) const;
- void setGameProperty(const std::string_view prop, const Variable& val);
+
+ virtual bool getGameProperty(const std::string_view prop1,
+ const std::string_view prop2, Variable& var) const;
+
+ virtual void setGameProperty(const std::string_view prop, const Variable& val);
const Queryable* getQueryable(const std::string_view prop) const override;
+ virtual const Queryable* getQueryable(const std::string_view prop1,
+ const std::string_view prop2) const;
+
std::vector> getQueryableList(
const std::string_view prop) const;
+
+ virtual bool getQueryableList(const std::string_view prop1, const std::string_view prop2,
+ std::vector>& queryableList) const;
};
diff --git a/src/Game/Save/SaveProperties.h b/DGEngine.core/src/Game/Save/SaveProperties.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Game/Save/SaveProperties.h
rename to DGEngine.core/src/Game/Save/SaveProperties.h
diff --git a/src/Game/Save/SaveUtils.cpp b/DGEngine.core/src/Game/Save/SaveUtils.cpp
old mode 100755
new mode 100644
similarity index 83%
rename from src/Game/Save/SaveUtils.cpp
rename to DGEngine.core/src/Game/Save/SaveUtils.cpp
index 079a32f2..1289cbd0
--- a/src/Game/Save/SaveUtils.cpp
+++ b/DGEngine.core/src/Game/Save/SaveUtils.cpp
@@ -52,49 +52,49 @@ namespace SaveUtils
void writeBool(PrettyWriter& writer,
const std::string_view key, bool val)
{
- writer.Key(key.data(), key.size());
+ writer.Key(key.data(), (SizeType)key.size());
writer.Bool(val);
}
void writeInt(PrettyWriter& writer,
const std::string_view key, int val)
{
- writer.Key(key.data(), key.size());
+ writer.Key(key.data(), (SizeType)key.size());
writer.Int(val);
}
void writeInt64(PrettyWriter& writer,
const std::string_view key, int64_t val)
{
- writer.Key(key.data(), key.size());
+ writer.Key(key.data(), (SizeType)key.size());
writer.Int64(val);
}
void writeUInt(PrettyWriter& writer,
const std::string_view key, unsigned val)
{
- writer.Key(key.data(), key.size());
+ writer.Key(key.data(), (SizeType)key.size());
writer.Uint(val);
}
void writeUInt64(PrettyWriter& writer,
const std::string_view key, uint64_t val)
{
- writer.Key(key.data(), key.size());
+ writer.Key(key.data(), (SizeType)key.size());
writer.Uint64(val);
}
void writeDouble(PrettyWriter& writer,
const std::string_view key, double val)
{
- writer.Key(key.data(), key.size());
+ writer.Key(key.data(), (SizeType)key.size());
writer.Double(val);
}
void writeNumber32(PrettyWriter& writer,
const std::string_view key, const Number32& val)
{
- writer.Key(key.data(), key.size());
+ writer.Key(key.data(), (SizeType)key.size());
if (val.isInt32() == true)
{
writer.Int(val.getInt32());
@@ -118,21 +118,21 @@ namespace SaveUtils
void writeKeyStringView(PrettyWriter& writer,
const std::string_view key)
{
- writer.Key(key.data(), key.size());
+ writer.Key(key.data(), (SizeType)key.size());
}
void writeString(PrettyWriter& writer,
const std::string_view key, const std::string& val)
{
- writer.Key(key.data(), key.size());
+ writer.Key(key.data(), (SizeType)key.size());
writer.String(val);
}
void writeStringView(PrettyWriter& writer,
const std::string_view key, const std::string_view val)
{
- writer.Key(key.data(), key.size());
- writer.String(val.data(), val.size());
+ writer.Key(key.data(), (SizeType)key.size());
+ writer.String(val.data(), (SizeType)val.size());
}
void writeString(PrettyWriter& writer,
@@ -144,6 +144,6 @@ namespace SaveUtils
void writeStringView(PrettyWriter& writer,
const std::string_view val)
{
- writer.String(val.data(), val.size());
+ writer.String(val.data(), (SizeType)val.size());
}
}
diff --git a/src/Game/Save/SaveUtils.h b/DGEngine.core/src/Game/Save/SaveUtils.h
old mode 100755
new mode 100644
similarity index 97%
rename from src/Game/Save/SaveUtils.h
rename to DGEngine.core/src/Game/Save/SaveUtils.h
index 4ce9cb02..4b59ccc7
--- a/src/Game/Save/SaveUtils.h
+++ b/DGEngine.core/src/Game/Save/SaveUtils.h
@@ -47,7 +47,7 @@ namespace SaveUtils
const std::string_view key, const T& val)
{
writer.SetFormatOptions(rapidjson::PrettyFormatOptions::kFormatSingleLineArray);
- writer.Key(key.data(), key.size());
+ writer.Key(key.data(), (rapidjson::SizeType)key.size());
writer.StartArray();
if constexpr (std::is_integral::value == true)
{
@@ -94,7 +94,7 @@ namespace SaveUtils
const std::string_view key, const T& val)
{
writer.SetFormatOptions(rapidjson::PrettyFormatOptions::kFormatSingleLineArray);
- writer.Key(key.data(), key.size());
+ writer.Key(key.data(), (rapidjson::SizeType)key.size());
writer.StartArray();
if constexpr (std::is_integral::value == true)
{
diff --git a/src/GameUtils.cpp b/DGEngine.core/src/GameUtils.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/GameUtils.cpp
rename to DGEngine.core/src/GameUtils.cpp
diff --git a/src/GameUtils.h b/DGEngine.core/src/GameUtils.h
old mode 100755
new mode 100644
similarity index 96%
rename from src/GameUtils.h
rename to DGEngine.core/src/GameUtils.h
index d19bcdc2..10f71cc0
--- a/src/GameUtils.h
+++ b/DGEngine.core/src/GameUtils.h
@@ -5,7 +5,6 @@
#include "AnimationType.h"
#include "BindingFlags.h"
#include "BlendMode.h"
-#include "GameUtilsGame.h"
#include "IgnoreResource.h"
#include "InputEvent.h"
#include "Palette.h"
@@ -51,7 +50,7 @@ namespace GameUtils
sf::Keyboard::Key getKeyCode(int num, sf::Keyboard::Key val) noexcept;
- // also gets extra keys (casted as sf::Keyboard::Key)
+ // also gets extra keys (cast as sf::Keyboard::Key)
sf::Keyboard::Key getKeyCode(const std::string_view str, sf::Keyboard::Key val);
IgnoreResource getIgnoreResource(const std::string_view str, IgnoreResource val);
diff --git a/DGEngine.core/src/Hooks.cpp b/DGEngine.core/src/Hooks.cpp
new file mode 100644
index 00000000..b8f09f06
--- /dev/null
+++ b/DGEngine.core/src/Hooks.cpp
@@ -0,0 +1,22 @@
+#include "Hooks.h"
+
+namespace Hooks
+{
+ InitializeShaderManagerFuncPtr InitializeShaderManager{ nullptr };
+
+ ParseDocumentElemFuncPtr ParseDocumentElem{ nullptr };
+
+ ParseActionElemFuncPtr ParseActionElem{ nullptr };
+
+ GetPredicateObjFuncPtr GetPredicateObj{ nullptr };
+
+ GetImageContainerObjFuncPtr GetImageContainerObj{ nullptr };
+
+ DecodeImageFuncPtr DecodeImage{ nullptr };
+
+ ParseTextureImgFuncPtr ParseTextureImg{ nullptr };
+
+ RegisterArchiversFuncPtr RegisterArchivers{ nullptr };
+
+ std::vector ArchiveExtensions{ ".zip" , ".7z" };
+}
diff --git a/DGEngine.core/src/Hooks.h b/DGEngine.core/src/Hooks.h
new file mode 100644
index 00000000..956d1107
--- /dev/null
+++ b/DGEngine.core/src/Hooks.h
@@ -0,0 +1,50 @@
+#pragma once
+
+#include "FileBytes.h"
+#include "Json/JsonParser.h"
+#include
+#include "Parser/ParserProperties.h"
+#include
+#include "Variable.h"
+#include
+
+class Action;
+class Game;
+class ImageContainer;
+class Predicate;
+class Queryable;
+class ShaderManager;
+
+namespace sf
+{
+ class Image;
+ class InputStream;
+}
+
+namespace Hooks
+{
+ typedef void(*InitializeShaderManagerFuncPtr)(ShaderManager& shaderManager);
+ typedef bool(*ParseDocumentElemFuncPtr)(Game& game, uint16_t nameHash16, const rapidjson::Value& elem,
+ ReplaceVars& replaceVars, rapidjson::MemoryPoolAllocator& allocator);
+ typedef std::shared_ptr(*ParseActionElemFuncPtr)(Game& game,
+ uint16_t nameHash16, const rapidjson::Value& elem);
+ typedef std::shared_ptr(*GetPredicateObjFuncPtr)(Game& game,
+ uint16_t nameHash16, const rapidjson::Value& elem);
+ typedef bool(*GetImageContainerObjFuncPtr)(std::shared_ptr& fileBytes,
+ const std::string_view fileName, const rapidjson::Value& elem,
+ std::shared_ptr& imgContainer);
+ typedef bool(*DecodeImageFuncPtr)(sf::InputStream& file, sf::Image& image);
+ typedef bool(*ParseTextureImgFuncPtr)(Game& game, const rapidjson::Value& elem, sf::Image& img);
+ typedef void(*RegisterArchiversFuncPtr)();
+
+ extern InitializeShaderManagerFuncPtr InitializeShaderManager;
+ extern ParseDocumentElemFuncPtr ParseDocumentElem;
+ extern ParseActionElemFuncPtr ParseActionElem;
+ extern GetPredicateObjFuncPtr GetPredicateObj;
+ extern GetImageContainerObjFuncPtr GetImageContainerObj;
+ extern DecodeImageFuncPtr DecodeImage;
+ extern ParseTextureImgFuncPtr ParseTextureImg;
+ extern RegisterArchiversFuncPtr RegisterArchivers;
+
+ extern std::vector ArchiveExtensions;
+}
diff --git a/src/IfCondition.cpp b/DGEngine.core/src/IfCondition.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/IfCondition.cpp
rename to DGEngine.core/src/IfCondition.cpp
diff --git a/src/IfCondition.h b/DGEngine.core/src/IfCondition.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/IfCondition.h
rename to DGEngine.core/src/IfCondition.h
diff --git a/src/IgnoreResource.h b/DGEngine.core/src/IgnoreResource.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/IgnoreResource.h
rename to DGEngine.core/src/IgnoreResource.h
diff --git a/src/Image.cpp b/DGEngine.core/src/Image.cpp
old mode 100755
new mode 100644
similarity index 92%
rename from src/Image.cpp
rename to DGEngine.core/src/Image.cpp
index f21b9d47..5634a016
--- a/src/Image.cpp
+++ b/DGEngine.core/src/Image.cpp
@@ -24,7 +24,7 @@ Image::Image(const TextureInfo& ti) : sprite(ti)
sprite.setOutlineEnabled(true);
}
-Image::Image(const std::vector& ti) : sprite(ti)
+Image::Image(const std::vector& ti, bool drawAfter) : sprite(ti, drawAfter)
{
sprite.setOutlineEnabled(true);
}
@@ -45,9 +45,9 @@ void Image::setTexture(const TextureInfo& ti)
sprite.setTexture(ti);
}
-void Image::setTexture(const std::vector& ti)
+void Image::setTexture(const std::vector& ti, bool drawAfter)
{
- sprite.setTexture(ti);
+ sprite.setTexture(ti, drawAfter);
}
void Image::setTexture(const TextureInfoVar& ti)
diff --git a/src/Image.h b/DGEngine.core/src/Image.h
old mode 100755
new mode 100644
similarity index 95%
rename from src/Image.h
rename to DGEngine.core/src/Image.h
index 50be478a..bec9e584
--- a/src/Image.h
+++ b/DGEngine.core/src/Image.h
@@ -18,7 +18,7 @@ class Image : public virtual UIObject
Image(const sf::Texture& tex);
Image(const sf::Texture& tex, const std::shared_ptr& pal);
Image(const TextureInfo& ti);
- Image(const std::vector& ti);
+ Image(const std::vector& ti, bool drawAfter = false);
bool Resizable() const noexcept { return resizable; }
void Resizable(bool resizable_) noexcept { resizable = resizable_; }
@@ -55,7 +55,7 @@ class Image : public virtual UIObject
void setTexture(const sf::Texture& texture, bool resetRect = false);
void setTexture(const TextureInfo& ti);
- void setTexture(const std::vector& ti);
+ void setTexture(const std::vector& ti, bool drawAfter = false);
void setTexture(const TextureInfoVar& ti);
void setTextureRect(const sf::IntRect& rectangle) { sprite.setTextureRect(rectangle); }
diff --git a/src/ImageContainers/ImageContainer.h b/DGEngine.core/src/ImageContainers/ImageContainer.h
old mode 100755
new mode 100644
similarity index 92%
rename from src/ImageContainers/ImageContainer.h
rename to DGEngine.core/src/ImageContainers/ImageContainer.h
index e1c492c0..fd68c4ac
--- a/src/ImageContainers/ImageContainer.h
+++ b/DGEngine.core/src/ImageContainers/ImageContainer.h
@@ -2,11 +2,10 @@
#include "BlendMode.h"
#include
-#include "Game/LevelFlags.h"
#include "Palette.h"
#include "SFML/Image2.h"
-class ImageContainer : public LevelFlags
+class ImageContainer
{
public:
struct ImageInfo
diff --git a/src/ImageContainers/SimpleImageContainer.cpp b/DGEngine.core/src/ImageContainers/SimpleImageContainer.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/ImageContainers/SimpleImageContainer.cpp
rename to DGEngine.core/src/ImageContainers/SimpleImageContainer.cpp
diff --git a/src/ImageContainers/SimpleImageContainer.h b/DGEngine.core/src/ImageContainers/SimpleImageContainer.h
old mode 100755
new mode 100644
similarity index 98%
rename from src/ImageContainers/SimpleImageContainer.h
rename to DGEngine.core/src/ImageContainers/SimpleImageContainer.h
index 41109757..c2cae673
--- a/src/ImageContainers/SimpleImageContainer.h
+++ b/DGEngine.core/src/ImageContainers/SimpleImageContainer.h
@@ -5,7 +5,7 @@
class SimpleImageContainer : public ImageContainer
{
-private:
+protected:
sf::Image image;
uint32_t maxFrames{ 0 };
uint32_t numFrames{ 0 };
diff --git a/src/ImageUtils.cpp b/DGEngine.core/src/ImageUtils.cpp
old mode 100755
new mode 100644
similarity index 87%
rename from src/ImageUtils.cpp
rename to DGEngine.core/src/ImageUtils.cpp
index 062a659e..b2c0c2c8
--- a/src/ImageUtils.cpp
+++ b/DGEngine.core/src/ImageUtils.cpp
@@ -1,6 +1,6 @@
#include "ImageUtils.h"
#include "CachedImagePack.h"
-#include "Pcx.h"
+#include "Hooks.h"
#include "SFML/PhysFSStream.h"
#include "Utils/NumberVector.h"
@@ -41,7 +41,8 @@ namespace ImageUtils
return image;
}
- if (LoadImagePCX(file, image) == false)
+ if (Hooks::DecodeImage == nullptr ||
+ Hooks::DecodeImage(file, image) == false)
{
image.loadFromStream(file);
}
@@ -59,9 +60,9 @@ namespace ImageUtils
CachedImagePack imgCache(&imgContainer, pal);
- size_t imgWidth = 0;
- size_t imgHeight = 0;
- for (size_t i = 0; i < imgCache.size(); i++)
+ unsigned imgWidth = 0;
+ unsigned imgHeight = 0;
+ for (uint32_t i = 0; i < imgCache.size(); i++)
{
auto frameSize = imgCache[i].getSize();
if (imgWidth < frameSize.x)
@@ -74,14 +75,14 @@ namespace ImageUtils
sf::Image img;
img.create(imgWidth, imgHeight, sf::Color::Transparent);
- size_t maxHeight = 0;
- for (size_t fr = 0; fr < imgCache.size(); fr++)
+ unsigned maxHeight = 0;
+ for (uint32_t fr = 0; fr < imgCache.size(); fr++)
{
const auto& frame = imgCache[fr];
auto frameSize = frame.getSize();
- for (size_t j = 0; j < frameSize.y; j++)
+ for (unsigned j = 0; j < frameSize.y; j++)
{
- for (size_t i = 0; i < frameSize.x; i++)
+ for (unsigned i = 0; i < frameSize.x; i++)
{
img.setPixel(i, maxHeight + j, frame.getPixel(i, j));
}
@@ -92,7 +93,7 @@ namespace ImageUtils
}
sf::Image loadImageFrame(const ImageContainer& imgContainer,
- const PaletteArray* pal, size_t frameIdx)
+ const PaletteArray* pal, uint32_t frameIdx)
{
if (imgContainer.size() > 0 && frameIdx < imgContainer.size())
{
@@ -117,8 +118,8 @@ namespace ImageUtils
img.create(firstImgSize.x * 16, firstImgSize.y * 16, sf::Color::Transparent);
NumberVector charMapping(fileNameCharMap, 0, 256);
- size_t xx = 0;
- size_t yy = 0;
+ unsigned xx = 0;
+ unsigned yy = 0;
for (auto charMap : charMapping.getContainer())
{
if (charMap != 0xFF && charMap < cacheSize)
@@ -126,9 +127,9 @@ namespace ImageUtils
const auto& frame = imgCache[charMap];
auto frameSize = frame.getSize();
- for (size_t j = 0; j < frameSize.y; j++)
+ for (unsigned j = 0; j < frameSize.y; j++)
{
- for (size_t i = 0; i < frameSize.x; i++)
+ for (unsigned i = 0; i < frameSize.x; i++)
{
img.setPixel(
frameSize.x * xx + i,
diff --git a/src/ImageUtils.h b/DGEngine.core/src/ImageUtils.h
old mode 100755
new mode 100644
similarity index 90%
rename from src/ImageUtils.h
rename to DGEngine.core/src/ImageUtils.h
index ffc42bee..1dae9f27
--- a/src/ImageUtils.h
+++ b/DGEngine.core/src/ImageUtils.h
@@ -3,6 +3,7 @@
#include "ImageContainers/ImageContainer.h"
#include
#include "Palette.h"
+#include
#include
namespace ImageUtils
@@ -17,7 +18,7 @@ namespace ImageUtils
const std::shared_ptr& pal);
sf::Image loadImageFrame(const ImageContainer& imgContainer,
- const PaletteArray* pal, size_t frameIdx);
+ const PaletteArray* pal, uint32_t frameIdx);
sf::Image loadBitmapFontImage(const ImageContainer& imgContainer,
const std::string_view fileNameCharMap, const std::shared_ptr& pal);
diff --git a/src/InputEvent.cpp b/DGEngine.core/src/InputEvent.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/InputEvent.cpp
rename to DGEngine.core/src/InputEvent.cpp
diff --git a/src/InputEvent.h b/DGEngine.core/src/InputEvent.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/InputEvent.h
rename to DGEngine.core/src/InputEvent.h
diff --git a/src/InputText.cpp b/DGEngine.core/src/InputText.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/InputText.cpp
rename to DGEngine.core/src/InputText.cpp
diff --git a/src/InputText.h b/DGEngine.core/src/InputText.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/InputText.h
rename to DGEngine.core/src/InputText.h
diff --git a/src/Json/JsonParser.h b/DGEngine.core/src/Json/JsonParser.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Json/JsonParser.h
rename to DGEngine.core/src/Json/JsonParser.h
diff --git a/src/Json/JsonUtils.cpp b/DGEngine.core/src/Json/JsonUtils.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/Json/JsonUtils.cpp
rename to DGEngine.core/src/Json/JsonUtils.cpp
diff --git a/src/Json/JsonUtils.h b/DGEngine.core/src/Json/JsonUtils.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Json/JsonUtils.h
rename to DGEngine.core/src/Json/JsonUtils.h
diff --git a/src/LoadingScreen.cpp b/DGEngine.core/src/LoadingScreen.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/LoadingScreen.cpp
rename to DGEngine.core/src/LoadingScreen.cpp
diff --git a/src/LoadingScreen.h b/DGEngine.core/src/LoadingScreen.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/LoadingScreen.h
rename to DGEngine.core/src/LoadingScreen.h
diff --git a/src/Menu.cpp b/DGEngine.core/src/Menu.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/Menu.cpp
rename to DGEngine.core/src/Menu.cpp
diff --git a/src/Menu.h b/DGEngine.core/src/Menu.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Menu.h
rename to DGEngine.core/src/Menu.h
diff --git a/src/Movie2.cpp b/DGEngine.core/src/Movie2.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/Movie2.cpp
rename to DGEngine.core/src/Movie2.cpp
diff --git a/src/Movie2.h b/DGEngine.core/src/Movie2.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Movie2.h
rename to DGEngine.core/src/Movie2.h
diff --git a/src/Palette.cpp b/DGEngine.core/src/Palette.cpp
old mode 100755
new mode 100644
similarity index 94%
rename from src/Palette.cpp
rename to DGEngine.core/src/Palette.cpp
index 4ac501ec..8fab3b9f
--- a/src/Palette.cpp
+++ b/DGEngine.core/src/Palette.cpp
@@ -67,13 +67,13 @@ Palette::Palette(const Palette& pal, const std::vector trn,
void Palette::loadTexture()
{
sf::Image img;
- img.create(palette.size(), 1, (const sf::Uint8*)&palette);
+ img.create((unsigned)palette.size(), 1, (const sf::Uint8*)&palette);
texture.loadFromImage(img);
}
void Palette::updateTexture()
{
- texture.update((const sf::Uint8*)&palette, palette.size(), 1, 0, 0);
+ texture.update((const sf::Uint8*)&palette, (unsigned)palette.size(), 1, 0, 0);
}
bool Palette::shiftLeft(size_t shift, size_t startIdx, size_t stopIdx)
diff --git a/src/Palette.h b/DGEngine.core/src/Palette.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Palette.h
rename to DGEngine.core/src/Palette.h
diff --git a/src/Panel.cpp b/DGEngine.core/src/Panel.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/Panel.cpp
rename to DGEngine.core/src/Panel.cpp
diff --git a/src/Panel.h b/DGEngine.core/src/Panel.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Panel.h
rename to DGEngine.core/src/Panel.h
diff --git a/src/Parser/ParseAction.cpp b/DGEngine.core/src/Parser/ParseAction.cpp
old mode 100755
new mode 100644
similarity index 99%
rename from src/Parser/ParseAction.cpp
rename to DGEngine.core/src/Parser/ParseAction.cpp
index 71623c84..133891b3
--- a/src/Parser/ParseAction.cpp
+++ b/DGEngine.core/src/Parser/ParseAction.cpp
@@ -29,8 +29,8 @@
#include "Actions/ActText.h"
#include "Actions/ActVariable.h"
#include "Actions/ActVisibility.h"
+#include "Hooks.h"
#include "Json/JsonUtils.h"
-#include "ParseActionGame.h"
#include "ParseCondition.h"
#include "Utils/ParseUtils.h"
@@ -1226,7 +1226,16 @@ namespace Parser
getBoolKey(elem, "resolveValue", true));
}
default:
- return parseActionGameElem(game, nameHash, elem);
+ {
+ if (Hooks::ParseActionElem != nullptr)
+ {
+ return Hooks::ParseActionElem(game, nameHash, elem);
+ }
+ else
+ {
+ return nullptr;
+ }
+ }
}
}
diff --git a/src/Parser/ParseAction.h b/DGEngine.core/src/Parser/ParseAction.h
old mode 100755
new mode 100644
similarity index 99%
rename from src/Parser/ParseAction.h
rename to DGEngine.core/src/Parser/ParseAction.h
index dcc432c2..4f5c312f
--- a/src/Parser/ParseAction.h
+++ b/DGEngine.core/src/Parser/ParseAction.h
@@ -7,6 +7,8 @@
namespace Parser
{
std::shared_ptr getActionKey(Game& game, const rapidjson::Value& elem, const char* key);
+
std::shared_ptr getActionVal(Game& game, const rapidjson::Value& elem);
+
void parseActionAndExecute(Game& game, const rapidjson::Value& elem);
}
diff --git a/src/Parser/ParseAnimation.cpp b/DGEngine.core/src/Parser/ParseAnimation.cpp
old mode 100755
new mode 100644
similarity index 92%
rename from src/Parser/ParseAnimation.cpp
rename to DGEngine.core/src/Parser/ParseAnimation.cpp
index 46dfa823..d2ceda3f
--- a/src/Parser/ParseAnimation.cpp
+++ b/DGEngine.core/src/Parser/ParseAnimation.cpp
@@ -1,5 +1,6 @@
#include "ParseAnimation.h"
#include "Animation.h"
+#include
#include "Game.h"
#include "GameUtils.h"
#include "Panel.h"
@@ -90,8 +91,11 @@ namespace Parser
return animation;
}
- void parseAnimation(Game& game, const Value& elem)
+ void parseAnimation(Game& game, const Value& elem,
+ const getAnimationObjFuncPtr getAnimationObjFunc)
{
+ assert(getAnimationObjFunc != nullptr);
+
if (isValidString(elem, "id") == false)
{
return;
@@ -101,7 +105,8 @@ namespace Parser
{
return;
}
- auto animation = getAnimationObj(game, elem);
+
+ auto animation = getAnimationObjFunc(game, elem);
if (animation == nullptr)
{
return;
@@ -122,4 +127,9 @@ namespace Parser
id, animation, manageObjDrawing, getStringViewKey(elem, "resource")
);
}
+
+ void parseAnimation(Game& game, const Value& elem)
+ {
+ parseAnimation(game, elem, getAnimationObj);
+ }
}
diff --git a/src/Parser/ParseAnimation.h b/DGEngine.core/src/Parser/ParseAnimation.h
old mode 100755
new mode 100644
similarity index 59%
rename from src/Parser/ParseAnimation.h
rename to DGEngine.core/src/Parser/ParseAnimation.h
index e2422e38..0dc8e579
--- a/src/Parser/ParseAnimation.h
+++ b/DGEngine.core/src/Parser/ParseAnimation.h
@@ -9,5 +9,11 @@ class Game;
namespace Parser
{
std::shared_ptr getAnimationObj(Game& game, const rapidjson::Value& elem);
+
+ typedef decltype(&getAnimationObj) getAnimationObjFuncPtr;
+
+ void parseAnimation(Game& game, const rapidjson::Value& elem,
+ const getAnimationObjFuncPtr getAnimationObjFunc);
+
void parseAnimation(Game& game, const rapidjson::Value& elem);
}
diff --git a/src/Parser/ParseAudio.cpp b/DGEngine.core/src/Parser/ParseAudio.cpp
old mode 100755
new mode 100644
similarity index 67%
rename from src/Parser/ParseAudio.cpp
rename to DGEngine.core/src/Parser/ParseAudio.cpp
index 2dc346e5..e0d10408
--- a/src/Parser/ParseAudio.cpp
+++ b/DGEngine.core/src/Parser/ParseAudio.cpp
@@ -1,4 +1,5 @@
#include "ParseAudio.h"
+#include
#include "Game.h"
#include "ParseAudioCommon.h"
#include "SFML/MusicLoops.h"
@@ -23,7 +24,7 @@ namespace Parser
}
bool openMusicFromFile(Game& game, std::shared_ptr music,
- sf::PhysFSStream& stream, const AudioSource audioSource,
+ sf::InputStream& stream, const AudioSource audioSource,
const std::string& id, const std::string_view resource)
{
if (music->openFromStream(stream) == true &&
@@ -38,7 +39,7 @@ namespace Parser
return false;
}
- sf::Music2* parseAudioFileObjHelper(Game& game, const Value& elem,
+ sf::Music2* parseAudioObjFromFile(Game& game, const Value& elem,
const std::string& id, const std::string& file)
{
bool hasLoopNames = elem.HasMember("loopNames"sv);
@@ -97,84 +98,91 @@ namespace Parser
return nullptr;
}
- sf::Music2* parseAudioObj(Game& game, const Value& elem)
+ sf::Music2* parseAudioObjFromSource(Game& game,
+ const Value& elem, const std::string& id)
{
- std::string id;
+ auto source = game.Resources().getAudioSource(elem["sourceId"sv].GetStringView());
- if (isValidString(elem, "id") == true)
+ if (std::holds_alternative>(source) == true)
{
- id = elem["id"sv].GetStringView();
- }
- bool validId = isValidId(id);
+ auto sndBuffer = std::get>(source).get();
- if (isValidString(elem, "sourceId") == true &&
- validId == true)
- {
- auto source = game.Resources().getAudioSource(elem["sourceId"sv].GetStringView());
+ if (sndBuffer == nullptr)
+ {
+ return nullptr;
+ }
- if (std::holds_alternative>(source) == true)
+ std::shared_ptr music;
+
+ if (elem.HasMember("loopPoints"sv) == true)
{
- auto sndBuffer = std::get>(source).get();
+ music = std::make_shared();
- if (sndBuffer == nullptr)
- {
- return nullptr;
- }
+ parseAudioLoopPointsVal(
+ elem,
+ "loopPoints",
+ (*(sf::MusicLoops*)music.get()));
+ }
+ else
+ {
+ music = std::make_shared();
+ }
+ auto resource = getStringViewKey(elem, "resource");
+ if (openMusicFromBuffer(game, music, *sndBuffer, id, resource) == true)
+ {
+ return music.get();
+ }
+ }
+ else if (std::holds_alternative>(source) == true)
+ {
+ auto sndBuffer = std::get>(source).get();
+
+ if (sndBuffer == nullptr)
+ {
+ return nullptr;
+ }
- std::shared_ptr music;
+ auto music = std::make_shared();
+ auto music2 = std::dynamic_pointer_cast(music);
+ auto resource = getStringViewKey(elem, "resource");
+ if (openMusicFromBuffer(game, music2,
+ sndBuffer->soundBuffer, id, resource) == true)
+ {
if (elem.HasMember("loopPoints"sv) == true)
{
- music = std::make_shared();
-
parseAudioLoopPointsVal(
elem,
"loopPoints",
- (*(sf::MusicLoops*)music.get()));
- }
- else
- {
- music = std::make_shared();
+ *music);
}
- auto resource = getStringViewKey(elem, "resource");
- if (openMusicFromBuffer(game, music, *sndBuffer, id, resource) == true)
+ else if (isValidString(elem, "playText") == true)
{
- return music.get();
+ updateAudioLoopString(
+ getStringViewVal(elem["playText"sv]),
+ sndBuffer->loops,
+ *music);
}
+ return music.get();
}
- else if (std::holds_alternative>(source) == true)
- {
- auto sndBuffer = std::get>(source).get();
+ }
+ return nullptr;
+ }
- if (sndBuffer == nullptr)
- {
- return nullptr;
- }
+ sf::Music2* parseAudioObj(Game& game, const Value& elem)
+ {
+ std::string id;
- auto music = std::make_shared();
- auto music2 = std::dynamic_pointer_cast(music);
- auto resource = getStringViewKey(elem, "resource");
+ if (isValidString(elem, "id") == true)
+ {
+ id = elem["id"sv].GetStringView();
+ }
+ bool validId = isValidId(id);
- if (openMusicFromBuffer(game, music2,
- sndBuffer->soundBuffer, id, resource) == true)
- {
- if (elem.HasMember("loopPoints"sv) == true)
- {
- parseAudioLoopPointsVal(
- elem,
- "loopPoints",
- *music);
- }
- else if (isValidString(elem, "playText") == true)
- {
- updateAudioLoopString(
- getStringViewVal(elem["playText"sv]),
- sndBuffer->loops,
- *music);
- }
- return music.get();
- }
- }
+ if (isValidString(elem, "sourceId") == true &&
+ validId == true)
+ {
+ return parseAudioObjFromSource(game, elem, id);
}
else if (isValidString(elem, "file") == true)
{
@@ -191,7 +199,7 @@ namespace Parser
return nullptr;
}
}
- return parseAudioFileObjHelper(game, elem, id, file);
+ return parseAudioObjFromFile(game, elem, id, file);
}
return nullptr;
}
@@ -218,14 +226,17 @@ namespace Parser
return false;
}
- void parseAudio(Game& game, const Value& elem)
+ void parseAudio(Game& game, const Value& elem,
+ const parseAudioObjFuncPtr parseAudioObjFunc)
{
+ assert(parseAudioObjFunc != nullptr);
+
if (parseAudioFromId(game, elem) == true)
{
return;
}
- auto music = parseAudioObj(game, elem);
+ auto music = parseAudioObjFunc(game, elem);
if (music == nullptr)
{
return;
@@ -252,4 +263,9 @@ namespace Parser
music->play();
}
}
+
+ void parseAudio(Game& game, const Value& elem)
+ {
+ parseAudio(game, elem, parseAudioObj);
+ }
}
diff --git a/DGEngine.core/src/Parser/ParseAudio.h b/DGEngine.core/src/Parser/ParseAudio.h
new file mode 100644
index 00000000..d7cdb189
--- /dev/null
+++ b/DGEngine.core/src/Parser/ParseAudio.h
@@ -0,0 +1,38 @@
+#pragma once
+
+#include "AudioSource.h"
+#include "Json/JsonParser.h"
+
+class Game;
+
+namespace sf
+{
+ class Music2;
+}
+
+namespace Parser
+{
+ bool openMusicFromBuffer(Game& game, std::shared_ptr& music,
+ sf::SoundBuffer& buffer, const std::string& id, const std::string_view resource);
+
+ bool openMusicFromFile(Game& game, std::shared_ptr music,
+ sf::InputStream& stream, const AudioSource audioSource,
+ const std::string& id, const std::string_view resource);
+
+ sf::Music2* parseAudioObjFromFile(Game& game, const rapidjson::Value& elem,
+ const std::string& id, const std::string& file);
+
+ sf::Music2* parseAudioObjFromSource(Game& game,
+ const rapidjson::Value& elem, const std::string& id);
+
+ sf::Music2* parseAudioObj(Game& game, const rapidjson::Value& elem);
+
+ bool parseAudioFromId(Game& game, const rapidjson::Value& elem);
+
+ typedef decltype(&parseAudioObj) parseAudioObjFuncPtr;
+
+ void parseAudio(Game& game, const rapidjson::Value& elem,
+ const parseAudioObjFuncPtr parseAudioObjFunc);
+
+ void parseAudio(Game& game, const rapidjson::Value& elem);
+}
diff --git a/src/Parser/ParseAudioCommon.cpp b/DGEngine.core/src/Parser/ParseAudioCommon.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from src/Parser/ParseAudioCommon.cpp
rename to DGEngine.core/src/Parser/ParseAudioCommon.cpp
diff --git a/src/Parser/ParseAudioCommon.h b/DGEngine.core/src/Parser/ParseAudioCommon.h
old mode 100755
new mode 100644
similarity index 100%
rename from src/Parser/ParseAudioCommon.h
rename to DGEngine.core/src/Parser/ParseAudioCommon.h
diff --git a/src/Parser/ParseButton.cpp b/DGEngine.core/src/Parser/ParseButton.cpp
old mode 100755
new mode 100644
similarity index 82%
rename from src/Parser/ParseButton.cpp
rename to DGEngine.core/src/Parser/ParseButton.cpp
index 330c6e55..1319c762
--- a/src/Parser/ParseButton.cpp
+++ b/DGEngine.core/src/Parser/ParseButton.cpp
@@ -1,6 +1,7 @@
#include "ParseButton.h"
#include "BitmapButton.h"
#include "BitmapText.h"
+#include
#include "Game.h"
#include "GameUtils.h"
#include "Panel.h"
@@ -61,6 +62,22 @@ namespace Parser
button->setOutline(outline, outlineIgnore);
button->setOutlineEnabled(getBoolKey(elem, "enableOutline"));
+ auto anchor = getAnchorKey(elem, "anchor");
+ button->setAnchor(anchor);
+ auto size = button->Size();
+ auto pos = getPositionKey(elem, "position", size, game.RefSize());
+ if (getBoolKey(elem, "relativeCoords", true) == true &&
+ game.RefSize() != game.DrawRegionSize())
+ {
+ GameUtils::setAnchorPosSize(anchor, pos, size, game.RefSize(), game.DrawRegionSize());
+ }
+ button->Position(pos);
+ auto bitmapBtn = static_cast(button.get());
+ bitmapBtn->Size(size);
+ button->Visible(getBoolKey(elem, "visible", true));
+
+ button->setColor(getColorKey(elem, "color", sf::Color::White));
+
return button;
}
@@ -76,46 +93,34 @@ namespace Parser
return button;
}
- void parseButton(Game& game, const Value& elem)
+ std::shared_ptr