Skip to content

feat: port game switcher from NextUI with preview path fix#68

Open
charveey wants to merge 1 commit intoTurro75:mainfrom
Ayoka-Solutions:feat-game-switcher
Open

feat: port game switcher from NextUI with preview path fix#68
charveey wants to merge 1 commit intoTurro75:mainfrom
Ayoka-Solutions:feat-game-switcher

Conversation

@charveey
Copy link
Copy Markdown

Port game switcher feature from NextUI by @frysee with modifications
to properly build preview_path for save state display. See #44

Original work: LoveRetro#27

Changes from original:

  • Fix preview_path building in readyResumePath() to support switcher
  • Build state path and preview path based on selected slot number
  • Set has_preview flag when preview file exists
  • Use getStatePath() to determine correct preview location

Port game switcher feature from NextUI by @frysee with modifications
to properly build preview_path for save state display.

Original work: LoveRetro#27

Changes from original:
- Fix preview_path building in readyResumePath() to support switcher
- Build state path and preview path based on selected slot number
- Set has_preview flag when preview file exists
- Use getStatePath() to determine correct preview location
Copy link
Copy Markdown
Author

@charveey charveey left a comment

Choose a reason for hiding this comment

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

My modifications

The original NextUI code didn't build preview_path properly, causing previews not to display. I added this to readyResumePath() function:

// Build the state path for preview
char state_path[256];
getStatePath(path, state_path);

// Build preview_path based on the slot
if (last_selected_slot > 0) {
    sprintf(preview_path, "%s/%s.state%d.png", state_path, rom_file, last_selected_slot);
} else {
    sprintf(preview_path, "%s/%s.state.png", state_path, rom_file);
}

has_preview = exists(preview_path);

This ensures preview_path is properly set so the switcher can actually load and display the preview images.

Testing

So far the code has only been tested on MM+ :

  • Tested with games that have save states
  • Tested with games without save states
  • Verified LEFT/RIGHT navigation and wraparound
  • Confirmed Y button removes games from recents
  • Verified A button launches selected game

@Turro75
Copy link
Copy Markdown
Owner

Turro75 commented Dec 29, 2025

Thanks for Your contribute, I tested it Yesterday, in minui it shows the preview of the original scale and rotation ignoring the view at the time of exiting from the game, since minarch actually blit on the screen the frame rotated according to the real screen orientation I use this snippet in minarch to get the current snapshot:

menu.bitmap = rotozoomSurface(screengame, (4-gamerotate)*90.0, 1.0, 1);
SDL_Surface* backing = SDL_CreateRGBSurface(SDL_SWSURFACE,DEVICE_WIDTH,DEVICE_HEIGHT,FIXED_DEPTH,RGBA_MASK_565); 
//	SDL_BlitSurface(menu.bitmap, NULL, backing, NULL);
SDL_BlitScaled(menu.bitmap, NULL, backing, NULL);

I don't like the removal of the item from recent, I would prefer creating a new savestate at every game exit (i.e. in slot 0) then coloring the selection dot or the frame around preview in red to make the user aware that the selected preview is the one created at last exit.
Let me think about it a while.

@fengfrw
Copy link
Copy Markdown

fengfrw commented Dec 29, 2025

It is suggested to use a method that does not occupy the user's selected storage location to save game switching points. I think this is more reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants