Hi everyone, I've been using Irllicht for quite a while to do small projects but now I wanted to do a bigger project which would be an RPG final fantasy (or pokemon) style in 2D. To draw the maps I decided to make an RPG map editor, something easy that reads a map 500x500 of size and stores it into a file, then the file would be read from the game and so on.. anyways that's not the problem, I've been trying to make a GUI for the RPGEditor and my problem is when I have to "change screen"...
let me clarify this, I have the code that shows 3 buttons: New map, Load map, Quit.
the meaning is quite clear, anyways now I want that when the user clicks on "new map" or "load map" the whole GUI changes to get into the "map editing" phase, which would have a different GUI environment.. How exactly do I do that? It's a problem that's bugging me a lot, I don't know how to change from GUI to GUI...
Sorry if I didn't explain this quite well, it's been written hastily and later on I can provide pieces of code of what i've already done... I'm really out of ideas with this, help thanks
Help making an RPG map editor
I think the easiest way would be to create ALL of your GUI elements at the start, and then instead of creating them when clicked, just make them visible when they are needed and when they aren't.
I did that with my own games.
If you use windows check they are still there and if they are gone re-create them, on a regular basis. If someone clicks and 'x' to get rid of a window and then you try to make it visible later your app will crash.
Last I checked Irrlicht did not support multiple IGUIEnvironments.
I did that with my own games.
If you use windows check they are still there and if they are gone re-create them, on a regular basis. If someone clicks and 'x' to get rid of a window and then you try to make it visible later your app will crash.
Last I checked Irrlicht did not support multiple IGUIEnvironments.
Mmm yeah.. right after I figured it out by myself you posted it ._. lolDances wrote:I think the easiest way would be to create ALL of your GUI elements at the start, and then instead of creating them when clicked, just make them visible when they are needed and when they aren't.
I did that with my own games.
If you use windows check they are still there and if they are gone re-create them, on a regular basis. If someone clicks and 'x' to get rid of a window and then you try to make it visible later your app will crash.
Last I checked Irrlicht did not support multiple IGUIEnvironments.
anyways I'm trying to do it now but I get an error of "core segmentation fault" or something like this.. I'm using an array of IGUIElement* of all elements added to the IGUIEnvironment with an "add" function (like addButton) but I don't know what's wrong.. I have put in my event listener that if someone presses "new map" it modifies a global variable from 0 to 1 and in the drawing loop I check if that variable is 0 or 1, if it's 0 I call a procedure that sets everything else not visible and sets visible only new button, load button and quit button, if it's 1 it sets back button (the only other gui element I added to test) to visible and the other 3 buttons to non visible (I used a for that checks the whole IGUIElement* array) this is part of the code:
Code: Select all
void set_environment(IGUIEnvironment* env,IGUIElement* array[])
{
array[NEW_BUTTON-NEW_BUTTON]=env->addButton(rect<s32>(200,150,400,150 + 40), 0, NEW_BUTTON, L"New Map", L"Creates a new map/project");
array[LOAD_BUTTON-NEW_BUTTON]=env->addButton(rect<s32>(200,200,400,200 + 40), 0, LOAD_BUTTON, L"Load Map", L"Loads an existing map/project");
array[QUIT_BUTTON-NEW_BUTTON]=env->addButton(rect<s32>(200,250,400,250 + 40), 0, QUIT_BUTTON, L"Exit", L"Quits the program");
array[BACK_BUTTON-NEW_BUTTON]=env->addButton(rect<s32>(200,150,400,150 + 40), 0, BACK_BUTTON, L"Go Back", L"Goes back to the first page");
}
void draw_first_gui(IGUIElement* array[])
{
for(int i=0; i<(GUI_ELE_MAX-100);i++)
{
if(((i+101)>=NEW_BUTTON)&&((i+101)<BACK_BUTTON))
array[i+101]->setVisible(true);
else
array[i+101]->setVisible(false);
}
first_time = false;
}
void draw_second_gui(IGUIElement* array[])
{
for(int i=0; i<(GUI_ELE_MAX-100); i++)
{
if(((i+101)>=NEW_BUTTON)&&((i+101)<BACK_BUTTON))
array[i+101]->setVisible(false);
else
array[i+101]->setVisible(true);
}
first_time = false;
}
Code: Select all
while(device->run() && driver)
{
if(device->isWindowActive())
{
driver->beginScene(true,true,SColor(0,0,0,0));
if((window_type==0)&&(first_time))
draw_first_gui(gui_elements);
else if((window_type==1)&&(first_time))
draw_second_gui(gui_elements);
env->drawAll();
driver->endScene();
}
}ps: NEW_BUTTON, BACK_BUTTON and all that stuff is just an enum that starts from 101 (NEW_BUTTON) and finishes with 105 (GUI_ELE_MAX) that is just an element to count how many IGUIElements I have in the array...
EDIT:
When doing some debugging I found where the problem could be.. it's in the draw_first_gui and/or draw_second_gui function(s)... when I comment them away everything works fine...
EDITx2:
looks like there's a problem in the setVisibile function... that's exactly where the program is giving problem and the core gets "dumped"