//-------------------------------------------------------------------------------------
 // Class constructors
 public SpriteObject(GameHost game)
     : base(game)
 {
     // Set the default scale and color
     ScaleX = 1;
     ScaleY = 1;
     SpriteColor = Color.White;
 }
        //-------------------------------------------------------------------------------------
        // Class constructors
        public MonoLog(GameHost game)
            : base(game)
        {
            // Set the default scale and color
            ScaleX = 1;
            ScaleY = 1;
            SpriteColor = Color.White;

            Speed = 0.8f;
        }
 public Worm(GameHost game)
     : base(game)
 {
     SourceRect = new Rectangle(184,0,138,60);
 }
 public SpriteObject(GameHost game, Vector2 position, Texture2D texture)
     : this(game, position)
 {
     // Store the provided texture
     SpriteTexture = texture;
 }
Example #5
0
        public override bool Initialize(GameHost host)
        {
            base.Initialize(host);

            // Get the bindables we need to determine whether to confine the mouse to window or not
            if (host.Window is DesktopGameWindow desktopWindow)
            {
                confineMode.BindTo(desktopWindow.ConfineMouseMode);
                windowMode.BindTo(desktopWindow.WindowMode);
                mapAbsoluteInputToWindow.BindTo(desktopWindow.MapAbsoluteInputToWindow);
            }

            Enabled.BindValueChanged(enabled =>
            {
                if (enabled)
                {
                    host.InputThread.Scheduler.Add(scheduled = new ScheduledDelegate(delegate
                    {
                        if (!host.Window.Visible || host.Window.WindowState == WindowState.Minimized)
                        {
                            return;
                        }

                        if ((MouseInWindow || lastEachDeviceStates.Any(s => s != null && s.Buttons.HasAnyButtonPressed)) && host.Window.Focused)
                        {
                            osuTK.Input.Mouse.GetStates(newRawStates);

                            while (lastEachDeviceStates.Count < newRawStates.Count)
                            {
                                lastEachDeviceStates.Add(null);
                            }

                            for (int i = 0; i < newRawStates.Count; i++)
                            {
                                if (newRawStates[i].IsConnected != true)
                                {
                                    lastEachDeviceStates[i] = null;
                                    continue;
                                }

                                var rawState  = newRawStates[i];
                                var lastState = lastEachDeviceStates[i];

                                if (lastState != null && rawState.Equals(lastState.RawState))
                                {
                                    continue;
                                }

                                var newState = new OsuTKPollMouseState(rawState, host.IsActive, getUpdatedPosition(rawState, lastState));

                                HandleState(newState, lastState, rawState.Flags.HasFlag(MouseStateFlags.MoveAbsolute));

                                lastEachDeviceStates[i] = newState;
                                lastUnfocusedState      = null;
                            }
                        }
                        else
                        {
                            var state       = osuTK.Input.Mouse.GetCursorState();
                            var screenPoint = host.Window.PointToClient(new Point(state.X, state.Y));

                            var newState = new UnfocusedMouseState(new MouseState(), host.IsActive, new Vector2(screenPoint.X, screenPoint.Y));

                            HandleState(newState, lastUnfocusedState, true);

                            lastUnfocusedState = newState;
                            lastEachDeviceStates.Clear();
                        }
                    }, 0, 0));
                }
                else
                {
                    scheduled?.Cancel();
                    lastEachDeviceStates.Clear();
                    lastUnfocusedState = null;
                }
            }, true);

            return(true);
        }
Example #6
0
        private void load(Storage storage, GameHost host, FrameworkConfigManager frameworkConfig)
        {
            interactive = host.Window != null;
            config      = new TestBrowserConfig(storage);

            exit = host.Exit;

            showLogOverlay = frameworkConfig.GetBindable <bool>(FrameworkSetting.ShowLogOverlay);

            rateBindable = new BindableDouble(1)
            {
                MinValue = 0,
                MaxValue = 2,
            };

            var rateAdjustClock = new StopwatchClock(true);
            var framedClock     = new FramedClock(rateAdjustClock);

            Children = new Drawable[]
            {
                leftContainer = new Container
                {
                    RelativeSizeAxes = Axes.Y,
                    Size             = new Vector2(test_list_width, 1),
                    Children         = new Drawable[]
                    {
                        new Box
                        {
                            Colour           = Color4.DimGray,
                            RelativeSizeAxes = Axes.Both
                        },
                        new FillFlowContainer
                        {
                            Direction        = FillDirection.Vertical,
                            RelativeSizeAxes = Axes.Both,
                            Children         = new Drawable[]
                            {
                                searchTextBox = new TextBox
                                {
                                    OnCommit = delegate
                                    {
                                        var firstVisible = leftFlowContainer.FirstOrDefault(b => b.IsPresent);
                                        if (firstVisible != null)
                                        {
                                            LoadTest(firstVisible.TestType);
                                        }
                                    },
                                    Height           = 20,
                                    RelativeSizeAxes = Axes.X,
                                    PlaceholderText  = "type to search"
                                },
                                new ScrollContainer
                                {
                                    Padding = new MarginPadding {
                                        Top = 3, Bottom = 20
                                    },
                                    RelativeSizeAxes         = Axes.Both,
                                    ScrollbarOverlapsContent = false,
                                    Child = leftFlowContainer = new SearchContainer <TestCaseButton>
                                    {
                                        Padding          = new MarginPadding(3),
                                        Direction        = FillDirection.Vertical,
                                        Spacing          = new Vector2(0, 5),
                                        AutoSizeAxes     = Axes.Y,
                                        RelativeSizeAxes = Axes.X,
                                    }
                                }
                            }
                        }
                    }
                },
                mainContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding {
                        Left = test_list_width
                    },
                    Children = new Drawable[]
                    {
                        toolbar = new Toolbar
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = 50,
                            Depth            = -1,
                        },
                        testContentContainer = new Container
                        {
                            Clock            = framedClock,
                            RelativeSizeAxes = Axes.Both,
                            Padding          = new MarginPadding {
                                Top = 50
                            },
                            Child = compilingNotice = new Container
                            {
                                Alpha        = 0,
                                Anchor       = Anchor.Centre,
                                Origin       = Anchor.Centre,
                                Masking      = true,
                                Depth        = float.MinValue,
                                CornerRadius = 5,
                                AutoSizeAxes = Axes.Both,
                                Children     = new Drawable[]
                                {
                                    new Box
                                    {
                                        RelativeSizeAxes = Axes.Both,
                                        Colour           = Color4.Black,
                                    },
                                    new SpriteText
                                    {
                                        TextSize = 30,
                                        Text     = @"Compiling new version..."
                                    }
                                },
                            }
                        }
                    }
                }
            };

            searchTextBox.Current.ValueChanged += newValue => leftFlowContainer.SearchTerm = newValue;

            backgroundCompiler = new DynamicClassCompiler <TestCase>
            {
                CompilationStarted  = compileStarted,
                CompilationFinished = compileFinished,
                CompilationFailed   = compileFailed
            };
            try
            {
                backgroundCompiler.Start();
            }
            catch
            {
                //it's okay for this to fail for now.
            }

            foreach (Assembly asm in assemblies)
            {
                toolbar.AssemblyDropdown.AddDropdownItem(asm.GetName().Name, asm);
            }

            toolbar.AssemblyDropdown.Current.ValueChanged += updateList;
            toolbar.RunAllSteps.Current.ValueChanged      += v => runTests(null);
            toolbar.RateAdjustSlider.Current.BindTo(rateBindable);

            rateBindable.ValueChanged += v => rateAdjustClock.Rate = v;
            rateBindable.TriggerChange();
        }
Example #7
0
 public WindowsStorage(string baseName, GameHost host)
     : base(baseName, host)
 {
     // allows traversal of long directory/filenames beyond the standard limitations (see https://stackoverflow.com/a/5188559)
     BasePath = Regex.Replace(BasePath, @"^([a-zA-Z]):\\", @"\\?\$1:\");
 }
Example #8
0
 public GameObjectBase(GameHost game)
 {
     this.Game = game;
 }
 public Grass(GameHost game, Vector2 position)
     : base(game, position)
 {
 }
 public Grass(GameHost game)
     : base(game)
 {
     SetRandomPosition();
     setRandomGrassSprite();
 }
 public MonoLog(GameHost game, SpriteFont font, Color fontColor)
     : this(game, font)
 {
     FontColor = fontColor;
 }
 public MonoLog(GameHost game, SpriteFont font)
     : this(game)
 {
     Font = font;
     LineSpacing = Font.LineSpacing;
 }
Example #13
0
 public GameObjectBase(GameHost game)
 {
     this.Game = game;
 }
 public EnvironmentGraphics(GameHost game, Vector2 position, Texture2D texture)
     : this(game, position)
 {
     // Store the provided texture
     SpriteTexture = texture;
 }
 public Worm(GameHost game, Vector2 position, Texture2D texture)
     : base(game, position, texture)
 {
 }
Example #16
0
 public VCheckPosition(GameHost host)
     : base(host)
 {
     _info = new Dictionary<long, ValidationInfo>();
 }
 public EnvironmentGraphics(GameHost game, Vector2 position)
     : this(game)
 {
     // Store the provided position
     Position = position;
 }
 private void load(GameHost host, AudioManager audio)
 {
     Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
     Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, Beatmap.Default));
     beatmaps.Import(TestResources.GetTestBeatmapForImport(true)).Wait();
 }
Example #19
0
 public static void Main()
 {
     using (GameHost host = Host.GetSuitableHost(@"MusicVisualizer"))
         using (osu.Framework.Game game = new MusicVisualizerGame())
             host.Run(game);
 }
Example #20
0
 private void load(GameHost host, AudioManager audio)
 {
     Dependencies.Cache(rulesets = new RealmRulesetStore(Realm));
     Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, Realm, rulesets, API, audio, Resources, host, Beatmap.Default));
     Dependencies.Cache(Realm);
 }
Example #21
0
 protected override Storage CreateStorage(GameHost host, Storage defaultStorage) => new OsuStorage(host, defaultStorage);
Example #22
0
 public TestBeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore <byte[]> resources, GameHost host, WorkingBeatmap defaultBeatmap, WorkingBeatmap testBeatmap)
     : base(storage, contextFactory, rulesets, api, audioManager, resources, host, defaultBeatmap)
 {
     this.testBeatmap = testBeatmap;
 }
 public DatabaseContextFactory(GameHost host)
 {
     this.host = host;
 }
Example #24
0
 protected override BeatmapModelManager CreateBeatmapModelManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, GameHost host)
 {
     return(new TestBeatmapModelManager(storage, contextFactory, rulesets, api, host));
 }
Example #25
0
 protected BaseValidator(GameHost host)
 {
     Host = host;
 }
Example #26
0
 protected override WorkingBeatmapCache CreateWorkingBeatmapCache(AudioManager audioManager, IResourceStore <byte[]> resources, IResourceStore <byte[]> storage, WorkingBeatmap defaultBeatmap, GameHost host)
 {
     return(new TestWorkingBeatmapCache(this, audioManager, resources, storage, defaultBeatmap, host));
 }
 public SpriteObject(GameHost game, Vector2 position)
     : this(game)
 {
     // Store the provided position
     Position = position;
 }
Example #28
0
 public TestWorkingBeatmapCache(TestBeatmapManager testBeatmapManager, AudioManager audioManager, IResourceStore <byte[]> resourceStore, IResourceStore <byte[]> storage, WorkingBeatmap defaultBeatmap, GameHost gameHost)
     : base(audioManager, resourceStore, storage, defaultBeatmap, gameHost)
 {
     this.testBeatmapManager = testBeatmapManager;
 }
 //-------------------------------------------------------------------------------------
 // Class constructors
 /// <summary>
 /// Constructor for the object
 /// </summary>
 /// <param name="game">A reference to the MonoGame Game class inside which the object resides</param>
 public GameObjectBase(GameHost game)
 {
     // Store a reference to the game
     Game = game;
 }
Example #30
0
 public TestBeatmapModelManager(Storage storage, IDatabaseContextFactory databaseContextFactory, RulesetStore rulesetStore, IAPIProvider apiProvider, GameHost gameHost)
     : base(storage, databaseContextFactory, rulesetStore, gameHost)
 {
 }
 public Worm(GameHost game, Vector2 position)
     : base(game, position)
 {
 }
Example #32
0
        private void load(OsuColour colours, GameHost host)
        {
            beatDivisor.Value = Beatmap.Value.BeatmapInfo.BeatDivisor;
            beatDivisor.BindValueChanged(divisor => Beatmap.Value.BeatmapInfo.BeatDivisor = divisor.NewValue);

            // Todo: should probably be done at a DrawableRuleset level to share logic with Player.
            var sourceClock = (IAdjustableClock)Beatmap.Value.Track ?? new StopwatchClock();

            clock = new EditorClock(Beatmap.Value, beatDivisor)
            {
                IsCoupled = false
            };
            clock.ChangeSource(sourceClock);

            dependencies.CacheAs <IFrameBasedClock>(clock);
            dependencies.CacheAs <IAdjustableClock>(clock);

            // todo: remove caching of this and consume via editorBeatmap?
            dependencies.Cache(beatDivisor);

            try
            {
                playableBeatmap = Beatmap.Value.GetPlayableBeatmap(Beatmap.Value.BeatmapInfo.Ruleset);
            }
            catch (Exception e)
            {
                Logger.Error(e, "Could not load beatmap successfully!");
                // couldn't load, hard abort!
                this.Exit();
                return;
            }

            AddInternal(editorBeatmap = new EditorBeatmap(playableBeatmap));
            dependencies.CacheAs(editorBeatmap);

            changeHandler = new EditorChangeHandler(editorBeatmap);
            dependencies.CacheAs <IEditorChangeHandler>(changeHandler);

            EditorMenuBar menuBar;
            OsuMenuItem   undoMenuItem;
            OsuMenuItem   redoMenuItem;

            var fileMenuItems = new List <MenuItem>
            {
                new EditorMenuItem("Save", MenuItemType.Standard, saveBeatmap)
            };

            if (RuntimeInfo.IsDesktop)
            {
                fileMenuItems.Add(new EditorMenuItem("Export package", MenuItemType.Standard, exportBeatmap));
            }

            fileMenuItems.Add(new EditorMenuItemSpacer());
            fileMenuItems.Add(new EditorMenuItem("Exit", MenuItemType.Standard, this.Exit));

            AddInternal(new OsuContextMenuContainer
            {
                RelativeSizeAxes = Axes.Both,
                Children         = new[]
                {
                    new Container
                    {
                        Name             = "Screen container",
                        RelativeSizeAxes = Axes.Both,
                        Padding          = new MarginPadding {
                            Top = 40, Bottom = 60
                        },
                        Child = screenContainer = new Container
                        {
                            RelativeSizeAxes = Axes.Both,
                            Masking          = true
                        }
                    },
                    new Container
                    {
                        Name             = "Top bar",
                        RelativeSizeAxes = Axes.X,
                        Height           = 40,
                        Child            = menuBar = new EditorMenuBar
                        {
                            Anchor           = Anchor.CentreLeft,
                            Origin           = Anchor.CentreLeft,
                            RelativeSizeAxes = Axes.Both,
                            Items            = new[]
                            {
                                new MenuItem("File")
                                {
                                    Items = fileMenuItems
                                },
                                new MenuItem("Edit")
                                {
                                    Items = new[]
                                    {
                                        undoMenuItem = new EditorMenuItem("Undo", MenuItemType.Standard, Undo),
                                        redoMenuItem = new EditorMenuItem("Redo", MenuItemType.Standard, Redo)
                                    }
                                }
                            }
                        }
                    },
                    new Container
                    {
                        Name             = "Bottom bar",
                        Anchor           = Anchor.BottomLeft,
                        Origin           = Anchor.BottomLeft,
                        RelativeSizeAxes = Axes.X,
                        Height           = 60,
                        Children         = new Drawable[]
                        {
                            bottomBackground = new Box {
                                RelativeSizeAxes = Axes.Both
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Padding          = new MarginPadding {
                                    Vertical = 5, Horizontal = 10
                                },
                                Child = new GridContainer
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    ColumnDimensions = new[]
                                    {
                                        new Dimension(GridSizeMode.Absolute, 220),
                                        new Dimension(),
                                        new Dimension(GridSizeMode.Absolute, 220)
                                    },
                                    Content = new[]
                                    {
                                        new Drawable[]
                                        {
                                            new Container
                                            {
                                                RelativeSizeAxes = Axes.Both,
                                                Padding          = new MarginPadding {
                                                    Right = 10
                                                },
                                                Child = new TimeInfoContainer {
                                                    RelativeSizeAxes = Axes.Both
                                                },
                                            },
                                            new SummaryTimeline
                                            {
                                                RelativeSizeAxes = Axes.Both,
                                            },
                                            new Container
                                            {
                                                RelativeSizeAxes = Axes.Both,
                                                Padding          = new MarginPadding {
                                                    Left = 10
                                                },
                                                Child = new PlaybackControl {
                                                    RelativeSizeAxes = Axes.Both
                                                },
                                            }
                                        },
                                    }
                                },
                            }
                        }
                    },
                }
            });

            changeHandler.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true);
            changeHandler.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true);

            menuBar.Mode.ValueChanged += onModeChanged;

            bottomBackground.Colour = colours.Gray2;
        }
 //-------------------------------------------------------------------------------------
 // Class constructors
 public BenchmarkObject(GameHost game, SpriteFont font, Vector2 position, Color textColor)
     : base(game, font, position)
 {
     SpriteColor = textColor;
 }
 //-------------------------------------------------------------------------------------
 // Class constructors
 public EnvironmentGraphics(GameHost game)
     : base(game)
 {
     SpriteColor = Color.White;
 }