Skip to content

Commit c8c3fec

Browse files
committed
Visualize readyToContinue flag in UI
1 parent 645c174 commit c8c3fec

File tree

6 files changed

+98
-70
lines changed

6 files changed

+98
-70
lines changed

internal/app/engine/consume_tracker.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ func (e *Engine) ProcessTrackerFrame(wrapperFrame *tracker.TrackerWrapperPacket)
2020

2121
// for now, all tracker sources update the GC state
2222
e.gcState.TrackerStateGc = &state
23+
24+
if e.gcState.ReadyToContinue == nil {
25+
e.gcState.ReadyToContinue = new(bool)
26+
}
27+
*e.gcState.ReadyToContinue = e.readyToContinue()
2328
})
2429
}
2530

@@ -43,3 +48,12 @@ func convertBalls(balls []*tracker.TrackedBall) *Ball {
4348
}
4449
return &ball
4550
}
51+
52+
func (e *Engine) readyToContinue() bool {
53+
radius := e.gameConfig.DistanceToBallInStop + robotRadius + distanceThreshold
54+
if !e.ballSteady() ||
55+
e.robotsInsideRadius(e.gcState.TrackerStateGc.Robots, e.gcState.TrackerStateGc.Ball.Pos.ToVector2(), radius) {
56+
return false
57+
}
58+
return false
59+
}

internal/app/engine/process_prepare.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const minPreparationTime = time.Second * 2
1111
func (e *Engine) processPrepare() {
1212
if !e.currentState.Command.IsPrepare() ||
1313
e.gcState.TrackerStateGc.Ball == nil ||
14-
!e.readyToContinue() ||
14+
e.gcState.ReadyToContinue == nil ||
15+
!*e.gcState.ReadyToContinue ||
1516
e.currentState.NextCommand == nil ||
1617
!e.currentState.GetAutoContinue() ||
1718
e.timeSinceLastChange() < minPreparationTime {
@@ -53,12 +54,3 @@ func (e *Engine) processPrepare() {
5354
},
5455
})
5556
}
56-
57-
func (e *Engine) readyToContinue() bool {
58-
radius := e.gameConfig.DistanceToBallInStop + robotRadius + distanceThreshold
59-
if !e.ballSteady() ||
60-
e.robotsInsideRadius(e.gcState.TrackerStateGc.Robots, e.gcState.TrackerStateGc.Ball.Pos.ToVector2(), radius) {
61-
return false
62-
}
63-
return false
64-
}

internal/app/engine/ssl_gc_engine.pb.go

Lines changed: 42 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/ssl_gc_engine.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ message GcState {
1010
map<string, GcStateAutoRef> auto_ref_state = 2;
1111
map<string, GcStateTracker> tracker_state = 3;
1212
optional GcStateTracker tracker_state_gc = 4;
13+
optional bool ready_to_continue = 5;
1314
}
1415

1516
message GcStateTeam {

src/components/control/ControlFlowBar.vue

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
:title="'Continue based on last game event (' + Object.keys(keymapContinue)[0] + ')'">
1515
<b-button v-hotkey="keymapContinue"
1616
ref="btnContinue"
17+
:class="continueButtonClass"
1718
v-on:click="triggerContinue"
1819
v-bind:disabled="continueDisabled">
1920
Continue
@@ -24,25 +25,6 @@
2425
</span>
2526
</b-button>
2627
</div>
27-
28-
<div v-for="autoRefId of autoRefs"
29-
v-bind:key="autoRefId"
30-
v-if="autoRefReady(autoRefId) !== undefined || autoRefBallPlaced(autoRefId) !== undefined"
31-
class="auto-ref-meta">
32-
{{autoRefId}}
33-
<font-awesome-icon
34-
v-b-tooltip.hover.d500
35-
title="Ready to continue"
36-
v-if="autoRefReady(autoRefId)"
37-
class="fa-xs"
38-
icon="check-circle"/>
39-
<font-awesome-icon
40-
v-b-tooltip.hover.d500
41-
title="Not ready to continue yet"
42-
v-else
43-
class="fa-xs"
44-
icon="times-circle"/>
45-
</div>
4628
</div>
4729
</template>
4830

@@ -59,9 +41,6 @@
5941
triggerContinue() {
6042
submitChange({continue: {}});
6143
},
62-
autoRefReady(id) {
63-
return this.$store.state.gcState.autoRefState[id].readyToContinue;
64-
}
6544
},
6645
computed: {
6746
keymapHalt() {
@@ -110,8 +89,14 @@
11089
'team-yellow': this.nextCommand && this.nextCommand.forTeam === TEAM_YELLOW
11190
}
11291
},
113-
autoRefs() {
114-
return Object.keys(this.$store.state.gcState.autoRefState);
92+
continueButtonClass() {
93+
if (!this.$store.state.gcState.hasOwnProperty('readyToContinue')) {
94+
return '';
95+
}
96+
if (this.$store.state.gcState.readyToContinue) {
97+
return 'continue-btn-ready';
98+
}
99+
return 'continue-btn-not-ready';
115100
}
116101
}
117102
}
@@ -128,9 +113,12 @@
128113
justify-content: center;
129114
}
130115
131-
.auto-ref-meta {
132-
font-size: 1.2em;
133-
margin: auto .2em;
116+
.continue-btn-ready {
117+
background-color: green;
118+
}
119+
120+
.continue-btn-not-ready {
121+
background-color: red;
134122
}
135123
136124
</style>

src/proto.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21721,6 +21721,7 @@ export const GcState = $root.GcState = (() => {
2172121721
* @property {Object.<string,IGcStateAutoRef>|null} [autoRefState] GcState autoRefState
2172221722
* @property {Object.<string,IGcStateTracker>|null} [trackerState] GcState trackerState
2172321723
* @property {IGcStateTracker|null} [trackerStateGc] GcState trackerStateGc
21724+
* @property {boolean|null} [readyToContinue] GcState readyToContinue
2172421725
*/
2172521726

2172621727
/**
@@ -21773,6 +21774,14 @@ export const GcState = $root.GcState = (() => {
2177321774
*/
2177421775
GcState.prototype.trackerStateGc = null;
2177521776

21777+
/**
21778+
* GcState readyToContinue.
21779+
* @member {boolean} readyToContinue
21780+
* @memberof GcState
21781+
* @instance
21782+
*/
21783+
GcState.prototype.readyToContinue = false;
21784+
2177621785
/**
2177721786
* Creates a new GcState instance using the specified properties.
2177821787
* @function create
@@ -21814,6 +21823,8 @@ export const GcState = $root.GcState = (() => {
2181421823
}
2181521824
if (message.trackerStateGc != null && message.hasOwnProperty("trackerStateGc"))
2181621825
$root.GcStateTracker.encode(message.trackerStateGc, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
21826+
if (message.readyToContinue != null && message.hasOwnProperty("readyToContinue"))
21827+
writer.uint32(/* id 5, wireType 0 =*/40).bool(message.readyToContinue);
2181721828
return writer;
2181821829
};
2181921830

@@ -21875,6 +21886,9 @@ export const GcState = $root.GcState = (() => {
2187521886
case 4:
2187621887
message.trackerStateGc = $root.GcStateTracker.decode(reader, reader.uint32());
2187721888
break;
21889+
case 5:
21890+
message.readyToContinue = reader.bool();
21891+
break;
2187821892
default:
2187921893
reader.skipType(tag & 7);
2188021894
break;
@@ -21945,6 +21959,9 @@ export const GcState = $root.GcState = (() => {
2194521959
if (error)
2194621960
return "trackerStateGc." + error;
2194721961
}
21962+
if (message.readyToContinue != null && message.hasOwnProperty("readyToContinue"))
21963+
if (typeof message.readyToContinue !== "boolean")
21964+
return "readyToContinue: boolean expected";
2194821965
return null;
2194921966
};
2195021967

@@ -21995,6 +22012,8 @@ export const GcState = $root.GcState = (() => {
2199522012
throw TypeError(".GcState.trackerStateGc: object expected");
2199622013
message.trackerStateGc = $root.GcStateTracker.fromObject(object.trackerStateGc);
2199722014
}
22015+
if (object.readyToContinue != null)
22016+
message.readyToContinue = Boolean(object.readyToContinue);
2199822017
return message;
2199922018
};
2200022019

@@ -22016,8 +22035,10 @@ export const GcState = $root.GcState = (() => {
2201622035
object.autoRefState = {};
2201722036
object.trackerState = {};
2201822037
}
22019-
if (options.defaults)
22038+
if (options.defaults) {
2202022039
object.trackerStateGc = null;
22040+
object.readyToContinue = false;
22041+
}
2202122042
let keys2;
2202222043
if (message.teamState && (keys2 = Object.keys(message.teamState)).length) {
2202322044
object.teamState = {};
@@ -22036,6 +22057,8 @@ export const GcState = $root.GcState = (() => {
2203622057
}
2203722058
if (message.trackerStateGc != null && message.hasOwnProperty("trackerStateGc"))
2203822059
object.trackerStateGc = $root.GcStateTracker.toObject(message.trackerStateGc, options);
22060+
if (message.readyToContinue != null && message.hasOwnProperty("readyToContinue"))
22061+
object.readyToContinue = message.readyToContinue;
2203922062
return object;
2204022063
};
2204122064

0 commit comments

Comments
 (0)