}   // end of HandleMouseInput()

        private void OnAccept()
        {
            // If the current creator name or pin isn't valid, don't allow the user to click OK.
            // Skip this check if we have Guest signed in.
            if (creatorBlob.ScrubbedText != Auth.DefaultCreatorName && pinBlob.ScrubbedText != Auth.DefaultCreatorPin)
            {
                if (!Auth.IsPinValid(pinBlob.ScrubbedText) || string.IsNullOrWhiteSpace(creatorBlob.ScrubbedText))
                {
                    Foley.PlayNoBudget();
                    return;
                }
            }

            string newCreatorName = creatorBlob.ScrubbedText;
            string newPin         = pinBlob.ScrubbedText;
            string newIdHash      = Auth.CreateIdHash(newCreatorName, newPin);

            if (!newUserMode)
            {
                bool previouslySeenHash = true;     // TODO (v-chph) Put test here.  Note we should always return true for guest ( Auth.DefaultCreatorHash ) without having to ping the server.

                if (previouslySeenHash)
                {
                    // We've seen this name before.
                    // Update Auth with the new values.
                    Auth.SetCreator(newCreatorName, newIdHash);
                }
                else
                {
                    // We haven't seen this name before so change dialog to New User.
                    newUserMode = true;
                    return; // Don't deactivate.
                }
            }

            // We've seen this name before.
            // Update Auth with the new values.
            Auth.SetCreator(newCreatorName, newIdHash);

            // Note that setting this also forces the creator name and idHash
            // to be saved from Auth.
            XmlOptionsData.KeepSignedInOnExit = keepSignedInChecked;

            // Done, we can exit now.
            Active = false;

            newUserMode = false;

            // Restart status dialog.
            AuthUI.ShowStatusDialog();
        }   // end of OnAccept()
            public void TextInput(char c)
            {
                shared.lastKeyPressedAt = DateTime.Now;
                // Handle special character input.
                if (KeyboardInput.AltWasPressed)
                {
                    specialChar = null;
                }
                if (KeyboardInput.AltIsPressed)
                {
                    // accumulate keystrokes
                    specialChar += c;
                    return;
                }

                //Ignore backspace and return character
                if (c == '\b' || c == '\r')
                {
                    return;
                }
                var oldText = shared.blob.RawText;

                shared.blob.InsertString(new string(c, 1));

                //Validate the text if required.
                if (shared.validateTextCallback != null && !shared.validateTextCallback(shared.blob))
                {
                    //Invalid so restore text.
                    shared.blob.RawText = oldText;
                    Foley.PlayNoBudget();
                }
                else
                {
                    Foley.PlayClickDown();
                }
            }   // end of UpdateObj TextInput()
        public void TextInput(char c)
        {
            // Handle special character input.
            if (KeyboardInput.AltWasPressed)
            {
                specialChar = null;
            }
            if (KeyboardInput.AltIsPressed)
            {
                // accumulate keystrokes
                specialChar += c;
                return;
            }

            // Grab the tab and use it for cycling through the focus options.
            if (c == '\t')
            {
                ToggleEditTarget();
                KeyboardInput.ClearAllWasPressedState(Keys.Tab);

                return;
            }

            if (EditingCreator || EditingPin)
            {
                // Ignore enter.
                if (c == 13)
                {
                    return;
                }

                string str = new string(c, 1);
                str = TextHelper.FilterInvalidCharacters(str);

                if (!string.IsNullOrEmpty(str))
                {
                    // Check if we've gotten too long.
                    if (EditingCreator)
                    {
                        creatorBlob.InsertString(str);

                        int width = creatorBlob.GetLineWidth(0);
                        if (width >= creatorBox.Width)
                        {
                            // Bzzzt!
                            Foley.PlayNoBudget();
                            for (int i = 0; i < str.Length; i++)
                            {
                                creatorBlob.Backspace();
                            }
                        }
                        else
                        {
                            Foley.PlayClickDown();
                        }
                    }
                    else if (EditingPin)
                    {
                        // With the pin, max out at 4 digits and only allow digits.
                        if (pinBlob.ScrubbedText.Length > 3 || !char.IsDigit(str[0]))
                        {
                            Foley.PlayNoBudget();
                        }
                        else
                        {
                            pinBlob.InsertString(str);
                        }
                    }
                }
            }
        }   // end of TextInput()
        }   // end of BasePicker RestorePreviousChoice()

        public virtual void Update(PerspectiveUICamera camera)
        {
            if (active)
            {
                if (hidden)
                {
                    // Note, even though we're hidden we may still be rendering our fade out.
                    double elapsedTime = Time.WallClockTotalSeconds - startFadeTime;
                    if (elapsedTime >= fadeTime)
                    {
                        Alpha = 0.0f;
                    }
                    else
                    {
                        Alpha = 1.0f - (float)(elapsedTime / fadeTime);
                    }
                }
                else
                {
                    // Not hidden, so respond to user input.

                    int scroll = MouseInput.ScrollWheel - MouseInput.PrevScrollWheel;

                    if (Actions.PickerRight.WasPressedOrRepeat || scroll > 0)
                    {
                        Actions.PickerRight.ClearAllWasPressedState();
                        DecrementFocus();
                    }
                    if (Actions.PickerLeft.WasPressedOrRepeat || scroll < 0)
                    {
                        Actions.PickerLeft.ClearAllWasPressedState();
                        IncrementFocus();
                    }

                    if (Actions.Select.WasPressed)
                    {
                        Actions.Select.ClearAllWasPressedState();

                        SelectCurrentChoice();
                        Foley.PlayPressA();
                    }

                    if (Actions.Cancel.WasPressedOrRepeat)
                    {
                        Actions.Cancel.ClearAllWasPressedState();

                        RestorePreviousChoice();
                        Foley.PlayBack();
                    }
                    bool handled = false;
                    if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                    {
                        handled = HandleTouchInput(camera);
                    }
                    else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                    {
                        handled = HandleMouseInput(camera);
                    }

                    if (!handled)
                    {
                        // If the user clicked but didn't hit any of the picker elements, close the picker.
                        // If alt is pressed, they must be in eyedropper mode.
                        if ((MouseInput.Left.WasPressed && !KeyboardInput.AltIsPressed) ||
                            (TouchGestureManager.Get().TapGesture.WasRecognized))
                        {
                            SelectCurrentChoice();
                            Foley.PlayPressA();
                        }
                        else if (Actions.Sample.WasPressed ||
                                 MouseEdit.TriggerSample() || TouchEdit.TriggerSample())
                        {
                            Actions.Sample.ClearAllWasPressedState();

                            int t = OnSampleType();
                            if (t >= 0)
                            {
                                OnSetType(t);
                                Point selection = grid.SelectionIndex;
                                selection.X         = t;
                                grid.SelectionIndex = selection;
                                Foley.PlayCut();
                            }
                            else
                            {
                                Foley.PlayNoBudget();
                            }
                        }
                    }

                    grid.Update(ref worldMatrix);
                }
            } // end if active
        }     // end of BasePicker Update()
            }   // end of EditObjectUpdateObj CancelNewItemSelector()

            public void SelectNewItemSelector(UiSelector selector)
            {
                UiSelector.GroupData groupData = selector.SelectedItem as UiSelector.GroupData;
                if (groupData != null)
                {
                    // sub group was activated
                    Foley.PlayProgrammingMoveOut();
                }
                else
                {
                    Instrumentation.IncrementCounter(Instrumentation.CounterId.AddItem);

                    GameActor thingToColor   = null;
                    GameActor thingToDistort = null;

                    //Object item = selector.ObjectSelectedItem;

                    ActorMenuItem item = selector.ObjectSelectedItem as ActorMenuItem;
                    if (item != null)
                    {
                        if (item.StaticActor != null)
                        {
                            if (addPositionIsExplicit)
                            {
                                ///Client has requested a specific position to add this guy.
                                ///Give the people what they want.
                                thingToColor = parent.AddActor(
                                    ActorFactory.Create(item.StaticActor),
                                    new Vector3(addPosition, float.MaxValue),
                                    InGame.inGame.shared.camera.Rotation);

                                // Reset
                                addPositionIsExplicit = false;
                            }
                            else
                            {
                                /// Default is to add at the cursor position.
                                thingToColor = parent.AddActorAtCursor(ActorFactory.Create(item.StaticActor));
                            }

                            // Give a ref to the actor to the HelpCard.  If it's active it
                            // can then program the actor's brain.
                            InGame.inGame.shared.addItemHelpCard.Actor = thingToColor as GameActor;
                        }
                        else if (item.TextureFilename.StartsWith("filter.path"))
                        {
                            if (parent.UnderBudget)
                            {
                                /// If the waypoint editor is active, let it handle this.
                                if (!shared.editWayPoint.Active)
                                {
                                    int pathType = 0;
                                    if (item.TextureFilename.EndsWith("road"))
                                    {
                                        pathType = Road.LastRoadCreated;
                                    }
                                    else if (item.TextureFilename.Contains("wall"))
                                    {
                                        pathType = Road.LastWallCreated;
                                    }
                                    else if (item.TextureFilename.Contains("flora"))
                                    {
                                        pathType = Road.LastVegCreated;
                                    }
                                    Road.GenIndex = pathType;
                                    Vector3 pos = addPositionIsExplicit
                                        ? new Vector3(addPosition, float.MaxValue)
                                        : parent.cursor3D.Position;
                                    shared.editWayPoint.NewPath(pos, shared.curObjectColor);
                                }
                            }
                            else
                            {
                                Instrumentation.IncrementCounter(Instrumentation.CounterId.AddItemNoBudget);

                                Foley.PlayNoBudget();
                            }
                        }
                    }
                    else
                    {
                        Debug.Assert(false, "How did this happen?");
                    }


                    if (thingToColor != null)
                    {
                        Foley.PlayProgrammingAdd();

                        shared.curObjectColor = ColorPalette.GetIndexFromColor(thingToColor.ClassColor);
                        //                        thingToColor.Classcolor = ColorPalette.GetColorFromIndex(shared.curObjectColor);
                        thingToDistort = thingToColor;
                    }

                    if (thingToDistort != null)
                    {
                        parent.DistortionPulse(thingToDistort, true);
                    }

                    newItemSelectorShim.Deactivate();

                    InGame.IsLevelDirty = true;
                }
            }   // end of EditObjectUpdateObj SelectNewItemSelector()