+ <>
+ {bodyParts.map(({ label, type, value: originalValue, ...props }) => {
+ const value =
+ 'index' in props && props.index !== undefined
+ ? props.bones[props.index].value
+ : originalValue;
+ const selected = currentSelection.label === label;
-
-
+ const selectNew = () => {
+ switch (type) {
+ case LabelType.Bone: {
+ if (!('bone' in props)) throw 'unreachable';
+ dispatch({
+ ...props,
+ label,
+ value,
+ type: ProportionChangeType.Bone,
+ });
+ break;
+ }
+ case LabelType.Group: {
+ if (!('bones' in props)) throw 'unreachable';
+ dispatch({
+ ...props,
+ label,
+ value,
+ type: ProportionChangeType.Group,
+ index: undefined,
+ parentLabel: label,
+ });
+ break;
+ }
+ case LabelType.GroupPart: {
+ if (!('index' in props)) throw 'unreachable';
+ dispatch({
+ ...props,
+ label,
+ // If this isn't done, we are replacing total
+ // with percentage value
+ value: originalValue,
+ type: ProportionChangeType.Group,
+ index: props.index,
+ });
+ }
+ }
+ };
+
+ return (
+
+
+ {!precise && (
+
+ type === LabelType.GroupPart
+ ? dispatch({
+ type: ProportionChangeType.Ratio,
+ value: -0.05,
+ })
+ : dispatch({
+ type: ProportionChangeType.Linear,
+ value: -5,
+ })
+ }
+ >
+ {configFormat.format(-5)}
+
+ )}
+
+ type === LabelType.GroupPart
+ ? dispatch({
+ type: ProportionChangeType.Ratio,
+ value: -0.01,
+ })
+ : dispatch({
+ type: ProportionChangeType.Linear,
+ value: -1,
+ })
+ }
+ >
+ {configFormat.format(-1)}
+
+ {precise && (
+
+ type === LabelType.GroupPart
+ ? dispatch({
+ type: ProportionChangeType.Ratio,
+ value: -0.005,
+ })
+ : dispatch({
+ type: ProportionChangeType.Linear,
+ value: -0.5,
+ })
+ }
+ >
+ {configFormat.format(-0.5)}
+
+ )}
+
+
+
+
+ {l10n.getString(label)}
+
+
+ {type === LabelType.GroupPart
+ ? /* Make number rounding so it's based on .5 decimals */
+ percentageFormat.format(Math.round(value * 200) / 200)
+ : cmFormat.format(value * 100)}
+ {type === LabelType.GroupPart && (
+ {`(${cmFormat.format(
+ value * originalValue * 100
+ )})`}
+ )}
+
+
+
+
+ {precise && (
+
+ type === LabelType.GroupPart
+ ? dispatch({
+ type: ProportionChangeType.Ratio,
+ value: 0.005,
+ })
+ : dispatch({
+ type: ProportionChangeType.Linear,
+ value: 0.5,
+ })
+ }
+ >
+ {configFormat.format(+0.5)}
+
+ )}
+
+ type === LabelType.GroupPart
+ ? dispatch({
+ type: ProportionChangeType.Ratio,
+ value: 0.01,
+ })
+ : dispatch({
+ type: ProportionChangeType.Linear,
+ value: 1,
+ })
+ }
+ >
+ {configFormat.format(+1)}
+
+ {!precise && (
+
+ type === LabelType.GroupPart
+ ? dispatch({
+ type: ProportionChangeType.Ratio,
+ value: 0.05,
+ })
+ : dispatch({
+ type: ProportionChangeType.Linear,
+ value: 5,
+ })
+ }
+ >
+ {configFormat.format(+5)}
+
+ )}
+
+
+ );
+ })}
+ >