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