BsStringTableManager.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. #include "Utility/BsModule.h"
  6. #include "Localization/BsStringTable.h"
  7. namespace bs
  8. {
  9. /** @addtogroup Localization
  10. * @{
  11. */
  12. /**
  13. * Manages string tables used for localizing text. Allows you to add and remove different tables and change the active
  14. * language.
  15. */
  16. class BS_CORE_EXPORT BS_SCRIPT_EXPORT(n:StringTables,m:Localization) StringTableManager : public Module<StringTableManager>
  17. {
  18. public:
  19. StringTableManager();
  20. /** Determines the currently active language. Any newly created strings will use this value. */
  21. BS_SCRIPT_EXPORT(n:ActiveLanguage,pr:setter)
  22. void setActiveLanguage(Language language);
  23. /** @copydoc setActiveLanguage() */
  24. BS_SCRIPT_EXPORT(n:ActiveLanguage,pr:getter)
  25. Language getActiveLanguage() const { return mActiveLanguage; }
  26. /**
  27. * Returns the string table with the specified id. If the table doesn't exist new one is created.
  28. *
  29. * @param[in] id Identifier of the string table.
  30. * @return String table with the specified identifier.
  31. */
  32. BS_SCRIPT_EXPORT()
  33. HStringTable getTable(UINT32 id);
  34. /**
  35. * Removes the string table with the specified id.
  36. *
  37. * @param[in] id Identifier of the string table.
  38. */
  39. BS_SCRIPT_EXPORT()
  40. void removeTable(UINT32 id);
  41. /**
  42. * Registers a new string table or replaces an old one at the specified id.
  43. *
  44. * @param[in] id Identifier of the string table.
  45. * @param[in] table New string table to assign to the specified identifier.
  46. */
  47. BS_SCRIPT_EXPORT()
  48. void setTable(UINT32 id, const HStringTable& table);
  49. private:
  50. Language mActiveLanguage;
  51. UnorderedMap<UINT32, HStringTable> mTables;
  52. };
  53. /** Provides easier access to StringTableManager. */
  54. BS_CORE_EXPORT StringTableManager& gStringTableManager();
  55. /** @} */
  56. }