Jump to content

Screen function change


Recommended Posts

From what I read about your questions I can tell you:
You questions most of the time sounds quite easy, but important information is missing.
And if I ask you about more information it turns out that the whole thing behind your question is ultra complex and difficult :D

Maybe it is because I have no knowledge about screens and this lua script, but I don't know what you mean by "functions at screen".
And what do you want to do? Do you want to change the status widgets like hunger while the game is already running?
I fear I don't have an answer, but this explanation might help to get an answer from someone who knows.

Edited by Serpens
Link to comment
Share on other sites

2 hours ago, Serpens said:

From what I read about your questions I can tell you:
You questions most of the time sounds quite easy, but important information is missing.
And if I ask you about more information it turns out that the whole thing behind your question is ultra complex and difficult :D

Maybe it is because I have no knowledge about screens and this lua script, but I don't know what you mean by "functions at screen".
And what do you want to do? Do you want to change the status widgets like hunger while the game is already running?
I fear I don't have an answer, but this explanation might help to get an answer from someone who knows.

Ok, so I want to change onclick function for view profile button in screens/playerstatusscreen.lua, so when it clicked, it'll show player's steam profile. Here's picture:12.png

Edited by makar5000
  • Like 1
Link to comment
Share on other sites

13 minutes ago, makar5000 said:

Ok, so I want to change onclick function for view profile button in screens/playerstatusscreen.lua, so when it clicked, it'll show player's steam profile.

great.
But again you missed to describe what you already know/can do.

Eg. do you already know what to put somewhere, to get the steam profil and are only looking for where to place the code?
If you already have part of the code, it will attract more users to help, since then you already did most of the work.

Link to comment
Share on other sites

1 minute ago, Serpens said:

great.
But again you missed to describe what you already know/can do.

Eg. do you already know what to put somewhere, to get the steam profil and are only looking for where to place the code?
If you already have part of the code, it will attract more users to help, since then you already did most of the work.

I allready know that in function UpdatePlayerListing I need to replace playerListing.viewprofile:SetOnClick to this:

playerListing.viewprofile:SetOnClick(
	function()
		if client.netid ~= nil then
			TheNet:ViewNetProfile(client.netid)--Вмесот этого экрана, мы открываем профиль стима
		end
	end)

 

  • Like 1
Link to comment
Share on other sites

Ok, I have no clue about screens, but maybe this is the right way to go:

Use AddClassPostConstruct("screens/playerstatusscreen",function..." to be able to change the playerstatusscreen object.
When you have this object as "self", it should be possible to just change (i is the index of player):

self.player_widgets[i].viewprofile:SetOnClick(...)

edit:
this is just my first guess. I'm sure it is not that easy :D also everytime the update function is called it might be resett... so... hmmm

edit2:
this Update function is called one time in DoInit and it seems always when

self.scroll_list = self.list_root:AddChild(ScrollableList(ClientObjs, 380, 370, 60, 5, UpdatePlayerListing, self.player_widgets, nil, nil, nil, -15))

To run your change after DoInit, you simply change the DoInit function to call DoInit and after that do your change.

But I don't know how to change the scroll_list thing that way, that your change is also present each time it calls update...
The only way I know at the moment would be to write your own UpdatePlayerListing function and replace self.scroll_list to use your new function.

Edited by Serpens
Link to comment
Share on other sites

15 minutes ago, Serpens said:

Ok, I have no clue about screens, but maybe this is the right way to go:

Use AddClassPostConstruct("screens/playerstatusscreen",function..." to be able to change the playerstatusscreen object.
When you have this object as "self", it should be possible to just change (i is the index of player):


self.player_widgets[i].viewprofile:SetOnClick(...)

edit:
this is just my first guess. I'm sure it is not that easy :D also everytime the update function is called it might be resett... so... hmmm

Thanks for trying to help!:) But it's my first time using AddClassPostConstruct... What should I use with self and player_widgets? I can't understand it at all... :D 

  • Like 1
Link to comment
Share on other sites

4 hours ago, makar5000 said:

Thanks for trying to help!:) But it's my first time using AddClassPostConstruct... What should I use with self and player_widgets? I can't understand it at all... :D 

I edited a bit into my previous post.

AddClassPostConstruct works the same like AddComponentPostInit, except that you have to add the folder name, so in this case screens, AddClassPostConstruct("screens/playerstatusscreen",function..."

Here an example of how to use it for builder replica. You can use self and such stuff the same way:
http://forums.kleientertainment.com/topic/70550-solved-recipes-availability-while-running-game/#comment-820391

 

Edited by Serpens
Link to comment
Share on other sites

Spoiler

AddClassPostConstruct("screens/playerstatusscreen",function(self)
    local _DoInit = self.DoInit
	self.DoInit = function(self, ClientObjs)
        TheInput:EnableDebugToggle(false)

        if not self.black then
            --darken everything behind the dialog
            --bleed outside the screen a bit, otherwise it may not cover
            --the edge of the screen perfectly when scaled to some sizes
            local bleeding = 4
            self.black = self:AddChild(Image("images/global.xml", "square.tex"))
            self.black:SetSize(RESOLUTION_X + bleeding, RESOLUTION_Y + bleeding)
            self.black:SetVRegPoint(ANCHOR_MIDDLE)
            self.black:SetHRegPoint(ANCHOR_MIDDLE)
            self.black:SetVAnchor(ANCHOR_MIDDLE)
            self.black:SetHAnchor(ANCHOR_MIDDLE)
            self.black:SetScaleMode(SCALEMODE_FIXEDPROPORTIONAL)
            self.black:SetTint(0,0,0,0) -- invisible, but clickable!
        end

        if not self.root then
            self.root = self:AddChild(Widget("ROOT"))
            self.root:SetScaleMode(SCALEMODE_PROPORTIONAL)
            self.root:SetHAnchor(ANCHOR_MIDDLE)
            self.root:SetVAnchor(ANCHOR_MIDDLE)
        end

        if not self.bg then
            self.bg = self.root:AddChild(Image( "images/scoreboard.xml", "scoreboard_frame.tex" ))
            self.bg:SetScale(.95,.9)
        end

        local serverNameStr = TheNet:GetServerName()
        if not self.servertitle then
            self.servertitle = self.root:AddChild(Text(UIFONT,45))
            self.servertitle:SetColour(1,1,1,1)
        end

        if not self.serverstate then
            self.serverstate = self.root:AddChild(Text(UIFONT,30))
            self.serverstate:SetColour(1,1,1,1)
        end
        self.serverage = TheWorld.state.cycles + 1
        local modeStr = GetGameModeString(TheNet:GetServerGameMode()) ~= nil and GetGameModeString(TheNet:GetServerGameMode()).." - " or ""
        self.serverstate:SetString(modeStr.." "..STRINGS.UI.PLAYERSTATUSSCREEN.AGE_PREFIX..self.serverage)

        local servermenunumbtns = 0

        self.server_group = TheNet:GetServerClanID()
        if self.server_group ~= "" and not TheInput:ControllerAttached() then
            if self.viewgroup_button == nil then
                self.viewgroup_button = self.root:AddChild(ImageButton("images/scoreboard.xml", "clan_normal.tex", "clan_hover.tex", "clan.tex", "clan.tex", nil, { .4, .4 }, { 0, 0 }))
                self.viewgroup_button:SetOnClick(function() TheNet:ViewNetProfile(self.server_group) end)
                self.viewgroup_button:SetHoverText(STRINGS.UI.SERVERLISTINGSCREEN.VIEWGROUP, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 48, colour = WHITE})
            end
            servermenunumbtns = servermenunumbtns + 1
        elseif self.viewgroup_button ~= nil then
            self.viewgroup_button:Kill()
            self.viewgroup_button = nil
        end

        if not TheInput:ControllerAttached() and #UserCommands.GetServerActions(self.owner) > 0 then
            if self.serveractions_button == nil then
                self.serveractions_button = self.root:AddChild(ImageButton("images/scoreboard.xml", "more_actions_normal.tex", "more_actions_hover.tex", "more_actions.tex", "more_actions.tex", nil, { .4, .4 }, { 0, 0 }))
                self.serveractions_button:SetOnClick(function()
                    TheFrontEnd:PopScreen()
                    self:OpenUserCommandPickerScreen(nil)
                end)
                self.serveractions_button:SetHoverText(STRINGS.UI.SERVERLISTINGSCREEN.SERVERACTIONS, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 48, colour = WHITE})
            end
            servermenunumbtns = servermenunumbtns + 1
        elseif self.serveractions_button ~= nil then
            self.serveractions_button:Kill()
            self.serveractions_button = nil
        end

        if ClientObjs == nil then
            ClientObjs = TheNet:GetClientTable() or {}
        end
        self.numPlayers = #ClientObjs

        if not self.players_number then
            self.players_number = self.root:AddChild(Text(UIFONT, 25))
            self.players_number:SetPosition(303,170) 
            self.players_number:SetRegionSize(100,30)
            self.players_number:SetHAlign(ANCHOR_RIGHT)
            self.players_number:SetColour(1,1,1,1)
        end
        self.players_number:SetString(tostring(not TheNet:GetServerIsClientHosted() and self.numPlayers - 1 or self.numPlayers).."/"..(TheNet:GetServerMaxPlayers() or "?"))

        local serverDescStr = TheNet:GetServerDescription()
        if not self.serverdesc then
            self.serverdesc = self.root:AddChild(Text(UIFONT,30))
            self.serverdesc:SetColour(1,1,1,1)
        end

        if not self.divider then
            self.divider = self.root:AddChild(Image("images/scoreboard.xml", "white_line.tex"))
        end

        local servermenux = -329
        local servermenubtnoffs = 24
        if self.viewgroup_button ~= nil then
            self.viewgroup_button:SetPosition(servermenux - (servermenunumbtns > 1 and servermenubtnoffs or 0), 200)
        end
        if self.serveractions_button ~= nil then
            self.serveractions_button:SetPosition(servermenux + (servermenunumbtns > 1 and servermenubtnoffs or 0), 200)
        end

        if serverDescStr == "" then
            self.servertitle:SetPosition(0,215)
            self.serverdesc:SetPosition(0,175)
            self.serverstate:SetPosition(0,175)
            self.divider:SetPosition(0,155)
        else
            self.servertitle:SetPosition(0,223)
            self.servertitle:SetSize(40)
            self.serverdesc:SetPosition(0,188)
            self.serverdesc:SetSize(23)
            self.serverstate:SetPosition(0,163)
            self.serverstate:SetSize(23)
            self.players_number:SetPosition(303,160)
            self.players_number:SetSize(20)
            self.divider:SetPosition(0,149)
        end

        if serverNameStr == "" then
            self.servertitle:SetString(serverNameStr)
        elseif servermenunumbtns > 1 then
            self.servertitle:SetTruncatedString(serverNameStr, 550, 100, true)
        elseif servermenunumbtns > 0 then
            self.servertitle:SetTruncatedString(serverNameStr, 600, 110, true)
        else
            self.servertitle:SetTruncatedString(serverNameStr, 800, 145, true)
        end

        if serverDescStr == "" then
            self.serverdesc:SetString(serverDescStr)
        elseif servermenunumbtns > 1 then
            self.serverdesc:SetTruncatedString(serverDescStr, 550, 175, true)
        elseif servermenunumbtns > 0 then
            self.serverdesc:SetTruncatedString(serverDescStr, 600, 190, true)
        else
            self.serverdesc:SetTruncatedString(serverDescStr, 800, 250, true)
        end

        if not self.servermods and TheNet:GetServerModsEnabled() then
            local modsStr = TheNet:GetServerModsDescription()
            self.servermods = self.root:AddChild(Text(UIFONT,25))
            self.servermods:SetPosition(20,-250,0)
            self.servermods:SetColour(1,1,1,1)
            self.servermods:SetTruncatedString(STRINGS.UI.PLAYERSTATUSSCREEN.MODSLISTPRE.." "..modsStr, 650, 146, true)

            self.bg:SetScale(.95,.95)
            self.bg:SetPosition(0,-10)
        end

        local function doButtonFocusHookups(playerListing)
            local buttons = {}
            if playerListing.viewprofile:IsVisible() then table.insert(buttons, playerListing.viewprofile) end
            if playerListing.mute:IsVisible() then table.insert(buttons, playerListing.mute) end
            if playerListing.kick:IsVisible() then table.insert(buttons, playerListing.kick) end
            if playerListing.ban:IsVisible() then table.insert(buttons, playerListing.ban) end
            if playerListing.useractions:IsVisible() then table.insert(buttons, playerListing.useractions) end

            local focusforwardset = false
            for i,button in ipairs(buttons) do
                if not focusforwardset then
                    focusforwardset = true
                    playerListing.focus_forward = button
                end
                if buttons[i-1] then
                    button:SetFocusChangeDir(MOVE_LEFT, buttons[i-1])
                end
                if buttons[i+1] then
                    button:SetFocusChangeDir(MOVE_RIGHT, buttons[i+1])
                end
            end
        end

        local function listingConstructor(i, parent)
            local playerListing =  parent:AddChild(Widget("playerListing"))

            playerListing.highlight = playerListing:AddChild(Image("images/scoreboard.xml", "row_goldoutline.tex"))
            playerListing.highlight:SetPosition(22, 5)
            playerListing.highlight:Hide()

            playerListing.characterBadge = nil
            playerListing.characterBadge = playerListing:AddChild(PlayerBadge("", DEFAULT_PLAYER_COLOUR, false, 0))
            playerListing.characterBadge:SetScale(.8)
            playerListing.characterBadge:SetPosition(-328,5,0)
            playerListing.characterBadge:Hide()

            playerListing.number = playerListing:AddChild(Text(UIFONT, 35))
            playerListing.number:SetPosition(-385,0,0)
            playerListing.number:SetHAlign(ANCHOR_MIDDLE)
            playerListing.number:SetColour(1,1,1,1)
            playerListing.number:Hide()

            playerListing.adminBadge = playerListing:AddChild(ImageButton("images/avatars.xml", "avatar_admin.tex", "avatar_admin.tex", "avatar_admin.tex", nil, nil, {1,1}, {0,0}))
            playerListing.adminBadge:Disable()
            playerListing.adminBadge:SetPosition(-359,-13,0)
            playerListing.adminBadge.image:SetScale(.3)
            playerListing.adminBadge.scale_on_focus = false
            playerListing.adminBadge:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.ADMIN, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 30, colour = {1,1,1,1}})
            playerListing.adminBadge:Hide()

            playerListing.name = playerListing:AddChild(Text(UIFONT, 35, ""))
            playerListing.name._align = {
                maxwidth = 215,
                maxchars = 36,
                x = -286,
            }

            playerListing.age = playerListing:AddChild(Text(UIFONT, 35, ""))
            playerListing.age:SetPosition(-20,0,0)
            playerListing.age:SetHAlign(ANCHOR_MIDDLE)

            playerListing.viewprofile = playerListing:AddChild(ImageButton("images/scoreboard.xml", "addfriend.tex", "addfriend.tex", "addfriend.tex", "addfriend.tex", nil, {1,1}, {0,0}))
            playerListing.viewprofile:SetPosition(120,3,0)
            playerListing.viewprofile:SetNormalScale(0.39)
            playerListing.viewprofile:SetFocusScale(0.39*1.1)
            playerListing.viewprofile:SetFocusSound("dontstarve/HUD/click_mouseover")
            playerListing.viewprofile:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.VIEWPROFILE, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 30, colour = {1,1,1,1}})

            playerListing.mute = playerListing:AddChild(ImageButton("images/scoreboard.xml", "chat.tex", "chat.tex", "chat.tex", "chat.tex", nil, {1,1}, {0,0}))
            playerListing.mute:SetPosition(170,3,0)
            playerListing.mute:SetNormalScale(0.39)
            playerListing.mute:SetFocusScale(0.39*1.1)
            playerListing.mute:SetFocusSound("dontstarve/HUD/click_mouseover")
            playerListing.mute:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.MUTE, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 30, colour = {1,1,1,1}})
            playerListing.mute.image.inst.OnUpdateVoice = function(inst)
                inst.widget:SetTint(unpack(playerListing.userid ~= nil and TheNet:IsVoiceActive(playerListing.userid) and VOICE_ACTIVE_COLOUR or VOICE_IDLE_COLOUR))
            end
            playerListing.mute.image.inst.SetMuted = function(inst, muted)
                if muted then
                    inst.widget:SetTint(unpack(VOICE_MUTE_COLOUR))
                    if inst._task ~= nil then
                        inst._task:Cancel()
                        inst._task = nil
                    end
                else
                    inst:OnUpdateVoice()
                    if inst._task == nil then
                        inst._task = inst:DoPeriodicTask(1, inst.OnUpdateVoice)
                    end
                end
            end
            playerListing.mute.image.inst.DisableMute = function(inst)
                inst.widget:SetTint(unpack(VOICE_IDLE_COLOUR))
                if inst._task ~= nil then
                    inst._task:Cancel()
                    inst._task = nil
                end
            end

            playerListing.mute:SetOnClick(
                function()
                    if playerListing.userid ~= nil then
                        playerListing.isMuted = not playerListing.isMuted
                        TheNet:SetPlayerMuted(playerListing.userid, playerListing.isMuted)
                        if playerListing.isMuted then
                            playerListing.mute.image_focus = "mute.tex"
                            playerListing.mute.image:SetTexture("images/scoreboard.xml", "mute.tex") 
                            playerListing.mute:SetTextures("images/scoreboard.xml", "mute.tex")
                            playerListing.mute:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.UNMUTE)
                        else
                            playerListing.mute.image_focus = "chat.tex"
                            playerListing.mute.image:SetTexture("images/scoreboard.xml", "chat.tex")
                            playerListing.mute:SetTextures("images/scoreboard.xml", "chat.tex")
                            playerListing.mute:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.MUTE)
                        end
                        playerListing.mute.image.inst:SetMuted(playerListing.isMuted)
                    end
                end)

            playerListing.mute.image.inst:DisableMute()

            playerListing.kick = playerListing:AddChild(ImageButton("images/scoreboard.xml", "kickout.tex", "kickout.tex", "kickout_disabled.tex", "kickout.tex", nil, {1,1}, {0,0}))
            playerListing.kick:SetNormalScale(0.39)
            playerListing.kick:SetFocusScale(0.39*1.1)
            playerListing.kick:SetFocusSound("dontstarve/HUD/click_mouseover")
            playerListing.kick:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.KICK, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 30, colour = {1,1,1,1}})
            local gainfocusfn = playerListing.kick.OnGainFocus
            playerListing.kick.OnGainFocus = function()
                gainfocusfn(playerListing.kick)
                --TODO gjans: same functionality for extended command list
                local commandresult = UserCommands.UserRunCommandResult("kick", self.owner, playerListing.userid)
                if commandresult == COMMAND_RESULT.ALLOW then
                    playerListing.kick:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.KICK)
                elseif commandresult == COMMAND_RESULT.VOTE then
                    -- TODO: This thing should be voter-unaware, that should be handled by the usercommands and just return an appropriate result
                    playerListing.kick:SetHoverText(string.format(STRINGS.UI.PLAYERSTATUSSCREEN.VOTEHOVERFMT, STRINGS.UI.PLAYERSTATUSSCREEN.KICK))
                elseif commandresult == COMMAND_RESULT.DISABLED then
                    --we know canstart is false, but we want the reason
                    local canstart, reason = UserCommands.CanUserStartCommand("kick", self.owner, playerListing.userid)
                    playerListing.kick:SetHoverText(reason ~= nil and STRINGS.UI.PLAYERSTATUSSCREEN.COMMANDCANNOTSTART[reason] or "")
                elseif commandresult == COMMAND_RESULT.DENY then
                    local worldvoter = TheWorld.net ~= nil and TheWorld.net.components.worldvoter or nil
                    local playervoter = self.owner.components.playervoter
                    if worldvoter == nil or playervoter == nil or not worldvoter:IsEnabled() then
                        --technically we should never get here (expected COMMAND_RESULT.INVALID)
                    elseif worldvoter:IsVoteActive() then
                        playerListing.kick:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.VOTEACTIVEHOVER)
                    elseif playervoter:IsSquelched() then
                        playerListing.kick:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.VOTESQUELCHEDHOVER)
                    else
                        --we know canstart is false, but we want the reason
                        local canstart, reason = UserCommands.CanUserStartVote("kick", self.owner, playerListing.userid)
                        playerListing.kick:SetHoverText(reason ~= nil and STRINGS.UI.PLAYERSTATUSSCREEN.VOTECANNOTSTART[reason] or "")
                    end
                end -- INVALID hides the button.
            end
            playerListing.kick:SetOnClick( function()
                if playerListing.userid then
                    TheFrontEnd:PopScreen()
                    UserCommands.RunUserCommand("kick", {user=playerListing.userid}, self.owner)
                end
            end)

            playerListing.ban = playerListing:AddChild(ImageButton("images/scoreboard.xml", "banhammer.tex", "banhammer.tex", "banhammer.tex", "banhammer.tex", nil, {1,1}, {0,0}))
            playerListing.ban:SetPosition(220,3,0)
            playerListing.ban:SetNormalScale(0.39)
            playerListing.ban:SetFocusScale(0.39*1.1)
            playerListing.ban:SetFocusSound("dontstarve/HUD/click_mouseover")
            playerListing.ban:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.BAN, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 30, colour = {1,1,1,1}})
            playerListing.ban:SetOnClick( function()
                if playerListing.userid then
                    TheFrontEnd:PopScreen()
                    UserCommands.RunUserCommand("ban", {user=playerListing.userid}, self.owner)
                end
            end)

            playerListing.useractions = playerListing:AddChild(ImageButton("images/scoreboard.xml", "more_actions.tex", "more_actions.tex", "more_actions.tex", "more_actions.tex", nil, {1,1}, {0,0}))
            playerListing.useractions:SetPosition(220,3,0)
            playerListing.useractions:SetNormalScale(0.39)
            playerListing.useractions:SetFocusScale(0.39*1.1)
            playerListing.useractions:SetFocusSound("dontstarve/HUD/click_mouseover")
            playerListing.useractions:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.USERACTIONS, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 30, colour = {1,1,1,1}})
            playerListing.useractions:SetOnClick(function()
                TheFrontEnd:PopScreen()
                self:OpenUserCommandPickerScreen(playerListing.userid)
            end)

            playerListing.perf = playerListing:AddChild(Image("images/scoreboard.xml", PERF_CLIENT_UNKNOWN))
            playerListing.perf:SetPosition(295, 4, 0)
            playerListing.perf:SetScale(unpack(PERF_CLIENT_SCALE))

            playerListing.OnGainFocus = function()
                playerListing.highlight:Show()
            end
            playerListing.OnLoseFocus = function()
                playerListing.highlight:Hide()
            end

            return playerListing
        end

        local function UpdatePlayerListing(playerListing, client, i)

            if client == nil or GetTableSize(client) == 0 then
                playerListing:Hide()
                return
            end

            playerListing:Show()

            playerListing.displayName = self:GetDisplayName(client)

            playerListing.userid = client.userid

            playerListing.characterBadge:Set(client.prefab or "", client.colour or DEFAULT_PLAYER_COLOUR, client.performance ~= nil, client.userflags or 0)
            playerListing.characterBadge:Show()

            if client.admin then
                playerListing.adminBadge:Show()
            else
                playerListing.adminBadge:Hide()
            end

            local visible_index = i
            if not TheNet:GetServerIsClientHosted() then
                playerListing.number:SetString(i-1)
                visible_index = i-1
                if i > 1 then
                    playerListing.number:Show()
                else
                    playerListing.number:Hide()
                end
            else
                playerListing.number:SetString(i)
            end

            playerListing.name:SetTruncatedString(playerListing.displayName, playerListing.name._align.maxwidth, playerListing.name._align.maxchars, true)
            local w, h = playerListing.name:GetRegionSize()
            playerListing.name:SetPosition(playerListing.name._align.x + w * .5, 0, 0)
            playerListing.name:SetColour(unpack(client.colour or DEFAULT_PLAYER_COLOUR))

            playerListing.age:SetString(client.playerage ~= nil and client.playerage > 0 and (tostring(client.playerage)..(client.playerage == 1 and STRINGS.UI.PLAYERSTATUSSCREEN.AGE_DAY or STRINGS.UI.PLAYERSTATUSSCREEN.AGE_DAYS)) or "")

            playerListing.ishost = client.performance ~= nil

            if client.performance ~= nil then
                local perf_id = math.min(client.performance + 1, #PERF_HOST_LEVELS)
                playerListing.perf:SetTexture("images/scoreboard.xml", PERF_HOST_LEVELS[perf_id])
                playerListing.perf:SetScale(unpack(PERF_HOST_SCALE))
                playerListing.perf:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.PERF_HOST_LEVELS[perf_id])
            else
                if client.netscore ~= nil then
                    local perf_id = math.min(client.netscore + 1, #PERF_CLIENT_LEVELS)
                    playerListing.perf:SetTexture("images/scoreboard.xml", PERF_CLIENT_LEVELS[perf_id])
                    playerListing.perf:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.PERF_CLIENT_LEVELS[perf_id])
                else
                    playerListing.perf:SetTexture("images/scoreboard.xml", PERF_CLIENT_UNKNOWN)
                    playerListing.perf:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.PERF_CLIENT_LEVEL_UNKNOWN)
                end
                playerListing.perf:SetScale(unpack(PERF_CLIENT_SCALE))
            end

            local this_user_is_dedicated_server = client.performance ~= nil and not TheNet:GetServerIsClientHosted()

            playerListing.viewprofile:SetOnClick(
                function()
                    if client.netid ~= nil then
                        GLOBAL.TheNet:ViewNetProfile(client.netid)--Вмесот этого экрана, мы открываем профиль стима
                    end
                end)

            local button_start = 50
            local button_x = button_start
            local button_x_offset = 42

            local can_kick = false
            local can_ban = false

            if not this_user_is_dedicated_server then
                playerListing.viewprofile:Show()
                playerListing.viewprofile:SetPosition(button_x,3,0)
                button_x = button_x + button_x_offset
                can_kick = UserCommands.CanUserAccessCommand("kick", self.owner, client.userid)
                can_ban = BAN_ENABLED and UserCommands.CanUserAccessCommand("ban", self.owner, client.userid)
            else
                playerListing.viewprofile:Hide()
            end

            playerListing.isMuted = client.muted == true
            if playerListing.isMuted then
                playerListing.mute.image_focus = "mute.tex"
                playerListing.mute.image:SetTexture("images/scoreboard.xml", "mute.tex") 
                playerListing.mute:SetTextures("images/scoreboard.xml", "mute.tex")
                playerListing.mute:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.UNMUTE)
            else
                playerListing.mute.image_focus = "chat.tex"
                playerListing.mute.image:SetTexture("images/scoreboard.xml", "chat.tex")
                playerListing.mute:SetTextures("images/scoreboard.xml", "chat.tex")
                playerListing.mute:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.MUTE)
            end

            if client.userid ~= self.owner.userid and not this_user_is_dedicated_server then
                playerListing.mute:Show()
                playerListing.mute:SetPosition(button_x,3,0)
                button_x = button_x + button_x_offset
                playerListing.mute.image.inst:SetMuted(playerListing.isMuted)
            else
                playerListing.mute:Hide()
                playerListing.mute.image.inst:DisableMute()
            end

            if can_kick then
                playerListing.kick:Show()
                playerListing.kick:SetPosition(button_x,3,0)
                button_x = button_x + button_x_offset

                local res = UserCommands.UserRunCommandResult("kick", self.owner, client.userid)
                if res == COMMAND_RESULT.DENY or res == COMMAND_RESULT.DISABLED then
                    playerListing.kick:Select()
                else
                    playerListing.kick:Unselect()
                end
            else
                playerListing.kick:Hide()
            end

            if can_ban then
                playerListing.ban:Show()
                playerListing.ban:SetPosition(button_x,3,0)
                button_x = button_x + button_x_offset

                local res = UserCommands.UserRunCommandResult("ban", self.owner, client.userid)
                if res == COMMAND_RESULT.DENY or res == COMMAND_RESULT.DISABLED then
                    playerListing.ban:Select()
                else
                    playerListing.ban:Unselect()
                end
            else
                playerListing.ban:Hide()
            end

            if this_user_is_dedicated_server then
                playerListing.useractions:Hide()
            else
                --Check if we have any user actions other than kick or ban (they have their own buttons)
                playerListing.useractions:Hide()
                for i, v in ipairs(UserCommands.GetUserActions(self.owner, playerListing.userid)) do
                    if v.commandname ~= "kick" and v.commandname ~= "ban" then
                        playerListing.useractions:SetPosition(button_start + button_x_offset * 4, 3, 0)
                        playerListing.useractions:Show()
                        break
                    end
                end
            end

            doButtonFocusHookups(playerListing)
        end

        if not self.scroll_list then
            self.list_root = self.root:AddChild(Widget("list_root"))
            self.list_root:SetPosition(190, -35)

            self.row_root = self.root:AddChild(Widget("row_root"))
            self.row_root:SetPosition(190, -35)

            self.player_widgets = {}
            for i=1,6 do
                table.insert(self.player_widgets, listingConstructor(i, self.row_root))
                UpdatePlayerListing(self.player_widgets[i], ClientObjs[i] or {}, i)
            end

            self.scroll_list = self.list_root:AddChild(ScrollableList(ClientObjs, 380, 370, 60, 5, UpdatePlayerListing, self.player_widgets, nil, nil, nil, -15))
            self.scroll_list:LayOutStaticWidgets(-15)
            self.scroll_list:SetPosition(0,-10)

            self.focus_forward = self.scroll_list
            self.default_focus = self.scroll_list
        else
            self.scroll_list:SetList(ClientObjs)
        end

        if not self.bgs then
            self.bgs = {}
        end
        if #self.bgs > #ClientObjs then
            for i = #ClientObjs + 1, #self.bgs do
                table.remove(self.bgs):Kill()
            end
        else
            local maxbgs = math.min(self.scroll_list.widgets_per_view, #ClientObjs)
            if #self.bgs < maxbgs then
                for i = #self.bgs + 1, maxbgs do
                    local bg = self.scroll_list:AddChild(Image("images/scoreboard.xml", "row.tex"))
                    bg:SetTint(1, 1, 1, (i % 2) == 0 and .85 or .5)
                    bg:SetPosition(-170, 165 - 65 * (i - 1))
                    bg:MoveToBack()
                    table.insert(self.bgs, bg)
                end
            end
        end
    end
end)

 

There might be a better way, but in the code above I simply replaced the whole DoInit function.
I just copied the original, but replaced the relevant part with your code to show the profile.

Since we are in modmain now, you have to add to alot of things "GLOBAL." in front of it, I did not do this yet, so you have to.
Also there could be other local functions that are not accesable via modmain. In this case also copy them into modmain.

This is not a nice solution, cause it will confilict with game updates and other mods, but it is better then nothing.

Another more simpler way would be to completely replace the playerstatusscreen file.
So you copy the whole file and place it into scripts/screens/playerstatusscreen.lua of your mod folder.

Edited by Serpens
Link to comment
Share on other sites

14 hours ago, Serpens said:
  Reveal hidden contents


AddClassPostConstruct("screens/playerstatusscreen",function(
    local _DoInit = self.DoInit
	self.DoInit = function(self, ClientObjs)
        TheInput:EnableDebugToggle(false)

        if not self.black then
            --darken everything behind the dialog
            --bleed outside the screen a bit, otherwise it may not cover
            --the edge of the screen perfectly when scaled to some sizes
            local bleeding = 4
            self.black = self:AddChild(Image("images/global.xml", "square.tex"))
            self.black:SetSize(RESOLUTION_X + bleeding, RESOLUTION_Y + bleeding)
            self.black:SetVRegPoint(ANCHOR_MIDDLE)
            self.black:SetHRegPoint(ANCHOR_MIDDLE)
            self.black:SetVAnchor(ANCHOR_MIDDLE)
            self.black:SetHAnchor(ANCHOR_MIDDLE)
            self.black:SetScaleMode(SCALEMODE_FIXEDPROPORTIONAL)
            self.black:SetTint(0,0,0,0) -- invisible, but clickable!
        end

        if not self.root then
            self.root = self:AddChild(Widget("ROOT"))
            self.root:SetScaleMode(SCALEMODE_PROPORTIONAL)
            self.root:SetHAnchor(ANCHOR_MIDDLE)
            self.root:SetVAnchor(ANCHOR_MIDDLE)
        end

        if not self.bg then
            self.bg = self.root:AddChild(Image( "images/scoreboard.xml", "scoreboard_frame.tex" ))
            self.bg:SetScale(.95,.9)
        end

        local serverNameStr = TheNet:GetServerName()
        if not self.servertitle then
            self.servertitle = self.root:AddChild(Text(UIFONT,45))
            self.servertitle:SetColour(1,1,1,1)
        end

        if not self.serverstate then
            self.serverstate = self.root:AddChild(Text(UIFONT,30))
            self.serverstate:SetColour(1,1,1,1)
        end
        self.serverage = TheWorld.state.cycles + 1
        local modeStr = GetGameModeString(TheNet:GetServerGameMode()) ~= nil and GetGameModeString(TheNet:GetServerGameMode()).." - " or ""
        self.serverstate:SetString(modeStr.." "..STRINGS.UI.PLAYERSTATUSSCREEN.AGE_PREFIX..self.serverage)

        local servermenunumbtns = 0

        self.server_group = TheNet:GetServerClanID()
        if self.server_group ~= "" and not TheInput:ControllerAttached() then
            if self.viewgroup_button == nil then
                self.viewgroup_button = self.root:AddChild(ImageButton("images/scoreboard.xml", "clan_normal.tex", "clan_hover.tex", "clan.tex", "clan.tex", nil, { .4, .4 }, { 0, 0 }))
                self.viewgroup_button:SetOnClick(function() TheNet:ViewNetProfile(self.server_group) end)
                self.viewgroup_button:SetHoverText(STRINGS.UI.SERVERLISTINGSCREEN.VIEWGROUP, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 48, colour = WHITE})
            end
            servermenunumbtns = servermenunumbtns + 1
        elseif self.viewgroup_button ~= nil then
            self.viewgroup_button:Kill()
            self.viewgroup_button = nil
        end

        if not TheInput:ControllerAttached() and #UserCommands.GetServerActions(self.owner) > 0 then
            if self.serveractions_button == nil then
                self.serveractions_button = self.root:AddChild(ImageButton("images/scoreboard.xml", "more_actions_normal.tex", "more_actions_hover.tex", "more_actions.tex", "more_actions.tex", nil, { .4, .4 }, { 0, 0 }))
                self.serveractions_button:SetOnClick(function()
                    TheFrontEnd:PopScreen()
                    self:OpenUserCommandPickerScreen(nil)
                end)
                self.serveractions_button:SetHoverText(STRINGS.UI.SERVERLISTINGSCREEN.SERVERACTIONS, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 48, colour = WHITE})
            end
            servermenunumbtns = servermenunumbtns + 1
        elseif self.serveractions_button ~= nil then
            self.serveractions_button:Kill()
            self.serveractions_button = nil
        end

        if ClientObjs == nil then
            ClientObjs = TheNet:GetClientTable() or {}
        end
        self.numPlayers = #ClientObjs

        if not self.players_number then
            self.players_number = self.root:AddChild(Text(UIFONT, 25))
            self.players_number:SetPosition(303,170) 
            self.players_number:SetRegionSize(100,30)
            self.players_number:SetHAlign(ANCHOR_RIGHT)
            self.players_number:SetColour(1,1,1,1)
        end
        self.players_number:SetString(tostring(not TheNet:GetServerIsClientHosted() and self.numPlayers - 1 or self.numPlayers).."/"..(TheNet:GetServerMaxPlayers() or "?"))

        local serverDescStr = TheNet:GetServerDescription()
        if not self.serverdesc then
            self.serverdesc = self.root:AddChild(Text(UIFONT,30))
            self.serverdesc:SetColour(1,1,1,1)
        end

        if not self.divider then
            self.divider = self.root:AddChild(Image("images/scoreboard.xml", "white_line.tex"))
        end

        local servermenux = -329
        local servermenubtnoffs = 24
        if self.viewgroup_button ~= nil then
            self.viewgroup_button:SetPosition(servermenux - (servermenunumbtns > 1 and servermenubtnoffs or 0), 200)
        end
        if self.serveractions_button ~= nil then
            self.serveractions_button:SetPosition(servermenux + (servermenunumbtns > 1 and servermenubtnoffs or 0), 200)
        end

        if serverDescStr == "" then
            self.servertitle:SetPosition(0,215)
            self.serverdesc:SetPosition(0,175)
            self.serverstate:SetPosition(0,175)
            self.divider:SetPosition(0,155)
        else
            self.servertitle:SetPosition(0,223)
            self.servertitle:SetSize(40)
            self.serverdesc:SetPosition(0,188)
            self.serverdesc:SetSize(23)
            self.serverstate:SetPosition(0,163)
            self.serverstate:SetSize(23)
            self.players_number:SetPosition(303,160)
            self.players_number:SetSize(20)
            self.divider:SetPosition(0,149)
        end

        if serverNameStr == "" then
            self.servertitle:SetString(serverNameStr)
        elseif servermenunumbtns > 1 then
            self.servertitle:SetTruncatedString(serverNameStr, 550, 100, true)
        elseif servermenunumbtns > 0 then
            self.servertitle:SetTruncatedString(serverNameStr, 600, 110, true)
        else
            self.servertitle:SetTruncatedString(serverNameStr, 800, 145, true)
        end

        if serverDescStr == "" then
            self.serverdesc:SetString(serverDescStr)
        elseif servermenunumbtns > 1 then
            self.serverdesc:SetTruncatedString(serverDescStr, 550, 175, true)
        elseif servermenunumbtns > 0 then
            self.serverdesc:SetTruncatedString(serverDescStr, 600, 190, true)
        else
            self.serverdesc:SetTruncatedString(serverDescStr, 800, 250, true)
        end

        if not self.servermods and TheNet:GetServerModsEnabled() then
            local modsStr = TheNet:GetServerModsDescription()
            self.servermods = self.root:AddChild(Text(UIFONT,25))
            self.servermods:SetPosition(20,-250,0)
            self.servermods:SetColour(1,1,1,1)
            self.servermods:SetTruncatedString(STRINGS.UI.PLAYERSTATUSSCREEN.MODSLISTPRE.." "..modsStr, 650, 146, true)

            self.bg:SetScale(.95,.95)
            self.bg:SetPosition(0,-10)
        end

        local function doButtonFocusHookups(playerListing)
            local buttons = {}
            if playerListing.viewprofile:IsVisible() then table.insert(buttons, playerListing.viewprofile) end
            if playerListing.mute:IsVisible() then table.insert(buttons, playerListing.mute) end
            if playerListing.kick:IsVisible() then table.insert(buttons, playerListing.kick) end
            if playerListing.ban:IsVisible() then table.insert(buttons, playerListing.ban) end
            if playerListing.useractions:IsVisible() then table.insert(buttons, playerListing.useractions) end

            local focusforwardset = false
            for i,button in ipairs(buttons) do
                if not focusforwardset then
                    focusforwardset = true
                    playerListing.focus_forward = button
                end
                if buttons[i-1] then
                    button:SetFocusChangeDir(MOVE_LEFT, buttons[i-1])
                end
                if buttons[i+1] then
                    button:SetFocusChangeDir(MOVE_RIGHT, buttons[i+1])
                end
            end
        end

        local function listingConstructor(i, parent)
            local playerListing =  parent:AddChild(Widget("playerListing"))

            playerListing.highlight = playerListing:AddChild(Image("images/scoreboard.xml", "row_goldoutline.tex"))
            playerListing.highlight:SetPosition(22, 5)
            playerListing.highlight:Hide()

            playerListing.characterBadge = nil
            playerListing.characterBadge = playerListing:AddChild(PlayerBadge("", DEFAULT_PLAYER_COLOUR, false, 0))
            playerListing.characterBadge:SetScale(.8)
            playerListing.characterBadge:SetPosition(-328,5,0)
            playerListing.characterBadge:Hide()

            playerListing.number = playerListing:AddChild(Text(UIFONT, 35))
            playerListing.number:SetPosition(-385,0,0)
            playerListing.number:SetHAlign(ANCHOR_MIDDLE)
            playerListing.number:SetColour(1,1,1,1)
            playerListing.number:Hide()

            playerListing.adminBadge = playerListing:AddChild(ImageButton("images/avatars.xml", "avatar_admin.tex", "avatar_admin.tex", "avatar_admin.tex", nil, nil, {1,1}, {0,0}))
            playerListing.adminBadge:Disable()
            playerListing.adminBadge:SetPosition(-359,-13,0)
            playerListing.adminBadge.image:SetScale(.3)
            playerListing.adminBadge.scale_on_focus = false
            playerListing.adminBadge:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.ADMIN, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 30, colour = {1,1,1,1}})
            playerListing.adminBadge:Hide()

            playerListing.name = playerListing:AddChild(Text(UIFONT, 35, ""))
            playerListing.name._align = {
                maxwidth = 215,
                maxchars = 36,
                x = -286,
            }

            playerListing.age = playerListing:AddChild(Text(UIFONT, 35, ""))
            playerListing.age:SetPosition(-20,0,0)
            playerListing.age:SetHAlign(ANCHOR_MIDDLE)

            playerListing.viewprofile = playerListing:AddChild(ImageButton("images/scoreboard.xml", "addfriend.tex", "addfriend.tex", "addfriend.tex", "addfriend.tex", nil, {1,1}, {0,0}))
            playerListing.viewprofile:SetPosition(120,3,0)
            playerListing.viewprofile:SetNormalScale(0.39)
            playerListing.viewprofile:SetFocusScale(0.39*1.1)
            playerListing.viewprofile:SetFocusSound("dontstarve/HUD/click_mouseover")
            playerListing.viewprofile:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.VIEWPROFILE, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 30, colour = {1,1,1,1}})

            playerListing.mute = playerListing:AddChild(ImageButton("images/scoreboard.xml", "chat.tex", "chat.tex", "chat.tex", "chat.tex", nil, {1,1}, {0,0}))
            playerListing.mute:SetPosition(170,3,0)
            playerListing.mute:SetNormalScale(0.39)
            playerListing.mute:SetFocusScale(0.39*1.1)
            playerListing.mute:SetFocusSound("dontstarve/HUD/click_mouseover")
            playerListing.mute:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.MUTE, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 30, colour = {1,1,1,1}})
            playerListing.mute.image.inst.OnUpdateVoice = function(inst)
                inst.widget:SetTint(unpack(playerListing.userid ~= nil and TheNet:IsVoiceActive(playerListing.userid) and VOICE_ACTIVE_COLOUR or VOICE_IDLE_COLOUR))
            end
            playerListing.mute.image.inst.SetMuted = function(inst, muted)
                if muted then
                    inst.widget:SetTint(unpack(VOICE_MUTE_COLOUR))
                    if inst._task ~= nil then
                        inst._task:Cancel()
                        inst._task = nil
                    end
                else
                    inst:OnUpdateVoice()
                    if inst._task == nil then
                        inst._task = inst:DoPeriodicTask(1, inst.OnUpdateVoice)
                    end
                end
            end
            playerListing.mute.image.inst.DisableMute = function(inst)
                inst.widget:SetTint(unpack(VOICE_IDLE_COLOUR))
                if inst._task ~= nil then
                    inst._task:Cancel()
                    inst._task = nil
                end
            end

            playerListing.mute:SetOnClick(
                function()
                    if playerListing.userid ~= nil then
                        playerListing.isMuted = not playerListing.isMuted
                        TheNet:SetPlayerMuted(playerListing.userid, playerListing.isMuted)
                        if playerListing.isMuted then
                            playerListing.mute.image_focus = "mute.tex"
                            playerListing.mute.image:SetTexture("images/scoreboard.xml", "mute.tex") 
                            playerListing.mute:SetTextures("images/scoreboard.xml", "mute.tex")
                            playerListing.mute:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.UNMUTE)
                        else
                            playerListing.mute.image_focus = "chat.tex"
                            playerListing.mute.image:SetTexture("images/scoreboard.xml", "chat.tex")
                            playerListing.mute:SetTextures("images/scoreboard.xml", "chat.tex")
                            playerListing.mute:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.MUTE)
                        end
                        playerListing.mute.image.inst:SetMuted(playerListing.isMuted)
                    end
                end)

            playerListing.mute.image.inst:DisableMute()

            playerListing.kick = playerListing:AddChild(ImageButton("images/scoreboard.xml", "kickout.tex", "kickout.tex", "kickout_disabled.tex", "kickout.tex", nil, {1,1}, {0,0}))
            playerListing.kick:SetNormalScale(0.39)
            playerListing.kick:SetFocusScale(0.39*1.1)
            playerListing.kick:SetFocusSound("dontstarve/HUD/click_mouseover")
            playerListing.kick:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.KICK, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 30, colour = {1,1,1,1}})
            local gainfocusfn = playerListing.kick.OnGainFocus
            playerListing.kick.OnGainFocus = function()
                gainfocusfn(playerListing.kick)
                --TODO gjans: same functionality for extended command list
                local commandresult = UserCommands.UserRunCommandResult("kick", self.owner, playerListing.userid)
                if commandresult == COMMAND_RESULT.ALLOW then
                    playerListing.kick:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.KICK)
                elseif commandresult == COMMAND_RESULT.VOTE then
                    -- TODO: This thing should be voter-unaware, that should be handled by the usercommands and just return an appropriate result
                    playerListing.kick:SetHoverText(string.format(STRINGS.UI.PLAYERSTATUSSCREEN.VOTEHOVERFMT, STRINGS.UI.PLAYERSTATUSSCREEN.KICK))
                elseif commandresult == COMMAND_RESULT.DISABLED then
                    --we know canstart is false, but we want the reason
                    local canstart, reason = UserCommands.CanUserStartCommand("kick", self.owner, playerListing.userid)
                    playerListing.kick:SetHoverText(reason ~= nil and STRINGS.UI.PLAYERSTATUSSCREEN.COMMANDCANNOTSTART[reason] or "")
                elseif commandresult == COMMAND_RESULT.DENY then
                    local worldvoter = TheWorld.net ~= nil and TheWorld.net.components.worldvoter or nil
                    local playervoter = self.owner.components.playervoter
                    if worldvoter == nil or playervoter == nil or not worldvoter:IsEnabled() then
                        --technically we should never get here (expected COMMAND_RESULT.INVALID)
                    elseif worldvoter:IsVoteActive() then
                        playerListing.kick:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.VOTEACTIVEHOVER)
                    elseif playervoter:IsSquelched() then
                        playerListing.kick:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.VOTESQUELCHEDHOVER)
                    else
                        --we know canstart is false, but we want the reason
                        local canstart, reason = UserCommands.CanUserStartVote("kick", self.owner, playerListing.userid)
                        playerListing.kick:SetHoverText(reason ~= nil and STRINGS.UI.PLAYERSTATUSSCREEN.VOTECANNOTSTART[reason] or "")
                    end
                end -- INVALID hides the button.
            end
            playerListing.kick:SetOnClick( function()
                if playerListing.userid then
                    TheFrontEnd:PopScreen()
                    UserCommands.RunUserCommand("kick", {user=playerListing.userid}, self.owner)
                end
            end)

            playerListing.ban = playerListing:AddChild(ImageButton("images/scoreboard.xml", "banhammer.tex", "banhammer.tex", "banhammer.tex", "banhammer.tex", nil, {1,1}, {0,0}))
            playerListing.ban:SetPosition(220,3,0)
            playerListing.ban:SetNormalScale(0.39)
            playerListing.ban:SetFocusScale(0.39*1.1)
            playerListing.ban:SetFocusSound("dontstarve/HUD/click_mouseover")
            playerListing.ban:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.BAN, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 30, colour = {1,1,1,1}})
            playerListing.ban:SetOnClick( function()
                if playerListing.userid then
                    TheFrontEnd:PopScreen()
                    UserCommands.RunUserCommand("ban", {user=playerListing.userid}, self.owner)
                end
            end)

            playerListing.useractions = playerListing:AddChild(ImageButton("images/scoreboard.xml", "more_actions.tex", "more_actions.tex", "more_actions.tex", "more_actions.tex", nil, {1,1}, {0,0}))
            playerListing.useractions:SetPosition(220,3,0)
            playerListing.useractions:SetNormalScale(0.39)
            playerListing.useractions:SetFocusScale(0.39*1.1)
            playerListing.useractions:SetFocusSound("dontstarve/HUD/click_mouseover")
            playerListing.useractions:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.USERACTIONS, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 30, colour = {1,1,1,1}})
            playerListing.useractions:SetOnClick(function()
                TheFrontEnd:PopScreen()
                self:OpenUserCommandPickerScreen(playerListing.userid)
            end)

            playerListing.perf = playerListing:AddChild(Image("images/scoreboard.xml", PERF_CLIENT_UNKNOWN))
            playerListing.perf:SetPosition(295, 4, 0)
            playerListing.perf:SetScale(unpack(PERF_CLIENT_SCALE))

            playerListing.OnGainFocus = function()
                playerListing.highlight:Show()
            end
            playerListing.OnLoseFocus = function()
                playerListing.highlight:Hide()
            end

            return playerListing
        end

        local function UpdatePlayerListing(playerListing, client, i)

            if client == nil or GetTableSize(client) == 0 then
                playerListing:Hide()
                return
            end

            playerListing:Show()

            playerListing.displayName = self:GetDisplayName(client)

            playerListing.userid = client.userid

            playerListing.characterBadge:Set(client.prefab or "", client.colour or DEFAULT_PLAYER_COLOUR, client.performance ~= nil, client.userflags or 0)
            playerListing.characterBadge:Show()

            if client.admin then
                playerListing.adminBadge:Show()
            else
                playerListing.adminBadge:Hide()
            end

            local visible_index = i
            if not TheNet:GetServerIsClientHosted() then
                playerListing.number:SetString(i-1)
                visible_index = i-1
                if i > 1 then
                    playerListing.number:Show()
                else
                    playerListing.number:Hide()
                end
            else
                playerListing.number:SetString(i)
            end

            playerListing.name:SetTruncatedString(playerListing.displayName, playerListing.name._align.maxwidth, playerListing.name._align.maxchars, true)
            local w, h = playerListing.name:GetRegionSize()
            playerListing.name:SetPosition(playerListing.name._align.x + w * .5, 0, 0)
            playerListing.name:SetColour(unpack(client.colour or DEFAULT_PLAYER_COLOUR))

            playerListing.age:SetString(client.playerage ~= nil and client.playerage > 0 and (tostring(client.playerage)..(client.playerage == 1 and STRINGS.UI.PLAYERSTATUSSCREEN.AGE_DAY or STRINGS.UI.PLAYERSTATUSSCREEN.AGE_DAYS)) or "")

            playerListing.ishost = client.performance ~= nil

            if client.performance ~= nil then
                local perf_id = math.min(client.performance + 1, #PERF_HOST_LEVELS)
                playerListing.perf:SetTexture("images/scoreboard.xml", PERF_HOST_LEVELS[perf_id])
                playerListing.perf:SetScale(unpack(PERF_HOST_SCALE))
                playerListing.perf:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.PERF_HOST_LEVELS[perf_id])
            else
                if client.netscore ~= nil then
                    local perf_id = math.min(client.netscore + 1, #PERF_CLIENT_LEVELS)
                    playerListing.perf:SetTexture("images/scoreboard.xml", PERF_CLIENT_LEVELS[perf_id])
                    playerListing.perf:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.PERF_CLIENT_LEVELS[perf_id])
                else
                    playerListing.perf:SetTexture("images/scoreboard.xml", PERF_CLIENT_UNKNOWN)
                    playerListing.perf:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.PERF_CLIENT_LEVEL_UNKNOWN)
                end
                playerListing.perf:SetScale(unpack(PERF_CLIENT_SCALE))
            end

            local this_user_is_dedicated_server = client.performance ~= nil and not TheNet:GetServerIsClientHosted()

            playerListing.viewprofile:SetOnClick(
                function()
                    if client.netid ~= nil then
                        GLOBAL.TheNet:ViewNetProfile(client.netid)--Вмесот этого экрана, мы открываем профиль стима
                    end
                end)

            local button_start = 50
            local button_x = button_start
            local button_x_offset = 42

            local can_kick = false
            local can_ban = false

            if not this_user_is_dedicated_server then
                playerListing.viewprofile:Show()
                playerListing.viewprofile:SetPosition(button_x,3,0)
                button_x = button_x + button_x_offset
                can_kick = UserCommands.CanUserAccessCommand("kick", self.owner, client.userid)
                can_ban = BAN_ENABLED and UserCommands.CanUserAccessCommand("ban", self.owner, client.userid)
            else
                playerListing.viewprofile:Hide()
            end

            playerListing.isMuted = client.muted == true
            if playerListing.isMuted then
                playerListing.mute.image_focus = "mute.tex"
                playerListing.mute.image:SetTexture("images/scoreboard.xml", "mute.tex") 
                playerListing.mute:SetTextures("images/scoreboard.xml", "mute.tex")
                playerListing.mute:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.UNMUTE)
            else
                playerListing.mute.image_focus = "chat.tex"
                playerListing.mute.image:SetTexture("images/scoreboard.xml", "chat.tex")
                playerListing.mute:SetTextures("images/scoreboard.xml", "chat.tex")
                playerListing.mute:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.MUTE)
            end

            if client.userid ~= self.owner.userid and not this_user_is_dedicated_server then
                playerListing.mute:Show()
                playerListing.mute:SetPosition(button_x,3,0)
                button_x = button_x + button_x_offset
                playerListing.mute.image.inst:SetMuted(playerListing.isMuted)
            else
                playerListing.mute:Hide()
                playerListing.mute.image.inst:DisableMute()
            end

            if can_kick then
                playerListing.kick:Show()
                playerListing.kick:SetPosition(button_x,3,0)
                button_x = button_x + button_x_offset

                local res = UserCommands.UserRunCommandResult("kick", self.owner, client.userid)
                if res == COMMAND_RESULT.DENY or res == COMMAND_RESULT.DISABLED then
                    playerListing.kick:Select()
                else
                    playerListing.kick:Unselect()
                end
            else
                playerListing.kick:Hide()
            end

            if can_ban then
                playerListing.ban:Show()
                playerListing.ban:SetPosition(button_x,3,0)
                button_x = button_x + button_x_offset

                local res = UserCommands.UserRunCommandResult("ban", self.owner, client.userid)
                if res == COMMAND_RESULT.DENY or res == COMMAND_RESULT.DISABLED then
                    playerListing.ban:Select()
                else
                    playerListing.ban:Unselect()
                end
            else
                playerListing.ban:Hide()
            end

            if this_user_is_dedicated_server then
                playerListing.useractions:Hide()
            else
                --Check if we have any user actions other than kick or ban (they have their own buttons)
                playerListing.useractions:Hide()
                for i, v in ipairs(UserCommands.GetUserActions(self.owner, playerListing.userid)) do
                    if v.commandname ~= "kick" and v.commandname ~= "ban" then
                        playerListing.useractions:SetPosition(button_start + button_x_offset * 4, 3, 0)
                        playerListing.useractions:Show()
                        break
                    end
                end
            end

            doButtonFocusHookups(playerListing)
        end

        if not self.scroll_list then
            self.list_root = self.root:AddChild(Widget("list_root"))
            self.list_root:SetPosition(190, -35)

            self.row_root = self.root:AddChild(Widget("row_root"))
            self.row_root:SetPosition(190, -35)

            self.player_widgets = {}
            for i=1,6 do
                table.insert(self.player_widgets, listingConstructor(i, self.row_root))
                UpdatePlayerListing(self.player_widgets[i], ClientObjs[i] or {}, i)
            end

            self.scroll_list = self.list_root:AddChild(ScrollableList(ClientObjs, 380, 370, 60, 5, UpdatePlayerListing, self.player_widgets, nil, nil, nil, -15))
            self.scroll_list:LayOutStaticWidgets(-15)
            self.scroll_list:SetPosition(0,-10)

            self.focus_forward = self.scroll_list
            self.default_focus = self.scroll_list
        else
            self.scroll_list:SetList(ClientObjs)
        end

        if not self.bgs then
            self.bgs = {}
        end
        if #self.bgs > #ClientObjs then
            for i = #ClientObjs + 1, #self.bgs do
                table.remove(self.bgs):Kill()
            end
        else
            local maxbgs = math.min(self.scroll_list.widgets_per_view, #ClientObjs)
            if #self.bgs < maxbgs then
                for i = #self.bgs + 1, maxbgs do
                    local bg = self.scroll_list:AddChild(Image("images/scoreboard.xml", "row.tex"))
                    bg:SetTint(1, 1, 1, (i % 2) == 0 and .85 or .5)
                    bg:SetPosition(-170, 165 - 65 * (i - 1))
                    bg:MoveToBack()
                    table.insert(self.bgs, bg)
                end
            end
        end
    end
end)

 

Another more simpler way would be to completely replace the playerstatusscreen file.
So you copy the whole file and place it into scripts/screens/playerstatusscreen.lua of your mod folder.

I allready did it. It worked without any other localisation mods, but, for example when I enabled Russian Language pack, screen came back to normal...

 

  • Like 1
Link to comment
Share on other sites

15 hours ago, Serpens said:
  Reveal hidden contents


AddClassPostConstruct("screens/playerstatusscreen",function(
    local _DoInit = self.DoInit
	self.DoInit = function(self, ClientObjs)
        TheInput:EnableDebugToggle(false)

        if not self.black then
            --darken everything behind the dialog
            --bleed outside the screen a bit, otherwise it may not cover
            --the edge of the screen perfectly when scaled to some sizes
            local bleeding = 4
            self.black = self:AddChild(Image("images/global.xml", "square.tex"))
            self.black:SetSize(RESOLUTION_X + bleeding, RESOLUTION_Y + bleeding)
            self.black:SetVRegPoint(ANCHOR_MIDDLE)
            self.black:SetHRegPoint(ANCHOR_MIDDLE)
            self.black:SetVAnchor(ANCHOR_MIDDLE)
            self.black:SetHAnchor(ANCHOR_MIDDLE)
            self.black:SetScaleMode(SCALEMODE_FIXEDPROPORTIONAL)
            self.black:SetTint(0,0,0,0) -- invisible, but clickable!
        end

        if not self.root then
            self.root = self:AddChild(Widget("ROOT"))
            self.root:SetScaleMode(SCALEMODE_PROPORTIONAL)
            self.root:SetHAnchor(ANCHOR_MIDDLE)
            self.root:SetVAnchor(ANCHOR_MIDDLE)
        end

        if not self.bg then
            self.bg = self.root:AddChild(Image( "images/scoreboard.xml", "scoreboard_frame.tex" ))
            self.bg:SetScale(.95,.9)
        end

        local serverNameStr = TheNet:GetServerName()
        if not self.servertitle then
            self.servertitle = self.root:AddChild(Text(UIFONT,45))
            self.servertitle:SetColour(1,1,1,1)
        end

        if not self.serverstate then
            self.serverstate = self.root:AddChild(Text(UIFONT,30))
            self.serverstate:SetColour(1,1,1,1)
        end
        self.serverage = TheWorld.state.cycles + 1
        local modeStr = GetGameModeString(TheNet:GetServerGameMode()) ~= nil and GetGameModeString(TheNet:GetServerGameMode()).." - " or ""
        self.serverstate:SetString(modeStr.." "..STRINGS.UI.PLAYERSTATUSSCREEN.AGE_PREFIX..self.serverage)

        local servermenunumbtns = 0

        self.server_group = TheNet:GetServerClanID()
        if self.server_group ~= "" and not TheInput:ControllerAttached() then
            if self.viewgroup_button == nil then
                self.viewgroup_button = self.root:AddChild(ImageButton("images/scoreboard.xml", "clan_normal.tex", "clan_hover.tex", "clan.tex", "clan.tex", nil, { .4, .4 }, { 0, 0 }))
                self.viewgroup_button:SetOnClick(function() TheNet:ViewNetProfile(self.server_group) end)
                self.viewgroup_button:SetHoverText(STRINGS.UI.SERVERLISTINGSCREEN.VIEWGROUP, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 48, colour = WHITE})
            end
            servermenunumbtns = servermenunumbtns + 1
        elseif self.viewgroup_button ~= nil then
            self.viewgroup_button:Kill()
            self.viewgroup_button = nil
        end

        if not TheInput:ControllerAttached() and #UserCommands.GetServerActions(self.owner) > 0 then
            if self.serveractions_button == nil then
                self.serveractions_button = self.root:AddChild(ImageButton("images/scoreboard.xml", "more_actions_normal.tex", "more_actions_hover.tex", "more_actions.tex", "more_actions.tex", nil, { .4, .4 }, { 0, 0 }))
                self.serveractions_button:SetOnClick(function()
                    TheFrontEnd:PopScreen()
                    self:OpenUserCommandPickerScreen(nil)
                end)
                self.serveractions_button:SetHoverText(STRINGS.UI.SERVERLISTINGSCREEN.SERVERACTIONS, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 48, colour = WHITE})
            end
            servermenunumbtns = servermenunumbtns + 1
        elseif self.serveractions_button ~= nil then
            self.serveractions_button:Kill()
            self.serveractions_button = nil
        end

        if ClientObjs == nil then
            ClientObjs = TheNet:GetClientTable() or {}
        end
        self.numPlayers = #ClientObjs

        if not self.players_number then
            self.players_number = self.root:AddChild(Text(UIFONT, 25))
            self.players_number:SetPosition(303,170) 
            self.players_number:SetRegionSize(100,30)
            self.players_number:SetHAlign(ANCHOR_RIGHT)
            self.players_number:SetColour(1,1,1,1)
        end
        self.players_number:SetString(tostring(not TheNet:GetServerIsClientHosted() and self.numPlayers - 1 or self.numPlayers).."/"..(TheNet:GetServerMaxPlayers() or "?"))

        local serverDescStr = TheNet:GetServerDescription()
        if not self.serverdesc then
            self.serverdesc = self.root:AddChild(Text(UIFONT,30))
            self.serverdesc:SetColour(1,1,1,1)
        end

        if not self.divider then
            self.divider = self.root:AddChild(Image("images/scoreboard.xml", "white_line.tex"))
        end

        local servermenux = -329
        local servermenubtnoffs = 24
        if self.viewgroup_button ~= nil then
            self.viewgroup_button:SetPosition(servermenux - (servermenunumbtns > 1 and servermenubtnoffs or 0), 200)
        end
        if self.serveractions_button ~= nil then
            self.serveractions_button:SetPosition(servermenux + (servermenunumbtns > 1 and servermenubtnoffs or 0), 200)
        end

        if serverDescStr == "" then
            self.servertitle:SetPosition(0,215)
            self.serverdesc:SetPosition(0,175)
            self.serverstate:SetPosition(0,175)
            self.divider:SetPosition(0,155)
        else
            self.servertitle:SetPosition(0,223)
            self.servertitle:SetSize(40)
            self.serverdesc:SetPosition(0,188)
            self.serverdesc:SetSize(23)
            self.serverstate:SetPosition(0,163)
            self.serverstate:SetSize(23)
            self.players_number:SetPosition(303,160)
            self.players_number:SetSize(20)
            self.divider:SetPosition(0,149)
        end

        if serverNameStr == "" then
            self.servertitle:SetString(serverNameStr)
        elseif servermenunumbtns > 1 then
            self.servertitle:SetTruncatedString(serverNameStr, 550, 100, true)
        elseif servermenunumbtns > 0 then
            self.servertitle:SetTruncatedString(serverNameStr, 600, 110, true)
        else
            self.servertitle:SetTruncatedString(serverNameStr, 800, 145, true)
        end

        if serverDescStr == "" then
            self.serverdesc:SetString(serverDescStr)
        elseif servermenunumbtns > 1 then
            self.serverdesc:SetTruncatedString(serverDescStr, 550, 175, true)
        elseif servermenunumbtns > 0 then
            self.serverdesc:SetTruncatedString(serverDescStr, 600, 190, true)
        else
            self.serverdesc:SetTruncatedString(serverDescStr, 800, 250, true)
        end

        if not self.servermods and TheNet:GetServerModsEnabled() then
            local modsStr = TheNet:GetServerModsDescription()
            self.servermods = self.root:AddChild(Text(UIFONT,25))
            self.servermods:SetPosition(20,-250,0)
            self.servermods:SetColour(1,1,1,1)
            self.servermods:SetTruncatedString(STRINGS.UI.PLAYERSTATUSSCREEN.MODSLISTPRE.." "..modsStr, 650, 146, true)

            self.bg:SetScale(.95,.95)
            self.bg:SetPosition(0,-10)
        end

        local function doButtonFocusHookups(playerListing)
            local buttons = {}
            if playerListing.viewprofile:IsVisible() then table.insert(buttons, playerListing.viewprofile) end
            if playerListing.mute:IsVisible() then table.insert(buttons, playerListing.mute) end
            if playerListing.kick:IsVisible() then table.insert(buttons, playerListing.kick) end
            if playerListing.ban:IsVisible() then table.insert(buttons, playerListing.ban) end
            if playerListing.useractions:IsVisible() then table.insert(buttons, playerListing.useractions) end

            local focusforwardset = false
            for i,button in ipairs(buttons) do
                if not focusforwardset then
                    focusforwardset = true
                    playerListing.focus_forward = button
                end
                if buttons[i-1] then
                    button:SetFocusChangeDir(MOVE_LEFT, buttons[i-1])
                end
                if buttons[i+1] then
                    button:SetFocusChangeDir(MOVE_RIGHT, buttons[i+1])
                end
            end
        end

        local function listingConstructor(i, parent)
            local playerListing =  parent:AddChild(Widget("playerListing"))

            playerListing.highlight = playerListing:AddChild(Image("images/scoreboard.xml", "row_goldoutline.tex"))
            playerListing.highlight:SetPosition(22, 5)
            playerListing.highlight:Hide()

            playerListing.characterBadge = nil
            playerListing.characterBadge = playerListing:AddChild(PlayerBadge("", DEFAULT_PLAYER_COLOUR, false, 0))
            playerListing.characterBadge:SetScale(.8)
            playerListing.characterBadge:SetPosition(-328,5,0)
            playerListing.characterBadge:Hide()

            playerListing.number = playerListing:AddChild(Text(UIFONT, 35))
            playerListing.number:SetPosition(-385,0,0)
            playerListing.number:SetHAlign(ANCHOR_MIDDLE)
            playerListing.number:SetColour(1,1,1,1)
            playerListing.number:Hide()

            playerListing.adminBadge = playerListing:AddChild(ImageButton("images/avatars.xml", "avatar_admin.tex", "avatar_admin.tex", "avatar_admin.tex", nil, nil, {1,1}, {0,0}))
            playerListing.adminBadge:Disable()
            playerListing.adminBadge:SetPosition(-359,-13,0)
            playerListing.adminBadge.image:SetScale(.3)
            playerListing.adminBadge.scale_on_focus = false
            playerListing.adminBadge:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.ADMIN, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 30, colour = {1,1,1,1}})
            playerListing.adminBadge:Hide()

            playerListing.name = playerListing:AddChild(Text(UIFONT, 35, ""))
            playerListing.name._align = {
                maxwidth = 215,
                maxchars = 36,
                x = -286,
            }

            playerListing.age = playerListing:AddChild(Text(UIFONT, 35, ""))
            playerListing.age:SetPosition(-20,0,0)
            playerListing.age:SetHAlign(ANCHOR_MIDDLE)

            playerListing.viewprofile = playerListing:AddChild(ImageButton("images/scoreboard.xml", "addfriend.tex", "addfriend.tex", "addfriend.tex", "addfriend.tex", nil, {1,1}, {0,0}))
            playerListing.viewprofile:SetPosition(120,3,0)
            playerListing.viewprofile:SetNormalScale(0.39)
            playerListing.viewprofile:SetFocusScale(0.39*1.1)
            playerListing.viewprofile:SetFocusSound("dontstarve/HUD/click_mouseover")
            playerListing.viewprofile:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.VIEWPROFILE, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 30, colour = {1,1,1,1}})

            playerListing.mute = playerListing:AddChild(ImageButton("images/scoreboard.xml", "chat.tex", "chat.tex", "chat.tex", "chat.tex", nil, {1,1}, {0,0}))
            playerListing.mute:SetPosition(170,3,0)
            playerListing.mute:SetNormalScale(0.39)
            playerListing.mute:SetFocusScale(0.39*1.1)
            playerListing.mute:SetFocusSound("dontstarve/HUD/click_mouseover")
            playerListing.mute:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.MUTE, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 30, colour = {1,1,1,1}})
            playerListing.mute.image.inst.OnUpdateVoice = function(inst)
                inst.widget:SetTint(unpack(playerListing.userid ~= nil and TheNet:IsVoiceActive(playerListing.userid) and VOICE_ACTIVE_COLOUR or VOICE_IDLE_COLOUR))
            end
            playerListing.mute.image.inst.SetMuted = function(inst, muted)
                if muted then
                    inst.widget:SetTint(unpack(VOICE_MUTE_COLOUR))
                    if inst._task ~= nil then
                        inst._task:Cancel()
                        inst._task = nil
                    end
                else
                    inst:OnUpdateVoice()
                    if inst._task == nil then
                        inst._task = inst:DoPeriodicTask(1, inst.OnUpdateVoice)
                    end
                end
            end
            playerListing.mute.image.inst.DisableMute = function(inst)
                inst.widget:SetTint(unpack(VOICE_IDLE_COLOUR))
                if inst._task ~= nil then
                    inst._task:Cancel()
                    inst._task = nil
                end
            end

            playerListing.mute:SetOnClick(
                function()
                    if playerListing.userid ~= nil then
                        playerListing.isMuted = not playerListing.isMuted
                        TheNet:SetPlayerMuted(playerListing.userid, playerListing.isMuted)
                        if playerListing.isMuted then
                            playerListing.mute.image_focus = "mute.tex"
                            playerListing.mute.image:SetTexture("images/scoreboard.xml", "mute.tex") 
                            playerListing.mute:SetTextures("images/scoreboard.xml", "mute.tex")
                            playerListing.mute:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.UNMUTE)
                        else
                            playerListing.mute.image_focus = "chat.tex"
                            playerListing.mute.image:SetTexture("images/scoreboard.xml", "chat.tex")
                            playerListing.mute:SetTextures("images/scoreboard.xml", "chat.tex")
                            playerListing.mute:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.MUTE)
                        end
                        playerListing.mute.image.inst:SetMuted(playerListing.isMuted)
                    end
                end)

            playerListing.mute.image.inst:DisableMute()

            playerListing.kick = playerListing:AddChild(ImageButton("images/scoreboard.xml", "kickout.tex", "kickout.tex", "kickout_disabled.tex", "kickout.tex", nil, {1,1}, {0,0}))
            playerListing.kick:SetNormalScale(0.39)
            playerListing.kick:SetFocusScale(0.39*1.1)
            playerListing.kick:SetFocusSound("dontstarve/HUD/click_mouseover")
            playerListing.kick:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.KICK, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 30, colour = {1,1,1,1}})
            local gainfocusfn = playerListing.kick.OnGainFocus
            playerListing.kick.OnGainFocus = function()
                gainfocusfn(playerListing.kick)
                --TODO gjans: same functionality for extended command list
                local commandresult = UserCommands.UserRunCommandResult("kick", self.owner, playerListing.userid)
                if commandresult == COMMAND_RESULT.ALLOW then
                    playerListing.kick:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.KICK)
                elseif commandresult == COMMAND_RESULT.VOTE then
                    -- TODO: This thing should be voter-unaware, that should be handled by the usercommands and just return an appropriate result
                    playerListing.kick:SetHoverText(string.format(STRINGS.UI.PLAYERSTATUSSCREEN.VOTEHOVERFMT, STRINGS.UI.PLAYERSTATUSSCREEN.KICK))
                elseif commandresult == COMMAND_RESULT.DISABLED then
                    --we know canstart is false, but we want the reason
                    local canstart, reason = UserCommands.CanUserStartCommand("kick", self.owner, playerListing.userid)
                    playerListing.kick:SetHoverText(reason ~= nil and STRINGS.UI.PLAYERSTATUSSCREEN.COMMANDCANNOTSTART[reason] or "")
                elseif commandresult == COMMAND_RESULT.DENY then
                    local worldvoter = TheWorld.net ~= nil and TheWorld.net.components.worldvoter or nil
                    local playervoter = self.owner.components.playervoter
                    if worldvoter == nil or playervoter == nil or not worldvoter:IsEnabled() then
                        --technically we should never get here (expected COMMAND_RESULT.INVALID)
                    elseif worldvoter:IsVoteActive() then
                        playerListing.kick:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.VOTEACTIVEHOVER)
                    elseif playervoter:IsSquelched() then
                        playerListing.kick:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.VOTESQUELCHEDHOVER)
                    else
                        --we know canstart is false, but we want the reason
                        local canstart, reason = UserCommands.CanUserStartVote("kick", self.owner, playerListing.userid)
                        playerListing.kick:SetHoverText(reason ~= nil and STRINGS.UI.PLAYERSTATUSSCREEN.VOTECANNOTSTART[reason] or "")
                    end
                end -- INVALID hides the button.
            end
            playerListing.kick:SetOnClick( function()
                if playerListing.userid then
                    TheFrontEnd:PopScreen()
                    UserCommands.RunUserCommand("kick", {user=playerListing.userid}, self.owner)
                end
            end)

            playerListing.ban = playerListing:AddChild(ImageButton("images/scoreboard.xml", "banhammer.tex", "banhammer.tex", "banhammer.tex", "banhammer.tex", nil, {1,1}, {0,0}))
            playerListing.ban:SetPosition(220,3,0)
            playerListing.ban:SetNormalScale(0.39)
            playerListing.ban:SetFocusScale(0.39*1.1)
            playerListing.ban:SetFocusSound("dontstarve/HUD/click_mouseover")
            playerListing.ban:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.BAN, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 30, colour = {1,1,1,1}})
            playerListing.ban:SetOnClick( function()
                if playerListing.userid then
                    TheFrontEnd:PopScreen()
                    UserCommands.RunUserCommand("ban", {user=playerListing.userid}, self.owner)
                end
            end)

            playerListing.useractions = playerListing:AddChild(ImageButton("images/scoreboard.xml", "more_actions.tex", "more_actions.tex", "more_actions.tex", "more_actions.tex", nil, {1,1}, {0,0}))
            playerListing.useractions:SetPosition(220,3,0)
            playerListing.useractions:SetNormalScale(0.39)
            playerListing.useractions:SetFocusScale(0.39*1.1)
            playerListing.useractions:SetFocusSound("dontstarve/HUD/click_mouseover")
            playerListing.useractions:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.USERACTIONS, { font = NEWFONT_OUTLINE, size = 24, offset_x = 0, offset_y = 30, colour = {1,1,1,1}})
            playerListing.useractions:SetOnClick(function()
                TheFrontEnd:PopScreen()
                self:OpenUserCommandPickerScreen(playerListing.userid)
            end)

            playerListing.perf = playerListing:AddChild(Image("images/scoreboard.xml", PERF_CLIENT_UNKNOWN))
            playerListing.perf:SetPosition(295, 4, 0)
            playerListing.perf:SetScale(unpack(PERF_CLIENT_SCALE))

            playerListing.OnGainFocus = function()
                playerListing.highlight:Show()
            end
            playerListing.OnLoseFocus = function()
                playerListing.highlight:Hide()
            end

            return playerListing
        end

        local function UpdatePlayerListing(playerListing, client, i)

            if client == nil or GetTableSize(client) == 0 then
                playerListing:Hide()
                return
            end

            playerListing:Show()

            playerListing.displayName = self:GetDisplayName(client)

            playerListing.userid = client.userid

            playerListing.characterBadge:Set(client.prefab or "", client.colour or DEFAULT_PLAYER_COLOUR, client.performance ~= nil, client.userflags or 0)
            playerListing.characterBadge:Show()

            if client.admin then
                playerListing.adminBadge:Show()
            else
                playerListing.adminBadge:Hide()
            end

            local visible_index = i
            if not TheNet:GetServerIsClientHosted() then
                playerListing.number:SetString(i-1)
                visible_index = i-1
                if i > 1 then
                    playerListing.number:Show()
                else
                    playerListing.number:Hide()
                end
            else
                playerListing.number:SetString(i)
            end

            playerListing.name:SetTruncatedString(playerListing.displayName, playerListing.name._align.maxwidth, playerListing.name._align.maxchars, true)
            local w, h = playerListing.name:GetRegionSize()
            playerListing.name:SetPosition(playerListing.name._align.x + w * .5, 0, 0)
            playerListing.name:SetColour(unpack(client.colour or DEFAULT_PLAYER_COLOUR))

            playerListing.age:SetString(client.playerage ~= nil and client.playerage > 0 and (tostring(client.playerage)..(client.playerage == 1 and STRINGS.UI.PLAYERSTATUSSCREEN.AGE_DAY or STRINGS.UI.PLAYERSTATUSSCREEN.AGE_DAYS)) or "")

            playerListing.ishost = client.performance ~= nil

            if client.performance ~= nil then
                local perf_id = math.min(client.performance + 1, #PERF_HOST_LEVELS)
                playerListing.perf:SetTexture("images/scoreboard.xml", PERF_HOST_LEVELS[perf_id])
                playerListing.perf:SetScale(unpack(PERF_HOST_SCALE))
                playerListing.perf:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.PERF_HOST_LEVELS[perf_id])
            else
                if client.netscore ~= nil then
                    local perf_id = math.min(client.netscore + 1, #PERF_CLIENT_LEVELS)
                    playerListing.perf:SetTexture("images/scoreboard.xml", PERF_CLIENT_LEVELS[perf_id])
                    playerListing.perf:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.PERF_CLIENT_LEVELS[perf_id])
                else
                    playerListing.perf:SetTexture("images/scoreboard.xml", PERF_CLIENT_UNKNOWN)
                    playerListing.perf:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.PERF_CLIENT_LEVEL_UNKNOWN)
                end
                playerListing.perf:SetScale(unpack(PERF_CLIENT_SCALE))
            end

            local this_user_is_dedicated_server = client.performance ~= nil and not TheNet:GetServerIsClientHosted()

            playerListing.viewprofile:SetOnClick(
                function()
                    if client.netid ~= nil then
                        GLOBAL.TheNet:ViewNetProfile(client.netid)--Вмесот этого экрана, мы открываем профиль стима
                    end
                end)

            local button_start = 50
            local button_x = button_start
            local button_x_offset = 42

            local can_kick = false
            local can_ban = false

            if not this_user_is_dedicated_server then
                playerListing.viewprofile:Show()
                playerListing.viewprofile:SetPosition(button_x,3,0)
                button_x = button_x + button_x_offset
                can_kick = UserCommands.CanUserAccessCommand("kick", self.owner, client.userid)
                can_ban = BAN_ENABLED and UserCommands.CanUserAccessCommand("ban", self.owner, client.userid)
            else
                playerListing.viewprofile:Hide()
            end

            playerListing.isMuted = client.muted == true
            if playerListing.isMuted then
                playerListing.mute.image_focus = "mute.tex"
                playerListing.mute.image:SetTexture("images/scoreboard.xml", "mute.tex") 
                playerListing.mute:SetTextures("images/scoreboard.xml", "mute.tex")
                playerListing.mute:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.UNMUTE)
            else
                playerListing.mute.image_focus = "chat.tex"
                playerListing.mute.image:SetTexture("images/scoreboard.xml", "chat.tex")
                playerListing.mute:SetTextures("images/scoreboard.xml", "chat.tex")
                playerListing.mute:SetHoverText(STRINGS.UI.PLAYERSTATUSSCREEN.MUTE)
            end

            if client.userid ~= self.owner.userid and not this_user_is_dedicated_server then
                playerListing.mute:Show()
                playerListing.mute:SetPosition(button_x,3,0)
                button_x = button_x + button_x_offset
                playerListing.mute.image.inst:SetMuted(playerListing.isMuted)
            else
                playerListing.mute:Hide()
                playerListing.mute.image.inst:DisableMute()
            end

            if can_kick then
                playerListing.kick:Show()
                playerListing.kick:SetPosition(button_x,3,0)
                button_x = button_x + button_x_offset

                local res = UserCommands.UserRunCommandResult("kick", self.owner, client.userid)
                if res == COMMAND_RESULT.DENY or res == COMMAND_RESULT.DISABLED then
                    playerListing.kick:Select()
                else
                    playerListing.kick:Unselect()
                end
            else
                playerListing.kick:Hide()
            end

            if can_ban then
                playerListing.ban:Show()
                playerListing.ban:SetPosition(button_x,3,0)
                button_x = button_x + button_x_offset

                local res = UserCommands.UserRunCommandResult("ban", self.owner, client.userid)
                if res == COMMAND_RESULT.DENY or res == COMMAND_RESULT.DISABLED then
                    playerListing.ban:Select()
                else
                    playerListing.ban:Unselect()
                end
            else
                playerListing.ban:Hide()
            end

            if this_user_is_dedicated_server then
                playerListing.useractions:Hide()
            else
                --Check if we have any user actions other than kick or ban (they have their own buttons)
                playerListing.useractions:Hide()
                for i, v in ipairs(UserCommands.GetUserActions(self.owner, playerListing.userid)) do
                    if v.commandname ~= "kick" and v.commandname ~= "ban" then
                        playerListing.useractions:SetPosition(button_start + button_x_offset * 4, 3, 0)
                        playerListing.useractions:Show()
                        break
                    end
                end
            end

            doButtonFocusHookups(playerListing)
        end

        if not self.scroll_list then
            self.list_root = self.root:AddChild(Widget("list_root"))
            self.list_root:SetPosition(190, -35)

            self.row_root = self.root:AddChild(Widget("row_root"))
            self.row_root:SetPosition(190, -35)

            self.player_widgets = {}
            for i=1,6 do
                table.insert(self.player_widgets, listingConstructor(i, self.row_root))
                UpdatePlayerListing(self.player_widgets[i], ClientObjs[i] or {}, i)
            end

            self.scroll_list = self.list_root:AddChild(ScrollableList(ClientObjs, 380, 370, 60, 5, UpdatePlayerListing, self.player_widgets, nil, nil, nil, -15))
            self.scroll_list:LayOutStaticWidgets(-15)
            self.scroll_list:SetPosition(0,-10)

            self.focus_forward = self.scroll_list
            self.default_focus = self.scroll_list
        else
            self.scroll_list:SetList(ClientObjs)
        end

        if not self.bgs then
            self.bgs = {}
        end
        if #self.bgs > #ClientObjs then
            for i = #ClientObjs + 1, #self.bgs do
                table.remove(self.bgs):Kill()
            end
        else
            local maxbgs = math.min(self.scroll_list.widgets_per_view, #ClientObjs)
            if #self.bgs < maxbgs then
                for i = #self.bgs + 1, maxbgs do
                    local bg = self.scroll_list:AddChild(Image("images/scoreboard.xml", "row.tex"))
                    bg:SetTint(1, 1, 1, (i % 2) == 0 and .85 or .5)
                    bg:SetPosition(-170, 165 - 65 * (i - 1))
                    bg:MoveToBack()
                    table.insert(self.bgs, bg)
                end
            end
        end
    end
end)

 

There might be a better way, but in the code above I simply replaced the whole DoInit function.
I just copied the original, but replaced the relevant part with your code to show the profile.

Since we are in modmain now, you have to add to alot of things "GLOBAL." in front of it, I did not do this yet, so you have to.
Also there could be other local functions that are not accesable via modmain. In this case also copy them into modmain.

This is not a nice solution, cause it will confilict with game updates and other mods, but it is better then nothing.

Another more simpler way would be to completely replace the playerstatusscreen file.
So you copy the whole file and place it into scripts/screens/playerstatusscreen.lua of your mod folder.

oh, thanks! But there's so much globals I need to write... :D 

There's One problem. It is crashing with 

[string "scripts/widgets/text.lua"]:180: calling 'SetHAnchor' on bad self (number expected, got nil)

All globals are here:

local _G = GLOBAL
local TheFrontEnd = _G.TheFrontEnd
local require = _G.require
local TheInput = _G.TheInput
local NEWFONT_OUTLINE = _G.NEWFONT_OUTLINE
local MOVE_RIGHT = _G.MOVE_RIGHT
local MOVE_LEFT = _G.MOVE_LEFT
local TheWorld = _G.TheWorld
local TheNet = _G.TheNet
local STRINGS = _G.STRINGS
local USERFLAGS = _G.USERFLAGS
local checkbit = _G.checkbit
local DST_CHARACTERLIST = _G.DST_CHARACTERLIST
local MODCHARACTERLIST = _G.MODCHARACTERLIST
local MOD_AVATAR_LOCATIONS = _G.MOD_AVATAR_LOCATIONS
local RESOLUTION_X = _G.RESOLUTION_X
local ANCHOR_MIDDLE = _G.ANCHOR_MIDDLE
local SCALEMODE_FIXEDPROPORTIONAL = _G.SCALEMODE_FIXEDPROPORTIONAL
local RESOLUTION_Y = _G.RESOLUTION_Y
local SCALEMODE_PROPORTIONAL = _G.SCALEMODE_PROPORTIONAL
local UIFONT = _G.UIFONT
local GetGameModeString = _G.GetGameModeString
local UserCommands = require("usercommands")
local ImageButton = require "widgets/imagebutton"
local easing = require("easing")
local Widget = require "widgets/widget"
local Text = require "widgets/text"
local UIAnim = require "widgets/uianim"
local Image = require "widgets/image"
local ConsoleScreen = require "screens/consolescreen"
local DebugMenuScreen = require "screens/DebugMenuScreen"
local PopupDialogScreen = require "screens/popupdialog"
local TEMPLATES = require "widgets/templates"

So many thanks for your help! :D 

Edited by makar5000
  • Like 1
Link to comment
Share on other sites

2 hours ago, makar5000 said:

oh, thanks! But there's so much globals I need to write... :D 

There's One problem. It is crashing with 


[string "scripts/widgets/text.lua"]:180: calling 'SetHAnchor' on bad self (number expected, got nil)

All globals are here:

So many thanks for your help! :D 

Then go to text.lua and see what it is line 180 ;)
There you will see the function
function Text:SetHAlign(anchor)
Search for this function in the DoInit code and you will see there is one with ANCHOR_RIGHT , which is not GLOBAL yet.

It could be that after everything of the code works, that it is also not compatible to your translation mod.
You should take a look in files of translation mod what it is changing in playerstatusscreen file.

edit:
you already fixed it, but I also fixed it in my doinit code above. The first line was "function(" instead of "function(self)"

Edited by Serpens
Link to comment
Share on other sites

On 27.06.2017 at 2:00 PM, Serpens said:

Then go to text.lua and see what it is line 180 ;)
There you will see the function
function Text:SetHAlign(anchor)
Search for this function in the DoInit code and you will see there is one with ANCHOR_RIGHT , which is not GLOBAL yet.

It could be that after everything of the code works, that it is also not compatible to your translation mod.
You should take a look in files of translation mod what it is changing in playerstatusscreen file.

edit:
you already fixed it, but I also fixed it in my doinit code above. The first line was "function(" instead of "function(self)"

Ok, there's too many globals... But I think I'll do it b myself from here. Thanks! Give me your trade link, so I'll be able to give your reward! :D 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...