forked from sakura-editor/sakura
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
・アイコンコンバーターのリサイズ機能が動作していなかったので修正 ・HSPのメニュー系ファイルのコミット忘れ ・ダークモード時のステータスバーの描画不具合の修正
- Loading branch information
inovia
committed
Jan 2, 2024
1 parent
83f6a5b
commit e843304
Showing
16 changed files
with
260 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// CHsp3MenuItemParser.cpp | ||
|
||
#include "StdAfx.h" | ||
#include "CHsp3MenuItemParser.h" | ||
#include <fstream> | ||
#include <sstream> | ||
#include <algorithm> | ||
|
||
// 文字列の先頭と末尾のスペースやタブを除去する関数 | ||
std::wstring CHsp3MenuItemParser::trim(const std::wstring& str) | ||
{ | ||
size_t first = str.find_first_not_of(L" \t"); | ||
if (first == std::wstring::npos) return L""; | ||
size_t last = str.find_last_not_of(L" \t"); | ||
return str.substr(first, (last - first + 1)); | ||
} | ||
|
||
// CSVファイルをパースする関数 | ||
ErrorCode CHsp3MenuItemParser::parse(const std::wstring& filePath, std::vector<MenuItem>& items) | ||
{ | ||
// Shift_JISでファイルを開く | ||
std::ifstream file(filePath, std::ios::binary); | ||
if (!file.is_open()) | ||
{ | ||
return FILE_OPEN_ERROR; // ファイルが開けなかった場合はエラーコードを返す | ||
} | ||
|
||
// ファイルの内容をShift_JISで読み取る | ||
std::string sjisContent((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>()); | ||
file.close(); | ||
|
||
// Shift_JISからUTF-16に変換 | ||
int requiredSize = MultiByteToWideChar( | ||
CP_ACP, 0, sjisContent.c_str(), sjisContent.size(), nullptr, 0); | ||
std::wstring utf16Content(requiredSize, 0); | ||
MultiByteToWideChar( | ||
CP_ACP, 0, sjisContent.c_str(), sjisContent.size(), &utf16Content[0], requiredSize); | ||
|
||
// 各行をパースする | ||
std::wstringstream ss(utf16Content); | ||
std::wstring line; | ||
while (std::getline(ss, line, L'\n')) | ||
{ | ||
// CRLFの場合、'\r'を除去する | ||
if (!line.empty() && line.back() == L'\r') | ||
{ | ||
line.pop_back(); | ||
} | ||
|
||
// 各行のカンマの数をチェック | ||
size_t numCommas = std::count(line.begin(), line.end(), L','); | ||
if (numCommas != 2) | ||
{ | ||
return PARSE_ERROR; // カンマの数が想定と異なる場合はエラーを返す | ||
} | ||
|
||
std::wstringstream lineStream(line); | ||
std::wstring menuName, runtimeName, axFileName; | ||
|
||
// カンマで区切られた各項目を取得 | ||
if (!std::getline(lineStream, menuName, L',') || | ||
!std::getline(lineStream, runtimeName, L',') || | ||
!std::getline(lineStream, axFileName, L',')) | ||
{ | ||
return PARSE_ERROR; // 項目の取得に失敗した場合はエラーを返す | ||
} | ||
|
||
// トリムして結果のベクタに追加 | ||
items.push_back( | ||
{ | ||
trim(menuName), trim(runtimeName), trim(axFileName) | ||
}); | ||
} | ||
|
||
return SUCCESS; // 正常に終了 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// CHsp3MenuItemParser.h | ||
|
||
#pragma once | ||
|
||
#include <windows.h> | ||
#include <vector> | ||
#include <string> | ||
|
||
// メニューアイテムを表す構造体 | ||
struct MenuItem | ||
{ | ||
// もし、メンバを入れ替える際は注意してください。 | ||
// C++20 以前の構造体の初期化を使っているところがあります。 | ||
|
||
std::wstring menuName; // メニュー名 | ||
std::wstring runtimeName; // ランタイム名 | ||
std::wstring axFileName; // AXファイル名 | ||
}; | ||
|
||
// エラーコードの列挙型 | ||
enum ErrorCode | ||
{ | ||
SUCCESS = 0, // 成功 | ||
FILE_OPEN_ERROR, // ファイルオープンのエラー | ||
FILE_READ_ERROR, // ファイルの読み取りエラー | ||
PARSE_ERROR // パースのエラー | ||
}; | ||
|
||
class CHsp3MenuItemParser | ||
{ | ||
public: | ||
ErrorCode parse(const std::wstring& filePath, std::vector<MenuItem>& items); | ||
|
||
private: | ||
std::wstring trim(const std::wstring& str); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.