示例#1
0
    static void Main()
    {
        Application.Init (false);
        var d = new Container (0, 0, Application.Cols, Application.Lines);

        d.Add (new Label (10, 10, "Text"));
        d.Add (new Entry (16, 10, 20, "Edit me"));
        Application.Run (d);
    }
示例#2
0
        public override void Reset()
        {
            base.Reset();

            Clock.ProcessFrame();

            Container approachContainer = new Container { Depth = float.MinValue, };

            Add(approachContainer);

            const int count = 10;

            for (int i = 0; i < count; i++)
            {
                var h = new HitCircle
                {
                    StartTime = Clock.CurrentTime + 1000 + i * 80,
                    Position = new Vector2((i - count / 2) * 14),
                };

                DrawableHitCircle d = new DrawableHitCircle(h)
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre,
                    Depth = i,
                    State = ArmedState.Hit,
                    Judgement = new OsuJudgementInfo { Result = HitResult.Hit }
                };

                approachContainer.Add(d.ApproachCircle.CreateProxy());
                Add(d);
            }
        }
示例#3
0
	public static void AddWidget(Container box, Widget widget, int position, bool expandAndFill = false)
	{
		box.Add(widget);
		((Box.BoxChild)box[widget]).Position = position;
		((Box.BoxChild)box[widget]).Expand = expandAndFill;
		((Box.BoxChild)box[widget]).Fill = expandAndFill;
	}
示例#4
0
        void AddSnackBarContainer(Container?mainWindow, Widget snackBarLayout)
        {
            var children = mainWindow?.Children ?? Enumerable.Empty <Widget>();

            foreach (var child in children)
            {
                mainWindow?.Remove(child);
            }

            foreach (var child in children)
            {
                mainWindow?.Add(child);
            }

            mainWindow?.Add(snackBarLayout);
            snackBarLayout.ShowAll();
        }
示例#5
0
        public HUD(SoulGame game, ContentManager content, GraphicsDevice graphicsDevice)
        {
            Container = new Container(game, content, graphicsDevice);
            btn1 = new Button();
            btn1.X = 100;
            btn1.Y = 100;
            btn1.Text = "oi";
            btn1.Width = 100;
            btn1.Height = 50;
            btn1.Font = content.Load<SpriteFont>("World");
            btn1.Click += btn1_Click;
            Container.Add(btn1);

            txt1 = new TextBox();
            txt1.X = 300;
            txt1.Y = 300;
            txt1.Width = 200;
            txt1.Height = 30;
            txt1.Font = content.Load<SpriteFont>("World");
            Container.Add(txt1);
            txt1.EnterPressed += txt1_EnterPressed;
        }
示例#6
0
        public static void Bind(Entity entity, Main main, ListContainer commandQueueContainer)
        {
            PCInput                             input                                 = entity.Get <PCInput>();
            Editor                              editor                                = entity.Get <Editor>();
            EditorGeeUI                         gui                                   = entity.Get <EditorGeeUI>();
            Property <bool>                     analyticsEnable                       = new Property <bool>();
            ListProperty <SessionEntry>         analyticsSessions                     = new ListProperty <SessionEntry>();
            ListProperty <SessionEntry>         analyticsActiveSessions               = new ListProperty <SessionEntry>();
            ListProperty <EventEntry>           analyticsEvents                       = new ListProperty <EventEntry>();
            ListProperty <EventEntry>           analyticsActiveEvents                 = new ListProperty <EventEntry>();
            ListProperty <PropertyEntry>        analyticsProperties                   = new ListProperty <PropertyEntry>();
            ListProperty <PropertyEntry>        analyticsActiveProperties             = new ListProperty <PropertyEntry>();
            Dictionary <Session, ModelInstance> sessionPositionModels                 = new Dictionary <Session, ModelInstance>();
            Dictionary <Session.EventList, List <ModelInstance> > eventPositionModels = new Dictionary <Session.EventList, List <ModelInstance> >();
            Property <bool>  analyticsPlaying = new Property <bool>();
            Property <float> playbackSpeed    = new Property <float> {
                Value = 1.0f
            };
            Property <float> playbackLocation = new Property <float>();

            const float timelineHeight = 32.0f;

            Scroller timelineScroller = new Scroller();

            timelineScroller.ScrollAmount.Value            = 60.0f;
            timelineScroller.EnableScissor.Value           = false;
            timelineScroller.DefaultScrollHorizontal.Value = true;
            timelineScroller.AnchorPoint.Value             = new Vector2(0, 1);
            timelineScroller.ResizeVertical.Value          = true;
            timelineScroller.Add(new Binding <Vector2, Point>(timelineScroller.Position, x => new Vector2(0, x.Y), main.ScreenSize));
            timelineScroller.Add(new Binding <Vector2, Point>(timelineScroller.Size, x => new Vector2(x.X, timelineHeight), main.ScreenSize));
            timelineScroller.Add(new Binding <bool>(timelineScroller.Visible, () => analyticsEnable && Editor.EditorModelsVisible, analyticsEnable, Editor.EditorModelsVisible));
            timelineScroller.Add(new Binding <bool>(timelineScroller.EnableScroll, x => !x, input.GetKey(Keys.LeftAlt)));
            entity.Add(new CommandBinding(entity.Delete, timelineScroller.Delete));
            main.UI.Root.Children.Add(timelineScroller);

            timelineScroller.Add(new Binding <bool>(editor.EnableCameraDistanceScroll, () => !timelineScroller.Highlighted || editor.VoxelEditMode, timelineScroller.Highlighted, editor.VoxelEditMode));
            timelineScroller.Add(new CommandBinding(timelineScroller.Delete, delegate()
            {
                editor.EnableCameraDistanceScroll.Value = true;
            }));

            ListContainer timelines = new ListContainer();

            timelines.Alignment.Value   = ListContainer.ListAlignment.Min;
            timelines.Orientation.Value = ListContainer.ListOrientation.Vertical;
            timelines.Reversed.Value    = true;
            timelineScroller.Children.Add(timelines);

            input.Add(new CommandBinding <int>(input.MouseScrolled, () => input.GetKey(Keys.LeftAlt) && timelineScroller.Highlighted && !editor.VoxelEditMode, delegate(int delta)
            {
                float newScale           = Math.Max(timelines.Scale.Value.X + delta * 6.0f, timelineScroller.Size.Value.X / timelines.Size.Value.X);
                Matrix absoluteTransform = timelines.GetAbsoluteTransform();
                float x = input.Mouse.Value.X + ((absoluteTransform.Translation.X - input.Mouse.Value.X) * (newScale / timelines.Scale.Value.X));
                timelines.Position.Value = new Vector2(x, 0.0f);
                timelines.Scale.Value    = new Vector2(newScale, 1.0f);
            }));

            Container timeline = new Container();

            timeline.Size.Value             = new Vector2(0, timelineHeight);
            timeline.Tint.Value             = Microsoft.Xna.Framework.Color.Black;
            timeline.ResizeHorizontal.Value = false;
            timeline.ResizeVertical.Value   = false;
            timelines.Children.Add(timeline);

            EditorFactory.AddCommand
            (
                entity, main, commandQueueContainer, "Load analytics data", new PCInput.Chord(),
                new Command
            {
                Action = delegate()
                {
                    if (main.MapFile.Value != null)
                    {
                        List <Session> sessions = main.LoadAnalytics(main.MapFile);
                        if (sessions.Count > 0)
                        {
                            analyticsEnable.Value = true;
                            Dictionary <string, bool> distinctEventNames    = new Dictionary <string, bool>();
                            Dictionary <string, bool> distinctPropertyNames = new Dictionary <string, bool>();
                            foreach (Session s in sessions)
                            {
                                foreach (Session.EventList el in s.Events)
                                {
                                    distinctEventNames[el.Name] = true;
                                    s.TotalTime = Math.Max(s.TotalTime, el.Events[el.Events.Count - 1].Time);
                                }
                                foreach (Session.ContinuousProperty p in s.ContinuousProperties)
                                {
                                    if (p.Independent)
                                    {
                                        distinctPropertyNames[p.Name] = true;
                                    }
                                }
                                analyticsSessions.Add(new SessionEntry {
                                    Session = s
                                });
                            }
                            analyticsEvents.AddAll(distinctEventNames.Keys.Select(x => new EventEntry {
                                Name = x
                            }));
                            analyticsProperties.AddAll(distinctPropertyNames.Keys.Select(x => new PropertyEntry {
                                Name = x
                            }));
                            timeline.Size.Value   = new Vector2(analyticsSessions.Max(x => x.Session.TotalTime), timelineScroller.Size.Value.Y);
                            timelines.Scale.Value = new Vector2(timelineScroller.Size.Value.X / timeline.Size.Value.X, 1.0f);
                        }
                    }
                }
            },
                gui.MapCommands,
                () => !analyticsEnable && !string.IsNullOrEmpty(main.MapFile) && !gui.PickNextEntity,
                analyticsEnable, main.MapFile, gui.PickNextEntity
            );

            ListContainer sessionsSidebar = new ListContainer();

            sessionsSidebar.AnchorPoint.Value = new Vector2(1, 1);
            sessionsSidebar.Add(new Binding <Vector2>(sessionsSidebar.Position, () => new Vector2(main.ScreenSize.Value.X - 10, main.ScreenSize.Value.Y - timelineScroller.ScaledSize.Value.Y - 10), main.ScreenSize, timelineScroller.ScaledSize));
            sessionsSidebar.Add(new Binding <bool>(sessionsSidebar.Visible, () => analyticsEnable && Editor.EditorModelsVisible, analyticsEnable, Editor.EditorModelsVisible));
            sessionsSidebar.Alignment.Value = ListContainer.ListAlignment.Max;
            sessionsSidebar.Reversed.Value  = true;
            main.UI.Root.Children.Add(sessionsSidebar);
            entity.Add(new CommandBinding(entity.Delete, sessionsSidebar.Delete));

            Func <string, ListContainer> createCheckboxListItem = delegate(string text)
            {
                ListContainer layout = new ListContainer();
                layout.Orientation.Value = ListContainer.ListOrientation.Horizontal;

                TextElement label = new TextElement();
                label.FontFile.Value = main.Font;
                label.Text.Value     = text;
                label.Name.Value     = "Label";
                layout.Children.Add(label);

                Container checkboxContainer = new Container();
                checkboxContainer.PaddingBottom.Value = checkboxContainer.PaddingLeft.Value = checkboxContainer.PaddingRight.Value = checkboxContainer.PaddingTop.Value = 1.0f;
                layout.Children.Add(checkboxContainer);

                Container checkbox = new Container();
                checkbox.Name.Value             = "Checkbox";
                checkbox.ResizeHorizontal.Value = checkbox.ResizeVertical.Value = false;
                checkbox.Size.Value             = new Vector2(16.0f, 16.0f);
                checkboxContainer.Children.Add(checkbox);
                return(layout);
            };

            Container sessionsContainer = new Container();

            sessionsContainer.Tint.Value        = Microsoft.Xna.Framework.Color.Black;
            sessionsContainer.Opacity.Value     = UIFactory.Opacity;
            sessionsContainer.AnchorPoint.Value = new Vector2(1, 1);
            sessionsSidebar.Children.Add(sessionsContainer);

            Scroller sessionsScroller = new Scroller();

            sessionsScroller.ResizeHorizontal.Value = true;
            sessionsScroller.ResizeVertical.Value   = true;
            sessionsScroller.MaxVerticalSize.Value  = 256;
            sessionsContainer.Children.Add(sessionsScroller);

            ListContainer sessionList = new ListContainer();

            sessionList.Orientation.Value = ListContainer.ListOrientation.Vertical;
            sessionList.Alignment.Value   = ListContainer.ListAlignment.Max;
            sessionsScroller.Children.Add(sessionList);

            Property <bool> allSessions = new Property <bool>();

            sessionList.Add(new ListBinding <UIComponent, SessionEntry>(sessionList.Children, analyticsSessions, delegate(SessionEntry entry)
            {
                ListContainer item = createCheckboxListItem(string.Format("{0} {1:d} ({2})", entry.Session.UUID.Substring(0, 8), entry.Session.Date, new TimeSpan(0, 0, (int)entry.Session.TotalTime)));

                Container checkbox = (Container)item.GetChildByName("Checkbox");
                checkbox.Add(new Binding <Microsoft.Xna.Framework.Color, bool>(checkbox.Tint, x => x ? Microsoft.Xna.Framework.Color.White : Microsoft.Xna.Framework.Color.Black, entry.Active));

                item.Add(new CommandBinding(item.MouseLeftDown, delegate()
                {
                    if (entry.Active)
                    {
                        allSessions.Value = false;
                        analyticsActiveSessions.Remove(entry);
                    }
                    else
                    {
                        analyticsActiveSessions.Add(entry);
                    }
                }));

                return(item);
            }));

            ListContainer allSessionsButton = createCheckboxListItem("[All]");

            allSessionsButton.Add(new CommandBinding(allSessionsButton.MouseLeftDown, delegate()
            {
                if (allSessions)
                {
                    allSessions.Value = false;
                    foreach (SessionEntry s in analyticsActiveSessions.ToList())
                    {
                        analyticsActiveSessions.Remove(s);
                    }
                }
                else
                {
                    allSessions.Value = true;
                    foreach (SessionEntry s in analyticsSessions)
                    {
                        if (!s.Active)
                        {
                            analyticsActiveSessions.Add(s);
                        }
                    }
                }
            }));

            Container allSessionsCheckbox = (Container)allSessionsButton.GetChildByName("Checkbox");

            allSessionsCheckbox.Add(new Binding <Microsoft.Xna.Framework.Color, bool>(allSessionsCheckbox.Tint, x => x ? Microsoft.Xna.Framework.Color.White : Microsoft.Xna.Framework.Color.Black, allSessions));
            sessionList.Children.Add(allSessionsButton);

            Container eventsContainer = new Container();

            eventsContainer.Tint.Value        = Microsoft.Xna.Framework.Color.Black;
            eventsContainer.Opacity.Value     = UIFactory.Opacity;
            eventsContainer.AnchorPoint.Value = new Vector2(1, 1);
            sessionsSidebar.Children.Add(eventsContainer);

            Scroller eventsScroller = new Scroller();

            eventsScroller.ResizeHorizontal.Value = true;
            eventsScroller.ResizeVertical.Value   = true;
            eventsScroller.MaxVerticalSize.Value  = 256;
            eventsContainer.Children.Add(eventsScroller);

            ListContainer eventList = new ListContainer();

            eventList.Orientation.Value = ListContainer.ListOrientation.Vertical;
            eventList.Alignment.Value   = ListContainer.ListAlignment.Max;
            eventsScroller.Children.Add(eventList);

            Property <bool> allEvents = new Property <bool>();

            eventList.Add(new ListBinding <UIComponent, EventEntry>(eventList.Children, analyticsEvents, delegate(EventEntry e)
            {
                ListContainer item = createCheckboxListItem(e.Name);

                Container checkbox = (Container)item.GetChildByName("Checkbox");
                checkbox.Add(new Binding <Microsoft.Xna.Framework.Color, bool>(checkbox.Tint, x => x ? Microsoft.Xna.Framework.Color.White : Microsoft.Xna.Framework.Color.Black, e.Active));

                TextElement label = (TextElement)item.GetChildByName("Label");
                label.Tint.Value  = new Microsoft.Xna.Framework.Color(colorHash(e.Name));

                item.Add(new CommandBinding(item.MouseLeftDown, delegate()
                {
                    if (e.Active)
                    {
                        allEvents.Value = false;
                        analyticsActiveEvents.Remove(e);
                    }
                    else
                    {
                        analyticsActiveEvents.Add(e);
                    }
                }));

                return(item);
            }));

            ListContainer allEventsButton = createCheckboxListItem("[All]");

            allEventsButton.Add(new CommandBinding(allEventsButton.MouseLeftDown, delegate()
            {
                if (allEvents)
                {
                    allEvents.Value = false;
                    foreach (EventEntry e in analyticsActiveEvents.ToList())
                    {
                        analyticsActiveEvents.Remove(e);
                    }
                }
                else
                {
                    allEvents.Value = true;
                    foreach (EventEntry e in analyticsEvents)
                    {
                        if (!e.Active)
                        {
                            analyticsActiveEvents.Add(e);
                        }
                    }
                }
            }));
            Container allEventsCheckbox = (Container)allEventsButton.GetChildByName("Checkbox");

            allEventsCheckbox.Add(new Binding <Microsoft.Xna.Framework.Color, bool>(allEventsCheckbox.Tint, x => x ? Microsoft.Xna.Framework.Color.White : Microsoft.Xna.Framework.Color.Black, allEvents));
            eventList.Children.Add(allEventsButton);

            Container propertiesContainer = new Container();

            propertiesContainer.Tint.Value        = Microsoft.Xna.Framework.Color.Black;
            propertiesContainer.Opacity.Value     = UIFactory.Opacity;
            propertiesContainer.AnchorPoint.Value = new Vector2(1, 1);
            sessionsSidebar.Children.Add(propertiesContainer);

            Scroller propertiesScroller = new Scroller();

            propertiesScroller.ResizeHorizontal.Value = true;
            propertiesScroller.ResizeVertical.Value   = true;
            propertiesScroller.MaxVerticalSize.Value  = 256;
            propertiesContainer.Children.Add(propertiesScroller);

            ListContainer propertiesList = new ListContainer();

            propertiesList.Orientation.Value = ListContainer.ListOrientation.Vertical;
            propertiesList.Alignment.Value   = ListContainer.ListAlignment.Max;
            propertiesScroller.Children.Add(propertiesList);

            Property <bool> allProperties = new Property <bool>();

            propertiesList.Add(new ListBinding <UIComponent, PropertyEntry>(propertiesList.Children, analyticsProperties, delegate(PropertyEntry e)
            {
                ListContainer item = createCheckboxListItem(e.Name);

                Container checkbox = (Container)item.GetChildByName("Checkbox");
                checkbox.Add(new Binding <Microsoft.Xna.Framework.Color, bool>(checkbox.Tint, x => x ? Microsoft.Xna.Framework.Color.White : Microsoft.Xna.Framework.Color.Black, e.Active));

                TextElement label = (TextElement)item.GetChildByName("Label");
                label.Tint.Value  = new Microsoft.Xna.Framework.Color(colorHash(e.Name));

                item.Add(new CommandBinding(item.MouseLeftDown, delegate()
                {
                    if (e.Active)
                    {
                        allProperties.Value = false;
                        analyticsActiveProperties.Remove(e);
                    }
                    else
                    {
                        analyticsActiveProperties.Add(e);
                    }
                }));

                return(item);
            }));

            ListContainer allPropertiesButton = createCheckboxListItem("[All]");

            allPropertiesButton.Add(new CommandBinding(allPropertiesButton.MouseLeftDown, delegate()
            {
                if (allProperties)
                {
                    allProperties.Value = false;
                    foreach (PropertyEntry e in analyticsActiveProperties.ToList())
                    {
                        analyticsActiveProperties.Remove(e);
                    }
                }
                else
                {
                    allProperties.Value = true;
                    foreach (PropertyEntry e in analyticsProperties)
                    {
                        if (!e.Active)
                        {
                            analyticsActiveProperties.Add(e);
                        }
                    }
                }
            }));
            Container allPropertiesCheckbox = (Container)allPropertiesButton.GetChildByName("Checkbox");

            allPropertiesCheckbox.Add(new Binding <Microsoft.Xna.Framework.Color, bool>(allPropertiesCheckbox.Tint, x => x ? Microsoft.Xna.Framework.Color.White : Microsoft.Xna.Framework.Color.Black, allProperties));
            propertiesList.Children.Add(allPropertiesButton);

            Func <Session.EventList, LineDrawer2D> createEventLines = delegate(Session.EventList el)
            {
                LineDrawer2D line = new LineDrawer2D();
                line.Color.Value    = colorHash(el.Name);
                line.UserData.Value = el;

                foreach (Session.Event e in el.Events)
                {
                    line.Lines.Add(new LineDrawer2D.Line
                    {
                        A = new Microsoft.Xna.Framework.Graphics.VertexPositionColor(new Vector3(e.Time, 0.0f, 0.0f), Microsoft.Xna.Framework.Color.White),
                        B = new Microsoft.Xna.Framework.Graphics.VertexPositionColor(new Vector3(e.Time, timeline.Size.Value.Y, 0.0f), Microsoft.Xna.Framework.Color.White),
                    });
                }
                return(line);
            };

            analyticsActiveEvents.ItemAdded += delegate(int index, EventEntry ee)
            {
                ee.Active.Value = true;
                foreach (SessionEntry s in analyticsActiveSessions)
                {
                    Session.PositionProperty positionProperty = s.Session.PositionProperties[0];
                    foreach (Session.EventList el in s.Session.Events)
                    {
                        if (el.Name == ee.Name)
                        {
                            List <ModelInstance> models = new List <ModelInstance>();
                            Vector4 color = colorHash(el.Name);
                            int     hash  = (int)(new Color(color).PackedValue);
                            foreach (Session.Event e in el.Events)
                            {
                                ModelInstance i = new ModelInstance();
                                i.Serialize = false;
                                i.Setup("InstancedModels\\position-model", hash);
                                if (i.IsFirstInstance)
                                {
                                    i.Model.Color.Value = new Vector3(color.X, color.Y, color.Z);
                                }
                                i.Transform.Value = Matrix.CreateTranslation(positionProperty.GetLastRecordedPosition(e.Time));
                                models.Add(i);
                                entity.Add(i);
                            }
                            eventPositionModels[el] = models;
                        }
                    }

                    timeline.Children.AddAll(s.Session.Events.Where(x => x.Name == ee.Name).Select(createEventLines));
                }
            };

            analyticsActiveEvents.ItemRemoved += delegate(int index, EventEntry e)
            {
                e.Active.Value = false;
                foreach (KeyValuePair <Session.EventList, List <ModelInstance> > pair in eventPositionModels.ToList())
                {
                    if (pair.Key.Name == e.Name)
                    {
                        foreach (ModelInstance instance in pair.Value)
                        {
                            instance.Delete.Execute();
                        }
                        eventPositionModels.Remove(pair.Key);
                    }
                }
                timeline.Children.RemoveAll(timeline.Children.Where(x => x.UserData.Value != null && ((Session.EventList)x.UserData.Value).Name == e.Name).ToList());
            };

            analyticsActiveProperties.ItemAdded += delegate(int index, PropertyEntry e)
            {
                e.Active.Value = true;
            };

            analyticsActiveProperties.ItemRemoved += delegate(int index, PropertyEntry e)
            {
                e.Active.Value = false;
            };

            ListContainer propertyTimelines = new ListContainer();

            propertyTimelines.Alignment.Value   = ListContainer.ListAlignment.Min;
            propertyTimelines.Orientation.Value = ListContainer.ListOrientation.Vertical;
            timelines.Children.Add(propertyTimelines);

            Action <Container> refreshPropertyGraph = delegate(Container container)
            {
                TextElement  label        = (TextElement)container.GetChildByName("Label");
                LineDrawer2D lines        = (LineDrawer2D)container.GetChildByName("Graph");
                string       propertyName = ((PropertyEntry)lines.UserData.Value).Name;
                lines.Lines.Clear();
                float time = 0.0f, lastTime = 0.0f;
                float lastValue = 0.0f;
                bool  firstLine = true;
                float max = float.MinValue, min = float.MaxValue;
                while (true)
                {
                    bool stop = true;

                    // Calculate average
                    int   count = 0;
                    float sum   = 0.0f;
                    foreach (SessionEntry s in analyticsActiveSessions)
                    {
                        if (time < s.Session.TotalTime)
                        {
                            Session.ContinuousProperty prop = s.Session.GetContinuousProperty(propertyName);
                            if (prop != null)
                            {
                                stop = false;
                                sum += prop[time];
                                count++;
                            }
                        }
                    }

                    if (stop)
                    {
                        break;
                    }
                    else
                    {
                        float value = sum / (float)count;
                        if (firstLine)
                        {
                            firstLine = false;
                        }
                        else
                        {
                            lines.Lines.Add(new LineDrawer2D.Line
                            {
                                A = new Microsoft.Xna.Framework.Graphics.VertexPositionColor
                                {
                                    Color    = Microsoft.Xna.Framework.Color.White,
                                    Position = new Vector3(lastTime, lastValue, 0.0f),
                                },
                                B = new Microsoft.Xna.Framework.Graphics.VertexPositionColor
                                {
                                    Color    = Microsoft.Xna.Framework.Color.White,
                                    Position = new Vector3(time, value, 0.0f),
                                },
                            });
                        }
                        min       = Math.Min(min, value);
                        max       = Math.Max(max, value);
                        lastValue = value;
                        lastTime  = time;
                        time     += Session.Recorder.Interval;
                    }

                    if (min < max)
                    {
                        float scale = -timelineHeight / (max - min);
                        lines.Scale.Value    = new Vector2(1, scale);
                        lines.Position.Value = new Vector2(0, max * -scale);
                    }
                    else
                    {
                        lines.AnchorPoint.Value = Vector2.Zero;
                        if (min <= 0.0f)
                        {
                            lines.Position.Value = new Vector2(0, timelineHeight);
                        }
                        else
                        {
                            lines.Position.Value = new Vector2(0, timelineHeight * 0.5f);
                        }
                    }
                    label.Text.Value = max.ToString("F");
                }
            };

            Action refreshPropertyGraphs = delegate()
            {
                foreach (Container propertyTimeline in propertyTimelines.Children)
                {
                    refreshPropertyGraph(propertyTimeline);
                }
            };

            propertyTimelines.Add(new ListBinding <UIComponent, PropertyEntry>(propertyTimelines.Children, analyticsActiveProperties, delegate(PropertyEntry e)
            {
                Container propertyTimeline = new Container();
                propertyTimeline.Add(new Binding <Vector2>(propertyTimeline.Size, timeline.Size));
                propertyTimeline.Tint.Value             = Microsoft.Xna.Framework.Color.Black;
                propertyTimeline.Opacity.Value          = UIFactory.Opacity;
                propertyTimeline.ResizeHorizontal.Value = false;
                propertyTimeline.ResizeVertical.Value   = false;

                LineDrawer2D line   = new LineDrawer2D();
                line.Name.Value     = "Graph";
                line.Color.Value    = colorHash(e.Name);
                line.UserData.Value = e;
                propertyTimeline.Children.Add(line);

                TextElement label    = new TextElement();
                label.FontFile.Value = main.Font;
                label.Name.Value     = "Label";
                label.Add(new Binding <Vector2>(label.Scale, x => new Vector2(1.0f / x.X, 1.0f / x.Y), timelines.Scale));
                label.AnchorPoint.Value = new Vector2(0, 0);
                label.Position.Value    = new Vector2(0, 0);
                propertyTimeline.Children.Add(label);

                refreshPropertyGraph(propertyTimeline);

                return(propertyTimeline);
            }));

            analyticsActiveSessions.ItemAdded += delegate(int index, SessionEntry s)
            {
                Session.PositionProperty positionProperty = s.Session.PositionProperties[0];
                foreach (Session.EventList el in s.Session.Events)
                {
                    if (analyticsActiveEvents.FirstOrDefault(x => x.Name == el.Name) != null)
                    {
                        List <ModelInstance> models = new List <ModelInstance>();
                        Vector4 color = colorHash(el.Name);
                        int     hash  = (int)(new Color(color).PackedValue);
                        foreach (Session.Event e in el.Events)
                        {
                            ModelInstance i = new ModelInstance();
                            i.Serialize = false;
                            i.Setup("InstancedModels\\position-model", hash);
                            if (i.IsFirstInstance)
                            {
                                i.Model.Color.Value = new Vector3(color.X, color.Y, color.Z);
                            }
                            i.Transform.Value = Matrix.CreateTranslation(positionProperty.GetLastRecordedPosition(e.Time));
                            entity.Add(i);
                            models.Add(i);
                        }
                        eventPositionModels[el] = models;
                    }
                }

                ModelInstance instance = new ModelInstance();
                instance.Setup("InstancedModels\\position-model", 0);
                instance.Serialize = false;
                entity.Add(instance);
                sessionPositionModels.Add(s.Session, instance);
                s.Active.Value = true;
                timeline.Children.AddAll(s.Session.Events.Where(x => analyticsActiveEvents.FirstOrDefault(y => y.Name == x.Name) != null).Select(createEventLines));
                playbackLocation.Reset();

                refreshPropertyGraphs();
            };

            analyticsActiveSessions.ItemRemoved += delegate(int index, SessionEntry s)
            {
                ModelInstance instance = sessionPositionModels[s.Session];
                instance.Delete.Execute();

                foreach (KeyValuePair <Session.EventList, List <ModelInstance> > pair in eventPositionModels.ToList())
                {
                    if (pair.Key.Session == s.Session)
                    {
                        foreach (ModelInstance i in pair.Value)
                        {
                            i.Delete.Execute();
                        }
                        eventPositionModels.Remove(pair.Key);
                    }
                }

                sessionPositionModels.Remove(s.Session);
                s.Active.Value = false;
                timeline.Children.RemoveAll(timeline.Children.Where(x => x.UserData.Value != null && ((Session.EventList)x.UserData.Value).Session == s.Session).ToList());

                refreshPropertyGraphs();
            };

            entity.Add(new SetBinding <float>(playbackLocation, delegate(float value)
            {
                if (analyticsActiveSessions.Length == 0)
                {
                    return;
                }

                if (value < 0.0f)
                {
                    playbackLocation.Value = 0.0f;
                }
                float end = analyticsActiveSessions.Max(x => x.Session.TotalTime);
                if (value > end)
                {
                    playbackLocation.Value = end;
                    analyticsPlaying.Value = false;
                }

                foreach (KeyValuePair <Session, ModelInstance> pair in sessionPositionModels)
                {
                    pair.Value.Transform.Value = Matrix.CreateTranslation(pair.Key.PositionProperties[0][playbackLocation]);
                }
            }));

            LineDrawer2D playbackLine = new LineDrawer2D();

            playbackLine.Color.Value = Vector4.One;
            playbackLine.Lines.Add(new LineDrawer2D.Line
            {
                A = new Microsoft.Xna.Framework.Graphics.VertexPositionColor
                {
                    Color    = Microsoft.Xna.Framework.Color.White,
                    Position = new Vector3(0.0f, -10.0f, 0.0f),
                },
                B = new Microsoft.Xna.Framework.Graphics.VertexPositionColor
                {
                    Color    = Microsoft.Xna.Framework.Color.White,
                    Position = new Vector3(0.0f, timeline.Size.Value.Y, 0.0f),
                },
            });
            playbackLine.Add(new Binding <Vector2, float>(playbackLine.Position, x => new Vector2(x, 0.0f), playbackLocation));
            timeline.Children.Add(playbackLine);

            entity.Add(new NotifyBinding(delegate()
            {
                allEventsButton.Detach();
                allSessionsButton.Detach();
                allPropertiesButton.Detach();
                analyticsSessions.Clear();
                analyticsEvents.Clear();
                analyticsProperties.Clear();
                eventList.Children.Add(allEventsButton);
                sessionList.Children.Add(allSessionsButton);
                propertiesList.Children.Add(allPropertiesButton);

                foreach (ModelInstance instance in sessionPositionModels.Values)
                {
                    instance.Delete.Execute();
                }
                sessionPositionModels.Clear();

                foreach (ModelInstance instance in eventPositionModels.Values.SelectMany(x => x))
                {
                    instance.Delete.Execute();
                }
                eventPositionModels.Clear();

                allEvents.Value       = false;
                allSessions.Value     = false;
                allProperties.Value   = false;
                analyticsEnable.Value = false;

                analyticsActiveEvents.Clear();
                analyticsActiveSessions.Clear();
                analyticsActiveProperties.Clear();

                propertyTimelines.Children.Clear();

                playbackLine.Detach();
                timeline.Children.Clear();
                timeline.Children.Add(playbackLine);

                analyticsPlaying.Value = false;
                playbackLocation.Value = 0.0f;
            }, main.MapFile));

            EditorFactory.AddCommand
            (
                entity, main, commandQueueContainer, "Toggle analytics playback", new PCInput.Chord {
                Modifier = Keys.LeftAlt, Key = Keys.A
            }, new Command
            {
                Action = delegate()
                {
                    analyticsPlaying.Value = !analyticsPlaying;
                }
            },
                gui.MapCommands,
                () => analyticsEnable && !editor.MovementEnabled && analyticsActiveSessions.Length > 0,
                analyticsEnable, editor.MovementEnabled, analyticsActiveSessions.Length
            );

            EditorFactory.AddCommand
            (
                entity, main, commandQueueContainer, "Stop analytics playback", new PCInput.Chord {
                Key = Keys.Escape
            }, new Command
            {
                Action = delegate()
                {
                    analyticsPlaying.Value = false;
                }
            }, gui.MapCommands, () => analyticsPlaying, analyticsPlaying
            );

            Container playbackContainer = new Container();

            playbackContainer.Tint.Value    = Microsoft.Xna.Framework.Color.Black;
            playbackContainer.Opacity.Value = UIFactory.Opacity;
            sessionsSidebar.Children.Add(playbackContainer);
            playbackContainer.Add(new CommandBinding <int>(playbackContainer.MouseScrolled, delegate(int delta)
            {
                playbackSpeed.Value = Math.Max(1.0f, Math.Min(10.0f, playbackSpeed.Value + delta));
            }));

            TextElement playbackLabel = new TextElement();

            playbackLabel.FontFile.Value = main.Font;
            playbackLabel.Add(new Binding <string>(playbackLabel.Text, delegate()
            {
                return(string.Format("{0} {1} {2:F}x", TimeTrialUI.SecondsToTimeString(playbackLocation), (analyticsPlaying ? "Playing" : "Stopped"), playbackSpeed));
            }, playbackLocation, playbackSpeed, analyticsPlaying));
            playbackContainer.Children.Add(playbackLabel);

            Container descriptionContainer = null;

            Updater timelineUpdate = new Updater
                                     (
                delegate(float dt)
            {
                bool setTimelinePosition = false;

                if (timelines.Highlighted || descriptionContainer != null)
                {
                    if (input.LeftMouseButton)
                    {
                        setTimelinePosition    = true;
                        playbackLocation.Value = Vector3.Transform(new Vector3(input.Mouse.Value.X, 0.0f, 0.0f), Matrix.Invert(timeline.GetAbsoluteTransform())).X;
                    }

                    float threshold     = 3.0f / timelines.Scale.Value.X;
                    float mouseRelative = Vector3.Transform(new Vector3(input.Mouse, 0.0f), Matrix.Invert(timelines.GetAbsoluteTransform())).X;

                    if (descriptionContainer != null)
                    {
                        if (!timelines.Highlighted || (float)Math.Abs(descriptionContainer.Position.Value.X - mouseRelative) > threshold)
                        {
                            descriptionContainer.Delete.Execute();
                            descriptionContainer = null;
                        }
                    }

                    if (descriptionContainer == null && timeline.Highlighted)
                    {
                        foreach (UIComponent component in timeline.Children)
                        {
                            LineDrawer2D lines = component as LineDrawer2D;

                            if (lines == null)
                            {
                                continue;
                            }

                            Session.EventList el = lines.UserData.Value as Session.EventList;
                            if (el != null)
                            {
                                bool stop = false;
                                foreach (Session.Event e in el.Events)
                                {
                                    if (el != null && (float)Math.Abs(e.Time - mouseRelative) < threshold)
                                    {
                                        descriptionContainer = new Container();
                                        descriptionContainer.AnchorPoint.Value = new Vector2(0.5f, 1.0f);
                                        descriptionContainer.Position.Value    = new Vector2(e.Time, 0.0f);
                                        descriptionContainer.Opacity.Value     = 1.0f;
                                        descriptionContainer.Tint.Value        = Microsoft.Xna.Framework.Color.Black;
                                        descriptionContainer.Add(new Binding <Vector2>(descriptionContainer.Scale, x => new Vector2(1.0f / x.X, 1.0f / x.Y), timelines.Scale));
                                        timeline.Children.Add(descriptionContainer);
                                        TextElement description     = new TextElement();
                                        description.WrapWidth.Value = 256;

                                        if (string.IsNullOrEmpty(e.Data))
                                        {
                                            description.Text.Value = el.Name;
                                        }
                                        else
                                        {
                                            description.Text.Value = string.Format("{0}\n{1}", el.Name, e.Data);
                                        }

                                        description.FontFile.Value = main.Font;
                                        descriptionContainer.Children.Add(description);
                                        stop = true;
                                        break;
                                    }
                                }
                                if (stop)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }

                if (analyticsPlaying && !setTimelinePosition)
                {
                    if (analyticsActiveSessions.Length == 0)
                    {
                        analyticsPlaying.Value = false;
                    }
                    else
                    {
                        playbackLocation.Value += dt * playbackSpeed;
                    }
                }
            }
                                     );

            entity.Add(timelineUpdate);
            timelineUpdate.EnabledInEditMode = true;
        }
示例#7
0
 void Awake()
 {
     inventory.OnContainerReady += () => {
         containerItemId = inventory.Add(WeaponType.ToString(), maxAmmo);
     };
 }
        public void ConvertTo()
        {
            ReferenceConverter converter = new ReferenceConverter(typeof(ITestInterface));
            string referenceName = "reference name";

            Assert.Equal("(none)", (string)converter.ConvertTo(null, null, null, typeof(string)));

            TestComponent component = new TestComponent();

            // no context
            Assert.Equal(String.Empty, (string)converter.ConvertTo(null, null, component, typeof(string)));

            // context with IReferenceService
            TestReferenceService referenceService = new TestReferenceService();
            referenceService.AddReference(referenceName, component);
            TestTypeDescriptorContext context = new TestTypeDescriptorContext(referenceService);
            Assert.Equal(referenceName, (string)converter.ConvertTo(context, null, component, typeof(string)));

            // context with Component without IReferenceService
            Container container = new Container();
            container.Add(component, referenceName);
            context = new TestTypeDescriptorContext();
            context.Container = container;
            Assert.Equal(referenceName, (string)converter.ConvertTo(context, null, component, typeof(string)));
        }
示例#9
0
 public void Add(TKey key, TValue value)
 {
     Container.Add(key, value);
 }
示例#10
0
        /// <summary>
        /// Erzeugt ein neues CreativeMainScreen-Objekt und initialisiert dieses mit einem Knot3Game-Objekt.
        /// </summary>
        public CreativeMainScreen(GameCore game)
            : base(game)
        {
            buttons = new Container (this, DisplayLayer.ScreenUI + DisplayLayer.Menu);
            buttons.ItemAlignX = HorizontalAlignment.Center;
            buttons.ItemAlignY = VerticalAlignment.Center;

            Button newKnotButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "NEW\nKnot",
                onClick: (time) => NextScreen = new CreativeModeScreen (Game, new Knot ())
            );
            newKnotButton.SetCoordinates (left: 0.100f, top: 0.150f, right: 0.300f, bottom: 0.350f);

            Button loadKnotButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "LOAD\nKnot",
                onClick: (time) => NextScreen = new CreativeLoadScreen (Game)
            );
            loadKnotButton.SetCoordinates (left: 0.675f, top: 0.300f, right: 0.875f, bottom: 0.475f);

            Button newChallengeButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "NEW\nChallenge",
                onClick: (time) => NextScreen = new ChallengeCreateScreen (Game)
            );
            newChallengeButton.SetCoordinates (left: 0.250f, top: 0.525f, right: 0.600f, bottom: 0.750f);

            Button backButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Back",
                onClick: (time) => NextScreen = Game.Screens.Where ((s) => !(

                                                    s is CreativeMainScreen
                                                    || s is CreativeLoadScreen
                                                    || s is ChallengeCreateScreen)).ElementAt (0)
            );
            backButton.AddKey (Keys.Escape);
            backButton.SetCoordinates (left: 0.825f, top: 0.850f, right: 0.975f, bottom: 0.950f);

            buttons.Add (newKnotButton);
            buttons.Add (loadKnotButton);
            buttons.Add (newChallengeButton);
            buttons.Add (backButton);
            buttons.IsVisible = true;

            // die Linien
            lines.AddPoints (0.000f, 0.150f,
                             0.300f, 0.350f, 0.100f, 0.070f, 0.600f, 0.750f, 0.250f,
                             0.525f, 0.875f, 0.300f, 0.675f, 0.475f, 0.950f, 0.000f
                            );

            lines.AddPoints (0.975f, 0.850f, 0.825f, 0.950f, 0.975f, 0.850f);
        }
示例#11
0
 protected void Add(Drawable visualisation) => timeline.Add(visualisation);
示例#12
0
文件: OsuGame.cs 项目: yheno/osu
        protected override void LoadComplete()
        {
            base.LoadComplete();

            Add(new Drawable[] {
                new VolumeControlReceptor
                {
                    RelativeSizeAxes = Axes.Both,
                    ActionRequested = delegate(InputState state) { volume.Adjust(state); }
                },
                mainContent = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                },
                volume = new VolumeControl(),
                overlayContent = new Container{ RelativeSizeAxes = Axes.Both },
                new GlobalHotkeys //exists because UserInputManager is at a level below us.
                {
                    Handler = globalHotkeyPressed
                }
            });

            (modeStack = new Intro()).Preload(this, d =>
            {
                mainContent.Add(d);

                modeStack.ModePushed += modeAdded;
                modeStack.Exited += modeRemoved;
                modeStack.DisplayAsRoot();
            });

            //overlay elements
            (chat = new ChatOverlay { Depth = 0 }).Preload(this, overlayContent.Add);
            (options = new OptionsOverlay { Depth = -1 }).Preload(this, overlayContent.Add);
            (musicController = new MusicController() { Depth = -3 }).Preload(this, overlayContent.Add);

            Dependencies.Cache(options);
            Dependencies.Cache(musicController);

            (Toolbar = new Toolbar
            {
                Depth = -2,
                OnHome = delegate { mainMenu?.MakeCurrent(); },
                OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
            }).Preload(this, t =>
            {
                PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
                PlayMode.TriggerChange();
                overlayContent.Add(Toolbar);
            });

            options.StateChanged += delegate
            {
                switch (options.State)
                {
                    case Visibility.Hidden:
                        intro.MoveToX(0, OptionsOverlay.TRANSITION_LENGTH, EasingTypes.OutQuint);
                        break;
                    case Visibility.Visible:
                        intro.MoveToX(OptionsOverlay.SIDEBAR_WIDTH / 2, OptionsOverlay.TRANSITION_LENGTH, EasingTypes.OutQuint);
                        break;
                }
            };

            Cursor.Alpha = 0;
        }
示例#13
0
 public void AddTo(Container container)
 {
     container.Add(this);
 }
示例#14
0
        /// <summary>
        ///
        /// </summary>
        public HighscoreDialog(IScreen screen, DisplayLayer drawOrder, Challenge challenge)
            : base(screen, drawOrder, "Highscores")
        {
            // Der Titel-Text ist mittig ausgerichtet
            AlignX = HorizontalAlignment.Center;
            Bounds.Size = new ScreenPoint (screen, 0.60f, 0.5f);

            // Erstelle das Highscore-Menü
            highscoreList = new Menu (Screen, Index + DisplayLayer.Menu);
            highscoreList.Bounds = ContentBounds;
            highscoreList.ItemAlignX = HorizontalAlignment.Left;
            highscoreList.ItemAlignY = VerticalAlignment.Center;

            if (challenge.Highscore != null) {
                //sotiert die Highscoreliste wird nach der Zeit sotiert
                int highscoreCounter = 0;
                foreach (KeyValuePair<string, int> entry in challenge.Highscore.OrderBy (key => key.Value)) {
                    TimeSpan playTime = TimeSpan.FromSeconds (entry.Value);
                    string formattedPlayTime = (playTime.Hours * 60 + playTime.Minutes).ToString ("D2") + "m " + playTime.Seconds.ToString ("D2") + "s";

                    TextItem firstScore = new TextItem (screen, drawOrder, formattedPlayTime + "    " + entry.Key);
                    highscoreList.Add (firstScore);
                    highscoreCounter++;
                    if (highscoreCounter > 8) {
                        break;
                    }
                }
            }

            buttons = new Container (screen, Index + DisplayLayer.Menu);
            buttons.ItemBackgroundColor =(s) => Design.DialogBackground;
            buttons.ItemAlignX = HorizontalAlignment.Center;

            // Button zum Neustarten der Challenge
            Action<GameTime> restartAction = (time) => {
                Close (time);
                Screen.NextScreen = new ChallengeModeScreen (Screen.Game, challenge);
            };
            MenuEntry restartButton = new MenuEntry (
                screen: Screen,
                drawOrder: Index + DisplayLayer.MenuItem,
                name: "Restart challenge",
                onClick: restartAction
            );
            restartButton.Bounds.Size = new ScreenPoint (screen, ContentBounds.Size.Relative.X / 2, 0.05f);
            restartButton.Bounds.Position = ContentBounds.Position + ContentBounds.Size.OnlyY
                                            - restartButton.Bounds.Size.OnlyY;
            buttons.Add (restartButton);

            // Button für die Rückkehr zum StartScreen
            Action<GameTime> returnAction = (time) => {
                Close (time);
                Screen.NextScreen = new StartScreen (Screen.Game);
            };
            MenuEntry returnButton = new MenuEntry (
                screen: Screen,
                drawOrder: Index + DisplayLayer.MenuItem,
                name: "Return to menu",
                onClick: returnAction
            );
            returnButton.Bounds.Size = new ScreenPoint (screen, ContentBounds.Size.Relative.X / 2, 0.05f);
            returnButton.Bounds.Position = ContentBounds.Position + ContentBounds.Size.OnlyY
                                           - returnButton.Bounds.Size.OnlyY + ContentBounds.Size.OnlyX / 2;
            buttons.Add (returnButton);
        }
示例#15
0
        /// <summary>
        /// Erzeugt ein neues ConfirmDialog-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt.
        /// Zudem sind Angaben zur Zeichenreihenfolge, einer Zeichenkette für den Titel und für den eingeblendeten Text Pflicht.
        /// [base=screen, drawOrder, title, text]
        /// </summary>
        public ConfirmDialog(IScreen screen, DisplayLayer drawOrder, string title)
            : base(screen, drawOrder, title)
        {
            // Der Titel-Text ist mittig ausgerichtet
            AlignX = HorizontalAlignment.Center;

            Cancel = (time) => {
                Close (time);
            };
            Submit = (time) => {
                Close (time);
            };

            // Keys
            ValidKeys.AddRange (new Keys[] { Keys.Enter, Keys.Escape });

            // Menü, in dem die Textanzeige angezeigt wird
            menu = new Menu (Screen, Index + DisplayLayer.Menu);
            menu.Bounds = ContentBounds;
            menu.ItemForegroundColor = (s) => Color.White;
            menu.ItemBackgroundColor = (s) => Color.Transparent;
            menu.ItemAlignX = HorizontalAlignment.Left;
            menu.ItemAlignY = VerticalAlignment.Center;

            // Button-Container
            buttons = new Container (screen, Index + DisplayLayer.Menu);
            buttons.ItemAlignX = HorizontalAlignment.Center;
            buttons.ItemBackgroundColor = (s) => Design.DialogBackground;

            // Button zum Canceln
            Action<GameTime> cancelAction = (time) => {
                Cancel (time);
            };
            MenuEntry cancelButton = new MenuEntry (
                screen: Screen,
                drawOrder: Index + DisplayLayer.MenuItem,
                name: "Cancel",
                onClick: cancelAction
            );
            cancelButton.Bounds.Size = new ScreenPoint (screen, ()=>ContentBounds.Size.Relative.X / 2, ()=>0.05f);
            cancelButton.Bounds.Position = ContentBounds.Position + ContentBounds.Size.OnlyY
                                           - cancelButton.Bounds.Size.OnlyY;
            buttons.Add (cancelButton);

            // Button zum Submitten
            Action<GameTime> submitAction = (time) => {
                Submit (time);
            };
            MenuEntry submitButton = new MenuEntry (
                screen: Screen,
                drawOrder: Index + DisplayLayer.MenuItem,
                name: "Confirm",
                onClick: submitAction
            );
            submitButton.Bounds.Size = new ScreenPoint (screen, ()=>ContentBounds.Size.Relative.X / 2, ()=>0.05f);
            submitButton.Bounds.Position = ContentBounds.Position + ContentBounds.Size.OnlyY
                                           - submitButton.Bounds.Size.OnlyY + ContentBounds.Size.OnlyX / 2;
            buttons.Add (submitButton);

            // Buttons zum Menü hinzufügen
            menu.Add (buttons);
        }
示例#16
0
        protected SongSelect()
        {
            const float carousel_width = 640;
            const float filter_height  = 100;

            AddRange(new Drawable[]
            {
                new ParallaxContainer
                {
                    Padding = new MarginPadding {
                        Top = filter_height
                    },
                    ParallaxAmount   = 0.005f,
                    RelativeSizeAxes = Axes.Both,
                    Children         = new[]
                    {
                        new WedgeBackground
                        {
                            RelativeSizeAxes = Axes.Both,
                            Padding          = new MarginPadding {
                                Right = carousel_width * 0.76f
                            },
                        }
                    }
                },
                LeftContent = new Container
                {
                    Origin           = Anchor.BottomLeft,
                    Anchor           = Anchor.BottomLeft,
                    RelativeSizeAxes = Axes.Both,
                    Size             = new Vector2(wedged_container_size.X, 1),
                    Padding          = new MarginPadding
                    {
                        Bottom = 50,
                        Top    = wedged_container_size.Y + left_area_padding,
                        Left   = left_area_padding,
                        Right  = left_area_padding * 2,
                    }
                },
                new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Masking          = true,
                    Anchor           = Anchor.Centre,
                    Origin           = Anchor.Centre,
                    Width            = 2, //avoid horizontal masking so the panels don't clip when screen stack is pushed.
                    Child            = new Container
                    {
                        RelativeSizeAxes = Axes.Both,
                        Anchor           = Anchor.Centre,
                        Origin           = Anchor.Centre,
                        Width            = 0.5f,
                        Children         = new Drawable[]
                        {
                            Carousel = new BeatmapCarousel
                            {
                                Masking            = false,
                                RelativeSizeAxes   = Axes.Y,
                                Size               = new Vector2(carousel_width, 1),
                                Anchor             = Anchor.CentreRight,
                                Origin             = Anchor.CentreRight,
                                SelectionChanged   = updateSelectedBeatmap,
                                BeatmapSetsChanged = carouselBeatmapsLoaded,
                            },
                            FilterControl = new FilterControl
                            {
                                RelativeSizeAxes = Axes.X,
                                Height           = filter_height,
                                FilterChanged    = c => Carousel.Filter(c),
                                Background       = { Width = 2 },
                                Exit             = Exit,
                            },
                        }
                    },
                },
                beatmapInfoWedge = new BeatmapInfoWedge
                {
                    Size             = wedged_container_size,
                    RelativeSizeAxes = Axes.X,
                    Margin           = new MarginPadding
                    {
                        Top   = left_area_padding,
                        Right = left_area_padding,
                    },
                },
                new ResetScrollContainer(() => Carousel.ScrollToSelected())
                {
                    RelativeSizeAxes = Axes.Y,
                    Width            = 250,
                }
            });

            if (ShowFooter)
            {
                Add(FooterPanels = new Container
                {
                    Anchor           = Anchor.BottomLeft,
                    Origin           = Anchor.BottomLeft,
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Margin           = new MarginPadding
                    {
                        Bottom = Footer.HEIGHT,
                    },
                });
                Add(Footer = new Footer
                {
                    OnBack = Exit,
                });

                FooterPanels.Add(BeatmapOptions = new BeatmapOptionsOverlay());
            }
        }
示例#17
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            // The next time this is updated is in UpdateAfterChildren, which occurs too late and results
            // in the cursor being shown for a few frames during the intro.
            // This prevents the cursor from showing until we have a screen with CursorVisible = true
            CursorOverrideContainer.CanShowCursor = currentScreen?.CursorVisible ?? false;

            // hook up notifications to components.
            BeatmapManager.PostNotification = n => notifications?.Post(n);
            BeatmapManager.GetStableStorage = GetStorageForStableInstall;

            AddRange(new Drawable[]
            {
                new VolumeControlReceptor
                {
                    RelativeSizeAxes = Axes.Both,
                    ActionRequested  = action => volume.Adjust(action)
                },
                mainContent = new Container {
                    RelativeSizeAxes = Axes.Both
                },
                overlayContent = new Container {
                    RelativeSizeAxes = Axes.Both, Depth = float.MinValue
                },
            });

            loadComponentSingleFile(screenStack = new Loader(), d =>
            {
                screenStack.ModePushed += screenAdded;
                screenStack.Exited     += screenRemoved;
                mainContent.Add(screenStack);
            });

            loadComponentSingleFile(Toolbar = new Toolbar
            {
                Depth  = -5,
                OnHome = delegate
                {
                    hideAllOverlays();
                    intro?.ChildScreen?.MakeCurrent();
                },
            }, overlayContent.Add);

            loadComponentSingleFile(volume = new VolumeControl(), Add);
            loadComponentSingleFile(new OnScreenDisplay(), Add);

            //overlay elements
            loadComponentSingleFile(direct = new DirectOverlay {
                Depth = -1
            }, mainContent.Add);
            loadComponentSingleFile(social = new SocialOverlay {
                Depth = -1
            }, mainContent.Add);
            loadComponentSingleFile(chat = new ChatOverlay {
                Depth = -1
            }, mainContent.Add);
            loadComponentSingleFile(settings = new MainSettings
            {
                GetToolbarHeight = () => ToolbarOffset,
                Depth            = -1
            }, overlayContent.Add);
            loadComponentSingleFile(userProfile = new UserProfileOverlay {
                Depth = -2
            }, mainContent.Add);
            loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay {
                Depth = -3
            }, mainContent.Add);
            loadComponentSingleFile(musicController = new MusicController
            {
                Depth    = -4,
                Position = new Vector2(0, Toolbar.HEIGHT),
                Anchor   = Anchor.TopRight,
                Origin   = Anchor.TopRight,
            }, overlayContent.Add);

            loadComponentSingleFile(notifications = new NotificationOverlay
            {
                GetToolbarHeight = () => ToolbarOffset,
                Depth            = -4,
                Anchor           = Anchor.TopRight,
                Origin           = Anchor.TopRight,
            }, overlayContent.Add);

            loadComponentSingleFile(dialogOverlay = new DialogOverlay
            {
                Depth = -6,
            }, overlayContent.Add);

            forwardLoggedErrorsToNotifications();

            dependencies.Cache(settings);
            dependencies.Cache(social);
            dependencies.Cache(direct);
            dependencies.Cache(chat);
            dependencies.Cache(userProfile);
            dependencies.Cache(musicController);
            dependencies.Cache(beatmapSetOverlay);
            dependencies.Cache(notifications);
            dependencies.Cache(dialogOverlay);

            // ensure only one of these overlays are open at once.
            var singleDisplayOverlays = new OverlayContainer[] { chat, social, direct };

            foreach (var overlay in singleDisplayOverlays)
            {
                overlay.StateChanged += state =>
                {
                    if (state == Visibility.Hidden)
                    {
                        return;
                    }

                    foreach (var c in singleDisplayOverlays)
                    {
                        if (c == overlay)
                        {
                            continue;
                        }
                        c.State = Visibility.Hidden;
                    }
                };
            }

            // eventually informational overlays should be displayed in a stack, but for now let's only allow one to stay open at a time.
            var informationalOverlays = new OverlayContainer[] { beatmapSetOverlay, userProfile };

            foreach (var overlay in informationalOverlays)
            {
                overlay.StateChanged += state =>
                {
                    if (state == Visibility.Hidden)
                    {
                        return;
                    }

                    foreach (var c in informationalOverlays)
                    {
                        if (c == overlay)
                        {
                            continue;
                        }
                        c.State = Visibility.Hidden;
                    }
                };
            }

            void updateScreenOffset()
            {
                float offset = 0;

                if (settings.State == Visibility.Visible)
                {
                    offset += ToolbarButton.WIDTH / 2;
                }
                if (notifications.State == Visibility.Visible)
                {
                    offset -= ToolbarButton.WIDTH / 2;
                }

                screenStack.MoveToX(offset, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint);
            }

            settings.StateChanged      += _ => updateScreenOffset();
            notifications.StateChanged += _ => updateScreenOffset();

            notifications.Enabled.BindTo(ShowOverlays);

            ShowOverlays.ValueChanged += show =>
            {
                //central game screen change logic.
                if (!show)
                {
                    hideAllOverlays();
                    musicController.State = Visibility.Hidden;
                    Toolbar.State         = Visibility.Hidden;
                }
                else
                {
                    Toolbar.State = Visibility.Visible;
                }
            };
        }
 public RelativeCylinderConstraintRenderer(string label) : base(label)
 {
     radiusField = new TextField("Radius");
     radiusField.SetEnabled(false);
     Container.Add(radiusField);
 }
 public ComponentIconRenderer(string label) : base(label)
 {
     iconNameField = new TextField("Icon Name");
     iconNameField.SetEnabled(false);
     Container.Add(iconNameField);
 }
 public RelativeBoxConstraintRenderer(string label) : base(label)
 {
     edgeLengthField = new global::Improbable.EdgeLengthRenderer("Edge Length");
     Container.Add(edgeLengthField);
 }
示例#21
0
        /// <summary>
        /// Erzeugt eine neue Instanz eines StartScreen-Objekts und initialisiert diese mit einem Knot3Game-Objekt.
        /// </summary>
        public StartScreen(GameCore game)
            : base(game)
        {
            // leere den Screen-Stack beim Öffnen dieses Screens
            ClearScreenHistory = true;

            // der Container für die Buttons
            buttons = new Container (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.Menu);

            // logo
            logo = this.LoadTexture (name: "logo");
            if (Config.Default ["debug", "projector-mode", false]) {
                logo = ContentLoader.InvertTexture (screen: this, texture: logo);
            }

            // create a new SpriteBatch, which can be used to draw textures
            spriteBatch = new SpriteBatch (GraphicsDevice);

            // menu
            buttons.ItemAlignX = HorizontalAlignment.Center;
            buttons.ItemAlignY = VerticalAlignment.Center;

            Button creativeButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Creative",
                onClick: (time) => NextScreen = new CreativeMainScreen (Game)
            );
            creativeButton.SetCoordinates (left: 0.700f, top: 0.250f, right: 0.960f, bottom: 0.380f);

            Button challengeButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Challenge",
                onClick: (time) => NextScreen = new ChallengeStartScreen (Game)
            );
            challengeButton.SetCoordinates (left: 0.000f, top: 0.050f, right: 0.380f, bottom: 0.190f);

            Button settingsButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Settings",
                onClick: (time) => NextScreen = new GeneralSettingsScreen (Game)
            );
            settingsButton.SetCoordinates (left: 0.260f, top: 0.840f, right: 0.480f, bottom: 0.950f);

            Button exitButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: String.Empty, // "Exit",
                onClick: (time) => Game.Exit ()
            );

            exitButton.AddKey (Keys.Escape);
            exitButton.SetCoordinates (left: 0.815f, top: 0.585f, right: 0.895f, bottom: 0.705f);
            exitButton.BackgroundTexture = this.LoadTexture ("exit300");
            if (Config.Default ["debug", "projector-mode", false]) {
                exitButton.BackgroundTexture = ContentLoader.InvertTexture (screen: this, texture: exitButton.BackgroundTexture);
            }

            buttons.Add (creativeButton);
            buttons.Add (challengeButton);
            buttons.Add (settingsButton);
            buttons.Add (exitButton);

            // Linien:

            lines.AddPoints (
                0.000f,
                0.050f,
                0.380f,
                0.250f,
                0.960f,
                0.380f,
                0.700f,
                0.160f,
                1.000f
            );

            lines.AddPoints (0.000f,
                             0.190f,
                             0.620f,
                             0.785f,
                             0.800f,
                             0.565f, // Exit oben.
                             0.910f, // Exit rechts.
                             0.730f, // Exit unten.
                             0.480f,
                             0.950f,
                             0.260f,
                             0.840f,
                             0.520f,
                             1.000f
                            );
        }
            public QueryConstraintRenderer(string label) : base(label)
            {
                var sphereConstraintInnerField = new global::Improbable.ComponentInterestRenderer.SphereConstraintRenderer("Value");

                sphereConstraintField = new NullableVisualElement <global::Improbable.ComponentInterestRenderer.SphereConstraintRenderer, global::Improbable.ComponentInterest.SphereConstraint>("Sphere Constraint", sphereConstraintInnerField, (element, data) => { element.Update(data); });
                Container.Add(sphereConstraintField);

                var cylinderConstraintInnerField = new global::Improbable.ComponentInterestRenderer.CylinderConstraintRenderer("Value");

                cylinderConstraintField = new NullableVisualElement <global::Improbable.ComponentInterestRenderer.CylinderConstraintRenderer, global::Improbable.ComponentInterest.CylinderConstraint>("Cylinder Constraint", cylinderConstraintInnerField, (element, data) => { element.Update(data); });
                Container.Add(cylinderConstraintField);

                var boxConstraintInnerField = new global::Improbable.ComponentInterestRenderer.BoxConstraintRenderer("Value");

                boxConstraintField = new NullableVisualElement <global::Improbable.ComponentInterestRenderer.BoxConstraintRenderer, global::Improbable.ComponentInterest.BoxConstraint>("Box Constraint", boxConstraintInnerField, (element, data) => { element.Update(data); });
                Container.Add(boxConstraintField);

                var relativeSphereConstraintInnerField = new global::Improbable.ComponentInterestRenderer.RelativeSphereConstraintRenderer("Value");

                relativeSphereConstraintField = new NullableVisualElement <global::Improbable.ComponentInterestRenderer.RelativeSphereConstraintRenderer, global::Improbable.ComponentInterest.RelativeSphereConstraint>("Relative Sphere Constraint", relativeSphereConstraintInnerField, (element, data) => { element.Update(data); });
                Container.Add(relativeSphereConstraintField);

                var relativeCylinderConstraintInnerField = new global::Improbable.ComponentInterestRenderer.RelativeCylinderConstraintRenderer("Value");

                relativeCylinderConstraintField = new NullableVisualElement <global::Improbable.ComponentInterestRenderer.RelativeCylinderConstraintRenderer, global::Improbable.ComponentInterest.RelativeCylinderConstraint>("Relative Cylinder Constraint", relativeCylinderConstraintInnerField, (element, data) => { element.Update(data); });
                Container.Add(relativeCylinderConstraintField);

                var relativeBoxConstraintInnerField = new global::Improbable.ComponentInterestRenderer.RelativeBoxConstraintRenderer("Value");

                relativeBoxConstraintField = new NullableVisualElement <global::Improbable.ComponentInterestRenderer.RelativeBoxConstraintRenderer, global::Improbable.ComponentInterest.RelativeBoxConstraint>("Relative Box Constraint", relativeBoxConstraintInnerField, (element, data) => { element.Update(data); });
                Container.Add(relativeBoxConstraintField);

                var entityIdConstraintInnerField = new TextField("Value");

                entityIdConstraintInnerField.SetEnabled(false);
                entityIdConstraintField = new NullableVisualElement <TextField, long>("Entity Id Constraint", entityIdConstraintInnerField, (element, data) => { element.value = data.ToString(); });
                Container.Add(entityIdConstraintField);

                var componentConstraintInnerField = new TextField("Value");

                componentConstraintInnerField.SetEnabled(false);
                componentConstraintField = new NullableVisualElement <TextField, uint>("Component Constraint", componentConstraintInnerField, (element, data) => { element.value = data.ToString(); });
                Container.Add(componentConstraintField);

                andConstraintField = new PaginatedListView <global::Improbable.ComponentInterestRenderer.QueryConstraintRenderer, global::Improbable.ComponentInterest.QueryConstraint>("And Constraint", () => {
                    var inner = new global::Improbable.ComponentInterestRenderer.QueryConstraintRenderer("");
                    return(inner);
                }, (index, data, element) => {
                    element.Label = $"Item {index + 1}";
                    element.Update(data);
                });
                Container.Add(andConstraintField);

                orConstraintField = new PaginatedListView <global::Improbable.ComponentInterestRenderer.QueryConstraintRenderer, global::Improbable.ComponentInterest.QueryConstraint>("Or Constraint", () => {
                    var inner = new global::Improbable.ComponentInterestRenderer.QueryConstraintRenderer("");
                    return(inner);
                }, (index, data, element) => {
                    element.Label = $"Item {index + 1}";
                    element.Update(data);
                });
                Container.Add(orConstraintField);
            }
示例#23
0
    static void RunCUI()
    {
        Container a = new Container (0, 0, Application.Cols, Application.Lines);

        Frame fMain = new Frame(0, 0, 0, 0, "zerob0t");
        Frame fHighA = new Frame(0, 0, 0, 0, "fHighA");
        Frame fHighB = new Frame(0, 0, 0, 0, "fHighB");
        Frame fHighLR = new Frame(0, 0, 0, 0, "Info");
        Frame fHighSR = new Frame(0, 0, 0, 0, "fHighSR");

        a.Add(fMain);
        a.Add(fHighA);
        a.Add(fHighB);
        a.Add(fHighLR);
        a.Add(fHighSR);

        Button bQuit = new Button(1, 1, "Quit");
        bQuit.Clicked += delegate {
            a.Running = false;
        };
        fMain.Add(bQuit);

        // Final setup details
        // GUI.cs Colors:
        // 0:	Black
        // 1:
        // 2:
        // 3:
        // 4:
        // 5:
        // 6:
        // 7:
        // 8:
        // 9:
        // 10:
        // 11:
        // 12:
        // 13:
        // 14:
        // 15:

        // ColorBasic is
        //	Application.ColorBasic = 3585;

        // ColorDialogFocus is
        //	Application.ColorDialogFocus = 0;

        // ColorDialogHotFocus is
        //	Application.ColorDialogHotFocus = 0;

        //	Application.ColorDialogHotNormal = 0;

        // ColorDialogNormal is label background color
        //	Application.ColorDialogNormal = 0;

        //	Application.ColorError = 0;

        // ColorFocus is background of whatever widget has focus
        //	Application.ColorFocus = 0;

        //	Application.ColorNormal = 0;

        LayoutDialogs(fMain, fHighA, fHighB, fHighLR, fHighSR);

        Application.Timeout = 1000;
        Application.Iteration += delegate {
            Application.Refresh();
        };

        a.SizeChangedEvent += delegate {
            LayoutDialogs(fMain, fHighA, fHighB, fHighLR, fHighSR);
        };
        Application.Run(a);
    }
示例#24
0
        protected SongSelect()
        {
            const float carousel_width = 640;
            const float filter_height  = 100;

            Add(new ParallaxContainer
            {
                Padding = new MarginPadding {
                    Top = filter_height
                },
                ParallaxAmount   = 0.005f,
                RelativeSizeAxes = Axes.Both,
                Children         = new[]
                {
                    new WedgeBackground
                    {
                        RelativeSizeAxes = Axes.Both,
                        Padding          = new MarginPadding {
                            Right = carousel_width * 0.76f
                        },
                    }
                }
            });
            Add(LeftContent = new Container
            {
                Origin           = Anchor.BottomLeft,
                Anchor           = Anchor.BottomLeft,
                RelativeSizeAxes = Axes.Both,
                Size             = new Vector2(wedged_container_size.X, 1),
                Padding          = new MarginPadding
                {
                    Bottom = 50,
                    Top    = wedged_container_size.Y + left_area_padding,
                    Left   = left_area_padding,
                    Right  = left_area_padding * 2,
                }
            });
            Add(carousel = new BeatmapCarousel
            {
                RelativeSizeAxes = Axes.Y,
                Size             = new Vector2(carousel_width, 1),
                Anchor           = Anchor.CentreRight,
                Origin           = Anchor.CentreRight,
                SelectionChanged = carouselSelectionChanged,
                BeatmapsChanged  = carouselBeatmapsLoaded,
                DeleteRequested  = promptDelete,
                RestoreRequested = s => { foreach (var b in s.Beatmaps)
                                          {
                                              beatmaps.Restore(b);
                                          }
                },
                EditRequested           = editRequested,
                HideDifficultyRequested = b => beatmaps.Hide(b),
                StartRequested          = () => carouselRaisedStart(),
            });
            Add(FilterControl = new FilterControl
            {
                RelativeSizeAxes = Axes.X,
                Height           = filter_height,
                FilterChanged    = criteria => filterChanged(criteria),
                Exit             = Exit,
            });
            Add(beatmapInfoWedge = new BeatmapInfoWedge
            {
                Alpha            = 0,
                Size             = wedged_container_size,
                RelativeSizeAxes = Axes.X,
                Margin           = new MarginPadding
                {
                    Top   = left_area_padding,
                    Right = left_area_padding,
                },
            });
            Add(new ResetScrollContainer(() => carousel.ScrollToSelected())
            {
                RelativeSizeAxes = Axes.Y,
                Width            = 250,
            });

            if (ShowFooter)
            {
                Add(FooterPanels = new Container
                {
                    Anchor           = Anchor.BottomLeft,
                    Origin           = Anchor.BottomLeft,
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Margin           = new MarginPadding
                    {
                        Bottom = Footer.HEIGHT,
                    },
                });
                Add(Footer = new Footer
                {
                    OnBack = Exit,
                });

                FooterPanels.Add(BeatmapOptions = new BeatmapOptionsOverlay());
            }
        }
        public void ConvertFrom()
        {
            ReferenceConverter converter = new ReferenceConverter(typeof(ITestInterface));
            string referenceName = "reference name";
            // no context
            Assert.Null(converter.ConvertFrom(null, null, referenceName));

            TestComponent component = new TestComponent();

            // context with IReferenceService
            TestReferenceService referenceService = new TestReferenceService();
            referenceService.AddReference(referenceName, component);
            TestTypeDescriptorContext context = new TestTypeDescriptorContext(referenceService);
            Assert.Same(component, converter.ConvertFrom(context, null, referenceName));

            // context with Component without IReferenceService
            Container container = new Container();
            container.Add(component, referenceName);
            context = new TestTypeDescriptorContext();
            context.Container = container;
            Assert.Same(component, converter.ConvertFrom(context, null, referenceName));
        }
示例#26
0
        private void loadTest(int testType)
        {
            testContainer.Clear();

            Container box;

            switch (testType)
            {
            case 0:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                addCornerMarkers(box);

                box.Add(new InfofulBox
                {
                    //chameleon = true,
                    Position = new Vector2(0, 0),
                    Size     = new Vector2(25, 25),
                    Origin   = Anchor.Centre,
                    Anchor   = Anchor.Centre,
                    Colour   = Color4.Blue,
                });

                box.Add(box = new InfofulBox
                {
                    Size   = new Vector2(250, 250),
                    Alpha  = 0.5f,
                    Origin = Anchor.Centre,
                    Anchor = Anchor.Centre,
                    Colour = Color4.DarkSeaGreen,
                });

                box.OnUpdate += delegate { box.Rotation += 0.05f; };
                break;

            case 1:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                addCornerMarkers(box, 5);


                box.Add(box = new InfofulBoxAutoSize
                {
                    Colour = Color4.DarkSeaGreen,
                    Alpha  = 0.5f,
                    Origin = Anchor.Centre,
                    Anchor = Anchor.Centre
                });

                Drawable localBox = box;
                box.OnUpdate += delegate { localBox.Rotation += 0.05f; };

                box.Add(new InfofulBox
                {
                    //chameleon = true,
                    Size     = new Vector2(100, 100),
                    Position = new Vector2(50, 50),
                    Alpha    = 0.5f,
                    Origin   = Anchor.Centre,
                    Anchor   = Anchor.Centre,
                    Colour   = Color4.Blue,
                });
                break;

            case 2:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                addCornerMarkers(box, 10, Color4.YellowGreen);

                for (int i = 0; i < 50; i++)
                {
                    box.Add(box = new InfofulBoxAutoSize
                    {
                        Colour   = new Color4(253, 253, 253, 255),
                        Position = new Vector2(-3, -3),
                        Origin   = Anchor.BottomRight,
                        Anchor   = Anchor.BottomRight,
                    });
                }

                addCornerMarkers(box, 2);

                box.Add(new InfofulBox
                {
                    //chameleon = true,
                    Size   = new Vector2(50, 50),
                    Origin = Anchor.BottomRight,
                    Anchor = Anchor.BottomRight,
                    Colour = Color4.SeaGreen,
                });
                break;

            case 3:
                testContainer.Add(box = new InfofulBox
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre,
                    Size   = new Vector2(250, 250)
                });

                addCornerMarkers(box, 10, Color4.YellowGreen);

                for (int i = 0; i < 100; i++)
                {
                    box.Add(box = new InfofulBox
                    {
                        RelativeSizeAxes = Axes.Both,
                        Colour           = new Color4(253, 253, 253, 255),
                        Origin           = Anchor.BottomRight,
                        Anchor           = Anchor.BottomRight,
                        Size             = new Vector2(0.99f, 0.99f)
                    });
                }

                addCornerMarkers(box, 2);

                box.Add(new InfofulBox
                {
                    //chameleon = true,
                    Size   = new Vector2(50, 50),
                    Origin = Anchor.BottomRight,
                    Anchor = Anchor.BottomRight,
                    Colour = Color4.SeaGreen,
                });
                break;

            case 4:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.CentreLeft
                });

                box.Add(new InfofulBox
                {
                    Position = new Vector2(5, 0),
                    Size     = new Vector2(300, 80),
                    Origin   = Anchor.TopLeft,
                    Anchor   = Anchor.TopLeft,
                    Colour   = Color4.OrangeRed,
                });

                box.Add(new SpriteText
                {
                    Position = new Vector2(5, -20),
                    Text     = "Test CentreLeft line 1",
                    Origin   = Anchor.CentreLeft,
                    Anchor   = Anchor.CentreLeft
                });

                box.Add(new SpriteText
                {
                    Position = new Vector2(5, 20),
                    Text     = "Test CentreLeft line 2",
                    Origin   = Anchor.CentreLeft,
                    Anchor   = Anchor.CentreLeft
                });
                break;

            case 5:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.CentreLeft
                });

                box.Add(new InfofulBox
                {
                    Position = new Vector2(5, 0),
                    Size     = new Vector2(300, 80),
                    Origin   = Anchor.TopLeft,
                    Anchor   = Anchor.TopLeft,
                    Colour   = Color4.OrangeRed,
                });

                box.Add(new SpriteText
                {
                    Position = new Vector2(5, -20),
                    Text     = "123,456,789=",
                    Origin   = Anchor.CentreLeft,
                    Anchor   = Anchor.CentreLeft,
                    Scale    = new Vector2(2f)
                });

                box.Add(new SpriteText
                {
                    Position = new Vector2(5, 20),
                    Text     = "123,456,789ms",
                    Origin   = Anchor.CentreLeft,
                    Anchor   = Anchor.CentreLeft
                });
                break;

            case 6:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                box.Add(box = new InfofulBoxAutoSize
                {
                    Colour   = Color4.OrangeRed,
                    Position = new Vector2(100, 100),
                    Origin   = Anchor.Centre,
                    Anchor   = Anchor.TopLeft
                });

                box.Add(new InfofulBox
                {
                    Position = new Vector2(100, 100),
                    Size     = new Vector2(100, 100),
                    Origin   = Anchor.Centre,
                    Anchor   = Anchor.TopLeft,
                    Colour   = Color4.OrangeRed,
                });
                break;

            case 7:
                Container            shrinkContainer;
                Container <Drawable> boxes;

                testContainer.Add(shrinkContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Size             = new Vector2(0.5f, 1),
                    Anchor           = Anchor.TopCentre,
                    Origin           = Anchor.TopCentre,
                    Children         = new Drawable[]
                    {
                        new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Colour           = Color4.AliceBlue,
                            Alpha            = 0.2f
                        },
                        boxes = new FillFlowContainer
                        {
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes     = Axes.Y,
                            Direction        = FillDirection.Vertical,
                            Spacing          = new Vector2(0, 10),
                        }
                    }
                });

                for (int i = 0; i < 10; i++)
                {
                    boxes.Add(new Box
                    {
                        RelativeSizeAxes = Axes.X,
                        Anchor           = Anchor.TopCentre,
                        Origin           = Anchor.TopCentre,
                        Size             = new Vector2(0.9f, 40),
                        Colour           = Color4.AliceBlue,
                        Alpha            = 0.2f
                    });
                }

                shrinkContainer.ScaleTo(new Vector2(1.5f, 1), 1000).Then().ScaleTo(Vector2.One, 1000).Loop();
                break;

            case 8:
            {
                Container box1;
                Container box2;
                Container box3;

                testContainer.Add(new FillFlowContainer
                    {
                        RelativeSizeAxes = Axes.Both,
                        Children         = new Drawable[]
                        {
                            // This first guy is used for spacing.
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.125f, 1),
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Padding      = new MarginPadding(50),
                                                Children     = new Drawable[]
                                                {
                                                    box1 = new InfofulBox
                                                    {
                                                        Anchor = Anchor.TopLeft,
                                                        Origin = Anchor.TopLeft,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Padding      = new MarginPadding(50),
                                                Children     = new Drawable[]
                                                {
                                                    box2 = new InfofulBox
                                                    {
                                                        Anchor = Anchor.Centre,
                                                        Origin = Anchor.Centre,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Padding      = new MarginPadding(50),
                                                Children     = new Drawable[]
                                                {
                                                    box3 = new InfofulBox
                                                    {
                                                        Anchor = Anchor.BottomRight,
                                                        Origin = Anchor.BottomRight,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                        }
                    });

                foreach (Container b in new[] { box1, box2, box3 })
                {
                    b.ScaleTo(new Vector2(2), 1000).Then().ScaleTo(Vector2.One, 1000).Loop();
                }

                break;
            }

            case 9:
            {
                Container box1;
                Container box2;
                Container box3;

                testContainer.Add(new FillFlowContainer
                    {
                        RelativeSizeAxes = Axes.Both,
                        Children         = new Drawable[]
                        {
                            // This first guy is used for spacing.
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.125f, 1),
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Margin       = new MarginPadding(50),
                                                Children     = new Drawable[]
                                                {
                                                    box1 = new InfofulBox
                                                    {
                                                        Anchor = Anchor.TopLeft,
                                                        Origin = Anchor.TopLeft,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Margin       = new MarginPadding(50),
                                                Children     = new Drawable[]
                                                {
                                                    box2 = new InfofulBox
                                                    {
                                                        Anchor = Anchor.Centre,
                                                        Origin = Anchor.Centre,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Margin       = new MarginPadding(50),
                                                Children     = new Drawable[]
                                                {
                                                    box3 = new InfofulBox
                                                    {
                                                        Anchor = Anchor.BottomRight,
                                                        Origin = Anchor.BottomRight,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                        }
                    });

                foreach (Container b in new[] { box1, box2, box3 })
                {
                    b.ScaleTo(new Vector2(2), 1000).Then().ScaleTo(Vector2.One, 1000).Loop();
                }

                break;
            }

            case 10:
            {
                Container box1;
                Container box2;
                Container box3;

                testContainer.Add(new FillFlowContainer
                    {
                        RelativeSizeAxes = Axes.Both,
                        Children         = new Drawable[]
                        {
                            // This first guy is used for spacing.
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.125f, 1),
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Children     = new Drawable[]
                                                {
                                                    box1 = new InfofulBox
                                                    {
                                                        Margin = new MarginPadding(50),
                                                        Anchor = Anchor.TopLeft,
                                                        Origin = Anchor.TopLeft,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Children     = new Drawable[]
                                                {
                                                    box2 = new InfofulBox
                                                    {
                                                        Margin = new MarginPadding(50),
                                                        Anchor = Anchor.Centre,
                                                        Origin = Anchor.Centre,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Children     = new Drawable[]
                                                {
                                                    box3 = new InfofulBox
                                                    {
                                                        Margin = new MarginPadding(50),
                                                        Anchor = Anchor.BottomRight,
                                                        Origin = Anchor.BottomRight,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                        }
                    });

                foreach (Container b in new[] { box1, box2, box3 })
                {
                    b.ScaleTo(new Vector2(2), 1000).Then().ScaleTo(Vector2.One, 1000).Loop();
                }

                break;
            }

            case 11:
            {
                Drawable box1;
                Drawable box2;
                Drawable box3;

                testContainer.Add(new FillFlowContainer
                    {
                        RelativeSizeAxes = Axes.Both,
                        Children         = new Drawable[]
                        {
                            // This first guy is used for spacing.
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.125f, 1),
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Children     = new[]
                                                {
                                                    box1 = new Box
                                                    {
                                                        Margin = new MarginPadding(50),
                                                        Anchor = Anchor.TopLeft,
                                                        Origin = Anchor.TopLeft,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Children     = new[]
                                                {
                                                    box2 = new Box
                                                    {
                                                        Margin = new MarginPadding(50),
                                                        Anchor = Anchor.Centre,
                                                        Origin = Anchor.Centre,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Children     = new[]
                                                {
                                                    box3 = new Box
                                                    {
                                                        Margin = new MarginPadding(50),
                                                        Anchor = Anchor.BottomRight,
                                                        Origin = Anchor.BottomRight,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                        }
                    });

                foreach (Drawable b in new[] { box1, box2, box3 })
                {
                    b.ScaleTo(new Vector2(2), 1000).Then().ScaleTo(Vector2.One, 1000).Loop();
                }

                break;
            }

            case 12:
            {
                // demonstrates how relativeaxes drawables act inside an autosize parent
                Drawable sizedBox;

                testContainer.Add(new FillFlowContainer
                    {
                        RelativeSizeAxes = Axes.Both,
                        Children         = new Drawable[]
                        {
                            new Container
                            {
                                Size     = new Vector2(300),
                                Anchor   = Anchor.Centre,
                                Origin   = Anchor.Centre,
                                Children = new Drawable[]
                                {
                                    new Box {
                                        Colour = Color4.Gray, RelativeSizeAxes = Axes.Both
                                    },
                                    new Container
                                    {
                                        AutoSizeAxes = Axes.Both,
                                        Anchor       = Anchor.Centre,
                                        Origin       = Anchor.Centre,
                                        Children     = new[]
                                        {
                                            // defines the size of autosize
                                            sizedBox = new Box
                                            {
                                                Colour = Color4.Red,
                                                Anchor = Anchor.Centre,
                                                Origin = Anchor.Centre,
                                                Size   = new Vector2(100f)
                                            },
                                            // gets relative size based on autosize
                                            new Box
                                            {
                                                Colour           = Color4.Black,
                                                RelativeSizeAxes = Axes.Both,
                                                Size             = new Vector2(0.5f)
                                            },
                                        }
                                    }
                                }
                            }
                        }
                    });

                sizedBox.ScaleTo(new Vector2(2), 1000, Easing.Out).Then().ScaleTo(Vector2.One, 1000, Easing.In).Loop();
                break;
            }
            }
        }
示例#27
0
        protected SongSelect()
        {
            const float carousel_width = 640;
            const float filter_height  = 100;

            Add(new ParallaxContainer
            {
                Padding = new MarginPadding {
                    Top = filter_height
                },
                ParallaxAmount   = 0.005f,
                RelativeSizeAxes = Axes.Both,
                Children         = new[]
                {
                    new WedgeBackground
                    {
                        RelativeSizeAxes = Axes.Both,
                        Padding          = new MarginPadding {
                            Right = carousel_width * 0.76f
                        },
                    }
                }
            });
            Add(LeftContent = new Container
            {
                Origin           = Anchor.BottomLeft,
                Anchor           = Anchor.BottomLeft,
                RelativeSizeAxes = Axes.Both,
                Size             = new Vector2(wedged_container_size.X, 1),
                Padding          = new MarginPadding
                {
                    Bottom = 50,
                    Top    = wedged_container_size.Y + left_area_padding,
                    Left   = left_area_padding,
                    Right  = left_area_padding * 2,
                }
            });
            Add(carousel = new BeatmapCarousel
            {
                RelativeSizeAxes = Axes.Y,
                Size             = new Vector2(carousel_width, 1),
                Anchor           = Anchor.CentreRight,
                Origin           = Anchor.CentreRight,
                SelectionChanged = selectionChanged,
                StartRequested   = raiseSelect
            });
            Add(FilterControl = new FilterControl
            {
                RelativeSizeAxes = Axes.X,
                Height           = filter_height,
                FilterChanged    = criteria => filterChanged(criteria),
                Exit             = Exit,
            });
            Add(beatmapInfoWedge = new BeatmapInfoWedge
            {
                Alpha            = 0,
                Size             = wedged_container_size,
                RelativeSizeAxes = Axes.X,
                Margin           = new MarginPadding
                {
                    Top   = left_area_padding,
                    Right = left_area_padding,
                },
                X = -50,
            });

            if (ShowFooter)
            {
                Add(FooterPanels = new Container
                {
                    Anchor           = Anchor.BottomLeft,
                    Origin           = Anchor.BottomLeft,
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Margin           = new MarginPadding
                    {
                        Bottom = Footer.HEIGHT,
                    },
                });
                Add(Footer = new Footer
                {
                    OnBack  = Exit,
                    OnStart = raiseSelect,
                });

                FooterPanels.Add(BeatmapOptions = new BeatmapOptionsOverlay());
            }
        }
示例#28
0
        /// <summary>
        /// Constructor
        /// </summary>
        public UpgradeView(ViewBase owner) : base(owner)
        {
            Builder builder = BuilderFromResource("ApsimNG.Resources.Glade.UpgradeView.glade");

            window1          = (Window)builder.GetObject("window1");
            button1          = (Button)builder.GetObject("button1");
            button2          = (Button)builder.GetObject("button2");
            table1           = (Table)builder.GetObject("table1");
            table2           = (Table)builder.GetObject("table2");
            firstNameBox     = (Entry)builder.GetObject("firstNameBox");
            lastNameBox      = (Entry)builder.GetObject("lastNameBox");
            organisationBox  = (Entry)builder.GetObject("organisationBox");
            emailBox         = (Entry)builder.GetObject("emailBox");
            countryBox       = (ComboBox)builder.GetObject("countryBox");
            label1           = (Label)builder.GetObject("label1");
            licenseContainer = (Container)builder.GetObject("licenseContainer");
            checkbutton1     = (CheckButton)builder.GetObject("checkbutton1");
            listview1        = (Gtk.TreeView)builder.GetObject("listview1");
            alignment7       = (Alignment)builder.GetObject("alignment7");
            oldVersions      = (CheckButton)builder.GetObject("checkbutton2");
            listview1.Model  = listmodel;

            Version version = Assembly.GetExecutingAssembly().GetName().Version;

            if (version.Revision == 0)
            {
                button1.Sensitive = false;
                table2.Hide();
                checkbutton1.Hide();
            }

            CellRendererText textRender = new Gtk.CellRendererText();

            textRender.Editable = false;

            TreeViewColumn column0 = new TreeViewColumn("Version", textRender, "text", 0);

            listview1.AppendColumn(column0);
            column0.Sizing    = TreeViewColumnSizing.Autosize;
            column0.Resizable = true;

            TreeViewColumn column1 = new TreeViewColumn("Description", textRender, "text", 1);

            listview1.AppendColumn(column1);
            column1.Sizing    = TreeViewColumnSizing.Autosize;
            column1.Resizable = true;

            // Populate the combo box with a list of valid country names.
            ListStore countries = new ListStore(typeof(string));

            foreach (string country in Constants.Countries)
            {
                countries.AppendValues(country);
            }
            countryBox.Model = countries;

            // Add a cell renderer to the combo box.
            CellRendererText cell = new CellRendererText();

            countryBox.PackStart(cell, false);
            countryBox.AddAttribute(cell, "text", 0);

            // Make the tab order a little more sensible than the defaults
            table1.FocusChain = new Widget[] { alignment7, button1, button2 };
            table2.FocusChain = new Widget[] { firstNameBox, lastNameBox, emailBox, organisationBox, countryBox };

            licenseView = new MarkdownView(owner);
            licenseContainer.Add(licenseView.MainWidget);
            tabbedExplorerView = owner as IMainView;

            window1.TransientFor = owner.MainWidget.Toplevel as Window;
            window1.Modal        = true;
            oldVersions.Toggled += OnShowOldVersionsToggled;
            button1.Clicked     += OnUpgrade;
            button2.Clicked     += OnViewMoreDetail;
            window1.Destroyed   += OnFormClosing;
            window1.MapEvent    += OnShown;
        }
示例#29
0
        private void computeLayout()
        {
            bool allowKeepingExistingDrawables = true;

            //adjust shadow alpha based on highest component intensity to avoid muddy display of darker text.
            //squared result for quadratic fall-off seems to give the best result.
            var   avgColour   = (Color4)DrawInfo.Colour.AverageColour;
            float shadowAlpha = (float)Math.Pow(Math.Max(Math.Max(avgColour.R, avgColour.G), avgColour.B), 2);

            //we can't keep existing drawabled if our shadow has changed, as the shadow is applied in the add-loop.
            //this could potentially be optimised if necessary.
            allowKeepingExistingDrawables &= shadowAlpha == lastShadowAlpha && font == lastFont;

            lastShadowAlpha = shadowAlpha;
            lastFont        = font;

            //keep sprites which haven't changed since last layout.
            List <Drawable> keepDrawables = new List <Drawable>();

            if (allowKeepingExistingDrawables)
            {
                if (lastText == text)
                {
                    return;
                }

                int length = Math.Min(lastText?.Length ?? 0, text.Length);
                keepDrawables.AddRange(Children.TakeWhile((n, i) => i < length && lastText[i] == text[i]));
                RemoveRange(keepDrawables); //doesn't dispose
            }

            Clear();

            if (text.Length == 0)
            {
                return;
            }

            if (FixedWidth && !constantWidth.HasValue)
            {
                constantWidth = CreateCharacterDrawable('D').DrawWidth;
            }

            foreach (var k in keepDrawables)
            {
                Add(k);
            }

            for (int index = keepDrawables.Count; index < text.Length; index++)
            {
                char c = text[index];

                bool fixedWidth = FixedWidth && !FixedWidthExceptionCharacters.Contains(c);

                Drawable d;

                if (char.IsWhiteSpace(c))
                {
                    float width = fixedWidth ? constantWidth.GetValueOrDefault() : spaceWidth;

                    switch ((int)c)
                    {
                    case 0x3000:     //double-width space
                        width *= 2;
                        break;
                    }

                    d = new Container
                    {
                        Size   = new Vector2(width),
                        Scale  = new Vector2(TextSize),
                        Colour = Color4.Transparent,
                    };
                }
                else
                {
                    d = CreateCharacterDrawable(c);

                    if (fixedWidth)
                    {
                        d.Anchor = Anchor.TopCentre;
                        d.Origin = Anchor.TopCentre;
                    }

                    var ctn = new Container
                    {
                        Size  = new Vector2(fixedWidth ? constantWidth.GetValueOrDefault() : d.DrawSize.X, UseFullGlyphHeight ? 1 : d.DrawSize.Y),
                        Scale = new Vector2(TextSize),
                        Child = d
                    };

                    if (shadow && shadowAlpha > 0)
                    {
                        Drawable shadowDrawable = CreateCharacterDrawable(c);
                        shadowDrawable.Position = new Vector2(0, 0.06f);
                        shadowDrawable.Anchor   = d.Anchor;
                        shadowDrawable.Origin   = d.Origin;
                        shadowDrawable.Alpha    = shadowAlpha;
                        shadowDrawable.Colour   = shadowColour;
                        shadowDrawable.Depth    = float.MaxValue;
                        ctn.Add(shadowDrawable);
                    }

                    d = ctn;
                }

                Add(d);
            }

            lastText = text;
        }
示例#30
0
        private Drawable createOverlayComponents(WorkingBeatmap working)
        {
            var container = new Container
            {
                RelativeSizeAxes = Axes.Both,
                Children         = new[]
                {
                    DimmableStoryboard.OverlayLayerContainer.CreateProxy(),
                BreakOverlay = new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, ScoreProcessor)
                    {
                        Clock = DrawableRuleset.FrameStableClock,
                        ProcessCustomClock = false,
                        Breaks             = working.Beatmap.Breaks
                    },
                    // display the cursor above some HUD elements.
                DrawableRuleset.Cursor?.CreateProxy() ?? new Container(),
                DrawableRuleset.ResumeOverlay?.CreateProxy() ?? new Container(),
                HUDOverlay = new HUDOverlay(ScoreProcessor, HealthProcessor, DrawableRuleset, Mods.Value)
                    {
                        HoldToQuit =
                        {
                            Action   = performUserRequestedExit,
                            IsPaused = { BindTarget = GameplayClockContainer.IsPaused }
                        },
                        PlayerSettingsOverlay = { PlaybackSettings = { UserPlaybackRate = { BindTarget = GameplayClockContainer.UserPlaybackRate } } },
                        KeyCounter            =
                        {
                            AlwaysVisible = { BindTarget = DrawableRuleset.HasReplayLoaded },
                            IsCounting    = false
                        },
                        RequestSeek = time =>
                        {
                            GameplayClockContainer.Seek(time);
                            GameplayClockContainer.Start();
                        },
                        Anchor = Anchor.Centre,
                        Origin = Anchor.Centre
                    },
                    skipOverlay = new SkipOverlay(DrawableRuleset.GameplayStartTime)
                    {
                        RequestSkip = performUserRequestedSkip
                    },
                    FailOverlay = new FailOverlay
                    {
                        OnRetry = Restart,
                        OnQuit  = performUserRequestedExit,
                    },
                    PauseOverlay = new PauseOverlay
                    {
                        OnResume = Resume,
                        Retries  = RestartCount,
                        OnRetry  = Restart,
                        OnQuit   = performUserRequestedExit,
                    },
                    new HotkeyExitOverlay
                    {
                        Action = () =>
                        {
                            if (!this.IsCurrentScreen())
                            {
                                return;
                            }

                            fadeOut(true);
                            PerformExit(true);
                        },
                    },
                    failAnimation = new FailAnimation(DrawableRuleset)
                    {
                        OnComplete = onFailComplete,
                    },
                }
            };

            if (!Configuration.AllowSkippingIntro)
            {
                skipOverlay.Expire();
            }

            if (Configuration.AllowRestart)
            {
                container.Add(new HotkeyRetryOverlay
                {
                    Action = () =>
                    {
                        if (!this.IsCurrentScreen())
                        {
                            return;
                        }

                        fadeOut(true);
                        Restart();
                    },
                });
            }

            return(container);
        }
示例#31
0
 protected virtual void AddHitObject(DrawableHitObject hitObject) => HitObjectContainer.Add(hitObject);
示例#32
0
文件: OsuGame.cs 项目: Xenocidel/osu
        protected override void LoadComplete()
        {
            base.LoadComplete();

            Add(new Drawable[] {
                new VolumeControlReceptor
                {
                    RelativeSizeAxes = Axes.Both,
                    ActionRequested  = delegate(InputState state) { volume.Adjust(state); }
                },
                mainContent = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                },
                volume         = new VolumeControl(),
                overlayContent = new Container {
                    RelativeSizeAxes = Axes.Both
                },
                new GlobalHotkeys //exists because UserInputManager is at a level below us.
                {
                    Handler = globalHotkeyPressed
                }
            });

            (screenStack = new Loader()).LoadAsync(this, d =>
            {
                screenStack.ModePushed += screenAdded;
                screenStack.Exited     += screenRemoved;
                mainContent.Add(screenStack);
            });

            //overlay elements
            (chat = new ChatOverlay {
                Depth = 0
            }).LoadAsync(this, overlayContent.Add);
            (options = new OptionsOverlay {
                Depth = -1
            }).LoadAsync(this, overlayContent.Add);
            (musicController = new MusicController
            {
                Depth = -2,
                Position = new Vector2(0, Toolbar.HEIGHT),
                Anchor = Anchor.TopRight,
                Origin = Anchor.TopRight,
            }).LoadAsync(this, overlayContent.Add);

            (notificationManager = new NotificationManager
            {
                Depth = -2,
                Anchor = Anchor.TopRight,
                Origin = Anchor.TopRight,
            }).LoadAsync(this, overlayContent.Add);

            (dialogOverlay = new DialogOverlay
            {
                Depth = -4,
            }).LoadAsync(this, overlayContent.Add);

            Logger.NewEntry += entry =>
            {
                if (entry.Level < LogLevel.Important)
                {
                    return;
                }

                notificationManager.Post(new SimpleNotification
                {
                    Text = $@"{entry.Level}: {entry.Message}"
                });
            };

            Dependencies.Cache(options);
            Dependencies.Cache(musicController);
            Dependencies.Cache(notificationManager);
            Dependencies.Cache(dialogOverlay);

            (Toolbar = new Toolbar
            {
                Depth = -3,
                OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); },
                OnPlayModeChange = m => PlayMode.Value = m,
            }).LoadAsync(this, t =>
            {
                PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
                PlayMode.TriggerChange();
                overlayContent.Add(Toolbar);
            });

            options.StateChanged += delegate
            {
                switch (options.State)
                {
                case Visibility.Hidden:
                    intro.MoveToX(0, OptionsOverlay.TRANSITION_LENGTH, EasingTypes.OutQuint);
                    break;

                case Visibility.Visible:
                    intro.MoveToX(OptionsOverlay.SIDEBAR_WIDTH / 2, OptionsOverlay.TRANSITION_LENGTH, EasingTypes.OutQuint);
                    break;
                }
            };

            Cursor.State = Visibility.Hidden;
        }
示例#33
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            Add(new Drawable[] {
                new VolumeControlReceptor
                {
                    RelativeSizeAxes = Axes.Both,
                    ActionRequested  = delegate(InputState state) { volume.Adjust(state); }
                },
                mainContent = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                },
                volume         = new VolumeControl(),
                overlayContent = new Container {
                    RelativeSizeAxes = Axes.Both
                },
                new OnScreenDisplay(),
                new GlobalHotkeys //exists because UserInputManager is at a level below us.
                {
                    Handler = globalHotkeyPressed
                }
            });

            LoadComponentAsync(screenStack = new Loader(), d =>
            {
                screenStack.ModePushed += screenAdded;
                screenStack.Exited     += screenRemoved;
                mainContent.Add(screenStack);
            });

            //overlay elements
            LoadComponentAsync(direct = new DirectOverlay {
                Depth = -1
            }, mainContent.Add);
            LoadComponentAsync(social = new SocialOverlay {
                Depth = -1
            }, mainContent.Add);
            LoadComponentAsync(chat = new ChatOverlay {
                Depth = -1
            }, mainContent.Add);
            LoadComponentAsync(settings = new SettingsOverlay {
                Depth = -1
            }, overlayContent.Add);
            LoadComponentAsync(musicController = new MusicController
            {
                Depth    = -2,
                Position = new Vector2(0, Toolbar.HEIGHT),
                Anchor   = Anchor.TopRight,
                Origin   = Anchor.TopRight,
            }, overlayContent.Add);

            LoadComponentAsync(notificationManager = new NotificationManager
            {
                Depth  = -2,
                Anchor = Anchor.TopRight,
                Origin = Anchor.TopRight,
            }, overlayContent.Add);

            LoadComponentAsync(dialogOverlay = new DialogOverlay
            {
                Depth = -4,
            }, overlayContent.Add);

            Logger.NewEntry += entry =>
            {
                if (entry.Level < LogLevel.Important)
                {
                    return;
                }

                notificationManager.Post(new SimpleNotification
                {
                    Text = $@"{entry.Level}: {entry.Message}"
                });
            };

            Dependencies.Cache(settings);
            Dependencies.Cache(social);
            Dependencies.Cache(chat);
            Dependencies.Cache(musicController);
            Dependencies.Cache(notificationManager);
            Dependencies.Cache(dialogOverlay);

            // ensure both overlays aren't presented at the same time
            chat.StateChanged   += (container, state) => social.State = state == Visibility.Visible ? Visibility.Hidden : social.State;
            social.StateChanged += (container, state) => chat.State = state == Visibility.Visible ? Visibility.Hidden : chat.State;

            LoadComponentAsync(Toolbar = new Toolbar
            {
                Depth  = -3,
                OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); },
            }, overlayContent.Add);

            settings.StateChanged += delegate
            {
                switch (settings.State)
                {
                case Visibility.Hidden:
                    intro.MoveToX(0, SettingsOverlay.TRANSITION_LENGTH, EasingTypes.OutQuint);
                    break;

                case Visibility.Visible:
                    intro.MoveToX(SettingsOverlay.SIDEBAR_WIDTH / 2, SettingsOverlay.TRANSITION_LENGTH, EasingTypes.OutQuint);
                    break;
                }
            };

            Cursor.State = Visibility.Hidden;
        }
示例#34
0
        public DrawableSlider(Slider s) : base(s)
        {
            slider = s;

            Children = new Drawable[]
            {
                body = new SliderBody(s)
                {
                    AccentColour = AccentColour,
                    Position     = s.StackedPosition,
                    PathWidth    = s.Scale * 64,
                },
                ticks        = new Container <DrawableSliderTick>(),
                repeatPoints = new Container <DrawableRepeatPoint>(),
                ball         = new SliderBall(s)
                {
                    Scale         = new Vector2(s.Scale),
                    AccentColour  = AccentColour,
                    AlwaysPresent = true,
                    Alpha         = 0
                },
                initialCircle = new DrawableHitCircle(new HitCircle
                {
                    //todo: avoid creating this temporary HitCircle.
                    StartTime   = s.StartTime,
                    Position    = s.StackedPosition,
                    ComboIndex  = s.ComboIndex,
                    Scale       = s.Scale,
                    ComboColour = s.ComboColour,
                    Samples     = s.Samples,
                })
            };

            components.Add(body);
            components.Add(ball);

            AddNested(initialCircle);

            var repeatDuration = s.Curve.Distance / s.Velocity;

            foreach (var tick in s.Ticks)
            {
                var repeatStartTime = s.StartTime + tick.RepeatIndex * repeatDuration;
                var fadeInTime      = repeatStartTime + (tick.StartTime - repeatStartTime) / 2 - (tick.RepeatIndex == 0 ? TIME_FADEIN : TIME_FADEIN / 2);
                var fadeOutTime     = repeatStartTime + repeatDuration;

                var drawableTick = new DrawableSliderTick(tick)
                {
                    FadeInTime  = fadeInTime,
                    FadeOutTime = fadeOutTime,
                    Position    = tick.Position,
                };

                ticks.Add(drawableTick);
                AddNested(drawableTick);
            }

            foreach (var repeatPoint in s.RepeatPoints)
            {
                var repeatStartTime = s.StartTime + repeatPoint.RepeatIndex * repeatDuration;
                var fadeInTime      = repeatStartTime + (repeatPoint.StartTime - repeatStartTime) / 2 - (repeatPoint.RepeatIndex == 0 ? TIME_FADEIN : TIME_FADEIN / 2);
                var fadeOutTime     = repeatStartTime + repeatDuration;

                var drawableRepeatPoint = new DrawableRepeatPoint(repeatPoint, this)
                {
                    FadeInTime  = fadeInTime,
                    FadeOutTime = fadeOutTime,
                    Position    = repeatPoint.Position,
                };

                repeatPoints.Add(drawableRepeatPoint);
                AddNested(drawableRepeatPoint);
            }
        }
示例#35
0
        public DrawableSlider(Slider s)
            : base(s)
        {
            slider = s;

            Children = new Drawable[]
            {
                Body = new SliderBody(s)
                {
                    AccentColour = AccentColour,
                    Position     = s.StackedPosition,
                    PathWidth    = s.Scale * 64,
                },
                ticks        = new Container <DrawableSliderTick>(),
                repeatPoints = new Container <DrawableRepeatPoint>(),
                Ball         = new SliderBall(s)
                {
                    Scale         = new Vector2(s.Scale),
                    AccentColour  = AccentColour,
                    AlwaysPresent = true,
                    Alpha         = 0
                },
                InitialCircle = new DrawableHitCircle(new HitCircle
                {
                    StartTime           = s.StartTime,
                    Position            = s.StackedPosition,
                    IndexInCurrentCombo = s.IndexInCurrentCombo,
                    Scale              = s.Scale,
                    ComboColour        = s.ComboColour,
                    Samples            = s.Samples,
                    SampleControlPoint = s.SampleControlPoint,
                    TimePreempt        = s.TimePreempt,
                    TimeFadein         = s.TimeFadein,
                    HitWindow300       = s.HitWindow300,
                    HitWindow100       = s.HitWindow100,
                    HitWindow50        = s.HitWindow50
                })
            };

            components.Add(Body);
            components.Add(Ball);

            AddNested(InitialCircle);

            foreach (var tick in s.NestedHitObjects.OfType <SliderTick>())
            {
                var spanStartTime = s.StartTime + tick.SpanIndex * s.SpanDuration;
                var fadeInTime    = spanStartTime + (tick.StartTime - spanStartTime) / 2 - (tick.SpanIndex == 0 ? HitObject.TimeFadein : HitObject.TimeFadein / 2);
                var fadeOutTime   = spanStartTime + s.SpanDuration;

                var drawableTick = new DrawableSliderTick(tick)
                {
                    FadeInTime  = fadeInTime,
                    FadeOutTime = fadeOutTime,
                    Position    = tick.Position,
                };

                ticks.Add(drawableTick);
                AddNested(drawableTick);
            }

            foreach (var repeatPoint in s.NestedHitObjects.OfType <RepeatPoint>())
            {
                var drawableRepeatPoint = new DrawableRepeatPoint(repeatPoint, this)
                {
                    Position = repeatPoint.Position
                };

                repeatPoints.Add(drawableRepeatPoint);
                components.Add(drawableRepeatPoint);
                AddNested(drawableRepeatPoint);
            }
        }
示例#36
0
 public void Set(CookieCollection cookies)
 {
     Container.Add(cookies);
 }
示例#37
0
文件: OsuGame.cs 项目: foucard/osu
        protected override void LoadComplete()
        {
            // this needs to be cached before base.LoadComplete as it is used by MenuCursorContainer.
            dependencies.Cache(screenshotManager = new ScreenshotManager());

            base.LoadComplete();

            // The next time this is updated is in UpdateAfterChildren, which occurs too late and results
            // in the cursor being shown for a few frames during the intro.
            // This prevents the cursor from showing until we have a screen with CursorVisible = true
            MenuCursorContainer.CanShowCursor = currentScreen?.CursorVisible ?? false;

            // hook up notifications to components.
            SkinManager.PostNotification    = n => notifications?.Post(n);
            BeatmapManager.PostNotification = n => notifications?.Post(n);

            BeatmapManager.GetStableStorage = GetStorageForStableInstall;
            BeatmapManager.PresentBeatmap   = PresentBeatmap;

            AddRange(new Drawable[]
            {
                new VolumeControlReceptor
                {
                    RelativeSizeAxes      = Axes.Both,
                    ActionRequested       = action => volume.Adjust(action),
                    ScrollActionRequested = (action, amount, isPrecise) => volume.Adjust(action, amount, isPrecise),
                },
                mainContent = new Container {
                    RelativeSizeAxes = Axes.Both
                },
                overlayContent = new Container {
                    RelativeSizeAxes = Axes.Both, Depth = float.MinValue
                },
            });

            loadComponentSingleFile(screenStack = new Loader(), d =>
            {
                screenStack.ModePushed += screenAdded;
                screenStack.Exited     += screenRemoved;
                mainContent.Add(screenStack);
            });

            loadComponentSingleFile(Toolbar = new Toolbar
            {
                Depth  = -5,
                OnHome = delegate
                {
                    CloseAllOverlays(false);
                    intro?.ChildScreen?.MakeCurrent();
                },
            }, overlayContent.Add);

            loadComponentSingleFile(volume          = new VolumeOverlay(), overlayContent.Add);
            loadComponentSingleFile(onscreenDisplay = new OnScreenDisplay(), Add);

            loadComponentSingleFile(screenshotManager, Add);

            //overlay elements
            loadComponentSingleFile(direct = new DirectOverlay {
                Depth = -1
            }, mainContent.Add);
            loadComponentSingleFile(social = new SocialOverlay {
                Depth = -1
            }, mainContent.Add);
            loadComponentSingleFile(chat = new ChatOverlay {
                Depth = -1
            }, mainContent.Add);
            loadComponentSingleFile(settings = new MainSettings
            {
                GetToolbarHeight = () => ToolbarOffset,
                Depth            = -1
            }, overlayContent.Add);
            loadComponentSingleFile(userProfile = new UserProfileOverlay {
                Depth = -2
            }, mainContent.Add);
            loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay {
                Depth = -3
            }, mainContent.Add);
            loadComponentSingleFile(musicController = new MusicController
            {
                Depth    = -4,
                Position = new Vector2(0, Toolbar.HEIGHT),
                Anchor   = Anchor.TopRight,
                Origin   = Anchor.TopRight,
            }, overlayContent.Add);

            loadComponentSingleFile(notifications = new NotificationOverlay
            {
                GetToolbarHeight = () => ToolbarOffset,
                Depth            = -4,
                Anchor           = Anchor.TopRight,
                Origin           = Anchor.TopRight,
            }, overlayContent.Add);

            loadComponentSingleFile(dialogOverlay = new DialogOverlay
            {
                Depth = -6,
            }, overlayContent.Add);

            dependencies.Cache(settings);
            dependencies.Cache(onscreenDisplay);
            dependencies.Cache(social);
            dependencies.Cache(direct);
            dependencies.Cache(chat);
            dependencies.Cache(userProfile);
            dependencies.Cache(musicController);
            dependencies.Cache(beatmapSetOverlay);
            dependencies.Cache(notifications);
            dependencies.Cache(dialogOverlay);

            var singleDisplaySideOverlays = new OverlayContainer[] { settings, notifications };

            overlays.AddRange(singleDisplaySideOverlays);

            foreach (var overlay in singleDisplaySideOverlays)
            {
                overlay.StateChanged += state =>
                {
                    if (state == Visibility.Hidden)
                    {
                        return;
                    }
                    singleDisplaySideOverlays.Where(o => o != overlay).ForEach(o => o.Hide());
                };
            }

            // eventually informational overlays should be displayed in a stack, but for now let's only allow one to stay open at a time.
            var informationalOverlays = new OverlayContainer[] { beatmapSetOverlay, userProfile };

            overlays.AddRange(informationalOverlays);

            foreach (var overlay in informationalOverlays)
            {
                overlay.StateChanged += state =>
                {
                    if (state == Visibility.Hidden)
                    {
                        return;
                    }
                    informationalOverlays.Where(o => o != overlay).ForEach(o => o.Hide());
                };
            }

            // ensure only one of these overlays are open at once.
            var singleDisplayOverlays = new OverlayContainer[] { chat, social, direct };

            overlays.AddRange(singleDisplayOverlays);

            foreach (var overlay in singleDisplayOverlays)
            {
                overlay.StateChanged += state =>
                {
                    // informational overlays should be dismissed on a show or hide of a full overlay.
                    informationalOverlays.ForEach(o => o.Hide());

                    if (state == Visibility.Hidden)
                    {
                        return;
                    }

                    singleDisplayOverlays.Where(o => o != overlay).ForEach(o => o.Hide());
                };
            }

            OverlayActivationMode.ValueChanged += v =>
            {
                if (v != OverlayActivation.All)
                {
                    CloseAllOverlays();
                }
            };

            void updateScreenOffset()
            {
                float offset = 0;

                if (settings.State == Visibility.Visible)
                {
                    offset += ToolbarButton.WIDTH / 2;
                }
                if (notifications.State == Visibility.Visible)
                {
                    offset -= ToolbarButton.WIDTH / 2;
                }

                screenStack.MoveToX(offset, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint);
            }

            settings.StateChanged      += _ => updateScreenOffset();
            notifications.StateChanged += _ => updateScreenOffset();
        }
示例#38
0
 public void Set(string name, string value, string domain, string path = "/")
 {
     Container.Add(new Cookie(name, value, path, domain));
 }
示例#39
0
 /// <summary>
 /// Добавляет Cookie в хранилище <see cref="CookieContainer"/>.
 /// </summary>
 /// <param name="cookie">Кука</param>
 public void Add(Cookie cookie)
 {
     Container.Add(cookie);
 }
示例#40
0
 private void construct()
 {
     mainContainer = new Container(size, new Vector2f(0, 0), reference, "main_container", false);
     mainContainer.Add(new TestView(new Vector2f(), new Vector2f(), reference, "test_view"));
     mainContainer.Add(new Healthbar(new Vector2f(), new Vector2f(), reference, "health_view"));
 }
示例#41
0
	static void RunGui ()
	{
		Container a = new Container (0, 0, Application.Cols, Application.Lines);

		Frame ftorrents = new Frame (0,  0, 0, 0, "Torrents");
		a.Add (ftorrents);

		// Add
		Button badd = new Button (1, 1, "Add");
		badd.Clicked += delegate { AddDialog (); };
		ftorrents.Add (badd);

		// Options
		Button boptions = new Button (9, 1, "Options");
		boptions.Clicked += delegate { OptionsDialog (); };
		ftorrents.Add (boptions);

		// Quit
		Button bquit = new Button (21, 1, "Quit");
		bquit.Clicked += delegate {
			// FIXME: shut down torrent here
			a.Running = false;
		};
		ftorrents.Add (bquit);
		
		// Random widget tests
		//f.Add (new Label (7,  3, "Name:"));
		//f.Add (new Entry (13, 3, 20, "First"));
		
		//f.Add (new Label (4,  5, "Address:"));
		//f.Add (new Entry (13, 5, 20, "Second"));

		ListView ltorrents = new ListView (1, 5, 0, 0, torrent_list);
		ltorrents.Fill = Fill.Horizontal | Fill.Vertical;
		ftorrents.Add (ltorrents);
		
		Frame fprogress = new Frame ("Messages");
		fprogress.Add (log_widget = new LogWidget (0, 0));
		a.Add (fprogress);

		// For testing focus, not ready
		//f.Add (new Label (0, 0, "->0<-"));
		//f.Add (new Entry  (7, 0, 20, "Another"));


		// Details
		Frame fdetails = new Frame ("Details");
		fdetails.Add (new Label (1, 1, "Files for: "));
		torrent_name = new TrimLabel (12, 1, 10, "");
		torrent_name.Fill = Fill.Horizontal;
		fdetails.Add (torrent_name);
			      
		details_list = new TorrentDetailsList ();
		list_details = new ListView (1, 3, 0, 0, details_list);
		list_details.Fill = Fill.Horizontal | Fill.Vertical;
		fdetails.Add (list_details);
		
		a.Add (fdetails);

		// Status
		Frame fstatus = SetupStatus ();
		a.Add (fstatus);

		iteration = new Label (35, 0, "0");
		fstatus.Add (iteration);
		
		Application.Timeout = 1000;

		Application.Iteration += delegate {
			iteration.Text = (it++).ToString ();
			UpdateStatus ();
			lock (queue){
				if (queue.Count > 0){
					foreach (string s in queue){
						log_widget.AddText (s);
					}
					queue.Clear ();
				}
			}
			Application.Refresh ();
		};
		
		LayoutDialogs (ftorrents, fstatus, fdetails, fprogress);
		a.SizeChangedEvent += delegate {
			LayoutDialogs (ftorrents, fstatus, fdetails, fprogress);
		};

		UpdateStatus ();
		Application.Run (a);
	}
示例#42
0
        public override void OnJudgement(DrawableHitObject <OsuHitObject, OsuJudgementInfo> judgedObject)
        {
            HitExplosion explosion = new HitExplosion(judgedObject.Judgement, judgedObject.HitObject);

            judgementLayer.Add(explosion);
        }
示例#43
0
 public Container CreateContainer()
 {
     if (container != null)
         throw new InvalidOperationException();
     container = new Container();
     container.Add(new MyComponent());
     container.Add(this);
     return container;
 }
示例#44
0
        public Stage(int firstColumnIndex, StageDefinition definition, ref ManiaAction normalColumnStartAction, ref ManiaAction specialColumnStartAction)
        {
            this.firstColumnIndex = firstColumnIndex;

            Name = "Stage";

            Anchor           = Anchor.Centre;
            Origin           = Anchor.Centre;
            RelativeSizeAxes = Axes.Y;
            AutoSizeAxes     = Axes.X;

            Container topLevelContainer;

            InternalChildren = new Drawable[]
            {
                judgementPool = new DrawablePool <DrawableManiaJudgement>(2),
                new Container
                {
                    Anchor           = Anchor.TopCentre,
                    Origin           = Anchor.TopCentre,
                    RelativeSizeAxes = Axes.Y,
                    AutoSizeAxes     = Axes.X,
                    Children         = new Drawable[]
                    {
                        new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.StageBackground, stageDefinition: definition), _ => new DefaultStageBackground())
                        {
                            RelativeSizeAxes = Axes.Both
                        },
                        columnFlow = new ColumnFlow <Column>(definition)
                        {
                            RelativeSizeAxes = Axes.Y,
                        },
                        new Container
                        {
                            Name               = "Barlines mask",
                            Anchor             = Anchor.TopCentre,
                            Origin             = Anchor.TopCentre,
                            RelativeSizeAxes   = Axes.Y,
                            Width              = 1366, // Bar lines should only be masked on the vertical axis
                            BypassAutoSizeAxes = Axes.Both,
                            Masking            = true,
                            Child              = barLineContainer = new HitObjectArea(HitObjectContainer)
                            {
                                Name             = "Bar lines",
                                Anchor           = Anchor.TopCentre,
                                Origin           = Anchor.TopCentre,
                                RelativeSizeAxes = Axes.Y,
                            }
                        },
                        new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.StageForeground, stageDefinition: definition), _ => null)
                        {
                            RelativeSizeAxes = Axes.Both
                        },
                        judgements = new JudgementContainer <DrawableManiaJudgement>
                        {
                            Anchor           = Anchor.TopCentre,
                            Origin           = Anchor.Centre,
                            RelativeSizeAxes = Axes.Both,
                            Y = HIT_TARGET_POSITION + 150,
                        },
                        topLevelContainer = new Container {
                            RelativeSizeAxes = Axes.Both
                        }
                    }
                }
            };

            for (int i = 0; i < definition.Columns; i++)
            {
                var columnType = definition.GetTypeOfColumn(i);

                var column = new Column(firstColumnIndex + i)
                {
                    RelativeSizeAxes = Axes.Both,
                    Width            = 1,
                    ColumnType       = columnType,
                    AccentColour     = columnColours[columnType],
                    Action           = { Value = columnType == ColumnType.Special ? specialColumnStartAction++ : normalColumnStartAction++ }
                };

                topLevelContainer.Add(column.TopLevelContainer.CreateProxy());
                columnFlow.SetContentForColumn(i, column);
                AddNested(column);
            }
        }
示例#45
0
 /// <summary>
 /// 根据类型注册
 /// </summary>
 /// <param name="controller_instance_type">控制器类型</param>
 /// <returns></returns>
 public IActorBuilder RegisterService(Type controller_instance_type)
 {
     Container.Add(ServiceDescriptor.Scoped(typeof(ActorController), controller_instance_type));
     return(this);
 }
示例#46
0
 /* ----------------------------------------------------------------- */
 ///
 /// ExtractImageFiles
 /// 
 /// <summary>
 /// 指定されたパスから対象となる画像ファイルのパスを抽出する.
 /// src がフォルダの場合は,再帰的に展開する.
 /// </summary>
 /// 
 /* ----------------------------------------------------------------- */
 private void ExtractImageFiles(string src, Container.List<string> dest)
 {
     if (System.IO.Directory.Exists(src)) {
         var dir = new System.IO.DirectoryInfo(src);
         foreach (var item in dir.GetFileSystemInfos()) {
             this.ExtractImageFiles(item.FullName, dest);
         }
     }
     else {
         var ext = System.IO.Path.GetExtension(src).ToLower();
         if (ext == ".bmp" || ext == ".jpg" || ext == ".jpeg" || ext == ".png" || ext == ".gif") dest.Add(src);
     }
 }