Explorar el Código

Allow mass estimation; fix food intake/value clashing

Also styles selects differently if they have their 'disabled' value
master
Fen Dweller hace 4 años
padre
commit
a3515c745c
Se han modificado 1 ficheros con 47 adiciones y 3 borrados
  1. +47
    -3
      macrovision.js

+ 47
- 3
macrovision.js Ver fichero

@@ -1206,8 +1206,26 @@ function makeEntity(info, views, sizes, forms = {}) {

view.units = {};

if (config.autoMass && view.attributes.weight === undefined) {
let base = undefined;
switch(config.autoMass) {
case "human":
base = math.divide(math.unit(150, "lbs"), math.unit(5.917, "feet"))
break
case "quadruped at shoulder":
base = math.divide(math.unit(80, "lbs"), math.unit(30, "inches"))
break
}
view.attributes.weight = {
name: "Mass",
power: 3,
type: "mass",
base: math.multiply(base, view.attributes.height.base)
}
}

if (config.autoFoodIntake && view.attributes.weight !== undefined && view.attributes.energyNeed === undefined) {
view.attributes.energyNeed = {
view.attributes.energyIntake = {
name: "Food Intake",
power: 3,
type: "energy",
@@ -2526,6 +2544,7 @@ const settingsData = {
desc: "Draw interesting altitudes",
type: "select",
default: "none",
disabled: "none",
options: [
"none",
"all",
@@ -2598,6 +2617,7 @@ const settingsData = {
desc: "What kind of ground to show, if any",
type: "select",
default: "black",
disabled: "none",
options: [
"none",
"black",
@@ -2822,6 +2842,24 @@ const settingsData = {
toggleBodyClass("smoothing", param);
}
},
"auto-mass": {
name: "Estimate Mass",
desc: "Guess the mass of things that don't have one specified using the selected body type",
type: "select",
default: "off",
disabled: "off",
options: [
"off",
"human",
"quadruped at shoulder",
],
get value() {
return config.autoMass
},
set value(param) {
config.autoMass = param
}
},
"auto-food-intake": {
name: "Estimate Food Intake",
desc: "Guess how much food creatures need, based on their mass -- 2000kcal per 150lbs",
@@ -2941,10 +2979,16 @@ function prepareSettings(userSettings) {
holder.appendChild(select);
menubar.appendChild(holder);

holder.classList.add("enabled");

const update = () => {
entry.value = select.value;

if (entry.disabled !== undefined && entry.value !== entry.disabled) {
holder.classList.add("enabled");
holder.classList.remove("disabled");
} else {
holder.classList.remove("enabled");
holder.classList.add("disabled");
}
}

update();


Cargando…
Cancelar
Guardar