Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Switching between Windows  (Read 3888 times)

0 Members and 1 Guest are viewing this topic.

AMAGameZ

  • Newbie
  • *
  • Posts: 1
    • View Profile
Switching between Windows
« 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);
 
« Last Edit: April 16, 2014, 04:05:11 am by AMAGameZ »

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Switching between Windows
« Reply #1 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?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
AW: Switching between Windows
« Reply #2 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: AW: Switching between Windows
« Reply #3 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?

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Switching between Windows
« Reply #4 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.
« Last Edit: April 16, 2014, 08:41:24 pm by Jesper Juhl »

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Switching between Windows
« Reply #5 on: April 16, 2014, 09:20:52 pm »
Real existing language for bookkeeping:  ;D
Функция ПолучитьНоменклатуру()
   Запрос = Новый Запрос;
   Запрос.Текст =
      "ВЫБРАТЬ ПЕРВЫЕ 1000
      |   Номенклатура.Ссылка,
      |   Номенклатура.Код,
      |   Номенклатура.Родитель,
      |   Номенклатура.Наименование
      |ИЗ
      |   Справочник.Номенклатура КАК Номенклатура";
   Результат = Запрос.Выполнить();
   ТаблицаЗначений = Результат.Выгрузить();
   возврат ТаблицаЗначений;
КонецФункции // ПолучитьНоменклатуру()   

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Switching between Windows
« Reply #6 on: April 17, 2014, 04:19:29 am »
I think you made the point very clear.  :)
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor