Exemple #1
0
 public void Minimize(Atom m)
 {
     if (dock != null)
     {
         dock.Add(m);
         Remove(m);
     }
 }
Exemple #2
0
        private void SetActive(Area area)
        {
            bool add = active.Children.Contains(area.Link) == false;

            active.Children.Clear();
            if (add)
            {
                active.Add(area.Link);
            }
            layer.Update();
        }
Exemple #3
0
        private Area Menu()
        {
            Material       material       = new Material("menu", renderer.Programs["Textured"], MeshMode.PolygonFill);
            FontStyle      fontStyle      = new FontStyle("res/fonts/large.fnt");
            Vector2        padding        = new Vector2(6.0f, 6.0f);
            Vector2        innerPadding   = new Vector2(2.0f, 2.0f);
            NinePatchStyle ninePatchStyle = new NinePatchStyle("ninepatch8.png");

            menuStyle = new Style(
                padding,
                innerPadding,
                fontStyle,
                ninePatchStyle,
                material
                );

            Dock dock = new Dock(Orientation.Vertical);

            dock.OffsetFreeSizeRelative = new Vector2(0.5f, 0.5f);
            dock.OffsetSelfSizeRelative = new Vector2(-0.5f, -0.5f);
            var b1 = new Button(renderer, "New Game", menuStyle);
            var b2 = new Button(renderer, "Load", menuStyle);
            var b3 = new Button(renderer, "Options", menuStyle);
            var b4 = new Button(renderer, "Quit", menuStyle);

            b1.OffsetFreeSizeRelative = new Vector2(0.5f, 0.0f);
            b2.OffsetFreeSizeRelative = new Vector2(0.5f, 0.0f);
            b3.OffsetFreeSizeRelative = new Vector2(0.5f, 0.0f);
            b4.OffsetFreeSizeRelative = new Vector2(0.5f, 0.0f);
            b1.OffsetSelfSizeRelative = new Vector2(-0.5f, 0.0f);
            b2.OffsetSelfSizeRelative = new Vector2(-0.5f, 0.0f);
            b3.OffsetSelfSizeRelative = new Vector2(-0.5f, 0.0f);
            b4.OffsetSelfSizeRelative = new Vector2(-0.5f, 0.0f);
            dock.Add(b1);
            dock.Add(b2);
            dock.Add(b3);
            dock.Add(b4);
            return(dock);
        }
Exemple #4
0
        public void SetDock(Dock d)
        {
            if (d == null)
            {
                return;
            }

            if (dock != null)
            {
                d.Add(dock.DockedItems);
            }

            dock = d;
        }
Exemple #5
0
        private Area Camera()
        {
            Button expand = new Button(renderer, "Camera");

            expand.Name   = "expand";
            expand.Action = TogglePopup;

            MenuList list  = new MenuList(renderer, Orientation.Vertical);
            Popup    popup = new Popup(expand, list);

            list.Name             = "list";
            list.ChildLayoutStyle = Area.AreaLayoutStyle.ExtendHorizontal;
            popup.Name            = "popup";

            Button collapse = new Button(renderer, "Camera");

            collapse.Action = TogglePopup;
            collapse.Link   = popup;
            collapse.Name   = "collapse";
            list.Add(collapse);

            Camera           camera = sceneManager.Camera;
            StereoParameters stereo = camera.StereoParameters;

            list.ChildLayoutStyle   = Area.AreaLayoutStyle.ExtendHorizontal;
            stereo.ViewportCenter.Z = 4.0f;
            list.Add(new Slider(renderer, "Fov X", camera.FovXParameter, 0, 0.0f, (float)(System.Math.PI), 0.0f, 180.0f));
            list.Add(new Slider(renderer, "Fov Y", camera.FovYParameter, 0, 0.0f, (float)(System.Math.PI), 0.0f, 180.0f));

#if false
            {
                list.Add(new Slider(renderer, "Eye Separation", stereo.EyeSeparation, 0, -1.0f, 1.0f, -1.0f, 1.0f));
                list.Add(new Slider(renderer, "Perspective", stereo.Perspective, 0, 0.0f, 1.0f, 0.0f, 1.0f));
                list.Add(new Slider(renderer, "Center X", stereo.ViewportCenter, 0, -4.0f, 4.0f, -4.0f, 4.0f));
                list.Add(new Slider(renderer, "Center Y", stereo.ViewportCenter, 1, -4.0f, 4.0f, -4.0f, 4.0f));
                list.Add(new Slider(renderer, "Center Z", stereo.ViewportCenter, 2, 0.0f, 20.0f,   0.0f, 20.0f));
                list.Add(new Slider(renderer, "Eye X", stereo.EyePosition, 0, -4.0f, 4.0f, -4.0f, 4.0f));
                list.Add(new Slider(renderer, "Eye Y", stereo.EyePosition, 1, -4.0f, 4.0f, -4.0f, 4.0f));
                list.Add(new Slider(renderer, "Eye Z", stereo.EyePosition, 2, -20.0f, 20.0f, -20.0f, 20.0f));
                //list.Add(new Slider(renderer, "Near",           camera.NearParameter,   0,    0.0f,  10.0f,    0.0f,  10.0f));
                //list.Add(new Slider(renderer, "Far",            camera.FarParameter,    0,    0.0f, 100.0f,    0.0f, 100.0f));
            }

            {
                Choice choice = new Choice(Orientation.Horizontal);
                choice.Name  = "Focus choice";
                choice.Style = Style.NullPadding;
                choice.Add(new ChoiceItem(renderer, "AutoFocus"));
                choice.Add(new ChoiceItem(renderer, "Manual"));
                choice.Action   = FocusChoiceAction;
                choice.Selected = choice.Items.First();
                list.Add(choice);
            }
#endif

            {
                Choice choice = new Choice(Orientation.Horizontal);
                choice.Name  = "FOV choice";
                choice.Style = Style.NullPadding;
                choice.Add(new ChoiceItem(renderer, "Vertical"));
                choice.Add(new ChoiceItem(renderer, "Horizontal"));

#if false
                {
                    choice.Add(new ChoiceItem(renderer, "V. Stereo"));
                    choice.Add(new ChoiceItem(renderer, "H. Stereo"));
                }
#endif
                choice.Action   = ProjectionChoiceAction;
                choice.Selected = choice.Items.First();
                list.Add(choice);
            }

#if false
            {
                Choice choice = new Choice(Orientation.Horizontal);
                choice.Name  = "StereoMode choice";
                choice.Style = Style.NullPadding;
                foreach (var kvp in stereoModes)
                {
                    choice.Add(new ChoiceItem(renderer, kvp.Key));
                }
                choice.Action   = StereoModeChoiceAction;
                choice.Selected = choice.Items.First();
                list.Add(choice);
            }

            {
                list.Add(new Slider(renderer, "Saturation", (renderer.GlobalParameters["saturation"]    as Floats), 0, 0.0f, 1.0f, 0.0f, 1.0f));
                list.Add(new Slider(renderer, "Contrast", (renderer.GlobalParameters["contrast"]      as Floats), 0, 0.0f, 1.0f, 0.0f, 1.0f));
                list.Add(new Slider(renderer, "Deghost", (renderer.GlobalParameters["deghost"]       as Floats), 0, 0.0f, 1.0f, 0.0f, 1.0f));
            }
#endif

            {
                Dock dock = new Dock(Orientation.Horizontal);
                dock.Name  = "Reset Home dock";
                dock.Style = Style.NullPadding;

                Button reset = new Button(renderer, "Reset");
                reset.Action = ResetCamera;
                dock.Add(reset);

                list.Add(dock);
            }

            expand.Link = popup;
            popup.Set(false);

            return(popup);
        }
Exemple #6
0
        public override bool Tick(Actor self)
        {
            if (!shouldCancel && (DockActor == null || DockActor.IsDead || !DockActor.IsInWorld || Dock.GetDockAction(DockableActor) == null))
            {
                shouldCancel = true;
            }

            if (ChildActivity != null)
            {
                if (shouldCancel)
                {
                    ChildActivity.Cancel(self);
                }

                if (ChildActivity != null)
                {
                    ChildActivity.Tick(self);
                }
            }

            switch (DockingState)
            {
            case DockingState.Approaching:
                if (shouldCancel)
                {
                    DockingState = DockingState.Undocked;
                    break;
                }

                // TODO does not null when target reached...?
                if (ChildActivity != null)
                {
                    break;
                }

                var distance = (DockableActor.CenterPosition - DockActor.CenterPosition).Length;

                if (distance > WDist.FromCells(Dock.Info.QueueDistance).Length)
                {
                    QueueChild(new Move(DockableActor, Target.FromActor(DockActor), WDist.FromCells(Dock.Info.QueueDistance)));
                }
                else
                {
                    DockingState = DockingState.Waiting;
                    Dock.Add(DockableActor);
                }

                break;

            case DockingState.Waiting:
                if (shouldCancel)
                {
                    DockingState = DockingState.Undocked;
                    Dock.Remove(DockableActor);
                }

                break;

            case DockingState.Docking:
                if (ChildActivity == null)
                {
                    if (shouldCancel)
                    {
                        DockingState = DockingState.Undocked;
                        Dock.Remove(DockableActor);
                    }
                    else
                    {
                        DockingState = DockingState.Docked;
                        Dock.OnDock();
                    }
                }

                break;

            case DockingState.Docked:
                if (shouldCancel)
                {
                    StartUndocking();
                }

                break;

            case DockingState.Undocking:
                if (ChildActivity == null)
                {
                    DockingState = DockingState.Undocked;
                    Dock.Remove(DockableActor);

                    if (!DockActor.IsDead && DockActor.IsInWorld)
                    {
                        var rallyPoint = DockActor.TraitOrDefault <RallyPoint>();
                        if (rallyPoint != null && rallyPoint.Path.Any())
                        {
                            DockableActor.QueueActivity(new Move(DockableActor, rallyPoint.Path.First()));
                        }
                    }
                }

                break;

            case DockingState.Undocked:
                break;
            }

            return(DockingState == DockingState.Undocked && ChildActivity == null);
        }
Exemple #7
0
        private Area Camera()
        {
            var list = new MenuList(renderer, Orientation.Vertical);

            list.Name             = "list";
            list.ChildLayoutStyle = Area.AreaLayoutStyle.ExtendHorizontal;

            Camera           camera = sceneManager.Camera;
            StereoParameters stereo = camera.Projection.StereoParameters;

            list.ChildLayoutStyle   = Area.AreaLayoutStyle.ExtendHorizontal;
            stereo.ViewportCenter.Z = 4.0f;
            list.Add(new Slider(renderer, "Fov X", camera.Projection.FovXParameter, 0, 0.0f, (float)(System.Math.PI), 0.0f, 180.0f));
            list.Add(new Slider(renderer, "Fov Y", camera.Projection.FovYParameter, 0, 0.0f, (float)(System.Math.PI), 0.0f, 180.0f));
            if (Configuration.stereo)
            {
                list.Add(new Slider(renderer, "Eye Separation", stereo.EyeSeparation, 0, -1.0f, 1.0f, -1.0f, 1.0f));
                list.Add(new Slider(renderer, "Perspective", stereo.Perspective, 0, 0.0f, 1.0f, 0.0f, 1.0f));
                list.Add(new Slider(renderer, "Center X", stereo.ViewportCenter, 0, -4.0f, 4.0f, -4.0f, 4.0f));
                list.Add(new Slider(renderer, "Center Y", stereo.ViewportCenter, 1, -4.0f, 4.0f, -4.0f, 4.0f));
                list.Add(new Slider(renderer, "Center Z", stereo.ViewportCenter, 2, 0.0f, 20.0f,   0.0f, 20.0f));
                list.Add(new Slider(renderer, "Eye X", stereo.EyePosition, 0, -4.0f, 4.0f, -4.0f, 4.0f));
                list.Add(new Slider(renderer, "Eye Y", stereo.EyePosition, 1, -4.0f, 4.0f, -4.0f, 4.0f));
                list.Add(new Slider(renderer, "Eye Z", stereo.EyePosition, 2, -20.0f, 20.0f, -20.0f, 20.0f));
                //list.Add(new Slider(renderer, "Near",           camera.NearParameter,   0,    0.0f,  10.0f,    0.0f,  10.0f));
                //list.Add(new Slider(renderer, "Far",            camera.FarParameter,    0,    0.0f, 100.0f,    0.0f, 100.0f));
            }

            if (Configuration.stereo)
            {
                Choice choice = new Choice(Orientation.Horizontal);
                choice.Name  = "Focus choice";
                choice.Style = Style.NullPadding;
                choice.Add(new ChoiceItem(renderer, "AutoFocus"));
                choice.Add(new ChoiceItem(renderer, "Manual"));
                choice.Action   = FocusChoiceAction;
                choice.Selected = choice.Items.First();
                list.Add(choice);
            }

            {
                Choice choice = new Choice(Orientation.Horizontal);
                choice.Name  = "FOV choice";
                choice.Style = Style.NullPadding;
                var dict = new Dictionary <string, ProjectionType>();
                dict["Vertical"]   = ProjectionType.PerspectiveVertical;
                dict["Horizontal"] = ProjectionType.PerspectiveHorizontal;
                dict["V. Stereo"]  = ProjectionType.StereoscopicVertical;
                dict["H. Stereo"]  = ProjectionType.StereoscopicHorizontal;
                foreach (var kvp in dict)
                {
                    var choiceItem = choice.Add(new ChoiceItem(renderer, kvp.Key));
                    if (kvp.Value == sceneManager.Camera.Projection.ProjectionType)
                    {
                        choice.Selected = choiceItem;
                    }
                }
                choice.Action = ProjectionChoiceAction;
                list.Add(choice);
            }

            {
                Choice choice = new Choice(Orientation.Horizontal);
                choice.Name  = "StereoMode choice";
                choice.Style = Style.NullPadding;
                foreach (var kvp in stereoModes)
                {
                    ChoiceItem choiceItem = choice.Add(new ChoiceItem(renderer, kvp.Key));
                    if (kvp.Value == CurrentStereoMode)
                    {
                        choice.Selected = choiceItem;
                    }
                }
                choice.Action = StereoModeChoiceAction;
                list.Add(choice);
            }

#if false
            // \todo stereo material
            if (Configuration.stereo)
            {
                list.Add(new Slider(renderer, "Saturation", renderer.Global.Floats("saturation"), 0, 0.0f, 1.0f, 0.0f, 1.0f));
                list.Add(new Slider(renderer, "Contrast", renderer.Global.Floats("contrast"), 0, 0.0f, 1.0f, 0.0f, 1.0f));
                list.Add(new Slider(renderer, "Deghost", renderer.Global.Floats("deghost"), 0, 0.0f, 1.0f, 0.0f, 1.0f));
            }
#endif

            {
                Dock dock = new Dock(Orientation.Horizontal);
                dock.Name  = "Reset Home dock";
                dock.Style = Style.NullPadding;

                Button reset = new Button(renderer, "Reset");
                reset.Action = ResetCamera;
                dock.Add(reset);

                /*Button reference = new Button(renderer, "Reference");
                 * reference.Action = ReferenceStereo;
                 * dock.Add(reference);*/

                Button home = new Button(renderer, "Home");
                home.Action = HomeCamera;
                dock.Add(home);

                list.Add(dock);
            }

            var expand = new Button(renderer, "Camera", SetActive);
            expand.Link = list;
            return(expand);
        }
Exemple #8
0
        public void Reset()
        {
            CurrentPalette = "cupola";

            wheel = window.Mouse.WheelPrecise;

            layer      = new Layer(this, window);
            layer.Name = "Root layer";

            if (Configuration.graphicalUserInterface == false)
            {
                return;
            }

            Dock verticalGroup = new Dock(Orientation.Vertical);

            active = new Dock(Orientation.Horizontal);
            #region bottom
            MenuList bottom = new MenuList(renderer, Orientation.Horizontal);
            bottom.Name = "test";

            bottom.Add(Operations());
            bottom.Add(Palette());
            bottom.Add(Scene());
            bottom.Add(Camera());
            bottom.Add(Lights());
            bottom.Add(Materials());
            bottom.Add(Noise());
            bottom.Add(Physics());

            //if(Configuration.physics)
            {
                Choice choice = new Choice(Orientation.Horizontal);
                choice.Name  = "Action choice";
                choice.Style = Style.NullPadding;
                if (Configuration.physics)
                {
                    choice.Add(new ChoiceItem(renderer, "Drag"));
                    choice.Add(new ChoiceItem(renderer, "Select"));
                }
                else
                {
                    if (Configuration.physics)
                    {
                        choice.Add(new ChoiceItem(renderer, "Drag"));
                    }
                    choice.Add(new ChoiceItem(renderer, "Select"));
                }
                choice.Add(new ChoiceItem(renderer, "Add"));
                choice.Action   = ActionChoiceAction;
                choice.Selected = choice.Items.First();
                bottom.Add(choice);
            }

            {
                Choice choice = new Choice(Orientation.Horizontal);
                choice.Name  = "AddWithPhysics choice";
                choice.Style = Style.NullPadding;
                choice.Add(new ChoiceItem(renderer, "Add Static"));
                choice.Add(new ChoiceItem(renderer, "Add Dynamic"));
                choice.Action   = AddModeChoiceAction;
                choice.Selected = choice.Items.First();
                bottom.Add(choice);
            }


            bottom.OffsetFreeSizeRelative = new Vector2(0.5f, 0.0f);
            bottom.OffsetSelfSizeRelative = new Vector2(-0.5f, 0.0f);
            //bottom.OffsetPixels           = new Vector2( 4.0f, 4.0f);
            #endregion bottom
            verticalGroup.Add(bottom);
            verticalGroup.OffsetFreeSizeRelative = new Vector2(0.5f, 0.0f);
            verticalGroup.OffsetSelfSizeRelative = new Vector2(-0.5f, 0.0f);
            verticalGroup.OffsetPixels           = new Vector2(4.0f, 4.0f);
            verticalGroup.Add(active);

            Layer.Add(verticalGroup);

            if (CurrentScene != "Game")
            {
                ConnectUserControls();
            }
        }
Exemple #9
0
        public override bool Tick(Actor self)
        {
            if ((DockActor.IsDead || !DockActor.IsInWorld || Dock.IsTraitDisabled) && !IsCanceling)
            {
                Cancel(self, true);
            }

            switch (DockingState)
            {
            case DockingState.Approaching:
                if (State == ActivityState.Canceling)
                {
                    return(true);
                }

                if (ChildActivity != null)
                {
                    break;
                }

                var distance = WDist.FromCells(Dock.Info.QueueDistance);

                if ((dockableActor.CenterPosition - DockActor.CenterPosition).Length > distance.Length)
                {
                    QueueChild(new Move(dockableActor, Target.FromActor(DockActor), distance));
                }
                else
                {
                    DockingState = DockingState.Waiting;
                    Dock.Add(dockableActor);
                }

                break;

            case DockingState.Waiting:
                if (State == ActivityState.Canceling)
                {
                    Dock.Remove(dockableActor);
                    return(true);
                }

                break;

            case DockingState.PrepareDocking:
                if (State == ActivityState.Canceling)
                {
                    Dock.Remove(dockableActor);
                    return(true);
                }

                if (ChildActivity != null)
                {
                    break;
                }

                var target = DockActor.World.Map.CellContaining(DockActor.CenterPosition + Dock.Info.Position + Dock.Info.DragOffset);

                if (dockableActor.Location != target)
                {
                    QueueChild(new Move(dockableActor, target));
                }
                else
                {
                    DockingState = DockingState.Docking;

                    QueueChild(new Turn(dockableActor, Dock.Info.Angle));
                    initialPosition = dockableActor.CenterPosition;
                    QueueChild(new Drag(dockableActor, dockableActor.CenterPosition, DockActor.CenterPosition + Dock.Info.Position, Dock.Info.DragLength));
                }

                break;

            case DockingState.Docking:
                if (State == ActivityState.Canceling)
                {
                    StartUndocking();
                    return(false);
                }

                if (ChildActivity == null)
                {
                    DockingState = DockingState.Docked;
                    Dock.OnDock();
                }

                break;

            case DockingState.Docked:
                if (State == ActivityState.Canceling)
                {
                    StartUndocking();
                    return(false);
                }

                break;

            case DockingState.Undocking:
                if (ChildActivity == null)
                {
                    DockingState = DockingState.None;
                    Dock.Remove(dockableActor);

                    if (!DockActor.IsDead && DockActor.IsInWorld)
                    {
                        var rallyPoint = DockActor.TraitOrDefault <RallyPoint>();
                        if (rallyPoint != null && rallyPoint.Path.Any())
                        {
                            foreach (var cell in rallyPoint.Path)
                            {
                                dockableActor.QueueActivity(new Move(dockableActor, cell));
                            }
                        }
                    }
                }

                break;

            case DockingState.None:
                return(true);
            }

            return(false);
        }