Wrapper; Input; fixing neko mouse position being completely wrong. Problem due to stage scale mode not being set, meaning mStageScale was scaling the input event x/y according to that, blowing it up.
Wrapper; Debug; general cleanup of _debug prints, these are now limited to debug builds so they don't allocate strings constantly or anything like that in release builds. Wrapper; Audio; making sure audio is shutdown accordingly so it doesn't try update in the background Wrapper; Lime; More cleanup, strict typing the lime config values as it hasn't fluxed in a long time, and is better typed. Wrapper; template; updating to use typed lime config and stricter typing on items passed in
This commit is contained in:
@@ -45,11 +45,13 @@ class AudioHandler {
|
|||||||
sounds = new Map();
|
sounds = new Map();
|
||||||
|
|
||||||
#if (!audio_thread_disabled && lime_native)
|
#if (!audio_thread_disabled && lime_native)
|
||||||
|
|
||||||
audio_state = new AudioThreadState ();
|
audio_state = new AudioThreadState ();
|
||||||
audio_thread_running = true;
|
audio_thread_running = true;
|
||||||
audio_thread_is_idle = false;
|
audio_thread_is_idle = false;
|
||||||
audio_state.main_thread = Thread.current ();
|
audio_state.main_thread = Thread.current ();
|
||||||
audio_state.audio_thread = Thread.create( audio_thread_handler );
|
audio_state.audio_thread = Thread.create( audio_thread_handler );
|
||||||
|
|
||||||
#end //#(!audio_thread_disabled && lime_native)
|
#end //#(!audio_thread_disabled && lime_native)
|
||||||
|
|
||||||
#if lime_html5
|
#if lime_html5
|
||||||
@@ -70,6 +72,12 @@ class AudioHandler {
|
|||||||
|
|
||||||
} //startup
|
} //startup
|
||||||
|
|
||||||
|
@:noCompletion public function shutdown() {
|
||||||
|
|
||||||
|
audio_thread_running = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@:noCompletion public function update() {
|
@:noCompletion public function update() {
|
||||||
|
|
||||||
#if lime_native
|
#if lime_native
|
||||||
@@ -133,9 +141,14 @@ class AudioHandler {
|
|||||||
|
|
||||||
public function audio_thread_handler() {
|
public function audio_thread_handler() {
|
||||||
|
|
||||||
|
#if debug
|
||||||
|
lib._debug("lime: Audio background thread started.");
|
||||||
|
#end //debug
|
||||||
|
|
||||||
|
var thread_message : Dynamic;
|
||||||
while (audio_thread_running) {
|
while (audio_thread_running) {
|
||||||
|
|
||||||
var thread_message:Dynamic = Thread.readMessage (false);
|
thread_message = Thread.readMessage (false);
|
||||||
|
|
||||||
if (thread_message == audio_message_check_complete) {
|
if (thread_message == audio_message_check_complete) {
|
||||||
audio_state.check();
|
audio_state.check();
|
||||||
@@ -153,6 +166,10 @@ class AudioHandler {
|
|||||||
audio_thread_running = false;
|
audio_thread_running = false;
|
||||||
audio_thread_is_idle = true;
|
audio_thread_is_idle = true;
|
||||||
|
|
||||||
|
#if debug
|
||||||
|
lib._debug("lime: Audio background thread shutdown.");
|
||||||
|
#end //debug
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#end //(!audio_thread_disabled && lime_native)
|
#end //(!audio_thread_disabled && lime_native)
|
||||||
|
|||||||
@@ -53,7 +53,9 @@ class InputHandler {
|
|||||||
|
|
||||||
@:noCompletion public function startup() {
|
@:noCompletion public function startup() {
|
||||||
|
|
||||||
lib._debug(':: lime :: \t InputHandler Initialized.');
|
#if debug
|
||||||
|
lib._debug(':: lime :: \t InputHandler Initialized.');
|
||||||
|
#end //debug
|
||||||
|
|
||||||
touches_active = new Map<Int, Dynamic>();
|
touches_active = new Map<Int, Dynamic>();
|
||||||
keys_down = new Map();
|
keys_down = new Map();
|
||||||
@@ -68,7 +70,9 @@ class InputHandler {
|
|||||||
|
|
||||||
@:noCompletion public function shutdown() {
|
@:noCompletion public function shutdown() {
|
||||||
|
|
||||||
lib._debug(':: lime :: \t InputHandler shut down.');
|
#if debug
|
||||||
|
lib._debug(':: lime :: \t InputHandler shut down.');
|
||||||
|
#end //debug
|
||||||
|
|
||||||
} //shutdown
|
} //shutdown
|
||||||
|
|
||||||
|
|||||||
123
lime/Lime.hx
123
lime/Lime.hx
@@ -10,12 +10,30 @@ import lime.WindowHandler;
|
|||||||
|
|
||||||
import haxe.Timer;
|
import haxe.Timer;
|
||||||
|
|
||||||
|
typedef LimeConfig = {
|
||||||
|
? host : Dynamic,
|
||||||
|
? fullscreen : Bool,
|
||||||
|
? resizable : Bool,
|
||||||
|
? borderless : Bool,
|
||||||
|
? antialiasing : Int,
|
||||||
|
? stencil_buffer : Bool,
|
||||||
|
? depth_buffer : Bool,
|
||||||
|
? vsync : Bool,
|
||||||
|
? multitouch_supported : Bool,
|
||||||
|
? multitouch : Bool,
|
||||||
|
? fps : Int,
|
||||||
|
? width : Int,
|
||||||
|
? height : Int,
|
||||||
|
? title : String,
|
||||||
|
? orientation : String
|
||||||
|
}
|
||||||
|
|
||||||
class Lime {
|
class Lime {
|
||||||
|
|
||||||
//The host class of the application
|
//The host class of the application
|
||||||
public var host : Dynamic;
|
public var host : Dynamic;
|
||||||
//the config passed to us on creation
|
//the config passed to us on creation
|
||||||
public var config : Dynamic;
|
public var config : LimeConfig;
|
||||||
|
|
||||||
//The handlers for the messages from lime
|
//The handlers for the messages from lime
|
||||||
public var audio : AudioHandler;
|
public var audio : AudioHandler;
|
||||||
@@ -43,7 +61,9 @@ class Lime {
|
|||||||
frame_rate = value;
|
frame_rate = value;
|
||||||
frame_period = (frame_rate <= 0 ? frame_rate : 1.0 / frame_rate);
|
frame_period = (frame_rate <= 0 ? frame_rate : 1.0 / frame_rate);
|
||||||
|
|
||||||
|
#if debug
|
||||||
_debug(':: lime :: frame rate set to ' + frame_rate);
|
_debug(':: lime :: frame rate set to ' + frame_rate);
|
||||||
|
#end
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
|
||||||
@@ -59,21 +79,19 @@ class Lime {
|
|||||||
public function new() {} //new
|
public function new() {} //new
|
||||||
|
|
||||||
//Initialize
|
//Initialize
|
||||||
public function init( _main_, _config : Dynamic ) {
|
public function init( _main_, _config : LimeConfig ) {
|
||||||
|
|
||||||
config = _config;
|
config = _config;
|
||||||
host = _main_;
|
host = _main_;
|
||||||
|
|
||||||
_debug(':: lime :: initializing - ');
|
#if debug
|
||||||
_debug(':: lime :: Creating window at ' + config.width + 'x' + config.height);
|
_debug(':: lime :: initializing - ');
|
||||||
|
_debug(':: lime :: Creating window at ' + config.width + 'x' + config.height);
|
||||||
|
#end
|
||||||
|
|
||||||
//default to 60 fps
|
//default to 60 fps
|
||||||
if( config.fps != null ) {
|
if( config.fps != null ) {
|
||||||
if(Std.is(config.fps, String)) {
|
frame_rate = config.fps;
|
||||||
frame_rate = Std.parseFloat( config.fps );
|
|
||||||
} else {
|
|
||||||
frame_rate = config.fps;
|
|
||||||
}
|
|
||||||
} else { //config.fps
|
} else { //config.fps
|
||||||
frame_rate = 60;
|
frame_rate = 60;
|
||||||
}
|
}
|
||||||
@@ -121,7 +139,9 @@ class Lime {
|
|||||||
//Since we are done...
|
//Since we are done...
|
||||||
window.set_active(true);
|
window.set_active(true);
|
||||||
|
|
||||||
_debug(':: lime :: Ready.');
|
#if debug
|
||||||
|
_debug(':: lime :: Ready.');
|
||||||
|
#end
|
||||||
|
|
||||||
//Tell the host application we are ready
|
//Tell the host application we are ready
|
||||||
if(host.ready != null) {
|
if(host.ready != null) {
|
||||||
@@ -147,7 +167,7 @@ class Lime {
|
|||||||
window.set_active(false);
|
window.set_active(false);
|
||||||
|
|
||||||
//Order is imporant here too
|
//Order is imporant here too
|
||||||
|
audio.shutdown();
|
||||||
render.shutdown();
|
render.shutdown();
|
||||||
input.shutdown();
|
input.shutdown();
|
||||||
window.shutdown();
|
window.shutdown();
|
||||||
@@ -155,7 +175,9 @@ class Lime {
|
|||||||
//Flag it
|
//Flag it
|
||||||
has_shutdown = true;
|
has_shutdown = true;
|
||||||
|
|
||||||
_debug(':: lime :: Goodbye.');
|
#if debug
|
||||||
|
_debug(':: lime :: Goodbye.');
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cleanup() {
|
public function cleanup() {
|
||||||
@@ -169,9 +191,11 @@ class Lime {
|
|||||||
var result = 0.0;
|
var result = 0.0;
|
||||||
var event_type:Int = Std.int(Reflect.field(_event, "type"));
|
var event_type:Int = Std.int(Reflect.field(_event, "type"));
|
||||||
|
|
||||||
if(event_type != SystemEvents.poll) {
|
#if debug
|
||||||
_debug('event_from_stage : ' + event_type, true, true);
|
if(event_type != SystemEvents.poll) {
|
||||||
}
|
_debug('event_from_stage : ' + event_type, true, true);
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
switch(event_type) {
|
switch(event_type) {
|
||||||
|
|
||||||
@@ -287,23 +311,30 @@ class Lime {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return __updateNextWake();
|
__updateNextWake();
|
||||||
|
return null;
|
||||||
|
|
||||||
} //on_lime_event
|
} //on_lime_event
|
||||||
|
|
||||||
//Handle system/window messages
|
//Handle system/window messages
|
||||||
public function on_syswm(ev:Dynamic) {
|
public function on_syswm(ev:Dynamic) {
|
||||||
_debug('syswm event');
|
#if debug
|
||||||
|
_debug('syswm event');
|
||||||
|
#end
|
||||||
} //on_syswm
|
} //on_syswm
|
||||||
|
|
||||||
public function on_change(ev:Dynamic) {
|
public function on_change(ev:Dynamic) {
|
||||||
_debug('change event');
|
#if debug
|
||||||
|
_debug('change event');
|
||||||
|
#end
|
||||||
} //on_syswm
|
} //on_syswm
|
||||||
|
|
||||||
|
|
||||||
public function on_update(_event) {
|
public function on_update(_event) {
|
||||||
|
|
||||||
_debug('on_update ' + Timer.stamp(), true, false);
|
#if debug
|
||||||
|
_debug('on_update ' + Timer.stamp(), true, false);
|
||||||
|
#end //debug
|
||||||
|
|
||||||
#if lime_native
|
#if lime_native
|
||||||
Timer.__checkTimers();
|
Timer.__checkTimers();
|
||||||
@@ -392,12 +423,12 @@ class Lime {
|
|||||||
|
|
||||||
return nextWake;
|
return nextWake;
|
||||||
|
|
||||||
#else
|
#else //lime_native
|
||||||
return null;
|
return null;
|
||||||
#end
|
#end //!lime_native
|
||||||
|
|
||||||
|
|
||||||
}
|
} //__updateNextWake
|
||||||
|
|
||||||
@:noCompletion private function __nextFrameDue( _otherTimers:Float ) {
|
@:noCompletion private function __nextFrameDue( _otherTimers:Float ) {
|
||||||
|
|
||||||
@@ -424,31 +455,37 @@ class Lime {
|
|||||||
|
|
||||||
//Noisy stuff
|
//Noisy stuff
|
||||||
|
|
||||||
|
#if lime_native
|
||||||
|
|
||||||
|
private static var lime_stage_request_render = Libs.load("lime","lime_stage_request_render", 0);
|
||||||
|
private static var lime_stage_set_next_wake = Libs.load("lime","lime_stage_set_next_wake", 2);
|
||||||
|
|
||||||
|
#end //lime_native
|
||||||
|
|
||||||
//temporary debugging with verbosity options
|
//temporary debugging with verbosity options
|
||||||
|
|
||||||
public var log : Bool = false;
|
#if debug
|
||||||
public var verbose : Bool = false;
|
|
||||||
public var more_verbose : Bool = false;
|
public var log : Bool = false;
|
||||||
public function _debug(value:Dynamic, _verbose:Bool = false, _more_verbose:Bool = false) {
|
public var verbose : Bool = false;
|
||||||
if(log) {
|
public var more_verbose : Bool = false;
|
||||||
if(verbose && _verbose && !_more_verbose) {
|
public function _debug(value:Dynamic, _verbose:Bool = false, _more_verbose:Bool = false) {
|
||||||
trace(value);
|
if(log) {
|
||||||
} else
|
if(verbose && _verbose && !_more_verbose) {
|
||||||
if(more_verbose && _more_verbose) {
|
|
||||||
trace(value);
|
|
||||||
} else {
|
|
||||||
if(!_verbose && !_more_verbose) {
|
|
||||||
trace(value);
|
trace(value);
|
||||||
}
|
} else
|
||||||
} //elses
|
if(more_verbose && _more_verbose) {
|
||||||
} //log
|
trace(value);
|
||||||
} //_debug
|
} else {
|
||||||
|
if(!_verbose && !_more_verbose) {
|
||||||
|
trace(value);
|
||||||
|
}
|
||||||
|
} //elses
|
||||||
|
} //log
|
||||||
|
} //_debug
|
||||||
|
|
||||||
#if lime_native
|
#end //debug
|
||||||
private static var lime_stage_request_render = Libs.load("lime","lime_stage_request_render", 0);
|
|
||||||
private static var lime_stage_set_next_wake = Libs.load("lime","lime_stage_set_next_wake", 2);
|
|
||||||
#end
|
|
||||||
|
|
||||||
}
|
} //Lime
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -114,12 +114,16 @@ class RenderHandler {
|
|||||||
#end //lime_html5
|
#end //lime_html5
|
||||||
|
|
||||||
//Done.
|
//Done.
|
||||||
lib._debug(':: lime :: \t RenderHandler Initialized.');
|
#if debug
|
||||||
|
lib._debug(':: lime :: \t RenderHandler Initialized.');
|
||||||
|
#end //debug
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function shutdown() {
|
public function shutdown() {
|
||||||
lib._debug(':: lime :: \t RenderHandler shut down.');
|
#if debug
|
||||||
|
lib._debug(':: lime :: \t RenderHandler shut down.');
|
||||||
|
#end //debug
|
||||||
}
|
}
|
||||||
|
|
||||||
public function on_resize(_event:Dynamic) {
|
public function on_resize(_event:Dynamic) {
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ class WindowHandler {
|
|||||||
|
|
||||||
public function startup() {
|
public function startup() {
|
||||||
|
|
||||||
lib._debug(':: lime :: \t WindowHandler Initializing...');
|
#if debug
|
||||||
|
lib._debug(':: lime :: \t WindowHandler Initializing...');
|
||||||
|
#end //debug
|
||||||
|
|
||||||
#if lime_native
|
#if lime_native
|
||||||
|
|
||||||
@@ -76,7 +78,9 @@ class WindowHandler {
|
|||||||
lime_close();
|
lime_close();
|
||||||
#end
|
#end
|
||||||
|
|
||||||
lib._debug(':: lime :: \t WindowHandler shut down.');
|
#if debug
|
||||||
|
lib._debug(':: lime :: \t WindowHandler shut down.');
|
||||||
|
#end //debug
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ready() {
|
public function ready() {
|
||||||
@@ -84,16 +88,17 @@ class WindowHandler {
|
|||||||
#if lime_native
|
#if lime_native
|
||||||
//Fetch the stage handle
|
//Fetch the stage handle
|
||||||
lib.view_handle = lime_get_frame_stage( lib.window_handle );
|
lib.view_handle = lime_get_frame_stage( lib.window_handle );
|
||||||
|
//Make sure nothing silly is happening to the stage scale
|
||||||
|
lime_stage_set_scale_mode(lib.view_handle, 1);
|
||||||
//Make sure that our configs are up to date with the actual screen resolution
|
//Make sure that our configs are up to date with the actual screen resolution
|
||||||
//not just the specified resolution in the project file
|
//not just the specified resolution in the project file
|
||||||
lib.config.width = lime_stage_get_stage_width(lib.view_handle);
|
lib.config.width = lime_stage_get_stage_width(lib.view_handle);
|
||||||
lib.config.height = lime_stage_get_stage_height(lib.view_handle);
|
lib.config.height = lime_stage_get_stage_height(lib.view_handle);
|
||||||
|
|
||||||
//move the window based on xml flags
|
//move the window based on xml flags
|
||||||
if(lib.config.x != null && lib.config.y != null) {
|
// if(lib.config.x != null && lib.config.y != null) {
|
||||||
set_window_position(lib.config.x, lib.config.y);
|
// set_window_position(lib.config.x, lib.config.y);
|
||||||
}
|
// }
|
||||||
|
|
||||||
//Update the touch support
|
//Update the touch support
|
||||||
lib.config.multitouch_supported = lime_stage_get_multitouch_supported(lib.view_handle);
|
lib.config.multitouch_supported = lime_stage_get_multitouch_supported(lib.view_handle);
|
||||||
@@ -103,7 +108,6 @@ class WindowHandler {
|
|||||||
|
|
||||||
#end //lime_native
|
#end //lime_native
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function post_ready() {
|
public function post_ready() {
|
||||||
@@ -119,7 +123,9 @@ class WindowHandler {
|
|||||||
lib.render.render();
|
lib.render.render();
|
||||||
#end
|
#end
|
||||||
|
|
||||||
lib._debug(':: lime :: \t WindowHandler Initialized.');
|
#if debug
|
||||||
|
lib._debug(':: lime :: \t WindowHandler Initialized.');
|
||||||
|
#end //debug
|
||||||
}
|
}
|
||||||
|
|
||||||
//Invalidate the window (forcing a redraw on next update)
|
//Invalidate the window (forcing a redraw on next update)
|
||||||
@@ -312,7 +318,7 @@ class WindowHandler {
|
|||||||
|
|
||||||
//lime functions
|
//lime functions
|
||||||
#if lime_native
|
#if lime_native
|
||||||
|
private static var lime_stage_set_scale_mode = Libs.load ("lime", "lime_stage_set_scale_mode", 2);
|
||||||
private static var lime_stage_get_stage_width = Libs.load("lime","lime_stage_get_stage_width", 1);
|
private static var lime_stage_get_stage_width = Libs.load("lime","lime_stage_get_stage_width", 1);
|
||||||
private static var lime_stage_get_stage_height = Libs.load("lime","lime_stage_get_stage_height", 1);
|
private static var lime_stage_get_stage_height = Libs.load("lime","lime_stage_get_stage_height", 1);
|
||||||
private static var lime_set_stage_handler = Libs.load("lime","lime_set_stage_handler", 4);
|
private static var lime_set_stage_handler = Libs.load("lime","lime_set_stage_handler", 4);
|
||||||
|
|||||||
@@ -10,21 +10,23 @@ class ApplicationMain {
|
|||||||
public static function main () {
|
public static function main () {
|
||||||
//Create the runtime
|
//Create the runtime
|
||||||
_lime = new Lime();
|
_lime = new Lime();
|
||||||
//Create the game class, give it the runtime
|
//Create the app class, give it to the bootstrapper
|
||||||
_main_ = new ::APP_MAIN::();
|
_main_ = new ::APP_MAIN::();
|
||||||
|
|
||||||
var config = {
|
var config : LimeConfig = {
|
||||||
|
host : _main_,
|
||||||
fullscreen : ::WIN_FULLSCREEN::,
|
fullscreen : ::WIN_FULLSCREEN::,
|
||||||
resizable : ::WIN_RESIZABLE::,
|
resizable : ::WIN_RESIZABLE::,
|
||||||
borderless : ::WIN_BORDERLESS::,
|
borderless : ::WIN_BORDERLESS::,
|
||||||
antialiasing : ::WIN_ANTIALIASING::,
|
antialiasing : Std.int(::WIN_ANTIALIASING::),
|
||||||
stencil_buffer : ::WIN_STENCIL_BUFFER::,
|
stencil_buffer : ::WIN_STENCIL_BUFFER::,
|
||||||
depth_buffer : ::WIN_DEPTH_BUFFER::,
|
depth_buffer : ::WIN_DEPTH_BUFFER::,
|
||||||
vsync : ::WIN_VSYNC::,
|
vsync : ::WIN_VSYNC::,
|
||||||
fps : ::WIN_FPS::,
|
fps : Std.int(::WIN_FPS::),
|
||||||
width : ::WIN_WIDTH::,
|
width : Std.int(::WIN_WIDTH::),
|
||||||
height : ::WIN_HEIGHT::,
|
height : Std.int(::WIN_HEIGHT::),
|
||||||
title : "::APP_TITLE::"
|
orientation : "::WIN_ORIENTATION::",
|
||||||
|
title : "::APP_TITLE::",
|
||||||
};
|
};
|
||||||
|
|
||||||
//Start up
|
//Start up
|
||||||
|
|||||||
Reference in New Issue
Block a user