From ea6269c4110282a3e7c05bec9c7f17ffd1bd5191 Mon Sep 17 00:00:00 2001 From: erihel Date: Fri, 17 Aug 2012 23:03:52 +0200 Subject: * ui/key.cpp compiles * csoundinterface to ccontrol --- src/common/key.h | 1 + src/ui/control.cpp | 2 +- src/ui/control.h | 2 +- src/ui/interface.cpp | 4 ++++ src/ui/interface.h | 2 ++ src/ui/key.cpp | 11 +++++------ src/ui/key.h | 4 ++++ 7 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/common/key.h b/src/common/key.h index de31c09..1d03a47 100644 --- a/src/common/key.h +++ b/src/common/key.h @@ -29,6 +29,7 @@ // If need arises, it can be changed to custom function or anything else #define KEY(x) SDLK_ ## x + // Key modifier defined as concatenation to KMOD_... // If need arises, it can be changed to custom function or anything else #define KEY_MOD(x) KMOD_ ## x diff --git a/src/ui/control.cpp b/src/ui/control.cpp index 867958c..61fd6dd 100644 --- a/src/ui/control.cpp +++ b/src/ui/control.cpp @@ -51,7 +51,7 @@ CControl::CControl(CInstanceManager* iMan) m_event = static_cast< CEventQueue* > ( m_iMan->SearchInstance(CLASS_EVENT) ); m_main = static_cast< CRobotMain* > ( m_iMan->SearchInstance(CLASS_MAIN) ); m_particle = static_cast< Gfx::CParticle* > (m_iMan->SearchInstance(CLASS_PARTICULE)); - m_sound = static_cast< CSound* > (m_iMan->SearchInstance(CLASS_SOUND)); + m_sound = static_cast< CSoundInterface* > (m_iMan->SearchInstance(CLASS_SOUND)); m_eventType = EVENT_NULL; m_state = STATE_ENABLE|STATE_VISIBLE|STATE_GLINT; m_fontSize = Gfx::FONT_SIZE_SMALL; diff --git a/src/ui/control.h b/src/ui/control.h index ef49b65..d336ede 100644 --- a/src/ui/control.h +++ b/src/ui/control.h @@ -116,7 +116,7 @@ protected: CEventQueue* m_event; CRobotMain* m_main; Gfx::CParticle* m_particle; - CSound* m_sound; + CSoundInterface* m_sound; Math::Point m_pos; // corner upper / left Math::Point m_dim; // dimensions diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index afedfc9..0398e7f 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -20,6 +20,8 @@ #include +namespace Ui { + CInterface::CInterface() { @@ -337,3 +339,5 @@ void CInterface::Draw() m_table[i]->Draw(); } } + +} diff --git a/src/ui/interface.h b/src/ui/interface.h index d8f4d62..43f2698 100644 --- a/src/ui/interface.h +++ b/src/ui/interface.h @@ -49,6 +49,7 @@ #include #include +namespace Ui { const int MAXCONTROL = 100; @@ -100,3 +101,4 @@ class CInterface }; +} diff --git a/src/ui/key.cpp b/src/ui/key.cpp index 0d73ed0..de668bc 100644 --- a/src/ui/key.cpp +++ b/src/ui/key.cpp @@ -20,6 +20,7 @@ #include +namespace Ui { void GetKeyName(char *name, int key) { @@ -90,12 +91,9 @@ bool CKey::EventProcess(const Event &event) if (event.type == EVENT_MOUSE_BUTTON_DOWN && m_bCatch) { m_bCatch = false; - if ( TestKey(event.param) ) // impossible ? - { + if ( TestKey(event.param) ) { // impossible ? m_sound->Play(SOUND_TZOING); - } - else - { + } else { if ( event.param == m_key[0] || event.param == m_key[1] ) { m_key[0] = event.param; m_key[1] = 0; @@ -120,7 +118,7 @@ bool CKey::EventProcess(const Event &event) bool CKey::TestKey(int key) { - if ( key == VK_PAUSE || key == VK_SNAPSHOT ) return true; // blocked key + if ( key == KEY(PAUSE) || key == KEY(PRINT) ) return true; // blocked key for (int i = 0; i < 20; i++) { for (int j = 0; j < 2; j++) { @@ -237,3 +235,4 @@ int CKey::GetKey(int option) return m_key[option]; } +} diff --git a/src/ui/key.h b/src/ui/key.h index db7d856..5ca71b0 100644 --- a/src/ui/key.h +++ b/src/ui/key.h @@ -27,9 +27,11 @@ #include #include #include +#include #include +namespace Ui { class CKey : public CControl { @@ -55,3 +57,5 @@ class CKey : public CControl }; +} + -- cgit v1.2.3-1-g7c22