Skip to content

Commit

Permalink
・エアロスナップの緩和策を適用
Browse files Browse the repository at this point in the history
・アイコンコンバーターのリサイズ機能が動作していなかったので修正
・HSPのメニュー系ファイルのコミット忘れ
・ダークモード時のステータスバーの描画不具合の修正
  • Loading branch information
inovia committed Jan 2, 2024
1 parent 83f6a5b commit e843304
Show file tree
Hide file tree
Showing 16 changed files with 260 additions and 48 deletions.
7 changes: 7 additions & 0 deletions iconcnv/iconcnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ vector<BYTE> ConvertImageToARGB(
::GlobalUnlock(hg);
}
stream->Release();

//// Debug
//pBitmap->Save(L"C:\\Temp\\test.png", &pngClsid, nullptr);

//std::ofstream file(L"C:\\Temp\\test2.png", std::ios::out | std::ios::binary);
//file.write(reinterpret_cast<const char*>(pngData.data()), pngData.size());
//file.close();
}

return pngData;
Expand Down
4 changes: 4 additions & 0 deletions sakura_core/_main/WinMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "util/std_macro.h"
#include "env/DLLSHAREDATA.h"
#include "hsp/CHsp3DarkMode.h"
#include "config/system_constants.h"

/*!
Windows Entry point
Expand Down Expand Up @@ -77,6 +78,9 @@ int WINAPI wWinMain(
CHsp3DarkMode::PreferredAppMode::APPMODE_ALLOWDARK);
DarkMode.RefreshImmersiveColorPolicyState();
}

// AppUserModelID
::SetCurrentProcessExplicitAppUserModelID( GSTR_APP_USER_MODEL_ID);
}

//開発情報
Expand Down
7 changes: 7 additions & 0 deletions sakura_core/config/system_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,13 @@
//! ビュー
#define GSTR_VIEWNAME (L"HSPSakuraEditorSakuraView" _T(STR_SHAREDATA_VERSION))

// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //
// AppUserModelID //
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //

//! AppUserModelID
#define GSTR_APP_USER_MODEL_ID (L"HSPSakuraEditor.Id" _T(CON_SKR_MACHINE_SUFFIX_) _T(_CODE_SUFFIX_) _T(_DEBUG_SUFFIX_) _T(STR_SHAREDATA_VERSION))

// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //
// リソース //
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //
Expand Down
1 change: 1 addition & 0 deletions sakura_core/env/CShareData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ bool CShareData::InitShareData()
sHSP.m_bHspAssistantAutoStartEnabled = true;
sHSP.m_bUseLegacyLabelAnalysis = false;
sHSP.m_bAutoSaveBeforeCompile = false;
sHSP.m_bAeroSnapMitigation = false;
sHSP.m_bShowDebugWindow = false;
sHSP.m_szCommandLineOption[0] = L'\0';
sHSP.m_szExecuteExternalFile_Name[0] = L'\0';
Expand Down
3 changes: 3 additions & 0 deletions sakura_core/env/CShareData_IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2315,6 +2315,8 @@ void CShareData_IO::IO_HSP(CDataProfile& cProfile, CommonSetting_HSP& hsp)
hsp.m_bUseLegacyLabelAnalysis = false;
if (!cProfile.IOProfileData(pszSecName, LTEXT("AutoSaveBeforeCompile"), hsp.m_bAutoSaveBeforeCompile))
hsp.m_bAutoSaveBeforeCompile = false;
if (!cProfile.IOProfileData(pszSecName, LTEXT("AeroSnapMitigation"), hsp.m_bAeroSnapMitigation))
hsp.m_bAeroSnapMitigation = false;
}
else
{
Expand All @@ -2323,6 +2325,7 @@ void CShareData_IO::IO_HSP(CDataProfile& cProfile, CommonSetting_HSP& hsp)
cProfile.IOProfileData(pszSecName, LTEXT("AssistantAutoStartEnabled"), hsp.m_bHspAssistantAutoStartEnabled);
cProfile.IOProfileData(pszSecName, LTEXT("UseLegacyLabelAnalysis"), hsp.m_bUseLegacyLabelAnalysis);
cProfile.IOProfileData(pszSecName, LTEXT("AutoSaveBeforeCompile"), hsp.m_bAutoSaveBeforeCompile);
cProfile.IOProfileData(pszSecName, LTEXT("AeroSnapMitigation"), hsp.m_bAeroSnapMitigation);
}
}

Expand Down
3 changes: 2 additions & 1 deletion sakura_core/env/CommonSetting.h
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,8 @@ struct CommonSetting_HSP
bool m_bUseLegacyLabelAnalysis; //!< 従来方式のラベル解析を優先する(HSP 3.6互換)
bool m_bAutoSaveBeforeCompile; //!< コンパイル時、未保存のファイルを自動保存する
bool m_bHspAssistantAutoStartFlag; //!< (未保存)HSPアシスタントを自動起動管理フラグ(別プロセスでstaticできないのでここで)
bool m_PADDING[1]; //!< (未保存)未使用: Padding領域
bool m_bAeroSnapMitigation; //!< エアロスナップの緩和策を適用する
bool m_PADDING[256]; //!< (未保存)未使用: Padding領域
};

// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //
Expand Down
4 changes: 2 additions & 2 deletions sakura_core/hsp/CHsp3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,10 +961,10 @@ bool CHsp3::RunIconConverter(HWND hParent) const
args += L"/OUTPUT \"" + fileSavePath + L"\" ";

// /RESIZE フラグを追加
args += L"/RESIZE";
args += L"/RESIZE ";

// /FORCE32BIT フラグを追加
args += L"/FORCE32BIT";
args += L"/FORCE32BIT ";
}

// 実行
Expand Down
10 changes: 10 additions & 0 deletions sakura_core/hsp/CHsp3.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,16 @@ class CHsp3
GetDllShareData().m_Common.m_sHSP.m_bAutoSaveBeforeCompile = bAutoSaveBeforeCompile;
}

inline const bool IsAeroSnapMitigation() const
{
return GetDllShareData().m_Common.m_sHSP.m_bAeroSnapMitigation;
}

inline void SetAeroSnapMitigation(bool bAeroSnapMitigation) const
{
GetDllShareData().m_Common.m_sHSP.m_bAutoSaveBeforeCompile = bAeroSnapMitigation;
}

bool InitKeyword(CKeyWordSetMgr& keywordMgr) const;

private:
Expand Down
76 changes: 76 additions & 0 deletions sakura_core/hsp/CHsp3MenuItemParser.cpp
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; // 正常に終了
}
36 changes: 36 additions & 0 deletions sakura_core/hsp/CHsp3MenuItemParser.h
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);
};
6 changes: 6 additions & 0 deletions sakura_core/prop/CPropComHSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ void CPropHSP::SetData( HWND hwndDlg )

/* コンパイル時、未保存のファイルを自動保存する(&S) */
::CheckDlgButtonBool(hwndDlg, IDC_CHECK_bAutoSaveBeforeCompile, m_Common.m_sHSP.m_bAutoSaveBeforeCompile);

/* エアロスナップの緩和策を適用する(&M) */
::CheckDlgButtonBool(hwndDlg, IDC_CHECK_bAeroSnapMitigation, m_Common.m_sHSP.m_bAeroSnapMitigation);
return;
}

Expand All @@ -130,5 +133,8 @@ int CPropHSP::GetData( HWND hwndDlg )
/* コンパイル時、未保存のファイルを自動保存する(&S) */
m_Common.m_sHSP.m_bAutoSaveBeforeCompile = ::IsDlgButtonCheckedBool(hwndDlg, IDC_CHECK_bAutoSaveBeforeCompile);

/* エアロスナップの緩和策を適用する(&M) */
m_Common.m_sHSP.m_bAeroSnapMitigation = ::IsDlgButtonCheckedBool(hwndDlg, IDC_CHECK_bAeroSnapMitigation);

return TRUE;
}
2 changes: 1 addition & 1 deletion sakura_core/sakura_rc.h
Original file line number Diff line number Diff line change
Expand Up @@ -797,8 +797,8 @@
#define IDC_HSP_CHECK2 1740
#define IDC_CHECK_bAutoRunHSPAssistant 1740
#define IDC_CHECK_bUseLegacyLabelAnalysis 1741
#define IDC_CHECK_bUseLegacyLabelAnalysis2 1742
#define IDC_CHECK_bAutoSaveBeforeCompile 1742
#define IDC_CHECK_bAeroSnapMitigation 1743
#define IDS_AUTHOR_PAGE 4054
#define IDS_ABOUT_DESCRIPTION 4056
#define IDD_TYPELIST 5000
Expand Down
42 changes: 24 additions & 18 deletions sakura_core/sakura_rc.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1731,11 +1731,13 @@ FONT 9, "MS Pゴシック", 0, 0, 0x1
BEGIN
CONTROL "HSPアシスタントを自動起動する(&A)",IDC_CHECK_bAutoRunHSPAssistant,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,14,206,10
GROUPBOX "",-1,3,3,218,66,WS_GROUP
GROUPBOX "",-1,3,3,218,118,WS_GROUP
CONTROL "従来方式のラベル解析を優先する(HSP 3.6互換)(&L)",IDC_CHECK_bUseLegacyLabelAnalysis,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,29,205,10
CONTROL "コンパイル時、未保存のファイルを自動保存する(&S)",IDC_CHECK_bAutoSaveBeforeCompile,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,43,205,10
CONTROL "エアロスナップの緩和策を適用する(&M)",IDC_CHECK_bAeroSnapMitigation,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,57,205,10
END


Expand Down Expand Up @@ -2421,9 +2423,24 @@ BEGIN
F_OPEN_POWERSHELL_AS_ADMIN "管理者としてPowerShellを開く"
F_HSP_LABEL_LIST "HSPのラベル・関数一覧..."
F_HSP_COMPILE_RUN "コンパイル + 実行"
END

STRINGTABLE
BEGIN
F_HSP_OPEN_PAINT_TOOL "ペイントツールを開く..."
F_HSP_SEARCH_KEYWORD "HSPキーワード検索..."
F_HSP_OPEN_PG_MANUAL "HSPプログラミング・マニュアルを開く..."
F_HSP_OPEN_FUNC_REF "HSP命令リファレンスを開く..."
F_HSP_OPEN_MANUAL_INDEX "HSPマニュアル目次..."
F_HSP_OPEN_HELP_SOURCE_EDITOR "Help Source Editorを開く..."
F_HSP_RUN_ICON_CONVERTER "アイコンコンバーター起動..."
F_HSP_OPEN_DOCUMENT "ドキュメントを開く"
F_HSP_JUMP_DEFINITION "定義へ移動"
F_HSP_JUMP_ALL_REFERENCES "すべての参照を検索"
F_HSP_RUN_HSP3_UPDATER "機能の追加と削除..."
F_CUSTMENU_1 "カスタムメニュー1"
F_CUSTMENU_2 "カスタムメニュー2"
F_CUSTMENU_3 "カスタムメニュー3"
END

STRINGTABLE
Expand Down Expand Up @@ -2972,21 +2989,6 @@ BEGIN
F_HSP_OPEN_HGIMG4_TOOL "HGIMG4ツールを開く..."
END

STRINGTABLE
BEGIN
F_HSP_OPEN_PAINT_TOOL "ペイントツールを開く..."
F_HSP_SEARCH_KEYWORD "HSPキーワード検索..."
F_HSP_OPEN_PG_MANUAL "HSPプログラミング・マニュアルを開く..."
F_HSP_OPEN_FUNC_REF "HSP命令リファレンスを開く..."
F_HSP_OPEN_MANUAL_INDEX "HSPマニュアル目次..."
F_HSP_OPEN_HELP_SOURCE_EDITOR "Help Source Editorを開く..."
F_HSP_RUN_ICON_CONVERTER "アイコンコンバーター起動..."
F_HSP_RUN_HSP3_UPDATER "機能の追加と削除..."
F_CUSTMENU_1 "カスタムメニュー1"
F_CUSTMENU_2 "カスタムメニュー2"
F_CUSTMENU_3 "カスタムメニュー3"
END

STRINGTABLE
BEGIN
F_MENU_RBUTTON "右クリックメニュー"
Expand Down Expand Up @@ -3040,7 +3042,7 @@ BEGIN
F_CUSTMENU_LIST "カスタムメニューリスト"
F_USERMACRO_LIST "登録済みマクロリスト"
F_PLUGIN_LIST "プラグインコマンドリスト"
F_HSPINIMENU_LIST "HSP用Menu.txtリスト"
F_HSPINIMENU_LIST "HSP用Menu.txtリスト"
END

STRINGTABLE
Expand Down Expand Up @@ -3895,7 +3897,11 @@ BEGIN
STR_PROPCOMMON_EDITING "編集"
STR_PROPCOMMON_FILE "ファイル"
STR_PROPCOMMON_BACKUP "バックアップ"
STR_PROPCOMMON_HSP "HSP"
END

STRINGTABLE
BEGIN
STR_PROPCOMMON_HSP "HSP"
END

STRINGTABLE
Expand Down
Loading

0 comments on commit e843304

Please sign in to comment.