summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/ChangeAvatarDialog.java
blob: 9843b44fbc6dea991aff61c2e919f08ac63d8968 (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
package NET.worlds.scape;

import NET.worlds.console.Console;
import NET.worlds.console.DialogReceiver;
import NET.worlds.console.ImageButtons;
import NET.worlds.console.ImageButtonsCallback;
import NET.worlds.console.PolledDialog;
import NET.worlds.core.IniFile;
import java.awt.Component;
import java.awt.Rectangle;
import java.awt.Window;
import java.text.MessageFormat;

public class ChangeAvatarDialog extends PolledDialog implements ImageButtonsCallback {
   private ImageButtons ib;

   public ChangeAvatarDialog(Window parent, DialogReceiver receiver, String name) {
      super(parent, receiver, Console.message("Change-Avatar"), false);
      this.setAlignment(1);
      Rectangle[] rects = new Rectangle[2];
      int yesX = IniFile.override().getIniInt("changeavYesX", 39);
      int yesY = IniFile.override().getIniInt("changeavYesY", 23);
      int yesW = IniFile.override().getIniInt("changeavYesW", 48);
      int yesH = IniFile.override().getIniInt("changeavYesH", 18);
      rects[0] = new Rectangle(yesX, yesY, yesW, yesH);
      int noX = IniFile.override().getIniInt("changeavNoX", 96);
      int noY = IniFile.override().getIniInt("changeavNoY", 23);
      int noW = IniFile.override().getIniInt("changeavNoW", 42);
      int noH = IniFile.override().getIniInt("changeavnoH", 18);
      rects[1] = new Rectangle(noX, noY, noW, noH);
      Object[] arguments = new Object[]{new String(name)};
      this.ib = new ChangeAvatarImageButtons(
         IniFile.override().getIniString("changeAvDlg", Console.message("changeav.gif")),
         rects,
         this,
         MessageFormat.format(Console.message("Change-avatar-to"), arguments)
      );
      this.ready();
   }

   @Override
   protected void build() {
      this.add("Center", this.ib);
   }

   @Override
   public Object imageButtonsCallback(Component who, int which) {
      this.done(which == 0);
      return null;
   }

   @Override
   public boolean keyDown(java.awt.Event event, int key) {
      if (key == 27) {
         return this.done(false);
      } else {
         return key == 10 ? this.done(true) : super.keyDown(event, key);
      }
   }
}