X-Git-Url: http://nitlanguage.org diff --git a/lib/mnit/mnit_app.nit b/lib/mnit/mnit_app.nit index fdb9409..4ae8b89 100644 --- a/lib/mnit/mnit_app.nit +++ b/lib/mnit/mnit_app.nit @@ -17,25 +17,23 @@ # General Mnit application structure module mnit_app -import mnit_display +import ::app +import mnit::display # An App instance serves as base to every Mnit projects. # # This class is redefed by plateforme modules and so # App can be specialized directly in the user app. -abstract class App - type IE: InputEvent +redef class App type D: Display type I: Image # Display to use by apps # Is null if the display is not available or not yet ready - var display: nullable D protected writable = null + var display: nullable D = null is protected writable # Received quit order - var quit: Bool writable = false - - init do end + var quit: Bool = false is writable # App is visible? (vs minimized or in background) fun visible: Bool is abstract @@ -54,43 +52,7 @@ abstract class App # Main frame method to redef # Is called between readying display and flipping it - fun frame_core( display: D ) is abstract - - #fun start do end - #fun stop do end - #fun destroy do end - - # Called when asked by the system (mainly for Android) - fun save do end - - # Called when asked by the system (mainly for Android) - fun pause do end - - # Called when asked by the system (mainly for Android) - fun resume do end - - # System notification - fun gained_focus do end - - # System notification - fun lost_focus do end - - # Main init method for graphical stuff - # Is called when display is ready so graphical assets - # can be loaded at this time. - fun init_window do end - - # Called before destroying the window - fun term_window do end - - # Helper function for logging - fun log_error( msg: String ) do print "#nit error: {msg}" - - # Helper function for logging - fun log_warning( msg: String ) do print "#nit warn: {msg}" - - # Helper function for logging - fun log_info( msg: String ) do print "#nit info: {msg}" + fun frame_core( display: D ) do end # Receive and deal with all inputs fun input( event: InputEvent ): Bool @@ -99,11 +61,16 @@ abstract class App end # Internal method to generate inputs - protected fun generate_input is abstract + protected fun generate_input + do + if "NIT_TESTING".environ == "true" then exit 0 + print "Compiled without platform" + exit 1 + end # Main app loop - # Usually you want to redef framw_core instead of this - fun main_loop + # Usually you want to redef frame_core instead of this + redef fun run do while not quit do generate_input