OtherOptionsTab.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * VcmiSettingsWindow.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "OtherOptionsTab.h"
  12. #include "../../../lib/filesystem/ResourcePath.h"
  13. #include "../../GameEngine.h"
  14. #include "../../widgets/Buttons.h"
  15. #include "CConfigHandler.h"
  16. static void setBoolSetting(std::string group, std::string field, bool value)
  17. {
  18. Settings fullscreen = settings.write[group][field];
  19. fullscreen->Bool() = value;
  20. }
  21. OtherOptionsTab::OtherOptionsTab() : InterfaceObjectConfigurable()
  22. {
  23. OBJECT_CONSTRUCTION;
  24. const JsonNode config(JsonPath::builtin("config/widgets/settings/otherOptionsTab.json"));
  25. addCallback("availableCreaturesAsDwellingLabelChanged", [](bool value)
  26. {
  27. return setBoolSetting("gameTweaks", "availableCreaturesAsDwellingLabel", value);
  28. });
  29. addCallback("compactTownCreatureInfoChanged", [](bool value)
  30. {
  31. return setBoolSetting("gameTweaks", "compactTownCreatureInfo", value);
  32. });
  33. build(config);
  34. std::shared_ptr<CToggleButton> availableCreaturesAsDwellingLabelCheckbox = widget<CToggleButton>("availableCreaturesAsDwellingLabelCheckbox");
  35. availableCreaturesAsDwellingLabelCheckbox->setSelected(settings["gameTweaks"]["availableCreaturesAsDwellingLabel"].Bool());
  36. std::shared_ptr<CToggleButton> compactTownCreatureInfo = widget<CToggleButton>("compactTownCreatureInfoCheckbox");
  37. compactTownCreatureInfo->setSelected(settings["gameTweaks"]["compactTownCreatureInfo"].Bool());
  38. }