Skip to content

Commit

Permalink
Other fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Feodor0090 committed Jan 24, 2023
1 parent 92d59b7 commit b2e6277
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace osu.Game.Rulesets.OvkTab.UI.Components.Account
{
public class LogoutDialog : PopupDialog
public partial class LogoutDialog : PopupDialog
{
public LogoutDialog(Action callback)
{
Expand Down
11 changes: 6 additions & 5 deletions osu.Game.Rulesets.OvkTab/UI/Components/Account/VkLoginBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal partial class VkLoginBlock : Container
[Resolved]
private OvkOverlay ovk { get; set; }

private OvkTabConfig config;
private OvkTabConfig? config;
private readonly OvkTabRuleset ruleset;

private readonly Bindable<bool> keepSession = new();
Expand All @@ -36,10 +36,10 @@ public VkLoginBlock(OvkTabRuleset ruleset)
}

[BackgroundDependencyLoader]
void load(IRulesetConfigCache c)
void load(IRulesetConfigCache? c)
{
RelativeSizeAxes = Axes.Both;
if (ruleset != null) config = c?.GetConfigFor(ruleset) as OvkTabConfig;
config = c?.GetConfigFor(ruleset) as OvkTabConfig;
string loginStr = config?.Get<string>(OvkTabRulesetSetting.Login) ?? string.Empty;
Add(new FillFlowContainer
{
Expand Down Expand Up @@ -96,7 +96,8 @@ void load(IRulesetConfigCache c)
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Text = "This is an experimental project, that works via multiple hacks." +
" If you experience problems with the game, uninstall this extension before attempting to diagnose them. 2FA not supported, you will have to disable it.",
" If you experience problems with the game, uninstall this extension before attempting to diagnose them. 2FA not supported, you will have to disable it. "
+ "Your login, id and token will be stored in osu! database as plain text! No encryption yet, at all!",
Position = new(0, -40),
TextAnchor = Anchor.TopCentre,
Padding = new() { Horizontal = 40 }
Expand All @@ -105,7 +106,7 @@ void load(IRulesetConfigCache c)
{
Text = "GitHub page",
Action = () => { Dependencies.Get<OsuGame>().HandleLink(new LinkDetails(LinkAction.External, "https://github.com/Feodor0090/ovktab")); },
Height = 30,
Height = 40,
Width = 200,
Position = new(0, -5),
Origin = Anchor.BottomCentre,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ void repost()
{
if (postId == 0 || repostButton.state.Value) return;

RepostDialog dialog = new(ownerId, postId, ovkApiHub, ovkOverlay?.newsLoading, x =>
RepostDialog dialog = new(ownerId, postId, ovkOverlay?.newsLoading, x =>
{
ovkOverlay?.newsLoading.Hide();

Expand Down
36 changes: 26 additions & 10 deletions osu.Game.Rulesets.OvkTab/UI/Components/PostElements/RepostDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,52 @@
using osu.Game.Overlays.Dialog;
using osu.Game.Rulesets.OvkTab.API;
using System;
using osu.Framework.Allocation;

namespace osu.Game.Rulesets.OvkTab.UI.Components.PostElements
{
public class RepostDialog : PopupDialog
public partial class RepostDialog : PopupDialog
{
private readonly int ownerId;
private readonly int postId;
private readonly LoadingLayer? newsLoading;
private readonly Action<(int?, int?)?>? callback;

public RepostDialog(int ownerId, int postId, IOvkApiHub api, LoadingLayer newsLoading, Action<(int?, int?)?> callback)
[Resolved]
private IOvkApiHub? api { get; set; }

public RepostDialog(int ownerId, int postId, LoadingLayer? newsLoading, Action<(int?, int?)?>? callback = null)
{
this.ownerId = ownerId;
this.postId = postId;
this.newsLoading = newsLoading;
this.callback = callback;
Icon = FontAwesome.Solid.Bullhorn;
HeaderText = "Confirm the repost";
BodyText = "Everybody will see it. Do you want it?";

Buttons = new PopupDialogButton[]
{
new PopupDialogOkButton
{
Text = @"Yes. Totally. Repost it.",
Action = async () =>
{
if(ownerId==0 || postId==0) return;
if(api == null) return;
if(newsLoading!=null) Schedule(newsLoading.Show);
var r = await api.Repost(ownerId, postId);
callback(r);
}
Action = repost
},
new PopupDialogCancelButton
{
Text = @"Shit, go back!",
},
};
}

private async void repost()
{
if (ownerId == 0 || postId == 0 || api == null)
return;

if (newsLoading != null) Schedule(newsLoading.Show);
var r = await api.Repost(ownerId, postId);
callback?.Invoke(r);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
using System;
using osu.Framework.Graphics.Sprites;


namespace osu.Game.Rulesets.OvkTab.UI.Components.PostElements
{
public class SendDialog : PopupDialog
public partial class SendDialog : PopupDialog
{
public SendDialog(string chat, Action callback)
{
Expand Down
24 changes: 12 additions & 12 deletions osu.Game.Rulesets.OvkTab/UI/Components/PostElements/SendPopover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ namespace osu.Game.Rulesets.OvkTab.UI.Components.PostElements
{
public partial class SendPopover : OsuPopover
{
readonly FillFlowContainer content;
private readonly FillFlowContainer content;
private readonly int ownerId;
private readonly int postId;

[Resolved]
private IDialogOverlay dialogOverlay { get; set; } = null!;

[Resolved]
private IOvkApiHub api { get; set; } = null!;

public SendPopover(int ownerId, int postId)
{
this.ownerId = ownerId;
Expand All @@ -29,22 +35,16 @@ public SendPopover(int ownerId, int postId)
});
}

[Resolved]
private IDialogOverlay dialogOverlay { get; set; }

[Resolved]
private IOvkApiHub api { get; set; }

[BackgroundDependencyLoader(true)]
async void load()
[BackgroundDependencyLoader]
private void load()
{
foreach (var x in await api.GetDialogsList())
foreach (var x in api.GetDialogsList().Result)
{
var u = x.Item1;
if (u == null)
u = new SimpleVkUser()
u = new SimpleVkUser
{
name = x.Item2.Conversation.ChatSettings?.Title,
name = x.Item2.Conversation.ChatSettings?.Title ?? string.Empty,
avatarUrl = x.Item2.Conversation.ChatSettings?.Photo?.Photo100.AbsoluteUri
};
content.Add(new DrawableActionableDialog(u, (int)x.Item2.Conversation.Peer.Id, send));
Expand Down
19 changes: 9 additions & 10 deletions osu.Game.Rulesets.OvkTab/UI/Components/Posts/DrawableVkWall.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Textures;
using osu.Game.Rulesets.OvkTab.API;
using osu.Game.Rulesets.OvkTab.UI.Components.PostElements;
using System;
using VkNet.Model.Attachments;

namespace osu.Game.Rulesets.OvkTab.UI.Components.Posts
{
public class DrawableVkWall : FillFlowContainer
public sealed partial class DrawableVkWall : FillFlowContainer
{
Wall post;
SimpleVkUser author;
private readonly Wall post;
private readonly SimpleVkUser author;

public DrawableVkWall(Wall post, SimpleVkUser author)
{
this.post = post;
Expand All @@ -24,22 +24,21 @@ public DrawableVkWall(Wall post, SimpleVkUser author)
Margin = new() { Bottom = 25 };
}

[BackgroundDependencyLoader(true)]
void load(OsuGame game, LargeTextureStore lts)
[BackgroundDependencyLoader]
private void load()
{
Children = new Drawable[]
{
new PostHeader(author, post.Date??DateTime.UtcNow),
new TextFlowContainer()
new PostHeader(author, post.Date ?? DateTime.UtcNow),
new TextFlowContainer
{
Text = post.Text,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new() { Horizontal = 5 }
Padding = new MarginPadding { Horizontal = 5 }
}
};
AddRange(post.Attachments.ParseAttachments(Dependencies));
// footer
Add(new PostFooter(post));
}
}
Expand Down
44 changes: 25 additions & 19 deletions osu.Game.Rulesets.OvkTab/UI/Components/UserPanel.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.OvkTab.API;
using osuTK;
using VkNet.Model;

namespace osu.Game.Rulesets.OvkTab.UI.Components
{
public class UserPanel : BeatSyncedContainer
public partial class UserPanel : BeatSyncedContainer, IHasTooltip
{
SimpleVkUser user;
private Box bg;
private readonly SimpleVkUser user;
private Box bg = null!;

public UserPanel(SimpleVkUser user)
{
Expand All @@ -26,43 +29,46 @@ public UserPanel(SimpleVkUser user)
}

[BackgroundDependencyLoader]
void load(OsuColour colour)
private void load(OsuColour colour)
{
Add(bg = new Box()
Add(bg = new Box
{
Colour = Colour4.Black,
Colour = Colour4.White,
Alpha = 0.3f,
RelativeSizeAxes = Axes.Both,
});
LoadComponentAsync(new DrawableVkAvatar(user)
{
Position = new(30)
}, x =>
{
Add(x);
});

OsuSpriteText t;
Add(t = new OsuSpriteText()
Add(t = new OsuSpriteText
{
Text = user.name,
Position = new(65, 0),
Position = new Vector2(65, 0),
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
Font = OsuFont.GetFont(size: 24),
});

if (user.full is User u)
{
if (u.Online ?? false)
t.Colour = colour.Lime;
};
}

LoadComponentAsync(new DrawableVkAvatar(user)
{
Position = new(30)
}, Add);
}
Colour4 kiai = Colour4.FromHex("222");
Colour4 normal = Colour4.FromHex("111");

private readonly Colour4 kiai = Colour4.FromHex("BBB");
private readonly Colour4 normal = Colour4.FromHex("EEE");

protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
{
base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);
bg?.FlashColour(effectPoint.KiaiMode ? kiai : normal, timingPoint.BeatLength);
bg.FlashColour(effectPoint.KiaiMode ? kiai : normal, timingPoint.BeatLength);
}

public LocalisableString TooltipText => "click the avatar to browse the wall";
}
}

0 comments on commit b2e6277

Please sign in to comment.