Пример #1
0
        public UIColorField AddColorPicker(string name, Color defaultValue, OnColorChanged eventCallback, out UILabel title)
        {
            if (eventCallback != null && !string.IsNullOrEmpty(name))
            {
                UIPanel panel = m_Root.AttachUIComponent(UITemplateManager.GetAsGameObject(UIHelperExtension.kDropdownTemplate)) as UIPanel;
                panel.name = "DropDownColorSelector";
                title      = panel.Find <UILabel>("Label");
                title.text = name;
                panel.autoLayoutDirection       = LayoutDirection.Horizontal;
                panel.wrapLayout                = false;
                panel.autoFitChildrenVertically = true;
                GameObject.Destroy(panel.Find <UIDropDown>("Dropdown").gameObject);
                var colorField = KlyteUtils.CreateColorField(panel);

                colorField.eventSelectedColorReleased += (cp, value) =>
                {
                    eventCallback(value);
                };

                return(colorField);
            }
            DebugOutputPanel.AddMessage(PluginManager.MessageType.Warning, "Cannot create colorPicker with no name or no event");
            title = null;
            return(null);
        }
Пример #2
0
        private void Awake()
        {
            SVMServiceBuildingDetailPanel.eventOnDistrictSelectionChanged += onDistrictChanged;


            mainPanel            = GetComponentInChildren <UIScrollablePanel>();
            mainPanel.autoLayout = false;
            m_uiHelper           = new UIHelperExtension(mainPanel);

            SVMUtils.createUIElement(out UILabel lbl, mainPanel.transform, "DistrictColorLabel", new Vector4(5, 5, 250, 40));

            allowColorChange = SVMConfigWarehouse.allowColorChanging(extension.ConfigIndexKey);
            if (allowColorChange)
            {
                SVMUtils.LimitWidth(lbl, 250);
                lbl.autoSize = true;
                lbl.localeID = "SVM_DISTRICT_COLOR_LABEL";

                m_districtColor = KlyteUtils.CreateColorField(mainPanel);
                m_districtColor.eventSelectedColorChanged += onChangeDistrictColor;

                SVMUtils.createUIElement(out UIButton resetColor, mainPanel.transform, "DistrictColorReset", new Vector4(290, 0, 0, 0));
                SVMUtils.initButton(resetColor, false, "ButtonMenu");
                SVMUtils.LimitWidth(resetColor, 200);
                resetColor.textPadding = new RectOffset(5, 5, 5, 2);
                resetColor.autoSize    = true;
                resetColor.localeID    = "SVM_RESET_COLOR";
                resetColor.eventClick += onResetColor;
            }


            SVMUtils.createElement(out m_assetSelectorWindow, mainPanel.transform);
            m_assetSelectorWindow.setTabContent(this);
        }
Пример #3
0
        protected Dictionary <T, string> GetValueFromStringArray(string x)
        {
            var    saida = new Dictionary <T, string>();
            string value;

            if (x.Contains(KvSepLvl1))
            {
                string[] array = x.Split(KvSepLvl1.ToCharArray());
                value = array[1];
            }
            else
            {
                value = x;
            }
            foreach (string item in value.Split(ItSepLvl2.ToCharArray()))
            {
                var kv = item.Split(KvSepLvl2.ToCharArray());
                if (kv.Length != 2)
                {
                    continue;
                }
                try
                {
                    T subkey = (T)Enum.Parse(typeof(T), kv[0]);
                    saida[subkey] = kv[1];
                }
                catch (Exception e)
                {
                    KlyteUtils.doLog("ERRO AO OBTER VALOR STR ARR: {0}", e.StackTrace);
                    continue;
                }
            }
            return(saida);
        }
        public void Awake()
        {
            if (instance != null)
            {
                Destroy(this);
                return;
            }
            instance = this;
            GameObject gameObject = GameObject.FindGameObjectWithTag("MainCamera");

            if (gameObject != null)
            {
                m_CameraController = gameObject.GetComponent <CameraController>();
            }
            createInfoView();
            CreateIgnoreDistrictOption();

            SVMUtils.createUIElement(out UIPanel confContainer, panelTransform, "SubConfigContainer", new Vector4(m_buildingInfoPanel.width, 0, 0, m_buildingInfoPanel.height));
            confContainer.autoLayout          = true;
            confContainer.autoLayoutDirection = LayoutDirection.Horizontal;
            confContainer.wrapLayout          = false;
            confContainer.height       = m_buildingInfoPanel.height;
            confContainer.clipChildren = false;

            foreach (var kv in ServiceSystemDefinition.sysDefinitions)
            {
                Type targetType = KlyteUtils.GetImplementationForGenericType(typeof(SVMBuildingSSDConfigWindow <>), kv.Value);
                SVMUtils.createElement(targetType, confContainer.transform);
            }
        }
Пример #5
0
        public override void AwakeBody()
        {
            KlyteUtils.doLog("Loading NonKCModsOverrides");
            #region Suburb Styler
            foreach (var typeName in supportedClasses)
            {
                var type = Type.GetType(typeName);
                try
                {
                    if (type != null)
                    {
                        KlyteUtils.SetPrivateStaticField("GetMainReference", type, new Func <UIComponent>(() => KlyteModsPanel.instance.mainPanel));
                        KlyteUtils.SetPrivateStaticField("ClosePanel", type, new OnButtonClicked(() => KlyteCommonsMod.CloseKCPanel()));
                        KlyteUtils.SetPrivateStaticField("OpenPanel", type, new OnButtonClicked(() => KlyteModsPanel.instance.OpenAt((ModTab)Enum.Parse(typeof(ModTab), KlyteUtils.RunPrivateStaticMethod <string>(type, "GetEnumName")))));



                        MethodInfo createPanelOverride = typeof(NonKCModsOverrides).GetMethod("CreateMainPanelOverride", allFlags);

                        AddRedirect(type.GetMethod("CreateMainPanel", allFlags), createPanelOverride);
                    }
                }
                catch (Exception e)
                {
                    KlyteUtils.doErrorLog($"{e.GetType()} detouring {type}: {e.Message}\n{e.StackTrace}");
                }
            }
            #endregion
        }
Пример #6
0
        private UILabel criaFatiaELegenda(Color c, UIRadialChartExtended chart, UIPanel legendPanel = null, string localeID = "", float offsetY = 0)
        {
            chart.AddSlice(c, c);
            UIPanel legendItemContainer = null;

            if (legendPanel != null)
            {
                KlyteUtils.createUIElement(out legendItemContainer, legendPanel.transform);
                legendItemContainer.width            = legendPanel.width;
                legendItemContainer.relativePosition = new Vector3(0f, offsetY);
                legendItemContainer.name             = "LegendItem";
                legendItemContainer.autoLayout       = false;
                legendItemContainer.useCenter        = true;
                legendItemContainer.wrapLayout       = false;
                legendItemContainer.height           = 20;
                KlyteUtils.createUIElement(out UILabel legendColor, legendItemContainer.transform);
                legendColor.backgroundSprite = "EmptySprite";
                legendColor.width            = 10;
                legendColor.height           = 10;
                legendColor.relativePosition = new Vector3(0, 0);
                legendColor.color            = c;
                KlyteUtils.createUIElement(out UILabel legendName, legendItemContainer.transform);
                legendName.textAlignment     = UIHorizontalAlignment.Right;
                legendName.width             = legendItemContainer.width - 10;
                legendName.localeID          = localeID;
                legendName.textScale         = 0.6f;
                legendName.relativePosition  = new Vector3(15f, 2f);
                legendName.verticalAlignment = UIVerticalAlignment.Middle;
                return(legendName);
            }
            return(null);
        }
Пример #7
0
        protected List <Dictionary <T, string> > LoadConfigList(K idx, bool global = false)
        {
            var result = new List <Dictionary <T, string> >();

            KlyteUtils.doLog("{0} load()", idx);
            string[] itemListLvl1;
            if (global && !AllowGlobal)
            {
                throw new Exception("CONFIGURAÇÂO NÃO GLOBAL TENTOU SER CARREGADA COMO GLOBAL: " + typeof(U));
            }
            if (global)
            {
                itemListLvl1 = Singleton <I> .instance.getConfig2().getString(idx).Split(ItSepLvl1.ToCharArray());
            }
            else
            {
                itemListLvl1 = Singleton <I> .instance.currentLoadedCityConfig.getString(idx).Split(ItSepLvl1.ToCharArray());
            }

            if (itemListLvl1.Length > 0)
            {
                KlyteUtils.doLog("{0} load(): file.Length > 0", idx);
                foreach (string s in itemListLvl1)
                {
                    var value = GetValueFromStringArray(s);
                    result.Add(value);
                }
                KlyteUtils.doLog("{0} load(): dic done", idx);
            }
            return(result);
        }
Пример #8
0
        private void CreateColorSelector()
        {
            TLMUtils.createUIElement(out UIPanel panelColorSelector, m_subpanel.self.transform, "ColorSelector", new Vector4(500, 60, 0, 0));
            panelColorSelector.autoLayout                  = true;
            panelColorSelector.autoLayoutDirection         = LayoutDirection.Horizontal;
            panelColorSelector.autoLayoutPadding           = new RectOffset(3, 3, 0, 0);
            panelColorSelector.autoFitChildrenHorizontally = true;
            panelColorSelector.autoFitChildrenVertically   = true;

            TLMUtils.createUIElement(out UILabel lbl, panelColorSelector.transform, "PrefixColorLabel", new Vector4(5, 12, 250, 40));
            TLMUtils.LimitWidth(lbl, 250, true);
            lbl.localeID          = "TLM_PREFIX_COLOR_LABEL";
            lbl.verticalAlignment = UIVerticalAlignment.Middle;
            lbl.font = UIHelperExtension.defaultFontCheckbox;

            m_prefixColor = KlyteUtils.CreateColorField(panelColorSelector);
            m_prefixColor.eventSelectedColorChanged += onChangePrefixColor;

            TLMUtils.createUIElement(out UIButton resetColor, panelColorSelector.transform, "PrefixColorReset", new Vector4(290, 0, 0, 0));
            TLMUtils.initButton(resetColor, false, "ButtonMenu");
            TLMUtils.LimitWidth(resetColor, 200);
            resetColor.textPadding = new RectOffset(5, 5, 5, 2);
            resetColor.autoSize    = true;
            resetColor.localeID    = "TLM_RESET_COLOR";
            resetColor.eventClick += onResetColor;
        }
Пример #9
0
        public override void AwakeBody()
        {
            KlyteUtils.doLog("Loading Instance Manager Overrides");
            #region Release Line Hooks
            MethodInfo posRename = typeof(InstanceManagerOverrides).GetMethod("OnInstanceRenamed", allFlags);

            AddRedirect(typeof(InstanceManager).GetMethod("SetName", allFlags), null, posRename);
            #endregion
        }
        public override void AwakeBody()
        {
            KlyteUtils.doLog("Loading Transport Manager Overrides");
            #region Release Line Hooks
            MethodInfo posUpdate = typeof(TransportManagerOverrides).GetMethod("RunOnLineUpdated", allFlags);

            AddRedirect(typeof(TransportManager).GetMethod("UpdateLine", allFlags), null, posUpdate);
            #endregion
        }
Пример #11
0
        protected static I construct(string cityId, string cityName)
        {
            if (string.IsNullOrEmpty(cityId))
            {
                throw new Exception("CITY ID NÃO PODE SER NULO!!!!!");
            }
            I result = new I
            {
                cityId   = cityId,
                cityName = cityName
            };
            SettingsFile settingFile = new SettingsFile
            {
                pathName = result.thisPathName
            };

            GameSettings.AddSettingsFile(settingFile);

            if (!settingFile.IsValid() && cityId != GLOBAL_CONFIG_INDEX)
            {
                try
                {
                    I defaultFile = getConfig(GLOBAL_CONFIG_INDEX, GLOBAL_CONFIG_INDEX);
                    foreach (string key in GameSettings.FindSettingsFileByName(defaultFile.thisFileName).ListKeys())
                    {
                        try
                        {
                            T ci = (T)Enum.Parse(typeof(T), key);
                            switch (ci.ToInt32(CultureInfo.CurrentCulture.NumberFormat) & TYPE_PART)
                            {
                            case TYPE_BOOL:
                                result.setBool(ci, defaultFile.getBool(ci));
                                break;

                            case TYPE_STRING:
                            case TYPE_LIST:
                                result.setString(ci, defaultFile.getString(ci));
                                break;

                            case TYPE_INT:
                                result.setInt(ci, defaultFile.getInt(ci));
                                break;
                            }
                        }
                        catch (Exception e)
                        {
                            KlyteUtils.doErrorLog($"Erro copiando propriedade \"{key}\" para o novo arquivo da classe {typeof(I)}: {e.Message}");
                        }
                    }
                }
                catch
                {
                }
            }
            return(result);
        }
        public override void AwakeBody()
        {
            KlyteUtils.doLog("Loading District Manager Overrides");
            #region Release Line Hooks
            MethodInfo posChange = typeof(DistrictManagerOverrides).GetMethod("OnDistrictChanged", allFlags);

            AddRedirect(typeof(DistrictManager).GetMethod("SetDistrictName", allFlags), null, posChange);
            AddRedirect(typeof(DistrictManager).GetMethod("AreaModified", allFlags), null, posChange);
            #endregion
        }
Пример #13
0
 private static UIButton CreateTabTemplate()
 {
     KlyteUtils.createUIElement(out UIButton tabTemplate, null, "KCTabTemplate");
     KlyteUtils.initButton(tabTemplate, false, "GenericTab");
     tabTemplate.autoSize             = false;
     tabTemplate.width                = 40;
     tabTemplate.height               = 40;
     tabTemplate.foregroundSpriteMode = UIForegroundSpriteMode.Scale;
     return(tabTemplate);
 }
        public override void AwakeBody()
        {
            KlyteUtils.doLog("Loading Building Manager Overrides");
            #region Net Manager Hooks
            MethodInfo OnBuildingCreated  = GetType().GetMethod("OnBuildingCreated", allFlags);
            MethodInfo OnBuildingReleased = GetType().GetMethod("OnBuildingReleased", allFlags);

            AddRedirect(typeof(BuildingManager).GetMethod("CreateBuilding", allFlags), null, OnBuildingCreated);
            AddRedirect(typeof(BuildingManager).GetMethod("ReleaseBuilding", allFlags), null, OnBuildingReleased);
            #endregion
        }
Пример #15
0
        private void CreateTsdTabstrip(out UITabstrip strip, UIComponent parent, UiCategoryTab category)
        {
            TLMUtils.createUIElement(out strip, parent.transform, "TLMTabstrip", new Vector4(5, 0, parent.width - 10, 40));
            var effectiveOffsetY = strip.height;

            TLMUtils.createUIElement(out UITabContainer tabContainer, parent.transform, "TLMTabContainer", new Vector4(0, 40, parent.width, parent.height - 40));
            strip.tabPages = tabContainer;

            UIButton tabTemplate = CreateTabSubStripTemplate();

            UIComponent bodyContent = CreateContentTemplate(parent.width, parent.height - effectiveOffsetY - 10, category.isScrollable());

            foreach (var kv in TransportSystemDefinition.sysDefinitions)
            {
                Type[] components;
                Type   targetType;
                try
                {
                    targetType = KlyteUtils.GetImplementationForGenericType(category.getTabGenericContentImpl(), kv.Value);
                    components = new Type[] { targetType };
                }
                catch
                {
                    continue;
                }

                GameObject tab       = Instantiate(tabTemplate.gameObject);
                GameObject body      = Instantiate(bodyContent.gameObject);
                var        configIdx = kv.Key.toConfigIndex();
                String     name      = kv.Value.Name;
                TLMUtils.doLog($"configIdx = {configIdx};kv.Key = {kv.Key}; kv.Value= {kv.Value} ");
                String   bgIcon    = TLMConfigWarehouse.getBgIconForIndex(configIdx);
                String   fgIcon    = kv.Key.getTransportTypeIcon();
                UIButton tabButton = tab.GetComponent <UIButton>();
                tabButton.tooltip          = TLMConfigWarehouse.getNameForTransportType(configIdx);
                tabButton.hoveredBgSprite  = bgIcon;
                tabButton.focusedBgSprite  = bgIcon;
                tabButton.normalBgSprite   = bgIcon;
                tabButton.disabledBgSprite = bgIcon;
                tabButton.focusedColor     = Color.green;
                tabButton.hoveredColor     = new Color(0, 0.5f, 0f);
                tabButton.color            = Color.black;
                tabButton.disabledColor    = Color.gray;
                if (!string.IsNullOrEmpty(fgIcon))
                {
                    TLMUtils.createUIElement(out UIButton secSprite, tabButton.transform, "OverSprite", new Vector4(5, 5, 30, 30));
                    secSprite.normalFgSprite       = fgIcon;
                    secSprite.foregroundSpriteMode = UIForegroundSpriteMode.Scale;
                    secSprite.isInteractive        = false;
                    secSprite.disabledColor        = Color.black;
                }
                strip.AddTab(name, tab, body, components);
            }
        }
Пример #16
0
        public AssetBundle loadBundle(string filename)
        {
            try
            {
                return(AssetBundle.LoadFromMemory(loadResourceData(filename)));
            }
            catch (Exception e)
            {
                KlyteUtils.doErrorLog("The file could not be read:" + e.Message);
            }

            return(null);
        }
Пример #17
0
        private void CreateTitleBar()
        {
            KlyteUtils.createUIElement(out UILabel titlebar, MainPanel.transform, "SSPanel", new Vector4(75, 10, MainPanel.width - 150, 20));
            titlebar.autoSize      = false;
            titlebar.text          = $"{SuburbStyler.instance.SimpleName} v{SuburbStyler.version}";
            titlebar.textAlignment = UIHorizontalAlignment.Center;
            KlyteUtils.createDragHandle(titlebar, SSController.GetMainReference());

            KlyteUtils.createUIElement(out UISprite logo, MainPanel.transform, "SSLogo", new Vector4(22, 5f, 32, 32));
            logo.atlas      = SSCommonTextureAtlas.instance.atlas;
            logo.spriteName = "SSIcon";
            KlyteUtils.createDragHandle(logo, SSController.GetMainReference());
        }
Пример #18
0
        private void createLineCharts(Vector3 relativePos)
        {
            KlyteUtils.createUIElement(out agesChartPanel, parent);
            agesChartPanel.relativePosition = relativePos;
            agesChartPanel.width            = 140;
            agesChartPanel.height           = 70;
            agesChartPanel.name             = "WorkersPanel";
            agesChartPanel.autoLayout       = false;
            agesChartPanel.useCenter        = true;
            agesChartPanel.wrapLayout       = false;
            agesChartPanel.tooltipLocaleID  = "ZONEDBUILDING_WORKERCHART";

            KlyteUtils.createUIElement(out UIPanel pieLegendPanel, agesChartPanel.transform);
            pieLegendPanel.relativePosition = new Vector3(70f, 0f);
            pieLegendPanel.width            = 70;
            pieLegendPanel.height           = 70;
            pieLegendPanel.name             = "WorkersLegendPanel";
            pieLegendPanel.wrapLayout       = false;
            pieLegendPanel.autoLayout       = false;
            pieLegendPanel.useCenter        = true;

            KlyteUtils.createUIElement(out workplaceChart, agesChartPanel.transform);
            workplaceChart.spriteName       = "PieChartWhiteBg";
            workplaceChart.relativePosition = new Vector3(0, 0);
            workplaceChart.width            = 70;
            workplaceChart.height           = 70;
            workplaceChart.name             = "WorkersChart";

            Color32 unskill     = new Color32(210, 40, 40, 255);
            Color32 oneSchool   = new Color32(180, 180, 40, 255);
            Color32 twoSchool   = new Color32(40, 180, 40, 255);
            Color32 threeSchool = new Color32(40, 40, 210, 255);
            int     y           = 0;

            legendL0 = criaFatiaELegenda(unskill, workplaceChart, pieLegendPanel, "ZONEDBUILDING_UNEDUCATED", 14 * y++);
            legendL1 = criaFatiaELegenda(oneSchool, workplaceChart, pieLegendPanel, "ZONEDBUILDING_EDUCATED", 14 * y++);
            legendL2 = criaFatiaELegenda(twoSchool, workplaceChart, pieLegendPanel, "ZONEDBUILDING_WELLEDUCATED", 14 * y++);
            legendL3 = criaFatiaELegenda(threeSchool, workplaceChart, pieLegendPanel, "ZONEDBUILDING_HIGHLYEDUCATED", 14 * y++);

            KlyteUtils.createUIElement(out workersChart, workplaceChart.transform);
            workersChart.spriteName       = "PieChartWhiteFg";
            workersChart.relativePosition = new Vector3(0, 0);
            workersChart.width            = 70;
            workersChart.height           = 70;
            workersChart.name             = "WorkersChart";
            criaFatiaELegenda(MultiplyColor(unskill, 0.5f), workersChart);
            criaFatiaELegenda(MultiplyColor(oneSchool, 0.5f), workersChart);
            criaFatiaELegenda(MultiplyColor(twoSchool, 0.5f), workersChart);
            criaFatiaELegenda(MultiplyColor(threeSchool, 0.5f), workersChart);
            legendFr = criaFatiaELegenda(Color.gray, workersChart, pieLegendPanel, "ZONEDBUILDING_JOBSAVAIL", 14 * y++);
        }
Пример #19
0
        public static object ExecuteReflectionMethod(Type t, string methodName, params object[] args)
        {
            var method = t.GetMethod(methodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);

            try
            {
                return(method?.Invoke(null, args));
            }
            catch (Exception e)
            {
                KlyteUtils.doErrorLog("ERROR REFLECTING METHOD: {0} ({1}) => {2}\r\n{3}\r\n{4}", null, methodName, args, e.Message, e.StackTrace);
                return(null);
            }
        }
Пример #20
0
        private void Awake()
        {
            controlContainer      = GetComponent <UIPanel>();
            controlContainer.name = "KCPanel";

            KlyteUtils.createUIElement(out UIPanel _mainPanel, controlContainer.transform, "KCListPanel", new Vector4(395, 58, 875, 550));
            mainPanel = _mainPanel;

            KlyteUtils.createUIElement(out m_StripMain, mainPanel.transform, "KCTabstrip", new Vector4(10, -40, mainPanel.width - 20, 40));

            KlyteUtils.createUIElement(out UITabContainer tabContainer, mainPanel.transform, "KCTabContainer", new Vector4(0, 0, mainPanel.width, mainPanel.height));
            m_StripMain.tabPages      = tabContainer;
            m_StripMain.selectedIndex = 0;
            m_StripMain.selectedIndex = -1;
        }
Пример #21
0
        public Texture2D loadTexture(int x, int y, string filename)
        {
            try
            {
                Texture2D texture = new Texture2D(x, y);
                texture.LoadImage(loadResourceData(filename));
                return(texture);
            }
            catch (Exception e)
            {
                KlyteUtils.doErrorLog("The file could not be read:" + e.Message);
            }

            return(null);
        }
Пример #22
0
        public string loadResourceString(string name)
        {
            name = prefix + name;

            UnmanagedMemoryStream stream = (UnmanagedMemoryStream)Assembly.GetAssembly(resourceReference).GetManifestResourceStream(name);

            if (stream == null)
            {
                KlyteUtils.doErrorLog("Could not find resource: " + name);
                return(null);
            }

            StreamReader read = new StreamReader(stream);

            return(read.ReadToEnd());
        }
Пример #23
0
        public void Start()
        {
            KlyteModsPanel.instance.AddTab(ModTab.ServiceVehiclesManager, typeof(SVMServiceBuildingDetailPanel), taSVM, "ServiceVehiclesManagerIcon", "Service Vehicles Manager (v" + ServiceVehiclesManagerMod.version + ")");

            SVMUtils.createUIElement(out UIPanel buildingInfoParent, FindObjectOfType <UIView>().transform, "SVMBuildingInfoPanel", new Vector4(0, 0, 0, 1));

            buildingInfoParent.gameObject.AddComponent <SVMBuildingInfoPanel>();

            var         typeTarg  = typeof(Redirector <>);
            List <Type> instances = KlyteUtils.GetSubtypesRecursive(typeTarg, typeof(SVMController));

            foreach (Type t in instances)
            {
                gameObject.AddComponent(t);
            }
        }
Пример #24
0
        public override void AwakeBody()
        {
            KlyteUtils.doLog("Loading Net Manager Overrides");
            #region Net Manager Hooks
            MethodInfo OnNodeChanged        = GetType().GetMethod("OnNodeChanged", allFlags);
            MethodInfo OnSegmentCreated     = GetType().GetMethod("OnSegmentCreated", allFlags);
            MethodInfo OnSegmentReleased    = GetType().GetMethod("OnSegmentReleased", allFlags);
            MethodInfo OnSegmentNameChanged = GetType().GetMethod("OnSegmentNameChanged", allFlags);

            AddRedirect(typeof(NetManager).GetMethod("CreateNode", allFlags), null, OnNodeChanged);
            AddRedirect(typeof(NetManager).GetMethod("ReleaseNode", allFlags), null, OnNodeChanged);
            AddRedirect(typeof(NetManager).GetMethod("CreateSegment", allFlags), null, OnSegmentCreated);
            AddRedirect(typeof(NetManager).GetMethod("ReleaseSegment", allFlags), OnSegmentReleased);
            AddRedirect(typeof(NetManager).GetMethod("SetSegmentNameImpl", allFlags), null, OnSegmentNameChanged);
            #endregion
        }
Пример #25
0
        public byte[] loadResourceData(string name)
        {
            name = prefix + name;

            UnmanagedMemoryStream stream = (UnmanagedMemoryStream)Assembly.GetAssembly(resourceReference).GetManifestResourceStream(name);

            if (stream == null)
            {
                KlyteUtils.doErrorLog("Could not find resource: " + name);
                return(null);
            }

            BinaryReader read = new BinaryReader(stream);

            return(read.ReadBytes((int)stream.Length));
        }
Пример #26
0
        private Vector3 GetControlPoint(ushort segment)
        {
            Vector3 position       = nodeBuffer[(int)segmentBuffer[(int)segment].m_startNode].m_position;
            Vector3 startDirection = segmentBuffer[(int)segment].m_startDirection;
            Vector3 position2      = nodeBuffer[(int)segmentBuffer[(int)segment].m_endNode].m_position;
            Vector3 endDirection   = segmentBuffer[(int)segment].m_endDirection;

            if (!NetSegment.IsStraight(position, startDirection, position2, endDirection, out float num))
            {
                float num2 = startDirection.x * endDirection.x + startDirection.z * endDirection.z;
                if (num2 >= -0.999f && Line2.Intersect(VectorUtils.XZ(position), VectorUtils.XZ(position + startDirection), VectorUtils.XZ(position2), VectorUtils.XZ(position2 + endDirection), out float d, out float num3))
                {
                    return(position + startDirection * d);
                }
                KlyteUtils.doErrorLog("Warning! Invalid segment directions!");
            }
            return((position + position2) / 2f);
        }
Пример #27
0
        public void OnLevelUnloading()
        {
            var typeTarg  = typeof(Redirector <>);
            var instances = ReflectionUtils.GetSubtypesRecursive(typeTarg, typeof(U));

            doLog($"{SimpleName} Redirectors: {instances.Count()}");
            foreach (Type t in instances)
            {
                GameObject.Destroy((Redirector)KlyteUtils.GetPrivateStaticField("instance", t));
            }
            GameObject.Destroy(topObj);
            typeTarg  = typeof(Singleton <>);
            instances = ReflectionUtils.GetSubtypesRecursive(typeTarg, typeof(U));

            foreach (Type t in instances)
            {
                GameObject.Destroy(((MonoBehaviour)KlyteUtils.GetPrivateStaticProperty("instance", t)));
            }
        }
Пример #28
0
        private void Awake()
        {
            m_instance                       = this;
            m_controlContainer               = GetComponent <UIComponent>();
            m_controlContainer.name          = "SSPanel";
            m_controlContainer.isInteractive = false;

            var lateralListWidth = 180;


            KlyteUtils.createUIElement(out UIPanel _mainPanel, GetComponent <UIPanel>().transform, "SSListPanel", new Vector4(0, 0, m_controlContainer.width, m_controlContainer.height));
            MainPanel = _mainPanel;
            MainPanel.backgroundSprite = "MenuPanel2";



            CreateTitleBar();
            KlyteUtils.CreateScrollPanel(_mainPanel, out m_profileList, out UIScrollbar scrollbar, lateralListWidth, m_controlContainer.height - 110, new Vector3(10, 100));

            KlyteUtils.createUIElement(out m_tabstripCategories, MainPanel.transform, "SSTabstrip", new Vector4(lateralListWidth + 30, 50, MainPanel.width - 340, 40));

            KlyteUtils.createUIElement(out UITabContainer tabContainer, MainPanel.transform, "SSTabContainer", new Vector4(lateralListWidth + 30, 90, MainPanel.width - 350, MainPanel.height - 90));
            m_tabstripCategories.tabPages = tabContainer;

            UIButton tabTrees = CreateTabTemplate();

            KlyteUtils.createUIElement(out UIPanel containerTrees, null);
            containerTrees.area             = new Vector4(0, 0, tabContainer.width, tabContainer.height);
            containerTrees.backgroundSprite = "MainPanelInfo";
            containerTrees.color            = Color.gray;

            List <Type> tabs = KlyteUtils.GetSubtypesRecursive(typeof(SSDecorationTab <,>), GetType());

            foreach (var tab in tabs)
            {
                m_tabstripCategories.AddTab(tab.Name, tabTrees.gameObject, containerTrees.gameObject);
                var tabController = (SSDecorationTab)containerTrees.gameObject.AddComponent(tab);
                tabTrees.normalFgSprite     = tabController.TabIcon;
                tabTrees.tooltipLocaleID    = tabController.TabDescriptionLocale;
                tabTrees.isTooltipLocalized = true;
            }
            m_tabstripCategories.selectedIndex = -1;
        }
        private void Awake()
        {
            CreateMainPanel();

            CreateScrollPanel();

            SetPreviewWindow();

            BindParentChanges();

            CreateRemoveUndesiredModelsButton();

            PopulateCheckboxes();

            var ssd = Singleton <T> .instance.GetSSD();

            var  extension        = ssd.GetTransportExtension();
            bool allowColorChange = SVMConfigWarehouse.allowColorChanging(extension.ConfigIndexKey);

            if (allowColorChange)
            {
                SVMUtils.createUIElement(out UILabel lbl, m_mainPanel.transform, "DistrictColorLabel", new Vector4(5, m_mainPanel.height - 30, 120, 40));
                SVMUtils.LimitWidth(lbl, 120);
                lbl.autoSize = true;
                lbl.localeID = "SVM_COLOR_LABEL";

                m_color = KlyteUtils.CreateColorField(m_mainPanel);
                m_color.eventSelectedColorChanged += onChangeColor;

                SVMUtils.createUIElement(out UIButton resetColor, m_mainPanel.transform, "DistrictColorReset", new Vector4(m_mainPanel.width - 110, m_mainPanel.height - 35, 0, 0));
                SVMUtils.initButton(resetColor, false, "ButtonMenu");
                SVMUtils.LimitWidth(resetColor, 100);
                resetColor.textPadding = new RectOffset(5, 5, 5, 2);
                resetColor.autoSize    = true;
                resetColor.localeID    = "SVM_RESET_COLOR";
                resetColor.eventClick += onResetColor;
            }
            else
            {
                m_mainPanel.height -= 40;
            }
        }
Пример #30
0
        protected void SaveConfig(Dictionary <T, string> target, K idx, bool global = false)
        {
            I loadedConfig;

            if (global && !AllowGlobal)
            {
                throw new Exception("CONFIGURAÇÂO NÃO GLOBAL TENTOU SER SALVA COMO GLOBAL: " + typeof(U));
            }
            if (global)
            {
                loadedConfig = Singleton <I> .instance.getConfig2();
            }
            else
            {
                loadedConfig = Singleton <I> .instance.currentLoadedCityConfig;
            }
            var value = RecursiveEncode(target, 1);

            KlyteUtils.doLog("saveConfig ({0}) NEW VALUE: {1}", idx, value);
            loadedConfig.setString(idx, value);
        }