Esempio n. 1
0
 void OnDetails(MyGuiControlButton button)
 {
     if (m_selectedItem == null)
     {
         if (m_activeDetail)
         {
             MyScreenManager.RemoveScreen(m_detailScreen);
         }
         return;
     }
     else if (m_activeDetail)
     {
         MyScreenManager.RemoveScreen(m_detailScreen);
     }
     else if (!m_activeDetail)
     {
         if ((m_selectedItem.UserData as MyBlueprintItemInfo).Type == MyBlueprintTypeEnum.LOCAL)
         {
             var path = Path.Combine(m_localBlueprintFolder, m_selectedItem.Text.ToString(), "bp.sbc");
             if (File.Exists(path))
             {
                 m_thumbnailImage.Visible = false;
                 m_detailScreen           = new MyGuiDetailScreenLocal(
                     callBack : delegate(MyGuiControlListbox.Item item)
                 {
                     if (item == null)
                     {
                         m_screenshotButton.Enabled = false;
                         m_detailsButton.Enabled    = false;
                         m_replaceButton.Enabled    = false;
                         m_deleteButton.Enabled     = false;
                     }
                     m_selectedItem = item;
                     m_activeDetail = false;
                     m_detailScreen = null;
                     if (m_task.IsComplete)
                     {
                         RefreshBlueprintList();
                     }
                 },
                     selectedItem: m_selectedItem,
                     parent: this,
                     thumbnailTexture: m_selectedImage.BackgroundTexture,
                     textScale: m_textScale
                     );
                 m_activeDetail = true;
                 MyScreenManager.InputToNonFocusedScreens = true;
                 MyScreenManager.AddScreen(m_detailScreen);
             }
             else
             {
                 MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                            buttonType: MyMessageBoxButtonsType.OK,
                                            styleEnum: MyMessageBoxStyleEnum.Error,
                                            messageCaption: new StringBuilder("Error"),
                                            messageText: new StringBuilder("Cannot find the blueprint file.")
                                            ));
             }
         }
         else if ((m_selectedItem.UserData as MyBlueprintItemInfo).Type == MyBlueprintTypeEnum.STEAM)
         {
             var path2 = Path.Combine(m_workshopBlueprintFolder, (m_selectedItem.UserData as MyBlueprintItemInfo).PublishedItemId.ToString() + m_workshopBlueprintSuffix);
             if (File.Exists(path2))
             {
                 m_thumbnailImage.Visible = false;
                 m_detailScreen           = new MyGuiDetailScreenSteam(
                     callBack : delegate(MyGuiControlListbox.Item item)
                 {
                     m_selectedItem = item;
                     m_activeDetail = false;
                     m_detailScreen = null;
                     if (m_task.IsComplete)
                     {
                         RefreshBlueprintList();
                     }
                 },
                     selectedItem: m_selectedItem,
                     parent: this,
                     thumbnailTexture: m_selectedImage.BackgroundTexture,
                     textScale: m_textScale
                     );
                 m_activeDetail = true;
                 MyScreenManager.InputToNonFocusedScreens = true;
                 MyScreenManager.AddScreen(m_detailScreen);
             }
             else
             {
                 MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                            buttonType: MyMessageBoxButtonsType.OK,
                                            styleEnum: MyMessageBoxStyleEnum.Error,
                                            messageCaption: new StringBuilder("Error"),
                                            messageText: new StringBuilder("Cannot find the blueprint file.")
                                            ));
             }
         }
     }
 }
 void OnBlueprintDownloadedDetails(MySteamWorkshop.SubscribedItem workshopDetails)
 {
     var path2 = Path.Combine(m_workshopBlueprintFolder, workshopDetails.PublishedFileId.ToString() + m_workshopBlueprintSuffix);
     if (File.Exists(path2))
     {
         m_thumbnailImage.Visible = false;
         m_detailScreen = new MyGuiDetailScreenSteam(
             callBack: delegate(MyGuiControlListbox.Item item)
             {
                 m_selectedItem = item;
                 m_activeDetail = false;
                 m_detailScreen = null;
                 if (Task.IsComplete)
                 {
                     RefreshBlueprintList();
                 }
             },
             selectedItem: m_selectedItem,
             parent: this,
             thumbnailTexture: m_selectedImage.BackgroundTexture,
             textScale: m_textScale
             );
         m_activeDetail = true;
         MyScreenManager.InputToNonFocusedScreens = true;
         MyScreenManager.AddScreen(m_detailScreen);
     }
     else
     {
         MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                     buttonType: MyMessageBoxButtonsType.OK,
                     styleEnum: MyMessageBoxStyleEnum.Error,
                     messageCaption: new StringBuilder("Error"),
                     messageText: new StringBuilder("Cannot find the blueprint file.")
                     ));
     }
 }
 void OnDetails(MyGuiControlButton button)
 {
     if (m_selectedItem == null)
     {
         if (m_activeDetail)
         {
             MyScreenManager.RemoveScreen(m_detailScreen);
         }
         return;
     }
     else if(m_activeDetail)
     {
         MyScreenManager.RemoveScreen(m_detailScreen);
     }
     else if (!m_activeDetail)
     {
         if ((m_selectedItem.UserData as MyBlueprintItemInfo).Type == MyBlueprintTypeEnum.LOCAL)
         {
             var path = Path.Combine(m_localBlueprintFolder, m_selectedItem.Text.ToString(), "bp.sbc");
             if (File.Exists(path))
             {
                 m_thumbnailImage.Visible = false;
                 m_detailScreen = new MyGuiDetailScreenLocal(
                     callBack: delegate(MyGuiControlListbox.Item item)
                     {
                         if (item == null)
                         {
                             m_screenshotButton.Enabled = false;
                             m_detailsButton.Enabled = false;
                             m_replaceButton.Enabled = false;
                             m_deleteButton.Enabled = false;
                         }
                         m_selectedItem = item;
                         m_activeDetail = false;
                         m_detailScreen = null;
                         if (Task.IsComplete)
                         {
                             RefreshBlueprintList();
                         }
                     },
                     selectedItem: m_selectedItem,
                     parent: this,
                     thumbnailTexture: m_selectedImage.BackgroundTexture,
                     textScale: m_textScale
                     );
                 m_activeDetail = true;
                 MyScreenManager.InputToNonFocusedScreens = true;
                 MyScreenManager.AddScreen(m_detailScreen);
             }
             else
             {
                 MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                             buttonType: MyMessageBoxButtonsType.OK,
                             styleEnum: MyMessageBoxStyleEnum.Error,
                             messageCaption: new StringBuilder("Error"),
                             messageText: new StringBuilder("Cannot find the blueprint file.")
                             ));
             }
         }
         else if ((m_selectedItem.UserData as MyBlueprintItemInfo).Type == MyBlueprintTypeEnum.DEFAULT)
         {
             var path = Path.Combine(m_defaultBlueprintFolder, m_selectedItem.Text.ToString(), "bp.sbc");
             if (File.Exists(path))
             {
                 m_thumbnailImage.Visible = false;
                 m_detailScreen = new MyGuiDetailScreenDefault(
                     callBack: delegate(MyGuiControlListbox.Item item)
                     {
                         if (item == null)
                         {
                             m_screenshotButton.Enabled = false;
                             m_detailsButton.Enabled = false;
                             m_replaceButton.Enabled = false;
                             m_deleteButton.Enabled = false;
                         }
                         m_selectedItem = item;
                         m_activeDetail = false;
                         m_detailScreen = null;
                         if (Task.IsComplete)
                         {
                             RefreshBlueprintList();
                         }
                     },
                     selectedItem: m_selectedItem,
                     parent: this,
                     thumbnailTexture: m_selectedImage.BackgroundTexture,
                     textScale: m_textScale
                     );
                 m_activeDetail = true;
                 MyScreenManager.InputToNonFocusedScreens = true;
                 MyScreenManager.AddScreen(m_detailScreen);
             }
             else
             {
                 MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                             buttonType: MyMessageBoxButtonsType.OK,
                             styleEnum: MyMessageBoxStyleEnum.Error,
                             messageCaption: new StringBuilder("Error"),
                             messageText: new StringBuilder("Cannot find the blueprint file.")
                             ));
             }
         }
         else if ((m_selectedItem.UserData as MyBlueprintItemInfo).Type == MyBlueprintTypeEnum.STEAM)
         {
             var path2 = Path.Combine(m_workshopBlueprintFolder, (m_selectedItem.UserData as MyBlueprintItemInfo).PublishedItemId.ToString() + m_workshopBlueprintSuffix);
             if (File.Exists(path2))
             {
                 m_thumbnailImage.Visible = false;
                 m_detailScreen = new MyGuiDetailScreenSteam(
                     callBack: delegate(MyGuiControlListbox.Item item)
                     {
                         m_selectedItem = item;
                         m_activeDetail = false;
                         m_detailScreen = null;
                         if (Task.IsComplete)
                         {
                             RefreshBlueprintList();
                         }
                     },
                     selectedItem: m_selectedItem,
                     parent: this,
                     thumbnailTexture: m_selectedImage.BackgroundTexture,
                     textScale: m_textScale
                     );
                 m_activeDetail = true;
                 MyScreenManager.InputToNonFocusedScreens = true;
                 MyScreenManager.AddScreen(m_detailScreen);
             }
             else
             {
                 MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                             buttonType: MyMessageBoxButtonsType.OK,
                             styleEnum: MyMessageBoxStyleEnum.Error,
                             messageCaption: new StringBuilder("Error"),
                             messageText: new StringBuilder("Cannot find the blueprint file.")
                             ));
             }
         }
     }
 }
        void OnDetails(MyGuiControlButton button)
        {
            if (m_selectedItem == null)
            {
                if (m_activeDetail)
                {
                    MyScreenManager.RemoveScreen(m_detailScreen);
                }
                return;
            }
            else if(m_activeDetail)
            {
                MyScreenManager.RemoveScreen(m_detailScreen);
            }
            else if (!m_activeDetail)
            {
                MyBlueprintItemInfo blueprintInfo = (m_selectedItem.UserData as MyBlueprintItemInfo);
                if (blueprintInfo.Type == MyBlueprintTypeEnum.LOCAL)
                {
                    var path = Path.Combine(m_localBlueprintFolder, m_selectedItem.Text.ToString(), "bp.sbc");
                    if (File.Exists(path))
                    {
                        m_thumbnailImage.Visible = false;
                        m_detailScreen = new MyGuiDetailScreenLocal(
                            callBack: delegate(MyGuiControlListbox.Item item)
                            {
                                if (item == null)
                                {
                                    m_screenshotButton.Enabled = false;
                                    m_detailsButton.Enabled = false;
                                    m_replaceButton.Enabled = false;
                                    m_deleteButton.Enabled = false;
                                }
                                m_selectedItem = item;
                                m_activeDetail = false;
                                m_detailScreen = null;
                                if (Task.IsComplete)
                                {
                                    RefreshBlueprintList();
                                }
                            },
                            selectedItem: m_selectedItem,
                            parent: this,
                            thumbnailTexture: m_selectedThumbnailPath,
                            textScale: m_textScale
                            );
                        m_activeDetail = true;
                        MyScreenManager.InputToNonFocusedScreens = true;
                        MyScreenManager.AddScreen(m_detailScreen);
                    }
                    else
                    {
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                    buttonType: MyMessageBoxButtonsType.OK,
                                    styleEnum: MyMessageBoxStyleEnum.Error,
                                    messageCaption: new StringBuilder("Error"),
                                    messageText: new StringBuilder("Cannot find the blueprint file.")
                                    ));
                    }
                }
                else if (blueprintInfo.Type == MyBlueprintTypeEnum.DEFAULT)
                {
                    var path = Path.Combine(m_defaultBlueprintFolder, m_selectedItem.Text.ToString(), "bp.sbc");
                    if (File.Exists(path))
                    {
                        m_thumbnailImage.Visible = false;
                        m_detailScreen = new MyGuiDetailScreenDefault(
                            callBack: delegate(MyGuiControlListbox.Item item)
                            {
                                if (item == null)
                                {
                                    m_screenshotButton.Enabled = false;
                                    m_detailsButton.Enabled = false;
                                    m_replaceButton.Enabled = false;
                                    m_deleteButton.Enabled = false;
                                }
                                m_selectedItem = item;
                                m_activeDetail = false;
                                m_detailScreen = null;
                                if (Task.IsComplete)
                                {
                                    RefreshBlueprintList();
                                }
                            },
                            selectedItem: m_selectedItem,
                            parent: this,
                            thumbnailTexture: m_selectedThumbnailPath,
                            textScale: m_textScale
                            );
                        m_activeDetail = true;
                        MyScreenManager.InputToNonFocusedScreens = true;
                        MyScreenManager.AddScreen(m_detailScreen);
                    }
                    else
                    {
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                    buttonType: MyMessageBoxButtonsType.OK,
                                    styleEnum: MyMessageBoxStyleEnum.Error,
                                    messageCaption: new StringBuilder("Error"),
                                    messageText: new StringBuilder("Cannot find the blueprint file.")
                                    ));
                    }
                }
#if !XB1 // XB1_NOWORKSHOP
                else if (blueprintInfo.Type == MyBlueprintTypeEnum.STEAM)
                {
                    MySteamWorkshop.SubscribedItem workshopData = blueprintInfo.Item;
                    Task = Parallel.Start(() => {
                        if (MySteamWorkshop.IsBlueprintUpToDate(workshopData) == false) 
                        { 
                            DownloadBlueprintFromSteam(workshopData);
                        } 
                    }, () => { OnBlueprintDownloadedDetails(workshopData); });               
                }
#endif // !XB1
            }
        }