Changeset 63:66d555da083e
- Timestamp:
- 06/27/08 13:35:33
(7 months ago)
- Author:
- Diggory Hardy <diggory.hardy@gmail.com>
- branch:
- default
- Message:
Moved many modules/packages to better reflect usage.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r61 |
r63 |
|
| 14 | 14 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
|---|
| 15 | 15 | |
|---|
| 16 | | /// Handles all events from SDL_PollEvent. |
|---|
| | 16 | /** Handling for all events from SDL_PollEvent. |
|---|
| | 17 | * |
|---|
| | 18 | * Handles some events, including a quit-request and window resizing, and passes the rest on to the |
|---|
| | 19 | * input system. */ |
|---|
| 17 | 20 | module mde.events; |
|---|
| 18 | 21 | |
|---|
| 19 | 22 | import imde = mde.imde; |
|---|
| 20 | | import sdl = mde.sdl; // resizeWindow |
|---|
| | 23 | import sdl = mde.setup.sdl; // resizeWindow |
|---|
| 21 | 24 | |
|---|
| 22 | 25 | import mde.input.Input; |
|---|
| r61 |
r63 |
|
| 23 | 23 | * coords are cartesian (i.e. y increases upwards), although largely this is too abstract to |
|---|
| 24 | 24 | * matter. However, for the model/world coords, y increases downwards. */ |
|---|
| 25 | | module mde.resource.FontTexture; |
|---|
| 26 | | |
|---|
| 27 | | import mde.types.basic; // Colour |
|---|
| 28 | | import mde.Options; |
|---|
| 29 | | import mde.resource.exception; |
|---|
| | 25 | module mde.font.FontTexture; |
|---|
| | 26 | |
|---|
| | 27 | import mde.types.Colour; |
|---|
| | 28 | import mde.lookup.Options; |
|---|
| | 29 | import mde.font.exception; |
|---|
| 30 | 30 | |
|---|
| 31 | 31 | import derelict.freetype.ft; |
|---|
| … | … | |
| 37 | 37 | private Logger logger; |
|---|
| 38 | 38 | static this () { |
|---|
| 39 | | logger = Log.getLogger ("mde.resource.FontTexture"); |
|---|
| | 39 | logger = Log.getLogger ("mde.font.FontTexture"); |
|---|
| 40 | 40 | } |
|---|
| 41 | 41 | |
|---|
| r48 |
r63 |
|
| 14 | 14 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
|---|
| 15 | 15 | |
|---|
| 16 | | /// Contains resource exceptions |
|---|
| 17 | | module mde.resource.exception; |
|---|
| | 16 | /// Contains font exceptions |
|---|
| | 17 | module mde.font.exception; |
|---|
| 18 | 18 | import mde.exception; |
|---|
| 19 | 19 | |
|---|
| … | … | |
| 21 | 21 | class fontException : mdeException { |
|---|
| 22 | 22 | char[] getSymbol () { |
|---|
| 23 | | return super.getSymbol ~ ".resource.font"; |
|---|
| | 23 | return super.getSymbol ~ ".font"; |
|---|
| 24 | 24 | } |
|---|
| 25 | 25 | |
|---|
| r61 |
r63 |
|
| 15 | 15 | |
|---|
| 16 | 16 | /// Sets up freetype (in a basic way). |
|---|
| 17 | | module mde.resource.font; |
|---|
| 18 | | |
|---|
| 19 | | public import mde.types.basic; // Colour |
|---|
| 20 | | import mde.Options; |
|---|
| 21 | | import mde.resource.FontTexture; |
|---|
| 22 | | import mde.resource.exception; |
|---|
| | 17 | module mde.font.font; |
|---|
| | 18 | |
|---|
| | 19 | public import mde.types.Colour; |
|---|
| | 20 | import mde.lookup.Options; |
|---|
| | 21 | import mde.font.FontTexture; |
|---|
| | 22 | import mde.font.exception; |
|---|
| 23 | 23 | |
|---|
| 24 | 24 | import mde.mergetag.Reader; |
|---|
| 25 | 25 | import mde.mergetag.DataSet; |
|---|
| 26 | 26 | import mde.mergetag.exception; |
|---|
| 27 | | import mde.resource.paths; |
|---|
| | 27 | import mde.setup.paths; |
|---|
| 28 | 28 | |
|---|
| 29 | 29 | import derelict.freetype.ft; |
|---|
| … | … | |
| 36 | 36 | |
|---|
| 37 | 37 | // "Publically import" this symbol: |
|---|
| 38 | | alias mde.resource.FontTexture.TextBlock TextBlock; |
|---|
| | 38 | alias mde.font.FontTexture.TextBlock TextBlock; |
|---|
| 39 | 39 | |
|---|
| 40 | 40 | private Logger logger; |
|---|
| 41 | 41 | static this () { |
|---|
| 42 | | logger = Log.getLogger ("mde.resource.font"); |
|---|
| | 42 | logger = Log.getLogger ("mde.font.font"); |
|---|
| 43 | 43 | } |
|---|
| 44 | 44 | |
|---|
| r61 |
r63 |
|
| 27 | 27 | import tango.util.log.Log : Log, Logger; |
|---|
| 28 | 28 | |
|---|
| 29 | | import mde.resource.font; |
|---|
| | 29 | import mde.font.font; |
|---|
| 30 | 30 | private Logger logger; |
|---|
| 31 | 31 | static this () { |
|---|
| r58 |
r63 |
|
| 38 | 38 | import mde.mergetag.Reader; |
|---|
| 39 | 39 | import mde.mergetag.Writer; |
|---|
| 40 | | import mde.resource.paths; |
|---|
| | 40 | import mde.setup.paths; |
|---|
| 41 | 41 | |
|---|
| 42 | 42 | import tango.util.log.Log : Log, Logger; |
|---|
| r62 |
r63 |
|
| 25 | 25 | import mde.gui.content.Content; |
|---|
| 26 | 26 | |
|---|
| 27 | | import mde.resource.font; |
|---|
| | 27 | import mde.font.font; |
|---|
| 28 | 28 | |
|---|
| 29 | 29 | import tango.io.Stdout; |
|---|
| r32 |
r63 |
|
| 22 | 22 | |
|---|
| 23 | 23 | import MT = mde.mergetag.Reader; |
|---|
| 24 | | import mde.resource.paths; |
|---|
| | 24 | import mde.setup.paths; |
|---|
| 25 | 25 | import tango.scrapple.text.convert.parseTo : parseTo; |
|---|
| 26 | 26 | |
|---|
| r61 |
r63 |
|
| 367 | 367 | es_m_fcts = [ ES_M.OUT : &es_m_out ]; |
|---|
| 368 | 368 | |
|---|
| 369 | | logger = Log.getLogger ("mde.input.input.Input"); |
|---|
| | 369 | logger = Log.getLogger ("mde.input.Input"); |
|---|
| 370 | 370 | } |
|---|
| 371 | 371 | |
|---|
| r62 |
r63 |
|
| 20 | 20 | * small numbers of variables for now. |
|---|
| 21 | 21 | */ |
|---|
| 22 | | module mde.Options; |
|---|
| | 22 | module mde.lookup.Options; |
|---|
| 23 | 23 | |
|---|
| 24 | 24 | import mde.exception; |
|---|
| … | … | |
| 28 | 28 | import mde.mergetag.DataSet; |
|---|
| 29 | 29 | import mde.mergetag.exception; |
|---|
| 30 | | import mde.resource.paths; |
|---|
| | 30 | import mde.setup.paths; |
|---|
| 31 | 31 | |
|---|
| 32 | 32 | import tango.scrapple.text.convert.parseTo : parseTo; |
|---|
| … | … | |
| 466 | 466 | } |
|---|
| 467 | 467 | |
|---|
| 468 | | /* NOTE: These Options classes use templates to ease inserting contents. |
|---|
| 469 | | * |
|---|
| 470 | | * Each entry has an I18nTranslation entry; see data/L10n/ClassName.mtt for descriptions. |
|---|
| 471 | | * |
|---|
| 472 | | * To create a new class, just copy and paste anywhere and adjust. |
|---|
| | 468 | /* NOTE: Options sub-classes are expected to use a template to ease inserting contents and |
|---|
| | 469 | * hide some of the "backend" functionality. Use impl as below, or read the documentation for impl. |
|---|
| | 470 | * |
|---|
| | 471 | * Each entry should have a Translation entry with humanized names and descriptions in |
|---|
| | 472 | * data/L10n/ClassName.mtt |
|---|
| | 473 | * |
|---|
| | 474 | * To create a new Options sub-class, just copy, paste and adjust. |
|---|
| 473 | 475 | */ |
|---|
| 474 | 476 | |
|---|
| r26 |
r63 |
|
| 13 | 13 | You should have received a copy of the GNU General Public License |
|---|
| 14 | 14 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
|---|
| 15 | | /** I18nTranslation â internationalization module for translating strings |
|---|
| | 15 | /** Translation â internationalization module for translating strings |
|---|
| 16 | 16 | * |
|---|
| 17 | 17 | * The idea behind this module is a class which, when asked to load symbols for a particular module/ |
|---|
| … | … | |
| 36 | 36 | * this feature. Of course, out of date entries are still valid for use. |
|---|
| 37 | 37 | */ |
|---|
| 38 | | module mde.i18n.I18nTranslation; |
|---|
| | 38 | module mde.lookup.Translation; |
|---|
| 39 | 39 | |
|---|
| 40 | 40 | import mde.options; |
|---|
| … | … | |
| 55 | 55 | * Encoding used is UTF-8. |
|---|
| 56 | 56 | */ |
|---|
| 57 | | class I18nTranslation : IDataSection |
|---|
| | 57 | class Translation : IDataSection |
|---|
| 58 | 58 | { |
|---|
| 59 | 59 | final char[] name; /// The module/package/... which the instance is for |
|---|
| … | … | |
| 90 | 90 | * loaded), or an error occurs while loading the database, a L10nLoadException will be thrown. |
|---|
| 91 | 91 | */ |
|---|
| 92 | | static I18nTranslation load (char[] name) |
|---|
| | 92 | static Translation load (char[] name) |
|---|
| 93 | 93 | { |
|---|
| 94 | 94 | bool[ID] loadedSecs; // set of all locales/sections loaded; used to prevent circular loading |
|---|
| … | … | |
| 96 | 96 | = [cast(ID) miscOpts.L10n]; // start by loading the current locale |
|---|
| 97 | 97 | |
|---|
| 98 | | I18nTranslation transl = new I18nTranslation (name, miscOpts.L10n); |
|---|
| | 98 | Translation transl = new Translation (name, miscOpts.L10n); |
|---|
| 99 | 99 | |
|---|
| 100 | 100 | IReader reader; |
|---|
| … | … | |
| 134 | 134 | |
|---|
| 135 | 135 | static this() { |
|---|
| 136 | | logger = Log.getLogger ("mde.input.i18n.I18nTranslation"); |
|---|
| | 136 | logger = Log.getLogger ("mde.lookup.Translation"); |
|---|
| 137 | 137 | } |
|---|
| 138 | 138 | |
|---|
| … | … | |
| 219 | 219 | miscOpts.L10n = "test-1"; |
|---|
| 220 | 220 | |
|---|
| 221 | | I18nTranslation transl = load ("i18nUnitTest"); |
|---|
| | 221 | Translation transl = load ("i18nUnitTest"); |
|---|
| 222 | 222 | |
|---|
| 223 | 223 | // Simple get-string, check dependancy's entry doesn't override |
|---|
| r53 |
r63 |
|
| 24 | 24 | import mde.imde; // this module's interface for external modules |
|---|
| 25 | 25 | import mde.events; // pollEvents |
|---|
| 26 | | import mde.Options; // pollInterval option |
|---|
| | 26 | import mde.lookup.Options; // pollInterval option |
|---|
| 27 | 27 | |
|---|
| 28 | 28 | import gl = mde.gl.draw; // gl.draw() |
|---|
| 29 | 29 | import mde.input.Input; // new Input() |
|---|
| 30 | 30 | |
|---|
| 31 | | import mde.scheduler.Init; |
|---|
| | 31 | import mde.setup.Init; |
|---|
| 32 | 32 | import mde.scheduler.Scheduler; // Scheduler.run() |
|---|
| 33 | | import mde.scheduler.exception; // InitException |
|---|
| | 33 | import mde.setup.exception; // InitException |
|---|
| 34 | 34 | |
|---|
| 35 | 35 | import tango.core.Thread : Thread; // Thread.sleep() |
|---|
| r39 |
r63 |
|
| 14 | 14 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
|---|
| 15 | 15 | |
|---|
| 16 | | /** Scheduler |
|---|
| 17 | | */ |
|---|
| | 16 | /** A fairly generic scheduler. |
|---|
| | 17 | * |
|---|
| | 18 | * This class implements most functionality a generic scheduler might want, however currently it |
|---|
| | 19 | * doesn't any uses where equivalent functionality couldn't be achived very easily anyway. */ |
|---|
| 18 | 20 | module mde.scheduler.Scheduler; |
|---|
| 19 | 21 | |
|---|
| r56 |
r63 |
|
| 21 | 21 | * code; with the exception of that for the logger. |
|---|
| 22 | 22 | *************************************************************************************************/ |
|---|
| 23 | | module mde.scheduler.Init; |
|---|
| 24 | | |
|---|
| 25 | | import mde.scheduler.init2; // This module is responsible for setting up some init functions. |
|---|
| 26 | | import mde.scheduler.initFunctions; |
|---|
| 27 | | import mde.scheduler.exception; |
|---|
| 28 | | |
|---|
| 29 | | import mde.Options; |
|---|
| 30 | | import paths = mde.resource.paths; |
|---|
| | 23 | module mde.setup.Init; |
|---|
| | 24 | |
|---|
| | 25 | import mde.setup.init2; // This module is responsible for setting up some init functions. |
|---|
| | 26 | import mde.setup.initFunctions; |
|---|
| | 27 | import mde.setup.exception; |
|---|
| | 28 | |
|---|
| | 29 | import mde.lookup.Options; |
|---|
| | 30 | import paths = mde.setup.paths; |
|---|
| 31 | 31 | import mde.exception; |
|---|
| 32 | 32 | |
|---|
| … | … | |
| 85 | 85 | private static Logger logger; |
|---|
| 86 | 86 | static this() { |
|---|
| 87 | | logger = Log.getLogger ("mde.scheduler.Init.Init"); |
|---|
| | 87 | logger = Log.getLogger ("mde.setup.Init"); |
|---|
| 88 | 88 | } |
|---|
| 89 | 89 | |
|---|
| r26 |
r63 |
|
| 15 | 15 | |
|---|
| 16 | 16 | /// Contains the exception classes for Init. |
|---|
| 17 | | module mde.scheduler.exception; |
|---|
| | 17 | module mde.setup.exception; |
|---|
| 18 | 18 | |
|---|
| 19 | 19 | import mde.exception; |
|---|
| … | … | |
| 22 | 22 | class InitException : mdeException { |
|---|
| 23 | 23 | char[] getSymbol () { |
|---|
| 24 | | return super.getSymbol ~ ".Init"; |
|---|
| | 24 | return super.getSymbol ~ ".setup.Init"; |
|---|
| 25 | 25 | } |
|---|
| 26 | 26 | |
|---|
| r49 |
r63 |
|
| 28 | 28 | /* Idea: go back to init being controlled from elsewhere. Add a function to wait for another init |
|---|
| 29 | 29 | * function to complete (threaded; might need to be done differently for non-threaded). */ |
|---|
| 30 | | module mde.scheduler.init2; |
|---|
| | 30 | module mde.setup.init2; |
|---|
| 31 | 31 | |
|---|
| 32 | | import mde.scheduler.initFunctions; |
|---|
| | 32 | import mde.setup.initFunctions; |
|---|
| 33 | 33 | |
|---|
| 34 | 34 | import tango.util.log.Log : Log, Logger; |
|---|
| … | … | |
| 38 | 38 | import mde.gui.Gui; |
|---|
| 39 | 39 | import mde.input.Input; |
|---|
| 40 | | import font = mde.resource.font; |
|---|
| | 40 | import font = mde.font.font; |
|---|
| 41 | 41 | |
|---|
| 42 | 42 | // NOTE: error reporting needs a revision |
|---|
| … | … | |
| 44 | 44 | private Logger logger; |
|---|
| 45 | 45 | static this () { |
|---|
| 46 | | logger = Log.getLogger ("mde.scheduler.Init2"); |
|---|
| | 46 | logger = Log.getLogger ("mde.setup.init2"); |
|---|
| 47 | 47 | |
|---|
| 48 | 48 | init.addFunc (&initInput, "initInput"); |
|---|
| r39 |
r63 |
|
| 22 | 22 | * either by throwing an exception or by returning a boolean. Functions may take parameters, e.g. |
|---|
| 23 | 23 | * "out cleanupFunc[]". */ |
|---|
| 24 | | module mde.scheduler.initFunctions; |
|---|
| | 24 | module mde.setup.initFunctions; |
|---|
| 25 | 25 | |
|---|
| 26 | 26 | /+ unused |
|---|
| 27 | 27 | import tango.util.log.Log : Log, Logger; |
|---|
| 28 | 28 | static this() { |
|---|
| 29 | | logger = Log.getLogger ("mde.scheduler.InitFunctions"); |
|---|
| 30 | | }+/ |
|---|
| | 29 | logger = Log.getLogger ("mde.setup.initFunctions"); |
|---|
| | 30 | } |
|---|
| | 31 | private Logger logger; |
|---|
| | 32 | +/ |
|---|
| 31 | 33 | |
|---|
| 32 | 34 | void setInitFailure () { /// Call to indicate failure in an init function |
|---|
| … | … | |
| 72 | 74 | package: |
|---|
| 73 | 75 | bool initFailure = false; // set on failure (throwing through threads isn't a good idea) |
|---|
| 74 | | |
|---|
| 75 | | private: |
|---|
| 76 | | //Logger logger; |
|---|
| r53 |
r63 |
|
| 30 | 30 | * the FilePath has served its immediate purpose, since it's more convenient and creating new |
|---|
| 31 | 31 | * FilePaths for adjusted paths should be no slower than mutating existing ones. */ |
|---|
| 32 | | module mde.resource.paths; |
|---|
| | 32 | module mde.setup.paths; |
|---|
| 33 | 33 | |
|---|
| 34 | 34 | import mde.exception; |
|---|
| … | … | |
| 310 | 310 | assert (files !is null, "mdeReader.this: files is null"); |
|---|
| 311 | 311 | } body { |
|---|
| | 312 | // Don't let sub-readers create their own, separate, datasets: |
|---|
| 312 | 313 | if (ds is null) ds = new DataSet; |
|---|
| 313 | 314 | |
|---|
| r55 |
r63 |
|
| 16 | 16 | /** Just a temporary place to put SDL Init and Video stuff. |
|---|
| 17 | 17 | */ |
|---|
| 18 | | module mde.sdl; |
|---|
| | 18 | module mde.setup.sdl; |
|---|
| 19 | 19 | |
|---|
| 20 | | import mde.scheduler.initFunctions; |
|---|
| | 20 | import mde.setup.initFunctions; |
|---|
| 21 | 21 | import mde.input.joystick; |
|---|
| 22 | | import mde.Options; |
|---|
| | 22 | import mde.lookup.Options; |
|---|
| 23 | 23 | import mde.gl.basic; |
|---|
| 24 | 24 | import imde = mde.imde; |
|---|
| … | … | |
| 33 | 33 | private Logger logger; |
|---|
| 34 | 34 | static this() { |
|---|
| 35 | | logger = Log.getLogger ("mde.SDL"); |
|---|
| | 35 | logger = Log.getLogger ("mde.setup.sdl"); |
|---|
| 36 | 36 | |
|---|
| 37 | 37 | init.addFunc (&initSdlAndGl, "initSdlAndGl"); |
|---|
| r57 |
r63 |
|
| 14 | 14 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
|---|
| 15 | 15 | |
|---|
| 16 | | /** Contains basic types used by mde. Some may be moved to other modules. */ |
|---|
| 17 | | module mde.types.basic; |
|---|
| 18 | | |
|---|
| 19 | | //FIXME: remove import and change types or not? |
|---|
| 20 | | import derelict.opengl.gltypes; |
|---|
| | 16 | /** Contains a basic colour type. */ |
|---|
| | 17 | module mde.types.Colour; |
|---|
| 21 | 18 | |
|---|
| 22 | 19 | /// Represent a colour using clamped floats |
|---|
| 23 | 20 | struct Colour { |
|---|
| 24 | 21 | /// Returns GL_ONE if total value is nearer white than black, else GL_ZERO. |
|---|
| 25 | | GLenum nearestGLConst () { |
|---|
| 26 | | return r+g+b >= 1.5f ? GL_ONE : GL_ZERO; |
|---|
| | 22 | uint nearestGLConst () { |
|---|
| | 23 | return r+g+b >= 1.5f ? 1u : 0u; |
|---|
| 27 | 24 | } |
|---|
| 28 | 25 | |
|---|
| 29 | | GLclampf r,g,b; /// values |
|---|
| | 26 | float r,g,b; /// values |
|---|
| 30 | 27 | |
|---|
| 31 | 28 | static { |
|---|