1 | package main;
|
---|
2 |
|
---|
3 | import java.awt.FontMetrics;
|
---|
4 | import java.util.HashMap;
|
---|
5 | import java.util.ArrayList;
|
---|
6 | import utils.WrappedString;
|
---|
7 |
|
---|
8 | public 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 | }
|
---|