[colobot] 293/390: Implemented shortcuts for starting programs (#391)

Didier Raboud odyx at moszumanska.debian.org
Fri Jun 12 14:21:56 UTC 2015


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

odyx pushed a commit to branch upstream/latest
in repository colobot.

commit 23c734c3c15752cc9da5d2e768a98a7fff452e8e
Author: krzys-h <krzys_h at interia.pl>
Date:   Sun Mar 22 15:49:33 2015 +0100

    Implemented shortcuts for starting programs (#391)
---
 src/object/brain.cpp | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/object/brain.h   |  1 +
 src/ui/studio.cpp    | 11 ---------
 3 files changed, 66 insertions(+), 11 deletions(-)

diff --git a/src/object/brain.cpp b/src/object/brain.cpp
index 169e3c5..31cbee2 100644
--- a/src/object/brain.cpp
+++ b/src/object/brain.cpp
@@ -247,6 +247,54 @@ bool CBrain::EventProcess(const Event &event)
         action = event.type;
     }
 
+    if(event.type == EVENT_KEY_DOWN && m_object->GetSelect())
+    {
+        bool bControl = (event.kmodState & KEY_MOD(CTRL)) != 0;
+        bool bAlt = (event.kmodState & KEY_MOD(ALT)) != 0;
+        CEventQueue* queue = CApplication::GetInstancePointer()->GetEventQueue();
+
+        if(event.key.slot == INPUT_SLOT_ACTION && bControl)
+        {
+            Event newEvent = event;
+            newEvent.type = (m_studio == nullptr ? EVENT_OBJECT_PROGEDIT : EVENT_STUDIO_OK);
+            queue->AddEvent(newEvent);
+            return false;
+        }
+
+        if(event.key.slot == INPUT_SLOT_ACTION && bAlt)
+        {
+            Event newEvent = event;
+            newEvent.type = EVENT_OBJECT_PROGRUN;
+            queue->AddEvent(newEvent);
+            return false;
+        }
+
+        if(bAlt)
+        {
+            int index = GetSelScript();
+            if(event.key.slot == INPUT_SLOT_UP)
+                index--;
+            else if(event.key.slot == INPUT_SLOT_DOWN)
+                index++;
+            else if(event.key.key >= KEY(1) && event.key.key <= KEY(9))
+                index = event.key.key-KEY(1);
+            else if(event.key.key == KEY(0))
+                index = 9;
+            if(index < 0) index = 9;
+            if(index > 9) index = 0;
+
+            if(GetSelScript() != index)
+            {
+                SetSelScript(index);
+
+                Event newEvent = event;
+                newEvent.type = EVENT_OBJECT_PROGLIST;
+                queue->AddEvent(newEvent);
+                return false;
+            }
+        }
+    }
+
     if ( action == EVENT_NULL )  return true;
 
     if ( action == EVENT_UPDINTERFACE )
@@ -2463,6 +2511,23 @@ int CBrain::GetSelScript()
     return pl->GetSelect();
 }
 
+// Changes selected script
+
+void CBrain::SetSelScript(int index)
+{
+    Ui::CWindow*    pw;
+    Ui::CList*      pl;
+
+    pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
+    if ( pw == 0 )  return;
+
+    pl = static_cast< Ui::CList* >(pw->SearchControl(EVENT_OBJECT_PROGLIST));
+    if ( pl == 0 )  return;
+
+    pl->SetSelect(index);
+    pl->ShowSelect(true);
+}
+
 // Blinks the running program.
 
 void CBrain::BlinkScript(bool bEnable)
diff --git a/src/object/brain.h b/src/object/brain.h
index a67a1ef..b62f826 100644
--- a/src/object/brain.h
+++ b/src/object/brain.h
@@ -159,6 +159,7 @@ protected:
 
     void        UpdateScript(Ui::CWindow *pw);
     int         GetSelScript();
+    void        SetSelScript(int index);
     void        BlinkScript(bool bEnable);
 
     void        CheckInterface(Ui::CWindow *pw, EventType event, bool bState);
diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp
index 11fb62f..c1c4971 100644
--- a/src/ui/studio.cpp
+++ b/src/ui/studio.cpp
@@ -125,17 +125,6 @@ bool CStudio::EventProcess(const Event &event)
         newEvent.type = EVENT_STUDIO_OK;
         m_event->AddEvent(newEvent);
     }
-    
-    if ( event.type == EVENT_KEY_DOWN )
-    {
-        if ( event.key.slot == INPUT_SLOT_ACTION &&
-             (event.kmodState & KEY_MOD(CTRL)) != 0 )
-        {
-            Event newEvent = event;
-            newEvent.type = EVENT_STUDIO_OK;
-            m_event->AddEvent(newEvent);
-        }
-    }
 
     if ( event.type == EVENT_STUDIO_EDIT )  // text modifief?
     {

-- 
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