Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: V2 Dev #77

Draft
wants to merge 49 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
fd12d09
[wip-v2] rework start. main menu integration, disclaimer, avatar setup
roydejong Mar 2, 2024
d95fdbd
[wip-v2] fix some menu transition scenarios
roydejong Mar 2, 2024
ad61218
[wip-v2] ui toolkit beginnings
roydejong Mar 3, 2024
d361c3d
[wip-v2] ui toolkit: search and filter bar components
roydejong Mar 6, 2024
6657489
[wip-v2] ui browser: backgrounds, colors, skews, paddings
roydejong Mar 6, 2024
99e723b
[wip-v2] ui toolkit: loading control
roydejong Mar 6, 2024
711b86c
[wip-v2] ui work: user pane
roydejong Mar 7, 2024
9ac2516
[wip-v2] smooth transition to/from avatar editor
roydejong Mar 7, 2024
ad5ecbe
[wip-v2] session basics, steam auth, avatar loading
roydejong Mar 7, 2024
5091450
[wip-v2] don't login til multiplayer launch
roydejong Mar 7, 2024
dce87d4
[wip-v2] rounded avatar image
roydejong Mar 9, 2024
5e57efe
[wip-v2] scroll views & basic discovery structure
roydejong Mar 9, 2024
667abfa
[wip-v2] login: cache & reuse platform auth tokens
roydejong Mar 9, 2024
0b4c3e7
[wip-v2] login: cancel retries on flow coordinator exit
roydejong Mar 9, 2024
d606ef2
[wip-v2] browser: text search and scroll view fixes
roydejong Mar 9, 2024
dcd512a
[wip-v2] browser: scrollable grid
roydejong Mar 9, 2024
63078e5
[wip-v2] browser: server cells v1
roydejong Mar 11, 2024
659bff7
[wip-v2] browser: avatar (silly)
roydejong Mar 11, 2024
cc838ba
[wip-v2] browser: cleanup, cover art loading, UI tweaks
roydejong Mar 14, 2024
737da6f
[wip-v2] browser: local server sorting, image cache fixes
roydejong Mar 14, 2024
fb97457
[wip-v2] ui: basic modal system
roydejong Mar 16, 2024
b246a9c
[wip-v2] ui: table view
roydejong Mar 16, 2024
7fe3fce
[wip-v2] feat: local network discovery!
roydejong Mar 17, 2024
77232ca
[wip-v2] feat: multiplayer connections!
roydejong Mar 18, 2024
e627440
[wip-v2] fix UI issues on lobby joins / leaves
roydejong Mar 18, 2024
5f3a99e
[wip-v2] tweak discovery timings
roydejong Mar 19, 2024
8b71f41
[wip-v2] don't hide loading spinner on lobby fade in
roydejong Mar 19, 2024
be406eb
[wip-v2] logging cleanup
roydejong Mar 19, 2024
95d2c5f
[wip-v2] pass mask/config from local discovery to lobby
roydejong Mar 19, 2024
91c8322
[wip-v2] show server name in lobby title
roydejong Mar 19, 2024
1697eab
[wip-v2] custom songs patch for direct connects
roydejong Mar 20, 2024
cc64f54
[wip-v2] discovery: include game version in query
roydejong Mar 21, 2024
b5e0a9d
[wip-v2] ui: split out account tile into component
roydejong Mar 21, 2024
7a27730
[wip-v2] fix ui breakage if you get disconnected really fast
roydejong Mar 21, 2024
289eb4b
[wip-v2] more useful error messages if immediately disconnected
roydejong Mar 21, 2024
3f1e3e5
[wip-v2] more useful error message for ServerTerminating CFR
roydejong Mar 21, 2024
33ef99b
[wip-v2] modal open/close animations
roydejong Mar 22, 2024
82ee6be
[wip-v2] menu lights tomfoolery
roydejong Mar 22, 2024
fb41988
[wip-v2] modals progress, join by server code
roydejong Mar 22, 2024
4673f42
[wip-v2] ui controls test temporary
roydejong Mar 30, 2024
abea65b
[wip-v2] quick play / create server / join by code flows
roydejong Mar 30, 2024
d8d5e72
[wip-v2] fix avatar editor UI nullref (event bindings)
roydejong Mar 31, 2024
b46e1b9
[wip-v2] show server type in server detail modal
roydejong Mar 31, 2024
39b7b61
[wip-v2] server filter options
roydejong Mar 31, 2024
f263e25
[wip-v2] use sub view titles
roydejong Apr 4, 2024
5d6763c
[wip-v2] MpCore 1.5 config & status integration basics
roydejong Apr 5, 2024
739a4f2
[wip-v2] multiplayer status checks / unavailable errors
roydejong Apr 5, 2024
708fe62
[wip-v2] master server repository /w remote updates
roydejong Apr 14, 2024
47cca8f
[wip-v2] mode selection views: form extension framework
roydejong Apr 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .idea/.idea.ServerBrowser.dir/.idea/.name

This file was deleted.

7 changes: 7 additions & 0 deletions .idea/.idea.ServerBrowser.dir/.idea/discord.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/.idea.ServerBrowserMod/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 0 additions & 53 deletions ATTRIBUTION.md

This file was deleted.

File renamed without changes
164 changes: 45 additions & 119 deletions Assets/Sprites.cs
Original file line number Diff line number Diff line change
@@ -1,134 +1,60 @@
using System.Linq;
using System.Reflection;
using System.Collections.Generic;
using System.Threading.Tasks;
using BeatSaberMarkupLanguage;
using UnityEngine;
using UnityEngine.UI;

namespace ServerBrowser.Assets
{
/// <summary>
/// Utilities for using embedded and downloaded sprite assets in the UI.
/// </summary>
/// <remarks>
/// Helper code taken from BeatSaverDownloader
/// Copyright (c) 2018 andruzzzhka (MIT Licensed)
/// </remarks>
internal static class Sprites
{
/// Announce icon
/// Icon by RemixIcon (https://www.iconfinder.com/iconsets/remixicon-media)
/// Licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
public static Sprite? Announce;
/// Announce icon, padded version
/// Icon by RemixIcon (https://www.iconfinder.com/iconsets/remixicon-media)
/// Licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
public static Sprite? AnnouncePadded;

/// BSSB logo
public static Sprite? ServerBrowserLogo;

/// BeatSaver logo
public static Sprite? BeatSaverLogo;

/// Crown icon
/// Icon by Ivan Boyko (https://www.iconfinder.com/visualpharm)
/// Licensed under CC BY 3.0 (https://creativecommons.org/licenses/by/3.0/)
public static Sprite? Crown;

/// Pencil icon
/// Icon by Github, MIT Licensed
/// Copyright (c) 2020 GitHub Inc
public static Sprite? Pencil;

/// Person icon
/// Icon by Ivan Boyko (https://www.iconfinder.com/visualpharm)
/// Licensed under CC BY 3.0 (https://creativecommons.org/licenses/by/3.0/)
public static Sprite? Person;

/// Portal icon
/// Straight Line icon set by designforeat (https://www.iconfinder.com/iconsets/technology-straight-line)
/// Licensed under CC BY 3.0 (https://creativecommons.org/licenses/by/3.0/)
public static Sprite? Portal;

/// Portal user icon
/// Straight Line icon set by designforeat (https://www.iconfinder.com/iconsets/technology-straight-line)
/// Licensed under CC BY 3.0 (https://creativecommons.org/licenses/by/3.0/)
public static Sprite? PortalUser;

/// Robot icon
/// Fluent Solid 24px vol.1 icon pack by Microsoft (https://www.iconfinder.com/iconsets/fluent-solid-24px-vol-1)
/// Licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
public static Sprite? Robot;

public static bool IsInitialized { get; private set; }

public static void Initialize()
{
IsInitialized = true;

Announce = LoadSpriteFromResources("ServerBrowser.Assets.Sprites.Announce.png");
AnnouncePadded = LoadSpriteFromResources("ServerBrowser.Assets.Sprites.AnnouncePadded.png");
ServerBrowserLogo = LoadSpriteFromResources("ServerBrowser.Assets.Sprites.BSSB.png");
BeatSaverLogo = LoadSpriteFromResources("ServerBrowser.Assets.Sprites.BeatSaver.png");
Crown = LoadSpriteFromResources("ServerBrowser.Assets.Sprites.Crown.png");
Pencil = LoadSpriteFromResources("ServerBrowser.Assets.Sprites.Pencil.png");
Person = LoadSpriteFromResources("ServerBrowser.Assets.Sprites.Person.png");
Portal = LoadSpriteFromResources("ServerBrowser.Assets.Sprites.Portal.png");
PortalUser = LoadSpriteFromResources("ServerBrowser.Assets.Sprites.PortalUser.png");
Robot = LoadSpriteFromResources("ServerBrowser.Assets.Sprites.Robot.png");
}

private static Sprite? LoadSpriteFromResources(string resourcePath, float pixelsPerUnit = 100.0f)
private const string ResourcePrefix = "ServerBrowser.Assets.Sprites.";

internal const string Avatar = "Avatar";
internal const string Checkmark = "Checkmark";
internal const string CircleDot = "CircleDot";
internal const string ComboCrown = "ComboCrown";
internal const string Crown = "Crown";
internal const string EnergyBolt = "EnergyBolt";
internal const string Friends = "Friends";
internal const string Ghost = "Ghost";
internal const string Global = "Global";
internal const string Lock = "Lock";
internal const string PlaceholderAvatar = "PlaceholderAvatar";
internal const string PlaceholderSabers = "PlaceholderSabers";
internal const string Player = "Player";
internal const string Plus = "Plus";
internal const string Random = "Random";
internal const string SaberClash = "SaberClash";
internal const string SaberUp = "SaberUp";
internal const string Search = "Search";
internal const string Spectator = "Spectator";
internal const string SuperFast = "SuperFast";

private static readonly Dictionary<string, Sprite> _loadedSprites = new();

internal static async Task<Sprite?> LoadAsync(string spriteName)
{
var rawData = GetResource(Assembly.GetCallingAssembly(), resourcePath);

if (rawData is null)
return null;

var sprite = LoadSpriteRaw(rawData, pixelsPerUnit);

if (sprite is null)
return null;

sprite.name = resourcePath;
var spritePath = $"{ResourcePrefix}{spriteName}.png";

if (_loadedSprites.TryGetValue(spritePath, out var cachedSprite))
if (cachedSprite != null)
return cachedSprite;

var sprite = await Utilities.LoadSpriteFromAssemblyAsync(spritePath);
if (sprite != null)
_loadedSprites[spritePath] = sprite;
return sprite;
}

private static byte[]? GetResource(Assembly asm, string resourceName)
{
var stream = asm.GetManifestResourceStream(resourceName);

if (stream is null)
return null;

var data = new byte[stream.Length];
stream.Read(data, 0, (int) stream.Length);
return data;
}

internal static Sprite? LoadSpriteRaw(byte[] image, float pixelsPerUnit = 100.0f,
SpriteMeshType spriteMeshType = SpriteMeshType.Tight)
internal static async Task SetAssetSpriteAsync(this Image image, string spriteName)
{
var texture = LoadTextureRaw(image);

if (texture is null)
return null;
var sprite = await LoadAsync(spriteName);

return LoadSpriteFromTexture(texture, pixelsPerUnit, spriteMeshType);
}

private static Texture2D? LoadTextureRaw(byte[] file)
{
if (!file.Any())
return null;

var texture = new Texture2D(2, 2);
return texture.LoadImage(file) ? texture : null;
}

private static Sprite LoadSpriteFromTexture(Texture2D spriteTexture, float pixelsPerUnit = 100.0f,
SpriteMeshType spriteMeshType = SpriteMeshType.Tight)
{
return Sprite.Create(spriteTexture, new Rect(0, 0, spriteTexture.width, spriteTexture.height),
new Vector2(0, 0), pixelsPerUnit, 0, spriteMeshType);
if (sprite == null || image == null)
return;

image.sprite = sprite;
}
}
}
Binary file removed Assets/Sprites/Announce.png
Binary file not shown.
Binary file removed Assets/Sprites/AnnouncePadded.png
Binary file not shown.
Binary file added Assets/Sprites/Avatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Assets/Sprites/BeatSaver.png
Binary file not shown.
Binary file added Assets/Sprites/Checkmark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Sprites/CircleDot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Sprites/ComboCrown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Sprites/Crown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Sprites/EnergyBolt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Sprites/Friends.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Sprites/Ghost.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Sprites/Global.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Sprites/Lock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Assets/Sprites/Pencil.png
Binary file not shown.
Binary file removed Assets/Sprites/Person.png
Binary file not shown.
Binary file added Assets/Sprites/PlaceholderAvatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Sprites/PlaceholderSabers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Sprites/Player.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Sprites/Plus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Assets/Sprites/Portal.png
Binary file not shown.
Binary file removed Assets/Sprites/PortalUser.png
Binary file not shown.
Binary file added Assets/Sprites/Random.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Assets/Sprites/Robot.png
Binary file not shown.
Binary file added Assets/Sprites/SaberClash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Sprites/SaberUp.png
Binary file added Assets/Sprites/Search.png
Binary file added Assets/Sprites/Spectator.png
Binary file added Assets/Sprites/SuperFast.png
Loading