Ejemplo n.º 1
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);
     }
 }
Ejemplo n.º 2
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);
                });
            });
        }
Ejemplo n.º 3
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));
         });
     }
 }
Ejemplo n.º 4
0
 public override void Update()
 {
     if (base.Input.Cancel || m_okButtonWidget.IsClicked)
     {
         DialogsManager.HideDialog(this);
     }
 }
 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);
     }
 }
        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);
            }));
        }
Ejemplo n.º 7
0
 public void Dismiss(string result)
 {
     if (AutoHide)
     {
         DialogsManager.HideDialog(this);
     }
     m_handler?.Invoke(result);
 }
Ejemplo n.º 8
0
 public void HideSpawnDialog()
 {
     if (m_spawnDialog != null)
     {
         DialogsManager.HideDialog(m_spawnDialog);
         m_spawnDialog = null;
     }
 }
 public void Dismiss(int?result)
 {
     DialogsManager.HideDialog(this);
     if (m_handler != null && result.HasValue)
     {
         m_handler(result.Value);
     }
 }
Ejemplo n.º 10
0
 public void Dismiss(bool result)
 {
     DialogsManager.HideDialog(this);
     if (m_handler != null && result)
     {
         m_handler();
     }
 }
Ejemplo n.º 11
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));
            });
        }
Ejemplo n.º 12
0
 public void Dismiss(MessageDialogButton button)
 {
     if (AutoHide)
     {
         DialogsManager.HideDialog(this);
     }
     if (m_handler != null)
     {
         m_handler(button);
     }
 }
Ejemplo n.º 13
0
 public void Dismiss(object result)
 {
     if (!m_isDismissed)
     {
         m_isDismissed = true;
         DialogsManager.HideDialog(this);
         if (m_selectionHandler != null && result != null)
         {
             m_selectionHandler(result);
         }
     }
 }
Ejemplo n.º 14
0
 public override void Update()
 {
     if (okButton.IsClicked)
     {
         commandData.Command = textBox.Text;
         DialogsManager.HideDialog(this);
     }
     else if (cancelButton.IsClicked || Input.Cancel)
     {
         DialogsManager.HideDialog(this);
     }
 }
Ejemplo n.º 15
0
 public override void Update()
 {
     m_helpButton.IsVisible = !(ScreensManager.CurrentScreen is HelpScreen);
     if (m_okButton.IsClicked || base.Input.Cancel || base.Input.IsPadButtonDownOnce(GamePadButton.Start))
     {
         DialogsManager.HideDialog(this);
     }
     if (m_helpButton.IsClicked)
     {
         DialogsManager.HideDialog(this);
         ScreensManager.SwitchScreen("Help");
     }
 }
Ejemplo n.º 16
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));
            });
        }
Ejemplo n.º 17
0
 public override void Update()
 {
     if (btna.IsClicked)
     {
         Dictionary <string, string> par = new Dictionary <string, string>();
         par.Add("user", txa.Text);
         par.Add("pass", txb.Text);
         WebManager.Post(SPMBoxExternalContentProvider.m_redirectUri + "/com/api/login", par, null, new MemoryStream(), new CancellableProgress(), succ, fail);
     }
     if (btnb.IsClicked)
     {
         WebBrowserManager.LaunchBrowser(SPMBoxExternalContentProvider.m_redirectUri + "/com/reg");
     }
     if (btnc.IsClicked)
     {
         DialogsManager.HideDialog(this);
     }
 }
Ejemplo n.º 18
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);
     }
 }
Ejemplo n.º 19
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();
     }
 }
Ejemplo n.º 20
0
 public override void Update()
 {
     if (m_copyButton.IsClicked)
     {
         ClipboardManager.ClipboardString = GameLogSink.GetRecentLog(131072);
     }
     if (m_filterButton.IsClicked)
     {
         if (m_filter < LogType.Warning)
         {
             m_filter = LogType.Warning;
         }
         else if (m_filter < LogType.Error)
         {
             m_filter = LogType.Error;
         }
         else
         {
             m_filter = LogType.Debug;
         }
         PopulateList();
     }
     if (base.Input.Cancel || m_closeButton.IsClicked)
     {
         DialogsManager.HideDialog(this);
     }
     if (m_filter == LogType.Debug)
     {
         m_filterButton.Text = "All";
     }
     else if (m_filter == LogType.Warning)
     {
         m_filterButton.Text = "Warnings";
     }
     else if (m_filter == LogType.Error)
     {
         m_filterButton.Text = "Errors";
     }
 }
        public override void Update()
        {
            string text = (UserManager.ActiveUser != null) ? UserManager.ActiveUser.DisplayName : "No User";

            if (text.Length > 15)
            {
                text = text.Substring(0, 15) + "...";
            }
            m_userLabel.Text = text;
            string text2 = (UserManager.ActiveUser != null) ? UserManager.ActiveUser.UniqueId : "No User";

            if (text2.Length > 15)
            {
                text2 = text2.Substring(0, 15) + "...";
            }
            m_userIdLabel.Text           = text2;
            m_publishButton.IsEnabled    = (UserManager.ActiveUser != null);
            m_copyUserIdButton.IsEnabled = (UserManager.ActiveUser != null);
            if (m_changeUserButton.IsClicked)
            {
                DialogsManager.ShowDialog(base.ParentWidget, new ListSelectionDialog("Select Active User", UserManager.GetUsers(), 60f, (object item) => ((UserInfo)item).DisplayName, delegate(object item)
                {
                    UserManager.ActiveUser = (UserInfo)item;
                }));
            }
            if (m_copyUserIdButton.IsClicked && UserManager.ActiveUser != null)
            {
                ClipboardManager.ClipboardString = UserManager.ActiveUser.UniqueId;
            }
            if (m_publishButton.IsClicked && UserManager.ActiveUser != null)
            {
                DialogsManager.ShowDialog(base.ParentWidget, new PublishCommunityLinkDialog(UserManager.ActiveUser.UniqueId, null, null));
            }
            if (base.Input.Cancel || m_closeButton.IsClicked)
            {
                DialogsManager.HideDialog(this);
            }
        }
Ejemplo n.º 22
0
 public override void Update()
 {
     if (Progress.Completed > 0f && Progress.Total > 0f)
     {
         SmallMessage = $"{Progress.Completed / Progress.Total * 100f:0}%";
     }
     else
     {
         SmallMessage = string.Empty;
     }
     if (m_cancelButtonWidget.IsClicked)
     {
         Progress.Cancel();
         if (m_autoHideOnCancel)
         {
             DialogsManager.HideDialog(this);
         }
     }
     if (base.Input.Cancel)
     {
         base.Input.Clear();
     }
 }
Ejemplo n.º 23
0
 public void DeleteEntry(CommunityContentEntry entry)
 {
     if (UserManager.ActiveUser != null)
     {
         DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get(fName, 4), LanguageControl.Get(fName, 5), LanguageControl.Get("Usual", "yes"), LanguageControl.Get("Usual", "no"), delegate(MessageDialogButton button)
         {
             if (button == MessageDialogButton.Button1)
             {
                 CancellableBusyDialog busyDialog = new CancellableBusyDialog(string.Format(LanguageControl.Get(fName, 3), entry.Name), autoHideOnCancel: false);
                 DialogsManager.ShowDialog(null, busyDialog);
                 CommunityContentManager.Delete(entry.Address, UserManager.ActiveUser.UniqueId, busyDialog.Progress, delegate
                 {
                     DialogsManager.HideDialog(busyDialog);
                     DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get(fName, 6), LanguageControl.Get(fName, 7), 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.º 24
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));
                });
            }
        }
 public override void Update()
 {
     m_reportButton.IsEnabled = (m_reasonWidgetsList.Count((CheckboxWidget w) => w.IsChecked) == 1);
     if (m_reportButton.IsClicked)
     {
         DialogsManager.HideDialog(this);
         DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog("Are you sure?", "Reporting offensive content is a serious matter. Please make sure you checked the right box. Do not report content which is not offensive.", "Proceed", "Cancel", delegate(MessageDialogButton b)
         {
             if (b == MessageDialogButton.Button1)
             {
                 string report = string.Empty;
                 foreach (CheckboxWidget reasonWidgets in m_reasonWidgetsList)
                 {
                     if (reasonWidgets.IsChecked)
                     {
                         report = (string)reasonWidgets.Tag;
                         break;
                     }
                 }
                 CancellableBusyDialog busyDialog = new CancellableBusyDialog("Sending Report", autoHideOnCancel: false);
                 DialogsManager.ShowDialog(base.ParentWidget, busyDialog);
                 CommunityContentManager.Report(m_address, m_userId, report, busyDialog.Progress, delegate
                 {
                     DialogsManager.HideDialog(busyDialog);
                 }, delegate
                 {
                     DialogsManager.HideDialog(busyDialog);
                 });
             }
         }));
     }
     if (base.Input.Cancel || m_cancelButton.IsClicked)
     {
         DialogsManager.HideDialog(this);
     }
 }
Ejemplo n.º 26
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.º 27
0
 public void Dismiss()
 {
     DialogsManager.HideDialog(this);
 }
Ejemplo n.º 28
0
        public new void HandleInput()
        {
            WidgetInput    input          = m_componentPlayer.View.Input;
            PlayerInput    playerInput    = m_componentPlayer.ComponentInput.PlayerInput;
            ComponentRider componentRider = m_componentPlayer.ComponentRider;

            if (m_componentPlayer.View.ActiveCamera.IsEntityControlEnabled)
            {
                if (!m_keyboardHelpMessageShown && (m_componentPlayer.PlayerData.InputDevice & WidgetInputDevice.Keyboard) != 0 && Time.PeriodicEvent(7.0, 0.0))
                {
                    m_keyboardHelpMessageShown = true;
                    DisplaySmallMessage(Utils.Get("按 H 键查看键盘控制帮助\n(或看帮助)"), true, true);
                }
                else if (!m_gamepadHelpMessageShown && (m_componentPlayer.PlayerData.InputDevice & WidgetInputDevice.Gamepads) != 0 && Time.PeriodicEvent(7.0, 0.0))
                {
                    m_gamepadHelpMessageShown = true;
                    DisplaySmallMessage(Utils.Get("按 START/PAUSE 键查看手柄控制帮助\n(或看帮助)"), true, true);
                }
            }
            if (playerInput.KeyboardHelp)
            {
                if (m_keyboardHelpDialog == null)
                {
                    m_keyboardHelpDialog = new KeyboardHelpDialog();
                }
                if (m_keyboardHelpDialog.ParentWidget != null)
                {
                    DialogsManager.HideDialog(m_keyboardHelpDialog);
                }
                else
                {
                    DialogsManager.ShowDialog(m_componentPlayer.View.GameWidget, m_keyboardHelpDialog);
                }
            }
            if (playerInput.GamepadHelp)
            {
                if (m_gamepadHelpDialog == null)
                {
                    m_gamepadHelpDialog = new GamepadHelpDialog();
                }
                if (m_gamepadHelpDialog.ParentWidget != null)
                {
                    DialogsManager.HideDialog(m_gamepadHelpDialog);
                }
                else
                {
                    DialogsManager.ShowDialog(m_componentPlayer.View.GameWidget, m_gamepadHelpDialog);
                }
            }
            if (m_helpButtonWidget.IsClicked)
            {
                ScreensManager.SwitchScreen("Help");
            }
            IInventory inventory = m_componentPlayer.ComponentMiner.Inventory;

            if (playerInput.ToggleInventory || m_inventoryButtonWidget.IsClicked)
            {
                if (componentRider.Mount != null && ModalPanelWidget == null)
                {
                    Widget widget = OpenEntity(inventory, m_componentPlayer.ComponentRider.Mount.Entity);
                    if (widget != null)
                    {
                        ModalPanelWidget = widget;
                        AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
                        return;
                    }
                }
                ModalPanelWidget = IsInventoryVisible()
                                        ? null
                                        : inventory is ComponentCreativeInventory
                                        ? new CreativeInventoryWidget(m_componentPlayer.Entity)
                                        : (Widget) new FullInventoryWidget(inventory, m_componentPlayer.Entity.FindComponent <ComponentCraftingTable>(true));
            }
            if (playerInput.ToggleClothing || m_clothingButtonWidget.IsClicked)
            {
                ModalPanelWidget = IsClothingVisible() ? null : new ClothingWidget(m_componentPlayer);
            }
            if (m_sneakButtonWidget.IsClicked || playerInput.ToggleSneak)
            {
                bool isSneaking = m_componentPlayer.ComponentBody.IsSneaking;
                m_componentPlayer.ComponentBody.IsSneaking = !isSneaking;
                if (m_componentPlayer.ComponentBody.IsSneaking != isSneaking)
                {
                    DisplaySmallMessage(Utils.Get(m_componentPlayer.ComponentBody.IsSneaking ? "潜行模式:开" : "潜行模式:关"), false, false);
                }
            }
            if (componentRider != null && (m_mountButtonWidget.IsClicked || playerInput.ToggleMount))
            {
                bool flag = componentRider.Mount != null;
                if (flag)
                {
                    componentRider.StartDismounting();
                }
                else
                {
                    ComponentMount componentMount = FindNearestMount(componentRider);
                    if (componentMount != null)
                    {
                        componentRider.StartMounting(componentMount);
                    }
                }
                if (componentRider.Mount != null != flag)
                {
                    DisplaySmallMessage(Utils.Get(componentRider.Mount != null ? "上马" : "下马"), false, false);
                }
            }
            if ((m_editItemButton.IsClicked || playerInput.EditItem) && m_nearbyEditableCell.HasValue)
            {
                int cellValue = m_subsystemTerrain.Terrain.GetCellValue(m_nearbyEditableCell.Value.X, m_nearbyEditableCell.Value.Y, m_nearbyEditableCell.Value.Z);
                int contents  = Terrain.ExtractContents(cellValue);
                SubsystemBlockBehavior[] blockBehaviors = m_subsystemBlockBehaviors.GetBlockBehaviors(contents);
                for (int i = 0; i < blockBehaviors.Length && !blockBehaviors[i].OnEditBlock(m_nearbyEditableCell.Value.X, m_nearbyEditableCell.Value.Y, m_nearbyEditableCell.Value.Z, cellValue, m_componentPlayer); i++)
                {
                }
            }
            else if ((m_editItemButton.IsClicked || playerInput.EditItem) && IsActiveSlotEditable())
            {
                if (inventory != null)
                {
                    int activeSlotIndex = inventory.ActiveSlotIndex;
                    int num             = Terrain.ExtractContents(inventory.GetSlotValue(activeSlotIndex));
                    if (BlocksManager.Blocks[num].IsEditable)
                    {
                        SubsystemBlockBehavior[] blockBehaviors2 = m_subsystemBlockBehaviors.GetBlockBehaviors(num);
                        for (int j = 0; j < blockBehaviors2.Length && !blockBehaviors2[j].OnEditInventoryItem(inventory, activeSlotIndex, m_componentPlayer); j++)
                        {
                        }
                    }
                }
            }
            bool isCreative = m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative;

            if (isCreative && (m_creativeFlyButtonWidget.IsClicked || playerInput.ToggleCreativeFly) && componentRider.Mount == null)
            {
                bool isCreativeFlyEnabled = m_componentPlayer.ComponentLocomotion.IsCreativeFlyEnabled;
                m_componentPlayer.ComponentLocomotion.IsCreativeFlyEnabled = !isCreativeFlyEnabled;
                if (m_componentPlayer.ComponentLocomotion.IsCreativeFlyEnabled != isCreativeFlyEnabled)
                {
                    if (m_componentPlayer.ComponentLocomotion.IsCreativeFlyEnabled)
                    {
                        m_componentPlayer.ComponentLocomotion.JumpOrder = 1f;
                        DisplaySmallMessage(Utils.Get("飞行模式:开"), false, false);
                    }
                    else
                    {
                        DisplaySmallMessage(Utils.Get("飞行模式:关"), false, false);
                    }
                }
            }
            if (m_cameraButtonWidget.IsClicked || playerInput.SwitchCameraMode)
            {
                View view = m_componentPlayer.View;
                if (view.ActiveCamera.GetType() == typeof(FppCamera))
                {
                    view.ActiveCamera = view.FindCamera <TppCamera>(true);
                    DisplaySmallMessage(Utils.Get("第三人称视角"), false, false);
                }
                else if (view.ActiveCamera.GetType() == typeof(TppCamera))
                {
                    view.ActiveCamera = view.FindCamera <OrbitCamera>(true);
                    DisplaySmallMessage(Utils.Get("滑轨视角"), false, false);
                }
                else if (view.ActiveCamera.GetType() == typeof(OrbitCamera))
                {
                    view.ActiveCamera = isCreative ? (Camera) new DebugCamera(view) : view.FindCamera <FixedCamera>(true);
                    DisplaySmallMessage(Utils.Get(isCreative ? "调试视角" : "固定视角"), false, false);
                }
                else if (isCreative && view.ActiveCamera.GetType() == typeof(FixedCamera))
                {
                    view.ActiveCamera = new FlyCamera(view);
                    DisplaySmallMessage(Utils.Get("飞行视角"), false, false);
                }
                else if (view.ActiveCamera.GetType() == typeof(DebugCamera))
                {
                    view.ActiveCamera = view.FindCamera <FixedCamera>(true);
                    DisplaySmallMessage(Utils.Get("固定视角"), false, false);
                }
                else if (view.ActiveCamera.GetType() == typeof(FlyCamera))
                {
                    view.ActiveCamera = new RandomJumpCamera(view);
                    DisplaySmallMessage(Utils.Get("随机跳跃视角"), false, false);
                }
                else if (view.ActiveCamera.GetType() == typeof(RandomJumpCamera))
                {
                    view.ActiveCamera = new StraightFlightCamera(view);
                    DisplaySmallMessage(Utils.Get("垂直飞行视角"), false, false);
                }
                else
                {
                    view.ActiveCamera = view.FindCamera <FppCamera>(true);
                    DisplaySmallMessage(Utils.Get("第一人称视角"), false, false);
                }
            }
            if (m_photoButtonWidget.IsClicked || playerInput.TakeScreenshot)
            {
                ScreenCaptureManager.CapturePhoto();
                Time.QueueFrameCountDelayedExecution(Time.FrameIndex + 1, delegate
                {
                    DisplaySmallMessage(Utils.Get("照片已保存到图片相册"), false, false);
                });
            }
            if (isCreative && (m_lightningButtonWidget.IsClicked || playerInput.Lighting))
            {
                Project.FindSubsystem <SubsystemWeather>(true).ManualLightingStrike(m_componentPlayer.ComponentCreatureModel.EyePosition, Matrix.CreateFromQuaternion(m_componentPlayer.ComponentCreatureModel.EyeRotation).Forward);
            }
            if (isCreative && (m_timeOfDayButtonWidget.IsClicked || playerInput.TimeOfDay))
            {
                float num2  = MathUtils.Remainder(0.25f, 1f);
                float num3  = MathUtils.Remainder(0.5f, 1f);
                float num4  = MathUtils.Remainder(0.75f, 1f);
                float num5  = MathUtils.Remainder(1f, 1f);
                float num6  = MathUtils.Remainder(num2 - m_subsystemTimeOfDay.TimeOfDay, 1f);
                float num7  = MathUtils.Remainder(num3 - m_subsystemTimeOfDay.TimeOfDay, 1f);
                float num8  = MathUtils.Remainder(num4 - m_subsystemTimeOfDay.TimeOfDay, 1f);
                float num9  = MathUtils.Remainder(num5 - m_subsystemTimeOfDay.TimeOfDay, 1f);
                float num10 = MathUtils.Min(num6, num7, num8, num9);
                if (num6 == num10)
                {
                    m_subsystemTimeOfDay.TimeOfDayOffset += num6;
                    DisplaySmallMessage(Utils.Get("黎明"), false, false);
                }
                else if (num7 == num10)
                {
                    m_subsystemTimeOfDay.TimeOfDayOffset += num7;
                    DisplaySmallMessage(Utils.Get("中午"), false, false);
                }
                else if (num8 == num10)
                {
                    m_subsystemTimeOfDay.TimeOfDayOffset += num8;
                    DisplaySmallMessage(Utils.Get("黄昏"), false, false);
                }
                else if (num9 == num10)
                {
                    m_subsystemTimeOfDay.TimeOfDayOffset += num9;
                    DisplaySmallMessage(Utils.Get("午夜"), false, false);
                }
            }
            if (ModalPanelWidget != null)
            {
                if (input.Cancel || input.Back || m_backButtonWidget.IsClicked)
                {
                    ModalPanelWidget = null;
                }
            }
            else if (input.Back || m_backButtonWidget.IsClicked)
            {
                DialogsManager.ShowDialog(m_componentPlayer.View.GameWidget, new GameMenuDialog(m_componentPlayer));
            }
            return;
        }
Ejemplo n.º 29
0
 public override void Update()
 {
     if (Children.Find <ButtonWidget>("More").IsClicked)
     {
         List <Tuple <string, Action> > list = new List <Tuple <string, Action> >();
         if (m_adventureRestartExists && GameManager.WorldInfo.WorldSettings.GameMode == GameMode.Adventure)
         {
             list.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 82), delegate
             {
                 DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog(LanguageControl.Get(fName, 83), LanguageControl.Get(fName, 84), LanguageControl.Get("Usual", "yes"), LanguageControl.Get("Usual", "no"), delegate(MessageDialogButton result)
                 {
                     if (result == MessageDialogButton.Button1)
                     {
                         ScreensManager.SwitchScreen("GameLoading", GameManager.WorldInfo, "AdventureRestart");
                     }
                 }));
             }));
         }
         if (GetRateableItems().FirstOrDefault() != null && UserManager.ActiveUser != null)
         {
             list.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 85), delegate
             {
                 DialogsManager.ShowDialog(base.ParentWidget, new ListSelectionDialog(LanguageControl.Get(fName, 86), GetRateableItems(), 60f, (object o) => ((ActiveExternalContentInfo)o).DisplayName, delegate(object o)
                 {
                     ActiveExternalContentInfo activeExternalContentInfo = (ActiveExternalContentInfo)o;
                     DialogsManager.ShowDialog(base.ParentWidget, new RateCommunityContentDialog(activeExternalContentInfo.Address, activeExternalContentInfo.DisplayName, UserManager.ActiveUser.UniqueId));
                 }));
             }));
         }
         list.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 87), delegate
         {
             ScreensManager.SwitchScreen("Players", m_componentPlayer.Project.FindSubsystem <SubsystemPlayers>(throwOnError: true));
         }));
         list.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 88), delegate
         {
             ScreensManager.SwitchScreen("Settings");
         }));
         list.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 89), delegate
         {
             ScreensManager.SwitchScreen("Help");
         }));
         if ((base.Input.Devices & (WidgetInputDevice.Keyboard | WidgetInputDevice.Mouse)) != 0)
         {
             list.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 90), delegate
             {
                 DialogsManager.ShowDialog(base.ParentWidget, new KeyboardHelpDialog());
             }));
         }
         if ((base.Input.Devices & WidgetInputDevice.Gamepads) != 0)
         {
             list.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 91), delegate
             {
                 DialogsManager.ShowDialog(base.ParentWidget, new GamepadHelpDialog());
             }));
         }
         ListSelectionDialog dialog = new ListSelectionDialog(LanguageControl.Get(fName, 92), list, 60f, (object t) => ((Tuple <string, Action>) t).Item1, delegate(object t)
         {
             ((Tuple <string, Action>)t).Item2();
         });
         DialogsManager.ShowDialog(base.ParentWidget, dialog);
     }
     if (base.Input.Back || base.Input.Cancel || Children.Find <ButtonWidget>("Resume").IsClicked)
     {
         DialogsManager.HideDialog(this);
     }
     if (Children.Find <ButtonWidget>("Quit").IsClicked)
     {
         DialogsManager.HideDialog(this);
         GameManager.SaveProject(waitForCompletion: true, showErrorDialog: true);
         GameManager.DisposeProject();
         ScreensManager.SwitchScreen("MainMenu");
     }
 }
Ejemplo n.º 30
0
 public void Dismiss(bool result)
 {
     DialogsManager.HideDialog(this);
     m_handler(result);
 }