BVB Source Codes

CRYENGINE Show FlashUIEventSystem.cpp Source code

Return Download CRYENGINE: download FlashUIEventSystem.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  File name:   FlashUIEventSystem.cpp
  5. //  Version:     v1.00
  6. //  Created:     10/9/2010 by Paul Reindell.
  7. //  Description:
  8. // -------------------------------------------------------------------------
  9. //  History:
  10. //
  11. ////////////////////////////////////////////////////////////////////////////
  12. #include "StdAfx.h"
  13. #include "FlashUIEventSystem.h"
  14. #include <CryGame/IGameFramework.h>
  15. #include "FlashUI.h"
  16.  
  17. //------------------------------------------------------------------------------------
  18. CFlashUIEventSystem::~CFlashUIEventSystem()
  19. {
  20.         for (TEventListener::Notifier notifier(m_listener); notifier.IsValid(); notifier.Next())
  21.                 notifier->OnEventSystemDestroyed(this);
  22.  
  23.         for (TUIEventsLookup::const_iterator iter = m_eventDescriptions.begin(); iter != m_eventDescriptions.end(); ++iter)
  24.                 delete *iter;
  25. }
  26.  
  27. //------------------------------------------------------------------------------------
  28. uint CFlashUIEventSystem::RegisterEvent(const SUIEventDesc& sEventDesc)
  29. {
  30.         m_eventDescriptions.push_back(new SUIEventDesc(sEventDesc));
  31.         return (uint) m_eventDescriptions.size() - 1;
  32. }
  33.  
  34. //------------------------------------------------------------------------------------
  35. void CFlashUIEventSystem::RegisterListener(IUIEventListener* pListener, const char* name)
  36. {
  37.         const bool ok = m_listener.Add(pListener, name);
  38.         CRY_ASSERT_MESSAGE(ok, "Listener already registered!");
  39. }
  40.  
  41. //------------------------------------------------------------------------------------
  42. void CFlashUIEventSystem::UnregisterListener(IUIEventListener* pListener)
  43. {
  44.         CRY_ASSERT_MESSAGE(m_listener.Contains(pListener), "Listener was never registered or already unregistered!");
  45.         m_listener.Remove(pListener);
  46. }
  47.  
  48. //------------------------------------------------------------------------------------
  49. SUIArgumentsRet CFlashUIEventSystem::SendEvent(const SUIEvent& event)
  50. {
  51.         FUNCTION_PROFILER(GetISystem(), PROFILE_ACTION);
  52.  
  53.         SUIArguments ret;
  54.         if (gEnv->IsEditor())
  55.         {
  56.                 if (GetType() == eEST_UI_TO_SYSTEM && !CFlashUI::CV_gfx_uievents_editorenabled)
  57.                 {
  58.                         const SUIEventDesc* pEventDesc = GetEventDesc(event.event);
  59.                         UIACTION_WARNING("%s (UI->System): Event sent \"%s\" BUT NOT DISPATCHED! (args: %s)", GetName(), pEventDesc ? pEventDesc->sDisplayName : "<UNDEFINED EVENT>", event.args.GetAsString());
  60.                         return ret;
  61.                 }
  62.         }
  63.  
  64. #if defined (UIACTION_LOGGING)
  65.         {
  66.                 const char* evtSysType = GetType() == eEST_UI_TO_SYSTEM ? "UI->System" : "System->UI";
  67.                 const SUIEventDesc* pEventDesc = GetEventDesc(event.event);
  68.                 UIACTION_LOG("%s (%s): Event sent \"%s\" (args: %s)", GetName(), evtSysType, pEventDesc ? pEventDesc->sDisplayName : "<UNDEFINED EVENT>", event.args.GetAsString());
  69.         }
  70. #endif
  71.  
  72.         for (TEventListener::Notifier notifier(m_listener); notifier.IsValid(); notifier.Next())
  73.                 ret.AddArguments(notifier->OnEvent(event));
  74.         return ret;
  75. }
  76.  
  77. //------------------------------------------------------------------------------------
  78. uint CFlashUIEventSystem::GetEventId(const char* sEventName)
  79. {
  80.         uint res = 0;
  81.         for (TUIEventsLookup::const_iterator iter = m_eventDescriptions.begin(); iter != m_eventDescriptions.end(); ++iter)
  82.         {
  83.                 if (strcmp((*iter)->sName, sEventName) == 0)
  84.                         return res;
  85.                 ++res;
  86.         }
  87.         return ~0;
  88. }
  89.  
  90. //-------------------------------------------------------------------
  91. void CFlashUIEventSystem::GetMemoryUsage(ICrySizer* s) const
  92. {
  93.         SIZER_SUBCOMPONENT_NAME(s, "FlashUIEventSystem");
  94.         //s->AddObject(this, sizeof(*this)); // collected by owner (AddContainer)
  95.         s->AddContainer(m_eventDescriptions);
  96.         s->AddObject(&m_listener, m_listener.MemSize());
  97. }
  98.  
  99. //------------------------------------------------------------------------------------
  100. CUIEventSystemIterator::CUIEventSystemIterator(TUIEventSystemMap* pMap)
  101. {
  102.         m_iRefs = 1;
  103.         m_currIter = pMap->begin();
  104.         m_endIter = pMap->end();
  105. }
  106.  
  107. //------------------------------------------------------------------------------------
  108. void CUIEventSystemIterator::AddRef()
  109. {
  110.         m_iRefs++;
  111. }
  112.  
  113. //------------------------------------------------------------------------------------
  114. void CUIEventSystemIterator::Release()
  115. {
  116.         if (--m_iRefs == 0)
  117.                 delete this;
  118. }
  119.  
  120. //------------------------------------------------------------------------------------
  121. IUIEventSystem* CUIEventSystemIterator::Next(string& sName)
  122. {
  123.         IUIEventSystem* pNext = NULL;
  124.         if (m_currIter != m_endIter)
  125.         {
  126.                 sName = m_currIter->first;
  127.                 pNext = m_currIter->second;
  128.                 ++m_currIter;
  129.         }
  130.         return pNext;
  131. }
  132.  
  133. //------------------------------------------------------------------------------------
  134.  
downloadFlashUIEventSystem.cpp Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top