From 9ab883c79b73f439c2079969866c120b0d47f3b7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Sun, 1 May 2016 15:11:35 -0400 Subject: [PATCH] lib/android: revamp entrypoint MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- contrib/asteronits/src/android.nit | 2 +- lib/android/android.nit | 51 -------------------------- lib/android/game.nit | 71 ++++++++++++++++++++++++++++++++++++ lib/android/input_events.nit | 2 +- lib/app/audio.nit | 1 - lib/app/data_store.nit | 1 - lib/app/ui.nit | 3 +- lib/gamnit/display_android.nit | 2 +- lib/mnit/android/android_app.nit | 2 +- 9 files changed, 76 insertions(+), 59 deletions(-) create mode 100644 lib/android/game.nit diff --git a/contrib/asteronits/src/android.nit b/contrib/asteronits/src/android.nit index 4042f6d..e7ac9df 100644 --- a/contrib/asteronits/src/android.nit +++ b/contrib/asteronits/src/android.nit @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import ::android::platform +import ::android import ::android::vibration import asteronits diff --git a/lib/android/android.nit b/lib/android/android.nit index b5aa04f..58e296a 100644 --- a/lib/android/android.nit +++ b/lib/android/android.nit @@ -21,56 +21,5 @@ module android import platform -import native_app_glue import dalvik private import log -private import assets - -redef class App - redef fun init_window - do - super - on_create - on_restore_state - on_start - end - - redef fun term_window - do - super - on_stop - end - - # Is the application currently paused? - var paused = true - - redef fun pause - do - paused = true - on_pause - super - end - - redef fun resume - do - paused = false - on_resume - super - end - - redef fun save_state do on_save_state - - redef fun lost_focus - do - paused = true - super - end - - redef fun gained_focus - do - paused = false - super - end - - redef fun destroy do on_destroy -end diff --git a/lib/android/game.nit b/lib/android/game.nit new file mode 100644 index 0000000..2d17054 --- /dev/null +++ b/lib/android/game.nit @@ -0,0 +1,71 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Android services and implementation of app.nit for gamnit and mnit +module game + +import platform +import native_app_glue +import dalvik +private import log +private import assets + +redef class App + redef fun init_window + do + super + on_create + on_restore_state + on_start + end + + redef fun term_window + do + super + on_stop + end + + # Is the application currently paused? + var paused = true + + redef fun pause + do + paused = true + on_pause + super + end + + redef fun resume + do + paused = false + on_resume + super + end + + redef fun save_state do on_save_state + + redef fun lost_focus + do + paused = true + super + end + + redef fun gained_focus + do + paused = false + super + end + + redef fun destroy do on_destroy +end diff --git a/lib/android/input_events.nit b/lib/android/input_events.nit index 9597eea..8aea378 100644 --- a/lib/android/input_events.nit +++ b/lib/android/input_events.nit @@ -18,7 +18,7 @@ module input_events import mnit::input -import android +import android::game in "C header" `{ #include diff --git a/lib/app/audio.nit b/lib/app/audio.nit index 42d90ae..7f22c78 100644 --- a/lib/app/audio.nit +++ b/lib/app/audio.nit @@ -27,7 +27,6 @@ import app_base import core::error # Platform variations -# TODO: move on the platform once qualified names are understand in the condition import linux::audio is conditional(linux) import android::audio is conditional(android) diff --git a/lib/app/data_store.nit b/lib/app/data_store.nit index 4db4b22..ebebe83 100644 --- a/lib/app/data_store.nit +++ b/lib/app/data_store.nit @@ -23,7 +23,6 @@ import app_base import serialization # Platform variations -# TODO: move on the platform once qualified names are understand in the condition import linux::data_store is conditional(linux) import android::data_store is conditional(android) import ios::data_store is conditional(ios) diff --git a/lib/app/ui.nit b/lib/app/ui.nit index 4efbb87..0c7d524 100644 --- a/lib/app/ui.nit +++ b/lib/app/ui.nit @@ -18,9 +18,8 @@ module ui import app_base # Platform variations -# TODO: move on the platform once qualified names are understand in the condition import linux::ui is conditional(linux) -import android::ui is conditional(android) # FIXME it should be conditional to `android::platform` +import android::ui is conditional(android) import ios::ui is conditional(ios) redef class App diff --git a/lib/gamnit/display_android.nit b/lib/gamnit/display_android.nit index 3997c4a..c412e9f 100644 --- a/lib/gamnit/display_android.nit +++ b/lib/gamnit/display_android.nit @@ -21,7 +21,7 @@ module display_android is android_manifest """""" end -import ::android +import ::android::game intrude import android::load_image private import gamnit::egl diff --git a/lib/mnit/android/android_app.nit b/lib/mnit/android/android_app.nit index c8f02e3..e78da16 100644 --- a/lib/mnit/android/android_app.nit +++ b/lib/mnit/android/android_app.nit @@ -22,7 +22,7 @@ module android_app is android_manifest_activity """ import mnit import mnit::opengles1 -import ::android +import ::android::game intrude import ::android::input_events in "C" `{ -- 1.7.9.5