Skip to content

Commit ceca64e

Browse files
committed
Changes the default for most confirm dialogs to OK. Operations that we consider too destructive should have Cancel as the default.
1 parent afc077e commit ceca64e

File tree

5 files changed

+38
-35
lines changed

5 files changed

+38
-35
lines changed

Diff for: src/net/sf/freecol/client/FreeColClient.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ public boolean unblockServer(int port) {
818818
final FreeColServer freeColServer = getFreeColServer();
819819
if (freeColServer != null ) {
820820
if (!getGUI().confirm("stopServer.text", "stopServer.yes",
821-
"stopServer.no")) return false;
821+
"stopServer.no", true)) return false;
822822
stopServer();
823823
}
824824
return true;
@@ -981,7 +981,7 @@ public void skipTurns(int turns) {
981981
* Quits the application.
982982
*/
983983
public void askToQuit() {
984-
if (gui.confirm("quitDialog.areYouSure.text", "ok", "cancel")) {
984+
if (gui.confirm("quitDialog.areYouSure.text", "ok", "cancel", false)) {
985985
Player player = getMyPlayer();
986986
if (player == null) { // If no player, must be already logged out
987987
quit();
@@ -996,7 +996,7 @@ public void askToQuit() {
996996
* Retire from the game.
997997
*/
998998
public void retire() {
999-
if (gui.confirm("retireDialog.areYouSure.text", "ok", "cancel")) {
999+
if (gui.confirm("retireDialog.areYouSure.text", "ok", "cancel", false)) {
10001000
final Player player = getMyPlayer();
10011001
player.changePlayerType(Player.PlayerType.RETIRED);
10021002
final boolean highScore = askServer().retire();

Diff for: src/net/sf/freecol/client/control/InGameController.java

+16-16
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,7 @@ private boolean moveDisembark(Unit unit, final Direction direction) {
17011701
for (Unit u : disembarkable) changeState(u, UnitState.ACTIVE);
17021702
if (disembarkable.size() == 1) {
17031703
if (getGUI().confirm(tile, StringTemplate.key("disembark.text"),
1704-
disembarkable.get(0), "ok", "cancel")) {
1704+
disembarkable.get(0), "ok", "cancel", true)) {
17051705
moveDirection(disembarkable.get(0), direction, false);
17061706
}
17071707
} else {
@@ -1787,7 +1787,7 @@ private boolean moveExplore(Unit unit, Direction direction) {
17871787
final Tile tile = now.getNeighbourOrNull(direction);
17881788
if (!getGUI().confirm(now,
17891789
StringTemplate.key("exploreLostCityRumour.text"), unit,
1790-
"exploreLostCityRumour.yes", "exploreLostCityRumour.no")) {
1790+
"exploreLostCityRumour.yes", "exploreLostCityRumour.no", true)) {
17911791
if (unit.getDestination() != null) askClearGotoOrders(unit);
17921792
return false;
17931793
}
@@ -1796,7 +1796,7 @@ private boolean moveExplore(Unit unit, Direction direction) {
17961796
if (tile.getLostCityRumour().getType() == LostCityRumour.RumourType.MOUNDS
17971797
&& !getGUI().confirm(now,
17981798
StringTemplate.key("exploreMoundsRumour.text"), unit,
1799-
"exploreLostCityRumour.yes", "exploreLostCityRumour.no")) {
1799+
"exploreLostCityRumour.yes", "exploreLostCityRumour.no", true)) {
18001800
askServer().declineMounds(unit, direction); // LCR goes away
18011801
return false;
18021802
}
@@ -1835,7 +1835,7 @@ private boolean moveHighSeas(Unit unit, Direction direction) {
18351835
} else if (getGUI().confirm(oldTile, StringTemplate
18361836
.template("highseas.text")
18371837
.addAmount("%number%", unit.getSailTurns()),
1838-
unit, "highseas.yes", "highseas.no")) {
1838+
unit, "highseas.yes", "highseas.no", true)) {
18391839
return moveTowardEurope(unit, unit.getOwner().getEurope());
18401840
}
18411841
}
@@ -1871,7 +1871,7 @@ && askServer().askSkill(unit, direction)) {
18711871
} else if (getGUI().confirm(unit.getTile(), StringTemplate
18721872
.template("learnSkill.text")
18731873
.addNamed("%skill%", skill),
1874-
unit, "learnSkill.yes", "learnSkill.no")) {
1874+
unit, "learnSkill.yes", "learnSkill.no", true)) {
18751875
if (askServer().learnSkill(unit, direction)) {
18761876
if (unit.isDisposed()) {
18771877
showInformationPanel(is, "learnSkill.die");
@@ -2549,7 +2549,7 @@ private boolean unloadUnitAtStop(Unit unit, LogBuilder lb) {
25492549
.addAmount("%amount%", toUnload - atStop)
25502550
.addNamed("%goods%", goods);
25512551
if (!getGUI().confirm(unit.getTile(), template,
2552-
unit, "yes", "no")) {
2552+
unit, "yes", "no", true)) {
25532553
if (atStop == 0) continue;
25542554
amount = atStop;
25552555
}
@@ -2813,7 +2813,7 @@ public boolean buildColony(Unit unit) {
28132813
StringTemplate warnings = tile.getBuildColonyWarnings(unit);
28142814
if (!warnings.isEmpty()
28152815
&& !getGUI().confirm(tile, warnings, unit,
2816-
"buildColony.yes", "buildColony.no")) {
2816+
"buildColony.yes", "buildColony.no", true)) {
28172817
return false;
28182818
}
28192819
}
@@ -3038,7 +3038,7 @@ public boolean checkCashInTreasureTrain(Unit unit) {
30383038
.addAmount("%fee%", percent);
30393039
}
30403040
if (!getGUI().confirm(unit.getTile(), template, unit,
3041-
"accept", "reject")) return false;
3041+
"accept", "reject", true)) return false;
30423042
}
30433043

30443044
UnitWas unitWas = new UnitWas(unit);
@@ -3153,7 +3153,7 @@ public boolean clearOrders(Unit unit) {
31533153
&& !getGUI().confirm(unit.getTile(), StringTemplate
31543154
.template("clearOrders.text")
31553155
.addAmount("%turns%", unit.getWorkTurnsLeft()),
3156-
unit, "ok", "cancel")) {
3156+
unit, "ok", "cancel", true)) {
31573157
return false;
31583158
}
31593159

@@ -3194,7 +3194,7 @@ public boolean clearSpeciality(Unit unit) {
31943194
.addStringTemplate("%oldUnit%",
31953195
unit.getLabel(Unit.UnitLabelType.NATIONAL))
31963196
.addNamed("%unit%", newType),
3197-
unit, "ok", "cancel")) {
3197+
unit, "ok", "cancel", true)) {
31983198
return false;
31993199
}
32003200

@@ -3358,7 +3358,7 @@ public boolean disbandUnit(Unit unit) {
33583358
&& !getGUI().confirmLeaveColony(unit)) return false;
33593359
final Tile tile = (getGUI().isPanelShowing()) ? null : unit.getTile();
33603360
if (!getGUI().confirm(tile, StringTemplate.key("disbandUnit.text"),
3361-
unit, "disbandUnit.yes", "cancel"))
3361+
unit, "disbandUnit.yes", "cancel", true))
33623362
return false;
33633363

33643364
// Try to disband
@@ -3720,7 +3720,7 @@ public void inciteHandler(Unit unit, IndianSettlement is, Player enemy,
37203720
.template("missionarySettlement.inciteConfirm")
37213721
.addStringTemplate("%enemy%", enemy.getNationLabel())
37223722
.addAmount("%amount%", gold),
3723-
unit, "yes", "no")) {
3723+
unit, "yes", "no", true)) {
37243724
askServer().incite(unit, is, enemy, gold);
37253725
}
37263726
});
@@ -4649,7 +4649,7 @@ public void reconnect() {
46494649
final FreeColClient fcc = getFreeColClient();
46504650
invokeLater(() -> {
46514651
if (getGUI().confirm("reconnect.text",
4652-
"reconnect.no", "reconnect.yes")) {
4652+
"reconnect.no", "reconnect.yes", false)) {
46534653
logger.finest("Reconnect quit.");
46544654
fcc.getConnectController().requestLogout(LogoutReason.QUIT);
46554655
} else {
@@ -4826,7 +4826,7 @@ public boolean saveGame() {
48264826
if (!getClientOptions().getBoolean(ClientOptions.CONFIRM_SAVE_OVERWRITE)
48274827
|| !file.exists()
48284828
|| getGUI().confirm("saveConfirmationDialog.areYouSure.text",
4829-
"ok", "cancel")) {
4829+
"ok", "cancel", false)) {
48304830
FreeColDirectories.setSavegameFile(file.getPath());
48314831
return saveGame(file);
48324832
}
@@ -5054,14 +5054,14 @@ private boolean setDead() {
50545054
} else {
50555055
if (player.getPlayerType() != Player.PlayerType.UNDEAD
50565056
&& getGUI().confirm("defeatedSinglePlayer.text",
5057-
"defeatedSinglePlayer.yes", "quit")) {
5057+
"defeatedSinglePlayer.yes", "quit", true)) {
50585058
askServer().enterRevengeMode();
50595059
return true;
50605060
}
50615061
reason = LogoutReason.DEFEATED;
50625062
}
50635063
} else {
5064-
if (!getGUI().confirm("defeated.text", "defeated.yes", "quit")) {
5064+
if (!getGUI().confirm("defeated.text", "defeated.yes", "quit", true)) {
50655065
reason = LogoutReason.DEFEATED;
50665066
}
50675067
}

Diff for: src/net/sf/freecol/client/gui/GUI.java

+17-14
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,13 @@ public GUI(FreeColClient freeColClient) {
137137
* @param textKey A string to use as the message key.
138138
* @param okKey A key for the message on the "ok" button.
139139
* @param cancelKey A key for the message on the "cancel" button.
140+
* @param defaultOk The OK button gets the focus if {@code true}, else
141+
* it's the cancel button that gets focused.
140142
* @return True if the "ok" button was selected.
141143
*/
142-
public final boolean confirm(String textKey,
143-
String okKey, String cancelKey) {
144+
public final boolean confirm(String textKey, String okKey, String cancelKey, boolean defaultOk) {
144145
return confirm(null, StringTemplate.key(textKey), (ImageIcon)null,
145-
okKey, cancelKey, false);
146+
okKey, cancelKey, defaultOk);
146147
}
147148

148149
/**
@@ -156,7 +157,7 @@ public final boolean confirm(String textKey,
156157
public final boolean confirm(StringTemplate template,
157158
String okKey, String cancelKey) {
158159
return confirm(null, template, (ImageIcon)null,
159-
okKey, cancelKey, false);
160+
okKey, cancelKey, true);
160161
}
161162

162163
/**
@@ -174,7 +175,7 @@ public final boolean confirm(Tile tile, StringTemplate template,
174175
String okKey, String cancelKey) {
175176
ImageIcon icon = new ImageIcon(getFixedImageLibrary()
176177
.getScaledGoodsTypeImage(goodsType));
177-
return confirm(tile, template, icon, okKey, cancelKey, false);
178+
return confirm(tile, template, icon, okKey, cancelKey, true);
178179
}
179180

180181
/**
@@ -192,7 +193,7 @@ public final boolean confirm(Tile tile, StringTemplate template,
192193
String okKey, String cancelKey) {
193194
ImageIcon icon = new ImageIcon(getFixedImageLibrary()
194195
.getScaledSettlementImage(settlement));
195-
return confirm(tile, template, icon, okKey, cancelKey, false);
196+
return confirm(tile, template, icon, okKey, cancelKey, true);
196197
}
197198

198199
/**
@@ -203,13 +204,15 @@ public final boolean confirm(Tile tile, StringTemplate template,
203204
* @param unit A unit to make an icon for the dialog from.
204205
* @param okKey A key for the "ok" button.
205206
* @param cancelKey A key for the "cancel" button.
207+
* @param defaultOk The OK button gets the focus if {@code true}, else
208+
* it's the cancel button that gets focused.
206209
* @return True if the "ok" button was selected.
207210
*/
208211
public final boolean confirm(Tile tile, StringTemplate template, Unit unit,
209-
String okKey, String cancelKey) {
212+
String okKey, String cancelKey, boolean defaultOk) {
210213
ImageIcon icon = new ImageIcon(getFixedImageLibrary()
211214
.getScaledUnitImage(unit));
212-
return confirm(tile, template, icon, okKey, cancelKey, false);
215+
return confirm(tile, template, icon, okKey, cancelKey, defaultOk);
213216
}
214217

215218
/**
@@ -246,7 +249,7 @@ public boolean confirmAbandonEducation(Unit unit, boolean leaveColony) {
246249
: null;
247250
return template == null
248251
|| confirm(unit.getTile(), template, unit,
249-
"abandonEducation.yes", "abandonEducation.no");
252+
"abandonEducation.yes", "abandonEducation.no", true);
250253
}
251254

252255
/**
@@ -264,7 +267,7 @@ public boolean confirmClearTradeRoute(Unit unit) {
264267
.addStringTemplate("%unit%",
265268
unit.getLabel(Unit.UnitLabelType.NATIONAL))
266269
.addName("%route%", tr.getName());
267-
return confirm(unit.getTile(), template, unit, "yes", "no");
270+
return confirm(unit.getTile(), template, unit, "yes", "no", true);
268271
}
269272

270273
/**
@@ -357,7 +360,7 @@ public boolean confirmHostileAction(Unit attacker, Tile target) {
357360
StringTemplate t = StringTemplate.template(messageId)
358361
.addStringTemplate("%nation%", enemy.getNationLabel());
359362
return confirm(attacker.getTile(), t, attacker,
360-
"confirmHostile.yes", "cancel");
363+
"confirmHostile.yes", "cancel", false);
361364
}
362365

363366
/**
@@ -402,7 +405,7 @@ public int confirmNativeTribute(Unit attacker, IndianSettlement is) {
402405
.addStringTemplate("%settlement%", is.getLocationLabelFor(player))
403406
.addStringTemplate("%nation%", other.getNationLabel());
404407
return (confirm(is.getTile(), t, attacker,
405-
"confirmTribute.yes", "confirmTribute.no")) ? 1 : -1;
408+
"confirmTribute.yes", "confirmTribute.no", true)) ? 1 : -1;
406409
}
407410

408411
/**
@@ -431,7 +434,7 @@ public boolean confirmPreCombat(Unit attacker, Tile tile) {
431434
*/
432435
public boolean confirmStopGame() {
433436
return confirm("stopCurrentGame.text",
434-
"stopCurrentGame.yes", "stopCurrentGame.no");
437+
"stopCurrentGame.yes", "stopCurrentGame.no", false);
435438
}
436439

437440
/**
@@ -1224,7 +1227,7 @@ public void animateUnitMove(Unit unit, Tile srcTile, Tile dstTile) {}
12241227
* @param okKey A key for the message on the "ok" button.
12251228
* @param cancelKey A key for the message on the "cancel" button.
12261229
* @param defaultOk The OK button gets the focus if {@code true}, else
1227-
* it's the cancel button that gets focused.
1230+
* it's the cancel button that gets focused.
12281231
* @return True if the "ok" button was selected.
12291232
*/
12301233
public boolean confirm(Tile tile, StringTemplate template, ImageIcon icon,

Diff for: src/net/sf/freecol/client/gui/dialog/EditSettlementDialog.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ public IndianSettlement getResponse() {
254254

255255
} else if (options.get(1).equals(value)) {
256256
if (!gui.confirm("editSettlementDialog.removeSettlement.text",
257-
"ok", "cancel")) {
257+
"ok", "cancel", true)) {
258258
return is;
259259
}
260260
// Dispose of units and settlement on tile

Diff for: src/net/sf/freecol/client/gui/panel/EuropePanel.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public Component add(Component comp, boolean editState) {
204204
if (!getGUI().confirm(null, StringTemplate
205205
.template("europePanel.leaveColonists")
206206
.addStringTemplate("%newWorld%", locName),
207-
unit, "ok", "cancel")) return null;
207+
unit, "ok", "cancel", true)) return null;
208208
}
209209

210210
igc().moveTo(unit, dest);

0 commit comments

Comments
 (0)