2020-04-02 01:21:32 +01:00
|
|
|
package assetstore
|
|
|
|
|
|
|
|
import (
|
2020-04-11 00:13:28 +01:00
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
|
2020-04-02 01:21:32 +01:00
|
|
|
"code.ur.gs/lupine/ordoor/internal/config"
|
|
|
|
"code.ur.gs/lupine/ordoor/internal/data"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Generic returns a struct containing a grab-bag of otherwise-unrelated data
|
|
|
|
// TODO: it would be nice if this could be cleaner
|
|
|
|
func (a *AssetStore) Generic() (*data.Generic, error) {
|
|
|
|
if a.generic != nil {
|
|
|
|
return a.generic, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
filename, err := a.lookup("GenericData", "dat", "Data")
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
generic, err := data.LoadGeneric(filename)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-04-11 00:13:28 +01:00
|
|
|
// These changes are made so data in generic plays nicer with assetstore
|
|
|
|
for i, filename := range generic.CampaignMaps {
|
|
|
|
generic.CampaignMaps[i] =
|
|
|
|
strings.TrimSuffix(filename, filepath.Ext(filename))
|
|
|
|
}
|
|
|
|
|
2020-04-02 01:21:32 +01:00
|
|
|
a.generic = generic
|
|
|
|
|
|
|
|
return generic, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *AssetStore) DefaultOptions() (*config.Options, error) {
|
|
|
|
cfg := &config.Options{}
|
|
|
|
g, err := a.Generic()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
cfg.PlayMovies = intToBool(g.Options[data.OptionMovies])
|
|
|
|
cfg.PlayMusic = intToBool(g.Options[data.OptionMusic])
|
|
|
|
cfg.CombatVoices = intToBool(g.Options[data.OptionCombatVoices])
|
|
|
|
cfg.ShowGrid = intToBool(g.Options[data.OptionGrid])
|
|
|
|
cfg.ShowPaths = intToBool(g.Options[data.OptionShowPaths])
|
|
|
|
cfg.PointSaving = intToBool(g.Options[data.OptionPointSave])
|
|
|
|
cfg.AutoCutLevel = intToBool(g.Options[data.OptionAutoCutLevel])
|
|
|
|
cfg.Animations = intToBool(g.Options[data.OptionShowUnitAnimations])
|
|
|
|
|
|
|
|
// These are overrides of data.OptionCombatResolution. *This* default from
|
|
|
|
// 1998 is no good at all!
|
|
|
|
cfg.XRes = 1280
|
|
|
|
cfg.YRes = 1024
|
|
|
|
|
|
|
|
cfg.MusicVolume = g.Options[data.OptionMusicVolume]
|
|
|
|
cfg.SFXVolume = g.Options[data.OptionSoundEffectsVolume]
|
|
|
|
|
|
|
|
cfg.UnitSpeed = g.Options[data.OptionUnitAnimationSpeed]
|
|
|
|
cfg.AnimSpeed = g.Options[data.OptionEffectAnimationSpeed]
|
|
|
|
|
|
|
|
return cfg, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func intToBool(i int) bool {
|
|
|
|
return i > 0
|
|
|
|
}
|