Skip to content

Commit

Permalink
Update for game version 1.38.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DJDavid98 committed Nov 20, 2024
1 parent 075d184 commit b2ec135
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 62 deletions.
2 changes: 1 addition & 1 deletion ImageFactory/Components/IFSprite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public IFImage? Image
}
else
{
_spriteRenderer.sprite = _image.animationData!.sprites[0];
_spriteRenderer.sprite = _image.animationData!.Sprites[0];
if (_animator == null)
{
_animator = gameObject.AddComponent<RendererAnimationStateUpdater>();
Expand Down
2 changes: 1 addition & 1 deletion ImageFactory/Components/RendererAnimationStateUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ protected void LateUpdate()
{
if (Renderer != null && ControllerData != null)
{
Renderer.sprite = ControllerData.sprites[ControllerData.uvIndex];
Renderer.sprite = ControllerData.Sprites[ControllerData.UvIndex];
}
}
}
Expand Down
13 changes: 10 additions & 3 deletions ImageFactory/ImageFactory.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<OutputType>Library</OutputType>
<LangVersion>8</LangVersion>
<Nullable>enable</Nullable>
Expand Down Expand Up @@ -53,12 +53,18 @@
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\BeatmapCore.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BeatSaber.ViewSystem">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\BeatSaber.ViewSystem.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="BSML">
<HintPath>$(BeatSaberDir)\Plugins\BSML.dll</HintPath>
<Private>False</Private>
<Publicize>True</Publicize>
</Reference>
<Reference Include="DataModels">
<HintPath>E:\BSManager\BSInstances\Beat Saber 1.37.0\Beat Saber_Data\Managed\DataModels.dll</HintPath>
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\DataModels.dll</HintPath>
</Reference>
<Reference Include="GameplayCore">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\GameplayCore.dll</HintPath>
Expand Down Expand Up @@ -190,5 +196,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.4.2" PrivateAssets="all" />
</ItemGroup>
</Project>
</Project>
4 changes: 2 additions & 2 deletions ImageFactory/Managers/MenuButtonManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public MenuButtonManager(MainFlowCoordinator mainFlowCoordinator, ImageFactoryFl

public void Initialize()
{
MenuButtons.instance.RegisterButton(_menuButton);
MenuButtons.Instance.RegisterButton(_menuButton);
}

public void Dispose()
Expand All @@ -31,7 +31,7 @@ public void Dispose()
// PersistentSingletons are WeirdChamp.
try
{
MenuButtons.instance.UnregisterButton(_menuButton);
MenuButtons.Instance.UnregisterButton(_menuButton);
}
catch (ObjectDisposedException)
{
Expand Down
6 changes: 3 additions & 3 deletions ImageFactory/Models/IFImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public IFImage(AnimationControllerData animData, Metadata metadata, TimeSpan tim
loadTime = timeToLoad;
animationData = animData;
this.metadata = metadata;
sprite = animData.sprite;
width = (int)animData.sprites[0].rect.width;
height = (int)animData.sprites[0].rect.height;
sprite = animData.Sprites[0];
width = (int)animData.Sprites[0].rect.width;
height = (int)animData.Sprites[0].rect.height;
}

public struct Metadata
Expand Down
24 changes: 12 additions & 12 deletions ImageFactory/Models/RendererAnimationControllerData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,33 @@ public RendererAnimationControllerData(Texture2D tex, Rect[] uvs, float[] delays
}
}

internal void CheckFrame(DateTime now)
public new void CheckFrame(DateTime now)
{
double differenceMs = (now - lastSwitch).TotalMilliseconds;
if (differenceMs < delays[uvIndex])
double differenceMs = (now - LastSwitch).TotalMilliseconds;
if (differenceMs < Delays[UvIndex])
return;

if (_isDelayConsistent && delays[uvIndex] <= 10 && differenceMs < 100)
if (_isDelayConsistent && Delays[UvIndex] <= 10 && differenceMs < 100)
{
// Bump animations with consistently 10ms or lower frame timings to 100ms
return;
}

lastSwitch = now;
LastSwitch = now;
do
{
uvIndex++;
if (uvIndex >= uvs.Length)
uvIndex = 0;
UvIndex++;
if (UvIndex >= this.uvs.Length)
UvIndex = 0;
}
while (!_isDelayConsistent && delays[uvIndex] == 0);
while (!_isDelayConsistent && Delays[UvIndex] == 0);

if (activeImages.Count != 0)
if (ActiveImages.Count != 0)
{
foreach (Image image in activeImages)
foreach (Image image in ActiveImages)
{
if (image != null && image.isActiveAndEnabled)
image.sprite = sprites[uvIndex];
image.sprite = Sprites[UvIndex];
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions ImageFactory/UI/IFEditImageView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ public void EnableEditing(IFImage image, IFSaveData? data = null)
// child of the handle screen.
_floatingScreen.gameObject.SetActive(true);
_floatingScreen.SetRootViewController(_dummyView, AnimationType.None);
_floatingScreen.handle.transform.localScale = Vector3.one / 5f * saveData.Size;
_floatingScreen.handle.gameObject.transform.localPosition = Vector3.zero;
_floatingScreen.Handle.transform.localScale = Vector3.one / 5f * saveData.Size;
_floatingScreen.Handle.gameObject.transform.localPosition = Vector3.zero;
Transform tForm = _imageEditorManager.Present(image, saveData, clone =>
{
var val = _presentationHost.Export();
Expand Down Expand Up @@ -161,8 +161,8 @@ public void EnableEditing(IFImage image, IFSaveData? data = null)
});
_floatingScreen.ScreenPosition = _imageEditorManager.Position;
_floatingScreen.ScreenRotation = _imageEditorManager.Rotation;
_floatingScreen.handle.gameObject.transform.localPosition = Vector3.zero;
_floatingScreen.handle.gameObject.transform.position = saveData.Position;
_floatingScreen.Handle.gameObject.transform.localPosition = Vector3.zero;
_floatingScreen.Handle.gameObject.transform.position = saveData.Position;
tForm.transform.SetParent(_floatingScreen.transform, true);
_editorFieldView.SetText(_imageEditorManager.Name);
Enabled = Enabled;
Expand All @@ -177,13 +177,13 @@ private void NameFieldUpdated(InputFieldView field)
_imageEditorManager.Name = field.text;
}

protected override void DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
public override void DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
{
base.DidActivate(firstActivation, addedToHierarchy, screenSystemEnabling);
_editorFieldView.onValueChanged.AddListener(NameFieldUpdated);
}

protected override void DidDeactivate(bool removedFromHierarchy, bool screenSystemDisabling)
public override void DidDeactivate(bool removedFromHierarchy, bool screenSystemDisabling)
{
_presentationHost.Reset();
_imageManager.ReanimateAll();
Expand Down
2 changes: 1 addition & 1 deletion ImageFactory/UI/IFInfoView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected string ModalActionText
set { _modalActionText = value; NotifyPropertyChanged(); }
}

protected override void DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
public override void DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
{
base.DidActivate(firstActivation, addedToHierarchy, screenSystemEnabling);
if (firstActivation)
Expand Down
6 changes: 3 additions & 3 deletions ImageFactory/UI/IFNewImageView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public async Task LoadImages()

var data = loadedImages.Select(image => new NewImageCell(image, ClickedImageCell)).ToList();
Utilities.InitializeCustomCellTableviewData(_imageList, data, _siraLog);
_imageList.tableView.ReloadData();
_imageList.TableView.ReloadData();
}

private void ClickedImageCell(IFImage image)
Expand Down Expand Up @@ -157,8 +157,8 @@ protected void Parsed()
if (image.animationData != null)
{
var stateUpdater = _previewImage.gameObject.AddComponent<AnimationStateUpdater>();
image.animationData.activeImages.Add(_previewImage);
stateUpdater.image = _previewImage;
image.animationData.ActiveImages.Add(_previewImage);
stateUpdater.Image = _previewImage;
}
else
{
Expand Down
20 changes: 10 additions & 10 deletions ImageFactory/UI/IFSavedImageView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,19 @@ public async Task AnimateToSelectionCanvas()

public async Task LoadImages()
{
foreach (var image in _imageList.data.Cast<EditImageCell>())
foreach (var image in _imageList.Data.Cast<EditImageCell>())
{
if (image.stateUpdater != null && image.previewImage != null)
{
image.image.animationData!.activeImages.Remove(image.previewImage);
image.stateUpdater.image = null;
image.image.animationData!.ActiveImages.Remove(image.previewImage);
image.stateUpdater.Image = null;
}
}
foreach (Transform pres in _imageList.tableView.contentTransform)
foreach (Transform pres in _imageList.TableView.contentTransform)
Destroy(pres.gameObject);

_imageList.data.Clear();
_imageList.tableView.ReloadData();
_imageList.Data.Clear();
_imageList.TableView.ReloadData();

var data = new List<EditImageCell>();
foreach (var save in _config.SaveData)
Expand All @@ -125,7 +125,7 @@ public async Task LoadImages()
}
Utilities.InitializeCustomCellTableviewData(_imageList, data, _siraLog);
await AnimateToSelectionCanvas();
_imageList.tableView.ReloadData();
_imageList.TableView.ReloadData();
}

private void ClickedImageDelete(IFImage image, IFSaveData saveData)
Expand Down Expand Up @@ -162,7 +162,7 @@ private void ImageManager_ImageUpdated(object sender, ImageUpdateArgs e)
_ = LoadImages();
}

protected override void OnDestroy()
public override void OnDestroy()
{
_imageManager.ImageUpdated -= ImageManager_ImageUpdated;
base.OnDestroy();
Expand Down Expand Up @@ -197,8 +197,8 @@ protected void Parsed()
if (image.animationData != null)
{
stateUpdater = previewImage.gameObject.AddComponent<AnimationStateUpdater>();
image.animationData.activeImages.Add(previewImage);
stateUpdater.image = previewImage;
image.animationData.ActiveImages.Add(previewImage);
stateUpdater.Image = previewImage;
}
else
{
Expand Down
16 changes: 8 additions & 8 deletions ImageFactory/UI/PresentationHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ protected void Changed(PresentationStore.Value value)
return;

_activeValue = value;
_presentationList.data.Clear();
_presentationList.tableView.ReloadData();
_presentationList.Data.Clear();
_presentationList.TableView.ReloadData();

foreach (Transform pres in _presentationList.tableView.contentTransform)
foreach (Transform pres in _presentationList.TableView.contentTransform)
UnityEngine.Object.Destroy(pres.gameObject);

_presentationOptions = _store.Values().Cast<object>().ToList();
Expand Down Expand Up @@ -143,19 +143,19 @@ protected void Changed(PresentationStore.Value value)

var constructors = _activeValue.Constructors.Select(c => new InternalHost(c));
foreach (var constructor in constructors) {
_presentationList.data.Add(constructor);
_presentationList.Data.Add(constructor);
}
if (_activeValue.HasDuration)
{
var durHost = new InternalHost();
_presentationList.data.Add(durHost);
_presentationList.Data.Add(durHost);
if (_activeValue != null && _activeValue.HasDuration && LastData != null && LastData.Duration != 0)
durHost.Duration = LastData.Duration;
}
_presentationList.tableView.ReloadData();
_presentationList.TableView.ReloadData();
_lastID = _activeValue!.ID;

_dropdown.values = _presentationOptions;
_dropdown.Values = _presentationOptions;
_parserParams.EmitEvent("get");
_dropdown.UpdateChoices();
_justSet = false;
Expand All @@ -164,7 +164,7 @@ protected void Changed(PresentationStore.Value value)
// LITERALLY PRETEND THIS DOES NOT EXIST
public Tuple<string, string, float?> Export()
{
var hosts = _presentationList.data.Cast<InternalHost>();
var hosts = _presentationList.Data.Cast<InternalHost>();
var duration = hosts.FirstOrDefault(h => h.isDuration);
var agg = (hosts.Count() == 0 || (hosts.Count() == 1 && duration != null)) ? ""
: hosts.Where(h => !h.isDuration).Select(f => f.Value.ToString()).Aggregate((f, n) => f + "|" + n);
Expand Down
10 changes: 5 additions & 5 deletions ImageFactory/UI/SelectImageModalHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,20 @@ protected void Parsed()
public void Present(IFImage image, Action<IFImage> callback)
{
_callback = delegate () { callback.Invoke(image); };
if (_lastControllerData != null && _lastControllerData.activeImages.Contains(_preview))
_lastControllerData.activeImages.Remove(_preview);
if (_lastControllerData != null && _lastControllerData.ActiveImages.Contains(_preview))
_lastControllerData.ActiveImages.Remove(_preview);
if (image.animationData != null)
{
_preview.material = _originalMaterial;
_lastControllerData = image.animationData;
_lastControllerData.activeImages.Add(_preview);
_animationState.image = _preview;
_lastControllerData.ActiveImages.Add(_preview);
_animationState.Image = _preview;
}
else
{
_preview.material = Utilities.UINoGlowRoundEdge;
_preview.sprite = image.sprite;
_animationState.image = null;
_animationState.Image = null;
}
_preview.sprite = image.sprite;
var fileSize = FileSizeExtension(image.metadata.size);
Expand Down
4 changes: 2 additions & 2 deletions ImageFactory/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static async Task<ProcessedAnimation> ProcessAnimation(AnimationFormat fo
throw new System.Exception($"Unknown animation format {format}");
}

return new ProcessedAnimation(animationData.atlas, animationData.uvs, animationData.delays, animationData.width, animationData.height);
return new ProcessedAnimation(animationData.Atlas, animationData.Uvs, animationData.Delays, animationData.Width, animationData.Height);
}

private static Material _uiNoGlowRoundEdgeMaterial = null!;
Expand Down Expand Up @@ -80,7 +80,7 @@ public static void InitializeCustomCellTableviewData(BeatSaberMarkupLanguage.Com
{
try
{
_imageList.data = data;
_imageList.Data = data;
}
catch (Exception ex)
{
Expand Down
10 changes: 5 additions & 5 deletions ImageFactory/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"id": "ImageFactory",
"name": "ImageFactory",
"author": "Auros",
"version": "1.2.3",
"version": "1.2.4",
"description": "Place and customize images throughout your game.",
"gameVersion": "1.37.0",
"gameVersion": "1.38.0",
"dependsOn": {
"BSIPA": "^4.3.4",
"SiraUtil": "^3.1.10",
"BeatSaberMarkupLanguage": "^1.11.2"
"BSIPA": "^4.3.5",
"SiraUtil": "^3.1.12",
"BeatSaberMarkupLanguage": "^1.12.3"
}
}

0 comments on commit b2ec135

Please sign in to comment.