diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/console/GiftDialog.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/console/GiftDialog.java')
| -rw-r--r-- | NET/worlds/console/GiftDialog.java | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/NET/worlds/console/GiftDialog.java b/NET/worlds/console/GiftDialog.java new file mode 100644 index 0000000..73cfc10 --- /dev/null +++ b/NET/worlds/console/GiftDialog.java @@ -0,0 +1,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); + } +} |