Need help making changes to the in game lobby

Post here if you want to help developing something for FAF.

Re: Need help making changes to the in game lobby

Postby CavemanHost » 17 May 2016, 23:33

Are there any debugging functions? I'd like to take a look at the value of a variable during execution.
User avatar
CavemanHost
Avatar-of-War
 
Posts: 78
Joined: 27 Jan 2016, 14:26
Has liked: 53 times
Been liked: 15 times
FAF User Name: CavemanHost

Re: Need help making changes to the in game lobby

Postby Exotic_Retard » 18 May 2016, 00:00

your best bet is to put logging in every place you want the variables value - for example
LOG('random text here')
LOG(variable)

substitute LOG with WARN for it so show up as a warning rather than info - i usually use that.
Spoiler: show
there is a kinda working debugger in supcom - use it with alt + f9, ignore the error and then you can set break lines in the code and whatnot

only problem; makes your game run at 0 fps. have not heard any successful use so far.
User avatar
Exotic_Retard
Contributor
 
Posts: 1470
Joined: 21 Mar 2013, 22:51
Has liked: 557 times
Been liked: 626 times
FAF User Name: Exotic_Retard

Re: Need help making changes to the in game lobby

Postby CavemanHost » 18 May 2016, 03:43

Made some progress :-)
Image

Now I'm a bit lost at getting and setting the rank of each player. Is it part of one of the peer functions/methods?
Is the StartPosition the same as the slot number? I'm getting my coordinates for the labels from GUI.mapView.startPositions
Does anybody know if there is any logical connection between marker, slotnumber and playerID?
User avatar
CavemanHost
Avatar-of-War
 
Posts: 78
Joined: 27 Jan 2016, 14:26
Has liked: 53 times
Been liked: 15 times
FAF User Name: CavemanHost

Re: Need help making changes to the in game lobby

Postby CavemanHost » 18 May 2016, 21:38

Its working! Even in multiplayer. (I could test it thanks to the VM).
Image

There are a few bugs to get rid of. The labels don't get updated when someone kicks a player, makes the player an observer or remove an ai.

Its an ugly function tho.

Code: Select all
function LblPlayerRatingMapview ()

    local scenarioInfo
    --Check if scenario is selected
    if gameInfo.GameOptions.ScenarioFile and (gameInfo.GameOptions.ScenarioFile ~= "") then
        scenarioInfo = MapUtil.LoadScenario(gameInfo.GameOptions.ScenarioFile)
    else
        return
    end

    -- ugly destruction of all existing labels on the map preview
    if GUI.mapViewPlayerRating_1 then GUI.mapViewPlayerRating_1:Destroy() end
    if GUI.mapViewPlayerRating_2 then GUI.mapViewPlayerRating_2:Destroy() end
    if GUI.mapViewPlayerRating_3 then GUI.mapViewPlayerRating_3:Destroy() end
    if GUI.mapViewPlayerRating_4 then GUI.mapViewPlayerRating_4:Destroy() end
    if GUI.mapViewPlayerRating_5 then GUI.mapViewPlayerRating_5:Destroy() end
    if GUI.mapViewPlayerRating_6 then GUI.mapViewPlayerRating_6:Destroy() end
    if GUI.mapViewPlayerRating_7 then GUI.mapViewPlayerRating_7:Destroy() end
    if GUI.mapViewPlayerRating_8 then GUI.mapViewPlayerRating_8:Destroy() end
    if GUI.mapViewPlayerRating_9 then GUI.mapViewPlayerRating_9:Destroy() end
    if GUI.mapViewPlayerRating_10 then GUI.mapViewPlayerRating_10:Destroy() end
    if GUI.mapViewPlayerRating_11 then GUI.mapViewPlayerRating_11:Destroy() end
    if GUI.mapViewPlayerRating_12 then GUI.mapViewPlayerRating_12:Destroy() end

    local marker_left = 0
    local marker_top = 0
    local rating = 0

    for slots, player in gameInfo.PlayerOptions:pairs() do

        local playerInfo = gameInfo.PlayerOptions[slots]

        --check if peer
        if player.Human and player.OwnerID ~= localPlayerID then
            WARN("Peer")
            local peer = lobbyComm:GetPeer(player.OwnerID)
            local peerSlot = FindSlotForID(peer.id)
            local playerInfo = gameInfo.PlayerOptions[peerSlot]
            local PeerRating = playerInfo.PL --not sure if this works yet, not able to test it
            rating = PeerRating
        elseif player.Human and (player.OwnerID == localPlayerID) then --check if local player

            local myPlayerData = GetLocalPlayerData()
            rating = myPlayerData.PL --playerInfo.MEAN - playerInfo.DEV * 3
        else
            rating = player.PlayerName
        end
        marker_left =    GUI.mapView.startPositions[slots].Left() - 8
        marker_top =     GUI.mapView.startPositions[slots].Top() - 12

        ---Create labels, it's dumb, but it works
        ---lets hope there are never more than 12 players on a map

        if slots == 1 then
        GUI.mapViewPlayerRating_1 = UIUtil.CreateText(GUI.panel, rating, 9, 'Arial Gras', true)
        LayoutHelpers.AtLeftTopIn(GUI.mapViewPlayerRating_1, GUI.panel, marker_left, marker_top)
        LayoutHelpers.DepthOverParent(GUI.mapViewPlayerRating_1, GUI.mapPanel, 2)
        end
        if slots == 2 then
        GUI.mapViewPlayerRating_2 = UIUtil.CreateText(GUI.panel, rating, 9, 'Arial Gras', true)
        LayoutHelpers.AtLeftTopIn(GUI.mapViewPlayerRating_2, GUI.panel, marker_left, marker_top)
        LayoutHelpers.DepthOverParent(GUI.mapViewPlayerRating_2, GUI.mapPanel, 2)
        end
        if slots == 3 then
        GUI.mapViewPlayerRating_3 = UIUtil.CreateText(GUI.panel, rating, 9, 'Arial Gras', true)
        LayoutHelpers.AtLeftTopIn(GUI.mapViewPlayerRating_3, GUI.panel, marker_left, marker_top)
        LayoutHelpers.DepthOverParent(GUI.mapViewPlayerRating_3, GUI.mapPanel, 2)
        end
        if slots == 4 then
        GUI.mapViewPlayerRating_4 = UIUtil.CreateText(GUI.panel, rating, 9, 'Arial Gras', true)
        LayoutHelpers.AtLeftTopIn(GUI.mapViewPlayerRating_4, GUI.panel, marker_left, marker_top)
        LayoutHelpers.DepthOverParent(GUI.mapViewPlayerRating_4, GUI.mapPanel, 2)
        end
        if slots == 5 then
        GUI.mapViewPlayerRating_5 = UIUtil.CreateText(GUI.panel, rating, 9, 'Arial Gras', true)
        LayoutHelpers.AtLeftTopIn(GUI.mapViewPlayerRating_5, GUI.panel, marker_left, marker_top)
        LayoutHelpers.DepthOverParent(GUI.mapViewPlayerRating_5, GUI.mapPanel, 2)
        end
        if slots == 6 then
        GUI.mapViewPlayerRating_6 = UIUtil.CreateText(GUI.panel, rating, 9, 'Arial Gras', true)
        LayoutHelpers.AtLeftTopIn(GUI.mapViewPlayerRating_6, GUI.panel, marker_left, marker_top)
        LayoutHelpers.DepthOverParent(GUI.mapViewPlayerRating_6, GUI.mapPanel, 2)
        end
        if slots == 7 then
        GUI.mapViewPlayerRating_7 = UIUtil.CreateText(GUI.panel, rating, 9, 'Arial Gras', true)
        LayoutHelpers.AtLeftTopIn(GUI.mapViewPlayerRating_7, GUI.panel, marker_left, marker_top)
        LayoutHelpers.DepthOverParent(GUI.mapViewPlayerRating_7, GUI.mapPanel, 2)
        end
        if slots == 8 then
        GUI.mapViewPlayerRating_8 = UIUtil.CreateText(GUI.panel, rating, 9, 'Arial Gras', true)
        LayoutHelpers.AtLeftTopIn(GUI.mapViewPlayerRating_8, GUI.panel, marker_left, marker_top)
        LayoutHelpers.DepthOverParent(GUI.mapViewPlayerRating_8, GUI.mapPanel, 2)
        end
        if slots == 9 then
        GUI.mapViewPlayerRating_9 = UIUtil.CreateText(GUI.panel, rating, 9, 'Arial Gras', true)
        LayoutHelpers.AtLeftTopIn(GUI.mapViewPlayerRating_9, GUI.panel, marker_left, marker_top)
        LayoutHelpers.DepthOverParent(GUI.mapViewPlayerRating_9, GUI.mapPanel, 2)
        end
        if slots == 10 then
        GUI.mapViewPlayerRating_10 = UIUtil.CreateText(GUI.panel, rating, 9, 'Arial Gras', true)
        LayoutHelpers.AtLeftTopIn(GUI.mapViewPlayerRating_10, GUI.panel, marker_left, marker_top)
        LayoutHelpers.DepthOverParent(GUI.mapViewPlayerRating_10, GUI.mapPanel, 2)
        end
        if slots == 11 then
        GUI.mapViewPlayerRating_11 = UIUtil.CreateText(GUI.panel, rating, 9, 'Arial Gras', true)
        LayoutHelpers.AtLeftTopIn(GUI.mapViewPlayerRating_11, GUI.panel, marker_left, marker_top)
        LayoutHelpers.DepthOverParent(GUI.mapViewPlayerRating_11, GUI.mapPanel, 2)
        end
        if slots == 12 then
        GUI.mapViewPlayerRating_12 = UIUtil.CreateText(GUI.panel, rating, 9, 'Arial Gras', true)
        LayoutHelpers.AtLeftTopIn(GUI.mapViewPlayerRating_12, GUI.panel, marker_left, marker_top)
        LayoutHelpers.DepthOverParent(GUI.mapViewPlayerRating_12, GUI.mapPanel, 2)
        end
    end
end


Code not yet complete, obviously.
User avatar
CavemanHost
Avatar-of-War
 
Posts: 78
Joined: 27 Jan 2016, 14:26
Has liked: 53 times
Been liked: 15 times
FAF User Name: CavemanHost

Re: Need help making changes to the in game lobby

Postby nocaps » 18 May 2016, 23:17

very cool! although, is there a particular reason you can't just make an array GUI.mapViewPlayerRating, instead of a gigantic list of GUI.mapViewPlayerRating_#?

thinking something like this
Code: Select all
function LblPlayerRatingMapview ()

    local scenarioInfo
    --Check if scenario is selected
    if gameInfo.GameOptions.ScenarioFile and (gameInfo.GameOptions.ScenarioFile ~= "") then
        scenarioInfo = MapUtil.LoadScenario(gameInfo.GameOptions.ScenarioFile)
    else
        return
    end

    -- less ugly destruction of all existing labels on the map preview
    for pNum = 1, #GUI.mapViewPlayerRating do
        GUI.mapViewPlayerRating[pNum]:Destroy()
    end

    local marker_left = 0
    local marker_top = 0
    local rating = 0

    for slots, player in gameInfo.PlayerOptions:pairs() do

        local playerInfo = gameInfo.PlayerOptions[slots]

        --check if peer
        if player.Human and player.OwnerID ~= localPlayerID then
            WARN("Peer")
            local peer = lobbyComm:GetPeer(player.OwnerID)
            local peerSlot = FindSlotForID(peer.id)
            local playerInfo = gameInfo.PlayerOptions[peerSlot]
            local PeerRating = playerInfo.PL --not sure if this works yet, not able to test it
            rating = PeerRating
        elseif player.Human and (player.OwnerID == localPlayerID) then --check if local player

            local playerData = GetLocalPlayerData()
            rating = playerData.PL --playerInfo.MEAN - playerInfo.DEV * 3
        else
            rating = player.PlayerName
        end
        marker_left =    GUI.mapView.startPositions[slots].Left() - 8
        marker_top =     GUI.mapView.startPositions[slots].Top() - 12

        ---Create labels, it's less dumb, but it works

        GUI.mapViewPlayerRating[slots] = UIUtil.CreateText(GUI.panel, rating, 9, 'Arial Gras, true)
        LayoutHelpers.AtLeftTopIn(GUI.mapViewPlayerRating[slots], GUI.panel, marker_left, marker_top)
        LayoutHelpers.DepthOverParent(GUI.mapViewPlayerRating[slots], GUI.mapPanel, 2)
    end
end


(i don't know lua, ymmv)
nocaps
Avatar-of-War
 
Posts: 60
Joined: 03 Feb 2016, 09:12
Location: behind you
Has liked: 34 times
Been liked: 24 times
FAF User Name: nocaps

Re: Need help making changes to the in game lobby

Postby CavemanHost » 18 May 2016, 23:44

That was the first thing I tried, but apperently the game doesn't like labels being created/destroyed in an array. So I had to do it this way. I have not much experience in lua either, just started a few days ago.
User avatar
CavemanHost
Avatar-of-War
 
Posts: 78
Joined: 27 Jan 2016, 14:26
Has liked: 53 times
Been liked: 15 times
FAF User Name: CavemanHost

Re: Need help making changes to the in game lobby

Postby Dragonfire » 19 May 2016, 00:35

Very cool !!!

Do you need help with git?

PS.: Maybe you send visionik your email, that he can invite you to Slack, our developer communication plattform ;)
My native language is not english, please correct me, because I want to improve my skills # Resource Overview
User avatar
Dragonfire
Evaluator
 
Posts: 559
Joined: 19 Dec 2013, 10:18
Has liked: 39 times
Been liked: 61 times
FAF User Name: Dragonfire

Re: Need help making changes to the in game lobby

Postby CavemanHost » 19 May 2016, 01:54

Thanks!
Yeah, I never used git before. Some help would be nice. I've got it set up according to the coding school tutorial but I'm unsure about how to handle changes.

I'll send him a message.
User avatar
CavemanHost
Avatar-of-War
 
Posts: 78
Joined: 27 Jan 2016, 14:26
Has liked: 53 times
Been liked: 15 times
FAF User Name: CavemanHost

Re: Need help making changes to the in game lobby

Postby CavemanHost » 19 May 2016, 18:32

I got rid of all bugs that I could find.
Labels are now deleted when game gets set to random spawns.
Fixed an issue with labels moving when game window is being resized.
Labels get updated when someone kicks a player, makes him observer or removes an ai.

Ai names and sometimes ranks overlap with the spawn point symbol on the map preview if spawn points are too close together, but that is not fixable since it is a result of the size of the map preview.

To be honest, I think the table of players as a whole is bad for setting up the game. The map preview is way better for this purpose. That is why I made this awesome lobby Ui redesign with the UI designer pro tool: ms paint.
Image


Not sure if it is doable tho. The Label right beside that totally accurate com symbol on the map would have some functionality that is now inside the table of players: Displaying rank & number of games, setting faction, setting teams, setting colors. I think I could get rid of the table all together. I will also try to add a primitve form of drag and drop to the map that will be based on MouseEvents.

But again. I'm not even sure if it is doable. Maybe all this will end in a just slightly bigger map map preview or no changes at all.
User avatar
CavemanHost
Avatar-of-War
 
Posts: 78
Joined: 27 Jan 2016, 14:26
Has liked: 53 times
Been liked: 15 times
FAF User Name: CavemanHost

Re: Need help making changes to the in game lobby

Postby IceDreamer » 20 May 2016, 04:16

I tried a similar layout in testing when I redesigned the lobby about a year ago. There simply isn't enough space to do it, because we're limited by having to support a minimum 1280*1024 resolution or something dumb and old. If we could tell those with monitors from 1985 to go away, and support a minimum of 1980*1080, we could do SO MUCH MORE :(
IceDreamer
Supreme Commander
 
Posts: 2607
Joined: 27 Dec 2011, 07:01
Has liked: 138 times
Been liked: 488 times

PreviousNext

Return to Contributors

Who is online

Users browsing this forum: No registered users and 1 guest