Minor fixes and add save button
This commit is contained in:
parent
b01d38e55d
commit
330c98267a
Binary file not shown.
After Width: | Height: | Size: 728 B |
|
@ -42,6 +42,29 @@
|
|||
}
|
||||
}
|
||||
|
||||
&.save {
|
||||
background-image: uiResource("icons/save.png");
|
||||
@include MakeAnimationWrappedEvenOdd(0.5s ease-in-out) {
|
||||
0% {
|
||||
transform: scale(1, 1);
|
||||
}
|
||||
|
||||
70% {
|
||||
transform: scale(1.5, 1.5) rotate(20deg);
|
||||
opacity: 0.2;
|
||||
}
|
||||
|
||||
85% {
|
||||
transform: scale(0.9, 0.9);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
90% {
|
||||
transform: scale(1.1, 1.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.settings {
|
||||
background-image: uiResource("icons/settings.png");
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { GameRoot } from "./root";
|
||||
import { globalConfig, IS_DEBUG } from "../core/config";
|
||||
import { Math_max } from "../core/builtins";
|
||||
import { createLogger } from "../core/logging";
|
||||
|
||||
// How important it is that a savegame is created
|
||||
/**
|
||||
|
@ -11,15 +12,10 @@ export const enumSavePriority = {
|
|||
asap: 100,
|
||||
};
|
||||
|
||||
// Internals
|
||||
let MIN_INTERVAL_SECS = 15;
|
||||
const logger = createLogger("autosave");
|
||||
|
||||
if (G_IS_DEV && IS_DEBUG) {
|
||||
// // Testing
|
||||
// MIN_INTERVAL_SECS = 1;
|
||||
// MAX_INTERVAL_SECS = 1;
|
||||
MIN_INTERVAL_SECS = 9999999;
|
||||
}
|
||||
// Internals
|
||||
let MIN_INTERVAL_SECS = 60;
|
||||
|
||||
export class AutomaticSave {
|
||||
constructor(root) {
|
||||
|
@ -50,6 +46,7 @@ export class AutomaticSave {
|
|||
// Bad idea
|
||||
return;
|
||||
}
|
||||
|
||||
// Check when the last save was, but make sure that if it fails, we don't spam
|
||||
const lastSaveTime = Math_max(this.lastSaveAttempt, this.root.savegame.getRealLastUpdate());
|
||||
|
||||
|
@ -72,7 +69,7 @@ export class AutomaticSave {
|
|||
break;
|
||||
}
|
||||
if (shouldSave) {
|
||||
// log(this, "Saving automatically");
|
||||
logger.log("Saving automatically");
|
||||
this.lastSaveAttempt = Date.now();
|
||||
this.doSave();
|
||||
}
|
||||
|
|
|
@ -52,13 +52,17 @@ export class HUDGameMenu extends BaseHUDPart {
|
|||
|
||||
this.musicButton = makeDiv(menuButtons, null, ["button", "music"]);
|
||||
this.sfxButton = makeDiv(menuButtons, null, ["button", "sfx"]);
|
||||
this.saveButton = makeDiv(menuButtons, null, ["button", "save", "animEven"]);
|
||||
this.settingsButton = makeDiv(menuButtons, null, ["button", "settings"]);
|
||||
|
||||
this.trackClicks(this.musicButton, this.toggleMusic);
|
||||
this.trackClicks(this.sfxButton, this.toggleSfx);
|
||||
this.trackClicks(this.saveButton, this.startSave);
|
||||
|
||||
this.musicButton.classList.toggle("muted", this.root.app.settings.getAllSettings().musicMuted);
|
||||
this.sfxButton.classList.toggle("muted", this.root.app.settings.getAllSettings().musicMuted);
|
||||
|
||||
this.root.signals.gameSaved.add(this.onGameSaved, this);
|
||||
}
|
||||
|
||||
update() {
|
||||
|
@ -75,6 +79,16 @@ export class HUDGameMenu extends BaseHUDPart {
|
|||
}
|
||||
}
|
||||
|
||||
onGameSaved() {
|
||||
console.log("ON GAME SAVED");
|
||||
this.saveButton.classList.toggle("animEven");
|
||||
this.saveButton.classList.toggle("animOdd");
|
||||
}
|
||||
|
||||
startSave() {
|
||||
this.root.gameState.doSave();
|
||||
}
|
||||
|
||||
toggleMusic() {
|
||||
const newValue = !this.root.app.settings.getAllSettings().musicMuted;
|
||||
this.root.app.settings.updateSetting("musicMuted", newValue);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { gItemRegistry } from "../core/global_registries";
|
||||
import { ShapeItem } from "./items/shape_item";
|
||||
import { ColorItem } from "./items/color_item";
|
||||
|
||||
export function initItemRegistry() {
|
||||
gItemRegistry.register(ShapeItem);
|
||||
gItemRegistry.register(ColorItem);
|
||||
}
|
||||
|
|
|
@ -187,14 +187,6 @@ export class Savegame extends ReadWriteProxy {
|
|||
if (!dump) {
|
||||
return false;
|
||||
}
|
||||
const parsed = JSON.stringify(compressObject(dump));
|
||||
const compressed = compressX64(parsed);
|
||||
|
||||
console.log("Regular: ", Math.round(parsed.length / 1024.0), "KB");
|
||||
console.log("Compressed: ", Math.round(compressed.length / 1024.0), "KB");
|
||||
|
||||
// let duration = performanceNow() - timer;
|
||||
// console.log("TOOK", duration, "ms to generate dump:", dump);
|
||||
|
||||
const shadowData = Object.assign({}, this.currentData);
|
||||
shadowData.dump = dump;
|
||||
|
|
|
@ -165,7 +165,7 @@ export class InGameState extends GameState {
|
|||
return;
|
||||
}
|
||||
this.stageLeavingGame();
|
||||
this.doSave(false, true).then(() => {
|
||||
this.doSave().then(() => {
|
||||
this.stageDestroyed();
|
||||
this.moveToState(stateId, payload);
|
||||
});
|
||||
|
@ -424,6 +424,7 @@ export class InGameState extends GameState {
|
|||
|
||||
// First update the game data
|
||||
logger.log("Starting to save game ...");
|
||||
this.core.root.signals.gameSaved.dispatch();
|
||||
this.savegame.updateData(this.core.root);
|
||||
return this.savegame.writeSavegameAndMetadata().catch(err => {
|
||||
logger.warn("Failed to save:", err);
|
||||
|
|
|
@ -10,10 +10,7 @@ function accessNestedPropertyReverse(obj, keys) {
|
|||
return result;
|
||||
}
|
||||
|
||||
const rusha = require("rusha");
|
||||
|
||||
const salt = accessNestedPropertyReverse(globalConfig, ["file", "info"]);
|
||||
const encryptKey = globalConfig.info.sgSalt;
|
||||
|
||||
onmessage = function (event) {
|
||||
const { jobId, job, data } = event.data;
|
||||
|
|
Reference in New Issue