Mercurial > projects > mde
comparison mde/lookup/Options.d @ 112:fe061009029d
EnumContent; log level can be selected from a popup list.
New EnumContent, with code to load translations in Items. Editable as an AStringContent.
Hacked OptionsMisc to use an EnumContent.
Implemented a EnumContentWidget providing a pop-up list to select from (still needs improving).
Moved IContent to its own module.
ContentExceptions thrown via WDCCheck now.
Fixed a small bug with reloading translations.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sat, 13 Dec 2008 12:54:43 +0000 |
parents | 08651e8a8c51 |
children | 1b1e2297e2fc |
comparison
equal
deleted
inserted
replaced
111:1655693702fc | 112:fe061009029d |
---|---|
428 "TextContent L10n;". The pragma statement can be uncommented to see what code gets injected | 428 "TextContent L10n;". The pragma statement can be uncommented to see what code gets injected |
429 (note: pragma () gets called each time the module is imported as well as when it's compiled). | 429 (note: pragma () gets called each time the module is imported as well as when it's compiled). |
430 impl creates a this() function; if you want to include your own CTOR see impl's ddoc. */ | 430 impl creates a this() function; if you want to include your own CTOR see impl's ddoc. */ |
431 const A = "bool exitImmediately; int maxThreads, logLevel, logOutput; double pollInterval; char[] L10n;"; | 431 const A = "bool exitImmediately; int maxThreads, logLevel, logOutput; double pollInterval; char[] L10n;"; |
432 //pragma (msg, impl!(A)); | 432 //pragma (msg, impl!(A)); |
433 mixin (impl!(A)); | 433 //mixin (impl!(A)); |
434 BoolContent exitImmediately; | |
435 IntContent maxThreads, logOutput; | |
436 EnumContent logLevel; | |
437 DoubleContent pollInterval; | |
438 StringContent L10n; | |
439 | |
440 this(char[] name){ | |
441 optionChanges = new OptionChanges; | |
442 super (name); | |
443 opts["exitImmediately"] = (exitImmediately = new BoolContent ("exitImmediately")).addCallback (&optionChanges.set); | |
444 opts["maxThreads"] = (maxThreads = new IntContent ("maxThreads")).addCallback (&optionChanges.set); | |
445 opts["logLevel"] = (logLevel = new EnumContent ("logLevel", ["Trace", "Info", "Warn", "Error", "Fatal", "None"])).addCallback (&optionChanges.set); | |
446 opts["logOutput"] = (logOutput = new IntContent ("logOutput")).addCallback (&optionChanges.set); | |
447 opts["pollInterval"] = (pollInterval = new DoubleContent ("pollInterval")).addCallback (&optionChanges.set); | |
448 opts["L10n"] = (L10n = new StringContent ("L10n")).addCallback (&optionChanges.set); | |
449 } | |
434 | 450 |
435 // Overriding validate allows limits to be enforced on variables at load time. Currently | 451 // Overriding validate allows limits to be enforced on variables at load time. Currently |
436 // there's no infrastructure for enforcing limits when options are set at run-time. | 452 // there's no infrastructure for enforcing limits when options are set at run-time. |
437 override void validate() { | 453 override void validate() { |
438 // Try to enforce sensible values, whilst being reasonably flexible: | 454 // Try to enforce sensible values, whilst being reasonably flexible: |
439 if (maxThreads() < 1 || maxThreads() > 64) { | 455 if (maxThreads() < 1 || maxThreads() > 64) { |
440 logger.warn ("maxThreads must be in the range 1-64. Defaulting to 4."); | 456 logger.warn ("maxThreads must be in the range 1-64. Defaulting to 4."); |
441 maxThreads = 4; | 457 maxThreads = 4; |
442 } | 458 } |
443 if (pollInterval() !<= 1.0 || pollInterval() !>= 0.0) | 459 if (pollInterval() !<= 0.1 || pollInterval() !>= 0.0) |
444 pollInterval = 0.01; | 460 pollInterval = 0.01; |
445 } | 461 } |
446 | 462 |
447 // A static CTOR is a good place to create the instance (it must be created before init runs). | 463 // A static CTOR is a good place to create the instance (it must be created before init runs). |
448 static this() { | 464 static this() { |