From 5e4f63aecc56c4594b5697225ce91e227b7fbcc0 Mon Sep 17 00:00:00 2001 From: Zsolt Tasnadi Date: Wed, 5 Jul 2023 22:05:48 +0200 Subject: [PATCH] pointer fixes for kcontext and settings --- konstructor/engine/engine.wrapper.go | 4 ++-- konstructor/engine/screen.dialog.go | 22 +++++++++++----------- konstructor/engine/screen.menu.go | 22 +++++++++++----------- konstructor/engine/screen.playground.go | 8 ++++---- konstructor/entity/entity.engine.go | 4 ++-- konstructor/konstructor.go | 4 ++-- main.go | 2 +- 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/konstructor/engine/engine.wrapper.go b/konstructor/engine/engine.wrapper.go index 6084ce1..b31e6d1 100644 --- a/konstructor/engine/engine.wrapper.go +++ b/konstructor/engine/engine.wrapper.go @@ -12,9 +12,9 @@ type EngineWrapper struct { func (ew *EngineWrapper) Init(options entity.EngineOptions) { ew.Engine = Engine{ - KContext: &options.KContext, + KContext: options.KContext, Domain: options.Domain, - Settings: &options.Settings, + Settings: options.Settings, } ebiten.SetWindowSize(options.Settings.Screen.Width, options.Settings.Screen.Height) ebiten.SetWindowTitle(options.Settings.Name) diff --git a/konstructor/engine/screen.dialog.go b/konstructor/engine/screen.dialog.go index 240f29d..bc27834 100644 --- a/konstructor/engine/screen.dialog.go +++ b/konstructor/engine/screen.dialog.go @@ -5,17 +5,6 @@ import ( "github.com/hajimehoshi/ebiten/text" ) -func (e *Engine) DialogDraw(screen *ebiten.Image) { - dialog := e.Domain.GetDialog(e.KContext.ScreenValue) - - face := GetFontFace(dialog.Layout.ChoiceFont) - - for i, choice := range dialog.Choices { - offset := int(dialog.Layout.ChoiceFont.Size) * (i + 1) - text.Draw(screen, choice.Label+"\n", face, 8, offset, dialog.GetChoiceColor(i)) - } -} - func (e *Engine) DialogUpdate() { dialog := e.Domain.GetDialog(e.KContext.ScreenValue) @@ -32,3 +21,14 @@ func (e *Engine) DialogUpdate() { } e.Domain.SetDialog(e.KContext.ScreenValue, dialog) } + +func (e *Engine) DialogDraw(screen *ebiten.Image) { + dialog := e.Domain.GetDialog(e.KContext.ScreenValue) + + face := GetFontFace(dialog.Layout.ChoiceFont) + + for i, choice := range dialog.Choices { + offset := int(dialog.Layout.ChoiceFont.Size) * (i + 1) + text.Draw(screen, choice.Label+"\n", face, 8, offset, dialog.GetChoiceColor(i)) + } +} diff --git a/konstructor/engine/screen.menu.go b/konstructor/engine/screen.menu.go index 4bb93c3..2434244 100644 --- a/konstructor/engine/screen.menu.go +++ b/konstructor/engine/screen.menu.go @@ -5,17 +5,6 @@ import ( "github.com/hajimehoshi/ebiten/text" ) -func (e *Engine) MenuDraw(screen *ebiten.Image) { - menu := e.Domain.GetMenu(e.KContext.ScreenValue) - face := GetFontFace(menu.Layout.MenuItemFont) - - for i, menu_item := range menu.MenuItems { - color := menu.GetMenuItemColor(i) - offset := int(menu.Layout.MenuItemFont.Size) * (i + 1) - text.Draw(screen, menu_item.Label+"\n", face, 8, offset, color) - } -} - func (e *Engine) MenuUpdate() { menu := e.Domain.GetMenu(e.KContext.ScreenValue) @@ -33,3 +22,14 @@ func (e *Engine) MenuUpdate() { e.Domain.SetMenu(e.KContext.ScreenValue, menu) } + +func (e *Engine) MenuDraw(screen *ebiten.Image) { + menu := e.Domain.GetMenu(e.KContext.ScreenValue) + face := GetFontFace(menu.Layout.MenuItemFont) + + for i, menu_item := range menu.MenuItems { + color := menu.GetMenuItemColor(i) + offset := int(menu.Layout.MenuItemFont.Size) * (i + 1) + text.Draw(screen, menu_item.Label+"\n", face, 8, offset, color) + } +} diff --git a/konstructor/engine/screen.playground.go b/konstructor/engine/screen.playground.go index 0dcef29..dcb7193 100644 --- a/konstructor/engine/screen.playground.go +++ b/konstructor/engine/screen.playground.go @@ -6,10 +6,6 @@ import ( "github.com/hajimehoshi/ebiten" ) -func (e *Engine) PlaygroundDraw(screen *ebiten.Image) { - e.Domain.GetLevel(e.KContext.CurrentLevel) -} - func (e *Engine) PlaygroundUpdate() { level := e.Domain.GetLevel(e.KContext.CurrentLevel) e.Domain.Process(entity.DomainProcessOptions{ @@ -17,3 +13,7 @@ func (e *Engine) PlaygroundUpdate() { KContext: e.KContext, }) } + +func (e *Engine) PlaygroundDraw(screen *ebiten.Image) { + e.Domain.GetLevel(e.KContext.CurrentLevel) +} diff --git a/konstructor/entity/entity.engine.go b/konstructor/entity/entity.engine.go index f44886b..6b26cda 100644 --- a/konstructor/entity/entity.engine.go +++ b/konstructor/entity/entity.engine.go @@ -2,8 +2,8 @@ package entity type EngineOptions struct { Domain DomainInterface - KContext KContext - Settings Settings + KContext *KContext + Settings *Settings } type EngineWrapperInterface interface { diff --git a/konstructor/konstructor.go b/konstructor/konstructor.go index daf0957..b6f84cc 100644 --- a/konstructor/konstructor.go +++ b/konstructor/konstructor.go @@ -7,7 +7,7 @@ import ( type Konstructor struct { Domain entity.DomainInterface KContext *entity.KContext - Settings entity.Settings + Settings *entity.Settings EngineWrapper entity.EngineWrapperInterface } @@ -15,7 +15,7 @@ func (k Konstructor) Init() { k.Domain.Init() k.EngineWrapper.Init(entity.EngineOptions{ Domain: k.Domain, - KContext: *k.KContext, + KContext: k.KContext, Settings: k.Settings, }) k.EngineWrapper.Run() diff --git a/main.go b/main.go index 6b49c9a..e4a49ca 100644 --- a/main.go +++ b/main.go @@ -27,7 +27,7 @@ func main() { ScreenValue: "MainMenu", CurrentLevel: 0, }, - Settings: entity.Settings{ + Settings: &entity.Settings{ Name: "Game", Screen: &entity.ScreenSettings{ Width: 640,