diff --git a/include/hotkeys.cpp b/include/hotkeys.cpp index 8d8f601..cb5c785 100644 --- a/include/hotkeys.cpp +++ b/include/hotkeys.cpp @@ -11,7 +11,20 @@ Hotkey::Hotkey(ImGuiKey key1, ImGuiKey key2) { } } +bool IsAppFocused() { + HWND hwnd = GetForegroundWindow(); + if (hwnd == NULL) return false; + + DWORD foregroundProcessID; + GetWindowThreadProcessId(hwnd, &foregroundProcessID); + return foregroundProcessID == GetCurrentProcessId(); +} + bool Hotkey::Pressed(bool noDelay) { + if (!IsAppFocused()) { + return false; + } + if (ImGui::GetTime() - lastUpdate < 0.5) return false; bool key0Pressed = GetAsyncKeyState(codes[0]) & 0x8000; diff --git a/src/editor.cpp b/src/editor.cpp index 3e982d6..dad34cc 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -541,7 +541,7 @@ void Editor::Run() static_cast(Ui::eTheme::SystemDefault))); Ui::Specification spec; - spec.Name = "Grinch_'s IMG Editor v" EDITOR_VERSION; + spec.Name = EDITOR_TITLE; spec.MenuBarFunc = ProcessMenuBar; HMONITOR monitor = MonitorFromWindow(NULL, MONITOR_DEFAULTTONEAREST); diff --git a/src/imgarchive.cpp b/src/imgarchive.cpp index 509cd87..2a48d46 100644 --- a/src/imgarchive.cpp +++ b/src/imgarchive.cpp @@ -167,7 +167,7 @@ void IMGArchive::ImportEntries(ArchiveInfo *pInfo) { pInfo->pArc->ImportEntry(list[i], pInfo->removeExisting); } - pInfo->pArc->AddLogMessage(L"Imported entries"); + pInfo->pArc->AddLogMessage(std::format(L"Imported {} entries", list.size())); pInfo->pArc->bUpdateSearch = true; } diff --git a/src/imgarchive.h b/src/imgarchive.h index 53e3093..3d634de 100644 --- a/src/imgarchive.h +++ b/src/imgarchive.h @@ -17,7 +17,7 @@ struct EntryInfo // archive data uint32_t Offset = 0; // in sectors (each sector is 2048 bytes) uint32_t Sector = 0; // in sectors (each sector is 2048 bytes) - wchar_t FileName[24]; // file name in the archive + wchar_t FileName[32]; // file name in the archive // editor data std::wstring Type = L"Unknown"; diff --git a/src/parser/pc_v1.cpp b/src/parser/pc_v1.cpp index 2dd9c31..4597398 100644 --- a/src/parser/pc_v1.cpp +++ b/src/parser/pc_v1.cpp @@ -20,7 +20,7 @@ void ParserPCv1::Open(IMGArchive* pArc) stream.read(reinterpret_cast(&entry.Offset), sizeof(entry.Offset)); stream.read(reinterpret_cast(&entry.Sector), sizeof(entry.Sector)); - std::vector buffer(24); + std::vector buffer(32); stream.read(buffer.data(), buffer.size()); Utils::ConvertUtf8ToWide(buffer.data(), entry.FileName, buffer.size()); @@ -122,7 +122,7 @@ void ParserPCv1::Save(ArchiveInfo* pInfo) std::ofstream fImg(tempPath, std::ios::binary); std::ifstream fIn(pInfo->pArc->Path, std::ios::binary); - if (!fImg.is_open() || !fIn.is_open()) { + if (!fImg.is_open()) { throw std::runtime_error("Archive open failed"); } diff --git a/src/parser/pc_v2.cpp b/src/parser/pc_v2.cpp index 0a1d63f..2473fda 100644 --- a/src/parser/pc_v2.cpp +++ b/src/parser/pc_v2.cpp @@ -53,7 +53,7 @@ void ParserPCv2::Save(ArchiveInfo* pInfo) std::ofstream fImg(tempPath, std::ios::binary); std::ifstream fIn(pInfo->pArc->Path, std::ios::binary); - if (!fImg.is_open() || !fIn.is_open()) { + if (!fImg.is_open()) { throw std::runtime_error("Archive open failed"); } diff --git a/src/pch.h b/src/pch.h index 2c0e07e..fe9a971 100644 --- a/src/pch.h +++ b/src/pch.h @@ -2,6 +2,7 @@ #define _CRT_SECURE_NO_WARNINGS #define EDITOR_VERSION_NUM "0.60" #define EDITOR_VERSION EDITOR_VERSION_NUM"-beta" +#define EDITOR_TITLE "Grinch_'s IMG Editor v" EDITOR_VERSION #include #include