v3.0.0: removed scene resetting from custom note entry
This commit is contained in:
+67
-64
@@ -33,12 +33,11 @@ import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndJournal;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndJournalItem;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndJournalItem;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndTextInput;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndTextInput;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndTitledMessage;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndTitledMessage;
|
||||||
import com.watabou.noosa.Game;
|
|
||||||
import com.watabou.utils.Callback;
|
|
||||||
import com.watabou.utils.Reflection;
|
import com.watabou.utils.Reflection;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -66,39 +65,8 @@ public class CustomNoteButton extends IconButton {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameScene.show(new WndOptions(Icons.SCROLL_COLOR.get(),
|
GameScene.show(new WndNoteTypeSelect());
|
||||||
Messages.get(CustomNoteButton.class, "title"),
|
|
||||||
Messages.get(CustomNoteButton.class, "desc"),
|
|
||||||
Messages.get(CustomNoteButton.class, "new_text"),
|
|
||||||
Messages.get(CustomNoteButton.class, "new_floor"),
|
|
||||||
Messages.get(CustomNoteButton.class, "new_inv"),
|
|
||||||
Messages.get(CustomNoteButton.class, "new_type")){
|
|
||||||
@Override
|
|
||||||
protected void onSelect(int index) {
|
|
||||||
if (index == 0){
|
|
||||||
Notes.CustomRecord custom = new Notes.CustomRecord("", "");
|
|
||||||
addNote(custom,
|
|
||||||
Messages.get(CustomNoteButton.class, "new_text"),
|
|
||||||
Messages.get(CustomNoteButton.class, "new_text_title"));
|
|
||||||
} else if (index == 1){
|
|
||||||
GameScene.show(new WndDepthSelect());
|
|
||||||
} else if (index == 2){
|
|
||||||
GameScene.selectItem(itemSelector);
|
|
||||||
} else {
|
|
||||||
GameScene.show(new WndItemtypeSelect());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hide() {
|
|
||||||
//do nothing, prevents window closing when user steps back in note creation process
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
super.hide(); //actually hide in this case
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,6 +74,49 @@ public class CustomNoteButton extends IconButton {
|
|||||||
return Messages.get(this, "title");
|
return Messages.get(this, "title");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static WndNoteTypeSelect NOTE_SELECT_INSTANCE;
|
||||||
|
|
||||||
|
private class WndNoteTypeSelect extends WndOptions {
|
||||||
|
|
||||||
|
public WndNoteTypeSelect(){
|
||||||
|
super(Icons.SCROLL_COLOR.get(),
|
||||||
|
Messages.get(CustomNoteButton.class, "title"),
|
||||||
|
Messages.get(CustomNoteButton.class, "desc"),
|
||||||
|
Messages.get(CustomNoteButton.class, "new_text"),
|
||||||
|
Messages.get(CustomNoteButton.class, "new_floor"),
|
||||||
|
Messages.get(CustomNoteButton.class, "new_inv"),
|
||||||
|
Messages.get(CustomNoteButton.class, "new_type"));
|
||||||
|
NOTE_SELECT_INSTANCE = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSelect(int index) {
|
||||||
|
if (index == 0){
|
||||||
|
Notes.CustomRecord custom = new Notes.CustomRecord("", "");
|
||||||
|
addNote(null, custom,
|
||||||
|
Messages.get(CustomNoteButton.class, "new_text"),
|
||||||
|
Messages.get(CustomNoteButton.class, "new_text_title"));
|
||||||
|
} else if (index == 1){
|
||||||
|
GameScene.show(new WndDepthSelect());
|
||||||
|
} else if (index == 2){
|
||||||
|
GameScene.selectItem(itemSelector);
|
||||||
|
} else {
|
||||||
|
GameScene.show(new WndItemtypeSelect());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {
|
||||||
|
//do nothing, prevents window closing when user steps back in note creation process
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
super.hide(); //actually hide in this case
|
||||||
|
NOTE_SELECT_INSTANCE = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class WndDepthSelect extends WndTitledMessage {
|
private class WndDepthSelect extends WndTitledMessage {
|
||||||
|
|
||||||
public WndDepthSelect(){
|
public WndDepthSelect(){
|
||||||
@@ -125,7 +136,7 @@ public class CustomNoteButton extends IconButton {
|
|||||||
RedButton btnDepth = new RedButton(Integer.toString(finalI)){
|
RedButton btnDepth = new RedButton(Integer.toString(finalI)){
|
||||||
@Override
|
@Override
|
||||||
protected void onClick() {
|
protected void onClick() {
|
||||||
addNote(new Notes.CustomRecord(finalI, "", ""),
|
addNote(WndDepthSelect.this, new Notes.CustomRecord(finalI, "", ""),
|
||||||
Messages.get(CustomNoteButton.class, "new_floor"),
|
Messages.get(CustomNoteButton.class, "new_floor"),
|
||||||
Messages.get(CustomNoteButton.class, "new_floor_title", finalI));
|
Messages.get(CustomNoteButton.class, "new_floor_title", finalI));
|
||||||
}
|
}
|
||||||
@@ -175,7 +186,7 @@ public class CustomNoteButton extends IconButton {
|
|||||||
((EquipableItem) item).customNoteID = custom.ID();
|
((EquipableItem) item).customNoteID = custom.ID();
|
||||||
}
|
}
|
||||||
|
|
||||||
addNote(custom,
|
addNote(null, custom,
|
||||||
Messages.get(CustomNoteButton.class, "new_inv"),
|
Messages.get(CustomNoteButton.class, "new_inv"),
|
||||||
Messages.get(CustomNoteButton.class, "new_item_title", Messages.titleCase(item.name())));
|
Messages.get(CustomNoteButton.class, "new_item_title", Messages.titleCase(item.name())));
|
||||||
}
|
}
|
||||||
@@ -207,7 +218,7 @@ public class CustomNoteButton extends IconButton {
|
|||||||
ItemButton itemButton = new ItemButton(){
|
ItemButton itemButton = new ItemButton(){
|
||||||
@Override
|
@Override
|
||||||
protected void onClick() {
|
protected void onClick() {
|
||||||
addNote(new Notes.CustomRecord(item, "", ""),
|
addNote(WndItemtypeSelect.this, new Notes.CustomRecord(item, "", ""),
|
||||||
Messages.get(CustomNoteButton.class, "new_type"),
|
Messages.get(CustomNoteButton.class, "new_type"),
|
||||||
Messages.get(CustomNoteButton.class, "new_item_title", Messages.titleCase(item.name())));
|
Messages.get(CustomNoteButton.class, "new_item_title", Messages.titleCase(item.name())));
|
||||||
}
|
}
|
||||||
@@ -271,7 +282,8 @@ public class CustomNoteButton extends IconButton {
|
|||||||
public void onSelect(boolean positive, String text) {
|
public void onSelect(boolean positive, String text) {
|
||||||
if (positive && !text.isEmpty()){
|
if (positive && !text.isEmpty()){
|
||||||
rec.editText(text, rec.desc());
|
rec.editText(text, rec.desc());
|
||||||
refreshScene(rec);
|
CustomNoteWindow.this.hide();
|
||||||
|
ShatteredPixelDungeon.scene().addToFront(new CustomNoteWindow(rec));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -295,7 +307,8 @@ public class CustomNoteButton extends IconButton {
|
|||||||
public void onSelect(boolean positive, String text) {
|
public void onSelect(boolean positive, String text) {
|
||||||
if (positive){
|
if (positive){
|
||||||
rec.editText(rec.title(), text);
|
rec.editText(rec.title(), text);
|
||||||
refreshScene(rec);
|
CustomNoteWindow.this.hide();
|
||||||
|
ShatteredPixelDungeon.scene().addToFront(new CustomNoteWindow(rec));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -316,7 +329,8 @@ public class CustomNoteButton extends IconButton {
|
|||||||
protected void onSelect(int index) {
|
protected void onSelect(int index) {
|
||||||
if (index == 0){
|
if (index == 0){
|
||||||
Notes.remove(rec);
|
Notes.remove(rec);
|
||||||
refreshScene(null);
|
CustomNoteWindow.this.hide();
|
||||||
|
ShatteredPixelDungeon.scene().addToFront(new WndJournal());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -334,7 +348,7 @@ public class CustomNoteButton extends IconButton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addNote(Notes.CustomRecord note, String promptTitle, String prompttext){
|
private static void addNote(Window parentWindow, Notes.CustomRecord note, String promptTitle, String prompttext){
|
||||||
GameScene.show(new WndTextInput(promptTitle,
|
GameScene.show(new WndTextInput(promptTitle,
|
||||||
prompttext,
|
prompttext,
|
||||||
"",
|
"",
|
||||||
@@ -347,32 +361,21 @@ public class CustomNoteButton extends IconButton {
|
|||||||
if (positive && !text.isEmpty()){
|
if (positive && !text.isEmpty()){
|
||||||
Notes.add(note);
|
Notes.add(note);
|
||||||
note.editText(text, "");
|
note.editText(text, "");
|
||||||
refreshScene(null);
|
if (parentWindow != null) {
|
||||||
|
parentWindow.hide();
|
||||||
|
}
|
||||||
|
if (WndBag.INSTANCE != null) {
|
||||||
|
WndBag.INSTANCE.hide();
|
||||||
|
}
|
||||||
|
if (NOTE_SELECT_INSTANCE != null){
|
||||||
|
NOTE_SELECT_INSTANCE.onBackPressed();
|
||||||
|
}
|
||||||
|
hide();
|
||||||
|
ShatteredPixelDungeon.scene().addToFront(new WndJournal());
|
||||||
|
ShatteredPixelDungeon.scene().addToFront(new CustomNoteWindow(note));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void refreshScene(Notes.CustomRecord recToShow){
|
|
||||||
if (recToShow == null){
|
|
||||||
ShatteredPixelDungeon.seamlessResetScene();
|
|
||||||
} else {
|
|
||||||
ShatteredPixelDungeon.seamlessResetScene(new Game.SceneChangeCallback() {
|
|
||||||
@Override
|
|
||||||
public void beforeCreate() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterCreate() {
|
|
||||||
Game.runOnRenderThread(new Callback() {
|
|
||||||
@Override
|
|
||||||
public void call() {
|
|
||||||
ShatteredPixelDungeon.scene().addToFront(new CustomNoteWindow(recToShow));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,8 +100,14 @@ public class WndJournal extends WndTabbed {
|
|||||||
private BadgesTab badgesTab;
|
private BadgesTab badgesTab;
|
||||||
|
|
||||||
public static int last_index = 0;
|
public static int last_index = 0;
|
||||||
|
|
||||||
|
private static WndJournal INSTANCE = null;
|
||||||
|
|
||||||
public WndJournal(){
|
public WndJournal(){
|
||||||
|
|
||||||
|
if (INSTANCE != null){
|
||||||
|
INSTANCE.hide();
|
||||||
|
}
|
||||||
|
|
||||||
int width = PixelScene.landscape() ? WIDTH_L : WIDTH_P;
|
int width = PixelScene.landscape() ? WIDTH_L : WIDTH_P;
|
||||||
int height = PixelScene.landscape() ? HEIGHT_L : HEIGHT_P;
|
int height = PixelScene.landscape() ? HEIGHT_L : HEIGHT_P;
|
||||||
@@ -202,6 +208,8 @@ public class WndJournal extends WndTabbed {
|
|||||||
layoutTabs();
|
layoutTabs();
|
||||||
|
|
||||||
select(last_index);
|
select(last_index);
|
||||||
|
|
||||||
|
INSTANCE = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user