Jump to content
LaunchBox Community Forums

Possible Bug with IBigBoxMainViewModel.ShowGame Method


Recommended Posts

I apologize in advance if this is the wrong forum to post this.

 

Hello,

I am very very new to plugin development and using APIs in general. I am developing a very simple game randomizer for Big Box. I am using the IGameMenuItemPlugin interface and added an extra menu button on the game detail page on BigBox. So I have the logic that randomly selects an IGame object, and launches the game with the PluginHelper.BigBoxMainViewModel.ShowGame. method

 

So how it works is:

I would manually choose a game(game 1) and on the game detail page, I will click on the 'random game' menu button. Then the plugin will find a random game and load up the game detail page of the randomly selected game(game 2).

 

The issue is, if I try to exit out of the game detail page of game 2, it would go back to the game detail page of game 1. And if I try to exit out of game 1, it would send me back to game 2, so it's stuck in this weird loop between the two games.

 

Is this a bug? Or am I using this method wrong?

using Unbroken.LaunchBox.Plugins;
using Unbroken.LaunchBox.Plugins.Data;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Plugindemo
{
    public class DemoPluginMenuItem : IGameMenuItemPlugin
    {
       

        public bool SupportsMultipleGames
        {
            get { return true; }
        }

        public string Caption
        {
            get { return "Random Game";}
        }

        public System.Drawing.Image IconImage
        {
            get { return null; }
        }

        public bool ShowInLaunchBox
        {
            get { return true; }
        }

        public bool ShowInBigBox
        {
            get { return true; }
        }

        public bool GetIsValidForGame(IGame selectedGame)
        {
             return true; 
        }

        public bool GetIsValidForGames(IGame[] selectedGames)
        {
            return false;
        }

        public void OnSelected(IGame selectedGame)
        {
            IPlatform[] platforms = PluginHelper.DataManager.GetAllPlatforms();
            Random rand = new Random();
            int index = rand.Next(platforms.Length);
            IPlatform randomPlatform = platforms[index];


            IGame[] platformAllGames = randomPlatform.GetAllGames(true, true);
            Random gameRand = new Random();
            int gameIndex = rand.Next(platformAllGames.Length);
            PluginHelper.BigBoxMainViewModel.ShowGame(platformAllGames[gameIndex], FilterType.None);
        }

        public void OnSelected(IGame[] selectedGames)
        {
            return;
        }
    }
}

 

 

Link to comment
Share on other sites

Oh yeah I am very familiar of your plugin! I been using your plugin for the last couple of months now and it is really really good!

 

I'm not sure if it's just me or not, but whenever I use your plugin on any version above 11.2, I get errors. I was hoping to make a simpler version of the plugin to avoid these errors. If you like, I can PM a copy of the errors I would get.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...