bugfixes
This commit is contained in:
@@ -232,9 +232,16 @@ namespace SplashEdit.EditorCode
|
||||
serializedObject.Update();
|
||||
|
||||
Vector2 res = PSXCanvas.PSXResolution;
|
||||
EditorGUILayout.LabelField($"PSX Canvas ({res.x}x{res.y})", EditorStyles.boldLabel);
|
||||
|
||||
// Header card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField($"PSX Canvas ({res.x}x{res.y})", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Properties card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("canvasName"), new GUIContent("Canvas Name",
|
||||
"Name used from Lua: UI.FindCanvas(\"name\"). Max 24 chars."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("startVisible"), new GUIContent("Start Visible",
|
||||
@@ -244,18 +251,18 @@ namespace SplashEdit.EditorCode
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("defaultFont"), new GUIContent("Default Font",
|
||||
"Default custom font for text elements. If empty, uses built-in system font (8x16)."));
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
PSXEditorStyles.DrawSeparator(6, 6);
|
||||
|
||||
// Force Canvas configuration button
|
||||
if (GUILayout.Button($"Reset Canvas to {res.x}x{res.y}"))
|
||||
if (GUILayout.Button($"Reset Canvas to {res.x}x{res.y}", PSXEditorStyles.SecondaryButton))
|
||||
{
|
||||
PSXCanvas.InvalidateResolutionCache();
|
||||
((PSXCanvas)target).ConfigureCanvas();
|
||||
}
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Element summary
|
||||
// Element summary card
|
||||
PSXCanvas canvas = (PSXCanvas)target;
|
||||
int imageCount = canvas.GetComponentsInChildren<PSXUIImage>(true).Length;
|
||||
int boxCount = canvas.GetComponentsInChildren<PSXUIBox>(true).Length;
|
||||
@@ -263,14 +270,16 @@ namespace SplashEdit.EditorCode
|
||||
int progressCount = canvas.GetComponentsInChildren<PSXUIProgressBar>(true).Length;
|
||||
int total = imageCount + boxCount + textCount + progressCount;
|
||||
|
||||
EditorGUILayout.HelpBox(
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField(
|
||||
$"Elements: {total} total\n" +
|
||||
$" Images: {imageCount} | Boxes: {boxCount}\n" +
|
||||
$" Texts: {textCount} | Progress Bars: {progressCount}",
|
||||
total > 128 ? MessageType.Warning : MessageType.Info);
|
||||
PSXEditorStyles.InfoBox);
|
||||
|
||||
if (total > 128)
|
||||
EditorGUILayout.HelpBox("PS1 UI system supports max 128 elements total across all canvases.", MessageType.Error);
|
||||
EditorGUILayout.LabelField("PS1 UI system supports max 128 elements total across all canvases.", PSXEditorStyles.InfoBox);
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
@@ -286,9 +295,15 @@ namespace SplashEdit.EditorCode
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.LabelField("PSX UI Image", EditorStyles.boldLabel);
|
||||
// Header card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("PSX UI Image", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Properties card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("elementName"), new GUIContent("Element Name",
|
||||
"Name used from Lua: UI.FindElement(canvas, \"name\"). Max 24 chars."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("sourceTexture"), new GUIContent("Source Texture",
|
||||
@@ -298,13 +313,19 @@ namespace SplashEdit.EditorCode
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("tintColor"), new GUIContent("Tint Color",
|
||||
"Color multiply applied to the image (white = no tint)."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("startVisible"));
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
// Texture size warning
|
||||
PSXUIImage img = (PSXUIImage)target;
|
||||
if (img.SourceTexture != null)
|
||||
{
|
||||
if (img.SourceTexture.width > 256 || img.SourceTexture.height > 256)
|
||||
EditorGUILayout.HelpBox("Texture exceeds 256x256. It will be resized during export.", MessageType.Warning);
|
||||
{
|
||||
EditorGUILayout.Space(4);
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("Texture exceeds 256x256. It will be resized during export.", PSXEditorStyles.InfoBox);
|
||||
PSXEditorStyles.EndCard();
|
||||
}
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
@@ -321,13 +342,20 @@ namespace SplashEdit.EditorCode
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.LabelField("PSX UI Box", EditorStyles.boldLabel);
|
||||
// Header card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("PSX UI Box", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Properties card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("elementName"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("boxColor"), new GUIContent("Box Color",
|
||||
"Solid fill color rendered as a FastFill primitive."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("startVisible"));
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
@@ -343,9 +371,15 @@ namespace SplashEdit.EditorCode
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.LabelField("PSX UI Text", EditorStyles.boldLabel);
|
||||
// Header card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("PSX UI Text", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Properties card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("elementName"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("defaultText"), new GUIContent("Default Text",
|
||||
"Initial text content. Max 63 chars. Change at runtime via UI.SetText()."));
|
||||
@@ -354,24 +388,33 @@ namespace SplashEdit.EditorCode
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("fontOverride"), new GUIContent("Font Override",
|
||||
"Custom font for this text element. If empty, uses the canvas default font or built-in system font (8x16)."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("startVisible"));
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
// Character count
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Warnings and info
|
||||
PSXUIText txt = (PSXUIText)target;
|
||||
if (!string.IsNullOrEmpty(txt.DefaultText) && txt.DefaultText.Length > 63)
|
||||
EditorGUILayout.HelpBox("Text exceeds 63 characters and will be truncated.", MessageType.Warning);
|
||||
{
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("Text exceeds 63 characters and will be truncated.", PSXEditorStyles.InfoBox);
|
||||
PSXEditorStyles.EndCard();
|
||||
EditorGUILayout.Space(4);
|
||||
}
|
||||
|
||||
// Font info
|
||||
PSXEditorStyles.BeginCard();
|
||||
PSXFontAsset font = txt.GetEffectiveFont();
|
||||
if (font != null)
|
||||
{
|
||||
EditorGUILayout.HelpBox(
|
||||
EditorGUILayout.LabelField(
|
||||
$"Font: {font.name} ({font.GlyphWidth}x{font.GlyphHeight} glyphs)",
|
||||
MessageType.Info);
|
||||
PSXEditorStyles.InfoBox);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("Using built-in system font (8x16 glyphs).", MessageType.Info);
|
||||
EditorGUILayout.LabelField("Using built-in system font (8x16 glyphs).", PSXEditorStyles.InfoBox);
|
||||
}
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
@@ -387,9 +430,15 @@ namespace SplashEdit.EditorCode
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.LabelField("PSX UI Progress Bar", EditorStyles.boldLabel);
|
||||
// Header card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("PSX UI Progress Bar", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Properties card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("elementName"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("backgroundColor"), new GUIContent("Background Color",
|
||||
"Color shown behind the fill bar."));
|
||||
@@ -399,13 +448,12 @@ namespace SplashEdit.EditorCode
|
||||
"Starting progress (0-100). Change via UI.SetProgress()."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("startVisible"));
|
||||
|
||||
PSXEditorStyles.DrawSeparator(6, 4);
|
||||
|
||||
// Preview bar
|
||||
Rect r = EditorGUILayout.GetControlRect(false, 16);
|
||||
PSXUIProgressBar bar = (PSXUIProgressBar)target;
|
||||
EditorGUI.DrawRect(r, bar.BackgroundColor);
|
||||
Rect fill = r;
|
||||
fill.width *= bar.InitialValue / 100f;
|
||||
EditorGUI.DrawRect(fill, bar.FillColor);
|
||||
PSXEditorStyles.DrawProgressBar(bar.InitialValue / 100f, "Preview", bar.FillColor, 16);
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
@@ -424,11 +472,18 @@ namespace SplashEdit.EditorCode
|
||||
|
||||
PSXFontAsset font = (PSXFontAsset)target;
|
||||
|
||||
EditorGUILayout.LabelField("PSX Font Asset", EditorStyles.boldLabel);
|
||||
// Header card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("PSX Font Asset", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// ── Source font (TTF/OTF) ──
|
||||
EditorGUILayout.LabelField("Auto-Convert from Font", EditorStyles.miniBoldLabel);
|
||||
// Source font card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("Auto-Convert from Font", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.DrawSeparator(2, 4);
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("sourceFont"), new GUIContent("Source Font (TTF/OTF)",
|
||||
"Assign a Unity Font (TrueType/OpenType). Click 'Generate Bitmap' to rasterize it.\n" +
|
||||
"Glyph cell dimensions are auto-derived from the font metrics."));
|
||||
@@ -440,102 +495,121 @@ namespace SplashEdit.EditorCode
|
||||
if (font.SourceFont != null)
|
||||
{
|
||||
EditorGUILayout.Space(2);
|
||||
if (GUILayout.Button("Generate Bitmap from Font", GUILayout.Height(28)))
|
||||
if (GUILayout.Button("Generate Bitmap from Font", PSXEditorStyles.PrimaryButton, GUILayout.Height(28)))
|
||||
{
|
||||
Undo.RecordObject(font, "Generate PSX Font Bitmap");
|
||||
font.GenerateBitmapFromFont();
|
||||
}
|
||||
|
||||
if (font.FontTexture == null)
|
||||
EditorGUILayout.HelpBox(
|
||||
EditorGUILayout.LabelField(
|
||||
"Click 'Generate Bitmap' to create the font texture.\n" +
|
||||
"If generation fails, check that the font's import settings have " +
|
||||
"'Character' set to 'ASCII Default Set'.", MessageType.Info);
|
||||
"'Character' set to 'ASCII Default Set'.", PSXEditorStyles.InfoBox);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space(8);
|
||||
|
||||
// ── Manual bitmap ──
|
||||
EditorGUILayout.LabelField("Manual Bitmap Source", EditorStyles.miniBoldLabel);
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("fontTexture"), new GUIContent("Font Texture",
|
||||
"256px wide bitmap. Glyphs in ASCII order from 0x20 (space). " +
|
||||
"Transparent = background, opaque = foreground."));
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// ── Glyph metrics ──
|
||||
// If using auto-convert, these are set by GenerateBitmapFromFont.
|
||||
// For manual bitmaps, the user sets them directly.
|
||||
EditorGUILayout.LabelField("Glyph Metrics", EditorStyles.miniBoldLabel);
|
||||
// Manual bitmap card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("Manual Bitmap Source", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.DrawSeparator(2, 4);
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("fontTexture"), new GUIContent("Font Texture",
|
||||
"256px wide bitmap. Glyphs in ASCII order from 0x20 (space). " +
|
||||
"Transparent = background, opaque = foreground."));
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Glyph metrics card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("Glyph Metrics", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.DrawSeparator(2, 4);
|
||||
|
||||
if (font.SourceFont != null && font.FontTexture != null)
|
||||
{
|
||||
// Show as read-only when auto-generated
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.IntField(new GUIContent("Glyph Width", "Auto-derived from font. Re-generate to change."), font.GlyphWidth);
|
||||
EditorGUILayout.IntField(new GUIContent("Glyph Height", "Auto-derived from font. Re-generate to change."), font.GlyphHeight);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
EditorGUILayout.HelpBox("Glyph dimensions are auto-derived when generating from a font.\n" +
|
||||
"Change the Font Size slider and re-generate to adjust.", MessageType.Info);
|
||||
EditorGUILayout.LabelField("Glyph dimensions are auto-derived when generating from a font.\n" +
|
||||
"Change the Font Size slider and re-generate to adjust.", PSXEditorStyles.InfoBox);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Editable for manual bitmap workflow
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("glyphWidth"), new GUIContent("Glyph Width",
|
||||
"Width of each glyph cell in pixels. Must divide 256 evenly (4, 8, 16, or 32)."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("glyphHeight"), new GUIContent("Glyph Height",
|
||||
"Height of each glyph cell in pixels."));
|
||||
}
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// ── Layout info ──
|
||||
// Layout info card
|
||||
PSXEditorStyles.BeginCard();
|
||||
int glyphsPerRow = font.GlyphsPerRow;
|
||||
int rowCount = font.RowCount;
|
||||
int totalH = font.TextureHeight;
|
||||
int vramBytes = totalH * 128; // 128 bytes per row at 4bpp 256px
|
||||
int vramBytes = totalH * 128;
|
||||
|
||||
EditorGUILayout.HelpBox(
|
||||
EditorGUILayout.LabelField(
|
||||
$"Layout: {glyphsPerRow} glyphs/row, {rowCount} rows\n" +
|
||||
$"Texture: 256 x {totalH} pixels (4bpp)\n" +
|
||||
$"VRAM: {vramBytes} bytes ({vramBytes / 1024f:F1} KB)\n" +
|
||||
$"Glyph cell: {font.GlyphWidth} x {font.GlyphHeight}",
|
||||
MessageType.Info);
|
||||
PSXEditorStyles.InfoBox);
|
||||
|
||||
// Show advance width status
|
||||
if (font.AdvanceWidths != null && font.AdvanceWidths.Length >= 95)
|
||||
{
|
||||
int minAdv = 255, maxAdv = 0;
|
||||
for (int i = 1; i < 95; i++) // skip space
|
||||
for (int i = 1; i < 95; i++)
|
||||
{
|
||||
if (font.AdvanceWidths[i] < minAdv) minAdv = font.AdvanceWidths[i];
|
||||
if (font.AdvanceWidths[i] > maxAdv) maxAdv = font.AdvanceWidths[i];
|
||||
}
|
||||
EditorGUILayout.HelpBox(
|
||||
EditorGUILayout.LabelField(
|
||||
$"Advance widths: {minAdv}-{maxAdv}px (proportional spacing stored)",
|
||||
MessageType.Info);
|
||||
PSXEditorStyles.InfoBox);
|
||||
}
|
||||
else if (font.FontTexture != null)
|
||||
{
|
||||
EditorGUILayout.HelpBox(
|
||||
EditorGUILayout.LabelField(
|
||||
"No advance widths stored. Click 'Generate Bitmap' to compute them.",
|
||||
MessageType.Warning);
|
||||
PSXEditorStyles.InfoBox);
|
||||
}
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
// ── Validation ──
|
||||
// Validation
|
||||
if (font.FontTexture != null)
|
||||
{
|
||||
if (font.FontTexture.width != 256)
|
||||
EditorGUILayout.HelpBox($"Font texture must be 256 pixels wide (currently {font.FontTexture.width}).", MessageType.Error);
|
||||
{
|
||||
EditorGUILayout.Space(4);
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField($"Font texture must be 256 pixels wide (currently {font.FontTexture.width}).", PSXEditorStyles.InfoBox);
|
||||
PSXEditorStyles.EndCard();
|
||||
}
|
||||
|
||||
if (256 % font.GlyphWidth != 0)
|
||||
EditorGUILayout.HelpBox($"Glyph width ({font.GlyphWidth}) must divide 256 evenly. " +
|
||||
"Valid values: 4, 8, 16, 32.", MessageType.Error);
|
||||
{
|
||||
EditorGUILayout.Space(4);
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField($"Glyph width ({font.GlyphWidth}) must divide 256 evenly. " +
|
||||
"Valid values: 4, 8, 16, 32.", PSXEditorStyles.InfoBox);
|
||||
PSXEditorStyles.EndCard();
|
||||
}
|
||||
|
||||
// Show preview
|
||||
// Preview
|
||||
EditorGUILayout.Space(4);
|
||||
EditorGUILayout.LabelField("Preview", EditorStyles.miniBoldLabel);
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("Preview", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.DrawSeparator(2, 4);
|
||||
Rect previewRect = EditorGUILayout.GetControlRect(false, 64);
|
||||
GUI.DrawTexture(previewRect, font.FontTexture, ScaleMode.ScaleToFit);
|
||||
PSXEditorStyles.EndCard();
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
Reference in New Issue
Block a user