UserOptions.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. // Description : These are helper classes for containing the data from the
  9. // generic overwrite dialog
  10. #include "EditorDefs.h"
  11. #include "UserOptions.h"
  12. //////////////////////////////////////////////////////////////////////////
  13. CUserOptions::CUserOptionsReferenceCountHelper::CUserOptionsReferenceCountHelper(CUserOptions& roUserOptions)
  14. : m_roReferencedUserOptionsObject(roUserOptions)
  15. {
  16. m_roReferencedUserOptionsObject.IncRef();
  17. }
  18. //////////////////////////////////////////////////////////////////////////
  19. CUserOptions::CUserOptionsReferenceCountHelper::~CUserOptionsReferenceCountHelper()
  20. {
  21. m_roReferencedUserOptionsObject.DecRef();
  22. }
  23. //////////////////////////////////////////////////////////////////////////
  24. CUserOptions::CUserOptions()
  25. {
  26. m_boToAll = false;
  27. m_nCurrentOption = ENotSet;
  28. }
  29. //////////////////////////////////////////////////////////////////////////
  30. bool CUserOptions::IsOptionValid()
  31. {
  32. return m_nCurrentOption != ENotSet;
  33. }
  34. //////////////////////////////////////////////////////////////////////////
  35. int CUserOptions::GetOption()
  36. {
  37. return m_nCurrentOption;
  38. }
  39. //////////////////////////////////////////////////////////////////////////
  40. bool CUserOptions::IsOptionToAll()
  41. {
  42. return m_boToAll;
  43. }
  44. //////////////////////////////////////////////////////////////////////////
  45. void CUserOptions::SetOption(int nNewOption, bool boToAll)
  46. {
  47. m_nCurrentOption = nNewOption;
  48. m_boToAll = boToAll;
  49. }
  50. //////////////////////////////////////////////////////////////////////////
  51. int CUserOptions::DecRef()
  52. {
  53. if (m_nNumberOfReferences >= 1)
  54. {
  55. --m_nNumberOfReferences;
  56. if (m_nNumberOfReferences == 0)
  57. {
  58. SetOption(CUserOptions::ENotSet, false);
  59. }
  60. }
  61. return m_nNumberOfReferences;
  62. }
  63. //////////////////////////////////////////////////////////////////////////
  64. int CUserOptions::IncRef()
  65. {
  66. ++m_nNumberOfReferences;
  67. return m_nNumberOfReferences;
  68. }
  69. //////////////////////////////////////////////////////////////////////////