Mutators: added "no mutators" text to GUI
This commit is contained in:
parent
6eff68f0ae
commit
aa2fabd636
2 changed files with 87 additions and 20 deletions
|
@ -9,6 +9,7 @@ local _DEFINITIONS = dofile("scripts/mods/vmf/modules/ui/mutators/mutators_gui_d
|
||||||
local _UI_SCENEGRAPH
|
local _UI_SCENEGRAPH
|
||||||
local _MUTATOR_LIST_WIDGETS = {}
|
local _MUTATOR_LIST_WIDGETS = {}
|
||||||
local _PARTY_BUTTON_WIDGET
|
local _PARTY_BUTTON_WIDGET
|
||||||
|
local _NO_MUTATORS_TEXT_WIDGET
|
||||||
local _OTHER_WIDGETS = {}
|
local _OTHER_WIDGETS = {}
|
||||||
|
|
||||||
local _ORIGINAL_VALUES = {} -- @TODO: get rid of it?
|
local _ORIGINAL_VALUES = {} -- @TODO: get rid of it?
|
||||||
|
@ -278,6 +279,9 @@ local function initialize_mutators_ui(map_view)
|
||||||
-- Party button
|
-- Party button
|
||||||
_PARTY_BUTTON_WIDGET = UIWidget.init(_DEFINITIONS.party_button_widget_defenition)
|
_PARTY_BUTTON_WIDGET = UIWidget.init(_DEFINITIONS.party_button_widget_defenition)
|
||||||
|
|
||||||
|
-- "No mutators installed" text
|
||||||
|
_NO_MUTATORS_TEXT_WIDGET = UIWidget.init(_DEFINITIONS.no_mutators_text_widget)
|
||||||
|
|
||||||
-- Other widgets
|
-- Other widgets
|
||||||
for widget_name, widget in pairs(_DEFINITIONS.widgets_definition) do
|
for widget_name, widget in pairs(_DEFINITIONS.widgets_definition) do
|
||||||
_OTHER_WIDGETS[widget_name] = UIWidget.init(widget)
|
_OTHER_WIDGETS[widget_name] = UIWidget.init(widget)
|
||||||
|
@ -305,7 +309,7 @@ local function draw(map_view, dt)
|
||||||
UIRenderer.draw_widget(ui_renderer, _PARTY_BUTTON_WIDGET)
|
UIRenderer.draw_widget(ui_renderer, _PARTY_BUTTON_WIDGET)
|
||||||
|
|
||||||
if _IS_MUTATOR_LIST_VISIBLE then
|
if _IS_MUTATOR_LIST_VISIBLE then
|
||||||
|
if #_MUTATORS > 0 then
|
||||||
-- Mutator list (render only 8 (or less) currently visible mutator widgets)
|
-- Mutator list (render only 8 (or less) currently visible mutator widgets)
|
||||||
for i = ((_CURRENT_PAGE_NUMBER - 1) * 8 + 1), (_CURRENT_PAGE_NUMBER * 8) do
|
for i = ((_CURRENT_PAGE_NUMBER - 1) * 8 + 1), (_CURRENT_PAGE_NUMBER * 8) do
|
||||||
if not _MUTATOR_LIST_WIDGETS[i] then
|
if not _MUTATOR_LIST_WIDGETS[i] then
|
||||||
|
@ -313,6 +317,9 @@ local function draw(map_view, dt)
|
||||||
end
|
end
|
||||||
UIRenderer.draw_widget(ui_renderer, _MUTATOR_LIST_WIDGETS[i])
|
UIRenderer.draw_widget(ui_renderer, _MUTATOR_LIST_WIDGETS[i])
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
UIRenderer.draw_widget(ui_renderer, _NO_MUTATORS_TEXT_WIDGET)
|
||||||
|
end
|
||||||
|
|
||||||
-- Other widgets
|
-- Other widgets
|
||||||
for _, widget in pairs(_OTHER_WIDGETS) do
|
for _, widget in pairs(_OTHER_WIDGETS) do
|
||||||
|
|
|
@ -62,6 +62,16 @@ local scenegraph_definition = {
|
||||||
horizontal_alignment = "left"
|
horizontal_alignment = "left"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
sg_no_mutators_text = {
|
||||||
|
size = {310, 30},
|
||||||
|
position = {0, 10, 1},
|
||||||
|
|
||||||
|
parent = "sg_mutators_list",
|
||||||
|
|
||||||
|
vertical_alignment = "center",
|
||||||
|
horizontal_alignment = "center",
|
||||||
|
},
|
||||||
|
|
||||||
sg_scrollbar = {
|
sg_scrollbar = {
|
||||||
size = {0, 290}, -- X size doesn't affect scrollbar width
|
size = {0, 290}, -- X size doesn't affect scrollbar width
|
||||||
position = {452, 52, 3},
|
position = {452, 52, 3},
|
||||||
|
@ -137,11 +147,10 @@ local widgets_definition = {
|
||||||
style = {}
|
style = {}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
-- Scrollbar
|
||||||
scrollbar = UIWidgets.create_scrollbar(scenegraph_definition.sg_scrollbar.size[2], "sg_scrollbar")
|
scrollbar = UIWidgets.create_scrollbar(scenegraph_definition.sg_scrollbar.size[2], "sg_scrollbar")
|
||||||
}
|
}
|
||||||
|
widgets_definition.scrollbar.content.disable_frame = true -- Hide scrollbar frame
|
||||||
-- Hide scrollbar frame
|
|
||||||
widgets_definition.scrollbar.content.disable_frame = true
|
|
||||||
|
|
||||||
-- The 4th button, which will toggle old "Party" view (which is replaced by "Mutators" view)
|
-- The 4th button, which will toggle old "Party" view (which is replaced by "Mutators" view)
|
||||||
local party_button_widget_defenition = UIWidgets.create_octagon_button(
|
local party_button_widget_defenition = UIWidgets.create_octagon_button(
|
||||||
|
@ -156,17 +165,73 @@ local party_button_widget_defenition = UIWidgets.create_octagon_button(
|
||||||
"sg_mutators_button"
|
"sg_mutators_button"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
-- Text displayed when user has 0 mutators
|
||||||
|
local no_mutators_text_widget = {
|
||||||
|
scenegraph_id = "sg_no_mutators_text",
|
||||||
|
element = {
|
||||||
|
passes = {
|
||||||
|
{
|
||||||
|
pass_type = "text",
|
||||||
|
|
||||||
|
style_id = "text",
|
||||||
|
text_id = "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pass_type = "hotspot",
|
||||||
|
|
||||||
|
content_id = "tooltip_hotspot"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pass_type = "tooltip_text",
|
||||||
|
|
||||||
|
style_id = "tooltip_text",
|
||||||
|
text_id = "tooltip_text",
|
||||||
|
content_check_function = function (ui_content)
|
||||||
|
return ui_content.tooltip_hotspot.is_hover
|
||||||
|
end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
content = {
|
||||||
|
text = vmf:localize("no_mutators"),
|
||||||
|
tooltip_text = vmf:localize("no_mutators_tooltip"),
|
||||||
|
tooltip_hotspot = {},
|
||||||
|
color = Colors.get_color_table_with_alpha("slate_gray", 255)
|
||||||
|
},
|
||||||
|
style = {
|
||||||
|
|
||||||
|
text = {
|
||||||
|
vertical_alignment = "center",
|
||||||
|
horizontal_alignment = "center",
|
||||||
|
font_size = 22,
|
||||||
|
localize = false,
|
||||||
|
word_wrap = true,
|
||||||
|
font_type = "hell_shark",
|
||||||
|
text_color = Colors.get_color_table_with_alpha("slate_gray", 255),
|
||||||
|
offset = {0, 2, 4}
|
||||||
|
},
|
||||||
|
|
||||||
|
tooltip_text = {
|
||||||
|
font_size = 24,
|
||||||
|
max_width = 500,
|
||||||
|
localize = false,
|
||||||
|
horizontal_alignment = "left",
|
||||||
|
vertical_alignment = "top",
|
||||||
|
font_type = "hell_shark",
|
||||||
|
text_color = Colors.get_color_table_with_alpha("white", 255),
|
||||||
|
line_colors = {},
|
||||||
|
offset = {0, 0, 50}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
-- Creates a widget for every mutator (that string with checkbox)
|
-- Creates a widget for every mutator (that string with checkbox)
|
||||||
local function create_mutator_widget(mutator, offset_function_callback)
|
local function create_mutator_widget(mutator, offset_function_callback)
|
||||||
return {
|
return {
|
||||||
scenegraph_id = "sg_mutators_list_start",
|
scenegraph_id = "sg_mutators_list_start",
|
||||||
element = {
|
element = {
|
||||||
passes = {
|
passes = {
|
||||||
-- {
|
|
||||||
-- pass_type = "rect",
|
|
||||||
|
|
||||||
-- style_id = "mutators_list_background"
|
|
||||||
-- },
|
|
||||||
{
|
{
|
||||||
pass_type = "hotspot",
|
pass_type = "hotspot",
|
||||||
|
|
||||||
|
@ -236,12 +301,6 @@ local function create_mutator_widget(mutator, offset_function_callback)
|
||||||
},
|
},
|
||||||
style = {
|
style = {
|
||||||
|
|
||||||
-- mutators_list_background = {
|
|
||||||
-- --scenegraph_id = "sg_mutators_list_start",
|
|
||||||
-- size = {370, 32},
|
|
||||||
-- color = {math.random(255), math.random(255), math.random(255), 255}
|
|
||||||
-- },
|
|
||||||
|
|
||||||
text = {
|
text = {
|
||||||
offset = {10, -2, 2},
|
offset = {10, -2, 2},
|
||||||
font_size = 24,
|
font_size = 24,
|
||||||
|
@ -282,5 +341,6 @@ return {
|
||||||
scenegraph_definition = scenegraph_definition,
|
scenegraph_definition = scenegraph_definition,
|
||||||
widgets_definition = widgets_definition,
|
widgets_definition = widgets_definition,
|
||||||
party_button_widget_defenition = party_button_widget_defenition,
|
party_button_widget_defenition = party_button_widget_defenition,
|
||||||
|
no_mutators_text_widget = no_mutators_text_widget,
|
||||||
create_mutator_widget = create_mutator_widget
|
create_mutator_widget = create_mutator_widget
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue