diff options
author | krzys-h <krzys_h@interia.pl> | 2013-05-02 18:07:20 +0200 |
---|---|---|
committer | krzys-h <krzys_h@interia.pl> | 2013-05-02 19:17:17 +0200 |
commit | 02b65fecd3e99df5ef4fcd953795d06b616bf035 (patch) | |
tree | 8a0c8edd94ed2df92ca3a6d169465ba7e843b31e | |
parent | 8a1e4b1e5f9a321aaa10b120881c52706c48c68a (diff) | |
download | colobot-02b65fecd3e99df5ef4fcd953795d06b616bf035.tar.gz colobot-02b65fecd3e99df5ef4fcd953795d06b616bf035.tar.bz2 colobot-02b65fecd3e99df5ef4fcd953795d06b616bf035.zip |
Fixed Destroyer button
* Commands were executed for all Destroyers on map
* Button can't be clicked when Destroyer is working
-rw-r--r-- | src/object/auto/autodestroyer.cpp | 38 | ||||
-rw-r--r-- | src/object/robotmain.h | 3 |
2 files changed, 23 insertions, 18 deletions
diff --git a/src/object/auto/autodestroyer.cpp b/src/object/auto/autodestroyer.cpp index 2d64fb1..e33c317 100644 --- a/src/object/auto/autodestroyer.cpp +++ b/src/object/auto/autodestroyer.cpp @@ -82,23 +82,26 @@ bool CAutoDestroyer::EventProcess(const Event &event) if ( m_engine->GetPause() ) return true; - if ( event.type == EVENT_OBJECT_BDESTROY ) + if (m_main->GetSelect() == m_object) { - if ( m_object->GetVirusMode() ) // contaminated by a virus? + if ( event.type == EVENT_OBJECT_BDESTROY ) { - return true; // Don't do anything. TODO: Error? - } + if ( m_object->GetVirusMode() ) // contaminated by a virus? + { + return true; // Don't do anything. TODO: Error? + } - scrap = SearchPlastic(); - scrap->SetLock(true); // usable waste -//? scrap->SetTruck(m_object); // usable waste + scrap = SearchPlastic(); + scrap->SetLock(true); // usable waste +//? scrap->SetTruck(m_object); // usable waste - m_sound->Play(SOUND_PSHHH2, m_object->GetPosition(0), 1.0f, 1.0f); + m_sound->Play(SOUND_PSHHH2, m_object->GetPosition(0), 1.0f, 1.0f); - m_phase = ADEP_DOWN; - m_progress = 0.0f; - m_speed = 1.0f/1.0f; - m_bExplo = false; + m_phase = ADEP_DOWN; + m_progress = 0.0f; + m_speed = 1.0f/1.0f; + m_bExplo = false; + } } if ( event.type != EVENT_FRAME ) return true; @@ -115,6 +118,7 @@ bool CAutoDestroyer::EventProcess(const Event &event) return true; } + pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0)); if ( m_phase == ADEP_WAIT ) { if ( m_progress >= 1.0f ) @@ -122,12 +126,12 @@ bool CAutoDestroyer::EventProcess(const Event &event) m_phase = ADEP_WAIT; // still waiting ... m_progress = 0.0f; m_speed = 1.0f/0.5f; - scrap = SearchPlastic(); - pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0)); - if ( pw == 0 ) return true; - EnableInterface(pw, EVENT_OBJECT_BDESTROY, (scrap != 0)); + if (m_main->GetSelect() == m_object) { + scrap = SearchPlastic(); + if ( pw != 0 ) EnableInterface(pw, EVENT_OBJECT_BDESTROY, (scrap != 0)); + } } - } + } else if ( pw != 0 ) EnableInterface(pw, EVENT_OBJECT_BDESTROY, false); if ( m_phase == ADEP_DOWN ) { diff --git a/src/object/robotmain.h b/src/object/robotmain.h index 6c331ab..adabf64 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -374,6 +374,8 @@ public: void SetNumericLocale(); void RestoreNumericLocale(); + CObject* GetSelect(); + protected: bool EventFrame(const Event &event); bool EventObject(const Event &event); @@ -404,7 +406,6 @@ protected: void DeleteAllObjects(); void UpdateInfoText(); CObject* SearchObject(ObjectType type); - CObject* GetSelect(); void StartDisplayVisit(EventType event); void FrameVisit(float rTime); void StopDisplayVisit(); |