Skip to content

Commit 6385d77

Browse files
committed
removed controlSetupFn, removed MicroData specific code, reworked scene() so that it uses one fiber (eventContext.registerFrameHandler) instead of 4
1 parent c435732 commit 6385d77

File tree

2 files changed

+177
-264
lines changed

2 files changed

+177
-264
lines changed

cursorscene.ts

Lines changed: 39 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,6 @@ namespace user_interface_base {
22
import Screen = user_interface_base.Screen
33
import Scene = user_interface_base.Scene
44

5-
/**
6-
* Used to control the flow between scenes,
7-
* The SensorSelect scene is used to set the sensors before the RecordData, DistributedLogging and LiveDataViewer scenes
8-
* This enum may be passed to the constructors of these scenes so that they can dynamically control this flow.
9-
* TODO: REMOVE THIS!!
10-
*/
11-
export enum CursorSceneEnum {
12-
LiveDataViewer,
13-
SensorSelect,
14-
RecordingConfigSelect,
15-
RecordData,
16-
DistributedLogging
17-
}
18-
195

206
/**
217
* Top-level abstraction that is rendered on the screen.
@@ -68,50 +54,47 @@ namespace user_interface_base {
6854
* If you wish to override what the controller buttons do, then pass controlSetupFn.
6955
* overrides parent method, still invokes it.
7056
*/
71-
startup(controlSetupFn?: () => void) {
57+
startup() {
7258
super.startup()
73-
if (controlSetupFn != null) {
74-
controlSetupFn();
75-
} else {
76-
control.onEvent(
77-
ControllerButtonEvent.Pressed,
78-
controller.right.id,
79-
() => this.moveCursor(CursorDir.Right)
80-
)
81-
control.onEvent(
82-
ControllerButtonEvent.Pressed,
83-
controller.up.id,
84-
() => this.moveCursor(CursorDir.Up)
85-
)
86-
control.onEvent(
87-
ControllerButtonEvent.Pressed,
88-
controller.down.id,
89-
() => this.moveCursor(CursorDir.Down)
90-
)
91-
control.onEvent(
92-
ControllerButtonEvent.Pressed,
93-
controller.left.id,
94-
() => this.moveCursor(CursorDir.Left)
95-
)
59+
control.onEvent(
60+
ControllerButtonEvent.Pressed,
61+
controller.right.id,
62+
() => this.moveCursor(CursorDir.Right)
63+
)
64+
control.onEvent(
65+
ControllerButtonEvent.Pressed,
66+
controller.up.id,
67+
() => this.moveCursor(CursorDir.Up)
68+
)
69+
control.onEvent(
70+
ControllerButtonEvent.Pressed,
71+
controller.down.id,
72+
() => this.moveCursor(CursorDir.Down)
73+
)
74+
control.onEvent(
75+
ControllerButtonEvent.Pressed,
76+
controller.left.id,
77+
() => this.moveCursor(CursorDir.Left)
78+
)
79+
80+
// click
81+
const click = () => this.cursor.click()
82+
control.onEvent(
83+
ControllerButtonEvent.Pressed,
84+
controller.A.id,
85+
click
86+
)
87+
control.onEvent(
88+
ControllerButtonEvent.Pressed,
89+
controller.A.id + keymap.PLAYER_OFFSET,
90+
click
91+
)
92+
control.onEvent(
93+
ControllerButtonEvent.Pressed,
94+
controller.B.id,
95+
() => this.back()
96+
)
9697

97-
// click
98-
const click = () => this.cursor.click()
99-
control.onEvent(
100-
ControllerButtonEvent.Pressed,
101-
controller.A.id,
102-
click
103-
)
104-
control.onEvent(
105-
ControllerButtonEvent.Pressed,
106-
controller.A.id + keymap.PLAYER_OFFSET,
107-
click
108-
)
109-
control.onEvent(
110-
ControllerButtonEvent.Pressed,
111-
controller.B.id,
112-
() => this.back()
113-
)
114-
}
11598
this.cursor = new Cursor()
11699
this.picker = new Picker(this.cursor)
117100
if (this.navigator == null)
@@ -176,82 +159,4 @@ namespace user_interface_base {
176159
this.cursor.draw()
177160
}
178161
}
179-
180-
181-
/**
182-
* Ovverides the B button on the controller to go invoke a passed function.
183-
* That passed function is normally {this.app.popScene(); this.app.pushScene(new ...);
184-
* Defaults to RowNavigator if not passsed.
185-
*/
186-
export class CursorSceneWithPriorPage extends CursorScene {
187-
private goBack1PageFn: () => void;
188-
189-
constructor(app: AppInterface, goBack1PageFn: () => void, navigator?: INavigator) {
190-
super(app)
191-
this.backgroundColor = 11
192-
193-
if (navigator)
194-
this.navigator = navigator
195-
else
196-
this.navigator = null
197-
this.goBack1PageFn = goBack1PageFn
198-
}
199-
200-
/* override */ startup(controlSetupFn?: () => void) {
201-
if (controlSetupFn != null) {
202-
controlSetupFn();
203-
} else {
204-
control.onEvent(
205-
ControllerButtonEvent.Pressed,
206-
controller.right.id,
207-
() => this.moveCursor(CursorDir.Right)
208-
)
209-
control.onEvent(
210-
ControllerButtonEvent.Pressed,
211-
controller.up.id,
212-
() => this.moveCursor(CursorDir.Up)
213-
)
214-
control.onEvent(
215-
ControllerButtonEvent.Pressed,
216-
controller.down.id,
217-
() => this.moveCursor(CursorDir.Down)
218-
)
219-
control.onEvent(
220-
ControllerButtonEvent.Pressed,
221-
controller.left.id,
222-
() => this.moveCursor(CursorDir.Left)
223-
)
224-
225-
// click
226-
const click = () => this.cursor.click()
227-
control.onEvent(
228-
ControllerButtonEvent.Pressed,
229-
controller.A.id,
230-
click
231-
)
232-
control.onEvent(
233-
ControllerButtonEvent.Pressed,
234-
controller.A.id + keymap.PLAYER_OFFSET,
235-
click
236-
)
237-
control.onEvent(
238-
ControllerButtonEvent.Pressed,
239-
controller.B.id,
240-
() => this.back()
241-
)
242-
243-
control.onEvent(
244-
ControllerButtonEvent.Pressed,
245-
controller.B.id,
246-
() => this.goBack1PageFn()
247-
)
248-
}
249-
this.cursor = new Cursor()
250-
this.picker = new Picker(this.cursor)
251-
252-
if (this.navigator == null)
253-
this.navigator = new RowNavigator()
254-
this.cursor.navigator = this.navigator
255-
}
256-
}
257162
}

0 commit comments

Comments
 (0)