Mercurial > projects > mde
annotate examples/guiDemo.d @ 174:3d58adc17d20
Temporary commit to allow backup
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Mon, 31 Aug 2009 13:54:23 +0200 |
parents | a1ba9157510e |
children |
rev | line source |
---|---|
17
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
1 /* LICENSE BLOCK |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
2 Part of mde: a Modular D game-oriented Engine |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
3 Copyright © 2007-2008 Diggory Hardy |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
4 |
26
611f7b9063c6
Changed the licensing and removed a few dead files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
25
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify it under the terms |
611f7b9063c6
Changed the licensing and removed a few dead files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
25
diff
changeset
|
6 of the GNU General Public License as published by the Free Software Foundation, either |
611f7b9063c6
Changed the licensing and removed a few dead files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
25
diff
changeset
|
7 version 2 of the License, or (at your option) any later version. |
17
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
8 |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
11 See the GNU General Public License for more details. |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
12 |
26
611f7b9063c6
Changed the licensing and removed a few dead files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
25
diff
changeset
|
13 You should have received a copy of the GNU General Public License |
611f7b9063c6
Changed the licensing and removed a few dead files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
25
diff
changeset
|
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
17
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
15 |
85
56c0ddd90193
Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
84
diff
changeset
|
16 /** Main module for a gui demo & testing executable. */ |
56c0ddd90193
Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
84
diff
changeset
|
17 module examples.guiDemo; |
0 | 18 |
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.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
132
diff
changeset
|
19 import mde.imde; |
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.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
132
diff
changeset
|
20 import mde.mainLoop; // Some setup for the main loop |
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.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
132
diff
changeset
|
21 import mde.menus; // add default menus |
83
2813ac68576f
Start of creating a separate gui demo module and leaving mde.d for testing.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
22 import mde.setup.Init; // initialization |
2813ac68576f
Start of creating a separate gui demo module and leaving mde.d for testing.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
23 import mde.scheduler.Scheduler; // mainSchedule |
85
56c0ddd90193
Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
84
diff
changeset
|
24 import mde.setup.Screen; // Screen.draw() |
56c0ddd90193
Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
84
diff
changeset
|
25 import mde.setup.InitStage; // StageState |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
26 import mde.gui.WMScreen; |
0 | 27 |
25
2c28ee04a4ed
Some minor and some futile efforts.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
24
diff
changeset
|
28 import tango.core.Thread : Thread; // Thread.sleep() |
2c28ee04a4ed
Some minor and some futile efforts.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
24
diff
changeset
|
29 import tango.time.Clock; // Clock.now() |
4
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
3
diff
changeset
|
30 import tango.util.log.Log : Log, Logger; |
174
3d58adc17d20
Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents:
173
diff
changeset
|
31 //import tango.core.stacktrace.TraceExceptions; |
4
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
3
diff
changeset
|
32 |
53
f000d6cd0f74
Changes to paths, command line arguments and font LCD rendering.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
33 int main(char[][] args) |
0 | 34 { |
85
56c0ddd90193
Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
84
diff
changeset
|
35 Logger logger = Log.getLogger ("mde.mde"); |
83
2813ac68576f
Start of creating a separate gui demo module and leaving mde.d for testing.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
36 // If compiled with unittests, notify that they completed and exit: |
68
3a737e06dc50
Unittests: fixes and changes. Plus some doc changes.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
64
diff
changeset
|
37 debug (mdeUnitTest) { |
3a737e06dc50
Unittests: fixes and changes. Plus some doc changes.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
64
diff
changeset
|
38 logger.info ("Compiled unittests have completed; terminating."); |
3a737e06dc50
Unittests: fixes and changes. Plus some doc changes.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
64
diff
changeset
|
39 return 0; |
3a737e06dc50
Unittests: fixes and changes. Plus some doc changes.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
64
diff
changeset
|
40 } |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
41 |
85
56c0ddd90193
Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
84
diff
changeset
|
42 // Set up the gui |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
43 scope WMScreen gui = new WMScreen ("guiDemo"); |
85
56c0ddd90193
Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
84
diff
changeset
|
44 StageState guiLoad () { // init func |
56c0ddd90193
Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
84
diff
changeset
|
45 gui.loadDesign(); |
56c0ddd90193
Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
84
diff
changeset
|
46 return StageState.ACTIVE; |
56c0ddd90193
Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
84
diff
changeset
|
47 } |
56c0ddd90193
Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
84
diff
changeset
|
48 StageState guiSave () { |
56c0ddd90193
Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
84
diff
changeset
|
49 gui.save; |
56c0ddd90193
Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
84
diff
changeset
|
50 return StageState.INACTIVE; |
56c0ddd90193
Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
84
diff
changeset
|
51 } |
56c0ddd90193
Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
84
diff
changeset
|
52 addInitStage ("GuiM", &guiLoad, &guiSave, ["SWnd", "Font"]); |
56c0ddd90193
Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
84
diff
changeset
|
53 |
83
2813ac68576f
Start of creating a separate gui demo module and leaving mde.d for testing.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
54 scope Init init = new Init(args); // initialize mde |
36
57d000574d75
Enabled drawing on demand, and made the polling interval configurable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
31
diff
changeset
|
55 |
95
2a364c7d82c9
Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
85
diff
changeset
|
56 mainSchedule.add (SCHEDULE.DRAW, &Screen.draw).request = true; // Draw, per event and first frame only. |
30
467c74d4804d
Major changes to the scheduler, previously only used by the main loop.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
27
diff
changeset
|
57 |
36
57d000574d75
Enabled drawing on demand, and made the polling interval configurable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
31
diff
changeset
|
58 while (run) { |
104
ee209602770d
Cleaned up Options.d removing old storage method. It's now possible to get a ContentList of the whole of Options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
98
diff
changeset
|
59 mainSchedule.execute (Clock.now()); |
ee209602770d
Cleaned up Options.d removing old storage method. It's now possible to get a ContentList of the whole of Options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
98
diff
changeset
|
60 |
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.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
132
diff
changeset
|
61 Thread.sleep (mainInterval); // sleep this many seconds |
4
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
3
diff
changeset
|
62 } |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
3
diff
changeset
|
63 |
9a990644948c
Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
3
diff
changeset
|
64 return 0; // cleanup handled by init's DTOR |
0 | 65 } |