mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Moved the "forge.view.swing" package into "forge.view".
This commit is contained in:
4
.gitattributes
vendored
4
.gitattributes
vendored
@@ -11065,6 +11065,7 @@ src/main/java/forge/quest/gui/package-info.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/package-info.java svneol=native#text/plain
|
||||
src/main/java/forge/view/FView.java svneol=native#text/plain
|
||||
src/main/java/forge/view/GuiTopLevel.java -text
|
||||
src/main/java/forge/view/Main.java -text
|
||||
src/main/java/forge/view/editor/EditorTopLevel.java -text
|
||||
src/main/java/forge/view/editor/package-info.java svneol=native#text/plain
|
||||
src/main/java/forge/view/home/HomeTopLevel.java -text
|
||||
@@ -11092,9 +11093,6 @@ src/main/java/forge/view/match/ViewTopLevel.java -text
|
||||
src/main/java/forge/view/match/ViewWinLose.java -text
|
||||
src/main/java/forge/view/match/package-info.java svneol=native#text/plain
|
||||
src/main/java/forge/view/package-info.java svneol=native#text/plain
|
||||
src/main/java/forge/view/swing/ApplicationView.java svneol=native#text/plain
|
||||
src/main/java/forge/view/swing/Main.java svneol=native#text/plain
|
||||
src/main/java/forge/view/swing/package-info.java svneol=native#text/plain
|
||||
src/main/java/forge/view/toolbox/CardFaceSymbols.java svneol=native#text/plain
|
||||
src/main/java/forge/view/toolbox/CardViewer.java -text
|
||||
src/main/java/forge/view/toolbox/DeckLister.java -text
|
||||
|
||||
6
pom.xml
6
pom.xml
@@ -246,7 +246,7 @@
|
||||
</descriptorRefs>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>forge.view.swing.Main</mainClass>
|
||||
<mainClass>forge.view.Main</mainClass>
|
||||
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
|
||||
</manifest>
|
||||
<manifestEntries>
|
||||
@@ -842,7 +842,7 @@
|
||||
<errTitle>forge</errTitle>
|
||||
<icon>${configSourceDirectory}/forge.ico</icon>
|
||||
<classPath>
|
||||
<mainClass>forge.view.swing.Main</mainClass>
|
||||
<mainClass>forge.view.Main</mainClass>
|
||||
<addDependencies>false</addDependencies>
|
||||
<preCp>anything</preCp>
|
||||
</classPath>
|
||||
@@ -1012,7 +1012,7 @@
|
||||
<mkdir dir="${project.build.directory}/res/cardsfolder" />
|
||||
<zip destfile="${project.build.directory}/res/cardsfolder/cardsfolder.zip" basedir="${basedir}/res/cardsfolder" level="1" />
|
||||
<taskdef name="jarbundler" classpathref="maven.runtime.classpath" classname="net.sourceforge.jarbundler.JarBundler" />
|
||||
<jarbundler dir="${project.build.directory}/${project.build.finalName}-osx" name="${project.name}" version="${project.version}" mainclass="forge.view.swing.Main" icon="${basedir}/${configSourceDirectory}/Forge.icns" jvmversion="1.6+" vmoptions="-Xmx1024m" shortname="${project.name}" workingdirectory="$APP_PACKAGE/Contents/Resources/Java" jar="${project.build.directory}/${project.build.finalName}-jar-with-dependencies.jar">
|
||||
<jarbundler dir="${project.build.directory}/${project.build.finalName}-osx" name="${project.name}" version="${project.version}" mainclass="forge.view.Main" icon="${basedir}/${configSourceDirectory}/Forge.icns" jvmversion="1.6+" vmoptions="-Xmx1024m" shortname="${project.name}" workingdirectory="$APP_PACKAGE/Contents/Resources/Java" jar="${project.build.directory}/${project.build.finalName}-jar-with-dependencies.jar">
|
||||
<javafileset dir="${basedir}">
|
||||
<include name="*.properties" />
|
||||
<include name="res/**" />
|
||||
|
||||
@@ -17,13 +17,86 @@
|
||||
*/
|
||||
package forge.view;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import net.slightlymagic.braids.util.UtilFunctions;
|
||||
import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor;
|
||||
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.ComputerAIGeneral;
|
||||
import forge.ComputerAIInput;
|
||||
import forge.Constant;
|
||||
import forge.ImageCache;
|
||||
import forge.control.ControlAllUI;
|
||||
import forge.error.ErrorViewer;
|
||||
import forge.game.GameType;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.view.home.SplashFrame;
|
||||
import forge.view.toolbox.CardFaceSymbols;
|
||||
import forge.view.toolbox.FSkin;
|
||||
|
||||
/**
|
||||
* Generic view (as in model-view-controller) interface for Forge.
|
||||
* The main view for Forge: a java swing application. All view class instances
|
||||
* should be accessible from here.
|
||||
*/
|
||||
public interface FView {
|
||||
public class FView {
|
||||
|
||||
private transient SplashFrame splashFrame;
|
||||
|
||||
/**
|
||||
* The splashFrame field is guaranteed to exist when this constructor exits.
|
||||
*
|
||||
* @param skin
|
||||
* the skin
|
||||
*/
|
||||
public FView(final FSkin skin) {
|
||||
|
||||
// We must use invokeAndWait here to fulfill the constructor's
|
||||
// contract.
|
||||
|
||||
UtilFunctions.invokeInEventDispatchThreadAndWait(new Runnable() { // NOPMD
|
||||
// by
|
||||
// Braids
|
||||
// on
|
||||
// 8/18/11
|
||||
// 11:37
|
||||
// PM
|
||||
@Override
|
||||
public void run() {
|
||||
FView.this.splashFrame = new SplashFrame(skin);
|
||||
}
|
||||
});
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() { // NOPMD by Braids on
|
||||
// 8/18/11 11:37 PM
|
||||
@Override
|
||||
public void run() {
|
||||
FView.this.splashFrame.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the progress monitor for loading all cards at once.
|
||||
*
|
||||
* @return a progress monitor having only one phase; may be null
|
||||
*/
|
||||
public final BraidsProgressMonitor getCardLoadingProgressMonitor() {
|
||||
BraidsProgressMonitor result;
|
||||
|
||||
if (this.splashFrame == null) {
|
||||
result = null;
|
||||
} else {
|
||||
result = this.splashFrame.getMonitorModel();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell the view that the model has been bootstrapped, and its data is ready
|
||||
@@ -32,12 +105,57 @@ public interface FView {
|
||||
* @param model
|
||||
* the model that has finished bootstrapping
|
||||
*/
|
||||
void setModel(FModel model);
|
||||
public final void setModel(final FModel model) {
|
||||
try {
|
||||
|
||||
/**
|
||||
* Get the progress monitor for loading all cards at once.
|
||||
*
|
||||
* @return a progress monitor having only one phase; may be null
|
||||
*/
|
||||
BraidsProgressMonitor getCardLoadingProgressMonitor();
|
||||
final ForgePreferences preferences = model.getPreferences();
|
||||
|
||||
// FindBugs doesn't like the next line.
|
||||
ImageCache.setScaleLargerThanOriginal(preferences.isScaleLargerThanOriginal());
|
||||
|
||||
} catch (final Exception exn) {
|
||||
Log.error("Error loading preferences: " + exn);
|
||||
}
|
||||
|
||||
// For the following two blocks, check if user has cancelled
|
||||
// SplashFrame.
|
||||
// Note: Error thrown sometimes because log file cannot be accessed
|
||||
if (!this.splashFrame.getSplashHasBeenClosed()) {
|
||||
AllZone.getCardFactory(); // forces preloading of all cards
|
||||
}
|
||||
|
||||
if (!this.splashFrame.getSplashHasBeenClosed()) {
|
||||
try {
|
||||
CardFaceSymbols.loadImages();
|
||||
|
||||
Constant.Runtime.setGameType(GameType.Constructed);
|
||||
SwingUtilities.invokeLater(new Runnable() { // NOPMD by Braids
|
||||
// on 8/7/11 1:07
|
||||
// PM: this isn't a
|
||||
// web app
|
||||
@Override
|
||||
public void run() {
|
||||
AllZone.getInputControl().setComputer(new ComputerAIInput(new ComputerAIGeneral()));
|
||||
|
||||
// Enable only one of the following two lines.
|
||||
// The second
|
||||
// is useful for debugging.
|
||||
|
||||
FView.this.splashFrame.dispose();
|
||||
// splashFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
|
||||
FView.this.splashFrame = null;
|
||||
AllZone.getSkin().loadFontAndImages();
|
||||
GuiTopLevel g = new GuiTopLevel();
|
||||
g.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
AllZone.setDisplay(g);
|
||||
g.getController().changeState(ControlAllUI.HOME_SCREEN);
|
||||
}
|
||||
});
|
||||
} catch (final Exception ex) {
|
||||
ErrorViewer.showError(ex);
|
||||
}
|
||||
} // End if(splashHasBeenClosed)
|
||||
|
||||
} // End FView()
|
||||
}
|
||||
|
||||
@@ -1,195 +1,194 @@
|
||||
/*
|
||||
* Forge: Play Magic: the Gathering.
|
||||
* Copyright (C) 2011 Forge Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.view.swing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.Constant;
|
||||
import forge.ConstantStringArrayList;
|
||||
import forge.FileUtil;
|
||||
import forge.Singletons;
|
||||
import forge.error.ErrorViewer;
|
||||
import forge.error.ExceptionHandler;
|
||||
import forge.model.FModel;
|
||||
import forge.view.FView;
|
||||
import forge.view.toolbox.FSkin;
|
||||
|
||||
/**
|
||||
* Main class for Forge's swing application view.
|
||||
*/
|
||||
public final class Main {
|
||||
|
||||
/**
|
||||
* Do not instantiate.
|
||||
*/
|
||||
private Main() {
|
||||
// intentionally blank
|
||||
}
|
||||
|
||||
/**
|
||||
* main method for Forge's swing application view.
|
||||
*
|
||||
* @param args
|
||||
* an array of {@link java.lang.String} objects.
|
||||
*/
|
||||
public static void main(final String[] args) {
|
||||
ExceptionHandler.registerErrorHandling();
|
||||
try {
|
||||
final FModel model = new FModel(null);
|
||||
Singletons.setModel(model);
|
||||
|
||||
final FSkin skin = new FSkin(model.getPreferences().getSkin());
|
||||
final FView view = new ApplicationView(skin);
|
||||
Singletons.setView(view);
|
||||
AllZone.setSkin(skin);
|
||||
|
||||
// Need this soon after card factory is loaded
|
||||
Main.loadDynamicGamedata();
|
||||
|
||||
// TODO this code should go elsewhere, like wherever we start a new
|
||||
// game.
|
||||
// It is only here to maintain semantic equality with the current
|
||||
// code base.
|
||||
|
||||
model.resetGameState();
|
||||
|
||||
view.setModel(model);
|
||||
|
||||
} catch (final Throwable exn) {
|
||||
ErrorViewer.showError(exn);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load dynamic gamedata.
|
||||
*/
|
||||
public static void loadDynamicGamedata() {
|
||||
if (!Constant.CardTypes.LOADED[0]) {
|
||||
final ArrayList<String> typeListFile = FileUtil.readFile("res/gamedata/TypeLists.txt");
|
||||
|
||||
ArrayList<String> tList = null;
|
||||
|
||||
Constant.CardTypes.CARD_TYPES[0] = new ConstantStringArrayList();
|
||||
Constant.CardTypes.SUPER_TYPES[0] = new ConstantStringArrayList();
|
||||
Constant.CardTypes.BASIC_TYPES[0] = new ConstantStringArrayList();
|
||||
Constant.CardTypes.LAND_TYPES[0] = new ConstantStringArrayList();
|
||||
Constant.CardTypes.CREATURE_TYPES[0] = new ConstantStringArrayList();
|
||||
Constant.CardTypes.INSTANT_TYPES[0] = new ConstantStringArrayList();
|
||||
Constant.CardTypes.SORCERY_TYPES[0] = new ConstantStringArrayList();
|
||||
Constant.CardTypes.ENCHANTMENT_TYPES[0] = new ConstantStringArrayList();
|
||||
Constant.CardTypes.ARTIFACT_TYPES[0] = new ConstantStringArrayList();
|
||||
Constant.CardTypes.WALKER_TYPES[0] = new ConstantStringArrayList();
|
||||
|
||||
if (typeListFile.size() > 0) {
|
||||
for (int i = 0; i < typeListFile.size(); i++) {
|
||||
final String s = typeListFile.get(i);
|
||||
|
||||
if (s.equals("[CardTypes]")) {
|
||||
tList = Constant.CardTypes.CARD_TYPES[0].getList();
|
||||
}
|
||||
|
||||
else if (s.equals("[SuperTypes]")) {
|
||||
tList = Constant.CardTypes.SUPER_TYPES[0].getList();
|
||||
}
|
||||
|
||||
else if (s.equals("[BasicTypes]")) {
|
||||
tList = Constant.CardTypes.BASIC_TYPES[0].getList();
|
||||
}
|
||||
|
||||
else if (s.equals("[LandTypes]")) {
|
||||
tList = Constant.CardTypes.LAND_TYPES[0].getList();
|
||||
}
|
||||
|
||||
else if (s.equals("[CreatureTypes]")) {
|
||||
tList = Constant.CardTypes.CREATURE_TYPES[0].getList();
|
||||
}
|
||||
|
||||
else if (s.equals("[InstantTypes]")) {
|
||||
tList = Constant.CardTypes.INSTANT_TYPES[0].getList();
|
||||
}
|
||||
|
||||
else if (s.equals("[SorceryTypes]")) {
|
||||
tList = Constant.CardTypes.SORCERY_TYPES[0].getList();
|
||||
}
|
||||
|
||||
else if (s.equals("[EnchantmentTypes]")) {
|
||||
tList = Constant.CardTypes.ENCHANTMENT_TYPES[0].getList();
|
||||
}
|
||||
|
||||
else if (s.equals("[ArtifactTypes]")) {
|
||||
tList = Constant.CardTypes.ARTIFACT_TYPES[0].getList();
|
||||
}
|
||||
|
||||
else if (s.equals("[WalkerTypes]")) {
|
||||
tList = Constant.CardTypes.WALKER_TYPES[0].getList();
|
||||
}
|
||||
|
||||
else if (s.length() > 1) {
|
||||
tList.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
Constant.CardTypes.LOADED[0] = true;
|
||||
/*
|
||||
* if (Constant.Runtime.DevMode[0]) {
|
||||
* System.out.println(Constant.CardTypes.cardTypes[0].list);
|
||||
* System.out.println(Constant.CardTypes.superTypes[0].list);
|
||||
* System.out.println(Constant.CardTypes.basicTypes[0].list);
|
||||
* System.out.println(Constant.CardTypes.landTypes[0].list);
|
||||
* System.out.println(Constant.CardTypes.creatureTypes[0].list);
|
||||
* System.out.println(Constant.CardTypes.instantTypes[0].list);
|
||||
* System.out.println(Constant.CardTypes.sorceryTypes[0].list);
|
||||
* System.out.println(Constant.CardTypes.enchantmentTypes[0].list);
|
||||
* System.out.println(Constant.CardTypes.artifactTypes[0].list);
|
||||
* System.out.println(Constant.CardTypes.walkerTypes[0].list); }
|
||||
*/
|
||||
}
|
||||
|
||||
if (!Constant.Keywords.LOADED[0]) {
|
||||
final ArrayList<String> nskwListFile = FileUtil.readFile("res/gamedata/NonStackingKWList.txt");
|
||||
|
||||
Constant.Keywords.NON_STACKING_LIST[0] = new ConstantStringArrayList();
|
||||
|
||||
if (nskwListFile.size() > 1) {
|
||||
for (int i = 0; i < nskwListFile.size(); i++) {
|
||||
final String s = nskwListFile.get(i);
|
||||
if (s.length() > 1) {
|
||||
Constant.Keywords.NON_STACKING_LIST[0].getList().add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
Constant.Keywords.LOADED[0] = true;
|
||||
/*
|
||||
* if (Constant.Runtime.DevMode[0]) {
|
||||
* System.out.println(Constant.Keywords.NonStackingList[0].list); }
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* if (!Constant.Color.loaded[0]) { ArrayList<String> lcListFile =
|
||||
* FileUtil.readFile("res/gamedata/LandColorList");
|
||||
*
|
||||
* if (lcListFile.size() > 1) { for (int i=0; i<lcListFile.size(); i++)
|
||||
* { String s = lcListFile.get(i); if (s.length() > 1)
|
||||
* Constant.Color.LandColor[0].map.add(s); } }
|
||||
* Constant.Keywords.loaded[0] = true; if (Constant.Runtime.DevMode[0])
|
||||
* { System.out.println(Constant.Keywords.NonStackingList[0].list); } }
|
||||
*/
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Forge: Play Magic: the Gathering.
|
||||
* Copyright (C) 2011 Forge Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.view;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.Constant;
|
||||
import forge.ConstantStringArrayList;
|
||||
import forge.FileUtil;
|
||||
import forge.Singletons;
|
||||
import forge.error.ErrorViewer;
|
||||
import forge.error.ExceptionHandler;
|
||||
import forge.model.FModel;
|
||||
import forge.view.toolbox.FSkin;
|
||||
|
||||
/**
|
||||
* Main class for Forge's swing application view.
|
||||
*/
|
||||
public final class Main {
|
||||
|
||||
/**
|
||||
* Do not instantiate.
|
||||
*/
|
||||
private Main() {
|
||||
// intentionally blank
|
||||
}
|
||||
|
||||
/**
|
||||
* main method for Forge's swing application view.
|
||||
*
|
||||
* @param args
|
||||
* an array of {@link java.lang.String} objects.
|
||||
*/
|
||||
public static void main(final String[] args) {
|
||||
ExceptionHandler.registerErrorHandling();
|
||||
try {
|
||||
final FModel model = new FModel(null);
|
||||
Singletons.setModel(model);
|
||||
|
||||
final FSkin skin = new FSkin(Singletons.getModel().getPreferences().getSkin());
|
||||
final FView view = new FView(skin);
|
||||
Singletons.setView(view);
|
||||
AllZone.setSkin(skin);
|
||||
|
||||
// Need this soon after card factory is loaded
|
||||
Main.loadDynamicGamedata();
|
||||
|
||||
// TODO this code should go elsewhere, like wherever we start a new
|
||||
// game.
|
||||
// It is only here to maintain semantic equality with the current
|
||||
// code base.
|
||||
|
||||
model.resetGameState();
|
||||
|
||||
view.setModel(model);
|
||||
|
||||
} catch (final Throwable exn) {
|
||||
ErrorViewer.showError(exn);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load dynamic gamedata.
|
||||
*/
|
||||
public static void loadDynamicGamedata() {
|
||||
if (!Constant.CardTypes.LOADED[0]) {
|
||||
final ArrayList<String> typeListFile = FileUtil.readFile("res/gamedata/TypeLists.txt");
|
||||
|
||||
ArrayList<String> tList = null;
|
||||
|
||||
Constant.CardTypes.CARD_TYPES[0] = new ConstantStringArrayList();
|
||||
Constant.CardTypes.SUPER_TYPES[0] = new ConstantStringArrayList();
|
||||
Constant.CardTypes.BASIC_TYPES[0] = new ConstantStringArrayList();
|
||||
Constant.CardTypes.LAND_TYPES[0] = new ConstantStringArrayList();
|
||||
Constant.CardTypes.CREATURE_TYPES[0] = new ConstantStringArrayList();
|
||||
Constant.CardTypes.INSTANT_TYPES[0] = new ConstantStringArrayList();
|
||||
Constant.CardTypes.SORCERY_TYPES[0] = new ConstantStringArrayList();
|
||||
Constant.CardTypes.ENCHANTMENT_TYPES[0] = new ConstantStringArrayList();
|
||||
Constant.CardTypes.ARTIFACT_TYPES[0] = new ConstantStringArrayList();
|
||||
Constant.CardTypes.WALKER_TYPES[0] = new ConstantStringArrayList();
|
||||
|
||||
if (typeListFile.size() > 0) {
|
||||
for (int i = 0; i < typeListFile.size(); i++) {
|
||||
final String s = typeListFile.get(i);
|
||||
|
||||
if (s.equals("[CardTypes]")) {
|
||||
tList = Constant.CardTypes.CARD_TYPES[0].getList();
|
||||
}
|
||||
|
||||
else if (s.equals("[SuperTypes]")) {
|
||||
tList = Constant.CardTypes.SUPER_TYPES[0].getList();
|
||||
}
|
||||
|
||||
else if (s.equals("[BasicTypes]")) {
|
||||
tList = Constant.CardTypes.BASIC_TYPES[0].getList();
|
||||
}
|
||||
|
||||
else if (s.equals("[LandTypes]")) {
|
||||
tList = Constant.CardTypes.LAND_TYPES[0].getList();
|
||||
}
|
||||
|
||||
else if (s.equals("[CreatureTypes]")) {
|
||||
tList = Constant.CardTypes.CREATURE_TYPES[0].getList();
|
||||
}
|
||||
|
||||
else if (s.equals("[InstantTypes]")) {
|
||||
tList = Constant.CardTypes.INSTANT_TYPES[0].getList();
|
||||
}
|
||||
|
||||
else if (s.equals("[SorceryTypes]")) {
|
||||
tList = Constant.CardTypes.SORCERY_TYPES[0].getList();
|
||||
}
|
||||
|
||||
else if (s.equals("[EnchantmentTypes]")) {
|
||||
tList = Constant.CardTypes.ENCHANTMENT_TYPES[0].getList();
|
||||
}
|
||||
|
||||
else if (s.equals("[ArtifactTypes]")) {
|
||||
tList = Constant.CardTypes.ARTIFACT_TYPES[0].getList();
|
||||
}
|
||||
|
||||
else if (s.equals("[WalkerTypes]")) {
|
||||
tList = Constant.CardTypes.WALKER_TYPES[0].getList();
|
||||
}
|
||||
|
||||
else if (s.length() > 1) {
|
||||
tList.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
Constant.CardTypes.LOADED[0] = true;
|
||||
/*
|
||||
* if (Constant.Runtime.DevMode[0]) {
|
||||
* System.out.println(Constant.CardTypes.cardTypes[0].list);
|
||||
* System.out.println(Constant.CardTypes.superTypes[0].list);
|
||||
* System.out.println(Constant.CardTypes.basicTypes[0].list);
|
||||
* System.out.println(Constant.CardTypes.landTypes[0].list);
|
||||
* System.out.println(Constant.CardTypes.creatureTypes[0].list);
|
||||
* System.out.println(Constant.CardTypes.instantTypes[0].list);
|
||||
* System.out.println(Constant.CardTypes.sorceryTypes[0].list);
|
||||
* System.out.println(Constant.CardTypes.enchantmentTypes[0].list);
|
||||
* System.out.println(Constant.CardTypes.artifactTypes[0].list);
|
||||
* System.out.println(Constant.CardTypes.walkerTypes[0].list); }
|
||||
*/
|
||||
}
|
||||
|
||||
if (!Constant.Keywords.LOADED[0]) {
|
||||
final ArrayList<String> nskwListFile = FileUtil.readFile("res/gamedata/NonStackingKWList.txt");
|
||||
|
||||
Constant.Keywords.NON_STACKING_LIST[0] = new ConstantStringArrayList();
|
||||
|
||||
if (nskwListFile.size() > 1) {
|
||||
for (int i = 0; i < nskwListFile.size(); i++) {
|
||||
final String s = nskwListFile.get(i);
|
||||
if (s.length() > 1) {
|
||||
Constant.Keywords.NON_STACKING_LIST[0].getList().add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
Constant.Keywords.LOADED[0] = true;
|
||||
/*
|
||||
* if (Constant.Runtime.DevMode[0]) {
|
||||
* System.out.println(Constant.Keywords.NonStackingList[0].list); }
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* if (!Constant.Color.loaded[0]) { ArrayList<String> lcListFile =
|
||||
* FileUtil.readFile("res/gamedata/LandColorList");
|
||||
*
|
||||
* if (lcListFile.size() > 1) { for (int i=0; i<lcListFile.size(); i++)
|
||||
* { String s = lcListFile.get(i); if (s.length() > 1)
|
||||
* Constant.Color.LandColor[0].map.add(s); } }
|
||||
* Constant.Keywords.loaded[0] = true; if (Constant.Runtime.DevMode[0])
|
||||
* { System.out.println(Constant.Keywords.NonStackingList[0].list); } }
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -1,164 +0,0 @@
|
||||
/*
|
||||
* Forge: Play Magic: the Gathering.
|
||||
* Copyright (C) 2011 Forge Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.view.swing;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import net.slightlymagic.braids.util.UtilFunctions;
|
||||
import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor;
|
||||
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.ComputerAIGeneral;
|
||||
import forge.ComputerAIInput;
|
||||
import forge.Constant;
|
||||
import forge.ImageCache;
|
||||
import forge.control.ControlAllUI;
|
||||
import forge.error.ErrorViewer;
|
||||
import forge.game.GameType;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.view.FView;
|
||||
import forge.view.GuiTopLevel;
|
||||
import forge.view.home.SplashFrame;
|
||||
import forge.view.toolbox.CardFaceSymbols;
|
||||
import forge.view.toolbox.FSkin;
|
||||
|
||||
/**
|
||||
* The main view for Forge: a java swing application. All view class instances
|
||||
* should be accessible from here.
|
||||
*/
|
||||
public class ApplicationView implements FView {
|
||||
|
||||
private transient SplashFrame splashFrame;
|
||||
|
||||
/**
|
||||
* The splashFrame field is guaranteed to exist when this constructor exits.
|
||||
*
|
||||
* @param skin
|
||||
* the skin
|
||||
*/
|
||||
public ApplicationView(final FSkin skin) {
|
||||
|
||||
// We must use invokeAndWait here to fulfill the constructor's
|
||||
// contract.
|
||||
|
||||
UtilFunctions.invokeInEventDispatchThreadAndWait(new Runnable() { // NOPMD
|
||||
// by
|
||||
// Braids
|
||||
// on
|
||||
// 8/18/11
|
||||
// 11:37
|
||||
// PM
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationView.this.splashFrame = new SplashFrame(skin);
|
||||
}
|
||||
});
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() { // NOPMD by Braids on
|
||||
// 8/18/11 11:37 PM
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationView.this.splashFrame.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see forge.view.FView#getCardLoadingProgressMonitor()
|
||||
*/
|
||||
@Override
|
||||
public final BraidsProgressMonitor getCardLoadingProgressMonitor() {
|
||||
BraidsProgressMonitor result;
|
||||
|
||||
if (this.splashFrame == null) {
|
||||
result = null;
|
||||
} else {
|
||||
result = this.splashFrame.getMonitorModel();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see forge.view.FView#setModel(forge.model.FModel)
|
||||
*/
|
||||
|
||||
@Override
|
||||
public final void setModel(final FModel model) {
|
||||
try {
|
||||
|
||||
final ForgePreferences preferences = model.getPreferences();
|
||||
|
||||
// FindBugs doesn't like the next line.
|
||||
ImageCache.setScaleLargerThanOriginal(preferences.isScaleLargerThanOriginal());
|
||||
|
||||
} catch (final Exception exn) {
|
||||
Log.error("Error loading preferences: " + exn);
|
||||
}
|
||||
|
||||
// For the following two blocks, check if user has cancelled
|
||||
// SplashFrame.
|
||||
// Note: Error thrown sometimes because log file cannot be accessed
|
||||
if (!this.splashFrame.getSplashHasBeenClosed()) {
|
||||
AllZone.getCardFactory(); // forces preloading of all cards
|
||||
}
|
||||
|
||||
if (!this.splashFrame.getSplashHasBeenClosed()) {
|
||||
try {
|
||||
CardFaceSymbols.loadImages();
|
||||
|
||||
Constant.Runtime.setGameType(GameType.Constructed);
|
||||
SwingUtilities.invokeLater(new Runnable() { // NOPMD by Braids
|
||||
// on 8/7/11 1:07
|
||||
// PM: this isn't a
|
||||
// web app
|
||||
@Override
|
||||
public void run() {
|
||||
AllZone.getInputControl().setComputer(new ComputerAIInput(new ComputerAIGeneral()));
|
||||
|
||||
// Enable only one of the following two lines.
|
||||
// The second
|
||||
// is useful for debugging.
|
||||
|
||||
ApplicationView.this.splashFrame.dispose();
|
||||
// splashFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
|
||||
ApplicationView.this.splashFrame = null;
|
||||
AllZone.getSkin().loadFontAndImages();
|
||||
GuiTopLevel g = new GuiTopLevel();
|
||||
g.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
AllZone.setDisplay(g);
|
||||
g.getController().changeState(ControlAllUI.HOME_SCREEN);
|
||||
}
|
||||
});
|
||||
} catch (final Exception ex) {
|
||||
ErrorViewer.showError(ex);
|
||||
}
|
||||
} // End if(splashHasBeenClosed)
|
||||
|
||||
} // End ApplicationView()
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
/** Primary swing implementation for Forge's View (as in model-view-controller). */
|
||||
package forge.view.swing;
|
||||
|
||||
@@ -17,7 +17,7 @@ import forge.card.cardfactory.LazyCardFactory;
|
||||
import forge.card.cardfactory.PreloadingCardFactory;
|
||||
import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants;
|
||||
import forge.view.swing.Main;
|
||||
import forge.view.Main;
|
||||
|
||||
//import net.slightlymagic.braids.testng.BraidsAssertFunctions;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user