diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 624af822..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,31 +0,0 @@ -version: 2.1 -executors: - exec: - docker: - - image: siredmar/mdcii-builder:latest - -jobs: - build: - executor: exec - steps: - - checkout - - run: - name: Create build directories - command: | - mkdir -p build - - run: - name: Setup cmake and build artifacts - command: | - cd build - cmake -DCMAKE_BUILD_TYPE=Release .. - make -j16 - - run: - name: Run unit tests - command: | - cd build - ./cacheprotobuf-test - ./proto-gamelist-test - ./proto-textcod-test - - persist_to_workspace: - root: . - paths: build diff --git a/.clang-format b/.clang-format deleted file mode 100644 index 4e88e587..00000000 --- a/.clang-format +++ /dev/null @@ -1,100 +0,0 @@ ---- -Language: Cpp -# BasedOnStyle: WebKit -AccessModifierOffset: -4 -AlignAfterOpenBracket: DontAlign -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlines: Right -AlignOperands: false -AlignTrailingComments: false -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: false -BinPackArguments: true -BinPackParameters: true -BraceWrapping: - AfterClass: false - AfterControlStatement: false - AfterEnum: false - AfterFunction: true - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - BeforeCatch: false - BeforeElse: false - IndentBraces: false - SplitEmptyFunction: true - SplitEmptyRecord: true - SplitEmptyNamespace: true -BreakBeforeBinaryOperators: All -BreakBeforeBraces: Allman -BreakBeforeInheritanceComma: false -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: BeforeComma -BreakAfterJavaFieldAnnotations: false -BreakStringLiterals: true -ColumnLimit: 0 -CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: false -DerivePointerAlignment: false -DisableFormat: false -ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: false -ForEachMacros: - - foreach - - Q_FOREACH - - BOOST_FOREACH -IndentCaseLabels: true -IndentWidth: 4 -IndentWrappedFunctionNames: false -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: true -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: Inner -ObjCBlockIndentWidth: 4 -ObjCSpaceAfterProperty: true -ObjCSpaceBeforeProtocolList: true -PenaltyBreakAssignment: 2 -PenaltyBreakBeforeFirstCallParameter: 19 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Left -ReflowComments: true -SortIncludes: true -SortUsingDeclarations: true -SpaceAfterCStyleCast: false -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeParens: ControlStatements -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInContainerLiterals: true -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: Cpp11 -TabWidth: 8 -UseTab: Never ---- -Language: Proto -AllowShortFunctionsOnASingleLine: None \ No newline at end of file diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 00000000..920b056f --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,15 @@ +name: mdcii +on: + push: + branches: + - main + +jobs: + build-push-anck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: "1.18" + - run: make diff --git a/.github/workflows/pullrequest.yaml b/.github/workflows/pullrequest.yaml new file mode 100644 index 00000000..3f8bf80d --- /dev/null +++ b/.github/workflows/pullrequest.yaml @@ -0,0 +1,15 @@ +name: pullrequest +on: + pull_request: + branches: + - main + +jobs: + build-push-anck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: "1.18" + - run: make diff --git a/.gitignore b/.gitignore index cd4c35b9..77394626 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,11 @@ - +*.png +*.json +out +__debug_* \.vscode/ build compile_commands.json -.clangd/ +install +bin + +tools/ diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index a4db0692..00000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,210 +0,0 @@ - -# -# CMake options -# - -# CMake version -cmake_minimum_required(VERSION 3.0 FATAL_ERROR) - -# -# Configure CMake environment -# - -# Generates compile_commands.json, often consumed by IDEs. -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - -# Register general cmake commands -include(cmake/Custom.cmake) - -# Set policies -set_policy(CMP0054 NEW) # ENABLE CMP0054: Only interpret if() arguments as variables or keywords when unquoted. -set_policy(CMP0042 NEW) # ENABLE CMP0042: MACOSX_RPATH is enabled by default. -set_policy(CMP0063 NEW) # ENABLE CMP0063: Honor visibility properties for all target types. -set_policy(CMP0077 NEW) # ENABLE CMP0077: option() honors normal variables - -# Include cmake modules -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - -include(GenerateExportHeader) - -set(WriterCompilerDetectionHeaderFound NOTFOUND) -# This module is only available with CMake >=3.1, so check whether it could be found -# BUT in CMake 3.1 this module doesn't recognize AppleClang as compiler, so just use it as of CMake 3.2 -if (${CMAKE_VERSION} VERSION_GREATER "3.2") - include(WriteCompilerDetectionHeader OPTIONAL RESULT_VARIABLE WriterCompilerDetectionHeaderFound) -endif() - -# Include custom cmake modules -include(cmake/Coverage.cmake) -include(cmake/GenerateTemplateExportHeader.cmake) -include(cmake/GetGitRevisionDescription.cmake) -include(cmake/HealthCheck.cmake) - - -# -# Project description and (meta) information -# - -# Get git revision -get_git_head_revision(GIT_REFSPEC GIT_SHA1) -string(SUBSTRING "${GIT_SHA1}" 0 12 GIT_REV) -if(NOT GIT_SHA1) - set(GIT_REV "0") -endif() - -# Meta information about the project -set(META_PROJECT_NAME "mdcii") -set(META_PROJECT_DESCRIPTION "Free Anno1602 engine") -set(META_AUTHOR_ORGANIZATION "mdcii") -set(META_AUTHOR_DOMAIN "https://github.com/siredmar/mdcii") -set(META_AUTHOR_MAINTAINER "armin.schlegel@gmx.de") -set(META_VERSION_MAJOR "0") -set(META_VERSION_MINOR "0") -set(META_VERSION_PATCH "1") -set(META_VERSION_REVISION "${GIT_REV}") -set(META_VERSION "${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}") -set(META_NAME_VERSION "${META_PROJECT_NAME} v${META_VERSION} (${META_VERSION_REVISION})") -set(META_CMAKE_INIT_SHA "${GIT_REV}") - -string(MAKE_C_IDENTIFIER ${META_PROJECT_NAME} META_PROJECT_ID) -string(TOUPPER ${META_PROJECT_ID} META_PROJECT_ID) - - -# -# Project configuration options -# - -# Project options -option(BUILD_SHARED_LIBS "Build shared instead of static libraries." ON) -option(OPTION_SELF_CONTAINED "Create a self-contained install with all dependencies." OFF) -option(OPTION_BUILD_TESTS "Build tests." ON) -option(OPTION_BUILD_DOCS "Build documentation." OFF) -option(OPTION_BUILD_EXAMPLES "Build examples." OFF) -option(OPTION_ENABLE_COVERAGE "Add coverage information." OFF) - - -# -# Declare project -# - -# Generate folders for IDE targets (e.g., VisualStudio solutions) -set_property(GLOBAL PROPERTY USE_FOLDERS ON) -set(IDE_FOLDER "") - -# Declare project -project(${META_PROJECT_NAME} C CXX) - -# Set output directories -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) - -# Create version file -file(WRITE "${PROJECT_BINARY_DIR}/VERSION" "${META_NAME_VERSION}") - - -# -# Project Health Check Setup -# - -# Add cmake-init template check cmake targets -add_check_template_target(${META_CMAKE_INIT_SHA}) - -# Configure health check tools -enable_cppcheck(ON) -enable_clang_tidy(ON) -enable_coverage(${OPTION_ENABLE_COVERAGE}) - - -# -# Compiler settings and options -# - -include(cmake/CompileOptions.cmake) - - -# -# Deployment/installation setup -# - -# Get project name -set(project ${META_PROJECT_NAME}) - -# Check for system dir install -set(SYSTEM_DIR_INSTALL FALSE) -if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr" OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local") - set(SYSTEM_DIR_INSTALL TRUE) -endif() - -# Installation paths -if(UNIX AND SYSTEM_DIR_INSTALL) - # Install into the system (/usr/bin or /usr/local/bin) - set(INSTALL_ROOT "share/${project}") # /usr/local/share/mdcii - set(INSTALL_CMAKE "share/${project}/cmake") # /usr/local/share/mdcii/cmake - set(INSTALL_EXAMPLES "share/${project}") # /usr/local/share/mdcii - set(INSTALL_DATA "share/${project}") # /usr/local/share/mdcii - set(INSTALL_BIN "bin") # /usr/local/bin - set(INSTALL_SHARED "lib") # /usr/local/lib - set(INSTALL_LIB "lib") # /usr/local/lib - set(INSTALL_INCLUDE "include") # /usr/local/include - set(INSTALL_DOC "share/doc/${project}") # /usr/local/share/doc/mdcii - set(INSTALL_SHORTCUTS "share/applications") # /usr/local/share/applications - set(INSTALL_ICONS "share/pixmaps") # /usr/local/share/pixmaps - set(INSTALL_INIT "/etc/init") # /etc/init (upstart init scripts) -else() - # Install into local directory - set(INSTALL_ROOT ".") # ./ - set(INSTALL_CMAKE "cmake") # ./cmake - set(INSTALL_EXAMPLES ".") # ./ - set(INSTALL_DATA ".") # ./ - set(INSTALL_BIN ".") # ./ - set(INSTALL_SHARED "lib") # ./lib - set(INSTALL_LIB "lib") # ./lib - set(INSTALL_INCLUDE "include") # ./include - set(INSTALL_DOC "doc") # ./doc - set(INSTALL_SHORTCUTS "misc") # ./misc - set(INSTALL_ICONS "misc") # ./misc - set(INSTALL_INIT "misc") # ./misc -endif() - -# Set runtime path -set(CMAKE_SKIP_BUILD_RPATH FALSE) # Add absolute path to all dependencies for BUILD -set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # Use CMAKE_INSTALL_RPATH for INSTALL -set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) # Do NOT add path to dependencies for INSTALL - -if(NOT SYSTEM_DIR_INSTALL) - # Find libraries relative to binary - if(APPLE) - set(CMAKE_INSTALL_RPATH "@loader_path/../../../${INSTALL_LIB}") - else() - set(CMAKE_INSTALL_RPATH "$ORIGIN/${INSTALL_LIB}") - endif() -endif() - - -# -# Project modules -# - -add_subdirectory(source) -add_subdirectory(docs) -add_subdirectory(deploy) - - -# -# Deployment (global project files) -# - -# Install version file -install(FILES "${PROJECT_BINARY_DIR}/VERSION" DESTINATION ${INSTALL_ROOT} COMPONENT runtime) - -# Install cmake find script for the project -install(FILES ${META_PROJECT_NAME}-config.cmake DESTINATION ${INSTALL_ROOT} COMPONENT dev) - -# Install the project meta files -install(FILES AUTHORS DESTINATION ${INSTALL_ROOT} COMPONENT runtime) -install(FILES LICENSE DESTINATION ${INSTALL_ROOT} COMPONENT runtime) -install(FILES README.md DESTINATION ${INSTALL_ROOT} COMPONENT runtime) - -# Install runtime data -install(DIRECTORY ${PROJECT_SOURCE_DIR}/data DESTINATION ${INSTALL_DATA} COMPONENT runtime) diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..93a67076 --- /dev/null +++ b/Makefile @@ -0,0 +1,42 @@ +NAME = mdcii +BIN_DIR ?= ./bin +VERSION ?= $(shell git describe --match=NeVeRmAtCh --always --abbrev=40 --dirty) +GO_LDFLAGS = -tags 'netgo osusergo static_build' +GO_ARCH = amd64 + +all: proto-cod build + +build: bshdump + +bshdump: test + GOOS=linux GOARCH=${GO_ARCH} go build -o ${BIN_DIR}/bshdump cmd/bshdump/main.go + +proto-cod: + @go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.32.0 + @mkdir -p tools/protoc + curl -L https://github.com/protocolbuffers/protobuf/releases/download/v25.1/protoc-25.1-linux-x86_64.zip -o tools/protoc.zip + @unzip -o tools/protoc.zip -d tools/protoc/ + tools/protoc/bin/protoc --proto_path=proto --go_out=pkg/cod proto/cod.proto + @mv pkg/cod/github.com/siredmar/mdcii-engine/pkg/cod/cod.pb.go pkg/cod + @rm -r pkg/cod/github.com/ + +test: + go test ./... + +clean: + rm -rf ${BIN_DIR}/bshdump + +.PHONY: bin +bin: + mkdir -p ${BIN_DIR} + +.PHONY: assets_generator +assets_generator: bin + go build -o ${BIN_DIR}/assets_generator cmd/assets_generator/main.go + +.PHONY: mdcii +mdcii: bin + go build -o ${BIN_DIR}/mdcii cmd/mdcii/main.go + +.PHONY: check test clean + diff --git a/README.md b/README.md index c68799a0..69ae3663 100644 --- a/README.md +++ b/README.md @@ -8,25 +8,24 @@ The main goal of this project is to provide an independent reimplementation of t Currently this project contains several helper tools: -- [`bshdump`](docs/doc/bshdump.md) -- [`bshpacker`](docs/doc/bshpacker.md) -- `cod_parser` -- `codcat` -- `gam_parser` -- `paldump` -- `zeidump` -- `inselbmp` -- `weltbmp` -- `zeitext` +- [`bshdump`](docs/doc/bshdump.md) +- [`bshpacker`](docs/doc/bshpacker.md) +- `cod_parser` +- `codcat` +- `gam_parser` +- `paldump` +- `zeidump` +- `inselbmp` +- `weltbmp` +- `zeitext` The most complex program is [`mdcii-sdltest`](docs/doc/mdcii-sdltest.md) that can load savegames and scenario files and animate the buildings. ## Requirements -- g++-8 or greater -- SDL2 -- boost -- protobuf +- golang > v1.21 + +Dependencies for ebiten [see docs][https://ebitengine.org/en/documents/install.html] ## Media diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 72184922..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,49 +0,0 @@ -version: '{build}' -branches: - only: - - master -clone_folder: c:\projects\cmake-init -image: -- Visual Studio 2013 -- Visual Studio 2015 -- Visual Studio 2017 -configuration: -- Release -- Debug -platform: -- x64 -environment: - matrix: - - arch: Win64 - # - arch: #does not work, Release|x64 not a valid target -matrix: - fast_finish: true - -# skip unsupported combinations -init: -- set arch= -- if "%arch%"=="Win64" ( set arch= Win64) -- echo %arch% -- echo %APPVEYOR_BUILD_WORKER_IMAGE% -- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" ( set generator="Visual Studio 15 2017%arch%" ) -- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" ( set generator="Visual Studio 14 2015%arch%" ) -- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2013" ( set generator="Visual Studio 12 2013%arch%" ) -- echo %generator% - -before_build: -- cmd: |- - mkdir build - cd build - cmake --version - cmake .. -G %generator% - -build: - project: c:\projects\cmake-init\build\template.sln - verbosity: minimal - parallel: true -only_commits: - files: - - CMakeLists.txt - - appveyor.yml - - source/ - - cmake/ diff --git a/assets/gfx/0.png b/assets/gfx/0.png new file mode 100644 index 00000000..92746c3b Binary files /dev/null and b/assets/gfx/0.png differ diff --git a/assets/gfx/1.png b/assets/gfx/1.png new file mode 100644 index 00000000..651c8ecf Binary files /dev/null and b/assets/gfx/1.png differ diff --git a/assets/gfx/blue_gfx.png b/assets/gfx/blue_gfx.png new file mode 100644 index 00000000..a42bed59 Binary files /dev/null and b/assets/gfx/blue_gfx.png differ diff --git a/assets/gfx/corner_gfx.png b/assets/gfx/corner_gfx.png new file mode 100644 index 00000000..43ed93f8 Binary files /dev/null and b/assets/gfx/corner_gfx.png differ diff --git a/assets/gfx/frame_gfx.png b/assets/gfx/frame_gfx.png new file mode 100644 index 00000000..48ffa3c7 Binary files /dev/null and b/assets/gfx/frame_gfx.png differ diff --git a/cmake-init-logo.png b/cmake-init-logo.png deleted file mode 100644 index 5c8e6aae..00000000 Binary files a/cmake-init-logo.png and /dev/null differ diff --git a/cmake-init-logo.svg b/cmake-init-logo.svg deleted file mode 100644 index 2f8b66da..00000000 --- a/cmake-init-logo.svg +++ /dev/null @@ -1 +0,0 @@ -cmake-init-logo \ No newline at end of file diff --git a/cmake/CheckTemplate.cmake b/cmake/CheckTemplate.cmake deleted file mode 100644 index 6f695902..00000000 --- a/cmake/CheckTemplate.cmake +++ /dev/null @@ -1,49 +0,0 @@ - -# -# Get cmake-init latest commit SHA on master -# - -file(DOWNLOAD - "https://api.github.com/repos/cginternals/cmake-init/commits/master" - "${PROJECT_BINARY_DIR}/cmake-init.github.data" -) -file(READ - "${PROJECT_BINARY_DIR}/cmake-init.github.data" - CMAKE_INIT_INFO -) - -string(REGEX MATCH - "\"sha\": \"([0-9a-f]+)\"," - CMAKE_INIT_SHA - ${CMAKE_INIT_INFO}) - -string(SUBSTRING - ${CMAKE_INIT_SHA} - 8 - 40 - CMAKE_INIT_SHA -) - -# -# Get latest cmake-init commit on this repository -# - -# APPLIED_CMAKE_INIT_SHA can be set by parent script -if(NOT APPLIED_CMAKE_INIT_SHA) - # [TODO]: Get from git commit list (see cmake_init/source/scripts/check_template.sh) - set(APPLIED_CMAKE_INIT_SHA "") -endif () - -if("${APPLIED_CMAKE_INIT_SHA}" STREQUAL "") - message(WARNING - "No cmake-init version detected, could not verify up-to-dateness. " - "Set the cmake-init version by defining a META_CMAKE_INIT_SHA for your project." - ) - return() -endif() - -if(${APPLIED_CMAKE_INIT_SHA} STREQUAL ${CMAKE_INIT_SHA}) - message(STATUS "cmake-init template is up-to-date (${CMAKE_INIT_SHA})") -else() - message(STATUS "cmake-init template needs an update https://github.com/cginternals/cmake-init/compare/${APPLIED_CMAKE_INIT_SHA}...master") -endif() diff --git a/cmake/ClangTidy.cmake b/cmake/ClangTidy.cmake deleted file mode 100644 index 3e01032b..00000000 --- a/cmake/ClangTidy.cmake +++ /dev/null @@ -1,24 +0,0 @@ - -# Function to register a target for clang-tidy -function(perform_clang_tidy check_target target) - set(includes "$") - - add_custom_target( - ${check_target} - COMMAND - ${clang_tidy_EXECUTABLE} - -p\t${PROJECT_BINARY_DIR} - ${ARGN} - -checks=* - "$<$>:--\t$<$:-I$>>" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - ) - - set_target_properties(${check_target} - PROPERTIES - FOLDER "Maintenance" - EXCLUDE_FROM_DEFAULT_BUILD 1 - ) - - add_dependencies(${check_target} ${target}) -endfunction() diff --git a/cmake/CompileOptions.cmake b/cmake/CompileOptions.cmake deleted file mode 100644 index 89ef21c2..00000000 --- a/cmake/CompileOptions.cmake +++ /dev/null @@ -1,169 +0,0 @@ - -# -# Platform and architecture setup -# - -# Get upper case system name -string(TOUPPER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME_UPPER) - -# Determine architecture (32/64 bit) -set(X64 OFF) -if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(X64 ON) -endif() - - -# -# Project options -# - -set(DEFAULT_PROJECT_OPTIONS - DEBUG_POSTFIX "d" - CXX_STANDARD 17 # Not available before CMake 3.1; see below for manual command line argument addition - LINKER_LANGUAGE "CXX" - POSITION_INDEPENDENT_CODE ON - CXX_VISIBILITY_PRESET "hidden" - CXX_EXTENSIONS Off -) - - -# -# Include directories -# - -set(DEFAULT_INCLUDE_DIRECTORIES) - - -# -# Libraries -# - -set(DEFAULT_LIBRARIES) - - -# -# Compile definitions -# - -set(DEFAULT_COMPILE_DEFINITIONS - SYSTEM_${SYSTEM_NAME_UPPER} -) - -# MSVC compiler options -if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") - set(DEFAULT_COMPILE_DEFINITIONS ${DEFAULT_COMPILE_DEFINITIONS} - _SCL_SECURE_NO_WARNINGS # Calling any one of the potentially unsafe methods in the Standard C++ Library - _CRT_SECURE_NO_WARNINGS # Calling any one of the potentially unsafe methods in the CRT Library - ) -endif () - - -# -# Compile options -# - -set(DEFAULT_COMPILE_OPTIONS) - -# MSVC compiler options -if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") - set(DEFAULT_COMPILE_OPTIONS ${DEFAULT_COMPILE_OPTIONS} - PRIVATE - /MP # -> build with multiple processes - /W4 # -> warning level 4 - # /WX # -> treat warnings as errors - - #$<$: - #/RTCc # -> value is assigned to a smaller data type and results in a data loss - #> - - $<$: - /Gw # -> whole program global optimization - /GS- # -> buffer security check: no - /GL # -> whole program optimization: enable link-time code generation (disables Zi) - /GF # -> enable string pooling - > - - # No manual c++11 enable for MSVC as all supported MSVC versions for cmake-init have C++11 implicitly enabled (MSVC >=2013) - - PUBLIC - /wd4251 # -> disable warning: 'identifier': class 'type' needs to have dll-interface to be used by clients of class 'type2' - /wd4592 # -> disable warning: 'identifier': symbol will be dynamically initialized (implementation limitation) - # /wd4201 # -> disable warning: nonstandard extension used: nameless struct/union (caused by GLM) - # /wd4127 # -> disable warning: conditional expression is constant (caused by Qt) - ) -endif () - -# GCC and Clang compiler options -if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - set(DEFAULT_COMPILE_OPTIONS ${DEFAULT_COMPILE_OPTIONS} - PRIVATE - -Wall - -Wextra - -Wunused - - -Wreorder - -Wignored-qualifiers - -Wmissing-braces - -Wreturn-type - -Wswitch - -Wswitch-default - -Wuninitialized - -Wmissing-field-initializers - - $<$: - -Wmaybe-uninitialized - - $<$,4.8>: - -Wpedantic - - -Wreturn-local-addr - > - > - - $<$: - -Wpedantic - - # -Wreturn-stack-address # gives false positives - > - - $<$: - -fprofile-arcs - -ftest-coverage - > - - PUBLIC - $<$: - -pthread - > - - # Required for CMake < 3.1; should be removed if minimum required CMake version is raised. - $<$: - -std=c++17 - > - ) -endif () - - -# -# Linker options -# - -set(DEFAULT_LINKER_OPTIONS) - -# Use pthreads on mingw and linux -if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_SYSTEM_NAME}" MATCHES "Linux") - set(DEFAULT_LINKER_OPTIONS - PUBLIC - ${DEFAULT_LINKER_OPTIONS} - -pthread - ) - - if (${OPTION_COVERAGE_ENABLED}) - set(DEFAULT_LINKER_OPTIONS - PUBLIC - ${DEFAULT_LINKER_OPTIONS} - -fprofile-arcs - -ftest-coverage - ) - endif () -endif() diff --git a/cmake/ComponentInstall.cmake b/cmake/ComponentInstall.cmake deleted file mode 100644 index 8606060c..00000000 --- a/cmake/ComponentInstall.cmake +++ /dev/null @@ -1,6 +0,0 @@ - -# Execute cmake_install.cmake wrapper that allows to pass both DESTDIR and COMPONENT environment variable - -execute_process( - COMMAND ${CMAKE_COMMAND} -DCOMPONENT=$ENV{COMPONENT} -P cmake_install.cmake -) diff --git a/cmake/Coverage.cmake b/cmake/Coverage.cmake deleted file mode 100644 index ded2a636..00000000 --- a/cmake/Coverage.cmake +++ /dev/null @@ -1,51 +0,0 @@ - -include(${CMAKE_CURRENT_LIST_DIR}/Gcov.cmake) - -set(OPTION_COVERAGE_ENABLED OFF) - -set(LCOV_EXCLUDE_COVERAGE - ${LCOV_EXCLUDE_COVERAGE} - "\"*/googletest/*\"" - "\"*v1*\"" - "\"/usr/*\"" -) - -# Function to register a target for enabled coverage report -function(generate_coverage_report target) - if(NOT TARGET coverage) - add_custom_target(coverage) - - set_target_properties(coverage - PROPERTIES - FOLDER "Maintenance" - EXCLUDE_FROM_DEFAULT_BUILD 1 - ) - endif() - - if (${OPTION_COVERAGE_ENABLED}) - generate_lcov_report(coverage-${target} ${target} ${ARGN}) - add_dependencies(coverage coverage-${target}) - endif() -endfunction() - -# Enable or disable coverage -function(enable_coverage status) - if(NOT ${status}) - set(OPTION_COVERAGE_ENABLED ${status} PARENT_SCOPE) - message(STATUS "Coverage lcov skipped: Manually disabled") - - return() - endif() - - find_package(lcov) - - if(NOT lcov_FOUND) - set(OPTION_COVERAGE_ENABLED OFF PARENT_SCOPE) - message(STATUS "Coverage lcov skipped: lcov not found") - - return() - endif() - - set(OPTION_COVERAGE_ENABLED ${status} PARENT_SCOPE) - message(STATUS "Coverage report enabled") -endfunction() diff --git a/cmake/Cppcheck.cmake b/cmake/Cppcheck.cmake deleted file mode 100644 index 1f9ac05b..00000000 --- a/cmake/Cppcheck.cmake +++ /dev/null @@ -1,26 +0,0 @@ - -# Function to register a target for cppcheck -function(perform_cppcheck check_target target) - set(includes "$") - - add_custom_target( - ${check_target} - COMMAND - ${cppcheck_EXECUTABLE} - "$<$:-I$>" - --enable=all - --std=c++11 - --verbose - --suppress=missingIncludeSystem - ${ARGN} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - ) - - set_target_properties(${check_target} - PROPERTIES - FOLDER "Maintenance" - EXCLUDE_FROM_DEFAULT_BUILD 1 - ) - - add_dependencies(${check_target} ${target}) -endfunction() diff --git a/cmake/Custom.cmake b/cmake/Custom.cmake deleted file mode 100644 index e0e690fc..00000000 --- a/cmake/Custom.cmake +++ /dev/null @@ -1,46 +0,0 @@ - -# Set policy if policy is available -function(set_policy POL VAL) - - if(POLICY ${POL}) - cmake_policy(SET ${POL} ${VAL}) - endif() - -endfunction(set_policy) - - -# Define function "source_group_by_path with three mandatory arguments (PARENT_PATH, REGEX, GROUP, ...) -# to group source files in folders (e.g. for MSVC solutions). -# -# Example: -# source_group_by_path("${CMAKE_CURRENT_SOURCE_DIR}/src" "\\\\.h$|\\\\.inl$|\\\\.cpp$|\\\\.c$|\\\\.ui$|\\\\.qrc$" "Source Files" ${sources}) -function(source_group_by_path PARENT_PATH REGEX GROUP) - - foreach (FILENAME ${ARGN}) - - get_filename_component(FILEPATH "${FILENAME}" REALPATH) - file(RELATIVE_PATH FILEPATH ${PARENT_PATH} ${FILEPATH}) - get_filename_component(FILEPATH "${FILEPATH}" DIRECTORY) - - string(REPLACE "/" "\\" FILEPATH "${FILEPATH}") - - source_group("${GROUP}\\${FILEPATH}" REGULAR_EXPRESSION "${REGEX}" FILES ${FILENAME}) - - endforeach() - -endfunction(source_group_by_path) - - -# Function that extract entries matching a given regex from a list. -# ${OUTPUT} will store the list of matching filenames. -function(list_extract OUTPUT REGEX) - - foreach(FILENAME ${ARGN}) - if(${FILENAME} MATCHES "${REGEX}") - list(APPEND ${OUTPUT} ${FILENAME}) - endif() - endforeach() - - set(${OUTPUT} ${${OUTPUT}} PARENT_SCOPE) - -endfunction(list_extract) diff --git a/cmake/FindASSIMP.cmake b/cmake/FindASSIMP.cmake deleted file mode 100644 index 7dccbf79..00000000 --- a/cmake/FindASSIMP.cmake +++ /dev/null @@ -1,102 +0,0 @@ - -# ASSIMP_FOUND -# ASSIMP_INCLUDE_DIR -# ASSIMP_LIBRARY_RELEASE -# ASSIMP_LIBRARY_DEBUG -# ASSIMP_LIBRARIES -# ASSIMP_BINARY (win32 only) - -include(FindPackageHandleStandardArgs) - -find_path(ASSIMP_INCLUDE_DIR assimp/Importer.hpp - - PATHS - $ENV{ASSIMP_DIR} - $ENV{PROGRAMFILES}/Assimp - /usr - /usr/local - /sw - /opt/local - - PATH_SUFFIXES - /include - - DOC "The directory where assimp/Importer.hpp etc. resides") - -if(MSVC AND X64) - set(ASSIMP_PF "64") -else() - set(ASSIMP_PF "86") -endif() - -find_library(ASSIMP_LIBRARY_RELEASE NAMES assimp - - HINTS - ${ASSIMP_INCLUDE_DIR}/.. - - PATHS - $ENV{ASSIMP_DIR} - /usr - /usr/local - /sw - /opt/local - - PATH_SUFFIXES - /lib - /lib${ASSIMP_PF} - /build/code - /build-debug/code - - DOC "The Assimp library (release)") - -find_library(ASSIMP_LIBRARY_DEBUG NAMES assimpd - - HINTS - ${ASSIMP_INCLUDE_DIR}/.. - - PATHS - $ENV{ASSIMP_DIR} - /usr - /usr/local - /sw - /opt/local - - PATH_SUFFIXES - /lib - /lib${ASSIMP_PF} - /build/code - /build-debug/code - - DOC "The Assimp library (debug)") - -set(ASSIMP_LIBRARIES "") -if(ASSIMP_LIBRARY_RELEASE AND ASSIMP_LIBRARY_DEBUG) - set(ASSIMP_LIBRARIES - optimized ${ASSIMP_LIBRARY_RELEASE} - debug ${ASSIMP_LIBRARY_DEBUG}) -elseif(ASSIMP_LIBRARY_RELEASE) - set(ASSIMP_LIBRARIES ${ASSIMP_LIBRARY_RELEASE}) -elseif(ASSIMP_LIBRARY_DEBUG) - set(ASSIMP_LIBRARIES ${ASSIMP_LIBRARY_DEBUG}) -endif() - -if(WIN32) - - find_file(ASSIMP_BINARY NAMES assimp.dll "assimp${ASSIMP_PF}.dll" - - HINTS - ${ASSIMP_INCLUDE_DIR}/.. - - PATHS - $ENV{ASSIMP_DIR} - - PATH_SUFFIXES - /bin - /bin${ASSIMP_PF} - - DOC "The Assimp binary") - -endif() - -find_package_handle_standard_args(ASSIMP DEFAULT_MSG ASSIMP_LIBRARIES ASSIMP_INCLUDE_DIR) -mark_as_advanced(ASSIMP_FOUND ASSIMP_INCLUDE_DIR ASSIMP_LIBRARIES) diff --git a/cmake/FindEGL.cmake b/cmake/FindEGL.cmake deleted file mode 100644 index ac4ce1aa..00000000 --- a/cmake/FindEGL.cmake +++ /dev/null @@ -1,55 +0,0 @@ - -# EGL::EGL -# EGL_FOUND -# EGL_INCLUDE_DIR -# EGL_LIBRARY - -include(FindPackageHandleStandardArgs) - -find_path(EGL_INCLUDE_DIR EGL/egl.h - - PATHS - $ENV{EGL_DIR} - /usr - /usr/local - /sw - /opt/local - - PATH_SUFFIXES - /include - - DOC "The directory where EGL/egl.h resides") - -find_library(EGL_LIBRARY NAMES EGL - - PATHS - $ENV{EGL_DIR} - /usr - /usr/local - /sw - /opt/local - - # authors prefered choice for development - - PATH_SUFFIXES - /lib - /lib64 - /lib/x86_64-linux-gnu - - DOC "The EGL library") - -add_library(EGL::EGL SHARED IMPORTED) - -set_target_properties(EGL::EGL PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${EGL_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "${EGL_LIBRARY}" -) - -set_property(TARGET EGL::EGL APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) -set_target_properties(EGL::EGL PROPERTIES - IMPORTED_LOCATION_RELEASE "${EGL_LIBRARY}" -) - -find_package_handle_standard_args(EGL REQUIRED_VARS EGL_INCLUDE_DIR EGL_LIBRARY) -mark_as_advanced(EGL_INCLUDE_DIR EGL_LIBRARY) - diff --git a/cmake/FindFFMPEG.cmake b/cmake/FindFFMPEG.cmake deleted file mode 100644 index 7dccd6f9..00000000 --- a/cmake/FindFFMPEG.cmake +++ /dev/null @@ -1,79 +0,0 @@ - -# - Try to find ffmpeg libraries (libavcodec, libavformat and libavutil) -# Once done this will define -# -# FFMPEG_FOUND - system has ffmpeg or libav -# FFMPEG_INCLUDE_DIR - the ffmpeg include directory -# FFMPEG_LIBRARIES - Link these to use ffmpeg -# FFMPEG_LIBAVCODEC -# FFMPEG_LIBAVFORMAT -# FFMPEG_LIBAVUTIL -# FFMPEG_LIBSWSCALE -# -# Copyright (c) 2008 Andreas Schneider -# Modified for other libraries by Lasse Kärkkäinen -# Modified for Hedgewars by Stepik777 -# -# Redistribution and use is allowed according to the terms of the New -# BSD license. -# - -include(FindPackageHandleStandardArgs) - -if (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) - # in cache already - set(FFMPEG_FOUND TRUE) -else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) - find_path(FFMPEG_AVCODEC_INCLUDE_DIR - NAMES libavcodec/avcodec.h - PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS} /usr/include /usr/local/include /opt/local/include /sw/include - PATH_SUFFIXES ffmpeg libav - ) - - find_library(FFMPEG_LIBAVCODEC - NAMES avcodec - PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib - ) - - find_library(FFMPEG_LIBAVFORMAT - NAMES avformat - PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib - ) - - find_library(FFMPEG_LIBAVUTIL - NAMES avutil - PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib - ) - - find_library(FFMPEG_LIBSWSCALE - NAMES swscale - PATHS ${_FFMPEG_SWSCALE_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib - ) - - if (FFMPEG_LIBAVCODEC AND FFMPEG_LIBAVFORMAT) - set(FFMPEG_FOUND TRUE) - endif() - - if (FFMPEG_FOUND) - set(FFMPEG_INCLUDE_DIR ${FFMPEG_AVCODEC_INCLUDE_DIR}) - - set(FFMPEG_LIBRARIES - ${FFMPEG_LIBAVCODEC} - ${FFMPEG_LIBAVFORMAT} - ${FFMPEG_LIBAVUTIL} - ${FFMPEG_LIBSWSCALE} - ) - - endif (FFMPEG_FOUND) - - if (FFMPEG_FOUND) - if (NOT FFMPEG_FIND_QUIETLY) - message(STATUS "Found FFMPEG or Libav: ${FFMPEG_LIBRARIES}, ${FFMPEG_INCLUDE_DIR}") - endif (NOT FFMPEG_FIND_QUIETLY) - else (FFMPEG_FOUND) - if (FFMPEG_FIND_REQUIRED) - message(FATAL_ERROR "Could not find libavcodec or libavformat or libavutil") - endif (FFMPEG_FIND_REQUIRED) - endif (FFMPEG_FOUND) - -endif (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) diff --git a/cmake/FindGLESv2.cmake b/cmake/FindGLESv2.cmake deleted file mode 100644 index c7c47b66..00000000 --- a/cmake/FindGLESv2.cmake +++ /dev/null @@ -1,55 +0,0 @@ - -# GLESv2::GLESv2 -# GLESv2_FOUND -# GLESv2_INCLUDE_DIR -# GLESv2_LIBRARY - -include(FindPackageHandleStandardArgs) - -find_path(GLESv2_INCLUDE_DIR GLES2/gl2.h - - PATHS - $ENV{GLESv2_DIR} - /usr - /usr/local - /sw - /opt/local - - PATH_SUFFIXES - /include - - DOC "The directory where GLESv2/GLESv2.h resides") - -find_library(GLESv2_LIBRARY NAMES GLESv2 - - PATHS - $ENV{GLESv2_DIR} - /usr - /usr/local - /sw - /opt/local - - # authors prefered choice for development - - PATH_SUFFIXES - /lib - /lib64 - /lib/x86_64-linux-gnu - - DOC "The GLESv2 library") - -add_library(GLESv2::GLESv2 SHARED IMPORTED) - -set_target_properties(GLESv2::GLESv2 PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${GLESv2_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "${GLESv2_LIBRARY}" -) - -set_property(TARGET GLESv2::GLESv2 APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) -set_target_properties(GLESv2::GLESv2 PROPERTIES - IMPORTED_LOCATION_RELEASE "${GLESv2_LIBRARY}" -) - -find_package_handle_standard_args(GLESv2 REQUIRED_VARS GLESv2_INCLUDE_DIR GLESv2_LIBRARY) -mark_as_advanced(GLESv2_INCLUDE_DIR GLESv2_LIBRARY) - diff --git a/cmake/FindGLEW.cmake b/cmake/FindGLEW.cmake deleted file mode 100644 index de6c6b79..00000000 --- a/cmake/FindGLEW.cmake +++ /dev/null @@ -1,73 +0,0 @@ - -# GLEW_FOUND -# GLEW_INCLUDE_DIR -# GLEW_LIBRARY - -# GLEW_BINARY (win32 only) - -include(FindPackageHandleStandardArgs) - -find_path(GLEW_INCLUDE_DIR GL/glew.h - - PATHS - $ENV{GLEW_DIR} - /usr - /usr/local - /sw - /opt/local - - PATH_SUFFIXES - /include - - DOC "The directory where GL/glew.h resides") - -if (X64) - set(GLEW_BUILD_DIR Release/x64) -else() - set(GLEW_BUILD_DIR Release/Win32) -endif() - -find_library(GLEW_LIBRARY NAMES GLEW glew glew32 glew32s - - PATHS - $ENV{GLEW_DIR} - /usr - /usr/local - /sw - /opt/local - - # authors prefered choice for development - /build - /build-release - /build-debug - $ENV{GLEW_DIR}/build - $ENV{GLEW_DIR}/build-release - $ENV{GLEW_DIR}/build-debug - - PATH_SUFFIXES - /lib - /lib64 - /lib/${GLEW_BUILD_DIR} - - DOC "The GLEW library") - -if(WIN32) - - find_file(GLEW_BINARY NAMES glew32.dll glew32s.dll - - HINTS - ${GLEW_INCLUDE_DIR}/.. - - PATHS - $ENV{GLEW_DIR} - - PATH_SUFFIXES - /bin - /bin/${GLEW_BUILD_DIR} - - DOC "The GLEW binary") - -endif() - -find_package_handle_standard_args(GLEW REQUIRED_VARS GLEW_INCLUDE_DIR GLEW_LIBRARY) -mark_as_advanced(GLEW_INCLUDE_DIR GLEW_LIBRARY) diff --git a/cmake/FindHIDAPI.cmake b/cmake/FindHIDAPI.cmake deleted file mode 100644 index 51082705..00000000 --- a/cmake/FindHIDAPI.cmake +++ /dev/null @@ -1,33 +0,0 @@ - -# HIDAPI_FOUND -# HIDAPI_INCLUDE_DIRS -# HIDAPI_LIBRARIES - -include(FindPackageHandleStandardArgs) - -find_path(HIDAPI_INCLUDE_DIRS - NAMES hidapi/hidapi.h - /usr/include - /usr/local/include - /sw/include - /opt/local/include - DOC "The directory where hidapi/hidapi.h resides") - -find_library(HIDAPI_LIBRARIES - NAMES hidapi-hidraw hidapi-libusb - PATHS - /usr/lib64 - /usr/local/lib64 - /sw/lib64 - /opt/loca/lib64 - /usr/lib - /usr/local/lib - /sw/lib - /opt/local/lib - DOC "The hidapi library") - - -find_package_handle_standard_args(HIDAPI REQUIRED_VARS HIDAPI_LIBRARIES HIDAPI_INCLUDE_DIRS) - -mark_as_advanced(HIDAPI_INCLUDE_DIR HIDAPI_LIBRARY) - diff --git a/cmake/FindSDL2.cmake b/cmake/FindSDL2.cmake deleted file mode 100644 index 7c275ed9..00000000 --- a/cmake/FindSDL2.cmake +++ /dev/null @@ -1,249 +0,0 @@ -# - Find SDL2 -# Find the SDL2 headers and libraries -# -# SDL2::SDL2 - Imported target to use for building a library -# SDL2::SDL2main - Imported interface target to use if you want SDL and SDLmain. -# SDL2_FOUND - True if SDL2 was found. -# SDL2_DYNAMIC - If we found a DLL version of SDL (meaning you might want to copy a DLL from SDL2::SDL2) -# -# Original Author: -# 2015 Ryan Pavlik -# -# Copyright Sensics, Inc. 2015. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -# Set up architectures (for windows) and prefixes (for mingw builds) -if(WIN32) - if(MINGW) - include(MinGWSearchPathExtras OPTIONAL) - if(MINGWSEARCH_TARGET_TRIPLE) - set(SDL2_PREFIX ${MINGWSEARCH_TARGET_TRIPLE}) - endif() - endif() - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(SDL2_LIB_PATH_SUFFIX lib/x64) - if(NOT MSVC AND NOT SDL2_PREFIX) - set(SDL2_PREFIX x86_64-w64-mingw32) - endif() - else() - set(SDL2_LIB_PATH_SUFFIX lib/x86) - if(NOT MSVC AND NOT SDL2_PREFIX) - set(SDL2_PREFIX i686-w64-mingw32) - endif() - endif() -endif() - -if(SDL2_PREFIX) - set(SDL2_ORIGPREFIXPATH ${CMAKE_PREFIX_PATH}) - if(SDL2_ROOT_DIR) - list(APPEND CMAKE_PREFIX_PATH "${SDL2_ROOT_DIR}") - endif() - if(CMAKE_PREFIX_PATH) - foreach(_prefix ${CMAKE_PREFIX_PATH}) - list(APPEND CMAKE_PREFIX_PATH "${_prefix}/${SDL2_PREFIX}") - endforeach() - endif() - if(MINGWSEARCH_PREFIXES) - list(APPEND CMAKE_PREFIX_PATH ${MINGWSEARCH_PREFIXES}) - endif() -endif() - -# Invoke pkgconfig for hints -find_package(PkgConfig QUIET) -set(SDL2_INCLUDE_HINTS) -set(SDL2_LIB_HINTS) -if(PKG_CONFIG_FOUND) - pkg_search_module(SDL2PC QUIET sdl2) - if(SDL2PC_INCLUDE_DIRS) - set(SDL2_INCLUDE_HINTS ${SDL2PC_INCLUDE_DIRS}) - endif() - if(SDL2PC_LIBRARY_DIRS) - set(SDL2_LIB_HINTS ${SDL2PC_LIBRARY_DIRS}) - endif() -endif() - -include(FindPackageHandleStandardArgs) - -find_library(SDL2_LIBRARY - NAMES - SDL2 - HINTS - ${SDL2_LIB_HINTS} - PATHS - ${SDL2_ROOT_DIR} - ENV SDL2DIR - PATH_SUFFIXES lib SDL2 ${SDL2_LIB_PATH_SUFFIX}) - -set(_sdl2_framework FALSE) -# Some special-casing if we've found/been given a framework. -# Handles whether we're given the library inside the framework or the framework itself. -if(APPLE AND "${SDL2_LIBRARY}" MATCHES "(/[^/]+)*.framework(/.*)?$") - set(_sdl2_framework TRUE) - set(SDL2_FRAMEWORK "${SDL2_LIBRARY}") - # Move up in the directory tree as required to get the framework directory. - while("${SDL2_FRAMEWORK}" MATCHES "(/[^/]+)*.framework(/.*)$" AND NOT "${SDL2_FRAMEWORK}" MATCHES "(/[^/]+)*.framework$") - get_filename_component(SDL2_FRAMEWORK "${SDL2_FRAMEWORK}" DIRECTORY) - endwhile() - if("${SDL2_FRAMEWORK}" MATCHES "(/[^/]+)*.framework$") - set(SDL2_FRAMEWORK_NAME ${CMAKE_MATCH_1}) - # If we found a framework, do a search for the header ahead of time that will be more likely to get the framework header. - find_path(SDL2_INCLUDE_DIR - NAMES - SDL_haptic.h # this file was introduced with SDL2 - HINTS - "${SDL2_FRAMEWORK}/Headers/") - else() - # For some reason we couldn't get the framework directory itself. - # Shouldn't happen, but might if something is weird. - unset(SDL2_FRAMEWORK) - endif() -endif() - -find_path(SDL2_INCLUDE_DIR - NAMES - SDL_haptic.h # this file was introduced with SDL2 - HINTS - ${SDL2_INCLUDE_HINTS} - PATHS - ${SDL2_ROOT_DIR} - ENV SDL2DIR - PATH_SUFFIXES include include/sdl2 include/SDL2 SDL2) - -if(WIN32 AND SDL2_LIBRARY) - find_file(SDL2_RUNTIME_LIBRARY - NAMES - SDL2.dll - libSDL2.dll - HINTS - ${SDL2_LIB_HINTS} - PATHS - ${SDL2_ROOT_DIR} - ENV SDL2DIR - PATH_SUFFIXES bin lib ${SDL2_LIB_PATH_SUFFIX}) -endif() - - -if(WIN32 OR ANDROID OR IOS OR (APPLE AND NOT _sdl2_framework)) - set(SDL2_EXTRA_REQUIRED SDL2_SDLMAIN_LIBRARY) - find_library(SDL2_SDLMAIN_LIBRARY - NAMES - SDL2main - PATHS - ${SDL2_ROOT_DIR} - ENV SDL2DIR - PATH_SUFFIXES lib ${SDL2_LIB_PATH_SUFFIX}) -endif() - -if(MINGW AND NOT SDL2PC_FOUND) - find_library(SDL2_MINGW_LIBRARY mingw32) - find_library(SDL2_MWINDOWS_LIBRARY mwindows) -endif() - -if(SDL2_PREFIX) - # Restore things the way they used to be. - set(CMAKE_PREFIX_PATH ${SDL2_ORIGPREFIXPATH}) -endif() - -# handle the QUIETLY and REQUIRED arguments and set QUATLIB_FOUND to TRUE if -# all listed variables are TRUE -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(SDL2 - DEFAULT_MSG - SDL2_LIBRARY - SDL2_INCLUDE_DIR - ${SDL2_EXTRA_REQUIRED}) - -if(SDL2_FOUND) - if(NOT TARGET SDL2::SDL2) - # Create SDL2::SDL2 - if(WIN32 AND SDL2_RUNTIME_LIBRARY) - set(SDL2_DYNAMIC TRUE) - add_library(SDL2::SDL2 SHARED IMPORTED) - set_target_properties(SDL2::SDL2 - PROPERTIES - IMPORTED_IMPLIB "${SDL2_LIBRARY}" - IMPORTED_LOCATION "${SDL2_RUNTIME_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}" - ) - else() - add_library(SDL2::SDL2 UNKNOWN IMPORTED) - if(SDL2_FRAMEWORK AND SDL2_FRAMEWORK_NAME) - # Handle the case that SDL2 is a framework and we were able to decompose it above. - set_target_properties(SDL2::SDL2 PROPERTIES - IMPORTED_LOCATION "${SDL2_FRAMEWORK}/${SDL2_FRAMEWORK_NAME}") - elseif(_sdl2_framework AND SDL2_LIBRARY MATCHES "(/[^/]+)*.framework$") - # Handle the case that SDL2 is a framework and SDL_LIBRARY is just the framework itself. - - # This takes the basename of the framework, without the extension, - # and sets it (as a child of the framework) as the imported location for the target. - # This is the library symlink inside of the framework. - set_target_properties(SDL2::SDL2 PROPERTIES - IMPORTED_LOCATION "${SDL2_LIBRARY}/${CMAKE_MATCH_1}") - else() - # Handle non-frameworks (including non-Mac), as well as the case that we're given the library inside of the framework - set_target_properties(SDL2::SDL2 PROPERTIES - IMPORTED_LOCATION "${SDL2_LIBRARY}") - endif() - set_target_properties(SDL2::SDL2 - PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}" - ) - endif() - - if(APPLE) - # Need Cocoa here, is always a framework - find_library(SDL2_COCOA_LIBRARY Cocoa) - list(APPEND SDL2_EXTRA_REQUIRED SDL2_COCOA_LIBRARY) - if(SDL2_COCOA_LIBRARY) - set_target_properties(SDL2::SDL2 PROPERTIES - IMPORTED_LINK_INTERFACE_LIBRARIES ${SDL2_COCOA_LIBRARY}) - endif() - endif() - - - # Compute what to do with SDL2main - set(SDL2MAIN_LIBRARIES SDL2::SDL2) - add_library(SDL2::SDL2main INTERFACE IMPORTED) - if(SDL2_SDLMAIN_LIBRARY) - add_library(SDL2::SDL2main_real STATIC IMPORTED) - set_target_properties(SDL2::SDL2main_real - PROPERTIES - IMPORTED_LOCATION "${SDL2_SDLMAIN_LIBRARY}") - set(SDL2MAIN_LIBRARIES SDL2::SDL2main_real ${SDL2MAIN_LIBRARIES}) - endif() - if(MINGW) - # MinGW requires some additional libraries to appear earlier in the link line. - if(SDL2PC_LIBRARIES) - # Use pkgconfig-suggested extra libraries if available. - list(REMOVE_ITEM SDL2PC_LIBRARIES SDL2main SDL2) - set(SDL2MAIN_LIBRARIES ${SDL2PC_LIBRARIES} ${SDL2MAIN_LIBRARIES}) - else() - # fall back to extra libraries specified in pkg-config in - # an official binary distro of SDL2 for MinGW I downloaded - if(SDL2_MINGW_LIBRARY) - set(SDL2MAIN_LIBRARIES ${SDL2_MINGW_LIBRARY} ${SDL2MAIN_LIBRARIES}) - endif() - if(SDL2_MWINDOWS_LIBRARY) - set(SDL2MAIN_LIBRARIES ${SDL2_MWINDOWS_LIBRARY} ${SDL2MAIN_LIBRARIES}) - endif() - endif() - set_target_properties(SDL2::SDL2main - PROPERTIES - INTERFACE_COMPILE_DEFINITIONS "main=SDL_main") - endif() - set_target_properties(SDL2::SDL2main - PROPERTIES - INTERFACE_LINK_LIBRARIES "${SDL2MAIN_LIBRARIES}") - endif() - mark_as_advanced(SDL2_ROOT_DIR) -endif() - -mark_as_advanced(SDL2_LIBRARY - SDL2_RUNTIME_LIBRARY - SDL2_INCLUDE_DIR - SDL2_SDLMAIN_LIBRARY - SDL2_COCOA_LIBRARY - SDL2_MINGW_LIBRARY - SDL2_MWINDOWS_LIBRARY) \ No newline at end of file diff --git a/cmake/FindSDL2_image.cmake b/cmake/FindSDL2_image.cmake deleted file mode 100644 index 624e9154..00000000 --- a/cmake/FindSDL2_image.cmake +++ /dev/null @@ -1,222 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -# Copyright 2019 Amine Ben Hassouna -# Copyright 2000-2019 Kitware, Inc. and Contributors -# All rights reserved. - -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: - -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. - -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. - -# * Neither the name of Kitware, Inc. nor the names of Contributors -# may be used to endorse or promote products derived from this -# software without specific prior written permission. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#[=======================================================================[.rst: -FindSDL2_image --------------- - -Locate SDL2_image library - -This module defines the following 'IMPORTED' target: - -:: - - SDL2::Image - The SDL2_image library, if found. - Have SDL2::Core as a link dependency. - - - -This module will set the following variables in your project: - -:: - - SDL2_IMAGE_LIBRARIES, the name of the library to link against - SDL2_IMAGE_INCLUDE_DIRS, where to find the headers - SDL2_IMAGE_FOUND, if false, do not try to link against - SDL2_IMAGE_VERSION_STRING - human-readable string containing the - version of SDL2_image - - - -This module responds to the following cache variables: - -:: - - SDL2_IMAGE_PATH - Set a custom SDL2_image Library path (default: empty) - - SDL2_IMAGE_NO_DEFAULT_PATH - Disable search SDL2_image Library in default path. - If SDL2_IMAGE_PATH (default: ON) - Else (default: OFF) - - SDL2_IMAGE_INCLUDE_DIR - SDL2_image headers path. - - SDL2_IMAGE_LIBRARY - SDL2_image Library (.dll, .so, .a, etc) path. - - -Additional Note: If you see an empty SDL2_IMAGE_LIBRARY in your project -configuration, it means CMake did not find your SDL2_image library -(SDL2_image.dll, libsdl2_image.so, etc). Set SDL2_IMAGE_LIBRARY to point -to your SDL2_image library, and configure again. This value is used to -generate the final SDL2_IMAGE_LIBRARIES variable and the SDL2::Image target, -but when this value is unset, SDL2_IMAGE_LIBRARIES and SDL2::Image does not -get created. - - -$SDL2IMAGEDIR is an environment variable that would correspond to the -./configure --prefix=$SDL2IMAGEDIR used in building SDL2_image. - -$SDL2DIR is an environment variable that would correspond to the -./configure --prefix=$SDL2DIR used in building SDL2. - - - -Created by Amine Ben Hassouna: - Adapt FindSDL_image.cmake to SDL2_image (FindSDL2_image.cmake). - Add cache variables for more flexibility: - SDL2_IMAGE_PATH, SDL2_IMAGE_NO_DEFAULT_PATH (for details, see doc above). - Add SDL2 as a required dependency. - Modernize the FindSDL2_image.cmake module by creating a specific target: - SDL2::Image (for details, see doc above). - -Original FindSDL_image.cmake module: - Created by Eric Wing. This was influenced by the FindSDL.cmake - module, but with modifications to recognize OS X frameworks and - additional Unix paths (FreeBSD, etc). -#]=======================================================================] - -# SDL2 Library required -find_package(SDL2 QUIET) -if(NOT SDL2_FOUND) - set(SDL2_IMAGE_SDL2_NOT_FOUND "Could NOT find SDL2 (SDL2 is required by SDL2_image).") - if(SDL2_image_FIND_REQUIRED) - message(FATAL_ERROR ${SDL2_IMAGE_SDL2_NOT_FOUND}) - else() - if(NOT SDL2_image_FIND_QUIETLY) - message(STATUS ${SDL2_IMAGE_SDL2_NOT_FOUND}) - endif() - return() - endif() - unset(SDL2_IMAGE_SDL2_NOT_FOUND) -endif() - - -# Define options for searching SDL2_image Library in a custom path - -set(SDL2_IMAGE_PATH "" CACHE STRING "Custom SDL2_image Library path") - -set(_SDL2_IMAGE_NO_DEFAULT_PATH OFF) -if(SDL2_IMAGE_PATH) - set(_SDL2_IMAGE_NO_DEFAULT_PATH ON) -endif() - -set(SDL2_IMAGE_NO_DEFAULT_PATH ${_SDL2_IMAGE_NO_DEFAULT_PATH} - CACHE BOOL "Disable search SDL2_image Library in default path") -unset(_SDL2_IMAGE_NO_DEFAULT_PATH) - -set(SDL2_IMAGE_NO_DEFAULT_PATH_CMD) -if(SDL2_IMAGE_NO_DEFAULT_PATH) - set(SDL2_IMAGE_NO_DEFAULT_PATH_CMD NO_DEFAULT_PATH) -endif() - -# Search for the SDL2_image include directory -find_path(SDL2_IMAGE_INCLUDE_DIR SDL_image.h - HINTS - ENV SDL2IMAGEDIR - ENV SDL2DIR - ${SDL2_IMAGE_NO_DEFAULT_PATH_CMD} - PATH_SUFFIXES SDL2 - # path suffixes to search inside ENV{SDL2DIR} - # and ENV{SDL2IMAGEDIR} - include/SDL2 include - PATHS ${SDL2_IMAGE_PATH} - DOC "Where the SDL2_image headers can be found" -) - -if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(VC_LIB_PATH_SUFFIX lib/x64) -else() - set(VC_LIB_PATH_SUFFIX lib/x86) -endif() - -# Search for the SDL2_image library -find_library(SDL2_IMAGE_LIBRARY - NAMES SDL2_image - HINTS - ENV SDL2IMAGEDIR - ENV SDL2DIR - ${SDL2_IMAGE_NO_DEFAULT_PATH_CMD} - PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} - PATHS ${SDL2_IMAGE_PATH} - DOC "Where the SDL2_image Library can be found" -) - -# Read SDL2_image version -if(SDL2_IMAGE_INCLUDE_DIR AND EXISTS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h") - file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+[0-9]+$") - string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_MAJOR "${SDL2_IMAGE_VERSION_MAJOR_LINE}") - string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_MINOR "${SDL2_IMAGE_VERSION_MINOR_LINE}") - string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_PATCH "${SDL2_IMAGE_VERSION_PATCH_LINE}") - set(SDL2_IMAGE_VERSION_STRING ${SDL2_IMAGE_VERSION_MAJOR}.${SDL2_IMAGE_VERSION_MINOR}.${SDL2_IMAGE_VERSION_PATCH}) - unset(SDL2_IMAGE_VERSION_MAJOR_LINE) - unset(SDL2_IMAGE_VERSION_MINOR_LINE) - unset(SDL2_IMAGE_VERSION_PATCH_LINE) - unset(SDL2_IMAGE_VERSION_MAJOR) - unset(SDL2_IMAGE_VERSION_MINOR) - unset(SDL2_IMAGE_VERSION_PATCH) -endif() - -set(SDL2_IMAGE_LIBRARIES ${SDL2_IMAGE_LIBRARY}) -set(SDL2_IMAGE_INCLUDE_DIRS ${SDL2_IMAGE_INCLUDE_DIR}) - -include(FindPackageHandleStandardArgs) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_image - REQUIRED_VARS SDL2_IMAGE_LIBRARIES SDL2_IMAGE_INCLUDE_DIRS - VERSION_VAR SDL2_IMAGE_VERSION_STRING) - - -mark_as_advanced(SDL2_IMAGE_PATH - SDL2_IMAGE_NO_DEFAULT_PATH - SDL2_IMAGE_LIBRARY - SDL2_IMAGE_INCLUDE_DIR) - - -if(SDL2_IMAGE_FOUND) - - # SDL2::Image target - if(SDL2_IMAGE_LIBRARY AND NOT TARGET SDL2::Image) - add_library(SDL2::Image UNKNOWN IMPORTED) - set_target_properties(SDL2::Image PROPERTIES - IMPORTED_LOCATION "${SDL2_IMAGE_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${SDL2_IMAGE_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES SDL2::Core) - endif() -endif() diff --git a/cmake/FindSDL2_ttf.cmake b/cmake/FindSDL2_ttf.cmake deleted file mode 100644 index 2ab9a76b..00000000 --- a/cmake/FindSDL2_ttf.cmake +++ /dev/null @@ -1,222 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -# Copyright 2019 Amine Ben Hassouna -# Copyright 2000-2019 Kitware, Inc. and Contributors -# All rights reserved. - -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: - -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. - -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. - -# * Neither the name of Kitware, Inc. nor the names of Contributors -# may be used to endorse or promote products derived from this -# software without specific prior written permission. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#[=======================================================================[.rst: -FindSDL2_ttf ------------- - -Locate SDL2_ttf library - -This module defines the following 'IMPORTED' target: - -:: - - SDL2::TTF - The SDL2_ttf library, if found. - Have SDL2::Core as a link dependency. - - - -This module will set the following variables in your project: - -:: - - SDL2_TTF_LIBRARIES, the name of the library to link against - SDL2_TTF_INCLUDE_DIRS, where to find the headers - SDL2_TTF_FOUND, if false, do not try to link against - SDL2_TTF_VERSION_STRING - human-readable string containing the - version of SDL2_ttf - - - -This module responds to the following cache variables: - -:: - - SDL2_TTF_PATH - Set a custom SDL2_ttf Library path (default: empty) - - SDL2_TTF_NO_DEFAULT_PATH - Disable search SDL2_ttf Library in default path. - If SDL2_TTF_PATH (default: ON) - Else (default: OFF) - - SDL2_TTF_INCLUDE_DIR - SDL2_ttf headers path. - - SDL2_TTF_LIBRARY - SDL2_ttf Library (.dll, .so, .a, etc) path. - - -Additional Note: If you see an empty SDL2_TTF_LIBRARY in your project -configuration, it means CMake did not find your SDL2_ttf library -(SDL2_ttf.dll, libsdl2_ttf.so, etc). Set SDL2_TTF_LIBRARY to point -to your SDL2_ttf library, and configure again. This value is used to -generate the final SDL2_TTF_LIBRARIES variable and the SDL2::TTF target, -but when this value is unset, SDL2_TTF_LIBRARIES and SDL2::TTF does not -get created. - - -$SDL2TTFDIR is an environment variable that would correspond to the -./configure --prefix=$SDL2TTFDIR used in building SDL2_ttf. - -$SDL2DIR is an environment variable that would correspond to the -./configure --prefix=$SDL2DIR used in building SDL2. - - - -Created by Amine Ben Hassouna: - Adapt FindSDL_ttf.cmake to SDL2_ttf (FindSDL2_ttf.cmake). - Add cache variables for more flexibility: - SDL2_TTF_PATH, SDL2_TTF_NO_DEFAULT_PATH (for details, see doc above). - Add SDL2 as a required dependency. - Modernize the FindSDL2_ttf.cmake module by creating a specific target: - SDL2::TTF (for details, see doc above). - -Original FindSDL_ttf.cmake module: - Created by Eric Wing. This was influenced by the FindSDL.cmake - module, but with modifications to recognize OS X frameworks and - additional Unix paths (FreeBSD, etc). -#]=======================================================================] - -# SDL2 Library required -find_package(SDL2 QUIET) -if(NOT SDL2_FOUND) - set(SDL2_TTF_SDL2_NOT_FOUND "Could NOT find SDL2 (SDL2 is required by SDL2_ttf).") - if(SDL2_ttf_FIND_REQUIRED) - message(FATAL_ERROR ${SDL2_TTF_SDL2_NOT_FOUND}) - else() - if(NOT SDL2_ttf_FIND_QUIETLY) - message(STATUS ${SDL2_TTF_SDL2_NOT_FOUND}) - endif() - return() - endif() - unset(SDL2_TTF_SDL2_NOT_FOUND) -endif() - - -# Define options for searching SDL2_ttf Library in a custom path - -set(SDL2_TTF_PATH "" CACHE STRING "Custom SDL2_ttf Library path") - -set(_SDL2_TTF_NO_DEFAULT_PATH OFF) -if(SDL2_TTF_PATH) - set(_SDL2_TTF_NO_DEFAULT_PATH ON) -endif() - -set(SDL2_TTF_NO_DEFAULT_PATH ${_SDL2_TTF_NO_DEFAULT_PATH} - CACHE BOOL "Disable search SDL2_ttf Library in default path") -unset(_SDL2_TTF_NO_DEFAULT_PATH) - -set(SDL2_TTF_NO_DEFAULT_PATH_CMD) -if(SDL2_TTF_NO_DEFAULT_PATH) - set(SDL2_TTF_NO_DEFAULT_PATH_CMD NO_DEFAULT_PATH) -endif() - -# Search for the SDL2_ttf include directory -find_path(SDL2_TTF_INCLUDE_DIR SDL_ttf.h - HINTS - ENV SDL2TTFDIR - ENV SDL2DIR - ${SDL2_TTF_NO_DEFAULT_PATH_CMD} - PATH_SUFFIXES SDL2 - # path suffixes to search inside ENV{SDL2DIR} - # and ENV{SDL2TTFDIR} - include/SDL2 include - PATHS ${SDL2_TTF_PATH} - DOC "Where the SDL2_ttf headers can be found" -) - -if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(VC_LIB_PATH_SUFFIX lib/x64) -else() - set(VC_LIB_PATH_SUFFIX lib/x86) -endif() - -# Search for the SDL2_ttf library -find_library(SDL2_TTF_LIBRARY - NAMES SDL2_ttf - HINTS - ENV SDL2TTFDIR - ENV SDL2DIR - ${SDL2_TTF_NO_DEFAULT_PATH_CMD} - PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} - PATHS ${SDL2_TTF_PATH} - DOC "Where the SDL2_ttf Library can be found" -) - -# Read SDL2_ttf version -if(SDL2_TTF_INCLUDE_DIR AND EXISTS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h") - file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+[0-9]+$") - string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_MAJOR "${SDL2_TTF_VERSION_MAJOR_LINE}") - string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_MINOR "${SDL2_TTF_VERSION_MINOR_LINE}") - string(REGEX REPLACE "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_PATCH "${SDL2_TTF_VERSION_PATCH_LINE}") - set(SDL2_TTF_VERSION_STRING ${SDL2_TTF_VERSION_MAJOR}.${SDL2_TTF_VERSION_MINOR}.${SDL2_TTF_VERSION_PATCH}) - unset(SDL2_TTF_VERSION_MAJOR_LINE) - unset(SDL2_TTF_VERSION_MINOR_LINE) - unset(SDL2_TTF_VERSION_PATCH_LINE) - unset(SDL2_TTF_VERSION_MAJOR) - unset(SDL2_TTF_VERSION_MINOR) - unset(SDL2_TTF_VERSION_PATCH) -endif() - -set(SDL2_TTF_LIBRARIES ${SDL2_TTF_LIBRARY}) -set(SDL2_TTF_INCLUDE_DIRS ${SDL2_TTF_INCLUDE_DIR}) - -include(FindPackageHandleStandardArgs) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_ttf - REQUIRED_VARS SDL2_TTF_LIBRARIES SDL2_TTF_INCLUDE_DIRS - VERSION_VAR SDL2_TTF_VERSION_STRING) - - -mark_as_advanced(SDL2_TTF_PATH - SDL2_TTF_NO_DEFAULT_PATH - SDL2_TTF_LIBRARY - SDL2_TTF_INCLUDE_DIR) - - -if(SDL2_TTF_FOUND) - - # SDL2::TTF target - if(SDL2_TTF_LIBRARY AND NOT TARGET SDL2::TTF) - add_library(SDL2::TTF UNKNOWN IMPORTED) - set_target_properties(SDL2::TTF PROPERTIES - IMPORTED_LOCATION "${SDL2_TTF_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${SDL2_TTF_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES SDL2::Core) - endif() -endif() diff --git a/cmake/Findclang_tidy.cmake b/cmake/Findclang_tidy.cmake deleted file mode 100644 index c29dfcdf..00000000 --- a/cmake/Findclang_tidy.cmake +++ /dev/null @@ -1,28 +0,0 @@ - -# Findclang_tidy results: -# clang_tidy_FOUND -# clang_tidy_EXECUTABLE - -include(FindPackageHandleStandardArgs) - -find_program(clang_tidy_EXECUTABLE - NAMES - clang-tidy-3.5 - clang-tidy-3.6 - clang-tidy-3.7 - clang-tidy-3.8 - clang-tidy-3.9 - clang-tidy-4.0 - clang-tidy - PATHS - "${CLANG_TIDY_DIR}" -) - -find_package_handle_standard_args(clang_tidy - FOUND_VAR - clang_tidy_FOUND - REQUIRED_VARS - clang_tidy_EXECUTABLE -) - -mark_as_advanced(clang_tidy_EXECUTABLE) \ No newline at end of file diff --git a/cmake/Findcppcheck.cmake b/cmake/Findcppcheck.cmake deleted file mode 100644 index c90e7cd0..00000000 --- a/cmake/Findcppcheck.cmake +++ /dev/null @@ -1,28 +0,0 @@ - -# Findcppcheck results: -# cppcheck_FOUND -# cppcheck_EXECUTABLE - -include(FindPackageHandleStandardArgs) - -# work around CMP0053, see http://public.kitware.com/pipermail/cmake/2014-November/059117.html -set(PROGRAMFILES_x86_ENV "PROGRAMFILES(x86)") - -find_program(cppcheck_EXECUTABLE - NAMES - cppcheck - PATHS - "${CPPCHECK_DIR}" - "$ENV{CPPCHECK_DIR}" - "$ENV{PROGRAMFILES}/Cppcheck" - "$ENV{${PROGRAMFILES_x86_ENV}}/Cppcheck" -) - -find_package_handle_standard_args(cppcheck - FOUND_VAR - cppcheck_FOUND - REQUIRED_VARS - cppcheck_EXECUTABLE -) - -mark_as_advanced(cppcheck_EXECUTABLE) diff --git a/cmake/Findgcov.cmake b/cmake/Findgcov.cmake deleted file mode 100644 index 99666cef..00000000 --- a/cmake/Findgcov.cmake +++ /dev/null @@ -1,28 +0,0 @@ - -# Findgcov results: -# gcov_FOUND -# gcov_EXECUTABLE - -include(FindPackageHandleStandardArgs) - -# work around CMP0053, see http://public.kitware.com/pipermail/cmake/2014-November/059117.html -set(PROGRAMFILES_x86_ENV "PROGRAMFILES(x86)") - -find_program(gcov_EXECUTABLE - NAMES - gcov - PATHS - "${GCOV_DIR}" - "$ENV{GCOV_DIR}" - "$ENV{PROGRAMFILES}/gcov" - "$ENV{${PROGRAMFILES_x86_ENV}}/gcov" -) - -find_package_handle_standard_args(gcov - FOUND_VAR - gcov_FOUND - REQUIRED_VARS - gcov_EXECUTABLE -) - -mark_as_advanced(gcov_EXECUTABLE) diff --git a/cmake/Findlcov.cmake b/cmake/Findlcov.cmake deleted file mode 100644 index 8b7a398c..00000000 --- a/cmake/Findlcov.cmake +++ /dev/null @@ -1,42 +0,0 @@ - -# Findlcov results: -# lcov_FOUND -# lcov_EXECUTABLE - -include(FindPackageHandleStandardArgs) - -# work around CMP0053, see http://public.kitware.com/pipermail/cmake/2014-November/059117.html -set(PROGRAMFILES_x86_ENV "PROGRAMFILES(x86)") - -find_program(lcov_EXECUTABLE - NAMES - lcov - PATHS - "${LCOV_DIR}" - "$ENV{LCOV_DIR}" - "$ENV{PROGRAMFILES}/lcov" - "$ENV{${PROGRAMFILES_x86_ENV}}/lcov" -) - -find_program(genhtml_EXECUTABLE - NAMES - genhtml - PATHS - "${LCOV_DIR}" - "$ENV{LCOV_DIR}" - "$ENV{PROGRAMFILES}/lcov" - "$ENV{${PROGRAMFILES_x86_ENV}}/lcov" -) - -find_package_handle_standard_args(lcov - FOUND_VAR - lcov_FOUND - REQUIRED_VARS - lcov_EXECUTABLE - genhtml_EXECUTABLE -) - -mark_as_advanced( - lcov_EXECUTABLE - genhtml_EXECUTABLE -) diff --git a/cmake/Findnodejs.cmake b/cmake/Findnodejs.cmake deleted file mode 100644 index 024e104f..00000000 --- a/cmake/Findnodejs.cmake +++ /dev/null @@ -1,58 +0,0 @@ - -# NODEJS_FOUND -# NODEJS_INCLUDE_DIRS -# NODEJS_INCLUDE_DIR -# NODEJS_LIBUV_INCLUDE_DIR - -include(FindPackageHandleStandardArgs) - -find_path(NODEJS_INCLUDE_DIR node.h - $ENV{NODEJS_HOME} - $ENV{NODEJSDIR} - $ENV{NODEJS_HOME}/src - $ENV{NODEJSDIR}/src - /usr/include/nodejs/src - /usr/local/include/nodejs/src - /usr/include - /usr/local/include - /sw/include - /usr/local/include/node - /opt/local/include - DOC "The directory where node.h resides.") - -find_path(NODEJS_LIBUV_INCLUDE_DIR uv.h - $ENV{NODEJS_HOME} - $ENV{NODEJSDIR} - $ENV{NODEJS_HOME}/src - $ENV{NODEJSDIR}/src - $ENV{NODEJS_HOME}/deps/uv/include - $ENV{NODEJSDIR}/deps/uv/include - /usr/include/nodejs/deps/uv/include - /usr/local/include/nodejs/deps/uv/include - /usr/include - /usr/local/include - /sw/include - /opt/local/include - /usr/local/include/node - DOC "The directory where uv.h resides.") - -find_path(NODEJS_LIBV8_INCLUDE_DIR v8.h - $ENV{NODEJS_HOME} - $ENV{NODEJSDIR} - $ENV{NODEJS_HOME}/src - $ENV{NODEJSDIR}/src - $ENV{NODEJS_HOME}/deps/v8/include - $ENV{NODEJSDIR}/deps/v8/include - /usr/include/nodejs/deps/uv/include - /usr/local/include/nodejs/deps/uv/include - /usr/include - /usr/local/include - /sw/include - /opt/local/include - /usr/local/include/node - DOC "The directory where v8.h resides.") - -set(NODEJS_INCLUDE_DIRS ${NODEJS_INCLUDE_DIR} ${NODEJS_LIBUV_INCLUDE_DIR} ${NODEJS_LIBV8_INCLUDE_DIR}) - -find_package_handle_standard_args(NODEJS REQUIRED_VARS NODEJS_INCLUDE_DIRS) -mark_as_advanced(NODEJS_INCLUDE_DIRS) diff --git a/cmake/Gcov.cmake b/cmake/Gcov.cmake deleted file mode 100644 index bcf24ce9..00000000 --- a/cmake/Gcov.cmake +++ /dev/null @@ -1,104 +0,0 @@ - -#mkdir build/coverage -#lcov -d build/source/tests/fiblib-test/CMakeFiles/fiblib-test.dir -c -o build/coverage/fiblib-test.info -#genhtml -o build/coverage/html build/coverage/fiblib-test.info - -set(LCOV_EXCLUDE_COVERAGE) - -# Function to register a target for coverage -function(generate_lcov_report coverage_target target) - if(NOT TARGET coverage-init) - add_custom_target( - coverage-zero - COMMAND - ${lcov_EXECUTABLE} - --zerocounters - --base-directory ${CMAKE_BINARY_DIR} - --directory ${CMAKE_SOURCE_DIR} - -q - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - - add_custom_target( - coverage-init - COMMAND - ${lcov_EXECUTABLE} - --no-external - --capture - --initial - --base-directory ${CMAKE_BINARY_DIR} - --directory ${CMAKE_SOURCE_DIR} - --output-file ${CMAKE_BINARY_DIR}/coverage-base.info - -q - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - BYPRODUCTS ${CMAKE_BINARY_DIR}/coverage-base.info - ) - - add_custom_target( - coverage-info - COMMAND - ${lcov_EXECUTABLE} - --capture - --no-external - --base-directory ${CMAKE_BINARY_DIR} - --directory ${CMAKE_SOURCE_DIR} - --output-file ${CMAKE_BINARY_DIR}/coverage-captured.info - -q - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - BYPRODUCTS ${CMAKE_BINARY_DIR}/coverage-captured.info - ) - - add_custom_target( - coverage-merge - COMMAND - ${lcov_EXECUTABLE} - --add-tracefile ${CMAKE_BINARY_DIR}/coverage-base.info - --add-tracefile ${CMAKE_BINARY_DIR}/coverage-captured.info - --output-file ${CMAKE_BINARY_DIR}/coverage-merged.info - -q - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - BYPRODUCTS ${CMAKE_BINARY_DIR}/coverage-merged.info - ) - - add_custom_target( - coverage-filter - COMMAND - ${lcov_EXECUTABLE} - --base-directory ${CMAKE_BINARY_DIR} - --directory ${CMAKE_SOURCE_DIR} - --remove ${CMAKE_BINARY_DIR}/coverage-merged.info - ${LCOV_EXCLUDE_COVERAGE} - --output-file ${CMAKE_BINARY_DIR}/coverage-filtered.info - -q - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - BYPRODUCTS ${CMAKE_BINARY_DIR}/coverage-filtered.info - ) - - add_custom_target( - coverage-report - COMMAND - ${genhtml_EXECUTABLE} - --output-directory ${CMAKE_BINARY_DIR}/coverage - --title "${META_PROJECT_NAME} Test Coverage" - --num-spaces 4 - ${CMAKE_BINARY_DIR}/coverage-filtered.info - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - DEPENDS ${CMAKE_BINARY_DIR}/coverage-filtered.info - ) - - add_dependencies(coverage-init coverage-zero) - #add_dependencies(coverage-info coverage-init) - add_dependencies(coverage-merge coverage-info) - add_dependencies(coverage-filter coverage-merge) - add_dependencies(coverage-report coverage-filter) - add_dependencies(coverage coverage-report) - endif() - - add_custom_target(${coverage_target} - COMMAND $ - ) - - add_dependencies(coverage-info ${coverage_target}) - add_dependencies(${coverage_target} coverage-init) - -endfunction() diff --git a/cmake/GenerateTemplateExportHeader.cmake b/cmake/GenerateTemplateExportHeader.cmake deleted file mode 100644 index 5c36a9de..00000000 --- a/cmake/GenerateTemplateExportHeader.cmake +++ /dev/null @@ -1,12 +0,0 @@ - -# Creates an export header similar to generate_export_header, but for templates. -# The main difference is that for MSVC, templates must not get exported. -# When the file ${export_file} is included in source code, the macro ${target_id}_TEMPLATE_API -# may get used to define public visibility for templates on GCC and Clang platforms. -function(generate_template_export_header target target_id export_file) - if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") - configure_file(${PROJECT_SOURCE_DIR}/source/codegeneration/template_msvc_api.h.in ${CMAKE_CURRENT_BINARY_DIR}/${export_file} @ONLY) - else() - configure_file(${PROJECT_SOURCE_DIR}/source/codegeneration/template_api.h.in ${CMAKE_CURRENT_BINARY_DIR}/${export_file} @ONLY) - endif() -endfunction() diff --git a/cmake/GetGitRevisionDescription.cmake b/cmake/GetGitRevisionDescription.cmake deleted file mode 100644 index 85eae156..00000000 --- a/cmake/GetGitRevisionDescription.cmake +++ /dev/null @@ -1,130 +0,0 @@ -# - Returns a version string from Git -# -# These functions force a re-configure on each git commit so that you can -# trust the values of the variables in your build system. -# -# get_git_head_revision( [ ...]) -# -# Returns the refspec and sha hash of the current head revision -# -# git_describe( [ ...]) -# -# Returns the results of git describe on the source tree, and adjusting -# the output so that it tests false if an error occurs. -# -# git_get_exact_tag( [ ...]) -# -# Returns the results of git describe --exact-match on the source tree, -# and adjusting the output so that it tests false if there was no exact -# matching tag. -# -# Requires CMake 2.6 or newer (uses the 'function' command) -# -# Original Author: -# 2009-2010 Ryan Pavlik -# http://academic.cleardefinition.com -# Iowa State University HCI Graduate Program/VRAC -# -# Copyright Iowa State University 2009-2010. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -if(__get_git_revision_description) - return() -endif() -set(__get_git_revision_description YES) - -# We must run the following at "include" time, not at function call time, -# to find the path to this module rather than the path to a calling list file -get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) - -function(get_git_head_revision _refspecvar _hashvar) - set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") - set(GIT_DIR "${GIT_PARENT_DIR}/.git") - while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories - set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") - get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) - if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) - # We have reached the root directory, we are not in git - set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) - set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) - return() - endif() - set(GIT_DIR "${GIT_PARENT_DIR}/.git") - endwhile() - # check if this is a submodule - if(NOT IS_DIRECTORY ${GIT_DIR}) - file(READ ${GIT_DIR} submodule) - string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) - get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) - get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) - endif() - set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") - if(NOT EXISTS "${GIT_DATA}") - file(MAKE_DIRECTORY "${GIT_DATA}") - endif() - - if(NOT EXISTS "${GIT_DIR}/HEAD") - return() - endif() - set(HEAD_FILE "${GIT_DATA}/HEAD") - configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) - - configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" - "${GIT_DATA}/grabRef.cmake" - @ONLY) - include("${GIT_DATA}/grabRef.cmake") - - set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) - set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) -endfunction() - -function(git_describe _var) - if(NOT GIT_FOUND) - find_package(Git QUIET) - endif() - get_git_head_revision(refspec hash) - if(NOT GIT_FOUND) - set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) - return() - endif() - if(NOT hash) - set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) - return() - endif() - - # TODO sanitize - #if((${ARGN}" MATCHES "&&") OR - # (ARGN MATCHES "||") OR - # (ARGN MATCHES "\\;")) - # message("Please report the following error to the project!") - # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") - #endif() - - #message(STATUS "Arguments to execute_process: ${ARGN}") - - execute_process(COMMAND - "${GIT_EXECUTABLE}" - describe - ${hash} - ${ARGN} - WORKING_DIRECTORY - "${CMAKE_CURRENT_SOURCE_DIR}" - RESULT_VARIABLE - res - OUTPUT_VARIABLE - out - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT res EQUAL 0) - set(out "${out}-${res}-NOTFOUND") - endif() - - set(${_var} "${out}" PARENT_SCOPE) -endfunction() - -function(git_get_exact_tag _var) - git_describe(out --exact-match ${ARGN}) - set(${_var} "${out}" PARENT_SCOPE) -endfunction() diff --git a/cmake/GetGitRevisionDescription.cmake.in b/cmake/GetGitRevisionDescription.cmake.in deleted file mode 100644 index e15aa600..00000000 --- a/cmake/GetGitRevisionDescription.cmake.in +++ /dev/null @@ -1,46 +0,0 @@ -# -# Internal file for GetGitRevisionDescription.cmake -# -# Requires CMake 2.6 or newer (uses the 'function' command) -# -# Original Author: -# 2009-2010 Ryan Pavlik -# http://academic.cleardefinition.com -# Iowa State University HCI Graduate Program/VRAC -# -# Copyright Iowa State University 2009-2010. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -set(HEAD_HASH) -set(HEAD_REF) - -if (NOT EXISTS "@HEAD_FILE@") - return() -endif() - -file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) - -string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) -if(HEAD_CONTENTS MATCHES "ref") - # named branch - string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") - if(EXISTS "@GIT_DIR@/${HEAD_REF}") - configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) - elseif(EXISTS "@GIT_DIR@/packed-refs") - configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) - file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) - if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") - set(HEAD_HASH "${CMAKE_MATCH_1}") - endif() - endif() -else() - # detached HEAD - configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) -endif() - -if(NOT HEAD_HASH AND EXISTS "@GIT_DATA@/head-ref") - file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) - string(STRIP "${HEAD_HASH}" HEAD_HASH) -endif() diff --git a/cmake/HealthCheck.cmake b/cmake/HealthCheck.cmake deleted file mode 100644 index 8df8b9a3..00000000 --- a/cmake/HealthCheck.cmake +++ /dev/null @@ -1,104 +0,0 @@ - -include(${CMAKE_CURRENT_LIST_DIR}/Cppcheck.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/ClangTidy.cmake) - -set(OPTION_CPPCHECK_ENABLED Off) -set(OPTION_CLANG_TIDY_ENABLED Off) - -# Function to register a target for enabled health checks -function(perform_health_checks target) - if(NOT TARGET check-all) - add_custom_target(check-all) - - set_target_properties(check-all - PROPERTIES - FOLDER "Maintenance" - EXCLUDE_FROM_DEFAULT_BUILD 1 - ) - endif() - - add_custom_target(check-${target}) - - set_target_properties(check-${target} - PROPERTIES - FOLDER "Maintenance" - EXCLUDE_FROM_DEFAULT_BUILD 1 - ) - - if (OPTION_CPPCHECK_ENABLED) - perform_cppcheck(cppcheck-${target} ${target} ${ARGN}) - add_dependencies(check-${target} cppcheck-${target}) - endif() - - if (OPTION_CLANG_TIDY_ENABLED) - perform_clang_tidy(clang-tidy-${target} ${target} ${ARGN}) - add_dependencies(check-${target} clang-tidy-${target}) - endif() - - add_dependencies(check-all check-${target}) -endfunction() - -# Enable or disable cppcheck for health checks -function(enable_cppcheck status) - if(NOT ${status}) - set(OPTION_CPPCHECK_ENABLED ${status} PARENT_SCOPE) - message(STATUS "Check cppcheck skipped: Manually disabled") - - return() - endif() - - find_package(cppcheck) - - if(NOT cppcheck_FOUND) - set(OPTION_CPPCHECK_ENABLED Off PARENT_SCOPE) - message(STATUS "Check cppcheck skipped: cppcheck not found") - - return() - endif() - - set(OPTION_CPPCHECK_ENABLED ${status} PARENT_SCOPE) - message(STATUS "Check cppcheck") -endfunction() - -# Enable or disable clang-tidy for health checks -function(enable_clang_tidy status) - if(NOT ${status}) - set(OPTION_CLANG_TIDY_ENABLED ${status} PARENT_SCOPE) - message(STATUS "Check clang-tidy skipped: Manually disabled") - - return() - endif() - - find_package(clang_tidy) - - if(NOT clang_tidy_FOUND) - set(OPTION_CLANG_TIDY_ENABLED Off PARENT_SCOPE) - message(STATUS "Check clang-tidy skipped: clang-tidy not found") - - return() - endif() - - set(OPTION_CLANG_TIDY_ENABLED ${status} PARENT_SCOPE) - message(STATUS "Check clang-tidy") - - set(CMAKE_EXPORT_COMPILE_COMMANDS On PARENT_SCOPE) -endfunction() - -# Configure cmake target to check for cmake-init template -function(add_check_template_target current_template_sha) - add_custom_target( - check-template - COMMAND ${CMAKE_COMMAND} - -DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} - -DPROJECT_BINARY_DIR=${PROJECT_BINARY_DIR} - -DAPPLIED_CMAKE_INIT_SHA=${current_template_sha} - -P ${PROJECT_SOURCE_DIR}/cmake/CheckTemplate.cmake - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - ) - - set_target_properties(check-template - PROPERTIES - FOLDER "Maintenance" - EXCLUDE_FROM_DEFAULT_BUILD 1 - ) -endfunction() diff --git a/cmake/README.md b/cmake/README.md deleted file mode 100644 index e69de29b..00000000 diff --git a/cmake/RuntimeDependencies.cmake b/cmake/RuntimeDependencies.cmake deleted file mode 100644 index 7568b274..00000000 --- a/cmake/RuntimeDependencies.cmake +++ /dev/null @@ -1,19 +0,0 @@ - -# -# Default dependencies for the runtime-package -# - -# Install 3rd-party runtime dependencies into runtime-component -# install(FILES ... COMPONENT runtime) - - -# -# Full dependencies for self-contained packages -# - -if(OPTION_SELF_CONTAINED) - - # Install 3rd-party runtime dependencies into runtime-component - # install(FILES ... COMPONENT runtime) - -endif() diff --git a/cmd/animations/LICENSE b/cmd/animations/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/cmd/animations/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cmd/animations/cmd/root.go b/cmd/animations/cmd/root.go new file mode 100644 index 00000000..16854e70 --- /dev/null +++ b/cmd/animations/cmd/root.go @@ -0,0 +1,323 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package cmd + +import ( + "fmt" + "image" + "image/color" + "image/draw" + "log" + "os" + "path/filepath" + "time" + + "github.com/hajimehoshi/ebiten/v2" + "github.com/hajimehoshi/ebiten/v2/text" + "github.com/siredmar/mdcii-engine/pkg/bsh" + "github.com/siredmar/mdcii-engine/pkg/cod" + buildingsCod "github.com/siredmar/mdcii-engine/pkg/cod/buildings" + "github.com/siredmar/mdcii-engine/pkg/files" + animations "github.com/siredmar/mdcii-engine/pkg/texture/animations" + "github.com/siredmar/mdcii-engine/pkg/texture/atlas" + "github.com/siredmar/mdcii-engine/pkg/world/rotation" + "github.com/spf13/cobra" + "golang.org/x/image/font/basicfont" +) + +var ( + gamePath string + buildingIndex int + rotationArg int + // buildingParam int +) + +var ( + ScreenWidth int = 1024 + ScreenHeight int = 1024 +) + +func init() { + rootCmd.Flags().StringVarP(&gamePath, "path", "p", ".", "Path to game") + rootCmd.Flags().IntVarP(&buildingIndex, "buildingIndex", "i", 381, "building index") + rootCmd.Flags().IntVarP(&rotationArg, "rotation", "r", 0, "rotation") + // rootCmd.Flags().IntVarP(&buildingParam, "building", "b", 380, "building ID") +} + +var rootCmd = &cobra.Command{ + Use: "animations for buildings", + Short: "animations for buildings", + Run: func(cmd *cobra.Command, args []string) { + absPath, err := filepath.Abs(gamePath) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + dirPath := filepath.Dir(absPath) + + files.CreateInstance(dirPath) + buildingsCodPath, err := files.Instance().FindPathForFile("haeuser.cod") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + haeuserCod, err := cod.NewCod(buildingsCodPath, true) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = haeuserCod.Parse() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + buildings, err := buildingsCod.NewBuildings(haeuserCod) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + gfxStadtfldBshPath, err := files.Instance().FindPathForFile("gfx/stadtfld.bsh") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + gfxStadtfldBsh, err := bsh.NewPng(bsh.WithFile(gfxStadtfldBshPath), bsh.WithConvertAll()) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + atlasWidth := 4096 + atlasHeight := 4096 + + atlas, err := atlas.New(atlasWidth, atlasHeight, buildings, atlas.WithName("texture-atlas"), atlas.WithImages(gfxStadtfldBsh)) + if err != nil { + fmt.Println("Error:", err) + return + } + ani, err := animations.New(atlas) + if err != nil { + fmt.Println("Error:", err) + return + } + + ebiten.SetWindowSize(ScreenWidth, ScreenHeight) + ebiten.SetWindowTitle("animations") + game := &Game{ + windowWidth: ScreenWidth, + windowHeight: ScreenHeight, + animations: ani, + // animation: nil, + buildingIndex: buildingIndex, + // buildingId: id, + count: 0, + buildings: buildings, + atlas: atlas, + rotation: rotation.Rotation(rotationArg), + } + game.buildingId, err = buildings.GetBuildingIdByIndex(game.buildingIndex) + if err != nil { + fmt.Println("Error:", err) + return + } + // game.animation = game.animations.GetAnimation(buildingParam, rotation.DEG0) + if err := ebiten.RunGame(game); err != nil { + log.Fatal(err) + } + }, +} + +func Execute() { + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } + +} + +type Game struct { + windowWidth int + windowHeight int + animations *animations.Animations + buildings *buildingsCod.Buildings + ScreenWidth int + ScreenHeight int + // buffer *ebiten.Image + // op *ebiten.DrawImageOptions + // drawToBuffer bool + lastKeyPressTime time.Time + buildingId int + buildingIndex int + rotation rotation.Rotation + // animation *animations.Animation + lastTime time.Time + count int + currentFrame int + atlas *atlas.TextureAtlas + // currentAnimationTime time.Time +} + +var once bool +var oldRot = 0 + +func (g *Game) Draw(screen *ebiten.Image) { + if oldRot != int(g.rotation) { + fmt.Println("Rotation", g.rotation) + oldRot = int(g.rotation) + } + + // i := g.animation.Frames[g.animation.CurrentFrame] + // g.animation = g.animations.Animations[g.buildingId][g.rotation] + // if g.animation.Animated { + // if g.animation.Started { + // if g.animation.Once { + // if g.animation.CurrentFrame < g.animation.Steps { + // g.animation.CurrentFrame++ + // } + // } else { + // g.animation.CurrentFrame = (g.animation.CurrentFrame + 1) % g.animation.Steps + // if g.animation != nil { + // g.currentFrame = (g.count / 5) % g.animation.Steps + // } + + // ebitenImg := ebiten.NewImageFromImage( + options := &ebiten.DrawImageOptions{} + options.GeoM.Translate(100, 100) + // options.GeoM.Scale(1.5, 1.5) + // fmt.Println("Building ID", g.buildingId) + // fmt.Println("Rotation", g.rotation) + // fmt.Println("Current Frame", g.currentFrame) + + frame := g.animations.Animations[g.buildingId][g.rotation].Frames[g.currentFrame] + // if !once { + // g.atlas.ExportPNG("out.png", toRGBA(*frame)) + // once = true + // } + // ebitemImg := ebiten.NewImageFromImage(*frame) + screen.DrawImage(frame, options) + // } + // g.DrawBuildingInfo(screen) + // g.DrawUsage(screen) + // } + // } +} + +func toRGBA(src image.Image) *image.RGBA { + // Get the bounds of the source image + bounds := src.Bounds() + + // Create a new RGBA image with the same bounds + rgba := image.NewRGBA(bounds) + + // Draw the source image onto the RGBA image + draw.Draw(rgba, bounds, src, bounds.Min, draw.Src) + + return rgba +} + +func (g *Game) DrawBuildingInfo(screen *ebiten.Image) { + textColor := color.RGBA{255, 255, 255, 255} + face := basicfont.Face7x13 + + b := g.buildings.BuildingsVector[g.buildingId] + text.Draw(screen, fmt.Sprintf("Building Id: %d", b.Id), face, 10, 10, textColor) + text.Draw(screen, fmt.Sprintf("Building Size: %d,%d", b.Size.W, b.Size.H), face, 10, 20, textColor) + text.Draw(screen, fmt.Sprintf("Building Animation Amount: %d", b.AnimationAmount), face, 10, 30, textColor) + text.Draw(screen, fmt.Sprintf("Building Animation Add: %d", b.AnimationAdd), face, 10, 40, textColor) + text.Draw(screen, fmt.Sprintf("Building Gfx: %d", b.Gfx), face, 10, 50, textColor) + // text.Draw(screen, fmt.Sprintf("Building Rotation: %d", g.Building.Rotation), face, 10, 60, textColor) + // text.Draw(screen, fmt.Sprintf("Building BaseIndex: %d", g.Building.BaseIndex), face, 10, 70, textColor) + // text.Draw(screen, fmt.Sprintf("CurrentAnimationStep: %d", g.Building.CurrentAnimationStep), face, 10, 80, textColor) +} + +func (g *Game) DrawUsage(screen *ebiten.Image) { + textColor := color.RGBA{255, 255, 255, 255} + face := basicfont.Face7x13 + + text.Draw(screen, "Up: Animation Step, Left/Right: Rotate, N: next, M: previous", face, 10, ScreenHeight-20, textColor) + +} + +func (g *Game) Update() error { + g.count++ + + const debounceDuration = time.Millisecond * 100 + // if g.animation == nil { + // return nil + // } + now := time.Now() + // if time.Duration(g.lastTime.Sub(now)) >= g.animation.FrameDuration { + // g.animation.CurrentFrame = (g.animation.CurrentFrame + 1) % g.animation.Steps + // } + + if now.Sub(g.lastKeyPressTime) >= debounceDuration { + if ebiten.IsKeyPressed(ebiten.KeyLeft) { + fmt.Println(int(g.rotation)) + g.rotation.Increment() + fmt.Println(int(g.rotation)) + // g.animation = g.animations.GetAnimation(g.buildingId, g.rotation) + g.lastKeyPressTime = now + + } else if ebiten.IsKeyPressed(ebiten.KeyRight) { + fmt.Println(int(g.rotation)) + g.rotation.Decrement() + fmt.Println(int(g.rotation)) + // g.animation = g.animations.GetAnimation(g.buildingId, g.rotation) + g.lastKeyPressTime = now + } else if ebiten.IsKeyPressed(ebiten.KeyUp) { + if g.animations.Animations[g.buildingId][g.rotation].Animated { + g.currentFrame = (g.currentFrame + 1) % g.animations.Animations[g.buildingId][g.rotation].Steps + } + g.lastKeyPressTime = now + } else if ebiten.IsKeyPressed(ebiten.KeyN) { + fmt.Println(g.buildingId) + g.buildingIndex = (g.buildingIndex + 1) % len(g.buildings.BuildingsVector) + var err error + g.buildingId, err = g.buildings.GetBuildingIdByIndex(g.buildingIndex) + if err != nil { + log.Fatalln("Error:", err) + } + fmt.Println(g.buildingId) + // g.animation = g.animations.GetAnimation(g.buildingId, g.rotation) + g.lastKeyPressTime = now + } else if ebiten.IsKeyPressed(ebiten.KeyM) { + if g.buildingIndex > 0 { + g.buildingIndex-- + } else { + g.buildingIndex = len(g.buildings.BuildingsVector) - 1 + } + var err error + g.buildingId, err = g.buildings.GetBuildingIdByIndex(g.buildingIndex) + if err != nil { + log.Fatalln("Error:", err) + } + // g.animation = g.animations.GetAnimation(g.buildingId, g.rotation) + + g.lastKeyPressTime = now + } else if ebiten.IsKeyPressed(ebiten.KeyEscape) { + os.Exit(0) + } + } + g.lastTime = now + return nil +} + +func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) { + return ScreenWidth, ScreenHeight +} diff --git a/cmd/animations/main.go b/cmd/animations/main.go new file mode 100644 index 00000000..1654f345 --- /dev/null +++ b/cmd/animations/main.go @@ -0,0 +1,22 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package main + +import "github.com/siredmar/mdcii-engine/cmd/animations/cmd" + +func main() { + cmd.Execute() +} diff --git a/cmd/animations_ecs/LICENSE b/cmd/animations_ecs/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/cmd/animations_ecs/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cmd/animations_ecs/cmd/root.go b/cmd/animations_ecs/cmd/root.go new file mode 100644 index 00000000..2ca90b5d --- /dev/null +++ b/cmd/animations_ecs/cmd/root.go @@ -0,0 +1,298 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package cmd + +import ( + "fmt" + "image/color" + "log" + "os" + "path/filepath" + "time" + + "github.com/hajimehoshi/ebiten/v2" + "github.com/hajimehoshi/ebiten/v2/text" + "github.com/siredmar/mdcii-engine/pkg/bsh" + "github.com/siredmar/mdcii-engine/pkg/cod" + buildingsCod "github.com/siredmar/mdcii-engine/pkg/cod/buildings" + "github.com/siredmar/mdcii-engine/pkg/ecs/components" + "github.com/siredmar/mdcii-engine/pkg/ecs/systems" + "github.com/siredmar/mdcii-engine/pkg/ecs/world" + "github.com/siredmar/mdcii-engine/pkg/files" + animations "github.com/siredmar/mdcii-engine/pkg/texture/animations" + "github.com/siredmar/mdcii-engine/pkg/texture/atlas" + "github.com/siredmar/mdcii-engine/pkg/world/rotation" + "github.com/spf13/cobra" + "golang.org/x/image/font/basicfont" + + donburi "github.com/yohamta/donburi" +) + +var ( + gamePath string + buildingIndex int + rotationArg int + // buildingParam int +) + +var ( + ScreenWidth int = 1024 + ScreenHeight int = 1024 +) + +func init() { + rootCmd.Flags().StringVarP(&gamePath, "path", "p", ".", "Path to game") + rootCmd.Flags().IntVarP(&buildingIndex, "buildingIndex", "i", 381, "building index") + rootCmd.Flags().IntVarP(&rotationArg, "rotation", "r", 0, "rotation") + // rootCmd.Flags().IntVarP(&buildingParam, "building", "b", 380, "building ID") +} + +var rootCmd = &cobra.Command{ + Use: "animations for buildings", + Short: "animations for buildings", + Run: func(cmd *cobra.Command, args []string) { + absPath, err := filepath.Abs(gamePath) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + dirPath := filepath.Dir(absPath) + + files.CreateInstance(dirPath) + buildingsCodPath, err := files.Instance().FindPathForFile("haeuser.cod") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + haeuserCod, err := cod.NewCod(buildingsCodPath, true) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = haeuserCod.Parse() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + buildings, err := buildingsCod.NewBuildings(haeuserCod) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + gfxStadtfldBshPath, err := files.Instance().FindPathForFile("gfx/stadtfld.bsh") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + gfxStadtfldBsh, err := bsh.NewPng(bsh.WithFile(gfxStadtfldBshPath), bsh.WithConvertAll()) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + atlasWidth := 4096 + atlasHeight := 4096 + + atlas, err := atlas.New(atlasWidth, atlasHeight, buildings, atlas.WithName("texture-atlas"), atlas.WithImages(gfxStadtfldBsh)) + if err != nil { + fmt.Println("Error:", err) + return + } + ani, err := animations.New(atlas) + if err != nil { + fmt.Println("Error:", err) + return + } + + ebiten.SetWindowSize(ScreenWidth, ScreenHeight) + ebiten.SetWindowTitle("animations") + + w := world.New() + // Create an entity and get its Entry + entity := w.World.Create(components.AnimationType, components.TileType, components.PositionType, components.BuildingType) + entry := w.World.Entry(entity) + + buildingId, err := buildings.GetBuildingIdByIndex(buildingIndex) + if err != nil { + log.Fatalln("Error:", err) + } + + game := &Game{ + world: w, + animations: ani, + // animation: nil, + buildingIndex: buildingIndex, + // buildingId: id, + // count: 0, + buildings: buildings, + rotation: rotation.Rotation(rotationArg), + // entry: entry, + } + + components.BuildingType.Set(entry, &components.Building{ + BuildingID: buildingId, + Rotation: game.rotation, + }) + + // Set initial values for the Animation component + components.AnimationType.Set(entry, &components.Animation{ + Running: true, + Duration: 1, + Loop: true, + }) + + components.TileType.Set(entry, &components.Tile{ + Image: nil, + }) + + components.PositionType.Set(entry, &components.Position{ + X: 100, + Y: 100, + }) + + game.entry = entry + + game.buildingId, err = buildings.GetBuildingIdByIndex(game.buildingIndex) + if err != nil { + fmt.Println("Error:", err) + return + } + // game.animation = game.animations.GetAnimation(buildingParam, rotation.DEG0) + if err := ebiten.RunGame(game); err != nil { + log.Fatal(err) + } + }, +} + +func Execute() { + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } + +} + +type Game struct { + world *world.World + animations *animations.Animations + ScreenWidth int + ScreenHeight int + lastKeyPressTime time.Time + buildingId int + buildingIndex int + rotation rotation.Rotation + lastTime time.Time + entry *donburi.Entry + buildings *buildingsCod.Buildings +} + +func (g *Game) Draw(screen *ebiten.Image) { + systems.RenderSystem(g.world.World, screen) +} + +// func (g *Game) DrawBuildingInfo(screen *ebiten.Image) { +// textColor := color.RGBA{255, 255, 255, 255} +// face := basicfont.Face7x13 + +// b := g.buildings.BuildingsVector[g.buildingId] +// text.Draw(screen, fmt.Sprintf("Building Id: %d", b.Id), face, 10, 10, textColor) +// text.Draw(screen, fmt.Sprintf("Building Size: %d,%d", b.Size.W, b.Size.H), face, 10, 20, textColor) +// text.Draw(screen, fmt.Sprintf("Building Animation Amount: %d", b.AnimationAmount), face, 10, 30, textColor) +// text.Draw(screen, fmt.Sprintf("Building Animation Add: %d", b.AnimationAdd), face, 10, 40, textColor) +// text.Draw(screen, fmt.Sprintf("Building Gfx: %d", b.Gfx), face, 10, 50, textColor) +// // text.Draw(screen, fmt.Sprintf("Building Rotation: %d", g.Building.Rotation), face, 10, 60, textColor) +// // text.Draw(screen, fmt.Sprintf("Building BaseIndex: %d", g.Building.BaseIndex), face, 10, 70, textColor) +// // text.Draw(screen, fmt.Sprintf("CurrentAnimationStep: %d", g.Building.CurrentAnimationStep), face, 10, 80, textColor) +// } + +func (g *Game) DrawUsage(screen *ebiten.Image) { + textColor := color.RGBA{255, 255, 255, 255} + face := basicfont.Face7x13 + + text.Draw(screen, "Up: Animation Step, Left/Right: Rotate, N: next, M: previous", face, 10, ScreenHeight-20, textColor) + +} + +func (g *Game) Update() error { + systems.AnimationSystem(g.world.World, g.animations, 1.0/60.0) + + const debounceDuration = time.Millisecond * 250 + now := time.Now() + + if now.Sub(g.lastKeyPressTime) >= debounceDuration { + if ebiten.IsKeyPressed(ebiten.KeyLeft) { + fmt.Println(int(g.rotation)) + g.rotation.Increment() + components.BuildingType.Set(g.entry, &components.Building{ + BuildingID: g.buildingId, + Rotation: g.rotation, + }) + fmt.Println(int(g.rotation)) + g.lastKeyPressTime = now + + } else if ebiten.IsKeyPressed(ebiten.KeyRight) { + fmt.Println(int(g.rotation)) + g.rotation.Decrement() + fmt.Println(int(g.rotation)) + components.BuildingType.Set(g.entry, &components.Building{ + BuildingID: g.buildingId, + Rotation: g.rotation, + }) + g.lastKeyPressTime = now + } else if ebiten.IsKeyPressed(ebiten.KeyN) { + fmt.Println(g.buildingId) + g.buildingIndex = (g.buildingIndex + 1) % len(g.buildings.BuildingsVector) + var err error + g.buildingId, err = g.buildings.GetBuildingIdByIndex(g.buildingIndex) + if err != nil { + log.Fatalln("Error:", err) + } + components.BuildingType.Set(g.entry, &components.Building{ + BuildingID: g.buildingId, + Rotation: g.rotation, + }) + fmt.Println(g.buildingId) + g.lastKeyPressTime = now + } else if ebiten.IsKeyPressed(ebiten.KeyM) { + if g.buildingIndex > 0 { + g.buildingIndex-- + } else { + g.buildingIndex = len(g.buildings.BuildingsVector) - 1 + } + var err error + g.buildingId, err = g.buildings.GetBuildingIdByIndex(g.buildingIndex) + if err != nil { + log.Fatalln("Error:", err) + } + components.BuildingType.Set(g.entry, &components.Building{ + BuildingID: g.buildingId, + Rotation: g.rotation, + }) + g.lastKeyPressTime = now + } else if ebiten.IsKeyPressed(ebiten.KeyEscape) { + os.Exit(0) + } + } + g.lastTime = now + return nil +} + +func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) { + return ScreenWidth, ScreenHeight +} diff --git a/cmd/animations_ecs/main.go b/cmd/animations_ecs/main.go new file mode 100644 index 00000000..fe58b3ae --- /dev/null +++ b/cmd/animations_ecs/main.go @@ -0,0 +1,22 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package main + +import "github.com/siredmar/mdcii-engine/cmd/animations_ecs/cmd" + +func main() { + cmd.Execute() +} diff --git a/cmd/assets_generator/LICENSE b/cmd/assets_generator/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/cmd/assets_generator/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cmd/assets_generator/cmd/root.go b/cmd/assets_generator/cmd/root.go new file mode 100644 index 00000000..b3e9fbef --- /dev/null +++ b/cmd/assets_generator/cmd/root.go @@ -0,0 +1,169 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package cmd + +import ( + "fmt" + "os" + + "github.com/spf13/cobra" + + "github.com/siredmar/mdcii-engine/pkg/bsh" + "github.com/siredmar/mdcii-engine/pkg/cod" + files "github.com/siredmar/mdcii-engine/pkg/files" + "github.com/siredmar/mdcii-engine/pkg/texture/atlas" + "github.com/spf13/viper" +) + +var cfgFile string + +var ( + outputDir string + inputDir string + buildingsPath string +) + +// rootCmd represents the base command when called without any subcommands +var rootCmd = &cobra.Command{ + Use: "assets_generator", + Run: func(cmd *cobra.Command, args []string) { + f := files.CreateInstance(inputDir) + haeuserCodPath, err := f.FindPathForFile("haeuser.cod") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + buildingsCod, err := cod.NewCod(haeuserCodPath, true) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = buildingsCod.Parse() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + mgfxStadtfldBshPath, err := files.Instance().FindPathForFile("mgfx/stadtfld.bsh") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + sgfxStadtfldBshPath, err := files.Instance().FindPathForFile("sgfx/stadtfld.bsh") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + gfxStadtfldBshPath, err := files.Instance().FindPathForFile("gfx/stadtfld.bsh") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + mgfxStadtfldBsh, err := bsh.NewPng(bsh.WithFile(mgfxStadtfldBshPath), bsh.WithConvertAll()) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + mgfxAtlas, err := atlas.New(4096, 4096, atlas.WithOutputDir(outputDir), atlas.WithName("mgfx-stadtfld"), atlas.WithImages(mgfxStadtfldBsh.Images)) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = mgfxAtlas.Export() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + sgfxStadtfldBsh, err := bsh.NewPng(bsh.WithFile(sgfxStadtfldBshPath), bsh.WithConvertAll()) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + sgfxAtlas, err := atlas.New(4096, 4096, atlas.WithOutputDir(outputDir), atlas.WithName("sgfx-stadtfld"), atlas.WithImages(sgfxStadtfldBsh.Images)) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = sgfxAtlas.Export() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + gfxStadtfldBsh, err := bsh.NewPng(bsh.WithFile(gfxStadtfldBshPath), bsh.WithConvertAll()) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + gfxAtlas, err := atlas.New(4096, 4096, atlas.WithOutputDir(outputDir), atlas.WithName("gfx-stadtfld"), atlas.WithImages(gfxStadtfldBsh.Images)) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = gfxAtlas.Export() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + // b, err := buildings.NewBuildings(buildingsCod) + // if err != nil { + // fmt.Println(err) + // os.Exit(1) + // } + + // mgfxBsh := bsh.NewPng() + // todo: dump stadtfld mgfx, sgfx and gfx bsh files + // todo: create texture atlas for each bsh file + // atlas, err := atlas.CreateTextureAtlas() + }, +} + +// Execute adds all child commands to the root command and sets flags appropriately. +// This is called by main.main(). It only needs to happen once to the rootCmd. +func Execute() { + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } +} + +func init() { + cobra.OnInitialize(initConfig) + + // Cobra also supports local flags, which will only run + // when this action is called directly. + + // rootCmd.Flags().BoolVarP(&decrypt, "decrypt", "d", false, "decrypt true/false") + rootCmd.Flags().StringVarP(&inputDir, "dir", "d", ".", "Game directory") + rootCmd.Flags().StringVarP(&outputDir, "output", "o", ".", "Output directory") +} + +// initConfig reads in config file and ENV variables if set. +func initConfig() { + if cfgFile != "" { + // Use config file from the flag. + viper.SetConfigFile(cfgFile) + } + + viper.AutomaticEnv() // read in environment variables that match + + // If a config file is found, read it in. + if err := viper.ReadInConfig(); err == nil { + fmt.Println("Using config file:", viper.ConfigFileUsed()) + } +} diff --git a/cmd/assets_generator/main.go b/cmd/assets_generator/main.go new file mode 100644 index 00000000..6828437e --- /dev/null +++ b/cmd/assets_generator/main.go @@ -0,0 +1,22 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package main + +import "github.com/siredmar/mdcii-engine/cmd/assets_generator/cmd" + +func main() { + cmd.Execute() +} diff --git a/cmd/atlas/LICENSE b/cmd/atlas/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/cmd/atlas/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cmd/atlas/cmd/root.go b/cmd/atlas/cmd/root.go new file mode 100644 index 00000000..532d5359 --- /dev/null +++ b/cmd/atlas/cmd/root.go @@ -0,0 +1,158 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package cmd + +import ( + "fmt" + "os" + "path/filepath" + + "github.com/spf13/cobra" + + "github.com/spf13/viper" + + "github.com/siredmar/mdcii-engine/pkg/bsh" + "github.com/siredmar/mdcii-engine/pkg/cod" + "github.com/siredmar/mdcii-engine/pkg/files" + atlas "github.com/siredmar/mdcii-engine/pkg/texture/atlas" + + buildingsCod "github.com/siredmar/mdcii-engine/pkg/cod/buildings" +) + +var cfgFile string + +var ( + outputDir string + gamePath string + inputBSH string + buildingsPath string +) + +// rootCmd represents the base command when called without any subcommands +var rootCmd = &cobra.Command{ + Use: "atlas", + Run: func(cmd *cobra.Command, args []string) { + absPath, err := filepath.Abs(gamePath) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + dirPath := filepath.Dir(absPath) + + files.CreateInstance(dirPath) + buildingsCodPath, err := files.Instance().FindPathForFile("haeuser.cod") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + haeuserCod, err := cod.NewCod(buildingsCodPath, true) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = haeuserCod.Parse() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + buildings, err := buildingsCod.NewBuildings(haeuserCod) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + gfxStadtfldBshPath, err := files.Instance().FindPathForFile("gfx/stadtfld.bsh") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + gfxStadtfldBsh, err := bsh.NewPng(bsh.WithFile(gfxStadtfldBshPath), bsh.WithConvertAll()) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + // filenames := []string{"1.png", "2.png", "3.png"} // Add your filenames here + // files, err := os.ReadDir(inputDir) + // if err != nil { + // fmt.Println(err) + // os.Exit(1) + // } + atlasWidth := 4096 + atlasHeight := 4096 + // filenames := []string{} + // for _, file := range files { + // if !file.IsDir() { + // if strings.HasSuffix(file.Name(), ".png") { + // filenames = append(filenames, fmt.Sprintf("%s/%s", inputDir, file.Name())) + // } + // } + // } + // fmt.Println(filenames) + + atlas, err := atlas.New(atlasWidth, atlasHeight, buildings, atlas.WithName("texture-atlas"), atlas.WithImages(gfxStadtfldBsh)) + if err != nil { + fmt.Println("Error:", err) + return + } + + if err := atlas.Export(); err != nil { + fmt.Println("Error exporting texture atlas:", err) + return + } + + }, +} + +// Execute adds all child commands to the root command and sets flags appropriately. +// This is called by main.main(). It only needs to happen once to the rootCmd. +func Execute() { + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } + +} + +func init() { + cobra.OnInitialize(initConfig) + + // Cobra also supports local flags, which will only run + // when this action is called directly. + + // rootCmd.Flags().BoolVarP(&decrypt, "decrypt", "d", false, "decrypt true/false") + // rootCmd.Flags().StringVarP(&inputDir, "dir", "d", ".", "Input directory") + rootCmd.Flags().StringVarP(&gamePath, "game", "g", ".", "game path") + rootCmd.Flags().StringVarP(&outputDir, "output", "o", ".", "Output directory") + rootCmd.Flags().StringVarP(&buildingsPath, "buildings", "b", "", "Path to buildings file") + // rootCmd.Flags().StringVarP(&inputBSH, "bsh", "b", ".", "input BSH") +} + +// initConfig reads in config file and ENV variables if set. +func initConfig() { + if cfgFile != "" { + // Use config file from the flag. + viper.SetConfigFile(cfgFile) + } + + viper.AutomaticEnv() // read in environment variables that match + + // If a config file is found, read it in. + if err := viper.ReadInConfig(); err == nil { + fmt.Println("Using config file:", viper.ConfigFileUsed()) + } +} diff --git a/cmd/atlas/main.go b/cmd/atlas/main.go new file mode 100644 index 00000000..736dba9e --- /dev/null +++ b/cmd/atlas/main.go @@ -0,0 +1,22 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package main + +import "github.com/siredmar/mdcii-engine/cmd/atlas/cmd" + +func main() { + cmd.Execute() +} diff --git a/cmd/basegad/LICENSE b/cmd/basegad/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/cmd/basegad/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cmd/basegad/cmd/root.go b/cmd/basegad/cmd/root.go new file mode 100644 index 00000000..b961971f --- /dev/null +++ b/cmd/basegad/cmd/root.go @@ -0,0 +1,123 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package cmd + +import ( + "encoding/json" + "fmt" + "os" + "path/filepath" + + "github.com/siredmar/mdcii-engine/pkg/cod" + "github.com/siredmar/mdcii-engine/pkg/cod/basegad" + "github.com/siredmar/mdcii-engine/pkg/files" + "github.com/spf13/cobra" + + homedir "github.com/mitchellh/go-homedir" + "github.com/spf13/viper" +) + +var cfgFile string + +var ( + codFile string +) + +// rootCmd represents the base command when called without any subcommands +var rootCmd = &cobra.Command{ + Use: "basegad", + Run: func(cmd *cobra.Command, args []string) { + absPath, err := filepath.Abs(codFile) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + dirPath := filepath.Dir(absPath) + + files.CreateInstance(dirPath) + cod, err := cod.NewCod(codFile, false) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = cod.Parse() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + b, err := basegad.NewBasegad(cod) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + fmt.Println(b.GetGadgetsSize()) + jsonBytes, err := json.MarshalIndent(b.GetGadgets(), "", " ") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + fmt.Println(string(jsonBytes)) + + }, +} + +// Execute adds all child commands to the root command and sets flags appropriately. +// This is called by main.main(). It only needs to happen once to the rootCmd. +func Execute() { + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } + +} + +func init() { + cobra.OnInitialize(initConfig) + + // Cobra also supports local flags, which will only run + // when this action is called directly. + + // rootCmd.Flags().BoolVarP(&decrypt, "decrypt", "d", false, "decrypt true/false") + rootCmd.Flags().StringVarP(&codFile, "cod", "c", "BASE.GAD", "Path to BASE.GAD file") +} + +// initConfig reads in config file and ENV variables if set. +func initConfig() { + if cfgFile != "" { + // Use config file from the flag. + viper.SetConfigFile(cfgFile) + } else { + // Find home directory. + home, err := homedir.Dir() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + // Search config in home directory with name ".cod_parser" (without extension). + viper.AddConfigPath(home) + viper.SetConfigName(".cod_parser") + } + + viper.AutomaticEnv() // read in environment variables that match + + // If a config file is found, read it in. + if err := viper.ReadInConfig(); err == nil { + fmt.Println("Using config file:", viper.ConfigFileUsed()) + } +} diff --git a/cmd/basegad/main.go b/cmd/basegad/main.go new file mode 100644 index 00000000..3b562125 --- /dev/null +++ b/cmd/basegad/main.go @@ -0,0 +1,22 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package main + +import "github.com/siredmar/mdcii-engine/cmd/basegad/cmd" + +func main() { + cmd.Execute() +} diff --git a/cmd/bshdump/LICENSE b/cmd/bshdump/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/cmd/bshdump/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cmd/bshdump/cmd/root.go b/cmd/bshdump/cmd/root.go new file mode 100644 index 00000000..e050ecb8 --- /dev/null +++ b/cmd/bshdump/cmd/root.go @@ -0,0 +1,92 @@ +/* +Copyright © 2021 Armin Schlegel armin.schlegel@gmx.de + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package cmd + +import ( + "fmt" + "log" + "os" + "runtime" + "strconv" + "sync" + + "github.com/siredmar/mdcii-engine/pkg/bsh" + "github.com/spf13/cobra" +) + +var ( + bshFile string + palFile string + index string + outputFolder string +) + +var rootCmd = &cobra.Command{ + Use: "bshdump", + Short: "Dumps one or all bsh files to png files.", + Long: `Dumps one or all bsh files to png files.`, + Run: func(cmd *cobra.Command, args []string) { + if _, err := os.Stat(outputFolder); os.IsNotExist(err) { + log.Fatal(err) + } + + b, err := bsh.NewPng(bsh.WithFile(bshFile)) + if err != nil { + log.Fatal(err) + } + if index != "all" { + i, err := strconv.Atoi(index) + if err != nil { + log.Fatal(err) + } + err = b.Export(i, fmt.Sprintf("%s/%d.png", outputFolder, i)) + if err != nil { + log.Fatal(err) + } + } else { + numCpu := runtime.NumCPU() / 2 + numberOfImages := len(b.Bsh) + numberPerRoutine := numberOfImages / numCpu + var wg sync.WaitGroup + for c := 0; c < numCpu; c++ { + wg.Add(1) + go func(start int, stop int, c int, wg *sync.WaitGroup) { + for i := range b.Bsh[start:stop] { + err = b.Export(i+c*numberPerRoutine, fmt.Sprintf("%s/%d.png", outputFolder, i+c*numberPerRoutine)) + if err != nil { + log.Fatal(err) + } + } + wg.Done() + }(c*numberPerRoutine, (c+1)*numberPerRoutine, c, &wg) + } + wg.Wait() + } + }, +} + +func Execute() { + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } +} + +func init() { + rootCmd.Flags().StringVarP(&outputFolder, "output", "o", ".", "Output folder for images (default: .)") + rootCmd.Flags().StringVarP(&bshFile, "bsh", "b", "stadtfld.bsh", "BSH file input") + rootCmd.Flags().StringVarP(&index, "index", "i", "all", "index (default: all)") +} diff --git a/cmd/bshdump/main.go b/cmd/bshdump/main.go new file mode 100644 index 00000000..7d8ae322 --- /dev/null +++ b/cmd/bshdump/main.go @@ -0,0 +1,22 @@ +/* +Copyright © 2021 Armin Schlegel armin.schlegel@gmx.de + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package main + +import "github.com/siredmar/mdcii-engine/cmd/bshdump/cmd" + +func main() { + cmd.Execute() +} diff --git a/cmd/building_from_atlas/LICENSE b/cmd/building_from_atlas/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/cmd/building_from_atlas/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cmd/building_from_atlas/cmd/root.go b/cmd/building_from_atlas/cmd/root.go new file mode 100644 index 00000000..603ffd63 --- /dev/null +++ b/cmd/building_from_atlas/cmd/root.go @@ -0,0 +1,280 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package cmd + +import ( + "fmt" + "image" + "image/color" + "log" + "os" + "path/filepath" + "time" + + "github.com/hajimehoshi/ebiten/v2" + "github.com/hajimehoshi/ebiten/v2/text" + "github.com/siredmar/mdcii-engine/pkg/bsh" + "github.com/siredmar/mdcii-engine/pkg/building" + "github.com/siredmar/mdcii-engine/pkg/cod" + "github.com/siredmar/mdcii-engine/pkg/cod/buildings" + buildingsCod "github.com/siredmar/mdcii-engine/pkg/cod/buildings" + "github.com/siredmar/mdcii-engine/pkg/files" + atlas "github.com/siredmar/mdcii-engine/pkg/texture/atlas" + "github.com/siredmar/mdcii-engine/pkg/world/rotation" + "github.com/spf13/cobra" + "golang.org/x/image/font/basicfont" +) + +var ( + gamePath string + buildingIndex int + // buildingParam int +) + +var ( + ScreenWidth int = 600 + ScreenHeight int = 600 + TileSize int = 64 + GridEnable bool = false +) + +func init() { + rootCmd.Flags().StringVarP(&gamePath, "path", "p", ".", "Path to game") + rootCmd.Flags().IntVarP(&buildingIndex, "buildingIndex", "i", 381, "building index") + // rootCmd.Flags().IntVarP(&buildingParam, "building", "b", 2121, "building ID") +} + +const ( + tileWidth = 64 // Breite eines Tiles in Pixel + tileHeight = 31 // Höhe eines Tiles in Pixel +) + +var rootCmd = &cobra.Command{ + Use: "gfx viewer for buildings", + Short: "gfx viewer for buildings", + Run: func(cmd *cobra.Command, args []string) { + absPath, err := filepath.Abs(gamePath) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + dirPath := filepath.Dir(absPath) + + files.CreateInstance(dirPath) + buildingsCodPath, err := files.Instance().FindPathForFile("haeuser.cod") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + haeuserCod, err := cod.NewCod(buildingsCodPath, true) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = haeuserCod.Parse() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + buildings, err := buildingsCod.NewBuildings(haeuserCod) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + gfxStadtfldBshPath, err := files.Instance().FindPathForFile("gfx/stadtfld.bsh") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + gfxStadtfldBsh, err := bsh.NewPng(bsh.WithFile(gfxStadtfldBshPath), bsh.WithConvertAll()) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + atlas, err := atlas.New(4096, 4096, buildings, atlas.WithName("texture-atlas"), atlas.WithImages(gfxStadtfldBsh)) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + // if buildingIndex == -1 { + // for i, b := range buildings.BuildingsVector { + // if b.Id == buildingParam { + // buildingIndex = i + // break + // } + // } + // } + + ebiten.SetWindowSize(ScreenWidth, ScreenHeight) + ebiten.SetWindowTitle("building_from_atlas") + game := &Game{ + windowWidth: ScreenWidth, + windowHeight: ScreenHeight, + tileSize: TileSize, + gfxStadtfldBsh: gfxStadtfldBsh, + buildings: buildings, + op: &ebiten.DrawImageOptions{}, + buffer: ebiten.NewImage(ScreenWidth, ScreenHeight), + drawToBuffer: true, + Building: &building.Building{ + AnimationSteps: 0, + CurrentAnimationStep: 0, + }, + buildingIndex: buildingIndex, + atlas: atlas, + Sprite: nil, + rotation: rotation.DEG0, + animationIndex: 0, + } + game.setBuilding(game.buildingIndex, 0) + if err := ebiten.RunGame(game); err != nil { + log.Fatal(err) + } + }, +} + +func Execute() { + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } + +} + +func (g *Game) setBuilding(index int, animationStep int) { + fmt.Println("Building ID", index) + fmt.Println("Rotation", g.rotation) + fmt.Println("Animation Index", animationStep) + b := g.buildings.BuildingsVector[index] + sprite := g.atlas.ImagesMeta[b.Id].Animations[g.rotation].Images[animationStep].Sprite + + g.Building.Sprite = sprite + g.Building.AnimationSteps = b.AnimationAmount + g.Building.CurrentAnimationStep = animationStep + g.Building.Size = building.BuildingSize(b.Size.W, b.Size.H) +} + +type Game struct { + windowWidth int + windowHeight int + tileSize int + gfxStadtfldBsh *bsh.BshPng + buildings *buildings.Buildings + ScreenWidth int + ScreenHeight int + buffer *ebiten.Image + op *ebiten.DrawImageOptions + drawToBuffer bool + Building *building.Building + lastKeyPressTime time.Time + buildingIndex int + atlas *atlas.TextureAtlas + Sprite image.Image + rotation rotation.Rotation + animationIndex int +} + +func (g *Game) Draw(screen *ebiten.Image) { + + ebitenImg := ebiten.NewImageFromImage(g.Building.Sprite) + + options := &ebiten.DrawImageOptions{} + options.GeoM.Translate(100, 100) + // options.GeoM.Scale(1.5, 1.5) + screen.DrawImage(ebitenImg, options) + g.DrawBuildingInfo(screen) + g.DrawUsage(screen) +} + +func (g *Game) DrawBuildingInfo(screen *ebiten.Image) { + textColor := color.RGBA{255, 255, 255, 255} + face := basicfont.Face7x13 + + b := g.buildings.BuildingsVector[g.buildingIndex] + text.Draw(screen, fmt.Sprintf("Building Id: %d", b.Id), face, 10, 10, textColor) + text.Draw(screen, fmt.Sprintf("Building Size: %d,%d", b.Size.W, b.Size.H), face, 10, 20, textColor) + text.Draw(screen, fmt.Sprintf("Building Animation Amount: %d", b.AnimationAmount), face, 10, 30, textColor) + text.Draw(screen, fmt.Sprintf("Building Animation Add: %d", b.AnimationAdd), face, 10, 40, textColor) + text.Draw(screen, fmt.Sprintf("Building Gfx: %d", b.Gfx), face, 10, 50, textColor) + text.Draw(screen, fmt.Sprintf("Building Rotation: %d", g.Building.Rotation), face, 10, 60, textColor) + text.Draw(screen, fmt.Sprintf("Building BaseIndex: %d", g.Building.BaseIndex), face, 10, 70, textColor) + text.Draw(screen, fmt.Sprintf("CurrentAnimationStep: %d", g.Building.CurrentAnimationStep), face, 10, 80, textColor) +} + +func (g *Game) DrawUsage(screen *ebiten.Image) { + textColor := color.RGBA{255, 255, 255, 255} + face := basicfont.Face7x13 + + text.Draw(screen, "Up: Animation Step, Left/Right: Rotate, N: next, M: previous", face, 10, ScreenHeight-20, textColor) + +} + +func (g *Game) Update() error { + const debounceDuration = time.Millisecond * 100 + + now := time.Now() + + if now.Sub(g.lastKeyPressTime) >= debounceDuration { + if ebiten.IsKeyPressed(ebiten.KeyLeft) { + // g.Building.Rotation = (g.Building.Rotation + 3) % 4 // Linksrotation + g.rotation.Decrement() + g.setBuilding(g.buildingIndex, g.animationIndex) + g.lastKeyPressTime = now + } else if ebiten.IsKeyPressed(ebiten.KeyRight) { + // g.Building.Rotation = (g.Building.Rotation + 1) % 4 // Rechtsrotation + g.rotation.Increment() + g.setBuilding(g.buildingIndex, g.animationIndex) + g.lastKeyPressTime = now + } else if ebiten.IsKeyPressed(ebiten.KeyUp) { + fmt.Println(g.Building.AnimationSteps) + if g.Building.AnimationSteps > 0 { + g.Building.CurrentAnimationStep = (g.Building.CurrentAnimationStep + 1) % g.Building.AnimationSteps + // add := g.Building.CurrentAnimationStep * g.Building.AnimationAdd + // g.Building.BaseIndex = g.Building.BaseIndexSaved + add + // g.Building.CurrentAnimationStep++ + // g.Building.CurrentAnimationStep = g.Building.CurrentAnimationStep % g.Building.AnimationSteps + g.setBuilding(g.buildingIndex, g.Building.CurrentAnimationStep) + } + g.lastKeyPressTime = now + } else if ebiten.IsKeyPressed(ebiten.KeyN) { + fmt.Println(g.buildingIndex) + g.buildingIndex = (g.buildingIndex + 1) % len(g.buildings.BuildingsVector) + fmt.Println(g.buildingIndex) + g.setBuilding(g.buildingIndex, g.animationIndex) + g.lastKeyPressTime = now + } else if ebiten.IsKeyPressed(ebiten.KeyM) { + if g.buildingIndex > 0 { + g.buildingIndex-- + } else { + g.buildingIndex = len(g.buildings.BuildingsVector) - 1 + } + g.setBuilding(g.buildingIndex, g.animationIndex) + g.lastKeyPressTime = now + } else if ebiten.IsKeyPressed(ebiten.KeyEscape) { + os.Exit(0) + } + } + return nil +} + +func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) { + return ScreenWidth, ScreenHeight +} diff --git a/cmd/building_from_atlas/main.go b/cmd/building_from_atlas/main.go new file mode 100644 index 00000000..c6b18ee8 --- /dev/null +++ b/cmd/building_from_atlas/main.go @@ -0,0 +1,28 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package main + +import ( + "github.com/siredmar/mdcii-engine/cmd/building_from_atlas/cmd" +) + +func main() { + // mux := http.NewServeMux() + // mux.HandleFunc("/profile", pprof.Profile) + // log.Fatal(http.ListenAndServe(":7777", mux)) + + cmd.Execute() +} diff --git a/cmd/building_gfxs/LICENSE b/cmd/building_gfxs/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/cmd/building_gfxs/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cmd/building_gfxs/cmd/root.go b/cmd/building_gfxs/cmd/root.go new file mode 100644 index 00000000..a83d75cf --- /dev/null +++ b/cmd/building_gfxs/cmd/root.go @@ -0,0 +1,278 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package cmd + +import ( + "fmt" + "image/color" + "log" + "os" + "path/filepath" + "time" + + "github.com/hajimehoshi/ebiten/v2" + "github.com/hajimehoshi/ebiten/v2/text" + "github.com/siredmar/mdcii-engine/pkg/bsh" + "github.com/siredmar/mdcii-engine/pkg/building" + "github.com/siredmar/mdcii-engine/pkg/cod" + "github.com/siredmar/mdcii-engine/pkg/cod/buildings" + buildingsCod "github.com/siredmar/mdcii-engine/pkg/cod/buildings" + "github.com/siredmar/mdcii-engine/pkg/files" + "github.com/spf13/cobra" + "golang.org/x/image/font/basicfont" +) + +var ( + gamePath string + buildingIndex int + buildingParam int +) + +var ( + ScreenWidth int = 600 + ScreenHeight int = 600 + TileSize int = 64 + GridEnable bool = false +) + +func init() { + rootCmd.Flags().StringVarP(&gamePath, "path", "p", ".", "Path to game") + rootCmd.Flags().IntVarP(&buildingIndex, "buildingIndex", "i", -1, "building index") + rootCmd.Flags().IntVarP(&buildingParam, "building", "b", 2121, "building ID") +} + +const ( + tileWidth = 64 // Breite eines Tiles in Pixel + tileHeight = 31 // Höhe eines Tiles in Pixel +) + +var rootCmd = &cobra.Command{ + Use: "gfx viewer for buildings", + Short: "gfx viewer for buildings", + Run: func(cmd *cobra.Command, args []string) { + absPath, err := filepath.Abs(gamePath) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + dirPath := filepath.Dir(absPath) + + files.CreateInstance(dirPath) + buildingsCodPath, err := files.Instance().FindPathForFile("haeuser.cod") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + haeuserCod, err := cod.NewCod(buildingsCodPath, true) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = haeuserCod.Parse() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + buildings, err := buildingsCod.NewBuildings(haeuserCod) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + gfxStadtfldBshPath, err := files.Instance().FindPathForFile("gfx/stadtfld.bsh") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + gfxStadtfldBsh, err := bsh.NewPng(bsh.WithFile(gfxStadtfldBshPath), bsh.WithConvertAll()) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + if buildingIndex == -1 { + for i, b := range buildings.BuildingsVector { + if b.Id == buildingParam { + buildingIndex = i + break + } + } + } + + ebiten.SetWindowSize(ScreenWidth, ScreenHeight) + ebiten.SetWindowTitle("buildings_gfx") + game := &Game{ + windowWidth: ScreenWidth, + windowHeight: ScreenHeight, + tileSize: TileSize, + gfxStadtfldBsh: gfxStadtfldBsh, + buildings: buildings, + op: &ebiten.DrawImageOptions{}, + buffer: ebiten.NewImage(ScreenWidth, ScreenHeight), + drawToBuffer: true, + Building: nil, + buildingId: buildingIndex, + } + game.setBuilding(game.buildingId) + if err := ebiten.RunGame(game); err != nil { + log.Fatal(err) + } + }, +} + +func Execute() { + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } + +} + +func (g *Game) setBuilding(id int) { + b := g.buildings.BuildingsVector[id] + g.Building = &building.Building{ + BaseIndexSaved: b.Gfx, + BaseIndex: b.Gfx, + Rotation: 0, + X: ScreenWidth / 4, + Y: ScreenHeight / 4, + AnimationSteps: b.AnimationAmount, + CurrentAnimationStep: 0, + AnimationAdd: b.AnimationAdd, + Size: building.BuildingSize(b.Size.W, b.Size.H), + } +} + +type Game struct { + windowWidth int + windowHeight int + tileSize int + gfxStadtfldBsh *bsh.BshPng + buildings *buildings.Buildings + ScreenWidth int + ScreenHeight int + buffer *ebiten.Image + op *ebiten.DrawImageOptions + drawToBuffer bool + Building *building.Building + lastKeyPressTime time.Time + buildingId int +} + +func (g *Game) Draw(screen *ebiten.Image) { + if g.Building != nil { + offsets := building.RotationOffsets[g.Building.Size][g.Building.Rotation] + for i, offset := range offsets { + screenX := float64(g.Building.X) + float64(offset[0]-offset[1])*(float64(tileWidth)/2) + screenY := float64(g.Building.Y) + float64(offset[0]+offset[1])*(float64(tileHeight)/2) + + textureKey := func(baseIndex, rotation, tileIndex int, size building.BuildingSizeIdentifier) string { + tilesPerRotation := len(building.RotationOffsets[size][rotation]) + return fmt.Sprintf("%d", baseIndex+(rotation*tilesPerRotation)+tileIndex) + }(g.Building.BaseIndex, g.Building.Rotation, i, g.Building.Size) + + tileImg, ok := g.gfxStadtfldBsh.Images[textureKey] + if !ok { + log.Printf("Texture key %s not found in texture atlas", textureKey) + continue + } + baseOffsetY := func(tileHeight, gridTileHeight int) int { + if tileHeight > gridTileHeight { + return tileHeight - gridTileHeight + } + return 0 + }(tileImg.Bounds().Dy(), tileHeight) + + ebitenImg := ebiten.NewImageFromImage(tileImg) + + options := &ebiten.DrawImageOptions{} + options.GeoM.Translate(screenX, screenY-float64(baseOffsetY)) + options.GeoM.Scale(1.5, 1.5) + screen.DrawImage(ebitenImg, options) + g.DrawBuildingInfo(screen) + g.DrawUsage(screen) + } + } +} + +func (g *Game) DrawBuildingInfo(screen *ebiten.Image) { + textColor := color.RGBA{255, 255, 255, 255} + face := basicfont.Face7x13 + + b := g.buildings.BuildingsVector[g.buildingId] + text.Draw(screen, fmt.Sprintf("Building Id: %d", b.Id), face, 10, 10, textColor) + text.Draw(screen, fmt.Sprintf("Building Size: %d,%d", b.Size.W, b.Size.H), face, 10, 20, textColor) + text.Draw(screen, fmt.Sprintf("Building Animation Amount: %d", b.AnimationAmount), face, 10, 30, textColor) + text.Draw(screen, fmt.Sprintf("Building Animation Add: %d", b.AnimationAdd), face, 10, 40, textColor) + text.Draw(screen, fmt.Sprintf("Building Gfx: %d", b.Gfx), face, 10, 50, textColor) + text.Draw(screen, fmt.Sprintf("Building Rotation: %d", g.Building.Rotation), face, 10, 60, textColor) + text.Draw(screen, fmt.Sprintf("Building BaseIndex: %d", g.Building.BaseIndex), face, 10, 70, textColor) + text.Draw(screen, fmt.Sprintf("CurrentAnimationStep: %d", g.Building.CurrentAnimationStep), face, 10, 80, textColor) +} + +func (g *Game) DrawUsage(screen *ebiten.Image) { + textColor := color.RGBA{255, 255, 255, 255} + face := basicfont.Face7x13 + + text.Draw(screen, "Up: Animation Step, Left/Right: Rotate, N: next, M: previous", face, 10, ScreenHeight-20, textColor) + +} + +func (g *Game) Update() error { + const debounceDuration = time.Millisecond * 100 + + now := time.Now() + + if now.Sub(g.lastKeyPressTime) >= debounceDuration { + if ebiten.IsKeyPressed(ebiten.KeyLeft) { + g.Building.Rotation = (g.Building.Rotation + 3) % 4 // Linksrotation + g.lastKeyPressTime = now + } else if ebiten.IsKeyPressed(ebiten.KeyRight) { + g.Building.Rotation = (g.Building.Rotation + 1) % 4 // Rechtsrotation + g.lastKeyPressTime = now + } else if ebiten.IsKeyPressed(ebiten.KeyUp) { + if g.Building.AnimationSteps > 0 { + g.Building.CurrentAnimationStep = (g.Building.CurrentAnimationStep + 1) % g.Building.AnimationSteps + add := g.Building.CurrentAnimationStep * g.Building.AnimationAdd + g.Building.BaseIndex = g.Building.BaseIndexSaved + add + } + g.lastKeyPressTime = now + } else if ebiten.IsKeyPressed(ebiten.KeyN) { + fmt.Println(g.buildingId) + g.buildingId = (g.buildingId + 1) % len(g.buildings.BuildingsVector) + fmt.Println(g.buildingId) + g.setBuilding(g.buildingId) + g.lastKeyPressTime = now + } else if ebiten.IsKeyPressed(ebiten.KeyM) { + if g.buildingId > 0 { + g.buildingId-- + } else { + g.buildingId = len(g.buildings.BuildingsVector) - 1 + } + g.setBuilding(g.buildingId) + g.lastKeyPressTime = now + } else if ebiten.IsKeyPressed(ebiten.KeyEscape) { + os.Exit(0) + } + } + return nil +} + +func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) { + return ScreenWidth, ScreenHeight +} diff --git a/cmd/building_gfxs/main.go b/cmd/building_gfxs/main.go new file mode 100644 index 00000000..4d014f19 --- /dev/null +++ b/cmd/building_gfxs/main.go @@ -0,0 +1,22 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package main + +import "github.com/siredmar/mdcii-engine/cmd/building_gfxs/cmd" + +func main() { + cmd.Execute() +} diff --git a/cmd/building_gfxs_std/LICENSE b/cmd/building_gfxs_std/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/cmd/building_gfxs_std/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cmd/building_gfxs_std/cmd/root.go b/cmd/building_gfxs_std/cmd/root.go new file mode 100644 index 00000000..85710195 --- /dev/null +++ b/cmd/building_gfxs_std/cmd/root.go @@ -0,0 +1,206 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + + See the License for the specific language governing permissions and + +limitations under the License. +*/ +package cmd + +import ( + "fmt" + "image" + "image/draw" + "image/png" + "log" + "os" + "path/filepath" + + "github.com/siredmar/mdcii-engine/pkg/bsh" + building "github.com/siredmar/mdcii-engine/pkg/building" + "github.com/siredmar/mdcii-engine/pkg/cod" + buildingsCod "github.com/siredmar/mdcii-engine/pkg/cod/buildings" + "github.com/siredmar/mdcii-engine/pkg/files" + "github.com/spf13/cobra" +) + +var ( + gamePath string + buildingParam int + ScreenWidth int = 600 + ScreenHeight int = 600 + TileSize int = 64 +) + +func init() { + rootCmd.Flags().StringVarP(&gamePath, "path", "p", ".", "Path to game") + rootCmd.Flags().IntVarP(&buildingParam, "building", "b", 381, "building ID") +} + +const ( + tileWidth = 64 // Tile width in pixels + tileHeight = 31 // Tile height in pixels +) + +var rootCmd = &cobra.Command{ + Use: "gfx viewer for buildings", + Short: "gfx viewer for buildings", + Run: func(cmd *cobra.Command, args []string) { + absPath, err := filepath.Abs(gamePath) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + dirPath := filepath.Dir(absPath) + + files.CreateInstance(dirPath) + buildingsCodPath, err := files.Instance().FindPathForFile("haeuser.cod") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + haeuserCod, err := cod.NewCod(buildingsCodPath, true) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = haeuserCod.Parse() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + buildings, err := buildingsCod.NewBuildings(haeuserCod) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + gfxStadtfldBshPath, err := files.Instance().FindPathForFile("gfx/stadtfld.bsh") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + gfxStadtfldBsh, err := bsh.NewPng(bsh.WithFile(gfxStadtfldBshPath), bsh.WithConvertAll()) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + renderToPNG(ScreenWidth, ScreenHeight, buildings, gfxStadtfldBsh, buildingParam) + }, +} + +func renderToPNG(screenWidth, screenHeight int, buildings *buildingsCod.Buildings, gfxStadtfldBsh *bsh.BshPng, buildingID int) { + // Create a blank RGBA image for drawing + outputImage := image.NewRGBA(image.Rect(0, 0, screenWidth, screenHeight)) + + // Fetch the building data + b := buildings.BuildingsVector[buildingID] + buildingData := &building.Building{ + BaseIndex: b.Gfx, + Size: building.BuildingSize(b.Size.W, b.Size.H), + Rotation: 0, + X: screenWidth / 4, + Y: screenHeight / 4, + } + + // Draw the building + offsets := building.RotationOffsets[buildingData.Size][buildingData.Rotation] + for i, offset := range offsets { + screenX := buildingData.X + (offset[0]-offset[1])*(tileWidth/2) + screenY := buildingData.Y + (offset[0]+offset[1])*(tileHeight/2) + + textureKey := fmt.Sprintf("%d", buildingData.BaseIndex+i) + tileImg, ok := gfxStadtfldBsh.Images[textureKey] + if !ok { + log.Printf("Texture key %s not found in texture atlas", textureKey) + continue + } + + baseOffsetY := 0 + if tileImg.Bounds().Dy() > tileHeight { + baseOffsetY = tileImg.Bounds().Dy() - tileHeight + } + + draw.Draw(outputImage, image.Rect(screenX, screenY-baseOffsetY, screenX+tileWidth, screenY+tileHeight), + tileImg, image.Point{}, draw.Over) + } + + // Find the bounds of the non-alpha content + cropBounds := findNonAlphaBounds(outputImage) + + // Crop the image to the determined bounds + croppedImage := cropImage(outputImage, cropBounds) + + // Save the cropped output image as a PNG file + outputFile, err := os.Create("output.png") + if err != nil { + log.Fatal(err) + } + defer outputFile.Close() + + err = png.Encode(outputFile, croppedImage) + if err != nil { + log.Fatal(err) + } + fmt.Println("Image rendered, cropped, and saved as output.png") +} + +// findNonAlphaBounds determines the bounds of the non-transparent content in an image. +func findNonAlphaBounds(img *image.RGBA) image.Rectangle { + bounds := img.Bounds() + minX, minY := bounds.Max.X, bounds.Max.Y + maxX, maxY := bounds.Min.X, bounds.Min.Y + + for y := bounds.Min.Y; y < bounds.Max.Y; y++ { + for x := bounds.Min.X; x < bounds.Max.X; x++ { + _, _, _, a := img.At(x, y).RGBA() + if a > 0 { // Check for non-transparent pixel + if x < minX { + minX = x + } + if x > maxX { + maxX = x + } + if y < minY { + minY = y + } + if y > maxY { + maxY = y + } + } + } + } + + // Ensure valid bounds are returned + if minX > maxX || minY > maxY { + return image.Rect(0, 0, 0, 0) // No content found + } + return image.Rect(minX, minY, maxX+1, maxY+1) +} + +// cropImage crops an image to the specified rectangle. +func cropImage(img *image.RGBA, rect image.Rectangle) *image.RGBA { + cropped := image.NewRGBA(rect) + draw.Draw(cropped, rect, img, rect.Min, draw.Src) + return cropped +} + +func Execute() { + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } +} diff --git a/cmd/building_gfxs_std/main.go b/cmd/building_gfxs_std/main.go new file mode 100644 index 00000000..998d1ea2 --- /dev/null +++ b/cmd/building_gfxs_std/main.go @@ -0,0 +1,22 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package main + +import "github.com/siredmar/mdcii-engine/cmd/building_gfxs_std/cmd" + +func main() { + cmd.Execute() +} diff --git a/cmd/buildings/LICENSE b/cmd/buildings/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/cmd/buildings/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cmd/buildings/cmd/root.go b/cmd/buildings/cmd/root.go new file mode 100644 index 00000000..4d4e2fe0 --- /dev/null +++ b/cmd/buildings/cmd/root.go @@ -0,0 +1,116 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package cmd + +import ( + "encoding/json" + "fmt" + "os" + "path/filepath" + + "github.com/siredmar/mdcii-engine/pkg/cod" + "github.com/siredmar/mdcii-engine/pkg/cod/buildings" + "github.com/siredmar/mdcii-engine/pkg/files" + "github.com/spf13/cobra" + + "github.com/spf13/viper" + // cod "github.com/siredmar/mdcii-engine/pkg/cod" +) + +var cfgFile string + +var ( + decrypt bool = false + codFile string +) + +// rootCmd represents the base command when called without any subcommands +var rootCmd = &cobra.Command{ + Use: "buildings", + Short: "Parse buildings.cod file", + // Uncomment the following line if your bare application + // has an action associated with it: + Run: func(cmd *cobra.Command, args []string) { + absPath, err := filepath.Abs(codFile) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + dirPath := filepath.Dir(absPath) + + files.CreateInstance(dirPath) + haeuserCod, err := cod.NewCod(codFile, decrypt) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = haeuserCod.Parse() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + buildings, err := buildings.NewBuildings(haeuserCod) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + jsonBytes, err := json.MarshalIndent(buildings.GetBuildings(), "", " ") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + fmt.Println(string(jsonBytes)) + + }, +} + +// Execute adds all child commands to the root command and sets flags appropriately. +// This is called by main.main(). It only needs to happen once to the rootCmd. +func Execute() { + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } + +} + +func init() { + cobra.OnInitialize(initConfig) + + // Cobra also supports local flags, which will only run + // when this action is called directly. + rootCmd.Flags().BoolVarP(&decrypt, "decrypt", "d", false, "decrypt true/false") + + // rootCmd.Flags().BoolVarP(&decrypt, "decrypt", "d", false, "decrypt true/false") + rootCmd.Flags().StringVarP(&codFile, "cod", "c", "haeuser.cod", "Path to haeuser.cod file") +} + +// initConfig reads in config file and ENV variables if set. +func initConfig() { + if cfgFile != "" { + // Use config file from the flag. + viper.SetConfigFile(cfgFile) + } + + viper.AutomaticEnv() // read in environment variables that match + + // If a config file is found, read it in. + if err := viper.ReadInConfig(); err == nil { + fmt.Println("Using config file:", viper.ConfigFileUsed()) + } +} diff --git a/cmd/buildings/main.go b/cmd/buildings/main.go new file mode 100644 index 00000000..d7558df8 --- /dev/null +++ b/cmd/buildings/main.go @@ -0,0 +1,22 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package main + +import "github.com/siredmar/mdcii-engine/cmd/buildings/cmd" + +func main() { + cmd.Execute() +} diff --git a/cmd/cod_cat/LICENSE b/cmd/cod_cat/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/cmd/cod_cat/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cmd/cod_cat/cmd/root.go b/cmd/cod_cat/cmd/root.go new file mode 100644 index 00000000..0d655a52 --- /dev/null +++ b/cmd/cod_cat/cmd/root.go @@ -0,0 +1,108 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package cmd + +import ( + "fmt" + "log" + "os" + + "github.com/spf13/cobra" + + homedir "github.com/mitchellh/go-homedir" + "github.com/spf13/viper" + // cod "github.com/siredmar/mdcii-engine/pkg/cod" +) + +var cfgFile string + +var ( + decrypt bool = false + codFile string +) + +// rootCmd represents the base command when called without any subcommands +var rootCmd = &cobra.Command{ + Use: "cod_parser", + Short: "A brief description of your application", + Long: `A longer description that spans multiple lines and likely contains +examples and usage of using your application. For example: + +Cobra is a CLI library for Go that empowers applications. +This application is a tool to generate the needed files +to quickly create a Cobra application.`, + // Uncomment the following line if your bare application + // has an action associated with it: + Run: func(cmd *cobra.Command, args []string) { + b, err := os.ReadFile(codFile) + if err != nil { + log.Fatal(err) + } + if decrypt { + for i, v := range b { + b[i] = -v + } + } + fmt.Println(string(b)) + }, +} + +// Execute adds all child commands to the root command and sets flags appropriately. +// This is called by main.main(). It only needs to happen once to the rootCmd. +func Execute() { + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } + +} + +func init() { + cobra.OnInitialize(initConfig) + + // Cobra also supports local flags, which will only run + // when this action is called directly. + rootCmd.Flags().BoolVarP(&decrypt, "decrypt", "d", false, "decrypt true/false") + + // rootCmd.Flags().BoolVarP(&decrypt, "decrypt", "d", false, "decrypt true/false") + rootCmd.Flags().StringVarP(&codFile, "cod", "c", "test.cod", "Path to .cod file") +} + +// initConfig reads in config file and ENV variables if set. +func initConfig() { + if cfgFile != "" { + // Use config file from the flag. + viper.SetConfigFile(cfgFile) + } else { + // Find home directory. + home, err := homedir.Dir() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + // Search config in home directory with name ".cod_parser" (without extension). + viper.AddConfigPath(home) + viper.SetConfigName(".cod_parser") + } + + viper.AutomaticEnv() // read in environment variables that match + + // If a config file is found, read it in. + if err := viper.ReadInConfig(); err == nil { + fmt.Println("Using config file:", viper.ConfigFileUsed()) + } +} diff --git a/cmd/cod_cat/main.go b/cmd/cod_cat/main.go new file mode 100644 index 00000000..4fd0da78 --- /dev/null +++ b/cmd/cod_cat/main.go @@ -0,0 +1,22 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package main + +import "github.com/siredmar/mdcii-engine/cmd/cod_cat/cmd" + +func main() { + cmd.Execute() +} diff --git a/cmd/cod_parser/LICENSE b/cmd/cod_parser/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/cmd/cod_parser/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cmd/cod_parser/cmd/root.go b/cmd/cod_parser/cmd/root.go new file mode 100644 index 00000000..4b49b4c9 --- /dev/null +++ b/cmd/cod_parser/cmd/root.go @@ -0,0 +1,125 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package cmd + +import ( + "fmt" + "os" + "path/filepath" + + "github.com/siredmar/mdcii-engine/pkg/cod" + "github.com/siredmar/mdcii-engine/pkg/files" + "github.com/spf13/cobra" + + homedir "github.com/mitchellh/go-homedir" + "github.com/spf13/viper" + // cod "github.com/siredmar/mdcii-engine/pkg/cod" +) + +var cfgFile string + +var ( + decrypt bool = false + codFile string +) + +// rootCmd represents the base command when called without any subcommands +var rootCmd = &cobra.Command{ + Use: "cod_parser", + Short: "A brief description of your application", + Long: `A longer description that spans multiple lines and likely contains +examples and usage of using your application. For example: + +Cobra is a CLI library for Go that empowers applications. +This application is a tool to generate the needed files +to quickly create a Cobra application.`, + // Uncomment the following line if your bare application + // has an action associated with it: + Run: func(cmd *cobra.Command, args []string) { + absPath, err := filepath.Abs(codFile) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + dirPath := filepath.Dir(absPath) + + files.CreateInstance(dirPath) + codParser, err := cod.NewCod(codFile, decrypt) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = codParser.Parse() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + str, err := codParser.DumpObjectsToJSON() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + fmt.Println(str) + }, +} + +// Execute adds all child commands to the root command and sets flags appropriately. +// This is called by main.main(). It only needs to happen once to the rootCmd. +func Execute() { + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } + +} + +func init() { + cobra.OnInitialize(initConfig) + + // Cobra also supports local flags, which will only run + // when this action is called directly. + rootCmd.Flags().BoolVarP(&decrypt, "decrypt", "d", false, "decrypt true/false") + + // rootCmd.Flags().BoolVarP(&decrypt, "decrypt", "d", false, "decrypt true/false") + rootCmd.Flags().StringVarP(&codFile, "cod", "c", "test.cod", "Path to .cod file") +} + +// initConfig reads in config file and ENV variables if set. +func initConfig() { + if cfgFile != "" { + // Use config file from the flag. + viper.SetConfigFile(cfgFile) + } else { + // Find home directory. + home, err := homedir.Dir() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + // Search config in home directory with name ".cod_parser" (without extension). + viper.AddConfigPath(home) + viper.SetConfigName(".cod_parser") + } + + viper.AutomaticEnv() // read in environment variables that match + + // If a config file is found, read it in. + if err := viper.ReadInConfig(); err == nil { + fmt.Println("Using config file:", viper.ConfigFileUsed()) + } +} diff --git a/cmd/cod_parser/main.go b/cmd/cod_parser/main.go new file mode 100644 index 00000000..59c2cc93 --- /dev/null +++ b/cmd/cod_parser/main.go @@ -0,0 +1,22 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package main + +import "github.com/siredmar/mdcii-engine/cmd/cod_parser/cmd" + +func main() { + cmd.Execute() +} diff --git a/cmd/island_ecs/LICENSE b/cmd/island_ecs/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/cmd/island_ecs/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cmd/island_ecs/cmd/root.go b/cmd/island_ecs/cmd/root.go new file mode 100644 index 00000000..f940a3b1 --- /dev/null +++ b/cmd/island_ecs/cmd/root.go @@ -0,0 +1,321 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package cmd + +import ( + "fmt" + "image/color" + "log" + "os" + "path/filepath" + "time" + + "github.com/hajimehoshi/ebiten/v2" + "github.com/hajimehoshi/ebiten/v2/text" + "github.com/siredmar/mdcii-engine/pkg/bsh" + "github.com/siredmar/mdcii-engine/pkg/cod" + buildingsCod "github.com/siredmar/mdcii-engine/pkg/cod/buildings" + "github.com/siredmar/mdcii-engine/pkg/ecs/components" + "github.com/siredmar/mdcii-engine/pkg/ecs/systems" + "github.com/siredmar/mdcii-engine/pkg/ecs/world" + "github.com/siredmar/mdcii-engine/pkg/files" + "github.com/siredmar/mdcii-engine/pkg/gam" + animations "github.com/siredmar/mdcii-engine/pkg/texture/animations" + "github.com/siredmar/mdcii-engine/pkg/texture/atlas" + "github.com/siredmar/mdcii-engine/pkg/world/rotation" + "github.com/spf13/cobra" + "golang.org/x/image/font/basicfont" + + donburi "github.com/yohamta/donburi" + "github.com/yohamta/donburi/filter" +) + +var ( + gamePath string + buildingIndex int + rotationArg int + // buildingParam int +) + +var ( + ScreenWidth int = 1024 + ScreenHeight int = 1024 +) + +func init() { + rootCmd.Flags().StringVarP(&gamePath, "path", "p", ".", "Path to game") + rootCmd.Flags().IntVarP(&buildingIndex, "buildingIndex", "i", 381, "building index") + rootCmd.Flags().IntVarP(&rotationArg, "rotation", "r", 0, "rotation") + // rootCmd.Flags().IntVarP(&buildingParam, "building", "b", 380, "building ID") +} + +var rootCmd = &cobra.Command{ + Use: "animations for buildings", + Short: "animations for buildings", + Run: func(cmd *cobra.Command, args []string) { + absPath, err := filepath.Abs(gamePath) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + dirPath := filepath.Dir(absPath) + + files.CreateInstance(dirPath) + buildingsCodPath, err := files.Instance().FindPathForFile("haeuser.cod") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + haeuserCod, err := cod.NewCod(buildingsCodPath, true) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = haeuserCod.Parse() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + buildings, err := buildingsCod.NewBuildings(haeuserCod) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + gfxStadtfldBshPath, err := files.Instance().FindPathForFile("gfx/stadtfld.bsh") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + gfxStadtfldBsh, err := bsh.NewPng(bsh.WithFile(gfxStadtfldBshPath), bsh.WithConvertAll()) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + atlasWidth := 4096 + atlasHeight := 4096 + + atlas, err := atlas.New(atlasWidth, atlasHeight, buildings, atlas.WithName("texture-atlas"), atlas.WithImages(gfxStadtfldBsh)) + if err != nil { + fmt.Println("Error:", err) + return + } + ani, err := animations.New(atlas) + if err != nil { + fmt.Println("Error:", err) + return + } + + gamParser, err := gam.NewParser() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = gamParser.LoadPath("/home/armin/spiele/anno1602/SAVEGAME/lastgame.gam") + // err = gamParser.LoadPath("/home/armin/spiele/anno1602/NORDNAT/LIT02.SCP") + + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = gamParser.Parse(buildings) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + ebiten.SetWindowSize(ScreenWidth, ScreenHeight) + ebiten.SetWindowTitle("animations") + + w := world.New() + // Create an entity and get its Entry + w.World.Create(components.AnimationType, components.TileType, components.PositionType, components.BuildingType, components.IslandType) + // island := components.CreateIsland(w.World, ani, 10, 10, 10, 10) + components.CreateIslandFromChunk(w.World, ani, gamParser.Islands5[0], 10, 10) + + cameraEntity := w.World.Create(components.CameraType) + cameraEntry := w.World.Entry(cameraEntity) + components.CameraType.Set(cameraEntry, &components.Camera{ + X: 0, + Y: 0, + Zoom: 1.0, + Rotation: rotation.DEG0, + }) + + controlEntity := w.World.Create(components.ControlType) + controlEntry := w.World.Entry(controlEntity) + + components.ControlType.Set(controlEntry, &components.Control{ + Rotation: rotation.DEG0, + GridVisible: true, + LastKeyPressTime: time.Now(), + }) + + // fmt.Println(island) + // w.World.Entry(entity) + + // fmt.Println(w.World) + + // buildingId, err := buildings.GetBuildingIdByIndex(buildingIndex) + // if err != nil { + // log.Fatalln("Error:", err) + // } + + game := &Game{ + world: w, + animations: ani, + // animation: nil, + buildingIndex: buildingIndex, + // buildingId: id, + // count: 0, + buildings: buildings, + rotation: rotation.Rotation(rotationArg), + // entry: entry, + grid: true, + } + + // components.BuildingType.Set(entry, &components.Building{ + // BuildingID: buildingId, + // Rotation: game.rotation, + // }) + + // // Set initial values for the Animation component + // components.AnimationType.Set(entry, &components.Animation{ + // Running: true, + // Duration: 1, + // Loop: true, + // }) + + // components.TileType.Set(entry, &components.Tile{ + // Image: nil, + // }) + + // components.PositionType.Set(entry, &components.Position{ + // X: 100, + // Y: 100, + // }) + + // game.entry = entry + + // game.buildingId, err = buildings.GetBuildingIdByIndex(game.buildingIndex) + // if err != nil { + // fmt.Println("Error:", err) + // return + // } + // game.animation = game.animations.GetAnimation(buildingParam, rotation.DEG0) + if err := ebiten.RunGame(game); err != nil { + log.Fatal(err) + } + }, +} + +func Execute() { + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } + +} + +type Game struct { + world *world.World + animations *animations.Animations + ScreenWidth int + ScreenHeight int + // lastKeyPressTime time.Time + // buildingId int + buildingIndex int + rotation rotation.Rotation + // lastTime time.Time + // entry *donburi.Entry + buildings *buildingsCod.Buildings + grid bool +} + +func (g *Game) Draw(screen *ebiten.Image) { + var rot rotation.Rotation + var grid bool + + controlQuery := donburi.NewQuery(filter.Contains(components.ControlType)) + controlQuery.Each(g.world.World, func(entry *donburi.Entry) { + ctrl := components.ControlType.Get(entry) + rot = ctrl.Rotation + grid = ctrl.GridVisible + }) + systems.RenderSystem(g.world.World, screen, grid, rot) + // systems.MouseSelectorSystem(g.world.World) // Add the mouse selector system + // systems.RenderSystemAscii(g.world.World) +} + +// func (g *Game) DrawBuildingInfo(screen *ebiten.Image) { +// textColor := color.RGBA{255, 255, 255, 255} +// face := basicfont.Face7x13 + +// b := g.buildings.BuildingsVector[g.buildingId] +// text.Draw(screen, fmt.Sprintf("Building Id: %d", b.Id), face, 10, 10, textColor) +// text.Draw(screen, fmt.Sprintf("Building Size: %d,%d", b.Size.W, b.Size.H), face, 10, 20, textColor) +// text.Draw(screen, fmt.Sprintf("Building Animation Amount: %d", b.AnimationAmount), face, 10, 30, textColor) +// text.Draw(screen, fmt.Sprintf("Building Animation Add: %d", b.AnimationAdd), face, 10, 40, textColor) +// text.Draw(screen, fmt.Sprintf("Building Gfx: %d", b.Gfx), face, 10, 50, textColor) +// // text.Draw(screen, fmt.Sprintf("Building Rotation: %d", g.Building.Rotation), face, 10, 60, textColor) +// // text.Draw(screen, fmt.Sprintf("Building BaseIndex: %d", g.Building.BaseIndex), face, 10, 70, textColor) +// // text.Draw(screen, fmt.Sprintf("CurrentAnimationStep: %d", g.Building.CurrentAnimationStep), face, 10, 80, textColor) +// } + +func (g *Game) DrawUsage(screen *ebiten.Image) { + textColor := color.RGBA{255, 255, 255, 255} + face := basicfont.Face7x13 + + text.Draw(screen, "Up: Animation Step, Left/Right: Rotate, N: next, M: previous", face, 10, ScreenHeight-20, textColor) + +} + +func (g *Game) Update() error { + systems.AnimationSystem(g.world.World, g.animations, 1.0/60.0) + systems.InputSystem(g.world.World) + return nil + // const debounceDuration = time.Millisecond * 250 + // now := time.Now() + + // if now.Sub(g.lastKeyPressTime) >= debounceDuration { + // if ebiten.IsKeyPressed(ebiten.KeyLeft) { + // fmt.Println(int(g.rotation)) + // g.rotation.Increment() + // fmt.Println(int(g.rotation)) + // g.lastKeyPressTime = now + + // } else if ebiten.IsKeyPressed(ebiten.KeyRight) { + // fmt.Println(int(g.rotation)) + // g.rotation.Decrement() + // fmt.Println(int(g.rotation)) + // g.lastKeyPressTime = now + // } else if ebiten.IsKeyPressed(ebiten.KeyG) { + // g.grid = !g.grid + // g.lastKeyPressTime = now + // } else if ebiten.IsKeyPressed(ebiten.KeyEscape) { + // os.Exit(0) + // } + // } + // g.lastTime = now + // return nil +} + +func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) { + return ScreenWidth, ScreenHeight +} diff --git a/cmd/island_ecs/main.go b/cmd/island_ecs/main.go new file mode 100644 index 00000000..5b3dea5a --- /dev/null +++ b/cmd/island_ecs/main.go @@ -0,0 +1,22 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package main + +import "github.com/siredmar/mdcii-engine/cmd/island_ecs/cmd" + +func main() { + cmd.Execute() +} diff --git a/cmd/islandhouse/LICENSE b/cmd/islandhouse/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/cmd/islandhouse/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cmd/islandhouse/cmd/root.go b/cmd/islandhouse/cmd/root.go new file mode 100644 index 00000000..e672b2e4 --- /dev/null +++ b/cmd/islandhouse/cmd/root.go @@ -0,0 +1,170 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package cmd + +import ( + "fmt" + "os" + "path/filepath" + "strconv" + + "github.com/siredmar/mdcii-engine/pkg/cod" + "github.com/siredmar/mdcii-engine/pkg/cod/buildings" + "github.com/siredmar/mdcii-engine/pkg/files" + "github.com/siredmar/mdcii-engine/pkg/gam" + "github.com/spf13/cobra" + + "github.com/spf13/viper" + // cod "github.com/siredmar/mdcii-engine/pkg/cod" +) + +var cfgFile string + +var ( + gamePath string + gamFile string +) + +// rootCmd represents the base command when called without any subcommands +var rootCmd = &cobra.Command{ + Use: "islandpng", + Short: "generate ", + // Uncomment the following line if your bare application + // has an action associated with it: + Run: func(cmd *cobra.Command, args []string) { + absPath, err := filepath.Abs(gamePath) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + dirPath := filepath.Dir(absPath) + + files.CreateInstance(dirPath) + buildingsCodPath, err := files.Instance().FindPathForFile("haeuser.cod") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + haeuserCod, err := cod.NewCod(buildingsCodPath, true) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = haeuserCod.Parse() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + buildings, err := buildings.NewBuildings(haeuserCod) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + // jsonBytes, err := json.MarshalIndent(buildings.GetBuildings(), "", " ") + // if err != nil { + // fmt.Println(err) + // os.Exit(1) + // } + + gamParser, err := gam.NewParser() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = gamParser.LoadPath(gamFile) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = gamParser.Parse(buildings) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + uniqueIds := make(map[int]string) + for _, island5 := range gamParser.Islands5 { + for _, islandHouse := range island5.Layers.IslandHouse { + for _, field := range islandHouse.Fields { + uniqueIds[field.Id] = strconv.Itoa(field.Id) + } + } + } + cnt := 32 + for key, _ := range uniqueIds { + uniqueIds[key] = string(rune(cnt)) + cnt++ + } + + for _, island5 := range gamParser.Islands5 { + for _, islandHouse := range island5.Layers.Final { + for i, field := range islandHouse.Fields { + x := i % islandHouse.Size.Width + // y := i / islandHouse.Size.Width + switch field.Id { + case 65535: + fmt.Printf(" ") + default: + fmt.Printf(" %s", uniqueIds[field.Id]) + } + if x%islandHouse.Size.Width == 0 { + fmt.Println() + } + // fmt.Printf("x: %d, y: %d: ", x, y) + // fmt.Println(field) + } + } + } + }, +} + +// Execute adds all child commands to the root command and sets flags appropriately. +// This is called by main.main(). It only needs to happen once to the rootCmd. +func Execute() { + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } + +} + +func init() { + cobra.OnInitialize(initConfig) + + // Cobra also supports local flags, which will only run + // when this action is called directly. + // rootCmd.Flags().BoolVarP(&decrypt, "decrypt", "d", false, "decrypt true/false") + rootCmd.Flags().StringVarP(&gamePath, "path", "p", ".", "Path to game") + + rootCmd.Flags().StringVarP(&gamFile, "gam", "g", "", "gam file path") +} + +// initConfig reads in config file and ENV variables if set. +func initConfig() { + if cfgFile != "" { + // Use config file from the flag. + viper.SetConfigFile(cfgFile) + } + + viper.AutomaticEnv() // read in environment variables that match + + // If a config file is found, read it in. + if err := viper.ReadInConfig(); err == nil { + fmt.Println("Using config file:", viper.ConfigFileUsed()) + } +} diff --git a/cmd/islandhouse/main.go b/cmd/islandhouse/main.go new file mode 100644 index 00000000..4609ff7a --- /dev/null +++ b/cmd/islandhouse/main.go @@ -0,0 +1,22 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package main + +import "github.com/siredmar/mdcii-engine/cmd/islandhouse/cmd" + +func main() { + cmd.Execute() +} diff --git a/cmd/islandpng/LICENSE b/cmd/islandpng/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/cmd/islandpng/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cmd/islandpng/cmd/root.go b/cmd/islandpng/cmd/root.go new file mode 100644 index 00000000..8724f02b --- /dev/null +++ b/cmd/islandpng/cmd/root.go @@ -0,0 +1,391 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package cmd + +// import ( +// "fmt" +// "log" +// "math" +// "os" +// "path/filepath" + +// "github.com/hajimehoshi/ebiten/v2" +// "github.com/hajimehoshi/ebiten/v2/ebitenutil" +// "github.com/siredmar/mdcii-engine/pkg/bsh" +// "github.com/siredmar/mdcii-engine/pkg/chunks" +// "github.com/siredmar/mdcii-engine/pkg/cod" +// "github.com/siredmar/mdcii-engine/pkg/cod/buildings" +// "github.com/siredmar/mdcii-engine/pkg/files" +// "github.com/siredmar/mdcii-engine/pkg/gam" +// "github.com/siredmar/mdcii-engine/pkg/texture/atlas" +// "github.com/siredmar/mdcii-engine/pkg/texture/sprites" +// "github.com/siredmar/mdcii-engine/pkg/world/camera" +// island "github.com/siredmar/mdcii-engine/pkg/world/island/v1alpha1" +// "github.com/siredmar/mdcii-engine/pkg/world/rotation" +// "github.com/siredmar/mdcii-engine/pkg/world/tiles" +// "github.com/spf13/cobra" + +// "github.com/spf13/viper" +// // cod "github.com/siredmar/mdcii-engine/pkg/cod" +// ) + +// var cfgFile string + +// var ( +// gamePath string +// gamFile string +// ) + +// var ( +// ScreenWidth int = 2280 +// ScreenHeight int = 1320 +// TileSize int = 64 +// GridEnable bool = false +// ) + +// // rootCmd represents the base command when called without any subcommands +// var rootCmd = &cobra.Command{ +// Use: "islandpng", +// Short: "generate ", +// // Uncomment the following line if your bare application +// // has an action associated with it: +// Run: func(cmd *cobra.Command, args []string) { +// absPath, err := filepath.Abs(gamePath) +// if err != nil { +// fmt.Println(err) +// os.Exit(1) +// } + +// dirPath := filepath.Dir(absPath) + +// files.CreateInstance(dirPath) +// buildingsCodPath, err := files.Instance().FindPathForFile("haeuser.cod") +// if err != nil { +// fmt.Println(err) +// os.Exit(1) +// } +// haeuserCod, err := cod.NewCod(buildingsCodPath, true) +// if err != nil { +// fmt.Println(err) +// os.Exit(1) +// } +// err = haeuserCod.Parse() +// if err != nil { +// fmt.Println(err) +// os.Exit(1) +// } + +// buildings, err := buildings.NewBuildings(haeuserCod) +// if err != nil { +// fmt.Println(err) +// os.Exit(1) +// } +// // jsonBytes, err := json.MarshalIndent(buildings.GetBuildings(), "", " ") +// // if err != nil { +// // fmt.Println(err) +// // os.Exit(1) +// // } + +// gamParser, err := gam.NewParser() +// if err != nil { +// fmt.Println(err) +// os.Exit(1) +// } +// err = gamParser.LoadPath(gamFile) +// if err != nil { +// fmt.Println(err) +// os.Exit(1) +// } +// err = gamParser.Parse(buildings) +// if err != nil { +// fmt.Println(err) +// os.Exit(1) +// } + +// gfxStadtfldBshPath, err := files.Instance().FindPathForFile("gfx/stadtfld.bsh") +// if err != nil { +// fmt.Println(err) +// os.Exit(1) +// } +// gfxStadtfldBsh, err := bsh.NewPng(bsh.WithFile(gfxStadtfldBshPath), bsh.WithConvertAll()) +// if err != nil { +// fmt.Println(err) +// os.Exit(1) +// } + +// // // convert to json gamParser.Islands5[0 +// // jsonBytes, err := json.MarshalIndent(gamParser.Islands5[0], "", " ") +// // if err != nil { +// // fmt.Println(err) +// // os.Exit(1) +// // } +// // fmt.Println(string(jsonBytes)) +// gridAtlas, err := atlas.New(100, 100, atlas.WithName("grid"), atlas.WithFiles([]string{"./assets/gfx/0.png", "./assets/gfx/1.png"})) +// if err != nil { +// fmt.Println(err) +// os.Exit(1) +// } + +// gfxAtlas, err := atlas.New(4096, 4096, atlas.WithName("gfx-stadtfld"), atlas.WithImages(gfxStadtfldBsh.Images)) +// if err != nil { +// fmt.Println(err) +// os.Exit(1) +// } + +// gridSprites, err := sprites.NewSprites(gridAtlas) +// if err != nil { +// fmt.Println(err) +// os.Exit(1) +// } + +// gfxSprites, err := sprites.NewSprites(gfxAtlas) +// if err != nil { +// fmt.Println(err) +// os.Exit(1) +// } +// // fmt.Println(gfxSprites) + +// ebiten.SetWindowSize(ScreenWidth, ScreenHeight) +// ebiten.SetWindowTitle("islandpng") +// game := &Game{ +// windowWidth: ScreenWidth, +// windowHeight: ScreenHeight, +// tileSize: TileSize, +// gfxSprites: gfxSprites, +// gridSprites: gridSprites, +// gam: gamParser, +// buildings: buildings, +// op: &ebiten.DrawImageOptions{}, +// buffer: ebiten.NewImage(ScreenWidth, ScreenHeight), +// Camera: camera.NewCamera(-float64(ScreenWidth/2), -float64(ScreenHeight/2), 500, 1, 1.2), +// drawToBuffer: true, +// tileInfoX: 0, +// tileInfoY: 0, +// gKeyDebounce: 0, +// islandToLoad: gamParser.Islands5[0], +// island: nil, +// } +// game.island, err = island.NewIsland(island.WithChunk(game.gfxSprites, game.buildings, gamParser.Islands5[0])) +// if err != nil { +// fmt.Println(err) +// os.Exit(1) +// } + +// if err := ebiten.RunGame(game); err != nil { +// log.Fatal(err) +// } +// }, +// } + +// type Game struct { +// windowWidth int +// windowHeight int +// tileSize int +// gfxSprites *sprites.Sprites +// gridSprites *sprites.Sprites +// gam *gam.GamParser +// buildings *buildings.Buildings +// ScreenWidth int +// ScreenHeight int +// Camera *camera.Camera +// buffer *ebiten.Image +// op *ebiten.DrawImageOptions +// drawToBuffer bool +// tileInfoX int +// tileInfoY int +// gKeyDebounce int +// islandToLoad *chunks.Island5 +// island *island.Island +// } + +// func (g *Game) Update() error { +// dt := 1.0 / 60 +// if ebiten.IsKeyPressed(ebiten.KeyLeft) || ebiten.IsKeyPressed(ebiten.KeyA) { +// g.Camera.X -= g.Camera.Speed * dt / g.Camera.Zoom +// g.drawToBuffer = true +// } +// if ebiten.IsKeyPressed(ebiten.KeyRight) || ebiten.IsKeyPressed(ebiten.KeyD) { +// g.Camera.X += g.Camera.Speed * dt / g.Camera.Zoom +// g.drawToBuffer = true +// } +// if ebiten.IsKeyPressed(ebiten.KeyDown) || ebiten.IsKeyPressed(ebiten.KeyS) { +// g.Camera.Y -= g.Camera.Speed * dt / g.Camera.Zoom +// g.drawToBuffer = true +// } +// if ebiten.IsKeyPressed(ebiten.KeyUp) || ebiten.IsKeyPressed(ebiten.KeyW) { +// g.Camera.Y += g.Camera.Speed * dt / g.Camera.Zoom +// g.drawToBuffer = true +// } +// if ebiten.IsKeyPressed(ebiten.KeyG) { +// g.gKeyDebounce++ +// if g.gKeyDebounce > 4 { +// GridEnable = !GridEnable +// g.gKeyDebounce = 0 +// } +// } +// if ebiten.IsKeyPressed(ebiten.KeyR) { +// g.gKeyDebounce++ +// if g.gKeyDebounce > 6 { +// g.Camera.RotateRight() +// g.gKeyDebounce = 0 +// } +// } +// if ebiten.IsKeyPressed(ebiten.KeyL) { +// g.gKeyDebounce++ +// if g.gKeyDebounce > 6 { +// g.Camera.RotateLeft() +// g.gKeyDebounce = 0 +// } +// } +// if ebiten.IsKeyPressed(ebiten.KeyEscape) { +// os.Exit(0) +// } +// _, sY := ebiten.Wheel() +// g.Camera.Zoom *= math.Pow(g.Camera.ZoomSpeed, sY) + +// if sY != 0 { +// g.drawToBuffer = true +// } + +// // Get the cursor position +// mx, my := ebiten.CursorPosition() +// // Offset for center +// fmx := float64(mx) - float64(g.windowWidth)/2.0 +// fmy := float64(my) - float64(g.windowHeight)/2.0 +// // x, y := float64(mx)+float64(g.windowWidth/2.0), float64(my)+float64(g.windowHeight/2.0) +// // Translate it to game coordinates +// x, y := (float64(fmx/g.Camera.Zoom) + g.Camera.X), float64(fmy/g.Camera.Zoom)-g.Camera.Y + +// // Do a half tile mouse shift because of our perspective +// x -= .5 * float64(g.tileSize) +// y -= .5 * float64(g.tileSize) +// // Convert isometric +// imx, imy := rotation.IsoToCartesian(x, y, g.tileSize) +// imx = math.Floor(imx) + 1 +// imy = math.Floor(imy) + 1 +// g.tileInfoX = int(imx) +// g.tileInfoY = int(imy) +// return nil +// } + +// // var once sync.Once +// // update is called every frame (1/60 [s]). +// func (g *Game) Draw(screen *ebiten.Image) { +// // fmt.Println("Rendering frame", g.frames) + +// // Write your game's logical update. + +// // // Draw only if we have to (and only draw the visible ones) +// g.buffer.Clear() +// g.render(g.buffer) +// g.drawToBuffer = false +// screen.DrawImage(g.buffer, nil) +// ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS %f, FPS %f", ebiten.ActualTPS(), ebiten.ActualFPS())) +// ebitenutil.DebugPrintAt(screen, fmt.Sprintf("Camera: X: %f, Y: %f, Zoom: %f", g.Camera.X, g.Camera.Y, g.Camera.Zoom), 0, 20) +// ebitenutil.DebugPrintAt(screen, fmt.Sprintf("Rotation: %s", g.Camera.CurrentRotation().String()), 0, 30) + +// // g.lastMousePosX = mx +// // g.lastMousePosY = my + +// } + +// // func PrintGrid(dst *ebiten.Image, x1, y1 float64, color color.Color, tileSize int) { +// // x1i, y1i := rotation.CartesianToIso(float64(x1), float64(y1), tileSize) +// // x2i, y2i := rotation.CartesianToIso(float64(x1+float64(tileSize)), y1+float64(tileSize), tileSize) + +// // vector.StrokeLine(dst, float32(x1i), float32(y1i), float32(x2i), float32(y2i), 1, color, false) +// // } + +// func (g *Game) render(screen *ebiten.Image) { +// t := g.gam.Islands5[0].Layers.Top.Fields[y*g.gam.Islands5[0].Width+x] +// if t.Id == 65535 || t.Id == 102 { +// continue +// } +// if t.Id == 1201 { +// fmt.Println("found 1201") +// } +// building := g.buildings.Buildings[t.Id] +// tile := tiles.NewTerrainTile(rotation.Rotation(t.Orientation), t.Posx, t.Posy, g.buildings.Buildings[t.Id], g.gfxSprites) +// if g.tileInfoX == x && g.tileInfoY == y { +// ebitenutil.DebugPrintAt(screen, fmt.Sprintf("Tile: %d, X: %d, Y: %d, Orientation: %d, GFX: %d, PosOffset: %d", t.Id, x, y, t.Orientation, tile.Gfx[tile.Rotation], building.PositionOffset), 0, 40) +// ebitenutil.DebugPrintAt(screen, fmt.Sprintf("Type: %s", building.Kind.String()), 0, 60) +// } + +// xi, yi := rotation.CartesianToIso(float64(x), float64(y), g.tileSize) +// g.op.GeoM.Reset() +// //Translate for isometric +// g.op.GeoM.Translate(float64(xi), float64(yi)) +// // Translate for tile offset +// g.op.GeoM.Translate(0, -float64(tile.CalcOffset())) +// //Scale for camera zoom +// g.op.GeoM.Scale(g.Camera.Zoom, g.Camera.Zoom) +// //Translate for center of screen offset +// g.op.GeoM.Translate(float64(g.windowWidth/2.0), float64(g.windowHeight/2.0)) +// //Translate for camera position +// g.op.GeoM.Translate(-g.Camera.X, g.Camera.Y) +// // gridOp := &ebiten.DrawImageOptions{} +// // gridOp.GeoM.Translate(float64(xi), float64(yi)) +// // gridOp.GeoM.Scale(g.Camera.Zoom, g.Camera.Zoom) +// // gridOp.GeoM.Translate(float64(g.windowWidth/2.0), float64(g.windowHeight/2.0)) +// // gridOp.GeoM.Translate(-g.Camera.X, g.Camera.Y) + +// img := g.gfxSprites.Sprites[tile.Gfx[tile.Rotation]].Image +// screen.DrawImage(img, g.op) +// // if GridEnable { +// // screen.DrawImage(g.gridSprites.Sprites[0].Image, gridOp) +// // } + +// } + +// func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) { +// return ScreenWidth, ScreenHeight +// } + +// // Execute adds all child commands to the root command and sets flags appropriately. +// // This is called by main.main(). It only needs to happen once to the rootCmd. +// func Execute() { +// if err := rootCmd.Execute(); err != nil { +// fmt.Println(err) +// os.Exit(1) +// } + +// } + +// func init() { +// cobra.OnInitialize(initConfig) + +// // Cobra also supports local flags, which will only run +// // when this action is called directly. +// // rootCmd.Flags().BoolVarP(&decrypt, "decrypt", "d", false, "decrypt true/false") +// rootCmd.Flags().StringVarP(&gamePath, "path", "p", ".", "Path to game") + +// rootCmd.Flags().StringVarP(&gamFile, "gam", "g", "", "gam file path") +// } + +// // initConfig reads in config file and ENV variables if set. +// func initConfig() { +// if cfgFile != "" { +// // Use config file from the flag. +// viper.SetConfigFile(cfgFile) +// } + +// viper.AutomaticEnv() // read in environment variables that match + +// // If a config file is found, read it in. +// if err := viper.ReadInConfig(); err == nil { +// fmt.Println("Using config file:", viper.ConfigFileUsed()) +// } +// } diff --git a/cmd/islandpng/main.go b/cmd/islandpng/main.go new file mode 100644 index 00000000..4b6bb93e --- /dev/null +++ b/cmd/islandpng/main.go @@ -0,0 +1,22 @@ +/* +Copyright © 2023 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package main + +// import "github.com/siredmar/mdcii-engine/cmd/islandpng/cmd" + +func main() { + // cmd.Execute() +} diff --git a/cmd/mdcii/main.go b/cmd/mdcii/main.go new file mode 100644 index 00000000..69aed202 --- /dev/null +++ b/cmd/mdcii/main.go @@ -0,0 +1,27 @@ +package main + +import ( + "flag" + + ebiten "github.com/hajimehoshi/ebiten/v2" +) + +var ( + path = flag.String("path", ".", "PATH TO GAME") +) + +func main() { + flag.Parse() + ebiten.SetWindowTitle("MDCII") + ebiten.SetWindowSize(640, 480) + ebiten.SetWindowResizable(true) + + // g, err := game.NewGame(*path, "") + // if err != nil { + // log.Fatal(err) + // } + + // if err = ebiten.RunGame(g); err != nil { + // log.Fatal(err) + // } +} diff --git a/configure b/configure deleted file mode 100755 index cdf8e574..00000000 --- a/configure +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/bash - -# Default options -BUILD_DIR="build" -CMAKE_GENERATOR="Unix Makefiles" -BUILD_TYPE="Release" -CMAKE_OPTIONS="$CMAKE_OPTIONS" - -# Create default configs -if [ ! -d "./.localconfig" ] -then - mkdir ".localconfig" - - touch ".localconfig/default" - echo "#!/bin/bash" >> ".localconfig/default" - echo "" >> ".localconfig/default" - echo "# Default configuration for configure (is always sourced)" >> ".localconfig/default" - echo "" >> ".localconfig/default" - echo "# CMake generator" >> ".localconfig/default" - echo "CMAKE_GENERATOR=\"Unix Makefiles\"" >> ".localconfig/default" - echo "" >> ".localconfig/default" - echo "# Build directory and build type" >> ".localconfig/default" - echo "BUILD_DIR=\"build\"" >> ".localconfig/default" - echo "BUILD_TYPE=\"Release\"" >> ".localconfig/default" - echo "" >> ".localconfig/default" - echo "# Installation directory" >> ".localconfig/default" - echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DCMAKE_INSTALL_PREFIX=../install\"" >> ".localconfig/default" - echo "" >> ".localconfig/default" - echo "# Build static libraries" >> ".localconfig/default" - echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF\"" >> ".localconfig/default" - echo "" >> ".localconfig/default" - echo "# Enable examples" >> ".localconfig/default" - echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_EXAMPLES:BOOL=ON\"" >> ".localconfig/default" - echo "" >> ".localconfig/default" - echo "# Enable documentation" >> ".localconfig/default" - echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_DOCS:BOOL=ON\"" >> ".localconfig/default" - echo "" >> ".localconfig/default" - echo "# Disable tests" >> ".localconfig/default" - echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_TESTS:BOOL=OFF\"" >> ".localconfig/default" - echo "" >> ".localconfig/default" - echo "" >> ".localconfig/default" - echo "# CMake and environment variables (e.g., search paths for external libraries)" >> ".localconfig/default" - echo "" >> ".localconfig/default" - echo "# Qt" >> ".localconfig/default" - echo "#export CMAKE_PREFIX_PATH=\"\${CMAKE_PREFIX_PATH}:/opt/Qt5.2.1/5.2.1/gcc_64/\"" >> ".localconfig/default" - - touch ".localconfig/debug" - echo "#!/bin/bash" >> ".localconfig/debug" - echo "" >> ".localconfig/debug" - echo "# Configuration for debug builds" >> ".localconfig/debug" - echo "" >> ".localconfig/debug" - echo "# Build directory and build type" >> ".localconfig/debug" - echo "BUILD_DIR=\"\${BUILD_DIR}-debug\"" >> ".localconfig/debug" - echo "BUILD_TYPE=\"Debug\"" >> ".localconfig/debug" - - touch ".localconfig/pack" - echo "#!/bin/bash" >> ".localconfig/pack" - echo "" >> ".localconfig/pack" - echo "# Configuration for creating packages" >> ".localconfig/pack" - echo "" >> ".localconfig/pack" - echo "# Installation directory" >> ".localconfig/pack" - echo "CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DCMAKE_INSTALL_PREFIX=/usr\"" >> ".localconfig/pack" - echo "" >> ".localconfig/pack" - echo "# Enable self-contained installation" >> ".localconfig/pack" - echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_SELF_CONTAINED:BOOL=ON\"" >> ".localconfig/pack" - echo "" >> ".localconfig/pack" - echo "# Enable all components for the package" >> ".localconfig/pack" - echo "CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_EXAMPLES:BOOL=ON\"" >> ".localconfig/pack" - echo "CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_DOCS:BOOL=ON\"" >> ".localconfig/pack" - echo "CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_TESTS:BOOL=OFF\"" >> ".localconfig/pack" - - echo "Default configuration has been written to .localconfig" - echo "Please review and adjust the configuration, then run again" - echo "" - echo " ./configure $@" - - exit -fi - -# Read local default options -if [ -f "./.localconfig/default" ] -then - . ./.localconfig/default -fi - -# Parse command line arguments -for ARG in "$@" -do - # Read in configuration for that command-line argument - CONFIGFILE="./.localconfig/$ARG" - if [ -f "./.localconfig/$ARG" ] - then - . "./.localconfig/$ARG" - elif [ -f "$HOME/.localconfig/$ARG" ] - then - . "$HOME/.localconfig/$ARG" - else - echo "Configuration \"$ARG\" not found (searched in ./.localconfig and ~/.localconfig)" - fi -done - -if [ "$CMAKE_GENERATOR_OVERRIDE" != "" ] -then - echo "Override CMAKE_GENERATOR to $CMAKE_GENERATOR_OVERRIDE" - CMAKE_GENERATOR="$CMAKE_GENERATOR_OVERRIDE" -fi - -# Configure build -echo "Configuring in $BUILD_DIR..." -echo "" - -# Create build directory -if [ ! -d "$BUILD_DIR" ] -then - mkdir -p "$BUILD_DIR" -fi - -# Configure project -PREVIOUS_DIR=$(pwd) -cd $BUILD_DIR -echo cmake -G "$CMAKE_GENERATOR" "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" $CMAKE_OPTIONS "$PREVIOUS_DIR" -cmake -G "$CMAKE_GENERATOR" "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" $CMAKE_OPTIONS "$PREVIOUS_DIR" -if [ $? == 0 ] -then - echo "" - echo "Project configured. To build the project, use"; - echo "" - echo " cmake --build $BUILD_DIR" -else - echo "" - echo "Configuration failed."; -fi - -cd "$PREVIOUS_DIR" diff --git a/deploy/CMakeLists.txt b/deploy/CMakeLists.txt deleted file mode 100644 index 0ac54f6b..00000000 --- a/deploy/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ - -# -# Target 'pack' -# - -add_custom_target(pack) -set_target_properties(pack PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1) - - -# Install additional runtime dependencies -include(${PROJECT_SOURCE_DIR}/cmake/RuntimeDependencies.cmake) - - -# -# Packages -# - -include(packages/pack-${META_PROJECT_NAME}.cmake) - - -# -# Target 'component_install' -# - -add_custom_target( - component_install - COMMAND make preinstall - COMMAND ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/cmake/ComponentInstall.cmake - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} -) diff --git a/deploy/README.md b/deploy/README.md deleted file mode 100644 index f6d7cb23..00000000 --- a/deploy/README.md +++ /dev/null @@ -1,16 +0,0 @@ - -# Deployment Types - -## System Install - -## Global Install - -## Source Build - -## Relocatable - -# Packages and Installer - -## Package Manager - -# Components diff --git a/deploy/packages/pack-mdcii.cmake b/deploy/packages/pack-mdcii.cmake deleted file mode 100644 index 8585bf18..00000000 --- a/deploy/packages/pack-mdcii.cmake +++ /dev/null @@ -1,259 +0,0 @@ - -# -# Check if cpack is available -# - -if(NOT EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") - return() -endif() - - -# -# Output packages -# - -if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows") - # Windows installer - set(OPTION_PACK_GENERATOR "NSIS;ZIP" CACHE STRING "Package targets") - set(PACK_COMPONENT_INSTALL ON) - set(PACK_INCLUDE_TOPDIR OFF) -elseif(UNIX AND SYSTEM_DIR_INSTALL) - # System installation packages for unix systems - if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") - set(OPTION_PACK_GENERATOR "TGZ;DEB;RPM" CACHE STRING "Package targets") - set(PACK_COMPONENT_INSTALL ON) - set(PACK_INCLUDE_TOPDIR OFF) - else() - set(OPTION_PACK_GENERATOR "TGZ" CACHE STRING "Package targets") - set(PACK_COMPONENT_INSTALL OFF) - set(PACK_INCLUDE_TOPDIR OFF) - endif() -#elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") - # MacOS X disk image - # At the moment, DMG generator and CPACK_INCLUDE_TOPLEVEL_DIRECTORY=ON do not work together. - # Therefore, we disable dmg images for MacOS until we've found a solution -# set(OPTION_PACK_GENERATOR "DragNDrop" CACHE STRING "Package targets") -# set(PACK_COMPONENT_INSTALL OFF) -# set(PACK_INCLUDE_TOPDIR ON) -else() - # Default (portable package for any platform) - set(OPTION_PACK_GENERATOR "ZIP;TGZ" CACHE STRING "Package targets") - set(PACK_COMPONENT_INSTALL OFF) - set(PACK_INCLUDE_TOPDIR ON) -endif() - - -# -# Package components -# - -set(CPACK_COMPONENT_RUNTIME_DISPLAY_NAME "${META_PROJECT_NAME} library") -set(CPACK_COMPONENT_RUNTIME_DESCRIPTION "Runtime components for ${META_PROJECT_NAME} library") - -set(CPACK_COMPONENT_DEV_DISPLAY_NAME "C/C++ development files") -set(CPACK_COMPONENT_DEV_DESCRIPTION "Development files for ${META_PROJECT_NAME} library") -set(CPACK_COMPONENT_DEV_DEPENDS runtime) - -set(CPACK_COMPONENTS_ALL runtime dev) - -if (OPTION_BUILD_EXAMPLES) - set(CPACK_COMPONENT_EXAMPLES_DISPLAY_NAME "Example applications") - set(CPACK_COMPONENT_EXAMPLES_DESCRIPTION "Example applications for ${META_PROJECT_NAME} library") - set(CPACK_COMPONENT_EXAMPLES_DEPENDS runtime) - - set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} examples) -endif() - -if (OPTION_BUILD_DOCS) - set(CPACK_COMPONENT_DOCS_DISPLAY_NAME "Documentation") - set(CPACK_COMPONENT_DOCS_DESCRIPTION "Documentation of ${META_PROJECT_NAME} library") - - set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} docs) -endif() - - -# -# Initialize CPack -# - -# Reset CPack configuration -if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") - set(CPACK_IGNORE_FILES "") - set(CPACK_INSTALLED_DIRECTORIES "") - set(CPACK_SOURCE_IGNORE_FILES "") - set(CPACK_SOURCE_INSTALLED_DIRECTORIES "") - set(CPACK_STRIP_FILES "") - set(CPACK_SOURCE_TOPLEVEL_TAG "") - set(CPACK_SOURCE_PACKAGE_FILE_NAME "") - set(CPACK_PACKAGE_RELOCATABLE OFF) - set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY ${PACK_INCLUDE_TOPDIR}) - set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY ${PACK_INCLUDE_TOPDIR}) -endif() - -# Find cpack executable -get_filename_component(CPACK_PATH ${CMAKE_COMMAND} PATH) -set(CPACK_COMMAND "${CPACK_PATH}/cpack") - -# Set install prefix -if(SYSTEM_DIR_INSTALL) - set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") -else() - set(CPACK_PACKAGING_INSTALL_PREFIX "") -endif() - -# Package project -set(project_name ${META_PROJECT_NAME}) # Name of package project -set(project_root ${META_PROJECT_NAME}) # Name of root project that is to be installed - -# Package information -string(TOLOWER ${META_PROJECT_NAME} package_name) -set(package_description ${META_PROJECT_DESCRIPTION}) -set(package_vendor ${META_AUTHOR_ORGANIZATION}) -set(package_maintainer ${META_AUTHOR_MAINTAINER}) - -# Package specific options -set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/deploy/packages/${project_name}) - - -# -# Package information -# - -set(CPACK_PACKAGE_NAME "${package_name}") -set(CPACK_PACKAGE_VENDOR "${package_vendor}") -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${package_description}") -set(CPACK_PACKAGE_VERSION "${META_VERSION}") -set(CPACK_PACKAGE_VERSION_MAJOR "${META_VERSION_MAJOR}") -set(CPACK_PACKAGE_VERSION_MINOR "${META_VERSION_MINOR}") -set(CPACK_PACKAGE_VERSION_PATCH "${META_VERSION_PATCH}") -set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") -set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.md") -set(CPACK_RESOURCE_FILE_WELCOME "${PROJECT_SOURCE_DIR}/README.md") -set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.md") -set(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake-init-logo.png") -set(CPACK_PACKAGE_FILE_NAME "${package_name}-${CPACK_PACKAGE_VERSION}") -set(CPACK_PACKAGE_INSTALL_DIRECTORY "${package_name}") -set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${package_name}") - - -# -# NSIS package -# - -# Fix icon path -if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows" AND CPACK_PACKAGE_ICON) - # NOTE: for using MUI (UN)WELCOME images we suggest to replace nsis defaults, - # since there is currently no way to do so without manipulating the installer template (which we won't). - # http://public.kitware.com/pipermail/cmake-developers/2013-January/006243.html - - # SO the following only works for the installer icon, not for the welcome image. - - # NSIS requires "\\" - escaped backslash to work properly. We probably won't rely on this feature, - # so just replacing / with \\ manually. - - #file(TO_NATIVE_PATH "${CPACK_PACKAGE_ICON}" CPACK_PACKAGE_ICON) - string(REGEX REPLACE "/" "\\\\\\\\" CPACK_PACKAGE_ICON "${CPACK_PACKAGE_ICON}") -endif() - -# Fix installation path for x64 builds -if(X64) - # http://public.kitware.com/Bug/view.php?id=9094 - set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64") -endif() - -# Package options -#set(CPACK_NSIS_DISPLAY_NAME "${package_name}-${META_VERSION}") -#set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/deploy/images/logo.ico") -#set(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/deploy/images/logo.ico") - -# Optional Preliminaries (i.e., silent Visual Studio Redistributable install) -if(NOT INSTALL_MSVC_REDIST_FILEPATH) - set(INSTALL_MSVC_REDIST_FILEPATH "" CACHE FILEPATH "Visual C++ Redistributable Installer (note: manual match the selected generator)" FORCE) -endif() - -if(EXISTS ${INSTALL_MSVC_REDIST_FILEPATH}) - get_filename_component(MSVC_REDIST_NAME ${INSTALL_MSVC_REDIST_FILEPATH} NAME) - string(REGEX REPLACE "/" "\\\\\\\\" INSTALL_MSVC_REDIST_FILEPATH ${INSTALL_MSVC_REDIST_FILEPATH}) - list(APPEND CPACK_NSIS_EXTRA_INSTALL_COMMANDS " - SetOutPath \\\"$TEMP\\\" - File \\\"${INSTALL_MSVC_REDIST_FILEPATH}\\\" - ExecWait '\\\"$TEMP\\\\${MSVC_REDIST_NAME} /quiet\\\"' - Delete \\\"$TEMP\\\\${MSVC_REDIST_NAME}\\\" - ") -endif() - - -# -# Debian package -# - -set(CPACK_DEBIAN_PACKAGE_NAME "${package_name}") -set(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}") -set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "all") -#set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.1-6), libgcc1 (>= 1:3.4.2-12)") -set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${package_maintainer}") -set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") -set(CPACK_DEBIAN_PACKAGE_SECTION "devel") -set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") -#set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "") -#set(CPACK_DEBIAN_PACKAGE_SUGGESTS "") -set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "") -set(CPACK_DEB_COMPONENT_INSTALL ${PACK_COMPONENT_INSTALL}) - - -# -# RPM package -# - -set(CPACK_RPM_PACKAGE_NAME "${package_name}") -set(CPACK_RPM_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}") -set(CPACK_RPM_PACKAGE_RELEASE 1) -set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") -set(CPACK_RPM_PACKAGE_REQUIRES "") -set(CPACK_RPM_PACKAGE_PROVIDES "") -set(CPACK_RPM_PACKAGE_VENDOR "${package_vendor}") -set(CPACK_RPM_PACKAGE_LICENSE "MIT") -set(CPACK_RPM_PACKAGE_SUMMARY "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") -set(CPACK_RPM_PACKAGE_DESCRIPTION "") -set(CPACK_RPM_PACKAGE_GROUP "unknown") -#set(CPACK_RPM_SPEC_INSTALL_POST "") -#set(CPACK_RPM_SPEC_MORE_DEFINE "") -#set(CPACK_RPM_USER_BINARY_SPECFILE "") -#set(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE "") -#set(CPACK_RPM__INSTALL_SCRIPT_FILE "") -#set(CPACK_RPM_PACKAGE_DEBUG 1) -set(CPACK_RPM_PACKAGE_RELOCATABLE OFF) -set(CPACK_RPM_COMPONENT_INSTALL ${PACK_COMPONENT_INSTALL}) - - -# -# Archives (zip, tgz, ...) -# - -set(CPACK_ARCHIVE_COMPONENT_INSTALL ${PACK_COMPONENT_INSTALL}) - - -# -# Execute CPack -# - -set(CPACK_OUTPUT_CONFIG_FILE "${PROJECT_BINARY_DIR}/CPackConfig-${project_name}.cmake") -set(CPACK_GENERATOR "${OPTION_PACK_GENERATOR}") -set(CPack_CMake_INCLUDED FALSE) -include(CPack) - - -# -# Package target -# - -# Create target -add_custom_target( - pack-${project_name} - COMMAND ${CPACK_COMMAND} --config ${PROJECT_BINARY_DIR}/CPackConfig-${project_name}.cmake -C $ - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} -) -set_target_properties(pack-${project_name} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1) - -# Set dependencies -add_dependencies(pack pack-${project_name}) diff --git a/deploy/ubuntu-ppa/debian/changelog b/deploy/ubuntu-ppa/debian/changelog deleted file mode 100644 index 9d713595..00000000 --- a/deploy/ubuntu-ppa/debian/changelog +++ /dev/null @@ -1,6 +0,0 @@ - -cmake-init (2.0.0-0) UNRELEASED; urgency=low - - * Initial release. - - -- Willy Scheibel Tue, 31 Jan 2017 13:30:00 +0100 diff --git a/deploy/ubuntu-ppa/debian/compat b/deploy/ubuntu-ppa/debian/compat deleted file mode 100644 index ec635144..00000000 --- a/deploy/ubuntu-ppa/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/deploy/ubuntu-ppa/debian/control b/deploy/ubuntu-ppa/debian/control deleted file mode 100644 index f6e95c90..00000000 --- a/deploy/ubuntu-ppa/debian/control +++ /dev/null @@ -1,46 +0,0 @@ -Source: cmake-init -Section: misc -Priority: optional -Maintainer: Willy Scheibel -Build-Depends: build-essential, cmake, qtbase5-dev, doxygen, graphviz -Standards-Version: 3.8.0 - -Package: libcmake-init -Architecture: any -Depends: -Homepage: https://github.com/cginternals/cmake-init -Description: Template for reliable, cross-platform C++ project setup using cmake. - -Package: libcmake-init-dev -Architecture: any -Depends: libcmake-init -Homepage: https://github.com/cginternals/cmake-init -Description: Template for reliable, cross-platform C++ project setup using cmake. - -Package: libcmake-init-examples-data -Architecture: any -Homepage: https://github.com/cginternals/cmake-init -Description: Template for reliable, cross-platform C++ project setup using cmake. - -Package: libcmake-init-examples -Architecture: any -Depends: libcmake-init, libcmake-init-examples-data, libqt5core5a -Homepage: https://github.com/cginternals/cmake-init -Description: Template for reliable, cross-platform C++ project setup using cmake. - -Package: libcmake-init-docs -Architecture: any -Homepage: https://github.com/cginternals/cmake-init -Description: Template for reliable, cross-platform C++ project setup using cmake. - -Package: libcmake-init-dbg -Architecture: any -Depends: libcmake-init, libcmake-init-dev -Homepage: https://github.com/cginternals/cmake-init -Description: Template for reliable, cross-platform C++ project setup using cmake. - -Package: libcmake-init-all -Architecture: any -Depends: libcmake-init, libcmake-init-dev, libcmake-init-docs, libcmake-init-examples -Homepage: https://github.com/cginternals/cmake-init -Description: Template for reliable, cross-platform C++ project setup using cmake. \ No newline at end of file diff --git a/deploy/ubuntu-ppa/debian/copyright b/deploy/ubuntu-ppa/debian/copyright deleted file mode 100644 index 5d8e1adb..00000000 --- a/deploy/ubuntu-ppa/debian/copyright +++ /dev/null @@ -1,18 +0,0 @@ -This package was debianised by Willy Scheibel on -Tue, 31 Jan 2017 13:30:00 +0100 - -It was downloaded from: - - https://github.com/cginternals/cmake-init - -Upstream Author: - - CG Internals - -Copyright: - - Copyright (c) 2015-2017 CG Internals GmbH and Computer Graphics Systems Group at the Hasso-Plattner-Institute, Germany. - -License: - - This software is available to you under the terms of the MIT license, see "https://github.com/cginternals/cmake-init/blob/master/LICENSE". diff --git a/deploy/ubuntu-ppa/debian/rules b/deploy/ubuntu-ppa/debian/rules deleted file mode 100644 index 64e5deef..00000000 --- a/deploy/ubuntu-ppa/debian/rules +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/make -f - -BUILDDIR = build -BUILDDEBUGDIR = build-debug - -# firstly called by launchpad -clean: - rm -rf $(BUILDDIR) - rm -rf $(BUILDDEBUGDIR) - -# secondly called by launchpad -build: build-arch - -build-arch: - mkdir $(BUILDDIR) - cd $(BUILDDIR);cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DOPTION_BUILD_TESTS=Off -DOPTION_BUILD_EXAMPLES=On -DOPTION_BUILD_DOCS=On .. - make -C $(BUILDDIR) - mkdir $(BUILDDEBUGDIR) - cd $(BUILDDEBUGDIR);cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr -DOPTION_BUILD_TESTS=Off -DOPTION_BUILD_EXAMPLES=Off -DOPTION_BUILD_DOCS=Off .. - make -C $(BUILDDEBUGDIR) - -# thirdly called by launchpad -binary: binary-arch - -binary-arch: libcmake-init libcmake-init-dev libcmake-init-docs libcmake-init-dbg libcmake-init-examples-data libcmake-init-examples libcmake-init-all - -libcmake-init: - cd $(BUILDDIR); DESTDIR=../debian/tmp COMPONENT=runtime make component_install - mkdir -p debian/tmp/DEBIAN - dpkg-gencontrol -plibcmake-init - dpkg --build debian/tmp .. - rm -rf debian/tmp - -libcmake-init-dev: - cd $(BUILDDIR); DESTDIR=../debian/tmp COMPONENT=dev make component_install - mkdir -p debian/tmp/DEBIAN - dpkg-gencontrol -plibcmake-init-dev - dpkg --build debian/tmp .. - rm -rf debian/tmp - -libcmake-init-docs: - cd $(BUILDDIR); DESTDIR=../debian/tmp COMPONENT=docs make component_install - mkdir -p debian/tmp/DEBIAN - dpkg-gencontrol -plibcmake-init-docs - dpkg --build debian/tmp .. - rm -rf debian/tmp - -libcmake-init-dbg: - cd $(BUILDDEBUGDIR); DESTDIR=../debian/tmp COMPONENT=runtime make component_install - cd $(BUILDDEBUGDIR); DESTDIR=../debian/tmp COMPONENT=dev make component_install - rm -rf debian/tmp/usr/include - rm debian/tmp/usr/share/*/*-config.cmake - rm debian/tmp/usr/share/*/AUTHORS - rm debian/tmp/usr/share/*/LICENSE - rm debian/tmp/usr/share/*/README.md - rm debian/tmp/usr/share/*/VERSION - rm debian/tmp/usr/share/*/cmake/*/*-export.cmake - mkdir -p debian/tmp/DEBIAN - dpkg-gencontrol -plibcmake-init-dbg - dpkg --build debian/tmp .. - rm -rf debian/tmp - -libcmake-init-examples-data: - cd $(BUILDDIR); DESTDIR=../debian/tmp COMPONENT=examples_data make component_install - mkdir -p debian/tmp/DEBIAN - dpkg-gencontrol -plibcmake-init-examples-data - dpkg --build debian/tmp .. - rm -rf debian/tmp - -libcmake-init-examples: - cd $(BUILDDIR); DESTDIR=../debian/tmp COMPONENT=examples_qt make component_install - mkdir -p debian/tmp/DEBIAN - dpkg-gencontrol -plibcmake-init-examples - dpkg --build debian/tmp .. - rm -rf debian/tmp - -libcmake-init-all: - mkdir -p debian/tmp/DEBIAN - dpkg-gencontrol -plibcmake-init-all - dpkg --build debian/tmp .. - rm -rf debian/tmp - -.PHONY: build build-arch binary binary-arch clean libcmake-init libcmake-init-dev libcmake-init-docs libcmake-init-dbg libcmake-init-examples-data libcmake-init-examples libcmake-init-all diff --git a/deploy/ubuntu-ppa/debian/source/format b/deploy/ubuntu-ppa/debian/source/format deleted file mode 100644 index 89ae9db8..00000000 --- a/deploy/ubuntu-ppa/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (native) diff --git a/deploy/ubuntu-ppa/recipe.txt b/deploy/ubuntu-ppa/recipe.txt deleted file mode 100644 index caa0ce15..00000000 --- a/deploy/ubuntu-ppa/recipe.txt +++ /dev/null @@ -1,3 +0,0 @@ -# git-build-recipe format 0.4 deb-version {debupstream}+{revno} -lp:cmake-init -nest-part packaging lp:cmake-init deploy/ubuntu-ppa/debian debian master diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 77d223a8..00000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -FROM ubuntu:18.04 - -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - build-essential \ - cmake \ - libsdl2-dev \ - libsdl2-image-2.0-0 \ - libsdl2-image-dev \ - libsdl2-ttf-2.0-0 \ - libsdl2-ttf-dev \ - libboost-system1.65.1 \ - libboost-system1.65-dev \ - libboost-regex1.65.1 \ - libboost-regex1.65-dev \ - libboost-program-options1.65.1 \ - libboost-program-options1.65-dev \ - libboost-iostreams1.65.1 \ - libboost-iostreams1.65-dev \ - libboost-filesystem1.65.1 \ - libboost-filesystem1.65-dev \ - libprotobuf-dev \ - libprotobuf-c-dev \ - protobuf-compiler \ - protobuf-c-compiler \ - gcc-8 \ - g++-8 \ - gosu && \ - update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-8 && \ - update-alternatives --config gcc && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -WORKDIR /build - -COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh -RUN chmod +x /usr/local/bin/entrypoint.sh - -ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/docker/Readme.md b/docker/Readme.md deleted file mode 100644 index 2c0e6f24..00000000 --- a/docker/Readme.md +++ /dev/null @@ -1,27 +0,0 @@ -# MDCII docker builder image - -This image contains everything to build mdcii within a docker environment for ubuntu 18.04. - -## Precondition - -Clone the repository somewhere - - cd /projects - git clone https://github.com/siredmar/mdcii-engine - cd mdcii-engine - -## How to build the image - -Go to the projects root directory - - cd /projects/mdcii-engine - docker build --tag mdcii-builder -f docker/Dockerfile . - -## Building mdcii with the builder image - - # define the build directory and thus where to store the compiled artifacts - MDCII_OUTPUT_DIR=/tmp/mdcii - - # build it! - cd /projects/mdcii-engine - docker run --rm -it -v /projects/mdcii-engine:/source -v ${MDCII_OUTPUT_DIR}:/build siredmar/mdcii-builder bash -c "cmake -DCMAKE_BUILD_TYPE=Debug /source && make -j$(nproc)" diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh deleted file mode 100644 index ec91daae..00000000 --- a/docker/entrypoint.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -# Add non root user -# Either use the LOCAL_USER_ID if passed in at runtime or -# fallback -USER_ID=${LOCAL_USER_ID:-8000} - -echo "Starting with UID : ${USER_ID}" -useradd --shell /bin/bash -u "${USER_ID}" -o -m user -export HOME=/home/user - -mkdir -p /build -chown user:user /build - -exec gosu user "$@" diff --git a/docs/3x3.png b/docs/3x3.png new file mode 100644 index 00000000..703ecd91 Binary files /dev/null and b/docs/3x3.png differ diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt deleted file mode 100644 index 7bb7ed01..00000000 --- a/docs/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ - -# -# Target 'docs' -# - -if(NOT OPTION_BUILD_DOCS) - return() -endif() - -add_custom_target(docs) - - -# -# Documentation -# - -add_subdirectory(api-docs) -add_subdirectory(manual) diff --git a/docs/README.md b/docs/README.md index e69de29b..eef09ff3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -0,0 +1,3 @@ +# Documentation + +This folder is intended to document all those things for which doxygen comments are unsuitable. diff --git a/docs/api-docs/CMakeLists.txt b/docs/api-docs/CMakeLists.txt deleted file mode 100644 index 5aea6cb0..00000000 --- a/docs/api-docs/CMakeLists.txt +++ /dev/null @@ -1,71 +0,0 @@ - -# -# Find doxygen -# - -find_package(Doxygen) -if(NOT DOXYGEN_FOUND) - message(STATUS "Disabled generation of doxygen documentation (missing doxygen).") - return() -endif() - - -# -# Target name -# - -set(target api-docs) -message(STATUS "Doc ${target}") - - -# -# Input file -# - -set(doxyfile_in doxyfile.in) - - -# -# Create documentation -# - -# Set project variables -set(doxyfile "${CMAKE_CURRENT_BINARY_DIR}/doxyfile") -set(doxyfile_directory "${CMAKE_CURRENT_BINARY_DIR}/html") -set(doxyfile_html "${doxyfile_directory}/index.html") - -# Get filename and path of doxyfile -get_filename_component(name ${doxyfile_in} NAME) -get_filename_component(path ${doxyfile_in} PATH) -if(NOT path) - set(path ${CMAKE_CURRENT_SOURCE_DIR}) -endif() - -# Configure doxyfile (if it is a real doxyfile already, it should simply copy the file) -set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -configure_file(${doxyfile_in} ${doxyfile} @ONLY) - -# Invoke doxygen -add_custom_command( - OUTPUT ${doxyfile_html} - DEPENDS ${doxyfile} ${META_PROJECT_NAME}::baselib ${META_PROJECT_NAME}::fiblib - WORKING_DIRECTORY ${path} - COMMAND ${CMAKE_COMMAND} -E copy_directory ${path} ${doxyfile_directory} # ToDO, configure doxygen to use source as is - COMMAND ${DOXYGEN} \"${doxyfile}\" - COMMENT "Creating doxygen documentation." -) - -# Declare target -add_custom_target(${target} ALL DEPENDS ${doxyfile_html}) -add_dependencies(docs ${target}) - - -# -# Deployment -# - -install( - DIRECTORY ${doxyfile_directory} - DESTINATION ${INSTALL_DOC} - COMPONENT docs -) diff --git a/docs/api-docs/doxyfile.in b/docs/api-docs/doxyfile.in deleted file mode 100644 index 44fb2f0a..00000000 --- a/docs/api-docs/doxyfile.in +++ /dev/null @@ -1,2333 +0,0 @@ -# Doxyfile 1.8.5 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a double hash (##) is considered a comment and is placed in -# front of the TAG it is preceding. -# -# All text after a single hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists, items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (\" \"). - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all text -# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv -# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv -# for the list of possible encodings. -# The default value is: UTF-8. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by -# double-quotes, unless you are using Doxywizard) that should identify the -# project for which the documentation is generated. This name is used in the -# title of most generated pages and in a few other places. -# The default value is: My Project. - -PROJECT_NAME = @META_PROJECT_NAME@ - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. This -# could be handy for archiving the generated documentation or if some version -# control system is used. - -PROJECT_NUMBER = @META_VERSION_MAJOR@.@META_VERSION_MINOR@.@META_VERSION_PATCH@.@GIT_REV@ - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer a -# quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = "@META_PROJECT_DESCRIPTION@" - -# With the PROJECT_LOGO tag one can specify an logo or icon that is included in -# the documentation. The maximum height of the logo should not exceed 55 pixels -# and the maximum width should not exceed 200 pixels. Doxygen will copy the logo -# to the output directory. - -PROJECT_LOGO = @PROJECT_SOURCE_DIR@/cmake-init-logo.png - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path -# into which the generated documentation will be written. If a relative path is -# entered, it will be relative to the location where doxygen was started. If -# left blank the current directory will be used. - -OUTPUT_DIRECTORY = @DOXYGEN_OUTPUT_DIRECTORY@ - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub- -# directories (in 2 levels) under the output directory of each output format and -# will distribute the generated files over these directories. Enabling this -# option can be useful when feeding doxygen a huge amount of source files, where -# putting all generated files in the same directory would otherwise causes -# performance problems for the file system. -# The default value is: NO. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# Possible values are: Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese- -# Traditional, Croatian, Czech, Danish, Dutch, English, Esperanto, Farsi, -# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en, -# Korean, Korean-en, Latvian, Norwegian, Macedonian, Persian, Polish, -# Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, -# Turkish, Ukrainian and Vietnamese. -# The default value is: English. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES doxygen will include brief member -# descriptions after the members that are listed in the file and class -# documentation (similar to Javadoc). Set to NO to disable this. -# The default value is: YES. - -BRIEF_MEMBER_DESC = NO - -# If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief -# description of a member or function before the detailed description -# -# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. -# The default value is: YES. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator that is -# used to form the text in various listings. Each string in this list, if found -# as the leading text of the brief description, will be stripped from the text -# and the result, after processing the whole list, is used as the annotated -# text. Otherwise, the brief description is used as-is. If left blank, the -# following values are used ($name is automatically replaced with the name of -# the entity):The $name class, The $name widget, The $name file, is, provides, -# specifies, contains, represents, a, an and the. - -ABBREVIATE_BRIEF = "The $name class " \ - "The $name widget " \ - "The $name file " \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# doxygen will generate a detailed section even if there is only a brief -# description. -# The default value is: NO. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. -# The default value is: NO. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path -# before files name in the file list and in the header files. If set to NO the -# shortest path that makes the file name unique will be used -# The default value is: YES. - -FULL_PATH_NAMES = NO - -# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. -# Stripping is only done if one of the specified strings matches the left-hand -# part of the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the path to -# strip. -# -# Note that you can specify absolute paths here, but also relative paths, which -# will be relative from the directory where doxygen is started. -# This tag requires that the tag FULL_PATH_NAMES is set to YES. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the -# path mentioned in the documentation of a class, which tells the reader which -# header file to include in order to use a class. If left blank only the name of -# the header file containing the class definition is used. Otherwise one should -# specify the list of include paths that are normally passed to the compiler -# using the -I flag. - -STRIP_FROM_INC_PATH = ../include - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but -# less readable) file names. This can be useful is your file systems doesn't -# support long names like on DOS, Mac, or CD-ROM. -# The default value is: NO. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the -# first line (until the first dot) of a Javadoc-style comment as the brief -# description. If set to NO, the Javadoc-style will behave just like regular Qt- -# style comments (thus requiring an explicit @brief command for a brief -# description.) -# The default value is: NO. - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first -# line (until the first dot) of a Qt-style comment as the brief description. If -# set to NO, the Qt-style will behave just like regular Qt-style comments (thus -# requiring an explicit \brief command for a brief description.) -# The default value is: NO. - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a -# multi-line C++ special comment block (i.e. a block of //! or /// comments) as -# a brief description. This used to be the default behavior. The new default is -# to treat a multi-line C++ comment block as a detailed description. Set this -# tag to YES if you prefer the old behavior instead. -# -# Note that setting this tag to YES also means that rational rose comments are -# not recognized any more. -# The default value is: NO. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the -# documentation from any documented member that it re-implements. -# The default value is: YES. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a -# new page for each member. If set to NO, the documentation of a member will be -# part of the file/class/namespace that contains it. -# The default value is: NO. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen -# uses this value to replace tabs by spaces in code fragments. -# Minimum value: 1, maximum value: 16, default value: 4. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that act as commands in -# the documentation. An alias has the form: -# name=value -# For example adding -# "sideeffect=@par Side Effects:\n" -# will allow you to put the command \sideeffect (or @sideeffect) in the -# documentation, which will result in a user-defined paragraph with heading -# "Side Effects:". You can put \n's in the value part of an alias to insert -# newlines. - -ALIASES = - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding "class=itcl::class" -# will allow you to use the command class in the itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. For -# instance, some of the names that are used will be different. The list of all -# members will be omitted, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or -# Python sources only. Doxygen will then generate output that is more tailored -# for that language. For instance, namespaces will be presented as packages, -# qualified scopes will look different, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources. Doxygen will then generate output that is tailored for Fortran. -# The default value is: NO. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for VHDL. -# The default value is: NO. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given -# extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# C#, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL. For instance to make -# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C -# (default is Fortran), use: inc=Fortran f=C. -# -# Note For files without extension you can use no_extension as a placeholder. -# -# Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. - -EXTENSION_MAPPING = - -# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments -# according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you can -# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in -# case of backward compatibilities issues. -# The default value is: YES. - -MARKDOWN_SUPPORT = YES - -# When enabled doxygen tries to link words that correspond to documented -# classes, or namespaces to their corresponding documentation. Such a link can -# be prevented in individual cases by by putting a % sign in front of the word -# or globally by setting AUTOLINK_SUPPORT to NO. -# The default value is: YES. - -AUTOLINK_SUPPORT = YES - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should set this -# tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); -# versus func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. -# The default value is: NO. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. -# The default value is: NO. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen -# will parse them like normal C++ but will assume all classes use public instead -# of private inheritance when no explicit protection keyword is present. -# The default value is: NO. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate -# getter and setter methods for a property. Setting this option to YES will make -# doxygen to replace the get and set methods by a property in the documentation. -# This will only work if the methods are indeed getting or setting a simple -# type. If this is not the case, or you want to show the methods anyway, you -# should set this option to NO. -# The default value is: YES. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. -# The default value is: NO. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES to allow class member groups of the same type -# (for instance a group of public functions) to be put as a subgroup of that -# type (e.g. under the Public Functions section). Set it to NO to prevent -# subgrouping. Alternatively, this can be done per class using the -# \nosubgrouping command. -# The default value is: YES. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions -# are shown inside the group in which they are included (e.g. using \ingroup) -# instead of on a separate page (for HTML and Man pages) or section (for LaTeX -# and RTF). -# -# Note that this feature does not work in combination with -# SEPARATE_MEMBER_PAGES. -# The default value is: NO. - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions -# with only public data fields or simple typedef fields will be shown inline in -# the documentation of the scope in which they are defined (i.e. file, -# namespace, or group documentation), provided this scope is documented. If set -# to NO, structs, classes, and unions are shown on a separate page (for HTML and -# Man pages) or section (for LaTeX and RTF). -# The default value is: NO. - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or -# enum is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically be -# useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. -# The default value is: NO. - -TYPEDEF_HIDES_STRUCT = NO - -# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This -# cache is used to resolve symbols given their name and scope. Since this can be -# an expensive process and often the same symbol appears multiple times in the -# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small -# doxygen will become slower. If the cache is too large, memory is wasted. The -# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range -# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 -# symbols. At the end of a run doxygen will report the cache usage and suggest -# the optimal cache size from a speed point of view. -# Minimum value: 0, maximum value: 9, default value: 0. - -LOOKUP_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. Private -# class members and static file members will be hidden unless the -# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. -# Note: This will also disable the warnings about undocumented members that are -# normally produced when WARNINGS is set to YES. -# The default value is: NO. - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will -# be included in the documentation. -# The default value is: NO. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal -# scope will be included in the documentation. -# The default value is: NO. - -EXTRACT_PACKAGE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file will be -# included in the documentation. -# The default value is: NO. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined -# locally in source files will be included in the documentation. If set to NO -# only classes defined in header files are included. Does not have any effect -# for Java sources. -# The default value is: YES. - -EXTRACT_LOCAL_CLASSES = NO - -# This flag is only useful for Objective-C code. When set to YES local methods, -# which are defined in the implementation section but not in the interface are -# included in the documentation. If set to NO only methods in the interface are -# included. -# The default value is: NO. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base name of -# the file that contains the anonymous namespace. By default anonymous namespace -# are hidden. -# The default value is: NO. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all -# undocumented members inside documented classes or files. If set to NO these -# members will be included in the various overviews, but no documentation -# section is generated. This option has no effect if EXTRACT_ALL is enabled. -# The default value is: NO. - -HIDE_UNDOC_MEMBERS = YES - -# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. If set -# to NO these classes will be included in the various overviews. This option has -# no effect if EXTRACT_ALL is enabled. -# The default value is: NO. - -HIDE_UNDOC_CLASSES = YES - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# (class|struct|union) declarations. If set to NO these declarations will be -# included in the documentation. -# The default value is: NO. - -HIDE_FRIEND_COMPOUNDS = YES - -# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any -# documentation blocks found inside the body of a function. If set to NO these -# blocks will be appended to the function's detailed documentation block. -# The default value is: NO. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation that is typed after a -# \internal command is included. If the tag is set to NO then the documentation -# will be excluded. Set it to YES to include the internal documentation. -# The default value is: NO. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. -# The default value is: system dependent. - -CASE_SENSE_NAMES = NO - -# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with -# their full class and namespace scopes in the documentation. If set to YES the -# scope will be hidden. -# The default value is: NO. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of -# the files that are included by a file in the documentation of that file. -# The default value is: YES. - -SHOW_INCLUDE_FILES = YES - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include -# files with double quotes in the documentation rather than with sharp brackets. -# The default value is: NO. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the -# documentation for inline members. -# The default value is: YES. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the -# (detailed) documentation of file and class members alphabetically by member -# name. If set to NO the members will appear in declaration order. -# The default value is: YES. - -SORT_MEMBER_DOCS = NO - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief -# descriptions of file, namespace and class members alphabetically by member -# name. If set to NO the members will appear in declaration order. -# The default value is: NO. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the -# (brief and detailed) documentation of class members so that constructors and -# destructors are listed first. If set to NO the constructors will appear in the -# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. -# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief -# member documentation. -# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting -# detailed member documentation. -# The default value is: NO. - -SORT_MEMBERS_CTORS_1ST = YES - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy -# of group names into alphabetical order. If set to NO the group names will -# appear in their defined order. -# The default value is: NO. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by -# fully-qualified names, including namespaces. If set to NO, the class list will -# be sorted only by class name, not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the alphabetical -# list. -# The default value is: NO. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper -# type resolution of all parameters of a function it will reject a match between -# the prototype and the implementation of a member function even if there is -# only one candidate or it is obvious which candidate to choose by doing a -# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still -# accept a match between prototype and implementation in such cases. -# The default value is: NO. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable ( YES) or disable ( NO) the -# todo list. This list is created by putting \todo commands in the -# documentation. -# The default value is: YES. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable ( YES) or disable ( NO) the -# test list. This list is created by putting \test commands in the -# documentation. -# The default value is: YES. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable ( YES) or disable ( NO) the bug -# list. This list is created by putting \bug commands in the documentation. -# The default value is: YES. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable ( YES) or disable ( NO) -# the deprecated list. This list is created by putting \deprecated commands in -# the documentation. -# The default value is: YES. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional documentation -# sections, marked by \if ... \endif and \cond -# ... \endcond blocks. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the -# initial value of a variable or macro / define can have for it to appear in the -# documentation. If the initializer consists of more lines than specified here -# it will be hidden. Use a value of 0 to hide initializers completely. The -# appearance of the value of individual variables and macros / defines can be -# controlled using \showinitializer or \hideinitializer command in the -# documentation regardless of this setting. -# Minimum value: 0, maximum value: 10000, default value: 30. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at -# the bottom of the documentation of classes and structs. If set to YES the list -# will mention the files that were used to generate the documentation. -# The default value is: YES. - -SHOW_USED_FILES = YES - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This -# will remove the Files entry from the Quick Index and from the Folder Tree View -# (if specified). -# The default value is: YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces -# page. This will remove the Namespaces entry from the Quick Index and from the -# Folder Tree View (if specified). -# The default value is: YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command command input-file, where command is the value of the -# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided -# by doxygen. Whatever the program writes to standard output is used as the file -# version. For an example see the documentation. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. You can -# optionally specify a file name after the option, if omitted DoxygenLayout.xml -# will be used as the name of the layout file. -# -# Note that if you run doxygen from a directory containing a file called -# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE -# tag is left empty. - -LAYOUT_FILE = - -# The CITE_BIB_FILES tag can be used to specify one or more bib files containing -# the reference definitions. This must be a list of .bib files. The .bib -# extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. -# For LaTeX the style of the bibliography can be controlled using -# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the -# search path. Do not use file names with spaces, bibtex cannot handle them. See -# also \cite for info how to create references. - -CITE_BIB_FILES = - -#--------------------------------------------------------------------------- -# Configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated to -# standard output by doxygen. If QUIET is set to YES this implies that the -# messages are off. -# The default value is: NO. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES -# this implies that the warnings are on. -# -# Tip: Turn warnings on while writing the documentation. -# The default value is: YES. - -WARNINGS = YES - -# If the WARN_IF_UNDOCUMENTED tag is set to YES, then doxygen will generate -# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag -# will automatically be disabled. -# The default value is: YES. - -WARN_IF_UNDOCUMENTED = YES - -# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some parameters -# in a documented function, or documenting parameters that don't exist or using -# markup commands wrongly. -# The default value is: YES. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that -# are documented, but have no documentation for their parameters or return -# value. If set to NO doxygen will only warn about wrong or incomplete parameter -# documentation, but not about the absence of documentation. -# The default value is: NO. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that doxygen -# can produce. The string should contain the $file, $line, and $text tags, which -# will be replaced by the file and line number from which the warning originated -# and the warning text. Optionally the format may contain $version, which will -# be replaced by the version of the file (if it could be obtained via -# FILE_VERSION_FILTER) -# The default value is: $file:$line: $text. - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning and error -# messages should be written. If left blank the output is written to standard -# error (stderr). - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# Configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag is used to specify the files and/or directories that contain -# documented source files. You may enter file names like myfile.cpp or -# directories like /usr/src/myproject. Separate the files or directories with -# spaces. -# Note: If this tag is empty the current directory is searched. - -INPUT = @PROJECT_SOURCE_DIR@/source/baselib/include \ - @PROJECT_SOURCE_DIR@/source/fiblib/include - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses -# libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: http://www.gnu.org/software/libiconv) for the list of -# possible encodings. -# The default value is: UTF-8. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and -# *.h) to filter out the source-files in the directories. If left blank the -# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii, -# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp, -# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown, -# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, -# *.qsf, *.as and *.js. - -FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.c++ \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.idl \ - *.odl \ - *.cs \ - *.php \ - *.php3 \ - *.inc \ - *.m \ - *.mm \ - *.dox - -# The RECURSIVE tag can be used to specify whether or not subdirectories should -# be searched for input files as well. -# The default value is: NO. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. -# The default value is: NO. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories use the pattern */test/* - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or directories -# that contain example code fragments that are included (see the \include -# command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and -# *.h) to filter out the source-files in the directories. If left blank all -# files are included. - -EXAMPLE_PATTERNS = * - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude commands -# irrespective of the value of the RECURSIVE tag. -# The default value is: NO. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or directories -# that contain images that are to be included in the documentation (see the -# \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command: -# -# -# -# where is the value of the INPUT_FILTER tag, and is the -# name of an input file. Doxygen will then use the output that the filter -# program writes to standard output. If FILTER_PATTERNS is specified, this tag -# will be ignored. -# -# Note that the filter must not add or remove lines; it is applied before the -# code is scanned, but not when the output code is generated. If lines are added -# or removed, the anchors will not be placed correctly. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: pattern=filter -# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how -# filters are used. If the FILTER_PATTERNS tag is empty or if none of the -# patterns match the file name, INPUT_FILTER is applied. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER ) will also be used to filter the input files that are used for -# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). -# The default value is: NO. - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and -# it is also possible to disable source filtering for a specific pattern using -# *.ext= (so without naming a filter). -# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. - -FILTER_SOURCE_PATTERNS = - -# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that -# is part of the input, its contents will be placed on the main page -# (index.html). This can be useful if you have a project on for instance GitHub -# and want to reuse the introduction page also for the doxygen output. - -USE_MDFILE_AS_MAINPAGE = - -#--------------------------------------------------------------------------- -# Configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will be -# generated. Documented entities will be cross-referenced with these sources. -# -# Note: To get rid of all source code in the generated output, make sure that -# also VERBATIM_HEADERS is set to NO. -# The default value is: NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body of functions, -# classes and enums directly into the documentation. -# The default value is: NO. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any -# special comment blocks from generated source code fragments. Normal C, C++ and -# Fortran comments will always remain visible. -# The default value is: YES. - -STRIP_CODE_COMMENTS = NO - -# If the REFERENCED_BY_RELATION tag is set to YES then for each documented -# function all documented functions referencing it will be listed. -# The default value is: NO. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES then for each documented function -# all documented entities called/used by that function will be listed. -# The default value is: NO. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set -# to YES, then the hyperlinks from functions in REFERENCES_RELATION and -# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will -# link to the documentation. -# The default value is: YES. - -REFERENCES_LINK_SOURCE = YES - -# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the -# source code will show a tooltip with additional information such as prototype, -# brief description and links to the definition and documentation. Since this -# will make the HTML file larger and loading of large files a bit slower, you -# can opt to disable this feature. -# The default value is: YES. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -SOURCE_TOOLTIPS = YES - -# If the USE_HTAGS tag is set to YES then the references to source code will -# point to the HTML generated by the htags(1) tool instead of doxygen built-in -# source browser. The htags tool is part of GNU's global source tagging system -# (see http://www.gnu.org/software/global/global.html). You will need version -# 4.8.6 or higher. -# -# To use it do the following: -# - Install the latest version of global -# - Enable SOURCE_BROWSER and USE_HTAGS in the config file -# - Make sure the INPUT points to the root of the source tree -# - Run doxygen as normal -# -# Doxygen will invoke htags (and that will in turn invoke gtags), so these -# tools must be available from the command line (i.e. in the search path). -# -# The result: instead of the source browser generated by doxygen, the links to -# source code will now point to the output of htags. -# The default value is: NO. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a -# verbatim copy of the header file for each class for which an include is -# specified. Set to NO to disable this. -# See also: Section \class. -# The default value is: YES. - -VERBATIM_HEADERS = YES - -# If the CLANG_ASSISTED_PARSING tag is set to YES, then doxygen will use the -# clang parser (see: http://clang.llvm.org/) for more acurate parsing at the -# cost of reduced performance. This can be particularly helpful with template -# rich C++ code for which doxygen's built-in parser lacks the necessary type -# information. -# Note: The availability of this option depends on whether or not doxygen was -# compiled with the --with-libclang option. -# The default value is: NO. - -CLANG_ASSISTED_PARSING = NO - -# If clang assisted parsing is enabled you can provide the compiler with command -# line options that you would normally use when invoking the compiler. Note that -# the include paths will already be set by doxygen for the files and directories -# specified with INPUT and INCLUDE_PATH. -# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. - -CLANG_OPTIONS = - -#--------------------------------------------------------------------------- -# Configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all -# compounds will be generated. Enable this if the project contains a lot of -# classes, structs, unions or interfaces. -# The default value is: YES. - -ALPHABETICAL_INDEX = YES - -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all classes will -# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag -# can be used to specify a prefix (or a list of prefixes) that should be ignored -# while generating the index headers. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES doxygen will generate HTML output -# The default value is: YES. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a -# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of -# it. -# The default directory is: html. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each -# generated HTML page (for example: .htm, .php, .asp). -# The default value is: .html. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a user-defined HTML header file for -# each generated HTML page. If the tag is left blank doxygen will generate a -# standard header. -# -# To get valid HTML the header file that includes any scripts and style sheets -# that doxygen needs, which is dependent on the configuration options used (e.g. -# the setting GENERATE_TREEVIEW). It is highly recommended to start with a -# default header using -# doxygen -w html new_header.html new_footer.html new_stylesheet.css -# YourConfigFile -# and then modify the file new_header.html. See also section "Doxygen usage" -# for information on how to generate the default header that doxygen normally -# uses. -# Note: The header is subject to change so you typically have to regenerate the -# default header when upgrading to a newer version of doxygen. For a description -# of the possible markers and block names see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each -# generated HTML page. If the tag is left blank doxygen will generate a standard -# footer. See HTML_HEADER for more information on how to generate a default -# footer and what special commands can be used inside the footer. See also -# section "Doxygen usage" for information on how to generate the default footer -# that doxygen normally uses. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style -# sheet that is used by each HTML page. It can be used to fine-tune the look of -# the HTML output. If left blank doxygen will generate a default style sheet. -# See also section "Doxygen usage" for information on how to generate the style -# sheet that doxygen normally uses. -# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as -# it is more robust and this tag (HTML_STYLESHEET) will in the future become -# obsolete. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_STYLESHEET = - -# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional user- -# defined cascading style sheet that is included after the standard style sheets -# created by doxygen. Using this option one can overrule certain style aspects. -# This is preferred over using HTML_STYLESHEET since it does not replace the -# standard style sheet and is therefor more robust against future updates. -# Doxygen will copy the style sheet file to the output directory. For an example -# see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_STYLESHEET = - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that the -# files will be copied as-is; there are no commands or markers available. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen -# will adjust the colors in the stylesheet and background images according to -# this color. Hue is specified as an angle on a colorwheel, see -# http://en.wikipedia.org/wiki/Hue for more information. For instance the value -# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 -# purple, and 360 is red again. -# Minimum value: 0, maximum value: 359, default value: 220. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors -# in the HTML output. For a value of 0 the output will use grayscales only. A -# value of 255 will produce the most vivid colors. -# Minimum value: 0, maximum value: 255, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the -# luminance component of the colors in the HTML output. Values below 100 -# gradually make the output lighter, whereas values above 100 make the output -# darker. The value divided by 100 is the actual gamma applied, so 80 represents -# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not -# change the gamma. -# Minimum value: 40, maximum value: 240, default value: 80. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting this -# to NO can help when comparing the output of multiple runs. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_TIMESTAMP = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_DYNAMIC_SECTIONS = YES - -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries -# shown in the various tree structured indices initially; the user can expand -# and collapse entries dynamically later on. Doxygen will expand the tree to -# such a level that at most the specified number of entries are visible (unless -# a fully collapsed tree already exceeds this amount). So setting the number of -# entries 1 will produce a full collapsed tree by default. 0 is a special value -# representing an infinite number of entries and will result in a full expanded -# tree by default. -# Minimum value: 0, maximum value: 9999, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_INDEX_NUM_ENTRIES = 100 - -# If the GENERATE_DOCSET tag is set to YES, additional index files will be -# generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: http://developer.apple.com/tools/xcode/), introduced with -# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a -# Makefile in the HTML output directory. Running make will produce the docset in -# that directory and running make install will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_DOCSET = NO - -# This tag determines the name of the docset feed. A documentation feed provides -# an umbrella under which multiple documentation sets from a single provider -# (such as a company or product suite) can be grouped. -# The default value is: Doxygen generated docs. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# This tag specifies a string that should uniquely identify the documentation -# set bundle. This should be a reverse domain-name style string, e.g. -# com.mycompany.MyDocSet. Doxygen will append .docset to the name. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style -# string, e.g. com.mycompany.MyDocSet.documentation. -# The default value is: org.doxygen.Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. -# The default value is: Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three -# additional HTML index files: index.hhp, index.hhc, and index.hhk. The -# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on -# Windows. -# -# The HTML Help Workshop contains a compiler that can convert all HTML output -# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML -# files are now used as the Windows 98 help format, and will replace the old -# Windows help format (.hlp) on all Windows platforms in the future. Compressed -# HTML files also contain an index, a table of contents, and you can search for -# words in the documentation. The HTML workshop also contains a viewer for -# compressed HTML files. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_HTMLHELP = NO - -# The CHM_FILE tag can be used to specify the file name of the resulting .chm -# file. You can add a path in front of the file if the result should not be -# written to the html output directory. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -CHM_FILE = @META_PROJECT_ID@.chm - -# The HHC_LOCATION tag can be used to specify the location (absolute path -# including file name) of the HTML help compiler ( hhc.exe). If non-empty -# doxygen will try to run the HTML help compiler on the generated index.hhp. -# The file has to be specified with full path. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -HHC_LOCATION = - -# The GENERATE_CHI flag controls if a separate .chi index file is generated ( -# YES) or that it should be included in the master .chm file ( NO). -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -GENERATE_CHI = NO - -# The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc) -# and project file content. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -CHM_INDEX_ENCODING = - -# The BINARY_TOC flag controls whether a binary table of contents is generated ( -# YES) or a normal table of contents ( NO) in the .chm file. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members to -# the table of contents of the HTML help documentation and to the tree view. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that -# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help -# (.qch) of the generated HTML documentation. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify -# the file name of the resulting .qch file. The path specified is relative to -# the HTML output folder. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help -# Project output. For more information please see Qt Help Project / Namespace -# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt -# Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- -# folders). -# The default value is: doc. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_VIRTUAL_FOLDER = doc - -# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom -# filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's filter section matches. Qt Help Project / Filter Attributes (see: -# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_SECT_FILTER_ATTRS = - -# The QHG_LOCATION tag can be used to specify the location of Qt's -# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the -# generated .qhp file. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be -# generated, together with the HTML files, they form an Eclipse help plugin. To -# install this plugin and make it available under the help contents menu in -# Eclipse, the contents of the directory containing the HTML and XML files needs -# to be copied into the plugins directory of eclipse. The name of the directory -# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. -# After copying Eclipse needs to be restarted before the help appears. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the Eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have this -# name. Each documentation set should have its own identifier. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# If you want full control over the layout of the generated HTML pages it might -# be necessary to disable the index and replace it with your own. The -# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top -# of each HTML page. A value of NO enables the index and the value YES disables -# it. Since the tabs in the index contain the same information as the navigation -# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -DISABLE_INDEX = NO - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. If the tag -# value is set to YES, a side panel will be generated containing a tree-like -# index structure (just like the one that is generated for HTML Help). For this -# to work a browser that supports JavaScript, DHTML, CSS and frames is required -# (i.e. any modern browser). Windows users are probably better off using the -# HTML help feature. Via custom stylesheets (see HTML_EXTRA_STYLESHEET) one can -# further fine-tune the look of the index. As an example, the default style -# sheet generated by doxygen has an example that shows how to put an image at -# the root of the tree instead of the PROJECT_NAME. Since the tree basically has -# the same information as the tab index, you could consider setting -# DISABLE_INDEX to YES when enabling this option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_TREEVIEW = NO - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that -# doxygen will group on one line in the generated HTML documentation. -# -# Note that a value of 0 will completely suppress the enum values from appearing -# in the overview section. -# Minimum value: 0, maximum value: 20, default value: 4. -# This tag requires that the tag GENERATE_HTML is set to YES. - -ENUM_VALUES_PER_LINE = 4 - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used -# to set the initial width (in pixels) of the frame in which the tree is shown. -# Minimum value: 0, maximum value: 1500, default value: 250. -# This tag requires that the tag GENERATE_HTML is set to YES. - -TREEVIEW_WIDTH = 250 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open links to -# external symbols imported via tag files in a separate window. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of LaTeX formulas included as images in -# the HTML documentation. When you change the font size after a successful -# doxygen run you need to manually remove any form_*.png images from the HTML -# output directory to force them to be regenerated. -# Minimum value: 8, maximum value: 50, default value: 10. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are not -# supported properly for IE 6.0, but are supported on all modern browsers. -# -# Note that when changing this option you need to delete any form_*.png files in -# the HTML output directory before the changes have effect. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# http://www.mathjax.org) which uses client side Javascript for the rendering -# instead of using prerendered bitmaps. Use this if you do not have LaTeX -# installed or if you want to formulas look prettier in the HTML output. When -# enabled you may also need to install MathJax separately and configure the path -# to it using the MATHJAX_RELPATH option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -USE_MATHJAX = NO - -# When MathJax is enabled you can set the default output format to be used for -# the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. -# Possible values are: HTML-CSS (which is slower, but has the best -# compatibility), NativeMML (i.e. MathML) and SVG. -# The default value is: HTML-CSS. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_FORMAT = HTML-CSS - -# When MathJax is enabled you need to specify the location relative to the HTML -# output directory using the MATHJAX_RELPATH option. The destination directory -# should contain the MathJax.js script. For instance, if the mathjax directory -# is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax -# Content Delivery Network so you can quickly see the result without installing -# MathJax. However, it is strongly recommended to install a local copy of -# MathJax from http://www.mathjax.org before deployment. -# The default value is: http://cdn.mathjax.org/mathjax/latest. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_RELPATH = http://www.mathjax.org/mathjax - -# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax -# extension names that should be enabled during MathJax rendering. For example -# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_EXTENSIONS = - -# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces -# of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an -# example see the documentation. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_CODEFILE = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box for -# the HTML output. The underlying search engine uses javascript and DHTML and -# should work on any modern browser. Note that when using HTML help -# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) -# there is already a search function so this one should typically be disabled. -# For large projects the javascript based search engine can be slow, then -# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to -# search using the keyboard; to jump to the search box use + S -# (what the is depends on the OS and browser, but it is typically -# , /