Beispiel #1
0
        public void TryToRename()
        {
            if (mWaitingForRename)
            {
                return;
            }

            if (State.HasBeenCreated && State.CreatedByPlayer)
            {
                Location           location = worlditem.Get <Location>();
                StringDialogResult result   = new StringDialogResult();
                result.Message = "Rename Campsite";
                string currentName = location.State.Name.CommonName;
                //by default campsites are named 'Campsite'
                //otherwise they're named 'Camp [name]'
                if (currentName == "Campsite")
                {
                    currentName = string.Empty;
                }
                else
                {
                    currentName = currentName.Replace("Camp", "").Trim();
                }
                result.Result           = currentName;
                result.Message          = "Camp {Result}";
                result.MessageType      = "Rename Campsite";                                           //this will display the result as we type
                result.AllowEmptyResult = true;
                GameObject confirmEditor = GUIManager.SpawnNGUIChildEditor(gameObject, GUIManager.Get.NGUIStringDialog, false);
                GUIManager.SendEditObjectToChildEditor <StringDialogResult>(new ChildEditorCallback <StringDialogResult>(OnFinishRename),
                                                                            confirmEditor,
                                                                            result);

                mWaitingForRename = true;
            }
        }
Beispiel #2
0
        public void OnFinishRename(StringDialogResult editObject, IGUIChildEditor <StringDialogResult> childEditor)
        {
            mWaitingForRename = false;

            if (editObject.Cancelled)
            {
                return;
            }

            Location location = null;

            if (worlditem.Is <Location>(out location))
            {
                if (string.IsNullOrEmpty(editObject.Result.Trim()))
                {
                    return;
                }
                location.State.Name.CommonName = editObject.Result;
                GUIManager.PostSuccess("Renamed structure to " + location.State.Name.CommonName);
            }
        }
Beispiel #3
0
        public void OnRenameCritter(object dialogResult)
        {
            Debug.Log("Finished using gui option list dialog");

            usingMenu = false;

            if (lastCritterInFocus == null || lastCritterInFocus.Destroyed)
            {
                Debug.Log("Critter was no longer in focus or null");
                return;
            }

            WIListResult result = (WIListResult)dialogResult;

            Debug.Log("Result: " + result.Result);

            switch (result.Result)
            {
            case "GiveNameToCritter":
                //spawn a name dialog and apply the result to the critter
                StringDialogResult nameResult = new StringDialogResult();
                nameResult.Message          = "Name Critter";
                nameResult.Result           = string.Empty;
                nameResult.MessageType      = string.Empty;           //this will display the result as we type
                nameResult.AllowEmptyResult = true;
                GameObject confirmEditor = GUIManager.SpawnNGUIChildEditor(gameObject, GUIManager.Get.NGUIStringDialog, false);
                GUIManager.SendEditObjectToChildEditor <StringDialogResult> (new ChildEditorCallback <StringDialogResult> (OnFinishRename),
                                                                             confirmEditor,
                                                                             nameResult);
                mWaitingForRename = true;
                break;

            default:
                break;
            }
        }
Beispiel #4
0
        public void OnFinishRename(StringDialogResult editObject, IGUIChildEditor <StringDialogResult> childEditor)
        {
            Debug.Log("Finished renaming");

            mWaitingForRename = false;

            if (editObject.Cancelled)
            {
                return;
            }

            if (lastCritterInFocus == null || lastCritterInFocus.Destroyed)
            {
                Debug.Log("Critter was no longer in focus or null");
                return;
            }

            if (string.IsNullOrEmpty(editObject.Result.Trim()))
            {
                return;
            }
            lastCritterInFocus.Name = editObject.Result;
            GUIManager.PostSuccess("Renamed critter to " + editObject.Result);
        }