All files / src/lib/events eventCameraPropertySet.js

0% Statements 0/14
0% Branches 0/4
0% Functions 0/2
0% Lines 0/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76                                                                                                                                                       
const l10n = require("../helpers/l10n").default;
 
const id = "EVENT_CAMERA_PROPERTY_SET";
const groups = ["EVENT_GROUP_CAMERA"];
const subGroups = {
  EVENT_GROUP_CAMERA: "EVENT_GROUP_PROPERTIES",
};
 
const autoLabel = (fetchArg, input) => {
  /* eslint-disable camelcase */
  const propL10N = {
    camera_deadzone_x: l10n("FIELD_CAMERA_DEADZONE_X"),
    camera_deadzone_y: l10n("FIELD_CAMERA_DEADZONE_Y"),
    camera_offset_x: l10n("FIELD_CAMERA_OFFSET_X"),
    camera_offset_y: l10n("FIELD_CAMERA_OFFSET_Y"),
  };
  /* eslint-enable camelcase */
 
  Iif (
    input.property === undefined ||
    input.value === undefined ||
    !propL10N[input.property]
  ) {
    return l10n("EVENT_CAMERA_PROPERTY_SET");
  }
 
  return l10n("EVENT_GENERIC_SET_LABEL", {
    field: propL10N[input.property],
    value: fetchArg("value"),
  });
};
 
const fields = [
  {
    key: "property",
    label: l10n("FIELD_PROPERTY"),
    description: l10n("FIELD_CAMERA_PROPERTY_SET_DESC"),
    type: "select",
    defaultValue: "camera_deadzone_x",
    options: [
      ["camera_deadzone_x", l10n("FIELD_CAMERA_DEADZONE_X")],
      ["camera_deadzone_y", l10n("FIELD_CAMERA_DEADZONE_Y")],
      ["camera_offset_x", l10n("FIELD_CAMERA_OFFSET_X")],
      ["camera_offset_y", l10n("FIELD_CAMERA_OFFSET_Y")],
    ],
  },
  {
    key: "value",
    label: l10n("FIELD_VALUE"),
    description: l10n("FIELD_VALUE_SET_DESC"),
    type: "value",
    min: -128,
    max: 127,
    defaultValue: {
      type: "number",
      value: 0,
    },
  },
];
 
const compile = (input, helpers) => {
  const { cameraSetPropertyToScriptValue } = helpers;
  cameraSetPropertyToScriptValue(input.property, input.value);
};
 
module.exports = {
  id,
  description: l10n("EVENT_CAMERA_PROPERTY_SET_DESC"),
  autoLabel,
  groups,
  subGroups,
  fields,
  compile,
  allowedBeforeInitFade: true,
};