go_dreamfactory/modules/oldtimes/configure.go

72 lines
1.6 KiB
Go

package oldtimes
import (
"fmt"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
cfg "go_dreamfactory/sys/configure/structs"
)
const (
gameLinestoryMainTask = "game_linestorymaintask.json"
gameLinestoryTimeline = "game_linestorytimeline.json"
)
type configureComp struct {
modules.MCompConfigure
}
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.MCompConfigure.Init(service, module, comp, options)
err = this.LoadMultiConfigure(map[string]interface{}{
gameLinestoryMainTask: cfg.NewGameLinestoryMainTask,
gameLinestoryTimeline: cfg.NewGameLinestoryTimeLine,
})
return
}
func (this *configureComp) getMaintaskCfg() (data *cfg.GameLinestoryMainTask, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(gameLinestoryMainTask); err != nil {
return
} else {
if data, ok = v.(*cfg.GameLinestoryMainTask); !ok {
err = fmt.Errorf("%T is *cfg.GameTalent", v)
return
}
}
return
}
func (this *configureComp) getMaintaskCfgBy(id int32) (data *cfg.GameLinestoryMainTaskData) {
glmt, err := this.getMaintaskCfg()
if err != nil {
return nil
}
if glmt != nil {
data = glmt.GetDataMap()[id]
return data
}
return data
}
func (this *configureComp) getTimelineCfg() (data *cfg.GameLinestoryTimeLine, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(gameLinestoryTimeline); err != nil {
return
} else {
if data, ok = v.(*cfg.GameLinestoryTimeLine); !ok {
err = fmt.Errorf("%T is *cfg.GameLinestoryTimeline", v)
return
}
}
return
}