mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
Lonely preference settings moved out of FModel into loadPreferences with the rest of the preference settings.
This commit is contained in:
@@ -67,19 +67,19 @@ public class ControlTabber extends MyObservable {
|
||||
this.view.getLblMilling().setEnabled(false);
|
||||
}
|
||||
|
||||
if (Singletons.getModel().getPreferences().getHandView()) {
|
||||
if (Singletons.getModel().getPreferences().isHandView()) {
|
||||
this.view.getLblHandView().setEnabled(true);
|
||||
} else {
|
||||
this.view.getLblHandView().setEnabled(false);
|
||||
}
|
||||
|
||||
if (Singletons.getModel().getPreferences().getLibraryView()) {
|
||||
if (Singletons.getModel().getPreferences().isLibraryView()) {
|
||||
this.view.getLblLibraryView().setEnabled(true);
|
||||
} else {
|
||||
this.view.getLblLibraryView().setEnabled(false);
|
||||
}
|
||||
|
||||
if (Singletons.getModel().getPreferences().getUnlimitedLand()) {
|
||||
if (Singletons.getModel().getPreferences().isUnlimitedLand()) {
|
||||
this.view.getLblUnlimitedLands().setEnabled(true);
|
||||
} else {
|
||||
this.view.getLblUnlimitedLands().setEnabled(false);
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor;
|
||||
import arcane.util.MultiplexOutputStream;
|
||||
import forge.AllZone;
|
||||
import forge.ComputerAIGeneral;
|
||||
@@ -60,19 +59,14 @@ public class FModel {
|
||||
/** The preferences. */
|
||||
private ForgePreferences preferences;
|
||||
private FGameState gameState;
|
||||
private final boolean http;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param theMonitor
|
||||
* a progress monitor (from the View) that shows the progress of
|
||||
* the model's initialization.
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
* if we could not find or write to the log file.
|
||||
*/
|
||||
public FModel(final BraidsProgressMonitor theMonitor) throws FileNotFoundException {
|
||||
public FModel() throws FileNotFoundException {
|
||||
// Fire up log file
|
||||
final File logFile = new File("forge.log");
|
||||
final boolean deleteSucceeded = logFile.delete();
|
||||
@@ -92,7 +86,6 @@ public class FModel {
|
||||
try {
|
||||
this.setPreferences(new ForgePreferences("forge.preferences"));
|
||||
} catch (final Exception exn) {
|
||||
|
||||
// Log.error("Error loading preferences: " + exn);
|
||||
throw new RuntimeException(exn);
|
||||
}
|
||||
@@ -101,25 +94,11 @@ public class FModel {
|
||||
AllZone.setInputControl(new InputControl(FModel.this));
|
||||
AllZone.getInputControl().setComputer(new ComputerAIInput(new ComputerAIGeneral()));
|
||||
|
||||
// TODO these should be set along with others all at the same time, not
|
||||
// here
|
||||
Constant.Runtime.MILL[0] = this.preferences.isMillingLossCondition();
|
||||
Constant.Runtime.DEV_MODE[0] = this.preferences.isDeveloperMode();
|
||||
Constant.Runtime.UPLOAD_DRAFT[0] = this.preferences.isUploadDraftAI();
|
||||
Constant.Runtime.RANDOM_FOIL[0] = this.preferences.isRandCFoil();
|
||||
// ///////
|
||||
|
||||
// Instantiate pinger
|
||||
// TODO is this in the right place?
|
||||
// Set gameplay preferences and constants
|
||||
final HttpUtil pinger = new HttpUtil();
|
||||
final String url = ForgeProps.getProperty(NewConstants.CARDFORGE_URL) + "/draftAI/ping.php";
|
||||
if (pinger.getURL(url).equals("pong")) {
|
||||
http = true;
|
||||
Constant.Runtime.NET_CONN[0] = true;
|
||||
} else {
|
||||
http = false;
|
||||
Constant.Runtime.UPLOAD_DRAFT[0] = false;
|
||||
}
|
||||
Constant.Runtime.NET_CONN[0] = (pinger.getURL(url).equals("pong") ? true : false);
|
||||
|
||||
this.setBuildInfo(new BuildInfo());
|
||||
FModel.loadDynamicGamedata();
|
||||
@@ -268,11 +247,6 @@ public class FModel {
|
||||
}
|
||||
}
|
||||
|
||||
/** @return boolean */
|
||||
public final boolean isHTTP() {
|
||||
return http;
|
||||
}
|
||||
|
||||
/** @return {@link forge.model.BuildInfo} */
|
||||
public final BuildInfo getBuildInfo() {
|
||||
return this.buildInfo;
|
||||
|
||||
@@ -300,7 +300,7 @@ public class ForgePreferences {
|
||||
}
|
||||
|
||||
/** @return boolean */
|
||||
public boolean getHandView() {
|
||||
public boolean isHandView() {
|
||||
return Boolean.parseBoolean(prefs.get("dev.hand.view"));
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ public class ForgePreferences {
|
||||
}
|
||||
|
||||
/** @return boolean */
|
||||
public boolean getLibraryView() {
|
||||
public boolean isLibraryView() {
|
||||
return Boolean.parseBoolean(prefs.get("dev.library.view"));
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ public class ForgePreferences {
|
||||
}
|
||||
|
||||
/** @return boolean */
|
||||
public boolean getUnlimitedLand() {
|
||||
public boolean isUnlimitedLand() {
|
||||
return Boolean.parseBoolean(prefs.get("dev.unlimited.land"));
|
||||
}
|
||||
|
||||
|
||||
@@ -317,6 +317,14 @@ public class GuiTopLevel extends JFrame implements Display, CardContainer {
|
||||
final ForgePreferences fp = Singletons.getModel().getPreferences();
|
||||
final List<ViewField> fieldViews = this.control.getMatchController().getView().getFieldViews();
|
||||
|
||||
Constant.Runtime.MILL[0] = fp.isMillingLossCondition();
|
||||
Constant.Runtime.DEV_MODE[0] = fp.isDeveloperMode();
|
||||
Constant.Runtime.UPLOAD_DRAFT[0] = fp.isUploadDraftAI();
|
||||
Constant.Runtime.RANDOM_FOIL[0] = fp.isRandCFoil();
|
||||
Constant.Runtime.HANDVIEW[0] = fp.isHandView();
|
||||
Constant.Runtime.LIBRARYVIEW[0] = fp.isLibraryView();
|
||||
Constant.Runtime.UPLOAD_DRAFT[0] = (Constant.Runtime.NET_CONN[0] ? fp.isUploadDraftAI() : false);
|
||||
|
||||
// AI field is at index [0]
|
||||
fieldViews.get(0).getLblUpkeep().setEnabled(fp.isShowPhase("phase.ai.upkeep"));
|
||||
fieldViews.get(0).getLblDraw().setEnabled(fp.isShowPhase("phase.ai.draw"));
|
||||
@@ -353,11 +361,9 @@ public class GuiTopLevel extends JFrame implements Display, CardContainer {
|
||||
* <p>
|
||||
* savePrefs.
|
||||
* </p>
|
||||
* Required by Display interface. Due to be deprecated: will be handled by
|
||||
* ControlMatchUI. Also, this functionality is already performed elsewhere
|
||||
* in the code base. Furthermore, there's a strong possibility this will
|
||||
* need bo be broken down and can't be in one place - e.g. keyboard
|
||||
* shortcuts are saved after they're edited.
|
||||
* Required by Display interface. Due to be deprecated: should be in FModel.
|
||||
* Also, this functionality is already performed elsewhere
|
||||
* in the code base.
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
|
||||
@@ -44,7 +44,7 @@ public final class Main {
|
||||
public static void main(final String[] args) {
|
||||
ExceptionHandler.registerErrorHandling();
|
||||
try {
|
||||
final FModel model = new FModel(null);
|
||||
final FModel model = new FModel();
|
||||
final FSkin skin = new FSkin(model.getPreferences().getSkin());
|
||||
final FView view = new FView(skin);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class FModelTest {
|
||||
*/
|
||||
@BeforeTest
|
||||
public final void setUp() throws FileNotFoundException {
|
||||
this.model = new FModel(null);
|
||||
this.model = new FModel();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ public class FModelTest {
|
||||
|
||||
System.err.println("log test");
|
||||
|
||||
this.model = new FModel(null);
|
||||
this.model = new FModel();
|
||||
Assert.assertNotNull(this.model, "model is not null");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user