Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Gamepad/keyboard navigation support #239

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/app/css/launcher.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
transition: 0.3s ease-in-out;
background-color: transparent;


margin: 20px;
position: relative;
border-radius: 0px;
box-sizing: border-box;
flex-basis: calc(100% - 10px);
}
Expand Down Expand Up @@ -111,7 +111,8 @@
.contentMenu li:last-child {margin-right: 0px}
.contentMenu li:first-child {margin-left: 0px}

.contentMenu li:hover {opacity: 0.7}
.contentMenu li:hover,
.contentMenu li.active-selection {opacity: 0.7}

.contentMenu li[active] {
opacity: 1.0;
Expand Down Expand Up @@ -305,7 +306,8 @@ button:has(img):has(span) img {
transition: opacity 0.2s ease-in-out;
}

button:has(img):has(span):hover img {
button:has(img):has(span):hover img,
button:has(img):has(span).active-selection img {
opacity: 1.0;
}

Expand All @@ -315,7 +317,8 @@ button:has(img):has(span) span {
transition: right 0.2s ease-in-out;
}

button:has(img):has(span):hover span {
button:has(img):has(span):hover span,
button:has(img):has(span).active-selection span {
right: 0.1em;
}

Expand Down
23 changes: 23 additions & 0 deletions src/app/css/selection.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#selection {
z-index: 99999999999999;

transition: 0.15s ease-in-out;
transition-property:
opacity, border-radius, background,
transform, width, height, top, left;

position: fixed;
pointer-events: none;
transform: scale(1.0);
background: rgba(255, 255, 255, 0.3);
border-radius: calc(var(--padding) / 2);
}

:has(.active-selection.scroll-selection) #selection {
background: rgba(255, 255, 255, 0.2);
}

#selection.keyboard-selecting,
#selection.controller-selecting {
transform: scale(1.1);
}
2 changes: 1 addition & 1 deletion src/app/css/theming.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ a.disabled:not("[onclick='kill('game')']") {
pointer-events: none;
}

a:hover {
a:hover, a.active-selection {
filter: brightness(80%) !important;
}

Expand Down
14 changes: 8 additions & 6 deletions src/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<meta charset="utf-8">
</head>
<body>
<div id="selection"></div>

<div id="tooltip">Test</div>

<div id="bgHolder"></div>
Expand Down Expand Up @@ -33,7 +35,7 @@
<div id="overlay" onclick="popups.set_all(false)"></div>
<div class="popup" id="options">
<div class="misc">
<input class="search" placeholder="%%gui.search%%">
<input class="search default-selection" placeholder="%%gui.search%%">
<button id="apply" onclick="settings.popup.apply();settings.popup.toggle(false)">
<img src="icons/apply.png">
%%gui.settings.save%%
Expand Down Expand Up @@ -251,7 +253,7 @@ <h2>%%gui.settings.title.misc%%</h2>
</div>

<div class="misc">
<input class="search" placeholder="%%gui.search%%">
<input class="search default-selection" placeholder="%%gui.search%%">
<button id="filter" onclick="browser.filters.toggle()">
<img src="icons/filter.png">
</button>
Expand All @@ -264,7 +266,7 @@ <h2>%%gui.settings.title.misc%%</h2>
</div>
</div>
<div class="popup small blur" id="preview">
<div class="misc fixed vertical">
<div class="misc fixed vertical default-selection">
<button id="close" onclick="browser.preview.hide()">
<img src="icons/close.png">
</button>
Expand All @@ -273,7 +275,7 @@ <h2>%%gui.settings.title.misc%%</h2>
</button>
</div>

<webview></webview>
<webview class="scroll-selection"></webview>
</div>

<nav class="gamesContainer">
Expand All @@ -297,7 +299,7 @@ <h2>%%gui.settings.title.misc%%</h2>
<a id="setpath" href="#" onclick="gamepath.set()" class="disable-when-installing">%%gui.setpath%%</a>
</div>
</div>
<div id="vpReleaseNotes" class="hidden section"></div>
<div id="vpReleaseNotes" class="scroll-selection hidden section"></div>
<div id="vpInfo" class="hidden section">
<h2>%%viper.info.links%%</h2>
<ul>
Expand Down Expand Up @@ -357,7 +359,7 @@ <h2>%%viper.info.credits%%</h2>
</div>
</div>
</div>
<div id="nsRelease" class="hidden section"></div>
<div id="nsRelease" class="scroll-selection hidden section"></div>
</div>
</div>

Expand Down
6 changes: 0 additions & 6 deletions src/app/js/dom_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ document.addEventListener("drop", (e) => {
mods.install_from_path(e.dataTransfer.files[0].path);
})

document.body.addEventListener("keyup", (e) => {
if (e.key == "Escape") {
popups.hide_last();
}
})

document.body.addEventListener("click", (e) => {
if (e.target.tagName.toLowerCase() === "a"
&& e.target.protocol != "file:") {
Expand Down
Loading
Loading