Merge pull request #1 from LexxyDrexxy/main
Transparency Settings in Graphics Menu
This commit is contained in:
6
LWGlass/languages/English/English_settings.jecs
Normal file
6
LWGlass/languages/English/English_settings.jecs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
MHG.SettingsMenu.Pages.Graphics.Headings.LW_Glass: "Mod: Glass"
|
||||||
|
LWGlass.Glass.GlassTransparency: "Transparency"
|
||||||
|
|
||||||
|
LWGlass.Glass.GlassTransparency.Description: """
|
||||||
|
Transparency of the Glass Material.
|
||||||
|
"""
|
||||||
8
LWGlass/settings/LWGlass_settingsdata.jecs
Normal file
8
LWGlass/settings/LWGlass_settingsdata.jecs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
LWGlass.Glass.GlassTransparency:
|
||||||
|
Page: Graphics
|
||||||
|
Heading: LW_Glass
|
||||||
|
Min: 15
|
||||||
|
Max: 85
|
||||||
|
SliderInterval: 1
|
||||||
|
DecimalPlacesToDisplay: 0
|
||||||
|
PerformanceImpact: Low
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using JimmysUnityUtilities;
|
using JimmysUnityUtilities;
|
||||||
using LogicAPI.Data;
|
using LogicAPI.Data;
|
||||||
|
using LogicSettings;
|
||||||
using LogicWorld.Building.Overhaul;
|
using LogicWorld.Building.Overhaul;
|
||||||
using LogicWorld.ClientCode;
|
using LogicWorld.ClientCode;
|
||||||
using LogicWorld.ClientCode.Resizing;
|
using LogicWorld.ClientCode.Resizing;
|
||||||
@@ -20,6 +21,36 @@ namespace LWGlass.Client
|
|||||||
IResizableX,
|
IResizableX,
|
||||||
IResizableZ
|
IResizableZ
|
||||||
{
|
{
|
||||||
|
[Setting_SliderFloat("LWGlass.Glass.GlassTransparency")]
|
||||||
|
public static float GlassTransparency
|
||||||
|
{
|
||||||
|
get => _glassTransparency;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_glassTransparency = (float) value;
|
||||||
|
updateGlassTransparency();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static float _glassTransparency = 50;
|
||||||
|
|
||||||
|
protected static void updateGlassTransparency()
|
||||||
|
{
|
||||||
|
var world = Instances.MainWorld;
|
||||||
|
if (world == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var glass = world.ComponentTypes.GetComponentType("LWGlass.Glass");
|
||||||
|
foreach(var kvp in world.Data.AllComponents)
|
||||||
|
{
|
||||||
|
var (address, data) = kvp;
|
||||||
|
if (data.Data.Type == glass)
|
||||||
|
{
|
||||||
|
world.Renderer.Entities.GetClientCode(address).QueueDataUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int previousSizeX;
|
private int previousSizeX;
|
||||||
private int previousSizeZ;
|
private int previousSizeZ;
|
||||||
|
|
||||||
@@ -49,17 +80,22 @@ namespace LWGlass.Client
|
|||||||
public int MaxZ => 80;
|
public int MaxZ => 80;
|
||||||
public float GridIntervalZ => 1f;
|
public float GridIntervalZ => 1f;
|
||||||
|
|
||||||
|
protected Material setSharedMaterial()
|
||||||
|
{
|
||||||
|
return LogicWorld.References.MaterialsCache.StandardUnlitColorTransparent(Color, (float) GlassTransparency/100);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnComponentImaged()
|
protected override void OnComponentImaged()
|
||||||
{
|
{
|
||||||
Data.Color = new Color24(255, 255, 255);
|
Data.Color = new Color24(255, 255, 255);
|
||||||
GameObject obj = Decorations[0].DecorationObject;
|
GameObject obj = Decorations[0].DecorationObject;
|
||||||
obj.GetComponent<MeshRenderer>().sharedMaterial = LogicWorld.References.MaterialsCache.StandardUnlitColorTransparent(Color, 0.7f);
|
obj.GetComponent<MeshRenderer>().sharedMaterial = setSharedMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void DataUpdate()
|
protected override void DataUpdate()
|
||||||
{
|
{
|
||||||
GameObject obj = Decorations[0].DecorationObject;
|
GameObject obj = Decorations[0].DecorationObject;
|
||||||
obj.GetComponent<MeshRenderer>().sharedMaterial = LogicWorld.References.MaterialsCache.StandardUnlitColorTransparent(Color, 0.2f);
|
obj.GetComponent<MeshRenderer>().sharedMaterial = setSharedMaterial();
|
||||||
if (SizeX == previousSizeX && SizeZ == previousSizeZ)
|
if (SizeX == previousSizeX && SizeZ == previousSizeZ)
|
||||||
return;
|
return;
|
||||||
previousSizeX = SizeX;
|
previousSizeX = SizeX;
|
||||||
@@ -125,7 +161,7 @@ namespace LWGlass.Client
|
|||||||
var meshFilter = myGameObject.AddComponent<MeshFilter>();
|
var meshFilter = myGameObject.AddComponent<MeshFilter>();
|
||||||
meshFilter.sharedMesh = LogicWorld.References.Meshes.OriginCube;
|
meshFilter.sharedMesh = LogicWorld.References.Meshes.OriginCube;
|
||||||
var meshRenderer = myGameObject.AddComponent<MeshRenderer>();
|
var meshRenderer = myGameObject.AddComponent<MeshRenderer>();
|
||||||
meshRenderer.sharedMaterial = LogicWorld.References.MaterialsCache.StandardUnlitColorTransparent(Color, 0.2f);
|
meshRenderer.sharedMaterial = setSharedMaterial();
|
||||||
return new IDecoration[]
|
return new IDecoration[]
|
||||||
{
|
{
|
||||||
new Decoration()
|
new Decoration()
|
||||||
|
|||||||
Reference in New Issue
Block a user