~extremepopcorn/dhlib/dhlib_ep

« back to all changes in this revision

Viewing changes to lib/draw/test/VarsDialog.mhx

  • Committer: edA-qa mort-ora-y
  • Date: 2010-02-16 05:36:32 UTC
  • Revision ID: eda-qa@disemia.com-20100216053632-60lt7fndfi3fgblw
first

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* <license>
 
2
 * This file is part of the dis-Emi-A HaXe Library. Copyright © edA-qa mort-ora-y
 
3
 * For full copyright and license information please refer to doc/license.txt.
 
4
 * </license> 
 
5
 */
 
6
package draw.test;
 
7
 
 
8
import draw.TileDesc;
 
9
 
 
10
class VarsDialog extends ui.Dialog
 
11
{
 
12
        var rows : Hash<VarsDialogRow>;
 
13
        var tileDesc : TileDesc;
 
14
        
 
15
        public function new( td : TileDesc )
 
16
        {
 
17
                tileDesc = td;
 
18
                rows = new Hash<VarsDialogRow>();
 
19
                var names = ArrayUtil.fromIter( td.getTokenNames() );
 
20
                
 
21
                var items = ui.GridLayout.simple( 5, 1 + names.length );
 
22
                items.setItem( 0, 0, ui.StaticText.singleLine( "Variable" ) );
 
23
                items.setColSize( 0, ui.SizeType.XWidth( 10 ) );
 
24
                items.setItem( 1, 0, ui.StaticText.singleLine( "Definition" ) );
 
25
                items.setColSize( 1, ui.SizeType.XWidth( 20 ) );
 
26
                items.setItem( 2, 0, ui.StaticText.singleLine( "Last" ) );
 
27
                items.setColSize( 2, ui.SizeType.XWidth( 20 ) );
 
28
                items.setItem( 3, 0, ui.StaticText.singleLine( "lk" ) );
 
29
                items.setColSize( 3, ui.SizeType.XWidth( 2 ) ); //wide for title only
 
30
                items.setItem( 4, 0, ui.StaticText.singleLine( "sn" ) );
 
31
                items.setColSize( 4, ui.SizeType.XWidth( 2 ) ); //wide for title only
 
32
                
 
33
                items.setRowSize( 0, ui.SizeType.Lines(1.2) );
 
34
                
 
35
                for( i in 0...names.length )
 
36
                {
 
37
                        var vdr = new VarsDialogRow( td, names[i] );
 
38
                        rows.set( names[i], vdr );
 
39
                        items.setRowSize( i+1, ui.SizeType.Lines(1) );
 
40
                        items.setItem( 0, i+1, vdr.title );
 
41
                        items.setItem( 1, i+1, vdr.defn );
 
42
                        items.setItem( 2, i+1, vdr.last );
 
43
                        items.setItem( 3, i+1, vdr.lock );
 
44
                        items.setItem( 4, i+1, vdr.single );
 
45
                }
 
46
                
 
47
                super( "Actor Parameters", items );
 
48
                
 
49
                addCloseAction( "Okay", "xOkay" );
 
50
                addCloseAction( "Cancel", "xCancel" );
 
51
        }
 
52
        
 
53
        public function applyValues()
 
54
        {
 
55
                for( name in tileDesc.getTokenNames() )
 
56
                {
 
57
                        var vdr = rows.get( name );
 
58
                        tileDesc.setTokenLock( name, vdr.lock.getSelected() );
 
59
                        tileDesc.setTokenDef( name, vdr.defn.text );
 
60
                        tileDesc.setTokenLimitSingle( name, vdr.single.getSelected() );
 
61
                }
 
62
        }
 
63
}
 
64
 
 
65
private class VarsDialogRow
 
66
{
 
67
        public var title : ui.StaticText;
 
68
        public var defn : ui.EditText;
 
69
        public var last : ui.StaticText;
 
70
        public var lock : ui.CheckBox;
 
71
        public var single : ui.CheckBox;
 
72
        public function new( td, name )
 
73
        { 
 
74
                var core = td.getTokenCoreType( name );
 
75
                title = ui.StaticText.singleLine( "<" + core + "> " +name );
 
76
                defn = ui.EditText.singleLine( td.getTokenDef( name ) );
 
77
                last = ui.StaticText.singleLine( td.getTokenLast( name ) );
 
78
                lock = ui.CheckBox.plain( "" ); //TODO: Create a nice Lock actor
 
79
                lock.setSelected( td.getTokenLock( name ) );
 
80
                single = ui.CheckBox.plain( "" );
 
81
                single.setSelected( td.getTokenLimitSingle( name ) );
 
82
        }
 
83
}