Skip to content

Commit 2e5e04a

Browse files
committed
feat(tutorial): move tutorial sections into headings
1 parent 1b74927 commit 2e5e04a

File tree

7 files changed

+190
-27
lines changed

7 files changed

+190
-27
lines changed

engine/src/main/java/org/destinationsol/game/tutorial/TutorialManager.java

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.destinationsol.game.tutorial.steps.ButtonPressStep;
2828
import org.destinationsol.game.tutorial.steps.BuyItemStep;
2929
import org.destinationsol.game.tutorial.steps.BuyMercenaryStep;
30+
import org.destinationsol.game.tutorial.steps.ChangeTutorialSectionStep;
3031
import org.destinationsol.game.tutorial.steps.CheckGunReloadStep;
3132
import org.destinationsol.game.tutorial.steps.CheckItemEquippedStep;
3233
import org.destinationsol.game.tutorial.steps.CloseScreenStep;
@@ -78,6 +79,7 @@ public class TutorialManager implements UpdateAwareSystem {
7879
private final BeanContext beanContext;
7980
private List<TutorialStep> steps;
8081
private int stepNo;
82+
private String currentTutorialHeading;
8183

8284
@Inject
8385
public TutorialManager(NUIManager nuiManager, SolApplication solApplication, Provider<SolGame> game, BeanContext beanContext) {
@@ -151,23 +153,23 @@ public void start() {
151153
itemTypesExplanations.put(Shield.class, "Shields absorb energy-based projectiles until depleted.");
152154

153155
steps = new ArrayList<>(Arrays.asList(
154-
new MessageStep("Section 1 - Movement"),
156+
new ChangeTutorialSectionStep("Movement"),
155157
new TurnLeftRightStep(isMobile ? "Turn left and right." : "Turn left and right (" + turnControlHint + ")."),
156158
new ThrustForwardsStep(isMobile ? "Thrust forwards." : "Thrust forwards (" + thrustForwardControlHint + ")."),
157159
new SlowVelocityStep(0.1f, "Turn around and thrust again to slow down.\n\nTry slowing to a stop."),
158160
new FlyToRandomWaypointAroundHeroStep(1.0f, 2.5f, "Fly to the waypoint."),
159-
new MessageStep("Section 2 - Weapons"),
161+
new ChangeTutorialSectionStep("Weapons"),
160162
new FireGunStep(isMobile ? "Fire your gun." : "Fire your gun (" + shootControlHint + ")."),
161163
new CheckGunReloadStep(false, true, "Firing weapons drains your ammunition. Keep on firing."),
162164
new CheckGunReloadStep(false, false,
163165
"Your weapon reloads when depleted.\n" +
164166
"You can't fire when reloading."),
165167
new UseAbilityStep(isMobile ? "Use your ability." : "Use your ability (" + abilityControlHint + ")."),
166168
new MessageStep("Abilities consume ability charges."),
167-
new MessageStep("Section 3 - Money"),
169+
new ChangeTutorialSectionStep("Money"),
168170
new DestroySpawnedAsteroidAroundHeroStep(1.0f, 2.5f, "Fire at the asteroid."),
169-
new MessageStep("Asteroids drop loot - money in this case."),
170-
new MessageStep("Section 4 - Items"),
171+
new MessageStep("Asteroids drop money. You can fly into it to collect it."),
172+
new ChangeTutorialSectionStep("Items"),
171173
new OpenScreenStep(
172174
solGame.get().getScreens().mainGameScreen.getInventoryButton(),
173175
solGame.get().getScreens().inventoryScreen,
@@ -191,27 +193,27 @@ public void start() {
191193
solGame.get().getScreens().inventoryScreen.getCloseButton(),
192194
solGame.get().getScreens().inventoryScreen,
193195
isMobile ? "Close your inventory (tap outside of the inventory)." : "Close your inventory."),
194-
new MessageStep("Section 5 - Weapon Mounts"),
196+
new ChangeTutorialSectionStep("Weapon Mounts"),
195197
new MessageStep("All ships may come with up to two weapon mounts."),
196198
new MessageStep("Weapon mounts are either fixed or rotating."),
197199
new MessageStep("You can only equip weapons on matching mounts."),
198-
new MessageStep("Section 6 - Shops"),
200+
new ChangeTutorialSectionStep("Shops"),
199201
new FlyToNearestStationStep("Fly to the station."),
200202
new OpenScreenStep(
201203
solGame.get().getScreens().mainGameScreen.getTalkButton(),
202204
solGame.get().getScreens().talkScreen,
203205
isMobile ? "Talk to the station." : "Talk to the station (" + gameOptions.getKeyTalkName() + ")."),
204206
new BuyItemStep(usesKeyboard ? "Select Buy (" + gameOptions.getKeyBuyMenuName() + ")." : "Select Buy.",
205207
isMobile ? "Buy an item." : "Buy an item (" + gameOptions.getKeyBuyItemName() + ")."),
206-
new MessageStep("Section 7 - Combat"),
208+
new ChangeTutorialSectionStep("Combat"),
207209
new MessageStep("Shoot at ships to destroy them.\n"),
208210
new DestroySpawnedShipsStep(1, "core:minerSmall",
209211
"core:fixedBlaster", "Destroy the targeted ship.",
210212
"Enemy ships can be tough.\nOpen the pause menu and select Respawn."),
211213
new MessageStep("Destroyed ships drop valuable loot."),
212-
new MessageStep("Section 8 - Repair Kits"),
214+
new ChangeTutorialSectionStep("Repair Kits"),
213215
new WaitUntilFullyRepairedStep("Stay still and wait until the repair kits have repaired your hull fully."),
214-
new MessageStep("Section 9 - Map"),
216+
new ChangeTutorialSectionStep("Map"),
215217
new OpenScreenStep(
216218
solGame.get().getScreens().mainGameScreen.getMapButton(),
217219
solGame.get().getScreens().mapScreen,
@@ -225,8 +227,9 @@ public void start() {
225227
solGame.get().getScreens().mapScreen,
226228
"Close the map."),
227229
new FlyToHeroFirstWaypointStep("Fly to your waypoint."),
228-
new MessageStep("Section 10 - Hiring Mercenaries"),
229-
new FlyToPlanetSellingMercenariesStep("Fly to a planetary station providing mercenaries."),
230+
new ChangeTutorialSectionStep("Planets"),
231+
new FlyToPlanetSellingMercenariesStep("Head towards a planet.", "Look for the planetary station."),
232+
new ChangeTutorialSectionStep("Mercenaries"),
230233
new MessageStep("When flying around planets, you'll be affected by gravity."),
231234
new OpenScreenStep(
232235
solGame.get().getScreens().mainGameScreen.getTalkButton(),
@@ -236,7 +239,6 @@ public void start() {
236239
usesKeyboard ? "Select Hire (" + gameOptions.getKeyHireShipMenuName() + ")." : "Select Hire.",
237240
"Try hiring a mercenary."),
238241
new MessageStep("Mercenaries will fight for you. They keep any money they collect as part of their payment."),
239-
new MessageStep("Section 11 - Managing Mercenaries"),
240242
new OpenScreenStep(
241243
solGame.get().getScreens().mainGameScreen.getMercsButton(),
242244
solGame.get().getScreens().inventoryScreen,
@@ -246,9 +248,11 @@ public void start() {
246248
"Here you can give items to your mercenary.",
247249
"Here you can take items back from your mercenary.",
248250
"Here you can manage your mercenary's equipment."),
251+
new ChangeTutorialSectionStep("Star Lanes"),
249252
new FlyToNearestStarPortStep("Fly to the marked star lane."),
250253
new MessageStep("For a small fee, star lanes allow you to travel quickly between planets."),
251254
new TravelThroughStarPortStep("Fly into the centre to travel across the star lane."),
255+
new ChangeTutorialSectionStep("Finish"),
252256
new MessageStep("That's it! The tutorial is finished. You will be returned to the main menu.")
253257
));
254258

@@ -309,7 +313,12 @@ public void update(SolGame game, float timeStep) {
309313
}
310314

311315
private void setUpTutorialBox(TutorialStep tutorialStep) {
316+
if (tutorialStep.getTutorialHeading() != null) {
317+
currentTutorialHeading = tutorialStep.getTutorialHeading();
318+
}
319+
312320
tutorialScreen.setTutorialText(tutorialStep.getTutorialText(), tutorialStep.getTutorialBoxPosition());
321+
tutorialScreen.setTutorialHeading(currentTutorialHeading, tutorialStep.getTutorialBoxPosition());
313322
if (tutorialStep.getRequiredInput() != null) {
314323
tutorialScreen.setInteractHintInput(tutorialStep.getTutorialBoxPosition(), tutorialStep.getRequiredInput());
315324
tutorialScreen.setInteractEvent(tutorialStep.getTutorialBoxPosition(), tutorialStep.getInputHandler());

engine/src/main/java/org/destinationsol/game/tutorial/TutorialStep.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* populate.
2929
*/
3030
public abstract class TutorialStep {
31+
private String tutorialHeading;
3132
private String tutorialText;
3233
private HorizontalAlign tutorialBoxPosition = HorizontalAlign.CENTER;
3334
private Input requiredInput;
@@ -46,8 +47,16 @@ public abstract class TutorialStep {
4647
public abstract boolean checkComplete(float timeStep);
4748

4849
/**
49-
* Returns the explanatory text to the shown to the player.
50-
* @return the explanatory text to the shown to the player
50+
* Returns the heading text shown to the player. This can be null, to preserve the existing heading.
51+
* @return the heading text shown to the player This can be null to preserve the existing heading.
52+
*/
53+
public String getTutorialHeading() {
54+
return tutorialHeading;
55+
}
56+
57+
/**
58+
* Returns the explanatory text to be the shown to the player.
59+
* @return the explanatory text to be the shown to the player
5160
*/
5261
public String getTutorialText() {
5362
return tutorialText;
@@ -77,6 +86,14 @@ public Consumer<Input> getInputHandler() {
7786
return inputHandler;
7887
}
7988

89+
/**
90+
* Specifies the heading to display above the tutorial box. This can be null to preserve the existing heading.
91+
* @param tutorialHeading the heading to display above the tutorial box, or null to preserve the existing heading.
92+
*/
93+
protected void setTutorialHeading(String tutorialHeading) {
94+
this.tutorialHeading = tutorialHeading;
95+
}
96+
8097
/**
8198
* Specifies the explanatory text to display in the tutorial box.
8299
* @param tutorialText the explanatory text to display
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2023 The Terasology Foundation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.destinationsol.game.tutorial.steps;
18+
19+
import org.destinationsol.game.tutorial.TutorialStep;
20+
21+
import javax.inject.Inject;
22+
23+
/**
24+
* This tutorial step simply changes the displayed heading above the tutorial box.
25+
*/
26+
public class ChangeTutorialSectionStep extends TutorialStep {
27+
private final String sectionHeading;
28+
29+
@Inject
30+
protected ChangeTutorialSectionStep() {
31+
throw new RuntimeException("Attempted to instantiate TutorialStep via DI. This is not supported.");
32+
}
33+
34+
public ChangeTutorialSectionStep(String sectionHeading) {
35+
this.sectionHeading = sectionHeading;
36+
}
37+
38+
@Override
39+
public void start() {
40+
setTutorialText(sectionHeading);
41+
setTutorialHeading(sectionHeading);
42+
}
43+
44+
@Override
45+
public boolean checkComplete(float timeStep) {
46+
return true;
47+
}
48+
}

engine/src/main/java/org/destinationsol/game/tutorial/steps/FlyToPlanetSellingMercenariesStep.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,16 @@
3232
* It guides the player towards the planet first with a waypoint, then towards the shop itself.
3333
*/
3434
public class FlyToPlanetSellingMercenariesStep extends FlyToPlanetStep {
35+
private final String onPlanetMessage;
36+
3537
@Inject
3638
protected FlyToPlanetSellingMercenariesStep() {
3739
throw new RuntimeException("Attempted to instantiate TutorialStep via DI. This is not supported.");
3840
}
3941

40-
public FlyToPlanetSellingMercenariesStep(String message) {
42+
public FlyToPlanetSellingMercenariesStep(String message, String onPlanetMessage) {
4143
super(null, message);
44+
this.onPlanetMessage = onPlanetMessage;
4245
}
4346

4447
@Override
@@ -107,12 +110,15 @@ private void setPlanetStationWaypoint() {
107110
@Override
108111
public boolean checkComplete(float timeStep) {
109112
boolean nearPlanet = super.checkComplete(timeStep);
110-
if (nearPlanet && planet.areObjectsCreated()) {
111-
setPlanetStationWaypoint();
112-
if (game.getMainGameScreen().getTalkButton().isEnabled()) {
113-
game.getHero().getWaypoints().remove(waypoint);
114-
game.getObjectManager().removeObjDelayed(waypoint);
115-
return true;
113+
if (nearPlanet) {
114+
setTutorialText(onPlanetMessage);
115+
if (planet.areObjectsCreated()) {
116+
setPlanetStationWaypoint();
117+
if (game.getMainGameScreen().getTalkButton().isEnabled()) {
118+
game.getHero().getWaypoints().remove(waypoint);
119+
game.getObjectManager().removeObjDelayed(waypoint);
120+
return true;
121+
}
116122
}
117123
}
118124
return false;

engine/src/main/java/org/destinationsol/ui/nui/screens/TutorialScreen.java

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ public class TutorialScreen extends NUIScreenLayer {
4343
private static final class TutorialBox {
4444
public final UIBox box;
4545
public final UILabel text;
46+
public final UILabel heading;
4647
public final InteractHint interactHint;
4748
public Consumer<Input> inputEventListener;
4849

49-
public TutorialBox(UIBox box, UILabel text, InteractHint interactHint) {
50+
public TutorialBox(UIBox box, UILabel text, UILabel heading, InteractHint interactHint) {
5051
this.box = box;
5152
this.text = text;
53+
this.heading = heading;
5254
this.interactHint = interactHint;
5355
}
5456
}
@@ -86,6 +88,7 @@ public void initialise() {
8688
TutorialBox tutorialBox = new TutorialBox(
8789
find("tutorialBox" + horizontalAlign.toString(), UIBox.class),
8890
find("tutorialText" + horizontalAlign.toString(), UILabel.class),
91+
find("tutorialHeading" + horizontalAlign.toString(), UILabel.class),
8992
find("interactHint" + horizontalAlign.toString(), InteractHint.class)
9093
);
9194
if (tutorialBox.interactHint != null) {
@@ -130,6 +133,41 @@ public void setTutorialText(String text, HorizontalAlign horizontalAlign) {
130133
getTutorialBox(horizontalAlign).setVisible(!text.isEmpty());
131134
}
132135

136+
/**
137+
* Returns the heading displayed above the centre tutorial box.
138+
* @return the heading displayed above the centre tutorial box.
139+
*/
140+
public String getTutorialHeading() {
141+
return getTutorialHeading(HorizontalAlign.CENTER);
142+
}
143+
144+
/**
145+
* Returns the heading displayed above the specified tutorial box.
146+
* @param horizontalAlign the tutorial box to select
147+
* @return the heading displayed above the specified tutorial box.
148+
*/
149+
public String getTutorialHeading(HorizontalAlign horizontalAlign) {
150+
return getTutorialHeadingLabel(horizontalAlign).getText();
151+
}
152+
153+
/**
154+
* Specifies the heading to be displayed above the specified tutorial box.
155+
* @param heading the heading to be displayed
156+
*/
157+
public void setTutorialHeading(String heading) {
158+
setTutorialHeading(heading, HorizontalAlign.CENTER);
159+
}
160+
161+
/**
162+
* Specifies the heading to be displayed above the specified tutorial box.
163+
* @param heading the heading to be displayed
164+
* @param horizontalAlign the tutorial box to select
165+
*/
166+
public void setTutorialHeading(String heading, HorizontalAlign horizontalAlign) {
167+
getTutorialHeadingLabel(horizontalAlign).setText(heading);
168+
getTutorialHeadingLabel(horizontalAlign).setVisible(!heading.isEmpty());
169+
}
170+
133171
/**
134172
* Returns the input hinted at by the centre tutorial box. This can be null.
135173
* @return the input hinted at by the centre tutorial box
@@ -214,6 +252,10 @@ protected UILabel getTutorialTextLabel(HorizontalAlign horizontalAlign) {
214252
return tutorialBoxes.get(horizontalAlign).text;
215253
}
216254

255+
protected UILabel getTutorialHeadingLabel(HorizontalAlign horizontalAlign) {
256+
return tutorialBoxes.get(horizontalAlign).heading;
257+
}
258+
217259
protected UIBox getTutorialBox(HorizontalAlign horizontalAlign) {
218260
return tutorialBoxes.get(horizontalAlign).box;
219261
}

engine/src/main/resources/org/destinationsol/assets/skins/tutorialScreen.skin

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@
1414
},
1515
"tutorialBoxLEFT": {
1616
"font": "engine:main#0.8",
17-
"max-width": 160,
17+
"min-width": 178,
1818
"min-height": 192,
1919
"elements": {
2020
"UIBox": {
2121
"background": "engine:box",
2222
"text-align-horizontal": "middle"
2323
}
2424
}
25+
},
26+
"tutorialHeading": {
27+
"font": "engine:main#0.4"
2528
}
2629
},
2730
"elements": {

0 commit comments

Comments
 (0)