public PlayScreen() { XElement node = ContentManager.Get <XElement>("Screens/PlayScreen"); LoadContents(this, node); m_worldsListWidget = Children.Find <ListPanelWidget>("WorldsList"); ListPanelWidget worldsListWidget = m_worldsListWidget; worldsListWidget.ItemWidgetFactory = (Func <object, Widget>) Delegate.Combine(worldsListWidget.ItemWidgetFactory, (Func <object, Widget>) delegate(object item) { WorldInfo worldInfo = (WorldInfo)item; XElement node2 = ContentManager.Get <XElement>("Widgets/SavedWorldItem"); ContainerWidget containerWidget = (ContainerWidget)Widget.LoadWidget(this, node2, null); LabelWidget labelWidget = containerWidget.Children.Find <LabelWidget>("WorldItem.Name"); LabelWidget labelWidget2 = containerWidget.Children.Find <LabelWidget>("WorldItem.Details"); containerWidget.Tag = worldInfo; labelWidget.Text = worldInfo.WorldSettings.Name; labelWidget2.Text = string.Format("{0} | {1:dd MMM yyyy HH:mm} | {2} | {3} | {4}", DataSizeFormatter.Format(worldInfo.Size), worldInfo.LastSaveTime.ToLocalTime(), (worldInfo.PlayerInfos.Count > 1) ? string.Format(LanguageControl.GetContentWidgets(fName, 9), worldInfo.PlayerInfos.Count): string.Format(LanguageControl.GetContentWidgets(fName, 10), 1), LanguageControl.Get("GameMode", worldInfo.WorldSettings.GameMode.ToString()), LanguageControl.Get("EnvironmentBehaviorMode", worldInfo.WorldSettings.EnvironmentBehaviorMode.ToString())); if (worldInfo.SerializationVersion != VersionsManager.SerializationVersion) { labelWidget2.Text = labelWidget2.Text + " | " + (string.IsNullOrEmpty(worldInfo.SerializationVersion) ? LanguageControl.GetContentWidgets("Usual", "Unknown") : ("(" + worldInfo.SerializationVersion + ")")); } return(containerWidget); }); m_worldsListWidget.ScrollPosition = 0f; m_worldsListWidget.ScrollSpeed = 0f; m_worldsListWidget.ItemClicked += delegate(object item) { if (item != null && m_worldsListWidget.SelectedItem == item) { Play(item); } }; }
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; } }; }
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); } } }; }
public static void ShowUploadUi(ExternalContentType type, string name) { DialogsManager.ShowDialog(null, new SelectExternalContentProviderDialog(LanguageControl.Get(fName, 9), listingSupportRequired : false, delegate(IExternalContentProvider provider) { try { if (provider != null) { ShowLoginUiIfNeeded(provider, showWarningDialog: true, delegate { CancellableBusyDialog busyDialog = new CancellableBusyDialog(LanguageControl.Get(fName, 10), autoHideOnCancel: false); DialogsManager.ShowDialog(null, busyDialog); Task.Run(delegate { bool needsDelete = false; string sourcePath = null; Stream stream = null; Action cleanup = delegate { Utilities.Dispose(ref stream); if (needsDelete && sourcePath != null) { try { Storage.DeleteFile(sourcePath); } catch { } } }; try { string path; if (type == ExternalContentType.BlocksTexture) { sourcePath = BlocksTexturesManager.GetFileName(name); if (sourcePath == null) { throw new InvalidOperationException(LanguageControl.Get(fName, 11)); } path = Storage.GetFileName(sourcePath); } else if (type == ExternalContentType.CharacterSkin) { sourcePath = CharacterSkinsManager.GetFileName(name); if (sourcePath == null) { throw new InvalidOperationException(LanguageControl.Get(fName, 11)); } path = Storage.GetFileName(sourcePath); } else if (type == ExternalContentType.FurniturePack) { sourcePath = FurniturePacksManager.GetFileName(name); if (sourcePath == null) { throw new InvalidOperationException(LanguageControl.Get(fName, 11)); } path = Storage.GetFileName(sourcePath); } else { if (type != ExternalContentType.World) { throw new InvalidOperationException(LanguageControl.Get(fName, 12)); } busyDialog.LargeMessage = LanguageControl.Get(fName, 13); sourcePath = "android:SurvivalCraft2.2/WorldUpload.tmp"; needsDelete = true; string name2 = WorldsManager.GetWorldInfo(name).WorldSettings.Name; path = $"{name2}.scworld"; using (Stream targetStream = Storage.OpenFile(sourcePath, OpenFileMode.Create)) { WorldsManager.ExportWorld(name, targetStream); } } busyDialog.LargeMessage = LanguageControl.Get(fName, 14); stream = Storage.OpenFile(sourcePath, OpenFileMode.Read); provider.Upload(path, stream, busyDialog.Progress, delegate(string link) { long length = stream.Length; cleanup(); DialogsManager.HideDialog(busyDialog); if (string.IsNullOrEmpty(link)) { DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "success"), string.Format(LanguageControl.Get(fName, 15), DataSizeFormatter.Format(length)), LanguageControl.Get("Usual", "ok"), null, null)); } else { DialogsManager.ShowDialog(null, new ExternalContentLinkDialog(link)); } }, delegate(Exception error) { cleanup(); DialogsManager.HideDialog(busyDialog); DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "error"), error.Message, LanguageControl.Get("Usual", "ok"), null, null)); }); } catch (Exception ex2) { cleanup(); DialogsManager.HideDialog(busyDialog); DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "error"), ex2.Message, LanguageControl.Get("Usual", "ok"), null, null)); } }); }); } } catch (Exception ex) { DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "error"), ex.Message, LanguageControl.Get("Usual", "ok"), null, null)); } })); }