Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,449 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Struggle with pan_create pan_remove #130101
05/15/07 22:03
05/15/07 22:03
Joined: Jul 2006
Posts: 40
North Europe
D
DeepReflection Offline OP
Newbie
DeepReflection  Offline OP
Newbie
D

Joined: Jul 2006
Posts: 40
North Europe
I'm trying to make a reusable menupanel system, that only use system
resourses when called for, but I've reached a dead end....

Please tell What am I doing wrong? .. or is this bugs? (using LiteC V1.02)


Approach structure example 1:

Code:

PANEL* onfly;

function firstpan() {
onfly = pan_create("bmap=\"background.bmp\";
button = 20,0,\"ubutt.png\",\"sbutt.png\",\"hbutt.png\",NULL,NULL,NULL;
button = 60,0,\"ubutt.png\",\"sbutt.png\",\"hbutt.png\",VideoPan,NULL,NULL;
",1);
onfly.flags = VISIBLE;
}

function VideoPan() {
pan_remove(onfly);
onfly = pan_create("bmap=\"background.bmp\";
button = 20,0,\"ubutt.png\",\"sbutt.png\",\"hbutt.png\",GamePan,NULL,NULL;
button = 60,0,\"ubutt.png\",\"sbutt.png\",\"hbutt.png\",NULL,NULL,NULL;
",1);
onfly.flags = VISIBLE;
}

usw...




This will bring up the panel but click on the button for VideoPan
(and call for the VideoPan() ) won't work. Actually no buttons work
this way, seems something not getting initialized internally.


Approach structure example 2:

Code:

PANEL* onfly = {bmap="background.bmp";
button = 20,0,"ubutt.png","sbutt.png","hbutt.png",NULL,NULL,NULL;
button = 60,0,"ubutt.png","sbutt.png","hbutt.png",VideoPan,NULL,NULL;
}

usw...

onfly.flags = VISIBLE;




-> Mousepick button for VideoPan works and following executes

Code:

function VideoPan() {
pan_remove(onfly);
onfly = pan_create("bmap=\"background.bmp\";
button = 20,0,\"ubutt.png\",\"sbutt.png\",\"hbutt.png\",GamePan,NULL,NULL;
button = 60,0,\"ubutt.png\",\"sbutt.png\",\"hbutt.png\",NULL,NULL,NULL;
",1);
onfly.flags = VISIBLE;
}



-> Now button function for GamePan are not updated, the initial pan creation
(internal structure) remains (NULL in this case), and GamePan() will never be called for.


Whoever has the gold makes the rules.
Re: Struggle with pan_create pan_remove [Re: DeepReflection] #130102
05/16/07 06:34
05/16/07 06:34
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
I have not much time yet, so I can't test it. Anyway, here are my suggestions:

In the first example you create a panel with a button function 'videopan'. But it isnt defined previously! Try to make a function prototype of videopan before 'firstpan'.

If this isnt working at all, try to use function pointers instead and fill them after engine start. I will test it later.

Cheers
Christian

Re: Struggle with pan_create pan_remove [Re: HeelX] #130103
05/17/07 19:49
05/17/07 19:49
Joined: Jul 2006
Posts: 40
North Europe
D
DeepReflection Offline OP
Newbie
DeepReflection  Offline OP
Newbie
D

Joined: Jul 2006
Posts: 40
North Europe
Yes, I may have overseen the necessity to define before use (literally the manual says "Previously defined functions and bitmaps must be given, non-initialized pointers won't do" for buttons), but I have run some tests and that still make no sense?! or even contradict.

I'll bring on an easy way to test this anomaly with some comments, to anyone who will test and bring some light on this behavior.

Throw this bit of code in Workshop06 folder from the liteC workshop together with the tap.wav from work folder.


Code:

////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
////////////////////////////////////////////////////////////////////
// run in workshop06 folder and add tap.wav from work folder here too

PANEL* first_pan =
{
digits(200,550,"hit P for panel",*,0,0);
digits(700,2,"memory used kb",*,0,0);
digits(700,20,"bmp%6.0f",*,1,d3d_texbmaps);
flags = VISIBLE;
}

BMAP* mouse_pcx = "mouse.pcx";
SOUND* beep_sound = "tap.wav"; // earthball.c sound

BMAP* Back_bmp = "main.pcx"; // Panel background
BMAP* bQ_c = "quitclicked.pcx"; // Button selected
BMAP* bQ_n = "quitnormal.pcx"; // Button normal
BMAP* bQ_o = "quitover.pcx"; // Button highlighted (pointer over)

function quit_program() { while (key_any) {wait (1);} sys_exit(NULL); } // Quit

function ConPan() {quit_program(); } // Prototype
function GamPan(); // Prototype


PANEL* onfly = {
bmap= Back_bmp;
digits = 40,35 ,"initial PANEL creation level",*,0,0;
button =250,134,bQ_c,bQ_n,bQ_o,quit_program,NULL,NULL;
button = 10,50 ,bQ_c,bQ_n,bQ_o,GamPan1,NULL,NULL; // Notice that PANEL* create don't accept your empty prototype if you remove 1 from GamPan
digits = 5,80 ,"Jump GamPan()",*,0,0;
button =200,50 ,bQ_c,bQ_n,bQ_o,ConPan,NULL,NULL; // But it gladly accept the ugly ConPan proto..
digits =190,80 ,"Jump ConPan()",*,0,0;
digits =45,160 ,"Tappsound",*,0,0;
button =10,134 ,bQ_c,bQ_n,bQ_o,TappS,NULL,NULL; // Tapp sound
pos_x = 250;
pos_y = 200;
}

//PANEL* onfly; // Since this startup with an empty won't bring buttons definitions to work at all I abandoned that path

///////////////////////////////////////////////////////////////////////////

function TappS(){ snd_play(beep_sound,100,0);
}

function ConPan1() {
TappS();
pan_remove (onfly);
wait(1);
onfly = pan_create("bmap= Back_bmp;
digits = 10,35 ,\"You ran ConPan1() \",*,0,0;
button(250,134,bQ_c,bQ_n,bQ_o,quit_program,NULL,NULL);
button = 10,50 ,bQ_c,bQ_n,bQ_o,GamPan,NULL,NULL; // No matter how you got here, it won't work
digits = 5,85 ,\"Jump GamPan()\",*,0,0;
button =200,50 ,bQ_c,bQ_n,bQ_o,ConPan,NULL,NULL; //If hard jumped by I key, this will quit if you hit ConPan button
digits =190,85 ,\"Jump ConPan()\",*,0,0;
digits = 45,160,\"Tappsound\",*,0,0;
button =10,134 ,bQ_c,bQ_n,bQ_o,TappS,NULL,NULL; // Tapp sound
",1);
onfly.flags = OVERLAY | VISIBLE;
onfly.pos_x = 250;
onfly.pos_y = 200;
}

function GamPan1() {
TappS();
pan_remove (onfly);
wait(3);
onfly = pan_create("bmap= Back_bmp;
digits = 10,35 ,\"You ran GamPan1() \",*,0,0;
button =250,134,bQ_c,bQ_n,bQ_o,quit_program,NULL,NULL;
button = 10,50 ,bQ_c,bQ_n,bQ_o,GamPan,NULL,NULL;
digits = 5,85 ,\"Jump GamPan()\",*,0,0;
button =200,50 ,bQ_c,bQ_n,bQ_o,ConPan1,NULL,NULL; // Will not run unregarded that you defined ConPan1 function before this
digits =190,85 ,\"Jump ConPan()\",*,0,0;
digits = 45,160,\"Tappsound\",*,0,0;
button =10,134 ,bQ_c,bQ_n,bQ_o,TappS,NULL,NULL; // Tapp sound
",1);
onfly.flags = OVERLAY | VISIBLE;
onfly.pos_x = 250;
onfly.pos_y = 200;
}

function FirstPan() {
TappS();
pan_remove(onfly);
onfly = pan_create("bmap= Back_bmp;
digits = 10,35 ,\"You ran FirstPan() with by P-key \",*,0,0;
button =250,134,bQ_c,bQ_n,bQ_o,quit_program,NULL,NULL;
button = 10,50 ,bQ_c,bQ_n,bQ_o,GamPan,NULL,NULL; // You think it will run GamPan(GamPan1) but it will not!
digits = 5,85 ,\"Jump GamPan()\",*,0,0;
button =200,50 ,bQ_c,bQ_n,bQ_o,ConPan1,NULL,NULL; // Now we call a previously defined function but it will not!
digits =190,85 ,\"Jump ConPan()\",*,0,0;
button =110,50 ,bQ_c,bQ_n,bQ_o,GamPan1,NULL,NULL; // This work since it's new and call GamPan1()!?, GamPan() call will not run!
digits =100,85 ,\"Jump GamPan()\",*,0,0;
digits = 45,160,\"Tappsound\",*,0,0;
button =10,134 ,bQ_c,bQ_n,bQ_o,TappS,NULL,NULL; // Tapp sound
",1);
onfly.flags = OVERLAY | VISIBLE;
onfly.pos_x = 250;
onfly.pos_y = 200;
}

function Dinky()
{
snd_play(beep_sound,100,0);
snd_play(beep_sound,100,0);
onfly.flags = OVERLAY | VISIBLE;
}

///////////////////////////////////////////////////////////////
function main()
{
ConPan = ConPan1; // Repoint function
GamPan = GamPan1; // Repoint function

video_mode = 7; // 800x600 screen
shadow_stencil = 1;
sound_vol = 100;
master_vol = 100;
screen_color.blue = 200;
mouse_map = mouse_pcx;
mouse_mode = 2;

on_p = FirstPan; // Put upp panel
on_o = Dinky; // Bring up wathever in onfly structure
on_i = ConPan; // Hard jump to ConPan

while (1) { // MAJOR LOOP
if (mouse_mode != 0) {
mouse_pos.x = mouse_cursor.x;
mouse_pos.y = mouse_cursor.y;
}
wait(1);
}
}




Whoever has the gold makes the rules.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1