2024-08-10 19:26:52 +02:00
|
|
|
-- Generic GUI stuff goes here.
|
|
|
|
|
2024-09-09 20:20:52 +02:00
|
|
|
GENERIC_GUI_MAX_HEIGHT = 500
|
|
|
|
|
2024-08-10 19:26:52 +02:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- GUI Styles
|
|
|
|
--------------------------------------------------------------------------------
|
2024-09-05 19:18:47 +02:00
|
|
|
---@type LuaStyle
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
2024-08-10 19:26:52 +02:00
|
|
|
my_fixed_width_style = {
|
|
|
|
minimal_width = 450,
|
|
|
|
maximal_width = 450
|
|
|
|
}
|
2024-09-05 19:18:47 +02:00
|
|
|
---@type LuaStyle
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
2024-08-10 19:26:52 +02:00
|
|
|
my_label_style = {
|
|
|
|
-- minimal_width = 450,
|
|
|
|
-- maximal_width = 50,
|
|
|
|
single_line = false,
|
|
|
|
font_color = {r=1,g=1,b=1},
|
|
|
|
top_padding = 0,
|
|
|
|
bottom_padding = 0
|
|
|
|
}
|
2024-09-05 19:18:47 +02:00
|
|
|
---@type LuaStyle
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
2024-08-10 19:26:52 +02:00
|
|
|
my_label_header_style = {
|
|
|
|
single_line = false,
|
|
|
|
font = "heading-1",
|
|
|
|
font_color = {r=1,g=1,b=1},
|
|
|
|
top_padding = 0,
|
|
|
|
bottom_padding = 0
|
|
|
|
}
|
2024-09-05 19:18:47 +02:00
|
|
|
---@type LuaStyle
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
2024-09-07 03:10:29 +02:00
|
|
|
my_label_header2_style = {
|
|
|
|
single_line = false,
|
|
|
|
font = "heading-2",
|
|
|
|
font_color = {r=1,g=1,b=1},
|
|
|
|
top_padding = 0,
|
|
|
|
bottom_padding = 0
|
|
|
|
}
|
|
|
|
---@type LuaStyle
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
2024-08-10 19:26:52 +02:00
|
|
|
my_label_header_grey_style = {
|
|
|
|
single_line = false,
|
|
|
|
font = "heading-1",
|
|
|
|
font_color = {r=0.6,g=0.6,b=0.6},
|
|
|
|
top_padding = 0,
|
|
|
|
bottom_padding = 0
|
|
|
|
}
|
2024-09-05 19:18:47 +02:00
|
|
|
---@type LuaStyle
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
2024-08-10 19:26:52 +02:00
|
|
|
my_note_style = {
|
|
|
|
-- minimal_width = 450,
|
|
|
|
single_line = false,
|
2024-09-05 19:18:47 +02:00
|
|
|
font = "default-semibold",
|
2024-08-10 19:26:52 +02:00
|
|
|
font_color = {r=1,g=0.5,b=0.5},
|
|
|
|
top_padding = 0,
|
|
|
|
bottom_padding = 0
|
|
|
|
}
|
2024-10-06 21:28:16 +02:00
|
|
|
|
2024-09-05 19:18:47 +02:00
|
|
|
---@type LuaStyle
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
2024-08-10 19:26:52 +02:00
|
|
|
my_warning_style = {
|
|
|
|
-- minimal_width = 450,
|
|
|
|
-- maximal_width = 450,
|
|
|
|
single_line = false,
|
2024-09-06 03:15:56 +02:00
|
|
|
font = "default-bold",
|
|
|
|
font_color = {r=1,g=0.3,b=0.3},
|
2024-08-10 19:26:52 +02:00
|
|
|
top_padding = 0,
|
|
|
|
bottom_padding = 0
|
|
|
|
}
|
2024-09-05 19:18:47 +02:00
|
|
|
---@type LuaStyle
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
2024-08-10 19:26:52 +02:00
|
|
|
my_spacer_style = {
|
|
|
|
minimal_height = 10,
|
|
|
|
top_padding = 0,
|
|
|
|
bottom_padding = 0
|
|
|
|
}
|
2024-09-05 19:18:47 +02:00
|
|
|
---@type LuaStyle
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
2024-08-10 19:26:52 +02:00
|
|
|
my_small_button_style = {
|
|
|
|
font = "default-small-semibold"
|
|
|
|
}
|
2024-09-05 19:18:47 +02:00
|
|
|
---@type LuaStyle
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
2024-08-10 19:26:52 +02:00
|
|
|
my_player_list_fixed_width_style = {
|
|
|
|
minimal_width = 200,
|
|
|
|
maximal_width = 400,
|
|
|
|
maximal_height = 200
|
|
|
|
}
|
2024-09-05 19:18:47 +02:00
|
|
|
---@type LuaStyle
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
2024-08-10 19:26:52 +02:00
|
|
|
my_shared_item_list_fixed_width_style = {
|
|
|
|
minimal_width = 200,
|
|
|
|
maximal_width = 600,
|
|
|
|
maximal_height = 600
|
|
|
|
}
|
2024-09-05 19:18:47 +02:00
|
|
|
---@type LuaStyle
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
2024-08-10 19:26:52 +02:00
|
|
|
my_player_list_admin_style = {
|
|
|
|
font = "default-semibold",
|
2024-10-04 20:10:11 +02:00
|
|
|
font_color = { r=0.9, g=0.7, b=0.3 },
|
2024-10-04 19:27:42 +02:00
|
|
|
-- minimal_width = 200,
|
2024-08-10 19:26:52 +02:00
|
|
|
top_padding = 0,
|
|
|
|
bottom_padding = 0,
|
|
|
|
single_line = false,
|
|
|
|
}
|
2024-09-05 19:18:47 +02:00
|
|
|
---@type LuaStyle
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
2024-08-10 19:26:52 +02:00
|
|
|
my_player_list_style = {
|
|
|
|
font = "default-semibold",
|
2024-10-04 19:27:42 +02:00
|
|
|
-- minimal_width = 200,
|
2024-08-10 19:26:52 +02:00
|
|
|
top_padding = 0,
|
|
|
|
bottom_padding = 0,
|
|
|
|
single_line = false,
|
|
|
|
}
|
2024-09-05 19:18:47 +02:00
|
|
|
---@type LuaStyle
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
2024-08-10 19:26:52 +02:00
|
|
|
my_player_list_offline_style = {
|
|
|
|
-- font = "default-semibold",
|
|
|
|
font_color = {r=0.5,g=0.5,b=0.5},
|
2024-10-04 19:27:42 +02:00
|
|
|
-- minimal_width = 200,
|
2024-08-10 19:26:52 +02:00
|
|
|
top_padding = 0,
|
|
|
|
bottom_padding = 0,
|
|
|
|
single_line = false,
|
|
|
|
}
|
2024-09-05 19:18:47 +02:00
|
|
|
---@type LuaStyle
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
2024-08-10 19:26:52 +02:00
|
|
|
my_player_list_style_spacer = {
|
|
|
|
minimal_height = 20,
|
|
|
|
}
|
2024-09-05 19:18:47 +02:00
|
|
|
---@type Color
|
2024-08-10 19:26:52 +02:00
|
|
|
my_color_red = {r=1,g=0.1,b=0.1}
|
|
|
|
|
2024-09-05 19:18:47 +02:00
|
|
|
---@type LuaStyle
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
2024-08-10 19:26:52 +02:00
|
|
|
my_longer_label_style = {
|
|
|
|
maximal_width = 600,
|
|
|
|
single_line = false,
|
|
|
|
font_color = {r=1,g=1,b=1},
|
|
|
|
top_padding = 0,
|
|
|
|
bottom_padding = 0
|
|
|
|
}
|
2024-09-05 19:18:47 +02:00
|
|
|
---@type LuaStyle
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
2024-08-10 19:26:52 +02:00
|
|
|
my_longer_warning_style = {
|
|
|
|
maximal_width = 600,
|
|
|
|
single_line = false,
|
|
|
|
font_color = {r=1,g=0.1,b=0.1},
|
|
|
|
top_padding = 0,
|
|
|
|
bottom_padding = 0
|
|
|
|
}
|
2024-09-05 19:18:47 +02:00
|
|
|
---@type LuaStyle
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
2024-08-10 19:26:52 +02:00
|
|
|
my_notepad_fixed_width_style = {
|
|
|
|
minimal_width = 600,
|
|
|
|
maximal_width = 600,
|
|
|
|
minimal_height = 300,
|
|
|
|
maximal_height = 300,
|
|
|
|
font = "default-small-semibold",
|
|
|
|
font_color = {r=0.2,g=0.3,b=0.4},
|
|
|
|
top_margin = 5,
|
|
|
|
bottom_margin = 5
|
|
|
|
}
|
2024-12-04 03:03:39 +02:00
|
|
|
---@type LuaStyle
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
|
|
|
my_player_list_surface_max_width_style = {
|
|
|
|
maximal_width = 200
|
|
|
|
}
|
2024-08-10 19:26:52 +02:00
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- GUI Functions
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
2024-08-22 02:46:29 +02:00
|
|
|
---Apply a style option to a GUI
|
|
|
|
---@param gui_element LuaGuiElement
|
|
|
|
---@param style_in table
|
|
|
|
---@return nil
|
|
|
|
function ApplyStyle (gui_element, style_in)
|
|
|
|
for k,v in pairs(style_in) do
|
|
|
|
gui_element.style[k]=v
|
2024-08-10 19:26:52 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-08-22 02:46:29 +02:00
|
|
|
---Shorter way to add a label with a style
|
|
|
|
---@param gui_element LuaGuiElement
|
|
|
|
---@param name string?
|
|
|
|
---@param message LocalisedString
|
|
|
|
---@param style table|string
|
2024-09-05 19:18:47 +02:00
|
|
|
---@return LuaGuiElement
|
2024-08-22 02:46:29 +02:00
|
|
|
function AddLabel(gui_element, name, message, style)
|
|
|
|
local g = gui_element.add{name = name, type = "label", caption=message}
|
2024-08-10 19:26:52 +02:00
|
|
|
if (type(style) == "table") then
|
|
|
|
ApplyStyle(g, style)
|
|
|
|
else
|
|
|
|
g.style = style
|
|
|
|
end
|
2024-09-05 19:18:47 +02:00
|
|
|
return g
|
2024-08-10 19:26:52 +02:00
|
|
|
end
|
|
|
|
|
2024-08-22 02:46:29 +02:00
|
|
|
---Shorter way to add a spacer
|
|
|
|
---@param gui_element LuaGuiElement
|
|
|
|
---@return nil
|
|
|
|
function AddSpacer(gui_element)
|
|
|
|
ApplyStyle(gui_element.add{type = "label", caption=" "}, my_spacer_style)
|
2024-08-10 19:26:52 +02:00
|
|
|
end
|
|
|
|
|
2024-08-22 02:46:29 +02:00
|
|
|
---Shorter way to add a spacer line
|
|
|
|
---@param gui_element LuaGuiElement
|
|
|
|
---@return nil
|
|
|
|
function AddSpacerLine(gui_element)
|
|
|
|
ApplyStyle(gui_element.add{type = "line", direction="horizontal"}, my_spacer_style)
|
2024-08-10 19:26:52 +02:00
|
|
|
end
|