Author Topic: WMSK.instance.showProvinces = true rehighlights countries  (Read 101 times)

hiddengearz

  • Newbie
  • *
  • Posts: 7
    • View Profile
I have a small script that shows the provinces when a player zooms in on the map.

Code
        private void Update()
        {
            //wip show provinces when zoomded in and don't show them when zoomed out.
            //May be a performance hog, look into
            //http://docs.unity3d.com/ScriptReference/Coroutine.html
            //http://docs.unity3d.com/ScriptReference/MonoBehaviour.InvokeRepeating.html
            if (WMSK.instance.showProvinces == false && WMSK.instance.GetZoomLevel() < 0.21f)
            {
                WMSK.instance.showProvinces = true;
                //WMSK.instance.Redraw();
                Debug.Log("show provices");
                Debug.Log(_player.Country);
                Debug.Log(_player.SelectedCountry);
            }
            else if (WMSK.instance.GetZoomLevel() > 0.21f && WMSK.instance.showProvinces == true)
            {
                WMSK.instance.showProvinces = false;
                //WMSK.instance.HighlightP = false;
                //WMSK.instance.Redraw();
                Debug.Log("hide provices");
            }

        }

I noticed that when you toggle WMSK.instance.showProvinces to true and your mouse enters a country that was previously highlighted it will automatically rehighlight it. Please see this video for an example https://youtu.be/rahmBhvIqnk

You can see that every country that was highlighted when picking a country was rehighlighted when WMSK.instance.showProvinces = true and my mouse entered the country.

On the country select screen, the code to highlight the country is the following.


Code
void OnCountryClick(int countryIndex, int regionIndex, int buttonIndex)
        {
            if (UIManager.Instance.CurrentUI.gameObject.name == gameObject.name)
            {
                _player.Country = WMSK.instance.GetCountry(countryIndex);
             
                if (_player.Country.name == _selectedCountry.text) //if country that was clicked matches, already selected country
                {
                    Debug.Log("return");
                    return;

                } else //if already selected country != country that was clicked
                {
                    //unhighlight old country
                    Debug.Log("else " + _player.Country.name);
                    WMSK.instance.ToggleCountryOutline(WMSK.instance.GetCountryIndex(_selectedCountry.text), false);

                    //highlight new country
                    _player.Country = WMSK.instance.GetCountry(countryIndex);
                    WMSK.instance.ToggleCountryOutline(countryIndex, true, borderWidth: 0.4f, tintColor: new Color(1, 0, 0, 1));
                    _selectedCountry.text = _player.Country.name;
                    _PlayButton.interactable = true;

                    UIManager.Instance.tmpvar = _player.Country.name;
                }

            }
        }

Note, the selected country is un-highlighted when they exit that screen with the same code under the  //unhighlight old country comment.

I think that somewhere in WMSK when WMSK.instance.showProvinces = true when your mouse enters the border of a previously highlighted country (even tho visibile = false) WMSK will re-enable the highlight.
« Last Edit: July 31, 2021, 08:40:02 PM by hiddengearz »

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7262
    • View Profile
Re: WMSK.instance.showProvinces = true rehighlights countries
« Reply #1 on: August 02, 2021, 01:18:12 PM »
Found the issue. When a country is hidden (country.hidden = true), enabling provinces will ignore that and highlight the country when mouse is over one of its provinces. This has been fixed (stay tuned for next beta).

hiddengearz

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: WMSK.instance.showProvinces = true rehighlights countries
« Reply #2 on: August 03, 2021, 04:59:47 AM »
Thanks!