Skip to content

Commit

Permalink
Merge branch 'master' into hands
Browse files Browse the repository at this point in the history
  • Loading branch information
Schrodinger71 authored Jan 3, 2025
2 parents 3f659b4 + a7f9aad commit cd4406e
Show file tree
Hide file tree
Showing 20 changed files with 360 additions and 247 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/build-test-debug-win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Build & Test Debug Windows

on:
push:
branches: [ master, staging, trying ]
merge_group:
pull_request:
types: [ opened, reopened, synchronize, ready_for_review ]
branches: [ master ]
workflow_dispatch: # ручной запуск

jobs:
build:
if: github.actor != 'IanComradeBot' && github.event.pull_request.draft == false
strategy:
matrix:
os: [ windows-latest ]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout Master
uses: actions/[email protected]

- name: Setup Submodule
run: |
git submodule update --init --recursive
- name: Pull engine updates
uses: space-wizards/[email protected]

- name: Update Engine Submodules
run: |
cd RobustToolbox/
git submodule update --init --recursive
- name: Setup .NET Core
uses: actions/[email protected]
with:
dotnet-version: 8.0.x

- name: Install dependencies
run: dotnet restore

- name: Build Project
run: dotnet build --configuration DebugOpt --no-restore /p:WarningsAsErrors=nullable /m

- name: Run Content.Tests
run: dotnet test --no-build --configuration DebugOpt Content.Tests/Content.Tests.csproj -- NUnit.ConsoleOut=0

- name: Run Content.IntegrationTests
shell: pwsh
run: |
$env:DOTNET_gcServer=1
dotnet test --no-build --configuration DebugOpt Content.IntegrationTests/Content.IntegrationTests.csproj -- NUnit.ConsoleOut=0 NUnit.MapWarningTo=Failed
ci-success:
name: Build & Test Debug
needs:
- build
runs-on: windows-latest
steps:
- name: CI succeeded
run: exit 0
111 changes: 56 additions & 55 deletions Content.Client/ADT/MiningShop/MiningShopBui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public sealed class MiningShopBui : BoundUserInterface
[Dependency] private readonly IResourceCache _resource = default!;
private readonly MiningPointsSystem _miningPoints;
private MiningShopWindow? _window;
private List<SharedMiningShopSectionPrototype> _sections = new();
public MiningShopBui(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
_miningPoints = EntMan.System<MiningPointsSystem>();
Expand All @@ -34,63 +35,61 @@ protected override void Open()
_window.OnClose += Close;
_window.Title = EntMan.GetComponentOrNull<MetaDataComponent>(Owner)?.EntityName ?? "MiningShop";

if (EntMan.TryGetComponent(Owner, out MiningShopComponent? vendor))
if (!EntMan.TryGetComponent(Owner, out MiningShopComponent? vendor))
return;
var sections = _prototype.EnumeratePrototypes<SharedMiningShopSectionPrototype>().ToList();
sections.Sort((x, y) => x.Name[0].CompareTo(x.Name[0]));

foreach (var section in sections)
{
for (var sectionIndex = 0; sectionIndex < vendor.Sections.Count; sectionIndex++)
var uiSection = new MiningShopSection();
uiSection.Label.SetMessage(GetSectionName(section));
_sections.Add(section);

foreach (var entry in section.Entries)
{
var section = vendor.Sections[sectionIndex];
var uiEntry = new MiningShopEntry();

if (_prototype.TryIndex(entry.Id, out var entity))
{
uiEntry.Texture.Textures = SpriteComponent.GetPrototypeTextures(entity, _resource)
.Select(o => o.Default)
.ToList();
uiEntry.Panel.Button.Label.Text = entry.Name?.Replace("\\n", "\n") ?? entity.Name;

var uiSection = new MiningShopSection();
uiSection.Label.SetMessage(GetSectionName(section));
var name = entity.Name;
var color = MiningShopPanel.DefaultColor;
var borderColor = MiningShopPanel.DefaultBorderColor;
var hoverColor = MiningShopPanel.DefaultBorderColor;

uiEntry.Panel.Color = color;
uiEntry.Panel.BorderColor = borderColor;
uiEntry.Panel.HoveredColor = hoverColor;

for (var entryIndex = 0; entryIndex < section.Entries.Count; entryIndex++)
{
var entry = section.Entries[entryIndex];
var uiEntry = new MiningShopEntry();

if (_prototype.TryIndex(entry.Id, out var entity))
{
uiEntry.Texture.Textures = SpriteComponent.GetPrototypeTextures(entity, _resource)
.Select(o => o.Default)
.ToList();
uiEntry.Panel.Button.Label.Text = entry.Name?.Replace("\\n", "\n") ?? entity.Name;

var name = entity.Name;
var color = MiningShopPanel.DefaultColor;
var borderColor = MiningShopPanel.DefaultBorderColor;
var hoverColor = MiningShopPanel.DefaultBorderColor;

uiEntry.Panel.Color = color;
uiEntry.Panel.BorderColor = borderColor;
uiEntry.Panel.HoveredColor = hoverColor;

var msg = new FormattedMessage();
msg.AddText(name);
msg.PushNewline();

if (!string.IsNullOrWhiteSpace(entity.Description))
msg.AddText(entity.Description);

var tooltip = new Tooltip();
tooltip.SetMessage(msg);
tooltip.MaxWidth = 250f;

uiEntry.TooltipLabel.ToolTip = entity.Description;
uiEntry.TooltipLabel.TooltipDelay = 0;
uiEntry.TooltipLabel.TooltipSupplier = _ => tooltip;

var sectionI = sectionIndex;
var entryI = entryIndex;
uiEntry.Panel.Button.OnPressed += _ => OnButtonPressed(sectionI, entryI);
}

uiSection.Entries.AddChild(uiEntry);
var msg = new FormattedMessage();
msg.AddText(name);
msg.PushNewline();

if (!string.IsNullOrWhiteSpace(entity.Description))
msg.AddText(entity.Description);

var tooltip = new Tooltip();
tooltip.SetMessage(msg);
tooltip.MaxWidth = 250f;

uiEntry.TooltipLabel.ToolTip = entity.Description;
uiEntry.TooltipLabel.TooltipDelay = 0;
uiEntry.TooltipLabel.TooltipSupplier = _ => tooltip;

uiEntry.Panel.Button.OnPressed += _ => OnButtonPressed(entry);
}

_window.Sections.AddChild(uiSection);
uiSection.Entries.AddChild(uiEntry);
}

_window.Sections.AddChild(uiSection);
}

_window.Express.OnPressed += _ => OnExpressDeliveryButtonPressed();
_window.Search.OnTextChanged += OnSearchChanged;

Expand All @@ -99,9 +98,9 @@ protected override void Open()
_window.OpenCentered();
}

private void OnButtonPressed(int sectionIndex, int entryIndex)
private void OnButtonPressed(Content.Shared.ADT.MiningShop.MiningShopEntry entry)
{
var msg = new MiningShopBuiMsg(sectionIndex, entryIndex);
var msg = new MiningShopBuiMsg(entry);
SendMessage(msg);
Refresh();
}
Expand Down Expand Up @@ -168,18 +167,20 @@ public void Refresh()

_window.PointsLabel.Text = $"Осталось очков: {userpoints}";

for (var sectionIndex = 0; sectionIndex < vendor.Sections.Count; sectionIndex++)
var sections = _prototype.EnumeratePrototypes<SharedMiningShopSectionPrototype>();

for (var sectionIndex = 0; sectionIndex < _sections.Count; sectionIndex++)
{
var section = vendor.Sections[sectionIndex];
var uiSection = (MiningShopSection) _window.Sections.GetChild(sectionIndex);
var section = _sections[sectionIndex];
var uiSection = (MiningShopSection)_window.Sections.GetChild(sectionIndex);
uiSection.Label.SetMessage(GetSectionName(section));

var sectionDisabled = false;

for (var entryIndex = 0; entryIndex < section.Entries.Count; entryIndex++)
{
var entry = section.Entries[entryIndex];
var uiEntry = (MiningShopEntry) uiSection.Entries.GetChild(entryIndex);
var uiEntry = (MiningShopEntry)uiSection.Entries.GetChild(entryIndex);
var disabled = sectionDisabled;

if (userpoints < entry.Price)
Expand Down Expand Up @@ -210,7 +211,7 @@ protected override void ReceiveMessage(BoundUserInterfaceMessage message)
}
}

private FormattedMessage GetSectionName(SharedMiningShopSection section)
private FormattedMessage GetSectionName(SharedMiningShopSectionPrototype section)
{
var name = new FormattedMessage();
name.PushTag(new MarkupNode("bold", new MarkupParameter(section.Name.ToUpperInvariant()), null));
Expand Down
80 changes: 77 additions & 3 deletions Content.Server/Administration/Managers/AdminManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.Errors;
using Robust.Shared.Utility;
using Content.Shared.ADT.CCVar;
using Content.Server.Discord;
using Serilog;


namespace Content.Server.Administration.Managers
Expand All @@ -36,6 +39,7 @@ public sealed partial class AdminManager : IAdminManager, IPostInjectInit, IConG
[Dependency] private readonly IChatManager _chat = default!;
[Dependency] private readonly ToolshedManager _toolshed = default!;
[Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly DiscordWebhook _discord = default!;

private readonly Dictionary<ICommonSession, AdminReg> _admins = new();
private readonly HashSet<NetUserId> _promotedPlayers = new();
Expand Down Expand Up @@ -76,7 +80,7 @@ public bool IsAdmin(ICommonSession session, bool includeDeAdmin = false)
return null;
}

public void DeAdmin(ICommonSession session)
public async void DeAdmin(ICommonSession session) // ADT-tweak: add "async"
{
if (!_admins.TryGetValue(session, out var reg))
{
Expand All @@ -97,6 +101,22 @@ public void DeAdmin(ICommonSession session)

SendPermsChangedEvent(session);
UpdateAdminStatus(session);
// ADT-Tweak-start: Постит сообщение в чат при деадмине
if (!string.IsNullOrEmpty(_cfg.GetCVar(ADTDiscordWebhookCCVars.DiscordAdminchatWebhook)))
{
var webhookUrl = _cfg.GetCVar(ADTDiscordWebhookCCVars.DiscordAdminchatWebhook);
if (webhookUrl == null)
return;
if (await _discord.GetWebhook(webhookUrl) is not { } webhookData)
return;
var payload = new WebhookPayload
{
Content = $"**Снял права**: **{session.Name}**"
};
var identifier = webhookData.ToIdentifier();
await _discord.CreateMessage(identifier, payload);
}
// ADT-Tweak-end
}

public void Stealth(ICommonSession session)
Expand Down Expand Up @@ -137,7 +157,7 @@ public void UnStealth(ICommonSession session)
// _chat.SendAdminAnnouncement(Loc.GetString("admin-manager-self-disable-stealth", ("exStealthAdminName", session.Name)), flagWhitelist: AdminFlags.Stealth);
}

public void ReAdmin(ICommonSession session)
public async void ReAdmin(ICommonSession session) // ADT-tweak: add "async"
{
if (!_admins.TryGetValue(session, out var reg))
{
Expand Down Expand Up @@ -168,6 +188,22 @@ public void ReAdmin(ICommonSession session)

SendPermsChangedEvent(session);
UpdateAdminStatus(session);
// ADT-Tweak-start: Постит сообщение в чат при деадмине
if (!string.IsNullOrEmpty(_cfg.GetCVar(ADTDiscordWebhookCCVars.DiscordAdminchatWebhook)))
{
var webhookUrl = _cfg.GetCVar(ADTDiscordWebhookCCVars.DiscordAdminchatWebhook);
if (webhookUrl == null)
return;
if (await _discord.GetWebhook(webhookUrl) is not { } webhookData)
return;
var payload = new WebhookPayload
{
Content = $"**Вернул права**: **{session.Name}**"
};
var identifier = webhookData.ToIdentifier();
await _discord.CreateMessage(identifier, payload);
}
// ADT-Tweak-end
}

public async void ReloadAdmin(ICommonSession player)
Expand Down Expand Up @@ -353,13 +389,31 @@ private void PlayerStatusChanged(object? sender, SessionStatusEventArgs e)
}
else
{
DisconnectedAdminMaybe(e.Session); // ADT-Tweak
_chat.SendAdminAnnouncement(Loc.GetString("admin-manager-admin-logout-message",
("name", e.Session.Name)));
}
}
}
}

// ADT-Tweak-start: Кидает инфу в дис если админ вышел из игры
private async void DisconnectedAdminMaybe(ICommonSession session)
{
if (!string.IsNullOrEmpty(_cfg.GetCVar(ADTDiscordWebhookCCVars.DiscordAdminchatWebhook)))
{
var webhookUrl = _cfg.GetCVar(ADTDiscordWebhookCCVars.DiscordAdminchatWebhook);
var senderName = session.Name;
if (await _discord.GetWebhook(webhookUrl) is not { } webhookData)
return;
var payload = new WebhookPayload
{
Content = $"**Оповещение: Админ ВЫШЕЛ {senderName}**"
};
var identifier = webhookData.ToIdentifier();
await _discord.CreateMessage(identifier, payload);
}
}
// ADT-Tweak-end
private async void LoginAdminMaybe(ICommonSession session)
{
var adminDat = await LoadAdminData(session);
Expand Down Expand Up @@ -398,6 +452,26 @@ private async void LoginAdminMaybe(ICommonSession session)
{
_chat.SendAdminAnnouncement(Loc.GetString("admin-manager-admin-login-message",
("name", session.Name)));
// ADT-Tweak-start: Кидает инфу в дис если админ зашёл
if (!string.IsNullOrEmpty(_cfg.GetCVar(ADTDiscordWebhookCCVars.DiscordAdminchatWebhook)))
{
var webhookUrl = _cfg.GetCVar(ADTDiscordWebhookCCVars.DiscordAdminchatWebhook);
var senderAdmin = GetAdminData(session);
if (senderAdmin == null)
return;
var senderName = session.Name;
if (!string.IsNullOrEmpty(senderAdmin.Title))
senderName += $"\\[{senderAdmin.Title}\\]";
if (await _discord.GetWebhook(webhookUrl) is not { } webhookData)
return;
var payload = new WebhookPayload
{
Content = $"**Оповещение: Админ зашёл {senderName}**"
};
var identifier = webhookData.ToIdentifier();
await _discord.CreateMessage(identifier, payload);
}
// ADT-Tweak-end
}
}

Expand Down
Loading

0 comments on commit cd4406e

Please sign in to comment.