Fix no-start issue
This commit is contained in:
Vendored
+3
-3
@@ -10,9 +10,9 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"mode": "debug",
|
"mode": "debug",
|
||||||
"program": "rhemawave.go",
|
"program": "rhemawave.go",
|
||||||
"env": {
|
// "env": {
|
||||||
"DEBUGINFOD_URLS": ""
|
// "DEBUGINFOD_URLS": ""
|
||||||
}
|
// }
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -67,6 +67,7 @@ import (
|
|||||||
"rhemawavetech.com/rhemawave/internal/colors"
|
"rhemawavetech.com/rhemawave/internal/colors"
|
||||||
"rhemawavetech.com/rhemawave/internal/db"
|
"rhemawavetech.com/rhemawave/internal/db"
|
||||||
"rhemawavetech.com/rhemawave/internal/fontManager"
|
"rhemawavetech.com/rhemawave/internal/fontManager"
|
||||||
|
"rhemawavetech.com/rhemawave/internal/logger"
|
||||||
"rhemawavetech.com/rhemawave/internal/mixer"
|
"rhemawavetech.com/rhemawave/internal/mixer"
|
||||||
colorPattern "rhemawavetech.com/rhemawave/internal/pattern/color"
|
colorPattern "rhemawavetech.com/rhemawave/internal/pattern/color"
|
||||||
linePattern "rhemawavetech.com/rhemawave/internal/pattern/line"
|
linePattern "rhemawavetech.com/rhemawave/internal/pattern/line"
|
||||||
@@ -207,6 +208,7 @@ func (p *ScrollerPage) Init(ctx *PageCtx) error {
|
|||||||
return fmt.Errorf("unable to fetch font 'Scrambled'")
|
return fmt.Errorf("unable to fetch font 'Scrambled'")
|
||||||
}
|
}
|
||||||
p.font = font
|
p.font = font
|
||||||
|
logger.Info("Font name: %s", font.Name)
|
||||||
|
|
||||||
p.Base.Init(ctx)
|
p.Base.Init(ctx)
|
||||||
|
|
||||||
@@ -216,11 +218,14 @@ func (p *ScrollerPage) Init(ctx *PageCtx) error {
|
|||||||
return fmt.Errorf("text shader not found")
|
return fmt.Errorf("text shader not found")
|
||||||
}
|
}
|
||||||
p.shader = textShader
|
p.shader = textShader
|
||||||
|
logger.Info("Shader Program ID: %d", textShader.ProgramID)
|
||||||
|
logger.Info("p.shader Program ID: %d", p.shader.ProgramID)
|
||||||
|
|
||||||
// Load proclamation words from database
|
// Load proclamation words from database
|
||||||
if err := p.loadProclamations(); err != nil {
|
if err := p.loadProclamations(); err != nil {
|
||||||
// Don't stop execution, just show fallback words
|
logger.Error("Error loading proclamations: %v", err)
|
||||||
p.words = strings.Fields("No Proclamations Selected!")
|
p.Context.NavigateTo(PROCLAMATIONS)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
p.wordIndex = 0
|
p.wordIndex = 0
|
||||||
|
|
||||||
@@ -254,14 +259,17 @@ func (p *ScrollerPage) Init(ctx *PageCtx) error {
|
|||||||
p.lines = NewLineDeque(nLines * 2)
|
p.lines = NewLineDeque(nLines * 2)
|
||||||
|
|
||||||
// Calculate space width using the SCALE ratio, not the font size int
|
// Calculate space width using the SCALE ratio, not the font size int
|
||||||
spaceGlyph, ok := fm.GetGlyph(p.font.Name, ' ')
|
spaceGlyph, ok := fm.GetGlyph(font.Name, ' ')
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("failed to get space glyph")
|
return fmt.Errorf("failed to get space glyph")
|
||||||
}
|
}
|
||||||
p.spaceWidth = int32(float32(spaceGlyph.Advance) * p.fontScale)
|
p.spaceWidth = int32(float32(spaceGlyph.Advance) * p.fontScale)
|
||||||
|
|
||||||
// Get line height using the SCALE ratio
|
// Get line height using the SCALE ratio
|
||||||
tmpStrID, _, H, err := fm.NewCreateStringTexture(p.font.Name, "Mg", p.shader)
|
if fm == nil {
|
||||||
|
logger.Error("FontManager somehow ended up nil...")
|
||||||
|
}
|
||||||
|
tmpStrID, _, H, err := fm.NewCreateStringTexture(font.Name, "Mg", p.shader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create sample texture: %w", err)
|
return fmt.Errorf("failed to create sample texture: %w", err)
|
||||||
}
|
}
|
||||||
@@ -270,7 +278,7 @@ func (p *ScrollerPage) Init(ctx *PageCtx) error {
|
|||||||
|
|
||||||
p.lineCtx = &linePattern.LineRenderContext{
|
p.lineCtx = &linePattern.LineRenderContext{
|
||||||
ScreenWidth: p.ScreenWidth,
|
ScreenWidth: p.ScreenWidth,
|
||||||
Font: p.font,
|
Font: font,
|
||||||
FontScale: p.fontScale,
|
FontScale: p.fontScale,
|
||||||
SpaceWidth: p.spaceWidth,
|
SpaceWidth: p.spaceWidth,
|
||||||
}
|
}
|
||||||
@@ -324,7 +332,7 @@ func (p *ScrollerPage) loadProclamations() error {
|
|||||||
|
|
||||||
// Build word list from selected, available proclamations
|
// Build word list from selected, available proclamations
|
||||||
for _, proclamation := range proclamations {
|
for _, proclamation := range proclamations {
|
||||||
if proclamation.Selected && proclamation.Available {
|
if proclamation.Selected {
|
||||||
// Split content into words and add to list
|
// Split content into words and add to list
|
||||||
words := strings.Fields(proclamation.Content)
|
words := strings.Fields(proclamation.Content)
|
||||||
p.words = append(p.words, words...)
|
p.words = append(p.words, words...)
|
||||||
@@ -332,8 +340,7 @@ func (p *ScrollerPage) loadProclamations() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(p.words) == 0 {
|
if len(p.words) == 0 {
|
||||||
p.words = strings.Fields("No Proclamations Selected!")
|
return fmt.Errorf("Failed to load proclamations, no proclamations selected!")
|
||||||
return fmt.Errorf("no proclamations selected or available")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -590,25 +597,39 @@ func (p *ScrollerPage) Destroy() error {
|
|||||||
mixer.Stop(1000, p.Base.Context.CfgPtr)
|
mixer.Stop(1000, p.Base.Context.CfgPtr)
|
||||||
|
|
||||||
// GL cleanup — delete all text textures
|
// GL cleanup — delete all text textures
|
||||||
for i := 0; i < p.lines.Len(); i++ {
|
if p.lines != nil {
|
||||||
line := p.lines.Get(i)
|
for i := 0; i < p.lines.Len(); i++ {
|
||||||
for j := range line.words {
|
line := p.lines.Get(i)
|
||||||
if id := line.words[j].ID; id != 0 {
|
for j := range line.words {
|
||||||
gl.DeleteTextures(1, &line.words[j].ID)
|
if id := line.words[j].ID; id != 0 {
|
||||||
line.words[j].ID = 0
|
gl.DeleteTextures(1, &line.words[j].ID)
|
||||||
|
line.words[j].ID = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gl.Flush()
|
gl.Flush()
|
||||||
|
|
||||||
// Drop references for GC
|
// Drop references for GC safely
|
||||||
p.lines = nil
|
if p.lines != nil {
|
||||||
p.words = nil
|
p.lines = nil
|
||||||
p.lineCtx = nil
|
}
|
||||||
p.font = nil
|
if p.words != nil {
|
||||||
p.shader = nil
|
p.words = nil
|
||||||
p.colorPattern = nil
|
}
|
||||||
|
if p.lineCtx != nil {
|
||||||
|
p.lineCtx = nil
|
||||||
|
}
|
||||||
|
if p.font != nil {
|
||||||
|
p.font = nil
|
||||||
|
}
|
||||||
|
if p.shader != nil {
|
||||||
|
p.shader = nil
|
||||||
|
}
|
||||||
|
if p.colorPattern != nil {
|
||||||
|
p.colorPattern = nil
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user