From c26408f863fbfeb7860196c19f9852db14444081 Mon Sep 17 00:00:00 2001 From: Ajick Date: Thu, 28 Dec 2023 18:42:54 +0500 Subject: [PATCH] feat: Added refresh players list button. --- locale/en/strings.cfg | 3 ++- locale/ru/strings.cfg | 1 + scripts/players_inventory/main_window.lua | 31 ++++++++++++++++++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/locale/en/strings.cfg b/locale/en/strings.cfg index 63befcb..bcf6fcb 100644 --- a/locale/en/strings.cfg +++ b/locale/en/strings.cfg @@ -112,7 +112,8 @@ tooltip-mute=Mute tooltip-no-more-admin=Dismiss Admin tooltip-no-more-manager=Dismiss Manager tooltip-open-inventory=Open inventory -tooltip-reason=Reason: __1__ +tooltip-reason=Reason: __1_ +tooltip-refresh-list=Refresh list tooltip-set-admin=Make an Admin tooltip-set-manager=Make a Manager tooltip-unban=Unban diff --git a/locale/ru/strings.cfg b/locale/ru/strings.cfg index 80c59d3..d3a2222 100644 --- a/locale/ru/strings.cfg +++ b/locale/ru/strings.cfg @@ -111,6 +111,7 @@ tooltip-kick=Выгнать tooltip-mute=Запретить писать сообщения (заглушить) tooltip-open-inventory=Открыть инвентарь tooltip-reason=Причина: __1__ +tooltip-refresh-list=Обновить список tooltip-set-admin=Сделать Админом tooltip-set-manager=Сделать Руководителем tooltip-unban=Разбанить diff --git a/scripts/players_inventory/main_window.lua b/scripts/players_inventory/main_window.lua index 6897da1..b25bd91 100644 --- a/scripts/players_inventory/main_window.lua +++ b/scripts/players_inventory/main_window.lua @@ -339,7 +339,6 @@ function MainWindow.create(player_index) style = "frame_action_button", elem_type="item" } - -- elem_type="item" filter_controls.search_item.style.top_margin = 2 filter_controls.search_item.style.left_margin = 5 filter_controls.search_item.style.size = 35 @@ -351,6 +350,22 @@ function MainWindow.create(player_index) MainWindow.filter_controls[player_index] = filter_controls + -- Spacer to the right + local filters_spacer = filters_container.add{type="empty-widget", ignored_by_interaction=true} + filters_spacer.style.horizontally_stretchable = true + + -- Refresh button + local refresh_list = filters_container.add{ + type = "sprite-button", + name = "players_inventory_refresh_list_button", + sprite = "utility/reset_white", + hovered_sprite = "utility/reset", + clicked_sprite = "utility/reset", + style = "frame_action_button", + tooltip = {"players-inventory.tooltip-refresh-list"} + } + refresh_list.style.top_margin = 2 + -- Players list -- @@ -556,6 +571,9 @@ function MainWindow.fill_list(player_index) ---@diagnostic disable-next-line: param-type-mismatch MainWindow.add_player(players_list, player, filters) end + + ---@diagnostic disable-next-line: need-check-nil + players_list.scroll_to_top() end -- Adds player bar into players list @@ -1718,6 +1736,16 @@ function MainWindow.on_clear_find_player_button_click(event) end end +-- On refresh players list button click +---@param event Event +function MainWindow.on_refresh_list_button_click(event) + if not event or not event.player_index then + return + end + + MainWindow.fill_list(event.player_index) +end + -- On open players inventory button click ---@param event Event function MainWindow.on_open_inventory_button_click(event) @@ -2210,6 +2238,7 @@ end MainWindow.on_gui_click_handlers = { ["players_inventory_close_window_button"] = MainWindow.on_close_button_click, ["players_inventory_clear_find_player_button"] = MainWindow.on_clear_find_player_button_click, + ["players_inventory_refresh_list_button"] = MainWindow.on_refresh_list_button_click, ["players_inventory_open_inventory_button"] = MainWindow.on_open_inventory_button_click, ["players_inventory_fix_permossions_button"] = MainWindow.on_fix_permossions_button_click, ["players_inventory_follow_button"] = MainWindow.on_follow_button_click,