Files
aego/modules/debug/settings.go
T
sanspie 67e2d77823 Stage 11f1–11f2: documentation style and rewrite (D347)
docs/style.md, docs/glossary.md, style checks DOC010–DOC023 and docs report; the site in a light theme; the Editor, Aego Script, Gameplay, Physics, Scenes, Rendering, Tools and Reference sections rewritten.
2026-10-25 15:31:22 +03:00

49 lines
1.4 KiB
Go

package debug
import (
"aego/core/errs"
"aego/engine/module"
"aego/schema"
)
type Settings struct {
Enabled bool `aego:"enabled"`
MaxPrimitives int32 `aego:"maxPrimitives"`
MaxPerChannel int32 `aego:"maxPerChannel"`
}
func DefaultSettings() Settings {
return Settings{Enabled: true, MaxPrimitives: 16384, MaxPerChannel: 4096}
}
func (s Settings) normalized() Settings {
d := DefaultSettings()
if s.MaxPrimitives <= 0 {
s.MaxPrimitives = d.MaxPrimitives
}
if s.MaxPerChannel <= 0 {
s.MaxPerChannel = d.MaxPerChannel
}
return s
}
func validate(s *Settings) error {
if s.MaxPrimitives < 0 || s.MaxPrimitives > 1<<20 || s.MaxPerChannel < 0 {
return errs.New(errs.ProjectBadFile, "debug: maxPrimitives must be between 0 and 1048576, maxPerChannel must not be negative")
}
return nil
}
func registerSettings(r *module.Registry) error {
if err := module.Struct[Settings](r,
schema.Name("debug.Settings"),
schema.FieldDoc("enabled", "Turns debug drawing on. When off, every draw call does nothing."),
schema.FieldDoc("maxPrimitives", "Primitives kept per world; extra ones are dropped and counted. Zero uses 16384."),
schema.FieldDoc("maxPerChannel", "Primitives kept per channel. Zero uses 4096."),
); err != nil {
return err
}
r.ProjectSection(module.SectionDesc[Settings]{ID: ID, Title: "Debug Draw", Order: 400, Default: DefaultSettings, Validate: validate})
return nil
}