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