Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Message Boxes  (Read 37778 times)

0 Members and 2 Guests are viewing this topic.

efeXor

  • Newbie
  • *
  • Posts: 10
    • MSN Messenger - Steam:BrokenGlassX
    • View Profile
Message Boxes
« on: December 01, 2008, 07:05:30 pm »
Not sure if SFML already has it, i'm still kind of new to it, but it would be nice to be able to display message boxes that pop up in your SFML window like say if you have an error or something. (Yes i know you can do it using the winapi but it requires alot of stuff being setup).

coral

  • Newbie
  • *
  • Posts: 37
    • View Profile
Message Boxes
« Reply #1 on: December 01, 2008, 09:09:39 pm »
This would be quite hard to implement practical and universal.

SFML is used in a lot of different enviroments with a lot of different window handlers. Think of it, there is no "global" way of making a box on them all. Each system has to have a hand written implemention, not to mention the intergration with QT and such.

And then also, this would distract the focus from a simple and fast multimedia layer and turn into something bloated. There is no universal way for each project. I know people using it for games, visualising studies and such.

Get developing with Win32 or QT is my advice.

zarka

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
Re: Message Boxes
« Reply #2 on: December 02, 2008, 06:21:07 pm »
Quote from: "efeXor"
(Yes i know you can do it using the winapi but it requires alot of stuff being setup).


win32 api message box is not that hard to do :)
Code: [Select]

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
int main(void)
{
    MessageBoxA(NULL, "text", "Title!!", MB_OKCANCEL | MB_ICONEXCLAMATION)
    return 0;
}
//Zzzarka

efeXor

  • Newbie
  • *
  • Posts: 10
    • MSN Messenger - Steam:BrokenGlassX
    • View Profile
Message Boxes
« Reply #3 on: December 04, 2008, 06:44:01 am »
No. It will not show in your application :(

Wizzard

  • Full Member
  • ***
  • Posts: 213
    • View Profile
Message Boxes
« Reply #4 on: December 04, 2008, 09:04:52 am »
If you're trying to display a message in your SFML canvas, simply draw a rectangle Shape and then draw a String containing a message inside of the rectangle.

Xardas2

  • Newbie
  • *
  • Posts: 5
    • View Profile
Message Boxes
« Reply #5 on: July 11, 2009, 03:05:28 pm »
You can also write a thread class. It isn't as difficult as it sounds ;)
Here's a part of mine. (I'm also a beginner and so don't know if this is a good solution. But so, you don't need to use the WAPI)
Code: [Select]

#include <SFML/Graphics.hpp>
#include <string>

class EMessage : public sf::Thread
{
        public:
            //variables
            std::string EMessage;

        protected:
            //methods
            virtual void Run()
            {
                bool running = true;
                sf::RenderWindow ErrWindow(sf::VideoMode(600, 130, 32), "ERROR!", sf::Style::Close);
                sf::String ErrMessage;
               
                ErrMessage.SetText(EMessage);

                while(running)
                {
                    while(ErrWindow.GetEvent(Event))
                    { /* Button Click, ...*/ }

                    ErrWindow.Draw(ErrMessage);
                    ErrWindow.Display();
                }
            }

},

l0calh05t

  • Full Member
  • ***
  • Posts: 200
    • View Profile
Message Boxes
« Reply #6 on: July 21, 2009, 02:14:31 pm »
Actually, a cross-platform message box (for the really bad/unrecoverable errors) would be nice to have.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Message Boxes
« Reply #7 on: July 21, 2009, 02:17:57 pm »
What about std::cerr?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Message Boxes
« Reply #8 on: July 22, 2009, 01:12:24 am »
Besides, a message box can rather easily be implemented about a separate window (and perhaps threads).

I don't see any need to change SFML in this point.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

l0calh05t

  • Full Member
  • ***
  • Posts: 200
    • View Profile
Message Boxes
« Reply #9 on: July 24, 2009, 12:37:07 pm »
Quote from: "Tank"
What about std::cerr?


Only works if you have one of those ugly console windows ;-)

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Message Boxes
« Reply #10 on: July 24, 2009, 01:25:19 pm »
Quote from: "l0calh05t"
Quote from: "Tank"
What about std::cerr?

Only works if you have one of those ugly console windows ;-)

Which you mostly have for debugging, I guess.

SamuraiCrow

  • Newbie
  • *
  • Posts: 40
    • Yahoo Instant Messenger - samuraileumas
    • View Profile
Message Boxes
« Reply #11 on: July 24, 2009, 06:05:05 pm »
Quote from: "Tank"
Quote from: "l0calh05t"
Quote from: "Tank"
What about std::cerr?

Only works if you have one of those ugly console windows ;-)

Which you mostly have for debugging, I guess.


Console windows are fine for debugging.  They are not fine for informing the end-user about an error.

@thread

IMO, this should be considered a GUI function.  GUIs can be implemented in SFML and themed according to the game/multimedia project you are designing.

If you are designing an SFML and want a standard windowing environment, look up how to use an appropriate windowing setup in the tutorials section of the Wiki.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Message Boxes
« Reply #12 on: July 24, 2009, 07:07:42 pm »
Quote from: "SamuraiCrow"
Quote from: "Tank"
Quote from: "l0calh05t"
Quote from: "Tank"
What about std::cerr?

Only works if you have one of those ugly console windows ;-)

Which you mostly have for debugging, I guess.


Console windows are fine for debugging.  They are not fine for informing the end-user about an error.

std::cerr is not the console. It's a standard stream that can be redirected to whatever you like; the console is just the default output.
Laurent Gomila - SFML developer

l0calh05t

  • Full Member
  • ***
  • Posts: 200
    • View Profile
Message Boxes
« Reply #13 on: July 24, 2009, 08:32:31 pm »
Quote from: "SamuraiCrow"

Console windows are fine for debugging.  They are not fine for informing the end-user about an error.


Exactly.

Quote
@thread

IMO, this should be considered a GUI function.  GUIs can be implemented in SFML and themed according to the game/multimedia project you are designing.

If you are designing an SFML and want a standard windowing environment, look up how to use an appropriate windowing setup in the tutorials section of the Wiki.


I'm talking about a platform independent error message box. Its a bad idea to do this in the GUI (as it might be a part of the GUI that caused the error). Bad errors happen. Even after tons of debugging and testing.

Quote from: "Laurent"

std::cerr is not the console. It's a standard stream that can be redirected to whatever you like; the console is just the default output.


I know, but of what use would that be in this case? So I might be able to log the error. But should the app simply close on a fatal error, without even pointing out to the user what happened? It should display a message box or something similar... and these aren't compatible with streams.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Message Boxes
« Reply #14 on: July 24, 2009, 09:19:55 pm »
Quote
It should display a message box or something similar... and these aren't compatible with streams.

Why not? You can redirect the stream to whatever you want, even message boxes.
The good thing with standard streams is that they don't care about where they write, they just send their content to their streambuf, which can be specialized to write to anything that support text output.
Laurent Gomila - SFML developer

 

anything