Ejemplo n.º 1
0
        private void Spawn()
        {
            Transform parent;

            switch (Type)
            {
            case SpawnType.Canvas:
                parent = UI.CanvasContainer.GetInstance.MainTransform;
                break;

            case SpawnType.Canvas3D:
                parent = _entity.MainTransform;
                break;

            default:
                throw new ArgumentOutOfRangeException(Type.ToString());
            }

            var prefab = Resources.Load <BaseUIElement>(PrefabPath);

            if (prefab == null)
            {
                throw new NullReferenceException($"Invalid prefab path: {PrefabPath}");
            }

            _instanceUI = GameObject.Instantiate(prefab, parent);
            InitInstance();
        }
        internal override BaseUIElement convertFromLuaData(BaseUIElement bue)
        {
            UINumericInput uini;

            if (bue == null)
            {
                uini = new UINumericInput();
            }
            else
            {
                try
                {
                    uini = bue as UINumericInput;
                }
                catch (Exception)
                {
                    uini = new UINumericInput();
                }
            }

            try
            {
                Reload();
            }
            catch (Exception)
            {
            }

            uini.defaultInput = defaultInput;
            uini.AssignNum(defaultInput);

            return(base.convertFromLuaData(uini));
        }
Ejemplo n.º 3
0
        internal override BaseUIElement convertFromLuaData(BaseUIElement bue)
        {
            UIGrid uib;

            if (bue == null)
            {
                uib = new UIGrid();
            }
            else
            {
                try
                {
                    uib = bue as UIGrid;
                }
                catch (Exception)
                {
                    uib = new UIGrid();
                }
            }

            UIGridTabItem layout = tabLayout.convertFromLuaData();

            if (layout != null)
            {
                HandleGridItems(layout, uib);
            }
            else
            {
                throw new Exception("UIGridTabItem layout is null--");
            }


            return(base.convertFromLuaData(uib));
        }
        internal override BaseUIElement Clone(BaseUIElement bue, BaseUIElement parent, UICollection parentCollection)
        {
            UIGridTabItem temp = (UIGridTabItem)this.MemberwiseClone();

            temp.TabItemContents = TabItemContents.Clone();

            return(base.Clone(temp, parent, parentCollection));
        }
Ejemplo n.º 5
0
    protected IEnumerator HandleRestartGane()
    {
        BaseUIElement blackout = UIManager.Instance.m_blackout;

        blackout.Show();
        yield return(new WaitForSeconds(blackout.m_transitionInDelay + blackout.m_transitionInTime + 1.0f));

        SceneManager.LoadScene(0);
    }
Ejemplo n.º 6
0
        internal static void RemoveElement(BaseUIElement element)
        {
            var elem         = Elements.Find(x => x.Equals(element.Element));
            var removedLinks = Links.Where(x => x.Element1.Equals(elem) || x.Element2.Equals(elem)).ToList();

            removedLinks.ForEach(RemoveLink);

            Elements.Remove(elem);
        }
Ejemplo n.º 7
0
        internal override BaseUIElement Clone(BaseUIElement bue, BaseUIElement parent, UICollection parentCollection)
        {
            UIGrid temp = (UIGrid)this.MemberwiseClone();

            temp.ldc                = ldc.Clone();
            temp.gridItems          = new List <UIGridTabItem>(temp.gridItems);
            temp.gridCompleteRender = new RenderTarget2D(gridCompleteRender.GraphicsDevice, gridCompleteRender.Width, gridCompleteRender.Height);

            return(base.Clone(temp, parent, parentCollection));
        }
 internal virtual BaseUIElement convertFromLuaData(BaseUIElement bue)
 {
     bue.name = name;
     bue.holdEventActivateTimer = holdEventActivateTimer;
     bue.holdEventTick          = holdEventTick;
     bue.position        = position.MGConvert();
     bue.initialPosition = position.MGConvert();
     bue.size            = size.MGConvert();
     bue.initialSize     = size.MGConvert();
     GetActivateType();
     bue.activateType = ActivateType;
     return(bue);
 }
        internal override BaseUIElement convertFromLuaData(BaseUIElement bue)
        {
            GButton uib;

            if (bue == null)
            {
                uib = new GButton();
            }
            else
            {
                try
                {
                    uib = bue as GButton;
                }
                catch (Exception)
                {
                    uib = new GButton();
                }
            }

            try
            {
                Reload();
            }
            catch (Exception)
            {
            }

            uib.AssignBaseButtonAnimations(_ButtonAnim_RestState, _ButtonAnim_HoverState, _ButtonAnim_ClickState);

            try
            {
                exFunction.Process(LuaUICollection.luaStateConversion);
            }
            catch (Exception)
            {
                exFunction = new LuaFRef();
            }
            uib.executeFunction = exFunction;

            return(base.convertFromLuaData(uib));
        }
Ejemplo n.º 10
0
        internal void RemoveUIElement(BaseUIElement element)
        {
            var removedEdges = new List <GraphEdge>();

            foreach (var child in GetMainPanel().Children)
            {
                if (child is GraphEdge)
                {
                    var c = child as GraphEdge;
                    if (c.SourceElement.Equals(element) || c.DestinationElement.Equals(element))
                    {
                        removedEdges.Add(c);
                    }
                }
            }

            removedEdges.ForEach(RemoveLink);

            GetMainPanel().Children.Remove(element);
        }
Ejemplo n.º 11
0
        private void ShowElementControls(BaseUIElement element)
        {
            if (CurrentChosenElement != null)
            {
                CurrentChosenElement.Material.Children.Remove(SelectMaterial);
            }

            CurrentChosenElement = element;

            switch (currentSelectMode)
            {
            case ClickMode.HideMode:
                CurrentChosenElement.IsShown = false;
                break;

            case ClickMode.SelectMode:
                CurrentChosenElement.Material.Children.Add(SelectMaterial);
                break;
            }
        }
        internal override BaseUIElement convertFromLuaData(BaseUIElement bue)
        {
            UIScreen uis;

            if (bue == null)
            {
                uis = new UIScreen();
            }
            else
            {
                try
                {
                    uis = bue as UIScreen;
                }
                catch (Exception)
                {
                    uis = new UIScreen();
                }
            }

            return(base.convertFromLuaData(uis));
        }
Ejemplo n.º 13
0
        private void MoveElement(BaseUIElement elem, Point point)
        {
            elem.SetLocation(point.X, point.Y);

            ElementsController.ChangeLocation(elem, point);

            GetMainPanel().Dispatcher.Invoke(delegate() { return; }, DispatcherPriority.Render);

            foreach (var child in GetMainPanel().Children)
            {
                if (child is GraphEdge)
                {
                    var c = child as GraphEdge;
                    if (c.SourceElement == elem)
                    {
                        var sourceOffset = c.SourceCB.TransformToAncestor(c.SourceCB.Parent as Canvas).Transform(new Point(0, 0));

                        var sourcePoint = c.SourceCB.TransformToAncestor(GetMainPanel()).Transform(new Point(0, 0));

                        sourcePoint.X += sourceOffset.X;
                        sourcePoint.Y += sourceOffset.Y;

                        c.Source = sourcePoint;
                    }
                    else if (c.DestinationElement == elem)
                    {
                        var sourceOffset = c.DestinationCB.TransformToAncestor(c.DestinationCB.Parent as Canvas).Transform(new Point(0, 0));

                        var sourcePoint = c.DestinationCB.TransformToAncestor(GetMainPanel()).Transform(new Point(0, 0));

                        sourcePoint.X += sourceOffset.X;
                        sourcePoint.Y += sourceOffset.Y;

                        c.Destination = sourcePoint;
                    }
                }
            }
        }
Ejemplo n.º 14
0
        internal override BaseUIElement convertFromLuaData(BaseUIElement bue)
        {
            UITextElement utl;

            if (bue == null)
            {
                utl = new UITextElement();
            }
            else
            {
                try
                {
                    utl = bue as UITextElement;
                }
                catch (Exception)
                {
                    utl = new UITextElement();
                }
            }

            Reload();

            return(utl);
        }
Ejemplo n.º 15
0
        private void OpenMenuClick(object sender, RoutedEventArgs e)
        {
            NewMenuClick(null, null);

            var text = File.ReadAllText(Directory.GetCurrentDirectory() + "save.txt");

            var str = XElement.Parse(text);

            try
            {
                str.Elements().ToList().ForEach(x =>
                {
                    if (x.Name.ToString().Contains("Computer"))
                    {
                        var point = x.Attribute("Point");
                        var val   = point.Value.Split(new char[] { ';' });
                        var id    = x.Attribute("Id").Value;
                        ElementsController.SetLastId(int.Parse(id));
                        var computer = new Computer(new Point(double.Parse(val[0]), double.Parse(val[1])), int.Parse(id))
                        {
                            Name = x.Attribute("Name").Value
                        };

                        ElementsController.AddElement(computer);
                        GetMainPanel().Children.Add(new ComputerElement(MENU_ELEMENT_WIDTH, MENU_ELEMENT_HEIGHT, ImageController.Open("computer.svg"), SchemeElementMouseDown, computer.Point.X, computer.Point.Y, 1, computer, computer.Name));
                    }
                    else if (x.Name.ToString().Contains("Router"))
                    {
                        var point = x.Attribute("Point");
                        var val   = point.Value.Split(new char[] { ';' });
                        var id    = x.Attribute("Id").Value;
                        ElementsController.SetLastId(int.Parse(id));
                        var router = new Router(new Point(double.Parse(val[0]), double.Parse(val[1])), int.Parse(id))
                        {
                            Name = x.Attribute("Name").Value
                        };

                        ElementsController.AddElement(router);
                        GetMainPanel().Children.Add(new RouterElement(MENU_ELEMENT_WIDTH, MENU_ELEMENT_HEIGHT, ImageController.Open("router.svg"), SchemeElementMouseDown, router.Point.X, router.Point.Y, 8, router, router.Name));
                    }
                    else
                    {
                        var length = int.Parse(x.Attribute("Length").Value);

                        var id1 = int.Parse(x.Attribute("Element1").Value);
                        var id2 = int.Parse(x.Attribute("Element2").Value);

                        var fp = int.Parse(x.Attribute("FirstPosition").Value);
                        var sp = int.Parse(x.Attribute("SecondPosition").Value);

                        var s = ElementsController.Elements.First(y => y.Id == id1);
                        var d = ElementsController.Elements.First(y => y.Id == id2);

                        ElementsController.AddLink(s, d, fp, sp, length);

                        BaseUIElement firstBaseElement  = null;
                        BaseUIElement secondBaseElement = null;

                        for (var i = 0; i < GetMainPanel().Children.Count; i++)
                        {
                            if (GetMainPanel().Children[i] is BaseUIElement)
                            {
                                var el = GetMainPanel().Children[i] as BaseUIElement;
                                if (el.Element.Equals(s))
                                {
                                    firstBaseElement = el;
                                }
                                else if (el.Element.Equals(d))
                                {
                                    secondBaseElement = el;
                                }
                            }
                        }

                        var firstPin  = firstBaseElement.GetPinByNumber(fp);
                        var secondPin = secondBaseElement.GetPinByNumber(sp);

                        var source      = firstPin.GetCheckBox();
                        var destination = secondPin.GetCheckBox();

                        var sourceOffset      = destination.TransformToAncestor(destination.Parent as Canvas).Transform(new Point(0, 0));
                        var destinationOffset = source.TransformToAncestor(source.Parent as Canvas).Transform(new Point(0, 0));

                        var sourcePoint = destination.TransformToAncestor(GetMainPanel()).Transform(new Point(0, 0));
                        sourcePoint.X  += sourceOffset.X;
                        sourcePoint.Y  += sourceOffset.Y;

                        var destinationPoint = source.TransformToAncestor(GetMainPanel()).Transform(new Point(0, 0));
                        destinationPoint.X  += destinationOffset.X;
                        destinationPoint.Y  += destinationOffset.Y;

                        DrawLine(destinationPoint, sourcePoint, firstPin.ParentElement, secondPin.ParentElement, source, destination);
                    }

                    GetMainPanel().Dispatcher.Invoke(delegate() { return; }, DispatcherPriority.Render);
                });
            }
            catch
            {
                MessageBox.Show("Ошибка загрузки файла");
            }
        }
Ejemplo n.º 16
0
 internal static void RemoveElement(BaseUIElement element)
 {
     mainWindow.RemoveUIElement(element);
 }
Ejemplo n.º 17
0
 internal static void ChangeLocation(BaseUIElement elem, Point point)
 {
     Elements.First(x => x.Equals(elem.Element)).Point = point;
 }