Panel below Entities

Posted By: Espér

Panel below Entities - 07/06/09 20:07

I asked for a new function of panels here: Panel.layer = lower than ent => below ent!?

So i tried:

Code:
#include <acknex.h>
#include <default.c>


//========================================================================
BMAP* testbmap = "flatplane.tga";


//========================================================================
PANEL* test =
{
   layer = -1;
   bmap = testbmap;
   flags = SHOW;
}

//========================================================================

function main()
{
   fps_max = 60;
   video_mode = 8;
   level_load(NULL);
   wait(3);
   
   ent_create("cube.mdl", vector(0,0,0), NULL);
   
   camera.tilt = -50;
   camera.pan = 90;
   camera.z = 500;
   camera.x = 0;
   camera.y = -250;
}




but the panel is still shown ABOVE the model...

Do you know any way to show panels i want BELOW Entities?
Posted By: Joozey

Re: Panel below Entities - 07/06/09 21:10

I'd make screen entities but as Helghast points out negative layers work, perhaps you should wait for an example from him :p.
Posted By: Espér

Re: Panel below Entities - 07/07/09 21:57

ok.. while iw ait for the the other topic..

Another question:

How am i able to readout the bitmapname of a panel...?
I need the name to be written into a my.string1
Problem: There´re many Panels.. and i need the filename of every panel ^^.

Sylar said, i should use Structs.. but i´ve no clue how they work...
That´s what i tried at the moment:
Code:
//=================================================================================================================================
//                                                                                                                               //
//                                                     DAS MAINSCRIPT                                                            //
//                                                     ^^^^^^^^^^^^^^                                                            //
//                                                                                                                               //
//=================================================================================================================================
//                                                                                                                               //
//                                          EINBINDEN DER UNTERORDNER UND SCRIPTS                                                //
//                                          """""""""""""""""""""""""""""""""""""                                                //
//                                                                                                                               //
//=================================================================================================================================
#define PRAGMA_PATH "Graphics\Characters"


#include <acknex.h>
#include <default.c>

//=================================================================================================================================
//                                                                                                                               //
//                                                       FUNKTIONEN                                                              //
//                                                       """"""""""                                                              //
//                                                                                                                               //
//=================================================================================================================================
typedef struct 
{
	STRING* name;
	BMAP* bitmap;
} PANELMAP;

PANELMAP* mypanmap;


//=================================================================================================================================
//                                                                                                                               //
//                                                     DAS MAINSCRIPT                                                            //
//                                                     """"""""""""""                                                            //
//                                                                                                                               //
//=================================================================================================================================
function main()
{
	fps_max = 60;
	d3d_antialias = 9;
	video_set(1024,768,32,0);
	video_window(vector(10,10,NULL),NULL,48,"@-´-,-´-,-´-,-  NEVERTOLD  -,-`-,-`-,-`-@ ");
	screen_color.red   = 1;
	screen_color.green = 1;
	screen_color.blue  = 1;
	sky_color.red   = 1;
	sky_color.green = 1;
	sky_color.blue  = 1;
	level_load(NULL);
	wait(3);
	
	str_cpy(mypanmap.name, "Gegner_Weißer Drachenreiter_stehen.png");
	mypanmap.bitmap = bmap_create(mypanmap.name);
	
	
	
	PANEL* test = pan_create("bmap = mypanmap.bitmap; flags = SHOW;", 10);
	
	error(mypanmap.name);
}



But it only gives me an "E1513" Error..

Need help!!!
Posted By: Joozey

Re: Panel below Entities - 07/07/09 23:45

You can't read out the bitmap name of dynamically created bitmaps, I've requested this feature before without a positive respond.
For static bitmaps: bmap.link.name (as to read in the public header).
Posted By: Espér

Re: Panel below Entities - 07/07/09 23:46

Sylar said, i should use Structs.. but i´ve no clue how they work...
That´s what i tried at the moment:
Code:
//=================================================================================================================================
//                                                                                                                               //
//                                                     DAS MAINSCRIPT                                                            //
//                                                     ^^^^^^^^^^^^^^                                                            //
//                                                                                                                               //
//=================================================================================================================================
//                                                                                                                               //
//                                          EINBINDEN DER UNTERORDNER UND SCRIPTS                                                //
//                                          """""""""""""""""""""""""""""""""""""                                                //
//                                                                                                                               //
//=================================================================================================================================
#define PRAGMA_PATH "Graphics\Characters"


#include <acknex.h>
#include <default.c>

//=================================================================================================================================
//                                                                                                                               //
//                                                       FUNKTIONEN                                                              //
//                                                       """"""""""                                                              //
//                                                                                                                               //
//=================================================================================================================================
typedef struct 
{
	STRING* name;
	BMAP* bitmap;
} PANELMAP;

PANELMAP* mypanmap;


//=================================================================================================================================
//                                                                                                                               //
//                                                     DAS MAINSCRIPT                                                            //
//                                                     """"""""""""""                                                            //
//                                                                                                                               //
//=================================================================================================================================
function main()
{
	fps_max = 60;
	d3d_antialias = 9;
	video_set(1024,768,32,0);
	video_window(vector(10,10,NULL),NULL,48,"@-´-,-´-,-´-,-  NEVERTOLD  -,-`-,-`-,-`-@ ");
	screen_color.red   = 1;
	screen_color.green = 1;
	screen_color.blue  = 1;
	sky_color.red   = 1;
	sky_color.green = 1;
	sky_color.blue  = 1;
	level_load(NULL);
	wait(3);
	
	str_cpy(mypanmap.name, "Gegner_Weißer Drachenreiter_stehen.png");
	mypanmap.bitmap = bmap_create(mypanmap.name);
	
	
	
	PANEL* test = pan_create("bmap = mypanmap.bitmap; flags = SHOW;", 10);
	
	error(mypanmap.name);
}



But it only gives me an "E1513" Error..

Need help!!!
Posted By: Joozey

Re: Panel below Entities - 07/07/09 23:51

You only have a pointer to your struct (PANELMAP* mypanmap;) and not the actual object. So you want to fill a bitmap pointer than doesn't exists (the bitmap pointer only exists in an actual object, not in an empty pointer). Either use PANELMAP mypanmap;, or fill mypanmap with the object in your function (mypanmap = malloc( sizeof(PANELMAP) );)


Also, when referencing pointers, say:
PANELMAP* mypanmap;
mypanmap.bitmap = NULL;

Then always use the arrow notation:
PANELMAP* mypanmap;
mypanmap->bitmap = NULL;
Posted By: Espér

Re: Panel below Entities - 07/08/09 13:37

oh man.. structs are hell of shit to code... and the manual is actually not really good.. a few sentences and many examples wich said nonsense... HWERE THE HELL, are some really examples and a good manual to this..


seems like i use entity definated strings/bitmaps.. because i´ve really no clue how structs work..
Posted By: EvilSOB

Re: Panel below Entities - 07/08/09 14:34

Do you really need the REAL filename?
Or would "Gegner_Weißer Drachenreiter_stehen_png" do for "Gegner_Weißer Drachenreiter_stehen.png"?
Try error(mypan->bmap->link.name); (once the panel mypan is created of course)

ALSO: Just tested paanel behind entities. Panel must be negative layer AND sky_color must = 0,0,0
Posted By: Espér

Re: Panel below Entities - 07/08/09 14:59

no.. i need the real filename of the panelbitmap..
Posted By: Espér

Re: Panel below Entities - 07/08/09 15:02

ok..

this is my structcode:
Code:
//=================================================================================================================================
//                                                                                                                               //
//                                                       DIE BITMAPS                                                             //
//                                                       ^^^^^^^^^^^                                                             //
//                                                                                                                               //
//=================================================================================================================================
//=================================================================================================================================
//                                                                                                                               //
//                                                      STRUCKTUREN                                                              //
//                                                      """""""""""                                                              //
//                                                                                                                               //
//=================================================================================================================================
typedef struct 
{
	STRING* name;
	BMAP* bitmap;
} PANELMAP;


//=================================================================================================================================
//                                                                                                                               //
//                                                  STRUCKTURENPOINTER                                                           //
//                                                  """"""""""""""""""                                                           //
//                                                                                                                               //
//=================================================================================================================================
PANELMAP* mypanmap;

//=================================================================================================================================
//                                                                                                                               //
//                                                  STRUCKTURENFUNKTION                                                          //
//                                                  """""""""""""""""""                                                          //
//                                                                                                                               //
//=================================================================================================================================
PANELMAP* panelmapSetup(PANELMAP* inpanel)
{
	str_cpy(inpanel.name, "test");
	inpanel.bitmap = bmap_create(testobjekt);
}

//=================================================================================================================================
//                                                                                                                               //
//                                                   STRUCKTURENMEMORY                                                           //
//                                                   """""""""""""""""                                                           //
//                                                                                                                               //
//=================================================================================================================================
mypanmap = malloc(sizeof(PANELMAP));
panelmapSetup(mypanmap);



and this is called right after level loading in the main function:
Code:
level_load("leer.wmb");
	wait(3);
	
	vec_set(camera.x, vector(0,-250,500));
	vec_set(camera.pan, vector(90,-50,0));
	
	error("str_cpy(mypanmap.name, Weisser_Drachenreiter_1+4.tga);"); ///////////
	str_cpy(mypanmap.name, "Weisser_Drachenreiter_1+4.tga");
	error("mypanmap.bitmap = bmap_create(mypanmap.name);"); /////////////////////////////
	mypanmap.bitmap = bmap_create(mypanmap.name);
	
	error("PANEL* testerpanel erstellen"); //////////////////////////////////////////////
	pan_create("pos_x=300; pos_y=150; bmap = mypanmap.bitmap; flags = SHOW;", -10);
	
	
	error(mypanmap.name);



What i get? a Crash in main right after the first error-message.
Posted By: EvilSOB

Re: Panel below Entities - 07/08/09 15:07

This snippet has pretty much everything you are after I think.
If you have questions, just ask...
Code:
#include <acknex.h>
#include <default.c>


PANEL* mainpan =
{
	layer = -10;
	pos_x = 350;  pos_y = 175;
	bmap = "test_img.bmp";
	flags = SHOW;
}


typedef struct 
{
	STRING* name;
	BMAP* bitmap;
}PANELMAP;


PANELMAP mypanmap;



function main()
{
	sky_color.red   = 0;
	sky_color.green = 0;
	sky_color.blue  = 0;
	level_load(NULL);

	wait(3);
	
	vec_set(camera.x, vector(200,-20,50));
	vec_set(camera.pan, vector(175,-20,0));
	ent_create("cube.mdl", nullvector,NULL);

	wait(3);	
	
	mypanmap.name = str_create( mainpan->bmap->link.name );
	(mypanmap.name->chars)[str_len(mypanmap.name)-4] = 46;
	
	mypanmap.bitmap = mainpan.bmap;
	
	
	error(mypanmap.name);

}


Posted By: Espér

Re: Panel below Entities - 07/08/09 15:14

if all i want is a crash in main.. yes ^^

Click to reveal.. ("main.c")

Code:
//=================================================================================================================================
//                                                                                                                               //
//                                                     DAS MAINSCRIPT                                                            //
//                                                     ^^^^^^^^^^^^^^                                                            //
//                                                                                                                               //
//=================================================================================================================================
//                                                                                                                               //
//                                          EINBINDEN DER UNTERORDNER UND SCRIPTS                                                //
//                                          """""""""""""""""""""""""""""""""""""                                                //
//                                                                                                                               //
//=================================================================================================================================
#define PRAGMA_PATH "Graphics\Characters"
#define PRAGMA_PATH "Graphics\Battlebacks"
#define PRAGMA_PATH "Data\Levels"


#include <acknex.h>
#include <default.c>

#include "game_bitmaps.c"
#include "game_structs.c"

//=================================================================================================================================
//                                                                                                                               //
//                                                       FUNKTIONEN                                                              //
//                                                       """"""""""                                                              //
//                                                                                                                               //
//=================================================================================================================================


//=================================================================================================================================
//                                                                                                                               //
//                                                        AKTIONEN                                                               //
//                                                        """"""""                                                               //
//                                                                                                                               //
//=================================================================================================================================
action debugging()
{
	wait(1);
	while(1)
	{
		my.pan  += random(3)*time_step;
		my.tilt += random(3)*time_step;
		my.roll += random(3)*time_step;
		wait(1);
	}
}

//=================================================================================================================================
//                                                                                                                               //
//                                                     DAS MAINSCRIPT                                                            //
//                                                     """"""""""""""                                                            //
//                                                                                                                               //
//=================================================================================================================================
function main()
{
	fps_max = 60;
	d3d_antialias = 9;
	video_set(1024,768,32,0);
	video_window(vector(10,10,NULL),NULL,48,"@-´-,-´-,-´-,-  NEVERTOLD  -,-`-,-`-,-`-@");
	screen_color.red   = 0;
	screen_color.green = 0;
	screen_color.blue  = 0;
	sky_color.red   = 0;
	sky_color.green = 0;
	sky_color.blue  = 0;
	level_load("leer.wmb");
	wait(3);
	
	vec_set(camera.x, vector(0,-250,500));
	vec_set(camera.pan, vector(90,-50,0));
	
	
	PANEL* mainpan = pan_create("pos_x=300; pos_y=150; bmap = testobjekt; flags = SHOW;", -1);
	
	//=================================================================================================================================
	//	error("str_cpy(mypanmap.name, Gegner_Weisser_Drachenreiter_stehen.png);"); //////////
	//	str_cpy(mypanmap.name, "Weisser_Drachenreiter_1+4.tga");
	//	
	//	error("mypanmap.bitmap = bmap_create(mypanmap.name);"); /////////////////////////////
	//	mypanmap.bitmap = "Gegner_Weisser_Drachenreiter_stehen.png";
	//	
	//	error("PANEL* testerpanel erstellen"); //////////////////////////////////////////////
	//	pan_create("pos_x=300; pos_y=150; bmap = mypanmap.bitmap; flags = SHOW;", -10);
	//	
	//	error(mypanmap.name); ///////////////////////////////////////////////////////////////
	mypanmap.name = str_create( mainpan->bmap->link.name );
	(mypanmap.name->chars)[str_len(mypanmap.name)-4] = 46;
	
	mypanmap.bitmap = mainpan.bmap;
	
	error(mypanmap.name);

	//=================================================================================================================================
	
	
	
	pan_create("bmap = testobjekt; flags = SHOW;", -10);
	ent_create("Weisser_Drachenreiter_1+4.tga", vector(0,0,0), debugging);
}


Click to reveal.. ("game_structs.c")

Code:
//=================================================================================================================================
//                                                                                                                               //
//                                                     DIE STRUCKTUREN                                                           //
//                                                     ^^^^^^^^^^^^^^^                                                           //
//                                                                                                                               //
//=================================================================================================================================
//=================================================================================================================================
//                                                                                                                               //
//                                                      STRUCKTUREN                                                              //
//                                                      """""""""""                                                              //
//                                                                                                                               //
//=================================================================================================================================
typedef struct 
{
	STRING* name;
	BMAP* bitmap;
} PANELMAP;


//=================================================================================================================================
//                                                                                                                               //
//                                                  STRUCKTURENPOINTER                                                           //
//                                                  """"""""""""""""""                                                           //
//                                                                                                                               //
//=================================================================================================================================
PANELMAP* mypanmap;

//=================================================================================================================================
//                                                                                                                               //
//                                                  STRUCKTURENFUNKTION                                                          //
//                                                  """""""""""""""""""                                                          //
//                                                                                                                               //
//=================================================================================================================================
PANELMAP* panelmapSetup(PANELMAP* inpanel)
{
	str_cpy(inpanel.name, "test");
	inpanel.bitmap = bmap_create(testobjekt);
}

//=================================================================================================================================
//                                                                                                                               //
//                                                   STRUCKTURENMEMORY                                                           //
//                                                   """""""""""""""""                                                           //
//                                                                                                                               //
//=================================================================================================================================
mypanmap = malloc(sizeof(PANELMAP));
panelmapSetup(mypanmap);


Click to reveal.. ("game_bitmaps.c")

Code:
//=================================================================================================================================
//                                                                                                                               //
//                                                       DIE BITMAPS                                                             //
//                                                       ^^^^^^^^^^^                                                             //
//                                                                                                                               //
//=================================================================================================================================
//=================================================================================================================================
BMAP* testobjekt = "Mountainroad.png";



That´re the codes..


i think i´ll do it like i said..
creating entitys.. and use their Skills and Strings for the panelbase
Posted By: EvilSOB

Re: Panel below Entities - 07/08/09 15:38

Gah! So much happening at once!

Hard for me to tell whats going on.

But Im fairly sure there is no way to get to the bitmap names when you load a BMAP into a panel.
Whereas you can (my way) when you load a bmap FILE into a panel, like this.
PANEL* mainpan = pan_create("pos_x=300; pos_y=150; bmap = \"Mountainroad.bmp\"; flags = SHOW;", -1);

Also,
Make this change to game_structs.c to get your structures working
Code:
//=================================================================================================================================
//                                                                                                                               //
//                                                  STRUCKTURENPOINTER                                                           //
//                                                  """"""""""""""""""                                                           //
//                                                                                                                               //
//=================================================================================================================================
PANELMAP mypanmap;

//=================================================================================================================================
//                                                                                                                               //
//                                                  STRUCKTURENFUNKTION                                                          //
//                                                  """""""""""""""""""                                                          //
//                                                                                                                               //
//=================================================================================================================================
PANELMAP* panelmapSetup(PANELMAP* inpanel)
{
	str_cpy(inpanel.name, "test");
	inpanel.bitmap = bmap_create(testobjekt);
}

//=================================================================================================================================
//                                                                                                                               //
//                                                   STRUCKTURENMEMORY                                                           //
//                                                   """""""""""""""""                                                           //
//                                                                                                                               //
//=================================================================================================================================
//mypanmap = malloc(sizeof(PANELMAP));
panelmapSetup(mypanmap);


Posted By: Espér

Re: Panel below Entities - 07/08/09 16:45

hmm.. ok.. now there´s no error or crash..

but the mypanmap.name gives me as result "testob.ekt"

o.O
Posted By: EvilSOB

Re: Panel below Entities - 07/08/09 17:10

As I said, but maybe not clearly, if you use
BMAP* picture = "image.bmp";
PANEL* panel = { ... bmap=picture; ...}

then there is NO way to get the filename of the original bitmap
through the panel, the filename just isnt stored anywhere.

But if you use PANEL* panel = { ... bmap="image.bmp"; ...} then you can get it back with
STRING* filename = str_create( mainpan->bmap->link.name );
(filename.chars)[str_len(filename.name)-4] = 46;

Posted By: Espér

Re: Panel below Entities - 07/08/09 17:12

ok.. i´m confused.. sry.. have no clue of structs...
Posted By: EvilSOB

Re: Panel below Entities - 07/08/09 17:38

Thats cool. I'll try to explain.

When you create a BMAP from a file, the name is lost. End of story.

So if you use a BMAP in a panel, there is NO way to get the original filename.
Code:
PANEL* mainpan = {   ...  bmap = testobjekt;  ...  }


But, if you use a image filename in the panel, like this
Code:
PANEL* mainpan = {   ...  bmap = "Mountainroad.png";  ...  }

then the filename CAN be salvaged.

[in both these examples Ive used global panel definitions, this applies to pan_create()-created panels too]

I wont explain the "how" of my piece of code, unless you ask, as it is pretty advanced struct and pointer stuff.
But basically the engine creates a temporary BMAP based on the filename, and my code just gets that temp name,
and turns it back into a filename as a string.
Posted By: Pappenheimer

Re: Panel below Entities - 07/08/09 18:50

You say its pretty advanced stuff, nonetheless it seems that one could learn it. May I ask where the "link.name" is comming from/relating to, and what the "->" means?
Quote:
mypanmap.name = str_create( mainpan->bmap->link.name );

Posted By: EvilSOB

Re: Panel below Entities - 07/08/09 19:43

No problem. I was just giving Esper a chance of avoiding un-familiar stuff
if he felt he wasnt ready for it, being new to structs as he is.

For you, Pappenheimer, I wouldnt call it advanced most likely, just unfamiliar.
So here goes.

mainpan is our example panel name. Created with a global declaration or pan_create().
mainpan.bmap is a pointer to the BMAP it uses as a background.
To access the contents of a pointer, its best to use the "->" separator instead of just "."
So therefore, using
mainpan->bmap will allow us to get to the properties of the BMAP.
Now most engine structured-objects are part of a linked-list system. The "link" property
is a pointer to a C_LINK structure that holds these lists together.

mainpan->bmap->link gives us access to the properties of the C_Link object.
mainpan->bmap->link.name gives us a char pointer to the engine-recognised name of the BMAP.

So we now have a char* to the name of the BMAP the panel is using.
Now, IF the panels BMAP was set from a pre-defined BMAP, like this...
Code:
BMAP* pic = "image.jpg";
PANEL* mainpan = {   bmap = pic;  }

then the char string will be "pic", cause thats the engine-recognised name it was given in the BMAP* pic = ... line.

But, if the panel BMAP was directly given a filename like so...
Code:
PANEL* mainpan = {   bmap = "image.jpg";  }

THEN the char string will be "image_jpg", because thats the engine-generated temporary BMAP name.
The generated name is basically the filename with the "." replaced by a "_"

That is how I am retrieving the filenames, by accessing the bmap.link name char string and
building a STRING from it with STRING* file_name = str_create(mainpan->bmap->link.name);
Then I convert this name from a temp-name back to the real filename by (crudely)replacing the "_" that is
four bytes from the end with a new "." (ascii-code 46) using the line (file_name.chars)[str_len(file_name)-4] = 46;

Any other questions on anything Ive covered here, just ask...
Posted By: Joozey

Re: Panel below Entities - 07/08/09 21:08

I was typing a big post here, but evilsob was ahead of me smile.

In addition, I contributed a way of structured programming here:
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=277335#Post277335

Perhaps it's of use for you.

Regards,
Joozey
Posted By: Pappenheimer

Re: Panel below Entities - 07/08/09 21:43

EvilSOB, thank you for your kind explanations. You're opening a further part of a door to new fields in programming to me!

I looked for the first time into the header files of Lite-C like atypes.h, now.

Code:
// use for the lite-C compiler 
typedef struct C_LINK {
	long	index;		// index number of the object (handle)
	struct C_LINK *next; // pointer to next object
	char	*name;		// pointer to name of object (if any)
} C_LINK;				// object header

typedef byte* EVENT;	// just a pointer to a machine code function

typedef struct STRING {
	C_LINK	link;
	char	*chars;		// pointer to null terminated string
	long	length;		// allocated length of string
	long	flags;		// see STRF_... above
    byte    pad[PAD_STRING];
} STRING;

typedef struct SOUND {
	C_LINK	link;
	long 	length;
	byte	*buffer;
	long	type;		// 2 = WAV, 5 = OGG
} SOUND;



This could be a way to get an idea how to organize my own code, when looking at the code of the engine that I know quite closely from the wdl site.

@ Joozey:
Yeah, I already recognized that. Very much appreciated. I'll definitely have a closer look into that soon!

Explanations like that are very appreciated! smile
© 2024 lite-C Forums