achievements

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmulatorInterface

type EmulatorInterface interface {
	ReadMemory(addr uint32, buf []byte) uint32
}

EmulatorInterface defines the interface for emulator memory access. This matches the emucore.MemoryInspector interface, decoupling the achievement manager from the concrete emulator type. The core adapter handles mapping flat addresses to internal memory regions.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager wraps the rcheevos client for RetroAchievements integration

func NewManager

func NewManager(notification Notification, config *storage.Config, appName, appVersion string, consoleID uint32) *Manager

NewManager creates a new achievement manager

func (*Manager) ClearProgressDirty

func (m *Manager) ClearProgressDirty()

ClearProgressDirty clears the dirty flag after the detail screen refreshes.

func (*Manager) ComputeGameHash

func (m *Manager) ComputeGameHash(romData []byte) string

ComputeGameHash generates the MD5 hash for ROM data in rcheevos format. Use this as a fallback when the MD5 is not in the RDB.

func (*Manager) Destroy

func (m *Manager) Destroy()

Destroy cleans up the client resources

func (*Manager) DoFrame

func (m *Manager) DoFrame()

DoFrame processes achievements for the current frame

func (*Manager) EnsureLibrariesLoaded

func (m *Manager) EnsureLibrariesLoaded(callback func(success bool))

EnsureLibrariesLoaded fetches the hash library and user progress for SMS if not already cached. Call this when logged in to pre-fetch data for the detail screen.

func (*Manager) GetBadgeImage

func (m *Manager) GetBadgeImage(achievementID uint32) *ebiten.Image

GetBadgeImage returns a cached badge image for an achievement. Always returns the colored (unlocked) version - caller applies grayscale if needed. Returns nil if the badge is not yet cached.

func (*Manager) GetBadgeImageAsync

func (m *Manager) GetBadgeImageAsync(achievementID uint32, callback func(*ebiten.Image))

GetBadgeImageAsync fetches a badge image asynchronously. Always fetches the colored (unlocked) version - caller applies grayscale if needed. The callback is called when the image is ready (may be nil on error).

func (*Manager) GetCachedAchievements

func (m *Manager) GetCachedAchievements() []*rcheevos.Achievement

GetCachedAchievements returns the cached achievement list for the current game. Returns nil if no game is loaded. The slice is safe to read; do not modify.

func (*Manager) GetCachedGameTitle

func (m *Manager) GetCachedGameTitle() string

GetCachedGameTitle returns the cached game title.

func (*Manager) GetGame

func (m *Manager) GetGame() *rcheevos.Game

GetGame returns information about the currently loaded game. Returns nil if no game is loaded.

func (*Manager) GetUsername

func (m *Manager) GetUsername() string

GetUsername returns the logged in username

func (*Manager) Idle

func (m *Manager) Idle()

Idle processes periodic tasks when paused

func (*Manager) IsEnabled

func (m *Manager) IsEnabled() bool

IsEnabled returns whether achievements are enabled in config

func (*Manager) IsGameLoaded

func (m *Manager) IsGameLoaded() bool

IsGameLoaded returns whether a game is currently loaded for achievements

func (*Manager) IsLoggedIn

func (m *Manager) IsLoggedIn() bool

IsLoggedIn returns whether a user is currently logged in

func (*Manager) IsProgressDirty

func (m *Manager) IsProgressDirty() bool

IsProgressDirty returns true if achievements were unlocked since the last check. Used by the detail screen to know when to refresh cached progress data.

func (*Manager) IsSpectatorMode

func (m *Manager) IsSpectatorMode() bool

IsSpectatorMode returns whether spectator mode is enabled in config

func (*Manager) LoadGame

func (m *Manager) LoadGame(romData []byte, filePath string, md5Hash string) error

LoadGame identifies and loads a game for achievement tracking. If md5Hash is provided and non-empty, it will be used directly (fast path). Otherwise, the hash will be computed from romData (fallback).

func (*Manager) Login

func (m *Manager) Login(username, password string, callback func(success bool, token string, err error))

Login authenticates with RetroAchievements using username and password

func (*Manager) LoginWithToken

func (m *Manager) LoginWithToken(username, token string, callback func(success bool, result int, err error))

LoginWithToken authenticates with RetroAchievements using a stored token. The result code is passed through so callers can distinguish credential errors (e.g. ExpiredToken) from network errors (e.g. NoResponse).

func (*Manager) Logout

func (m *Manager) Logout()

Logout logs out the current user and clears all caches

func (*Manager) LookupGameProgress

func (m *Manager) LookupGameProgress(md5Hash string) (found bool, progress *rcheevos.UserProgressEntry)

LookupGameProgress returns user progress for a game by MD5 hash. Returns (false, nil) if the game is not in the RetroAchievements database. Returns (true, nil) if the game exists but user has no progress. Returns (true, progress) if the game exists and user has progress.

func (*Manager) RefreshUserProgress

func (m *Manager) RefreshUserProgress(callback func(success bool))

RefreshUserProgress re-fetches user progress data from the server. Call this after achievements are unlocked to update cached progress.

func (*Manager) SetEmulator

func (m *Manager) SetEmulator(emu EmulatorInterface)

SetEmulator sets the emulator for memory access

func (*Manager) SetOnUnlockCallback

func (m *Manager) SetOnUnlockCallback(fn func(achievementID uint32))

SetOnUnlockCallback sets a callback that's called when an achievement is unlocked. The callback receives the achievement ID. Used by the overlay to update its display.

func (*Manager) SetScreenshotFunc

func (m *Manager) SetScreenshotFunc(fn ScreenshotFunc)

SetScreenshotFunc sets the callback for taking screenshots on achievement unlock

func (*Manager) UnloadGame

func (m *Manager) UnloadGame()

UnloadGame unloads the current game

type Notification

type Notification interface {
	ShowDefault(message string)
	ShowAchievementWithBadge(title, description string, badge *ebiten.Image)
	SetBadge(badge *ebiten.Image) // Update badge after async fetch
	PlaySound(soundData []byte)   // Play sound through notification audio stream
}

Notification interface for showing achievement popups

type ScreenshotFunc

type ScreenshotFunc func()

ScreenshotFunc is called when an achievement triggers to capture a screenshot

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL