Need help making changes to the in game lobby

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

Need help making changes to the in game lobby

Postby CavemanHost » 14 May 2016, 17:33

I have the amibitious plan to add the player ratings to the map preview in the in game lobby, so it makes the act of balancing easier. I never worked with lua or faf before and just set up the dev enviroment during the coding school today. I have some experience in TSQL, C#.Net and VBA.Net but no serious programming experience.


My question is, how do I start adding labels to the map preview right beside the player spawn points?
I guess I need to write a function that gets triggered on map change, slot swap and other events. Will it be possible to dynamically move or create/destroy the labels depending on the map currently selected?

This would add a label over the map preview, right?
Code: Select all
GUI.mapViewPlayerRating = makeLabel("Player Rating on Map", 12)
    LayoutHelpers.AtLeftTopIn(GUI.mapViewPlayerRating, GUI.mapPanel, -1, -1)
    LayoutHelpers.DepthOverParent(GUI.mapViewPlayerRating, GUI.mapPanel, -1)

LayoutHelpers does place the label relative to the mapPanel, right?
Is there any documentation about those methods and functions?

In my idea, I would need to get the "spawn point count", and position of the spawn point of the map and create an array of labels so I can dynamically add the labels to the map preview.


Any advice is welcome.


Thanks in advance!
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 » 15 May 2016, 15:40

This seems to be how to get the Position of the spawn points / markers.
Code: Select all
local markerPos = GUI.mapView.startPositions[i].Left()


So basicly I need to write a function like

Code: Select all
local function LabelForPlayerRatingInMapview ()

    local numAvailStartSpots = nil
    local scenarioInfo = nil

    if gameInfo.GameOptions.ScenarioFile and (gameInfo.GameOptions.ScenarioFile ~= "") then
        scenarioInfo = MapUtil.LoadScenario(gameInfo.GameOptions.ScenarioFile)
    end

    if scenarioInfo then
        local armyTable = MapUtil.GetArmies(scenarioInfo)
        if armyTable then
            if gameInfo.GameOptions['RandomMap'] == 'Off' then
                numAvailStartSpots = table.getn(armyTable)
            else
                numAvailStartSpots = numberOfPlayers
            end
        end
    else return


    for i = 1, numAvailStartSpots do
        if not gameInfo.ClosedSlots[i] then

            local markerPosLeft = GUI.mapView.startPositions[i].Left() + 5
            local markerPosTop = GUI.mapView.startPositions[i].Top() + 10

            GUI.mapPanel = Group(GUI.panel, "mapPanel")
            GUI.mapViewPlayerRating[i] = makeLabel(playerRating[i], 10)
            LayoutHelpers.AtLeftTopIn(GUI.mapViewPlayerRating, GUI.mapPanel, markerPosLeft, markerPosTop)
            LayoutHelpers.DepthOverParent(GUI.mapViewPlayerRating, GUI.mapPanel, 1)
           
     end
end


This is just some sort of pseudo code for now. Not functional or complete. No sure I can create labels like this:
GUI.mapViewPlayerRating[i] I guess I need to use a Group for that?

I guess I would have to delete and recreate the labels each time a new map gets set. So the function for creating the labels should be part of the code handling the mapPreview. (?) Or I could just add a fixed amount of max 12 labels and reposition the ones that get used while making the unused ones empty.


Again any input is welcome.
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 » 17 May 2016, 14:39

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 Downlord » 17 May 2016, 15:26

Hi,

I don't read the forums in general so sorry that *I* didn't answer (shame on all others! :-))
First I'm very happy that you try to implement this feature, I'd love to see it.
Second, I'd love to help you but I'm reeeeally short on time atm. so I can't dive into this right now.

But Blodir linked this topic in the developer chat so I hope someone can hook up with you soon. Otherwise just send me a PM and I'll take care :-)
Working on FAF is my passion. Most of you know me for the feature-rich Downlord's FAF Client, but I also program and maintain the FAF server. Visit my Patreon page to get some insights on my work.
Downlord
Councillor - DevOps
 
Posts: 226
Joined: 14 Jul 2013, 14:55
Has liked: 161 times
Been liked: 213 times
FAF User Name: Downlord

Re: Need help making changes to the in game lobby

Postby CavemanHost » 17 May 2016, 16:16

Thanks for answering. I actually have another problem that needs to be solved before I can start working on this.I can't seem to get supcom to run my modified code. I followed parts of the video and this readme: https://github.com/FAForever/fa

I also looked at various wiki pages:
http://wiki.faforever.com/index.php?tit ... fficiently
http://wiki.faforever.com/index.php?tit ... ent_School
http://wiki.faforever.com/index.php?tit ... ool_Client
http://wiki.faforever.com/index.php?title=Modding

I work inside that VM mentioned in the wiki. I copied the game files (without installation) to the VM. Told the github app to clone the repository to the repo folder I created right beside the bin folder of supcom. I copied the SupComDataPath.lua to the bin folder, created a init_dev.lua file in the bin folder with the following content (copied from the github readme):

Code: Select all
dev_path = 'C:\Program Files (x86)\THQ\Gas Powered Games\Supreme Commander - Forged Alliance\repo\fa'
-- this imports a path file that is written by Forged Alliance Forever right before it starts the game.
dofile(InitFileDir .. '\\..\\fa_path.lua')
path = {}
local function mount_dir(dir, mountpoint)
    table.insert(path, { dir = dir, mountpoint = mountpoint } )
end
local function mount_contents(dir, mountpoint)
    LOG('checking ' .. dir)
    for _,entry in io.dir(dir .. '\\*') do
        if entry != '.' and entry != '..' then
            local mp = string.lower(entry)
            mp = string.gsub(mp, '[.]scd$', '')
            mp = string.gsub(mp, '[.]zip$', '')
            mount_dir(dir .. '\\' .. entry, mountpoint .. '/' .. mp)
        end
    end
end
-- these are the classic supcom directories. They don't work with accents or other foreign characters in usernames
mount_contents(SHGetFolderPath('PERSONAL') .. 'My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\mods', '/mods')
mount_contents(SHGetFolderPath('PERSONAL') .. 'My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\maps', '/maps')
-- these are the local FAF directories. The My Games ones are only there for people with usernames that don't work in the uppder ones.
mount_contents(InitFileDir .. '\\..\\user\\My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\mods', '/mods')
mount_contents(InitFileDir .. '\\..\\user\\My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\maps', '/maps')
mount_dir(dev_path, '/')
-- these are using the newly generated path from the dofile() statement at the beginning of this script
mount_dir(fa_path .. '\\gamedata\\*.scd', '/')
mount_dir(fa_path, '/')
hook = {
    '/schook'
}
protocols = {
    'http',
    'https',
    'mailto',
    'ventrilo',
    'teamspeak',
    'daap',
    'im',
}


I created a shortcuton the desktop that launches supcom with the following commands:
/init "init_dev.lua" /EnableDiskWatch /showlog /nointro



I get this error:
Code: Select all
warning: Running "C:\Program Files (x86)\THQ\Gas Powered Games\Supreme Commander - Forged Alliance\bin\init_dev.lua" failed: cannot read C:\Program Files (x86)\THQ\Gas Powered Games\Supreme Commander - Forged Alliance\bin\..\fa_path.lua: No such file or directory
         stack traceback:
            [C]: in function `dofile'
            ...Supreme Commander - Forged Alliance\bin\init_dev.lua(3): in main chunk


What am I doing wrong?
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 » 17 May 2016, 19:21

that first line should be the thing you want to add on top - i.e. the dir of your repo

for me its
Code: Select all
dev_path = 'E:\\GITS\\fa'
-- this imports a path file that is written by Forged Alliance Forever right before it starts the game.
dofile(InitFileDir .. '\\..\\fa_path.lua')
path = {}
local function mount_dir(dir, mountpoint)
    table.insert(path, { dir = dir, mountpoint = mountpoint } )
end
local function mount_contents(dir, mountpoint)
    LOG('checking ' .. dir)
    for _,entry in io.dir(dir .. '\\*') do
        if entry != '.' and entry != '..' then
            local mp = string.lower(entry)
            mp = string.gsub(mp, '[.]scd$', '')
            mp = string.gsub(mp, '[.]zip$', '')
            mount_dir(dir .. '\\' .. entry, mountpoint .. '/' .. mp)
        end
    end
end
-- these are the classic supcom directories. They don't work with accents or other foreign characters in usernames
mount_contents(SHGetFolderPath('PERSONAL') .. 'My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\mods', '/mods')
mount_contents(SHGetFolderPath('PERSONAL') .. 'My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\maps', '/maps')
-- these are the local FAF directories. The My Games ones are only there for people with usernames that don't work in the uppder ones.
mount_contents(InitFileDir .. '\\..\\user\\My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\mods', '/mods')
mount_contents(InitFileDir .. '\\..\\user\\My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\maps', '/maps')
mount_dir(dev_path, '/')
-- these are using the newly generated path from the dofile() statement at the beginning of this script
mount_dir(fa_path .. '\\gamedata\\*.scd', '/')
mount_dir(fa_path, '/')
hook = {
    '/schook'
}
protocols = {
    'http',
    'https',
    'mailto',
    'ventrilo',
    'teamspeak',
    'daap',
    'im',
}
protocols = {

    'http',

    'https',

    'mailto',

    'ventrilo',

    'teamspeak',

    'daap',

    'im',

}

also for this i am not running any vm or anything at all. i just use this to get it to find my repo and then run from shortcut similar to what you descibed. so if youre on windows i would do the same thing,

hope this helps
feel free to ask any more questions, and be persistent, we often forget about stuff happening xD
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 yorick » 17 May 2016, 19:35

btw you mentioned a VM to run ( i guess ? ) the supcom code . I dont think that is neccesary, you should be able to do the same steps as described in the readme and get it running natively.
VM's for FAF development are only neccesary for server/api/db stuff afaik. There also is a method to run the client in a VM ( which probably was what you read on the wiki).
yorick
Avatar-of-War
 
Posts: 113
Joined: 01 Oct 2014, 02:53
Has liked: 16 times
Been liked: 27 times
FAF User Name: yorick

Re: Need help making changes to the in game lobby

Postby CavemanHost » 17 May 2016, 22:05

Thanks for your help. :-)
Ok. I will develop without the VM. Though I thought since the VM is a pretty clean enviroment, I should have less sources for unexpected problems.


Exotic_Retard wrote:that first line should be the thing you want to add on top - i.e. the dir of your repo


I still can't seem to get it running. Not on my pc or the VM. I get the same error.

warning: Running "D:\Program Files (x86)\THQ\Gas Powered Games\Supreme Commander - Forged Alliance\bin\init_dev.lua" failed: cannot read D:\Program Files (x86)\THQ\Gas Powered Games\Supreme Commander - Forged Alliance\bin\..\fa_path.lua: No such file or directory
stack traceback:
[C]: in function `dofile'
...Supreme Commander - Forged Alliance\bin\init_dev.lua(3): in main chunk


This my init_dev.lua file:

Code: Select all
dev_path = 'D:\\GitHub\\fa'
-- this imports a path file that is written by Forged Alliance Forever right before it starts the game.
dofile(InitFileDir .. '\\..\\fa_path.lua')
path = {}
local function mount_dir(dir, mountpoint)
    table.insert(path, { dir = dir, mountpoint = mountpoint } )
end
local function mount_contents(dir, mountpoint)
    LOG('checking ' .. dir)
    for _,entry in io.dir(dir .. '\\*') do
        if entry != '.' and entry != '..' then
            local mp = string.lower(entry)
            mp = string.gsub(mp, '[.]scd$', '')
            mp = string.gsub(mp, '[.]zip$', '')
            mount_dir(dir .. '\\' .. entry, mountpoint .. '/' .. mp)
        end
    end
end
-- these are the classic supcom directories. They don't work with accents or other foreign characters in usernames
mount_contents(SHGetFolderPath('PERSONAL') .. 'My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\mods', '/mods')
mount_contents(SHGetFolderPath('PERSONAL') .. 'My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\maps', '/maps')
-- these are the local FAF directories. The My Games ones are only there for people with usernames that don't work in the uppder ones.
mount_contents(InitFileDir .. '\\..\\user\\My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\mods', '/mods')
mount_contents(InitFileDir .. '\\..\\user\\My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\maps', '/maps')
mount_dir(dev_path, '/')
-- these are using the newly generated path from the dofile() statement at the beginning of this script
mount_dir(fa_path .. '\\gamedata\\*.scd', '/')
mount_dir(fa_path, '/')
hook = {
    '/schook'
}
protocols = {
    'http',
    'https',
    'mailto',
    'ventrilo',
    'teamspeak',
    'daap',
    'im',
}
protocols = {

    'http',

    'https',

    'mailto',

    'ventrilo',

    'teamspeak',

    'daap',

    'im',

}


I copied and pasted yours and edited the first line to point at my repo.

This is how I run it:
Code: Select all
"D:\Program Files (x86)\THQ\Gas Powered Games\Supreme Commander - Forged Alliance\bin\ForgedAlliance.exe" /init init_dev.lua
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 » 17 May 2016, 22:27

right so to be absolutely clear
your github repo is inside the fa install directory? why would you put it there?
Code: Select all
dev_path = 'C:\Program Files (x86)\THQ\Gas Powered Games\Supreme Commander - Forged Alliance\repo\fa'


the init file itself needs to be inside
Code: Select all
C:\ProgramData\FAForever\gamedata

is that correct for you? note that its gamedata not program files.


i run my exe with a shortcut set to:
Code: Select all
C:\ProgramData\FAForever\bin\ForgedAlliance.exe /init init_dev.lua /EnableDiskWatch /showlog /log C:\ProgramData\FAForever\logs\dev.log


that might be your issue. it looks like you are trying to run the base fa install, while faf has its own exe so that the game versions do not overwrite destructively.
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 » 17 May 2016, 22:53

Ah. I see. I got confused because the name of the mod files and the game files are just too similar.

I put it there because of this comment in the SupComDataPath.lua
Code: Select all
-- This is assuming the following structure:
--
-- bin/
-- repo/
--     /faf
--     /gw
--     /coop
--     etc...
--
-- And that SupComDataPath gets copied from here to bin/


My fa repo is now in D:\Github\ like all the other repos. See: my last post.

I got it working now. :-) The init file needed to be in C:\ProgramData\FAForever\bin tho.
Thanks a lot!
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

Next

Return to Contributors

Who is online

Users browsing this forum: No registered users and 1 guest