/**
 *  Base for a standard mania app
 */
#RequireContext CManiaAppPlayground
#Const AppBase_Version     "2017-03-09"
#Const AppBase_ScriptName  "ManiaApps/Nadeo/AppBase.Script.txt"

// ---------------------------------- //
// Libraries
// ---------------------------------- //
#Include "Libs/Nadeo/Env.Script.txt" as Env
#Include "Libs/Nadeo/Log.Script.txt" as Log
#Include "ManiaApps/Nadeo/Layers.Script.txt" as Layers

// ---------------------------------- //
// Settings
// ---------------------------------- //
#Setting S_ScriptEnvironment "production" as "<hidden>" ///< Environment in which the script runs

// ---------------------------------- //
// Extends
// ---------------------------------- //
***LoadLibraries***
***
// Must be loaded before other libraries
Env::Load();
Env::Set(S_ScriptEnvironment);
Log::Load();
Layers::Load();
***

***UnloadLibraries***
***
Layers::Unload();
Log::Unload();
Env::Unload();
***

// ---------------------------------- //
// Functions
// ---------------------------------- //
// ---------------------------------- //
// Public
// ---------------------------------- //
// ---------------------------------- //
/** yield; the script
 *  This should be the only place  
 *  in the complete mania app where
 *  the script yields
 */
Void App_Yield() {
  yield;
  +++Yield+++
}

// ---------------------------------- //
// Main
// ---------------------------------- //
main() {
  LayersDefaultManialinkVersion = 3;
  EnableMenuNavigationInputs = False;

  // ---------------------------------- //
  // Settings
  +++Settings+++

  // ---------------------------------- //
  // Load libraries
  +++LoadLibraries+++

  +++LogVersions+++
  Log::DisplayScripts();

  // ---------------------------------- //
  // Init app and config
  +++InitApp+++

  // ---------------------------------- //
  // Start app
  +++StartApp+++

  while(True) {
    App_Yield();
    +++AppLoop+++
  }

  // ---------------------------------- //
  // Stop app and cleanup
  +++EndApp+++

  // ---------------------------------- //
  // Unload libraries
  +++UnloadLibraries+++
}