Exemple #1
0
        private string LoadGame(string gameFile, bool?isCompiled, string id, string folder, string loadData, AzureFileManager.ApiGame apiGameData)
        {
            if (string.IsNullOrEmpty(gameFile) && loadData == null)
            {
                return("No game specified");
            }

            string rootPath = folder ?? ConfigurationManager.AppSettings["GameFolder"];
            string libPath  = ConfigurationManager.AppSettings["LibraryFolder"];
            string filename;

            if (Config.ReadGameFileFromAzureBlob)
            {
                filename = gameFile;
            }
            else
            {
                filename = WebPlayer.Play.GetGameFilename(gameFile, rootPath);
                if (filename == null)
                {
                    return("Invalid filename");
                }
            }

            List <string> errors;

            try
            {
                m_player                      = new PlayerHandler(filename, m_buffer);
                m_player.LoadData             = loadData;
                m_player.ApiGameData          = apiGameData;
                m_player.GameId               = m_gameId;
                m_player.LibraryFolder        = libPath;
                Games[m_gameId]               = m_player;
                m_player.BeginWait           += m_player_BeginWait;
                m_player.BeginPause          += m_player_BeginPause;
                m_player.ShowMenuDelegate     = m_player_ShowMenu;
                m_player.ShowQuestionDelegate = m_player_ShowQuestion;
                m_player.AddResource         += AddResource;
                m_player.PlayAudio           += m_player_PlayAudio;
                m_player.StopAudio           += m_player_StopAudio;
                if (Config.ReadGameFileFromAzureBlob)
                {
                    m_player.ResourceUrlRoot = AzureFileManager.GetResourceUrlRoot(id);
                }

                if (m_player.Initialise(out errors, isCompiled))
                {
                    Resources.AddGame(m_player.Game);

                    // Successful game start
                    return(m_player.ClearBuffer());
                }
            }
            catch (Exception ex)
            {
                return("<b>Error loading game:</b><br/>" + ex.Message);
            }

            string output = string.Empty;

            if (errors != null)
            {
                foreach (string error in errors)
                {
                    output += error + "<br/>";
                }
            }

            return(output);
        }
Exemple #2
0
        private string LoadGame(string gameFile)
        {
            if (string.IsNullOrEmpty(gameFile))
            {
                return "No game specified";
            }

            // Block attempts to access files outside the GameFolder
            if (gameFile.Contains(".."))
            {
                return "Invalid filename";
            }

            string rootPath = ConfigurationManager.AppSettings["GameFolder"];
            string libPath = ConfigurationManager.AppSettings["LibraryFolder"];
            string filename = System.IO.Path.Combine(rootPath, gameFile);
            List<string> errors;

            try
            {
                m_player = new PlayerHandler(filename, m_buffer);
                m_player.GameId = m_gameId;
                m_player.LibraryFolder = libPath;
                m_gamesInSession[m_gameId] = m_player;
                m_player.BeginWait += m_player_BeginWait;
                m_player.BeginPause += m_player_BeginPause;
                m_player.ShowMenuDelegate = m_player_ShowMenu;
                m_player.ShowQuestionDelegate = m_player_ShowQuestion;
                m_player.AddResource += AddResource;
                m_player.PlayAudio += m_player_PlayAudio;
                m_player.StopAudio += m_player_StopAudio;

                if (m_player.Initialise(out errors))
                {
                    // Successful game start
                    return m_player.ClearBuffer();
                }
            }
            catch (Exception ex)
            {
                return "<b>Error loading game:</b><br/>" + ex.Message;
            }

            string output = string.Empty;

            foreach (string error in errors)
            {
                output += error + "<br/>";
            }

            return output;
        }
Exemple #3
0
        private string LoadGame(string gameFile, bool? isCompiled, string id, string folder, string loadData, AzureFileManager.ApiGame apiGameData)
        {
            if (string.IsNullOrEmpty(gameFile) && loadData == null)
            {
                return "No game specified";
            }

            string rootPath = folder ?? ConfigurationManager.AppSettings["GameFolder"];
            string libPath = ConfigurationManager.AppSettings["LibraryFolder"];
            string filename;

            if (Config.ReadGameFileFromAzureBlob)
            {
                filename = gameFile;
            }
            else
            {
                filename = WebPlayer.Play.GetGameFilename(gameFile, rootPath);
                if (filename == null)
                {
                    return "Invalid filename";
                }
            }

            List<string> errors;

            try
            {
                m_player = new PlayerHandler(filename, m_buffer);
                m_player.LoadData = loadData;
                m_player.ApiGameData = apiGameData;
                m_player.GameId = m_gameId;
                m_player.LibraryFolder = libPath;
                Games[m_gameId] = m_player;
                m_player.BeginWait += m_player_BeginWait;
                m_player.BeginPause += m_player_BeginPause;
                m_player.ShowMenuDelegate = m_player_ShowMenu;
                m_player.ShowQuestionDelegate = m_player_ShowQuestion;
                m_player.AddResource += AddResource;
                m_player.PlayAudio += m_player_PlayAudio;
                m_player.StopAudio += m_player_StopAudio;
                if (Config.ReadGameFileFromAzureBlob)
                {
                    m_player.ResourceUrlRoot = AzureFileManager.GetResourceUrlRoot(id);
                }
                
                if (m_player.Initialise(out errors, isCompiled))
                {
                    Resources.AddGame(m_player.Game);

                    // Successful game start
                    return m_player.ClearBuffer();
                }
            }
            catch (Exception ex)
            {
                return "<b>Error loading game:</b><br/>" + ex.Message;
            }

            string output = string.Empty;

            if (errors != null)
            {
                foreach (string error in errors)
                {
                    output += error + "<br/>";
                }
            }

            return output;
        }
Exemple #4
0
        private string LoadGame(string gameFile, string id, string folder)
        {
            if (string.IsNullOrEmpty(gameFile))
            {
                return "No game specified";
            }

            string rootPath = folder ?? ConfigurationManager.AppSettings["GameFolder"];
            string libPath = ConfigurationManager.AppSettings["LibraryFolder"];
            var filename = GetGameFilename(gameFile, rootPath);
            if (filename == null)
            {
                return "Invalid filename";
            }
            List<string> errors;

            try
            {
                m_player = new PlayerHandler(filename, m_buffer, id, SessionManagerLoader.GetSessionManager().GetUser());
                m_player.GameId = m_gameId;
                m_player.LibraryFolder = libPath;
                Games[m_gameId] = m_player;
                m_player.BeginWait += m_player_BeginWait;
                m_player.BeginPause += m_player_BeginPause;
                m_player.ShowMenuDelegate = m_player_ShowMenu;
                m_player.ShowQuestionDelegate = m_player_ShowQuestion;
                m_player.AddResource += AddResource;
                m_player.PlayAudio += m_player_PlayAudio;
                m_player.StopAudio += m_player_StopAudio;
                
                if (m_player.Initialise(out errors))
                {
                    Resources.AddGame(m_player.Game);

                    // Successful game start
                    return m_player.ClearBuffer();
                }
            }
            catch (Exception ex)
            {
                return "<b>Error loading game:</b><br/>" + ex.Message;
            }

            string output = string.Empty;

            foreach (string error in errors)
            {
                output += error + "<br/>";
            }

            return output;
        }