Developer-mode setting gates the dev console
GameSettings.DeveloperMode (default ON) + a toggle in the settings panel. WorldScene only stands up the dev console (and, later, the dev spawner) when it is enabled, so without dev mode the backtick key does nothing. GodCameraSystem''s console arg is now nullable (no console when dev mode off). Localized settings.devmode ru/en. Build clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
d44e17198b
commit
cf2bc77882
@@ -108,6 +108,7 @@
|
||||
"settings.resolution": "Resolution",
|
||||
"settings.volume": "Volume",
|
||||
"settings.uiscale": "UI scale",
|
||||
"settings.devmode": "Developer mode",
|
||||
"settings.apply": "Apply",
|
||||
"settings.back": "Back",
|
||||
"pause.title": "Paused",
|
||||
|
||||
@@ -108,6 +108,7 @@
|
||||
"settings.resolution": "Разрешение",
|
||||
"settings.volume": "Громкость",
|
||||
"settings.uiscale": "Масштаб UI",
|
||||
"settings.devmode": "Режим разработчика",
|
||||
"settings.apply": "Применить",
|
||||
"settings.back": "Назад",
|
||||
"pause.title": "Пауза",
|
||||
|
||||
@@ -31,6 +31,9 @@ public sealed class GameSettings
|
||||
|
||||
/// <summary>Масштаб интерфейса (1 — обычный); применяется к Myra-десктопу всех сцен.</summary>
|
||||
public float UiScale { get; set; } = 1f;
|
||||
|
||||
/// <summary>Режим разработчика: открывает дев-консоль (backtick) и дев-спавнер. По умолчанию включён.</summary>
|
||||
public bool DeveloperMode { get; set; } = true;
|
||||
}
|
||||
|
||||
/// <summary>Чтение/запись <see cref="GameSettings"/> и применение их к движку.</summary>
|
||||
|
||||
@@ -183,31 +183,41 @@ public sealed class WorldScene : Scene
|
||||
desktop.Root = Ui.Screen(hudLabel, _inspect.Panel, speedBar, _pause.Root);
|
||||
|
||||
this.UseInspector(renderer);
|
||||
var console = this.UseDevConsole();
|
||||
RegisterCommands(console, content, atlases);
|
||||
console.Register(
|
||||
"light",
|
||||
"light [radius] — place a point light at the cursor (night shadows demo)",
|
||||
(c, args) =>
|
||||
{
|
||||
var radius =
|
||||
args.Length > 0
|
||||
? float.Parse(args[0], System.Globalization.CultureInfo.InvariantCulture)
|
||||
: 120f;
|
||||
var mouse = Mouse.GetState();
|
||||
var world = renderer.ScreenToWorld(new Vector2(mouse.X, mouse.Y));
|
||||
Store.CreateEntity(
|
||||
Transform2D.At(world),
|
||||
new PointLight
|
||||
{
|
||||
Radius = radius,
|
||||
Color = Color.White,
|
||||
Intensity = 0.9f,
|
||||
}
|
||||
);
|
||||
c.WriteLine($"light at {world.X:0},{world.Y:0} r{radius:0}");
|
||||
}
|
||||
);
|
||||
|
||||
// Режим разработчика (настройка, по умолчанию вкл): без него дев-консоль и спавнер не поднимаются.
|
||||
var devMode = GameSettingsStore.Load().DeveloperMode;
|
||||
MrGameEng.DevConsole.DevConsole? console = null;
|
||||
if (devMode)
|
||||
{
|
||||
console = this.UseDevConsole();
|
||||
RegisterCommands(console, content, atlases);
|
||||
console.Register(
|
||||
"light",
|
||||
"light [radius] — place a point light at the cursor (night shadows demo)",
|
||||
(c, args) =>
|
||||
{
|
||||
var radius =
|
||||
args.Length > 0
|
||||
? float.Parse(
|
||||
args[0],
|
||||
System.Globalization.CultureInfo.InvariantCulture
|
||||
)
|
||||
: 120f;
|
||||
var mouse = Mouse.GetState();
|
||||
var world = renderer.ScreenToWorld(new Vector2(mouse.X, mouse.Y));
|
||||
Store.CreateEntity(
|
||||
Transform2D.At(world),
|
||||
new PointLight
|
||||
{
|
||||
Radius = radius,
|
||||
Color = Color.White,
|
||||
Intensity = 0.9f,
|
||||
}
|
||||
);
|
||||
c.WriteLine($"light at {world.X:0},{world.Y:0} r{radius:0}");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
UpdateSystems.Add(new PlantGrowthSystem(_plants, calendar, climate, lighting, CellSize));
|
||||
UpdateSystems.Add(new PlantFruitingSystem(_plants, calendar, climate));
|
||||
|
||||
@@ -125,13 +125,13 @@ public sealed class GodCameraSystem(
|
||||
Entity cameraEntity,
|
||||
InputManager input,
|
||||
Renderer2D renderer,
|
||||
MrGameEng.DevConsole.DevConsole console,
|
||||
MrGameEng.DevConsole.DevConsole? console,
|
||||
Func<bool>? blocked = null
|
||||
) : BaseSystem
|
||||
{
|
||||
protected override void OnUpdateGroup()
|
||||
{
|
||||
if (console.IsOpen || blocked?.Invoke() == true)
|
||||
if (console?.IsOpen == true || blocked?.Invoke() == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -98,6 +98,16 @@ internal static class SettingsPanel
|
||||
// Громкость — кнопки −/+ с подписью процента.
|
||||
column.Widgets.Add(Volume(lang.Get("settings.volume"), settings, refreshers));
|
||||
|
||||
// Режим разработчика — тумблер (дев-консоль и спавнер; по умолчанию включён).
|
||||
column.Widgets.Add(
|
||||
Toggle(
|
||||
lang.Get("settings.devmode"),
|
||||
() => settings.DeveloperMode,
|
||||
v => settings.DeveloperMode = v,
|
||||
refreshers
|
||||
)
|
||||
);
|
||||
|
||||
column.Widgets.Add(new Label { Height = 8 });
|
||||
var buttons = Ui.Row(10);
|
||||
buttons.Widgets.Add(Ui.Button(lang.Get("settings.apply"), onApply, width: 150));
|
||||
|
||||
Reference in New Issue
Block a user