From 227caada9990573ff247ed206920c8fed6987fff Mon Sep 17 00:00:00 2001 From: Yannick Date: Tue, 18 Oct 2016 14:01:31 +0200 Subject: [PATCH] Few fixes for the 0.4 release. More exposed parameters in config.ini. Few fixes for VR about books and scrolls. Changed the InputManager to use Button_1/4 for actions --- .gitignore | 18 ++---------- Assets/Materials/Underwater_Reversed.mat | 8 ++--- Assets/Prefabs/TESUnity.prefab | 6 ++-- Assets/Scenes/Scene.unity.meta | 2 +- .../TES/Components/PathSelectionComponent.cs | 22 +++++++++++++- .../Scripts/TES/Components/PlayerComponent.cs | 9 ++++-- .../TES/Components/Records/BookComponent.cs | 18 ------------ .../TES/Components/Records/WeaponComponent.cs | 2 +- Assets/Scripts/TES/MorrowindEngine.cs | 15 +++++++++- Assets/Scripts/TES/TESUnity.cs | 17 +++++++---- Assets/Scripts/TES/UI/UIBook.cs | 9 ++++++ Assets/Scripts/TES/UI/UIScroll.cs | 9 ++++++ CHANGES.md | 15 ++++++++++ ProjectSettings/InputManager.asset | 18 ++++++------ README.md | 29 +++++++++++++++---- config.ini.dist | 28 ++++++++++++++++++ 16 files changed, 159 insertions(+), 66 deletions(-) create mode 100644 config.ini.dist diff --git a/.gitignore b/.gitignore index 672a860..26188ac 100644 --- a/.gitignore +++ b/.gitignore @@ -6,18 +6,10 @@ Thumbs.db.meta .vs .vscode -# Build files +# Android Build files *.apk *.obb -# Lightmaps -*.exr -*.exr.meta -LightmapSnapshot.asset -LightmapSnapshot.asset.meta -LightingData.asset -LightingData.asset.meta - # Visual Studio files *.cachefile *.csproj @@ -29,8 +21,7 @@ LightingData.asset.meta *.userprefs *.v11 *.v12 - -# Misc +*.VC.db [C|c]onfig.ini # Folder to exclude @@ -42,9 +33,4 @@ ipch/ Library/ obj/ Temp/ -UWP/ -WindowsStore/ -WS/ -UnityVS/ -UnityVS.meta Data Files/ \ No newline at end of file diff --git a/Assets/Materials/Underwater_Reversed.mat b/Assets/Materials/Underwater_Reversed.mat index fc9d92b..9f781dc 100644 --- a/Assets/Materials/Underwater_Reversed.mat +++ b/Assets/Materials/Underwater_Reversed.mat @@ -8,9 +8,9 @@ Material: m_PrefabInternal: {fileID: 0} m_Name: Underwater_Reversed m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} - m_ShaderKeywords: _ALPHAPREMULTIPLY_ON _EMISSION + m_ShaderKeywords: _EMISSION m_LightmapFlags: 1 - m_CustomRenderQueue: 3000 + m_CustomRenderQueue: -1 stringTagMap: RenderType: Transparent m_SavedProperties: @@ -82,7 +82,7 @@ Material: second: 1 - first: name: _DstBlend - second: 10 + second: 0 - first: name: _GlossMapScale second: 1 @@ -118,7 +118,7 @@ Material: second: 0 - first: name: _ZWrite - second: 0 + second: 1 m_Colors: - first: name: _Color diff --git a/Assets/Prefabs/TESUnity.prefab b/Assets/Prefabs/TESUnity.prefab index 12bfe9c..8dbd37f 100644 --- a/Assets/Prefabs/TESUnity.prefab +++ b/Assets/Prefabs/TESUnity.prefab @@ -44,16 +44,17 @@ MonoBehaviour: dataPath: useKinematicRigidbodies: 1 playMusic: 1 + materialType: 2 + renderPath: 1 ambientIntensity: 1.5 renderSunShadows: 0 renderLightShadows: 0 - materialType: 2 - renderPath: 1 renderExteriorCellLights: 0 animateLights: 0 antiAliasing: 0 ambientOcclusion: 0 bloom: 0 + waterBackSideTransparent: 0 followHeadDirection: 0 UIBackgroundImg: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} UICheckmarkImg: {fileID: 10901, guid: 0000000000000000f000000000000000, type: 0} @@ -78,6 +79,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 18f65c96457599848b0d63ff346899ad, type: 3} m_Name: m_EditorClassIdentifier: + bypassConfigINI: 0 --- !u!1001 &100100000 Prefab: m_ObjectHideFlags: 1 diff --git a/Assets/Scenes/Scene.unity.meta b/Assets/Scenes/Scene.unity.meta index f62b984..0107a16 100644 --- a/Assets/Scenes/Scene.unity.meta +++ b/Assets/Scenes/Scene.unity.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: b2c6de990d4e0bd419fdcd159a2d7f8d +guid: 5a8ff10dbfe696e45bca66d86c2f4347 timeCreated: 1461523859 licenseType: Free DefaultImporter: diff --git a/Assets/Scripts/TES/Components/PathSelectionComponent.cs b/Assets/Scripts/TES/Components/PathSelectionComponent.cs index 217b57b..69c4c93 100644 --- a/Assets/Scripts/TES/Components/PathSelectionComponent.cs +++ b/Assets/Scripts/TES/Components/PathSelectionComponent.cs @@ -21,10 +21,19 @@ public class PathSelectionComponent : MonoBehaviour private Toggle toggle; private Text errorText; +#if UNITY_EDITOR + [SerializeField] + private bool bypassConfigINI = false; +#endif + private void Start() { +#if UNITY_EDITOR + if (!bypassConfigINI) + CheckConfigINI(); +#else CheckConfigINI(); - +#endif var savedPath = PlayerPrefs.GetString(SavePathKey, string.Empty); if (savedPath != string.Empty) defaultMWDataPath = savedPath; @@ -57,12 +66,21 @@ private void Start() errorText.gameObject.AddComponent(); errorText.enabled = false; + // Load the game if the Data Files folder is here var path = Path.Combine(System.Environment.CurrentDirectory, "Data Files"); if (Directory.Exists(path)) { LoadWorld(path); return; } + + // Or if it's already in the config.ini file. + var tes = GetComponent(); + if (Directory.Exists(tes.dataPath)) + { + LoadWorld(tes.dataPath); + return; + } } private void OnDestroy() @@ -139,11 +157,13 @@ private void CheckConfigINI() case "AmbientOcclusion": tes.ambientOcclusion = ParseBool(value, tes.ambientOcclusion); break; case "AnimateLights": tes.animateLights = ParseBool(value, tes.animateLights); break; case "Bloom": tes.bloom = ParseBool(value, tes.bloom); break; + case "MorrowindPath": tes.dataPath = value; break; case "FollowHeadDirection": tes.followHeadDirection = ParseBool(value, tes.followHeadDirection); break; case "SunShadows": tes.renderSunShadows = ParseBool(value, tes.renderSunShadows); break; case "LightShadows": tes.renderLightShadows = ParseBool(value, tes.renderLightShadows); break; case "PlayMusic": tes.playMusic = ParseBool(value, tes.playMusic); break; case "RenderExteriorCellLights": tes.renderExteriorCellLights = ParseBool(value, tes.renderExteriorCellLights); break; + case "WaterBackSideTransparent": tes.waterBackSideTransparent = ParseBool(value, tes.waterBackSideTransparent); break; case "RenderPath": var renderPathID = ParseInt(value, 0); if (renderPathID == 1 || renderPathID == 3) diff --git a/Assets/Scripts/TES/Components/PlayerComponent.cs b/Assets/Scripts/TES/Components/PlayerComponent.cs index 079551b..0df8685 100644 --- a/Assets/Scripts/TES/Components/PlayerComponent.cs +++ b/Assets/Scripts/TES/Components/PlayerComponent.cs @@ -90,7 +90,7 @@ private void Update() isFlying = !isFlying; } - if (isGrounded && !isFlying && Input.GetButtonDown("Jump")) + if (isGrounded && !isFlying && Input.GetButtonDown("Button_4")) { var newVelocity = rigidbody.velocity; newVelocity.y = 5; @@ -207,8 +207,13 @@ private Vector3 CalculateLocalMovementDirection() // A small hack for French Keyboard... if (Application.systemLanguage == SystemLanguage.French) { - direction = Vector3.zero; + // Cancel Qwerty + if (Input.GetKeyDown(KeyCode.W)) + direction.z = 0; + else if (Input.GetKeyDown(KeyCode.A)) + direction.x = 0; + // Use Azerty if (Input.GetKey(KeyCode.Z)) direction.z = 1; else if (Input.GetKey(KeyCode.S)) diff --git a/Assets/Scripts/TES/Components/Records/BookComponent.cs b/Assets/Scripts/TES/Components/Records/BookComponent.cs index e1728ed..1a8b989 100644 --- a/Assets/Scripts/TES/Components/Records/BookComponent.cs +++ b/Assets/Scripts/TES/Components/Records/BookComponent.cs @@ -7,7 +7,6 @@ namespace TESUnity.Components.Records public class BookComponent : GenericObjectComponent { private static PlayerComponent _player = null; - private GameObject _container = null; private static UIBook _uiBook = null; private static UIScroll _uiScroll = null; @@ -42,25 +41,8 @@ void Start() objData.value = BOOK.BKDT.value.ToString(); } - void Update() - { - if (Input.GetButtonDown("Fire1") && _container != null) - { - Destroy(_container); - Player.Pause(false); - return; - } - } - public override void Interact() { - if (_container != null) - { - Destroy(_container); - Player.Pause(false); - return; - } - var BOOK = (BOOKRecord)record; if (BOOK.BKDT.scroll == 1) diff --git a/Assets/Scripts/TES/Components/Records/WeaponComponent.cs b/Assets/Scripts/TES/Components/Records/WeaponComponent.cs index 6301b95..ae3461d 100644 --- a/Assets/Scripts/TES/Components/Records/WeaponComponent.cs +++ b/Assets/Scripts/TES/Components/Records/WeaponComponent.cs @@ -32,7 +32,7 @@ void Update() { if (_isEquiped) { - if (Input.GetButtonDown("Fire1")) + if (Input.GetButtonDown("Button_1")) { if (_isVisible) PlayAttackAnimation(); diff --git a/Assets/Scripts/TES/MorrowindEngine.cs b/Assets/Scripts/TES/MorrowindEngine.cs index 34c30b7..c29bdaf 100644 --- a/Assets/Scripts/TES/MorrowindEngine.cs +++ b/Assets/Scripts/TES/MorrowindEngine.cs @@ -100,6 +100,19 @@ public MorrowindEngine( MorrowindDataReader dataReader ) waterObj = GameObject.Instantiate(TESUnity.instance.waterPrefab); waterObj.SetActive(false); + + if (!TESUnity.instance.waterBackSideTransparent) + { + var side = waterObj.transform.GetChild(0); + var sideMaterial = side.GetComponent().sharedMaterial; + sideMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); + sideMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero); + sideMaterial.SetInt("_ZWrite", 1); + sideMaterial.DisableKeyword("_ALPHATEST_ON"); + sideMaterial.DisableKeyword("_ALPHABLEND_ON"); + sideMaterial.DisableKeyword("_ALPHAPREMULTIPLY_ON"); + sideMaterial.renderQueue = -1; + } } public Vector2i GetExteriorCellIndices(Vector3 point) @@ -227,7 +240,7 @@ public void CastInteractRay() ShowInteractiveText(component); - if (Input.GetButtonDown("Use")) + if (Input.GetButtonDown("Button_1")) { if (component is DoorComponent) OpenDoor((DoorComponent)component); diff --git a/Assets/Scripts/TES/TESUnity.cs b/Assets/Scripts/TES/TESUnity.cs index 30cc3b6..8621855 100644 --- a/Assets/Scripts/TES/TESUnity.cs +++ b/Assets/Scripts/TES/TESUnity.cs @@ -14,21 +14,27 @@ public enum MWMaterialType #region Inspector-set Members + [Header("Global")] public string dataPath; public bool useKinematicRigidbodies = true; public bool playMusic = true; + + [Header("Rendering")] + public MWMaterialType materialType = MWMaterialType.BumpedDiffuse; + public RenderingPath renderPath = RenderingPath.Forward; + + [Header("Lighting")] public float ambientIntensity = 1.5f; public bool renderSunShadows = false; public bool renderLightShadows = false; - public MWMaterialType materialType = MWMaterialType.BumpedDiffuse; - public RenderingPath renderPath = RenderingPath.Forward; public bool renderExteriorCellLights = false; public bool animateLights = false; [Header("Effects")] - public bool antiAliasing; - public bool ambientOcclusion; - public bool bloom; + public bool antiAliasing = false; + public bool ambientOcclusion = false; + public bool bloom = false; + public bool waterBackSideTransparent = false; [Header("VR")] public bool followHeadDirection = false; @@ -42,6 +48,7 @@ public enum MWMaterialType public Sprite UIMaskImg; public Sprite UISpriteImg; + [Header("Prefabs")] public GameObject waterPrefab; [Header("Debug")] diff --git a/Assets/Scripts/TES/UI/UIBook.cs b/Assets/Scripts/TES/UI/UIBook.cs index 4e3ed33..eb52671 100644 --- a/Assets/Scripts/TES/UI/UIBook.cs +++ b/Assets/Scripts/TES/UI/UIBook.cs @@ -42,9 +42,18 @@ void Start() _background.sprite = GUIUtils.CreateSprite(texture); transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; + transform.localScale = Vector3.one; Close(); } + void Update() + { + if (Input.GetButtonDown("Button_3")) + Take(); + else if (Input.GetButton("Button_2")) + Close(); + } + public void Show(BOOKRecord book) { _bookRecord = book; diff --git a/Assets/Scripts/TES/UI/UIScroll.cs b/Assets/Scripts/TES/UI/UIScroll.cs index a757c27..c4b0c04 100644 --- a/Assets/Scripts/TES/UI/UIScroll.cs +++ b/Assets/Scripts/TES/UI/UIScroll.cs @@ -25,9 +25,18 @@ void Start() _background.sprite = GUIUtils.CreateSprite(texture); transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; + transform.localScale = Vector3.one; Close(); } + void Update() + { + if (Input.GetButtonDown("Button_3")) + Take(); + else if (Input.GetButton("Button_2")) + Close(); + } + public void Show(BOOKRecord book) { _bookRecord = book; diff --git a/CHANGES.md b/CHANGES.md index 70b95d3..40ae14e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,20 @@ #TESUnity Changelog +## Version 0.4 - 10/18/2016 +### Added +- New flags to enable new features (see readme.md) +- Experimental static creatures support +- Experimental weapon support (with home made animation) +- Books and scrolls support +- Crosshair +- Morrowind cursor + +### Changes +- Use the same keys binding as Morrowind + +### Fixes +- Fixed an encoding issue for texts with accents + ## Version 0.3 - 10/09/2016 ### Added - More parameters in config.ini diff --git a/ProjectSettings/InputManager.asset b/ProjectSettings/InputManager.asset index bfe6aa9..a1c898d 100644 --- a/ProjectSettings/InputManager.asset +++ b/ProjectSettings/InputManager.asset @@ -38,7 +38,7 @@ InputManager: axis: 0 joyNum: 0 - serializedVersion: 3 - m_Name: Fire1 + m_Name: Button_1 descriptiveName: descriptiveNegativeName: negativeButton: @@ -54,7 +54,7 @@ InputManager: axis: 0 joyNum: 0 - serializedVersion: 3 - m_Name: Menu + m_Name: Button_2 descriptiveName: Open the menu descriptiveNegativeName: negativeButton: @@ -70,7 +70,7 @@ InputManager: axis: 0 joyNum: 0 - serializedVersion: 3 - m_Name: Use + m_Name: Button_3 descriptiveName: descriptiveNegativeName: negativeButton: @@ -86,7 +86,7 @@ InputManager: axis: 0 joyNum: 0 - serializedVersion: 3 - m_Name: Jump + m_Name: Button_4 descriptiveName: descriptiveNegativeName: negativeButton: @@ -182,7 +182,7 @@ InputManager: axis: 1 joyNum: 0 - serializedVersion: 3 - m_Name: Fire1 + m_Name: Button_1 descriptiveName: descriptiveNegativeName: negativeButton: @@ -198,7 +198,7 @@ InputManager: axis: 0 joyNum: 0 - serializedVersion: 3 - m_Name: Menu + m_Name: Button_2 descriptiveName: Open the menu descriptiveNegativeName: negativeButton: @@ -214,7 +214,7 @@ InputManager: axis: 0 joyNum: 0 - serializedVersion: 3 - m_Name: Use + m_Name: Button_3 descriptiveName: descriptiveNegativeName: negativeButton: @@ -266,7 +266,7 @@ InputManager: descriptiveName: descriptiveNegativeName: negativeButton: - positiveButton: joystick button 2 + positiveButton: altNegativeButton: altPositiveButton: l gravity: 1000 @@ -294,7 +294,7 @@ InputManager: axis: 0 joyNum: 0 - serializedVersion: 3 - m_Name: Jump + m_Name: Button_4 descriptiveName: descriptiveNegativeName: negativeButton: diff --git a/README.md b/README.md index 1815ede..ceab010 100644 --- a/README.md +++ b/README.md @@ -11,29 +11,46 @@ To get started, download the source code as a ZIP file, extract it, and open the You can copy the `Data Files` folder from your Morrowind installation to the root folder of the project / release. The game will start automatically without asking for a path. ## Configuration file -You can create a configuration file named `Config.ini` at the root folder of the project / release folder. +You can use the `config.ini` file located at the root folder of the project / release folder to configure and tweak your game experience. +The first step is to rename the `config.ini.dist` file to `config.ini`. + | Parameter | Values | |-----------|---------| +|**Global** | | +| PlayMusic | `True` or `False` | +| MorrowindPath | The Morrowind's `Data Files` path | +|**Lighting**| | +| AnimateLights | `True` or `False` | | SunShadows | `True` or `False` | | LightShadows | `True` or `False` | -| PlayMusic | `True` or `False` | +| RenderExteriorCellLights | `True` or `False` | +|**Effects** | | +|AntiAliasing | `True` or `False` | +|AmbientOcclusion | `True` or `False` | +|Bloom | `True` or `False` | +|WaterBackSideTransparent | `True` or `False` | +|**Rendering** | | | Shader | `Unlit` or `Standard` or `Default` or `Bumped` | | RenderPath | `1` = Forward, `3` = Deferred | - +|**Debug** | | +| CreaturesEnabled | `True` or `False` | ## Controls | Action | Keys | Gamepad | |--------|------|---------| -| Move | W, A, S, D | Left thumbstick | +| Move | W, A, S, D* | Left thumbstick | | Sprint | Left Shift | Left thumbstick button | | Walk | Left Ctrl | Right thumstick button | +| Use / Open / Attack | Space | Button A | +| Cancel / Menu | Left click | Button B | +| Take (book mode) | Nothing | Button X | | Jump | E | button Y | -| Interact | Space | button A | | Toggle Flight Mode | Tab | Nothing | -| Toggle Lantern | L | button X | +| Toggle Lantern | L | Nothing | | Free Cursor Lock | Backquote | Nothing | +\* *It uses the AZERTY mapping for French users.* ## Contribute diff --git a/config.ini.dist b/config.ini.dist new file mode 100644 index 0000000..b80ac56 --- /dev/null +++ b/config.ini.dist @@ -0,0 +1,28 @@ +# TESUnity Configuration File + +[Global] +PlayMusic = True +MorrowindPath = C:/Program Files (x86)/Steam/steamapps/common/Morrowind/Data Files + +[Rendering] +RenderPath = 1 +Shader = Bumped + +[Lighting] +AnimateLights = False +SunShadows = True +LightShadows = False +RenderExteriorCellLights = False + +[Effects] +AntiAliasing = False +AmbientOcclusion = False +Bloom = False +WaterBackSideTransparent = False + +[VR] +FollowHeadDirection = False + +[Debug] +CreaturesEnabled = False +