diff --git a/info.json b/info.json index 40c309a..85628c6 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "Fed1sServerMod", - "version": "1.1.4", + "version": "1.1.5", "title": "Fed1sServerMod", "author": "danbka33", "contact": "", diff --git a/locale/en/strings.cfg b/locale/en/strings.cfg index 1e855e3..37976da 100644 --- a/locale/en/strings.cfg +++ b/locale/en/strings.cfg @@ -83,6 +83,7 @@ message-demoted=Player __1__ in no longer a Manager message-inventory-full=There is no space in the inventory for given items type. message-no-items=__1__ already don't have items: __2__ __3__ message-promoted=__1__ is now the Manager +message-warning=__1__ has been warned __2__ times: __3__ tooltip-ban=Ban tooltip-button-ammo=[color=#7674ff]ctrl+click[/color] - take ammo tooltip-button-armor-only-show=[color=#7674ff]left click[/color] - show armor @@ -99,6 +100,7 @@ tooltip-unban=Unban tooltip-unfavorite=Remove from Favorites tooltip-unmute=Unmute tooltip-warn=Warn +tooltip-warnings=Warnings: [statistics] heading-1=[font=heading-1]__1__[/font] diff --git a/locale/ru/strings.cfg b/locale/ru/strings.cfg index f0f4b7d..4ff0ba0 100644 --- a/locale/ru/strings.cfg +++ b/locale/ru/strings.cfg @@ -77,12 +77,13 @@ label-online-badge=[онлайн] label-trash-inventory=Мусорные слоты label-undecided-badge=[неопределившийся] label-warnings-badge=[предупреждений: __1__] -label-warnings-info=Уже предупреждений вынесено: __1__ +label-warnings-info=Уже вынесено предупреждений: __1__ label-warrior-badge=[color=#ff8f00][атакующий][/color] message-demoted=Игрок __1__ больше не Руководитель message-inventory-full=В инвентаре больше нет места для перемещаемых предметов. message-no-items=__1__ уже успел куда-то сныкать все предметы __2__ __3__ message-promoted=__1__ теперь Руководитель +message-warning=Игроку __1__ вынесено предупреждение __2__: __3__ tooltip-ban=Забанить tooltip-button-ammo=[color=#7674ff]ctrl+click[/color] - забрать боеприпасы tooltip-button-armor-only-show=[color=#7674ff]left click[/color] - показать броню @@ -99,6 +100,7 @@ tooltip-unban=Разбанить tooltip-unfavorite=Удалить из Избранных tooltip-unmute=Разрешить писать сообщения tooltip-warn=Вынести предупреждение +tooltip-warnings=Прудпреждения: [statistics] heading-1=[font=heading-1]__1__[/font] diff --git a/scripts/players_inventory.lua b/scripts/players_inventory.lua index 1a4696c..06d155f 100644 --- a/scripts/players_inventory.lua +++ b/scripts/players_inventory.lua @@ -180,7 +180,7 @@ function PlayersInventory.settingup_and_fill_current_tab(player_index, in_search local current_tab = player_data.current_tab if current_tab.name == "favorites" and #player_filters.favorites == 0 - or current_tab.name == "warnings" and table_size(global.players_inventory_warnings) == 0 + or current_tab.name == "warnings" and #global.players_inventory_warnings == 0 or current_tab.name == "muted" and #global.players_inventory_muted == 0 or current_tab.name == "banned" and #global.players_inventory_banned == 0 then @@ -286,7 +286,7 @@ function PlayersInventory.build_player_inventory_panel(players_list, target_play local self_player = game.players[players_list.player_index] local muted = PlayersInventory.is_muted(target_player.index) local banned = PlayersInventory.is_banned(target_player.index) - local warnings = global.players_inventory_warnings[target_player.index] or 0 + local warnings = global.players_inventory_warnings[target_player.index] or {} local tab_name = PlayersInventory.players_data[self_player.index].current_tab.name local role_index = global.players_inventory_filters[self_player.index].role_index @@ -334,8 +334,8 @@ function PlayersInventory.build_player_inventory_panel(players_list, target_play end header.add{ - type="label", name="warnings", caption={"players-inventory.label-warnings-badge", warnings}, - visible=(warnings > 0) + type="label", name="warnings", caption={"players-inventory.label-warnings-badge", #warnings}, + visible=(#warnings > 0), tooltip=PlayersInventory.get_warn_tooltip(warnings) } header.add{ @@ -806,11 +806,18 @@ function PlayersInventory.build_accept_prompt_window(self_player, tags) reason_textbox.style.width = 450 reason_textbox.style.height = 100 - local player_warnings = global.players_inventory_warnings[target_player.index] or 0 + local warnings = global.players_inventory_warnings[target_player.index] or {} + local tooltip + + if #warnings > 0 then + tooltip = PlayersInventory.get_warn_tooltip(warnings) + end if tags.action == "warn" then local warn_info = window.add{ - type="label", caption={"players-inventory.label-warnings-info", player_warnings} + type = "label", + caption = {"players-inventory.label-warnings-info", #warnings}, + tooltip = tooltip } warn_info.style.font_color = {0.6 ,0.6, 0.6, 1} end @@ -843,11 +850,12 @@ function PlayersInventory.build_accept_prompt_window(self_player, tags) end function PlayersInventory.warn_player(self_index, target_player, reason) - local warnings_count = PlayersInventory.warn(target_player, reason) + local warnings = PlayersInventory.warn(target_player, reason) local current_tab = PlayersInventory.players_data[self_index].current_tab local panel = current_tab.players.list[target_player.name] - panel.header.warnings.caption = {"players-inventory.label-warnings-badge", warnings_count} + panel.header.warnings.caption = {"players-inventory.label-warnings-badge", #warnings} + panel.header.warnings.tooltip = PlayersInventory.get_warn_tooltip(warnings) panel.header.warnings.visible = true end @@ -1287,18 +1295,16 @@ function PlayersInventory.unfavorite(self_index, player_index) end function PlayersInventory.warn(target_player, reason) - local warnings_count = global.players_inventory_warnings[target_player.index] or 0 - warnings_count = warnings_count + 1 + if not global.players_inventory_warnings[target_player.index] then + global.players_inventory_warnings[target_player.index] = {} + end - global.players_inventory_warnings[target_player.index] = warnings_count + local warnings = global.players_inventory_warnings[target_player.index] + table.insert(warnings, reason) - if target_player.connected then - local counts = {"первое", "второе", "третье"} - target_player.print("Вам вынесено "..counts[warnings_count].." предупреждение:") - target_player.print(reason) - end + game.print({"players-inventory.message-warning", target_player.name, #warnings, reason}) - return warnings_count + return warnings end function PlayersInventory.mute(target_player) @@ -1347,6 +1353,16 @@ function PlayersInventory.decrise_selected(self_index, target_index) buttons.players_inventory_take_selected_button.enabled = (selected_count > 0) end +function PlayersInventory.get_warn_tooltip(warnings) + local tooltip = {"", {"players-inventory.tooltip-warnings"}} + + for index, warning in pairs(warnings) do + table.insert(tooltip, "\n" .. index .. ". " .. warning) + end + + return tooltip +end + function PlayersInventory.remove(list, item) for index = 1, #list do @@ -1371,21 +1387,19 @@ function PlayersInventory.on_init() end function PlayersInventory.on_configuration_changed(data) - PlayersInventory.on_init() - - for _, player in pairs(game.players) do - local player_filters = global.players_inventory_filters[player.index] or {} - - player_filters.favorites = player_filters.favorites or {} - player_filters.tab_index = player_filters.tab_index or 1 - player_filters.role_index = player_filters.role_index or 1 - - global.players_inventory_filters[player.index] = player_filters + if not data then + return + end - PlayersInventory.create_toggle_button(player) + if data.mod_changes + and data.mod_changes["Fed1sServerMod"] + and data.mod_changes["Fed1sServerMod"].old_version < "1.1.4" + then + global.players_inventory_warnings[2] = {} + table.insert(global.players_inventory_warnings[2], "МАЛО ПИЛ ВОДКИ НА ВЫХОДНЫХ!") end - if gebug then + if in_gebug then game.print("Configuration updated") end end @@ -1527,7 +1541,7 @@ function PlayersInventory.on_clear_search(event) event.element.parent.parent.players.visible = false event.element.parent.parent.placeholder.visible = true - PlayersInventory.player_data[event.player_index].selected = nil + PlayersInventory.players_data[event.player_index].selected = nil end function PlayersInventory.on_toggle_expand_panel(event)