A box in the middle of the screen with some text and some buttons. Blocking.

I suggest we start with the non-interactive message box. Also, unless you remember exactly how these message boxes worked in MW, I suggest you go back into the game and have a look at them again.

Here is what I remember:
- There can be up to 3 message boxes displayed at the same time. If there are more the oldest is removed.
- The message boxes are removed after some time. The duration seems to be related to the amount of text.

You should implement the message box feature inside the apps/openmw/mwgui directory. Have a look at the WindowManager::messageBox function. You get a non-interactive message box, when the buttons vector is empty.

A few more hints regarding the implementation:
- In some parts of apps/openmw/mwgui the indention and the source formatting is a bit odd. If in doubt, follow the guidelines in our wiki.
- The WindowManager class in its current state is suboptimal (it is scheduled for a refactoring). It should do little more than bringing together the individual parts of the GUI.
- I suggest you create a new class (MessageBoxManager or something) and add an instance of it to WindowManager. The WindowManager can then forward calls to this instance.
- To test your message box implementation, open the console (F1) and enter MessageBox "someText"

swick wrote:
So, if you call WindowManager::messageBox it should forward to MessageBoxManager::New or something like that and this should create a new instance of MessageBox which is interactive/non-interactive, right? So, I create the files message_box_manager.cpp/hpp?

Just seen the non-interactive box but I could not produce more then one message box at the same time.

Zini wrote:

Just seen the non-interactive box but I could not produce more then one message box at the same time.

Probably requires writing a script. Not sure, if you can do it from the console. I don't remember if the new boxes come up at the bottom or the top. We need to find out which variant MW is using.

So, if you call WindowManager::messageBox it should forward to MessageBoxManager::New or something like that and this should create a new instance of MessageBox which is interactive/non-interactive, right? So, I create the files message_box_manager.cpp/hpp?

Mostly correct. Might be a good idea to have a separate function for interactive and non-interactive message boxes each in MessageBoxManager, since these are complete different GUI features.
Also, the file name is not correct. We have in the project wiki several pages about naming conventions. You should reed these (and yes, I know that the current codebase is not always following these guidelines; they were written retroactively to match what the majority of the codebase is using).

Zini wrote:
I saw your first commit on github. Two comments:

- To add new files, you also need to add them to the cmake scripts (in this case apps/openmw/CMakeLists.txt).

- Never write "using namespace" in a header. Never! This is one of the rare cases, where a rule about coding mentioning the word "never" really does mean never; with no exceptions.
That is not OpenMW specific, but a general advice for C++ coding. About as fundamental and important as "don't use goto".

swick wrote:
okay, next try. Now I got stuck with creating the box. Somehow I dont understand why it throws the exception. All other layout-files do the same thing.

root widget name '_Main' in layout 'openmw_messagebox_layout.xml' not found.

Zini wrote:
Because you forgot to add the file to the cmake script? You can't just create new files (source or others) and expect that it works.

swick wrote:
Shame on me.

Zini wrote:
Not really. Using cmake can be confusing at first, when you are not used to a script based build system.

swick wrote:
Seems like I don't understand when a widget is shown and when not. The position and the size should fit now but I can't see it :/

Zini wrote:
I don't know much about MyGUI or how it is integrated into OpenMW via OpenEngine. But from a quick look it seems you need to call a function named setVisible to make a window visible.

Star-Demon wrote:
poll keys
on button hit - toggle isvisible

except the messageBox we're familiar with are usually on the screen for an amount of time, except the ones with an OK button.

swick wrote:
Here is what i got for the non-interactive messageBox:

at most 3 MessageBoxes

longer text, longer visible (default is 0.1sec/char)

fixed width, variable height

text is centered,

newest box appears at the bottom, olders get pushed upwards

when an interactive MessageBox spawns, all non-interactive's disappear

Now, they are visible but not formatted correctly.

Star-Demon wrote:

swick wrote:Here is what i got for the non-interactive messageBox:

at most 3 MessageBoxes

longer text, longer visible (default is 0.1sec/char)

fixed width, variable height

text is centered,

newest box appears at the bottom, olders get pushed upwards

when an interactive MessageBox spawns, all non-interactive's disappear

Now, they are visible but not formatted correctly.

All cool - except I'd note that when the interactive one appears, the game pauses. I'm not sure what our mechanism for doing that is.

swick wrote:
Is there some function to break the text if it gets to long or must I do it myself? I didn't find anything useful in the docs.

Zini wrote:
Don't know MyGUI well enough to answer that question. But you could have a look at the NPC dialogue implementation. I think it already has some kind of text formatting.

swick wrote:
Made progress, now I only have to find a way to start a timer. I've seen the timer class in Ogre but the MessageBoxManager is not called so often, so I need a way to register a timer and then get notified. Any thoughts?

Zini wrote:
That is not the way to do it. You go through the framelistener in the engine class. From this framelistener you call a function in the window manager once per frame, passing the duration of the frame as an argument.

Zini wrote:
The duration of the message boxes looks wrong. Short text disappears way too fast. Maybe you could do a few test runs with MW and measure the time for different text lengths? The original MW implementation is anything but optimal, but at least it gives you enough time to read the messages while still not clogging up the screen with old messages totally.

btw. you forgot to add the new header to the cmake script. For the build process it doesn't matter, but people using an IDE will complain if the header does not appear in their project file window.

swick wrote:
No. The duration is okay I especially looked it up in Morrowind. But when I've done that I noticed that the MessageBox'es behave not like I thought. The new Code is in my repository. Should I sent a pull request?

Zini wrote:

No. The duration is okay I especially looked it up in Morrowind

Strange. From what I remember message boxes with very short messages (only 2-3 characters) stayed up a bit longer in the original game. But okay, maybe my memory is playing tricks on me.

Another pull request is not required.

Zini wrote:
Merged into next.

I noticed a problem with very long text without spaces. The whole message box content seems to be shifted to the right.

swick wrote:
Okay, I see. There is not much I can do to fix it, maybe force the text to break? The problem would be that I have to disregard the grammar rules.

Zini wrote:
Its not something we must fix now, if it makes to many problems. I think we can get away with not handling these kind of edge-cases for now. Later (post 1.0) we will have to think about how to improve the message box system anyway.

Zini wrote:
Okay! Step two: The interactive message box. Some text with one or more buttons.

The GUI manager already implements some kind of GUI-mode system. The message box is probably best implemented as a separate mode.

Add a function readPressedButton to the window manager (I will hook it up to the script system later). This function should return the index of the pressed button (first button is #0) and then set the index to -1 (which is also the default value). If no button has been pressed since the last call to readPressedButton, the function should also return -1,

Zini wrote:
Hint: Storing the interactive message boxes in a vector is not the correct method. There can be only one.

swick wrote:
@Zini: thx.

So, here is what i got for the interactive MessageBox:

there is a maximum witdth, the height is variable

the buttons will be shown on one line if possible

if not possible, they are shown among each other

if a button is bigger then the text, the window will be that big (the maximum is the same)

Zini wrote:
Sounds reasonable.

Zini wrote:
Any progress on this? It's been a while since we heard from you.

swick wrote:
Sorry, no. I'm a bit in a hurry because every teacher thinks he has to write one more class test before the holidays begin. After the next week I'll have much time for working on it...

Zini wrote:
Merged into next. Works great!

@swick: You are currently our most experienced MyGUI developer. Would you mind having a quick look at ObsidianBlk's book branch? He seems to have some rather obscure layout problem.
After that, do you want another tasks? Currently there are only two GUI tasks on the roadmap:

The second one was assigned to Peppe (jpn on github). But he hasn't worked on it for months and from what I hear from him, his free time is still very limited. Since we need this feature soon, I wouldn't mind giving the task to you, if you want it.
But you can also have a task that is not GUI related, if that is preferable to you.