Skip to content
Snippets Groups Projects
eventHandlers.js 1.13 KiB
Newer Older
  • Learn to ignore specific revisions
  • App.EventHandlers = function() {
    	/**
    
    ezsh's avatar
    ezsh committed
    	 * @param {TwineSugarCube.SaveObject} save
    
    	 */
    	function onLoad(save) {
    
    		const v = save.state.history[0].variables;
    
    Blank_Alt's avatar
    Blank_Alt committed
    		if (v.releaseID === 2000) {
    			v.releaseID = 1100;
    		}
    
    		if (v.releaseID > App.Version.release) {
    			console.error("Save game version problem. Loaded : " + v.releaseID + ", above expected:" + App.Version.release); // eslint-disable-line no-console
    			throw new Error("The save you're attempting to load was created with the game version newer than one you are running. Please download the latest game version.");
    		}
    		// updating settings only for the same releaseID, otherwise user will run
    		// backwards compatibility and we update settings from there
    		if (v.releaseID === App.Version.release) {
    			App.UI.SlaveSummary.settingsChanged(v);
    		}
    
    ezsh's avatar
    ezsh committed
    	 * @param {TwineSugarCube.SaveObject} save
    
    	 */
    	function onSave(save) {
    	}
    
    	function storyReady() {
    
    		App.UI.Theme.init();
    
    		App.UI.Hotkeys.init();
    
    	function optionsChanged() {
    
    		App.UI.SlaveSummary.settingsChanged();
    
    	return {
    		onLoad: onLoad,
    		onSave: onSave,
    
    		storyReady: storyReady,
    		optionsChanged: optionsChanged