Author Topic: Territories Importer issues  (Read 1337 times)

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #15 on: July 13, 2021, 11:38:12 PM »
I have a couple of land provinces that are completely inside sea provinces. The tooltip etc doesn't work on them.
Can this be made to work somehow, or should I change the sea regions so they never have a complete land province inside them (so each land province in the ocean borders to at least two sea provinces) ?

« Last Edit: July 13, 2021, 11:39:45 PM by Pollyfun »

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7262
    • View Profile
Re: Territories Importer issues
« Reply #16 on: July 14, 2021, 09:57:08 AM »
Try enabling enclaves. That option can be found under "Miscellanea" section at bottom of the inspector.

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #17 on: July 14, 2021, 07:54:12 PM »
I thought I had it enabled already, but that was in an earlier test. Thanks for pointing it out. Now those provinces work.

Additional question, after doing the import is there any way to access the color that was used in the texture for each province?
Something like 8CFFBA, 7CA3FF, 900AFF. If that's possible I could use that as a unique identifer, and connect it with the custom data I have for each.
Like:
(Province 0) 8CFFBA == "Weddell Island"
(Province 1) 7CA3FF == "Speedwell Island"
(Province 2) 900AFF == "Lafonia"
(Province 3) FF66AD == "Port Howard"

If not, do you know any suitable place during the import process where I can hook in and where the color is available so I can set a data-property (unique ID)?
« Last Edit: July 14, 2021, 07:58:18 PM by Pollyfun »

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7262
    • View Profile
Re: Territories Importer issues
« Reply #18 on: July 14, 2021, 08:40:31 PM »
The importer could add that info although you can also fetch it in the reverse way.
The center of a province is stored in province.mainRegion.center, which is a vector2 in the -0.5..0.5 range. Just add a "0.5" to convert that to texture coordinates and you can fetch the color of your territory texture.

Code
Vector2 textureCoordinates = province.mainRegion.center + new Vector2(0.5f, 0.5f);

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7262
    • View Profile
Re: Territories Importer issues
« Reply #19 on: July 16, 2021, 01:53:38 PM »
Next beta now adds an entity attribute which can be accessed and modified using country.attrib["ImporterColor"] or province.attrib["ImporterColor"].
See attached.
The format of this value is RRGGBB in hexadecimal.

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #20 on: July 17, 2021, 12:54:35 AM »
I did get a rough test to work using the code you provided and Texture2D.GetPixel(). But I'm not sure that it will work if the province is C-shaped, or some other shape where the center is not inside the province.
And additionally, it would require including the Province texture in the game which would take up memory unnecessarily.

I will test out the new attribute next. It looks much smoother.
« Last Edit: July 17, 2021, 11:29:43 AM by Pollyfun »

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #21 on: July 18, 2021, 04:44:34 PM »
The ImporterColor worked as described, so now I've matched the provinces with the custom data for each, which is an important step forward.


Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7262
    • View Profile
Re: Territories Importer issues
« Reply #22 on: July 18, 2021, 04:47:07 PM »
Nice!

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #23 on: July 18, 2021, 04:51:40 PM »
Now I'm looking at assigning provinces during load game.

CountryTransferProvince - when I use this it's quick, but it seems the regions for the countries aren't updated, so tooltip/highlighting doesn't work afterwards.
CountryTransferProvinceRegion - when I use this it looks correct but it takes a lot of time (10-20s) for 84 provinces.

Any advice on this is appreciated. Could CountryTransferProvinceRegion() be made quicker somehow when doing all provinces at once?

And a general question, is there a good reason that geodata for regions have to exist both in country and in the province? It seems a bit redundant.

Thanks

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7262
    • View Profile
Re: Territories Importer issues
« Reply #24 on: July 18, 2021, 08:14:37 PM »
Try latest beta. The method CountryTransferProvince will now also add the province regions to the country regions list.

Regarding the redundancy of region layers, the issue is that the asset can use just countries or both countries and provinces, so the geodata and highlighting system expects that each entity level has its own region data (could use different detail levels). If you just use countries + provinces, then yes, it could be optimized so country regions could be ignored and use directly the province regions (assuming every part of the world is covered by a province).. but it's not how currently works.

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #25 on: July 18, 2021, 11:25:26 PM »
Thanks for the explanation, and for the quick fix. Now it assigns the provinces correctly, and quickly.  :)

One remaining issue is that the black borders between countries are not in the correct place. The 3 provinces with the black borders shouldn't have them,
and the red line I painted on top is where the country border should actually be. Is there an easy way to refresh just the border?


Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7262
    • View Profile
Re: Territories Importer issues
« Reply #26 on: July 19, 2021, 09:28:29 AM »
The quick-transfer operation just adds the new regions of the provinces to the country region list so it will highilght independently.
The other function, which is slower, does the merging when land areas overlap. Could this be the reason? Feel free to send the geodata by pm so I can better understand the issue.

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #27 on: July 19, 2021, 10:40:34 PM »
I've sent the geodata in case it helps. I'll try to illustrate the situation better. After loading and assigning all provinces,
3 of the land provinces belongs to United Kingdom. The other land provinces belongs to Argentine, and all the ocean provinces
belongs to "Ocean Country". I believe there should a frontier/border between provinces owned by United Kingdom and provinces
owned by Argentine (the red line I drew).

In the second image I made frontiers bigger. They are not in the correct place, and there's also the black border around 3 provinces
(as before) which I don't know what it is.
« Last Edit: July 19, 2021, 10:44:58 PM by Pollyfun »

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #28 on: July 19, 2021, 11:07:40 PM »
I sent a PM with a video of the problem. The file was too big for posting.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7262
    • View Profile
Re: Territories Importer issues
« Reply #29 on: July 20, 2021, 10:54:50 AM »
Thank you, that was helpful.
Well, the issue with the new method (one of the reasons why the other one is slower) is that it didn't test if the province region would overlap any existing country region. This has been changed in latest beta, please try it.