Ejemplo n.º 1
0
        public TextureMap GenerateFakeTileMap(Room room, Vector2 offset, int width, int height, short tileset, bool edgesExtend = false)
        {
            TileGrid grid = new TileGrid(width, height)
            {
                DefaultValue = tileset
            };

            grid.Fill(tileset);

            TextureMap   map = GenerateTextureMap(grid, edgesExtend);
            DrawableRoom dr  = MapEditor.Instance.Renderer.GetRoom(room);

            if (!Menubar.View_OBTiles)
            {
                return(map);
            }

            // Object tiles
            Rectangle mapBounds = new Rectangle((int)offset.X / 8, (int)offset.Y / 8, width, height);

            foreach (StaticTexture t in dr.OBTiles)
            {
                if (mapBounds.Contains(new Point((int)t.Position.X / 8, (int)t.Position.Y / 8)))
                {
                    map.Textures[(int)t.Position.X / 8 - (int)offset.X / 8 + (width * ((int)t.Position.Y / 8 - (int)offset.Y / 8))].Visible = false;
                }
            }

            return(map);
        }
Ejemplo n.º 2
0
        private void didSelect(DrawableRoom room)
        {
            RoomsContainer.Children.ForEach(c =>
            {
                if (c != room)
                {
                    c.State = SelectionState.NotSelected;
                }
            });

            Inspector.Room = room.Room;

            // open the room if its selected and is clicked again
            if (room.State == SelectionState.Selected)
            {
                Push(new Match());
            }
        }
Ejemplo n.º 3
0
        public void TestEnableAndDisablePassword()
        {
            DrawableRoom drawableRoom = null;
            Room         room         = null;

            AddStep("create room", () => Child = drawableRoom = createDrawableRoom(room = new Room
            {
                Name   = { Value = "Room with password" },
                Status = { Value = new RoomStatusOpen() },
                Type   = { Value = MatchType.HeadToHead },
            }));

            AddAssert("password icon hidden", () => Precision.AlmostEquals(0, drawableRoom.ChildrenOfType <DrawableRoom.PasswordProtectedIcon>().Single().Alpha));

            AddStep("set password", () => room.Password.Value = "password");
            AddAssert("password icon visible", () => Precision.AlmostEquals(1, drawableRoom.ChildrenOfType <DrawableRoom.PasswordProtectedIcon>().Single().Alpha));

            AddStep("unset password", () => room.Password.Value = string.Empty);
            AddAssert("password icon hidden", () => Precision.AlmostEquals(0, drawableRoom.ChildrenOfType <DrawableRoom.PasswordProtectedIcon>().Single().Alpha));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Updates the given area of tiles in the given room.
        /// </summary>
        /// <param name="room">The room to update the tiles in.</param>
        /// <param name="fg">Whether the foreground or background layer should be updated.</param>
        /// <param name="r">The rectangular area within which tiles should be updated.</param>
        public void Update(DrawableRoom room, bool fg, Rectangle r)
        {
            TileGrid   grid = fg ? room.Room.ForegroundTiles : room.Room.BackgroundTiles;
            TextureMap map  = fg ? room.FGTiles : room.BGTiles;

            Rectangle rect = new Rectangle(r.X - 2, r.Y - 2, r.Width + 4, r.Height + 4);

            for (int y = 0; y < rect.Height; y++)
            {
                int yInc = (y + rect.Y) * grid.Width;
                for (int x = 0; x < rect.Width; x++)
                {
                    if (x + rect.X < 0 || x + rect.X > grid.Width - 1 || y + rect.Y < 0 || y + rect.Y > grid.Height - 1)
                    {
                        continue;
                    }

                    map.Textures[x + rect.X + yInc] = GenerateTileTexture(grid, x + rect.X, y + rect.Y, true, yInc);
                }
            }
        }
Ejemplo n.º 5
0
        public static void SaveRoomImage()
        {
            if (!Engine.MapLoaded || MapEditor.Instance == null)
            {
                return;
            }

            if (NfdResult.OKAY == NFD.SaveDialog("png", Settings.CelesteDirectory, out string pngPath))
            {
                if (!File.Exists(pngPath))
                {
                    using (FileStream stream = File.Create(pngPath + ".png")) {
                        stream.Close();
                    }
                }

                using (FileStream stream = File.Open(pngPath, FileMode.Truncate)) {
                    DrawableRoom dr = MapEditor.Instance.Renderer.SelectedRoom;

                    dr.Target.SaveAsPng(stream, dr.Room.Width, dr.Room.Height);
                }
            }
        }
Ejemplo n.º 6
0
        private DrawableRoom createDrawableRoom(Room room)
        {
            room.Host.Value ??= new User {
                Username = "******", Id = 2
            };

            if (room.RecentParticipants.Count == 0)
            {
                room.RecentParticipants.AddRange(Enumerable.Range(0, 20).Select(i => new User
                {
                    Id       = i,
                    Username = $"User {i}"
                }));
            }

            var drawableRoom = new DrawableRoom(room)
            {
                MatchingFilter = true
            };

            drawableRoom.Action = () => drawableRoom.State = drawableRoom.State == SelectionState.Selected ? SelectionState.NotSelected : SelectionState.Selected;

            return(drawableRoom);
        }
Ejemplo n.º 7
0
        private void load(AudioManager audio)
        {
            DrawableRoom = new DrawableRoom(room, false, false, true, true, false, false);
            dependencies.Cache(DrawableRoom);

            Size   = new Vector2(room.SizeX, room.SizeY) * DrawableTile.SIZE;
            Anchor = Anchor.Centre;
            Origin = Anchor.Centre;

            InternalChildren = new Drawable[]
            {
                DrawableRoom,
                CreateLayerBehindPlayer(),
                Player = new DefaultPlayer
                {
                    Died      = onDeath,
                    Completed = onCompletion,
                    Saved     = onSave,
                },
                new WaterRenderer(room),
                deathOverlay = new PlayerParticlesContainer(),
                roomEntering = new DrawableSample(audio.Samples.Get("room-entering"))
            };
        }
Ejemplo n.º 8
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            DrawableRoom first;

            Add(new FillFlowContainer
            {
                Anchor       = Anchor.Centre,
                Origin       = Anchor.Centre,
                AutoSizeAxes = Axes.Y,
                Width        = 580f,
                Direction    = FillDirection.Vertical,
                Children     = new Drawable[]
                {
                    first = new DrawableRoom(new Room
                    {
                        Name = { Value = @"Great Room Right Here" },
                        Host = { Value            = new User    {
                                     Username     = @"Naeferith", Id = 9492835, Country = new Country{
                                         FlagName = @"FR"
                                     }
                                 } },
                        Status  = { Value = new RoomStatusOpen() },
                        Type    = { Value = new GameTypeTeamVersus() },
                        Beatmap =
                        {
                            Value                 = new BeatmapInfo
                            {
                                StarDifficulty =                                                                  4.65,
                                Ruleset        = rulesets.GetRuleset(3),
                                Metadata       = new BeatmapMetadata
                                {
                                    Title  = @"Critical Crystal",
                                    Artist = @"Seiryu",
                                },
                                BeatmapSet        = new BeatmapSetInfo
                                {
                                    OnlineInfo    = new BeatmapSetOnlineInfo
                                    {
                                        Covers    = new BeatmapSetOnlineCovers
                                        {
                                            Cover = @"https://assets.ppy.sh//beatmaps/376340/covers/cover.jpg?1456478455",
                                        },
                                    },
                                },
                            },
                        },
                        Participants =
                        {
                            Value                  = new[]
                            {
                                new User {
                                    Statistics     = new UserStatistics           {
                                        Ranks      = new UserStatistics.UserRanks {
                                            Global =     1355
                                        }
                                    }
                                },
                                new User {
                                    Statistics     = new UserStatistics           {
                                        Ranks      = new UserStatistics.UserRanks {
                                            Global = 8756
                                        }
                                    }
                                },
                            },
                        },
                    }),
                    new DrawableRoom(new Room
                    {
                        Name = { Value = @"Relax It's The Weekend" },
                        Host = { Value            = new User    {
                                     Username     = @"peppy", Id = 2, Country = new Country{
                                         FlagName = @"AU"
                                     }
                                 } },
                        Status  = { Value = new RoomStatusPlaying() },
                        Type    = { Value = new GameTypeTagTeam() },
                        Beatmap =
                        {
                            Value                 = new BeatmapInfo
                            {
                                StarDifficulty =                                                                  1.96,
                                Ruleset        = rulesets.GetRuleset(0),
                                Metadata       = new BeatmapMetadata
                                {
                                    Title  = @"Serendipity",
                                    Artist = @"ZAQ",
                                },
                                BeatmapSet        = new BeatmapSetInfo
                                {
                                    OnlineInfo    = new BeatmapSetOnlineInfo
                                    {
                                        Covers    = new BeatmapSetOnlineCovers
                                        {
                                            Cover = @"https://assets.ppy.sh//beatmaps/526839/covers/cover.jpg?1493815706",
                                        },
                                    },
                                },
                            },
                        },
                        Participants =
                        {
                            Value                  = new[]
                            {
                                new User {
                                    Statistics     = new UserStatistics           {
                                        Ranks      = new UserStatistics.UserRanks {
                                            Global =     578975
                                        }
                                    }
                                },
                                new User {
                                    Statistics     = new UserStatistics           {
                                        Ranks      = new UserStatistics.UserRanks {
                                            Global = 24554
                                        }
                                    }
                                },
                            },
                        },
                    }),
                }
            });

            AddStep(@"change title", () => first.Room.Name.Value = @"I Changed Name");
            AddStep(@"change host", () => first.Room.Host.Value  = new User {
                Username = @"DrabWeb", Id = 6946022, Country = new Country {
                    FlagName = @"CA"
                }
            });
            AddStep(@"change status", () => first.Room.Status.Value             = new RoomStatusPlaying());
            AddStep(@"change type", () => first.Room.Type.Value                 = new GameTypeVersus());
            AddStep(@"change beatmap", () => first.Room.Beatmap.Value           = null);
            AddStep(@"change participants", () => first.Room.Participants.Value = new[]
            {
                new User {
                    Statistics = new UserStatistics {
                        Ranks = new UserStatistics.UserRanks {
                            Global = 1254
                        }
                    }
                },
                new User {
                    Statistics = new UserStatistics {
                        Ranks = new UserStatistics.UserRanks {
                            Global = 123189
                        }
                    }
                },
            });
        }
 private bool checkRoomVisible(DrawableRoom room) =>
 loungeScreen.ChildrenOfType <OsuScrollContainer>().First().ScreenSpaceDrawQuad
 .Contains(room.ScreenSpaceDrawQuad.Centre);
Ejemplo n.º 10
0
 /// <summary>
 /// Updates the given tile in the given room.
 /// </summary>
 /// <param name="room">The room to update the tile in.</param>
 /// <param name="fg">Whether the foreground or background layer should be updated.</param>
 /// <param name="point">The tile location to update.</param>
 public void Update(DrawableRoom room, bool fg, Point point)
 {
     Update(room, fg, new Rectangle(point.X, point.Y, 1, 1));
 }
Ejemplo n.º 11
0
 public EditorAction(Room room)
 {
     Room         = room;
     DrawableRoom = MapEditor.Instance.Renderer.GetRoom(room);
 }
Ejemplo n.º 12
0
 public void SelectRoom(DrawableRoom room, bool moveCamera = false)
 {
     SelectRoom(Renderer.Rooms.IndexOf(room), moveCamera);
 }