mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2026-08-15 02:57:49 +04:00
fpopov thanks
This commit is contained in:
+5
-5
@@ -12,10 +12,10 @@ namespace NResUI;
|
||||
|
||||
public class App
|
||||
{
|
||||
public GL GL { get; set; }
|
||||
public IInputContext Input { get; set; }
|
||||
public GL GL { get; set; } = null!;
|
||||
public IInputContext Input { get; set; } = null!;
|
||||
|
||||
public static App Instance;
|
||||
public static App Instance = null!;
|
||||
|
||||
private static bool _dockspaceOpen = true;
|
||||
private static bool _optFullscreenPersistant = true;
|
||||
@@ -25,7 +25,7 @@ public class App
|
||||
|
||||
public ImFontPtr OpenSansFont;
|
||||
|
||||
private List<IImGuiPanel> _imGuiPanels;
|
||||
private List<IImGuiPanel> _imGuiPanels = [];
|
||||
|
||||
public App()
|
||||
{
|
||||
@@ -151,4 +151,4 @@ public class App
|
||||
public void OnKeyReleased(Key key)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class NResExplorerPanel : IImGuiPanel
|
||||
ImGui.SameLine();
|
||||
ImGui.Text(_viewModel.Archive.Header.TotalFileLengthBytes.ToString());
|
||||
|
||||
if (ImGui.BeginTable("content", 12,
|
||||
if (ImGui.BeginTable("content", 9,
|
||||
ImGuiTableFlags.Borders | ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.NoHostExtendX))
|
||||
{
|
||||
ImGui.TableSetupColumn("Тип файла");
|
||||
@@ -79,12 +79,9 @@ public class NResExplorerPanel : IImGuiPanel
|
||||
ImGui.TableSetupColumn("Длина файла в байтах");
|
||||
ImGui.TableSetupColumn("Размер элемента");
|
||||
ImGui.TableSetupColumn("Имя файла");
|
||||
ImGui.TableSetupColumn("Magic3");
|
||||
ImGui.TableSetupColumn("Magic4");
|
||||
ImGui.TableSetupColumn("Magic5");
|
||||
ImGui.TableSetupColumn("Magic6");
|
||||
ImGui.TableSetupColumn("Смещение в байтах");
|
||||
ImGui.TableSetupColumn("Индекс в файле");
|
||||
ImGui.TableSetupColumn("SortIndex");
|
||||
ImGui.TableSetupColumn("DirectoryIndex");
|
||||
|
||||
ImGui.TableHeadersRow();
|
||||
|
||||
@@ -124,26 +121,6 @@ public class NResExplorerPanel : IImGuiPanel
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.Text(_viewModel.Archive.Files[i].FileName);
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.Text(
|
||||
_viewModel.Archive.Files[i]
|
||||
.Magic3.ToString()
|
||||
);
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.Text(
|
||||
_viewModel.Archive.Files[i]
|
||||
.Magic4.ToString()
|
||||
);
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.Text(
|
||||
_viewModel.Archive.Files[i]
|
||||
.Magic5.ToString()
|
||||
);
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.Text(
|
||||
_viewModel.Archive.Files[i]
|
||||
.Magic6.ToString()
|
||||
);
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.Text(
|
||||
_viewModel.Archive.Files[i]
|
||||
.OffsetInFile.ToString()
|
||||
@@ -151,7 +128,12 @@ public class NResExplorerPanel : IImGuiPanel
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.Text(
|
||||
_viewModel.Archive.Files[i]
|
||||
.Index.ToString()
|
||||
.SortIndex.ToString()
|
||||
);
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.Text(
|
||||
_viewModel.Archive.Files[i]
|
||||
.DirectoryIndex.ToString()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -309,4 +291,4 @@ public class NResExplorerPanel : IImGuiPanel
|
||||
ImGui.End();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,6 +166,43 @@ public class TexmExplorer : IImGuiPanel
|
||||
}
|
||||
|
||||
ImGui.Image((IntPtr) glTexture.GlTexture, imageSize);
|
||||
|
||||
var imageHovered = ImGui.IsItemHovered();
|
||||
|
||||
if (imageHovered && index < _viewModel.RgbaBytesByMipmap.Count)
|
||||
{
|
||||
var mousePos = ImGui.GetMousePos();
|
||||
|
||||
var scale = _viewModel.DoubleSize ? 2.0f : 1.0f;
|
||||
var relativePos = (mousePos - screenPos) / scale;
|
||||
|
||||
var pixelX = (int)MathF.Floor(relativePos.X);
|
||||
var pixelY = (int)MathF.Floor(relativePos.Y);
|
||||
|
||||
pixelX = (int)Math.Clamp(pixelX, 0, glTexture.Width - 1);
|
||||
pixelY = (int)Math.Clamp(pixelY, 0, glTexture.Height - 1);
|
||||
|
||||
var rgbaBytes = _viewModel.RgbaBytesByMipmap[index];
|
||||
var byteIndex = (pixelY * glTexture.Width + pixelX) * 4;
|
||||
|
||||
if (byteIndex + 3 < rgbaBytes.Length)
|
||||
{
|
||||
var r = rgbaBytes[byteIndex + 0];
|
||||
var g = rgbaBytes[byteIndex + 1];
|
||||
var b = rgbaBytes[byteIndex + 2];
|
||||
var a = rgbaBytes[byteIndex + 3];
|
||||
|
||||
ImGui.BeginTooltip();
|
||||
|
||||
ImGui.Text($"Mipmap: {index}");
|
||||
ImGui.Text($"Pixel: X={pixelX}, Y={pixelY}");
|
||||
ImGui.Text($"RGBA: {r}, {g}, {b}, {a}");
|
||||
ImGui.Text($"HEX: #{r:X2}{g:X2}{b:X2}{a:X2}");
|
||||
|
||||
ImGui.EndTooltip();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
if (_viewModel.ViewPages && _viewModel.TexmFile.Pages is not null)
|
||||
@@ -180,18 +217,6 @@ public class TexmExplorer : IImGuiPanel
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
var mousePos = ImGui.GetMousePos();
|
||||
var relativePos = (mousePos - screenPos) / (_viewModel.DoubleSize
|
||||
? 2
|
||||
: 1);
|
||||
|
||||
ImGui.Text("Hovering over: ");
|
||||
ImGui.SameLine();
|
||||
ImGui.Text(relativePos.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ public class TexmExplorerViewModel
|
||||
|
||||
public string? Path { get; set; }
|
||||
public List<OpenGlTexture> GlTextures { get; set; } = [];
|
||||
public List<byte[]> RgbaBytesByMipmap { get; set; } = [];
|
||||
|
||||
private bool _glTexturesDirty = false;
|
||||
public bool IsWhiteBgEnabled;
|
||||
@@ -48,11 +49,14 @@ public class TexmExplorerViewModel
|
||||
}
|
||||
|
||||
GlTextures.Clear();
|
||||
RgbaBytesByMipmap.Clear();
|
||||
|
||||
for (var i = 0; i < TexmFile!.Header.MipmapCount; i++)
|
||||
for (var i = 0; i < TexmFile.Header.MipmapCount; i++)
|
||||
{
|
||||
var bytes = TexmFile.GetRgba32BytesFromMipmap(i, out var width, out var height);
|
||||
|
||||
RgbaBytesByMipmap.Add(bytes);
|
||||
|
||||
var glTexture = new OpenGlTexture(
|
||||
gl,
|
||||
width,
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace NResUI
|
||||
|
||||
public static float? MaxAniso;
|
||||
private readonly GL _gl;
|
||||
public readonly string Name;
|
||||
public readonly string Name = string.Empty;
|
||||
public readonly uint GlTexture;
|
||||
public readonly uint Width, Height;
|
||||
public readonly uint MipmapLevels;
|
||||
@@ -152,4 +152,4 @@ namespace NResUI
|
||||
_gl.DeleteTexture(GlTexture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user