|
|
| AGUI Popup |
|
RickyLee
Member #11,573
December 2009
|
I notice Popup seemed to be in the new version but the old version (and the example) doesn't have it. I assume this Popup is just like a message box that would allow me to let people confirm things with a Yes, No, &|| Cancel? Does anyone have an example of using AGui Popup for such a purpose? Or the more I think of it is this more like a Context Menu? If a Context Menu, then a MessageBox Widget would be a nice addition. I guess I could make it myself with a Frame, Label, and some buttons but would be nice if it came with AGui like it does with other libraries as it's a pretty common task even in games. I need this to confirm land purchases in my game after the player selects the land to buy. Thanks! |
|
jmasterx
Member #11,410
October 2009
|
The PopUp us a context menu (and also a menustrip menu). It gets its name from Java's JPopUp. Agui does not have a message box for several reasons and I will not be adding one. I do not feel 1 'look' or style would fit everyone's needs. It's a bit subjective to me. Most messageboxes block the calling thread until a response from the user which allows the nice: You could probably quickly roll one out for your game and needs with images and buttons to your liking. I did this for my game. Or there is always the native dialogs addon. Agui GUI API -> https://github.com/jmasterx/Agui |
|
RickyLee
Member #11,573
December 2009
|
OK, I'll roll my own that uses your GUI so that the look and feel between things stays the same. Though I don't really understand the look and feel argument you have. You could say the same for the entire GUI then. I'd think one would want the look and feel of a message box to be the same as the look and feel of the GUI they are using. The blocking aspect of most message boxes is something I was thinking about too, but I think I'll just attach the event to the game state and will just expose the button types of the message box (yes, no, cancel, ok) so I can check against those. Not a huge deal not having it, would have just made things slightly easier for me so thought I'd bring it up. Thanks! |
|
jmasterx
Member #11,410
October 2009
|
What I mean is that, MessageBoxes usually need icons, which agui will not provide. Sometimes you can float your buttons right, or left. You may want a title bar, you may not. You may want an X button, you may not. In addition, you would have to provide all the OK, Cancel, Yes, No, Abort, Retry, Fail, texts because I cannot assume everyone's game is English. And this is only for Gui Applications. Often game message boxes might have checkboxes and other assortments. For the PopUp, I felt I could make it generic enough to be useful in a variety of situations. But I did not feel this for the messagebox. Agui is designed for you to subclass all of its Widgets and make your own sort of GuiFactory to your games' needs. This is why every Widget has only 1 constructor that takes in pointers to its children. This is so that, if you make a custom button, then you can use that to make a custom scroll bar. Then your custom ListBox can use your custom scrollbar. This means that any of Agui's parameters can be fine tuned at 3 levels: Ex: Scroll rate. This gives the user a lot of control and flexibility which I like. Agui GUI API -> https://github.com/jmasterx/Agui |
|
RickyLee
Member #11,573
December 2009
|
I get what you are saying, I just don't agree with it. Not that it really matters or is a huge deal as I'll just make my own, but I believe a large % of message boxes are pretty much the same, even in games, and if someone needs a highly customized one, then they can make one, but I believe that would be the exception and not the rule. It'll just set me back an hour or so with something that I thought to be pretty common in all GUI libraries. |
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
Well, I don't have a message box in my gui either. :/ I mean, you could make one real quick with just a few widgets and then put it in a function and run it. I mean, the library can't be expected to do everything. And there are already other options available, like the native dialogs addon, so use that. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|
Trent Gamblin
Member #261
April 2000
|
My GUI doesn't have message boxes but it has modal "dialogs". Which can be anything a regular set of widgets can, it just disables the background, darkens it and presents a new GUI on top.
|
|
RickyLee
Member #11,573
December 2009
|
Sounds like Agui could provide more functionality than the other allegro gui's then if added .Net, Java, QT, WxWidgets, etc all have a message box. I'd say its pretty standard even in games. In fact I'm going through a wiki of GUIs and googling them and message boxes and they all seem to have them. Just saying |
|
jmasterx
Member #11,410
October 2009
|
I know that, but these produce gui applications that often use the underlying OS to produce the messagebox. Anything like GTK, wx, QT, Java, will obviously need a messagebox. In most cases the native messagebox is invoked so the OS is handling it and doing thread blocking and such. Agui does provide modal blocking like Trent mentioned. I suppose I could whip one up eventually, but I would really need to make sure I cover all grounds. As you may have noticed, Agui is very feature rich and I want to make sure all Widgets offer this. I'll certainly consider it though. I'm returning back to school tomorrow for my last semester and I'll be pretty busy, but if I find time and I have an elegant and flexible way to do the callback then I will do it. The messagebox I made for my game is actually a pimped out frame. Inside I can put a content Widget. I needed that for a Next, Next, Finish style dialog. If anyone knows of a nice way to do blocking-like messageboxes without blocking I'd love something like that. That was a big reason for not including one. Agui GUI API -> https://github.com/jmasterx/Agui |
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
I could do this easily enough in my gui I suppose. Create a new graphics context (window), give it a gui and a few buttons and wait for a close signal. Truly modal is harder though, because then you have to use a native dialog. So again, why not just use the native dialog addon? My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|
pkrcel
Member #14,001
February 2012
|
Well, the native dialog addon is not "transparently" cross-platform, you can't do on Windows what you can do on Linux for example (IIRC there is some recent discussion about this, namely about customizing buttons...). BUT I agree thou that if you need "true" modal dialog, the native one should suffice for the average needs of a game. It is unlikely that Google shares your distaste for capitalism. - Derezo |
|
RickyLee
Member #11,573
December 2009
|
I don't understand the worry about this being modal. I can simulate modal if I want by setting a flag to skip running my entire logic or just other GUI logic when I pop this modal box up, but I think a good number of games don't have 100% true modal anyway. I think of games like WoW that have a message box come up when a battleground is ready. Accept/Decline, oh and you can keep doing other things I'm just a message that allows you to click buttons to do a certain action. No need for me to block anything. I just don't know that many decent games that use the native OS's message box in the game itself. That's a little cheesy if you ask me. |
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
If you ask me, you're being lazy. Like I said, it would take about an hour to write one of these, but I can't foretell how you would like it to be customized myself, you have to do that, so it makes more sense for you to write your own message box to begin with. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|
RickyLee
Member #11,573
December 2009
|
1. I've already created my own with Agui. I'm simply trying to give feedback to help give the library more functionality and be more on par with professional GUI libraries. 2. Of course I am lazy. Everyone using Allego is lazy. Everyone using .Net is lazy. Being lazy is why libraries exist. We don't want to have to rewrite things that have consistency to them, and my argument is other professional guis have basically standardized the basic message box. if I want a non standard message box in .Net its up to me to make my own but 99% of the time the flexible standard message box works and save me time because I am lazy. jmasterx said: If anyone knows of a nice way to do blocking-like messageboxes without blocking I'd love something like that. That was a big reason for not including one. "Nice way" can be somewhat objective but here is basically what I did with mine. 1namespace AGuiMessageBoxButtons
2{
3 enum MessageBoxButtons
4 {
5 OK = 0,
6 OKCancel,
7 YesNoCancel,
8 YesNo,
9 None // this can be used just for message updates for network processes
10 };
11}
12
13namespace AGuiMessageBoxResult
14{
15 enum MessageBoxResult
16 {
17 OK = 0,
18 Cancel,
19 Yes,
20 No,
21 None
22 };
23}
24
25AGuiMessageBoxResult::MessageBoxResult AGuiMessageBox::Show(string msg, string title, AGuiMessageBoxButtons::MessageBoxButtons buttons)
26{
27...
28}
I create a member variable of AGuiMessageBoxResult::MessageBoxResult which holds the result and that's what I return from Show(). The MessageBox class holds the frame, buttons, and label widgets. They are predefined Yes, No, Cancel, OK. In the show you set the msg and title and what combinations of the buttons you want. The order is always the same. It's not that big of a deal. The MessageBox class is derived from ActionListener and 'this' passed to the controls inside it. It overrides the actionPerformed method to check which button was clicked and sets the MessageBoxResult class variable accordingly, which Show returns. By default it's set to None. The "trick" is that Show() is to be called every frame since with this you can't have a true blocking messagebox. In my game code I handle this with flags. For example in my Login game state when the player clicks exit I pop up an "Are you sure" msgbox. In the Login state class when Exit is clicked I set a flag, that my Update method in Login state class will do the showing of this to check the return value to see what was pressed. I then simply disable/enable all other controls. On my login screen I do this manually, but I'm assuming if I made a panel or something I could enable/disable the entire panel to do this for the controls I want to enable/disable. For online games you don't want to block the game logic from running (which I assume the native msg box would do). You simply just want to block other GUI widget messages, but allow the game to still run. This gives me that. |
|
jmasterx
Member #11,410
October 2009
|
What I do is, show takes in an ActionListener, or one can be explicitly set. When a button is clicked, the action widget's actionPerformed reads the ActionEvent.getId() which is OK,CANCEL... etc This works for me. Agui GUI API -> https://github.com/jmasterx/Agui |
|
|