All files / src/lib/events eventSetColorAreaSGB.js

0% Statements 0/10
100% Branches 0/0
0% Functions 0/1
0% Lines 0/10

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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124                                                                                                                                                                                                                                                       
const l10n = require("../helpers/l10n").default;
 
const id = "EVENT_SET_SGB_COLOR_AREA";
const groups = ["EVENT_GROUP_COLOR"];
 
const paletteOptions = [
  ["none", l10n("FIELD_NONE")],
  ["0", l10n("FIELD_SUPER_GB_PALETTE_N", { index: 1 })],
  ["1", l10n("FIELD_SUPER_GB_PALETTE_N", { index: 2 })],
  ["2", l10n("FIELD_SUPER_GB_PALETTE_N", { index: 3 })],
  ["3", l10n("FIELD_SUPER_GB_PALETTE_N", { index: 4 })],
];
 
const fields = [
  {
    type: "group",
    fields: [
      {
        key: "x",
        label: l10n("FIELD_X"),
        description: l10n("FIELD_X_DESC"),
        type: "number",
        min: 0,
        max: 19,
        defaultValue: 0,
        width: "50%",
        unitsField: "units",
        unitsDefault: "tiles",
      },
      {
        key: "y",
        label: l10n("FIELD_Y"),
        description: l10n("FIELD_Y_DESC"),
        type: "number",
        min: 0,
        max: 17,
        defaultValue: 0,
        width: "50%",
        unitsField: "units",
        unitsDefault: "tiles",
      },
    ],
  },
  {
    type: "group",
    fields: [
      {
        key: "width",
        label: l10n("FIELD_WIDTH"),
        description: l10n("FIELD_BOX_WIDTH_DESC"),
        type: "number",
        min: 1,
        max: 20,
        defaultValue: 4,
        width: "50%",
        unitsField: "units",
        unitsDefault: "tiles",
      },
      {
        key: "height",
        label: l10n("FIELD_HEIGHT"),
        description: l10n("FIELD_BOX_HEIGHT_DESC"),
        type: "number",
        min: 1,
        max: 18,
        defaultValue: 4,
        width: "50%",
        unitsField: "units",
        unitsDefault: "tiles",
      },
    ],
  },
  {
    key: "fill",
    label: l10n("FIELD_FILL_PALETTE"),
    description: l10n("FIELD_FILL_PALETTE_DESC"),
    type: "select",
    defaultValue: "none",
    options: paletteOptions,
  },
  {
    key: "border",
    label: l10n("FIELD_BORDER_PALETTE"),
    description: l10n("FIELD_BORDER_PALETTE_DESC"),
    type: "select",
    defaultValue: "none",
    options: paletteOptions,
  },
  {
    key: "outside",
    label: l10n("FIELD_OUTSIDE_PALETTE"),
    description: l10n("FIELD_OUTSIDE_PALETTE_DESC"),
    type: "select",
    defaultValue: "none",
    options: paletteOptions,
  },
];
 
const compile = (input, helpers) => {
  const { setSGBColorArea } = helpers;
  const { fill, border, outside, x, y, width, height } = input;
 
  setSGBColorArea(fill, border, outside, x, y, width, height);
};
 
module.exports = {
  id,
  description: l10n("EVENT_SET_SGB_COLOR_AREA_DESC"),
  groups,
  fields,
  allowBeforeInitFade: true,
  helper: {
    type: "area",
    x: "x",
    y: "y",
    width: "width",
    height: "height",
    fill: "fill",
    border: "border",
    outside: "outside",
  },
  compile,
};