1 registered members (AndrewAMD),
959
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Panel below Entities
[Re: Espér]
#277266
07/08/09 15:07
07/08/09 15:07
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
This snippet has pretty much everything you are after I think. If you have questions, just ask...
#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);
}
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Panel below Entities
[Re: EvilSOB]
#277268
07/08/09 15:14
07/08/09 15:14
|
Joined: Mar 2008
Posts: 2,247 Baden Württemberg, Germany
Espér
OP
Expert
|
OP
Expert
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
|
if all i want is a crash in main.. yes ^^
//=================================================================================================================================
// //
// 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);
}
//=================================================================================================================================
// //
// 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);
//=================================================================================================================================
// //
// 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
Last edited by Espér; 07/08/09 15:25.
|
|
|
Re: Panel below Entities
[Re: Espér]
#277271
07/08/09 15:38
07/08/09 15:38
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
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
//=================================================================================================================================
// //
// 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);
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Panel below Entities
[Re: Espér]
#277290
07/08/09 17:10
07/08/09 17:10
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
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;
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Panel below Entities
[Re: Espér]
#277297
07/08/09 17:38
07/08/09 17:38
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
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.
PANEL* mainpan = { ... bmap = testobjekt; ... }
But, if you use a image filename in the panel, like this
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.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Panel below Entities
[Re: EvilSOB]
#277310
07/08/09 18:50
07/08/09 18:50
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
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? mypanmap.name = str_create( mainpan->bmap->link.name );
|
|
|
Re: Panel below Entities
[Re: Pappenheimer]
#277315
07/08/09 19:43
07/08/09 19:43
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
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...
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...
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...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
|