Fix common.tsx

This commit is contained in:
thepaperpilot 2023-04-18 20:58:35 -05:00
parent a262d6fd03
commit b666e0c1f5

View file

@ -5,11 +5,10 @@ import { createClickable } from "features/clickables/clickable";
import type { GenericConversion } from "features/conversion"; import type { GenericConversion } from "features/conversion";
import type { CoercableComponent, JSXFunction, OptionsFunc, Replace } from "features/feature"; import type { CoercableComponent, JSXFunction, OptionsFunc, Replace } from "features/feature";
import { jsx, setDefault } from "features/feature"; import { jsx, setDefault } from "features/feature";
import { displayResource, Resource } from "features/resources/resource"; import { Resource, displayResource } from "features/resources/resource";
import type { GenericTree, GenericTreeNode, TreeNode, TreeNodeOptions } from "features/trees/tree"; import type { GenericTree, GenericTreeNode, TreeNode, TreeNodeOptions } from "features/trees/tree";
import { createTreeNode } from "features/trees/tree"; import { createTreeNode } from "features/trees/tree";
import Formula from "game/formulas/formulas"; import type { GenericFormula } from "game/formulas/types";
import type { FormulaSource, GenericFormula } from "game/formulas/types";
import type { Modifier } from "game/modifiers"; import type { Modifier } from "game/modifiers";
import type { Persistent } from "game/persistence"; import type { Persistent } from "game/persistence";
import { DefaultValue, persistent } from "game/persistence"; import { DefaultValue, persistent } from "game/persistence";
@ -99,8 +98,8 @@ export type GenericResetButton = Replace<
export function createResetButton<T extends ClickableOptions & ResetButtonOptions>( export function createResetButton<T extends ClickableOptions & ResetButtonOptions>(
optionsFunc: OptionsFunc<T> optionsFunc: OptionsFunc<T>
): ResetButton<T> { ): ResetButton<T> {
return createClickable(() => { return createClickable(feature => {
const resetButton = optionsFunc(); const resetButton = optionsFunc.call(feature, feature);
processComputable(resetButton as T, "showNextAt"); processComputable(resetButton as T, "showNextAt");
setDefault(resetButton, "showNextAt", true); setDefault(resetButton, "showNextAt", true);
@ -213,8 +212,8 @@ export type GenericLayerTreeNode = Replace<
export function createLayerTreeNode<T extends LayerTreeNodeOptions>( export function createLayerTreeNode<T extends LayerTreeNodeOptions>(
optionsFunc: OptionsFunc<T> optionsFunc: OptionsFunc<T>
): LayerTreeNode<T> { ): LayerTreeNode<T> {
return createTreeNode(() => { return createTreeNode(feature => {
const options = optionsFunc(); const options = optionsFunc.call(feature, feature);
processComputable(options as T, "display"); processComputable(options as T, "display");
setDefault(options, "display", options.layerID); setDefault(options, "display", options.layerID);
processComputable(options as T, "append"); processComputable(options as T, "append");