summaryrefslogtreecommitdiff
path: root/NET/worlds/console/AvatarDialog.java
blob: c4069ca274912ef4a523926b8c854116d2163a55 (plain) (blame)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/*     */ package NET.worlds.console;
/*     */ 
/*     */ import NET.worlds.scape.EventQueue;
/*     */ import java.awt.Button;
/*     */ import java.awt.Choice;
/*     */ import java.awt.Color;
/*     */ import java.awt.Event;
/*     */ import java.awt.Font;
/*     */ import java.awt.GridBagConstraints;
/*     */ import java.awt.GridBagLayout;
/*     */ import java.awt.GridLayout;
/*     */ import java.awt.Label;
/*     */ import java.awt.Panel;
/*     */ import java.awt.Point;
/*     */ import java.awt.Window;
/*     */ import java.util.Vector;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class AvatarDialog
/*     */   extends PolledDialog
/*     */ {
/*     */   private static final long serialVersionUID = 8661992825430619335L;
/*  42 */   private Button okButton = new Button(Console.message("Close"));
/*     */   private AvatarDialogCallback callback;
/*  44 */   private Vector<Choice> choices = new Vector();
/*  45 */   private Vector<int[]> changes = new Vector();
/*  46 */   private static Font font = new Font(Console.message("MenuFont"), 
/*  47 */     0, 12);
/*  48 */   private static Font bfont = new Font(Console.message("ButtonFont"), 
/*  49 */     0, 12);
/*     */   
/*     */   private int checkChanges;
/*     */   
/*     */ 
/*     */   public AvatarDialog(Window parent, DialogReceiver receiver, String title, AvatarDialogCallback callback)
/*     */   {
/*  56 */     super(parent, receiver, title, false);
/*  57 */     this.callback = callback;
/*     */     
/*  59 */     setResizable(false);
/*  60 */     setAlignment(3);
/*     */     
/*  62 */     ready();
/*     */   }
/*     */   
/*     */   public void setChangeCheck() {
/*  66 */     this.checkChanges = 2;
/*     */   }
/*     */   
/*     */   protected void build()
/*     */   {
/*  71 */     Vector<String> headings = this.callback.getComponents();
/*  72 */     int rows = headings.size();
/*  73 */     Panel top = new Panel(new GridLayout(rows, 2, 2, 2));
/*  74 */     top.setFont(font);
/*  75 */     top.setBackground(Color.black);
/*  76 */     for (int i = 0; i < rows; i++) {
/*  77 */       Label label = new Label((String)headings.elementAt(i), 2);
/*  78 */       label.setForeground(Color.white);
/*  79 */       label.setFont(font);
/*  80 */       top.add(label);
/*  81 */       Choice choice = new Choice();
/*  82 */       choice.setForeground(Color.white);
/*  83 */       choice.setBackground(Color.black);
/*  84 */       choice.setFont(font);
/*  85 */       top.add(choice);
/*  86 */       this.choices.addElement(choice);
/*  87 */       Vector<String> items = this.callback.getChoices(i);
/*  88 */       int count = items.size();
/*  89 */       for (int j = 0; j < count; j++)
/*  90 */         choice.add((String)items.elementAt(j));
/*  91 */       choice.select(this.callback.getCurrentSelection(i));
/*     */     }
/*  93 */     GridBagLayout gbag = new GridBagLayout();
/*  94 */     setLayout(gbag);
/*  95 */     GridBagConstraints c = new GridBagConstraints();
/*  96 */     c.weightx = 1.0D;
/*  97 */     c.weighty = 1.0D;
/*  98 */     c.gridheight = rows;
/*  99 */     c.gridwidth = 0;
/* 100 */     c.fill = 0;
/* 101 */     add(gbag, top, c);
/* 102 */     Panel bottom = new Panel();
/* 103 */     this.okButton.setFont(bfont);
/* 104 */     bottom.add(this.okButton);
/* 105 */     bottom.setBackground(Color.black);
/* 106 */     c.gridheight = 1;
/* 107 */     c.weightx = 0.0D;
/* 108 */     c.weighty = 0.0D;
/* 109 */     c.fill = 1;
/* 110 */     add(gbag, bottom, c);
/* 111 */     this.okButton.setBackground(Color.black);
/* 112 */     this.okButton.setForeground(Color.white);
/*     */   }
/*     */   
/*     */   @Deprecated
/*     */   public boolean handleEvent(Event event)
/*     */   {
/* 118 */     if (EventQueue.redirectDrivingKeys(event)) {
/* 119 */       return true;
/*     */     }
/* 121 */     if (event.id == 201)
/* 122 */       return done(false);
/* 123 */     return super.handleEvent(event);
/*     */   }
/*     */   
/*     */   @Deprecated
/*     */   public boolean action(Event event, Object what)
/*     */   {
/* 129 */     Object target = event.target;
/* 130 */     if (target == this.okButton) {
/* 131 */       return done(true);
/*     */     }
/* 133 */     int count = this.choices.size();
/* 134 */     for (int i = 0; i < count; i++) {
/* 135 */       Choice choice = (Choice)this.choices.elementAt(i);
/* 136 */       if (target == choice) {
/* 137 */         int[] change = new int[2];
/* 138 */         change[0] = i;
/* 139 */         change[1] = choice.getSelectedIndex();
/* 140 */         this.changes.addElement(change);
/* 141 */         return true;
/*     */       }
/*     */     }
/*     */     
/* 145 */     return false;
/*     */   }
/*     */   
/*     */ 
/* 149 */   static Point lastWindowLocation = null;
/*     */   
/*     */   public boolean done(boolean confirmed)
/*     */   {
/* 153 */     lastWindowLocation = getLocation();
/* 154 */     return super.done(confirmed);
/*     */   }
/*     */   
/*     */   public void closeWin() {
/* 158 */     if (lastWindowLocation == null) {
/* 159 */       done(true);
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   protected void initialSize(int width, int height)
/*     */   {
/* 168 */     if (lastWindowLocation == null) {
/* 169 */       super.initialSize(width, height);
/*     */     } else {
/* 171 */       setLocation(lastWindowLocation);
/* 172 */       lastWindowLocation = null;
/* 173 */       setSize(width, height);
/*     */     }
/*     */   }
/*     */   
/*     */   protected void activeCallback()
/*     */   {
/* 179 */     if ((this.checkChanges > 0) && 
/* 180 */       (--this.checkChanges == 0)) {
/* 181 */       for (int i = 0; i < this.choices.size(); i++) {
/* 182 */         ((Choice)this.choices.elementAt(i)).select(this.callback
/* 183 */           .getCurrentSelection(i));
/*     */       }
/*     */     }
/* 186 */     while (this.changes.size() != 0) {
/* 187 */       int[] change = (int[])this.changes.elementAt(0);
/*     */       
/* 189 */       this.callback.setCurrentSelection(change[0], change[1]);
/*     */       
/* 191 */       this.checkChanges = 1;
/*     */       
/* 193 */       this.changes.removeElementAt(0);
/*     */     }
/*     */   }
/*     */   
/*     */   @Deprecated
/*     */   public boolean keyDown(Event event, int key)
/*     */   {
/* 200 */     if (key == 27)
/* 201 */       return done(false);
/* 202 */     return super.keyDown(event, key);
/*     */   }
/*     */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\AvatarDialog.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */