added option to skip text-loading
This commit is contained in:
parent
37a26627f2
commit
e8c909de67
@ -10,6 +10,7 @@ public class Dialog {
|
|||||||
private Timer timer;
|
private Timer timer;
|
||||||
private DialogBar dialogBar;
|
private DialogBar dialogBar;
|
||||||
private int charNumber;
|
private int charNumber;
|
||||||
|
private boolean timerIsRunning;
|
||||||
|
|
||||||
Dialog(String text, DialogBar dialogBar) {
|
Dialog(String text, DialogBar dialogBar) {
|
||||||
this.text = text;
|
this.text = text;
|
||||||
@ -69,16 +70,26 @@ public class Dialog {
|
|||||||
public void showText() {
|
public void showText() {
|
||||||
charNumber = 0;
|
charNumber = 0;
|
||||||
dialogBar.setVisible(true);
|
dialogBar.setVisible(true);
|
||||||
timer = new Timer(17, new ActionListener() {
|
timer = new Timer(20, new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
showByChar();
|
showByChar();
|
||||||
dialogBar.repaint();
|
dialogBar.repaint();
|
||||||
|
timerIsRunning = timer.isRunning();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
timer.start();
|
timer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void skipShowText() {
|
||||||
|
timer.stop();
|
||||||
|
timerIsRunning = false;
|
||||||
|
dialogBar.remove(0);
|
||||||
|
dialogBar.repaint();
|
||||||
|
dialogBar.add(prepareDialogBar(text));
|
||||||
|
dialogBar.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
public void hideText() {
|
public void hideText() {
|
||||||
dialogBar.setVisible(false);
|
dialogBar.setVisible(false);
|
||||||
dialogBar.repaint();
|
dialogBar.repaint();
|
||||||
@ -92,5 +103,9 @@ public class Dialog {
|
|||||||
public void setImageDialog(ImageDialog imageDialog) {
|
public void setImageDialog(ImageDialog imageDialog) {
|
||||||
this.imageDialog = imageDialog;
|
this.imageDialog = imageDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getTimerIsRunning() {
|
||||||
|
return timerIsRunning;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,7 @@ public class InteractionCell extends Cell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void readNextLine() {
|
public void readNextLine() {
|
||||||
if (scanner.hasNextLine()) {
|
if (scanner.hasNextLine() && !dialog.getTimerIsRunning()) {
|
||||||
String data = scanner.nextLine();
|
String data = scanner.nextLine();
|
||||||
if (data.equals("<end>"))
|
if (data.equals("<end>"))
|
||||||
endEvent();
|
endEvent();
|
||||||
@ -47,9 +47,11 @@ public class InteractionCell extends Cell {
|
|||||||
dialog.hideText();
|
dialog.hideText();
|
||||||
dialog.setText(data);
|
dialog.setText(data);
|
||||||
dialog.showText();
|
dialog.showText();
|
||||||
dialog.prepareDialogBar(data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
dialog.skipShowText();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endEvent() {
|
public void endEvent() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user