Example #1
0
        private void load(LadderInfo ladder, Storage storage)
        {
            RelativeSizeAxes = Axes.Both;

            InternalChildren = new Drawable[]
            {
                blueWinVideo = new TourneyVideo(storage.GetStream(@"BG Team - Win Blue.m4v"))
                {
                    Alpha            = 1,
                    RelativeSizeAxes = Axes.Both,
                    Loop             = true,
                },
                redWinVideo = new TourneyVideo(storage.GetStream(@"BG Team - Win Red.m4v"))
                {
                    Alpha            = 0,
                    RelativeSizeAxes = Axes.Both,
                    Loop             = true,
                },
                new TournamentLogo(false)
                {
                    Y = 40,
                },
                mainContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                }
            };

            currentMatch.BindValueChanged(matchChanged);
            currentMatch.BindTo(ladder.CurrentMatch);

            currentCompleted.BindValueChanged(_ => update());
        }
Example #2
0
        private void load(LadderInfo ladder, Storage storage)
        {
            RelativeSizeAxes = Axes.Both;

            InternalChildren = new Drawable[]
            {
                blueWinVideo = new TourneyVideo("teamwin-blue")
                {
                    Alpha            = 1,
                    RelativeSizeAxes = Axes.Both,
                    Loop             = true,
                },
                redWinVideo = new TourneyVideo("teamwin-red")
                {
                    Alpha            = 0,
                    RelativeSizeAxes = Axes.Both,
                    Loop             = true,
                },
                mainContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                }
            };

            currentCompleted.BindValueChanged(_ => update());
        }
    public virtual void setLadderData(LadderInfo ladderInfo)
    {
        // rotate by init angle
        initAngle = ladderInfo.initAngle;
        transform.Rotate(0, 0, -initAngle);
        initPosition = ladderInfo.initPosition.GetV3();
        type         = ladderInfo.type;
        timeout      = ladderInfo.timeout;

        if (ladderInfo.movement == null || ladderInfo.movement.speed <= 0)
        {
            GetComponent <LadderMovement>().enabled = false;
        }
        else
        {
            GetComponent <LadderMovement>().enabled = true;
            GetComponent <LadderMovement>().SetMovementData(ladderInfo.movement);
        }

        if (ladderInfo.rotate == null || ladderInfo.rotate.speed <= 0)
        {
            GetComponent <LadderRotate>().enabled = false;
        }
        else
        {
            GetComponent <LadderRotate>().enabled = true;
            GetComponent <LadderRotate>().SetRotateData(ladderInfo.rotate);
        }
    }
Example #4
0
        private void load(TextureStore textures, LadderInfo ladderInfo)
        {
            var customTexture = textures.Get($"mods/{modAcronym}");

            if (customTexture != null)
            {
                AddInternal(new Sprite
                {
                    FillMode         = FillMode.Fit,
                    RelativeSizeAxes = Axes.Both,
                    Anchor           = Anchor.CentreRight,
                    Origin           = Anchor.CentreRight,
                    Texture          = customTexture
                });

                return;
            }

            var ruleset = rulesets.GetRuleset(ladderInfo.Ruleset.Value?.ID ?? 0);
            var modIcon = ruleset?.CreateInstance().GetAllMods().FirstOrDefault(mod => mod.Acronym == modAcronym);

            if (modIcon == null)
            {
                return;
            }

            AddInternal(new ModIcon(modIcon, false)
            {
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
                Scale  = new Vector2(0.5f)
            });
        }
Example #5
0
        private void load(LadderInfo ladder, MatchIPCInfo ipc)
        {
            score1.BindValueChanged(_ => updateScores());
            score1.BindTo(ipc.Score1);

            score2.BindValueChanged(_ => updateScores());
            score2.BindTo(ipc.Score2);
        }
Example #6
0
 private void load(LadderInfo info)
 {
     // if (info.CurrentMatch.Value.Team1.Value.Players.Any(u => u.Id == Message.Sender.Id))
     //     SenderText.Colour = TournamentGame.COLOUR_RED;
     // else if (info.CurrentMatch.Value.Team2.Value.Players.Any(u => u.Id == Message.Sender.Id))
     //     SenderText.Colour = TournamentGame.COLOUR_BLUE;
     // else if (Message.Sender.Colour != null)
     //     SenderText.Colour = ColourBox.Colour = Color4Extensions.FromHex(Message.Sender.Colour);
 }
Example #7
0
 private void load(LadderInfo info)
 {
     //if (info.CurrentMatch.Value.Team1.Value.Players.Any(u => u.Id == Message.Sender.Id))
     //    ColourBox.Colour = red;
     //else if (info.CurrentMatch.Value.Team2.Value.Players.Any(u => u.Id == Message.Sender.Id))
     //    ColourBox.Colour = blue;
     //else if (Message.Sender.Colour != null)
     //    SenderText.Colour = ColourBox.Colour = OsuColour.FromHex(Message.Sender.Colour);
 }
Example #8
0
    public LadderInfo(LadderInfo other)
    {
        this.type         = other.type;
        this.initPosition = other.initPosition;
        this.initAngle    = other.initAngle;
        this.timeout      = other.timeout;

        this.movement = other.movement;
        this.rotate   = other.rotate;
    }
Example #9
0
        private void load(LadderInfo ladder, TextureStore textures)
        {
            currentMatch.BindValueChanged(matchChanged);
            currentMatch.BindTo(ladder.CurrentMatch);

            CornerRadius   = HEIGHT / 2;
            CornerExponent = 2;
            Masking        = true;

            AddRangeInternal(new Drawable[]
            {
                new Box
                {
                    RelativeSizeAxes = Axes.Both,
                    Colour           = Color4.Black,
                },
                new UpdateableBeatmapSetCover
                {
                    RelativeSizeAxes = Axes.Both,
                    Colour           = OsuColour.Gray(0.5f),
                    BeatmapSet       = Beatmap.BeatmapSet,
                },
                new FillFlowContainer
                {
                    AutoSizeAxes = Axes.Both,
                    Anchor       = Anchor.TopCentre,
                    Origin       = Anchor.TopCentre,
                    Padding      = new MarginPadding(vertical_padding),
                    Direction    = FillDirection.Vertical,
                    Children     = new Drawable[]
                    {
                        new OsuSpriteText
                        {
                            Anchor = Anchor.TopCentre,
                            Origin = Anchor.TopCentre,
                            Text   = new LocalisedString((
                                                             $"{Beatmap.Metadata.ArtistUnicode ?? Beatmap.Metadata.Artist} - {Beatmap.Metadata.TitleUnicode ?? Beatmap.Metadata.Title}",
                                                             $"{Beatmap.Metadata.Artist} - {Beatmap.Metadata.Title}")),
                            Font = OsuFont.GetFont(weight: FontWeight.Bold, italics: true),
                        },
Example #10
0
        private void load(LadderInfo ladder, Storage storage)
        {
            this.ladder = ladder;

            RelativeSizeAxes = Axes.Both;

            InternalChildren = new Drawable[]
            {
                new TourneyVideo(storage.GetStream(@"videos/schedule.m4v"))
                {
                    RelativeSizeAxes = Axes.Both,
                    Loop             = true,
                },
                mainContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                }
            };

            currentMatch.BindValueChanged(matchChanged);
            currentMatch.BindTo(ladder.CurrentMatch);
        }
Example #11
0
        private void load(LadderInfo ladder, TextureStore textures)
        {
            currentMatch.BindValueChanged(matchChanged);
            currentMatch.BindTo(ladder.CurrentMatch);

            Masking = true;

            AddRangeInternal(new Drawable[]
            {
                new Box
                {
                    RelativeSizeAxes = Axes.Both,
                    Colour           = Color4.Black,
                },
                new UpdateableBeatmapSetCover
                {
                    RelativeSizeAxes = Axes.Both,
                    Colour           = OsuColour.Gray(0.5f),
                    BeatmapSet       = Beatmap.BeatmapSet,
                },
                new FillFlowContainer
                {
                    AutoSizeAxes = Axes.Both,
                    Anchor       = Anchor.CentreLeft,
                    Origin       = Anchor.CentreLeft,
                    Padding      = new MarginPadding(15),
                    Direction    = FillDirection.Vertical,
                    Children     = new Drawable[]
                    {
                        new TournamentSpriteText
                        {
                            Text = new LocalisedString((
                                                           $"{Beatmap.Metadata.ArtistUnicode ?? Beatmap.Metadata.Artist} - {Beatmap.Metadata.TitleUnicode ?? Beatmap.Metadata.Title}",
                                                           $"{Beatmap.Metadata.Artist} - {Beatmap.Metadata.Title}")),
                            Font = OsuFont.Torus.With(weight: FontWeight.Bold),
                        },
Example #12
0
        private void load(LadderInfo ladder, Storage storage)
        {
            InternalChildren = new Drawable[]
            {
                new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    X               = 200,
                    FillMode        = FillMode.Fit,
                    FillAspectRatio = 16 / 9f,
                    Anchor          = Anchor.TopLeft,
                    Origin          = Anchor.TopLeft,
                    Size            = new Vector2(0.8f, 1),
                    //Masking = true,
                    Children = new Drawable[]
                    {
                        video = new TourneyVideo(storage.GetStream("BG Logoless - OWC.m4v"))
                        {
                            Loop             = true,
                            RelativeSizeAxes = Axes.Both,
                        },
                        screens = new Container
                        {
                            RelativeSizeAxes = Axes.Both,
                            Children         = new Drawable[]
                            {
                                new SetupScreen(),
                                new ScheduleScreen(),
                                new LadderScreen(),
                                new LadderEditorScreen(),
                                new TeamEditorScreen(),
                                new RoundEditorScreen(),
                                new ShowcaseScreen(),
                                new MapPoolScreen(),
                                new TeamIntroScreen(),
                                new DrawingsScreen(),
                                new GameplayScreen(),
                                new TeamWinScreen()
                            }
                        },
                        chatContainer = new Container
                        {
                            RelativeSizeAxes = Axes.Both,
                            Child            = chat
                        },
                    }
                },
                new Container
                {
                    RelativeSizeAxes = Axes.Y,
                    Width            = 200,
                    Children         = new Drawable[]
                    {
                        new Box
                        {
                            Colour           = Color4.Black,
                            RelativeSizeAxes = Axes.Both,
                        },
                        new FillFlowContainer
                        {
                            RelativeSizeAxes = Axes.Both,
                            Direction        = FillDirection.Vertical,
                            Children         = new Drawable[]
                            {
                                new OsuButton {
                                    RelativeSizeAxes = Axes.X, Text = "Setup", Action = () => SetScreen(typeof(SetupScreen))
                                },
                                new Container {
                                    RelativeSizeAxes = Axes.X, Height = 50
                                },
                                new OsuButton {
                                    RelativeSizeAxes = Axes.X, Text = "Team Editor", Action = () => SetScreen(typeof(TeamEditorScreen))
                                },
                                new OsuButton {
                                    RelativeSizeAxes = Axes.X, Text = "Rounds Editor", Action = () => SetScreen(typeof(RoundEditorScreen))
                                },
                                new OsuButton {
                                    RelativeSizeAxes = Axes.X, Text = "Bracket Editor", Action = () => SetScreen(typeof(LadderEditorScreen))
                                },
                                new Container {
                                    RelativeSizeAxes = Axes.X, Height = 50
                                },
                                new OsuButton {
                                    RelativeSizeAxes = Axes.X, Text = "Drawings", Action = () => SetScreen(typeof(DrawingsScreen))
                                },
                                new OsuButton {
                                    RelativeSizeAxes = Axes.X, Text = "Showcase", Action = () => SetScreen(typeof(ShowcaseScreen))
                                },
                                new Container {
                                    RelativeSizeAxes = Axes.X, Height = 50
                                },
                                new OsuButton {
                                    RelativeSizeAxes = Axes.X, Text = "Schedule", Action = () => SetScreen(typeof(ScheduleScreen))
                                },
                                new OsuButton {
                                    RelativeSizeAxes = Axes.X, Text = "Bracket", Action = () => SetScreen(typeof(LadderScreen))
                                },
                                new Container {
                                    RelativeSizeAxes = Axes.X, Height = 50
                                },
                                new OsuButton {
                                    RelativeSizeAxes = Axes.X, Text = "TeamIntro", Action = () => SetScreen(typeof(TeamIntroScreen))
                                },
                                new OsuButton {
                                    RelativeSizeAxes = Axes.X, Text = "MapPool", Action = () => SetScreen(typeof(MapPoolScreen))
                                },
                                new OsuButton {
                                    RelativeSizeAxes = Axes.X, Text = "Gameplay", Action = () => SetScreen(typeof(GameplayScreen))
                                },
                                new Container {
                                    RelativeSizeAxes = Axes.X, Height = 50
                                },
                                new OsuButton {
                                    RelativeSizeAxes = Axes.X, Text = "Win", Action = () => SetScreen(typeof(TeamWinScreen))
                                },
                            }
                        },
                    },
                },
            };

            SetScreen(typeof(SetupScreen));
        }
Example #13
0
 private void load(LadderInfo ladder)
 {
     currentMatch.BindValueChanged(matchChanged);
     currentMatch.BindTo(ladder.CurrentMatch);
 }
Example #14
0
        private void load(LadderInfo ladder, MatchIPCInfo ipc, Storage storage)
        {
            this.ipc = ipc;

            AddRangeInternal(new Drawable[]
            {
                new TourneyVideo("gameplay")
                {
                    Loop             = true,
                    RelativeSizeAxes = Axes.Both,
                },
                header = new MatchHeader
                {
                    ShowLogo = false
                },
                new Container
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Y        = 110,
                    Anchor   = Anchor.TopCentre,
                    Origin   = Anchor.TopCentre,
                    Children = new Drawable[]
                    {
                        chroma = new Box
                        {
                            // chroma key area for stable gameplay
                            Name   = "chroma",
                            Anchor = Anchor.TopCentre,
                            Origin = Anchor.TopCentre,
                            Height = 512,
                            Colour = new Color4(0, 255, 0, 255),
                        },
                    }
                },
                scoreDisplay = new MatchScoreDisplay
                {
                    Y      = -147,
                    Anchor = Anchor.BottomCentre,
                    Origin = Anchor.TopCentre,
                },
                new ControlPanel
                {
                    Children = new Drawable[]
                    {
                        warmupButton = new TourneyButton
                        {
                            RelativeSizeAxes = Axes.X,
                            Text             = "Toggle warmup",
                            Action           = () => warmup.Toggle()
                        },
                        new TourneyButton
                        {
                            RelativeSizeAxes = Axes.X,
                            Text             = "Toggle chat",
                            Action           = () => { State.Value = State.Value == TourneyState.Idle ? TourneyState.Playing : TourneyState.Idle; }
                        },
                        new SettingsSlider <int>
                        {
                            LabelText    = "Chroma Width",
                            Bindable     = LadderInfo.ChromaKeyWidth,
                            KeyboardStep = 1,
                        }
                    }
                }
            });

            State.BindTo(ipc.State);
            State.BindValueChanged(stateChanged, true);

            ladder.ChromaKeyWidth.BindValueChanged(width => chroma.Width = width.NewValue, true);

            currentMatch.BindValueChanged(m =>
            {
                warmup.Value = m.NewValue.Team1Score.Value + m.NewValue.Team2Score.Value == 0;
                scheduledOperation?.Cancel();
            });

            currentMatch.BindTo(ladder.CurrentMatch);

            warmup.BindValueChanged(w =>
            {
                warmupButton.Alpha = !w.NewValue ? 0.5f : 1;
                header.ShowScores  = !w.NewValue;
            }, true);
        }
Example #15
0
        private void load(LadderInfo ladder)
        {
            currentMatch.BindValueChanged(matchChanged);
            currentMatch.BindTo(ladder.CurrentMatch);

            Masking = true;

            AddRangeInternal(new Drawable[]
            {
                new Box
                {
                    RelativeSizeAxes = Axes.Both,
                    Colour = Color4.Black,
                },
                new UpdateableOnlineBeatmapSetCover
                {
                    RelativeSizeAxes = Axes.Both,
                    Colour = OsuColour.Gray(0.5f),
                    OnlineInfo = Beatmap.BeatmapSet,
                },
                new FillFlowContainer
                {
                    AutoSizeAxes = Axes.Both,
                    Anchor = Anchor.CentreLeft,
                    Origin = Anchor.CentreLeft,
                    Padding = new MarginPadding(15),
                    Direction = FillDirection.Vertical,
                    Children = new Drawable[]
                    {
                        new TournamentSpriteText
                        {
                            Text = Beatmap.GetDisplayTitleRomanisable(false, false),
                            Font = OsuFont.Torus.With(weight: FontWeight.Bold),
                        },
                        new FillFlowContainer
                        {
                            AutoSizeAxes = Axes.Both,
                            Direction = FillDirection.Horizontal,
                            Children = new Drawable[]
                            {
                                new TournamentSpriteText
                                {
                                    Text = "mapper",
                                    Padding = new MarginPadding { Right = 5 },
                                    Font = OsuFont.Torus.With(weight: FontWeight.Regular, size: 14)
                                },
                                new TournamentSpriteText
                                {
                                    Text = Beatmap.Metadata.Author.Username,
                                    Padding = new MarginPadding { Right = 20 },
                                    Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 14)
                                },
                                new TournamentSpriteText
                                {
                                    Text = "difficulty",
                                    Padding = new MarginPadding { Right = 5 },
                                    Font = OsuFont.Torus.With(weight: FontWeight.Regular, size: 14)
                                },
                                new TournamentSpriteText
                                {
                                    Text = Beatmap.DifficultyName,
                                    Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 14)
                                },
                            }
                        }
                    },
                },
                flash = new Box
                {
                    RelativeSizeAxes = Axes.Both,
                    Colour = Color4.Gray,
                    Blending = BlendingParameters.Additive,
                    Alpha = 0,
                },
            });

            if (!string.IsNullOrEmpty(mod))
            {
                AddInternal(new TournamentModIcon(mod)
                {
                    Anchor = Anchor.CentreRight,
                    Origin = Anchor.CentreRight,
                    Margin = new MarginPadding(10),
                    Width = 60,
                    RelativeSizeAxes = Axes.Y,
                });
            }
        }
    public void GenerateLevelData(bool withBackup = false)
    {
        Debug.Log(withBackup);
        if (withBackup)
        {
            level = backupLevel;
        }
        else
        {
            // Push all data to level
            List <LadderInfo> ladderInfos = new List <LadderInfo>();
            level = new Level(levelIndex, tutorialContent, ladderInfos);
            LevelUtil.setCurrentLevel(level);

            GameObject[] ladders = GameObjectUtils.FindGameObjectsWithTag(Constants.ObjectTags.ladder.ToString());
            GameObjectUtils.SortGameObjectByPositionY(ladders);
            for (int i = 0; i < ladders.Length; i++)
            {
                GameObject ladder          = ladders[i];
                LadderInfo ladderInfo      = new LadderInfo();
                Ladder     ladderComponent = ladder.GetComponent <Ladder>();

                ladderInfo.initAngle = -1 * ladderComponent.initAngle;
                ladderInfo.type      = Constants.LadderType.normalLadder;
                ladderInfo.timeout   = ladderComponent.timeout;

                LadderRotate ladderRotate = ladder.GetComponent <LadderRotate>();
                if (ladderRotate.speed > 0)
                {
                    ladderInfo.rotate = new LadderRotateData(ladderRotate.isClockwise, ladderRotate.speed);
                }
                else
                {
                    ladderInfo.rotate = null;
                }

                LadderMovement ladderMovement = ladder.GetComponent <LadderMovement>();
                if (ladderMovement.speed > 0)
                {
                    ladderInfo.initPosition.Fill(ladder.GetComponent <Explode>().initPosition);
                    MyVector3[] points = new MyVector3[ladderMovement.points.Count];
                    for (int j = 0; j < ladderMovement.points.Count; j++)
                    {
                        points[j] = new MyVector3();
                        points[j].Fill(ladderMovement.points[j]);
                    }
                    ladderInfo.movement = new LadderMovementData(ladderMovement.type, points, ladderMovement.distances, ladderMovement.speed, ladderMovement.radius, ladderMovement.isClockwise, ladderMovement.initAngle);
                }
                else
                {
                    ladderInfo.initPosition.Fill(ladder.transform.position);
                    ladderInfo.movement = null;
                }

                ladderInfos.Add(ladderInfo);
            }

            level.ladders = ladderInfos;
            backupLevel   = level;
        }
    }
Example #17
0
        private void load(LadderInfo ladder, Storage storage)
        {
            this.ladder = ladder;

            RelativeSizeAxes = Axes.Both;

            InternalChildren = new Drawable[]
            {
                new TourneyVideo("schedule")
                {
                    RelativeSizeAxes = Axes.Both,
                    Loop             = true,
                },
                new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding(100)
                    {
                        Bottom = 50
                    },
                    Children = new Drawable[]
                    {
                        new GridContainer
                        {
                            RelativeSizeAxes = Axes.Both,
                            RowDimensions    = new[]
                            {
                                new Dimension(GridSizeMode.AutoSize),
                                new Dimension(),
                            },
                            Content = new[]
                            {
                                new Drawable[]
                                {
                                    new FillFlowContainer
                                    {
                                        AutoSizeAxes = Axes.Both,
                                        Direction    = FillDirection.Vertical,
                                        Children     = new Drawable[]
                                        {
                                            new DrawableTournamentHeaderText(),
                                            new Container
                                            {
                                                Margin = new MarginPadding {
                                                    Top = 40
                                                },
                                                AutoSizeAxes = Axes.Both,
                                                Children     = new Drawable[]
                                                {
                                                    new Box
                                                    {
                                                        Colour = Color4.White,
                                                        Size   = new Vector2(50, 10),
                                                    },
                                                    new TournamentSpriteTextWithBackground("Schedule")
                                                    {
                                                        X     = 60,
                                                        Scale = new Vector2(0.8f)
                                                    }
                                                }
                                            },
                                        }
                                    },
                                },
                                new Drawable[]
                                {
                                    mainContainer = new Container
                                    {
                                        RelativeSizeAxes = Axes.Both,
                                    }
                                }
                            }
                        }
                    }
                },
            };

            currentMatch.BindValueChanged(matchChanged);
            currentMatch.BindTo(ladder.CurrentMatch);
        }
Example #18
0
        private void load(LadderInfo ladder, MatchIPCInfo ipc)
        {
            this.ipc = ipc;

            AddRangeInternal(new Drawable[]
            {
                new TourneyVideo("gameplay")
                {
                    Loop             = true,
                    RelativeSizeAxes = Axes.Both,
                },
                header = new MatchHeader
                {
                    ShowLogo = false
                },
                new Container
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Y        = 110,
                    Anchor   = Anchor.TopCentre,
                    Origin   = Anchor.TopCentre,
                    Children = new[]
                    {
                        chroma = new Container
                        {
                            Anchor   = Anchor.TopCentre,
                            Origin   = Anchor.TopCentre,
                            Height   = 512,
                            Children = new Drawable[]
                            {
                                new ChromaArea
                                {
                                    Name             = "Left chroma",
                                    RelativeSizeAxes = Axes.Both,
                                    Width            = 0.5f,
                                },
                                new ChromaArea
                                {
                                    Name             = "Right chroma",
                                    RelativeSizeAxes = Axes.Both,
                                    Anchor           = Anchor.TopRight,
                                    Origin           = Anchor.TopRight,
                                    Width            = 0.5f,
                                }
                            }
                        },
                    }
                },
                scoreDisplay = new TournamentMatchScoreDisplay
                {
                    Y      = -147,
                    Anchor = Anchor.BottomCentre,
                    Origin = Anchor.TopCentre,
                },
                new ControlPanel
                {
                    Children = new Drawable[]
                    {
                        warmupButton = new TourneyButton
                        {
                            RelativeSizeAxes = Axes.X,
                            Text             = "Toggle warmup",
                            Action           = () => warmup.Toggle()
                        },
                        new TourneyButton
                        {
                            RelativeSizeAxes = Axes.X,
                            Text             = "Toggle chat",
                            Action           = () => { State.Value = State.Value == TourneyState.Idle ? TourneyState.Playing : TourneyState.Idle; }
                        },
                        new SettingsSlider <int>
                        {
                            LabelText    = "Chroma width",
                            Current      = LadderInfo.ChromaKeyWidth,
                            KeyboardStep = 1,
                        },
                        new SettingsSlider <int>
                        {
                            LabelText    = "Players per team",
                            Current      = LadderInfo.PlayersPerTeam,
                            KeyboardStep = 1,
                        }
                    }
                }
            });

            ladder.ChromaKeyWidth.BindValueChanged(width => chroma.Width = width.NewValue, true);

            warmup.BindValueChanged(w =>
            {
                warmupButton.Alpha = !w.NewValue ? 0.5f : 1;
                header.ShowScores  = !w.NewValue;
            }, true);
        }
Example #19
0
        private void load(LadderInfo ladder, Storage storage)
        {
            InternalChildren = new Drawable[]
            {
                new Container
                {
                    RelativeSizeAxes = Axes.Y,
                    X               = CONTROL_AREA_WIDTH,
                    FillMode        = FillMode.Fit,
                    FillAspectRatio = 16 / 9f,
                    Anchor          = Anchor.TopLeft,
                    Origin          = Anchor.TopLeft,
                    Width           = STREAM_AREA_WIDTH,
                    //Masking = true,
                    Children = new Drawable[]
                    {
                        video = new TourneyVideo("main", true)
                        {
                            Loop             = true,
                            RelativeSizeAxes = Axes.Both,
                        },
                        screens = new Container
                        {
                            RelativeSizeAxes = Axes.Both,
                            Children         = new Drawable[]
                            {
                                new SetupScreen(),
                                new ScheduleScreen(),
                                new LadderScreen(),
                                new LadderEditorScreen(),
                                new TeamEditorScreen(),
                                new RoundEditorScreen(),
                                new ShowcaseScreen(),
                                new MapPoolScreen(),
                                new TeamIntroScreen(),
                                new SeedingScreen(),
                                new DrawingsScreen(),
                                new GameplayScreen(),
                                new TeamWinScreen()
                            }
                        },
                        chatContainer = new Container
                        {
                            RelativeSizeAxes = Axes.Both,
                            Child            = chat
                        },
                    }
                },
                new Container
                {
                    RelativeSizeAxes = Axes.Y,
                    Width            = CONTROL_AREA_WIDTH,
                    Children         = new Drawable[]
                    {
                        new Box
                        {
                            Colour           = Colour4.Black,
                            RelativeSizeAxes = Axes.Both,
                        },
                        buttons = new FillFlowContainer
                        {
                            RelativeSizeAxes = Axes.Both,
                            Direction        = FillDirection.Vertical,
                            Spacing          = new Vector2(5),
                            Padding          = new MarginPadding(5),
                            Children         = new Drawable[]
                            {
                                new ScreenButton(typeof(SetupScreen))
                                {
                                    Text = "Setup", RequestSelection = SetScreen
                                },
                                new Separator(),
                                new ScreenButton(typeof(TeamEditorScreen))
                                {
                                    Text = "Team Editor", RequestSelection = SetScreen
                                },
                                new ScreenButton(typeof(RoundEditorScreen))
                                {
                                    Text = "Rounds Editor", RequestSelection = SetScreen
                                },
                                new ScreenButton(typeof(LadderEditorScreen))
                                {
                                    Text = "Bracket Editor", RequestSelection = SetScreen
                                },
                                new Separator(),
                                new ScreenButton(typeof(ScheduleScreen))
                                {
                                    Text = "Schedule", RequestSelection = SetScreen
                                },
                                new ScreenButton(typeof(LadderScreen))
                                {
                                    Text = "Bracket", RequestSelection = SetScreen
                                },
                                new Separator(),
                                new ScreenButton(typeof(TeamIntroScreen))
                                {
                                    Text = "Team Intro", RequestSelection = SetScreen
                                },
                                new ScreenButton(typeof(SeedingScreen))
                                {
                                    Text = "Seeding", RequestSelection = SetScreen
                                },
                                new Separator(),
                                new ScreenButton(typeof(MapPoolScreen))
                                {
                                    Text = "Map Pool", RequestSelection = SetScreen
                                },
                                new ScreenButton(typeof(GameplayScreen))
                                {
                                    Text = "Gameplay", RequestSelection = SetScreen
                                },
                                new Separator(),
                                new ScreenButton(typeof(TeamWinScreen))
                                {
                                    Text = "Win", RequestSelection = SetScreen
                                },
                                new Separator(),
                                new ScreenButton(typeof(DrawingsScreen))
                                {
                                    Text = "Drawings", RequestSelection = SetScreen
                                },
                                new ScreenButton(typeof(ShowcaseScreen))
                                {
                                    Text = "Showcase", RequestSelection = SetScreen
                                },
                            }
                        },
                    },
                },
            };

            foreach (var drawable in screens)
            {
                drawable.Hide();
            }

            SetScreen(typeof(SetupScreen));
        }
Example #20
0
        private void load(LadderInfo ladder, GameHost host)
        {
            StableStorage stable;

            try
            {
                stable = new StableStorage(host as DesktopGameHost);
            }
            catch (Exception e)
            {
                Logger.Error(e, "Stable installation could not be found; disabling file based IPC");
                return;
            }

            const string file_ipc_filename         = "ipc.txt";
            const string file_ipc_state_filename   = "ipc-state.txt";
            const string file_ipc_scores_filename  = "ipc-scores.txt";
            const string file_ipc_channel_filename = "ipc-channel.txt";

            if (stable.Exists(file_ipc_filename))
            {
                Scheduler.AddDelayed(delegate
                {
                    try
                    {
                        using (var stream = stable.GetStream(file_ipc_filename))
                            using (var sr = new StreamReader(stream))
                            {
                                var beatmapId = int.Parse(sr.ReadLine());
                                var mods      = int.Parse(sr.ReadLine());

                                if (lastBeatmapId != beatmapId)
                                {
                                    lastBeatmapId = beatmapId;

                                    var existing = ladder.CurrentMatch.Value?.Round.Value?.Beatmaps.FirstOrDefault(b => b.ID == beatmapId && b.BeatmapInfo != null);

                                    if (existing != null)
                                    {
                                        Beatmap.Value = existing.BeatmapInfo;
                                    }
                                    else
                                    {
                                        var req = new GetBeatmapRequest(new BeatmapInfo {
                                            OnlineBeatmapID = beatmapId
                                        });
                                        req.Success += b => Beatmap.Value = b.ToBeatmap(Rulesets);
                                        API.Queue(req);
                                    }
                                }

                                Mods.Value = (LegacyMods)mods;
                            }
                    }
                    catch
                    {
                        // file might be in use.
                    }

                    try
                    {
                        using (var stream = stable.GetStream(file_ipc_channel_filename))
                            using (var sr = new StreamReader(stream))
                            {
                                ChatChannel.Value = sr.ReadLine();
                            }
                    }
                    catch (Exception)
                    {
                        // file might be in use.
                    }

                    try
                    {
                        using (var stream = stable.GetStream(file_ipc_state_filename))
                            using (var sr = new StreamReader(stream))
                            {
                                State.Value = (TourneyState)Enum.Parse(typeof(TourneyState), sr.ReadLine());
                            }
                    }
                    catch (Exception)
                    {
                        // file might be in use.
                    }

                    try
                    {
                        using (var stream = stable.GetStream(file_ipc_scores_filename))
                            using (var sr = new StreamReader(stream))
                            {
                                Score1.Value = int.Parse(sr.ReadLine());
                                Score2.Value = int.Parse(sr.ReadLine());
                            }
                    }
                    catch (Exception)
                    {
                        // file might be in use.
                    }
                }, 250, true);
            }
        }
Example #21
0
        private void readBracket()
        {
            try
            {
                if (storage.Exists(bracket_filename))
                {
                    using (Stream stream = storage.GetStream(bracket_filename, FileAccess.Read, FileMode.Open))
                        using (var sr = new StreamReader(stream))
                            ladder = JsonConvert.DeserializeObject <LadderInfo>(sr.ReadToEnd(), new JsonPointConverter());
                }

                ladder ??= new LadderInfo();

                ladder.Ruleset.Value = RulesetStore.GetRuleset(ladder.Ruleset.Value?.ShortName)
                                       ?? RulesetStore.AvailableRulesets.First();

                bool addedInfo = false;

                // assign teams
                foreach (var match in ladder.Matches)
                {
                    match.Team1.Value = ladder.Teams.FirstOrDefault(t => t.Acronym.Value == match.Team1Acronym);
                    match.Team2.Value = ladder.Teams.FirstOrDefault(t => t.Acronym.Value == match.Team2Acronym);

                    foreach (var conditional in match.ConditionalMatches)
                    {
                        conditional.Team1.Value = ladder.Teams.FirstOrDefault(t => t.Acronym.Value == conditional.Team1Acronym);
                        conditional.Team2.Value = ladder.Teams.FirstOrDefault(t => t.Acronym.Value == conditional.Team2Acronym);
                        conditional.Round.Value = match.Round.Value;
                    }
                }

                // assign progressions
                foreach (var pair in ladder.Progressions)
                {
                    var src  = ladder.Matches.FirstOrDefault(p => p.ID == pair.SourceID);
                    var dest = ladder.Matches.FirstOrDefault(p => p.ID == pair.TargetID);

                    if (src == null)
                    {
                        continue;
                    }

                    if (dest != null)
                    {
                        if (pair.Losers)
                        {
                            src.LosersProgression.Value = dest;
                        }
                        else
                        {
                            src.Progression.Value = dest;
                        }
                    }
                }

                // link matches to rounds
                foreach (var round in ladder.Rounds)
                {
                    foreach (int id in round.Matches)
                    {
                        var found = ladder.Matches.FirstOrDefault(p => p.ID == id);

                        if (found != null)
                        {
                            found.Round.Value = round;
                            if (round.StartDate.Value > found.Date.Value)
                            {
                                found.Date.Value = round.StartDate.Value;
                            }
                        }
                    }
                }

                addedInfo |= addPlayers();
                addedInfo |= addRoundBeatmaps();
                addedInfo |= addSeedingBeatmaps();

                if (addedInfo)
                {
                    SaveChanges();
                }

                ladder.CurrentMatch.Value = ladder.Matches.FirstOrDefault(p => p.Current.Value);
            }
            catch (Exception e)
            {
                taskCompletionSource.SetException(e);
                return;
            }

            Schedule(() =>
            {
                Ruleset.BindTo(ladder.Ruleset);

                dependencies.Cache(ladder);
                dependencies.CacheAs <MatchIPCInfo>(ipc = new FileBasedIPC());
                Add(ipc);

                taskCompletionSource.SetResult(true);

                initialisationText.Expire();
            });
        }
Example #22
0
        private void readBracket()
        {
            if (storage.Exists(bracket_filename))
            {
                using (Stream stream = storage.GetStream(bracket_filename, FileAccess.Read, FileMode.Open))
                    using (var sr = new StreamReader(stream))
                        ladder = JsonConvert.DeserializeObject <LadderInfo>(sr.ReadToEnd());
            }

            if (ladder == null)
            {
                ladder = new LadderInfo();
            }

            if (ladder.Ruleset.Value == null)
            {
                ladder.Ruleset.Value = RulesetStore.AvailableRulesets.First();
            }

            Ruleset.BindTo(ladder.Ruleset);

            dependencies.Cache(ladder);

            bool addedInfo = false;

            // assign teams
            foreach (var match in ladder.Matches)
            {
                match.Team1.Value = ladder.Teams.FirstOrDefault(t => t.Acronym.Value == match.Team1Acronym);
                match.Team2.Value = ladder.Teams.FirstOrDefault(t => t.Acronym.Value == match.Team2Acronym);

                foreach (var conditional in match.ConditionalMatches)
                {
                    conditional.Team1.Value = ladder.Teams.FirstOrDefault(t => t.Acronym.Value == conditional.Team1Acronym);
                    conditional.Team2.Value = ladder.Teams.FirstOrDefault(t => t.Acronym.Value == conditional.Team2Acronym);
                    conditional.Round.Value = match.Round.Value;
                }
            }

            // assign progressions
            foreach (var pair in ladder.Progressions)
            {
                var src  = ladder.Matches.FirstOrDefault(p => p.ID == pair.SourceID);
                var dest = ladder.Matches.FirstOrDefault(p => p.ID == pair.TargetID);

                if (src == null)
                {
                    continue;
                }

                if (dest != null)
                {
                    if (pair.Losers)
                    {
                        src.LosersProgression.Value = dest;
                    }
                    else
                    {
                        src.Progression.Value = dest;
                    }
                }
            }

            // link matches to rounds
            foreach (var round in ladder.Rounds)
            {
                foreach (var id in round.Matches)
                {
                    var found = ladder.Matches.FirstOrDefault(p => p.ID == id);

                    if (found != null)
                    {
                        found.Round.Value = round;
                        if (round.StartDate.Value > found.Date.Value)
                        {
                            found.Date.Value = round.StartDate.Value;
                        }
                    }
                }
            }

            addedInfo |= addPlayers();
            addedInfo |= addBeatmaps();

            if (addedInfo)
            {
                SaveChanges();
            }
        }
Example #23
0
        private void load(LadderInfo ladder, MatchIPCInfo ipc)
        {
            this.ipc = ipc;

            AddRangeInternal(new Drawable[]
            {
                new MatchHeader(),
                new Container
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Y        = 5,
                    Anchor   = Anchor.Centre,
                    Origin   = Anchor.Centre,
                    Children = new Drawable[]
                    {
                        new Box
                        {
                            // chroma key area for stable gameplay
                            Name             = "chroma",
                            RelativeSizeAxes = Axes.X,
                            Height           = 512,
                            Colour           = new Color4(0, 255, 0, 255),
                        },
                        new Container
                        {
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes     = Axes.Y,
                            Y        = -4,
                            Children = new Drawable[]
                            {
                                new Circle
                                {
                                    Name             = "top bar red",
                                    RelativeSizeAxes = Axes.X,
                                    Height           = 8,
                                    Width            = 0.5f,
                                    Colour           = red,
                                },
                                new Circle
                                {
                                    Name             = "top bar blue",
                                    RelativeSizeAxes = Axes.X,
                                    Height           = 8,
                                    Width            = 0.5f,
                                    Colour           = blue,
                                    Anchor           = Anchor.TopRight,
                                    Origin           = Anchor.TopRight,
                                },
                            }
                        },
                    }
                },
                scoreDisplay = new MatchScoreDisplay
                {
                    Y      = -60,
                    Scale  = new Vector2(0.8f),
                    Anchor = Anchor.BottomCentre,
                    Origin = Anchor.BottomCentre,
                },
                new ControlPanel
                {
                    Children = new Drawable[]
                    {
                        warmupButton = new TourneyButton
                        {
                            RelativeSizeAxes = Axes.X,
                            Text             = "Toggle warmup",
                            Action           = () => warmup.Toggle()
                        },
                        new TourneyButton
                        {
                            RelativeSizeAxes = Axes.X,
                            Text             = "Toggle chat",
                            Action           = () => { State.Value = State.Value == TourneyState.Idle ? TourneyState.Playing : TourneyState.Idle; }
                        }
                    }
                }
            });

            State.BindTo(ipc.State);
            State.BindValueChanged(stateChanged, true);

            currentMatch.BindValueChanged(m =>
            {
                warmup.Value = m.NewValue.Team1Score.Value + m.NewValue.Team2Score.Value == 0;
                scheduledOperation?.Cancel();
            });

            currentMatch.BindTo(ladder.CurrentMatch);

            warmup.BindValueChanged(w => warmupButton.Alpha = !w.NewValue ? 0.5f : 1, true);
        }