Skip to content

Commit 01d70fa

Browse files
Merge branch 'tps'
2 parents ec02a9d + 95219fe commit 01d70fa

File tree

8 files changed

+96
-20
lines changed

8 files changed

+96
-20
lines changed

VERSIONS.MD

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
# Versions
22

3-
## In progress
3+
## In progress - 0.13.4 - GUI improvements
4+
5+
#### Bugfixes:
6+
7+
- Bot API for Java:
8+
- Major bugfix with getTurnRemaining(), which returned the wrong value.
49

510
#### Changes:
611

712
- GUI:
813
- **Del Key**: It is now possible to use the Del key to remove a selected bot item on the Booted Bots (to unboot),
914
Joined Bots, and Selected Bot lists when selecting bots for a new battle.
1015
- **Unboot All**: An `← Unboot All` button has been added right below the `← Unboot` button.
16+
- **TPS**:
17+
- The last used TPS (Turns Per Second) is now restored when starting up the GUI again.
18+
- Added a "Default TPS" button to reset the TPS to the default setting (30 TPS).
19+
- **Tool tips**: Added tool tip texts on the Control panel.
1120

1221
## 0.13.3 - Stabilization of Bot APIs - 01-Jun-2022
1322

bot-api/java/src/main/java/dev/robocode/tankroyale/botapi/internal/BotInternals.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ private void setTurnRemaining(double newTurnRemaining) {
176176

177177
public double getTurnRemaining() {
178178
synchronized (turnMonitor) {
179-
return __distanceRemaining;
179+
return __turnRemaining;
180180
}
181181
}
182182

gui-app/src/main/kotlin/dev/robocode/tankroyale/gui/client/Client.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import dev.robocode.tankroyale.gui.client.ClientEvents.onRoundEnded
1111
import dev.robocode.tankroyale.gui.client.ClientEvents.onRoundStarted
1212
import dev.robocode.tankroyale.gui.client.ClientEvents.onTickEvent
1313
import dev.robocode.tankroyale.gui.model.*
14+
import dev.robocode.tankroyale.gui.settings.ConfigSettings
1415
import dev.robocode.tankroyale.gui.settings.GamesSettings
1516
import dev.robocode.tankroyale.gui.settings.ServerSettings
1617
import dev.robocode.tankroyale.gui.ui.server.ServerEvents
@@ -41,7 +42,7 @@ object Client {
4142

4243
private lateinit var lastStartGame: StartGame
4344

44-
private var tps: Int? = null
45+
private var lastTps: Int? = null
4546

4647
init {
4748
TpsEvents.onTpsChanged.subscribe(Client) { changeTps(it.tps) }
@@ -126,7 +127,7 @@ object Client {
126127
}
127128
}
128129

129-
fun doNextTurn() {
130+
internal fun doNextTurn() {
130131
if (isRunning.get() && isPaused.get()) {
131132
send(NextTurn())
132133
}
@@ -150,10 +151,10 @@ object Client {
150151
}
151152

152153
private fun changeTps(tps: Int) {
153-
if (isRunning.get() && tps != this.tps) {
154-
this.tps = tps
154+
if (isRunning.get() && tps != lastTps) {
155155
send(ChangeTps(tps))
156156
}
157+
lastTps = tps
157158
}
158159

159160
private fun onMessage(msg: String) {
@@ -196,6 +197,8 @@ object Client {
196197
participants = gameStartedEvent.participants
197198

198199
onGameStarted.fire(gameStartedEvent)
200+
201+
changeTps(ConfigSettings.tps)
199202
}
200203

201204
private fun handleGameEnded(gameEndedEvent: GameEndedEvent) {

gui-app/src/main/kotlin/dev/robocode/tankroyale/gui/settings/ConfigSettings.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package dev.robocode.tankroyale.gui.settings
22

33
object ConfigSettings : PropertiesStore("Robocode Misc Settings", "config.properties") {
44

5+
const val DEFAULT_TPS = 30
6+
57
private const val BOT_DIRECTORIES = "bot-directories"
68
private const val TPS = "tps"
7-
private const val DEFAULT_TPS = 30
89

910
private const val BOT_DIRS_SEPARATOR = ","
1011

gui-app/src/main/kotlin/dev/robocode/tankroyale/gui/ui/control/ControlPanel.kt

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,59 @@ package dev.robocode.tankroyale.gui.ui.control
22

33
import dev.robocode.tankroyale.gui.client.ClientEvents
44
import dev.robocode.tankroyale.gui.client.ClientEvents.onGameStarted
5+
import dev.robocode.tankroyale.gui.model.TpsChangedEvent
6+
import dev.robocode.tankroyale.gui.settings.ConfigSettings.DEFAULT_TPS
7+
import dev.robocode.tankroyale.gui.ui.Hints
58
import dev.robocode.tankroyale.gui.ui.Strings
69
import dev.robocode.tankroyale.gui.ui.extensions.JComponentExt.addButton
710
import dev.robocode.tankroyale.gui.ui.extensions.JComponentExt.setDefaultButton
11+
import dev.robocode.tankroyale.gui.ui.tps.TpsEvents
812
import dev.robocode.tankroyale.gui.ui.tps.TpsField
913
import dev.robocode.tankroyale.gui.ui.tps.TpsSlider
14+
import dev.robocode.tankroyale.gui.util.Event
1015
import dev.robocode.tankroyale.gui.util.GuiTask.enqueue
1116
import dev.robocode.tankroyale.gui.util.RegisterWsProtocol
17+
import javax.swing.JButton
1218
import javax.swing.JLabel
1319
import javax.swing.JPanel
1420

1521
object ControlPanel : JPanel() {
1622

17-
private val pauseResumeButton = addButton("pause", ControlEvents.onPauseResume)
23+
private val pauseResumeButton = addButton("pause", ControlEvents.onPauseResume).apply {
24+
toolTipText = Hints.get("control.pause")
25+
}
26+
1827
private val nextButton = addButton("next_turn", ControlEvents.onNextTurn).apply {
28+
toolTipText = Hints.get("control.next_turn")
1929
isEnabled = false
2030
}
21-
private val stopButton = addButton("stop", ControlEvents.onStop)
31+
private val stopButton = addButton("stop", ControlEvents.onStop).apply {
32+
toolTipText = Hints.get("control.stop")
33+
}
34+
35+
private val onDefaultTps = Event<JButton>()
2236

2337
init {
24-
addButton("restart", ControlEvents.onRestart)
38+
addButton("restart", ControlEvents.onRestart).apply {
39+
toolTipText = Hints.get("control.restart")
40+
}
2541

2642
RegisterWsProtocol
2743

44+
val tpsLabel = JLabel("TPS:")
45+
2846
add(TpsSlider)
29-
add(JLabel("TPS:"))
47+
add(tpsLabel)
3048
add(TpsField)
49+
addButton("default_tps", onDefaultTps).apply {
50+
toolTipText = Hints.get("control.default_tps")
51+
}
52+
53+
val tpsHint = Hints.get("control.tps")
54+
55+
TpsSlider.toolTipText = tpsHint
56+
tpsLabel.toolTipText = tpsHint
57+
TpsField.toolTipText = tpsHint
3158

3259
ClientEvents.apply {
3360
onGamePaused.subscribe(ControlPanel) {
@@ -58,6 +85,10 @@ object ControlPanel : JPanel() {
5885
}
5986
}
6087

88+
onDefaultTps.subscribe(ControlPanel) {
89+
TpsEvents.onTpsChanged.fire(TpsChangedEvent(DEFAULT_TPS))
90+
}
91+
6192
enqueue {
6293
setDefaultButton(pauseResumeButton)
6394
}
@@ -69,10 +100,16 @@ object ControlPanel : JPanel() {
69100
}
70101

71102
private fun setPausedText() {
72-
pauseResumeButton.text = Strings.get("pause")
103+
pauseResumeButton.apply {
104+
text = Strings.get("pause")
105+
toolTipText = Hints.get("control.pause")
106+
}
73107
}
74108

75109
private fun setResumedText() {
76-
pauseResumeButton.text = Strings.get("resume")
110+
pauseResumeButton.apply {
111+
text = Strings.get("resume")
112+
toolTipText = Hints.get("control.resume")
113+
}
77114
}
78115
}

gui-app/src/main/resources/Hints.properties

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,30 @@ new_battle.selected_bots=\
1919
new_battle.start_button=\
2020
Requires at least %d participants, and maximum of %s participants.
2121

22+
# Control Panel
23+
control.pause=\
24+
Pauses the battle.
25+
26+
control.resume=\
27+
Resumes the paused battle.
28+
29+
control.next_turn=\
30+
Go to the next turn while the battle is paused. Useful for debugging.
31+
32+
control.stop=\
33+
Stops the battle.
34+
35+
control.restart=\
36+
Restarts the battle so it starts all over.
37+
38+
control.tps=\
39+
Sets the Turns Per Second (TPS). Set to <i>max</i> for fastest possible TPS.<br>\
40+
Note that the TPS cannot go faster than the <em>turn timeout</em> allows for.<br>\
41+
The lower <em>turn timeout</em>, the higher TPS is possible.
42+
43+
control.default_tps=\
44+
Resets the Turns Per Second (TPS) to the default:
45+
2246
# Debug Options
2347
option.enable_initial_position=\
2448
Server-option for allowing your bot(s) to start with an initial starting position.<br>\

gui-app/src/main/resources/Strings.properties

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ apply=Apply
4848
add=Add
4949
remove=Remove
5050
url=URL
51-
stop=Stop
52-
restart=Restart
53-
pause=Pause
54-
resume=Resume
55-
next_turn=Next turn
51+
stop=Stop \u23F9
52+
restart=Restart \u21BA
53+
pause=Pause \u23F8
54+
resume=Resume \u25B6
55+
next_turn=Next turn \u2192
5656
bot_root_dirs=Bot Root Directories
5757
server_is_running=Server is running
5858
server_not_found=Server was not found
@@ -68,4 +68,6 @@ bot_info.country_codes=Country Code(s)
6868
bot_info.platform=Platform
6969
bot_info.programming_lang=Programming Lang.
7070
# Debug Options
71-
option.enable_initial_position.text=Enable initial start position
71+
option.enable_initial_position.text=Enable initial start position
72+
# TPS
73+
default_tps=Default TPS

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
val version = "0.13.3"
1+
val version = "0.13.4"
22

33
// Schema Generator
44
include("schema:jvm")

0 commit comments

Comments
 (0)