Skip to content

Commit

Permalink
resolve decimal place issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mullenpaul committed Feb 5, 2024
1 parent b2caa84 commit 73cd773
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions code/modules/tgui/tgui_number_input.dm
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
"min_value" = min_value,
"preferences" = list(),
"title" = title,
"integer_only" = integer_only
)

/datum/tgui_input_number/ui_data(mob/user)
Expand Down
20 changes: 17 additions & 3 deletions tgui/packages/tgui/interfaces/NumberInputModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@ type NumberInputData = {
min_value: number | null;
timeout: number;
title: string;
integer_only: 0 | 1;
};

export const NumberInputModal = () => {
const { act, data } = useBackend<NumberInputData>();
const { init_value, large_buttons, message = '', timeout, title } = data;
const {
init_value,
large_buttons,
message = '',
timeout,
title,
integer_only,
} = data;
const [input, setInput] = useLocalState('input', init_value);
const onChange = (value: number) => {
if (value === input) {
Expand Down Expand Up @@ -56,7 +64,12 @@ export const NumberInputModal = () => {
<Box color="label">{message}</Box>
</Stack.Item>
<Stack.Item>
<InputArea input={input} onClick={onClick} onChange={onChange} />
<InputArea
input={input}
onClick={onClick}
onChange={onChange}
integer_only={integer_only}
/>
</Stack.Item>
<Stack.Item>
<InputButtons input={input} />
Expand All @@ -72,7 +85,7 @@ export const NumberInputModal = () => {
const InputArea = (props) => {
const { act, data } = useBackend<NumberInputData>();
const { min_value, max_value, init_value } = data;
const { input, onClick, onChange } = props;
const { input, onClick, onChange, integer_only } = props;

return (
<Stack fill>
Expand All @@ -94,6 +107,7 @@ const InputArea = (props) => {
onChange={(_, value) => onChange(value)}
onEnter={(_, value) => act('submit', { entry: value })}
value={input}
allowFloats={integer_only === 1 ? false : true}
/>
</Stack.Item>
<Stack.Item>
Expand Down

0 comments on commit 73cd773

Please sign in to comment.