GUI Dialouges

Hello!

You may’ve seen my WIP (If not, http://javadaemon.com/pictures/pokemon_engine.png).
I’m at a point where I’d really much like chatting with NPC’s. This is hard though, because both NPC’s needs to be able to chat, aswell as signs, and other objects that has text written on them in-game.
I’m planning on not making the player talk at all.

Here’s how I want the dialouges to be: When the player interracts with something a box comes up with text it in. The box can upon input be refreshed to that the player can view the next line of text. I also want actions available like different directions of the dialouge depending on simple input like yes/no, and items given to the player upon reaching a point in a dialouge (a line).

I’m using a design pattern where data objects are not responsable for drawing themselves, instead I have a different object (screen) that draws all the things to the screen. My problem is, how do I attack this?
I’m sure I want some kind of dialouge object that both NPCs and Tiles can posses, and I might want a different object, in the screen, that draws the currenty active dialouge.

Thing is I have never done anything like that before, and I’m very unsure how I craft the system, because I obviously need to be able to modify the player from the dialouges, and I also need to be able to get input from the player (the screen has access to both the player, and the input).

I would have a DialogBox class. In the class, have an Array of Strings, where each element is another sentence or w/e, and a nextLine() method to move the dialog forward. Each NPC would be their own class with all of them inheriting an abstract talk() method. Inside talk(), call the dialog box’s nextLine() method. You can program certain NPCs to give an item at a certain point in the conversation by tinkering with their specific talk method.

Just off the top of my head, so it might not be perfect.

It so happens that i am trying to design a more general user interface api for my game that the input will be this of pokemon like games. A and B buttons and arrow buttons from a keyboard. My idea is to use a class to model all kind of ui elements i.e Component that will be able to update its state based on input and redraw it self. And a second class called Manager that would hold a list of all the “alive” Components and its task will be to collect the input, send it to all the elements so that they can update their state and finally call their draw methods. Based on this model i plan to design all the ui elements i will need.

If you are interested in the idea why not work together? Let me know :wink:

Depends if you want it to show up as in a regular RPG in the bottom (then I’d use a general borderlayout and then just show a jpanel at south when needed which populated from model), though if you want it to pop up next to the tile/player which fire said dialogue I’d use JPopupMenu which pops up when fired. Can easily be modified the way you wish it to be and should be populated from the model.

If you consider either of those suggestions sounds interesting you can just post a reply and I’ll see if I can post a quick mock-up code of it.