Skip to content

Commit

Permalink
feat: Added refresh players list button.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajick2013 committed Dec 28, 2023
1 parent 7418fc1 commit c26408f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
3 changes: 2 additions & 1 deletion locale/en/strings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions locale/ru/strings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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=Разбанить
Expand Down
31 changes: 30 additions & 1 deletion scripts/players_inventory/main_window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 --

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c26408f

Please sign in to comment.