text: ////////////////////////////////////////////////////////////////////////////////////////////////////////
  // Part of Injectable Generic Camera System
  // Copyright(c) 2019, Frans Bouma
  // All rights reserved.
  // https://github.com/FransBouma/InjectableGenericCameraSystem
  //
  // Redistribution and use in source and binary forms, with or without
  // modification, are permitted provided that the following conditions are met :
  //
  //  * Redistributions of source code must retain the above copyright notice, this
  //	  list of conditions and the following disclaimer.
  //
  //  * Redistributions in binary form must reproduce the above copyright notice,
  //    this list of conditions and the following disclaimer in the documentation
  //    and / or other materials provided with the distribution.
  //
  // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  // DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  // DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  // OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  ////////////////////////////////////////////////////////////////////////////////////////////////////////
  #pragma once
  #include "stdafx.h"
  #include "Gamepad.h"
  #include "GameConstants.h"
  #include "Defaults.h"
  #include "CDataFile.h"
  #include "Utils.h"
  #include <atomic>
  #include "Settings.h"
  #include "ActionData.h"
  #include <map>
  #include "ScreenshotController.h"
  
  extern "C" BYTE g_cameraEnabled;
  extern "C" BYTE g_gamePaused;
  
  namespace IGCS
  {
  	class Globals
  	{
  	public:
  		Globals();
  		~Globals();
  
  		static Globals& instance();
  
  		void saveSettingsIfRequired(float delta);
  		void markSettingsDirty();
  
  		bool inputBlocked() const { return _inputBlocked; }
  		void inputBlocked(bool value) { _inputBlocked = value; }
  		bool systemActive() const { return _systemActive; }
  		void systemActive(bool value) { _systemActive = value; }
  		HWND mainWindowHandle() const { return _mainWindowHandle; }
  		void mainWindowHandle(HWND handle) { _mainWindowHandle = handle; }
  		Gamepad& gamePad() { return _gamePad; }
  		Settings& settings() { return _settings; }
  		bool keyboardMouseControlCamera() const { return _settings.cameraControlDevice == DEVICE_ID_KEYBOARD_MOUSE || _settings.cameraControlDevice == DEVICE_ID_ALL; }
  		bool controllerControlsCamera() const { return _settings.cameraControlDevice == DEVICE_ID_GAMEPAD || _settings.cameraControlDevice == DEVICE_ID_ALL; }
  		ActionData* getActionData(ActionType type);
  		void updateActionDataForAction(ActionType type);
  		ActionData& getKeyCollector() { return _keyCollectorData; }
  		ScreenshotController& getScreenshotController() { return _screenshotController; }
  		void reinitializeScreenshotController();
  
  	private:
  		void initializeKeyBindings();
  
  		bool _inputBlocked = false;
  		atomic_bool _systemActive = false;
  		Gamepad _gamePad;
  		HWND _mainWindowHandle;
  		Settings _settings;
  		float _settingsDirtyTimer=0.0f;			// when settings are marked dirty, this is set with a value > 0 and decremented each frame. If 0, settings are saved. In seconds.
  		map<ActionType, ActionData*> _keyBindingPerActionType;
  		ActionData _keyCollectorData = ActionData("KeyCollector", "", 0, false, false, false);
  		ScreenshotController _screenshotController;
  	};
  }