Ver Fonte

Merge pull request #466 from LumaDigital/master

Player setup doesn't override engine parameters, constants for .pak file extensions.
JoshEngebretson há 10 anos atrás
pai
commit
f90301a204

+ 2 - 0
Script/AtomicEditor/ui/frames/inspector/MaterialInspector.ts

@@ -18,6 +18,7 @@ solidSource.addItem(new Atomic.UIMenuItem("Diffuse", "Diffuse"));
 solidSource.addItem(new Atomic.UIMenuItem("Diffuse Emissive", "Diffuse Emissive"));
 solidSource.addItem(new Atomic.UIMenuItem("Diffuse Emissive", "Diffuse Emissive"));
 solidSource.addItem(new Atomic.UIMenuItem("Diffuse Normal", "Diffuse Normal"));
 solidSource.addItem(new Atomic.UIMenuItem("Diffuse Normal", "Diffuse Normal"));
 solidSource.addItem(new Atomic.UIMenuItem("Diffuse Normal Specular", "Diffuse Normal Specular"));
 solidSource.addItem(new Atomic.UIMenuItem("Diffuse Normal Specular", "Diffuse Normal Specular"));
+solidSource.addItem(new Atomic.UIMenuItem("Diffuse Unlit", "Diffuse Unlit"));
 
 
 var tranSource = new Atomic.UIMenuItemSource();
 var tranSource = new Atomic.UIMenuItemSource();
 tranSource.addItem(new Atomic.UIMenuItem("Alpha", "Alpha"));
 tranSource.addItem(new Atomic.UIMenuItem("Alpha", "Alpha"));
@@ -49,6 +50,7 @@ var techniqueLookup = {
     "Techniques/DiffEmissive.xml": "Diffuse Emissive",
     "Techniques/DiffEmissive.xml": "Diffuse Emissive",
     "Techniques/DiffNormal.xml": "Diffuse Normal",
     "Techniques/DiffNormal.xml": "Diffuse Normal",
     "Techniques/DiffNormalSpec.xml": "Diffuse Normal Specular",
     "Techniques/DiffNormalSpec.xml": "Diffuse Normal Specular",
+    "Techniques/DiffUnlit.xml": "Diffuse Unlit",
     "Techniques/DiffAlpha.xml": "Alpha",
     "Techniques/DiffAlpha.xml": "Alpha",
     "Techniques/DiffAlphaMask.xml": "Alpha Mask",
     "Techniques/DiffAlphaMask.xml": "Alpha Mask",
     "Techniques/DiffAdd.xml": "Additive"
     "Techniques/DiffAdd.xml": "Additive"

+ 18 - 0
Source/Atomic/Container/HashMap.h

@@ -358,6 +358,24 @@ public:
             InsertNode(*it++);
             InsertNode(*it++);
     }
     }
 
 
+    // ATOMIC BEGIN
+
+    /// Insert a pair only if a corresponding key does not already exist.
+    Iterator InsertNew(const T& key, const U& value)
+    {
+        unsigned hashKey = Hash(key);
+        if (ptrs_) 
+        {
+            Node* node = FindNode(key, hashKey);
+            if (node)
+                return Iterator(node);
+        }
+
+        return InsertNode(key, value, false);
+    }
+
+    // ATOMIC END
+
     /// Erase a pair by key. Return true if was found.
     /// Erase a pair by key. Return true if was found.
     bool Erase(const T& key)
     bool Erase(const T& key)
     {
     {

+ 10 - 3
Source/Atomic/Engine/Engine.cpp

@@ -245,7 +245,7 @@ bool Engine::Initialize(const VariantMap& parameters)
         // If path is not absolute, prefer to add it as a package if possible
         // If path is not absolute, prefer to add it as a package if possible
         if (!IsAbsolutePath(resourcePaths[i]))
         if (!IsAbsolutePath(resourcePaths[i]))
         {
         {
-            String packageName = resourcePrefixPath + resourcePaths[i] + ".pak";
+            String packageName = resourcePrefixPath + resourcePaths[i] + PAK_EXTENSION;
             if (fileSystem->FileExists(packageName))
             if (fileSystem->FileExists(packageName))
                 success = cache->AddPackageFile(packageName);
                 success = cache->AddPackageFile(packageName);
 
 
@@ -259,7 +259,9 @@ bool Engine::Initialize(const VariantMap& parameters)
         else
         else
         {
         {
             String pathName = resourcePaths[i];
             String pathName = resourcePaths[i];
-            if (fileSystem->DirExists(pathName))
+            if (pathName.EndsWith(PAK_EXTENSION) && fileSystem->FileExists(pathName))
+                success = cache->AddPackageFile(pathName);
+            else if (fileSystem->DirExists(pathName))
                 success = cache->AddResourceDir(pathName);
                 success = cache->AddResourceDir(pathName);
         }
         }
 
 
@@ -320,7 +322,7 @@ bool Engine::Initialize(const VariantMap& parameters)
 
 
             // Add all the found package files (non-recursive)
             // Add all the found package files (non-recursive)
             Vector<String> paks;
             Vector<String> paks;
-            fileSystem->ScanDir(paks, autoLoadPath, "*.pak", SCAN_FILES, false);
+            fileSystem->ScanDir(paks, autoLoadPath, PAK_EXTENSION, SCAN_FILES, false);
             for (unsigned y = 0; y < paks.Size(); ++y)
             for (unsigned y = 0; y < paks.Size(); ++y)
             {
             {
                 String pak = paks[y];
                 String pak = paks[y];
@@ -829,6 +831,11 @@ VariantMap Engine::ParseParameters(const Vector<String>& arguments)
                     ++i;
                     ++i;
                 }
                 }
             }
             }
+            else if (argument == "logname" && !value.Empty())
+            {
+                ret["LogName"] = value;
+                ++i;
+            }
             else if (argument == "x" && !value.Empty())
             else if (argument == "x" && !value.Empty())
             {
             {
                 ret["WindowWidth"] = ToInt(value);
                 ret["WindowWidth"] = ToInt(value);

+ 1 - 1
Source/Atomic/IO/FileSystem.cpp

@@ -778,7 +778,7 @@ void FileSystem::ScanDirInternal(Vector<String>& result, String path, const Stri
     if (path.Length() > startPath.Length())
     if (path.Length() > startPath.Length())
         deltaPath = path.Substring(startPath.Length());
         deltaPath = path.Substring(startPath.Length());
 
 
-    String filterExtension = filter.Substring(filter.Find('.'));
+    String filterExtension = filter.Substring(filter.FindLast('.'));
     if (filterExtension.Contains('*'))
     if (filterExtension.Contains('*'))
         filterExtension.Clear();
         filterExtension.Clear();
 
 

+ 2 - 0
Source/Atomic/Resource/ResourceCache.cpp

@@ -64,6 +64,8 @@ static const char* checkDirs[] =
 };
 };
 
 
 static const SharedPtr<Resource> noResource;
 static const SharedPtr<Resource> noResource;
+const char* Atomic::PAK_EXTENSION = ".pak";
+const char* Atomic::PAK_FILTER = "*.pak";
 
 
 ResourceCache::ResourceCache(Context* context) :
 ResourceCache::ResourceCache(Context* context) :
     Object(context),
     Object(context),

+ 4 - 0
Source/Atomic/Resource/ResourceCache.h

@@ -37,6 +37,10 @@ class PackageFile;
 
 
 /// Sets to priority so that a package or file is pushed to the end of the vector.
 /// Sets to priority so that a package or file is pushed to the end of the vector.
 static const unsigned PRIORITY_LAST = 0xffffffff;
 static const unsigned PRIORITY_LAST = 0xffffffff;
+/// Extension used for package files
+extern const char* PAK_EXTENSION;
+/// File search filter used to find package files
+extern const char* PAK_FILTER;
 
 
 /// Container of resources with specific type.
 /// Container of resources with specific type.
 struct ResourceGroup
 struct ResourceGroup

+ 18 - 18
Source/AtomicPlayer/Application/AtomicPlayer.cpp

@@ -76,35 +76,35 @@ void AtomicPlayerApp::Setup()
     FileSystem* filesystem = GetSubsystem<FileSystem>();
     FileSystem* filesystem = GetSubsystem<FileSystem>();
     context_->RegisterSubsystem(new ScriptSystem(context_));
     context_->RegisterSubsystem(new ScriptSystem(context_));
 
 
-    engineParameters_["WindowTitle"] = "AtomicPlayer";
+    engineParameters_.InsertNew("WindowTitle", "AtomicPlayer");
 
 
 #if (ATOMIC_PLATFORM_ANDROID)
 #if (ATOMIC_PLATFORM_ANDROID)
-    engineParameters_["FullScreen"] = true;
-    engineParameters_["ResourcePaths"] = "CoreData;PlayerData;Cache;AtomicResources";
+    engineParameters_.InsertNew("FullScreen", true);
+    engineParameters_.InsertNew("ResourcePaths", "CoreData;PlayerData;Cache;AtomicResources");
 #elif ATOMIC_PLATFORM_WEB
 #elif ATOMIC_PLATFORM_WEB
-    engineParameters_["FullScreen"] = false;
-    engineParameters_["ResourcePaths"] = "AtomicResources";
-    // engineParameters_["WindowWidth"] = 1280;
-    // engineParameters_["WindowHeight"] = 720;
+    engineParameters_.InsertNew("FullScreen", false);
+    engineParameters_.InsertNew("ResourcePaths", "AtomicResources");
+    // engineParameters_.InsertNew("WindowWidth", 1280);
+    // engineParameters_.InsertNew("WindowHeight", 720);
 #elif ATOMIC_PLATFORM_IOS
 #elif ATOMIC_PLATFORM_IOS
-    engineParameters_["FullScreen"] = false;
-    engineParameters_["ResourcePaths"] = "AtomicResources";
+    engineParameters_.InsertNew("FullScreen", false);
+    engineParameters_.InsertNew("ResourcePaths", "AtomicResources");
 #else
 #else
-    engineParameters_["FullScreen"] = false;
-    engineParameters_["WindowWidth"] = 1280;
-    engineParameters_["WindowHeight"] = 720;
-    engineParameters_["ResourcePaths"] = "AtomicResources";
+    engineParameters_.InsertNew("FullScreen", false);
+    engineParameters_.InsertNew("WindowWidth", 1280);
+    engineParameters_.InsertNew("WindowHeight", 720);
+    engineParameters_.InsertNew("ResourcePaths", "AtomicResources");
 #endif
 #endif
 
 
 #if ATOMIC_PLATFORM_WINDOWS
 #if ATOMIC_PLATFORM_WINDOWS
 
 
-    engineParameters_["WindowIcon"] = "Images/AtomicLogo32.png";
-    engineParameters_["ResourcePrefixPath"] = "AtomicPlayer_Resources";
+    engineParameters_.InsertNew("WindowIcon", "Images/AtomicLogo32.png");
+    engineParameters_.InsertNew("ResourcePrefixPath", "AtomicPlayer_Resources");
 
 
 #elif ATOMIC_PLATFORM_ANDROID
 #elif ATOMIC_PLATFORM_ANDROID
-    //engineParameters_["ResourcePrefixPath"] = "assets";
+    //engineParameters_.InsertNew("ResourcePrefixPath"], "assets");
 #elif ATOMIC_PLATFORM_OSX
 #elif ATOMIC_PLATFORM_OSX
-    engineParameters_["ResourcePrefixPath"] = "../Resources";
+    engineParameters_.InsertNew("ResourcePrefixPath", "../Resources");
 #endif
 #endif
 
 
     const Vector<String>& arguments = GetArguments();
     const Vector<String>& arguments = GetArguments();
@@ -124,7 +124,7 @@ void AtomicPlayerApp::Setup()
     }
     }
 
 
     // Use the script file name as the base name for the log file
     // Use the script file name as the base name for the log file
-    engineParameters_["LogName"] = filesystem->GetAppPreferencesDir("AtomicPlayer", "Logs") + "AtomicPlayer.log";
+    engineParameters_.InsertNew("LogName", filesystem->GetAppPreferencesDir("AtomicPlayer", "Logs") + "AtomicPlayer.log");
 }
 }
 
 
 void AtomicPlayerApp::Start()
 void AtomicPlayerApp::Start()

+ 2 - 1
Source/ToolCore/Build/BuildIOS.cpp

@@ -7,6 +7,7 @@
 
 
 #include <Atomic/IO/File.h>
 #include <Atomic/IO/File.h>
 #include <Atomic/IO/FileSystem.h>
 #include <Atomic/IO/FileSystem.h>
+#include <Atomic/Resource/ResourceCache.h>
 
 
 #include "../ToolSystem.h"
 #include "../ToolSystem.h"
 #include "../ToolEnvironment.h"
 #include "../ToolEnvironment.h"
@@ -308,7 +309,7 @@ void BuildIOS::Build(const String& buildPath)
 
 
     fileSystem->CreateDir(buildDestDist);
     fileSystem->CreateDir(buildDestDist);
 
 
-    String resourcePackagePath = buildDestDist + "/AtomicResources.pak";
+    String resourcePackagePath = buildDestDist + "/AtomicResources" + PAK_EXTENSION;
     GenerateResourcePackage(resourcePackagePath);
     GenerateResourcePackage(resourcePackagePath);
 
 
     fileSystem->Copy(buildAppSourceDir + "/AtomicPlayer", buildDestDist + "/AtomicPlayer");
     fileSystem->Copy(buildAppSourceDir + "/AtomicPlayer", buildDestDist + "/AtomicPlayer");

+ 2 - 1
Source/ToolCore/Build/BuildMac.cpp

@@ -6,6 +6,7 @@
 //
 //
 
 
 #include <Atomic/IO/FileSystem.h>
 #include <Atomic/IO/FileSystem.h>
+#include <Atomic/Resource/ResourceCache.h>
 
 
 #include "../ToolSystem.h"
 #include "../ToolSystem.h"
 #include "../ToolEnvironment.h"
 #include "../ToolEnvironment.h"
@@ -81,7 +82,7 @@ void BuildMac::Build(const String& buildPath)
     fileSystem->CreateDir(buildPath_ + "/Contents/MacOS");
     fileSystem->CreateDir(buildPath_ + "/Contents/MacOS");
     fileSystem->CreateDir(buildPath_ + "/Contents/Resources");
     fileSystem->CreateDir(buildPath_ + "/Contents/Resources");
 
 
-    String resourcePackagePath = buildPath_ + "/Contents/Resources/AtomicResources.pak";
+    String resourcePackagePath = buildPath_ + "/Contents/Resources/AtomicResources" + PAK_EXTENSION;
     GenerateResourcePackage(resourcePackagePath);
     GenerateResourcePackage(resourcePackagePath);
 
 
     fileSystem->Copy(appSrcPath + "/Contents/Resources/Atomic.icns", buildPath_ + "/Contents/Resources/Atomic.icns");
     fileSystem->Copy(appSrcPath + "/Contents/Resources/Atomic.icns", buildPath_ + "/Contents/Resources/Atomic.icns");

+ 2 - 1
Source/ToolCore/Build/BuildWeb.cpp

@@ -8,6 +8,7 @@
 #include <Atomic/Core/StringUtils.h>
 #include <Atomic/Core/StringUtils.h>
 #include <Atomic/IO/FileSystem.h>
 #include <Atomic/IO/FileSystem.h>
 #include <Atomic/IO/File.h>
 #include <Atomic/IO/File.h>
+#include <Atomic/Resource/ResourceCache.h>
 
 
 #include "../ToolSystem.h"
 #include "../ToolSystem.h"
 #include "../ToolEnvironment.h"
 #include "../ToolEnvironment.h"
@@ -99,7 +100,7 @@ void BuildWeb::Build(const String& buildPath)
     file.Close();
     file.Close();
 
 
     String request;
     String request;
-    request.AppendWithFormat("new DataRequest(0, %i, 0, 0).open('GET', '/AtomicResources.pak');", rsize);
+    request.AppendWithFormat("new DataRequest(0, %i, 0, 0).open('GET', '/AtomicResources%s');", rsize, PAK_EXTENSION);
 
 
     resourcejs.Replace("$$REMOTE_PACKAGE_SIZE$$", ToString("%i", rsize));
     resourcejs.Replace("$$REMOTE_PACKAGE_SIZE$$", ToString("%i", rsize));
     resourcejs.Replace("$$ATOMIC_RESOURCES_DATA_REQUEST$$", request);
     resourcejs.Replace("$$ATOMIC_RESOURCES_DATA_REQUEST$$", request);

+ 2 - 1
Source/ToolCore/Build/BuildWindows.cpp

@@ -7,6 +7,7 @@
 
 
 #include <Atomic/Core/StringUtils.h>
 #include <Atomic/Core/StringUtils.h>
 #include <Atomic/IO/FileSystem.h>
 #include <Atomic/IO/FileSystem.h>
+#include <Atomic/Resource/ResourceCache.h>
 
 
 #include "../ToolSystem.h"
 #include "../ToolSystem.h"
 #include "../ToolEnvironment.h"
 #include "../ToolEnvironment.h"
@@ -143,7 +144,7 @@ void BuildWindows::Build(const String& buildPath)
     fileSystem->CreateDir(buildPath_);
     fileSystem->CreateDir(buildPath_);
     fileSystem->CreateDir(buildPath_ + "/AtomicPlayer_Resources");
     fileSystem->CreateDir(buildPath_ + "/AtomicPlayer_Resources");
 
 
-    String resourcePackagePath = buildPath_ + "/AtomicPlayer_Resources/AtomicResources.pak";
+    String resourcePackagePath = buildPath_ + "/AtomicPlayer_Resources/AtomicResources" + PAK_EXTENSION;
     GenerateResourcePackage(resourcePackagePath);
     GenerateResourcePackage(resourcePackagePath);
 
 
     fileSystem->Copy(playerBinary, buildPath_ + "/AtomicPlayer.exe");
     fileSystem->Copy(playerBinary, buildPath_ + "/AtomicPlayer.exe");