blob: 73cfc10a7582a835004a9b6da45e07b1c09775a0 (
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
|
package NET.worlds.console;
import NET.worlds.core.Std;
import NET.worlds.scape.InventoryItem;
import NET.worlds.scape.InventoryManager;
import java.text.MessageFormat;
import java.util.Hashtable;
class GiftDialog extends OkCancelDialog {
private static final long serialVersionUID = -5698666260017940591L;
private String inv;
private int autoCloseTime;
public static String calcMsg(String inv, int duration) {
InventoryManager im = InventoryManager.getInventoryManager();
Hashtable<String, InventoryItem> inventory = im.parseInventoryString(inv);
String hr = TradeDialog.buildInvDesc(inventory);
Object[] arguments = new Object[]{new String(hr), new String("" + duration / 1000)};
return MessageFormat.format(Console.message("To-claim-hr"), arguments);
}
public GiftDialog(String _inv, int duration) {
super(Console.getFrame(), null, Console.message("A-Gift"), null, "Accept", calcMsg(_inv, duration), false);
this.autoCloseTime = Std.getFastTime() + duration;
this.inv = _inv;
}
@Override
protected void activeCallback() {
super.activeCallback();
if (Std.getFastTime() > this.autoCloseTime && this.autoCloseTime != 0) {
this.done(false);
}
}
@Override
protected synchronized boolean done(boolean confirmed) {
WhisperManager.whisperManager().giftDialogDone();
if (confirmed) {
TradeDialog.sendTradeMessage("&|+deal>TRADE ," + this.inv);
}
return super.done(confirmed);
}
}
|