Adds first draft of HomeScreen gui. Requires an environmental variable to be present in order to enable it.

Move ManaSymbol initialization from OldGuiNewGame to ApplicationView.
This commit is contained in:
Rob Cashwalker
2011-09-24 17:44:15 +00:00
parent fd55737978
commit b40c3d1b2a
9 changed files with 1733 additions and 7 deletions

View File

@@ -17,6 +17,7 @@ import forge.quest.data.QuestMatchState;
import forge.quest.data.QuestPreferences;
import forge.quest.gui.QuestFrame;
import forge.quest.gui.main.QuestChallenge;
import forge.view.swing.Gui_HomeScreen;
import forge.view.swing.OldGuiNewGame;
import net.miginfocom.swing.MigLayout;
@@ -341,7 +342,19 @@ public class Gui_WinLose extends JFrame implements NewConstants {
//are we on a quest?
if (model.quest == null) {
model.match.reset();
new OldGuiNewGame();
if (System.getenv("NG2") != null) {
if (System.getenv("NG2").equalsIgnoreCase("true")) {
String argz[] = {};
Gui_HomeScreen.main(argz);
} else {
new OldGuiNewGame();
}
} else {
new OldGuiNewGame();
}
} else { //Quest
boolean wonMatch = false;

View File

@@ -15,6 +15,7 @@ import forge.item.ItemPool;
import forge.item.ItemPoolView;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import forge.view.swing.Gui_HomeScreen;
import forge.view.swing.OldGuiNewGame;
import net.slightlymagic.maxmtg.Predicate;
@@ -103,7 +104,18 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
JOptionPane.YES_NO_OPTION);
if (n == JOptionPane.YES_OPTION) {
dispose();
new OldGuiNewGame();
if (System.getenv("NG2") != null) {
if (System.getenv("NG2").equalsIgnoreCase("true")) {
String argz[] = {};
Gui_HomeScreen.main(argz);
} else {
new OldGuiNewGame();
}
} else {
new OldGuiNewGame();
}
}
}//windowClosing()
});
@@ -284,7 +296,18 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
//close and open next screen
dispose();
new OldGuiNewGame();
if (System.getenv("NG2") != null) {
if (System.getenv("NG2").equalsIgnoreCase("true")) {
String argz[] = {};
Gui_HomeScreen.main(argz);
} else {
new OldGuiNewGame();
}
} else {
new OldGuiNewGame();
}
}/*saveDraft()*/

View File

@@ -4,6 +4,7 @@ import forge.AllZone;
import forge.gui.GuiUtils;
import forge.quest.gui.bazaar.QuestBazaarPanel;
import forge.quest.gui.main.QuestEventManager;
import forge.view.swing.Gui_HomeScreen;
import forge.view.swing.OldGuiNewGame;
import javax.swing.*;
@@ -107,7 +108,18 @@ public class QuestFrame extends JFrame {
*/
public void returnToMainMenu() {
AllZone.getQuestData().saveData();
(new OldGuiNewGame()).setVisible(true);
if (System.getenv("NG2") != null) {
if (System.getenv("NG2").equalsIgnoreCase("true")) {
String argz[] = {};
Gui_HomeScreen.main(argz);
} else {
new OldGuiNewGame();
}
} else {
new OldGuiNewGame();
}
this.dispose();
}
}

View File

@@ -6,6 +6,7 @@ import forge.gui.GuiUtils;
import forge.quest.data.QuestData;
import forge.quest.data.QuestDataIO;
import forge.quest.data.QuestPreferences;
import forge.view.swing.Gui_HomeScreen;
import forge.view.swing.OldGuiNewGame;
import javax.swing.*;
@@ -81,7 +82,18 @@ public class QuestOptions extends JFrame {
@Override
public void windowClosing(WindowEvent ev) {
QuestOptions.this.dispose();
new OldGuiNewGame();
if (System.getenv("NG2") != null) {
if (System.getenv("NG2").equalsIgnoreCase("true")) {
String argz[] = {};
Gui_HomeScreen.main(argz);
} else {
new OldGuiNewGame();
}
} else {
new OldGuiNewGame();
}
}
});

View File

@@ -6,6 +6,8 @@ import javax.swing.UIManager;
import net.slightlymagic.braids.util.UtilFunctions;
import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor;
import arcane.ui.util.ManaSymbols;
import com.esotericsoftware.minlog.Log;
import forge.AllZone;
@@ -124,6 +126,8 @@ public class ApplicationView implements FView {
if(!splashFrame.getSplashHasBeenClosed()) {
try {
ManaSymbols.loadImages();
Constant.Runtime.gameType = GameType.Constructed;
SwingUtilities.invokeLater(new Runnable() { // NOPMD by Braids on 8/7/11 1:07 PM: this isn't a web app
public void run() {
@@ -137,7 +141,17 @@ public class ApplicationView implements FView {
splashFrame = null;
new OldGuiNewGame();
if (System.getenv("NG2") != null) {
if (System.getenv("NG2").equalsIgnoreCase("true")) {
String argz[] = {};
Gui_HomeScreen.main(argz);
} else {
new OldGuiNewGame();
}
} else {
new OldGuiNewGame();
}
}
});
} catch (Exception ex) {

File diff suppressed because it is too large Load Diff

View File

@@ -178,7 +178,7 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
setupMenu();
setVisible(true);
ManaSymbols.loadImages();
Log.WARN(); // set logging level to warn
SwingUtilities.updateComponentTreeUI(this);
}

View File

@@ -0,0 +1,92 @@
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Google, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.wb.swing;
import java.awt.Component;
import java.awt.Container;
import java.awt.FocusTraversalPolicy;
/**
* Cyclic focus traversal policy based on array of components.
* <p>
* This class may be freely distributed as part of any application or plugin.
*
* @author scheglov_ke
*/
public class FocusTraversalOnArray extends FocusTraversalPolicy {
private final Component m_Components[];
////////////////////////////////////////////////////////////////////////////
//
// Constructor
//
////////////////////////////////////////////////////////////////////////////
public FocusTraversalOnArray(Component components[]) {
m_Components = components;
}
////////////////////////////////////////////////////////////////////////////
//
// Utilities
//
////////////////////////////////////////////////////////////////////////////
private int indexCycle(int index, int delta) {
int size = m_Components.length;
int next = (index + delta + size) % size;
return next;
}
private Component cycle(Component currentComponent, int delta) {
int index = -1;
loop : for (int i = 0; i < m_Components.length; i++) {
Component component = m_Components[i];
for (Component c = currentComponent; c != null; c = c.getParent()) {
if (component == c) {
index = i;
break loop;
}
}
}
// try to find enabled component in "delta" direction
int initialIndex = index;
while (true) {
int newIndex = indexCycle(index, delta);
if (newIndex == initialIndex) {
break;
}
index = newIndex;
//
Component component = m_Components[newIndex];
if (component.isEnabled() && component.isVisible() && component.isFocusable()) {
return component;
}
}
// not found
return currentComponent;
}
////////////////////////////////////////////////////////////////////////////
//
// FocusTraversalPolicy
//
////////////////////////////////////////////////////////////////////////////
public Component getComponentAfter(Container container, Component component) {
return cycle(component, 1);
}
public Component getComponentBefore(Container container, Component component) {
return cycle(component, -1);
}
public Component getFirstComponent(Container container) {
return m_Components[0];
}
public Component getLastComponent(Container container) {
return m_Components[m_Components.length - 1];
}
public Component getDefaultComponent(Container container) {
return getFirstComponent(container);
}
}