Compare commits
2 Commits
12.2.rev11
...
fheroes2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e3a852855 | ||
|
|
1d85d74895 |
@@ -1,7 +0,0 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
indent_style = tab
|
||||
charset = utf-8
|
||||
156
.github/workflows/ballfield.yml
vendored
156
.github/workflows/ballfield.yml
vendored
@@ -1,156 +0,0 @@
|
||||
# Copyright (C) 2021-2021 Sergii Pylypenko <x.pelya.x@gmail.com>
|
||||
#
|
||||
# This software is provided 'as-is', without any express or implied
|
||||
# warranty. In no event will the authors be held liable for any damages
|
||||
# arising from the use of this software.
|
||||
#
|
||||
# Permission is granted to anyone to use this software for any purpose,
|
||||
# including commercial applications, and to alter it and redistribute it
|
||||
# freely, subject to the following restrictions:
|
||||
#
|
||||
# 1. The origin of this software must not be misrepresented; you must not
|
||||
# claim that you wrote the original software. If you use this software
|
||||
# in a product, an acknowledgment in the product documentation would be
|
||||
# appreciated but is not required.
|
||||
# 2. Altered source versions must be plainly marked as such, and must not be
|
||||
# misrepresented as being the original software.
|
||||
# 3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
name: ballfield
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '*'
|
||||
tags:
|
||||
- '*'
|
||||
pull_request: {}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
env:
|
||||
APP_NAME: ballfield
|
||||
# It takes one hour per one architecture to build Boost and ICU libraries, and Github limits CI script duration to 6 hours
|
||||
ARCH_LIST: armeabi-v7a arm64-v8a x86 x86_64
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check out the repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 1
|
||||
submodules: false
|
||||
|
||||
- name: Check out submodules
|
||||
# There are many more submodules in this repo, we don't need them all
|
||||
run: >
|
||||
git submodule update --init --recursive --depth=1
|
||||
project/jni/boost/src project/jni/iconv/src
|
||||
project/jni/sdl2 project/jni/sdl2_image
|
||||
project/jni/sdl2_mixer project/jni/sdl2_ttf
|
||||
|
||||
- name: Symlink the application dir
|
||||
run: |
|
||||
ln -s ${APP_NAME} project/jni/application/src
|
||||
|
||||
- name: Set architectures list
|
||||
run: |
|
||||
sed -i "s/MultiABI=.*/MultiABI='${ARCH_LIST}'/g" project/jni/application/src/AndroidAppSettings.cfg
|
||||
|
||||
# - name: Get Boost revision
|
||||
# id: boost-rev
|
||||
# run: echo "::set-output name=BOOST_REV::`git -C project/jni/boost/src rev-parse HEAD`"
|
||||
#
|
||||
# - name: Get ICU revision
|
||||
# id: icu-rev
|
||||
# run: echo "::set-output name=ICU_REV::`git -C project/jni/iconv/src rev-parse HEAD`"
|
||||
#
|
||||
# - name: Copy Boost libraries from cache
|
||||
# uses: actions/cache@v2
|
||||
# id: cache-boost
|
||||
# with:
|
||||
# # The same SDL revision will produce the same libraries
|
||||
# key: ${{steps.boost-rev.outputs.BOOST_REV}}
|
||||
# path: |
|
||||
# build-android/project/jni/boost/include
|
||||
# build-android/project/jni/boost/lib
|
||||
#
|
||||
# - name: Copy ICU libraries from cache
|
||||
# uses: actions/cache@v2
|
||||
# id: cache-icu
|
||||
# with:
|
||||
# # The same SDL revision will produce the same libraries
|
||||
# key: ${{steps.icu-rev.outputs.ICU_REV}}
|
||||
# path: |
|
||||
# build-android/project/jni/iconv/include
|
||||
# build-android/project/jni/iconv/lib
|
||||
# build-android/project/jni/icuuc/include
|
||||
# build-android/project/jni/icuuc/lib
|
||||
#
|
||||
# - name: Touch cached Boost timestamps
|
||||
# if: steps.cache-boost.outputs.cache-hit == 'true' || steps.cache-icu.outputs.cache-hit == 'true'
|
||||
# working-directory: build-android
|
||||
# run: touch project/jni/boost/lib/*/* || true
|
||||
#
|
||||
# - name: Touch cached ICU timestamps
|
||||
# if: steps.cache-boost.outputs.cache-hit == 'true' || steps.cache-icu.outputs.cache-hit == 'true'
|
||||
# working-directory: build-android
|
||||
# run: touch project/jni/iconv/lib/*/* project/jni/icuuc/lib/*/* || true
|
||||
|
||||
- name: Patch Java files and build Boost, ICU, and OpenSSL
|
||||
run: |
|
||||
export PATH=$ANDROID_NDK_LATEST_HOME:$PATH
|
||||
./changeAppSettings.sh
|
||||
|
||||
- name: Set up Gradle and Android SDK licenses
|
||||
working-directory: project
|
||||
run: |
|
||||
for Y in `seq 20`; do echo y; done | sudo $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses
|
||||
./gradlew assembleRelease || true
|
||||
for Y in `seq 20`; do echo y; done | sudo $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses --sdk_root=`pwd`
|
||||
mkdir -p $HOME/.android
|
||||
keytool -genkey -v -keystore $HOME/.android/debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "CN=Debug, OU=Debug, O=Debug, L=Debug, ST=Debug, C=Debug"
|
||||
echo "sdk.dir=$ANDROID_SDK_ROOT" > local.properties
|
||||
echo "proguard.config=proguard.cfg;proguard-local.cfg" >> local.properties
|
||||
|
||||
- name: Hyper turbo build script GOOOOOOOOOOOO
|
||||
run: |
|
||||
export PATH=$ANDROID_NDK_LATEST_HOME:$ANDROID_SDK_ROOT/build-tools/31.0.0:$PATH
|
||||
./build.sh
|
||||
|
||||
- name: App signing keys
|
||||
run: |
|
||||
echo "$ANDROID_KEYSTORE_B64" | base64 -d > keystore.jks || true
|
||||
echo "$ANDROID_UPLOAD_KEYSTORE_B64" | base64 -d > upload_keystore.jks || true
|
||||
find keystore.jks -empty -delete || true
|
||||
find upload_keystore.jks -empty -delete || true
|
||||
env:
|
||||
ANDROID_KEYSTORE_B64: "${{secrets.ANDROID_KEYSTORE_B64}}"
|
||||
ANDROID_UPLOAD_KEYSTORE_B64: "${{secrets.ANDROID_UPLOAD_KEYSTORE_B64}}"
|
||||
|
||||
- name: Package
|
||||
run: |
|
||||
export PATH=$ANDROID_NDK_LATEST_HOME:$ANDROID_SDK_ROOT/build-tools/31.0.0:$PATH
|
||||
if [ -e keystore.jks ]; then
|
||||
export ANDROID_KEYSTORE_FILE=`pwd`/keystore.jks
|
||||
fi
|
||||
if [ -e upload_keystore.jks ]; then
|
||||
export ANDROID_UPLOAD_KEYSTORE_FILE=`pwd`/upload_keystore.jks
|
||||
fi
|
||||
mkdir -p upload/
|
||||
./sign.sh
|
||||
mv *.apk upload/
|
||||
./signBundle.sh
|
||||
mv *.aab upload/
|
||||
env:
|
||||
ANDROID_KEYSTORE_PASS: "${{secrets.ANDROID_KEYSTORE_PASS}}"
|
||||
ANDROID_KEYSTORE_ALIAS: "${{secrets.ANDROID_KEYSTORE_ALIAS}}"
|
||||
ANDROID_UPLOAD_KEYSTORE_PASS: "${{secrets.ANDROID_UPLOAD_KEYSTORE_PASS}}"
|
||||
ANDROID_UPLOAD_KEYSTORE_ALIAS: "${{secrets.ANDROID_UPLOAD_KEYSTORE_ALIAS}}"
|
||||
|
||||
# Github actions is dumb and won't let you download single files from artifacts, so break up the artifacts instead
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{env.APP_NAME}}
|
||||
path: upload
|
||||
if-no-files-found: error
|
||||
156
.github/workflows/sdl2-demo.yml
vendored
156
.github/workflows/sdl2-demo.yml
vendored
@@ -1,156 +0,0 @@
|
||||
# Copyright (C) 2021-2021 Sergii Pylypenko <x.pelya.x@gmail.com>
|
||||
#
|
||||
# This software is provided 'as-is', without any express or implied
|
||||
# warranty. In no event will the authors be held liable for any damages
|
||||
# arising from the use of this software.
|
||||
#
|
||||
# Permission is granted to anyone to use this software for any purpose,
|
||||
# including commercial applications, and to alter it and redistribute it
|
||||
# freely, subject to the following restrictions:
|
||||
#
|
||||
# 1. The origin of this software must not be misrepresented; you must not
|
||||
# claim that you wrote the original software. If you use this software
|
||||
# in a product, an acknowledgment in the product documentation would be
|
||||
# appreciated but is not required.
|
||||
# 2. Altered source versions must be plainly marked as such, and must not be
|
||||
# misrepresented as being the original software.
|
||||
# 3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
name: sdl2-demo
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '*'
|
||||
tags:
|
||||
- '*'
|
||||
pull_request: {}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
env:
|
||||
APP_NAME: sdl2-demo
|
||||
# It takes one hour per one architecture to build Boost and ICU libraries, and Github limits CI script duration to 6 hours
|
||||
ARCH_LIST: armeabi-v7a arm64-v8a x86 x86_64
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check out the repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 1
|
||||
submodules: false
|
||||
|
||||
- name: Check out submodules
|
||||
# There are many more submodules in this repo, we don't need them all
|
||||
run: >
|
||||
git submodule update --init --recursive --depth=1
|
||||
project/jni/boost/src project/jni/iconv/src
|
||||
project/jni/sdl2 project/jni/sdl2_image
|
||||
project/jni/sdl2_mixer project/jni/sdl2_ttf
|
||||
|
||||
- name: Symlink the application dir
|
||||
run: |
|
||||
ln -s ${APP_NAME} project/jni/application/src
|
||||
|
||||
- name: Set architectures list
|
||||
run: |
|
||||
sed -i "s/MultiABI=.*/MultiABI='${ARCH_LIST}'/g" project/jni/application/src/AndroidAppSettings.cfg
|
||||
|
||||
# - name: Get Boost revision
|
||||
# id: boost-rev
|
||||
# run: echo "::set-output name=BOOST_REV::`git -C project/jni/boost/src rev-parse HEAD`"
|
||||
#
|
||||
# - name: Get ICU revision
|
||||
# id: icu-rev
|
||||
# run: echo "::set-output name=ICU_REV::`git -C project/jni/iconv/src rev-parse HEAD`"
|
||||
#
|
||||
# - name: Copy Boost libraries from cache
|
||||
# uses: actions/cache@v2
|
||||
# id: cache-boost
|
||||
# with:
|
||||
# # The same SDL revision will produce the same libraries
|
||||
# key: ${{steps.boost-rev.outputs.BOOST_REV}}
|
||||
# path: |
|
||||
# build-android/project/jni/boost/include
|
||||
# build-android/project/jni/boost/lib
|
||||
#
|
||||
# - name: Copy ICU libraries from cache
|
||||
# uses: actions/cache@v2
|
||||
# id: cache-icu
|
||||
# with:
|
||||
# # The same SDL revision will produce the same libraries
|
||||
# key: ${{steps.icu-rev.outputs.ICU_REV}}
|
||||
# path: |
|
||||
# build-android/project/jni/iconv/include
|
||||
# build-android/project/jni/iconv/lib
|
||||
# build-android/project/jni/icuuc/include
|
||||
# build-android/project/jni/icuuc/lib
|
||||
#
|
||||
# - name: Touch cached Boost timestamps
|
||||
# if: steps.cache-boost.outputs.cache-hit == 'true' || steps.cache-icu.outputs.cache-hit == 'true'
|
||||
# working-directory: build-android
|
||||
# run: touch project/jni/boost/lib/*/* || true
|
||||
#
|
||||
# - name: Touch cached ICU timestamps
|
||||
# if: steps.cache-boost.outputs.cache-hit == 'true' || steps.cache-icu.outputs.cache-hit == 'true'
|
||||
# working-directory: build-android
|
||||
# run: touch project/jni/iconv/lib/*/* project/jni/icuuc/lib/*/* || true
|
||||
|
||||
- name: Patch Java files and build Boost, ICU, and OpenSSL
|
||||
run: |
|
||||
export PATH=$ANDROID_NDK_LATEST_HOME:$PATH
|
||||
./changeAppSettings.sh
|
||||
|
||||
- name: Set up Gradle and Android SDK licenses
|
||||
working-directory: project
|
||||
run: |
|
||||
for Y in `seq 20`; do echo y; done | sudo $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses
|
||||
./gradlew assembleRelease || true
|
||||
for Y in `seq 20`; do echo y; done | sudo $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses --sdk_root=`pwd`
|
||||
mkdir -p $HOME/.android
|
||||
keytool -genkey -v -keystore $HOME/.android/debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "CN=Debug, OU=Debug, O=Debug, L=Debug, ST=Debug, C=Debug"
|
||||
echo "sdk.dir=$ANDROID_SDK_ROOT" > local.properties
|
||||
echo "proguard.config=proguard.cfg;proguard-local.cfg" >> local.properties
|
||||
|
||||
- name: Hyper turbo build script GOOOOOOOOOOOO
|
||||
run: |
|
||||
export PATH=$ANDROID_NDK_LATEST_HOME:$ANDROID_SDK_ROOT/build-tools/31.0.0:$PATH
|
||||
./build.sh
|
||||
|
||||
- name: App signing keys
|
||||
run: |
|
||||
echo "$ANDROID_KEYSTORE_B64" | base64 -d > keystore.jks || true
|
||||
echo "$ANDROID_UPLOAD_KEYSTORE_B64" | base64 -d > upload_keystore.jks || true
|
||||
find keystore.jks -empty -delete || true
|
||||
find upload_keystore.jks -empty -delete || true
|
||||
env:
|
||||
ANDROID_KEYSTORE_B64: "${{secrets.ANDROID_KEYSTORE_B64}}"
|
||||
ANDROID_UPLOAD_KEYSTORE_B64: "${{secrets.ANDROID_UPLOAD_KEYSTORE_B64}}"
|
||||
|
||||
- name: Package
|
||||
run: |
|
||||
export PATH=$ANDROID_NDK_LATEST_HOME:$ANDROID_SDK_ROOT/build-tools/31.0.0:$PATH
|
||||
if [ -e keystore.jks ]; then
|
||||
export ANDROID_KEYSTORE_FILE=`pwd`/keystore.jks
|
||||
fi
|
||||
if [ -e upload_keystore.jks ]; then
|
||||
export ANDROID_UPLOAD_KEYSTORE_FILE=`pwd`/upload_keystore.jks
|
||||
fi
|
||||
mkdir -p upload/
|
||||
./sign.sh
|
||||
mv *.apk upload/
|
||||
./signBundle.sh
|
||||
mv *.aab upload/
|
||||
env:
|
||||
ANDROID_KEYSTORE_PASS: "${{secrets.ANDROID_KEYSTORE_PASS}}"
|
||||
ANDROID_KEYSTORE_ALIAS: "${{secrets.ANDROID_KEYSTORE_ALIAS}}"
|
||||
ANDROID_UPLOAD_KEYSTORE_PASS: "${{secrets.ANDROID_UPLOAD_KEYSTORE_PASS}}"
|
||||
ANDROID_UPLOAD_KEYSTORE_ALIAS: "${{secrets.ANDROID_UPLOAD_KEYSTORE_ALIAS}}"
|
||||
|
||||
# Github actions is dumb and won't let you download single files from artifacts, so break up the artifacts instead
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{env.APP_NAME}}
|
||||
path: upload
|
||||
if-no-files-found: error
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -23,4 +23,3 @@
|
||||
/project/app/build.gradle
|
||||
/project/app/.gradle
|
||||
/project/app/build
|
||||
/project/assetpack/build
|
||||
|
||||
95
.gitmodules
vendored
95
.gitmodules
vendored
@@ -1,3 +1,38 @@
|
||||
[submodule "project/jni/application/NewRAW"]
|
||||
path = project/jni/application/NewRAW
|
||||
url = https://github.com/usineur/android-newraw.git
|
||||
[submodule "project/jni/boost/src"]
|
||||
path = project/jni/boost/src
|
||||
url = https://github.com/moritz-wundke/Boost-for-Android.git
|
||||
branch = master
|
||||
update = merge
|
||||
[submodule "project/jni/application/commandergenius/commandergenius"]
|
||||
path = project/jni/application/commandergenius/commandergenius
|
||||
url = https://github.com/gerstrong/Commander-Genius.git
|
||||
[submodule "project/jni/application/openarena/engine"]
|
||||
path = project/jni/application/openarena/engine
|
||||
url = https://github.com/pelya/openarena-engine.git
|
||||
[submodule "project/jni/application/openarena/vm"]
|
||||
path = project/jni/application/openarena/vm
|
||||
url = https://github.com/pelya/openarena-vm
|
||||
[submodule "project/jni/application/teeworlds/src"]
|
||||
path = project/jni/application/teeworlds/src
|
||||
url = https://github.com/pelya/teeworlds.git
|
||||
[submodule "project/jni/application/xserver/xserver"]
|
||||
path = project/jni/application/xserver/xserver
|
||||
url = https://github.com/pelya/xserver.git
|
||||
branch = xsdl-1.20
|
||||
update = merge
|
||||
[submodule "android-shmem"]
|
||||
path = project/jni/shmem
|
||||
url = https://github.com/pelya/android-shmem.git
|
||||
branch = master
|
||||
update = merge
|
||||
[submodule "project/jni/application/hid-pc-keyboard/src"]
|
||||
path = project/jni/application/hid-pc-keyboard/src
|
||||
url = https://github.com/pelya/android-keyboard-gadget.git
|
||||
branch = master
|
||||
update = merge
|
||||
[submodule "project/jni/iconv/src"]
|
||||
path = project/jni/iconv/src
|
||||
url = https://github.com/pelya/libiconv-libicu-android.git
|
||||
@@ -5,21 +40,47 @@
|
||||
update = merge
|
||||
[submodule "project/jni/application/openttd/src"]
|
||||
path = project/jni/application/openttd/src
|
||||
url = https://github.com/n-ice-community/openttd-android.git
|
||||
branch = 12
|
||||
[submodule "project/jni/sdl2"]
|
||||
path = project/jni/sdl2
|
||||
url = https://github.com/libsdl-org/SDL.git
|
||||
branch = main
|
||||
[submodule "project/jni/sdl2_image"]
|
||||
path = project/jni/sdl2_image
|
||||
url = https://github.com/libsdl-org/SDL_image
|
||||
branch = main
|
||||
[submodule "project/jni/sdl2_ttf"]
|
||||
path = project/jni/sdl2_ttf
|
||||
url = https://github.com/libsdl-org/SDL_ttf.git
|
||||
branch = main
|
||||
[submodule "project/jni/sdl2_mixer"]
|
||||
path = project/jni/sdl2_mixer
|
||||
url = https://github.com/libsdl-org/SDL_mixer.git
|
||||
url = https://github.com/pelya/openttd-android.git
|
||||
branch = 1.10
|
||||
[submodule "project/jni/application/uae4all2"]
|
||||
path = project/jni/application/uae4all2
|
||||
url = https://github.com/lubomyr/uae4all2.git
|
||||
[submodule "project/jni/application/basiliskii/basiliskii"]
|
||||
path = project/jni/application/basiliskii/basiliskii
|
||||
url = https://github.com/pelya/BasiliskII-android.git
|
||||
[submodule "project/jni/vncserver/src"]
|
||||
path = project/jni/vncserver/src
|
||||
url = https://github.com/LibVNC/libvncserver.git
|
||||
[submodule "project/jni/application/vice/vice"]
|
||||
path = project/jni/application/vice/vice
|
||||
url = https://github.com/lubomyr/vice-2.4.git
|
||||
[submodule "project/jni/application/xserver/pulseaudio"]
|
||||
path = project/jni/application/xserver/pulseaudio
|
||||
url = https://github.com/pelya/pulseaudio-android.git
|
||||
branch = master
|
||||
[submodule "project/jni/application/supertux/supertux"]
|
||||
path = project/jni/application/supertux/supertux
|
||||
url = https://github.com/pelya/supertux.git
|
||||
[submodule "project/jni/application/fheroes2/fheroes2"]
|
||||
path = project/jni/application/fheroes2/fheroes2
|
||||
url = https://github.com/gerstrong/fheroes2plus.git
|
||||
[submodule "project/jni/application/ninslash/src"]
|
||||
path = project/jni/application/ninslash/src
|
||||
url = https://github.com/pelya/Ninslash.git
|
||||
branch = master
|
||||
update = merge
|
||||
[submodule "project/jni/application/openttd-jgrpp/src"]
|
||||
path = project/jni/application/openttd-jgrpp/src
|
||||
url = https://github.com/pelya/OpenTTD-JGR-patchpack.git
|
||||
branch = android-desktop
|
||||
[submodule "project/jni/application/liero/src"]
|
||||
path = project/jni/application/liero/src
|
||||
url = https://github.com/pelya/liero-android.git
|
||||
[submodule "project/jni/application/openlierox/src"]
|
||||
path = project/jni/application/openlierox/src
|
||||
url = https://github.com/albertz/openlierox.git
|
||||
branch = half-assed-android-port
|
||||
[submodule "project/jni/application/xserver-debian/debian-image"]
|
||||
path = project/jni/application/xserver-debian/debian-image
|
||||
url = https://github.com/pelya/debian-noroot
|
||||
branch = master
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
project/app/build/outputs/apk/release/app-release.apk
|
||||
266
build.sh
266
build.sh
@@ -1,45 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/bin/sh
|
||||
#set -eu # Bashism, does not work with default shell on Ubuntu 12.04
|
||||
|
||||
# Handle any error or die
|
||||
set -e
|
||||
|
||||
THIS_BUILD_DIR=$(dirname "$0")
|
||||
install_apk=false
|
||||
run_apk=false
|
||||
sign_apk=false
|
||||
sign_bundle=false
|
||||
build_release=true
|
||||
do_zipalign=true
|
||||
quick_rebuild=false
|
||||
QUICK_REBUILD_ARGS=
|
||||
|
||||
# Fix Gradle compilation error
|
||||
if [ -z "$ANDROID_NDK_HOME" ]; then
|
||||
export ANDROID_NDK_HOME="$(which ndk-build | sed 's@/ndk-build@@')"
|
||||
if [ "$#" -gt 0 -a "$1" = "-s" ]; then
|
||||
shift
|
||||
sign_apk=true
|
||||
fi
|
||||
|
||||
while getopts "sirqbhz" OPT
|
||||
do
|
||||
case $OPT in
|
||||
s) sign_apk=true;;
|
||||
i) install_apk=true;;
|
||||
r) install_apk=true ; run_apk=true;;
|
||||
q) echo "Quick rebuild does not work anymore with Gradle!";;
|
||||
b) sign_bundle=true;;
|
||||
z) do_zipalign=false;;
|
||||
h)
|
||||
echo "Usage: $0 [-s] [-i] [-r] [-q] [debug|release] [app-name]"
|
||||
echo " -s: sign .apk file after building"
|
||||
echo " -b: sign .aab app bundle file after building"
|
||||
echo " -i: install APK file to device after building"
|
||||
echo " -r: run APK file on device after building"
|
||||
echo " -z: skip zipalign and apksigner"
|
||||
echo " debug: build debug package"
|
||||
echo " release: build release package (default)"
|
||||
echo " app-name: directory under project/jni/application to be compiled"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(expr $OPTIND - 1)
|
||||
if [ "$#" -gt 0 -a "$1" = "-i" ]; then
|
||||
shift
|
||||
install_apk=true
|
||||
fi
|
||||
|
||||
if [ "$#" -gt 0 -a "$1" = "-r" ]; then
|
||||
shift
|
||||
install_apk=true
|
||||
run_apk=true
|
||||
fi
|
||||
|
||||
if [ "$#" -gt 0 -a "$1" = "-q" ]; then
|
||||
shift
|
||||
quick_rebuild=true
|
||||
QUICK_REBUILD_ARGS=APP_ABI=armeabi-v7a
|
||||
fi
|
||||
|
||||
if [ "$#" -gt 0 -a "$1" = "release" ]; then
|
||||
shift
|
||||
@@ -52,7 +41,7 @@ if [ "$#" -gt 0 -a "$1" = "debug" ]; then
|
||||
export NDK_DEBUG=1
|
||||
fi
|
||||
|
||||
if [ "$#" -gt 0 ]; then
|
||||
if [ "$#" -gt 0 -a "$1" '!=' "-h" ]; then
|
||||
echo "Switching build target to $1"
|
||||
if [ -e project/jni/application/$1 ]; then
|
||||
rm -f project/jni/application/src
|
||||
@@ -60,41 +49,51 @@ if [ "$#" -gt 0 ]; then
|
||||
else
|
||||
echo "Error: no app $1 under project/jni/application"
|
||||
echo "Available applications:"
|
||||
pushd project/jni/application
|
||||
cd project/jni/application
|
||||
for f in *; do
|
||||
if [ -e "$f/AndroidAppSettings.cfg" ]; then
|
||||
echo "$f"
|
||||
fi
|
||||
done
|
||||
popd
|
||||
exit 1
|
||||
fi
|
||||
shift
|
||||
fi
|
||||
|
||||
if [ ! -e project/local.properties ] || \
|
||||
! grep -q "package $(grep -Po 'AppFullName\=\K[.[:alnum:]]+' AndroidAppSettings.cfg);" project/src/Globals.java || \
|
||||
[ "$(readlink AndroidAppSettings.cfg)" -nt "project/src/Globals.java" ] || \
|
||||
[ -n "$(find project/java/* \
|
||||
project/javaSDL2/* \
|
||||
project/jni/sdl2/android-project/app/src/main/java/org/libsdl/app/* \
|
||||
project/AndroidManifestTemplate.xml \
|
||||
-cnewer \
|
||||
project/src/Globals.java \
|
||||
)" \
|
||||
];
|
||||
then
|
||||
./changeAppSettings.sh -a
|
||||
if [ "$#" -gt 0 -a "$1" = "-h" ]; then
|
||||
echo "Usage: $0 [-s] [-i] [-r] [-q] [debug|release] [app-name]"
|
||||
echo " -s: sign APK file after building"
|
||||
echo " -i: install APK file to device after building"
|
||||
echo " -r: run APK file on device after building"
|
||||
echo " -q: quick-rebuild C code, without rebuilding Java files"
|
||||
echo " debug: build debug package"
|
||||
echo " release: build release package (default)"
|
||||
echo " app-name: directory under project/jni/application to be compiled"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
NDK_TOOLCHAIN_VERSION=$GCCVER
|
||||
[ -z "$NDK_TOOLCHAIN_VERSION" ] && NDK_TOOLCHAIN_VERSION=4.9
|
||||
|
||||
# Set here your own NDK path if needed
|
||||
# export PATH=$PATH:~/src/endless_space/android-ndk-r7
|
||||
NDKBUILDPATH=$PATH
|
||||
export `grep "AppFullName=" AndroidAppSettings.cfg`
|
||||
if [ -e project/local.properties ] && \
|
||||
( grep "package $AppFullName;" project/src/Globals.java > /dev/null 2>&1 && \
|
||||
[ "`readlink AndroidAppSettings.cfg`" -ot "project/src/Globals.java" ] && \
|
||||
[ -z "`find project/java/* project/AndroidManifestTemplate.xml -cnewer project/src/Globals.java`" ] ) ; then true ; else
|
||||
./changeAppSettings.sh -a || exit 1
|
||||
sleep 1
|
||||
touch project/src/Globals.java
|
||||
fi
|
||||
|
||||
MYARCH=linux-x86_64
|
||||
if [ -z "$NCPU" ]; then
|
||||
NCPU=8
|
||||
NCPU=4
|
||||
if uname -s | grep -i "linux" > /dev/null ; then
|
||||
MYARCH=linux-x86_64
|
||||
NCPU=$(cat /proc/cpuinfo | grep -c -i processor)
|
||||
NCPU=`cat /proc/cpuinfo | grep -c -i processor`
|
||||
fi
|
||||
if uname -s | grep -i "darwin" > /dev/null ; then
|
||||
MYARCH=darwin-x86_64
|
||||
@@ -103,85 +102,92 @@ if [ -z "$NCPU" ]; then
|
||||
MYARCH=windows-x86_64
|
||||
fi
|
||||
fi
|
||||
export BUILD_NUM_CPUS=$NCPU
|
||||
|
||||
$quick_rebuild || rm -r -f project/bin/* # New Android SDK introduced some lame-ass optimizations to the build system which we should take care about
|
||||
[ -x project/jni/application/src/AndroidPreBuild.sh ] && {
|
||||
cd project/jni/application/src
|
||||
./AndroidPreBuild.sh || { echo "AndroidPreBuild.sh returned with error" ; exit 1 ; }
|
||||
cd ../../../..
|
||||
}
|
||||
|
||||
if [ -x project/jni/application/src/AndroidPreBuild.sh ]; then
|
||||
pushd project/jni/application/src
|
||||
./AndroidPreBuild.sh
|
||||
popd
|
||||
fi
|
||||
strip_libs() {
|
||||
grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \
|
||||
grep "MultiABI=" ../AndroidAppSettings.cfg | grep "y\\|all\\|armeabi-v7a" > /dev/null && \
|
||||
echo Stripping libapplication-armeabi-v7a.so by hand && \
|
||||
rm obj/local/armeabi-v7a/libapplication.so && \
|
||||
cp jni/application/src/libapplication-armeabi-v7a.so obj/local/armeabi-v7a/libapplication.so && \
|
||||
cp jni/application/src/libapplication-armeabi-v7a.so libs/armeabi-v7a/libapplication.so && \
|
||||
`which ndk-build | sed 's@/ndk-build@@'`/toolchains/arm-linux-androideabi-${NDK_TOOLCHAIN_VERSION}/prebuilt/$MYARCH/bin/arm-linux-androideabi-strip --strip-unneeded libs/armeabi-v7a/libapplication.so
|
||||
grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \
|
||||
grep "MultiABI=" ../AndroidAppSettings.cfg | grep "all\\|x86" > /dev/null && \
|
||||
echo Stripping libapplication-x86.so by hand && \
|
||||
rm obj/local/x86/libapplication.so && \
|
||||
cp jni/application/src/libapplication-x86.so obj/local/x86/libapplication.so && \
|
||||
cp jni/application/src/libapplication-x86.so libs/x86/libapplication.so && \
|
||||
`which ndk-build | sed 's@/ndk-build@@'`/toolchains/x86-${NDK_TOOLCHAIN_VERSION}/prebuilt/$MYARCH/bin/i686-linux-android-strip --strip-unneeded libs/x86/libapplication.so
|
||||
grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \
|
||||
grep "MultiABI=" ../AndroidAppSettings.cfg | grep "all\\|x86_64" > /dev/null && \
|
||||
echo Stripping libapplication-x86_64.so by hand && \
|
||||
rm obj/local/x86_64/libapplication.so && \
|
||||
cp jni/application/src/libapplication-x86_64.so obj/local/x86_64/libapplication.so && \
|
||||
cp jni/application/src/libapplication-x86_64.so libs/x86_64/libapplication.so && \
|
||||
`which ndk-build | sed 's@/ndk-build@@'`/toolchains/x86_64-${NDK_TOOLCHAIN_VERSION}/prebuilt/$MYARCH/bin/x86_64-linux-android-strip --strip-unneeded libs/x86_64/libapplication.so
|
||||
grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \
|
||||
grep "MultiABI=" ../AndroidAppSettings.cfg | grep "all\\|arm64-v8a" > /dev/null && \
|
||||
echo Stripping libapplication-arm64-v8a.so by hand && \
|
||||
rm obj/local/arm64-v8a/libapplication.so && \
|
||||
cp jni/application/src/libapplication-arm64-v8a.so obj/local/arm64-v8a/libapplication.so && \
|
||||
cp jni/application/src/libapplication-arm64-v8a.so libs/arm64-v8a/libapplication.so && \
|
||||
`which ndk-build | sed 's@/ndk-build@@'`/toolchains/aarch64-linux-android-${NDK_TOOLCHAIN_VERSION}/prebuilt/$MYARCH/bin/aarch64-linux-android-strip --strip-unneeded libs/arm64-v8a/libapplication.so
|
||||
return 0
|
||||
}
|
||||
|
||||
if grep -q 'CustomBuildScript=y' ./AndroidAppSettings.cfg; then
|
||||
${ANDROID_NDK_HOME}/ndk-build -C project -j$NCPU V=1 CUSTOM_BUILD_SCRIPT_FIRST_PASS=1 NDK_APP_STRIP_MODE=none
|
||||
make -C project/jni/application -f CustomBuildScript.mk
|
||||
fi
|
||||
# Fix Gradle compilation error
|
||||
[ -z "$ANDROID_NDK_HOME" ] && export ANDROID_NDK_HOME="`which ndk-build | sed 's@/ndk-build@@'`"
|
||||
|
||||
${ANDROID_NDK_HOME}/ndk-build -C project -j$NCPU V=1 NDK_APP_STRIP_MODE=none
|
||||
./copyAssets.sh
|
||||
pushd project
|
||||
if $build_release ; then
|
||||
if [ -x ./gradlew ]; then
|
||||
./gradlew assembleRelease
|
||||
else
|
||||
gradle assembleRelease
|
||||
fi
|
||||
if [ -x jni/application/src/AndroidPostBuild.sh ]; then
|
||||
pushd jni/application/src
|
||||
./AndroidPostBuild.sh ${THIS_BUILD_DIR}/project/app/build/outputs/apk/release/app-release-unsigned.apk
|
||||
popd
|
||||
fi
|
||||
../copyAssets.sh pack-binaries app/build/outputs/apk/release/app-release-unsigned.apk
|
||||
rm -f app/build/outputs/apk/release/app-release.apk
|
||||
if $do_zipalign; then
|
||||
zipalign -p 4 app/build/outputs/apk/release/app-release-unsigned.apk app/build/outputs/apk/release/app-release.apk
|
||||
apksigner sign --ks ~/.android/debug.keystore --ks-key-alias androiddebugkey --ks-pass pass:android app/build/outputs/apk/release/app-release.apk
|
||||
fi
|
||||
else
|
||||
if [ -x ./gradlew ]; then
|
||||
./gradlew assembleDebug
|
||||
else
|
||||
gradle assembleDebug
|
||||
fi
|
||||
if [ -x jni/application/src/AndroidPostBuild.sh ]; then
|
||||
pushd jni/application/src
|
||||
./AndroidPostBuild.sh ${THIS_BUILD_DIR}/project/app/build/outputs/apk/debug/app-debug.apk
|
||||
popd
|
||||
fi
|
||||
mkdir -p app/build/outputs/apk/release
|
||||
../copyAssets.sh pack-binaries app/build/outputs/apk/debug/app-debug.apk
|
||||
rm -f app/build/outputs/apk/release/app-release.apk
|
||||
if $do_zipalign; then
|
||||
zipalign -p 4 app/build/outputs/apk/debug/app-debug.apk app/build/outputs/apk/release/app-release.apk
|
||||
apksigner sign --ks ~/.android/debug.keystore --ks-key-alias androiddebugkey --ks-pass pass:android app/build/outputs/apk/release/app-release.apk
|
||||
fi
|
||||
fi
|
||||
|
||||
if $sign_apk; then
|
||||
pushd ..
|
||||
./sign.sh
|
||||
popd
|
||||
fi
|
||||
|
||||
if $sign_bundle; then
|
||||
pushd ..
|
||||
./signBundle.sh
|
||||
popd
|
||||
fi
|
||||
if $install_apk && [ -n "$(adb devices | tail -n +2)" ]; then
|
||||
if $sign_apk; then
|
||||
APPNAME=$(grep AppName ../AndroidAppSettings.cfg | sed 's/.*=//' | tr -d '"' | tr " '/" '---')
|
||||
APPVER=$(grep AppVersionName ../AndroidAppSettings.cfg | sed 's/.*=//' | tr -d '"' | tr " '/" '---')
|
||||
adb install -r ../$APPNAME-$APPVER.apk ;
|
||||
else
|
||||
adb install -r app/build/outputs/apk/release/app-release.apk
|
||||
fi
|
||||
fi
|
||||
|
||||
if $run_apk; then
|
||||
ActivityName="$(grep AppFullName ../AndroidAppSettings.cfg | sed 's/.*=//')/.MainActivity"
|
||||
RUN_APK="adb shell am start -n $ActivityName"
|
||||
echo "Running $ActivityName on the USB-connected device:"
|
||||
echo "$RUN_APK"
|
||||
eval $RUN_APK
|
||||
fi
|
||||
cd project && env PATH=$NDKBUILDPATH BUILD_NUM_CPUS=$NCPU ndk-build -j$NCPU V=1 $QUICK_REBUILD_ARGS && \
|
||||
strip_libs && \
|
||||
cd .. && ./copyAssets.sh && cd project && \
|
||||
{ if $build_release ; then \
|
||||
$quick_rebuild && { \
|
||||
zip -u -r app/build/outputs/apk/release/app-release-unsigned.apk lib assets || exit 1 ; \
|
||||
} || ./gradlew assembleRelease || exit 1 ; \
|
||||
[ '!' -x jni/application/src/AndroidPostBuild.sh ] || {
|
||||
cd jni/application/src ; \
|
||||
./AndroidPostBuild.sh `pwd`/../../../app/build/outputs/apk/release/app-release-unsigned.apk || exit 1 ; \
|
||||
cd ../../.. ; \
|
||||
} || exit 1 ; \
|
||||
../copyAssets.sh pack-binaries app/build/outputs/apk/release/app-release-unsigned.apk ; \
|
||||
rm -f app/build/outputs/apk/release/app-release.apk ; \
|
||||
zipalign 4 app/build/outputs/apk/release/app-release-unsigned.apk app/build/outputs/apk/release/app-release.apk || exit 1 ; \
|
||||
apksigner sign --ks ~/.android/debug.keystore --ks-key-alias androiddebugkey --ks-pass pass:android app/build/outputs/apk/release/app-release.apk || exit 1 ; \
|
||||
else \
|
||||
./gradlew assembleDebug || exit 1 ; \
|
||||
[ '!' -x jni/application/src/AndroidPostBuild.sh ] || {
|
||||
cd jni/application/src ; \
|
||||
./AndroidPostBuild.sh `pwd`/../../../app/build/outputs/apk/debug/app-debug.apk || exit 1 ; \
|
||||
cd ../../.. ; \
|
||||
} || exit 1 ; \
|
||||
mkdir -p app/build/outputs/apk/release ; \
|
||||
../copyAssets.sh pack-binaries app/build/outputs/apk/debug/app-debug.apk && \
|
||||
rm -f app/build/outputs/apk/release/app-release.apk && \
|
||||
zipalign 4 app/build/outputs/apk/debug/app-debug.apk app/build/outputs/apk/release/app-release.apk &&
|
||||
apksigner sign --ks ~/.android/debug.keystore --ks-key-alias androiddebugkey --ks-pass pass:android app/build/outputs/apk/release/app-release.apk || exit 1 ; \
|
||||
fi ; } && \
|
||||
{ if $sign_apk; then cd .. && ./sign.sh && cd project ; else true ; fi ; } && \
|
||||
{ $install_apk && [ -n "`adb devices | tail -n +2`" ] && \
|
||||
{ if $sign_apk; then \
|
||||
APPNAME=`grep AppName ../AndroidAppSettings.cfg | sed 's/.*=//' | tr -d '"' | tr " '/" '---'` ; \
|
||||
APPVER=`grep AppVersionName ../AndroidAppSettings.cfg | sed 's/.*=//' | tr -d '"' | tr " '/" '---'` ; \
|
||||
adb install -r ../$APPNAME-$APPVER.apk ; \
|
||||
else \
|
||||
adb install -r app/build/outputs/apk/release/app-release.apk ; \
|
||||
fi ; } ; \
|
||||
true ; } && \
|
||||
{ $run_apk && { \
|
||||
ActivityName="`grep AppFullName ../AndroidAppSettings.cfg | sed 's/.*=//'`/.MainActivity" ; \
|
||||
RUN_APK="adb shell am start -n $ActivityName" ; \
|
||||
echo "Running $ActivityName on the USB-connected device:" ; \
|
||||
echo "$RUN_APK" ; \
|
||||
eval $RUN_APK ; } ; \
|
||||
true ; } || exit 1
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
AUTO=a
|
||||
CHANGED=
|
||||
JAVA_SRC_PATH=project/java
|
||||
@@ -45,10 +44,14 @@ if [ "$#" -gt 0 ]; then
|
||||
shift
|
||||
fi
|
||||
|
||||
source ./AndroidAppSettings.cfg
|
||||
. ./AndroidAppSettings.cfg
|
||||
|
||||
var=""
|
||||
|
||||
if [ "$LibSdlVersion" = "2.0" ]; then
|
||||
JAVA_SRC_PATH=project/javaSDL2
|
||||
fi
|
||||
|
||||
if [ "$CompatibilityHacks" = y ]; then
|
||||
SwVideoMode=y
|
||||
fi
|
||||
@@ -87,406 +90,368 @@ fi
|
||||
|
||||
|
||||
if [ -z "$AppVersionCode" -o "-$AUTO" != "-a" ]; then
|
||||
echo
|
||||
echo -n "Application version code (integer) ($AppVersionCode): "
|
||||
read var
|
||||
if [ -n "$var" ] ; then
|
||||
AppVersionCode="$var"
|
||||
CHANGED=1
|
||||
fi
|
||||
echo
|
||||
echo -n "Application version code (integer) ($AppVersionCode): "
|
||||
read var
|
||||
if [ -n "$var" ] ; then
|
||||
AppVersionCode="$var"
|
||||
CHANGED=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$AppVersionName" -o "-$AUTO" != "-a" ]; then
|
||||
echo
|
||||
echo -n "Application user-visible version name (string) ($AppVersionName): "
|
||||
read var
|
||||
if [ -n "$var" ] ; then
|
||||
AppVersionName="$var"
|
||||
CHANGED=1
|
||||
fi
|
||||
echo
|
||||
echo -n "Application user-visible version name (string) ($AppVersionName): "
|
||||
read var
|
||||
if [ -n "$var" ] ; then
|
||||
AppVersionName="$var"
|
||||
CHANGED=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$ResetSdlConfigForThisVersion" -o "-$AUTO" != "-a" ]; then
|
||||
echo
|
||||
echo -n "Reset SDL config when updating application to the new version (y) / (n) ($ResetSdlConfigForThisVersion): "
|
||||
read var
|
||||
if [ -n "$var" ] ; then
|
||||
ResetSdlConfigForThisVersion="$var"
|
||||
CHANGED=1
|
||||
fi
|
||||
echo
|
||||
echo -n "Reset SDL config when updating application to the new version (y) / (n) ($ResetSdlConfigForThisVersion): "
|
||||
read var
|
||||
if [ -n "$var" ] ; then
|
||||
ResetSdlConfigForThisVersion="$var"
|
||||
CHANGED=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "-$AUTO" != "-a" ]; then
|
||||
echo
|
||||
echo -n "Delete application data files when upgrading (specify file/dir paths separated by spaces): ($DeleteFilesOnUpgrade): "
|
||||
read var
|
||||
if [ -n "$var" ] ; then
|
||||
DeleteFilesOnUpgrade="$var"
|
||||
CHANGED=1
|
||||
fi
|
||||
echo
|
||||
echo -n "Delete application data files when upgrading (specify file/dir paths separated by spaces): ($DeleteFilesOnUpgrade): "
|
||||
read var
|
||||
if [ -n "$var" ] ; then
|
||||
DeleteFilesOnUpgrade="$var"
|
||||
CHANGED=1
|
||||
fi
|
||||
|
||||
# Compatibility - if RedefinedKeysScreenGestures is empty, copy keycodes from RedefinedKeysScreenKb
|
||||
KEY2=0
|
||||
if [ -z "$RedefinedKeysScreenGestures" ] ; then
|
||||
RedefinedKeysScreenGestures="$(
|
||||
for KEY in $RedefinedKeysScreenKb; do
|
||||
if [ $KEY2 -ge 6 ] && [ $KEY2 -le 9 ]; then
|
||||
echo -n $KEY ' '
|
||||
fi
|
||||
KEY2=$(expr $KEY2 '+' 1)
|
||||
done
|
||||
)"
|
||||
RedefinedKeysScreenKb="$(
|
||||
for KEY in $RedefinedKeysScreenKb; do
|
||||
if [ $KEY2 -lt 6 ] || [ $KEY2 -gt 9 ]; then
|
||||
echo -n $KEY ' '
|
||||
fi
|
||||
KEY2=$(expr $KEY2 '+' 1)
|
||||
done
|
||||
)"
|
||||
fi
|
||||
|
||||
if [ -n "$CHANGED" ]; then
|
||||
cat /dev/null > AndroidAppSettings.cfg
|
||||
cat <<EOF >./AndroidAppSettings.cfg
|
||||
# The application settings for Android libSDL port
|
||||
|
||||
# Specify application name (e.x. My Application)
|
||||
AppName="$AppName"
|
||||
|
||||
# Specify reversed site name of application (e.x. com.mysite.myapp)
|
||||
AppFullName=$AppFullName
|
||||
|
||||
# Application version code (integer)
|
||||
AppVersionCode=$AppVersionCode
|
||||
|
||||
# Application user-visible version name (string)
|
||||
AppVersionName="$AppVersionName"
|
||||
|
||||
# Specify path to download application data in zip archive in the form "Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...
|
||||
# If you'll start Description with '!' symbol it will be enabled by default, '!!' will also hide the entry from the menu, so it cannot be disabled
|
||||
# If the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as binary BLOB to the application dir and not unzipped
|
||||
# If the URL does not contain 'http://' or 'https://', it is treated as file from 'project/jni/application/src/AndroidData' dir -
|
||||
# these files are put inside .apk package by the build system
|
||||
# You can specify Google Play expansion files in the form 'obb:main.12345' or 'obb:patch.12345' where 12345 is the app version for the obb file
|
||||
# You can mount expansion files created with jobb tool if you put 'mnt:main.12345' or 'mnt:patch.12345'
|
||||
# The mount directory will be returned by calling getenv("ANDROID_OBB_MOUNT_DIR")
|
||||
# Android app bundles do not support .obb files, they use asset packs instead.
|
||||
# This app project includes one pre-configured install-time asset pack.
|
||||
# To put your data into asset pack, copy it to the directory AndroidData/assetpack
|
||||
# and run changeAppSettings.sh. The asset pack zip archive will be returned by
|
||||
# getenv("ANDROID_ASSET_PACK_PATH"), this call will return NULL if the asset pack is not installed.
|
||||
# You can put "assetpack" keyword to AppDataDownloadUrl, the code will check
|
||||
# if the asset pack is installed and will not download the data from other URLs.
|
||||
# You can extract files from the asset pack the same way you extract files from the app assets.
|
||||
# You can use .zip.xz archives for better compression, but you need to add 'lzma' to CompiledLibraries
|
||||
# Generate .zip.xz files like this: zip -0 -r data.zip your-data/* ; xz -8 data.zip
|
||||
AppDataDownloadUrl="$AppDataDownloadUrl"
|
||||
|
||||
# Reset SDL config when updating application to the new version (y) / (n)
|
||||
ResetSdlConfigForThisVersion=$ResetSdlConfigForThisVersion
|
||||
|
||||
# Delete application data files when upgrading (specify file/dir paths separated by spaces)
|
||||
DeleteFilesOnUpgrade="$DeleteFilesOnUpgrade"
|
||||
|
||||
# Here you may type readme text, which will be shown during startup. Format is:
|
||||
# Text in English, use \\\\n to separate lines (that's four backslashes)^de:Text in Deutsch^ru:Text in Russian^button:Button that will open some URL:http://url-to-open/
|
||||
ReadmeText='$ReadmeText' | sed 's/\\\\n/\\\\\\\\n/g'
|
||||
|
||||
# libSDL version to use (1.2/2)
|
||||
LibSdlVersion=$LibSdlVersion
|
||||
|
||||
# Specify screen orientation: (v)ertical/(p)ortrait or (h)orizontal/(l)andscape
|
||||
ScreenOrientation=$ScreenOrientation
|
||||
|
||||
# Video color depth - 16 BPP is the fastest and supported for all modes, 24 bpp is supported only
|
||||
# with SwVideoMode=y, SDL_OPENGL mode supports everything. (16)/(24)/(32)
|
||||
VideoDepthBpp=$VideoDepthBpp
|
||||
|
||||
# Enable OpenGL depth buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
|
||||
NeedDepthBuffer=$NeedDepthBuffer
|
||||
|
||||
# Enable OpenGL stencil buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
|
||||
NeedStencilBuffer=$NeedStencilBuffer
|
||||
|
||||
# Use GLES 2.x context
|
||||
# you need this option only if you're developing 3-d app (y) or (n)
|
||||
NeedGles2=$NeedGles2
|
||||
|
||||
# Use GLES 3.x context
|
||||
# you need this option only if you're developing 3-d app (y) or (n)
|
||||
NeedGles3=$NeedGles3
|
||||
|
||||
# Use gl4es library for provide OpenGL 1.x functionality to OpenGL ES accelerated cards (y) or (n)
|
||||
UseGl4es=$UseGl4es
|
||||
|
||||
# Application uses software video buffer - you're calling SDL_SetVideoMode() without SDL_HWSURFACE and without SDL_OPENGL,
|
||||
# this will allow small speed optimization. Enable this even when you're using SDL_HWSURFACE. (y) or (n)
|
||||
SwVideoMode=$SwVideoMode
|
||||
|
||||
# Application video output will be resized to fit into native device screen (y)/(n)
|
||||
SdlVideoResize=$SdlVideoResize
|
||||
|
||||
# Application resizing will keep 4:3 aspect ratio, with black bars at sides (y)/(n)
|
||||
SdlVideoResizeKeepAspect=$SdlVideoResizeKeepAspect
|
||||
|
||||
Do not allow device to sleep when the application is in foreground, set this for video players or apps which use accelerometer
|
||||
InhibitSuspend=$InhibitSuspend
|
||||
|
||||
# Create Android service, so the app is less likely to be killed while in background
|
||||
CreateService=$CreateService
|
||||
|
||||
# Application does not call SDL_Flip() or SDL_UpdateRects() appropriately, or draws from non-main thread -
|
||||
# enabling the compatibility mode will force screen update every 100 milliseconds, which is laggy and inefficient (y) or (n)
|
||||
CompatibilityHacksForceScreenUpdate=$CompatibilityHacksForceScreenUpdate
|
||||
|
||||
# Application does not call SDL_Flip() or SDL_UpdateRects() after mouse click (ScummVM and all Amiga emulators do that) -
|
||||
# force screen update by moving mouse cursor a little after each click (y) or (n)
|
||||
CompatibilityHacksForceScreenUpdateMouseClick=$CompatibilityHacksForceScreenUpdateMouseClick
|
||||
|
||||
# Application initializes SDL audio/video inside static constructors (which is bad, you won't be able to run ndk-gdb) (y)/(n)
|
||||
CompatibilityHacksStaticInit=$CompatibilityHacksStaticInit
|
||||
|
||||
# On-screen Android soft text input emulates hardware keyboard, this will only work with Hackers Keyboard app (y)/(n)
|
||||
CompatibilityHacksTextInputEmulatesHwKeyboard=$CompatibilityHacksTextInputEmulatesHwKeyboard
|
||||
|
||||
# Built-in text input keyboards with custom layouts for emulators, requires CompatibilityHacksTextInputEmulatesHwKeyboard=y
|
||||
# 0 or empty - standard Android keyboard
|
||||
# 1 - Simple QWERTY keyboard, no function keys, no arrow keys
|
||||
# 2 - Commodore 64 keyboard
|
||||
# 3 - Amiga keyboard
|
||||
# 4 - Atari800 keyboard
|
||||
TextInputKeyboard=$TextInputKeyboard
|
||||
|
||||
# Hack for broken devices: prevent audio chopping, by sleeping a bit after pushing each audio chunk (y)/(n)
|
||||
CompatibilityHacksPreventAudioChopping=$CompatibilityHacksPreventAudioChopping
|
||||
|
||||
# Hack for broken apps: application ignores audio buffer size returned by SDL (y)/(n)
|
||||
CompatibilityHacksAppIgnoresAudioBufferSize=$CompatibilityHacksAppIgnoresAudioBufferSize
|
||||
|
||||
# Hack for VCMI: preload additional shared libraries before aplication start
|
||||
CompatibilityHacksAdditionalPreloadedSharedLibraries="$CompatibilityHacksAdditionalPreloadedSharedLibraries"
|
||||
|
||||
# Hack for Free Heroes 2, which redraws the screen inside SDL_PumpEvents(): slow and compatible SDL event queue -
|
||||
# do not use it with accelerometer/gyroscope, or your app may freeze at random (y)/(n)
|
||||
CompatibilityHacksSlowCompatibleEventQueue=$CompatibilityHacksSlowCompatibleEventQueue
|
||||
|
||||
# Save and restore OpenGL state when drawing on-screen keyboard for apps that use SDL_OPENGL
|
||||
CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=$CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState
|
||||
|
||||
# Application uses SDL_UpdateRects() properly, and does not draw in any region outside those rects.
|
||||
# This improves drawing speed, but I know only one application that does that, and it's written by me (y)/(n)
|
||||
CompatibilityHacksProperUsageOfSDL_UpdateRects=$CompatibilityHacksProperUsageOfSDL_UpdateRects
|
||||
|
||||
# Application uses mouse (y) or (n), this will show mouse emulation dialog to the user
|
||||
AppUsesMouse=$AppUsesMouse
|
||||
|
||||
# Application needs two-button mouse, will also enable advanced point-and-click features (y) or (n)
|
||||
AppNeedsTwoButtonMouse=$AppNeedsTwoButtonMouse
|
||||
|
||||
# Right mouse button can do long-press/drag&drop action, necessary for some games (y) or (n)
|
||||
# If you disable it, swiping with two fingers will send mouse wheel events
|
||||
RightMouseButtonLongPress=$RightMouseButtonLongPress
|
||||
|
||||
# Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n)
|
||||
ShowMouseCursor=$ShowMouseCursor
|
||||
|
||||
# Screen follows mouse cursor, when it's covered by soft keyboard, this works only in software video mode (y) or (n)
|
||||
ScreenFollowsMouse=$ScreenFollowsMouse
|
||||
|
||||
# Generate more touch events, by default SDL generates one event per one video frame, this is useful for drawing apps (y) or (n)
|
||||
GenerateSubframeTouchEvents=$GenerateSubframeTouchEvents
|
||||
|
||||
# Force relative (laptop) mouse movement mode, useful when both on-screen keyboard and mouse are needed (y) or (n)
|
||||
ForceRelativeMouseMode=$ForceRelativeMouseMode
|
||||
|
||||
# Show on-screen dpad/joystick, that will act as arrow keys (y) or (n)
|
||||
AppNeedsArrowKeys=$AppNeedsArrowKeys
|
||||
|
||||
# On-screen dpad/joystick will appear under finger when it touches the screen (y) or (n)
|
||||
# Joystick always follows finger, so moving mouse requires touching the screen with other finger
|
||||
FloatingScreenJoystick=$FloatingScreenJoystick
|
||||
|
||||
# Application needs text input (y) or (n), enables button for text input on screen
|
||||
AppNeedsTextInput=$AppNeedsTextInput
|
||||
|
||||
# Application uses joystick (y) or (n), the on-screen DPAD will be used as joystick 0 axes 0-1
|
||||
# This will disable AppNeedsArrowKeys option
|
||||
AppUsesJoystick=$AppUsesJoystick
|
||||
|
||||
# Application uses second on-screen joystick, as SDL joystick 0 axes 2-3 (y)/(n)
|
||||
AppUsesSecondJoystick=$AppUsesSecondJoystick
|
||||
|
||||
# Application uses third on-screen joystick, as SDL joystick 0 axes 20-21 (y)/(n)
|
||||
AppUsesThirdJoystick=$AppUsesThirdJoystick
|
||||
|
||||
# Application uses accelerometer (y) or (n), the accelerometer will be used as joystick 1 axes 0-1 and 5-7
|
||||
AppUsesAccelerometer=$AppUsesAccelerometer
|
||||
|
||||
# Application uses gyroscope (y) or (n), the gyroscope will be used as joystick 1 axes 2-4
|
||||
AppUsesGyroscope=$AppUsesGyroscope
|
||||
|
||||
# Application uses orientation sensor (y) or (n), reported as joystick 1 axes 8-10
|
||||
AppUsesOrientationSensor=$AppUsesOrientationSensor
|
||||
|
||||
# Use gyroscope to move mouse cursor (y) or (n), it eats battery, and can be disabled in settings, do not use with AppUsesGyroscope setting
|
||||
MoveMouseWithGyroscope=$MoveMouseWithGyroscope
|
||||
|
||||
# Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBALLMOTION events for the joystick 0
|
||||
AppUsesMultitouch=$AppUsesMultitouch
|
||||
|
||||
# Application records audio (it will use any available source, such a s microphone)
|
||||
# API is defined in file SDL_android.h: int SDL_ANDROID_OpenAudioRecording(SDL_AudioSpec *spec); void SDL_ANDROID_CloseAudioRecording(void);
|
||||
# This option will add additional permission to Android manifest (y)/(n)
|
||||
AppRecordsAudio=$AppRecordsAudio
|
||||
|
||||
# Application needs read/write access SD card. Always disable it, unless you want to access user photos and downloads. (y) / (n)
|
||||
AccessSdCard=$AccessSdCard
|
||||
|
||||
# Application needs to read it's own OBB file. Enable this if you are using Play Store expansion files. (y) / (n)
|
||||
ReadObbFile=$ReadObbFile
|
||||
|
||||
# Application needs Internet access. If you disable it, you'll have to bundle all your data files inside .apk (y) / (n)
|
||||
AccessInternet=$AccessInternet
|
||||
|
||||
# Immersive mode - Android will hide on-screen Home/Back keys. Looks bad if you invoke Android keyboard. (y) / (n)
|
||||
ImmersiveMode=$ImmersiveMode
|
||||
|
||||
# Draw in the display cutout area. (y) / (n)
|
||||
DrawInDisplayCutout=$DrawInDisplayCutout
|
||||
|
||||
# Hide Android system mouse cursor image when USB mouse is attached (y) or (n) - the app must draw it's own mouse cursor
|
||||
HideSystemMousePointer=$HideSystemMousePointer
|
||||
|
||||
# Application implements Android-specific routines to put to background, and will not draw anything to screen
|
||||
# between SDL_ACTIVEEVENT lost / gained notifications - you should check for them
|
||||
# rigth after SDL_Flip(), if (n) then SDL_Flip() will block till app in background (y) or (n)
|
||||
# This option is reported to be buggy, sometimes failing to restore video state
|
||||
NonBlockingSwapBuffers=$NonBlockingSwapBuffers
|
||||
|
||||
# Redefine common hardware keys to SDL keysyms
|
||||
# BACK hardware key is available on all devices, MENU is available on pre-ICS devices, other keys may be absent
|
||||
# SEARCH and CALL by default return same keycode as DPAD_CENTER - one of those keys is available on most devices
|
||||
# Use word NO_REMAP if you want to preserve native functionality for certain key (volume keys are 3-rd and 4-th)
|
||||
# Keys: TOUCHSCREEN (works only when AppUsesMouse=n), DPAD_CENTER/SEARCH, VOLUMEUP, VOLUMEDOWN, MENU, BACK, CAMERA
|
||||
RedefinedKeys="$RedefinedKeys"
|
||||
|
||||
# Number of virtual keyboard keys - currently 12 keys is the maximum
|
||||
AppTouchscreenKeyboardKeysAmount=$AppTouchscreenKeyboardKeysAmount
|
||||
|
||||
# Define SDL keysyms for multitouch gestures - pinch-zoom in, pinch-zoom out, rotate left, rotate right
|
||||
RedefinedKeysScreenGestures="$RedefinedKeysScreenGestures"
|
||||
|
||||
# Redefine on-screen keyboard keys to SDL keysyms - currently 12 keys is the maximum
|
||||
RedefinedKeysScreenKb="$RedefinedKeysScreenKb"
|
||||
|
||||
# Names for on-screen keyboard keys, such as Fire, Jump, Run etc, separated by spaces, they are used in SDL config menu
|
||||
RedefinedKeysScreenKbNames="$RedefinedKeysScreenKbNames"
|
||||
|
||||
# On-screen keys theme
|
||||
# 0 = Ultimate Droid by Sean Stieber (green, with cross joystick)
|
||||
# 1 = Simple Theme by Beholder (white, with cross joystick)
|
||||
# 2 = Sun by Sirea (yellow, with round joystick)
|
||||
# 3 = Keen by Gerstrong (multicolor, with round joystick)
|
||||
# 4 = Retro by Santiago Radeff (red/white, with cross joystick)
|
||||
# 5 = GameBoy from RetroArch
|
||||
# 6 = PlayStation from RetroArch
|
||||
# 7 = SuperNintendo from RetroArch
|
||||
# 8 = DualShock from RetroArch
|
||||
# 9 = Nintendo64 from RetroArch
|
||||
TouchscreenKeysTheme=$TouchscreenKeysTheme
|
||||
|
||||
# Redefine gamepad keys to SDL keysyms, button order is:
|
||||
# A B X Y L1 R1 L2 R2 LThumb RThumb Start Select Up Down Left Right LThumbUp LThumbDown LThumbLeft LThumbRight RThumbUp RThumbDown RThumbLeft RThumbRight
|
||||
RedefinedKeysGamepad="$RedefinedKeysGamepad"
|
||||
|
||||
# Redefine keys for the second gamepad, same as the first gamepad if not set:
|
||||
RedefinedKeysSecondGamepad="$RedefinedKeysSecondGamepad"
|
||||
|
||||
# Redefine keys for the third gamepad, same as the first gamepad if not set:
|
||||
RedefinedKeysThirdGamepad="$RedefinedKeysThirdGamepad"
|
||||
|
||||
# Redefine keys for the fourth gamepad, same as the first gamepad if not set:
|
||||
RedefinedKeysFourthGamepad="$RedefinedKeysFourthGamepad"
|
||||
|
||||
"# How long to show startup menu button, in msec, 0 to disable startup menu
|
||||
StartupMenuButtonTimeout=$StartupMenuButtonTimeout
|
||||
|
||||
# Menu items to hide from startup menu, available menu items (SDL 1.2 only):
|
||||
# $MenuOptionsAvailable
|
||||
HiddenMenuOptions='$HiddenMenuOptions'
|
||||
|
||||
# Menu items to show at startup - this is Java code snippet, leave empty for default
|
||||
# $FirstStartMenuOptionsDefault
|
||||
# Available menu items:
|
||||
# $MenuOptionsAvailable
|
||||
FirstStartMenuOptions='$FirstStartMenuOptions'
|
||||
|
||||
# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower
|
||||
AppMinimumRAM=$AppMinimumRAM
|
||||
|
||||
# GCC version, or 'clang' for CLANG
|
||||
NDK_TOOLCHAIN_VERSION=$NDK_TOOLCHAIN_VERSION
|
||||
|
||||
# Android platform version.
|
||||
# android-16 = Android 4.1, the earliest supported version in NDK r18.
|
||||
# android-18 = Android 4.3, the first version supporting GLES3.
|
||||
# android-21 = Android 5.1, the first version with SO_REUSEPORT defined.
|
||||
APP_PLATFORM=$APP_PLATFORM
|
||||
|
||||
# Specify architectures to compile, 'all' or 'y' to compile for all architectures.
|
||||
# Available architectures: armeabi-v7a arm64-v8a x86 x86_64
|
||||
MultiABI='$MultiABI'
|
||||
|
||||
# Optional shared libraries to compile - removing some of them will save space
|
||||
# MP3 patents are expired, but libmad license is GPL, not LGPL
|
||||
rep 'Available' project/jni/SettingsTemplate.mk
|
||||
CompiledLibraries="$CompiledLibraries"
|
||||
|
||||
# Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n)
|
||||
CustomBuildScript=$CustomBuildScript
|
||||
|
||||
# Aditional CFLAGS for application
|
||||
AppCflags='$AppCflags'
|
||||
|
||||
# Aditional C++-specific compiler flags for application, added after AppCflags
|
||||
AppCppflags='$AppCppflags'
|
||||
|
||||
# Additional LDFLAGS for application
|
||||
AppLdflags='$AppLdflags'
|
||||
|
||||
# If application has headers with the same name as system headers, this option tries to fix compiler flags to make it compilable
|
||||
AppOverlapsSystemHeaders=$AppOverlapsSystemHeaders
|
||||
|
||||
# Build only following subdirs (empty will build all dirs, ignored with custom script)
|
||||
AppSubdirsBuild='$AppSubdirsBuild'
|
||||
|
||||
# Exclude these files from build
|
||||
AppBuildExclude='$AppBuildExclude'
|
||||
|
||||
# Application command line parameters, including app name as 0-th param
|
||||
AppCmdline='$AppCmdline'
|
||||
|
||||
# Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens
|
||||
# Minimum screen size that application supports: (s)mall / (m)edium / (l)arge
|
||||
MinimumScreenSize=$MinimumScreenSize
|
||||
|
||||
# Your AdMob Publisher ID, (n) if you don't want advertisements
|
||||
AdmobPublisherId=$AdmobPublisherId
|
||||
|
||||
# Your AdMob test device ID, to receive a test ad
|
||||
AdmobTestDeviceId=$AdmobTestDeviceId
|
||||
|
||||
# Your AdMob banner size (BANNER/FULL_BANNER/LEADERBOARD/MEDIUM_RECTANGLE/SMART_BANNER/WIDE_SKYSCRAPER/FULL_WIDTH:Height/Width:AUTO_HEIGHT/Width:Height)
|
||||
AdmobBannerSize=$AdmobBannerSize
|
||||
|
||||
# Google Play Game Services application ID, required for cloud saves to work
|
||||
GooglePlayGameServicesId=$GooglePlayGameServicesId
|
||||
|
||||
# The app will open files with following extension, file path will be added to commandline params
|
||||
AppOpenFileExtension='$AppOpenFileExtension'
|
||||
EOF
|
||||
echo "# The application settings for Android libSDL port" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Specify application name (e.x. My Application)" >> AndroidAppSettings.cfg
|
||||
echo AppName=\"$AppName\" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Specify reversed site name of application (e.x. com.mysite.myapp)" >> AndroidAppSettings.cfg
|
||||
echo AppFullName=$AppFullName >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application version code (integer)" >> AndroidAppSettings.cfg
|
||||
echo AppVersionCode=$AppVersionCode >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application user-visible version name (string)" >> AndroidAppSettings.cfg
|
||||
echo AppVersionName=\"$AppVersionName\" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'" >> AndroidAppSettings.cfg
|
||||
echo "# If you'll start Description with '!' symbol it will be enabled by default, '!!' will also hide the entry from the menu, so it cannot be disabled" >> AndroidAppSettings.cfg
|
||||
echo "# If the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as binary BLOB to the application dir and not unzipped" >> AndroidAppSettings.cfg
|
||||
echo "# If the URL does not contain 'http://' or 'https://', it is treated as file from 'project/jni/application/src/AndroidData' dir -" >> AndroidAppSettings.cfg
|
||||
echo "# these files are put inside .apk package by the build system" >> AndroidAppSettings.cfg
|
||||
echo "# You can specify Google Play expansion files in the form 'obb:main.12345' or 'obb:patch.12345' where 12345 is the app version for obb file" >> AndroidAppSettings.cfg
|
||||
echo "# You can use .zip.xz archives for better compression, but you need to add 'lzma' to CompiledLibraries" >> AndroidAppSettings.cfg
|
||||
echo "# Generate .zip.xz files like this: zip -0 -r data.zip your-data/* ; xz -8 data.zip" >> AndroidAppSettings.cfg
|
||||
echo AppDataDownloadUrl=\"$AppDataDownloadUrl\" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Reset SDL config when updating application to the new version (y) / (n)" >> AndroidAppSettings.cfg
|
||||
echo ResetSdlConfigForThisVersion=$ResetSdlConfigForThisVersion >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Delete application data files when upgrading (specify file/dir paths separated by spaces)" >> AndroidAppSettings.cfg
|
||||
echo DeleteFilesOnUpgrade=\"$DeleteFilesOnUpgrade\" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Here you may type readme text, which will be shown during startup. Format is:" >> AndroidAppSettings.cfg
|
||||
echo "# Text in English, use \\\\\\\\\\\\\\\\n to separate lines (that's four backslashes)^de:Text in Deutsch^ru:Text in Russian^button:Button that will open some URL:http://url-to-open/" >> AndroidAppSettings.cfg
|
||||
echo ReadmeText=\'$ReadmeText\' | sed 's/\\\\n/\\\\\\\\n/g' >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# libSDL version to use (1.2/1.3/2.0)" >> AndroidAppSettings.cfg
|
||||
echo LibSdlVersion=$LibSdlVersion >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Specify screen orientation: (v)ertical/(p)ortrait or (h)orizontal/(l)andscape" >> AndroidAppSettings.cfg
|
||||
echo ScreenOrientation=$ScreenOrientation >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Video color depth - 16 BPP is the fastest and supported for all modes, 24 bpp is supported only" >> AndroidAppSettings.cfg
|
||||
echo "# with SwVideoMode=y, SDL_OPENGL mode supports everything. (16)/(24)/(32)" >> AndroidAppSettings.cfg
|
||||
echo VideoDepthBpp=$VideoDepthBpp >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Enable OpenGL depth buffer (needed only for 3-d applications, small speed decrease) (y) or (n)" >> AndroidAppSettings.cfg
|
||||
echo NeedDepthBuffer=$NeedDepthBuffer >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Enable OpenGL stencil buffer (needed only for 3-d applications, small speed decrease) (y) or (n)" >> AndroidAppSettings.cfg
|
||||
echo NeedStencilBuffer=$NeedStencilBuffer >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Use GLES 2.x context" >> AndroidAppSettings.cfg
|
||||
echo "# you need this option only if you're developing 3-d app (y) or (n)" >> AndroidAppSettings.cfg
|
||||
echo NeedGles2=$NeedGles2 >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Use GLES 3.x context" >> AndroidAppSettings.cfg
|
||||
echo "# you need this option only if you're developing 3-d app (y) or (n)" >> AndroidAppSettings.cfg
|
||||
echo NeedGles3=$NeedGles3 >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Use gl4es library for provide OpenGL 1.x functionality to OpenGL ES accelerated cards (y) or (n)" >> AndroidAppSettings.cfg
|
||||
echo UseGl4es=$UseGl4es >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application uses software video buffer - you're calling SDL_SetVideoMode() without SDL_HWSURFACE and without SDL_OPENGL," >> AndroidAppSettings.cfg
|
||||
echo "# this will allow small speed optimization. Enable this even when you're using SDL_HWSURFACE. (y) or (n)" >> AndroidAppSettings.cfg
|
||||
echo SwVideoMode=$SwVideoMode >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application video output will be resized to fit into native device screen (y)/(n)" >> AndroidAppSettings.cfg
|
||||
echo SdlVideoResize=$SdlVideoResize >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application resizing will keep 4:3 aspect ratio, with black bars at sides (y)/(n)" >> AndroidAppSettings.cfg
|
||||
echo SdlVideoResizeKeepAspect=$SdlVideoResizeKeepAspect >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Do not allow device to sleep when the application is in foreground, set this for video players or apps which use accelerometer" >> AndroidAppSettings.cfg
|
||||
echo InhibitSuspend=$InhibitSuspend >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Create Android service, so the app is less likely to be killed while in background" >> AndroidAppSettings.cfg
|
||||
echo CreateService=$CreateService >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application does not call SDL_Flip() or SDL_UpdateRects() appropriately, or draws from non-main thread -" >> AndroidAppSettings.cfg
|
||||
echo "# enabling the compatibility mode will force screen update every 100 milliseconds, which is laggy and inefficient (y) or (n)" >> AndroidAppSettings.cfg
|
||||
echo CompatibilityHacksForceScreenUpdate=$CompatibilityHacksForceScreenUpdate >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application does not call SDL_Flip() or SDL_UpdateRects() after mouse click (ScummVM and all Amiga emulators do that) -" >> AndroidAppSettings.cfg
|
||||
echo "# force screen update by moving mouse cursor a little after each click (y) or (n)" >> AndroidAppSettings.cfg
|
||||
echo CompatibilityHacksForceScreenUpdateMouseClick=$CompatibilityHacksForceScreenUpdateMouseClick >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application initializes SDL audio/video inside static constructors (which is bad, you won't be able to run ndk-gdb) (y)/(n)" >> AndroidAppSettings.cfg
|
||||
echo CompatibilityHacksStaticInit=$CompatibilityHacksStaticInit >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# On-screen Android soft text input emulates hardware keyboard, this will only work with Hackers Keyboard app (y)/(n)" >> AndroidAppSettings.cfg
|
||||
echo CompatibilityHacksTextInputEmulatesHwKeyboard=$CompatibilityHacksTextInputEmulatesHwKeyboard >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Built-in text input keyboards with custom layouts for emulators, requires CompatibilityHacksTextInputEmulatesHwKeyboard=y" >> AndroidAppSettings.cfg
|
||||
echo "# 0 or empty - standard Android keyboard" >> AndroidAppSettings.cfg
|
||||
echo "# 1 - Simple QWERTY keyboard, no function keys, no arrow keys" >> AndroidAppSettings.cfg
|
||||
echo "# 2 - Commodore 64 keyboard" >> AndroidAppSettings.cfg
|
||||
echo "# 3 - Amiga keyboard" >> AndroidAppSettings.cfg
|
||||
echo "# 4 - Atari800 keyboard" >> AndroidAppSettings.cfg
|
||||
echo TextInputKeyboard=$TextInputKeyboard >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Hack for broken devices: prevent audio chopping, by sleeping a bit after pushing each audio chunk (y)/(n)" >> AndroidAppSettings.cfg
|
||||
echo CompatibilityHacksPreventAudioChopping=$CompatibilityHacksPreventAudioChopping >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Hack for broken apps: application ignores audio buffer size returned by SDL (y)/(n)" >> AndroidAppSettings.cfg
|
||||
echo CompatibilityHacksAppIgnoresAudioBufferSize=$CompatibilityHacksAppIgnoresAudioBufferSize >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Hack for VCMI: preload additional shared libraries before aplication start" >> AndroidAppSettings.cfg
|
||||
echo CompatibilityHacksAdditionalPreloadedSharedLibraries=\"$CompatibilityHacksAdditionalPreloadedSharedLibraries\" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Hack for Free Heroes 2, which redraws the screen inside SDL_PumpEvents(): slow and compatible SDL event queue -" >> AndroidAppSettings.cfg
|
||||
echo "# do not use it with accelerometer/gyroscope, or your app may freeze at random (y)/(n)" >> AndroidAppSettings.cfg
|
||||
echo CompatibilityHacksSlowCompatibleEventQueue=$CompatibilityHacksSlowCompatibleEventQueue >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Save and restore OpenGL state when drawing on-screen keyboard for apps that use SDL_OPENGL" >> AndroidAppSettings.cfg
|
||||
echo CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=$CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application uses SDL_UpdateRects() properly, and does not draw in any region outside those rects." >> AndroidAppSettings.cfg
|
||||
echo "# This improves drawing speed, but I know only one application that does that, and it's written by me (y)/(n)" >> AndroidAppSettings.cfg
|
||||
echo CompatibilityHacksProperUsageOfSDL_UpdateRects=$CompatibilityHacksProperUsageOfSDL_UpdateRects >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application uses mouse (y) or (n), this will show mouse emulation dialog to the user" >> AndroidAppSettings.cfg
|
||||
echo AppUsesMouse=$AppUsesMouse >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application needs two-button mouse, will also enable advanced point-and-click features (y) or (n)" >> AndroidAppSettings.cfg
|
||||
echo AppNeedsTwoButtonMouse=$AppNeedsTwoButtonMouse >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Right mouse button can do long-press/drag&drop action, necessary for some games (y) or (n)" >> AndroidAppSettings.cfg
|
||||
echo "# If you disable it, swiping with two fingers will send mouse wheel events" >> AndroidAppSettings.cfg
|
||||
echo RightMouseButtonLongPress=$RightMouseButtonLongPress >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n)" >> AndroidAppSettings.cfg
|
||||
echo ShowMouseCursor=$ShowMouseCursor >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Screen follows mouse cursor, when it's covered by soft keyboard, this works only in software video mode (y) or (n)" >> AndroidAppSettings.cfg
|
||||
echo ScreenFollowsMouse=$ScreenFollowsMouse >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Generate more touch events, by default SDL generates one event per one video frame, this is useful for drawing apps (y) or (n)" >> AndroidAppSettings.cfg
|
||||
echo GenerateSubframeTouchEvents=$GenerateSubframeTouchEvents >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Force relative (laptop) mouse movement mode, useful when both on-screen keyboard and mouse are needed (y) or (n)" >> AndroidAppSettings.cfg
|
||||
echo ForceRelativeMouseMode=$ForceRelativeMouseMode >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Show on-screen dpad/joystick, that will act as arrow keys (y) or (n)" >> AndroidAppSettings.cfg
|
||||
echo AppNeedsArrowKeys=$AppNeedsArrowKeys >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# On-screen dpad/joystick will appear under finger when it touches the screen (y) or (n)" >> AndroidAppSettings.cfg
|
||||
echo "# Joystick always follows finger, so moving mouse requires touching the screen with other finger" >> AndroidAppSettings.cfg
|
||||
echo FloatingScreenJoystick=$FloatingScreenJoystick >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application needs text input (y) or (n), enables button for text input on screen" >> AndroidAppSettings.cfg
|
||||
echo AppNeedsTextInput=$AppNeedsTextInput >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application uses joystick (y) or (n), the on-screen DPAD will be used as joystick 0 axes 0-1" >> AndroidAppSettings.cfg
|
||||
echo "# This will disable AppNeedsArrowKeys option" >> AndroidAppSettings.cfg
|
||||
echo AppUsesJoystick=$AppUsesJoystick >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application uses second on-screen joystick, as SDL joystick 0 axes 2-3 (y)/(n)" >> AndroidAppSettings.cfg
|
||||
echo AppUsesSecondJoystick=$AppUsesSecondJoystick >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application uses third on-screen joystick, as SDL joystick 0 axes 20-21 (y)/(n)" >> AndroidAppSettings.cfg
|
||||
echo AppUsesThirdJoystick=$AppUsesThirdJoystick >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application uses accelerometer (y) or (n), the accelerometer will be used as joystick 1 axes 0-1 and 5-7" >> AndroidAppSettings.cfg
|
||||
echo AppUsesAccelerometer=$AppUsesAccelerometer >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application uses gyroscope (y) or (n), the gyroscope will be used as joystick 1 axes 2-4" >> AndroidAppSettings.cfg
|
||||
echo AppUsesGyroscope=$AppUsesGyroscope >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application uses orientation sensor (y) or (n), reported as joystick 1 axes 8-10" >> AndroidAppSettings.cfg
|
||||
echo AppUsesOrientationSensor=$AppUsesOrientationSensor >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Use gyroscope to move mouse cursor (y) or (n), it eats battery, and can be disabled in settings, do not use with AppUsesGyroscope setting" >> AndroidAppSettings.cfg
|
||||
echo MoveMouseWithGyroscope=$MoveMouseWithGyroscope >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBALLMOTION events for the joystick 0" >> AndroidAppSettings.cfg
|
||||
echo AppUsesMultitouch=$AppUsesMultitouch >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application records audio (it will use any available source, such a s microphone)" >> AndroidAppSettings.cfg
|
||||
echo "# API is defined in file SDL_android.h: int SDL_ANDROID_OpenAudioRecording(SDL_AudioSpec *spec); void SDL_ANDROID_CloseAudioRecording(void);" >> AndroidAppSettings.cfg
|
||||
echo "# This option will add additional permission to Android manifest (y)/(n)" >> AndroidAppSettings.cfg
|
||||
echo AppRecordsAudio=$AppRecordsAudio >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application needs read/write access SD card. Always disable it, unless you want to access user photos and downloads. (y) / (n)" >> AndroidAppSettings.cfg
|
||||
echo AccessSdCard=$AccessSdCard >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application needs to read it's own OBB file. Enable this if you are using Play Store expansion files. (y) / (n)" >> AndroidAppSettings.cfg
|
||||
echo ReadObbFile=$ReadObbFile >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application needs Internet access. If you disable it, you'll have to bundle all your data files inside .apk (y) / (n)" >> AndroidAppSettings.cfg
|
||||
echo AccessInternet=$AccessInternet >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Immersive mode - Android will hide on-screen Home/Back keys. Looks bad if you invoke Android keyboard. (y) / (n)" >> AndroidAppSettings.cfg
|
||||
echo ImmersiveMode=$ImmersiveMode >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Hide Android system mouse cursor image when USB mouse is attached (y) or (n) - the app must draw it's own mouse cursor" >> AndroidAppSettings.cfg
|
||||
echo HideSystemMousePointer=$HideSystemMousePointer >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application implements Android-specific routines to put to background, and will not draw anything to screen" >> AndroidAppSettings.cfg
|
||||
echo "# between SDL_ACTIVEEVENT lost / gained notifications - you should check for them" >> AndroidAppSettings.cfg
|
||||
echo "# rigth after SDL_Flip(), if (n) then SDL_Flip() will block till app in background (y) or (n)" >> AndroidAppSettings.cfg
|
||||
echo "# This option is reported to be buggy, sometimes failing to restore video state" >> AndroidAppSettings.cfg
|
||||
echo NonBlockingSwapBuffers=$NonBlockingSwapBuffers >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Redefine common hardware keys to SDL keysyms" >> AndroidAppSettings.cfg
|
||||
echo "# BACK hardware key is available on all devices, MENU is available on pre-ICS devices, other keys may be absent" >> AndroidAppSettings.cfg
|
||||
echo "# SEARCH and CALL by default return same keycode as DPAD_CENTER - one of those keys is available on most devices" >> AndroidAppSettings.cfg
|
||||
echo "# Use word NO_REMAP if you want to preserve native functionality for certain key (volume keys are 3-rd and 4-th)" >> AndroidAppSettings.cfg
|
||||
echo "# Keys: TOUCHSCREEN (works only when AppUsesMouse=n), DPAD_CENTER/SEARCH, VOLUMEUP, VOLUMEDOWN, MENU, BACK, CAMERA" >> AndroidAppSettings.cfg
|
||||
echo RedefinedKeys=\"$RedefinedKeys\" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Number of virtual keyboard keys (currently 6 is maximum)" >> AndroidAppSettings.cfg
|
||||
echo AppTouchscreenKeyboardKeysAmount=$AppTouchscreenKeyboardKeysAmount >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right)" >> AndroidAppSettings.cfg
|
||||
echo RedefinedKeysScreenKb=\"$RedefinedKeysScreenKb\" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Names for on-screen keyboard keys, such as Fire, Jump, Run etc, separated by spaces, they are used in SDL config menu" >> AndroidAppSettings.cfg
|
||||
echo RedefinedKeysScreenKbNames=\"$RedefinedKeysScreenKbNames\" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# On-screen keys theme" >> AndroidAppSettings.cfg
|
||||
echo "# 0 = Ultimate Droid by Sean Stieber (green, with cross joystick)" >> AndroidAppSettings.cfg
|
||||
echo "# 1 = Simple Theme by Beholder (white, with cross joystick)" >> AndroidAppSettings.cfg
|
||||
echo "# 2 = Sun by Sirea (yellow, with round joystick)" >> AndroidAppSettings.cfg
|
||||
echo "# 3 = Keen by Gerstrong (multicolor, with round joystick)" >> AndroidAppSettings.cfg
|
||||
echo "# 4 = Retro by Santiago Radeff (red/white, with cross joystick)" >> AndroidAppSettings.cfg
|
||||
echo "# 5 = GameBoy from RetroArch" >> AndroidAppSettings.cfg
|
||||
echo "# 6 = PlayStation from RetroArch" >> AndroidAppSettings.cfg
|
||||
echo "# 7 = SuperNintendo from RetroArch" >> AndroidAppSettings.cfg
|
||||
echo "# 8 = DualShock from RetroArch" >> AndroidAppSettings.cfg
|
||||
echo "# 9 = Nintendo64 from RetroArch" >> AndroidAppSettings.cfg
|
||||
echo TouchscreenKeysTheme=$TouchscreenKeysTheme >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Redefine gamepad keys to SDL keysyms, button order is:" >> AndroidAppSettings.cfg
|
||||
echo "# A B X Y L1 R1 L2 R2 LThumb RThumb Start Select Up Down Left Right LThumbUp LThumbDown LThumbLeft LThumbRight RThumbUp RThumbDown RThumbLeft RThumbRight" >> AndroidAppSettings.cfg
|
||||
echo RedefinedKeysGamepad=\"$RedefinedKeysGamepad\" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Redefine keys for the second gamepad, same as the first gamepad if not set:" >> AndroidAppSettings.cfg
|
||||
echo RedefinedKeysSecondGamepad=\"$RedefinedKeysSecondGamepad\" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Redefine keys for the third gamepad, same as the first gamepad if not set:" >> AndroidAppSettings.cfg
|
||||
echo RedefinedKeysThirdGamepad=\"$RedefinedKeysThirdGamepad\" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Redefine keys for the fourth gamepad, same as the first gamepad if not set:" >> AndroidAppSettings.cfg
|
||||
echo RedefinedKeysFourthGamepad=\"$RedefinedKeysFourthGamepad\" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# How long to show startup menu button, in msec, 0 to disable startup menu" >> AndroidAppSettings.cfg
|
||||
echo StartupMenuButtonTimeout=$StartupMenuButtonTimeout >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Menu items to hide from startup menu, available menu items:" >> AndroidAppSettings.cfg
|
||||
echo "# $MenuOptionsAvailable" >> AndroidAppSettings.cfg
|
||||
echo HiddenMenuOptions=\'$HiddenMenuOptions\' >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Menu items to show at startup - this is Java code snippet, leave empty for default" >> AndroidAppSettings.cfg
|
||||
echo "# $FirstStartMenuOptionsDefault" >> AndroidAppSettings.cfg
|
||||
echo "# Available menu items:" >> AndroidAppSettings.cfg
|
||||
echo "# $MenuOptionsAvailable" >> AndroidAppSettings.cfg
|
||||
echo FirstStartMenuOptions=\'$FirstStartMenuOptions\' >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower" >> AndroidAppSettings.cfg
|
||||
echo AppMinimumRAM=$AppMinimumRAM >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# GCC version, or 'clang' for CLANG" >> AndroidAppSettings.cfg
|
||||
echo NDK_TOOLCHAIN_VERSION=$NDK_TOOLCHAIN_VERSION >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Android platform version." >> AndroidAppSettings.cfg
|
||||
echo "# android-16 = Android 4.1, the earliest supported version in NDK r18." >> AndroidAppSettings.cfg
|
||||
echo "# android-18 = Android 4.3, the first version supporting GLES3." >> AndroidAppSettings.cfg
|
||||
echo "# android-21 = Android 5.1, the first version with SO_REUSEPORT defined." >> AndroidAppSettings.cfg
|
||||
echo APP_PLATFORM=$APP_PLATFORM >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Specify architectures to compile, 'all' or 'y' to compile for all architectures." >> AndroidAppSettings.cfg
|
||||
echo "# Available architectures: armeabi-v7a arm64-v8a x86 x86_64" >> AndroidAppSettings.cfg
|
||||
echo MultiABI=\'$MultiABI\' >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Optional shared libraries to compile - removing some of them will save space" >> AndroidAppSettings.cfg
|
||||
echo "# MP3 patents are expired, but libmad license is GPL, not LGPL" >> AndroidAppSettings.cfg
|
||||
grep 'Available' project/jni/SettingsTemplate.mk >> AndroidAppSettings.cfg
|
||||
echo CompiledLibraries=\"$CompiledLibraries\" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n)" >> AndroidAppSettings.cfg
|
||||
echo CustomBuildScript=$CustomBuildScript >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Aditional CFLAGS for application" >> AndroidAppSettings.cfg
|
||||
echo AppCflags=\'$AppCflags\' >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Aditional C++-specific compiler flags for application, added after AppCflags" >> AndroidAppSettings.cfg
|
||||
echo AppCppflags=\'$AppCppflags\' >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Additional LDFLAGS for application" >> AndroidAppSettings.cfg
|
||||
echo AppLdflags=\'$AppLdflags\' >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# If application has headers with the same name as system headers, this option tries to fix compiler flags to make it compilable" >> AndroidAppSettings.cfg
|
||||
echo AppOverlapsSystemHeaders=$AppOverlapsSystemHeaders >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Build only following subdirs (empty will build all dirs, ignored with custom script)" >> AndroidAppSettings.cfg
|
||||
echo AppSubdirsBuild=\'$AppSubdirsBuild\' >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Exclude these files from build" >> AndroidAppSettings.cfg
|
||||
echo AppBuildExclude=\'$AppBuildExclude\' >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application command line parameters, including app name as 0-th param" >> AndroidAppSettings.cfg
|
||||
echo AppCmdline=\'$AppCmdline\' >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens" >> AndroidAppSettings.cfg
|
||||
echo "# Minimum screen size that application supports: (s)mall / (m)edium / (l)arge" >> AndroidAppSettings.cfg
|
||||
echo MinimumScreenSize=$MinimumScreenSize >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Your AdMob Publisher ID, (n) if you don't want advertisements" >> AndroidAppSettings.cfg
|
||||
echo AdmobPublisherId=$AdmobPublisherId >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Your AdMob test device ID, to receive a test ad" >> AndroidAppSettings.cfg
|
||||
echo AdmobTestDeviceId=$AdmobTestDeviceId >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Your AdMob banner size (BANNER/FULL_BANNER/LEADERBOARD/MEDIUM_RECTANGLE/SMART_BANNER/WIDE_SKYSCRAPER/FULL_WIDTH:Height/Width:AUTO_HEIGHT/Width:Height)" >> AndroidAppSettings.cfg
|
||||
echo AdmobBannerSize=$AdmobBannerSize >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Google Play Game Services application ID, required for cloud saves to work" >> AndroidAppSettings.cfg
|
||||
echo GooglePlayGameServicesId=$GooglePlayGameServicesId >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# The app will open files with following extension, file path will be added to commandline params" >> AndroidAppSettings.cfg
|
||||
echo AppOpenFileExtension=\'$AppOpenFileExtension\' >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
fi
|
||||
|
||||
AppShortName=`echo $AppName | sed 's/ //g'`
|
||||
@@ -496,12 +461,14 @@ AppSharedLibrariesPath=/data/data/$AppFullName/lib
|
||||
ScreenOrientation1=sensorPortrait
|
||||
HorizontalOrientation=false
|
||||
|
||||
UsingSdl2=false
|
||||
if [ "$LibSdlVersion" = "2.0" ] ; then
|
||||
"$LibSdlVersion" = "2"
|
||||
UsingSdl13=false
|
||||
if [ "$LibSdlVersion" = "1.3" ] ; then
|
||||
UsingSdl13=true
|
||||
fi
|
||||
if [ "$LibSdlVersion" = "2" ] ; then
|
||||
UsingSdl2=true
|
||||
|
||||
UsingSdl20=false
|
||||
if [ "$LibSdlVersion" = "2.0" ] ; then
|
||||
UsingSdl20=true
|
||||
fi
|
||||
|
||||
if [ "$ScreenOrientation" = "h" -o "$ScreenOrientation" = "l" ] ; then
|
||||
@@ -738,12 +705,6 @@ for KEY in $RedefinedKeys; do
|
||||
KEY2=`expr $KEY2 '+' 1`
|
||||
done
|
||||
|
||||
KEY2=0
|
||||
for KEY in $RedefinedKeysScreenGestures; do
|
||||
RedefinedSDLScreenGestures="$RedefinedSDLScreenGestures -DSDL_ANDROID_SCREEN_GESTURE_KEYCODE_$KEY2=$KEY"
|
||||
KEY2=`expr $KEY2 '+' 1`
|
||||
done
|
||||
|
||||
KEY2=0
|
||||
for KEY in $RedefinedKeysScreenKb; do
|
||||
RedefinedKeycodesScreenKb="$RedefinedKeycodesScreenKb -DSDL_ANDROID_SCREENKB_KEYCODE_$KEY2=$KEY"
|
||||
@@ -786,8 +747,7 @@ else
|
||||
MultiABI="$MultiABI"
|
||||
fi
|
||||
|
||||
LibrariesToLoad="\\\"sdl_native_helpers\\\", \\\"`$UsingSdl2 && echo SDL2 || echo sdl-1.2`\\\""
|
||||
|
||||
LibrariesToLoad="\\\"sdl_native_helpers\\\", \\\"sdl-$LibSdlVersion\\\""
|
||||
StaticLibraries="`echo '
|
||||
include project/jni/SettingsTemplate.mk
|
||||
all:
|
||||
@@ -808,11 +768,8 @@ for lib in $CompatibilityHacksAdditionalPreloadedSharedLibraries; do
|
||||
MainLibrariesToLoad="$MainLibrariesToLoad \\\"$lib\\\","
|
||||
done
|
||||
|
||||
if $UsingSdl2; then
|
||||
MainLibrariesToLoad="$MainLibrariesToLoad \\\"application\\\""
|
||||
else
|
||||
MainLibrariesToLoad="$MainLibrariesToLoad \\\"application\\\", \\\"sdl_main\\\""
|
||||
fi
|
||||
MainLibrariesToLoad="$MainLibrariesToLoad \\\"application\\\", \\\"sdl_main\\\""
|
||||
|
||||
|
||||
if [ "$CustomBuildScript" = "n" ] ; then
|
||||
CustomBuildScript=
|
||||
@@ -840,51 +797,37 @@ if uname -s | grep -i "darwin" > /dev/null ; then
|
||||
SEDI="sed -i.killme.tmp" # MacOsX version of sed is buggy, and requires a mandatory parameter
|
||||
fi
|
||||
|
||||
|
||||
rm -rf project/src
|
||||
mkdir -p project/src
|
||||
|
||||
if $UsingSdl2; then
|
||||
JAVA_SRC_PATH=project/javaSDL2
|
||||
fi
|
||||
|
||||
cd $JAVA_SRC_PATH
|
||||
for F in *.java; do
|
||||
echo '// DO NOT EDIT THIS FILE - it is automatically generated, ALL YOUR CHANGES WILL BE OVERWRITTEN, edit the file under '$JAVA_SRC_PATH' dir' | cat - $F > ../src/$F
|
||||
echo '// DO NOT EDIT THIS FILE - it is automatically generated, ALL YOUR CHANGES WILL BE OVERWRITTEN, edit the file under $JAVA_SRC_PATH dir' | cat - $F > ../src/$F
|
||||
done
|
||||
|
||||
if [ -e ../jni/application/src/java.diff ]; then patch -d ../src --no-backup-if-mismatch < ../jni/application/src/java.diff || exit 1 ; fi
|
||||
if [ -e ../jni/application/src/java.patch ]; then patch -d ../src --no-backup-if-mismatch < ../jni/application/src/java.patch || exit 1 ; fi
|
||||
if ls ../jni/application/src/*.java > /dev/null 2>&1; then cp -f ../jni/application/src/*.java ../src ; fi
|
||||
|
||||
for F in ../src/*.java; do
|
||||
echo Patching $F
|
||||
$SEDI "s/^package .*;/package $AppFullName;/" $F
|
||||
done
|
||||
|
||||
if $UsingSdl2; then
|
||||
# Keep package name org.libsdl.app, it's hardcoded inside libSDL2.so
|
||||
for F in `ls ../jni/sdl2/android-project/app/src/main/java/org/libsdl/app/`; do
|
||||
echo '// DO NOT EDIT THIS FILE - it is automatically generated, ALL YOUR CHANGES WILL BE OVERWRITTEN,' \
|
||||
'edit the file under project/jni/sdl2/android-project/app/src/main/java/org/libsdl/app dir' | \
|
||||
cat - ../jni/sdl2/android-project/app/src/main/java/org/libsdl/app/$F > ../src/$F
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -e ../jni/application/src/java.diff ]; then patch -d ../src --no-backup-if-mismatch < ../jni/application/src/java.diff || exit 1 ; fi
|
||||
if [ -e ../jni/application/src/java.patch ]; then patch -d ../src --no-backup-if-mismatch < ../jni/application/src/java.patch || exit 1 ; fi
|
||||
if ls ../jni/application/src/*.java > /dev/null 2>&1; then cp -f ../jni/application/src/*.java ../src ; fi
|
||||
|
||||
cd ../..
|
||||
|
||||
if $UsingSdl2; then
|
||||
ANDROID_MANIFEST_TEMPLATE=project/jni/sdl2/android-project/app/src/main/AndroidManifest.xml
|
||||
else
|
||||
ANDROID_MANIFEST_TEMPLATE=project/AndroidManifestTemplate.xml
|
||||
# In case we use SDL2 let simlink the SDLActivity source file
|
||||
if [ "$LibSdlVersion" = "2.0" ] ; then
|
||||
ln -s ../jni/sdl-2.0/android-project/src/org/libsdl/app/SDLActivity.java project/src/SDLActivity.java
|
||||
fi
|
||||
|
||||
|
||||
echo Patching project/AndroidManifest.xml
|
||||
cat $ANDROID_MANIFEST_TEMPLATE | \
|
||||
cat project/AndroidManifestTemplate.xml | \
|
||||
sed "s/package=.*/package=\"$AppFullName\"/" | \
|
||||
sed "s/android:screenOrientation=.*/android:screenOrientation=\"$ScreenOrientation1\"/" | \
|
||||
sed "s^android:versionCode=.*^android:versionCode=\"$AppVersionCode\"^" | \
|
||||
sed "s^android:versionName=.*^android:versionName=\"$AppVersionName\"^" | \
|
||||
sed "s^activity android:name=\"SDLActivity\"^activity android:name=\"MainActivity\"^" > \
|
||||
sed "s^android:versionName=.*^android:versionName=\"$AppVersionName\"^" > \
|
||||
project/AndroidManifest.xml
|
||||
if [ "$AdmobPublisherId" = "n" -o -z "$AdmobPublisherId" ] ; then
|
||||
$SEDI "/==ADMOB==/ d" project/AndroidManifest.xml
|
||||
@@ -951,12 +894,6 @@ else
|
||||
ImmersiveMode=true
|
||||
fi
|
||||
|
||||
if [ "$DrawInDisplayCutout" = "y" ]; then
|
||||
DrawInDisplayCutout=true
|
||||
else
|
||||
DrawInDisplayCutout=false
|
||||
fi
|
||||
|
||||
if [ "$HideSystemMousePointer" = "n" ]; then
|
||||
HideSystemMousePointer=false
|
||||
else
|
||||
@@ -994,8 +931,9 @@ fi
|
||||
|
||||
echo Patching project/src/Globals.java
|
||||
$SEDI "s/public static String ApplicationName = .*;/public static String ApplicationName = \"$AppShortName\";/" project/src/Globals.java
|
||||
$SEDI "s/public static final boolean Using_SDL_1_3 = .*;/public static final boolean Using_SDL_1_3 = $UsingSdl13;/" project/src/Globals.java
|
||||
|
||||
$SEDI "s/public static final boolean UsingSDL2 = .*;/public static final boolean UsingSDL2 = $UsingSdl2;/" project/src/Globals.java
|
||||
$SEDI "s/public static final boolean Using_SDL_2_0 = .*;/public static final boolean Using_SDL_2_0 = $UsingSdl20;/" project/src/Globals.java
|
||||
|
||||
# Work around "Argument list too long" problem when compiling VICE
|
||||
#$SEDI "s@public static String DataDownloadUrl = .*@public static String DataDownloadUrl = \"$AppDataDownloadUrl1\";@" project/src/Globals.java
|
||||
@@ -1039,7 +977,6 @@ $SEDI "s/public static boolean AppUsesMultitouch = .*;/public static boolean App
|
||||
$SEDI "s/public static boolean NonBlockingSwapBuffers = .*;/public static boolean NonBlockingSwapBuffers = $NonBlockingSwapBuffers;/" project/src/Globals.java
|
||||
$SEDI "s/public static boolean ResetSdlConfigForThisVersion = .*;/public static boolean ResetSdlConfigForThisVersion = $ResetSdlConfigForThisVersion;/" project/src/Globals.java
|
||||
$SEDI "s/public static boolean ImmersiveMode = .*;/public static boolean ImmersiveMode = $ImmersiveMode;/" project/src/Globals.java
|
||||
$SEDI "s/public static boolean DrawInDisplayCutout = .*;/public static boolean DrawInDisplayCutout = $DrawInDisplayCutout;/" project/src/Globals.java
|
||||
$SEDI "s/public static boolean HideSystemMousePointer = .*;/public static boolean HideSystemMousePointer = $HideSystemMousePointer;/" project/src/Globals.java
|
||||
$SEDI "s|public static String DeleteFilesOnUpgrade = .*;|public static String DeleteFilesOnUpgrade = \"$DeleteFilesOnUpgrade\";|" project/src/Globals.java
|
||||
$SEDI "s/public static int AppTouchscreenKeyboardKeysAmount = .*;/public static int AppTouchscreenKeyboardKeysAmount = $AppTouchscreenKeyboardKeysAmount;/" project/src/Globals.java
|
||||
@@ -1058,16 +995,11 @@ $SEDI "s%public static String GooglePlayGameServicesId = .*%public static String
|
||||
$SEDI "s/public static String AppLibraries.*/public static String AppLibraries[] = { $LibrariesToLoad };/" project/src/Globals.java
|
||||
$SEDI "s/public static String AppMainLibraries.*/public static String AppMainLibraries[] = { $MainLibrariesToLoad };/" project/src/Globals.java
|
||||
|
||||
if $UsingSdl2; then
|
||||
# Delete options that reference classes from SDL 1.2
|
||||
$SEDI "s/public static SettingsMenu.Menu HiddenMenuOptions .*;//" project/src/Globals.java
|
||||
$SEDI "s/public static SettingsMenu.Menu FirstStartMenuOptions .*;//" project/src/Globals.java
|
||||
fi
|
||||
|
||||
echo Patching project/jni/Settings.mk
|
||||
echo '# DO NOT EDIT THIS FILE - it is automatically generated, edit file SettingsTemplate.mk' > project/jni/Settings.mk
|
||||
cat project/jni/SettingsTemplate.mk | \
|
||||
sed "s/APP_MODULES := .*/APP_MODULES := `$UsingSdl2 && echo SDL2 || echo sdl-1.2` sdl_native_helpers jpeg png ogg flac vorbis freetype $CompiledLibraries/" | \
|
||||
sed "s/APP_MODULES := .*/APP_MODULES := sdl-$LibSdlVersion sdl_main sdl_native_helpers jpeg png ogg flac vorbis freetype $CompiledLibraries application/" | \
|
||||
sed "s/APP_ABI := .*/APP_ABI := $MultiABI/" | \
|
||||
sed "s/SDL_JAVA_PACKAGE_PATH := .*/SDL_JAVA_PACKAGE_PATH := $AppFullNameUnderscored/" | \
|
||||
sed "s^SDL_CURDIR_PATH := .*^SDL_CURDIR_PATH := $DataPath^" | \
|
||||
@@ -1081,7 +1013,6 @@ cat project/jni/SettingsTemplate.mk | \
|
||||
sed "s^USE_GL4ES :=.*^USE_GL4ES := $UseGl4es^" | \
|
||||
sed "s^SDL_ADDITIONAL_CFLAGS :=.*^SDL_ADDITIONAL_CFLAGS := \
|
||||
$RedefinedKeycodes \
|
||||
$RedefinedSDLScreenGestures \
|
||||
$RedefinedKeycodesScreenKb \
|
||||
$RedefinedKeycodesGamepad \
|
||||
$CompatibilityHacksPreventAudioChopping \
|
||||
@@ -1142,13 +1073,6 @@ else
|
||||
}
|
||||
fi
|
||||
|
||||
if [ -e "project/jni/application/src/AndroidData/assetpack" ] ; then
|
||||
true # Do nothing...
|
||||
else
|
||||
$SEDI "/==ASSETPACK==/ d" project/app/build.gradle
|
||||
fi
|
||||
|
||||
if [ -e project/jni/application/src/project.diff ]; then patch -p1 --dry-run -f -R < project/jni/application/src/project.diff > /dev/null 2>&1 || patch -p1 --no-backup-if-mismatch < project/jni/application/src/project.diff || exit 1 ; fi
|
||||
if [ -e project/jni/application/src/project.patch ]; then patch -p1 --dry-run -f -R < project/jni/application/src/project.patch > /dev/null 2>&1 || patch -p1 --no-backup-if-mismatch < project/jni/application/src/project.patch || exit 1 ; fi
|
||||
|
||||
rm -f project/lib
|
||||
@@ -1166,9 +1090,6 @@ rm -rf project/obj/local/*/objs*/sdl-*/SDL_renderer_gles.o
|
||||
rm -rf project/obj/local/*/objs*/sdl_*
|
||||
rm -rf project/obj/local/*/objs*/lzma/src/XZInputStream.o
|
||||
rm -rf project/obj/local/*/objs*/liblzma.so
|
||||
rm -rf project/obj/local/*/objs*/openal/src/Alc/android.o
|
||||
rm -rf project/obj/local/*/objs*/libopenal.so
|
||||
# No need to recompile SDL2 libraries, it does not contain package name
|
||||
|
||||
rm -rf project/jni/application/src/AndroidData/lib
|
||||
|
||||
@@ -1203,16 +1124,15 @@ fi
|
||||
echo Compiling prebuilt libraries
|
||||
|
||||
if echo "$CompiledLibraries" | grep -E 'crypto|ssl' > /dev/null; then
|
||||
make -C project/jni -f Makefile.prebuilt openssl ARCH_LIST="$MultiABI"
|
||||
make -C project/jni -f Makefile.prebuilt openssl
|
||||
fi
|
||||
|
||||
if echo "$CompiledLibraries" | grep -E 'iconv|charset|icu' > /dev/null; then
|
||||
echo "#=Compiling prebuilt icu"
|
||||
make -C project/jni -f Makefile.prebuilt icu ARCH_LIST="$MultiABI"
|
||||
if echo "$CompiledLibraries" | grep -E 'iconv|charset|icu|harfbuzz' > /dev/null; then
|
||||
make -C project/jni -f Makefile.prebuilt icu
|
||||
fi
|
||||
|
||||
if echo "$CompiledLibraries" | grep 'boost_' > /dev/null; then
|
||||
make -C project/jni -f Makefile.prebuilt boost ARCH_LIST="$MultiABI"
|
||||
make -C project/jni -f Makefile.prebuilt boost
|
||||
fi
|
||||
|
||||
echo Done
|
||||
|
||||
@@ -3,38 +3,36 @@
|
||||
ARCHES="arm64-v8a armeabi-v7a x86 x86_64"
|
||||
|
||||
if [ "$1" = "pack-binaries" -o "$1" = "pack-binaries-bundle" ]; then
|
||||
[ -e jni/application/src/AndroidData/lib ] || exit 0
|
||||
[ -e jni/application/src/AndroidData/binaries*.zip ] && {
|
||||
echo "Error: binaries.zip no longer supported in Android 10"
|
||||
echo "Copy your executable binaries to AndroidData/lib/arm64-v8a"
|
||||
echo "Then execute them using \$LIBDIR or getenv(\"LIBDIR\")"
|
||||
exit 0
|
||||
}
|
||||
APK="`pwd`/$2"
|
||||
echo "Copying binaries to .apk file"
|
||||
cd jni/application/src/AndroidData/ || exit 1
|
||||
if [ "$1" = "pack-binaries-bundle" ]; then
|
||||
rm -rf base
|
||||
mkdir -p base
|
||||
cp -L -r lib base/
|
||||
zip -r -D "$APK" base || exit 1
|
||||
rm -rf base
|
||||
else
|
||||
zip -r -D "$APK" lib || exit 1
|
||||
fi
|
||||
cd ../../../../
|
||||
[ -e jni/application/src/AndroidData/lib ] || exit 0
|
||||
[ -e jni/application/src/AndroidData/binaries*.zip ] && {
|
||||
echo "Error: binaries.zip no longer supported in Android 10"
|
||||
echo "Copy your executable binaries to AndroidData/lib/arm64-v8a"
|
||||
echo "Then execute them using \$LIBDIR or getenv(\"LIBDIR\")"
|
||||
exit 0
|
||||
}
|
||||
APK="`pwd`/$2"
|
||||
echo "Copying binaries to .apk file"
|
||||
cd jni/application/src/AndroidData/ || exit 1
|
||||
if [ "$1" = "pack-binaries-bundle" ]; then
|
||||
rm -rf base
|
||||
mkdir -p base
|
||||
mv lib base/
|
||||
zip -r "$APK" base || exit 1
|
||||
mv base/lib ./
|
||||
rm -rf base
|
||||
else
|
||||
zip -r "$APK" lib || exit 1
|
||||
fi
|
||||
cd ../../../../
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Copying app data files from project/jni/application/src/AndroidData to project/assets"
|
||||
mkdir -p project/assets
|
||||
rm -f -r project/assets/*
|
||||
if [ -d "project/jni/application/src/AndroidData" ] ; then
|
||||
for F in project/jni/application/src/AndroidData/*; do
|
||||
[ "$F" = "project/jni/application/src/AndroidData/lib" ] && continue
|
||||
[ "$F" = "project/jni/application/src/AndroidData/assetpack" ] && continue
|
||||
cp -L -r "$F" project/assets/
|
||||
done
|
||||
cp -L -r project/jni/application/src/AndroidData/* project/assets/
|
||||
rm -rf project/assets/lib
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -14,14 +14,12 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
>
|
||||
<activity android:name="MainActivity"
|
||||
<activity android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:alwaysRetainTaskState="true"
|
||||
android:launchMode="singleTask"
|
||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection"
|
||||
android:windowSoftInputMode="stateUnspecified"
|
||||
android:theme="@style/AppTheme"
|
||||
android:exported="true"
|
||||
>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
@@ -45,19 +43,18 @@
|
||||
<!-- ==OPENFILE== --> </intent-filter>
|
||||
</activity>
|
||||
<!-- ==ADMOB== --> <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection"/>
|
||||
<!-- ==ADMOB== --> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
|
||||
<!-- ==ADMOB== --> <meta-data android:name="com.google.android.gms.version" android:value="4323000" /> <!-- Change this value to the actual Google Play SDK version -->
|
||||
<!-- ==GOOGLEPLAYGAMESERVICES== --> <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/google_play_game_services_app_id" />
|
||||
<!-- ==GOOGLEPLAYGAMESERVICES== --> <meta-data android:name="com.google.android.gms.appstate.APP_ID" android:value="@string/google_play_game_services_app_id" />
|
||||
<!-- ==GOOGLEPLAYGAMESERVICES== --> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
|
||||
<meta-data android:name="com.sec.android.support.multiwindow" android:value="true" /> <!-- Samsung's multiwindow -->
|
||||
<activity android:name="RestartMainActivity"
|
||||
<activity android:name=".RestartMainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:alwaysRetainTaskState="true"
|
||||
android:launchMode="singleTask"
|
||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection"
|
||||
android:windowSoftInputMode="stateUnspecified"
|
||||
android:process=":RestartMainActivity"
|
||||
android:exported="true"
|
||||
/>
|
||||
<service android:name=".DummyService"
|
||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection"
|
||||
@@ -71,7 +68,7 @@
|
||||
<!-- ==NOT_EXTERNAL_STORAGE== --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
|
||||
<!-- ==NOT_EXTERNAL_STORAGE== --> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="18" /> <!-- App has write access to it's own dir on SD card without this permission on Android 4.4 and above -->
|
||||
<!-- ==READ_OBB== --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
|
||||
<!-- ==READ_OBB== --> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <!-- OBB file requires explicit permission before Marshmallow -->
|
||||
<!-- ==READ_OBB== --> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="23" /> <!-- OBB file requires explicit permission before Marshmallow -->
|
||||
<!-- ==RECORD_AUDIO== --> <uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<!-- ==ADMOB== --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<!-- ==FOREGROUND_SERVICE== --> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
|
||||
@@ -1,38 +1,26 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
}
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdk 31
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "30.0.0"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "net.olofson.ballfield"
|
||||
minSdk 16
|
||||
targetSdk 31
|
||||
minSdkVersion 16 // Must match version numbers in project/AndroidManifestTemplate.xml
|
||||
targetSdkVersion 29
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled true
|
||||
shrinkResources true
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), '../proguard-local.cfg', '../proguard.cfg'
|
||||
}
|
||||
releaseWithDebugInfo {
|
||||
initWith release
|
||||
ndk {
|
||||
debugSymbolLevel 'FULL'
|
||||
}
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
assetPacks = [":assetpack"] // ==ASSETPACK==
|
||||
dependencies { compile 'com.google.android.gms:play-services-games:19.0.0' } // ==GOOGLEPLAYGAMESERVICES==
|
||||
dependencies { compile 'com.google.android.gms:play-services-drive:17.0.0' } // ==GOOGLEPLAYGAMESERVICES==
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.3.1'
|
||||
implementation 'com.google.android.gms:play-services-games:21.0.0' // ==GOOGLEPLAYGAMESERVICES==
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
apply plugin: 'com.android.asset-pack'
|
||||
|
||||
assetPack {
|
||||
packName = "assetpack"
|
||||
dynamicDelivery {
|
||||
deliveryType = "install-time"
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
../../../jni/application/src/AndroidData/assetpack
|
||||
@@ -1,17 +1,25 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:7.0.3"
|
||||
classpath "com.android.tools.build:gradle:4.0.0"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||
org.gradle.jvmargs=-Xmx2048m
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
|
||||
BIN
project/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
project/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
#Sat Nov 27 22:44:43 EET 2021
|
||||
#Tue Jul 07 20:59:38 EEST 2020
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
|
||||
|
||||
53
project/gradlew
vendored
53
project/gradlew
vendored
@@ -1,21 +1,5 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
@@ -44,7 +28,7 @@ APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
@@ -82,7 +66,6 @@ esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
@@ -126,11 +109,10 @@ if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
@@ -156,19 +138,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
@@ -177,9 +159,14 @@ save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
||||
43
project/gradlew.bat
vendored
43
project/gradlew.bat
vendored
@@ -1,19 +1,3 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@@ -29,18 +13,15 @@ if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@@ -54,7 +35,7 @@ goto fail
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
@@ -64,14 +45,28 @@ echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
@@ -53,16 +53,10 @@ import java.util.Arrays;
|
||||
import android.text.SpannedString;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
import android.os.storage.StorageManager;
|
||||
import android.os.storage.OnObbStateChangeListener;
|
||||
import android.content.res.AssetManager;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
|
||||
class CountingInputStream extends BufferedInputStream
|
||||
{
|
||||
@@ -177,6 +171,7 @@ class DataDownloader extends Thread
|
||||
{
|
||||
Parent = _Parent;
|
||||
Status = new StatusWriter( _Status, _Parent );
|
||||
//Status.setText( "Connecting to " + Globals.DataDownloadUrl );
|
||||
outFilesDir = Globals.DataDir;
|
||||
DownloadComplete = false;
|
||||
this.start();
|
||||
@@ -192,6 +187,8 @@ class DataDownloader extends Thread
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Parent.getVideoLayout().setOnKeyListener(new BackKeyListener(Parent));
|
||||
|
||||
String [] downloadFiles = Globals.DataDownloadUrl;
|
||||
int total = 0;
|
||||
int count = 0;
|
||||
@@ -214,16 +211,7 @@ class DataDownloader extends Thread
|
||||
downloadFiles[i].contains("<ARCH>") &&
|
||||
! DownloadDataFile(downloadFiles[i].replace("<ARCH>", android.os.Build.CPU_ABI2), DOWNLOAD_FLAG_FILENAME + String.valueOf(i) + ".flag", count+1, total, i) ) )
|
||||
{
|
||||
if (!Parent.getFilesDir().getAbsolutePath().equals(Globals.DataDir))
|
||||
{
|
||||
Globals.DataDir = Parent.getFilesDir().getAbsolutePath();
|
||||
Globals.DownloadToSdcard = false;
|
||||
Log.i("SDL", "Switching download destination directory to internal storage and restarting the app: " + Globals.DataDir);
|
||||
Settings.Save(Parent);
|
||||
Intent intent = new Intent(Parent, RestartMainActivity.class);
|
||||
Parent.startActivity(intent);
|
||||
System.exit(0);
|
||||
}
|
||||
DownloadFailed = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -231,6 +219,7 @@ class DataDownloader extends Thread
|
||||
}
|
||||
}
|
||||
DownloadComplete = true;
|
||||
Parent.getVideoLayout().setOnKeyListener(null);
|
||||
initParent();
|
||||
}
|
||||
|
||||
@@ -274,6 +263,20 @@ class DataDownloader extends Thread
|
||||
if( ! matched )
|
||||
throw new IOException();
|
||||
Status.setText( res.getString(R.string.download_unneeded) );
|
||||
for( int i = 1; i < downloadUrls.length; i++ )
|
||||
{
|
||||
if( downloadUrls[i].indexOf("obb:") == 0 ) // APK expansion file provided by Google Play
|
||||
{
|
||||
String url = getObbFilePath(downloadUrls[i]);
|
||||
if (new File(url).length() > 256)
|
||||
{
|
||||
Writer writer = new OutputStreamWriter(new FileOutputStream(url), "UTF-8");
|
||||
writer.write("Extracted and truncated\n");
|
||||
writer.close();
|
||||
Log.i("SDL", "Truncated file from expansion: " + url);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch ( IOException e ) {
|
||||
forceOverwrite = true;
|
||||
@@ -303,9 +306,6 @@ class DataDownloader extends Thread
|
||||
boolean DoNotUnzip = false;
|
||||
boolean FileInAssets = false;
|
||||
boolean FileInExpansion = false;
|
||||
boolean MountObb = false;
|
||||
final boolean[] ObbMounted = new boolean[] { false };
|
||||
final boolean[] ObbMountedError = new boolean[] { false };
|
||||
String url = "";
|
||||
|
||||
int downloadUrlIndex = 1;
|
||||
@@ -331,61 +331,31 @@ class DataDownloader extends Thread
|
||||
partialDownloadLen = partialDownload.length();
|
||||
}
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.connecting_to, url) );
|
||||
if( url.equals("assetpack") )
|
||||
if( url.indexOf("obb:") == 0 ) // APK expansion file provided by Google Play
|
||||
{
|
||||
if( Parent.assetPackPath != null )
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M)
|
||||
{
|
||||
Log.i("SDL", "Found asset pack: " + Parent.assetPackPath);
|
||||
return true;
|
||||
}
|
||||
Log.i("SDL", "Asset pack is not installed");
|
||||
downloadUrlIndex++;
|
||||
continue;
|
||||
}
|
||||
else if( url.indexOf("obb:") == 0 || url.indexOf("mnt:") == 0 ) // APK expansion file provided by Google Play
|
||||
{
|
||||
boolean tmpMountObb = ( url.indexOf("mnt:") == 0 );
|
||||
url = getObbFilePath(url);
|
||||
InputStream stream1 = null;
|
||||
|
||||
try {
|
||||
stream1 = new FileInputStream(url);
|
||||
stream1.read();
|
||||
stream1.close();
|
||||
Log.i("SDL", "Fetching file from expansion: " + url);
|
||||
FileInExpansion = true;
|
||||
MountObb = tmpMountObb;
|
||||
break;
|
||||
} catch( IOException ee ) {
|
||||
Log.i("SDL", "Failed to open file, requesting storage read permission: " + url);
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M)
|
||||
int permissionCheck = Parent.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
if (permissionCheck != PackageManager.PERMISSION_GRANTED && !Parent.writeExternalStoragePermissionDialogAnswered)
|
||||
{
|
||||
int permissionCheck = Parent.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE);
|
||||
if (permissionCheck != PackageManager.PERMISSION_GRANTED && !Parent.readExternalStoragePermissionDialogAnswered)
|
||||
Parent.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
|
||||
while( !Parent.writeExternalStoragePermissionDialogAnswered )
|
||||
{
|
||||
Parent.requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 0);
|
||||
while( !Parent.readExternalStoragePermissionDialogAnswered )
|
||||
{
|
||||
try{ Thread.sleep(300); } catch (InterruptedException e) {}
|
||||
}
|
||||
try{ Thread.sleep(300); } catch (InterruptedException e) {}
|
||||
}
|
||||
}
|
||||
} catch( Exception eee ) {
|
||||
Log.i("SDL", "Failed to open file: " + url);
|
||||
downloadUrlIndex++;
|
||||
continue;
|
||||
}
|
||||
|
||||
url = getObbFilePath(url);
|
||||
InputStream stream1 = null;
|
||||
try {
|
||||
stream1 = new FileInputStream(url);
|
||||
stream1.read();
|
||||
stream1.close();
|
||||
Log.i("SDL", "Fetching file from expansion: " + url);
|
||||
FileInExpansion = true;
|
||||
MountObb = tmpMountObb;
|
||||
break;
|
||||
} catch( Exception eee ) {
|
||||
} catch( Exception e ) {
|
||||
Log.i("SDL", "Failed to open file: " + url);
|
||||
downloadUrlIndex++;
|
||||
continue;
|
||||
@@ -454,51 +424,6 @@ class DataDownloader extends Thread
|
||||
}
|
||||
}
|
||||
|
||||
if( MountObb )
|
||||
{
|
||||
Log.i("SDL", "Mounting OBB file: " + url);
|
||||
StorageManager sm = (StorageManager) Parent.getSystemService(Context.STORAGE_SERVICE);
|
||||
if( !sm.mountObb(url, null, new OnObbStateChangeListener()
|
||||
{
|
||||
public void onObbStateChange(String path, int state)
|
||||
{
|
||||
if (state == OnObbStateChangeListener.MOUNTED ||
|
||||
state == OnObbStateChangeListener.ERROR_ALREADY_MOUNTED)
|
||||
{
|
||||
ObbMounted[0] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ObbMountedError[0] = true;
|
||||
}
|
||||
}
|
||||
}) )
|
||||
{
|
||||
Log.i("SDL", "Cannot mount OBB file '" + url + "'");
|
||||
Status.setText( res.getString(R.string.error_dl_from, url) );
|
||||
return false;
|
||||
}
|
||||
while( !ObbMounted[0] )
|
||||
{
|
||||
try{ Thread.sleep(300); } catch (InterruptedException e) {}
|
||||
if( ObbMountedError[0] )
|
||||
{
|
||||
Log.i("SDL", "Cannot mount OBB file '" + url + "'");
|
||||
Status.setText( res.getString(R.string.error_dl_from, url) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Parent.ObbMountPath = sm.getMountedObbPath(url);
|
||||
if( Parent.ObbMountPath == null )
|
||||
{
|
||||
Log.i("SDL", "Cannot mount OBB file '" + url + "'");
|
||||
Status.setText( res.getString(R.string.error_dl_from, url) );
|
||||
return false;
|
||||
}
|
||||
Log.i("SDL", "Mounted OBB file '" + url + "' to path " + Parent.ObbMountPath);
|
||||
return true;
|
||||
}
|
||||
|
||||
if( FileInExpansion )
|
||||
{
|
||||
Log.i("SDL", "Count file size: '" + url);
|
||||
@@ -590,7 +515,15 @@ class DataDownloader extends Thread
|
||||
|
||||
try {
|
||||
stream.close();
|
||||
if( FileInExpansion )
|
||||
{
|
||||
Writer writer = new OutputStreamWriter(new FileOutputStream(url), "UTF-8");
|
||||
writer.write("Extracted and truncated\n");
|
||||
writer.close();
|
||||
Log.i("SDL", "Truncated file from expansion: " + url);
|
||||
}
|
||||
} catch( java.io.IOException e ) {
|
||||
Log.i("SDL", "Error truncating file from expansion: " + url);
|
||||
};
|
||||
|
||||
return true;
|
||||
@@ -850,7 +783,7 @@ class DataDownloader extends Thread
|
||||
public MainActivity Parent;
|
||||
public void run()
|
||||
{
|
||||
Parent.downloadFinishedInitSDL();
|
||||
Parent.initSDL();
|
||||
}
|
||||
}
|
||||
Callback cb = new Callback();
|
||||
@@ -868,13 +801,59 @@ class DataDownloader extends Thread
|
||||
|
||||
private String getObbFilePath(final String url)
|
||||
{
|
||||
// "obb:" or "mnt:" - same length
|
||||
return Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/obb/" +
|
||||
Parent.getPackageName() + "/" + url.substring("obb:".length()) + "." + Parent.getPackageName() + ".obb";
|
||||
}
|
||||
|
||||
public class BackKeyListener implements View.OnKeyListener
|
||||
{
|
||||
MainActivity p;
|
||||
public BackKeyListener(MainActivity _p)
|
||||
{
|
||||
p = _p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event)
|
||||
{
|
||||
if( DownloadFailed )
|
||||
System.exit(1);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.cancel_download));
|
||||
builder.setMessage(p.getResources().getString(R.string.cancel_download) + (DownloadCanBeResumed ? " " + p.getResources().getString(R.string.cancel_download_resume) : ""));
|
||||
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.yes), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
System.exit(1);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(p.getResources().getString(R.string.no), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public StatusWriter Status;
|
||||
public boolean DownloadComplete = false;
|
||||
public boolean DownloadFailed = false;
|
||||
public boolean DownloadCanBeResumed = false;
|
||||
private MainActivity Parent;
|
||||
private String outFilesDir = null;
|
||||
|
||||
@@ -40,7 +40,6 @@ import android.util.Log;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
import android.app.KeyguardManager;
|
||||
import android.graphics.Rect;
|
||||
|
||||
/**
|
||||
* An implementation of SurfaceView that uses the dedicated surface for
|
||||
|
||||
@@ -39,7 +39,8 @@ class Globals
|
||||
{ "expat", "expat-sdl" },
|
||||
{ "sqlite3", "sqlite3-sdl" },
|
||||
}; // Because some libraries are named differently to not clash with system libs
|
||||
public static final boolean UsingSDL2 = false;
|
||||
public static final boolean Using_SDL_1_3 = false;
|
||||
public static final boolean Using_SDL_2_0 = false;
|
||||
public static String[] DataDownloadUrl = { "Data files are 2 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-data.zip/download", "High-quality GFX and music - 40 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-hqp.zip/download" };
|
||||
public static boolean SwVideoMode = false;
|
||||
public static boolean NeedDepthBuffer = false;
|
||||
@@ -90,7 +91,6 @@ class Globals
|
||||
public static boolean HorizontalOrientation = true;
|
||||
public static boolean AutoDetectOrientation = false;
|
||||
public static boolean ImmersiveMode = true;
|
||||
public static boolean DrawInDisplayCutout = false;
|
||||
public static boolean HideSystemMousePointer = false;
|
||||
public static boolean DownloadToSdcard = true;
|
||||
public static boolean PhoneHasArrowKeys = false;
|
||||
@@ -131,66 +131,12 @@ class Globals
|
||||
public static boolean KeepAspectRatio = KeepAspectRatioDefaultSetting;
|
||||
public static boolean TvBorders = true;
|
||||
public static int RemapHwKeycode[] = new int[SDL_Keys.JAVA_KEYCODE_LAST];
|
||||
public static int RemapScreenKbKeycode[] = new int[12];
|
||||
// Values for 800x480 resolution
|
||||
public static int ScreenKbControlsLayout[][] =
|
||||
AppUsesThirdJoystick ? new int[][]
|
||||
{
|
||||
{ 0, 303, 177, 480 }, // Main joystick/DPAD
|
||||
{ 0, 0, 48, 48 }, // Text input button
|
||||
{ 400, 392, 488, 480 }, // Button 0
|
||||
{ 312, 392, 400, 480 }, // Button 1
|
||||
{ 400, 304, 488, 392 }, // Button 2
|
||||
{ 312, 304, 400, 392 }, // Button 3
|
||||
{ 400, 216, 488, 304 }, // Button 4
|
||||
{ 312, 216, 400, 304 }, // Button 5
|
||||
{ 623, 303, 800, 480 }, // Joystick 2
|
||||
{ 623, 126, 800, 303 }, // Joystick 3
|
||||
{ 400, 392, 488, 480 }, // Button 6 - copy of button 0, to be redefined in the code
|
||||
{ 312, 392, 400, 480 }, // Button 7 - copy of button 1, to be redefined in the code
|
||||
{ 400, 304, 488, 392 }, // Button 8 - copy of button 2, to be redefined in the code
|
||||
{ 312, 304, 400, 392 }, // Button 9 - copy of button 3, to be redefined in the code
|
||||
{ 400, 216, 488, 304 }, // Button 10 - copy of button 4, to be redefined in the code
|
||||
{ 312, 216, 400, 304 }, // Button 11 - copy of button 5, to be redefined in the code
|
||||
}
|
||||
: AppUsesSecondJoystick ? new int[][]
|
||||
{
|
||||
{ 0, 303, 177, 480 }, // Main joystick/DPAD
|
||||
{ 0, 0, 48, 48 }, // Text input button
|
||||
{ 400, 392, 488, 480 }, // Button 0
|
||||
{ 312, 392, 400, 480 }, // Button 1
|
||||
{ 400, 304, 488, 392 }, // Button 2
|
||||
{ 312, 304, 400, 392 }, // Button 3
|
||||
{ 400, 216, 488, 304 }, // Button 4
|
||||
{ 312, 216, 400, 304 }, // Button 5
|
||||
{ 623, 303, 800, 480 }, // Joystick 2
|
||||
{ 0, 0, 0, 0, }, // Joystick 3
|
||||
{ 400, 392, 488, 480 }, // Button 6 - copy of button 0, to be redefined in the code
|
||||
{ 312, 392, 400, 480 }, // Button 7 - copy of button 1, to be redefined in the code
|
||||
{ 400, 304, 488, 392 }, // Button 8 - copy of button 2, to be redefined in the code
|
||||
{ 312, 304, 400, 392 }, // Button 9 - copy of button 3, to be redefined in the code
|
||||
{ 400, 216, 488, 304 }, // Button 10 - copy of button 4, to be redefined in the code
|
||||
{ 312, 216, 400, 304 }, // Button 11 - copy of button 5, to be redefined in the code
|
||||
}
|
||||
: new int[][]
|
||||
{
|
||||
{ 0, 303, 177, 480 }, // Main joystick/DPAD
|
||||
{ 0, 0, 48, 48 }, // Text input button
|
||||
{ 712, 392, 800, 480 }, // Button 0
|
||||
{ 624, 392, 712, 480 }, // Button 1
|
||||
{ 712, 304, 800, 392 }, // Button 2
|
||||
{ 624, 304, 712, 392 }, // Button 3
|
||||
{ 712, 216, 800, 304 }, // Button 4
|
||||
{ 624, 216, 712, 304 }, // Button 5
|
||||
{ 0, 0, 0, 0, }, // Joystick 2
|
||||
{ 0, 0, 0, 0, }, // Joystick 3
|
||||
{ 536, 392, 624, 480 }, // Button 6
|
||||
{ 448, 392, 536, 480 }, // Button 7
|
||||
{ 536, 304, 624, 392 }, // Button 8
|
||||
{ 448, 304, 536, 392 }, // Button 9
|
||||
{ 536, 216, 624, 304 }, // Button 10
|
||||
{ 448, 216, 536, 304 }, // Button 11
|
||||
};
|
||||
public static int RemapScreenKbKeycode[] = new int[6];
|
||||
public static int ScreenKbControlsLayout[][] = AppUsesThirdJoystick ? // Values for 800x480 resolution
|
||||
new int[][] { { 0, 303, 177, 480 }, { 0, 0, 48, 48 }, { 400, 392, 488, 480 }, { 312, 392, 400, 480 }, { 400, 304, 488, 392 }, { 312, 304, 400, 392 }, { 400, 216, 488, 304 }, { 312, 216, 400, 304 }, { 623, 303, 800, 480 }, { 623, 126, 800, 303 } } :
|
||||
AppUsesSecondJoystick ?
|
||||
new int[][] { { 0, 303, 177, 480 }, { 0, 0, 48, 48 }, { 400, 392, 488, 480 }, { 312, 392, 400, 480 }, { 400, 304, 488, 392 }, { 312, 304, 400, 392 }, { 400, 216, 488, 304 }, { 312, 216, 400, 304 }, { 623, 303, 800, 480 } } :
|
||||
new int[][] { { 0, 303, 177, 480 }, { 0, 0, 48, 48 }, { 712, 392, 800, 480 }, { 624, 392, 712, 480 }, { 712, 304, 800, 392 }, { 624, 304, 712, 392 }, { 712, 216, 800, 304 }, { 624, 216, 712, 304 } };
|
||||
public static boolean ScreenKbControlsShown[] = new boolean[ScreenKbControlsLayout.length]; /* Also joystick and text input button added */
|
||||
public static int RemapMultitouchGestureKeycode[] = new int[4];
|
||||
public static boolean MultitouchGesturesUsed[] = new boolean[4];
|
||||
|
||||
@@ -278,7 +278,7 @@ class SDL_1_2_Keycodes
|
||||
|
||||
// Autogenerated by hand with a command:
|
||||
// grep 'SDL_SCANCODE_' SDL_scancode.h | sed 's/SDL_SCANCODE_\([a-zA-Z0-9_]\+\).*[=] \([0-9]\+\).*/public static final int SDLK_\1 = \2;/' >> Keycodes.java
|
||||
class SDL_2_Keycodes
|
||||
class SDL_1_3_Keycodes
|
||||
{
|
||||
public static final int SDLK_UNKNOWN = 0;
|
||||
public static final int SDLK_A = 4;
|
||||
@@ -519,10 +519,6 @@ class SDL_2_Keycodes
|
||||
public static final int SDLK_KBDILLUMUP = 280;
|
||||
public static final int SDLK_EJECT = 281;
|
||||
public static final int SDLK_SLEEP = 282;
|
||||
public static final int SDLK_APP1 = 283;
|
||||
public static final int SDLK_APP2 = 284;
|
||||
public static final int SDLK_AUDIOREWIND = 285;
|
||||
public static final int SDLK_AUDIOFASTFORWARD = 286;
|
||||
|
||||
// Mouse buttons can be mapped to on-screen keys
|
||||
public static final int SDLK_MOUSE_LEFT = 500;
|
||||
@@ -562,9 +558,9 @@ class SDL_Keys
|
||||
ArrayList<String> Names = new ArrayList<String> ();
|
||||
ArrayList<Integer> Values = new ArrayList<Integer> ();
|
||||
Field [] fields = SDL_1_2_Keycodes.class.getDeclaredFields();
|
||||
if( Globals.UsingSDL2 )
|
||||
if( Globals.Using_SDL_1_3 )
|
||||
{
|
||||
fields = SDL_2_Keycodes.class.getDeclaredFields();
|
||||
fields = SDL_1_3_Keycodes.class.getDeclaredFields();
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -43,7 +43,6 @@ import android.widget.RelativeLayout;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.Color;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
@@ -118,10 +117,6 @@ public class MainActivity extends Activity
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
|
||||
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
// We need to load Globals.DrawInDisplayCutout option to correctly set fullscreen mode, it can only be done from onCreate()
|
||||
Settings.LoadConfig(this);
|
||||
DimSystemStatusBar.dim(null, getWindow());
|
||||
|
||||
Log.i("SDL", "libSDL: Creating startup screen");
|
||||
_layout = new LinearLayout(this);
|
||||
_layout.setOrientation(LinearLayout.VERTICAL);
|
||||
@@ -187,32 +182,6 @@ public class MainActivity extends Activity
|
||||
_videoLayout.setFocusable(true);
|
||||
_videoLayout.setFocusableInTouchMode(true);
|
||||
_videoLayout.requestFocus();
|
||||
DimSystemStatusBar.dim(_videoLayout, getWindow());
|
||||
|
||||
//Log.i("SDL", "Checking for asset pack");
|
||||
try
|
||||
{
|
||||
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP )
|
||||
{
|
||||
ApplicationInfo info = this.getPackageManager().getApplicationInfo(this.getPackageName(), 0);
|
||||
if( info.splitSourceDirs != null )
|
||||
{
|
||||
for( String apk: info.splitSourceDirs )
|
||||
{
|
||||
Log.i("SDL", "Package apk: " + apk);
|
||||
if( apk.endsWith("assetpack.apk") )
|
||||
{
|
||||
this.assetPackPath = apk;
|
||||
Log.i("SDL", "Found asset pack: " + this.assetPackPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( Exception eee )
|
||||
{
|
||||
Log.i("SDL", "Asset pack exception: " + eee);
|
||||
}
|
||||
|
||||
class Callback implements Runnable
|
||||
{
|
||||
@@ -236,9 +205,8 @@ public class MainActivity extends Activity
|
||||
public MainActivity Parent;
|
||||
public void run()
|
||||
{
|
||||
Settings.ProcessConfig(Parent);
|
||||
Settings.Load(Parent);
|
||||
setScreenOrientation();
|
||||
DimSystemStatusBar.dim(_videoLayout, getWindow());
|
||||
loaded.release();
|
||||
loadedLibraries.release();
|
||||
if( _btn != null )
|
||||
@@ -346,11 +314,11 @@ public class MainActivity extends Activity
|
||||
this.runOnUiThread(cb);
|
||||
}
|
||||
|
||||
public void downloadFinishedInitSDL()
|
||||
public void initSDL()
|
||||
{
|
||||
setScreenOrientation();
|
||||
updateScreenOrientation();
|
||||
DimSystemStatusBar.dim(_videoLayout, getWindow());
|
||||
DimSystemStatusBar.get().dim(_videoLayout);
|
||||
(new Thread(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
@@ -369,7 +337,7 @@ public class MainActivity extends Activity
|
||||
Log.i("SDL", "libSDL: Application paused, cancelling SDL initialization until it will be brought to foreground");
|
||||
return;
|
||||
}
|
||||
DimSystemStatusBar.dim(_videoLayout, getWindow());
|
||||
DimSystemStatusBar.get().dim(_videoLayout);
|
||||
}
|
||||
runOnUiThread(new Runnable()
|
||||
{
|
||||
@@ -383,7 +351,7 @@ public class MainActivity extends Activity
|
||||
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT && Globals.ImmersiveMode &&
|
||||
(_videoLayout.getHeight() != dm.widthPixels || _videoLayout.getWidth() != dm.heightPixels) )
|
||||
{
|
||||
DimSystemStatusBar.dim(_videoLayout, getWindow());
|
||||
DimSystemStatusBar.get().dim(_videoLayout);
|
||||
try {
|
||||
Thread.sleep(300);
|
||||
} catch( Exception e ) {}
|
||||
@@ -402,7 +370,7 @@ public class MainActivity extends Activity
|
||||
Log.i("SDL", "libSDL: Initializing video and SDL application");
|
||||
|
||||
sdlInited = true;
|
||||
DimSystemStatusBar.dim(_videoLayout, getWindow());
|
||||
DimSystemStatusBar.get().dim(_videoLayout);
|
||||
_videoLayout.removeView(_layout);
|
||||
if( _ad.getView() != null )
|
||||
_videoLayout.removeView(_ad.getView());
|
||||
@@ -497,8 +465,8 @@ public class MainActivity extends Activity
|
||||
_videoLayout.addView(_ad.getView());
|
||||
_ad.getView().setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.TOP | Gravity.RIGHT));
|
||||
}
|
||||
DimSystemStatusBar.dim(_videoLayout, getWindow());
|
||||
//DimSystemStatusBar.dim(mGLView, getWindow());
|
||||
DimSystemStatusBar.get().dim(_videoLayout);
|
||||
//DimSystemStatusBar.get().dim(mGLView);
|
||||
|
||||
Rect r = new Rect();
|
||||
_videoLayout.getWindowVisibleDisplayFrame(r);
|
||||
@@ -508,40 +476,15 @@ public class MainActivity extends Activity
|
||||
public void onGlobalLayout()
|
||||
{
|
||||
final Rect r = new Rect();
|
||||
//_videoLayout.getWindowVisibleDisplayFrame(r);
|
||||
final int xy[] = new int[] { 0, 0 };
|
||||
_videoLayout.getLocationInWindow(xy);
|
||||
r.left = xy[0];
|
||||
r.top = xy[1];
|
||||
r.right = r.left + _videoLayout.getWidth();
|
||||
r.bottom = r.top + _videoLayout.getHeight();
|
||||
//boolean cutoutLeft = false, cutoutTop = false;
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P && Globals.ImmersiveMode)
|
||||
{
|
||||
if (getWindow().getDecorView() != null && getWindow().getDecorView().getRootWindowInsets() != null &&
|
||||
getWindow().getDecorView().getRootWindowInsets().getDisplayCutout() != null)
|
||||
{
|
||||
android.view.DisplayCutout cutout = getWindow().getDecorView().getRootWindowInsets().getDisplayCutout();
|
||||
Log.v("SDL", "Detected display cutout");
|
||||
// TODO: do something with it
|
||||
//if (cutout.getBoundingRectLeft().width() > 0)
|
||||
// cutoutLeft = true;
|
||||
//if (cutout.getBoundingRectTop().height() > 0)
|
||||
// cutoutTop = true;
|
||||
}
|
||||
}
|
||||
_videoLayout.getWindowVisibleDisplayFrame(r);
|
||||
final int heightDiff = _videoLayout.getRootView().getHeight() - _videoLayout.getHeight(); // Take system bar into consideration
|
||||
final int widthDiff = _videoLayout.getRootView().getWidth() - _videoLayout.getWidth(); // Nexus 5 has system bar at the right side
|
||||
Log.v("SDL", "Main window visible region changed: " + r.left + ":" + r.top + ":" + r.width() + ":" + r.height() + " -> " +
|
||||
(r.left + widthDiff) + ":" + (r.top + heightDiff) + ":" + r.width() + ":" + r.height());
|
||||
Log.v("SDL", "videoLayout: " + _videoLayout.getLeft() + ":" + _videoLayout.getTop() + ":" + _videoLayout.getWidth() + ":" + _videoLayout.getHeight() +
|
||||
" videoLayout.getRootView() " + _videoLayout.getRootView().getLeft() + ":" + _videoLayout.getRootView().getTop() + ":" +
|
||||
_videoLayout.getRootView().getWidth() + ":" + _videoLayout.getRootView().getHeight());
|
||||
Log.v("SDL", "Main window visible region changed: " + r.left + ":" + r.top + ":" + r.width() + ":" + r.height() );
|
||||
_videoLayout.postDelayed( new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
DimSystemStatusBar.dim(_videoLayout, getWindow());
|
||||
DimSystemStatusBar.get().dim(_videoLayout);
|
||||
mGLView.nativeScreenVisibleRect(r.left + widthDiff, r.top + heightDiff, r.width(), r.height());
|
||||
}
|
||||
}, 300 );
|
||||
@@ -549,7 +492,7 @@ public class MainActivity extends Activity
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
DimSystemStatusBar.dim(_videoLayout, getWindow());
|
||||
DimSystemStatusBar.get().dim(_videoLayout);
|
||||
mGLView.nativeScreenVisibleRect(r.left + widthDiff, r.top + heightDiff, r.width(), r.height());
|
||||
}
|
||||
}, 600 );
|
||||
@@ -579,8 +522,8 @@ public class MainActivity extends Activity
|
||||
super.onResume();
|
||||
if( mGLView != null )
|
||||
{
|
||||
DimSystemStatusBar.dim(_videoLayout, getWindow());
|
||||
//DimSystemStatusBar.dim(mGLView, getWindow());
|
||||
DimSystemStatusBar.get().dim(_videoLayout);
|
||||
//DimSystemStatusBar.get().dim(mGLView);
|
||||
mGLView.onResume();
|
||||
}
|
||||
else
|
||||
@@ -591,7 +534,7 @@ public class MainActivity extends Activity
|
||||
downloader.setStatusField(_tv);
|
||||
if( downloader.DownloadComplete )
|
||||
{
|
||||
downloadFinishedInitSDL();
|
||||
initSDL();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -857,8 +800,8 @@ public class MainActivity extends Activity
|
||||
}
|
||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||
_inputManager.hideSoftInputFromWindow(mGLView.getWindowToken(), 0);
|
||||
DimSystemStatusBar.dim(_videoLayout, getWindow());
|
||||
//DimSystemStatusBar.dim(mGLView, getWindow());
|
||||
DimSystemStatusBar.get().dim(_videoLayout);
|
||||
//DimSystemStatusBar.get().dim(mGLView);
|
||||
mGLView.captureMouse(true);
|
||||
}
|
||||
});
|
||||
@@ -995,13 +938,13 @@ public class MainActivity extends Activity
|
||||
_videoLayout.removeView(_screenKeyboard);
|
||||
_screenKeyboard = null;
|
||||
mGLView.captureMouse(true);
|
||||
DimSystemStatusBar.dim(_videoLayout, getWindow());
|
||||
DimSystemStatusBar.get().dim(_videoLayout);
|
||||
|
||||
_videoLayout.postDelayed( new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
DimSystemStatusBar.dim(_videoLayout, getWindow());
|
||||
DimSystemStatusBar.get().dim(_videoLayout);
|
||||
}
|
||||
}, 500 );
|
||||
};
|
||||
@@ -1300,11 +1243,6 @@ public class MainActivity extends Activity
|
||||
if( entry.isDirectory() )
|
||||
{
|
||||
File outDir = new File( libDir.getAbsolutePath() + "/" + entry.getName() );
|
||||
if( !outDir.getCanonicalPath().startsWith(libDir.getAbsolutePath() + "/") )
|
||||
{
|
||||
Log.i("SDL", "Security exception: " + outDir.getCanonicalPath());
|
||||
return;
|
||||
}
|
||||
if( !(outDir.exists() && outDir.isDirectory()) )
|
||||
outDir.mkdirs();
|
||||
continue;
|
||||
@@ -1315,11 +1253,6 @@ public class MainActivity extends Activity
|
||||
try
|
||||
{
|
||||
File outDir = new File( path.substring(0, path.lastIndexOf("/") ));
|
||||
if( !outDir.getCanonicalPath().startsWith(libDir.getAbsolutePath() + "/") )
|
||||
{
|
||||
Log.i("SDL", "Security exception: " + outDir.getCanonicalPath());
|
||||
return;
|
||||
}
|
||||
if( !(outDir.exists() && outDir.isDirectory()) )
|
||||
outDir.mkdirs();
|
||||
}
|
||||
@@ -1341,11 +1274,6 @@ public class MainActivity extends Activity
|
||||
} catch( Exception eeeeee ) { }
|
||||
|
||||
Log.i("SDL", "Saving to file '" + path + "'");
|
||||
if( !(new File(path).getCanonicalPath().startsWith(libDir.getAbsolutePath() + "/")) )
|
||||
{
|
||||
Log.i("SDL", "Security exception: " + path);
|
||||
return;
|
||||
}
|
||||
|
||||
out = new FileOutputStream( path );
|
||||
int len = zip.read(buf);
|
||||
@@ -1492,11 +1420,6 @@ public class MainActivity extends Activity
|
||||
{
|
||||
Log.i("SDL", "libSDL: Record audio permission: " + (grantResults[0] == PackageManager.PERMISSION_GRANTED ? "GRANTED" : "DENIED"));
|
||||
}
|
||||
if (Manifest.permission.READ_EXTERNAL_STORAGE.equals(permissions[0]))
|
||||
{
|
||||
Log.i("SDL", "libSDL: Read external storage permission: " + (grantResults[0] == PackageManager.PERMISSION_GRANTED ? "GRANTED" : "DENIED"));
|
||||
readExternalStoragePermissionDialogAnswered = true;
|
||||
}
|
||||
if (Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0]))
|
||||
{
|
||||
Log.i("SDL", "libSDL: Write external storage permission: " + (grantResults[0] == PackageManager.PERMISSION_GRANTED ? "GRANTED" : "DENIED"));
|
||||
@@ -1538,46 +1461,44 @@ public class MainActivity extends Activity
|
||||
|
||||
public LinkedList<Integer> textInput = new LinkedList<Integer> ();
|
||||
public static MainActivity instance = null;
|
||||
public boolean readExternalStoragePermissionDialogAnswered = false;
|
||||
public boolean writeExternalStoragePermissionDialogAnswered = false;
|
||||
|
||||
public String ObbMountPath = null;
|
||||
public String assetPackPath = null; // Not saved to the config file
|
||||
}
|
||||
|
||||
// *** HONEYCOMB / ICS FIX FOR FULLSCREEN MODE, by lmak ***
|
||||
class DimSystemStatusBar
|
||||
abstract class DimSystemStatusBar
|
||||
{
|
||||
public static void dim(final View view, final Window window)
|
||||
public static DimSystemStatusBar get()
|
||||
{
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT && Globals.ImmersiveMode)
|
||||
{
|
||||
// Immersive mode, I already hear curses when system bar reappears mid-game from the slightest swipe at the bottom of the screen
|
||||
//Log.i("SDL", "libSDL: Enabling fullscreen, Android SDK " + android.os.Build.VERSION.SDK_INT + " VERSION_CODES.P " + android.os.Build.VERSION_CODES.P);
|
||||
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P )
|
||||
{
|
||||
//Log.i("SDL", "libSDL: Setting display cutout mode to SHORT_EDGES");
|
||||
if (Globals.DrawInDisplayCutout)
|
||||
window.getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
|
||||
else
|
||||
window.getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
|
||||
}
|
||||
if (view != null)
|
||||
{
|
||||
view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
|
||||
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
|
||||
}
|
||||
}
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB)
|
||||
return DimSystemStatusBarHoneycomb.Holder.sInstance;
|
||||
else
|
||||
return DimSystemStatusBarDummy.Holder.sInstance;
|
||||
}
|
||||
public abstract void dim(final View view);
|
||||
|
||||
private static class DimSystemStatusBarHoneycomb extends DimSystemStatusBar
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
if (view != null)
|
||||
{
|
||||
private static final DimSystemStatusBarHoneycomb sInstance = new DimSystemStatusBarHoneycomb();
|
||||
}
|
||||
public void dim(final View view)
|
||||
{
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT && Globals.ImmersiveMode)
|
||||
// Immersive mode, I already hear curses when system bar reappears mid-game from the slightest swipe at the bottom of the screen
|
||||
view.setSystemUiVisibility(android.view.View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | android.view.View.SYSTEM_UI_FLAG_FULLSCREEN);
|
||||
else
|
||||
view.setSystemUiVisibility(android.view.View.SYSTEM_UI_FLAG_LOW_PROFILE);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static class DimSystemStatusBarDummy extends DimSystemStatusBar
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
private static final DimSystemStatusBarDummy sInstance = new DimSystemStatusBarDummy();
|
||||
}
|
||||
public void dim(final View view)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2014 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
class Mouse
|
||||
{
|
||||
public static final int LEFT_CLICK_NORMAL = 0;
|
||||
public static final int LEFT_CLICK_NEAR_CURSOR = 1;
|
||||
public static final int LEFT_CLICK_WITH_MULTITOUCH = 2;
|
||||
public static final int LEFT_CLICK_WITH_PRESSURE = 3;
|
||||
public static final int LEFT_CLICK_WITH_KEY = 4;
|
||||
public static final int LEFT_CLICK_WITH_TIMEOUT = 5;
|
||||
public static final int LEFT_CLICK_WITH_TAP = 6;
|
||||
public static final int LEFT_CLICK_WITH_TAP_OR_TIMEOUT = 7;
|
||||
|
||||
public static final int RIGHT_CLICK_NONE = 0;
|
||||
public static final int RIGHT_CLICK_WITH_MULTITOUCH = 1;
|
||||
public static final int RIGHT_CLICK_WITH_PRESSURE = 2;
|
||||
public static final int RIGHT_CLICK_WITH_KEY = 3;
|
||||
public static final int RIGHT_CLICK_WITH_TIMEOUT = 4;
|
||||
|
||||
public static final int SDL_FINGER_DOWN = 0;
|
||||
public static final int SDL_FINGER_UP = 1;
|
||||
public static final int SDL_FINGER_MOVE = 2;
|
||||
public static final int SDL_FINGER_HOVER = 3;
|
||||
|
||||
public static final int ZOOM_NONE = 0;
|
||||
public static final int ZOOM_MAGNIFIER = 1;
|
||||
|
||||
public static final int MOUSE_HW_INPUT_FINGER = 0;
|
||||
public static final int MOUSE_HW_INPUT_STYLUS = 1;
|
||||
public static final int MOUSE_HW_INPUT_MOUSE = 2;
|
||||
|
||||
public static final int MAX_HOVER_DISTANCE = 1024;
|
||||
public static final int HOVER_REDRAW_SCREEN = 1024 * 10;
|
||||
public static final float MAX_PRESSURE = 1024.0f;
|
||||
}
|
||||
@@ -87,7 +87,6 @@ public class Settings
|
||||
static boolean settingsChanged = false;
|
||||
static final int SETTINGS_FILE_VERSION = 5;
|
||||
static boolean convertButtonSizeFromOldSdlVersion = false;
|
||||
static int settingsAppVersion = 0;
|
||||
|
||||
static void Save(final MainActivity p)
|
||||
{
|
||||
@@ -192,7 +191,6 @@ public class Settings
|
||||
out.writeBoolean(Globals.ForceHardwareMouse);
|
||||
convertButtonSizeFromOldSdlVersion = false;
|
||||
out.writeBoolean(convertButtonSizeFromOldSdlVersion);
|
||||
out.writeBoolean(Globals.DrawInDisplayCutout);
|
||||
|
||||
out.close();
|
||||
settingsLoaded = true;
|
||||
@@ -202,157 +200,13 @@ public class Settings
|
||||
} catch ( IOException e ) {};
|
||||
}
|
||||
|
||||
static boolean LoadConfig( final MainActivity p )
|
||||
static void Load( final MainActivity p )
|
||||
{
|
||||
Globals.OptionalDataDownload = new boolean[Globals.DataDownloadUrl.length];
|
||||
for( int i = 0; i < Globals.DataDownloadUrl.length; i++ )
|
||||
{
|
||||
if( Globals.DataDownloadUrl[i].indexOf("!") == 0 )
|
||||
{
|
||||
Globals.OptionalDataDownload[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
ObjectInputStream settingsFile = new ObjectInputStream(new FileInputStream( p.getFilesDir().getAbsolutePath() + "/" + SettingsFileName ));
|
||||
if( settingsFile.readInt() != SETTINGS_FILE_VERSION )
|
||||
throw new IOException();
|
||||
Globals.DownloadToSdcard = settingsFile.readBoolean();
|
||||
Globals.PhoneHasArrowKeys = settingsFile.readBoolean();
|
||||
settingsFile.readBoolean();
|
||||
Globals.UseAccelerometerAsArrowKeys = settingsFile.readBoolean();
|
||||
Globals.UseTouchscreenKeyboard = settingsFile.readBoolean();
|
||||
Globals.TouchscreenKeyboardSize = settingsFile.readInt();
|
||||
convertButtonSizeFromOldSdlVersion = true; // Will be changed to false if we read the remainder of the config file
|
||||
Globals.AccelerometerSensitivity = settingsFile.readInt();
|
||||
Globals.AccelerometerCenterPos = settingsFile.readInt();
|
||||
settingsFile.readInt();
|
||||
Globals.AudioBufferConfig = settingsFile.readInt();
|
||||
Globals.TouchscreenKeyboardTheme = settingsFile.readInt();
|
||||
Globals.RightClickMethod = settingsFile.readInt();
|
||||
Globals.ShowScreenUnderFinger = settingsFile.readInt();
|
||||
Globals.LeftClickMethod = settingsFile.readInt();
|
||||
Globals.MoveMouseWithJoystick = settingsFile.readBoolean();
|
||||
Globals.ClickMouseWithDpad = settingsFile.readBoolean();
|
||||
Globals.ClickScreenPressure = settingsFile.readInt();
|
||||
Globals.ClickScreenTouchspotSize = settingsFile.readInt();
|
||||
Globals.KeepAspectRatio = settingsFile.readBoolean();
|
||||
Globals.MoveMouseWithJoystickSpeed = settingsFile.readInt();
|
||||
Globals.MoveMouseWithJoystickAccel = settingsFile.readInt();
|
||||
int readKeysSize = settingsFile.readInt();
|
||||
for( int i = 0; i < readKeysSize; i++ )
|
||||
{
|
||||
Globals.RemapHwKeycode[i] = settingsFile.readInt();
|
||||
}
|
||||
int readScreenKbRemapKeysSize = settingsFile.readInt();
|
||||
if( readScreenKbRemapKeysSize > Globals.RemapScreenKbKeycode.length )
|
||||
throw new IOException();
|
||||
for( int i = 0; i < readScreenKbRemapKeysSize; i++ )
|
||||
{
|
||||
Globals.RemapScreenKbKeycode[i] = settingsFile.readInt();
|
||||
}
|
||||
int readScreenKbShownSize = settingsFile.readInt();
|
||||
if( readScreenKbShownSize > Globals.ScreenKbControlsShown.length )
|
||||
throw new IOException();
|
||||
for( int i = 0; i < readScreenKbShownSize; i++ )
|
||||
{
|
||||
Globals.ScreenKbControlsShown[i] = settingsFile.readBoolean();
|
||||
}
|
||||
Globals.TouchscreenKeyboardTransparency = settingsFile.readInt();
|
||||
if( settingsFile.readInt() != Globals.RemapMultitouchGestureKeycode.length )
|
||||
throw new IOException();
|
||||
for( int i = 0; i < Globals.RemapMultitouchGestureKeycode.length; i++ )
|
||||
{
|
||||
Globals.RemapMultitouchGestureKeycode[i] = settingsFile.readInt();
|
||||
Globals.MultitouchGesturesUsed[i] = settingsFile.readBoolean();
|
||||
}
|
||||
Globals.MultitouchGestureSensitivity = settingsFile.readInt();
|
||||
for( int i = 0; i < Globals.TouchscreenCalibration.length; i++ )
|
||||
Globals.TouchscreenCalibration[i] = settingsFile.readInt();
|
||||
StringBuilder b = new StringBuilder();
|
||||
int len = settingsFile.readInt();
|
||||
for( int i = 0; i < len; i++ )
|
||||
b.append( settingsFile.readChar() );
|
||||
Globals.DataDir = b.toString();
|
||||
|
||||
b = new StringBuilder();
|
||||
len = settingsFile.readInt();
|
||||
for( int i = 0; i < len; i++ )
|
||||
b.append( settingsFile.readChar() );
|
||||
Globals.CommandLine = b.toString();
|
||||
|
||||
int screenKbControlsLayoutSize = settingsFile.readInt();
|
||||
if( screenKbControlsLayoutSize > Globals.ScreenKbControlsLayout.length )
|
||||
throw new IOException();
|
||||
for( int i = 0; i < screenKbControlsLayoutSize; i++ )
|
||||
for( int ii = 0; ii < 4; ii++ )
|
||||
Globals.ScreenKbControlsLayout[i][ii] = settingsFile.readInt();
|
||||
Globals.LeftClickKey = settingsFile.readInt();
|
||||
Globals.RightClickKey = settingsFile.readInt();
|
||||
Globals.VideoLinearFilter = settingsFile.readBoolean();
|
||||
Globals.LeftClickTimeout = settingsFile.readInt();
|
||||
Globals.RightClickTimeout = settingsFile.readInt();
|
||||
Globals.RelativeMouseMovement = settingsFile.readBoolean();
|
||||
Globals.RelativeMouseMovementSpeed = settingsFile.readInt();
|
||||
Globals.RelativeMouseMovementAccel = settingsFile.readInt();
|
||||
Globals.MultiThreadedVideo = settingsFile.readBoolean();
|
||||
|
||||
Globals.OptionalDataDownload = new boolean[settingsFile.readInt()];
|
||||
for(int i = 0; i < Globals.OptionalDataDownload.length; i++)
|
||||
Globals.OptionalDataDownload[i] = settingsFile.readBoolean();
|
||||
settingsFile.readBoolean(); // Unused
|
||||
Globals.TouchscreenKeyboardDrawSize = settingsFile.readInt();
|
||||
settingsAppVersion = settingsFile.readInt();
|
||||
// Gyroscope calibration data, now unused
|
||||
settingsFile.readFloat();
|
||||
settingsFile.readFloat();
|
||||
settingsFile.readFloat();
|
||||
settingsFile.readFloat();
|
||||
settingsFile.readFloat();
|
||||
settingsFile.readFloat();
|
||||
settingsFile.readFloat();
|
||||
settingsFile.readFloat();
|
||||
settingsFile.readFloat();
|
||||
|
||||
Globals.OuyaEmulation = settingsFile.readBoolean();
|
||||
Globals.HoverJitterFilter = settingsFile.readBoolean();
|
||||
Globals.MoveMouseWithGyroscope = settingsFile.readBoolean();
|
||||
Globals.MoveMouseWithGyroscopeSpeed = settingsFile.readInt();
|
||||
Globals.FingerHover = settingsFile.readBoolean();
|
||||
Globals.FloatingScreenJoystick = settingsFile.readBoolean();
|
||||
Globals.GenerateSubframeTouchEvents = settingsFile.readBoolean();
|
||||
Globals.VideoDepthBpp = settingsFile.readInt();
|
||||
Globals.HorizontalOrientation = settingsFile.readBoolean();
|
||||
Globals.ImmersiveMode = settingsFile.readBoolean();
|
||||
Globals.AutoDetectOrientation = settingsFile.readBoolean();
|
||||
Globals.TvBorders = settingsFile.readBoolean();
|
||||
Globals.ForceHardwareMouse = settingsFile.readBoolean();
|
||||
convertButtonSizeFromOldSdlVersion = settingsFile.readBoolean();
|
||||
Globals.DrawInDisplayCutout = settingsFile.readBoolean();
|
||||
|
||||
Log.i("SDL", "libSDL: Settings.LoadConfig(): loaded settings successfully");
|
||||
settingsFile.close();
|
||||
|
||||
return true;
|
||||
|
||||
} catch( FileNotFoundException e ) {
|
||||
Log.i("SDL", "libSDL: settings file not found: " + e);
|
||||
} catch( SecurityException e ) {
|
||||
Log.i("SDL", "libSDL: settings file cannot be opened: " + e);
|
||||
} catch( IOException e ) {
|
||||
Log.i("SDL", "libSDL: settings file cannot be read: " + e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void ProcessConfig( final MainActivity p )
|
||||
{
|
||||
if( settingsLoaded ) // Prevent starting twice
|
||||
if(settingsLoaded) // Prevent starting twice
|
||||
{
|
||||
return;
|
||||
}
|
||||
Log.i("SDL", "libSDL: Settings.ProcessConfig(): enter");
|
||||
Log.i("SDL", "libSDL: Settings.Load(): enter");
|
||||
nativeInitKeymap();
|
||||
for( int i = 0; i < SDL_Keys.JAVA_KEYCODE_LAST; i++ )
|
||||
{
|
||||
@@ -374,14 +228,12 @@ public class Settings
|
||||
}
|
||||
Globals.ScreenKbControlsShown[0] = (Globals.AppNeedsArrowKeys || Globals.AppUsesJoystick);
|
||||
Globals.ScreenKbControlsShown[1] = Globals.AppNeedsTextInput;
|
||||
for( int i = 2; i < 8; i++ )
|
||||
for( int i = 2; i < Globals.ScreenKbControlsShown.length; i++ )
|
||||
Globals.ScreenKbControlsShown[i] = ( i - 2 < Globals.AppTouchscreenKeyboardKeysAmount );
|
||||
if( Globals.AppUsesSecondJoystick )
|
||||
Globals.ScreenKbControlsShown[8] = true;
|
||||
if( Globals.AppUsesThirdJoystick )
|
||||
Globals.ScreenKbControlsShown[9] = true;
|
||||
for( int i = 10; i < Globals.ScreenKbControlsShown.length; i++ )
|
||||
Globals.ScreenKbControlsShown[i] = ( i - 4 < Globals.AppTouchscreenKeyboardKeysAmount );
|
||||
for( int i = 0; i < Globals.RemapMultitouchGestureKeycode.length; i++ )
|
||||
{
|
||||
int sdlKey = nativeGetKeymapKeyMultitouchGesture(i);
|
||||
@@ -424,18 +276,131 @@ public class Settings
|
||||
}
|
||||
convertButtonSizeFromOldSdlVersion = false;
|
||||
|
||||
settingsLoaded = LoadConfig(p);
|
||||
try {
|
||||
ObjectInputStream settingsFile = new ObjectInputStream(new FileInputStream( p.getFilesDir().getAbsolutePath() + "/" + SettingsFileName ));
|
||||
if( settingsFile.readInt() != SETTINGS_FILE_VERSION )
|
||||
throw new IOException();
|
||||
Globals.DownloadToSdcard = settingsFile.readBoolean();
|
||||
Globals.PhoneHasArrowKeys = settingsFile.readBoolean();
|
||||
settingsFile.readBoolean();
|
||||
Globals.UseAccelerometerAsArrowKeys = settingsFile.readBoolean();
|
||||
Globals.UseTouchscreenKeyboard = settingsFile.readBoolean();
|
||||
Globals.TouchscreenKeyboardSize = settingsFile.readInt();
|
||||
convertButtonSizeFromOldSdlVersion = true; // Will be changed to false if we read the remainder of the config file
|
||||
Globals.AccelerometerSensitivity = settingsFile.readInt();
|
||||
Globals.AccelerometerCenterPos = settingsFile.readInt();
|
||||
settingsFile.readInt();
|
||||
Globals.AudioBufferConfig = settingsFile.readInt();
|
||||
Globals.TouchscreenKeyboardTheme = settingsFile.readInt();
|
||||
Globals.RightClickMethod = settingsFile.readInt();
|
||||
Globals.ShowScreenUnderFinger = settingsFile.readInt();
|
||||
Globals.LeftClickMethod = settingsFile.readInt();
|
||||
Globals.MoveMouseWithJoystick = settingsFile.readBoolean();
|
||||
Globals.ClickMouseWithDpad = settingsFile.readBoolean();
|
||||
Globals.ClickScreenPressure = settingsFile.readInt();
|
||||
Globals.ClickScreenTouchspotSize = settingsFile.readInt();
|
||||
Globals.KeepAspectRatio = settingsFile.readBoolean();
|
||||
Globals.MoveMouseWithJoystickSpeed = settingsFile.readInt();
|
||||
Globals.MoveMouseWithJoystickAccel = settingsFile.readInt();
|
||||
int readKeys = settingsFile.readInt();
|
||||
for( int i = 0; i < readKeys; i++ )
|
||||
{
|
||||
Globals.RemapHwKeycode[i] = settingsFile.readInt();
|
||||
}
|
||||
if( settingsFile.readInt() != Globals.RemapScreenKbKeycode.length )
|
||||
throw new IOException();
|
||||
for( int i = 0; i < Globals.RemapScreenKbKeycode.length; i++ )
|
||||
{
|
||||
Globals.RemapScreenKbKeycode[i] = settingsFile.readInt();
|
||||
}
|
||||
if( settingsFile.readInt() != Globals.ScreenKbControlsShown.length )
|
||||
throw new IOException();
|
||||
for( int i = 0; i < Globals.ScreenKbControlsShown.length; i++ )
|
||||
{
|
||||
Globals.ScreenKbControlsShown[i] = settingsFile.readBoolean();
|
||||
}
|
||||
Globals.TouchscreenKeyboardTransparency = settingsFile.readInt();
|
||||
if( settingsFile.readInt() != Globals.RemapMultitouchGestureKeycode.length )
|
||||
throw new IOException();
|
||||
for( int i = 0; i < Globals.RemapMultitouchGestureKeycode.length; i++ )
|
||||
{
|
||||
Globals.RemapMultitouchGestureKeycode[i] = settingsFile.readInt();
|
||||
Globals.MultitouchGesturesUsed[i] = settingsFile.readBoolean();
|
||||
}
|
||||
Globals.MultitouchGestureSensitivity = settingsFile.readInt();
|
||||
for( int i = 0; i < Globals.TouchscreenCalibration.length; i++ )
|
||||
Globals.TouchscreenCalibration[i] = settingsFile.readInt();
|
||||
StringBuilder b = new StringBuilder();
|
||||
int len = settingsFile.readInt();
|
||||
for( int i = 0; i < len; i++ )
|
||||
b.append( settingsFile.readChar() );
|
||||
Globals.DataDir = b.toString();
|
||||
|
||||
if (settingsLoaded)
|
||||
{
|
||||
Log.i("SDL", "libSDL: Settings.ProcessConfig(): loaded settings successfully");
|
||||
Log.i("SDL", "libSDL: old app version " + settingsAppVersion + ", new app version " + p.getApplicationVersion());
|
||||
if( settingsAppVersion != p.getApplicationVersion() )
|
||||
b = new StringBuilder();
|
||||
len = settingsFile.readInt();
|
||||
for( int i = 0; i < len; i++ )
|
||||
b.append( settingsFile.readChar() );
|
||||
Globals.CommandLine = b.toString();
|
||||
|
||||
if( settingsFile.readInt() != Globals.ScreenKbControlsLayout.length )
|
||||
throw new IOException();
|
||||
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ )
|
||||
for( int ii = 0; ii < 4; ii++ )
|
||||
Globals.ScreenKbControlsLayout[i][ii] = settingsFile.readInt();
|
||||
Globals.LeftClickKey = settingsFile.readInt();
|
||||
Globals.RightClickKey = settingsFile.readInt();
|
||||
Globals.VideoLinearFilter = settingsFile.readBoolean();
|
||||
Globals.LeftClickTimeout = settingsFile.readInt();
|
||||
Globals.RightClickTimeout = settingsFile.readInt();
|
||||
Globals.RelativeMouseMovement = settingsFile.readBoolean();
|
||||
Globals.RelativeMouseMovementSpeed = settingsFile.readInt();
|
||||
Globals.RelativeMouseMovementAccel = settingsFile.readInt();
|
||||
Globals.MultiThreadedVideo = settingsFile.readBoolean();
|
||||
|
||||
Globals.OptionalDataDownload = new boolean[settingsFile.readInt()];
|
||||
for(int i = 0; i < Globals.OptionalDataDownload.length; i++)
|
||||
Globals.OptionalDataDownload[i] = settingsFile.readBoolean();
|
||||
settingsFile.readBoolean(); // Unused
|
||||
Globals.TouchscreenKeyboardDrawSize = settingsFile.readInt();
|
||||
int cfgVersion = settingsFile.readInt();
|
||||
// Gyroscope calibration data, now unused
|
||||
settingsFile.readFloat();
|
||||
settingsFile.readFloat();
|
||||
settingsFile.readFloat();
|
||||
settingsFile.readFloat();
|
||||
settingsFile.readFloat();
|
||||
settingsFile.readFloat();
|
||||
settingsFile.readFloat();
|
||||
settingsFile.readFloat();
|
||||
settingsFile.readFloat();
|
||||
|
||||
Globals.OuyaEmulation = settingsFile.readBoolean();
|
||||
Globals.HoverJitterFilter = settingsFile.readBoolean();
|
||||
Globals.MoveMouseWithGyroscope = settingsFile.readBoolean();
|
||||
Globals.MoveMouseWithGyroscopeSpeed = settingsFile.readInt();
|
||||
Globals.FingerHover = settingsFile.readBoolean();
|
||||
Globals.FloatingScreenJoystick = settingsFile.readBoolean();
|
||||
Globals.GenerateSubframeTouchEvents = settingsFile.readBoolean();
|
||||
Globals.VideoDepthBpp = settingsFile.readInt();
|
||||
Globals.HorizontalOrientation = settingsFile.readBoolean();
|
||||
Globals.ImmersiveMode = settingsFile.readBoolean();
|
||||
Globals.AutoDetectOrientation = settingsFile.readBoolean();
|
||||
Globals.TvBorders = settingsFile.readBoolean();
|
||||
Globals.ForceHardwareMouse = settingsFile.readBoolean();
|
||||
convertButtonSizeFromOldSdlVersion = settingsFile.readBoolean();
|
||||
|
||||
settingsLoaded = true;
|
||||
|
||||
Log.i("SDL", "libSDL: Settings.Load(): loaded settings successfully");
|
||||
settingsFile.close();
|
||||
|
||||
Log.i("SDL", "libSDL: old cfg version " + cfgVersion + ", our version " + p.getApplicationVersion());
|
||||
if( cfgVersion != p.getApplicationVersion() )
|
||||
{
|
||||
DeleteFilesOnUpgrade(p);
|
||||
if( Globals.ResetSdlConfigForThisVersion )
|
||||
{
|
||||
Log.i("SDL", "libSDL: old app version " + settingsAppVersion + ", new app version " + p.getApplicationVersion() + " and we need to clean up config file");
|
||||
Log.i("SDL", "libSDL: old cfg version " + cfgVersion + ", our version " + p.getApplicationVersion() + " and we need to clean up config file");
|
||||
// Delete settings file, and restart the application
|
||||
DeleteSdlConfigOnUpgradeAndRestart(p);
|
||||
}
|
||||
@@ -443,21 +408,26 @@ public class Settings
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Log.i("SDL", "libSDL: settings cannot be loaded");
|
||||
DeleteFilesOnUpgrade(p);
|
||||
if (convertButtonSizeFromOldSdlVersion && Globals.TouchscreenKeyboardSize + 1 < Globals.TOUCHSCREEN_KEYBOARD_CUSTOM)
|
||||
{
|
||||
Globals.TouchscreenKeyboardSize ++; // New default button size is bigger, but we are keeping old button size for existing installations
|
||||
//if (Globals.AppTouchscreenKeyboardKeysAmount <= 4 && Globals.TouchscreenKeyboardSize + 1 < Globals.TOUCHSCREEN_KEYBOARD_CUSTOM)
|
||||
// Globals.TouchscreenKeyboardSize ++; // If there are only 4 buttons they are even bigger
|
||||
}
|
||||
if( Globals.ResetSdlConfigForThisVersion && settingsAppVersion != 0 )
|
||||
{
|
||||
Log.i("SDL", "libSDL: old cfg version unknown or too old, our version " + p.getApplicationVersion() + " and we need to clean up config file");
|
||||
DeleteSdlConfigOnUpgradeAndRestart(p);
|
||||
}
|
||||
|
||||
} catch( FileNotFoundException e ) {
|
||||
Log.i("SDL", "libSDL: settings file not found: " + e);
|
||||
} catch( SecurityException e ) {
|
||||
Log.i("SDL", "libSDL: settings file cannot be opened: " + e);
|
||||
} catch( IOException e ) {
|
||||
Log.i("SDL", "libSDL: settings file cannot be read: " + e);
|
||||
DeleteFilesOnUpgrade(p);
|
||||
if (convertButtonSizeFromOldSdlVersion && Globals.TouchscreenKeyboardSize + 1 < Globals.TOUCHSCREEN_KEYBOARD_CUSTOM)
|
||||
{
|
||||
Globals.TouchscreenKeyboardSize ++; // New default button size is bigger, but we are keeping old button size for existing installations
|
||||
//if (Globals.AppTouchscreenKeyboardKeysAmount <= 4 && Globals.TouchscreenKeyboardSize + 1 < Globals.TOUCHSCREEN_KEYBOARD_CUSTOM)
|
||||
// Globals.TouchscreenKeyboardSize ++; // If there are only 4 buttons they are even bigger
|
||||
}
|
||||
if( Globals.ResetSdlConfigForThisVersion )
|
||||
{
|
||||
Log.i("SDL", "libSDL: old cfg version unknown or too old, our version " + p.getApplicationVersion() + " and we need to clean up config file");
|
||||
DeleteSdlConfigOnUpgradeAndRestart(p);
|
||||
}
|
||||
};
|
||||
|
||||
if( Globals.DataDir.length() == 0 )
|
||||
{
|
||||
@@ -638,7 +608,7 @@ public class Settings
|
||||
Globals.TouchscreenKeyboardTransparency,
|
||||
Globals.FloatingScreenJoystick ? 1 : 0,
|
||||
Globals.AppTouchscreenKeyboardKeysAmount );
|
||||
DemoGLSurfaceView.SetupTouchscreenKeyboardGraphics(p);
|
||||
SetupTouchscreenKeyboardGraphics(p);
|
||||
for( int i = 0; i < Globals.RemapScreenKbKeycode.length; i++ )
|
||||
nativeSetKeymapKeyScreenKb(i, SDL_Keys.values[Globals.RemapScreenKbKeycode[i]]);
|
||||
if( Globals.TouchscreenKeyboardSize == Globals.TOUCHSCREEN_KEYBOARD_CUSTOM )
|
||||
@@ -695,14 +665,6 @@ public class Settings
|
||||
try {
|
||||
nativeSetEnv( "ANDROID_OBB_DIR", p.getObbDir().getAbsolutePath() );
|
||||
} catch (Exception eeeeeee) {}
|
||||
if( p.ObbMountPath != null )
|
||||
{
|
||||
nativeSetEnv( "ANDROID_OBB_MOUNT_DIR", p.ObbMountPath );
|
||||
}
|
||||
if( p.assetPackPath != null )
|
||||
{
|
||||
nativeSetEnv( "ANDROID_ASSET_PACK_PATH", p.assetPackPath );
|
||||
}
|
||||
try {
|
||||
nativeSetEnv( "ANDROID_APP_NAME", p.getString(p.getApplicationInfo().labelRes) );
|
||||
} catch (Exception eeeeee) {}
|
||||
@@ -745,6 +707,63 @@ public class Settings
|
||||
} catch (Exception eeeee) {}
|
||||
}
|
||||
|
||||
static byte [] loadRaw(Activity p, int res)
|
||||
{
|
||||
byte [] buf = new byte[65536 * 2];
|
||||
byte [] a = new byte[1048576 * 5]; // We need 5Mb buffer for Keen theme, and this Java code is inefficient
|
||||
int written = 0;
|
||||
try{
|
||||
InputStream is = new GZIPInputStream(p.getResources().openRawResource(res));
|
||||
int readed = 0;
|
||||
while( (readed = is.read(buf)) >= 0 )
|
||||
{
|
||||
if( written + readed > a.length )
|
||||
{
|
||||
byte [] b = new byte [written + readed];
|
||||
System.arraycopy(a, 0, b, 0, written);
|
||||
a = b;
|
||||
}
|
||||
System.arraycopy(buf, 0, a, written, readed);
|
||||
written += readed;
|
||||
}
|
||||
} catch(Exception e) {};
|
||||
byte [] b = new byte [written];
|
||||
System.arraycopy(a, 0, b, 0, written);
|
||||
return b;
|
||||
}
|
||||
|
||||
static void SetupTouchscreenKeyboardGraphics(Activity p)
|
||||
{
|
||||
if( Globals.UseTouchscreenKeyboard )
|
||||
{
|
||||
if(Globals.TouchscreenKeyboardTheme < 0)
|
||||
Globals.TouchscreenKeyboardTheme = 0;
|
||||
if(Globals.TouchscreenKeyboardTheme > 9)
|
||||
Globals.TouchscreenKeyboardTheme = 9;
|
||||
|
||||
if( Globals.TouchscreenKeyboardTheme == 0 )
|
||||
nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.ultimatedroid));
|
||||
if( Globals.TouchscreenKeyboardTheme == 1 )
|
||||
nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.simpletheme));
|
||||
if( Globals.TouchscreenKeyboardTheme == 2 )
|
||||
nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.sun));
|
||||
if( Globals.TouchscreenKeyboardTheme == 3 )
|
||||
nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.keen));
|
||||
if( Globals.TouchscreenKeyboardTheme == 4 )
|
||||
nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.retro));
|
||||
if( Globals.TouchscreenKeyboardTheme == 5 )
|
||||
nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.gba));
|
||||
if( Globals.TouchscreenKeyboardTheme == 6 )
|
||||
nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.psx));
|
||||
if( Globals.TouchscreenKeyboardTheme == 7 )
|
||||
nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.snes));
|
||||
if( Globals.TouchscreenKeyboardTheme == 8 )
|
||||
nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.dualshock));
|
||||
if( Globals.TouchscreenKeyboardTheme == 9 )
|
||||
nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.n64));
|
||||
}
|
||||
}
|
||||
|
||||
abstract static class SdcardAppPath
|
||||
{
|
||||
public static SdcardAppPath get()
|
||||
@@ -953,7 +972,6 @@ public class Settings
|
||||
Save(MainActivity.instance);
|
||||
}
|
||||
|
||||
// libsdl-1.2.so, does not exist in SDL2
|
||||
private static native void nativeSetAccelerometerSettings(int sensitivity, int centerPos);
|
||||
private static native void nativeSetMouseUsed(int RightClickMethod, int ShowScreenUnderFinger, int LeftClickMethod,
|
||||
int MoveMouseWithJoystick, int ClickMouseWithDpad, int MaxForce, int MaxRadius,
|
||||
@@ -965,7 +983,7 @@ public class Settings
|
||||
int HoverJitterFilter, int RightMouseButtonLongPress,
|
||||
int MoveMouseWithGyroscope, int MoveMouseWithGyroscopeSpeed,
|
||||
int ForceScreenUpdateMouseClick, int ScreenFollowsMouse);
|
||||
public static native void nativeSetJoystickUsed(int amount);
|
||||
private static native void nativeSetJoystickUsed(int amount);
|
||||
private static native void nativeSetAccelerometerUsed();
|
||||
private static native void nativeSetMultitouchUsed();
|
||||
private static native void nativeSetTouchscreenKeyboardUsed();
|
||||
@@ -975,7 +993,7 @@ public class Settings
|
||||
private static native void nativeSetVideoMultithreaded();
|
||||
private static native void nativeSetVideoForceSoftwareMode();
|
||||
public static native void nativeSetupScreenKeyboard(int size, int drawsize, int theme, int transparency, int floatingScreenJoystick, int buttonAmount);
|
||||
public static native void nativeSetupScreenKeyboardButtons(byte[] img);
|
||||
private static native void nativeSetupScreenKeyboardButtons(byte[] img);
|
||||
private static native void nativeInitKeymap();
|
||||
private static native int nativeGetKeymapKey(int key);
|
||||
private static native void nativeSetKeymapKey(int javakey, int key);
|
||||
@@ -988,7 +1006,6 @@ public class Settings
|
||||
private static native void nativeSetKeymapKeyMultitouchGesture(int keynum, int key);
|
||||
private static native void nativeSetMultitouchGestureSensitivity(int sensitivity);
|
||||
public static native void nativeSetTouchscreenCalibration(int x1, int y1, int x2, int y2);
|
||||
// libsdl_native_helpers.so, exists in both versions
|
||||
public static native void nativeSetEnv(final String name, final String value);
|
||||
public static native int nativeChmod(final String name, int mode);
|
||||
public static native void nativeChdir(final String dir);
|
||||
|
||||
@@ -386,22 +386,26 @@ class SettingsMenuKeyboard extends SettingsMenu
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 4",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 5",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 6",
|
||||
p.getResources().getString(R.string.remap_screenkb_joystick) + " 2",
|
||||
p.getResources().getString(R.string.remap_screenkb_joystick) + " 3",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 7",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 8",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 9",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 10",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 11",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 12",
|
||||
};
|
||||
|
||||
boolean defaults[] = Arrays.copyOf(Globals.ScreenKbControlsShown, Globals.ScreenKbControlsShown.length);
|
||||
if( Globals.AppUsesSecondJoystick )
|
||||
{
|
||||
items = Arrays.copyOf(items, items.length + 1);
|
||||
items[items.length - 1] = p.getResources().getString(R.string.remap_screenkb_joystick) + " 2";
|
||||
defaults = Arrays.copyOf(defaults, defaults.length + 1);
|
||||
defaults[defaults.length - 1] = true;
|
||||
}
|
||||
if( Globals.AppUsesThirdJoystick )
|
||||
{
|
||||
items = Arrays.copyOf(items, items.length + 1);
|
||||
items[items.length - 1] = p.getResources().getString(R.string.remap_screenkb_joystick) + " 3";
|
||||
defaults = Arrays.copyOf(defaults, defaults.length + 1);
|
||||
defaults[defaults.length - 1] = true;
|
||||
}
|
||||
|
||||
for( int i = 0; i < Math.min(6, Globals.AppTouchscreenKeyboardKeysNames.length); i++ )
|
||||
items[i+2] = items[i+2] + " - " + Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
|
||||
for( int i = 6; i < Math.min(12, Globals.AppTouchscreenKeyboardKeysNames.length); i++ )
|
||||
items[i+4] = items[i+4] + " - " + Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.remap_screenkb));
|
||||
@@ -441,15 +445,9 @@ class SettingsMenuKeyboard extends SettingsMenu
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 4",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 5",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 6",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 7",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 8",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 9",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 10",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 11",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 12",
|
||||
};
|
||||
|
||||
for( int i = 0; i < Math.min(12, Globals.AppTouchscreenKeyboardKeysNames.length); i++ )
|
||||
for( int i = 0; i < Math.min(6, Globals.AppTouchscreenKeyboardKeysNames.length); i++ )
|
||||
items[i] = items[i] + " - " + Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
|
||||
|
||||
if( currentButton >= Globals.RemapScreenKbKeycode.length )
|
||||
@@ -457,12 +455,7 @@ class SettingsMenuKeyboard extends SettingsMenu
|
||||
goBack(p);
|
||||
return;
|
||||
}
|
||||
if( currentButton < 6 && ! Globals.ScreenKbControlsShown[currentButton + 2] )
|
||||
{
|
||||
showRemapScreenKbConfig2(p, currentButton + 1);
|
||||
return;
|
||||
}
|
||||
if( currentButton >= 6 && ! Globals.ScreenKbControlsShown[currentButton + 4] )
|
||||
if( ! Globals.ScreenKbControlsShown[currentButton + 2] )
|
||||
{
|
||||
showRemapScreenKbConfig2(p, currentButton + 1);
|
||||
return;
|
||||
@@ -634,7 +627,7 @@ class SettingsMenuKeyboard extends SettingsMenu
|
||||
{
|
||||
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help));
|
||||
if (Globals.ImmersiveMode)
|
||||
DimSystemStatusBar.dim(p.getVideoLayout(), p.getWindow());
|
||||
DimSystemStatusBar.get().dim(p.getVideoLayout());
|
||||
p.getVideoLayout().getHandler().postDelayed(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
@@ -664,25 +657,13 @@ class SettingsMenuKeyboard extends SettingsMenu
|
||||
R.drawable.b5,
|
||||
R.drawable.b6,
|
||||
R.drawable.dpad,
|
||||
R.drawable.dpad,
|
||||
R.drawable.b1,
|
||||
R.drawable.b2,
|
||||
R.drawable.b3,
|
||||
R.drawable.b4,
|
||||
R.drawable.b5,
|
||||
R.drawable.b6,
|
||||
R.drawable.dpad
|
||||
};
|
||||
int oldX = 0, oldY = 0;
|
||||
boolean resizing = false;
|
||||
|
||||
|
||||
public CustomizeScreenKbLayoutTool(MainActivity _p)
|
||||
{
|
||||
if( buttons.length != Globals.ScreenKbControlsLayout.length )
|
||||
{
|
||||
Log.i("SDL", "Assertion failed: buttons.length != Globals.ScreenKbControlsLayout.length" );
|
||||
throw new RuntimeException("Assertion failed: buttons.length != Globals.ScreenKbControlsLayout.length");
|
||||
}
|
||||
|
||||
p = _p;
|
||||
layout = new FrameLayout(p);
|
||||
p.getVideoLayout().addView(layout);
|
||||
@@ -705,7 +686,6 @@ class SettingsMenuKeyboard extends SettingsMenu
|
||||
if( Globals.TouchscreenKeyboardSize != Globals.TOUCHSCREEN_KEYBOARD_CUSTOM )
|
||||
{
|
||||
DemoRenderer.nativeResize(displayX, displayY, 0);
|
||||
Settings.nativeSetJoystickUsed( Globals.AppUsesThirdJoystick ? 3 : (Globals.AppUsesSecondJoystick ? 2 : (Globals.AppUsesJoystick ? 1 : 0)) );
|
||||
Settings.nativeSetupScreenKeyboard( Globals.TouchscreenKeyboardSize,
|
||||
Globals.TouchscreenKeyboardDrawSize,
|
||||
Globals.TouchscreenKeyboardTheme,
|
||||
@@ -800,10 +780,6 @@ class SettingsMenuKeyboard extends SettingsMenu
|
||||
buttonText = "Joystick 2";
|
||||
if( i == 9 )
|
||||
buttonText = "Joystick 3";
|
||||
if( i >= 10 && i <= 15 )
|
||||
buttonText = p.getResources().getString(R.string.remap_screenkb_button) + (i - 4);
|
||||
if( i >= 10 && i - 4 < Globals.AppTouchscreenKeyboardKeysNames.length )
|
||||
buttonText = Globals.AppTouchscreenKeyboardKeysNames[i - 4].replace("_", " ");
|
||||
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help) + "\n" + buttonText);
|
||||
}
|
||||
|
||||
@@ -903,7 +879,7 @@ class SettingsMenuKeyboard extends SettingsMenu
|
||||
p.getResources().getString(R.string.screenkb_floating_joystick),
|
||||
};
|
||||
|
||||
boolean defaults[] = {
|
||||
boolean defaults[] = {
|
||||
Globals.FloatingScreenJoystick,
|
||||
};
|
||||
|
||||
|
||||
@@ -324,7 +324,6 @@ class SettingsMenuMisc extends SettingsMenu
|
||||
p.getResources().getString(R.string.mouse_keepaspectratio),
|
||||
p.getResources().getString(R.string.video_smooth),
|
||||
p.getResources().getString(R.string.video_immersive),
|
||||
p.getResources().getString(R.string.video_draw_cutout),
|
||||
p.getResources().getString(R.string.video_orientation_autodetect),
|
||||
p.getResources().getString(R.string.video_orientation_vertical),
|
||||
p.getResources().getString(R.string.video_bpp_24),
|
||||
@@ -334,7 +333,6 @@ class SettingsMenuMisc extends SettingsMenu
|
||||
Globals.KeepAspectRatio,
|
||||
Globals.VideoLinearFilter,
|
||||
Globals.ImmersiveMode,
|
||||
Globals.DrawInDisplayCutout,
|
||||
Globals.AutoDetectOrientation,
|
||||
!Globals.HorizontalOrientation,
|
||||
Globals.VideoDepthBpp == 24,
|
||||
@@ -347,7 +345,6 @@ class SettingsMenuMisc extends SettingsMenu
|
||||
p.getResources().getString(R.string.mouse_keepaspectratio),
|
||||
p.getResources().getString(R.string.video_smooth),
|
||||
p.getResources().getString(R.string.video_immersive),
|
||||
p.getResources().getString(R.string.video_draw_cutout),
|
||||
p.getResources().getString(R.string.video_orientation_autodetect),
|
||||
p.getResources().getString(R.string.video_orientation_vertical),
|
||||
p.getResources().getString(R.string.video_bpp_24),
|
||||
@@ -358,7 +355,6 @@ class SettingsMenuMisc extends SettingsMenu
|
||||
Globals.KeepAspectRatio,
|
||||
Globals.VideoLinearFilter,
|
||||
Globals.ImmersiveMode,
|
||||
Globals.DrawInDisplayCutout,
|
||||
Globals.AutoDetectOrientation,
|
||||
!Globals.HorizontalOrientation,
|
||||
Globals.VideoDepthBpp == 24,
|
||||
@@ -369,7 +365,7 @@ class SettingsMenuMisc extends SettingsMenu
|
||||
defaults = defaults2;
|
||||
}
|
||||
|
||||
if(Globals.UsingSDL2)
|
||||
if(Globals.Using_SDL_1_3)
|
||||
{
|
||||
CharSequence[] items2 = {
|
||||
p.getResources().getString(R.string.mouse_keepaspectratio),
|
||||
@@ -394,16 +390,14 @@ class SettingsMenuMisc extends SettingsMenu
|
||||
if( item == 2 )
|
||||
Globals.ImmersiveMode = isChecked;
|
||||
if( item == 3 )
|
||||
Globals.DrawInDisplayCutout = isChecked;
|
||||
if( item == 4 )
|
||||
Globals.AutoDetectOrientation = isChecked;
|
||||
if( item == 5 )
|
||||
if( item == 4 )
|
||||
Globals.HorizontalOrientation = !isChecked;
|
||||
if( item == 6 )
|
||||
if( item == 5 )
|
||||
Globals.VideoDepthBpp = (isChecked ? 24 : 16);
|
||||
if( item == 7 )
|
||||
if( item == 6 )
|
||||
Globals.TvBorders = isChecked;
|
||||
if( item == 8 )
|
||||
if( item == 7 )
|
||||
Globals.MultiThreadedVideo = isChecked;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -33,13 +33,11 @@ import javax.microedition.khronos.egl.EGLDisplay;
|
||||
import javax.microedition.khronos.egl.EGLSurface;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.LinkedList;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Build;
|
||||
@@ -68,9 +66,42 @@ import android.net.Uri;
|
||||
import android.Manifest;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.input.InputManager;
|
||||
import android.graphics.Rect;
|
||||
|
||||
|
||||
class Mouse
|
||||
{
|
||||
public static final int LEFT_CLICK_NORMAL = 0;
|
||||
public static final int LEFT_CLICK_NEAR_CURSOR = 1;
|
||||
public static final int LEFT_CLICK_WITH_MULTITOUCH = 2;
|
||||
public static final int LEFT_CLICK_WITH_PRESSURE = 3;
|
||||
public static final int LEFT_CLICK_WITH_KEY = 4;
|
||||
public static final int LEFT_CLICK_WITH_TIMEOUT = 5;
|
||||
public static final int LEFT_CLICK_WITH_TAP = 6;
|
||||
public static final int LEFT_CLICK_WITH_TAP_OR_TIMEOUT = 7;
|
||||
|
||||
public static final int RIGHT_CLICK_NONE = 0;
|
||||
public static final int RIGHT_CLICK_WITH_MULTITOUCH = 1;
|
||||
public static final int RIGHT_CLICK_WITH_PRESSURE = 2;
|
||||
public static final int RIGHT_CLICK_WITH_KEY = 3;
|
||||
public static final int RIGHT_CLICK_WITH_TIMEOUT = 4;
|
||||
|
||||
public static final int SDL_FINGER_DOWN = 0;
|
||||
public static final int SDL_FINGER_UP = 1;
|
||||
public static final int SDL_FINGER_MOVE = 2;
|
||||
public static final int SDL_FINGER_HOVER = 3;
|
||||
|
||||
public static final int ZOOM_NONE = 0;
|
||||
public static final int ZOOM_MAGNIFIER = 1;
|
||||
|
||||
public static final int MOUSE_HW_INPUT_FINGER = 0;
|
||||
public static final int MOUSE_HW_INPUT_STYLUS = 1;
|
||||
public static final int MOUSE_HW_INPUT_MOUSE = 2;
|
||||
|
||||
public static final int MAX_HOVER_DISTANCE = 1024;
|
||||
public static final int HOVER_REDRAW_SCREEN = 1024 * 10;
|
||||
public static final float MAX_PRESSURE = 1024.0f;
|
||||
}
|
||||
|
||||
abstract class DifferentTouchInput
|
||||
{
|
||||
public abstract void process(final MotionEvent event);
|
||||
@@ -744,7 +775,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
|
||||
if(mGlContextLost) {
|
||||
mGlContextLost = false;
|
||||
DemoGLSurfaceView.SetupTouchscreenKeyboardGraphics(context); // Reload on-screen buttons graphics
|
||||
Settings.SetupTouchscreenKeyboardGraphics(context); // Reload on-screen buttons graphics
|
||||
super.SwapBuffers();
|
||||
}
|
||||
|
||||
@@ -1071,6 +1102,9 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||
if( nativeKey( keyCode, 0, event.getUnicodeChar(), DifferentTouchInput.processGamepadDeviceId(event.getDevice()) ) == 0 )
|
||||
return super.onKeyUp(keyCode, event);
|
||||
|
||||
//if( keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU )
|
||||
// DimSystemStatusBar.get().dim(mParent._videoLayout);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1129,19 +1163,14 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||
if (DifferentTouchInput.capturedMouseY >= this.getHeight())
|
||||
DifferentTouchInput.capturedMouseY = this.getHeight() - 1;
|
||||
|
||||
//Log.v("SDL", "SDL DemoGLSurfaceView::onCapturedPointerEvent(): X " + DifferentTouchInput.capturedMouseX + " Y " + DifferentTouchInput.capturedMouseY +
|
||||
//Log.v("SDL", "DemoGLSurfaceView::onCapturedPointerEvent(): X " + DifferentTouchInput.capturedMouseX + " Y " + DifferentTouchInput.capturedMouseY +
|
||||
// " W " + this.getWidth() + " H " + this.getHeight() + " getX " + event.getX() + " getY " + event.getY() +
|
||||
// " RelX " + event.getAxisValue(MotionEvent.AXIS_RELATIVE_X) + " RelY " + event.getAxisValue(MotionEvent.AXIS_RELATIVE_Y) );
|
||||
|
||||
event.setLocation(DifferentTouchInput.capturedMouseX, DifferentTouchInput.capturedMouseY);
|
||||
event.setAction(MotionEvent.ACTION_HOVER_MOVE);
|
||||
|
||||
int scrollX = Math.round(event.getAxisValue(MotionEvent.AXIS_HSCROLL));
|
||||
int scrollY = Math.round(event.getAxisValue(MotionEvent.AXIS_VSCROLL));
|
||||
if (scrollX != 0 || scrollY != 0)
|
||||
DemoGLSurfaceView.nativeMouseWheel(scrollX, scrollY);
|
||||
|
||||
//Log.v("SDL", "DemoGLSurfaceView::onCapturedPointerEvent(): XY " + event.getX() + " " + event.getY() + " action " + event.getAction() + " scroll " + scrollX + " " + scrollY);
|
||||
//Log.v("SDL", "DemoGLSurfaceView::onCapturedPointerEvent(): XY " + event.getX() + " " + event.getY() + " action " + event.getAction());
|
||||
|
||||
return this.onTouchEvent(event);
|
||||
}
|
||||
@@ -1224,63 +1253,6 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||
}
|
||||
}
|
||||
|
||||
static byte [] loadRaw(Activity p, int res)
|
||||
{
|
||||
byte [] buf = new byte[65536 * 2];
|
||||
byte [] a = new byte[1048576 * 5]; // We need 5Mb buffer for Keen theme, and this Java code is inefficient
|
||||
int written = 0;
|
||||
try{
|
||||
InputStream is = new GZIPInputStream(p.getResources().openRawResource(res));
|
||||
int readed = 0;
|
||||
while( (readed = is.read(buf)) >= 0 )
|
||||
{
|
||||
if( written + readed > a.length )
|
||||
{
|
||||
byte [] b = new byte [written + readed];
|
||||
System.arraycopy(a, 0, b, 0, written);
|
||||
a = b;
|
||||
}
|
||||
System.arraycopy(buf, 0, a, written, readed);
|
||||
written += readed;
|
||||
}
|
||||
} catch(Exception e) {};
|
||||
byte [] b = new byte [written];
|
||||
System.arraycopy(a, 0, b, 0, written);
|
||||
return b;
|
||||
}
|
||||
|
||||
static void SetupTouchscreenKeyboardGraphics(Activity p)
|
||||
{
|
||||
if( Globals.UseTouchscreenKeyboard )
|
||||
{
|
||||
if(Globals.TouchscreenKeyboardTheme < 0)
|
||||
Globals.TouchscreenKeyboardTheme = 0;
|
||||
if(Globals.TouchscreenKeyboardTheme > 9)
|
||||
Globals.TouchscreenKeyboardTheme = 9;
|
||||
|
||||
if( Globals.TouchscreenKeyboardTheme == 0 )
|
||||
Settings.nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.ultimatedroid));
|
||||
if( Globals.TouchscreenKeyboardTheme == 1 )
|
||||
Settings.nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.simpletheme));
|
||||
if( Globals.TouchscreenKeyboardTheme == 2 )
|
||||
Settings.nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.sun));
|
||||
if( Globals.TouchscreenKeyboardTheme == 3 )
|
||||
Settings.nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.keen));
|
||||
if( Globals.TouchscreenKeyboardTheme == 4 )
|
||||
Settings.nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.retro));
|
||||
if( Globals.TouchscreenKeyboardTheme == 5 )
|
||||
Settings.nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.gba));
|
||||
if( Globals.TouchscreenKeyboardTheme == 6 )
|
||||
Settings.nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.psx));
|
||||
if( Globals.TouchscreenKeyboardTheme == 7 )
|
||||
Settings.nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.snes));
|
||||
if( Globals.TouchscreenKeyboardTheme == 8 )
|
||||
Settings.nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.dualshock));
|
||||
if( Globals.TouchscreenKeyboardTheme == 9 )
|
||||
Settings.nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.n64));
|
||||
}
|
||||
}
|
||||
|
||||
DemoRenderer mRenderer;
|
||||
MainActivity mParent;
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@ class GameHelperUtils {
|
||||
return "RESULT_CANCELED";
|
||||
case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
|
||||
return "RESULT_APP_MISCONFIGURED";
|
||||
case GamesActivityResultCodes.RESULT_LEFT_ROOM:
|
||||
return "RESULT_LEFT_ROOM";
|
||||
case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
|
||||
return "RESULT_LICENSE_FAILED";
|
||||
case GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED:
|
||||
|
||||
@@ -160,7 +160,6 @@
|
||||
<string name="video_orientation_autodetect">Auto-detect screen orientation</string>
|
||||
<string name="video_bpp_24">24 bpp screen color depth</string>
|
||||
<string name="video_immersive">Hide system navigation buttons / immersive mode</string>
|
||||
<string name="video_draw_cutout">Draw in display cutout area</string>
|
||||
<string name="tv_borders">TV borders</string>
|
||||
|
||||
<string name="text_edit_click_here">Tap to start typing, press Back when done</string>
|
||||
|
||||
129
project/javaSDL2/Accelerometer.java
Normal file
129
project/javaSDL2/Accelerometer.java
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.os.Vibrator;
|
||||
import android.hardware.SensorManager;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.util.Log;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
class AccelerometerReader implements SensorEventListener
|
||||
{
|
||||
|
||||
private SensorManager _manager = null;
|
||||
public boolean openedBySDL = false;
|
||||
public static final GyroscopeListener gyro = new GyroscopeListener();
|
||||
|
||||
public AccelerometerReader(Activity context)
|
||||
{
|
||||
_manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||
}
|
||||
|
||||
public synchronized void stop()
|
||||
{
|
||||
if( _manager != null )
|
||||
{
|
||||
Log.i("SDL", "libSDL: stopping accelerometer/gyroscope");
|
||||
_manager.unregisterListener(this);
|
||||
_manager.unregisterListener(gyro);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void start()
|
||||
{
|
||||
if( (Globals.UseAccelerometerAsArrowKeys || Globals.AppUsesAccelerometer) &&
|
||||
_manager != null && _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) != null )
|
||||
{
|
||||
Log.i("SDL", "libSDL: starting accelerometer");
|
||||
_manager.registerListener(this, _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME);
|
||||
}
|
||||
if( Globals.AppUsesGyroscope && _manager != null && _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null )
|
||||
{
|
||||
Log.i("SDL", "libSDL: starting gyroscope");
|
||||
_manager.registerListener(gyro, _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME);
|
||||
}
|
||||
}
|
||||
|
||||
public void onSensorChanged(SensorEvent event)
|
||||
{
|
||||
if( Globals.HorizontalOrientation )
|
||||
nativeAccelerometer(event.values[1], -event.values[0], event.values[2]);
|
||||
else
|
||||
nativeAccelerometer(event.values[0], event.values[1], event.values[2]); // TODO: not tested!
|
||||
}
|
||||
public void onAccuracyChanged(Sensor s, int a)
|
||||
{
|
||||
}
|
||||
|
||||
static class GyroscopeListener implements SensorEventListener
|
||||
{
|
||||
public float x1, x2, xc, y1, y2, yc, z1, z2, zc;
|
||||
public GyroscopeListener()
|
||||
{
|
||||
}
|
||||
public void onSensorChanged(SensorEvent event)
|
||||
{
|
||||
// TODO: vertical orientation
|
||||
//if( Globals.HorizontalOrientation )
|
||||
if( event.values[0] < x1 || event.values[0] > x2 ||
|
||||
event.values[1] < y1 || event.values[1] > y2 ||
|
||||
event.values[2] < z1 || event.values[2] > z2 )
|
||||
nativeGyroscope(event.values[0] - xc, event.values[1] - yc, event.values[2] - zc);
|
||||
}
|
||||
public void onAccuracyChanged(Sensor s, int a)
|
||||
{
|
||||
}
|
||||
public boolean available(Activity context)
|
||||
{
|
||||
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||
return ( manager != null && manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null );
|
||||
}
|
||||
public void registerListener(Activity context, SensorEventListener l)
|
||||
{
|
||||
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||
if ( manager == null && manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) == null )
|
||||
return;
|
||||
manager.registerListener(l, manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME);
|
||||
}
|
||||
public void unregisterListener(Activity context,SensorEventListener l)
|
||||
{
|
||||
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||
if ( manager == null )
|
||||
return;
|
||||
manager.unregisterListener(l);
|
||||
}
|
||||
}
|
||||
|
||||
private static native void nativeAccelerometer(float accX, float accY, float accZ);
|
||||
private static native void nativeGyroscope(float X, float Y, float Z);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2014 Sergii Pylypenko
|
||||
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
@@ -9,7 +9,7 @@ arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
@@ -22,27 +22,29 @@ freely, subject to the following restrictions:
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.content.Context;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
import android.view.View;
|
||||
|
||||
// Stubs for compatibility with SDL 1.2 code
|
||||
class Advertisement
|
||||
{
|
||||
MainActivity parent;
|
||||
|
||||
class SettingsMenu {
|
||||
public static void showConfig(final MainActivity p, final boolean firstStart) {
|
||||
}
|
||||
}
|
||||
|
||||
class RestartMainActivity extends Activity {
|
||||
// For compatibility with SDL 1.2 code
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
public Advertisement(MainActivity p)
|
||||
{
|
||||
parent = p;
|
||||
}
|
||||
|
||||
public static final String ACTIVITY_AUTODETECT_SCREEN_ORIENTATION = "libsdl.org.ACTIVITY_AUTODETECT_SCREEN_ORIENTATION";
|
||||
public static final String SDL_RESTART_PARAMS = "SDL_RESTART_PARAMS";
|
||||
}
|
||||
public View getView()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
class DemoGLSurfaceView {
|
||||
static void SetupTouchscreenKeyboardGraphics(Activity p) {
|
||||
public void requestNewAd()
|
||||
{
|
||||
}
|
||||
}
|
||||
307
project/javaSDL2/Audio.java
Normal file
307
project/javaSDL2/Audio.java
Normal file
@@ -0,0 +1,307 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.media.AudioTrack;
|
||||
import android.media.AudioManager;
|
||||
import android.media.AudioFormat;
|
||||
import android.media.AudioRecord;
|
||||
import android.media.MediaRecorder.AudioSource;
|
||||
import java.io.*;
|
||||
import android.util.Log;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
|
||||
|
||||
class AudioThread
|
||||
{
|
||||
|
||||
private MainActivity mParent;
|
||||
private AudioTrack mAudio;
|
||||
private byte[] mAudioBuffer;
|
||||
private int mVirtualBufSize;
|
||||
|
||||
public AudioThread(MainActivity parent)
|
||||
{
|
||||
mParent = parent;
|
||||
mAudio = null;
|
||||
mAudioBuffer = null;
|
||||
//nativeAudioInitJavaCallbacks();
|
||||
}
|
||||
|
||||
public int fillBuffer()
|
||||
{
|
||||
if( mParent.isPaused() )
|
||||
{
|
||||
try{
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {}
|
||||
}
|
||||
else
|
||||
{
|
||||
//if( Globals.AudioBufferConfig == 0 ) // Gives too much spam to logcat, makes things worse
|
||||
// mAudio.flush();
|
||||
|
||||
mAudio.write( mAudioBuffer, 0, mVirtualBufSize );
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int initAudio(int rate, int channels, int encoding, int bufSize)
|
||||
{
|
||||
if( mAudio == null )
|
||||
{
|
||||
channels = ( channels == 1 ) ? AudioFormat.CHANNEL_CONFIGURATION_MONO :
|
||||
AudioFormat.CHANNEL_CONFIGURATION_STEREO;
|
||||
encoding = ( encoding == 1 ) ? AudioFormat.ENCODING_PCM_16BIT :
|
||||
AudioFormat.ENCODING_PCM_8BIT;
|
||||
|
||||
mVirtualBufSize = bufSize;
|
||||
|
||||
if( AudioTrack.getMinBufferSize( rate, channels, encoding ) > bufSize )
|
||||
bufSize = AudioTrack.getMinBufferSize( rate, channels, encoding );
|
||||
|
||||
if(Globals.AudioBufferConfig != 0) { // application's choice - use minimal buffer
|
||||
bufSize = (int)((float)bufSize * (((float)(Globals.AudioBufferConfig - 1) * 2.5f) + 1.0f));
|
||||
mVirtualBufSize = bufSize;
|
||||
}
|
||||
mAudioBuffer = new byte[bufSize];
|
||||
|
||||
mAudio = new AudioTrack(AudioManager.STREAM_MUSIC,
|
||||
rate,
|
||||
channels,
|
||||
encoding,
|
||||
bufSize,
|
||||
AudioTrack.MODE_STREAM );
|
||||
mAudio.play();
|
||||
}
|
||||
return mVirtualBufSize;
|
||||
}
|
||||
|
||||
public byte[] getBuffer()
|
||||
{
|
||||
return mAudioBuffer;
|
||||
}
|
||||
|
||||
public int deinitAudio()
|
||||
{
|
||||
if( mAudio != null )
|
||||
{
|
||||
mAudio.stop();
|
||||
mAudio.release();
|
||||
mAudio = null;
|
||||
}
|
||||
mAudioBuffer = null;
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int initAudioThread()
|
||||
{
|
||||
// Make audio thread priority higher so audio thread won't get underrun
|
||||
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int pauseAudioPlayback()
|
||||
{
|
||||
if( mAudio != null )
|
||||
{
|
||||
mAudio.pause();
|
||||
}
|
||||
if( mRecordThread != null )
|
||||
{
|
||||
mRecordThread.pauseRecording();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int resumeAudioPlayback()
|
||||
{
|
||||
if( mAudio != null )
|
||||
{
|
||||
mAudio.play();
|
||||
}
|
||||
if( mRecordThread != null )
|
||||
{
|
||||
mRecordThread.resumeRecording();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
private native int nativeAudioInitJavaCallbacks();
|
||||
|
||||
// ----- Audio recording -----
|
||||
|
||||
private RecordingThread mRecordThread = null;
|
||||
private AudioRecord mRecorder = null;
|
||||
private int mRecorderBufferSize = 0;
|
||||
|
||||
private byte[] startRecording(int rate, int channels, int encoding, int bufsize)
|
||||
{
|
||||
if( mRecordThread == null )
|
||||
{
|
||||
mRecordThread = new RecordingThread();
|
||||
mRecordThread.start();
|
||||
}
|
||||
if( !mRecordThread.isStopped() )
|
||||
{
|
||||
Log.i("SDL", "SDL: error: application already opened audio recording device");
|
||||
return null;
|
||||
}
|
||||
|
||||
mRecordThread.init(bufsize);
|
||||
|
||||
int channelConfig = ( channels == 1 ) ? AudioFormat.CHANNEL_IN_MONO :
|
||||
AudioFormat.CHANNEL_IN_STEREO;
|
||||
int encodingConfig = ( encoding == 1 ) ? AudioFormat.ENCODING_PCM_16BIT :
|
||||
AudioFormat.ENCODING_PCM_8BIT;
|
||||
|
||||
int minBufDevice = AudioRecord.getMinBufferSize(rate, channelConfig, encodingConfig);
|
||||
int minBufferSize = Math.max(bufsize * 8, minBufDevice + (bufsize - (minBufDevice % bufsize)));
|
||||
Log.i("SDL", "SDL: app opened recording device, rate " + rate + " channels " + channels + " sample size " + (encoding+1) + " bufsize " + bufsize + " internal bufsize " + minBufferSize);
|
||||
if( mRecorder == null || mRecorder.getSampleRate() != rate ||
|
||||
mRecorder.getChannelCount() != channels ||
|
||||
mRecorder.getAudioFormat() != encodingConfig ||
|
||||
mRecorderBufferSize != minBufferSize )
|
||||
{
|
||||
if( mRecorder != null )
|
||||
mRecorder.release();
|
||||
mRecorder = null;
|
||||
try {
|
||||
mRecorder = new AudioRecord(AudioSource.DEFAULT, rate, channelConfig, encodingConfig, minBufferSize);
|
||||
mRecorderBufferSize = minBufferSize;
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.i("SDL", "SDL: error: failed to open recording device!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.i("SDL", "SDL: reusing old recording device");
|
||||
}
|
||||
mRecordThread.startRecording();
|
||||
return mRecordThread.mRecordBuffer;
|
||||
}
|
||||
|
||||
private void stopRecording()
|
||||
{
|
||||
if( mRecordThread == null || mRecordThread.isStopped() )
|
||||
{
|
||||
Log.i("SDL", "SDL: error: application already closed audio recording device");
|
||||
return;
|
||||
}
|
||||
mRecordThread.stopRecording();
|
||||
Log.i("SDL", "SDL: app closed recording device");
|
||||
}
|
||||
|
||||
private class RecordingThread extends Thread
|
||||
{
|
||||
private boolean stopped = true;
|
||||
byte[] mRecordBuffer;
|
||||
private Semaphore waitStarted = new Semaphore(0);
|
||||
private boolean sleep = false;
|
||||
|
||||
RecordingThread()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
void init(int bufsize)
|
||||
{
|
||||
if( mRecordBuffer == null || mRecordBuffer.length != bufsize )
|
||||
mRecordBuffer = new byte[bufsize];
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
while( true )
|
||||
{
|
||||
waitStarted.acquireUninterruptibly();
|
||||
waitStarted.drainPermits();
|
||||
stopped = false;
|
||||
sleep = false;
|
||||
|
||||
while( !sleep )
|
||||
{
|
||||
int got = mRecorder.read(mRecordBuffer, 0, mRecordBuffer.length);
|
||||
if( got != mRecordBuffer.length )
|
||||
{
|
||||
// Audio is stopped here, sleep a bit.
|
||||
try{
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.i("SDL", "SDL: nativeAudioRecordCallback with len " + mRecordBuffer.length);
|
||||
nativeAudioRecordCallback();
|
||||
//Log.i("SDL", "SDL: nativeAudioRecordCallback returned");
|
||||
}
|
||||
}
|
||||
|
||||
stopped = true;
|
||||
mRecorder.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public void startRecording()
|
||||
{
|
||||
mRecorder.startRecording();
|
||||
waitStarted.release();
|
||||
}
|
||||
public void stopRecording()
|
||||
{
|
||||
sleep = true;
|
||||
while( !stopped )
|
||||
{
|
||||
try{
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {}
|
||||
}
|
||||
}
|
||||
public void pauseRecording()
|
||||
{
|
||||
if( !stopped )
|
||||
mRecorder.stop();
|
||||
}
|
||||
public void resumeRecording()
|
||||
{
|
||||
if( !stopped )
|
||||
mRecorder.startRecording();
|
||||
}
|
||||
public boolean isStopped()
|
||||
{
|
||||
return stopped;
|
||||
}
|
||||
}
|
||||
|
||||
private native void nativeAudioRecordCallback();
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
../java/DataDownloader.java
|
||||
758
project/javaSDL2/DataDownloader.java
Normal file
758
project/javaSDL2/DataDownloader.java
Normal file
@@ -0,0 +1,758 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.os.Environment;
|
||||
|
||||
import android.widget.TextView;
|
||||
import org.apache.http.client.methods.*;
|
||||
import org.apache.http.*;
|
||||
import org.apache.http.params.BasicHttpParams;
|
||||
import org.apache.http.conn.*;
|
||||
import org.apache.http.conn.params.*;
|
||||
import org.apache.http.conn.scheme.*;
|
||||
import org.apache.http.conn.ssl.*;
|
||||
import org.apache.http.impl.*;
|
||||
import org.apache.http.impl.client.*;
|
||||
import org.apache.http.impl.conn.SingleClientConnManager;
|
||||
import java.security.cert.*;
|
||||
import java.security.SecureRandom;
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.util.zip.*;
|
||||
import java.io.*;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import java.lang.String;
|
||||
import android.text.SpannedString;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
|
||||
|
||||
class CountingInputStream extends BufferedInputStream
|
||||
{
|
||||
|
||||
private long bytesReadMark = 0;
|
||||
private long bytesRead = 0;
|
||||
|
||||
public CountingInputStream(InputStream in, int size) {
|
||||
|
||||
super(in, size);
|
||||
}
|
||||
|
||||
public CountingInputStream(InputStream in) {
|
||||
|
||||
super(in);
|
||||
}
|
||||
|
||||
public long getBytesRead() {
|
||||
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
public synchronized int read() throws IOException {
|
||||
|
||||
int read = super.read();
|
||||
if (read >= 0) {
|
||||
bytesRead++;
|
||||
}
|
||||
return read;
|
||||
}
|
||||
|
||||
public synchronized int read(byte[] b, int off, int len) throws IOException {
|
||||
|
||||
int read = super.read(b, off, len);
|
||||
if (read >= 0) {
|
||||
bytesRead += read;
|
||||
}
|
||||
return read;
|
||||
}
|
||||
|
||||
public synchronized long skip(long n) throws IOException {
|
||||
|
||||
long skipped = super.skip(n);
|
||||
if (skipped >= 0) {
|
||||
bytesRead += skipped;
|
||||
}
|
||||
return skipped;
|
||||
}
|
||||
|
||||
public synchronized void mark(int readlimit) {
|
||||
|
||||
super.mark(readlimit);
|
||||
bytesReadMark = bytesRead;
|
||||
}
|
||||
|
||||
public synchronized void reset() throws IOException {
|
||||
|
||||
super.reset();
|
||||
bytesRead = bytesReadMark;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class DataDownloader extends Thread
|
||||
{
|
||||
|
||||
public static final String DOWNLOAD_FLAG_FILENAME = "libsdl-DownloadFinished-";
|
||||
|
||||
class StatusWriter
|
||||
{
|
||||
private TextView Status;
|
||||
private MainActivity Parent;
|
||||
private SpannedString oldText = new SpannedString("");
|
||||
|
||||
public StatusWriter( TextView _Status, MainActivity _Parent )
|
||||
{
|
||||
Status = _Status;
|
||||
Parent = _Parent;
|
||||
}
|
||||
public void setParent( TextView _Status, MainActivity _Parent )
|
||||
{
|
||||
synchronized(DataDownloader.this) {
|
||||
Status = _Status;
|
||||
Parent = _Parent;
|
||||
setText( oldText.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
public void setText(final String str)
|
||||
{
|
||||
class Callback implements Runnable
|
||||
{
|
||||
public TextView Status;
|
||||
public SpannedString text;
|
||||
public void run()
|
||||
{
|
||||
Status.setText(text);
|
||||
}
|
||||
}
|
||||
synchronized(DataDownloader.this) {
|
||||
Callback cb = new Callback();
|
||||
oldText = new SpannedString(str);
|
||||
cb.text = new SpannedString(str);
|
||||
cb.Status = Status;
|
||||
if( Parent != null && Status != null )
|
||||
Parent.runOnUiThread(cb);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public DataDownloader( MainActivity _Parent, TextView _Status )
|
||||
{
|
||||
Parent = _Parent;
|
||||
Status = new StatusWriter( _Status, _Parent );
|
||||
//Status.setText( "Connecting to " + Globals.DataDownloadUrl );
|
||||
outFilesDir = Globals.DataDir;
|
||||
DownloadComplete = false;
|
||||
this.start();
|
||||
}
|
||||
|
||||
public void setStatusField(TextView _Status)
|
||||
{
|
||||
synchronized(this) {
|
||||
Status.setParent( _Status, Parent );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Parent.keyListener = new BackKeyListener(Parent);
|
||||
String [] downloadFiles = Globals.DataDownloadUrl;
|
||||
int total = 0;
|
||||
int count = 0;
|
||||
for( int i = 0; i < downloadFiles.length; i++ )
|
||||
{
|
||||
if( downloadFiles[i].length() > 0 &&
|
||||
( Globals.OptionalDataDownload.length > i && Globals.OptionalDataDownload[i] ) ||
|
||||
( Globals.OptionalDataDownload.length <= i && downloadFiles[i].indexOf("!") == 0 ) )
|
||||
total += 1;
|
||||
}
|
||||
for( int i = 0; i < downloadFiles.length; i++ )
|
||||
{
|
||||
if( downloadFiles[i].length() > 0 &&
|
||||
( Globals.OptionalDataDownload.length > i && Globals.OptionalDataDownload[i] ) ||
|
||||
( Globals.OptionalDataDownload.length <= i && downloadFiles[i].indexOf("!") == 0 ) )
|
||||
{
|
||||
if( ! DownloadDataFile(downloadFiles[i], DOWNLOAD_FLAG_FILENAME + String.valueOf(i) + ".flag", count+1, total, i) )
|
||||
{
|
||||
DownloadFailed = true;
|
||||
return;
|
||||
}
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
DownloadComplete = true;
|
||||
Parent.keyListener = null;
|
||||
initParent();
|
||||
}
|
||||
|
||||
public boolean DownloadDataFile(final String DataDownloadUrl, final String DownloadFlagFileName, int downloadCount, int downloadTotal, int downloadIndex)
|
||||
{
|
||||
DownloadCanBeResumed = false;
|
||||
Resources res = Parent.getResources();
|
||||
|
||||
String [] downloadUrls = DataDownloadUrl.split("[|]");
|
||||
if( downloadUrls.length < 2 )
|
||||
{
|
||||
Log.i("SDL", "Error: download string invalid: '" + DataDownloadUrl + "', your AndroidAppSettigns.cfg is broken");
|
||||
Status.setText( res.getString(R.string.error_dl_from, DataDownloadUrl) );
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean forceOverwrite = false;
|
||||
String path = getOutFilePath(DownloadFlagFileName);
|
||||
InputStream checkFile = null;
|
||||
try {
|
||||
checkFile = new FileInputStream( path );
|
||||
} catch( FileNotFoundException e ) {
|
||||
} catch( SecurityException e ) { };
|
||||
if( checkFile != null )
|
||||
{
|
||||
try {
|
||||
byte b[] = new byte[ Globals.DataDownloadUrl[downloadIndex].getBytes("UTF-8").length + 1 ];
|
||||
int readed = checkFile.read(b);
|
||||
String compare = "";
|
||||
if( readed > 0 )
|
||||
compare = new String( b, 0, readed, "UTF-8" );
|
||||
boolean matched = false;
|
||||
//Log.i("SDL", "Read URL: '" + compare + "'");
|
||||
for( int i = 1; i < downloadUrls.length; i++ )
|
||||
{
|
||||
//Log.i("SDL", "Comparing: '" + downloadUrls[i] + "'");
|
||||
if( compare.compareTo(downloadUrls[i]) == 0 )
|
||||
matched = true;
|
||||
}
|
||||
//Log.i("SDL", "Matched: " + String.valueOf(matched));
|
||||
if( ! matched )
|
||||
throw new IOException();
|
||||
Status.setText( res.getString(R.string.download_unneeded) );
|
||||
return true;
|
||||
} catch ( IOException e ) {
|
||||
forceOverwrite = true;
|
||||
new File(path).delete();
|
||||
}
|
||||
}
|
||||
checkFile = null;
|
||||
|
||||
// Create output directory (not necessary for phone storage)
|
||||
Log.i("SDL", "Downloading data to: '" + outFilesDir + "'");
|
||||
try {
|
||||
File outDir = new File( outFilesDir );
|
||||
if( !(outDir.exists() && outDir.isDirectory()) )
|
||||
outDir.mkdirs();
|
||||
OutputStream out = new FileOutputStream( getOutFilePath(".nomedia") );
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
catch( SecurityException e ) {}
|
||||
catch( FileNotFoundException e ) {}
|
||||
catch( IOException e ) {};
|
||||
|
||||
HttpResponse response = null, responseError = null;
|
||||
HttpGet request;
|
||||
long totalLen = 0;
|
||||
CountingInputStream stream;
|
||||
byte[] buf = new byte[16384];
|
||||
boolean DoNotUnzip = false;
|
||||
boolean FileInAssets = false;
|
||||
String url = "";
|
||||
long partialDownloadLen = 0;
|
||||
|
||||
int downloadUrlIndex = 1;
|
||||
while( downloadUrlIndex < downloadUrls.length )
|
||||
{
|
||||
Log.i("SDL", "Processing download " + downloadUrls[downloadUrlIndex]);
|
||||
url = new String(downloadUrls[downloadUrlIndex]);
|
||||
DoNotUnzip = false;
|
||||
if(url.indexOf(":") == 0)
|
||||
{
|
||||
path = getOutFilePath(url.substring( 1, url.indexOf(":", 1) ));
|
||||
url = url.substring( url.indexOf(":", 1) + 1 );
|
||||
DoNotUnzip = true;
|
||||
DownloadCanBeResumed = true;
|
||||
File partialDownload = new File( path );
|
||||
if( partialDownload.exists() && !partialDownload.isDirectory() && !forceOverwrite )
|
||||
partialDownloadLen = partialDownload.length();
|
||||
}
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.connecting_to, url) );
|
||||
if( url.indexOf("http://") == -1 && url.indexOf("https://") == -1 ) // File inside assets
|
||||
{
|
||||
InputStream stream1 = null;
|
||||
try {
|
||||
stream1 = Parent.getAssets().open(url);
|
||||
stream1.close();
|
||||
} catch( Exception e ) {
|
||||
try {
|
||||
stream1 = Parent.getAssets().open(url + "000");
|
||||
stream1.close();
|
||||
} catch( Exception ee ) {
|
||||
Log.i("SDL", "Failed to open file in assets: " + url);
|
||||
downloadUrlIndex++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
FileInAssets = true;
|
||||
Log.i("SDL", "Fetching file from assets: " + url);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.i("SDL", "Connecting to: " + url);
|
||||
request = new HttpGet(url);
|
||||
request.addHeader("Accept", "*/*");
|
||||
if( partialDownloadLen > 0 ) {
|
||||
request.addHeader("Range", "bytes=" + partialDownloadLen + "-");
|
||||
Log.i("SDL", "Trying to resume download at pos " + partialDownloadLen);
|
||||
}
|
||||
try {
|
||||
DefaultHttpClient client = HttpWithDisabledSslCertCheck();
|
||||
client.getParams().setBooleanParameter("http.protocol.handle-redirects", true);
|
||||
response = client.execute(request);
|
||||
} catch (IOException e) {
|
||||
Log.i("SDL", "Failed to connect to " + url);
|
||||
downloadUrlIndex++;
|
||||
};
|
||||
if( response != null )
|
||||
{
|
||||
if( response.getStatusLine().getStatusCode() != 200 && response.getStatusLine().getStatusCode() != 206 )
|
||||
{
|
||||
Log.i("SDL", "Failed to connect to " + url + " with error " + response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
|
||||
responseError = response;
|
||||
response = null;
|
||||
downloadUrlIndex++;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( FileInAssets )
|
||||
{
|
||||
int multipartCounter = 0;
|
||||
InputStream multipart = null;
|
||||
while( true )
|
||||
{
|
||||
try {
|
||||
// Make string ".zip000", ".zip001" etc for multipart archives
|
||||
String url1 = url + String.format("%03d", multipartCounter);
|
||||
CountingInputStream stream1 = new CountingInputStream(Parent.getAssets().open(url1), 8192);
|
||||
while( stream1.skip(65536) > 0 ) { };
|
||||
totalLen += stream1.getBytesRead();
|
||||
stream1.close();
|
||||
InputStream s = Parent.getAssets().open(url1);
|
||||
if( multipart == null )
|
||||
multipart = s;
|
||||
else
|
||||
multipart = new SequenceInputStream(multipart, s);
|
||||
Log.i("SDL", "Multipart archive found: " + url1);
|
||||
} catch( IOException e ) {
|
||||
break;
|
||||
}
|
||||
multipartCounter += 1;
|
||||
}
|
||||
if( multipart != null )
|
||||
stream = new CountingInputStream(multipart, 8192);
|
||||
else
|
||||
{
|
||||
try {
|
||||
stream = new CountingInputStream(Parent.getAssets().open(url), 8192);
|
||||
while( stream.skip(65536) > 0 ) { };
|
||||
totalLen += stream.getBytesRead();
|
||||
stream.close();
|
||||
stream = new CountingInputStream(Parent.getAssets().open(url), 8192);
|
||||
} catch( IOException e ) {
|
||||
Log.i("SDL", "Unpacking from assets '" + url + "' - error: " + e.toString());
|
||||
Status.setText( res.getString(R.string.error_dl_from, url) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( response == null )
|
||||
{
|
||||
Log.i("SDL", "Error connecting to " + url);
|
||||
Status.setText( res.getString(R.string.failed_connecting_to, url) + (responseError == null ? "" : ": " + responseError.getStatusLine().getStatusCode() + " " + responseError.getStatusLine().getReasonPhrase()) );
|
||||
return false;
|
||||
}
|
||||
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_from, url) );
|
||||
totalLen = response.getEntity().getContentLength();
|
||||
try {
|
||||
stream = new CountingInputStream(response.getEntity().getContent(), 8192);
|
||||
} catch( java.io.IOException e ) {
|
||||
Status.setText( res.getString(R.string.error_dl_from, url) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
long updateStatusTime = 0;
|
||||
|
||||
if(DoNotUnzip)
|
||||
{
|
||||
Log.i("SDL", "Saving file '" + path + "'");
|
||||
OutputStream out = null;
|
||||
try {
|
||||
try {
|
||||
File outDir = new File( path.substring(0, path.lastIndexOf("/") ));
|
||||
if( !(outDir.exists() && outDir.isDirectory()) )
|
||||
outDir.mkdirs();
|
||||
} catch( SecurityException e ) { };
|
||||
|
||||
if( partialDownloadLen > 0 )
|
||||
{
|
||||
try {
|
||||
Header[] range = response.getHeaders("Content-Range");
|
||||
if( range.length > 0 && range[0].getValue().indexOf("bytes") == 0 )
|
||||
{
|
||||
//Log.i("SDL", "Resuming download of file '" + path + "': Content-Range: " + range[0].getValue());
|
||||
String[] skippedBytes = range[0].getValue().split("/")[0].split("-")[0].split(" ");
|
||||
if( skippedBytes.length >= 2 && Long.parseLong(skippedBytes[1]) == partialDownloadLen )
|
||||
{
|
||||
out = new FileOutputStream( path, true );
|
||||
Log.i("SDL", "Resuming download of file '" + path + "' at pos " + partialDownloadLen);
|
||||
}
|
||||
}
|
||||
else
|
||||
Log.i("SDL", "Server does not support partial downloads. " + (range.length == 0 ? "" : range[0].getValue()));
|
||||
} catch (Exception e) { }
|
||||
}
|
||||
if( out == null )
|
||||
{
|
||||
out = new FileOutputStream( path );
|
||||
partialDownloadLen = 0;
|
||||
}
|
||||
} catch( FileNotFoundException e ) {
|
||||
Log.i("SDL", "Saving file '" + path + "' - error creating output file: " + e.toString());
|
||||
} catch( SecurityException e ) {
|
||||
Log.i("SDL", "Saving file '" + path + "' - error creating output file: " + e.toString());
|
||||
};
|
||||
if( out == null )
|
||||
{
|
||||
Status.setText( res.getString(R.string.error_write, path) );
|
||||
Log.i("SDL", "Saving file '" + path + "' - error creating output file");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
int len = stream.read(buf);
|
||||
while (len >= 0)
|
||||
{
|
||||
if(len > 0)
|
||||
out.write(buf, 0, len);
|
||||
len = stream.read(buf);
|
||||
|
||||
float percent = 0.0f;
|
||||
if( totalLen > 0 )
|
||||
percent = (stream.getBytesRead() + partialDownloadLen) * 100.0f / (totalLen + partialDownloadLen);
|
||||
if( System.currentTimeMillis() > updateStatusTime + 1000 )
|
||||
{
|
||||
updateStatusTime = System.currentTimeMillis();
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_progress, percent, path) );
|
||||
}
|
||||
}
|
||||
out.flush();
|
||||
out.close();
|
||||
out = null;
|
||||
} catch( java.io.IOException e ) {
|
||||
Status.setText( res.getString(R.string.error_write, path) + ": " + e.getMessage() );
|
||||
Log.i("SDL", "Saving file '" + path + "' - error writing: " + e.toString());
|
||||
return false;
|
||||
}
|
||||
Log.i("SDL", "Saving file '" + path + "' done");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.i("SDL", "Reading from zip file '" + url + "'");
|
||||
ZipInputStream zip = new ZipInputStream(stream);
|
||||
|
||||
while(true)
|
||||
{
|
||||
ZipEntry entry = null;
|
||||
try {
|
||||
entry = zip.getNextEntry();
|
||||
if( entry != null )
|
||||
Log.i("SDL", "Reading from zip file '" + url + "' entry '" + entry.getName() + "'");
|
||||
} catch( java.io.IOException e ) {
|
||||
Status.setText( res.getString(R.string.error_dl_from, url) );
|
||||
Log.i("SDL", "Error reading from zip file '" + url + "': " + e.toString());
|
||||
return false;
|
||||
}
|
||||
if( entry == null )
|
||||
{
|
||||
Log.i("SDL", "Reading from zip file '" + url + "' finished");
|
||||
break;
|
||||
}
|
||||
if( entry.isDirectory() )
|
||||
{
|
||||
Log.i("SDL", "Creating dir '" + getOutFilePath(entry.getName()) + "'");
|
||||
try {
|
||||
File outDir = new File( getOutFilePath(entry.getName()) );
|
||||
if( !(outDir.exists() && outDir.isDirectory()) )
|
||||
outDir.mkdirs();
|
||||
} catch( SecurityException e ) { };
|
||||
continue;
|
||||
}
|
||||
|
||||
OutputStream out = null;
|
||||
path = getOutFilePath(entry.getName());
|
||||
float percent = 0.0f;
|
||||
|
||||
Log.i("SDL", "Saving file '" + path + "'");
|
||||
|
||||
try {
|
||||
File outDir = new File( path.substring(0, path.lastIndexOf("/") ));
|
||||
if( !(outDir.exists() && outDir.isDirectory()) )
|
||||
outDir.mkdirs();
|
||||
} catch( SecurityException e ) { };
|
||||
|
||||
try {
|
||||
CheckedInputStream check = new CheckedInputStream( new FileInputStream(path), new CRC32() );
|
||||
while( check.read(buf, 0, buf.length) >= 0 ) {};
|
||||
check.close();
|
||||
if( check.getChecksum().getValue() != entry.getCrc() )
|
||||
{
|
||||
File ff = new File(path);
|
||||
ff.delete();
|
||||
throw new Exception();
|
||||
}
|
||||
Log.i("SDL", "File '" + path + "' exists and passed CRC check - not overwriting it");
|
||||
if( totalLen > 0 )
|
||||
percent = stream.getBytesRead() * 100.0f / totalLen;
|
||||
if( System.currentTimeMillis() > updateStatusTime + 1000 )
|
||||
{
|
||||
updateStatusTime = System.currentTimeMillis();
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_progress, percent, path) );
|
||||
}
|
||||
continue;
|
||||
} catch( Exception e ) { }
|
||||
|
||||
try {
|
||||
out = new FileOutputStream( path );
|
||||
} catch( FileNotFoundException e ) {
|
||||
Log.i("SDL", "Saving file '" + path + "' - cannot create file: " + e.toString());
|
||||
} catch( SecurityException e ) {
|
||||
Log.i("SDL", "Saving file '" + path + "' - cannot create file: " + e.toString());
|
||||
};
|
||||
if( out == null )
|
||||
{
|
||||
Status.setText( res.getString(R.string.error_write, path) );
|
||||
Log.i("SDL", "Saving file '" + path + "' - cannot create file");
|
||||
return false;
|
||||
}
|
||||
|
||||
if( totalLen > 0 )
|
||||
percent = stream.getBytesRead() * 100.0f / totalLen;
|
||||
if( System.currentTimeMillis() > updateStatusTime + 1000 )
|
||||
{
|
||||
updateStatusTime = System.currentTimeMillis();
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_progress, percent, path) );
|
||||
}
|
||||
|
||||
try {
|
||||
int len = zip.read(buf);
|
||||
while (len >= 0)
|
||||
{
|
||||
if(len > 0)
|
||||
out.write(buf, 0, len);
|
||||
len = zip.read(buf);
|
||||
|
||||
percent = 0.0f;
|
||||
if( totalLen > 0 )
|
||||
percent = stream.getBytesRead() * 100.0f / totalLen;
|
||||
if( System.currentTimeMillis() > updateStatusTime + 1000 )
|
||||
{
|
||||
updateStatusTime = System.currentTimeMillis();
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_progress, percent, path) );
|
||||
}
|
||||
}
|
||||
out.flush();
|
||||
out.close();
|
||||
out = null;
|
||||
} catch( java.io.IOException e ) {
|
||||
Status.setText( res.getString(R.string.error_write, path) + ": " + e.getMessage() );
|
||||
Log.i("SDL", "Saving file '" + path + "' - error writing or downloading: " + e.toString());
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
long count = 0, ret = 0;
|
||||
CheckedInputStream check = new CheckedInputStream( new FileInputStream(path), new CRC32() );
|
||||
while( ret >= 0 )
|
||||
{
|
||||
count += ret;
|
||||
ret = check.read(buf, 0, buf.length);
|
||||
}
|
||||
check.close();
|
||||
if( check.getChecksum().getValue() != entry.getCrc() || count != entry.getSize() )
|
||||
{
|
||||
File ff = new File(path);
|
||||
ff.delete();
|
||||
Log.i("SDL", "Saving file '" + path + "' - CRC check failed, ZIP: " +
|
||||
String.format("%x", entry.getCrc()) + " actual file: " + String.format("%x", check.getChecksum().getValue()) +
|
||||
" file size in ZIP: " + entry.getSize() + " actual size " + count );
|
||||
throw new Exception();
|
||||
}
|
||||
} catch( Exception e ) {
|
||||
Status.setText( res.getString(R.string.error_write, path) + ": " + e.getMessage() );
|
||||
return false;
|
||||
}
|
||||
Log.i("SDL", "Saving file '" + path + "' done");
|
||||
}
|
||||
};
|
||||
|
||||
OutputStream out = null;
|
||||
path = getOutFilePath(DownloadFlagFileName);
|
||||
try {
|
||||
out = new FileOutputStream( path );
|
||||
out.write(downloadUrls[downloadUrlIndex].getBytes("UTF-8"));
|
||||
out.flush();
|
||||
out.close();
|
||||
} catch( FileNotFoundException e ) {
|
||||
} catch( SecurityException e ) {
|
||||
} catch( java.io.IOException e ) {
|
||||
Status.setText( res.getString(R.string.error_write, path) + ": " + e.getMessage() );
|
||||
return false;
|
||||
};
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_finished) );
|
||||
|
||||
try {
|
||||
stream.close();
|
||||
} catch( java.io.IOException e ) {
|
||||
};
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
private void initParent()
|
||||
{
|
||||
class Callback implements Runnable
|
||||
{
|
||||
public MainActivity Parent;
|
||||
public void run()
|
||||
{
|
||||
Parent.initSDL();
|
||||
}
|
||||
}
|
||||
Callback cb = new Callback();
|
||||
synchronized(this) {
|
||||
cb.Parent = Parent;
|
||||
if(Parent != null)
|
||||
Parent.runOnUiThread(cb);
|
||||
}
|
||||
}
|
||||
|
||||
private String getOutFilePath(final String filename)
|
||||
{
|
||||
return outFilesDir + "/" + filename;
|
||||
};
|
||||
|
||||
private static DefaultHttpClient HttpWithDisabledSslCertCheck()
|
||||
{
|
||||
return new DefaultHttpClient();
|
||||
// This code does not work
|
||||
/*
|
||||
HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
|
||||
|
||||
DefaultHttpClient client = new DefaultHttpClient();
|
||||
|
||||
SchemeRegistry registry = new SchemeRegistry();
|
||||
SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
|
||||
socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
|
||||
registry.register(new Scheme("https", socketFactory, 443));
|
||||
SingleClientConnManager mgr = new SingleClientConnManager(client.getParams(), registry);
|
||||
DefaultHttpClient http = new DefaultHttpClient(mgr, client.getParams());
|
||||
|
||||
HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
|
||||
|
||||
return http;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
public class BackKeyListener implements MainActivity.KeyEventsListener
|
||||
{
|
||||
MainActivity p;
|
||||
public BackKeyListener(MainActivity _p)
|
||||
{
|
||||
p = _p;
|
||||
}
|
||||
|
||||
public void onKeyEvent(final int keyCode)
|
||||
{
|
||||
if( DownloadFailed )
|
||||
System.exit(1);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.cancel_download));
|
||||
builder.setMessage(p.getResources().getString(R.string.cancel_download) + (DownloadCanBeResumed ? " " + p.getResources().getString(R.string.cancel_download_resume) : ""));
|
||||
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.yes), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
System.exit(1);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(p.getResources().getString(R.string.no), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
public StatusWriter Status;
|
||||
public boolean DownloadComplete = false;
|
||||
public boolean DownloadFailed = false;
|
||||
public boolean DownloadCanBeResumed = false;
|
||||
private MainActivity Parent;
|
||||
private String outFilesDir = null;
|
||||
}
|
||||
|
||||
1278
project/javaSDL2/GLSurfaceView_SDL.java
Normal file
1278
project/javaSDL2/GLSurfaceView_SDL.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
../java/Globals.java
|
||||
126
project/javaSDL2/Globals.java
Normal file
126
project/javaSDL2/Globals.java
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
/*import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import java.util.Vector;*/
|
||||
import android.view.KeyEvent;
|
||||
|
||||
class Globals
|
||||
{
|
||||
// These config options are modified by ChangeAppsettings.sh script - see the detailed descriptions there
|
||||
public static String ApplicationName = "CommanderGenius";
|
||||
public static String AppLibraries[] = { "sdl-1.2", };
|
||||
public static String AppMainLibraries[] = { "application", "sdl_main" };
|
||||
public static final boolean Using_SDL_1_3 = false;
|
||||
public static final boolean Using_SDL_2_0 = false;
|
||||
public static String[] DataDownloadUrl = { "Data files are 2 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-data.zip/download", "High-quality GFX and music - 40 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-hqp.zip/download" };
|
||||
public static int VideoDepthBpp = 16;
|
||||
public static boolean SwVideoMode = false;
|
||||
public static boolean NeedDepthBuffer = false;
|
||||
public static boolean NeedStencilBuffer = false;
|
||||
public static boolean NeedGles2 = false;
|
||||
public static boolean CompatibilityHacksVideo = false;
|
||||
public static boolean CompatibilityHacksStaticInit = false;
|
||||
public static boolean CompatibilityHacksTextInputEmulatesHwKeyboard = false;
|
||||
public static boolean HorizontalOrientation = true;
|
||||
public static boolean KeepAspectRatioDefaultSetting = false;
|
||||
public static boolean InhibitSuspend = false;
|
||||
public static String ReadmeText = "^You may press \"Home\" now - the data will be downloaded in background".replace("^","\n");
|
||||
public static String CommandLine = "";
|
||||
public static boolean AppUsesMouse = false;
|
||||
public static boolean AppNeedsTwoButtonMouse = false;
|
||||
public static boolean ForceRelativeMouseMode = false; // If both on-screen keyboard and mouse are needed, this will only set the default setting, user may override it later
|
||||
public static boolean ShowMouseCursor = false;
|
||||
public static boolean AppNeedsArrowKeys = true;
|
||||
public static boolean AppNeedsTextInput = true;
|
||||
public static boolean AppUsesJoystick = false;
|
||||
public static boolean AppUsesSecondJoystick = false;
|
||||
public static boolean AppUsesAccelerometer = false;
|
||||
public static boolean AppUsesGyroscope = false;
|
||||
public static boolean AppUsesMultitouch = false;
|
||||
public static boolean NonBlockingSwapBuffers = false;
|
||||
public static boolean ResetSdlConfigForThisVersion = false;
|
||||
public static String DeleteFilesOnUpgrade = "";
|
||||
public static int AppTouchscreenKeyboardKeysAmount = 4;
|
||||
public static int AppTouchscreenKeyboardKeysAmountAutoFire = 1;
|
||||
public static String[] AppTouchscreenKeyboardKeysNames = "Fire Shoot Switch_weapon Jump Run Hide/Seek".split(" ");
|
||||
public static int StartupMenuButtonTimeout = 3000;
|
||||
public static int AppMinimumRAM = 0;
|
||||
public static SettingsMenu.Menu HiddenMenuOptions [] = {}; // If you see error here - update HiddenMenuOptions in your AndroidAppSettings.cfg: change OptionalDownloadConfig to SettingsMenuMisc.OptionalDownloadConfig etc.
|
||||
public static SettingsMenu.Menu FirstStartMenuOptions [] = { new SettingsMenuMisc.ShowReadme(), (AppUsesMouse && ! ForceRelativeMouseMode ? new SettingsMenuMouse.DisplaySizeConfig() : new SettingsMenu.DummyMenu()), new SettingsMenuMisc.OptionalDownloadConfig(), new SettingsMenuMisc.GyroscopeCalibration() };
|
||||
public static String AdmobPublisherId = "";
|
||||
public static String AdmobTestDeviceId = "";
|
||||
public static String AdmobBannerSize = "";
|
||||
|
||||
// Phone-specific config, modified by user in "Change phone config" startup dialog, TODO: move this to settings
|
||||
public static boolean DownloadToSdcard = true;
|
||||
public static boolean PhoneHasTrackball = false;
|
||||
public static boolean PhoneHasArrowKeys = false;
|
||||
public static boolean UseAccelerometerAsArrowKeys = false;
|
||||
public static boolean UseTouchscreenKeyboard = true;
|
||||
public static int TouchscreenKeyboardSize = 1;
|
||||
public static final int TOUCHSCREEN_KEYBOARD_CUSTOM = 4;
|
||||
public static int TouchscreenKeyboardDrawSize = 1;
|
||||
public static int TouchscreenKeyboardTheme = 2;
|
||||
public static int TouchscreenKeyboardTransparency = 2;
|
||||
public static int AccelerometerSensitivity = 2;
|
||||
public static int AccelerometerCenterPos = 2;
|
||||
public static int TrackballDampening = 0;
|
||||
public static int AudioBufferConfig = 0;
|
||||
public static boolean OptionalDataDownload[] = null;
|
||||
public static int LeftClickMethod = Mouse.LEFT_CLICK_NORMAL;
|
||||
public static int LeftClickKey = KeyEvent.KEYCODE_DPAD_CENTER;
|
||||
public static int LeftClickTimeout = 3;
|
||||
public static int RightClickTimeout = 4;
|
||||
public static int RightClickMethod = AppNeedsTwoButtonMouse ? Mouse.RIGHT_CLICK_WITH_MULTITOUCH : Mouse.RIGHT_CLICK_NONE;
|
||||
public static int RightClickKey = KeyEvent.KEYCODE_MENU;
|
||||
public static boolean MoveMouseWithJoystick = false;
|
||||
public static int MoveMouseWithJoystickSpeed = 0;
|
||||
public static int MoveMouseWithJoystickAccel = 0;
|
||||
public static boolean ClickMouseWithDpad = false;
|
||||
public static boolean RelativeMouseMovement = ForceRelativeMouseMode; // Laptop touchpad mode
|
||||
public static int RelativeMouseMovementSpeed = 2;
|
||||
public static int RelativeMouseMovementAccel = 0;
|
||||
public static int ShowScreenUnderFinger = Mouse.ZOOM_NONE;
|
||||
public static boolean KeepAspectRatio = KeepAspectRatioDefaultSetting;
|
||||
public static int ClickScreenPressure = 0;
|
||||
public static int ClickScreenTouchspotSize = 0;
|
||||
public static int RemapHwKeycode[] = new int[SDL_Keys.JAVA_KEYCODE_LAST];
|
||||
public static int RemapScreenKbKeycode[] = new int[6];
|
||||
public static int ScreenKbControlsLayout[][] = AppUsesSecondJoystick ? // Values for 800x480 resolution
|
||||
new int[][] { { 0, 303, 177, 480 }, { 0, 0, 48, 48 }, { 400, 392, 488, 480 }, { 312, 392, 400, 480 }, { 400, 304, 488, 392 }, { 312, 304, 400, 392 }, { 400, 216, 488, 304 }, { 312, 216, 400, 304 }, { 623, 303, 800, 480 } } :
|
||||
new int[][] { { 0, 303, 177, 480 }, { 0, 0, 48, 48 }, { 712, 392, 800, 480 }, { 624, 392, 712, 480 }, { 712, 304, 800, 392 }, { 624, 304, 712, 392 }, { 712, 216, 800, 304 }, { 624, 216, 712, 304 } };
|
||||
public static boolean ScreenKbControlsShown[] = new boolean[ScreenKbControlsLayout.length]; // Also joystick and text input button added
|
||||
public static int RemapMultitouchGestureKeycode[] = new int[4];
|
||||
public static boolean MultitouchGesturesUsed[] = new boolean[4];
|
||||
public static int MultitouchGestureSensitivity = 1;
|
||||
public static int TouchscreenCalibration[] = new int[4];
|
||||
public static String DataDir = new String("");
|
||||
public static boolean VideoLinearFilter = true;
|
||||
public static boolean MultiThreadedVideo = false;
|
||||
public static boolean BrokenLibCMessageShown = false;
|
||||
// Gyroscope calibration
|
||||
public static float gyro_x1, gyro_x2, gyro_xc, gyro_y1, gyro_y2, gyro_yc, gyro_z1, gyro_z2, gyro_zc;
|
||||
public static boolean OuyaEmulation = false; // For debugging
|
||||
}
|
||||
592
project/javaSDL2/Keycodes.java
Normal file
592
project/javaSDL2/Keycodes.java
Normal file
@@ -0,0 +1,592 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import java.lang.String;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
|
||||
// Autogenerated by hand with a command:
|
||||
// grep 'SDLK_' SDL_keysym.h | sed 's/SDLK_\([a-zA-Z0-9_]\+\).*[=] \([0-9]\+\).*/public static final int SDLK_\1 = \2;/' >> Keycodes.java
|
||||
class SDL_1_2_Keycodes
|
||||
{
|
||||
public static final int SDLK_UNKNOWN = 0;
|
||||
public static final int SDLK_BACKSPACE = 8;
|
||||
public static final int SDLK_TAB = 9;
|
||||
public static final int SDLK_CLEAR = 12;
|
||||
public static final int SDLK_RETURN = 13;
|
||||
public static final int SDLK_PAUSE = 19;
|
||||
public static final int SDLK_ESCAPE = 27;
|
||||
public static final int SDLK_SPACE = 32;
|
||||
public static final int SDLK_EXCLAIM = 33;
|
||||
public static final int SDLK_QUOTEDBL = 34;
|
||||
public static final int SDLK_HASH = 35;
|
||||
public static final int SDLK_DOLLAR = 36;
|
||||
public static final int SDLK_AMPERSAND = 38;
|
||||
public static final int SDLK_QUOTE = 39;
|
||||
public static final int SDLK_LEFTPAREN = 40;
|
||||
public static final int SDLK_RIGHTPAREN = 41;
|
||||
public static final int SDLK_ASTERISK = 42;
|
||||
public static final int SDLK_PLUS = 43;
|
||||
public static final int SDLK_COMMA = 44;
|
||||
public static final int SDLK_MINUS = 45;
|
||||
public static final int SDLK_PERIOD = 46;
|
||||
public static final int SDLK_SLASH = 47;
|
||||
public static final int SDLK_0 = 48;
|
||||
public static final int SDLK_1 = 49;
|
||||
public static final int SDLK_2 = 50;
|
||||
public static final int SDLK_3 = 51;
|
||||
public static final int SDLK_4 = 52;
|
||||
public static final int SDLK_5 = 53;
|
||||
public static final int SDLK_6 = 54;
|
||||
public static final int SDLK_7 = 55;
|
||||
public static final int SDLK_8 = 56;
|
||||
public static final int SDLK_9 = 57;
|
||||
public static final int SDLK_COLON = 58;
|
||||
public static final int SDLK_SEMICOLON = 59;
|
||||
public static final int SDLK_LESS = 60;
|
||||
public static final int SDLK_EQUALS = 61;
|
||||
public static final int SDLK_GREATER = 62;
|
||||
public static final int SDLK_QUESTION = 63;
|
||||
public static final int SDLK_AT = 64;
|
||||
public static final int SDLK_LEFTBRACKET = 91;
|
||||
public static final int SDLK_BACKSLASH = 92;
|
||||
public static final int SDLK_RIGHTBRACKET = 93;
|
||||
public static final int SDLK_CARET = 94;
|
||||
public static final int SDLK_UNDERSCORE = 95;
|
||||
public static final int SDLK_BACKQUOTE = 96;
|
||||
public static final int SDLK_a = 97;
|
||||
public static final int SDLK_b = 98;
|
||||
public static final int SDLK_c = 99;
|
||||
public static final int SDLK_d = 100;
|
||||
public static final int SDLK_e = 101;
|
||||
public static final int SDLK_f = 102;
|
||||
public static final int SDLK_g = 103;
|
||||
public static final int SDLK_h = 104;
|
||||
public static final int SDLK_i = 105;
|
||||
public static final int SDLK_j = 106;
|
||||
public static final int SDLK_k = 107;
|
||||
public static final int SDLK_l = 108;
|
||||
public static final int SDLK_m = 109;
|
||||
public static final int SDLK_n = 110;
|
||||
public static final int SDLK_o = 111;
|
||||
public static final int SDLK_p = 112;
|
||||
public static final int SDLK_q = 113;
|
||||
public static final int SDLK_r = 114;
|
||||
public static final int SDLK_s = 115;
|
||||
public static final int SDLK_t = 116;
|
||||
public static final int SDLK_u = 117;
|
||||
public static final int SDLK_v = 118;
|
||||
public static final int SDLK_w = 119;
|
||||
public static final int SDLK_x = 120;
|
||||
public static final int SDLK_y = 121;
|
||||
public static final int SDLK_z = 122;
|
||||
public static final int SDLK_DELETE = 127;
|
||||
public static final int SDLK_WORLD_0 = 160;
|
||||
public static final int SDLK_WORLD_1 = 161;
|
||||
public static final int SDLK_WORLD_2 = 162;
|
||||
public static final int SDLK_WORLD_3 = 163;
|
||||
public static final int SDLK_WORLD_4 = 164;
|
||||
public static final int SDLK_WORLD_5 = 165;
|
||||
public static final int SDLK_WORLD_6 = 166;
|
||||
public static final int SDLK_WORLD_7 = 167;
|
||||
public static final int SDLK_WORLD_8 = 168;
|
||||
public static final int SDLK_WORLD_9 = 169;
|
||||
public static final int SDLK_WORLD_10 = 170;
|
||||
public static final int SDLK_WORLD_11 = 171;
|
||||
public static final int SDLK_WORLD_12 = 172;
|
||||
public static final int SDLK_WORLD_13 = 173;
|
||||
public static final int SDLK_WORLD_14 = 174;
|
||||
public static final int SDLK_WORLD_15 = 175;
|
||||
public static final int SDLK_WORLD_16 = 176;
|
||||
public static final int SDLK_WORLD_17 = 177;
|
||||
public static final int SDLK_WORLD_18 = 178;
|
||||
public static final int SDLK_WORLD_19 = 179;
|
||||
public static final int SDLK_WORLD_20 = 180;
|
||||
public static final int SDLK_WORLD_21 = 181;
|
||||
public static final int SDLK_WORLD_22 = 182;
|
||||
public static final int SDLK_WORLD_23 = 183;
|
||||
public static final int SDLK_WORLD_24 = 184;
|
||||
public static final int SDLK_WORLD_25 = 185;
|
||||
public static final int SDLK_WORLD_26 = 186;
|
||||
public static final int SDLK_WORLD_27 = 187;
|
||||
public static final int SDLK_WORLD_28 = 188;
|
||||
public static final int SDLK_WORLD_29 = 189;
|
||||
public static final int SDLK_WORLD_30 = 190;
|
||||
public static final int SDLK_WORLD_31 = 191;
|
||||
public static final int SDLK_WORLD_32 = 192;
|
||||
public static final int SDLK_WORLD_33 = 193;
|
||||
public static final int SDLK_WORLD_34 = 194;
|
||||
public static final int SDLK_WORLD_35 = 195;
|
||||
public static final int SDLK_WORLD_36 = 196;
|
||||
public static final int SDLK_WORLD_37 = 197;
|
||||
public static final int SDLK_WORLD_38 = 198;
|
||||
public static final int SDLK_WORLD_39 = 199;
|
||||
public static final int SDLK_WORLD_40 = 200;
|
||||
public static final int SDLK_WORLD_41 = 201;
|
||||
public static final int SDLK_WORLD_42 = 202;
|
||||
public static final int SDLK_WORLD_43 = 203;
|
||||
public static final int SDLK_WORLD_44 = 204;
|
||||
public static final int SDLK_WORLD_45 = 205;
|
||||
public static final int SDLK_WORLD_46 = 206;
|
||||
public static final int SDLK_WORLD_47 = 207;
|
||||
public static final int SDLK_WORLD_48 = 208;
|
||||
public static final int SDLK_WORLD_49 = 209;
|
||||
public static final int SDLK_WORLD_50 = 210;
|
||||
public static final int SDLK_WORLD_51 = 211;
|
||||
public static final int SDLK_WORLD_52 = 212;
|
||||
public static final int SDLK_WORLD_53 = 213;
|
||||
public static final int SDLK_WORLD_54 = 214;
|
||||
public static final int SDLK_WORLD_55 = 215;
|
||||
public static final int SDLK_WORLD_56 = 216;
|
||||
public static final int SDLK_WORLD_57 = 217;
|
||||
public static final int SDLK_WORLD_58 = 218;
|
||||
public static final int SDLK_WORLD_59 = 219;
|
||||
public static final int SDLK_WORLD_60 = 220;
|
||||
public static final int SDLK_WORLD_61 = 221;
|
||||
public static final int SDLK_WORLD_62 = 222;
|
||||
public static final int SDLK_WORLD_63 = 223;
|
||||
public static final int SDLK_WORLD_64 = 224;
|
||||
public static final int SDLK_WORLD_65 = 225;
|
||||
public static final int SDLK_WORLD_66 = 226;
|
||||
public static final int SDLK_WORLD_67 = 227;
|
||||
public static final int SDLK_WORLD_68 = 228;
|
||||
public static final int SDLK_WORLD_69 = 229;
|
||||
public static final int SDLK_WORLD_70 = 230;
|
||||
public static final int SDLK_WORLD_71 = 231;
|
||||
public static final int SDLK_WORLD_72 = 232;
|
||||
public static final int SDLK_WORLD_73 = 233;
|
||||
public static final int SDLK_WORLD_74 = 234;
|
||||
public static final int SDLK_WORLD_75 = 235;
|
||||
public static final int SDLK_WORLD_76 = 236;
|
||||
public static final int SDLK_WORLD_77 = 237;
|
||||
public static final int SDLK_WORLD_78 = 238;
|
||||
public static final int SDLK_WORLD_79 = 239;
|
||||
public static final int SDLK_WORLD_80 = 240;
|
||||
public static final int SDLK_WORLD_81 = 241;
|
||||
public static final int SDLK_WORLD_82 = 242;
|
||||
public static final int SDLK_WORLD_83 = 243;
|
||||
public static final int SDLK_WORLD_84 = 244;
|
||||
public static final int SDLK_WORLD_85 = 245;
|
||||
public static final int SDLK_WORLD_86 = 246;
|
||||
public static final int SDLK_WORLD_87 = 247;
|
||||
public static final int SDLK_WORLD_88 = 248;
|
||||
public static final int SDLK_WORLD_89 = 249;
|
||||
public static final int SDLK_WORLD_90 = 250;
|
||||
public static final int SDLK_WORLD_91 = 251;
|
||||
public static final int SDLK_WORLD_92 = 252;
|
||||
public static final int SDLK_WORLD_93 = 253;
|
||||
public static final int SDLK_WORLD_94 = 254;
|
||||
public static final int SDLK_WORLD_95 = 255;
|
||||
public static final int SDLK_KP0 = 256;
|
||||
public static final int SDLK_KP1 = 257;
|
||||
public static final int SDLK_KP2 = 258;
|
||||
public static final int SDLK_KP3 = 259;
|
||||
public static final int SDLK_KP4 = 260;
|
||||
public static final int SDLK_KP5 = 261;
|
||||
public static final int SDLK_KP6 = 262;
|
||||
public static final int SDLK_KP7 = 263;
|
||||
public static final int SDLK_KP8 = 264;
|
||||
public static final int SDLK_KP9 = 265;
|
||||
public static final int SDLK_KP_PERIOD = 266;
|
||||
public static final int SDLK_KP_DIVIDE = 267;
|
||||
public static final int SDLK_KP_MULTIPLY = 268;
|
||||
public static final int SDLK_KP_MINUS = 269;
|
||||
public static final int SDLK_KP_PLUS = 270;
|
||||
public static final int SDLK_KP_ENTER = 271;
|
||||
public static final int SDLK_KP_EQUALS = 272;
|
||||
public static final int SDLK_UP = 273;
|
||||
public static final int SDLK_DOWN = 274;
|
||||
public static final int SDLK_RIGHT = 275;
|
||||
public static final int SDLK_LEFT = 276;
|
||||
public static final int SDLK_INSERT = 277;
|
||||
public static final int SDLK_HOME = 278;
|
||||
public static final int SDLK_END = 279;
|
||||
public static final int SDLK_PAGEUP = 280;
|
||||
public static final int SDLK_PAGEDOWN = 281;
|
||||
public static final int SDLK_F1 = 282;
|
||||
public static final int SDLK_F2 = 283;
|
||||
public static final int SDLK_F3 = 284;
|
||||
public static final int SDLK_F4 = 285;
|
||||
public static final int SDLK_F5 = 286;
|
||||
public static final int SDLK_F6 = 287;
|
||||
public static final int SDLK_F7 = 288;
|
||||
public static final int SDLK_F8 = 289;
|
||||
public static final int SDLK_F9 = 290;
|
||||
public static final int SDLK_F10 = 291;
|
||||
public static final int SDLK_F11 = 292;
|
||||
public static final int SDLK_F12 = 293;
|
||||
public static final int SDLK_F13 = 294;
|
||||
public static final int SDLK_F14 = 295;
|
||||
public static final int SDLK_F15 = 296;
|
||||
public static final int SDLK_NUMLOCK = 300;
|
||||
public static final int SDLK_CAPSLOCK = 301;
|
||||
public static final int SDLK_SCROLLOCK = 302;
|
||||
public static final int SDLK_RSHIFT = 303;
|
||||
public static final int SDLK_LSHIFT = 304;
|
||||
public static final int SDLK_RCTRL = 305;
|
||||
public static final int SDLK_LCTRL = 306;
|
||||
public static final int SDLK_RALT = 307;
|
||||
public static final int SDLK_LALT = 308;
|
||||
public static final int SDLK_RMETA = 309;
|
||||
public static final int SDLK_LMETA = 310;
|
||||
public static final int SDLK_LSUPER = 311;
|
||||
public static final int SDLK_RSUPER = 312;
|
||||
public static final int SDLK_MODE = 313;
|
||||
public static final int SDLK_COMPOSE = 314;
|
||||
public static final int SDLK_HELP = 315;
|
||||
public static final int SDLK_PRINT = 316;
|
||||
public static final int SDLK_SYSREQ = 317;
|
||||
public static final int SDLK_BREAK = 318;
|
||||
public static final int SDLK_MENU = 319;
|
||||
public static final int SDLK_POWER = 320;
|
||||
public static final int SDLK_EURO = 321;
|
||||
public static final int SDLK_UNDO = 322;
|
||||
|
||||
public static final int SDLK_NO_REMAP = 512;
|
||||
}
|
||||
|
||||
// Autogenerated by hand with a command:
|
||||
// grep 'SDL_SCANCODE_' SDL_scancode.h | sed 's/SDL_SCANCODE_\([a-zA-Z0-9_]\+\).*[=] \([0-9]\+\).*/public static final int SDLK_\1 = \2;/' >> Keycodes.java
|
||||
class SDL_1_3_Keycodes
|
||||
{
|
||||
public static final int SDLK_UNKNOWN = 0;
|
||||
public static final int SDLK_A = 4;
|
||||
public static final int SDLK_B = 5;
|
||||
public static final int SDLK_C = 6;
|
||||
public static final int SDLK_D = 7;
|
||||
public static final int SDLK_E = 8;
|
||||
public static final int SDLK_F = 9;
|
||||
public static final int SDLK_G = 10;
|
||||
public static final int SDLK_H = 11;
|
||||
public static final int SDLK_I = 12;
|
||||
public static final int SDLK_J = 13;
|
||||
public static final int SDLK_K = 14;
|
||||
public static final int SDLK_L = 15;
|
||||
public static final int SDLK_M = 16;
|
||||
public static final int SDLK_N = 17;
|
||||
public static final int SDLK_O = 18;
|
||||
public static final int SDLK_P = 19;
|
||||
public static final int SDLK_Q = 20;
|
||||
public static final int SDLK_R = 21;
|
||||
public static final int SDLK_S = 22;
|
||||
public static final int SDLK_T = 23;
|
||||
public static final int SDLK_U = 24;
|
||||
public static final int SDLK_V = 25;
|
||||
public static final int SDLK_W = 26;
|
||||
public static final int SDLK_X = 27;
|
||||
public static final int SDLK_Y = 28;
|
||||
public static final int SDLK_Z = 29;
|
||||
public static final int SDLK_1 = 30;
|
||||
public static final int SDLK_2 = 31;
|
||||
public static final int SDLK_3 = 32;
|
||||
public static final int SDLK_4 = 33;
|
||||
public static final int SDLK_5 = 34;
|
||||
public static final int SDLK_6 = 35;
|
||||
public static final int SDLK_7 = 36;
|
||||
public static final int SDLK_8 = 37;
|
||||
public static final int SDLK_9 = 38;
|
||||
public static final int SDLK_0 = 39;
|
||||
public static final int SDLK_RETURN = 40;
|
||||
public static final int SDLK_ESCAPE = 41;
|
||||
public static final int SDLK_BACKSPACE = 42;
|
||||
public static final int SDLK_TAB = 43;
|
||||
public static final int SDLK_SPACE = 44;
|
||||
public static final int SDLK_MINUS = 45;
|
||||
public static final int SDLK_EQUALS = 46;
|
||||
public static final int SDLK_LEFTBRACKET = 47;
|
||||
public static final int SDLK_RIGHTBRACKET = 48;
|
||||
public static final int SDLK_BACKSLASH = 49;
|
||||
public static final int SDLK_NONUSHASH = 50;
|
||||
public static final int SDLK_SEMICOLON = 51;
|
||||
public static final int SDLK_APOSTROPHE = 52;
|
||||
public static final int SDLK_GRAVE = 53;
|
||||
public static final int SDLK_COMMA = 54;
|
||||
public static final int SDLK_PERIOD = 55;
|
||||
public static final int SDLK_SLASH = 56;
|
||||
public static final int SDLK_CAPSLOCK = 57;
|
||||
public static final int SDLK_F1 = 58;
|
||||
public static final int SDLK_F2 = 59;
|
||||
public static final int SDLK_F3 = 60;
|
||||
public static final int SDLK_F4 = 61;
|
||||
public static final int SDLK_F5 = 62;
|
||||
public static final int SDLK_F6 = 63;
|
||||
public static final int SDLK_F7 = 64;
|
||||
public static final int SDLK_F8 = 65;
|
||||
public static final int SDLK_F9 = 66;
|
||||
public static final int SDLK_F10 = 67;
|
||||
public static final int SDLK_F11 = 68;
|
||||
public static final int SDLK_F12 = 69;
|
||||
public static final int SDLK_PRINTSCREEN = 70;
|
||||
public static final int SDLK_SCROLLLOCK = 71;
|
||||
public static final int SDLK_PAUSE = 72;
|
||||
public static final int SDLK_INSERT = 73;
|
||||
public static final int SDLK_HOME = 74;
|
||||
public static final int SDLK_PAGEUP = 75;
|
||||
public static final int SDLK_DELETE = 76;
|
||||
public static final int SDLK_END = 77;
|
||||
public static final int SDLK_PAGEDOWN = 78;
|
||||
public static final int SDLK_RIGHT = 79;
|
||||
public static final int SDLK_LEFT = 80;
|
||||
public static final int SDLK_DOWN = 81;
|
||||
public static final int SDLK_UP = 82;
|
||||
public static final int SDLK_NUMLOCKCLEAR = 83;
|
||||
public static final int SDLK_KP_DIVIDE = 84;
|
||||
public static final int SDLK_KP_MULTIPLY = 85;
|
||||
public static final int SDLK_KP_MINUS = 86;
|
||||
public static final int SDLK_KP_PLUS = 87;
|
||||
public static final int SDLK_KP_ENTER = 88;
|
||||
public static final int SDLK_KP_1 = 89;
|
||||
public static final int SDLK_KP_2 = 90;
|
||||
public static final int SDLK_KP_3 = 91;
|
||||
public static final int SDLK_KP_4 = 92;
|
||||
public static final int SDLK_KP_5 = 93;
|
||||
public static final int SDLK_KP_6 = 94;
|
||||
public static final int SDLK_KP_7 = 95;
|
||||
public static final int SDLK_KP_8 = 96;
|
||||
public static final int SDLK_KP_9 = 97;
|
||||
public static final int SDLK_KP_0 = 98;
|
||||
public static final int SDLK_KP_PERIOD = 99;
|
||||
public static final int SDLK_NONUSBACKSLASH = 100;
|
||||
public static final int SDLK_APPLICATION = 101;
|
||||
public static final int SDLK_POWER = 102;
|
||||
public static final int SDLK_KP_EQUALS = 103;
|
||||
public static final int SDLK_F13 = 104;
|
||||
public static final int SDLK_F14 = 105;
|
||||
public static final int SDLK_F15 = 106;
|
||||
public static final int SDLK_F16 = 107;
|
||||
public static final int SDLK_F17 = 108;
|
||||
public static final int SDLK_F18 = 109;
|
||||
public static final int SDLK_F19 = 110;
|
||||
public static final int SDLK_F20 = 111;
|
||||
public static final int SDLK_F21 = 112;
|
||||
public static final int SDLK_F22 = 113;
|
||||
public static final int SDLK_F23 = 114;
|
||||
public static final int SDLK_F24 = 115;
|
||||
public static final int SDLK_EXECUTE = 116;
|
||||
public static final int SDLK_HELP = 117;
|
||||
public static final int SDLK_MENU = 118;
|
||||
public static final int SDLK_SELECT = 119;
|
||||
public static final int SDLK_STOP = 120;
|
||||
public static final int SDLK_AGAIN = 121;
|
||||
public static final int SDLK_UNDO = 122;
|
||||
public static final int SDLK_CUT = 123;
|
||||
public static final int SDLK_COPY = 124;
|
||||
public static final int SDLK_PASTE = 125;
|
||||
public static final int SDLK_FIND = 126;
|
||||
public static final int SDLK_MUTE = 127;
|
||||
public static final int SDLK_VOLUMEUP = 128;
|
||||
public static final int SDLK_VOLUMEDOWN = 129;
|
||||
public static final int SDLK_KP_COMMA = 133;
|
||||
public static final int SDLK_KP_EQUALSAS400 = 134;
|
||||
public static final int SDLK_INTERNATIONAL1 = 135;
|
||||
public static final int SDLK_INTERNATIONAL2 = 136;
|
||||
public static final int SDLK_INTERNATIONAL3 = 137;
|
||||
public static final int SDLK_INTERNATIONAL4 = 138;
|
||||
public static final int SDLK_INTERNATIONAL5 = 139;
|
||||
public static final int SDLK_INTERNATIONAL6 = 140;
|
||||
public static final int SDLK_INTERNATIONAL7 = 141;
|
||||
public static final int SDLK_INTERNATIONAL8 = 142;
|
||||
public static final int SDLK_INTERNATIONAL9 = 143;
|
||||
public static final int SDLK_LANG1 = 144;
|
||||
public static final int SDLK_LANG2 = 145;
|
||||
public static final int SDLK_LANG3 = 146;
|
||||
public static final int SDLK_LANG4 = 147;
|
||||
public static final int SDLK_LANG5 = 148;
|
||||
public static final int SDLK_LANG6 = 149;
|
||||
public static final int SDLK_LANG7 = 150;
|
||||
public static final int SDLK_LANG8 = 151;
|
||||
public static final int SDLK_LANG9 = 152;
|
||||
public static final int SDLK_ALTERASE = 153;
|
||||
public static final int SDLK_SYSREQ = 154;
|
||||
public static final int SDLK_CANCEL = 155;
|
||||
public static final int SDLK_CLEAR = 156;
|
||||
public static final int SDLK_PRIOR = 157;
|
||||
public static final int SDLK_RETURN2 = 158;
|
||||
public static final int SDLK_SEPARATOR = 159;
|
||||
public static final int SDLK_OUT = 160;
|
||||
public static final int SDLK_OPER = 161;
|
||||
public static final int SDLK_CLEARAGAIN = 162;
|
||||
public static final int SDLK_CRSEL = 163;
|
||||
public static final int SDLK_EXSEL = 164;
|
||||
public static final int SDLK_KP_00 = 176;
|
||||
public static final int SDLK_KP_000 = 177;
|
||||
public static final int SDLK_THOUSANDSSEPARATOR = 178;
|
||||
public static final int SDLK_DECIMALSEPARATOR = 179;
|
||||
public static final int SDLK_CURRENCYUNIT = 180;
|
||||
public static final int SDLK_CURRENCYSUBUNIT = 181;
|
||||
public static final int SDLK_KP_LEFTPAREN = 182;
|
||||
public static final int SDLK_KP_RIGHTPAREN = 183;
|
||||
public static final int SDLK_KP_LEFTBRACE = 184;
|
||||
public static final int SDLK_KP_RIGHTBRACE = 185;
|
||||
public static final int SDLK_KP_TAB = 186;
|
||||
public static final int SDLK_KP_BACKSPACE = 187;
|
||||
public static final int SDLK_KP_A = 188;
|
||||
public static final int SDLK_KP_B = 189;
|
||||
public static final int SDLK_KP_C = 190;
|
||||
public static final int SDLK_KP_D = 191;
|
||||
public static final int SDLK_KP_E = 192;
|
||||
public static final int SDLK_KP_F = 193;
|
||||
public static final int SDLK_KP_XOR = 194;
|
||||
public static final int SDLK_KP_POWER = 195;
|
||||
public static final int SDLK_KP_PERCENT = 196;
|
||||
public static final int SDLK_KP_LESS = 197;
|
||||
public static final int SDLK_KP_GREATER = 198;
|
||||
public static final int SDLK_KP_AMPERSAND = 199;
|
||||
public static final int SDLK_KP_DBLAMPERSAND = 200;
|
||||
public static final int SDLK_KP_VERTICALBAR = 201;
|
||||
public static final int SDLK_KP_DBLVERTICALBAR = 202;
|
||||
public static final int SDLK_KP_COLON = 203;
|
||||
public static final int SDLK_KP_HASH = 204;
|
||||
public static final int SDLK_KP_SPACE = 205;
|
||||
public static final int SDLK_KP_AT = 206;
|
||||
public static final int SDLK_KP_EXCLAM = 207;
|
||||
public static final int SDLK_KP_MEMSTORE = 208;
|
||||
public static final int SDLK_KP_MEMRECALL = 209;
|
||||
public static final int SDLK_KP_MEMCLEAR = 210;
|
||||
public static final int SDLK_KP_MEMADD = 211;
|
||||
public static final int SDLK_KP_MEMSUBTRACT = 212;
|
||||
public static final int SDLK_KP_MEMMULTIPLY = 213;
|
||||
public static final int SDLK_KP_MEMDIVIDE = 214;
|
||||
public static final int SDLK_KP_PLUSMINUS = 215;
|
||||
public static final int SDLK_KP_CLEAR = 216;
|
||||
public static final int SDLK_KP_CLEARENTRY = 217;
|
||||
public static final int SDLK_KP_BINARY = 218;
|
||||
public static final int SDLK_KP_OCTAL = 219;
|
||||
public static final int SDLK_KP_DECIMAL = 220;
|
||||
public static final int SDLK_KP_HEXADECIMAL = 221;
|
||||
public static final int SDLK_LCTRL = 224;
|
||||
public static final int SDLK_LSHIFT = 225;
|
||||
public static final int SDLK_LALT = 226;
|
||||
public static final int SDLK_LGUI = 227;
|
||||
public static final int SDLK_RCTRL = 228;
|
||||
public static final int SDLK_RSHIFT = 229;
|
||||
public static final int SDLK_RALT = 230;
|
||||
public static final int SDLK_RGUI = 231;
|
||||
public static final int SDLK_MODE = 257;
|
||||
public static final int SDLK_AUDIONEXT = 258;
|
||||
public static final int SDLK_AUDIOPREV = 259;
|
||||
public static final int SDLK_AUDIOSTOP = 260;
|
||||
public static final int SDLK_AUDIOPLAY = 261;
|
||||
public static final int SDLK_AUDIOMUTE = 262;
|
||||
public static final int SDLK_MEDIASELECT = 263;
|
||||
public static final int SDLK_WWW = 264;
|
||||
public static final int SDLK_MAIL = 265;
|
||||
public static final int SDLK_CALCULATOR = 266;
|
||||
public static final int SDLK_COMPUTER = 267;
|
||||
public static final int SDLK_AC_SEARCH = 268;
|
||||
public static final int SDLK_AC_HOME = 269;
|
||||
public static final int SDLK_AC_BACK = 270;
|
||||
public static final int SDLK_AC_FORWARD = 271;
|
||||
public static final int SDLK_AC_STOP = 272;
|
||||
public static final int SDLK_AC_REFRESH = 273;
|
||||
public static final int SDLK_AC_BOOKMARKS = 274;
|
||||
public static final int SDLK_BRIGHTNESSDOWN = 275;
|
||||
public static final int SDLK_BRIGHTNESSUP = 276;
|
||||
public static final int SDLK_DISPLAYSWITCH = 277;
|
||||
public static final int SDLK_KBDILLUMTOGGLE = 278;
|
||||
public static final int SDLK_KBDILLUMDOWN = 279;
|
||||
public static final int SDLK_KBDILLUMUP = 280;
|
||||
public static final int SDLK_EJECT = 281;
|
||||
public static final int SDLK_SLEEP = 282;
|
||||
|
||||
public static final int SDLK_NO_REMAP = 512;
|
||||
}
|
||||
|
||||
class SDL_Keys
|
||||
{
|
||||
public static String [] names = null;
|
||||
public static Integer [] values = null;
|
||||
|
||||
public static String [] namesSorted = null;
|
||||
public static Integer [] namesSortedIdx = null;
|
||||
public static Integer [] namesSortedBackIdx = null;
|
||||
|
||||
static final int JAVA_KEYCODE_LAST = 255; // Android 2.3 added several new gaming keys, Android 3.1 added even more - keep in sync with javakeycodes.h
|
||||
|
||||
static String getName(int v)
|
||||
{
|
||||
for( int f = 0; f < values.length; f++ )
|
||||
{
|
||||
if( values[f] == v )
|
||||
return names[f];
|
||||
}
|
||||
return names[0];
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
ArrayList<String> Names = new ArrayList<String> ();
|
||||
ArrayList<Integer> Values = new ArrayList<Integer> ();
|
||||
Field [] fields = SDL_1_2_Keycodes.class.getDeclaredFields();
|
||||
if( Globals.Using_SDL_1_3 )
|
||||
{
|
||||
fields = SDL_1_3_Keycodes.class.getDeclaredFields();
|
||||
}
|
||||
|
||||
try {
|
||||
for(Field f: fields)
|
||||
{
|
||||
Values.add(f.getInt(null));
|
||||
Names.add(f.getName().substring(5).toUpperCase());
|
||||
}
|
||||
} catch(IllegalAccessException e) {};
|
||||
|
||||
// Sort by value
|
||||
for( int i = 0; i < Values.size(); i++ )
|
||||
{
|
||||
for( int j = i; j < Values.size(); j++ )
|
||||
{
|
||||
if( Values.get(i) > Values.get(j) )
|
||||
{
|
||||
int x = Values.get(i);
|
||||
Values.set(i, Values.get(j));
|
||||
Values.set(j, x);
|
||||
String s = Names.get(i);
|
||||
Names.set(i, Names.get(j));
|
||||
Names.set(j, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
names = Names.toArray(new String[0]);
|
||||
values = Values.toArray(new Integer[0]);
|
||||
namesSorted = Names.toArray(new String[0]);
|
||||
namesSortedIdx = new Integer[values.length];
|
||||
namesSortedBackIdx = new Integer[values.length];
|
||||
Arrays.sort(namesSorted);
|
||||
for( int i = 0; i < namesSorted.length; i++ )
|
||||
{
|
||||
for( int j = 0; j < namesSorted.length; j++ )
|
||||
{
|
||||
if( namesSorted[i].equals( names[j] ) )
|
||||
{
|
||||
namesSortedIdx[i] = j;
|
||||
namesSortedBackIdx[j] = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
../java/Mouse.java
|
||||
@@ -1 +0,0 @@
|
||||
../java/SDL_Keys.java
|
||||
@@ -1 +0,0 @@
|
||||
../java/Settings.java
|
||||
782
project/javaSDL2/Settings.java
Normal file
782
project/javaSDL2/Settings.java
Normal file
@@ -0,0 +1,782 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
import android.util.Log;
|
||||
import java.io.*;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Environment;
|
||||
import android.os.StatFs;
|
||||
import java.util.Locale;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.Collections;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import java.lang.String;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.RectF;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Bitmap;
|
||||
import android.widget.TextView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Button;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.text.Editable;
|
||||
import android.text.SpannedString;
|
||||
import android.content.Intent;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.AlarmManager;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.net.Uri;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.Arrays;
|
||||
import android.graphics.Color;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.Sensor;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
// TODO: too much code here, split into multiple files, possibly auto-generated menus?
|
||||
class Settings
|
||||
{
|
||||
static String SettingsFileName = "libsdl-settings.cfg";
|
||||
|
||||
static boolean settingsLoaded = false;
|
||||
static boolean settingsChanged = false;
|
||||
static final int SETTINGS_FILE_VERSION = 5;
|
||||
|
||||
static void Save(final MainActivity p)
|
||||
{
|
||||
try {
|
||||
ObjectOutputStream out = new ObjectOutputStream(p.openFileOutput( SettingsFileName, p.MODE_WORLD_READABLE ));
|
||||
out.writeInt(SETTINGS_FILE_VERSION);
|
||||
out.writeBoolean(Globals.DownloadToSdcard);
|
||||
out.writeBoolean(Globals.PhoneHasArrowKeys);
|
||||
out.writeBoolean(Globals.PhoneHasTrackball);
|
||||
out.writeBoolean(Globals.UseAccelerometerAsArrowKeys);
|
||||
out.writeBoolean(Globals.UseTouchscreenKeyboard);
|
||||
out.writeInt(Globals.TouchscreenKeyboardSize);
|
||||
out.writeInt(Globals.AccelerometerSensitivity);
|
||||
out.writeInt(Globals.AccelerometerCenterPos);
|
||||
out.writeInt(Globals.TrackballDampening);
|
||||
out.writeInt(Globals.AudioBufferConfig);
|
||||
out.writeInt(Globals.TouchscreenKeyboardTheme);
|
||||
out.writeInt(Globals.RightClickMethod);
|
||||
out.writeInt(Globals.ShowScreenUnderFinger);
|
||||
out.writeInt(Globals.LeftClickMethod);
|
||||
out.writeBoolean(Globals.MoveMouseWithJoystick);
|
||||
out.writeBoolean(Globals.ClickMouseWithDpad);
|
||||
out.writeInt(Globals.ClickScreenPressure);
|
||||
out.writeInt(Globals.ClickScreenTouchspotSize);
|
||||
out.writeBoolean(Globals.KeepAspectRatio);
|
||||
out.writeInt(Globals.MoveMouseWithJoystickSpeed);
|
||||
out.writeInt(Globals.MoveMouseWithJoystickAccel);
|
||||
out.writeInt(SDL_Keys.JAVA_KEYCODE_LAST);
|
||||
for( int i = 0; i < SDL_Keys.JAVA_KEYCODE_LAST; i++ )
|
||||
{
|
||||
out.writeInt(Globals.RemapHwKeycode[i]);
|
||||
}
|
||||
out.writeInt(Globals.RemapScreenKbKeycode.length);
|
||||
for( int i = 0; i < Globals.RemapScreenKbKeycode.length; i++ )
|
||||
{
|
||||
out.writeInt(Globals.RemapScreenKbKeycode[i]);
|
||||
}
|
||||
out.writeInt(Globals.ScreenKbControlsShown.length);
|
||||
for( int i = 0; i < Globals.ScreenKbControlsShown.length; i++ )
|
||||
{
|
||||
out.writeBoolean(Globals.ScreenKbControlsShown[i]);
|
||||
}
|
||||
out.writeInt(Globals.TouchscreenKeyboardTransparency);
|
||||
out.writeInt(Globals.RemapMultitouchGestureKeycode.length);
|
||||
for( int i = 0; i < Globals.RemapMultitouchGestureKeycode.length; i++ )
|
||||
{
|
||||
out.writeInt(Globals.RemapMultitouchGestureKeycode[i]);
|
||||
out.writeBoolean(Globals.MultitouchGesturesUsed[i]);
|
||||
}
|
||||
out.writeInt(Globals.MultitouchGestureSensitivity);
|
||||
for( int i = 0; i < Globals.TouchscreenCalibration.length; i++ )
|
||||
out.writeInt(Globals.TouchscreenCalibration[i]);
|
||||
out.writeInt(Globals.DataDir.length());
|
||||
for( int i = 0; i < Globals.DataDir.length(); i++ )
|
||||
out.writeChar(Globals.DataDir.charAt(i));
|
||||
out.writeInt(Globals.CommandLine.length());
|
||||
for( int i = 0; i < Globals.CommandLine.length(); i++ )
|
||||
out.writeChar(Globals.CommandLine.charAt(i));
|
||||
out.writeInt(Globals.ScreenKbControlsLayout.length);
|
||||
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ )
|
||||
for( int ii = 0; ii < 4; ii++ )
|
||||
out.writeInt(Globals.ScreenKbControlsLayout[i][ii]);
|
||||
out.writeInt(Globals.LeftClickKey);
|
||||
out.writeInt(Globals.RightClickKey);
|
||||
out.writeBoolean(Globals.VideoLinearFilter);
|
||||
out.writeInt(Globals.LeftClickTimeout);
|
||||
out.writeInt(Globals.RightClickTimeout);
|
||||
out.writeBoolean(Globals.RelativeMouseMovement);
|
||||
out.writeInt(Globals.RelativeMouseMovementSpeed);
|
||||
out.writeInt(Globals.RelativeMouseMovementAccel);
|
||||
out.writeBoolean(Globals.MultiThreadedVideo);
|
||||
|
||||
out.writeInt(Globals.OptionalDataDownload.length);
|
||||
for(int i = 0; i < Globals.OptionalDataDownload.length; i++)
|
||||
out.writeBoolean(Globals.OptionalDataDownload[i]);
|
||||
out.writeBoolean(Globals.BrokenLibCMessageShown);
|
||||
out.writeInt(Globals.TouchscreenKeyboardDrawSize);
|
||||
out.writeInt(p.getApplicationVersion());
|
||||
out.writeFloat(Globals.gyro_x1);
|
||||
out.writeFloat(Globals.gyro_x2);
|
||||
out.writeFloat(Globals.gyro_xc);
|
||||
out.writeFloat(Globals.gyro_y1);
|
||||
out.writeFloat(Globals.gyro_y2);
|
||||
out.writeFloat(Globals.gyro_yc);
|
||||
out.writeFloat(Globals.gyro_z1);
|
||||
out.writeFloat(Globals.gyro_z2);
|
||||
out.writeFloat(Globals.gyro_zc);
|
||||
|
||||
out.writeBoolean(Globals.OuyaEmulation);
|
||||
|
||||
out.close();
|
||||
settingsLoaded = true;
|
||||
|
||||
} catch( FileNotFoundException e ) {
|
||||
} catch( SecurityException e ) {
|
||||
} catch ( IOException e ) {};
|
||||
}
|
||||
|
||||
static void Load( final MainActivity p )
|
||||
{
|
||||
if(settingsLoaded) // Prevent starting twice
|
||||
{
|
||||
return;
|
||||
}
|
||||
Log.i("SDL", "libSDL: Settings.Load(): enter");
|
||||
/*nativeInitKeymap(); // TODO: Disabled in SDL2
|
||||
if( p.isRunningOnOUYA() )
|
||||
nativeSetKeymapKey(KeyEvent.KEYCODE_MENU, nativeGetKeymapKey(KeyEvent.KEYCODE_BACK)); // Ouya does not have Back key, only Menu, so remap Back keycode to Menu
|
||||
for( int i = 0; i < SDL_Keys.JAVA_KEYCODE_LAST; i++ )
|
||||
{
|
||||
int sdlKey = nativeGetKeymapKey(i);
|
||||
int idx = 0;
|
||||
for(int ii = 0; ii < SDL_Keys.values.length; ii++)
|
||||
if(SDL_Keys.values[ii] == sdlKey)
|
||||
idx = ii;
|
||||
Globals.RemapHwKeycode[i] = idx;
|
||||
}
|
||||
for( int i = 0; i < Globals.RemapScreenKbKeycode.length; i++ )
|
||||
{
|
||||
int sdlKey = nativeGetKeymapKeyScreenKb(i);
|
||||
int idx = 0;
|
||||
for(int ii = 0; ii < SDL_Keys.values.length; ii++)
|
||||
if(SDL_Keys.values[ii] == sdlKey)
|
||||
idx = ii;
|
||||
Globals.RemapScreenKbKeycode[i] = idx;
|
||||
}*/
|
||||
Globals.ScreenKbControlsShown[0] = (Globals.AppNeedsArrowKeys || Globals.AppUsesJoystick);
|
||||
Globals.ScreenKbControlsShown[1] = Globals.AppNeedsTextInput;
|
||||
for( int i = 2; i < Globals.ScreenKbControlsShown.length; i++ )
|
||||
Globals.ScreenKbControlsShown[i] = ( i - 2 < Globals.AppTouchscreenKeyboardKeysAmount );
|
||||
if( Globals.AppUsesSecondJoystick )
|
||||
Globals.ScreenKbControlsShown[8] = true;
|
||||
/*for( int i = 0; i < Globals.RemapMultitouchGestureKeycode.length; i++ )
|
||||
{
|
||||
int sdlKey = nativeGetKeymapKeyMultitouchGesture(i);
|
||||
int idx = 0;
|
||||
for(int ii = 0; ii < SDL_Keys.values.length; ii++)
|
||||
if(SDL_Keys.values[ii] == sdlKey)
|
||||
idx = ii;
|
||||
Globals.RemapMultitouchGestureKeycode[i] = idx;
|
||||
}*/
|
||||
for( int i = 0; i < Globals.MultitouchGesturesUsed.length; i++ )
|
||||
Globals.MultitouchGesturesUsed[i] = true;
|
||||
// Adjust coordinates of on-screen buttons from 800x480
|
||||
int displayX = 800;
|
||||
int displayY = 480;
|
||||
try {
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
p.getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
displayX = dm.widthPixels;
|
||||
displayY = dm.heightPixels;
|
||||
} catch (Exception eeeee) {}
|
||||
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ )
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[i][0] *= (float)displayX / 800.0f;
|
||||
Globals.ScreenKbControlsLayout[i][2] *= (float)displayX / 800.0f;
|
||||
Globals.ScreenKbControlsLayout[i][1] *= (float)displayY / 480.0f;
|
||||
Globals.ScreenKbControlsLayout[i][3] *= (float)displayY / 480.0f;
|
||||
// Make them square
|
||||
int wh = Math.min( Globals.ScreenKbControlsLayout[i][2] - Globals.ScreenKbControlsLayout[i][0], Globals.ScreenKbControlsLayout[i][3] - Globals.ScreenKbControlsLayout[i][1] );
|
||||
Globals.ScreenKbControlsLayout[i][2] = Globals.ScreenKbControlsLayout[i][0] + wh;
|
||||
Globals.ScreenKbControlsLayout[i][3] = Globals.ScreenKbControlsLayout[i][1] + wh;
|
||||
}
|
||||
|
||||
Log.i("SDL", "android.os.Build.MODEL: " + android.os.Build.MODEL);
|
||||
if( (android.os.Build.MODEL.equals("GT-N7000") || android.os.Build.MODEL.equals("SGH-I717"))
|
||||
&& android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.GINGERBREAD_MR1 )
|
||||
{
|
||||
// Samsung Galaxy Note generates a keypress when you hover a stylus over the screen, and that messes up OpenTTD dialogs
|
||||
// ICS update sends events in a proper way
|
||||
Globals.RemapHwKeycode[112] = SDL_1_2_Keycodes.SDLK_UNKNOWN;
|
||||
}
|
||||
|
||||
try {
|
||||
ObjectInputStream settingsFile = new ObjectInputStream(new FileInputStream( p.getFilesDir().getAbsolutePath() + "/" + SettingsFileName ));
|
||||
if( settingsFile.readInt() != SETTINGS_FILE_VERSION )
|
||||
throw new IOException();
|
||||
Globals.DownloadToSdcard = settingsFile.readBoolean();
|
||||
Globals.PhoneHasArrowKeys = settingsFile.readBoolean();
|
||||
Globals.PhoneHasTrackball = settingsFile.readBoolean();
|
||||
Globals.UseAccelerometerAsArrowKeys = settingsFile.readBoolean();
|
||||
Globals.UseTouchscreenKeyboard = settingsFile.readBoolean();
|
||||
Globals.TouchscreenKeyboardSize = settingsFile.readInt();
|
||||
Globals.AccelerometerSensitivity = settingsFile.readInt();
|
||||
Globals.AccelerometerCenterPos = settingsFile.readInt();
|
||||
Globals.TrackballDampening = settingsFile.readInt();
|
||||
Globals.AudioBufferConfig = settingsFile.readInt();
|
||||
Globals.TouchscreenKeyboardTheme = settingsFile.readInt();
|
||||
Globals.RightClickMethod = settingsFile.readInt();
|
||||
Globals.ShowScreenUnderFinger = settingsFile.readInt();
|
||||
Globals.LeftClickMethod = settingsFile.readInt();
|
||||
Globals.MoveMouseWithJoystick = settingsFile.readBoolean();
|
||||
Globals.ClickMouseWithDpad = settingsFile.readBoolean();
|
||||
Globals.ClickScreenPressure = settingsFile.readInt();
|
||||
Globals.ClickScreenTouchspotSize = settingsFile.readInt();
|
||||
Globals.KeepAspectRatio = settingsFile.readBoolean();
|
||||
Globals.MoveMouseWithJoystickSpeed = settingsFile.readInt();
|
||||
Globals.MoveMouseWithJoystickAccel = settingsFile.readInt();
|
||||
int readKeys = settingsFile.readInt();
|
||||
for( int i = 0; i < readKeys; i++ )
|
||||
{
|
||||
Globals.RemapHwKeycode[i] = settingsFile.readInt();
|
||||
}
|
||||
if( settingsFile.readInt() != Globals.RemapScreenKbKeycode.length )
|
||||
throw new IOException();
|
||||
for( int i = 0; i < Globals.RemapScreenKbKeycode.length; i++ )
|
||||
{
|
||||
Globals.RemapScreenKbKeycode[i] = settingsFile.readInt();
|
||||
}
|
||||
if( settingsFile.readInt() != Globals.ScreenKbControlsShown.length )
|
||||
throw new IOException();
|
||||
for( int i = 0; i < Globals.ScreenKbControlsShown.length; i++ )
|
||||
{
|
||||
Globals.ScreenKbControlsShown[i] = settingsFile.readBoolean();
|
||||
}
|
||||
Globals.TouchscreenKeyboardTransparency = settingsFile.readInt();
|
||||
if( settingsFile.readInt() != Globals.RemapMultitouchGestureKeycode.length )
|
||||
throw new IOException();
|
||||
for( int i = 0; i < Globals.RemapMultitouchGestureKeycode.length; i++ )
|
||||
{
|
||||
Globals.RemapMultitouchGestureKeycode[i] = settingsFile.readInt();
|
||||
Globals.MultitouchGesturesUsed[i] = settingsFile.readBoolean();
|
||||
}
|
||||
Globals.MultitouchGestureSensitivity = settingsFile.readInt();
|
||||
for( int i = 0; i < Globals.TouchscreenCalibration.length; i++ )
|
||||
Globals.TouchscreenCalibration[i] = settingsFile.readInt();
|
||||
StringBuilder b = new StringBuilder();
|
||||
int len = settingsFile.readInt();
|
||||
for( int i = 0; i < len; i++ )
|
||||
b.append( settingsFile.readChar() );
|
||||
Globals.DataDir = b.toString();
|
||||
|
||||
b = new StringBuilder();
|
||||
len = settingsFile.readInt();
|
||||
for( int i = 0; i < len; i++ )
|
||||
b.append( settingsFile.readChar() );
|
||||
Globals.CommandLine = b.toString();
|
||||
|
||||
if( settingsFile.readInt() != Globals.ScreenKbControlsLayout.length )
|
||||
throw new IOException();
|
||||
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ )
|
||||
for( int ii = 0; ii < 4; ii++ )
|
||||
Globals.ScreenKbControlsLayout[i][ii] = settingsFile.readInt();
|
||||
Globals.LeftClickKey = settingsFile.readInt();
|
||||
Globals.RightClickKey = settingsFile.readInt();
|
||||
Globals.VideoLinearFilter = settingsFile.readBoolean();
|
||||
Globals.LeftClickTimeout = settingsFile.readInt();
|
||||
Globals.RightClickTimeout = settingsFile.readInt();
|
||||
Globals.RelativeMouseMovement = settingsFile.readBoolean();
|
||||
Globals.RelativeMouseMovementSpeed = settingsFile.readInt();
|
||||
Globals.RelativeMouseMovementAccel = settingsFile.readInt();
|
||||
Globals.MultiThreadedVideo = settingsFile.readBoolean();
|
||||
|
||||
Globals.OptionalDataDownload = new boolean[settingsFile.readInt()];
|
||||
for(int i = 0; i < Globals.OptionalDataDownload.length; i++)
|
||||
Globals.OptionalDataDownload[i] = settingsFile.readBoolean();
|
||||
Globals.BrokenLibCMessageShown = settingsFile.readBoolean();
|
||||
Globals.TouchscreenKeyboardDrawSize = settingsFile.readInt();
|
||||
int cfgVersion = settingsFile.readInt();
|
||||
Globals.gyro_x1 = settingsFile.readFloat();
|
||||
Globals.gyro_x2 = settingsFile.readFloat();
|
||||
Globals.gyro_xc = settingsFile.readFloat();
|
||||
Globals.gyro_y1 = settingsFile.readFloat();
|
||||
Globals.gyro_y2 = settingsFile.readFloat();
|
||||
Globals.gyro_yc = settingsFile.readFloat();
|
||||
Globals.gyro_z1 = settingsFile.readFloat();
|
||||
Globals.gyro_z2 = settingsFile.readFloat();
|
||||
Globals.gyro_zc = settingsFile.readFloat();
|
||||
|
||||
Globals.OuyaEmulation = settingsFile.readBoolean();
|
||||
|
||||
settingsLoaded = true;
|
||||
|
||||
Log.i("SDL", "libSDL: Settings.Load(): loaded settings successfully");
|
||||
settingsFile.close();
|
||||
|
||||
Log.i("SDL", "libSDL: old cfg version " + cfgVersion + ", our version " + p.getApplicationVersion());
|
||||
if( cfgVersion != p.getApplicationVersion() )
|
||||
{
|
||||
DeleteFilesOnUpgrade(p);
|
||||
if( Globals.ResetSdlConfigForThisVersion )
|
||||
{
|
||||
Log.i("SDL", "libSDL: old cfg version " + cfgVersion + ", our version " + p.getApplicationVersion() + " and we need to clean up config file");
|
||||
// Delete settings file, and restart the application
|
||||
DeleteSdlConfigOnUpgradeAndRestart(p);
|
||||
}
|
||||
Save(p);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
} catch( FileNotFoundException e ) {
|
||||
} catch( SecurityException e ) {
|
||||
} catch ( IOException e ) {
|
||||
DeleteFilesOnUpgrade(p);
|
||||
if( Globals.ResetSdlConfigForThisVersion )
|
||||
{
|
||||
Log.i("SDL", "libSDL: old cfg version unknown or too old, our version " + p.getApplicationVersion() + " and we need to clean up config file");
|
||||
DeleteSdlConfigOnUpgradeAndRestart(p);
|
||||
}
|
||||
};
|
||||
|
||||
if( Globals.DataDir.length() == 0 )
|
||||
{
|
||||
if( !Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED) )
|
||||
{
|
||||
Log.i("SDL", "libSDL: SD card or external storage is not mounted (state " + Environment.getExternalStorageState() + "), switching to the internal storage.");
|
||||
Globals.DownloadToSdcard = false;
|
||||
}
|
||||
Globals.DataDir = Globals.DownloadToSdcard ?
|
||||
SdcardAppPath.getPath(p) :
|
||||
p.getFilesDir().getAbsolutePath();
|
||||
if( Globals.DownloadToSdcard )
|
||||
{
|
||||
// Check if data already installed into deprecated location at /sdcard/app-data/<package-name>
|
||||
String[] fileList = new File(SdcardAppPath.deprecatedPath(p)).list();
|
||||
if( fileList != null )
|
||||
for( String s: fileList )
|
||||
if( s.toUpperCase().startsWith(DataDownloader.DOWNLOAD_FLAG_FILENAME.toUpperCase()) )
|
||||
Globals.DataDir = SdcardAppPath.deprecatedPath(p);
|
||||
}
|
||||
}
|
||||
|
||||
Log.i("SDL", "libSDL: Settings.Load(): loading settings failed, running config dialog");
|
||||
p.setUpStatusLabel();
|
||||
if( checkRamSize(p) )
|
||||
SettingsMenu.showConfig(p, true);
|
||||
}
|
||||
|
||||
// ===============================================================================================
|
||||
|
||||
public static boolean deleteRecursively(File dir)
|
||||
{
|
||||
if (dir.isDirectory()) {
|
||||
String[] children = dir.list();
|
||||
for (int i=0; i<children.length; i++)
|
||||
{
|
||||
boolean success = deleteRecursively(new File(dir, children[i]));
|
||||
if (!success)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return dir.delete();
|
||||
}
|
||||
public static boolean deleteRecursivelyAndLog(File dir)
|
||||
{
|
||||
Log.v("SDL", "Deleting old file: " + dir.getAbsolutePath() + " exists " + dir.exists());
|
||||
if (dir.isDirectory()) {
|
||||
String[] children = dir.list();
|
||||
for (int i=0; i<children.length; i++)
|
||||
{
|
||||
boolean success = deleteRecursively(new File(dir, children[i]));
|
||||
if (!success)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return dir.delete();
|
||||
}
|
||||
public static void DeleteFilesOnUpgrade(final MainActivity p)
|
||||
{
|
||||
String [] files = Globals.DeleteFilesOnUpgrade.split(" ");
|
||||
for(String path: files)
|
||||
{
|
||||
if( path.equals("") )
|
||||
continue;
|
||||
|
||||
deleteRecursivelyAndLog(new File( SdcardAppPath.getPath(p) + "/" + path ));
|
||||
deleteRecursivelyAndLog(new File( p.getFilesDir().getAbsolutePath() + "/" + path ));
|
||||
deleteRecursivelyAndLog(new File( SdcardAppPath.deprecatedPath(p) + "/" + path ));
|
||||
}
|
||||
}
|
||||
public static void DeleteSdlConfigOnUpgradeAndRestart(final MainActivity p)
|
||||
{
|
||||
try {
|
||||
ObjectOutputStream out = new ObjectOutputStream(p.openFileOutput( SettingsFileName, p.MODE_WORLD_READABLE ));
|
||||
out.writeInt(-1);
|
||||
out.close();
|
||||
} catch( FileNotFoundException e ) {
|
||||
} catch ( IOException e ) { }
|
||||
new File( p.getFilesDir() + "/" + SettingsFileName ).delete();
|
||||
PendingIntent intent = PendingIntent.getActivity(p, 0, new Intent(p.getIntent()), p.getIntent().getFlags());
|
||||
AlarmManager mgr = (AlarmManager) p.getSystemService(Context.ALARM_SERVICE);
|
||||
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, intent);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
// ===============================================================================================
|
||||
|
||||
static void Apply(MainActivity p)
|
||||
{
|
||||
/*nativeSetVideoDepth(Globals.VideoDepthBpp, Globals.NeedGles2 ? 1 : 0);
|
||||
if(Globals.VideoLinearFilter)
|
||||
nativeSetVideoLinearFilter();
|
||||
if( Globals.CompatibilityHacksVideo )
|
||||
{
|
||||
Globals.MultiThreadedVideo = true;
|
||||
Globals.SwVideoMode = true;
|
||||
nativeSetCompatibilityHacks();
|
||||
}
|
||||
if( Globals.SwVideoMode )
|
||||
nativeSetVideoForceSoftwareMode();
|
||||
if( Globals.SwVideoMode && Globals.MultiThreadedVideo )
|
||||
nativeSetVideoMultithreaded();
|
||||
if( Globals.PhoneHasTrackball )
|
||||
nativeSetTrackballUsed();
|
||||
if( Globals.AppUsesMouse )
|
||||
nativeSetMouseUsed( Globals.RightClickMethod,
|
||||
Globals.ShowScreenUnderFinger,
|
||||
Globals.LeftClickMethod,
|
||||
Globals.MoveMouseWithJoystick ? 1 : 0,
|
||||
Globals.ClickMouseWithDpad ? 1 : 0,
|
||||
Globals.ClickScreenPressure,
|
||||
Globals.ClickScreenTouchspotSize,
|
||||
Globals.MoveMouseWithJoystickSpeed,
|
||||
Globals.MoveMouseWithJoystickAccel,
|
||||
Globals.LeftClickKey,
|
||||
Globals.RightClickKey,
|
||||
Globals.LeftClickTimeout,
|
||||
Globals.RightClickTimeout,
|
||||
Globals.RelativeMouseMovement ? 1 : 0,
|
||||
Globals.RelativeMouseMovementSpeed,
|
||||
Globals.RelativeMouseMovementAccel,
|
||||
Globals.ShowMouseCursor ? 1 : 0 );
|
||||
nativeSetJoystickUsed(Globals.AppUsesJoystick ? 1 : 0, Globals.AppUsesSecondJoystick ? 1 : 0);
|
||||
if( Globals.AppUsesAccelerometer )
|
||||
nativeSetAccelerometerUsed();
|
||||
if( Globals.AppUsesMultitouch )
|
||||
nativeSetMultitouchUsed();
|
||||
nativeSetAccelerometerSettings(Globals.AccelerometerSensitivity, Globals.AccelerometerCenterPos);
|
||||
nativeSetTrackballDampening(Globals.TrackballDampening);
|
||||
if( Globals.UseTouchscreenKeyboard )
|
||||
{
|
||||
boolean screenKbReallyUsed = false;
|
||||
for( int i = 0; i < Globals.ScreenKbControlsShown.length; i++ )
|
||||
if( Globals.ScreenKbControlsShown[i] )
|
||||
screenKbReallyUsed = true;
|
||||
if( p.isRunningOnOUYA() )
|
||||
screenKbReallyUsed = false;
|
||||
if( screenKbReallyUsed )
|
||||
{
|
||||
nativeSetTouchscreenKeyboardUsed();
|
||||
nativeSetupScreenKeyboard( Globals.TouchscreenKeyboardSize,
|
||||
Globals.TouchscreenKeyboardDrawSize,
|
||||
Globals.TouchscreenKeyboardTheme,
|
||||
Globals.AppTouchscreenKeyboardKeysAmountAutoFire,
|
||||
Globals.TouchscreenKeyboardTransparency );
|
||||
SetupTouchscreenKeyboardGraphics(p);
|
||||
for( int i = 0; i < Globals.RemapScreenKbKeycode.length; i++ )
|
||||
nativeSetKeymapKeyScreenKb(i, SDL_Keys.values[Globals.RemapScreenKbKeycode[i]]);
|
||||
if( Globals.TouchscreenKeyboardSize == Globals.TOUCHSCREEN_KEYBOARD_CUSTOM )
|
||||
{
|
||||
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ )
|
||||
if( Globals.ScreenKbControlsLayout[i][0] < Globals.ScreenKbControlsLayout[i][2] )
|
||||
nativeSetScreenKbKeyLayout( i, Globals.ScreenKbControlsLayout[i][0], Globals.ScreenKbControlsLayout[i][1],
|
||||
Globals.ScreenKbControlsLayout[i][2], Globals.ScreenKbControlsLayout[i][3]);
|
||||
}
|
||||
for( int i = 0; i < Globals.ScreenKbControlsShown.length; i++ )
|
||||
nativeSetScreenKbKeyUsed(i, Globals.ScreenKbControlsShown[i] ? 1 : 0);
|
||||
}
|
||||
else
|
||||
Globals.UseTouchscreenKeyboard = false;
|
||||
}
|
||||
|
||||
for( int i = 0; i < SDL_Keys.JAVA_KEYCODE_LAST; i++ )
|
||||
nativeSetKeymapKey(i, SDL_Keys.values[Globals.RemapHwKeycode[i]]);
|
||||
for( int i = 0; i < Globals.RemapMultitouchGestureKeycode.length; i++ )
|
||||
nativeSetKeymapKeyMultitouchGesture(i, Globals.MultitouchGesturesUsed[i] ? SDL_Keys.values[Globals.RemapMultitouchGestureKeycode[i]] : 0);
|
||||
nativeSetMultitouchGestureSensitivity(Globals.MultitouchGestureSensitivity);
|
||||
if( Globals.TouchscreenCalibration[2] > Globals.TouchscreenCalibration[0] )
|
||||
nativeSetTouchscreenCalibration(Globals.TouchscreenCalibration[0], Globals.TouchscreenCalibration[1],
|
||||
Globals.TouchscreenCalibration[2], Globals.TouchscreenCalibration[3]);*/
|
||||
|
||||
String lang = new String(Locale.getDefault().getLanguage());
|
||||
if( Locale.getDefault().getCountry().length() > 0 )
|
||||
lang = lang + "_" + Locale.getDefault().getCountry();
|
||||
Log.i("SDL", "libSDL: setting envvar LANGUAGE to '" + lang + "'");
|
||||
nativeSetEnv( "LANG", lang );
|
||||
nativeSetEnv( "LANGUAGE", lang );
|
||||
// TODO: get current user name and set envvar USER, the API is not availalbe on Android 1.6 so I don't bother with this
|
||||
nativeSetEnv( "APPDIR", p.getFilesDir().getAbsolutePath() );
|
||||
nativeSetEnv( "SECURE_STORAGE_DIR", p.getFilesDir().getAbsolutePath() );
|
||||
nativeSetEnv( "DATADIR", Globals.DataDir );
|
||||
nativeSetEnv( "UNSECURE_STORAGE_DIR", Globals.DataDir );
|
||||
nativeSetEnv( "HOME", Globals.DataDir );
|
||||
nativeSetEnv( "ANDROID_VERSION", String.valueOf(android.os.Build.VERSION.SDK_INT) );
|
||||
Log.d("SDL", "libSDL: Is running on OUYA: " + p.isRunningOnOUYA());
|
||||
if( p.isRunningOnOUYA() )
|
||||
nativeSetEnv( "OUYA", "1" );
|
||||
try {
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
p.getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
float xx = dm.widthPixels/dm.xdpi;
|
||||
float yy = dm.heightPixels/dm.ydpi;
|
||||
float x = Math.max(xx, yy);
|
||||
float y = Math.min(xx, yy);
|
||||
float displayInches = (float)Math.sqrt( x*x + y*y );
|
||||
nativeSetEnv( "DISPLAY_SIZE", String.valueOf(displayInches) );
|
||||
nativeSetEnv( "DISPLAY_SIZE_MM", String.valueOf((int)(displayInches*25.4f)) );
|
||||
nativeSetEnv( "DISPLAY_WIDTH", String.valueOf(x) );
|
||||
nativeSetEnv( "DISPLAY_HEIGHT", String.valueOf(y) );
|
||||
nativeSetEnv( "DISPLAY_WIDTH_MM", String.valueOf((int)(x*25.4f)) );
|
||||
nativeSetEnv( "DISPLAY_HEIGHT_MM", String.valueOf((int)(y*25.4f)) );
|
||||
nativeSetEnv( "DISPLAY_RESOLUTION_WIDTH", String.valueOf(Math.max(dm.widthPixels, dm.heightPixels)) );
|
||||
nativeSetEnv( "DISPLAY_RESOLUTION_HEIGHT", String.valueOf(Math.min(dm.widthPixels, dm.heightPixels)) );
|
||||
} catch (Exception eeeee) {}
|
||||
}
|
||||
|
||||
static byte [] loadRaw(Activity p, int res)
|
||||
{
|
||||
byte [] buf = new byte[65536 * 2];
|
||||
byte [] a = new byte[65536 * 4 * 10]; // We need 2363516 bytes for the Sun theme
|
||||
int written = 0;
|
||||
try{
|
||||
InputStream is = new GZIPInputStream(p.getResources().openRawResource(res));
|
||||
int readed = 0;
|
||||
while( (readed = is.read(buf)) >= 0 )
|
||||
{
|
||||
if( written + readed > a.length )
|
||||
{
|
||||
byte [] b = new byte [written + readed];
|
||||
System.arraycopy(a, 0, b, 0, written);
|
||||
a = b;
|
||||
}
|
||||
System.arraycopy(buf, 0, a, written, readed);
|
||||
written += readed;
|
||||
}
|
||||
} catch(Exception e) {};
|
||||
byte [] b = new byte [written];
|
||||
System.arraycopy(a, 0, b, 0, written);
|
||||
return b;
|
||||
}
|
||||
|
||||
static void SetupTouchscreenKeyboardGraphics(Activity p)
|
||||
{
|
||||
if( Globals.UseTouchscreenKeyboard )
|
||||
{
|
||||
if(Globals.TouchscreenKeyboardTheme < 0)
|
||||
Globals.TouchscreenKeyboardTheme = 0;
|
||||
if(Globals.TouchscreenKeyboardTheme > 3)
|
||||
Globals.TouchscreenKeyboardTheme = 3;
|
||||
|
||||
if( Globals.TouchscreenKeyboardTheme == 0 )
|
||||
{
|
||||
nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.ultimatedroid));
|
||||
}
|
||||
if( Globals.TouchscreenKeyboardTheme == 1 )
|
||||
{
|
||||
nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.simpletheme));
|
||||
}
|
||||
if( Globals.TouchscreenKeyboardTheme == 2 )
|
||||
{
|
||||
nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.sun));
|
||||
}
|
||||
if( Globals.TouchscreenKeyboardTheme == 3 )
|
||||
{
|
||||
nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.keen));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract static class SdcardAppPath
|
||||
{
|
||||
private static SdcardAppPath get()
|
||||
{
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO)
|
||||
return Froyo.Holder.sInstance;
|
||||
else
|
||||
return Dummy.Holder.sInstance;
|
||||
}
|
||||
public abstract String path(final Context p);
|
||||
public static String deprecatedPath(final Context p)
|
||||
{
|
||||
return Environment.getExternalStorageDirectory().getAbsolutePath() + "/app-data/" + p.getPackageName();
|
||||
}
|
||||
public static String getPath(final Context p)
|
||||
{
|
||||
try {
|
||||
return get().path(p);
|
||||
} catch(Exception e) { }
|
||||
return Dummy.Holder.sInstance.path(p);
|
||||
}
|
||||
|
||||
private static class Froyo extends SdcardAppPath
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
private static final Froyo sInstance = new Froyo();
|
||||
}
|
||||
public String path(final Context p)
|
||||
{
|
||||
return p.getExternalFilesDir(null).getAbsolutePath();
|
||||
}
|
||||
}
|
||||
private static class Dummy extends SdcardAppPath
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
private static final Dummy sInstance = new Dummy();
|
||||
}
|
||||
public String path(final Context p)
|
||||
{
|
||||
return Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/" + p.getPackageName() + "/files";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static boolean checkRamSize(final MainActivity p)
|
||||
{
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new FileReader("/proc/meminfo"));
|
||||
String line = null;
|
||||
while( ( line = reader.readLine() ) != null )
|
||||
{
|
||||
if( line.indexOf("MemTotal:") == 0 )
|
||||
{
|
||||
String[] fields = line.split("[ \t]+");
|
||||
Long size = Long.parseLong(fields[1]);
|
||||
Log.i("SDL", "Device RAM size: " + size / 1024 + " Mb, required minimum RAM: " + Globals.AppMinimumRAM + " Mb" );
|
||||
if( size / 1024 < Globals.AppMinimumRAM )
|
||||
{
|
||||
settingsChanged = true;
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.not_enough_ram);
|
||||
builder.setMessage(p.getResources().getString( R.string.not_enough_ram_size, Globals.AppMinimumRAM, (int)(size / 1024)) );
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
p.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + p.getPackageName())));
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(p.getResources().getString(R.string.ignore), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
SettingsMenu.showConfig(p, true);
|
||||
return;
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
p.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + p.getPackageName())));
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
final AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
Log.i("SDL", "Error: cannot parse /proc/meminfo: " + e.toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static native void nativeSetTrackballUsed();
|
||||
private static native void nativeSetTrackballDampening(int value);
|
||||
private static native void nativeSetAccelerometerSettings(int sensitivity, int centerPos);
|
||||
private static native void nativeSetMouseUsed(int RightClickMethod, int ShowScreenUnderFinger, int LeftClickMethod,
|
||||
int MoveMouseWithJoystick, int ClickMouseWithDpad, int MaxForce, int MaxRadius,
|
||||
int MoveMouseWithJoystickSpeed, int MoveMouseWithJoystickAccel,
|
||||
int leftClickKeycode, int rightClickKeycode,
|
||||
int leftClickTimeout, int rightClickTimeout,
|
||||
int relativeMovement, int relativeMovementSpeed,
|
||||
int relativeMovementAccel, int showMouseCursor);
|
||||
private static native void nativeSetJoystickUsed(int firstJoystickUsed, int secondJoystickUsed);
|
||||
private static native void nativeSetAccelerometerUsed();
|
||||
private static native void nativeSetMultitouchUsed();
|
||||
private static native void nativeSetTouchscreenKeyboardUsed();
|
||||
private static native void nativeSetVideoLinearFilter();
|
||||
private static native void nativeSetVideoDepth(int bpp, int gles2);
|
||||
private static native void nativeSetCompatibilityHacks();
|
||||
private static native void nativeSetVideoMultithreaded();
|
||||
private static native void nativeSetVideoForceSoftwareMode();
|
||||
private static native void nativeSetupScreenKeyboard(int size, int drawsize, int theme, int nbuttonsAutoFire, int transparency);
|
||||
private static native void nativeSetupScreenKeyboardButtons(byte[] img);
|
||||
private static native void nativeInitKeymap();
|
||||
private static native int nativeGetKeymapKey(int key);
|
||||
private static native void nativeSetKeymapKey(int javakey, int key);
|
||||
private static native int nativeGetKeymapKeyScreenKb(int keynum);
|
||||
private static native void nativeSetKeymapKeyScreenKb(int keynum, int key);
|
||||
private static native void nativeSetScreenKbKeyUsed(int keynum, int used);
|
||||
private static native void nativeSetScreenKbKeyLayout(int keynum, int x1, int y1, int x2, int y2);
|
||||
private static native int nativeGetKeymapKeyMultitouchGesture(int keynum);
|
||||
private static native void nativeSetKeymapKeyMultitouchGesture(int keynum, int key);
|
||||
private static native void nativeSetMultitouchGestureSensitivity(int sensitivity);
|
||||
private static native void nativeSetTouchscreenCalibration(int x1, int y1, int x2, int y2);
|
||||
public static native void nativeSetEnv(final String name, final String value);
|
||||
public static native int nativeChmod(final String name, int mode);
|
||||
public static native void nativeChdir(final String dir);
|
||||
}
|
||||
|
||||
257
project/javaSDL2/SettingsMenu.java
Normal file
257
project/javaSDL2/SettingsMenu.java
Normal file
@@ -0,0 +1,257 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
import android.util.Log;
|
||||
import java.io.*;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Environment;
|
||||
import android.os.StatFs;
|
||||
import java.util.Locale;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.Collections;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import java.lang.String;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.RectF;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Bitmap;
|
||||
import android.widget.TextView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Button;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.text.Editable;
|
||||
import android.text.SpannedString;
|
||||
import android.content.Intent;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.AlarmManager;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.net.Uri;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.Arrays;
|
||||
import android.graphics.Color;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.Sensor;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
class SettingsMenu
|
||||
{
|
||||
public static abstract class Menu
|
||||
{
|
||||
// Should be overridden by children
|
||||
abstract void run(final MainActivity p);
|
||||
abstract String title(final MainActivity p);
|
||||
boolean enabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// Should not be overridden
|
||||
boolean enabledOrHidden()
|
||||
{
|
||||
for( Menu m: Globals.HiddenMenuOptions )
|
||||
{
|
||||
if( m.getClass().getName().equals( this.getClass().getName() ) )
|
||||
return false;
|
||||
}
|
||||
return enabled();
|
||||
}
|
||||
void showMenuOptionsList(final MainActivity p, final Menu[] list)
|
||||
{
|
||||
menuStack.add(this);
|
||||
ArrayList<CharSequence> items = new ArrayList<CharSequence> ();
|
||||
for( Menu m: list )
|
||||
{
|
||||
if(m.enabledOrHidden())
|
||||
items.add(m.title(p));
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(title(p));
|
||||
builder.setItems(items.toArray(new CharSequence[0]), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
int selected = 0;
|
||||
|
||||
for( Menu m: list )
|
||||
{
|
||||
if(m.enabledOrHidden())
|
||||
{
|
||||
if( selected == item )
|
||||
{
|
||||
m.run(p);
|
||||
return;
|
||||
}
|
||||
selected ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBackOuterMenu(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static ArrayList<Menu> menuStack = new ArrayList<Menu> ();
|
||||
|
||||
public static void showConfig(final MainActivity p, final boolean firstStart)
|
||||
{
|
||||
Settings.settingsChanged = true;
|
||||
if( Globals.OptionalDataDownload == null )
|
||||
{
|
||||
String downloads[] = Globals.DataDownloadUrl;
|
||||
Globals.OptionalDataDownload = new boolean[downloads.length];
|
||||
boolean oldFormat = true;
|
||||
for( int i = 0; i < downloads.length; i++ )
|
||||
{
|
||||
if( downloads[i].indexOf("!") == 0 )
|
||||
{
|
||||
Globals.OptionalDataDownload[i] = true;
|
||||
oldFormat = false;
|
||||
}
|
||||
}
|
||||
if( oldFormat )
|
||||
Globals.OptionalDataDownload[0] = true;
|
||||
}
|
||||
|
||||
if(!firstStart)
|
||||
new MainMenu().run(p);
|
||||
else
|
||||
{
|
||||
if( Globals.StartupMenuButtonTimeout > 0 ) // If we did not disable startup menu altogether
|
||||
{
|
||||
for( Menu m: Globals.FirstStartMenuOptions )
|
||||
{
|
||||
boolean hidden = false;
|
||||
for( Menu m1: Globals.HiddenMenuOptions )
|
||||
{
|
||||
if( m1.getClass().getName().equals( m.getClass().getName() ) )
|
||||
hidden = true;
|
||||
}
|
||||
if( ! hidden )
|
||||
menuStack.add(0, m);
|
||||
}
|
||||
}
|
||||
goBack(p);
|
||||
}
|
||||
}
|
||||
|
||||
static void goBack(final MainActivity p)
|
||||
{
|
||||
if(menuStack.isEmpty())
|
||||
{
|
||||
Settings.Save(p);
|
||||
p.startDownloader();
|
||||
}
|
||||
else
|
||||
{
|
||||
Menu c = menuStack.remove(menuStack.size() - 1);
|
||||
c.run(p);
|
||||
}
|
||||
}
|
||||
|
||||
static void goBackOuterMenu(final MainActivity p)
|
||||
{
|
||||
if(!menuStack.isEmpty())
|
||||
menuStack.remove(menuStack.size() - 1);
|
||||
goBack(p);
|
||||
}
|
||||
|
||||
static class OkButton extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.ok);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
goBackOuterMenu(p);
|
||||
}
|
||||
}
|
||||
|
||||
static class DummyMenu extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.ok);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
}
|
||||
|
||||
static class MainMenu extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.device_config);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
Menu options[] =
|
||||
{
|
||||
new SettingsMenuMisc.DownloadConfig(),
|
||||
new SettingsMenuMisc.OptionalDownloadConfig(false),
|
||||
new SettingsMenuKeyboard.KeyboardConfigMainMenu(),
|
||||
new SettingsMenuMouse.MouseConfigMainMenu(),
|
||||
new SettingsMenuMisc.GyroscopeCalibration(),
|
||||
new SettingsMenuMisc.AudioConfig(),
|
||||
new SettingsMenuKeyboard.RemapHwKeysConfig(),
|
||||
new SettingsMenuKeyboard.ScreenGesturesConfig(),
|
||||
new SettingsMenuMisc.VideoSettingsConfig(),
|
||||
new SettingsMenuMisc.ResetToDefaultsConfig(),
|
||||
new OkButton(),
|
||||
};
|
||||
showMenuOptionsList(p, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
843
project/javaSDL2/SettingsMenuKeyboard.java
Normal file
843
project/javaSDL2/SettingsMenuKeyboard.java
Normal file
@@ -0,0 +1,843 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
import android.util.Log;
|
||||
import java.io.*;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Environment;
|
||||
import android.os.StatFs;
|
||||
import java.util.Locale;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.Collections;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import java.lang.String;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.RectF;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Bitmap;
|
||||
import android.widget.TextView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Button;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.text.Editable;
|
||||
import android.text.SpannedString;
|
||||
import android.content.Intent;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.AlarmManager;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.net.Uri;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.Arrays;
|
||||
import android.graphics.Color;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.Sensor;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
class SettingsMenuKeyboard extends SettingsMenu
|
||||
{
|
||||
static class KeyboardConfigMainMenu extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.controls_screenkb);
|
||||
}
|
||||
boolean enabled()
|
||||
{
|
||||
return Globals.UseTouchscreenKeyboard;
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
Menu options[] =
|
||||
{
|
||||
new ScreenKeyboardThemeConfig(),
|
||||
new ScreenKeyboardSizeConfig(),
|
||||
new ScreenKeyboardDrawSizeConfig(),
|
||||
new ScreenKeyboardTransparencyConfig(),
|
||||
new RemapScreenKbConfig(),
|
||||
new CustomizeScreenKbLayout(),
|
||||
new OkButton(),
|
||||
};
|
||||
showMenuOptionsList(p, options);
|
||||
}
|
||||
}
|
||||
|
||||
static class ScreenKeyboardSizeConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.controls_screenkb_size);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.controls_screenkb_large),
|
||||
p.getResources().getString(R.string.controls_screenkb_medium),
|
||||
p.getResources().getString(R.string.controls_screenkb_small),
|
||||
p.getResources().getString(R.string.controls_screenkb_tiny),
|
||||
p.getResources().getString(R.string.controls_screenkb_custom) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_size));
|
||||
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardSize, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.TouchscreenKeyboardSize = item;
|
||||
dialog.dismiss();
|
||||
if( Globals.TouchscreenKeyboardSize == Globals.TOUCHSCREEN_KEYBOARD_CUSTOM )
|
||||
new CustomizeScreenKbLayout().run(p);
|
||||
else
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class ScreenKeyboardDrawSizeConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.controls_screenkb_drawsize);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.controls_screenkb_large),
|
||||
p.getResources().getString(R.string.controls_screenkb_medium),
|
||||
p.getResources().getString(R.string.controls_screenkb_small),
|
||||
p.getResources().getString(R.string.controls_screenkb_tiny) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_drawsize));
|
||||
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardDrawSize, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.TouchscreenKeyboardDrawSize = item;
|
||||
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class ScreenKeyboardThemeConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.controls_screenkb_theme);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = {
|
||||
p.getResources().getString(R.string.controls_screenkb_by, "Ultimate Droid", "Sean Stieber"),
|
||||
p.getResources().getString(R.string.controls_screenkb_by, "Simple Theme", "Beholder"),
|
||||
p.getResources().getString(R.string.controls_screenkb_by, "Sun", "Sirea"),
|
||||
p.getResources().getString(R.string.controls_screenkb_by, "Keen", "Gerstrong")
|
||||
};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_theme));
|
||||
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardTheme, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.TouchscreenKeyboardTheme = item;
|
||||
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class ScreenKeyboardTransparencyConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.controls_screenkb_transparency);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.controls_screenkb_trans_0),
|
||||
p.getResources().getString(R.string.controls_screenkb_trans_1),
|
||||
p.getResources().getString(R.string.controls_screenkb_trans_2),
|
||||
p.getResources().getString(R.string.controls_screenkb_trans_3),
|
||||
p.getResources().getString(R.string.controls_screenkb_trans_4) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_transparency));
|
||||
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardTransparency, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.TouchscreenKeyboardTransparency = item;
|
||||
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class RemapHwKeysConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.remap_hwkeys);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
p.setText(p.getResources().getString(R.string.remap_hwkeys_press));
|
||||
p.keyListener = new KeyRemapTool(p);
|
||||
}
|
||||
|
||||
public static class KeyRemapTool implements MainActivity.KeyEventsListener
|
||||
{
|
||||
MainActivity p;
|
||||
public KeyRemapTool(MainActivity _p)
|
||||
{
|
||||
p = _p;
|
||||
}
|
||||
|
||||
public void onKeyEvent(final int keyCode)
|
||||
{
|
||||
p.keyListener = null;
|
||||
int keyIndex = keyCode;
|
||||
if( keyIndex < 0 )
|
||||
keyIndex = 0;
|
||||
if( keyIndex > SDL_Keys.JAVA_KEYCODE_LAST )
|
||||
keyIndex = 0;
|
||||
|
||||
final int KeyIndexFinal = keyIndex;
|
||||
CharSequence[] items = {
|
||||
SDL_Keys.names[Globals.RemapScreenKbKeycode[0]],
|
||||
SDL_Keys.names[Globals.RemapScreenKbKeycode[1]],
|
||||
SDL_Keys.names[Globals.RemapScreenKbKeycode[2]],
|
||||
SDL_Keys.names[Globals.RemapScreenKbKeycode[3]],
|
||||
SDL_Keys.names[Globals.RemapScreenKbKeycode[4]],
|
||||
SDL_Keys.names[Globals.RemapScreenKbKeycode[5]],
|
||||
p.getResources().getString(R.string.remap_hwkeys_select_more_keys),
|
||||
};
|
||||
|
||||
for( int i = 0; i < Math.min(6, Globals.AppTouchscreenKeyboardKeysNames.length); i++ )
|
||||
items[i] = Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.remap_hwkeys_select_simple);
|
||||
builder.setItems(items, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
if( item >= 6 )
|
||||
ShowAllKeys(KeyIndexFinal);
|
||||
else
|
||||
{
|
||||
Globals.RemapHwKeycode[KeyIndexFinal] = Globals.RemapScreenKbKeycode[item];
|
||||
goBack(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
public void ShowAllKeys(final int KeyIndex)
|
||||
{
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.remap_hwkeys_select);
|
||||
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapHwKeycode[KeyIndex]], new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.RemapHwKeycode[KeyIndex] = SDL_Keys.namesSortedIdx[item];
|
||||
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class RemapScreenKbConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.remap_screenkb);
|
||||
}
|
||||
//boolean enabled() { return true; };
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
CharSequence[] items = {
|
||||
p.getResources().getString(R.string.remap_screenkb_joystick),
|
||||
p.getResources().getString(R.string.remap_screenkb_button_text),
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 1",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 2",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 3",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 4",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 5",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 6",
|
||||
};
|
||||
|
||||
boolean defaults[] = Arrays.copyOf(Globals.ScreenKbControlsShown, Globals.ScreenKbControlsShown.length);
|
||||
if( Globals.AppUsesSecondJoystick )
|
||||
{
|
||||
items = Arrays.copyOf(items, items.length + 1);
|
||||
items[items.length - 1] = p.getResources().getString(R.string.remap_screenkb_joystick) + " 2";
|
||||
defaults = Arrays.copyOf(defaults, defaults.length + 1);
|
||||
defaults[defaults.length - 1] = true;
|
||||
}
|
||||
|
||||
for( int i = 0; i < Math.min(6, Globals.AppTouchscreenKeyboardKeysNames.length); i++ )
|
||||
items[i+2] = items[i+2] + " - " + Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.remap_screenkb));
|
||||
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
||||
{
|
||||
Globals.ScreenKbControlsShown[item] = isChecked;
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
showRemapScreenKbConfig2(p, 0);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showRemapScreenKbConfig2(final MainActivity p, final int currentButton)
|
||||
{
|
||||
CharSequence[] items = {
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 1",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 2",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 3",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 4",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 5",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 6",
|
||||
};
|
||||
|
||||
for( int i = 0; i < Math.min(6, Globals.AppTouchscreenKeyboardKeysNames.length); i++ )
|
||||
items[i] = items[i] + " - " + Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
|
||||
|
||||
if( currentButton >= Globals.RemapScreenKbKeycode.length )
|
||||
{
|
||||
goBack(p);
|
||||
return;
|
||||
}
|
||||
if( ! Globals.ScreenKbControlsShown[currentButton + 2] )
|
||||
{
|
||||
showRemapScreenKbConfig2(p, currentButton + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(items[currentButton]);
|
||||
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapScreenKbKeycode[currentButton]], new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.RemapScreenKbKeycode[currentButton] = SDL_Keys.namesSortedIdx[item];
|
||||
|
||||
dialog.dismiss();
|
||||
showRemapScreenKbConfig2(p, currentButton + 1);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class ScreenGesturesConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.remap_screenkb_button_gestures);
|
||||
}
|
||||
//boolean enabled() { return true; };
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
CharSequence[] items = {
|
||||
p.getResources().getString(R.string.remap_screenkb_button_zoomin),
|
||||
p.getResources().getString(R.string.remap_screenkb_button_zoomout),
|
||||
p.getResources().getString(R.string.remap_screenkb_button_rotateleft),
|
||||
p.getResources().getString(R.string.remap_screenkb_button_rotateright),
|
||||
};
|
||||
|
||||
boolean defaults[] = {
|
||||
Globals.MultitouchGesturesUsed[0],
|
||||
Globals.MultitouchGesturesUsed[1],
|
||||
Globals.MultitouchGesturesUsed[2],
|
||||
Globals.MultitouchGesturesUsed[3],
|
||||
};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.remap_screenkb_button_gestures));
|
||||
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
||||
{
|
||||
Globals.MultitouchGesturesUsed[item] = isChecked;
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
showScreenGesturesConfig2(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showScreenGesturesConfig2(final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = {
|
||||
p.getResources().getString(R.string.accel_slow),
|
||||
p.getResources().getString(R.string.accel_medium),
|
||||
p.getResources().getString(R.string.accel_fast),
|
||||
p.getResources().getString(R.string.accel_veryfast)
|
||||
};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.remap_screenkb_button_gestures_sensitivity);
|
||||
builder.setSingleChoiceItems(items, Globals.MultitouchGestureSensitivity, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.MultitouchGestureSensitivity = item;
|
||||
|
||||
dialog.dismiss();
|
||||
showScreenGesturesConfig3(p, 0);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showScreenGesturesConfig3(final MainActivity p, final int currentButton)
|
||||
{
|
||||
CharSequence[] items = {
|
||||
p.getResources().getString(R.string.remap_screenkb_button_zoomin),
|
||||
p.getResources().getString(R.string.remap_screenkb_button_zoomout),
|
||||
p.getResources().getString(R.string.remap_screenkb_button_rotateleft),
|
||||
p.getResources().getString(R.string.remap_screenkb_button_rotateright),
|
||||
};
|
||||
|
||||
if( currentButton >= Globals.RemapMultitouchGestureKeycode.length )
|
||||
{
|
||||
goBack(p);
|
||||
return;
|
||||
}
|
||||
if( ! Globals.MultitouchGesturesUsed[currentButton] )
|
||||
{
|
||||
showScreenGesturesConfig3(p, currentButton + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(items[currentButton]);
|
||||
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapMultitouchGestureKeycode[currentButton]], new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.RemapMultitouchGestureKeycode[currentButton] = SDL_Keys.namesSortedIdx[item];
|
||||
|
||||
dialog.dismiss();
|
||||
showScreenGesturesConfig3(p, currentButton + 1);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class CustomizeScreenKbLayout extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.screenkb_custom_layout);
|
||||
}
|
||||
//boolean enabled() { return true; };
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help));
|
||||
CustomizeScreenKbLayoutTool tool = new CustomizeScreenKbLayoutTool(p);
|
||||
p.touchListener = tool;
|
||||
p.keyListener = tool;
|
||||
Globals.TouchscreenKeyboardSize = Globals.TOUCHSCREEN_KEYBOARD_CUSTOM;
|
||||
}
|
||||
|
||||
static class CustomizeScreenKbLayoutTool implements MainActivity.TouchEventsListener, MainActivity.KeyEventsListener
|
||||
{
|
||||
MainActivity p;
|
||||
FrameLayout layout = null;
|
||||
ImageView imgs[] = new ImageView[Globals.ScreenKbControlsLayout.length];
|
||||
Bitmap bmps[] = new Bitmap[Globals.ScreenKbControlsLayout.length];
|
||||
ImageView boundary = null;
|
||||
Bitmap boundaryBmp = null;
|
||||
int currentButton = 0;
|
||||
int buttons[] = {
|
||||
R.drawable.dpad,
|
||||
R.drawable.keyboard,
|
||||
R.drawable.b1,
|
||||
R.drawable.b2,
|
||||
R.drawable.b3,
|
||||
R.drawable.b4,
|
||||
R.drawable.b5,
|
||||
R.drawable.b6,
|
||||
R.drawable.dpad
|
||||
};
|
||||
int oldX = 0, oldY = 0;
|
||||
boolean resizing = false;
|
||||
|
||||
public CustomizeScreenKbLayoutTool(MainActivity _p)
|
||||
{
|
||||
p = _p;
|
||||
layout = new FrameLayout(p);
|
||||
p.getVideoLayout().addView(layout);
|
||||
boundary = new ImageView(p);
|
||||
boundary.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
||||
boundary.setScaleType(ImageView.ScaleType.MATRIX);
|
||||
boundaryBmp = BitmapFactory.decodeResource( p.getResources(), R.drawable.rectangle );
|
||||
boundary.setImageBitmap(boundaryBmp);
|
||||
layout.addView(boundary);
|
||||
currentButton = -1;
|
||||
if( Globals.TouchscreenKeyboardTheme == 2 )
|
||||
{
|
||||
buttons = new int[] {
|
||||
R.drawable.sun_dpad,
|
||||
R.drawable.sun_keyboard,
|
||||
R.drawable.sun_b1,
|
||||
R.drawable.sun_b2,
|
||||
R.drawable.sun_b3,
|
||||
R.drawable.sun_b4,
|
||||
R.drawable.sun_b5,
|
||||
R.drawable.sun_b6,
|
||||
R.drawable.sun_dpad
|
||||
};
|
||||
}
|
||||
|
||||
int displayX = 800;
|
||||
int displayY = 480;
|
||||
try {
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
p.getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
displayX = dm.widthPixels;
|
||||
displayY = dm.heightPixels;
|
||||
} catch (Exception eeeee) {}
|
||||
|
||||
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ )
|
||||
{
|
||||
if( ! Globals.ScreenKbControlsShown[i] )
|
||||
continue;
|
||||
if( currentButton == -1 )
|
||||
currentButton = i;
|
||||
//Log.i("SDL", "Screen kb button " + i + " coords " + Globals.ScreenKbControlsLayout[i][0] + ":" + Globals.ScreenKbControlsLayout[i][1] + ":" + Globals.ScreenKbControlsLayout[i][2] + ":" + Globals.ScreenKbControlsLayout[i][3] );
|
||||
// Check if the button is off screen edge or shrunk to zero
|
||||
if( Globals.ScreenKbControlsLayout[i][0] > Globals.ScreenKbControlsLayout[i][2] - displayY/12 )
|
||||
Globals.ScreenKbControlsLayout[i][0] = Globals.ScreenKbControlsLayout[i][2] - displayY/12;
|
||||
if( Globals.ScreenKbControlsLayout[i][1] > Globals.ScreenKbControlsLayout[i][3] - displayY/12 )
|
||||
Globals.ScreenKbControlsLayout[i][1] = Globals.ScreenKbControlsLayout[i][3] - displayY/12;
|
||||
if( Globals.ScreenKbControlsLayout[i][0] < Globals.ScreenKbControlsLayout[i][2] - displayY*2/3 )
|
||||
Globals.ScreenKbControlsLayout[i][0] = Globals.ScreenKbControlsLayout[i][2] - displayY*2/3;
|
||||
if( Globals.ScreenKbControlsLayout[i][1] < Globals.ScreenKbControlsLayout[i][3] - displayY*2/3 )
|
||||
Globals.ScreenKbControlsLayout[i][1] = Globals.ScreenKbControlsLayout[i][3] - displayY*2/3;
|
||||
if( Globals.ScreenKbControlsLayout[i][0] < 0 )
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[i][2] += -Globals.ScreenKbControlsLayout[i][0];
|
||||
Globals.ScreenKbControlsLayout[i][0] = 0;
|
||||
}
|
||||
if( Globals.ScreenKbControlsLayout[i][2] > displayX )
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[i][0] -= Globals.ScreenKbControlsLayout[i][2] - displayX;
|
||||
Globals.ScreenKbControlsLayout[i][2] = displayX;
|
||||
}
|
||||
if( Globals.ScreenKbControlsLayout[i][1] < 0 )
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[i][3] += -Globals.ScreenKbControlsLayout[i][1];
|
||||
Globals.ScreenKbControlsLayout[i][1] = 0;
|
||||
}
|
||||
if( Globals.ScreenKbControlsLayout[i][3] > displayY )
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[i][1] -= Globals.ScreenKbControlsLayout[i][3] - displayY;
|
||||
Globals.ScreenKbControlsLayout[i][3] = displayY;
|
||||
}
|
||||
//Log.i("SDL", "After bounds check coords " + Globals.ScreenKbControlsLayout[i][0] + ":" + Globals.ScreenKbControlsLayout[i][1] + ":" + Globals.ScreenKbControlsLayout[i][2] + ":" + Globals.ScreenKbControlsLayout[i][3] );
|
||||
|
||||
imgs[i] = new ImageView(p);
|
||||
imgs[i].setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
||||
imgs[i].setScaleType(ImageView.ScaleType.MATRIX);
|
||||
bmps[i] = BitmapFactory.decodeResource( p.getResources(), buttons[i] );
|
||||
imgs[i].setImageBitmap(bmps[i]);
|
||||
imgs[i].setAlpha(128);
|
||||
layout.addView(imgs[i]);
|
||||
Matrix m = new Matrix();
|
||||
RectF src = new RectF(0, 0, bmps[i].getWidth(), bmps[i].getHeight());
|
||||
RectF dst = new RectF(Globals.ScreenKbControlsLayout[i][0], Globals.ScreenKbControlsLayout[i][1],
|
||||
Globals.ScreenKbControlsLayout[i][2], Globals.ScreenKbControlsLayout[i][3]);
|
||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||
imgs[i].setImageMatrix(m);
|
||||
}
|
||||
boundary.bringToFront();
|
||||
if( currentButton == -1 )
|
||||
onKeyEvent( KeyEvent.KEYCODE_BACK ); // All buttons disabled - do not show anything
|
||||
else
|
||||
setupButton(currentButton);
|
||||
}
|
||||
|
||||
void setupButton(int i)
|
||||
{
|
||||
Matrix m = new Matrix();
|
||||
RectF src = new RectF(0, 0, bmps[i].getWidth(), bmps[i].getHeight());
|
||||
RectF dst = new RectF(Globals.ScreenKbControlsLayout[i][0], Globals.ScreenKbControlsLayout[i][1],
|
||||
Globals.ScreenKbControlsLayout[i][2], Globals.ScreenKbControlsLayout[i][3]);
|
||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||
imgs[i].setImageMatrix(m);
|
||||
m = new Matrix();
|
||||
src = new RectF(0, 0, boundaryBmp.getWidth(), boundaryBmp.getHeight());
|
||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||
boundary.setImageMatrix(m);
|
||||
String buttonText = "";
|
||||
if( i >= 2 && i <= 7 )
|
||||
buttonText = p.getResources().getString(R.string.remap_screenkb_button) + (i - 2);
|
||||
if( i >= 2 && i - 2 < Globals.AppTouchscreenKeyboardKeysNames.length )
|
||||
buttonText = Globals.AppTouchscreenKeyboardKeysNames[i - 2].replace("_", " ");
|
||||
if( i == 0 )
|
||||
buttonText = "Joystick";
|
||||
if( i == 1 )
|
||||
buttonText = "Text input";
|
||||
if( i == 8 )
|
||||
buttonText = "Joystick 2";
|
||||
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help) + "\n" + buttonText);
|
||||
}
|
||||
|
||||
public void onTouchEvent(final MotionEvent ev)
|
||||
{
|
||||
if( ev.getAction() == MotionEvent.ACTION_DOWN )
|
||||
{
|
||||
oldX = (int)ev.getX();
|
||||
oldY = (int)ev.getY();
|
||||
resizing = true;
|
||||
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ )
|
||||
{
|
||||
if( ! Globals.ScreenKbControlsShown[i] )
|
||||
continue;
|
||||
if( Globals.ScreenKbControlsLayout[i][0] <= oldX &&
|
||||
Globals.ScreenKbControlsLayout[i][2] >= oldX &&
|
||||
Globals.ScreenKbControlsLayout[i][1] <= oldY &&
|
||||
Globals.ScreenKbControlsLayout[i][3] >= oldY )
|
||||
{
|
||||
currentButton = i;
|
||||
setupButton(currentButton);
|
||||
resizing = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( ev.getAction() == MotionEvent.ACTION_MOVE )
|
||||
{
|
||||
int dx = (int)ev.getX() - oldX;
|
||||
int dy = (int)ev.getY() - oldY;
|
||||
if( resizing )
|
||||
{
|
||||
// Resize slowly, with 1/3 of movement speed
|
||||
dx /= 6;
|
||||
dy /= 6;
|
||||
if( Globals.ScreenKbControlsLayout[currentButton][0] <= Globals.ScreenKbControlsLayout[currentButton][2] + dx*2 )
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[currentButton][0] -= dx;
|
||||
Globals.ScreenKbControlsLayout[currentButton][2] += dx;
|
||||
}
|
||||
if( Globals.ScreenKbControlsLayout[currentButton][1] <= Globals.ScreenKbControlsLayout[currentButton][3] + dy*2 )
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[currentButton][1] += dy;
|
||||
Globals.ScreenKbControlsLayout[currentButton][3] -= dy;
|
||||
}
|
||||
dx *= 6;
|
||||
dy *= 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[currentButton][0] += dx;
|
||||
Globals.ScreenKbControlsLayout[currentButton][2] += dx;
|
||||
Globals.ScreenKbControlsLayout[currentButton][1] += dy;
|
||||
Globals.ScreenKbControlsLayout[currentButton][3] += dy;
|
||||
}
|
||||
oldX += dx;
|
||||
oldY += dy;
|
||||
Matrix m = new Matrix();
|
||||
RectF src = new RectF(0, 0, bmps[currentButton].getWidth(), bmps[currentButton].getHeight());
|
||||
RectF dst = new RectF(Globals.ScreenKbControlsLayout[currentButton][0], Globals.ScreenKbControlsLayout[currentButton][1],
|
||||
Globals.ScreenKbControlsLayout[currentButton][2], Globals.ScreenKbControlsLayout[currentButton][3]);
|
||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||
imgs[currentButton].setImageMatrix(m);
|
||||
m = new Matrix();
|
||||
src = new RectF(0, 0, boundaryBmp.getWidth(), boundaryBmp.getHeight());
|
||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||
boundary.setImageMatrix(m);
|
||||
}
|
||||
}
|
||||
|
||||
public void onKeyEvent(final int keyCode)
|
||||
{
|
||||
if( keyCode == KeyEvent.KEYCODE_BACK )
|
||||
{
|
||||
p.getVideoLayout().removeView(layout);
|
||||
layout = null;
|
||||
p.touchListener = null;
|
||||
p.keyListener = null;
|
||||
goBack(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
755
project/javaSDL2/SettingsMenuMisc.java
Normal file
755
project/javaSDL2/SettingsMenuMisc.java
Normal file
@@ -0,0 +1,755 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
import android.util.Log;
|
||||
import java.io.*;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Environment;
|
||||
import android.os.StatFs;
|
||||
import java.util.Locale;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.Collections;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import java.lang.String;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.RectF;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Bitmap;
|
||||
import android.widget.TextView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Button;
|
||||
import android.widget.Scroller;
|
||||
import android.view.View;
|
||||
import android.view.Gravity;
|
||||
import android.widget.LinearLayout;
|
||||
import android.text.Editable;
|
||||
import android.text.SpannedString;
|
||||
import android.content.Intent;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.AlarmManager;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.net.Uri;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.Arrays;
|
||||
import android.graphics.Color;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.Sensor;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
class SettingsMenuMisc extends SettingsMenu
|
||||
{
|
||||
static class DownloadConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.storage_question);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
long freeSdcard = 0;
|
||||
long freePhone = 0;
|
||||
try
|
||||
{
|
||||
StatFs sdcard = new StatFs(Environment.getExternalStorageDirectory().getPath());
|
||||
StatFs phone = new StatFs(Environment.getDataDirectory().getPath());
|
||||
freeSdcard = (long)sdcard.getAvailableBlocks() * sdcard.getBlockSize() / 1024 / 1024;
|
||||
freePhone = (long)phone.getAvailableBlocks() * phone.getBlockSize() / 1024 / 1024;
|
||||
}
|
||||
catch(Exception e) {}
|
||||
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.storage_phone, freePhone),
|
||||
p.getResources().getString(R.string.storage_sd, freeSdcard),
|
||||
p.getResources().getString(R.string.storage_custom) };
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.storage_question));
|
||||
builder.setSingleChoiceItems(items, Globals.DownloadToSdcard ? 1 : 0, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
|
||||
if( item == 2 )
|
||||
showCustomDownloadDirConfig(p);
|
||||
else
|
||||
{
|
||||
Globals.DownloadToSdcard = (item != 0);
|
||||
Globals.DataDir = Globals.DownloadToSdcard ?
|
||||
Settings.SdcardAppPath.getPath(p) :
|
||||
p.getFilesDir().getAbsolutePath();
|
||||
goBack(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
static void showCustomDownloadDirConfig(final MainActivity p)
|
||||
{
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.storage_custom));
|
||||
|
||||
final EditText edit = new EditText(p);
|
||||
edit.setFocusableInTouchMode(true);
|
||||
edit.setFocusable(true);
|
||||
edit.setText(Globals.DataDir);
|
||||
builder.setView(edit);
|
||||
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.DataDir = edit.getText().toString();
|
||||
dialog.dismiss();
|
||||
showCommandLineConfig(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
static void showCommandLineConfig(final MainActivity p)
|
||||
{
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.storage_commandline));
|
||||
|
||||
final EditText edit = new EditText(p);
|
||||
edit.setFocusableInTouchMode(true);
|
||||
edit.setFocusable(true);
|
||||
edit.setText(Globals.CommandLine);
|
||||
builder.setView(edit);
|
||||
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.CommandLine = edit.getText().toString();
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class OptionalDownloadConfig extends Menu
|
||||
{
|
||||
boolean firstStart = false;
|
||||
OptionalDownloadConfig()
|
||||
{
|
||||
firstStart = true;
|
||||
}
|
||||
OptionalDownloadConfig(boolean firstStart)
|
||||
{
|
||||
this.firstStart = firstStart;
|
||||
}
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.downloads);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
String [] downloadFiles = Globals.DataDownloadUrl;
|
||||
final boolean [] mandatory = new boolean[downloadFiles.length];
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.downloads));
|
||||
|
||||
CharSequence[] items = new CharSequence[downloadFiles.length];
|
||||
for(int i = 0; i < downloadFiles.length; i++ )
|
||||
{
|
||||
items[i] = new String(downloadFiles[i].split("[|]")[0]);
|
||||
if( items[i].toString().indexOf("!") == 0 )
|
||||
items[i] = items[i].toString().substring(1);
|
||||
if( items[i].toString().indexOf("!") == 0 )
|
||||
{
|
||||
items[i] = items[i].toString().substring(1);
|
||||
mandatory[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( Globals.OptionalDataDownload == null || Globals.OptionalDataDownload.length != items.length )
|
||||
{
|
||||
Globals.OptionalDataDownload = new boolean[downloadFiles.length];
|
||||
boolean oldFormat = true;
|
||||
for( int i = 0; i < downloadFiles.length; i++ )
|
||||
{
|
||||
if( downloadFiles[i].indexOf("!") == 0 )
|
||||
{
|
||||
Globals.OptionalDataDownload[i] = true;
|
||||
oldFormat = false;
|
||||
}
|
||||
}
|
||||
if( oldFormat )
|
||||
{
|
||||
Globals.OptionalDataDownload[0] = true;
|
||||
mandatory[0] = true;
|
||||
}
|
||||
}
|
||||
|
||||
builder.setMultiChoiceItems(items, Globals.OptionalDataDownload, new DialogInterface.OnMultiChoiceClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
||||
{
|
||||
Globals.OptionalDataDownload[item] = isChecked;
|
||||
if( mandatory[item] && !isChecked )
|
||||
{
|
||||
Globals.OptionalDataDownload[item] = true;
|
||||
((AlertDialog)dialog).getListView().setItemChecked(item, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
if( firstStart )
|
||||
{
|
||||
builder.setNegativeButton(p.getResources().getString(R.string.show_more_options), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
menuStack.clear();
|
||||
new MainMenu().run(p);
|
||||
}
|
||||
});
|
||||
}
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class AudioConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.audiobuf_question);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.audiobuf_verysmall),
|
||||
p.getResources().getString(R.string.audiobuf_small),
|
||||
p.getResources().getString(R.string.audiobuf_medium),
|
||||
p.getResources().getString(R.string.audiobuf_large) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.audiobuf_question);
|
||||
builder.setSingleChoiceItems(items, Globals.AudioBufferConfig, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.AudioBufferConfig = item;
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class VideoSettingsConfig extends Menu
|
||||
{
|
||||
static int debugMenuShowCount = 0;
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.video);
|
||||
}
|
||||
//boolean enabled() { return true; };
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
debugMenuShowCount++;
|
||||
CharSequence[] items = {
|
||||
p.getResources().getString(R.string.pointandclick_keepaspectratio),
|
||||
p.getResources().getString(R.string.video_smooth)
|
||||
};
|
||||
boolean defaults[] = {
|
||||
Globals.KeepAspectRatio,
|
||||
Globals.VideoLinearFilter
|
||||
};
|
||||
|
||||
if(Globals.SwVideoMode && !Globals.CompatibilityHacksVideo)
|
||||
{
|
||||
CharSequence[] items2 = {
|
||||
p.getResources().getString(R.string.pointandclick_keepaspectratio),
|
||||
p.getResources().getString(R.string.video_smooth),
|
||||
p.getResources().getString(R.string.video_separatethread),
|
||||
};
|
||||
boolean defaults2[] = {
|
||||
Globals.KeepAspectRatio,
|
||||
Globals.VideoLinearFilter,
|
||||
Globals.MultiThreadedVideo
|
||||
};
|
||||
items = items2;
|
||||
defaults = defaults2;
|
||||
}
|
||||
|
||||
if(Globals.Using_SDL_1_3)
|
||||
{
|
||||
CharSequence[] items2 = {
|
||||
p.getResources().getString(R.string.pointandclick_keepaspectratio),
|
||||
};
|
||||
boolean defaults2[] = {
|
||||
Globals.KeepAspectRatio,
|
||||
};
|
||||
items = items2;
|
||||
defaults = defaults2;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.video));
|
||||
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
||||
{
|
||||
if( item == 0 )
|
||||
Globals.KeepAspectRatio = isChecked;
|
||||
if( item == 1 )
|
||||
Globals.VideoLinearFilter = isChecked;
|
||||
if( item == 2 )
|
||||
Globals.MultiThreadedVideo = isChecked;
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
if( debugMenuShowCount > 5 || Globals.OuyaEmulation )
|
||||
showDebugMenu(p);
|
||||
else
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
void showDebugMenu (final MainActivity p)
|
||||
{
|
||||
CharSequence[] items = {
|
||||
"OUYA emulation"
|
||||
};
|
||||
boolean defaults[] = {
|
||||
Globals.OuyaEmulation,
|
||||
};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle("Debug settings");
|
||||
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
||||
{
|
||||
if( item == 0 )
|
||||
Globals.OuyaEmulation = isChecked;
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class ShowReadme extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return "Readme";
|
||||
}
|
||||
boolean enabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
String readmes[] = Globals.ReadmeText.split("\\^");
|
||||
String lang = new String(Locale.getDefault().getLanguage()) + ":";
|
||||
if( p.isRunningOnOUYA() )
|
||||
lang = "ouya:";
|
||||
String readme = readmes[0];
|
||||
String buttonName = "", buttonUrl = "";
|
||||
for( String r: readmes )
|
||||
{
|
||||
if( r.startsWith(lang) )
|
||||
readme = r.substring(lang.length());
|
||||
if( r.startsWith("button:") )
|
||||
{
|
||||
buttonName = r.substring("button:".length());
|
||||
if( buttonName.indexOf(":") != -1 )
|
||||
{
|
||||
buttonUrl = buttonName.substring(buttonName.indexOf(":") + 1);
|
||||
buttonName = buttonName.substring(0, buttonName.indexOf(":"));
|
||||
}
|
||||
}
|
||||
}
|
||||
readme = readme.trim();
|
||||
if( readme.length() <= 2 )
|
||||
{
|
||||
goBack(p);
|
||||
return;
|
||||
}
|
||||
TextView text = new TextView(p);
|
||||
text.setMaxLines(100);
|
||||
//text.setScroller(new Scroller(p));
|
||||
//text.setVerticalScrollBarEnabled(true);
|
||||
text.setText(readme);
|
||||
text.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
text.setPadding(0, 5, 0, 20);
|
||||
text.setTextSize(20.0f);
|
||||
text.setGravity(Gravity.CENTER);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
ScrollView scroll = new ScrollView(p);
|
||||
scroll.addView(text, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
Button ok = new Button(p);
|
||||
final AlertDialog alertDismiss[] = new AlertDialog[1];
|
||||
ok.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
public void onClick(View v)
|
||||
{
|
||||
alertDismiss[0].cancel();
|
||||
}
|
||||
});
|
||||
ok.setText(R.string.ok);
|
||||
LinearLayout layout = new LinearLayout(p);
|
||||
layout.setOrientation(LinearLayout.VERTICAL);
|
||||
layout.addView(scroll);
|
||||
//layout.addView(text);
|
||||
layout.addView(ok);
|
||||
if( buttonName.length() > 0 )
|
||||
{
|
||||
Button cancel = new Button(p);
|
||||
cancel.setText(buttonName);
|
||||
final String url = buttonUrl;
|
||||
cancel.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
public void onClick(View v)
|
||||
{
|
||||
if( url.length() > 0 )
|
||||
{
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse(url));
|
||||
p.startActivity(i);
|
||||
}
|
||||
alertDismiss[0].cancel();
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
layout.addView(cancel);
|
||||
}
|
||||
builder.setView(layout);
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alertDismiss[0] = alert;
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class GyroscopeCalibration extends Menu implements SensorEventListener
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.calibrate_gyroscope);
|
||||
}
|
||||
boolean enabled()
|
||||
{
|
||||
return Globals.AppUsesGyroscope;
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
if( !Globals.AppUsesGyroscope || !AccelerometerReader.gyro.available(p) )
|
||||
{
|
||||
if( Globals.AppUsesGyroscope )
|
||||
{
|
||||
Toast toast = Toast.makeText(p, p.getResources().getString(R.string.calibrate_gyroscope_not_supported), Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
}
|
||||
goBack(p);
|
||||
return;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.calibrate_gyroscope));
|
||||
builder.setMessage(p.getResources().getString(R.string.calibrate_gyroscope_text));
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
startCalibration(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
ImageView img;
|
||||
Bitmap bmp;
|
||||
int numEvents;
|
||||
MainActivity p;
|
||||
|
||||
void startCalibration(final MainActivity _p)
|
||||
{
|
||||
p = _p;
|
||||
img = new ImageView(p);
|
||||
img.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
||||
img.setScaleType(ImageView.ScaleType.MATRIX);
|
||||
bmp = BitmapFactory.decodeResource( p.getResources(), R.drawable.calibrate );
|
||||
img.setImageBitmap(bmp);
|
||||
Matrix m = new Matrix();
|
||||
RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
|
||||
RectF dst = new RectF( p.getVideoLayout().getWidth()/2 - 50, p.getVideoLayout().getHeight()/2 - 50,
|
||||
p.getVideoLayout().getWidth()/2 + 50, p.getVideoLayout().getHeight()/2 + 50);
|
||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||
img.setImageMatrix(m);
|
||||
p.getVideoLayout().addView(img);
|
||||
numEvents = 0;
|
||||
AccelerometerReader.gyro.x1 = 100;
|
||||
AccelerometerReader.gyro.x2 = -100;
|
||||
AccelerometerReader.gyro.xc = 0;
|
||||
AccelerometerReader.gyro.y1 = 100;
|
||||
AccelerometerReader.gyro.y2 = -100;
|
||||
AccelerometerReader.gyro.yc = 0;
|
||||
AccelerometerReader.gyro.z1 = 100;
|
||||
AccelerometerReader.gyro.z2 = -100;
|
||||
AccelerometerReader.gyro.zc = 0;
|
||||
AccelerometerReader.gyro.registerListener(p, this);
|
||||
(new Thread(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
for(int count = 1; count < 10; count++)
|
||||
{
|
||||
p.setText("" + count + "0% ...");
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch( Exception e ) {}
|
||||
}
|
||||
finishCalibration(p);
|
||||
}
|
||||
}
|
||||
)).start();
|
||||
}
|
||||
|
||||
public void onSensorChanged(SensorEvent event)
|
||||
{
|
||||
gyroscopeEvent(event.values[0], event.values[1], event.values[2]);
|
||||
}
|
||||
public void onAccuracyChanged(Sensor s, int a)
|
||||
{
|
||||
}
|
||||
void gyroscopeEvent(float x, float y, float z)
|
||||
{
|
||||
numEvents++;
|
||||
AccelerometerReader.gyro.xc += x;
|
||||
AccelerometerReader.gyro.yc += y;
|
||||
AccelerometerReader.gyro.zc += z;
|
||||
AccelerometerReader.gyro.x1 = Math.min(AccelerometerReader.gyro.x1, x * 1.1f); // Small safety bound coefficient
|
||||
AccelerometerReader.gyro.x2 = Math.max(AccelerometerReader.gyro.x2, x * 1.1f);
|
||||
AccelerometerReader.gyro.y1 = Math.min(AccelerometerReader.gyro.y1, y * 1.1f);
|
||||
AccelerometerReader.gyro.y2 = Math.max(AccelerometerReader.gyro.y2, y * 1.1f);
|
||||
AccelerometerReader.gyro.z1 = Math.min(AccelerometerReader.gyro.z1, z * 1.1f);
|
||||
AccelerometerReader.gyro.z2 = Math.max(AccelerometerReader.gyro.z2, z * 1.1f);
|
||||
final Matrix m = new Matrix();
|
||||
RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
|
||||
RectF dst = new RectF( x * 5000 + p.getVideoLayout().getWidth()/2 - 50, y * 5000 + p.getVideoLayout().getHeight()/2 - 50,
|
||||
x * 5000 + p.getVideoLayout().getWidth()/2 + 50, y * 5000 + p.getVideoLayout().getHeight()/2 + 50);
|
||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||
p.runOnUiThread(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
img.setImageMatrix(m);
|
||||
}
|
||||
});
|
||||
}
|
||||
void finishCalibration(final MainActivity p)
|
||||
{
|
||||
AccelerometerReader.gyro.unregisterListener(p, this);
|
||||
try {
|
||||
Thread.sleep(200); // Just in case we have pending events
|
||||
} catch( Exception e ) {}
|
||||
if( numEvents > 5 )
|
||||
{
|
||||
AccelerometerReader.gyro.xc /= (float)numEvents;
|
||||
AccelerometerReader.gyro.yc /= (float)numEvents;
|
||||
AccelerometerReader.gyro.zc /= (float)numEvents;
|
||||
}
|
||||
p.runOnUiThread(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
p.getVideoLayout().removeView(img);
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static class ResetToDefaultsConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.reset_config);
|
||||
}
|
||||
boolean enabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.reset_config_ask));
|
||||
builder.setMessage(p.getResources().getString(R.string.reset_config_ask));
|
||||
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Settings.DeleteSdlConfigOnUpgradeAndRestart(p); // Never returns
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(p.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
771
project/javaSDL2/SettingsMenuMouse.java
Normal file
771
project/javaSDL2/SettingsMenuMouse.java
Normal file
@@ -0,0 +1,771 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
import android.util.Log;
|
||||
import java.io.*;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Environment;
|
||||
import android.os.StatFs;
|
||||
import java.util.Locale;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.Collections;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import java.lang.String;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.RectF;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Bitmap;
|
||||
import android.widget.TextView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Button;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.text.Editable;
|
||||
import android.text.SpannedString;
|
||||
import android.content.Intent;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.AlarmManager;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.net.Uri;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.Arrays;
|
||||
import android.graphics.Color;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.Sensor;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
class SettingsMenuMouse extends SettingsMenu
|
||||
{
|
||||
static class MouseConfigMainMenu extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.mouse_emulation);
|
||||
}
|
||||
boolean enabled()
|
||||
{
|
||||
return Globals.AppUsesMouse;
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
Menu options[] =
|
||||
{
|
||||
new DisplaySizeConfig(false),
|
||||
new LeftClickConfig(),
|
||||
new RightClickConfig(),
|
||||
new AdditionalMouseConfig(),
|
||||
new JoystickMouseConfig(),
|
||||
new TouchPressureMeasurementTool(),
|
||||
new CalibrateTouchscreenMenu(),
|
||||
new OkButton(),
|
||||
};
|
||||
showMenuOptionsList(p, options);
|
||||
}
|
||||
}
|
||||
|
||||
static class DisplaySizeConfig extends Menu
|
||||
{
|
||||
boolean firstStart = false;
|
||||
DisplaySizeConfig()
|
||||
{
|
||||
this.firstStart = true;
|
||||
}
|
||||
DisplaySizeConfig(boolean firstStart)
|
||||
{
|
||||
this.firstStart = firstStart;
|
||||
}
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.display_size_mouse);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
CharSequence[] items = {
|
||||
p.getResources().getString(R.string.display_size_tiny_touchpad),
|
||||
p.getResources().getString(R.string.display_size_tiny),
|
||||
p.getResources().getString(R.string.display_size_small),
|
||||
p.getResources().getString(R.string.display_size_small_touchpad),
|
||||
p.getResources().getString(R.string.display_size_large),
|
||||
};
|
||||
int _size_tiny_touchpad = 0;
|
||||
int _size_tiny = 1;
|
||||
int _size_small = 2;
|
||||
int _size_small_touchpad = 3;
|
||||
int _size_large = 4;
|
||||
int _more_options = 5;
|
||||
|
||||
if( ! Globals.SwVideoMode )
|
||||
{
|
||||
CharSequence[] items2 = {
|
||||
p.getResources().getString(R.string.display_size_small_touchpad),
|
||||
p.getResources().getString(R.string.display_size_large),
|
||||
};
|
||||
items = items2;
|
||||
_size_small_touchpad = 0;
|
||||
_size_large = 1;
|
||||
_size_tiny_touchpad = _size_tiny = _size_small = 1000;
|
||||
|
||||
}
|
||||
if( firstStart )
|
||||
{
|
||||
CharSequence[] items2 = {
|
||||
p.getResources().getString(R.string.display_size_tiny_touchpad),
|
||||
p.getResources().getString(R.string.display_size_tiny),
|
||||
p.getResources().getString(R.string.display_size_small),
|
||||
p.getResources().getString(R.string.display_size_small_touchpad),
|
||||
p.getResources().getString(R.string.display_size_large),
|
||||
p.getResources().getString(R.string.show_more_options),
|
||||
};
|
||||
items = items2;
|
||||
if( ! Globals.SwVideoMode )
|
||||
{
|
||||
CharSequence[] items3 = {
|
||||
p.getResources().getString(R.string.display_size_small_touchpad),
|
||||
p.getResources().getString(R.string.display_size_large),
|
||||
p.getResources().getString(R.string.show_more_options),
|
||||
};
|
||||
items = items3;
|
||||
_more_options = 3;
|
||||
}
|
||||
}
|
||||
// Java is so damn worse than C++11
|
||||
final int size_tiny_touchpad = _size_tiny_touchpad;
|
||||
final int size_tiny = _size_tiny;
|
||||
final int size_small = _size_small;
|
||||
final int size_small_touchpad = _size_small_touchpad;
|
||||
final int size_large = _size_large;
|
||||
final int more_options = _more_options;
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.display_size);
|
||||
class ClickListener implements DialogInterface.OnClickListener
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
if( item == size_large )
|
||||
{
|
||||
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NORMAL;
|
||||
Globals.RelativeMouseMovement = false;
|
||||
Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE;
|
||||
}
|
||||
if( item == size_small )
|
||||
{
|
||||
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NEAR_CURSOR;
|
||||
Globals.RelativeMouseMovement = false;
|
||||
Globals.ShowScreenUnderFinger = Mouse.ZOOM_MAGNIFIER;
|
||||
}
|
||||
if( item == size_small_touchpad )
|
||||
{
|
||||
Globals.LeftClickMethod = Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT;
|
||||
Globals.RelativeMouseMovement = true;
|
||||
Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE;
|
||||
}
|
||||
if( item == size_tiny )
|
||||
{
|
||||
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NEAR_CURSOR;
|
||||
Globals.RelativeMouseMovement = false;
|
||||
Globals.ShowScreenUnderFinger = Mouse.ZOOM_SCREEN_TRANSFORM;
|
||||
}
|
||||
if( item == size_tiny_touchpad )
|
||||
{
|
||||
Globals.LeftClickMethod = Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT;
|
||||
Globals.RelativeMouseMovement = true;
|
||||
Globals.ShowScreenUnderFinger = Mouse.ZOOM_FULLSCREEN_MAGNIFIER;
|
||||
}
|
||||
if( item == more_options )
|
||||
{
|
||||
menuStack.clear();
|
||||
new MainMenu().run(p);
|
||||
return;
|
||||
}
|
||||
goBack(p);
|
||||
}
|
||||
}
|
||||
builder.setItems(items, new ClickListener());
|
||||
/*
|
||||
else
|
||||
builder.setSingleChoiceItems(items,
|
||||
Globals.ShowScreenUnderFinger == Mouse.ZOOM_NONE ?
|
||||
( Globals.RelativeMouseMovement ? Globals.SwVideoMode ? 2 : 1 : 0 ) :
|
||||
( Globals.ShowScreenUnderFinger == Mouse.ZOOM_MAGNIFIER && Globals.SwVideoMode ) ? 1 :
|
||||
Globals.ShowScreenUnderFinger + 1,
|
||||
new ClickListener());
|
||||
*/
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class LeftClickConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.leftclick_question);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.leftclick_normal),
|
||||
p.getResources().getString(R.string.leftclick_near_cursor),
|
||||
p.getResources().getString(R.string.leftclick_multitouch),
|
||||
p.getResources().getString(R.string.leftclick_pressure),
|
||||
p.getResources().getString(R.string.rightclick_key),
|
||||
p.getResources().getString(R.string.leftclick_timeout),
|
||||
p.getResources().getString(R.string.leftclick_tap),
|
||||
p.getResources().getString(R.string.leftclick_tap_or_timeout) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.leftclick_question);
|
||||
builder.setSingleChoiceItems(items, Globals.LeftClickMethod, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
Globals.LeftClickMethod = item;
|
||||
if( item == Mouse.LEFT_CLICK_WITH_KEY )
|
||||
p.keyListener = new KeyRemapToolMouseClick(p, true);
|
||||
else if( item == Mouse.LEFT_CLICK_WITH_TIMEOUT || item == Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT )
|
||||
showLeftClickTimeoutConfig(p);
|
||||
else
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
static void showLeftClickTimeoutConfig(final MainActivity p) {
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.leftclick_timeout_time_0),
|
||||
p.getResources().getString(R.string.leftclick_timeout_time_1),
|
||||
p.getResources().getString(R.string.leftclick_timeout_time_2),
|
||||
p.getResources().getString(R.string.leftclick_timeout_time_3),
|
||||
p.getResources().getString(R.string.leftclick_timeout_time_4) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.leftclick_timeout_time);
|
||||
builder.setSingleChoiceItems(items, Globals.LeftClickTimeout, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.LeftClickTimeout = item;
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class RightClickConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.rightclick_question);
|
||||
}
|
||||
boolean enabled()
|
||||
{
|
||||
return Globals.AppNeedsTwoButtonMouse;
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.rightclick_none),
|
||||
p.getResources().getString(R.string.rightclick_multitouch),
|
||||
p.getResources().getString(R.string.rightclick_pressure),
|
||||
p.getResources().getString(R.string.rightclick_key),
|
||||
p.getResources().getString(R.string.leftclick_timeout) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.rightclick_question);
|
||||
builder.setSingleChoiceItems(items, Globals.RightClickMethod, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.RightClickMethod = item;
|
||||
dialog.dismiss();
|
||||
if( item == Mouse.RIGHT_CLICK_WITH_KEY )
|
||||
p.keyListener = new KeyRemapToolMouseClick(p, false);
|
||||
else if( item == Mouse.RIGHT_CLICK_WITH_TIMEOUT )
|
||||
showRightClickTimeoutConfig(p);
|
||||
else
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showRightClickTimeoutConfig(final MainActivity p) {
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.leftclick_timeout_time_0),
|
||||
p.getResources().getString(R.string.leftclick_timeout_time_1),
|
||||
p.getResources().getString(R.string.leftclick_timeout_time_2),
|
||||
p.getResources().getString(R.string.leftclick_timeout_time_3),
|
||||
p.getResources().getString(R.string.leftclick_timeout_time_4) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.leftclick_timeout_time);
|
||||
builder.setSingleChoiceItems(items, Globals.RightClickTimeout, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.RightClickTimeout = item;
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
public static class KeyRemapToolMouseClick implements MainActivity.KeyEventsListener
|
||||
{
|
||||
MainActivity p;
|
||||
boolean leftClick;
|
||||
public KeyRemapToolMouseClick(MainActivity _p, boolean leftClick)
|
||||
{
|
||||
p = _p;
|
||||
p.setText(p.getResources().getString(R.string.remap_hwkeys_press));
|
||||
this.leftClick = leftClick;
|
||||
}
|
||||
|
||||
public void onKeyEvent(final int keyCode)
|
||||
{
|
||||
p.keyListener = null;
|
||||
int keyIndex = keyCode;
|
||||
if( keyIndex < 0 )
|
||||
keyIndex = 0;
|
||||
if( keyIndex > SDL_Keys.JAVA_KEYCODE_LAST )
|
||||
keyIndex = 0;
|
||||
|
||||
if( leftClick )
|
||||
Globals.LeftClickKey = keyIndex;
|
||||
else
|
||||
Globals.RightClickKey = keyIndex;
|
||||
|
||||
goBack(p);
|
||||
}
|
||||
}
|
||||
|
||||
static class AdditionalMouseConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.pointandclick_question);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
CharSequence[] items = {
|
||||
p.getResources().getString(R.string.pointandclick_joystickmouse),
|
||||
p.getResources().getString(R.string.click_with_dpadcenter),
|
||||
p.getResources().getString(R.string.pointandclick_relative)
|
||||
};
|
||||
|
||||
boolean defaults[] = {
|
||||
Globals.MoveMouseWithJoystick,
|
||||
Globals.ClickMouseWithDpad,
|
||||
Globals.RelativeMouseMovement
|
||||
};
|
||||
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.pointandclick_question));
|
||||
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
||||
{
|
||||
if( item == 0 )
|
||||
Globals.MoveMouseWithJoystick = isChecked;
|
||||
if( item == 1 )
|
||||
Globals.ClickMouseWithDpad = isChecked;
|
||||
if( item == 2 )
|
||||
Globals.RelativeMouseMovement = isChecked;
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
if( Globals.RelativeMouseMovement )
|
||||
showRelativeMouseMovementConfig(p);
|
||||
else
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showRelativeMouseMovementConfig(final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.accel_veryslow),
|
||||
p.getResources().getString(R.string.accel_slow),
|
||||
p.getResources().getString(R.string.accel_medium),
|
||||
p.getResources().getString(R.string.accel_fast),
|
||||
p.getResources().getString(R.string.accel_veryfast) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.pointandclick_relative_speed);
|
||||
builder.setSingleChoiceItems(items, Globals.RelativeMouseMovementSpeed, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.RelativeMouseMovementSpeed = item;
|
||||
|
||||
dialog.dismiss();
|
||||
showRelativeMouseMovementConfig1(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showRelativeMouseMovementConfig1(final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.none),
|
||||
p.getResources().getString(R.string.accel_slow),
|
||||
p.getResources().getString(R.string.accel_medium),
|
||||
p.getResources().getString(R.string.accel_fast) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.pointandclick_relative_accel);
|
||||
builder.setSingleChoiceItems(items, Globals.RelativeMouseMovementAccel, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.RelativeMouseMovementAccel = item;
|
||||
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class JoystickMouseConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.pointandclick_joystickmousespeed);
|
||||
}
|
||||
boolean enabled()
|
||||
{
|
||||
return Globals.MoveMouseWithJoystick;
|
||||
};
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.accel_slow),
|
||||
p.getResources().getString(R.string.accel_medium),
|
||||
p.getResources().getString(R.string.accel_fast) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.pointandclick_joystickmousespeed);
|
||||
builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickSpeed, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.MoveMouseWithJoystickSpeed = item;
|
||||
|
||||
dialog.dismiss();
|
||||
showJoystickMouseAccelConfig(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showJoystickMouseAccelConfig(final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.none),
|
||||
p.getResources().getString(R.string.accel_slow),
|
||||
p.getResources().getString(R.string.accel_medium),
|
||||
p.getResources().getString(R.string.accel_fast) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.pointandclick_joystickmouseaccel);
|
||||
builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickAccel, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.MoveMouseWithJoystickAccel = item;
|
||||
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class TouchPressureMeasurementTool extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.measurepressure);
|
||||
}
|
||||
boolean enabled()
|
||||
{
|
||||
return Globals.RightClickMethod == Mouse.RIGHT_CLICK_WITH_PRESSURE ||
|
||||
Globals.LeftClickMethod == Mouse.LEFT_CLICK_WITH_PRESSURE;
|
||||
};
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
p.setText(p.getResources().getString(R.string.measurepressure_touchplease));
|
||||
p.touchListener = new TouchMeasurementTool(p);
|
||||
}
|
||||
|
||||
public static class TouchMeasurementTool implements MainActivity.TouchEventsListener
|
||||
{
|
||||
MainActivity p;
|
||||
ArrayList<Integer> force = new ArrayList<Integer>();
|
||||
ArrayList<Integer> radius = new ArrayList<Integer>();
|
||||
static final int maxEventAmount = 100;
|
||||
|
||||
public TouchMeasurementTool(MainActivity _p)
|
||||
{
|
||||
p = _p;
|
||||
}
|
||||
|
||||
public void onTouchEvent(final MotionEvent ev)
|
||||
{
|
||||
force.add(new Integer((int)(ev.getPressure() * 1000.0)));
|
||||
radius.add(new Integer((int)(ev.getSize() * 1000.0)));
|
||||
p.setText(p.getResources().getString(R.string.measurepressure_response, force.get(force.size()-1), radius.get(radius.size()-1)));
|
||||
try {
|
||||
Thread.sleep(10L);
|
||||
} catch (InterruptedException e) { }
|
||||
|
||||
if( force.size() >= maxEventAmount )
|
||||
{
|
||||
p.touchListener = null;
|
||||
Globals.ClickScreenPressure = getAverageForce();
|
||||
Globals.ClickScreenTouchspotSize = getAverageRadius();
|
||||
Log.i("SDL", "SDL: measured average force " + Globals.ClickScreenPressure + " radius " + Globals.ClickScreenTouchspotSize);
|
||||
goBack(p);
|
||||
}
|
||||
}
|
||||
|
||||
int getAverageForce()
|
||||
{
|
||||
int avg = 0;
|
||||
for(Integer f: force)
|
||||
{
|
||||
avg += f;
|
||||
}
|
||||
return avg / force.size();
|
||||
}
|
||||
int getAverageRadius()
|
||||
{
|
||||
int avg = 0;
|
||||
for(Integer r: radius)
|
||||
{
|
||||
avg += r;
|
||||
}
|
||||
return avg / radius.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class CalibrateTouchscreenMenu extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.calibrate_touchscreen);
|
||||
}
|
||||
//boolean enabled() { return true; };
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
p.setText(p.getResources().getString(R.string.calibrate_touchscreen_touch));
|
||||
Globals.TouchscreenCalibration[0] = 0;
|
||||
Globals.TouchscreenCalibration[1] = 0;
|
||||
Globals.TouchscreenCalibration[2] = 0;
|
||||
Globals.TouchscreenCalibration[3] = 0;
|
||||
ScreenEdgesCalibrationTool tool = new ScreenEdgesCalibrationTool(p);
|
||||
p.touchListener = tool;
|
||||
p.keyListener = tool;
|
||||
}
|
||||
|
||||
static class ScreenEdgesCalibrationTool implements MainActivity.TouchEventsListener, MainActivity.KeyEventsListener
|
||||
{
|
||||
MainActivity p;
|
||||
ImageView img;
|
||||
Bitmap bmp;
|
||||
|
||||
public ScreenEdgesCalibrationTool(MainActivity _p)
|
||||
{
|
||||
p = _p;
|
||||
img = new ImageView(p);
|
||||
img.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
||||
img.setScaleType(ImageView.ScaleType.MATRIX);
|
||||
bmp = BitmapFactory.decodeResource( p.getResources(), R.drawable.calibrate );
|
||||
img.setImageBitmap(bmp);
|
||||
Matrix m = new Matrix();
|
||||
RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
|
||||
RectF dst = new RectF(Globals.TouchscreenCalibration[0], Globals.TouchscreenCalibration[1],
|
||||
Globals.TouchscreenCalibration[2], Globals.TouchscreenCalibration[3]);
|
||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||
img.setImageMatrix(m);
|
||||
p.getVideoLayout().addView(img);
|
||||
}
|
||||
|
||||
public void onTouchEvent(final MotionEvent ev)
|
||||
{
|
||||
if( Globals.TouchscreenCalibration[0] == Globals.TouchscreenCalibration[1] &&
|
||||
Globals.TouchscreenCalibration[1] == Globals.TouchscreenCalibration[2] &&
|
||||
Globals.TouchscreenCalibration[2] == Globals.TouchscreenCalibration[3] )
|
||||
{
|
||||
Globals.TouchscreenCalibration[0] = (int)ev.getX();
|
||||
Globals.TouchscreenCalibration[1] = (int)ev.getY();
|
||||
Globals.TouchscreenCalibration[2] = (int)ev.getX();
|
||||
Globals.TouchscreenCalibration[3] = (int)ev.getY();
|
||||
}
|
||||
if( ev.getX() < Globals.TouchscreenCalibration[0] )
|
||||
Globals.TouchscreenCalibration[0] = (int)ev.getX();
|
||||
if( ev.getY() < Globals.TouchscreenCalibration[1] )
|
||||
Globals.TouchscreenCalibration[1] = (int)ev.getY();
|
||||
if( ev.getX() > Globals.TouchscreenCalibration[2] )
|
||||
Globals.TouchscreenCalibration[2] = (int)ev.getX();
|
||||
if( ev.getY() > Globals.TouchscreenCalibration[3] )
|
||||
Globals.TouchscreenCalibration[3] = (int)ev.getY();
|
||||
Matrix m = new Matrix();
|
||||
RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
|
||||
RectF dst = new RectF(Globals.TouchscreenCalibration[0], Globals.TouchscreenCalibration[1],
|
||||
Globals.TouchscreenCalibration[2], Globals.TouchscreenCalibration[3]);
|
||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||
img.setImageMatrix(m);
|
||||
}
|
||||
|
||||
public void onKeyEvent(final int keyCode)
|
||||
{
|
||||
p.touchListener = null;
|
||||
p.keyListener = null;
|
||||
p.getVideoLayout().removeView(img);
|
||||
goBack(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
846
project/javaSDL2/Video.java
Normal file
846
project/javaSDL2/Video.java
Normal file
@@ -0,0 +1,846 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
import javax.microedition.khronos.opengles.GL11;
|
||||
import javax.microedition.khronos.opengles.GL11Ext;
|
||||
|
||||
import javax.microedition.khronos.egl.EGL10;
|
||||
import javax.microedition.khronos.egl.EGL11;
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.egl.EGLContext;
|
||||
import javax.microedition.khronos.egl.EGLDisplay;
|
||||
import javax.microedition.khronos.egl.EGLSurface;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.InputDevice;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.os.Environment;
|
||||
import java.io.File;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.AssetManager;
|
||||
import android.widget.Toast;
|
||||
import android.util.Log;
|
||||
|
||||
import android.widget.TextView;
|
||||
import java.lang.Thread;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import android.os.Build;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
|
||||
class Mouse
|
||||
{
|
||||
public static final int LEFT_CLICK_NORMAL = 0;
|
||||
public static final int LEFT_CLICK_NEAR_CURSOR = 1;
|
||||
public static final int LEFT_CLICK_WITH_MULTITOUCH = 2;
|
||||
public static final int LEFT_CLICK_WITH_PRESSURE = 3;
|
||||
public static final int LEFT_CLICK_WITH_KEY = 4;
|
||||
public static final int LEFT_CLICK_WITH_TIMEOUT = 5;
|
||||
public static final int LEFT_CLICK_WITH_TAP = 6;
|
||||
public static final int LEFT_CLICK_WITH_TAP_OR_TIMEOUT = 7;
|
||||
|
||||
public static final int RIGHT_CLICK_NONE = 0;
|
||||
public static final int RIGHT_CLICK_WITH_MULTITOUCH = 1;
|
||||
public static final int RIGHT_CLICK_WITH_PRESSURE = 2;
|
||||
public static final int RIGHT_CLICK_WITH_KEY = 3;
|
||||
public static final int RIGHT_CLICK_WITH_TIMEOUT = 4;
|
||||
|
||||
public static final int SDL_FINGER_DOWN = 0;
|
||||
public static final int SDL_FINGER_UP = 1;
|
||||
public static final int SDL_FINGER_MOVE = 2;
|
||||
public static final int SDL_FINGER_HOVER = 3;
|
||||
|
||||
public static final int ZOOM_NONE = 0;
|
||||
public static final int ZOOM_MAGNIFIER = 1;
|
||||
public static final int ZOOM_SCREEN_TRANSFORM = 2;
|
||||
public static final int ZOOM_FULLSCREEN_MAGNIFIER = 3;
|
||||
}
|
||||
|
||||
abstract class DifferentTouchInput
|
||||
{
|
||||
public abstract void process(final MotionEvent event);
|
||||
public abstract void processGenericEvent(final MotionEvent event);
|
||||
|
||||
public static boolean ExternalMouseDetected = false;
|
||||
|
||||
public static DifferentTouchInput getInstance()
|
||||
{
|
||||
boolean multiTouchAvailable1 = false;
|
||||
boolean multiTouchAvailable2 = false;
|
||||
// Not checking for getX(int), getY(int) etc 'cause I'm lazy
|
||||
Method methods [] = MotionEvent.class.getDeclaredMethods();
|
||||
for(Method m: methods)
|
||||
{
|
||||
if( m.getName().equals("getPointerCount") )
|
||||
multiTouchAvailable1 = true;
|
||||
if( m.getName().equals("getPointerId") )
|
||||
multiTouchAvailable2 = true;
|
||||
}
|
||||
try {
|
||||
Log.i("SDL", "Device model: " + android.os.Build.MODEL);
|
||||
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH )
|
||||
{
|
||||
if( DetectCrappyDragonRiseDatexGamepad() )
|
||||
return CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad.Holder.sInstance;
|
||||
return IcsTouchInput.Holder.sInstance;
|
||||
}
|
||||
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD )
|
||||
return GingerbreadTouchInput.Holder.sInstance;
|
||||
if (multiTouchAvailable1 && multiTouchAvailable2)
|
||||
return MultiTouchInput.Holder.sInstance;
|
||||
else
|
||||
return SingleTouchInput.Holder.sInstance;
|
||||
} catch( Exception e ) {
|
||||
try {
|
||||
if (multiTouchAvailable1 && multiTouchAvailable2)
|
||||
return MultiTouchInput.Holder.sInstance;
|
||||
else
|
||||
return SingleTouchInput.Holder.sInstance;
|
||||
} catch( Exception ee ) {
|
||||
return SingleTouchInput.Holder.sInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
private static boolean DetectCrappyDragonRiseDatexGamepad()
|
||||
{
|
||||
if( CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad.Holder.sInstance == null )
|
||||
return false;
|
||||
return CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad.Holder.sInstance.detect();
|
||||
}
|
||||
|
||||
private static class SingleTouchInput extends DifferentTouchInput
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
private static final SingleTouchInput sInstance = new SingleTouchInput();
|
||||
}
|
||||
@Override
|
||||
public void processGenericEvent(final MotionEvent event)
|
||||
{
|
||||
process(event);
|
||||
}
|
||||
public void process(final MotionEvent event)
|
||||
{
|
||||
int action = -1;
|
||||
if( event.getAction() == MotionEvent.ACTION_DOWN )
|
||||
action = Mouse.SDL_FINGER_DOWN;
|
||||
if( event.getAction() == MotionEvent.ACTION_UP )
|
||||
action = Mouse.SDL_FINGER_UP;
|
||||
if( event.getAction() == MotionEvent.ACTION_MOVE )
|
||||
action = Mouse.SDL_FINGER_MOVE;
|
||||
if ( action >= 0 )
|
||||
DemoGLSurfaceView.nativeMotionEvent( (int)event.getX(), (int)event.getY(), action, 0,
|
||||
(int)(event.getPressure() * 1000.0),
|
||||
(int)(event.getSize() * 1000.0) );
|
||||
}
|
||||
}
|
||||
private static class MultiTouchInput extends DifferentTouchInput
|
||||
{
|
||||
public static final int TOUCH_EVENTS_MAX = 16; // Max multitouch pointers
|
||||
|
||||
private class touchEvent
|
||||
{
|
||||
public boolean down = false;
|
||||
public int x = 0;
|
||||
public int y = 0;
|
||||
public int pressure = 0;
|
||||
public int size = 0;
|
||||
}
|
||||
|
||||
protected touchEvent touchEvents[];
|
||||
|
||||
MultiTouchInput()
|
||||
{
|
||||
touchEvents = new touchEvent[TOUCH_EVENTS_MAX];
|
||||
for( int i = 0; i < TOUCH_EVENTS_MAX; i++ )
|
||||
touchEvents[i] = new touchEvent();
|
||||
}
|
||||
|
||||
private static class Holder
|
||||
{
|
||||
private static final MultiTouchInput sInstance = new MultiTouchInput();
|
||||
}
|
||||
|
||||
public void processGenericEvent(final MotionEvent event)
|
||||
{
|
||||
process(event);
|
||||
}
|
||||
public void process(final MotionEvent event)
|
||||
{
|
||||
int action = -1;
|
||||
|
||||
//Log.i("SDL", "Got motion event, type " + (int)(event.getAction()) + " X " + (int)event.getX() + " Y " + (int)event.getY());
|
||||
if( (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP ||
|
||||
(event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_CANCEL )
|
||||
{
|
||||
action = Mouse.SDL_FINGER_UP;
|
||||
for( int i = 0; i < TOUCH_EVENTS_MAX; i++ )
|
||||
{
|
||||
if( touchEvents[i].down )
|
||||
{
|
||||
touchEvents[i].down = false;
|
||||
DemoGLSurfaceView.nativeMotionEvent( touchEvents[i].x, touchEvents[i].y, action, i, touchEvents[i].pressure, touchEvents[i].size );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN )
|
||||
{
|
||||
action = Mouse.SDL_FINGER_DOWN;
|
||||
for( int i = 0; i < event.getPointerCount(); i++ )
|
||||
{
|
||||
int id = event.getPointerId(i);
|
||||
if( id >= TOUCH_EVENTS_MAX )
|
||||
id = TOUCH_EVENTS_MAX - 1;
|
||||
touchEvents[id].down = true;
|
||||
touchEvents[id].x = (int)event.getX(i);
|
||||
touchEvents[id].y = (int)event.getY(i);
|
||||
touchEvents[id].pressure = (int)(event.getPressure(i) * 1000.0);
|
||||
touchEvents[id].size = (int)(event.getSize(i) * 1000.0);
|
||||
DemoGLSurfaceView.nativeMotionEvent( touchEvents[id].x, touchEvents[id].y, action, id, touchEvents[id].pressure, touchEvents[id].size );
|
||||
}
|
||||
}
|
||||
if( (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_MOVE ||
|
||||
(event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_DOWN ||
|
||||
(event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_UP )
|
||||
{
|
||||
/*
|
||||
String s = "MOVE: ptrs " + event.getPointerCount();
|
||||
for( int i = 0 ; i < event.getPointerCount(); i++ )
|
||||
{
|
||||
s += " p" + event.getPointerId(i) + "=" + (int)event.getX(i) + ":" + (int)event.getY(i);
|
||||
}
|
||||
Log.i("SDL", s);
|
||||
*/
|
||||
int pointerReleased = -1;
|
||||
if( (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_UP )
|
||||
pointerReleased = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
|
||||
|
||||
for( int id = 0; id < TOUCH_EVENTS_MAX; id++ )
|
||||
{
|
||||
int ii;
|
||||
for( ii = 0; ii < event.getPointerCount(); ii++ )
|
||||
{
|
||||
if( id == event.getPointerId(ii) )
|
||||
break;
|
||||
}
|
||||
if( ii >= event.getPointerCount() )
|
||||
{
|
||||
// Up event
|
||||
if( touchEvents[id].down )
|
||||
{
|
||||
action = Mouse.SDL_FINGER_UP;
|
||||
touchEvents[id].down = false;
|
||||
DemoGLSurfaceView.nativeMotionEvent( touchEvents[id].x, touchEvents[id].y, action, id, touchEvents[id].pressure, touchEvents[id].size );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( pointerReleased == id && touchEvents[pointerReleased].down )
|
||||
{
|
||||
action = Mouse.SDL_FINGER_UP;
|
||||
touchEvents[id].down = false;
|
||||
}
|
||||
else if( touchEvents[id].down )
|
||||
{
|
||||
action = Mouse.SDL_FINGER_MOVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
action = Mouse.SDL_FINGER_DOWN;
|
||||
touchEvents[id].down = true;
|
||||
}
|
||||
touchEvents[id].x = (int)event.getX(ii);
|
||||
touchEvents[id].y = (int)event.getY(ii);
|
||||
touchEvents[id].pressure = (int)(event.getPressure(ii) * 1000.0);
|
||||
touchEvents[id].size = (int)(event.getSize(ii) * 1000.0);
|
||||
DemoGLSurfaceView.nativeMotionEvent( touchEvents[id].x, touchEvents[id].y, action, id, touchEvents[id].pressure, touchEvents[id].size );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_HOVER_MOVE ) // Support bluetooth/USB mouse - available since Android 3.1
|
||||
{
|
||||
// TODO: it is possible that multiple pointers return that event, but we're handling only pointer #0
|
||||
if( touchEvents[0].down )
|
||||
action = Mouse.SDL_FINGER_UP;
|
||||
else
|
||||
action = Mouse.SDL_FINGER_HOVER;
|
||||
touchEvents[0].down = false;
|
||||
touchEvents[0].x = (int)event.getX();
|
||||
touchEvents[0].y = (int)event.getY();
|
||||
touchEvents[0].pressure = 0;
|
||||
touchEvents[0].size = 0;
|
||||
DemoGLSurfaceView.nativeMotionEvent( touchEvents[0].x, touchEvents[0].y, action, 0, touchEvents[0].pressure, touchEvents[0].size );
|
||||
}
|
||||
}
|
||||
}
|
||||
private static class GingerbreadTouchInput extends MultiTouchInput
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
private static final GingerbreadTouchInput sInstance = new GingerbreadTouchInput();
|
||||
}
|
||||
|
||||
GingerbreadTouchInput()
|
||||
{
|
||||
super();
|
||||
}
|
||||
public void process(final MotionEvent event)
|
||||
{
|
||||
boolean hwMouseEvent = ( (event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE ||
|
||||
(event.getSource() & InputDevice.SOURCE_STYLUS) == InputDevice.SOURCE_STYLUS ||
|
||||
(event.getMetaState() & KeyEvent.FLAG_TRACKING) != 0 ); // Hack to recognize Galaxy Note Gingerbread stylus
|
||||
if( ExternalMouseDetected != hwMouseEvent )
|
||||
{
|
||||
ExternalMouseDetected = hwMouseEvent;
|
||||
DemoGLSurfaceView.nativeHardwareMouseDetected(hwMouseEvent ? 1 : 0);
|
||||
}
|
||||
super.process(event);
|
||||
}
|
||||
public void processGenericEvent(final MotionEvent event)
|
||||
{
|
||||
process(event);
|
||||
}
|
||||
}
|
||||
private static class IcsTouchInput extends GingerbreadTouchInput
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
private static final IcsTouchInput sInstance = new IcsTouchInput();
|
||||
}
|
||||
private int buttonState = 0;
|
||||
public void process(final MotionEvent event)
|
||||
{
|
||||
//Log.i("SDL", "Got motion event, type " + (int)(event.getAction()) + " X " + (int)event.getX() + " Y " + (int)event.getY() + " buttons " + buttonState + " source " + event.getSource());
|
||||
int buttonStateNew = event.getButtonState();
|
||||
if( buttonStateNew != buttonState )
|
||||
{
|
||||
for( int i = 1; i <= MotionEvent.BUTTON_FORWARD; i *= 2 )
|
||||
{
|
||||
if( (buttonStateNew & i) != (buttonState & i) )
|
||||
DemoGLSurfaceView.nativeMouseButtonsPressed(i, ((buttonStateNew & i) == 0) ? 0 : 1);
|
||||
}
|
||||
buttonState = buttonStateNew;
|
||||
}
|
||||
super.process(event); // Push mouse coordinate first
|
||||
}
|
||||
public void processGenericEvent(final MotionEvent event)
|
||||
{
|
||||
// Joysticks are supported since Honeycomb, but I don't care about it, because very little devices have it
|
||||
if( (event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK )
|
||||
{
|
||||
DemoGLSurfaceView.nativeGamepadAnalogJoystickInput(
|
||||
event.getAxisValue(MotionEvent.AXIS_X), event.getAxisValue(MotionEvent.AXIS_Y),
|
||||
event.getAxisValue(MotionEvent.AXIS_Z), event.getAxisValue(MotionEvent.AXIS_RZ),
|
||||
event.getAxisValue(MotionEvent.AXIS_RTRIGGER), event.getAxisValue(MotionEvent.AXIS_LTRIGGER) );
|
||||
return;
|
||||
}
|
||||
// Process mousewheel
|
||||
if( event.getAction() == MotionEvent.ACTION_SCROLL )
|
||||
{
|
||||
int scrollX = Math.round(event.getAxisValue(MotionEvent.AXIS_HSCROLL));
|
||||
int scrollY = Math.round(event.getAxisValue(MotionEvent.AXIS_VSCROLL));
|
||||
DemoGLSurfaceView.nativeMouseWheel(scrollX, scrollY);
|
||||
return;
|
||||
}
|
||||
super.processGenericEvent(event);
|
||||
}
|
||||
}
|
||||
private static class CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad extends IcsTouchInput
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
private static final CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad sInstance = new CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad();
|
||||
}
|
||||
float hatX = 0.0f, hatY = 0.0f;
|
||||
public void processGenericEvent(final MotionEvent event)
|
||||
{
|
||||
// Joysticks are supported since Honeycomb, but I don't care about it, because very little devices have it
|
||||
if( (event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK )
|
||||
{
|
||||
// event.getAxisValue(AXIS_HAT_X) and event.getAxisValue(AXIS_HAT_Y) are joystick arrow keys, they also send keyboard events
|
||||
DemoGLSurfaceView.nativeGamepadAnalogJoystickInput(
|
||||
event.getAxisValue(MotionEvent.AXIS_X), event.getAxisValue(MotionEvent.AXIS_Y),
|
||||
event.getAxisValue(MotionEvent.AXIS_RX), event.getAxisValue(MotionEvent.AXIS_RZ),
|
||||
0, 0);
|
||||
if( event.getAxisValue(MotionEvent.AXIS_HAT_X) != hatX )
|
||||
{
|
||||
hatX = event.getAxisValue(MotionEvent.AXIS_HAT_X);
|
||||
if( hatX == 0.0f )
|
||||
{
|
||||
DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_LEFT, 0);
|
||||
DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_RIGHT, 0);
|
||||
}
|
||||
else
|
||||
DemoGLSurfaceView.nativeKey(hatX < 0.0f ? KeyEvent.KEYCODE_DPAD_LEFT : KeyEvent.KEYCODE_DPAD_RIGHT, 1);
|
||||
}
|
||||
if( event.getAxisValue(MotionEvent.AXIS_HAT_Y) != hatY )
|
||||
{
|
||||
hatY = event.getAxisValue(MotionEvent.AXIS_HAT_Y);
|
||||
if( hatY == 0.0f )
|
||||
{
|
||||
DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_UP, 0);
|
||||
DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_DOWN, 0);
|
||||
}
|
||||
else
|
||||
DemoGLSurfaceView.nativeKey(hatY < 0.0f ? KeyEvent.KEYCODE_DPAD_UP : KeyEvent.KEYCODE_DPAD_DOWN, 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
super.processGenericEvent(event);
|
||||
}
|
||||
public boolean detect()
|
||||
{
|
||||
int[] devIds = InputDevice.getDeviceIds();
|
||||
for( int id : devIds )
|
||||
{
|
||||
InputDevice device = InputDevice.getDevice(id);
|
||||
if( device == null )
|
||||
continue;
|
||||
System.out.println("libSDL: input device ID " + id + " type " + device.getSources() + " name " + device.getName() );
|
||||
if( (device.getSources() & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD &&
|
||||
(device.getSources() & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK &&
|
||||
device.getName().indexOf("DragonRise Inc") == 0 )
|
||||
{
|
||||
System.out.println("libSDL: Detected crappy DragonRise gamepad, enabling special hack for it. Please press button labeled 'Analog', otherwise it won't work, because it's cheap and crappy");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
{
|
||||
public DemoRenderer(MainActivity _context)
|
||||
{
|
||||
context = _context;
|
||||
}
|
||||
|
||||
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
|
||||
Log.i("SDL", "libSDL: DemoRenderer.onSurfaceCreated(): paused " + mPaused + " mFirstTimeStart " + mFirstTimeStart );
|
||||
mGlSurfaceCreated = true;
|
||||
mGl = gl;
|
||||
/*if( ! mPaused && ! mFirstTimeStart )
|
||||
nativeGlContextRecreated();*/
|
||||
mFirstTimeStart = false;
|
||||
}
|
||||
|
||||
public void onSurfaceChanged(GL10 gl, int w, int h) {
|
||||
Log.i("SDL", "libSDL: DemoRenderer.onSurfaceChanged(): paused " + mPaused + " mFirstTimeStart " + mFirstTimeStart + " w " + w + " h " + h);
|
||||
if( w < h && Globals.HorizontalOrientation )
|
||||
{
|
||||
// Sometimes when Android awakes from lockscreen, portrait orientation is kept
|
||||
int x = w;
|
||||
w = h;
|
||||
h = x;
|
||||
}
|
||||
mWidth = w;
|
||||
mHeight = h;
|
||||
mGl = gl;
|
||||
//nativeResize(w, h, Globals.KeepAspectRatio ? 1 : 0);
|
||||
}
|
||||
|
||||
public void onSurfaceDestroyed() {
|
||||
Log.i("SDL", "libSDL: DemoRenderer.onSurfaceDestroyed(): paused " + mPaused + " mFirstTimeStart " + mFirstTimeStart );
|
||||
mGlSurfaceCreated = false;
|
||||
mGlContextLost = true;
|
||||
//nativeGlContextLost();
|
||||
};
|
||||
|
||||
public void onDrawFrame(GL10 gl) {
|
||||
|
||||
mGl = gl;
|
||||
DrawLogo(mGl);
|
||||
SwapBuffers();
|
||||
|
||||
//nativeInitJavaCallbacks();
|
||||
|
||||
// Make main thread priority lower so audio thread won't get underrun
|
||||
// Thread.currentThread().setPriority((Thread.currentThread().getPriority() + Thread.MIN_PRIORITY)/2);
|
||||
|
||||
mGlContextLost = false;
|
||||
|
||||
if(Globals.CompatibilityHacksStaticInit)
|
||||
MainActivity.LoadApplicationLibrary(context);
|
||||
|
||||
Settings.Apply(context);
|
||||
accelerometer = new AccelerometerReader(context);
|
||||
// Tweak video thread priority, if user selected big audio buffer
|
||||
if(Globals.AudioBufferConfig >= 2)
|
||||
Thread.currentThread().setPriority( (Thread.NORM_PRIORITY + Thread.MIN_PRIORITY) / 2 ); // Lower than normal
|
||||
// Calls main() and never returns, hehe - we'll call eglSwapBuffers() from native code
|
||||
/*nativeInit( Globals.DataDir,
|
||||
Globals.CommandLine,
|
||||
( (Globals.SwVideoMode && Globals.MultiThreadedVideo) || Globals.CompatibilityHacksVideo ) ? 1 : 0,
|
||||
android.os.Debug.isDebuggerConnected() ? 1 : 0 );*/
|
||||
//System.exit(0); // The main() returns here - I don't bother with deinit stuff, just terminate process
|
||||
}
|
||||
|
||||
public int swapBuffers() // Called from native code
|
||||
{
|
||||
if( ! super.SwapBuffers() && Globals.NonBlockingSwapBuffers )
|
||||
{
|
||||
if(mRatelimitTouchEvents)
|
||||
{
|
||||
synchronized(this)
|
||||
{
|
||||
this.notify();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(mGlContextLost) {
|
||||
mGlContextLost = false;
|
||||
Settings.SetupTouchscreenKeyboardGraphics(context); // Reload on-screen buttons graphics
|
||||
DrawLogo(mGl);
|
||||
super.SwapBuffers();
|
||||
}
|
||||
|
||||
// Unblock event processing thread only after we've finished rendering
|
||||
if(mRatelimitTouchEvents)
|
||||
{
|
||||
synchronized(this)
|
||||
{
|
||||
this.notify();
|
||||
}
|
||||
}
|
||||
/*if( context.isScreenKeyboardShown() )
|
||||
{
|
||||
try {
|
||||
Thread.sleep(50); // Give some time to the keyboard input thread
|
||||
} catch(Exception e) { };
|
||||
}*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void showScreenKeyboardWithoutTextInputField() // Called from native code
|
||||
{
|
||||
class Callback implements Runnable
|
||||
{
|
||||
public MainActivity parent;
|
||||
public void run()
|
||||
{
|
||||
parent.showScreenKeyboardWithoutTextInputField();
|
||||
}
|
||||
}
|
||||
Callback cb = new Callback();
|
||||
cb.parent = context;
|
||||
context.runOnUiThread(cb);
|
||||
}
|
||||
|
||||
public void showScreenKeyboard(final String oldText, int sendBackspace) // Called from native code
|
||||
{
|
||||
class Callback implements Runnable
|
||||
{
|
||||
public MainActivity parent;
|
||||
public String oldText;
|
||||
public boolean sendBackspace;
|
||||
public void run()
|
||||
{
|
||||
parent.showScreenKeyboard(oldText, sendBackspace);
|
||||
}
|
||||
}
|
||||
Callback cb = new Callback();
|
||||
cb.parent = context;
|
||||
cb.oldText = oldText;
|
||||
cb.sendBackspace = (sendBackspace != 0);
|
||||
context.runOnUiThread(cb);
|
||||
}
|
||||
|
||||
public void hideScreenKeyboard() // Called from native code
|
||||
{
|
||||
class Callback implements Runnable
|
||||
{
|
||||
public MainActivity parent;
|
||||
public void run()
|
||||
{
|
||||
//parent.hideScreenKeyboard();
|
||||
}
|
||||
}
|
||||
Callback cb = new Callback();
|
||||
cb.parent = context;
|
||||
context.runOnUiThread(cb);
|
||||
}
|
||||
|
||||
public int isScreenKeyboardShown() // Called from native code
|
||||
{
|
||||
//return context.isScreenKeyboardShown() ? 1 : 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setScreenKeyboardHintMessage(String s)
|
||||
{
|
||||
//context.setScreenKeyboardHintMessage(s);
|
||||
}
|
||||
|
||||
public void startAccelerometerGyroscope(int started)
|
||||
{
|
||||
accelerometer.openedBySDL = (started != 0);
|
||||
if( accelerometer.openedBySDL && !mPaused )
|
||||
accelerometer.start();
|
||||
else
|
||||
accelerometer.stop();
|
||||
}
|
||||
|
||||
public void exitApp()
|
||||
{
|
||||
//nativeDone();
|
||||
}
|
||||
|
||||
public void getAdvertisementParams(int params[])
|
||||
{
|
||||
//context.getAdvertisementParams(params);
|
||||
}
|
||||
public void setAdvertisementVisible(int visible)
|
||||
{
|
||||
//context.setAdvertisementVisible(visible);
|
||||
}
|
||||
public void setAdvertisementPosition(int left, int top)
|
||||
{
|
||||
//context.setAdvertisementPosition(left, top);
|
||||
}
|
||||
public void requestNewAdvertisement()
|
||||
{
|
||||
//context.requestNewAdvertisement();
|
||||
}
|
||||
|
||||
private int PowerOf2(int i)
|
||||
{
|
||||
int value = 1;
|
||||
while (value < i)
|
||||
value <<= 1;
|
||||
return value;
|
||||
}
|
||||
public void DrawLogo(GL10 gl)
|
||||
{
|
||||
/*
|
||||
// TODO: this not quite works, as it seems
|
||||
BitmapDrawable bmp = null;
|
||||
try
|
||||
{
|
||||
bmp = new BitmapDrawable(context.getAssets().open("logo.png"));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
bmp = new BitmapDrawable(context.getResources().openRawResource(R.drawable.publisherlogo));
|
||||
}
|
||||
int width = bmp.getBitmap().getWidth();
|
||||
int height = bmp.getBitmap().getHeight();
|
||||
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(4 * width * height);
|
||||
//byteBuffer.order(ByteOrder.BIG_ENDIAN);
|
||||
bmp.getBitmap().copyPixelsToBuffer(byteBuffer);
|
||||
byteBuffer.position(0);
|
||||
|
||||
gl.glViewport(0, 0, mWidth, mHeight);
|
||||
gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
|
||||
gl.glColor4x(0x10000, 0x10000, 0x10000, 0x10000);
|
||||
gl.glPixelStorei(gl.GL_UNPACK_ALIGNMENT, 1);
|
||||
gl.glEnable(GL10.GL_TEXTURE_2D);
|
||||
int textureName = -1;
|
||||
int mTextureNameWorkspace[] = new int[1];
|
||||
int mCropWorkspace[] = new int[4];
|
||||
gl.glGenTextures(1, mTextureNameWorkspace, 0);
|
||||
textureName = mTextureNameWorkspace[0];
|
||||
gl.glBindTexture(GL10.GL_TEXTURE_2D, textureName);
|
||||
gl.glActiveTexture(textureName);
|
||||
gl.glClientActiveTexture(textureName);
|
||||
gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGBA,
|
||||
PowerOf2(width), PowerOf2(height), 0,
|
||||
GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, null);
|
||||
gl.glTexSubImage2D(GL10.GL_TEXTURE_2D, 0, 0, 0,
|
||||
width, height,
|
||||
GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, byteBuffer);
|
||||
mCropWorkspace[0] = 0; // u
|
||||
mCropWorkspace[1] = height; // v
|
||||
mCropWorkspace[2] = width;
|
||||
mCropWorkspace[3] = -height;
|
||||
((GL11) gl).glTexParameteriv(GL10.GL_TEXTURE_2D,
|
||||
GL11Ext.GL_TEXTURE_CROP_RECT_OES, mCropWorkspace, 0);
|
||||
((GL11Ext) gl).glDrawTexiOES(0, -mHeight, 0, mWidth, mHeight);
|
||||
gl.glActiveTexture(0);
|
||||
gl.glClientActiveTexture(0);
|
||||
gl.glBindTexture(GL10.GL_TEXTURE_2D, 0);
|
||||
gl.glDeleteTextures(1, mTextureNameWorkspace, 0);
|
||||
|
||||
gl.glFlush();
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
//private native void nativeInitJavaCallbacks();
|
||||
//private native void nativeInit(String CurrentPath, String CommandLine, int multiThreadedVideo, int isDebuggerConnected);
|
||||
//private native void nativeResize(int w, int h, int keepAspectRatio);
|
||||
//private native void nativeDone();
|
||||
//private native void nativeGlContextLost();
|
||||
//public native void nativeGlContextRecreated();
|
||||
//public native void nativeGlContextLostAsyncEvent();
|
||||
//public static native void nativeTextInput( int ascii, int unicode );
|
||||
//public static native void nativeTextInputFinished();
|
||||
|
||||
private MainActivity context = null;
|
||||
public AccelerometerReader accelerometer = null;
|
||||
|
||||
private GL10 mGl = null;
|
||||
private EGL10 mEgl = null;
|
||||
private EGLDisplay mEglDisplay = null;
|
||||
private EGLSurface mEglSurface = null;
|
||||
//private EGLContext mEglContext = null;
|
||||
private boolean mGlContextLost = false;
|
||||
public boolean mGlSurfaceCreated = false;
|
||||
public boolean mPaused = false;
|
||||
private boolean mFirstTimeStart = true;
|
||||
public int mWidth = 0;
|
||||
public int mHeight = 0;
|
||||
|
||||
public static final boolean mRatelimitTouchEvents = true; //(Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO);
|
||||
}
|
||||
|
||||
class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||
public DemoGLSurfaceView(MainActivity context) {
|
||||
super(context);
|
||||
mParent = context;
|
||||
touchInput = DifferentTouchInput.getInstance();
|
||||
setEGLConfigChooser(Globals.VideoDepthBpp, Globals.NeedDepthBuffer, Globals.NeedStencilBuffer, Globals.NeedGles2);
|
||||
mRenderer = new DemoRenderer(context);
|
||||
setRenderer(mRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(final MotionEvent event)
|
||||
{
|
||||
touchInput.process(event);
|
||||
if( DemoRenderer.mRatelimitTouchEvents )
|
||||
{
|
||||
limitEventRate(event);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean onGenericMotionEvent (final MotionEvent event)
|
||||
{
|
||||
touchInput.processGenericEvent(event);
|
||||
if( DemoRenderer.mRatelimitTouchEvents )
|
||||
{
|
||||
limitEventRate(event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void limitEventRate(final MotionEvent event)
|
||||
{
|
||||
// Wait a bit, and try to synchronize to app framerate, or event thread will eat all CPU and we'll lose FPS
|
||||
// With Froyo the rate of touch events seems to be limited by OS, but they are arriving faster then we're redrawing anyway
|
||||
if((event.getAction() == MotionEvent.ACTION_MOVE ||
|
||||
event.getAction() == MotionEvent.ACTION_HOVER_MOVE))
|
||||
{
|
||||
synchronized(mRenderer)
|
||||
{
|
||||
try
|
||||
{
|
||||
mRenderer.wait(300L); // And sometimes the app decides not to render at all, so this timeout should not be big.
|
||||
} catch (InterruptedException e) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void exitApp() {
|
||||
mRenderer.exitApp();
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
if(mRenderer.mPaused)
|
||||
return;
|
||||
mRenderer.mPaused = true;
|
||||
//mRenderer.nativeGlContextLostAsyncEvent();
|
||||
if( mRenderer.accelerometer != null ) // For some reason it crashes here often - are we getting this event before initialization?
|
||||
mRenderer.accelerometer.stop();
|
||||
super.onPause();
|
||||
};
|
||||
|
||||
public boolean isPaused() {
|
||||
return mRenderer.mPaused;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
if(!mRenderer.mPaused)
|
||||
return;
|
||||
mRenderer.mPaused = false;
|
||||
super.onResume();
|
||||
Log.i("SDL", "libSDL: DemoGLSurfaceView.onResume(): mRenderer.mGlSurfaceCreated " + mRenderer.mGlSurfaceCreated + " mRenderer.mPaused " + mRenderer.mPaused);
|
||||
/*if( mRenderer.mGlSurfaceCreated && ! mRenderer.mPaused || Globals.NonBlockingSwapBuffers )
|
||||
mRenderer.nativeGlContextRecreated();*/
|
||||
if( mRenderer.accelerometer != null && mRenderer.accelerometer.openedBySDL ) // For some reason it crashes here often - are we getting this event before initialization?
|
||||
mRenderer.accelerometer.start();
|
||||
};
|
||||
|
||||
// This seems like redundant code - it handled in MainActivity.java
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, final KeyEvent event) {
|
||||
//Log.i("SDL", "Got key down event, id " + keyCode + " meta " + event.getMetaState() + " event " + event.toString());
|
||||
if( nativeKey( keyCode, 1 ) == 0 )
|
||||
return super.onKeyDown(keyCode, event);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, final KeyEvent event) {
|
||||
//Log.i("SDL", "Got key up event, id " + keyCode + " meta " + event.getMetaState());
|
||||
if( nativeKey( keyCode, 0 ) == 0 )
|
||||
return super.onKeyUp(keyCode, event);
|
||||
return true;
|
||||
}
|
||||
|
||||
DemoRenderer mRenderer;
|
||||
MainActivity mParent;
|
||||
DifferentTouchInput touchInput = null;
|
||||
|
||||
public static native void nativeMotionEvent( int x, int y, int action, int pointerId, int pressure, int radius );
|
||||
public static native int nativeKey( int keyCode, int down );
|
||||
public static native void nativeTouchpad( int x, int y, int down, int multitouch );
|
||||
public static native void initJavaCallbacks();
|
||||
public static native void nativeHardwareMouseDetected( int detected );
|
||||
public static native void nativeMouseButtonsPressed( int buttonId, int pressedState );
|
||||
public static native void nativeMouseWheel( int scrollX, int scrollY );
|
||||
public static native void nativeGamepadAnalogJoystickInput( float stick1x, float stick1y, float stick2x, float stick2y, float rtrigger, float ltrigger );
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../java/XZInputStream.java
|
||||
75
project/javaSDL2/admob/Advertisement.java
Normal file
75
project/javaSDL2/admob/Advertisement.java
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.ads.*; // Copy GoogleAdMobAdsSdk.jar to the directory project/libs
|
||||
|
||||
class Advertisement
|
||||
{
|
||||
private AdView ad;
|
||||
MainActivity parent;
|
||||
|
||||
public Advertisement(MainActivity p)
|
||||
{
|
||||
parent = p;
|
||||
AdSize adSize = AdSize.BANNER;
|
||||
if( Globals.AdmobBannerSize.equals("BANNER") )
|
||||
adSize = AdSize.BANNER;
|
||||
else if( Globals.AdmobBannerSize.equals("IAB_BANNER") )
|
||||
adSize = AdSize.IAB_BANNER;
|
||||
else if( Globals.AdmobBannerSize.equals("IAB_LEADERBOARD") )
|
||||
adSize = AdSize.IAB_LEADERBOARD;
|
||||
else if( Globals.AdmobBannerSize.equals("IAB_MRECT") )
|
||||
adSize = AdSize.IAB_MRECT;
|
||||
else if( Globals.AdmobBannerSize.equals("IAB_WIDE_SKYSCRAPER") )
|
||||
adSize = AdSize.IAB_WIDE_SKYSCRAPER;
|
||||
else if( Globals.AdmobBannerSize.equals("SMART_BANNER") )
|
||||
adSize = AdSize.SMART_BANNER;
|
||||
ad = new AdView(parent, adSize, Globals.AdmobPublisherId);
|
||||
AdRequest adRequest = new AdRequest();
|
||||
adRequest.addTestDevice(AdRequest.TEST_EMULATOR); // Copy GoogleAdMobAdsSdk.jar to the directory project/libs
|
||||
adRequest.addTestDevice(Globals.AdmobTestDeviceId);
|
||||
ad.loadAd(adRequest);
|
||||
}
|
||||
|
||||
public View getView()
|
||||
{
|
||||
return ad;
|
||||
}
|
||||
|
||||
public void requestNewAd()
|
||||
{
|
||||
AdRequest adRequest = new AdRequest();
|
||||
adRequest.addTestDevice(AdRequest.TEST_EMULATOR); // Copy GoogleAdMobAdsSdk.jar to the directory project/libs
|
||||
adRequest.addTestDevice(Globals.AdmobTestDeviceId);
|
||||
ad.loadAd(adRequest);
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
../java/translations
|
||||
31
project/javaSDL2/translations/generate.sh
Executable file
31
project/javaSDL2/translations/generate.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
grep '<string name=' values/strings.xml | while read str; do
|
||||
|
||||
var=`echo $str | sed 's/<string name=["]\([^"]*\).*/\1/'`
|
||||
text=`echo $str | sed 's/<string name=["][^"]*["]>\([^<]*\).*/\1/'`
|
||||
if [ "$var" = "app_name" ]; then
|
||||
continue
|
||||
fi
|
||||
PRINTEN=true
|
||||
echo
|
||||
for dir in values-*; do
|
||||
lang=`echo $dir | sed 's/[^-]*-\(..\).*/\1/'`
|
||||
trans=`grep "<string name=\"$var\">" $dir/strings.xml`
|
||||
transtext=`echo $trans | sed 's/<string name=["][^"]*["]>\([^<]*\).*/\1/'`
|
||||
if [ -z "$transtext" ] ; then
|
||||
#transtext=`./translate.py en $lang "$text"`
|
||||
#echo "$transtext" | grep 'Suspected Terms of Service Abuse' > /dev/null && transtext="$text"
|
||||
transtext="$text"
|
||||
grep -v "^[<]/resources[>]\$" $dir/strings.xml > $dir/strings.1.xml
|
||||
echo "<string name=\"$var\">$transtext</string>" >> $dir/strings.1.xml
|
||||
echo "</resources>" >> $dir/strings.1.xml
|
||||
mv -f $dir/strings.1.xml $dir/strings.xml
|
||||
if $PRINTEN ; then
|
||||
echo en: $var: $text
|
||||
PRINTEN=false
|
||||
fi
|
||||
echo $lang: $var: $transtext
|
||||
fi
|
||||
done
|
||||
done
|
||||
24
project/javaSDL2/translations/translate.py
Executable file
24
project/javaSDL2/translations/translate.py
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python
|
||||
from urllib2 import urlopen
|
||||
from urllib import urlencode
|
||||
import sys
|
||||
|
||||
# The google translate API can be found here:
|
||||
# http://code.google.com/apis/ajaxlanguage/documentation/#Examples
|
||||
|
||||
lang1=sys.argv[1]
|
||||
lang2=sys.argv[2]
|
||||
langpair='%s|%s'%(lang1,lang2)
|
||||
text=' '.join(sys.argv[3:])
|
||||
base_url='http://ajax.googleapis.com/ajax/services/language/translate?'
|
||||
params=urlencode( (('v',1.0),
|
||||
('q',text),
|
||||
('langpair',langpair),) )
|
||||
url=base_url+params
|
||||
content=urlopen(url).read()
|
||||
start_idx=content.find('"translatedText":"')+18
|
||||
translation=content[start_idx:]
|
||||
end_idx=translation.find('"}, "')
|
||||
translation=translation[:end_idx]
|
||||
print translation
|
||||
|
||||
3
project/javaSDL2/translations/unsupported/readme.txt
Normal file
3
project/javaSDL2/translations/unsupported/readme.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
I''ve tired of using Google Translate to create random gibberish in the languages I don't know,
|
||||
so from now on the only supported languages are English, Russian, Ukrainian, and French with some community support,
|
||||
If you wish to maintain a translation - contact me, but I will want a continuous support, not just one-time translation.
|
||||
137
project/javaSDL2/translations/unsupported/values-de/strings.xml
Normal file
137
project/javaSDL2/translations/unsupported/values-de/strings.xml
Normal file
@@ -0,0 +1,137 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="init">Initialisiere</string>
|
||||
<string name="please_wait">Bitte warte, während die Dateien heruntergeladen werden.</string>
|
||||
|
||||
<string name="device_config">Gerätekonfiguration</string>
|
||||
<string name="device_change_cfg">Gerätekonfiguration bearbeiten</string>
|
||||
|
||||
<string name="download_unneeded">Download nicht nötig</string>
|
||||
<string name="connecting_to">Verbinde mit %s</string>
|
||||
<string name="failed_connecting_to">Verbindung mit %s fehlgeschlagen</string>
|
||||
<string name="error_connecting_to">Fehler beim Verbinden mit %s</string>
|
||||
<string name="dl_from">Lade Daten von %s</string>
|
||||
<string name="error_dl_from">Fehler beim Download von %s</string>
|
||||
<string name="error_write">Fehler beim schreiben auf %s</string>
|
||||
<string name="dl_progress">Zu %1$.0f%% abgeschlossen: Datei %2$s</string>
|
||||
<string name="dl_finished">Abgeschlossen</string>
|
||||
|
||||
<string name="storage_phone">Interner Speicher: %d MiB frei</string>
|
||||
<string name="storage_sd">SD Karte: %d MiB frei</string>
|
||||
<string name="storage_question">Wohin sollen die Dateien gespeichert werden</string>
|
||||
|
||||
<string name="controls_arrows">Pfeiltasten / Joystick / dpad</string>
|
||||
<string name="controls_trackball">Trackball</string>
|
||||
<string name="controls_accel">Accelerometer</string>
|
||||
<string name="controls_question">Welche Arten von Navigationstasten hat das Gerät?</string>
|
||||
|
||||
<string name="trackball_no_dampening">Keine Dämpfung</string>
|
||||
<string name="trackball_fast">Schnell</string>
|
||||
<string name="trackball_medium">Mittel</string>
|
||||
<string name="trackball_slow">Langsam</string>
|
||||
<string name="trackball_question">Dämpfung des Trackball</string>
|
||||
|
||||
<string name="accel_fast">Schnell</string>
|
||||
<string name="accel_medium">Mittel</string>
|
||||
<string name="accel_slow">Langsam</string>
|
||||
<string name="accel_question">Empfindlichkeit des Accelerometers</string>
|
||||
|
||||
<string name="audiobuf_small">Klein (für schnelle Geräte)</string>
|
||||
<string name="audiobuf_medium">Mittel</string>
|
||||
<string name="audiobuf_large">Groß (Wenn Ton "hängt")</string>
|
||||
<string name="audiobuf_question">Größe des Audiopuffers</string>
|
||||
<string name="optional_downloads">Optional Downloads</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="controls_touch">Touchscreen nur</string>
|
||||
<string name="controls_additional">Zusätzliche Kontrollen zu verwenden</string>
|
||||
<string name="controls_screenkb">On-Screen-Tastatur</string>
|
||||
<string name="controls_accelnav">Beschleunigungsmesser</string>
|
||||
<string name="controls_screenkb_size">On-Screen-Tastatur Größe</string>
|
||||
<string name="controls_screenkb_large">Große</string>
|
||||
<string name="controls_screenkb_medium">Medium</string>
|
||||
<string name="controls_screenkb_small">Kleine</string>
|
||||
<string name="controls_screenkb_tiny">Winzig</string>
|
||||
<string name="controls_screenkb_theme">On-Screen-Tastatur Thema</string>
|
||||
<string name="controls_screenkb_by">%1$s von %2$s</string>
|
||||
<string name="accel_floating">Schwimmend</string>
|
||||
<string name="accel_fixed_start">Feste, wenn die Anwendung startet</string>
|
||||
<string name="accel_fixed_horiz">Fixiert auf Tisch Schreibtisch Orientierung</string>
|
||||
<string name="accel_question_center">Beschleunigungsmesser Mittelstellung</string>
|
||||
<string name="audiobuf_verysmall">Sehr kleine (schnelle Geräte, weniger Verzögerung)</string>
|
||||
<string name="rightclick_question">Rechter Mausklick ausgelöst durch</string>
|
||||
<string name="rightclick_menu">Menütaste</string>
|
||||
<string name="rightclick_multitouch">Touch-Screen mit dem zweiten Finger</string>
|
||||
<string name="rightclick_pressure">Touchscreen mit Kraft</string>
|
||||
<string name="pointandclick_question">Erweiterte Funktionen</string>
|
||||
<string name="pointandclick_keepaspectratio">Halten 4:3-Bildschirm Seitenverhältnis</string>
|
||||
<string name="pointandclick_showcreenunderfinger">Show-Bildschirm unter dem Finger in einem separaten Fenster</string>
|
||||
<string name="measurepressure_touchplease">Bitte schieben Sie den Finger über den Bildschirm für zwei Sekunden</string>
|
||||
<string name="rightclick_none">Deaktivieren der rechten Maustaste</string>
|
||||
<string name="leftclick_question">Linke Maustaste</string>
|
||||
<string name="leftclick_normal">Normal</string>
|
||||
<string name="leftclick_near_cursor">Tippen Sie auf nahe Mauszeiger</string>
|
||||
<string name="leftclick_multitouch">Touch-Screen mit dem zweiten Finger</string>
|
||||
<string name="leftclick_pressure">Touchscreen mit Kraft</string>
|
||||
<string name="leftclick_dpadcenter">Trackball klicken Select-Taste</string>
|
||||
<string name="pointandclick_joystickmouse">Bewegen Sie die Maus mit Joystick oder Trackball</string>
|
||||
<string name="measurepressure_response">Pressure %1$03d Radius %2$03d</string>
|
||||
<string name="click_with_dpadcenter">Linker Mausklick mit Trackball / Joystick Zentrum</string>
|
||||
<string name="pointandclick_joystickmousespeed">Bewegen Sie die Maus mit Joystick-Geschwindigkeit</string>
|
||||
<string name="pointandclick_joystickmouseaccel">Bewegen Sie die Maus mit Joystick-Beschleunigung</string>
|
||||
<string name="none">Keine</string>
|
||||
<string name="controls_screenkb_transparency">On-Screen-Tastatur Transparenz</string>
|
||||
<string name="controls_screenkb_trans_0">Nicht sichtbar</string>
|
||||
<string name="controls_screenkb_trans_1">Fast unsichtbar</string>
|
||||
<string name="controls_screenkb_trans_2">Transparente</string>
|
||||
<string name="controls_screenkb_trans_3">Semi-transparent</string>
|
||||
<string name="controls_screenkb_trans_4">Non-transparent</string>
|
||||
<string name="mouse_emulation">Maus-Emulation</string>
|
||||
<string name="measurepressure">Kalibrieren Touchscreen Druck</string>
|
||||
<string name="remap_hwkeys">Remap physischen Tasten</string>
|
||||
<string name="remap_hwkeys_press">Drücken Sie eine beliebige Taste außer HOME und POWER, können Sie Lautstärke-Tasten</string>
|
||||
<string name="remap_hwkeys_select">Wählen Sie SDL Schlüsselcode</string>
|
||||
<string name="remap_screenkb">Remap On-Screen-Steuerung</string>
|
||||
<string name="remap_screenkb_joystick">On-Screen-Joystick</string>
|
||||
<string name="remap_screenkb_button">On-Screen-Taste</string>
|
||||
<string name="remap_screenkb_button_text">On-Screen-Texteingabe-Taste</string>
|
||||
<string name="remap_screenkb_button_zoomin">Zoom in Zwei-Finger-Geste</string>
|
||||
<string name="remap_screenkb_button_zoomout">Verkleinern Zwei-Finger-Geste</string>
|
||||
<string name="remap_screenkb_button_rotateleft">Nach links drehen Zwei-Finger-Geste</string>
|
||||
<string name="remap_screenkb_button_rotateright">Nach rechts drehen Zwei-Finger-Geste</string>
|
||||
<string name="remap_screenkb_button_gestures">Zwei-Finger-Gesten</string>
|
||||
<string name="accel_veryfast">Sehr schnell</string>
|
||||
<string name="remap_screenkb_button_gestures_sensitivity">Zwei-Finger-Gesten Bildschirm Empfindlichkeit</string>
|
||||
<string name="storage_custom">Geben Sie direkt</string>
|
||||
<string name="storage_commandline">Geben Kommandozeilenparameter</string>
|
||||
<string name="calibrate_touchscreen">Kalibrieren Touchscreen</string>
|
||||
<string name="calibrate_touchscreen_touch">Touch allen vier Rändern des Bildschirms, drücken Sie Menü, wenn Sie fertig</string>
|
||||
<string name="screenkb_custom_layout">Passen Sie auf dem Bildschirm Tastatur-Layout</string>
|
||||
<string name="screenkb_custom_layout_help">Slide-Bildschirm hinzufügen Taste, drücken Sie Menü zum letzten Knopf rückgängig machen</string>
|
||||
<string name="rightclick_key">Physikalische Schlüssel</string>
|
||||
<string name="pointandclick_showcreenunderfinger2">On-Screen-Lupe</string>
|
||||
<string name="video">Video-Einstellungen</string>
|
||||
<string name="video_smooth">Glatte Video</string>
|
||||
<string name="accel_veryslow">Sehr langsam</string>
|
||||
<string name="leftclick_timeout">Halten Sie an der gleichen Stelle</string>
|
||||
<string name="leftclick_tap">Tippen Sie auf</string>
|
||||
<string name="leftclick_tap_or_timeout">Tippen Sie auf oder halten</string>
|
||||
<string name="leftclick_timeout_time">Holding-Timeout</string>
|
||||
<string name="leftclick_timeout_time_0">0,3 Sek.</string>
|
||||
<string name="leftclick_timeout_time_1">0,5 Sek.</string>
|
||||
<string name="leftclick_timeout_time_2">0,7 Sek.</string>
|
||||
<string name="leftclick_timeout_time_3">1 Sek.</string>
|
||||
<string name="leftclick_timeout_time_4">1,5 Sek.</string>
|
||||
<string name="pointandclick_relative">Relative Bewegung der Maus (Laptop-Modus)</string>
|
||||
<string name="pointandclick_relative_speed">Relative Maus Bewegungsgeschwindigkeit</string>
|
||||
<string name="pointandclick_relative_accel">Relative Bewegung der Maus Beschleunigung</string>
|
||||
<string name="downloads">Downloads</string>
|
||||
<string name="video_separatethread">Separaten Thread für Video, FPS bei einigen Geräten zu erhöhen</string>
|
||||
<string name="text_edit_click_here">Tippen Sie auf der Eingabe beginnen, drücken Sie Zurück, wenn Sie fertig</string>
|
||||
<string name="display_size_mouse">Konfigurieren der Maus je nach Display-Größe</string>
|
||||
<string name="display_size">Wählen Sie Ihre Display-Größe</string>
|
||||
<string name="display_size_large">Groß (Tablette)</string>
|
||||
<string name="display_size_small">Klein (Telefon)</string>
|
||||
<string name="display_size_tiny">Uberklein (Xperia Mini)</string>
|
||||
<string name="show_more_options">Weitere Optionen</string>
|
||||
<string name="controls_screenkb_drawsize">Größe der Schaltfläche Bilder</string>
|
||||
</resources>
|
||||
137
project/javaSDL2/translations/unsupported/values-fi/strings.xml
Normal file
137
project/javaSDL2/translations/unsupported/values-fi/strings.xml
Normal file
@@ -0,0 +1,137 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="init">Käynnistetään</string>
|
||||
<string name="please_wait">Odota kun tietoja ladataan</string>
|
||||
|
||||
<string name="device_config">Laiteasetukset</string>
|
||||
<string name="device_change_cfg">Muuta laiteasetuksia</string>
|
||||
|
||||
<string name="download_unneeded">Ei tarvitse ladata</string>
|
||||
<string name="connecting_to">Yhdistetään %s</string>
|
||||
<string name="failed_connecting_to">Yhdistäminen epäonnistui %s</string>
|
||||
<string name="error_connecting_to">Virhe yhdistettäessä %s</string>
|
||||
<string name="dl_from">Ladataan kohteesta %s</string>
|
||||
<string name="error_dl_from">Virhe ladattaessa kohteesta %s</string>
|
||||
<string name="error_write">Virhe kirjoittaessa %s</string>
|
||||
<string name="dl_progress">%1$.0f%% valmis: tiedosto %2$s</string>
|
||||
<string name="dl_finished">Valmis</string>
|
||||
|
||||
<string name="storage_phone">Sisäinen muisti - %d Mt vapaana</string>
|
||||
<string name="storage_sd">SD kortti - %d Mt vapaana</string>
|
||||
<string name="storage_question">Minne sovelluksen data ladataan</string>
|
||||
|
||||
<string name="controls_arrows">Nuolinapit / joystick / dpad</string>
|
||||
<string name="controls_trackball">Pallohiiri</string>
|
||||
<string name="controls_accel">Kiihtyvyysanturi</string>
|
||||
<string name="controls_question">Millaiset navigointinapit laittessasi on?</string>
|
||||
|
||||
<string name="trackball_no_dampening">Ei vaimennusta</string>
|
||||
<string name="trackball_fast">Nopea</string>
|
||||
<string name="trackball_medium">Kohtalainen</string>
|
||||
<string name="trackball_slow">Hidas</string>
|
||||
<string name="trackball_question">Pallohiiren vaimennus</string>
|
||||
|
||||
<string name="accel_fast">Nopea</string>
|
||||
<string name="accel_medium">Kohtalainen</string>
|
||||
<string name="accel_slow">Hidas</string>
|
||||
<string name="accel_question">Kiihtyvyysanturin herkkyys</string>
|
||||
|
||||
<string name="audiobuf_small">Pieni (nopeat laitteet)</string>
|
||||
<string name="audiobuf_medium">Keskisuuri</string>
|
||||
<string name="audiobuf_large">Suuri (jos ääni pätkii)</string>
|
||||
<string name="audiobuf_question">Äänipuskurin koko</string>
|
||||
<string name="optional_downloads">Vapaaehtoinen lataukset</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="controls_touch">Kosketusnäyttö vain</string>
|
||||
<string name="controls_additional">Muita ohjausobjekteja käyttää</string>
|
||||
<string name="controls_screenkb">Näyttönäppäimistöllä</string>
|
||||
<string name="controls_accelnav">Kiihtyvyysmittari</string>
|
||||
<string name="controls_screenkb_size">Näyttönäppäimistöllä koko</string>
|
||||
<string name="controls_screenkb_large">Suuri</string>
|
||||
<string name="controls_screenkb_medium">Medium</string>
|
||||
<string name="controls_screenkb_small">Pienet</string>
|
||||
<string name="controls_screenkb_tiny">Tiny</string>
|
||||
<string name="controls_screenkb_theme">Näyttönäppäimistöllä teema</string>
|
||||
<string name="controls_screenkb_by">%1$s %2$s</string>
|
||||
<string name="accel_floating">Kelluva</string>
|
||||
<string name="accel_fixed_start">Kiinteät kun sovellus käynnistyy</string>
|
||||
<string name="accel_fixed_horiz">Korjattu taulukko työpöytä suuntautumiseen</string>
|
||||
<string name="accel_question_center">Kiihtyvyysmittari keskiasentoon</string>
|
||||
<string name="audiobuf_verysmall">Hyvin pieni (nopea laitteita, vähemmän lag)</string>
|
||||
<string name="rightclick_question">Napsauta hiiren kakkospainikkeella alkunsa</string>
|
||||
<string name="rightclick_menu">Valikkonäppäin</string>
|
||||
<string name="rightclick_multitouch">Kosketusnäyttö on toinen sormi</string>
|
||||
<string name="rightclick_pressure">Kosketusnäyttö voimalla</string>
|
||||
<string name="pointandclick_question">Lisäominaisuudet</string>
|
||||
<string name="pointandclick_keepaspectratio">Pidä 04:03 kuvasuhde</string>
|
||||
<string name="pointandclick_showcreenunderfinger">Näytä näytön alle sormi erillisessä ikkunassa</string>
|
||||
<string name="measurepressure_touchplease">Ole hyvä ja liu\u0026#39;uttamalla sormea näytöllä kaksi sekuntia</string>
|
||||
<string name="rightclick_none">Poista oikealla hiiren klikkauksella</string>
|
||||
<string name="leftclick_question">Vasen hiiren nappi</string>
|
||||
<string name="leftclick_normal">Normaali</string>
|
||||
<string name="leftclick_near_cursor">Touch lähellä hiiren kursori</string>
|
||||
<string name="leftclick_multitouch">Kosketusnäyttö on toinen sormi</string>
|
||||
<string name="leftclick_pressure">Kosketusnäyttö voimalla</string>
|
||||
<string name="leftclick_dpadcenter">Trackball Valitse / Select-näppäintä</string>
|
||||
<string name="pointandclick_joystickmouse">Siirrä hiiren ohjaimella tai trackball</string>
|
||||
<string name="measurepressure_response">Paine %1$03d säde %2$03d</string>
|
||||
<string name="click_with_dpadcenter">Vasen hiiren klikkaus trackball-ohjaimella keskusta</string>
|
||||
<string name="pointandclick_joystickmousespeed">Siirrä hiiri ohjainta nopeasti</string>
|
||||
<string name="pointandclick_joystickmouseaccel">Siirrä hiiri ohjainta kiihtyvyys</string>
|
||||
<string name="none">Ei</string>
|
||||
<string name="controls_screenkb_transparency">Näyttönäppäimistöllä avoimuutta</string>
|
||||
<string name="controls_screenkb_trans_0">Näkymätön</string>
|
||||
<string name="controls_screenkb_trans_1">Lähes näkymätön</string>
|
||||
<string name="controls_screenkb_trans_2">Läpinäkyvä</string>
|
||||
<string name="controls_screenkb_trans_3">Semi-avoimet</string>
|
||||
<string name="controls_screenkb_trans_4">Ei-läpinäkyvä</string>
|
||||
<string name="mouse_emulation">Hiiren emulointi</string>
|
||||
<string name="measurepressure">Kalibroi kosketusnäyttö paine</string>
|
||||
<string name="remap_hwkeys">Remap fyysiset näppäimet</string>
|
||||
<string name="remap_hwkeys_press">Paina mitä tahansa näppäintä paitsi koti-ja POWER, voit käyttää äänenvoimakkuusnäppäimiä</string>
|
||||
<string name="remap_hwkeys_select">Valitse SDL näppäinkoodien</string>
|
||||
<string name="remap_screenkb">Remap näytön valvonnan</string>
|
||||
<string name="remap_screenkb_joystick">Näytöllä ohjainta</string>
|
||||
<string name="remap_screenkb_button">Ruutunäyttöpainike</string>
|
||||
<string name="remap_screenkb_button_text">Näytön tekstin tulopainiketta</string>
|
||||
<string name="remap_screenkb_button_zoomin">Suurenna kahden sormen elettä</string>
|
||||
<string name="remap_screenkb_button_zoomout">Pienennä kahden sormen elettä</string>
|
||||
<string name="remap_screenkb_button_rotateleft">Kierrä vasemmalle kahden sormen elettä</string>
|
||||
<string name="remap_screenkb_button_rotateright">Kierrä oikealle kahden sormen elettä</string>
|
||||
<string name="remap_screenkb_button_gestures">Kahden sormen eleitä</string>
|
||||
<string name="accel_veryfast">Erittäin nopea</string>
|
||||
<string name="remap_screenkb_button_gestures_sensitivity">Kahden sormen näytön eleet herkkyys</string>
|
||||
<string name="storage_custom">Määritä hakemisto</string>
|
||||
<string name="storage_commandline">Määritä komentoriviparametrit</string>
|
||||
<string name="calibrate_touchscreen">Kalibroi kosketusnäyttö</string>
|
||||
<string name="calibrate_touchscreen_touch">Touch kaikki neljä reunaa näytön, paina Valikko, kun olet valmis</string>
|
||||
<string name="screenkb_custom_layout">Mukauta-ruudun näppäimistö</string>
|
||||
<string name="screenkb_custom_layout_help">Työnnä näytön lisätä painikkeen, paina Menu kumota viimeksi painike</string>
|
||||
<string name="rightclick_key">Fyysinen avain</string>
|
||||
<string name="pointandclick_showcreenunderfinger2">Näytöllä suurennuslasi</string>
|
||||
<string name="video">Videon asetukset</string>
|
||||
<string name="video_smooth">Tasainen video</string>
|
||||
<string name="accel_veryslow">Erittäin hidas</string>
|
||||
<string name="leftclick_timeout">Pidä samalla paikalla</string>
|
||||
<string name="leftclick_tap">Hana</string>
|
||||
<string name="leftclick_tap_or_timeout">Napauta tai pidä</string>
|
||||
<string name="leftclick_timeout_time">Holding aikakatkaisu</string>
|
||||
<string name="leftclick_timeout_time_0">0,3 sekuntia</string>
|
||||
<string name="leftclick_timeout_time_1">0,5 sekuntia</string>
|
||||
<string name="leftclick_timeout_time_2">0,7 sekuntia</string>
|
||||
<string name="leftclick_timeout_time_3">1 sek</string>
|
||||
<string name="leftclick_timeout_time_4">1,5 sek</string>
|
||||
<string name="pointandclick_relative">Suhteellinen hiiren liikkeet (kannettavan tietokoneen tilassa)</string>
|
||||
<string name="pointandclick_relative_speed">Suhteellinen hiiren liikkeen nopeus</string>
|
||||
<string name="pointandclick_relative_accel">Suhteellinen hiiren liikkeen kiihtyvyys</string>
|
||||
<string name="downloads">Downloads</string>
|
||||
<string name="video_separatethread">Erillisessä säikeessä video, kasvaa FPS joissakin laitteissa</string>
|
||||
<string name="text_edit_click_here">Napauta aloittaa kirjoittamisen, paina Takaisin, kun olet valmis</string>
|
||||
<string name="display_size_mouse">Määritä hiiren riippuen näytön koosta</string>
|
||||
<string name="display_size">Valitse näytön koko</string>
|
||||
<string name="display_size_large">Suuri (tabletti)</string>
|
||||
<string name="display_size_small">Pieni (puhelin)</string>
|
||||
<string name="display_size_tiny">Tiny (Xperia Mini)</string>
|
||||
<string name="show_more_options">Näytä enemmän vaihtoehtoja</string>
|
||||
<string name="controls_screenkb_drawsize">Koko painike kuvia</string>
|
||||
</resources>
|
||||
176
project/javaSDL2/translations/values-fr/strings.xml
Normal file
176
project/javaSDL2/translations/values-fr/strings.xml
Normal file
@@ -0,0 +1,176 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="init">Démarrage</string>
|
||||
<string name="please_wait">Veuillez patienter pendant que les données sont téléchargées</string>
|
||||
|
||||
<string name="device_config">Configuration de l\'appareil</string>
|
||||
<string name="device_change_cfg">Changer la configuration</string>
|
||||
|
||||
<string name="download_unneeded">Téléchargement non nécessaire</string>
|
||||
<string name="connecting_to">Connexion à %s</string>
|
||||
<string name="failed_connecting_to">Echec de la connexion à %s</string>
|
||||
<string name="error_connecting_to">Erreur durant la connexion à %s</string>
|
||||
<string name="dl_from">Téléchargement à partir de %s</string>
|
||||
<string name="error_dl_from">Erreur lors du téléchargement à partir de %s</string>
|
||||
<string name="error_write">Erreur d\'écriture dans %s</string>
|
||||
<string name="dl_progress">%1$.0f%% fait : fichier %2$s</string>
|
||||
<string name="dl_finished">Fini</string>
|
||||
|
||||
<string name="storage_phone">Stockage interne - %d Mo de libre</string>
|
||||
<string name="storage_sd">Carte SD - %d Mo de libre</string>
|
||||
<string name="storage_custom">Choisir le répertoire</string>
|
||||
<string name="storage_commandline">Choisir les paramètres de la ligne de commande</string>
|
||||
<string name="storage_question">Où télécharger les données</string>
|
||||
<string name="optional_downloads">Téléchargements</string>
|
||||
<string name="downloads">Téléchargements</string>
|
||||
<string name="ok">OK</string>
|
||||
|
||||
<string name="controls_arrows">Flèches / joystick / dpad</string>
|
||||
<string name="controls_trackball">Trackball</string>
|
||||
<string name="controls_accel">Accéléromètre</string>
|
||||
<string name="controls_touch">Ecran tactile seul</string>
|
||||
<string name="controls_question">Quel type de touches votre appareil a-t-il?</string>
|
||||
|
||||
<string name="controls_additional">Contrôles supplémentaires</string>
|
||||
<string name="controls_screenkb">Clavier à l\'écran</string>
|
||||
<string name="controls_accelnav">Accéléromètre</string>
|
||||
|
||||
<string name="controls_screenkb_size">Taille du clavier à l\'écran</string>
|
||||
<string name="controls_screenkb_drawsize">Taille des images des boutons</string>
|
||||
<string name="controls_screenkb_large">Grande</string>
|
||||
<string name="controls_screenkb_medium">Moyenne</string>
|
||||
<string name="controls_screenkb_small">Petite</string>
|
||||
<string name="controls_screenkb_tiny">Minuscule</string>
|
||||
<string name="controls_screenkb_theme">Thème du clavier à l\'écran</string>
|
||||
<string name="controls_screenkb_by">%1$s par %2$s</string>
|
||||
<string name="controls_screenkb_transparency">Transparence du clavier</string>
|
||||
<string name="controls_screenkb_trans_0">Invisible</string>
|
||||
<string name="controls_screenkb_trans_1">Presque invisible</string>
|
||||
<string name="controls_screenkb_trans_2">Transparent</string>
|
||||
<string name="controls_screenkb_trans_3">Semi-transparent</string>
|
||||
<string name="controls_screenkb_trans_4">Non-transparent</string>
|
||||
|
||||
<string name="trackball_no_dampening">Sans limite</string>
|
||||
<string name="trackball_fast">Rapide</string>
|
||||
<string name="trackball_medium">Moyenne</string>
|
||||
<string name="trackball_slow">Lente</string>
|
||||
<string name="trackball_question">Limitation du trackball</string>
|
||||
|
||||
<string name="accel_veryfast">Très rapide</string>
|
||||
<string name="accel_fast">Rapide</string>
|
||||
<string name="accel_medium">Moyenne</string>
|
||||
<string name="accel_slow">Lente</string>
|
||||
<string name="accel_veryslow">Très lente</string>
|
||||
<string name="accel_question">Sensibilité de l\'accéléromètre</string>
|
||||
|
||||
<string name="accel_floating">Flottante</string>
|
||||
<string name="accel_fixed_start">Déterminée au démarrage de l\'application</string>
|
||||
<string name="accel_fixed_horiz">Orientaton de la table</string>
|
||||
<string name="accel_question_center">Position du centre de l\'accéléromètre</string>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<string name="mouse_emulation">Emulation de la souris</string>
|
||||
<string name="rightclick_question">Clic droit de la souris</string>
|
||||
<string name="rightclick_menu">Touche Menu</string>
|
||||
<string name="rightclick_key">Touche Physique</string>
|
||||
<string name="rightclick_multitouch">Ecran tactile avec le deuxième doigt</string>
|
||||
<string name="rightclick_pressure">Ecran tactile avec force</string>
|
||||
<string name="rightclick_none">Désactiver le clic droit de la souris</string>
|
||||
|
||||
<string name="leftclick_question">Clic gauche de la souris</string>
|
||||
<string name="leftclick_normal">Normal</string>
|
||||
<string name="leftclick_near_cursor">Curseur de la souris près Touch</string>
|
||||
<string name="leftclick_multitouch">Ecran tactile avec le deuxième doigt</string>
|
||||
<string name="leftclick_pressure">Ecran tactile avec force</string>
|
||||
<string name="leftclick_dpadcenter">Trackball clic / Joystick au centre</string>
|
||||
<string name="leftclick_timeout">Tenir au même endroit</string>
|
||||
<string name="leftclick_tap">Appuyez sur</string>
|
||||
<string name="leftclick_tap_or_timeout">Appuyez sur, ou maintenez</string>
|
||||
<string name="leftclick_timeout_time">timeout Holding</string>
|
||||
<string name="leftclick_timeout_time_0">0,3 s</string>
|
||||
<string name="leftclick_timeout_time_1">0,5 sec</string>
|
||||
<string name="leftclick_timeout_time_2">0,7 sec</string>
|
||||
<string name="leftclick_timeout_time_3">1 sec</string>
|
||||
<string name="leftclick_timeout_time_4">1,5 sec</string>
|
||||
<string name="click_with_dpadcenter">Cliquez gauche de la souris avec le Trackball / centre du joystick </string>
|
||||
|
||||
<string name="pointandclick_question">Fonctionnalités avancées</string>
|
||||
<string name="pointandclick_keepaspectratio">Gardez le format 4:3 écran</string>
|
||||
<string name="pointandclick_showcreenunderfinger">Afficher l\'écran sous le doigt dans une fenêtre séparée</string>
|
||||
<string name="pointandclick_showcreenunderfinger2">Loupe à l\'écran</string>
|
||||
<string name="pointandclick_joystickmouse">Déplacez la souris avec un trackball ou le joystick</string>
|
||||
<string name="pointandclick_joystickmousespeed">Déplacez la souris avec la vitesse du joystick</string>
|
||||
<string name="pointandclick_joystickmouseaccel">Déplacez la souris avec l\'accélération du joystick</string>
|
||||
<string name="pointandclick_relative">Mouvement relatif de la souris (mode portable)</string>
|
||||
<string name="pointandclick_relative_speed">Vitesse relative de la souris</string>
|
||||
<string name="pointandclick_relative_accel">Accélération relative de la souris</string>
|
||||
|
||||
<string name="none">Aucun</string>
|
||||
|
||||
<string name="measurepressure">Calibrer la pression de l\'écran tactile</string>
|
||||
<string name="measurepressure_touchplease">Glisser les doigts sur l\'écran pendant deux secondes</string>
|
||||
<string name="measurepressure_response">Pression %1$03d rayon %2$03d</string>
|
||||
|
||||
<string name="audiobuf_verysmall">Très petite (appareils rapides, plus de réactivité)</string>
|
||||
<string name="audiobuf_small">Petite (appareils rapides)</string>
|
||||
<string name="audiobuf_medium">Moyenne</string>
|
||||
<string name="audiobuf_large">Grande (appareils anciens, si le son est saccadé)</string>
|
||||
<string name="audiobuf_question">Taille du tampon audio</string>
|
||||
|
||||
<string name="remap_hwkeys">Reconfigurer les touches physiques</string>
|
||||
<string name="remap_hwkeys_press">Appuyez sur n\'importe quelle touche sauf HOME et POWER, vous pouvez utiliser les touches de volume</string>
|
||||
<string name="remap_hwkeys_select">Sélectionnez le keycode SDL</string>
|
||||
|
||||
<string name="remap_screenkb">Reconfigurer les contrôles via l\'écran</string>
|
||||
<string name="remap_screenkb_joystick">Joystick à l\'écran</string>
|
||||
<string name="remap_screenkb_button">Bouton à l\'écran</string>
|
||||
<string name="remap_screenkb_button_text">Saisie de texte à l\'écran</string>
|
||||
<string name="remap_screenkb_button_gestures">Gestes avec deux doigts</string>
|
||||
<string name="remap_screenkb_button_gestures_sensitivity">Sensibilité des gestes</string>
|
||||
<string name="remap_screenkb_button_zoomin">Geste de +Zoom avec deux doigts</string>
|
||||
<string name="remap_screenkb_button_zoomout">Geste de -Zoom avec deux doigts</string>
|
||||
<string name="remap_screenkb_button_rotateleft">Geste de rotation à gauche avec deux doigts</string>
|
||||
<string name="remap_screenkb_button_rotateright">Geste de rotation à droite avec deux doigts</string>
|
||||
|
||||
<string name="screenkb_custom_layout">Personnalisation de la présentation du clavier à l\'écran</string>
|
||||
|
||||
<string name="calibrate_touchscreen">Calibrer l\'écran tactile</string>
|
||||
<string name="calibrate_touchscreen_touch">Touchez les bords de l\'écran, appuyez sur Retour/BACK lorsque vous avez terminé</string>
|
||||
|
||||
<string name="video">Paramètres vidéo</string>
|
||||
<string name="video_smooth">Fluidité de la vidéo</string>
|
||||
<string name="video_separatethread">Thread séparé pour la vidéo : permet paroifs d\'augmenter FPS</string>
|
||||
|
||||
<string name="text_edit_click_here">Appuyez pour commencer à taper, appuyez sur Retour/BACK lorsque vous avez terminé</string>
|
||||
|
||||
<string name="display_size_mouse">Mode d\'émulation de la souris</string>
|
||||
<string name="display_size">Sélectionnez votre taille d\'affichage</string>
|
||||
<string name="display_size_large">Large (tablet)</string>
|
||||
<string name="display_size_small">Petit (téléphone)</string>
|
||||
<string name="display_size_small_touchpad">Petit, mode touchpad</string>
|
||||
<string name="display_size_tiny">Très petit</string>
|
||||
<string name="display_size_tiny_touchpad">Très petit, mode touchpad</string>
|
||||
|
||||
<string name="show_more_options">Afficher plus d\'options</string>
|
||||
|
||||
<string name="hardware_mouse_detected">Hardware mouse detected, disabling mouse emulation</string>
|
||||
<string name="not_enough_ram">Not enough RAM</string>
|
||||
<string name="not_enough_ram_size">This app needs %1$d Mb RAM, your device has %2$d Mb</string>
|
||||
<string name="ignore">Ignore</string>
|
||||
<string name="calibrate_gyroscope">Calibrate gyroscope</string>
|
||||
<string name="calibrate_gyroscope_text">Put your phone on a flat surface</string>
|
||||
<string name="reset_config">Reset config to defaults</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="calibrate_gyroscope_not_supported">Your device does not have gyroscope</string>
|
||||
<string name="reset_config_ask">Reset all options to default values?</string>
|
||||
<string name="cancel_download">Cancel data downloading?</string>
|
||||
<string name="cancel_download_resume">You can resume it later, the data will not be downloaded twice.</string>
|
||||
<string name="yes">Yes</string>
|
||||
<string name="no">No</string>
|
||||
<string name="screenkb_custom_layout_help">Press BACK when done. Resize buttons by sliding on empty space.</string>
|
||||
<string name="controls_screenkb_custom">Custom</string>
|
||||
</resources>
|
||||
149
project/javaSDL2/translations/values-ru/strings.xml
Normal file
149
project/javaSDL2/translations/values-ru/strings.xml
Normal file
@@ -0,0 +1,149 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="init">Инициализация</string>
|
||||
<string name="please_wait">Пожалуйста, подождите, пока данные загружаются</string>
|
||||
<string name="device_config">Конфигурация устройства</string>
|
||||
<string name="device_change_cfg">Изменение конфигурации устройства</string>
|
||||
<string name="download_unneeded">Нет необходимости скачивать</string>
|
||||
<string name="connecting_to">Подключение к %s</string>
|
||||
<string name="failed_connecting_to">Ошибка подключения к %s</string>
|
||||
<string name="error_connecting_to">Ошибка подключения к %s</string>
|
||||
<string name="dl_from">Загрузка данных с %s</string>
|
||||
<string name="error_dl_from">Ошибка при загрузке данных с %s</string>
|
||||
<string name="error_write">Ошибка записи в %s</string>
|
||||
<string name="dl_progress">%1$.0f%% готово: файл %2$s</string>
|
||||
<string name="dl_finished">Завершенный</string>
|
||||
<string name="storage_phone">Внутреннее хранение - %d Мб</string>
|
||||
<string name="storage_sd">SD карта - %d Мб</string>
|
||||
<string name="storage_question">Куда сохранять данные приложения</string>
|
||||
<string name="optional_downloads">Дополнительные загрузки</string>
|
||||
<string name="ok">Продолжить</string>
|
||||
<string name="controls_arrows">Стрелки / джойстик / Dpad</string>
|
||||
<string name="controls_trackball">Трекбол</string>
|
||||
<string name="controls_accel">Акселерометр</string>
|
||||
<string name="controls_touch">Только сенсорный экран</string>
|
||||
<string name="controls_question">Какие на телефоне клавиши навигации?</string>
|
||||
<string name="controls_additional">Дополнительные элементы управления</string>
|
||||
<string name="controls_screenkb">Экранная клавиатура</string>
|
||||
<string name="controls_accelnav">Акселерометр</string>
|
||||
<string name="controls_screenkb_size">Размер экранной клавиатуры</string>
|
||||
<string name="controls_screenkb_large">Большой</string>
|
||||
<string name="controls_screenkb_medium">Средний</string>
|
||||
<string name="controls_screenkb_small">Маленький</string>
|
||||
<string name="controls_screenkb_tiny">Крошечный</string>
|
||||
<string name="controls_screenkb_theme">Тема клавиатуры</string>
|
||||
<string name="controls_screenkb_by">%1$s от %2$s</string>
|
||||
<string name="trackball_no_dampening">Нет</string>
|
||||
<string name="trackball_fast">Быстрое</string>
|
||||
<string name="trackball_medium">Среднее</string>
|
||||
<string name="trackball_slow">Медленное</string>
|
||||
<string name="trackball_question">Замедление трекбола</string>
|
||||
<string name="accel_fast">Быстрая</string>
|
||||
<string name="accel_medium">Средний</string>
|
||||
<string name="accel_slow">Медленно</string>
|
||||
<string name="accel_question">Чувствительность акселерометра</string>
|
||||
<string name="rightclick_question">Правая кнопка мыши</string>
|
||||
<string name="rightclick_menu">Клавиша меню</string>
|
||||
<string name="rightclick_multitouch">Касание экрана вторым пальцем</string>
|
||||
<string name="rightclick_pressure">Нажатие на экран с силой</string>
|
||||
<string name="pointandclick_question">Расширенные функции</string>
|
||||
<string name="pointandclick_keepaspectratio">Сохранять соотношение сторон 4:3 на экране</string>
|
||||
<string name="pointandclick_showcreenunderfinger">Экранная лупа</string>
|
||||
<string name="measurepressure_touchplease">Пожалуйста, проведите пальцем по экрану в течение двух секунд</string>
|
||||
<string name="measurepressure_response">Давление %1$03d радиус %2$03d </string>
|
||||
<string name="audiobuf_verysmall">Очень мало (быстрые устройства)</string>
|
||||
<string name="audiobuf_small">Малый</string>
|
||||
<string name="audiobuf_medium">Средний</string>
|
||||
<string name="audiobuf_large">Большой (для старых устройств, если звук прерывается)</string>
|
||||
<string name="audiobuf_question">Размер буфера аудио</string>
|
||||
<string name="accel_floating">Плавающее</string>
|
||||
<string name="accel_fixed_start">Фиксировано при запуске приложения</string>
|
||||
<string name="accel_fixed_horiz">Фиксировано на горизонт</string>
|
||||
<string name="accel_question_center">Центральное положение акселерометра</string>
|
||||
<string name="rightclick_none">Правая кнопка мыши отключена</string>
|
||||
<string name="leftclick_question">Левая кнопка мыши</string>
|
||||
<string name="leftclick_normal">Нормальный</string>
|
||||
<string name="leftclick_near_cursor">Касание возле курсора мыши</string>
|
||||
<string name="leftclick_multitouch">Касание двумя пальцами</string>
|
||||
<string name="leftclick_pressure">Нажатие с силой</string>
|
||||
<string name="leftclick_dpadcenter">Нажатие на трекбол / центр джойстика</string>
|
||||
<string name="pointandclick_joystickmouse">Перемещение мыши при помощи джойстика или трекбола</string>
|
||||
<string name="click_with_dpadcenter">Левый клик мыши при помощи трекбола / центра джойстика</string>
|
||||
<string name="pointandclick_joystickmousespeed">Перемещение мыши джойстиком - скорость</string>
|
||||
<string name="pointandclick_joystickmouseaccel">Перемещение мыши джойстиком - ускорение</string>
|
||||
<string name="none">Нет</string>
|
||||
<string name="controls_screenkb_transparency">Прозрачность клавиатуры</string>
|
||||
<string name="controls_screenkb_trans_0">Невидимый</string>
|
||||
<string name="controls_screenkb_trans_1">Почти невидимый</string>
|
||||
<string name="controls_screenkb_trans_2">Прозрачный</string>
|
||||
<string name="controls_screenkb_trans_3">Полупрозрачные</string>
|
||||
<string name="controls_screenkb_trans_4">Непрозрачные</string>
|
||||
<string name="mouse_emulation">Эмуляции мыши</string>
|
||||
<string name="measurepressure">Калибровка сенсорного давления</string>
|
||||
<string name="remap_hwkeys">Переназначение физических клавиш</string>
|
||||
<string name="remap_hwkeys_press">Нажмите любую клавишу, кроме HOME и POWER, вы можете использовать клавиши регулировки громкости</string>
|
||||
<string name="remap_hwkeys_select">Выберите код кнопки SDL</string>
|
||||
<string name="remap_screenkb">Переназначение экранных кнопок</string>
|
||||
<string name="remap_screenkb_joystick">Экранный джойстик</string>
|
||||
<string name="remap_screenkb_button">Экранные кнопки</string>
|
||||
<string name="remap_screenkb_button_text">Экранная кнопка ввода текста</string>
|
||||
<string name="remap_screenkb_button_zoomin">Увеличить двумя пальцами</string>
|
||||
<string name="remap_screenkb_button_zoomout">Уменьшить двумя пальцами</string>
|
||||
<string name="remap_screenkb_button_rotateleft">Повернуть налево двумя пальцами</string>
|
||||
<string name="remap_screenkb_button_rotateright">Повернуть вправо двумя пальцами</string>
|
||||
<string name="remap_screenkb_button_gestures">Жест двумя пальцами по экрану</string>
|
||||
<string name="accel_veryfast">Очень быстро</string>
|
||||
<string name="remap_screenkb_button_gestures_sensitivity">Чувствительность жеста двумя пальцами по экрану</string>
|
||||
<string name="storage_custom">Укажите каталог</string>
|
||||
<string name="storage_commandline">Укажите параметры командной строки</string>
|
||||
<string name="calibrate_touchscreen">Калибровка сенсорного экрана</string>
|
||||
<string name="calibrate_touchscreen_touch">Дотроньтесь до всех краев экрана, потом нажмите Назад/BACK</string>
|
||||
<string name="screenkb_custom_layout">Настройка расположения кнопок</string>
|
||||
<string name="screenkb_custom_layout_help">Нажмите клавишу Назад/BACK для завершения. Проведите по пустому месту, чтобы изменить размер кнопки</string>
|
||||
<string name="rightclick_key">Физическая кнопка</string>
|
||||
<string name="pointandclick_showcreenunderfinger2">Наэкранная лупа</string>
|
||||
<string name="video">Настройки видео</string>
|
||||
<string name="video_smooth">Линейное сглаживание видео</string>
|
||||
<string name="accel_veryslow">Очень медленно</string>
|
||||
<string name="leftclick_timeout">Нажатие с задержкой</string>
|
||||
<string name="leftclick_tap">Быстрое нажатие</string>
|
||||
<string name="leftclick_tap_or_timeout">Быстрое нажатие либо с задержкой</string>
|
||||
<string name="leftclick_timeout_time">Время нажатия</string>
|
||||
<string name="leftclick_timeout_time_0">0,3 сек</string>
|
||||
<string name="leftclick_timeout_time_1">0,5 сек</string>
|
||||
<string name="leftclick_timeout_time_2">0,7 сек</string>
|
||||
<string name="leftclick_timeout_time_3">1 сек</string>
|
||||
<string name="leftclick_timeout_time_4">1,5 сек</string>
|
||||
<string name="pointandclick_relative">Относительное движение мыши (режим ноутбука)</string>
|
||||
<string name="pointandclick_relative_speed">Скорость движения мыши</string>
|
||||
<string name="pointandclick_relative_accel">Ускорение движения мыши</string>
|
||||
<string name="downloads">Загрузки</string>
|
||||
<string name="video_separatethread">Отдельный поток для видео, увеличит FPS на некоторых устройствах</string>
|
||||
<string name="text_edit_click_here">Нажмите, чтобы ввести текст, нажмите Назад, когда закончите</string>
|
||||
<string name="display_size_mouse">Настройка размера дисплея</string>
|
||||
<string name="display_size">Размер дисплея</string>
|
||||
<string name="display_size_large">Большой (таблетка)</string>
|
||||
<string name="display_size_small">Маленький (телефон)</string>
|
||||
<string name="display_size_tiny">Крохотный</string>
|
||||
<string name="show_more_options">Показать больше параметров</string>
|
||||
<string name="controls_screenkb_drawsize">Размер изображения кнопок</string>
|
||||
<string name="display_size_small_touchpad">Маленький, режим тачпада</string>
|
||||
<string name="display_size_tiny_touchpad">Крохотный, режим тачпада</string>
|
||||
<string name="hardware_mouse_detected">Обнаружена внешняя мышь, эмуляция мыши выключена</string>
|
||||
|
||||
<string name="not_enough_ram">Недостаточно оперативной памяти</string>
|
||||
<string name="not_enough_ram_size">Для запуска приложения нужно %1$d Мб оперативной памяти, на этом устройстве есть %2$d Мб</string>
|
||||
<string name="ignore">Игнорировать</string>
|
||||
|
||||
<string name="calibrate_gyroscope">Калибровать гироскоп</string>
|
||||
<string name="calibrate_gyroscope_text">Положите устройство на ровную поверхность</string>
|
||||
<string name="reset_config">Сбросить все настройки</string>
|
||||
<string name="cancel">Отменить</string>
|
||||
<string name="calibrate_gyroscope_not_supported">Гироскоп отсутствует</string>
|
||||
<string name="reset_config_ask">Сбросить все настройки в значения по умолчанию?</string>
|
||||
<string name="cancel_download">Остановить загрузку?</string>
|
||||
<string name="cancel_download_resume">Загрузка может быть продолжена позднее.</string>
|
||||
<string name="yes">Да</string>
|
||||
<string name="no">Нет</string>
|
||||
<string name="controls_screenkb_custom">Пользовательские настройки</string>
|
||||
</resources>
|
||||
148
project/javaSDL2/translations/values-uk/strings.xml
Normal file
148
project/javaSDL2/translations/values-uk/strings.xml
Normal file
@@ -0,0 +1,148 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="init">Ініціалізація</string>
|
||||
<string name="please_wait">Будь-ласка, зачекайте, поки завантажуться дані</string>
|
||||
<string name="device_config">Конфігурація пристрою</string>
|
||||
<string name="device_change_cfg">Зміна конфігурації пристрою</string>
|
||||
<string name="download_unneeded">Немає необхідності викачувати</string>
|
||||
<string name="connecting_to">Підключенння до %s</string>
|
||||
<string name="failed_connecting_to">Помилка підключення до %s</string>
|
||||
<string name="error_connecting_to">помилка підключення до %s</string>
|
||||
<string name="dl_from">Завантаження даних з %s</string>
|
||||
<string name="error_dl_from">Помилка при завантаженні даних з %s</string>
|
||||
<string name="error_write">Помилка запису в %s</string>
|
||||
<string name="dl_progress">%1$.0f%% готово: файл %2$s</string>
|
||||
<string name="dl_finished">Завершений</string>
|
||||
<string name="storage_phone">Внутрішнє зберігання - %d Мб</string>
|
||||
<string name="storage_sd">SD карта - %d Мб</string>
|
||||
<string name="storage_question">Куди зберігати дані програми</string>
|
||||
<string name="optional_downloads">Додаткові завантаження</string>
|
||||
<string name="ok">ОК</string>
|
||||
<string name="controls_arrows">Стрілки / джойстік / Dpad</string>
|
||||
<string name="controls_trackball">Трекбол</string>
|
||||
<string name="controls_accel">Акселерометр</string>
|
||||
<string name="controls_touch">Тільки сенсорний екран</string>
|
||||
<string name="controls_question">Які на телефоні кнопки навігації?</string>
|
||||
<string name="controls_additional">Додаткові элементи керування</string>
|
||||
<string name="controls_screenkb">Наекранні кнопки</string>
|
||||
<string name="controls_accelnav">Акселерометр</string>
|
||||
<string name="controls_screenkb_size">Розмір наекранних кнопок</string>
|
||||
<string name="controls_screenkb_large">Великий</string>
|
||||
<string name="controls_screenkb_medium">Середній</string>
|
||||
<string name="controls_screenkb_small">Малий</string>
|
||||
<string name="controls_screenkb_tiny">Дрібний</string>
|
||||
<string name="controls_screenkb_theme">Тема кнопок</string>
|
||||
<string name="controls_screenkb_by">%1$s від %2$s</string>
|
||||
<string name="trackball_no_dampening">Немає</string>
|
||||
<string name="trackball_fast">Швидке</string>
|
||||
<string name="trackball_medium">Середнє</string>
|
||||
<string name="trackball_slow">Повільне</string>
|
||||
<string name="trackball_question">Сповільнення трекболу</string>
|
||||
<string name="accel_fast">Швидко</string>
|
||||
<string name="accel_medium">середньо</string>
|
||||
<string name="accel_slow">повільно</string>
|
||||
<string name="accel_question">Чутливість акселерометру</string>
|
||||
<string name="rightclick_question">Права кнопка миші</string>
|
||||
<string name="rightclick_menu">Кнопка меню</string>
|
||||
<string name="rightclick_multitouch">Торкання екрана другим пальцем</string>
|
||||
<string name="rightclick_pressure">Натиск на екран силою</string>
|
||||
<string name="pointandclick_question">Розширені функції</string>
|
||||
<string name="pointandclick_keepaspectratio">Зберігати співвідношення сторін 4:3 на екрані</string>
|
||||
<string name="pointandclick_showcreenunderfinger">Наекранна лупа</string>
|
||||
<string name="measurepressure_touchplease">Будь-ласка, проведіть пальцем по екрану на протязі двох секунд</string>
|
||||
<string name="measurepressure_response">Тиск %1$03d радіус %2$03d </string>
|
||||
<string name="audiobuf_verysmall">Дуже мало (швидкі пристрої)</string>
|
||||
<string name="audiobuf_small">Малий</string>
|
||||
<string name="audiobuf_medium">Середній</string>
|
||||
<string name="audiobuf_large">Великий (для старих пристроїв, якщо звук переривається)</string>
|
||||
<string name="audiobuf_question">Розмір буферу аудіо</string>
|
||||
<string name="accel_floating">Плаваюче</string>
|
||||
<string name="accel_fixed_start">Фiксоване під час запуску програми</string>
|
||||
<string name="accel_fixed_horiz">Фiксоване до горизонту</string>
|
||||
<string name="accel_question_center">Центральне положення акселерометра</string>
|
||||
<string name="rightclick_none">Вiдключена</string>
|
||||
<string name="leftclick_question">Ліва кнопка миші</string>
|
||||
<string name="leftclick_normal">Нормальна</string>
|
||||
<string name="leftclick_near_cursor">Дотик біля курсору миші</string>
|
||||
<string name="leftclick_multitouch">Натиск на екран другим пальцем</string>
|
||||
<string name="leftclick_pressure">>Натиск на екран з силою</string>
|
||||
<string name="leftclick_dpadcenter">Натиск на трекбол / центр джойстику</string>
|
||||
<string name="pointandclick_joystickmouse">Переміщення миші за допомогою джойстика або трекбола</string>
|
||||
<string name="click_with_dpadcenter">Лівий клік миші за допомогою трекбола / центра джойстика</string>
|
||||
<string name="pointandclick_joystickmousespeed">Переміщення миші джойстиком - швидкiсть</string>
|
||||
<string name="pointandclick_joystickmouseaccel">Переміщення миші джойстиком - прискорення</string>
|
||||
<string name="none">Немає</string>
|
||||
<string name="controls_screenkb_transparency">Прозорість клавіатури</string>
|
||||
<string name="controls_screenkb_trans_0">Невидимий</string>
|
||||
<string name="controls_screenkb_trans_1">Майже невидимий</string>
|
||||
<string name="controls_screenkb_trans_2">Прозорий</string>
|
||||
<string name="controls_screenkb_trans_3">Напівпрозорі</string>
|
||||
<string name="controls_screenkb_trans_4">Непрозорі</string>
|
||||
<string name="mouse_emulation">Емуляція миші</string>
|
||||
<string name="measurepressure">Калібрування сенсорного натискання</string>
|
||||
<string name="remap_hwkeys">Перепризначення фізичних кнопок</string>
|
||||
<string name="remap_hwkeys_press">Натисніть будь-яку клавішу, крім HOME і POWER, ви можете використовувати клавіші регулювання гучності</string>
|
||||
<string name="remap_hwkeys_select">Виберіть код кнопки SDL</string>
|
||||
<string name="remap_screenkb">Перепризначення наекранних кнопок</string>
|
||||
<string name="remap_screenkb_joystick">Наекранний джойстік</string>
|
||||
<string name="remap_screenkb_button">Наекранні кнопки</string>
|
||||
<string name="remap_screenkb_button_text">Наекранна кнопка вводу тексту</string>
|
||||
<string name="remap_screenkb_button_zoomin">Збільшити двома пальцями</string>
|
||||
<string name="remap_screenkb_button_zoomout">Зменшити двома пальцями</string>
|
||||
<string name="remap_screenkb_button_rotateleft">Повернути наліво двома пальцями</string>
|
||||
<string name="remap_screenkb_button_rotateright">Повернути праворуч двома пальцями</string>
|
||||
<string name="remap_screenkb_button_gestures">Жест двома пальцями по екрану</string>
|
||||
<string name="accel_veryfast">Дуже швидко</string>
|
||||
<string name="remap_screenkb_button_gestures_sensitivity">Чутливість жесту двома пальцями по екрану</string>
|
||||
<string name="storage_custom">Вкажіть каталог</string>
|
||||
<string name="storage_commandline">Вкажіть параметри командного рядка</string>
|
||||
<string name="calibrate_touchscreen">Калібрування сенсорного екрану</string>
|
||||
<string name="calibrate_touchscreen_touch">Доторкнiться до всіх країв екрану, потiм натисніть Назад/BACK</string>
|
||||
<string name="screenkb_custom_layout">Налаштування положення кнопок</string>
|
||||
<string name="screenkb_custom_layout_help">Натисніть Назад/BACK для завершення. Проведiть по екрану, щоб змінити розмір кнопки</string>
|
||||
<string name="rightclick_key">Фізична кнопка</string>
|
||||
<string name="pointandclick_showcreenunderfinger2">Наекранна лупа</string>
|
||||
<string name="video">Налаштування відео</string>
|
||||
<string name="video_smooth">Лінійне сглажування відео</string>
|
||||
<string name="accel_veryslow">Дуже повільно</string>
|
||||
<string name="leftclick_timeout">Натискання з затримкою</string>
|
||||
<string name="leftclick_tap">Швидке натискання</string>
|
||||
<string name="leftclick_tap_or_timeout">Швидке натискання або з затримкою</string>
|
||||
<string name="leftclick_timeout_time">Час натискання</string>
|
||||
<string name="leftclick_timeout_time_0">0,3 сек</string>
|
||||
<string name="leftclick_timeout_time_1">0,5 сек</string>
|
||||
<string name="leftclick_timeout_time_2">0,7 секунд</string>
|
||||
<string name="leftclick_timeout_time_3">1 сек</string>
|
||||
<string name="leftclick_timeout_time_4">1,5 сек</string>
|
||||
<string name="pointandclick_relative">Відносний рух миші (режим ноутбука)</string>
|
||||
<string name="pointandclick_relative_speed">Швидкість руху миші</string>
|
||||
<string name="pointandclick_relative_accel">Прискорення руху миші</string>
|
||||
<string name="downloads">Завантаження</string>
|
||||
<string name="video_separatethread">Окремий потік для відео, збільшить FPS на деяких пристроях</string>
|
||||
<string name="text_edit_click_here">Натисніть, щоб ввести текст, натисніть Назад, коли закiнчете</string>
|
||||
<string name="display_size_mouse">Налаштування розміру дисплея</string>
|
||||
<string name="display_size">Виберіть розмір дисплея</string>
|
||||
<string name="display_size_large">Великий (таблетка)</string>
|
||||
<string name="display_size_small">Маленький</string>
|
||||
<string name="display_size_tiny">Крихiтний</string>
|
||||
<string name="show_more_options">Показати більше параметрів</string>
|
||||
<string name="controls_screenkb_drawsize">Розмір зображення кнопок</string>
|
||||
<string name="display_size_small_touchpad">Маленький, режим тачпаду</string>
|
||||
<string name="display_size_tiny_touchpad">Крихiтний, режим тачпаду</string>
|
||||
<string name="hardware_mouse_detected">Виявлена зовнiшня миша, емуляція миші вимкнена</string>
|
||||
|
||||
<string name="not_enough_ram">Недостатньо пам’яті</string>
|
||||
<string name="not_enough_ram_size">Потрібно %1$d Mb пам’яті, доступно лише %2$d Mb</string>
|
||||
<string name="ignore">Ігнорувати</string>
|
||||
<string name="calibrate_gyroscope">Калібрувати гіроскоп</string>
|
||||
<string name="calibrate_gyroscope_text">Покладіть телефон на рівну поверхню</string>
|
||||
<string name="reset_config">Скинути всі налаштування</string>
|
||||
<string name="cancel">Відмінити</string>
|
||||
<string name="calibrate_gyroscope_not_supported">Гіроскоп відсутній</string>
|
||||
<string name="reset_config_ask">Скинути всі налаштування у значення за замовчуванням?</string>
|
||||
<string name="cancel_download">Припинити завантаження?</string>
|
||||
<string name="cancel_download_resume">Завантаження може бути відновлено пізніше.</string>
|
||||
<string name="yes">Так</string>
|
||||
<string name="no">Ні</string>
|
||||
<string name="controls_screenkb_custom">Налаштування користувача</string>
|
||||
</resources>
|
||||
181
project/javaSDL2/translations/values/strings.xml
Normal file
181
project/javaSDL2/translations/values/strings.xml
Normal file
@@ -0,0 +1,181 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Commander Genius</string>
|
||||
|
||||
|
||||
<string name="init">Initializing</string>
|
||||
<string name="please_wait">Please wait while data is being downloaded</string>
|
||||
|
||||
<string name="device_config">Device configuration</string>
|
||||
<string name="device_change_cfg">Change device configuration</string>
|
||||
|
||||
<string name="download_unneeded">No need to download</string>
|
||||
<string name="connecting_to">Connecting to %s</string>
|
||||
<string name="failed_connecting_to">Failed connecting to %s</string>
|
||||
<string name="error_connecting_to">Error connecting to %s</string>
|
||||
<string name="dl_from">Downloading data from %s</string>
|
||||
<string name="error_dl_from">Error downloading data from %s</string>
|
||||
<string name="error_write">Error writing to %s</string>
|
||||
<string name="dl_progress">%1$.0f%% done: file %2$s</string>
|
||||
<string name="dl_finished">Finished</string>
|
||||
|
||||
<string name="storage_phone">Internal storage - %d MB free</string>
|
||||
<string name="storage_sd">SD card storage - %d MB free</string>
|
||||
<string name="storage_custom">Specify directory</string>
|
||||
<string name="storage_commandline">Specify command line parameters</string>
|
||||
<string name="storage_question">Data installation location</string>
|
||||
<string name="optional_downloads">Downloads</string>
|
||||
<string name="downloads">Downloads</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
|
||||
<string name="controls_arrows">Arrows / joystick / dpad</string>
|
||||
<string name="controls_trackball">Trackball</string>
|
||||
<string name="controls_accel">Accelerometer</string>
|
||||
<string name="controls_touch">Touchscreen only</string>
|
||||
<string name="controls_question">What kind of navigation keys does your device have?</string>
|
||||
|
||||
<string name="controls_additional">Additional controls</string>
|
||||
<string name="controls_screenkb">On-screen keyboard</string>
|
||||
<string name="controls_accelnav">Accelerometer</string>
|
||||
|
||||
<string name="controls_screenkb_size">On-screen keyboard size</string>
|
||||
<string name="controls_screenkb_drawsize">Size of button images</string>
|
||||
<string name="controls_screenkb_large">Large</string>
|
||||
<string name="controls_screenkb_medium">Medium</string>
|
||||
<string name="controls_screenkb_small">Small</string>
|
||||
<string name="controls_screenkb_tiny">Tiny</string>
|
||||
<string name="controls_screenkb_custom">Custom</string>
|
||||
<string name="controls_screenkb_theme">On-screen keyboard theme</string>
|
||||
<string name="controls_screenkb_by">%1$s by %2$s</string>
|
||||
<string name="controls_screenkb_transparency">On-screen keyboard transparency</string>
|
||||
<string name="controls_screenkb_trans_0">Invisible</string>
|
||||
<string name="controls_screenkb_trans_1">Almost invisible</string>
|
||||
<string name="controls_screenkb_trans_2">Transparent</string>
|
||||
<string name="controls_screenkb_trans_3">Semi-transparent</string>
|
||||
<string name="controls_screenkb_trans_4">Non-transparent</string>
|
||||
|
||||
<string name="trackball_no_dampening">No dampening</string>
|
||||
<string name="trackball_fast">Fast</string>
|
||||
<string name="trackball_medium">Medium</string>
|
||||
<string name="trackball_slow">Slow</string>
|
||||
<string name="trackball_question">Trackball dampening</string>
|
||||
|
||||
<string name="accel_veryfast">Very fast</string>
|
||||
<string name="accel_fast">Fast</string>
|
||||
<string name="accel_medium">Medium</string>
|
||||
<string name="accel_slow">Slow</string>
|
||||
<string name="accel_veryslow">Very slow</string>
|
||||
<string name="accel_question">Accelerometer sensitivity</string>
|
||||
|
||||
<string name="accel_floating">Floating</string>
|
||||
<string name="accel_fixed_start">Fixed when application starts</string>
|
||||
<string name="accel_fixed_horiz">Fixed to table desk orientation</string>
|
||||
<string name="accel_question_center">Accelerometer center position</string>
|
||||
|
||||
<string name="mouse_emulation">Mouse emulation</string>
|
||||
<string name="rightclick_question">Right mouse click</string>
|
||||
<string name="rightclick_menu">Menu key</string>
|
||||
<string name="rightclick_key">Physical key</string>
|
||||
<string name="rightclick_multitouch">Touch screen with second finger</string>
|
||||
<string name="rightclick_pressure">Touch screen with force</string>
|
||||
<string name="rightclick_none">Disable right mouse click</string>
|
||||
|
||||
<string name="leftclick_question">Left mouse click</string>
|
||||
<string name="leftclick_normal">Normal</string>
|
||||
<string name="leftclick_near_cursor">Touch near mouse cursor</string>
|
||||
<string name="leftclick_multitouch">Touch screen with second finger</string>
|
||||
<string name="leftclick_pressure">Touch screen with force</string>
|
||||
<string name="leftclick_dpadcenter">Trackball click / joystick center</string>
|
||||
<string name="leftclick_timeout">Hold at the same spot</string>
|
||||
<string name="leftclick_tap">Tap</string>
|
||||
<string name="leftclick_tap_or_timeout">Tap or hold</string>
|
||||
<string name="leftclick_timeout_time">Holding timeout</string>
|
||||
<string name="leftclick_timeout_time_0">0.3 sec</string>
|
||||
<string name="leftclick_timeout_time_1">0.5 sec</string>
|
||||
<string name="leftclick_timeout_time_2">0.7 sec</string>
|
||||
<string name="leftclick_timeout_time_3">1 sec</string>
|
||||
<string name="leftclick_timeout_time_4">1.5 sec</string>
|
||||
<string name="click_with_dpadcenter">Left mouse click with trackball / joystick center</string>
|
||||
|
||||
<string name="pointandclick_question">Advanced features</string>
|
||||
<string name="pointandclick_keepaspectratio">Keep 4:3 screen aspect ratio</string>
|
||||
<string name="pointandclick_showcreenunderfinger">Show screen under finger in separate window</string>
|
||||
<string name="pointandclick_showcreenunderfinger2">On-screen magnifying glass</string>
|
||||
<string name="pointandclick_joystickmouse">Move mouse with joystick or trackball</string>
|
||||
<string name="pointandclick_joystickmousespeed">Move mouse with joystick speed</string>
|
||||
<string name="pointandclick_joystickmouseaccel">Move mouse with joystick acceleration</string>
|
||||
<string name="pointandclick_relative">Relative mouse movement (laptop mode)</string>
|
||||
<string name="pointandclick_relative_speed">Relative mouse movement speed</string>
|
||||
<string name="pointandclick_relative_accel">Relative mouse movement acceleration</string>
|
||||
|
||||
<string name="none">None</string>
|
||||
|
||||
<string name="measurepressure">Calibrate touchscreen pressure</string>
|
||||
<string name="measurepressure_touchplease">Please slide finger across the screen for two seconds</string>
|
||||
<string name="measurepressure_response">Pressure %1$03d radius %2$03d</string>
|
||||
|
||||
<string name="audiobuf_verysmall">Very small (fast devices, less lag)</string>
|
||||
<string name="audiobuf_small">Small</string>
|
||||
<string name="audiobuf_medium">Medium</string>
|
||||
<string name="audiobuf_large">Large (older devices, if sound is choppy)</string>
|
||||
<string name="audiobuf_question">Size of audio buffer</string>
|
||||
|
||||
<string name="remap_hwkeys">Remap physical keys</string>
|
||||
<string name="remap_hwkeys_press">Press any key except HOME and POWER, you may use volume keys</string>
|
||||
<string name="remap_hwkeys_select">Select SDL keycode</string>
|
||||
<string name="remap_hwkeys_select_simple">Select action</string>
|
||||
<string name="remap_hwkeys_select_more_keys">Show all keycodes</string>
|
||||
|
||||
<string name="remap_screenkb">Remap on-screen controls</string>
|
||||
<string name="remap_screenkb_joystick">Joystick</string>
|
||||
<string name="remap_screenkb_button">Button</string>
|
||||
<string name="remap_screenkb_button_text">Text input button</string>
|
||||
<string name="remap_screenkb_button_gestures">Two-finger screen gestures</string>
|
||||
<string name="remap_screenkb_button_gestures_sensitivity">Two-finger screen gestures sensitivity</string>
|
||||
<string name="remap_screenkb_button_zoomin">Zoom in two-finger gesture</string>
|
||||
<string name="remap_screenkb_button_zoomout">Zoom out two-finger gesture</string>
|
||||
<string name="remap_screenkb_button_rotateleft">Rotate left two-finger gesture</string>
|
||||
<string name="remap_screenkb_button_rotateright">Rotate right two-finger gesture</string>
|
||||
|
||||
<string name="screenkb_custom_layout">Customize on-screen keyboard layout</string>
|
||||
<string name="screenkb_custom_layout_help">Press BACK when done. Resize buttons by sliding on empty space.</string>
|
||||
|
||||
<string name="calibrate_touchscreen">Calibrate touchscreen</string>
|
||||
<string name="calibrate_touchscreen_touch">Touch all edges of the screen, press BACK when done</string>
|
||||
|
||||
<string name="video">Video settings</string>
|
||||
<string name="video_smooth">Linear video filtering</string>
|
||||
<string name="video_separatethread">Separate thread for video, will increase FPS on some devices</string>
|
||||
|
||||
<string name="text_edit_click_here">Tap to start typing, press Back when done</string>
|
||||
|
||||
<string name="display_size_mouse">Mouse emulation mode</string>
|
||||
<string name="display_size">Display size for mouse emulation</string>
|
||||
<string name="display_size_large">Large (tablets)</string>
|
||||
<string name="display_size_small">Small, magnifying glass</string>
|
||||
<string name="display_size_small_touchpad">Small, touchpad mode</string>
|
||||
<string name="display_size_tiny">Tiny</string>
|
||||
<string name="display_size_tiny_touchpad">Tiny, touchpad mode</string>
|
||||
|
||||
<string name="show_more_options">Show more options</string>
|
||||
|
||||
<string name="hardware_mouse_detected">Hardware mouse detected, disabling mouse emulation</string>
|
||||
|
||||
<string name="not_enough_ram">Not enough RAM</string>
|
||||
<string name="not_enough_ram_size">This app needs %1$d Mb RAM, your device has %2$d Mb</string>
|
||||
<string name="ignore">Ignore</string>
|
||||
|
||||
<string name="calibrate_gyroscope">Calibrate gyroscope</string>
|
||||
<string name="calibrate_gyroscope_text">Put your device on a flat surface</string>
|
||||
<string name="calibrate_gyroscope_not_supported">Your device does not have gyroscope</string>
|
||||
|
||||
<string name="reset_config">Reset config to defaults</string>
|
||||
<string name="reset_config_ask">Reset all options to default values?</string>
|
||||
|
||||
<string name="cancel_download">Cancel data downloading?</string>
|
||||
<string name="cancel_download_resume">You can resume it later, the data will not be downloaded twice.</string>
|
||||
<string name="yes">Yes</string>
|
||||
<string name="no">No</string>
|
||||
|
||||
</resources>
|
||||
@@ -4,19 +4,12 @@ ifneq ($(strip $(filter mad, $(COMPILED_LIBRARIES))),)
|
||||
SDL_MIXER_USE_LIBMAD := 1
|
||||
endif
|
||||
|
||||
# Disable timidity library inside sdl2_mixer, we have our own version of timidity used by OpenTTD
|
||||
SUPPORT_MID_TIMIDITY := 0
|
||||
|
||||
NDK_VERSION := $(strip $(patsubst android-ndk-%,%,$(filter android-ndk-%, $(subst /, ,$(dir $(TARGET_CC))))))
|
||||
#$(info NDK version $(NDK_VERSION)) # This warning puzzles ndk-gdb
|
||||
ifneq ($(filter r1 r2 r3 r4 r5 r6 r7 r8,$(NDK_VERSION)),)
|
||||
$(error Your NDK $(NDK_VERSION) is too old, please download NDK from http://developer.android.com)
|
||||
endif
|
||||
|
||||
ifdef ANDROID_NDK_HOME
|
||||
NDK_PATH := $(ANDROID_NDK_HOME)
|
||||
else
|
||||
NDK_PATH := $(shell dirname $(shell which ndk-build))
|
||||
endif
|
||||
|
||||
include $(call all-subdir-makefiles)
|
||||
|
||||
@@ -1,17 +1,44 @@
|
||||
# Makefile to build precompiled libraries, which cannot be built using standard NDK makefiles
|
||||
# TODO: libffmpeg, libpython (used only in GemRB)
|
||||
# TODO: libboost, libffmpeg, libpython (used only in GemRB)
|
||||
|
||||
ARCH_LIST ?= arm64-v8a x86_64 armeabi-v7a x86
|
||||
ifeq ($(strip $(ARCH_LIST)),all)
|
||||
ARCH_LIST := arm64-v8a x86_64 armeabi-v7a x86
|
||||
endif
|
||||
ARCHES32 := armeabi-v7a x86
|
||||
ARCHES64 := arm64-v8a x86_64
|
||||
|
||||
ICONV := $(foreach ARCH, $(ARCH_LIST), iconv/lib/$(ARCH)/libiconv.so iconv/lib/$(ARCH)/libcharset.so)
|
||||
ICONV := $(foreach ARCH, $(ARCHES32) $(ARCHES64), iconv/lib/$(ARCH)/libiconv.so iconv/lib/$(ARCH)/libcharset.so)
|
||||
|
||||
ICU_LIBS := icudata icui18n icuio icutest icutu icuuc iculx icu-le-hb
|
||||
ICU := $(foreach ARCH, $(ARCH_LIST), $(foreach NAME, $(ICU_LIBS), icuuc/lib/$(ARCH)/lib$(NAME).a))
|
||||
ICU_LIBS := icudata icui18n icuio icutest icutu icuuc iculx icu-le-hb harfbuzz
|
||||
ICU := $(foreach ARCH, $(ARCHES32) $(ARCHES64), $(foreach NAME, $(ICU_LIBS), icuuc/lib/$(ARCH)/lib$(NAME).a))
|
||||
|
||||
OPENSSL := $(foreach ARCH, $(ARCH_LIST), openssl/lib/$(ARCH)/libcrypto.so.sdl.1.so openssl/lib/$(ARCH)/libssl.so.sdl.1.so)
|
||||
OPENSSL := $(foreach ARCH, $(ARCHES32) $(ARCHES64), openssl/lib-$(ARCH)/libcrypto.so.sdl.1.so openssl/lib-$(ARCH)/libssl.so.sdl.1.so)
|
||||
|
||||
LIBS := $(ICONV) $(ICU) $(OPENSSL)
|
||||
|
||||
.PHONY: all boost openssl icu
|
||||
all: $(LIBS)
|
||||
|
||||
openssl: $(OPENSSL)
|
||||
|
||||
icu: $(ICONV) $(ICU)
|
||||
|
||||
#.NOTPARALLEL: $(LIBS) $(BOOST)
|
||||
|
||||
$(ICONV) $(ICU): iconv/src/build.sh
|
||||
cd iconv/src && \
|
||||
./build.sh && \
|
||||
for ARCH in $(ARCHES32) $(ARCHES64); do \
|
||||
mkdir -p ../lib/$$ARCH ../include ; \
|
||||
cp -f $$ARCH/libiconv.so $$ARCH/libcharset.so ../lib/$$ARCH/ ; \
|
||||
cp -f $$ARCH/include/*.h ../include/ ; \
|
||||
mkdir -p ../../icuuc/lib/$$ARCH ../../icuuc/include/unicode ../../icuuc/include/layout ; \
|
||||
cp -f $$ARCH/libicu*.a $$ARCH/libharfbuzz.a ../../icuuc/lib/$$ARCH/ ; \
|
||||
cp -f $$ARCH/include/unicode/*.h ../../icuuc/include/unicode/ ; \
|
||||
cp -f $$ARCH/include/layout/*.h ../../icuuc/include/layout/ ; \
|
||||
cp -f $$ARCH/include/icu-le-hb/layout/*.h ../../icuuc/include/layout/ ; \
|
||||
done && \
|
||||
git clean -f -d -x
|
||||
|
||||
$(OPENSSL): openssl/compile.sh
|
||||
cd openssl && ./compile.sh
|
||||
|
||||
BOOST_LIBS := \
|
||||
atomic \
|
||||
@@ -22,10 +49,10 @@ BOOST_LIBS := \
|
||||
coroutine \
|
||||
date_time \
|
||||
exception \
|
||||
fiber \
|
||||
filesystem \
|
||||
graph \
|
||||
iostreams \
|
||||
json \
|
||||
locale \
|
||||
log \
|
||||
log_setup \
|
||||
@@ -35,12 +62,13 @@ BOOST_LIBS := \
|
||||
math_tr1 \
|
||||
math_tr1f \
|
||||
math_tr1l \
|
||||
nowide \
|
||||
prg_exec_monitor \
|
||||
program_options \
|
||||
random \
|
||||
regex \
|
||||
serialization \
|
||||
stacktrace_basic \
|
||||
stacktrace_noop \
|
||||
system \
|
||||
test_exec_monitor \
|
||||
thread \
|
||||
@@ -51,69 +79,22 @@ BOOST_LIBS := \
|
||||
wserialization \
|
||||
|
||||
|
||||
BOOST := $(foreach ARCH, $(ARCH_LIST), $(foreach NAME, $(strip $(BOOST_LIBS)), boost/lib/$(ARCH)/libboost_$(NAME).a))
|
||||
|
||||
.PHONY: all boost icu openssl
|
||||
|
||||
all: $(ICONV) $(ICU) $(OPENSSL) $(BOOST)
|
||||
|
||||
boost: $(BOOST) $(foreach NAME, $(strip $(BOOST_LIBS)), boost_$(NAME))
|
||||
|
||||
icu: $(ICONV) $(ICU)
|
||||
|
||||
openssl: $(OPENSSL)
|
||||
|
||||
$(ICONV) $(ICU): iconv/src/build.sh
|
||||
cd iconv/src && \
|
||||
for ARCH in $(ARCH_LIST); do \
|
||||
$(shell echo "#=Compiling iconv for $$ARCH") \
|
||||
env ARCHS=$$ARCH PATH=$(PATH):${ANDROID_NDK_HOME} ./build.sh && \
|
||||
mkdir -p ../lib/$$ARCH ../include ; \
|
||||
cp -f $$ARCH/libiconv.so $$ARCH/libcharset.so ../lib/$$ARCH/ ; \
|
||||
cp -f $$ARCH/include/*.h ../include/ ; \
|
||||
mkdir -p ../../icuuc/lib/$$ARCH ../../icuuc/include/unicode ../../icuuc/include/layout ; \
|
||||
cp -f $$ARCH/libicu*.a ../../icuuc/lib/$$ARCH/ ; \
|
||||
cp -f $$ARCH/include/unicode/*.h ../../icuuc/include/unicode/ ; \
|
||||
cp -f $$ARCH/include/layout/*.h ../../icuuc/include/layout/ ; \
|
||||
cp -f $$ARCH/include/icu-le-hb/layout/*.h ../../icuuc/include/layout/ ; \
|
||||
done
|
||||
|
||||
$(OPENSSL): openssl/compile.sh
|
||||
cd openssl && env ARCH_LIST="$(ARCH_LIST)" ./compile.sh
|
||||
BOOST := $(foreach ARCH, $(ARCHES32) $(ARCHES64), $(foreach NAME, $(BOOST_LIBS), boost/lib/$(ARCH)/libboost_$(NAME).a))
|
||||
|
||||
$(BOOST): boost/src/build-android.sh
|
||||
rm -rf boost/include boost/lib ; \
|
||||
cd boost/src && \
|
||||
./build-android.sh --boost=1.78.0 --with-iconv --target-version=16 --arch=$(shell echo $(foreach ARCH, $(ARCH_LIST),$(ARCH),) | tr -d ' ') && \
|
||||
for ARCH in $(ARCH_LIST); do \
|
||||
./build-android.sh --boost=1.69.0 --with-iconv --arch=$(shell echo $(foreach ARCH, $(ARCHES32) $(ARCHES64),$(ARCH),) | tr -d ' ') && \
|
||||
for ARCH in $(ARCHES32) $(ARCHES64); do \
|
||||
mkdir -p ../lib/$$ARCH ../include ; \
|
||||
$(foreach NAME, $(strip $(BOOST_LIBS)), cp -f build/out/$$ARCH/lib/libboost_$(NAME)-clang-mt-*.a ../lib/$$ARCH/libboost_$(NAME).a || exit 1 ;) \
|
||||
$(foreach NAME, $(BOOST_LIBS), cp -f build/out/$$ARCH/lib/libboost_$(NAME)-clang-mt-*.a ../lib/$$ARCH/libboost_$(NAME).a || exit 1 ;) \
|
||||
cp -r -f build/out/$$ARCH/include/boost-*/* ../include/ || exit 1 ; \
|
||||
done || exit 1
|
||||
done || exit 1 ; \
|
||||
git clean -f -d -x ; \
|
||||
$(foreach NAME, $(BOOST_LIBS), ln -sf boost ../../boost_$(NAME) ;)
|
||||
|
||||
$(foreach NAME, $(strip $(BOOST_LIBS)), boost_$(NAME)):
|
||||
ln -sf boost $@
|
||||
boost: $(BOOST)
|
||||
|
||||
iconv/src/build.sh boost/src/build-android.sh:
|
||||
git submodule update --init --recursive
|
||||
|
||||
# Dependencies for CustomBuildScript.mk
|
||||
|
||||
define COPY_TO_OBJ =
|
||||
|
||||
ARCH := $(1)
|
||||
SRCDIR := $(2)
|
||||
FILENAME := $(3)
|
||||
|
||||
../obj/local/$$(ARCH)/$$(FILENAME) $$(abspath ../obj/local/$$(ARCH)/$$(FILENAME)): $$(SRCDIR)/$$(FILENAME)
|
||||
cp -f $$< $$@
|
||||
|
||||
#$$(warning === ARCH = $(1) SRCDIR = $(2) FILENAME = $(3) ../obj/local/$$(ARCH)/$$(FILENAME) $$(abspath ../obj/local/$$(ARCH)/$$(FILENAME)): $$(SRCDIR)/$$(FILENAME))
|
||||
|
||||
endef # COPY_TO_OBJ
|
||||
|
||||
$(foreach ARCH, $(ARCH_LIST), $(foreach NAME, libiconv.so libcharset.so, $(eval $(call COPY_TO_OBJ,$(ARCH),iconv/lib/$(ARCH),$(NAME)))))
|
||||
|
||||
$(foreach ARCH, $(ARCH_LIST), $(foreach NAME, $(ICU_LIBS), $(eval $(call COPY_TO_OBJ,$(ARCH),icuuc/lib/$(ARCH),lib$(NAME).a))))
|
||||
|
||||
$(foreach ARCH, $(ARCH_LIST), $(foreach NAME, libcrypto.so.sdl.1.so libssl.so.sdl.1.so, $(eval $(call COPY_TO_OBJ,$(ARCH),openssl/lib/$(ARCH),$(NAME)))))
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../sdl2/include
|
||||
@@ -1 +0,0 @@
|
||||
../sdl2_image
|
||||
@@ -1 +0,0 @@
|
||||
../sdl2_mixer/include
|
||||
@@ -1 +0,0 @@
|
||||
../sdl2_ttf
|
||||
@@ -1,24 +1,18 @@
|
||||
|
||||
SDL_VERSION := 1.2
|
||||
|
||||
# To filter out static libs from all libs in makefile
|
||||
APP_AVAILABLE_STATIC_LIBS := jpeg png webp freetype fontconfig xerces ogg vorbis tremor flac \
|
||||
boost_atomic boost_chrono boost_container boost_context boost_contract boost_coroutine boost_date_time boost_exception boost_filesystem \
|
||||
boost_graph boost_iostreams boost_json boost_locale boost_log boost_log_setup boost_math_c99 boost_math_c99f boost_math_c99l boost_math_tr1 \
|
||||
boost_math_tr1f boost_math_tr1l boost_nowide boost_prg_exec_monitor boost_program_options boost_random boost_regex boost_serialization \
|
||||
APP_AVAILABLE_STATIC_LIBS := jpeg png freetype fontconfig xerces ogg vorbis flac \
|
||||
boost_atomic boost_chrono boost_container boost_context boost_coroutine boost_date_time boost_exception boost_filesystem \
|
||||
boost_graph boost_iostreams boost_locale boost_log boost_log_setup boost_prg_exec_monitor boost_program_options boost_random \
|
||||
boost_regex boost_serialization boost_signals boost_stacktrace_basic boost_stacktrace_noop \
|
||||
boost_system boost_test_exec_monitor boost_thread boost_timer boost_type_erasure boost_unit_test_framework boost_wave boost_wserialization \
|
||||
glu icudata icutest icui18n icuio icule iculx icutu icuuc icu-le-hb harfbuzz sdl_savepng android_support \
|
||||
gl4es nanogl gd guichan glm
|
||||
gl4es nanogl gd guichan
|
||||
|
||||
# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2
|
||||
APP_MODULES := application sdl-1.2 sdl_native_helpers jpeg png ogg flac vorbis freetype tremor ogg
|
||||
|
||||
ifeq ($(CUSTOM_BUILD_SCRIPT_FIRST_PASS),)
|
||||
APP_MODULES += application $(if $(filter 1.2, $(SDL_VERSION)), sdl_main)
|
||||
endif
|
||||
APP_MODULES := application sdl-1.2 sdl_main sdl_native_helpers jpeg png ogg flac vorbis freetype tremor ogg
|
||||
|
||||
ifeq ($(APP_ABI),)
|
||||
APP_ABI := arm64-v8a armeabi-v7a x86 x86_64
|
||||
APP_ABI := armeabi-v7a
|
||||
endif
|
||||
|
||||
# The namespace in Java file, with dots replaced with underscores
|
||||
@@ -64,6 +58,8 @@ USE_GL4ES :=
|
||||
|
||||
SDL_ADDITIONAL_CFLAGS := -DSDL_ANDROID_KEYCODE_MOUSE=UNKNOWN -DSDL_ANDROID_KEYCODE_0=LCTRL -DSDL_ANDROID_KEYCODE_1=LALT -DSDL_ANDROID_KEYCODE_2=SPACE -DSDL_ANDROID_KEYCODE_3=RETURN -DSDL_ANDROID_KEYCODE_4=RETURN
|
||||
|
||||
SDL_VERSION := 1.2
|
||||
|
||||
NDK_TOOLCHAIN_VERSION := clang
|
||||
|
||||
APP_PLATFORM := android-16
|
||||
|
||||
@@ -3,21 +3,8 @@ LOCAL_PATH := $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := application
|
||||
|
||||
APPDIR := $(shell readlink $(LOCAL_PATH)/src)
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := $(if $(filter 1.2, $(SDL_VERSION)), sdl-1.2, SDL2) $(filter-out $(APP_AVAILABLE_STATIC_LIBS), $(COMPILED_LIBRARIES))
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := $(filter $(APP_AVAILABLE_STATIC_LIBS), $(COMPILED_LIBRARIES))
|
||||
|
||||
LOCAL_LDLIBS := $(APPLICATION_GLES_LIBRARY) -ldl -llog -lz
|
||||
|
||||
LOCAL_LDFLAGS := -Lobj/local/$(TARGET_ARCH_ABI)
|
||||
|
||||
LOCAL_LDFLAGS += $(APPLICATION_ADDITIONAL_LDFLAGS)
|
||||
|
||||
ifeq ($(APPLICATION_CUSTOM_BUILD_SCRIPT),)
|
||||
|
||||
APP_SUBDIRS := $(patsubst $(LOCAL_PATH)/%, %, $(shell find $(LOCAL_PATH)/$(APPDIR) -path '*/.svn' -prune -o -type d -print))
|
||||
ifneq ($(APPLICATION_SUBDIRS_BUILD),)
|
||||
APPLICATION_SUBDIRS_BUILD_NONRECURSIVE := $(addprefix $(APPDIR)/, $(filter-out %/*, $(APPLICATION_SUBDIRS_BUILD)))
|
||||
@@ -27,10 +14,9 @@ APPLICATION_SUBDIRS_BUILD_RECURSIVE := $(patsubst $(LOCAL_PATH)/%, %, $(APPLICAT
|
||||
APP_SUBDIRS := $(APPLICATION_SUBDIRS_BUILD_NONRECURSIVE) $(APPLICATION_SUBDIRS_BUILD_RECURSIVE)
|
||||
endif
|
||||
|
||||
LOCAL_SRC_FILES := $(filter %.c %.cpp %.cc, $(APP_SUBDIRS))
|
||||
APP_SUBDIRS := $(filter-out %.c %.cpp %.cc, $(APP_SUBDIRS))
|
||||
LOCAL_SRC_FILES := $(filter %.c %.cpp, $(APP_SUBDIRS))
|
||||
APP_SUBDIRS := $(filter-out %.c %.cpp, $(APP_SUBDIRS))
|
||||
LOCAL_SRC_FILES += $(foreach F, $(APP_SUBDIRS), $(addprefix $(F)/,$(notdir $(wildcard $(LOCAL_PATH)/$(F)/*.cpp))))
|
||||
LOCAL_SRC_FILES += $(foreach F, $(APP_SUBDIRS), $(addprefix $(F)/,$(notdir $(wildcard $(LOCAL_PATH)/$(F)/*.cc))))
|
||||
LOCAL_SRC_FILES += $(foreach F, $(APP_SUBDIRS), $(addprefix $(F)/,$(notdir $(wildcard $(LOCAL_PATH)/$(F)/*.c))))
|
||||
LOCAL_SRC_FILES := $(filter-out $(addprefix $(APPDIR)/, $(APPLICATION_BUILD_EXCLUDE)), $(LOCAL_SRC_FILES))
|
||||
|
||||
@@ -46,7 +32,7 @@ LOCAL_CFLAGS += $(foreach D, $(LOCAL_C_INCLUDES), -iquote$(D))
|
||||
LOCAL_C_INCLUDES :=
|
||||
endif
|
||||
|
||||
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../$(strip $(if $(filter 1.2, $(SDL_VERSION)), sdl-1.2, SDL2))/include
|
||||
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../sdl-$(SDL_VERSION)/include
|
||||
LOCAL_C_INCLUDES += $(foreach L, $(COMPILED_LIBRARIES), $(LOCAL_PATH)/../$(L)/include)
|
||||
|
||||
LOCAL_CFLAGS += $(APPLICATION_ADDITIONAL_CFLAGS)
|
||||
@@ -55,13 +41,73 @@ LOCAL_CPPFLAGS += $(APPLICATION_ADDITIONAL_CPPFLAGS)
|
||||
# Change C++ file extension as appropriate
|
||||
LOCAL_CPP_EXTENSION := .cpp .cxx .cc
|
||||
|
||||
ifneq ($(APPLICATION_CUSTOM_BUILD_SCRIPT),)
|
||||
LOCAL_SRC_FILES := dummy.c
|
||||
endif
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := sdl-$(SDL_VERSION) $(filter-out $(APP_AVAILABLE_STATIC_LIBS), $(COMPILED_LIBRARIES))
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := $(filter $(APP_AVAILABLE_STATIC_LIBS), $(COMPILED_LIBRARIES))
|
||||
|
||||
LOCAL_LDLIBS := $(APPLICATION_GLES_LIBRARY) -ldl -llog -lz
|
||||
|
||||
LOCAL_LDFLAGS := -Lobj/local/$(TARGET_ARCH_ABI)
|
||||
|
||||
LOCAL_LDFLAGS += $(APPLICATION_ADDITIONAL_LDFLAGS)
|
||||
|
||||
LOCAL_CPP_EXTENSION := .cpp .cxx .cc
|
||||
|
||||
SDL_APP_LIB_DEPENDS-$(TARGET_ARCH_ABI) := $(LOCAL_PATH)/src/AndroidBuild.sh $(LOCAL_PATH)/src/AndroidAppSettings.cfg
|
||||
SDL_APP_LIB_DEPENDS-$(TARGET_ARCH_ABI) += $(foreach LIB, $(LOCAL_SHARED_LIBRARIES), obj/local/$(TARGET_ARCH_ABI)/lib$(LIB).so)
|
||||
SDL_APP_LIB_DEPENDS-$(TARGET_ARCH_ABI) += $(foreach LIB, $(LOCAL_STATIC_LIBRARIES), obj/local/$(TARGET_ARCH_ABI)/lib$(LIB).a)
|
||||
|
||||
.PHONY: obj/local/$(TARGET_ARCH_ABI)/libcrypto.so obj/local/$(TARGET_ARCH_ABI)/libssl.so obj/local/$(TARGET_ARCH_ABI)/libcurl.so
|
||||
obj/local/$(TARGET_ARCH_ABI)/libcrypto.so: obj/local/$(TARGET_ARCH_ABI)/libcrypto.so.sdl.0.so
|
||||
obj/local/$(TARGET_ARCH_ABI)/libssl.so: obj/local/$(TARGET_ARCH_ABI)/libssl.so.sdl.0.so
|
||||
obj/local/$(TARGET_ARCH_ABI)/libcurl.so: obj/local/$(TARGET_ARCH_ABI)/libcurl-sdl.so
|
||||
obj/local/$(TARGET_ARCH_ABI)/libexpat.so: obj/local/$(TARGET_ARCH_ABI)/libexpat-sdl.so
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
else ifeq ($(CUSTOM_BUILD_SCRIPT_FIRST_PASS),) # APPLICATION_CUSTOM_BUILD_SCRIPT and not CUSTOM_BUILD_SCRIPT_FIRST_PASS
|
||||
ifneq ($(APPLICATION_CUSTOM_BUILD_SCRIPT),)
|
||||
|
||||
LOCAL_SRC_FILES := $(APPDIR)/libapplication-$(TARGET_ARCH_ABI).so
|
||||
LOCAL_MODULE_FILENAME := libapplication
|
||||
# TODO: here we're digging inside NDK internal build system, that's not portable
|
||||
# NDK r5b provided the $(PREBUILT_SHARED_LIBRARY) target, however it requires .so file to be already present on disk
|
||||
# Also I cannot just launch AndroidBuild.sh from makefile because other libraries are not rebuilt and linking will fail
|
||||
.PHONY: OVERRIDE_CUSTOM_LIB
|
||||
OVERRIDE_CUSTOM_LIB:
|
||||
# Prevent ./AndroidBuild.sh to be invoked in parallel for different architectures, it may do things like downloading files which work poorly when launched in parallel
|
||||
# .NOTPARALLEL prevents other sources from building in parallel, so we're using flock shell command here
|
||||
# There is flock command on Linux, but it fails to lock a file, and mkdir is more portable
|
||||
PARALLEL_LOCK := until mkdir .lock >/dev/null 2>&1; do sleep 1; done
|
||||
PARALLEL_UNLOCK := rmdir .lock >/dev/null 2>&1
|
||||
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
LOCAL_PATH_SDL_APPLICATION := $(LOCAL_PATH)
|
||||
|
||||
endif
|
||||
$(shell cd $(LOCAL_PATH_SDL_APPLICATION)/src && $(PARALLEL_UNLOCK))
|
||||
|
||||
obj/local/armeabi-v7a/libapplication.so: $(LOCAL_PATH)/src/libapplication-armeabi-v7a.so
|
||||
|
||||
$(LOCAL_PATH)/src/libapplication-armeabi-v7a.so: $(SDL_APP_LIB_DEPENDS-armeabi-v7a) OVERRIDE_CUSTOM_LIB
|
||||
cd $(LOCAL_PATH_SDL_APPLICATION)/src && $(PARALLEL_LOCK) && \
|
||||
./AndroidBuild.sh armeabi-v7a arm-linux-androideabi && $(PARALLEL_UNLOCK)
|
||||
|
||||
obj/local/x86/libapplication.so: $(LOCAL_PATH)/src/libapplication-x86.so
|
||||
|
||||
$(LOCAL_PATH)/src/libapplication-x86.so: $(SDL_APP_LIB_DEPENDS-x86) OVERRIDE_CUSTOM_LIB
|
||||
cd $(LOCAL_PATH_SDL_APPLICATION)/src && $(PARALLEL_LOCK) && \
|
||||
./AndroidBuild.sh x86 i686-linux-android && $(PARALLEL_UNLOCK)
|
||||
|
||||
obj/local/arm64-v8a/libapplication.so: $(LOCAL_PATH)/src/libapplication-arm64-v8a.so
|
||||
|
||||
$(LOCAL_PATH)/src/libapplication-arm64-v8a.so: $(SDL_APP_LIB_DEPENDS-arm64-v8a) OVERRIDE_CUSTOM_LIB
|
||||
cd $(LOCAL_PATH_SDL_APPLICATION)/src && $(PARALLEL_LOCK) && \
|
||||
./AndroidBuild.sh arm64-v8a aarch64-linux-android && $(PARALLEL_UNLOCK)
|
||||
|
||||
obj/local/x86_64/libapplication.so: $(LOCAL_PATH)/src/libapplication-x86_64.so
|
||||
|
||||
$(LOCAL_PATH)/src/libapplication-x86_64.so: $(SDL_APP_LIB_DEPENDS-x86_64) OVERRIDE_CUSTOM_LIB
|
||||
cd $(LOCAL_PATH_SDL_APPLICATION)/src && $(PARALLEL_LOCK) && \
|
||||
./AndroidBuild.sh x86_64 x86_64-linux-android && $(PARALLEL_UNLOCK)
|
||||
|
||||
endif # $(APPLICATION_CUSTOM_BUILD_SCRIPT)
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
include ../Settings.mk
|
||||
|
||||
APPDIR := $(shell readlink src)
|
||||
|
||||
all: $(foreach ARCH, $(APP_ABI), $(APPDIR)/libapplication-$(ARCH).so)
|
||||
|
||||
.PHONY: all $(foreach ARCH, $(APP_ABI), $(APPDIR)/libapplication-$(ARCH).so)
|
||||
|
||||
TARGET_GCC_PREFIX_armeabi-v7a := arm-linux-androideabi
|
||||
TARGET_GCC_PREFIX_x86 := i686-linux-android
|
||||
TARGET_GCC_PREFIX_arm64-v8a := aarch64-linux-android
|
||||
TARGET_GCC_PREFIX_x86_64 := x86_64-linux-android
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := $(filter $(APP_AVAILABLE_STATIC_LIBS), $(COMPILED_LIBRARIES))
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := sdl-$(SDL_VERSION) $(filter-out $(APP_AVAILABLE_STATIC_LIBS), $(COMPILED_LIBRARIES))
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := $(patsubst crypto, crypto.so.sdl.1, $(LOCAL_SHARED_LIBRARIES))
|
||||
LOCAL_SHARED_LIBRARIES := $(patsubst ssl, ssl.so.sdl.1, $(LOCAL_SHARED_LIBRARIES))
|
||||
LOCAL_SHARED_LIBRARIES := $(patsubst curl, curl-sdl, $(LOCAL_SHARED_LIBRARIES))
|
||||
LOCAL_SHARED_LIBRARIES := $(patsubst expat, expat-sdl, $(LOCAL_SHARED_LIBRARIES))
|
||||
|
||||
define DEPENDS_FOR_ARCH =
|
||||
|
||||
../../obj/local/$(1)/$(2):
|
||||
make -C .. -f Makefile.prebuilt $$(abspath $$@)
|
||||
|
||||
SDL_APP_LIB_DEPENDS_$(1) += ../../obj/local/$(1)/$(2)
|
||||
|
||||
#$$(warning === ../../obj/local/$(1)/$(2):)
|
||||
|
||||
endef
|
||||
|
||||
$(foreach ARCH, $(APP_ABI), $(foreach LIB, $(LOCAL_SHARED_LIBRARIES), $(eval $(call DEPENDS_FOR_ARCH,$(ARCH),lib$(LIB).so))))
|
||||
|
||||
$(foreach ARCH, $(APP_ABI), $(foreach LIB, $(LOCAL_STATIC_LIBRARIES), $(eval $(call DEPENDS_FOR_ARCH,$(ARCH),lib$(LIB).a))))
|
||||
|
||||
define BUILD_FOR_ARCH =
|
||||
|
||||
SDL_APP_LIB_DEPENDS_$(1) += $$(APPDIR)/AndroidBuild.sh $$(APPDIR)/AndroidAppSettings.cfg
|
||||
|
||||
$$(APPDIR)/libapplication-$(1).so: $$(SDL_APP_LIB_DEPENDS_$(1))
|
||||
cd $$(APPDIR) && ./AndroidBuild.sh $(1) $$(TARGET_GCC_PREFIX_$(1))
|
||||
@objdump -p $$@ | grep 'SONAME' && { \
|
||||
objdump -p $$@ | grep 'SONAME *libapplication.so' || { \
|
||||
rm $$@ ; echo 'Error: $$@ must have SONAME set to "libapplication.so", add option -Wl,-soname=libapplication.so to your linker flags' ; \
|
||||
} ; \
|
||||
}
|
||||
|
||||
#$$(warning ====== $$(APPDIR)/libapplication-$(1).so: ==> $$(SDL_APP_LIB_DEPENDS_$(1)))
|
||||
|
||||
endef
|
||||
|
||||
$(foreach ARCH, $(APP_ABI), $(eval $(call BUILD_FOR_ARCH,$(ARCH))))
|
||||
1
project/jni/application/NewRAW
Submodule
1
project/jni/application/NewRAW
Submodule
Submodule project/jni/application/NewRAW added at 65b7361c8e
34
project/jni/application/REminiscence/AndroidAppSettings.cfg
Normal file
34
project/jni/application/REminiscence/AndroidAppSettings.cfg
Normal file
@@ -0,0 +1,34 @@
|
||||
# The application settings for Android libSDL port
|
||||
AppSettingVersion=16
|
||||
LibSdlVersion=1.2
|
||||
AppName="REminiscence"
|
||||
AppFullName=fr.freecyxdown.sdl
|
||||
ScreenOrientation=h
|
||||
InhibitSuspend=n
|
||||
AppDataDownloadUrl="Data files size is 1 Mb|http://anddev.at.ua/data/reminiscence-data.zip?attredirects=0&d=1"
|
||||
SdlVideoResize=y
|
||||
SdlVideoResizeKeepAspect=n
|
||||
NeedDepthBuffer=n
|
||||
AppUsesMouse=n
|
||||
AppNeedsTwoButtonMouse=n
|
||||
AppNeedsArrowKeys=y
|
||||
AppNeedsTextInput=y
|
||||
AppUsesJoystick=n
|
||||
AppHandlesJoystickSensitivity=n
|
||||
AppUsesMultitouch=n
|
||||
NonBlockingSwapBuffers=n
|
||||
RedefinedKeys="RSHIFT RETURN BACKSPACE RETURN SPACE"
|
||||
AppTouchscreenKeyboardKeysAmount=3
|
||||
AppTouchscreenKeyboardKeysAmountAutoFire=0
|
||||
RedefinedKeysScreenKb="RSHIFT RETURN BACKSPACE RETURN SPACE"
|
||||
MultiABI=n
|
||||
AppVersionCode=01901
|
||||
AppVersionName="0.1.9"
|
||||
CompiledLibraries="jpeg png"
|
||||
CustomBuildScript=n
|
||||
AppCflags='-Dmain=SDL_main -DBYPASS_PROTECTION'
|
||||
AppLdflags=''
|
||||
AppSubdirsBuild=''
|
||||
AppUseCrystaXToolchain=n
|
||||
AppCmdline=''
|
||||
ReadmeText='^You may press "Home" now - the data will be downloaded in background'
|
||||
20
project/jni/application/REminiscence/AndroidBuild.sh
Executable file
20
project/jni/application/REminiscence/AndroidBuild.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
LOCAL_PATH=`dirname $0`
|
||||
LOCAL_PATH=`cd $LOCAL_PATH && pwd`
|
||||
|
||||
# Hacks for broken configure scripts
|
||||
#rm -rf $LOCAL_PATH/../../obj/local/armeabi/libSDL_*.so
|
||||
#rm -rf $LOCAL_PATH/../../obj/local/armeabi/libsdl_main.so
|
||||
|
||||
# Uncomment if your configure expects SDL libraries in form "libSDL_name.so"
|
||||
#if [ -e $LOCAL_PATH/../../obj/local/armeabi/libsdl_mixer.so ] ; then
|
||||
# ln -sf libsdl_mixer.so $LOCAL_PATH/../../obj/local/armeabi/libSDL_Mixer.so
|
||||
#fi
|
||||
|
||||
#for F in $LOCAL_PATH/../../obj/local/armeabi/libsdl_*.so; do
|
||||
# LIBNAME=`echo $F | sed "s@$LOCAL_PATH/../../obj/local/armeabi/libsdl_\(.*\)[.]so@\1@"`
|
||||
# ln -sf libsdl_$LIBNAME.so $LOCAL_PATH/../../obj/local/armeabi/libSDL_$LIBNAME.so
|
||||
#done
|
||||
|
||||
../setEnvironment.sh make -C REminiscence-0.1.9 -j2 && cp -f REminiscence-0.1.9/rs libapplication.so
|
||||
340
project/jni/application/REminiscence/REminiscence-0.1.9/COPYING
Normal file
340
project/jni/application/REminiscence/REminiscence-0.1.9/COPYING
Normal file
@@ -0,0 +1,340 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
SDL_CFLAGS = `sdl-config --cflags` -Dmain=SDL_main -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I/home/lubomyr/src/endless_space/android-ndk-r4-crystax/build/platforms/android-8/arch-arm/usr/include -I/home/lubomyr/project/jni/sdl-1.2/include
|
||||
SDL_LIBS = `sdl-config --libs` -nostdlib -Wl,-soname,libapplication.so -Wl,-shared,-Bsymbolic -Wl,--whole-archive -Wl,--no-whole-archive /home/lubomyr/src/endless_space/android-ndk-r4-crystax/build/prebuilt/linux-x86/arm-eabi-4.4.0/arm-eabi/lib/libstdc++.a /home/lubomyr/src/endless_space/android-ndk-r4-crystax/build/platforms/android-8/arch-arm/usr/lib/libc.a -L/home/lubomyr/project/obj/local/armeabi -lsdl-1.2 -lm -llog -lgcc -L/home/lubomyr/src/endless_space/android-ndk-r4-crystax/build/platforms/android-8/arch-arm/usr/lib
|
||||
|
||||
DEFINES = -DBYPASS_PROTECTION
|
||||
#DEFINES = -DBYPASS_PROTECTION -DNDEBUG
|
||||
|
||||
CXX = arm-eabi-g++
|
||||
CXXFLAGS:= -g -Wall -Wuninitialized -Wno-unknown-pragmas -Wshadow -Wimplicit
|
||||
CXXFLAGS+= -Wundef -Wreorder -Wwrite-strings -Wnon-virtual-dtor -Wno-multichar
|
||||
CXXFLAGS+= $(SDL_CFLAGS) $(DEFINES)
|
||||
|
||||
SRCS = collision.cpp cutscene.cpp file.cpp game.cpp graphics.cpp main.cpp menu.cpp \
|
||||
mixer.cpp mod_player.cpp piege.cpp resource.cpp scaler.cpp sfx_player.cpp \
|
||||
staticres.cpp systemstub_sdl.cpp unpack.cpp util.cpp video.cpp
|
||||
|
||||
OBJS = $(SRCS:.cpp=.o)
|
||||
DEPS = $(SRCS:.cpp=.d)
|
||||
|
||||
rs: $(OBJS)
|
||||
$(CXX) $(LDFLAGS) -o $@ $(OBJS) $(SDL_LIBS) -lz
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) $(CXXFLAGS) -MMD -c $< -o $*.o
|
||||
|
||||
clean:
|
||||
rm -f *.o *.d
|
||||
|
||||
-include $(DEPS)
|
||||
138
project/jni/application/REminiscence/REminiscence-0.1.9/README
Normal file
138
project/jni/application/REminiscence/REminiscence-0.1.9/README
Normal file
@@ -0,0 +1,138 @@
|
||||
|
||||
REminiscence README
|
||||
Release version: 0.1.9 (Mar 16 2007)
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
About:
|
||||
------
|
||||
|
||||
REminiscence is a re-implementation of the engine used in the game Flashback
|
||||
made by Delphine Software and released in 1992. More informations about the
|
||||
game can be found at [1], [2] and [3].
|
||||
|
||||
|
||||
Supported Versions:
|
||||
-------------------
|
||||
|
||||
Only the PC DOS versions are supported. The engine has been reported to work
|
||||
with english, french, german and spanish versions of the game.
|
||||
|
||||
|
||||
Compiling:
|
||||
----------
|
||||
|
||||
Tweak the Makefile if needed and type make (only gcc3 has been tested so far).
|
||||
The SDL and zlib libraries are required.
|
||||
|
||||
|
||||
Data Files:
|
||||
-----------
|
||||
|
||||
You will need the original files, here is the required list :
|
||||
|
||||
FB_TXT.FNT
|
||||
GLOBAL.ICN
|
||||
GLOBAL.FIB
|
||||
GLOBAL.SPC
|
||||
*.OFF
|
||||
*.SPR
|
||||
*.MAP
|
||||
*.PAL
|
||||
*.ANI
|
||||
*.CT
|
||||
*.MBK
|
||||
*.OBJ
|
||||
*.PGE
|
||||
*.RP
|
||||
*.TBN
|
||||
*.CMD
|
||||
*.POL
|
||||
*CINE.*
|
||||
|
||||
If you have a version distributed by SSI, you'll have to rename some files :
|
||||
|
||||
logosssi.cmd -> logos.cmd
|
||||
logosssi.pol -> logos.pol
|
||||
menu1ssi.map -> menu1.map
|
||||
menu1ssi.pal -> menu1.pal
|
||||
|
||||
In order to hear music, you'll need the original music files (.mod) of the
|
||||
amiga version. Copy them to the DATA directory and rename them like this :
|
||||
|
||||
mod.flashback-ascenseur
|
||||
mod.flashback-ceinturea
|
||||
mod.flashback-chute
|
||||
mod.flashback-desintegr
|
||||
mod.flashback-donneobjt
|
||||
mod.flashback-fin
|
||||
mod.flashback-fin2
|
||||
mod.flashback-game_over
|
||||
mod.flashback-holocube
|
||||
mod.flashback-introb
|
||||
mod.flashback-jungle
|
||||
mod.flashback-logo
|
||||
mod.flashback-memoire
|
||||
mod.flashback-missionca
|
||||
mod.flashback-options1
|
||||
mod.flashback-options2
|
||||
mod.flashback-reunion
|
||||
mod.flashback-taxi
|
||||
mod.flashback-teleport2
|
||||
mod.flashback-teleporta
|
||||
mod.flashback-voyage
|
||||
|
||||
|
||||
Running:
|
||||
--------
|
||||
|
||||
By default, the engine will try to load the game data files from the 'DATA'
|
||||
directory (as the original game did). The savestates are saved in the current
|
||||
directory. These paths can be changed using command line switches :
|
||||
|
||||
Usage: rs [OPTIONS]...
|
||||
--datapath=PATH Path to data files (default 'DATA')
|
||||
--savepath=PATH Path to save files (default '.')
|
||||
|
||||
In-game hotkeys :
|
||||
|
||||
Arrow Keys move Conrad
|
||||
Enter use the current inventory object
|
||||
Shift talk / use / run / shoot
|
||||
Escape display the options
|
||||
Backspace display the inventory
|
||||
Alt Enter toggle windowed/fullscreen mode
|
||||
Alt + and - change video scaler
|
||||
Ctrl S save game state
|
||||
Ctrl L load game state
|
||||
Ctrl + and - change game state slot
|
||||
Ctrl R toggle input keys record
|
||||
Ctrl P toggle input keys replay
|
||||
|
||||
Debug hotkeys :
|
||||
|
||||
Ctrl F toggle fast mode
|
||||
Ctrl I set Conrad life counter to 32767
|
||||
Ctrl B toggle display of updated dirty blocks
|
||||
Ctrl M mirror mode (just a hack, really)
|
||||
|
||||
|
||||
Credits:
|
||||
--------
|
||||
|
||||
Delphine Software, obviously, for making another great game.
|
||||
Yaz0r, Pixel and gawd for sharing information they gathered on the game.
|
||||
|
||||
|
||||
Contact:
|
||||
--------
|
||||
|
||||
Gregory Montoir, cyx@users.sourceforge.net
|
||||
|
||||
|
||||
URLs:
|
||||
-----
|
||||
|
||||
[1] http://www.mobygames.com/game/flashback-the-quest-for-identity
|
||||
[2] http://en.wikipedia.org/wiki/Flashback:_The_Quest_for_Identity
|
||||
[3] http://ramal.free.fr/fb_en.htm
|
||||
@@ -0,0 +1,523 @@
|
||||
/* REminiscence - Flashback interpreter
|
||||
* Copyright (C) 2005-2007 Gregory Montoir
|
||||
*
|
||||
* This program 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.
|
||||
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "game.h"
|
||||
#include "resource.h"
|
||||
|
||||
|
||||
void Game::col_prepareRoomState() {
|
||||
memset(_col_activeCollisionSlots, 0xFF, sizeof(_col_activeCollisionSlots));
|
||||
_col_currentLeftRoom = _res._ctData[CT_LEFT_ROOM + _currentRoom];
|
||||
_col_currentRightRoom = _res._ctData[CT_RIGHT_ROOM + _currentRoom];
|
||||
for (int i = 0; i != _col_curPos; ++i) {
|
||||
CollisionSlot *_di = _col_slotsTable[i];
|
||||
uint8 room = _di->ct_pos / 64;
|
||||
if (room == _currentRoom) {
|
||||
_col_activeCollisionSlots[0x30 + (_di->ct_pos & 0x3F)] = i;
|
||||
} else if (room == _col_currentLeftRoom) {
|
||||
_col_activeCollisionSlots[0x00 + (_di->ct_pos & 0x3F)] = i;
|
||||
} else if (room == _col_currentRightRoom) {
|
||||
_col_activeCollisionSlots[0x60 + (_di->ct_pos & 0x3F)] = i;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_COLLISION
|
||||
printf("---\n");
|
||||
for (int y = 0; y < 7; ++y) {
|
||||
for (int x = 0; x < 16; ++x) {
|
||||
printf("%d", _res._ctData[0x100 + _currentRoom * 0x70 + y * 16 + x]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Game::col_clearState() {
|
||||
_col_curPos = 0;
|
||||
_col_curSlot = _col_slots;
|
||||
}
|
||||
|
||||
void Game::col_preparePiegeState(LivePGE *pge) {
|
||||
debug(DBG_COL, "Game::col_preparePiegeState() pge_num=%d", pge - &_pgeLive[0]);
|
||||
CollisionSlot *ct_slot1, *ct_slot2;
|
||||
if (pge->init_PGE->unk1C == 0) {
|
||||
pge->collision_slot = 0xFF;
|
||||
return;
|
||||
}
|
||||
int i = 0;
|
||||
ct_slot1 = 0;
|
||||
for (int c = 0; c < pge->init_PGE->unk1C; ++c) {
|
||||
ct_slot2 = _col_curSlot;
|
||||
if (ct_slot2 + 1 > &_col_slots[255])
|
||||
return;
|
||||
_col_curSlot = ct_slot2 + 1;
|
||||
int16 pos = col_getGridPos(pge, i);
|
||||
if (pos < 0) {
|
||||
if (ct_slot1 == 0) {
|
||||
pge->collision_slot = 0xFF;
|
||||
} else {
|
||||
ct_slot1->index = 0xFFFF;
|
||||
}
|
||||
return;
|
||||
}
|
||||
ct_slot2->ct_pos = pos;
|
||||
ct_slot2->live_pge = pge;
|
||||
ct_slot2->index = 0xFFFF;
|
||||
int16 _ax = col_findSlot(pos);
|
||||
if (_ax >= 0) {
|
||||
ct_slot2->prev_slot = _col_slotsTable[_ax];
|
||||
_col_slotsTable[_ax] = ct_slot2;
|
||||
if (ct_slot1 == 0) {
|
||||
pge->collision_slot = _ax;
|
||||
} else {
|
||||
ct_slot1->index = _ax;
|
||||
}
|
||||
LivePGE *temp_pge = ct_slot2->live_pge;
|
||||
if (temp_pge->flags & 0x80) {
|
||||
_pge_liveTable2[temp_pge->index] = temp_pge;
|
||||
temp_pge->flags |= 4;
|
||||
}
|
||||
if (ct_slot2->prev_slot) {
|
||||
temp_pge = ct_slot2->prev_slot->live_pge;
|
||||
if (temp_pge->flags & 0x80) {
|
||||
_pge_liveTable2[temp_pge->index] = temp_pge;
|
||||
temp_pge->flags |= 4;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ct_slot2->prev_slot = 0;
|
||||
_col_slotsTable[_col_curPos] = ct_slot2;
|
||||
if (ct_slot1 == 0) {
|
||||
pge->collision_slot = _col_curPos;
|
||||
} else {
|
||||
ct_slot1->index = _col_curPos;
|
||||
}
|
||||
_col_curPos++;
|
||||
}
|
||||
ct_slot1 = ct_slot2;
|
||||
i += 0x10;
|
||||
}
|
||||
}
|
||||
|
||||
uint16 Game::col_getGridPos(LivePGE *pge, int16 dx) {
|
||||
int16 x = pge->pos_x + dx;
|
||||
int16 y = pge->pos_y;
|
||||
|
||||
int8 c = pge->room_location;
|
||||
if (c < 0) return 0xFFFF;
|
||||
|
||||
if (x < 0) {
|
||||
c = _res._ctData[CT_LEFT_ROOM + c];
|
||||
if (c < 0) return 0xFFFF;
|
||||
x += 256;
|
||||
} else if (x >= 256) {
|
||||
c = _res._ctData[CT_RIGHT_ROOM + c];
|
||||
if (c < 0) return 0xFFFF;
|
||||
x -= 256;
|
||||
} else if (y < 0) {
|
||||
c = _res._ctData[CT_UP_ROOM + c];
|
||||
if (c < 0) return 0xFFFF;
|
||||
y += 216;
|
||||
} else if (y >= 216) {
|
||||
c = _res._ctData[CT_DOWN_ROOM + c];
|
||||
if (c < 0) return 0xFFFF;
|
||||
y -= 216;
|
||||
}
|
||||
|
||||
x = (x + 8) >> 4;
|
||||
y = (y - 8) / 72;
|
||||
if (x < 0 || x > 15 || y < 0 || y > 2) {
|
||||
return 0xFFFF;
|
||||
} else {
|
||||
return y * 16 + x + c * 64;
|
||||
}
|
||||
}
|
||||
|
||||
int16 Game::col_findSlot(int16 pos) {
|
||||
for (uint16 i = 0; i < _col_curPos; ++i) {
|
||||
if (_col_slotsTable[i]->ct_pos == pos)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int16 Game::col_getGridData(LivePGE *pge, int16 dy, int16 dx) {
|
||||
if (_pge_currentPiegeFacingDir) {
|
||||
dx = -dx;
|
||||
}
|
||||
const int16 pge_grid_y = _col_currentPiegeGridPosY + dy;
|
||||
const int16 pge_grid_x = _col_currentPiegeGridPosX + dx;
|
||||
const int8 *room_ct_data;
|
||||
int8 next_room;
|
||||
if (pge_grid_x < 0) {
|
||||
room_ct_data = &_res._ctData[CT_LEFT_ROOM];
|
||||
next_room = room_ct_data[pge->room_location];
|
||||
if (next_room < 0) return 1;
|
||||
room_ct_data += pge_grid_x + 16 + pge_grid_y * 16 + next_room * 0x70;
|
||||
return (int16)room_ct_data[0x40];
|
||||
} else if (pge_grid_x >= 16) {
|
||||
room_ct_data = &_res._ctData[CT_RIGHT_ROOM];
|
||||
next_room = room_ct_data[pge->room_location];
|
||||
if (next_room < 0) return 1;
|
||||
room_ct_data += pge_grid_x - 16 + pge_grid_y * 16 + next_room * 0x70;
|
||||
return (int16)room_ct_data[0x80];
|
||||
} else if (pge_grid_y < 1) {
|
||||
room_ct_data = &_res._ctData[CT_UP_ROOM];
|
||||
next_room = room_ct_data[pge->room_location];
|
||||
if (next_room < 0) return 1;
|
||||
room_ct_data += pge_grid_x + (pge_grid_y + 6) * 16 + next_room * 0x70;
|
||||
return (int16)room_ct_data[0x100];
|
||||
} else if (pge_grid_y >= 7) {
|
||||
room_ct_data = &_res._ctData[CT_DOWN_ROOM];
|
||||
next_room = room_ct_data[pge->room_location];
|
||||
if (next_room < 0) return 1;
|
||||
room_ct_data += pge_grid_x + (pge_grid_y - 6) * 16 + next_room * 0x70;
|
||||
return (int16)room_ct_data[0xC0];
|
||||
} else {
|
||||
room_ct_data = &_res._ctData[0x100];
|
||||
room_ct_data += pge_grid_x + pge_grid_y * 16 + pge->room_location * 0x70;
|
||||
return (int16)room_ct_data[0];
|
||||
}
|
||||
}
|
||||
|
||||
LivePGE *Game::col_findPiege(LivePGE *pge, uint16 arg2) {
|
||||
if (pge->collision_slot != 0xFF) {
|
||||
CollisionSlot *slot = _col_slotsTable[pge->collision_slot];
|
||||
while (slot) {
|
||||
if (slot->live_pge == pge) {
|
||||
slot = slot->prev_slot;
|
||||
} else {
|
||||
if (arg2 == 0xFFFF || arg2 == slot->live_pge->init_PGE->object_type) {
|
||||
return slot->live_pge;
|
||||
} else {
|
||||
slot = slot->prev_slot;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8 Game::col_findCurrentCollidingObject(LivePGE *pge, uint8 n1, uint8 n2, uint8 n3, LivePGE **pge_out) {
|
||||
if (pge_out) {
|
||||
*pge_out = pge;
|
||||
}
|
||||
if (pge->collision_slot != 0xFF) {
|
||||
CollisionSlot *cs = _col_slotsTable[pge->collision_slot];
|
||||
while (cs) {
|
||||
LivePGE *col_pge = cs->live_pge;
|
||||
if (pge_out) {
|
||||
*pge_out = col_pge;
|
||||
}
|
||||
if (col_pge->init_PGE->object_type == n1 ||
|
||||
col_pge->init_PGE->object_type == n2 ||
|
||||
col_pge->init_PGE->object_type == n3) {
|
||||
return col_pge->init_PGE->colliding_icon_num;
|
||||
} else {
|
||||
cs = cs->prev_slot;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int16 Game::col_detectHit(LivePGE *pge, int16 arg2, int16 arg4, col_Callback1 callback1, col_Callback2 callback2, int16 argA, int16 argC) {
|
||||
debug(DBG_COL, "col_detectHit()");
|
||||
int16 pos_dx, pos_dy, var8, varA;
|
||||
int16 collision_score = 0;
|
||||
int8 pge_room = pge->room_location;
|
||||
if (pge_room < 0 || pge_room >= 0x40) {
|
||||
return 0;
|
||||
}
|
||||
int16 thr = pge->init_PGE->counter_values[0];
|
||||
if (thr > 0) {
|
||||
pos_dx = -1;
|
||||
pos_dy = -1;
|
||||
} else {
|
||||
pos_dx = 1;
|
||||
pos_dy = 1;
|
||||
thr = -thr;
|
||||
}
|
||||
if (_pge_currentPiegeFacingDir) {
|
||||
pos_dx = -pos_dx;
|
||||
}
|
||||
int16 grid_pos_x = (pge->pos_x + 8) >> 4;
|
||||
int16 grid_pos_y = (pge->pos_y / 72);
|
||||
if (grid_pos_y >= 0 && grid_pos_y <= 2) {
|
||||
grid_pos_y *= 16;
|
||||
collision_score = 0;
|
||||
var8 = 0;
|
||||
varA = 0;
|
||||
if (argA != 0) {
|
||||
var8 = pos_dy;
|
||||
grid_pos_x += pos_dx;
|
||||
varA = 1;
|
||||
}
|
||||
while (varA <= thr) {
|
||||
if (grid_pos_x < 0) {
|
||||
pge_room = _res._ctData[CT_LEFT_ROOM + pge_room];
|
||||
if (pge_room < 0) break;
|
||||
grid_pos_x += 16;
|
||||
}
|
||||
if (grid_pos_x >= 16) {
|
||||
pge_room = _res._ctData[CT_RIGHT_ROOM + pge_room];
|
||||
if (pge_room < 0) break;
|
||||
grid_pos_x -= 16;
|
||||
}
|
||||
int16 slot = col_findSlot(grid_pos_y + grid_pos_x + pge_room * 64);
|
||||
if (slot >= 0) {
|
||||
CollisionSlot *cs = _col_slotsTable[slot];
|
||||
while (cs) {
|
||||
collision_score += (this->*callback1)(cs->live_pge, pge, arg2, arg4);
|
||||
cs = cs->prev_slot;
|
||||
}
|
||||
}
|
||||
if ((this->*callback2)(pge, var8, varA, arg2) != 0) {
|
||||
break;
|
||||
}
|
||||
grid_pos_x += pos_dx;
|
||||
++varA;
|
||||
var8 += pos_dy;
|
||||
}
|
||||
}
|
||||
if (argC == -1) {
|
||||
return collision_score;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int Game::col_detectHitCallback1(LivePGE *pge, int16 dy, int16 unk1, int16 unk2) {
|
||||
if (col_getGridData(pge, 1, dy) != 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int Game::col_detectHitCallback6(LivePGE *pge, int16 dy, int16 unk1, int16 unk2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Game::col_detectHitCallback2(LivePGE *pge1, LivePGE *pge2, int16 unk1, int16 unk2) {
|
||||
if (pge1 != pge2 && (pge1->flags & 4)) {
|
||||
if (pge1->init_PGE->object_type == unk2) {
|
||||
if ((pge1->flags & 1) == (pge2->flags & 1)) {
|
||||
if (col_detectHitCallbackHelper(pge1, unk1) == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Game::col_detectHitCallback3(LivePGE *pge1, LivePGE *pge2, int16 unk1, int16 unk2) {
|
||||
if (pge1 != pge2 && (pge1->flags & 4)) {
|
||||
if (pge1->init_PGE->object_type == unk2) {
|
||||
if ((pge1->flags & 1) != (pge2->flags & 1)) {
|
||||
if (col_detectHitCallbackHelper(pge1, unk1) == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Game::col_detectHitCallback4(LivePGE *pge1, LivePGE *pge2, int16 unk1, int16 unk2) {
|
||||
if (pge1 != pge2 && (pge1->flags & 4)) {
|
||||
if (pge1->init_PGE->object_type == unk2) {
|
||||
if ((pge1->flags & 1) != (pge2->flags & 1)) {
|
||||
if (col_detectHitCallbackHelper(pge1, unk1) == 0) {
|
||||
pge_updateGroup(pge2->index, pge1->index, unk1);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Game::col_detectHitCallback5(LivePGE *pge1, LivePGE *pge2, int16 unk1, int16 unk2) {
|
||||
if (pge1 != pge2 && (pge1->flags & 4)) {
|
||||
if (pge1->init_PGE->object_type == unk2) {
|
||||
if ((pge1->flags & 1) == (pge2->flags & 1)) {
|
||||
if (col_detectHitCallbackHelper(pge1, unk1) == 0) {
|
||||
pge_updateGroup(pge2->index, pge1->index, unk1);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Game::col_detectHitCallbackHelper(LivePGE *pge, int16 groupId) {
|
||||
InitPGE *init_pge = pge->init_PGE;
|
||||
assert(init_pge->obj_node_number < _res._numObjectNodes);
|
||||
ObjectNode *on = _res._objectNodesMap[init_pge->obj_node_number];
|
||||
Object *obj = &on->objects[pge->first_obj_number];
|
||||
int i = pge->first_obj_number;
|
||||
while (pge->obj_type == obj->type && on->last_obj_number > i) {
|
||||
if (obj->opcode2 == 0x6B) { // pge_op_isInGroupSlice
|
||||
if (obj->opcode_arg2 == 0) {
|
||||
if (groupId == 1 || groupId == 2) return 0xFFFF;
|
||||
}
|
||||
if (obj->opcode_arg2 == 1) {
|
||||
if (groupId == 3 || groupId == 4) return 0xFFFF;
|
||||
}
|
||||
} else if (obj->opcode2 == 0x22) { // pge_op_isInGroup
|
||||
if (obj->opcode_arg2 == groupId) return 0xFFFF;
|
||||
}
|
||||
|
||||
if (obj->opcode1 == 0x6B) { // pge_op_isInGroupSlice
|
||||
if (obj->opcode_arg1 == 0) {
|
||||
if (groupId == 1 || groupId == 2) return 0xFFFF;
|
||||
}
|
||||
if (obj->opcode_arg1 == 1) {
|
||||
if (groupId == 3 || groupId == 4) return 0xFFFF;
|
||||
}
|
||||
} else if (obj->opcode1 == 0x22) { // pge_op_isInGroup
|
||||
if (obj->opcode_arg1 == groupId) return 0xFFFF;
|
||||
}
|
||||
++obj;
|
||||
++i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Game::col_detectGunHitCallback1(LivePGE *pge, int16 arg2, int16 arg4, int16 arg6) {
|
||||
int16 _ax = col_getGridData(pge, 1, arg2);
|
||||
if (_ax != 0) {
|
||||
if (!(_ax & 2) || (arg6 != 1)) {
|
||||
return _ax;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Game::col_detectGunHitCallback2(LivePGE *pge1, LivePGE *pge2, int16 arg4, int16) {
|
||||
if (pge1 != pge2 && (pge1->flags & 4)) {
|
||||
if (pge1->init_PGE->object_type == 1 || pge1->init_PGE->object_type == 10) {
|
||||
uint8 id;
|
||||
if ((pge1->flags & 1) != (pge2->flags & 1)) {
|
||||
id = 4;
|
||||
if (arg4 == 0) {
|
||||
id = 3;
|
||||
}
|
||||
} else {
|
||||
id = 2;
|
||||
if (arg4 == 0) {
|
||||
id = 1;
|
||||
}
|
||||
}
|
||||
if (col_detectHitCallbackHelper(pge1, id) != 0) {
|
||||
pge_updateGroup(pge2->index, pge1->index, id);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Game::col_detectGunHitCallback3(LivePGE *pge1, LivePGE *pge2, int16 arg4, int16) {
|
||||
if (pge1 != pge2 && (pge1->flags & 4)) {
|
||||
if (pge1->init_PGE->object_type == 1 || pge1->init_PGE->object_type == 12 || pge1->init_PGE->object_type == 10) {
|
||||
uint8 id;
|
||||
if ((pge1->flags & 1) != (pge2->flags & 1)) {
|
||||
id = 4;
|
||||
if (arg4 == 0) {
|
||||
id = 3;
|
||||
}
|
||||
} else {
|
||||
id = 2;
|
||||
if (arg4 == 0) {
|
||||
id = 1;
|
||||
}
|
||||
}
|
||||
if (col_detectHitCallbackHelper(pge1, id) != 0) {
|
||||
pge_updateGroup(pge2->index, pge1->index, id);
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Game::col_detectGunHit(LivePGE *pge, int16 arg2, int16 arg4, col_Callback1 callback1, col_Callback2 callback2, int16 argA, int16 argC) {
|
||||
int8 pge_room = pge->room_location;
|
||||
if (pge_room < 0 || pge_room >= 0x40) return 0;
|
||||
int16 thr, pos_dx, pos_dy;
|
||||
if (argC == -1) {
|
||||
thr = pge->init_PGE->counter_values[0];
|
||||
} else {
|
||||
thr = pge->init_PGE->counter_values[3];
|
||||
}
|
||||
if (thr > 0) {
|
||||
pos_dx = -1;
|
||||
pos_dy = -1;
|
||||
} else {
|
||||
pos_dx = 1;
|
||||
pos_dy = 1;
|
||||
thr = -thr;
|
||||
}
|
||||
if (_pge_currentPiegeFacingDir) {
|
||||
pos_dx = -pos_dx;
|
||||
}
|
||||
int16 grid_pos_x = (pge->pos_x + 8) >> 4;
|
||||
int16 grid_pos_y = (pge->pos_y - 8) / 72;
|
||||
if (grid_pos_y >= 0 && grid_pos_y <= 2) {
|
||||
grid_pos_y *= 16;
|
||||
int16 var8 = 0;
|
||||
int16 varA = 0;
|
||||
if (argA != 0) {
|
||||
var8 = pos_dy;
|
||||
grid_pos_x += pos_dx;
|
||||
varA = 1;
|
||||
}
|
||||
while (varA <= thr) {
|
||||
if (grid_pos_x < 0) {
|
||||
pge_room = _res._ctData[CT_LEFT_ROOM + pge_room];
|
||||
if (pge_room < 0) return 0;
|
||||
grid_pos_x += 0x10;
|
||||
}
|
||||
if (grid_pos_x >= 0x10) {
|
||||
pge_room = _res._ctData[CT_RIGHT_ROOM + pge_room];
|
||||
if (pge_room < 0) return 0;
|
||||
grid_pos_x -= 0x10;
|
||||
}
|
||||
int16 slot = col_findSlot(pge_room * 64 + grid_pos_x + grid_pos_y);
|
||||
if (slot >= 0) {
|
||||
CollisionSlot *cs = _col_slotsTable[slot];
|
||||
while (cs) {
|
||||
int r = (this->*callback1)(cs->live_pge, pge, arg2, arg4);
|
||||
if (r != 0) return r;
|
||||
cs = cs->prev_slot;
|
||||
}
|
||||
}
|
||||
if ((this->*callback2)(pge, var8, varA, arg2) != 0) {
|
||||
break;
|
||||
}
|
||||
grid_pos_x += pos_dx;
|
||||
++varA;
|
||||
var8 += pos_dy;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
1028
project/jni/application/REminiscence/REminiscence-0.1.9/cutscene.cpp
Normal file
1028
project/jni/application/REminiscence/REminiscence-0.1.9/cutscene.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,138 @@
|
||||
/* REminiscence - Flashback interpreter
|
||||
* Copyright (C) 2005-2007 Gregory Montoir
|
||||
*
|
||||
* This program 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.
|
||||
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CUTSCENE_H__
|
||||
#define __CUTSCENE_H__
|
||||
|
||||
#include "intern.h"
|
||||
#include "graphics.h"
|
||||
|
||||
struct ModPlayer;
|
||||
struct Resource;
|
||||
struct SystemStub;
|
||||
struct Video;
|
||||
|
||||
struct Cutscene {
|
||||
typedef void (Cutscene::*OpcodeStub)();
|
||||
|
||||
enum {
|
||||
NUM_OPCODES = 15,
|
||||
TIMER_SLICE = 15
|
||||
};
|
||||
|
||||
static const OpcodeStub _opcodeTable[];
|
||||
static const char *_namesTable[];
|
||||
static const uint16 _offsetsTable[];
|
||||
static const uint16 _cosTable[];
|
||||
static const uint16 _sinTable[];
|
||||
static const uint8 _creditsData[];
|
||||
static const uint16 _creditsCutSeq[];
|
||||
static const uint8 _musicTable[];
|
||||
static const uint8 _protectionShapeData[];
|
||||
|
||||
Graphics _gfx;
|
||||
ModPlayer *_ply;
|
||||
Resource *_res;
|
||||
SystemStub *_stub;
|
||||
Video *_vid;
|
||||
Version _ver;
|
||||
|
||||
uint16 _id;
|
||||
uint16 _deathCutsceneId;
|
||||
bool _interrupted;
|
||||
bool _stop;
|
||||
uint8 *_polPtr;
|
||||
uint8 *_cmdPtr;
|
||||
uint8 *_cmdPtrBak;
|
||||
uint32 _tstamp;
|
||||
uint8 _frameDelay;
|
||||
bool _newPal;
|
||||
uint8 _palBuf[0x20 * 2];
|
||||
uint16 _startOffset;
|
||||
bool _creditsSequence;
|
||||
uint32 _rotData[4];
|
||||
uint8 _primitiveColor;
|
||||
uint8 _clearScreen;
|
||||
Point _vertices[0x80];
|
||||
bool _hasAlphaColor;
|
||||
uint8 _varText;
|
||||
uint8 _varKey;
|
||||
int16 _shape_ix;
|
||||
int16 _shape_iy;
|
||||
int16 _shape_ox;
|
||||
int16 _shape_oy;
|
||||
int16 _shape_cur_x;
|
||||
int16 _shape_cur_y;
|
||||
int16 _shape_prev_x;
|
||||
int16 _shape_prev_y;
|
||||
uint16 _shape_count;
|
||||
uint32 _shape_cur_x16;
|
||||
uint32 _shape_cur_y16;
|
||||
uint32 _shape_prev_x16;
|
||||
uint32 _shape_prev_y16;
|
||||
uint8 _textSep[0x14];
|
||||
uint8 _textBuf[500];
|
||||
const uint8 *_textCurPtr;
|
||||
uint8 *_textCurBuf;
|
||||
uint8 _textUnk2;
|
||||
uint8 _creditsTextPosX;
|
||||
uint8 _creditsTextPosY;
|
||||
int16 _creditsTextCounter;
|
||||
uint8 *_page0, *_page1, *_pageC;
|
||||
|
||||
Cutscene(ModPlayer *player, Resource *res, SystemStub *stub, Video *vid, Version ver);
|
||||
|
||||
void sync();
|
||||
void copyPalette(const uint8 *pal, uint16 num);
|
||||
void updatePalette();
|
||||
void setPalette();
|
||||
void initRotationData(uint16 a, uint16 b, uint16 c);
|
||||
uint16 findTextSeparators(const uint8 *p);
|
||||
void drawText(int16 x, int16 y, const uint8 *p, uint16 color, uint8 *page, uint8 n);
|
||||
void swapLayers();
|
||||
void drawCreditsText();
|
||||
void drawProtectionShape(uint8 shapeNum, int16 zoom);
|
||||
void drawShape(const uint8 *data, int16 x, int16 y);
|
||||
void drawShapeScale(const uint8 *data, int16 zoom, int16 b, int16 c, int16 d, int16 e, int16 f, int16 g);
|
||||
void drawShapeScaleRotate(const uint8 *data, int16 zoom, int16 b, int16 c, int16 d, int16 e, int16 f, int16 g);
|
||||
|
||||
void op_markCurPos();
|
||||
void op_refreshScreen();
|
||||
void op_waitForSync();
|
||||
void op_drawShape();
|
||||
void op_setPalette();
|
||||
void op_drawStringAtBottom();
|
||||
void op_nop();
|
||||
void op_skip3();
|
||||
void op_refreshAll();
|
||||
void op_drawShapeScale();
|
||||
void op_drawShapeScaleRotate();
|
||||
void op_drawCreditsText();
|
||||
void op_drawStringAtPos();
|
||||
void op_handleKeys();
|
||||
|
||||
uint8 fetchNextCmdByte();
|
||||
uint16 fetchNextCmdWord();
|
||||
void mainLoop(uint16 offset);
|
||||
void load(uint16 cutName);
|
||||
void prepare();
|
||||
void startCredits();
|
||||
void play();
|
||||
};
|
||||
|
||||
#endif // __CUTSCENE_H__
|
||||
222
project/jni/application/REminiscence/REminiscence-0.1.9/file.cpp
Normal file
222
project/jni/application/REminiscence/REminiscence-0.1.9/file.cpp
Normal file
@@ -0,0 +1,222 @@
|
||||
/* REminiscence - Flashback interpreter
|
||||
* Copyright (C) 2005-2007 Gregory Montoir
|
||||
*
|
||||
* This program 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.
|
||||
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "zlib.h"
|
||||
#include "file.h"
|
||||
|
||||
|
||||
struct File_impl {
|
||||
bool _ioErr;
|
||||
File_impl() : _ioErr(false) {}
|
||||
virtual bool open(const char *path, const char *mode) = 0;
|
||||
virtual void close() = 0;
|
||||
virtual uint32 size() = 0;
|
||||
virtual void seek(int32 off) = 0;
|
||||
virtual void read(void *ptr, uint32 len) = 0;
|
||||
virtual void write(void *ptr, uint32 len) = 0;
|
||||
};
|
||||
|
||||
struct stdFile : File_impl {
|
||||
FILE *_fp;
|
||||
stdFile() : _fp(0) {}
|
||||
bool open(const char *path, const char *mode) {
|
||||
_ioErr = false;
|
||||
_fp = fopen(path, mode);
|
||||
return (_fp != 0);
|
||||
}
|
||||
void close() {
|
||||
if (_fp) {
|
||||
fclose(_fp);
|
||||
_fp = 0;
|
||||
}
|
||||
}
|
||||
uint32 size() {
|
||||
uint32 sz = 0;
|
||||
if (_fp) {
|
||||
int pos = ftell(_fp);
|
||||
fseek(_fp, 0, SEEK_END);
|
||||
sz = ftell(_fp);
|
||||
fseek(_fp, pos, SEEK_SET);
|
||||
}
|
||||
return sz;
|
||||
}
|
||||
void seek(int32 off) {
|
||||
if (_fp) {
|
||||
fseek(_fp, off, SEEK_SET);
|
||||
}
|
||||
}
|
||||
void read(void *ptr, uint32 len) {
|
||||
if (_fp) {
|
||||
uint32 r = fread(ptr, 1, len, _fp);
|
||||
if (r != len) {
|
||||
_ioErr = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
void write(void *ptr, uint32 len) {
|
||||
if (_fp) {
|
||||
uint32 r = fwrite(ptr, 1, len, _fp);
|
||||
if (r != len) {
|
||||
_ioErr = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct zlibFile : File_impl {
|
||||
gzFile _fp;
|
||||
zlibFile() : _fp(0) {}
|
||||
bool open(const char *path, const char *mode) {
|
||||
_ioErr = false;
|
||||
_fp = gzopen(path, mode);
|
||||
return (_fp != 0);
|
||||
}
|
||||
void close() {
|
||||
if (_fp) {
|
||||
gzclose(_fp);
|
||||
_fp = 0;
|
||||
}
|
||||
}
|
||||
uint32 size() {
|
||||
uint32 sz = 0;
|
||||
if (_fp) {
|
||||
int pos = gztell(_fp);
|
||||
gzseek(_fp, 0, SEEK_END);
|
||||
sz = gztell(_fp);
|
||||
gzseek(_fp, pos, SEEK_SET);
|
||||
}
|
||||
return sz;
|
||||
}
|
||||
void seek(int32 off) {
|
||||
if (_fp) {
|
||||
gzseek(_fp, off, SEEK_SET);
|
||||
}
|
||||
}
|
||||
void read(void *ptr, uint32 len) {
|
||||
if (_fp) {
|
||||
uint32 r = gzread(_fp, ptr, len);
|
||||
if (r != len) {
|
||||
_ioErr = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
void write(void *ptr, uint32 len) {
|
||||
if (_fp) {
|
||||
uint32 r = gzwrite(_fp, ptr, len);
|
||||
if (r != len) {
|
||||
_ioErr = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
File::File(bool gzipped) {
|
||||
if (gzipped) {
|
||||
_impl = new zlibFile;
|
||||
} else {
|
||||
_impl = new stdFile;
|
||||
}
|
||||
}
|
||||
|
||||
File::~File() {
|
||||
_impl->close();
|
||||
delete _impl;
|
||||
}
|
||||
|
||||
bool File::open(const char *filename, const char *directory, const char *mode) {
|
||||
_impl->close();
|
||||
char buf[512];
|
||||
sprintf(buf, "%s/%s", directory, filename);
|
||||
char *p = buf + strlen(directory) + 1;
|
||||
string_lower(p);
|
||||
bool opened = _impl->open(buf, mode);
|
||||
if (!opened) { // let's try uppercase
|
||||
string_upper(p);
|
||||
opened = _impl->open(buf, mode);
|
||||
}
|
||||
return opened;
|
||||
}
|
||||
|
||||
void File::close() {
|
||||
_impl->close();
|
||||
}
|
||||
|
||||
bool File::ioErr() const {
|
||||
return _impl->_ioErr;
|
||||
}
|
||||
|
||||
uint32 File::size() {
|
||||
return _impl->size();
|
||||
}
|
||||
|
||||
void File::seek(int32 off) {
|
||||
_impl->seek(off);
|
||||
}
|
||||
|
||||
void File::read(void *ptr, uint32 len) {
|
||||
_impl->read(ptr, len);
|
||||
}
|
||||
|
||||
uint8 File::readByte() {
|
||||
uint8 b;
|
||||
read(&b, 1);
|
||||
return b;
|
||||
}
|
||||
|
||||
uint16 File::readUint16LE() {
|
||||
uint8 lo = readByte();
|
||||
uint8 hi = readByte();
|
||||
return (hi << 8) | lo;
|
||||
}
|
||||
|
||||
uint32 File::readUint32LE() {
|
||||
uint16 lo = readUint16LE();
|
||||
uint16 hi = readUint16LE();
|
||||
return (hi << 16) | lo;
|
||||
}
|
||||
|
||||
uint16 File::readUint16BE() {
|
||||
uint8 hi = readByte();
|
||||
uint8 lo = readByte();
|
||||
return (hi << 8) | lo;
|
||||
}
|
||||
|
||||
uint32 File::readUint32BE() {
|
||||
uint16 hi = readUint16BE();
|
||||
uint16 lo = readUint16BE();
|
||||
return (hi << 16) | lo;
|
||||
}
|
||||
|
||||
void File::write(void *ptr, uint32 len) {
|
||||
_impl->write(ptr, len);
|
||||
}
|
||||
|
||||
void File::writeByte(uint8 b) {
|
||||
write(&b, 1);
|
||||
}
|
||||
|
||||
void File::writeUint16BE(uint16 n) {
|
||||
writeByte(n >> 8);
|
||||
writeByte(n & 0xFF);
|
||||
}
|
||||
|
||||
void File::writeUint32BE(uint32 n) {
|
||||
writeUint16BE(n >> 16);
|
||||
writeUint16BE(n & 0xFFFF);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/* REminiscence - Flashback interpreter
|
||||
* Copyright (C) 2005-2007 Gregory Montoir
|
||||
*
|
||||
* This program 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.
|
||||
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __FILE_H__
|
||||
#define __FILE_H__
|
||||
|
||||
#include "intern.h"
|
||||
|
||||
struct File_impl;
|
||||
|
||||
struct File {
|
||||
File(bool gzipped = false);
|
||||
~File();
|
||||
|
||||
File_impl *_impl;
|
||||
|
||||
bool open(const char *filename, const char *directory, const char *mode);
|
||||
void close();
|
||||
bool ioErr() const;
|
||||
uint32 size();
|
||||
void seek(int32 off);
|
||||
void read(void *ptr, uint32 len);
|
||||
uint8 readByte();
|
||||
uint16 readUint16LE();
|
||||
uint32 readUint32LE();
|
||||
uint16 readUint16BE();
|
||||
uint32 readUint32BE();
|
||||
void write(void *ptr, uint32 size);
|
||||
void writeByte(uint8 b);
|
||||
void writeUint16BE(uint16 n);
|
||||
void writeUint32BE(uint32 n);
|
||||
};
|
||||
|
||||
#endif // __FILE_H__
|
||||
1600
project/jni/application/REminiscence/REminiscence-0.1.9/game.cpp
Normal file
1600
project/jni/application/REminiscence/REminiscence-0.1.9/game.cpp
Normal file
File diff suppressed because it is too large
Load Diff
391
project/jni/application/REminiscence/REminiscence-0.1.9/game.h
Normal file
391
project/jni/application/REminiscence/REminiscence-0.1.9/game.h
Normal file
@@ -0,0 +1,391 @@
|
||||
/* REminiscence - Flashback interpreter
|
||||
* Copyright (C) 2005-2007 Gregory Montoir
|
||||
*
|
||||
* This program 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.
|
||||
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GAME_H__
|
||||
#define __GAME_H__
|
||||
|
||||
#include "intern.h"
|
||||
#include "cutscene.h"
|
||||
#include "menu.h"
|
||||
#include "mixer.h"
|
||||
#include "mod_player.h"
|
||||
#include "resource.h"
|
||||
#include "sfx_player.h"
|
||||
#include "video.h"
|
||||
|
||||
struct File;
|
||||
struct SystemStub;
|
||||
|
||||
struct Game {
|
||||
typedef int (Game::*pge_OpcodeProc)(ObjectOpcodeArgs *args);
|
||||
typedef int (Game::*pge_ZOrderCallback)(LivePGE *, LivePGE *, uint8, uint8);
|
||||
typedef int (Game::*col_Callback1)(LivePGE *, LivePGE *, int16, int16);
|
||||
typedef int (Game::*col_Callback2)(LivePGE *, int16, int16, int16);
|
||||
|
||||
enum {
|
||||
CT_UP_ROOM = 0x00,
|
||||
CT_DOWN_ROOM = 0x40,
|
||||
CT_RIGHT_ROOM = 0x80,
|
||||
CT_LEFT_ROOM = 0xC0
|
||||
};
|
||||
|
||||
static const Level _gameLevels[];
|
||||
static const uint16 _scoreTable[];
|
||||
static const uint8 _monsterListLevel1[];
|
||||
static const uint8 _monsterListLevel2[];
|
||||
static const uint8 _monsterListLevel3[];
|
||||
static const uint8 _monsterListLevel4_1[];
|
||||
static const uint8 _monsterListLevel4_2[];
|
||||
static const uint8 _monsterListLevel5_1[];
|
||||
static const uint8 _monsterListLevel5_2[];
|
||||
static const uint8 *_monsterListLevels[];
|
||||
static const uint8 _monsterPals[4][32];
|
||||
static const char *_monsterNames[];
|
||||
static const pge_OpcodeProc _pge_opcodeTable[];
|
||||
static const uint8 _pge_modKeysTable[];
|
||||
static const uint8 _protectionCodeData[];
|
||||
static const uint8 _protectionPal[];
|
||||
|
||||
Cutscene _cut;
|
||||
Menu _menu;
|
||||
Mixer _mix;
|
||||
ModPlayer _modPly;
|
||||
Resource _res;
|
||||
SfxPlayer _sfxPly;
|
||||
Video _vid;
|
||||
SystemStub *_stub;
|
||||
const char *_savePath;
|
||||
|
||||
const uint8 *_stringsTable;
|
||||
const char **_textsTable;
|
||||
uint8 _currentLevel;
|
||||
uint8 _skillLevel;
|
||||
uint32 _score;
|
||||
uint8 _currentRoom;
|
||||
uint8 _currentIcon;
|
||||
bool _loadMap;
|
||||
uint8 _printLevelCodeCounter;
|
||||
uint32 _randSeed;
|
||||
uint16 _currentInventoryIconNum;
|
||||
uint16 _curMonsterFrame;
|
||||
uint16 _curMonsterNum;
|
||||
uint8 _blinkingConradCounter;
|
||||
uint16 _textToDisplay;
|
||||
bool _eraseBackground;
|
||||
AnimBufferState _animBuffer0State[41];
|
||||
AnimBufferState _animBuffer1State[6]; // Conrad
|
||||
AnimBufferState _animBuffer2State[42];
|
||||
AnimBufferState _animBuffer3State[12];
|
||||
AnimBuffers _animBuffers;
|
||||
uint8 _bankData[0x7000];
|
||||
uint8 *_firstBankData;
|
||||
uint8 *_lastBankData;
|
||||
BankSlot _bankSlots[49];
|
||||
BankSlot *_curBankSlot;
|
||||
const uint8 *_bankDataPtrs;
|
||||
uint16 _deathCutsceneCounter;
|
||||
bool _saveStateCompleted;
|
||||
|
||||
Game(SystemStub *, const char *dataPath, const char *savePath, Version ver);
|
||||
|
||||
void run();
|
||||
void resetGameState();
|
||||
void mainLoop();
|
||||
void updateTiming();
|
||||
void playCutscene(int id = -1);
|
||||
void loadLevelMap();
|
||||
void loadLevelData();
|
||||
void start();
|
||||
void drawIcon(uint8 iconNum, int16 x, int16 y, uint8 colMask);
|
||||
void drawCurrentInventoryItem();
|
||||
void printLevelCode();
|
||||
void showFinalScore();
|
||||
bool handleConfigPanel();
|
||||
bool handleContinueAbort();
|
||||
bool handleProtectionScreen();
|
||||
void printSaveStateCompleted();
|
||||
void drawLevelTexts();
|
||||
void drawStoryTexts();
|
||||
void prepareAnims();
|
||||
void prepareAnimsHelper(LivePGE *pge, int16 dx, int16 dy);
|
||||
void drawAnims();
|
||||
void drawAnimBuffer(uint8 stateNum, AnimBufferState *state);
|
||||
void drawObject(const uint8 *dataPtr, int16 x, int16 y, uint8 flags);
|
||||
void drawObjectFrame(const uint8 *dataPtr, int16 x, int16 y, uint8 flags);
|
||||
void decodeCharacterFrame(const uint8 *dataPtr, uint8 *dstPtr);
|
||||
void drawCharacter(const uint8 *dataPtr, int16 x, int16 y, uint8 a, uint8 b, uint8 flags);
|
||||
uint8 *loadBankData(uint16 MbkEntryNum);
|
||||
int loadMonsterSprites(LivePGE *pge);
|
||||
void playSound(uint8 sfxId, uint8 softVol);
|
||||
uint16 getRandomNumber();
|
||||
void changeLevel();
|
||||
uint16 getLineLength(const uint8 *str) const;
|
||||
void handleInventory();
|
||||
uint8 *findBankData(uint16 entryNum);
|
||||
|
||||
|
||||
// pieges
|
||||
bool _pge_playAnimSound;
|
||||
GroupPGE _pge_groups[256];
|
||||
GroupPGE *_pge_groupsTable[256];
|
||||
GroupPGE *_pge_nextFreeGroup;
|
||||
LivePGE *_pge_liveTable2[256]; // active pieges list (index = pge number)
|
||||
LivePGE *_pge_liveTable1[256]; // pieges list by room (index = room)
|
||||
LivePGE _pgeLive[256];
|
||||
uint8 _pge_currentPiegeRoom;
|
||||
bool _pge_currentPiegeFacingDir; // (false == left)
|
||||
bool _pge_processOBJ;
|
||||
uint8 _pge_inpKeysMask;
|
||||
uint16 _pge_opTempVar1;
|
||||
uint16 _pge_opTempVar2;
|
||||
uint16 _pge_compareVar1;
|
||||
uint16 _pge_compareVar2;
|
||||
|
||||
void pge_resetGroups();
|
||||
void pge_removeFromGroup(uint8 idx);
|
||||
int pge_isInGroup(LivePGE *pge_dst, uint16 group_id, uint16 counter);
|
||||
void pge_loadForCurrentLevel(uint16 idx);
|
||||
void pge_process(LivePGE *pge);
|
||||
void pge_setupNextAnimFrame(LivePGE *pge, GroupPGE *le);
|
||||
void pge_playAnimSound(LivePGE *pge, uint16 arg2);
|
||||
void pge_setupAnim(LivePGE *pge);
|
||||
int pge_execute(LivePGE *live_pge, InitPGE *init_pge, const Object *obj);
|
||||
void pge_prepare();
|
||||
void pge_setupDefaultAnim(LivePGE *pge);
|
||||
uint16 pge_processOBJ(LivePGE *pge);
|
||||
void pge_setupOtherPieges(LivePGE *pge, InitPGE *init_pge);
|
||||
void pge_addToCurrentRoomList(LivePGE *pge, uint8 room);
|
||||
void pge_getInput();
|
||||
int pge_op_isInpUp(ObjectOpcodeArgs *args);
|
||||
int pge_op_isInpBackward(ObjectOpcodeArgs *args);
|
||||
int pge_op_isInpDown(ObjectOpcodeArgs *args);
|
||||
int pge_op_isInpForward(ObjectOpcodeArgs *args);
|
||||
int pge_op_isInpUpMod(ObjectOpcodeArgs *args);
|
||||
int pge_op_isInpBackwardMod(ObjectOpcodeArgs *args);
|
||||
int pge_op_isInpDownMod(ObjectOpcodeArgs *args);
|
||||
int pge_op_isInpForwardMod(ObjectOpcodeArgs *args);
|
||||
int pge_op_isInpIdle(ObjectOpcodeArgs *args);
|
||||
int pge_op_isInpNoMod(ObjectOpcodeArgs *args);
|
||||
int pge_op_getCollision0u(ObjectOpcodeArgs *args);
|
||||
int pge_op_getCollision00(ObjectOpcodeArgs *args);
|
||||
int pge_op_getCollision0d(ObjectOpcodeArgs *args);
|
||||
int pge_op_getCollision1u(ObjectOpcodeArgs *args);
|
||||
int pge_op_getCollision10(ObjectOpcodeArgs *args);
|
||||
int pge_op_getCollision1d(ObjectOpcodeArgs *args);
|
||||
int pge_op_getCollision2u(ObjectOpcodeArgs *args);
|
||||
int pge_op_getCollision20(ObjectOpcodeArgs *args);
|
||||
int pge_op_getCollision2d(ObjectOpcodeArgs *args);
|
||||
int pge_op_doesNotCollide0u(ObjectOpcodeArgs *args);
|
||||
int pge_op_doesNotCollide00(ObjectOpcodeArgs *args);
|
||||
int pge_op_doesNotCollide0d(ObjectOpcodeArgs *args);
|
||||
int pge_op_doesNotCollide1u(ObjectOpcodeArgs *args);
|
||||
int pge_op_doesNotCollide10(ObjectOpcodeArgs *args);
|
||||
int pge_op_doesNotCollide1d(ObjectOpcodeArgs *args);
|
||||
int pge_op_doesNotCollide2u(ObjectOpcodeArgs *args);
|
||||
int pge_op_doesNotCollide20(ObjectOpcodeArgs *args);
|
||||
int pge_op_doesNotCollide2d(ObjectOpcodeArgs *args);
|
||||
int pge_op_collides0o0d(ObjectOpcodeArgs *args);
|
||||
int pge_op_collides2o2d(ObjectOpcodeArgs *args);
|
||||
int pge_op_collides0o0u(ObjectOpcodeArgs *args);
|
||||
int pge_op_collides2o2u(ObjectOpcodeArgs *args);
|
||||
int pge_op_collides2u2o(ObjectOpcodeArgs *args);
|
||||
int pge_op_isInGroup(ObjectOpcodeArgs *args);
|
||||
int pge_op_updateGroup0(ObjectOpcodeArgs *args);
|
||||
int pge_op_updateGroup1(ObjectOpcodeArgs *args);
|
||||
int pge_op_updateGroup2(ObjectOpcodeArgs *args);
|
||||
int pge_op_updateGroup3(ObjectOpcodeArgs *args);
|
||||
int pge_op_isPiegeDead(ObjectOpcodeArgs *args);
|
||||
int pge_op_collides1u2o(ObjectOpcodeArgs *args);
|
||||
int pge_op_collides1u1o(ObjectOpcodeArgs *args);
|
||||
int pge_op_collides1o1u(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x2B(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x2C(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x2D(ObjectOpcodeArgs *args);
|
||||
int pge_op_nop(ObjectOpcodeArgs *args);
|
||||
int pge_op_pickupObject(ObjectOpcodeArgs *args);
|
||||
int pge_op_addItemToInventory(ObjectOpcodeArgs *args);
|
||||
int pge_op_copyPiege(ObjectOpcodeArgs *args);
|
||||
int pge_op_canUseCurrentInventoryItem(ObjectOpcodeArgs *args);
|
||||
int pge_op_removeItemFromInventory(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x34(ObjectOpcodeArgs *args);
|
||||
int pge_op_isInpMod(ObjectOpcodeArgs *args);
|
||||
int pge_op_setCollisionState1(ObjectOpcodeArgs *args);
|
||||
int pge_op_setCollisionState0(ObjectOpcodeArgs *args);
|
||||
int pge_op_isInGroup1(ObjectOpcodeArgs *args);
|
||||
int pge_op_isInGroup2(ObjectOpcodeArgs *args);
|
||||
int pge_op_isInGroup3(ObjectOpcodeArgs *args);
|
||||
int pge_op_isInGroup4(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x3C(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x3D(ObjectOpcodeArgs *args);
|
||||
int pge_op_setPiegeCounter(ObjectOpcodeArgs *args);
|
||||
int pge_op_decPiegeCounter(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x40(ObjectOpcodeArgs *args);
|
||||
int pge_op_wakeUpPiege(ObjectOpcodeArgs *args);
|
||||
int pge_op_removePiege(ObjectOpcodeArgs *args);
|
||||
int pge_op_removePiegeIfNotNear(ObjectOpcodeArgs *args);
|
||||
int pge_op_loadPiegeCounter(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x45(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x46(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x47(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x48(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x49(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x4A(ObjectOpcodeArgs *args);
|
||||
int pge_op_killPiege(ObjectOpcodeArgs *args);
|
||||
int pge_op_isInCurrentRoom(ObjectOpcodeArgs *args);
|
||||
int pge_op_isNotInCurrentRoom(ObjectOpcodeArgs *args);
|
||||
int pge_op_scrollPosY(ObjectOpcodeArgs *args);
|
||||
int pge_op_playDefaultDeathCutscene(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x50(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x52(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x53(ObjectOpcodeArgs *args);
|
||||
int pge_op_isPiegeNear(ObjectOpcodeArgs *args);
|
||||
int pge_op_setLife(ObjectOpcodeArgs *args);
|
||||
int pge_op_incLife(ObjectOpcodeArgs *args);
|
||||
int pge_op_setPiegeDefaultAnim(ObjectOpcodeArgs *args);
|
||||
int pge_op_setLifeCounter(ObjectOpcodeArgs *args);
|
||||
int pge_op_decLifeCounter(ObjectOpcodeArgs *args);
|
||||
int pge_op_playCutscene(ObjectOpcodeArgs *args);
|
||||
int pge_op_isTempVar2Set(ObjectOpcodeArgs *args);
|
||||
int pge_op_playDeathCutscene(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x5D(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x5E(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x5F(ObjectOpcodeArgs *args);
|
||||
int pge_op_findAndCopyPiege(ObjectOpcodeArgs *args);
|
||||
int pge_op_isInRandomRange(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x62(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x63(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x64(ObjectOpcodeArgs *args);
|
||||
int pge_op_addToCredits(ObjectOpcodeArgs *args);
|
||||
int pge_op_subFromCredits(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x67(ObjectOpcodeArgs *args);
|
||||
int pge_op_setCollisionState2(ObjectOpcodeArgs *args);
|
||||
int pge_op_saveState(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x6A(ObjectOpcodeArgs *args);
|
||||
int pge_op_isInGroupSlice(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x6C(ObjectOpcodeArgs *args);
|
||||
int pge_op_isCollidingObject(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x6E(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x6F(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x70(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x71(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x72(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x73(ObjectOpcodeArgs *args);
|
||||
int pge_op_collides4u(ObjectOpcodeArgs *args);
|
||||
int pge_op_doesNotCollide4u(ObjectOpcodeArgs *args);
|
||||
int pge_op_isBelowConrad(ObjectOpcodeArgs *args);
|
||||
int pge_op_isAboveConrad(ObjectOpcodeArgs *args);
|
||||
int pge_op_isNotFacingConrad(ObjectOpcodeArgs *args);
|
||||
int pge_op_isFacingConrad(ObjectOpcodeArgs *args);
|
||||
int pge_op_collides2u1u(ObjectOpcodeArgs *args);
|
||||
int pge_op_displayText(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x7C(ObjectOpcodeArgs *args);
|
||||
int pge_op_playSound(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x7E(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x7F(ObjectOpcodeArgs *args);
|
||||
int pge_op_setPiegePosX(ObjectOpcodeArgs *args);
|
||||
int pge_op_setPiegePosModX(ObjectOpcodeArgs *args);
|
||||
int pge_op_changeRoom(ObjectOpcodeArgs *args);
|
||||
int pge_op_hasInventoryItem(ObjectOpcodeArgs *args);
|
||||
int pge_op_changeLevel(ObjectOpcodeArgs *args);
|
||||
int pge_op_shakeScreen(ObjectOpcodeArgs *args);
|
||||
int pge_o_unk0x86(ObjectOpcodeArgs *args);
|
||||
int pge_op_playSoundGroup(ObjectOpcodeArgs *args);
|
||||
int pge_op_adjustPos(ObjectOpcodeArgs *args);
|
||||
int pge_op_setTempVar1(ObjectOpcodeArgs *args);
|
||||
int pge_op_isTempVar1Set(ObjectOpcodeArgs *args);
|
||||
int pge_setCurrentInventoryObject(LivePGE *pge);
|
||||
void pge_updateInventory(LivePGE *pge1, LivePGE *pge2);
|
||||
void pge_reorderInventory(LivePGE *pge);
|
||||
LivePGE *pge_getInventoryItemBefore(LivePGE *pge, LivePGE *last_pge);
|
||||
void pge_addToInventory(LivePGE *pge1, LivePGE *pge2, LivePGE *pge3);
|
||||
int pge_updateCollisionState(LivePGE *pge, int16 pge_dy, uint8 var8);
|
||||
int pge_ZOrder(LivePGE *pge, int16 num, pge_ZOrderCallback compare, uint16 unk);
|
||||
void pge_updateGroup(uint8 idx, uint8 unk1, int16 unk2);
|
||||
void pge_removeFromInventory(LivePGE *pge1, LivePGE *pge2, LivePGE *pge3);
|
||||
int pge_ZOrderByAnimY(LivePGE *pge1, LivePGE *pge2, uint8 comp, uint8 comp2);
|
||||
int pge_ZOrderByAnimYIfType(LivePGE *pge1, LivePGE *pge2, uint8 comp, uint8 comp2);
|
||||
int pge_ZOrderIfIndex(LivePGE *pge1, LivePGE *pge2, uint8 comp, uint8 comp2);
|
||||
int pge_ZOrderByIndex(LivePGE *pge1, LivePGE *pge2, uint8 comp, uint8 comp2);
|
||||
int pge_ZOrderByObj(LivePGE *pge1, LivePGE *pge2, uint8 comp, uint8 comp2);
|
||||
int pge_ZOrderIfDifferentDirection(LivePGE *pge1, LivePGE *pge2, uint8 comp, uint8 comp2);
|
||||
int pge_ZOrderIfSameDirection(LivePGE *pge1, LivePGE *pge2, uint8 comp, uint8 comp2);
|
||||
int pge_ZOrderIfTypeAndSameDirection(LivePGE *pge1, LivePGE *pge2, uint8 comp, uint8 comp2);
|
||||
int pge_ZOrderIfTypeAndDifferentDirection(LivePGE *pge1, LivePGE *pge2, uint8 comp, uint8 comp2);
|
||||
int pge_ZOrderByNumber(LivePGE *pge1, LivePGE *pge2, uint8 comp, uint8 comp2);
|
||||
|
||||
|
||||
// collision
|
||||
CollisionSlot _col_slots[256];
|
||||
uint8 _col_curPos;
|
||||
CollisionSlot *_col_slotsTable[256];
|
||||
CollisionSlot *_col_curSlot;
|
||||
CollisionSlot2 _col_slots2[256];
|
||||
CollisionSlot2 *_col_slots2Cur;
|
||||
CollisionSlot2 *_col_slots2Next;
|
||||
uint8 _col_activeCollisionSlots[0x30 * 3]; // left, current, right
|
||||
uint8 _col_currentLeftRoom;
|
||||
uint8 _col_currentRightRoom;
|
||||
int16 _col_currentPiegeGridPosX;
|
||||
int16 _col_currentPiegeGridPosY;
|
||||
|
||||
void col_prepareRoomState();
|
||||
void col_clearState();
|
||||
LivePGE *col_findPiege(LivePGE *pge, uint16 arg2);
|
||||
int16 col_findSlot(int16 pos);
|
||||
void col_preparePiegeState(LivePGE *dst_pge);
|
||||
uint16 col_getGridPos(LivePGE *pge, int16 dx);
|
||||
int16 col_getGridData(LivePGE *pge, int16 dy, int16 dx);
|
||||
uint8 col_findCurrentCollidingObject(LivePGE *pge, uint8 n1, uint8 n2, uint8 n3, LivePGE **pge_out);
|
||||
int16 col_detectHit(LivePGE *pge, int16 arg2, int16 arg4, col_Callback1 callback1, col_Callback2 callback2, int16 argA, int16 argC);
|
||||
int col_detectHitCallback2(LivePGE *pge1, LivePGE *pge2, int16 unk1, int16 unk2);
|
||||
int col_detectHitCallback3(LivePGE *pge1, LivePGE *pge2, int16 unk1, int16 unk2);
|
||||
int col_detectHitCallback4(LivePGE *pge1, LivePGE *pge2, int16 unk1, int16 unk2);
|
||||
int col_detectHitCallback5(LivePGE *pge1, LivePGE *pge2, int16 unk1, int16 unk2);
|
||||
int col_detectHitCallback1(LivePGE *pge, int16 dy, int16 unk1, int16 unk2);
|
||||
int col_detectHitCallback6(LivePGE *pge, int16 dy, int16 unk1, int16 unk2);
|
||||
int col_detectHitCallbackHelper(LivePGE *pge, int16 unk1);
|
||||
int col_detectGunHitCallback1(LivePGE *pge, int16 arg2, int16 arg4, int16 arg6);
|
||||
int col_detectGunHitCallback2(LivePGE *pge1, LivePGE *pge2, int16 arg4, int16);
|
||||
int col_detectGunHitCallback3(LivePGE *pge1, LivePGE *pge2, int16 arg4, int16);
|
||||
int col_detectGunHit(LivePGE *pge, int16 arg2, int16 arg4, col_Callback1 callback1, col_Callback2 callback2, int16 argA, int16 argC);
|
||||
|
||||
|
||||
// input
|
||||
uint8 _inp_lastKeysHit;
|
||||
uint8 _inp_lastKeysHitLeftRight;
|
||||
bool _inp_replay;
|
||||
bool _inp_record;
|
||||
File *_inp_demo;
|
||||
|
||||
void inp_handleSpecialKeys();
|
||||
void inp_update();
|
||||
|
||||
|
||||
// save/load state
|
||||
uint8 _stateSlot;
|
||||
bool _validSaveState;
|
||||
|
||||
void makeGameDemoName(char *buf);
|
||||
void makeGameStateName(uint8 slot, char *buf);
|
||||
bool saveGameState(uint8 slot);
|
||||
bool loadGameState(uint8 slot);
|
||||
void saveState(File *f);
|
||||
void loadState(File *f);
|
||||
};
|
||||
|
||||
#endif // __GAME_H__
|
||||
@@ -0,0 +1,718 @@
|
||||
/* REminiscence - Flashback interpreter
|
||||
* Copyright (C) 2005-2007 Gregory Montoir
|
||||
*
|
||||
* This program 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.
|
||||
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "graphics.h"
|
||||
|
||||
|
||||
void Graphics::setClippingRect(int16 rx, int16 ry, int16 rw, int16 rh) {
|
||||
debug(DBG_VIDEO, "Graphics::setClippingRect(%d, %d, %d, %d)", rx, ry, rw, rh);
|
||||
_crx = rx;
|
||||
_cry = ry;
|
||||
_crw = rw;
|
||||
_crh = rh;
|
||||
}
|
||||
|
||||
void Graphics::drawPoint(uint8 color, const Point *pt) {
|
||||
debug(DBG_VIDEO, "Graphics::drawPoint() col=0x%X x=%d, y=%d", color, pt->x, pt->y);
|
||||
if (pt->x >= 0 && pt->x < _crw && pt->y >= 0 && pt->y < _crh) {
|
||||
*(_layer + (pt->y + _cry) * 256 + pt->x + _crx) = color;
|
||||
}
|
||||
}
|
||||
|
||||
void Graphics::drawLine(uint8 color, const Point *pt1, const Point *pt2) {
|
||||
debug(DBG_VIDEO, "Graphics::drawLine()");
|
||||
int16 dxincr1 = 1;
|
||||
int16 dyincr1 = 1;
|
||||
int16 dx = pt2->x - pt1->x;
|
||||
if (dx < 0) {
|
||||
dxincr1 = -1;
|
||||
dx = -dx;
|
||||
}
|
||||
int16 dy = pt2->y - pt1->y;
|
||||
if (dy < 0) {
|
||||
dyincr1 = -1;
|
||||
dy = -dy;
|
||||
}
|
||||
int16 dxincr2, dyincr2, delta1, delta2;
|
||||
if (dx < dy) {
|
||||
dxincr2 = 0;
|
||||
dyincr2 = 1;
|
||||
delta1 = dx;
|
||||
delta2 = dy;
|
||||
if (dyincr1 < 0) {
|
||||
dyincr2 = -1;
|
||||
}
|
||||
} else {
|
||||
dxincr2 = 1;
|
||||
dyincr2 = 0;
|
||||
delta1 = dy;
|
||||
delta2 = dx;
|
||||
if (dxincr1 < 0) {
|
||||
dxincr2 = -1;
|
||||
}
|
||||
}
|
||||
Point pt;
|
||||
pt.x = pt1->x;
|
||||
pt.y = pt1->y;
|
||||
int16 octincr1 = delta1 * 2 - delta2 * 2;
|
||||
int16 octincr2 = delta1 * 2;
|
||||
int16 oct = delta1 * 2 - delta2;
|
||||
if (delta2 >= 0) {
|
||||
drawPoint(color, &pt);
|
||||
while (--delta2 >= 0) {
|
||||
if (oct >= 0) {
|
||||
pt.x += dxincr1;
|
||||
pt.y += dyincr1;
|
||||
oct += octincr1;
|
||||
} else {
|
||||
pt.x += dxincr2;
|
||||
pt.y += dyincr2;
|
||||
oct += octincr2;
|
||||
}
|
||||
drawPoint(color, &pt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Graphics::addEllipseRadius(int16 y, int16 x1, int16 x2) {
|
||||
debug(DBG_VIDEO, "Graphics::addEllipseRadius()");
|
||||
if (y >= 0 && y <= _crh) {
|
||||
y = (y - _areaPoints[0]) * 2;
|
||||
if (x1 < 0) {
|
||||
x1 = 0;
|
||||
}
|
||||
if (x2 >= _crw) {
|
||||
x2 = _crw - 1;
|
||||
}
|
||||
_areaPoints[y + 1] = x1;
|
||||
_areaPoints[y + 2] = x2;
|
||||
}
|
||||
}
|
||||
|
||||
void Graphics::drawEllipse(uint8 color, bool hasAlpha, const Point *pt, int16 rx, int16 ry) {
|
||||
debug(DBG_VIDEO, "Graphics::drawEllipse()");
|
||||
bool flag = false;
|
||||
int16 y = pt->y - ry;
|
||||
if (y < 0) {
|
||||
y = 0;
|
||||
}
|
||||
if (y < _crh) {
|
||||
if (pt->y + ry >= 0) {
|
||||
_areaPoints[0] = y;
|
||||
int32 dy = 0;
|
||||
int32 rxsq = rx * rx;
|
||||
int32 rxsq2 = rx * rx * 2;
|
||||
int32 rxsq4 = rx * rx * 4;
|
||||
int32 rysq = ry * ry;
|
||||
int32 rysq2 = ry * ry * 2;
|
||||
int32 rysq4 = ry * ry * 4;
|
||||
|
||||
int32 dx = 0;
|
||||
int32 b = rx * ((rysq2 & 0xFFFF) + (rysq2 >> 16));
|
||||
int32 a = 2 * b;
|
||||
|
||||
int32 ny1, ny2, nx1, nx2;
|
||||
ny1 = ny2 = rysq4 / 2 - a + rxsq;
|
||||
nx1 = nx2 = rxsq2 - b + rysq;
|
||||
|
||||
while (ny2 < 0) {
|
||||
int16 x2 = pt->x + rx;
|
||||
int16 x1 = pt->x - rx;
|
||||
int16 by = pt->y + dy;
|
||||
int16 ty = pt->y - dy;
|
||||
if (x1 != x2) {
|
||||
addEllipseRadius(by, x1, x2);
|
||||
if (ty < by) {
|
||||
addEllipseRadius(ty, x1, x2);
|
||||
}
|
||||
}
|
||||
dy += 1;
|
||||
dx += rxsq4;
|
||||
nx1 = dx;
|
||||
if (nx2 < 0) {
|
||||
nx2 += nx1 + rxsq2;
|
||||
ny2 += nx1;
|
||||
} else {
|
||||
--rx;
|
||||
a -= rysq4;
|
||||
ny1 = a;
|
||||
nx2 += nx1 + rxsq2 - ny1;
|
||||
ny2 += nx1 + rysq2 - ny1;
|
||||
}
|
||||
}
|
||||
|
||||
while (rx >= 0) {
|
||||
bool flag2 = false;
|
||||
int16 x2 = pt->x + rx;
|
||||
int16 x1 = pt->x - rx;
|
||||
int16 by = pt->y + dy;
|
||||
int16 ty = pt->y - dy;
|
||||
if (!flag && x1 != x2) {
|
||||
flag2 = true;
|
||||
addEllipseRadius(by, x1, x2);
|
||||
if (ty < by) {
|
||||
addEllipseRadius(ty, x1, x2);
|
||||
}
|
||||
}
|
||||
if (flag2) {
|
||||
flag = true;
|
||||
}
|
||||
--rx;
|
||||
a -= rysq4;
|
||||
nx1 = a;
|
||||
if (ny2 < 0) {
|
||||
++dy;
|
||||
flag = false;
|
||||
dx += rxsq4;
|
||||
ny2 += dx - nx1 + rysq2;
|
||||
ny1 = dx - nx1 + rysq2;
|
||||
} else {
|
||||
ny2 += rysq2 - nx1;
|
||||
ny1 = rysq2 - nx1;
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
++dy;
|
||||
}
|
||||
|
||||
while (dy <= ry) {
|
||||
int16 ty = pt->y - dy;
|
||||
int16 by = pt->y + dy;
|
||||
if (ty < by) {
|
||||
addEllipseRadius(ty, pt->x, pt->x);
|
||||
}
|
||||
addEllipseRadius(by, pt->x, pt->x);
|
||||
++dy;
|
||||
}
|
||||
y = pt->y + ry + 1;
|
||||
if (y > _crh) {
|
||||
y = _crh;
|
||||
}
|
||||
y = (y - _areaPoints[0]) * 2;
|
||||
_areaPoints[y + 1] = -1;
|
||||
fillArea(color, hasAlpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Graphics::fillArea(uint8 color, bool hasAlpha) {
|
||||
debug(DBG_VIDEO, "Graphics::fillArea()");
|
||||
int16 *pts = _areaPoints;
|
||||
uint8 *dst = _layer + (_cry + *pts++) * 256 + _crx;
|
||||
int16 x1 = *pts++;
|
||||
if (x1 >= 0) {
|
||||
if (hasAlpha && color > 0xC7) {
|
||||
do {
|
||||
int16 x2 = *pts++;
|
||||
if (x2 < _crw && x2 >= x1) {
|
||||
int len = x2 - x1 + 1;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
*(dst + x1 + i) |= color & 8; // XXX 0x88
|
||||
}
|
||||
}
|
||||
dst += 256;
|
||||
x1 = *pts++;
|
||||
} while (x1 >= 0);
|
||||
} else {
|
||||
do {
|
||||
int16 x2 = *pts++;
|
||||
if (x2 < _crw && x2 >= x1) {
|
||||
int len = x2 - x1 + 1;
|
||||
memset(dst + x1, color, len);
|
||||
}
|
||||
dst += 256;
|
||||
x1 = *pts++;
|
||||
} while (x1 >= 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Graphics::drawSegment(uint8 color, bool hasAlpha, int16 ys, const Point *pts, uint8 numPts) {
|
||||
debug(DBG_VIDEO, "Graphics::drawSegment()");
|
||||
int16 xmin, xmax, ymin, ymax;
|
||||
xmin = xmax = pts[0].x;
|
||||
ymin = ymax = pts[0].y;
|
||||
for (int i = 1; i < numPts; ++i) {
|
||||
int16 x = pts[i].x;
|
||||
int16 y = pts[i].y;
|
||||
if ((xmin << 16) + ymin > (x << 16) + y) {
|
||||
xmin = x;
|
||||
ymin = y;
|
||||
}
|
||||
if ((xmax << 16) + ymax < (x << 16) + y) {
|
||||
xmax = x;
|
||||
ymax = y;
|
||||
}
|
||||
}
|
||||
if (xmin < 0) {
|
||||
xmin = 0;
|
||||
}
|
||||
if (xmax >= _crw) {
|
||||
xmax = _crw - 1;
|
||||
}
|
||||
_areaPoints[0] = ys;
|
||||
_areaPoints[1] = xmin;
|
||||
_areaPoints[2] = xmax;
|
||||
_areaPoints[3] = -1;
|
||||
fillArea(color, hasAlpha);
|
||||
}
|
||||
|
||||
void Graphics::drawPolygonOutline(uint8 color, const Point *pts, uint8 numPts) {
|
||||
debug(DBG_VIDEO, "Graphics::drawPolygonOutline()");
|
||||
assert(numPts >= 2);
|
||||
int i;
|
||||
for (i = 0; i < numPts - 1; ++i) {
|
||||
drawLine(color, &pts[i], &pts[i + 1]);
|
||||
}
|
||||
drawLine(color, &pts[i], &pts[0]);
|
||||
}
|
||||
|
||||
static int32 calcPolyStep1(int16 dx, int16 dy) {
|
||||
debug(DBG_VIDEO, "Graphics::calcPolyStep1()");
|
||||
assert(dy != 0);
|
||||
int32 a = dx * 256;
|
||||
if ((a >> 16) < dy) {
|
||||
a = ((int16)(a / dy)) * 256;
|
||||
} else {
|
||||
a = ((a / 256) / dy) & 0xFFFF0000;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
static int32 calcPolyStep2(int16 dx, int16 dy) {
|
||||
debug(DBG_VIDEO, "Graphics::calcPolyStep2()");
|
||||
assert(dy != 0);
|
||||
int32 a = dx * 256;
|
||||
if ((a >> 16) < dy) {
|
||||
a = ((int16)(a / dy)) * 256;
|
||||
} else {
|
||||
a = ((a / 256) / dy) << 16;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
static void drawPolygonHelper1(int32 &x, int16 &y, int32 &step, int16 *&pts, int16 *&start) {
|
||||
bool first = true;
|
||||
x = pts[0];
|
||||
y = pts[1];
|
||||
int16 dy, dx;
|
||||
do {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
x = *pts;
|
||||
}
|
||||
--pts;
|
||||
dy = *pts - y;
|
||||
--pts;
|
||||
dx = *pts - x;
|
||||
} while (dy <= 0 && start < pts);
|
||||
x <<= 16;
|
||||
if (dy > 0) {
|
||||
step = calcPolyStep1(dx, dy);
|
||||
}
|
||||
}
|
||||
|
||||
static void drawPolygonHelper2(int32 &x, int16 &y, int32 &step, int16 *&pts, int16 *&start) {
|
||||
bool first = true;
|
||||
x = *start++;
|
||||
y = *start++;
|
||||
int16 dy, dx;
|
||||
do {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
x = *start;
|
||||
start += 2;
|
||||
}
|
||||
dy = start[1] - y;
|
||||
dx = start[0] - x;
|
||||
} while (dy <= 0 && start < pts);
|
||||
x <<= 16;
|
||||
if (dy > 0) {
|
||||
step = calcPolyStep2(dx, dy);
|
||||
}
|
||||
}
|
||||
|
||||
void Graphics::drawPolygon(uint8 color, bool hasAlpha, const Point *pts, uint8 numPts) {
|
||||
debug(DBG_VIDEO, "Graphics::drawPolygon()");
|
||||
assert(numPts * 4 < 0x100);
|
||||
|
||||
int16 *apts1 = &_areaPoints[0x100];
|
||||
int16 *apts2 = &_areaPoints[0x100 + numPts * 2];
|
||||
|
||||
int16 xmin, xmax, ymin, ymax;
|
||||
xmin = xmax = pts[0].x;
|
||||
ymin = ymax = pts[0].y;
|
||||
|
||||
int16 *spts = apts1;
|
||||
*apts1++ = *apts2++ = pts[0].x;
|
||||
*apts1++ = *apts2++ = pts[0].y;
|
||||
|
||||
for (int p = 1; p < numPts; ++p) {
|
||||
int16 x = pts[p].x;
|
||||
int16 y = pts[p].y;
|
||||
if (ymin > y) {
|
||||
ymin = y;
|
||||
spts = apts1;
|
||||
}
|
||||
if (ymax < y) {
|
||||
ymax = y;
|
||||
}
|
||||
*apts1++ = *apts2++ = x;
|
||||
*apts1++ = *apts2++ = y;
|
||||
|
||||
if (xmin > x) {
|
||||
xmin = x;
|
||||
}
|
||||
if (xmax < x) {
|
||||
xmax = x;
|
||||
}
|
||||
}
|
||||
int16 *rpts = _areaPoints;
|
||||
if (xmax < 0 || xmin >= _crw || ymax < 0 || ymin >= _crh) {
|
||||
return;
|
||||
}
|
||||
if (numPts == 2) {
|
||||
drawLine(color, &pts[0], &pts[1]);
|
||||
return;
|
||||
}
|
||||
if (ymax == ymin) {
|
||||
drawSegment(color, hasAlpha, ymax, pts, numPts);
|
||||
return;
|
||||
}
|
||||
int16 x, dx, y, dy;
|
||||
int32 a, b, d, f;
|
||||
int32 xstep1 = 0;
|
||||
int32 xstep2 = 0;
|
||||
|
||||
apts1 = &spts[numPts * 2];
|
||||
xmax = _crw - 1;
|
||||
ymax = _crh - 1;
|
||||
int32 l1 = 65536;
|
||||
int32 l2 = -65536;
|
||||
if (ymin < 0) {
|
||||
int16 x0, y0;
|
||||
do {
|
||||
--apts1;
|
||||
y0 = *apts1;
|
||||
--apts1;
|
||||
x0 = *apts1;
|
||||
} while (y0 < 0);
|
||||
x = apts1[2];
|
||||
y = apts1[3];
|
||||
dy = y0 - y;
|
||||
dx = x0 - x;
|
||||
xstep1 = (dy << 16) | dx;
|
||||
assert(dy != 0);
|
||||
a = y * dx / dy;
|
||||
b = (x - a) << 16;
|
||||
d = xstep1 = calcPolyStep1(dx, dy);
|
||||
if (d < 0) {
|
||||
d = -d;
|
||||
}
|
||||
if (d < l1) {
|
||||
d = l2;
|
||||
}
|
||||
d /= 2;
|
||||
b -= d;
|
||||
|
||||
do {
|
||||
x0 = *spts++;
|
||||
y0 = *spts++;
|
||||
} while (*(spts + 1) < 0);
|
||||
dy = spts[1] - y0;
|
||||
dx = spts[0] - x0;
|
||||
xstep2 = (dy << 16) | dx;
|
||||
assert(dy != 0);
|
||||
a = y0 * dx / dy;
|
||||
f = (x0 - a) << 16;
|
||||
d = xstep2 = calcPolyStep2(dx, dy);
|
||||
if (d < 0) {
|
||||
d = -d;
|
||||
}
|
||||
if (d < l1) {
|
||||
d = l1;
|
||||
}
|
||||
d /= 2;
|
||||
f += d;
|
||||
ymin = 0;
|
||||
*rpts++ = 0;
|
||||
goto gfx_startLine;
|
||||
}
|
||||
|
||||
*rpts++ = ymin;
|
||||
|
||||
gfx_startNewLine:
|
||||
drawPolygonHelper2(f, ymin, xstep2, apts1, spts);
|
||||
if (spts >= apts1) {
|
||||
b = apts1[0] << 16;
|
||||
dy = apts1[1];
|
||||
if (dy <= ymax) goto gfx_endLine;
|
||||
goto gfx_fillArea;
|
||||
}
|
||||
drawPolygonHelper1(b, ymin, xstep1, apts1, spts);
|
||||
d = xstep1;
|
||||
if (d < 0) {
|
||||
if (d >= l2) {
|
||||
d = l1;
|
||||
}
|
||||
d /= 2;
|
||||
b += d;
|
||||
}
|
||||
d = xstep2;
|
||||
if (d >= 0) {
|
||||
if (d <= l1) {
|
||||
d = l1;
|
||||
}
|
||||
d /= 2;
|
||||
f += d;
|
||||
}
|
||||
d = b;
|
||||
if (d < 0) {
|
||||
d = 0;
|
||||
}
|
||||
x = f >> 16;
|
||||
if (x > xmax) {
|
||||
x = xmax;
|
||||
}
|
||||
*rpts++ = d >> 16;
|
||||
*rpts++ = x;
|
||||
++ymin;
|
||||
d = xstep1;
|
||||
if (d >= 0) {
|
||||
if (d <= l1) {
|
||||
d = l1;
|
||||
}
|
||||
d /= 2;
|
||||
}
|
||||
b += d;
|
||||
d = xstep2;
|
||||
if (d < 0) {
|
||||
if (d >= l2) {
|
||||
d = l1;
|
||||
}
|
||||
d /= 2;
|
||||
}
|
||||
f += d;
|
||||
|
||||
gfx_startLine:
|
||||
while (1) {
|
||||
dy = apts1[1];
|
||||
if (spts >= apts1) {
|
||||
break;
|
||||
} else if (dy > spts[1]) {
|
||||
dy = spts[1];
|
||||
if (dy > ymax) {
|
||||
goto gfx_drawPolygonEnd;
|
||||
}
|
||||
dy -= ymin;
|
||||
if (dy > 0) {
|
||||
--dy;
|
||||
do {
|
||||
a = b;
|
||||
if (a < 0) {
|
||||
a = 0;
|
||||
}
|
||||
x = f >> 16;
|
||||
if (x > xmax) {
|
||||
x = xmax;
|
||||
}
|
||||
*rpts++ = a >> 16;
|
||||
*rpts++ = x;
|
||||
b += xstep1;
|
||||
f += xstep2;
|
||||
--dy;
|
||||
} while (dy >= 0);
|
||||
}
|
||||
drawPolygonHelper2(f, ymin, xstep2, apts1, spts);
|
||||
d = xstep2;
|
||||
if (d >= 0) {
|
||||
if (d <= l1) {
|
||||
d = l1;
|
||||
}
|
||||
d /= 2;
|
||||
f += d;
|
||||
} else {
|
||||
d = b;
|
||||
if (d < 0) {
|
||||
d = 0;
|
||||
}
|
||||
x = f >> 16;
|
||||
if (x > xmax) {
|
||||
x = xmax;
|
||||
}
|
||||
*rpts++ = d >> 16;
|
||||
*rpts++ = x;
|
||||
++ymin;
|
||||
d = xstep2;
|
||||
if (d >= l2) {
|
||||
d = l1;
|
||||
}
|
||||
d /= 2;
|
||||
f += d;
|
||||
b += xstep1;
|
||||
}
|
||||
} else if (dy == spts[1]) {
|
||||
if (dy > ymax) goto gfx_drawPolygonEnd;
|
||||
dy -= ymin;
|
||||
if (dy > 0) {
|
||||
--dy;
|
||||
do {
|
||||
a = b;
|
||||
if (a < 0) {
|
||||
a = 0;
|
||||
}
|
||||
x = f >> 16;
|
||||
if (x > xmax) {
|
||||
x = xmax;
|
||||
}
|
||||
*rpts++ = a >> 16;
|
||||
*rpts++ = x;
|
||||
b += xstep1;
|
||||
f += xstep2;
|
||||
--dy;
|
||||
} while (dy >= 0);
|
||||
}
|
||||
goto gfx_startNewLine;
|
||||
} else if (dy > ymax) {
|
||||
goto gfx_drawPolygonEnd;
|
||||
} else {
|
||||
dy -= ymin;
|
||||
if (dy > 0) {
|
||||
--dy;
|
||||
do {
|
||||
a = b;
|
||||
if (a < 0) {
|
||||
a = 0;
|
||||
}
|
||||
x = f >> 16;
|
||||
if (x > xmax) {
|
||||
x = xmax;
|
||||
}
|
||||
*rpts++ = a >> 16;
|
||||
*rpts++ = x;
|
||||
b += xstep1;
|
||||
f += xstep2;
|
||||
--dy;
|
||||
} while (dy >= 0);
|
||||
}
|
||||
drawPolygonHelper1(b, ymin, xstep1, apts1, spts);
|
||||
d = xstep1;
|
||||
if (d < 0) {
|
||||
if (d >= l2) {
|
||||
d = l1;
|
||||
}
|
||||
d /= 2;
|
||||
b += d;
|
||||
} else {
|
||||
d = b;
|
||||
if (d < 0) {
|
||||
d = 0;
|
||||
}
|
||||
x = f >> 16;
|
||||
if (x > xmax) {
|
||||
x = xmax;
|
||||
}
|
||||
*rpts++ = d >> 16;
|
||||
*rpts++ = x;
|
||||
++ymin;
|
||||
d = xstep1;
|
||||
if (d <= l1) {
|
||||
d = l1;
|
||||
}
|
||||
d /= 2;
|
||||
b += d;
|
||||
f += xstep2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dy > ymax) goto gfx_drawPolygonEnd;
|
||||
dy -= ymin;
|
||||
if (dy < 0) goto gfx_fillArea;
|
||||
if (dy > 0) {
|
||||
--dy;
|
||||
do {
|
||||
a = b;
|
||||
if (a < 0) {
|
||||
a = 0;
|
||||
}
|
||||
x = f >> 16;
|
||||
if (x > xmax) {
|
||||
x = xmax;
|
||||
}
|
||||
*rpts++ = a >> 16;
|
||||
*rpts++ = x;
|
||||
b += xstep1;
|
||||
f += xstep2;
|
||||
--dy;
|
||||
} while (dy >= 0);
|
||||
}
|
||||
|
||||
b = f = (apts1[0] << 16) | apts1[1];
|
||||
|
||||
gfx_endLine:
|
||||
d = xstep1;
|
||||
if (d >= 0) {
|
||||
if (d >= l1) {
|
||||
d /= 2;
|
||||
b -= d;
|
||||
}
|
||||
}
|
||||
d = xstep2;
|
||||
if (d < 0) {
|
||||
d /= 2;
|
||||
f -= d;
|
||||
}
|
||||
a = b;
|
||||
if (a < 0) {
|
||||
a = 0;
|
||||
}
|
||||
x = f >> 16;
|
||||
if (x > xmax) {
|
||||
x = xmax;
|
||||
}
|
||||
*rpts++ = a >> 16;
|
||||
*rpts++ = x;
|
||||
goto gfx_fillArea;
|
||||
|
||||
gfx_drawPolygonEnd:
|
||||
dy = ymax - ymin;
|
||||
if (dy >= 0) {
|
||||
do {
|
||||
a = b;
|
||||
if (a < 0) {
|
||||
a = 0;
|
||||
}
|
||||
x = f >> 16;
|
||||
if (x > xmax) {
|
||||
x = xmax;
|
||||
}
|
||||
*rpts++ = a >> 16;
|
||||
*rpts++ = x;
|
||||
b += xstep1;
|
||||
f += xstep2;
|
||||
--dy;
|
||||
} while (dy >= 0);
|
||||
}
|
||||
|
||||
gfx_fillArea:
|
||||
*rpts++ = -1;
|
||||
fillArea(color, hasAlpha);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/* REminiscence - Flashback interpreter
|
||||
* Copyright (C) 2005-2007 Gregory Montoir
|
||||
*
|
||||
* This program 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.
|
||||
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GRAPHICS_H__
|
||||
#define __GRAPHICS_H__
|
||||
|
||||
#include "intern.h"
|
||||
|
||||
struct Graphics {
|
||||
uint8 *_layer;
|
||||
int16 _areaPoints[0x200];
|
||||
int16 _crx, _cry, _crw, _crh;
|
||||
|
||||
void setClippingRect(int16 vx, int16 vy, int16 vw, int16 vh);
|
||||
void drawPoint(uint8 color, const Point *pt);
|
||||
void drawLine(uint8 color, const Point *pt1, const Point *pt2);
|
||||
void addEllipseRadius(int16 y, int16 x1, int16 x2);
|
||||
void drawEllipse(uint8 color, bool hasAlpha, const Point *pt, int16 rx, int16 ry);
|
||||
void fillArea(uint8 color, bool hasAlpha);
|
||||
void drawSegment(uint8 color, bool hasAlpha, int16 ys, const Point *pts, uint8 numPts);
|
||||
void drawPolygonOutline(uint8 color, const Point *pts, uint8 numPts);
|
||||
void drawPolygon(uint8 color, bool hasAlpha, const Point *pts, uint8 numPts);
|
||||
};
|
||||
|
||||
#endif // __GRAPHICS_H__
|
||||
193
project/jni/application/REminiscence/REminiscence-0.1.9/intern.h
Normal file
193
project/jni/application/REminiscence/REminiscence-0.1.9/intern.h
Normal file
@@ -0,0 +1,193 @@
|
||||
/* REminiscence - Flashback interpreter
|
||||
* Copyright (C) 2005-2007 Gregory Montoir
|
||||
*
|
||||
* This program 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.
|
||||
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __INTERN_H__
|
||||
#define __INTERN_H__
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
#include "sys.h"
|
||||
#include "util.h"
|
||||
|
||||
#define MAX(x,y) ((x)>(y)?(x):(y))
|
||||
#define MIN(x,y) ((x)<(y)?(x):(y))
|
||||
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
inline void SWAP(T &a, T &b) {
|
||||
T tmp = a;
|
||||
a = b;
|
||||
b = tmp;
|
||||
}
|
||||
|
||||
enum Version {
|
||||
VER_FR,
|
||||
VER_EN,
|
||||
VER_DE,
|
||||
VER_SP
|
||||
};
|
||||
|
||||
struct Color {
|
||||
uint8 r;
|
||||
uint8 g;
|
||||
uint8 b;
|
||||
};
|
||||
|
||||
struct Point {
|
||||
int16 x;
|
||||
int16 y;
|
||||
};
|
||||
|
||||
struct Level {
|
||||
const char *name;
|
||||
const char *name2;
|
||||
uint16 cutscene_id;
|
||||
};
|
||||
|
||||
struct InitPGE {
|
||||
uint16 type;
|
||||
int16 pos_x;
|
||||
int16 pos_y;
|
||||
uint16 obj_node_number;
|
||||
uint16 life;
|
||||
int16 counter_values[4];
|
||||
uint8 object_type;
|
||||
uint8 init_room;
|
||||
uint8 room_location;
|
||||
uint8 init_flags;
|
||||
uint8 colliding_icon_num;
|
||||
uint8 icon_num;
|
||||
uint8 object_id;
|
||||
uint8 skill;
|
||||
uint8 mirror_x;
|
||||
uint8 flags;
|
||||
uint8 unk1C; // collidable, collision_data_len
|
||||
uint8 text_num;
|
||||
};
|
||||
|
||||
struct LivePGE {
|
||||
uint16 obj_type;
|
||||
int16 pos_x;
|
||||
int16 pos_y;
|
||||
uint8 anim_seq;
|
||||
uint8 room_location;
|
||||
int16 life;
|
||||
int16 counter_value;
|
||||
uint8 collision_slot;
|
||||
uint8 next_inventory_PGE;
|
||||
uint8 current_inventory_PGE;
|
||||
uint8 unkF; // unk_inventory_PGE
|
||||
uint16 anim_number;
|
||||
uint8 flags;
|
||||
uint8 index;
|
||||
uint16 first_obj_number;
|
||||
LivePGE *next_PGE_in_room;
|
||||
InitPGE *init_PGE;
|
||||
};
|
||||
|
||||
struct GroupPGE {
|
||||
GroupPGE *next_entry;
|
||||
uint16 index;
|
||||
uint16 group_id;
|
||||
};
|
||||
|
||||
struct Object {
|
||||
uint16 type;
|
||||
int8 dx;
|
||||
int8 dy;
|
||||
uint16 init_obj_type;
|
||||
uint8 opcode2;
|
||||
uint8 opcode1;
|
||||
uint8 flags;
|
||||
uint8 opcode3;
|
||||
uint16 init_obj_number;
|
||||
int16 opcode_arg1;
|
||||
int16 opcode_arg2;
|
||||
int16 opcode_arg3;
|
||||
};
|
||||
|
||||
struct ObjectNode {
|
||||
uint16 last_obj_number;
|
||||
Object *objects;
|
||||
uint16 num_objects;
|
||||
};
|
||||
|
||||
struct ObjectOpcodeArgs {
|
||||
LivePGE *pge; // arg0
|
||||
int16 a; // arg2
|
||||
int16 b; // arg4
|
||||
};
|
||||
|
||||
struct AnimBufferState {
|
||||
int16 x;
|
||||
int16 y;
|
||||
const uint8 *dataPtr;
|
||||
LivePGE *pge;
|
||||
};
|
||||
|
||||
struct AnimBuffers {
|
||||
AnimBufferState *_states[4];
|
||||
uint8 _curPos[4];
|
||||
|
||||
void addState(uint8 stateNum, int16 x, int16 y, const uint8 *dataPtr, LivePGE *pge);
|
||||
};
|
||||
|
||||
struct CollisionSlot {
|
||||
int16 ct_pos;
|
||||
CollisionSlot *prev_slot;
|
||||
LivePGE *live_pge;
|
||||
uint16 index;
|
||||
};
|
||||
|
||||
struct MbkEntry {
|
||||
uint16 offset;
|
||||
uint16 len;
|
||||
};
|
||||
|
||||
struct BankSlot {
|
||||
uint16 entryNum;
|
||||
uint8 *ptr;
|
||||
};
|
||||
|
||||
struct CollisionSlot2 {
|
||||
CollisionSlot2 *next_slot;
|
||||
int8 *unk2;
|
||||
uint8 data_size;
|
||||
uint8 data_buf[0x10]; // XXX check size
|
||||
};
|
||||
|
||||
struct InventoryItem {
|
||||
uint8 icon_num;
|
||||
InitPGE *init_pge;
|
||||
LivePGE *live_pge;
|
||||
};
|
||||
|
||||
struct SoundFx {
|
||||
uint32 offset;
|
||||
uint16 len;
|
||||
uint8 *data;
|
||||
};
|
||||
|
||||
#endif // __INTERN_H__
|
||||
@@ -0,0 +1,50 @@
|
||||
/* REminiscence - Flashback interpreter
|
||||
* Copyright (C) 2005-2006 Gregory Montoir
|
||||
*
|
||||
* This program 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.
|
||||
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "locale.h"
|
||||
|
||||
|
||||
Locale::Locale(Version ver)
|
||||
: _ver(ver) {
|
||||
switch (_ver) {
|
||||
case VER_FR:
|
||||
_stringsTable = _stringsTableFR;
|
||||
_textsTable = _textsTableFR;
|
||||
break;
|
||||
case VER_EN:
|
||||
_stringsTable = _stringsTableEN;
|
||||
_textsTable = _textsTableEN;
|
||||
break;
|
||||
case VER_DE:
|
||||
_stringsTable = _stringsTableDE;
|
||||
_textsTable = _textsTableDE;
|
||||
break;
|
||||
case VER_SP:
|
||||
_stringsTable = _stringsTableSP;
|
||||
_textsTable = _textsTableSP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const char *Locale::get(int id) const {
|
||||
const char *text = 0;
|
||||
if (id >= 0 && id < LI_NUM) {
|
||||
text = _textsTable[id];
|
||||
}
|
||||
return text;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/* REminiscence - Flashback interpreter
|
||||
* Copyright (C) 2005-2006 Gregory Montoir
|
||||
*
|
||||
* This program 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.
|
||||
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __LOCALE_H__
|
||||
#define __LOCALE_H__
|
||||
|
||||
#include "intern.h"
|
||||
|
||||
struct Locale {
|
||||
enum Id {
|
||||
LI_01_CONTINUE_OR_ABORT = 0,
|
||||
LI_02_TIME,
|
||||
LI_03_CONTINUE,
|
||||
LI_04_ABORT,
|
||||
LI_05_COMPLETED,
|
||||
LI_06_LEVEL,
|
||||
LI_07_START,
|
||||
LI_08_SKILL,
|
||||
LI_09_PASSWORD,
|
||||
LI_10_INFO,
|
||||
LI_11_QUIT,
|
||||
LI_12_SKILL_LEVEL,
|
||||
LI_13_EASY,
|
||||
LI_14_NORMAL,
|
||||
LI_15_EXPERT,
|
||||
LI_16_ENTER_PASSWORD1,
|
||||
LI_17_ENTER_PASSWORD2,
|
||||
LI_18_RESUME_GAME,
|
||||
LI_19_ABORT_GAME,
|
||||
LI_20_LOAD_GAME,
|
||||
LI_21_SAVE_GAME,
|
||||
LI_22_SAVE_SLOT,
|
||||
|
||||
LI_NUM
|
||||
};
|
||||
|
||||
static const char *_textsTableFR[];
|
||||
static const char *_textsTableEN[];
|
||||
static const char *_textsTableDE[];
|
||||
static const char *_textsTableSP[];
|
||||
static const uint8 _stringsTableFR[];
|
||||
static const uint8 _stringsTableEN[];
|
||||
static const uint8 _stringsTableDE[];
|
||||
static const uint8 _stringsTableSP[];
|
||||
|
||||
Version _ver;
|
||||
const char **_textsTable;
|
||||
const uint8 *_stringsTable;
|
||||
|
||||
Locale(Version ver);
|
||||
const char *get(int id) const;
|
||||
};
|
||||
|
||||
#endif // __LOCALE_H__
|
||||
@@ -0,0 +1,85 @@
|
||||
/* REminiscence - Flashback interpreter
|
||||
* Copyright (C) 2005-2007 Gregory Montoir
|
||||
*
|
||||
* This program 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.
|
||||
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "file.h"
|
||||
#include "game.h"
|
||||
#include "systemstub.h"
|
||||
|
||||
static const char *USAGE =
|
||||
"REminiscence - Flashback Interpreter\n"
|
||||
"Usage: rs [OPTIONS]...\n"
|
||||
" --datapath=PATH Path to data files (default 'DATA')\n"
|
||||
" --savepath=PATH Path to save files (default '.')";
|
||||
|
||||
static bool parseOption(const char *arg, const char *longCmd, const char **opt) {
|
||||
bool handled = false;
|
||||
if (arg[0] == '-' && arg[1] == '-') {
|
||||
if (strncmp(arg + 2, longCmd, strlen(longCmd)) == 0) {
|
||||
*opt = arg + 2 + strlen(longCmd);
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
static Version detectVersion(const char *dataPath) {
|
||||
static struct {
|
||||
const char *filename;
|
||||
Version ver;
|
||||
} checkTable[] = {
|
||||
{ "ENGCINE.BIN", VER_EN },
|
||||
{ "FR_CINE.BIN", VER_FR },
|
||||
{ "GERCINE.BIN", VER_DE },
|
||||
{ "SPACINE.BIN", VER_SP }
|
||||
};
|
||||
for (uint8 i = 0; i < ARRAYSIZE(checkTable); ++i) {
|
||||
File f;
|
||||
if (f.open(checkTable[i].filename, dataPath, "rb")) {
|
||||
return checkTable[i].ver;
|
||||
}
|
||||
}
|
||||
error("Unable to find data files, check that all required files are present");
|
||||
return VER_EN;
|
||||
}
|
||||
|
||||
#undef main
|
||||
|
||||
#include <SDL.h>
|
||||
int main(int argc, char *argv[]) {
|
||||
const char *dataPath = "DATA";
|
||||
const char *savePath = ".";
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
bool opt = false;
|
||||
if (strlen(argv[i]) >= 2) {
|
||||
opt |= parseOption(argv[i], "datapath=", &dataPath);
|
||||
opt |= parseOption(argv[i], "savepath=", &savePath);
|
||||
}
|
||||
if (!opt) {
|
||||
printf(USAGE);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Version ver = detectVersion(dataPath);
|
||||
g_debugMask = DBG_INFO; // DBG_CUT | DBG_VIDEO | DBG_RES | DBG_MENU | DBG_PGE | DBG_GAME | DBG_UNPACK | DBG_COL | DBG_MOD | DBG_SFX;
|
||||
SystemStub *stub = SystemStub_SDL_create();
|
||||
Game *g = new Game(stub, dataPath, savePath, ver);
|
||||
g->run();
|
||||
delete g;
|
||||
delete stub;
|
||||
return 0;
|
||||
}
|
||||
316
project/jni/application/REminiscence/REminiscence-0.1.9/menu.cpp
Normal file
316
project/jni/application/REminiscence/REminiscence-0.1.9/menu.cpp
Normal file
@@ -0,0 +1,316 @@
|
||||
/* REminiscence - Flashback interpreter
|
||||
* Copyright (C) 2005-2007 Gregory Montoir
|
||||
*
|
||||
* This program 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.
|
||||
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "game.h"
|
||||
#include "mod_player.h"
|
||||
#include "resource.h"
|
||||
#include "systemstub.h"
|
||||
#include "video.h"
|
||||
#include "menu.h"
|
||||
|
||||
|
||||
Menu::Menu(ModPlayer *ply, Resource *res, SystemStub *stub, Video *vid)
|
||||
: _ply(ply), _res(res), _stub(stub), _vid(vid) {
|
||||
}
|
||||
|
||||
void Menu::drawString(const char *str, int16 y, int16 x, uint8 color) {
|
||||
debug(DBG_MENU, "Menu::drawString()");
|
||||
uint8 v1b = _vid->_charFrontColor;
|
||||
uint8 v2b = _vid->_charTransparentColor;
|
||||
uint8 v3b = _vid->_charShadowColor;
|
||||
switch (color) {
|
||||
case 0:
|
||||
_vid->_charFrontColor = _charVar1;
|
||||
_vid->_charTransparentColor = _charVar2;
|
||||
_vid->_charShadowColor = _charVar2;
|
||||
break;
|
||||
case 1:
|
||||
_vid->_charFrontColor = _charVar2;
|
||||
_vid->_charTransparentColor = _charVar1;
|
||||
_vid->_charShadowColor = _charVar1;
|
||||
break;
|
||||
case 2:
|
||||
_vid->_charFrontColor = _charVar3;
|
||||
_vid->_charTransparentColor = 0xFF;
|
||||
_vid->_charShadowColor = _charVar1;
|
||||
break;
|
||||
case 3:
|
||||
_vid->_charFrontColor = _charVar4;
|
||||
_vid->_charTransparentColor = 0xFF;
|
||||
_vid->_charShadowColor = _charVar1;
|
||||
break;
|
||||
case 4:
|
||||
_vid->_charFrontColor = _charVar2;
|
||||
_vid->_charTransparentColor = 0xFF;
|
||||
_vid->_charShadowColor = _charVar1;
|
||||
break;
|
||||
case 5:
|
||||
_vid->_charFrontColor = _charVar2;
|
||||
_vid->_charTransparentColor = 0xFF;
|
||||
_vid->_charShadowColor = _charVar5;
|
||||
break;
|
||||
}
|
||||
|
||||
drawString2(str, y, x);
|
||||
|
||||
_vid->_charFrontColor = v1b;
|
||||
_vid->_charTransparentColor = v2b;
|
||||
_vid->_charShadowColor = v3b;
|
||||
}
|
||||
|
||||
void Menu::drawString2(const char *str, int16 y, int16 x) {
|
||||
debug(DBG_MENU, "Menu::drawString2()");
|
||||
int len = 0;
|
||||
while (*str) {
|
||||
_vid->drawChar((uint8)*str, y, x + len);
|
||||
++str;
|
||||
++len;
|
||||
}
|
||||
_vid->markBlockAsDirty(x * 8, y * 8, len * 8, 8);
|
||||
}
|
||||
|
||||
void Menu::loadPicture(const char *prefix) {
|
||||
debug(DBG_MENU, "Menu::loadPicture('%s')", prefix);
|
||||
_res->load_MAP_menu(prefix, _res->_memBuf);
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
for (int y = 0; y < 224; ++y) {
|
||||
for (int x = 0; x < 64; ++x) {
|
||||
_vid->_frontLayer[i + x * 4 + 256 * y] = _res->_memBuf[0x3800 * i + x + 64 * y];
|
||||
}
|
||||
}
|
||||
}
|
||||
_res->load_PAL_menu(prefix, _res->_memBuf);
|
||||
_stub->setPalette(_res->_memBuf, 256);
|
||||
}
|
||||
|
||||
void Menu::handleInfoScreen() {
|
||||
debug(DBG_MENU, "Menu::handleInfoScreen()");
|
||||
_vid->fadeOut();
|
||||
switch (_res->_ver) {
|
||||
case VER_FR:
|
||||
loadPicture("instru_f");
|
||||
break;
|
||||
case VER_EN:
|
||||
case VER_DE:
|
||||
case VER_SP:
|
||||
loadPicture("instru_e");
|
||||
break;
|
||||
}
|
||||
_vid->fullRefresh();
|
||||
_vid->updateScreen();
|
||||
do {
|
||||
_stub->sleep(EVENTS_DELAY);
|
||||
_stub->processEvents();
|
||||
if (_stub->_pi.enter) {
|
||||
_stub->_pi.enter = false;
|
||||
break;
|
||||
}
|
||||
} while (!_stub->_pi.quit);
|
||||
}
|
||||
|
||||
void Menu::handleSkillScreen(uint8 &new_skill) {
|
||||
debug(DBG_MENU, "Menu::handleSkillScreen()");
|
||||
static const uint8 option_colors[3][3] = { { 2, 3, 3 }, { 3, 2, 3}, { 3, 3, 2 } };
|
||||
_vid->fadeOut();
|
||||
loadPicture("menu3");
|
||||
_vid->fullRefresh();
|
||||
drawString(_res->getMenuString(LocaleData::LI_12_SKILL_LEVEL), 12, 4, 3);
|
||||
int skill_level = new_skill;
|
||||
do {
|
||||
drawString(_res->getMenuString(LocaleData::LI_13_EASY), 15, 14, option_colors[skill_level][0]);
|
||||
drawString(_res->getMenuString(LocaleData::LI_14_NORMAL), 17, 14, option_colors[skill_level][1]);
|
||||
drawString(_res->getMenuString(LocaleData::LI_15_EXPERT), 19, 14, option_colors[skill_level][2]);
|
||||
|
||||
_vid->updateScreen();
|
||||
_stub->sleep(EVENTS_DELAY);
|
||||
_stub->processEvents();
|
||||
|
||||
if (_stub->_pi.dirMask & PlayerInput::DIR_UP) {
|
||||
_stub->_pi.dirMask &= ~PlayerInput::DIR_UP;
|
||||
if (skill_level != 0) {
|
||||
--skill_level;
|
||||
} else {
|
||||
skill_level = 2;
|
||||
}
|
||||
}
|
||||
if (_stub->_pi.dirMask & PlayerInput::DIR_DOWN) {
|
||||
_stub->_pi.dirMask &= ~PlayerInput::DIR_DOWN;
|
||||
if (skill_level != 2) {
|
||||
++skill_level;
|
||||
} else {
|
||||
skill_level = 0;
|
||||
}
|
||||
}
|
||||
if (_stub->_pi.enter) {
|
||||
_stub->_pi.enter = false;
|
||||
new_skill = skill_level;
|
||||
return;
|
||||
}
|
||||
} while (!_stub->_pi.quit);
|
||||
new_skill = 1;
|
||||
}
|
||||
|
||||
bool Menu::handlePasswordScreen(uint8 &new_skill, uint8 &new_level) {
|
||||
debug(DBG_MENU, "Menu::handlePasswordScreen()");
|
||||
_vid->fadeOut();
|
||||
_vid->_charShadowColor = _charVar1;
|
||||
_vid->_charTransparentColor = 0xFF;
|
||||
_vid->_charFrontColor = _charVar4;
|
||||
_vid->fullRefresh();
|
||||
char password[7];
|
||||
int len = 0;
|
||||
do {
|
||||
loadPicture("menu2");
|
||||
drawString2(_res->getMenuString(LocaleData::LI_16_ENTER_PASSWORD1), 15, 3);
|
||||
drawString2(_res->getMenuString(LocaleData::LI_17_ENTER_PASSWORD2), 17, 3);
|
||||
|
||||
for (int i = 0; i < len; ++i) {
|
||||
_vid->drawChar((uint8)password[i], 21, i + 15);
|
||||
}
|
||||
_vid->drawChar(0x20, 21, len + 15);
|
||||
|
||||
_vid->markBlockAsDirty(15 * 8, 21 * 8, (len + 1) * 8, 8);
|
||||
_vid->updateScreen();
|
||||
_stub->sleep(EVENTS_DELAY);
|
||||
_stub->processEvents();
|
||||
char c = _stub->_pi.lastChar;
|
||||
if (c != 0) {
|
||||
_stub->_pi.lastChar = 0;
|
||||
if (len < 6) {
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
c &= ~0x20;
|
||||
}
|
||||
if ((c >= 'A' && c <= 'Z') || (c == 0x20)) {
|
||||
password[len] = c;
|
||||
++len;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_stub->_pi.backspace) {
|
||||
_stub->_pi.backspace = false;
|
||||
if (len > 0) {
|
||||
--len;
|
||||
}
|
||||
}
|
||||
if (_stub->_pi.enter) {
|
||||
_stub->_pi.enter = false;
|
||||
password[len] = '\0';
|
||||
for (int level = 0; level < 8; ++level) {
|
||||
for (int skill = 0; skill < 3; ++skill) {
|
||||
if (strcmp(_passwords[level][skill], password) == 0) {
|
||||
new_level = level;
|
||||
new_skill = skill;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} while (!_stub->_pi.quit);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Menu::handleTitleScreen(uint8 &new_skill, uint8 &new_level) {
|
||||
debug(DBG_MENU, "Menu::handleTitleScreen()");
|
||||
bool quit_loop = false;
|
||||
int menu_entry = 0;
|
||||
bool reinit_screen = true;
|
||||
bool continue_game = true;
|
||||
_charVar1 = 0;
|
||||
_charVar2 = 0;
|
||||
_charVar3 = 0;
|
||||
_charVar4 = 0;
|
||||
_charVar5 = 0;
|
||||
_ply->play(1);
|
||||
while (!quit_loop) {
|
||||
if (reinit_screen) {
|
||||
_vid->fadeOut();
|
||||
loadPicture("menu1");
|
||||
_vid->fullRefresh();
|
||||
_charVar3 = 1;
|
||||
_charVar4 = 2;
|
||||
menu_entry = 0;
|
||||
reinit_screen = false;
|
||||
}
|
||||
int selected_menu_entry = -1;
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
int color = (i == menu_entry) ? 2 : 3;
|
||||
drawString(_res->getMenuString(LocaleData::LI_07_START + i), 16 + i * 2, 20, color);
|
||||
}
|
||||
|
||||
_vid->updateScreen();
|
||||
_stub->sleep(EVENTS_DELAY);
|
||||
_stub->processEvents();
|
||||
|
||||
if (_stub->_pi.dirMask & PlayerInput::DIR_UP) {
|
||||
_stub->_pi.dirMask &= ~PlayerInput::DIR_UP;
|
||||
if (menu_entry != 0) {
|
||||
--menu_entry;
|
||||
} else {
|
||||
menu_entry = 4;
|
||||
}
|
||||
}
|
||||
if (_stub->_pi.dirMask & PlayerInput::DIR_DOWN) {
|
||||
_stub->_pi.dirMask &= ~PlayerInput::DIR_DOWN;
|
||||
if (menu_entry != 4) {
|
||||
++menu_entry;
|
||||
} else {
|
||||
menu_entry = 0;
|
||||
}
|
||||
}
|
||||
if (_stub->_pi.enter) {
|
||||
_stub->_pi.enter = false;
|
||||
selected_menu_entry = menu_entry;
|
||||
}
|
||||
|
||||
if (selected_menu_entry != -1) {
|
||||
switch (selected_menu_entry) {
|
||||
case MENU_OPTION_ITEM_START:
|
||||
new_level = 0;
|
||||
quit_loop = true;
|
||||
break;
|
||||
case MENU_OPTION_ITEM_SKILL:
|
||||
handleSkillScreen(new_skill);
|
||||
reinit_screen = true;
|
||||
break;
|
||||
case MENU_OPTION_ITEM_PASSWORD:
|
||||
if (handlePasswordScreen(new_skill, new_level)) {
|
||||
quit_loop = true;
|
||||
} else {
|
||||
reinit_screen = true;
|
||||
}
|
||||
break;
|
||||
case MENU_OPTION_ITEM_INFO:
|
||||
handleInfoScreen();
|
||||
reinit_screen = true;
|
||||
break;
|
||||
case MENU_OPTION_ITEM_QUIT:
|
||||
continue_game = false;
|
||||
quit_loop = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (_stub->_pi.quit) {
|
||||
continue_game = false;
|
||||
quit_loop = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
_ply->stop();
|
||||
return continue_game;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/* REminiscence - Flashback interpreter
|
||||
* Copyright (C) 2005-2007 Gregory Montoir
|
||||
*
|
||||
* This program 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.
|
||||
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __MENU_H__
|
||||
#define __MENU_H__
|
||||
|
||||
#include "intern.h"
|
||||
|
||||
struct ModPlayer;
|
||||
struct Resource;
|
||||
struct SystemStub;
|
||||
struct Video;
|
||||
|
||||
struct Menu {
|
||||
enum {
|
||||
MENU_OPTION_ITEM_START = 0,
|
||||
MENU_OPTION_ITEM_SKILL,
|
||||
MENU_OPTION_ITEM_PASSWORD,
|
||||
MENU_OPTION_ITEM_INFO,
|
||||
MENU_OPTION_ITEM_QUIT
|
||||
};
|
||||
|
||||
enum {
|
||||
EVENTS_DELAY = 80
|
||||
};
|
||||
|
||||
static const char *_passwords[8][3];
|
||||
|
||||
ModPlayer *_ply;
|
||||
Resource *_res;
|
||||
SystemStub *_stub;
|
||||
Video *_vid;
|
||||
|
||||
const char **_textOptions;
|
||||
uint8 _charVar1;
|
||||
uint8 _charVar2;
|
||||
uint8 _charVar3;
|
||||
uint8 _charVar4;
|
||||
uint8 _charVar5;
|
||||
|
||||
Menu(ModPlayer *ply, Resource *res, SystemStub *stub, Video *vid);
|
||||
|
||||
void drawString(const char *str, int16 y, int16 x, uint8 color);
|
||||
void drawString2(const char *str, int16 y, int16 x);
|
||||
void loadPicture(const char *prefix);
|
||||
void handleInfoScreen();
|
||||
void handleSkillScreen(uint8 &new_skill);
|
||||
bool handlePasswordScreen(uint8 &new_skill, uint8 &new_level);
|
||||
bool handleTitleScreen(uint8 &new_skill, uint8 &new_level);
|
||||
};
|
||||
|
||||
#endif // __MENU_H__
|
||||
@@ -0,0 +1,124 @@
|
||||
/* REminiscence - Flashback interpreter
|
||||
* Copyright (C) 2005-2007 Gregory Montoir
|
||||
*
|
||||
* This program 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.
|
||||
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "mixer.h"
|
||||
#include "systemstub.h"
|
||||
|
||||
|
||||
Mixer::Mixer(SystemStub *stub)
|
||||
: _stub(stub) {
|
||||
}
|
||||
|
||||
void Mixer::init() {
|
||||
memset(_channels, 0, sizeof(_channels));
|
||||
_premixHook = 0;
|
||||
_mutex = _stub->createMutex();
|
||||
_stub->startAudio(Mixer::mixCallback, this);
|
||||
}
|
||||
|
||||
void Mixer::free() {
|
||||
stopAll();
|
||||
_stub->stopAudio();
|
||||
_stub->destroyMutex(_mutex);
|
||||
}
|
||||
|
||||
void Mixer::setPremixHook(PremixHook premixHook, void *userData) {
|
||||
debug(DBG_SND, "Mixer::setPremixHook()");
|
||||
MutexStack(_stub, _mutex);
|
||||
_premixHook = premixHook;
|
||||
_premixHookData = userData;
|
||||
}
|
||||
|
||||
void Mixer::play(const MixerChunk *mc, uint16 freq, uint8 volume) {
|
||||
debug(DBG_SND, "Mixer::play(%d, %d)", freq, volume);
|
||||
MutexStack(_stub, _mutex);
|
||||
MixerChannel *ch = 0;
|
||||
for (int i = 0; i < NUM_CHANNELS; ++i) {
|
||||
MixerChannel *cur = &_channels[i];
|
||||
if (cur->active) {
|
||||
if (cur->chunk.data == mc->data) {
|
||||
cur->chunkPos = 0;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
ch = cur;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ch) {
|
||||
ch->active = true;
|
||||
ch->volume = volume;
|
||||
ch->chunk = *mc;
|
||||
ch->chunkPos = 0;
|
||||
ch->chunkInc = (freq << FRAC_BITS) / _stub->getOutputSampleRate();
|
||||
}
|
||||
}
|
||||
|
||||
uint32 Mixer::getSampleRate() const {
|
||||
return _stub->getOutputSampleRate();
|
||||
}
|
||||
|
||||
void Mixer::stopAll() {
|
||||
debug(DBG_SND, "Mixer::stopAll()");
|
||||
MutexStack(_stub, _mutex);
|
||||
for (uint8 i = 0; i < NUM_CHANNELS; ++i) {
|
||||
_channels[i].active = false;
|
||||
}
|
||||
}
|
||||
|
||||
inline void addclamp(int16& a, int b) {
|
||||
int add = a + b;
|
||||
if (add < -32767) {
|
||||
add = -32767;
|
||||
} else if (add > 32767) {
|
||||
add = 32767;
|
||||
}
|
||||
a = add;
|
||||
}
|
||||
|
||||
void Mixer::mix(int8 *buf1, int len) {
|
||||
int16 *buf = (int16 *)buf1;
|
||||
MutexStack(_stub, _mutex);
|
||||
memset(buf, 0, len);
|
||||
len /= 2;
|
||||
if (_premixHook) {
|
||||
if (!_premixHook(_premixHookData, buf, len)) {
|
||||
_premixHook = 0;
|
||||
_premixHookData = 0;
|
||||
}
|
||||
}
|
||||
for (uint8 i = 0; i < NUM_CHANNELS; ++i) {
|
||||
MixerChannel *ch = &_channels[i];
|
||||
if (ch->active) {
|
||||
for (int pos = 0; pos < len; ++pos) {
|
||||
if ((ch->chunkPos >> FRAC_BITS) >= (ch->chunk.len - 1)) {
|
||||
ch->active = false;
|
||||
break;
|
||||
}
|
||||
int out = resampleLinear(&ch->chunk, ch->chunkPos, ch->chunkInc, FRAC_BITS);
|
||||
addclamp(buf[pos], out * Mixer::MIX_AMPLIFICATIION * ch->volume / Mixer::MAX_VOLUME );
|
||||
ch->chunkPos += ch->chunkInc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Mixer::mixCallback(void *param, uint8 *buf, int len) {
|
||||
((Mixer *)param)->mix((int8 *)buf, len);
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/* REminiscence - Flashback interpreter
|
||||
* Copyright (C) 2005-2007 Gregory Montoir
|
||||
*
|
||||
* This program 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.
|
||||
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __MIXER_H__
|
||||
#define __MIXER_H__
|
||||
|
||||
#include "intern.h"
|
||||
|
||||
struct MixerChunk {
|
||||
uint8 *data;
|
||||
uint32 len;
|
||||
|
||||
int8 getPCM(int offset) const {
|
||||
if (offset < 0) {
|
||||
offset = 0;
|
||||
} else if (offset >= (int)len) {
|
||||
offset = len - 1;
|
||||
}
|
||||
return (int8)data[offset];
|
||||
}
|
||||
};
|
||||
|
||||
struct MixerChannel {
|
||||
uint8 active;
|
||||
uint8 volume;
|
||||
MixerChunk chunk;
|
||||
uint32 chunkPos;
|
||||
uint32 chunkInc;
|
||||
};
|
||||
|
||||
struct SystemStub;
|
||||
|
||||
struct Mixer {
|
||||
typedef bool (*PremixHook)(void *userData, int16 *buf, int len);
|
||||
|
||||
enum {
|
||||
NUM_CHANNELS = 4,
|
||||
FRAC_BITS = 12,
|
||||
MAX_VOLUME = 64,
|
||||
MIX_AMPLIFICATIION = 64 // TODO: edit here to tweak sound
|
||||
};
|
||||
|
||||
void *_mutex;
|
||||
SystemStub *_stub;
|
||||
MixerChannel _channels[NUM_CHANNELS];
|
||||
PremixHook _premixHook;
|
||||
void *_premixHookData;
|
||||
|
||||
Mixer(SystemStub *stub);
|
||||
void init();
|
||||
void free();
|
||||
void setPremixHook(PremixHook premixHook, void *userData);
|
||||
void play(const MixerChunk *mc, uint16 freq, uint8 volume);
|
||||
void stopAll();
|
||||
uint32 getSampleRate() const;
|
||||
void mix(int8 *buf, int len);
|
||||
|
||||
//static void addclamp(int16 &a, int b);
|
||||
static void mixCallback(void *param, uint8 *buf, int len);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
int resampleLinear(T *sample, int pos, int step, int fracBits) {
|
||||
const int inputPos = pos >> fracBits;
|
||||
const int inputFrac = (1 << fracBits) - 1;
|
||||
int out = sample->getPCM(inputPos);
|
||||
out += (sample->getPCM(inputPos + 1) - out) * inputFrac >> fracBits;
|
||||
return out;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
int resample3Pt(T *sample, int pos, int step, int fracBits) {
|
||||
const int inputPos = pos >> fracBits;
|
||||
const int inputFrac = (1 << fracBits) - 1;
|
||||
int out = sample->getPCM(inputPos) >> 1;
|
||||
out += sample->getPCM(inputPos + ((inputFrac - (step >> 1)) >> fracBits)) >> 2;
|
||||
out += sample->getPCM(inputPos + ((inputFrac + (step >> 1)) >> fracBits)) >> 2;
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // __MIXER_H__
|
||||
@@ -0,0 +1,533 @@
|
||||
/* REminiscence - Flashback interpreter
|
||||
* Copyright (C) 2005-2007 Gregory Montoir
|
||||
*
|
||||
* This program 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.
|
||||
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "file.h"
|
||||
#include "mixer.h"
|
||||
#include "mod_player.h"
|
||||
|
||||
|
||||
ModPlayer::ModPlayer(Mixer *mixer, const char *dataPath)
|
||||
: _playing(false), _mix(mixer), _dataPath(dataPath) {
|
||||
memset(&_modInfo, 0, sizeof(_modInfo));
|
||||
}
|
||||
|
||||
uint16 ModPlayer::findPeriod(uint16 period, uint8 fineTune) const {
|
||||
for (int p = 0; p < 36; ++p) {
|
||||
if (_periodTable[p] == period) {
|
||||
return fineTune * 36 + p;
|
||||
}
|
||||
}
|
||||
error("Invalid period=%d", period);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ModPlayer::load(File *f) {
|
||||
f->read(_modInfo.songName, 20);
|
||||
_modInfo.songName[20] = 0;
|
||||
debug(DBG_MOD, "songName = '%s'", _modInfo.songName);
|
||||
|
||||
for (int s = 0; s < NUM_SAMPLES; ++s) {
|
||||
SampleInfo *si = &_modInfo.samples[s];
|
||||
f->read(si->name, 22);
|
||||
si->name[22] = 0;
|
||||
si->len = f->readUint16BE() * 2;
|
||||
si->fineTune = f->readByte();
|
||||
si->volume = f->readByte();
|
||||
si->repeatPos = f->readUint16BE() * 2;
|
||||
si->repeatLen = f->readUint16BE() * 2;
|
||||
si->data = 0;
|
||||
assert(si->len == 0 || si->repeatPos + si->repeatLen <= si->len);
|
||||
debug(DBG_MOD, "sample=%d name='%s' len=%d vol=%d", s, si->name, si->len, si->volume);
|
||||
}
|
||||
_modInfo.numPatterns = f->readByte();
|
||||
assert(_modInfo.numPatterns < NUM_PATTERNS);
|
||||
f->readByte(); // 0x7F
|
||||
f->read(_modInfo.patternOrderTable, NUM_PATTERNS);
|
||||
f->readUint32BE(); // 'M.K.', Protracker, 4 channels
|
||||
|
||||
uint16 n = 0;
|
||||
for (int i = 0; i < NUM_PATTERNS; ++i) {
|
||||
if (_modInfo.patternOrderTable[i] != 0) {
|
||||
n = MAX(n, _modInfo.patternOrderTable[i]);
|
||||
}
|
||||
}
|
||||
debug(DBG_MOD, "numPatterns=%d",n + 1);
|
||||
n = (n + 1) * 64 * 4 * 4; // 64 lines of 4 notes per channel
|
||||
_modInfo.patternsTable = (uint8 *)malloc(n);
|
||||
assert(_modInfo.patternsTable);
|
||||
f->read(_modInfo.patternsTable, n);
|
||||
|
||||
for (int s = 0; s < NUM_SAMPLES; ++s) {
|
||||
SampleInfo *si = &_modInfo.samples[s];
|
||||
if (si->len != 0) {
|
||||
si->data = (int8 *)malloc(si->len);
|
||||
if (si->data) {
|
||||
f->read(si->data, si->len);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ModPlayer::unload() {
|
||||
if (_modInfo.songName[0]) {
|
||||
free(_modInfo.patternsTable);
|
||||
for (int s = 0; s < NUM_SAMPLES; ++s) {
|
||||
free(_modInfo.samples[s].data);
|
||||
}
|
||||
memset(&_modInfo, 0, sizeof(_modInfo));
|
||||
}
|
||||
}
|
||||
|
||||
void ModPlayer::play(uint8 num) {
|
||||
if (!_playing && num < _modulesFilesCount) {
|
||||
File f;
|
||||
bool found = false;
|
||||
for (uint8 i = 0; i < ARRAYSIZE(_modulesFiles[num]); ++i) {
|
||||
if (f.open(_modulesFiles[num][i], _dataPath, "rb")) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
warning("Can't find music file %d", num);
|
||||
} else {
|
||||
load(&f);
|
||||
_currentPatternOrder = 0;
|
||||
_currentPatternPos = 0;
|
||||
_currentTick = 0;
|
||||
_patternDelay = 0;
|
||||
_songSpeed = 6;
|
||||
_songTempo = 125;
|
||||
_patternLoopPos = 0;
|
||||
_patternLoopCount = -1;
|
||||
_samplesLeft = 0;
|
||||
_songNum = num;
|
||||
_introSongHack = false;
|
||||
memset(_tracks, 0, sizeof(_tracks));
|
||||
_mix->setPremixHook(mixCallback, this);
|
||||
_playing = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ModPlayer::stop() {
|
||||
if (_playing) {
|
||||
_mix->setPremixHook(0, 0);
|
||||
_playing = false;
|
||||
}
|
||||
unload();
|
||||
}
|
||||
|
||||
void ModPlayer::handleNote(int trackNum, uint32 noteData) {
|
||||
Track *tk = &_tracks[trackNum];
|
||||
uint16 sampleNum = ((noteData >> 24) & 0xF0) | ((noteData >> 12) & 0xF);
|
||||
uint16 samplePeriod = (noteData >> 16) & 0xFFF;
|
||||
uint16 effectData = noteData & 0xFFF;
|
||||
debug(DBG_MOD, "ModPlayer::handleNote(%d) p=%d/%d sampleNumber=0x%X samplePeriod=0x%X effectData=0x%X tk->period=%d", trackNum, _currentPatternPos, _currentPatternOrder, sampleNum, samplePeriod, effectData, tk->period);
|
||||
if (sampleNum != 0) {
|
||||
tk->sample = &_modInfo.samples[sampleNum - 1];
|
||||
tk->volume = tk->sample->volume;
|
||||
tk->pos = 0;
|
||||
}
|
||||
if (samplePeriod != 0) {
|
||||
tk->periodIndex = findPeriod(samplePeriod, tk->sample->fineTune);
|
||||
if ((effectData >> 8) != 0x3 && (effectData >> 8) != 0x5) {
|
||||
tk->period = _periodTable[tk->periodIndex];
|
||||
tk->freq = PAULA_FREQ / tk->period;
|
||||
} else {
|
||||
tk->portamento = _periodTable[tk->periodIndex];
|
||||
}
|
||||
tk->vibratoAmp = 0;
|
||||
tk->vibratoSpeed = 0;
|
||||
tk->vibratoPos = 0;
|
||||
}
|
||||
tk->effectData = effectData;
|
||||
}
|
||||
|
||||
void ModPlayer::applyVolumeSlide(int trackNum, int amount) {
|
||||
debug(DBG_MOD, "ModPlayer::applyVolumeSlide(%d, %d)", trackNum, amount);
|
||||
Track *tk = &_tracks[trackNum];
|
||||
int vol = tk->volume + amount;
|
||||
if (vol < 0) {
|
||||
vol = 0;
|
||||
} else if (vol > 64) {
|
||||
vol = 64;
|
||||
}
|
||||
tk->volume = vol;
|
||||
}
|
||||
|
||||
void ModPlayer::applyVibrato(int trackNum) {
|
||||
debug(DBG_MOD, "ModPlayer::applyVibrato(%d)", trackNum);
|
||||
Track *tk = &_tracks[trackNum];
|
||||
int vib = tk->vibratoAmp * _sineWaveTable[tk->vibratoPos] / 128;
|
||||
if (tk->period + vib != 0) {
|
||||
tk->freq = PAULA_FREQ / (tk->period + vib);
|
||||
}
|
||||
tk->vibratoPos += tk->vibratoSpeed;
|
||||
if (tk->vibratoPos >= 64) {
|
||||
tk->vibratoPos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ModPlayer::applyPortamento(int trackNum) {
|
||||
debug(DBG_MOD, "ModPlayer::applyPortamento(%d)", trackNum);
|
||||
Track *tk = &_tracks[trackNum];
|
||||
if (tk->period < tk->portamento) {
|
||||
tk->period = MIN(tk->period + tk->portamentoSpeed, tk->portamento);
|
||||
} else if (tk->period > tk->portamento) {
|
||||
tk->period = MAX(tk->period - tk->portamentoSpeed, tk->portamento);
|
||||
}
|
||||
if (tk->period != 0) {
|
||||
tk->freq = PAULA_FREQ / tk->period;
|
||||
}
|
||||
}
|
||||
|
||||
void ModPlayer::handleEffect(int trackNum, bool tick) {
|
||||
Track *tk = &_tracks[trackNum];
|
||||
uint8 effectNum = tk->effectData >> 8;
|
||||
uint8 effectXY = tk->effectData & 0xFF;
|
||||
uint8 effectX = effectXY >> 4;
|
||||
uint8 effectY = effectXY & 0xF;
|
||||
debug(DBG_MOD, "ModPlayer::handleEffect(%d) effectNum=0x%X effectXY=0x%X", trackNum, effectNum, effectXY);
|
||||
switch (effectNum) {
|
||||
case 0x0: // arpeggio
|
||||
if (tick && effectXY != 0) {
|
||||
uint16 period = tk->period;
|
||||
switch (_currentTick & 3) {
|
||||
case 1:
|
||||
period = _periodTable[tk->periodIndex + effectX];
|
||||
break;
|
||||
case 2:
|
||||
period = _periodTable[tk->periodIndex + effectY];
|
||||
break;
|
||||
}
|
||||
tk->freq = PAULA_FREQ / period;
|
||||
}
|
||||
break;
|
||||
case 0x1: // portamento up
|
||||
if (tick) {
|
||||
tk->period -= effectXY;
|
||||
if (tk->period < 113) { // note B-3
|
||||
tk->period = 113;
|
||||
}
|
||||
tk->freq = PAULA_FREQ / tk->period;
|
||||
}
|
||||
break;
|
||||
case 0x2: // portamento down
|
||||
if (tick) {
|
||||
tk->period += effectXY;
|
||||
if (tk->period > 856) { // note C-1
|
||||
tk->period = 856;
|
||||
}
|
||||
tk->freq = PAULA_FREQ / tk->period;
|
||||
}
|
||||
break;
|
||||
case 0x3: // tone portamento
|
||||
if (!tick) {
|
||||
if (effectXY != 0) {
|
||||
tk->portamentoSpeed = effectXY;
|
||||
}
|
||||
} else {
|
||||
applyPortamento(trackNum);
|
||||
}
|
||||
break;
|
||||
case 0x4: // vibrato
|
||||
if (!tick) {
|
||||
if (effectX != 0) {
|
||||
tk->vibratoSpeed = effectX;
|
||||
}
|
||||
if (effectY != 0) {
|
||||
tk->vibratoAmp = effectY;
|
||||
}
|
||||
} else {
|
||||
applyVibrato(trackNum);
|
||||
}
|
||||
break;
|
||||
case 0x5: // tone portamento + volume slide
|
||||
if (tick) {
|
||||
applyPortamento(trackNum);
|
||||
applyVolumeSlide(trackNum, effectX - effectY);
|
||||
}
|
||||
break;
|
||||
case 0x6: // vibrato + volume slide
|
||||
if (tick) {
|
||||
applyVibrato(trackNum);
|
||||
applyVolumeSlide(trackNum, effectX - effectY);
|
||||
}
|
||||
break;
|
||||
case 0x9: // set sample offset
|
||||
if (!tick) {
|
||||
tk->pos = effectXY << (8 + FRAC_BITS);
|
||||
}
|
||||
break;
|
||||
case 0xA: // volume slide
|
||||
if (tick) {
|
||||
applyVolumeSlide(trackNum, effectX - effectY);
|
||||
}
|
||||
break;
|
||||
case 0xB: // position jump
|
||||
if (!tick) {
|
||||
_currentPatternOrder = effectXY;
|
||||
_currentPatternPos = 0;
|
||||
assert(_currentPatternOrder < _modInfo.numPatterns);
|
||||
}
|
||||
break;
|
||||
case 0xC: // set volume
|
||||
if (!tick) {
|
||||
assert(effectXY <= 64);
|
||||
tk->volume = effectXY;
|
||||
}
|
||||
break;
|
||||
case 0xD: // pattern break
|
||||
if (!tick) {
|
||||
_currentPatternPos = effectX * 10 + effectY;
|
||||
assert(_currentPatternPos < 64);
|
||||
++_currentPatternOrder;
|
||||
debug(DBG_MOD, "_currentPatternPos = %d _currentPatternOrder = %d", _currentPatternPos, _currentPatternOrder);
|
||||
}
|
||||
break;
|
||||
case 0xE: // extended effects
|
||||
switch (effectX) {
|
||||
case 0x0: // set filter, ignored
|
||||
break;
|
||||
case 0x1: // fineslide up
|
||||
if (!tick) {
|
||||
tk->period -= effectY;
|
||||
if (tk->period < 113) { // B-3 note
|
||||
tk->period = 113;
|
||||
}
|
||||
tk->freq = PAULA_FREQ / tk->period;
|
||||
}
|
||||
break;
|
||||
case 0x2: // fineslide down
|
||||
if (!tick) {
|
||||
tk->period += effectY;
|
||||
if (tk->period > 856) { // C-1 note
|
||||
tk->period = 856;
|
||||
}
|
||||
tk->freq = PAULA_FREQ / tk->period;
|
||||
}
|
||||
break;
|
||||
case 0x6: // loop pattern
|
||||
if (!tick) {
|
||||
if (effectY == 0) {
|
||||
_patternLoopPos = _currentPatternPos | (_currentPatternOrder << 8);
|
||||
debug(DBG_MOD, "_patternLoopPos=%d/%d", _currentPatternPos, _currentPatternOrder);
|
||||
} else {
|
||||
if (_patternLoopCount == -1) {
|
||||
_patternLoopCount = effectY;
|
||||
_currentPatternPos = _patternLoopPos & 0xFF;
|
||||
_currentPatternOrder = _patternLoopPos >> 8;
|
||||
} else {
|
||||
--_patternLoopCount;
|
||||
if (_patternLoopCount != 0) {
|
||||
_currentPatternPos = _patternLoopPos & 0xFF;
|
||||
_currentPatternOrder = _patternLoopPos >> 8;
|
||||
} else {
|
||||
_patternLoopCount = -1;
|
||||
}
|
||||
}
|
||||
debug(DBG_MOD, "_patternLoopCount=%d", _patternLoopCount);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x9: // retrigger sample
|
||||
if (tick) {
|
||||
tk->retriggerCounter = effectY;
|
||||
} else {
|
||||
if (tk->retriggerCounter == 0) {
|
||||
tk->pos = 0;
|
||||
tk->retriggerCounter = effectY;
|
||||
debug(DBG_MOD, "retrigger sample=%d _songSpeed=%d", effectY, _songSpeed);
|
||||
}
|
||||
--tk->retriggerCounter;
|
||||
}
|
||||
break;
|
||||
case 0xA: // fine volume slide up
|
||||
if (!tick) {
|
||||
applyVolumeSlide(trackNum, effectY);
|
||||
}
|
||||
break;
|
||||
case 0xB: // fine volume slide down
|
||||
if (!tick) {
|
||||
applyVolumeSlide(trackNum, -effectY);
|
||||
}
|
||||
break;
|
||||
case 0xC: // cut sample
|
||||
if (!tick) {
|
||||
tk->cutCounter = effectY;
|
||||
} else {
|
||||
--tk->cutCounter;
|
||||
if (tk->cutCounter == 0) {
|
||||
tk->volume = 0;
|
||||
}
|
||||
}
|
||||
case 0xD: // delay sample
|
||||
if (!tick) {
|
||||
tk->delayCounter = effectY;
|
||||
} else {
|
||||
if (tk->delayCounter != 0) {
|
||||
--tk->delayCounter;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0xE: // delay pattern
|
||||
if (!tick) {
|
||||
debug(DBG_MOD, "ModPlayer::handleEffect() _currentTick=%d delay pattern=%d", _currentTick, effectY);
|
||||
_patternDelay = effectY;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
warning("Unhandled extended effect 0x%X params=0x%X", effectX, effectY);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 0xF: // set speed
|
||||
if (!tick) {
|
||||
if (effectXY < 0x20) {
|
||||
_songSpeed = effectXY;
|
||||
} else {
|
||||
_songTempo = effectXY;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
warning("Unhandled effect 0x%X params=0x%X", effectNum, effectXY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ModPlayer::handleTick() {
|
||||
if (!_playing) {
|
||||
return;
|
||||
}
|
||||
// if (_patternDelay != 0) {
|
||||
// --_patternDelay;
|
||||
// return;
|
||||
// }
|
||||
if (_currentTick == 0) {
|
||||
debug(DBG_MOD, "_currentPatternOrder=%d _currentPatternPos=%d", _currentPatternOrder, _currentPatternPos);
|
||||
uint8 currentPattern = _modInfo.patternOrderTable[_currentPatternOrder];
|
||||
const uint8 *p = _modInfo.patternsTable + (currentPattern * 64 + _currentPatternPos) * 16;
|
||||
for (int i = 0; i < NUM_TRACKS; ++i) {
|
||||
uint32 noteData = READ_BE_UINT32(p);
|
||||
handleNote(i, noteData);
|
||||
p += 4;
|
||||
}
|
||||
++_currentPatternPos;
|
||||
if (_currentPatternPos == 64) {
|
||||
++_currentPatternOrder;
|
||||
_currentPatternPos = 0;
|
||||
debug(DBG_MOD, "ModPlayer::handleTick() _currentPatternOrder = %d/%d", _currentPatternOrder, _modInfo.numPatterns);
|
||||
// On the amiga version, the introduction cutscene is shorter than the PC version ;
|
||||
// so the music module doesn't synchronize at all with the PC datafiles, here we
|
||||
// add a hack to let the music play longer
|
||||
if (_songNum == 0 && _currentPatternOrder == 3 && !_introSongHack) {
|
||||
_currentPatternOrder = 1;
|
||||
_introSongHack = true;
|
||||
// warning("Introduction module synchronization hack");
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < NUM_TRACKS; ++i) {
|
||||
handleEffect(i, (_currentTick != 0));
|
||||
}
|
||||
++_currentTick;
|
||||
if (_currentTick == _songSpeed) {
|
||||
_currentTick = 0;
|
||||
}
|
||||
if (_currentPatternOrder == _modInfo.numPatterns) {
|
||||
debug(DBG_MOD, "ModPlayer::handleEffect() _currentPatternOrder == _modInfo.numPatterns");
|
||||
_playing = false;
|
||||
}
|
||||
}
|
||||
|
||||
inline void addclamp(int16& a, int b) {
|
||||
int add = a + b;
|
||||
if (add < -32767) {
|
||||
add = -32767;
|
||||
} else if (add > 32767) {
|
||||
add = 32767;
|
||||
}
|
||||
a = add;
|
||||
}
|
||||
|
||||
void ModPlayer::mixSamples(int16 *buf, int samplesLen) {
|
||||
for (int i = 0; i < NUM_TRACKS; ++i) {
|
||||
Track *tk = &_tracks[i];
|
||||
if (tk->sample != 0 && tk->delayCounter == 0) {
|
||||
int16 *mixbuf = buf;
|
||||
SampleInfo *si = tk->sample;
|
||||
int len = si->len << FRAC_BITS;
|
||||
int loopLen = si->repeatLen << FRAC_BITS;
|
||||
int loopPos = si->repeatPos << FRAC_BITS;
|
||||
int deltaPos = (tk->freq << FRAC_BITS) / _mix->getSampleRate();
|
||||
int curLen = samplesLen;
|
||||
int pos = tk->pos;
|
||||
while (curLen != 0) {
|
||||
int count;
|
||||
if (loopLen > (2 << FRAC_BITS)) {
|
||||
if (pos >= loopPos + loopLen) {
|
||||
pos -= loopLen;
|
||||
}
|
||||
count = MIN(curLen, (loopPos + loopLen - pos - 1) / deltaPos + 1);
|
||||
curLen -= count;
|
||||
} else {
|
||||
if (pos >= len) {
|
||||
count = 0;
|
||||
} else {
|
||||
count = MIN(curLen, (len - pos - 1) / deltaPos + 1);
|
||||
}
|
||||
curLen = 0;
|
||||
}
|
||||
while (count--) {
|
||||
int out = resample3Pt(si, pos, deltaPos, FRAC_BITS);
|
||||
addclamp(*mixbuf++, out * Mixer::MIX_AMPLIFICATIION * tk->volume / 64);
|
||||
pos += deltaPos;
|
||||
}
|
||||
}
|
||||
tk->pos = pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ModPlayer::mix(int16 *buf, int len) {
|
||||
if (_playing) {
|
||||
memset(buf, 0, len*2);
|
||||
const int samplesPerTick = _mix->getSampleRate() / (50 * _songTempo / 125);
|
||||
while (len != 0) {
|
||||
if (_samplesLeft == 0) {
|
||||
handleTick();
|
||||
_samplesLeft = samplesPerTick;
|
||||
}
|
||||
int count = _samplesLeft;
|
||||
if (count > len) {
|
||||
count = len;
|
||||
}
|
||||
_samplesLeft -= count;
|
||||
len -= count;
|
||||
mixSamples(buf, count);
|
||||
buf += count;
|
||||
}
|
||||
}
|
||||
return _playing;
|
||||
}
|
||||
|
||||
bool ModPlayer::mixCallback(void *param, int16 *buf, int len) {
|
||||
return ((ModPlayer *)param)->mix(buf, len);
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/* REminiscence - Flashback interpreter
|
||||
* Copyright (C) 2005-2007 Gregory Montoir
|
||||
*
|
||||
* This program 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.
|
||||
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __MOD_PLAYER_H__
|
||||
#define __MOD_PLAYER_H__
|
||||
|
||||
#include "intern.h"
|
||||
|
||||
struct File;
|
||||
struct Mixer;
|
||||
|
||||
struct ModPlayer {
|
||||
enum {
|
||||
NUM_SAMPLES = 31,
|
||||
NUM_TRACKS = 4,
|
||||
NUM_PATTERNS = 128,
|
||||
FRAC_BITS = 12,
|
||||
PAULA_FREQ = 3546897
|
||||
};
|
||||
|
||||
struct SampleInfo {
|
||||
char name[23];
|
||||
uint16 len;
|
||||
uint8 fineTune;
|
||||
uint8 volume;
|
||||
uint16 repeatPos;
|
||||
uint16 repeatLen;
|
||||
int8 *data;
|
||||
|
||||
int8 getPCM(int offset) const {
|
||||
if (offset < 0) {
|
||||
offset = 0;
|
||||
} else if (offset >= (int)len) {
|
||||
offset = len - 1;
|
||||
}
|
||||
return data[offset];
|
||||
}
|
||||
};
|
||||
|
||||
struct ModuleInfo {
|
||||
char songName[21];
|
||||
SampleInfo samples[NUM_SAMPLES];
|
||||
uint8 numPatterns;
|
||||
uint8 patternOrderTable[NUM_PATTERNS];
|
||||
uint8 *patternsTable;
|
||||
};
|
||||
|
||||
struct Track {
|
||||
SampleInfo *sample;
|
||||
uint8 volume;
|
||||
int pos;
|
||||
int freq;
|
||||
uint16 period;
|
||||
uint16 periodIndex;
|
||||
uint16 effectData;
|
||||
int vibratoSpeed;
|
||||
int vibratoAmp;
|
||||
int vibratoPos;
|
||||
int portamento;
|
||||
int portamentoSpeed;
|
||||
int retriggerCounter;
|
||||
int delayCounter;
|
||||
int cutCounter;
|
||||
};
|
||||
|
||||
static const int8 _sineWaveTable[];
|
||||
static const uint16 _periodTable[];
|
||||
static const char *_modulesFiles[][2];
|
||||
static const int _modulesFilesCount;
|
||||
|
||||
ModuleInfo _modInfo;
|
||||
uint8 _currentPatternOrder;
|
||||
uint8 _currentPatternPos;
|
||||
uint8 _currentTick;
|
||||
uint8 _songSpeed;
|
||||
uint8 _songTempo;
|
||||
int _patternDelay;
|
||||
int _patternLoopPos;
|
||||
int _patternLoopCount;
|
||||
int _samplesLeft;
|
||||
uint8 _songNum;
|
||||
bool _introSongHack;
|
||||
bool _playing;
|
||||
Track _tracks[NUM_TRACKS];
|
||||
Mixer *_mix;
|
||||
const char *_dataPath;
|
||||
|
||||
ModPlayer(Mixer *mixer, const char *dataPath);
|
||||
|
||||
uint16 findPeriod(uint16 period, uint8 fineTune) const;
|
||||
void load(File *f);
|
||||
void unload();
|
||||
void play(uint8 num);
|
||||
void stop();
|
||||
void handleNote(int trackNum, uint32 noteData);
|
||||
void handleTick();
|
||||
void applyVolumeSlide(int trackNum, int amount);
|
||||
void applyVibrato(int trackNum);
|
||||
void applyPortamento(int trackNum);
|
||||
void handleEffect(int trackNum, bool tick);
|
||||
void mixSamples(int16 *buf, int len);
|
||||
bool mix(int16 *buf, int len);
|
||||
|
||||
static bool mixCallback(void *param, int16 *buf, int len);
|
||||
};
|
||||
|
||||
#endif // __MOD_PLAYER_H__
|
||||
2269
project/jni/application/REminiscence/REminiscence-0.1.9/piege.cpp
Normal file
2269
project/jni/application/REminiscence/REminiscence-0.1.9/piege.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,742 @@
|
||||
/* REminiscence - Flashback interpreter
|
||||
* Copyright (C) 2005-2007 Gregory Montoir
|
||||
*
|
||||
* This program 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.
|
||||
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "file.h"
|
||||
#include "unpack.h"
|
||||
#include "resource.h"
|
||||
|
||||
|
||||
Resource::Resource(const char *dataPath, Version ver) {
|
||||
memset(this, 0, sizeof(Resource));
|
||||
_dataPath = dataPath;
|
||||
_ver = ver;
|
||||
_memBuf = (uint8 *)malloc(0xE000);
|
||||
}
|
||||
|
||||
Resource::~Resource() {
|
||||
clearLevelRes();
|
||||
free(_fnt);
|
||||
free(_icn);
|
||||
free(_tab);
|
||||
free(_spr1);
|
||||
free(_memBuf);
|
||||
free(_cmd);
|
||||
free(_pol);
|
||||
free(_cine_off);
|
||||
free(_cine_txt);
|
||||
for (int i = 0; i < _numSfx; ++i) {
|
||||
free(_sfxList[i].data);
|
||||
}
|
||||
free(_sfxList);
|
||||
free(_voiceBuf);
|
||||
}
|
||||
|
||||
void Resource::clearLevelRes() {
|
||||
free(_tbn); _tbn = 0;
|
||||
free(_mbk); _mbk = 0;
|
||||
free(_mbkData); _mbkData = 0;
|
||||
free(_pal); _pal = 0;
|
||||
free(_map); _map = 0;
|
||||
free(_spc); _spc = 0;
|
||||
free(_ani); _ani = 0;
|
||||
free_OBJ();
|
||||
}
|
||||
|
||||
void Resource::load_FIB(const char *fileName) {
|
||||
debug(DBG_RES, "Resource::load_FIB('%s')", fileName);
|
||||
static const uint8 fibonacciTable[] = {
|
||||
0xDE, 0xEB, 0xF3, 0xF8, 0xFB, 0xFD, 0xFE, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x05, 0x08, 0x0D, 0x15
|
||||
};
|
||||
sprintf(_entryName, "%s.FIB", fileName);
|
||||
File f;
|
||||
if (f.open(_entryName, _dataPath, "rb")) {
|
||||
_numSfx = f.readUint16LE();
|
||||
_sfxList = (SoundFx *)malloc(_numSfx * sizeof(SoundFx));
|
||||
if (!_sfxList) {
|
||||
error("Unable to allocate SoundFx table");
|
||||
}
|
||||
int i;
|
||||
for (i = 0; i < _numSfx; ++i) {
|
||||
SoundFx *sfx = &_sfxList[i];
|
||||
sfx->offset = f.readUint32LE();
|
||||
sfx->len = f.readUint16LE();
|
||||
sfx->data = 0;
|
||||
}
|
||||
for (i = 0; i < _numSfx; ++i) {
|
||||
SoundFx *sfx = &_sfxList[i];
|
||||
if (sfx->len == 0) {
|
||||
continue;
|
||||
}
|
||||
f.seek(sfx->offset);
|
||||
uint8 *data = (uint8 *)malloc(sfx->len * 2);
|
||||
if (!data) {
|
||||
error("Unable to allocate SoundFx data buffer");
|
||||
}
|
||||
sfx->data = data;
|
||||
uint8 c = f.readByte();
|
||||
*data++ = c;
|
||||
*data++ = c;
|
||||
uint16 sz = sfx->len - 1;
|
||||
while (sz--) {
|
||||
uint8 d = f.readByte();
|
||||
c += fibonacciTable[d >> 4];
|
||||
*data++ = c;
|
||||
c += fibonacciTable[d & 15];
|
||||
*data++ = c;
|
||||
}
|
||||
sfx->len *= 2;
|
||||
}
|
||||
if (f.ioErr()) {
|
||||
error("I/O error when reading '%s'", _entryName);
|
||||
}
|
||||
} else {
|
||||
error("Can't open '%s'", _entryName);
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::load_MAP_menu(const char *fileName, uint8 *dstPtr) {
|
||||
debug(DBG_RES, "Resource::load_MAP_menu('%s')", fileName);
|
||||
sprintf(_entryName, "%s.MAP", fileName);
|
||||
File f;
|
||||
if (f.open(_entryName, _dataPath, "rb")) {
|
||||
if (f.size() != 0x3800 * 4) {
|
||||
error("Wrong file size for '%s', %d", _entryName, f.size());
|
||||
}
|
||||
f.read(dstPtr, 0x3800 * 4);
|
||||
if (f.ioErr()) {
|
||||
error("I/O error when reading '%s'", _entryName);
|
||||
}
|
||||
} else {
|
||||
error("Can't open '%s'", _entryName);
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::load_PAL_menu(const char *fileName, uint8 *dstPtr) {
|
||||
debug(DBG_RES, "Resource::load_PAL_menu('%s')", fileName);
|
||||
sprintf(_entryName, "%s.PAL", fileName);
|
||||
File f;
|
||||
if (f.open(_entryName, _dataPath, "rb")) {
|
||||
if (f.size() != 768) {
|
||||
error("Wrong file size for '%s', %d", _entryName, f.size());
|
||||
}
|
||||
f.read(dstPtr, 768);
|
||||
if (f.ioErr()) {
|
||||
error("I/O error when reading '%s'", _entryName);
|
||||
}
|
||||
} else {
|
||||
error("Can't open '%s'", _entryName);
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::load_SPR_OFF(const char *fileName, uint8 *sprData) {
|
||||
debug(DBG_RES, "Resource::load_SPR_OFF('%s')", fileName);
|
||||
sprintf(_entryName, "%s.OFF", fileName);
|
||||
File f;
|
||||
if (f.open(_entryName, _dataPath, "rb")) {
|
||||
int len = f.size();
|
||||
uint8 *offData = (uint8 *)malloc(len);
|
||||
if (!offData) {
|
||||
error("Unable to allocate sprite offsets");
|
||||
}
|
||||
f.read(offData, len);
|
||||
if (f.ioErr()) {
|
||||
error("I/O error when reading '%s'", _entryName);
|
||||
}
|
||||
const uint8 *p = offData;
|
||||
uint16 pos;
|
||||
while ((pos = READ_LE_UINT16(p)) != 0xFFFF) {
|
||||
uint32 off = READ_LE_UINT32(p + 2);
|
||||
if (off == 0xFFFFFFFF) {
|
||||
_spr_off[pos] = 0;
|
||||
} else {
|
||||
_spr_off[pos] = sprData + off;
|
||||
}
|
||||
p += 6;
|
||||
}
|
||||
free(offData);
|
||||
} else {
|
||||
error("Can't open '%s'", _entryName);
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::load_CINE() {
|
||||
const char *baseName = 0;
|
||||
switch (_ver) {
|
||||
case VER_FR:
|
||||
baseName = "FR_CINE";
|
||||
break;
|
||||
case VER_EN:
|
||||
baseName = "ENGCINE";
|
||||
break;
|
||||
case VER_DE:
|
||||
baseName = "GERCINE";
|
||||
break;
|
||||
case VER_SP:
|
||||
baseName = "SPACINE";
|
||||
break;
|
||||
}
|
||||
debug(DBG_RES, "Resource::load_CINE('%s')", baseName);
|
||||
if (_cine_off == 0) {
|
||||
sprintf(_entryName, "%s.BIN", baseName);
|
||||
File f;
|
||||
if (f.open(_entryName, _dataPath, "rb")) {
|
||||
int len = f.size();
|
||||
_cine_off = (uint8 *)malloc(len);
|
||||
if (!_cine_off) {
|
||||
error("Unable to allocate cinematics offsets");
|
||||
}
|
||||
f.read(_cine_off, len);
|
||||
if (f.ioErr()) {
|
||||
error("I/O error when reading '%s'", _entryName);
|
||||
}
|
||||
} else {
|
||||
error("Can't open '%s'", _entryName);
|
||||
}
|
||||
}
|
||||
if (_cine_txt == 0) {
|
||||
sprintf(_entryName, "%s.TXT", baseName);
|
||||
File f;
|
||||
if (f.open(_entryName, _dataPath, "rb")) {
|
||||
int len = f.size();
|
||||
_cine_txt = (uint8 *)malloc(len);
|
||||
if (!_cine_txt) {
|
||||
error("Unable to allocate cinematics text data");
|
||||
}
|
||||
f.read(_cine_txt, len);
|
||||
if (f.ioErr()) {
|
||||
error("I/O error when reading '%s'", _entryName);
|
||||
}
|
||||
} else {
|
||||
error("Can't open '%s'", _entryName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::load_TEXT() {
|
||||
File f;
|
||||
// Load game strings
|
||||
_stringsTable = 0;
|
||||
if (f.open("STRINGS.TXT", _dataPath, "rb")) {
|
||||
const int sz = f.size();
|
||||
_extStringsTable = (uint8 *)malloc(sz);
|
||||
if (_extStringsTable) {
|
||||
f.read(_extStringsTable, sz);
|
||||
_stringsTable = _extStringsTable;
|
||||
}
|
||||
f.close();
|
||||
}
|
||||
if (!_stringsTable) {
|
||||
switch (_ver) {
|
||||
case VER_FR:
|
||||
_stringsTable = LocaleData::_stringsTableFR;
|
||||
break;
|
||||
case VER_EN:
|
||||
_stringsTable = LocaleData::_stringsTableEN;
|
||||
break;
|
||||
case VER_DE:
|
||||
_stringsTable = LocaleData::_stringsTableDE;
|
||||
break;
|
||||
case VER_SP:
|
||||
_stringsTable = LocaleData::_stringsTableSP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Load menu strings
|
||||
_textsTable = 0;
|
||||
if (f.open("MENUS.TXT", _dataPath, "rb")) {
|
||||
const int offs = LocaleData::LI_NUM * sizeof(char *);
|
||||
const int sz = f.size() + 1;
|
||||
_extTextsTable = (char **)malloc(offs + sz);
|
||||
if (_extTextsTable) {
|
||||
char *textData = (char *)_extTextsTable + offs;
|
||||
f.read(textData, sz);
|
||||
textData[sz] = 0;
|
||||
int textsCount = 0;
|
||||
for (char *eol; (eol = strpbrk(textData, "\r\n")) != 0; ) {
|
||||
*eol++ = 0;
|
||||
if (*eol == '\r' || *eol == '\n') {
|
||||
*eol++ = 0;
|
||||
}
|
||||
if (textsCount < LocaleData::LI_NUM && textData[0] != 0) {
|
||||
_extTextsTable[textsCount] = textData;
|
||||
++textsCount;
|
||||
}
|
||||
textData = eol;
|
||||
}
|
||||
if (textsCount < LocaleData::LI_NUM && textData[0] != 0) {
|
||||
_extTextsTable[textsCount] = textData;
|
||||
++textsCount;
|
||||
}
|
||||
if (textsCount < LocaleData::LI_NUM) {
|
||||
free(_extTextsTable);
|
||||
_extTextsTable = 0;
|
||||
} else {
|
||||
_textsTable = (const char **)_extTextsTable;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!_textsTable) {
|
||||
switch (_ver) {
|
||||
case VER_FR:
|
||||
_textsTable = LocaleData::_textsTableFR;
|
||||
break;
|
||||
case VER_EN:
|
||||
_textsTable = LocaleData::_textsTableEN;
|
||||
break;
|
||||
case VER_DE:
|
||||
_textsTable = LocaleData::_textsTableDE;
|
||||
break;
|
||||
case VER_SP:
|
||||
_textsTable = LocaleData::_textsTableSP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::free_TEXT() {
|
||||
if (_extTextsTable) {
|
||||
free(_extTextsTable);
|
||||
_extTextsTable = 0;
|
||||
}
|
||||
_stringsTable = 0;
|
||||
if (_extStringsTable) {
|
||||
free(_extStringsTable);
|
||||
_extStringsTable = 0;
|
||||
}
|
||||
_textsTable = 0;
|
||||
}
|
||||
|
||||
void Resource::load(const char *objName, int objType) {
|
||||
debug(DBG_RES, "Resource::load('%s', %d)", objName, objType);
|
||||
LoadStub loadStub = 0;
|
||||
switch (objType) {
|
||||
case OT_MBK:
|
||||
debug(DBG_RES, "chargement bank (mbk)");
|
||||
sprintf(_entryName, "%s.MBK", objName);
|
||||
loadStub = &Resource::load_MBK;
|
||||
break;
|
||||
case OT_PGE:
|
||||
debug(DBG_RES, "chargement piege (pge)");
|
||||
sprintf(_entryName, "%s.PGE", objName);
|
||||
loadStub = &Resource::load_PGE;
|
||||
break;
|
||||
case OT_PAL:
|
||||
debug(DBG_RES, "chargement palettes (pal)");
|
||||
sprintf(_entryName, "%s.PAL", objName);
|
||||
loadStub = &Resource::load_PAL;
|
||||
break;
|
||||
case OT_CT:
|
||||
debug(DBG_RES, "chargement collision (ct)");
|
||||
sprintf(_entryName, "%s.CT", objName);
|
||||
loadStub = &Resource::load_CT;
|
||||
break;
|
||||
case OT_MAP:
|
||||
debug(DBG_RES, "ouverture map (map)");
|
||||
sprintf(_entryName, "%s.MAP", objName);
|
||||
loadStub = &Resource::load_MAP;
|
||||
break;
|
||||
case OT_SPC:
|
||||
debug(DBG_RES, "chargement sprites caracteres (spc)");
|
||||
strcpy(_entryName, "GLOBAL.SPC");
|
||||
loadStub = &Resource::load_SPC;
|
||||
break;
|
||||
case OT_RP:
|
||||
debug(DBG_RES, "chargement positions des banks pour sprite_car (rp)");
|
||||
sprintf(_entryName, "%s.RP", objName);
|
||||
loadStub = &Resource::load_RP;
|
||||
break;
|
||||
case OT_SPR:
|
||||
debug(DBG_RES, "chargement des sprites (spr)");
|
||||
sprintf(_entryName, "%s.SPR", objName);
|
||||
loadStub = &Resource::load_SPR;
|
||||
break;
|
||||
case OT_SPRM:
|
||||
debug(DBG_RES, "chargement des sprites monstre (spr)");
|
||||
sprintf(_entryName, "%s.SPR", objName);
|
||||
loadStub = &Resource::load_SPRM;
|
||||
break;
|
||||
case OT_ICN:
|
||||
debug(DBG_RES, "chargement des icones (icn)");
|
||||
sprintf(_entryName, "%s.ICN", objName);
|
||||
loadStub = &Resource::load_ICN;
|
||||
break;
|
||||
case OT_FNT:
|
||||
debug(DBG_RES, "chargement de la font (fnt)");
|
||||
sprintf(_entryName, "%s.FNT", objName);
|
||||
loadStub = &Resource::load_FNT;
|
||||
break;
|
||||
case OT_OBJ:
|
||||
debug(DBG_RES, "chargement objets (obj)");
|
||||
sprintf(_entryName, "%s.OBJ", objName);
|
||||
loadStub = &Resource::load_OBJ;
|
||||
break;
|
||||
case OT_ANI:
|
||||
debug(DBG_RES, "chargement animations (ani)");
|
||||
sprintf(_entryName, "%s.ANI", objName);
|
||||
loadStub = &Resource::load_ANI;
|
||||
break;
|
||||
case OT_TBN:
|
||||
debug(DBG_RES, "chargement des textes (tbn)");
|
||||
sprintf(_entryName, "%s.TBN", objName);
|
||||
loadStub = &Resource::load_TBN;
|
||||
break;
|
||||
case OT_CMD:
|
||||
debug(DBG_RES, "chargement des commandes (cmd)");
|
||||
sprintf(_entryName, "%s.CMD", objName);
|
||||
loadStub = &Resource::load_CMD;
|
||||
break;
|
||||
case OT_POL:
|
||||
debug(DBG_RES, "chargement des polygones (pol)");
|
||||
sprintf(_entryName, "%s.POL", objName);
|
||||
loadStub = &Resource::load_POL;
|
||||
break;
|
||||
default:
|
||||
error("Unimplemented Resource::load() type %d", objType);
|
||||
break;
|
||||
}
|
||||
if (loadStub) {
|
||||
File f;
|
||||
if (f.open(_entryName, _dataPath, "rb")) {
|
||||
(this->*loadStub)(&f);
|
||||
if (f.ioErr()) {
|
||||
error("I/O error when reading '%s'", _entryName);
|
||||
}
|
||||
} else {
|
||||
error("Can't open '%s'", _entryName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::load_CT(File *pf) {
|
||||
debug(DBG_RES, "Resource::load_CT()");
|
||||
int len = pf->size();
|
||||
uint8 *tmp = (uint8 *)malloc(len);
|
||||
if (!tmp) {
|
||||
error("Unable to allocate CT buffer");
|
||||
} else {
|
||||
pf->read(tmp, len);
|
||||
if (!delphine_unpack((uint8 *)_ctData, tmp, len)) {
|
||||
error("Bad CRC for collision data");
|
||||
}
|
||||
free(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::load_FNT(File *f) {
|
||||
debug(DBG_RES, "Resource::load_FNT()");
|
||||
int len = f->size();
|
||||
_fnt = (uint8 *)malloc(len);
|
||||
if (!_fnt) {
|
||||
error("Unable to allocate FNT buffer");
|
||||
} else {
|
||||
f->read(_fnt, len);
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::load_MBK(File *f) {
|
||||
debug(DBG_RES, "Resource::load_MBK()");
|
||||
uint8 num = f->readByte();
|
||||
int dataSize = f->size() - num * 6;
|
||||
_mbk = (MbkEntry *)malloc(sizeof(MbkEntry) * num);
|
||||
if (!_mbk) {
|
||||
error("Unable to allocate MBK buffer");
|
||||
}
|
||||
f->seek(0);
|
||||
for (int i = 0; i < num; ++i) {
|
||||
f->readUint16BE(); /* unused */
|
||||
_mbk[i].offset = f->readUint16BE() - num * 6;
|
||||
_mbk[i].len = f->readUint16BE();
|
||||
debug(DBG_RES, "dataSize=0x%X entry %d off=0x%X len=0x%X", dataSize, i, _mbk[i].offset + num * 6, _mbk[i].len);
|
||||
assert(_mbk[i].offset <= dataSize);
|
||||
}
|
||||
_mbkData = (uint8 *)malloc(dataSize);
|
||||
if (!_mbkData) {
|
||||
error("Unable to allocate MBK data buffer");
|
||||
}
|
||||
f->read(_mbkData, dataSize);
|
||||
}
|
||||
|
||||
void Resource::load_ICN(File *f) {
|
||||
debug(DBG_RES, "Resource::load_ICN()");
|
||||
int len = f->size();
|
||||
_icn = (uint8 *)malloc(len);
|
||||
if (!_icn) {
|
||||
error("Unable to allocate ICN buffer");
|
||||
} else {
|
||||
f->read(_icn, len);
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::load_SPR(File *f) {
|
||||
debug(DBG_RES, "Resource::load_SPR()");
|
||||
int len = f->size() - 12;
|
||||
_spr1 = (uint8 *)malloc(len);
|
||||
if (!_spr1) {
|
||||
error("Unable to allocate SPR buffer");
|
||||
} else {
|
||||
f->seek(12);
|
||||
f->read(_spr1, len);
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::load_SPRM(File *f) {
|
||||
debug(DBG_RES, "Resource::load_SPRM()");
|
||||
int len = f->size() - 12;
|
||||
f->seek(12);
|
||||
f->read(_sprm, len);
|
||||
}
|
||||
|
||||
void Resource::load_RP(File *f) {
|
||||
debug(DBG_RES, "Resource::load_RP()");
|
||||
f->read(_rp, 0x4A);
|
||||
}
|
||||
|
||||
void Resource::load_SPC(File *f) {
|
||||
debug(DBG_RES, "Resource::load_SPC()");
|
||||
int len = f->size();
|
||||
_spc = (uint8 *)malloc(len);
|
||||
if (!_spc) {
|
||||
error("Unable to allocate SPC buffer");
|
||||
} else {
|
||||
f->read(_spc, len);
|
||||
_numSpc = READ_BE_UINT16(_spc) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::load_PAL(File *f) {
|
||||
debug(DBG_RES, "Resource::load_PAL()");
|
||||
int len = f->size();
|
||||
_pal = (uint8 *)malloc(len);
|
||||
if (!_pal) {
|
||||
error("Unable to allocate PAL buffer");
|
||||
} else {
|
||||
f->read(_pal, len);
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::load_MAP(File *f) {
|
||||
debug(DBG_RES, "Resource::load_MAP()");
|
||||
int len = f->size();
|
||||
_map = (uint8 *)malloc(len);
|
||||
if (!_map) {
|
||||
error("Unable to allocate MAP buffer");
|
||||
} else {
|
||||
f->read(_map, len);
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::load_OBJ(File *f) {
|
||||
debug(DBG_RES, "Resource::load_OBJ()");
|
||||
|
||||
uint16 i;
|
||||
|
||||
_numObjectNodes = f->readUint16LE();
|
||||
assert(_numObjectNodes < 255);
|
||||
|
||||
uint32 offsets[256];
|
||||
for (i = 0; i < _numObjectNodes; ++i) {
|
||||
offsets[i] = f->readUint32LE();
|
||||
}
|
||||
offsets[i] = f->size() - 2;
|
||||
|
||||
int numObjectsCount = 0;
|
||||
uint16 objectsCount[256];
|
||||
for (i = 0; i < _numObjectNodes; ++i) {
|
||||
int diff = offsets[i + 1] - offsets[i];
|
||||
if (diff != 0) {
|
||||
objectsCount[numObjectsCount] = (diff - 2) / 0x12;
|
||||
debug(DBG_RES, "i=%d objectsCount[numObjectsCount]=%d", i, objectsCount[numObjectsCount]);
|
||||
++numObjectsCount;
|
||||
}
|
||||
}
|
||||
|
||||
uint32 prevOffset = 0;
|
||||
ObjectNode *prevNode = 0;
|
||||
int iObj = 0;
|
||||
for (i = 0; i < _numObjectNodes; ++i) {
|
||||
if (prevOffset != offsets[i]) {
|
||||
ObjectNode *on = (ObjectNode *)malloc(sizeof(ObjectNode));
|
||||
if (!on) {
|
||||
error("Unable to allocate ObjectNode num=%d", i);
|
||||
}
|
||||
f->seek(offsets[i] + 2);
|
||||
on->last_obj_number = f->readUint16LE();
|
||||
on->num_objects = objectsCount[iObj];
|
||||
debug(DBG_RES, "last=%d num=%d", on->last_obj_number, on->num_objects);
|
||||
on->objects = (Object *)malloc(sizeof(Object) * on->num_objects);
|
||||
for (uint16 j = 0; j < on->num_objects; ++j) {
|
||||
Object *obj = &on->objects[j];
|
||||
obj->type = f->readUint16LE();
|
||||
obj->dx = f->readByte();
|
||||
obj->dy = f->readByte();
|
||||
obj->init_obj_type = f->readUint16LE();
|
||||
obj->opcode2 = f->readByte();
|
||||
obj->opcode1 = f->readByte();
|
||||
obj->flags = f->readByte();
|
||||
obj->opcode3 = f->readByte();
|
||||
obj->init_obj_number = f->readUint16LE();
|
||||
obj->opcode_arg1 = f->readUint16LE();
|
||||
obj->opcode_arg2 = f->readUint16LE();
|
||||
obj->opcode_arg3 = f->readUint16LE();
|
||||
debug(DBG_RES, "obj_node=%d obj=%d op1=0x%X op2=0x%X op3=0x%X", i, j, obj->opcode2, obj->opcode1, obj->opcode3);
|
||||
}
|
||||
++iObj;
|
||||
prevOffset = offsets[i];
|
||||
prevNode = on;
|
||||
}
|
||||
_objectNodesMap[i] = prevNode;
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::free_OBJ() {
|
||||
debug(DBG_RES, "Resource::free_OBJ()");
|
||||
ObjectNode *prevNode = 0;
|
||||
for (int i = 0; i < _numObjectNodes; ++i) {
|
||||
if (_objectNodesMap[i] != prevNode) {
|
||||
ObjectNode *curNode = _objectNodesMap[i];
|
||||
free(curNode->objects);
|
||||
_objectNodesMap[i] = 0;
|
||||
prevNode = curNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::load_PGE(File *f) {
|
||||
debug(DBG_RES, "Resource::load_PGE()");
|
||||
int len = f->size() - 2;
|
||||
_pgeNum = f->readUint16LE();
|
||||
memset(_pgeInit, 0, sizeof(_pgeInit));
|
||||
debug(DBG_RES, "len=%d _pgeNum=%d", len, _pgeNum);
|
||||
for (uint16 i = 0; i < _pgeNum; ++i) {
|
||||
InitPGE *pge = &_pgeInit[i];
|
||||
pge->type = f->readUint16LE();
|
||||
pge->pos_x = f->readUint16LE();
|
||||
pge->pos_y = f->readUint16LE();
|
||||
pge->obj_node_number = f->readUint16LE();
|
||||
pge->life = f->readUint16LE();
|
||||
for (int lc = 0; lc < 4; ++lc) {
|
||||
pge->counter_values[lc] = f->readUint16LE();
|
||||
}
|
||||
pge->object_type = f->readByte();
|
||||
pge->init_room = f->readByte();
|
||||
pge->room_location = f->readByte();
|
||||
pge->init_flags = f->readByte();
|
||||
pge->colliding_icon_num = f->readByte();
|
||||
pge->icon_num = f->readByte();
|
||||
pge->object_id = f->readByte();
|
||||
pge->skill = f->readByte();
|
||||
pge->mirror_x = f->readByte();
|
||||
pge->flags = f->readByte();
|
||||
pge->unk1C = f->readByte();
|
||||
f->readByte();
|
||||
pge->text_num = f->readByte();
|
||||
f->readByte();
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::load_ANI(File *f) {
|
||||
debug(DBG_RES, "Resource::load_ANI()");
|
||||
int size = f->size() - 2;
|
||||
_ani = (uint8 *)malloc(size);
|
||||
if (!_ani) {
|
||||
error("Unable to allocate ANI buffer");
|
||||
} else {
|
||||
f->seek(2);
|
||||
f->read(_ani, size);
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::load_TBN(File *f) {
|
||||
debug(DBG_RES, "Resource::load_TBN()");
|
||||
int len = f->size();
|
||||
_tbn = (uint8 *)malloc(len);
|
||||
if (!_tbn) {
|
||||
error("Unable to allocate TBN buffer");
|
||||
} else {
|
||||
f->read(_tbn, len);
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::load_CMD(File *pf) {
|
||||
debug(DBG_RES, "Resource::load_CMD()");
|
||||
free(_cmd);
|
||||
int len = pf->size();
|
||||
_cmd = (uint8 *)malloc(len);
|
||||
if (!_cmd) {
|
||||
error("Unable to allocate CMD buffer");
|
||||
} else {
|
||||
pf->read(_cmd, len);
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::load_POL(File *pf) {
|
||||
debug(DBG_RES, "Resource::load_POL()");
|
||||
free(_pol);
|
||||
int len = pf->size();
|
||||
_pol = (uint8 *)malloc(len);
|
||||
if (!_pol) {
|
||||
error("Unable to allocate POL buffer");
|
||||
} else {
|
||||
pf->read(_pol, len);
|
||||
}
|
||||
}
|
||||
|
||||
void Resource::load_VCE(int num, int segment, uint8 **buf, uint32 *bufSize) {
|
||||
*buf = 0;
|
||||
int offset = _voicesOffsetsTable[num];
|
||||
if (offset != 0xFFFF) {
|
||||
const uint16 *p = _voicesOffsetsTable + offset / 2;
|
||||
offset = (*p++) * 2048;
|
||||
int count = *p++;
|
||||
if (segment < count) {
|
||||
File f;
|
||||
if (f.open("VOICE.VCE", _dataPath, "rb")) {
|
||||
int voiceSize = p[segment] * 2048 / 5;
|
||||
free(_voiceBuf);
|
||||
_voiceBuf = (uint8 *)malloc(voiceSize);
|
||||
if (_voiceBuf) {
|
||||
uint8 *dst = _voiceBuf;
|
||||
offset += 0x2000;
|
||||
for (int s = 0; s < count; ++s) {
|
||||
int len = p[s] * 2048;
|
||||
for (int i = 0; i < len / (0x2000 + 2048); ++i) {
|
||||
if (s == segment) {
|
||||
f.seek(offset);
|
||||
int n = 2048;
|
||||
while (n--) {
|
||||
int v = f.readByte();
|
||||
if (v & 0x80) {
|
||||
v = -(v & 0x7F);
|
||||
}
|
||||
*dst++ = (uint8)(v & 0xFF);
|
||||
}
|
||||
}
|
||||
offset += 0x2000 + 2048;
|
||||
}
|
||||
if (s == segment) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
*buf = _voiceBuf;
|
||||
*bufSize = voiceSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
/* REminiscence - Flashback interpreter
|
||||
* Copyright (C) 2005-2007 Gregory Montoir
|
||||
*
|
||||
* This program 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.
|
||||
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __RESOURCE_H__
|
||||
#define __RESOURCE_H__
|
||||
|
||||
#include "intern.h"
|
||||
|
||||
struct File;
|
||||
|
||||
struct LocaleData {
|
||||
enum Id {
|
||||
LI_01_CONTINUE_OR_ABORT = 0,
|
||||
LI_02_TIME,
|
||||
LI_03_CONTINUE,
|
||||
LI_04_ABORT,
|
||||
LI_05_COMPLETED,
|
||||
LI_06_LEVEL,
|
||||
LI_07_START,
|
||||
LI_08_SKILL,
|
||||
LI_09_PASSWORD,
|
||||
LI_10_INFO,
|
||||
LI_11_QUIT,
|
||||
LI_12_SKILL_LEVEL,
|
||||
LI_13_EASY,
|
||||
LI_14_NORMAL,
|
||||
LI_15_EXPERT,
|
||||
LI_16_ENTER_PASSWORD1,
|
||||
LI_17_ENTER_PASSWORD2,
|
||||
LI_18_RESUME_GAME,
|
||||
LI_19_ABORT_GAME,
|
||||
LI_20_LOAD_GAME,
|
||||
LI_21_SAVE_GAME,
|
||||
LI_22_SAVE_SLOT,
|
||||
|
||||
LI_NUM
|
||||
};
|
||||
|
||||
static const char *_textsTableFR[];
|
||||
static const char *_textsTableEN[];
|
||||
static const char *_textsTableDE[];
|
||||
static const char *_textsTableSP[];
|
||||
static const uint8 _stringsTableFR[];
|
||||
static const uint8 _stringsTableEN[];
|
||||
static const uint8 _stringsTableDE[];
|
||||
static const uint8 _stringsTableSP[];
|
||||
};
|
||||
|
||||
struct Resource {
|
||||
typedef void (Resource::*LoadStub)(File *);
|
||||
|
||||
enum ObjectType {
|
||||
OT_MBK = 0x00,
|
||||
OT_PGE = 0x01,
|
||||
OT_PAL = 0x02,
|
||||
OT_CT = 0x03,
|
||||
OT_MAP = 0x04,
|
||||
OT_SGD = 0x05,
|
||||
OT_SPC = 0x06,
|
||||
OT_RP = 0x07,
|
||||
OT_DEMO = 0x08,
|
||||
OT_ANI = 0x09,
|
||||
OT_OBJ = 0x0A,
|
||||
OT_TBN = 0x0B,
|
||||
OT_SPR = 0x0C,
|
||||
OT_TAB = 0x0D,
|
||||
OT_ICN = 0x0E,
|
||||
OT_FNT = 0x0F,
|
||||
OT_TXTBIN = 0x10,
|
||||
OT_CMD = 0x11,
|
||||
OT_POL = 0x12,
|
||||
OT_SPRM = 0x13,
|
||||
OT_OFF = 0x14,
|
||||
|
||||
OT_NUM = 0x15
|
||||
};
|
||||
|
||||
static const uint16 _voicesOffsetsTable[];
|
||||
|
||||
const char *_dataPath;
|
||||
Version _ver;
|
||||
char _entryName[30];
|
||||
uint8 *_fnt;
|
||||
MbkEntry *_mbk;
|
||||
uint8 *_mbkData;
|
||||
uint8 *_icn;
|
||||
uint8 *_tab;
|
||||
uint8 *_spc; // BE
|
||||
uint16 _numSpc;
|
||||
uint8 _rp[0x4A];
|
||||
uint8 *_pal; // BE
|
||||
uint8 *_ani;
|
||||
uint8 *_tbn;
|
||||
int8 _ctData[0x1D00];
|
||||
uint8 *_spr1;
|
||||
uint8 *_spr_off[1287]; // 0-0x22F + 0x28E-0x2E9 ... conrad, 0x22F-0x28D : junkie
|
||||
uint8 _sprm[0x8411]; // MERCENAI.SPR size
|
||||
uint16 _pgeNum;
|
||||
InitPGE _pgeInit[256];
|
||||
uint8 *_map;
|
||||
uint16 _numObjectNodes;
|
||||
ObjectNode *_objectNodesMap[255];
|
||||
uint8 *_memBuf;
|
||||
SoundFx *_sfxList;
|
||||
uint8 _numSfx;
|
||||
uint8 *_cmd;
|
||||
uint8 *_pol;
|
||||
uint8 *_cine_off;
|
||||
uint8 *_cine_txt;
|
||||
uint8 *_voiceBuf;
|
||||
char **_extTextsTable;
|
||||
const char **_textsTable;
|
||||
uint8 *_extStringsTable;
|
||||
const uint8 *_stringsTable;
|
||||
|
||||
Resource(const char *dataPath, Version ver);
|
||||
~Resource();
|
||||
|
||||
void clearLevelRes();
|
||||
void load_FIB(const char *fileName);
|
||||
void load_MAP_menu(const char *fileName, uint8 *dstPtr);
|
||||
void load_PAL_menu(const char *fileName, uint8 *dstPtr);
|
||||
void load_SPR_OFF(const char *fileName, uint8 *sprData);
|
||||
void load_CINE();
|
||||
void load_TEXT();
|
||||
void free_TEXT();
|
||||
void load(const char *objName, int objType);
|
||||
void load_CT(File *pf);
|
||||
void load_FNT(File *pf);
|
||||
void load_MBK(File *pf);
|
||||
void load_ICN(File *pf);
|
||||
void load_SPR(File *pf);
|
||||
void load_SPRM(File *pf);
|
||||
void load_RP(File *pf);
|
||||
void load_SPC(File *pf);
|
||||
void load_PAL(File *pf);
|
||||
void load_MAP(File *pf);
|
||||
void load_OBJ(File *pf);
|
||||
void free_OBJ();
|
||||
void load_PGE(File *pf);
|
||||
void load_ANI(File *pf);
|
||||
void load_TBN(File *pf);
|
||||
void load_CMD(File *pf);
|
||||
void load_POL(File *pf);
|
||||
void load_VCE(int num, int segment, uint8 **buf, uint32 *bufSize);
|
||||
const uint8 *getGameString(int num) {
|
||||
return _stringsTable + READ_LE_UINT16(_stringsTable + num * 2);
|
||||
}
|
||||
const char *getMenuString(int num) {
|
||||
return (num >= 0 && num < LocaleData::LI_NUM) ? _textsTable[num] : "";
|
||||
}
|
||||
};
|
||||
|
||||
#endif // __RESOURCE_H__
|
||||
@@ -0,0 +1,142 @@
|
||||
/* REminiscence - Flashback interpreter
|
||||
* Copyright (C) 2005-2007 Gregory Montoir
|
||||
*
|
||||
* This program 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.
|
||||
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "scaler.h"
|
||||
|
||||
|
||||
const Scaler _scalers[] = {
|
||||
{ "point1x", &point1x, 1 },
|
||||
{ "point2x", &point2x, 2 },
|
||||
{ "scale2x", &scale2x, 2 },
|
||||
{ "point3x", &point3x, 3 },
|
||||
{ "scale3x", &scale3x, 3 }
|
||||
};
|
||||
|
||||
void point1x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h) {
|
||||
dstPitch >>= 1;
|
||||
while (h--) {
|
||||
memcpy(dst, src, w * 2);
|
||||
dst += dstPitch;
|
||||
src += srcPitch;
|
||||
}
|
||||
}
|
||||
|
||||
void point2x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h) {
|
||||
dstPitch >>= 1;
|
||||
while (h--) {
|
||||
uint16 *p = dst;
|
||||
for (int i = 0; i < w; ++i, p += 2) {
|
||||
uint16 c = *(src + i);
|
||||
*(p) = c;
|
||||
*(p + 1) = c;
|
||||
*(p + dstPitch) = c;
|
||||
*(p + dstPitch + 1) = c;
|
||||
}
|
||||
dst += dstPitch * 2;
|
||||
src += srcPitch;
|
||||
}
|
||||
}
|
||||
|
||||
void point3x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h) {
|
||||
dstPitch >>= 1;
|
||||
while (h--) {
|
||||
uint16 *p = dst;
|
||||
for (int i = 0; i < w; ++i, p += 3) {
|
||||
uint16 c = *(src + i);
|
||||
*(p) = c;
|
||||
*(p + 1) = c;
|
||||
*(p + 2) = c;
|
||||
*(p + dstPitch) = c;
|
||||
*(p + dstPitch + 1) = c;
|
||||
*(p + dstPitch + 2) = c;
|
||||
*(p + 2 * dstPitch) = c;
|
||||
*(p + 2 * dstPitch + 1) = c;
|
||||
*(p + 2 * dstPitch + 2) = c;
|
||||
}
|
||||
dst += dstPitch * 3;
|
||||
src += srcPitch;
|
||||
}
|
||||
}
|
||||
|
||||
void scale2x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h) {
|
||||
dstPitch >>= 1;
|
||||
while (h--) {
|
||||
uint16 *p = dst;
|
||||
for (int i = 0; i < w; ++i, p += 2) {
|
||||
uint16 B = *(src + i - srcPitch);
|
||||
uint16 D = *(src + i - 1);
|
||||
uint16 E = *(src + i);
|
||||
uint16 F = *(src + i + 1);
|
||||
uint16 H = *(src + i + srcPitch);
|
||||
if (B != H && D != F) {
|
||||
*(p) = D == B ? D : E;
|
||||
*(p + 1) = B == F ? F : E;
|
||||
*(p + dstPitch) = D == H ? D : E;
|
||||
*(p + dstPitch + 1) = H == F ? F : E;
|
||||
} else {
|
||||
*(p) = E;
|
||||
*(p + 1) = E;
|
||||
*(p + dstPitch) = E;
|
||||
*(p + dstPitch + 1) = E;
|
||||
}
|
||||
}
|
||||
dst += dstPitch * 2;
|
||||
src += srcPitch;
|
||||
}
|
||||
}
|
||||
|
||||
void scale3x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h) {
|
||||
dstPitch >>= 1;
|
||||
while (h--) {
|
||||
uint16 *p = dst;
|
||||
for (int i = 0; i < w; ++i, p += 3) {
|
||||
uint16 A = *(src + i - srcPitch - 1);
|
||||
uint16 B = *(src + i - srcPitch);
|
||||
uint16 C = *(src + i - srcPitch + 1);
|
||||
uint16 D = *(src + i - 1);
|
||||
uint16 E = *(src + i);
|
||||
uint16 F = *(src + i + 1);
|
||||
uint16 G = *(src + i + srcPitch - 1);
|
||||
uint16 H = *(src + i + srcPitch);
|
||||
uint16 I = *(src + i + srcPitch + 1);
|
||||
if (B != H && D != F) {
|
||||
*(p) = D == B ? D : E;
|
||||
*(p + 1) = (D == B && E != C) || (B == F && E != A) ? B : E;
|
||||
*(p + 2) = B == F ? F : E;
|
||||
*(p + dstPitch) = (D == B && E != G) || (D == B && E != A) ? D : E;
|
||||
*(p + dstPitch + 1) = E;
|
||||
*(p + dstPitch + 2) = (B == F && E != I) || (H == F && E != C) ? F : E;
|
||||
*(p + 2 * dstPitch) = D == H ? D : E;
|
||||
*(p + 2 * dstPitch + 1) = (D == H && E != I) || (H == F && E != G) ? H : E;
|
||||
*(p + 2 * dstPitch + 2) = H == F ? F : E;
|
||||
} else {
|
||||
*(p) = E;
|
||||
*(p + 1) = E;
|
||||
*(p + 2) = E;
|
||||
*(p + dstPitch) = E;
|
||||
*(p + dstPitch + 1) = E;
|
||||
*(p + dstPitch + 2) = E;
|
||||
*(p + 2 * dstPitch) = E;
|
||||
*(p + 2 * dstPitch + 1) = E;
|
||||
*(p + 2 * dstPitch + 2) = E;
|
||||
}
|
||||
}
|
||||
dst += dstPitch * 3;
|
||||
src += srcPitch;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user