FIFE forums

Please login or register.

Login with username, password and session length
Advanced search  

News:

FIFE 0.4.0 has been released on 15th of January, 2017!

Author Topic: change main screen size during game  (Read 2700 times)

noobpeek

  • Newbie
  • Posts: 15
    • View Profile
change main screen size during game
« on: June 12, 2010, 03:39:45 am »

hi,

does anyone know if it is possible to change the main screen size during a game? the game i am trying to make has a toolbar pane that should be "collapsable". i.e. when a button is clicked, the screenwidth will become smaller and that pane will disappear, leaving only the map.

i could redraw the map properly during the resize, but when i try to redraw the GUI elements - the containers, label and buttons, they become out of proportion.

any clues anyone?

thanks!
Logged

rivon

  • Newbie
  • Posts: 26
    • View Profile
Re: change main screen size during game
« Reply #1 on: June 12, 2010, 05:42:13 am »

I think the easiest solution would be to draw the map on the whole screen and draw the toolbar on top of it. Just like in the FIFEdit ;)
Logged

noobpeek

  • Newbie
  • Posts: 15
    • View Profile
Re: change main screen size during game
« Reply #2 on: June 12, 2010, 09:27:09 pm »

haha... yes.. that's a good idea! but the game that i am programming requires collapsable toolbar. it's more of a functionality device then a design one...

in fact it requires the other way too, a collapsable map - leaving only the toolbar. and now I have problems redrawing the map too.

the map becomes white, even though i reloaded the map and everything..  :(

anybody have any ideas?

Also, is it possible for FIFE to open up new windows? I mean real windows. Not those layered boxes shown in the Pychan Demo, that cannot move out of the space of the main screen.

Thanks in advance!
Logged

prock

  • Developer
  • Full Member
  • *
  • Posts: 236
    • View Profile
Re: change main screen size during game
« Reply #3 on: June 14, 2010, 09:45:00 am »

Hi noobpeek,

I'm not sure about your problem with drawing the map.   Can you perhaps post some code along with screenshots so we can see what is happening?

As far as a new window yes FIFE can do that..  Just use the <Window> </Window> tag in the xml file.
Logged

noobpeek

  • Newbie
  • Posts: 15
    • View Profile
Re: change main screen size during game
« Reply #4 on: June 15, 2010, 10:42:23 am »

Dear prock,

Thanks for the tip about the <Window>! I will go look into that!

As for the redrawing of the map, actually I am working with the C++ version of FIFE engine. Compiling C++ as a dll. I used the RenderBackend class createMainScreen function to change the size of the screen.

Code: [Select]
                FIFE::EngineSettings& settings = m_engine->getSettings();
                settings.setScreenWidth(newScreenWidth);
m_engine->getRenderBackend()->createMainScreen(
settings.getScreenWidth(),
settings.getScreenHeight(),
static_cast<unsigned char>(settings.getBitsPerPixel()),
settings.isFullScreen(),
settings.getWindowTitle(),
settings.getWindowIcon());

Now I have did the program in such a way that it has 2 modes.
1) Simple mode - just toolbar
2) Full mode - toolbar and map
(There should be a third mode in the future with just the map, but i'll just get this right first!)

The program starts of with simple mode, only toolbar with widgets drawn with GUIManager. Not a problem.

When the user clicks a button, the program goes to Full mode, and the map is drawn with the toolbar at the side. Not a problem too. I solved the garbled GUI problem by reinitializing the GUIManager's graphic.

Code: [Select]
settings.setScreenWidth(newScreenWidth);
m_engine->getRenderBackend()->createMainScreen(
settings.getScreenWidth(),
settings.getScreenHeight(),
static_cast<unsigned char>(settings.getBitsPerPixel()),
settings.isFullScreen(),
settings.getWindowTitle(),
settings.getWindowIcon());

#ifdef HAVE_OPENGL
if( settings.getRenderBackend() != "SDL" ) {
m_gui_graphics = new FIFE::OpenGLGuiGraphics(*m_imagepool);
}
#endif
if( settings.getRenderBackend()== "SDL" ) {
m_gui_graphics = new FIFE::SdlGuiGraphics(*m_imagepool);
}

gm->getGuichanGUI()->setGraphics(m_gui_graphics);

The user can click the button again to toggle it back to simple mode. The above code is also used to refresh the GUI graphics to get the toolbar looking right in the new screen size.

The next time the user toggles it back to full mode, the GUI is still right. But this time when the map is redrawn, it is just a white screen (refer to attachment).

 :-[

Thanks!
Logged

vtchill

  • Developer
  • Full Member
  • *
  • Posts: 206
    • View Profile
Re: change main screen size during game
« Reply #5 on: June 16, 2010, 08:42:08 am »

Not exactly sure why the white screen is appearing.

Are you calling createMainScreen each time you need to redraw the map?

And I assume you are removing the current map when the user clicks the simple mode and then reloading the map when the user goes to full mode?

It may be easier to simply draw a plain screen such as a black screen over the map area when the user goes to simple mode to avoid having to reload the map and lose all map information. Then when the user goes to the full mode just remove the top layer you drew to hide the map.
Logged