v1.4.0: made tutorial significantly more robust
This commit is contained in:
+8
-1
@@ -40,8 +40,15 @@ public class Guidebook extends Item {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final boolean doPickUp(Hero hero, int pos) {
|
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);
|
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();
|
GameLog.wipe();
|
||||||
GLog.i( Messages.capitalize(Messages.get(Hero.class, "you_now_have", name())) );
|
GLog.i( Messages.capitalize(Messages.get(Hero.class, "you_now_have", name())) );
|
||||||
GLog.p(Messages.get(GameScene.class, "tutorial_guidebook"));
|
GLog.p(Messages.get(GameScene.class, "tutorial_guidebook"));
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public enum Document {
|
|||||||
public static final int READ = 2;
|
public static final int READ = 2;
|
||||||
private LinkedHashMap<String, Integer> pagesStates = new LinkedHashMap<>();
|
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){
|
if (pagesStates.containsKey(page) && pagesStates.get(page) == NOT_FOUND){
|
||||||
pagesStates.put(page, FOUND);
|
pagesStates.put(page, FOUND);
|
||||||
Journal.saveNeeded = true;
|
Journal.saveNeeded = true;
|
||||||
@@ -75,6 +75,19 @@ public enum Document {
|
|||||||
return findPage( pagesStates.keySet().toArray(new String[0])[pageIdx] );
|
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 ){
|
public boolean isPageFound( String page ){
|
||||||
return pagesStates.containsKey(page) && pagesStates.get(page) > NOT_FOUND;
|
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_IDING = "Identifying";
|
||||||
public static final String GUIDE_FOOD = "Food";
|
public static final String GUIDE_FOOD = "Food";
|
||||||
public static final String GUIDE_DIEING = "Dieing";
|
public static final String GUIDE_DIEING = "Dieing";
|
||||||
|
|
||||||
public static final String GUIDE_SEARCHING = "Searching";
|
public static final String GUIDE_SEARCHING = "Searching";
|
||||||
|
|
||||||
//pages and default states
|
//pages and default states
|
||||||
static {
|
static {
|
||||||
boolean debug = DeviceCompat.isDebug();
|
boolean debug = DeviceCompat.isDebug();
|
||||||
//hero starts with these
|
//hero gets these when guidebook is collected
|
||||||
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_INTRO, debug ? READ : FOUND);
|
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_INTRO, debug ? READ : NOT_FOUND);
|
||||||
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_EXAMINING, debug ? READ : FOUND);
|
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_EXAMINING, debug ? READ : NOT_FOUND);
|
||||||
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_SURPRISE_ATKS, debug ? READ : FOUND);
|
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_SURPRISE_ATKS, debug ? READ : NOT_FOUND);
|
||||||
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_IDING, debug ? READ : FOUND);
|
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_IDING, debug ? READ : NOT_FOUND);
|
||||||
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_FOOD, debug ? READ : FOUND);
|
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_FOOD, debug ? READ : NOT_FOUND);
|
||||||
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_DIEING, debug ? READ : FOUND);
|
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_DIEING, debug ? READ : NOT_FOUND);
|
||||||
//given in sewers
|
//given in sewers
|
||||||
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_SEARCHING, debug ? READ : NOT_FOUND);
|
ADVENTURERS_GUIDE.pagesStates.put(GUIDE_SEARCHING, debug ? READ : NOT_FOUND);
|
||||||
ADVENTURERS_GUIDE.pagesStates.put("Strength", debug ? READ : NOT_FOUND);
|
ADVENTURERS_GUIDE.pagesStates.put("Strength", debug ? READ : NOT_FOUND);
|
||||||
|
|||||||
@@ -587,19 +587,26 @@ public class GameScene extends PixelScene {
|
|||||||
//Tutorial
|
//Tutorial
|
||||||
if (SPDSettings.intro()){
|
if (SPDSettings.intro()){
|
||||||
|
|
||||||
if (ControllerHandler.isControllerConnected()){
|
if (Document.ADVENTURERS_GUIDE.isPageFound(Document.GUIDE_INTRO)){
|
||||||
GLog.p(Messages.get(GameScene.class, "tutorial_move_controller"));
|
GLog.p(Messages.get(GameScene.class, "tutorial_guidebook"));
|
||||||
} else if (SPDSettings.interfaceSize() == 0){
|
flashForDocument(Document.ADVENTURERS_GUIDE, Document.GUIDE_INTRO);
|
||||||
GLog.p(Messages.get(GameScene.class, "tutorial_move_mobile"));
|
|
||||||
} else {
|
} 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;
|
toolbar.visible = toolbar.active = false;
|
||||||
status.visible = status.active = false;
|
status.visible = status.active = false;
|
||||||
if (inventory != null) inventory.visible = inventory.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"));
|
GLog.p(Messages.get(Guidebook.class, "hint"));
|
||||||
GameScene.flashForDocument(Document.ADVENTURERS_GUIDE, Document.GUIDE_DIEING);
|
GameScene.flashForDocument(Document.ADVENTURERS_GUIDE, Document.GUIDE_DIEING);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -216,7 +216,7 @@ public class HeroSelectScene extends PixelScene {
|
|||||||
btnExit = new ExitButton();
|
btnExit = new ExitButton();
|
||||||
btnExit.setPos( Camera.main.width - btnExit.width(), 0 );
|
btnExit.setPos( Camera.main.width - btnExit.width(), 0 );
|
||||||
add( btnExit );
|
add( btnExit );
|
||||||
btnExit.visible = !SPDSettings.intro();
|
btnExit.visible = btnExit.active = !SPDSettings.intro();
|
||||||
|
|
||||||
prompt = PixelScene.renderTextBlock(Messages.get(this, "title"), 12);
|
prompt = PixelScene.renderTextBlock(Messages.get(this, "title"), 12);
|
||||||
prompt.hardlight(Window.TITLE_COLOR);
|
prompt.hardlight(Window.TITLE_COLOR);
|
||||||
@@ -282,7 +282,7 @@ public class HeroSelectScene extends PixelScene {
|
|||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
super.update();
|
super.update();
|
||||||
btnExit.visible = !SPDSettings.intro();
|
btnExit.visible = btnExit.active = !SPDSettings.intro();
|
||||||
//do not fade when a window is open
|
//do not fade when a window is open
|
||||||
for (Object v : members){
|
for (Object v : members){
|
||||||
if (v instanceof Window) resetFade();
|
if (v instanceof Window) resetFade();
|
||||||
@@ -310,7 +310,7 @@ public class HeroSelectScene extends PixelScene {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onBackPressed() {
|
protected void onBackPressed() {
|
||||||
if (btnExit.visible){
|
if (btnExit.active){
|
||||||
ShatteredPixelDungeon.switchScene(TitleScene.class);
|
ShatteredPixelDungeon.switchScene(TitleScene.class);
|
||||||
} else {
|
} else {
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
|
|||||||
+8
-1
@@ -34,6 +34,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Statistics;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.BannerSprites;
|
import com.shatteredpixel.shatteredpixeldungeon.effects.BannerSprites;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Fireball;
|
import com.shatteredpixel.shatteredpixeldungeon.effects.Fireball;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
|
import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.journal.Journal;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Archs;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.Archs;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
|
||||||
@@ -88,8 +89,14 @@ public class WelcomeScene extends PixelScene {
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
//TODO temporary so alpha/beta players can test the tutorial
|
//TODO temporary so alpha/beta players can test the tutorial
|
||||||
if (previousVersion <= 653){
|
if (previousVersion <= 653 && GamesInProgress.firstEmpty() != -1){
|
||||||
SPDSettings.intro(true);
|
SPDSettings.intro(true);
|
||||||
|
} else if (GamesInProgress.firstEmpty() == -1){
|
||||||
|
SPDSettings.intro(false);
|
||||||
|
}
|
||||||
|
if (SPDSettings.intro()){
|
||||||
|
Journal.loadGlobal();
|
||||||
|
Document.ADVENTURERS_GUIDE.deletePage(Document.GUIDE_INTRO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -111,20 +111,19 @@ public class WndGame extends Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Main menu
|
// Main menu
|
||||||
if (!SPDSettings.intro()) {
|
addButton(curBtn = new RedButton(Messages.get(this, "menu")) {
|
||||||
addButton(curBtn = new RedButton(Messages.get(this, "menu")) {
|
@Override
|
||||||
@Override
|
protected void onClick() {
|
||||||
protected void onClick() {
|
try {
|
||||||
try {
|
Dungeon.saveAll();
|
||||||
Dungeon.saveAll();
|
} catch (IOException e) {
|
||||||
} catch (IOException e) {
|
ShatteredPixelDungeon.reportException(e);
|
||||||
ShatteredPixelDungeon.reportException(e);
|
|
||||||
}
|
|
||||||
Game.switchScene(TitleScene.class);
|
|
||||||
}
|
}
|
||||||
});
|
Game.switchScene(TitleScene.class);
|
||||||
curBtn.icon(Icons.get(Icons.DISPLAY));
|
}
|
||||||
}
|
});
|
||||||
|
curBtn.icon(Icons.get(Icons.DISPLAY));
|
||||||
|
if (SPDSettings.intro()) curBtn.enable(false);
|
||||||
|
|
||||||
resize( WIDTH, pos );
|
resize( WIDTH, pos );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user