예제 #1
0
 public void LoginLaunchBrowser()
 {
     try
     {
         LoginDialog login = new LoginDialog();
         login.succ = delegate(byte[] a) {
             StreamReader streamReader = new StreamReader(new MemoryStream(a));
             JsonObject   json         = (JsonObject)SimpleJson.SimpleJson.DeserializeObject(streamReader.ReadToEnd());
             int          code         = int.Parse(json["code"].ToString());
             string       msg          = json["msg"].ToString();
             if (code == 200)
             {
                 JsonObject token = (JsonObject)json["data"];
                 SettingsManager.ScpboxAccessToken = token["accessToken"].ToString();
                 DialogsManager.HideAllDialogs();
             }
             else
             {
                 login.tip.Text = msg;
             }
         };
         login.fail = delegate(Exception e) { login.tip.Text = e.ToString(); };
         DialogsManager.ShowDialog(null, login);
     }
     catch (Exception error)
     {
         m_loginProcessData.Fail(this, error);
     }
 }
        public override void Enter(object[] parameters)
        {
            BusyDialog dialog = new BusyDialog("Scanning Worlds", (string)null);

            DialogsManager.ShowDialog((Dialog)dialog);
            Task.Run((Action)(() =>
            {
                WorldInfo selectedItem = (WorldInfo)this.m_worldsListWidget.SelectedItem;
                WorldsManager.UpdateWorldsList();
                List <WorldInfo> worldInfos = new List <WorldInfo>((IEnumerable <WorldInfo>)(object) WorldsManager.WorldInfos);
                worldInfos.Sort((Comparison <WorldInfo>)((w1, w2) => DateTime.Compare(w2.LastSaveTime, w1.LastSaveTime)));
                Dispatcher.Dispatch((Action)(() =>
                {
                    this.m_worldsListWidget.ClearItems();
                    foreach (object obj in worldInfos)
                    {
                        this.m_worldsListWidget.AddItem(obj);
                    }
                    if (selectedItem != null)
                    {
                        this.m_worldsListWidget.SelectedItem = (object)worldInfos.FirstOrDefault <WorldInfo>((Func <WorldInfo, bool>)(wi => wi.DirectoryName == selectedItem.DirectoryName));
                    }
                    DialogsManager.HideDialog((Dialog)dialog);
                }), false);
            }));
        }
예제 #3
0
        public override bool OnEditInventoryItem(IInventory inventory, int slotIndex, ComponentPlayer componentPlayer)
        {
            int value1           = inventory.GetSlotValue(slotIndex);
            int count            = inventory.GetSlotCount(slotIndex);
            int id               = Terrain.ExtractData(value1);
            var commandBlockData = GetItemData(id);

            if (commandBlockData != null)
            {
                commandBlockData = (CommandData)commandBlockData.Copy();
            }
            else
            {
                commandBlockData = new CommandData();
            }
            DialogsManager.ShowDialog(componentPlayer.View.GameWidget, new TextBoxDialog("enter a one-line command", commandBlockData.Command, 300, delegate(string result)
            {
                commandBlockData.Command = result;
                var data  = StoreItemDataAtUniqueId(commandBlockData);
                var value = Terrain.ReplaceData(value1, data);
                inventory.RemoveSlotItems(slotIndex, count);
                inventory.AddSlotItems(slotIndex, value, 1);
            }));
            return(true);
        }
예제 #4
0
 public override void Update()
 {
     if (m_windowModeButton.IsClicked)
     {
         SettingsManager.WindowMode = (WindowMode)((int)(SettingsManager.WindowMode + 1) % EnumUtils.GetEnumValues(typeof(WindowMode)).Count);
     }
     if (m_languageButton.IsClicked)
     {
         DialogsManager.ShowDialog(null, 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)
             {
                 ModsManager.modSettings.languageType = (LanguageControl.LanguageType)((int)(ModsManager.modSettings.languageType + 1) % EnumUtils.GetEnumValues(typeof(LanguageControl.LanguageType)).Count);
                 ModsManager.SaveSettings();
                 System.Environment.Exit(0);
             }
         }));
     }
     if (m_uiSizeButton.IsClicked)
     {
         SettingsManager.GuiSize = (GuiSize)((int)(SettingsManager.GuiSize + 1) % EnumUtils.GetEnumValues(typeof(GuiSize)).Count);
     }
     if (m_upsideDownButton.IsClicked)
     {
         SettingsManager.UpsideDownLayout = !SettingsManager.UpsideDownLayout;
     }
     if (m_hideMoveLookPadsButton.IsClicked)
     {
         SettingsManager.HideMoveLookPads = !SettingsManager.HideMoveLookPads;
     }
     if (m_showGuiInScreenshotsButton.IsClicked)
     {
         SettingsManager.ShowGuiInScreenshots = !SettingsManager.ShowGuiInScreenshots;
     }
     if (m_showLogoInScreenshotsButton.IsClicked)
     {
         SettingsManager.ShowLogoInScreenshots = !SettingsManager.ShowLogoInScreenshots;
     }
     if (m_screenshotSizeButton.IsClicked)
     {
         SettingsManager.ScreenshotSize = (ScreenshotSize)((int)(SettingsManager.ScreenshotSize + 1) % EnumUtils.GetEnumValues(typeof(ScreenshotSize)).Count);
     }
     if (m_communityContentModeButton.IsClicked)
     {
         SettingsManager.CommunityContentMode = (CommunityContentMode)((int)(SettingsManager.CommunityContentMode + 1) % EnumUtils.GetEnumValues(typeof(CommunityContentMode)).Count);
     }
     m_windowModeButton.Text            = LanguageControl.Get("WindowMode", SettingsManager.WindowMode.ToString());
     m_uiSizeButton.Text                = LanguageControl.Get("GuiSize", SettingsManager.GuiSize.ToString());
     m_languageButton.Text              = LanguageControl.LName();
     m_upsideDownButton.Text            = (SettingsManager.UpsideDownLayout ? LanguageControl.Get("Usual", "yes") : LanguageControl.Get("Usual", "no"));
     m_hideMoveLookPadsButton.Text      = (SettingsManager.HideMoveLookPads ? LanguageControl.Get("Usual", "yes") : LanguageControl.Get("Usual", "no"));
     m_showGuiInScreenshotsButton.Text  = (SettingsManager.ShowGuiInScreenshots ? LanguageControl.Get("Usual", "yes") : LanguageControl.Get("Usual", "no"));
     m_showLogoInScreenshotsButton.Text = (SettingsManager.ShowLogoInScreenshots ? LanguageControl.Get("Usual", "yes") : LanguageControl.Get("Usual", "no"));
     m_screenshotSizeButton.Text        = LanguageControl.Get("ScreenshotSize", SettingsManager.ScreenshotSize.ToString());
     m_communityContentModeButton.Text  = LanguageControl.Get("CommunityContentMode", SettingsManager.CommunityContentMode.ToString());
     if (base.Input.Back || base.Input.Cancel || Children.Find <ButtonWidget>("TopBar.Back").IsClicked)
     {
         ScreensManager.SwitchScreen(ScreensManager.PreviousScreen);
     }
 }
예제 #5
0
 public override void Update()
 {
     if (animals.IsChecked)
     {
         DialogsManager.ShowDialog(ParentWidget,
                                   new ListSelectionDialog("select a animal name to copy",
                                                           SearchForKeyWord(textBoxAnimal.Text, commandEngine.creatureTemplateNames.Keys),
                                                           64f,
                                                           arg => arg.ToString(),
                                                           obj =>
         {
             string result = obj.ToString();
             ClipboardManager.ClipboardString = result;
         }));
     }
     if (blocks.IsChecked)
     {
         DialogsManager.ShowDialog(ParentWidget,
                                   new ListSelectionDialog("select a block to copy id",
                                                           SearchForKeyWord(textBoxBlock.Text, commandEngine.blockIds.Keys),
                                                           64f,
                                                           arg => arg.ToString(),
                                                           obj =>
         {
             int result = commandEngine.blockIds[obj.ToString()];
             ClipboardManager.ClipboardString = result.ToString();
         }));
     }
     if (Input.Cancel || back.IsClicked)
     {
         DialogsManager.HideDialog(this);
     }
 }
예제 #6
0
 public override void Update()
 {
     if (m_singlethreadedTerrainUpdateButton.IsClicked)
     {
         SettingsManager.MultithreadedTerrainUpdate = !SettingsManager.MultithreadedTerrainUpdate;
         m_descriptionLabel.Text = StringsManager.GetString("Settings.Compatibility.SinglethreadedTerrainUpdate.Description");
     }
     if (m_useReducedZRangeButton.IsClicked)
     {
         SettingsManager.UseReducedZRange = !SettingsManager.UseReducedZRange;
         m_descriptionLabel.Text          = StringsManager.GetString("Settings.Compatibility.UseReducedZRange.Description");
     }
     if (m_viewGameLogButton.IsClicked)
     {
         DialogsManager.ShowDialog(null, new ViewGameLogDialog());
     }
     if (m_resetDefaultsButton.IsClicked)
     {
         SettingsManager.MultithreadedTerrainUpdate = true;
         SettingsManager.UseReducedZRange           = false;
     }
     if (m_useAudioTrackCachingButton.IsClicked)
     {
         SettingsManager.EnableAndroidAudioTrackCaching = !SettingsManager.EnableAndroidAudioTrackCaching;
     }
     m_singlethreadedTerrainUpdateButton.Text = (SettingsManager.MultithreadedTerrainUpdate ? LanguageControl.Get("Usual", "off") : LanguageControl.Get("Usual", "on"));
     m_useReducedZRangeButton.Text            = (SettingsManager.UseReducedZRange ? LanguageControl.Get("Usual", "on") : LanguageControl.Get("Usual", "off"));
     m_useAudioTrackCachingButton.Text        = (SettingsManager.EnableAndroidAudioTrackCaching? LanguageControl.Get("Usual", "on") : LanguageControl.Get("Usual", "off"));
     m_resetDefaultsButton.IsEnabled          = (!SettingsManager.MultithreadedTerrainUpdate || SettingsManager.UseReducedZRange);
     if (base.Input.Back || base.Input.Cancel || Children.Find <ButtonWidget>("TopBar.Back").IsClicked)
     {
         ScreensManager.SwitchScreen(ScreensManager.PreviousScreen);
     }
 }
예제 #7
0
        public override void Enter(object[] parameters)
        {
            BusyDialog dialog = new BusyDialog(LanguageControl.GetContentWidgets(fName, 5), null);

            DialogsManager.ShowDialog(null, dialog);
            Task.Run(delegate
            {
                WorldInfo selectedItem = (WorldInfo)m_worldsListWidget.SelectedItem;
                WorldsManager.UpdateWorldsList();
                List <WorldInfo> worldInfos = new List <WorldInfo>(WorldsManager.WorldInfos);
                worldInfos.Sort((WorldInfo w1, WorldInfo w2) => DateTime.Compare(w2.LastSaveTime, w1.LastSaveTime));
                Dispatcher.Dispatch(delegate
                {
                    m_worldsListWidget.ClearItems();
                    foreach (WorldInfo item in worldInfos)
                    {
                        m_worldsListWidget.AddItem(item);
                    }
                    if (selectedItem != null)
                    {
                        m_worldsListWidget.SelectedItem = worldInfos.FirstOrDefault((WorldInfo wi) => wi.DirectoryName == selectedItem.DirectoryName);
                    }
                    DialogsManager.HideDialog(dialog);
                });
            });
        }
예제 #8
0
 public void UpdateList()
 {
     m_directoryList.ClearItems();
     if (m_externalContentProvider != null && m_externalContentProvider.IsLoggedIn)
     {
         CancellableBusyDialog busyDialog = new CancellableBusyDialog(LanguageControl.Get(fName, 9), autoHideOnCancel: false);
         DialogsManager.ShowDialog(null, busyDialog);
         m_externalContentProvider.List(m_path, busyDialog.Progress, delegate(ExternalContentEntry entry)
         {
             DialogsManager.HideDialog(busyDialog);
             List <ExternalContentEntry> list = new List <ExternalContentEntry>(entry.ChildEntries.Where((ExternalContentEntry e) => EntryFilter(e)).Take(1000));
             m_directoryList.ClearItems();
             list.Sort(delegate(ExternalContentEntry e1, ExternalContentEntry e2)
             {
                 if (e1.Type == ExternalContentType.Directory && e2.Type != ExternalContentType.Directory)
                 {
                     return(-1);
                 }
                 return((e1.Type != ExternalContentType.Directory && e2.Type == ExternalContentType.Directory) ? 1 : string.Compare(e1.Path, e2.Path));
             });
             foreach (ExternalContentEntry item in list)
             {
                 m_directoryList.AddItem(item);
             }
         }, delegate(Exception error)
         {
             DialogsManager.HideDialog(busyDialog);
             DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "error"), error.Message, LanguageControl.Get("Usual", "ok"), null, null));
         });
     }
 }
 public override void Update()
 {
     m_rateButton.IsEnabled = (m_starRating.Rating != 0f);
     if (m_rateButton.IsClicked)
     {
         DialogsManager.HideDialog(this);
         CancellableBusyDialog busyDialog = new CancellableBusyDialog("иб╦═к└иоол...", autoHideOnCancel: false);
         DialogsManager.ShowDialog(base.ParentWidget, busyDialog);
         CommunityContentManager.Rate(m_address, m_userId, (int)m_starRating.Rating, busyDialog.Progress, delegate
         {
             DialogsManager.HideDialog(busyDialog);
         }, delegate
         {
             DialogsManager.HideDialog(busyDialog);
         });
     }
     if (m_reportLink.IsClicked && UserManager.ActiveUser != null)
     {
         DialogsManager.HideDialog(this);
         DialogsManager.ShowDialog(base.ParentWidget, new ReportCommunityContentDialog(m_address, m_displayName, UserManager.ActiveUser.UniqueId));
     }
     if (base.Input.Cancel || m_cancelButton.IsClicked)
     {
         DialogsManager.HideDialog(this);
     }
 }
예제 #10
0
        public void PopulateList(string cursor)
        {
            string text = string.Empty;

            if (SettingsManager.CommunityContentMode == CommunityContentMode.Strict)
            {
                text = "1";
            }
            if (SettingsManager.CommunityContentMode == CommunityContentMode.Normal)
            {
                text = "0";
            }
            string text2    = (m_filter is string) ? ((string)m_filter) : string.Empty;
            string text3    = (m_filter is ExternalContentType) ? LanguageControl.Get(fName, m_filter.ToString()) : string.Empty;
            string text4    = LanguageControl.Get(fName, m_order.ToString());
            string cacheKey = text2 + "\n" + text3 + "\n" + text4 + "\n" + text;

            m_moreLink = null;
            if (string.IsNullOrEmpty(cursor))
            {
                m_listPanel.ClearItems();
                m_listPanel.ScrollPosition = 0f;
                if (m_contentExpiryTime != 0.0 && Time.RealTime < m_contentExpiryTime && m_itemsCache.TryGetValue(cacheKey, out IEnumerable <object> value))
                {
                    foreach (object item in value)
                    {
                        m_listPanel.AddItem(item);
                    }
                    return;
                }
            }
            CancellableBusyDialog busyDialog = new CancellableBusyDialog(LanguageControl.Get(fName, 2), autoHideOnCancel: false);

            DialogsManager.ShowDialog(null, busyDialog);
            CommunityContentManager.List(cursor, text2, text3, text, text4, busyDialog.Progress, delegate(List <CommunityContentEntry> list, string nextCursor)
            {
                DialogsManager.HideDialog(busyDialog);
                m_contentExpiryTime = Time.RealTime + 300.0;
                while (m_listPanel.Items.Count > 0 && !(m_listPanel.Items[m_listPanel.Items.Count - 1] is CommunityContentEntry))
                {
                    m_listPanel.RemoveItemAt(m_listPanel.Items.Count - 1);
                }
                foreach (CommunityContentEntry item2 in list)
                {
                    m_listPanel.AddItem(item2);
                }
                if (list.Count > 0 && !string.IsNullOrEmpty(nextCursor))
                {
                    m_listPanel.AddItem(nextCursor);
                }
                m_itemsCache[cacheKey] = new List <object>(m_listPanel.Items);
            }, delegate(Exception error)
            {
                DialogsManager.HideDialog(busyDialog);
                DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "error"), error.Message, LanguageControl.Get("Usual", "ok"), null, null));
            });
        }
예제 #11
0
 public bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner)
 {
     ComponentPlayer = componentMiner.ComponentPlayer;
     if (!Powered || ComponentPlayer == null)
     {
         return(false);
     }
     DialogsManager.ShowDialog(ComponentPlayer.View.GameWidget, new TextBoxDialog("Enter Code", lastcode, int.MaxValue, Execute));
     return(true);
 }
예제 #12
0
 public override void Update()
 {
     for (int j = 0; j < 16; j++)
     {
         m_labels[j].Text            = m_tmpPalette.Names[j];
         m_rectangles[j].CenterColor = m_tmpPalette.Colors[j];
         m_resetButtons[j].IsEnabled = (m_tmpPalette.Colors[j] != WorldPalette.DefaultColors[j] || m_tmpPalette.Names[j] != LanguageControl.Get("WorldPalette", j));
     }
     for (int k = 0; k < 16; k++)
     {
         int i = k;
         if (m_labels[k].IsClicked)
         {
             DialogsManager.ShowDialog(this, new TextBoxDialog("Edit Color Name", m_labels[k].Text, 16, delegate(string s)
             {
                 if (s != null)
                 {
                     if (WorldPalette.VerifyColorName(s))
                     {
                         m_tmpPalette.Names[i] = s;
                     }
                     else
                     {
                         DialogsManager.ShowDialog(this, new MessageDialog("Invalid name", null, "OK", null, null));
                     }
                 }
             }));
         }
         if (m_rectangles[k].IsClicked)
         {
             DialogsManager.ShowDialog(this, new EditColorDialog(m_tmpPalette.Colors[k], delegate(Color? color)
             {
                 if (color.HasValue)
                 {
                     m_tmpPalette.Colors[i] = color.Value;
                 }
             }));
         }
         if (m_resetButtons[k].IsClicked)
         {
             m_tmpPalette.Colors[k] = WorldPalette.DefaultColors[k];
             m_tmpPalette.Names[k]  = LanguageControl.Get("WorldPalette", k);
         }
     }
     if (m_okButton.IsClicked)
     {
         m_tmpPalette.CopyTo(m_palette);
         Dismiss();
     }
     if (base.Input.Cancel || m_cancelButton.IsClicked)
     {
         Dismiss();
     }
 }
예제 #13
0
 public override void Update()
 {
     try
     {
         m_stateMachine.Update();
     }
     catch (Exception e)
     {
         ScreensManager.SwitchScreen(ScreensManager.PreviousScreen);
         DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get(fName, 1), ExceptionManager.MakeFullErrorMessage(e), LanguageControl.Get("Usual", "ok"), null, null));
     }
 }
예제 #14
0
        public override void Update()
        {
            if (!m_loadingStarted)
            {
                m_loadingStarted = true;
            }
            else
            {
                if (m_loadingFinished)
                {
                    return;
                }
                double realTime = Time.RealTime;
                while (!m_pauseLoading && m_index < m_loadActions.Count)
                {
                    try
                    {
                        m_loadActions[m_index++]();
                    }
                    catch (Exception ex)
                    {
                        Log.Error("Loading error. Reason: " + ex.Message);
                        if (!m_loadingErrorsSuppressed)
                        {
                            m_pauseLoading = true;
                            DialogsManager.ShowDialog(ScreensManager.RootWidget, new MessageDialog("Loading Error", ExceptionManager.MakeFullErrorMessage(ex), LanguageControl.Get("Usual", "ok"), "Suppress", delegate(MessageDialogButton b)
                            {
                                switch (b)
                                {
                                case MessageDialogButton.Button1:
                                    m_pauseLoading = false;
                                    break;

                                case MessageDialogButton.Button2:
                                    m_loadingErrorsSuppressed = true;
                                    break;
                                }
                            }));
                        }
                    }
                    if (Time.RealTime - realTime > 0.1)
                    {
                        break;
                    }
                }
                if (m_index >= m_loadActions.Count)
                {
                    m_loadingFinished = true;
                    AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
                    ScreensManager.SwitchScreen("MainMenu");
                }
            }
        }
예제 #15
0
 public void WindowActivated()
 {
     if (m_loginProcessData != null && !m_loginProcessData.IsTokenFlow)
     {
         LoginProcessData loginProcessData = m_loginProcessData;
         m_loginProcessData = null;
         TextBoxDialog dialog = new TextBoxDialog("输入用户登录Token:", "", 256, delegate(string s)
         {
             if (s != null)
             {
                 try
                 {
                     WebManager.Post(m_redirectUri + "/com/oauth2/token", new Dictionary <string, string>
                     {
                         {
                             "code",
                             s.Trim()
                         },
                         {
                             "client_id",
                             "1unnzwkb8igx70k"
                         },
                         {
                             "client_secret",
                             "3i5u3j3141php7u"
                         },
                         {
                             "grant_type",
                             "authorization_code"
                         }
                     }, null, new MemoryStream(), loginProcessData.Progress, delegate(byte[] result)
                     {
                         SettingsManager.ScpboxAccessToken = ((IDictionary <string, object>)WebManager.JsonFromBytes(result))["access_token"].ToString();
                         loginProcessData.Succeed(this);
                     }, delegate(Exception error)
                     {
                         loginProcessData.Fail(this, error);
                     });
                 }
                 catch (Exception error2)
                 {
                     loginProcessData.Fail(this, error2);
                 }
             }
             else
             {
                 loginProcessData.Fail(this, null);
             }
         });
         DialogsManager.ShowDialog(null, dialog);
     }
 }
예제 #16
0
 public bool VerifyName()
 {
     if (m_nameWasInvalid)
     {
         return(false);
     }
     if (PlayerData.VerifyName(m_nameTextBox.Text.Trim()))
     {
         return(true);
     }
     DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "error"), LanguageControl.Get(fName, 12), LanguageControl.Get("Usual", "ok"), null, null));
     return(false);
 }
예제 #17
0
 public void ExportFurnitureSet()
 {
     try
     {
         FurnitureDesign[] designs     = SubsystemFurnitureBlockBehavior.GetFurnitureSetDesigns(ComponentFurnitureInventory.FurnitureSet).ToArray();
         string            displayName = FurniturePacksManager.GetDisplayName(FurniturePacksManager.CreateFurniturePack(ComponentFurnitureInventory.FurnitureSet.Name, designs));
         DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, new MessageDialog(LanguageControl.Get(fName, 21), string.Format(LanguageControl.Get(fName, 22), displayName), LanguageControl.Get("Usual", "ok"), null, null));
     }
     catch (Exception ex)
     {
         DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, new MessageDialog(LanguageControl.Get(fName, 23), ex.Message, LanguageControl.Get("Usual", "ok"), null, null));
     }
 }
예제 #18
0
 public static void SaveProject(bool waitForCompletion, bool showErrorDialog)
 {
     if (m_project != null)
     {
         double      realTime    = Time.RealTime;
         ProjectData projectData = m_project.Save();
         m_saveCompleted.WaitOne();
         m_saveCompleted.Reset();
         SubsystemGameInfo subsystemGameInfo = m_project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
         string            projectFileName   = Storage.CombinePaths(subsystemGameInfo.DirectoryName, "Project.xml");
         Exception         e = default(Exception);
         Task.Run(delegate
         {
             try
             {
                 WorldsManager.MakeQuickWorldBackup(subsystemGameInfo.DirectoryName);
                 XElement xElement = new XElement("Project");
                 projectData.Save(xElement);
                 XmlUtils.SetAttributeValue(xElement, "Version", VersionsManager.SerializationVersion);
                 Storage.CreateDirectory(subsystemGameInfo.DirectoryName);
                 using (Stream stream = Storage.OpenFile(projectFileName, OpenFileMode.Create))
                 {
                     XmlUtils.SaveXmlToStream(xElement, stream, null, throwOnError: true);
                 }
             }
             catch (Exception ex)
             {
                 e = ex;
                 if (showErrorDialog)
                 {
                     Dispatcher.Dispatch(delegate
                     {
                         DialogsManager.ShowDialog(null, new MessageDialog("Error saving game", e.Message, LanguageControl.Get("Usual", "ok"), null, null));
                     });
                 }
             }
             finally
             {
                 m_saveCompleted.Set();
             }
         });
         if (waitForCompletion)
         {
             m_saveCompleted.WaitOne();
         }
         double realTime2 = Time.RealTime;
         Log.Verbose($"Saved project, {MathUtils.Round((realTime2 - realTime) * 1000.0)}ms");
     }
 }
예제 #19
0
        public void DownloadEntry(CommunityContentEntry entry)
        {
            string userId = (UserManager.ActiveUser != null) ? UserManager.ActiveUser.UniqueId : string.Empty;
            CancellableBusyDialog busyDialog = new CancellableBusyDialog(string.Format(LanguageControl.Get(fName, 1), entry.Name), autoHideOnCancel: false);

            DialogsManager.ShowDialog(null, busyDialog);
            CommunityContentManager.Download(entry.Address, entry.Name, entry.Type, userId, busyDialog.Progress, delegate
            {
                DialogsManager.HideDialog(busyDialog);
            }, delegate(Exception error)
            {
                DialogsManager.HideDialog(busyDialog);
                DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "error"), error.Message, LanguageControl.Get("Usual", "ok"), null, null));
            });
        }
예제 #20
0
 public void ShowTopic(HelpTopic helpTopic)
 {
     if (helpTopic.Name == "Keyboard")
     {
         DialogsManager.ShowDialog(null, new KeyboardHelpDialog());
     }
     else if (helpTopic.Name == "Gamepad")
     {
         DialogsManager.ShowDialog(null, new GamepadHelpDialog());
     }
     else
     {
         ScreensManager.SwitchScreen("HelpTopic", helpTopic);
     }
 }
예제 #21
0
        public override bool OnEditBlock(int x, int y, int z, int value, ComponentPlayer componentPlayer)
        {
            CommandData commandBlockData = GetBlockData(new Point3(x, y, z)) ?? new CommandData();

            DialogsManager.ShowDialog(componentPlayer.View.GameWidget, new TextBoxDialog("enter one-line command", commandBlockData.Command, 300, delegate(string result)
            {
                commandBlockData.Command = result;
                SetBlockData(new Point3(x, y, z), commandBlockData);
                var electricElement = subsystemElectricity.GetElectricElement(x, y, z, 0);
                if (electricElement != null)
                {
                    subsystemElectricity.QueueElectricElementForSimulation(electricElement, subsystemElectricity.CircuitStep + 1);
                }
            }));
            return(true);
        }
예제 #22
0
        public override bool OnEditBlock(int x, int y, int z, int value, ComponentPlayer componentPlayer)
        {
            MemoryBankData memoryBankData = GetBlockData(new Point3(x, y, z)) ?? new MemoryBankData();

            DialogsManager.ShowDialog(componentPlayer.GuiWidget, new EditMemeryDialogB(memoryBankData, delegate() {
                SetBlockData(new Point3(x, y, z), memoryBankData);
                int face = ((MemoryBankBlock)BlocksManager.Blocks[186]).GetFace(value);
                SubsystemElectricity subsystemElectricity = base.SubsystemTerrain.Project.FindSubsystem <SubsystemElectricity>(throwOnError: true);
                ElectricElement electricElement           = subsystemElectricity.GetElectricElement(x, y, z, face);
                if (electricElement != null)
                {
                    subsystemElectricity.QueueElectricElementForSimulation(electricElement, subsystemElectricity.CircuitStep + 1);
                }
            }));
            return(true);
        }
예제 #23
0
        public override bool OnEditInventoryItem(IInventory inventory, int slotIndex, ComponentPlayer componentPlayer)
        {
            int value = inventory.GetSlotValue(slotIndex);
            int count = inventory.GetSlotCount(slotIndex);
            int data  = Terrain.ExtractData(value);

            DialogsManager.ShowDialog(componentPlayer.GuiWidget, new EditPistonDialog(data, delegate(int newData)
            {
                int num = Terrain.ReplaceData(value, newData);
                if (num != value)
                {
                    inventory.RemoveSlotItems(slotIndex, count);
                    inventory.AddSlotItems(slotIndex, num, 1);
                }
            }));
            return(true);
        }
예제 #24
0
        public ViewGameLogDialog()
        {
            XElement node = ContentManager.Get <XElement>("Dialogs/ViewGameLogDialog");

            LoadContents(this, node);
            m_listPanel              = Children.Find <ListPanelWidget>("ViewGameLogDialog.ListPanel");
            m_copyButton             = Children.Find <ButtonWidget>("ViewGameLogDialog.CopyButton");
            m_filterButton           = Children.Find <ButtonWidget>("ViewGameLogDialog.FilterButton");
            m_closeButton            = Children.Find <ButtonWidget>("ViewGameLogDialog.CloseButton");
            m_listPanel.ItemClicked += delegate(object item)
            {
                if (m_listPanel.SelectedItem == item)
                {
                    DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog("Log Item", item.ToString(), LanguageControl.Get("Usual", "ok"), null, null));
                }
            };
            PopulateList();
        }
예제 #25
0
 public override void Update()
 {
     if (m_categoryLeftButton.IsClicked || base.Input.Left)
     {
         int num = --m_componentCreativeInventory.CategoryIndex;
     }
     if (m_categoryRightButton.IsClicked || base.Input.Right)
     {
         int num = ++m_componentCreativeInventory.CategoryIndex;
     }
     if (m_categoryButton.IsClicked)
     {
         ComponentPlayer componentPlayer = Entity.FindComponent <ComponentPlayer>();
         if (componentPlayer != null)
         {
             DialogsManager.ShowDialog(componentPlayer.GuiWidget, new ListSelectionDialog(string.Empty, m_categories, 56f, (object c) => new LabelWidget
             {
                 Text  = ((Category)c).Name,
                 Color = ((Category)c).Color,
                 HorizontalAlignment = WidgetAlignment.Center,
                 VerticalAlignment   = WidgetAlignment.Center
             }, delegate(object c)
             {
                 if (c != null)
                 {
                     m_componentCreativeInventory.CategoryIndex = m_categories.IndexOf((Category)c);
                 }
             }));
         }
     }
     m_componentCreativeInventory.CategoryIndex = MathUtils.Clamp(m_componentCreativeInventory.CategoryIndex, 0, m_categories.Count - 1);
     m_categoryButton.Text           = m_categories[m_componentCreativeInventory.CategoryIndex].Name;
     m_categoryLeftButton.IsEnabled  = (m_componentCreativeInventory.CategoryIndex > 0);
     m_categoryRightButton.IsEnabled = (m_componentCreativeInventory.CategoryIndex < m_categories.Count - 1);
     if (m_componentCreativeInventory.CategoryIndex != m_activeCategoryIndex)
     {
         foreach (Category category in m_categories)
         {
             category.Panel.IsVisible = false;
         }
         m_categories[m_componentCreativeInventory.CategoryIndex].Panel.IsVisible = true;
         m_activeCategoryIndex = m_componentCreativeInventory.CategoryIndex;
     }
 }
예제 #26
0
        public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner)
        {
            AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
            Point3 point = new Point3(raycastResult.CellFace.X, raycastResult.CellFace.Y, raycastResult.CellFace.Z);

            if (m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Adventure)
            {
                SignData signData = GetSignData(point);
                if (signData != null && !string.IsNullOrEmpty(signData.Url))
                {
                    WebBrowserManager.LaunchBrowser(signData.Url);
                }
            }
            else if (componentMiner.ComponentPlayer != null)
            {
                DialogsManager.ShowDialog(componentMiner.ComponentPlayer.GuiWidget, new EditSignDialog(this, point));
            }
            return(true);
        }
예제 #27
0
 public static void MigrateDataFromIsolatedStorageWithDialog()
 {
     try
     {
         if (Storage.DirectoryExists("data:/.config/.isolated-storage"))
         {
             Log.Information("1.26 data found, starting migration to 1.27.");
             BusyDialog dialog = new BusyDialog("Please wait", "Migrating 1.26 data to 1.27 format...");
             DialogsManager.ShowDialog(null, dialog);
             Task.Run(delegate
             {
                 string empty  = string.Empty;
                 string empty2 = string.Empty;
                 try
                 {
                     int num = MigrateFolder("data:/.config/.isolated-storage", "data:");
                     empty   = "Migration Successful";
                     empty2  = $"{num} file(s) were migrated from 1.26 to 1.27.";
                     AnalyticsManager.LogEvent("[Migration to 1.27]", new AnalyticsParameter("Details", empty2));
                 }
                 catch (Exception ex2)
                 {
                     empty  = "Migration Failed";
                     empty2 = ex2.Message;
                     Log.Error("Migration to 1.27 failed, reason: {0}", ex2.Message);
                     AnalyticsManager.LogError("Migration to 1.27 failed", ex2);
                 }
                 DialogsManager.HideDialog(dialog);
                 DialogsManager.ShowDialog(null, new MessageDialog(empty, empty2, LanguageControl.Get("Usual", "ok"), null, null));
                 Dispatcher.Dispatch(delegate
                 {
                     SettingsManager.LoadSettings();
                 });
             });
         }
     }
     catch (Exception ex)
     {
         Log.Error("Failed to migrate data. Reason: {0}", ex.Message);
         AnalyticsManager.LogError("Migration to 1.27 failed", ex);
     }
 }
예제 #28
0
 public static void ShowLoginUiIfNeeded(IExternalContentProvider provider, bool showWarningDialog, Action handler)
 {
     if (provider.RequiresLogin && !provider.IsLoggedIn)
     {
         Action loginAction = delegate
         {
             CancellableBusyDialog busyDialog = new CancellableBusyDialog(LanguageControl.Get(fName, 5), autoHideOnCancel: true);
             DialogsManager.ShowDialog(null, busyDialog);
             provider.Login(busyDialog.Progress, delegate
             {
                 DialogsManager.HideDialog(busyDialog);
                 handler?.Invoke();
             }, delegate(Exception error)
             {
                 DialogsManager.HideDialog(busyDialog);
                 if (error != null)
                 {
                     DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "error"), error.Message, LanguageControl.Get("Usual", "ok"), null, null));
                 }
             });
         };
         if (showWarningDialog)
         {
             DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get(fName, 6), string.Format(LanguageControl.Get(fName, 7), provider.DisplayName), LanguageControl.Get(fName, 8), LanguageControl.Get("Usual", "cancel"), delegate(MessageDialogButton b)
             {
                 if (b == MessageDialogButton.Button1)
                 {
                     loginAction();
                 }
             }));
         }
         else
         {
             loginAction();
         }
     }
     else
     {
         handler?.Invoke();
     }
 }
예제 #29
0
 public override void Update()
 {
     if (m_rectangle.IsClicked)
     {
         DialogsManager.ShowDialog(this, new TextBoxDialog("Enter Color", GetColorString(), 20, delegate(string s)
         {
             if (s != null)
             {
                 try
                 {
                     m_color.RGB = HumanReadableConverter.ConvertFromString <Color>(s);
                 }
                 catch
                 {
                     DialogsManager.ShowDialog(this, new MessageDialog("Invalid Color", "Use R,G,B or #HEX notation, e.g. 255,92,13 or #FF5C0D", LanguageControl.Get("Usual", "ok"), null, null));
                 }
             }
         }));
     }
     if (m_sliderR.IsSliding)
     {
         m_color.R = (byte)m_sliderR.Value;
     }
     if (m_sliderG.IsSliding)
     {
         m_color.G = (byte)m_sliderG.Value;
     }
     if (m_sliderB.IsSliding)
     {
         m_color.B = (byte)m_sliderB.Value;
     }
     if (m_okButton.IsClicked)
     {
         Dismiss(m_color);
     }
     if (base.Input.Cancel || m_cancelButton.IsClicked)
     {
         Dismiss(null);
     }
     UpdateControls();
 }
예제 #30
0
        public override bool OnEditBlock(int x, int y, int z, int value, ComponentPlayer componentPlayer)
        {
            int contents = Terrain.ExtractContents(value);
            int data     = Terrain.ExtractData(value);

            DialogsManager.ShowDialog(componentPlayer.GuiWidget, new EditPistonDialog(data, delegate(int newData)
            {
                if (newData != data && base.SubsystemTerrain.Terrain.GetCellContents(x, y, z) == contents)
                {
                    int value2 = Terrain.ReplaceData(value, newData);
                    base.SubsystemTerrain.ChangeCell(x, y, z, value2);
                    SubsystemElectricity subsystemElectricity = base.Project.FindSubsystem <SubsystemElectricity>(throwOnError: true);
                    ElectricElement electricElement           = subsystemElectricity.GetElectricElement(x, y, z, 0);
                    if (electricElement != null)
                    {
                        subsystemElectricity.QueueElectricElementForSimulation(electricElement, subsystemElectricity.CircuitStep + 1);
                    }
                }
            }));
            return(true);
        }