Page 1 of 1
gameoptions values order
Posted: 04 July 2020, 19:27
by Idsky
Quantum has a big list of map options, 0 to 50-odd
Code: Select all
101 => array(
'name' => totranslate('Map and cube count'),
'values' => array(
0 => array(
'name' => totranslate('Basic map'),…
1 => array(…
I want to add my 'Random 6 or 7 cube map' option near the top of the list (and a couple new maps in the middle). But it seems that the list gets sorted by key value when displayed in table setup, so I need to move every item 7 through 56 by 1 number!?
I hate to do this as I didn't want to change the IDs for all existing maps. Anyone setting up a table when the update gets done will get the wrong map I think! And old database IDs won't match. Any suggestions?
Re: gameoptions values order
Posted: 05 July 2020, 08:21
by Brainchild
I haven't tried this myself, but you could add it with a key value of 0.5 and see what happens.
Re: gameoptions values order
Posted: 05 July 2020, 12:52
by Idsky
Brainchild wrote: ↑05 July 2020, 08:21
I haven't tried this myself, but you could add it with a key value of 0.5 and see what happens.
PHP truncates float values used as array keys (i.e. it will truncate 6.5 to an integer value of 6). PHP can have string (text) keys like "6a" but I believe BGA requires integer options, the global_value field in the DB is an INT.
I think gaps in your option values (like use 10,20,30) would work and would be a good idea to prevent this problem (at least for a while! It's line old-school programming with line numbers!). But Quantum map options are all consecutive currently. I'll experiment a bit more but it's looking like I need to break things to add stuff (in the right place in the option list) which sucks. I believe Arena mode settings are controlled by admins, and any player map preference settings would become invalid. I wish it'd just use the order in the gameoptions.inc.php file array regardless of the key values.
Re: gameoptions values order
Posted: 05 July 2020, 13:36
by Brainchild
Another idea I haven't tried: if you sort the options array with uksort and a custom comparison function, is the new order respected or is BGA framework re-sorting it before presenting it to the player?
Re: gameoptions values order
Posted: 05 July 2020, 15:14
by Idsky
Brainchild wrote: ↑05 July 2020, 13:36
Another idea I haven't tried: if you sort the options array with uksort and a custom comparison function, is the new order respected or is BGA framework re-sorting it before presenting it to the player?
I carefully put option 65 in between 52 and 53 in both the values and the startcondition array assignments in gameoptions.inc.php. So that's the correct order they are in before the BGA lobby code does it's thing to them -- BGA must be sorting them numerically by key before display in the select form field, but I really don't know why it would do that! A 'do_not_sort' option would be great!
Re: gameoptions values order
Posted: 06 July 2020, 08:27
by Idsky
Guess I'll just have to add my options in a pile right at the bottom of the list instead of in the correct sections. Make a 'New Maps' section. Better than breaking stuff that references the existing map ID options.
If anyone can offer a solution to move my new IDs to the right place I can update it again.
Re: gameoptions values order
Posted: 06 July 2020, 12:34
by Een
We probably need to do something on the framework side for option ordering. Some games indeed have a lot of options, and when adding options later on it can become an issue.
In any case, the option ids should not be changed once the game is in production, in order not to break ongoing game, and audience option statistics.
Categorizing new maps in a separate bottom section may also be better to make clear that they are not part of the original maps.
Re: gameoptions values order
Posted: 06 July 2020, 15:12
by Idsky
Een wrote: ↑06 July 2020, 12:34
We probably need to do something on the framework side for option ordering. Some games indeed have a lot of options, and when adding options later on it can become an issue.
In any case, the option ids should not be changed once the game is in production, in order not to break ongoing game, and audience option statistics.
Categorizing new maps in a separate bottom section may also be better to make clear that they are not part of the original maps.
Thanks for the official response. I expected it would be bad to change any existing option IDs.
Why does it sort the array by key value — why not just leave it in the order assigned in gameoptions.inc.php? I guess now it does that, changing it could upset some existing games that expect it. I'll ask for a 'do_not_sort' option in suggestions.
Putting my new maps at the bottom is fine, but I had a request for a 'Random 6 or 7 cube advanced map' which *should* go near the top, below 'Random 6 cube map'.
Also, I intend to add two original maps which were meant to be in the game but were excluded due to dimensions. With my new scaling, I think it's fine to include them… I will make a 'huge map' category for anything bigger than 5x5 with an on/off option though, if phone users find them a bit annoying still.