mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Prevent crash if you try to load a quest or conquest too soon
This commit is contained in:
@@ -98,7 +98,7 @@ public class ConquestMapScreen extends FScreen {
|
||||
if (y + rowHeight > 0) {
|
||||
g.drawImage(FSkinImage.PLANAR_PORTAL, 0, y, w, rowHeight);
|
||||
if (planeData.getBossResult() == 0) { //draw overlay if boss hasn't been beaten yet
|
||||
if (planeData.getEventResult(regionCount - 1, rows - 1, (cols - 1) / 2) > 0) {
|
||||
if (planeData.getEventResult(regionCount - 1, rows - 1, Region.PORTAL_COL) > 0) {
|
||||
color = UNCONQUERED_COLOR;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -84,6 +84,7 @@ public class LoadConquestScreen extends LaunchScreen {
|
||||
public void onActivate() {
|
||||
lblOldConquests.setText("Loading Existing Conquests...");
|
||||
lstConquests.clear();
|
||||
btnStart.setEnabled(false);
|
||||
revalidate();
|
||||
|
||||
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||
@@ -130,7 +131,8 @@ public class LoadConquestScreen extends LaunchScreen {
|
||||
@Override
|
||||
public void run() {
|
||||
lblOldConquests.setText("Old conquest data? Put into \""
|
||||
+ ForgeConstants.CONQUEST_SAVE_DIR.replace('\\', '/') + "\" and restart Forge.");
|
||||
+ ForgeConstants.CONQUEST_SAVE_DIR + "\" and restart Forge.");
|
||||
btnStart.setEnabled(true);
|
||||
revalidate();
|
||||
lstConquests.scrollIntoView(lstConquests.selectedIndex);
|
||||
}
|
||||
@@ -172,8 +174,10 @@ public class LoadConquestScreen extends LaunchScreen {
|
||||
}
|
||||
|
||||
private void changeConquest() {
|
||||
FModel.getConquestPreferences().setPref(CQPref.CURRENT_CONQUEST,
|
||||
lstConquests.getSelectedConquest().getName() + ".dat");
|
||||
ConquestData conquest = lstConquests.getSelectedConquest();
|
||||
if (conquest == null) { return; }
|
||||
|
||||
FModel.getConquestPreferences().setPref(CQPref.CURRENT_CONQUEST, conquest.getName() + ".dat");
|
||||
FModel.getConquestPreferences().save();
|
||||
ConquestMenu.launchPlanarConquest(LaunchReason.LoadConquest);
|
||||
}
|
||||
|
||||
@@ -85,6 +85,7 @@ public class LoadQuestScreen extends LaunchScreen {
|
||||
public void onActivate() {
|
||||
lblOldQuests.setText("Loading Existing Quests...");
|
||||
lstQuests.clear();
|
||||
btnStart.setEnabled(false);
|
||||
revalidate();
|
||||
|
||||
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||
@@ -131,7 +132,8 @@ public class LoadQuestScreen extends LaunchScreen {
|
||||
@Override
|
||||
public void run() {
|
||||
lblOldQuests.setText("Old quest data? Put into \""
|
||||
+ ForgeConstants.QUEST_SAVE_DIR.replace('\\', '/') + "\" and restart Forge.");
|
||||
+ ForgeConstants.QUEST_SAVE_DIR + "\" and restart Forge.");
|
||||
btnStart.setEnabled(true);
|
||||
revalidate();
|
||||
lstQuests.scrollIntoView(lstQuests.selectedIndex);
|
||||
}
|
||||
@@ -174,8 +176,10 @@ public class LoadQuestScreen extends LaunchScreen {
|
||||
|
||||
/** Changes between quest data files. */
|
||||
private void changeQuest() {
|
||||
FModel.getQuestPreferences().setPref(QPref.CURRENT_QUEST,
|
||||
lstQuests.getSelectedQuest().getName() + ".dat");
|
||||
QuestData quest = lstQuests.getSelectedQuest();
|
||||
if (quest == null) { return; }
|
||||
|
||||
FModel.getQuestPreferences().setPref(QPref.CURRENT_QUEST, quest.getName() + ".dat");
|
||||
FModel.getQuestPreferences().save();
|
||||
QuestMenu.launchQuestMode(LaunchReason.LoadQuest);
|
||||
}
|
||||
|
||||
@@ -46,13 +46,10 @@ public class ConquestLocation {
|
||||
|
||||
public void travelToPlane(ConquestPlane plane0) {
|
||||
if (plane == plane0) { return; }
|
||||
if (plane == null /*|| plane0 follows plane in travel order */) {
|
||||
regionIndex = -1; //start on bottom portal row
|
||||
}
|
||||
else {
|
||||
regionIndex = plane.getRegions().size(); //start on top portal row
|
||||
}
|
||||
plane = plane0;
|
||||
regionIndex = -1; //start on bottom portal row
|
||||
row = 0;
|
||||
col = Region.PORTAL_COL;
|
||||
}
|
||||
|
||||
public List<ConquestLocation> getNeighbors() {
|
||||
@@ -69,8 +66,7 @@ public class ConquestLocation {
|
||||
else if (regionIndex0 < regionCount - 1) {
|
||||
locations.add(new ConquestLocation(plane, regionIndex0 + 1, 0, col0));
|
||||
}
|
||||
else if (regionIndex0 == regionCount - 1 && col0 == (Region.COLS_PER_REGION - 1) / 2) {
|
||||
//top portal only available from center column of topmost row
|
||||
else if (regionIndex0 == regionCount - 1 && col0 == Region.PORTAL_COL) {
|
||||
locations.add(new ConquestLocation(plane, regionCount, 0, col0));
|
||||
}
|
||||
|
||||
@@ -81,8 +77,7 @@ public class ConquestLocation {
|
||||
else if (regionIndex0 > 0) {
|
||||
locations.add(new ConquestLocation(plane, regionIndex0 - 1, Region.ROWS_PER_REGION - 1, col0));
|
||||
}
|
||||
else if (regionIndex0 == 0 && col0 == (Region.COLS_PER_REGION - 1) / 2) {
|
||||
//bottom portal only available from center column of bottommost row
|
||||
else if (regionIndex0 == 0 && col0 == Region.PORTAL_COL) {
|
||||
locations.add(new ConquestLocation(plane, -1, 0, col0));
|
||||
}
|
||||
|
||||
|
||||
@@ -274,6 +274,7 @@ public enum ConquestPlane {
|
||||
public static class Region {
|
||||
public static final int ROWS_PER_REGION = 3;
|
||||
public static final int COLS_PER_REGION = 3;
|
||||
public static final int PORTAL_COL = (COLS_PER_REGION - 1) / 2;
|
||||
|
||||
private final String name;
|
||||
private final String artCardName;
|
||||
|
||||
Reference in New Issue
Block a user