BVB Source Codes

CRYENGINE Show SubtitleManager.cpp Source code

Return Download CRYENGINE: download SubtitleManager.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:   SubtitleManager.cpp
  5. //  Version:     v1.00
  6. //  Created:     29/01/2007 by AlexL.
  7. //  Compilers:   Visual Studio.NET 2005
  8. //  Description: Subtitle Manager Implementation
  9. // -------------------------------------------------------------------------
  10. //  History:
  11. //
  12. ////////////////////////////////////////////////////////////////////////////
  13.  
  14. #include "StdAfx.h"
  15. #include "SubtitleManager.h"
  16. #include "ISubtitleManager.h"
  17. #include "DialogSystem/DialogActorContext.h"
  18.  
  19. CSubtitleManager* CSubtitleManager::s_Instance = NULL;
  20.  
  21. //////////////////////////////////////////////////////////////////////////
  22. CSubtitleManager::CSubtitleManager()
  23. {
  24.         m_bEnabled = false;
  25.         m_bAutoMode = true;
  26.         m_pHandler = NULL;
  27.  
  28.         s_Instance = this;
  29. }
  30.  
  31. //////////////////////////////////////////////////////////////////////////
  32. CSubtitleManager::~CSubtitleManager()
  33. {
  34.         SetEnabled(false);
  35.         s_Instance = NULL;
  36. }
  37.  
  38. //////////////////////////////////////////////////////////////////////////
  39. void CSubtitleManager::SetEnabled(bool bEnabled)
  40. {
  41.         if (bEnabled != m_bEnabled)
  42.         {
  43.                 m_bEnabled = bEnabled;
  44.  
  45.                 if (m_bAutoMode)
  46.                 {
  47.                         if (bEnabled)
  48.                         {
  49.                                 gEnv->pAudioSystem->AddRequestListener(&CSubtitleManager::OnAudioTriggerStarted, 0, eAudioRequestType_AudioObjectRequest, eAudioObjectRequestType_ExecuteTrigger);
  50.                                 gEnv->pAudioSystem->AddRequestListener(&CSubtitleManager::OnAudioTriggerFinished, 0, eAudioRequestType_AudioCallbackManagerRequest, eAudioCallbackManagerRequestType_ReportFinishedTriggerInstance);
  51.                         }
  52.                         else
  53.                         {
  54.                                 gEnv->pAudioSystem->RemoveRequestListener(&CSubtitleManager::OnAudioTriggerStarted, 0);
  55.                                 gEnv->pAudioSystem->RemoveRequestListener(&CSubtitleManager::OnAudioTriggerFinished, 0);
  56.                         }
  57.                 }
  58.         }
  59. }
  60.  
  61. //////////////////////////////////////////////////////////////////////////
  62. void CSubtitleManager::SetAutoMode(bool bOn)
  63. {
  64.         if (bOn != m_bAutoMode)
  65.         {
  66.                 if (m_bEnabled)
  67.                 {
  68.                         SetEnabled(false);  //force refresh for add/remove as audio listener
  69.                         m_bAutoMode = bOn;
  70.                         SetEnabled(true);
  71.                 }
  72.                 else
  73.                 {
  74.                         m_bAutoMode = bOn;
  75.                 }
  76.         }
  77. }
  78.  
  79. //////////////////////////////////////////////////////////////////////////
  80. void CSubtitleManager::ShowSubtitle(const char* subtitleLabel, bool bShow)
  81. {
  82.         if (m_bEnabled && m_pHandler)
  83.         {
  84.                 m_pHandler->ShowSubtitle(subtitleLabel, bShow);
  85.         }
  86. }
  87.  
  88. //////////////////////////////////////////////////////////////////////////
  89. void CSubtitleManager::ShowSubtitle(const SAudioRequestInfo* const pAudioRequestInfo, bool bShow)
  90. {
  91.         if (m_bEnabled && m_pHandler)
  92.         {
  93.                 m_pHandler->ShowSubtitle(pAudioRequestInfo, bShow);
  94.         }
  95. }
  96.  
  97. //////////////////////////////////////////////////////////////////////////
  98. void CSubtitleManager::OnAudioTriggerStarted(const SAudioRequestInfo* const pAudioRequestInfo)
  99. {
  100.         CSubtitleManager::s_Instance->ShowSubtitle(pAudioRequestInfo, true);
  101. }
  102.  
  103. //////////////////////////////////////////////////////////////////////////
  104. void CSubtitleManager::OnAudioTriggerFinished(const SAudioRequestInfo* const pAudioRequestInfo)
  105. {
  106.         CSubtitleManager::s_Instance->ShowSubtitle(pAudioRequestInfo, false);
  107. }
  108.  
downloadSubtitleManager.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