eliasdoehne / stellaris-dashboard

A graph dashboard and event log for Stellaris.
123 stars 14 forks source link

Add graph/timeline colors based on country flags #80

Closed chennin closed 10 months ago

chennin commented 1 year ago

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)

Discussion:

eliasdoehne commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Wow, that looks great!

eliasdoehne commented 1 year ago

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: https://github.com/eliasdoehne/stellaris-dashboard/pull/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 commented 1 year ago

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 commented 11 months ago

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

eliasdoehne commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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?