Opened 12 years ago
Last modified 8 years ago
#1580 closed enhancement
[PATCH] Change player color in the gamesetup — at Version 16
Reported by: | O.Davoodi | Owned by: | Stan |
---|---|---|---|
Priority: | Nice to Have | Milestone: | Alpha 19 |
Component: | UI & Simulation | Keywords: | patch |
Cc: | Patch: |
Description (last modified by )
Discussion here http://www.wildfiregames.com/forum/index.php?showtopic=16318
Change History (26)
comment:1 by , 11 years ago
Milestone: | Alpha 12 → Backlog |
---|
comment:2 by , 11 years ago
Owner: | removed |
---|
comment:3 by , 11 years ago
Owner: | set to |
---|
by , 11 years ago
Attachment: | customColorSupport.patch added |
---|
comment:4 by , 11 years ago
Keywords: | review patch added |
---|---|
Milestone: | Backlog → Alpha 15 |
Based on the previous work that Spahbod posted in the forums, I’m attaching a patch which in addition does the following:
- Keeps color display names in a string of their own, in preparation for the internationalization feature (#67).
- Sorts colors in the drop-down list by color.
Although I was planning on doing so, I refrained from including ancient-themed colors. I think that needs more discussion (even if we all agree on doing it, we still need to agree on the RGB and display name of the values to be added), and I’ll try to bump the forum thread about it.
Adding new colors is as easy as editing the relevand JavaScript object in code. In the future, we could even move such data into a separated .json file if needed.
Note also that the implementation is prepared to deal with a color defined in simulation/data/player_defaults.json not being available in the JavaScript object that defined colors and color names in the GUI code. This is to keep simulation and gui code separated, as they should not depend in one another. When this occurs (a color is unknown in the GUI), the drop-down list shows empty, and lets you either keep the current, unknown color, or change to another color; if you change, you can not select back any unknown color. (you’ll probably need to actually read the code to understand this, just look for “-1” in the patch)
comment:5 by , 11 years ago
Summary: | Adding the ability to change player colour in game setup → [PATCH] Adding the ability to change player colour in game setup |
---|
comment:6 by , 11 years ago
Owner: | removed |
---|
comment:7 by , 10 years ago
Milestone: | Alpha 15 → Alpha 16 |
---|
comment:8 by , 10 years ago
Keywords: | color gamesetup review removed |
---|
Can you make this patch work for skirmish maps too?
And the patch causes some problems when using a low resolution. The colour picker should be made smaller. Maybe only showing coloured squares instead of colour names?
comment:9 by , 10 years ago
Milestone: | Alpha 16 → Alpha 17 |
---|
comment:10 by , 10 years ago
Milestone: | Alpha 17 → Backlog |
---|
comment:11 by , 9 years ago
Owner: | set to |
---|
by , 9 years ago
WIP patch, it's currently broken for some reason, help is appreciated. I can't get the drop down to appear
comment:12 by , 9 years ago
Note that the json file will be removed, I added it in the patch, cause I forgot to delete it. It actually use default_players to get the colors.
comment:13 by , 9 years ago
- Please create the patch relatively to the trunk directory, so that we can apply the patch from there
settings.js
PlayerColors
instead ofPlayer_Colors
- the code was updated
gamesetup.js
- ++o instead of o++. I'd prefer
n
ori
overo
. But even better would be to remove that loop and just use array.find(...).length if possible.
getIndexOfColor
don't need to dovar playerColorsSorted = getPlayerColorsSorted();
every cycle, only once. replace the for loop by a call tofindIndex
rgbToHsl
- exact same function as inlobby.js
. we should annoy the devs with a ticket that movesrgbToHsl
andhslToRgb
to a new filecommon/color.js
(the other color functions from lobby.js are almost all baloney, for example the rainbow colored pony-nicknames, and must be deleted in #3383 or so instead of being moved)
getPlayerColorsSorted()
- early return
[]
instead ofnew Array()
- replacing for with map might be possible
- if the block has only one line, the brackets can be removed (unless neede for aesthetics)
let
instead ofvar
in nested blocks so that theoretically a bit of performance can be savedouterloop
: try to avoid jumping to labels, I bet we can use a map or something similar for the inner loop and omit the problem that way
copyRgbValuesFromColorIntoColor
- whitespace
gamesetup.xml
- a tab missing
- the position/size you gave the color picker is almost identical to the position of the player assignment dropdown. That might be why the former is invisible (but shows the tooltip when hovering) and why the latter seems disabled. The values are "left top right bottom". The "right" value of the left element must be smaller than the "left" value of the right element, etc. Where do you want to palce the color picker? Left of the playername? The xml should be moved to the correct location too.
Some rtfm's: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf and the other array functions linked there https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions http://trac.wildfiregames.com/wiki/Coding_Conventions
by , 9 years ago
Attachment: | 1580.4.diff added |
---|
by , 9 years ago
Attachment: | 1580.5.diff added |
---|
by , 9 years ago
Attachment: | 1580.7.diff added |
---|
comment:14 by , 9 years ago
Milestone: | Backlog → Alpha 19 |
---|
- hardcore cleanup
- gaia color not selectable anymore
- colors are actually used ingame after selecting them
TODO:
- only host can chose colors
- dropdown element should list only colors that are not picked yet
- discovered a dropdown list GUI bug. looks like the width of the scrollbar is subtracted even if the scrollbar doesn't exist. Might also have something to do with the xml / width.
by , 9 years ago
Attachment: | 1580.8.diff added |
---|
comment:15 by , 9 years ago
Keywords: | review added |
---|
- As agreed on IRC, it's better for now that only the host can change colors, so that there is no fight about it.
- There is no need for not showing colors, since we swap between them when they are being used.
- Only the gui bug remains on certain resolutions. see #3415
comment:16 by , 9 years ago
Description: | modified (diff) |
---|---|
Summary: | [PATCH] Adding the ability to change player colour in game setup → [PATCH] Change player color in the gamesetup |
by , 9 years ago
Attachment: | l10n_longestStrings.7z added |
---|
Mock language that contains the longest strings found in the translations of r17026.
Patch based on the work started by Spahbod.