Ver código fonte

Merge branch 'master' of https://github.com/g3n/engine

Daniel Salvadori 3 anos atrás
pai
commit
253be6caa1
3 arquivos alterados com 31 adições e 33 exclusões
  1. 11 3
      README.md
  2. 16 30
      core/node.go
  3. 4 0
      gui/builder.go

+ 11 - 3
README.md

@@ -3,7 +3,7 @@
 <p align="center">
   <a href="https://godoc.org/github.com/g3n/engine"><img src="https://godoc.org/github.com/g3n/engine?status.svg" alt="Godoc"></img></a>
   <a href="https://goreportcard.com/report/github.com/g3n/engine"><img src="https://goreportcard.com/badge/github.com/g3n/engine" alt="Go Report Card"/></a>
-  <a href="https://discord.gg/Dq9FpV4c"><img src="https://img.shields.io/badge/Discord-G3N-blue" alt="Discord"/></a>
+  <a href="https://discord.gg/NfaeVr8zDg"><img src="https://img.shields.io/badge/Discord-G3N-blue" alt="Discord"/></a>
   
 </p>
 <p><h1 align="center">G3N - Go 3D Game Engine</h1></p>
@@ -35,16 +35,24 @@ On Unix-based systems the engine depends on some C libraries that can be install
 
 ### Fedora
 
-    $ sudo dnf -y install xorg-x11-proto-devel mesa-libGL mesa-libGL-devel openal-soft openal-soft-devel libvorbis libvorbis-devel glfw-devel libXi-devel
+    $ sudo dnf -y install xorg-x11-proto-devel mesa-libGL mesa-libGL-devel openal-soft openal-soft-devel libvorbis libvorbis-devel glfw-devel libXi-devel libXxf86vm-devel
 
 ### CentOS 7
 
 Enable the EPEL repository:
 
     $ sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
-
+    
 Then install the same packages as for Fedora - remember to use `yum` instead of `dnf` for the package installation command.
+    
+### Arch
 
+    $ sudo pacman -S base-devel xorg-server mesa openal libvorbis
+    
+### Void
+
+    $ sudo xbps-install git xorg-server-devel base-devel libvorbis-devel libvorbis libXxf86vm-devel libXcursor-devel libXrandr-devel libXinerama-devel libopenal libopenal-devel libglvnd-devel
+    
 ### Windows
 
 We tested the Windows build using the [mingw-w64](https://mingw-w64.org) toolchain (you can download [this file](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-posix/seh/x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z) in particular).

+ 16 - 30
core/node.go

@@ -246,41 +246,27 @@ func (n *Node) UserData() interface{} {
 	return n.userData
 }
 
-// FindPath finds a node with the specified path starting with this node and
-// searching in all its children recursively.
-// A path is the sequence of the names from the first node to the desired node
-// separated by the forward slash.
+// FindPath finds a node with the specified path by recursively searching the children.
+// A path is a sequence of names of nested child nodes, separated by a forward slash.
 func (n *Node) FindPath(path string) INode {
 
-	// Internal recursive function to find node
-	var finder func(inode INode, path string) INode
-	finder = func(inode INode, path string) INode {
-		// Get first component of the path
-		parts := strings.Split(path, "/")
-		if len(parts) == 0 {
-			return nil
-		}
-		first := parts[0]
-		// Checks current node
-		node := inode.GetNode()
-		if node.name != first {
-			return nil
-		}
-		// If the path has finished this is the desired node
-		rest := strings.Join(parts[1:], "/")
-		if rest == "" {
-			return inode
-		}
-		// Otherwise search in this node children
-		for _, ichild := range node.children {
-			found := finder(ichild, rest)
-			if found != nil {
-				return found
+	// Split the path into head + tail
+	parts := strings.SplitN(path, "/", 2)
+	if len(parts) != 1 && len(parts) != 2 {
+		panic("expected 1 or 2 parts from SplitN")
+	}
+
+	// Search the children
+	for _, ichild := range n.children {
+		if ichild.Name() == parts[0] {
+			if len(parts) == 1 {
+				return ichild
 			}
+			return ichild.GetNode().FindPath(parts[1])
 		}
-		return nil
 	}
-	return finder(n, path)
+
+	return nil
 }
 
 // FindLoaderID looks in the specified node and in all its children

+ 4 - 0
gui/builder.go

@@ -563,6 +563,10 @@ func (b *Builder) SetAttribs(am map[string]interface{}, ipan IPanel) error {
 		panel.SetName(am[AttribName].(string))
 	}
 
+	if am[AttribId] != nil {
+		panel.SetLoaderID(am[AttribId].(string))
+	}
+
 	if am[AttribVisible] != nil {
 		panel.SetVisible(am[AttribVisible].(bool))
 	}