Files

131 lines
3.7 KiB
Go

package catalogs
import (
"encoding/json"
"os"
"path/filepath"
"sync"
)
var _ = json.RawMessage{}
var _ = sync.Mutex{}
var _ = os.ReadFile
var _ = filepath.Join
//
// One authored quest/task row.
// Counter is TaskConfig.Counter — the per-objective target values, e.g. [1] for a
// single-step quest and [7,1,3] for a three-step one. The task UI renders progress from
// CounterValues/Counters, so publishing rows without it is the main reason a populated task
// list can still draw nothing. 3765 of 4342 rows carry at least one counter.
//
type TaskCatalogEntry4229938 struct {
Id uint32 `json:"id"`
Name string `json:"name"`
RelatedRaid uint32 `json:"relatedRaid"`
Title uint32 `json:"title"`
Counter []int32 `json:"counter"`
}
// One TaskTitleConfig row — a task panel tab / chapter group to unlock.
type TaskTitleEntry4229938 struct {
Id uint32 `json:"id"`
Name string `json:"name"`
TabType uint32 `json:"tabType"`
RaidTask bool `json:"raidTask"`
ShowType uint32 `json:"showType"`
}
// One TaskChapterConfig row — a story chapter (70 on this build).
type TaskChapterEntry4229938 struct {
Id uint32 `json:"id"`
ChapterName string `json:"chapterName"`
SortId uint32 `json:"sortId"`
}
//
// Build-4229938 quest ("task") catalog, read from TaskCatalog.json in the configured client-data
// directory.
// That file is a slim projection of the client's TaskConfig.json — the authored quest table
// (Id / Name / RelatedRaid / Title / Counter, ids in 60000005..61086005). TaskConfig.json is not
// shipped in the v0.3 Configs folder; it comes from 补丁和工具\ConfigDump.zip. Regenerate with
// _gen_task_cfg.py.
// Two companion projections live next to it: TaskTitleCatalog.json (21 rows, the panel tabs
// handed to SyncTaskTitleGuideUnlock) and TaskChapterCatalog.json (70 story chapters).
//
var (
TaskCatalog4229938_cacheLock sync.RWMutex
TaskCatalog4229938_cached = false
TaskCatalog4229938_entries []any
)
// LoadTaskCatalog4229938 loads catalog records from client config directory
func LoadTaskCatalog4229938(configDir string) ([]any, error) {
TaskCatalog4229938_cacheLock.RLock()
if TaskCatalog4229938_cached {
defer TaskCatalog4229938_cacheLock.RUnlock()
return TaskCatalog4229938_entries, nil
}
TaskCatalog4229938_cacheLock.RUnlock()
TaskCatalog4229938_cacheLock.Lock()
defer TaskCatalog4229938_cacheLock.Unlock()
if TaskCatalog4229938_cached { return TaskCatalog4229938_entries, nil }
filePath := filepath.Join(configDir, "TaskCatalog.json.json")
data, err := os.ReadFile(filePath)
if err != nil {
return nil, err
}
var raw struct {
Records []json.RawMessage `json:"records"`
}
if err := json.Unmarshal(data, &raw); err != nil {
return nil, err
}
var result []any
for _, item := range raw.Records {
var m map[string]any
if err := json.Unmarshal(item, &m); err == nil {
result = append(result, m)
}
}
TaskCatalog4229938_entries = result
TaskCatalog4229938_cached = true
return result, nil
}
func TaskCatalog4229938_Find(id uint32) *TaskCatalogEntry4229938 {
// Catalog helper TaskCatalog4229938_Find
return nil
}
func TaskCatalog4229938_ConfigDir() string {
// Catalog helper TaskCatalog4229938_ConfigDir
return ""
}
func TaskCatalog4229938_Open(file string, doc any, records any) bool {
// Catalog helper TaskCatalog4229938_Open
return false
}
func TaskCatalog4229938_LoadTasks() []TaskCatalogEntry4229938 {
// Catalog helper TaskCatalog4229938_LoadTasks
return nil
}
func TaskCatalog4229938_LoadTitles() []TaskTitleEntry4229938 {
// Catalog helper TaskCatalog4229938_LoadTitles
return nil
}
func TaskCatalog4229938_LoadChapters() []TaskChapterEntry4229938 {
// Catalog helper TaskCatalog4229938_LoadChapters
return nil
}