settings.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /// <reference path="../events/_system/NavigationOverride.ts" />
  2. Config.macros.ifAssignmentError = false;
  3. Config.navigation.override = setup.navigationOverride;
  4. Config.passages.nobr = true; //vgl. https://www.motoslave.net/sugarcube/2/docs/#config-api-property-passages-nobr
  5. Config.history.maxStates = 3;
  6. Config.saves.isAllowed = function () {
  7. if(tags().includes("noSave"))
  8. return false;
  9. return true;
  10. };
  11. Save.onLoad.add(function (save) {
  12. console.log("Loading savegame",save);
  13. let saveVars = save.state.history.last().variables;
  14. setup.settingsApply(saveVars.settings);
  15. });
  16. setup.settingsApply = function(settings){
  17. if(!settings)
  18. return;
  19. console.warn('Aplly settings',settings);
  20. switch(settings.autosave){
  21. case 'ALWAYS':
  22. Config.saves.autosave = true;
  23. break;
  24. case 'AWAKE':
  25. Config.saves.autosave = ['sleepAwake','autosave'];
  26. break;
  27. case 'NONE':
  28. Config.saves.autosave = ()=>false;
  29. break;
  30. }
  31. switch(settings.ui?.sidebarRight){
  32. case true:
  33. $("#ui-bar").addClass("uiBarRight");
  34. break;
  35. default:
  36. break;
  37. }
  38. if(settings.ui?.css)
  39. importStyles(settings.ui?.css.split("\n"));
  40. if(settings.maxStates)
  41. Config.history.maxStates = settings.maxStates;
  42. }