Skip to content

Commit

Permalink
Update load.py
Browse files Browse the repository at this point in the history
fixing #32 and also reset button behaviour

doing the change I hinted at in my comment of #30
also proper rounding before value was just trunctated
though there are a few edgecases I've found that don't round properly

concerning #31 :
small fix where distance was always red if there wasn't even a position logged.
  • Loading branch information
Balvald committed Jan 3, 2023
1 parent 9e04747 commit 495e55c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions load.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ def reset(self) -> None:
self.AST_state.set("None")
self.rawvalue = 0
self.AST_value.set("0 Cr.")
self.AST_scan_1_pos_vector = [None, None]
self.AST_scan_2_pos_vector = [None, None]

def clipboard(self) -> None:
"""Copy value to clipboard."""
Expand Down Expand Up @@ -640,6 +642,7 @@ def bioscan_event(cmdr: str, is_beta, entry) -> None: # noqa #CCR001
plugin.AST_CCR.set(orgi.getclonalcolonialranges(orgi.genusgeneraltolocalised(entry["Genus"])))
plugin.AST_scan_1_pos_vector[0] = plugin.AST_current_pos_vector[0]
plugin.AST_scan_1_pos_vector[1] = plugin.AST_current_pos_vector[1]
plugin.AST_scan_2_pos_vector = [None, None]
plugin.on_preferences_closed(cmdr, is_beta)
elif entry["ScanType"] in ["Sample", "Analyse"]:
if (entry["ScanType"] == "Analyse"):
Expand Down Expand Up @@ -1086,23 +1089,27 @@ def rebuild_ui(plugin, cmdr: str) -> None: # noqa #CCR001
if plugin.AST_hide_CCR.get() != 1 and plugin.AST_near_planet is True:
# show distances for the last scans.
colour = "red"
if plugin.AST_current_scan_progress.get() in ["0/3", "3/3"]:
colour = None
if plugin.AST_scan_1_dist_green:
colour = "green"
ui_colourlabel(frame, "Distance to Scan #1: ", current_row, 0, colour, tk.W)
ui_colourentry(frame, plugin.AST_scan_1_pos_dist, current_row, 1, colour, tk.W)
current_row += 1
colour = "red"
if plugin.AST_current_scan_progress.get() in ["0/3", "1/3", "3/3"]:
colour = None
if plugin.AST_scan_2_dist_green:
colour = "green"
ui_colourlabel(frame, "Distance to Scan #2: ", current_row, 0, colour, tk.W)
ui_colourentry(frame, plugin.AST_scan_2_pos_dist, current_row, 1, colour, tk.W)
current_row += 1
colour = None
if ((plugin.AST_scan_1_dist_green
and plugin.AST_current_scan_progress == "1/3")
and plugin.AST_current_scan_progress.get() == "1/3")
or (plugin.AST_scan_1_dist_green
and plugin.AST_scan_2_dist_green
and plugin.AST_current_scan_progress == "2/3")):
and plugin.AST_current_scan_progress.get() == "2/3")):
colour = "green"
ui_colourlabel(frame, "Current Position: ", current_row, 0, colour, tk.W)
ui_colourentry(frame, plugin.AST_current_pos, current_row, 1, colour, tk.W)
Expand Down Expand Up @@ -1235,7 +1242,10 @@ def shortcreditstring(number):
unit = " " + prefix[prefixindex] + "Cr."
index = fullstring.find(",") + 1
fullstring = fullstring[:index].replace(",", ".")+fullstring[index:].replace(",", "")
fullstring = f"{float(fullstring):.6f}"[:5]
fullstring = f"{round(float(fullstring), (4-index+1)):.6f}"[:5]
if fullstring[1] == ".":
fullstring = fullstring[0] + "," + fullstring[2:]
unit = " " + prefix[prefixindex-1] + "Cr."
return fullstring + unit


Expand Down

0 comments on commit 495e55c

Please sign in to comment.