Fix: register D2R resolution profiles with engine, fix null API responses
This commit is contained in:
parent
67f8ec1fe8
commit
4ebed5e3ab
3 changed files with 20 additions and 2 deletions
|
|
@ -333,7 +333,7 @@ func (s *Server) handleLootRules(w http.ResponseWriter, r *http.Request) {
|
||||||
func (s *Server) handleRoutines(w http.ResponseWriter, r *http.Request) {
|
func (s *Server) handleRoutines(w http.ResponseWriter, r *http.Request) {
|
||||||
routines := s.engine.GamePlugin().Routines()
|
routines := s.engine.GamePlugin().Routines()
|
||||||
|
|
||||||
var response []map[string]interface{}
|
response := make([]map[string]interface{}, 0)
|
||||||
for _, routine := range routines {
|
for _, routine := range routines {
|
||||||
response = append(response, map[string]interface{}{
|
response = append(response, map[string]interface{}{
|
||||||
"name": routine.Name(),
|
"name": routine.Name(),
|
||||||
|
|
@ -475,7 +475,7 @@ func (s *Server) getRegions() []RegionInfo {
|
||||||
profile, err := registry.Get(gameID, width, height)
|
profile, err := registry.Get(gameID, width, height)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to get resolution profile: %v", err)
|
log.Printf("Failed to get resolution profile: %v", err)
|
||||||
return nil
|
return make([]RegionInfo, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
var regions []RegionInfo
|
var regions []RegionInfo
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,18 @@ func NewEngine(captureSource capture.Source, gamePlugin plugin.Plugin, devMode b
|
||||||
startTime: time.Now(),
|
startTime: time.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register game-specific resolution profiles with the engine's registry.
|
||||||
|
// Plugins that support resolution profiles implement this optional interface.
|
||||||
|
type profileRegistrar interface {
|
||||||
|
RegisterResolutionProfiles(*resolution.Registry) error
|
||||||
|
}
|
||||||
|
if registrar, ok := gamePlugin.(profileRegistrar); ok {
|
||||||
|
if err := registrar.RegisterResolutionProfiles(engine.resolutionRegistry); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to register resolution profiles: %w", err)
|
||||||
|
}
|
||||||
|
log.Printf("Registered resolution profiles for %s", gamePlugin.Info().ID)
|
||||||
|
}
|
||||||
|
|
||||||
// Create engine services for the plugin
|
// Create engine services for the plugin
|
||||||
engine.services = &engineServices{engine: engine}
|
engine.services = &engineServices{engine: engine}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,3 +78,9 @@ func (p *Plugin) DefaultLootFilter() plugin.LootFilter {
|
||||||
func (p *Plugin) SupportedResolutions() []image.Point {
|
func (p *Plugin) SupportedResolutions() []image.Point {
|
||||||
return p.resolutionRegistry.SupportedResolutions("d2r")
|
return p.resolutionRegistry.SupportedResolutions("d2r")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterResolutionProfiles registers D2R profiles with an external registry.
|
||||||
|
// Called by the engine before Init().
|
||||||
|
func (p *Plugin) RegisterResolutionProfiles(reg *resolution.Registry) error {
|
||||||
|
return RegisterProfiles(reg)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue