Esempio n. 1
0
        public void Awake()
        {
            m_container                     = transform.gameObject.AddComponent <UIPanel>();
            m_container.width               = transform.parent.gameObject.GetComponent <UIComponent>().width;
            m_container.height              = 30;
            m_container.autoLayout          = true;
            m_container.autoLayoutDirection = LayoutDirection.Horizontal;
            m_container.autoLayoutPadding   = new RectOffset(2, 2, 2, 2);
            m_container.wrapLayout          = false;
            m_container.name                = "AzimuthEditorTitle";

            CreateTitleLabel(out UILabel m_cityId, "CityId", "#", 30);
            CreateTitleLabel(out UILabel m_azimuthInput, "StartAzimuth", Locale.Get("K45_ADR_AZIMUTH_GRADOS_TITLE"), 50);
            CreateTitleLabel(out UILabel m_direction, "Direction", Locale.Get("K45_ADR_DIRECTION_TITLE"), 60);
            CreateTitleLabel(out UILabel m_generatedName, "GenName", Locale.Get("K45_ADR_GEN_NAME_TITLE"), 150);

            KlyteMonoUtils.CreateUIElement(out UIButton add, m_container.transform, "RegenName");
            add.textScale = 1f;
            add.width     = 30;
            add.height    = 30;
            add.tooltip   = Locale.Get("K45_ADR_ADD_REG_CITY");
            KlyteMonoUtils.InitButton(add, true, "ButtonMenu");
            add.isVisible   = true;
            add.text        = "+";
            add.eventClick += (component, eventParam) => AdrNeighborhoodExtension.SetAzimuth(99, 0);
        }
Esempio n. 2
0
        private static bool GetNameBasedInAngle(OutsideConnectionAI __instance, out string __result, ref InstanceID caller, float angle, out bool canTrust)
        {
            Randomizer?randomizer = AdrNeighborhoodExtension.GetRandomizerAt(angle);

            if (randomizer == null)
            {
                __result = OriginalGenerateName(__instance, caller);
                canTrust = false;
                return(false);
            }
            var fileName = AdrController.CurrentConfig.GlobalConfig.NeighborhoodConfig.NamesFile ?? "";

            if (fileName == null || !AdrController.LoadedLocalesNeighborName.ContainsKey(fileName))
            {
                caller.Index = (uint)randomizer.GetValueOrDefault().seed;
                __result     = OriginalGenerateName(__instance, caller);
                canTrust     = true;
                return(false);
            }
            var file = AdrController.LoadedLocalesNeighborName[fileName];

            __result = file[randomizer.GetValueOrDefault().Int32((uint)file.Length)];
            canTrust = true;
            return(false);
        }
        private void RebuildList()
        {
            AdrAzimuthEditorLineNeighbor[] currentLines = m_uiHelperNeighbors.Self.GetComponentsInChildren <AdrAzimuthEditorLineNeighbor>();
            int stopsCount = AdrNeighborhoodExtension.GetStopsCount();

            if (stopsCount == 0)
            {
                stopsCount = 1;
            }

            m_borderCities = new List <AdrAzimuthEditorLineNeighbor>();
            int count = 0;

            for (int i = 0; i < stopsCount; i++, count++)
            {
                if (i < currentLines.Length)
                {
                    currentLines[i].SetLegendInfo(GetColorForNumber(i), i + 1);
                    m_borderCities.Add(currentLines[i]);
                }
                else
                {
                    AdrAzimuthEditorLineNeighbor line = KlyteMonoUtils.CreateElement <AdrAzimuthEditorLineNeighbor>(m_uiHelperNeighbors.Self.transform);
                    line.SetLegendInfo(GetColorForNumber(i), i + 1);
                    line.OnValueChange += ValidateAngleStr;
                    m_borderCities.Add(line);
                }
            }
            for (int i = count; i < currentLines.Length; i++)
            {
                GameObject.Destroy(currentLines[i].gameObject);
            }
            ReordenateFields();
        }
 public void SetLegendInfo(Color c, int id)
 {
     m_id           = id - 1;
     m_cityId.text  = (id % 100).ToString();
     m_cityId.color = c;
     m_azimuthInput.eventTextChanged -= SendText;
     m_azimuthInput.text              = AdrNeighborhoodExtension.GetAzimuth(m_id).ToString();
     m_azimuthInput.eventTextChanged += SendText;
     m_die.isVisible = m_id > 0;
 }
        private void SetFixedName(int idx, string val)
        {
            if (m_isLoading)
            {
                return;
            }

            AdrNeighborhoodExtension.SetFixedName(idx, val);
            ReordenateFields();
        }
        public void SetData()
        {
            var angle         = AdrNeighborhoodExtension.GetAzimuth(m_id);
            var cityNameFixed = AdrNeighborhoodExtension.GetFixedName(m_id);

            m_direction.text = CardinalPoint.GetCardinalPoint16(angle);
            bool canTrust = true;
            var  name     = cityNameFixed ?? OutsideConnectionAIOverrides.GetNameBasedInAngle(angle, out canTrust);

            m_generatedName.text    = name;
            m_generatedName.tooltip = name;
            if (cityNameFixed == null && !canTrust)
            {
                m_generatedName.text = "?????";
            }
        }
        private void RebuildList()
        {
            m_isLoading = true;
            AdrAzimuthEditorLineNeighbor[] currentLines = m_neighborsList?.GetComponentsInChildren <AdrAzimuthEditorLineNeighbor>();
            if (currentLines is null)
            {
                return;
            }

            int stopsCount = AdrNeighborhoodExtension.GetStopsCount();

            if (stopsCount == 0)
            {
                stopsCount = 1;
            }

            m_borderCities = new List <AdrAzimuthEditorLineNeighbor>();
            int count = 0;

            for (int i = 0; i < stopsCount; i++, count++)
            {
                if (i < currentLines.Length)
                {
                    currentLines[i].SetLegendInfo(GetColorForNumber(i), i + 1);
                    m_borderCities.Add(currentLines[i]);
                }
                else
                {
                    KlyteMonoUtils.CreateUIElement(out UIPanel newEntry, m_neighborsList.transform, "NeighborhoodEntry");
                    AdrAzimuthEditorLineNeighbor line = newEntry.gameObject.AddComponent <AdrAzimuthEditorLineNeighbor>();
                    line.SetLegendInfo(GetColorForNumber(i), i + 1);
                    line.OnValueChange     += ValidateAngleStr;
                    line.OnFixedNameChange += SetFixedName;
                    m_borderCities.Add(line);
                }
            }
            for (int i = count; i < currentLines.Length; i++)
            {
                GameObject.Destroy(currentLines[i].gameObject);
            }
            m_isLoading = false;
            ReordenateFields();
        }
        public void Awake()
        {
            m_container                     = transform.gameObject.AddComponent <UIPanel>();
            m_container.width               = transform.parent.gameObject.GetComponent <UIComponent>().width;
            m_container.height              = 30;
            m_container.autoLayout          = true;
            m_container.autoLayoutDirection = LayoutDirection.Horizontal;
            m_container.autoLayoutPadding   = new RectOffset(2, 2, 2, 2);
            m_container.wrapLayout          = false;
            m_container.name                = "AzimuthInputLine";

            KlyteMonoUtils.CreateUIElement(out m_cityId, m_container.transform, "CityId");
            m_cityId.autoSize         = false;
            m_cityId.relativePosition = new Vector3(0, 0);
            m_cityId.backgroundSprite = "EmptySprite";
            m_cityId.width            = 30;
            m_cityId.height           = 30;
            m_cityId.textScale        = 1.3f;
            m_cityId.padding          = new RectOffset(3, 3, 4, 3);
            m_cityId.useOutline       = true;
            m_cityId.textAlignment    = UIHorizontalAlignment.Center;

            KlyteMonoUtils.CreateUIElement(out m_azimuthInput, m_container.transform, "StartAzimuth");
            KlyteMonoUtils.UiTextFieldDefaults(m_azimuthInput);
            m_azimuthInput.normalBgSprite    = "OptionsDropboxListbox";
            m_azimuthInput.width             = 50;
            m_azimuthInput.height            = 28;
            m_azimuthInput.textScale         = 1.6f;
            m_azimuthInput.maxLength         = 3;
            m_azimuthInput.numericalOnly     = true;
            m_azimuthInput.text              = "0";
            m_azimuthInput.eventTextChanged += SendText;

            KlyteMonoUtils.CreateUIElement(out m_direction, m_container.transform, "Direction");
            m_direction.autoSize      = false;
            m_direction.width         = 60;
            m_direction.height        = 30;
            m_direction.textScale     = 1.125f;
            m_direction.textAlignment = UIHorizontalAlignment.Center;
            m_direction.padding       = new RectOffset(3, 3, 5, 3);

            KlyteMonoUtils.CreateUIElement(out UIPanel nameContainer, m_container.transform, "GenNameContainer");
            nameContainer.autoSize            = false;
            nameContainer.width               = 150;
            nameContainer.height              = 30;
            nameContainer.autoLayout          = true;
            nameContainer.autoLayoutDirection = LayoutDirection.Horizontal;

            KlyteMonoUtils.CreateUIElement(out m_generatedName, nameContainer.transform, "GenName");
            m_generatedName.autoSize      = true;
            m_generatedName.height        = 30;
            m_generatedName.textScale     = 1.125f;
            m_generatedName.padding       = new RectOffset(3, 3, 5, 3);
            m_generatedName.text          = "???";
            m_generatedName.textAlignment = UIHorizontalAlignment.Center;
            m_generatedName.minimumSize   = new Vector2(150, 0);
            KlyteMonoUtils.LimitWidth(m_generatedName, 150);

            KlyteMonoUtils.CreateUIElement(out m_regenerateName, m_container.transform, "RegenName");
            m_regenerateName.textScale = 1f;
            m_regenerateName.width     = 30;
            m_regenerateName.height    = 30;
            m_regenerateName.tooltip   = Locale.Get("K45_ADR_REGENERATE_NAME");
            KlyteMonoUtils.InitButton(m_regenerateName, true, "ButtonMenu");
            m_regenerateName.isVisible   = true;
            m_regenerateName.text        = "R";
            m_regenerateName.eventClick += (component, eventParam) =>
            {
                AdrNeighborhoodExtension.SetSeed(m_id, new Randomizer(new System.Random().Next()).UInt32(0xFEFFFFFF));
                OnRegenerate?.Invoke();
            };

            KlyteMonoUtils.CreateUIElement(out m_die, m_container.transform, "Delete");
            m_die.textScale = 1f;
            m_die.width     = 30;
            m_die.height    = 30;
            m_die.tooltip   = Locale.Get("K45_ADR_DELETE_STOP_NEIGHBOR");
            KlyteMonoUtils.InitButton(m_die, true, "ButtonMenu");
            m_die.isVisible   = true;
            m_die.text        = "X";
            m_die.eventClick += (component, eventParam) =>
            {
                AdrNeighborhoodExtension.SafeCleanEntry(m_id);
                OnDie?.Invoke();
            };
        }
        public void Awake()
        {
            m_container                     = GetComponent <UIPanel>();
            m_container.width               = m_container.parent.width;
            m_container.height              = 30;
            m_container.autoLayout          = true;
            m_container.autoLayoutDirection = LayoutDirection.Horizontal;
            m_container.autoLayoutPadding   = new RectOffset(2, 2, 2, 2);
            m_container.wrapLayout          = false;
            m_container.name                = "AzimuthInputLine";

            KlyteMonoUtils.CreateUIElement(out m_cityId, m_container.transform, "CityId");
            m_cityId.autoSize         = false;
            m_cityId.relativePosition = new Vector3(0, 0);
            m_cityId.backgroundSprite = "EmptySprite";
            m_cityId.width            = 30;
            m_cityId.height           = 30;
            m_cityId.textScale        = 1.3f;
            m_cityId.padding          = new RectOffset(3, 3, 4, 3);
            m_cityId.useOutline       = true;
            m_cityId.textAlignment    = UIHorizontalAlignment.Center;

            KlyteMonoUtils.CreateUIElement(out m_azimuthInput, m_container.transform, "StartAzimuth");
            KlyteMonoUtils.UiTextFieldDefaults(m_azimuthInput);
            m_azimuthInput.normalBgSprite    = "OptionsDropboxListbox";
            m_azimuthInput.width             = 50;
            m_azimuthInput.height            = 28;
            m_azimuthInput.textScale         = 1.6f;
            m_azimuthInput.maxLength         = 3;
            m_azimuthInput.numericalOnly     = true;
            m_azimuthInput.allowNegative     = true;
            m_azimuthInput.text              = "0";
            m_azimuthInput.eventTextChanged += SendText;
            m_azimuthInput.eventMouseWheel  += DefaultEditorUILib.RollInteger;

            KlyteMonoUtils.CreateUIElement(out m_direction, m_container.transform, "Direction");
            m_direction.autoSize      = false;
            m_direction.width         = 60;
            m_direction.height        = 30;
            m_direction.textScale     = 1.125f;
            m_direction.textAlignment = UIHorizontalAlignment.Center;
            m_direction.padding       = new RectOffset(3, 3, 5, 3);

            KlyteMonoUtils.CreateUIElement(out m_generatedName, m_container.transform, "GenName");
            KlyteMonoUtils.UiTextFieldDefaults(m_generatedName);
            m_generatedName.autoSize            = true;
            m_generatedName.height              = 30;
            m_generatedName.textScale           = 1.125f;
            m_generatedName.padding             = new RectOffset(3, 3, 5, 3);
            m_generatedName.text                = "???";
            m_generatedName.horizontalAlignment = UIHorizontalAlignment.Center;
            m_generatedName.width               = m_container.width - 235;
            m_generatedName.eventTextSubmitted += SetFixedName;
            m_generatedName.submitOnFocusLost   = true;


            m_die = DefaultEditorUILib.AddButtonInEditorRow(m_generatedName, CommonsSpriteNames.K45_X, () =>
            {
                AdrNeighborhoodExtension.SafeCleanEntry(m_id);
                OnDie?.Invoke();
            }, "K45_ADR_DELETE_STOP_NEIGHBOR", false, 30);

            DefaultEditorUILib.AddButtonInEditorRow(m_generatedName, CommonsSpriteNames.K45_Reload, () =>
            {
                AdrNeighborhoodExtension.SetSeed(m_id, new Randomizer(new System.Random().Next()).UInt32(0xFEFFFFFF));
                OnRegenerate?.Invoke();
            }, "K45_ADR_REGENERATE_NAME", false, 30);
        }
Esempio n. 10
0
 private void SaveAzimuthConfig(int idx, ushort value) => AdrNeighborhoodExtension.SetAzimuth(idx, value);
Esempio n. 11
0
        public void Awake()
        {
            m_container                     = GetComponent <UIPanel>();
            m_container.width               = m_container.parent.width;
            m_container.height              = 30;
            m_container.autoLayout          = true;
            m_container.autoLayoutDirection = LayoutDirection.Horizontal;
            m_container.autoLayoutPadding   = new RectOffset(2, 2, 2, 2);
            m_container.wrapLayout          = false;
            m_container.name                = "AzimuthEditorTitle";



            CreateTitleLabel(out UILabel m_cityId, "CityId", "#", 30);
            CreateTitleLabel(out UILabel m_azimuthInput, "StartAzimuth", Locale.Get("K45_ADR_AZIMUTH_GRADOS_TITLE"), 50);
            CreateTitleLabel(out UILabel m_direction, "Direction", Locale.Get("K45_ADR_DIRECTION_TITLE"), 60);
            CreateTitleLabel(out UILabel m_generatedName, "GenName", Locale.Get("K45_ADR_GEN_NAME_TITLE"), m_container.width - 247.5f);

            DefaultEditorUILib.AddButtonInEditorRow(m_generatedName, CommonsSpriteNames.K45_Plus, () => AdrNeighborhoodExtension.SetAzimuth(99, 0), "K45_ADR_ADD_REG_CITY", false, 30);
        }