1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 05:22:54 +08:00

Move existing tournament resources to new project

This commit is contained in:
Dean Herbert 2018-08-25 21:40:40 +09:00
parent 1eb0277ba3
commit 51dcfeee92
18 changed files with 202 additions and 89 deletions

View File

@ -0,0 +1,31 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "VisualTests (Debug)",
"type": "coreclr",
"request": "launch",
"program": "dotnet",
"args": [
"${workspaceRoot}/bin/Debug/netcoreapp2.1/osu.Game.Tournament.Tests.dll"
],
"cwd": "${workspaceRoot}",
"preLaunchTask": "Build (Debug)",
"env": {},
"console": "internalConsole"
},
{
"name": "VisualTests (Release)",
"type": "coreclr",
"request": "launch",
"program": "dotnet",
"args": [
"${workspaceRoot}/bin/Release/netcoreapp2.1/osu.Game.Tournament.Tests.dll"
],
"cwd": "${workspaceRoot}",
"preLaunchTask": "Build (Release)",
"env": {},
"console": "internalConsole"
}
]
}

View File

@ -0,0 +1,47 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build (Debug)",
"type": "shell",
"command": "dotnet",
"args": [
"build",
"--no-restore",
"osu.Game.Tournament.Tests.csproj",
"/p:GenerateFullPaths=true",
"/m",
"/verbosity:m"
],
"group": "build",
"problemMatcher": "$msCompile"
},
{
"label": "Build (Release)",
"type": "shell",
"command": "dotnet",
"args": [
"build",
"--no-restore",
"osu.Game.Tournament.Tests.csproj",
"/p:Configuration=Release",
"/p:GenerateFullPaths=true",
"/m",
"/verbosity:m"
],
"group": "build",
"problemMatcher": "$msCompile"
},
{
"label": "Restore",
"type": "shell",
"command": "dotnet",
"args": [
"restore"
],
"problemMatcher": []
}
]
}

View File

@ -2,18 +2,17 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using System.ComponentModel;
using osu.Game.Screens.Tournament;
using osu.Game.Screens.Tournament.Teams;
using osu.Game.Tests.Visual;
using osu.Game.Tournament.Screens.Drawings;
using osu.Game.Tournament.Screens.Drawings.Components;
namespace osu.Game.Tests.Visual
namespace osu.Game.Tournament.Tests
{
[Description("for tournament use")]
public class TestCaseDrawings : OsuTestCase
{
public TestCaseDrawings()
{
Add(new Drawings
Add(new DrawingsScreen
{
TeamList = new TestTeamList(),
});
@ -21,57 +20,57 @@ namespace osu.Game.Tests.Visual
private class TestTeamList : ITeamList
{
public IEnumerable<DrawingsTeam> Teams { get; } = new[]
public IEnumerable<TournamentTeam> Teams { get; } = new[]
{
new DrawingsTeam
new TournamentTeam
{
FlagName = "GB",
FullName = "United Kingdom",
Acronym = "UK"
},
new DrawingsTeam
new TournamentTeam
{
FlagName = "FR",
FullName = "France",
Acronym = "FRA"
},
new DrawingsTeam
new TournamentTeam
{
FlagName = "CN",
FullName = "China",
Acronym = "CHN"
},
new DrawingsTeam
new TournamentTeam
{
FlagName = "AU",
FullName = "Australia",
Acronym = "AUS"
},
new DrawingsTeam
new TournamentTeam
{
FlagName = "JP",
FullName = "Japan",
Acronym = "JPN"
},
new DrawingsTeam
new TournamentTeam
{
FlagName = "RO",
FullName = "Romania",
Acronym = "ROM"
},
new DrawingsTeam
new TournamentTeam
{
FlagName = "IT",
FullName = "Italy",
Acronym = "PIZZA"
},
new DrawingsTeam
new TournamentTeam
{
FlagName = "VE",
FullName = "Venezuela",
Acronym = "VNZ"
},
new DrawingsTeam
new TournamentTeam
{
FlagName = "US",
FullName = "United States of America",

View File

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\osu.TestProject.props" />
<ItemGroup Label="Package References">
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="NUnit" Version="3.10.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
</ItemGroup>
<PropertyGroup Label="Project">
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\osu.Game.Tournament\osu.Game.Tournament.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,11 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Runtime.CompilerServices;
// We publish our internal attributes to other sub-projects of the framework.
// Note, that we omit visual tests as they are meant to test the framework
// behavior "in the wild".
[assembly: InternalsVisibleTo("osu.Game.Tournament.Tests")]
[assembly: InternalsVisibleTo("osu.Game.Tournament.Tests.Dynamic")]

View File

@ -4,7 +4,7 @@
using osu.Framework.Configuration;
using osu.Framework.Platform;
namespace osu.Game.Screens.Tournament.Components
namespace osu.Game.Tournament.Screens.Drawings.Components
{
public class DrawingsConfigManager : IniConfigManager<DrawingsConfig>
{

View File

@ -1,23 +1,29 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Screens.Tournament.Teams
namespace osu.Game.Tournament.Screens.Drawings.Components
{
public class DrawingsTeam
public class TournamentTeam
{
/// <summary>
/// The name of this team.
/// </summary>
public string FullName;
/// <summary>
/// Short acronym which appears in the group boxes post-selection.
/// </summary>
public string Acronym;
/// <summary>
/// Name of the file containing the flag.
/// </summary>
public string FlagName;
private string acronym;
/// <summary>
/// Short acronym which appears in the group boxes post-selection.
/// </summary>
public string Acronym
{
get { return acronym ?? FullName.Substring(0, 3); }
set { acronym = value; }
}
}
}

View File

@ -7,15 +7,14 @@ using System.Text;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics.Sprites;
using OpenTK;
using OpenTK.Graphics;
using osu.Game.Screens.Tournament.Teams;
using osu.Framework.Graphics.Shapes;
namespace osu.Game.Screens.Tournament
namespace osu.Game.Tournament.Screens.Drawings.Components
{
public class Group : Container
{
@ -73,7 +72,7 @@ namespace osu.Game.Screens.Tournament
};
}
public void AddTeam(DrawingsTeam team)
public void AddTeam(TournamentTeam team)
{
GroupTeam gt = new GroupTeam(team);
@ -91,7 +90,7 @@ namespace osu.Game.Screens.Tournament
return allTeams.Any(t => t.Team.FullName == fullName);
}
public bool RemoveTeam(DrawingsTeam team)
public bool RemoveTeam(TournamentTeam team)
{
allTeams.RemoveAll(gt => gt.Team == team);
@ -122,12 +121,12 @@ namespace osu.Game.Screens.Tournament
private class GroupTeam : Container
{
public readonly DrawingsTeam Team;
public readonly TournamentTeam Team;
private readonly FillFlowContainer innerContainer;
private readonly Sprite flagSprite;
public GroupTeam(DrawingsTeam team)
public GroupTeam(TournamentTeam team)
{
Team = team;

View File

@ -8,9 +8,8 @@ using System.Text;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using OpenTK;
using osu.Game.Screens.Tournament.Teams;
namespace osu.Game.Screens.Tournament
namespace osu.Game.Tournament.Screens.Drawings.Components
{
public class GroupContainer : Container
{
@ -64,7 +63,7 @@ namespace osu.Game.Screens.Tournament
}
}
public void AddTeam(DrawingsTeam team)
public void AddTeam(TournamentTeam team)
{
if (groups[currentGroup].TeamsCount == maxTeams)
return;

View File

@ -3,10 +3,10 @@
using System.Collections.Generic;
namespace osu.Game.Screens.Tournament.Teams
namespace osu.Game.Tournament.Screens.Drawings.Components
{
public interface ITeamList
{
IEnumerable<DrawingsTeam> Teams { get; }
IEnumerable<TournamentTeam> Teams { get; }
}
}

View File

@ -13,18 +13,17 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Threading;
using osu.Game.Screens.Tournament.Teams;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Screens.Tournament
namespace osu.Game.Tournament.Screens.Drawings.Components
{
public class ScrollingTeamContainer : Container
{
public event Action OnScrollStarted;
public event Action<DrawingsTeam> OnSelected;
public event Action<TournamentTeam> OnSelected;
private readonly List<DrawingsTeam> availableTeams = new List<DrawingsTeam>();
private readonly List<TournamentTeam> availableTeams = new List<TournamentTeam>();
private readonly Container tracker;
@ -84,6 +83,7 @@ namespace osu.Game.Screens.Tournament
}
private ScrollState _scrollState;
private ScrollState scrollState
{
get { return _scrollState; }
@ -166,7 +166,7 @@ namespace osu.Game.Screens.Tournament
}
}
public void AddTeam(DrawingsTeam team)
public void AddTeam(TournamentTeam team)
{
if (availableTeams.Contains(team))
return;
@ -177,12 +177,12 @@ namespace osu.Game.Screens.Tournament
scrollState = ScrollState.Idle;
}
public void AddTeams(IEnumerable<DrawingsTeam> teams)
public void AddTeams(IEnumerable<TournamentTeam> teams)
{
if (teams == null)
return;
foreach (DrawingsTeam t in teams)
foreach (TournamentTeam t in teams)
AddTeam(t);
}
@ -193,7 +193,7 @@ namespace osu.Game.Screens.Tournament
scrollState = ScrollState.Idle;
}
public void RemoveTeam(DrawingsTeam team)
public void RemoveTeam(TournamentTeam team)
{
availableTeams.Remove(team);
@ -278,7 +278,7 @@ namespace osu.Game.Screens.Tournament
private void addFlags()
{
foreach (DrawingsTeam t in availableTeams)
foreach (TournamentTeam t in availableTeams)
{
Add(new ScrollingTeam(t)
{
@ -320,12 +320,13 @@ namespace osu.Game.Screens.Tournament
public const float WIDTH = 58;
public const float HEIGHT = 41;
public DrawingsTeam Team;
public TournamentTeam Team;
private readonly Sprite flagSprite;
private readonly Box outline;
private bool selected;
public bool Selected
{
get { return selected; }
@ -341,7 +342,7 @@ namespace osu.Game.Screens.Tournament
}
}
public ScrollingTeam(DrawingsTeam team)
public ScrollingTeam(TournamentTeam team)
{
Team = team;

View File

@ -7,7 +7,7 @@ using System.IO;
using osu.Framework.Logging;
using osu.Framework.Platform;
namespace osu.Game.Screens.Tournament.Teams
namespace osu.Game.Tournament.Screens.Drawings.Components
{
public class StorageBackedTeamList : ITeamList
{
@ -20,11 +20,11 @@ namespace osu.Game.Screens.Tournament.Teams
this.storage = storage;
}
public IEnumerable<DrawingsTeam> Teams
public IEnumerable<TournamentTeam> Teams
{
get
{
var teams = new List<DrawingsTeam>();
var teams = new List<TournamentTeam>();
try
{
@ -47,17 +47,11 @@ namespace osu.Game.Screens.Tournament.Teams
continue;
}
string flagName = split[0].Trim();
string teamName = split[1].Trim();
string acronym = split.Length >= 3 ? split[2].Trim() : teamName;
acronym = acronym.Substring(0, Math.Min(3, acronym.Length));
teams.Add(new DrawingsTeam
teams.Add(new TournamentTeam
{
FlagName = flagName,
FullName = teamName,
Acronym = acronym
FlagName = split[0].Trim(),
FullName = split[1].Trim(),
Acronym = split.Length >= 3 ? split[2].Trim() : null
});
}
}

View File

@ -1,16 +1,16 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.MathUtils;
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Screens.Tournament.Components
namespace osu.Game.Tournament.Screens.Drawings.Components
{
public class VisualiserContainer : Container
{

View File

@ -9,23 +9,23 @@ using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.IO.Stores;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Screens;
using osu.Game.Screens.Backgrounds;
using osu.Game.Screens.Tournament.Components;
using osu.Game.Screens.Tournament.Teams;
using osu.Game.Tournament.Screens.Drawings.Components;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.IO.Stores;
using osu.Framework.Graphics.Shapes;
namespace osu.Game.Screens.Tournament
namespace osu.Game.Tournament.Screens.Drawings
{
public class Drawings : OsuScreen
public class DrawingsScreen : OsuScreen
{
private const string results_filename = "drawings_results.txt";
@ -37,7 +37,7 @@ namespace osu.Game.Screens.Tournament
private GroupContainer groupsContainer;
private OsuSpriteText fullTeamNameText;
private readonly List<DrawingsTeam> allTeams = new List<DrawingsTeam>();
private readonly List<TournamentTeam> allTeams = new List<TournamentTeam>();
private DrawingsConfigManager drawingsConfig;
@ -253,7 +253,7 @@ namespace osu.Game.Screens.Tournament
reset(true);
}
private void onTeamSelected(DrawingsTeam team)
private void onTeamSelected(TournamentTeam team)
{
groupsContainer.AddTeam(team);
@ -290,7 +290,7 @@ namespace osu.Game.Screens.Tournament
teamsContainer.ClearTeams();
allTeams.Clear();
foreach (DrawingsTeam t in TeamList.Teams)
foreach (TournamentTeam t in TeamList.Teams)
{
if (groupsContainer.ContainsTeam(t.FullName))
continue;
@ -327,7 +327,7 @@ namespace osu.Game.Screens.Tournament
continue;
// ReSharper disable once AccessToModifiedClosure
DrawingsTeam teamToAdd = allTeams.FirstOrDefault(t => t.FullName == line);
TournamentTeam teamToAdd = allTeams.FirstOrDefault(t => t.FullName == line);
if (teamToAdd == null)
continue;

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\osu.Game.props" />
<PropertyGroup Label="Project">
<TargetFramework>netstandard2.0</TargetFramework>
<OutputType>Library</OutputType>
<PlatformTarget>AnyCPU</PlatformTarget>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Description>tools for tournaments.</Description>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\osu.Game\osu.Game.csproj" />
</ItemGroup>
</Project>

View File

@ -3,11 +3,8 @@
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Input.EventArgs;
using osu.Framework.Input.States;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
@ -18,7 +15,6 @@ using osu.Game.Screens.Direct;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Multi;
using osu.Game.Screens.Select;
using osu.Game.Screens.Tournament;
namespace osu.Game.Screens.Menu
{
@ -199,16 +195,5 @@ namespace osu.Game.Screens.Menu
Content.FadeOut(3000);
return base.OnExiting(next);
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (!args.Repeat && state.Keyboard.ControlPressed && state.Keyboard.ShiftPressed && args.Key == Key.D)
{
Push(new Drawings());
return true;
}
return base.OnKeyDown(state, args);
}
}
}

View File

@ -48,7 +48,7 @@ namespace osu.Game.Tests.Visual
{
beatmap.SetAudioManager(audioManager);
Ruleset.Value = rulesets.AvailableRulesets.First();
Ruleset.Value = rulesets.AvailableRulesets.FirstOrDefault();
}
protected override void Dispose(bool isDisposing)

12
osu.sln
View File

@ -27,6 +27,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game.Rulesets.Taiko.Tes
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game.Rulesets.Osu.Tests", "osu.Game.Rulesets.Osu.Tests\osu.Game.Rulesets.Osu.Tests.csproj", "{6A2D5D58-0261-4A75-BE84-2BE8B076B7C2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Game.Tournament", "osu.Game.Tournament\osu.Game.Tournament.csproj", "{5672CA4D-1B37-425B-A118-A8DA26E78938}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Game.Tournament.Tests", "osu.Game.Tournament.Tests\osu.Game.Tournament.Tests.csproj", "{5789E78D-38F9-4072-AB7B-978F34B2C17F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -81,6 +85,14 @@ Global
{6A2D5D58-0261-4A75-BE84-2BE8B076B7C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6A2D5D58-0261-4A75-BE84-2BE8B076B7C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6A2D5D58-0261-4A75-BE84-2BE8B076B7C2}.Release|Any CPU.Build.0 = Release|Any CPU
{5672CA4D-1B37-425B-A118-A8DA26E78938}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5672CA4D-1B37-425B-A118-A8DA26E78938}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5672CA4D-1B37-425B-A118-A8DA26E78938}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5672CA4D-1B37-425B-A118-A8DA26E78938}.Release|Any CPU.Build.0 = Release|Any CPU
{5789E78D-38F9-4072-AB7B-978F34B2C17F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5789E78D-38F9-4072-AB7B-978F34B2C17F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5789E78D-38F9-4072-AB7B-978F34B2C17F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5789E78D-38F9-4072-AB7B-978F34B2C17F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE