-
Notifications
You must be signed in to change notification settings - Fork 7
/
TextureDisplay.go
64 lines (53 loc) · 1.88 KB
/
TextureDisplay.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package levels
import (
"fmt"
"github.com/inkyblackness/hacked/ss1/content/archive/level"
)
// TextureDisplay is an enumeration which texture to display in a 2D map view.
type TextureDisplay int
// TextureDisplay constants
const (
TextureDisplayFloor TextureDisplay = 0
TextureDisplayWall TextureDisplay = 1
TextureDisplayCeiling TextureDisplay = 2
)
// String returns a textual representation.
func (display TextureDisplay) String() string {
switch display {
case TextureDisplayFloor:
return "Floor"
case TextureDisplayWall:
return "Wall"
case TextureDisplayCeiling:
return "Ceiling"
default:
return fmt.Sprintf("Unknown%d", int(display))
}
}
// TextureDisplays returns all TextureDisplay constants.
func TextureDisplays() []TextureDisplay {
return []TextureDisplay{TextureDisplayFloor, TextureDisplayWall, TextureDisplayCeiling}
}
// TextureDisplayFunc is one that resolves texture properties.
type TextureDisplayFunc func(*level.TileMapEntry) (atlasIndex int, textureRotations int)
// FloorTexture returns the properties for the floor.
func FloorTexture(tile *level.TileMapEntry) (atlasIndex int, textureRotations int) {
return tile.TextureInfo.FloorTextureIndex(), tile.Floor.TextureRotations()
}
// CeilingTexture returns the properties for the ceiling.
func CeilingTexture(tile *level.TileMapEntry) (atlasIndex int, textureRotations int) {
return tile.TextureInfo.CeilingTextureIndex(), tile.Ceiling.TextureRotations()
}
// WallTexture returns the properties for the floor.
func WallTexture(tile *level.TileMapEntry) (atlasIndex int, textureRotations int) {
return tile.TextureInfo.WallTextureIndex(), 0
}
// Func returns the display func for the current display setting.
func (display TextureDisplay) Func() TextureDisplayFunc {
if display == TextureDisplayFloor {
return FloorTexture
} else if display == TextureDisplayCeiling {
return CeilingTexture
}
return WallTexture
}