tweaks
This commit is contained in:
@@ -30,6 +30,10 @@ func (d *Domain) InitDialog() {
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Domain) GetDialogMap() entity.DialogMap {
|
||||
return d.DialogMap
|
||||
}
|
||||
|
||||
func (d *Domain) GetDialog(name string) entity.Dialog {
|
||||
value, _ := d.DialogMap[name]
|
||||
return value
|
||||
|
||||
@@ -34,6 +34,10 @@ func (d *Domain) InitLevel() {
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Domain) GetLevels() []entity.Level {
|
||||
return d.Levels
|
||||
}
|
||||
|
||||
func (d *Domain) GetLevel(index int) entity.Level {
|
||||
return d.Levels[index]
|
||||
}
|
||||
|
||||
@@ -63,6 +63,10 @@ func (d *Domain) InitMenu() {
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Domain) GetMenuMap() entity.MenuMap {
|
||||
return d.MenuMap
|
||||
}
|
||||
|
||||
func (d *Domain) GetMenu(name string) entity.Menu {
|
||||
value, _ := d.MenuMap[name]
|
||||
return value
|
||||
|
||||
@@ -18,32 +18,28 @@ func (e *Engine) Layout(outsideWidth, outsideHeight int) (int, int) {
|
||||
return e.Settings.Screen.Width, e.Settings.Screen.Height
|
||||
}
|
||||
|
||||
func (e *Engine) ScreenTypeIs(name string) bool {
|
||||
return e.KContext.Screen.Type == name
|
||||
}
|
||||
|
||||
func (e *Engine) Update(screen *ebiten.Image) error {
|
||||
e.WatchKeyPress()
|
||||
if e.ScreenTypeIs("menu") {
|
||||
if e.KContext.ScreenTypeIs("menu") {
|
||||
e.MenuUpdate()
|
||||
}
|
||||
if e.ScreenTypeIs("dialog") {
|
||||
if e.KContext.ScreenTypeIs("dialog") {
|
||||
e.DialogUpdate()
|
||||
}
|
||||
if e.ScreenTypeIs("playground") {
|
||||
if e.KContext.ScreenTypeIs("playground") {
|
||||
e.PlaygroundUpdate()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *Engine) Draw(screen *ebiten.Image) {
|
||||
if e.ScreenTypeIs("menu") {
|
||||
if e.KContext.ScreenTypeIs("menu") {
|
||||
e.MenuDraw(screen)
|
||||
}
|
||||
if e.ScreenTypeIs("dialog") {
|
||||
if e.KContext.ScreenTypeIs("dialog") {
|
||||
e.DialogDraw(screen)
|
||||
}
|
||||
if e.ScreenTypeIs("playground") {
|
||||
if e.KContext.ScreenTypeIs("playground") {
|
||||
e.PlaygroundDraw(screen)
|
||||
}
|
||||
if e.Action3Pressed() {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
func (e *Engine) DialogDraw(screen *ebiten.Image) {
|
||||
dialog := e.Domain.GetDialog(e.KContext.Screen.Value)
|
||||
dialog := e.Domain.GetDialog(e.KContext.ScreenValue)
|
||||
|
||||
face := GetFontFace(dialog.Layout.ChoiceFont)
|
||||
|
||||
@@ -17,7 +17,7 @@ func (e *Engine) DialogDraw(screen *ebiten.Image) {
|
||||
}
|
||||
|
||||
func (e *Engine) DialogUpdate() {
|
||||
dialog := e.Domain.GetDialog(e.KContext.Screen.Value)
|
||||
dialog := e.Domain.GetDialog(e.KContext.ScreenValue)
|
||||
|
||||
if e.UpPressed() && dialog.CurrentSelected != 0 {
|
||||
dialog.CurrentSelected--
|
||||
@@ -30,5 +30,5 @@ func (e *Engine) DialogUpdate() {
|
||||
if e.Action0Pressed() {
|
||||
dialog.Choices[dialog.CurrentSelected].Handler()
|
||||
}
|
||||
e.Domain.SetDialog(e.KContext.Screen.Value, dialog)
|
||||
e.Domain.SetDialog(e.KContext.ScreenValue, dialog)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
func (e *Engine) MenuDraw(screen *ebiten.Image) {
|
||||
menu := e.Domain.GetMenu(e.KContext.Screen.Value)
|
||||
menu := e.Domain.GetMenu(e.KContext.ScreenValue)
|
||||
face := GetFontFace(menu.Layout.MenuItemFont)
|
||||
|
||||
for i, menu_item := range menu.MenuItems {
|
||||
@@ -17,7 +17,7 @@ func (e *Engine) MenuDraw(screen *ebiten.Image) {
|
||||
}
|
||||
|
||||
func (e *Engine) MenuUpdate() {
|
||||
menu := e.Domain.GetMenu(e.KContext.Screen.Value)
|
||||
menu := e.Domain.GetMenu(e.KContext.ScreenValue)
|
||||
|
||||
if e.UpPressed() && menu.CurrentSelected != 0 {
|
||||
menu.CurrentSelected--
|
||||
@@ -31,5 +31,5 @@ func (e *Engine) MenuUpdate() {
|
||||
menu.MenuItems[menu.CurrentSelected].Handler()
|
||||
}
|
||||
|
||||
e.Domain.SetMenu(e.KContext.Screen.Value, menu)
|
||||
e.Domain.SetMenu(e.KContext.ScreenValue, menu)
|
||||
}
|
||||
|
||||
@@ -2,11 +2,18 @@ package entity
|
||||
|
||||
type DomainInterface interface {
|
||||
Init()
|
||||
|
||||
GetMenuMap() MenuMap
|
||||
GetMenu(name string) Menu
|
||||
SetMenu(name string, menu Menu)
|
||||
|
||||
GetDialogMap() DialogMap
|
||||
GetDialog(name string) Dialog
|
||||
SetDialog(name string, menu Dialog)
|
||||
|
||||
GetLevels() []Level
|
||||
GetLevel(index int) Level
|
||||
|
||||
AddToInventory(item *Item) bool
|
||||
RemoveFromInventory(item *Item) bool
|
||||
UseInventoryItem(item *Item) bool
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package entity
|
||||
|
||||
type KContextScreen struct {
|
||||
Type string
|
||||
Value string
|
||||
type KContext struct {
|
||||
ScreenType string
|
||||
ScreenValue string
|
||||
CurrentLevel int
|
||||
Players []Player
|
||||
}
|
||||
|
||||
type KContext struct {
|
||||
Screen KContextScreen
|
||||
CurrentLevel int
|
||||
func (c *KContext) getPrimaryPlayer() Player {
|
||||
return c.Players[0]
|
||||
}
|
||||
|
||||
func (c *KContext) ScreenTypeIs(name string) bool {
|
||||
return c.ScreenType == name
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user