mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-06-12 17:34:52 +00:00
Move Common functionality to Core project & rendering and Model support as well
This commit is contained in:
24
PckStudio.Core/Interfaces/IEditor.cs
Normal file
24
PckStudio.Core/Interfaces/IEditor.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio.Interfaces
|
||||
{
|
||||
public interface IEditor<T> where T : class
|
||||
{
|
||||
T EditorValue { get; }
|
||||
|
||||
ISaveContext<T> SaveContext { get; }
|
||||
|
||||
void Save();
|
||||
|
||||
void SaveAs();
|
||||
|
||||
void Close();
|
||||
|
||||
void UpdateView();
|
||||
}
|
||||
}
|
||||
22
PckStudio.Core/Interfaces/IModelImportProvider.cs
Normal file
22
PckStudio.Core/Interfaces/IModelImportProvider.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using PckStudio.Core;
|
||||
|
||||
namespace PckStudio.Interfaces
|
||||
{
|
||||
public interface IModelImportProvider<T> where T : class
|
||||
{
|
||||
public string Name { get; }
|
||||
|
||||
public FileDialogFilter DialogFilter { get; }
|
||||
|
||||
public bool SupportImport { get; }
|
||||
public bool SupportExport { get; }
|
||||
|
||||
public T Import(string filename);
|
||||
public T Import(Stream stream);
|
||||
|
||||
public void Export(string filename, T model);
|
||||
public void Export(ref Stream stream, T model);
|
||||
}
|
||||
}
|
||||
9
PckStudio.Core/Interfaces/IPckAssetDeserializer.cs
Normal file
9
PckStudio.Core/Interfaces/IPckAssetDeserializer.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio.Interfaces
|
||||
{
|
||||
public interface IPckAssetDeserializer<T>
|
||||
{
|
||||
public T Deserialize(PckAsset asset);
|
||||
}
|
||||
}
|
||||
9
PckStudio.Core/Interfaces/IPckAssetSerializer.cs
Normal file
9
PckStudio.Core/Interfaces/IPckAssetSerializer.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio.Interfaces
|
||||
{
|
||||
public interface IPckAssetSerializer<T>
|
||||
{
|
||||
public void Serialize(T obj, ref PckAsset asset);
|
||||
}
|
||||
}
|
||||
9
PckStudio.Core/Interfaces/ISaveContext.cs
Normal file
9
PckStudio.Core/Interfaces/ISaveContext.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace PckStudio.Interfaces
|
||||
{
|
||||
public interface ISaveContext<T>
|
||||
{
|
||||
public bool AutoSave { get; }
|
||||
|
||||
public void Save(T value);
|
||||
}
|
||||
}
|
||||
65
PckStudio.Core/Interfaces/ITryGetSet.cs
Normal file
65
PckStudio.Core/Interfaces/ITryGetSet.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
namespace PckStudio.Interfaces
|
||||
{
|
||||
public delegate bool TryGetDelegate<in TKey, TValue>(TKey key, out TValue value);
|
||||
public delegate bool TrySetDelegate<in TKey, TValue>(TKey key, TValue value);
|
||||
|
||||
public sealed class TryGet<TKey, TValue> : ITryGet<TKey, TValue>
|
||||
{
|
||||
private TryGetDelegate<TKey, TValue> _tryGetDelegate;
|
||||
|
||||
public static ITryGet<TKey, TValue> FromDelegate(TryGetDelegate<TKey, TValue> tryGetDelegate) => new TryGet<TKey, TValue>(tryGetDelegate);
|
||||
|
||||
bool ITryGet<TKey, TValue>.TryGet(TKey key, out TValue value) => _tryGetDelegate(key, out value);
|
||||
|
||||
private TryGet(TryGetDelegate<TKey, TValue> tryGetDelegate)
|
||||
{
|
||||
_tryGetDelegate = tryGetDelegate;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class TrySet<TKey, TValue> : ITrySet<TKey, TValue>
|
||||
{
|
||||
private TrySetDelegate<TKey, TValue> _trySetDelegate;
|
||||
|
||||
public static ITrySet<TKey, TValue> FromDelegate(TrySetDelegate<TKey, TValue> trySetDelegate) => new TrySet<TKey, TValue>(trySetDelegate);
|
||||
|
||||
bool ITrySet<TKey, TValue>.TrySet(TKey key, TValue value) => _trySetDelegate(key, value);
|
||||
|
||||
private TrySet(TrySetDelegate<TKey, TValue> trySetDelegate)
|
||||
{
|
||||
_trySetDelegate = trySetDelegate;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class TryGetSet<TKey, TValue> : ITryGetSet<TKey, TValue>
|
||||
{
|
||||
public static ITryGetSet<TKey, TValue> FromDelegates(TryGetDelegate<TKey, TValue> tryGetDelegate, TrySetDelegate<TKey, TValue> trySetDelegate) => new TryGetSet<TKey, TValue>(tryGetDelegate, trySetDelegate);
|
||||
|
||||
public bool TryGet(TKey key, out TValue value) => _tryGetDelegate(key, out value);
|
||||
|
||||
public bool TrySet(TKey key, TValue value) => _trySetDelegate(key, value);
|
||||
|
||||
private TryGetDelegate<TKey, TValue> _tryGetDelegate;
|
||||
private TrySetDelegate<TKey, TValue> _trySetDelegate;
|
||||
|
||||
private TryGetSet(TryGetDelegate<TKey, TValue> tryGetDelegate, TrySetDelegate<TKey, TValue> trySetDelegate)
|
||||
{
|
||||
_tryGetDelegate = tryGetDelegate;
|
||||
_trySetDelegate = trySetDelegate;
|
||||
}
|
||||
}
|
||||
|
||||
public interface ITryGet<in TKey, TValue>
|
||||
{
|
||||
bool TryGet(TKey key, out TValue value);
|
||||
}
|
||||
|
||||
public interface ITrySet<in TKey, TValue>
|
||||
{
|
||||
bool TrySet(TKey key, TValue value);
|
||||
}
|
||||
|
||||
public interface ITryGetSet<in TKey, TValue> : ITryGet<TKey, TValue>, ITrySet<TKey, TValue>
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user