Skip to content

Commit

Permalink
Merge pull request #294 from GothicVRProject/feature/sky-improvements
Browse files Browse the repository at this point in the history
Feature/sky improvements
  • Loading branch information
JucanAndreiDaniel authored Jan 27, 2024
2 parents 3370111 + 8787d2e commit 4289247
Show file tree
Hide file tree
Showing 14 changed files with 5,371 additions and 146 deletions.
4,996 changes: 4,994 additions & 2 deletions Assets/GothicVR/Resources/Prefabs/UI Element Prefabs/VRPlayer.prefab

Large diffs are not rendered by default.

28 changes: 16 additions & 12 deletions Assets/GothicVR/Scripts/Data/SkyState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public class SkyState
public int cloudShadowOn;
public SkyLayerData[] layer;

// how long the transition should take
// 0.05 = 1 hour and 12 minutes
public float lerpDuration = 0.05f;

public SkyState()
{
layer = new SkyLayerData[2];
Expand Down Expand Up @@ -56,11 +60,11 @@ public void PresetDay0()
domeColor0 = fogColor;
domeColor1 = new Vector3(255.0f, 255.0f, 255.0f);

layer[0].texName = "SKYDAY_LAYER1_A0.TGA";
layer[1].texName = "SKYDAY_LAYER0_A0.TGA";
layer[0].texName = "SKYDAY_LAYER0_A0.TGA";
layer[1].texName = "SKYDAY_LAYER1_A0.TGA";

layer[0].texAlpha = 0.0f;
layer[1].texAlpha = 255.0f;
layer[0].texAlpha = 255.0f;
layer[1].texAlpha = 0.0f;

layer[1].texSpeed *= 0.2f;

Expand All @@ -77,11 +81,11 @@ public void PresetDay1()
domeColor0 = fogColor;
domeColor1 = new Vector3(255.0f, 255.0f, 255.0f);

layer[0].texName = "SKYDAY_LAYER1_A0.TGA";
layer[1].texName = "SKYDAY_LAYER0_A0.TGA";
layer[0].texName = "SKYDAY_LAYER0_A0.TGA";
layer[1].texName = "SKYDAY_LAYER1_A0.TGA";

layer[0].texAlpha = 215.0f;
layer[1].texAlpha = 255.0f;
layer[0].texAlpha = 255.0f;
layer[1].texAlpha = 215.0f;

fogDist = 0.05f;
sunOn = 1;
Expand All @@ -96,11 +100,11 @@ public void PresetDay2()
domeColor0 = new Vector3(120.0f, 140.0f, 180.0f);
domeColor1 = new Vector3(255.0f, 255.0f, 255.0f);

layer[0].texName = "SKYDAY_LAYER1_A0.TGA";
layer[1].texName = "SKYDAY_LAYER0_A0.TGA";
layer[0].texName = "SKYDAY_LAYER0_A0.TGA";
layer[1].texName = "SKYDAY_LAYER1_A0.TGA";

layer[0].texAlpha = 0.0f;
layer[1].texAlpha = 255.0f;
layer[0].texAlpha = 255.0f;
layer[1].texAlpha = 0.0f;

fogDist = 0.05f;
sunOn = 1;
Expand Down
7 changes: 7 additions & 0 deletions Assets/GothicVR/Scripts/Data/SkyStateRain.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace GVR.Data
{
public class SkyStateRain :SkyState
{
public float endTime;
}
}
11 changes: 11 additions & 0 deletions Assets/GothicVR/Scripts/Data/SkyStateRain.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions Assets/GothicVR/Scripts/Extensions/NumericsExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,25 @@ public static UnityEngine.Vector3 ToUnityVector(this Vector3 vector3)
return vector / 100;
}

public static UnityEngine.Color ToUnityColor(this Vector3 vector3)
public static UnityEngine.Color ToUnityColor(this Vector3 vector3, float alpha = 1)
{
return new UnityEngine.Color()
{
r = vector3.X,
g = vector3.Y,
b = vector3.Z
b = vector3.Z,
a = alpha
};
}

public static UnityEngine.Color ToUnityColor(this UnityEngine.Vector3 vector3)
public static UnityEngine.Color ToUnityColor(this UnityEngine.Vector3 vector3, float alpha = 1)
{
return new UnityEngine.Color()
{
r = vector3.x,
g = vector3.y,
b = vector3.z
b = vector3.z,
a = alpha
};
}

Expand Down
9 changes: 6 additions & 3 deletions Assets/GothicVR/Scripts/Manager/Settings/GameSettings.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
namespace GVR.Manager.Settings
using System.Collections.Generic;

namespace GVR.Manager.Settings
{
[System.Serializable]
public class GameSettings
{
public string GothicIPath;
public string GothicILanguage;
public string LogLevel;

public string GothicMenuFontPath;
public string GothicSubtitleFontPath;

public Dictionary<string, Dictionary<string, string>> GothicINISettings = new();
}
}
}
49 changes: 45 additions & 4 deletions Assets/GothicVR/Scripts/Manager/Settings/SettingsManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;
Expand Down Expand Up @@ -29,7 +30,9 @@ public static void SaveGameSettings(GameSettings gameSettings)

public static void LoadGameSettings()
{
var settingsFilePath = $"{GetRootPath()}/{SETTINGS_FILE_NAME}";
var rootPath = GetRootPath();

var settingsFilePath = $"{rootPath}/{SETTINGS_FILE_NAME}";
if (!File.Exists(settingsFilePath))
{
if (Application.platform == RuntimePlatform.Android)
Expand All @@ -43,14 +46,23 @@ public static void LoadGameSettings()

// We ignore the "GothicIPath" field which is found in GameSettings for Android
if (Application.platform == RuntimePlatform.Android)
GameSettings.GothicIPath = GetRootPath();
GameSettings.GothicIPath = rootPath;

var settingsDevFilePath = $"{GetRootPath()}/{SETTINGS_FILE_NAME_DEV}";
var settingsDevFilePath = $"{rootPath}/{SETTINGS_FILE_NAME_DEV}";
if (File.Exists(settingsDevFilePath))
{
var devJson = File.ReadAllText(settingsDevFilePath);
JsonUtility.FromJsonOverwrite(devJson, GameSettings);
}

var iniFilePath = Path.Combine(GameSettings.GothicIPath, "system", "gothic.ini");
if (!File.Exists(iniFilePath))
{
Debug.Log("The gothic.ini file does not exist at the specified path :" + iniFilePath);
return;
}

GameSettings.GothicINISettings = ParseGothicINI(iniFilePath);
}

/// <summary>
Expand Down Expand Up @@ -103,5 +115,34 @@ private static void CopyGameSettingsForAndroidBuild()
string FinalPath = Path.Combine(Application.persistentDataPath, $"{SETTINGS_FILE_NAME}");
File.WriteAllText(FinalPath, result);
}

private static Dictionary<string, Dictionary<string, string>> ParseGothicINI(string filePath)
{
var data = new Dictionary<string, Dictionary<string, string>>();
string currentSection = null;

foreach (var line in File.ReadLines(filePath))
{
string trimmedLine = line.Trim();
if (string.IsNullOrWhiteSpace(trimmedLine) || trimmedLine.StartsWith(";"))
continue;

if (trimmedLine.StartsWith("[") && trimmedLine.EndsWith("]"))
{
currentSection = trimmedLine.Substring(1, trimmedLine.Length - 2);
data[currentSection] = new Dictionary<string, string>();
}
else
{
var keyValue = trimmedLine.Split(new char[] { '=' }, 2);
if (keyValue.Length == 2 && currentSection != null)
{
data[currentSection][keyValue[0].Trim()] = keyValue[1].Trim();
}
}
}

return data;
}
}
}
}
Loading

0 comments on commit 4289247

Please sign in to comment.