|
Panel and Button
#260490
04/11/09 13:21
04/11/09 13:21
|
Joined: Jan 2009
Posts: 38
Anonymous2009
OP
Newbie
|
OP
Newbie
Joined: Jan 2009
Posts: 38
|
I'm using Bloodshed Dev-C++ for C++ using A7 engine (version 7.06.1). Showing panels itself is no problem, but I don't know how to implement buttons into them. When I try to implement button into my panel, both bmap and button give me an error that they are undeclared. I tried all variations of buttons and different ways of putting them: button_toggle(_VAR(0), _VAR(0), resume0_bmp, resume0_bmp, resume1_bmp, resume1_bmp, NULL, NULL, NULL); and button_toggle = _VAR(0), _VAR(0), resume0_bmp, resume0_bmp, resume1_bmp, resume1_bmp, NULL, NULL, NULL; This is part of my codes (there are no functions inside my button, it is still in testing phase): BMAP* resume0_bmp = bmap_create("button_resumeOut.bmp");
BMAP* resume1_bmp = bmap_create("button_resumeOver.bmp");
PANEL* pause_pan;
void loadHUD()
{
pause_pan = pan_create("bmap = screen_pause.tga;", _VAR(2));
pause_pan->pos_x = _VAR(373);
pause_pan->pos_y = _VAR(197);
pause_pan->flags |= OVERLAY | TRANSLUCENT;
button_toggle(_VAR(0), _VAR(0), resume0_bmp, resume0_bmp, resume1_bmp, resume1_bmp, NULL, NULL, NULL);
}
void engine_init()
{
ev = engine_open(NULL);
SETV(video_mode, 8);
SETV(max_particles, 20000);
SETV(max_entities, 2000);
SETV(fps_max, 60);
SETV(ph_fps_max_lock, 60);
SETV(shadow_stencil, ON);
...
loadHUD();
...
} Creating it using this method doesn't give any error on compiling but crash while running. PANEL* pause_pan = pan_create("bmap = screen_pause.tga; pos_x = _VAR(373); pos_y = _VAR(197); button_toggle(_VAR(0), _VAR(0), resume0_bmp, resume0_bmp, resume1_bmp, resume1_bmp, NULL, NULL, NULL); flags |= OVERLAY | TRANSLUCENT | INVISIBLE;", _VAR(3)); Anyone know what is my problem? How can I solve it? EDIT: typo
Last edited by Anonymous2009; 04/11/09 13:41.
|
|
|
Re: Panel and Button
[Re: Cowabanga]
#260545
04/11/09 21:30
04/11/09 21:30
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Your BMAPs are declared incorrectly for globals.
You would use this syntax if you were declaring LOCAL bmaps (INSIDE a function), BMAP* resume0_bmp = bmap_create("button_resumeOut.bmp"); BMAP* resume1_bmp = bmap_create("button_resumeOver.bmp");
But you are defining GLOBAL bmaps (OUTSIDE a function), so you need to use BMAP* resume0_bmp = "button_resumeOut.bmp"; BMAP* resume1_bmp = "button_resumeOver.bmp";
Its weird I know, but thats how it goes....
[EDIT] Sorry, just remembered you are using C++, not lite-c. This comment may not be applicable...
Last edited by EvilSOB; 04/11/09 21:33. Reason: Possible oops?
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Panel and Button
[Re: Anonymous2009]
#260707
04/13/09 04:51
04/13/09 04:51
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
This is largely educated guessing but try this. WARNING - requires 7.71
BMAP *resume0_bmp, *resume1_bmp;
PANEL *pause_pan;
void loadHUD()
{
resume0_bmp = bmap_create("button_resumeOut.bmp");
resume1_bmp = bmap_create("button_resumeOver.bmp");
pause_pan = pan_create("bmap = screen_pause.tga;", _VAR(2));
pause_pan->pos_x = _VAR(373);
pause_pan->pos_y = _VAR(197);
pause_pan->flags |= OVERLAY | TRANSLUCENT;
pan_setbutton(pause_pan, _VAR(0), _VAR(2), _VAR(0), _VAR(0), resume0_bmp, resume0_bmp, resume1_bmp, resume1_bmp, NULL, NULL, NULL);
}
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Panel and Button
[Re: EvilSOB]
#260999
04/15/09 08:26
04/15/09 08:26
|
Joined: Jan 2009
Posts: 38
Anonymous2009
OP
Newbie
|
OP
Newbie
Joined: Jan 2009
Posts: 38
|
I didn't try upgrading my version because my friend managed to make it work, anyway, I can make the button show, but it is not responding to any of the mouse over/click...
PANEL* panel2 = pan_create("button_toggle(0, 0, red.bmp, green.bmp, blue.bmp, white.bmp, clickMe, leaveMe, overMe);", _VAR(999));
And the image of the button is always in green.bmp, which is the off state. The clickMe, leaveMe, overMe are just simple functions to do a cout message.
Do you see any mistake in that line?
|
|
|
Re: Panel and Button
[Re: Anonymous2009]
#261795
04/20/09 09:35
04/20/09 09:35
|
Joined: Jan 2009
Posts: 9 Russia
Olorin
Newbie
|
Newbie
Joined: Jan 2009
Posts: 9
Russia
|
Hi. I had same problem. Try this code:
char *sStart_pan; // this is a pointer to char array with code of panel ev = engine_open(NULL);
if (!ev) return 1; // acknex.dll not found
//folder with button images add_folder("%EXE_DIR%\\DATA\\Btn\\");
... //Allocation of memory sStart_pan = new char[strlen("bmap = Start_pan.jpg;\ button (381, 229, btnStart_d.jpg, btnStart_u.jpg, btnStart_u.jpg, meth1, NULL, NULL);\ flags = OVERLAY;")];
//copy code of panel to char array strcpy(sStart_pan,"bmap = Start_pan.jpg;\ button (381, 229, btnStart_d.jpg, btnStart_u.jpg, btnStart_u.jpg, meth1, NULL, NULL);\ flags = OVERLAY;");
//create a new panel Start_pan = pan_create(sStart_pan,1);
// make it visible Start_pan->flags|=VISIBLE;
// wait some frame for visualisation of panel for (int i=0; i<3; i++) engine_frame();
It's working on my computer. The buttons is shown and method "meth1" is working. I'm using MS Visual Studio 2005 and A7 engine (version 7.06.1)
With best regards.
Last edited by Olorin; 04/20/09 09:36.
|
|
|
|