Merge remote-tracking branch 'upstream/master' into travis_merge_test

This commit is contained in:
Travis CI User 2018-03-22 19:28:11 +00:00
commit 080a2bbe23
14 changed files with 127 additions and 134 deletions

View File

@ -2320,9 +2320,9 @@ payForBuilding.disabled=A capacidade de pagar para concluir uma construção est
payForBuilding.text=Gostaria de pagar %amount% {{plural:%amount%|one=moeda|other=moedas|default=moedas}} de ouro para concluir este edifício?
renameColony.text=Sugira um novo nome para a nossa colónia, por favor:
renameUnit.text=Sugira um novo nome para a nossa unidade, por favor:
scoutSettlement.expertScout=Nós apreciámos muito os contos maravilhosos do seu batedor. Portanto, iremos fornecer-vos ajuda para as vossas futuras explorações. O seu batedor tornou-se %unit%.
scoutSettlement.speakBeads=Bem-vindo, viajante. Por favor, leve estas valiosas contas (no valor de %amount% de ouro) de volta ao seu chefe como sinal de paz.
scoutSettlement.speakDie=Quebrou os ritos sagrados da tribo! Vamos amarrá-lo para praticar tiro ao alvo.
scoutSettlement.expertScout=Gostámos muito das histórias que o seu batedor nos contou, por isso vamos fornecer guias para ajudar nas suas explorações futuras. O seu batedor tornou-se %unit%.
scoutSettlement.speakBeads=Bem-vindo, viajante. No regresso, leve estas contas valiosas (no valor de %amount% de ouro) ao seu chefe como sinal de paz.
scoutSettlement.speakDie=Quebrou os ritos sagrados da tribo! Vamos amarrá-lo e usá-lo para tiro ao alvo.
scoutSettlement.speakNothing=Ficamos sempre satisfeitos por receber viajantes %nation%.
scoutSettlement.speakTales=Recebemos com agrado viajantes de terras longínquas. Venham, sentem-se junto à fogueira e contar-vos-emos histórias de terras vizinhas.
sellProposition.text=Quer vender algumas mercadorias?

View File

@ -2604,7 +2604,7 @@ server.reject=Сервер не может этого сделать.
server.timeOut=Вышло время соединения с сервером.
server.userNameInUse=Имя пользователя %name% уже используется.
server.userNameNotPresent=Указанное имя пользователя %name% отсутствует в этой игре, но это: %names%.
-# Fuzzy
# Fuzzy
server.wrongFreeColVersion=Версии клиента и сервера FreeCol не совпадают.
buildColony.others={{tag:country|%nation%}} основали новую колонию %colony% в %region%.
cashInTreasureTrain.colonial=Сундуки сокровищ с %amount% золота прибыли в Европу. %cashInAmount% золота перечислено вам.

View File

@ -74,25 +74,29 @@ public final class CanvasMouseListener extends FreeColClientHolder
if (tile == null) return;
// Only process events that could not have been gotos.
final Unit unit = getGUI().getActiveUnit();
final GUI gui = getGUI();
final Unit active = gui.getActiveUnit();
if (e.getClickCount() > 1
|| unit == null
|| unit.getTile() == tile
|| active == null
|| active.getTile() == tile
|| !canvas.isDrag(e.getX(), e.getY())) {
if (tile.hasSettlement()) {
getGUI().showTileSettlement(tile);
} else if (unit == null || unit.getTile() != tile) {
if (!tile.isExplored()) {
gui.setSelectedTile(tile);
gui.setViewMode(GUI.VIEW_TERRAIN_MODE);
} if (tile.hasSettlement()) {
gui.showTileSettlement(tile);
} else if (active == null || active.getTile() != tile) {
Unit other = tile.getFirstUnit();
if (other != null && getMyPlayer().owns(other)) {
getGUI().setActiveUnit(other);
getGUI().setViewMode(GUI.MOVE_UNITS_MODE);
gui.setActiveUnit(other);
gui.setViewMode(GUI.MOVE_UNITS_MODE);
} else {
getGUI().setSelectedTile(tile);
getGUI().setViewMode(GUI.VIEW_TERRAIN_MODE);
gui.setSelectedTile(tile);
gui.setViewMode(GUI.VIEW_TERRAIN_MODE);
}
} else {
getGUI().setSelectedTile(tile);
getGUI().setViewMode(GUI.VIEW_TERRAIN_MODE);
gui.setSelectedTile(tile);
gui.setViewMode(GUI.VIEW_TERRAIN_MODE);
}
}
}

View File

@ -1672,11 +1672,8 @@ public class GUI extends FreeColClientHolder {
* Set the active unit.
*
* @param unit The {@code Unit} to activate.
* @return True if the focus was set.
*/
public boolean setActiveUnit(Unit unit) {
return false;
}
public void setActiveUnit(Unit unit) {}
/**
* Center the active unit.
@ -1696,11 +1693,8 @@ public class GUI extends FreeColClientHolder {
* Set the selected tile.
*
* @param tile The new selected {@code Tile}.
* @return True if setting the tile changes the focus.
*/
public boolean setSelectedTile(Tile tile) {
return true;
}
public void setSelectedTile(Tile tile) {}
// Zoom controls

View File

@ -256,6 +256,42 @@ public final class MapViewer extends FreeColClientHolder {
}
}
/**
* Gets the active unit.
*
* @return The {@code Unit}.
*/
public Unit getActiveUnit() {
return this.activeUnit;
}
/**
* Sets the active unit.
*
* @param activeUnit The new active {@code Unit}.
*/
public void setActiveUnit(Unit activeUnit) {
this.activeUnit = activeUnit;
}
/**
* Gets the selected tile.
*
* @return The {@code Tile} selected.
*/
public Tile getSelectedTile() {
return this.selectedTile;
}
/**
* Sets the selected tile.
*
* @param tile The new selected {@code Tile}.
*/
public void setSelectedTile(Tile tile) {
this.selectedTile = tile;
}
/**
* Centers the map on the selected unit.
*/
@ -918,56 +954,6 @@ public final class MapViewer extends FreeColClientHolder {
&& tile.getX() >= leftColumn && tile.getX() <= rightColumn;
}
/**
* Gets the selected tile.
*
* @return The {@code Tile} selected.
*/
Tile getSelectedTile() {
return selectedTile;
}
/**
* Selects the tile at the specified position. There are two
* possible cases:
*
* <ol>
* <li>If the tile contains a unit that can become active, then
* that unit will be set as the active unit.
* <li>If not, the {@code selectedTile} will become the map focus.
* </ol>
*
* If a unit is active and is located on the selected tile,
* then nothing (except perhaps a map reposition) will happen.
*
* @param newTile The {@code Tile}, the tile to be selected
* @return True if the focus was set.
* @see #getSelectedTile
* @see #setActiveUnit
* @see #setFocus(Tile)
*/
boolean setSelectedTile(Tile newTile) {
Tile oldTile = this.selectedTile;
boolean ret = false;
selectedTile = newTile;
// Check for refocus
if (!onScreen(newTile)
|| getClientOptions().getBoolean(ClientOptions.ALWAYS_CENTER)) {
gui.setFocus(newTile);
ret = true;
} else {
if (oldTile != null) {
gui.refreshTile(oldTile);
}
if (newTile != null) {
gui.refreshTile(newTile);
}
}
return ret;
}
/**
* Gets the unit that should be displayed on the given tile.
*
@ -1009,42 +995,6 @@ public final class MapViewer extends FreeColClientHolder {
return result;
}
/**
* Gets the active unit.
*
* @return The {@code Unit}.
* @see #setActiveUnit
*/
Unit getActiveUnit() {
return activeUnit;
}
/**
* Sets the active unit.
*
* @param activeUnit The new active {@code Unit}.
* @return True if the focus was set.
*/
boolean setActiveUnit(Unit activeUnit) {
// Don't select a unit with zero moves left. -sjm
// The user might what to check the status of a unit - SG
Tile tile = (activeUnit == null) ? null : activeUnit.getTile();
this.activeUnit = activeUnit;
if (activeUnit == null || tile == null) {
gui.getCanvas().stopGoto();
} else {
changeViewMode(GUI.MOVE_UNITS_MODE);
updateCurrentPathForActiveUnit();
if (!gui.setSelectedTile(tile)
|| getClientOptions().getBoolean(ClientOptions.JUMP_TO_ACTIVE_UNIT)) {
gui.setFocus(tile);
return true;
}
}
return false;
}
/**
* Checks if there is currently a goto operation on the mapboard.
*

View File

@ -174,6 +174,26 @@ public class SwingGUI extends GUI {
return null;
}
/**
* Internal version of setSelectedTile allowing focus override.
*
* @param newTile The new {@code Tile} to select.
* @param refocus If true, always refocus.
*/
private void setSelectedTile(Tile newTile, boolean refocus) {
final Tile oldTile = getSelectedTile();
refocus = newTile != null && (refocus || !mapViewer.onScreen(newTile)
|| getClientOptions().getBoolean(ClientOptions.ALWAYS_CENTER));
if (refocus) {
setFocus(newTile);
} else {
if (oldTile != null) refreshTile(oldTile);
if (newTile != null) refreshTile(newTile);
}
mapViewer.setSelectedTile(newTile);
}
// TODO
private void setFocusImmediately(Tile tileToFocus) {
mapViewer.setFocus(tileToFocus);
Dimension size = canvas.getSize();
@ -957,14 +977,34 @@ public class SwingGUI extends GUI {
* {@inheritDoc}
*/
@Override
public boolean setActiveUnit(Unit unit) {
boolean result = mapViewer.setActiveUnit(unit);
public void setActiveUnit(Unit unit) {
final Unit old = getActiveUnit();
Tile tile = null;
if (unit == null || (tile = unit.getTile()) == null) {
canvas.stopGoto();
}
mapViewer.setActiveUnit(unit);
// Automatic mode switch when switching to/from null active unit
if (unit != null && old == null) {
setViewMode(GUI.MOVE_UNITS_MODE);
// Bring the selected tile along with the unit
if (tile != getSelectedTile()) {
setSelectedTile(tile, tile != null
&& getClientOptions().getBoolean(ClientOptions.JUMP_TO_ACTIVE_UNIT));
}
} else if (unit == null && old != null) {
tile = getSelectedTile();
if (tile != null) setViewMode(GUI.VIEW_TERRAIN_MODE);
}
updateMapControls();
updateMenuBar();
// TODO: why do we have to refresh the entire canvas?
if (unit != null && !getMyPlayer().owns(unit)) {
canvas.refresh();
}
return result;
}
/**
@ -990,11 +1030,10 @@ public class SwingGUI extends GUI {
* {@inheritDoc}
*/
@Override
public boolean setSelectedTile(Tile newTileToSelect) {
boolean result = mapViewer.setSelectedTile(newTileToSelect);
public void setSelectedTile(Tile newTile) {
setSelectedTile(newTile, false);
updateMapControls();
updateMenuBar();
return result;
}

View File

@ -242,8 +242,7 @@ public final class EditSettlementDialog extends FreeColDialog<IndianSettlement>
Player owner = is.getOwner();
UnitType brave = spec.getDefaultUnitType(owner);
for (int index = 0; index < numberOfUnits; index++) {
is.add(new ServerUnit(is.getGame(),
is, owner, brave));
is.add(new ServerUnit(is.getGame(), is, owner, brave));
}
} else if (numberOfUnits < 0) {
List<Unit> unitList

View File

@ -638,7 +638,7 @@ public class EuropeanAIPlayer extends MissionAIPlayer {
int aPrice = player.getMonarch().loadMercenaries(air, aMercs);
if (aPrice > 0) {
List<Unit> mercs = ((ServerPlayer)player)
.createUnits(aMercs, europe);
.createUnits(aMercs, europe, air);
for (Unit u : mercs) {
AIUnit aiu = getAIUnit(u);
if (aiu == null) continue; // Can not happen

View File

@ -376,11 +376,11 @@ public final class InGameController extends Controller {
// For now, do not fail completely
}
List<Unit> landUnits = refPlayer.createUnits(exf.getLandUnitsList(),
europe);//-vis: safe!map
europe, null);//-vis: safe!map
List<Unit> navalUnits = refPlayer.createUnits(exf.getNavalUnitsList(),
europe);//-vis: safe!map
europe, random);//-vis: safe!map
List<Unit> leftOver = refPlayer.loadShips(landUnits, navalUnits,
random);//-vis: safe!map
random);//-vis: safe!map
if (!leftOver.isEmpty()) {
// Should not happen, make this return null one day
logger.warning("Failed to board REF units: "
@ -760,7 +760,7 @@ public final class InGameController extends Controller {
int warGold = 0;
if (!warSupport.isEmpty()) {
serverPlayer.createUnits(warSupport,
serverPlayer.getEurope());//-vis: safe, Europe
serverPlayer.getEurope(), random);//-vis: safe, Europe
warGold = spec.getInteger(GameOptions.WAR_SUPPORT_GOLD);
warGold += (warGold/10) * (randomInt(logger, "War support gold",
random, 5) - 2);
@ -789,7 +789,7 @@ public final class InGameController extends Controller {
List<AbstractUnit> support = monarch.getSupport(random, sea);
if (support.isEmpty()) break;
serverPlayer.createUnits(support,
serverPlayer.getEurope());//-vis: safe, Europe
serverPlayer.getEurope(), random);//-vis: safe, Europe
cs.add(See.only(serverPlayer), serverPlayer.getEurope());
cs.add(See.only(serverPlayer),
new MonarchActionMessage(action, StringTemplate

View File

@ -884,8 +884,10 @@ public class SimpleMapGenerator implements MapGenerator {
// In debug mode give each player a few more units and a colony.
UnitType unitType = spec.getUnitType("model.unit.galleon");
Unit galleon = new ServerUnit(game, startTile, player, unitType);
galleon.setName(player.getNameForUnit(unitType, random));
unitType = spec.getUnitType("model.unit.privateer");
Unit privateer = new ServerUnit(game, startTile, player, unitType);
privateer.setName(player.getNameForUnit(unitType, random));
((ServerPlayer)player).exploreForUnit(privateer);
unitType = spec.getUnitType("model.unit.freeColonist");
new ServerUnit(game, galleon, player, unitType);

View File

@ -83,6 +83,7 @@ public class MonarchSession extends Session {
* Primitive level to finishing the session with the given result.
*
* @param result The result of the session, null means ignored.
* @param random A pseudo-random number source.
* @param cs A {@code ChangeSet} to update.
*/
private void completeInternal(Boolean result, ChangeSet cs) {
@ -98,7 +99,7 @@ public class MonarchSession extends Session {
if (result == null) {
serverPlayer.ignoreMercenaries(cs);
} else if (result) {
serverPlayer.csAddMercenaries(mercenaries, price, cs);
serverPlayer.csAddMercenaries(mercenaries, price, null, cs);
}
break;
default:

View File

@ -155,6 +155,7 @@ public class ServerColony extends Colony implements TurnTaker {
UnitType type = (UnitType)buildQueue.getCurrentlyBuilding();
Unit unit = new ServerUnit(getGame(), getTile(), owner,
type);//-vis: safe, within colony
unit.setName(owner.getNameForUnit(type, random));
if (unit.hasAbility(Ability.BORN_IN_COLONY)) {
cs.addMessage(owner,
new ModelMessage(MessageType.UNIT_ADDED,

View File

@ -1127,10 +1127,11 @@ public class ServerPlayer extends Player implements TurnTaker {
* create.
* @param location The {@code Location} where the units will
* be created.
* @param random A pseudo-random number source.
* @return A list of units created.
*/
public List<Unit> createUnits(List<AbstractUnit> abstractUnits,
Location location) {
Location location, Random random) {
final Game game = getGame();
final Specification spec = game.getSpecification();
List<Unit> units = new ArrayList<>();
@ -1150,6 +1151,7 @@ public class ServerPlayer extends Player implements TurnTaker {
for (int i = 0; i < au.getNumber(); i++) {
ServerUnit su = new ServerUnit(game, location, this, type,
role);//-vis(this)
su.setName(this.getNameForUnit(type, random));
units.add(su);
lb.add(' ', su);
}
@ -1974,7 +1976,7 @@ outer: for (Effect effect : effects) {
List<AbstractUnit> units = father.getUnitList();
if (units != null && !units.isEmpty() && europe != null) {
createUnits(units, europe);//-vis: safe, Europe
createUnits(units, europe, random);//-vis: safe, Europe
europeDirty = true;
}
@ -4138,7 +4140,7 @@ outer: for (Effect effect : effects) {
* @param cs A {@code ChangeSet} to update.
*/
public void csAddMercenaries(List<AbstractUnit> mercs, int price,
ChangeSet cs) {
Random random, ChangeSet cs) {
if (checkGold(price)) {
final Specification spec = getSpecification();
final Predicate<AbstractUnit> isNaval = au ->
@ -4149,12 +4151,12 @@ outer: for (Effect effect : effects) {
Tile dst;
if (naval.isEmpty()) { // Deliver to first settlement
dst = first(getColonies()).getTile();
createUnits(mercs, dst);//-vis: safe, in colony
createUnits(mercs, dst, null);//-vis: safe, in colony
cs.add(See.only(this), dst);
} else { // Let them sail in
dst = getEntryTile();
loadShips(createUnits(transform(mercs, isLand), null),
createUnits(naval, dst),//-vis
loadShips(createUnits(transform(mercs, isLand), null, null),
createUnits(naval, dst, random),//-vis
null);
invalidateCanSeeTiles();//+vis(this)
cs.add(See.perhaps(), dst);
@ -4524,9 +4526,9 @@ outer: for (Effect effect : effects) {
// Create the force.
Force ivf = getMonarch().getInterventionForce();
List<Unit> land = createUnits(ivf.getLandUnitsList(),
entry);//-vis(this)
entry, random);//-vis(this)
List<Unit> naval = createUnits(ivf.getNavalUnitsList(),
entry);//-vis(this)
entry, random);//-vis(this)
List<Unit> leftOver = loadShips(land, naval, random);//-vis(this)
for (Unit unit : leftOver) {
// no use for left over units

View File

@ -134,6 +134,7 @@ public class ServerUnit extends Unit implements TurnTaker {
game.getSpecification().getDefaultRole());
final Specification spec = getSpecification();
if (template.getName() != null) setName(template.getName());
setNationality(template.getNationality());
setEthnicity(template.getEthnicity());
workLeft = template.getWorkLeft();
@ -166,8 +167,8 @@ public class ServerUnit extends Unit implements TurnTaker {
super(game);
final Specification spec = getSpecification();
this.type = type;
this.owner = owner;
this.type = type;
this.state = UnitState.ACTIVE; // placeholder
this.role = getSpecification().getDefaultRole(); // placeholder
this.location = null;