SFML community forums

Help => Window => Topic started by: AMAGameZ on April 16, 2014, 03:44:11 am

Title: Switching between Windows
Post by: AMAGameZ on April 16, 2014, 03:44:11 am
Hello, how to describe my problem ... I have a main menu. In this main menu are 4 menu-points I can Switch with the keys. This main-menu is open by a void function. And this function works. I see the whole window. But when I use the keys to get to "Exit Game" and press enter, the objective is to close the main-menu window and open an "Exit Game menu" which shall be also fullscreen like the other windows. But how I can code it (for example) that I can close the main-menu (fullscreen) window and open the Exit-menu (fullscreen)

Actual I have 3 functions. First the int main() who show a Picture and a text then with timer it is timed that he call the next function. In the main function the second and third window was set the visible to false so they won´t get shown at the start.

In the next (void) function I put

        hauptmenue.setVisible(true); //Second fullscreen window defined in the void function
        Fenster.setVisible(false);       //First fullscreen window defined in the int main()
 

And this works! In the second I do it also but then it doesn´t work. Code is very long to put it in here but maybe you have an better idea or a syntax how to "Switch" between fullscreen windows.

Edit : Don´t know it is helping you but all three windows get rendered with RenderWindow.
        sf::RenderWindow Fenster(sf::VideoMode(800,600), "Erstes Fenster", sf::Style::Fullscreen);
        sf::RenderWindow hauptmenue(sf::VideoMode(800,600), "Hauptmenue", sf::Style::Fullscreen);
        sf::RenderWindow Fenbeenden(sf::VideoMode(800,600), "Beenden", sf::Style::Fullscreen);
 
Title: Re: Switching between Windows
Post by: Jesper Juhl on April 16, 2014, 06:54:10 am
Why bother with different windows?
Why not simply draw the new menu in the window you already have?
Title: AW: Switching between Windows
Post by: eXpl0it3r on April 16, 2014, 08:06:11 am
Yes, there's no need for multiple Windows. Just have your state switch somewhere else.

I also highly recommend to only use English variable, class and function names.
Title: Re: AW: Switching between Windows
Post by: Ixrec on April 16, 2014, 08:21:36 pm
I also highly recommend to only use English variable, class and function names.

At the risk of being off-topic: Why?  Just to make it easier for English speakers to read the code?
Title: Re: Switching between Windows
Post by: Jesper Juhl on April 16, 2014, 08:31:18 pm
IMHO it makes sense to use English throughout since the language of C++ itself is English. Makes the code more readable.
And also, English is the most common language for programs, so if you ever want to share your code it gives you the greatest possible audience.

Code like

const bool collision = collides(a, b);
If (collision) ...

Is just a lot more readable than

const bool kollision = kolliderer(a, b);
If (kollision) ...

Even to native danish speakers.

Edit: yeah, I know - not the best example. But I hope you get the point.
Title: Re: Switching between Windows
Post by: ChronicRat on April 16, 2014, 09:20:52 pm
Real existing language for bookkeeping:  ;D
Функция ПолучитьНоменклатуру()
   Запрос = Новый Запрос;
   Запрос.Текст =
      "ВЫБРАТЬ ПЕРВЫЕ 1000
      |   Номенклатура.Ссылка,
      |   Номенклатура.Код,
      |   Номенклатура.Родитель,
      |   Номенклатура.Наименование
      |ИЗ
      |   Справочник.Номенклатура КАК Номенклатура";
   Результат = Запрос.Выполнить();
   ТаблицаЗначений = Результат.Выгрузить();
   возврат ТаблицаЗначений;
КонецФункции // ПолучитьНоменклатуру()   
Title: Re: Switching between Windows
Post by: zsbzsb on April 17, 2014, 04:19:29 am
I think you made the point very clear.  :)