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

Author Topic: Menus and dialog boxes  (Read 16002 times)

0 Members and 1 Guest are viewing this topic.

tester

  • Newbie
  • *
  • Posts: 17
    • View Profile
Menus and dialog boxes
« on: April 28, 2010, 09:57:07 am »
Is there any way to add a menu to an SFML window? And is it possible to show dialog boxes with control elements on them? If no, is it possible to get the platform dependent data for the window (in Windows: HWND)?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32453
    • View Profile
    • SFML's website
    • Email
Menus and dialog boxes
« Reply #1 on: April 28, 2010, 12:54:38 pm »
No, no and no. Sorry :wink:
Laurent Gomila - SFML developer

tester

  • Newbie
  • *
  • Posts: 17
    • View Profile
Menus and dialog boxes
« Reply #2 on: April 28, 2010, 02:39:10 pm »
Why not? How shall I create my menus now?

Mindiell

  • Hero Member
  • *****
  • Posts: 1262
    • ICQ Messenger - 41484135
    • View Profile
Menus and dialog boxes
« Reply #3 on: April 28, 2010, 03:50:16 pm »
Have a look to GUIs ;)
Mindiell
----

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6226
  • Thor Developer
    • View Profile
    • Bromeon
Menus and dialog boxes
« Reply #4 on: April 28, 2010, 04:17:54 pm »
Quote from: "tester"
Why not?
Because developping a GUI library involves a huge effort. Currently, there are more important, multimedia-related basic features to implement in SFML 2.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: first SFML book

tester

  • Newbie
  • *
  • Posts: 17
    • View Profile
Menus and dialog boxes
« Reply #5 on: April 28, 2010, 11:50:36 pm »
Quote from: "Nexus"
Because developping a GUI library involves a huge effort. Currently, there are more important, multimedia-related basic features to implement in SFML 2.

Well, I can of course understand why SFML doen't support it directly. But there should be at least a function to get the platform-dependent data of a window. Something like:
Code: [Select]
class Window
{
#ifdef WIN32
    HWND GetHwnd();
#elif defined UNIX
    UnixSomething1 GetThisStuff();
    UnixSomething2 GetThatStuff();
#elif ...
    ...
#endif
};
In this case, even if certain functions are not supported, the programmer can still use them by working with the native frameworks of their operation system.

panithadrum

  • Sr. Member
  • ****
  • Posts: 305
    • View Profile
    • Skyrpex@Github
    • Email
Menus and dialog boxes
« Reply #6 on: April 29, 2010, 09:26:39 am »
Quote from: "tester"
Quote from: "Nexus"
Because developping a GUI library involves a huge effort. Currently, there are more important, multimedia-related basic features to implement in SFML 2.

Well, I can of course understand why SFML doen't support it directly. But there should be at least a function to get the platform-dependent data of a window. Something like:
Code: [Select]
class Window
{
#ifdef WIN32
    HWND GetHwnd();
#elif defined UNIX
    UnixSomething1 GetThisStuff();
    UnixSomething2 GetThatStuff();
#elif ...
    ...
#endif
};
In this case, even if certain functions are not supported, the programmer can still use them by working with the native frameworks of their operation system.

I agree, but this also makes the API a bit more complicated. Let's read Laurent reply.

Mindiell

  • Hero Member
  • *****
  • Posts: 1262
    • ICQ Messenger - 41484135
    • View Profile
Menus and dialog boxes
« Reply #7 on: April 29, 2010, 01:40:49 pm »
The problem is that your app is no loosing compatibility... Why use SFML therefore ?

What do you want to do exactly ?
Can't you use an existent GUI ?
EDIT : What about Qt or wxWidget ?
Mindiell
----

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32453
    • View Profile
    • SFML's website
    • Email
Menus and dialog boxes
« Reply #8 on: April 29, 2010, 02:55:22 pm »
Quote
I agree, but this also makes the API a bit more complicated. Let's read Laurent reply.

It's a very simple function to write. It doesn't exist for design reasons, not technical ones.

Quote
The problem is that your app is no loosing compatibility... Why use SFML therefore ?

Not everybody wants to write cross-platform programs ;)
Laurent Gomila - SFML developer

Mindiell

  • Hero Member
  • *****
  • Posts: 1262
    • ICQ Messenger - 41484135
    • View Profile
Menus and dialog boxes
« Reply #9 on: April 29, 2010, 03:10:48 pm »
Quote from: "Laurent"
Not everybody wants to write cross-platform programs ;)
Gasp !  :shock:
Mindiell
----

tester

  • Newbie
  • *
  • Posts: 17
    • View Profile
Menus and dialog boxes
« Reply #10 on: April 29, 2010, 08:27:11 pm »
Quote from: "Mindiell"
The problem is that your app is no loosing compatibility... Why use SFML therefore ?

What do you want to do exactly ?
Can't you use an existent GUI ?
EDIT : What about Qt or wxWidget ?

Well, I do want to write a game, yes. A GUI is not the primary goal, so Qt or wxWidgets are not necessary. It's just that Windows users don't want to enter command line parameters to configure the game options. That's why I would add a native menu and some modal dialog boxes to the Windows version. The game would still be platform independent since I'd enclose every Windows-specific stuff with #ifdef WIN32. And it would still behave identical on every operation system, only that the Windows users have a menu above the window and Linux users don't and need to use command line parameters to change options.
That's similar to the NES emulator FCE Ultra: Compile it as a native Windows and DirectX version and you get a typical Windows interface with a menu and dialog boxes. Compile it as the SDL version and, in Windows and Linux alike, you only have that crappy standard window and you have to enter the options at the command line. Everything from the same source package and with the same configure script.

But it's o.k. I found out a way to do the menu anyway: I'll just use EnumWindows, GetWindowThreadProcessId and GetCurrentProcessId. That will give me the application window as a HWND.

Mindiell

  • Hero Member
  • *****
  • Posts: 1262
    • ICQ Messenger - 41484135
    • View Profile
Menus and dialog boxes
« Reply #11 on: April 30, 2010, 07:31:27 am »
And what about a menu inside the SFML window ?
With one of the multipe existing GUIs projects ?

With this solution, the menu will be inside the window, but all the app will be the same on each platform and need only one project and no specific platform things...
Mindiell
----

tester

  • Newbie
  • *
  • Posts: 17
    • View Profile
Menus and dialog boxes
« Reply #12 on: April 30, 2010, 08:58:31 am »
In this case you wouldn't have the correct look-and-feel. If I intended to use a GUI inside the game area, I would program my own stuff anyway. After all, it won't be much: Keyboard input, screen resolution etc.

Mindiell

  • Hero Member
  • *****
  • Posts: 1262
    • ICQ Messenger - 41484135
    • View Profile
Menus and dialog boxes
« Reply #13 on: April 30, 2010, 09:00:48 am »
As you wish, and good luck ;)
Mindiell
----

tester

  • Newbie
  • *
  • Posts: 17
    • View Profile
Menus and dialog boxes
« Reply #14 on: April 30, 2010, 12:29:19 pm »
O.k., I did the menu now, but then I remembered that I somehow have to catch the events. That's why here's my next question: Does SFML provide anything like that?
Code: [Select]
SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);

switch (event.type)
{
case SDL_SYSWMEVENT:
switch (event.syswm.msg->msg)
{
case WM_COMMAND:
if (LOWORD(event.syswm.msg->wParam) == ID_MENU_ITEM)
{
// ...
}
break;
}
break;
}

 

anything