Skip to content

Commit

Permalink
Various QoL changes and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Aemony committed Jan 28, 2024
1 parent 298af96 commit 3c69152
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 31 deletions.
1 change: 1 addition & 0 deletions include/SKIF.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ struct SKIF_Signals { // Used for command line arguments

// External declarations

extern PopupState GameMenu; // Library: used to show context menu for games
extern PopupState ServiceMenu; // Library / Service Mode: used to show an options menu for the service when right clicking
extern PopupState EmptySpaceMenu; // Library: used to show an options menu for the library when right clicking around the play/service buttons
extern PopupState AddGamePopup; // Library: show an add custom game prompt
Expand Down
2 changes: 1 addition & 1 deletion include/stores/Steam/app_record.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ struct app_record_s {
std::string used = ""; // Unix timestamp (in string) of when the game was last used
std::string used_formatted = ""; // Friendly human-readable representation of the Unix timestamp
int hidden = 0; // Visibility
int pinned = 0; // Is app pinned? (0 = no; 1 = yes; 2 = Special K)
int pinned = 0; // Is app pinned? (0 = no; 1 = yes; 99 = Special K)
} skif;

struct extended_config_s {
Expand Down
5 changes: 3 additions & 2 deletions src/SKIF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2519,7 +2519,7 @@ wWinMain ( _In_ HINSTANCE hInstance,
_drag_drop.Revoke (SKIF_ImGui_hWnd);


if (ImGui::BeginTabItem (" " ICON_FA_LIST_CHECK " Monitor ", nullptr, ImGuiTabItemFlags_NoTooltip | ((SKIF_Tab_ChangeTo == UITab_Monitor) ? ImGuiTabItemFlags_SetSelected : ImGuiTabItemFlags_None)))
if (ImGui::BeginTabItem (" " ICON_FA_MICROCHIP " Monitor ", nullptr, ImGuiTabItemFlags_NoTooltip | ((SKIF_Tab_ChangeTo == UITab_Monitor) ? ImGuiTabItemFlags_SetSelected : ImGuiTabItemFlags_None)))
{
SKIF_ImGui_BeginTabChildFrame ();

Expand All @@ -2538,7 +2538,7 @@ wWinMain ( _In_ HINSTANCE hInstance,
hModSpecialK = nullptr;
}

if (ImGui::BeginTabItem (" " ICON_FA_GEAR " Settings ", nullptr, ImGuiTabItemFlags_NoTooltip | ((SKIF_Tab_ChangeTo == UITab_Settings) ? ImGuiTabItemFlags_SetSelected : ImGuiTabItemFlags_None)))
if (ImGui::BeginTabItem (" " ICON_FA_LIST_CHECK " Settings ", nullptr, ImGuiTabItemFlags_NoTooltip | ((SKIF_Tab_ChangeTo == UITab_Settings) ? ImGuiTabItemFlags_SetSelected : ImGuiTabItemFlags_None)))
{
SKIF_ImGui_BeginTabChildFrame ();

Expand Down Expand Up @@ -3275,6 +3275,7 @@ wWinMain ( _In_ HINSTANCE hInstance,


// If there is any popups opened when SKIF is unfocused and not hovered, close them.
// This can probably mistakenly bug out, seeing how the focus state isn't tracked reliable at times
if (! SKIF_ImGui_IsFocused ( ) && ! ImGui::IsAnyItemHovered ( ) && ImGui::IsAnyPopupOpen ( ))
{
// But don't close those of interest
Expand Down
31 changes: 31 additions & 0 deletions src/imgui/imgui_impl_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,39 @@ static HMODULE g_hModXInput = nullptr;
bool SKIF_ImGui_ImplWin32_IsFocused (void)
{
// We should be able to trust g_Focused as it is fed by WM_SETFOCUS and WM_KILLFOCUS
// --- We cannot trust this crap...
//return g_Focused;

#if 1
extern DWORD SKIF_Util_timeGetTime (void);
static DWORD lastTime = SKIF_Util_timeGetTime ( );

// Executes once per frame
if (lastTime != SKIF_Util_timeGetTime ( ))
{
lastTime = SKIF_Util_timeGetTime ( );

if (HWND focused_hwnd = ::GetForegroundWindow ())
{
DWORD
dwWindowOwnerPid = 0;

GetWindowThreadProcessId (
focused_hwnd,
&dwWindowOwnerPid
);

static DWORD
dwPidOfMe = GetCurrentProcessId ();

g_Focused = (dwWindowOwnerPid == dwPidOfMe);
}
}

return g_Focused;

#endif

#if 0
extern HWND SKIF_hWnd;
extern HWND SKIF_ImGui_hWnd;
Expand Down
67 changes: 40 additions & 27 deletions src/tabs/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1871,7 +1871,7 @@ DrawGameContextMenu (app_record_s* pApp)
#endif

// Manage Game
if (ImGui::BeginMenu (ICON_FA_GEAR " Manage"))
if (ImGui::BeginMenu (ICON_FA_GEARS " Manage"))
{
ImGui::BeginGroup ( );
ImVec2 iconPos = ImGui::GetCursorPos ( );
Expand All @@ -1881,7 +1881,7 @@ DrawGameContextMenu (app_record_s* pApp)
pApp->store == app_record_s::Store::Custom ||
pApp->store == app_record_s::Store::GOG);

ImGui::ItemSize (ImVec2 (ImGui::CalcTextSize (ICON_FA_GEARS).x, ImGui::GetTextLineHeight()));
ImGui::ItemSize (ImVec2 (ImGui::CalcTextSize (ICON_FA_GEAR).x, ImGui::GetTextLineHeight()));

ImGui::ItemSize (ImVec2 (ImGui::CalcTextSize ((pApp->skif.pinned > 0) ? ICON_FA_HEART_CRACK : ICON_FA_HEART).x, ImGui::GetTextLineHeight()));

Expand All @@ -1892,7 +1892,7 @@ DrawGameContextMenu (app_record_s* pApp)
{
ImGui::ItemSize (ImVec2 (ImGui::CalcTextSize (ICON_FA_STEAM_SYMBOL).x, ImGui::GetTextLineHeight()));
ImGui::ItemSize (ImVec2 (ImGui::CalcTextSize (ICON_FA_GAMEPAD).x, ImGui::GetTextLineHeight()));
ImGui::ItemSize (ImVec2 (ImGui::CalcTextSize (ICON_FA_GEAR).x, ImGui::GetTextLineHeight()));
ImGui::ItemSize (ImVec2 (ImGui::CalcTextSize (ICON_FA_WRENCH).x, ImGui::GetTextLineHeight()));

ImGui::Separator ( );
}
Expand Down Expand Up @@ -2047,8 +2047,8 @@ DrawGameContextMenu (app_record_s* pApp)
ImGui::SetCursorPos (iconPos);

ImGui::TextColored (
ImColor (200, 200, 200, 255),
ICON_FA_GEARS
ImGui::GetStyleColorVec4 (ImGuiCol_SKIF_Info),
ICON_FA_GEAR
);

ImGui::TextColored (
Expand All @@ -2070,8 +2070,8 @@ DrawGameContextMenu (app_record_s* pApp)
ICON_FA_GAMEPAD );

ImGui::TextColored (
(_registry.iStyle == 2) ? ImColor(0, 0, 0) : ImColor(255, 255, 255),
ICON_FA_GEAR );
ImColor (200, 200, 200, 255),
ICON_FA_WRENCH );

ImGui::Separator ( );
}
Expand Down Expand Up @@ -2865,7 +2865,7 @@ DrawSpecialKContextMenu (app_record_s* pApp)

if (ImGui::Selectable ((pApp->skif.pinned > 0) ? labelUnpin : labelPin, false, ImGuiSelectableFlags_SpanAllColumns))
{
pApp->skif.pinned = (pApp->skif.pinned > 0) ? 0 : 2;
pApp->skif.pinned = (pApp->skif.pinned > 0) ? 0 : 99;

UpdateJsonMetaData ( pApp, true);

Expand Down Expand Up @@ -4195,13 +4195,13 @@ UpdateInjectionStrategy (app_record_s* pApp, std::set <std::string> apptickets)

// PCGamingWiki
pApp->ui.pcgwValue = (pApp->store == app_record_s::Store::Steam || pApp->store == app_record_s::Store::GOG)
? std::to_wstring (pApp->id)
: SK_UTF8ToWideChar (pApp->names.original);
? std::to_wstring (pApp->id)
: SK_UTF8ToWideChar (pApp->names.original);

pApp->ui.pcgwLink = ((pApp->store == app_record_s::Store::GOG) ? L"https://www.pcgamingwiki.com/api/gog.php?page="
: (pApp->store == app_record_s::Store::Steam) ? L"https://www.pcgamingwiki.com/api/appid.php?appid="
: L"https://www.pcgamingwiki.com/w/index.php?search=")
+ pApp->ui.pcgwValue;
: (pApp->store == app_record_s::Store::Steam) ? L"https://www.pcgamingwiki.com/api/appid.php?appid="
: L"https://www.pcgamingwiki.com/w/index.php?search=")
+ pApp->ui.pcgwValue;

// Steam Branches
pApp->ui.branches.clear ();
Expand Down Expand Up @@ -4800,8 +4800,12 @@ SKIF_UI_Tab_DrawLibrary (void)
// Special handling for non-Steam owners of Special K / SKIF
if (isSpecialK)
{
app.first = "Special K";
app.second.skif.pinned = 2; // Default to pinned
app.first = "Special K";

// Default values that needs to be set
app.second.skif.pinned = 99; // Default to pinned
app.second.ui.pcgwValue = std::to_wstring (app.second.id);
app.second.ui.pcgwLink = L"https://www.pcgamingwiki.com/api/appid.php?appid=" + app.second.ui.pcgwValue;
}

// Regular handling for the remaining Steam games
Expand Down Expand Up @@ -4839,7 +4843,7 @@ SKIF_UI_Tab_DrawLibrary (void)

// Special K defaults to pinned
if (isSpecialK)
keyPinned = 2; // Needed as otherwise we'd overwrite it below
keyPinned = 99; // Needed as otherwise we'd overwrite it below

if (key != nullptr && ! key.empty())
{
Expand Down Expand Up @@ -5606,12 +5610,10 @@ SKIF_UI_Tab_DrawLibrary (void)
ImGui::Button (ICON_FA_MAGNIFYING_GLASS);
ImGui::PopItemFlag ( );
ImGui::SameLine ( );

ImGui::PushStyleColor (ImGuiCol_NavHighlight, ImVec4(0,0,0,0));

ImGui::InputTextEx ("###AppListFilterField", "", charFilterTmp, MAX_PATH,
ImVec2 (300.0f * SKIF_ImGui_GlobalDPIScale - (showClearBtn ? fTopClearX : 0.0f), 0.0f),
ImGuiInputTextFlags_AutoSelectAll, 0, nullptr);
ImGui::PopStyleColor ( ); // ImGuiCol_NavHighlight

ImGui::PopStyleColor ( ); // ImGuiCol_Text

Expand All @@ -5629,6 +5631,12 @@ SKIF_UI_Tab_DrawLibrary (void)

if (bFilterActive)
allowShortcutCtrlA = false;
else if (ImGui::IsItemFocused ( ) && ! ImGui::IsItemHovered( ) && ImGui::IsAnyMouseDown( ))
{
// Clear highlight from filter box
ImGuiContext& g = *ImGui::GetCurrentContext();
g.NavDisableHighlight = false;
}

ImGui::SameLine ( );

Expand Down Expand Up @@ -5709,11 +5717,16 @@ SKIF_UI_Tab_DrawLibrary (void)

#pragma region GamesList

ImGuiWindowFlags flags = ImGuiWindowFlags_AlwaysUseWindowPadding;

if (! _registry.bHorizonMode)
flags |= ImGuiWindowFlags_NavFlattened;

ImGui::PushStyleColor (ImGuiCol_ScrollbarBg, ImVec4(0,0,0,0));
ImGui::BeginChild ( "###AppListInset",
ImVec2 ( (sizeList.x - ImGui::GetStyle().WindowPadding.x / 2.0f),
(sizeList.y * SKIF_ImGui_GlobalDPIScale) - (ImGui::GetStyle().FramePadding.x - 2.0f) - (fTop2.y - fTop1.y) ), (_registry.bUIBorders),
ImGuiWindowFlags_NavFlattened | ImGuiWindowFlags_AlwaysUseWindowPadding );
flags);
ImGui::BeginGroup ( );

auto _HandleItemSelection = [&](bool isIconMenu = false) ->
Expand Down Expand Up @@ -5812,7 +5825,7 @@ SKIF_UI_Tab_DrawLibrary (void)
continue;

// Separate pinned from unpinned
if (app.second.skif.pinned)
if (app.second.skif.pinned > 0)
pinned++;
else if (pinned > 0)
{
Expand Down Expand Up @@ -5943,8 +5956,8 @@ SKIF_UI_Tab_DrawLibrary (void)

if ( app.second.id == selection.appid &&
app.second.store == selection.store &&
sort_changed &&
(! ImGui::IsItemVisible ()) )
sort_changed /* &&
(! ImGui::IsItemVisible ()) */ )
{
sort_changed = false;
selection.reset ( );
Expand Down Expand Up @@ -6707,7 +6720,7 @@ SKIF_UI_Tab_DrawLibrary (void)

if (pApp != nullptr)
{
if (ImGui::BeginPopup ("GameContextMenu", ImGuiWindowFlags_NoMove))
if (ImGui::BeginPopup ("###GameContextMenu", ImGuiWindowFlags_NoMove))
{
// Context menu should not have any navigation highlight (white border around items)
ImGui::PushStyleColor (ImGuiCol_NavHighlight, ImVec4(0,0,0,0));
Expand All @@ -6724,14 +6737,14 @@ SKIF_UI_Tab_DrawLibrary (void)
// ImGui::CloseCurrentPopup ();

ImGui::PopStyleColor ( );
ImGui::EndPopup ();
ImGui::EndPopup ( );
}

// This is below the menu because it allows us to open the menu on the next frame,
// after the cache and whatnot has been updated.
if (GameMenu == PopupState_Open)
{
ImGui::OpenPopup ("GameContextMenu");
ImGui::OpenPopup ("###GameContextMenu");
GameMenu = PopupState_Closed;
}
}
Expand Down Expand Up @@ -7831,7 +7844,7 @@ SKIF_UI_Tab_DrawLibrary (void)

if (cached_pinned_load)
{
cached_pinned = (pApp->skif.pinned == 1);
cached_pinned = (pApp->skif.pinned > 0);
cached_pinned_load = false;
}

Expand Down
5 changes: 4 additions & 1 deletion src/utility/skif_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ SKIF_ImGui_StyleColorsDark (ImGuiStyle* dst)
colors[ImGuiCol_DragDropTarget] = ImVec4(0.90f, 0.90f, 0.10f, 1.00f);

// Nav/Modal
colors[ImGuiCol_NavHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); // ImVec4(0.26f, 0.59f, 0.98f, 1.00f); // This is the white border that highlights selected items when using keyboard focus etc
// This is the white border that highlights selected items when using keyboard focus etc
colors[ImGuiCol_NavHighlight] = ImVec4(0.27f, 0.27f, 0.27f, 1.00f);
//colors[ImGuiCol_NavHighlight] = ImVec4(0.48f, 0.48f, 0.48f, 1.00f);
//colors[ImGuiCol_NavHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.50f); // ImVec4(0.80f, 0.80f, 0.80f, 0.20f)
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.50f); // ImVec4(0.80f, 0.80f, 0.80f, 0.35f);
Expand Down

0 comments on commit 3c69152

Please sign in to comment.