Get the initial copyright notice displaying

This is really awful, but it's nice to check it off.
This commit is contained in:
2020-06-06 12:43:02 +01:00
parent 54fe95239e
commit c2cbf1d95d
6 changed files with 105 additions and 6 deletions

View File

@@ -8,6 +8,8 @@ import (
"path/filepath"
"strings"
"github.com/hajimehoshi/ebiten"
"code.ur.gs/lupine/ordoor/internal/config"
"code.ur.gs/lupine/ordoor/internal/data"
"code.ur.gs/lupine/ordoor/internal/idx"
@@ -44,6 +46,7 @@ type AssetStore struct {
fonts map[string]*Font
generic *data.Generic
idx *idx.Idx
images map[string]*ebiten.Image
maps map[string]*Map
menus map[string]*Menu
objs map[string]*Object
@@ -109,6 +112,7 @@ func (a *AssetStore) Refresh() error {
a.entries = newEntryMap
a.fonts = make(map[string]*Font)
a.idx = nil
a.images = make(map[string]*ebiten.Image)
a.maps = make(map[string]*Map)
a.menus = make(map[string]*Menu)
a.objs = make(map[string]*Object)

View File

@@ -0,0 +1,42 @@
package assetstore
import (
"image"
"os"
"github.com/hajimehoshi/ebiten"
_ "github.com/samuel/go-pcx/pcx" // PCX support
)
func (a *AssetStore) Image(name string) (*ebiten.Image, error) {
name = canonical(name)
if img, ok := a.images[name]; ok {
return img, nil
}
// baps, ordoor, geas store .pcx files in Pic
// TODO: SL stores .bmp files in Res
filename, err := a.lookup(name, "pcx", "Pic")
if err != nil {
return nil, err
}
f, err := os.Open(filename)
if err != nil {
return nil, err
}
defer f.Close()
rawImg, _, err := image.Decode(f)
if err != nil {
return nil, err
}
img, err := ebiten.NewImageFromImage(rawImg, ebiten.FilterDefault)
if err != nil {
return nil, err
}
a.images[name] = img
return img, nil
}