Skip to content

Commit

Permalink
Merge branch 'master' into slim
Browse files Browse the repository at this point in the history
  • Loading branch information
HighwayofLife committed Dec 29, 2019
2 parents 5e902e1 + 79b57ee commit 1a605b3
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 33 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom: http://www.freecol.org/news/donations.html
3 changes: 2 additions & 1 deletion packaging/common/freecol.appdata.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<application>
<id type="desktop">freecol.desktop</id>
<licence>CC0</licence>
<project_license>GPL-2.0</project_license>
<metadata_license>CC0-1.0</metadata_license>
<description>
<p>
The FreeCol team aims to create an Open Source version of Colonization (released under the GPL).
Expand Down
35 changes: 20 additions & 15 deletions src/net/sf/freecol/client/control/ConnectController.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,36 @@

package net.sf.freecol.client.control;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.SwingUtilities;

import net.sf.freecol.FreeCol;
import net.sf.freecol.FreeCol;
import net.sf.freecol.client.ClientOptions;
import net.sf.freecol.client.FreeColClient;
import net.sf.freecol.client.control.FreeColClientHolder;
import net.sf.freecol.client.gui.ChoiceItem;
import net.sf.freecol.client.gui.GUI;
import net.sf.freecol.client.gui.LoadingSavegameInfo;
import net.sf.freecol.common.i18n.Messages;
import net.sf.freecol.common.io.FreeColModFile;
import net.sf.freecol.common.io.FreeColSavegameFile;
import net.sf.freecol.common.io.FreeColXMLReader;
import net.sf.freecol.common.model.Game;
import net.sf.freecol.common.model.Game.LogoutReason;
import net.sf.freecol.common.model.Player;
import net.sf.freecol.common.model.Specification;
import net.sf.freecol.common.model.StringTemplate;
import net.sf.freecol.common.model.Unit;
import net.sf.freecol.common.networking.Connection;
import static net.sf.freecol.common.util.CollectionUtils.*;
import net.sf.freecol.common.util.Utils;
import net.sf.freecol.server.FreeColServer;
import net.sf.freecol.server.FreeColServer.ServerState;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import static net.sf.freecol.common.util.CollectionUtils.alwaysTrue;
import static net.sf.freecol.common.util.CollectionUtils.makeUnmodifiableList;
import static net.sf.freecol.common.util.CollectionUtils.transform;


/**
* The controller responsible for starting a server and connecting to it.
Expand Down Expand Up @@ -351,6 +349,8 @@ public boolean startSavedGame(File file) {
// public server state from the file, and update the client
// options if possible.
final ClientOptions options = getClientOptions();


final boolean defaultSinglePlayer;
final boolean defaultPublicServer;
FreeColSavegameFile fis = null;
Expand All @@ -370,6 +370,7 @@ public boolean startSavedGame(File file) {
return false;
}
options.merge(fis);

options.fixClientOptions();
List<String> values = null;
try {
Expand Down Expand Up @@ -414,7 +415,8 @@ public boolean startSavedGame(File file) {
port = -1;
}
Messages.loadActiveModMessageBundle(options.getActiveMods(),
FreeCol.getLocale());
FreeCol.getLocale());

if (!fcc.unblockServer(port)) return false;

if (fcc.isLoggedIn()) { // Should not happen, warn and suppress
Expand All @@ -425,6 +427,9 @@ public boolean startSavedGame(File file) {
FreeColServer fcs = fcc.startServer(publicServer, singlePlayer, file,
port, serverName);
if (fcs == null) return false;

fcs.getGame().getSpecification().loadMods(options.getActiveMods());

fcc.setFreeColServer(fcs);
fcc.setSinglePlayer(true);
return requestLogin(FreeCol.getName(), fcs.getHost(), fcs.getPort());
Expand Down
2 changes: 1 addition & 1 deletion src/net/sf/freecol/client/control/InGameController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2458,7 +2458,7 @@ public boolean assignTradeRoute(Unit unit, TradeRoute tradeRoute) {
* Called from CargoPanel, TilePopup.
*
* @param unit The {@code Unit} which is to board the carrier.
* @param carrier The carrier to board.
* @param carrier The location of this Unit.
* @return True if the unit boards the carrier.
*/
public boolean boardShip(Unit unit, Unit carrier) {
Expand Down
9 changes: 8 additions & 1 deletion src/net/sf/freecol/client/gui/CanvasMouseListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,14 @@ public void mousePressed(MouseEvent e) {
}

switch (e.getButton()) {
case MouseEvent.BUTTON1: // Drag and selection
case MouseEvent.BUTTON1:
// If we have GoTo mode enabled then GoTo takes precedence
if (getGUI().isGotoStarted()) {
getGUI().performGoto(e.getX(), e.getY());
break;
}

// Drag and selection
// Enable dragging with button 1
// @see CanvasMouseMotionListener#mouseDragged
getGUI().prepareDrag(e.getX(), e.getY());
Expand Down
11 changes: 11 additions & 0 deletions src/net/sf/freecol/client/gui/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -1570,6 +1570,17 @@ public void clearGotoPath() {}
*/
public void performGoto(Tile tile) {}

/**
* Check if the user has GoTo mode enabled.
*
* Called from {@link CanvasMouseListener}.
*
* @return True if the user has toggled GoTo mode.
*/
public boolean isGotoStarted() {
return false;
}

/**
* Perform an immediate goto to a point on the map.
*
Expand Down
8 changes: 8 additions & 0 deletions src/net/sf/freecol/client/gui/SwingGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,14 @@ public void clearGotoPath() {
updateUnitPath();
}

/**
* {@inheritDoc}
*/
@Override
public boolean isGotoStarted() {
return canvas.isGotoStarted();
}

/**
* {@inheritDoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ public final class ReportCompactColonyPanel extends ReportPanel {
/** Predicate to select units that are not working. */
private static final Predicate<Unit> notWorkingPred = u ->
u.getState() != Unit.UnitState.FORTIFIED && u.getState() != Unit.UnitState.SENTRY;

private static final JLabel emptyLabel = new JLabel();

/** Container class for all the information about a colony. */
private static class ColonySummary {
Expand Down Expand Up @@ -463,7 +461,7 @@ private JButton newButton(String action, String h, ImageIcon i,

private void addTogether(List<? extends JComponent> components) {
if (components.isEmpty()) {
reportPanel.add(emptyLabel);
reportPanel.add(new JLabel());
return;
}
String layout = (components.size() > 1) ? "split " + components.size()
Expand Down Expand Up @@ -574,7 +572,7 @@ private void updateColony(ColonySummary s) {
} else {
b = null;
}
reportPanel.add((b == null) ? emptyLabel : b);
reportPanel.add((b == null) ? new JLabel() : b);

// Field: The number of potential colony tiles that need
// exploring.
Expand All @@ -589,7 +587,7 @@ private void updateColony(ColonySummary s) {
} else {
b = null;
}
reportPanel.add((b == null) ? emptyLabel : b);
reportPanel.add((b == null) ? new JLabel() : b);

// Fields: The number of existing colony tiles that would
// benefit from improvements.
Expand Down Expand Up @@ -631,7 +629,7 @@ private void updateColony(ColonySummary s) {
} else {
b = null;
}
reportPanel.add((b == null) ? emptyLabel : b);
reportPanel.add((b == null) ? new JLabel() : b);
}

// Fields: The net production of each storable+non-trade-goods
Expand Down Expand Up @@ -719,7 +717,7 @@ private void updateColony(ColonySummary s) {
default:
throw new IllegalStateException("Bogus status: " + gp.status);
}
reportPanel.add((c == null) ? emptyLabel
reportPanel.add((c == null) ? new JLabel()
: newButton(cac, Integer.toString(gp.amount), null, c, t));
}

Expand All @@ -744,7 +742,7 @@ private void updateColony(ColonySummary s) {
} else {
b = null;
}
reportPanel.add((b == null) ? emptyLabel : b);
reportPanel.add((b == null) ? new JLabel() : b);

// Field: What is currently being built (clickable if on the
// buildqueue) and the turns until it completes, including
Expand Down Expand Up @@ -828,7 +826,7 @@ private void updateColony(ColonySummary s) {
// Field: The units that could be upgraded, followed by the units
// that could be added.
if (s.improve.isEmpty() && s.want.isEmpty()) {
reportPanel.add(emptyLabel);
reportPanel.add(new JLabel());
} else {
buttons.clear();
buttons.addAll(unitButtons(s.improve, s.couldWork, s.colony));
Expand Down Expand Up @@ -956,7 +954,7 @@ private void updateCombinedColonies(List<ColonySummary> summaries) {
Set<Tile> tiles = transform(rTileSuggestions,
TileImprovementSuggestion::isExploration,
ts -> ts.tile, Collectors.toSet());
reportPanel.add((tiles.isEmpty()) ? emptyLabel
reportPanel.add((tiles.isEmpty()) ? new JLabel()
: newLabel(Integer.toString(tiles.size()), null, cAlarm,
stpld("report.colony.exploring.summary")));

Expand All @@ -969,7 +967,7 @@ private void updateCombinedColonies(List<ColonySummary> summaries) {
tiles.addAll(transform(rTileSuggestions,
matchKey(ti, ts -> ts.tileImprovementType),
ts -> ts.tile, Collectors.toSet()));
reportPanel.add((tiles.isEmpty()) ? emptyLabel
reportPanel.add((tiles.isEmpty()) ? new JLabel()
: newLabel(Integer.toString(tiles.size()), null, cAlarm,
stpld("report.colony.tile." + ti.getSuffix()
+ ".summary")));
Expand Down Expand Up @@ -997,7 +995,7 @@ private void updateCombinedColonies(List<ColonySummary> summaries) {
default:
throw new IllegalStateException("Bogus status: " + gp.status);
}
reportPanel.add((c == null) ? emptyLabel
reportPanel.add((c == null) ? new JLabel()
: newLabel(Integer.toString(gp.amount), null, c,
stpld("report.colony.production.summary")
.addNamed("%goods%", gt)));
Expand Down
2 changes: 1 addition & 1 deletion src/net/sf/freecol/common/model/Goods.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public Location getLocation() {
}

/**
* {@inheritDoc}
* @param location The Settlement that is located on this Tile
*/
@Override
public boolean setLocation(Location location) {
Expand Down
2 changes: 1 addition & 1 deletion src/net/sf/freecol/common/model/Unit.java
Original file line number Diff line number Diff line change
Expand Up @@ -4083,7 +4083,7 @@ public Location getLocation() {
* -til: While units do not contribute to tile appearance as such, if
* they move in/out of a colony the visible colony size changes.
*
* @param newLocation The new {@code Location}.
* @param newLocation The Tile where this Unit is located. Or null if its location is Europe.
* @return True if the location change succeeds.
*/
@Override
Expand Down
2 changes: 1 addition & 1 deletion src/net/sf/freecol/common/networking/DiplomacyMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public ChangeSet serverHandler(FreeColServer freeColServer,
String otherId = getStringAttribute(OTHER_ID_TAG);
if (our == null) {
cs = serverPlayer.clientError("Missing our object: " + ourId);
} if (our instanceof Unit) {
} else if (our instanceof Unit) {
ourUnit = (Unit)our;
if (!serverPlayer.owns(ourUnit)) {
cs = serverPlayer.clientError("Not our unit: " + ourId);
Expand Down

0 comments on commit 1a605b3

Please sign in to comment.