Update required file for main form

This commit is contained in:
miku-666
2022-06-25 15:36:39 +02:00
parent 58b6615fe7
commit 8d3f377415
6 changed files with 804 additions and 743 deletions

View File

@@ -14,18 +14,15 @@ namespace PckStudio.Forms
{
public partial class AddPCKPassword : MetroForm
{
PCKFile currentPCK;
PCKFile.FileData file;
public AddPCKPassword(PCKFile.FileData fileIn, PCKFile currentPCKIn)
public string Password { get; private set; }
public AddPCKPassword()
{
InitializeComponent();
file = fileIn;
currentPCK = currentPCKIn;
}
private void buttonUnlocked_Click(object sender, EventArgs e)
{
file.properties.Add(new ValueTuple<string, string>("LOCK", MD5(textBoxPass.Text)));
Password = MD5(textBoxPass.Text);
Close();
}
@@ -34,10 +31,8 @@ namespace PckStudio.Forms
using (var provider = System.Security.Cryptography.MD5.Create())
{
StringBuilder builder = new StringBuilder();
foreach (byte b in provider.ComputeHash(Encoding.UTF8.GetBytes(s)))
builder.Append(b.ToString("x2").ToLower());
return builder.ToString();
}
}

View File

@@ -56,9 +56,9 @@
//
// RenamePrompt
//
this.AcceptButton = this.OKButton;
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ControlBox = false;
this.Controls.Add(this.InputTextBox);
this.Controls.Add(this.OKButton);
this.Controls.Add(this.TextLabel);

View File

@@ -18,8 +18,6 @@ namespace PckStudio.Forms
public pckLocked(string pass)
{
this.pass = pass;
InitializeComponent();
}

View File

@@ -100,10 +100,15 @@
this.DBGLabel = new MetroFramework.Controls.MetroLabel();
this.tabControl = new MetroFramework.Controls.MetroTabControl();
this.openTab = new System.Windows.Forms.TabPage();
this.myTablePanelStartScreen = new PckStudio.Forms.MyTablePanel();
this.richTextBoxChangelog = new System.Windows.Forms.RichTextBox();
this.label5 = new MetroFramework.Controls.MetroLabel();
this.pckOpen = new System.Windows.Forms.PictureBox();
this.editorTab = new MetroFramework.Controls.MetroTabPage();
this.entryTypeTextBox = new MetroFramework.Controls.MetroTextBox();
this.buttonEdit = new MetroFramework.Controls.MetroButton();
this.labelImageSize = new MetroFramework.Controls.MetroLabel();
this.pictureBoxImagePreview = new PckStudio.PictureBoxWithInterpolationMode();
this.fileEntryCountLabel = new MetroFramework.Controls.MetroLabel();
this.entryDataTextBox = new MetroFramework.Controls.MetroTextBox();
this.metroLabel2 = new MetroFramework.Controls.MetroLabel();
@@ -116,11 +121,6 @@
this.label11 = new MetroFramework.Controls.MetroLabel();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.LittleEndianCheckBox = new MetroFramework.Controls.MetroCheckBox();
this.myTablePanelStartScreen = new PckStudio.Forms.MyTablePanel();
this.richTextBoxChangelog = new System.Windows.Forms.RichTextBox();
this.label5 = new MetroFramework.Controls.MetroLabel();
this.pckOpen = new System.Windows.Forms.PictureBox();
this.pictureBoxImagePreview = new PckStudio.PictureBoxWithInterpolationMode();
this.contextMenuPCKEntries.SuspendLayout();
this.menuStrip.SuspendLayout();
this.contextMenuMetaTree.SuspendLayout();
@@ -129,12 +129,12 @@
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
this.tabControl.SuspendLayout();
this.openTab.SuspendLayout();
this.editorTab.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.myTablePanelStartScreen.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pckOpen)).BeginInit();
this.editorTab.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxImagePreview)).BeginInit();
this.tabControl1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.SuspendLayout();
//
// contextMenuPCKEntries
@@ -210,7 +210,6 @@
//
resources.ApplyResources(this.importFileToolStripMenuItem, "importFileToolStripMenuItem");
this.importFileToolStripMenuItem.Name = "importFileToolStripMenuItem";
this.importFileToolStripMenuItem.Click += new System.EventHandler(this.importFileToolStripMenuItem_Click);
//
// extractToolStripMenuItem
//
@@ -645,6 +644,45 @@
resources.ApplyResources(this.openTab, "openTab");
this.openTab.Name = "openTab";
//
// myTablePanelStartScreen
//
this.myTablePanelStartScreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
resources.ApplyResources(this.myTablePanelStartScreen, "myTablePanelStartScreen");
this.myTablePanelStartScreen.Controls.Add(this.richTextBoxChangelog, 1, 1);
this.myTablePanelStartScreen.Controls.Add(this.label5, 1, 0);
this.myTablePanelStartScreen.Controls.Add(this.pckOpen, 0, 0);
this.myTablePanelStartScreen.Name = "myTablePanelStartScreen";
//
// richTextBoxChangelog
//
this.richTextBoxChangelog.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(28)))), ((int)(((byte)(28)))));
this.richTextBoxChangelog.BorderStyle = System.Windows.Forms.BorderStyle.None;
resources.ApplyResources(this.richTextBoxChangelog, "richTextBoxChangelog");
this.richTextBoxChangelog.ForeColor = System.Drawing.Color.White;
this.richTextBoxChangelog.Name = "richTextBoxChangelog";
this.richTextBoxChangelog.ReadOnly = true;
//
// label5
//
resources.ApplyResources(this.label5, "label5");
this.label5.ForeColor = System.Drawing.Color.White;
this.label5.Name = "label5";
this.label5.Theme = MetroFramework.MetroThemeStyle.Dark;
//
// pckOpen
//
this.pckOpen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
resources.ApplyResources(this.pckOpen, "pckOpen");
this.pckOpen.Name = "pckOpen";
this.myTablePanelStartScreen.SetRowSpan(this.pckOpen, 2);
this.pckOpen.TabStop = false;
this.pckOpen.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
this.pckOpen.DragDrop += new System.Windows.Forms.DragEventHandler(this.OpenPck_DragDrop);
this.pckOpen.DragEnter += new System.Windows.Forms.DragEventHandler(this.OpenPck_DragEnter);
this.pckOpen.DragLeave += new System.EventHandler(this.OpenPck_DragLeave);
this.pckOpen.MouseEnter += new System.EventHandler(this.OpenPck_MouseEnter);
this.pckOpen.MouseLeave += new System.EventHandler(this.OpenPck_MouseLeave);
//
// editorTab
//
this.editorTab.BackColor = System.Drawing.Color.Transparent;
@@ -714,6 +752,14 @@
this.labelImageSize.Name = "labelImageSize";
this.labelImageSize.Theme = MetroFramework.MetroThemeStyle.Dark;
//
// pictureBoxImagePreview
//
resources.ApplyResources(this.pictureBoxImagePreview, "pictureBoxImagePreview");
this.pictureBoxImagePreview.Image = global::PckStudio.Properties.Resources.NoImageFound;
this.pictureBoxImagePreview.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
this.pictureBoxImagePreview.Name = "pictureBoxImagePreview";
this.pictureBoxImagePreview.TabStop = false;
//
// fileEntryCountLabel
//
resources.ApplyResources(this.fileEntryCountLabel, "fileEntryCountLabel");
@@ -825,53 +871,6 @@
this.LittleEndianCheckBox.Theme = MetroFramework.MetroThemeStyle.Dark;
this.LittleEndianCheckBox.UseSelectable = true;
//
// myTablePanelStartScreen
//
this.myTablePanelStartScreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
resources.ApplyResources(this.myTablePanelStartScreen, "myTablePanelStartScreen");
this.myTablePanelStartScreen.Controls.Add(this.richTextBoxChangelog, 1, 1);
this.myTablePanelStartScreen.Controls.Add(this.label5, 1, 0);
this.myTablePanelStartScreen.Controls.Add(this.pckOpen, 0, 0);
this.myTablePanelStartScreen.Name = "myTablePanelStartScreen";
//
// richTextBoxChangelog
//
this.richTextBoxChangelog.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(28)))), ((int)(((byte)(28)))));
this.richTextBoxChangelog.BorderStyle = System.Windows.Forms.BorderStyle.None;
resources.ApplyResources(this.richTextBoxChangelog, "richTextBoxChangelog");
this.richTextBoxChangelog.ForeColor = System.Drawing.Color.White;
this.richTextBoxChangelog.Name = "richTextBoxChangelog";
this.richTextBoxChangelog.ReadOnly = true;
//
// label5
//
resources.ApplyResources(this.label5, "label5");
this.label5.ForeColor = System.Drawing.Color.White;
this.label5.Name = "label5";
this.label5.Theme = MetroFramework.MetroThemeStyle.Dark;
//
// pckOpen
//
this.pckOpen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
resources.ApplyResources(this.pckOpen, "pckOpen");
this.pckOpen.Name = "pckOpen";
this.myTablePanelStartScreen.SetRowSpan(this.pckOpen, 2);
this.pckOpen.TabStop = false;
this.pckOpen.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
this.pckOpen.DragDrop += new System.Windows.Forms.DragEventHandler(this.OpenPck_DragDrop);
this.pckOpen.DragEnter += new System.Windows.Forms.DragEventHandler(this.OpenPck_DragEnter);
this.pckOpen.DragLeave += new System.EventHandler(this.OpenPck_DragLeave);
this.pckOpen.MouseEnter += new System.EventHandler(this.OpenPck_MouseEnter);
this.pckOpen.MouseLeave += new System.EventHandler(this.OpenPck_MouseLeave);
//
// pictureBoxImagePreview
//
resources.ApplyResources(this.pictureBoxImagePreview, "pictureBoxImagePreview");
this.pictureBoxImagePreview.Image = global::PckStudio.Properties.Resources.NoImageFound;
this.pictureBoxImagePreview.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
this.pictureBoxImagePreview.Name = "pictureBoxImagePreview";
this.pictureBoxImagePreview.TabStop = false;
//
// FormMain
//
this.ApplyImageInvert = true;
@@ -904,14 +903,14 @@
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
this.tabControl.ResumeLayout(false);
this.openTab.ResumeLayout(false);
this.editorTab.ResumeLayout(false);
this.editorTab.PerformLayout();
this.tabControl1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.myTablePanelStartScreen.ResumeLayout(false);
this.myTablePanelStartScreen.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pckOpen)).EndInit();
this.editorTab.ResumeLayout(false);
this.editorTab.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxImagePreview)).EndInit();
this.tabControl1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();

View File

@@ -23,9 +23,8 @@ namespace PckStudio
public partial class FormMain : MetroFramework.Forms.MetroForm
{
string saveLocation = string.Empty;
string PCKFilePath = "";
string PCKFileBCKUP = "x";
PCKFile currentPCK;
//string PCKFileBCKUP = "x";
PCKFile currentPCK = null;
bool needsUpdate = false;
bool saved = true;
bool isTemplateFile = false;
@@ -484,42 +483,12 @@ namespace PckStudio
{
if (ofd.ShowDialog() == DialogResult.OK)
{
PCKFile.FileData mf = new PCKFile.FileData(Path.GetFileName(ofd.FileName), 0);
mf.SetData(File.ReadAllBytes(ofd.FileName));
TreeNode add = new TreeNode(mf.name) { Tag = mf };
PCKFile.FileData newFile = new PCKFile.FileData(ofd.SafeFileName, 0);
newFile.SetData(File.ReadAllBytes(ofd.FileName));
//Gets proper file icon for minefile
if (Path.GetExtension(add.Text) == ".binka")
if (treeViewMain.SelectedNode.Tag == null) // Detects if user selected a folder to add file to
{
add.ImageIndex = 1;
add.SelectedImageIndex = 1;
}
else if (Path.GetExtension(add.Text) == ".png")
{
add.ImageIndex = 2;
add.SelectedImageIndex = 2;
}
else if (Path.GetExtension(add.Text) == ".loc")
{
add.ImageIndex = 3;
add.SelectedImageIndex = 3;
}
else if (Path.GetExtension(add.Text) == ".pck")
{
add.ImageIndex = 4;
add.SelectedImageIndex = 4;
}
else
{
add.ImageIndex = 5;
add.SelectedImageIndex = 5;
}
if (treeViewMain.SelectedNode.Tag == null) //Detects if user selected a folder to add file to
{
treeViewMain.SelectedNode.Nodes.Add(add);//adds generated minefile node to selected folder
currentPCK.file_entries.Insert(treeViewMain.SelectedNode.Nodes.Count - 1, mf);//inserts minefile into proper list index
currentPCK.file_entries.Insert(treeViewMain.SelectedNode.Nodes.Count - 1, newFile);//inserts minefile into proper list index
string itemPath = "";//item path template
List<TreeNode> path = new List<TreeNode>();//directory template
GetPathToRoot(treeViewMain.SelectedNode, path);//gets all parents nodes
@@ -529,22 +498,22 @@ namespace PckStudio
itemPath += dire.Text + "/";
}
currentPCK.file_entries[treeViewMain.SelectedNode.Nodes.Count - 1].name = itemPath + treeViewMain.SelectedNode.Nodes[treeViewMain.SelectedNode.Nodes.Count - 1].Text;//updates minefile name with directory
// updates minefile name with directory
currentPCK.file_entries[treeViewMain.SelectedNode.Nodes.Count - 1].name = itemPath + treeViewMain.SelectedNode.Nodes[treeViewMain.SelectedNode.Nodes.Count - 1].Text;
}
else //adds minefile to root of the pck
{
currentPCK.file_entries.Add(mf);
treeViewMain.Nodes.Add(add);
currentPCK.file_entries.Add(newFile);
}
saved = false;
}
}
saved = false;
}
private void GetPathToRoot(TreeNode node, List<TreeNode> path)
{
//gets all parents nodes of a file
// gets all parents nodes of a file
if (node == null) return; // previous node was the root.
else
{
@@ -628,7 +597,6 @@ namespace PckStudio
{
ofd.Filter = "PNG Files | *.png";
ofd.Title = "Select a PNG File";
if (ofd.ShowDialog() == DialogResult.OK)
{
try
@@ -665,7 +633,7 @@ namespace PckStudio
}
var locedit = new LOCEditor(l);
locedit.ShowDialog(this);
if (locedit.wasModified)
if (locedit.WasModified)
{
using (var stream = new MemoryStream())
{
@@ -883,7 +851,6 @@ namespace PckStudio
// Check the parent node of the second node.
if (node2.Parent == null) return false;
if (node2.Parent.Equals(node1)) return true;
// If the parent node is not null or equal to the first node,
// call the ContainsNode method recursively using the parent of
// the second node.
@@ -933,9 +900,9 @@ namespace PckStudio
currentPCK.file_entries.Add(loc);
}
private void InitializeTexturePack()
private void InitializeTexturePack(int packId, int packVersion, string packName)
{
InitializeSkinPack(0, 0, "no_name");
InitializeSkinPack(packId, packVersion, packName);
currentPCK.meta_data.Add("DATAPATH");
var texturepackInfo = new PCKFile.FileData("x16/x16Info.pck", 5);
texturepackInfo.properties.Add(("PACKID", "0"));
@@ -1339,8 +1306,8 @@ namespace PckStudio
mfNew.SetData(data);
string[] txtProperties = File.ReadAllText(contents.FileName).Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
LOCFile locFile = null;
if (txtProperties.Contains("DISPLAYNAMEID") && txtProperties.Contains("DISPLAYNAME") ||
txtProperties.Contains("THEMENAMEID") && txtProperties.Contains("THEMENAME") &&
if ((txtProperties.Contains("DISPLAYNAMEID") && txtProperties.Contains("DISPLAYNAME")) ||
(txtProperties.Contains("THEMENAMEID") && txtProperties.Contains("THEMENAME")) &&
TryGetLocFile(out locFile))
{
// do stuff

File diff suppressed because it is too large Load Diff