v1.4.0: made tutorial significantly more robust

This commit is contained in:
Evan Debenham
2022-09-26 16:57:00 -04:00
parent ee3f92c5c6
commit 7e5dc130ba
6 changed files with 66 additions and 32 deletions

View File

@@ -40,8 +40,15 @@ public class Guidebook extends Item {
@Override
public final boolean doPickUp(Hero hero, int pos) {
Document.ADVENTURERS_GUIDE.findPage(Document.GUIDE_INTRO);
Document.ADVENTURERS_GUIDE.findPage(Document.GUIDE_EXAMINING);
Document.ADVENTURERS_GUIDE.findPage(Document.GUIDE_SURPRISE_ATKS);
Document.ADVENTURERS_GUIDE.findPage(Document.GUIDE_IDING);
Document.ADVENTURERS_GUIDE.findPage(Document.GUIDE_FOOD);
Document.ADVENTURERS_GUIDE.findPage(Document.GUIDE_DIEING);
GameScene.pickUpJournal(this, pos);
//we do this here so it appears before the tutorial text
//we do this here so the pickup message appears before the tutorial text
GameLog.wipe();
GLog.i( Messages.capitalize(Messages.get(Hero.class, "you_now_have", name())) );
GLog.p(Messages.get(GameScene.class, "tutorial_guidebook"));

View File

@@ -62,7 +62,7 @@ public enum Document {
public static final int READ = 2;
private LinkedHashMap<String, Integer> pagesStates = new LinkedHashMap<>();
public boolean findPage(String page ) {
public boolean findPage( String page ) {
if (pagesStates.containsKey(page) && pagesStates.get(page) == NOT_FOUND){
pagesStates.put(page, FOUND);
Journal.saveNeeded = true;
@@ -75,6 +75,19 @@ public enum Document {
return findPage( pagesStates.keySet().toArray(new String[0])[pageIdx] );
}
public boolean deletePage( String page ){
if (pagesStates.containsKey(page) && pagesStates.get(page) != NOT_FOUND){
pagesStates.put(page, NOT_FOUND);
Journal.saveNeeded = true;
return true;
}
return false;
}
public boolean deletePage( int pageIdx ) {
return deletePage( pagesStates.keySet().toArray(new String[0])[pageIdx] );
}
public boolean isPageFound( String page ){
return pagesStates.containsKey(page) && pagesStates.get(page) > NOT_FOUND;
}
@@ -214,18 +227,19 @@ public enum Document {
public static final String GUIDE_IDING = "Identifying";
public static final String GUIDE_FOOD = "Food";
public static final String GUIDE_DIEING = "Dieing";
public static final String GUIDE_SEARCHING = "Searching";
//pages and default states
static {
boolean debug = DeviceCompat.isDebug();
//hero starts with these
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_INTRO, debug ? READ : FOUND);
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_EXAMINING, debug ? READ : FOUND);
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_SURPRISE_ATKS, debug ? READ : FOUND);
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_IDING, debug ? READ : FOUND);
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_FOOD, debug ? READ : FOUND);
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_DIEING, debug ? READ : FOUND);
//hero gets these when guidebook is collected
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_INTRO, debug ? READ : NOT_FOUND);
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_EXAMINING, debug ? READ : NOT_FOUND);
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_SURPRISE_ATKS, debug ? READ : NOT_FOUND);
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_IDING, debug ? READ : NOT_FOUND);
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_FOOD, debug ? READ : NOT_FOUND);
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_DIEING, debug ? READ : NOT_FOUND);
//given in sewers
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_SEARCHING, debug ? READ : NOT_FOUND);
ADVENTURERS_GUIDE.pagesStates.put("Strength", debug ? READ : NOT_FOUND);

View File

@@ -587,19 +587,26 @@ public class GameScene extends PixelScene {
//Tutorial
if (SPDSettings.intro()){
if (ControllerHandler.isControllerConnected()){
GLog.p(Messages.get(GameScene.class, "tutorial_move_controller"));
} else if (SPDSettings.interfaceSize() == 0){
GLog.p(Messages.get(GameScene.class, "tutorial_move_mobile"));
if (Document.ADVENTURERS_GUIDE.isPageFound(Document.GUIDE_INTRO)){
GLog.p(Messages.get(GameScene.class, "tutorial_guidebook"));
flashForDocument(Document.ADVENTURERS_GUIDE, Document.GUIDE_INTRO);
} else {
GLog.p(Messages.get(GameScene.class, "tutorial_move_desktop"));
if (ControllerHandler.isControllerConnected()) {
GLog.p(Messages.get(GameScene.class, "tutorial_move_controller"));
} else if (SPDSettings.interfaceSize() == 0) {
GLog.p(Messages.get(GameScene.class, "tutorial_move_mobile"));
} else {
GLog.p(Messages.get(GameScene.class, "tutorial_move_desktop"));
}
}
toolbar.visible = toolbar.active = false;
status.visible = status.active = false;
if (inventory != null) inventory.visible = inventory.active = false;
}
if (Rankings.INSTANCE.totalNumber > 0 && !Document.ADVENTURERS_GUIDE.isPageRead(Document.GUIDE_DIEING)){
if (!SPDSettings.intro() &&
Rankings.INSTANCE.totalNumber > 0 &&
!Document.ADVENTURERS_GUIDE.isPageRead(Document.GUIDE_DIEING)){
GLog.p(Messages.get(Guidebook.class, "hint"));
GameScene.flashForDocument(Document.ADVENTURERS_GUIDE, Document.GUIDE_DIEING);
}

View File

@@ -216,7 +216,7 @@ public class HeroSelectScene extends PixelScene {
btnExit = new ExitButton();
btnExit.setPos( Camera.main.width - btnExit.width(), 0 );
add( btnExit );
btnExit.visible = !SPDSettings.intro();
btnExit.visible = btnExit.active = !SPDSettings.intro();
prompt = PixelScene.renderTextBlock(Messages.get(this, "title"), 12);
prompt.hardlight(Window.TITLE_COLOR);
@@ -282,7 +282,7 @@ public class HeroSelectScene extends PixelScene {
@Override
public void update() {
super.update();
btnExit.visible = !SPDSettings.intro();
btnExit.visible = btnExit.active = !SPDSettings.intro();
//do not fade when a window is open
for (Object v : members){
if (v instanceof Window) resetFade();
@@ -310,7 +310,7 @@ public class HeroSelectScene extends PixelScene {
@Override
protected void onBackPressed() {
if (btnExit.visible){
if (btnExit.active){
ShatteredPixelDungeon.switchScene(TitleScene.class);
} else {
super.onBackPressed();

View File

@@ -34,6 +34,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Statistics;
import com.shatteredpixel.shatteredpixeldungeon.effects.BannerSprites;
import com.shatteredpixel.shatteredpixeldungeon.effects.Fireball;
import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
import com.shatteredpixel.shatteredpixeldungeon.journal.Journal;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.Archs;
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
@@ -88,8 +89,14 @@ public class WelcomeScene extends PixelScene {
return;
} else {
//TODO temporary so alpha/beta players can test the tutorial
if (previousVersion <= 653){
if (previousVersion <= 653 && GamesInProgress.firstEmpty() != -1){
SPDSettings.intro(true);
} else if (GamesInProgress.firstEmpty() == -1){
SPDSettings.intro(false);
}
if (SPDSettings.intro()){
Journal.loadGlobal();
Document.ADVENTURERS_GUIDE.deletePage(Document.GUIDE_INTRO);
}
}

View File

@@ -111,20 +111,19 @@ public class WndGame extends Window {
}
// Main menu
if (!SPDSettings.intro()) {
addButton(curBtn = new RedButton(Messages.get(this, "menu")) {
@Override
protected void onClick() {
try {
Dungeon.saveAll();
} catch (IOException e) {
ShatteredPixelDungeon.reportException(e);
}
Game.switchScene(TitleScene.class);
addButton(curBtn = new RedButton(Messages.get(this, "menu")) {
@Override
protected void onClick() {
try {
Dungeon.saveAll();
} catch (IOException e) {
ShatteredPixelDungeon.reportException(e);
}
});
curBtn.icon(Icons.get(Icons.DISPLAY));
}
Game.switchScene(TitleScene.class);
}
});
curBtn.icon(Icons.get(Icons.DISPLAY));
if (SPDSettings.intro()) curBtn.enable(false);
resize( WIDTH, pos );
}