comparison examples/guiDemo.d @ 137:9f035cd139c6

BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed. Content restrutured a lot: New IContent module, Content module includes more functionality. New ContentLoader module to manage content loading/saving/translation. Translation module moved to content dir and cut down to reflect current usage. File format unchanged except renames: FontOptions -> Font, VideoOptions -> Screen. Font render mode and LCD filter options are now enums. GUI loading needs to create content (and set type for enums), but doesn't save/load value. Some setup of mainSchedule moved to mde.mainLoop. Content callbacks are called on content change now. ContentLists are set up implicitly from content symbols. Not as fast but much easier! Bug-fix in the new MTTagReader. Renamed MT *Reader maker functions to avoid confusion in paths.d. New mde.setup.logger module to allow logger setup before any other module's static this().
author Diggory Hardy <diggory.hardy@gmail.com>
date Sat, 07 Feb 2009 12:46:03 +0000
parents 264028f4115a
children a1ba9157510e
comparison
equal deleted inserted replaced
136:4084f07f2c7a 137:9f035cd139c6
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
15 15
16 /** Main module for a gui demo & testing executable. */ 16 /** Main module for a gui demo & testing executable. */
17 module examples.guiDemo; 17 module examples.guiDemo;
18 18
19 import mde.imde; // this module's interface for external modules 19 import mde.imde;
20 import mde.menus; // add default menus 20 import mde.mainLoop; // Some setup for the main loop
21 import mde.events; // pollEvents() // NOTE: Must be imported before Init, otherwise fonts don't display properly (why??) 21 import mde.menus; // add default menus
22 import mde.setup.Init; // initialization 22 import mde.setup.Init; // initialization
23 import mde.lookup.Options; // pollInterval option
24 import mde.scheduler.Scheduler; // mainSchedule 23 import mde.scheduler.Scheduler; // mainSchedule
25 import mde.setup.Screen; // Screen.draw() 24 import mde.setup.Screen; // Screen.draw()
26 import mde.setup.InitStage; // StageState 25 import mde.setup.InitStage; // StageState
27 import mde.gui.WMScreen; 26 import mde.gui.WMScreen;
28 27
29 import tango.core.Thread : Thread; // Thread.sleep() 28 import tango.core.Thread : Thread; // Thread.sleep()
30 import tango.time.Clock; // Clock.now() 29 import tango.time.Clock; // Clock.now()
31 import tango.util.log.Log : Log, Logger; 30 import tango.util.log.Log : Log, Logger;
32 debug (mdeUnitTest) {
33 import mde.file.ssi;
34 import mde.file.mergetag.mdeUT;
35 }
36 31
37 int main(char[][] args) 32 int main(char[][] args)
38 { 33 {
39 Logger logger = Log.getLogger ("mde.mde"); 34 Logger logger = Log.getLogger ("mde.mde");
40 // If compiled with unittests, notify that they completed and exit: 35 // If compiled with unittests, notify that they completed and exit:
55 } 50 }
56 addInitStage ("GuiM", &guiLoad, &guiSave, ["SWnd", "Font"]); 51 addInitStage ("GuiM", &guiLoad, &guiSave, ["SWnd", "Font"]);
57 52
58 scope Init init = new Init(args); // initialize mde 53 scope Init init = new Init(args); // initialize mde
59 54
60 //BEGIN Main loop setup
61 /* Note: the main loop is currently controlled by the scheduler. This is not really ideal,
62 * since it provides no direct control of the order in which components are executed and does
63 * not allow running components simultaeneously with threads.
64 * Note: probably drawing should start at the beginning of the loop and glFlush()/swapBuffers
65 * be called at the end to optimise. */
66 mainSchedule.add (SCHEDULE.DRAW, &Screen.draw).request = true; // Draw, per event and first frame only. 55 mainSchedule.add (SCHEDULE.DRAW, &Screen.draw).request = true; // Draw, per event and first frame only.
67 mainSchedule.add (mainSchedule.getNewID, &mde.events.pollEvents).frame = true;
68 //END Main loop setup
69 56
70 double pollInterval = miscOpts.pollInterval();
71 while (run) { 57 while (run) {
72 mainSchedule.execute (Clock.now()); 58 mainSchedule.execute (Clock.now());
73 59
74 Thread.sleep (pollInterval); // sleep this many seconds 60 Thread.sleep (mainInterval); // sleep this many seconds
75 } 61 }
76 62
77 return 0; // cleanup handled by init's DTOR 63 return 0; // cleanup handled by init's DTOR
78 } 64 }