Object-specific property values of type angle are now displayed in degrees instead of radians. Fixed the types of some object-specific properties.

This commit is contained in:
Daan Vanden Bosch 2020-09-24 20:25:15 +02:00
parent 4bd137b407
commit d35cbcaf98
2 changed files with 23 additions and 12 deletions

View File

@ -958,7 +958,7 @@ define_object_type_data(
["Destination x", 40, "F32"], ["Destination x", 40, "F32"],
["Destination y", 44, "F32"], ["Destination y", 44, "F32"],
["Destination z", 48, "F32"], ["Destination z", 48, "F32"],
["Dst. rotation y", 52, "I32"], ["Dst. rotation y", 52, "Angle"],
], ],
); );
define_object_type_data( define_object_type_data(
@ -2288,7 +2288,7 @@ define_object_type_data(
["Destination x", 40, "F32"], ["Destination x", 40, "F32"],
["Destination y", 44, "F32"], ["Destination y", 44, "F32"],
["Destination z", 48, "F32"], ["Destination z", 48, "F32"],
["Dst. rotation y", 52, "I32"], ["Dst. rotation y", 52, "Angle"],
], ],
); );
define_object_type_data( define_object_type_data(

View File

@ -2,7 +2,7 @@ import { bind_attr, bind_children_to, div, table, td, th, tr } from "../../core/
import { UnavailableView } from "./UnavailableView"; import { UnavailableView } from "./UnavailableView";
import "./EntityInfoView.css"; import "./EntityInfoView.css";
import { NumberInput } from "../../core/gui/NumberInput"; import { NumberInput } from "../../core/gui/NumberInput";
import { rad_to_deg } from "../../core/math"; import { deg_to_rad, rad_to_deg } from "../../core/math";
import { EntityInfoController } from "../controllers/EntityInfoController"; import { EntityInfoController } from "../controllers/EntityInfoController";
import { ResizableView } from "../../core/gui/ResizableView"; import { ResizableView } from "../../core/gui/ResizableView";
import { QuestEntityPropModel } from "../model/QuestEntityPropModel"; import { QuestEntityPropModel } from "../model/QuestEntityPropModel";
@ -148,8 +148,8 @@ export class EntityInfoView extends ResizableView {
max = 0x7fffffff; max = 0x7fffffff;
break; break;
case EntityPropType.Angle: case EntityPropType.Angle:
min = -2 * Math.PI; min = -360;
max = 2 * Math.PI; max = 360;
break; break;
} }
@ -157,16 +157,27 @@ export class EntityInfoView extends ResizableView {
prop.type === EntityPropType.F32 || prop.type === EntityPropType.Angle ? 3 : 1; prop.type === EntityPropType.F32 || prop.type === EntityPropType.Angle ? 3 : 1;
const value_input = disposer.add( const value_input = disposer.add(
new NumberInput(prop.value.val, { new NumberInput(
prop.type === EntityPropType.Angle ? rad_to_deg(prop.value.val) : prop.value.val,
{
min, min,
max, max,
round_to, round_to,
}), },
),
); );
disposer.add_all( disposer.add_all(
value_input.value.bind_to(prop.value), value_input.value.bind_to(
value_input.value.observe(({ value }) => this.ctrl.set_prop_value(prop, value)), prop.type === EntityPropType.Angle ? prop.value.map(rad_to_deg) : prop.value,
),
value_input.value.observe(({ value }) =>
this.ctrl.set_prop_value(
prop,
prop.type === EntityPropType.Angle ? deg_to_rad(value) : value,
),
),
); );
const element = tr(th(`${prop.name}:`), td(value_input.element)); const element = tr(th(`${prop.name}:`), td(value_input.element));