コード例 #1
0
        private void RenderStep(TutorialEntity tutorial, int index, StepEntity step)
        {
            using (new GUILayout.HorizontalScope()) {
                string displayName    = ParseDisplayNameFromStep(tutorial.id, step.id);
                string newDisplayName = displayName;
                if (index == 0)
                {
                    EditorGUILayout.LabelField(stepIdGUIContent, EditorStyles.miniLabel, GUILayout.Width(k_ColumnWidth));
                }
                else
                {
                    EditorGUILayout.LabelField("", GUILayout.Width(k_ColumnWidth));
                }
                RestrictInputCharacters();
                newDisplayName = EditorGUILayout.TextField(displayName);
                if (newDisplayName != displayName)
                {
                    UpdateStep(step.id, ConstructStepIdFromDisplayName(tutorial.id, newDisplayName));
                }
                if (index == tutorial.steps.Count - 1)
                {
                    bool plusEnabled  = index < k_MaxSteps - 1;
                    bool minusEnabled = index > 0;

                    var prevColor = GUI.backgroundColor;
                    GUI.backgroundColor = Color.clear;
                    EditorGUI.BeginDisabledGroup(!plusEnabled);

                    if (GUILayout.Button(addStepButtonGUIContent, addButtonStyle, GUILayout.MaxWidth(20f)))
                    {
                        CreateStep(tutorial.id);
                    }
                    EditorGUI.EndDisabledGroup();
                    EditorGUI.BeginDisabledGroup(!minusEnabled);
                    if (GUILayout.Button(deleteStepButtonGUIContent, addButtonStyle, GUILayout.MaxWidth(20f)))
                    {
                        DestroyStep(step.id);
                    }
                    EditorGUI.EndDisabledGroup();
                    GUI.backgroundColor = prevColor;
                }
            }
            var textId = step.id + "-text";

            if (showContent && TMModel.TMData.contentTable.ContainsKey(textId))
            {
                var  contentEntity = TMModel.TMData.contentTable[textId];
                bool wrap          = EditorStyles.textField.wordWrap;
                EditorStyles.textField.wordWrap = true;
                var options = new GUILayoutOption[] {
                    GUILayout.ExpandHeight(true),
                    GUILayout.MaxHeight(50f),
                    GUILayout.Width(EditorGUIUtility.currentViewWidth - 30f)
                };
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.TextArea(contentEntity.text, options);
                EditorGUI.EndDisabledGroup();
                EditorStyles.textField.wordWrap = wrap;
            }
        }
コード例 #2
0
        public void DestroyTutorial()
        {

            var modelMiddleware = TutorialManagerModelMiddleware.GetInstance();
            modelMiddleware.Clear();

            modelMiddleware.CreateTutorialEntity(tutorialName1);
            modelMiddleware.CreateTutorialEntity(tutorialName2);
            Assert.AreEqual(2, modelMiddleware.TMData.tutorials.Count, "tutorial length should be 2");

            modelMiddleware.DestroyTutorialEntity(tutorialName1);
            Assert.AreEqual(1, modelMiddleware.TMData.tutorials.Count, "tutorial length should be 1");

            TutorialEntity entityFromLookup = modelMiddleware.TMData.tutorialTable[tutorialName2];
            Assert.IsNotNull(entityFromLookup, "the second tutorial still exists");
            Assert.That(tutorialName2, Is.EqualTo(entityFromLookup.id), "tutorial id 2 is unaffected");
            TutorialEntity entityFromList = modelMiddleware.TMData.tutorials[0];
            Assert.IsNotNull(entityFromList, "entity should exist");
            Assert.AreSame(entityFromList, entityFromLookup, "tutorial entities should be the same object");

            modelMiddleware.DestroyTutorialEntity(tutorialName2);
            Assert.AreEqual(0, modelMiddleware.TMData.tutorials.Count, "tutorials should be empty");
            Assert.AreEqual(0, modelMiddleware.TMData.tutorialTable.Count, "tutorialTable should be empty");

            PostTestCleanup();
        }
コード例 #3
0
        public void UpdateTutorialWhenNoStepsOrContent()
        {
            var modelMiddleware = TutorialManagerModelMiddleware.GetInstance();
            modelMiddleware.Clear();

            modelMiddleware.CreateTutorialEntity(tutorialName1);
            modelMiddleware.CreateTutorialEntity(tutorialName2);
            Assert.AreEqual(2, modelMiddleware.TMData.tutorials.Count, "tutorial length should be 2");

            modelMiddleware.UpdateTutorialEntity(tutorialName1, tutorialName1v2);

            Assert.AreEqual(2, modelMiddleware.TMData.tutorials.Count, "tutorial length should still be 2");

            Assert.IsFalse(modelMiddleware.TMData.tutorialTable.ContainsKey(tutorialName1), "the old key has been destroyed");

            TutorialEntity entityFromLookup = modelMiddleware.TMData.tutorialTable[tutorialName1v2];
            Assert.IsNotNull(entityFromLookup, "the new key exists");
            Assert.That(tutorialName1v2, Is.EqualTo(entityFromLookup.id), "tutorial name should be changed");
            TutorialEntity entityFromList = modelMiddleware.TMData.tutorials[0];
            Assert.IsNotNull(entityFromList, "entity should exist");
            Assert.AreSame(entityFromList, entityFromLookup, "tutorial entities should be the same object");

            TutorialEntity entityFromList2 = modelMiddleware.TMData.tutorials[1];
            Assert.IsNotNull(entityFromList2, "second entity should not be destroyed");
            Assert.That(tutorialName2, Is.EqualTo(entityFromList2.id), "second entity id should be unchanged");
            TutorialEntity entityFromLookup2 = modelMiddleware.TMData.tutorialTable[tutorialName2];
            Assert.AreSame(entityFromList2, entityFromLookup2, "tutorial entities should be the same object");

            Assert.AreEqual(2, modelMiddleware.TMData.tutorialTable.Count, "tutorialTable has 2 items");

            PostTestCleanup();
        }
コード例 #4
0
        public void CreateTutorial()
        {
            var modelMiddleware = TutorialManagerModelMiddleware.GetInstance();
            modelMiddleware.Clear();

            modelMiddleware.CreateTutorialEntity(tutorialName1);

            Assert.AreEqual(1, modelMiddleware.TMData.tutorials.Count, "tutorial length should be 1");
            TutorialEntity entityFromList = modelMiddleware.TMData.tutorials[0];
            Assert.IsNotNull(entityFromList, "entity should exist");
            Assert.That(tutorialName1, Is.EqualTo(entityFromList.id), string.Format("entity id shoyuld be {0}", tutorialName1));
            TutorialEntity entityFromLookup = modelMiddleware.TMData.tutorialTable[tutorialName1];

            Assert.AreSame(entityFromList, entityFromLookup, "tutorial entities should be the same object");
            Assert.AreEqual(1, modelMiddleware.TMData.tutorialTable.Count, "tutorialTable has 1 item");

            modelMiddleware.CreateTutorialEntity(tutorialName2);
            Assert.AreEqual(2, modelMiddleware.TMData.tutorials.Count, "tutorial length should be 2");
            TutorialEntity entityFromList2 = modelMiddleware.TMData.tutorials[1];
            Assert.IsNotNull(entityFromList2, "second entity should exist");
            Assert.That(tutorialName2, Is.EqualTo(entityFromList2.id), string.Format("second entity id should be {0}", tutorialName2));
            TutorialEntity entityFromLookup2 = modelMiddleware.TMData.tutorialTable[tutorialName2];
            Assert.AreSame(entityFromList2, entityFromLookup2, "tutorial entities should be the same object");
            Assert.AreEqual(2, modelMiddleware.TMData.tutorialTable.Count, "tutorialTable has 2 items");

            PostTestCleanup();
        }
コード例 #5
0
        public void ReadFromFile_WorksWhenFileExists()
        {
            PostTestCleanup();

            //Test set up - generate a model and save it out so it can be retreived by the middleware
            var tutorialName = "tutorial 1";
            var stepName = "step 1";
            var genreName = "myGenre";
            var stepLookupName = ConstructID(tutorialName, stepName);
            var textLookupName = ConstructID(stepLookupName, "text");
            var actualModel = new TutorialManagerModel();
            var tutorial = new TutorialEntity(tutorialName);
            tutorial.steps.Add(stepName);
            var step = new StepEntity(stepLookupName);
            step.messaging.isActive = true;
            var text = new ContentEntity(textLookupName, "text", "yooo what's up! I work!");
            step.messaging.content.Add(text.id);
            actualModel.genre = genreName;
            actualModel.tutorials.Add(tutorial);
            actualModel.steps.Add(step);
            actualModel.content.Add(text);

            BinaryFormatter binaryFormatter = new BinaryFormatter();
            FileStream file = File.Create(GetModelSavePath());

            binaryFormatter.Serialize(file, actualModel);
            file.Close();

            //Actual test code
            var modelMiddleware = TutorialManagerModelMiddleware.GetInstance();
            Assert.That(genreName, Is.EqualTo(modelMiddleware.TMData.genre), string.Format("genre should be {0}", genreName));
            Assert.IsNotEmpty(modelMiddleware.TMData.tutorials, "tutorials should be populated");
            Assert.IsNotEmpty(modelMiddleware.TMData.steps, "steps should be populated");
            Assert.IsNotEmpty(modelMiddleware.TMData.content, "content should be populated");
            Assert.AreEqual(1, modelMiddleware.TMData.tutorials.Count, "there should only be one tutorial");
            Assert.AreEqual(1, modelMiddleware.TMData.steps.Count, "there should only be one step");
            Assert.AreEqual(1, modelMiddleware.TMData.content.Count, "there should only be one conent");
            Assert.That(tutorialName, Is.EqualTo(modelMiddleware.TMData.tutorials[0].id), string.Format("the tutorial should be named {0}", tutorialName));
            Assert.That(stepLookupName, Is.EqualTo(modelMiddleware.TMData.steps[0].id), string.Format("the step should be named {0}", stepLookupName));
            Assert.That(textLookupName, Is.EqualTo(modelMiddleware.TMData.content[0].id), string.Format("the content should be named {0}", textLookupName));

            Assert.IsTrue(modelMiddleware.TMData.tutorialTable.ContainsKey(tutorialName), string.Format("tutorial table should contain {0}", tutorialName));
            Assert.IsTrue(modelMiddleware.TMData.stepTable.ContainsKey(stepLookupName), string.Format("steps table should contain {0}", stepLookupName));
            Assert.IsTrue(modelMiddleware.TMData.contentTable.ContainsKey(textLookupName), string.Format("content table should contain {0}", textLookupName));

            PostTestCleanup();
        }
コード例 #6
0
 private void CreateGuidePosition(Vector3 position, string key, bool force = false, TutorialEntity.ETutorialHandDirection handDirection = TutorialEntity.ETutorialHandDirection.ETHD_RightDown)
 {
     GameObject gameObject = Res.Load<GameObject>("Skill/com/st_059", false);
     if (gameObject == null)
     {
         global::Debug.LogError(new object[]
         {
             "Res.Load error, name = Skill/com/st_059"
         });
         return;
     }
     this.moveTarget = (UnityEngine.Object.Instantiate(gameObject, position, Quaternion.identity) as GameObject);
     position.y += 0.5f;
     base.CreateGuideMask();
     if (this.maskPanel == null)
     {
         this.maskPanel = this.guideMask.AddComponent<UIPanel>();
         this.maskPanel.enabled = true;
         this.maskPanel.depth = 2500;
         this.maskPanel.renderQueue = UIPanel.RenderQueue.StartAt;
         this.maskPanel.startingRenderQueue = 5000;
     }
     GameUITools.AddChild(GameUIManager.mInstance.uiCamera.gameObject, this.guideMask);
     base.SetHandDirection(handDirection);
     TweenPosition component = this.hand.GetComponent<TweenPosition>();
     component.enabled = true;
     this.guideMask.SetActive(true);
     this.guideAnimation.SetActive(true);
     this.tips.gameObject.SetActive(true);
     this.tips.text = Singleton<StringManager>.Instance.GetString(key);
     GameObject gameObject2 = GameUITools.FindGameObject("q", this.ui38);
     gameObject2.SetActive(false);
     if (!force)
     {
         this.fadeBG.gameObject.SetActive(false);
         this.area.gameObject.SetActive(false);
     }
     Vector3 position2 = Camera.main.WorldToViewportPoint(position);
     position2 = GameUIManager.mInstance.uiCamera.camera.ViewportToWorldPoint(position2);
     position2.z = 0f;
     this.guideMask.transform.position = position2;
 }
コード例 #7
0
        private void CreateStep(string tutorialId)
        {
            TutorialEntity tutorial = TMModel.TMData.tutorialTable[tutorialId];
            string         id       = "Step" + (tutorial.steps.Count + 1);

            // If the auto-generated key exists, attempt to append a letter
            string concatenatedId = ConstructStepIdFromDisplayName(tutorialId, id);

            if (TMModel.TMData.stepTable.ContainsKey(concatenatedId))
            {
                string[] alphabet = new string[] { "a", "b", "c", "d", "e", "f", "g" };
                int      a        = 0;
                while (TMModel.TMData.stepTable.ContainsKey(concatenatedId) && a < alphabet.Length)
                {
                    id            += alphabet[a];
                    concatenatedId = ConstructStepIdFromDisplayName(tutorialId, id);
                    a++;
                }
            }

            TMModel.CreateStepEntity(id, tutorialId);
        }
コード例 #8
0
        private void RenderTutorial(TutorialEntity tutorial, bool deleteDisabled)
        {
            using (new GUILayout.VerticalScope("box")) {
                using (new GUILayout.HorizontalScope()) {
                    EditorGUILayout.LabelField(tutorialIdGUIContent, EditorStyles.miniLabel, GUILayout.Width(k_ColumnWidth));

                    RestrictInputCharacters();
                    string tutorialId = EditorGUILayout.TextField(tutorial.id);
                    if (tutorialId != tutorial.id)
                    {
                        UpdateTutorial(tutorial.id, tutorialId);
                    }

                    var prevColor = GUI.backgroundColor;
                    GUI.backgroundColor = Color.clear;
                    EditorGUI.BeginDisabledGroup(deleteDisabled);
                    if (GUILayout.Button(deleteTutorialButtonGUIContent, addButtonStyle, GUILayout.MaxWidth(20f)))
                    {
                        MarkTutorialForDeletion(tutorialId);
                    }
                    EditorGUI.EndDisabledGroup();
                    GUI.backgroundColor = prevColor;
                }
                GUILayout.Space(3f);

                for (int a = 0; a < tutorial.steps.Count; a++)
                {
                    string stepId = tutorial.steps[a];
                    if (TMModel.TMData.stepTable.ContainsKey(stepId))
                    {
                        RenderStep(tutorial, a, TMModel.TMData.stepTable[stepId]);
                    }
                }
                GUILayout.Space(3f);
            }
        }