JD2022-TU1/main/tools/legacy/ResourceTools/ResourceTools.cs

1570 lines
64 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Collections;
using System.Security.Permissions;
using System.Threading;
using System.IO;
using System.Runtime.InteropServices;
using System.Diagnostics;
using PluginCommon;
using System.Media;
using System.Xml.Serialization;
using System.Xml;
using P4API;
namespace ResourceTools
{
public partial class ResourceTools : Form
{
/**** Perforce ****/
static public P4Connection p4 = null;
static public PerforceConfig p4Cfg = null;
static public bool isP4Connected = false;
/*****************/
readonly string ResourceType_All = "ResourceType_All";
private pluginWrapper m_plugin = null;
private engineWrapper m_engine = null;
private Queue<blobWrapper> m_blobQueue = new Queue<blobWrapper>();
private bool m_connected = false;
private bool m_updateConnectionStatus = false;
private string m_currentFileWorking = "";
private string m_platform = "None";
private bool m_updatePlatform = false;
private Thread m_thread = null;
private bool m_running = false;
readonly string m_savingPath = "coreConfig/configPlugin/";
string m_configFile;
string m_configFileUserApplication;
String IPAdress = "127.0.0.1";
private System.Windows.Forms.Timer timerUpdate;
private IContainer components;
private Button btnRefresh;
private ITFDataGridView dataGridViewResource;
private CheckBox checkBoxLoaded;
private ComboBox comboBoxIP;
private Button btnConnect;
private TextBox textLoadingTime;
private bool m_updateGrid = false;
private GroupBox resourceDetails;
private Button btnRecook;
private TextBox textBoxTextureMemory;
private PropertyGrid propertyGridResource;
private CheckBox checkBoxPS3;
private CheckBox checkBoxXBox360;
private CheckBox checkBoxCAFE;
private CheckBox checkBoxPC;
private String m_workingDirectory = "";
private TextureFileConfig m_currentTextureFileConfig = null;
private Button btnSave;
private TextBox textBoxWorkingDirectory;
private Button btnSelectWorkingDirectory;
private CheckBox checkBoxWII;
private PictureBox pictureResource;
private ComboBox comboBoxResourceType;
private Label ResourcesCountSelected;
private Label ResourcesCountGlobal;
private Label m_emulationLabel;
private DataGridViewTextBoxColumn NameColumn;
private DataGridViewTextBoxColumn TypeColumn;
private DataGridViewTextBoxColumn TimeToLoadColumn;
private DataGridViewTextBoxColumn LoadedColumn;
private DataGridViewTextBoxColumn MemoryColumn;
private DataGridViewTextBoxColumn CustomInfoColumn;
private DataGridViewTextBoxColumn PathColumn;
private GroupBox groupBox1;
public Button button_P4Connect;
public Label label_P4Status;
Hashtable m_applicationHash = new Hashtable();
private Button dump;
string m_dataRootPath;
public class ITFDataGridView : DataGridView
{
public ITFDataGridView()
{
this.SetStyle(ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint |
ControlStyles.DoubleBuffer |
ControlStyles.ResizeRedraw, true);
}
}
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.Label label1;
System.Windows.Forms.Label label2;
System.Windows.Forms.Label label3;
System.Windows.Forms.Label label4;
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
this.m_emulationLabel = new System.Windows.Forms.Label();
this.timerUpdate = new System.Windows.Forms.Timer(this.components);
this.btnRefresh = new System.Windows.Forms.Button();
this.dataGridViewResource = new ResourceTools.ITFDataGridView();
this.NameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.TypeColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.TimeToLoadColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.LoadedColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.MemoryColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.CustomInfoColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.PathColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.checkBoxLoaded = new System.Windows.Forms.CheckBox();
this.comboBoxIP = new System.Windows.Forms.ComboBox();
this.btnConnect = new System.Windows.Forms.Button();
this.textLoadingTime = new System.Windows.Forms.TextBox();
this.resourceDetails = new System.Windows.Forms.GroupBox();
this.checkBoxWII = new System.Windows.Forms.CheckBox();
this.btnSave = new System.Windows.Forms.Button();
this.checkBoxPS3 = new System.Windows.Forms.CheckBox();
this.checkBoxXBox360 = new System.Windows.Forms.CheckBox();
this.checkBoxCAFE = new System.Windows.Forms.CheckBox();
this.checkBoxPC = new System.Windows.Forms.CheckBox();
this.propertyGridResource = new System.Windows.Forms.PropertyGrid();
this.btnRecook = new System.Windows.Forms.Button();
this.textBoxTextureMemory = new System.Windows.Forms.TextBox();
this.textBoxWorkingDirectory = new System.Windows.Forms.TextBox();
this.btnSelectWorkingDirectory = new System.Windows.Forms.Button();
this.pictureResource = new System.Windows.Forms.PictureBox();
this.comboBoxResourceType = new System.Windows.Forms.ComboBox();
this.ResourcesCountSelected = new System.Windows.Forms.Label();
this.ResourcesCountGlobal = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label_P4Status = new System.Windows.Forms.Label();
this.button_P4Connect = new System.Windows.Forms.Button();
this.dump = new System.Windows.Forms.Button();
label1 = new System.Windows.Forms.Label();
label2 = new System.Windows.Forms.Label();
label3 = new System.Windows.Forms.Label();
label4 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dataGridViewResource)).BeginInit();
this.resourceDetails.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureResource)).BeginInit();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// label1
//
label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
label1.AutoSize = true;
label1.Location = new System.Drawing.Point(10, 425);
label1.Name = "label1";
label1.Size = new System.Drawing.Size(54, 13);
label1.TabIndex = 7;
label1.Text = "LoadTime";
//
// label2
//
label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
label2.AutoSize = true;
label2.Location = new System.Drawing.Point(151, 425);
label2.Name = "label2";
label2.Size = new System.Drawing.Size(20, 13);
label2.TabIndex = 9;
label2.Text = "ms";
//
// label3
//
label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
label3.AutoSize = true;
label3.Location = new System.Drawing.Point(10, 448);
label3.Name = "label3";
label3.Size = new System.Drawing.Size(83, 13);
label3.TabIndex = 12;
label3.Text = "Texture Memory";
//
// label4
//
label4.AutoSize = true;
label4.Location = new System.Drawing.Point(309, 10);
label4.Name = "label4";
label4.Size = new System.Drawing.Size(63, 13);
label4.TabIndex = 16;
label4.Text = "Working Dir";
//
// m_emulationLabel
//
this.m_emulationLabel.AutoSize = true;
this.m_emulationLabel.Location = new System.Drawing.Point(854, 11);
this.m_emulationLabel.Name = "m_emulationLabel";
this.m_emulationLabel.Size = new System.Drawing.Size(85, 13);
this.m_emulationLabel.TabIndex = 24;
this.m_emulationLabel.Text = "Emulation: None";
//
// timerUpdate
//
this.timerUpdate.Tick += new System.EventHandler(this.timerUpdate_Tick);
//
// btnRefresh
//
this.btnRefresh.Location = new System.Drawing.Point(580, 6);
this.btnRefresh.Name = "btnRefresh";
this.btnRefresh.Size = new System.Drawing.Size(57, 23);
this.btnRefresh.TabIndex = 0;
this.btnRefresh.Text = "Refresh";
this.btnRefresh.UseVisualStyleBackColor = true;
this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click);
//
// dataGridViewResource
//
this.dataGridViewResource.AllowUserToAddRows = false;
this.dataGridViewResource.AllowUserToDeleteRows = false;
this.dataGridViewResource.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridViewResource.BackgroundColor = System.Drawing.SystemColors.ActiveCaption;
this.dataGridViewResource.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.Sunken;
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dataGridViewResource.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
this.dataGridViewResource.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridViewResource.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.NameColumn,
this.TypeColumn,
this.TimeToLoadColumn,
this.LoadedColumn,
this.MemoryColumn,
this.CustomInfoColumn,
this.PathColumn});
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dataGridViewResource.DefaultCellStyle = dataGridViewCellStyle2;
this.dataGridViewResource.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
this.dataGridViewResource.Location = new System.Drawing.Point(12, 35);
this.dataGridViewResource.MultiSelect = false;
this.dataGridViewResource.Name = "dataGridViewResource";
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dataGridViewResource.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
this.dataGridViewResource.Size = new System.Drawing.Size(921, 381);
this.dataGridViewResource.TabIndex = 3;
this.dataGridViewResource.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridViewResource_CellClick);
this.dataGridViewResource.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridViewResource_CellContentClick);
this.dataGridViewResource.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridViewResource_CellDoubleClick);
this.dataGridViewResource.CellEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridViewResource_CellEnter);
this.dataGridViewResource.CellMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridViewResource_CellMouseClick);
//
// NameColumn
//
this.NameColumn.HeaderText = "Name";
this.NameColumn.Name = "NameColumn";
this.NameColumn.ReadOnly = true;
this.NameColumn.Width = 140;
//
// TypeColumn
//
this.TypeColumn.HeaderText = "Type";
this.TypeColumn.Name = "TypeColumn";
this.TypeColumn.ReadOnly = true;
//
// TimeToLoadColumn
//
this.TimeToLoadColumn.HeaderText = "TimeToLoad ms";
this.TimeToLoadColumn.Name = "TimeToLoadColumn";
this.TimeToLoadColumn.ReadOnly = true;
this.TimeToLoadColumn.ToolTipText = "Time to load this resource in milliseconds";
//
// LoadedColumn
//
this.LoadedColumn.HeaderText = "Loaded";
this.LoadedColumn.Name = "LoadedColumn";
this.LoadedColumn.ReadOnly = true;
//
// MemoryColumn
//
this.MemoryColumn.HeaderText = "MemoryUsage Kb";
this.MemoryColumn.Name = "MemoryColumn";
this.MemoryColumn.ReadOnly = true;
//
// CustomInfoColumn
//
this.CustomInfoColumn.HeaderText = "Info";
this.CustomInfoColumn.Name = "CustomInfoColumn";
this.CustomInfoColumn.ReadOnly = true;
this.CustomInfoColumn.Width = 150;
//
// PathColumn
//
this.PathColumn.HeaderText = "Path";
this.PathColumn.Name = "PathColumn";
this.PathColumn.ReadOnly = true;
this.PathColumn.Width = 200;
//
// checkBoxLoaded
//
this.checkBoxLoaded.AutoSize = true;
this.checkBoxLoaded.Checked = true;
this.checkBoxLoaded.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxLoaded.Location = new System.Drawing.Point(12, 9);
this.checkBoxLoaded.Name = "checkBoxLoaded";
this.checkBoxLoaded.Size = new System.Drawing.Size(84, 17);
this.checkBoxLoaded.TabIndex = 4;
this.checkBoxLoaded.Text = "only Loaded";
this.checkBoxLoaded.UseVisualStyleBackColor = true;
this.checkBoxLoaded.CheckedChanged += new System.EventHandler(this.checkBoxLoaded_CheckedChanged);
//
// comboBoxIP
//
this.comboBoxIP.FormattingEnabled = true;
this.comboBoxIP.Location = new System.Drawing.Point(643, 8);
this.comboBoxIP.Name = "comboBoxIP";
this.comboBoxIP.Size = new System.Drawing.Size(138, 21);
this.comboBoxIP.TabIndex = 5;
//
// btnConnect
//
this.btnConnect.Location = new System.Drawing.Point(787, 6);
this.btnConnect.Name = "btnConnect";
this.btnConnect.Size = new System.Drawing.Size(61, 23);
this.btnConnect.TabIndex = 6;
this.btnConnect.Text = "Connect";
this.btnConnect.UseVisualStyleBackColor = true;
this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click);
//
// textLoadingTime
//
this.textLoadingTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.textLoadingTime.Location = new System.Drawing.Point(74, 422);
this.textLoadingTime.Name = "textLoadingTime";
this.textLoadingTime.ReadOnly = true;
this.textLoadingTime.Size = new System.Drawing.Size(71, 20);
this.textLoadingTime.TabIndex = 8;
//
// resourceDetails
//
this.resourceDetails.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.resourceDetails.Controls.Add(this.checkBoxWII);
this.resourceDetails.Controls.Add(this.btnSave);
this.resourceDetails.Controls.Add(this.checkBoxPS3);
this.resourceDetails.Controls.Add(this.checkBoxXBox360);
this.resourceDetails.Controls.Add(this.checkBoxCAFE);
this.resourceDetails.Controls.Add(this.checkBoxPC);
this.resourceDetails.Controls.Add(this.propertyGridResource);
this.resourceDetails.Controls.Add(this.btnRecook);
this.resourceDetails.Location = new System.Drawing.Point(270, 422);
this.resourceDetails.Name = "resourceDetails";
this.resourceDetails.Size = new System.Drawing.Size(395, 256);
this.resourceDetails.TabIndex = 11;
this.resourceDetails.TabStop = false;
this.resourceDetails.Text = "Resource Details";
//
// checkBoxWII
//
this.checkBoxWII.AutoSize = true;
this.checkBoxWII.Checked = true;
this.checkBoxWII.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxWII.Location = new System.Drawing.Point(271, 92);
this.checkBoxWII.Name = "checkBoxWII";
this.checkBoxWII.Size = new System.Drawing.Size(43, 17);
this.checkBoxWII.TabIndex = 8;
this.checkBoxWII.Text = "WII";
this.checkBoxWII.UseVisualStyleBackColor = true;
this.checkBoxWII.CheckedChanged += new System.EventHandler(this.checkBoxWII_CheckedChanged);
//
// btnSave
//
this.btnSave.Enabled = false;
this.btnSave.Location = new System.Drawing.Point(6, 226);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(45, 23);
this.btnSave.TabIndex = 6;
this.btnSave.Text = "Save";
this.btnSave.UseVisualStyleBackColor = true;
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// checkBoxPS3
//
this.checkBoxPS3.AutoSize = true;
this.checkBoxPS3.Checked = true;
this.checkBoxPS3.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxPS3.Location = new System.Drawing.Point(271, 69);
this.checkBoxPS3.Name = "checkBoxPS3";
this.checkBoxPS3.Size = new System.Drawing.Size(46, 17);
this.checkBoxPS3.TabIndex = 5;
this.checkBoxPS3.Text = "PS3";
this.checkBoxPS3.UseVisualStyleBackColor = true;
this.checkBoxPS3.CheckedChanged += new System.EventHandler(this.checkBoxPS3_CheckedChanged);
//
// checkBoxXBox360
//
this.checkBoxXBox360.AutoSize = true;
this.checkBoxXBox360.Checked = true;
this.checkBoxXBox360.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxXBox360.Location = new System.Drawing.Point(271, 44);
this.checkBoxXBox360.Name = "checkBoxXBox360";
this.checkBoxXBox360.Size = new System.Drawing.Size(51, 17);
this.checkBoxXBox360.TabIndex = 4;
this.checkBoxXBox360.Text = "X360";
this.checkBoxXBox360.UseVisualStyleBackColor = true;
this.checkBoxXBox360.CheckedChanged += new System.EventHandler(this.checkBoxXBox360_CheckedChanged);
//
// checkBoxCAFE
//
this.checkBoxCAFE.AutoSize = true;
this.checkBoxCAFE.Checked = true;
this.checkBoxCAFE.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxCAFE.Location = new System.Drawing.Point(271, 114);
this.checkBoxCAFE.Name = "checkBoxCAFE";
this.checkBoxCAFE.Size = new System.Drawing.Size(53, 17);
this.checkBoxCAFE.TabIndex = 4;
this.checkBoxCAFE.Text = "CAFE";
this.checkBoxCAFE.UseVisualStyleBackColor = true;
this.checkBoxCAFE.CheckedChanged += new System.EventHandler(this.checkBoxCAFE_CheckedChanged);
//
// checkBoxPC
//
this.checkBoxPC.AutoSize = true;
this.checkBoxPC.Checked = true;
this.checkBoxPC.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxPC.Location = new System.Drawing.Point(271, 21);
this.checkBoxPC.Name = "checkBoxPC";
this.checkBoxPC.Size = new System.Drawing.Size(40, 17);
this.checkBoxPC.TabIndex = 3;
this.checkBoxPC.Text = "PC";
this.checkBoxPC.UseVisualStyleBackColor = true;
this.checkBoxPC.CheckedChanged += new System.EventHandler(this.checkBoxPC_CheckedChanged);
//
// propertyGridResource
//
this.propertyGridResource.HelpVisible = false;
this.propertyGridResource.Location = new System.Drawing.Point(6, 22);
this.propertyGridResource.Name = "propertyGridResource";
this.propertyGridResource.Size = new System.Drawing.Size(259, 198);
this.propertyGridResource.TabIndex = 2;
this.propertyGridResource.ToolbarVisible = false;
//
// btnRecook
//
this.btnRecook.Enabled = false;
this.btnRecook.Location = new System.Drawing.Point(57, 226);
this.btnRecook.Name = "btnRecook";
this.btnRecook.Size = new System.Drawing.Size(59, 23);
this.btnRecook.TabIndex = 1;
this.btnRecook.Text = "Recook";
this.btnRecook.UseVisualStyleBackColor = true;
this.btnRecook.Click += new System.EventHandler(this.btnRecook_Click);
//
// textBoxTextureMemory
//
this.textBoxTextureMemory.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.textBoxTextureMemory.ForeColor = System.Drawing.Color.Red;
this.textBoxTextureMemory.Location = new System.Drawing.Point(103, 445);
this.textBoxTextureMemory.Name = "textBoxTextureMemory";
this.textBoxTextureMemory.ReadOnly = true;
this.textBoxTextureMemory.Size = new System.Drawing.Size(100, 20);
this.textBoxTextureMemory.TabIndex = 13;
//
// textBoxWorkingDirectory
//
this.textBoxWorkingDirectory.Location = new System.Drawing.Point(378, 6);
this.textBoxWorkingDirectory.Name = "textBoxWorkingDirectory";
this.textBoxWorkingDirectory.Size = new System.Drawing.Size(165, 20);
this.textBoxWorkingDirectory.TabIndex = 15;
this.textBoxWorkingDirectory.TextChanged += new System.EventHandler(this.textBoxWorkingDirectory_TextChanged);
//
// btnSelectWorkingDirectory
//
this.btnSelectWorkingDirectory.Location = new System.Drawing.Point(549, 6);
this.btnSelectWorkingDirectory.Name = "btnSelectWorkingDirectory";
this.btnSelectWorkingDirectory.Size = new System.Drawing.Size(25, 23);
this.btnSelectWorkingDirectory.TabIndex = 17;
this.btnSelectWorkingDirectory.Text = "...";
this.btnSelectWorkingDirectory.UseVisualStyleBackColor = true;
this.btnSelectWorkingDirectory.Click += new System.EventHandler(this.btnSelectWorkingDirectory_Click);
//
// pictureResource
//
this.pictureResource.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.pictureResource.Location = new System.Drawing.Point(677, 422);
this.pictureResource.Name = "pictureResource";
this.pictureResource.Size = new System.Drawing.Size(256, 256);
this.pictureResource.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureResource.TabIndex = 19;
this.pictureResource.TabStop = false;
//
// comboBoxResourceType
//
this.comboBoxResourceType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxResourceType.FormattingEnabled = true;
this.comboBoxResourceType.Location = new System.Drawing.Point(102, 5);
this.comboBoxResourceType.Name = "comboBoxResourceType";
this.comboBoxResourceType.Size = new System.Drawing.Size(201, 21);
this.comboBoxResourceType.TabIndex = 20;
this.comboBoxResourceType.SelectedIndexChanged += new System.EventHandler(this.comboBoxResourceType_SelectedIndexChanged);
//
// ResourcesCountSelected
//
this.ResourcesCountSelected.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.ResourcesCountSelected.AutoSize = true;
this.ResourcesCountSelected.Location = new System.Drawing.Point(10, 468);
this.ResourcesCountSelected.Name = "ResourcesCountSelected";
this.ResourcesCountSelected.Size = new System.Drawing.Size(0, 13);
this.ResourcesCountSelected.TabIndex = 25;
//
// ResourcesCountGlobal
//
this.ResourcesCountGlobal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.ResourcesCountGlobal.AutoSize = true;
this.ResourcesCountGlobal.Location = new System.Drawing.Point(10, 489);
this.ResourcesCountGlobal.Name = "ResourcesCountGlobal";
this.ResourcesCountGlobal.Size = new System.Drawing.Size(0, 13);
this.ResourcesCountGlobal.TabIndex = 26;
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.groupBox1.Controls.Add(this.label_P4Status);
this.groupBox1.Controls.Add(this.button_P4Connect);
this.groupBox1.Location = new System.Drawing.Point(4, 523);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(260, 95);
this.groupBox1.TabIndex = 27;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Perforce";
//
// label_P4Status
//
this.label_P4Status.AutoSize = true;
this.label_P4Status.Location = new System.Drawing.Point(10, 19);
this.label_P4Status.Name = "label_P4Status";
this.label_P4Status.Size = new System.Drawing.Size(43, 13);
this.label_P4Status.TabIndex = 10;
this.label_P4Status.Text = "Status: ";
//
// button_P4Connect
//
this.button_P4Connect.Location = new System.Drawing.Point(128, 53);
this.button_P4Connect.Name = "button_P4Connect";
this.button_P4Connect.Size = new System.Drawing.Size(126, 36);
this.button_P4Connect.TabIndex = 9;
this.button_P4Connect.Text = "Reconnect";
this.button_P4Connect.UseVisualStyleBackColor = true;
this.button_P4Connect.Click += new System.EventHandler(this.button_P4Connect_Click);
//
// dump
//
this.dump.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.dump.Location = new System.Drawing.Point(12, 648);
this.dump.Name = "dump";
this.dump.Size = new System.Drawing.Size(75, 23);
this.dump.TabIndex = 28;
this.dump.Text = "Dump";
this.dump.UseVisualStyleBackColor = true;
this.dump.Click += new System.EventHandler(this.button_DumpClick);
//
// ResourceTools
//
this.ClientSize = new System.Drawing.Size(955, 690);
this.Controls.Add(this.dump);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.ResourcesCountGlobal);
this.Controls.Add(this.ResourcesCountSelected);
this.Controls.Add(this.m_emulationLabel);
this.Controls.Add(this.comboBoxResourceType);
this.Controls.Add(this.pictureResource);
this.Controls.Add(this.btnSelectWorkingDirectory);
this.Controls.Add(label4);
this.Controls.Add(this.textBoxWorkingDirectory);
this.Controls.Add(this.textBoxTextureMemory);
this.Controls.Add(label3);
this.Controls.Add(this.resourceDetails);
this.Controls.Add(label2);
this.Controls.Add(this.textLoadingTime);
this.Controls.Add(label1);
this.Controls.Add(this.btnConnect);
this.Controls.Add(this.comboBoxIP);
this.Controls.Add(this.checkBoxLoaded);
this.Controls.Add(this.dataGridViewResource);
this.Controls.Add(this.btnRefresh);
this.DoubleBuffered = true;
this.Name = "ResourceTools";
this.Text = " UA_ResourceTool";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ResourceTools_FormClosing);
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.ResourceTools_FormClosed);
this.Load += new System.EventHandler(this.ResourceTools_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridViewResource)).EndInit();
this.resourceDetails.ResumeLayout(false);
this.resourceDetails.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureResource)).EndInit();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
EngineSettings engineSettings = null;
public ResourceTools(string[] args)
{
CommandLineArgs cmdArgs = new CommandLineArgs(args);
engineSettings = new EngineSettings(cmdArgs);
InitializeComponent();
if (engineSettings.isClientRectValid())
{
engineSettings.applyToForm(this);
}
engineSettings.applyCurrentDirectory();
comboBoxResourceType.Items.Add(ResourceType_All);
comboBoxResourceType.SelectedIndex = 0;
m_configFile = m_savingPath + "resourcetools.xml";
m_configFileUserApplication = m_savingPath + "resourcetoolsApplicationUser.xml";
if (File.Exists(m_configFile))
{
loadConfigurationConnection();
loadUserInfo();
}
else
{
comboBoxIP.Items.Add(IPAdress);
comboBoxIP.SelectedIndex = 0;
saveConfigurationConnection();
}
m_engine = new engineWrapper("");
Text = "ResourceTools [Disconnected]";
CultureInfo tmp_ci = (CultureInfo)CultureInfo.CurrentCulture.Clone();
tmp_ci.NumberFormat.NumberDecimalSeparator = ".";
System.Threading.Thread.CurrentThread.CurrentCulture = tmp_ci;
timerUpdate.Start();
m_thread = new Thread(new ThreadStart(this.ThreadTask));
m_thread.IsBackground = true;
m_thread.Start();
}
private void ConnectToPerforce()
{
p4Cfg = new PerforceConfig();
p4 = new P4Connection();
PerforceUtils.dataRootPath = m_dataRootPath;
PerforceUtils.LoadP4Config();
p4.Connect();
PerforceUtils.Connect();
if (isP4Connected)
{
label_P4Status.Text = "Status: connected";
button_P4Connect.Enabled = false;
}
else
{
label_P4Status.Text = "Status: not connected";
button_P4Connect.Enabled = true;
}
}
protected void addResourceTypeToCombo(string resourceType)
{
foreach (string type in comboBoxResourceType.Items)
{
if (type == resourceType)
return;
}
comboBoxResourceType.Items.Add(resourceType);
}
private string makeTFIFilename(string src)
{
return src + ".tfi";
}
private string normalizeWorkingDirectory(string src)
{
if (src.Length >= 1)
{
string normalized = src.Normalize();
if (!normalized.EndsWith("\\"))
normalized+="\\";
return normalized;
}
return "";
}
private void recordIP(String _ipToRecord)
{
bool changed = true;
foreach (string ip in comboBoxIP.Items)
{
if (ip == _ipToRecord)
{
changed = false;
break;
}
}
if (changed)
{
comboBoxIP.Items.Add(_ipToRecord);
comboBoxIP.SelectedIndex = comboBoxIP.Items.Count - 1;
}
saveConfigurationConnection();
}
private void updateConnectedStatus()
{
bool connected = m_connected;
if (connected)
{
blobWrapper blob = new blobWrapper();
connected = blob.sendToHost();
}
if (!connected)
{
if (m_connected)
{
m_engine.disconnect();
m_plugin = null;
}
lock (IPAdress)
{
connected = m_engine.connectToHost(IPAdress, engineSettings.Port);
}
if (connected)
{
m_plugin = new pluginWrapper();
m_engine.addPlugin("ResourceTools_Plugin", m_plugin);
blobWrapper blob = new blobWrapper();
blob.push("PluginId");
blob.push("ResourceTools_Plugin");
blob.sendToHost();
blob = new blobWrapper();
blob.push("ResourceTools_Plugin");
blob.push("init");
blob.sendToHost();
}
}
if (connected != m_connected)
{
lock (this)
{
m_connected = connected;
if (!m_connected)
setPlatform("None");
m_updateConnectionStatus = true;
resfresh(ResourceType_All);
}
}
}
readonly int timeSleep = 50;
protected void execute(string exePath, string arguments, int timeout)
{
ProcessStartInfo startInfo = new ProcessStartInfo(exePath);
startInfo.Arguments = arguments;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process process = Process.Start(startInfo);
int timeElapsed = 0;
while (process.HasExited != true)
{
Thread.Sleep(timeSleep);
timeElapsed += timeSleep;
if (timeElapsed >= timeout)
break;
}
}
private void timerUpdate_Tick(object sender, EventArgs e)
{
if (m_updateConnectionStatus)
{
lock (this)
{
m_updateConnectionStatus = false;
if (m_connected)
{
Text = "ResourceTools [Connected]";
lock (IPAdress)
{
//record the ip
recordIP(IPAdress);
}
}
else
{
Text = "ResourceTools [Disconnected]";
}
}
}
if (m_updateGrid)
{
lock (this)
{
while (m_blobQueue.Count > 0)
{
blobWrapper blob = m_blobQueue.Dequeue();
string szAction = "";
blob.extract(ref szAction);
szAction = szAction.ToLower();
if (szAction == "dumpresources")
{
extractDumpResources(blob);
}
else if (szAction == "updateresource")
{
extractUpdateResource(blob);
}
else if (szAction == "platform")
{
setConnectedPlatform(blob);
}
else if (szAction == "dataroot")
{
blob.extract(ref m_dataRootPath);
ConnectToPerforce();
}
blob.Dispose();
}
m_updateGrid = false;
}
}
if (m_updatePlatform)
{
m_emulationLabel.Text = "Emulation: " + m_platform;
m_updatePlatform = false;
}
}
private void ThreadTask()
{
CultureInfo tmp_ci = (CultureInfo)CultureInfo.CurrentCulture.Clone();
tmp_ci.NumberFormat.NumberDecimalSeparator = ".";
System.Threading.Thread.CurrentThread.CurrentCulture = tmp_ci;
m_running = true;
while (m_running)
{
updateConnectedStatus();
if (m_connected)
{
m_engine.update();
blobWrapper blob = new blobWrapper();
while (m_plugin.dispatch(blob))
{
lock (this)
{
blobWrapper blobCopy = new blobWrapper();
m_updateGrid = true;
blobCopy.copyFrom(blob);
m_blobQueue.Enqueue(blobCopy);
blob.Dispose();
}
}
}
Thread.Sleep(100);
}
}
public class ResourceInfo
{
public String PathName = "";
public String ShortName = "";
public String TypeName = "";
public Boolean loaded = false;
public float timeToLoad = 0.0f;
public UInt32 memoryUsage = 0;
public String CustomInfo = "";
public bool Cooked = false;
}
private void extractOneResourceInfo(ref blobWrapper blob, ref ResourceInfo __resourceInfo)
{
blob.extractPath(ref __resourceInfo.PathName);
blob.extractString8(ref __resourceInfo.ShortName);
blob.extract(ref __resourceInfo.TypeName);
blob.extract(ref __resourceInfo.timeToLoad);
blob.extract(ref __resourceInfo.loaded);
blob.extract(ref __resourceInfo.memoryUsage);
blob.extract(ref __resourceInfo.Cooked);
blob.extract(ref __resourceInfo.CustomInfo);
}
private void extractUpdateResource(blobWrapper blob)
{
UInt32 textureGlobalMemoryUsage = 0;
ResourceInfo resourceInfo = new ResourceInfo();
extractOneResourceInfo(ref blob, ref resourceInfo);
blob.extract(ref textureGlobalMemoryUsage);
//find the row where this is one is
int columnIndex = 0;
int columnPath = -1;
foreach (DataGridViewColumn column in dataGridViewResource.Columns)
{
if (column.Name == "PathColumn")
{
columnPath = columnIndex;
break;
}
++columnIndex;
}
//now find the row where the column match
if (columnPath != -1)
{
int rowCount = dataGridViewResource.Rows.Count;
for (int index = 0; index < rowCount; ++index)
{
DataGridViewTextBoxCell element = (DataGridViewTextBoxCell)dataGridViewResource.Rows[index].Cells[columnPath];
if (element.FormattedValue.ToString() == resourceInfo.PathName)
{
dataGridViewResource.Rows[index].SetValues(resourceInfo.ShortName,
resourceInfo.TypeName,
resourceInfo.timeToLoad * 1000.0f,
resourceInfo.loaded,
resourceInfo.memoryUsage / 1024.0f,
resourceInfo.CustomInfo,
resourceInfo.PathName);
applyChangeToCell(index, resourceInfo);
}
}
}
updateTextureMemory(textureGlobalMemoryUsage);
}
private void setPlatform(string platform)
{
m_platform = platform;
m_updatePlatform = true;
}
private void setConnectedPlatform(blobWrapper blob)
{
string platform = null;
blob.extract(ref platform);
setPlatform(platform);
}
private void updateTextureMemory(UInt32 __memory)
{
string textureUsageKb = (__memory / 1024.0f).ToString() + " Kb";
textBoxTextureMemory.Text = textureUsageKb;
}
private void applyChangeToCell(int indexRow, ResourceInfo resourceInfo)
{
Font font = dataGridViewResource.Font;
foreach (DataGridViewColumn column in dataGridViewResource.Columns)
{
int indexColumn = column.Index;
dataGridViewResource.Rows[indexRow].Cells[indexColumn].Style.ForeColor = resourceInfo.Cooked ? Color.Green : Color.Red;
dataGridViewResource.Rows[indexRow].Cells[indexColumn].Style.Font = new Font(font, FontStyle.Bold);
}
}
private void extractDumpResources(blobWrapper blob)
{
UInt32 resourceNbSelelected = 0;
UInt32 resourcesNbGlobal = 0;
blob.extract(ref resourceNbSelelected);
Boolean onlyLoaded = checkBoxLoaded.Checked;
dataGridViewResource.Rows.Clear();
float loadtimeCumuled = 0.0f;
UInt32 textureGlobalMemoryUsage = 0;
for (Int32 index = 0; index < resourceNbSelelected; ++index)
{
ResourceInfo resourceInfo = new ResourceInfo();
extractOneResourceInfo(ref blob, ref resourceInfo);
//timeToLoad time in ms
if (onlyLoaded == false || (onlyLoaded == true && resourceInfo.loaded == true))
{
int indexRow = dataGridViewResource.Rows.Add(resourceInfo.ShortName,
resourceInfo.TypeName,
resourceInfo.timeToLoad * 1000.0f,
resourceInfo.loaded,
resourceInfo.memoryUsage / 1024.0f,
resourceInfo.CustomInfo,
resourceInfo.PathName);
applyChangeToCell(indexRow, resourceInfo);
addResourceTypeToCombo(resourceInfo.TypeName);
}
if (resourceInfo.loaded)
{
loadtimeCumuled += resourceInfo.timeToLoad;
}
}
blob.extract(ref textureGlobalMemoryUsage);
blob.extract(ref resourcesNbGlobal);
loadtimeCumuled *= 1000.0f;//translate in ms
textLoadingTime.Text = loadtimeCumuled.ToString();
ResourcesCountSelected.Text = "Resources Category selected: "+resourceNbSelelected.ToString();
ResourcesCountGlobal.Text = "Resources global: " + resourcesNbGlobal.ToString();
updateTextureMemory(textureGlobalMemoryUsage);
}
private void resfresh(string resourceType)
{
if (m_connected)
{
blobWrapper blob = new blobWrapper();
blob.push("ResourceTools_Plugin");
blob.push("dumpresources");
blob.push(resourceType);
blob.sendToHost();
}
}
private void saveConfigurationConnection()
{
XmlTextWriter filexml = new XmlTextWriter(m_configFile, null);
filexml.Formatting = Formatting.Indented;
filexml.WriteStartDocument(true);
filexml.WriteStartElement("root");
foreach (string ip in comboBoxIP.Items)
{
filexml.WriteStartElement("target");
filexml.WriteAttributeString("ip", ip);
filexml.WriteEndElement();
}
filexml.WriteStartElement("selection");
filexml.WriteStartAttribute("ip");
filexml.WriteValue(IPAdress);
filexml.WriteEndAttribute();
filexml.WriteEndElement();
filexml.WriteEndElement();
filexml.WriteEndDocument();
filexml.Close();
}
private void loadConfigurationConnection()
{
XmlTextReader filexml = new XmlTextReader(m_configFile);
filexml.WhitespaceHandling = WhitespaceHandling.None;
while (filexml.Read())
{
if (filexml.LocalName == "target")
{
string ip = filexml.GetAttribute("ip");
comboBoxIP.Items.Add(ip);
}
if (filexml.LocalName == "selection")
{
IPAdress = filexml.GetAttribute("ip");
comboBoxIP.Text = IPAdress;
}
}
filexml.Close();
}
private void btnRefresh_Click(object sender, EventArgs e)
{
resfresh(comboBoxResourceType.Text);
}
private void checkBoxLoaded_CheckedChanged(object sender, EventArgs e)
{
resfresh(comboBoxResourceType.Text);
}
private void btnConnect_Click(object sender, EventArgs e)
{
lock (IPAdress)
{
IPAdress = comboBoxIP.Text;
}
}
enum ResourceType { eUnknow, eTexture,eSound };
private bool isWorkingDirectorySet()
{
if (m_workingDirectory == null || m_workingDirectory == "")
{
MessageBox.Show("Error","Please select a working directory");
return false;
}
return true;
}
private void btnRecook_Click(object sender, EventArgs e)
{
if (!isWorkingDirectorySet())
return;
if (m_currentTextureFileConfig != null)
{
string Root = textBoxWorkingDirectory.Text + "\\";
m_currentTextureFileConfig.saveConfiguration(makeTFIFilename(Root + "ConfigTemporary"),false);
}
//use the connected platform to recook
List<string> platformListSelected = new List<string>();
platformListSelected.Add(m_platform);
string exeDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
exeDirectory = exeDirectory.Replace("file:\\", "");
cookerWrapper instanceCooker = new cookerWrapper();
instanceCooker.init(m_workingDirectory);
instanceCooker.registerVersionCallback();
foreach (string platform in platformListSelected)
{
instanceCooker.cookTexture(platform, m_currentFileWorking, true);
}
instanceCooker.destroy();
blobWrapper blob = new blobWrapper();
blob.push("ResourceTools_Plugin");
blob.push("ReloadResource");
blob.pushPath(m_currentFileWorking);
blob.sendToHost();
}
public void updateResourceProperties()
{
if (m_currentTextureFileConfig == null)
return;
List<TextureConfiguration> listTexture = new List<TextureConfiguration>();
if (checkBoxPC.Checked)
{
listTexture.Add(m_currentTextureFileConfig.getCurrentConfiguration(eTarget.PC));
}
if (checkBoxXBox360.Checked)
{
listTexture.Add(m_currentTextureFileConfig.getCurrentConfiguration(eTarget.X360));
}
if (checkBoxPS3.Checked)
{
listTexture.Add(m_currentTextureFileConfig.getCurrentConfiguration(eTarget.PS3));
}
if (checkBoxWII.Checked)
{
listTexture.Add(m_currentTextureFileConfig.getCurrentConfiguration(eTarget.WII));
}
if (checkBoxCAFE.Checked)
{
listTexture.Add(m_currentTextureFileConfig.getCurrentConfiguration(eTarget.CAFE));
}
propertyGridResource.SelectedObjects = listTexture.ToArray();
}
private void cellSelection(DataGridViewCellEventArgs e, bool doubleClick,bool rightClick)
{
int index = 0;
ResourceType resourceType = ResourceType.eUnknow;
string FilePath = "";
string Root = textBoxWorkingDirectory.Text + "\\";
pictureResource.Visible = false;
bool runView = doubleClick;
if (e.RowIndex != -1)
{
foreach (DataGridViewColumn column in dataGridViewResource.Columns)
{
if (column.Name == "TypeColumn")
{
DataGridViewTextBoxCell element = (DataGridViewTextBoxCell)dataGridViewResource.Rows[e.RowIndex].Cells[index];
String resourceTypeName = element.FormattedValue.ToString();
if ("ResourceType_Sound" == resourceTypeName)
{
resourceType = ResourceType.eSound;
}
else
if ("ResourceType_Texture" == resourceTypeName)
{
resourceType = ResourceType.eTexture;
}
}
else if (column.Name == "PathColumn")
{
DataGridViewTextBoxCell element = (DataGridViewTextBoxCell)dataGridViewResource.Rows[e.RowIndex].Cells[index];
FilePath = element.FormattedValue.ToString().Replace("/", "\\");
}
++index;
}
}
btnRecook.Enabled = false;
btnSave.Enabled = false;
if (File.Exists(Root + FilePath))
{
if (e.ColumnIndex <=0 && resourceType == ResourceType.eSound)
{
SoundPlayer simpleSound = new SoundPlayer(Root + FilePath);
simpleSound.Play();
}
else
if (resourceType == ResourceType.eTexture)
{
string extension = Path.GetExtension(Root + FilePath).Substring(1);
try
{
if (extension == "tga")
{
Bitmap bitmap = Paloma.TargaImage.LoadTargaImage(Root + FilePath);
pictureResource.Image = bitmap;
}
else
{
pictureResource.Image = Bitmap.FromFile(Root + FilePath);
}
pictureResource.Visible = true;
}
catch
{}
if (m_applicationHash.ContainsKey(extension) && runView)
{
//open the given resource;
ProcessStartInfo startInfo = new ProcessStartInfo((string)(m_applicationHash[extension]));
startInfo.Arguments = Root + FilePath;
startInfo.WindowStyle = ProcessWindowStyle.Maximized;
Process.Start(startInfo);
Thread.Sleep(50);
}
m_currentFileWorking = FilePath;
btnRecook.Enabled = true;
btnSave.Enabled = true;
String finalPath = Root + FilePath;
finalPath = finalPath.Replace("\\\\", "\\");
m_currentTextureFileConfig = new TextureFileConfig(finalPath);
m_currentTextureFileConfig.loadConfiguration(makeTFIFilename(finalPath));
updateResourceProperties();
if (rightClick)
{
//open the file directory in the explorer
/* open using an associate viewer
string myPath = finalPath;
System.Diagnostics.Process prc = new System.Diagnostics.Process();
prc.StartInfo.FileName = myPath;
prc.Start();*/
string myDocspath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
string windir = Environment.GetEnvironmentVariable("WINDIR");
System.Diagnostics.Process prc = new System.Diagnostics.Process();
prc.StartInfo.FileName = windir + @"\explorer.exe";
prc.StartInfo.Arguments = Path.GetDirectoryName(finalPath);
prc.Start();
}
}
}
}
private void dataGridViewResource_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
cellSelection(e, true,false);
}
private void dataGridViewResource_CellClick(object sender, DataGridViewCellEventArgs e)
{
cellSelection(e, false,false);
}
private void checkBoxPC_CheckedChanged(object sender, EventArgs e)
{
updateResourceProperties();
}
private void checkBoxXBox360_CheckedChanged(object sender, EventArgs e)
{
updateResourceProperties();
}
private void checkBoxCAFE_CheckedChanged(object sender, EventArgs e)
{
updateResourceProperties();
}
private void checkBoxPS3_CheckedChanged(object sender, EventArgs e)
{
updateResourceProperties();
}
private void btnSave_Click(object sender, EventArgs e)
{
if (m_currentTextureFileConfig != null)
{
string Root = textBoxWorkingDirectory.Text;
m_currentTextureFileConfig.saveConfiguration(makeTFIFilename(Root + m_currentFileWorking),true);
}
}
private void btnSelectWorkingDirectory_Click(object sender, EventArgs e)
{
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
folderBrowserDialog.SelectedPath = (m_workingDirectory == null) ? "c:\\" : m_workingDirectory;
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
m_workingDirectory = normalizeWorkingDirectory(folderBrowserDialog.SelectedPath);
textBoxWorkingDirectory.Text = m_workingDirectory;
}
saveUserInfo();
}
private void loadUserInfo()
{
if (File.Exists(m_configFileUserApplication))
{
XmlTextReader filexml = new XmlTextReader(m_configFileUserApplication);
filexml.WhitespaceHandling = WhitespaceHandling.None;
while (filexml.Read())
{
if (filexml.LocalName == "UserInfo")
{
m_workingDirectory = filexml.GetAttribute("WorkingDirectory");
m_workingDirectory = normalizeWorkingDirectory(m_workingDirectory);
textBoxWorkingDirectory.Text = m_workingDirectory;
}
}
filexml.Close();
}
}
private void saveUserInfo()
{
XmlTextWriter filexml = new XmlTextWriter(m_configFileUserApplication, null);
filexml.Formatting = Formatting.Indented;
filexml.WriteStartDocument(true);
filexml.WriteStartElement("root");
filexml.WriteStartElement("UserInfo");
filexml.WriteStartAttribute("WorkingDirectory");
filexml.WriteValue(m_workingDirectory);
filexml.WriteEndAttribute();
filexml.WriteEndElement();
filexml.WriteEndElement();
filexml.WriteEndDocument();
filexml.Close();
}
private void textBoxWorkingDirectory_TextChanged(object sender, EventArgs e)
{
}
private void dataGridViewResource_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void dataGridViewResource_CellEnter(object sender, DataGridViewCellEventArgs e)
{
//cellSelection(e, false);
}
private void comboBoxResourceType_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBoxResourceType.SelectedIndex == -1)
return;
resfresh(comboBoxResourceType.Text);
}
private void checkboxNotCooked_CheckedChanged(object sender, EventArgs e)
{
resfresh(comboBoxResourceType.Text);
}
private void checkboxCooked_CheckedChanged(object sender, EventArgs e)
{
resfresh(comboBoxResourceType.Text);
}
private void dataGridViewResource_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
DataGridViewCellEventArgs eventCell = new DataGridViewCellEventArgs(e.ColumnIndex,e.RowIndex);
dataGridViewResource.CurrentCell.Selected = false;
dataGridViewResource.Rows[e.RowIndex].Cells[e.ColumnIndex].Selected = true;
dataGridViewResource.CurrentCell = dataGridViewResource.SelectedCells[0];
cellSelection(eventCell, false, true);
}
}
private void checkBoxWII_CheckedChanged(object sender, EventArgs e)
{
updateResourceProperties();
}
private void ResourceTools_Load(object sender, EventArgs e)
{
}
private void ResourceTools_FormClosed(object sender, FormClosedEventArgs e)
{
m_plugin = null;
m_thread.Join();
if (m_engine != null)
{
m_engine.disconnect();
m_engine.destroy();
}
}
private void ResourceTools_FormClosing(object sender, FormClosingEventArgs e)
{
m_running = false;
}
private void button_P4Connect_Click(object sender, EventArgs e)
{
PerforceUtils.Connect();
if (isP4Connected)
{
label_P4Status.Text = "Status: connected";
button_P4Connect.Enabled = false;
}
else
{
label_P4Status.Text = "Status: not connected";
button_P4Connect.Enabled = true;
}
}
private void button_DumpClick(object sender, EventArgs e)
{
List<string> list = new List<string>();
foreach (DataGridViewRow row in dataGridViewResource.Rows)
{
string s = row.Cells[6].FormattedValue.ToString();
list.Add(s);
}
System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(list.GetType());
string dumpFile = string.Format("resource_tool_dump-{0:yyyy-MM-dd_hh-mm-ss-tt}.xml", DateTime.Now);
System.IO.StreamWriter file = new System.IO.StreamWriter(dumpFile);
serializer.Serialize(file, list);
file.Close();
}
}
}