|
| 1 | +package resource |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/hajimehoshi/ebiten/v2" |
| 5 | + "github.com/hajimehoshi/ebiten/v2/audio" |
| 6 | + "golang.org/x/image/font" |
| 7 | +) |
| 8 | + |
| 9 | +// AudioID is a typed key for Audio resources. |
| 10 | +// See also: AudioInfo. |
| 11 | +type AudioID int |
| 12 | + |
| 13 | +type AudioInfo struct { |
| 14 | + // A path that will be used to read the resource data. |
| 15 | + Path string |
| 16 | + |
| 17 | + // Group is a sound group ID. |
| 18 | + // Groups are used to apply group-wide operations like |
| 19 | + // volume adjustments. |
| 20 | + // Conventionally, group 0 is "sound effect", 1 is "music", 2 is "voice". |
| 21 | + Group uint |
| 22 | + |
| 23 | + // Volume adjust how loud this sound will be. |
| 24 | + // The default value of 0 means "unadjusted". |
| 25 | + // Value greated than 0 increases the volume, negative values decrease it. |
| 26 | + // This setting accepts values in [-1, 1] range, where -1 mutes the sound |
| 27 | + // while 1 makes it as loud as possible. |
| 28 | + Volume float64 |
| 29 | +} |
| 30 | + |
| 31 | +type Audio struct { |
| 32 | + // An ID that was associated with this resource. |
| 33 | + ID AudioID |
| 34 | + |
| 35 | + // An initialized audio player that can be used to play the audio. |
| 36 | + // Note that you may need to rewind it before playing the sound. |
| 37 | + // The player wraps an original stream, so you can't access it directly. |
| 38 | + Player *audio.Player |
| 39 | + |
| 40 | + Group uint |
| 41 | + Volume float64 |
| 42 | +} |
| 43 | + |
| 44 | +// FontID is a typed key for Font resources. |
| 45 | +// See also: FontInfo. |
| 46 | +type FontID int |
| 47 | + |
| 48 | +type FontInfo struct { |
| 49 | + // A path that will be used to read the resource data. |
| 50 | + Path string |
| 51 | + |
| 52 | + Size int |
| 53 | + |
| 54 | + LineSpacing float64 |
| 55 | +} |
| 56 | + |
| 57 | +type Font struct { |
| 58 | + // An ID that was associated with this resource. |
| 59 | + ID FontID |
| 60 | + |
| 61 | + Face font.Face |
| 62 | +} |
| 63 | + |
| 64 | +// ImageID is a typed key for Image resources. |
| 65 | +// See also: ImageInfo. |
| 66 | +type ImageID int |
| 67 | + |
| 68 | +type ImageInfo struct { |
| 69 | + // A path that will be used to read the resource data. |
| 70 | + Path string |
| 71 | + |
| 72 | + FrameWidth float64 |
| 73 | + FrameHeight float64 |
| 74 | +} |
| 75 | + |
| 76 | +type Image struct { |
| 77 | + // An ID that was associated with this resource. |
| 78 | + ID ImageID |
| 79 | + |
| 80 | + // An ebiten Image object initialized from the resource bytes. |
| 81 | + Data *ebiten.Image |
| 82 | + |
| 83 | + DefaultFrameWidth float64 |
| 84 | + DefaultFrameHeight float64 |
| 85 | +} |
| 86 | + |
| 87 | +// RawID is a typed key for Raw resources. |
| 88 | +// See also: RawInfo. |
| 89 | +type RawID int |
| 90 | + |
| 91 | +type RawInfo struct { |
| 92 | + // A path that will be used to read the resource data. |
| 93 | + Path string |
| 94 | +} |
| 95 | + |
| 96 | +type Raw struct { |
| 97 | + // An ID that was associated with this resource. |
| 98 | + ID RawID |
| 99 | + |
| 100 | + // Data is an uninterpreted resource contents. |
| 101 | + Data []byte |
| 102 | +} |
| 103 | + |
| 104 | +// ShaderID is a typed key for Shader resources. |
| 105 | +// See also: ShaderInfo. |
| 106 | +type ShaderID int |
| 107 | + |
| 108 | +type ShaderInfo struct { |
| 109 | + // A path that will be used to read the resource data. |
| 110 | + Path string |
| 111 | +} |
| 112 | + |
| 113 | +type Shader struct { |
| 114 | + // An ID that was associated with this resource. |
| 115 | + ID ShaderID |
| 116 | + |
| 117 | + // A compiled shader. |
| 118 | + Data *ebiten.Shader |
| 119 | +} |
0 commit comments