summaryrefslogtreecommitdiff
path: root/NET/worlds/console/WhisperManager.java
blob: 518aa46fa3a9f990a161c66560bfdb46849bfcce (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
/*     */ package NET.worlds.console;
/*     */ 
/*     */ import NET.worlds.network.NetUpdate;
/*     */ import NET.worlds.scape.InventoryManager;
/*     */ import java.awt.Window;
/*     */ import java.util.Enumeration;
/*     */ import java.util.Hashtable;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class WhisperManager
/*     */ {
/*     */   private static WhisperManager manager_;
/*     */   private Hashtable<String, WhisperDialog> dialogs_;
/*     */   private Hashtable<String, TradeDialog> tradeDialogs_;
/*     */   private Window parent;
/*  24 */   private String inventory = "";
/*  25 */   final String tradeServerName = "TRADE";
/*     */   static GiftDialog outstandingGift;
/*     */   
/*     */   private WhisperManager() {
/*  29 */     this.dialogs_ = new Hashtable();
/*  30 */     this.tradeDialogs_ = new Hashtable();
/*     */   }
/*     */   
/*     */   public static WhisperManager whisperManager() {
/*  34 */     if (manager_ == null) {
/*  35 */       manager_ = new WhisperManager();
/*     */     }
/*     */     
/*  38 */     return manager_;
/*     */   }
/*     */   
/*     */   void setParent(Window p) {
/*  42 */     this.parent = p;
/*     */   }
/*     */   
/*     */   public Hashtable<String, WhisperDialog> dialogs() {
/*  46 */     return this.dialogs_;
/*     */   }
/*     */   
/*     */   public Hashtable<String, TradeDialog> tradeDialogs() {
/*  50 */     return this.tradeDialogs_;
/*     */   }
/*     */   
/*     */   private WhisperDialog findWhisperDialog(String to) {
/*  54 */     if (!this.dialogs_.containsKey(to))
/*  55 */       return null;
/*  56 */     return (WhisperDialog)this.dialogs_.get(to);
/*     */   }
/*     */   
/*     */   private TradeDialog findTradeDialog(String to) {
/*  60 */     if (!this.tradeDialogs_.containsKey(to))
/*  61 */       return null;
/*  62 */     return (TradeDialog)this.tradeDialogs_.get(to);
/*     */   }
/*     */   
/*     */   private WhisperDialog start(String to, boolean takeFocus) {
/*  66 */     WhisperDialog wd = findWhisperDialog(to);
/*  67 */     if (wd == null) {
/*  68 */       this.dialogs_.put(to, wd = new WhisperDialog(this.parent, to));
/*     */     }
/*  70 */     if (takeFocus)
/*  71 */       wd.takeFocus();
/*  72 */     wd.ready();
/*  73 */     return wd;
/*     */   }
/*     */   
/*     */   public void remove(String name) {
/*  77 */     this.dialogs_.remove(name);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public void startTo(String to)
/*     */   {
/*  84 */     WhisperDialog wd = start(to, true);
/*     */   }
/*     */   
/*     */   public TradeDialog startToTrade(String to)
/*     */   {
/*  89 */     TradeDialog wd = findTradeDialog(to);
/*  90 */     if (wd == null) {
/*  91 */       this.tradeDialogs_.put(to, wd = new TradeDialog(this.parent, to));
/*     */     }
/*  93 */     wd.takeFocus();
/*  94 */     wd.ready();
/*  95 */     wd.setTrading(true);
/*  96 */     wd.whisperPart.println(Console.message("trade-start"));
/*     */     
/*  98 */     return wd;
/*     */   }
/*     */   
/*     */   public void printFrom(String from, String msg) {
/* 102 */     if (!msg.startsWith("&|+")) {
/* 103 */       WhisperDialog it = findWhisperDialog(from);
/* 104 */       if ((msg.equals("&|+trade>cancel")) && (
/* 105 */         (it == null) || (!it.isActive()) || (!it.isTrading))) {
/* 106 */         return;
/*     */       }
/* 108 */       it = start(from, false);
/* 109 */       it.print(msg);
/* 110 */     } else if ((msg.startsWith("&|+gift>")) && 
/* 111 */       (from.equalsIgnoreCase("TRADE")))
/*     */     {
/* 113 */       maybeQueryGift(msg.substring(8));
/*     */     }
/* 115 */     else if ((msg.startsWith("&|+inv>")) && 
/* 116 */       (from.equalsIgnoreCase("TRADE"))) {
/* 117 */       tradeMsg(msg.substring(7));
/* 118 */     } else if (msg.startsWith("&|+trade>")) {
/* 119 */       TradeDialog it = findTradeDialog(from);
/* 120 */       if ((msg.equals("&|+trade>cancel")) && (
/* 121 */         (it == null) || (!it.isActive()) || (!it.isTrading))) {
/* 122 */         return;
/*     */       }
/* 124 */       it = startToTrade(from);
/* 125 */       it.print(msg);
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public void tradeMsg(String newInv)
/*     */   {
/* 138 */     if (!newInv.equals(this.inventory)) {
/* 139 */       for (Enumeration<TradeDialog> e = this.tradeDialogs_.elements(); e.hasMoreElements();) {
/* 140 */         TradeDialog wd = (TradeDialog)e.nextElement();
/* 141 */         wd.doneDeal();
/*     */       }
/*     */       
/* 144 */       InventoryManager.getInventoryManager().setInventory(newInv);
/*     */     }
/*     */   }
/*     */   
/*     */   public void printTo(String to, String msg)
/*     */   {
/* 150 */     if ((to.equals("world")) || (to.equals("TRADE"))) {
/* 151 */       return;
/*     */     }
/* 153 */     if ((!msg.startsWith("&|+")) || (msg.startsWith("&|+trade>"))) {
/* 154 */       WhisperDialog it = start(to, false);
/* 155 */       it.send(msg);
/*     */     }
/*     */   }
/*     */   
/*     */   public void giftDialogDone() {
/* 160 */     outstandingGift = null;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public static void maybeQueryGift(String inv)
/*     */   {
/* 169 */     if (!NetUpdate.isInternalVersion()) {
/* 170 */       return;
/*     */     }
/* 172 */     Console c = Console.getActive();
/* 173 */     if ((c != null) && (outstandingGift == null) && (!c.isSleeping())) {
/* 174 */       outstandingGift = new GiftDialog(inv, 3000000);
/*     */     }
/*     */   }
/*     */ }


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