bugfixes
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using SplashEdit.RuntimeCode;
|
||||
using Unity.Collections;
|
||||
@@ -19,25 +18,15 @@ namespace SplashEdit.EditorCode
|
||||
private List<ProhibitedArea> prohibitedAreas = new List<ProhibitedArea>();
|
||||
private Vector2 scrollPosition;
|
||||
private Texture2D vramImage;
|
||||
private Vector2 selectedResolution = new Vector2(320, 240);
|
||||
private bool dualBuffering = true;
|
||||
private bool verticalLayout = true;
|
||||
private static readonly Vector2 selectedResolution = new Vector2(320, 240);
|
||||
private const bool dualBuffering = true;
|
||||
private const bool verticalLayout = true;
|
||||
private Color bufferColor1 = new Color(1, 0, 0, 0.5f);
|
||||
private Color bufferColor2 = new Color(0, 1, 0, 0.5f);
|
||||
private Color prohibitedColor = new Color(1, 0, 0, 0.3f);
|
||||
private PSXData _psxData;
|
||||
private PSXFontData[] _cachedFonts;
|
||||
|
||||
private static readonly Vector2[] resolutions =
|
||||
{
|
||||
new Vector2(256, 240), new Vector2(256, 480),
|
||||
new Vector2(320, 240), new Vector2(320, 480),
|
||||
new Vector2(368, 240), new Vector2(368, 480),
|
||||
new Vector2(512, 240), new Vector2(512, 480),
|
||||
new Vector2(640, 240), new Vector2(640, 480)
|
||||
};
|
||||
private static string[] resolutionsStrings => resolutions.Select(c => $"{c.x}x{c.y}").ToArray();
|
||||
|
||||
[MenuItem("PlayStation 1/VRAM Editor")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
@@ -58,7 +47,9 @@ namespace SplashEdit.EditorCode
|
||||
// Ensure minimum window size is applied.
|
||||
this.minSize = MinSize;
|
||||
|
||||
_psxData = DataStorage.LoadData(out selectedResolution, out dualBuffering, out verticalLayout, out prohibitedAreas);
|
||||
Vector2 ignoredRes;
|
||||
bool ignoredDb, ignoredVl;
|
||||
_psxData = DataStorage.LoadData(out ignoredRes, out ignoredDb, out ignoredVl, out prohibitedAreas);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -202,64 +193,18 @@ namespace SplashEdit.EditorCode
|
||||
}
|
||||
|
||||
vramImage.Apply();
|
||||
|
||||
// Prompt the user to select a file location and save the VRAM data.
|
||||
string path = EditorUtility.SaveFilePanel("Select Output File", "", "output", "bin");
|
||||
|
||||
if (path != string.Empty)
|
||||
{
|
||||
using (BinaryWriter writer = new BinaryWriter(File.Open(path, FileMode.Create)))
|
||||
{
|
||||
for (int y = 0; y < VramHeight; y++)
|
||||
{
|
||||
for (int x = 0; x < VramWidth; x++)
|
||||
{
|
||||
writer.Write(packed.vramPixels[x, y].Pack());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Label("VRAM Editor", EditorStyles.boldLabel);
|
||||
GUILayout.Label("VRAM Editor", PSXEditorStyles.WindowHeader);
|
||||
GUILayout.Label("320x240, dual-buffered, vertical layout", PSXEditorStyles.InfoBox);
|
||||
|
||||
// Dropdown for resolution selection.
|
||||
selectedResolution = resolutions[EditorGUILayout.Popup("Resolution", System.Array.IndexOf(resolutions, selectedResolution), resolutionsStrings)];
|
||||
|
||||
// Check resolution constraints for dual buffering.
|
||||
bool canDBHorizontal = selectedResolution.x * 2 <= VramWidth;
|
||||
bool canDBVertical = selectedResolution.y * 2 <= VramHeight;
|
||||
|
||||
if (canDBHorizontal || canDBVertical)
|
||||
{
|
||||
dualBuffering = EditorGUILayout.Toggle("Dual Buffering", dualBuffering);
|
||||
}
|
||||
else
|
||||
{
|
||||
dualBuffering = false;
|
||||
}
|
||||
|
||||
if (canDBVertical && canDBHorizontal)
|
||||
{
|
||||
verticalLayout = EditorGUILayout.Toggle("Vertical", verticalLayout);
|
||||
}
|
||||
else if (canDBVertical)
|
||||
{
|
||||
verticalLayout = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
verticalLayout = false;
|
||||
}
|
||||
|
||||
GUILayout.Space(10);
|
||||
GUILayout.Label("Prohibited Areas", EditorStyles.boldLabel);
|
||||
GUILayout.Space(10);
|
||||
PSXEditorStyles.DrawSeparator(6, 6);
|
||||
GUILayout.Label("Prohibited Areas", PSXEditorStyles.SectionHeader);
|
||||
GUILayout.Space(4);
|
||||
|
||||
scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true, GUILayout.MinHeight(300f), GUILayout.ExpandWidth(true));
|
||||
|
||||
@@ -270,10 +215,7 @@ namespace SplashEdit.EditorCode
|
||||
{
|
||||
var area = prohibitedAreas[i];
|
||||
|
||||
GUI.backgroundColor = new Color(0.95f, 0.95f, 0.95f);
|
||||
GUILayout.BeginVertical("box");
|
||||
|
||||
GUI.backgroundColor = Color.white;
|
||||
PSXEditorStyles.BeginCard();
|
||||
|
||||
// Display fields for editing the area
|
||||
area.X = EditorGUILayout.IntField("X Coordinate", area.X);
|
||||
@@ -281,17 +223,16 @@ namespace SplashEdit.EditorCode
|
||||
area.Width = EditorGUILayout.IntField("Width", area.Width);
|
||||
area.Height = EditorGUILayout.IntField("Height", area.Height);
|
||||
|
||||
|
||||
if (GUILayout.Button("Remove", GUILayout.Height(30)))
|
||||
EditorGUILayout.Space(2);
|
||||
if (GUILayout.Button("Remove", PSXEditorStyles.DangerButton, GUILayout.Height(24)))
|
||||
{
|
||||
toRemove.Add(i); // Mark for removal
|
||||
}
|
||||
|
||||
|
||||
prohibitedAreas[i] = area;
|
||||
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.Space(10);
|
||||
PSXEditorStyles.EndCard();
|
||||
GUILayout.Space(4);
|
||||
}
|
||||
|
||||
// Remove the areas marked for deletion outside the loop to avoid skipping elements
|
||||
@@ -303,19 +244,23 @@ namespace SplashEdit.EditorCode
|
||||
GUILayout.EndScrollView();
|
||||
GUILayout.Space(10);
|
||||
|
||||
if (GUILayout.Button("Add Prohibited Area"))
|
||||
if (GUILayout.Button("Add Prohibited Area", PSXEditorStyles.SecondaryButton))
|
||||
{
|
||||
prohibitedAreas.Add(new ProhibitedArea());
|
||||
}
|
||||
|
||||
// Button to initiate texture packing.
|
||||
if (GUILayout.Button("Pack Textures"))
|
||||
PSXEditorStyles.DrawSeparator(4, 4);
|
||||
|
||||
// Button to pack and preview VRAM layout.
|
||||
if (GUILayout.Button("Pack Preview", PSXEditorStyles.PrimaryButton, GUILayout.Height(28)))
|
||||
{
|
||||
PackTextures();
|
||||
}
|
||||
|
||||
// Button to save settings; saving now occurs only on button press.
|
||||
if (GUILayout.Button("Save Settings"))
|
||||
EditorGUILayout.Space(2);
|
||||
|
||||
// Button to save prohibited areas.
|
||||
if (GUILayout.Button("Save Settings", PSXEditorStyles.SuccessButton, GUILayout.Height(28)))
|
||||
{
|
||||
_psxData.OutputResolution = selectedResolution;
|
||||
_psxData.DualBuffering = dualBuffering;
|
||||
|
||||
Reference in New Issue
Block a user