Exemple #1
0
        public bool Save(string path)
        {
            gvTasks.CloseEditor();
            gvLevelItems.CloseEditor();
            gvAttachmentTypes.CloseEditor();

            int selectionStart = txtLog.Text.Length - 1;

            if (!_pack.Save(path))
            {
                tabBottom.SelectedTabPage = tbpLog;
                txtLog.Select(selectionStart, txtLog.Text.Length - selectionStart);
                txtLog.ScrollToCaret();

                DialogUtility.ShowWarning("Pack was not saved, see errors on the \"{0}\" tab.", tbpLog.Text);

                return(false);
            }

            Text       = path;
            IsNeedSave = false;
            IsNew      = false;

            return(true);
        }
Exemple #2
0
        private bool ValidateData()
        {
            gvItems.CloseEditor();
            gvItems.UpdateCurrentRow();

            if (txtCount.Value <= 1)
            {
                DialogUtility.ShowWarning("{0} must be greater than 1.", lblCount.Text);
                return(false);
            }

            if (txtInterval.Value <= 0)
            {
                DialogUtility.ShowWarning("{0} must be greater than 0.", lblInterval.Text);
                return(false);
            }

            if (_items.Count == 0)
            {
                DialogUtility.ShowWarning("No items added.");
                return(false);
            }

            int  prevFocused   = gvItems.FocusedRowHandle;
            bool hasItemErrors = false;

            for (int i = 0; i < gvItems.DataRowCount; i++)
            {
                gvItems.FocusedRowHandle = i;

                // NOTE: HasColumnErrors doesn't work
                foreach (GridColumn gc in gvItems.Columns)
                {
                    if (!gvItems.GetColumnError(gc).IsNullOrWhiteSpace())
                    {
                        hasItemErrors = true;
                        break;
                    }
                }

                if (hasItemErrors)
                {
                    break;
                }
            }

            gvItems.FocusedRowHandle = prevFocused;

            if (hasItemErrors)
            {
                DialogUtility.ShowWarning("One ore more items in the grid has errors. Correct or remove invalid item(s).");
                return(false);
            }

            return(true);
        }
Exemple #3
0
        private void EndBinding()
        {
            int counter = Interlocked.Decrement(ref _unstableCounter);

            if (counter < 0)
            {
                DialogUtility.ShowError("Unexpected unstable counter: {0}", counter);
                _unstableCounter = 0;
            }
        }
        public void LogFormat(UnityEngine.LogType logType, UnityEngine.Object context, string format, params object[] args)
        {
            _handler.LogFormat(logType, context, format, args);

            var level = logType.Cast();

            #if DEBUG || PROFILE
            if (level == LoggerLogLevel.Assert || level == LoggerLogLevel.Exception)
            {
                DialogUtility.OpenStackJumpDialog(System.Enum.GetName(typeof(LoggerLogLevel), level) + "!", string.Format(format, args), 3);
            }
            #endif
        }
Exemple #5
0
        private async UniTask OpenJoinRoomDialog()
        {
            var dialog = await DialogUtility.CreateDialog <RoomDialogPresenter>(DialogType.RoomDialog);

            var name = await dialog.WaitClose();

            if (dialog.Result.IsNullOrWhiteSpace())
            {
                return;
            }

            await _roomConnector.ConnectRoom(name);
        }
Exemple #6
0
        public override void DoWindowContents(Rect inRect)
        {
            if (Multiplayer.IsRunning)
            {
                Multiplayer.WatchBegin();
            }

            var listingStandard = new Listing_Standard {
                ColumnWidth = inRect.width
            };

            listingStandard.Begin(inRect);

            var comp = map.GetMapComponent();

            Multiplayer.mapFields?.Watch(comp);

            string labelStay     = "AreaToStay".Translate();
            string labelBuy      = "AreaToBuy".Translate();
            var    rectStayLabel = listingStandard.GetRect(Text.CalcHeight(labelStay, listingStandard.ColumnWidth));
            var    rectStay      = listingStandard.GetRect(24);
            var    rectBuyLabel  = listingStandard.GetRect(Text.CalcHeight(labelBuy, listingStandard.ColumnWidth));
            var    rectBuy       = listingStandard.GetRect(24);

            DialogUtility.LabelWithTooltip(labelStay, "AreaToStayTooltip".Translate(), rectStayLabel);
            GenericUtility.DoAreaRestriction(rectStay, comp.defaultAreaRestriction, area => comp.defaultAreaRestriction = area, AreaUtility.AreaAllowedLabel_Area);
            DialogUtility.LabelWithTooltip(labelBuy, "AreaToBuyTooltip".Translate(), rectBuyLabel);
            GenericUtility.DoAreaRestriction(rectBuy, comp.defaultAreaShopping, area => comp.defaultAreaShopping = area, GenericUtility.GetShoppingLabel);

            var rectImproveRelationship = listingStandard.GetRect(Text.LineHeight);

            DialogUtility.CheckboxLabeled(listingStandard, "ImproveRelationship".Translate(), ref comp.defaultEntertain, rectImproveRelationship, false, ITab_Pawn_Guest.txtImproveTooltip);
            var rectMakeFriends = listingStandard.GetRect(Text.LineHeight);

            DialogUtility.CheckboxLabeled(listingStandard, "MakeFriends".Translate(), ref comp.defaultMakeFriends, rectMakeFriends, false, ITab_Pawn_Guest.txtMakeFriendsTooltip);

            listingStandard.GapLine(24);

            var rectGuestsAreWelcome = listingStandard.GetRect(Text.LineHeight);

            DialogUtility.CheckboxLabeled(listingStandard, "GuestsWelcome".Translate(), ref comp.guestsAreWelcome, rectGuestsAreWelcome, false, "GuestsWelcomeTooltip".Translate());

            listingStandard.End();

            if (Multiplayer.IsRunning)
            {
                Multiplayer.WatchEnd();
            }
        }
Exemple #7
0
        private void packForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            DialogResult res      = DialogResult.Yes;
            var          packForm = (PackForm)sender;

            if (packForm.IsNew || packForm.IsNeedSave)
            {
                string message = String.Format("Save pack \"{0}\"?", Path.GetFileNameWithoutExtension(packForm.Text));
                res = DialogUtility.ShowConfirm(true, message);

                if (res == DialogResult.Yes && !SaveCurrentPack(false))
                {
                    res = DialogResult.Cancel;
                }
            }

            e.Cancel = (res == DialogResult.Cancel);
        }
Exemple #8
0
        private void miNavigationNext_Click(object sender, System.EventArgs e)
        {
            var packForm = GetActivePack();

            if (ActiveMdiChild != null)
            {
                if (packForm.NextLevel())
                {
                    UpdateLevelIndex();
                }
                else
                {
                    DialogResult res = DialogUtility.ShowConfirm(true, "Current level is the last. Add new level?");

                    if (res == DialogResult.Yes)
                    {
                        miLevelsAdd_Click(sender, e);
                    }
                }
            }
        }
Exemple #9
0
        private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            string fullDetail = String.Format("Unhandled application error occurred: {0}{1}{0}{0}{2}", Environment.NewLine, e.Exception.Message, e.Exception.ToString());
            bool   isLogged   = false;

            if (_mainForm != null)
            {
                var log = _mainForm.ActiveMdiChild as ILog;
                if (log != null)
                {
                    log.Write(fullDetail);
                    isLogged = true;
                }
            }

            if (isLogged)
            {
                DialogUtility.ShowError("{1}{0}{0}See log tab for detail.", Environment.NewLine, e.Exception.Message);
            }
            else
            {
                DialogUtility.ShowError(fullDetail);
            }
        }
        public override void DoWindowContents(Rect inRect)
        {
            Rect rect = new Rect(MarginFS, 0f, inRect.width, TitleHeight);

            Text.Font   = GameFont.Medium;
            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(rect, Title);
            Text.Anchor = TextAnchor.UpperLeft;
            Text.Font   = GameFont.Small;

            // re-render pawn
            try
            {
                if (this.RerenderPawn)
                {
                    Pawn.Drawer.renderer.graphics.ResolveAllGraphics();
                    PortraitsCache.SetDirty(Pawn);
                    this.RerenderPawn = false;
                }

                if (!this.Initialized)
                {
                    this.DresserDto = new DresserDTO(Pawn);
                    this.DresserDto.SetUpdatePawnListeners(this.UpdatePawn);
                }
            }
            catch (Exception ex)
            {
            }

            List <TabRecord> list = new List <TabRecord>();

            TabRecord item = new TabRecord(
                "FacialStuffEditor.Hair".Translate(),
                this.SetTabFaceStyle(FaceStyleTab.Hair),
                this.Tab == FaceStyleTab.Hair);

            list.Add(item);

            if (this.CompFace.Props.hasBeard)
            {
                if (Pawn.gender == Gender.Male)
                {
                    TabRecord item2 = new TabRecord(
                        "FacialStuffEditor.Beard".Translate(),
                        this.SetTabFaceStyle(FaceStyleTab.Beard),
                        this.Tab == FaceStyleTab.Beard);
                    list.Add(item2);
                }
            }

            if (this.CompFace.Props.hasEyes)
            {
                TabRecord item3 = new TabRecord(
                    "FacialStuffEditor.Eye".Translate(),
                    this.SetTabFaceStyle(FaceStyleTab.Eye),
                    this.Tab == FaceStyleTab.Eye);
                list.Add(item3);

                TabRecord item4 = new TabRecord(
                    "FacialStuffEditor.Brow".Translate(),
                    this.SetTabFaceStyle(FaceStyleTab.Brow),
                    this.Tab == FaceStyleTab.Brow);
                list.Add(item4);
            }

            if (Controller.settings.ShowBodyChange && Current.ProgramState == ProgramState.Playing)
            {
                TabRecord item5 = new TabRecord(
                    "FacialStuffEditor.TypeSelector".Translate(),
                    this.SetTabFaceStyle(FaceStyleTab.TypeSelector),
                    this.Tab == FaceStyleTab.TypeSelector);
                list.Add(item5);
            }

            Rect contentRect = new Rect(
                0f,
                TitleHeight + TabDrawer.TabHeight + MarginFS / 2,
                inRect.width,
                inRect.height - TitleHeight - MarginFS * 2 - TabDrawer.TabHeight);

            TabDrawer.DrawTabs(contentRect, list);

            this.DrawUI(contentRect);

            Action backAct = delegate
            {
                this.RemoveColorPicker();

                // SoundDef.Named("InteractShotgun").PlayOneShotOnCamera();
                if (this.OriginalGender != Gender.Male && this.Tab == FaceStyleTab.Beard)
                {
                    this.Tab = FaceStyleTab.Hair;
                }

                this.ResetPawnFace();
            };

            DialogUtility.DoNextBackButtons(
                inRect,
                "Randomize".Translate(),
                "FacialStuffEditor.Accept".Translate(),
                backAct,
                this.FaceRandomizer,
                this.SaveAndClose);
        }
Exemple #11
0
        private void OpenPack(string fileName, bool isShowDialog)
        {
            string formCaption = null;

            if (isShowDialog)
            {
                openPackDialog.InitialDirectory = _lastDirectory;

                if (openPackDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                fileName = openPackDialog.FileName;
                AddRecentPack(fileName);

                _lastDirectory = Path.GetDirectoryName(openPackDialog.FileName);
            }
            else if (!fileName.IsNullOrWhiteSpace())
            {
                if (!File.Exists(fileName))
                {
                    return;
                }

                var frmOpened = MdiChildren.FirstOrDefault(frm => frm.Text == fileName);
                if (frmOpened != null)
                {
                    frmOpened.Activate();
                    if (DialogUtility.ShowConfirm(true, "File is already opened, do you want to reopen it?") == DialogResult.Yes)
                    {
                        frmOpened.Close();

                        // проверяем, закрылось ли (могли предложить сохранить и закрытия не произошло)
                        if (MdiChildren.Contains(frmOpened))
                        {
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }
            else
            {
                int index = MdiChildren.Length;
                do
                {
                    formCaption = String.Format("Noname{0}", ++index);
                } while (MdiChildren.Any(frm => frm.Text == formCaption));
            }

            try
            {
                var packForm = new PackForm(_levelTemplatePath, fileName);

                packForm.MdiParent    = this;
                packForm.Activated   += packForm_Activated;
                packForm.FormClosing += packForm_FormClosing;
                packForm.Disposed    += packForm_Disposed;

                if (formCaption != null)
                {
                    packForm.Text = formCaption;
                }

                packForm.Show();
                UpdateFormState();
            }
            catch (Exception ex)
            {
                DialogUtility.ShowError("Error while opening pack: {0}", ex.Message);
            }
        }