func (info *VersionInfo) FromKeyValues(kv *keyvalues.KeyValues) error { if !strings.EqualFold(kv.Name(), "versioninfo") { return fmt.Errorf("VersionInfo: key name was %q, not %q", kv.Name(), "versioninfo") } info.EditorVersion = kv.SubKey("editorversion").Int(0) info.EditorBuild = kv.SubKey("editorbuild").Int(0) info.MapVersion = kv.SubKey("mapversion").Int(0) info.FormatVersion = kv.SubKey("formatversion").Int(0) info.Prefab = kv.SubKey("prefab").Bool(false) return nil }
func (vg *VisGroups) FromKeyValues(kv *keyvalues.KeyValues) error { if !strings.EqualFold(kv.Name(), "visgroups") { return fmt.Errorf("VisGroups: key name was %q, not %q", kv.Name(), "visgroups") } *vg = (*vg)[:0] for subkey := range kv.Each() { var group VisGroup if err := group.FromKeyValues(subkey); err != nil { return err } *vg = append(*vg, group) } return nil }
func (vg *VisGroup) FromKeyValues(kv *keyvalues.KeyValues) error { if !strings.EqualFold(kv.Name(), "visgroup") { return fmt.Errorf("VisGroup: key name was %q, not %q", kv.Name(), "visgroup") } if name := kv.SubKey("name").String(""); name != "" { vg.Name = name } else { return fmt.Errorf("VisGroup: no name") } if id := kv.SubKey("visgroupid").Int(0); id > 0 { vg.ID = id } else { return fmt.Errorf("VisGroup: %s: ID = %d or no ID", vg.Name, id) } if err := vg.Color.FromKeyValues(kv.SubKey("color")); err != nil { return fmt.Errorf("VisGroup: %s: %v", vg.Name, err) } return nil }