render GetImage and replace Options prefix to Args

This commit is contained in:
2023-07-06 01:20:23 +02:00
parent 731548ef86
commit 701205ac82
17 changed files with 61 additions and 52 deletions

View File

@@ -5,7 +5,7 @@ import "image/color"
type DialogMap map[string]Dialog
type DialogLayout struct {
Background string
Render Render
ChoiceFont FontLayout
}

View File

@@ -18,10 +18,10 @@ type DomainInterface interface {
RemoveFromInventory(item *Item) bool
UseInventoryItem(item *Item) bool
Process(DomainProcessOptions)
Process(DomainProcessArgs)
}
type DomainProcessOptions struct {
type DomainProcessArgs struct {
Level *Level
KContext *KContext
}

View File

@@ -1,12 +1,12 @@
package entity
type EngineOptions struct {
type EngineArgs struct {
Domain DomainInterface
KContext *KContext
Settings *Settings
}
type EngineWrapperInterface interface {
Init(options EngineOptions)
Init(options EngineArgs)
Run()
}

View File

@@ -18,11 +18,11 @@ type FontLayout struct {
func (fl *FontLayout) GetFontFace() font.Face {
file, _ := ioutil.ReadFile(fl.Path)
tt, _ := opentype.Parse(file)
face, _ := opentype.NewFace(tt, &opentype.FaceOptions{
true_type, _ := opentype.Parse(file)
font_face, _ := opentype.NewFace(true_type, &opentype.FaceOptions{
Size: fl.DPI,
DPI: fl.Size,
Hinting: font.HintingVertical,
})
return face
return font_face
}

View File

@@ -1,8 +1,8 @@
package entity
type ItemType struct {
ID string
RenderOptions RenderOptions
ID string
Render Render
}
type Item struct {

View File

@@ -5,7 +5,6 @@ import "image/color"
type MenuMap map[string]Menu
type MenuLayout struct {
Background string
MenuItemFont FontLayout
}

View File

@@ -1,8 +1,8 @@
package entity
type NPCType struct {
ID string
RenderOptions RenderOptions
ID string
Render Render
}
type NPC struct {

View File

@@ -1,8 +1,8 @@
package entity
type ObjectType struct {
ID string
RenderOptions RenderOptions
ID string
Render Render
}
type Object struct {

View File

@@ -11,8 +11,8 @@ type Inventory struct {
}
type Player struct {
ID string
RenderOptions RenderOptions
Position Position
Inventory Inventory
ID string
Render Render
Position Position
Inventory Inventory
}

View File

@@ -6,18 +6,11 @@ type Position struct {
Z int
}
type RenderOptions struct {
Image string
Width int
Height int
Visible bool
}
type Playground struct {
Background string
Objects []Object
NPCs []NPC
Items []Item
Render Render
Objects []Object
NPCs []NPC
Items []Item
}
type Level struct {

View File

@@ -0,0 +1,28 @@
package entity
import (
"bytes"
"image"
"io/ioutil"
"log"
)
type Render struct {
Image string
Width int
Height int
Visible bool
}
func (ro *Render) GetImage() image.Image {
file, err := ioutil.ReadFile(ro.Image)
if err != nil {
log.Fatal(err)
}
img, _, err := image.Decode(bytes.NewReader(file))
if err != nil {
log.Fatal(err)
}
return img
}