mirror of
https://github.com/Bithack/principia.git
synced 2026-06-24 02:04:08 +00:00
Compare commits
No commits in common. "master" and "2024.07.12" have entirely different histories.
master
...
2024.07.12
1903 changed files with 35972 additions and 133860 deletions
6
.gitattributes
vendored
6
.gitattributes
vendored
|
|
@ -1,3 +1,7 @@
|
|||
|
||||
# Exclude vendored libraries from GitHub language detection
|
||||
lib/* linguist-vendored
|
||||
src/lua/* linguist-vendored
|
||||
src/luasocket/* linguist-vendored
|
||||
src/SDL_image/* linguist-vendored
|
||||
src/SDL_mixer/* linguist-vendored
|
||||
src/SDL-mobile/* linguist-vendored
|
||||
|
|
|
|||
2
.github/CONTRIBUTING.md
vendored
2
.github/CONTRIBUTING.md
vendored
|
|
@ -1,2 +0,0 @@
|
|||
# Contributing to Principia
|
||||
Contributions are welcome! Please see [Contributing to the Game](https://principia-web.se/wiki/Contributing_to_the_Game) on the Principia Wiki for more information.
|
||||
28
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
28
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: If you are reporting a bug, please fill out this form with the necessary details.
|
||||
title: ''
|
||||
labels: Bug
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
##### Principia version
|
||||
<!--
|
||||
Describe the version you are running here. Are you on a 1.5.2 Beta build downloaded
|
||||
from principia-web or have you built from source? If you're reporting something from
|
||||
1.5.1 make sure it still exists in the open source version.
|
||||
-->
|
||||
|
||||
##### OS / Hardware
|
||||
<!-- General information about your hardware and operating system -->
|
||||
- Platform:
|
||||
- Operating system:
|
||||
|
||||
<!-- For graphical issues only, feel free to omit if not graphical -->
|
||||
- GPU model:
|
||||
|
||||
##### Summary
|
||||
<!-- Describe your problem here -->
|
||||
|
||||
##### Steps to reproduce
|
||||
<!-- Explain the steps one could take to reproduce it. If reporting a Lua issue, please give a minimal code example to reproduce it. -->
|
||||
40
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
40
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
|
|
@ -1,40 +0,0 @@
|
|||
name: Bug report
|
||||
description: Reporting bugs, crashes and other related issues with the game
|
||||
labels: ["Bug"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: Thank you for helping to make the game better by reporting issues that you discover. Make sure to describe the necessary details about the bug such that it can be reproduced by others. Additionally please refrain from using LLMs ("AI") to write or "improve" your report, as they typically just make it more verbose without adding any useful information.
|
||||
- type: input
|
||||
attributes:
|
||||
label: Principia version
|
||||
description: Describe the version you are running here. Are you on a stable release or on a nightly build, or have you built from source? To determine where a non-release build was built off of you can press the version number in the bottom right corner of the main menu.
|
||||
placeholder: "Example: 20XX.XX.XX"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: Platform
|
||||
description: A lot of times a issue can be specific to a particular platform. Please write the platform you're on, or list the platforms you can reproduce it on.
|
||||
placeholder: "Example: Linux"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: System information
|
||||
description: Give some information about your device that may be relevant for your issue. For example it would be helpful to know your GPU vendor for graphical issues.
|
||||
placeholder: "Example: AMD Radeon RX 560 with Mesa drivers"
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Summary
|
||||
description: Describe the problem here.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: Explain the steps one could take to reproduce it. If applicable, providing Lua code snippets or attaching a test level would also be helpful.
|
||||
validations:
|
||||
required: true
|
||||
5
.github/ISSUE_TEMPLATE/config.yml
vendored
5
.github/ISSUE_TEMPLATE/config.yml
vendored
|
|
@ -1,5 +0,0 @@
|
|||
blank_issues_enabled: true
|
||||
contact_links:
|
||||
- name: Questions
|
||||
url: https://principia-web.se/forum/
|
||||
about: For asking more general questions about Principia, please see the Principia forums.
|
||||
11
.github/SECURITY.md
vendored
11
.github/SECURITY.md
vendored
|
|
@ -1,11 +0,0 @@
|
|||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
We only support the latest stable version for security issues.
|
||||
|
||||
## Reporting a Vulnerability
|
||||
If you have found a bug that could be exploited by a malicious actor by playing a level or in any other way where an end-user could be victimised, then please responsibly disclose it privately by email to:
|
||||
|
||||
- ROllerozxa, project maintainer \<rollerozxa@voxelmanip.se\>
|
||||
|
||||
We will evaluate possible means of mitigating it on the community site and/or swiftly release a new version of Principia to fix the issue, depending on the severity. If it is deemed to not be a security-critical issue then we'll ask you to file a public bug report issue.
|
||||
22
.github/workflows/android.yml
vendored
22
.github/workflows/android.yml
vendored
|
|
@ -4,18 +4,16 @@ on:
|
|||
push:
|
||||
paths:
|
||||
- 'src/**'
|
||||
- 'lib/**'
|
||||
- 'android/**'
|
||||
- 'data/**'
|
||||
- 'build-android/**'
|
||||
- 'data-*/**'
|
||||
- 'packaging/**'
|
||||
- 'CMakeLists.txt'
|
||||
- '.github/workflows/android.yml'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'src/**'
|
||||
- 'lib/**'
|
||||
- 'android/**'
|
||||
- 'data/**'
|
||||
- 'build-android/**'
|
||||
- 'data-*/**'
|
||||
- 'packaging/**'
|
||||
- 'CMakeLists.txt'
|
||||
- '.github/workflows/android.yml'
|
||||
|
|
@ -24,23 +22,21 @@ jobs:
|
|||
android:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v5
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
|
||||
- name: Build with gradle
|
||||
run: |
|
||||
cd android
|
||||
cd build-android
|
||||
./gradlew assemblerelease
|
||||
|
||||
- name: Save apk artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: principia-release-unsigned.apk
|
||||
path: android/principia/build/outputs/apk/release/principia-release-unsigned.apk
|
||||
#archive: false
|
||||
if-no-files-found: error
|
||||
path: build-android/principia/build/outputs/apk/release/principia-release-unsigned.apk
|
||||
|
|
|
|||
34
.github/workflows/build_utils.yml
vendored
34
.github/workflows/build_utils.yml
vendored
|
|
@ -1,34 +0,0 @@
|
|||
name: build_utils
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'src/**'
|
||||
- 'utils/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'src/**'
|
||||
- 'utils/**'
|
||||
|
||||
jobs:
|
||||
build_utils:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libjansson-dev
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd utils
|
||||
make
|
||||
|
||||
- name: Upload output as artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: principia-utils
|
||||
path: utils/bin/
|
||||
if-no-files-found: error
|
||||
30
.github/workflows/linux.yml
vendored
30
.github/workflows/linux.yml
vendored
|
|
@ -4,16 +4,14 @@ on:
|
|||
push:
|
||||
paths:
|
||||
- 'src/**'
|
||||
- 'lib/**'
|
||||
- 'data/**'
|
||||
- 'data-*/**'
|
||||
- 'packaging/**'
|
||||
- 'CMakeLists.txt'
|
||||
- '.github/workflows/linux.yml'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'src/**'
|
||||
- 'lib/**'
|
||||
- 'data/**'
|
||||
- 'data-*/**'
|
||||
- 'packaging/**'
|
||||
- 'CMakeLists.txt'
|
||||
- '.github/workflows/linux.yml'
|
||||
|
|
@ -25,35 +23,23 @@ jobs:
|
|||
image: debian:bullseye
|
||||
env: { LANG: "C.UTF-8" }
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install deps
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y \
|
||||
clang-16 libgtk-3-dev libgl-dev libcurl4-openssl-dev libpng-dev libjpeg-dev libfreetype6-dev cmake ninja-build desktop-file-utils ca-certificates wget file \
|
||||
libasound2-dev libpulse-dev libjack-dev libsndio-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libxtst-dev libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev libpipewire-0.3-dev libwayland-dev liburing-dev \
|
||||
--no-install-recommends
|
||||
apt-get install -y g++ libgtk-3-dev libgl-dev libglew-dev libcurl4-openssl-dev libpng-dev libjpeg-dev libfreetype6-dev cmake ninja-build desktop-file-utils ca-certificates wget file --no-install-recommends
|
||||
|
||||
wget https://github.com/principia-game/linux-deps/releases/download/latest/deps.tar.gz -O linux-deps.tar.gz
|
||||
tar -xaf linux-deps.tar.gz -C /
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
mkdir build; cd build
|
||||
../packaging/build-appimage.sh
|
||||
env:
|
||||
CC: clang-16
|
||||
CXX: clang++-16
|
||||
|
||||
- name: Upload output as artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Principia-x86_64.AppImage
|
||||
path: build/Principia-x86_64.AppImage
|
||||
#archive: false
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Upload debug symbols as artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: linux-appimage-dbgsym
|
||||
path: build/principia.debug
|
||||
if-no-files-found: error
|
||||
|
|
|
|||
19
.github/workflows/linux_ss.yml
vendored
19
.github/workflows/linux_ss.yml
vendored
|
|
@ -4,40 +4,35 @@ on:
|
|||
push:
|
||||
paths:
|
||||
- 'src/**'
|
||||
- 'lib/**'
|
||||
- 'data/**'
|
||||
- 'data-*/**'
|
||||
- 'CMakeLists.txt'
|
||||
- '.github/workflows/linux_ss.yml'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'src/**'
|
||||
- 'lib/**'
|
||||
- 'data/**'
|
||||
- 'data-*/**'
|
||||
- 'CMakeLists.txt'
|
||||
- '.github/workflows/linux_ss.yml'
|
||||
|
||||
jobs:
|
||||
linux_ss:
|
||||
runs-on: ubuntu-24.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y g++ libgl-dev libpng-dev libjpeg-dev libfreetype6-dev cmake ninja-build \
|
||||
libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libxtst-dev libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libegl1-mesa-dev \
|
||||
--no-install-recommends
|
||||
sudo apt-get install -y g++ libgl-dev libpng-dev libjpeg-dev libfreetype6-dev libsdl2-dev cmake ninja-build --no-install-recommends
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
mkdir build; cd build
|
||||
cmake .. -DSCREENSHOT_BUILD=ON -G Ninja -DUSE_VENDORED_SDL3=ON
|
||||
cmake .. -DSCREENSHOT_BUILD=ON -G Ninja
|
||||
ninja -j4
|
||||
|
||||
- name: Upload output as artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: screenshotter_artifact
|
||||
path: build/principia
|
||||
if-no-files-found: error
|
||||
|
|
|
|||
19
.github/workflows/macos.yml
vendored
19
.github/workflows/macos.yml
vendored
|
|
@ -4,16 +4,14 @@ on:
|
|||
push:
|
||||
paths:
|
||||
- 'src/**'
|
||||
- 'lib/**'
|
||||
- 'data/**'
|
||||
- 'data-*/**'
|
||||
- 'packaging/**'
|
||||
- 'CMakeLists.txt'
|
||||
- '.github/workflows/macos.yml'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'src/**'
|
||||
- 'lib/**'
|
||||
- 'data/**'
|
||||
- 'data-*/**'
|
||||
- 'packaging/**'
|
||||
- 'CMakeLists.txt'
|
||||
- '.github/workflows/macos.yml'
|
||||
|
|
@ -22,14 +20,16 @@ jobs:
|
|||
macos:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install deps
|
||||
run: |
|
||||
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
|
||||
export HOMEBREW_NO_INSTALL_CLEANUP=1
|
||||
brew update --auto-update
|
||||
brew install cmake ninja libpng libjpeg-turbo freetype sdl3 gtk+3
|
||||
brew install cmake ninja glew libpng libjpeg-turbo freetype sdl2 gtk+3
|
||||
|
||||
patch /opt/homebrew/include/GL/glew.h < packaging/glew_macos_fix.patch
|
||||
|
||||
- name: Compile
|
||||
run: |
|
||||
|
|
@ -38,7 +38,8 @@ jobs:
|
|||
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.14 \
|
||||
-DCMAKE_FIND_FRAMEWORK=LAST \
|
||||
-DCMAKE_INSTALL_PREFIX=../build/macos/ \
|
||||
-DCMAKE_EXE_LINKER_FLAGS="-L/opt/homebrew/lib/"
|
||||
-DCMAKE_EXE_LINKER_FLAGS="-L/opt/homebrew/lib/" \
|
||||
-DGLEW_LIBRARY_RELEASE=/opt/homebrew/lib/libGLEW.dylib
|
||||
ninja
|
||||
|
||||
- name: Package
|
||||
|
|
@ -47,9 +48,7 @@ jobs:
|
|||
ninja package
|
||||
|
||||
- name: Upload output as artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: principia-macos
|
||||
path: build/*.zip
|
||||
#archive: false
|
||||
if-no-files-found: error
|
||||
|
|
|
|||
47
.github/workflows/web.yml
vendored
47
.github/workflows/web.yml
vendored
|
|
@ -1,47 +0,0 @@
|
|||
name: web
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'src/**'
|
||||
- 'lib/**'
|
||||
- 'data/**'
|
||||
- 'packaging/**'
|
||||
- 'CMakeLists.txt'
|
||||
- '.github/workflows/web.yml'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'src/**'
|
||||
- 'lib/**'
|
||||
- 'data/**'
|
||||
- 'packaging/**'
|
||||
- 'CMakeLists.txt'
|
||||
- '.github/workflows/web.yml'
|
||||
|
||||
jobs:
|
||||
web:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: emscripten/emsdk:latest
|
||||
env: { LANG: "C.UTF-8" }
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y ninja-build
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
mkdir build; cd build
|
||||
emcmake cmake .. -G Ninja -DCMAKE_INSTALL_PREFIX= -DUSE_VENDORED_SDL3=ON
|
||||
ninja
|
||||
DESTDIR=../web ninja install
|
||||
|
||||
- name: Save apk artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: principia-wasm
|
||||
path: web/
|
||||
if-no-files-found: error
|
||||
26
.github/workflows/windows.yml
vendored
26
.github/workflows/windows.yml
vendored
|
|
@ -4,16 +4,14 @@ on:
|
|||
push:
|
||||
paths:
|
||||
- 'src/**'
|
||||
- 'lib/**'
|
||||
- 'data/**'
|
||||
- 'data-*/**'
|
||||
- 'packaging/**'
|
||||
- 'CMakeLists.txt'
|
||||
- '.github/workflows/windows.yml'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'src/**'
|
||||
- 'lib/**'
|
||||
- 'data/**'
|
||||
- 'data-*/**'
|
||||
- 'packaging/**'
|
||||
- 'CMakeLists.txt'
|
||||
- '.github/workflows/windows.yml'
|
||||
|
|
@ -25,29 +23,31 @@ jobs:
|
|||
run:
|
||||
shell: msys2 {0}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
update: true
|
||||
release: false
|
||||
msystem: CLANG64
|
||||
msystem: UCRT64
|
||||
pacboy: >-
|
||||
git:
|
||||
gcc:p
|
||||
cmake:p
|
||||
ninja:p
|
||||
glew:p
|
||||
zlib:p
|
||||
gtk3:p
|
||||
libpng:p
|
||||
libjpeg-turbo:p
|
||||
sdl3:p
|
||||
SDL2:p
|
||||
nsis:p
|
||||
7zip:p
|
||||
|
||||
# custom built packages with less dependencies than MSYS' counterparts
|
||||
- name: Install external packages
|
||||
run: |
|
||||
./packaging/windows-install-pkgs.sh
|
||||
wget https://grejer.voxelmanip.se/msys-pkgs/mingw-w64-ucrt-x86_64-{curl-winssl-8.8.0-10,freetype-2.13.2-1}-any.pkg.tar.zst
|
||||
pacman -U --noconfirm *.pkg.tar.zst
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
|
|
@ -62,17 +62,13 @@ jobs:
|
|||
../packaging/windows_portable.sh
|
||||
|
||||
- name: Upload output as artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: principia-setup.exe
|
||||
path: build/principia-setup.exe
|
||||
#archive: false
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Upload output as artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: principia-portable.7z
|
||||
path: build/principia-portable.7z
|
||||
#archive: false
|
||||
if-no-files-found: error
|
||||
|
|
|
|||
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -11,8 +11,8 @@ opengl32.dll
|
|||
compile_commands.json
|
||||
|
||||
# Doxygen documentation
|
||||
doxy/
|
||||
doxygen-awesome.css
|
||||
doc/doxy/
|
||||
doc/doxygen-awesome.css
|
||||
|
||||
# Model junk files
|
||||
*.blend1
|
||||
|
|
|
|||
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -1,3 +0,0 @@
|
|||
[submodule "android/principia/deps-src"]
|
||||
path = android/principia/deps-src
|
||||
url = https://github.com/principia-game/android-deps
|
||||
322
CMakeLists.txt
322
CMakeLists.txt
|
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.14)
|
||||
cmake_minimum_required(VERSION 3.9)
|
||||
|
||||
project(principia)
|
||||
|
||||
|
|
@ -15,43 +15,29 @@ endif()
|
|||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
||||
|
||||
include(DownloadLib)
|
||||
|
||||
add_custom_target(GenerateGitVersion
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D "GENERATE_VERSION_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
-D "GENERATE_VERSION_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}"
|
||||
-P "${CMAKE_SOURCE_DIR}/cmake/Modules/GenerateGitVersion.cmake"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
option(UNITY_BUILD "Experimental unity build" FALSE)
|
||||
mark_as_advanced(UNITY_BUILD)
|
||||
|
||||
option(USE_VENDORED_SDL3 "Build with vendored SDL3 library" FALSE)
|
||||
|
||||
# Find core dependencies
|
||||
# ----------------------
|
||||
|
||||
if(USE_VENDORED_SDL3)
|
||||
include(cmake/SDL.cmake)
|
||||
else()
|
||||
find_package(SDL3 REQUIRED)
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
include(PrincipiaAndroidLibs)
|
||||
|
||||
else()
|
||||
if(NOT EMSCRIPTEN)
|
||||
find_package(SDL2 REQUIRED)
|
||||
else()
|
||||
include(PrincipiaEmscriptenLibs)
|
||||
endif()
|
||||
|
||||
set(OpenGL_GL_PREFERENCE GLVND)
|
||||
find_package(OpenGL REQUIRED)
|
||||
endif()
|
||||
|
||||
if(NOT EMSCRIPTEN)
|
||||
find_package(Freetype REQUIRED)
|
||||
find_package(JPEG REQUIRED)
|
||||
find_package(PNG REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
endif()
|
||||
find_package(Freetype REQUIRED)
|
||||
find_package(JPEG REQUIRED)
|
||||
find_package(PNG REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
|
||||
# Determine platform and backend
|
||||
|
|
@ -63,18 +49,14 @@ else()
|
|||
set(SCREENSHOT_BUILD FALSE)
|
||||
endif()
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
set(BACKEND_IMGUI TRUE)
|
||||
else()
|
||||
option(BACKEND_IMGUI "Enable incomplete Dear Imgui dialog backend (Experimental)" FALSE)
|
||||
endif()
|
||||
|
||||
set(TMS_FORMFACTOR "PC")
|
||||
if(WIN32)
|
||||
set(TMS_BACKEND "WINDOWS")
|
||||
elseif(ANDROID)
|
||||
set(TMS_BACKEND "ANDROID")
|
||||
set(TMS_FORMFACTOR "MOBILE")
|
||||
elseif(SCREENSHOT_BUILD)
|
||||
set(TMS_BACKEND "LINUX_SS")
|
||||
elseif(HAIKU)
|
||||
set(TMS_BACKEND "HAIKU")
|
||||
elseif(APPLE)
|
||||
|
|
@ -100,99 +82,116 @@ endif()
|
|||
# ----------------------------------
|
||||
|
||||
include_directories(
|
||||
lib/
|
||||
lib/GLAD/include/
|
||||
lib/imgui/
|
||||
lib/lua/
|
||||
lib/SDL_image/
|
||||
lib/SDL_mixer/
|
||||
src/
|
||||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
src/lua/
|
||||
src/SDL_image/
|
||||
src/src/
|
||||
${FREETYPE_INCLUDE_DIRS}
|
||||
${JPEG_INCLUDE_DIRS}
|
||||
${PNG_INCLUDE_DIRS}
|
||||
${ZLIB_INCLUDE_DIRS})
|
||||
|
||||
file(GLOB SRCS CONFIGURE_DEPENDS
|
||||
lib/GLAD/src/gl.c
|
||||
lib/lua/*.c
|
||||
lib/SDL_image/*.c
|
||||
file(GLOB SRCS
|
||||
src/tms/core/*.c
|
||||
src/tms/math/*.c
|
||||
src/tms/util/*.c
|
||||
src/tms/bindings/cpp/cpp.cc
|
||||
src/tms/modules/3ds.c
|
||||
|
||||
src/lua/*.c
|
||||
src/SDL_image/*.c
|
||||
|
||||
src/src/*.cc
|
||||
src/src/*.c
|
||||
|
||||
src/src/Box2D/Collision/*.cc
|
||||
src/src/Box2D/Collision/Shapes/*.cc
|
||||
src/src/Box2D/Common/*.cc
|
||||
src/src/Box2D/Dynamics/*.cc
|
||||
src/src/Box2D/Dynamics/Contacts/*.cc
|
||||
src/src/Box2D/Dynamics/Joints/*.cc
|
||||
src/src/Box2D/Particle/*.cc
|
||||
)
|
||||
|
||||
if(UNITY_BUILD)
|
||||
list(APPEND SRCS
|
||||
src/tms/_unity_chunk.c
|
||||
src/_unity_chunk.cc
|
||||
src/game.cc
|
||||
src/game-gearbox-edit.cc
|
||||
src/game-gui.cc
|
||||
src/game-panel-edit.cc
|
||||
src/menu_pkg.cc
|
||||
src/repair_station.cc
|
||||
src/solver_ingame.cc
|
||||
|
||||
lib/Box2D/_unity_chunk.cc)
|
||||
else()
|
||||
file(GLOB MAIN_SRCS CONFIGURE_DEPENDS
|
||||
src/tms/core/*.c
|
||||
src/tms/math/*.c
|
||||
src/tms/cpp.cc
|
||||
src/tms/modules/3ds.c
|
||||
|
||||
src/*.cc
|
||||
src/luascript/*.cc
|
||||
|
||||
lib/Box2D/Collision/*.cc
|
||||
lib/Box2D/Collision/Shapes/*.cc
|
||||
lib/Box2D/Common/*.cc
|
||||
lib/Box2D/Dynamics/*.cc
|
||||
lib/Box2D/Dynamics/Contacts/*.cc
|
||||
lib/Box2D/Dynamics/Joints/*.cc
|
||||
lib/Box2D/Particle/*.cc)
|
||||
list(APPEND SRCS ${MAIN_SRCS})
|
||||
endif()
|
||||
|
||||
if(BACKEND_IMGUI)
|
||||
file(GLOB IMGUI_SRCS CONFIGURE_DEPENDS
|
||||
lib/imgui/*.cpp
|
||||
lib/imgui/misc/freetype/*.cpp
|
||||
src/ui/*.cc)
|
||||
list(APPEND SRCS ${IMGUI_SRCS})
|
||||
endif()
|
||||
# For non-Android, system SDL2 and OpenGL include dirs
|
||||
include_directories(
|
||||
${SDL2_INCLUDE_DIRS}
|
||||
${OPENGL_INCLUDE_DIRS})
|
||||
|
||||
# Optional dependencies not found on Android or in the screenshot build
|
||||
if(NOT SCREENSHOT_BUILD)
|
||||
if(NOT ANDROID AND NOT EMSCRIPTEN)
|
||||
if(NOT BACKEND_IMGUI)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
|
||||
endif()
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
|
||||
|
||||
if(NOT BACKEND_IMGUI)
|
||||
include_directories(${GTK3_INCLUDE_DIRS})
|
||||
endif()
|
||||
find_package(GLEW REQUIRED)
|
||||
|
||||
include_directories(
|
||||
${GLEW_INCLUDE_DIRS}
|
||||
${GTK3_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
if(NOT EMSCRIPTEN)
|
||||
find_package(CURL REQUIRED)
|
||||
include_directories(${CURL_INCLUDE_DIR})
|
||||
add_definitions(-DBUILD_CURL)
|
||||
endif()
|
||||
find_package(CURL REQUIRED)
|
||||
|
||||
file(GLOB SDL_mixer_SRCS CONFIGURE_DEPENDS lib/SDL_mixer/*.c)
|
||||
list(APPEND SRCS ${SDL_mixer_SRCS})
|
||||
file(GLOB SDL_mixer_SRCS src/SDL_mixer/*.c)
|
||||
set(SRCS ${SRCS} ${SDL_mixer_SRCS})
|
||||
|
||||
include_directories(
|
||||
${CURL_INCLUDE_DIR}
|
||||
src/SDL_mixer/)
|
||||
|
||||
add_definitions(-DBUILD_CURL)
|
||||
endif()
|
||||
|
||||
|
||||
if(NOT UNITY_BUILD)
|
||||
if(SCREENSHOT_BUILD)
|
||||
set(BACKEND_SRC main_screenshotter.cc)
|
||||
else()
|
||||
set(BACKEND_SRC main.cc)
|
||||
list(APPEND SRCS src/tms/backend/pipe.cc)
|
||||
endif()
|
||||
# Optional luasocket functionality
|
||||
|
||||
list(APPEND SRCS src/tms/backend/${BACKEND_SRC})
|
||||
if(NOT SCREENSHOT_BUILD AND NOT ANDROID AND NOT EMSCRIPTEN)
|
||||
option(USE_LUASOCKET "Build with Luasocket support" TRUE)
|
||||
else()
|
||||
set(USE_LUASOCKET false)
|
||||
endif()
|
||||
|
||||
if(USE_LUASOCKET)
|
||||
add_definitions(-DBUILD_LUASOCKET)
|
||||
|
||||
file(GLOB LUASOCKET_SRCS
|
||||
src/luasocket/*.c)
|
||||
|
||||
set(SRCS ${SRCS} ${LUASOCKET_SRCS})
|
||||
endif()
|
||||
|
||||
|
||||
if(ANDROID)
|
||||
set(BACKEND_SRC main_android.cc)
|
||||
elseif(SCREENSHOT_BUILD)
|
||||
set(BACKEND_SRC main_screenshotter.cc)
|
||||
elseif(EMSCRIPTEN)
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||
set(BACKEND_SRC main_emscripten.cc)
|
||||
else()
|
||||
set(BACKEND_SRC main.cc)
|
||||
set(SRCS ${SRCS} src/tms/backend/pipe.cc)
|
||||
endif()
|
||||
|
||||
set(SRCS ${SRCS} src/tms/backend/${BACKEND_SRC})
|
||||
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND SRCS packaging/principia.rc)
|
||||
# Windows manifest (resource and icon) for Windows builds
|
||||
set(WINRESOURCE_FILE "packaging/principia.rc")
|
||||
set(WINMANIFEST_FILE "packaging/principia.manifest")
|
||||
|
||||
if(NOT CMAKE_RC_COMPILER)
|
||||
set(CMAKE_RC_COMPILER "windres.exe")
|
||||
endif()
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/principia.rc.o
|
||||
COMMAND ${CMAKE_RC_COMPILER} -I${CMAKE_CURRENT_SOURCE_DIR} -I${CMAKE_CURRENT_BINARY_DIR}
|
||||
-i${WINRESOURCE_FILE}
|
||||
-o ${CMAKE_CURRENT_BINARY_DIR}/principia.rc.o
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
DEPENDS ${WINRESOURCE_FILE} ${WINMANIFEST_FILE})
|
||||
set(SRCS ${SRCS} ${CMAKE_CURRENT_BINARY_DIR}/principia.rc.o)
|
||||
endif()
|
||||
|
||||
|
||||
|
|
@ -209,60 +208,58 @@ endif()
|
|||
# Link libraries against executable
|
||||
# ---------------------------------
|
||||
|
||||
if(NOT EMSCRIPTEN)
|
||||
set(LIBS
|
||||
Freetype::Freetype
|
||||
JPEG::JPEG
|
||||
PNG::PNG
|
||||
ZLIB::ZLIB)
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
${FREETYPE_LIBRARIES}
|
||||
${JPEG_LIBRARIES}
|
||||
${PNG_LIBRARIES}
|
||||
${ZLIB_LIBRARIES})
|
||||
|
||||
if(NOT SCREENSHOT_BUILD AND NOT EMSCRIPTEN)
|
||||
list(APPEND LIBS ${CURL_LIBRARIES})
|
||||
if(NOT SCREENSHOT_BUILD)
|
||||
target_link_libraries(${PROJECT_NAME} ${CURL_LIBRARIES})
|
||||
|
||||
if(NOT ANDROID AND NOT BACKEND_IMGUI)
|
||||
list(APPEND LIBS ${GTK3_LIBRARIES})
|
||||
endif()
|
||||
if(NOT ANDROID)
|
||||
target_link_libraries(${PROJECT_NAME} ${GTK3_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(NOT SHOULD_USE_GLES)
|
||||
target_link_libraries(${PROJECT_NAME} ${GLEW_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
list(APPEND LIBS SDL3::SDL3)
|
||||
if(NOT EMSCRIPTEN)
|
||||
target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(SHOULD_USE_GLES)
|
||||
list(APPEND LIBS GLESv2)
|
||||
target_link_libraries(${PROJECT_NAME} -lGLESv2)
|
||||
else()
|
||||
list(APPEND LIBS OpenGL::GL)
|
||||
target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
list(APPEND LIBS android dl log OpenSLES)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} ${LIBS})
|
||||
|
||||
add_dependencies(${PROJECT_NAME} GenerateGitVersion)
|
||||
|
||||
# Compiler flags
|
||||
# --------------
|
||||
|
||||
if(SHOULD_USE_GLES)
|
||||
add_definitions(-DTMS_USE_GLES)
|
||||
elseif(NOT SCREENSHOT_BUILD)
|
||||
add_definitions(-DTMS_USE_GLEW)
|
||||
endif()
|
||||
|
||||
if(UNITY_BUILD)
|
||||
add_definitions(-DUNITY_BUILD)
|
||||
endif()
|
||||
if(ANDROID)
|
||||
target_link_libraries(${PROJECT_NAME} -landroid -ldl -llog -lOpenSLES)
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(-D_WIN32_WINNT=0x0501)
|
||||
elseif(SCREENSHOT_BUILD)
|
||||
add_definitions(-DNO_UI -DSCREENSHOT_BUILD)
|
||||
endif()
|
||||
add_definitions(-DHAVE_GCC_ATOMICS)
|
||||
else()
|
||||
add_definitions(-DTMS_FAST_MATH)
|
||||
|
||||
if(BACKEND_IMGUI)
|
||||
add_definitions(-DPRINCIPIA_BACKEND_IMGUI -DIMGUI_DEFINE_MATH_OPERATORS)
|
||||
if(WIN32)
|
||||
target_link_libraries(${PROJECT_NAME} ws2_32.lib version.lib shlwapi.lib winmm.lib)
|
||||
|
||||
if(SHOULD_USE_GLES)
|
||||
add_definitions(-DIMGUI_IMPL_OPENGL_ES2)
|
||||
add_definitions(-D_WIN32_WINNT=0x0501 -DUNICODE)
|
||||
elseif(SCREENSHOT_BUILD)
|
||||
add_definitions(-DNO_UI)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
@ -271,13 +268,6 @@ add_definitions(-DTMS_BACKEND_${TMS_FORMFACTOR} -DTMS_BACKEND_${TMS_BACKEND})
|
|||
# Use a safe subset of fast math flags
|
||||
set(COMMON_FLAGS "-fno-math-errno -fno-trapping-math -fno-signed-zeros")
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "--preload-file ../data/")
|
||||
set(LIBRARY_FLAGS "-sUSE_FREETYPE=1 -sUSE_LIBJPEG=1 -sUSE_LIBPNG=1 -sUSE_ZLIB=1 -pthread")
|
||||
string(APPEND COMMON_FLAGS " ${LIBRARY_FLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS " ${LIBRARY_FLAGS} -pthread -sPTHREAD_POOL_SIZE=20 -sINITIAL_MEMORY=2013265920 -sALLOW_MEMORY_GROWTH=1 -sTOTAL_STACK=16Mb -sFETCH=1")
|
||||
endif()
|
||||
|
||||
set(COMMON_FLAGS_DEBUG "${COMMON_FLAGS} -O0 -ggdb -DDEBUG=1")
|
||||
set(COMMON_FLAGS_RELEASE "${COMMON_FLAGS} -DNDEBUG=1 -fomit-frame-pointer")
|
||||
|
||||
|
|
@ -289,31 +279,24 @@ set(CMAKE_CXX_FLAGS_RELEASE "${COMMON_FLAGS_RELEASE} -O2 -fno-rtti")
|
|||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -g")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${COMMON_FLAGS_DEBUG}")
|
||||
|
||||
if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_RELEASE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
string(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE "-mwindows ")
|
||||
endif()
|
||||
|
||||
# macOS Clang's linker doesn't like these flags
|
||||
if(NOT APPLE)
|
||||
string(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE "-Wl,-s ")
|
||||
if(WIN32)
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-mwindows -Wl,-s")
|
||||
else()
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-Wl,-s")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Register protocol handler util on Windows
|
||||
# -----------------------------------------
|
||||
|
||||
if(WIN32)
|
||||
add_executable(register-protocol-handler
|
||||
packaging/register-protocol-handler/main.c
|
||||
packaging/register-protocol-handler/windows.rc)
|
||||
endif()
|
||||
|
||||
# Installation
|
||||
# ------------
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "--preload-file ../data-pc/ --preload-file ../data-shared/")
|
||||
target_link_libraries(${PROJECT_NAME} -lemsocket -lssl -lcrypto)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(BUNDLE_NAME ${PROJECT_NAME}.app)
|
||||
set(BUNDLE_PATH "${BUNDLE_NAME}")
|
||||
|
|
@ -321,24 +304,19 @@ if(APPLE)
|
|||
set(BINDIR ${BUNDLE_NAME}/Contents/MacOS)
|
||||
set(SHAREDIR ${BUNDLE_NAME}/Contents/Resources)
|
||||
|
||||
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data" DESTINATION "${SHAREDIR}")
|
||||
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data-pc" DESTINATION "${SHAREDIR}")
|
||||
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data-shared" DESTINATION "${SHAREDIR}")
|
||||
|
||||
install(FILES "packaging/principia.icns" DESTINATION "${SHAREDIR}")
|
||||
install(FILES "packaging/Info.plist" DESTINATION "${BUNDLE_PATH}/Contents")
|
||||
|
||||
elseif(EMSCRIPTEN)
|
||||
|
||||
set(BINDIR .)
|
||||
install(FILES "packaging/index.html" DESTINATION .)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.wasm DESTINATION .)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.data DESTINATION .)
|
||||
|
||||
else()
|
||||
include(GNUInstallDirs)
|
||||
set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}")
|
||||
set(BINDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
|
||||
|
||||
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data" DESTINATION "${SHAREDIR}/principia")
|
||||
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data-pc" DESTINATION "${SHAREDIR}/principia")
|
||||
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data-shared" DESTINATION "${SHAREDIR}/principia")
|
||||
|
||||
install(FILES "packaging/principia.desktop" DESTINATION "${SHAREDIR}/applications")
|
||||
install(FILES "packaging/principia-url-handler.desktop" DESTINATION "${SHAREDIR}/applications")
|
||||
|
|
|
|||
8
Doxyfile
8
Doxyfile
|
|
@ -14,7 +14,9 @@ BUILTIN_STL_SUPPORT = YES
|
|||
# Input
|
||||
RECURSIVE = YES
|
||||
STRIP_FROM_PATH = src
|
||||
INPUT = src/
|
||||
INPUT = doc/main_page.dox \
|
||||
src/src/ src/tms/
|
||||
EXCLUDE = src/src/Box2D/
|
||||
|
||||
# Dot graphs
|
||||
HAVE_DOT = YES
|
||||
|
|
@ -25,7 +27,7 @@ DOT_MULTI_TARGETS = YES
|
|||
DOT_IMAGE_FORMAT = svg
|
||||
|
||||
# Output
|
||||
OUTPUT_DIRECTORY = doxy/ # /tmp/doxy/
|
||||
OUTPUT_DIRECTORY = doc/doxy/ # /tmp/doxy/
|
||||
GENERATE_LATEX = NO
|
||||
REFERENCED_BY_RELATION = YES
|
||||
REFERENCES_RELATION = YES
|
||||
|
|
@ -34,4 +36,4 @@ DISABLE_INDEX = YES
|
|||
GENERATE_TREEVIEW = YES
|
||||
HTML_DYNAMIC_SECTIONS = YES
|
||||
HTML_TIMESTAMP = YES
|
||||
HTML_EXTRA_STYLESHEET = doxygen-awesome.css
|
||||
HTML_EXTRA_STYLESHEET = doc/doxygen-awesome.css
|
||||
|
|
|
|||
12
README.md
12
README.md
|
|
@ -20,22 +20,22 @@ Principia runs on anything with a recent enough version of Windows, Linux or And
|
|||
|
||||
* Codeberg mirror: https://codeberg.org/principia/principia
|
||||
|
||||
* Mastodon: https://hachyderm.io/@principia
|
||||
* Mastodon: https://fosstodon.org/@principia
|
||||
|
||||
## Binary builds
|
||||
Release builds builds of Principia for Windows, Android and Linux are available on the [download page](https://principia-web.se/download).
|
||||
Binary builds of Principia for Windows, Android and Linux are available on the [downloads page](https://principia-web.se/download).
|
||||
|
||||
There are also nightly build artifacts that get automatically built by GitHub Actions CI on each commit and are available for download, see [Nightly Builds](https://principia-web.se/wiki/Nightly_Builds) on the wiki.
|
||||
There are also nightly build artifacts for Windows, Android and Linux that get automatically built by GitHub CI on each commit, see [Actions](https://github.com/Bithack/principia/actions). Keep in mind these may be broken at times during development, and you are recommended to use the release builds instead.
|
||||
|
||||
## Getting involved
|
||||
Feel free to fork this project and send in your pull requests. This is a community project and the community decides how the project evolves.
|
||||
|
||||
For a brief overview on how to get started with contributing to the game, see the [Contributing to the Game](https://principia-web.se/wiki/Contributing_to_the_Game) page on the wiki.
|
||||
Most of our discussion and development happens in the `#development` channel of the [Principia Discord server](https://principia-web.se/discord), make sure to join it if you want to discuss and participate in the development of the game.
|
||||
|
||||
Also be sure to follow [@principia](https://hachyderm.io/@principia) on Mastodon for more updates about the project.
|
||||
Also be sure to follow [@principia](https://fosstodon.org/@principia) on Fosstodon for more updates about the project.
|
||||
|
||||
## Building from source
|
||||
See [Compiling Principia](https://principia-web.se/wiki/Compiling_Principia) on the wiki for building from source on supported platforms.
|
||||
See [Compiling Principia](https://principia-web.se/wiki/Compiling_Principia) on the Principia Wiki.
|
||||
|
||||
(You can also view the plaintext Markdown document [here](https://raw.githubusercontent.com/principia-game/wiki/master/pages/Compiling_Principia.md))
|
||||
|
||||
|
|
|
|||
BIN
android/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
android/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
251
android/gradlew
vendored
251
android/gradlew
vendored
|
|
@ -1,251 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original 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.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
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
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# 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"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit f3e15935e822228400064b66677bd3e9d3d7a643
|
||||
|
|
@ -1 +0,0 @@
|
|||
../../../../data
|
||||
|
|
@ -1,933 +0,0 @@
|
|||
package com.bithack.principia;
|
||||
|
||||
import com.bithack.principia.shared.AutosaveDialog;
|
||||
import com.bithack.principia.shared.CamTargeterDialog;
|
||||
import com.bithack.principia.shared.ColorChooserDialog;
|
||||
import com.bithack.principia.shared.CommandPadDialog;
|
||||
import com.bithack.principia.shared.CommunityDialog;
|
||||
import com.bithack.principia.shared.ConfirmDialog;
|
||||
import com.bithack.principia.shared.ConfirmDialog.OnOptionSelectedListener;
|
||||
import com.bithack.principia.shared.ConsumableDialog;
|
||||
import com.bithack.principia.shared.DigitalDisplayDialog;
|
||||
import com.bithack.principia.shared.EventListenerDialog;
|
||||
import com.bithack.principia.shared.ExportDialog;
|
||||
import com.bithack.principia.shared.FactoryDialog;
|
||||
import com.bithack.principia.shared.FrequencyDialog;
|
||||
import com.bithack.principia.shared.FrequencyRangeDialog;
|
||||
import com.bithack.principia.shared.FxEmitterDialog;
|
||||
import com.bithack.principia.shared.InfoDialog;
|
||||
import com.bithack.principia.shared.ImportDialog;
|
||||
import com.bithack.principia.shared.JumperDialog;
|
||||
import com.bithack.principia.shared.Level;
|
||||
import com.bithack.principia.shared.LevelDialog;
|
||||
import com.bithack.principia.shared.LoginDialog;
|
||||
import com.bithack.principia.shared.NewLevelDialog;
|
||||
import com.bithack.principia.shared.OpenDialog;
|
||||
import com.bithack.principia.shared.PkgLevelDialog;
|
||||
import com.bithack.principia.shared.PlayDialog;
|
||||
import com.bithack.principia.shared.PromptDialog;
|
||||
import com.bithack.principia.shared.PromptSettingsDialog;
|
||||
import com.bithack.principia.shared.PublishDialog;
|
||||
import com.bithack.principia.shared.PublishedDialog;
|
||||
import com.bithack.principia.shared.QuickaddDialog;
|
||||
import com.bithack.principia.shared.RegisterDialog;
|
||||
import com.bithack.principia.shared.ResourceDialog;
|
||||
import com.bithack.principia.shared.RobotDialog;
|
||||
import com.bithack.principia.shared.RubberDialog;
|
||||
import com.bithack.principia.shared.SandboxTipsDialog;
|
||||
import com.bithack.principia.shared.SaveAsDialog;
|
||||
import com.bithack.principia.shared.ScriptDialog;
|
||||
import com.bithack.principia.shared.SequencerDialog;
|
||||
import com.bithack.principia.shared.SettingsDialog;
|
||||
import com.bithack.principia.shared.Sfx2Dialog;
|
||||
import com.bithack.principia.shared.SfxDialog;
|
||||
import com.bithack.principia.shared.ShapeExtruderDialog;
|
||||
import com.bithack.principia.shared.PolygonDialog;
|
||||
import com.bithack.principia.shared.KeyListenerDialog;
|
||||
import com.bithack.principia.shared.EmitterDialog;
|
||||
import com.bithack.principia.shared.DecorationDialog;
|
||||
import com.bithack.principia.shared.AnimalDialog;
|
||||
import com.bithack.principia.shared.StickyDialog;
|
||||
import com.bithack.principia.shared.SynthesizerDialog;
|
||||
import com.bithack.principia.shared.TimerDialog;
|
||||
import com.bithack.principia.shared.ToolDialog;
|
||||
import com.bithack.principia.shared.TouchFieldDialog;
|
||||
import com.bithack.principia.shared.VariableDialog;
|
||||
import com.bithack.principia.shared.SoundManDialog;
|
||||
import com.bithack.principia.shared.MultiSelectDialog;
|
||||
import com.bithack.principia.shared.VendorDialog;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.*;
|
||||
import android.content.*;
|
||||
import android.content.DialogInterface.OnKeyListener;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.view.*;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.MenuItem.OnMenuItemClickListener;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.net.Uri;
|
||||
import android.os.*;
|
||||
import android.graphics.*;
|
||||
import android.media.*;
|
||||
import android.hardware.*;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PrincipiaActivity extends SDLActivity implements View.OnSystemUiVisibilityChangeListener, DialogInterface.OnDismissListener, DialogInterface.OnShowListener, OnSeekBarChangeListener {
|
||||
private static final String TAG = "PrincipiaActivity";
|
||||
|
||||
public static Dialog wv_dialog;
|
||||
public static WebView wv;
|
||||
public static CookieManager wv_cm;
|
||||
|
||||
public static int num_dialogs = 0;
|
||||
|
||||
static Toast last_toast = null;
|
||||
private static SettingsDialog settings_dialog;
|
||||
|
||||
public static final int LEVEL_LOCAL = 0;
|
||||
public static final int LEVEL_DB = 1;
|
||||
public static final int LEVEL_MAIN = 2;
|
||||
public static final int LEVEL_SYS = 3;
|
||||
public static final int LEVEL_PARTIAL = 4;
|
||||
|
||||
public static final int LEVEL_LOCAL_STATE = 100;
|
||||
public static final int LEVEL_DB_STATE = 101;
|
||||
public static final int LEVEL_MAIN_STATE = 102;
|
||||
|
||||
public static final int ACTION_OPEN = 1;
|
||||
public static final int ACTION_RELOAD_GRAPHICS = 2;
|
||||
public static final int ACTION_RELOAD_LEVEL = 3;
|
||||
public static final int ACTION_SAVE = 4;
|
||||
public static final int ACTION_NEW_LEVEL = 5;
|
||||
public static final int ACTION_STICKY = 6;
|
||||
public static final int ACTION_LOGIN = 7;
|
||||
public static final int ACTION_SAVE_COPY = 8;
|
||||
public static final int ACTION_CONSTRUCT_ENTITY = 9;
|
||||
public static final int ACTION_OPEN_PLAY = 10;
|
||||
public static final int ACTION_PUBLISH = 11;
|
||||
public static final int ACTION_PLAY_PKG = 12;
|
||||
public static final int ACTION_WARP = 13;
|
||||
public static final int ACTION_PUBLISH_PKG = 14;
|
||||
public static final int ACTION_PING = 15;
|
||||
public static final int ACTION_UPGRADE_LEVEL = 16;
|
||||
public static final int ACTION_DERIVE = 17;
|
||||
public static final int ACTION_SET_STICKY_TEXT = 18;
|
||||
public static final int ACTION_IMPORT_OBJECT = 19;
|
||||
public static final int ACTION_EXPORT_OBJECT = 20;
|
||||
public static final int ACTION_MULTIEMITTER_SET = 21;
|
||||
public static final int ACTION_PUZZLEPLAY = 22;
|
||||
public static final int ACTION_EDIT = 23;
|
||||
public static final int ACTION_AUTOFIT_LEVEL_BORDERS = 24;
|
||||
public static final int ACTION_RESTART_LEVEL = 25;
|
||||
public static final int ACTION_BACK = 26;
|
||||
public static final int ACTION_RESELECT = 27;
|
||||
public static final int ACTION_HIGHLIGHT_SELECTED = 28;
|
||||
public static final int ACTION_OPEN_AUTOSAVE = 31;
|
||||
public static final int ACTION_REMOVE_AUTOSAVE = 32;
|
||||
public static final int ACTION_GOTO_MAINMENU = 33;
|
||||
public static final int ACTION_DELETE_LEVEL = 34;
|
||||
public static final int ACTION_DELETE_PARTIAL = 35;
|
||||
public static final int ACTION_SET_LEVEL_TYPE = 36;
|
||||
public static final int ACTION_RELOAD_DISPLAY = 37;
|
||||
public static final int ACTION_ENTITY_MODIFIED = 38;
|
||||
public static final int ACTION_SET_MODE = 39;
|
||||
public static final int ACTION_MAIN_MENU_PKG = 40;
|
||||
public static final int ACTION_WORLD_PAUSE = 41;
|
||||
public static final int ACTION_CONSTRUCT_ITEM = 45;
|
||||
public static final int ACTION_SUBMIT_SCORE = 46;
|
||||
public static final int ACTION_MULTI_DELETE = 47;
|
||||
public static final int ACTION_OPEN_STATE = 48;
|
||||
public static final int ACTION_AUTOSAVE = 49;
|
||||
|
||||
public static final int ACTION_MULTI_JOINT_STRENGTH = 50;
|
||||
public static final int ACTION_MULTI_PLASTIC_COLOR = 51;
|
||||
public static final int ACTION_MULTI_PLASTIC_DENSITY = 52;
|
||||
public static final int ACTION_MULTI_CHANGE_CONNECTION_RENDER_TYPE = 53;
|
||||
public static final int ACTION_MULTI_UNLOCK_ALL = 54;
|
||||
public static final int ACTION_MULTI_DISCONNECT_ALL = 55;
|
||||
|
||||
public static final int ACTION_SAVE_STATE = 65;
|
||||
public static final int ACTION_SELF_DESTRUCT = 71;
|
||||
|
||||
public static final int DIALOG_SANDBOX_MENU = 1;
|
||||
public static final int DIALOG_QUICKADD = 100;
|
||||
public static final int DIALOG_BEAM_COLOR = 101;
|
||||
public static final int DIALOG_SAVE = 102;
|
||||
public static final int DIALOG_OPEN = 103;
|
||||
public static final int DIALOG_NEW_LEVEL = 104;
|
||||
public static final int DIALOG_SET_FREQUENCY = 105;
|
||||
public static final int DIALOG_PIXEL_COLOR = 106;
|
||||
public static final int DIALOG_CONFIRM_QUIT = 107;
|
||||
public static final int DIALOG_SET_COMMAND = 108;
|
||||
public static final int DIALOG_STICKY = 109;
|
||||
public static final int DIALOG_FXEMITTER = 110;
|
||||
public static final int DIALOG_CAMTARGETER = 111;
|
||||
public static final int DIALOG_SET_FREQ_RANGE = 112;
|
||||
public static final int DIALOG_OPEN_OBJECT = 113;
|
||||
public static final int DIALOG_EXPORT = 114;
|
||||
public static final int DIALOG_SET_PKG_LEVEL = 115;
|
||||
public static final int DIALOG_ROBOT = 116;
|
||||
public static final int DIALOG_MULTIEMITTER = 117;
|
||||
public static final int DIALOG_PUZZLE_PLAY = 118;
|
||||
public static final int DIALOG_TIMER = 119;
|
||||
public static final int DIALOG_EVENTLISTENER = 120;
|
||||
public static final int DIALOG_SETTINGS = 121;
|
||||
public static final int DIALOG_SAVE_COPY = 122;
|
||||
public static final int DIALOG_LEVEL_PROPERTIES = 123;
|
||||
public static final int DIALOG_LEVEL_INFO = 124;
|
||||
public static final int DIALOG_DIGITAL_DISPLAY = 125;
|
||||
public static final int DIALOG_PLAY_MENU = 126;
|
||||
public static final int DIALOG_OPEN_AUTOSAVE = 127;
|
||||
public static final int DIALOG_COMMUNITY = 128;
|
||||
public static final int DIALOG_PROMPT_SETTINGS = 129;
|
||||
public static final int DIALOG_PROMPT = 130;
|
||||
public static final int DIALOG_SFX_EMITTER = 131;
|
||||
public static final int DIALOG_VARIABLE = 132;
|
||||
public static final int DIALOG_SYNTHESIZER = 133;
|
||||
public static final int DIALOG_SEQUENCER = 134;
|
||||
public static final int DIALOG_SHAPEEXTRUDER = 135;
|
||||
public static final int DIALOG_JUMPER = 136;
|
||||
|
||||
public static final int DIALOG_PUBLISHED = 138;
|
||||
|
||||
public static final int DIALOG_TOUCHFIELD = 140;
|
||||
public static final int DIALOG_ESCRIPT = 141;
|
||||
public static final int DIALOG_ITEM = 142;
|
||||
|
||||
public static final int DIALOG_SANDBOX_MODE = 143;
|
||||
|
||||
public static final int DIALOG_RUBBER = 144;
|
||||
|
||||
public static final int DIALOG_SOUNDMAN = 148;
|
||||
|
||||
public static final int DIALOG_FACTORY = 149;
|
||||
|
||||
public static final int DIALOG_SET_FACTION = 150;
|
||||
public static final int DIALOG_RESOURCE = 151;
|
||||
public static final int DIALOG_VENDOR = 152;
|
||||
public static final int DIALOG_ANIMAL = 153;
|
||||
public static final int DIALOG_POLYGON = 154;
|
||||
public static final int DIALOG_KEY_LISTENER = 155;
|
||||
public static final int DIALOG_OPEN_STATE = 156;
|
||||
public static final int DIALOG_POLYGON_COLOR = 157;
|
||||
public static final int DIALOG_MULTI_CONFIG = 158;
|
||||
public static final int DIALOG_EMITTER = 159;
|
||||
public static final int DIALOG_TREASURE_CHEST = 160;
|
||||
public static final int DIALOG_DECORATION = 161;
|
||||
public static final int DIALOG_SFX_EMITTER_2 = 162; // New SFX Emitter dialog (1.5.1+)
|
||||
|
||||
public static final int DIALOG_PUBLISH = 300;
|
||||
public static final int DIALOG_LOGIN = 301;
|
||||
public static final int DIALOG_SANDBOX_TIPS = 302;
|
||||
public static final int DIALOG_REGISTER = 303;
|
||||
|
||||
public static final int CLOSE_ALL_DIALOGS = 200;
|
||||
public static final int CLOSE_ABSOLUTELY_ALL_DIALOGS = 201;
|
||||
public static final int CLOSE_REGISTER_DIALOG = 202;
|
||||
public static final int DISABLE_REGISTER_LOADER = 203;
|
||||
|
||||
public static final int PROMPT_RESPONSE_NONE = 0;
|
||||
public static final int PROMPT_RESPONSE_A = 1;
|
||||
public static final int PROMPT_RESPONSE_B = 2;
|
||||
public static final int PROMPT_RESPONSE_C = 3;
|
||||
|
||||
@Override
|
||||
protected String[] getLibraries() {
|
||||
return new String[] {
|
||||
"principia"
|
||||
};
|
||||
}
|
||||
|
||||
public static PrincipiaActivity mSingleton;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mSingleton = this;
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
this.init_webview();
|
||||
|
||||
this.handle_intent(this.getIntent());
|
||||
|
||||
open_adapter = new ArrayAdapter<Level>(SDLActivity.mSingleton,
|
||||
android.R.layout.select_dialog_item);
|
||||
QuickaddDialog.object_adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line);
|
||||
}
|
||||
|
||||
|
||||
public static void message(final String s, final int longd)
|
||||
{
|
||||
Log.v("tes message", s);
|
||||
SDLActivity.mSingleton.runOnUiThread(new Runnable(){
|
||||
public void run() {
|
||||
if (last_toast != null) {
|
||||
last_toast.setText(s);
|
||||
} else {
|
||||
last_toast = Toast.makeText(SDLActivity.mSingleton, s, longd==1?Toast.LENGTH_LONG:Toast.LENGTH_SHORT);
|
||||
}
|
||||
last_toast.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void emit_signal(final int signal_id)
|
||||
{
|
||||
SDLActivity.mSingleton.runOnUiThread(new Runnable(){
|
||||
public void run() {
|
||||
if (signal_id == 200) { // SIGNAL_QUICKADD_REFRESH
|
||||
Log.v("Principia", "Quickadd refresh.");
|
||||
QuickaddDialog.object_adapter.clear();
|
||||
String[] objects = PrincipiaBackend.getObjects().split(",");
|
||||
|
||||
Log.v("Principia", String.format("Number of objects: %d", objects.length));
|
||||
|
||||
for (String name : objects) {
|
||||
QuickaddDialog.object_adapter.add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void open_url(final String url)
|
||||
{
|
||||
SDLActivity.mSingleton.runOnUiThread(new Runnable(){
|
||||
public void run() {
|
||||
String community_host = PrincipiaBackend.getCommunityHost();
|
||||
if (wv_cm != null) {
|
||||
String curl_token = PrincipiaBackend.getCookies();
|
||||
|
||||
if (curl_token != null) {
|
||||
// we got relevant cookies from curl!
|
||||
wv_cm.setCookie("."+community_host, "_PRINCSECURITY="+curl_token);
|
||||
}
|
||||
}
|
||||
|
||||
wv.stopLoading();
|
||||
wv.loadUrl(url);
|
||||
wv_dialog.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
public void init_webview()
|
||||
{
|
||||
wv_dialog = new Dialog(this, android.R.style.Theme_NoTitleBar_Fullscreen) {
|
||||
@Override
|
||||
protected void onCreate(Bundle saved_instance) {
|
||||
super.onCreate(saved_instance);
|
||||
getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
||||
}
|
||||
};
|
||||
|
||||
View v = LayoutInflater.from(this).inflate(R.layout.webview, null);
|
||||
LinearLayout ll = (LinearLayout)v.findViewById(R.id.wv_ll);
|
||||
final ProgressBar pb = (ProgressBar)v.findViewById(R.id.wv_progress);
|
||||
final TextView pb_tv = (TextView)v.findViewById(R.id.wv_progresstext);
|
||||
|
||||
wv = new WebView(this);
|
||||
wv.getSettings().setJavaScriptEnabled(true);
|
||||
int version = 0;
|
||||
PackageInfo pi;
|
||||
try {
|
||||
pi = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||
version = pi.versionCode;
|
||||
} catch (NameNotFoundException e) {
|
||||
version = 0;
|
||||
}
|
||||
wv.getSettings().setUserAgentString(String.format(Locale.US, "Principia WebView/%d (Android)", version));
|
||||
wv.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
Uri uri = Uri.parse(url);
|
||||
String host = uri.getHost();
|
||||
|
||||
if (uri.getScheme().equals("principia")) {
|
||||
Log.v("Principia", "set arg "+url);
|
||||
PrincipiaBackend.setarg(url);
|
||||
wv_dialog.dismiss();
|
||||
} else if (host.contains(PrincipiaBackend.getCommunityHost())) {
|
||||
Log.v("Principia", "Load url "+url);
|
||||
view.stopLoading();
|
||||
view.loadUrl(url);
|
||||
} else {
|
||||
Log.v(TAG, "unhandled url " + url);
|
||||
Log.v(TAG, "host: '" + uri.getHost()+"'");
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
try {
|
||||
SDLActivity.mSingleton.startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Log.v(TAG, "No app found to open url: " + url);
|
||||
}
|
||||
wv_dialog.dismiss();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url)
|
||||
{
|
||||
Log.v("Principia", "page finished: " + url);
|
||||
pb.setVisibility(View.GONE);
|
||||
pb_tv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageStarted(WebView view, String url, Bitmap favicon)
|
||||
{
|
||||
Log.v("Principia", "page started: " + url);
|
||||
pb.setVisibility(View.VISIBLE);
|
||||
pb_tv.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
ll.addView(wv);
|
||||
Button wv_close = (Button)v.findViewById(R.id.wv_close);
|
||||
wv_close.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
wv_dialog.dismiss();
|
||||
}
|
||||
});
|
||||
Button wv_reload = (Button)v.findViewById(R.id.wv_reload);
|
||||
wv_reload.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
wv.reload();
|
||||
}
|
||||
});
|
||||
|
||||
wv_dialog.setContentView(v);
|
||||
wv_dialog.setOnShowListener(this);
|
||||
wv_dialog.setOnDismissListener(this);
|
||||
wv_cm = CookieManager.getInstance();
|
||||
|
||||
wv_dialog.setOnKeyListener(new OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(DialogInterface dialog, int keyCode,
|
||||
KeyEvent event) {
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
if (wv.canGoBack()) {
|
||||
wv.goBack();
|
||||
} else {
|
||||
wv_dialog.dismiss();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean is_cool = false;
|
||||
|
||||
public static void open_dialog(final int num)
|
||||
{
|
||||
open_dialog(num, false);
|
||||
}
|
||||
|
||||
public static void open_dialog(final int num, final boolean is_cool)
|
||||
{
|
||||
PrincipiaActivity.is_cool = is_cool;
|
||||
|
||||
SDLActivity.mSingleton.runOnUiThread(new Runnable(){
|
||||
public void run() {
|
||||
if (num == DIALOG_PROMPT) {
|
||||
try {SDLActivity.mSingleton.removeDialog(num);} catch(Exception e){};
|
||||
}
|
||||
if (num == DIALOG_PLAY_MENU) {
|
||||
try {SDLActivity.mSingleton.removeDialog(num);} catch(Exception e){};
|
||||
}
|
||||
try {SDLActivity.mSingleton.removeDialog(DIALOG_OPEN);} catch(Exception e){};
|
||||
try {SDLActivity.mSingleton.removeDialog(DIALOG_OPEN_STATE);} catch(Exception e){};
|
||||
try {SDLActivity.mSingleton.removeDialog(DIALOG_MULTIEMITTER);} catch(Exception e){};
|
||||
try {SDLActivity.mSingleton.removeDialog(DIALOG_OPEN_OBJECT);} catch(Exception e){};
|
||||
SDLActivity.mSingleton.showDialog(num);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private List<Dialog> open_dialogs = new ArrayList<Dialog>();
|
||||
|
||||
public static void showInfoDialog(final String description)
|
||||
{
|
||||
SDLActivity.mSingleton.runOnUiThread(new Runnable(){
|
||||
public void run() {
|
||||
try {SDLActivity.mSingleton.removeDialog(DIALOG_LEVEL_INFO);} catch(Exception e){};
|
||||
InfoDialog.description = description;
|
||||
SDLActivity.mSingleton.showDialog(DIALOG_LEVEL_INFO);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void confirm(final String text, final String button1, final int action1, final long action1_data, final String button2, final int action2, final long action2_data, final String button3, final int action3, final long action3_data, final boolean dna_sandbox)
|
||||
{
|
||||
SDLActivity.mSingleton.runOnUiThread(new Runnable(){
|
||||
public void run() {
|
||||
new ConfirmDialog()
|
||||
.set_listener(new OnOptionSelectedListener() {
|
||||
@Override
|
||||
public void onOptionSelected(int option) {
|
||||
if (option == ConfirmDialog.OPTION_YES) {
|
||||
PrincipiaBackend.addActionAsInt(action1, action1_data);
|
||||
} else if (option == ConfirmDialog.OPTION_NO) {
|
||||
PrincipiaBackend.addActionAsInt(action2, action2_data);
|
||||
} else if (option == ConfirmDialog.OPTION_3) {
|
||||
PrincipiaBackend.addActionAsInt(action3, action3_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
.run(text, button1, button2, button3, dna_sandbox);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void showSandboxTips()
|
||||
{
|
||||
SDLActivity.mSingleton.runOnUiThread(new Runnable(){
|
||||
public void run() {
|
||||
try {SDLActivity.mSingleton.removeDialog(DIALOG_SANDBOX_TIPS);} catch(Exception e){};
|
||||
SDLActivity.mSingleton.showDialog(DIALOG_SANDBOX_TIPS);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int num)
|
||||
{
|
||||
Dialog d = null;
|
||||
|
||||
switch (num) {
|
||||
case DIALOG_SANDBOX_MENU:
|
||||
{
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(this);
|
||||
|
||||
final CharSequence[] items;
|
||||
|
||||
items = new CharSequence[] {
|
||||
"Level properties",
|
||||
"New level",
|
||||
"Save",
|
||||
"Save a copy",
|
||||
"Open",
|
||||
"Publish online",
|
||||
"Settings",
|
||||
"Log in",
|
||||
"Help: Getting started",
|
||||
"Help: Principia Wiki",
|
||||
"Browse levels online",
|
||||
"Back to menu",
|
||||
"Quit"
|
||||
};
|
||||
|
||||
bld.setItems(items, new DialogInterface.OnClickListener(){
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
/* TODO: Use dialog fragments */
|
||||
switch (which) {
|
||||
case 0: showDialog(DIALOG_LEVEL_PROPERTIES); break;
|
||||
case 1: showDialog(DIALOG_NEW_LEVEL); break;
|
||||
case 2: if (PrincipiaBackend.getLevelName().isEmpty()) {SaveAsDialog.refresh_name=true; SaveAsDialog.copy=false; showDialog(DIALOG_SAVE);} else PrincipiaBackend.triggerSave(false); break;
|
||||
case 3: SaveAsDialog.refresh_name = true; SaveAsDialog.copy = true; showDialog(DIALOG_SAVE_COPY); break;
|
||||
case 4: try {SDLActivity.mSingleton.removeDialog(DIALOG_OPEN);} catch(Exception e){}; showDialog(DIALOG_OPEN); break;
|
||||
case 5: showDialog(DIALOG_PUBLISH); break;
|
||||
case 6: showDialog(DIALOG_SETTINGS); break;
|
||||
case 7: showDialog(DIALOG_LOGIN); break;
|
||||
case 8: open_url("https://principia-web.se/wiki/Getting_Started"); break;
|
||||
case 9: open_url("https://principia-web.se/wiki/Main_Page"); break;
|
||||
case 10: open_url("https://principia-web.se/"); break;
|
||||
case 11: PrincipiaBackend.addActionAsInt(ACTION_GOTO_MAINMENU, 0); break;
|
||||
// why
|
||||
case 12: android.os.Process.killProcess(android.os.Process.myPid()); break;
|
||||
}
|
||||
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
d = bld.create();
|
||||
break;
|
||||
}
|
||||
|
||||
case DIALOG_SETTINGS:
|
||||
if (settings_dialog == null) {
|
||||
d = (settings_dialog = new SettingsDialog()).get_dialog();
|
||||
}
|
||||
break;
|
||||
|
||||
case DIALOG_QUICKADD: d = QuickaddDialog.get_dialog(); break;
|
||||
case DIALOG_OPEN: d = (new OpenDialog(false)).get_dialog(); break;
|
||||
case DIALOG_LEVEL_PROPERTIES: d = LevelDialog.get_dialog(); break;
|
||||
case DIALOG_SAVE_COPY: d = SaveAsDialog.get_dialog(); break;
|
||||
case DIALOG_SAVE: d = SaveAsDialog.get_dialog(); break;
|
||||
case DIALOG_LEVEL_INFO: d = (new InfoDialog()).get_dialog(); break;
|
||||
case DIALOG_STICKY: d = StickyDialog.get_dialog(); break;
|
||||
case DIALOG_NEW_LEVEL: d = (new NewLevelDialog()).get_dialog(); break;
|
||||
case DIALOG_ROBOT: d = RobotDialog.get_dialog(); break;
|
||||
case DIALOG_CAMTARGETER: d = CamTargeterDialog.get_dialog(); break;
|
||||
case DIALOG_SET_COMMAND: d = CommandPadDialog.get_dialog(); break;
|
||||
case DIALOG_FXEMITTER: d = FxEmitterDialog.get_dialog(); break;
|
||||
case DIALOG_EVENTLISTENER: d = EventListenerDialog.get_dialog(); break;
|
||||
case DIALOG_SET_PKG_LEVEL: d = PkgLevelDialog.get_dialog(); break;
|
||||
case DIALOG_PIXEL_COLOR: d = ColorChooserDialog.get_dialog(); break;
|
||||
case DIALOG_BEAM_COLOR: d = ColorChooserDialog.get_dialog(); break;
|
||||
case DIALOG_POLYGON_COLOR: d = ColorChooserDialog.get_dialog(); break;
|
||||
case DIALOG_DIGITAL_DISPLAY: d = DigitalDisplayDialog.get_dialog(); break;
|
||||
case DIALOG_SET_FREQUENCY: d = FrequencyDialog.get_dialog(); break;
|
||||
case DIALOG_SET_FREQ_RANGE: d = FrequencyRangeDialog.get_dialog(); break;
|
||||
case DIALOG_EXPORT: d = ExportDialog.get_dialog(); break;
|
||||
case DIALOG_MULTIEMITTER: d = (new ImportDialog(true)).get_dialog(); break;
|
||||
case DIALOG_OPEN_OBJECT: d = (new ImportDialog(false)).get_dialog(); break;
|
||||
case DIALOG_TIMER: d = TimerDialog.get_dialog(); break;
|
||||
case DIALOG_PLAY_MENU: d = (PlayDialog.create_dialog()); break;
|
||||
case DIALOG_OPEN_AUTOSAVE: d = (new AutosaveDialog()).get_dialog(); break;
|
||||
case DIALOG_COMMUNITY: d = (new CommunityDialog()).get_dialog(); break;
|
||||
case DIALOG_PROMPT_SETTINGS: d = PromptSettingsDialog.get_dialog(); break;
|
||||
case DIALOG_PROMPT: d = (new PromptDialog()).get_dialog(); break;
|
||||
case DIALOG_SFX_EMITTER: d = SfxDialog.get_dialog(); break;
|
||||
case DIALOG_SFX_EMITTER_2: d = Sfx2Dialog.get_dialog(); break;
|
||||
case DIALOG_VARIABLE: d = VariableDialog.get_dialog(); break;
|
||||
case DIALOG_SYNTHESIZER: d = SynthesizerDialog.get_dialog(); break;
|
||||
case DIALOG_SEQUENCER: d = SequencerDialog.get_dialog(); break;
|
||||
case DIALOG_JUMPER: d = JumperDialog.get_dialog(); break;
|
||||
case DIALOG_TOUCHFIELD: d = TouchFieldDialog.get_dialog(); break;
|
||||
case DIALOG_ESCRIPT: d = ScriptDialog.get_dialog(); break;
|
||||
case DIALOG_ITEM: d = ConsumableDialog.get_dialog(); break;
|
||||
case DIALOG_SANDBOX_MODE: d = (new ToolDialog()).get_dialog(); break;
|
||||
case DIALOG_RUBBER: d = RubberDialog.get_dialog(); break;
|
||||
case DIALOG_SHAPEEXTRUDER: d = ShapeExtruderDialog.get_dialog(); break;
|
||||
case DIALOG_POLYGON: d = PolygonDialog.get_dialog(); break;
|
||||
case DIALOG_KEY_LISTENER: d = KeyListenerDialog.get_dialog(); break;
|
||||
case DIALOG_EMITTER: d = EmitterDialog.get_dialog(); break;
|
||||
case DIALOG_DECORATION: d = DecorationDialog.get_dialog(); break;
|
||||
case DIALOG_ANIMAL: d = AnimalDialog.get_dialog(); break;
|
||||
case DIALOG_SOUNDMAN: d = SoundManDialog.get_dialog(); break;
|
||||
case DIALOG_MULTI_CONFIG: d = MultiSelectDialog.get_dialog(); break;
|
||||
case DIALOG_VENDOR: d = VendorDialog.get_dialog(); break;
|
||||
|
||||
case DIALOG_FACTORY: d = FactoryDialog.get_dialog(); break;
|
||||
|
||||
case DIALOG_RESOURCE: d = ResourceDialog.get_dialog(); break;
|
||||
case DIALOG_OPEN_STATE: d = (new OpenDialog(true)).get_dialog(); break;
|
||||
|
||||
case DIALOG_PUBLISH: d = PublishDialog.get_dialog(); break;
|
||||
case DIALOG_PUBLISHED: d = (new PublishedDialog()).get_dialog(); break;
|
||||
case DIALOG_LOGIN: d = LoginDialog.get_dialog(); break;
|
||||
case DIALOG_SANDBOX_TIPS: d = (new SandboxTipsDialog()).get_dialog(); break;
|
||||
case DIALOG_REGISTER: d = RegisterDialog.get_dialog(); break;
|
||||
|
||||
case CLOSE_ALL_DIALOGS: break; /* do nothing */
|
||||
case CLOSE_ABSOLUTELY_ALL_DIALOGS:
|
||||
SDLActivity.mSingleton.runOnUiThread(new Runnable(){
|
||||
public void run() {
|
||||
Log.v("Principia", "Closing all dialogs.");
|
||||
|
||||
for (Dialog open_dialog : open_dialogs) {
|
||||
Log.v("Principia", "Closing a dialog["+open_dialog.toString()+"]");
|
||||
//open_dialog.dismiss();
|
||||
}
|
||||
open_dialogs.clear();
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case CLOSE_REGISTER_DIALOG:
|
||||
SDLActivity.mSingleton.runOnUiThread(new Runnable(){
|
||||
public void run() {
|
||||
RegisterDialog.get_dialog().dismiss();
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case DISABLE_REGISTER_LOADER:
|
||||
SDLActivity.mSingleton.runOnUiThread(new Runnable(){
|
||||
public void run() {
|
||||
RegisterDialog.progressbar.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
default: Log.e("Principia", "Unhandled UI Dialog: "+num); break;
|
||||
}
|
||||
|
||||
if (d != null) {
|
||||
Log.v("Principia", "Adding dialog: "+ d);
|
||||
//this.open_dialogs.add(d);
|
||||
if (d.getWindow() != null) {
|
||||
d.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
public static ArrayAdapter<Level> open_adapter;
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v,
|
||||
ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
if (v == OpenDialog.lv) {
|
||||
AdapterContextMenuInfo aInfo = (AdapterContextMenuInfo) menuInfo;
|
||||
|
||||
final Level level = open_adapter.getItem(aInfo.position);
|
||||
|
||||
menu.setHeaderTitle("Options for " + level.get_name());
|
||||
menu.add(1, 1, 1, "Delete")
|
||||
.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
new ConfirmDialog()
|
||||
.set_listener(new OnOptionSelectedListener() {
|
||||
@Override
|
||||
public void onOptionSelected(int option) {
|
||||
if (option == ConfirmDialog.OPTION_YES) {
|
||||
PrincipiaBackend.addActionAsTriple(ACTION_DELETE_LEVEL, level.get_level_type(), level.get_id(), level.get_save_id());
|
||||
open_adapter.remove(level);
|
||||
}
|
||||
}
|
||||
})
|
||||
.run("Are you sure you want to delete this level?");
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else if (v == ImportDialog.lv) {
|
||||
AdapterContextMenuInfo aInfo = (AdapterContextMenuInfo) menuInfo;
|
||||
|
||||
final Level level = ImportDialog.list_adapter.getItem(aInfo.position);
|
||||
|
||||
menu.setHeaderTitle("Options for " + level.get_name());
|
||||
menu.add(1, 1, 1, "Delete")
|
||||
.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
new ConfirmDialog()
|
||||
.set_listener(new OnOptionSelectedListener() {
|
||||
@Override
|
||||
public void onOptionSelected(int option) {
|
||||
if (option == ConfirmDialog.OPTION_YES) {
|
||||
PrincipiaBackend.addActionAsInt(ACTION_DELETE_PARTIAL, level.get_id());
|
||||
ImportDialog.list_adapter.remove(level);
|
||||
}
|
||||
}
|
||||
})
|
||||
.run("Are you sure you want to delete this object?");
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* For the details option:
|
||||
* Level ID
|
||||
* Level name
|
||||
* Date modified
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepareDialog(int d, Dialog dialog, Bundle bundle)
|
||||
{
|
||||
switch (d) {
|
||||
case DIALOG_SETTINGS:
|
||||
if (settings_dialog != null) {
|
||||
settings_dialog.load();
|
||||
}
|
||||
break;
|
||||
|
||||
case DIALOG_QUICKADD: QuickaddDialog.prepare(dialog); break;
|
||||
case DIALOG_LEVEL_PROPERTIES: LevelDialog.prepare(dialog); break;
|
||||
case DIALOG_SAVE: SaveAsDialog.prepare(dialog); break;
|
||||
case DIALOG_SAVE_COPY: SaveAsDialog.prepare(dialog); break;
|
||||
case DIALOG_ROBOT: RobotDialog.prepare(dialog); break;
|
||||
case DIALOG_CAMTARGETER: CamTargeterDialog.prepare(dialog); break;
|
||||
case DIALOG_SET_COMMAND: CommandPadDialog.prepare(dialog); break;
|
||||
case DIALOG_FXEMITTER: FxEmitterDialog.prepare(dialog); break;
|
||||
case DIALOG_EVENTLISTENER: EventListenerDialog.prepare(dialog); break;
|
||||
case DIALOG_SET_PKG_LEVEL: PkgLevelDialog.prepare(dialog); break;
|
||||
case DIALOG_PIXEL_COLOR: ColorChooserDialog.prepare(dialog, true); break;
|
||||
case DIALOG_BEAM_COLOR: ColorChooserDialog.prepare(dialog, false); break;
|
||||
case DIALOG_POLYGON_COLOR: ColorChooserDialog.prepare(dialog, false); break;
|
||||
case DIALOG_DIGITAL_DISPLAY: DigitalDisplayDialog.prepare(dialog); break;
|
||||
case DIALOG_SET_FREQUENCY: FrequencyDialog.prepare(dialog); break;
|
||||
case DIALOG_SET_FREQ_RANGE: FrequencyRangeDialog.prepare(dialog); break;
|
||||
case DIALOG_EXPORT: ExportDialog.prepare(dialog); break;
|
||||
case DIALOG_STICKY: StickyDialog.prepare(dialog); break;
|
||||
case DIALOG_TIMER: TimerDialog.prepare(dialog); break;
|
||||
case DIALOG_PROMPT_SETTINGS: PromptSettingsDialog.prepare(dialog); break;
|
||||
case DIALOG_SFX_EMITTER: SfxDialog.prepare(dialog); break;
|
||||
case DIALOG_SFX_EMITTER_2: Sfx2Dialog.prepare(dialog); break;
|
||||
case DIALOG_VARIABLE: VariableDialog.prepare(dialog); break;
|
||||
case DIALOG_SYNTHESIZER: SynthesizerDialog.prepare(dialog); break;
|
||||
case DIALOG_SEQUENCER: SequencerDialog.prepare(dialog); break;
|
||||
case DIALOG_JUMPER: JumperDialog.prepare(dialog); break;
|
||||
case DIALOG_TOUCHFIELD: TouchFieldDialog.prepare(dialog); break;
|
||||
case DIALOG_ESCRIPT: ScriptDialog.prepare(dialog); break;
|
||||
case DIALOG_ITEM: ConsumableDialog.prepare(dialog); break;
|
||||
case DIALOG_RUBBER: RubberDialog.prepare(dialog); break;
|
||||
case DIALOG_SHAPEEXTRUDER: ShapeExtruderDialog.prepare(dialog); break;
|
||||
case DIALOG_POLYGON: PolygonDialog.prepare(dialog); break;
|
||||
case DIALOG_KEY_LISTENER: KeyListenerDialog.prepare(dialog); break;
|
||||
case DIALOG_EMITTER: EmitterDialog.prepare(dialog); break;
|
||||
case DIALOG_DECORATION: DecorationDialog.prepare(dialog); break;
|
||||
case DIALOG_ANIMAL: AnimalDialog.prepare(dialog); break;
|
||||
case DIALOG_SOUNDMAN: SoundManDialog.prepare(dialog); break;
|
||||
case DIALOG_MULTI_CONFIG: MultiSelectDialog.prepare(dialog); break;
|
||||
case DIALOG_VENDOR: VendorDialog.prepare(dialog); break;
|
||||
|
||||
case DIALOG_FACTORY: FactoryDialog.prepare(dialog); break;
|
||||
|
||||
case DIALOG_RESOURCE: ResourceDialog.prepare(dialog); break;
|
||||
|
||||
case DIALOG_PUBLISH: PublishDialog.prepare(dialog); break;
|
||||
case DIALOG_LOGIN: LoginDialog.prepare(dialog); break;
|
||||
}
|
||||
|
||||
/* Dialogs that need a separate onShowListener */
|
||||
switch (d) {
|
||||
case DIALOG_QUICKADD:
|
||||
case DIALOG_PUBLISH:
|
||||
case DIALOG_LOGIN:
|
||||
case DIALOG_SANDBOX_TIPS:
|
||||
case DIALOG_REGISTER:
|
||||
case DIALOG_PROMPT_SETTINGS:
|
||||
case DIALOG_OPEN:
|
||||
case DIALOG_OPEN_STATE:
|
||||
case DIALOG_OPEN_OBJECT:
|
||||
case DIALOG_MULTIEMITTER:
|
||||
break;
|
||||
|
||||
default: dialog.setOnShowListener(this); break;
|
||||
}
|
||||
|
||||
/* Dialogs that need to dismiss HARD */
|
||||
switch (d) {
|
||||
default: dialog.setOnDismissListener(this); break;
|
||||
}
|
||||
|
||||
//dialog.setOnCancelListener(this);
|
||||
}
|
||||
|
||||
public void onDismiss(DialogInterface dialog)
|
||||
{
|
||||
Log.v("Principia", "dialog onDismiss called");
|
||||
open_dialogs.remove(dialog);
|
||||
num_dialogs --;
|
||||
if (num_dialogs <= 0){
|
||||
num_dialogs = 0;
|
||||
PrincipiaBackend.focusGL(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void onShow(DialogInterface dialog) {
|
||||
Log.v("Principia", "dialog onShow called");
|
||||
this.open_dialogs.add((Dialog) dialog);
|
||||
num_dialogs ++;
|
||||
if (num_dialogs == 1) {
|
||||
PrincipiaBackend.focusGL(false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void on_show(DialogInterface dialog) {
|
||||
Log.v("Principia", "dialog onShow called");
|
||||
num_dialogs ++;
|
||||
if (num_dialogs == 1) {
|
||||
PrincipiaBackend.focusGL(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar sb, int progress,
|
||||
boolean fromUser) {
|
||||
Log.v("Principia", "Progress changed");
|
||||
if (sb == SynthesizerDialog.synth_pulse_width) {
|
||||
SynthesizerDialog.synth_pulse_width_tv.setText(String.format(Locale.US, "%.3f", ((float)progress) / 100.f));
|
||||
} else if (sb == SynthesizerDialog.synth_bitcrushing) {
|
||||
SynthesizerDialog.synth_bitcrushing_tv.setText(Integer.toString(progress));
|
||||
} else if (sb == SynthesizerDialog.synth_volume_vibrato_hz) {
|
||||
SynthesizerDialog.synth_volume_vibrato_hz_tv.setText(Integer.toString(progress));
|
||||
} else if (sb == SynthesizerDialog.synth_volume_vibrato_extent) {
|
||||
SynthesizerDialog.synth_volume_vibrato_extent_tv.setText(String.format(Locale.US, "%.3f", ((float)progress) / 100.f));
|
||||
} else if (sb == SynthesizerDialog.synth_freq_vibrato_hz) {
|
||||
SynthesizerDialog.synth_freq_vibrato_hz_tv.setText(Integer.toString(progress));
|
||||
} else if (sb == SynthesizerDialog.synth_freq_vibrato_extent) {
|
||||
SynthesizerDialog.synth_freq_vibrato_extent_tv.setText(String.format(Locale.US, "%.3f", ((float)progress) / 100.f));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
private void handle_intent(Intent i)
|
||||
{
|
||||
Log.v("Principia", "intent new!");
|
||||
|
||||
if (i != null) {
|
||||
if (i.getScheme() != null && i.getScheme().equals("principia")) {
|
||||
PrincipiaBackend.setarg(i.getDataString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewIntent(Intent i)
|
||||
{
|
||||
super.onNewIntent(i);
|
||||
|
||||
handle_intent(i);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,126 +0,0 @@
|
|||
package org.libsdl.app;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.AudioDeviceCallback;
|
||||
import android.media.AudioDeviceInfo;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
|
||||
class SDLAudioManager {
|
||||
protected static final String TAG = "SDLAudio";
|
||||
|
||||
protected static Context mContext;
|
||||
|
||||
private static AudioDeviceCallback mAudioDeviceCallback;
|
||||
|
||||
static void initialize() {
|
||||
mAudioDeviceCallback = null;
|
||||
|
||||
if(Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */)
|
||||
{
|
||||
mAudioDeviceCallback = new AudioDeviceCallback() {
|
||||
@Override
|
||||
public void onAudioDevicesAdded(AudioDeviceInfo[] addedDevices) {
|
||||
for (AudioDeviceInfo deviceInfo : addedDevices) {
|
||||
nativeAddAudioDevice(deviceInfo.isSink(), deviceInfo.getProductName().toString(), deviceInfo.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAudioDevicesRemoved(AudioDeviceInfo[] removedDevices) {
|
||||
for (AudioDeviceInfo deviceInfo : removedDevices) {
|
||||
nativeRemoveAudioDevice(deviceInfo.isSink(), deviceInfo.getId());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
static void setContext(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
static void release(Context context) {
|
||||
// no-op atm
|
||||
}
|
||||
|
||||
// Audio
|
||||
|
||||
private static AudioDeviceInfo getInputAudioDeviceInfo(int deviceId) {
|
||||
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
|
||||
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
||||
for (AudioDeviceInfo deviceInfo : audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS)) {
|
||||
if (deviceInfo.getId() == deviceId) {
|
||||
return deviceInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static AudioDeviceInfo getPlaybackAudioDeviceInfo(int deviceId) {
|
||||
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
|
||||
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
||||
for (AudioDeviceInfo deviceInfo : audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS)) {
|
||||
if (deviceInfo.getId() == deviceId) {
|
||||
return deviceInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static void registerAudioDeviceCallback() {
|
||||
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
|
||||
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
||||
// get an initial list now, before hotplug callbacks fire.
|
||||
for (AudioDeviceInfo dev : audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS)) {
|
||||
if (dev.getType() == AudioDeviceInfo.TYPE_TELEPHONY) {
|
||||
continue; // Device cannot be opened
|
||||
}
|
||||
nativeAddAudioDevice(dev.isSink(), dev.getProductName().toString(), dev.getId());
|
||||
}
|
||||
for (AudioDeviceInfo dev : audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS)) {
|
||||
nativeAddAudioDevice(dev.isSink(), dev.getProductName().toString(), dev.getId());
|
||||
}
|
||||
audioManager.registerAudioDeviceCallback(mAudioDeviceCallback, null);
|
||||
}
|
||||
}
|
||||
|
||||
static void unregisterAudioDeviceCallback() {
|
||||
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
|
||||
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
||||
audioManager.unregisterAudioDeviceCallback(mAudioDeviceCallback);
|
||||
}
|
||||
}
|
||||
|
||||
/** This method is called by SDL using JNI. */
|
||||
static void audioSetThreadPriority(boolean recording, int device_id) {
|
||||
try {
|
||||
|
||||
/* Set thread name */
|
||||
if (recording) {
|
||||
Thread.currentThread().setName("SDLAudioC" + device_id);
|
||||
} else {
|
||||
Thread.currentThread().setName("SDLAudioP" + device_id);
|
||||
}
|
||||
|
||||
/* Set thread priority */
|
||||
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_AUDIO);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.v(TAG, "modify thread properties failed " + e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
static native void nativeSetupJNI();
|
||||
|
||||
static native void nativeRemoveAudioDevice(boolean recording, int deviceId);
|
||||
|
||||
static native void nativeAddAudioDevice(boolean recording, String name, int deviceId);
|
||||
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
package org.libsdl.app;
|
||||
|
||||
import android.content.*;
|
||||
import android.text.InputType;
|
||||
import android.view.*;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputConnection;
|
||||
|
||||
/* This is a fake invisible editor view that receives the input and defines the
|
||||
* pan&scan region
|
||||
*/
|
||||
public class SDLDummyEdit extends View implements View.OnKeyListener
|
||||
{
|
||||
InputConnection ic;
|
||||
int input_type;
|
||||
|
||||
SDLDummyEdit(Context context) {
|
||||
super(context);
|
||||
setFocusableInTouchMode(true);
|
||||
setFocusable(true);
|
||||
setOnKeyListener(this);
|
||||
}
|
||||
|
||||
void setInputType(int input_type) {
|
||||
this.input_type = input_type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCheckIsTextEditor() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||
return SDLActivity.handleKeyEvent(v, keyCode, event, ic);
|
||||
}
|
||||
|
||||
//
|
||||
@Override
|
||||
public boolean onKeyPreIme (int keyCode, KeyEvent event) {
|
||||
// As seen on StackOverflow: http://stackoverflow.com/questions/7634346/keyboard-hide-event
|
||||
// FIXME: Discussion at http://bugzilla.libsdl.org/show_bug.cgi?id=1639
|
||||
// FIXME: This is not a 100% effective solution to the problem of detecting if the keyboard is showing or not
|
||||
// FIXME: A more effective solution would be to assume our Layout to be RelativeLayout or LinearLayout
|
||||
// FIXME: And determine the keyboard presence doing this: http://stackoverflow.com/questions/2150078/how-to-check-visibility-of-software-keyboard-in-android
|
||||
// FIXME: An even more effective way would be if Android provided this out of the box, but where would the fun be in that :)
|
||||
if (event.getAction()==KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
if (SDLActivity.mTextEdit != null && SDLActivity.mTextEdit.getVisibility() == View.VISIBLE) {
|
||||
SDLActivity.onNativeKeyboardFocusLost();
|
||||
}
|
||||
}
|
||||
return super.onKeyPreIme(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
|
||||
ic = new SDLInputConnection(this, true);
|
||||
|
||||
outAttrs.inputType = input_type;
|
||||
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI |
|
||||
EditorInfo.IME_FLAG_NO_FULLSCREEN /* API 11 */;
|
||||
|
||||
return ic;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,136 +0,0 @@
|
|||
package org.libsdl.app;
|
||||
|
||||
import android.content.*;
|
||||
import android.os.Build;
|
||||
import android.text.Editable;
|
||||
import android.view.*;
|
||||
import android.view.inputmethod.BaseInputConnection;
|
||||
import android.widget.EditText;
|
||||
|
||||
class SDLInputConnection extends BaseInputConnection
|
||||
{
|
||||
protected EditText mEditText;
|
||||
protected String mCommittedText = "";
|
||||
|
||||
SDLInputConnection(View targetView, boolean fullEditor) {
|
||||
super(targetView, fullEditor);
|
||||
mEditText = new EditText(SDL.getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editable getEditable() {
|
||||
return mEditText.getEditableText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendKeyEvent(KeyEvent event) {
|
||||
/*
|
||||
* This used to handle the keycodes from soft keyboard (and IME-translated input from hardkeyboard)
|
||||
* However, as of Ice Cream Sandwich and later, almost all soft keyboard doesn't generate key presses
|
||||
* and so we need to generate them ourselves in commitText. To avoid duplicates on the handful of keys
|
||||
* that still do, we empty this out.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Return DOES still generate a key event, however. So rather than using it as the 'click a button' key
|
||||
* as we do with physical keyboards, let's just use it to hide the keyboard.
|
||||
*/
|
||||
|
||||
if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
|
||||
if (SDLActivity.onNativeSoftReturnKey()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.sendKeyEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean commitText(CharSequence text, int newCursorPosition) {
|
||||
if (!super.commitText(text, newCursorPosition)) {
|
||||
return false;
|
||||
}
|
||||
updateText();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setComposingText(CharSequence text, int newCursorPosition) {
|
||||
if (!super.setComposingText(text, newCursorPosition)) {
|
||||
return false;
|
||||
}
|
||||
updateText();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
|
||||
// Workaround to capture backspace key. Ref: http://stackoverflow.com/questions>/14560344/android-backspace-in-webview-baseinputconnection
|
||||
// and https://bugzilla.libsdl.org/show_bug.cgi?id=2265
|
||||
if (beforeLength > 0 && afterLength == 0) {
|
||||
// backspace(s)
|
||||
while (beforeLength-- > 0) {
|
||||
nativeGenerateScancodeForUnichar('\b');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!super.deleteSurroundingText(beforeLength, afterLength)) {
|
||||
return false;
|
||||
}
|
||||
updateText();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void updateText() {
|
||||
final Editable content = getEditable();
|
||||
if (content == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String text = content.toString();
|
||||
int compareLength = Math.min(text.length(), mCommittedText.length());
|
||||
int matchLength, offset;
|
||||
|
||||
/* Backspace over characters that are no longer in the string */
|
||||
for (matchLength = 0; matchLength < compareLength; ) {
|
||||
int codePoint = mCommittedText.codePointAt(matchLength);
|
||||
if (codePoint != text.codePointAt(matchLength)) {
|
||||
break;
|
||||
}
|
||||
matchLength += Character.charCount(codePoint);
|
||||
}
|
||||
/* FIXME: This doesn't handle graphemes, like '🌬️' */
|
||||
for (offset = matchLength; offset < mCommittedText.length(); ) {
|
||||
int codePoint = mCommittedText.codePointAt(offset);
|
||||
nativeGenerateScancodeForUnichar('\b');
|
||||
offset += Character.charCount(codePoint);
|
||||
}
|
||||
|
||||
if (matchLength < text.length()) {
|
||||
String pendingText = text.subSequence(matchLength, text.length()).toString();
|
||||
if (!SDLActivity.dispatchingKeyEvent()) {
|
||||
for (offset = 0; offset < pendingText.length(); ) {
|
||||
int codePoint = pendingText.codePointAt(offset);
|
||||
if (codePoint == '\n') {
|
||||
if (SDLActivity.onNativeSoftReturnKey()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* Higher code points don't generate simulated scancodes */
|
||||
if (codePoint > 0 && codePoint < 128) {
|
||||
nativeGenerateScancodeForUnichar((char)codePoint);
|
||||
}
|
||||
offset += Character.charCount(codePoint);
|
||||
}
|
||||
}
|
||||
SDLInputConnection.nativeCommitText(pendingText, 0);
|
||||
}
|
||||
mCommittedText = text;
|
||||
}
|
||||
|
||||
public static native void nativeCommitText(String text, int newCursorPosition);
|
||||
|
||||
public static native void nativeGenerateScancodeForUnichar(char c);
|
||||
}
|
||||
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
package org.libsdl.app;
|
||||
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
|
||||
// This class coordinates synchronized access to sensor manager registration
|
||||
//
|
||||
// This prevents a java.util.ConcurrentModificationException exception on
|
||||
// Android 16, specifically on the Samsung Tab S9 Ultra.
|
||||
|
||||
class SDLSensorManager
|
||||
{
|
||||
static private SDLSensorManager mManager = new SDLSensorManager();
|
||||
|
||||
public static void registerListener(SensorManager manager, SensorEventListener listener, Sensor sensor, int samplingPeriodUs) {
|
||||
mManager.RegisterListener(manager, listener, sensor, samplingPeriodUs);
|
||||
}
|
||||
|
||||
public static void unregisterListener(SensorManager manager, SensorEventListener listener, Sensor sensor) {
|
||||
mManager.UnregisterListener(manager, listener, sensor);
|
||||
}
|
||||
|
||||
private synchronized void RegisterListener(SensorManager manager, SensorEventListener listener, Sensor sensor, int samplingPeriodUs) {
|
||||
manager.registerListener(listener, sensor, samplingPeriodUs, null);
|
||||
}
|
||||
|
||||
private synchronized void UnregisterListener(SensorManager manager, SensorEventListener listener, Sensor sensor) {
|
||||
manager.unregisterListener(listener, sensor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,464 +0,0 @@
|
|||
package org.libsdl.app;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.graphics.Insets;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.os.Build;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.InputDevice;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.PointerIcon;
|
||||
import android.view.Surface;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import android.view.ScaleGestureDetector;
|
||||
|
||||
/**
|
||||
SDLSurface. This is what we draw on, so we need to know when it's created
|
||||
in order to do anything useful.
|
||||
|
||||
Because of this, that's where we set up the SDL thread
|
||||
*/
|
||||
public class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
||||
View.OnApplyWindowInsetsListener, View.OnKeyListener, View.OnTouchListener,
|
||||
SensorEventListener, ScaleGestureDetector.OnScaleGestureListener {
|
||||
|
||||
// Sensors
|
||||
protected SensorManager mSensorManager;
|
||||
protected Display mDisplay;
|
||||
|
||||
// Keep track of the surface size to normalize touch events
|
||||
protected float mWidth, mHeight;
|
||||
|
||||
// Is SurfaceView ready for rendering
|
||||
protected boolean mIsSurfaceReady;
|
||||
|
||||
// Is on-screen keyboard visible
|
||||
protected boolean mKeyboardVisible;
|
||||
|
||||
// Pinch events
|
||||
private final ScaleGestureDetector scaleGestureDetector;
|
||||
|
||||
// Startup
|
||||
protected SDLSurface(Context context) {
|
||||
super(context);
|
||||
getHolder().addCallback(this);
|
||||
|
||||
scaleGestureDetector = new ScaleGestureDetector(context, this);
|
||||
|
||||
setFocusable(true);
|
||||
setFocusableInTouchMode(true);
|
||||
requestFocus();
|
||||
setOnApplyWindowInsetsListener(this);
|
||||
setOnKeyListener(this);
|
||||
setOnTouchListener(this);
|
||||
|
||||
mDisplay = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
|
||||
mSensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
|
||||
|
||||
setOnGenericMotionListener(SDLActivity.getMotionListener());
|
||||
|
||||
// Some arbitrary defaults to avoid a potential division by zero
|
||||
mWidth = 1.0f;
|
||||
mHeight = 1.0f;
|
||||
|
||||
mIsSurfaceReady = false;
|
||||
}
|
||||
|
||||
protected void handlePause() {
|
||||
enableSensor(Sensor.TYPE_ACCELEROMETER, false);
|
||||
}
|
||||
|
||||
protected void handleResume() {
|
||||
setFocusable(true);
|
||||
setFocusableInTouchMode(true);
|
||||
requestFocus();
|
||||
setOnApplyWindowInsetsListener(this);
|
||||
setOnKeyListener(this);
|
||||
setOnTouchListener(this);
|
||||
enableSensor(Sensor.TYPE_ACCELEROMETER, true);
|
||||
}
|
||||
|
||||
protected Surface getNativeSurface() {
|
||||
return getHolder().getSurface();
|
||||
}
|
||||
|
||||
// Called when we have a valid drawing surface
|
||||
@Override
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
Log.v("SDL", "surfaceCreated()");
|
||||
SDLActivity.onNativeSurfaceCreated();
|
||||
}
|
||||
|
||||
// Called when we lose the surface
|
||||
@Override
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
Log.v("SDL", "surfaceDestroyed()");
|
||||
|
||||
// Transition to pause, if needed
|
||||
SDLActivity.mNextNativeState = SDLActivity.NativeState.PAUSED;
|
||||
SDLActivity.handleNativeState();
|
||||
|
||||
mIsSurfaceReady = false;
|
||||
SDLActivity.onNativeSurfaceDestroyed();
|
||||
}
|
||||
|
||||
// Called when the surface is resized
|
||||
@Override
|
||||
public void surfaceChanged(SurfaceHolder holder,
|
||||
int format, int width, int height) {
|
||||
Log.v("SDL", "surfaceChanged()");
|
||||
|
||||
if (SDLActivity.mSingleton == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
int nDeviceWidth = width;
|
||||
int nDeviceHeight = height;
|
||||
float density = 1.0f;
|
||||
try
|
||||
{
|
||||
DisplayMetrics realMetrics = new DisplayMetrics();
|
||||
mDisplay.getRealMetrics( realMetrics );
|
||||
nDeviceWidth = realMetrics.widthPixels;
|
||||
nDeviceHeight = realMetrics.heightPixels;
|
||||
// Use densityDpi instead of density to more closely match what the UI scale is
|
||||
density = (float)realMetrics.densityDpi / 160.0f;
|
||||
} catch(Exception ignored) {
|
||||
}
|
||||
|
||||
synchronized(SDLActivity.getContext()) {
|
||||
// In case we're waiting on a size change after going fullscreen, send a notification.
|
||||
SDLActivity.getContext().notifyAll();
|
||||
}
|
||||
|
||||
Log.v("SDL", "Window size: " + width + "x" + height);
|
||||
Log.v("SDL", "Device size: " + nDeviceWidth + "x" + nDeviceHeight);
|
||||
SDLActivity.nativeSetScreenResolution(width, height, nDeviceWidth, nDeviceHeight, density, mDisplay.getRefreshRate());
|
||||
SDLActivity.onNativeResize();
|
||||
|
||||
// Prevent a screen distortion glitch,
|
||||
// for instance when the device is in Landscape and a Portrait App is resumed.
|
||||
boolean skip = false;
|
||||
int requestedOrientation = SDLActivity.mSingleton.getRequestedOrientation();
|
||||
|
||||
if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) {
|
||||
if (mWidth > mHeight) {
|
||||
skip = true;
|
||||
}
|
||||
} else if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) {
|
||||
if (mWidth < mHeight) {
|
||||
skip = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Special Patch for Square Resolution: Black Berry Passport
|
||||
if (skip) {
|
||||
double min = Math.min(mWidth, mHeight);
|
||||
double max = Math.max(mWidth, mHeight);
|
||||
|
||||
if (max / min < 1.20) {
|
||||
Log.v("SDL", "Don't skip on such aspect-ratio. Could be a square resolution.");
|
||||
skip = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Don't skip if we might be multi-window or have popup dialogs
|
||||
if (skip) {
|
||||
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
|
||||
skip = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (skip) {
|
||||
Log.v("SDL", "Skip .. Surface is not ready.");
|
||||
mIsSurfaceReady = false;
|
||||
return;
|
||||
}
|
||||
|
||||
/* If the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here */
|
||||
SDLActivity.onNativeSurfaceChanged();
|
||||
|
||||
/* Surface is ready */
|
||||
mIsSurfaceReady = true;
|
||||
|
||||
SDLActivity.mNextNativeState = SDLActivity.NativeState.RESUMED;
|
||||
SDLActivity.handleNativeState();
|
||||
}
|
||||
|
||||
// Window inset
|
||||
@Override
|
||||
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
|
||||
if (Build.VERSION.SDK_INT >= 30 /* Android 11 (R) */) {
|
||||
Insets combined = insets.getInsets(WindowInsets.Type.systemBars() |
|
||||
WindowInsets.Type.systemGestures() |
|
||||
WindowInsets.Type.mandatorySystemGestures() |
|
||||
WindowInsets.Type.tappableElement() |
|
||||
WindowInsets.Type.displayCutout());
|
||||
|
||||
SDLActivity.onNativeInsetsChanged(combined.left, combined.right, combined.top, combined.bottom);
|
||||
|
||||
if (insets.isVisible(WindowInsets.Type.ime())) {
|
||||
if (!mKeyboardVisible) {
|
||||
mKeyboardVisible = true;
|
||||
SDLActivity.onNativeScreenKeyboardShown();
|
||||
}
|
||||
} else {
|
||||
if (mKeyboardVisible) {
|
||||
mKeyboardVisible = false;
|
||||
SDLActivity.onNativeScreenKeyboardHidden();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Pass these to any child views in case they need them
|
||||
return insets;
|
||||
}
|
||||
|
||||
// Key events
|
||||
@Override
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||
return SDLActivity.handleKeyEvent(v, keyCode, event, null);
|
||||
}
|
||||
|
||||
private float getNormalizedX(float x)
|
||||
{
|
||||
if (mWidth <= 1) {
|
||||
return 0.5f;
|
||||
} else {
|
||||
return (x / (mWidth - 1));
|
||||
}
|
||||
}
|
||||
|
||||
private float getNormalizedY(float y)
|
||||
{
|
||||
if (mHeight <= 1) {
|
||||
return 0.5f;
|
||||
} else {
|
||||
return (y / (mHeight - 1));
|
||||
}
|
||||
}
|
||||
|
||||
// Touch events
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
/* Ref: http://developer.android.com/training/gestures/multi.html */
|
||||
int touchDevId = event.getDeviceId();
|
||||
final int pointerCount = event.getPointerCount();
|
||||
int action = event.getActionMasked();
|
||||
int pointerId;
|
||||
int i = 0;
|
||||
float x,y,p;
|
||||
|
||||
if (action == MotionEvent.ACTION_POINTER_UP || action == MotionEvent.ACTION_POINTER_DOWN)
|
||||
i = event.getActionIndex();
|
||||
|
||||
do {
|
||||
int toolType = event.getToolType(i);
|
||||
|
||||
if (toolType == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
int buttonState = event.getButtonState();
|
||||
boolean relative = false;
|
||||
|
||||
// We need to check if we're in relative mouse mode and get the axis offset rather than the x/y values
|
||||
// if we are. We'll leverage our existing mouse motion listener
|
||||
SDLGenericMotionListener_API14 motionListener = SDLActivity.getMotionListener();
|
||||
x = motionListener.getEventX(event, i);
|
||||
y = motionListener.getEventY(event, i);
|
||||
relative = motionListener.inRelativeMode();
|
||||
|
||||
SDLActivity.onNativeMouse(buttonState, action, x, y, relative);
|
||||
} else if (toolType == MotionEvent.TOOL_TYPE_STYLUS || toolType == MotionEvent.TOOL_TYPE_ERASER) {
|
||||
pointerId = event.getPointerId(i);
|
||||
x = event.getX(i);
|
||||
y = event.getY(i);
|
||||
p = event.getPressure(i);
|
||||
if (p > 1.0f) {
|
||||
// may be larger than 1.0f on some devices
|
||||
// see the documentation of getPressure(i)
|
||||
p = 1.0f;
|
||||
}
|
||||
|
||||
// BUTTON_STYLUS_PRIMARY is 2^5, so shift by 4, and apply SDL_PEN_INPUT_DOWN/SDL_PEN_INPUT_ERASER_TIP
|
||||
int buttonState = (event.getButtonState() >> 4) | (1 << (toolType == MotionEvent.TOOL_TYPE_STYLUS ? 0 : 30));
|
||||
if ((event.getButtonState() & MotionEvent.BUTTON_TERTIARY) != 0) {
|
||||
buttonState |= 0x08;
|
||||
}
|
||||
|
||||
SDLActivity.onNativePen(pointerId, SDLActivity.getMotionListener().getPenDeviceType(event.getDevice()), buttonState, action, x, y, p);
|
||||
} else { // MotionEvent.TOOL_TYPE_FINGER or MotionEvent.TOOL_TYPE_UNKNOWN
|
||||
pointerId = event.getPointerId(i);
|
||||
x = getNormalizedX(event.getX(i));
|
||||
y = getNormalizedY(event.getY(i));
|
||||
p = event.getPressure(i);
|
||||
if (p > 1.0f) {
|
||||
// may be larger than 1.0f on some devices
|
||||
// see the documentation of getPressure(i)
|
||||
p = 1.0f;
|
||||
}
|
||||
|
||||
SDLActivity.onNativeTouch(touchDevId, pointerId, action, x, y, p);
|
||||
}
|
||||
|
||||
// Non-primary up/down
|
||||
if (action == MotionEvent.ACTION_POINTER_UP || action == MotionEvent.ACTION_POINTER_DOWN)
|
||||
break;
|
||||
} while (++i < pointerCount);
|
||||
|
||||
scaleGestureDetector.onTouchEvent(event);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Sensor events
|
||||
protected void enableSensor(int sensortype, boolean enabled) {
|
||||
// TODO: This uses getDefaultSensor - what if we have >1 accels?
|
||||
if (enabled) {
|
||||
SDLSensorManager.registerListener(mSensorManager, this,
|
||||
mSensorManager.getDefaultSensor(sensortype),
|
||||
SensorManager.SENSOR_DELAY_GAME);
|
||||
} else {
|
||||
SDLSensorManager.unregisterListener(mSensorManager, this,
|
||||
mSensorManager.getDefaultSensor(sensortype));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
|
||||
|
||||
// Since we may have an orientation set, we won't receive onConfigurationChanged events.
|
||||
// We thus should check here.
|
||||
int newRotation;
|
||||
|
||||
float x, y;
|
||||
switch (mDisplay.getRotation()) {
|
||||
case Surface.ROTATION_0:
|
||||
default:
|
||||
x = event.values[0];
|
||||
y = event.values[1];
|
||||
newRotation = 0;
|
||||
break;
|
||||
case Surface.ROTATION_90:
|
||||
x = -event.values[1];
|
||||
y = event.values[0];
|
||||
newRotation = 90;
|
||||
break;
|
||||
case Surface.ROTATION_180:
|
||||
x = -event.values[0];
|
||||
y = -event.values[1];
|
||||
newRotation = 180;
|
||||
break;
|
||||
case Surface.ROTATION_270:
|
||||
x = event.values[1];
|
||||
y = -event.values[0];
|
||||
newRotation = 270;
|
||||
break;
|
||||
}
|
||||
|
||||
if (newRotation != SDLActivity.mCurrentRotation) {
|
||||
SDLActivity.mCurrentRotation = newRotation;
|
||||
SDLActivity.onNativeRotationChanged(newRotation);
|
||||
}
|
||||
|
||||
SDLActivity.onNativeAccel(-x / SensorManager.GRAVITY_EARTH,
|
||||
y / SensorManager.GRAVITY_EARTH,
|
||||
event.values[2] / SensorManager.GRAVITY_EARTH);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent android internal NullPointerException (https://github.com/libsdl-org/SDL/issues/13306)
|
||||
@Override
|
||||
public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) {
|
||||
try {
|
||||
return super.onResolvePointerIcon(event, pointerIndex);
|
||||
} catch (NullPointerException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Captured pointer events for API 26.
|
||||
@Override
|
||||
public boolean onCapturedPointerEvent(MotionEvent event)
|
||||
{
|
||||
int action = event.getActionMasked();
|
||||
int pointerCount = event.getPointerCount();
|
||||
|
||||
for (int i = 0; i < pointerCount; i++) {
|
||||
float x, y;
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_SCROLL:
|
||||
x = event.getAxisValue(MotionEvent.AXIS_HSCROLL, i);
|
||||
y = event.getAxisValue(MotionEvent.AXIS_VSCROLL, i);
|
||||
SDLActivity.onNativeMouse(0, action, x, y, false);
|
||||
return true;
|
||||
|
||||
case MotionEvent.ACTION_HOVER_MOVE:
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
x = event.getX(i);
|
||||
y = event.getY(i);
|
||||
SDLActivity.onNativeMouse(0, action, x, y, true);
|
||||
return true;
|
||||
|
||||
case MotionEvent.ACTION_BUTTON_PRESS:
|
||||
case MotionEvent.ACTION_BUTTON_RELEASE:
|
||||
|
||||
// Change our action value to what SDL's code expects.
|
||||
if (action == MotionEvent.ACTION_BUTTON_PRESS) {
|
||||
action = MotionEvent.ACTION_DOWN;
|
||||
} else { /* MotionEvent.ACTION_BUTTON_RELEASE */
|
||||
action = MotionEvent.ACTION_UP;
|
||||
}
|
||||
|
||||
x = event.getX(i);
|
||||
y = event.getY(i);
|
||||
int button = event.getButtonState();
|
||||
|
||||
SDLActivity.onNativeMouse(button, action, x, y, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScale(ScaleGestureDetector detector) {
|
||||
float scale = detector.getScaleFactor();
|
||||
SDLActivity.onNativePinchUpdate(scale);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScaleBegin(ScaleGestureDetector detector) {
|
||||
SDLActivity.onNativePinchStart();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScaleEnd(ScaleGestureDetector detector) {
|
||||
SDLActivity.onNativePinchEnd();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
.gradle/
|
||||
.idea/
|
||||
deps
|
||||
deps/
|
||||
principia/build/
|
||||
*.apk
|
||||
*.apk.idsig
|
||||
|
|
@ -10,7 +10,8 @@ buildscript {
|
|||
}
|
||||
|
||||
plugins {
|
||||
id 'com.android.application' version '8.8.1' apply false
|
||||
id 'com.android.application' version '8.5.0' apply false
|
||||
id 'com.android.library' version '8.5.0' apply false
|
||||
}
|
||||
|
||||
tasks.register('clean', Delete) {
|
||||
BIN
build-android/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
build-android/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
|
|
@ -1,7 +1,6 @@
|
|||
#Sun Aug 07 11:51:41 CEST 2022
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
185
build-android/gradlew
vendored
Executable file
185
build-android/gradlew
vendored
Executable file
|
|
@ -0,0 +1,185 @@
|
|||
#!/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
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
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"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
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
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
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
|
||||
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
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $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" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
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"
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
|
@ -4,19 +4,21 @@ plugins {
|
|||
}
|
||||
|
||||
android {
|
||||
compileSdk 35
|
||||
ndkVersion "27.2.12479018"
|
||||
compileSdk 34
|
||||
ndkVersion "26.2.11394342"
|
||||
namespace 'com.bithack.principia'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.bithack.principia"
|
||||
minSdk 21
|
||||
targetSdk 35
|
||||
versionCode 41
|
||||
versionName "2026.06.19"
|
||||
targetSdk 34
|
||||
versionCode 37
|
||||
versionName "2024.07.12"
|
||||
|
||||
externalNativeBuild {
|
||||
cmake.arguments "-DUSE_VENDORED_SDL3=1"
|
||||
ndkBuild {
|
||||
arguments '-j' + Runtime.getRuntime().availableProcessors()
|
||||
}
|
||||
}
|
||||
|
||||
ndk {
|
||||
1
build-android/principia/src/assets/data-mobile
Symbolic link
1
build-android/principia/src/assets/data-mobile
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../../data-mobile
|
||||
1
build-android/principia/src/assets/data-shared
Symbolic link
1
build-android/principia/src/assets/data-shared
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../../data-shared
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package com.bithack.principia;
|
||||
|
||||
public class PrincipiaActivity extends TMSActivity
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.bithack.principia;
|
||||
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
public class TMSActivity extends SDLActivity
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import com.bithack.principia.R;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
|
|
@ -26,7 +28,7 @@ public class AnimalDialog {
|
|||
s_animal = (Spinner)view.findViewById(R.id.s_animal);
|
||||
String[] consumables = PrincipiaBackend.getAnimals().split(",.,");
|
||||
|
||||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(PrincipiaActivity.mSingleton, android.R.layout.select_dialog_item, consumables);
|
||||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(SDLActivity.mSingleton, android.R.layout.select_dialog_item, consumables);
|
||||
s_animal.setAdapter(spinnerArrayAdapter);
|
||||
|
||||
_dialog = new AlertDialog.Builder(PrincipiaActivity.mSingleton)
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
|
||||
|
|
@ -19,12 +20,12 @@ public class AutosaveDialog
|
|||
.setMessage("Autosave file detected. Open or remove?")
|
||||
.setPositiveButton("Open", new OnClickListener(){
|
||||
public void onClick(DialogInterface dialog, int which){
|
||||
PrincipiaBackend.addActionAsInt(PrincipiaActivity.ACTION_OPEN_AUTOSAVE, 0);
|
||||
PrincipiaBackend.addActionAsInt(SDLActivity.ACTION_OPEN_AUTOSAVE, 0);
|
||||
}}
|
||||
)
|
||||
.setNegativeButton("Remove", new OnClickListener(){
|
||||
public void onClick(DialogInterface dialog, int which){
|
||||
PrincipiaBackend.addActionAsInt(PrincipiaActivity.ACTION_REMOVE_AUTOSAVE, 0);
|
||||
PrincipiaBackend.addActionAsInt(SDLActivity.ACTION_REMOVE_AUTOSAVE, 0);
|
||||
}}
|
||||
)
|
||||
.create();
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
|
@ -3,7 +3,7 @@ package com.bithack.principia.shared;
|
|||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
|
|
@ -18,13 +20,13 @@ public class CommunityDialog
|
|||
.setMessage("Do you want to return to the community site or to the main menu?")
|
||||
.setPositiveButton("Community", new OnClickListener(){
|
||||
public void onClick(DialogInterface dialog, int which){
|
||||
PrincipiaActivity.wv.loadUrl(PrincipiaBackend.getCurrentCommunityUrl());
|
||||
PrincipiaActivity.wv_dialog.show();
|
||||
SDLActivity.wv.loadUrl(PrincipiaBackend.getCurrentCommunityUrl());
|
||||
SDLActivity.wv_dialog.show();
|
||||
}}
|
||||
)
|
||||
.setNegativeButton("Main menu", new OnClickListener(){
|
||||
public void onClick(DialogInterface dialog, int which){
|
||||
PrincipiaBackend.addActionAsInt(PrincipiaActivity.ACTION_GOTO_MAINMENU, 0);
|
||||
PrincipiaBackend.addActionAsInt(SDLActivity.ACTION_GOTO_MAINMENU, 0);
|
||||
}}
|
||||
)
|
||||
.create();
|
||||
|
|
@ -2,7 +2,8 @@ package com.bithack.principia.shared;
|
|||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
|
|
@ -43,7 +44,7 @@ public class ConfirmDialog
|
|||
{
|
||||
final CheckBox cb;
|
||||
|
||||
AlertDialog dialog = new AlertDialog.Builder(PrincipiaActivity.getContext()).create();
|
||||
AlertDialog dialog = new AlertDialog.Builder(SDLActivity.getContext()).create();
|
||||
if (dna_sandbox_back) {
|
||||
View view = LayoutInflater.from(PrincipiaActivity.mSingleton).inflate(R.layout.confirm_sandbox, null);
|
||||
dialog.setView(view);
|
||||
|
|
@ -54,8 +55,8 @@ public class ConfirmDialog
|
|||
cb = null;
|
||||
}
|
||||
dialog.setCancelable(true);
|
||||
dialog.setOnShowListener(PrincipiaActivity.mSingleton);
|
||||
dialog.setOnDismissListener(PrincipiaActivity.mSingleton);
|
||||
dialog.setOnShowListener(SDLActivity.mSingleton);
|
||||
dialog.setOnDismissListener(SDLActivity.mSingleton);
|
||||
dialog.setButton(DialogInterface.BUTTON_POSITIVE, button1, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int buttonId) {
|
||||
if (mListener != null) {
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
import android.app.AlertDialog;
|
||||
|
|
@ -26,7 +28,7 @@ public class ConsumableDialog {
|
|||
s_consumable = (Spinner)view.findViewById(R.id.s_consumable);
|
||||
String[] consumables = PrincipiaBackend.getConsumables().split(",");
|
||||
|
||||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(PrincipiaActivity.mSingleton, android.R.layout.select_dialog_item, consumables);
|
||||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(SDLActivity.mSingleton, android.R.layout.select_dialog_item, consumables);
|
||||
s_consumable.setAdapter(spinnerArrayAdapter);
|
||||
|
||||
_dialog = new AlertDialog.Builder(PrincipiaActivity.mSingleton)
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
import android.app.AlertDialog;
|
||||
|
|
@ -26,7 +28,7 @@ public class DecorationDialog {
|
|||
s_deco = (Spinner)view.findViewById(R.id.s_deco);
|
||||
String[] consumables = PrincipiaBackend.getDecorations().split(",.,");
|
||||
|
||||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(PrincipiaActivity.mSingleton, android.R.layout.select_dialog_item, consumables);
|
||||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(SDLActivity.mSingleton, android.R.layout.select_dialog_item, consumables);
|
||||
s_deco.setAdapter(spinnerArrayAdapter);
|
||||
|
||||
_dialog = new AlertDialog.Builder(PrincipiaActivity.mSingleton)
|
||||
|
|
@ -4,7 +4,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
|
|
@ -63,7 +64,7 @@ public class DigitalDisplayDialog {
|
|||
ll_dd = (LinearLayout)view.findViewById(R.id.ll_dd);
|
||||
ll_wrap = (LinearLayout)view.findViewById(R.id.display_ll_wrap);
|
||||
|
||||
np_initial_position = new com.bithack.principia.shared.NumberPicker(PrincipiaActivity.getContext());
|
||||
np_initial_position = new com.bithack.principia.shared.NumberPicker(SDLActivity.getContext());
|
||||
np_initial_position.setRange(MIN_INITIAL_POS, 40);
|
||||
|
||||
ll_dd.addView((View)np_initial_position);
|
||||
|
|
@ -132,7 +133,7 @@ public class DigitalDisplayDialog {
|
|||
new_str.setCharAt(y, (isChecked?'1':'0'));
|
||||
symbols.set(cur_symbol, new_str.toString());
|
||||
} catch (StringIndexOutOfBoundsException e) {
|
||||
Log.e("Principia", "An unknown error occurred: " + e.getMessage());
|
||||
Log.e("Principia", "An unknown error occured: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -180,7 +181,7 @@ public class DigitalDisplayDialog {
|
|||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
if (num_symbols == 40) {
|
||||
PrincipiaActivity.message("Maximum number of symbols reached.", 0);
|
||||
SDLActivity.message("Maximum number of symbols reached.", 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -199,7 +200,7 @@ public class DigitalDisplayDialog {
|
|||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
if (num_symbols == 40) {
|
||||
PrincipiaActivity.message("Maximum number of symbols reached.", 0);
|
||||
SDLActivity.message("Maximum number of symbols reached.", 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -4,7 +4,7 @@ import java.util.Locale;
|
|||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
|
@ -5,7 +5,7 @@ import java.util.ArrayList;
|
|||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
|
@ -8,20 +8,23 @@ import android.content.DialogInterface;
|
|||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.text.Html;
|
||||
|
||||
public class InfoDialog
|
||||
public class HelpDialog
|
||||
{
|
||||
Dialog _dialog;
|
||||
|
||||
public static String description;
|
||||
public static String description ="";
|
||||
public static String title = "";
|
||||
|
||||
public InfoDialog()
|
||||
public HelpDialog()
|
||||
{
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(PrincipiaActivity.mSingleton);
|
||||
bld.setTitle("Level description");
|
||||
bld.setMessage(description);
|
||||
bld.setTitle(title);
|
||||
bld.setMessage(Html.fromHtml((description.replaceAll("\n", "<br />"))));
|
||||
|
||||
bld.setNeutralButton("Close", new OnClickListener(){
|
||||
public void onClick(DialogInterface dialog, int which) { }
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
}
|
||||
});
|
||||
|
||||
this._dialog = bld.create();
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
|
||||
|
|
@ -22,7 +23,7 @@ public class ImportDialog
|
|||
private final String[] level_names;
|
||||
|
||||
public static ListView lv;
|
||||
public static ArrayAdapter<Level> list_adapter = new ArrayAdapter<Level>(PrincipiaActivity.mSingleton,
|
||||
public static ArrayAdapter<Level> list_adapter = new ArrayAdapter<Level>(SDLActivity.mSingleton,
|
||||
android.R.layout.select_dialog_item);
|
||||
|
||||
public ImportDialog(final boolean is_multiemitter)
|
||||
|
|
@ -31,7 +32,7 @@ public class ImportDialog
|
|||
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(PrincipiaActivity.mSingleton);
|
||||
|
||||
String level_list = PrincipiaBackend.getLevels(PrincipiaActivity.LEVEL_PARTIAL);
|
||||
String level_list = PrincipiaBackend.getLevels(SDLActivity.LEVEL_PARTIAL);
|
||||
String[] levels = level_list.split("\n");
|
||||
|
||||
level_names = new String[levels.length];
|
||||
|
|
@ -81,7 +82,7 @@ public class ImportDialog
|
|||
this._dialog.setOnShowListener(new OnShowListener() {
|
||||
@Override
|
||||
public void onShow(DialogInterface dialog) {
|
||||
PrincipiaActivity.on_show(dialog);
|
||||
SDLActivity.on_show(dialog);
|
||||
ListView lv = _dialog.getListView();
|
||||
ImportDialog.lv = lv;
|
||||
if (lv != null) {
|
||||
|
|
@ -103,7 +104,7 @@ public class ImportDialog
|
|||
}
|
||||
});
|
||||
lv.setAdapter(ImportDialog.list_adapter);
|
||||
PrincipiaActivity.mSingleton.registerForContextMenu(lv);
|
||||
SDLActivity.mSingleton.registerForContextMenu(lv);
|
||||
} else {
|
||||
Log.v("Principia", "listview = null");
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ package com.bithack.principia.shared;
|
|||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
|
|
@ -2,7 +2,7 @@ package com.bithack.principia.shared;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
|
@ -2,7 +2,8 @@ package com.bithack.principia.shared;
|
|||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
|
|
@ -42,7 +43,7 @@ public class LoginDialog
|
|||
_dialog.setOnShowListener(new OnShowListener() {
|
||||
@Override
|
||||
public void onShow(DialogInterface dialog) {
|
||||
PrincipiaActivity.on_show(dialog);
|
||||
SDLActivity.on_show(dialog);
|
||||
|
||||
Button b = _dialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||
|
||||
|
|
@ -54,7 +55,7 @@ public class LoginDialog
|
|||
String password = et_password.getText().toString().trim();
|
||||
|
||||
if (username.length() <= 0 || password.length() <= 0) {
|
||||
PrincipiaActivity.message("You must enter a valid username and password.", 0);
|
||||
SDLActivity.message("You must enter a valid username and password.", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +74,7 @@ public class LoginDialog
|
|||
btn_register_account.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
PrincipiaActivity.open_dialog(PrincipiaActivity.DIALOG_REGISTER);
|
||||
SDLActivity.open_dialog(SDLActivity.DIALOG_REGISTER);
|
||||
_dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
|
@ -2,7 +2,7 @@ package com.bithack.principia.shared;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ import android.widget.ToggleButton;
|
|||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
|
@ -275,7 +275,7 @@ public class MultiSelectDialog implements OnSeekBarChangeListener, OnCheckedChan
|
|||
break;
|
||||
|
||||
case PLASTIC_DENSITY:
|
||||
PrincipiaBackend.addActionAsInt(PrincipiaActivity.ACTION_MULTI_PLASTIC_DENSITY, sb_plastic_density.getProgress()/10);
|
||||
PrincipiaBackend.addActionAsInt(PrincipiaActivity.ACTION_MULTI_PLASTIC_DENSITY, sb_plastic_density.getProgress());
|
||||
message = "Changed the density of all plastic entities.";
|
||||
break;
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
|
|
@ -23,11 +25,11 @@ public class OpenDialog
|
|||
|
||||
public OpenDialog(final boolean is_state)
|
||||
{
|
||||
PrincipiaActivity.open_adapter.clear();
|
||||
SDLActivity.open_adapter.clear();
|
||||
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(PrincipiaActivity.mSingleton);
|
||||
|
||||
String level_list = PrincipiaBackend.getLevels(is_state ? PrincipiaActivity.LEVEL_LOCAL_STATE : PrincipiaActivity.LEVEL_LOCAL);
|
||||
String level_list = PrincipiaBackend.getLevels(is_state ? SDLActivity.LEVEL_LOCAL_STATE : SDLActivity.LEVEL_LOCAL);
|
||||
Log.v("Principia", "Level list: " + level_list);
|
||||
String[] levels = level_list.split("\n");
|
||||
|
||||
|
|
@ -58,7 +60,7 @@ public class OpenDialog
|
|||
|
||||
Log.v("Principia", "Adding "+name);
|
||||
|
||||
PrincipiaActivity.open_adapter.add(l);
|
||||
SDLActivity.open_adapter.add(l);
|
||||
|
||||
level_names[x] = name;
|
||||
}
|
||||
|
|
@ -80,7 +82,7 @@ public class OpenDialog
|
|||
@Override
|
||||
public void onShow(DialogInterface dialog)
|
||||
{
|
||||
PrincipiaActivity.on_show(dialog);
|
||||
SDLActivity.on_show(dialog);
|
||||
ListView lv = _dialog.getListView();
|
||||
OpenDialog.lv = lv;
|
||||
if (lv != null) {
|
||||
|
|
@ -90,7 +92,7 @@ public class OpenDialog
|
|||
int position, long id) {
|
||||
Level level = (Level)parent.getAdapter().getItem(position);
|
||||
if (is_state) {
|
||||
PrincipiaBackend.openState(level.get_level_type(), level.get_id(), level.get_save_id(), PrincipiaActivity.is_cool); /* XXX */
|
||||
PrincipiaBackend.openState(level.get_level_type(), level.get_id(), level.get_save_id(), SDLActivity.is_cool); /* XXX */
|
||||
} else {
|
||||
PrincipiaBackend.addActionAsInt(PrincipiaActivity.ACTION_OPEN, level.get_id());
|
||||
}
|
||||
|
|
@ -98,8 +100,8 @@ public class OpenDialog
|
|||
}
|
||||
|
||||
});
|
||||
lv.setAdapter(PrincipiaActivity.open_adapter);
|
||||
PrincipiaActivity.mSingleton.registerForContextMenu(lv);
|
||||
lv.setAdapter(SDLActivity.open_adapter);
|
||||
SDLActivity.mSingleton.registerForContextMenu(lv);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -2,7 +2,8 @@ package com.bithack.principia.shared;
|
|||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
|
|
@ -26,7 +27,7 @@ public class PkgLevelDialog {
|
|||
|
||||
view = LayoutInflater.from(PrincipiaActivity.mSingleton).inflate(R.layout.pkg_level_id, null);
|
||||
|
||||
np_level_id = new com.bithack.principia.shared.NumberPicker(PrincipiaActivity.getContext());
|
||||
np_level_id = new com.bithack.principia.shared.NumberPicker(SDLActivity.getContext());
|
||||
np_level_id.setRange(0, 255);
|
||||
np_level_id.setValue(1);
|
||||
|
||||
|
|
@ -3,8 +3,9 @@ package com.bithack.principia.shared;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import com.bithack.principia.R;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
|
|
@ -20,17 +21,17 @@ public class PlayDialog
|
|||
*/
|
||||
|
||||
static final String[] shared_items = new String[] {
|
||||
PrincipiaActivity.mSingleton.getString(R.string.open_save),
|
||||
PrincipiaActivity.mSingleton.getString(R.string.back_to_sandbox),
|
||||
PrincipiaActivity.mSingleton.getString(R.string.back_to_main_menu),
|
||||
PrincipiaActivity.mSingleton.getString(R.string.cancel)
|
||||
SDLActivity.mSingleton.getString(R.string.open_save),
|
||||
SDLActivity.mSingleton.getString(R.string.back_to_sandbox),
|
||||
SDLActivity.mSingleton.getString(R.string.back_to_main_menu),
|
||||
SDLActivity.mSingleton.getString(R.string.cancel)
|
||||
};
|
||||
|
||||
static final String save_state = PrincipiaActivity.mSingleton.getString(R.string.save_state);
|
||||
static final String save_state = SDLActivity.mSingleton.getString(R.string.save_state);
|
||||
|
||||
static final String[] community_items = new String[] {
|
||||
PrincipiaActivity.mSingleton.getString(R.string.restart_level),
|
||||
PrincipiaActivity.mSingleton.getString(R.string.back_to_community)
|
||||
SDLActivity.mSingleton.getString(R.string.restart_level),
|
||||
SDLActivity.mSingleton.getString(R.string.back_to_community)
|
||||
};
|
||||
|
||||
public static Dialog create_dialog()
|
||||
|
|
@ -40,28 +41,28 @@ public class PlayDialog
|
|||
if (source > 100) {
|
||||
source -= 100;
|
||||
}
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(PrincipiaActivity.mSingleton);
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(SDLActivity.mSingleton);
|
||||
List<CharSequence> items = new ArrayList<CharSequence>();
|
||||
|
||||
if (PrincipiaBackend.getLevelFlag(33)) {
|
||||
items.add(save_state);
|
||||
}
|
||||
|
||||
items.add(PrincipiaActivity.mSingleton.getString(R.string.open_save));
|
||||
items.add(SDLActivity.mSingleton.getString(R.string.open_save));
|
||||
|
||||
if (PrincipiaBackend.isAdventure()) {
|
||||
items.add(PrincipiaActivity.mSingleton.getString(R.string.selfdestruct));
|
||||
items.add(SDLActivity.mSingleton.getString(R.string.selfdestruct));
|
||||
}
|
||||
|
||||
if (source == 1) {
|
||||
items.add(PrincipiaActivity.mSingleton.getString(R.string.restart_level));
|
||||
items.add(PrincipiaActivity.mSingleton.getString(R.string.back_to_community));
|
||||
items.add(SDLActivity.mSingleton.getString(R.string.restart_level));
|
||||
items.add(SDLActivity.mSingleton.getString(R.string.back_to_community));
|
||||
} else if (source == 0) {
|
||||
items.add(PrincipiaActivity.mSingleton.getString(R.string.back_to_sandbox));
|
||||
items.add(SDLActivity.mSingleton.getString(R.string.back_to_sandbox));
|
||||
}
|
||||
|
||||
items.add(PrincipiaActivity.mSingleton.getString(R.string.back_to_main_menu));
|
||||
items.add(PrincipiaActivity.mSingleton.getString(R.string.cancel));
|
||||
items.add(SDLActivity.mSingleton.getString(R.string.back_to_main_menu));
|
||||
items.add(SDLActivity.mSingleton.getString(R.string.cancel));
|
||||
|
||||
final CharSequence[] real_items = items.toArray(new CharSequence[items.size()]);
|
||||
|
||||
|
|
@ -70,26 +71,26 @@ public class PlayDialog
|
|||
String cool = real_items[which].toString();
|
||||
|
||||
if (cool.equalsIgnoreCase("open save")) {
|
||||
PrincipiaActivity.mSingleton.runOnUiThread(new Runnable(){
|
||||
SDLActivity.mSingleton.runOnUiThread(new Runnable(){
|
||||
public void run() {
|
||||
try { PrincipiaActivity.mSingleton.removeDialog(PrincipiaActivity.DIALOG_OPEN); } catch(Exception e) {};
|
||||
try { PrincipiaActivity.mSingleton.removeDialog(PrincipiaActivity.DIALOG_OPEN_STATE); } catch(Exception e) {};
|
||||
try { SDLActivity.mSingleton.removeDialog(SDLActivity.DIALOG_OPEN); } catch(Exception e) {};
|
||||
try { SDLActivity.mSingleton.removeDialog(SDLActivity.DIALOG_OPEN_STATE); } catch(Exception e) {};
|
||||
}
|
||||
});
|
||||
PrincipiaActivity.mSingleton.showDialog(PrincipiaActivity.DIALOG_OPEN_STATE);
|
||||
SDLActivity.mSingleton.showDialog(SDLActivity.DIALOG_OPEN_STATE);
|
||||
} else if (cool.equalsIgnoreCase("back to sandbox")) {
|
||||
PrincipiaBackend.addActionAsInt(PrincipiaActivity.ACTION_BACK, 0);
|
||||
PrincipiaBackend.addActionAsInt(SDLActivity.ACTION_BACK, 0);
|
||||
} else if (cool.equalsIgnoreCase("back to community")) {
|
||||
PrincipiaActivity.wv.loadUrl(PrincipiaBackend.getCurrentCommunityUrl());
|
||||
PrincipiaActivity.wv_dialog.show();
|
||||
SDLActivity.wv.loadUrl(PrincipiaBackend.getCurrentCommunityUrl());
|
||||
SDLActivity.wv_dialog.show();
|
||||
} else if (cool.equalsIgnoreCase("save state")) {
|
||||
PrincipiaBackend.addActionAsInt(PrincipiaActivity.ACTION_SAVE_STATE, 0);
|
||||
PrincipiaBackend.addActionAsInt(SDLActivity.ACTION_SAVE_STATE, 0);
|
||||
} else if (cool.equalsIgnoreCase("back to main menu")) {
|
||||
PrincipiaBackend.addActionAsInt(PrincipiaActivity.ACTION_GOTO_MAINMENU, 0);
|
||||
PrincipiaBackend.addActionAsInt(SDLActivity.ACTION_GOTO_MAINMENU, 0);
|
||||
} else if (cool.equalsIgnoreCase("restart level")) {
|
||||
PrincipiaBackend.addActionAsInt(PrincipiaActivity.ACTION_RESTART_LEVEL, 0);
|
||||
PrincipiaBackend.addActionAsInt(SDLActivity.ACTION_RESTART_LEVEL, 0);
|
||||
} else if (cool.equalsIgnoreCase("self-destruct")) {
|
||||
PrincipiaBackend.addActionAsInt(PrincipiaActivity.ACTION_SELF_DESTRUCT, 0);
|
||||
PrincipiaBackend.addActionAsInt(SDLActivity.ACTION_SELF_DESTRUCT, 0);
|
||||
} else {
|
||||
Log.e("PRINCIPIA", "UNKNOWN THING: " + cool);
|
||||
}
|
||||
|
|
@ -109,7 +110,7 @@ public class PlayDialog
|
|||
.setNeutralButton("Back", new OnClickListener(){
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
PrincipiaBackend.addActionAsInt(PrincipiaActivity.ACTION_BACK, 0);
|
||||
PrincipiaBackend.addActionAsInt(SDLActivity.ACTION_BACK, 0);
|
||||
}
|
||||
})
|
||||
.setNegativeButton("Cancel", new OnClickListener(){
|
||||
|
|
@ -4,7 +4,7 @@ import java.util.Locale;
|
|||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
|
|
@ -6,7 +6,7 @@ import java.util.List;
|
|||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
|
|
@ -2,7 +2,8 @@ package com.bithack.principia.shared;
|
|||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
|
|
@ -40,7 +41,7 @@ public class PromptSettingsDialog
|
|||
_dialog.setOnShowListener(new OnShowListener() {
|
||||
@Override
|
||||
public void onShow(DialogInterface dialog) {
|
||||
PrincipiaActivity.on_show(dialog);
|
||||
SDLActivity.on_show(dialog);
|
||||
|
||||
Button b = _dialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||
|
||||
|
|
@ -58,12 +59,12 @@ public class PromptSettingsDialog
|
|||
int message_len = message.length();
|
||||
|
||||
if (message_len <= 0) {
|
||||
PrincipiaActivity.message("You must enter a message for the prompt.", 0);
|
||||
SDLActivity.message("You must enter a message for the prompt.", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (b1_len <= 0 && b2_len <= 0 && b3_len <= 0) {
|
||||
PrincipiaActivity.message("You must use at least one button.", 0);
|
||||
SDLActivity.message("You must use at least one button.", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2,7 +2,8 @@ package com.bithack.principia.shared;
|
|||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
|
|
@ -40,7 +41,7 @@ public class PublishDialog
|
|||
_dialog.setOnShowListener(new OnShowListener() {
|
||||
@Override
|
||||
public void onShow(DialogInterface dialog) {
|
||||
PrincipiaActivity.on_show(dialog);
|
||||
SDLActivity.on_show(dialog);
|
||||
|
||||
Button b = _dialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||
|
||||
|
|
@ -52,7 +53,7 @@ public class PublishDialog
|
|||
String descr = et_descr.getText().toString().trim();
|
||||
|
||||
if (name.length() <= 0) {
|
||||
PrincipiaActivity.message("You must enter a name for your level!", 0);
|
||||
SDLActivity.message("You must enter a name for your level!", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +61,7 @@ public class PublishDialog
|
|||
PrincipiaBackend.setLevelDescription(descr);
|
||||
PrincipiaBackend.setLevelLocked(cb_locked.isChecked());
|
||||
|
||||
PrincipiaBackend.addActionAsInt(PrincipiaActivity.ACTION_PUBLISH, 0);
|
||||
PrincipiaBackend.addActionAsInt(SDLActivity.ACTION_PUBLISH, 0);
|
||||
|
||||
_dialog.dismiss();
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ package com.bithack.principia.shared;
|
|||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
|
||||
public class PuzzlePlayDialog
|
||||
{
|
||||
static Dialog _dialog = null;
|
||||
|
||||
public PuzzlePlayDialog()
|
||||
{
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(PrincipiaActivity.mSingleton);
|
||||
bld.setTitle("Play method");
|
||||
bld.setMessage("Do you want to test play the level, or just simulate it?");
|
||||
|
||||
bld.setPositiveButton("Test play", new OnClickListener(){
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
PrincipiaBackend.addActionAsInt(SDLActivity.ACTION_PUZZLEPLAY, 0);
|
||||
SDLActivity.message("Test-playing level!", 0);
|
||||
}
|
||||
});
|
||||
|
||||
bld.setNeutralButton("Simulate", new OnClickListener(){
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
PrincipiaBackend.addActionAsInt(SDLActivity.ACTION_PUZZLEPLAY, 1);
|
||||
SDLActivity.message("Simulating level!", 0);
|
||||
}
|
||||
});
|
||||
|
||||
bld.setNegativeButton("Cancel", new OnClickListener(){
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
}
|
||||
});
|
||||
|
||||
_dialog = bld.create();
|
||||
}
|
||||
|
||||
public Dialog get_dialog()
|
||||
{
|
||||
return _dialog;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
|
@ -2,7 +2,8 @@ package com.bithack.principia.shared;
|
|||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
|
|
@ -43,7 +44,7 @@ public class RegisterDialog
|
|||
_dialog.setOnShowListener(new OnShowListener() {
|
||||
@Override
|
||||
public void onShow(DialogInterface dialog) {
|
||||
PrincipiaActivity.on_show(dialog);
|
||||
SDLActivity.on_show(dialog);
|
||||
|
||||
Button b = _dialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||
|
||||
|
|
@ -57,22 +58,22 @@ public class RegisterDialog
|
|||
final String email = et_email.getText().toString().trim();
|
||||
|
||||
if (password.length() < 6 || password.length() > 100) {
|
||||
PrincipiaActivity.message("Your password must be at least 3 and at most 100 characters.", 0);
|
||||
SDLActivity.message("Your password must be at least 3 and at most 100 characters.", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!password.equals(password_confirm)) {
|
||||
PrincipiaActivity.message("The two passwords you entered don't match.", 0);
|
||||
SDLActivity.message("The two passwords you entered don't match.", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (username.length() < 3 || username.length() > 20) {
|
||||
PrincipiaActivity.message("Your username must be at least 3 and at most 20 characters.", 0);
|
||||
SDLActivity.message("Your username must be at least 3 and at most 20 characters.", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
|
||||
PrincipiaActivity.message("You must enter a valid email address.", 0);
|
||||
SDLActivity.message("You must enter a valid email address.", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
|||
|
||||
import com.bithack.principia.shared.MultiSpinner.MultiSpinnerListener;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
|
@ -2,7 +2,7 @@ package com.bithack.principia.shared;
|
|||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
|
|
@ -2,7 +2,8 @@ package com.bithack.principia.shared;
|
|||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
|
|
@ -33,13 +34,13 @@ public class SandboxTipsDialog
|
|||
.setTitle("Tips & tricks")
|
||||
.setPositiveButton("OK", new OnClickListener(){public void onClick(DialogInterface dialog, int which) {}})
|
||||
.setNeutralButton("Next", null)
|
||||
.setNegativeButton("More tips & tricks", new OnClickListener(){public void onClick(DialogInterface dialog, int which){PrincipiaActivity.open_url("https://principia-web.se/wiki/Getting_Started");}})
|
||||
.setNegativeButton("More tips & tricks", new OnClickListener(){public void onClick(DialogInterface dialog, int which){SDLActivity.open_url("https://principia-web.se/wiki/Getting_Started");}})
|
||||
.create();
|
||||
|
||||
_dialog.setOnShowListener(new OnShowListener() {
|
||||
@Override
|
||||
public void onShow(DialogInterface dialog) {
|
||||
PrincipiaActivity.on_show(dialog);
|
||||
SDLActivity.on_show(dialog);
|
||||
|
||||
Button b = _dialog.getButton(AlertDialog.BUTTON_NEUTRAL);
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
|
@ -5,7 +5,7 @@ import com.bithack.principia.R;
|
|||
import com.bithack.principia.shared.ConfirmDialog.OnOptionSelectedListener;
|
||||
import com.bithack.principia.shared.CustomLinearLayout.OnKeyboardStateChangedListener;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
|
@ -2,7 +2,7 @@ package com.bithack.principia.shared;
|
|||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
|
@ -13,7 +13,8 @@ import android.widget.Spinner;
|
|||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
public class Sfx2Dialog {
|
||||
static Dialog _dialog;
|
||||
|
|
@ -35,7 +36,7 @@ public class Sfx2Dialog {
|
|||
s_sfx = (Spinner)view.findViewById(R.id.s_sfx);
|
||||
String[] sound_effects = PrincipiaBackend.getSounds().split(",.,");
|
||||
|
||||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(PrincipiaActivity.mSingleton, android.R.layout.select_dialog_item, sound_effects);
|
||||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(SDLActivity.mSingleton, android.R.layout.select_dialog_item, sound_effects);
|
||||
s_sfx.setAdapter(spinnerArrayAdapter);
|
||||
|
||||
bld.setTitle("SFX Emitter");
|
||||
|
|
@ -72,6 +73,6 @@ public class Sfx2Dialog {
|
|||
PrincipiaBackend.setPropertyInt8(1, sfx_global.isChecked() ? 1 : 0);
|
||||
//TODO: property_index 2 (sound chunk)
|
||||
PrincipiaBackend.setPropertyInt8(3, sfx_loop.isChecked() ? 1 : 0);
|
||||
PrincipiaActivity.message("Saved properties for SFX Emitter.", 0);
|
||||
SDLActivity.message("Saved properties for SFX Emitter.", 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bithack.principia.shared;
|
||||
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
|
|
@ -32,7 +33,7 @@ public class SfxDialog {
|
|||
s_sfx = (Spinner)view.findViewById(R.id.s_sfx);
|
||||
String[] sound_effects = PrincipiaBackend.getSfxSounds().split(",");
|
||||
|
||||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(PrincipiaActivity.mSingleton, android.R.layout.select_dialog_item, sound_effects);
|
||||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(SDLActivity.mSingleton, android.R.layout.select_dialog_item, sound_effects);
|
||||
s_sfx.setAdapter(spinnerArrayAdapter);
|
||||
|
||||
bld.setTitle("SFX Emitter (Old)");
|
||||
|
|
@ -67,6 +68,6 @@ public class SfxDialog {
|
|||
{
|
||||
PrincipiaBackend.setPropertyInt(0, s_sfx.getSelectedItemId());
|
||||
PrincipiaBackend.setPropertyInt8(1, sfx_global.isChecked() ? 1 : 0);
|
||||
PrincipiaActivity.message("Saved properties for SFX Emitter.", 0);
|
||||
SDLActivity.message("Saved properties for SFX Emitter.", 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ import java.util.Locale;
|
|||
|
||||
import com.bithack.principia.PrincipiaActivity;
|
||||
import com.bithack.principia.R;
|
||||
import com.bithack.principia.PrincipiaBackend;
|
||||
import org.libsdl.app.PrincipiaBackend;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue