Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement file system watcher for textures (strata / decals) #22

Open
MrRowey opened this issue May 14, 2024 · 1 comment
Open

Implement file system watcher for textures (strata / decals) #22

MrRowey opened this issue May 14, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@MrRowey
Copy link
Member

MrRowey commented May 14, 2024

@Garanas could you please provide a short description on the how the desired outcome would look

@Garanas
Copy link
Member

Garanas commented May 15, 2024

It would need something such as this:

Which allows you to receive events when a file is changed on disk. Files are changed often when using procedural software such as Gaea, usually decals and/or map-wide content that are prime candidates for this.

Based on the reload function here:

public void ReloadStratums()
{
StratumSettings.Stratum0_Albedo.texture = ScmapEditor.Current.Textures[0].Albedo;
StratumSettings.Stratum0_Normal.texture = ScmapEditor.Current.Textures[0].Normal;
StratumSettings.Stratum1_Albedo.texture = ScmapEditor.Current.Textures[1].Albedo;
StratumSettings.Stratum1_Normal.texture = ScmapEditor.Current.Textures[1].Normal;
StratumSettings.Stratum2_Albedo.texture = ScmapEditor.Current.Textures[2].Albedo;
StratumSettings.Stratum2_Normal.texture = ScmapEditor.Current.Textures[2].Normal;
StratumSettings.Stratum3_Albedo.texture = ScmapEditor.Current.Textures[3].Albedo;
StratumSettings.Stratum3_Normal.texture = ScmapEditor.Current.Textures[3].Normal;
StratumSettings.Stratum4_Albedo.texture = ScmapEditor.Current.Textures[4].Albedo;
StratumSettings.Stratum4_Normal.texture = ScmapEditor.Current.Textures[4].Normal;
StratumSettings.Stratum5_Albedo.texture = ScmapEditor.Current.Textures[5].Albedo;
StratumSettings.Stratum5_Normal.texture = ScmapEditor.Current.Textures[5].Normal;
StratumSettings.Stratum6_Albedo.texture = ScmapEditor.Current.Textures[6].Albedo;
StratumSettings.Stratum6_Normal.texture = ScmapEditor.Current.Textures[6].Normal;
StratumSettings.Stratum7_Albedo.texture = ScmapEditor.Current.Textures[7].Albedo;
StratumSettings.Stratum7_Normal.texture = ScmapEditor.Current.Textures[7].Normal;
StratumSettings.Stratum8_Albedo.texture = ScmapEditor.Current.Textures[8].Albedo;
StratumSettings.Stratum8_Normal.texture = ScmapEditor.Current.Textures[8].Normal;
StratumSettings.Stratum9_Albedo.texture = ScmapEditor.Current.Textures[9].Albedo;
StratumSettings.Stratum9_Normal.texture = ScmapEditor.Current.Textures[9].Normal;
StratumSettings.Stratum1_Mask.texture = ScmapEditor.Current.map.TexturemapTex;
StratumSettings.Stratum2_Mask.texture = ScmapEditor.Current.map.TexturemapTex;
StratumSettings.Stratum3_Mask.texture = ScmapEditor.Current.map.TexturemapTex;
StratumSettings.Stratum4_Mask.texture = ScmapEditor.Current.map.TexturemapTex;
StratumSettings.Stratum5_Mask.texture = ScmapEditor.Current.map.TexturemapTex2;
StratumSettings.Stratum6_Mask.texture = ScmapEditor.Current.map.TexturemapTex2;
StratumSettings.Stratum7_Mask.texture = ScmapEditor.Current.map.TexturemapTex2;
StratumSettings.Stratum8_Mask.texture = ScmapEditor.Current.map.TexturemapTex2;
RefreshLayerUI();
}

The current data is defined here:

https://github.com/FAForever/FAForeverMapEditor/blob/ef338393d099e18e2640e3b2f773e7ce0df1573f/Assets/Scripts/Ozone%20SCMAP%20Code/ScmapEditor.cs#L16C16-L16C27

With the terrain textures defined here:

public TerrainTexture[] Textures; // Loaded textures

With the class responsible for the textures being here:

public class TerrainTexture
{
public Texture2D Albedo;
public Texture2D Normal;
public Vector2 Tilling = Vector2.one;
//Scmap Data
public string AlbedoPath;
public string NormalPath;
public float AlbedoScale;
public float NormalScale;
}

My suggestion would be to do the following steps, in separate pull requests:

  • (1) Extend the TerrainTexture class so that it detects a change. It doesn't need to do anything with it; just print it and show that it functionally works. The paths to check are in the same class. That would be your first pull request.
  • (2.1) Extend the TerrainTexture class so that it reloads the texture from disk. Reloading in this context means re-populating the corresponding Texture2D field. This would be the first commit in your second pull request.
  • (2.2) I'm not sure if this is required, but if the textures in the editor do not automatically update visually then you'll need to find a way to force a reload of the textures to the GPU.
  • (3) The support for stratum textures is now complete - now we need to support decals. I've not looked into them, but I bet that the path to the textures are stored in some decal class in the same way that it is done for textures. After all, when saving the scmap the editor needs to know the path. This would be your third pull request.

I hope that gives you a direction. Note that I have not worked with the code that much, which means that the suggestions may be wrong.

@Garanas Garanas added the enhancement New feature or request label May 15, 2024
@Garanas Garanas changed the title Auto Reload Changes from disk Implement file system watcher for textures (strata / decals) May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants