@remvst/game-navigation-core 1.6.1 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/game/game.js CHANGED
@@ -21,14 +21,16 @@ class Game {
21
21
  return this.pluginMap.get(keyProvider.key);
22
22
  }
23
23
  setup() {
24
+ this.inputs = new inputs_1.GameInputs(this);
25
+ this.inputs.setup();
26
+ this.screenStack = new screen_stack_1.ScreenStack(this);
24
27
  for (const plugin of this.plugins) {
25
28
  plugin.bind(this);
26
- plugin.setup();
27
29
  this.pluginMap.set(plugin.key, plugin);
28
30
  }
29
- this.inputs = new inputs_1.GameInputs(this);
30
- this.inputs.setup();
31
- this.screenStack = new screen_stack_1.ScreenStack(this);
31
+ for (const plugin of this.plugins) {
32
+ plugin.setup();
33
+ }
32
34
  this.lastFrame = window.performance.now();
33
35
  this.scheduleFrame();
34
36
  }
@@ -16,6 +16,7 @@ export declare class ScreenStack {
16
16
  current(): Screen;
17
17
  popTo(screen: Screen, inclusive?: boolean): void;
18
18
  push(screen: Screen): void;
19
+ replaceExisting(screen: Screen): void;
19
20
  pop(): void;
20
21
  reset(screen: Screen): void;
21
22
  resolvableScreen<T>(screen: Screen & ResolverHolder<T>, navigationType?: NavigationType, dismissWhenResolved?: boolean): Promise<T>;
@@ -45,6 +45,12 @@ class ScreenStack {
45
45
  this.game.onCurrentScreenChanged();
46
46
  });
47
47
  }
48
+ replaceExisting(screen) {
49
+ const existing = this.findByType(screen.constructor);
50
+ if (existing)
51
+ this.popTo(existing, true);
52
+ this.push(screen);
53
+ }
48
54
  pop() {
49
55
  this.queue.execute(() => {
50
56
  const screen = this.screens.pop();
@@ -80,10 +86,7 @@ class ScreenStack {
80
86
  this.reset(screen);
81
87
  break;
82
88
  case NavigationType.REPLACE_EXISTING:
83
- const existing = this.findByType(screen.constructor);
84
- if (existing)
85
- this.popTo(existing, true);
86
- this.push(screen);
89
+ this.replaceExisting(screen);
87
90
  break;
88
91
  }
89
92
  });
@@ -10,7 +10,7 @@ export declare abstract class Screen {
10
10
  frameCount: number;
11
11
  interpolationPool: InterpolationPool;
12
12
  delegate: ScreenDelegate | null;
13
- private readonly subscreens;
13
+ protected readonly subscreens: Screen[];
14
14
  constructor();
15
15
  addSubscreen(screen: Screen): void;
16
16
  bind(game: Game): void;
@@ -37,4 +37,5 @@ export declare abstract class Screen {
37
37
  get timeFactor(): number;
38
38
  get isCycling(): boolean;
39
39
  get isTakingInputs(): boolean;
40
+ updateLayout(): void;
40
41
  }
package/lib/ui/screen.js CHANGED
@@ -146,5 +146,10 @@ class Screen {
146
146
  }
147
147
  return false;
148
148
  }
149
+ updateLayout() {
150
+ for (const subscreen of this.subscreens) {
151
+ subscreen.updateLayout();
152
+ }
153
+ }
149
154
  }
150
155
  exports.Screen = Screen;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remvst/game-navigation-core",
3
- "version": "1.6.1",
3
+ "version": "1.7.1",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
package/src/game/game.ts CHANGED
@@ -41,16 +41,19 @@ export abstract class Game<ParamsType extends GameParams = GameParams> {
41
41
  }
42
42
 
43
43
  setup() {
44
+ this.inputs = new GameInputs(this);
45
+ this.inputs.setup();
46
+
47
+ this.screenStack = new ScreenStack(this);
48
+
44
49
  for (const plugin of this.plugins) {
45
50
  plugin.bind(this);
46
- plugin.setup();
47
51
  this.pluginMap.set(plugin.key, plugin);
48
52
  }
49
53
 
50
- this.inputs = new GameInputs(this);
51
- this.inputs.setup();
52
-
53
- this.screenStack = new ScreenStack(this);
54
+ for (const plugin of this.plugins) {
55
+ plugin.setup();
56
+ }
54
57
 
55
58
  this.lastFrame = window.performance.now();
56
59
  this.scheduleFrame();
@@ -60,6 +60,14 @@ export class ScreenStack {
60
60
  });
61
61
  }
62
62
 
63
+ replaceExisting(screen: Screen) {
64
+ const existing = this.findByType(
65
+ screen.constructor as new (...params: any) => Screen,
66
+ ) as Screen;
67
+ if (existing) this.popTo(existing, true);
68
+ this.push(screen);
69
+ }
70
+
63
71
  pop() {
64
72
  this.queue.execute(() => {
65
73
  const screen = this.screens.pop();
@@ -103,11 +111,7 @@ export class ScreenStack {
103
111
  this.reset(screen);
104
112
  break;
105
113
  case NavigationType.REPLACE_EXISTING:
106
- const existing = this.findByType(
107
- screen.constructor as new (...params: any) => Screen,
108
- ) as Screen;
109
- if (existing) this.popTo(existing, true);
110
- this.push(screen);
114
+ this.replaceExisting(screen);
111
115
  break;
112
116
  }
113
117
  });
package/src/ui/screen.ts CHANGED
@@ -13,7 +13,7 @@ export abstract class Screen {
13
13
  interpolationPool: InterpolationPool;
14
14
  delegate: ScreenDelegate | null = null;
15
15
 
16
- private readonly subscreens: Screen[] = [];
16
+ protected readonly subscreens: Screen[] = [];
17
17
 
18
18
  constructor() {
19
19
  this.game = null;
@@ -197,4 +197,10 @@ export abstract class Screen {
197
197
  }
198
198
  return false;
199
199
  }
200
+
201
+ updateLayout(): void {
202
+ for (const subscreen of this.subscreens) {
203
+ subscreen.updateLayout();
204
+ }
205
+ }
200
206
  }