About Store Forum Documentation Contact



Post Reply 
Gui problem
Author Message
FireMan Offline
Member

Post: #1
Gui problem
Hi.
What i doing wrong ?
Code:
/******************************************************************************/
#include "stdafx.h"
/******************************************************************************/
GuiObjs   gui_objs;
Button   *save,
*exit,
*load;
/******************************************************************************/
void InitPre()
{
   App.name("Loading Gui Objects");
   App.flag=APP_FULL_TOGGLE;
   IOPath("../data");
   Paks.add("engine.pak");
   D.mode(800,600).sync(true);
}
/******************************************************************************/
void ButtonFunction(Ptr)
{
   if(exit)exit=return false;             // <------- ERROR
}
/******************************************************************************/
Bool Init()
{
   Gui.kb_lit=0;

   if(gui_objs.load("gui/menu/menu.gobj"))
   {
      Gui+=gui_objs;

      save=gui_objs.getButton  ("save");
      load=gui_objs.getButton  ("load");
      exit=gui_objs.getButton  ("exit");
      save->func=ButtonFunction;
      load->func=ButtonFunction;
      exit->func=ButtonFunction;

      return true;
   }
   return false;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
Bool Update()
{
   if(Kb.bp(KB_ESC))return false;
   Gui.update();
   return true;
}
/******************************************************************************/
void Draw()
{
   D  .clear();
   Gui.draw ();

}
/******************************************************************************/

ERROR:
Code:
error C2059: syntax error : 'return'

Forum reklamowe: http://ad-forum.pl
(This post was last modified: 12-13-2009 07:21 PM by FireMan.)
12-13-2009 07:20 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Harton Offline
Member

Post: #2
RE: Gui problem
Try: if(exit)exit=0;
But you lose your pointer to exit button!!!
(This post was last modified: 12-13-2009 08:54 PM by Harton.)
12-13-2009 08:51 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #3
RE: Gui problem
This code should exit application? Maybe try if(exit)return false; or Exit() function.
12-13-2009 11:01 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Harton Offline
Member

Post: #4
RE: Gui problem
ButtonFunction can not return anything!
(This post was last modified: 12-13-2009 11:49 PM by Harton.)
12-13-2009 11:47 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Brainache Offline
Member

Post: #5
RE: Gui problem
Not sure exactly what you are after with that button function... but... couple things wrong with it like others have pointed out:

A) its a void function - you cant return a value... ie: false.. only "return" to exit the function

B) exit is defined as a pointer to a button.. you are trying to assign a value of "return false" to it... that is just.. wrong smile

If you want to create a button that causes Esenthel to close... you could do this:
most tutorials have something like this in the Main ( recently renamed to Update) function:

if(Kb.bp(KB_ESC))return false;

That works becuase return false from the Update function causes the application to shutdown...

So.. you could do something like:

Create a global value called 'engineRunning'

Bool engineRunning;

in.. say the InitPre function.. set it to true ( defaults to true.. but.. I always like to make sure!)

engineRunning = true;

then... change "if(Kb.bp(KB_ESC))return false;" to :

if ( !engineRunning || Kb.bp(KB_ESC) ) return false;

then... in your ButtonFucntion...

engineRunning = false;


That'll make is so the either pressing escape or clicking your button will clsoe Esenthel... ( and still call the Shutdown functions and such for engine cleanup )

If you just terminate the application via Exit() or something else.. you will leave memory allocated in the engine.. which causes Bad Things ™
12-14-2009 04:20 PM
Find all posts by this user Quote this message in a reply
Post Reply