Skip to content

Commit

Permalink
Merge pull request #10 from o-tr/master
Browse files Browse the repository at this point in the history
v0.2.8をリリース
  • Loading branch information
o-tr authored Nov 17, 2024
2 parents 815cfa7 + 2f195b7 commit 3df1675
Show file tree
Hide file tree
Showing 12 changed files with 1,873 additions and 975 deletions.
10 changes: 5 additions & 5 deletions Assets/Animations/ImageSlideAnimationController.controller
Original file line number Diff line number Diff line change
Expand Up @@ -319,25 +319,25 @@ AnimatorController:
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: Overlay
m_Type: 3
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: StopWatchState
m_Type: 3
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: Splash
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_DefaultBool: 1
m_Controller: {fileID: 0}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: New Layer
Expand Down
Binary file modified Assets/Textures/SplashScreen/ImageSlide.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Textures/SplashScreen/ImageSlideViewer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 18 additions & 2 deletions Runtime/Editor/ImageSlideEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class ImageSlideEditor : CommonDeviceEditor
private SerializedProperty _definedSourceOffsets;
private SerializedProperty _definedSourceIntervals;
private SerializedProperty _definedSources;
private SerializedProperty _definedSourceUrls;

private SerializedProperty _deviceSelectedUuids;

private VisualElement _definedSourceContainer;
Expand All @@ -35,6 +37,7 @@ public override void OnEnable()
_definedSourceTypes = serializedObject.FindProperty(nameof(ImageSlide.definedSourceTypes));
_definedSourceOffsets = serializedObject.FindProperty(nameof(ImageSlide.definedSourceOffsets));
_definedSourceIntervals = serializedObject.FindProperty(nameof(ImageSlide.definedSourceIntervals));
_definedSourceUrls = serializedObject.FindProperty(nameof(ImageSlide.definedSourceUrls));
Root.styleSheets.Add(imageSlideStyle);
}

Expand Down Expand Up @@ -174,16 +177,18 @@ private VisualElement BuildDefinedUrls(ImageSlide script)
var urlTypesLength = script.definedSourceTypes.Length;
var urlOffsetsLength = script.definedSourceOffsets.Length;
var urlIntervalsLength = script.definedSourceIntervals.Length;
var arraySize = Mathf.Max(urlsLength, urlTypesLength, urlOffsetsLength, urlIntervalsLength);
var urlUrlsLength = script.definedSourceUrls.Length;
var arraySize = Mathf.Max(urlsLength, urlTypesLength, urlOffsetsLength, urlIntervalsLength, urlUrlsLength);


if (urlsLength != arraySize || urlTypesLength != arraySize || urlOffsetsLength != arraySize || urlIntervalsLength != arraySize)
if (urlsLength != arraySize || urlTypesLength != arraySize || urlOffsetsLength != arraySize || urlIntervalsLength != arraySize || urlUrlsLength != arraySize)
{
serializedObject.Update();
_definedSources.arraySize = arraySize;
_definedSourceTypes.arraySize = arraySize;
_definedSourceOffsets.arraySize = arraySize;
_definedSourceIntervals.arraySize = arraySize;
_definedSourceUrls.arraySize = arraySize;
serializedObject.ApplyModifiedProperties();
}

Expand Down Expand Up @@ -262,6 +267,12 @@ private void RebuildRow(int index)
};
sourceField.Bind(serializedObject);
sourceField.AddToClassList("text-field");
sourceField.RegisterValueChangedCallback(evt =>
{
serializedObject.Update();
_definedSourceUrls.GetArrayElementAtIndex(index).FindPropertyRelative("url").stringValue = evt.newValue;
serializedObject.ApplyModifiedProperties();
});
row.Add(sourceField);

if (type == URLType.Video)
Expand Down Expand Up @@ -310,6 +321,7 @@ private void RebuildRow(int index)
_definedSourceTypes.DeleteArrayElementAtIndex(index);
_definedSourceOffsets.DeleteArrayElementAtIndex(index);
_definedSourceIntervals.DeleteArrayElementAtIndex(index);
_definedSourceUrls.DeleteArrayElementAtIndex(index);
_definedSourceElements.RemoveAt(index);
serializedObject.ApplyModifiedProperties();

Expand All @@ -330,6 +342,8 @@ private void SwitchSource(int index1, int index2)
(_definedSourceOffsets.GetArrayElementAtIndex(index2).floatValue, _definedSourceOffsets.GetArrayElementAtIndex(index1).floatValue);
(_definedSourceIntervals.GetArrayElementAtIndex(index1).floatValue, _definedSourceIntervals.GetArrayElementAtIndex(index2).floatValue) =
(_definedSourceIntervals.GetArrayElementAtIndex(index2).floatValue, _definedSourceIntervals.GetArrayElementAtIndex(index1).floatValue);
(_definedSourceUrls.GetArrayElementAtIndex(index1).FindPropertyRelative("url").stringValue, _definedSourceUrls.GetArrayElementAtIndex(index2).FindPropertyRelative("url").stringValue) =
(_definedSourceUrls.GetArrayElementAtIndex(index2).FindPropertyRelative("url").stringValue, _definedSourceUrls.GetArrayElementAtIndex(index1).FindPropertyRelative("url").stringValue);
serializedObject.ApplyModifiedProperties();
RebuildRow(index1);
RebuildRow(index2);
Expand All @@ -343,11 +357,13 @@ private void AddSource(ImageSlide script, string source, string options)
_definedSourceTypes.InsertArrayElementAtIndex(_definedSourceTypes.arraySize);
_definedSourceOffsets.InsertArrayElementAtIndex(_definedSourceOffsets.arraySize);
_definedSourceIntervals.InsertArrayElementAtIndex(_definedSourceIntervals.arraySize);
_definedSourceUrls.InsertArrayElementAtIndex(_definedSourceUrls.arraySize);

_definedSources.GetArrayElementAtIndex(_definedSources.arraySize - 1).stringValue = source;
_definedSourceTypes.GetArrayElementAtIndex(_definedSourceTypes.arraySize - 1).enumValueIndex = (int)type;
_definedSourceOffsets.GetArrayElementAtIndex(_definedSourceOffsets.arraySize - 1).floatValue = offset;
_definedSourceIntervals.GetArrayElementAtIndex(_definedSourceIntervals.arraySize - 1).floatValue = interval;
_definedSourceUrls.GetArrayElementAtIndex(_definedSourceUrls.arraySize - 1).FindPropertyRelative("url").stringValue = source;

serializedObject.ApplyModifiedProperties();

Expand Down
1 change: 0 additions & 1 deletion Runtime/jp.ootr.ImageSlide/Scripts/00_Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public enum QueueType
None,
AddSourceLocal,
AddSource,
RequestSyncAll,
SyncAll,
RemoveSource,
SeekTo,
Expand Down
25 changes: 2 additions & 23 deletions Runtime/jp.ootr.ImageSlide/Scripts/22_LogicQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ private void ProcessQueue()
case QueueType.UpdateList:
UpdateList(data);
break;
case QueueType.RequestSyncAll:
DoSyncAll();
break;
case QueueType.UpdateSeekMode:
ApplySeekMode(data);
break;
Expand Down Expand Up @@ -385,30 +382,12 @@ private void UpdateList(DataToken data)
ProcessQueue();
}

private void Abort()
{
SendCustomNetworkEvent(NetworkEventTarget.Owner, nameof(RequestReSyncAll));
}

public override void OnPlayerJoined(VRCPlayerApi player)
{
if (player.isLocal) return;
if (!Networking.IsOwner(gameObject)) return;
ConsoleDebug("try to request resync all due to player joined", _logicQueuePrefix);
RequestReSyncAll();
}

public void RequestReSyncAll()
{
var dic = new DataDictionary();
dic.SetValue("type", (int)QueueType.RequestSyncAll);
if (!VRCJson.TrySerializeToJson(dic, JsonExportType.Minify, out var json))
{
ConsoleError($"failed to serialize request sync all json: {json}", _logicQueuePrefix);
return;
}

ConsoleDebug("request resync all", _logicQueuePrefix);
AddQueue(json.String);
DoSyncAll();
}

public override void _OnDeserialization()
Expand Down
30 changes: 30 additions & 0 deletions Runtime/jp.ootr.ImageSlide/Scripts/25_LogicPreloadUrls.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using jp.ootr.ImageDeviceController;
using UnityEngine;
using VRC.SDKBase;

namespace jp.ootr.ImageSlide
{
public class LogicPreloadUrls : LogicResetTransform {
[SerializeField] internal string[] definedSources = new string[0];
[SerializeField] internal URLType[] definedSourceTypes = new URLType[0];
[SerializeField] internal float[] definedSourceOffsets = new float[0];
[SerializeField] internal float[] definedSourceIntervals = new float[0];
[SerializeField] internal VRCUrl[] definedSourceUrls = new VRCUrl[0];

public override void OnPlayerJoined(VRCPlayerApi player)
{
base.OnPlayerJoined(player);
if (!Networking.IsOwner(gameObject)) return;
if (!player.isLocal) return;

foreach (var url in definedSourceUrls)
{
controller.UsAddUrl(url);
}
for (var i = 0; i < definedSources.Length; i++)
{
AddSourceQueue(definedSources[i], UrlUtil.BuildSourceOptions(definedSourceTypes[i], definedSourceOffsets[i], definedSourceIntervals[i]));
}
}
}
}

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

15 changes: 2 additions & 13 deletions Runtime/jp.ootr.ImageSlide/Scripts/31_UISourceList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@

namespace jp.ootr.ImageSlide
{
public class UISourceList : LogicResetTransform
public class UISourceList : LogicPreloadUrls
{
[SerializeField] internal string[] definedSources = new string[0];
[SerializeField] internal URLType[] definedSourceTypes = new URLType[0];
[SerializeField] internal float[] definedSourceOffsets = new float[0];
[SerializeField] internal float[] definedSourceIntervals = new float[0];

[SerializeField] private TMP_InputField originalSourceNameInput;
[SerializeField] private RawImage originalSourceIcon;
[SerializeField] private Transform sourceTransform;
Expand All @@ -37,15 +32,9 @@ public class UISourceList : LogicResetTransform

protected Toggle[] SourceToggles;


protected void AddUrl(VRCUrl url, URLType type, string options)
{
if (definedSources.Has(url.ToString()))
{
ShowErrorModal("Error", "This source is already added.");
ConsoleWarn($"this source is already added: {url}", _uiSourceListPrefix);
return;
}

controller.UsAddUrl(url);
AddSourceQueue(url.ToString(), options);
}
Expand Down
Loading

0 comments on commit 3df1675

Please sign in to comment.