[colobot] 275/377: Pause game when in background, closes #609

Didier Raboud odyx at moszumanska.debian.org
Wed Mar 30 13:34:26 UTC 2016


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch debian/master
in repository colobot.

commit a3477edc8e25f1c98a31a3f4e5c8259db2de5044
Author: krzys-h <krzys_h at interia.pl>
Date:   Sat Feb 13 21:35:01 2016 +0100

    Pause game when in background, closes #609
---
 po/colobot.pot                      | 15 ++++++++++++---
 po/de.po                            | 21 +++++++++++++++------
 po/fr.po                            | 21 +++++++++++++++------
 po/pl.po                            | 21 +++++++++++++++------
 po/ru.po                            | 21 +++++++++++++++------
 src/common/event.cpp                |  1 +
 src/common/event.h                  |  1 +
 src/common/restext.cpp              |  1 +
 src/common/settings.cpp             | 14 +++++++++++++-
 src/common/settings.h               |  4 ++++
 src/level/robotmain.cpp             | 20 ++++++++++++++++++++
 src/level/robotmain.h               |  1 +
 src/ui/screen/screen_setup_game.cpp | 16 +++++++++++++++-
 13 files changed, 128 insertions(+), 29 deletions(-)

diff --git a/po/colobot.pot b/po/colobot.pot
index cf3b4e2..4343aa2 100644
--- a/po/colobot.pot
+++ b/po/colobot.pot
@@ -286,6 +286,9 @@ msgstr ""
 msgid "Custom levels\\Levels from mods created by the users"
 msgstr ""
 
+msgid "SatCom"
+msgstr ""
+
 msgid "Change player\\Change player"
 msgstr ""
 
@@ -379,6 +382,9 @@ msgstr ""
 msgid "Quake at explosions\\The screen shakes at explosions"
 msgstr ""
 
+msgid "Pause in background\\Pause the game when the window is unfocused"
+msgstr ""
+
 msgid "Automatic indent\\When program editing"
 msgstr ""
 
@@ -509,6 +515,9 @@ msgstr ""
 msgid "Pause\\Pause the game without opening menu"
 msgstr ""
 
+msgid "Cheat console\\Show cheat console"
+msgstr ""
+
 msgid "Sound effects:\\Volume of engines, voice, shooting, etc."
 msgstr ""
 
@@ -530,13 +539,13 @@ msgstr ""
 msgid "Normal\\Normal sound volume"
 msgstr ""
 
-msgid "Use a joystick\\Joystick or keyboard"
-msgstr ""
-
 msgid ""
 "Access to solution\\Shows the solution (detailed instructions for missions)"
 msgstr ""
 
+msgid "Invert\\Invert values on this axis"
+msgstr ""
+
 msgid "\\New player name"
 msgstr ""
 
diff --git a/po/de.po b/po/de.po
index f4c84e8..3ae02cd 100644
--- a/po/de.po
+++ b/po/de.po
@@ -376,6 +376,9 @@ msgstr "Andere Kamera\\Sichtpunkt einstellen"
 msgid "Change player\\Change player"
 msgstr "Anderer Spieler\\Spielername ändern"
 
+msgid "Cheat console\\Show cheat console"
+msgstr ""
+
 msgid "Checkpoint"
 msgstr "Checkpoint"
 
@@ -751,6 +754,9 @@ msgstr "Anweisungen\\Anweisungen für die Mission oder Übung"
 msgid "Internal error - tell the developers"
 msgstr "Interner Fehler - Benachrichtige die Entwickler"
 
+msgid "Invert\\Invert values on this axis"
+msgstr ""
+
 msgid "Jet temperature"
 msgstr "Triebwerktemperatur"
 
@@ -1040,6 +1046,9 @@ msgstr "Partikel in den Menüs\\Funken und Sterne in den Menüs"
 msgid "Paste (Ctrl+v)"
 msgstr "Einfügen (Ctrl+v)"
 
+msgid "Pause in background\\Pause the game when the window is unfocused"
+msgstr ""
+
 msgid "Pause/continue"
 msgstr "Pause/Weitermachen"
 
@@ -1281,6 +1290,9 @@ msgstr "Forschungsprogramm Kettenantrieb"
 msgid "Run research program for winged bots"
 msgstr "Forschungsprogramm Jetantrieb"
 
+msgid "SatCom"
+msgstr "SatCom"
+
 msgid "Satellite report"
 msgstr "Satellitenbericht"
 
@@ -1610,9 +1622,6 @@ msgstr "Markierung für unterirdisches Platinvorkommen"
 msgid "Uranium ore"
 msgstr "Platinerz"
 
-msgid "Use a joystick\\Joystick or keyboard"
-msgstr "Joystick\\Joystick oder Tastatur"
-
 msgid "User levels"
 msgstr "Userlevels"
 
@@ -1896,9 +1905,6 @@ msgstr "www.epsitec.com"
 #~ msgid "Robbie\\Your assistant"
 #~ msgstr "Robby\\Ihr Assistent"
 
-#~ msgid "SatCom"
-#~ msgstr "SatCom"
-
 #~ msgid "Sky\\Clouds and nebulae"
 #~ msgstr "Himmel\\Himmel und Wolken"
 
@@ -1916,6 +1922,9 @@ msgstr "www.epsitec.com"
 #~ "working.\n"
 #~ msgstr "Die Liste ist ohne \\l;Radar\\u object\\radar; nicht verfügbar.\n"
 
+#~ msgid "Use a joystick\\Joystick or keyboard"
+#~ msgstr "Joystick\\Joystick oder Tastatur"
+
 #~ msgid "User\\User levels"
 #~ msgstr "User\\Userlevels"
 
diff --git a/po/fr.po b/po/fr.po
index a67ba2c..730e849 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -373,6 +373,9 @@ msgstr "Changement de caméra\\Autre de point de vue"
 msgid "Change player\\Change player"
 msgstr "Autre joueur\\Choix du nom du joueur"
 
+msgid "Cheat console\\Show cheat console"
+msgstr ""
+
 msgid "Checkpoint"
 msgstr "Indicateur"
 
@@ -745,6 +748,9 @@ msgstr "Instructions mission\\Marche à suivre"
 msgid "Internal error - tell the developers"
 msgstr "Erreur interne - contacter les développeurs"
 
+msgid "Invert\\Invert values on this axis"
+msgstr ""
+
 msgid "Jet temperature"
 msgstr "Température du réacteur"
 
@@ -1032,6 +1038,9 @@ msgstr "Particules dans l'interface\\Pluie de particules"
 msgid "Paste (Ctrl+v)"
 msgstr "Coller (Ctrl+v)"
 
+msgid "Pause in background\\Pause the game when the window is unfocused"
+msgstr ""
+
 msgid "Pause/continue"
 msgstr "Pause/continuer"
 
@@ -1269,6 +1278,9 @@ msgstr "Recherche les chenilles"
 msgid "Run research program for winged bots"
 msgstr "Recherche les robots volants"
 
+msgid "SatCom"
+msgstr "SatCom"
+
 msgid "Satellite report"
 msgstr "Rapport du satellite"
 
@@ -1596,9 +1608,6 @@ msgstr "Emplacement pour derrick (uranium)"
 msgid "Uranium ore"
 msgstr "Minerai d'uranium"
 
-msgid "Use a joystick\\Joystick or keyboard"
-msgstr "Utilise un joystick\\Joystick ou clavier"
-
 msgid "User levels"
 msgstr "Niveaux supplémentaires"
 
@@ -1883,9 +1892,6 @@ msgstr "www.epsitec.com"
 #~ msgid "Robbie\\Your assistant"
 #~ msgstr "Robbie\\Votre assistant"
 
-#~ msgid "SatCom"
-#~ msgstr "SatCom"
-
 #~ msgid "Sky\\Clouds and nebulae"
 #~ msgstr "Ciel\\Ciel et nuages"
 
@@ -1906,6 +1912,9 @@ msgstr "www.epsitec.com"
 #~ "working.\n"
 #~ msgstr "Liste non disponible sans \\l;radar\\u object\\radar;.\n"
 
+#~ msgid "Use a joystick\\Joystick or keyboard"
+#~ msgstr "Utilise un joystick\\Joystick ou clavier"
+
 #~ msgid "User\\User levels"
 #~ msgstr "Suppl.\\Niveaux supplémentaires"
 
diff --git a/po/pl.po b/po/pl.po
index 8bf211a..a54a297 100644
--- a/po/pl.po
+++ b/po/pl.po
@@ -379,6 +379,9 @@ msgstr "Zmień kamerę\\Przełącza pomiędzy kamerą pokładową i śledzącą"
 msgid "Change player\\Change player"
 msgstr "Zmień gracza\\Zmień gracza"
 
+msgid "Cheat console\\Show cheat console"
+msgstr ""
+
 msgid "Checkpoint"
 msgstr "Punkt kontrolny"
 
@@ -752,6 +755,9 @@ msgstr "Rozkazy\\Pokazuje rozkazy dotyczące bieżącej misji"
 msgid "Internal error - tell the developers"
 msgstr "Błąd wewnętrzny - powiadom twórców gry"
 
+msgid "Invert\\Invert values on this axis"
+msgstr ""
+
 msgid "Jet temperature"
 msgstr "Temperatura silnika"
 
@@ -1039,6 +1045,9 @@ msgstr "Cząstki w interfejsie\\Para i iskry z silników w interfejsie"
 msgid "Paste (Ctrl+v)"
 msgstr "Wklej (Ctrl+V)"
 
+msgid "Pause in background\\Pause the game when the window is unfocused"
+msgstr ""
+
 msgid "Pause/continue"
 msgstr "Pauza/Kontynuuj"
 
@@ -1277,6 +1286,9 @@ msgstr "Rozpocznij prace badawcze nad transporterem na gąsienicach"
 msgid "Run research program for winged bots"
 msgstr "Rozpocznij prace badawcze nad transporterem latającym"
 
+msgid "SatCom"
+msgstr "SatCom"
+
 msgid "Satellite report"
 msgstr "Raport z satelity"
 
@@ -1601,9 +1613,6 @@ msgstr "Złoże uranu (miejsce na kopalnię)"
 msgid "Uranium ore"
 msgstr "Ruda uranu"
 
-msgid "Use a joystick\\Joystick or keyboard"
-msgstr "Używaj joysticka\\Joystick lub klawiatura"
-
 msgid "User levels"
 msgstr "Poziomy użytkownika"
 
@@ -1876,9 +1885,6 @@ msgstr "www.epsitec.com"
 #~ msgid "Robbie\\Your assistant"
 #~ msgstr "Robbie\\Twój asystent"
 
-#~ msgid "SatCom"
-#~ msgstr "SatCom"
-
 #~ msgid "Sky\\Clouds and nebulae"
 #~ msgstr "Niebo\\Chmury i mgławice"
 
@@ -1898,6 +1904,9 @@ msgstr "www.epsitec.com"
 #~ "Lista jest dostępna jedynie gdy działa \\l;stacja radarowa\\u object"
 #~ "\\radar;.\n"
 
+#~ msgid "Use a joystick\\Joystick or keyboard"
+#~ msgstr "Używaj joysticka\\Joystick lub klawiatura"
+
 #~ msgid "\\b;Aliens\n"
 #~ msgstr "\\b;Obcy\n"
 
diff --git a/po/ru.po b/po/ru.po
index 189963e..1febf45 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -371,6 +371,9 @@ msgstr "Изменить вид\\Переключение между борто
 msgid "Change player\\Change player"
 msgstr "Новый игрок\\Выберите имя для игрока"
 
+msgid "Cheat console\\Show cheat console"
+msgstr ""
+
 msgid "Checkpoint"
 msgstr "Контрольная точка"
 
@@ -744,6 +747,9 @@ msgstr "Инструкции\\Показывает инструкции по т
 msgid "Internal error - tell the developers"
 msgstr ""
 
+msgid "Invert\\Invert values on this axis"
+msgstr ""
+
 msgid "Jet temperature"
 msgstr "Температура реактивного двигателя"
 
@@ -1035,6 +1041,9 @@ msgstr "Частицы в интерфейсе меню\\Пар из труб и
 msgid "Paste (Ctrl+v)"
 msgstr "Вставить (Ctrl+V)"
 
+msgid "Pause in background\\Pause the game when the window is unfocused"
+msgstr ""
+
 msgid "Pause/continue"
 msgstr "Пауза/продолжить"
 
@@ -1276,6 +1285,9 @@ msgstr "Начать исследование программы для гусе
 msgid "Run research program for winged bots"
 msgstr "Начать исследование программы для летающего бота"
 
+msgid "SatCom"
+msgstr "SatCom"
+
 msgid "Satellite report"
 msgstr "Спутниковый отчет"
 
@@ -1601,9 +1613,6 @@ msgstr "Запасы урана (место для буровой вышки)"
 msgid "Uranium ore"
 msgstr "Урановая руда"
 
-msgid "Use a joystick\\Joystick or keyboard"
-msgstr "Использовать джойстик\\Джойстик или клавиатура"
-
 msgid "User levels"
 msgstr "Пользовательские уровни"
 
@@ -1887,9 +1896,6 @@ msgstr "www.epsitec.com"
 #~ msgid "Robbie\\Your assistant"
 #~ msgstr "Робби\\Ваш помощник"
 
-#~ msgid "SatCom"
-#~ msgstr "SatCom"
-
 #~ msgid "Sky\\Clouds and nebulae"
 #~ msgstr "Небо\\Облака и туманности"
 
@@ -1908,6 +1914,9 @@ msgstr "www.epsitec.com"
 #~ msgstr ""
 #~ "Список доступен только если \\l;radar station\\u object\\radar; работают\n"
 
+#~ msgid "Use a joystick\\Joystick or keyboard"
+#~ msgstr "Использовать джойстик\\Джойстик или клавиатура"
+
 #~ msgid "User\\User levels"
 #~ msgstr "Польз.\\Пользовательские уровни"
 
diff --git a/src/common/event.cpp b/src/common/event.cpp
index 81d50c1..ccd7fe8 100644
--- a/src/common/event.cpp
+++ b/src/common/event.cpp
@@ -212,6 +212,7 @@ void InitializeEventTypeTexts()
     EVENT_TYPE_TEXT[EVENT_INTERFACE_INVERTX] = "EVENT_INTERFACE_INVERTX";
     EVENT_TYPE_TEXT[EVENT_INTERFACE_INVERTY] = "EVENT_INTERFACE_INVERTY";
     EVENT_TYPE_TEXT[EVENT_INTERFACE_EFFECT]  = "EVENT_INTERFACE_EFFECT";
+    EVENT_TYPE_TEXT[EVENT_INTERFACE_BGPAUSE] = "EVENT_INTERFACE_BGPAUSE";
     EVENT_TYPE_TEXT[EVENT_INTERFACE_FOG]     = "EVENT_INTERFACE_FOG";
     EVENT_TYPE_TEXT[EVENT_INTERFACE_EDITMODE]= "EVENT_INTERFACE_EDITMODE";
     EVENT_TYPE_TEXT[EVENT_INTERFACE_EDITVALUE]= "EVENT_INTERFACE_EDITVALUE";
diff --git a/src/common/event.h b/src/common/event.h
index d314e18..362fb09 100644
--- a/src/common/event.h
+++ b/src/common/event.h
@@ -241,6 +241,7 @@ enum EventType
     EVENT_INTERFACE_INVERTX = 468,
     EVENT_INTERFACE_INVERTY = 469,
     EVENT_INTERFACE_EFFECT  = 470,
+    EVENT_INTERFACE_BGPAUSE = 471,
     EVENT_INTERFACE_FOG     = 474,
     EVENT_INTERFACE_EDITMODE= 476,
     EVENT_INTERFACE_EDITVALUE= 477,
diff --git a/src/common/restext.cpp b/src/common/restext.cpp
index 0243e92..18e7861 100644
--- a/src/common/restext.cpp
+++ b/src/common/restext.cpp
@@ -194,6 +194,7 @@ void InitializeRestext()
     stringsEvent[EVENT_INTERFACE_INVERTX]   = TR("Mouse inversion X\\Inversion of the scrolling direction on the X axis");
     stringsEvent[EVENT_INTERFACE_INVERTY]   = TR("Mouse inversion Y\\Inversion of the scrolling direction on the Y axis");
     stringsEvent[EVENT_INTERFACE_EFFECT]    = TR("Quake at explosions\\The screen shakes at explosions");
+    stringsEvent[EVENT_INTERFACE_BGPAUSE]   = TR("Pause in background\\Pause the game when the window is unfocused");
     stringsEvent[EVENT_INTERFACE_EDITMODE]  = TR("Automatic indent\\When program editing");
     stringsEvent[EVENT_INTERFACE_EDITVALUE] = TR("Big indent\\Indent 2 or 4 spaces per level defined by braces");
     stringsEvent[EVENT_INTERFACE_SOLUCE4]   = TR("Access to solutions\\Show program \"4: Solution\" in the exercises");
diff --git a/src/common/settings.cpp b/src/common/settings.cpp
index 2644345..9cfebed 100644
--- a/src/common/settings.cpp
+++ b/src/common/settings.cpp
@@ -41,6 +41,7 @@ CSettings::CSettings()
     m_interfaceRain  = true;
     m_soluce4        = true;
     m_movies         = true;
+    m_focusLostPause = true;
 
     m_fontSize  = 19.0f;
     m_windowPos = Math::Point(0.15f, 0.17f);
@@ -78,6 +79,7 @@ void CSettings::SaveSettings()
     GetConfigFile().SetBoolProperty("Setup", "InterfaceRain", m_interfaceRain);
     GetConfigFile().SetBoolProperty("Setup", "Soluce4", m_soluce4);
     GetConfigFile().SetBoolProperty("Setup", "Movies", m_movies);
+    GetConfigFile().SetBoolProperty("Setup", "FocusLostPause", m_focusLostPause);
     GetConfigFile().SetBoolProperty("Setup", "CameraScroll", camera->GetCameraScroll());
     GetConfigFile().SetBoolProperty("Setup", "CameraInvertX", camera->GetCameraInvertX());
     GetConfigFile().SetBoolProperty("Setup", "CameraInvertY", camera->GetCameraInvertY());
@@ -148,6 +150,7 @@ void CSettings::LoadSettings()
     GetConfigFile().GetBoolProperty("Setup", "InterfaceRain", m_interfaceRain);
     GetConfigFile().GetBoolProperty("Setup", "Soluce4", m_soluce4);
     GetConfigFile().GetBoolProperty("Setup", "Movies", m_movies);
+    GetConfigFile().GetBoolProperty("Setup", "FocusLostPause", m_focusLostPause);
 
     if (GetConfigFile().GetBoolProperty("Setup", "CameraScroll", bValue))
         camera->SetCameraScroll(bValue);
@@ -334,6 +337,15 @@ bool CSettings::GetMovies()
     return m_movies;
 }
 
+void CSettings::SetFocusLostPause(bool focusLostPause)
+{
+    m_focusLostPause = focusLostPause;
+}
+bool CSettings::GetFocusLostPause()
+{
+    return m_focusLostPause;
+}
+
 
 void CSettings::SetFontSize(float size)
 {
@@ -420,4 +432,4 @@ void CSettings::SetLanguage(Language language)
 Language CSettings::GetLanguage()
 {
     return m_language;
-}
+}
\ No newline at end of file
diff --git a/src/common/settings.h b/src/common/settings.h
index e4f956a..4e9b762 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -53,6 +53,9 @@ public:
     void SetMovies(bool movies);
     bool GetMovies();
 
+    void SetFocusLostPause(bool focusLostPause);
+    bool GetFocusLostPause();
+
 
     //! Managing the size of the default fonts
     //@{
@@ -90,6 +93,7 @@ protected:
     bool m_interfaceRain;
     bool m_soluce4;
     bool m_movies;
+    bool m_focusLostPause;
 
     float           m_fontSize;
     Math::Point     m_windowPos;
diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp
index 259ac61..c7d3b1a 100644
--- a/src/level/robotmain.cpp
+++ b/src/level/robotmain.cpp
@@ -695,6 +695,26 @@ bool CRobotMain::ProcessEvent(Event &event)
         return EventFrame(event);
     }
 
+    if (event.type == EVENT_FOCUS_LOST)
+    {
+        GetLogger()->Trace("Window unfocused\n");
+        if (m_settings->GetFocusLostPause())
+        {
+            m_focusPause = m_pause->ActivatePause(PAUSE_ENGINE);
+        }
+        return false;
+    }
+
+    if (event.type == EVENT_FOCUS_GAINED)
+    {
+        GetLogger()->Trace("Window focused\n");
+        if (m_focusPause != nullptr)
+        {
+            m_pause->DeactivatePause(m_focusPause);
+        }
+        return false;
+    }
+
     if (event.type == EVENT_WRITE_SCENE_FINISHED)
     {
         IOWriteSceneFinished();
diff --git a/src/level/robotmain.h b/src/level/robotmain.h
index 8d960ee..ee87028 100644
--- a/src/level/robotmain.h
+++ b/src/level/robotmain.h
@@ -460,6 +460,7 @@ protected:
 
     Phase           m_phase = PHASE_WELCOME1;
     ActivePause*    m_userPause = nullptr;
+    ActivePause*    m_focusPause = nullptr;
     ActivePause*    m_freePhotoPause = nullptr;
     bool            m_cmdEdit = false;
     ActivePause*    m_cmdEditPause = nullptr;
diff --git a/src/ui/screen/screen_setup_game.cpp b/src/ui/screen/screen_setup_game.cpp
index 8ebd85c..0479c2d 100644
--- a/src/ui/screen/screen_setup_game.cpp
+++ b/src/ui/screen/screen_setup_game.cpp
@@ -123,6 +123,9 @@ void CScreenSetupGame::CreateInterface()
     pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_RAIN);
     pc->SetState(STATE_SHADOW);
     pos.y -= 0.048f;
+    pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_BGPAUSE);
+    pc->SetState(STATE_SHADOW);
+    pos.y -= 0.048f;
     pos.y -= 0.048f;
     pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_EDITMODE);
     pc->SetState(STATE_SHADOW);
@@ -133,7 +136,6 @@ void CScreenSetupGame::CreateInterface()
     pos.y -= 0.048f;
     pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_EDITVALUE);
     pc->SetState(STATE_SHADOW);
-    pos.y -= 0.048f;
 
     ddim.y = dim.y*3.0f;
     pos.y -= ddim.y;
@@ -174,6 +176,12 @@ bool CScreenSetupGame::EventProcess(const Event &event)
             UpdateSetupButtons();
             break;
 
+        case EVENT_INTERFACE_BGPAUSE:
+            m_settings->SetFocusLostPause(!m_settings->GetFocusLostPause());
+            ChangeSetupButtons();
+            UpdateSetupButtons();
+            break;
+
         case EVENT_INTERFACE_EDITMODE:
             m_engine->SetEditIndentMode(!m_engine->GetEditIndentMode());
             ChangeSetupButtons();
@@ -284,6 +292,12 @@ void CScreenSetupGame::UpdateSetupButtons()
         pc->SetState(STATE_CHECK, m_settings->GetInterfaceRain());
     }
 
+    pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_BGPAUSE));
+    if ( pc != nullptr )
+    {
+        pc->SetState(STATE_CHECK, m_settings->GetFocusLostPause());
+    }
+
     pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_EDITMODE));
     if ( pc != nullptr )
     {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git



More information about the Pkg-games-commits mailing list