// NewViewModel returns a new ViewModel instance. func NewViewModel() *ViewModel { vm := &ViewModel{} vm.projects = viewmodel.NewValueSelectionNode("Select", nil, "") vm.newProjectID = viewmodel.NewEditableStringValueNode("New Project Name", "") vm.createProject = viewmodel.NewActionNode("Create Project") vm.textureCount = viewmodel.NewStringValueNode("Texture Count", "") projectSection := viewmodel.NewSectionNode("Project", []viewmodel.Node{vm.projects, vm.newProjectID, vm.createProject, vm.textureCount}, viewmodel.NewBoolValueNode("Available", true)) vm.levels = viewmodel.NewValueSelectionNode("Level", nil, "") vm.levelIsRealWorld = viewmodel.NewBoolValueNode("Is Real World", false) vm.tiles = NewTilesViewModel(vm.levelIsRealWorld) vm.levelObjects = NewObjectsViewModel(vm.levelIsRealWorld) vm.levelTextureIndex = viewmodel.NewValueSelectionNode("Texture Index", []string{""}, "") vm.levelTextureID = viewmodel.NewValueSelectionNode("Texture ID", []string{""}, "") levelTexturesControlSection := viewmodel.NewSectionNode("Level Textures", []viewmodel.Node{vm.levelTextureIndex, vm.levelTextureID}, vm.levelIsRealWorld) mapControlSection := viewmodel.NewSectionNode("Control", []viewmodel.Node{vm.levels}, viewmodel.NewBoolValueNode("", true)) mapSectionSelection := viewmodel.NewSectionSelectionNode("Map Section", map[string]*viewmodel.SectionNode{ "Control": mapControlSection, "Level Textures": levelTexturesControlSection, "Tiles": vm.tiles.root, "Objects": vm.levelObjects.root}, "Control") projectSelected := viewmodel.NewBoolValueNode("Available", false) vm.projects.Selected().Subscribe(func(projectID string) { projectSelected.Set(projectID != "") }) mapSection := viewmodel.NewSectionNode("Map", []viewmodel.Node{mapSectionSelection}, projectSelected) vm.mainSection = viewmodel.NewSectionSelectionNode("Section", map[string]*viewmodel.SectionNode{ "Project": projectSection, "Map": mapSection}, "Project") vm.pointerCoordinate = viewmodel.NewStringValueNode("Pointer at", "") vm.root = viewmodel.NewSectionNode("", []viewmodel.Node{vm.mainSection, vm.pointerCoordinate}, viewmodel.NewBoolValueNode("", true)) return vm }
// NewObjectsViewModel returns a new instance of a ObjectsViewModel. func NewObjectsViewModel(levelIsRealWorld *viewmodel.BoolValueNode) *ObjectsViewModel { vm := &ObjectsViewModel{} vm.selectedObject = viewmodel.NewValueSelectionNode("Selected Object", []string{""}, "") vm.cst = viewmodel.NewStringValueNode("C/S/T", "") vm.root = viewmodel.NewSectionNode("Objects", []viewmodel.Node{vm.selectedObject, vm.cst}, viewmodel.NewBoolValueNode("", true)) return vm }