Exemplo n.º 1
0
    public static string FixMapsPath(string BlueprintPath)
    {
        if (GetGamedataFile.IsMapPath(BlueprintPath))
        {
            //Debug.Log(MapLuaParser.Current.FolderName);
            if (!BlueprintPath.StartsWith("/maps/" + MapLuaParser.Current.FolderName) && !BlueprintPath.StartsWith("maps/" + MapLuaParser.Current.FolderName))
            {
                //if (!System.IO.File.Exists(GetGamedataFile.MapAssetSystemPath(BlueprintPath)))
                //{
                string NewBlueprintPath = GetGamedataFile.TryRecoverMapAsset(BlueprintPath);
                Debug.Log("Before: " + BlueprintPath + ", after: " + NewBlueprintPath);

                if (!string.IsNullOrEmpty(NewBlueprintPath))
                {
                    return(NewBlueprintPath);
                }
                else
                {
                    Debug.LogError("Unable to recover wrong map path: " + BlueprintPath);
                }
            }
        }
        return(BlueprintPath);
    }
Exemplo n.º 2
0
    public void LoadStratumScdTextures(bool Loading = true)
    {
        // Load Stratum Textures Paths


        bool NormalMapFix = false;

        for (int i = 0; i < Textures.Length; i++)
        {
            if (Loading)
            {
                MapLuaParser.Current.InfoPopup.Show(true, "Loading map...\n( Stratum textures " + (i + 1) + " )");

                if (i >= map.Layers.Count)
                {
                    map.Layers.Add(new Layer());
                }

                Textures[i].AlbedoPath = GetGamedataFile.FixMapsPath(map.Layers[i].PathTexture);
                if (Textures[i].AlbedoPath.StartsWith("/"))
                {
                    Textures[i].AlbedoPath = Textures[i].AlbedoPath.Remove(0, 1);
                }
                Textures[i].AlbedoScale = map.Layers[i].ScaleTexture;


                if (string.IsNullOrEmpty(map.Layers[i].PathNormalmap))
                {
                    if (i == 9)
                    {
                        // Upper stratum normal should be empty!
                        Textures[i].NormalPath = "";
                    }
                    else
                    {
                        Textures[i].NormalPath = "env/tundra/layers/tund_sandlight_normal.dds";
                        NormalMapFix           = true;
                    }
                }
                else
                {
                    if (i == 9)
                    {
                        // Upper stratum normal should be empty!
                        Textures[i].NormalPath = "";
                        NormalMapFix           = true;
                    }
                    else
                    {
                        Textures[i].NormalPath = GetGamedataFile.FixMapsPath(map.Layers[i].PathNormalmap);
                        if (Textures[i].NormalPath.StartsWith("/"))
                        {
                            Textures[i].NormalPath = Textures[i].NormalPath.Remove(0, 1);
                        }
                    }
                }
                Textures[i].NormalScale = map.Layers[i].ScaleNormalmap;
            }


            string Env = GetGamedataFile.EnvScd;
            if (GetGamedataFile.IsMapPath(Textures[i].AlbedoPath))
            {
                Env = GetGamedataFile.MapScd;
            }

            try
            {
                Textures[i].AlbedoPath = GetGamedataFile.FindFile(Env, Textures[i].AlbedoPath);
                //Debug.Log("Found: " + Textures[i].AlbedoPath);
                GetGamedataFile.LoadTextureFromGamedata(GetGamedataFile.EnvScd, Textures[i].AlbedoPath, i, false);
            }
            catch (System.Exception e)
            {
                Debug.LogError(i + ", Albedo tex: " + Textures[i].AlbedoPath);
                Debug.LogError(e);
            }
            Env = GetGamedataFile.EnvScd;
            if (GetGamedataFile.IsMapPath(Textures[i].NormalPath))
            {
                Env = GetGamedataFile.MapScd;
            }

            try
            {
                Textures[i].NormalPath = GetGamedataFile.FindFile(Env, Textures[i].NormalPath);
                //Debug.Log("Found: " + Textures[i].NormalPath);
                GetGamedataFile.LoadTextureFromGamedata(GetGamedataFile.EnvScd, Textures[i].NormalPath, i, true);
            }
            catch (System.Exception e)
            {
                Debug.LogError(i + ", Normal tex: " + Textures[i].NormalPath);
                Debug.LogError(e);
            }
        }


        if (NormalMapFix)
        {
            GenericInfoPopup.ShowInfo("Fixed wrong or missing normalmap textures on stratum layers");
        }
    }