source: lost-perception/main/Dialog.java

Last change on this file was ebd3538, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 6 years ago

Initial commit. This codebase for the Lost Perception game was created by decompiling code from a jar file.

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[ebd3538]1package main;
2
3import java.awt.FontMetrics;
4import java.util.HashMap;
5import java.util.ArrayList;
6import utils.WrappedString;
7
8public class Dialog
9{
10 WrappedString text;
11 private ArrayList<WrappedString> options;
12 private ArrayList<Dialog> references;
13 private HashMap<Integer, Integer> triggerMap;
14 FontMetrics metrics;
15 int width;
16
17 public Dialog(final String text, final FontMetrics metrics, final int width) {
18 this.text = new WrappedString(text, metrics, width);
19 this.options = new ArrayList<WrappedString>();
20 this.references = new ArrayList<Dialog>();
21 this.triggerMap = new HashMap<Integer, Integer>();
22 this.metrics = metrics;
23 this.width = width;
24 }
25
26 public int getNumOptions() {
27 return this.options.size();
28 }
29
30 public WrappedString getOption(final int num) {
31 return this.options.get(num);
32 }
33
34 public Dialog getReference(final int num) {
35 return this.references.get(num);
36 }
37
38 public void addEndOption() {
39 this.addOption("(end)", null);
40 }
41
42 public void addContinueOption(final Dialog reference) {
43 this.addOption("(continue)", reference);
44 }
45
46 public void addOption(final String option, final Dialog reference) {
47 this.options.add(new WrappedString(option, this.metrics, this.width));
48 this.references.add(reference);
49 }
50
51 public void changeReference(final int refNum, final Dialog reference) {
52 this.references.set(refNum, reference);
53 }
54
55 public Integer getTrigger(final int option) {
56 return this.triggerMap.get(option);
57 }
58
59 public void addTrigger(final int option, final int triggerNum) {
60 this.triggerMap.put(option, triggerNum);
61 }
62}
Note: See TracBrowser for help on using the repository browser.