pointer fixes for kcontext and settings
This commit is contained in:
@@ -12,9 +12,9 @@ type EngineWrapper struct {
|
|||||||
|
|
||||||
func (ew *EngineWrapper) Init(options entity.EngineOptions) {
|
func (ew *EngineWrapper) Init(options entity.EngineOptions) {
|
||||||
ew.Engine = Engine{
|
ew.Engine = Engine{
|
||||||
KContext: &options.KContext,
|
KContext: options.KContext,
|
||||||
Domain: options.Domain,
|
Domain: options.Domain,
|
||||||
Settings: &options.Settings,
|
Settings: options.Settings,
|
||||||
}
|
}
|
||||||
ebiten.SetWindowSize(options.Settings.Screen.Width, options.Settings.Screen.Height)
|
ebiten.SetWindowSize(options.Settings.Screen.Width, options.Settings.Screen.Height)
|
||||||
ebiten.SetWindowTitle(options.Settings.Name)
|
ebiten.SetWindowTitle(options.Settings.Name)
|
||||||
|
|||||||
@@ -5,17 +5,6 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/text"
|
"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() {
|
func (e *Engine) DialogUpdate() {
|
||||||
dialog := e.Domain.GetDialog(e.KContext.ScreenValue)
|
dialog := e.Domain.GetDialog(e.KContext.ScreenValue)
|
||||||
|
|
||||||
@@ -32,3 +21,14 @@ func (e *Engine) DialogUpdate() {
|
|||||||
}
|
}
|
||||||
e.Domain.SetDialog(e.KContext.ScreenValue, dialog)
|
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))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,17 +5,6 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/text"
|
"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() {
|
func (e *Engine) MenuUpdate() {
|
||||||
menu := e.Domain.GetMenu(e.KContext.ScreenValue)
|
menu := e.Domain.GetMenu(e.KContext.ScreenValue)
|
||||||
|
|
||||||
@@ -33,3 +22,14 @@ func (e *Engine) MenuUpdate() {
|
|||||||
|
|
||||||
e.Domain.SetMenu(e.KContext.ScreenValue, menu)
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,10 +6,6 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten"
|
"github.com/hajimehoshi/ebiten"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (e *Engine) PlaygroundDraw(screen *ebiten.Image) {
|
|
||||||
e.Domain.GetLevel(e.KContext.CurrentLevel)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *Engine) PlaygroundUpdate() {
|
func (e *Engine) PlaygroundUpdate() {
|
||||||
level := e.Domain.GetLevel(e.KContext.CurrentLevel)
|
level := e.Domain.GetLevel(e.KContext.CurrentLevel)
|
||||||
e.Domain.Process(entity.DomainProcessOptions{
|
e.Domain.Process(entity.DomainProcessOptions{
|
||||||
@@ -17,3 +13,7 @@ func (e *Engine) PlaygroundUpdate() {
|
|||||||
KContext: e.KContext,
|
KContext: e.KContext,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *Engine) PlaygroundDraw(screen *ebiten.Image) {
|
||||||
|
e.Domain.GetLevel(e.KContext.CurrentLevel)
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package entity
|
|||||||
|
|
||||||
type EngineOptions struct {
|
type EngineOptions struct {
|
||||||
Domain DomainInterface
|
Domain DomainInterface
|
||||||
KContext KContext
|
KContext *KContext
|
||||||
Settings Settings
|
Settings *Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
type EngineWrapperInterface interface {
|
type EngineWrapperInterface interface {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
type Konstructor struct {
|
type Konstructor struct {
|
||||||
Domain entity.DomainInterface
|
Domain entity.DomainInterface
|
||||||
KContext *entity.KContext
|
KContext *entity.KContext
|
||||||
Settings entity.Settings
|
Settings *entity.Settings
|
||||||
EngineWrapper entity.EngineWrapperInterface
|
EngineWrapper entity.EngineWrapperInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ func (k Konstructor) Init() {
|
|||||||
k.Domain.Init()
|
k.Domain.Init()
|
||||||
k.EngineWrapper.Init(entity.EngineOptions{
|
k.EngineWrapper.Init(entity.EngineOptions{
|
||||||
Domain: k.Domain,
|
Domain: k.Domain,
|
||||||
KContext: *k.KContext,
|
KContext: k.KContext,
|
||||||
Settings: k.Settings,
|
Settings: k.Settings,
|
||||||
})
|
})
|
||||||
k.EngineWrapper.Run()
|
k.EngineWrapper.Run()
|
||||||
|
|||||||
2
main.go
2
main.go
@@ -27,7 +27,7 @@ func main() {
|
|||||||
ScreenValue: "MainMenu",
|
ScreenValue: "MainMenu",
|
||||||
CurrentLevel: 0,
|
CurrentLevel: 0,
|
||||||
},
|
},
|
||||||
Settings: entity.Settings{
|
Settings: &entity.Settings{
|
||||||
Name: "Game",
|
Name: "Game",
|
||||||
Screen: &entity.ScreenSettings{
|
Screen: &entity.ScreenSettings{
|
||||||
Width: 640,
|
Width: 640,
|
||||||
|
|||||||
Reference in New Issue
Block a user