From 42df08befcd4d8144b5d5e7ca58f11a877bae9a7 Mon Sep 17 00:00:00 2001 From: musilto9 Date: Sat, 14 Mar 2020 00:41:25 +0100 Subject: [PATCH] added multiline dialogues --- .../game/gameOfProd/Cells/InteractionCell.java | 2 ++ .../ruscz/game/gameOfProd/Dialog/Dialog.java | 5 ++++- .../gameOfProd/Windows/WindowOfFreeMove.java | 5 ++++- src/main/resources/boobs.txt | 4 ++++ src/main/resources/dialog-test.txt | 3 +-- src/main/resources/first-dialog.txt | 3 +-- src/main/resources/javascript.txt | 4 ++++ src/main/resources/qa-tester.txt | 16 ++++++++++++++++ src/main/resources/roses-are-red.txt | 3 +++ src/main/resources/second-dialog.txt | 5 ----- 10 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 src/main/resources/boobs.txt create mode 100644 src/main/resources/javascript.txt create mode 100644 src/main/resources/qa-tester.txt create mode 100644 src/main/resources/roses-are-red.txt delete mode 100644 src/main/resources/second-dialog.txt diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java b/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java index 72c843e..b7b0f34 100644 --- a/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java @@ -52,6 +52,8 @@ public class InteractionCell extends Cell { readNextLine(); } else { + if (data.contains("
")) + data = "" + data + ""; dialog.hideText(); dialog.setText(data); dialog.showText(); diff --git a/src/main/java/ruscz/game/gameOfProd/Dialog/Dialog.java b/src/main/java/ruscz/game/gameOfProd/Dialog/Dialog.java index 98c6f3c..32c6003 100644 --- a/src/main/java/ruscz/game/gameOfProd/Dialog/Dialog.java +++ b/src/main/java/ruscz/game/gameOfProd/Dialog/Dialog.java @@ -1,6 +1,7 @@ package ruscz.game.gameOfProd.Dialog; import ruscz.game.gameOfProd.Image.ImageDialog; +import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; import javax.swing.*; import java.awt.*; @@ -41,10 +42,10 @@ public class Dialog { Font f1 = new Font("Times New Roman", Font.PLAIN, 20); JLabel text = new JLabel(); + text.setText(string); text.setFont(f1); text.setForeground(Color.red); text.setVisible(true); - text.setText(string); Dimension size = text.getPreferredSize(); if (imageDialog != null) { @@ -73,6 +74,8 @@ public class Dialog { public void showText() { charNumber = 0; + if (text.contains("")) + charNumber = 6; dialogBar.setVisible(true); timer = new Timer(20, new ActionListener() { @Override diff --git a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java index f2daeff..42d7c60 100644 --- a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java +++ b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java @@ -158,16 +158,19 @@ public class WindowOfFreeMove extends JFrame { m1.addMoveToEvent(new EventMoveToCell(4, 3, 8, 1, m4, this)); m1.addInteractionEvent(new InteractionCell(3,5,"first-dialog", new Dialog(dialogBar), m1.getImageCell())); m1.addInteractionEvent(new InteractionCell(5, 5, "dialog-test", new Dialog(dialogBar), m1.getImageCell())); - m1.addInteractionEvent(new TriggerCell(2,2,"second-dialog", new Dialog(dialogBar), m1.getImageCell())); + m1.addInteractionEvent(new TriggerCell(4,6,"roses-are-red", new Dialog(dialogBar), m1.getImageCell())); m2.addMoveToEvent(new EventMoveToCell(2, 1, 8, 8, m3, this)); m2.addMoveToEvent(new EventMoveToCell(1, 3, 8, 1, m1, this)); + m2.addInteractionEvent(new TriggerCell(7,2,"qa-tester", new Dialog(dialogBar), m1.getImageCell())); m3.addMoveToEvent(new EventMoveToCell(3, 1, 8, 8, m4, this)); m3.addMoveToEvent(new EventMoveToCell(2, 3, 8, 1, m2, this)); + m3.addInteractionEvent(new TriggerCell(2,5,"boobs", new Dialog(dialogBar), m1.getImageCell())); m4.addMoveToEvent(new EventMoveToCell(4, 1, 8, 8, m1, this)); m4.addMoveToEvent(new EventMoveToCell(3, 3, 8, 1, m3, this)); + m4.addInteractionEvent(new TriggerCell(3,3,"javascript", new Dialog(dialogBar), m1.getImageCell())); m1.getImageCell().readMapFile("m1-tileset"); m2.getImageCell().readMapFile("m1-tileset"); diff --git a/src/main/resources/boobs.txt b/src/main/resources/boobs.txt new file mode 100644 index 0000000..78f5aea --- /dev/null +++ b/src/main/resources/boobs.txt @@ -0,0 +1,4 @@ +What did one boob say to the other? +You are my breastfriend +*badumm tits* + \ No newline at end of file diff --git a/src/main/resources/dialog-test.txt b/src/main/resources/dialog-test.txt index 3de737f..1ec9407 100644 --- a/src/main/resources/dialog-test.txt +++ b/src/main/resources/dialog-test.txt @@ -1,5 +1,4 @@ Keep out BaetoriceFace.png -This sign can't stop me -because I can't read +This sign can't stop me
because I can't read \ No newline at end of file diff --git a/src/main/resources/first-dialog.txt b/src/main/resources/first-dialog.txt index 051a575..53c3e6b 100644 --- a/src/main/resources/first-dialog.txt +++ b/src/main/resources/first-dialog.txt @@ -1,5 +1,4 @@ Keep out ... -or enter -I'm a sign not a cop +or enter
I'm a sign not a cop \ No newline at end of file diff --git a/src/main/resources/javascript.txt b/src/main/resources/javascript.txt new file mode 100644 index 0000000..e8a6602 --- /dev/null +++ b/src/main/resources/javascript.txt @@ -0,0 +1,4 @@ +Dad: Why are your eyes red son? +Son: I smoke weed +Dad: Don't lie, you're crying because
you have been coding in javascript + \ No newline at end of file diff --git a/src/main/resources/qa-tester.txt b/src/main/resources/qa-tester.txt new file mode 100644 index 0000000..58028c8 --- /dev/null +++ b/src/main/resources/qa-tester.txt @@ -0,0 +1,16 @@ +A QA tester walks into a bar: +He orders a beer. +He orders 3 beers. +He orders 2976412836 beers. +He orders 0 beers. +He orders -1 beers. +He orders q beers. +He orders nothing. +Él ordena una cerveza. +He orders a deer. +He tries to leave without paying. +He starts ordering one beer
then throws himself out of window. +He orders a beer, gets his receipt
then tries to go back. +He orders a beer, goes to the door of the bar
throws handful of cookies onto the street ... +... then goes back to see if barman
still recognises him. + \ No newline at end of file diff --git a/src/main/resources/roses-are-red.txt b/src/main/resources/roses-are-red.txt new file mode 100644 index 0000000..f2f1d83 --- /dev/null +++ b/src/main/resources/roses-are-red.txt @@ -0,0 +1,3 @@ +Roses are red
violets are blue +unexpected "{"
on line 32 + \ No newline at end of file diff --git a/src/main/resources/second-dialog.txt b/src/main/resources/second-dialog.txt deleted file mode 100644 index 7fd57fc..0000000 --- a/src/main/resources/second-dialog.txt +++ /dev/null @@ -1,5 +0,0 @@ -Roses are read -violets are blue -unexpected "{" -on line 32 - \ No newline at end of file