diff --git a/.github/workflows/build-mys2.yml b/.github/workflows/build-mys2.yml deleted file mode 100644 index fabf7287..00000000 --- a/.github/workflows/build-mys2.yml +++ /dev/null @@ -1,142 +0,0 @@ -name: Build Modshot with MSYS2 -on: push -jobs: - build-windows: - name: Build ModShot for Windows - runs-on: windows-2019 - env: - CONAN_USER_HOME: C:\.conan - CONAN_USER_HOME_SHORT: C:\.conan - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Install conan and xxd - run: choco install -y vim; pip install conan - - name: Set path to include xxd - shell: bash - run: 'echo "C:\tools\vim\vim82" >> $GITHUB_PATH' - - name: Add Windows SDK to path - shell: bash - run: 'echo "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64" >> $GITHUB_PATH' - - name: Configure conan - run: | - conan remote add eliza https://rkevin.jfrog.io/artifactory/api/conan/eliza; - conan remote add bincrafters https://bincrafters.jfrog.io/artifactory/api/conan/public-conan; - conan remote add astrabit https://rkevin.jfrog.io/artifactory/api/conan/astrabit; - conan config set general.revisions_enabled=1; - conan config get; - setx CONAN_USE_ALWAYS_SHORT_PATHS 1; - setx CONAN_BASH_PATH C:\msys64\usr\bin\bash.exe; - mkdir ${{ runner.temp }}\build - - name: Configure profile - run: | - conan profile new msys2 --detect; - conan profile update settings.compiler=gcc msys2; - conan profile update settings.compiler.version=8.1 msys2; - conan profile update settings.compiler.libcxx=libstdc++11 msys2; - conan profile update settings.compiler.exception=seh msys2; - conan profile update settings.compiler.threads=posix msys2; - - name: Setup global.conf - run: | - echo tools.microsoft.bash:subsystem=msys2 >> C:\.conan\.conan\global.conf; - echo tools.microsoft.bash:path=C:\msys64\usr\bin\bash.exe >> C:\.conan\.conan\global.conf; - - name: Install msys2 and mingw - run: | - conan install mingw_installer/1.0@conan/stable --profile=msys2; - conan install msys2/cci.latest@ --profile=msys2 - - name: Install gems - run: | - gem install pathname - - name: Append to msys2 profile - run: | - echo [build_requires] >> C:\.conan\.conan\profiles\msys2; - echo mingw_installer/1.0@conan/stable >> C:\.conan\.conan\profiles\msys2; - echo msys2/cci.latest@ >> C:\.conan\.conan\profiles\msys2 - - name: Setup path in msys2 - run: | - echo 'export PATH="$PATH:C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64"' >> C:\msys64\home\runneradmin\.bashrc; - echo 'export PATH="$PATH:C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64"' >> C:\msys64\home\packer\.bashrc; - type C:\msys64\home\packer\.bashrc - - name: Cache conan dependenciesa - uses: actions/cache@v2 - with: - path: C:\.conan - key: ${{ runner.os }}-cached-conan-modules-${{ hashFiles('conanfile.py') }} - - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.6 - - name: where check - run: | - # show where - Write-Host - $where = 'gcc.exe', 'ragel.exe', 'make.exe', 'bison.exe', 'libcrypto-1_1-x64.dll', 'libssl-1_1-x64.dll' - foreach ($e in $where) { - $rslt = where.exe $e 2>&1 | Out-String - if ($rslt.contains($e)) { Write-Host $rslt } - else { Write-Host "`nCan't find $e" } - } - - name: Build dependencies using conan - run: conan install ${{ github.workspace }} --build=missing -o msys2=True --profile=msys2 - working-directory: ${{ runner.temp }}\build - - name: Build ModShot - run: conan build ${{ github.workspace }} - working-directory: ${{ runner.temp }}\build - - name: Create dist folder - run: | - mkdir ${{ runner.temp }}\built_artifact; - move ${{ runner.temp }}\build\bin\lib ${{ runner.temp }}\built_artifact\lib; - move ${{ runner.temp }}\build\bin\* ${{ runner.temp }}\built_artifact\lib; - move ${{ runner.temp }}\built_artifact\lib\oneshot-shim.exe ${{ runner.temp }}\built_artifact\oneshot.exe - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: modshot_build_windows_${{ github.sha }} - path: ${{ runner.temp }}\built_artifact - build-windows-steam: - name: Build ModShot for Windows (Steam support) - runs-on: windows-2019 - env: - CONAN_USER_HOME: C:\.conan - CONAN_USER_HOME_SHORT: C:\.conan - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Install conan and xxd - run: choco install -y vim; pip install conan - - name: Set path to include xxd - run: '[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\tools\vim\vim82", "Machine")' - - name: Configure conan - run: | - conan remote add eliza https://rkevin.jfrog.io/artifactory/api/conan/eliza; - conan remote add bincrafters https://bincrafters.jfrog.io/artifactory/api/conan/public-conan; - conan remote add astrabit https://rkevin.jfrog.io/artifactory/api/conan/astrabit; - conan config set general.revisions_enabled=1; - setx CONAN_USE_ALWAYS_SHORT_PATHS 1; - mkdir ${{ runner.temp }}\build - - name: Configure profile - run: | - conan profile new default --detect; - conan profile update settings.compiler=gcc default; - conan profile update settings.compiler.version=8.1 default; - conan profile update settings.compiler.libcxx=libstdc++11 default - - name: Cache conan dependencies - uses: actions/cache@v2 - with: - path: C:\.conan - key: ${{ runner.os }}-cached-conan-modules-${{ hashFiles('conanfile.py') }}-steam - - name: Build dependencies using conan - run: conan install ${{ github.workspace }} --build=missing -o platform=steam -o msys2=True - working-directory: ${{ runner.temp }}\build - - name: Build ModShot - run: conan build ${{ github.workspace }} - working-directory: ${{ runner.temp }}\build - - name: Create dist folder - run: | - mkdir ${{ runner.temp }}\built_artifact; - move ${{ runner.temp }}\build\bin\lib ${{ runner.temp }}\built_artifact\lib; - move ${{ runner.temp }}\build\bin\* ${{ runner.temp }}\built_artifact\lib; - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: modshot_build_steam_windows_${{ github.sha }} - path: ${{ runner.temp }}\built_artifact diff --git a/.github/workflows/build-standalone.yaml b/.github/workflows/build-standalone.yaml deleted file mode 100644 index 5a1aee92..00000000 --- a/.github/workflows/build-standalone.yaml +++ /dev/null @@ -1,91 +0,0 @@ -name: Build Modshot -on: push -jobs: - build-windows: - name: Build ModShot for Windows - runs-on: windows-2019 - env: - CONAN_USER_HOME: C:\.conan - CONAN_USER_HOME_SHORT: C:\.conan - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Install conan and xxd - run: choco install -y vim; pip install conan - - name: Set path to include xxd - run: '[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\tools\vim\vim82", "Machine")' - - name: Configure conan - run: | - conan remote add eliza https://rkevin.jfrog.io/artifactory/api/conan/eliza; - conan remote add bincrafters https://bincrafters.jfrog.io/artifactory/api/conan/public-conan; - conan remote add astrabit https://rkevin.jfrog.io/artifactory/api/conan/astrabit; - conan config set general.revisions_enabled=1; - setx CONAN_USE_ALWAYS_SHORT_PATHS 1; - mkdir ${{ runner.temp }}\build - - name: Cache conan dependencies - uses: actions/cache@v2 - with: - path: C:\.conan - key: ${{ runner.os }}-cached-conan-modules-${{ hashFiles('conanfile.py') }} - - name: Build dependencies using conan - run: conan install ${{ github.workspace }} --build=missing - working-directory: ${{ runner.temp }}\build - - name: Build ModShot - run: conan build ${{ github.workspace }} - working-directory: ${{ runner.temp }}\build - - name: Create dist folder - run: | - mkdir ${{ runner.temp }}\built_artifact; - move ${{ runner.temp }}\build\bin\lib ${{ runner.temp }}\built_artifact\lib; - move ${{ runner.temp }}\build\bin\* ${{ runner.temp }}\built_artifact\lib; - move ${{ runner.temp }}\built_artifact\lib\oneshot-shim.exe ${{ runner.temp }}\built_artifact\oneshot.exe - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: modshot_build_windows_${{ github.sha }} - path: ${{ runner.temp }}\built_artifact - build-linux: - name: Build ModShot for Linux - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Install dependencies - run: | - sudo apt-get update - sudo DEBIAN_FRONTEND=noninteractive apt install -y \ - libgtk2.0-dev libxfconf-0-dev libwmf0.2-7-gtk libegl1-mesa-dev libgbm-dev libasound2-dev libjack-dev libpulse-dev libaudio-dev patchelf && - sudo curl -Lo /usr/local/bin/linuxdeploy-x86_64.AppImage https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage && - sudo chmod +x /usr/local/bin/linuxdeploy-x86_64.AppImage - - name: Setup Python - uses: actions/setup-python@v2 - - name: Install and configure conan - run: | - pip3 install conan - conan remote add eliza https://rkevin.jfrog.io/artifactory/api/conan/eliza; - conan remote add bincrafters https://bincrafters.jfrog.io/artifactory/api/conan/public-conan; - conan remote add astrabit https://rkevin.jfrog.io/artifactory/api/conan/astrabit; - conan config set general.revisions_enabled=1; - mkdir ${{ runner.temp }}/build - - name: Cache conan dependencies - uses: actions/cache@v2 - with: - path: ~/.conan - key: ${{ runner.os }}-cached-conan-modules-${{ hashFiles('conanfile.py') }} - - name: Build dependencies using conan - run: conan install ${{ github.workspace }} --build=missing - working-directory: ${{ runner.temp }}/build - - name: Build ModShot - run: conan build ${{ github.workspace }} - working-directory: ${{ runner.temp }}/build - - name: Create dist folder - run: | - mkdir ${{ runner.temp }}/dist && - ${{ github.workspace }}/scripts/shell/make-linux-dist.sh ${{ runner.temp }}/build ${{ runner.temp }}/dist && - cd ${{ runner.temp }}/dist && - tar czf ${{ runner.temp }}/modshot_${{ github.sha }}.tar.gz . - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: modshot_build_linux_${{ github.sha }} - path: ${{ runner.temp }}/modshot_${{ github.sha }}.tar.gz diff --git a/.github/workflows/build-steam.yaml b/.github/workflows/build-steam.yaml deleted file mode 100644 index 0f177a49..00000000 --- a/.github/workflows/build-steam.yaml +++ /dev/null @@ -1,91 +0,0 @@ -name: Build Modshot with Steam support -on: push -jobs: - build-windows: - name: Build ModShot for Windows (Steam support) - runs-on: windows-2019 - env: - CONAN_USER_HOME: C:\.conan - CONAN_USER_HOME_SHORT: C:\.conan - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Install conan and xxd - run: choco install -y vim; pip install conan - - name: Set path to include xxd - run: '[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\tools\vim\vim82", "Machine")' - - name: Configure conan - run: | - conan remote add eliza https://rkevin.jfrog.io/artifactory/api/conan/eliza; - conan remote add bincrafters https://bincrafters.jfrog.io/artifactory/api/conan/public-conan; - conan remote add astrabit https://rkevin.jfrog.io/artifactory/api/conan/astrabit; - conan config set general.revisions_enabled=1; - setx CONAN_USE_ALWAYS_SHORT_PATHS 1; - mkdir ${{ runner.temp }}\build - - name: Cache conan dependencies - uses: actions/cache@v2 - with: - path: C:\.conan - key: ${{ runner.os }}-cached-conan-modules-${{ hashFiles('conanfile.py') }}-steam - - name: Build dependencies using conan - run: conan install ${{ github.workspace }} --build=missing -o platform=steam - working-directory: ${{ runner.temp }}\build - - name: Build ModShot - run: conan build ${{ github.workspace }} - working-directory: ${{ runner.temp }}\build - - name: Create dist folder - run: | - mkdir ${{ runner.temp }}\built_artifact; - move ${{ runner.temp }}\build\bin\lib ${{ runner.temp }}\built_artifact\lib; - move ${{ runner.temp }}\build\bin\* ${{ runner.temp }}\built_artifact\lib; - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: modshot_build_steam_windows_${{ github.sha }} - path: ${{ runner.temp }}\built_artifact - build-linux: - name: Build ModShot for Linux (Steam support) - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Install dependencies - run: | - sudo apt-get update - sudo DEBIAN_FRONTEND=noninteractive apt install -y \ - libgtk2.0-dev libxfconf-0-dev libwmf0.2-7-gtk libegl1-mesa-dev libgbm-dev libasound2-dev libjack-dev libpulse-dev libaudio-dev patchelf && - sudo curl -Lo /usr/local/bin/linuxdeploy-x86_64.AppImage https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage && - sudo chmod +x /usr/local/bin/linuxdeploy-x86_64.AppImage - - name: Setup Python - uses: actions/setup-python@v2 - - name: Install and configure conan - run: | - pip3 install conan - conan remote add eliza https://rkevin.jfrog.io/artifactory/api/conan/eliza; - conan remote add bincrafters https://bincrafters.jfrog.io/artifactory/api/conan/public-conan; - conan remote add astrabit https://rkevin.jfrog.io/artifactory/api/conan/astrabit; - conan config set general.revisions_enabled=1; - mkdir ${{ runner.temp }}/build - - name: Cache conan dependencies - uses: actions/cache@v2 - with: - path: ~/.conan - key: ${{ runner.os }}-cached-conan-modules-${{ hashFiles('conanfile.py') }}-steam - - name: Build dependencies using conan - run: conan install ${{ github.workspace }} --build=missing -o platform=steam - working-directory: ${{ runner.temp }}/build - - name: Build ModShot - run: conan build ${{ github.workspace }} - working-directory: ${{ runner.temp }}/build - - name: Create dist folder - run: | - mkdir ${{ runner.temp }}/dist && - ${{ github.workspace }}/scripts/shell/make-linux-dist.sh ${{ runner.temp }}/build ${{ runner.temp }}/dist && - cd ${{ runner.temp }}/dist && - rm oneshot && - tar czf ${{ runner.temp }}/modshot_${{ github.sha }}.tar.gz . - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: modshot_build_steam_linux_${{ github.sha }} - path: ${{ runner.temp }}/modshot_${{ github.sha }}.tar.gz diff --git a/.github/workflows/build-ubuntu.yml b/.github/workflows/build-ubuntu.yml new file mode 100644 index 00000000..0a2b6283 --- /dev/null +++ b/.github/workflows/build-ubuntu.yml @@ -0,0 +1,35 @@ +name: Build ModShot Ubuntu +on: workflow_dispatch +jobs: + build-ubuntu: + name: Build ModShot for Linux + runs-on: ubuntu-latest + strategy: + matrix: + ruby_ver: ['3.1', '3.0', '2.7'] + steam: [true, false] + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + - name: Build + working-directory: ${{ github.workspace }} + run: | + bash setup.sh + pip3 install meson ninja + cd linux + make RUBY_VER=${{ matrix.ruby_ver }} + source vars.sh + cd .. + meson build -Dmri_version=${{ matrix.ruby_ver }} --prefix=$PWD/out/ -Dsteam=${{ matrix.steam }} + cd build && ninja install + - name: Create dist folder + run: | + mkdir ${{ runner.temp }}/built_artifact; + mv ${{ github.workspace }}/out/* ${{ runner.temp }}/built_artifact/; + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: modshot_build_ubuntu_rb-${{ matrix.ruby_ver }}_steam-${{ matrix.steam }} + path: ${{ runner.temp }}/built_artifact diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml new file mode 100644 index 00000000..9d894d11 --- /dev/null +++ b/.github/workflows/build-windows.yml @@ -0,0 +1,50 @@ +name: Build ModShot Windows +on: workflow_dispatch +jobs: + build-windows: + name: Build ModShot for Windows + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + ruby_ver: ['3.0', '2.7'] + sys: ['mingw64'] + steam: [true, false] + include: + - sys: 'ucrt64' + ruby_ver: '3.1' + steam: true + - sys: 'ucrt64' + ruby_ver: '3.1' + steam: false + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Setup msys2 + uses: msys2/setup-msys2@v2 + with: + msystem: ${{matrix.sys}} + - name: Install packages with pacman + shell: msys2 {0} + run: | + pacman -S --noconfirm mm-common autoconf automake gcc make cmake libtool + - name: Build + working-directory: ${{ github.workspace }} + shell: msys2 {0} + run: | + bash setup.sh + cd windows + make RUBY_VER=${{ matrix.ruby_ver }} + source vars.sh + cd .. + meson build -Dmri_version=${{ matrix.ruby_ver }} --prefix=$PWD/out/ -Dsteam=${{ matrix.steam }} + cd build && ninja install + - name: Create dist folder + run: | + mkdir ${{ runner.temp }}\built_artifact; + move ${{ github.workspace }}\out\* ${{ runner.temp }}\built_artifact\; + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: modshot_build_windows_rb-${{ matrix.ruby_ver }}-${{ matrix.sys }}_steam-${{ matrix.steam }} + path: ${{ runner.temp }}\built_artifact \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2a8cee6e..24274dc3 100644 --- a/.gitignore +++ b/.gitignore @@ -20,13 +20,12 @@ lib/ *.dir/ x64/ -Makefile* - /oneshot /steamshim_parent/steamshim __pycache__ /build* +/m32build /dist /debug /release @@ -56,11 +55,8 @@ steamworks/ assets/icon.ico assets/icon.ico -src/version.h - !build-entrypoint-linux.sh !build-entrypoint-windows.bat .vscode -conan.lock -graph_info.json +out/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 6642a66e..dbe6ceb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,24 +1,47 @@ cmake_minimum_required(VERSION 2.8.11) -Project(oneshot) +Project(modshot) -#set(CONAN_DISABLE_CHECK_COMPILER ON) +option(STEAM "Build for Steam" OFF) +option(DEBUG "Debug mode" OFF) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_BUILD_RPATH "lib") -## Setup options ## +IF("${CMAKE_SYSTEM}" MATCHES "Linux") + SET(LINUX ON) +ENDIF() -# Note this option only adds steamshim_child into oneshot. -# It's outside this repo's responsibility to compile the parent. -# Contact rkevin for details. -option(STEAM "Build for Steam" OFF) -option(DEBUG "Debug mode" OFF) +IF(WORKDIR_CURRENT) + list(APPEND DEFINES + WORKDIR_CURRENT + ) +ENDIF() -## Misc setup ## +set(CMAKE_SKIP_BUILD_RPATH TRUE) +set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) +set(CMAKE_INSTALL_RPATH ${BIN_RPATH}) +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(MRI_VERSION "3.1" CACHE STRING "Version of MRI to link with") + +find_package(PkgConfig REQUIRED) + +pkg_check_modules(SIGCXX REQUIRED sigc++-2.0) +pkg_check_modules(PIXMAN REQUIRED pixman-1) +pkg_check_modules(PHYSFS REQUIRED physfs>=2.1) +pkg_check_modules(VORBISFILE REQUIRED vorbisfile) +pkg_check_modules(SDL2 REQUIRED sdl2) +pkg_check_modules(SDL2_TTF REQUIRED SDL2_ttf) +pkg_check_modules(SDL2_IMAGE REQUIRED SDL2_image) +pkg_check_modules(SDL_SOUND REQUIRED SDL_sound) +pkg_check_modules(MRI REQUIRED ruby-3.1) +pkg_check_modules(OGG REQUIRED ogg) +pkg_check_modules(SPEEX REQUIRED speex) +pkg_check_modules(MODPLUG REQUIRED libmodplug) -## Setup main source ## +find_package(Boost 1.49 COMPONENTS program_options REQUIRED) +find_package(OpenAL REQUIRED) +find_package(ZLIB REQUIRED) set(SRC_AUDIO_HEADER_PATH src/audio/headers) set(SRC_GRAPHICS_HEADER_PATH src/graphics/headers) @@ -83,6 +106,7 @@ set(MAIN_HEADERS ${SRC_FS_HEADER_PATH}/filesystem.h ${SRC_FS_HEADER_PATH}/rgssad.h + src/display.h src/binding.h src/etc.h src/etc-internal.h @@ -101,13 +125,7 @@ set(MAIN_HEADERS src/debugwriter.h src/oneshot.h src/pipe.h - chromasdk/RzChromaSDKDefines.h - chromasdk/RzChromaSDKTypes.h - chromasdk/RzErrors.h - chromasdk/ChromaApi.h src/i18n.h - src/otherview-message.h - src/crash-handler.h ) set(MAIN_SOURCE @@ -154,6 +172,7 @@ set(MAIN_SOURCE ${SRC_FS_SOURCE_PATH}/rgssad.cpp src/main.cpp + src/display.cpp src/eventthread.cpp src/etc.cpp src/config.cpp @@ -161,8 +180,6 @@ set(MAIN_SOURCE src/sharedstate.cpp src/oneshot.cpp src/i18n.cpp - src/otherview-message.cpp - src/crash-handler.cpp ) if(WIN32) @@ -172,12 +189,10 @@ if(WIN32) include_directories( ${CMAKE_CURRENT_BINARY_DIR}/windows ) -elseif(APPLE) - list(APPEND MAIN_HEADERS src/mac-desktop.h) - list(APPEND MAIN_SOURCE src/mac-desktop.mm) else() - find_package(PkgConfig REQUIRED) - pkg_check_modules(LINUXPKGS REQUIRED gtk+-2.0 libxfconf-0) + if(NOT MSYS2) + pkg_check_modules(LINUXPKGS REQUIRED gtk+-2.0 libxfconf-0) + endif() include_directories(${LINUXPKGS_INCLUDE_DIRS}) add_compile_options(${LINUXPKGS_CFLAGS_OTHER} -g) list(APPEND PLATFORM_LIBRARIES ${LINUXPKGS_LDFLAGS}) @@ -201,8 +216,6 @@ endif() source_group("MKXP Source" FILES ${MAIN_SOURCE} ${MAIN_HEADERS}) -## Setup embedded source ## - set(EMBEDDED_INPUT shader/common.h shader/transSimple.frag @@ -236,6 +249,7 @@ set(EMBEDDED_INPUT shader/cubic_lens.frag shader/water.frag shader/zoom.vert + shader/binary_glitch.frag assets/icon.png assets/gamecontrollerdb.txt ) @@ -253,8 +267,6 @@ if (MSVC) ) endif() -## Process Embeddeds ## - find_program(XXD_EXE xxd DOC "Location of the xxd executable" ) @@ -286,8 +298,6 @@ endforeach() source_group("Embedded Source" FILES ${EMBEDDED_INPUT} ${EMBEDDED_SOURCE}) -## Setup binding source ## - list(APPEND DEFINES BINDING_MRI ) @@ -321,18 +331,23 @@ set(BINDING_SOURCE binding-mri/steam-binding.cpp binding-mri/wallpaper-binding.cpp binding-mri/journal-binding.cpp - binding-mri/chroma-binding.cpp binding-mri/niko-binding.cpp binding-mri/modshot-window-binding.cpp binding-mri/aleffect-binding.cpp - binding-mri/otherview-binding.cpp + binding-mri/screen-binding.cpp + binding-mri/display-binding.cpp ) source_group("Binding Source" FILES ${BINDING_SOURCE} ${BINDING_HEADERS}) -## Setup main executable ## - -set(CMAKE_CXX_STANDARD 11) +link_directories( + ${SIGCXX_LIBRARY_DIRS} + ${PIXMAN_LIBRARY_DIRS} + ${PHYSFS_LIBRARY_DIRS} + ${SDL2_LIBRARY_DIRS} # Blindly assume other SDL bits are in same directory + ${Boost_LIBRARY_DIR} + ${MRI_LIBDIR} +) add_executable(${PROJECT_NAME} MACOSX_BUNDLE WIN32 ${MAIN_HEADERS} @@ -342,35 +357,61 @@ add_executable(${PROJECT_NAME} MACOSX_BUNDLE WIN32 ${EMBEDDED_SOURCE} ) -target_compile_definitions(${PROJECT_NAME} PRIVATE ${DEFINES}) -target_include_directories(${PROJECT_NAME} PRIVATE src) -target_include_directories(${PROJECT_NAME} PRIVATE ${SRC_AUDIO_HEADER_PATH}) -target_include_directories(${PROJECT_NAME} PRIVATE ${SRC_GRAPHICS_HEADER_PATH}) -target_include_directories(${PROJECT_NAME} PRIVATE ${SRC_OPENGL_HEADER_PATH}) -target_include_directories(${PROJECT_NAME} PRIVATE ${SRC_INPUT_HEADER_PATH}) -target_include_directories(${PROJECT_NAME} PRIVATE ${SRC_FS_HEADER_PATH}) -target_include_directories(${PROJECT_NAME} PRIVATE ${SRC_STEAM_PATH}) +target_compile_definitions(${PROJECT_NAME} PRIVATE + ${DEFINES} +) +target_include_directories(${PROJECT_NAME} PRIVATE + src + ${SRC_STEAM_PATH} + ${SRC_AUDIO_HEADER_PATH} + ${SRC_GRAPHICS_HEADER_PATH} + ${SRC_OPENGL_HEADER_PATH} + ${SRC_INPUT_HEADER_PATH} + ${SRC_FS_HEADER_PATH} + + ${SIGCXX_INCLUDE_DIRS} + ${PIXMAN_INCLUDE_DIRS} + ${PHYSFS_INCLUDE_DIRS} + ${SDL2_INCLUDE_DIRS} # Blindly assume other SDL bits are in same directory + ${SDL_SOUND_INCLUDE_DIRS} + ${Boost_INCLUDE_DIR} + ${MRI_INCLUDE_DIRS} + ${VORBISFILE_INCLUDE_DIRS} + ${FLUID_INCLUDE_DIRS} + ${OPENAL_INCLUDE_DIR} +) + target_link_libraries(${PROJECT_NAME} - CONAN_PKG::boost - CONAN_PKG::openal - CONAN_PKG::physfs - CONAN_PKG::pixman - CONAN_PKG::ruby - CONAN_PKG::sdl2 - CONAN_PKG::sdl2_image - CONAN_PKG::sdl2_ttf - CONAN_PKG::sdl_sound-mkxp - CONAN_PKG::sigc++ - ${PLATFORM_LIBRARIES}) - -IF(APPLE) - add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND cmake -P "${CMAKE_SOURCE_DIR}/patches/mac/CompleteBundle.cmake" VERBATIM) -ENDIF() + ${SIGCXX_LIBRARIES} + ${SDL2_LIBRARIES} + ${SDL2_IMAGE_LIBRARIES} + ${SDL2_TTF_LIBRARIES} + ${SDL_SOUND_LIBRARIES} + ${PHYSFS_LIBRARIES} + ${PIXMAN_LIBRARIES} + ${Boost_LIBRARIES} + ${MRI_LIBRARIES} + ${VORBISFILE_LIBRARIES} + ${FLUID_LIBRARIES} + ${OPENAL_LIBRARY} + ${ZLIB_LIBRARY} + + ${OGG_LIBRARIES} + ${SPEEX_LIBRARIES} + ${MODPLUG_LIBRARIES} + + ${PLATFORM_LIBRARIES} +) + +if(WIN32) +target_link_libraries(${PROJECT_NAME} + winmm.lib +) +endif() + if(WIN32 AND NOT STEAM) add_executable("oneshot-shim" WIN32 "${CMAKE_SOURCE_DIR}/windows/shim.c" "${CMAKE_SOURCE_DIR}/assets/resources.rc") endif() - -#add_subdirectory(scripts) diff --git a/Dockerfile-windows b/Dockerfile-windows index a4a995df..ffb67e3c 100644 --- a/Dockerfile-windows +++ b/Dockerfile-windows @@ -5,24 +5,25 @@ FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019 # install vs community (not vs buildtools because we need devenv to upgrade vs solutions ADD https://aka.ms/vs/16/release/vs_community.exe /vs_community.exe -RUN C:\vs_community.exe --quiet --wait --norestart --nocache --add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended +RUN C:\vs_community.exe --quiet --wait --norestart --nocache --add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --add Microsoft.VisualStudio.Workload.C++ # install chocolatey and use it to install cmake, git, conan, vim (vim for xxd only, since installing cygwin breaks docker) -RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -RUN iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) -RUN choco install -y cmake git conan vim +RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ` +iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); ` +choco install -y cmake git conan vim; # configure path (add xxd and cmake), conan remotes, and fix windows path size limits for conan -RUN [Environment]::SetEnvironmentVariable('Path', $env:Path + ';C:\Program Files\CMake\bin;C:\tools\vim\vim82', 'Machine') -RUN conan remote add eliza https://rkevin.jfrog.io/artifactory/api/conan/eliza -RUN conan remote add bincrafters https://bincrafters.jfrog.io/artifactory/api/conan/public-conan -RUN conan remote add astrabit https://rkevin.jfrog.io/artifactory/api/conan/astrabit -RUN conan config set general.revisions_enabled=1 -RUN setx CONAN_USE_ALWAYS_SHORT_PATHS 1 +RUN [Environment]::SetEnvironmentVariable('Path', $env:Path + ';C:\Program Files\CMake\bin;C:\tools\vim\vim82', 'Machine'); ` +conan remote add eliza https://rkevin.jfrog.io/artifactory/api/conan/eliza; ` +conan remote add bincrafters https://bincrafters.jfrog.io/artifactory/api/conan/public-conan; ` +conan remote add astrabit https://rkevin.jfrog.io/artifactory/api/conan/astrabit; ` +conan config set general.revisions_enabled=1; ` +conan profile new default --detect; ` +setx CONAN_USE_ALWAYS_SHORT_PATHS 1; # prebuild all dependencies using the conanfile in this commit COPY conanfile.py C:/Temp/install_deps/ -RUN conan install --build=missing C:\Temp\install_deps +RUN conan install --build=missing C:\Temp\install_deps -s compiler.cppstd=20 -s compiler.runtime=static # finally, we build oneshot when we run the container ENTRYPOINT ["C:\\work\\src\\build-entrypoint-windows.bat"] diff --git a/README.md b/README.md index 7e48f4ae..d20db260 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # ModShot-Core -[![Build Modshot](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-standalone.yaml/badge.svg)](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-standalone.yaml)[![Build Modshot with Steam support](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-steam.yaml/badge.svg)](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-steam.yaml)[![Build Modshot with MSYS2](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-mys2.yml/badge.svg)](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-mys2.yml) ---- +[![Build ModShot Ubuntu ](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-ubuntu.yml/badge.svg)](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-ubuntu.yml)[![Build ModShot Windows](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-windows.yml/badge.svg)](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-windows.yml) This is a even more MORE specialized fork of a specialized fork of ([mkxp by Ancurio](https://github.com/Ancurio/mkxp) designed for [*OneShot*](http://oneshot-game.com/)) for OneShot mods. @@ -8,6 +7,8 @@ Thanks to [hunternet93](https://github.com/hunternet93) for starting the reimple Thanks to [rkevin-arch](https://github.com/rkevin-arch) for the docker build! +Thanks to [somedevfox](https://github.com/somedevfox) for helping ModShot ditch conan! + > mkxp is a project that seeks to provide a fully open source implementation of the Ruby Game Scripting System (RGSS) interface used in the popular game creation software "RPG Maker XP", "RPG Maker VX" and "RPG Maker VX Ace" (trademark by Enterbrain, Inc.), with focus on Linux. The goal is to be able to run games created with the above software natively without changing a single file. > > It is licensed under the GNU General Public License v2+. @@ -15,35 +16,78 @@ Thanks to [rkevin-arch](https://github.com/rkevin-arch) for the docker build! *ModShot* also makes use of [steamshim](https://hg.icculus.org/icculus/steamshim/) for GPL compliance while making use of Steamworks features. See LICENSE.steamshim.txt for details. You can compile ModShot with steam without compiling steamshim, but you will need to source the steamshim binary yourself. +## Building + +Conan is no longer supported. Long live conan. +Instead, ModShot now makes use of meson, bash, and make, in a fairly simple setup. You only need to compile dependencies once. + +Because of this, compiling with Visual Studio as was standard before is no longer supported, and instead compiling using the msys2 toolset is required. +The main upshot of this, of course, is remaining on par with ruby in terms of gem support. (at least for windows) + +Previously, C extensions were very jank with ModShot, **however** now you can use a C extension right from your own Ruby install! +(Provided the version is the same, and the msys2 evironment is the same. I'll get back to this later.) + +## Build options + +Unfortunately because of the way ModShot is set up, you will need to pass build options to Make **and** Meson, if it pertains to dependencies. (ruby ver, opt level, etc.) + +# Options + +``` +RUBY_VER && -Dmri_version (default 3.1) sets the ruby version. +-Dsteam (default false) sets the build to use steam. +--build-type (default Release) sets the build type. +-Dbuild_static (default true) sets the build to be static. (True is faster, but with longer startup times.) +``` + +## Building on Windows + +First, you'll need to download [msys2](https://www.msys2.org/) and install it. +Then, you'll want to determine what Ruby version you're using, as this will determine what build environment you'll be using. +As is, ModShot is set up to use Ruby 3.1, so keep that in mind. Please refer to this table to determine the environment. +(You *can* use the wrong environment and it will work fine, just not with C extensions.) + +``` +Ruby >3.1 UCRT64 (Default) +Ruby 3.0-2.0 MINGW64 +Ruby <1.9 MINGW32 (NOT SUPPORTED!) +``` + +Once you've figured out the environment you need to use, pull up an msys2 shell of it. +(You can search the environment name in the Windows search box to open it) +From there, it's pretty much identical to the Linux setup. + +```sh +# Install dependencies from package manager +sh setup.sh + +# Build extra dependencies (like ruby) +cd windows; make +source vars.sh + +cd ..; meson build --prefix="$PWD/build.out" --bindir=. +cd build && ninja install +``` -# Usage -Please credit the project in some wayy, either by a direct title card, or some other means. - - Main features currently: - - Ruby gem support - - Vertical sprite mirroring - - Net::HTTP support - - Custom audio bindings - - Docker containers - - Simplified build process - +## Building on Linux -# Wiki +Building on Linux is fairly easy, as long as you're using one of the supported distros. (Manjaro, Debian/Ubuntu, Fedora/Red Hat) +Unlike Windows, you don't have to worry about msys2 environments. Just use gcc and you'll be good to go. +If you're not, fear not, as you can usually just install all the dependencies right from your package manager. See `setup.sh`. -> A wiki is in progress and will be made when more features are added. +```sh +# Install dependencies from package manager +sh setup.sh -### Supported image/audio formats -These depend on the SDL auxiliary libraries. *ModShot* only makes use of bmp/png for images and oggvorbis/wav for audio. +# Build extra dependencies (like ruby) +cd linux; make +source vars.sh -To run *ModShot*, you should have a graphics card capable of at least **OpenGL (ES) 2.0** with an up-to-date driver installed. +cd ..; meson build --prefix="$PWD/build.out" --bindir=. +cd build && ninja install +``` -To run *ModShot*, you must also have a x64 system. Currently, compiling for x86 is unsupported. +This should create a folder called `out` with your build of ModShot all ready to go! ## Configuration @@ -61,4 +105,3 @@ Modshot builds come pre-packaged with the ruby standard library in `/lib/ruby/`. You can ship your own gems by finding the gem install location (Typically `C:\Ruby27-x64\lib\ruby\gems\2.7.0\gems`), going inside the gem, and copying over all the files inside lib. -Some gems may ship with external dlls/sos, those are a little buggy at the moment, and may throw a loaderror when trying to use them. You may have some success putting the dlls/sos found in `//ext/` in `/lib/`. diff --git a/assets/meson.build b/assets/meson.build new file mode 100644 index 00000000..ba490ebd --- /dev/null +++ b/assets/meson.build @@ -0,0 +1,20 @@ +embedded_assets = [ + 'icon.png', + 'gamecontrollerdb.txt' +] + +embedded_assets_f = files(embedded_assets) + +count = 0 +foreach file : embedded_assets_f + global_sources += custom_target(embedded_assets[count], + input: file, + output: '@0@.xxd'.format(embedded_assets[count]), + command: [ + xxd, '-i', '@INPUT@' + ], + capture: true, + depend_files: embedded_assets_f[count] + ) + count += 1 +endforeach diff --git a/binding-mri/binding-mri-win32.h b/binding-mri/binding-mri-win32.h new file mode 100644 index 00000000..ae6a7f43 --- /dev/null +++ b/binding-mri/binding-mri-win32.h @@ -0,0 +1,43 @@ +#ifndef BINDING_MRI_WIN32_H +#define BINDING_MRI_WIN32_H + + +#include +#include "win-consoleutils.h" + +// Attempts to set $stdout and $stdin accordingly on Windows. Only +// called when debug mode is on, since that's when the console +// should be active. +void configureWindowsStreams() { + const int stdoutFD = getStdFD(STD_OUTPUT_HANDLE); + + // Configure $stdout + if (stdoutFD >= 0) { + VALUE winStdout = rb_funcall(rb_cIO, rb_intern("new"), 2, + INT2NUM(stdoutFD), rb_str_new_cstr("w+")); + + rb_gv_set("stdout", winStdout); + } + + const int stdinFD = getStdFD(STD_INPUT_HANDLE); + + // Configure $stdin + if (stdinFD >= 0) { + VALUE winStdin = rb_funcall(rb_cIO, rb_intern("new"), 2, + INT2NUM(stdinFD), rb_str_new_cstr("r")); + + rb_gv_set("stdin", winStdin); + } + + const int stderrFD = getStdFD(STD_ERROR_HANDLE); + + // Configure $stderr + if (stderrFD >= 0) { + VALUE winStderr = rb_funcall(rb_cIO, rb_intern("new"), 2, + INT2NUM(stderrFD), rb_str_new_cstr("w+")); + + rb_gv_set("stderr", winStderr); + } +} + +#endif \ No newline at end of file diff --git a/binding-mri/binding-mri.cpp b/binding-mri/binding-mri.cpp index 4e0466d7..207a1e6e 100644 --- a/binding-mri/binding-mri.cpp +++ b/binding-mri/binding-mri.cpp @@ -32,6 +32,10 @@ #include "boost-hash.h" #include "version.h" +#ifdef __WIN32 +#include "binding-mri-win32.h" +#endif + #include #include #undef inline @@ -40,7 +44,7 @@ #include #include -#include +#include extern const char module_rpg1[]; @@ -83,10 +87,9 @@ void wallpaperBindingTerminate(); void nikoBindingInit(); void oneshotBindingInit(); void steamBindingInit(); -void chromaBindingInit(); void modshotwindowBindingInit(); void aleffectBindingInit(); -void otherviewBindingInit(); +void screenBindingInit(); RB_METHOD(mriPrint); RB_METHOD(mriP); RB_METHOD(mkxpDataDirectory); @@ -122,10 +125,9 @@ static void mriBindingInit() nikoBindingInit(); oneshotBindingInit(); steamBindingInit(); - chromaBindingInit(); modshotwindowBindingInit(); aleffectBindingInit(); - otherviewBindingInit(); + screenBindingInit(); rb_define_global_const("MODSHOT_VERSION", rb_str_new_cstr(MODSHOT_VERSION)); if (rgssVer >= 3) { @@ -173,6 +175,12 @@ static void mriBindingInit() " ENV['SSL_CERT_FILE'] = './lib/cacert.pem'\n" "end\n" ); + +#ifdef __WIN32 + if (shState->config().winConsole) + configureWindowsStreams(); +#endif + } static void @@ -443,7 +451,6 @@ static void runRMXPScripts(BacktraceData &btData) /* Set the debug flag */ rb_gv_set("$debug", conf.debugMode ? Qtrue : Qfalse); - rb_gv_set("$otherview", conf.isOtherView ? Qtrue : Qfalse); rb_gv_set("$RGSS_SCRIPTS", scriptArray); @@ -602,6 +609,8 @@ static void showExc(VALUE exc, const BacktraceData &btData) static void mriBindingExecute() { + Config &conf = shState->rtData().config; + /* Normally only a ruby executable would do a sysinit, * but not doing it will lead to crashes due to closed * stdio streams on some platforms (eg. Windows) */ @@ -624,13 +633,53 @@ static void mriBindingExecute() // the three arguments are the executable name, and the '-e ""' is to tell ruby to run an empty file // otherwise (since this parses options for the ruby executable) it's gonna wait on stdin for code // --jit enables the jit i think - char options_argv1[] = "oneshot", options_argv2[] = "-e", options_argv3[] = ""; - char* options_argv[] = {options_argv1, options_argv2, options_argv3, NULL}; - ruby_options(3, options_argv); + std::vector rubyArgsC{"oneshot"}; + rubyArgsC.push_back("-e "); + void *node; + if (conf.mjitEnabled) { + std::string verboseLevel("--mjit-verbose="); verboseLevel += std::to_string(conf.mjitVerbosity); + std::string maxCache("--mjit-max-cache="); maxCache += std::to_string(conf.mjitMaxCache); + std::string minCalls("--mjit-min-calls="); minCalls += std::to_string(conf.mjitMinCalls); + rubyArgsC.push_back("--mjit"); + rubyArgsC.push_back(verboseLevel.c_str()); + rubyArgsC.push_back(maxCache.c_str()); + rubyArgsC.push_back(minCalls.c_str()); + } - rb_enc_set_default_external(rb_enc_from_encoding(rb_utf8_encoding())); + if (conf.yjitEnabled) { + std::string callThreshold("--yjit-call-threshold="); callThreshold += std::to_string(conf.yjitCallThreshold); + std::string maxVersions("--yjit-max-versions="); maxVersions += std::to_string(conf.yjitMaxVersions); + std::string greedyVersioning("--yjit-greedy-versioning"); greedyVersioning += std::to_string(conf.yjitGreedyVersioning); + rubyArgsC.push_back("--yjit"); + rubyArgsC.push_back(callThreshold.c_str()); + rubyArgsC.push_back(maxVersions.c_str()); + rubyArgsC.push_back(greedyVersioning.c_str()); + } - Config &conf = shState->rtData().config; + if (conf.jitEnabled) { + std::string verboseLevel("-jit-verbose="); verboseLevel += std::to_string(conf.jitVerbosity); + std::string maxCache("--jit-max-cache="); maxCache += std::to_string(conf.jitMaxCache); + std::string minCalls("--jit-min-calls="); minCalls += std::to_string(conf.jitMinCalls); + rubyArgsC.push_back("--jit"); + rubyArgsC.push_back(verboseLevel.c_str()); + rubyArgsC.push_back(maxCache.c_str()); + rubyArgsC.push_back(minCalls.c_str()); + } + + node = ruby_options(rubyArgsC.size(), const_cast(rubyArgsC.data())); + + int state; + bool valid = ruby_executable_node(node, &state); + if (valid) + state = ruby_exec_node(node); + if (state || !valid) { + showMsg("An error occurred while initializing Ruby. (Invalid JIT settings?)"); + ruby_cleanup(state); + shState->rtData().rqTermAck.set(); + return; + } + + rb_enc_set_default_external(rb_enc_from_encoding(rb_utf8_encoding())); if (!conf.rubyLoadpaths.empty()) { diff --git a/binding-mri/chroma-binding.cpp b/binding-mri/chroma-binding.cpp deleted file mode 100644 index f04089cf..00000000 --- a/binding-mri/chroma-binding.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "binding-util.h" -#include "binding-types.h" -#include "debugwriter.h" - -#include "chromasdk/ChromaApi.h" - -bool INIT_SUCCESS = false; - -#ifdef _WIN32 - HINSTANCE hLib = NULL; -#else - int* hLib = NULL; -#endif - -//dynamic-loaded proc pointers -PluginPlayAnimation _playAnimation = NULL; -PluginOpenAnimation _openAnimation = NULL; -PluginIsInitialized _pluginIsInitialized = NULL; -PluginInit _pluginInit = NULL; -PluginUninit _pluginUninit = NULL; - -int lastAnimId = -1; - - -void _attemptLinkSdk() { - Debug() << "Attempting to bind Chroma SDK"; - #ifdef _WIN32 - hLib = LoadLibrary(L"ChromaApi.dll"); - if (hLib != NULL) { - Debug() << "Chroma Impl @" << hLib; - INIT_SUCCESS = true; - - _playAnimation = (PluginPlayAnimation) GetProcAddress(hLib, "PluginPlayAnimation"); - INIT_SUCCESS &= _playAnimation != NULL; - Debug() << "Plugin method @" << (long)_playAnimation; - - _openAnimation = (PluginOpenAnimation) GetProcAddress(hLib, "PluginOpenAnimation"); - INIT_SUCCESS &= _openAnimation != NULL; - - _pluginInit = (PluginInit) GetProcAddress(hLib, "PluginInit"); - INIT_SUCCESS &= _pluginInit != NULL; - - _pluginIsInitialized = (PluginIsInitialized) GetProcAddress(hLib, "PluginIsInitialized"); - INIT_SUCCESS &= _pluginInit != NULL; - if (INIT_SUCCESS && !_pluginIsInitialized()) { - Debug() << "Initializing chroma plugin"; - _pluginInit(); - } - _pluginUninit = (PluginUninit) GetProcAddress(hLib, "PluginUninit"); - INIT_SUCCESS &= _pluginUninit != NULL; - Debug() << "Plugin init success:" << INIT_SUCCESS; - } - #else - // Currently the Razor Chroma API is Windows-only. - // So, if we are not building for Windows platform, - // then don't bother with Chroma stuff. - Debug() << "Chroma: Unsupported Platform"; - #endif -} - - -RB_METHOD(chromaPlayAnimation) { - RB_UNUSED_PARAM; - - Debug() << "Chroma: Attempting to play animation."; - const char* animfile; - bool loop; - - rb_get_args(argc, argv, "zb", &animfile, &loop RB_ARG_END); - - if (INIT_SUCCESS) { - Debug() << "Opening animation:" << animfile; - lastAnimId = _openAnimation(animfile); - Debug() << "ID:" << lastAnimId; - _playAnimation(lastAnimId); - } - - return Qnil; -} - -void chromaBindingInit() { - _attemptLinkSdk(); - - VALUE module = rb_define_module("Chroma"); - _rb_define_module_function(module, "playAnim", chromaPlayAnimation); -} - -void chromaBindingRelease() { - #ifdef _WIN32 - if (hLib != NULL) { - _pluginUninit(); - FreeLibrary(hLib); - hLib = NULL; - INIT_SUCCESS = false; - } - #endif -} diff --git a/binding-mri/display-binding.cpp b/binding-mri/display-binding.cpp new file mode 100644 index 00000000..82da7a58 --- /dev/null +++ b/binding-mri/display-binding.cpp @@ -0,0 +1,35 @@ +#include "binding-util.h" +#include "binding-types.h" +#include "sharedstate.h" +#include "eventthread.h" +#include "display.h" +#include "debugwriter.h" + +RB_METHOD(getScreenWidth) +{ + return rb_int_new(Display::getScreenWidth()); +} + +RB_METHOD(getScreenHeight) +{ + return rb_int_new(Display::getScreenHeight()); +} + +RB_METHOD(isWayland) +{ + return rb_bool_new(Display::isWayland()); +} + +RB_METHOD(isX) +{ + return rb_bool_new(Display::isX()); +} + +void displayBindingInit() +{ + VALUE module = rb_define_module("Display"); + _rb_define_module_function(module, "getScreenWidth", getScreenWidth); + _rb_define_module_function(module, "getScreenHeight", getScreenHeight); + _rb_define_module_function(module, "isWayland?", isWayland); + _rb_define_module_function(module, "isX?", isX); +} \ No newline at end of file diff --git a/binding-mri/journal-binding.cpp b/binding-mri/journal-binding.cpp index 7ca301f0..6c9dd4ae 100644 --- a/binding-mri/journal-binding.cpp +++ b/binding-mri/journal-binding.cpp @@ -27,7 +27,7 @@ #include #endif -#include +#include #define BUFFER_SIZE 256 diff --git a/binding-mri/meson.build b/binding-mri/meson.build new file mode 100644 index 00000000..66adb478 --- /dev/null +++ b/binding-mri/meson.build @@ -0,0 +1,41 @@ +if get_option('mri_includes') == '' + ver = get_option('mri_version') + if ver.version_compare('>=3.0') and compilers['cpp'].get_id() == 'clang' + global_args += '-fdeclspec' + endif + global_dependencies += dependency('ruby-' + ver) +else + global_args += ('-I' + get_option('mri_includes')) + global_dependencies += compilers['cpp'].find_library(get_option('mri_library'), dirs: get_option('mri_libpath')) +endif + +global_include_dirs += include_directories('.') + +binding_source = [files( + 'aleffect-binding.cpp', + 'audio-binding.cpp', + 'binding-mri.cpp', + 'binding-util.cpp', + 'bitmap-binding.cpp', + 'etc-binding.cpp', + 'filesystem-binding.cpp', + 'font-binding.cpp', + 'graphics-binding.cpp', + 'input-binding.cpp', + 'journal-binding.cpp', + 'modshot-window-binding.cpp', + 'module_rpg.cpp', + 'niko-binding.cpp', + 'oneshot-binding.cpp', + 'plane-binding.cpp', + 'screen-binding.cpp', + 'sprite-binding.cpp', + 'steam-binding.cpp', + 'table-binding.cpp', + 'tilemap-binding.cpp', + 'viewport-binding.cpp', + 'wallpaper-binding.cpp', + 'window-binding.cpp', +)] + +global_sources += binding_source diff --git a/binding-mri/modshot-window-binding.cpp b/binding-mri/modshot-window-binding.cpp index 2e3b8851..af4b25e2 100644 --- a/binding-mri/modshot-window-binding.cpp +++ b/binding-mri/modshot-window-binding.cpp @@ -5,9 +5,9 @@ #include "binding-types.h" #include "eventthread.h" -#include -#include -//#include +#include +#include +//#include #include #ifdef _WIN32 diff --git a/binding-mri/niko-binding.cpp b/binding-mri/niko-binding.cpp index 036900de..805b1a3c 100644 --- a/binding-mri/niko-binding.cpp +++ b/binding-mri/niko-binding.cpp @@ -28,9 +28,9 @@ #include #endif -#include +#include namespace syswm { -#include +#include } #define NIKO_X (320 - 16) diff --git a/binding-mri/oneshot-binding.cpp b/binding-mri/oneshot-binding.cpp index b305dc99..a5bc87c8 100644 --- a/binding-mri/oneshot-binding.cpp +++ b/binding-mri/oneshot-binding.cpp @@ -5,7 +5,7 @@ #include "binding-types.h" #include "eventthread.h" -#include +#include #include RB_METHOD(oneshotSetYesNo) diff --git a/binding-mri/otherview-binding.cpp b/binding-mri/otherview-binding.cpp deleted file mode 100644 index 8dd6f95b..00000000 --- a/binding-mri/otherview-binding.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include "binding-util.h" -#include "binding-types.h" -#include "sharedstate.h" -#include "eventthread.h" -#include "otherview-message.h" -#include "debugwriter.h" - -#include -#include - -std::vector subscribers; - -void notify(VALUE message) -{ - /* - Debug() << "ruby_string"; - Debug() << message; - */ - VALUE args[] = { message }; - - for (auto & element : subscribers) { - /* rb_funcallv(element, rb_intern("call"), 1, args); */ - rb_funcallv(element, rb_intern("call"), 1, args); - } -} - -RB_METHOD(pushSubscriber) -{ - - VALUE subscriberProc; - rb_get_args(argc, argv, "o", &subscriberProc RB_ARG_END); - subscribers.push_back(subscriberProc); - /* - VALUE obj = rb_block_proc(); - subscribers.push_back(obj); - */ - return Qnil; -} - -RB_METHOD(popSubscriber) -{ - int index = -1; - rb_get_args(argc, argv, "|i", &index RB_ARG_END); - if (index < 0) { - subscribers.pop_back(); - } else { - subscribers.erase(subscribers.begin() + index); - } - return Qnil; -} - -RB_METHOD(returnSubscribers) -{ - VALUE returnValue = rb_ary_new(); - std::vector::iterator it; - - for (it = subscribers.begin(); it != subscribers.end(); it++) - { - rb_ary_push(returnValue, *it); - } - - return returnValue; -} - -RB_METHOD(otherViewUpdate) -{ - OtherViewMessager &messager = shState->otherView(); - std::string response = messager.getMsg(); - /* - Debug() << "response"; - Debug() << response; - Debug() << strlen(response); - */ - - VALUE str = rb_str_new_cstr(response.c_str()); - - return str; -} - -RB_METHOD(sendMessage) -{ - OtherViewMessager &messager = shState->otherView(); - - std::string message; - rb_get_args(argc, argv, "z", &message RB_ARG_END); - - messager.sendMsg(message); - - return Qnil; -} -RB_METHOD(readMessage) -{ - OtherViewMessager &messager = shState->otherView(); - VALUE rtn = rb_str_new_cstr(messager.getMsg().c_str()); - return rtn; -} - -RB_METHOD(openOneShot) -{ - OtherViewMessager &messager = shState->otherView(); - messager.OpenOneShot(); - - return Qnil; -} - -void otherviewBindingInit() -{ - VALUE module = rb_define_module("OtherView"); - _rb_define_module_function(module, "pushSubscriber", pushSubscriber); - _rb_define_module_function(module, "popSubscriber", popSubscriber); - _rb_define_module_function(module, "subscribers", returnSubscribers); - _rb_define_module_function(module, "update", otherViewUpdate); - _rb_define_module_function(module, "send", sendMessage); - _rb_define_module_function(module, "read", readMessage); - _rb_define_module_function(module, "openOneShot", openOneShot); -} \ No newline at end of file diff --git a/binding-mri/viewport-binding.cpp b/binding-mri/viewport-binding.cpp index 505f4ceb..184d5ded 100644 --- a/binding-mri/viewport-binding.cpp +++ b/binding-mri/viewport-binding.cpp @@ -102,6 +102,18 @@ RB_METHOD(setCubicTime) return Qnil; } +RB_METHOD(setBinaryStrength) +{ + double strength; + rb_get_args(argc, argv, "f", &strength); + + Viewport *v = getPrivateData(self); + + v->setBinaryStrength(clamp(strength, 0.0, 1.0)); + + return Qnil; +} + RB_METHOD(setWaterTime) { double time; @@ -148,6 +160,7 @@ viewportBindingInit() _rb_define_method(klass, "setRGBOffset", setRGBOffset); _rb_define_method(klass, "setZoom", setZoom); _rb_define_method(klass, "setCubicTime", setCubicTime); + _rb_define_method(klass, "setBinaryStrength", setBinaryStrength); _rb_define_method(klass, "setWaterTime", setWaterTime); INIT_PROP_BIND( Viewport, Rect, "rect" ); diff --git a/binding-null/binding-null.cpp b/binding-null/binding-null.cpp deleted file mode 100644 index a4799e39..00000000 --- a/binding-null/binding-null.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* -** binding-null.cpp -** -** This file is part of mkxp. -** -** Copyright (C) 2013 Jonas Kulla -** -** mkxp is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 2 of the License, or -** (at your option) any later version. -** -** mkxp is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with mkxp. If not, see . -*/ - -#include "binding.h" -#include "sharedstate.h" -#include "eventthread.h" -#include "debugwriter.h" - -static void nullBindingExecute() -{ - Debug() << "The null binding doesn't do anything, so we're done!"; - shState->rtData().rqTermAck.set(); -} - -static void nullBindingTerminate() -{ - -} - -static void nullBindingReset() -{ - -} - -ScriptBinding scriptBindingImpl = -{ - nullBindingExecute, - nullBindingTerminate, - nullBindingReset -}; - -ScriptBinding *scriptBinding = &scriptBindingImpl; diff --git a/chromasdk/ChromaApi.h b/chromasdk/ChromaApi.h deleted file mode 100644 index 7aacf25b..00000000 --- a/chromasdk/ChromaApi.h +++ /dev/null @@ -1,175 +0,0 @@ - -typedef int (*PluginInit)(); -typedef double (*PluginInitD)(); - -typedef bool (*PluginIsPlatformSupported)(); -typedef double (*PluginIsPlatformSupportedD)(); - -typedef bool (*PluginIsInitialized)(); -typedef double (*PluginIsInitializedD)(); - -typedef bool (*PluginIsDialogOpen)(); -typedef double (*PluginIsDialogOpenD)(); - -typedef int (*PluginOpenEditorDialog)(const char* path); -typedef double (*PluginOpenEditorDialogD)(const char* path); - -typedef int (*PluginOpenEditorDialogAndPlay)(const char* path); -typedef double (*PluginOpenEditorDialogAndPlayD)(const char* path); - -typedef int (*PluginOpenAnimation)(const char* path); -typedef double (*PluginOpenAnimationD)(const char* path); - -typedef int (*PluginLoadAnimation)(int animationId); -typedef double (*PluginLoadAnimationD)(double animationId); - -typedef int (*PluginUnloadAnimation)(int animationId); -typedef double (*PluginUnloadAnimationD)(double animationId); - -typedef int (*PluginPlayAnimation)(int animationId); -typedef double (*PluginPlayAnimationD)(double animationId); - -typedef bool (*PluginIsPlaying)(int animationId); -typedef double (*PluginIsPlayingD)(double animationId); - -typedef int (*PluginStopAnimation)(int animationId); -typedef double (*PluginStopAnimationD)(double animationId); - -typedef int (*PluginCloseAnimation)(int animationId); -typedef double (*PluginCloseAnimationD)(double animationId); - -typedef int (*PluginUninit)(); -typedef double (*PluginUninitD)(); - -typedef int (*PluginCreateAnimationInMemory)(int deviceType, int device); -typedef int (*PluginCreateAnimation)(const char* path, int deviceType, int device); -typedef int (*PluginSaveAnimation)(int animationId, const char* path); -typedef int (*PluginResetAnimation)(int animationId); - -typedef int (*PluginGetDeviceType)(int animationId); -typedef int (*PluginGetDeviceTypeName)(const char* path); -typedef double (*PluginGetDeviceTypeNameD)(const char* path); - -typedef int (*PluginGetDevice)(int animationId); -typedef int (*PluginGetDeviceName)(const char* path); -typedef double (*PluginGetDeviceNameD)(const char* path); - -typedef int (*PluginSetDevice)(int animationId, int deviceType, int device); - -typedef int (*PluginGetMaxLeds)(int device); -typedef double (*PluginGetMaxLedsD)(double device); - -typedef int (*PluginGetMaxRow)(int device); -typedef double (*PluginGetMaxRowD)(double device); - -typedef int (*PluginGetMaxColumn)(int device); -typedef double (*PluginGetMaxColumnD)(double device); - -typedef int (*PluginAddFrame)(int animationId, float duration, int* colors, int length); -typedef int (*PluginUpdateFrame)(int animationId, int frameIndex, float duration, int* colors, int length); -typedef int (*PluginGetFrame)(int animationId, int frameIndex, float* duration, int* colors, int length); - -typedef int (*PluginPreviewFrame)(int animationId, int frameIndex); -typedef double (*PluginPreviewFrameD)(double animationId, double frameIndex); - -typedef int (*PluginOverrideFrameDuration)(int animationId, float duration); -typedef double (*PluginOverrideFrameDurationD)(double animationId, double duration); - -typedef int (*PluginReverse)(int animationId); -typedef int (*PluginMirrorHorizontally)(int animationId); -typedef int (*PluginMirrorVertically)(int animationId); - -typedef int (*PluginGetAnimation)(const char* name); -typedef double (*PluginGetAnimationD)(const char* name); - -typedef void (*PluginCloseAnimationName)(const char* path); -typedef double (*PluginCloseAnimationNameD)(const char* path); - -typedef void (*PluginPlayAnimationLoop)(int animationId, bool loop); -typedef void (*PluginPlayAnimationName)(const char* path, bool loop); -typedef double (*PluginPlayAnimationNameD)(const char* path, double loop); - -typedef void (*PluginPlayAnimationFrame)(int animationId, int frameId, bool loop); -typedef void (*PluginPlayAnimationFrameName)(const char* path, int frameId, bool loop); -typedef double (*PluginPlayAnimationFrameNameD)(const char* path, double frameId, double loop); - -typedef void (*PluginStopAnimationName)(const char* path); -typedef double (*PluginStopAnimationNameD)(const char* path); - -typedef void (*PluginStopAnimationType)(int deviceType, int device); -typedef double (*PluginStopAnimationTypeD)(double deviceType, double device); - -typedef bool (*PluginIsPlayingName)(const char* path); -typedef double (*PluginIsPlayingNameD)(const char* path); - -typedef bool (*PluginIsPlayingType)(int deviceType, int device); -typedef double (*PluginIsPlayingTypeD)(double deviceType, double device); - -typedef void (*PluginPlayComposite)(const char* name, bool loop); -typedef double (*PluginPlayCompositeD)(const char* name, double loop); - -typedef void (*PluginStopComposite)(const char* name); -typedef double (*PluginStopCompositeD)(const char* name); - -typedef void (*PluginCloseComposite)(const char* name); -typedef double (*PluginCloseCompositeD)(const char* name); - -typedef int (*PluginGetKeyColor)(int animationId, int frameId, int rzkey); -typedef int (*PluginGetKeyColorName)(const char* path, int frameId, int rzkey); -typedef double (*PluginGetKeyColorD)(const char* path, double frameId, double rzkey); - -typedef int (*PluginGet1DColor)(int animationId, int frameId, int led); -typedef int (*PluginGet1DColorName)(const char* path, int frameId, int led); -typedef double (*PluginGet1DColorNameD)(const char* path, double frameId, double led); - -typedef int (*PluginGet2DColor)(int animationId, int frameId, int row, int column); -typedef int (*PluginGet2DColorName)(const char* path, int frameId, int row, int column); -typedef double (*PluginGet2DColorNameD)(const char* path, double frameId, double row, double column); - -typedef void (*PluginSetKeyColor)(int animationId, int frameId, int rzkey, int color); -typedef void (*PluginSetKeyColorName)(const char* path, int frameId, int rzkey, int color); -typedef double (*PluginSetKeyColorNameD)(const char* path, double frameId, double rzkey, double color); - -typedef void (*PluginSet1DColor)(int animationId, int frameId, int led, int color); -typedef void (*PluginSet1DColorName)(const char* path, int frameId, int led, int color); -typedef double (*PluginSet1DColorNameD)(const char* path, double frameId, double led, double color); - -typedef void (*PluginSet2DColor)(int animationId, int frameId, int row, int column, int color); -typedef void (*PluginSet2DColorName)(const char* path, int frameId, int row, int column, int color); -typedef double (*PluginSet2DColorNameD)(const char* path, double frameId, double rowColumnIndex, double color); - -typedef void (*PluginCopyKeyColor)(int sourceAnimationId, int targetAnimationId, int frameId, int rzkey); -typedef void (*PluginCopyKeyColorName)(const char* sourceAnimation, const char* targetAnimation, int frameId, int rzkey); -typedef double (*PluginCopyKeyColorNameD)(const char* sourceAnimation, const char* targetAnimation, double frameId, double rzkey); - -typedef void (*PluginCopyNonZeroKeyColor)(int sourceAnimationId, int targetAnimationId, int frameId, int rzkey); -typedef void (*PluginCopyNonZeroKeyColorName)(const char* sourceAnimation, const char* targetAnimation, int frameId, int rzkey); -typedef double (*PluginCopyNonZeroKeyColorNameD)(const char* sourceAnimation, const char* targetAnimation, double frameId, double rzkey); - -typedef int (*PluginGetFrameCount)(int animationId); -typedef int (*PluginGetFrameCountName)(const char* path); -typedef double (*PluginGetFrameCountNameD)(const char* path); - -typedef int (*PluginGetCurrentFrame)(int animationId); -typedef int (*PluginGetCurrentFrameName)(const char* path); -typedef double (*PluginGetCurrentFrameNameD)(const char* path); - -typedef void (*PluginSetCurrentFrame)(int animationId, int frameId); -typedef void (*PluginSetCurrentFrameName)(const char* path, int frameId); -typedef double (*PluginSetCurrentFrameNameD)(const char* path, double frameId); - -typedef void (*PluginPauseAnimation)(int animationId); -typedef void (*PluginPauseAnimationName)(const char* path); -typedef double (*PluginPauseAnimationNameD)(const char* path); - -typedef bool (*PluginIsAnimationPaused)(int animationId); -typedef bool (*PluginIsAnimationPausedName)(const char* path); -typedef double (*PluginIsAnimationPausedNameD)(const char* path); - -typedef bool (*PluginHasAnimationLoop)(int animationId); -typedef bool (*PluginHasAnimationLoopName)(const char* path); -typedef double (*PluginHasAnimationLoopNameD)(const char* path); - -typedef void (*PluginResumeAnimation)(int animationId, bool loop); -typedef void (*PluginResumeAnimationName)(const char* path, bool loop); -typedef double (*PluginResumeAnimationNameD)(const char* path, double loop); diff --git a/chromasdk/RzChromaSDKDefines.h b/chromasdk/RzChromaSDKDefines.h deleted file mode 100644 index 0538ae12..00000000 --- a/chromasdk/RzChromaSDKDefines.h +++ /dev/null @@ -1,172 +0,0 @@ -//! \file RzChromaSDKDefines.h -//! \brief Definitions of global and static variables. - -#ifndef _RZSCHROMADKDEFINES_H_ -#define _RZSCHROMADKDEFINES_H_ - -#pragma once - -#ifndef GUID_DEFINED -#include -#endif - -namespace ChromaSDK -{ - // Keyboards - //! Razer Blackwidow Chroma device. - // {2EA1BB63-CA28-428D-9F06-196B88330BBB} - static const GUID BLACKWIDOW_CHROMA = - { 0x2ea1bb63, 0xca28, 0x428d, { 0x9f, 0x06, 0x19, 0x6b, 0x88, 0x33, 0x0b, 0xbb } }; - - //! Razer Blackwidow Chroma Tournament Edition device. - // {ED1C1B82-BFBE-418F-B49D-D03F05B149DF} - static const GUID BLACKWIDOW_CHROMA_TE = - { 0xed1c1b82, 0xbfbe, 0x418f, { 0xb4, 0x9d, 0xd0, 0x3f, 0x5, 0xb1, 0x49, 0xdf } }; - - //! Razer Deathstalker device. - // {18C5AD9B-4326-4828-92C4-2669A66D2283} - static const GUID DEATHSTALKER_CHROMA = - { 0x18c5ad9b, 0x4326, 0x4828, { 0x92, 0xc4, 0x26, 0x69, 0xa6, 0x6d, 0x22, 0x83 } }; - - //! Overwatch Keyboard. - // {872AB2A9-7959-4478-9FED-15F6186E72E4} - static const GUID OVERWATCH_KEYBOARD = - { 0x872ab2a9, 0x7959, 0x4478, { 0x9f, 0xed, 0x15, 0xf6, 0x18, 0x6e, 0x72, 0xe4 } }; - - //! Razer Blackwidow X Chroma device. - // {5AF60076-ADE9-43D4-B574-52599293B554} - static const GUID BLACKWIDOW_X_CHROMA = - { 0x5af60076, 0xade9, 0x43d4, { 0xb5, 0x74, 0x52, 0x59, 0x92, 0x93, 0xb5, 0x54 } }; - - //! Razer Blackwidow X TE Chroma device. - // {2D84DD51-3290-4AAC-9A89-D8AFDE38B57C} - static const GUID BLACKWIDOW_X_TE_CHROMA = - { 0x2d84dd51, 0x3290, 0x4aac, { 0x9a, 0x89, 0xd8, 0xaf, 0xde, 0x38, 0xb5, 0x7c } }; - - //! Razer Omata Chroma - // {803378C1-CC48-4970-8539-D828CC1D420A} - static const GUID OMATA_CHROMA = - { 0x803378c1, 0xcc48, 0x4970,{ 0x85, 0x39, 0xd8, 0x28, 0xcc, 0x1d, 0x42, 0xa } }; - - //! Razer Blade Stealth. - // {C83BDFE8-E7FC-40E0-99DB-872E23F19891} - static const GUID BLADE_STEALTH = - { 0xc83bdfe8, 0xe7fc, 0x40e0, { 0x99, 0xdb, 0x87, 0x2e, 0x23, 0xf1, 0x98, 0x91 } }; - - //! Razer Blade - // {F2BEDFAF-A0FE-4651-9D41-B6CE603A3DDD} - static const GUID BLADE = - { 0xf2bedfaf, 0xa0fe, 0x4651, { 0x9d, 0x41, 0xb6, 0xce, 0x60, 0x3a, 0x3d, 0xdd } }; - - //! Razer Blade Pro - // {A73AC338-F0E5-4BF7-91AE-DD1F7E1737A5} - static const GUID BLADE_PRO = - { 0xa73ac338, 0xf0e5, 0x4bf7,{ 0x91, 0xae, 0xdd, 0x1f, 0x7e, 0x17, 0x37, 0xa5 } }; - - //! Razer Blackwidow Chroma v2 - // {608E743F-B402-44BD-A7A6-7AA9F574ECF4} - static const GUID BLACKWIDOW_CHROMA2 = - { 0x608e743f, 0xb402, 0x44bd,{ 0xa7, 0xa6, 0x7a, 0xa9, 0xf5, 0x74, 0xec, 0xf4 } }; - - - - // Mice - //! Razer Deathadder Chroma device. - // {AEC50D91-B1F1-452F-8E16-7B73F376FDF3} - static const GUID DEATHADDER_CHROMA = - { 0xaec50d91, 0xb1f1, 0x452f, { 0x8e, 0x16, 0x7b, 0x73, 0xf3, 0x76, 0xfd, 0xf3 } }; - - //! Razer Mamba Chroma Tournament Edition device. - // {7EC00450-E0EE-4289-89D5-0D879C19061A} - static const GUID MAMBA_CHROMA_TE = - { 0x7ec00450, 0xe0ee, 0x4289, { 0x89, 0xd5, 0xd, 0x87, 0x9c, 0x19, 0x6, 0x1a } }; - - //! Razer Diamondback device. - // {FF8A5929-4512-4257-8D59-C647BF9935D0} - static const GUID DIAMONDBACK_CHROMA = - { 0xff8a5929, 0x4512, 0x4257, { 0x8d, 0x59, 0xc6, 0x47, 0xbf, 0x99, 0x35, 0xd0 } }; - - //! Razer Mamba device. - // {D527CBDC-EB0A-483A-9E89-66D50463EC6C} - static const GUID MAMBA_CHROMA = - { 0xd527cbdc, 0xeb0a, 0x483a, { 0x9e, 0x89, 0x66, 0xd5, 0x4, 0x63, 0xec, 0x6c } }; - - //! Razer Naga Epic device. - // {D714C50B-7158-4368-B99C-601ACB985E98} - static const GUID NAGA_EPIC_CHROMA = - { 0xd714c50b, 0x7158, 0x4368, { 0xb9, 0x9c, 0x60, 0x1a, 0xcb, 0x98, 0x5e, 0x98 } }; - - //! Razer Naga device. - // {F1876328-6CA4-46AE-BE04-BE812B414433} - static const GUID NAGA_CHROMA = - { 0xf1876328, 0x6ca4, 0x46ae, { 0xbe, 0x4, 0xbe, 0x81, 0x2b, 0x41, 0x44, 0x33 } }; - - //! Razer Orochi Chroma device. - // {52C15681-4ECE-4DD9-8A52-A1418459EB34} - static const GUID OROCHI_CHROMA = - { 0x52c15681, 0x4ece, 0x4dd9, { 0x8a, 0x52, 0xa1, 0x41, 0x84, 0x59, 0xeb, 0x34 } }; - - //! Razer Naga Hex Chroma device. - // {195D70F5-F285-4CFF-99F2-B8C0E9658DB4} - static const GUID NAGA_HEX_CHROMA = - { 0x195d70f5, 0xf285, 0x4cff, { 0x99, 0xf2, 0xb8, 0xc0, 0xe9, 0x65, 0x8d, 0xb4 } }; - - //! Razer DeathAdder Elite Chroma device. - // {77834867-3237-4A9F-AD77-4A46C4183003} - static const GUID DEATHADDER_ELITE_CHROMA = - { 0x77834867, 0x3237, 0x4a9f,{ 0xad, 0x77, 0x4a, 0x46, 0xc4, 0x18, 0x30, 0x3 } }; - - - // Headsets - //! Razer Kraken 7.1 Chroma device. - // {CD1E09A5-D5E6-4A6C-A93B-E6D9BF1D2092} - static const GUID KRAKEN71_CHROMA = - { 0xcd1e09a5, 0xd5e6, 0x4a6c, { 0xa9, 0x3b, 0xe6, 0xd9, 0xbf, 0x1d, 0x20, 0x92 } }; - - //! Razer ManO'War device. - // {DF3164D7-5408-4A0E-8A7F-A7412F26BEBF} - static const GUID MANOWAR_CHROMA = - { 0xdf3164d7, 0x5408, 0x4a0e, { 0x8a, 0x7f, 0xa7, 0x41, 0x2f, 0x26, 0xbe, 0xbf } }; - - //! Razer Kraken 7.1 Chroma Refresh headset. - // {7FB8A36E-9E74-4BB3-8C86-CAC7F7891EBD} - static const GUID KRAKEN71_REFRESH_CHROMA = - { 0x7fb8a36e, 0x9e74, 0x4bb3,{ 0x8c, 0x86, 0xca, 0xc7, 0xf7, 0x89, 0x1e, 0xbd } }; - - - // Mouse mat - //! Razer Firefly device. - // {80F95A94-73D2-48CA-AE9A-0986789A9AF2} - static const GUID FIREFLY_CHROMA = - { 0x80f95a94, 0x73d2, 0x48ca, { 0xae, 0x9a, 0x9, 0x86, 0x78, 0x9a, 0x9a, 0xf2 } }; - - - // Keypads - //! Razer Tartarus device. - // {00F0545C-E180-4AD1-8E8A-419061CE505E} - static const GUID TARTARUS_CHROMA = - { 0xf0545c, 0xe180, 0x4ad1, { 0x8e, 0x8a, 0x41, 0x90, 0x61, 0xce, 0x50, 0x5e } }; - - //! Razer Orbweaver device. - // {9D24B0AB-0162-466C-9640-7A924AA4D9FD} - static const GUID ORBWEAVER_CHROMA = - { 0x9d24b0ab, 0x162, 0x466c, { 0x96, 0x40, 0x7a, 0x92, 0x4a, 0xa4, 0xd9, 0xfd } }; - - - // Chroma Linked devices - // {35F6F18D-1AE5-436C-A575-AB44A127903A} - static const GUID LENOVO_Y900 = - { 0x35f6f18d, 0x1ae5, 0x436c, { 0xa5, 0x75, 0xab, 0x44, 0xa1, 0x27, 0x90, 0x3a } }; - - // {47DB1FA7-6B9B-4EE6-B6F4-4071A3B2053B} - static const GUID LENOVO_Y27 = - { 0x47db1fa7, 0x6b9b, 0x4ee6, { 0xb6, 0xf4, 0x40, 0x71, 0xa3, 0xb2, 0x5, 0x3b } }; - - // {0201203B-62F3-4C50-83DD-598BABD208E0} - static const GUID CORE_CHROMA = - { 0x201203b, 0x62f3, 0x4c50, { 0x83, 0xdd, 0x59, 0x8b, 0xab, 0xd2, 0x8, 0xe0 } }; - - -} - -#endif diff --git a/chromasdk/RzChromaSDKTypes.h b/chromasdk/RzChromaSDKTypes.h deleted file mode 100644 index 27f7bca4..00000000 --- a/chromasdk/RzChromaSDKTypes.h +++ /dev/null @@ -1,813 +0,0 @@ -//! \file RzChromaSDKTypes.h -//! \brief Data types. - -#ifndef _RZCHROMASDKTYPES_H_ -#define _RZCHROMASDKTYPES_H_ - -#pragma once - -typedef LONG RZRESULT; //!< Return result. -typedef GUID RZEFFECTID; //!< Effect Id. -typedef GUID RZDEVICEID; //!< Device Id. -typedef unsigned int RZDURATION; //!< Milliseconds. -typedef size_t RZSIZE; //!< Size. -typedef void* PRZPARAM; //!< Context sensitive pointer. -typedef DWORD RZID; //!< Generic data type for Identifier. -typedef DWORD RZCOLOR; //!< Color data. 1st byte = Red; 2nd byte = Green; 3rd byte = Blue; 4th byte = Alpha (if applicable) - -namespace ChromaSDK -{ - //! Event notification Window message - const UINT WM_CHROMA_EVENT = WM_APP+0x2000; - - //! Chroma generic effects. Note: Not all devices supported the listed effects. - typedef enum EFFECT_TYPE - { - CHROMA_NONE = 0, //!< No effect. - CHROMA_WAVE, //!< Wave effect (This effect type has deprecated and should not be used). - CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect (This effect type has deprecated and should not be used). - CHROMA_BREATHING, //!< Breathing effect (This effect type has deprecated and should not be used). - CHROMA_BLINKING, //!< Blinking effect (This effect type has deprecated and should not be used). - CHROMA_REACTIVE, //!< Reactive effect (This effect type has deprecated and should not be used). - CHROMA_STATIC, //!< Static effect. - CHROMA_CUSTOM, //!< Custom effect. For mice, please see Mouse::CHROMA_CUSTOM2. - CHROMA_RESERVED, //!< Reserved - CHROMA_INVALID //!< Invalid effect. - } EFFECT_TYPE; - - //! Device info. - typedef struct DEVICE_INFO_TYPE - { - //! Device types. - enum DeviceType - { - DEVICE_KEYBOARD = 1, //!< Keyboard device. - DEVICE_MOUSE = 2, //!< Mouse device. - DEVICE_HEADSET = 3, //!< Headset device. - DEVICE_MOUSEPAD = 4, //!< Mousepad device. - DEVICE_KEYPAD = 5, //!< Keypad device. - DEVICE_SYSTEM = 6, //!< System device. - DEVICE_INVALID //!< Invalid device. - } DeviceType; - - DWORD Connected; //!< Number of devices connected. - } DEVICE_INFO_TYPE; - - const RZSIZE MAX_ROW = 30; //!< Maximum rows for custom effects. - const RZSIZE MAX_COLUMN = 30; //!< Maximum columns for custom effects. - - //! Blinking effect (This effect type has deprecated and should not be used). - typedef struct BLINKING_EFFECT_TYPE - { - RZSIZE Size; //!< Size of the structure. Size = sizeof(BLINKING_EFFECT_TYPE) - DWORD Param; //!< Extra parameters. - - COLORREF Color; //!< Blinking color - } BLINKING_EFFECT_TYPE; - - //! Breathing effect (This effect type has deprecated and should not be used). - typedef struct BREATHING_EFFECT_TYPE - { - RZSIZE Size; //!< Size of ths structure. Size = sizeof(BREATHING_EFFECT_TYPE) - DWORD Param; //!< Extra parameters. - - //! Breathing effect types. - enum _Type - { - ONE_COLOR = 1, //!< 1 color (Only fill Color1). - TWO_COLORS, //!< 2 colors. - RANDOM_COLORS //!< Random colors - } Type; - - COLORREF Color1; //!< First color. - COLORREF Color2; //!< Second color. - } BREATHING_EFFECT_TYPE; - - //! Custom effect (This effect type has deprecated and should not be used). - typedef struct CUSTOM_EFFECT_TYPE - { - RZSIZE Size; //!< Size of the structure. Size = sizeof(CUSTOM_EFFECT_TYPE) - DWORD Param; //!< Extra parameters. - - RZCOLOR Color[MAX_ROW][MAX_COLUMN]; - } CUSTOM_EFFECT_TYPE; - - //! No effect. - typedef struct NO_EFFECT_TYPE - { - RZSIZE Size; //!< Size of the structure. Size = sizeof(NO_EFFECT_TYPE) - DWORD Param; //!< Extra parameters. - } NO_EFFECT_TYPE; - - //! Reactive effect (This effect type has deprecated and should not be used). - typedef struct REACTIVE_EFFECT_TYPE - { - RZSIZE Size; //!< Size of the structure. Size = sizeof(REACTIVE_EFFECT_TYPE) - DWORD Param; //!< Extra parameters. - - //! Duration of the effect. - enum _Duration - { - DURATION_SHORT = 1, //!< Short duration. - DURATION_MEDIUM, //!< Medium duration. - DURATION_LONG //!< Long duration. - } Duration; //!< The time taken for the effect to fade away. - - COLORREF Color; //!< Color of the effect. - } REACTIVE_EFFECT_TYPE; - - //! Spectrum cycling effect (This effect type has deprecated and should not be used). - typedef struct SPECTRUMCYCLING_EFFECT_TYPE - { - RZSIZE Size; //!< Size of the structure. Size = sizeof(SPECTRUMCYCLING_EFFECT_TYPE) - DWORD Param; //!< Extra parameters. - } SPECTRUMCYCLING_EFFECT_TYPE; - - //! Starlight effect (This effect type has deprecated and should not be used). - typedef struct STARLIGHT_EFFECT_TYPE - { - RZSIZE Size; //!< Size of the structure. Size = sizeof(SPECTRUMCYCLING_EFFECT_TYPE) - DWORD Param; //!< Extra parameters. - - //! Starlight effect types. - enum _Type - { - TWO_COLORS = 1, //!< 2 colors. - RANDOM_COLORS //!< Random colors - } Type; - - COLORREF Color1; //!< First color. - COLORREF Color2; //!< Second color. - - //! Duration of the effect. - enum _Duration - { - DURATION_SHORT = 1, //!< Short duration. - DURATION_MEDIUM, //!< Medium duration. - DURATION_LONG //!< Long duration. - } Duration; //!< The time taken for the effect to fade away. - - } STARLIGHT_EFFECT_TYPE; - - //! Static effect (This effect type has deprecated and should not be used). - typedef struct STATIC_EFFECT_TYPE - { - RZSIZE Size; //!< Size of the structure. Size = sizeof(STATIC_EFFECT_TYPE) - DWORD Param; //!< Extra parameters. - - COLORREF Color; //!< Color of the effect. - } STATIC_EFFECT_TYPE; - - //! Wave effect (This effect type has deprecated and should not be used). - typedef struct WAVE_EFFECT_TYPE - { - RZSIZE Size; //!< Size of the structure. Size = sizeof(WAVE_EFFECT_TYPE) - DWORD Param; //!< Extra parameters. - - //! Direction of effect. - enum _Direction - { - DIRECTION_LEFT_TO_RIGHT = 1, //!< Left to right. - DIRECTION_RIGHT_TO_LEFT, //!< Right to left. - DIRECTION_FRONT_TO_BACK, //!< Front to back - DIRECTION_BACK_TO_FRONT //!< Back top front - } Direction; - } WAVE_EFFECT_TYPE; - - //! Keyboards - namespace Keyboard - { - //! Definitions of keys. - typedef enum RZKEY - { - RZKEY_ESC = 0x0001, /*!< Esc (VK_ESCAPE) */ - RZKEY_F1 = 0x0003, /*!< F1 (VK_F1) */ - RZKEY_F2 = 0x0004, /*!< F2 (VK_F2) */ - RZKEY_F3 = 0x0005, /*!< F3 (VK_F3) */ - RZKEY_F4 = 0x0006, /*!< F4 (VK_F4) */ - RZKEY_F5 = 0x0007, /*!< F5 (VK_F5) */ - RZKEY_F6 = 0x0008, /*!< F6 (VK_F6) */ - RZKEY_F7 = 0x0009, /*!< F7 (VK_F7) */ - RZKEY_F8 = 0x000A, /*!< F8 (VK_F8) */ - RZKEY_F9 = 0x000B, /*!< F9 (VK_F9) */ - RZKEY_F10 = 0x000C, /*!< F10 (VK_F10) */ - RZKEY_F11 = 0x000D, /*!< F11 (VK_F11) */ - RZKEY_F12 = 0x000E, /*!< F12 (VK_F12) */ - RZKEY_1 = 0x0102, /*!< 1 (VK_1) */ - RZKEY_2 = 0x0103, /*!< 2 (VK_2) */ - RZKEY_3 = 0x0104, /*!< 3 (VK_3) */ - RZKEY_4 = 0x0105, /*!< 4 (VK_4) */ - RZKEY_5 = 0x0106, /*!< 5 (VK_5) */ - RZKEY_6 = 0x0107, /*!< 6 (VK_6) */ - RZKEY_7 = 0x0108, /*!< 7 (VK_7) */ - RZKEY_8 = 0x0109, /*!< 8 (VK_8) */ - RZKEY_9 = 0x010A, /*!< 9 (VK_9) */ - RZKEY_0 = 0x010B, /*!< 0 (VK_0) */ - RZKEY_A = 0x0302, /*!< A (VK_A) */ - RZKEY_B = 0x0407, /*!< B (VK_B) */ - RZKEY_C = 0x0405, /*!< C (VK_C) */ - RZKEY_D = 0x0304, /*!< D (VK_D) */ - RZKEY_E = 0x0204, /*!< E (VK_E) */ - RZKEY_F = 0x0305, /*!< F (VK_F) */ - RZKEY_G = 0x0306, /*!< G (VK_G) */ - RZKEY_H = 0x0307, /*!< H (VK_H) */ - RZKEY_I = 0x0209, /*!< I (VK_I) */ - RZKEY_J = 0x0308, /*!< J (VK_J) */ - RZKEY_K = 0x0309, /*!< K (VK_K) */ - RZKEY_L = 0x030A, /*!< L (VK_L) */ - RZKEY_M = 0x0409, /*!< M (VK_M) */ - RZKEY_N = 0x0408, /*!< N (VK_N) */ - RZKEY_O = 0x020A, /*!< O (VK_O) */ - RZKEY_P = 0x020B, /*!< P (VK_P) */ - RZKEY_Q = 0x0202, /*!< Q (VK_Q) */ - RZKEY_R = 0x0205, /*!< R (VK_R) */ - RZKEY_S = 0x0303, /*!< S (VK_S) */ - RZKEY_T = 0x0206, /*!< T (VK_T) */ - RZKEY_U = 0x0208, /*!< U (VK_U) */ - RZKEY_V = 0x0406, /*!< V (VK_V) */ - RZKEY_W = 0x0203, /*!< W (VK_W) */ - RZKEY_X = 0x0404, /*!< X (VK_X) */ - RZKEY_Y = 0x0207, /*!< Y (VK_Y) */ - RZKEY_Z = 0x0403, /*!< Z (VK_Z) */ - RZKEY_NUMLOCK = 0x0112, /*!< Numlock (VK_NUMLOCK) */ - RZKEY_NUMPAD0 = 0x0513, /*!< Numpad 0 (VK_NUMPAD0) */ - RZKEY_NUMPAD1 = 0x0412, /*!< Numpad 1 (VK_NUMPAD1) */ - RZKEY_NUMPAD2 = 0x0413, /*!< Numpad 2 (VK_NUMPAD2) */ - RZKEY_NUMPAD3 = 0x0414, /*!< Numpad 3 (VK_NUMPAD3) */ - RZKEY_NUMPAD4 = 0x0312, /*!< Numpad 4 (VK_NUMPAD4) */ - RZKEY_NUMPAD5 = 0x0313, /*!< Numpad 5 (VK_NUMPAD5) */ - RZKEY_NUMPAD6 = 0x0314, /*!< Numpad 6 (VK_NUMPAD6) */ - RZKEY_NUMPAD7 = 0x0212, /*!< Numpad 7 (VK_NUMPAD7) */ - RZKEY_NUMPAD8 = 0x0213, /*!< Numpad 8 (VK_NUMPAD8) */ - RZKEY_NUMPAD9 = 0x0214, /*!< Numpad 9 (VK_ NUMPAD9*/ - RZKEY_NUMPAD_DIVIDE = 0x0113, /*!< Divide (VK_DIVIDE) */ - RZKEY_NUMPAD_MULTIPLY = 0x0114, /*!< Multiply (VK_MULTIPLY) */ - RZKEY_NUMPAD_SUBTRACT = 0x0115, /*!< Subtract (VK_SUBTRACT) */ - RZKEY_NUMPAD_ADD = 0x0215, /*!< Add (VK_ADD) */ - RZKEY_NUMPAD_ENTER = 0x0415, /*!< Enter (VK_RETURN - Extended) */ - RZKEY_NUMPAD_DECIMAL = 0x0514, /*!< Decimal (VK_DECIMAL) */ - RZKEY_PRINTSCREEN = 0x000F, /*!< Print Screen (VK_PRINT) */ - RZKEY_SCROLL = 0x0010, /*!< Scroll Lock (VK_SCROLL) */ - RZKEY_PAUSE = 0x0011, /*!< Pause (VK_PAUSE) */ - RZKEY_INSERT = 0x010F, /*!< Insert (VK_INSERT) */ - RZKEY_HOME = 0x0110, /*!< Home (VK_HOME) */ - RZKEY_PAGEUP = 0x0111, /*!< Page Up (VK_PRIOR) */ - RZKEY_DELETE = 0x020f, /*!< Delete (VK_DELETE) */ - RZKEY_END = 0x0210, /*!< End (VK_END) */ - RZKEY_PAGEDOWN = 0x0211, /*!< Page Down (VK_NEXT) */ - RZKEY_UP = 0x0410, /*!< Up (VK_UP) */ - RZKEY_LEFT = 0x050F, /*!< Left (VK_LEFT) */ - RZKEY_DOWN = 0x0510, /*!< Down (VK_DOWN) */ - RZKEY_RIGHT = 0x0511, /*!< Right (VK_RIGHT) */ - RZKEY_TAB = 0x0201, /*!< Tab (VK_TAB) */ - RZKEY_CAPSLOCK = 0x0301, /*!< Caps Lock(VK_CAPITAL) */ - RZKEY_BACKSPACE = 0x010E, /*!< Backspace (VK_BACK) */ - RZKEY_ENTER = 0x030E, /*!< Enter (VK_RETURN) */ - RZKEY_LCTRL = 0x0501, /*!< Left Control(VK_LCONTROL) */ - RZKEY_LWIN = 0x0502, /*!< Left Window (VK_LWIN) */ - RZKEY_LALT = 0x0503, /*!< Left Alt (VK_LMENU) */ - RZKEY_SPACE = 0x0507, /*!< Spacebar (VK_SPACE) */ - RZKEY_RALT = 0x050B, /*!< Right Alt (VK_RMENU) */ - RZKEY_FN = 0x050C, /*!< Function key. */ - RZKEY_RMENU = 0x050D, /*!< Right Menu (VK_APPS) */ - RZKEY_RCTRL = 0x050E, /*!< Right Control (VK_RCONTROL) */ - RZKEY_LSHIFT = 0x0401, /*!< Left Shift (VK_LSHIFT) */ - RZKEY_RSHIFT = 0x040E, /*!< Right Shift (VK_RSHIFT) */ - RZKEY_MACRO1 = 0x0100, /*!< Macro Key 1 */ - RZKEY_MACRO2 = 0x0200, /*!< Macro Key 2 */ - RZKEY_MACRO3 = 0x0300, /*!< Macro Key 3 */ - RZKEY_MACRO4 = 0x0400, /*!< Macro Key 4 */ - RZKEY_MACRO5 = 0x0500, /*!< Macro Key 5 */ - RZKEY_OEM_1 = 0x0101, /*!< ~ (tilde/半角/全角) (VK_OEM_3) */ - RZKEY_OEM_2 = 0x010C, /*!< -- (minus) (VK_OEM_MINUS) */ - RZKEY_OEM_3 = 0x010D, /*!< = (equal) (VK_OEM_PLUS) */ - RZKEY_OEM_4 = 0x020C, /*!< [ (left sqaure bracket) (VK_OEM_4) */ - RZKEY_OEM_5 = 0x020D, /*!< ] (right square bracket) (VK_OEM_6) */ - RZKEY_OEM_6 = 0x020E, /*!< \ (backslash) (VK_OEM_5) */ - RZKEY_OEM_7 = 0x030B, /*!< ; (semi-colon) (VK_OEM_1) */ - RZKEY_OEM_8 = 0x030C, /*!< ' (apostrophe) (VK_OEM_7) */ - RZKEY_OEM_9 = 0x040A, /*!< , (comma) (VK_OEM_COMMA) */ - RZKEY_OEM_10 = 0x040B, /*!< . (period) (VK_OEM_PERIOD) */ - RZKEY_OEM_11 = 0x040C, /*!< / (forward slash) (VK_OEM_2) */ - RZKEY_EUR_1 = 0x030D, /*!< "#" (VK_OEM_5) */ - RZKEY_EUR_2 = 0x0402, /*!< \ (VK_OEM_102) */ - RZKEY_JPN_1 = 0x0015, /*!< ¥ (0xFF) */ - RZKEY_JPN_2 = 0x040D, /*!< \ (0xC1) */ - RZKEY_JPN_3 = 0x0504, /*!< 無変換 (VK_OEM_PA1) */ - RZKEY_JPN_4 = 0x0509, /*!< 変換 (0xFF) */ - RZKEY_JPN_5 = 0x050A, /*!< ひらがな/カタカナ (0xFF) */ - RZKEY_KOR_1 = 0x0015, /*!< | (0xFF) */ - RZKEY_KOR_2 = 0x030D, /*!< (VK_OEM_5) */ - RZKEY_KOR_3 = 0x0402, /*!< (VK_OEM_102) */ - RZKEY_KOR_4 = 0x040D, /*!< (0xC1) */ - RZKEY_KOR_5 = 0x0504, /*!< (VK_OEM_PA1) */ - RZKEY_KOR_6 = 0x0509, /*!< 한/영 (0xFF) */ - RZKEY_KOR_7 = 0x050A, /*!< (0xFF) */ - RZKEY_INVALID = 0xFFFF /*!< Invalid keys. */ - } RZKEY; - - //! Definition of LEDs. - typedef enum RZLED - { - RZLED_LOGO = 0x0014 /*!< Razer logo */ - } RZLED; - - //! Maximum number of rows in a keyboard. - const RZSIZE MAX_ROW = 6; - - //! Maximum number of columns in a keyboard. - const RZSIZE MAX_COLUMN = 22; - - //! Maximum number of keys. - const RZSIZE MAX_KEYS = MAX_ROW * MAX_COLUMN; - - //! Maximum number of custom effects. - const RZSIZE MAX_CUSTOM_EFFECTS = MAX_KEYS; - - //! Keyboard LED layout. - const COLORREF RZKEY_LAYOUT[MAX_ROW][MAX_COLUMN] = {}; - - //! Chroma keyboard effect types - typedef enum EFFECT_TYPE - { - CHROMA_NONE = 0, //!< No effect. - CHROMA_BREATHING, //!< Breathing effect (This effect has deprecated and should not be used). - CHROMA_CUSTOM, //!< Custom effect. - CHROMA_REACTIVE, //!< Reactive effect (This effect has deprecated and should not be used). - CHROMA_STATIC, //!< Static effect. - CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect (This effect has deprecated and should not be used). - CHROMA_WAVE, //!< Wave effect (This effect has deprecated and should not be used). - CHROMA_RESERVED, //!< Reserved. - CHROMA_CUSTOM_KEY, //!< Custom effects with keys. - CHROMA_INVALID //!< Invalid effect. - } EFFECT_TYPE; - - // Chroma keyboard effects - //! Breathing effect type (This effect has deprecated and should not be used). - typedef struct BREATHING_EFFECT_TYPE - { - //! Breathing effects. - enum Type - { - TWO_COLORS = 1, //!< 2 colors - RANDOM_COLORS, //!< Random colors - INVALID //!< Invalid type - } Type; - COLORREF Color1; //!< First color. - COLORREF Color2; //!< Second color. - } BREATHING_EFFECT_TYPE; - - //! Custom effect using a matrix type. - typedef struct CUSTOM_EFFECT_TYPE - { - COLORREF Color[MAX_ROW][MAX_COLUMN]; //!< Grid layout. 6 rows by 22 columns. - } CUSTOM_EFFECT_TYPE; - - //! Custom effect with keys. - typedef struct CUSTOM_KEY_EFFECT_TYPE - { - COLORREF Color[MAX_ROW][MAX_COLUMN]; //!< Grid layout. 6 rows by 22 columns. - COLORREF Key[MAX_ROW][MAX_COLUMN]; //!< Keys information. 6 rows by 22 columns. To indidate there is a key effect, OR with 0x01000000. i.e. Key[0][1] = 0x01000000 | Color; - } CUSTOM_KEY_EFFECT_TYPE; - - //! Reactive effect type (This effect has deprecated and should not be used). - typedef struct REACTIVE_EFFECT_TYPE - { - //! Duration of the effect. - enum Duration - { - DURATION_NONE=0, //!< No duration. - DURATION_SHORT, //!< Short duration. - DURATION_MEDIUM, //!< Medium duration. - DURATION_LONG, //!< Long duration. - DURATION_INVALID //!< Invalid duration. - } Duration; //!< The time taken for the effect to fade away. - - COLORREF Color; //!< Color of the effect - } REACTIVE_EFFECT_TYPE; - - //! Starlight effect (This effect has deprecated and should not be used). - typedef struct STARLIGHT_EFFECT_TYPE - { - //! Starlight effect types. - enum _Type - { - TWO_COLORS = 1, //!< 2 colors. - RANDOM_COLORS //!< Random colors - } Type; - - COLORREF Color1; //!< First color. - COLORREF Color2; //!< Second color. - - //! Duration of the effect. - enum _Duration - { - DURATION_SHORT = 1, //!< Short duration. - DURATION_MEDIUM, //!< Medium duration. - DURATION_LONG //!< Long duration. - } Duration; //!< The time taken for the effect to fade away. - - } STARLIGHT_EFFECT_TYPE; - - //! Static effect type - typedef struct STATIC_EFFECT_TYPE - { - COLORREF Color; //!< Color of the effect - } STATIC_EFFECT_TYPE; - - //! Wave effect type (This effect has deprecated and should not be used). - typedef struct WAVE_EFFECT_TYPE - { - //! Direction of the wave effect. - enum Direction - { - DIRECTION_NONE=0, //!< No direction. - DIRECTION_LEFT_TO_RIGHT, //!< Left to right. - DIRECTION_RIGHT_TO_LEFT, //!< Right to left. - DIRECTION_INVALID //!< Invalid direction. - } Direction; //!< Direction of the wave. - } WAVE_EFFECT_TYPE; - } - - //! Mice - namespace Mouse - { - //! Maximum number of custom LEDs (old definition to maintain backward compatibility). - const RZSIZE MAX_LEDS = 30; - - //! Mice LED layout (old definition to maintain backward compatibility). - const RZCOLOR RZLED_LAYOUT[MAX_LEDS] = {}; - - //! Maximum number of rows of the virtual grid. - const RZSIZE MAX_ROW = 9; - - //! Maximum number of columns of the virtual grid. - const RZSIZE MAX_COLUMN = 7; - - //! Maximum number of LEDs of the virtual grid. - const RZSIZE MAX_LEDS2 = MAX_ROW * MAX_COLUMN; - - //! Mice LED virtual grid layout. - const RZCOLOR RZLED_LAYOUT2[MAX_ROW][MAX_COLUMN] = {}; - - //! Mouse LED Id defintion (This effect type has deprecated and should not be used). - typedef enum RZLED - { - RZLED_NONE = 0, //!< No LED. - RZLED_SCROLLWHEEL = 1, //!< Scroll Wheel LED. - RZLED_LOGO = 2, //!< Logo LED. - RZLED_BACKLIGHT = 3, //!< Backlight or numpad. - RZLED_SIDE_STRIP1 = 4, //!< Side strip LED 1. (For Mamba TE, starts from top left hand) - RZLED_SIDE_STRIP2 = 5, //!< Side strip LED 2. (For Mamba TE) - RZLED_SIDE_STRIP3 = 6, //!< Side strip LED 3. (For Mamba TE) - RZLED_SIDE_STRIP4 = 7, //!< Side strip LED 4. (For Mamba TE) - RZLED_SIDE_STRIP5 = 8, //!< Side strip LED 5. (For Mamba TE) - RZLED_SIDE_STRIP6 = 9, //!< Side strip LED 6. (For Mamba TE) - RZLED_SIDE_STRIP7 = 10, //!< Side strip LED 7. (For Mamba TE) - RZLED_SIDE_STRIP8 = 11, //!< Side strip LED 8. (For Mamba TE) - RZLED_SIDE_STRIP9 = 12, //!< Side strip LED 9. (For Mamba TE) - RZLED_SIDE_STRIP10 = 13, //!< Side strip LED 10. (For Mamba TE) - RZLED_SIDE_STRIP11 = 14, //!< Side strip LED 11. (For Mamba TE) - RZLED_SIDE_STRIP12 = 15, //!< Side strip LED 12. (For Mamba TE) - RZLED_SIDE_STRIP13 = 16, //!< Side strip LED 13. (For Mamba TE) - RZLED_SIDE_STRIP14 = 17, //!< Side strip LED 14. (For Mamba TE) - RZLED_ALL = 0xFFFF - } RZLED; - - //! Mouse LED Id defintion for the virtual grid. - typedef enum RZLED2 - { - RZLED2_SCROLLWHEEL = 0x0203, //!< Scroll Wheel LED. - RZLED2_LOGO = 0x0703, //!< Logo LED. - RZLED2_BACKLIGHT = 0x0403, //!< Backlight LED. - RZLED2_LEFT_SIDE1 = 0x0100, //!< Left LED 1. - RZLED2_LEFT_SIDE2 = 0x0200, //!< Left LED 2. - RZLED2_LEFT_SIDE3 = 0x0300, //!< Left LED 3. - RZLED2_LEFT_SIDE4 = 0x0400, //!< Left LED 4. - RZLED2_LEFT_SIDE5 = 0x0500, //!< Left LED 5. - RZLED2_LEFT_SIDE6 = 0x0600, //!< Left LED 6. - RZLED2_LEFT_SIDE7 = 0x0700, //!< Left LED 7. - RZLED2_BOTTOM1 = 0x0801, //!< Bottom LED 1. - RZLED2_BOTTOM2 = 0x0802, //!< Bottom LED 2. - RZLED2_BOTTOM3 = 0x0803, //!< Bottom LED 3. - RZLED2_BOTTOM4 = 0x0804, //!< Bottom LED 4. - RZLED2_BOTTOM5 = 0x0805, //!< Bottom LED 5. - RZLED2_RIGHT_SIDE1 = 0x0106, //!< Right LED 1. - RZLED2_RIGHT_SIDE2 = 0x0206, //!< Right LED 2. - RZLED2_RIGHT_SIDE3 = 0x0306, //!< Right LED 3. - RZLED2_RIGHT_SIDE4 = 0x0406, //!< Right LED 4. - RZLED2_RIGHT_SIDE5 = 0x0506, //!< Right LED 5. - RZLED2_RIGHT_SIDE6 = 0x0606, //!< Right LED 6. - RZLED2_RIGHT_SIDE7 = 0x0706 //!< Right LED 7. - } RZLED2; - - //! Chroma mouse effect types - typedef enum EFFECT_TYPE - { - CHROMA_NONE = 0, //!< No effect. - CHROMA_BLINKING, //!< Blinking effect (This effect has deprecated and should not be used). - CHROMA_BREATHING, //!< Breathing effect (This effect has deprecated and should not be used). - CHROMA_CUSTOM, //!< Custom effect (old definition to maintain backward compatibility). - CHROMA_REACTIVE, //!< Reactive effect (This effect has deprecated and should not be used). - CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect (This effect has deprecated and should not be used). - CHROMA_STATIC, //!< Static effect. - CHROMA_WAVE, //!< Wave effect (This effect has deprecated and should not be used). - CHROMA_CUSTOM2, //!< Custom effects using a virtual grid. - CHROMA_INVALID //!< Invalid effect. - } EFFECT_TYPE; - - //! Static effect type - typedef struct STATIC_EFFECT_TYPE - { - RZLED LEDId; //!< LED Id - COLORREF Color; //!< Color of the effect. - } STATIC_EFFECT_TYPE; - - //! Blinking effect type (This effect has deprecated and should not be used). - typedef struct BLINKING_EFFECT_TYPE - { - RZLED LEDId; //!< LED Id - COLORREF Color; //!< Color. - } BLINKING_EFFECT_TYPE; - - //! Breathing effect (This effect has deprecated and should not be used). - typedef struct BREATHING_EFFECT_TYPE - { - RZLED LEDId; //!< LED Id - - //! Breathing type. - enum Type - { - ONE_COLOR = 1, //!< 1 color (Only fill Color1). - TWO_COLORS, //!< 2 colors. - RANDOM_COLORS, //!< Random colors - INVALID //!< Invalid type - } Type; - - COLORREF Color1; //!< First color. - COLORREF Color2; //!< Second color. - } BREATHING_EFFECT_TYPE; - - //! Custom effect (This effect type has deprecated and should not be used). - typedef struct CUSTOM_EFFECT_TYPE - { - RZCOLOR Color[MAX_LEDS]; //!< Array of colors. - } CUSTOM_EFFECT_TYPE; - - //! Custom effect using virtual grid. - //! Indexes of the LED are defined in RZLED2.i.e. Row = HIBYTE(RZLED2_SCROLLWHEEL), Column = LOBYTE(RZLED2_SCROLLWHEEL) - typedef struct CUSTOM_EFFECT_TYPE2 - { - RZCOLOR Color[MAX_ROW][MAX_COLUMN]; //!< Array of colors. - } CUSTOM_EFFECT_TYPE2; - - //! Reactive effect (This effect has deprecated and should not be used). - typedef struct REACTIVE_EFFECT_TYPE - { - RZLED LEDId; //!< LED Id - - //! Duration of the effect. - enum Duration - { - DURATION_NONE=0, //!< No duration. - DURATION_SHORT, //!< Short duration. - DURATION_MEDIUM, //!< Medium duration. - DURATION_LONG //!< Long duration. - } Duration; - - RZCOLOR Color; //!< Color of the effect. - } REACTIVE_EFFECT_TYPE; - - //! No effect (This effect has deprecated and should not be used). - typedef struct NO_EFFECT_TYPE - { - RZLED LEDId; //!< LED Id - } NO_EFFECT_TYPE; - - //! Spectrum cycling (This effect has deprecated and should not be used). - typedef struct SPECTRUMCYCLING_EFFECT_TYPE - { - RZLED LEDId; //!< LED id. - } SPECTRUMCYCLING_EFFECT_TYPE; - - //! Wave effect (This effect has deprecated and should not be used). - typedef struct WAVE_EFFECT_TYPE - { - //! Direction of the wave effect. - enum Direction - { - FRONT_TO_BACK, //!< Front to back - BACK_TO_FRONT //!< Back to front - } Direction; - } WAVE_EFFECT_TYPE; - } - - //! Headsets - namespace Headset - { - //! Maximum number of LEDs - const RZSIZE MAX_LEDS = 5; - - //! Chroma headset effect types - typedef enum EFFECT_TYPE - { - CHROMA_NONE = 0, //!< No effect. - CHROMA_STATIC, //!< Static effect. - CHROMA_BREATHING, //!< Breathing effect (This effect has deprecated and should not be used). - CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect (This effect has deprecated and should not be used). - CHROMA_CUSTOM, //!< Custom effects. - CHROMA_INVALID //!< Invalid effect. - } EFFECT_TYPE; - - //! Static effect type - typedef struct STATIC_EFFECT_TYPE - { - COLORREF Color; //!< Color of the effect. - } STATIC_EFFECT_TYPE; - - //! Breathing effect type (This effect has deprecated and should not be used). - typedef struct BREATHING_EFFECT_TYPE - { - COLORREF Color; //!< Color. - } BREATHING_EFFECT_TYPE; - - //! Custom effect type. - typedef struct CUSTOM_EFFECT_TYPE - { - RZCOLOR Color[MAX_LEDS]; //!< Array of colors. - } CUSTOM_EFFECT_TYPE; - } - - //! Mousepads - namespace Mousepad - { - //! Maximum number of LEDs - const RZSIZE MAX_LEDS = 15; - - //! Chroma mousepad effect types - typedef enum EFFECT_TYPE - { - CHROMA_NONE = 0, //!< No effect. - CHROMA_BREATHING, //!< Breathing effect (This effect has deprecated and should not be used). - CHROMA_CUSTOM, //!< Custom effect. - CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect (This effect has deprecated and should not be used). - CHROMA_STATIC, //!< Static effect. - CHROMA_WAVE, //!< Wave effect (This effect has deprecated and should not be used). - CHROMA_INVALID //!< Invalid effect. - } EFFECT_TYPE; - - // Chroma mousepad effects - //! Breathing effect type (This effect has deprecated and should not be used). - typedef struct BREATHING_EFFECT_TYPE - { - //! Breathing effects. - enum Type - { - TWO_COLORS = 1, //!< 2 colors - RANDOM_COLORS, //!< Random colors - INVALID - } Type; - COLORREF Color1; //!< First color. - COLORREF Color2; //!< Second color. - } BREATHING_EFFECT_TYPE; - - //! Custom effect type. - typedef struct CUSTOM_EFFECT_TYPE - { - RZCOLOR Color[MAX_LEDS]; //!< An array of colors for all the sides of the mousepad. First LED starts from top-right corner. - //!< LED 0-4 right side, 5-9 bottom side, 10-14 left side. - } CUSTOM_EFFECT_TYPE; - - //! Static effect type - typedef struct STATIC_EFFECT_TYPE - { - COLORREF Color; //!< Color of the effect - } STATIC_EFFECT_TYPE; - - //! Wave effect type - typedef struct WAVE_EFFECT_TYPE - { - //! Direction of the wave effect. - enum Direction - { - DIRECTION_NONE=0, //!< No direction. - DIRECTION_LEFT_TO_RIGHT, //!< Left to right. - DIRECTION_RIGHT_TO_LEFT, //!< Right to left. - DIRECTION_INVALID //!< Invalid direction. - } Direction; //!< Direction of the wave. - } WAVE_EFFECT_TYPE; - } - - //! Keypads - namespace Keypad - { - //! Maximum number of rows. - const RZSIZE MAX_ROW = 4; - - //! Maximum number of columns. - const RZSIZE MAX_COLUMN = 5; - - //! Total number of keys. - const RZSIZE MAX_KEYS = MAX_ROW * MAX_COLUMN; - - //! Chroma keypad effect types - typedef enum EFFECT_TYPE - { - CHROMA_NONE = 0, //!< No effect. - CHROMA_BREATHING, //!< Breathing effect (This effect has deprecated and should not be used). - CHROMA_CUSTOM, //!< Custom effect. - CHROMA_REACTIVE, //!< Reactive effect (This effect has deprecated and should not be used). - CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect (This effect has deprecated and should not be used). - CHROMA_STATIC, //!< Static effect. - CHROMA_WAVE, //!< Wave effect (This effect has deprecated and should not be used). - CHROMA_INVALID //!< Invalid effect. - } EFFECT_TYPE; - - // Chroma keypad effects - //! Breathing effect type (This effect has deprecated and should not be used). - typedef struct BREATHING_EFFECT_TYPE - { - //! Breathing effects. - enum Type - { - TWO_COLORS = 1, //!< 2 colors - RANDOM_COLORS, //!< Random colors - INVALID //!< Invalid type - } Type; - COLORREF Color1; //!< First color. - COLORREF Color2; //!< Second color. - } BREATHING_EFFECT_TYPE; - - //! Custom effect type - typedef struct CUSTOM_EFFECT_TYPE - { - RZCOLOR Color[MAX_ROW][MAX_COLUMN]; //!< Custom effect. - //!< For Razer Tartarus Chroma only Color[0] is valid. Use index '0' to change the keypad color. - } CUSTOM_EFFECT_TYPE; - - //! Reactive effect type (This effect has deprecated and should not be used). - typedef struct REACTIVE_EFFECT_TYPE - { - //! Duration of the effect. - enum Duration - { - DURATION_NONE=0, //!< No duration. - DURATION_SHORT, //!< Short duration. - DURATION_MEDIUM, //!< Medium duration. - DURATION_LONG, //!< Long duration. - DURATION_INVALID //!< Invalid duration. - } Duration; //!< The time taken for the effect to fade away. - - COLORREF Color; //!< Color of the effect - } REACTIVE_EFFECT_TYPE; - - //! Static effect type - typedef struct STATIC_EFFECT_TYPE - { - RZCOLOR Color; //!< Color of the effect. - } STATIC_EFFECT_TYPE; - - //! Wave effect type (This effect has deprecated and should not be used). - typedef struct WAVE_EFFECT_TYPE - { - //! Direction of the wave effect. - enum Direction - { - DIRECTION_NONE=0, //!< No direction. - DIRECTION_LEFT_TO_RIGHT, //!< Left to right. - DIRECTION_RIGHT_TO_LEFT, //!< Right to left. - DIRECTION_INVALID //!< Invalid direction. - } Direction; //!< Direction of the wave. - } WAVE_EFFECT_TYPE; - } - - //! Chroma Link - namespace ChromaLink - { - //! Maximum number of elements/LEDs - const RZSIZE MAX_LEDS = 5; - - //! Chroma Link effect types - typedef enum EFFECT_TYPE - { - CHROMA_NONE = 0, //!< No effect. - CHROMA_CUSTOM, //!< Custom effect. - CHROMA_STATIC, //!< Static effect. - CHROMA_INVALID //!< Invalid effect. - } EFFECT_TYPE; - - //! Custom effect type - typedef struct CUSTOM_EFFECT_TYPE - { - RZCOLOR Color[MAX_LEDS]; //!< Array of colors. - } CUSTOM_EFFECT_TYPE; - - //! Static effect type - typedef struct STATIC_EFFECT_TYPE - { - RZCOLOR Color; //!< Color of the effect. - } STATIC_EFFECT_TYPE; - } -} - -#endif diff --git a/chromasdk/RzErrors.h b/chromasdk/RzErrors.h deleted file mode 100644 index 2308d368..00000000 --- a/chromasdk/RzErrors.h +++ /dev/null @@ -1,46 +0,0 @@ - -//! \file RzErrors.h -//! \brief Error codes for Chroma SDK. If the error is not defined here, refer to WinError.h from the Windows SDK. - -#ifndef _RZERRORS_H_ -#define _RZERRORS_H_ - -#pragma once - -// Error codes -//! Invalid -#define RZRESULT_INVALID -1L -//! Success -#define RZRESULT_SUCCESS 0L -//! Access denied -#define RZRESULT_ACCESS_DENIED 5L -//! Invalid handle -#define RZRESULT_INVALID_HANDLE 6L -//! Not supported -#define RZRESULT_NOT_SUPPORTED 50L -//! Invalid parameter. -#define RZRESULT_INVALID_PARAMETER 87L -//! The service has not been started -#define RZRESULT_SERVICE_NOT_ACTIVE 1062L -//! Cannot start more than one instance of the specified program. -#define RZRESULT_SINGLE_INSTANCE_APP 1152L -//! Device not connected -#define RZRESULT_DEVICE_NOT_CONNECTED 1167L -//! Element not found. -#define RZRESULT_NOT_FOUND 1168L -//! Request aborted. -#define RZRESULT_REQUEST_ABORTED 1235L -//! An attempt was made to perform an initialization operation when initialization has already been completed. -#define RZRESULT_ALREADY_INITIALIZED 1247L -//! Resource not available or disabled -#define RZRESULT_RESOURCE_DISABLED 4309L -//! Device not available or supported -#define RZRESULT_DEVICE_NOT_AVAILABLE 4319L -//! The group or resource is not in the correct state to perform the requested operation. -#define RZRESULT_NOT_VALID_STATE 5023L -//! No more items -#define RZRESULT_NO_MORE_ITEMS 259L -//! General failure. -#define RZRESULT_FAILED 2147500037L - -#endif diff --git a/conanfile.py b/conanfile.py deleted file mode 100644 index 2abc0a0f..00000000 --- a/conanfile.py +++ /dev/null @@ -1,183 +0,0 @@ -import os.path -import datetime - -from conans import CMake, ConanFile, tools, AutoToolsBuildEnvironment -from conans.client.tools import win -from conans.errors import ConanException - -MODSHOT_VERSION_H='''#ifndef MODSHOT_VERSION -#define MODSHOT_VERSION "%s" -#endif -''' - -class MkxpConan(ConanFile): - name = "oneshot" - version = "0.0.0" - license = "GPLv2" - url = "https://github.com/elizagamedev/mkxp-oneshot" - description = "OneShot game runtime" - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" - exports_sources = "*" - requires = ( - "boost/1.77.0", - "openal/1.18.2@bincrafters/stable", - "physfs/3.0.1@astrabit/testing", - "pixman/0.34.0@astrabit/testing", - "ruby/3.0.2@astrabit/testing", - "sdl2_image/2.0.5@bincrafters/stable", - "sdl2_ttf/2.0.15@bincrafters/stable", - "sdl_sound-mkxp/1.0.1@eliza/stable", - "sigc++/2.10.0@astrabit/testing", - # Overrides - "libpng/1.6.37", - "zlib/1.2.11", - "bzip2/1.0.8", - "giflib/5.2.1", - "libffi/3.4.2" - ) - build_requires = ("ruby_installer/3.0.2@astrabit/testing") - options = { - "platform": ["standalone", "steam"], - "msys2": [True, False], - } - default_options = ( - "platform=standalone", - "boost:without_test=True", - "boost:without_fiber=True", - "cygwin_installer:packages=xxd", - # Avoid dead url bitrot in cygwin_installer - "cygwin_installer:with_pear=False", - "ruby:with_openssl=True", - "msys2=False", - ) - - #def build_requirements(self): - # if tools.os_info.is_windows: - # self.build_requires("cygwin_installer/2.9.0@bincrafters/stable") - - def requirements(self): - if tools.os_info.is_linux: - # Overrides - self.requires("sqlite3/3.29.0") - self.requires("flac/1.3.3") - self.requires("ogg/1.3.4") - self.requires("vorbis/1.3.6") - self.requires("libalsa/1.1.9") - self.requires("sdl2/2.0.9@bincrafters/stable") - self.requires("openssl/1.1.1l") - if tools.os_info.is_windows: - self.requires("sdl2/2.0.14@bincrafters/stable") - self.requires("openssl/1.1.1k") - - def build_requirements(self): - if self.options.msys2: - self.build_requires("msys2/cci.latest") - self.build_requires("mingw-w64/8.1") - - def configure(self): - if tools.os_info.is_windows: - # ??? - self.options["openal"].shared = True - # Fix linker error in SDL_sound fork with SDL2 - self.options["sdl2"].shared = True - self.options["openssl"].shared = True - win_bash = self.settings.compiler != "Visual Studio" - if win_bash or self.options.msys2: - self.win_bash = win_bash - - def generate_version_number(self): - try: - git = tools.Git(self.source_folder) - revision = git.get_commit()[0:7] - if not git.is_pristine(): - revision += "-dirty" - except ConanException: - # this is either not a git repo, or we don't have git on the system - revision = "nongit" - revision += datetime.datetime.now().strftime("-%y%m%d-%H%M%S") - - tools.save(os.path.join(self.source_folder, 'src/version.h'), MODSHOT_VERSION_H%revision) - - def build_configure(self): - self.generate_version_number() - - cmake = CMake(self, msbuild_verbosity='minimal') - if self.options.platform == "steam": - cmake.definitions["STEAM"] = "ON" - cmake.configure() - cmake.build() - - #if self.options.platform == "steam": - # cmake_command = f"cmake -D STEAM=ON {self.source_folder}" - # if self.options.msys2: - # cmake_command += " -G \"MinGW Makefiles\"" - #else: - # cmake_command = f"cmake {self.source_folder}" - # if self.options.msys2: - # cmake_command += " -G \"MinGW Makefiles\"" - #self.run(cmake_command) - #self.run("make") - - #autotools = AutoToolsBuildEnvironment(self, win_bash=self.options.msys2) - #if self.options.platform == "steam": - # autotools.defines.append("STEAM=ON") - # autotools.configure() - # autotools.make() - - def build(self): - #if tools.os_info.is_windows: - # cygwin_bin = self.deps_env_info["cygwin_installer"].CYGWIN_BIN - # with tools.environment_append({ - # "PATH": [cygwin_bin], - # "CONAN_BASH_PATH": - # os.path.join(cygwin_bin, "bash.exe") - # }): - # self.build_configure() - #else: - # self.build_configure() - self.build_configure() - - # ship certificates into the ssl folder in the game directory - # openssl will use this folder since we hardcoded it in binding-mri.cpp - tools.download("https://curl.haxx.se/ca/cacert.pem", "bin/lib/cacert.pem", overwrite=True) - - def package(self): - self.copy("*", dst="bin", src="bin") - - #def package_info(self): - # if self.options.msys2: - # self.conf_info["tools.microsoft.bash:subsystem"] = "msys2" - # self.conf_info["tools.microsoft.bash:path"] = "C:\\msys64\\usr\\bin\\bash.exe" - - def imports(self): - self.do_copy_deps(self.copy) - - def deploy(self): - self.copy("*") - self.do_copy_deps(self.copy_deps) - - def do_copy_deps(self, copy): - deps = set(self.deps_cpp_info.deps) - set( - ("cygwin_installer", "msys2_installer", "ruby_installer")) - for dep in deps: - copy("*.dll", - dst="bin", - src="bin", - root_package=dep, - keep_path=False) - copy("*.so*", - dst="lib", - src="lib", - root_package=dep, - keep_path=True) - if self.settings.build_type == "Debug": - copy("*.pdb", dst="bin", root_package=dep, keep_path=False) - # copy the ruby standard library - # this is a very ugly way of doing this (putting it in bin instead of lib) - # but this makes distributing mods easier, and also makes sure windows and linux are mostly the same - copy("*", - dst="bin/lib/ruby/", - src="lib/ruby/3.1.0/", - root_package="ruby", - keep_path=True) diff --git a/linux/.gitignore b/linux/.gitignore new file mode 100644 index 00000000..6ae7aea0 --- /dev/null +++ b/linux/.gitignore @@ -0,0 +1,2 @@ +downloads/ +build-*/ diff --git a/linux/Makefile b/linux/Makefile new file mode 100644 index 00000000..bb203768 --- /dev/null +++ b/linux/Makefile @@ -0,0 +1,116 @@ +ARCH := $(shell uname -m) + +RUBY_FLAGS := ${RUBY_FLAGS} +RUBY_VER ?= "3.1" +RUBY_BRANCH = $(subst .,_,$(RUBY_VER)) + +BUILD_PREFIX := ${PWD}/build-$(ARCH) +LIBDIR := $(BUILD_PREFIX)/lib +INCLUDEDIR := $(BUILD_PREFIX)/include +DOWNLOADS := ${PWD}/downloads/$(ARCH) +NPROC := $(shell nproc) +CFLAGS := -I$(INCLUDEDIR) -flax-vector-conversions +LDFLAGS := -L$(LIBDIR) +CC := gcc +PKG_CONFIG_LIBDIR := $(BUILD_PREFIX)/lib/pkgconfig +GIT := git +CLONE := $(GIT) clone -q +GITHUB := https://github.com + +CONFIGURE_ENV := \ + PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR) \ + CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" + +CONFIGURE_ARGS := --prefix="$(BUILD_PREFIX)" + +CMAKE_ARGS := \ + -DCMAKE_INSTALL_PREFIX="$(BUILD_PREFIX)" \ + -DCMAKE_C_FLAGS="$(CFLAGS)" + +RUBY_CONFIGURE_ARGS := \ + --disable-install-doc \ + --enable-shared + +CONFIGURE := $(CONFIGURE_ENV) ./configure $(CONFIGURE_ARGS) +AUTOGEN := $(CONFIGURE_ENV) ./autogen.sh $(CONFIGURE_ARGS) +CMAKE := $(CONFIGURE_ENV) cmake .. $(CMAKE_ARGS) + +default: everything + +# iconv +iconv: init_dirs $(LIBDIR)/libiconv.a + +$(LIBDIR)/libiconv.a: $(DOWNLOADS)/iconv/Makefile + cd $(DOWNLOADS)/iconv; make; make install + +$(DOWNLOADS)/iconv/Makefile: $(DOWNLOADS)/iconv/configure + cd $(DOWNLOADS)/iconv; \ + $(CONFIGURE) --enable-static=true --enable-shared=false + +$(DOWNLOADS)/iconv/configure: $(DOWNLOADS)/libiconv-1.16.tar.gz + cd $(DOWNLOADS); \ + tar -xzf libiconv-1.16.tar.gz; \ + mv libiconv-1.16 iconv + +$(DOWNLOADS)/libiconv-1.16.tar.gz: + wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz -P $(DOWNLOADS) + +# SDL_sound +sdlsound: init_dirs $(LIBDIR)/libSDL2_sound.a + +$(LIBDIR)/libSDL2_sound.a: $(DOWNLOADS)/sdl_sound/cmakebuild/Makefile + cd $(DOWNLOADS)/sdl_sound/cmakebuild; \ + make -j$(NPROC); make install + +$(DOWNLOADS)/sdl_sound/cmakebuild/Makefile: $(DOWNLOADS)/sdl_sound/CMakeLists.txt + cd $(DOWNLOADS)/sdl_sound; mkdir -p cmakebuild; cd cmakebuild; \ + $(CMAKE) \ + -DSDLSOUND_BUILD_TEST=false + +$(DOWNLOADS)/sdl_sound/CMakeLists.txt: + $(CLONE) $(GITHUB)/icculus/SDL_sound $(DOWNLOADS)/sdl_sound + +# Standard ruby +ruby: init_dirs $(BUILD_PREFIX)/libruby.so.$(RUBY_VER) + +$(BUILD_PREFIX)/libruby.so.$(RUBY_VER): $(DOWNLOADS)/ruby/Makefile + cd $(DOWNLOADS)/ruby; \ + make -j$(NPROC); make install + +$(DOWNLOADS)/ruby/Makefile: $(DOWNLOADS)/ruby/configure + cd $(DOWNLOADS)/ruby; \ + $(CONFIGURE) $(RUBY_CONFIGURE_ARGS) $(RUBY_FLAGS) + +$(DOWNLOADS)/ruby/configure: $(DOWNLOADS)/ruby/*.c + cd $(DOWNLOADS)/ruby; autoreconf -i + +$(DOWNLOADS)/ruby/*.c: + $(CLONE) $(GITHUB)/ruby/ruby $(DOWNLOADS)/ruby -b ruby_$(RUBY_BRANCH); + +libnsgif: init_dirs ${LIBDIR}/libnsgif.so + +$(LIBDIR)/libnsgif.so: $(DOWNLOADS)/libnsgif/Makefile + cd $(DOWNLOADS)/libnsgif; \ + make -j$(NPROC); make install + +$(DOWNLOADS)/libnsgif/Makefile: $(DOWNLOADS)/libnsgif/configure + cd $(DOWNLOADS)/libnsgif; \ + $(CONFIGURE) + +$(DOWNLOADS)/libnsgif/configure: $(DOWNLOADS)/libnsgif/autogen.sh + cd $(DOWNLOADS)/libnsgif; ./autogen.sh + +$(DOWNLOADS)/libnsgif/autogen.sh: + $(CLONE) $(GITHUB)/jcupitt/libnsgif-autotools $(DOWNLOADS)/libnsgif + +# ==== +init_dirs: + @mkdir -p $(LIBDIR) $(INCLUDEDIR) + +powerwash: clean-downloads + +clean-downloads: + -rm -rf downloads + +deps-core: sdlsound iconv libnsgif +everything: deps-core ruby diff --git a/linux/install.sh b/linux/install.sh new file mode 100644 index 00000000..1569d28c --- /dev/null +++ b/linux/install.sh @@ -0,0 +1,53 @@ +#!/bin/bash +BINARY=$1 +RUBY_VER=$2 + +MODSHOT_PREFIX=$(uname -m) +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +RUBY_LIB_DIR="$DIR/build-${MODSHOT_PREFIX}/lib/ruby" + +EXCLUDELIST=https://raw.githubusercontent.com/AppImage/pkg2appimage/master/excludelist +SO_BLACKLIST="$(curl -sL $EXCLUDELIST | grep -o '^[^ #]*')" +SO_PROCESSED="" + +function fail() { + echo "$1" + echo "Please beat the crap out of rkevin until he fixes this issue." + exit 1 +} + +function copy_dependencies() { + if [[ $SO_BLACKLIST =~ $1 ]]; then + return + fi + if [[ $SO_PROCESSED =~ $1 ]]; then + return + fi + [[ ! $1 =~ ^[a-zA-Z0-9+\._-]*$ ]] && fail "The library $1 has weird characters!" + + SO_PROCESSED="$SO_PROCESSED $1" + cp "$2" "$DESTDIR/$1" + patchelf --set-rpath '$ORIGIN' "$DESTDIR/$1" + ldd "$2" | while read -ra line; do + if [[ ${line[0]} == 'linux-vdso.so.1' ]] || [[ ${line[0]} =~ 'ld-linux-x86-64.so.2' ]]; then + continue + fi + [[ ${line[1]} != '=>' ]] && echo ${line[*]} && fail "ldd's output isn't what this script expected!" + [[ ! ${line[3]} =~ ^\(0x[0-9a-f]*\)$ ]] && echo ${line[*]} && fail "ldd's output isn't what this script expected!" + copy_dependencies "${line[0]}" "${line[2]}" + done +} + +shopt -s dotglob + +DESTDIR="${MESON_INSTALL_PREFIX}/lib" +mkdir -p $DESTDIR +copy_dependencies $BINARY $BINARY + +echo "Copying standard library..." +cp -ar "$RUBY_LIB_DIR/$RUBY_VER.0" "$DESTDIR/ruby" +echo "Downloading cacert.pem..." +curl -o "$DESTDIR/cacert.pem" https://curl.se/ca/cacert.pem +echo "Sym-linking modshot..." +ln -sf "$DESTDIR/lmodshot" $BINARY +echo "Done!" \ No newline at end of file diff --git a/linux/meson.build b/linux/meson.build new file mode 100644 index 00000000..debe2668 --- /dev/null +++ b/linux/meson.build @@ -0,0 +1,2 @@ +meson.add_install_script('install.sh', meson.project_name(), get_option('mri_version')) + diff --git a/linux/vars.sh b/linux/vars.sh new file mode 100644 index 00000000..52a2a5e3 --- /dev/null +++ b/linux/vars.sh @@ -0,0 +1,12 @@ +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +MODSHOT_PREFIX=$(uname -m) +export LDFLAGS="-L$DIR/build-${MODSHOT_PREFIX}/lib" +export CFLAGS="-I$DIR/build-${MODSHOT_PREFIX}/include" +MODSHOT_OLD_PC=$(pkg-config --variable pc_path pkg-config) + +# Try to load the stuff we built first +export PKG_CONFIG_LIBDIR="$DIR/build-${MODSHOT_PREFIX}/lib/pkgconfig:$DIR/build-${MODSHOT_PREFIX}/lib64/pkgconfig:${MODSHOT_OLD_PC}" +export PATH="$DIR/build-${MODSHOT_PREFIX}/bin:$PATH" +export LD_LIBRARY_PATH="$DIR/build-${MODSHOT_PREFIX}/lib:${LD_LIBRARY_PATH}" +export MODSHOT_PREFIX="$DIR/build-${MODSHOT_PREFIX}" diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..1bef5333 --- /dev/null +++ b/meson.build @@ -0,0 +1,98 @@ +project('modshot', 'c', 'cpp', version: '1.0.0', meson_version: '>=0.56.0', default_options: ['cpp_std=c++14', 'buildtype=release']) + +host_system = host_machine.system() + +xxd = find_program('xxd', native: true) + +compilers = {'cpp': meson.get_compiler('cpp')} + +global_sources = [] +global_dependencies = [] +global_include_dirs = [] +global_args = [] +global_link_args = [] + +sizeof = {'void*': compilers['cpp'].sizeof('void*'), + 'long': compilers['cpp'].sizeof('long') + } +win64 = (sizeof['void*'] != sizeof['long']) + +global_args += '-DHAVE_NANOSLEEP' + +gfx_backend = get_option('gfx_backend') +if gfx_backend == 'gles' + global_args += '-DGLES2_HEADER' +elif gfx_backend == 'gl' + global_dependencies += dependency('gl') +endif + +# ==================== +# Main source +# ==================== + +# Suppress warnings +global_args += ['-Wno-non-virtual-dtor', '-Wno-reorder', '-Wno-uninitialized', '-Wno-unknown-pragmas', '-Wno-stringop-truncation', '-Wno-parentheses', '-Wno-sign-compare', '-Wno-misleading-indentation'] +if compilers['cpp'].get_id() == 'clang' + global_args += ['-Wno-undefined-var-template', '-Wno-delete-non-abstract-non-virtual-dtor'] +endif +if host_system == 'windows' + if compilers['cpp'].get_id() != 'clang' + global_args += '-masm=intel' + endif +endif + +# Defines +if get_option('workdir_current') + global_args += '-DWORKDIR_CURRENT' +endif + +steam = false +if get_option('steam') == true + steam = true +endif + +build_static = false +if get_option('build_static') == true + if host_system == 'windows' + build_static = true + endif +endif + + +subdir('src') +subdir('binding-mri') +subdir('shader') +subdir('assets') + +global_include_dirs += include_directories('src', 'binding-mri') + +rpath = '' +if host_system == 'windows' + subdir('windows') + global_sources += windows_resources + global_include_dirs += include_directories('windows') +else + subdir('linux') + rpath = '$ORIGIN' +endif + +exe_name = meson.project_name() + +executable(exe_name, + sources: global_sources, + dependencies: global_dependencies, + include_directories: global_include_dirs, + install_rpath: rpath, + link_args: global_link_args, + cpp_args: global_args, + objc_args: global_args, + objcpp_args: global_args, + win_subsystem: 'windows', + install: (host_system != 'windows') +) + +if host_system == 'windows' + executable(meson.project_name() + '-shim', + sources: ['windows/shim.c', windows_resources] + ) +endif \ No newline at end of file diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..cefa1b48 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,12 @@ +option('mri_version', type: 'string', value: '3.1', description: 'Version of MRI to link with') +option('mri_includes', type: 'string', value: '', description: 'Ruby manual include path') +option('mri_libpath', type: 'string', value: '', description: 'Ruby manual lib path') +option('mri_library', type: 'string', value: '', description: 'Ruby manual link name') + +option('workdir_current', type: 'boolean', value: false, description: 'Keep current directory on startup') + +option('steam', type: 'boolean', value: false, description: 'Add steamworks support') + +option('build_static', type: 'boolean', value: true, description: 'Use static libraries') + +option('gfx_backend', type: 'combo', value: 'gl', choices: ['gl', 'gles'], description: 'Graphics rendering API to use.') diff --git a/mkxp.pro b/mkxp.pro deleted file mode 100644 index 6c2f77b4..00000000 --- a/mkxp.pro +++ /dev/null @@ -1,320 +0,0 @@ - - -TEMPLATE = app -QT = -TARGET = oneshot -DEPENDPATH += src shader assets -INCLUDEPATH += . src - -CONFIG -= qt -CONFIG += link_pkgconfig - -CONFIG(release, debug|release): DEFINES += NDEBUG STEAM - -isEmpty(BINDING) { - BINDING = MRI -} - -contains(BINDING, MRI) { - contains(_HAVE_BINDING, YES) { - error("Only one binding may be selected") - } - _HAVE_BINDING = YES - - CONFIG += BINDING_MRI -} - -contains(BINDING, NULL) { - contains(_HAVE_BINDING, YES) { - error("Only one binding may be selected") - } - _HAVE_BINDING = YES - - CONFIG += BINDING_NULL -} - -PKGCONFIG = sigc++-2.0 pixman-1 zlib sdl2 SDL2_image SDL2_ttf openal SDL_sound vorbisfile - -unix { - CONFIG += c++11 - PKGCONFIG += physfs - LIBS += -ldl - macx: { - INCLUDEPATH += $$QMAKE_MAC_SDK_PATH/System/Library/Frameworks/OpenAL.framework/Versions/A/Headers /usr/local/include - LIBS += -framework OpenAL -framework AppKit - QMAKE_LFLAGS += -L/usr/local/lib -L/usr/local/opt/ruby/lib -L/usr/local/opt/openal-soft/lib - HEADERS += src/mac-desktop.h - SOURCES += src/mac-desktop.mm - } - !macx: { - CONFIG(debug, debug|release) { - QMAKE_CXXFLAGS += -g - } - PKGCONFIG += gtk+-3.0 gdk-3.0 libxfconf-0 - INCLUDEPATH += /usr/include/AL /usr/local/include/AL - LIBS += -lX11 - QMAKE_LFLAGS += "-Wl,-rpath,\'\$$ORIGIN\'" - QMAKE_LFLAGS += -no-pie - } -} - -win32 { - QMAKE_CXXFLAGS += -std=gnu++11 - QMAKE_LFLAGS += -std=gnu++11 - - PKGCONFIG += freetype2 - LIBS += -lphysfs -lsecur32 -lwinmm - - release { - RC_FILE = assets/resources.rc - } -} - -# Deal with boost paths... -isEmpty(BOOST_I) { - BOOST_I = $$(BOOST_I) -} -isEmpty(BOOST_I) {} -else { - INCLUDEPATH += $$BOOST_I -} - -isEmpty(BOOST_L) { - BOOST_L = $$(BOOST_L) -} -isEmpty(BOOST_L) {} -else { - LIBS += -L$$BOOST_L -} - -isEmpty(BOOST_LIB_SUFFIX) { - BOOST_LIB_SUFFIX = $$(BOOST_LIB_SUFFIX) -} - -LIBS += -lboost_program_options$$BOOST_LIB_SUFFIX - -# Input -HEADERS += \ - src/quadarray.h \ - src/audio.h \ - src/binding.h \ - src/bitmap.h \ - src/disposable.h \ - src/etc.h \ - src/etc-internal.h \ - src/eventthread.h \ - src/flashable.h \ - src/font.h \ - src/input.h \ - src/plane.h \ - src/scene.h \ - src/sprite.h \ - src/table.h \ - src/texpool.h \ - src/tilequad.h \ - src/transform.h \ - src/viewport.h \ - src/window.h \ - src/serializable.h \ - src/shader.h \ - src/glstate.h \ - src/quad.h \ - src/tilemap.h \ - src/tilemap-common.h \ - src/graphics.h \ - src/gl-debug.h \ - src/global-ibo.h \ - src/exception.h \ - src/filesystem.h \ - src/serial-util.h \ - src/intrulist.h \ - src/binding.h \ - src/gl-util.h \ - src/util.h \ - src/config.h \ - src/settingsmenu.h \ - src/keybindings.h \ - src/tileatlas.h \ - src/sharedstate.h \ - src/al-util.h \ - src/boost-hash.h \ - src/debugwriter.h \ - src/gl-fun.h \ - src/gl-meta.h \ - src/vertex.h \ - src/soundemitter.h \ - src/aldatasource.h \ - src/alstream.h \ - src/audiostream.h \ - src/rgssad.h \ - src/sdl-util.h \ - src/oneshot.h \ - src/pipe.h \ - chromasdk/RzChromaSDKDefines.h \ - chromasdk/RzChromaSDKTypes.h \ - chromasdk/RzErrors.h \ - chromasdk/ChromaApi.h \ - src/i18n.h - -SOURCES += \ - src/main.cpp \ - src/audio.cpp \ - src/bitmap.cpp \ - src/eventthread.cpp \ - src/filesystem.cpp \ - src/font.cpp \ - src/input.cpp \ - src/plane.cpp \ - src/scene.cpp \ - src/sprite.cpp \ - src/table.cpp \ - src/tilequad.cpp \ - src/viewport.cpp \ - src/window.cpp \ - src/texpool.cpp \ - src/shader.cpp \ - src/glstate.cpp \ - src/tilemap.cpp \ - src/autotiles.cpp \ - src/graphics.cpp \ - src/gl-debug.cpp \ - src/etc.cpp \ - src/config.cpp \ - src/settingsmenu.cpp \ - src/keybindings.cpp \ - src/tileatlas.cpp \ - src/sharedstate.cpp \ - src/gl-fun.cpp \ - src/gl-meta.cpp \ - src/vertex.cpp \ - src/soundemitter.cpp \ - src/sdlsoundsource.cpp \ - src/alstream.cpp \ - src/audiostream.cpp \ - src/rgssad.cpp \ - src/vorbissource.cpp \ - src/oneshot.cpp \ - src/screen.cpp \ - src/i18n.cpp - -CONFIG(release, debug|release): { - HEADERS += src/steam.h steamshim/steamshim_child.h - SOURCES += src/steam.cpp steamshim/steamshim_child.c -} - -unix { - !macx { - HEADERS += src/xdg-user-dir-lookup.h - SOURCES += src/xdg-user-dir-lookup.c - } -} - -EMBED = \ - shader/common.h \ - shader/transSimple.frag \ - shader/trans.frag \ - shader/hue.frag \ - shader/sprite.frag \ - shader/plane.frag \ - shader/gray.frag \ - shader/bitmapBlit.frag \ - shader/flatColor.frag \ - shader/simple.frag \ - shader/simpleColor.frag \ - shader/simpleAlpha.frag \ - shader/simpleAlphaUni.frag \ - shader/flashMap.frag \ - shader/obscured.frag \ - shader/minimal.vert \ - shader/simple.vert \ - shader/simpleColor.vert \ - shader/sprite.vert \ - shader/tilemap.vert \ - shader/blur.frag \ - shader/blurH.vert \ - shader/blurV.vert \ - shader/mask.frag \ - shader/mask.vert \ - shader/crt.frag \ - shader/crt_sprite.frag \ - shader/simpleMatrix.vert \ - shader/chronos.frag \ - assets/icon.png \ - assets/gamecontrollerdb.txt - -defineReplace(xxdOutput) { - return($$basename(1).xxd) -} - -# xxd -xxd.output_function = xxdOutput -xxd.commands = xxd -i ${QMAKE_FILE_NAME} > ${QMAKE_FILE_OUT} -xxd.depends = $$EMBED -xxd.input = EMBED -xxd.variable_out = HEADERS - -QMAKE_EXTRA_COMPILERS += xxd - - -BINDING_NULL { - SOURCES += binding-null/binding-null.cpp -} - -BINDING_MRI { - MRIVERSION = $$(MRIVERSION) - isEmpty(MRIVERSION) { - MRIVERSION = 2.5 - unix { - !macx { - # Issues with compiling on Ubuntu with Ruby 2.4+. - MRIVERSION = 2.3 - } - } - } - - PKGCONFIG += ruby-$$MRIVERSION - DEFINES += BINDING_MRI - -# EMBED2 = binding-mri/module_rpg.rb -# xxdp.output = ${QMAKE_FILE_NAME}.xxd -# xxdp.commands = xxd+/xxd+ ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT} --string -# xxdp.depends = $$EMBED2 -# xxdp.input = EMBED2 -# xxdp.variable_out = HEADERS -# QMAKE_EXTRA_COMPILERS += xxdp - - HEADERS += \ - binding-mri/binding-util.h \ - binding-mri/binding-types.h \ - binding-mri/serializable-binding.h \ - binding-mri/disposable-binding.h \ - binding-mri/sceneelement-binding.h \ - binding-mri/viewportelement-binding.h \ - binding-mri/flashable-binding.h - - SOURCES += \ - binding-mri/binding-mri.cpp \ - binding-mri/binding-util.cpp \ - binding-mri/table-binding.cpp \ - binding-mri/etc-binding.cpp \ - binding-mri/bitmap-binding.cpp \ - binding-mri/font-binding.cpp \ - binding-mri/graphics-binding.cpp \ - binding-mri/input-binding.cpp \ - binding-mri/sprite-binding.cpp \ - binding-mri/viewport-binding.cpp \ - binding-mri/plane-binding.cpp \ - binding-mri/window-binding.cpp \ - binding-mri/tilemap-binding.cpp \ - binding-mri/audio-binding.cpp \ - binding-mri/module_rpg.cpp \ - binding-mri/filesystem-binding.cpp \ - binding-mri/oneshot-binding.cpp \ - binding-mri/steam-binding.cpp \ - binding-mri/wallpaper-binding.cpp \ - binding-mri/journal-binding.cpp \ - binding-mri/chroma-binding.cpp \ - binding-mri/niko-binding.cpp -} - -OTHER_FILES += $$EMBED diff --git a/oneshot.conf.sample b/modshot.conf.sample similarity index 95% rename from oneshot.conf.sample rename to modshot.conf.sample index 0cb2b5e3..2fa37e5f 100644 --- a/oneshot.conf.sample +++ b/modshot.conf.sample @@ -9,13 +9,11 @@ # relative to gameFolder and ignoring both RTPs and # encrypted archives. - # Start the game in debug/developer mode # (default: disabled) # # debugMode=false - # Continuously print average FPS to console. # This setting does not affect the window title # FPS display toggled via F2 @@ -23,52 +21,44 @@ # # printFPS=false - # Start game in fullscreen mode, # i.e. Big Picture/console mode. # (default: disabled) # # fullscreen=false - # Preserve game screen aspect ratio, # as opposed to stretch-to-fill # (default: enabled) # # fixedAspectRatio=true - # Apply linear interpolation when game screen # is upscaled # (default: disabled) # # smoothScaling=false - # Sync screen redraws to the monitor refresh rate # (default: enabled) # # vsync=true - # Override the game window title # (default: none) # # windowTitle=Custom Title - # Enforce a static frame rate # (0 = disabled) # # fixedFramerate=0 - # Skip (don't draw) frames when behind # (default: enabled) # # frameSkip=true - # Use a fixed framerate that is approx. equal to the # native screen refresh rate. This is different from # "fixedFramerate" because the actual frame rate is @@ -79,13 +69,11 @@ # # syncToRefreshrate=false - # Don't use alpha blending when rendering text # (default: disabled) # # solidFonts=false - # Work around buggy graphics drivers which don't # properly synchronize texture access, most # apparent when text doesn't show up or the map @@ -94,7 +82,6 @@ # # subImageFix=false - # Enable framebuffer blitting if the driver is # capable of it. Some drivers carry buggy # implementations of this functionality, so @@ -103,7 +90,6 @@ # # enableBlitting=true - # Limit the maximum size (width, height) of # most textures mkxp will create (exceptions are # rendering backbuffers and similar). @@ -114,25 +100,21 @@ # # maxTextureSize=0 - # Set the base path of the game to '/path/to/game' # (default: executable directory) # # gameFolder=/path/to/game - # Allow symlinks for game assets to be followed # (default: disabled) # # allowSymlinks=false - # Set the game window icon to 'path/to/icon.png' # (default: none) # # iconPath=/path/to/icon.png - # Define raw scripts to be executed before the # actual Scripts.rxdata execution starts # (default: none) @@ -140,23 +122,12 @@ # preloadScript=my_win32_wrapper.rb # preloadScript=ruby18_fixes.rb - # Index all accesible assets via their lower case path # (emulates windows case insensitivity) # (default: enabled) # # pathCache=true - -# Add 'rtp1', 'rtp2.zip' and 'game.rgssad' to the -# asset search path (multiple allowed) -# (default: none) -# -# RTP=/path/to/rtp1 -# RTP=/path/to/rtp2.zip -# RTP=/path/to/game.rgssad - - # Font substitutions allow drop-in replacements of fonts # to be used without changing the RGSS scripts, # eg. providing 'Open Sans' when the game thinkgs it's @@ -171,7 +142,6 @@ # fontSub=Arial>Open Sans # fontSub=Times New Roman>Liberation Serif - # Because mkxp is usually distributed as a stand alone # build, no predefined load paths are initialized # ($:, $LOAD_PATH) in the MRI backend. With this option, @@ -183,7 +153,6 @@ # rubyLoadpath=/usr/lib64/ruby/ # rubyLoadpath=/usr/local/share/ruby/site_ruby - # Number of OpenAL sources to allocate for SE playback. # If there are a lot of sounds playing at the same time # and audibly cutting each other off, try increasing diff --git a/patches/assets/Data/CommonEvents.rxdata b/patches/assets/Data/CommonEvents.rxdata deleted file mode 100644 index b3529bf2..00000000 Binary files a/patches/assets/Data/CommonEvents.rxdata and /dev/null differ diff --git a/patches/assets/Data/Map004.rxdata b/patches/assets/Data/Map004.rxdata deleted file mode 100644 index 08fb5e23..00000000 Binary files a/patches/assets/Data/Map004.rxdata and /dev/null differ diff --git a/patches/assets/Data/Map005.rxdata b/patches/assets/Data/Map005.rxdata deleted file mode 100644 index 8d64eaea..00000000 Binary files a/patches/assets/Data/Map005.rxdata and /dev/null differ diff --git a/patches/assets/Data/Map061.rxdata b/patches/assets/Data/Map061.rxdata deleted file mode 100644 index 4d0eaa16..00000000 Binary files a/patches/assets/Data/Map061.rxdata and /dev/null differ diff --git a/patches/assets/Data/Map243.rxdata b/patches/assets/Data/Map243.rxdata deleted file mode 100644 index 5e724e0d..00000000 Binary files a/patches/assets/Data/Map243.rxdata and /dev/null differ diff --git a/patches/assets/Data/Map255.rxdata b/patches/assets/Data/Map255.rxdata deleted file mode 100644 index b99a72b0..00000000 Binary files a/patches/assets/Data/Map255.rxdata and /dev/null differ diff --git a/patches/assets/Graphics/Pictures/es/pj_portal.png b/patches/assets/Graphics/Pictures/es/pj_portal.png deleted file mode 100644 index 886a8ea9..00000000 Binary files a/patches/assets/Graphics/Pictures/es/pj_portal.png and /dev/null differ diff --git a/patches/assets/Graphics/Pictures/fr/pj_portal.png b/patches/assets/Graphics/Pictures/fr/pj_portal.png deleted file mode 100644 index 157edda9..00000000 Binary files a/patches/assets/Graphics/Pictures/fr/pj_portal.png and /dev/null differ diff --git a/patches/assets/Graphics/Pictures/jp/pj_portal.png b/patches/assets/Graphics/Pictures/jp/pj_portal.png deleted file mode 100644 index 177a4359..00000000 Binary files a/patches/assets/Graphics/Pictures/jp/pj_portal.png and /dev/null differ diff --git a/patches/assets/Graphics/Pictures/ko/pj_portal.png b/patches/assets/Graphics/Pictures/ko/pj_portal.png deleted file mode 100644 index c0adf802..00000000 Binary files a/patches/assets/Graphics/Pictures/ko/pj_portal.png and /dev/null differ diff --git a/patches/assets/Graphics/Pictures/pj_portal.png b/patches/assets/Graphics/Pictures/pj_portal.png deleted file mode 100644 index 245b7671..00000000 Binary files a/patches/assets/Graphics/Pictures/pj_portal.png and /dev/null differ diff --git a/patches/assets/Graphics/Pictures/pt_BR/pj_portal.png b/patches/assets/Graphics/Pictures/pt_BR/pj_portal.png deleted file mode 100644 index 4914c7a2..00000000 Binary files a/patches/assets/Graphics/Pictures/pt_BR/pj_portal.png and /dev/null differ diff --git a/patches/assets/Graphics/Pictures/shrimp.png b/patches/assets/Graphics/Pictures/shrimp.png deleted file mode 100644 index fbb8c102..00000000 Binary files a/patches/assets/Graphics/Pictures/shrimp.png and /dev/null differ diff --git a/patches/assets/Graphics/Pictures/zh_CN/pj_portal.png b/patches/assets/Graphics/Pictures/zh_CN/pj_portal.png deleted file mode 100644 index e06d2dfc..00000000 Binary files a/patches/assets/Graphics/Pictures/zh_CN/pj_portal.png and /dev/null differ diff --git a/patches/assets/Wallpaper/desktop.png b/patches/assets/Wallpaper/desktop.png deleted file mode 100644 index f83e1017..00000000 Binary files a/patches/assets/Wallpaper/desktop.png and /dev/null differ diff --git a/patches/assets/Wallpaper/es/save_unix.png b/patches/assets/Wallpaper/es/save_unix.png deleted file mode 100644 index 3ee9f87a..00000000 Binary files a/patches/assets/Wallpaper/es/save_unix.png and /dev/null differ diff --git a/patches/assets/Wallpaper/fr/save_unix.png b/patches/assets/Wallpaper/fr/save_unix.png deleted file mode 100644 index bb362988..00000000 Binary files a/patches/assets/Wallpaper/fr/save_unix.png and /dev/null differ diff --git a/patches/assets/Wallpaper/ja/save_unix.png b/patches/assets/Wallpaper/ja/save_unix.png deleted file mode 100644 index c2a33239..00000000 Binary files a/patches/assets/Wallpaper/ja/save_unix.png and /dev/null differ diff --git a/patches/assets/Wallpaper/ko/save_unix.png b/patches/assets/Wallpaper/ko/save_unix.png deleted file mode 100644 index 80f4dff0..00000000 Binary files a/patches/assets/Wallpaper/ko/save_unix.png and /dev/null differ diff --git a/patches/assets/Wallpaper/pt_BR/save_unix.png b/patches/assets/Wallpaper/pt_BR/save_unix.png deleted file mode 100644 index ac52ed3a..00000000 Binary files a/patches/assets/Wallpaper/pt_BR/save_unix.png and /dev/null differ diff --git a/patches/assets/Wallpaper/save_unix.png b/patches/assets/Wallpaper/save_unix.png deleted file mode 100644 index fd3e8ae9..00000000 Binary files a/patches/assets/Wallpaper/save_unix.png and /dev/null differ diff --git a/patches/assets/Wallpaper/zh_CN/save_unix.png b/patches/assets/Wallpaper/zh_CN/save_unix.png deleted file mode 100644 index b637ba31..00000000 Binary files a/patches/assets/Wallpaper/zh_CN/save_unix.png and /dev/null differ diff --git a/patches/mac/CompleteBundle.cmake b/patches/mac/CompleteBundle.cmake deleted file mode 100644 index d31ac37e..00000000 --- a/patches/mac/CompleteBundle.cmake +++ /dev/null @@ -1,70 +0,0 @@ -#-- Need this for link line stuff? -if(COMMAND cmake_policy) - cmake_policy(SET CMP0009 NEW) -endif(COMMAND cmake_policy) - -# gp_item_default_embedded_path item default_embedded_path_var -# -# Return the path that others should refer to the item by when the item -# is embedded inside a bundle. -# -# Override on a per-project basis by providing a project-specific -# gp_item_default_embedded_path_override function. -# -function(gp_item_default_embedded_path_override item default_embedded_path_var) - # - # The assumption here is that all executables in the bundle will be - # in same-level-directories inside the bundle. The parent directory - # of an executable inside the bundle should be MacOS or a sibling of - # MacOS and all embedded paths returned from here will begin with - # "@loader_path/../" and will work from all executables in all - # such same-level-directories inside the bundle. - # - - # By default, embed things right next to the main bundle executable: - # - set (install_name_prefix "@executable_path") - # ------------------------------------------------------------------- - # If your application uses plugins then you should consider using the following - # instead but will limit your deployment to OS X 10.4. There is also a patch - # needed for CMake that as of Sept 30, 2008 has NOT been applied to CMake. - # set (install_name_prefix "@loader_path") - - set(path "${install_name_prefix}/../../Contents/MacOS") - - set(overridden 0) - - # Embed .dylibs in the Libraries Directory - # - if(item MATCHES "\\.dylib$") - set(path "${install_name_prefix}/../Libraries") - set(overridden 1) - endif(item MATCHES "\\.dylib$") - - # Embed .so files in the Plugins directory - # - if(item MATCHES "\\.so$") - set(path "${install_name_prefix}/../Plugins") - set(overridden 1) - endif(item MATCHES "\\.so$") - - # Embed frameworks in the embedded "Frameworks" directory (sibling of MacOS): - # - if(NOT overridden) - if(item MATCHES "[^/]+\\.framework/") - set(path "${install_name_prefix}/../Frameworks") - set(overridden 1) - endif(item MATCHES "[^/]+\\.framework/") - endif(NOT overridden) - - set(${default_embedded_path_var} "${path}" PARENT_SCOPE) -endfunction(gp_item_default_embedded_path_override) - -# -- Copy the App bundle to the installation location first -# EXECUTE_PROCESS(COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/patches/mac/CreateBundle.sh") - -# -- Run the BundleUtilities cmake code -include(BundleUtilities) -set(BU_CHMOD_BUNDLE_ITEMS ON) -fixup_bundle("${CMAKE_CURRENT_SOURCE_DIR}/OneShot.app" "" "${CMAKE_CURRENT_SOURCE_DIR}") -execute_process(COMMAND chmod 0700 "${CMAKE_CURRENT_SOURCE_DIR}/OneShot.app") \ No newline at end of file diff --git a/patches/mac/CreateBundle.sh b/patches/mac/CreateBundle.sh deleted file mode 100644 index 7236f9c3..00000000 --- a/patches/mac/CreateBundle.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -OSX_App="synglechance.app" -ContentsDir="$OSX_App/Contents" -LibrariesDir="$OSX_App/Contents/Libraries" -ResourcesDir="$OSX_App/Contents/Resources" - -# create directories in the @target@.app bundle -if [ ! -e $LibrariesDir ] - then - mkdir -p "$LibrariesDir" -fi - -if [ ! -e $ResourcesDir ] - then - mkdir -p "$ResourcesDir" -fi diff --git a/patches/mac/Info.plist.in b/patches/mac/Info.plist.in deleted file mode 100644 index 7f693f72..00000000 --- a/patches/mac/Info.plist.in +++ /dev/null @@ -1,36 +0,0 @@ - - - - - CFBundleName - OneShot - CFBundleDisplayName - OneShot - CFBundleGetInfoString - You only have one shot. - CFBundleIdentifier - queengooborg.oneshot-game.osx - CFBundleExecutable - oneshot.sh - CFBundleIconFile - icon.icns - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - APPL - CFBundleVersion - macOS Port v.ONESHOTMACVERSION - CFBundleShortVersionString - ONESHOTMACVERSION - LSApplicationCategoryType - public.app-category.games - LSMinimumSystemVersion - 10.7 - LSBackgroundOnly - 0 - NSHumanReadableCopyright - Copyright © 2017, OneShot team, all rights reserved. View CREDITS.txt for more. Port for macOS copyright © 2018, Vinyl Darkscratch, MIT License. - NSHighResolutionCapable - True - - diff --git a/patches/mac/JournalInfo.plist.in b/patches/mac/JournalInfo.plist.in deleted file mode 100644 index 833417b6..00000000 --- a/patches/mac/JournalInfo.plist.in +++ /dev/null @@ -1,36 +0,0 @@ - - - - - CFBundleDisplayName - _______ - CFBundleName - _______ - CFBundleIdentifier - queengooborg.oneshot-game.osx-journal - CFBundleExecutable - MacOS/_______ - CFBundleIconFile - icon_journal.icns - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - APPL - CFBundleShortVersionString - ONESHOTMACVERSION - LSBackgroundOnly - 0 - CFBundleGetInfoString - You only have one shot. - CFBundleVersion - ONESHOTMACVERSION - LSApplicationCategoryType - public.app-category.games - LSMinimumSystemVersion - 10.7 - NSHumanReadableCopyright - Copyright © 2017, OneShot team, all rights reserved. View CREDITS.txt for more. Port for macOS copyright © 2018, hunternet93 and Vinyl Darkscratch, MIT License. https://github.com/hunternet93/OneShot-Journal - NSHighResolutionCapable - True - - \ No newline at end of file diff --git a/patches/mac/libsteam_api.dylib b/patches/mac/libsteam_api.dylib deleted file mode 100644 index 6e2309a8..00000000 Binary files a/patches/mac/libsteam_api.dylib and /dev/null differ diff --git a/patches/mac/oneshot.sh b/patches/mac/oneshot.sh deleted file mode 100644 index 021f2d6d..00000000 --- a/patches/mac/oneshot.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -[[ $# -eq 1 && "$1" == -psn_* ]] && shift -cd "${0%/*}/../Resources" -DATA="$(cd "../../.." && echo "$PWD")" -export DYLD_FALLBACK_LIBRARY_PATH="$PWD:$DYLD_FALLBACK_LIBRARY_PATH" -exec ./steamshim --gameFolder="$DATA" "$@" diff --git a/patches/ruby/static_zlib.patch b/patches/ruby/static_zlib.patch deleted file mode 100644 index 62b977e0..00000000 --- a/patches/ruby/static_zlib.patch +++ /dev/null @@ -1,43 +0,0 @@ ---- a/common.mk -+++ b/common.mk -@@ -111,6 +111,7 @@ COMMONOBJS = array.$(OBJEXT) \ - vm_trace.$(OBJEXT) \ - thread.$(OBJEXT) \ - cont.$(OBJEXT) \ -+ ext/zlib/zlib.$(OBJEXT) \ - $(BUILTIN_ENCOBJS) \ - $(BUILTIN_TRANSOBJS) \ - $(MISSING) -diff --git a/ruby-2.1.5.orig/configure b/ruby-2.1.5/configure -index d0f1f68..45ab642 100755 ---- a/configure -+++ b/configure -@@ -2878,6 +2878,8 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - - - -+LIBS="$LIBS -lz" -+ - { # environment section - - ---- a/configure.in -+++ b/configure.in -@@ -35,6 +35,8 @@ rm() { - } - ])])]) - -+LIBS="$LIBS -lz" -+ - { # environment section - - AC_ARG_WITH(baseruby, ---- a/inits.c -+++ b/inits.c -@@ -61,5 +61,6 @@ rb_call_inits(void) - CALL(Complex); - CALL(version); - CALL(vm_trace); -+ CALL(zlib); - } - #undef CALL diff --git a/scripts/shell/cleanup.sh b/scripts/shell/cleanup.sh deleted file mode 100644 index 60f62b05..00000000 --- a/scripts/shell/cleanup.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -rm -rf journal/mac/__pycache__ -rm -rf steamshim_parent/build -rm -rf steamshim_parent/CMakeFiles -rm -rf steamshim_parent/CMakeCache.txt -rm -rf build -rm -rf bin -rm -rf lib -rm -rf dist -rm -rf x64 -rm -rf *.sln -rm -rf *.vcxproj -rm -rf *.vcxproj.filters -rm -rf *.user -rm -rf _______.app -rm -rf OneShot.app -rm -rf oneshot -rm -rf conanbuildinfo.cmake -rm -rf CMakeFiles -rm -rf cmake_install.cmake -rm -rf CMakeCache.txt -rm -rf conanbuildinfo.txt -rm -rf conaninfo.txt -rm -rf conan_imports_manifest.txt -rm -rf *.xxd -rm -rf *.dir -if [ -f .qmake.stash ] -then - make distclean -else - echo "" -fi diff --git a/scripts/shell/install.command b/scripts/shell/install.command deleted file mode 100644 index ca9e3781..00000000 --- a/scripts/shell/install.command +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -set -e - -# Credit to popkirby on GitHub for creating the majority of this file - -cd `dirname $0` - -# Colors -white="\033[0;37m" # White - Regular -bold="\033[1;37m" # White - Bold -cyan="\033[1;36m" # Cyan - Bold -green="\033[1;32m" # Green - Bold -color_reset="\033[0m" # Reset Colors - -ONESHOT_PATH=$HOME/Library/Application\ Support/Steam/steamapps/common/OneShot - -echo "-> ${cyan}Removing old OneShot apps...${color_reset}" -rm -rf "$ONESHOT_PATH/OneShot.app" -rm -rf "$ONESHOT_PATH/_______.app" -rm -f "$ONESHOT_PATH/Data/xScripts.rxdata" -rm -rf "$ONESHOT_PATH/*.exe" -rm -rf "$ONESHOT_PATH/*.dll" - -echo "-> ${cyan}Install OneShot apps to Steam directory...${color_reset}" -cp -rf "." "$ONESHOT_PATH" -rm -f "$ONESHOT_PATH/install.command" -ln -sfh "$ONESHOT_PATH/OneShot.app" "$HOME/Applications/OneShot.app" - -rm -f /tmp/oneshot-pipe # Important for pre-release version cleanup - -echo "\n${green}Complete! ${white}Please report any issues to https://github.com/vinyldarkscratch/synglechance/issues${color_reset}" -open "$ONESHOT_PATH" \ No newline at end of file diff --git a/scripts/shell/make-oneshot-linux.sh b/scripts/shell/make-oneshot-linux.sh deleted file mode 100644 index d0d520e2..00000000 --- a/scripts/shell/make-oneshot-linux.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh -set -e - -cd `dirname $0` - -# User-configurable variables. -linux_version="0.1.0" -make_threads=8 -oneshot_id=420530 -ONESHOT_PATH=$HOME/.local/share/Steam/steamapps/common/OneShot -STEAMWORKS_PATH=$(realpath ..)/steamworks - -# Colors. -white="\033[0;37m" # White - Regular -bold="\033[1;37m" # White - Bold -cyan="\033[1;36m" # Cyan - Bold -green="\033[1;32m" # Green - Bold -color_reset="\033[0m" # Reset Colors - -echo -e "${white}Compiling ${bold}SyngleChance v${linux_version} ${white}engine for Linux...${color_reset}\n" - -# Generate makefile. -echo -e "-> ${cyan}Generate makefile...${color_reset}" -export MRIVERSION=$(echo "puts RUBY_VERSION.split('.').slice(0, 2).join('.')" | ruby) -export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig -qmake mkxp.pro > oneshot.qmake.out - -# Compile OneShot. -echo -e "-> ${cyan}Compile engine...${color_reset}" -make -j${make_threads} > oneshot.make.out - -# Compile steamshim. -echo -e "-> ${cyan}Compile steamshim...${color_reset}" -cd steamshim_parent -mkdir build -cd build -cmake -DSTEAMWORKS_PATH=${STEAMWORKS_PATH} .. > steamshim.cmake.out -cp "$STEAMWORKS_PATH/redistributable_bin/linux64/libsteam_api.so" . -make -j${make_threads} > steamshim.make.out -cd ../.. - -# Compile Journal. -echo -e "-> ${cyan}Compile journal...${color_reset}" -pyinstaller journal/unix/journal.spec --windowed - -# Compile scripts. -echo -e "-> ${cyan}Compile xScripts.rxdata...${color_reset}" -ruby rpgscript.rb ./scripts "$ONESHOT_PATH" > rpgscript.out - -# Copy results. -echo -e "-> ${cyan}Install OneShot apps to Steam directory...${color_reset}" -yes | cp -r dist/_______/* "$ONESHOT_PATH" -yes | cp oneshot "$ONESHOT_PATH" -yes | cp steamshim_parent/build/steamshim "$ONESHOT_PATH" -echo "$oneshot_id" > "$ONESHOT_PATH/steam_appid.txt" - -# Copy libraries. -echo -e "-> ${cyan}Install OneShot libraries to Steam directory...${color_reset}" -mkdir libs -ldd oneshot | ruby libraries.rb -ldd steamshim_parent/build/steamshim | ruby libraries.rb -yes | cp libs/* "$ONESHOT_PATH" - -# Cleanup. -echo -e "-> ${cyan}Cleanup files...${color_reset}" -rm -rf journal/unix/__pycache__ -rm -rf build -rm -rf dist -rm -rf steamshim_parent/build -rm -rf libs -make clean > clean.out -rm -f *.out -rm Makefile -rm oneshot -rm .qmake.stash - -echo -e "\n${green}Complete! ${white}Please report any issues to https://github.com/GooborgStudios/synglechance/issues${color_reset}" diff --git a/scripts/shell/make-oneshot-mac.command b/scripts/shell/make-oneshot-mac.command deleted file mode 100644 index 881cb1e9..00000000 --- a/scripts/shell/make-oneshot-mac.command +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/sh -set -e - -cd `dirname $0` - -# User-configurable variables -mac_version="1.1.1" -make_threads=8 -ONESHOT_PATH=$HOME/Library/Application\ Support/Steam/steamapps/common/OneShot -# Colors -white="\033[0;37m" # White - Regular -bold="\033[1;37m" # White - Bold -cyan="\033[1;36m" # Cyan - Bold -green="\033[1;32m" # Green - Bold -color_reset="\033[0m" # Reset Colors - -use_qmake=True - -echo "${white}Compiling ${bold}SyngleChance v${mac_version} ${white}engine for macOS...${color_reset}\n" - -# Generate makefile and build main + journal -if [[ $use_qmake == True ]] - then - echo "-> ${cyan}Generate makefile...${color_reset}" - qmake MRIVERSION=2.5 - echo "-> ${cyan}Compile engine...${color_reset}" - make -j${make_threads} - echo "-> ${cyan}Compile steamshim...${color_reset}" - # cd steamshim_parent - # mkdir build && cd build - # cmake .. - # STEAMWORKS=./steamworks make -j${make_threads} - # cd ../.. -else - echo "${bold}WARNING: Conan/CMake method not ready yet.${color_reset}" -fi -echo "-> ${cyan}Compile journal...${color_reset}" -pyinstaller journal/unix/journal.spec --onefile --windowed - -# Create app bundles -echo "-> ${cyan}Create app bundles...${color_reset}" -OSX_App="OneShot.app" -ContentsDir="$OSX_App/Contents" -LibrariesDir="$OSX_App/Contents/Libraries" -ResourcesDir="$OSX_App/Contents/Resources" - -# create directories in the @target@.app bundle -if [ ! -e $LibrariesDir ] - then - mkdir -p "$LibrariesDir" -fi - -if [ ! -e $ResourcesDir ] - then - mkdir -p "$ResourcesDir" -fi - -cp steamshim_parent/steamshim ./OneShot.app/Contents/Resources/steamshim -# cp patches/mac/libsteam_api.dylib ./OneShot.app/Contents/Libraries/libsteam_api.dylib -cp -f journal/unix/macOS/Python dist/_______.app/Contents/MacOS/Python -install_name_tool -change @loader_path/libsteam_api.dylib "$( cd "$(dirname "$0")" ; pwd -P )"/steamworks/redistributable_bin/osx32/libsteam_api.dylib ./OneShot.app/Contents/Resources/steamshim -cmake -P patches/mac/CompleteBundle.cmake -cp assets/icon.icns ./OneShot.app/Contents/Resources/icon.icns -cp steam_appid.txt ./OneShot.app/Contents/Resources/steam_appid.txt -cp patches/mac/oneshot.sh ./OneShot.app/Contents/MacOS/oneshot.sh -mv OneShot.app/Contents/MacOS/OneShot OneShot.app/Contents/Resources/OneShot -cp -r dist/_______.app _______.app - -# Set version number -echo "-> ${cyan}Set version number...${color_reset}" -rm -f OneShot.app/Contents/Info.plist -rm -f _______.app/Contents/Info.plist -m4 patches/mac/Info.plist.in -DONESHOTMACVERSION=$mac_version > OneShot.app/Contents/Info.plist -m4 patches/mac/JournalInfo.plist.in -DONESHOTMACVERSION=$mac_version > _______.app/Contents/Info.plist - -# Compile scripts -echo "-> ${cyan}Compile xScripts.rxdata...${color_reset}" -ruby rpgscript.rb ./scripts "$ONESHOT_PATH" -cp "$ONESHOT_PATH/Data/xScripts.rxdata" . - -echo "-> ${cyan}Install OneShot apps to Steam directory...${color_reset}" -cp -rf "./OneShot.app" "$ONESHOT_PATH" -cp -rf "./_______.app" "$ONESHOT_PATH" - -# Cleanup -echo "-> ${cyan}Cleanup files...${color_reset}" -# make clean -rm -rf journal/unix/__pycache__ -rm -rf build -rm -rf dist - -echo "\n${green}Complete! ${white}Please report any issues to https://github.com/GooborgStudios/synglechance/issues${color_reset}" diff --git a/scripts/shell/oclint.sh b/scripts/shell/oclint.sh deleted file mode 100644 index 895c4636..00000000 --- a/scripts/shell/oclint.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -set -e - -cd `dirname $0` -cd oclint - -oclint -report-type html -o report.html ../src/alstream.cpp ../src/audio.cpp ../src/audiostream.cpp ../src/autotiles.cpp ../src/bitmap.cpp ../src/config.cpp ../src/etc.cpp ../src/eventthread.cpp ../src/filesystem.cpp ../src/font.cpp ../src/gl-debug.cpp ../src/gl-fun.cpp ../src/gl-meta.cpp ../src/glstate.cpp ../src/graphics.cpp ../src/i18n.cpp ../src/input.cpp ../src/keybindings.cpp ../src/mac-desktop.mm ../src/main.cpp ../src/oneshot.cpp ../src/plane.cpp ../src/rgssad.cpp ../src/scene.cpp ../src/screen.cpp ../src/sdlsoundsource.cpp ../src/settingsmenu.cpp ../src/shader.cpp ../src/sharedstate.cpp ../src/soundemitter.cpp ../src/sprite.cpp ../src/steam.cpp ../src/table.cpp ../src/texpool.cpp ../src/tileatlas.cpp ../src/tilemap.cpp ../src/tilequad.cpp ../src/vertex.cpp ../src/viewport.cpp ../src/vorbissource.cpp ../src/window.cpp ../binding-mri/audio-binding.cpp ../binding-mri/binding-mri.cpp ../binding-mri/binding-util.cpp ../binding-mri/bitmap-binding.cpp ../binding-mri/chroma-binding.cpp ../binding-mri/etc-binding.cpp ../binding-mri/filesystem-binding.cpp ../binding-mri/font-binding.cpp ../binding-mri/graphics-binding.cpp ../binding-mri/input-binding.cpp ../binding-mri/journal-binding.cpp ../binding-mri/module_rpg.cpp ../binding-mri/niko-binding.cpp ../binding-mri/oneshot-binding.cpp ../binding-mri/plane-binding.cpp ../binding-mri/screen-binding.cpp ../binding-mri/sprite-binding.cpp ../binding-mri/steam-binding.cpp ../binding-mri/table-binding.cpp ../binding-mri/tilemap-binding.cpp ../binding-mri/viewport-binding.cpp ../binding-mri/wallpaper-binding.cpp ../binding-mri/window-binding.cpp -- -c -pipe -stdlib=libc++ -O2 -std=gnu++11 -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -mmacosx-version-min=10.10 -Wall -W -fPIC -DNDEBUG -DBINDING_MRI -D_THREAD_SAFE -I. -I. -Isrc -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/OpenAL.framework/Versions/A/Headers -I/usr/local/Cellar/libsigc++/2.10.0/include/sigc++-2.0 -I/usr/local/Cellar/libsigc++/2.10.0/lib/sigc++-2.0/include -I/usr/local/Cellar/pixman/0.34.0_1/include/pixman-1 -I/usr/local/include/SDL2 -I/usr/local/include -I/usr/local/include/AL -I/usr/local/Cellar/libvorbis/1.3.6/include -I/usr/local/Cellar/libogg/1.3.3/include -I/usr/local/Cellar/physfs/3.0.1/include -I/usr/local/Cellar/ruby/2.5.0_2/include/ruby-2.5.0/x86_64-darwin17 -I/usr/local/Cellar/ruby/2.5.0_2/include/ruby-2.5.0 -I/usr/local/Cellar/qt/5.10.1/mkspecs/macx-clang - diff --git a/setup.sh b/setup.sh new file mode 100755 index 00000000..d568c851 --- /dev/null +++ b/setup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +if [[ $OSTYPE == msys ]]; then + echo "* MinGW-w64 detected." + echo "* Installing dependencies..." + pacman -S pactoys --noconfirm + pacboy -S libtool: autoconf: automake: git: gcc:p make:p cmake:p bison: doxygen:p ruby:p \ + SDL2:p SDL2_image:p SDL2_ttf:p openal:p vim: freetype:p \ + physfs:p pixman:p libwebp:p zlib:p meson:p clang:p \ + bzip2:p libvorbis:p libogg:p zeromq:p libsigc++:p \ + boost:p libpng:p libjpeg-turbo:p libtiff:p harfbuzz:p --noconfirm + +else + if [[ "$(cat /etc/issue)" == Debian* || "$(cat /etc/issue)" == Ubuntu* ]]; then + echo "* Debian Linux detected." + echo "* Installing dependencies..." + sudo apt install -y gcc make cmake bison doxygen ruby \ + libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libopenal-dev \ + libphysfs-dev libpixman-1-dev libwebp-dev libbz2-dev \ + libvorbis-dev libogg-dev libsodium-dev libboost-dev libpng-dev \ + libjpeg-dev libtiff-dev libsigc++-2.0-dev meson vim libgtk2.0-dev \ + libxfconf-0-dev libfreetype-dev libharfbuzz-dev \ + + fi + + if [[ "$(cat /etc/issue)" == Manjaro* ]]; then + echo "* Manjaro detected." + echo "* Installing dependencies..." + sudo pacman --noconfirm -S gcc make cmake bison doxygen ruby \ + sdl2 openal pixman libwebp bzip2 libvorbis libogg libsodium \ + libpng libjpeg libtiff zeromq mm-common base-devel vim gtk2 + echo "* Installing dependencies with pamac..." + sudo pamac install sdl2_image sdl2_ttf physfs boost boost-libs \ + libsigc++ sdl_sound m4 meson freetype harfbuzz --no-confirm + fi + + if [[ $(cat /etc/redhat-release) ]]; then + echo "* RedHat/Fedora Linux detected." + echo "* Installing dependencies..." + sudo dnf install gcc make m4 cmake bison doxygen ruby mm-common \ + SDL2 SDL2-devel SDL2_image SDL2_tff SDL2_ttf-devel SDL2_image-devel \ + bzip2-devel libwebp libwebp-devel libvorbis libvorbis-devel \ + libpng libpng-devel libjpeg-turbo libjpeg-turbo-devel libogg \ + libogg-devel libtiff libtiff-devel libsodium libsodium-devel \ + zeromq zeromq-devel physfs physfs-devel pixman pixman-devel \ + bzip2 openal-soft speex speex-devel libmodplug libmodplug-devel \ + boost boost-devel openal-soft-devel xfconf xfconf-devel gtk2 gtk2-devel \ + vim meson libsigc++-devel harfbuzz-devel + fi +fi \ No newline at end of file diff --git a/shader/binary_glitch.frag b/shader/binary_glitch.frag new file mode 100644 index 00000000..a2ab297c --- /dev/null +++ b/shader/binary_glitch.frag @@ -0,0 +1,53 @@ + +// Binary Glitch - based on Luminosity. +// use the Mouse to effect the strength. + + +// by D34N 4L3X +// dean@neuroid.co.uk + +uniform sampler2D texture; +uniform float strength; +varying vec2 v_texCoord; + +void main() +{ + vec2 uv = v_texCoord.xy; +// uv.t = 1.0 - uv.t; + + float x = uv.s; + float y = uv.t; + + // + float glitchStrength = strength * 5.0; + + // get snapped position + float psize = 0.04 * glitchStrength; + float psq = 1.0 / psize; + + float px = floor( x * psq + 0.5) * psize; + float py = floor( y * psq + 0.5) * psize; + + vec4 colSnap = texture2D( texture, vec2( px,py) ); + + float lum = pow( 1.0 - (colSnap.r + colSnap.g + colSnap.b) / 3.0, glitchStrength ); // remove the minus one if you want to invert luma + + + + // do move with lum as multiplying factor + float qsize = psize * lum; + + float qsq = 1.0 / qsize; + + float qx = floor( x * qsq + 0.5) * qsize; + float qy = floor( y * qsq + 0.5) * qsize; + + float rx = (px - qx) * lum + x; + float ry = (py - qy) * lum + y; + + vec4 colMove = texture2D( texture, vec2( rx,ry) ); + + + // final color + gl_FragColor = colMove; +} \ No newline at end of file diff --git a/shader/meson.build b/shader/meson.build new file mode 100644 index 00000000..644ea09b --- /dev/null +++ b/shader/meson.build @@ -0,0 +1,51 @@ +embedded_shaders = [ + 'binary_glitch.frag', + 'bitmapBlit.frag', + 'blur.frag', + 'blurH.vert', + 'blurV.vert', + 'chronos.frag', + 'common.h', + 'crt_sprite.frag', + 'crt.frag', + 'cubic_lens.frag', + 'flashMap.frag', + 'flatColor.frag', + 'gray.frag', + 'hue.frag', + 'mask.frag', + 'mask.vert', + 'minimal.vert', + 'obscured.frag', + 'plane.frag', + 'simple.frag', + 'simple.vert', + 'simpleAlpha.frag', + 'simpleAlphaUni.frag', + 'simpleColor.frag', + 'simpleColor.vert', + 'simpleMatrix.vert', + 'sprite.frag', + 'sprite.vert', + 'tilemap.vert', + 'trans.frag', + 'transSimple.frag', + 'water.frag', + 'zoom.vert' +] + +embedded_shaders_f = files(embedded_shaders) + +count = 0 +foreach file : embedded_shaders_f + global_sources += custom_target(embedded_shaders[count], + input: file, + output: '@0@.xxd'.format(embedded_shaders[count]), + command: [ + xxd, '-i', '@INPUT@' + ], + capture: true, + depend_files: embedded_shaders_f[count] + ) + count += 1 +endforeach diff --git a/src/audio/headers/al-util.h b/src/audio/headers/al-util.h index 99b4e8f0..a1cdf211 100644 --- a/src/audio/headers/al-util.h +++ b/src/audio/headers/al-util.h @@ -25,7 +25,8 @@ #define AL_ALEXT_PROTOTYPES #include #include -#include +#include +#include #include namespace AL @@ -319,6 +320,10 @@ inline uint8_t formatSampleSize(int sdlFormat) case AUDIO_S16MSB : return 2; + case AUDIO_F32LSB : + case AUDIO_F32MSB : + return 4; + default : assert(!"Unhandled sample format"); } @@ -343,6 +348,14 @@ inline ALenum chooseALFormat(int sampleSize, int channelCount) case 1 : return AL_FORMAT_MONO16; case 2 : return AL_FORMAT_STEREO16; } + + case 4 : + switch (channelCount) + { + case 1 : return AL_FORMAT_MONO_FLOAT32; + case 2 : return AL_FORMAT_STEREO_FLOAT32; + } + default : assert(!"Unhandled sample size / channel count"); } diff --git a/src/audio/headers/alstream.h b/src/audio/headers/alstream.h index 55822fd2..11cf302c 100644 --- a/src/audio/headers/alstream.h +++ b/src/audio/headers/alstream.h @@ -26,7 +26,7 @@ #include "sdl-util.h" #include -#include +#include struct ALDataSource; diff --git a/src/audio/source/alstream.cpp b/src/audio/source/alstream.cpp index 6e3fbc4a..acfd2901 100644 --- a/src/audio/source/alstream.cpp +++ b/src/audio/source/alstream.cpp @@ -29,9 +29,9 @@ #include "sdl-util.h" #include "debugwriter.h" -#include -#include -#include +#include +#include +#include ALStream::ALStream(LoopMode loopMode, AL::AuxiliaryEffectSlot::ID effectSlot, diff --git a/src/audio/source/audio.cpp b/src/audio/source/audio.cpp index c3021ca4..6a1ece25 100644 --- a/src/audio/source/audio.cpp +++ b/src/audio/source/audio.cpp @@ -30,8 +30,8 @@ #include -#include -#include +#include +#include struct AudioPrivate { diff --git a/src/audio/source/audiostream.cpp b/src/audio/source/audiostream.cpp index d84569bd..921e7c99 100644 --- a/src/audio/source/audiostream.cpp +++ b/src/audio/source/audiostream.cpp @@ -24,9 +24,9 @@ #include "util.h" #include "exception.h" -#include -#include -#include +#include +#include +#include AudioStream::AudioStream(ALStream::LoopMode loopMode, const std::string &threadId) diff --git a/src/audio/source/sdlsoundsource.cpp b/src/audio/source/sdlsoundsource.cpp index 8e1de83e..ed928f35 100644 --- a/src/audio/source/sdlsoundsource.cpp +++ b/src/audio/source/sdlsoundsource.cpp @@ -22,7 +22,7 @@ #include "aldatasource.h" #include "exception.h" -#include +#include struct SDLSoundSource : ALDataSource { diff --git a/src/audio/source/soundemitter.cpp b/src/audio/source/soundemitter.cpp index 256f6eb0..63d99708 100644 --- a/src/audio/source/soundemitter.cpp +++ b/src/audio/source/soundemitter.cpp @@ -28,7 +28,7 @@ #include "util.h" #include "debugwriter.h" -#include +#include #define SE_CACHE_MEM (10*1024*1024) // 10 MB diff --git a/src/filesystem/headers/filesystem.h b/src/filesystem/headers/filesystem.h index fc9a3c96..a5f15e2d 100644 --- a/src/filesystem/headers/filesystem.h +++ b/src/filesystem/headers/filesystem.h @@ -22,7 +22,7 @@ #ifndef FILESYSTEM_H #define FILESYSTEM_H -#include +#include struct FileSystemPrivate; class SharedFontState; diff --git a/src/filesystem/source/filesystem.cpp b/src/filesystem/source/filesystem.cpp index 9bbbc324..4f2820cf 100644 --- a/src/filesystem/source/filesystem.cpp +++ b/src/filesystem/source/filesystem.cpp @@ -31,7 +31,7 @@ #include -#include +#include #include #include diff --git a/src/opengl/headers/plane.h b/src/graphics/headers/plane.h similarity index 100% rename from src/opengl/headers/plane.h rename to src/graphics/headers/plane.h diff --git a/src/graphics/headers/scene.h b/src/graphics/headers/scene.h index eab0abc6..34dde593 100644 --- a/src/graphics/headers/scene.h +++ b/src/graphics/headers/scene.h @@ -63,7 +63,8 @@ class Scene const Vec4 /* rbg */, const Vec2 /* zoom */, const float /* cubic */, - const float /* water */) {} + const float /* water */, + const float /* binary */) {} const Geometry &getGeometry() const { return geometry; } diff --git a/src/opengl/headers/viewport.h b/src/graphics/headers/viewport.h similarity index 98% rename from src/opengl/headers/viewport.h rename to src/graphics/headers/viewport.h index 125e6549..f856a448 100644 --- a/src/opengl/headers/viewport.h +++ b/src/graphics/headers/viewport.h @@ -48,6 +48,7 @@ class Viewport : public Scene, public SceneElement, public Flashable, public Dis DECL_ATTR( RGBOffsetx, Vec4 ) DECL_ATTR( RGBOffsety, Vec4 ) DECL_ATTR( CubicTime, float ) + DECL_ATTR( BinaryStrength, float ) DECL_ATTR( WaterTime, float ) DECL_ATTR( Zoom, Vec2 ) diff --git a/src/opengl/headers/window.h b/src/graphics/headers/window.h similarity index 100% rename from src/opengl/headers/window.h rename to src/graphics/headers/window.h diff --git a/src/graphics/source/bitmap.cpp b/src/graphics/source/bitmap.cpp index cf22666e..0c31792f 100644 --- a/src/graphics/source/bitmap.cpp +++ b/src/graphics/source/bitmap.cpp @@ -21,11 +21,11 @@ #include "bitmap.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include diff --git a/src/graphics/source/font.cpp b/src/graphics/source/font.cpp index 36d12102..6cef6564 100644 --- a/src/graphics/source/font.cpp +++ b/src/graphics/source/font.cpp @@ -31,7 +31,7 @@ #include #include -#include +#include typedef std::pair FontKey; diff --git a/src/graphics/source/graphics.cpp b/src/graphics/source/graphics.cpp index 948941f2..797006fd 100644 --- a/src/graphics/source/graphics.cpp +++ b/src/graphics/source/graphics.cpp @@ -39,9 +39,9 @@ #include "debugwriter.h" #include "oneshot.h" -#include -#include -#include +#include +#include +#include #include #ifndef _MSC_VER @@ -178,7 +178,7 @@ class ScreenScene : public Scene } } - void requestViewportRender(const Vec4 &c, const Vec4 &f, const Vec4 &t, const bool s, const Vec4 rx, const Vec4 ry, const Vec2 z, const float cubic, const float water) + void requestViewportRender(const Vec4 &c, const Vec4 &f, const Vec4 &t, const bool s, const Vec4 rx, const Vec4 ry, const Vec2 z, const float cubic, const float water, const float binary) { const IntRect &viewpRect = glState.scissorBox.get(); const IntRect &screenRect = geometry.rect; @@ -192,6 +192,7 @@ class ScreenScene : public Scene const bool rgbOffset = rx.xyzNotNull() || ry.xyzNotNull() && !toneGrayEffect && !s && !(z.x != 1 || z.y != 1) && !cubicEffect; const bool scannedEffect = s && !t.w != 0 && !rgbOffset && !(z.x != 1 || z.y != 1) && !cubicEffect; const bool zoomEffect = (z.x != 1 || z.y != 1) && !scannedEffect && !rgbOffset && !cubicEffect; + const bool binaryEffect = binary != 0; if (toneGrayEffect) { @@ -225,6 +226,37 @@ class ScreenScene : public Scene glState.blend.pop(); } + if (binaryEffect) + { + pp.swapRender(); + + if (!viewpRect.encloses(screenRect)) + { + /* Scissor test _does_ affect FBO blit operations, + * and since we're inside the draw cycle, it will + * be turned on, so turn it off temporarily */ + glState.scissorTest.pushSet(false); + + GLMeta::blitBegin(pp.frontBuffer()); + GLMeta::blitSource(pp.backBuffer()); + GLMeta::blitRectangle(geometry.rect, Vec2i()); + GLMeta::blitEnd(); + + glState.scissorTest.pop(); + } + + BinaryShader &shader = shState->shaders().binary; + shader.bind(); + shader.applyViewportProj(); + shader.setTexSize(screenRect.size()); + + TEX::bind(pp.backBuffer().tex); + + glState.blend.pushSet(false); + screenQuad.draw(); + glState.blend.pop(); + } + if (scannedEffect) { pp.swapRender(); diff --git a/src/opengl/source/plane.cpp b/src/graphics/source/plane.cpp similarity index 100% rename from src/opengl/source/plane.cpp rename to src/graphics/source/plane.cpp diff --git a/src/graphics/source/sprite.cpp b/src/graphics/source/sprite.cpp index e5187ac0..1f0c2d60 100644 --- a/src/graphics/source/sprite.cpp +++ b/src/graphics/source/sprite.cpp @@ -38,10 +38,14 @@ #include -#include +#include #include +#ifndef M_PI + #define M_PI 3.14159265358979323846 +#endif + struct SpritePrivate { Bitmap *bitmap; diff --git a/src/graphics/source/tilemap.cpp b/src/graphics/source/tilemap.cpp index 4200eb6a..f4d8967e 100644 --- a/src/graphics/source/tilemap.cpp +++ b/src/graphics/source/tilemap.cpp @@ -46,7 +46,7 @@ #include #include -#include +#include #include "debugwriter.h" @@ -343,7 +343,7 @@ struct TilemapPrivate ySize(argySize), zlayersMax(argySize + 5) { - Debug() << xSize; Debug() << ySize; + // Debug() << xSize; Debug() << ySize; /* ZLayer vertices */ zlayerVert = new SVVector[zlayersMax]; diff --git a/src/opengl/source/viewport.cpp b/src/graphics/source/viewport.cpp similarity index 96% rename from src/opengl/source/viewport.cpp rename to src/graphics/source/viewport.cpp index f31a8067..898cfc37 100644 --- a/src/opengl/source/viewport.cpp +++ b/src/graphics/source/viewport.cpp @@ -28,7 +28,7 @@ #include "glstate.h" #include "graphics.h" -#include +#include #include @@ -55,6 +55,8 @@ struct ViewportPrivate float waterTime; + float binaryStrength; + Vec2 zoom; EtcTemps tmp; @@ -70,6 +72,7 @@ struct ViewportPrivate rgbOffsety(Vec4(0, 0, 0, 0)), cubicTime(0.0), waterTime(0.0), + binaryStrength(0.0), zoom(Vec2(1.0, 1.0)) { rect->set(x, y, width, height); @@ -110,7 +113,7 @@ struct ViewportPrivate bool needsEffectRender(bool flashing) { bool rectEffective = !rect->isEmpty(); - bool colorToneEffective = color->hasEffect() || tone->hasEffect() || flashing || scanned || rgbOffsetx.xyzNotNull() || rgbOffsety.xyzNotNull() || zoom.x != 1 || zoom.y != 1 || cubicTime != 0.0 || waterTime != 0.0; + bool colorToneEffective = color->hasEffect() || tone->hasEffect() || flashing || scanned || rgbOffsetx.xyzNotNull() || rgbOffsety.xyzNotNull() || zoom.x != 1 || zoom.y != 1 || cubicTime != 0.0 || waterTime != 0.0 || binaryStrength != 0.0; return (rectEffective && colorToneEffective && isOnScreen); } @@ -169,6 +172,7 @@ DEF_ATTR_SIMPLE(Viewport, Color, Color&, *p->color) DEF_ATTR_SIMPLE(Viewport, Tone, Tone&, *p->tone) DEF_ATTR_SIMPLE(Viewport, Scanned, bool, p->scanned) DEF_ATTR_SIMPLE(Viewport, CubicTime, float, p->cubicTime) +DEF_ATTR_SIMPLE(Viewport, BinaryStrength, float, p->binaryStrength) DEF_ATTR_SIMPLE(Viewport, WaterTime, float, p->waterTime) DEF_ATTR_SIMPLE(Viewport, RGBOffsetx, Vec4, p->rgbOffsetx) DEF_ATTR_SIMPLE(Viewport, RGBOffsety, Vec4, p->rgbOffsety) @@ -226,7 +230,7 @@ void Viewport::composite() * render them. */ if (renderEffect) scene->requestViewportRender - (p->color->norm, flashColor, p->tone->norm, p->scanned, p->rgbOffsetx, p->rgbOffsety, p->zoom, p->cubicTime, p->waterTime); + (p->color->norm, flashColor, p->tone->norm, p->scanned, p->rgbOffsetx, p->rgbOffsety, p->zoom, p->cubicTime, p->waterTime, p->binaryStrength); glState.scissorBox.pop(); glState.scissorTest.pop(); diff --git a/src/opengl/source/window.cpp b/src/graphics/source/window.cpp similarity index 100% rename from src/opengl/source/window.cpp rename to src/graphics/source/window.cpp diff --git a/src/input/headers/input.h b/src/input/headers/input.h index 104b203b..093f0d26 100644 --- a/src/input/headers/input.h +++ b/src/input/headers/input.h @@ -22,7 +22,7 @@ #ifndef INPUT_H #define INPUT_H -#include +#include struct InputPrivate; struct RGSSThreadData; diff --git a/src/input/headers/keybindings.h b/src/input/headers/keybindings.h index c8437019..a2c3bd8a 100644 --- a/src/input/headers/keybindings.h +++ b/src/input/headers/keybindings.h @@ -24,9 +24,9 @@ #include "input.h" -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/src/settingsmenu.h b/src/input/headers/settingsmenu.h similarity index 97% rename from src/settingsmenu.h rename to src/input/headers/settingsmenu.h index 836111c7..a6a9b345 100644 --- a/src/settingsmenu.h +++ b/src/input/headers/settingsmenu.h @@ -25,7 +25,7 @@ #include #include -#include +#include struct SettingsMenuPrivate; struct RGSSThreadData; diff --git a/src/input/source/input.cpp b/src/input/source/input.cpp index 1a3e7271..ac56f325 100644 --- a/src/input/source/input.cpp +++ b/src/input/source/input.cpp @@ -26,8 +26,8 @@ #include "exception.h" #include "util.h" -#include -#include +#include +#include #include #include diff --git a/src/settingsmenu.cpp b/src/input/source/settingsmenu.cpp similarity index 99% rename from src/settingsmenu.cpp rename to src/input/source/settingsmenu.cpp index e924dede..b561bd5f 100644 --- a/src/settingsmenu.cpp +++ b/src/input/source/settingsmenu.cpp @@ -21,11 +21,11 @@ #include "settingsmenu.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "keybindings.h" #include "eventthread.h" diff --git a/src/mac-desktop.h b/src/mac-desktop.h deleted file mode 100644 index 5fd150bb..00000000 --- a/src/mac-desktop.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// SyngleChance Engine - mac-desktop.h -// ©2018 Vinyl Darkscratch. You may use this code for anything you'd like. -// https://www.queengoob.org -// - -#pragma once - -#include - -namespace MacDesktop { - void CacheCurrentBackground(); - void ChangeBackground(std::string imageURL, double red, double green, double blue); - void ResetBackground(); -} \ No newline at end of file diff --git a/src/mac-desktop.mm b/src/mac-desktop.mm deleted file mode 100644 index cda130a0..00000000 --- a/src/mac-desktop.mm +++ /dev/null @@ -1,48 +0,0 @@ -// -// SyngleChance Engine - mac-desktop.mm -// ©2018 Vinyl Darkscratch. You may use this code for anything you'd like. -// https://www.queengoob.org -// - -#include "mac-desktop.h" -#include - -#import -#import - -BOOL isCached = NO; - -NSURL *originalBackground; -NSDictionary *originalOptions; - -NSScreen *screen = [NSScreen mainScreen]; -NSWorkspace *sharedworkspace = [NSWorkspace sharedWorkspace]; - -void MacDesktop::CacheCurrentBackground() { - if (isCached == NO) { - originalBackground = [sharedworkspace desktopImageURLForScreen:screen]; - originalOptions = [sharedworkspace desktopImageOptionsForScreen:screen]; - } - isCached = YES; -} - -void MacDesktop::ChangeBackground(std::string imageURL, double red, double green, double blue) { - NSURL *URL = [NSURL fileURLWithPath:@(imageURL.c_str())]; - NSDictionary *options = @{NSWorkspaceDesktopImageScalingKey : @3, NSWorkspaceDesktopImageAllowClippingKey : @0, NSWorkspaceDesktopImageFillColorKey : [NSColor colorWithSRGBRed:red green:green blue:blue alpha:1.0]}; - NSError *error = nil; - - BOOL success = [sharedworkspace setDesktopImageURL:[URL absoluteURL] forScreen:screen options:options error:&error]; - if (!success) { - NSLog(@"ERROR DURING DESKTOP BACKGROUND CHANGE: %@", error); - } -} - -void MacDesktop::ResetBackground() { - NSError *error = nil; - if (isCached) { - BOOL success = [sharedworkspace setDesktopImageURL:originalBackground forScreen:screen options:originalOptions error:&error]; - if (!success) { - NSLog(@"ERROR DURING DESKTOP BACKGROUND RESET: %@", error); - } - } -} diff --git a/src/main.cpp b/src/main.cpp index 3df584eb..6f95501d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,10 +21,10 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include #include #ifdef _MSC_VER @@ -56,6 +56,10 @@ #include "gamecontrollerdb.txt.xxd" #endif +#ifdef __WIN32 +#include "win-consoleutils.h" +#endif + static void rgssThreadError(RGSSThreadData *rtData, const std::string &msg) { @@ -180,7 +184,7 @@ static void setupWindowIcon(const Config &conf, SDL_Window *win) SDL_RWops *iconSrc; if (conf.iconPath.empty()) - iconSrc = SDL_RWFromConstMem(assets_icon_png, assets_icon_png_len); + iconSrc = SDL_RWFromConstMem(___assets_icon_png, ___assets_icon_png_len); else iconSrc = SDL_RWFromFile(conf.iconPath.c_str(), "rb"); @@ -234,9 +238,14 @@ static void setGamePathInRegistry() { #endif //TODO handle this for Linux/Mac } - -int main(int argc, char *argv[]) -{ +#ifdef _WIN32 +#include +int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { + auto argc = __argc; + auto argv = __argv; +#else +int main(int argc, char *argv[]) { +#endif Debug() << "ModShot version" << MODSHOT_VERSION; SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0"); @@ -292,6 +301,21 @@ int main(int argc, char *argv[]) showInitError(std::string("Unable to switch into gameFolder ") + conf.gameFolder); return 0; } + +#ifdef __WIN32 + // Create a debug console in debug mode + if (conf.winConsole) { + if (setupWindowsConsole()) { + reopenWindowsStreams(); + } else { + char buf[200]; + snprintf(buf, sizeof(buf), "Error allocating console: %lu", + GetLastError()); + showInitError(std::string(buf)); + } + } +#endif + extern int screenMain(Config &conf); if (conf.screenMode) @@ -386,8 +410,8 @@ int main(int argc, char *argv[]) #ifndef STEAM /* Add controller bindings from embedded controller DB */ - SDL_RWops *controllerDB = SDL_RWFromConstMem(assets_gamecontrollerdb_txt, - assets_gamecontrollerdb_txt_len); + SDL_RWops *controllerDB = SDL_RWFromConstMem(___assets_gamecontrollerdb_txt, + ___assets_gamecontrollerdb_txt_len); SDL_GameControllerAddMappingsFromRW(controllerDB, 1); #endif @@ -425,6 +449,7 @@ int main(int argc, char *argv[]) SDL_Delay(10); } + Debug() << "Waiting for shutdown"; /* If RGSS thread ack'd request, wait for it to shutdown, * otherwise abandon hope and just end the process as is. */ if (rtData.rqTermAck) @@ -441,6 +466,8 @@ int main(int argc, char *argv[]) } } + Debug() << "Cleaning up events"; + /* Clean up any remainin events */ eventThread.cleanup(); diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 00000000..e47549f9 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,132 @@ +boost = dependency('boost', version: '>=1.49', modules: ['program_options'], static: build_static) +physfs = dependency('physfs', version: '>=2.1', static: build_static) +openal = dependency('openal') +vorbisfile = dependency('vorbisfile', static: build_static) +vorbis = dependency('vorbis', static: build_static) +ogg = dependency('ogg', static: build_static) +sdl2 = dependency('SDL2') +freetype = dependency('freetype2', static: build_static) +harfbuzz = dependency('harfbuzz', static: build_static) +sdl_sound = dependency('SDL2_sound', static: build_static) +sdl2_ttf = dependency('SDL2_ttf', static: build_static) +sdl2_image = dependency('SDL2_image', static: build_static) +sigcxx = dependency('sigc++-2.0', static: build_static) +pixman = dependency('pixman-1', static: build_static) +png = dependency('libpng', static: build_static) +jpeg = dependency('libjpeg', static: build_static) +tiff = dependency('libtiff-4', static: build_static) +webp = dependency('libwebp', static: build_static) +zlib = dependency('zlib', static: build_static) +nsgif = dependency('libnsgif', static: build_static) + +if host_system == 'windows' + bz2 = dependency('bzip2') + iconv = compilers['cpp'].find_library('iconv') +else + bz2 = compilers['cpp'].find_library('bz2') + iconv = compilers['cpp'].find_library('iconv') + gtk = dependency('gtk+-2.0') + xfconf = dependency('libxfconf-0') + + global_dependencies += [gtk, xfconf] +endif + +# Windows needs to be treated like a special needs child here +explicit_libs = '' +if host_system == 'windows' + # Newer versions of Ruby will refuse to link without these + explicit_libs += 'libmsvcrt;libgcc;libmingwex;libgmp;' +endif + +foreach l : explicit_libs.split(';') + if l != '' + global_link_args += '-l:' + l + '.a' + endif +endforeach + +global_include_dirs += include_directories('.', + 'audio/headers', + 'filesystem/headers', + 'graphics/headers', + 'input/headers', + 'modshot/headers', + 'oneshot/headers', + 'opengl/headers', + 'rgss/headers', + 'thread/headers', + 'util/headers' +) + +global_dependencies += [boost, bz2, openal, zlib, sdl2, sdl_sound, pixman, physfs, vorbisfile, vorbis, iconv, ogg, sdl2_ttf, sigcxx, sdl2_image, png, jpeg, nsgif, freetype, tiff, webp, harfbuzz] + +if host_system == 'windows' + global_dependencies += compilers['cpp'].find_library('wsock32') + global_dependencies += compilers['cpp'].find_library('winmm') + global_dependencies += compilers['cpp'].find_library('Secur32') + global_dependencies += compilers['cpp'].find_library('Shlwapi') +endif + +main_source = files( + 'audio/source/alstream.cpp', + 'audio/source/audiostream.cpp', + 'audio/source/audiochannels.cpp', + 'audio/source/audio.cpp', + 'audio/source/soundemitter.cpp', + 'audio/source/sdlsoundsource.cpp', + 'audio/source/vorbissource.cpp', + 'filesystem/source/filesystem.cpp', + 'filesystem/source/rgssad.cpp', + 'graphics/source/autotiles.cpp', + 'graphics/source/bitmap.cpp', + 'graphics/source/graphics.cpp', + 'graphics/source/font.cpp', + 'graphics/source/sprite.cpp', + 'graphics/source/scene.cpp', + 'graphics/source/tilemap.cpp', + 'graphics/source/tileatlas.cpp', + 'graphics/source/window.cpp', + 'graphics/source/viewport.cpp', + 'graphics/source/plane.cpp', + 'input/source/input.cpp', + 'input/source/keybindings.cpp', + 'input/source/settingsmenu.cpp', + 'opengl/source/glstate.cpp', + 'opengl/source/gl-debug.cpp', + 'opengl/source/gl-fun.cpp', + 'opengl/source/gl-meta.cpp', + 'opengl/source/shader.cpp', + 'opengl/source/texpool.cpp', + 'opengl/source/vertex.cpp', + 'opengl/source/tilequad.cpp', + 'modshot/source/display.cpp', + 'oneshot/source/screen.cpp', + 'oneshot/source/oneshot.cpp', + 'oneshot/source/i18n.cpp', + 'rgss/source/table.cpp', + 'rgss/source/etc.cpp', + 'thread/source/eventthread.cpp', + 'thread/source/sharedstate.cpp', + 'util/source/config.cpp', + 'util/source/win-consoleutils.cpp', + 'main.cpp' +) + +global_sources += main_source + +if steam == true + global_sources += files( + 'steam/steam.cpp', + '../steamshim/steamshim_child.c' + ) + global_include_dirs += include_directories( + 'steam', + '../steamshim' + ) + + global_args += '-DSTEAM' +endif + +if host_system == 'windows' +else + global_sources += files('oneshot/source/xdg-user-dir-lookup.c') +endif diff --git a/src/crash-handler.h b/src/modshot/headers/crash-handler.h similarity index 100% rename from src/crash-handler.h rename to src/modshot/headers/crash-handler.h diff --git a/src/modshot/headers/display.h b/src/modshot/headers/display.h new file mode 100644 index 00000000..898e5fac --- /dev/null +++ b/src/modshot/headers/display.h @@ -0,0 +1,13 @@ +#pragma once +#include + +class Display { +public: + SDL_DisplayMode currentDisplayMode; + + //Display(); + static int getScreenWidth(); + static int getScreenHeight(); + static bool isWayland(); + static bool isX(); +}; \ No newline at end of file diff --git a/src/crash-handler.cpp b/src/modshot/source/crash-handler.cpp similarity index 97% rename from src/crash-handler.cpp rename to src/modshot/source/crash-handler.cpp index 2ca44cbc..89ff5e02 100644 --- a/src/crash-handler.cpp +++ b/src/modshot/source/crash-handler.cpp @@ -1,3 +1,4 @@ +/** #include "crash-handler.h" #include @@ -28,7 +29,7 @@ void LowLevelCrashHandler::upload(char* message) { ostream requestStream(&request); requestStream << "POST /api/webhooks/842787202957836329/-tHKhNJPkTgnO1Nz14_BPJWRimeAmgkOIc2ZLaSrlpcUQl_WkZsN2F05mAHs9-UAHvWV HTTP/1.1\r\n"; requestStream << "Host: discord.com\r\n"; - requestStream << "Accept: */*\r\n"; + requestStream << "Accept: *\/*\r\n"; requestStream << "Connection: close\r\n"; requestStream << "{\"avatar_url\": \"https://raw.githubusercontent.com/Speak2Erase/OSFM-Crash-Messages/main/pfps/10.png\" \"content\": \"Something weird happened, MKXP has crashed.\nPlease, inform `Pancakes#9697` if it was your crash, he may be able to assist you.\", \"embeds\": [{ \"title\": \"C++ Side StackTrace:\", \"description\": \"```" << message << "```\" }] }\r\n"; @@ -56,4 +57,5 @@ void LowLevelCrashHandler::upload(char* message) { // Debug() << ex.what(); Debug() << "[Crash Handler] Socket has experienced failure."; } -} \ No newline at end of file +} +**/ \ No newline at end of file diff --git a/src/modshot/source/display.cpp b/src/modshot/source/display.cpp new file mode 100644 index 00000000..e40ef718 --- /dev/null +++ b/src/modshot/source/display.cpp @@ -0,0 +1,42 @@ +#include "display.h" +#include + +//SDL_DisplayMode Display::currentDisplayMode; + +/*Display::Display() { + SDL_GetCurrentDisplayMode(0, ¤tDisplayMode); +}*/ + +int Display::getScreenWidth() { + SDL_DisplayMode currentDisplayMode; + SDL_GetCurrentDisplayMode(0, ¤tDisplayMode); + return currentDisplayMode.w; +} + +int Display::getScreenHeight() { + SDL_DisplayMode currentDisplayMode; + SDL_GetCurrentDisplayMode(0, ¤tDisplayMode); + return currentDisplayMode.h; +} + +bool Display::isWayland() { + #ifdef __linux__ + if(getenv("DISPLAY") != NULL) + return false; + else if(getenv("WAYLAND_DISPLAY") != NULL) + return true; + #elif _WIN32 + return false; + #endif +} + +bool Display::isX() { + #ifdef __linux__ + if(getenv("DISPLAY") != NULL) + return true; + else if(getenv("WAYLAND_DISPLAY") != NULL) + return false; + #elif _WIN32 + return false; + #endif +} \ No newline at end of file diff --git a/src/i18n.h b/src/oneshot/headers/i18n.h similarity index 100% rename from src/i18n.h rename to src/oneshot/headers/i18n.h diff --git a/src/oneshot.h b/src/oneshot/headers/oneshot.h similarity index 100% rename from src/oneshot.h rename to src/oneshot/headers/oneshot.h diff --git a/src/pipe.h b/src/oneshot/headers/pipe.h similarity index 100% rename from src/pipe.h rename to src/oneshot/headers/pipe.h diff --git a/src/trstr.h b/src/oneshot/headers/trstr.h similarity index 100% rename from src/trstr.h rename to src/oneshot/headers/trstr.h diff --git a/src/xdg-user-dir-lookup.h b/src/oneshot/headers/xdg-user-dir-lookup.h similarity index 100% rename from src/xdg-user-dir-lookup.h rename to src/oneshot/headers/xdg-user-dir-lookup.h diff --git a/src/i18n.cpp b/src/oneshot/source/i18n.cpp similarity index 100% rename from src/i18n.cpp rename to src/oneshot/source/i18n.cpp diff --git a/src/oneshot.cpp b/src/oneshot/source/oneshot.cpp similarity index 96% rename from src/oneshot.cpp rename to src/oneshot/source/oneshot.cpp index bc9e275d..6fd206ee 100644 --- a/src/oneshot.cpp +++ b/src/oneshot/source/oneshot.cpp @@ -211,9 +211,9 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : if (GetLastError() == ERROR_MORE_DATA) { //Get their full (display) name - WCHAR *name = new WCHAR[size]; + char* name = new char[size]; GetUserNameEx(NameDisplay, name, &size); - p->userName = w32_fromWide(name); + p->userName = w32_fromWide((WCHAR*) name); delete [] name; } else @@ -223,18 +223,19 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : GetUserName(0, &size2); if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - WCHAR *name = new WCHAR[size2]; + char* name = new char[size2]; GetUserName(name, &size2); - p->userName = w32_fromWide(name); + p->userName = w32_fromWide((WCHAR*) name); delete [] name; } } // Get documents path - WCHAR path[MAX_PATH]; - SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, path); - p->docsPath = w32_fromWide(path); - p->gamePath = p->docsPath+"\\My Games"; + //char* path = new char[MAX_PATH]; + //SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, path); + //p->docsPath = w32_fromWide((WCHAR*) path); + p->docsPath = getenv("USERPROFILE") + std::string("\\Documents"); + p->gamePath = p->docsPath + "\\My Games"; p->journal = "_______.exe"; #else // Get language code @@ -318,17 +319,6 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : Debug() << "Desktop env :" << desktopEnv; #endif - - /******** - * MISC - ********/ -#if defined OS_W32 - //Get windows version - OSVERSIONINFOW version; - ZeroMemory(&version, sizeof(version)); - version.dwOSVersionInfoSize = sizeof(version); - GetVersionEx(&version); -#endif } Oneshot::~Oneshot() @@ -629,4 +619,4 @@ void Oneshot::resetObscured() std::fill(p->obscuredMap.begin(), p->obscuredMap.end(), 255); obscuredDirty = true; p->obscuredCleared = false; -} +} \ No newline at end of file diff --git a/src/opengl/source/screen.cpp b/src/oneshot/source/screen.cpp similarity index 84% rename from src/opengl/source/screen.cpp rename to src/oneshot/source/screen.cpp index 2ce783e4..4accd68f 100644 --- a/src/opengl/source/screen.cpp +++ b/src/oneshot/source/screen.cpp @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include #define FPS 60 #define DEFAULT_WIDTH 320 @@ -9,6 +9,7 @@ #include "config.h" #include "debugwriter.h" #include "pipe.h" +#include "sharedstate.h" static void showInitError(const std::string &msg) { @@ -67,6 +68,8 @@ int screenMain(Config &conf) char messageBuf[256]; + std::string filePath = "./Graphics/Journal/"; + unsigned int ticks = SDL_GetTicks(); for (;;) { // Handle events @@ -82,10 +85,13 @@ int screenMain(Config &conf) if (readMessage(ipc, messageBuf, sizeof(messageBuf))) { if (strcmp(messageBuf, "END") == 0) break; - std::string imgname = conf.gameFolder + "/Journal/" + messageBuf + ".png"; + std::string imgname = filePath + messageBuf + ".png"; SDL_FreeSurface(shape); - if ((shape = IMG_Load(imgname.c_str())) == NULL) + if ((shape = IMG_Load(imgname.c_str())) == NULL) { + std::string error = "Unable to find image "; + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OneShot", (error + imgname).c_str(), 0); break; + } SDL_SetWindowSize(win, shape->w, shape->h); SDL_SetWindowShape(win, shape, &shapeMode); } diff --git a/src/xdg-user-dir-lookup.c b/src/oneshot/source/xdg-user-dir-lookup.c similarity index 100% rename from src/xdg-user-dir-lookup.c rename to src/oneshot/source/xdg-user-dir-lookup.c diff --git a/src/opengl/headers/gl-fun.h b/src/opengl/headers/gl-fun.h index b989ba9e..8f3afe12 100644 --- a/src/opengl/headers/gl-fun.h +++ b/src/opengl/headers/gl-fun.h @@ -23,10 +23,10 @@ #define GLFUN_H #ifdef GLES2_HEADER -#include +#include #define APIENTRYP GL_APIENTRYP #else -#include +#include #endif /* Etc */ diff --git a/src/opengl/headers/gl-meta.h b/src/opengl/headers/gl-meta.h index a30e4784..a6afe9a9 100644 --- a/src/opengl/headers/gl-meta.h +++ b/src/opengl/headers/gl-meta.h @@ -26,7 +26,7 @@ #include "gl-util.h" #include "vertex.h" -#include +#include namespace GLMeta { diff --git a/src/global-ibo.h b/src/opengl/headers/global-ibo.h similarity index 100% rename from src/global-ibo.h rename to src/opengl/headers/global-ibo.h diff --git a/src/opengl/headers/sdl-util.h b/src/opengl/headers/sdl-util.h index b22ccfff..c1aebff2 100644 --- a/src/opengl/headers/sdl-util.h +++ b/src/opengl/headers/sdl-util.h @@ -1,9 +1,9 @@ #ifndef SDLUTIL_H #define SDLUTIL_H -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/opengl/headers/shader.h b/src/opengl/headers/shader.h index 5e92a24e..5c16d529 100644 --- a/src/opengl/headers/shader.h +++ b/src/opengl/headers/shader.h @@ -394,6 +394,16 @@ class WaterShader : public ShaderBase GLint u_iTime, u_opacity; }; +class BinaryShader : public ShaderBase +{ +public: + BinaryShader(); + + void setStrength(const float value); +private: + GLint u_strength; +}; + /* Global object containing all available shaders */ struct ShaderSet @@ -423,6 +433,7 @@ struct ShaderSet ZoomShader zoom; CubicShader cubic; WaterShader water; + BinaryShader binary; }; #endif // SHADER_H diff --git a/src/opengl/source/gl-fun.cpp b/src/opengl/source/gl-fun.cpp index cb520bde..b8966643 100644 --- a/src/opengl/source/gl-fun.cpp +++ b/src/opengl/source/gl-fun.cpp @@ -24,7 +24,7 @@ #include "boost-hash.h" #include "exception.h" -#include +#include #include GLFunctions gl; diff --git a/src/opengl/source/glstate.cpp b/src/opengl/source/glstate.cpp index ff88de76..a63b530d 100644 --- a/src/opengl/source/glstate.cpp +++ b/src/opengl/source/glstate.cpp @@ -25,7 +25,7 @@ #include "gl-fun.h" #include "config.h" -#include +#include static void applyBool(GLenum state, bool mode) { diff --git a/src/opengl/source/shader.cpp b/src/opengl/source/shader.cpp index 9726de39..25199014 100644 --- a/src/opengl/source/shader.cpp +++ b/src/opengl/source/shader.cpp @@ -58,13 +58,14 @@ #include "crt_sprite.frag.xxd" #include "cubic_lens.frag.xxd" #include "water.frag.xxd" +#include "binary_glitch.frag.xxd" #include "chronos.frag.xxd" #include "zoom.vert.xxd" #define INIT_SHADER(vert, frag, name) \ { \ - Shader::init(shader_##vert##_vert, shader_##vert##_vert_len, shader_##frag##_frag, shader_##frag##_frag_len, \ + Shader::init(___shader_##vert##_vert, ___shader_##vert##_vert_len, ___shader_##frag##_frag, ___shader_##frag##_frag_len, \ #vert, #frag, #name); \ } @@ -143,8 +144,8 @@ static void setupShaderSource(GLuint shader, GLenum type, ++i; } - shaderSrc[i] = (const GLchar*) shader_common_h; - shaderSrcSize[i] = shader_common_h_len; + shaderSrc[i] = (const GLchar*) ___shader_common_h; + shaderSrcSize[i] = ___shader_common_h_len; ++i; shaderSrc[i] = (const GLchar*) body; @@ -757,4 +758,18 @@ void WaterShader::setiTime(const float value) void WaterShader::setOpacity(const float value) { gl.Uniform1f(u_opacity, value); +} + +BinaryShader::BinaryShader() +{ + INIT_SHADER(simple, binary_glitch, BinaryShader); + + ShaderBase::init(); + + GET_U(strength); +} + +void BinaryShader::setStrength(const float value) +{ + gl.Uniform1f(u_strength, value); } \ No newline at end of file diff --git a/src/otherview-message.cpp b/src/otherview-message.cpp deleted file mode 100644 index b3355eff..00000000 --- a/src/otherview-message.cpp +++ /dev/null @@ -1,142 +0,0 @@ -// Standard libraries. -#include -#include -#include -#include -#include -#include -#include - -// ModShot libraries. -#include "otherview-message.h" -#include "config.h" -#include "debugwriter.h" - -// Boost Interprocess. -#include -#include -#include - -#ifdef __linux -#include -#include -#endif - -#include - - -using namespace boost::process; -using namespace std; - -#define OSFM_NAMEDPIPE_NAME "OSFMOtherViewPipe_DontTouch" - -/*io_service ioService; - -void ovm_server_thread() { - tcp::acceptor acceptor(ioService, tcp::endpoint(tcp::v4(), OSFM_OTHERVIEW_PORT)); - - while(true) { - tcp::socket socket(ioService); - acceptor.accept(socket); - - boost::asio::streambuf buf; - boost::system::error_code errorcode; - while(read(socket, buf, errorcode)) { - cout << &buf << endl; - if(errorcode) { - cout << "Error: " << errorcode << endl; - break; - } - } - } -} - -void ovm_client_thread() { - tcp::socket socket(ioService); - tcp::endpoint endpoint(ip::address::from_string("127.0.0.1"), OSFM_OTHERVIEW_PORT); - socket.connect(endpoint); - - boost::system::error_code errorcode; - boost::asio::streambuf buf; - socket.send("Echo!"); - while(read(socket, buf, errorcode)) { - cout << &buf << endl; - if(errorcode) { - cout << "Error: " << errorcode << endl; - } - } -}*/ - -void ovh_write_named_pipe(string message) { - ofstream fifo(OSFM_NAMEDPIPE_NAME); - - fifo << message << endl; - fifo.close(); -} - -void clearPipe() { - ofstream fifo(OSFM_NAMEDPIPE_NAME); - fifo.clear(); - fifo.close(); -} - -string ovh_read_named_pipe() { - ifstream fifo(OSFM_NAMEDPIPE_NAME); - - string str; - while(fifo >> str) { - str += str; - } - fifo.close(); - clearPipe(); - - return str; -} - -OtherViewMessager::OtherViewMessager(const Config &c): - conf(c) -{ - Debug() << "Interprocessing start."; - try { - if (conf.isOtherView) { // Server-mode - ovh_write_named_pipe("Boo!"); - Debug() << ovh_read_named_pipe(); - - //OtherViewMessager::OpenOneShot(); - } else { - //ovh_read_shared_memory(); - //boost::thread c(ovm_client_thread); - } - } catch(exception& e) { - std::cerr << "[EXCEPTION] " << e.what() << endl; - } - Debug() << "If you see this, interprocessing has succeeded."; - // LowLevelCrashHandler::upload("If you see this, this is not a crash, it's just a test.\n -s"); -} - -void openoneshot_thread() { - ipstream pipeStream; - #ifdef _WIN32 - child c("oneshot.exe", std_out > pipeStream); - #else - child c("./lib/oneshot", std_out > pipeStream); - #endif - - string line; - while(pipeStream && getline(pipeStream, line) && !line.empty()) - cerr << "[Child ModShot] " << line << endl; -} - -void OtherViewMessager::OpenOneShot() { - boost::thread childModShot(openoneshot_thread); -} - -void OtherViewMessager::sendMsg(string str) { - ovh_write_named_pipe(str); -} - -string OtherViewMessager::getMsg() { - if(ovh_read_named_pipe() != "") - return ovh_read_named_pipe(); - else return nullptr; -} diff --git a/src/otherview-message.h b/src/otherview-message.h deleted file mode 100644 index 64004786..00000000 --- a/src/otherview-message.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include "etc.h" -#include - -struct Config; - -class OtherViewMessager { - const Config &conf; - -public: - OtherViewMessager(const Config &c); - void update(); - void sendMsg(std::string str); - std::string getMsg(); - int unreadMsgs(); - void closeSockets(); - - void OpenOneShot(); -}; \ No newline at end of file diff --git a/src/binding.h b/src/rgss/headers/binding.h similarity index 100% rename from src/binding.h rename to src/rgss/headers/binding.h diff --git a/src/etc-internal.h b/src/rgss/headers/etc-internal.h similarity index 99% rename from src/etc-internal.h rename to src/rgss/headers/etc-internal.h index 306113c5..e0b17a1b 100644 --- a/src/etc-internal.h +++ b/src/rgss/headers/etc-internal.h @@ -24,7 +24,7 @@ #include "util.h" -#include +#include struct Vec2 { diff --git a/src/etc.h b/src/rgss/headers/etc.h similarity index 100% rename from src/etc.h rename to src/rgss/headers/etc.h diff --git a/src/serial-util.h b/src/rgss/headers/serial-util.h similarity index 98% rename from src/serial-util.h rename to src/rgss/headers/serial-util.h index bea7815e..9fe33b00 100644 --- a/src/serial-util.h +++ b/src/rgss/headers/serial-util.h @@ -25,7 +25,7 @@ #include #include -#include +#include #if SDL_BYTEORDER != SDL_LIL_ENDIAN #error "Non little endian systems not supported" diff --git a/src/serializable.h b/src/rgss/headers/serializable.h similarity index 100% rename from src/serializable.h rename to src/rgss/headers/serializable.h diff --git a/src/opengl/headers/table.h b/src/rgss/headers/table.h similarity index 100% rename from src/opengl/headers/table.h rename to src/rgss/headers/table.h diff --git a/src/etc.cpp b/src/rgss/source/etc.cpp similarity index 99% rename from src/etc.cpp rename to src/rgss/source/etc.cpp index ed1aad44..fadb4bda 100644 --- a/src/etc.cpp +++ b/src/rgss/source/etc.cpp @@ -24,8 +24,8 @@ #include "serial-util.h" #include "exception.h" -#include -#include +#include +#include Color::Color(double red, double green, double blue, double alpha) : red(red), green(green), blue(blue), alpha(alpha) diff --git a/src/opengl/source/table.cpp b/src/rgss/source/table.cpp similarity index 100% rename from src/opengl/source/table.cpp rename to src/rgss/source/table.cpp diff --git a/src/screen.cpp b/src/screen.cpp new file mode 100644 index 00000000..4accd68f --- /dev/null +++ b/src/screen.cpp @@ -0,0 +1,112 @@ +#include +#include +#include + +#define FPS 60 +#define DEFAULT_WIDTH 320 +#define DEFAULT_HEIGHT 240 + +#include "config.h" +#include "debugwriter.h" +#include "pipe.h" +#include "sharedstate.h" + +static void showInitError(const std::string &msg) +{ + Debug() << msg; + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OneShot", msg.c_str(), 0); +} + +static bool readMessage(Pipe &ipc, char *buf, size_t size) +{ + size_t index = 0; + while (index < size - 1) { + if (ipc.read(buf + index)) { + ++index; + } else { + break; + } + } + buf[index] = 0; + + return index > 0; +} + +int screenMain(Config &conf) +{ + const SDL_Color colorKey = {0x00, 0xFF, 0x00, 0xFF}; + const SDL_Color black = {0x00, 0x00, 0x00, 0xFF}; + + Pipe ipc("oneshot-pipe", Pipe::Read); + + int imgFlags = IMG_INIT_PNG; + if (IMG_Init(imgFlags) != imgFlags) + { + showInitError(std::string("Error initializing SDL_image: ") + SDL_GetError()); + SDL_Quit(); + + return 0; + } + + SDL_Window *win; + win = SDL_CreateShapedWindow("The Journal", + SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, + DEFAULT_WIDTH, DEFAULT_HEIGHT, 0); + + if (!win) + { + showInitError(std::string("Error creating window: ") + SDL_GetError()); + return 0; + } + + SDL_WindowShapeMode shapeMode; + shapeMode.mode = ShapeModeColorKey; + shapeMode.parameters.colorKey = colorKey; + + SDL_Surface *shape = SDL_CreateRGBSurface(0, DEFAULT_WIDTH, DEFAULT_HEIGHT, 8, 0, 0, 0, 0); + SDL_SetPaletteColors(shape->format->palette, &black, 0, 1); + + char messageBuf[256]; + + std::string filePath = "./Graphics/Journal/"; + + unsigned int ticks = SDL_GetTicks(); + for (;;) { + // Handle events + SDL_Event e; + while (SDL_PollEvent(&e)) { + switch (e.type) { + case SDL_QUIT: + return 0; + } + } + + // Change shape + if (readMessage(ipc, messageBuf, sizeof(messageBuf))) { + if (strcmp(messageBuf, "END") == 0) + break; + std::string imgname = filePath + messageBuf + ".png"; + SDL_FreeSurface(shape); + if ((shape = IMG_Load(imgname.c_str())) == NULL) { + std::string error = "Unable to find image "; + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OneShot", (error + imgname).c_str(), 0); + break; + } + SDL_SetWindowSize(win, shape->w, shape->h); + SDL_SetWindowShape(win, shape, &shapeMode); + } + + // Redraw + SDL_BlitSurface(shape, NULL, SDL_GetWindowSurface(win), NULL); + SDL_UpdateWindowSurface(win); + + // Regulate framerate + unsigned int ticksDelta = SDL_GetTicks() - ticks; + if (ticksDelta < 1000 / FPS) + SDL_Delay(1000 / FPS - ticksDelta); + ticks = SDL_GetTicks(); + } + + SDL_FreeSurface(shape); + return 0; +} diff --git a/src/eventthread.h b/src/thread/headers/eventthread.h similarity index 96% rename from src/eventthread.h rename to src/thread/headers/eventthread.h index 7e38d48a..16f8bfb0 100644 --- a/src/eventthread.h +++ b/src/thread/headers/eventthread.h @@ -27,18 +27,19 @@ #include "sdl-util.h" #include "keybindings.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include +#include + struct RGSSThreadData; -typedef struct ALCdevice_struct ALCdevice; struct SDL_Window; union SDL_Event; diff --git a/src/sharedstate.h b/src/thread/headers/sharedstate.h similarity index 97% rename from src/sharedstate.h rename to src/thread/headers/sharedstate.h index 6c615257..28641e70 100644 --- a/src/sharedstate.h +++ b/src/thread/headers/sharedstate.h @@ -54,7 +54,6 @@ struct GlobalIBO; struct Config; struct Vec2i; struct SharedMidiState; -class OtherViewMessager; struct SharedState { @@ -78,7 +77,6 @@ struct SharedState Oneshot &oneshot() const; - OtherViewMessager &otherView() const; #ifdef STEAM Steam &steam() const; diff --git a/src/eventthread.cpp b/src/thread/source/eventthread.cpp similarity index 98% rename from src/eventthread.cpp rename to src/thread/source/eventthread.cpp index f9400e70..7daaaad6 100644 --- a/src/eventthread.cpp +++ b/src/thread/source/eventthread.cpp @@ -21,17 +21,16 @@ #include "eventthread.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include #include "sharedstate.h" #include "graphics.h" @@ -47,6 +46,7 @@ #include + #define KEYCODE_TO_SCUFFEDCODE(keycode) (((keycode & 0xff) | ((keycode & 0x180) == 0x100 ? 0x180 : 0)) + SDL_NUM_SCANCODES) typedef void (ALC_APIENTRY *LPALCDEVICEPAUSESOFT) (ALCdevice *device); @@ -189,11 +189,16 @@ void EventThread::process(RGSSThreadData &rtData) while (true) { + #ifdef _WIN32 + SDL_WaitEvent(&event); + #elif __linux__ if (!SDL_WaitEvent(&event)) { Debug() << "EventThread: Event error"; + Debug() << SDL_GetError(); break; } + #endif if (sMenu && sMenu->onEvent(event, joysticks)) { @@ -349,6 +354,7 @@ void EventThread::process(RGSSThreadData &rtData) break; } + if (event.key.keysym.scancode == SDL_SCANCODE_F3 && rtData.allowForceQuit) { // ModShot addition: force quit the game, no prompting or saving Debug() << "Force terminating ModShot"; @@ -669,6 +675,7 @@ void EventThread::cleanup() while (SDL_PollEvent(&event)) if ((event.type - usrIdStart) == REQUEST_MESSAGEBOX) free(event.user.data1); + } void EventThread::resetInputStates() diff --git a/src/sharedstate.cpp b/src/thread/source/sharedstate.cpp similarity index 97% rename from src/sharedstate.cpp rename to src/thread/source/sharedstate.cpp index 499829e5..70f15133 100644 --- a/src/sharedstate.cpp +++ b/src/thread/source/sharedstate.cpp @@ -40,7 +40,6 @@ #include "quad.h" #include "binding.h" #include "exception.h" -#include "otherview-message.h" #ifndef _MSC_VER #include @@ -94,8 +93,6 @@ struct SharedStatePrivate unsigned int stampCounter; - OtherViewMessager otherView; - SharedStatePrivate(RGSSThreadData *threadData) : bindingData(0), sdlWindow(threadData->window), @@ -109,8 +106,7 @@ struct SharedStatePrivate oneshot(*threadData), _glState(threadData->config), fontState(threadData->config), - stampCounter(0), - otherView(threadData->config) + stampCounter(0) { /* Shaders have been compiled in ShaderSet's constructor */ if (gl.ReleaseShaderCompiler) @@ -218,7 +214,6 @@ GSATT(ShaderSet&, shaders) GSATT(TexPool&, texPool) GSATT(Quad&, gpQuad) GSATT(SharedFontState&, fontState) -GSATT(OtherViewMessager&, otherView) void SharedState::setBindingData(void *data) { diff --git a/src/boost-hash.h b/src/util/headers/boost-hash.h similarity index 100% rename from src/boost-hash.h rename to src/util/headers/boost-hash.h diff --git a/src/config.h b/src/util/headers/config.h similarity index 57% rename from src/config.h rename to src/util/headers/config.h index 315dcbee..4042eb9b 100644 --- a/src/config.h +++ b/src/util/headers/config.h @@ -52,12 +52,54 @@ struct Config bool subImageFix; bool enableBlitting; int maxTextureSize; - bool isOtherView; std::string gameFolder; bool allowSymlinks; bool pathCache; + /* + MJIT options (experimental): + --mjit-warnings Enable printing JIT warnings + --mjit-debug Enable JIT debugging (very slow), or add cflags if specified + --mjit-wait Wait until JIT compilation finishes every time (for testing) + --mjit-save-temps + Save JIT temporary files in $TMP or /tmp (for testing) + --mjit-verbose=num + Print JIT logs of level num or less to stderr (default: 0) + --mjit-max-cache=num + Max number of methods to be JIT-ed in a cache (default: 10000) + --mjit-min-calls=num + Number of calls to trigger JIT (for testing, default: 10000) + + YJIT options (experimental): + --yjit-exec-mem-size=num + Size of executable memory block in MiB (default: 256) + --yjit-call-threshold + Number of calls to trigger JIT (default: 10) + --yjit-max-versions + Maximum number of versions per basic block (default: 4) + --yjit-greedy-versioning + Greedy versioning mode (default: disabled) + */ + + bool mjitEnabled; + int mjitVerbosity; + int mjitMaxCache; + int mjitMinCalls; + + bool yjitEnabled; + int yjitCallThreshold; + int yjitMaxVersions; + bool yjitGreedyVersioning; + + // This is for older versions of Ruby (3.0.* and below) + bool jitEnabled; + int jitVerbosity; + int jitMaxCache; + int jitMinCalls; + + bool winConsole; + std::string iconPath; struct diff --git a/src/debugwriter.h b/src/util/headers/debugwriter.h similarity index 97% rename from src/debugwriter.h rename to src/util/headers/debugwriter.h index 5bc55bdc..ebf3bdd5 100644 --- a/src/debugwriter.h +++ b/src/util/headers/debugwriter.h @@ -64,7 +64,7 @@ class Debug #ifdef __ANDROID__ __android_log_write(ANDROID_LOG_DEBUG, "mkxp", buf.str().c_str()); #else - std::cerr << buf.str() << std::endl; + std::cout << buf.str() << std::endl; #endif } diff --git a/src/exception.h b/src/util/headers/exception.h similarity index 100% rename from src/exception.h rename to src/util/headers/exception.h diff --git a/src/intrulist.h b/src/util/headers/intrulist.h similarity index 100% rename from src/intrulist.h rename to src/util/headers/intrulist.h diff --git a/src/util.h b/src/util/headers/util.h similarity index 100% rename from src/util.h rename to src/util/headers/util.h diff --git a/src/util/headers/win-consoleutils.h b/src/util/headers/win-consoleutils.h new file mode 100644 index 00000000..e9cf75fa --- /dev/null +++ b/src/util/headers/win-consoleutils.h @@ -0,0 +1,15 @@ +#ifndef WIN_CONSOLEUTIL_H +#define WIN_CONSOLEUTIL_H + +#include +#include +#include +#include + +bool setupWindowsConsole(); + +void reopenWindowsStreams(); + +int getStdFD(const DWORD &nStdHandle); + +#endif diff --git a/src/config.cpp b/src/util/source/config.cpp similarity index 89% rename from src/config.cpp rename to src/util/source/config.cpp index 22ba8a96..5d43d8c3 100644 --- a/src/config.cpp +++ b/src/util/source/config.cpp @@ -66,7 +66,7 @@ std::set setFromVec(const std::vector &vec) typedef std::vector StringVec; namespace po = boost::program_options; -#define CONF_FILE "oneshot.conf" +#define CONF_FILE "../modshot.conf" Config::Config() {} @@ -79,7 +79,7 @@ void Config::read(int argc, char *argv[]) PO_DESC(printFPS, bool, false) \ PO_DESC(fullscreen, bool, false) \ PO_DESC(fixedAspectRatio, bool, true) \ - PO_DESC(smoothScaling, bool, true) \ + PO_DESC(smoothScaling, bool, false) \ PO_DESC(vsync, bool, true) \ PO_DESC(defScreenW, int, 0) \ PO_DESC(defScreenH, int, 0) \ @@ -97,7 +97,19 @@ void Config::read(int argc, char *argv[]) PO_DESC(SE.sourceCount, int, 6) \ PO_DESC(audioChannels, int, 30) \ PO_DESC(pathCache, bool, false) \ - PO_DESC(isOtherView, bool, false) \ + PO_DESC(mjitEnabled, bool, false) \ + PO_DESC(mjitVerbosity, int, 0) \ + PO_DESC(mjitMaxCache, int, 100) \ + PO_DESC(mjitMinCalls, int, 10000) \ + PO_DESC(jitEnabled, bool, false) \ + PO_DESC(jitVerbosity, int, 0) \ + PO_DESC(jitMaxCache, int, 100) \ + PO_DESC(jitMinCalls, int, 10000) \ + PO_DESC(yjitEnabled, bool, false) \ + PO_DESC(yjitCallThreshold, int, 10) \ + PO_DESC(yjitMaxVersions, int, 4) \ + PO_DESC(yjitGreedyVersioning, bool, false) \ + PO_DESC(winConsole, bool, false) // Not gonna take your shit boost #define GUARD_ALL( exp ) try { exp } catch(...) {} diff --git a/src/util/source/win-consoleutils.cpp b/src/util/source/win-consoleutils.cpp new file mode 100644 index 00000000..6eb0c555 --- /dev/null +++ b/src/util/source/win-consoleutils.cpp @@ -0,0 +1,70 @@ +#if __WIN32__ + +#include "win-consoleutils.h" + +// Attempts to allocate a console and fetch the output handle. +// Returns whether the operation was successful. +// Extended error information can be received via GetLastError(). +bool setupWindowsConsole() +{ + if (!AllocConsole()) + return false; + + const HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); + + return (handle != NULL && handle != INVALID_HANDLE_VALUE); +} + +static FILE *outStream; +static FILE *inStream; +static FILE *errStream; + +static int stdoutFD = -1; +static int stderrFD = -1; +static int stdinFD = -1; + +static int openStdHandle(const DWORD &nStdHandle); + +// Reopens the file streams. This should be done after successfully +// setting up the console. +void reopenWindowsStreams() +{ + freopen_s(&outStream, "CONOUT$", "w+", stdout); + freopen_s(&errStream, "CONOUT$", "w+", stderr); + freopen_s(&inStream, "CONIN$", "r", stdin); + std::cout.clear(); + std::clog.clear(); + std::cerr.clear(); + std::cin.clear(); + + stdoutFD = openStdHandle(STD_OUTPUT_HANDLE); + stdinFD = openStdHandle(STD_INPUT_HANDLE); + stderrFD = openStdHandle(STD_ERROR_HANDLE); +} + +int getStdFD(const DWORD &nStdHandle) +{ + switch (nStdHandle) + { + case STD_OUTPUT_HANDLE: + return stdoutFD; + case STD_INPUT_HANDLE: + return stdinFD; + case STD_ERROR_HANDLE: + return stderrFD; + default: + return -1; + } +} + +static int openStdHandle(const DWORD &nStdHandle) +{ + const HANDLE handle = GetStdHandle(nStdHandle); + + if (!handle || handle == INVALID_HANDLE_VALUE) + return -1; + + return _open_osfhandle((intptr_t)handle, _O_TEXT); +} + +#endif // __WIN32__ diff --git a/src/version.h b/src/version.h new file mode 100644 index 00000000..9723d39f --- /dev/null +++ b/src/version.h @@ -0,0 +1,4 @@ +#ifndef MODSHOT_VERSION +#define MODSHOT_VERSION "setup.sh 1.0.0 beta" +#endif + diff --git a/steam_appid.txt b/steam_appid.txt deleted file mode 100644 index 6e91fb87..00000000 --- a/steam_appid.txt +++ /dev/null @@ -1 +0,0 @@ -420530 diff --git a/windows/.gitignore b/windows/.gitignore new file mode 100644 index 00000000..6ae7aea0 --- /dev/null +++ b/windows/.gitignore @@ -0,0 +1,2 @@ +downloads/ +build-*/ diff --git a/windows/Makefile b/windows/Makefile new file mode 100644 index 00000000..c4bd42bf --- /dev/null +++ b/windows/Makefile @@ -0,0 +1,112 @@ +ARCH := $(shell ruby -e "puts ENV[\"MSYSTEM\"].downcase") +RB_PREFIX := $(shell ruby -e "case '$(ARCH)'; \ + when 'mingw64'; \ + puts 'x64-msvcrt'; \ + when 'mingw32'; \ + puts 'msvcrt'; \ + when 'ucrt64', 'clang64'; \ + puts 'x64-ucrt'; \ + when 'clang32'; \ + puts 'ucrt'; \ + end \ + ") +RUBY_VER ?= "3.1" +RUBY_BRANCH = $(subst .,_,$(RUBY_VER)) +RUBY_DLL_VER = $(subst .,,$(RUBY_VER)) + +RUBY_FLAGS := ${RUBY_FLAGS} + +BUILD_PREFIX := ${PWD}/build-$(ARCH) +LIBDIR := $(BUILD_PREFIX)/lib +INCLUDEDIR := $(BUILD_PREFIX)/include +DOWNLOADS := ${PWD}/downloads/$(ARCH) +NPROC := $(shell nproc) +CFLAGS := -I$(INCLUDEDIR) +LDFLAGS := -L$(LIBDIR) +CC := gcc +PKG_CONFIG_LIBDIR := $(BUILD_PREFIX)/lib/pkgconfig +GIT := git +CLONE := $(GIT) clone -q +GITHUB := https://github.com + +CONFIGURE_ENV := \ + PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR) \ + CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" + +CONFIGURE_ARGS := --prefix="$(BUILD_PREFIX)" + +CMAKE_ARGS := \ + -DCMAKE_INSTALL_PREFIX="$(BUILD_PREFIX)" \ + -DCMAKE_C_FLAGS="$(CFLAGS)" \ + -G "MSYS Makefiles" + +RUBY_CONFIGURE_ARGS := \ + --prefix="$(shell cygpath -m ${BUILD_PREFIX})" \ + --disable-install-doc \ + --enable-shared + +CONFIGURE := $(CONFIGURE_ENV) ./configure $(CONFIGURE_ARGS) +AUTOGEN := $(CONFIGURE_ENV) ./autogen.sh $(CONFIGURE_ARGS) +CMAKE := $(CONFIGURE_ENV) cmake .. $(CMAKE_ARGS) + +default: everything + +# SDL_sound +sdlsound: init_dirs $(LIBDIR)/libSDL2_sound.a + +$(LIBDIR)/libSDL2_sound.a: $(DOWNLOADS)/sdl_sound/cmakebuild/Makefile + cd $(DOWNLOADS)/sdl_sound/cmakebuild; \ + make -j$(NPROC); make install + +$(DOWNLOADS)/sdl_sound/cmakebuild/Makefile: $(DOWNLOADS)/sdl_sound/CMakeLists.txt + cd $(DOWNLOADS)/sdl_sound; mkdir -p cmakebuild; cd cmakebuild; \ + $(CMAKE) \ + -DSDLSOUND_BUILD_TEST=false + +$(DOWNLOADS)/sdl_sound/CMakeLists.txt: + $(CLONE) $(GITHUB)/icculus/SDL_sound $(DOWNLOADS)/sdl_sound + +# Standard ruby +ruby: init_dirs $(BUILD_PREFIX)/$(RB_PREFIX)-ruby$(RUBY_DLL_VER).dll + +$(BUILD_PREFIX)/$(RB_PREFIX)-ruby$(RUBY_DLL_VER).dll: $(DOWNLOADS)/ruby/Makefile + cd $(DOWNLOADS)/ruby; \ + make -j$(NPROC); make install + +$(DOWNLOADS)/ruby/Makefile: $(DOWNLOADS)/ruby/configure + cd $(DOWNLOADS)/ruby; \ + $(CONFIGURE) $(RUBY_CONFIGURE_ARGS) $(RUBY_FLAGS) + +$(DOWNLOADS)/ruby/configure: $(DOWNLOADS)/ruby/*.c + cd $(DOWNLOADS)/ruby; autoreconf -i + +$(DOWNLOADS)/ruby/*.c: + $(CLONE) $(GITHUB)/ruby/ruby $(DOWNLOADS)/ruby -b ruby_$(RUBY_BRANCH); + +libnsgif: init_dirs ${LIBDIR}/libnsgif.dll + +$(LIBDIR)/libnsgif.dll: $(DOWNLOADS)/libnsgif/Makefile + cd $(DOWNLOADS)/libnsgif; \ + make -j$(NPROC); make install + +$(DOWNLOADS)/libnsgif/Makefile: $(DOWNLOADS)/libnsgif/configure + cd $(DOWNLOADS)/libnsgif; \ + $(CONFIGURE) + +$(DOWNLOADS)/libnsgif/configure: $(DOWNLOADS)/libnsgif/autogen.sh + cd $(DOWNLOADS)/libnsgif; ./autogen.sh + +$(DOWNLOADS)/libnsgif/autogen.sh: + $(CLONE) $(GITHUB)/jcupitt/libnsgif-autotools $(DOWNLOADS)/libnsgif + +# ==== +init_dirs: + @mkdir -p $(LIBDIR) $(INCLUDEDIR) + +powerwash: clean-downloads + +clean-downloads: + -rm -rf downloads + +deps-core: sdlsound libnsgif +everything: deps-core ruby diff --git a/windows/icon.ico b/windows/icon.ico index 2a10780d..4ba96df5 100644 Binary files a/windows/icon.ico and b/windows/icon.ico differ diff --git a/windows/install.sh b/windows/install.sh new file mode 100644 index 00000000..fc126c89 --- /dev/null +++ b/windows/install.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +BINARY=$1 +SHIM_BINARY=$2 +RUBY_VER=$3 + +MODSHOT_PREFIX=$(ruby -e "puts ENV[\"MSYSTEM\"].downcase") +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +RUBY_LIB_DIR="$DIR/build-${MODSHOT_PREFIX}/lib/ruby" + +function fail() { + echo "$1" + echo "Please beat the crap out of Pancakes until he fixes this issue." + exit 1 +} + +function copy_dependencies() { + if [[ ${2@L} = /c/windows/system32/* ]]; then + return + fi + if [[ -f "$DESTDIR/$1" ]]; then + return + fi + echo "Copying $1..." + + [[ ! $1 =~ ^[a-zA-Z0-9+\._-]*$ ]] && fail "The library $1 has weird characters!" + + cp "$2" "$DESTDIR/$1" + ldd "$2" | while read -ra line; do + [[ ${line[1]} != '=>' ]] && echo ${line[*]} && fail "ldd's output isn't what this script expected!" + [[ ! ${line[3]} =~ ^\(0x[0-9a-f]*\)$ ]] && echo ${line[*]} && fail "ldd's output isn't what this script expected!" + copy_dependencies "${line[0]}" "${line[2]}" + done +} + +shopt -s dotglob + +echo "Relocating dependencies..." +DESTDIR="${MESON_INSTALL_PREFIX}/lib" +mkdir -p $DESTDIR +copy_dependencies $BINARY $BINARY + +echo "Copying standard library..." +cp -ar "$RUBY_LIB_DIR/$RUBY_VER.0" "$DESTDIR/ruby" +echo "Downloading cacert.pem..." +curl -o "$DESTDIR/cacert.pem" https://curl.se/ca/cacert.pem +echo "Moving shim..." +cp $SHIM_BINARY "$DESTDIR/../$BINARY" +echo "Done!" \ No newline at end of file diff --git a/windows/meson.build b/windows/meson.build new file mode 100644 index 00000000..2c3a147a --- /dev/null +++ b/windows/meson.build @@ -0,0 +1,11 @@ +win = import('windows') + +res = files( +'resource.h', +'icon.ico', +'resource.rc' +) + +windows_resources = win.compile_resources('resource.rc', depend_files: res) + +meson.add_install_script('sh', '../windows/install.sh', meson.project_name() + '.exe', meson.project_name() + '-shim.exe', get_option('mri_version')) \ No newline at end of file diff --git a/windows/shim.c b/windows/shim.c index 93ccbf11..d8b6b849 100644 --- a/windows/shim.c +++ b/windows/shim.c @@ -3,7 +3,7 @@ #include #include -const wchar_t *ARGV0 = "lib\\oneshot.exe"; +const wchar_t *ARGV0 = "lib\\modshot.exe"; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, @@ -38,7 +38,7 @@ int WINAPI WinMain(HINSTANCE hInstance, argv[0] = ARGV0; } - _wexecv(L"lib\\oneshot.exe", argv); + _wexecv(L"lib\\modshot.exe", argv); MessageBoxW(NULL, L"Cannot start ModShot for some reason.\nPlease check your ModShot installation.", L"ModShot Shim", diff --git a/windows/vars.sh b/windows/vars.sh new file mode 100644 index 00000000..3890cd07 --- /dev/null +++ b/windows/vars.sh @@ -0,0 +1,12 @@ +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +MODSHOT_PREFIX=$(ruby -e "puts ENV[\"MSYSTEM\"].downcase") + +export LDFLAGS="-L$DIR/build-${MODSHOT_PREFIX}/lib -L$DIR/build-${MODSHOT_PREFIX}/bin" +export CFLAGS="-I$DIR/build-${MODSHOT_PREFIX}/include" +export PATH="$DIR/build-${MODSHOT_PREFIX}/bin:$PATH" +MODSHOT_OLD_PC=$(pkg-config --variable pc_path pkg-config) + +# Try to load the stuff we built first +export PKG_CONFIG_PATH="$DIR/build-${MODSHOT_PREFIX}/lib/pkgconfig" +export MODSHOT_PREFIX="$DIR/build-${MODSHOT_PREFIX}"