GUI Interface

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • GUI Interface

      Hi guys,

      Okay, let see if I can make this clear. I am designing and developing a GUI interface for users. With paper and pen in hand I came up with the following code based on what OpenGL does (structural). (pseudocode below)

      Source Code

      1. GUIBegin( GUI_CONSOLE, id );
      2. GUIRect4i( 25, 25, 100, 50 );
      3. GUISetBKColor4f( 0.5, 0.5, 0.5, 1.0);
      4. GUISetBorderColor4f( 1.0, 1.0, 0.5, 1.0);
      5. GUISetTitleString( GUI_TEXT, "Settings..." );
      6. GUISetWindowState( GUI_ACTIVE, FALSE );
      7. GUIDoHandleEvent(id, GUI_ACTIVE);
      8. result = GUIEnd();

      The resulting code above would produce a box with specific dimensions, color, title, button state, etc. This could be a MesageBox, Console, whatever.

      USAGE:
      GUI_CONSOLE = unique enum identifier that defines a console. GUIBegin( {GUI_CONSOLE} {GUI_MSGBOX} {GUI_LOADER}, .. ); (BNF format)
      id = UINT, WPARAM, LPARAM, other?
      GUI_ACTIVE = status of a botton (click, release) GUI_ACTIVE | GUI_HIDE
      result = return value defining the result of a key stroke or mouse click.

      The reason as to why build it this way is simplicity and ease (or not). Second, since I am looking for more abstraction to design this might provide a means to do just that. With this type of abstration it should eleaviate a 'coupling' problem (as far as I understand the term). Or perhapse a better way to say it is, to reduce the interdependency.

      Any thoughts as to how to implement the "GUIBegin(..)" and "GUIEnd()" scoping problem? Any other comments, thoughts, ideas.


      Sabrina.
    • There's a good starting GUI system in Game Development with Lua that is completely scriptable, and that uses Lua scripts for GUI event handlers.

      The authors use DirectX, but the basic implementation should be the same any way you slice it. Additionally, you could make base classes and inherit for a DXGUI family of objects and an OGLGUI family of objects - if you maintain a consistent interface you should be able to interchange them seamlessly and allow the end user to choose which is preferable.

      Er, sorry - just realized that I'm beginning to sound like some sort of Lua Evangelist.... You could build a "scriptable" system with whatever system you wanted though. You mentioned configuration files - you could use them to provide layout and have the classes themselves handle events however you see fit internally. And the Game Programming Gems have a few different approaches to designing widget systems for UI development - if you have them I'm pretty sure 1~3 have useful info on this and the others might as well.

      And, as for the in-game "console" you could look in The Zen of Direct3D Game Programming. He covers building a roll-out quake-style console in there, and it's pretty cool.
      Rich
      "Your job is not to die for your country. Your job is to make some other poor sod die for his."

      The post was edited 1 time, last by Nebuchadnezzar ().

    • I would definately agree with Nebuchadnezzar on this one. A scriptable, extendable, and adaptable UI system is where it's at. I can't say I've read Game Development with Lua, but it's not a bad idea to allow your scripting language to hook into your UI system.

      I would say that a UI system would lend itself to more on an OO paradigm than the OGL procedural design, although this is, once again, a matter of style, really. I would say that a good OO-oriented UI system would be more flexible in the long run.
      Feel you safe and secure in the protection of your pants . . . but one day, one day there shall be a No Pants Day and that shall be the harbinger of your undoing . . .