mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-18 23:59:46 +03:00
texm viewer
This commit is contained in:
@ -47,7 +47,8 @@ public class App
|
||||
serviceCollection.AddSingleton(type);
|
||||
}
|
||||
|
||||
serviceCollection.AddSingleton(new ExplorerViewModel());
|
||||
serviceCollection.AddSingleton(new NResExplorerViewModel());
|
||||
serviceCollection.AddSingleton(new TexmExplorerViewModel());
|
||||
|
||||
var serviceProvider = serviceCollection.BuildServiceProvider();
|
||||
|
||||
|
@ -4,17 +4,20 @@ using NativeFileDialogSharp;
|
||||
using NResLib;
|
||||
using NResUI.Abstractions;
|
||||
using NResUI.Models;
|
||||
using TexmLib;
|
||||
|
||||
namespace NResUI.ImGuiUI
|
||||
{
|
||||
public class MainMenuBar : IImGuiPanel
|
||||
{
|
||||
private readonly ExplorerViewModel _explorerViewModel;
|
||||
private readonly NResExplorerViewModel _nResExplorerViewModel;
|
||||
private readonly TexmExplorerViewModel _texmExplorerViewModel;
|
||||
|
||||
private readonly MessageBoxModalPanel _messageBox;
|
||||
public MainMenuBar(ExplorerViewModel explorerViewModel, MessageBoxModalPanel messageBox)
|
||||
public MainMenuBar(NResExplorerViewModel nResExplorerViewModel, TexmExplorerViewModel texmExplorerViewModel, MessageBoxModalPanel messageBox)
|
||||
{
|
||||
_explorerViewModel = explorerViewModel;
|
||||
_nResExplorerViewModel = nResExplorerViewModel;
|
||||
_texmExplorerViewModel = texmExplorerViewModel;
|
||||
_messageBox = messageBox;
|
||||
}
|
||||
|
||||
@ -34,11 +37,29 @@ namespace NResUI.ImGuiUI
|
||||
|
||||
var parseResult = NResParser.ReadFile(path);
|
||||
|
||||
_explorerViewModel.SetParseResult(parseResult, path);
|
||||
_nResExplorerViewModel.SetParseResult(parseResult, path);
|
||||
Console.WriteLine("Read NRES");
|
||||
}
|
||||
}
|
||||
|
||||
if (_explorerViewModel.HasFile)
|
||||
if (ImGui.MenuItem("Open TEXM"))
|
||||
{
|
||||
var result = Dialog.FileOpen();
|
||||
|
||||
if (result.IsOk)
|
||||
{
|
||||
var path = result.Path;
|
||||
|
||||
using var fs = new FileStream(path, FileMode.Open);
|
||||
|
||||
var parseResult = TexmParser.ReadFromStream(fs, path);
|
||||
|
||||
_texmExplorerViewModel.SetParseResult(parseResult, path);
|
||||
Console.WriteLine("Read TEXM");
|
||||
}
|
||||
}
|
||||
|
||||
if (_nResExplorerViewModel.HasFile)
|
||||
{
|
||||
if (ImGui.MenuItem("Экспортировать"))
|
||||
{
|
||||
@ -48,32 +69,13 @@ namespace NResUI.ImGuiUI
|
||||
{
|
||||
var path = result.Path;
|
||||
|
||||
NResExporter.Export(_explorerViewModel.Archive!, path, _explorerViewModel.Path!);
|
||||
NResExporter.Export(_nResExplorerViewModel.Archive!, path, _nResExplorerViewModel.Path!);
|
||||
|
||||
_messageBox.Show("Успешно экспортировано");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui.BeginMenu("Open Recent"))
|
||||
{
|
||||
ImGui.EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui.MenuItem("Exit"))
|
||||
{
|
||||
App.Instance.Exit();
|
||||
}
|
||||
|
||||
ImGui.EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui.BeginMenu("Windows"))
|
||||
{
|
||||
if (ImGui.MenuItem("Settings"))
|
||||
{
|
||||
}
|
||||
|
||||
ImGui.EndMenu();
|
||||
}
|
||||
|
||||
|
@ -4,18 +4,18 @@ using NResUI.Models;
|
||||
|
||||
namespace NResUI.ImGuiUI;
|
||||
|
||||
public class ExplorerPanel : IImGuiPanel
|
||||
public class NResExplorerPanel : IImGuiPanel
|
||||
{
|
||||
private readonly ExplorerViewModel _viewModel;
|
||||
private readonly NResExplorerViewModel _viewModel;
|
||||
|
||||
public ExplorerPanel(ExplorerViewModel viewModel)
|
||||
public NResExplorerPanel(NResExplorerViewModel viewModel)
|
||||
{
|
||||
_viewModel = viewModel;
|
||||
}
|
||||
|
||||
public void OnImGuiRender()
|
||||
{
|
||||
if (ImGui.Begin("Explorer"))
|
||||
if (ImGui.Begin("NRes Explorer"))
|
||||
{
|
||||
if (!_viewModel.HasFile)
|
||||
{
|
73
NResUI/ImGuiUI/TexmExplorer.cs
Normal file
73
NResUI/ImGuiUI/TexmExplorer.cs
Normal file
@ -0,0 +1,73 @@
|
||||
using ImGuiNET;
|
||||
using NResUI.Abstractions;
|
||||
using NResUI.Models;
|
||||
|
||||
namespace NResUI.ImGuiUI;
|
||||
|
||||
public class TexmExplorer : IImGuiPanel
|
||||
{
|
||||
private readonly TexmExplorerViewModel _viewModel;
|
||||
|
||||
public TexmExplorer(TexmExplorerViewModel viewModel)
|
||||
{
|
||||
_viewModel = viewModel;
|
||||
}
|
||||
|
||||
public void OnImGuiRender()
|
||||
{
|
||||
if (ImGui.Begin("TEXM Explorer"))
|
||||
{
|
||||
if (!_viewModel.HasFile)
|
||||
{
|
||||
ImGui.Text("No TEXM opened");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_viewModel.TexmFile is not null)
|
||||
{
|
||||
ImGui.Text("File: ");
|
||||
ImGui.SameLine();
|
||||
ImGui.Text(_viewModel.Path);
|
||||
|
||||
ImGui.Text("Header: ");
|
||||
ImGui.SameLine();
|
||||
ImGui.Text(_viewModel.TexmFile.Header.TexmAscii);
|
||||
|
||||
ImGui.Text("Width: ");
|
||||
ImGui.SameLine();
|
||||
ImGui.Text(_viewModel.TexmFile.Header.Width.ToString());
|
||||
|
||||
ImGui.Text("Height: ");
|
||||
ImGui.SameLine();
|
||||
ImGui.Text(_viewModel.TexmFile.Header.Height.ToString());
|
||||
|
||||
ImGui.Text("MipMap Count: ");
|
||||
ImGui.SameLine();
|
||||
ImGui.Text(_viewModel.TexmFile.Header.MipmapCount.ToString());
|
||||
|
||||
ImGui.Text("Stride: ");
|
||||
ImGui.SameLine();
|
||||
ImGui.Text(_viewModel.TexmFile.Header.Stride.ToString());
|
||||
|
||||
ImGui.Text("Magic1: ");
|
||||
ImGui.SameLine();
|
||||
ImGui.Text(_viewModel.TexmFile.Header.Magic1.ToString());
|
||||
|
||||
ImGui.Text("Magic2: ");
|
||||
ImGui.SameLine();
|
||||
ImGui.Text(_viewModel.TexmFile.Header.Magic2.ToString());
|
||||
|
||||
ImGui.Text("Format: ");
|
||||
ImGui.SameLine();
|
||||
ImGui.Text(_viewModel.TexmFile.Header.Format.ToString());
|
||||
|
||||
ImGui.Text("IsIndexed: ");
|
||||
ImGui.SameLine();
|
||||
ImGui.Text(_viewModel.TexmFile.IsIndexed.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.End();
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace NResUI.Models;
|
||||
|
||||
public class ExplorerViewModel
|
||||
public class NResExplorerViewModel
|
||||
{
|
||||
public bool HasFile { get; set; }
|
||||
public string? Error { get; set; }
|
27
NResUI/Models/TexmExplorerViewModel.cs
Normal file
27
NResUI/Models/TexmExplorerViewModel.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using TexmLib;
|
||||
|
||||
namespace NResUI.Models;
|
||||
|
||||
public class TexmExplorerViewModel
|
||||
{
|
||||
public bool HasFile { get; set; }
|
||||
public string? Error { get; set; }
|
||||
|
||||
public TexmFile? TexmFile { get; set; }
|
||||
|
||||
public string? Path { get; set; }
|
||||
|
||||
public void SetParseResult(TexmParseResult result, string path)
|
||||
{
|
||||
Error = result.Error;
|
||||
|
||||
if (result.TexmFile != null)
|
||||
{
|
||||
HasFile = true;
|
||||
}
|
||||
|
||||
TexmFile = result.TexmFile;
|
||||
Path = path;
|
||||
}
|
||||
|
||||
}
|
@ -20,6 +20,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NResLib\NResLib.csproj" />
|
||||
<ProjectReference Include="..\TexmLib\TexmLib.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Reference in New Issue
Block a user