diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL.ncb b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL.ncb index 31c740e..1bc28b9 100644 Binary files a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL.ncb and b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL.ncb differ diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL.suo b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL.suo index 8dbd2af..b90ed74 100644 Binary files a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL.suo and b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL.suo differ diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/AssemblyInfo.cpp b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/AssemblyInfo.cpp index 841b355..ac4e3e7 100644 --- a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/AssemblyInfo.cpp +++ b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/AssemblyInfo.cpp @@ -31,7 +31,7 @@ using namespace System::Security::Permissions; // すべての値を指定するか、下のように '*' を使ってリビジョンおよびビルド番号を // 既定値にすることができます: -[assembly:AssemblyVersionAttribute("1.0.*")]; +[assembly:AssemblyVersionAttribute("1.1.*")]; [assembly:ComVisible(false)]; diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/Debug/BuildLog.htm b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/Debug/BuildLog.htm index d1b92aa..eb2553d 100644 Binary files a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/Debug/BuildLog.htm and b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/Debug/BuildLog.htm differ diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/Form1.h b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/Form1.h index 80dba94..c1be512 100644 --- a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/Form1.h +++ b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/Form1.h @@ -35,6 +35,12 @@ namespace SheetCheckerTWL { private: System::Windows::Forms::DataGridViewTextBoxColumn^ colTitle; private: System::Windows::Forms::DataGridViewTextBoxColumn^ colSrl; private: System::Windows::Forms::DataGridViewTextBoxColumn^ colSheet; + + + + + + System::Boolean ^bReadSheet; public: @@ -92,10 +98,10 @@ namespace SheetCheckerTWL { /// void InitializeComponent(void) { - System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle17 = (gcnew System::Windows::Forms::DataGridViewCellStyle()); - System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle18 = (gcnew System::Windows::Forms::DataGridViewCellStyle()); - System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle19 = (gcnew System::Windows::Forms::DataGridViewCellStyle()); - System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle20 = (gcnew System::Windows::Forms::DataGridViewCellStyle()); + System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle5 = (gcnew System::Windows::Forms::DataGridViewCellStyle()); + System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle6 = (gcnew System::Windows::Forms::DataGridViewCellStyle()); + System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle7 = (gcnew System::Windows::Forms::DataGridViewCellStyle()); + System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle8 = (gcnew System::Windows::Forms::DataGridViewCellStyle()); this->tboxSrl = (gcnew System::Windows::Forms::TextBox()); this->tboxSheet = (gcnew System::Windows::Forms::TextBox()); this->butSrl = (gcnew System::Windows::Forms::Button()); @@ -154,15 +160,15 @@ namespace SheetCheckerTWL { // // gridCompare // - dataGridViewCellStyle17->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter; - dataGridViewCellStyle17->BackColor = System::Drawing::SystemColors::Control; - dataGridViewCellStyle17->Font = (gcnew System::Drawing::Font(L"MS UI Gothic", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + dataGridViewCellStyle5->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter; + dataGridViewCellStyle5->BackColor = System::Drawing::SystemColors::Control; + dataGridViewCellStyle5->Font = (gcnew System::Drawing::Font(L"MS UI Gothic", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, static_cast(128))); - dataGridViewCellStyle17->ForeColor = System::Drawing::SystemColors::WindowText; - dataGridViewCellStyle17->SelectionBackColor = System::Drawing::SystemColors::Highlight; - dataGridViewCellStyle17->SelectionForeColor = System::Drawing::SystemColors::HighlightText; - dataGridViewCellStyle17->WrapMode = System::Windows::Forms::DataGridViewTriState::True; - this->gridCompare->ColumnHeadersDefaultCellStyle = dataGridViewCellStyle17; + dataGridViewCellStyle5->ForeColor = System::Drawing::SystemColors::WindowText; + dataGridViewCellStyle5->SelectionBackColor = System::Drawing::SystemColors::Highlight; + dataGridViewCellStyle5->SelectionForeColor = System::Drawing::SystemColors::HighlightText; + dataGridViewCellStyle5->WrapMode = System::Windows::Forms::DataGridViewTriState::True; + this->gridCompare->ColumnHeadersDefaultCellStyle = dataGridViewCellStyle5; this->gridCompare->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize; this->gridCompare->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(3) {this->colTitle, this->colSrl, this->colSheet}); @@ -170,12 +176,12 @@ namespace SheetCheckerTWL { this->gridCompare->Name = L"gridCompare"; this->gridCompare->RowHeadersVisible = false; this->gridCompare->RowTemplate->Height = 21; - this->gridCompare->Size = System::Drawing::Size(363, 148); + this->gridCompare->Size = System::Drawing::Size(363, 170); this->gridCompare->TabIndex = 6; // // tboxResult // - this->tboxResult->Location = System::Drawing::Point(294, 273); + this->tboxResult->Location = System::Drawing::Point(294, 289); this->tboxResult->Name = L"tboxResult"; this->tboxResult->ReadOnly = true; this->tboxResult->Size = System::Drawing::Size(100, 19); @@ -184,7 +190,7 @@ namespace SheetCheckerTWL { // labResult // this->labResult->AutoSize = true; - this->labResult->Location = System::Drawing::Point(235, 276); + this->labResult->Location = System::Drawing::Point(235, 292); this->labResult->Name = L"labResult"; this->labResult->Size = System::Drawing::Size(53, 12); this->labResult->TabIndex = 8; @@ -201,26 +207,26 @@ namespace SheetCheckerTWL { // // colTitle // - dataGridViewCellStyle18->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter; - dataGridViewCellStyle18->BackColor = System::Drawing::Color::FromArgb(static_cast(static_cast(224)), + dataGridViewCellStyle6->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter; + dataGridViewCellStyle6->BackColor = System::Drawing::Color::FromArgb(static_cast(static_cast(224)), static_cast(static_cast(224)), static_cast(static_cast(224))); - this->colTitle->DefaultCellStyle = dataGridViewCellStyle18; + this->colTitle->DefaultCellStyle = dataGridViewCellStyle6; this->colTitle->HeaderText = L""; this->colTitle->Name = L"colTitle"; this->colTitle->Width = 120; // // colSrl // - dataGridViewCellStyle19->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter; - this->colSrl->DefaultCellStyle = dataGridViewCellStyle19; + dataGridViewCellStyle7->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter; + this->colSrl->DefaultCellStyle = dataGridViewCellStyle7; this->colSrl->HeaderText = L"SRL"; this->colSrl->Name = L"colSrl"; this->colSrl->Width = 120; // // colSheet // - dataGridViewCellStyle20->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter; - this->colSheet->DefaultCellStyle = dataGridViewCellStyle20; + dataGridViewCellStyle8->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter; + this->colSheet->DefaultCellStyle = dataGridViewCellStyle8; this->colSheet->HeaderText = L"提出確認書"; this->colSheet->Name = L"colSheet"; this->colSheet->Width = 120; @@ -229,7 +235,7 @@ namespace SheetCheckerTWL { // this->AutoScaleDimensions = System::Drawing::SizeF(6, 12); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; - this->ClientSize = System::Drawing::Size(428, 302); + this->ClientSize = System::Drawing::Size(429, 321); this->Controls->Add(this->labVersion); this->Controls->Add(this->labResult); this->Controls->Add(this->tboxResult); @@ -313,6 +319,17 @@ private: tmp2 = tadver.ToString() + " (" + tadver.ToString( "X04" ) + ")"; this->gridCompare->Rows->Add( "TADバージョン", "-", tmp2); + if( this->sheet->IsUnnecessaryRating ) + { + this->gridCompare->Rows->Add( "TITLE_TYPE", "-", "TWL_APP"); + System::Int32 last = this->gridCompare->Rows->Count - 2; + this->gridCompare->Rows[ last ]->DefaultCellStyle->ForeColor = System::Drawing::Color::Blue; // 青色で強調 + } + else + { + this->gridCompare->Rows->Add( "TITLE_TYPE", "-", "TWL_GAME"); + } + if( *this->error == SheetCheckerError::NOERROR ) { this->tboxResult->Text = "OK"; diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.cpp b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.cpp index ff6eaab..73478b8 100644 --- a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.cpp +++ b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.cpp @@ -15,21 +15,35 @@ using namespace SheetCheckerTWL; // ------------------------------------------------------------------ System::Int32 parseOption( array ^args, SheetCheckerContext ^context ); +int consoleRun( array ^args, int argc, SheetCheckerContext ^context ); +int consoleOptionRun( array ^args, int argc, SheetCheckerContext ^context ); int printResult( SheetCheckerContext ^context, ROM_Header *rh, SheetItem ^item, - System::String ^srlfile, System::String ^sheetfile, System::UInt16 srlcrc ); -int consoleRun( array ^args, int argc, SheetCheckerContext ^hContext ); + System::String ^srlfile, System::String ^sheetfile, System::UInt16 srlcrc, SheetCheckerError error ); + +// ------------------------------------------------------------------ +// main +// ------------------------------------------------------------------ [STAThreadAttribute] int main(array ^args) { - SheetCheckerContext ^hContext = gcnew SheetCheckerContext; + SheetCheckerContext ^context = gcnew SheetCheckerContext; // getopt - int argc = parseOption( args, hContext ); + int argc = parseOption( args, context ); if( argc > 0 ) { - int ret = consoleRun( args, argc, hContext ); + int ret; + if( context->bResult || context->bSubmitVersion || context->bTadVersion || + context->bSubmitVersion || context->bUnnecessaryRating ) + { + ret = consoleOptionRun( args, argc, context ); + } + else + { + ret = consoleRun( args, argc, context ); + } return ret; } @@ -43,49 +57,142 @@ int main(array ^args) } // ------------------------------------------------------------------ -// コンソール処理 +// コンソール処理 (ノーマル) // ------------------------------------------------------------------ -int consoleRun( array ^args, int argc, SheetCheckerContext ^hContext ) +int consoleRun( array ^args, int argc, SheetCheckerContext ^context ) { + SheetCheckerError error = SheetCheckerError::NOERROR; ROM_Header rh; memset( (void*)&rh, 0, sizeof(ROM_Header) ); - SheetItem ^hItem = gcnew SheetItem; + SheetItem ^item = gcnew SheetItem; // 引数処理 if( argc != 2 ) { - hContext->ErrorCode = SheetCheckerError::ERROR_ARG; - printResult( hContext, &rh, hItem, nullptr, nullptr, 0 ); - return -1; + error = SheetCheckerError::ERROR_ARG; + printResult( context, &rh, item, nullptr, nullptr, 0, error ); + return ((int)error); } - System::String ^hSrlFile = args[0]; - System::String ^hSheetFile = args[1]; + System::String ^romfile = args[0]; + System::String ^sheetfile = args[1]; // ROMヘッダの読み込み - if( !readRomHeader( hSrlFile, &rh ) ) + if( !readRomHeader( romfile, &rh ) ) { - hContext->ErrorCode = SheetCheckerError::ERROR_READ_SRL; - printResult( hContext, &rh, hItem, hSrlFile, hSheetFile, 0 ); - return -1; + error = SheetCheckerError::ERROR_READ_SRL; + printResult( context, &rh, item, romfile, sheetfile, 0, error ); + return ((int)error); } System::UInt16 crc; - getWholeCRCInFile( hSrlFile, &crc ); + getWholeCRCInFile( romfile, &crc ); // 提出確認書の読み込み - if( !readSheet( hSheetFile, hItem ) ) + if( !readSheet( sheetfile, item ) ) { - hContext->ErrorCode = SheetCheckerError::ERROR_READ_SHEET; - printResult( hContext, &rh, hItem, hSrlFile, hSheetFile, crc ); - return -1; + error = SheetCheckerError::ERROR_READ_SHEET; + printResult( context, &rh, item, romfile, sheetfile, crc, error ); + return ((int)error); } // 一致判定 - hContext->ErrorCode = checkSheet( &rh, crc, hItem ); + error = checkSheet( &rh, crc, item ); + printResult( context, &rh, item, romfile, sheetfile, crc, error ); // 結果を表形式で表示 - // 結果表示 - int ret = printResult( hContext, &rh, hItem, hSrlFile, hSheetFile, crc ); - return ret; + return ((int)error); +} + +// ------------------------------------------------------------------ +// コンソール処理 (オプション) +// ------------------------------------------------------------------ + +int consoleOptionRun( array ^args, const int argc, SheetCheckerContext ^context ) +{ + SheetCheckerError error = SheetCheckerError::NOERROR; + System::String ^romfile; + System::String ^sheetfile; + + // 引数解析 + switch( argc ) + { + case 1: + sheetfile = args[0]; + if( context->bResult ) // このオプションのときだけは引数1つを許さない + { + error = SheetCheckerError::ERROR_ARG; + printf( "%d", (int)error ); + return ((int)error); + } + break; + + case 2: + romfile = args[0]; + sheetfile = args[1]; + break; + + default: + error = SheetCheckerError::ERROR_ARG; + printf( "%d", (int)error ); + return ((int)error); + break; + } + + // 提出確認書の読み込み + SheetItem ^item = gcnew SheetItem; + if( !readSheet( sheetfile, item ) ) + { + error = SheetCheckerError::ERROR_READ_SHEET; + printf( "%d", (int)error ); + return ((int)error); + } + + // 引数が1つのときはSRLとの比較をしない + if( argc == 2 ) + { + ROM_Header rh; + memset( (void*)&rh, 0, sizeof(ROM_Header) ); + + // ROMヘッダの読み込み + if( !readRomHeader( romfile, &rh ) ) + { + error = SheetCheckerError::ERROR_READ_SHEET; + printf( "%d", (int)error ); + return ((int)error); + } + System::UInt16 crc; + getWholeCRCInFile( romfile, &crc ); + + // 比較 + error = checkSheet( &rh, crc, item ); + }//if( argc == 2 ) + + // 結果出力はオプションによって異なる(エラーのときには共通) + if( error != SheetCheckerError::NOERROR ) + { + if( context->bResult ) + { + printf( "0" ); // このパスは成功のときのみ + } + else if( context->bTadVersion ) + { + System::UInt16 tadver = item->RomVersion; + tadver = (tadver << 8) | item->SubmitVersion; + printf( "%d", tadver ); + } + else if( context->bSubmitVersion ) + { + printf( "%d", item->SubmitVersion ); + } + else if( context->bUnnecessaryRating ) + { + printf( "%d", (item->IsUnnecessaryRating)?1:0 ); + } + } + else + { + printf( "%d", (int)error ); + } + return ((int)error); } // ------------------------------------------------------------------ @@ -119,282 +226,40 @@ SheetCheckerError checkSheet( ROM_Header *rh, System::UInt16 crc, SheetItem ^ite // ------------------------------------------------------------------ int printResult( SheetCheckerContext ^context, ROM_Header *rh, SheetItem ^item, - System::String ^srlfile, System::String ^sheetfile, System::UInt16 srlcrc ) + System::String ^srlfile, System::String ^sheetfile, System::UInt16 srlcrc, SheetCheckerError error ) { System::UInt16 tadver = item->RomVersion; tadver = (tadver << 8) | item->SubmitVersion; // 通常の表示 - if( !context->bSubmitVersion && !context->bResult && !context->bTadVersion && !context->bUnnecessaryRating ) - { - Console::WriteLine( "" ); - Console::WriteLine( "SRL: " + srlfile ); - Console::WriteLine( "Sheet: " + sheetfile ); - Console::WriteLine( "" ); + Console::WriteLine( "" ); + Console::WriteLine( "SRL: " + srlfile ); + Console::WriteLine( "Sheet: " + sheetfile ); + Console::WriteLine( "" ); - printf( " SRL Sheet\n" ); - printf( "---------------------------------------\n" ); - printf( "InitialCode: %c%c%c%c %c%c%c%c\n", - rh->s.game_code[0], rh->s.game_code[1], rh->s.game_code[2], rh->s.game_code[3], - item->GameCode[0], item->GameCode[1], item->GameCode[2], item->GameCode[3] ); - printf( "RemasterVersion: %02X %02X\n", rh->s.rom_version, item->RomVersion ); - printf( "File CRC: %04X %04X\n", srlcrc, item->FileCRC ); - printf( "---------------------------------------\n" ); - printf( "Rating Display: %s\n", (item->IsUnnecessaryRating)?"Unnecessary":"Necessary" ); - printf( "---------------------------------------\n" ); - printf( "SubmitVersion: - %d (%02X)\n", item->SubmitVersion, item->SubmitVersion ); - printf( "TAD Version: %d (%04X)\n", tadver, tadver ); - printf( "---------------------------------------\n" ); - printf( "Result: " ); - if( context->ErrorCode == SheetCheckerError::NOERROR ) - { - printf( "OK\n" ); - } - else - { - printf( "NG (%d)\n", context->ErrorCode ); - } - } - - // オプションのときの表示 - if( context->bSubmitVersion ) + printf( " SRL Sheet\n" ); + printf( "---------------------------------------\n" ); + printf( "InitialCode: %c%c%c%c %c%c%c%c\n", + rh->s.game_code[0], rh->s.game_code[1], rh->s.game_code[2], rh->s.game_code[3], + item->GameCode[0], item->GameCode[1], item->GameCode[2], item->GameCode[3] ); + printf( "RemasterVersion: %02X %02X\n", rh->s.rom_version, item->RomVersion ); + printf( "File CRC: %04X %04X\n", srlcrc, item->FileCRC ); + printf( "---------------------------------------\n" ); + printf( "Rating Display: %s\n", (item->IsUnnecessaryRating)?"Unnecessary":"Necessary" ); + printf( "---------------------------------------\n" ); + printf( "SubmitVersion: - %d (%02X)\n", item->SubmitVersion, item->SubmitVersion ); + printf( "TAD Version: %d (%04X)\n", tadver, tadver ); + printf( "---------------------------------------\n" ); + printf( "Result: " ); + if( error == SheetCheckerError::NOERROR ) { - if( context->ErrorCode == SheetCheckerError::NOERROR ) - { - printf( "%d", item->SubmitVersion ); - } - else - { - printf( "%d", context->ErrorCode ); // エラーのときはエラーコード - } + printf( "OK\n" ); } - if( context->bTadVersion ) + else { - if( context->ErrorCode == SheetCheckerError::NOERROR ) - { - printf( "%d", tadver ); - } - else - { - printf( "%d", context->ErrorCode ); - } - } - if( context->bUnnecessaryRating ) - { - if( context->ErrorCode == SheetCheckerError::NOERROR ) - { - printf( "%d", (item->IsUnnecessaryRating)?1:0 ); - } - else - { - printf( "%d", context->ErrorCode ); - } - } - if( context->bResult ) - { - printf( "%d", context->ErrorCode ); - } - - if( context->ErrorCode != SheetCheckerError::NOERROR ) - { - return -1; + printf( "NG (%d)\n", (int)error ); } return 0; } -// ------------------------------------------------------------------ -// ROMヘッダの読み込み -// ------------------------------------------------------------------ - -System::Boolean readRomHeader( System::String ^srlfile, ROM_Header *rh ) -{ - FILE *fp = NULL; - const char *pchFilename = - (const char*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi( srlfile ).ToPointer(); - - // ファイルを開いてROMヘッダのみ読み出す - if( fopen_s( &fp, pchFilename, "rb" ) != NULL ) - { - return false; - } - (void)fseek( fp, 0, SEEK_SET ); // ROMヘッダはsrlの先頭から - - // 1バイトをsizeof(~)だけリード (逆だと返り値がsizeof(~)にならないので注意) - if( fread( (void*)rh, 1, sizeof(ROM_Header), fp ) != sizeof(ROM_Header) ) - { - fclose( fp ); - return false; - } - fclose( fp ); - return true; -} - -// ------------------------------------------------------------------ -// 提出確認書の読み込み -// ------------------------------------------------------------------ - -System::Boolean readSheet( System::String ^sheetfile, SheetItem ^item ) -{ - // XSLによってXML変換 - System::String ^tmpfile = ".\\temp" + System::DateTime::Now.ToString("yyyyMMddHHmmss") + ".xml"; - System::Xml::Xsl::XslCompiledTransform ^xslt = gcnew System::Xml::Xsl::XslCompiledTransform; - System::String ^xslpath = System::IO::Path::GetDirectoryName( System::Reflection::Assembly::GetEntryAssembly()->Location ) - + "\\extract_sheet.xsl"; - try - { - //Console::WriteLine( "xslpath: " + xslpath ); - xslt->Load( xslpath ); - xslt->Transform( sheetfile, tmpfile ); - } - catch( System::Exception ^ex ) - { - (void)ex; - //Console::WriteLine( "XSLT Error" ); - return false; - } - // 変換したXMLを読み込み - System::Xml::XmlDocument ^doc = gcnew System::Xml::XmlDocument; - try - { - doc->Load( tmpfile ); - } - catch( System::Exception ^ex ) - { - (void)ex; - //Console::WriteLine( "Load error" ); - return false; - } - - // XMLからデータを抽出 - System::Xml::XmlElement ^root = doc->DocumentElement; - System::String ^text; - try - { - item->Media = getXPathText( root, "/Sheet/Media" ); - - text = getXPathText( root, "/Sheet/GameCode" ); - char code[4]; - int i; - for(i=0; i<4; i++ ) - { - code[i] = (char)text[i]; - } - item->GameCode = code; // 代入したらコピーするように property を定義している - - text = getXPathText( root, "/Sheet/RomVersion" ); - if( text->Contains( "(" ) ) // 事前版のときには"(事前版)"が入る - { - text = text->Remove( text->IndexOf("(") ); - } - text = text->Trim(); - item->RomVersion = System::Byte::Parse( text, System::Globalization::NumberStyles::AllowHexSpecifier ); - - text = getXPathText( root, "/Sheet/CRC" ); - if( text->Contains( "0x" ) ) - { - text = text->Substring( text->IndexOf("x")+1 ); - } - item->FileCRC = System::UInt16::Parse( text, System::Globalization::NumberStyles::AllowHexSpecifier ); - - text = getXPathText( root, "/Sheet/SubmitVersion" ); - char c = (char)text[0]; - if( ('G' <= c) && (c <= 'Z') ) // Fより上はG..Zで表現されていく(可能性あり) - { - item->SubmitVersion = c - 'G' + 16; - } - else if( ('g' <= c) && (c <= 'z') ) - { - item->SubmitVersion = c - 'g' + 16; - } - else - { - item->SubmitVersion = System::Byte::Parse( text, System::Globalization::NumberStyles::AllowHexSpecifier ); - } - - text = getXPathText( root, "/Sheet/IsUnnecessaryRating" ); - if( !System::String::IsNullOrEmpty( text ) && text->Equals( "○" ) ) - { - item->IsUnnecessaryRating = true; - } - else - { - item->IsUnnecessaryRating = false; - } - } - catch( System::Exception ^ex ) - { - (void)ex; - return false; - } - - // 中間ファイルを削除 - if( System::IO::File::Exists( tmpfile ) ) - { - System::IO::File::Delete( tmpfile ); - } - return true; -} - -// ------------------------------------------------------------------ -// getopt -// ------------------------------------------------------------------ - -// @ret オプションを除いたときのargc -System::Int32 parseOption( array ^args, SheetCheckerContext ^context ) -{ - System::Collections::Generic::List ^indexList - = gcnew System::Collections::Generic::List; - - int numopt = 0; - int i; - for( i=0; i < args->Length; i++ ) - { - if( args[i]->StartsWith( "-s" ) ) - { - context->bSubmitVersion = true; - numopt++; - } - else if( args[i]->StartsWith( "-r" ) ) - { - context->bResult = true; - numopt++; - } - else if( args[i]->StartsWith( "-t" ) ) - { - context->bTadVersion = true; - numopt++; - } - else if( args[i]->StartsWith( "-u" ) ) - { - context->bUnnecessaryRating = true; - numopt++; - } - else if( !args[i]->StartsWith( "-" ) ) // オプションでない引数のindexを記録 - { - indexList->Add(i); - } - } - i=0; - for each( System::Int32 index in indexList ) // オプションでない引数を前につめていく - { - args[i] = args[index]; - i++; - } - return (args->Length - numopt); -} - -// ------------------------------------------------------------------ -// XMLタグ検索 -// ------------------------------------------------------------------ - -// @ret テキストが存在するときそのテキストを返す。存在しないときnullptr。 -System::String^ getXPathText( System::Xml::XmlElement ^root, System::String ^xpath ) -{ - System::Xml::XmlNode ^tmp = root->SelectSingleNode( xpath ); - if( tmp && tmp->FirstChild && tmp->FirstChild->Value ) - { - return tmp->FirstChild->Value; - } - return nullptr; -} diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.h b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.h index 483f424..5d4a5cf 100644 --- a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.h +++ b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.h @@ -24,45 +24,19 @@ enum class SheetCheckerError // 実行Context ref class SheetCheckerContext { -private: - System::Boolean ^hbSubmitVersion; // オプションフラグ - System::Boolean ^hbResult; - System::Boolean ^hbTadVersion; - System::Boolean ^hbUnnecessaryRating; - SheetCheckerError ^hErrorCode; // エラー情報 +public: + property System::Boolean bSubmitVersion; // オプションフラグ + property System::Boolean bResult; + property System::Boolean bTadVersion; + property System::Boolean bUnnecessaryRating; public: SheetCheckerContext() { - this->hbSubmitVersion = gcnew System::Boolean(false); - this->hbResult = gcnew System::Boolean(false); - this->hbTadVersion = gcnew System::Boolean(false); - this->hErrorCode = gcnew SheetCheckerError( SheetCheckerError::NOERROR ); + this->bSubmitVersion = false; + this->bResult = false; + this->bTadVersion = false; + this->bUnnecessaryRating = false; } - property System::Boolean bSubmitVersion - { - void set( System::Boolean flg ){ this->hbSubmitVersion = gcnew System::Boolean(flg); } - System::Boolean get(){ return *this->hbSubmitVersion; } - }; - property System::Boolean bResult - { - void set( System::Boolean flg ){ this->hbResult = gcnew System::Boolean(flg); } - System::Boolean get(){ return *this->hbResult; } - }; - property System::Boolean bTadVersion - { - void set( System::Boolean flg ){ this->hbTadVersion = gcnew System::Boolean(flg); } - System::Boolean get(){ return *this->hbTadVersion; } - }; - property System::Boolean bUnnecessaryRating - { - void set( System::Boolean flg ){ this->hbUnnecessaryRating = gcnew System::Boolean(flg); } - System::Boolean get(){ return *this->hbUnnecessaryRating; } - }; - property SheetCheckerError ErrorCode - { - void set( SheetCheckerError code ){ this->hErrorCode = gcnew SheetCheckerError(code); } - SheetCheckerError get(){ return *this->hErrorCode; } - }; }; // 提出確認書内の情報 @@ -70,24 +44,28 @@ ref class SheetItem { private: char *pGameCode; - System::Byte ^hRomVersion; - System::UInt16 ^hFileCRC; - System::Byte ^hSubmitVersion; - System::Boolean ^hIsUnnecessaryRating; -public: System::String ^hMedia; +public: + property System::Byte RomVersion; + property System::UInt16 FileCRC; + property System::Byte SubmitVersion; + property System::Boolean IsUnnecessaryRating; public: SheetItem() { this->pGameCode = new char[4]; std::memset( this->pGameCode, 0, 4 ); - this->hRomVersion = gcnew System::Byte(0); - this->hFileCRC = gcnew System::UInt16(0); - this->hSubmitVersion = gcnew System::Byte(0); - this->hMedia = gcnew System::String(""); - this->hIsUnnecessaryRating = gcnew System::Boolean(false); + this->hMedia = gcnew System::String(""); + this->RomVersion = 0; + this->FileCRC = 0; + this->SubmitVersion = 0; + this->IsUnnecessaryRating = false; } ~SheetItem() + { + this->!SheetItem(); + } + !SheetItem() { delete []this->pGameCode; } @@ -96,21 +74,6 @@ public: void set( char* p ){ memcpy( this->pGameCode, p, 4 ); } char* get(){ return this->pGameCode; } } - property System::Byte RomVersion - { - void set( System::Byte v ){ *this->hRomVersion = v; } - System::Byte get(){ return *this->hRomVersion; } - } - property System::UInt16 FileCRC - { - void set( System::UInt16 v ){ *this->hFileCRC = v; } - System::UInt16 get(){ return *this->hFileCRC; } - } - property System::Byte SubmitVersion - { - void set( System::Byte v ){ *this->hSubmitVersion = v; } - System::Byte get(){ return *this->hSubmitVersion; } - } property System::String ^Media { void set( System::String ^str ) @@ -118,15 +81,10 @@ public: if( str != nullptr ) this->hMedia = System::String::Copy(str); else - this->hMedia = gcnew System::String(""); + this->hMedia = gcnew System::String(""); // nullptrが代入されることはない } System::String^ get(){ return System::String::Copy( this->hMedia ); } } - property System::Boolean IsUnnecessaryRating - { - void set( System::Boolean b ){ *this->hIsUnnecessaryRating = b; } - System::Boolean get(){ return *this->hIsUnnecessaryRating; } - } }; diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.vcproj b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.vcproj index 5cfb462..e156b73 100644 --- a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.vcproj +++ b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.vcproj @@ -209,6 +209,10 @@ RelativePath=".\SheetCheckerTWL.cpp" > + +