desktop support
This commit is contained in:
34
static/js/seagull-desktop.js
Normal file
34
static/js/seagull-desktop.js
Normal file
@@ -0,0 +1,34 @@
|
||||
var desktop_mode = true;
|
||||
|
||||
async function prepare_gamestate() {
|
||||
var gamestate_loaded = null;
|
||||
try {
|
||||
gamestate_loaded = await window.pywebview.api.load_data("gamestate");
|
||||
} catch (exc) {
|
||||
console.error("no gamestate");
|
||||
gamestate_loaded = null;
|
||||
}
|
||||
|
||||
if (gamestate_loaded == null) {
|
||||
record_log("Welcome to Seagull Game! We haven't found a save in your app data, so we're starting a new game!");
|
||||
gamestate = structuredClone(gamestate_default);
|
||||
}
|
||||
else {
|
||||
console.log(gamestate_loaded);
|
||||
gamestate = JSON.parse(gamestate_loaded);
|
||||
record_log("Welcome back! Game loaded.")
|
||||
}
|
||||
}
|
||||
|
||||
function save_game() {
|
||||
window.pywebview.api.save_data("gamestate", JSON.stringify(gamestate));
|
||||
record_log("Game saved.");
|
||||
}
|
||||
|
||||
var tick_meter_running = true;
|
||||
|
||||
function reset_game() {
|
||||
tick_meter_running = false;
|
||||
window.pywebview.api.delete_data("gamestate");
|
||||
window.location.reload();
|
||||
}
|
Reference in New Issue
Block a user