mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-11-07 12:07:05 +01:00
Replace MenuManagerCS2 with Panorama UI Kit for the admin menus and css_vote. Layout names (menu, vote, banner, toast) are configurable under MenuConfig and preloaded on startup; MenuType is removed and ConfigVersion bumped to 26. - Drop MenuManagerApi.dll and the old chat menu classes - Reference PanoramaUiKit.Shared.dll, bump CounterStrikeSharp to 1.0.376 - Add .editorconfig and CODING_CONVENTIONS.md, apply them codebase-wide - Remove the CS2-SimpleAdmin-docs site - Rewrite README for the fork
2.3 KiB
2.3 KiB
Coding conventions
Rules for all C# in this repository. .editorconfig enforces most of them: run
dotnet format CS2-SimpleAdmin.sln before committing.
Types
- Always write the explicit type. No
var.List<CCSPlayerController> players = Helper.GetValidPlayers(); foreach (CCSPlayerController player in players) { ... } - The only exception is an anonymous type, which has no name (Dapper parameters):
var parameters = new { ... };. - Target-typed
new()and collection expressions ([]) are fine: the type is already written on the left.
Conditions
- No ternary operator (
c ? a : b). Write anif, or extract a small helper that returns.string status = "OFF"; if (loaded) { status = "ON"; } - Always use braces, even for one statement. No single-line
if (x) return;. switchexpressions on a value are fine (penaltyType switch { ... }).??and?.are fine.
Layout
- Allman braces, 4 spaces, LF line endings.
- File-scoped namespaces.
usingdirectives outside the namespace,Systemfirst, no unused ones.- Early return to keep nesting shallow.
Naming
- PascalCase for types, methods, properties, constants. camelCase for locals and parameters.
_camelCasefor private fields. - A lambda parameter you do not use is
_. Never assign to a discard (_ = ...) inside a lambda whose parameter is_: the assignment goes to the parameter.
Duplication
- When the same expression shows up in several commands, add a helper in
Helper(seeGetCallerName,GetReasonOrUnknown,GetArgsReason,GetAdminInfo,GetLogName,Truncate,HasCommandPermission).
Comments
- Comment why, not what. No commented-out code: git keeps the history.
- XML
<summary>on public members and on anything non-obvious.
UI
- All UI goes through the Panorama UI Kit (
Menus/UiKit.cs). Never call CounterStrikeSharp chat/center menus directly. - Menus are built with
MenuBuilder. A sub-menu returnsbuilder.WithBackButton(); the kit draws the back button. - An option closes the menu after its action, unless it passes
keepOpen: trueor its action opens another menu. - Panorama does not render chat color tags (
{red},ChatColors): keep them out of UI text. - Native calls are not thread-safe: after an
await, come back withServer.NextWorldUpdateAsyncbefore touching the UI.