Skip to content

Commit 1d2061b

Browse files
committed
show args control
1 parent a510667 commit 1d2061b

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

src/app/actionSelection.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import inspect from "@rbxts/inspect"
22
import Roact, { memo, useMemo } from "@rbxts/roact"
3-
import { useRootProducer } from "store"
3+
import { useRootProducer, useRootSelector } from "store"
44
import { Action } from "store/game"
55

66
interface Props {
@@ -12,6 +12,8 @@ interface Props {
1212
export const ActionSelection = memo((props: Props) => {
1313
const store = useRootProducer()
1414

15+
const showArgs = useRootSelector(state => state.widget.showArgs)
16+
1517
const inspectedArgs = useMemo(() => inspect(props.action.args), [props.action])
1618

1719
const formattedTimestamp = DateTime.fromUnixTimestampMillis(props.action.timestamp).FormatLocalTime(
@@ -67,6 +69,7 @@ export const ActionSelection = memo((props: Props) => {
6769
TextSize={16}
6870
TextWrapped
6971
TextXAlignment={Enum.TextXAlignment.Left}
72+
Visible={showArgs}
7073
key="args"
7174
/>
7275
)}

src/app/index.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export function App() {
1717
const actions = useRootSelector(state => state.game.actions)
1818
const selectedIndex = useRootSelector(state => state.widget.selectedIndex)
1919
const autoSelectLatest = useRootSelector(state => state.widget.autoSelectLatest)
20+
const showArgs = useRootSelector(state => state.widget.showArgs)
2021

2122
const selectedAction = selectedIndex !== undefined ? actions[selectedIndex] : undefined
2223

@@ -55,6 +56,11 @@ export function App() {
5556
/>
5657
<RowText order={4} text={`Selection Mode: ${autoSelectLatest ? "Auto" : "Manual"}`} />
5758

59+
<RowText order={3} text="•" />
60+
61+
<RowButton key="showargs" onClick={() => store.changeShowArgs(!showArgs)} order={5} text="Toggle" />
62+
<RowText order={6} text={`Show Args: ${showArgs ? "Yes" : "No"}`} />
63+
5864
<uilistlayout
5965
FillDirection={Enum.FillDirection.Horizontal}
6066
HorizontalAlignment={Enum.HorizontalAlignment.Left}

src/store/widget.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ export interface Widget {
66
open: boolean
77
selectedIndex?: number
88
autoSelectLatest: boolean
9+
showArgs: boolean
910
}
1011

1112
const initialState: Widget = {
1213
open: false,
13-
autoSelectLatest: true
14+
autoSelectLatest: true,
15+
showArgs: true
1416
}
1517

1618
export const widget = createProducer(initialState, {
@@ -26,5 +28,9 @@ export const widget = createProducer(initialState, {
2628
changeAutoSelectMode: (state, mode: boolean) => ({
2729
...state,
2830
autoSelectLatest: mode
31+
}),
32+
changeShowArgs: (state, show: boolean) => ({
33+
...state,
34+
showArgs: show
2935
})
3036
})

0 commit comments

Comments
 (0)