Skip to content

footer に メッセージを表示できるようにする #32

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

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions Assets/ArtNet/Editor/DmxRecorder/RecorderWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,46 @@ private void CreateView()
_recorderSettingsPanel = visualElement.Q<VisualElement>("recorderSettingsPanel");
_recorderSettingsPanel.Add(new IMGUIContainer(RecorderSettingsGUI));

var footerMessages = visualElement.Q<VisualElement>("footerMessages");
footerMessages.Add(new IMGUIContainer(StatusMessagesGUI));

SetRecordControllerSettings(RecordControllerSettings.GetOrNewGlobalSettings());
SetSettingPanelEnabled(!DisableEditRecordSettings());
}

private void StatusMessagesGUI()
{
var activeRecorders = _controller.Settings.RecorderSettings.Where(x => x.Enabled).ToArray();

if (activeRecorders.Length == 0)
{
ShowMessageInStatusBar("No active recorder", MessageType.Warning);
return;
}

if (activeRecorders.Any(x => x.HasErrors()))
{
ShowMessageInStatusBar("Some recorders have errors", MessageType.Error);
return;
}


switch (_controller.Status)
{
case RecordingStatus.Recording:
ShowMessageInStatusBar("Recording", MessageType.Info);
break;
case RecordingStatus.Paused:
ShowMessageInStatusBar("Paused", MessageType.Warning);
break;
case RecordingStatus.None:
ShowMessageInStatusBar("Ready", MessageType.Info);
break;
default:
throw new ArgumentOutOfRangeException();
}
}

private bool DisableEditRecordSettings()
{
return IsRecording;
Expand Down Expand Up @@ -466,6 +502,30 @@ private void SetSettingPanelEnabled(bool enabled)
_recorderSettingsPanel.SetEnabled(enabled);
}

private static void ShowMessageInStatusBar(string msg, MessageType messageType)
{
var rect = EditorGUILayout.GetControlRect();

if (messageType != MessageType.None)
{
var iconRect = rect;
iconRect.width = iconRect.height;

var icon = messageType switch
{
MessageType.Error => IconHelper.ErrorIcon,
MessageType.Warning => IconHelper.WarningIcon,
MessageType.Info => IconHelper.InfoIcon,
_ => null
};

GUI.DrawTexture(iconRect, icon);
rect.xMin = iconRect.xMax + 5.0f;
}

GUI.Label(rect, msg);
}

private static string TimeCodeText(int time)
{
var hours = time / 3600000;
Expand Down
5 changes: 4 additions & 1 deletion Assets/ArtNet/Editor/DmxRecorder/RecorderWindow.uss
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ EditableLabel > Label {

#footer {
padding: 6px;
flex-direction: row;
justify-content: space-between;
}

#footerMessages > .StatusMessage {
flex-direction: row;
}
2 changes: 1 addition & 1 deletion Assets/ArtNet/Editor/DmxRecorder/RecorderWindow.uxml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
</ui:ScrollView>
</ui:VisualElement>
<ui:VisualElement name="footer">
<ui:Label name="footerStatusLabel" />
<ui:VisualElement name="footerMessages" style="min-height: 16px; max-height: 64px;" />
</ui:VisualElement>
</ui:UXML>
Loading