Skip to content

Commit

Permalink
Merge pull request #11 from o-tr/master
Browse files Browse the repository at this point in the history
v0.2.9をリリース
  • Loading branch information
o-tr authored Nov 17, 2024
2 parents 3df1675 + 78e1b5e commit eddfd9b
Show file tree
Hide file tree
Showing 29 changed files with 270 additions and 561 deletions.
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.
42 changes: 29 additions & 13 deletions Prefabs/ImageSlideViewer.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -1749,23 +1749,35 @@ MonoBehaviour:
PrefabModifications: []
SerializationNodes: []
_udonSharpBackingUdonBehaviour: {fileID: 36657328902437027}
logLevel: 0
colorSchemeNames:
colorSchemaNames:
- PrimaryBackground
- SecondaryBackground
- TertiaryBackground
- SuccessColor
- ErrorColor
- PrimaryText
- PlaceholderText
colorSchemes:
colorSchemas:
- {r: 0.16078432, g: 0.15294118, b: 0.2, a: 1}
- {r: 0.24313726, g: 0.23529412, b: 0.30588236, a: 1}
- {r: 0.41568628, g: 0.3764706, b: 0.49411765, a: 1}
- {r: 0.5882353, g: 1, b: 0.62352943, a: 1}
- {r: 1, g: 0.5882353, b: 0.5882353, a: 1}
- {r: 1, g: 1, b: 1, a: 1}
- {r: 1, g: 1, b: 1, a: 0.5019608}
logLevel: 0
defaultLanguage: 0
supportedLanguages: 0000000006000000
localizationKeys:
- en.follow-master
- ja.follow-master
localizationValues:
- Sync is disabled
- "\u8FFD\u5F93\u304C\u7121\u52B9\u306B\u306A\u3063\u3066\u3044\u307E\u3059"
localizationTargetKeys:
- follow-master
localizationTargets:
- {fileID: 7053591785067101823}
splashImage: {fileID: 643319091859997542}
splashImageFitter: {fileID: 2269522274416780085}
splashImageTexture: {fileID: 2800000, guid: 9d6cefbcf97cf2f4f96b427e7c7475e3, type: 3}
Expand Down Expand Up @@ -1793,16 +1805,6 @@ MonoBehaviour:
- {fileID: 722368441950897630}
transformLockButtonActiveIcon: {fileID: 2971953338018381896}
isTransformLocked: 0
l10nKeys:
- en.follow-master
- ja.follow-master
l10nValues:
- Sync is disabled
- "\u8FFD\u5F93\u304C\u7121\u52B9\u306B\u306A\u3063\u3066\u3044\u307E\u3059"
l10nTexts:
- {fileID: 7053591785067101823}
l10nTextKeys:
- follow-master
--- !u!114 &36657328902437027
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -2370,6 +2372,7 @@ GameObject:
- component: {fileID: 7053591785067101823}
- component: {fileID: 4274868873778623950}
- component: {fileID: 4909937986353846975}
- component: {fileID: 3865132342245356490}
m_Layer: 13
m_Name: Text (TMP)
m_TagString: Untagged
Expand Down Expand Up @@ -2526,6 +2529,19 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
schemaName: PrimaryText
--- !u!114 &3865132342245356490
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5018429192624729762}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 66c1f1dc168048deacdde81b0314fe8b, type: 3}
m_Name:
m_EditorClassIdentifier:
textKey: follow-master
--- !u!1 &5328230871907909714
GameObject:
m_ObjectHideFlags: 0
Expand Down
156 changes: 80 additions & 76 deletions Runtime/Editor/ImageSlideEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ namespace jp.ootr.ImageSlide.Editor
public class ImageSlideEditor : CommonDeviceEditor
{
[SerializeField] private StyleSheet imageSlideStyle;
private SerializedProperty _definedSourceTypes;
private SerializedProperty _definedSourceOffsets;

private VisualElement _definedSourceContainer;
private readonly List<VisualElement> _definedSourceElements = new List<VisualElement>();
private SerializedProperty _definedSourceIntervals;
private SerializedProperty _definedSourceOffsets;
private SerializedProperty _definedSources;
private SerializedProperty _definedSourceTypes;
private SerializedProperty _definedSourceUrls;

private SerializedProperty _deviceSelectedUuids;

private VisualElement _definedSourceContainer;
private List<VisualElement> _definedSourceElements = new List<VisualElement>();

public override void OnEnable()
{
Expand All @@ -54,20 +54,20 @@ protected override VisualElement GetContentTk()
container.Add(BuildDeviceList((ImageSlide)target));
container.Add(BuildDefinedUrls((ImageSlide)target));
container.Add(ShowTransformLock());

var seekMode = new EnumField("Seek Mode")
{
bindingPath = nameof(ImageSlide.seekMode),
bindingPath = nameof(ImageSlide.seekMode)
};
container.Add(seekMode);

return container;
}

protected override void ShowContent()
{
}

protected VisualElement ShowTransformLock()
{
var container = new VisualElement();
Expand All @@ -77,28 +77,28 @@ protected VisualElement ShowTransformLock()

var rootToggle = new Toggle("Root")
{
bindingPath = nameof(ImageSlide.rootTransformLocked),
bindingPath = nameof(ImageSlide.rootTransformLocked)
};
container.Add(rootToggle);

var nextPreviewToggle = new Toggle("Next Preview")
{
bindingPath = nameof(ImageSlide.nextPreviewTransformLocked),
bindingPath = nameof(ImageSlide.nextPreviewTransformLocked)
};
container.Add(nextPreviewToggle);

var noteToggle = new Toggle("Note")
{
bindingPath = nameof(ImageSlide.noteTransformLocked),
bindingPath = nameof(ImageSlide.noteTransformLocked)
};
container.Add(noteToggle);

var thumbnailToggle = new Toggle("Thumbnail")
{
bindingPath = nameof(ImageSlide.thumbnailTransformLocked),
bindingPath = nameof(ImageSlide.thumbnailTransformLocked)
};
container.Add(thumbnailToggle);

return container;
}

Expand All @@ -123,7 +123,7 @@ private VisualElement BuildDeviceList(ImageSlide script)
foreach (var device in script.devices.GetCastableDevices())
{
var isSelected = uuids.Contains(device.deviceUuid);

var deviceContainer = new VisualElement();
deviceContainer.style.flexDirection = FlexDirection.Row;

Expand All @@ -133,17 +133,17 @@ private VisualElement BuildDeviceList(ImageSlide script)
style =
{
flexDirection = FlexDirection.RowReverse,
textOverflow = TextOverflow.Ellipsis,
textOverflow = TextOverflow.Ellipsis
}
};

toggle.RegisterValueChangedCallback(evt =>
{
if (evt.newValue)
uuids.Add(device.deviceUuid);
else
uuids.Remove(device.deviceUuid);

serializedObject.Update();
_deviceSelectedUuids.arraySize = uuids.Count;
for (var i = 0; i < uuids.Count; i++)
Expand All @@ -157,16 +157,16 @@ private VisualElement BuildDeviceList(ImageSlide script)
deviceContainer.Add(toggle);
scrollView.Add(deviceContainer);
}

var lockToggle = new Toggle("Lock Device List")
{
bindingPath = nameof(ImageSlide.isDeviceListLocked),
bindingPath = nameof(ImageSlide.isDeviceListLocked)
};
container.Add(lockToggle);

return container;
}

private VisualElement BuildDefinedUrls(ImageSlide script)
{
var container = new VisualElement();
Expand All @@ -179,9 +179,10 @@ private VisualElement BuildDefinedUrls(ImageSlide script)
var urlIntervalsLength = script.definedSourceIntervals.Length;
var urlUrlsLength = script.definedSourceUrls.Length;
var arraySize = Mathf.Max(urlsLength, urlTypesLength, urlOffsetsLength, urlIntervalsLength, urlUrlsLength);


if (urlsLength != arraySize || urlTypesLength != arraySize || urlOffsetsLength != arraySize || urlIntervalsLength != arraySize || urlUrlsLength != arraySize)


if (urlsLength != arraySize || urlTypesLength != arraySize || urlOffsetsLength != arraySize ||
urlIntervalsLength != arraySize || urlUrlsLength != arraySize)
{
serializedObject.Update();
_definedSources.arraySize = arraySize;
Expand Down Expand Up @@ -238,32 +239,30 @@ private void RebuildTable()
_definedSourceElements.Add(row);
RebuildRow(i);
}

_definedSourceContainer.MarkDirtyRepaint();
}

private void RebuildRow(int index)
{
var script = (ImageSlide)target;
var row = _definedSourceElements[index];
row.Clear();

var type = script.definedSourceTypes[index];

var typeField = new EnumField("Type")
{
bindingPath = $"{nameof(ImageSlide.definedSourceTypes)}.Array.data[{index}]",
bindingPath = $"{nameof(ImageSlide.definedSourceTypes)}.Array.data[{index}]"
};
typeField.Bind(serializedObject);
typeField.RegisterValueChangedCallback(evt =>
{
RebuildRow(index);
});
typeField.RegisterValueChangedCallback(evt => { RebuildRow(index); });
typeField.AddToClassList("enum-field");
row.Add(typeField);

var sourceField = new TextField("Source")
{
bindingPath = $"{nameof(ImageSlide.definedSources)}.Array.data[{index}]",
bindingPath = $"{nameof(ImageSlide.definedSources)}.Array.data[{index}]"
};
sourceField.Bind(serializedObject);
sourceField.AddToClassList("text-field");
Expand All @@ -279,15 +278,15 @@ private void RebuildRow(int index)
{
var offsetField = new FloatField("Offset")
{
bindingPath = $"{nameof(ImageSlide.definedSourceOffsets)}.Array.data[{index}]",
bindingPath = $"{nameof(ImageSlide.definedSourceOffsets)}.Array.data[{index}]"
};
offsetField.Bind(serializedObject);
offsetField.AddToClassList("float-field");
row.Add(offsetField);

var intervalField = new FloatField("Interval")
{
bindingPath = $"{nameof(ImageSlide.definedSourceIntervals)}.Array.data[{index}]",
bindingPath = $"{nameof(ImageSlide.definedSourceIntervals)}.Array.data[{index}]"
};
intervalField.Bind(serializedObject);
intervalField.AddToClassList("float-field");
Expand All @@ -296,54 +295,58 @@ private void RebuildRow(int index)

if (index > 0)
{
var upButton = new Button(() =>
{
SwitchSource(index, index - 1);
})
{ text = "↑", style = { width = 25 } };
var upButton = new Button(() => { SwitchSource(index, index - 1); })
{ text = "↑", style = { width = 25 } };
row.Add(upButton);
}

if (index < script.definedSources.Length - 1)
{
var downButton = new Button(() =>
{
SwitchSource(index, index + 1);
})
{ text = "↓", style = { width = 25 } };
var downButton = new Button(() => { SwitchSource(index, index + 1); })
{ text = "↓", style = { width = 25 } };
row.Add(downButton);
}

var deleteButton = new Button(() =>
{
serializedObject.Update();
_definedSources.DeleteArrayElementAtIndex(index);
_definedSourceTypes.DeleteArrayElementAtIndex(index);
_definedSourceOffsets.DeleteArrayElementAtIndex(index);
_definedSourceIntervals.DeleteArrayElementAtIndex(index);
_definedSourceUrls.DeleteArrayElementAtIndex(index);
_definedSourceElements.RemoveAt(index);
serializedObject.ApplyModifiedProperties();
RebuildTable();
})
{ text = "X", style = { width = 25 } };
{
serializedObject.Update();
_definedSources.DeleteArrayElementAtIndex(index);
_definedSourceTypes.DeleteArrayElementAtIndex(index);
_definedSourceOffsets.DeleteArrayElementAtIndex(index);
_definedSourceIntervals.DeleteArrayElementAtIndex(index);
_definedSourceUrls.DeleteArrayElementAtIndex(index);
_definedSourceElements.RemoveAt(index);
serializedObject.ApplyModifiedProperties();

RebuildTable();
})
{ text = "X", style = { width = 25 } };
row.Add(deleteButton);
}

private void SwitchSource(int index1, int index2)
{
serializedObject.Update();
(_definedSources.GetArrayElementAtIndex(index1).stringValue, _definedSources.GetArrayElementAtIndex(index2).stringValue) =
(_definedSources.GetArrayElementAtIndex(index2).stringValue, _definedSources.GetArrayElementAtIndex(index1).stringValue);
(_definedSourceTypes.GetArrayElementAtIndex(index1).enumValueIndex, _definedSourceTypes.GetArrayElementAtIndex(index2).enumValueIndex) =
(_definedSourceTypes.GetArrayElementAtIndex(index2).enumValueIndex, _definedSourceTypes.GetArrayElementAtIndex(index1).enumValueIndex);
(_definedSourceOffsets.GetArrayElementAtIndex(index1).floatValue, _definedSourceOffsets.GetArrayElementAtIndex(index2).floatValue) =
(_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);
(_definedSources.GetArrayElementAtIndex(index1).stringValue,
_definedSources.GetArrayElementAtIndex(index2).stringValue) =
(_definedSources.GetArrayElementAtIndex(index2).stringValue,
_definedSources.GetArrayElementAtIndex(index1).stringValue);
(_definedSourceTypes.GetArrayElementAtIndex(index1).enumValueIndex,
_definedSourceTypes.GetArrayElementAtIndex(index2).enumValueIndex) =
(_definedSourceTypes.GetArrayElementAtIndex(index2).enumValueIndex,
_definedSourceTypes.GetArrayElementAtIndex(index1).enumValueIndex);
(_definedSourceOffsets.GetArrayElementAtIndex(index1).floatValue,
_definedSourceOffsets.GetArrayElementAtIndex(index2).floatValue) =
(_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 @@ -363,11 +366,12 @@ private void AddSource(ImageSlide script, string source, string options)
_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;
_definedSourceUrls.GetArrayElementAtIndex(_definedSourceUrls.arraySize - 1).FindPropertyRelative("url")
.stringValue = source;

serializedObject.ApplyModifiedProperties();


var row = new VisualElement();
row.style.flexDirection = FlexDirection.Row;
_definedSourceContainer.Add(row);
Expand Down
Loading

0 comments on commit eddfd9b

Please sign in to comment.