1919import com .badlogic .gdx .math .Rectangle ;
2020import org .destinationsol .GameOptions ;
2121import org .destinationsol .common .SolColor ;
22- import org .destinationsol .game .screens .GameScreens ;
23- import org .destinationsol .game .screens .MainScreen ;
24- import org .destinationsol .game .screens .ShipKbControl ;
25- import org .destinationsol .game .screens .ShipMixedControl ;
22+ import org .destinationsol .game .SolGame ;
23+ import org .destinationsol .game .item .SolItem ;
24+ import org .destinationsol .game .screens .*;
2625
2726import java .util .ArrayList ;
27+ import java .util .List ;
2828
2929public class TutorialManager {
3030 private final Rectangle myBg ;
3131 private final ArrayList <Step > mySteps ;
3232
3333 private int myStepIdx ;
3434
35- public TutorialManager (float r , GameScreens screens , boolean mobile , GameOptions gameOptions ) {
35+ public TutorialManager (float r , GameScreens screens , boolean mobile , GameOptions gameOptions , SolGame game ) {
3636 float bgW = r * .5f ;
3737 float bgH = .2f ;
3838 myBg = new Rectangle (r /2 - bgW /2 , 1 - bgH , bgW , bgH );
@@ -127,10 +127,17 @@ public TutorialManager(float r, GameScreens screens, boolean mobile, GameOptions
127127 screens .inventoryScreen .showInventory .dropCtrl );
128128 }
129129
130+ // Extra step to make sure an equipped item is selected before asking player to unequip
131+ if (screens .inventoryScreen .getSelectedItem () == null ||
132+ (screens .inventoryScreen .getSelectedItem () != null && screens .inventoryScreen .getSelectedItem ().isEquipped () == 0 )) {
133+ s (new SelectEquippedItemStep (
134+ "Select an equipped item\n (note the text \" using\" )" , screens .inventoryScreen , game ));
135+ }
136+
130137 if (mobile ) {
131- s ("Unequip some item\n that is used now" , screens .inventoryScreen .showInventory .eq1Ctrl );
138+ s ("Unequip the item\n that is used now" , screens .inventoryScreen .showInventory .eq1Ctrl );
132139 } else {
133- s ("Unequip some item\n that is used now (" + gameOptions .getKeyEquipName () + " key)" ,
140+ s ("Unequip the item\n that is used now (" + gameOptions .getKeyEquipName () + " key)" ,
134141 screens .inventoryScreen .showInventory .eq1Ctrl );
135142 }
136143
@@ -209,11 +216,14 @@ private void s(String text, SolUiControl ctrl) {
209216 private void s (String text , SolUiControl ctrl , boolean checkOn ) {
210217 mySteps .add (new Step (text , ctrl , checkOn ));
211218 }
219+ private void s (Step step ) {
220+ mySteps .add (step );
221+ }
212222
213223 public void update () {
214224 Step step = mySteps .get (myStepIdx );
215- step .ctrl . enableWarn ();
216- if (step .checkOn ? step . ctrl . isOn () : step . ctrl . isJustOff ()) {
225+ step .highlight ();
226+ if (step .canProgressToNextStep ()) {
217227 myStepIdx ++;
218228 }
219229 }
@@ -239,5 +249,45 @@ public Step(String text, SolUiControl ctrl, boolean checkOn) {
239249 this .ctrl = ctrl ;
240250 this .checkOn = checkOn ;
241251 }
252+
253+ // highlight control that needs to be pressed
254+ public void highlight () {
255+ if (ctrl != null ) ctrl .enableWarn ();
256+ }
257+
258+ public boolean canProgressToNextStep () {
259+ if (checkOn ) {
260+ return ctrl .isOn ();
261+ } else {
262+ return ctrl .isJustOff ();
263+ }
264+ }
265+ }
266+
267+ public static class SelectEquippedItemStep extends Step {
268+ InventoryScreen inventoryScreen ;
269+ SolGame game ;
270+
271+ public SelectEquippedItemStep (String text , InventoryScreen inventoryScreen , SolGame game ) {
272+ super (text , null , true );
273+ this .inventoryScreen = inventoryScreen ;
274+ this .game = game ;
275+ }
276+
277+ @ Override
278+ public boolean canProgressToNextStep () {
279+ SolItem selected = inventoryScreen .getSelectedItem ();
280+ if (selected != null && selected .isEquipped () != 0 ) return true ;
281+ return false ;
282+ }
283+
284+ // Highlight all equipped items on opened inventory page
285+ @ Override
286+ public void highlight () {
287+ List <SolUiControl > equippedItemControls = inventoryScreen .getEquippedItemUIControlsForTutorial (game );
288+ for (SolUiControl control : equippedItemControls ) {
289+ control .enableWarn ();
290+ }
291+ }
242292 }
243293}
0 commit comments