fix positions

This commit is contained in:
pdxlocations
2025-07-26 00:55:41 -07:00
parent a8680ac0ed
commit 7a61808f47
3 changed files with 19 additions and 4 deletions
+1 -1
View File
@@ -427,7 +427,7 @@ def settings_menu(stdscr: object, interface: object) -> None:
elif selected_option in ["latitude", "longitude", "altitude"]:
new_value = get_text_input(
f"{human_readable_name} is currently: {current_value}", selected_option, None
f"{human_readable_name} is currently: {current_value}", selected_option, float
)
new_value = current_value if new_value is None else new_value
menu_state.current_menu[selected_option] = (field, new_value)
+11 -3
View File
@@ -102,12 +102,16 @@ def get_text_input(prompt: str, selected_config: str, input_type: str) -> Option
elif input_type is float:
try:
float(user_input)
float_val = float(user_input)
if not (min_value <= float_val <= max_value):
invalid_input(input_win, f"Enter a number between {min_value} and {max_value}.")
continue
except ValueError:
invalid_input(input_win, "Must be a valid floating point number.")
continue
else:
break
curses.curs_set(0)
return float_val
else:
break
@@ -123,7 +127,11 @@ def get_text_input(prompt: str, selected_config: str, input_type: str) -> Option
if char.isdigit():
user_input += char
elif input_type is float:
if char.isdigit() or (char == "." and "." not in user_input):
if (
char.isdigit()
or (char == "." and "." not in user_input)
or (char == "-" and len(user_input) == 0)
):
user_input += char
else:
user_input += char
+7
View File
@@ -5,6 +5,13 @@ validation_rules = {
"position_flags": {"max_length": 3},
"enabled_protocols": {"max_value": 2},
"hop_limit": {"max_value": 7},
"latitude": {"min_value": -90, "max_value": 90},
"longitude": {"min_value": -180, "max_value": 180},
"altitude": {"min_value": -4294967295, "max_value": 4294967295},
"red": {"max_value": 255},
"green": {"max_value": 255},
"blue": {"max_value": 255},
"current": {"max_value": 255},
}