I did some hackery to allow undoing multiple dialog file conversations. Might have some side effects on memory usage, though.
--- infinity/resource/dlg/Viewer.java
+++ infinity/resource/dlg/Viewer.java
@@ -52,6 +52,7 @@
private State currentstate;
private Transition currenttransition;
private boolean alive = true;
+ private DlgResource undoDlg;
Viewer(DlgResource dlg)
{
@@ -142,15 +143,27 @@
bundo.setEnabled(false);
}
+ public void setUndoDlg(DlgResource dlg) {
+ this.undoDlg = dlg;
+ bundo.setEnabled(true);
+ }
+
// --------------------- Begin Interface ActionListener ---------------------
public void actionPerformed(ActionEvent event)
{
if (!alive) return;
if (event.getSource() == bundo) {
+ if(lastStates.empty() && (undoDlg != null)) {
+ showExternState(undoDlg, -1, true);
+ return;
+ }
State oldstate = lastStates.pop();
Transition oldtrans = lastTransitions.pop();
- bundo.setEnabled(lastStates.size() > 0);
+ if (lastStates.empty() && (undoDlg == null)) {
+ bundo.setEnabled(false);
+ }
+ //bundo.setEnabled(lastStates.size() > 0);
if (oldstate != currentstate)
showState(oldstate.getNumber());
if (oldtrans != currenttransition)
@@ -202,16 +215,7 @@
else {
DlgResource newdlg = (DlgResource)ResourceFactory.getResource(
ResourceFactory.getInstance().getResourceEntry(next_dlg.toString()));
- alive = false;
- if (NearInfinity.getInstance().getViewable() == dlg)
- NearInfinity.getInstance().setViewable(newdlg);
- else {
- ViewFrame frame = (ViewFrame)getTopLevelAncestor();
- frame.setViewable(newdlg);
- }
- ((Viewer)newdlg.getDetailViewer()).showState(currenttransition.getNextDialogState());
- ((Viewer)newdlg.getDetailViewer()).showTransition(
- ((Viewer)newdlg.getDetailViewer()).currentstate.getFirstTrans());
+ showExternState(newdlg, currenttransition.getNextDialogState(), false);
}
}
if (alive) {
@@ -323,6 +327,26 @@
transTriList.add((ResponseTrigger)entry);
else if (entry instanceof Action)
actionList.add((Action)entry);
+ }
+ }
+
+ private void showExternState(DlgResource newdlg, int state, boolean isUndo) {
+
+ alive = false;
+ if (NearInfinity.getInstance().getViewable() == this.dlg)
+ NearInfinity.getInstance().setViewable(newdlg);
+ else {
+ ViewFrame frame = (ViewFrame)getTopLevelAncestor();
+ frame.setViewable(newdlg);
+ }
+ Viewer newdlg_viewer = (Viewer) newdlg.getDetailViewer();
+ if (isUndo) {
+ newdlg_viewer.alive = true;
+ }
+ else {
+ newdlg_viewer.setUndoDlg(this.dlg);
+ newdlg_viewer.showState(state);
+ newdlg_viewer.showTransition(newdlg_viewer.currentstate.getFirstTrans());
}
}