mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-27 23:57:13 +09:00
.
This commit is contained in:
1 parent
941f7974c4
commit
a3860c91e1
1 file changed
+10
-15
@@ -83,14 +83,13 @@ Elements.calculator_input_textfield = Gui.define("calculator/input_textfield")
|
|||||||
width = 400,
|
width = 400,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Output text box
|
--- Output label
|
||||||
Elements.calculator_result_text_box = Gui.define("calculator/result_text_box")
|
Elements.calculator_result_label = Gui.define("calculator/result_label")
|
||||||
:draw{
|
:draw{
|
||||||
type = "text-box",
|
type = "label",
|
||||||
caption = "",
|
caption = "",
|
||||||
text = "",
|
name = "calculator_result_label",
|
||||||
read_only = true,
|
style = "heading_2_label",
|
||||||
name = "calculator_result_text_box",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Container added to the screen
|
--- Container added to the screen
|
||||||
@@ -99,7 +98,7 @@ Elements.container = Gui.define("calculator/container")
|
|||||||
local screen_frame = Gui.elements.screen_frame(parent, nil, true)
|
local screen_frame = Gui.elements.screen_frame(parent, nil, true)
|
||||||
local header = Gui.elements.header(screen_frame, { caption = { "exp-gui_calculator.tooltip" } })
|
local header = Gui.elements.header(screen_frame, { caption = { "exp-gui_calculator.tooltip" } })
|
||||||
Elements.calculator_input_textfield(screen_frame)
|
Elements.calculator_input_textfield(screen_frame)
|
||||||
Elements.calculator_result_text_box(screen_frame)
|
Elements.calculator_result_label(screen_frame)
|
||||||
Elements.calculator_info_label(screen_frame)
|
Elements.calculator_info_label(screen_frame)
|
||||||
return Gui.elements.screen_frame.get_root_element(screen_frame)
|
return Gui.elements.screen_frame.get_root_element(screen_frame)
|
||||||
end)
|
end)
|
||||||
@@ -328,22 +327,18 @@ end
|
|||||||
|
|
||||||
--- Value change
|
--- Value change
|
||||||
function Elements.change(event)
|
function Elements.change(event)
|
||||||
local label = event.element.parent.calculator_result_text_box
|
local label = event.element.parent.calculator_result_label
|
||||||
|
|
||||||
if event.text == "" then
|
if event.text == "" then
|
||||||
label.caption = ""
|
label.caption = ""
|
||||||
label.text = ""
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local ok, result = Elements.parse(event.text:lower())
|
local ok, result = Elements.parse(event.text:lower())
|
||||||
label.style.font_color = ok and {1, 1, 1} or {1, 0, 0}
|
label.style.font_color = ok and {1, 1, 1} or {1, 0, 0}
|
||||||
|
label.caption = ok
|
||||||
if ok then
|
and ("= " .. format_number(result, false))
|
||||||
label.text = "= " .. format_number(result, false)
|
or (type(result) == "table" and result or {"", {"exp-gui_calculator.error"}, tostring(result)})
|
||||||
else
|
|
||||||
label.caption = type(result) == "table" and result or {"", {"exp-gui_calculator.error"}, tostring(result)}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local e = defines.events
|
local e = defines.events
|
||||||
|
|||||||
Reference in new issue
Block a user