Ejemplo n.º 1
0
 public static void Initialize()
 {
     Log.Information($"Survivalcraft starting up at {DateTime.Now}, Version={VersionsManager.Version}, BuildConfiguration={VersionsManager.BuildConfiguration}, Platform={VersionsManager.Platform}, DeviceModel={DeviceManager.DeviceModel}, OSVersion={DeviceManager.OperatingSystemVersion}, Storage.AvailableFreeSpace={Storage.FreeSpace / 1024 / 1024}MB, ApproximateScreenDpi={ScreenResolutionManager.ApproximateScreenDpi:0.0}, ApproxScreenInches={ScreenResolutionManager.ApproximateScreenInches:0.0}, ScreenResolution={Window.Size}, ProcessorsCount={Environment.ProcessorCount}, RAM={Utilities.GetTotalAvailableMemory() / 1024 / 1024}MB, 64bit={Marshal.SizeOf<IntPtr>() == 8}");
     MarketplaceManager.Initialize();
     SettingsManager.Initialize();
     AnalyticsManager.Initialize();
     VersionsManager.Initialize();
     ExternalContentManager.Initialize();
     ContentManager.Initialize();
     ScreensManager.Initialize();
 }
 public static ExternalContentType GetTypeFromLink(string address)
 {
     try
     {
         return(ExternalContentManager.ExtensionToType(Storage.GetExtension(UnclutterLink(address))));
     }
     catch (Exception)
     {
         return(ExternalContentType.Unknown);
     }
 }
Ejemplo n.º 3
0
 public static void VerifyLinkContent(string address, string name, ExternalContentType type, CancellableProgress progress, Action <byte[]> success, Action <Exception> failure)
 {
     progress = (progress ?? new CancellableProgress());
     WebManager.Get(address, null, null, progress, delegate(byte[] data)
     {
         ExternalContentManager.ImportExternalContent(new MemoryStream(data), type, "__Temp", delegate(string downloadedName)
         {
             ExternalContentManager.DeleteExternalContent(type, downloadedName);
             success(data);
         }, failure);
     }, failure);
 }
Ejemplo n.º 4
0
 public static string GetFilterDisplayName(object filter)
 {
     if (filter is string)
     {
         if (!string.IsNullOrEmpty((string)filter))
         {
             return(LanguageControl.Get(fName, 8));
         }
         return(LanguageControl.Get(fName, 9));
     }
     if (filter is ExternalContentType)
     {
         return(ExternalContentManager.GetEntryTypeDescription((ExternalContentType)filter));
     }
     throw new InvalidOperationException(LanguageControl.Get(fName, 10));
 }
Ejemplo n.º 5
0
 public SelectExternalContentTypeDialog(string title, Action <ExternalContentType> selectionHandler)
     : base(title, from v in EnumUtils.GetEnumValues(typeof(ExternalContentType))
            where ExternalContentManager.IsEntryTypeDownloadSupported((ExternalContentType) v)
            select v, 64f, delegate(object item)
 {
     ExternalContentType type = (ExternalContentType)item;
     XElement node            = ContentManager.Get <XElement>("Widgets/SelectExternalContentTypeItem");
     ContainerWidget obj      = (ContainerWidget)Widget.LoadWidget(null, node, null);
     obj.Children.Find <RectangleWidget>("SelectExternalContentType.Icon").Subtexture = ExternalContentManager.GetEntryTypeIcon(type);
     obj.Children.Find <LabelWidget>("SelectExternalContentType.Text").Text           = ExternalContentManager.GetEntryTypeDescription(type);
     return(obj);
 }, delegate(object item)
 {
     selectionHandler((ExternalContentType)item);
 })
 {
 }
Ejemplo n.º 6
0
 public static void Download(string address, string name, ExternalContentType type, string userId, CancellableProgress progress, Action success, Action <Exception> failure)
 {
     progress = (progress ?? new CancellableProgress());
     if (!WebManager.IsInternetConnectionAvailable())
     {
         failure(new InvalidOperationException("Internet connection is unavailable."));
     }
     else
     {
         WebManager.Get(address, null, null, progress, delegate(byte[] data)
         {
             string hash = CalculateContentHashString(data);
             ExternalContentManager.ImportExternalContent(new MemoryStream(data), type, name, delegate(string downloadedName)
             {
                 m_idToAddressMap[MakeContentIdString(type, downloadedName)] = address;
                 Feedback(address, "Success", null, hash, data.Length, userId, progress, delegate
                 {
                 }, delegate
                 {
                 });
                 AnalyticsManager.LogEvent("[CommunityContentManager] Download Success", new AnalyticsParameter("Name", name));
                 success();
             }, delegate(Exception error)
             {
                 Feedback(address, "ImportFailure", null, hash, data.Length, userId, null, delegate
                 {
                 }, delegate
                 {
                 });
                 AnalyticsManager.LogEvent("[CommunityContentManager] Import Failure", new AnalyticsParameter("Name", name), new AnalyticsParameter("Error", error.Message.ToString()));
                 failure(error);
             });
         }, delegate(Exception error)
         {
             Feedback(address, "DownloadFailure", null, null, 0L, userId, null, delegate
             {
             }, delegate
             {
             });
             AnalyticsManager.LogEvent("[CommunityContentManager] Download Failure", new AnalyticsParameter("Name", name), new AnalyticsParameter("Error", error.Message.ToString()));
             failure(error);
         });
     }
 }
Ejemplo n.º 7
0
        public static string ImportBlocksTexture(string name, Stream stream)
        {
            Exception ex = ExternalContentManager.VerifyExternalContentName(name);

            if (ex != null)
            {
                throw ex;
            }
            if (Storage.GetExtension(name) != ".scbtex")
            {
                name += ".scbtex";
            }
            ValidateBlocksTexture(stream);
            stream.Position = 0L;
            using (Stream destination = Storage.OpenFile(GetFileName(name), OpenFileMode.Create))
            {
                stream.CopyTo(destination);
                return(name);
            }
        }
Ejemplo n.º 8
0
 public static void UnpackWorld(string directoryName, Stream sourceStream, bool importEmbeddedExternalContent)
 {
     if (!Storage.DirectoryExists(directoryName))
     {
         throw new InvalidOperationException($"Cannot import world into \"{directoryName}\" because this directory does not exist.");
     }
     using (ZipArchive zipArchive = ZipArchive.Open(sourceStream, keepStreamOpen: true))
     {
         foreach (ZipArchiveEntry item in zipArchive.ReadCentralDir())
         {
             string text      = item.FilenameInZip.Replace('\\', '/');
             string extension = Storage.GetExtension(text);
             if (text.StartsWith("EmbeddedContent"))
             {
                 try
                 {
                     if (importEmbeddedExternalContent)
                     {
                         MemoryStream memoryStream = new MemoryStream();
                         zipArchive.ExtractFile(item, memoryStream);
                         memoryStream.Position = 0L;
                         ExternalContentType type = ExternalContentManager.ExtensionToType(extension);
                         ExternalContentManager.ImportExternalContentSync(memoryStream, type, Storage.GetFileNameWithoutExtension(text));
                     }
                 }
                 catch (Exception ex)
                 {
                     Log.Warning($"Failed to import embedded content \"{text}\". Reason: {ex.Message}");
                 }
             }
             else
             {
                 using (Stream stream = Storage.OpenFile(Storage.CombinePaths(directoryName, Storage.GetFileName(text)), OpenFileMode.Create))
                 {
                     zipArchive.ExtractFile(item, stream);
                 }
             }
         }
     }
 }
Ejemplo n.º 9
0
        public override void Update()
        {
            string text  = m_linkTextBoxWidget.Text.Trim();
            string text2 = m_nameTextBoxWidget.Text.Trim();

            m_typeLabelWidget.Text          = ExternalContentManager.GetEntryTypeDescription(m_type);
            m_typeIconWidget.Subtexture     = ExternalContentManager.GetEntryTypeIcon(m_type);
            m_publishButtonWidget.IsEnabled = (text.Length > 0 && text2.Length > 0);
            if (m_changeTypeButtonWidget.IsClicked)
            {
                DialogsManager.ShowDialog(base.ParentWidget, new SelectExternalContentTypeDialog("Select Content Type", delegate(ExternalContentType item)
                {
                    m_type = item;
                }));
            }
            else if (base.Input.Cancel || m_cancelButtonWidget.IsClicked)
            {
                DialogsManager.HideDialog(this);
            }
            else if (m_publishButtonWidget.IsClicked)
            {
                CancellableBusyDialog busyDialog = new CancellableBusyDialog("Publishing", autoHideOnCancel: false);
                DialogsManager.ShowDialog(base.ParentWidget, busyDialog);
                CommunityContentManager.Publish(text, text2, m_type, m_user, busyDialog.Progress, delegate
                {
                    DialogsManager.HideDialog(busyDialog);
                    DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog("Link Published Successfully", "It should start appearing in the listings after it is moderated. Please keep the file accessible through this link, so that other community members can download it.", LanguageControl.Get("Usual", "ok"), null, delegate
                    {
                        DialogsManager.HideDialog(this);
                    }));
                }, delegate(Exception error)
                {
                    DialogsManager.HideDialog(busyDialog);
                    DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog("Error", error.Message, LanguageControl.Get("Usual", "ok"), null, null));
                });
            }
        }
Ejemplo n.º 10
0
        public void DownloadEntry(ExternalContentEntry entry)
        {
            CancellableBusyDialog busyDialog = new CancellableBusyDialog(LanguageControl.Get(fName, 10), autoHideOnCancel: false);

            DialogsManager.ShowDialog(null, busyDialog);
            m_externalContentProvider.Download(entry.Path, busyDialog.Progress, delegate(Stream stream)
            {
                busyDialog.LargeMessage = LanguageControl.Get(fName, 12);
                ExternalContentManager.ImportExternalContent(stream, entry.Type, Storage.GetFileName(entry.Path), delegate
                {
                    stream.Dispose();
                    DialogsManager.HideDialog(busyDialog);
                }, delegate(Exception error)
                {
                    stream.Dispose();
                    DialogsManager.HideDialog(busyDialog);
                    DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "error"), error.Message, LanguageControl.Get("Usual", "ok"), null, null));
                });
            }, delegate(Exception error)
            {
                DialogsManager.HideDialog(busyDialog);
                DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "error"), error.Message, LanguageControl.Get("Usual", "ok"), null, null));
            });
        }
Ejemplo n.º 11
0
        public override void Update()
        {
            if (m_gameModeButton.IsClicked && m_worldSettings.GameMode != GameMode.Cruel)
            {
                IList <int> enumValues = EnumUtils.GetEnumValues(typeof(GameMode));
                do
                {
                    m_worldSettings.GameMode = (GameMode)((enumValues.IndexOf((int)m_worldSettings.GameMode) + 1) % enumValues.Count);
                }while (m_worldSettings.GameMode == GameMode.Cruel);
                m_descriptionLabel.Text = StringsManager.GetString("GameMode." + m_worldSettings.GameMode.ToString() + ".Description");
            }
            m_currentWorldSettingsData.Clear();
            m_worldSettings.Save(m_currentWorldSettingsData, liveModifiableParametersOnly: true);
            bool flag  = !CompareValueDictionaries(m_originalWorldSettingsData, m_currentWorldSettingsData);
            bool flag2 = WorldsManager.ValidateWorldName(m_worldSettings.Name);

            m_nameTextBox.Text           = m_worldSettings.Name;
            m_seedLabel.Text             = m_worldSettings.Seed;
            m_gameModeButton.Text        = LanguageControl.Get("GameMode", m_worldSettings.GameMode.ToString());
            m_gameModeButton.IsEnabled   = (m_worldSettings.GameMode != GameMode.Cruel);
            m_errorLabel.IsVisible       = !flag2;
            m_descriptionLabel.IsVisible = flag2;
            m_uploadButton.IsEnabled     = (flag2 && !flag);
            m_applyButton.IsEnabled      = (flag2 && flag);
            m_descriptionLabel.Text      = StringsManager.GetString("GameMode." + m_worldSettings.GameMode.ToString() + ".Description");
            if (m_worldOptionsButton.IsClicked)
            {
                ScreensManager.SwitchScreen("WorldOptions", m_worldSettings, true);
            }
            if (m_deleteButton.IsClicked)
            {
                MessageDialog dialog = null;
                dialog = new MessageDialog(LanguageControl.Get(fName, 1), LanguageControl.Get(fName, 2), LanguageControl.Get("Usual", "yes"), LanguageControl.Get("Usual", "no"), delegate(MessageDialogButton button)
                {
                    if (button == MessageDialogButton.Button1)
                    {
                        WorldsManager.DeleteWorld(m_directoryName);
                        ScreensManager.SwitchScreen("Play");
                        DialogsManager.HideDialog(dialog);
                    }
                    else
                    {
                        DialogsManager.HideDialog(dialog);
                    }
                });
                dialog.AutoHide = false;
                DialogsManager.ShowDialog(null, dialog);
            }
            if (m_uploadButton.IsClicked && flag2 && !flag)
            {
                ExternalContentManager.ShowUploadUi(ExternalContentType.World, m_directoryName);
            }
            if ((m_applyButton.IsClicked && flag2) & flag)
            {
                if (m_worldSettings.GameMode != 0 && m_worldSettings.GameMode != GameMode.Adventure)
                {
                    m_worldSettings.ResetOptionsForNonCreativeMode();
                }
                WorldsManager.ChangeWorld(m_directoryName, m_worldSettings);
                ScreensManager.SwitchScreen("Play");
            }
            if (base.Input.Back || base.Input.Cancel || Children.Find <ButtonWidget>("TopBar.Back").IsClicked)
            {
                if (flag)
                {
                    DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get(fName, 3), LanguageControl.Get(fName, 4), LanguageControl.Get("Usual", "yes"), LanguageControl.Get("Usual", "no"), delegate(MessageDialogButton button)
                    {
                        if (button == MessageDialogButton.Button1)
                        {
                            ScreensManager.SwitchScreen("Play");
                        }
                    }));
                }
                else
                {
                    ScreensManager.SwitchScreen("Play");
                }
            }
        }
Ejemplo n.º 12
0
        internal static ExternalContentEntry JsonObjectToEntry(JsonObject jsonObject)
        {
            ExternalContentEntry externalContentEntry = new ExternalContentEntry();

            if (jsonObject.ContainsKey("entries"))
            {
                foreach (JsonObject item in (JsonArray)jsonObject["entries"])
                {
                    ExternalContentEntry externalContentEntry2 = new ExternalContentEntry();
                    externalContentEntry2.Path = item["path_display"].ToString();
                    externalContentEntry2.Type = ((item[".tag"].ToString() == "folder") ? ExternalContentType.Directory : ExternalContentManager.ExtensionToType(Storage.GetExtension(externalContentEntry2.Path)));
                    if (externalContentEntry2.Type != ExternalContentType.Directory)
                    {
                        externalContentEntry2.Time = (item.ContainsKey("server_modified") ? DateTime.Parse(item["server_modified"].ToString(), CultureInfo.InvariantCulture) : new DateTime(2000, 1, 1));
                        externalContentEntry2.Size = (item.ContainsKey("size") ? ((long)item["size"]) : 0);
                    }
                    externalContentEntry.ChildEntries.Add(externalContentEntry2);
                }
                return(externalContentEntry);
            }
            return(externalContentEntry);
        }
        public override void Update()
        {
            string text = m_linkTextBoxWidget.Text.Trim();
            string name = m_nameTextBoxWidget.Text.Trim();

            m_typeLabelWidget.Text      = ExternalContentManager.GetEntryTypeDescription(m_type);
            m_typeIconWidget.Subtexture = ExternalContentManager.GetEntryTypeIcon(m_type);
            if (ExternalContentManager.DoesEntryTypeRequireName(m_type))
            {
                m_nameTextBoxWidget.IsEnabled    = true;
                m_downloadButtonWidget.IsEnabled = (text.Length > 0 && name.Length > 0 && m_type != ExternalContentType.Unknown);
                if (m_updateContentName)
                {
                    m_nameTextBoxWidget.Text = GetNameFromLink(m_linkTextBoxWidget.Text);
                    m_updateContentName      = false;
                }
            }
            else
            {
                m_nameTextBoxWidget.IsEnabled    = false;
                m_nameTextBoxWidget.Text         = string.Empty;
                m_downloadButtonWidget.IsEnabled = (text.Length > 0 && m_type != ExternalContentType.Unknown);
            }
            if (m_updateContentType)
            {
                m_type = GetTypeFromLink(m_linkTextBoxWidget.Text);
                m_updateContentType = false;
            }
            if (m_changeTypeButtonWidget.IsClicked)
            {
                DialogsManager.ShowDialog(base.ParentWidget, new SelectExternalContentTypeDialog("Select Content Type", delegate(ExternalContentType item)
                {
                    m_type = item;
                    m_updateContentName = true;
                }));
            }
            else if (base.Input.Cancel || m_cancelButtonWidget.IsClicked)
            {
                DialogsManager.HideDialog(this);
            }
            else if (m_downloadButtonWidget.IsClicked)
            {
                CancellableBusyDialog busyDialog = new CancellableBusyDialog("Downloading", autoHideOnCancel: false);
                DialogsManager.ShowDialog(base.ParentWidget, busyDialog);
                WebManager.Get(text, null, null, busyDialog.Progress, delegate(byte[] data)
                {
                    ExternalContentManager.ImportExternalContent(new MemoryStream(data), m_type, name, delegate
                    {
                        DialogsManager.HideDialog(busyDialog);
                        DialogsManager.HideDialog(this);
                    }, delegate(Exception error)
                    {
                        DialogsManager.HideDialog(busyDialog);
                        DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog("Error", error.Message, LanguageControl.Get("Usual", "ok"), null, null));
                    });
                }, delegate(Exception error)
                {
                    DialogsManager.HideDialog(busyDialog);
                    DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog("Error", error.Message, LanguageControl.Get("Usual", "ok"), null, null));
                });
            }
        }
Ejemplo n.º 14
0
        public CommunityContentScreen()
        {
            XElement node = ContentManager.Get <XElement>("Screens/CommunityContentScreen");

            LoadContents(this, node);
            m_listPanel                   = Children.Find <ListPanelWidget>("List");
            m_orderLabel                  = Children.Find <LabelWidget>("Order");
            m_changeOrderButton           = Children.Find <ButtonWidget>("ChangeOrder");
            m_filterLabel                 = Children.Find <LabelWidget>("Filter");
            m_changeFilterButton          = Children.Find <ButtonWidget>("ChangeFilter");
            m_downloadButton              = Children.Find <ButtonWidget>("Download");
            m_deleteButton                = Children.Find <ButtonWidget>("Delete");
            m_moreOptionsButton           = Children.Find <ButtonWidget>("MoreOptions");
            m_listPanel.ItemWidgetFactory = delegate(object item)
            {
                CommunityContentEntry communityContentEntry = item as CommunityContentEntry;
                if (communityContentEntry != null)
                {
                    XElement        node2 = ContentManager.Get <XElement>("Widgets/CommunityContentItem");
                    ContainerWidget obj   = (ContainerWidget)Widget.LoadWidget(this, node2, null);
                    obj.Children.Find <RectangleWidget>("CommunityContentItem.Icon").Subtexture   = ExternalContentManager.GetEntryTypeIcon(communityContentEntry.Type);
                    obj.Children.Find <LabelWidget>("CommunityContentItem.Text").Text             = communityContentEntry.Name;
                    obj.Children.Find <LabelWidget>("CommunityContentItem.Details").Text          = $"{ExternalContentManager.GetEntryTypeDescription(communityContentEntry.Type)} {DataSizeFormatter.Format(communityContentEntry.Size)}";
                    obj.Children.Find <StarRatingWidget>("CommunityContentItem.Rating").Rating    = communityContentEntry.RatingsAverage;
                    obj.Children.Find <StarRatingWidget>("CommunityContentItem.Rating").IsVisible = (communityContentEntry.RatingsAverage > 0f);
                    obj.Children.Find <LabelWidget>("CommunityContentItem.ExtraText").Text        = communityContentEntry.ExtraText;
                    return(obj);
                }
                XElement        node3           = ContentManager.Get <XElement>("Widgets/CommunityContentItemMore");
                ContainerWidget containerWidget = (ContainerWidget)Widget.LoadWidget(this, node3, null);
                m_moreLink     = containerWidget.Children.Find <LinkWidget>("CommunityContentItemMore.Link");
                m_moreLink.Tag = (item as string);
                return(containerWidget);
            };
            m_listPanel.SelectionChanged += delegate
            {
                if (m_listPanel.SelectedItem != null && !(m_listPanel.SelectedItem is CommunityContentEntry))
                {
                    m_listPanel.SelectedItem = null;
                }
            };
        }
Ejemplo n.º 15
0
        public override void Update()
        {
            if (m_listDirty)
            {
                m_listDirty = false;
                UpdateList();
            }
            ExternalContentEntry externalContentEntry = null;

            if (m_directoryList.SelectedIndex.HasValue)
            {
                externalContentEntry = (m_directoryList.Items[m_directoryList.SelectedIndex.Value] as ExternalContentEntry);
            }
            if (externalContentEntry != null)
            {
                m_actionButton.IsVisible = true;
                if (externalContentEntry.Type == ExternalContentType.Directory)
                {
                    m_actionButton.Text        = LanguageControl.Get(fName, 1);
                    m_actionButton.IsEnabled   = true;
                    m_copyLinkButton.IsEnabled = false;
                }
                else
                {
                    m_actionButton.Text = LanguageControl.Get(fName, 2);
                    if (ExternalContentManager.IsEntryTypeDownloadSupported(ExternalContentManager.ExtensionToType(Storage.GetExtension(externalContentEntry.Path).ToLower())))
                    {
                        m_actionButton.IsEnabled   = true;
                        m_copyLinkButton.IsEnabled = true;
                    }
                    else
                    {
                        m_actionButton.IsEnabled   = false;
                        m_copyLinkButton.IsEnabled = false;
                    }
                }
            }
            else
            {
                m_actionButton.IsVisible   = false;
                m_copyLinkButton.IsVisible = false;
            }
            m_directoryLabel.Text         = m_externalContentProvider.IsLoggedIn ? string.Format(LanguageControl.Get(fName, 3), m_path) : LanguageControl.Get(fName, 4);
            m_providerNameLabel.Text      = m_externalContentProvider.DisplayName;
            m_upDirectoryButton.IsEnabled = (m_externalContentProvider.IsLoggedIn && m_path != "/");
            m_loginLogoutButton.Text      = (m_externalContentProvider.IsLoggedIn ? LanguageControl.Get(fName, 5) : LanguageControl.Get(fName, 6));
            m_loginLogoutButton.IsVisible = m_externalContentProvider.RequiresLogin;
            m_copyLinkButton.IsVisible    = m_externalContentProvider.SupportsLinks;
            m_copyLinkButton.IsEnabled    = (externalContentEntry != null && ExternalContentManager.IsEntryTypeDownloadSupported(externalContentEntry.Type));
            if (m_changeProviderButton.IsClicked)
            {
                DialogsManager.ShowDialog(null, new SelectExternalContentProviderDialog(LanguageControl.Get(fName, 7), listingSupportRequired : true, delegate(IExternalContentProvider provider)
                {
                    m_externalContentProvider = provider;
                    m_listDirty = true;
                    SetPath(null);
                }));
            }
            if (m_upDirectoryButton.IsClicked)
            {
                string directoryName = Storage.GetDirectoryName(m_path);
                SetPath(directoryName);
            }
            if (m_actionButton.IsClicked && externalContentEntry != null)
            {
                if (externalContentEntry.Type == ExternalContentType.Directory)
                {
                    SetPath(externalContentEntry.Path);
                }
                else
                {
                    DownloadEntry(externalContentEntry);
                }
            }
            if (m_copyLinkButton.IsClicked && externalContentEntry != null && ExternalContentManager.IsEntryTypeDownloadSupported(externalContentEntry.Type))
            {
                CancellableBusyDialog busyDialog = new CancellableBusyDialog(LanguageControl.Get(fName, 8), autoHideOnCancel: false);
                DialogsManager.ShowDialog(null, busyDialog);
                m_externalContentProvider.Link(externalContentEntry.Path, busyDialog.Progress, delegate(string link)
                {
                    DialogsManager.HideDialog(busyDialog);
                    DialogsManager.ShowDialog(null, new ExternalContentLinkDialog(link));
                }, delegate(Exception error)
                {
                    DialogsManager.HideDialog(busyDialog);
                    DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "error"), error.Message, LanguageControl.Get("Usual", "ok"), null, null));
                });
            }
            if (m_loginLogoutButton.IsClicked)
            {
                if (m_externalContentProvider.IsLoggedIn)
                {
                    m_externalContentProvider.Logout();
                    SetPath(null);
                    m_listDirty = true;
                }
                else
                {
                    ExternalContentManager.ShowLoginUiIfNeeded(m_externalContentProvider, showWarningDialog: false, delegate
                    {
                        SetPath(null);
                        m_listDirty = true;
                    });
                }
            }
            if (base.Input.Back || base.Input.Cancel || Children.Find <ButtonWidget>("TopBar.Back").IsClicked)
            {
                ScreensManager.SwitchScreen("Content");
            }
        }
Ejemplo n.º 16
0
        public ExternalContentScreen()
        {
            XElement node = ContentManager.Get <XElement>("Screens/ExternalContentScreen");

            LoadContents(this, node);
            m_directoryLabel                  = Children.Find <LabelWidget>("TopBar.Label");
            m_directoryList                   = Children.Find <ListPanelWidget>("DirectoryList");
            m_providerNameLabel               = Children.Find <LabelWidget>("ProviderName");
            m_changeProviderButton            = Children.Find <ButtonWidget>("ChangeProvider");
            m_loginLogoutButton               = Children.Find <ButtonWidget>("LoginLogout");
            m_upDirectoryButton               = Children.Find <ButtonWidget>("UpDirectory");
            m_actionButton                    = Children.Find <ButtonWidget>("Action");
            m_copyLinkButton                  = Children.Find <ButtonWidget>("CopyLink");
            m_directoryList.ItemWidgetFactory = delegate(object item)
            {
                ExternalContentEntry externalContentEntry2 = (ExternalContentEntry)item;
                XElement             node2           = ContentManager.Get <XElement>("Widgets/ExternalContentItem");
                ContainerWidget      containerWidget = (ContainerWidget)Widget.LoadWidget(this, node2, null);
                string fileName = Storage.GetFileName(externalContentEntry2.Path);
                string text     = m_downloadedFiles.ContainsKey(externalContentEntry2.Path) ? LanguageControl.Get(fName, 11) : string.Empty;
                string text2    = (externalContentEntry2.Type != ExternalContentType.Directory) ? $"{ExternalContentManager.GetEntryTypeDescription(externalContentEntry2.Type)} | {DataSizeFormatter.Format(externalContentEntry2.Size)} | {externalContentEntry2.Time:dd-MMM-yyyy HH:mm}{text}" : ExternalContentManager.GetEntryTypeDescription(externalContentEntry2.Type);
                containerWidget.Children.Find <RectangleWidget>("ExternalContentItem.Icon").Subtexture = ExternalContentManager.GetEntryTypeIcon(externalContentEntry2.Type);
                containerWidget.Children.Find <LabelWidget>("ExternalContentItem.Text").Text           = fileName;
                containerWidget.Children.Find <LabelWidget>("ExternalContentItem.Details").Text        = text2;
                return(containerWidget);
            };
            m_directoryList.ItemClicked += delegate(object item)
            {
                if (m_directoryList.SelectedItem == item)
                {
                    ExternalContentEntry externalContentEntry = item as ExternalContentEntry;
                    if (externalContentEntry != null && externalContentEntry.Type == ExternalContentType.Directory)
                    {
                        SetPath(externalContentEntry.Path);
                    }
                }
            };
        }
Ejemplo n.º 17
0
        public override void Update()
        {
            CommunityContentEntry communityContentEntry = m_listPanel.SelectedItem as CommunityContentEntry;

            m_downloadButton.IsEnabled = (communityContentEntry != null);
            m_deleteButton.IsEnabled   = (UserManager.ActiveUser != null && communityContentEntry != null && communityContentEntry.UserId == UserManager.ActiveUser.UniqueId);
            m_orderLabel.Text          = GetOrderDisplayName(m_order);
            m_filterLabel.Text         = GetFilterDisplayName(m_filter);
            if (m_changeOrderButton.IsClicked)
            {
                List <Order> items = EnumUtils.GetEnumValues(typeof(Order)).Cast <Order>().ToList();
                DialogsManager.ShowDialog(null, new ListSelectionDialog(LanguageControl.Get(fName, "Order Type"), items, 60f, (object item) => GetOrderDisplayName((Order)item), delegate(object item)
                {
                    m_order = (Order)item;
                    PopulateList(null);
                }));
            }
            if (m_changeFilterButton.IsClicked)
            {
                List <object> list = new List <object>();
                list.Add(string.Empty);
                foreach (ExternalContentType item in from ExternalContentType t in EnumUtils.GetEnumValues(typeof(ExternalContentType))
                         where ExternalContentManager.IsEntryTypeDownloadSupported(t)
                         select t)
                {
                    list.Add(item);
                }
                if (UserManager.ActiveUser != null)
                {
                    list.Add(UserManager.ActiveUser.UniqueId);
                }
                DialogsManager.ShowDialog(null, new ListSelectionDialog(LanguageControl.Get(fName, "Filter"), list, 60f, (object item) => GetFilterDisplayName(item), delegate(object item)
                {
                    m_filter = item;
                    PopulateList(null);
                }));
            }
            if (m_downloadButton.IsClicked && communityContentEntry != null)
            {
                DownloadEntry(communityContentEntry);
            }
            if (m_deleteButton.IsClicked && communityContentEntry != null)
            {
                DeleteEntry(communityContentEntry);
            }
            if (m_moreOptionsButton.IsClicked)
            {
                DialogsManager.ShowDialog(null, new MoreCommunityLinkDialog());
            }
            if (m_moreLink != null && m_moreLink.IsClicked)
            {
                PopulateList((string)m_moreLink.Tag);
            }
            if (base.Input.Back || Children.Find <BevelledButtonWidget>("TopBar.Back").IsClicked)
            {
                ScreensManager.SwitchScreen("Content");
            }
            if (base.Input.Hold.HasValue && base.Input.HoldTime > 2f && base.Input.Hold.Value.Y < 20f)
            {
                m_contentExpiryTime = 0.0;
                Task.Delay(250).Wait();
            }
        }