Adding modding folder with a hacked build.

This commit is contained in:
ml
2026-09-26 08:53:08 +02:00
parent cdb960dc71
commit c91080aba7
755 changed files with 50424 additions and 0 deletions
@@ -0,0 +1,58 @@
package bitmap
import (
"github.com/inkyblackness/hacked/ss1/resource"
)
// AnimationCache retrieves animations from a localizer and keeps them decoded until they are invalidated.
type AnimationCache struct {
localizer resource.Localizer
animations map[resource.Key]Animation
}
// NewAnimationCache returns a new instance.
func NewAnimationCache(localizer resource.Localizer) *AnimationCache {
cache := &AnimationCache{
localizer: localizer,
animations: make(map[resource.Key]Animation),
}
return cache
}
// InvalidateResources lets the cache remove any animations from resources that are specified in the given slice.
func (cache *AnimationCache) InvalidateResources(ids []resource.ID) {
for _, id := range ids {
for key := range cache.animations {
if key.ID == id {
delete(cache.animations, key)
}
}
}
}
// Animation tries to look up given animation.
func (cache *AnimationCache) Animation(key resource.Key) (anim Animation, err error) {
anim, existing := cache.animations[key]
if existing {
return anim, nil
}
selector := cache.localizer.LocalizedResources(key.Lang)
view, err := selector.Select(key.ID)
if err != nil {
return
}
if (view.ContentType() != resource.Animation) || (view.BlockCount() != 1) {
return anim, resource.ErrWrongType(key, resource.Animation)
}
reader, err := view.Block(0)
if err != nil {
return
}
anim, err = ReadAnimation(reader)
if err != nil {
return
}
cache.animations[key] = anim
return anim, nil
}