view mde/mde.d @ 16:9cb7b9310168

Improvements to Options and Init. Revamped Options with sections and auto saving/loading. Moved some of init's functions outside the module. committer: Diggory Hardy <diggory.hardy@gmail.com>
author Diggory Hardy <diggory.hardy@gmail.com>
date Sat, 15 Mar 2008 11:56:13 +0000
parents 4608be19ebe2
children 5f90774ea1ef
line wrap: on
line source

/** Modular D Engine
 *
 * This module contains main().
 */
module mde.mde;

// Package imports
import mde.Init;
import global = mde.global;
import mde.events;
import mde.scheduler;
import mde.i18n.I18nTranslation;        // greeting message
import mde.exception;

// This module is ONLY imported because otherwise it wouldn't be compiled in:
import mde.SDL;

import mde.input.input;

// External library imports
import tango.core.Thread : Thread;	// for sleep
//import tango.io.Stdout;
import tango.time.Clock;
import tango.util.log.Log : Log, Logger;

import derelict.sdl.sdl;

int main()
{
    //BEGIN Initialisation
    Logger logger = Log.getLogger ("mde.mde");
    
    try {
        init = new Init();	// initialisation
    } catch (InitException e) {
        logger.fatal ("Initialisation failed; error was:");
        logger.fatal (e.msg);
        return 1;
    }
    
    global.input.addButtonCallback (cast(Input.inputID) 0x0u, delegate void(Input.inputID i, bool b) {
        if (b) {
            logger.info ("Quiting...");
            global.run = false;
        }
    } );
    //END Initialisation
    
    /* Log a greeting message. Just a little test really, but it can stay until i18n finds a proper use. */
    I18nTranslation transl = I18nTranslation.load ("mde");
    logger.info (transl.getEntry ("greeting"));
    
    while (global.run) {
        Scheduler.run (Clock.now());
        
        Thread.sleep (0.050);	// sleep this many seconds
    }
    
    return 0;		// cleanup handled by init's DTOR
}