diff --git a/dist/css/style.css b/dist/css/style.css index ecdb4f2..ea50686 100644 --- a/dist/css/style.css +++ b/dist/css/style.css @@ -203,7 +203,6 @@ input:hover,input:active { .edit-mode-btn { width: 30px; height: 30px; - margin-top: 5px; } .edit-mode-btn.selected { background-color: var(--btn-hover); @@ -233,9 +232,8 @@ input:hover,input:active { #unnatural-org-warning { color: red; text-align: center; - font-size: 22px; + font-size: 15px; border-radius: 10px; - margin: 2px; border: 2px solid red; } #unnatural-org-warning:hover { @@ -326,10 +324,6 @@ input:hover,input:active { padding-bottom: 0; } -#reset-with-editor-org { - margin-top: 5px; -} - .load-panel { width: 800px; background-color: var(--panel-bg); diff --git a/dist/index.html b/dist/index.html index 2930cff..bdc967f 100644 --- a/dist/index.html +++ b/dist/index.html @@ -84,6 +84,7 @@ +
@@ -125,6 +126,10 @@ - -
diff --git a/src/Controllers/EditorController.js b/src/Controllers/EditorController.js index b3f9e31..e743611 100644 --- a/src/Controllers/EditorController.js +++ b/src/Controllers/EditorController.js @@ -5,6 +5,7 @@ const Directions = require("../Organism/Directions"); const Hyperparams = require("../Hyperparameters"); const Species = require("../Stats/Species"); const LoadController = require("./LoadController"); +const FossilRecord = require("../Stats/FossilRecord"); class EditorController extends CanvasController{ constructor(env, canvas) { @@ -98,6 +99,13 @@ class EditorController extends CanvasController{ this.decision_names = ["ignore", "move away", "move towards"]; + $('#species-name-edit').on('focusout', function() { + const new_name = $('#species-name-edit').val(); + if (new_name === '' || new_name === this.env.organism.species.name) + return; + FossilRecord.changeSpeciesName(this.env.organism.species, new_name); + }.bind(this)); + $('#move-range-edit').change ( function() { this.env.organism.move_range = parseInt($('#move-range-edit').val()); }.bind(this)); @@ -123,7 +131,8 @@ class EditorController extends CanvasController{ let data = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(org)); let downloadEl = document.getElementById('download-el'); downloadEl.setAttribute("href", data); - downloadEl.setAttribute("download", "organism.json"); + const name = this.env.organism.species.name ? this.env.organism.species.name : "organism"; + downloadEl.setAttribute("download", name+".json"); downloadEl.click(); }); $('#load-org').click(() => { @@ -188,6 +197,7 @@ class EditorController extends CanvasController{ this.clearDetailsPanel(); var org = this.env.organism; + $('#species-name-edit').val(org.species.name); $('.cell-count').text("Cell count: "+org.anatomy.cells.length); if (this.setMoveRangeVisibility()){ $('#move-range-edit').val(org.move_range); diff --git a/src/Stats/FossilRecord.js b/src/Stats/FossilRecord.js index a72b46b..21477a0 100644 --- a/src/Stats/FossilRecord.js +++ b/src/Stats/FossilRecord.js @@ -34,6 +34,16 @@ const FossilRecord = { return species; }, + changeSpeciesName: function(species, new_name) { + if (this.extant_species[new_name]) { + console.warn('Tried to change species name to an existing species name. Change failed.'); + return; + } + delete this.extant_species[species.name]; + species.name = new_name; + this.extant_species[new_name] = species; + }, + numExtantSpecies() {return Object.values(this.extant_species).length}, numExtinctSpecies() {return Object.values(this.extinct_species).length}, speciesIsExtant(species_name) {return !!this.extant_species[species_name]},