ECL, default scale, and preferred alignment entries
This commit is contained in:
@@ -215,6 +215,7 @@ type TopDataConfig struct {
|
||||
PackageHAK string `json:"package_hak" yaml:"package_hak"`
|
||||
PackageTLK string `json:"package_tlk" yaml:"package_tlk"`
|
||||
ValueEncodings []TopDataValueEncodingConfig `json:"value_encodings" yaml:"value_encodings"`
|
||||
ValueDefaults []TopDataValueDefaultConfig `json:"value_defaults" yaml:"value_defaults"`
|
||||
Wiki TopDataWikiConfig `json:"wiki" yaml:"wiki"`
|
||||
}
|
||||
|
||||
@@ -227,6 +228,12 @@ type TopDataValueEncodingConfig struct {
|
||||
HexWidth int `json:"hex_width" yaml:"hex_width"`
|
||||
}
|
||||
|
||||
type TopDataValueDefaultConfig struct {
|
||||
Dataset string `json:"dataset" yaml:"dataset"`
|
||||
Column string `json:"column" yaml:"column"`
|
||||
Value any `json:"value" yaml:"value"`
|
||||
}
|
||||
|
||||
type TopDataWikiConfig struct {
|
||||
OutputRoot string `json:"output_root" yaml:"output_root"`
|
||||
PagesDir string `json:"pages_dir" yaml:"pages_dir"`
|
||||
@@ -570,6 +577,7 @@ func (p *Project) ValidateLayout() error {
|
||||
failures = append(failures, validateRelativePath("outputs.hak_archive", effective.Outputs.HAKArchive)...)
|
||||
failures = append(failures, validateGeneratedConfig(effective.Generated)...)
|
||||
failures = append(failures, validateTopDataValueEncodings(effective.TopData.ValueEncodings)...)
|
||||
failures = append(failures, validateTopDataValueDefaults(effective.TopData.ValueDefaults)...)
|
||||
failures = append(failures, validateRelativePath("scripts.cache", effective.Scripts.Cache)...)
|
||||
failures = append(failures, validateRelativePath("scripts.source_dir", effective.Scripts.SourceDir)...)
|
||||
failures = append(failures, validateRelativePath("topdata.compiled_2da_dir", effective.TopData.Compiled2DADir)...)
|
||||
@@ -722,7 +730,7 @@ func validateTopDataValueEncodings(encodings []TopDataValueEncodingConfig) []err
|
||||
failures = append(failures, fmt.Errorf("%s.column is required", prefix))
|
||||
}
|
||||
switch strings.TrimSpace(encoding.Mode) {
|
||||
case "packed_hex_list":
|
||||
case "packed_hex_list", "alignment_hex_list":
|
||||
default:
|
||||
failures = append(failures, fmt.Errorf("%s.mode %q is not supported", prefix, encoding.Mode))
|
||||
}
|
||||
@@ -746,6 +754,28 @@ func validateTopDataValueEncodings(encodings []TopDataValueEncodingConfig) []err
|
||||
return failures
|
||||
}
|
||||
|
||||
func validateTopDataValueDefaults(defaults []TopDataValueDefaultConfig) []error {
|
||||
failures := []error{}
|
||||
seen := map[string]struct{}{}
|
||||
for index, valueDefault := range defaults {
|
||||
prefix := fmt.Sprintf("topdata.value_defaults[%d]", index)
|
||||
dataset := strings.TrimSpace(valueDefault.Dataset)
|
||||
column := strings.TrimSpace(valueDefault.Column)
|
||||
if dataset == "" {
|
||||
failures = append(failures, fmt.Errorf("%s.dataset is required", prefix))
|
||||
}
|
||||
if column == "" {
|
||||
failures = append(failures, fmt.Errorf("%s.column is required", prefix))
|
||||
}
|
||||
key := filepath.ToSlash(dataset) + "\x00" + strings.ToLower(column)
|
||||
if _, ok := seen[key]; ok {
|
||||
failures = append(failures, fmt.Errorf("%s duplicates an earlier dataset/column default", prefix))
|
||||
}
|
||||
seen[key] = struct{}{}
|
||||
}
|
||||
return failures
|
||||
}
|
||||
|
||||
func intPow(base, exponent int) int {
|
||||
result := 1
|
||||
for i := 0; i < exponent; i++ {
|
||||
|
||||
Reference in New Issue
Block a user