From e175cfe1549d499c2d95446cde70eb6c370b9cde Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Wed, 12 Feb 2014 17:21:09 -0800 Subject: [PATCH] Merge openfl-native templates --- include.xml | 2 +- templates/android/hxml/debug.hxml | 2 +- templates/android/hxml/release.hxml | 2 +- .../android/template/AndroidManifest.xml | 4 +- .../src/org/haxe/lime/GameActivity.java | 14 ++- .../template/src/org/haxe/lime/MainView.java | 106 ++++++++-------- templates/blackberry/hxml/debug.hxml | 1 + templates/blackberry/hxml/release.hxml | 1 + templates/cpp/hxml/debug.hxml | 7 +- templates/cpp/hxml/release.hxml | 7 +- templates/emscripten/hxml/debug.hxml | 1 + templates/emscripten/hxml/release.hxml | 1 + templates/haxe/limePreloader.hx | 115 ------------------ templates/iphone/PROJ/haxe/Build.hxml | 1 + templates/neko/hxml/debug.hxml | 1 + templates/neko/hxml/release.hxml | 1 + templates/neko/ndll/mac/libneko.dylib | Bin templates/neko/ndll/mac/regexp.ndll | Bin templates/neko/ndll/mac/sqlite.ndll | Bin templates/neko/ndll/mac/std.ndll | Bin templates/neko/ndll/mac/zlib.ndll | Bin templates/neko/ndll/mac64/libneko.dylib | Bin templates/neko/ndll/mac64/regexp.ndll | Bin templates/neko/ndll/mac64/sqlite.ndll | Bin templates/neko/ndll/mac64/std.ndll | Bin templates/neko/ndll/mac64/zlib.ndll | Bin templates/tizen/hxml/debug.hxml | 1 + templates/tizen/hxml/release.hxml | 1 + .../template/CommandLineBuild/build_data | 2 +- templates/tizen/template/manifest.xml | 18 +-- templates/webos/hxml/debug.hxml | 1 + templates/webos/hxml/release.hxml | 1 + 32 files changed, 98 insertions(+), 192 deletions(-) delete mode 100644 templates/haxe/limePreloader.hx mode change 100644 => 100755 templates/neko/ndll/mac/libneko.dylib mode change 100644 => 100755 templates/neko/ndll/mac/regexp.ndll mode change 100644 => 100755 templates/neko/ndll/mac/sqlite.ndll mode change 100644 => 100755 templates/neko/ndll/mac/std.ndll mode change 100644 => 100755 templates/neko/ndll/mac/zlib.ndll mode change 100644 => 100755 templates/neko/ndll/mac64/libneko.dylib mode change 100644 => 100755 templates/neko/ndll/mac64/regexp.ndll mode change 100644 => 100755 templates/neko/ndll/mac64/sqlite.ndll mode change 100644 => 100755 templates/neko/ndll/mac64/std.ndll mode change 100644 => 100755 templates/neko/ndll/mac64/zlib.ndll diff --git a/include.xml b/include.xml index 4db4676d0..463975664 100644 --- a/include.xml +++ b/include.xml @@ -29,7 +29,7 @@ - + diff --git a/templates/android/hxml/debug.hxml b/templates/android/hxml/debug.hxml index d8dc94f20..5e5312606 100644 --- a/templates/android/hxml/debug.hxml +++ b/templates/android/hxml/debug.hxml @@ -4,4 +4,4 @@ -D android -D android-9 -debug --D no-compilation \ No newline at end of file +--macro keep("::APP_MAIN::") \ No newline at end of file diff --git a/templates/android/hxml/release.hxml b/templates/android/hxml/release.hxml index d13afb58b..c4bc5299a 100644 --- a/templates/android/hxml/release.hxml +++ b/templates/android/hxml/release.hxml @@ -1,6 +1,6 @@ -main ApplicationMain ::HAXE_FLAGS:: -cp ::BUILD_DIR::/android/haxe -cpp ::CPP_DIR:: +--macro keep("::APP_MAIN::") -D android -D android-9 --D no-compilation diff --git a/templates/android/template/AndroidManifest.xml b/templates/android/template/AndroidManifest.xml index 669cd6120..85c9ee9de 100644 --- a/templates/android/template/AndroidManifest.xml +++ b/templates/android/template/AndroidManifest.xml @@ -7,7 +7,7 @@ - + @@ -23,4 +23,4 @@ - \ No newline at end of file + diff --git a/templates/android/template/src/org/haxe/lime/GameActivity.java b/templates/android/template/src/org/haxe/lime/GameActivity.java index eb918e36f..a76a40239 100644 --- a/templates/android/template/src/org/haxe/lime/GameActivity.java +++ b/templates/android/template/src/org/haxe/lime/GameActivity.java @@ -17,7 +17,6 @@ import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.Handler; -import android.os.Message; import android.os.Vibrator; import android.util.DisplayMetrics; import android.util.Log; @@ -99,6 +98,7 @@ public class GameActivity extends Activity implements SensorEventListener { //getResources().getAssets(); requestWindowFeature (Window.FEATURE_NO_TITLE); + ::if WIN_FULLSCREEN:: ::if (ANDROID_TARGET_SDK_VERSION < 19):: getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN @@ -138,6 +138,8 @@ public class GameActivity extends Activity implements SensorEventListener { mView = mMainView;*/ mView = new MainView (getApplication (), this); setContentView (mView); + + Extension.mainView = mView; sensorManager = (SensorManager)activity.getSystemService (Context.SENSOR_SERVICE); @@ -165,7 +167,7 @@ public class GameActivity extends Activity implements SensorEventListener { } // IMMERSIVE MODE SUPPORT - ::if (ANDROID_TARGET_SDK_VERSION >= 19):: + ::if (WIN_FULLSCREEN)::::if (ANDROID_TARGET_SDK_VERSION >= 19):: @Override public void onWindowFocusChanged(boolean hasFocus) { @@ -188,7 +190,7 @@ public class GameActivity extends Activity implements SensorEventListener { | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); } - ::end:: + ::end::::end:: public static double CapabilitiesGetPixelAspectRatio () { @@ -717,6 +719,12 @@ public class GameActivity extends Activity implements SensorEventListener { public static void showKeyboard (boolean show) { + if (activity == null) { + + return; + + } + InputMethodManager mgr = (InputMethodManager)activity.getSystemService (Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow (activity.mView.getWindowToken (), 0); diff --git a/templates/android/template/src/org/haxe/lime/MainView.java b/templates/android/template/src/org/haxe/lime/MainView.java index dd84a4a11..939dcd2d8 100644 --- a/templates/android/template/src/org/haxe/lime/MainView.java +++ b/templates/android/template/src/org/haxe/lime/MainView.java @@ -22,7 +22,6 @@ import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLContext; import javax.microedition.khronos.egl.EGLDisplay; import javax.microedition.khronos.opengles.GL10; -import java.util.Date; import java.util.Timer; import java.util.TimerTask; @@ -36,16 +35,29 @@ class MainView extends GLSurfaceView { static final int etTouchTap = 18; static final int resTerminate = -1; + boolean isPollImminent; Activity mActivity; static MainView mRefreshView; Timer mTimer = new Timer (); int mTimerID = 0; + TimerTask pendingTimer; + Runnable pollMe; + boolean renderPending = false; public MainView (Context context, Activity inActivity) { super (context); + isPollImminent = false; + final MainView me = this; + + pollMe = new Runnable () { + + @Override public void run () { me.onPoll (); } + + }; + int eglVersion = 1; if (::WIN_ALLOW_SHADERS:: || ::WIN_REQUIRE_SHADERS::) { @@ -196,6 +208,7 @@ class MainView extends GLSurfaceView { } + // Haxe Thread public void HandleResult (int inCode) { if (inCode == resTerminate) { @@ -206,39 +219,38 @@ class MainView extends GLSurfaceView { } double wake = Lime.getNextWake (); - final MainView me = this; + int delayMS = (int)(wake * 1000); - if (wake <= 0) { + if (renderPending && delayMS < 5) { - queueEvent (new Runnable () { - - public void run () { - - me.onPoll (); - - } - - }); + delayMS = 5; + + } + + if (delayMS <= 1) { + + queuePoll (); } else { - final int tid = ++mTimerID; - Date end = new Date (); - end.setTime (end.getTime () + (int)(wake * 1000)); - - mTimer.schedule (new TimerTask () { + if (pendingTimer != null) { - public void run () { + pendingTimer.cancel (); + + } + + final MainView me = this; + pendingTimer = new TimerTask () { + + @Override public void run () { - if (tid == me.mTimerID) { - - me.queuePoll (); - - } + me.queuePoll (); } - }, end); + }; + + mTimer.schedule (pendingTimer, delayMS); } @@ -303,34 +315,18 @@ class MainView extends GLSurfaceView { if (range != null) { - final float flat = range.getFlat (); final float value = event.getAxisValue (axis); - if (Math.abs (value) > flat) { + queueEvent (new Runnable () { - queueEvent (new Runnable () { + public void run () { - public void run () { - - me.HandleResult (Lime.onJoyMotion (deviceId, axis, ((value - range.getMin ()) / (range.getRange ())) * 65535 - 32768)); - - } + me.HandleResult (Lime.onJoyMotion (deviceId, axis, ((value - range.getMin ()) / (range.getRange ())) * 65535 - 32768)); - }); + } - } else { + }); - queueEvent (new Runnable () { - - public void run () { - - me.HandleResult (Lime.onJoyMotion (deviceId, axis, 0)); - - } - - }); - - } } } @@ -442,8 +438,10 @@ class MainView extends GLSurfaceView { } + // Haxe Thread void onPoll () { + isPollImminent = false; HandleResult (Lime.onPoll ()); } @@ -520,19 +518,15 @@ class MainView extends GLSurfaceView { } + // GUI/Timer Thread void queuePoll () { - final MainView me = this; - - queueEvent (new Runnable () { + if (!isPollImminent) { - public void run () { - - me.onPoll (); - - } + isPollImminent = true; + queueEvent (pollMe); - }); + } } @@ -540,6 +534,7 @@ class MainView extends GLSurfaceView { static public void renderNow () { //Called directly from C++ + mRefreshView.renderPending = true; mRefreshView.requestRender (); } @@ -601,6 +596,7 @@ class MainView extends GLSurfaceView { public void onDrawFrame (GL10 gl) { + mMainView.renderPending = false; mMainView.HandleResult (Lime.onRender ()); Sound.checkSoundCompletion (); @@ -623,4 +619,4 @@ class MainView extends GLSurfaceView { } -} \ No newline at end of file +} diff --git a/templates/blackberry/hxml/debug.hxml b/templates/blackberry/hxml/debug.hxml index 8b386d318..8b23d4f2e 100644 --- a/templates/blackberry/hxml/debug.hxml +++ b/templates/blackberry/hxml/debug.hxml @@ -1,5 +1,6 @@ -main ApplicationMain ::HAXE_FLAGS:: -cp ::BUILD_DIR::/blackberry/cpp/haxe -cpp ::CPP_DIR:: +--macro keep("::APP_MAIN::") -D blackberry -debug \ No newline at end of file diff --git a/templates/blackberry/hxml/release.hxml b/templates/blackberry/hxml/release.hxml index d6c0ef183..fa23e62e8 100644 --- a/templates/blackberry/hxml/release.hxml +++ b/templates/blackberry/hxml/release.hxml @@ -1,4 +1,5 @@ -main ApplicationMain ::HAXE_FLAGS:: -cp ::BUILD_DIR::/blackberry/cpp/haxe -cpp ::CPP_DIR:: +--macro keep("::APP_MAIN::") -D blackberry \ No newline at end of file diff --git a/templates/cpp/hxml/debug.hxml b/templates/cpp/hxml/debug.hxml index 443f14774..c87f1eb5d 100644 --- a/templates/cpp/hxml/debug.hxml +++ b/templates/cpp/hxml/debug.hxml @@ -1,4 +1,5 @@ --main ApplicationMain ::HAXE_FLAGS:: --cpp ::CPP_DIR:: --cp ::BUILD_DIR::/cpp/haxe +-main ApplicationMain ::HAXE_FLAGS:: +-cpp ::CPP_DIR:: +-cp ::BUILD_DIR::/cpp/haxe +--macro keep("::APP_MAIN::") -debug \ No newline at end of file diff --git a/templates/cpp/hxml/release.hxml b/templates/cpp/hxml/release.hxml index b306ec7be..45516fc8b 100644 --- a/templates/cpp/hxml/release.hxml +++ b/templates/cpp/hxml/release.hxml @@ -1,3 +1,4 @@ --main ApplicationMain ::HAXE_FLAGS:: --cp ::BUILD_DIR::/cpp/haxe --cpp ::CPP_DIR:: +-main ApplicationMain ::HAXE_FLAGS:: +-cp ::BUILD_DIR::/cpp/haxe +-cpp ::CPP_DIR:: +--macro keep("::APP_MAIN::") \ No newline at end of file diff --git a/templates/emscripten/hxml/debug.hxml b/templates/emscripten/hxml/debug.hxml index 544f01d3b..8a8077187 100644 --- a/templates/emscripten/hxml/debug.hxml +++ b/templates/emscripten/hxml/debug.hxml @@ -1,6 +1,7 @@ -main ApplicationMain ::HAXE_FLAGS:: -cp ::BUILD_DIR::/emscripten/haxe -cpp ::CPP_DIR:: +--macro keep("::APP_MAIN::") -lib openfl-native -D emscripten -D webgl diff --git a/templates/emscripten/hxml/release.hxml b/templates/emscripten/hxml/release.hxml index 5025e35d8..e17ff7bce 100644 --- a/templates/emscripten/hxml/release.hxml +++ b/templates/emscripten/hxml/release.hxml @@ -1,5 +1,6 @@ -main ApplicationMain ::HAXE_FLAGS:: -cp ::BUILD_DIR::/emscripten/haxe -cpp ::CPP_DIR:: +--macro keep("::APP_MAIN::") -D emscripten -D webgl \ No newline at end of file diff --git a/templates/haxe/limePreloader.hx b/templates/haxe/limePreloader.hx deleted file mode 100644 index 2c13f9e8b..000000000 --- a/templates/haxe/limePreloader.hx +++ /dev/null @@ -1,115 +0,0 @@ -import nme.display.Sprite; -import nme.events.Event; - - -class NMEPreloader extends Sprite -{ - private var outline:Sprite; - private var progress:Sprite; - - - public function new() - { - super(); - - var backgroundColor = getBackgroundColor (); - var r = backgroundColor >> 16 & 0xFF; - var g = backgroundColor >> 8 & 0xFF; - var b = backgroundColor & 0xFF; - var perceivedLuminosity = (0.299 * r + 0.587 * g + 0.114 * b); - var color = 0x000000; - - if (perceivedLuminosity < 70) { - - color = 0xFFFFFF; - - } - - var x = 30; - var height = 9; - var y = getHeight () / 2 - height / 2; - var width = getWidth () - x * 2; - - var padding = 3; - - outline = new Sprite (); - outline.graphics.lineStyle (1, color, 0.15, true); - outline.graphics.drawRoundRect (0, 0, width, height, padding * 2, padding * 2); - outline.x = x; - outline.y = y; - addChild (outline); - - progress = new Sprite (); - progress.graphics.beginFill (color, 0.35); - progress.graphics.drawRect (0, 0, width - padding * 2, height - padding * 2); - progress.x = x + padding; - progress.y = y + padding; - progress.scaleX = 0; - addChild (progress); - } - - - public function getBackgroundColor():Int - { - return ::WIN_BACKGROUND::; - } - - - public function getHeight():Float - { - var height = ::WIN_HEIGHT::; - - if (height > 0) { - - return height; - - } else { - - return nme.Lib.current.stage.stageHeight; - - } - } - - - public function getWidth():Float - { - var width = ::WIN_WIDTH::; - - if (width > 0) { - - return width; - - } else { - - return nme.Lib.current.stage.stageWidth; - - } - } - - - public function onInit() - { - - } - - - public function onLoaded() - { - dispatchEvent (new Event (Event.COMPLETE)); - } - - - public function onUpdate(bytesLoaded:Int, bytesTotal:Int) - { - var percentLoaded = bytesLoaded / bytesTotal; - - if (percentLoaded > 1) - { - percentLoaded == 1; - } - - progress.scaleX = percentLoaded; - } - - -} \ No newline at end of file diff --git a/templates/iphone/PROJ/haxe/Build.hxml b/templates/iphone/PROJ/haxe/Build.hxml index a77f2dd6b..7629a5804 100644 --- a/templates/iphone/PROJ/haxe/Build.hxml +++ b/templates/iphone/PROJ/haxe/Build.hxml @@ -1,4 +1,5 @@ -main ApplicationMain ::HAXE_FLAGS:: -D iphone -D ios +--macro keep("::APP_MAIN::") -D no-compilation \ No newline at end of file diff --git a/templates/neko/hxml/debug.hxml b/templates/neko/hxml/debug.hxml index 00753e663..f5b4db93e 100644 --- a/templates/neko/hxml/debug.hxml +++ b/templates/neko/hxml/debug.hxml @@ -1,4 +1,5 @@ -main ApplicationMain ::HAXE_FLAGS:: -cp ::BUILD_DIR::/neko/haxe -neko ::NEKO_FILE:: +--macro keep("::APP_MAIN::") -debug \ No newline at end of file diff --git a/templates/neko/hxml/release.hxml b/templates/neko/hxml/release.hxml index 32e74491d..75625aa15 100644 --- a/templates/neko/hxml/release.hxml +++ b/templates/neko/hxml/release.hxml @@ -1,3 +1,4 @@ -main ApplicationMain ::HAXE_FLAGS:: -cp ::BUILD_DIR::/neko/haxe -neko ::NEKO_FILE:: +--macro keep("::APP_MAIN::") \ No newline at end of file diff --git a/templates/neko/ndll/mac/libneko.dylib b/templates/neko/ndll/mac/libneko.dylib old mode 100644 new mode 100755 diff --git a/templates/neko/ndll/mac/regexp.ndll b/templates/neko/ndll/mac/regexp.ndll old mode 100644 new mode 100755 diff --git a/templates/neko/ndll/mac/sqlite.ndll b/templates/neko/ndll/mac/sqlite.ndll old mode 100644 new mode 100755 diff --git a/templates/neko/ndll/mac/std.ndll b/templates/neko/ndll/mac/std.ndll old mode 100644 new mode 100755 diff --git a/templates/neko/ndll/mac/zlib.ndll b/templates/neko/ndll/mac/zlib.ndll old mode 100644 new mode 100755 diff --git a/templates/neko/ndll/mac64/libneko.dylib b/templates/neko/ndll/mac64/libneko.dylib old mode 100644 new mode 100755 diff --git a/templates/neko/ndll/mac64/regexp.ndll b/templates/neko/ndll/mac64/regexp.ndll old mode 100644 new mode 100755 diff --git a/templates/neko/ndll/mac64/sqlite.ndll b/templates/neko/ndll/mac64/sqlite.ndll old mode 100644 new mode 100755 diff --git a/templates/neko/ndll/mac64/std.ndll b/templates/neko/ndll/mac64/std.ndll old mode 100644 new mode 100755 diff --git a/templates/neko/ndll/mac64/zlib.ndll b/templates/neko/ndll/mac64/zlib.ndll old mode 100644 new mode 100755 diff --git a/templates/tizen/hxml/debug.hxml b/templates/tizen/hxml/debug.hxml index 779a8f1ae..afeca1ea3 100644 --- a/templates/tizen/hxml/debug.hxml +++ b/templates/tizen/hxml/debug.hxml @@ -1,6 +1,7 @@ -main ApplicationMain ::HAXE_FLAGS:: -cp ::BUILD_DIR::/tizen/haxe -cpp ::CPP_DIR:: +--macro keep("::APP_MAIN::") -D tizen -debug -D no-compilation \ No newline at end of file diff --git a/templates/tizen/hxml/release.hxml b/templates/tizen/hxml/release.hxml index 087308420..afdab8443 100644 --- a/templates/tizen/hxml/release.hxml +++ b/templates/tizen/hxml/release.hxml @@ -1,5 +1,6 @@ -main ApplicationMain ::HAXE_FLAGS:: -cp ::BUILD_DIR::/tizen/haxe -cpp ::CPP_DIR:: +--macro keep("::APP_MAIN::") -D tizen -D no-compilation \ No newline at end of file diff --git a/templates/tizen/template/CommandLineBuild/build_data b/templates/tizen/template/CommandLineBuild/build_data index ff438fa9d..17f1fc356 100644 --- a/templates/tizen/template/CommandLineBuild/build_data +++ b/templates/tizen/template/CommandLineBuild/build_data @@ -1,4 +1,4 @@ PLATFORM_VER:Tizen 2.2 -ARCHITECTURE:armel +ARCHITECTURE:::if (SIMULATOR)::i386::else::armel::end:: TOOLCHAIN:GCC-4.5 TYPE:app diff --git a/templates/tizen/template/manifest.xml b/templates/tizen/template/manifest.xml index a1d563066..8c97989ea 100644 --- a/templates/tizen/template/manifest.xml +++ b/templates/tizen/template/manifest.xml @@ -1,23 +1,27 @@ - + ::APP_PACKAGE:: - 1.0.0 + ::APP_VERSION:: C++App - 2.2 + true + true 2.2 - - - - + + http://tizen.org/privilege/application.launch + + + + ::APP_TITLE:: mainmenu.png + diff --git a/templates/webos/hxml/debug.hxml b/templates/webos/hxml/debug.hxml index 6453e8742..f1429d067 100644 --- a/templates/webos/hxml/debug.hxml +++ b/templates/webos/hxml/debug.hxml @@ -1,6 +1,7 @@ -main ApplicationMain ::HAXE_FLAGS:: -cp ::BUILD_DIR::/webos/haxe -cpp ::CPP_DIR:: +--macro keep("::APP_MAIN::") -D webos -D HXCPP_LOAD_DEBUG -D HXCPP_RTLD_LAZY diff --git a/templates/webos/hxml/release.hxml b/templates/webos/hxml/release.hxml index 352af0329..1288019f5 100644 --- a/templates/webos/hxml/release.hxml +++ b/templates/webos/hxml/release.hxml @@ -1,5 +1,6 @@ -main ApplicationMain ::HAXE_FLAGS:: -cp ::BUILD_DIR::/webos/haxe -cpp ::CPP_DIR:: +--macro keep("::APP_MAIN::") -D webos -D HXCPP_RTLD_LAZY \ No newline at end of file