private void Form2_Load(object sender, EventArgs e) { this.ForeColor = EdLib.CFore; this.BackColor = EdLib.CBack; listView1.ForeColor = EdLib.CFore; listView1.BackColor = EdLib.CBack; richTextBox1.ForeColor = EdLib.CFore; richTextBox1.BackColor = EdLib.CBack; button1.ForeColor = EdLib.CFore; button1.BackColor = EdLib.CBack; button2.ForeColor = EdLib.CFore; button2.BackColor = EdLib.CBack; button3.ForeColor = EdLib.CFore; button3.BackColor = EdLib.CBack; button4.ForeColor = EdLib.CFore; button4.BackColor = EdLib.CBack; button5.ForeColor = EdLib.CFore; button5.BackColor = EdLib.CBack; this.Text = Form1.appChineseName; this.Icon = Form1.main.Icon; EdLib.SetBrowser(listView1, listView1.Width); reloadList(); listView1.Items.Add("☀官方资源包"); descs.Add("该资源包为官方原版内容资源包,包含所有该游戏的图标、模型、音乐、卡牌设计等数据,适合新手学习使用。"); names.Add("Builtin"); ids.Add(""); var pos = EdLib.HasFile(Form1.GetPath("{game}"), true) ? Form1.GetPath("{game}") : Form1.GetPath("{localgame}"); paths.Add(pos + "\\TetraProject_Data\\StreamingAssets\\Packages\\Builtin"); pictureBox1.BackgroundImageLayout = ImageLayout.Stretch; pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; //EdLib.AskMsg(pos + "\\TetraProject_Data\\StreamingAssets\\Packages\\Builtin"); }
private void Button5_Click(object sender, EventArgs e) { if (indexOfLastSelection >= 0 && indexOfLastSelection < listView1.Items.Count) { if (paths[indexOfLastSelection].Contains("steamapps")) { EdLib.AskMsg(Form1.loadOnlinePackageWarning); } else { if (EdLib.HasFile(paths[indexOfLastSelection], true)) { if (EdLib.AskMsg("确认要移除该资源包吗? 该操作将无法挽回,确定吗?")) { try { System.IO.Directory.Delete(paths[indexOfLastSelection]); indexOfLastSelection = -2; //FileSystem.DeleteDirectory(paths[indexOfLastSelection], UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin); reloadList(); } catch (Exception E) { EdLib.AskMsg("由于文件夹被占用或无法正常处理(被防病毒软件阻止),因此删除操作已取消。"); } } } } } }
private void ListView1_SelectedIndexChanged_1(object sender, EventArgs e) { var text = EdLib.TryGetListViewSelection(listView1); if (text != null) { indexOfLastSelection = text.Index; richTextBox1.Text = descs[indexOfLastSelection]; workshopId = ids[indexOfLastSelection]; if (EdLib.HasFile(paths[indexOfLastSelection] + "\\icon.png")) { Image image = System.Drawing.Image.FromFile(paths[indexOfLastSelection] + "\\icon.png"); pictureBox1.Image = image; } else if (EdLib.HasFile(EdLib.path_AppData + "\\icon.png")) { Image image = System.Drawing.Image.FromFile(EdLib.path_AppData + "\\icon.png"); pictureBox1.Image = image; } else { pictureBox1.Image = null; } } }
public void CreateNewPackage() { string infoName = EdLib.InputBox("请输入资源包文件夹名称 (英文)").Trim(); string infoName2 = EdLib.InputBox("请输入MOD名称").Trim(); string infoIntro = EdLib.InputBox("请输入MOD简介").Trim(); if (infoName.Trim() == "" || infoName2.Trim() == "") { return; } EdLib.AskMsg("准备按程序生成默认资源,这将需要一些时间,请耐心等待。"); var pos = Form1.GetPath(Form1.path_UserPackage) + "\\" + infoName; System.IO.Directory.CreateDirectory(pos); System.IO.Directory.CreateDirectory(pos + "\\DataBase"); System.IO.Directory.CreateDirectory(pos + "\\CardArt"); System.IO.Directory.CreateDirectory(pos + "\\CharacterModel"); System.IO.Directory.CreateDirectory(pos + "\\Effect"); System.IO.Directory.CreateDirectory(pos + "\\Emoji"); System.IO.Directory.CreateDirectory(pos + "\\EnvironmentModel"); System.IO.Directory.CreateDirectory(pos + "\\Illustration"); System.IO.Directory.CreateDirectory(pos + "\\MinimapModel"); System.IO.Directory.CreateDirectory(pos + "\\Music"); System.IO.Directory.CreateDirectory(pos + "\\Sound"); System.IO.Directory.CreateDirectory(pos + "\\StageMap"); System.IO.File.Copy(Form1.GetPath(Form1.path_GameApp) + "\\TetraProject_Data\\StreamingAssets\\Packages\\Builtin\\Database\\Database.xls", pos + "\\DataBase\\DataBase.xls"); System.IO.File.Copy(EdLib.path_AppData + "\\icon.png", pos + "\\icon.png"); if (!EdLib.HasFile(pos + "\\PackageInfo.json", false)) { System.IO.File.WriteAllText(pos + "\\PackageInfo.json", @"{ ""id"": """ + infoName + @""", ""displayName"": """ + infoName2 + @""", ""description"": """ + infoIntro + @""", ""publishedTags"": [ ""Card"" ] } "); } path_CurrentPackage = pos; loadAll(); foreach (var item in ReoMain.Worksheets) { for (int i = 1; i < item.RowCount - 1; i++) { for (int d = 0; d < item.ColumnCount; d++) { if (item[i, d] != null) { item[i, d] = null; } } } } SaveFile(); EdLib.AskMsg("资源包创建完毕"); System.Diagnostics.Process.Start(pos); }
private void Form1_Shown(object sender, EventArgs e) { LoadUserInfo(); this.Text = appChineseName + " " + currentPackageName; if (!EdLib.HasFile(path_GameApp, true)) { StartFirstUsingSettings(); } reoGridControl2.SheetTabWidth = 600; loadAll(); //pictureBox3.Controls.Add(label5); //label5.Location = new Point(120, 270); label5.BackColor = System.Drawing.Color.Transparent; label5.FlatStyle = FlatStyle.Flat; label5.Font = new Font("黑体", 10, FontStyle.Regular); //pictureBox3.Controls.Add(pictureBox1); //pictureBox1.Location = new Point(120, 150); pictureBox1.BackColor = System.Drawing.Color.Transparent; //pictureBox2.Controls.Add(pictureBox3); //pictureBox3.Location = new Point(0, 0); //pictureBox3.BackColor = System.Drawing.Color.Transparent; //pictureBox1.Hide(); pictureBox1.Controls.Add(label4); //label4.Location = new Point(10, 100); label4.BackColor = System.Drawing.Color.Transparent; label4.FlatStyle = FlatStyle.Flat; label4.TextAlign = ContentAlignment.TopCenter; label4.Font = new Font("黑体", 12, FontStyle.Regular); //pictureBox3.Controls.Add(label6); label6.Text = "1"; //label6.Location = new Point(97, 150); label6.BackColor = System.Drawing.Color.Transparent; label6.FlatStyle = FlatStyle.Flat; label6.Font = new Font("黑体", 18, FontStyle.Regular); label6.Height = 20; //pictureBox3.Controls.Add(label7); label7.Text = "1"; //label7.Location = new Point(100, 180); label7.BackColor = System.Drawing.Color.Transparent; label7.FlatStyle = FlatStyle.Flat; label7.Font = new Font("黑体", 12, FontStyle.Regular); label7.ForeColor = Color.DarkGray; //pictureBox3.Controls.Add(label8); label8.Text = "1"; //label8.Location = new Point(100, 200); label8.BackColor = System.Drawing.Color.Transparent; label8.FlatStyle = FlatStyle.Flat; label8.Font = new Font("黑体", 12, FontStyle.Regular); label8.ForeColor = Color.DarkRed; pictureBox1.BackgroundImageLayout = ImageLayout.Stretch; pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; }
private void LoadFiles(string path) { bool IsCurrentPackageSteamWorkshop = false; path = Form1.GetPath(path); if (path.Contains("steamapps")) { IsCurrentPackageSteamWorkshop = true; } string[] folders = System.IO.Directory.GetDirectories(path); foreach (var folder in folders) { string oneInfo = System.IO.Path.GetFileNameWithoutExtension(folder); string mainInfo = oneInfo; string descInfo = ""; string IdInfo = ""; if (mainInfo == "1815462892") { continue; } if (EdLib.HasFile(path + "\\" + mainInfo + "\\PackageInfo.json", false)) { using (System.IO.StreamReader file = System.IO.File.OpenText(path + "\\" + mainInfo + "\\PackageInfo.json")) { using (JsonTextReader reader = new JsonTextReader(file)) { Newtonsoft.Json.Linq.JObject o = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.Linq.JToken.ReadFrom(reader); var a = o["displayName"]; var b = o["description"]; var c = o["id"]; if (a != null) { oneInfo = (IsCurrentPackageSteamWorkshop ? "☁在线资源包 " : "◉自制资源包 ") + a.ToString(); } if (b != null) { descInfo = "" + b.ToString(); } if (c != null) { IdInfo = o["id"].ToString(); } } } } listView1.Items.Add(oneInfo); names.Add(oneInfo); descs.Add(descInfo); ids.Add(IdInfo); paths.Add(path + "\\" + mainInfo); } }
private void 常见异常ToolStripMenuItem_Click(object sender, EventArgs e) { var pos2 = EdLib.path_AppData + "\\help.xlsx"; if (EdLib.HasFile(pos2)) { reoGridControl3.Load(pos2, unvell.ReoGrid.IO.FileFormat.Excel2007); var sheet = reoGridControl3.CurrentWorksheet; reoGridControl3.Show(); } }
private void 打开CardCommandToolStripMenuItem_Click_1(object sender, EventArgs e) { var pos2 = GetPath("{game}\\TetraProject_Data\\StreamingAssets\\Packages\\Builtin\\Database\\CardCommand.csv"); if (EdLib.HasFile(pos2)) { reoGridControl3.Load(pos2, unvell.ReoGrid.IO.FileFormat.CSV); var sheet = reoGridControl3.CurrentWorksheet; sheet.SetColumnsWidth(0, 2, 200); reoGridControl3.Show(); } }
private void reloadList() { listView1.Clear(); descs.Clear(); paths.Clear(); EdLib.SetBrowser(listView1, 160); if (EdLib.HasFile(Form1.path_UserPackage, true)) { LoadFiles("{packages}"); LoadFiles("{localpackages}"); } }
/* * if (control == pictureBox1 || control == pictureBox2 || control == pictureBox3 || control == pictureBox4 || control == label4 || control == label5 || control == label6 || control == label7 || control == label8) * { * * continue; * } */ private void StartFirstUsingSettings() { if (!EdLib.HasFile(path_UserPackage, true)) { path_UserPackage = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\TetraProject\\Packages"; if (!EdLib.HasFile(path_UserPackage, true)) { EdLib.AskMsg("未能自动找到您的 Packages 路径,请您手动设置。"); } } EdLib.path_FileSelection = GetPath("{game}"); var pos = GetPath("{localgame}"); if (EdLib.HasFile(pos, true) && !pos.Contains("Debug")) { path_GameApp = GetPath(pos); path_CurrentPackage = PackageSelection(); SaveUserInfo(); loadAll(); return; } else { EdLib.AskMsg(GetPath("无法自动获取游戏目录,请您手动选择一些文件 TetraProject.exe, \n错误信息:{localgame}")); } StartFirstUsingSettingsFlag: EdLib.ShowFileSelection("找到您的游戏 TetraProject.exe"); if (EdLib.GetFileSelection()) { var path = System.IO.Path.GetFileName(EdLib.path_FileSelection); if (path != "TetraProject.exe") { if (EdLib.AskMsg("不是 TetraProject.exe,是否重新开始选择?。")) { goto StartFirstUsingSettingsFlag; } } else { path_GameApp = EdLib.path_FileSelection; } } path_CurrentPackage = PackageSelection(); SaveUserInfo(); loadAll(); }
private void 打开资源包文件夹ToolStripMenuItem_Click(object sender, EventArgs e) { if (EdLib.HasFile(path_CurrentPackage, true)) { if (IsCurrentPackageSteamWorkshop) { EdLib.AskMsg(loadOnlinePackageWarning); } else { System.Diagnostics.Process.Start(path_CurrentPackage); } } }
public void SaveFile() { if (EdLib.HasFile(path_CurrentPackage, true)) { if (IsCurrentPackageSteamWorkshop) { EdLib.AskMsg(loadOnlinePackageWarning); } else { ReoMain.Save(GetPath(path_CurrentPackage) + "\\Database\\database.xlsx", unvell.ReoGrid.IO.FileFormat.Excel2007); foreach (var item in ReoMain.Worksheets) { item.ExportAsCSV(GetPath(path_CurrentPackage) + "\\Database\\" + item.Name + ".csv"); } } } }
private void Button4_Click(object sender, EventArgs e) { if (indexOfLastSelection >= 0 && indexOfLastSelection < listView1.Items.Count) { if (paths[indexOfLastSelection].Contains("steamapps")) { EdLib.AskMsg(Form1.loadOnlinePackageWarning); } else { if (EdLib.HasFile(paths[indexOfLastSelection] + "\\PackageInfo.json")) { string json = System.IO.File.ReadAllText(paths[indexOfLastSelection] + "\\PackageInfo.json"); dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(json); jsonObj["description"] = richTextBox1.Text; string output = Newtonsoft.Json.JsonConvert.SerializeObject(jsonObj, Newtonsoft.Json.Formatting.Indented); System.IO.File.WriteAllText(paths[indexOfLastSelection] + "\\PackageInfo.json", output); descs[indexOfLastSelection] = richTextBox1.Text; } } } }
public void loadAll() { var pos2 = GetPath("{game}\\TetraProject_Data\\StreamingAssets\\Packages\\Builtin\\Database\\CardCommand.csv"); if (EdLib.HasFile(pos2)) { if (AutoCompleteData == null) { AutoCompleteData = new List <ICompletionData>(); var obj = new ReoGridControl(); obj.Load(pos2, unvell.ReoGrid.IO.FileFormat.CSV); for (int i = 1; i < obj.CurrentWorksheet.RowCount; i++) { if (obj.CurrentWorksheet[i, 0] != null) { if (obj.CurrentWorksheet[i, 1] != null) { AutoCompleteData.Add(new MyCompletionData(obj.CurrentWorksheet[i, 0].ToString(), obj.CurrentWorksheet[i, 1].ToString())); } } } obj.Dispose(); } } if (EdLib.HasFile(path_CurrentPackage, true)) { //sheet.SetColumnsWidth(0, 1, 50); IsCurrentPackageSteamWorkshop = false; var pos = GetPath(path_CurrentPackage) + "\\Database\\"; if (path_CurrentPackage.Contains("steamapps")) { IsCurrentPackageSteamWorkshop = true; } //return; try { if (IsCSVLoader) { LoadCSV(pos); } else { if (EdLib.HasFile(pos + "database.xlsx")) { ReoMain.Load(pos + "database.xlsx", unvell.ReoGrid.IO.FileFormat.Excel2007); } else { ReoMain.Load(pos + "database.xls", unvell.ReoGrid.IO.FileFormat.Excel2007); } } } catch (Exception e) { if (e.Message.Contains("ZipFile")) { //直接读取--- csv LoadCSV(pos); } else { EdLib.AskMsg("读取资料库时发生严重异常,错误信息:\n" + e.ToString() + "\n" + e.Message); return; } } ReoMain.Readonly = IsCurrentPackageSteamWorkshop; foreach (var item in reoGridControl2.Worksheets) { item.NameTextColor = EdLib.CFore; item.NameBackColor = EdLib.CBack; item.SelectionRangeChanged += Item_SelectionRangeChanged; if (item.Name == "Card") { ReoMain.CurrentWorksheet = item; } } LoadSheet(); return; } }
public void LoadCardSheet() { var sheet = reoGridControl2.CurrentWorksheet; sheet.SetColumnsWidth(0, 1, 100); for (int i = 0; i < sheet.ColumnCount; i++) { if (sheet[0, i] == null) { continue; } var name = sheet[0, i].ToString().ToLower(); if (name == "displayname") { sheet.AutoFitColumnWidth(i, true); } if (name == "id") { for (int d = 1; d < sheet.RowCount; d++) { if (sheet[d, i] == null) { continue; } sheet.Cells[d, i].Style.HAlign = ReoGridHorAlign.Left; sheet.AutoFitRowHeight(d, false); sheet.SetRowsHeight(d, 1, 20); } } if (name == "code" || name == "description") { sheet.SetColumnsWidth(i, sheet.RowCount, 250); for (int d = 1; d < sheet.RowCount; d++) { if (sheet[d, i] == null) { continue; } sheet.Cells[d, i].Style.VAlign = ReoGridVerAlign.Top; sheet.Cells[d, i].Style.TextWrap = TextWrapMode.WordBreak; sheet.AutoFitRowHeight(d, false); sheet.SetRowsHeight(d, 1, 20); } //sheet.AutoFitColumnWidth(i, true); } } return; for (int i = 0; i < sheet.RowCount; i++) { object save = sheet[i, 0]; if (save != null) { var pos = Form1.GetPath(Form1.path_CurrentPackage) + "\\CardArt\\" + save.ToString().Trim() + ".png"; if (EdLib.HasFile(pos, false)) { Image image = Image.FromFile(pos); var imgCell = new ImageCell(image, ImageCellViewMode.Zoom); imgCell.ViewMode = ImageCellViewMode.Zoom; sheet[i, 0] = imgCell; //sheet.SetRowsHeight(i, 1, 50); } } } }
private void Item_SelectionRangeChanged(object sender, unvell.ReoGrid.Events.RangeEventArgs e) { if (e == null) { return; } var cellLine = e.Range.StartPos.Row; if (Editing != null) { string local; if (Editing.Data == null) { local = ""; } else { local = Editing.Data.ToString(); } if (local != lastMainEdtiorText) { mainEditor.Text = local; } } if (Editing != null && !IsCurrentPackageSteamWorkshop) { reoGridControl2.CurrentWorksheet[Editing.Position] = GetClear(mainEditor.Text); reoGridControl2.CurrentWorksheet.Cells[Editing.Position].Style.TextWrap = TextWrapMode.WordBreak; reoGridControl2.CurrentWorksheet.AutoFitRowHeight(Editing.Position.Row, false); reoGridControl2.CurrentWorksheet.SetRowsHeight(Editing.Position.Row, 1, 20); mainEditor.Text = ""; Editing = null; } var nameSheet = reoGridControl2.CurrentWorksheet.Name; for (int i = 0; i < 25; i++) { if (reoGridControl2.CurrentWorksheet[0, i] == null) { continue; } var name = reoGridControl2.CurrentWorksheet[0, i].ToString().ToLower(); var current = reoGridControl2.CurrentWorksheet[cellLine, i]; if (cellLine == 0) { return; } if (current == null) { if ((nameSheet == "Card" && name == "code") || (nameSheet == "Character" && name == "fieldcode")) { Editing = reoGridControl2.CurrentWorksheet.Cells[cellLine, i]; } if (nameSheet == "Card") { switch (name) { case "id": if (EdLib.HasFile(EdLib.path_AppData + "\\icon.png") && lastPicture != EdLib.path_AppData + "\\icon.png") { Image image = System.Drawing.Image.FromFile(EdLib.path_AppData + "\\icon.png"); pictureBox1.Image = image; lastPicture = EdLib.path_AppData + "\\icon.png"; } break; case "displayname": label4.Text = "无名称"; break; case "description": label5.Text = "无描述"; break; case "energyreq": label6.Text = "0"; break; case "range": label7.Text = "0"; break; case "code": mainEditor.Text = ""; break; case "spreadradius": label8.Text = "0"; break; case "backgroundid": var pos2 = Form1.GetPath("{game}\\TetraProject_Data\\StreamingAssets\\Packages\\Builtin\\CardBackground\\5\\Card.png"); if (EdLib.HasFile(pos2, false) && lastPictureBG != pos2) { lastPictureBG = pos2; Image image = System.Drawing.Image.FromFile(pos2); pictureBox3.Image = image; } break; } } if (nameSheet == "Character") { switch (name) { case "fieldcode": mainEditor.Text = ""; break; case "id": if (EdLib.HasFile(EdLib.path_AppData + "\\icon.png") && lastASE != EdLib.path_AppData + "\\icon.png") { Image image = System.Drawing.Image.FromFile(EdLib.path_AppData + "\\icon.png"); pictureBox4.Image = image; lastASE = EdLib.path_AppData + "\\icon.png"; } break; } } continue; } if (nameSheet == "Card") { switch (name) { case "id": var pos = Form1.GetPath(Form1.path_CurrentPackage) + "\\CardArt\\" + current.ToString().Trim() + ".png"; if (EdLib.HasFile(pos, false) && lastPicture != pos) { lastPicture = pos; Image image = System.Drawing.Image.FromFile(pos); pictureBox1.Image = image; } else if (EdLib.HasFile(EdLib.path_AppData + "\\icon.png") && lastPicture != EdLib.path_AppData + "\\icon.png") { Image image = System.Drawing.Image.FromFile(EdLib.path_AppData + "\\icon.png"); pictureBox1.Image = image; lastPicture = EdLib.path_AppData + "\\icon.png"; } break; case "displayname": label4.Text = current.ToString().Trim(); break; case "description": label5.Text = current.ToString().Trim(); break; case "energyreq": label6.Text = current.ToString().Trim(); break; case "range": label7.Text = current.ToString().Trim(); break; case "code": Editing = reoGridControl2.CurrentWorksheet.Cells[cellLine, i]; OptimizeVision(current.ToString()); lastMainEdtiorText = Editing.Data.ToString(); break; case "spreadradius": label8.Text = current.ToString().Trim(); break; case "backgroundid": var pos2 = Form1.GetPath("{game}\\TetraProject_Data\\StreamingAssets\\Packages\\Builtin\\CardBackground\\" + current.ToString().Trim() + "\\Card.png"); if (EdLib.HasFile(pos2, false) && lastPictureBG != pos2) { lastPictureBG = pos2; Image image = System.Drawing.Image.FromFile(pos2); //pictureBox2.Image = ZoomImage(new Bitmap(image), -25,-25); pictureBox3.Image = image; // pictureBox3.BackgroundImageLayout = ImageLayout.Stretch; //pictureBox3.SizeMode = PictureBoxSizeMode.Zoom; } var pos3 = Form1.GetPath("{game}\\TetraProject_Data\\StreamingAssets\\Packages\\Builtin\\CardBackground\\" + current.ToString().Trim() + "\\CardGlow.png"); if (EdLib.HasFile(pos3, false) && lastPictureBG2 != pos3) { lastPictureBG2 = pos3; Image image = System.Drawing.Image.FromFile(pos3); //pictureBox2.Image = ZoomImage(new Bitmap(image), -25,-25); //pictureBox2.Image = image; //pictureBox2.BackgroundImageLayout = ImageLayout.Stretch; //pictureBox2.SizeMode = PictureBoxSizeMode.Zoom; } break; } } if (nameSheet == "Character") { switch (name) { case "id": var pos = Form1.GetPath(Form1.path_CurrentPackage) + "\\CharacterModel\\" + current.ToString().Trim() + ".ase"; if (EdLib.HasFile(pos, false) && lastASE != pos) { lastASE = pos; var bytes = System.IO.File.ReadAllBytes(pos); var ase = Aseprite.ASEParser.Parse(bytes); if (ase == null) { break; } var image = EdLib.GetImageFromAseCel(ase); if (image != null) { pictureBox4.Image = image; } //pictureBox4.BackgroundImageLayout = ImageLayout.Stretch; //pictureBox4.SizeMode = PictureBoxSizeMode.Zoom; } break; case "fieldcode": Editing = reoGridControl2.CurrentWorksheet.Cells[cellLine, i]; OptimizeVision(current.ToString()); lastMainEdtiorText = Editing.Data.ToString(); break; default: break; } } } //Text = e.Cell.Data.ToString(); }