Display the Badges after the name in scoreboard

CalegoCalego Join Date: 2013-01-24 Member: 181848Members, NS2 Map Tester
How does one modify the order in which the scoreboard displays things?

I did the obvious thing and moved all of the "playerBadge" related stuff in GUIScoreboard:CreatePlayerItem after the "playernameitem" stuff, but I don't think that worked.
    // Player name text item.
    local playerNameItem = GUIManager:CreateTextItem()
    playerNameItem:SetFontName(GUIScoreboard.kPlayerStatsFontName)
    playerNameItem:SetAnchor(GUIItem.Left, GUIItem.Center)
    playerNameItem:SetTextAlignmentX(GUIItem.Align_Min)
    playerNameItem:SetTextAlignmentY(GUIItem.Align_Center)
    playerNameItem:SetPosition(Vector(
                playerItemChildX,
                0, 0))
    playerNameItem:SetColor(Color(1, 1, 1, 1))
    playerNameItem:SetStencilFunc(GUIItem.NotEqual)
    playerItem:AddChild(playerNameItem)

	//----------------------------------------
    //  Badge icons
    //----------------------------------------
    local maxBadges = Badges_GetMaxBadges()
    local badgeItems = {}
    
    // Player badges
    for i = 1,maxBadges do

        local playerBadge = GUIManager:CreateGraphicItem()
        playerBadge:SetSize(Vector(kPlayerBadgeIconSize, kPlayerBadgeIconSize, 0))
        playerBadge:SetAnchor(GUIItem.Left, GUIItem.Center)
        playerBadge:SetPosition(Vector(playerItemChildX, -kPlayerBadgeIconSize/2, 0))
        playerItemChildX = playerItemChildX + kPlayerBadgeIconSize + kPlayerBadgeRightPadding
        playerBadge:SetIsVisible(false)
        playerBadge:SetStencilFunc(GUIItem.NotEqual)
        playerItem:AddChild(playerBadge)
        table.insert( badgeItems, playerBadge )

    end

Note that I'm trying to edit this within ns2+'s files so that the modification works off of what's already there in NS2+. So if this is how you're supposed to do it, how do I tell NS2+ not to override my changes in this mod?

Comments

  • GhoulofGSG9GhoulofGSG9 Join Date: 2013-03-31 Member: 184566Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Reinforced - Supporter, WC 2013 - Supporter, Pistachionauts
    edited November 2014
    Just redefine the given method yourself. Just make sure your entry priority is lower than the one of ns2+.

    But what function is really interesting for you is https://github.com/Mendasp/NS2Plus/blob/05fdc7e89acd4b873f884604a52c6ed92f47f022/lua/GUIScoreboard.lua#L622
  • CalegoCalego Join Date: 2013-01-24 Member: 181848Members, NS2 Map Tester
    Just redefine the given method yourself. Just make sure your entry priority is lower than the one of ns2+.

    But what function is really interesting for you is https://github.com/Mendasp/NS2Plus/blob/05fdc7e89acd4b873f884604a52c6ed92f47f022/lua/GUIScoreboard.lua#L622

    So for entry priority, there would be something similar to this somewhere?
    modEntry = [[
    	Client: lua/GUIScoreboard.lua,
    	Priority: 40
    ]]
    


    With regards to that function:
    -- now adjust the position of the player name
        local numBadgesShown = math.min( #badgeTextures, #item.BadgeItems )
        
        offset = numBadgesShown*(kPlayerBadgeIconSize + kPlayerBadgeRightPadding)
                    
        return offset      
    

    So if I'm reading this right, it's taking the number of badges there are, multiplying it by however wide they are and then returning that as the value of the offset that is applied to the text of the name.

    So basically I'd need the text offset to be 0 all the time, but find a way to apply an offset to the badges equal to the length of the text? I feel like it would be simpler to make the badges appear on the far right of the name column, but then again, everything is complicated to me.

    Thanks for the help, I'll tinker with this some more tonight and report back.
  • GhoulofGSG9GhoulofGSG9 Join Date: 2013-03-31 Member: 184566Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Reinforced - Supporter, WC 2013 - Supporter, Pistachionauts
    edited November 2014
    Calego wrote: »
    Just redefine the given method yourself. Just make sure your entry priority is lower than the one of ns2+.

    But what function is really interesting for you is https://github.com/Mendasp/NS2Plus/blob/05fdc7e89acd4b873f884604a52c6ed92f47f022/lua/GUIScoreboard.lua#L622

    So for entry priority, there would be something similar to this somewhere?
    modEntry = [[
    	Client: lua/GUIScoreboard.lua,
    	Priority: 40
    ]]
    


    With regards to that function:
    -- now adjust the position of the player name
        local numBadgesShown = math.min( #badgeTextures, #item.BadgeItems )
        
        offset = numBadgesShown*(kPlayerBadgeIconSize + kPlayerBadgeRightPadding)
                    
        return offset      
    

    So if I'm reading this right, it's taking the number of badges there are, multiplying it by however wide they are and then returning that as the value of the offset that is applied to the text of the name.

    So basically I'd need the text offset to be 0 all the time, but find a way to apply an offset to the badges equal to the length of the text? I feel like it would be simpler to make the badges appear on the far right of the name column, but then again, everything is complicated to me.

    Thanks for the help, I'll tinker with this some more tonight and report back.

    You should avoid naming your mod files like ns2 vanilla files if you use the entry system. Otherwise you end up overloading vanilla files! Some more details can be found in my never finished mod guide i started writing a year ago but never finished (but might help you)
Sign In or Register to comment.