Forged Alliance Forever Forums
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
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
Users browsing this forum: No registered users and 1 guest