Creating the Map Veto function

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

Creating the Map Veto function

Postby Alluminati » 07 Aug 2013, 17:04

Hey guys,

in conclusion of this thread: viewtopic.php?f=2&t=2573
and after a lot of demands for map vetos and complaints about the current ladder map situation, I decided that I want to push the development for the ladder map veto function.

Now here's where I stand:
Set up python + all necessary libraries, downloaded zeps github repo, got everything to work fine.
Aaaand now I got no clue how to continue. Yes.

I thought it'd be a minor thing even for a total python noob like I am, but I stand corrected :)
After a couple first experiments, I quickly realized that I have no clue how the client works. So far I figued out thet the Qt is the responsible library for the interface and I worked my way through the folder structure and sort of halfish understand how it is structured.

I'd therefore like to ask for some help on this, in the end still rather simple, feature.

Here's the feature logic:
~ Include a pop up window into the game section of the client which allows to select maps which the player wants to veto.
~ Save these settings for the player.
~ Matchup search & generation as usual.
~ When matchup is found:
~ At the point where a map is chosen for a matchup, remove the vetoed maps of both players from the random map pool.
~ After that, random the map and go on as usually.


What I really need help with is how to integrate and create that said window. I also had trouble finding the section where the map is randomed, that might even be server side stuff.

If anyone here cared to fill me in or wants to work on this with me, I'd be really glad. In the end, a lot of people really want this feature, it'd pose a huge addition to the client.
User avatar
Alluminati
Crusader
 
Posts: 22
Joined: 01 Jul 2013, 16:32
Location: Germany
Has liked: 0 time
Been liked: 0 time
FAF User Name: Alluminati

Re: Creating the Map Veto function

Postby Ze_PilOt » 07 Aug 2013, 17:14

Do you already know how Qt is working with signals and slots ?
Nossa wrote:I've never played GPG or even heard of FA until FAF started blowing up.
User avatar
Ze_PilOt
Supreme Commander
 
Posts: 8985
Joined: 24 Aug 2011, 18:41
Location: fafland
Has liked: 18 times
Been liked: 376 times
FAF User Name: Ze_PilOt

Re: Creating the Map Veto function

Postby Alluminati » 07 Aug 2013, 17:17

Nope, I'm willing to spend a couple nights reading and getting into it.

Is there anything else I should look up that you can tell me now before I have to ask? ;-)

/e: Reading through a tutorial right now while browsing the code, seems nice and simple, I think I'll get the hang of it.
What about the part where the map is randomned, I'll need to edit that.
Last edited by Alluminati on 07 Aug 2013, 17:29, edited 1 time in total.
User avatar
Alluminati
Crusader
 
Posts: 22
Joined: 01 Jul 2013, 16:32
Location: Germany
Has liked: 0 time
Been liked: 0 time
FAF User Name: Alluminati

Re: Creating the Map Veto function

Postby Ze_PilOt » 07 Aug 2013, 17:26

Well the whole things is based on signals that are connected between modules.

The main emitters of signals is the server, and it's all in the main client file.

The whole map pool is sent by the stat function. Probably want to catch that signal to build your own interface.

I don't think it's sent by the server without the client triggering the request, so you may have to ask for it first.
dict(action="stats", type="ladder_maps") should return a dict with
message = "stats"
type = "ladder_maps"
values = "[dict(idmap=id, mapname=mapname, maprealname=maprealname)]"

When the client receive that message, it send a signal already (I don't know it by heart, but it's in the list of signals in the main client file), and you can connect it to your own interface.
Nossa wrote:I've never played GPG or even heard of FA until FAF started blowing up.
User avatar
Ze_PilOt
Supreme Commander
 
Posts: 8985
Joined: 24 Aug 2011, 18:41
Location: fafland
Has liked: 18 times
Been liked: 376 times
FAF User Name: Ze_PilOt

Re: Creating the Map Veto function

Postby Alluminati » 07 Aug 2013, 17:31

Alright. I got no clue what the signals are yet and how to interpret them but if I'll come back to that after I managed the basics of the new interface.
User avatar
Alluminati
Crusader
 
Posts: 22
Joined: 01 Jul 2013, 16:32
Location: Germany
Has liked: 0 time
Been liked: 0 time
FAF User Name: Alluminati

Re: Creating the Map Veto function

Postby Ze_PilOt » 07 Aug 2013, 17:33

You will have to look at Qt/pyQt tutorials to understand how signals and slots are working.

This is not that complicated once you grasp the basic concept behind them.
Nossa wrote:I've never played GPG or even heard of FA until FAF started blowing up.
User avatar
Ze_PilOt
Supreme Commander
 
Posts: 8985
Joined: 24 Aug 2011, 18:41
Location: fafland
Has liked: 18 times
Been liked: 376 times
FAF User Name: Ze_PilOt

Re: Creating the Map Veto function

Postby Alluminati » 07 Aug 2013, 17:48

Yup I'm already at that point in the tutorial, I think I'm getting it ;-) This will be a lot of trial and error but it always is. I'll report back once I either produced something noteworthy or got a new question.

What I'm still not really getting is where the actual game UI is drawn... If I wanted to add a button to the game widget, where'd I place it?
User avatar
Alluminati
Crusader
 
Posts: 22
Joined: 01 Jul 2013, 16:32
Location: Germany
Has liked: 0 time
Been liked: 0 time
FAF User Name: Alluminati

Re: Creating the Map Veto function

Postby johnie102 » 08 Aug 2013, 21:49

Alluminati wrote:Yup I'm already at that point in the tutorial, I think I'm getting it ;-) This will be a lot of trial and error but it always is. I'll report back once I either produced something noteworthy or got a new question.

What I'm still not really getting is where the actual game UI is drawn... If I wanted to add a button to the game widget, where'd I place it?


The UI is made using Qt Designer. It is a program installed when you install pyqt. Designer creates .ui files that are loaded by the program.
Check \src\client\_clientwindow.py line 51. It loads it.
Designer should be easy enough to use.

Btw, the .ui file is actually just xml, so if you can't figure Designer out, you could just manually alter the xml ;)
johnie102
Avatar-of-War
 
Posts: 128
Joined: 27 Dec 2012, 22:26
Has liked: 0 time
Been liked: 2 times
FAF User Name: johnie102

Re: Creating the Map Veto function

Postby Alluminati » 17 Aug 2013, 03:42

Thanks johnie :)
I haven't been active for more than a week because of TI3 (dota) and a couple other things. Only got back to work on this two hours ago.

Alright, here's where I'm at right now:

Image

...

As you can see, I successfully managed to add a button and the dialog itself =P
That was a bit tricky for me but I got through it without major frustration.

Now here's my plan:
Somehow, I'll get the map list from the server. Somehow. I haven't figured ANY of that out yet.
The code will "manually" create checkboxes for each map in a loop. That'll be a shitload of trial and error.
Then, I'm going to count the amount of vetos already done and disable all checkboxes when the limit of 3 is reached.
When "Save Vetos" is pressed, I'll save the maps that got vetoed to an array.
This array should then be available to the client. (I haven't figured global variables out yet, so wish me luck.)

After that, I got no clue how to continue.

As I have literally NO idea about how to do any of this, expect a couple days to go before I report back with my next results. As an alternative to that, you can continue helping me :D
User avatar
Alluminati
Crusader
 
Posts: 22
Joined: 01 Jul 2013, 16:32
Location: Germany
Has liked: 0 time
Been liked: 0 time
FAF User Name: Alluminati

Re: Creating the Map Veto function

Postby johnie102 » 17 Aug 2013, 10:44

Just wanna say that if you type "QCheckBox doc" into google (or any other QThingy doc) the first result is the official doc.

You'll probably want to use a curried function to do stuff with the signals of the checkboxes.

Code: Select all
self.checkboxes = [list of checkboxes]
def generate_stuff(index):
    @QtCore.pyqtSlot(int)
    def f(self, index):
        handle_checkbox(index)
    return f
for i in range(len(self.checkboxes)):
    self.checkboxes[i].stateChanged.connect(generate_stuff(i))


hope it helps :)
johnie102
Avatar-of-War
 
Posts: 128
Joined: 27 Dec 2012, 22:26
Has liked: 0 time
Been liked: 2 times
FAF User Name: johnie102

Next

Return to Contributors

Who is online

Users browsing this forum: No registered users and 1 guest