Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LBL1セクションの可読性を向上させました。誤字報告と要望への対応#13 #14

Merged
merged 1 commit into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
LBL1セクションの可読性を向上させました。誤字報告と要望への対応#13
  • Loading branch information
penguin117117 committed Aug 19, 2021
commit f0e05b2a9baad578428bd115e45ebb4b3ab5af47
11 changes: 10 additions & 1 deletion MSBT_Editor/FileSys/Calculation_System.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

namespace MSBT_Editor.FileSys
{
/// <summary>
/// <para><br/></para>
/// </summary>
class Calculation_System
{
public static string Byte2Char(BinaryReader br, int readchers = 4)
Expand All @@ -30,7 +33,6 @@ public static string Byte2Str_UTF16BE(BinaryReader br, int readchers = 2)
}
catch (Exception e)
{

br.Close();
string[] errorJP01 = { "深刻なエラーが発生しました\n\r[" + e.Message + "]\n\r" + "ErrorNo 1", "エラー" };
string[] errorJP02 = { "「以前に他のMSBTエディタで編集していませんか?」\n\r", "ファイルフォーマット規則が一部破損しているので\n\r", "このエディタでは開くことが出来ません", "このエラーの原因で考えられること" };
Expand Down Expand Up @@ -757,6 +759,9 @@ public static byte[] StringToBytes(string str)
return bs.ToArray();
}

public static void StringToBytesWriter(BinaryWriter bw , string str) {
bw.Write(StringToBytes(str));
}


public static byte[] StringToInt32_byte(string str)
Expand Down Expand Up @@ -792,6 +797,10 @@ public static byte[] StringToInt32_byte(string str)

}

public static void String_Writer(BinaryWriter bw , string str , string EncodingName = "ASCII") {
bw.Write(Encoding.GetEncoding(EncodingName).GetBytes(str));
}



public static string String2TagChecker(string str) {
Expand Down
92 changes: 71 additions & 21 deletions MSBT_Editor/FileSys/Dialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,25 @@
using MSBT_Editor.Formsys;
using MSBT_Editor.MSBFsys;
using MSBT_Editor.Sectionsys;
using System.Drawing;

namespace MSBT_Editor.FileSys
{
/// <summary>
/// ダイアログクラス
/// </summary>
/// <remarks>ファイルを開いたり保存する</remarks>
public class Dialog:objects
public class Dialog : objects
{
private static string Save_Path_Msbt = "None";
private static string Save_Path_Msbf = "None";

/// <summary>
/// ファイルを選択して開く
/// </summary>
/// <param name="filenum">「1の場合MSBT」「2の場合MSBF」</param>
/// <remarks></remarks>
public static void Open(int filenum) {
public static void Open(int filenum)
{

OpenFileDialog ofd = new OpenFileDialog();
ofd.FileName = "default.msbt";
Expand All @@ -38,14 +39,20 @@ public class Dialog:objects
ofd.CheckFileExists = true;
ofd.CheckPathExists = true;

if (ofd.ShowDialog() == DialogResult.OK){
if (ofd.ShowDialog() == DialogResult.OK)
{
FileCheck(ofd.FileName);
}
}



private static bool SaveErrorMessage(string path) {
/// <summary>
/// ファイルパスが設定されているかをチェックします。
/// </summary>
/// <param name="path">Noneの場合trueを返す</param>
/// <returns>path == "None"の場合true</returns>
private static bool CheckSavePath(string path)
{
if (path == "None")
{
MessageBox.Show("ファイルを開くまたは保存先を指定してください", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
Expand All @@ -54,19 +61,45 @@ public class Dialog:objects
return false;
}

public static void Save(MSBT_Header MSBTH) {
//public static void Save(object obj) {
// if (obj is MSBF_Header) {
// MSBF_Header MSBFH = (MSBF_Header)obj;
// MSBFH.Write(Save_Path_Msbf);

// Console.WriteLine("MSBFです");

// }


//}

public static void Save(MSBT_Header MSBTH)
{

var flag = SaveErrorMessage(Save_Path_Msbt);
if (flag) return;
var hasPath = CheckSavePath(Save_Path_Msbt);
if (hasPath) return;
MSBTH.Write(Save_Path_Msbt);
SaveStatusPathString.Text = Save_Path_Msbt;
SaveStatusPathString.ForeColor = Color.Green;
}


public static void Save(MSBF_Header MSBFH)
{
var flag = SaveErrorMessage(Save_Path_Msbf);
if (flag) return;
bool hasNotPath = CheckSavePath(Save_Path_Msbf);
if (hasNotPath) return;
//var OldMsbfBytes = File.ReadAllBytes(Save_Path_Msbf);

//try
//{
MSBFH.Write(Save_Path_Msbf);
//}
//catch
//{
// File.WriteAllBytes(Save_Path_Msbf, OldMsbfBytes);
//}
SaveStatusPathString.Text = Save_Path_Msbf;
SaveStatusPathString.ForeColor = Color.Green;
}

public static void SaveAs(int filenum)
Expand All @@ -85,25 +118,40 @@ public static void SaveAs(int filenum)
//ダイアログを表示する
if (sfd.ShowDialog() == DialogResult.OK)
{
switch (filenum) {
switch (filenum)
{
case 1:
MSBT_Header msbth = new MSBT_Header();
//try
//{

msbth.Write(sfd.FileName);
Save_Path_Msbt = sfd.FileName;
break;
SaveStatusPathString.Text = Save_Path_Msbt;
SaveStatusPathString.ForeColor = Color.Green;
//}
//catch
//{

//}

break;
case 2:
MSBF_Header msbfh = new MSBF_Header();
msbfh.Write(sfd.FileName);
Save_Path_Msbf = sfd.FileName;
SaveStatusPathString.ForeColor = Color.Green;
SaveStatusPathString.Text = Save_Path_Msbf;
break;
default:
MessageBox.Show("このメッセージが表示されている場合\n\r"+"アプリ製作者のミスの可能性が高いので\n\r"+"至急このバージョンの制作者に連絡してください\n\r"+"ErrorName StaffMiss001 ", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("このメッセージが表示されている場合\n\r" + "アプリ製作者のミスの可能性が高いので\n\r" + "至急このバージョンの制作者に連絡してください\n\r" + "ErrorName StaffMiss001 ", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
break;
}
}
}

public static bool MSBF_Item_And_ListItem_Checker(Action action) {
public static bool MSBF_Item_And_ListItem_Checker(Action action)
{
FLW2 flw2 = new FLW2();
FEN1 fen1 = new FEN1();

Expand All @@ -128,11 +176,12 @@ public static bool MSBT_Item_And_ListItem_Checker(Action action)
FLW2 flw2 = new FLW2();
FEN1 fen1 = new FEN1();

var list1_counter = list1.Items.Count == 0;
var list1_counter = MsbtListBox.Items.Count == 0;
var msbt_all_item = MSBT_Data.MSBT_All_Data.Item == default;
var msbt_all_text = MSBT_Data.MSBT_All_Data.Text == default;

if (list1_counter|| (msbt_all_item) || msbt_all_text) {
if (list1_counter || (msbt_all_item) || msbt_all_text)
{
MessageBox.Show("MSBTの項目が設定されていません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
Expand All @@ -147,12 +196,13 @@ public static void FileCheck(string filepath)
{
var file_flag = File.Exists(filepath);
var File_Extension = Path.GetExtension(filepath);

var MSBF_File_Path = Path.ChangeExtension(filepath,"msbf");

var MSBF_File_Path = Path.ChangeExtension(filepath, "msbf");

if (file_flag == false) {
MessageBox.Show("ファイルが存在しません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);

if (file_flag == false)
{
MessageBox.Show("ファイルが存在しません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
}


Expand Down
Loading