diff --git a/IGIEditor/IGIEditorUI.Designer.cs b/IGIEditor/IGIEditorUI.Designer.cs index 1d735c2..f289d39 100644 --- a/IGIEditor/IGIEditorUI.Designer.cs +++ b/IGIEditor/IGIEditorUI.Designer.cs @@ -511,7 +511,7 @@ private void InitializeComponent() 0, 0}); this.levelStartTxt.Name = "levelStartTxt"; - this.levelStartTxt.Size = new System.Drawing.Size(56, 41); + this.levelStartTxt.Size = new System.Drawing.Size(78, 41); this.levelStartTxt.TabIndex = 42; this.levelStartTxt.Value = new decimal(new int[] { 1, @@ -4706,7 +4706,6 @@ private void InitializeComponent() // // appMenuSettings // - this.appMenuSettings.GripMargin = new System.Windows.Forms.Padding(2, 2, 0, 2); this.appMenuSettings.ImageScalingSize = new System.Drawing.Size(20, 20); this.appMenuSettings.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.settingsToolStripMenuItem, @@ -4755,7 +4754,6 @@ private void InitializeComponent() // // levelStartTxtMenu // - this.levelStartTxtMenu.Font = new System.Drawing.Font("Segoe UI", 9F); this.levelStartTxtMenu.Name = "levelStartTxtMenu"; this.levelStartTxtMenu.Size = new System.Drawing.Size(224, 39); this.levelStartTxtMenu.Text = "1"; @@ -4886,7 +4884,6 @@ private void InitializeComponent() // // gameProfileNameLbl // - this.gameProfileNameLbl.Font = new System.Drawing.Font("Segoe UI", 9F); this.gameProfileNameLbl.Name = "gameProfileNameLbl"; this.gameProfileNameLbl.Size = new System.Drawing.Size(224, 39); this.gameProfileNameLbl.Text = "N/A"; @@ -4993,7 +4990,6 @@ private void InitializeComponent() // // musicVolumeUpdateTxt // - this.musicVolumeUpdateTxt.Font = new System.Drawing.Font("Segoe UI", 9F); this.musicVolumeUpdateTxt.Name = "musicVolumeUpdateTxt"; this.musicVolumeUpdateTxt.Size = new System.Drawing.Size(224, 39); this.musicVolumeUpdateTxt.Text = "5.0"; @@ -5009,7 +5005,6 @@ private void InitializeComponent() // // sfxVolumeUpdateTxt // - this.sfxVolumeUpdateTxt.Font = new System.Drawing.Font("Segoe UI", 9F); this.sfxVolumeUpdateTxt.Name = "sfxVolumeUpdateTxt"; this.sfxVolumeUpdateTxt.Size = new System.Drawing.Size(224, 39); this.sfxVolumeUpdateTxt.Text = "3.5"; @@ -5025,7 +5020,6 @@ private void InitializeComponent() // // framesTxt // - this.framesTxt.Font = new System.Drawing.Font("Segoe UI", 9F); this.framesTxt.Name = "framesTxt"; this.framesTxt.Size = new System.Drawing.Size(224, 39); this.framesTxt.Text = "30"; @@ -5145,7 +5139,7 @@ private void InitializeComponent() this.shareAppLogsBtn, this.viewAppLogsBtn}); this.logsToolStripMenuItem.Name = "logsToolStripMenuItem"; - this.logsToolStripMenuItem.Size = new System.Drawing.Size(359, 44); + this.logsToolStripMenuItem.Size = new System.Drawing.Size(344, 44); this.logsToolStripMenuItem.Text = "Logs"; // // appLogsCb @@ -5176,27 +5170,27 @@ private void InitializeComponent() this.clearCacheBtn, this.clearTempToolStripMenuItem}); this.appdataToolStripMenuItem.Name = "appdataToolStripMenuItem"; - this.appdataToolStripMenuItem.Size = new System.Drawing.Size(359, 44); + this.appdataToolStripMenuItem.Size = new System.Drawing.Size(344, 44); this.appdataToolStripMenuItem.Text = "Appdata"; // // showAppDataCachePathBtn // this.showAppDataCachePathBtn.Name = "showAppDataCachePathBtn"; - this.showAppDataCachePathBtn.Size = new System.Drawing.Size(359, 44); + this.showAppDataCachePathBtn.Size = new System.Drawing.Size(275, 44); this.showAppDataCachePathBtn.Text = "Show Path"; this.showAppDataCachePathBtn.Click += new System.EventHandler(this.showAppDataCachePathBtn_Click); // // clearCacheBtn // this.clearCacheBtn.Name = "clearCacheBtn"; - this.clearCacheBtn.Size = new System.Drawing.Size(359, 44); + this.clearCacheBtn.Size = new System.Drawing.Size(275, 44); this.clearCacheBtn.Text = "Clear Cache"; this.clearCacheBtn.Click += new System.EventHandler(this.clearCacheBtn_Click); // // clearTempToolStripMenuItem // this.clearTempToolStripMenuItem.Name = "clearTempToolStripMenuItem"; - this.clearTempToolStripMenuItem.Size = new System.Drawing.Size(359, 44); + this.clearTempToolStripMenuItem.Size = new System.Drawing.Size(275, 44); this.clearTempToolStripMenuItem.Text = "Clear Temp"; this.clearTempToolStripMenuItem.Click += new System.EventHandler(this.clearTempToolStripMenuItem_Click); // @@ -5206,7 +5200,7 @@ private void InitializeComponent() this.autoResetCb, this.autoRefreshGameCb}); this.autoOptionsToolStripMenuItem.Name = "autoOptionsToolStripMenuItem"; - this.autoOptionsToolStripMenuItem.Size = new System.Drawing.Size(359, 44); + this.autoOptionsToolStripMenuItem.Size = new System.Drawing.Size(344, 44); this.autoOptionsToolStripMenuItem.Text = "Auto level options"; // // autoResetCb @@ -5229,7 +5223,7 @@ private void InitializeComponent() this.internalCompilerCb, this.externalCompilerCb}); this.compilerSelectToolStripMenuItem.Name = "compilerSelectToolStripMenuItem"; - this.compilerSelectToolStripMenuItem.Size = new System.Drawing.Size(359, 44); + this.compilerSelectToolStripMenuItem.Size = new System.Drawing.Size(344, 44); this.compilerSelectToolStripMenuItem.Text = "Compiler select"; // // internalCompilerCb @@ -5252,7 +5246,7 @@ private void InitializeComponent() this.editorUpdaterBtn, this.updateCheckerAutomaticOption}); this.updateToolStripMenuItem.Name = "updateToolStripMenuItem"; - this.updateToolStripMenuItem.Size = new System.Drawing.Size(359, 44); + this.updateToolStripMenuItem.Size = new System.Drawing.Size(344, 44); this.updateToolStripMenuItem.Text = "Update"; // // editorUpdaterBtn @@ -5273,7 +5267,6 @@ private void InitializeComponent() // // updateIntervalTxt // - this.updateIntervalTxt.Font = new System.Drawing.Font("Segoe UI", 9F); this.updateIntervalTxt.Name = "updateIntervalTxt"; this.updateIntervalTxt.Size = new System.Drawing.Size(224, 39); this.updateIntervalTxt.Text = "15"; @@ -5290,7 +5283,7 @@ private void InitializeComponent() // appSupportBtn // this.appSupportBtn.Name = "appSupportBtn"; - this.appSupportBtn.Size = new System.Drawing.Size(359, 44); + this.appSupportBtn.Size = new System.Drawing.Size(344, 44); this.appSupportBtn.Text = "Support"; this.appSupportBtn.Click += new System.EventHandler(this.appSupportBtn_Click); // @@ -5300,7 +5293,7 @@ private void InitializeComponent() this.exportObjectsDD, this.exportObjectsBtn}); this.exportObjectsToolStripMenuItem.Name = "exportObjectsToolStripMenuItem"; - this.exportObjectsToolStripMenuItem.Size = new System.Drawing.Size(359, 44); + this.exportObjectsToolStripMenuItem.Size = new System.Drawing.Size(344, 44); this.exportObjectsToolStripMenuItem.Text = "Export Objects"; // // exportObjectsDD @@ -5323,7 +5316,7 @@ private void InitializeComponent() // gamePathBtn // this.gamePathBtn.Name = "gamePathBtn"; - this.gamePathBtn.Size = new System.Drawing.Size(359, 44); + this.gamePathBtn.Size = new System.Drawing.Size(344, 44); this.gamePathBtn.Text = "Set Game path"; this.gamePathBtn.Click += new System.EventHandler(this.gamePathBtn_Click); // diff --git a/IGIEditor/IGIEditorUI.cs b/IGIEditor/IGIEditorUI.cs index fe655d5..119e603 100644 --- a/IGIEditor/IGIEditorUI.cs +++ b/IGIEditor/IGIEditorUI.cs @@ -185,7 +185,7 @@ public IGIEditorUI() { QUtils.ResetScriptFile(gameLevel); } - clearTempToolStripMenuItem_Click(null, null); + QUtils.CleanUpTmpFiles(); if (appLogs) { diff --git a/QTask.cs b/QTask.cs index decb4a5..07b3525 100644 --- a/QTask.cs +++ b/QTask.cs @@ -71,85 +71,90 @@ internal static int GetUniqueQTaskId(int taskId) internal static int GenerateTaskID(bool minimalId = false, bool fromBackup = false) { - int taskId = 0; try { - QUtils.AddLog(MethodBase.GetCurrentMethod().Name, "called minimal Id : " + minimalId + " fromBackup: " + fromBackup + " Level: " + QUtils.gGameLevel); + QUtils.AddLog(MethodBase.GetCurrentMethod().Name, "Method called with parameters: minimalId=" + minimalId + ", fromBackup=" + fromBackup + ", Level=" + QUtils.gGameLevel); string inputQscPath = cfgQscPath + QUtils.gGameLevel + "\\" + objectsQsc; - string qscData = fromBackup ? LoadFile(inputQscPath) : LoadFile(); + QUtils.AddLog(MethodBase.GetCurrentMethod().Name, "inputQscPath: " + inputQscPath); + string qscData = fromBackup ? LoadFile(inputQscPath) : LoadFile(); qscData = qscData.Replace("\t", String.Empty); string[] qscDataSplit = qscData.Split('\n'); + List qIdsList = new List(); foreach (var data in qscDataSplit) { if (data.Contains(taskNew)) { - var startIndex = data.IndexOf(',', 14) + 1; - var taskName = (data.Slice(13, startIndex)); - string[] taskNew = data.Split(','); - int taskIndex = 0; - - foreach (var task in taskNew) - { - if (taskIndex == (int)QTASKINFO.QTASK_ID) - { - var taskIdx = task.IndexOf('('); - if (taskIdx == -1) break; - var qidSub = task.Substring(taskIdx + 1); - int qid = Convert.ToInt32(qidSub); - if (qid == -1) break; - if (qid > QUtils.LEVEL_FLOW_TASK_ID) - qIdsList.Add(qid); - break; - } - } + int qid = GetTaskIdFromData(taskNew); + + if (qid > QUtils.LEVEL_FLOW_TASK_ID) + qIdsList.Add(qid); } } qIdsList.Sort(); - QUtils.AddLog(MethodBase.GetCurrentMethod().Name, "sorting done. count: " + qIdsList.Count); + int taskId = GetNextTaskId(qIdsList, minimalId); - taskId = qIdsList[0] + 1; - int maxVal = qIdsList[0], minVal = qIdsList[1]; + taskId = GetUniqueQTaskId(taskId); + QUtils.AddLog(MethodBase.GetCurrentMethod().Name, "Unique task ID generated. Task ID: " + taskId); + + return taskId; + } + catch (Exception ex) + { + QUtils.ShowLogException(MethodBase.GetCurrentMethod().Name, ex); + return 0; + } + } - if (minimalId) + private static int GetTaskIdFromData(string[] taskNew) + { + int qid = -1; + foreach (var task in taskNew) + { + int taskIndex = Array.IndexOf(taskNew, task); + if (taskIndex == (int)QTASKINFO.QTASK_ID) { - int diffVal = 0; - for (int index = 0; index < qIdsList.Count; index++) + var taskIdx = task.IndexOf('('); + if (taskIdx != -1 && int.TryParse(task.Substring(taskIdx + 1), out qid) && qid != -1) { - minVal = qIdsList[index]; - maxVal = qIdsList[index + 1]; - diffVal = Math.Abs(maxVal - minVal); - //QUtils.AddLog(MethodBase.GetCurrentMethod().Name, "maxVal : " + maxVal + "\tminVal : " + minVal + "\tdiffVal : " + diffVal); - - if (diffVal >= QUtils.MAX_MINIMAL_ID_DIFF) - { - taskId = minVal + 1; - break; - } + break; } } - else + } + return qid; + } + + private static int GetNextTaskId(List qIdsList, bool minimalId) + { + if (minimalId) + { + for (int index = 0; index < qIdsList.Count - 1; index++) { - qIdsList.Reverse(); - maxVal = qIdsList[0]; - taskId = maxVal + 1; + int minVal = qIdsList[index]; + int maxVal = qIdsList[index + 1]; + int diffVal = Math.Abs(maxVal - minVal); + + if (diffVal >= QUtils.MAX_MINIMAL_ID_DIFF) + { + return minVal + 1; + } } - taskId = GetUniqueQTaskId(taskId); - QUtils.AddLog(MethodBase.GetCurrentMethod().Name, "Returned Task Id: " + taskId); } - catch (Exception ex) + else { - QUtils.ShowLogException(MethodBase.GetCurrentMethod().Name, ex); + return qIdsList[qIdsList.Count - 1] + 1; } - return taskId; + + return qIdsList[0] + 1; } + internal static QScriptTask GetQTask(string taskName) { AddLog(MethodBase.GetCurrentMethod().Name, " taskName called");