|
2 registered members (Grant, AndrewAMD),
911
guests, and 9
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Wanna turn your panels into entities? Look here! [OBSOLETE]
#328241
06/11/10 08:57
06/11/10 08:57
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
OP
Expert
|
OP
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Hi again guys. I was looking into this for someone, but I cant remember who? But Ive developed it a bit beyond what they wanted, but I thought it is more "generic" now, and so maybe of interest to some of you. In a nutshell, just create an ouput panel, that is one that has no "active" controls on it. Buttons,sliders, etc are out! (for now) Feed that panel into my "ent_for_panel", and it gives you a sprite-entity with the output from the panel on it. You can have it as a view-entity or a level-entity. Heres the code, and the spoiler below it is a sample script showing how to get it to work...
////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// ENT_FOR_PANEL - Function for turning a panel into a view-entity or level-entity sprite //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Author : EvilSOB //
// Written : 11-06-2010 //
// Version : 1.0 //
// //
// Requirements: Acknex.h //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// ent_for_panel(PANEL* panel, var type, VIEW* view); //
//----------------------------------------------------------------------------------------------------//
// Create a new entity based of the visual output of "panel". (using target_map) //
// !!! ACTIVE panel controls / clicks are NOT recognised. !!! //
// "panel" is no longer visible once its attached to the new entity. //
// The function returns a pointer to the new entity. This entityis then used for all //
// visual effect and position controls. //
// Both panel and entity are removed only if PANEL.SHOW is turned off. //
//----------------------------------------------------------------------------------------------------//
// Parameters: //
// panel - pointer to the "source" panel. (must contain a valid panel) //
// type - entity type to create. 0=view-entity, 1=level-entity. (optional default = 0 ) //
// view - pointer to the target view. (optional default = camera) //
//----------------------------------------------------------------------------------------------------//
// Returns: //
// Pointer to panel-entity. //
//----------------------------------------------------------------------------------------------------//
// //
// Overloads:: //
// ent_for_panel(PANEL* panel); === defaults to type=0 & view=camera //
// ent_for_panel(PANEL* panel, var type) === defaults to view=camera //
// ent_for_panel(PANEL* panel, VIEW* view) === defaults to type=0 //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
void _ent_panel_worker(ENTITY* ME, PANEL* panel, VIEW* view); //worker-thread prototype //
////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
ENTITY* ent_for_panel(PANEL* panel, var type, VIEW* view) //
{ if(!panel) return(NULL); //ABORT :: not a valid panel //
static long sprite_create_counter = 0; //keep names unique counter //
static short f_bmp[30] = { 19778,58,0,0,0,54,0,40,0,1,0,1,0,1,24, //
0,0,4,0,3779,0,3779,0,0,0,0,0,0,0,0 }; //
sprite_create_counter++; //create (required) unique temp dummy filename //
STRING* tmpname = str_create("#15"); // //
str_cat_num(tmpname, "tmp_%.0f.bmp", sprite_create_counter); //
add_buffer(tmpname, (void*)f_bmp, 60); //create dummy bitmap file in a file-buffer //
ENTITY* ME; if(!type) //
{ ME = ent_createlayer(tmpname, NULL, panel.layer); ME.x = 675; } //
else //
{ ME = ent_create(tmpname, NULL, NULL); } //
set(ME, SHOW); ME.material=mat_sprite; ME.alpha = panel.alpha; //
panel.target_map = bmap_createblack(panel.size_x*panel.scale_x, panel.size_y*panel.scale_y, 32); //
ent_setskin(ME, panel.target_map, 1); //
_ent_panel_worker(ME, panel, view); //
ME.string1 = tmpname; //
return(ME); //
} //
ENTITY* ent_for_panel(PANEL* panel) { return(ent_for_panel(panel, 0, camera)); } //
ENTITY* ent_for_panel(PANEL* panel, var type) { return(ent_for_panel(panel, type, camera)); } //
ENTITY* ent_for_panel(PANEL* panel, VIEW* view) { return(ent_for_panel(panel, 0, view)); } //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
void _ent_panel_worker(ENTITY* ME, PANEL* panel, VIEW* view) //
{ //
proc_mode = PROC_GLOBAL; //
if(!ME||!panel) return; //ABORT :: not a valid panel or entity //
panel.pos_x = panel.pos_y = 0; panel.alpha = 100; //
while(ME && panel && is(panel, SHOW)) wait(1); //
if(panel) //
{ reset(panel,SHOW); bmap_purge(panel.target_map); //
bmap_remove(panel.target_map); panel.target_map = NULL; } //
if(ME) //
{ add_buffer(ME.string1,NULL,NULL); str_remove(ME.string1); //
ent_remove(ME); } //
} //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <litec.h>
#include <default.c>
////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "ent_for_panel.h"
////////////////////////////////////////////////////////////////////////////////////////////////////////
var xxx=2999;
PANEL* test_pan = { bmap="tmp1.bmp"; layer=2; digits(10,10, "%.0f", "Arial#18b",1,xxx); flags=SHOW; }
function main()
{
level_load(NULL); camera.x = -550; sun_angle.pan = 180; wait(5);
ENTITY* My_Panel = NULL;
while(1)
{
if(key_space)
{
if(My_Panel) { reset(My_Panel, SHOW); My_Panel=NULL; }
else { My_Panel = ent_for_panel(test_pan); }
while(key_space) wait(1);
}
if(My_Panel)
{
My_Panel.x += key_home - key_end;
My_Panel.y += key_cul - key_cur;
My_Panel.z += key_cuu - key_cud;
My_Panel.pan += key_pgup - key_pgdn;
if(key_i) { toggle(My_Panel, INVISIBLE); while(key_i) wait(1); }
if(key_t) { toggle(My_Panel, TRANSLUCENT); while(key_t) wait(1); }
if(key_o) { toggle(My_Panel, OVERLAY); while(key_o) wait(1); }
if(key_n) { toggle(My_Panel, NOFILTER); while(key_n) wait(1); }
if(key_u) { toggle(My_Panel, UNLIT); while(key_u) wait(1); }
if(key_l) { toggle(My_Panel, LIGHT); while(key_l) wait(1); }
if(key_b) { toggle(My_Panel, BRIGHT); while(key_b) wait(1); }
}
xxx--;
wait(1);
}
}
As usual, Im hoping you guys can keep an eye out for bugs, and make any suggestions that come to mind. [EDIT] This is now a dead thread. I'll still respond to it, but it is no longer under development. A NEWER and BETTER version is now available HERE .
Last edited by EvilSOB; 07/16/10 11:56.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Wanna turn your panels into entities? Look here!
[Re: EvilSOB]
#328250
06/11/10 10:03
06/11/10 10:03
|
Joined: Apr 2010
Posts: 265
Vinous_Beret
Member
|
Member
Joined: Apr 2010
Posts: 265
|
|
|
|
Re: Wanna turn your panels into entities? Look here!
[Re: Vinous_Beret]
#328252
06/11/10 10:12
06/11/10 10:12
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
OP
Expert
|
OP
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Ahhh, Beret... it was you got me looking into this wasnt it?
BTW, this version isnt limited to only one at a time either...
Thanks for the inspiration my friend.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Wanna turn your panels into entities? Look here!
[Re: MrGuest]
#328261
06/11/10 11:18
06/11/10 11:18
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
OP
Expert
|
OP
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Yeah, my bad I s'pose. It was old dirty debuging code that I cant be bother cleaning up... Sorry, but Ive been awake for 32 hours ATM...  [EDIT] Thre. Sample code tidier now... Happy? 
Last edited by EvilSOB; 06/11/10 11:31.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Wanna turn your panels into entities? Look here!
[Re: MMike]
#328279
06/11/10 13:46
06/11/10 13:46
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
OP
Expert
|
OP
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Unfortunately NO. (at least not at this stage)
View-entities vary in size with resolution changes, and I havent been able to figure a formula for it yet. Its close to he mark on 800x600 but the evil math is eluding me for now...
Level-entities, floating in 3d-space as such, the concept doesnt really apply either.
I havent really even tried to get the size and position of the entities matched with the old panel, cause I see the whole point of making them entities if to get them more mobile than real panels.
Ive sized them on a 1-panel-pixel == 1-quant for sizing...
But remember, this is only a first edition...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Wanna turn your panels into entities? Look here!
[Re: MMike]
#328405
06/12/10 23:43
06/12/10 23:43
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
OP
Expert
|
OP
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Eh whut ?
I dont understand the question MMike...
Just put test onto the panels through 'digit' commands and its readable...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
|