Changeset 74:cee261eba249

Show
Ignore:
Timestamp:
07/07/08 10:54:47 (6 months ago)
Author:
Diggory Hardy <diggory.hardy@gmail.com>
branch:
default
Message:

Minor tweaks.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • codeDoc/jobs.txt

    r72 r74  
    44 
    55In progress: 
     6Redesigning how widgets are created and receive their data. 
    67 
    78 
     
    910To do (importance 0-5: 0 pointless, 1 no obvious impact now, 2 todo sometime, 3 useful, 4 important, 5 urgent): 
    1011Also see todo.txt and FIXME/NOTE comment marks. 
    11 4   Fonts from Options. Get yMax for font not all glyphs on line? 
     124   Try to correlate names of option sections more. (i.e. symbol name, class name, name of i18n translation file) 
    12134   Not guaranteed to catch up-click ending callback! Appears not to be a problem... 
    13144   OutOfMemoryException is not currently checked for − it should be at least in critical places (use high-level catching of all errors?). 
     153   Fonts from Options. Get yMax for font not all glyphs on line? 
    14163   glBindTexture not working with non-0 index (??) 
    15173   on-event draw support (mde.events and GUI need to tell mde.mde) 
     
    17193   Update scheduler as outlined in FIXME. 
    18203   Windows building/compatibility (currently partial) 
     212   Remove ability to scan, then load, mergetag sections. Not so necessary with section creator callback and allows "sliding window" type partial buffering. 
    19222   Options need a "level": simple options, for advanced users, for debugging only, etc. 
    20232   Command-line options for paths to by-pass normal path finding functionality. 
  • codeDoc/todo.txt

    r66 r74  
    33 
    44 
    5 * means done 
     5* means done: 
    66 
    77GUI: 
     
    1515->  Content: 
    1616    ->  lists 
     17 
     18 
     19+ shows current preference: 
     20 
     21Redesign: 
     22->  requirements 
     23    ->  widgets can receive int and string data types 
     24->  possibilities 
     25    ->  per-widget merging (i.e. separate tag(s) for each widget's data)? 
     26        ->  if a widget with sub-widgets is defined in a base file, but redesigned in a derived file, any unused widgets with data resolting are not created 
     27        ->  if design changes in a base file, while the old design was modified in a derived file, will the result be sane? 
     28        ->  if a locally modified gui is updated upstream (so the base files change), should: 
     29            ->  the local modifications persist? 
     30            ->  the local modifications be lost? 
     31            ->  the widgets be merged? 
     32                ->  potentially gives the best of both worlds 
     33                ->  should original widgets used as sub-widgets of modified widgets: 
     34                    ->  use original data (from base file), so they can be updated? 
     35                    ->  have data copied, also impacting unmodified portions of window using same widget? 
     36                    ->  have data copied under a new ID? 
     37            ->  the user be asked? 
     38                ->  requires copy of old data... 
     39    +>  widget data per-gui instead of per-window? 
     40        ->  identical sub-widget could be used in multiple windows more easily, when data file is hand edited 
     41        ->  in-gui editor will probably copy data under a new ID anyway 
     42        +>  Maybe change to: 
     43            ->  One section per version, containing widget data 
     44                ->  can inherit from other sections 
     45            ->  Which section (version of gui design) to use saved in header 
     46            ->  Either/or: 
     47                ->  Windows defined in header by primary widget 
     48                +>  Windows become ordinary sub-widgets or some parent widget, gui becomes a parent widget 
     49    +>  widget data no longer has "construction" and "mutable" variations 
     50        +>  widgets know their IDs and update their data whenever necessary, via the gui, into a new data set, which is saved upon exit 
  • mde/font/font.d

    r70 r74  
    5757        } 
    5858         
    59         /** Load the freetype library. */ 
     59        /** Load the freetype library from the file fileName. */ 
     60        private const fileName = "fonts"; 
    6061        void initialize () { 
    6162            if (!confDir.exists (fileName)) 
     
    106107                 
    107108                // get fallback name 
    108                 char[]* p = "fallback" in reader.dataset.header.Arg!(char[]).Arg
     109                char[]* p = "fallback" in reader.dataset.header.Arg!(char[])
    109110                if (p is null) 
    110111                    throw new fontException ("No fallback font style specified"); 
     
    124125            fallback.load; 
    125126        } 
    126         private const fileName = "fonts"; 
    127127         
    128128        //FIXME: don't use GC for FontStyle resources 
  • mde/gui/Gui.d

    r65 r74  
    7777         
    7878        // Get the renderer 
    79         char[]* p = RENDERER in reader.dataset.header.Arg!(char[]).Arg
     79        char[]* p = "Renderer" in reader.dataset.header.Arg!(char[])
    8080        if (p is null || *p is null) { 
    8181            logger.warn ("no renderer specified: defaulting to Simple"); 
     
    111111        // Add header: 
    112112        ds.header = new mt.DefaultData; 
    113         ds.header.Arg!(char[]).Arg[RENDERER] = rendName; 
     113        ds.header.Arg!(char[])["Renderer"] = rendName; 
    114114         
    115115        // Add windows to be saved: 
     
    127127            return; 
    128128        } 
    129     } 
    130     private static const { 
    131         auto RENDERER = "Renderer"; 
    132129    } 
    133130    //END Loading code 
  • mde/gui/widget/Window.d

    r70 r74  
    101101    void addTag (char[] tp, mt.ID id, char[] dt) { 
    102102        // Priority is HIGH_LOW, so don't overwrite data which has already been loaded. 
    103         if (tp == INTAINT) { 
    104             if (id == WDGD && widgetData == null) { 
     103        if (tp == "int[][int]") { 
     104            if (id == "widgetData" && widgetData == null) { 
    105105                widgetData = cast(int[][widgetID]) parseTo!(int[][int]) (dt); 
    106106            } 
    107         } else if (tp == CHARAINT) { 
    108             if (id == WS && widgetStrings == null) { 
     107        } else if (tp == "char[][int]") { 
     108            if (id == "widgetStrings" && widgetStrings == null) { 
    109109                widgetStrings = parseTo!(char[][int]) (dt); 
    110110            } 
    111         } else if (tp == INTA) { 
    112             if (id == MD && mutableData == null) { 
     111        } else if (tp == "int[]") { 
     112            if (id == "mutableData" && mutableData == null) { 
    113113                mutableData = parseTo!(int[]) (dt); 
    114114            } 
    115         } else if (tp == INT) { 
    116             if (id == X && x == -1) { 
     115        } else if (tp == "int") { 
     116            if (id == "x" && x == -1) { 
    117117                x = cast(wdim) parseTo!(int) (dt); 
    118             } else if (id == Y && y == -1) { 
     118            } else if (id == "y" && y == -1) { 
    119119                y = cast(wdim) parseTo!(int) (dt); 
    120120            } 
     
    128128        if (edited) {   // only save the widget creation data if it's been adjusted: 
    129129            addCreationData (widget);   // generate widget save data 
    130             dlg (INTAINT, WDGD, parseFrom!(int[][int]) (widgetData)); 
    131             dlg (CHARAINT, WS, parseFrom!(char[][int]) (widgetStrings)); 
     130            dlg ("int[][int]", "widgetData", parseFrom!(int[][int]) (widgetData)); 
     131            dlg ("char[][int]", "widgetStrings", parseFrom!(char[][int]) (widgetStrings)); 
    132132        }+/ 
    133133        // Save mutable data: 
    134         dlg (INTA, MD, parseFrom!(int[]) (widget.getMutableData)); 
     134        dlg ("int[]", "mutableData", parseFrom!(int[]) (widget.getMutableData)); 
    135135        // Save the window position: 
    136         dlg (INT, X, parseFrom!(int) (x)); 
    137         dlg (INT, Y, parseFrom!(int) (y)); 
    138     } 
    139     private static const { 
    140         auto CHARAINT = "char[][int]"; 
    141         auto INTAINT = "int[][int]"; 
    142         auto INTA = "int[]"; 
    143         auto INT = "int"; 
    144         auto WDGD = "widgetData"; 
    145         auto MD = "mutableData"; 
    146         auto WS = "widgetStrings"; 
    147         auto X = "x"; 
    148         auto Y = "y"; 
     136        dlg ("int", "x", parseFrom!(int) (x)); 
     137        dlg ("int", "y", parseFrom!(int) (y)); 
    149138    } 
    150139    //END Mergetag code 
  • mde/input/Config.d

    r70 r74  
    142142            delegate MT.IDataSection (MT.ID) {  return new Config;  }; 
    143143             
    144             // D2.0: enum MT.ID CONFIGS = "Configs"; 
    145             const MT.ID CONFIGS = cast(MT.ID)"Configs"; 
    146144            // Restrict config sections if this tag exists: 
    147             auto file_configs_p = CONFIGS in file.dataset.header._charAA; 
     145            auto file_configs_p = cast(MT.ID)"Configs" in file.dataset.header._charAA; 
    148146            MT.ID[] file_configs = null; 
    149147            if (file_configs_p) { 
     
    179177    } 
    180178     
    181     // D2.0: private enum QUEUE : MT.ID { BUTTON = "B", AXIS = "A", MOUSE = "M" } 
    182     private struct QUEUE { 
    183         static const MT.ID BUTTON = cast(MT.ID)"B", AXIS = cast(MT.ID)"A", MOUSE = cast(MT.ID)"M"; 
    184     } 
    185179    private this() {}   // Private since this class should only be created from here. 
    186180     
    187181    void addTag (char[] tp, MT.ID id, char[] dt) { 
    188182        if (tp == "uint[][uint]") { 
    189             if (id == QUEUE.BUTTON) button = cast(outQueue[][uint]) parseTo!(uint[][][uint]) (dt); 
    190             else if (id == QUEUE.AXIS) axis = cast(outQueue[][uint]) parseTo!(uint[][][uint]) (dt); 
    191             else if (id == QUEUE.MOUSE) relMotion = cast(outQueue[][uint]) parseTo!(uint[][][uint]) (dt); 
     183                if (id == "B") button    = cast(outQueue[][uint]) parseTo!(uint[][][uint]) (dt); 
     184            else if (id == "A") axis      = cast(outQueue[][uint]) parseTo!(uint[][][uint]) (dt); 
     185            else if (id == "M") relMotion = cast(outQueue[][uint]) parseTo!(uint[][][uint]) (dt); 
    192186            else logger.warn ("Unexpected tag encountered with ID " ~ cast(char[])id); 
    193187        } // FIXME: add support for name and inheritants. 
  • mde/lookup/Translation.d

    r70 r74  
    3838module mde.lookup.Translation; 
    3939 
    40 import mde.options; 
    41 import mde.resource.paths; 
     40import mde.lookup.Options; 
     41import mde.setup.paths; 
    4242import mde.exception; 
    4343 
     
    6060    final char[] L10n;      /// The localization loaded (e.g. en-GB) 
    6161     
    62     /** Get the translation for the given identifier, and optionally the description. 
    63     * If no entry exists, the identifier will be returned. */ 
    64     char[] getEntry (char[] id, out char[] description) { 
     62    alias entry opCall;     /// Convenience alias 
     63     
     64    /** Get the translation for the given identifier. 
     65    * If no entry exists, the identifier will be returned. 
     66    * 
     67    * Optionally, the description can be returned. */ 
     68    char[] entry (char[] id) { 
    6569        Entry* p = id in entries; 
    66         if (p) {    // FIXME: check: a SEGFAULT? 
     70        if (p) { 
     71            return p.str; 
     72        } else { 
     73            return id; 
     74        } 
     75    } 
     76    /** ditto */ 
     77    char[] entry (char[] id, out char[] description) { 
     78        Entry* p = id in entries; 
     79        if (p) { 
    6780            description = p.desc; 
    6881            return p.str; 
    69         } else 
     82        } else { 
    7083            return id; 
    71     } 
    72         /** ditto */ 
    73     char[] getEntry (char[] id) { 
     84        } 
     85    } 
     86     
     87    /** Alternative usage: return a Translation.Entry struct. */ 
     88    Entry getStruct (char[] id) { 
    7489        Entry* p = id in entries; 
    75         if (p !is null) {    // FIXME: check: a SEGFAULT? 
    76             return p.str; 
    77         } else 
    78             return id; 
     90        if (p) { 
     91            return *p; 
     92        } else { 
     93            Entry ret; 
     94            ret.str  = id; 
     95            return ret; 
     96        } 
    7997    } 
    8098     
     
    175193    void writeAll (ItemDelg) {} 
    176194     
     195    /** This struct is used to store each translation entry. 
     196     * 
     197     * Note that although each entry also has a version field, this is not loaded for general use. 
     198     */ 
     199    struct Entry { 
     200        char[] str;         // The translated string 
     201        char[] desc;        // An optional description 
     202    } 
     203     
    177204private: 
    178205    /* Sets name and L10n. 
     
    186213    //BEGIN Data 
    187214    static Logger logger; 
    188      
    189     /* This struct is used to store each translation entry. 
    190     * 
    191     * Note that although each entry also has a version field, this is not loaded for general use. 
    192     */ 
    193     struct Entry { 
    194         char[] str;         // The translated string 
    195         char[] desc;        // An optional description 
    196     } 
    197215     
    198216    Entry[char[]] entries;  // all entries 
     
    222240         
    223241        // Simple get-string, check dependancy's entry doesn't override 
    224         assert (transl.getEntry ("Str1") == "Test 1"); 
     242        assert (transl.entry ("Str1") == "Test 1"); 
    225243         
    226244        // Entry included from dependancy with description 
    227245        char[] desc; 
    228         assert (transl.getEntry ("Str2", desc) == "Test 3"); 
     246        assert (transl.entry ("Str2", desc) == "Test 3"); 
    229247        assert (desc == "Description"); 
    230248         
    231249        // No entry: fallback to identifier string 
    232         assert (transl.getEntry ("Str3") == "Str3"); 
     250        assert (transl.entry ("Str3") == "Str3"); 
    233251         
    234252        // No checks for version info since it's not functionality of this module. 
  • mde/mergetag/DefaultData.d

    r70 r74  
    168168    * Error: identifier '_boolAA' is not defined 
    169169    */ 
    170     template Arg(T : T[]) { 
    171         const ArgString = Arg!(T).ArgString ~ `A`; 
    172         mixin(`alias `~ArgString~` Arg;`); 
     170    template ArgName (T : T[]) { 
     171        const char[] ArgName = ArgName!(T)~`A`; 
     172    } 
     173    template ArgName (T) { 
     174        const char[] ArgName = `_`~T.stringof; 
    173175    } 
    174176    template Arg(T) { 
    175         const ArgString = `_` ~ T.stringof; 
    176         mixin(`alias `~ArgString~` Arg;`); 
     177        mixin(`alias `~ArgName!(T)~` Arg;`); 
    177178    } 
    178179}