Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,7 @@ export function Actions() {
}, [validEmulators, validProfiles]);

return (
<div
className={cn(
"flex relative",
"[&_*[data-radix-popper-content-wrapper]]:contents sm:[&_*[data-radix-popper-content-wrapper]]:block",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These classes are necessary for the popover to correctly render on mobile. Can we look into a different solution here?

It would be helpful to have a description of the root cause for this visual bug.

)}
>
<div className="flex relative">
<div
className={cn(
"w-full *:w-full rounded-l-lg sm:rounded-tl-none overflow-hidden border-r-2",
Expand All @@ -97,9 +92,9 @@ export function Actions() {
</DropdownMenuTrigger>

<DropdownMenuContent
portal={false}
align="start"
className="absolute inset-x-0 top-full mt-2 sm:mt-0"
sideOffset={8}
className="w-[var(--radix-dropdown-menu-trigger-width)]"
>
<DropdownMenuSub>
<DropdownMenuSubTrigger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export function GameFiles() {
className={cn(
"relative grid gap-px w-full",
"grid-flow-col grid-cols-[minmax(0,1fr)_auto] ",
"[&_[data-radix-popper-content-wrapper]]:contents",
)}
>
<Select
Expand Down Expand Up @@ -155,9 +154,9 @@ export function GameFiles() {
</DropdownMenuTrigger>

<DropdownMenuContent
portal={false}
align="start"
className={cn("absolute inset-x-0 sm:left-auto top-full mt-1")}
sideOffset={8}
className={cn("w-[var(--radix-dropdown-menu-trigger-width)] sm:w-auto")}
>
<DropdownMenuGroup>
<DropdownMenuItem
Expand Down
50 changes: 50 additions & 0 deletions packages/codegen/localstorage-polyfill.cjs
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is duplicated in #447 , please remove from this PR for clarity.

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Minimal localStorage polyfill for Node environments where `localStorage`
// exists but does not implement the standard Storage interface (e.g. Node 25).
// This is only used during code generation (buf/protoc-gen-es) and keeps
// everything in-memory for the lifetime of the process.

(() => {
try {
const ls = globalThis.localStorage;
if (ls && typeof ls.getItem === 'function') {
// A compatible implementation already exists; do nothing.
return;
}
} catch {
// Accessing localStorage might throw in some environments; fall through to polyfill.
}

const store = new Map();

const localStoragePolyfill = {
getItem(key) {
const value = store.get(String(key));
return value === undefined ? null : value;
},
setItem(key, value) {
store.set(String(key), String(value));
},
removeItem(key) {
store.delete(String(key));
},
clear() {
store.clear();
},
key(index) {
const keys = Array.from(store.keys());
return index >= 0 && index < keys.length ? keys[index] : null;
},
get length() {
return store.size;
},
};

Object.defineProperty(globalThis, 'localStorage', {
value: localStoragePolyfill,
configurable: true,
enumerable: false,
writable: true,
});
})();


2 changes: 1 addition & 1 deletion packages/codegen/project.json
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is duplicated in #447 , please remove from this PR for clarity.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"executor": "nx:run-commands",
"cache": true,
"options": {
"command": "pnpm buf generate",
"command": "NODE_OPTIONS=--require=./localstorage-polyfill.cjs pnpm buf generate",
"cwd": "{projectRoot}"
},
"inputs": [
Expand Down
46 changes: 39 additions & 7 deletions plugins/retrom-plugin-launcher/src/commands.rs
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is duplicated in #447 , please remove from this PR for clarity.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::{desktop::GameProcess, LauncherExt, Result};
use prost::Message;
use retrom_codegen::retrom::{
client::installation::InstallationStatus, emulator::OperatingSystem, GamePlayStatusUpdate,
GetGamePlayStatusPayload, GetLocalEmulatorConfigsRequest, PlayGamePayload, PlayStatus,
StopGamePayload,
GetGamePlayStatusPayload, GetGameFilesRequest, GetLocalEmulatorConfigsRequest, PlayGamePayload,
PlayStatus, StopGamePayload,
};
use retrom_plugin_config::ConfigExt;
use retrom_plugin_installer::InstallerExt;
Expand All @@ -14,7 +14,7 @@ use tauri::{
command, http::HeaderValue, AppHandle, Runtime, WebviewUrl, WebviewWindow, WindowEvent,
};
use tokio::sync::Mutex;
use tracing::{info, instrument};
use tracing::{info, instrument, warn};
use walkdir::WalkDir;

#[command]
Expand Down Expand Up @@ -57,12 +57,44 @@ pub(crate) async fn play_game<R: Runtime>(app: AppHandle<R>, payload: Vec<u8>) -
.emulator_profile
.expect("No emulator profile provided");
let emulator = payload.emulator.expect("No emulator provided");
let maybe_default_game_file = payload.file;
let mut maybe_default_game_file = payload.file;

if maybe_default_game_file.is_none() {
if let Some(default_file_id) = game.default_file_id {
let mut game_client = app.get_game_client().await;
match game_client
.get_game_files(GetGameFilesRequest {
ids: vec![default_file_id],
include_deleted: None,
})
.await
{
Ok(response) => {
let default_file = response
.into_inner()
.game_files
.into_iter()
.find(|file| file.id == default_file_id);

if default_file.is_none() {
warn!("Default file {} not found in response", default_file_id);
}

maybe_default_game_file = default_file;
}
Err(err) => {
warn!(
"Failed to fetch default file {} from service: {}",
default_file_id, err
);
}
}
}
}

let maybe_default_file = maybe_default_game_file
.clone()
.map(|file| file.path)
.map(PathBuf::from);
.as_ref()
.map(|file| PathBuf::from(&file.path));

if emulator.libretro_name.is_some()
&& emulator
Expand Down