mirror of
https://github.com/pdxlocations/contact.git
synced 2026-06-26 21:11:11 +02:00
fix positions
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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},
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user