3 registered members (NewbieZorro, TipmyPip, 1 invisible),
19,045
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Struggle with pan_create pan_remove
#130101
05/15/07 22:03
05/15/07 22:03
|
Joined: Jul 2006
Posts: 40 North Europe
DeepReflection
OP
Newbie
|
OP
Newbie
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: HeelX]
#130103
05/17/07 19:49
05/17/07 19:49
|
Joined: Jul 2006
Posts: 40 North Europe
DeepReflection
OP
Newbie
|
OP
Newbie
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.
|
|
|
|