1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sf.magicproject.ui;
20
21 import java.awt.BorderLayout;
22 import java.awt.Color;
23 import java.awt.Dimension;
24 import java.awt.FlowLayout;
25 import java.awt.Toolkit;
26 import java.awt.event.ActionEvent;
27 import java.awt.event.ActionListener;
28 import java.awt.event.InputEvent;
29 import java.awt.event.KeyEvent;
30 import java.awt.event.MouseListener;
31 import java.awt.event.WindowListener;
32 import java.io.File;
33 import java.util.Locale;
34
35 import javax.swing.BoxLayout;
36 import javax.swing.ButtonGroup;
37 import javax.swing.ImageIcon;
38 import javax.swing.JButton;
39 import javax.swing.JCheckBoxMenuItem;
40 import javax.swing.JDialog;
41 import javax.swing.JFrame;
42 import javax.swing.JLabel;
43 import javax.swing.JMenu;
44 import javax.swing.JMenuBar;
45 import javax.swing.JMenuItem;
46 import javax.swing.JOptionPane;
47 import javax.swing.JPanel;
48 import javax.swing.JRadioButtonMenuItem;
49 import javax.swing.JScrollPane;
50 import javax.swing.JSeparator;
51 import javax.swing.JTabbedPane;
52 import javax.swing.JTextField;
53 import javax.swing.JToggleButton;
54 import javax.swing.KeyStroke;
55 import javax.swing.ScrollPaneConstants;
56 import javax.swing.SwingConstants;
57 import javax.swing.Timer;
58 import javax.swing.ToolTipManager;
59
60 import net.sf.magicproject.AbstractMainForm;
61 import net.sf.magicproject.Magic;
62 import net.sf.magicproject.clickable.action.ChoosenCostPanel;
63 import net.sf.magicproject.clickable.mana.Mana;
64 import net.sf.magicproject.clickable.targetable.TargetableFactory;
65 import net.sf.magicproject.clickable.targetable.card.CardFactory;
66 import net.sf.magicproject.clickable.targetable.player.Player;
67 import net.sf.magicproject.network.MChat;
68 import net.sf.magicproject.stack.EventManager;
69 import net.sf.magicproject.token.IdConst;
70 import net.sf.magicproject.tools.Configuration;
71 import net.sf.magicproject.tools.MToolKit;
72 import net.sf.magicproject.tools.Picture;
73 import net.sf.magicproject.tools.TimerTarget;
74 import net.sf.magicproject.tools.WebBrowser;
75 import net.sf.magicproject.ui.component.CardPropertiesPanel;
76 import net.sf.magicproject.ui.component.ChatArea;
77 import net.sf.magicproject.ui.component.EditorPane;
78 import net.sf.magicproject.ui.component.LogArea;
79 import net.sf.magicproject.ui.component.MessageButton;
80 import net.sf.magicproject.ui.component.SplashScreen;
81 import net.sf.magicproject.ui.component.TableTop;
82 import net.sf.magicproject.ui.i18n.Language;
83 import net.sf.magicproject.ui.i18n.LanguageManager;
84 import net.sf.magicproject.ui.layout.BorderLayout2;
85 import net.sf.magicproject.zone.PopupManager;
86 import net.sf.magicproject.zone.ZoneManager;
87
88 /***
89 * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
90 * @since 0.54.17
91 */
92 public abstract class MagicUIComponents extends AbstractMainForm implements
93 MUIManager, ActionListener, MouseListener, WindowListener {
94
95 /***
96 * The timer panel.
97 */
98 public static TimerGlassPane timerPanel;
99
100 /***
101 * The timer target of Magic-Project
102 */
103 public static TimerTarget targetTimer;
104
105 /***
106 * The timer of Magic-Project
107 */
108 public static Timer timer;
109
110 /***
111 *
112 */
113 public MagicUIComponents() {
114 super("Magic-Project");
115 magicForm = (Magic) this;
116
117
118 Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
119 getRootPane().setPreferredSize(
120 new Dimension(screenDim.width - 100, screenDim.height - 100));
121 getRootPane().setMinimumSize(getRootPane().getPreferredSize());
122 setUndecorated(frameDecorated);
123 addWindowListener(this);
124 targetTimer = new TimerTarget();
125 timer = new Timer(1000, targetTimer);
126 timerPanel = new TimerGlassPane();
127 timerPanel.setVisible(false);
128 setGlassPane(timerPanel);
129 }
130
131 /***
132 * This method is called from within the constructor to initialize the form.
133 * WARNING: Do NOT modify this code. The content of this method is always
134 * regenerated by the Form Editor.
135 */
136 protected void initComponents() {
137 try {
138 setIconImage(Picture.loadImage(IdConst.IMAGES_DIR + "mp.gif"));
139 } catch (Exception e) {
140
141 }
142 MToolKit.tbsName = Configuration.getString("lastTBS", IdConst.TBS_DEFAULT);
143 moreThemeMenu = new JMenuItem(LanguageManager.getString("morethemes"));
144
145
146 waitingLabel = new JLabel();
147 waitingLabel.setHorizontalAlignment(SwingConstants.RIGHT);
148
149 final JPanel infoPanel = new JPanel();
150 infoPanel.setLayout(new BoxLayout(infoPanel, BoxLayout.X_AXIS));
151 infoPanel.setMaximumSize(new Dimension(2200, 20));
152 EventManager.turnsLbl = new JLabel();
153 EventManager.turnsLbl.setHorizontalTextPosition(SwingConstants.LEFT);
154 EventManager.turnsLbl.setMaximumSize(new Dimension(70, 16));
155 EventManager.turnsLbl.setPreferredSize(new Dimension(70, 16));
156 infoPanel.add(EventManager.turnsLbl);
157
158 backgroundBtn = new MessageButton(UIHelper.getIcon("smlquestion1.gif"),
159 UIHelper.getIcon("smlquestion2.gif"));
160 backgroundBtn.setVisible(false);
161
162 EventManager.moreInfoLbl = new JLabel();
163 EventManager.moreInfoLbl.setHorizontalTextPosition(SwingConstants.RIGHT);
164 EventManager.moreInfoLbl.setMaximumSize(new Dimension(2200, 16));
165 EventManager.moreInfoLbl.setForeground(Color.BLUE);
166 infoPanel.add(EventManager.moreInfoLbl);
167
168 playerTabbedPanel = new JTabbedPane(SwingConstants.BOTTOM,
169 JTabbedPane.SCROLL_TAB_LAYOUT);
170
171
172 JTabbedPane previewTabbedPanel = null;
173 previewPanel = new JPanel(new FlowLayout(0, 0, 0));
174 previewPanel.setBackground(Color.black);
175 choosenCostPanel = new ChoosenCostPanel();
176 databasePanel = new CardPropertiesPanel();
177 if (speparateAvatar) {
178 previewTabbedPanel = new JTabbedPane(SwingConstants.BOTTOM,
179 JTabbedPane.SCROLL_TAB_LAYOUT);
180 previewTabbedPanel.add(previewPanel, UIHelper.getIcon("zoom.gif"));
181 previewTabbedPanel.add(choosenCostPanel, UIHelper
182 .getIcon("choosenaction.gif"));
183 previewTabbedPanel.add(databasePanel, UIHelper
184 .getIcon("databasecard.gif"));
185 previewTabbedPanel.setToolTipTextAt(previewTabbedPanel
186 .indexOfComponent(previewPanel), "<html>"
187 + LanguageManager.getString("zoom.tooltip"));
188 previewTabbedPanel.setToolTipTextAt(previewTabbedPanel
189 .indexOfComponent(choosenCostPanel), "<html>"
190 + LanguageManager.getString("choosen.tooltip"));
191 previewTabbedPanel.setToolTipTextAt(previewTabbedPanel
192 .indexOfComponent(databasePanel), "<html>"
193 + LanguageManager.getString("database.tooltip"));
194 } else {
195 playerTabbedPanel.add(previewPanel, UIHelper.getIcon("zoom.gif"));
196 playerTabbedPanel.add(choosenCostPanel, UIHelper
197 .getIcon("choosenaction.gif"));
198 playerTabbedPanel.setToolTipTextAt(playerTabbedPanel
199 .indexOfComponent(previewPanel), "<html>"
200 + LanguageManager.getString("zoom.tooltip"));
201 playerTabbedPanel.setToolTipTextAt(playerTabbedPanel
202 .indexOfComponent(choosenCostPanel), "<html>"
203 + LanguageManager.getString("choosen.tooltip"));
204 playerTabbedPanel
205 .add(databasePanel, UIHelper.getIcon("databasecard.gif"));
206 playerTabbedPanel.setToolTipTextAt(playerTabbedPanel
207 .indexOfComponent(databasePanel), "<html>"
208 + LanguageManager.getString("database.tooltip"));
209 }
210
211
212 chatPanel = new JPanel(new BorderLayout());
213
214
215 final JPanel chatOptions = new JPanel();
216 chatHistoryText = new ChatArea(new FlowLayout(FlowLayout.LEFT, 2, 0));
217 final JButton clearChatButton = new JButton(UIHelper.getIcon("clear.gif"));
218 clearChatButton.setActionCommand("clear");
219 clearChatButton.addActionListener(chatHistoryText);
220 clearChatButton.setPreferredSize(new Dimension(18, 18));
221 clearChatButton.setFocusPainted(false);
222 chatOptions.add(clearChatButton);
223 final JToggleButton chatTimeButton = new JToggleButton(UIHelper
224 .getIcon("time.gif"), Configuration.getBoolean("chatdisptime", false));
225 chatTimeButton.setActionCommand("disptime");
226 chatTimeButton.addActionListener(chatHistoryText);
227 chatTimeButton.setPreferredSize(new Dimension(18, 18));
228 chatTimeButton.setFocusPainted(false);
229 chatOptions.add(chatTimeButton);
230 final JToggleButton chatLockButton = new JToggleButton(UIHelper
231 .getIcon("lock.gif"), Configuration.getBoolean("chatlocked", false));
232 chatLockButton.setActionCommand("lock");
233 chatLockButton.addActionListener(chatHistoryText);
234 chatLockButton.setFocusPainted(false);
235 chatLockButton.setPreferredSize(new Dimension(18, 18));
236 chatOptions.add(chatLockButton);
237 chatOptions.setMaximumSize(new Dimension(2000, 18));
238 chatOptions.add(chatLockButton);
239 chatPanel.add(chatOptions, BorderLayout.NORTH);
240
241
242 final JScrollPane chatSPanel = new JScrollPane();
243 chatHistoryText.setLocked(chatLockButton.isSelected());
244 chatHistoryText.setDispTime(chatTimeButton.isSelected());
245 chatSPanel
246 .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
247 chatSPanel
248 .setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
249 chatSPanel.setAutoscrolls(true);
250 MToolKit.addOverlay(chatSPanel);
251 chatSPanel.setViewportView(chatHistoryText);
252 chatPanel.add(chatSPanel, BorderLayout.CENTER);
253
254
255 sendTxt = new JTextField();
256 final JPanel messagePanel = new JPanel(new BorderLayout());
257 messagePanel.setMaximumSize(new Dimension(200, 18));
258 messagePanel.add(sendTxt, BorderLayout.CENTER);
259 sendButton = new JButton(UIHelper.getIcon("ok.gif"));
260 sendButton.setBorderPainted(false);
261 sendButton.setFocusPainted(false);
262 sendButton.setPreferredSize(new Dimension(18, 18));
263 sendButton.addActionListener(this);
264 messagePanel.add(sendButton, BorderLayout.EAST);
265 chatPanel.add(messagePanel, BorderLayout.SOUTH);
266
267 playerTabbedPanel.add(chatPanel, UIHelper.getIcon("chat-old.gif"));
268 playerTabbedPanel.setToolTipTextAt(playerTabbedPanel
269 .indexOfComponent(chatPanel), "<html>"
270 + LanguageManager.getString("chat.tooltip"));
271
272
273 final JPanel logPanel = new JPanel(new BorderLayout());
274
275
276 final JPanel logOptions = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 0));
277 logListing = new LogArea();
278 final JButton clearButton = new JButton(UIHelper.getIcon("clear.gif"));
279 clearButton.setActionCommand("clear");
280 clearButton.addActionListener(logListing);
281 clearButton.setPreferredSize(new Dimension(18, 18));
282 clearButton.setFocusPainted(false);
283 logOptions.add(clearButton);
284 final JToggleButton timeButton = new JToggleButton(UIHelper
285 .getIcon("time.gif"), Configuration.getBoolean("logdisptime", false));
286 timeButton.setActionCommand("disptime");
287 timeButton.addActionListener(logListing);
288 timeButton.setPreferredSize(new Dimension(18, 18));
289 timeButton.setFocusPainted(false);
290 logOptions.add(timeButton);
291 final JToggleButton lockButton = new JToggleButton(UIHelper
292 .getIcon("lock.gif"), Configuration.getBoolean("loglocked", false));
293 lockButton.setActionCommand("lock");
294 lockButton.addActionListener(logListing);
295 lockButton.setPreferredSize(new Dimension(18, 18));
296 lockButton.setFocusPainted(false);
297 logOptions.add(lockButton);
298 logPanel.add(logOptions, BorderLayout.NORTH);
299
300
301 final JScrollPane logSPanel = new JScrollPane(
302 ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
303 ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
304 logListing.setLocked(lockButton.isSelected());
305 logListing.setDispTime(timeButton.isSelected());
306
307 logOptions.setMaximumSize(new Dimension(2000, 18));
308 logSPanel.setAutoscrolls(true);
309 MToolKit.addOverlay(logSPanel);
310 logSPanel.setViewportView(logListing);
311 logPanel.add(logSPanel);
312
313 playerTabbedPanel.add(logPanel, UIHelper.getIcon("menu_tools_log.gif"));
314 playerTabbedPanel.setToolTipTextAt(playerTabbedPanel
315 .indexOfComponent(logPanel), "<html>"
316 + LanguageManager.getString("log.tooltip"));
317
318
319 JMenuBar magicMenu = new JMenuBar();
320 JMenu gameMenu = UIHelper.buildMenu("menu_game", 'g');
321 JMenu newGameMenu = UIHelper.buildMenu("menu_game_new", 'n');
322
323
324 JMenuItem joinMenu = UIHelper.buildMenu("menu_game_new_client", 'j', this);
325 joinMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0));
326 newGameMenu.add(joinMenu);
327
328
329 JMenuItem createMenu = UIHelper
330 .buildMenu("menu_game_new_server", 'c', this);
331 createMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F2,
332 InputEvent.SHIFT_MASK));
333 newGameMenu.add(createMenu);
334
335 gameMenu.add(newGameMenu);
336
337
338 skipButton = UIHelper.buildButton("menu_game_skip", this);
339 skipButton.setPreferredSize(new Dimension(Player.PLAYER_SIZE_HEIGHT,
340 Player.PLAYER_SIZE_HEIGHT));
341
342
343 skipMenu = UIHelper.buildMenu("menu_game_skip", 's', this);
344 skipMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0));
345 gameMenu.add(skipMenu);
346
347 gameMenu.add(UIHelper.buildMenu("menu_game_proposedraw", this));
348 gameMenu.add(UIHelper.buildMenu("menu_game_disconnect", this));
349 gameMenu.add(UIHelper.buildMenu("menu_game_proxy", this));
350 gameMenu.add(new JSeparator());
351
352
353 final JMenuItem exitMenu = UIHelper.buildMenu("menu_game_exit", 'q', this);
354 exitMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4,
355 InputEvent.ALT_MASK));
356 gameMenu.add(exitMenu);
357 magicMenu.add(gameMenu);
358
359 optionMenu = UIHelper.buildMenu("menu_options", 'o');
360 final JMenu lookNFeelMenu = UIHelper.buildMenu("menu_lf");
361
362
363 reverseArtCheck = new JCheckBoxMenuItem(LanguageManager
364 .getString("reverseart"),
365 Configuration.getBoolean("reverseArt", true) ? UIHelper
366 .getIcon("reverse.gif") : UIHelper.getIcon("reverseoff.gif"),
367 Configuration.getBoolean("reverseArt", true));
368 reverseArtCheck.setToolTipText("<html>"
369 + LanguageManager.getString("reverseart.tooltip"));
370 reverseSideCheck = new JCheckBoxMenuItem(LanguageManager
371 .getString("reverseside"), Configuration.getBoolean("reverseSide",
372 false) ? UIHelper.getIcon("reverseside.gif") : UIHelper
373 .getIcon("reversesideoff.gif"), Configuration.getBoolean("reverseSide",
374 false));
375 reverseSideCheck.setToolTipText("<html>"
376 + LanguageManager.getString("reverseside.tooltip"));
377 reverseArtCheck.addActionListener(this);
378 reverseSideCheck.addActionListener(this);
379 lookNFeelMenu.add(reverseArtCheck);
380 lookNFeelMenu.add(reverseSideCheck);
381
382
383 final String[] colors = { "black", "white", "gold", "auto" };
384 final String currentColor = Configuration.getString("border-color",
385 colors[3]);
386 cardBorderMenu = new JMenu(LanguageManager.getString("border-color"));
387 final ButtonGroup group4 = new ButtonGroup();
388 boolean found = false;
389 for (int i = 0; i < colors.length; i++) {
390 String codeColor = "border-" + colors[i];
391 JRadioButtonMenuItem colorItem = new JRadioButtonMenuItem(LanguageManager
392 .getString(codeColor), UIHelper.getIcon(codeColor + ".gif"));
393 colorItem.setActionCommand(codeColor);
394 colorItem.addActionListener(this);
395 if (!found && currentColor.equals(colors[i])) {
396 colorItem.setSelected(true);
397 found = true;
398 }
399 group4.add(colorItem);
400 cardBorderMenu.add(colorItem);
401 }
402 if (!found) {
403 ((JRadioButtonMenuItem) cardBorderMenu.getComponent(0)).setSelected(true);
404 }
405 lookNFeelMenu.add(cardBorderMenu);
406
407
408 lookNFeelMenu.add(UIHelper.buildMenu("menu_lf_powerToughnessColor", this));
409
410
411 final JCheckBoxMenuItem randomAngleMenu = new JCheckBoxMenuItem(
412 LanguageManager.getString("menu_lf_randomAngle"), UIHelper
413 .getIcon("menu_lf_randomAngle.gif"), Configuration.getBoolean(
414 "randomAngle", false));
415 randomAngleMenu.addActionListener(this);
416 lookNFeelMenu.add(randomAngleMenu);
417
418
419 soundMenu = new JCheckBoxMenuItem(LanguageManager.getString("enablesound"),
420 Configuration.getBoolean("sound", false) ? UIHelper
421 .getIcon("sound.gif") : UIHelper.getIcon("soundoff.gif"),
422 Configuration.getBoolean("sound", false));
423 soundMenu.addActionListener(this);
424 lookNFeelMenu.add(soundMenu);
425
426
427
428 final ToolTipManager toolTipManager = ToolTipManager.sharedInstance();
429 final int delay = Configuration.getInt("initialdelay", 800);
430 final int dismissDelay = Configuration.getInt("dismissdelay", 10000);
431 if (delay == 0) {
432 toolTipManager.setEnabled(false);
433 } else {
434 toolTipManager.setInitialDelay(delay);
435 }
436 toolTipManager.setDismissDelay(dismissDelay);
437 initialdelayMenu = new JMenuItem(LanguageManager.getString("initialdelay")
438 + " : " + delay + " ms", UIHelper.getIcon("initialdelay.gif"));
439 dismissdelayMenu = new JMenuItem(LanguageManager.getString("dismissdelay")
440 + " : " + dismissDelay + " ms", UIHelper.getIcon("initialdelay.gif"));
441
442 lookNFeelMenu.add(initialdelayMenu);
443 lookNFeelMenu.add(dismissdelayMenu);
444
445
446 themeMenu = new JMenu(LanguageManager.getString("theme"));
447 themeMenu.setIcon(UIHelper.getIcon("theme.gif"));
448 themeMenu.add(new JSeparator());
449 themeMenu.add(moreThemeMenu);
450 lookNFeelMenu.add(themeMenu);
451
452
453 languageMenu = new JMenu(LanguageManager.getString("menu_lf_language"));
454
455
456 final ButtonGroup group5 = new ButtonGroup();
457 JRadioButtonMenuItem autoChck = null;
458 for (Language language : LanguageManager.languages) {
459 File flagFile = MToolKit.getFile(IdConst.FLAGS_DIR + language.getKey()
460 + IdConst.TYPE_PIC);
461 boolean isDefault = language.getKey().equalsIgnoreCase(
462 LanguageManager.getLanguage().getKey());
463 JRadioButtonMenuItem itemChck = null;
464 if (flagFile == null) {
465 itemChck = new JRadioButtonMenuItem(language.getName(), isDefault);
466 } else {
467 itemChck = new JRadioButtonMenuItem(language.getName(), new ImageIcon(
468 flagFile.getAbsolutePath()), isDefault);
469
470 }
471 itemChck.addActionListener(langListener);
472 itemChck.setActionCommand(language.getKey());
473 if ("auto".equals(language.getKey())) {
474
475 itemChck.setToolTipText("<html><b>"
476 + LanguageManager.getString("menu_lf_language.auto.tooltip", Locale
477 .getDefault().getLanguage()));
478 autoChck = itemChck;
479 } else {
480 itemChck.setToolTipText("<html><b>"
481 + LanguageManager.getString("author") + "</b> : "
482 + language.getAuthor() + "<br><b>"
483 + LanguageManager.getString("contact") + "</b> : "
484 + language.getMoreInfo() + "<br><b>"
485 + LanguageManager.getString("version") + "</b> : "
486 + language.getVersion());
487 languageMenu.add(itemChck);
488 }
489 group5.add(itemChck);
490 }
491 languageMenu.add(autoChck);
492 languageMenu.add(new JSeparator());
493
494
495 languageMenu.add(UIHelper.buildMenu("menu_lf_language.more", langListener));
496 lookNFeelMenu.add(languageMenu);
497 magicMenu.add(lookNFeelMenu);
498
499
500 autoManaMenu = new JCheckBoxMenuItem(LanguageManager.getString("automana"),
501 UIHelper.getIcon("automana.gif"));
502 autoManaMenu.setMnemonic('m');
503 autoManaMenu.setToolTipText("<html>"
504 + LanguageManager.getString("automana.tooltip"));
505 autoManaMenu.addActionListener(this);
506 optionMenu.add(autoManaMenu);
507
508
509 autoPlayMenu = new JCheckBoxMenuItem(LanguageManager
510 .getString("autoaction"), UIHelper.getIcon("fast.gif"));
511 autoPlayMenu.setMnemonic('p');
512 autoPlayMenu.setSelected(true);
513 autoPlayMenu.setToolTipText("<html>"
514 + LanguageManager.getString("autoaction.tooltip") + "<br><br>"
515 + MagicUIComponents.HTML_ICON_TIP
516 + LanguageManager.getString("yourtbzTTtip2"));
517 autoPlayMenu.addActionListener(this);
518 optionMenu.add(autoPlayMenu);
519
520 JMenuItem settingsItem = UIHelper.buildMenu("menu_options_settings", this);
521 settingsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0));
522 optionMenu.add(settingsItem);
523
524 initAbstractMenu();
525 magicMenu.add(optionMenu);
526
527
528 final JMenu toolMenu = UIHelper.buildMenu("tools", 't');
529 toolMenu.add(UIHelper.buildMenu("menu_tools_log", this));
530 toolMenu.add(UIHelper.buildMenu("menu_tools_bugreport", this));
531 toolMenu.add(UIHelper.buildMenu("menu_tools_featurerequest", this));
532 toolMenu.add(new JSeparator());
533 toolMenu.add(UIHelper.buildMenu("menu_tools_jdb", 'd', this));
534 JMenuItem cardBuilderMenu = UIHelper.buildMenu("menu_tools_jcb", 'c', this);
535 cardBuilderMenu.setEnabled(false);
536 toolMenu.add(cardBuilderMenu);
537 magicMenu.add(toolMenu);
538
539
540 JMenu questionMenu = UIHelper.buildMenu("menu_help", 'h');
541 JMenuItem helpMenu = UIHelper.buildMenu("menu_help_help", 'h', this);
542 helpMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
543 questionMenu.add(helpMenu);
544
545
546 JMenuItem aboutMenu = UIHelper.buildMenu("menu_help_about", 'a', this);
547 aboutMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1,
548 InputEvent.SHIFT_MASK));
549 questionMenu.add(aboutMenu);
550
551
552 JMenuItem aboutMdbMenu = UIHelper.buildMenu("menu_help_about.tbs", 'm',
553 null, this);
554 aboutMdbMenu.setIcon(aboutMenu.getIcon());
555 aboutMdbMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1,
556 InputEvent.ALT_MASK));
557 questionMenu.add(aboutMdbMenu);
558 questionMenu.add(new JSeparator());
559
560
561 final JMenuItem checkUpdateMenu = UIHelper.buildMenu(
562 "menu_help_check-update", 'u', this);
563 checkUpdateMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F10,
564 InputEvent.SHIFT_MASK));
565 questionMenu.add(checkUpdateMenu);
566 questionMenu.add(UIHelper.buildMenu("menu_help_mailing", 'l', this));
567 magicMenu.add(questionMenu);
568
569
570 final JMenu disabledMenu = new JMenu();
571 disabledMenu.setEnabled(false);
572 disabledMenu.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
573 magicMenu.add(disabledMenu);
574
575
576 final JMenu menu = new JMenu(LanguageManager.getString("version")
577 + IdConst.VERSION);
578 menu.setEnabled(false);
579
580 magicMenu.add(menu);
581 setJMenuBar(magicMenu);
582
583
584 EventManager.init();
585 TargetableFactory.initSettings();
586 CardFactory.initSettings();
587 PopupManager.init();
588
589
590 getContentPane().setLayout(new BorderLayout2());
591 getContentPane().add(infoPanel, BorderLayout.SOUTH);
592 TableTop.init(playerTabbedPanel, previewTabbedPanel);
593 chatPanel.getRootPane().setDefaultButton(sendButton);
594 }
595
596 /***
597 * An ActionListener that listens to the radio buttons menus
598 */
599 protected class UIListener implements ActionListener {
600
601 /***
602 * Creates a new instance of UIListener <br>
603 */
604 public UIListener() {
605 super();
606 }
607
608 public void actionPerformed(ActionEvent e) {
609 SkinLF.installLookAndFeel(e.getActionCommand(), e.getSource());
610 ZoneManager.updateLookAndFeel();
611 }
612 }
613
614 /***
615 * Set the current UI as Metal
616 */
617 protected static void setDefaultUI() {
618 lookAndFeelName = MUIManager.LF_METAL_CLASSNAME;
619 JFrame.setDefaultLookAndFeelDecorated(true);
620 JDialog.setDefaultLookAndFeelDecorated(true);
621 frameDecorated = true;
622 }
623
624 @Override
625 protected final void setToolKitMdb(String tbsName) {
626 super.setToolKitMdb(tbsName);
627 MagicUIComponents.previewPanel.removeAll();
628 Mana.init(tbsName);
629 Picture pic = CardFactory.initPreview();
630 MagicUIComponents.previewPanel.add(pic);
631 MagicUIComponents.previewPanel.setPreferredSize(new Dimension(pic
632 .getPreferredSize().width + 2, pic.getPreferredSize().height + 2));
633 choosenCostPanel.initialize();
634
635 }
636
637 /***
638 * An ActionListener that listens to the radio buttons menus
639 */
640 private final ActionListener langListener = new ActionListener() {
641 /***
642 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
643 */
644 public void actionPerformed(ActionEvent e) {
645 final String command = e.getActionCommand();
646 if ("menu_lf_language.more".equals(command)) {
647
648 try {
649 WebBrowser
650 .launchBrowser("http://sourceforge.net/project/showfiles.php?group_id=92519&package_id=107882");
651 } catch (Exception e1) {
652 JOptionPane.showOptionDialog(magicForm, LanguageManager
653 .getString("error"), LanguageManager.getString("web-pb"),
654 JOptionPane.OK_OPTION, JOptionPane.INFORMATION_MESSAGE, UIHelper
655 .getIcon("wiz_update_error.gif"), null, null);
656 }
657 return;
658 }
659 LanguageManager.setLanguage(e.getActionCommand());
660 JOptionPane
661 .showMessageDialog(MagicUIComponents.magicForm, LanguageManager
662 .getString("menu_lf_language.restart"), LanguageManager
663 .getString("restart"), JOptionPane.INFORMATION_MESSAGE);
664 }
665 };
666
667 /***
668 * Comment for <code>chat</code>
669 */
670 public static MChat chat;
671
672 /***
673 * all radioButtonMenu of each L&F available
674 */
675 protected JRadioButtonMenuItem[] lookAndFeels;
676
677 /***
678 * Comment for <code>lookAndFeelName</code>
679 */
680 public static String lookAndFeelName;
681
682 /***
683 * Comment for <code>magicForm</code>
684 */
685 public static Magic magicForm;
686
687 /***
688 * Comment for <code>frameDecorated</code>
689 */
690 public static boolean frameDecorated;
691
692 /***
693 * Comment for <code>autoManaMenu</code>
694 */
695 public static JCheckBoxMenuItem autoManaMenu;
696
697 /***
698 * Comment for <code>autoPlayMenu</code>
699 */
700 public static JCheckBoxMenuItem autoPlayMenu;
701
702 /***
703 * Comment for <code>chatPanel</code>
704 */
705 public static JPanel chatPanel;
706
707 /***
708 * Comment for <code>historyText</code>
709 */
710 public static EditorPane chatHistoryText;
711
712 /***
713 * Comment for <code>themeMenu</code>
714 */
715 public static JMenu themeMenu;
716
717 /***
718 * Comment for <code>previewPanel</code>
719 */
720 public static JPanel previewPanel;
721
722 /***
723 * Comment for <code>sendButton</code>
724 */
725 public static JButton sendButton;
726
727 /***
728 * Comment for <code>sendTxt</code>
729 */
730 public static JTextField sendTxt;
731
732 /***
733 * The button used to skip/decline to response to the current ability.
734 */
735 public static JButton skipButton;
736
737 /***
738 * Comment for <code>skipMenu</code>
739 */
740 public static JMenuItem skipMenu;
741
742 /***
743 * The label containg information about the active player
744 */
745 public static JLabel waitingLabel;
746
747 /***
748 *
749 */
750 protected static JMenuItem reverseArtCheck;
751
752 /***
753 *
754 */
755 protected static JMenuItem reverseSideCheck;
756
757 /***
758 *
759 */
760 protected static JCheckBoxMenuItem soundMenu;
761
762 /***
763 *
764 */
765 protected static JMenuItem initialdelayMenu;
766
767 /***
768 *
769 */
770 protected static JMenuItem dismissdelayMenu;
771
772 private static JMenu languageMenu;
773
774 /***
775 *
776 */
777 protected static JMenuItem moreThemeMenu;
778
779 /***
780 * The main panel containing player stuffs.
781 */
782 public static JTabbedPane playerTabbedPanel;
783
784 /***
785 * The logging editor pane.
786 */
787 public static EditorPane logListing;
788
789 /***
790 * Is the main avatar picture is separated from the tabbed pane containing
791 * zones.
792 */
793 public static boolean speparateAvatar = true;
794
795 /***
796 * The splash screen
797 */
798 protected static SplashScreen splash;
799
800 /***
801 *
802 */
803 protected static JMenu cardBorderMenu;
804
805 /***
806 * The choosen cost panel
807 */
808 public static ChoosenCostPanel choosenCostPanel;
809
810 /***
811 * The tip picture.
812 */
813 public static final String HTML_ICON_TIP = "<img src='file:///"
814 + MToolKit.getIconPath("tip.gif") + "'> ";
815
816 /***
817 * The warning picture.
818 */
819 public static final String HTML_ICON_WARNING = "<br><img src='file:///"
820 + MToolKit.getIconPath("warn.gif") + "'> ";
821
822 /***
823 * The button restoring the current backgrounded wizard.
824 */
825 public static MessageButton backgroundBtn;
826
827 /***
828 * Data base panel. Displayed in the <code>previewTabbedPanel</code>.
829 */
830 public static CardPropertiesPanel databasePanel;
831 }