plugin work, page navigation, reticks
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
using BarRaider.SdTools;
|
||||
using ClipTrimDotNet.Keys;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Newtonsoft.Json;
|
||||
using SocketIOClient;
|
||||
using System;
|
||||
@ -104,23 +106,96 @@ namespace ClipTrimDotNet.Client
|
||||
|
||||
public List<CollectionMetaData> Collections { get; private set; } = new List<CollectionMetaData>();
|
||||
public int SelectedCollection { get; private set; } = -1;
|
||||
public int PageIndex { get; private set; } = 0;
|
||||
|
||||
public Dictionary<int, int> CollectionIndexes { get; private set; } = new();
|
||||
public int PageIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SelectedCollection == -1) return 0;
|
||||
if (!CollectionIndexes.ContainsKey(SelectedCollection))
|
||||
{
|
||||
CollectionIndexes[SelectedCollection] = 0;
|
||||
}
|
||||
return CollectionIndexes[SelectedCollection];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (SelectedCollection == -1) return;
|
||||
CollectionIndexes[SelectedCollection] = value;
|
||||
}
|
||||
}
|
||||
public bool PageMode { get; set; } = false;
|
||||
|
||||
public int PageCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SelectedCollection == -1) return 0;
|
||||
var collection = Collections[SelectedCollection];
|
||||
return (collection.Clips.Count - 1) / 10 + 1;
|
||||
}
|
||||
}
|
||||
public bool CanPageUp
|
||||
{
|
||||
get
|
||||
{
|
||||
if(PageMode) return false;
|
||||
if (SelectedCollection == -1) return false;
|
||||
return PageCount - PageIndex > 1;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanPageDown
|
||||
{
|
||||
get
|
||||
{
|
||||
if (PageMode) return false;
|
||||
return PageIndex > 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void PageDown()
|
||||
{
|
||||
if (CanPageDown)
|
||||
{
|
||||
PageIndex--;
|
||||
}
|
||||
}
|
||||
|
||||
public void PageUp()
|
||||
{
|
||||
if (CanPageUp)
|
||||
{
|
||||
PageIndex++;
|
||||
}
|
||||
}
|
||||
public List<string> GetCollectionNames()
|
||||
{
|
||||
//await GetMetadata();
|
||||
return Collections.Select(x => x.Name).ToList();
|
||||
return Collections.Where(x => x.Name != "Uncategorized").Select(x => x.Name).ToList();
|
||||
}
|
||||
|
||||
public void SetSelectedCollectionByName(string name)
|
||||
public string GetPlayerStringByCoordinateIndex(int index)
|
||||
{
|
||||
SelectedCollection = Collections.FindIndex(x => x.Name == name);
|
||||
if (SelectedCollection != -1)
|
||||
if (PageMode)
|
||||
{
|
||||
PageIndex = 0;
|
||||
int pageNumber = index + 1;
|
||||
if(pageNumber <= PageCount)
|
||||
{
|
||||
return pageNumber.ToString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
var collection = GetClipByPagedIndex(index);
|
||||
return collection?.Name ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ClipMetadata? GetClipByPagedIndex(int index)
|
||||
{
|
||||
SelectedCollection = Collections.FindIndex(x => x.Name == GlobalSettings.Instance.ProfileName);
|
||||
@ -134,11 +209,29 @@ namespace ClipTrimDotNet.Client
|
||||
return null;
|
||||
}
|
||||
|
||||
public async void PlayClip(ClipMetadata? metadata)
|
||||
public async void PlayClip(int index)
|
||||
{
|
||||
if (metadata == null) return;
|
||||
Logger.Instance.LogMessage(TracingLevel.INFO, $"playing clip:");
|
||||
await socket.EmitAsync("play_clip", new List<object>() { metadata });
|
||||
if (PageMode)
|
||||
{
|
||||
if(index < 0 || index >= PageCount) return;
|
||||
PageIndex = index;
|
||||
PageMode = false;
|
||||
Player.TickAll();
|
||||
PageNavigator.TickAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
var metadata = GetClipByPagedIndex(index);
|
||||
if (metadata == null) return;
|
||||
Logger.Instance.LogMessage(TracingLevel.INFO, $"playing clip:");
|
||||
await socket.EmitAsync("play_clip", new List<object>() { metadata });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async void SaveClip()
|
||||
{
|
||||
await socket.EmitAsync("record_clip", new List<object>() { });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user