Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add graph/timeline colors based on country flags #80

Closed
chennin opened this issue Nov 24, 2022 · 10 comments · Fixed by #117
Closed

Add graph/timeline colors based on country flags #80

chennin opened this issue Nov 24, 2022 · 10 comments · Fixed by #117

Comments

@chennin
Copy link
Contributor

chennin commented Nov 24, 2022

Hi, so first off, I have a branch where this is "done", but there's several maybe-issues and I'm not sure I like the design. So this is to discuss.

Second, it looks like this: https://imgur.com/a/f75FweM (Serious Empire is shadow_blue/white, Vulpes is orange/black, Mandasura is blue/black, and Zaxxod is dark_brown/blue)

  • I've added letter outlining and increased the font size because reading dark colors on black is hard. Can be adjusted
  • I take the secondary empire color as the map color because that's what the game does for the fill, except if it's white or black because those look bad, in which case I try the primary color or random
  • You may notice two empires got the same blue color. This is one of the issues.

Discussion:

  • I added parsing of the empire's colors from the save. In the save format don't know what the 3rd and 4th are, but the 1st is the primary color (map border) and the 2nd is the secondary (map fill). Anyone know what the others represent, if present?
  • I saved the colors in the database. Adding columns means that all existing databases can't be loaded by the new code. Users could re-parse saves, but since the game doesn't keep more than 5 autosaves, this loses a ton of data if the dashboard parsed previous autosaves. I didn't find a way to either ignore the missing column error or auto migrate. I could write a one-time migration script that adds the columns manually?
  • I'm not sure how to handle when two empires have the same color. It seems obvious to pick a different color for clarity on the display, but I didn't get far enough in understanding the code to know the best place to do so. My implementation changes some function signatures (optionally), cascading down to visualization_data.get_color_vals() which is the lowest-level color picking function and now does a database call. So I also implemented some storing of the colors in a few higher places. I'm not sure I like this design. But I wasn't sure where else to do the database calls, or where best to cache the retrieved colors. Thoughts?
  • I didn't see an easy way to implement empire borders with the other color. I was able to implement borders around each system (not committed), but lines around every system was pretty ugly, and I'm not really familiar with matplotlib or plotly so I'm just reading the boring manual here :). This is probably a nice-to-have, but might be a different solution to the same-empire-color problem. Thoughts on how to draw a border around each contiguous empire holding?
@eliasdoehne
Copy link
Owner

eliasdoehne commented Dec 3, 2022

Yes, having consistent (or at least similar) colors would be a huge improvement! I tried this before but could never finish it due to time limitations.

I added parsing of the empire's colors from the save. In the save format don't know what the 3rd and 4th are, but the 1st is the primary color (map border) and the 2nd is the secondary (map fill). Anyone know what the others represent, if present?

I had the same question and didn't manage to fully figure it out at the time. I believe it's actually a different file that is relevant here: flags/colors.txt, it looks like this one controls the exact shade to be used in different contexts (flag, map, ship) as well as the combinations of colors that may be assigned together, it is split into two sections which look like this:

colors = {
dark_brown         = { flag = rgb { 58 38 23 } map = rgb {107 68 40} ship = rgb {255 228 136 } }
brown         = { flag = rgb { 101 66 40 } map = rgb {156 91 45} ship = rgb {255 228 136 } }
...
}
		randomizable_combo = { orange black orange }
		randomizable_combo = { black orange orange }
...

This is also one of the files that is modified by country color mods like this one, so I'm pretty sure that it's the right place.

I am not sure how the colors in the save file map to this. I think one of the additional colors might be used if the country is part of a federation or some similar in-game condition? But this is just a guess.

I didn't find a way to either ignore the missing column error or auto migrate. I could write a one-time migration script that adds the columns manually?

I researched this before and at some point just accepted that there will be breaking changes like this from time to time and decided not to worry too much about backwards compatibility. It means that users will have to start a new game, but this usually happens with every major game update anyway. When I have time to work on the dashboard, I usually start with non-breaking updates first so anyone stuck on the old version can at least get one more round of bug fixes. That said, if you have some idea or experience for handling migrations in sqlalchemy that doesn't add much work, I would reconsider it.

I'm not sure how to handle when two empires have the same color

Good question, we can first try draw some borders as you suggested. I'll have another look at the scipy Voronoi data structure. Maybe I can make some small example work. Alternatively (or additionally), we can apply some small hue offset based on a hash of the country name, similar to the current approach. Or we check the number of countries with the same color and space it out evenly over some range

Overall from taking a look at the code, I think your solution is quite good. The only bigger change I would add is to obtain the available colors at runtime, similar to how the localization of names is handled. I think it is quite common to mod and it would be great to have compatibility with that.

@eliasdoehne
Copy link
Owner

eliasdoehne commented Dec 3, 2022

definitely seems doable to add some borders. Here I have them between systems connected by hyperlane (I just put it in the edge metadata for a first test), but I can adapt it to surround each country instead

test

@eliasdoehne
Copy link
Owner

eliasdoehne commented Dec 3, 2022

I have it now like this, there's another special case needed to handle the artificial boundary at the inner and outer galaxy edge. Of course also the border colors will need adjustment :D asdf

I'll add that and share my code tomorrow

@chennin
Copy link
Contributor Author

chennin commented Dec 3, 2022

Wow, that looks great!

@eliasdoehne
Copy link
Owner

eliasdoehne commented Dec 3, 2022

I agree, it looks much clearer with the borders. I pushed my changes here but I'll have another look tomorrow to clean up the duplicated code a bit: #84

It looks like this now:
Screenshot from 2022-12-03 20-12-44

This was faster than I expected, so maybe I can try something else for the colors tomorrow. Maybe I'll try the part I mentioned about parsing them from the game files, I think your branch actually covers most other changes already.

@chennin
Copy link
Contributor Author

chennin commented Dec 24, 2022

Updated the branch to lastest master to include the lined borders

https://imgur.com/a/NWf1oEN

I changed the names to medium size, white outlined by black as I found it the most readable, though I didn't like losing the color name. Maybe the text outline should be a different discussion/PR as it's a small change separate to map colors matching empire flag.

@MichaelMakesGames
Copy link
Collaborator

@eliasdoehne are you working or planning on working on this? If not, I can take a look

@eliasdoehne
Copy link
Owner

eliasdoehne commented Nov 11, 2023

I am not working on this, but thought a bit about it previously. It would be great if you want to pick it up!

You'll probably need to add the colors to the Country, populate that from the save file here (can they change over time?) and map to a color value at runtime (replacing/extending this).

I am not sure about duplicate color assignments, so maybe it makes sense to keep the random colors for line graphs, or apply some random offsets to the country colors. (I think for the map this is no problem)

@MichaelMakesGames
Copy link
Collaborator

Thanks for the pointers to relevant code; that helps.

can they change over time?

yes, though the only case I know of is color changing to red when forming the galactic imperium

apply some random offsets to the country colors

maybe we can detect duplicate colors, and lighten/darken the duplicates to be distinct (but preserve the hue for consistency)

@MichaelMakesGames
Copy link
Collaborator

Screenshot from 2023-11-11 20-23-52

The above is a screenshot implementing lightness-shifting to avoid conflicts. Originally, the 2 top lines were the same color (see below):

Screenshot from 2023-11-11 20-26-50

Thoughts @eliasdoehne?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants