Skip to content

Commit

Permalink
Fix #13 #14 #15
Browse files Browse the repository at this point in the history
  • Loading branch information
user-grinch committed Nov 11, 2024
1 parent 3b82911 commit c37c1a5
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 6 deletions.
13 changes: 13 additions & 0 deletions include/hotkeys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ void Editor::Run()
static_cast<long>(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);
Expand Down
2 changes: 1 addition & 1 deletion src/imgarchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/imgarchive.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions src/parser/pc_v1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void ParserPCv1::Open(IMGArchive* pArc)
stream.read(reinterpret_cast<char*>(&entry.Offset), sizeof(entry.Offset));
stream.read(reinterpret_cast<char*>(&entry.Sector), sizeof(entry.Sector));

std::vector<char> buffer(24);
std::vector<char> buffer(32);
stream.read(buffer.data(), buffer.size());
Utils::ConvertUtf8ToWide(buffer.data(), entry.FileName, buffer.size());

Expand Down Expand Up @@ -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");
}

Expand Down
2 changes: 1 addition & 1 deletion src/parser/pc_v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
1 change: 1 addition & 0 deletions src/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <fstream>
#include <filesystem>
Expand Down

0 comments on commit c37c1a5

Please sign in to comment.