예제 #1
0
        /// <summary>
        /// Code ajouté lors de la création d'une action
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ListActions_ItemToCreate(object sender, EventArgs e)
        {
            VO_Action vNewItem = _Service.CreateAction();

            ListActions.AddItem(vNewItem.Id, vNewItem.Title);
            LoadAction(vNewItem.Id);
        }
예제 #2
0
 /// <summary>
 /// Lors de l'edit du titre
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtName_TextChanged(object sender, EventArgs e)
 {
     if (ListActions.ChangeItemName(CurrentAction.Id, txtName.Text))
     {
         CurrentAction.Title = txtName.Text;
     }
     else
     {
         txtName.Text = CurrentAction.Title;
         MessageBox.Show(Errors.ERROR_UNIQUE_TITLE, Errors.ERROR_BOX_TITLE);
     }
 }
예제 #3
0
 /// <summary>
 /// Survient lorsque le formulaire devient visible
 /// </summary>
 public void InitializeDBActions()
 {
     CurrentAction = null;
     ProvisionList();
     if (ListActions.DataSource.Count > 0)
     {
         Guid firstAction = ListActions.DataSource[0].Id;
         ListActions.SelectItem(firstAction);
         LoadAction(firstAction);
     }
     else
     {
         ListActions_ListIsEmpty(this, new EventArgs());
     }
 }
예제 #4
0
        public virtual void SetListAction(ListActions action)
        {
            string val = "change";

            switch (action)
            {
            case ListActions.ListActionChange:
                break;

            case ListActions.ListActionReplace:
                val = "replace";
                break;

            default:
            {
                string src = base.GetType().FullName + ".setListAction()";
                throw new CsiClientException(-2147467259L, src);
            }
            }
            base.SetAttribute("__listAction", val);
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            SerializedProperty id             = property.FindPropertyRelative("ID");
            SerializedProperty title          = property.FindPropertyRelative("Title");
            SerializedProperty speaker        = property.FindPropertyRelative("speakerIndex");
            SerializedProperty isEnd          = property.FindPropertyRelative("isEnd");
            SerializedProperty text           = property.FindPropertyRelative("Text");
            SerializedProperty onEnter        = property.FindPropertyRelative("OnEnter");
            SerializedProperty cutsceneEvents = property.FindPropertyRelative("cutsceneEvents");
            SerializedProperty transitions    = property.FindPropertyRelative("transitions");
            SerializedProperty responsesList  = property.FindPropertyRelative("Responses");
            SerializedProperty response;
            SerializedObject   parent = property.serializedObject;//TODO instead use serialized property, and get conversation from that

            EditorGUILayout.BeginVertical();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("ID: ");
            EditorGUILayout.SelectableLabel(id.intValue.ToString());
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.PropertyField(title);
            // Display possible speakers as popup
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Speaker: ");
            speaker.intValue = EditorGUILayout.Popup(speaker.intValue, (parent.targetObject as Conversation).Speakers.ToArray());
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.PropertyField(isEnd);
            EditorGUILayout.PropertyField(text);
            EditorGUILayout.Separator();
            EditorGUILayout.PropertyField(onEnter, true);
            EditorGUILayout.PropertyField(cutsceneEvents, true);
            EditorGUILayout.Separator();
            EditorGUILayout.PropertyField(transitions, true);

            EditorGUILayout.Separator();

            // Responses list area
            int         responsesSize = responsesList.arraySize;
            ListActions action        = ListActions.Nothing;
            int         selectedIndex = -1;

            responsesList.isExpanded = EditorGUILayout.Foldout(responsesList.isExpanded, "Responses", true, EditorStyles.boldLabel);
            if (responsesList.isExpanded)
            {
                // Display each response
                for (int i = 0; i < responsesSize; ++i)
                {
                    response = responsesList.GetArrayElementAtIndex(i);

                    string responseTitle = response.FindPropertyRelative("Text").stringValue;
                    if (string.IsNullOrEmpty(responseTitle))
                    {
                        responseTitle = "Response " + i.ToString();
                    }

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.BeginVertical();
                    // Display response details if expanded
                    response.isExpanded = EditorGUILayout.Foldout(response.isExpanded, responseTitle);
                    if (response.isExpanded)
                    {
                        EditorGUILayout.PropertyField(response, new GUIContent(responseTitle), true); //TODO get text from response, use as label
                    }
                    EditorGUILayout.EndVertical();
                    // Buttons for moving or deleting response
                    bool moveUp = false, moveDown = false, deleteResponse = false;
                    using (new EditorGUI.DisabledScope(i <= 0))     // Disable if first in array
                    {
                        moveUp = GUILayout.Button("^", GUILayout.Width(MOVE_BUTTON_WIDTH));
                    }
                    using (new EditorGUI.DisabledScope(i + 1 >= responsesSize))
                    {
                        moveDown = GUILayout.Button("v", GUILayout.Width(MOVE_BUTTON_WIDTH));
                    }
                    deleteResponse = GUILayout.Button("X", GUILayout.Width(MOVE_BUTTON_WIDTH));
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.Separator();
                    // Set button action based on buttons clicked
                    if (moveUp)
                    {
                        action        = ListActions.MoveUp;
                        selectedIndex = i;
                    }
                    else if (moveDown)
                    {
                        action        = ListActions.MoveDown;
                        selectedIndex = i;
                    }
                    else if (deleteResponse)
                    {
                        action        = ListActions.Delete;
                        selectedIndex = i;
                    }
                }
                GUILayout.BeginHorizontal();
                bool addItem    = GUILayout.Button("Add Response");
                bool clearItems = GUILayout.Button("Clear Responses");
                GUILayout.EndHorizontal();
                // Perform action based on buttons clicked
                if (addItem)
                {
                    responsesList.InsertArrayElementAtIndex(responsesSize);
                }
                if (clearItems)
                {
                    responsesList.arraySize = 0;
                }
                switch (action)
                {
                case ListActions.MoveUp:
                    if (selectedIndex > 0)
                    {
                        responsesList.MoveArrayElement(selectedIndex, selectedIndex - 1);
                    }
                    break;

                case ListActions.MoveDown:
                    if (selectedIndex >= 0 && selectedIndex < (responsesSize - 1))
                    {
                        responsesList.MoveArrayElement(selectedIndex, selectedIndex + 1);
                    }
                    break;

                case ListActions.Delete:
                    if (selectedIndex >= 0 && selectedIndex < (responsesSize))
                    {
                        responsesList.DeleteArrayElementAtIndex(selectedIndex);
                    }
                    break;

                case ListActions.Nothing:
                default:
                    break;
                }
            }
            else
            {
                responsesList.isExpanded = GUILayout.Button("Show");
            }

            EditorGUILayout.EndVertical();
        }
예제 #6
0
 /// <summary>
 /// Charge la liste de actions
 /// </summary>
 private void ProvisionList()
 {
     ListActions.DataSource = _Service.ProvisionList();
     ListActions.LoadList();
 }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            //TODO add buttons for moving transitions, add/remove
            SerializedProperty optionsList       = property.FindPropertyRelative("transitions");
            SerializedProperty defaultTransition = property.FindPropertyRelative("defaultTransition");
            int optionSize = optionsList.arraySize;

            //HACK if transitions can ever be displayed outside a conversation being selected this will have to change
            Conversation conversation = Selection.activeObject as Conversation;

            ListActions action        = ListActions.Nothing;
            int         selectedIndex = -1;

            //TODO figure out good place to extract out this list drawing code (have attribute to use?)
            SerializedProperty option;
            SerializedProperty targetID;
            SerializedProperty condition;

            EditorGUILayout.BeginVertical();
            //EditorGUILayout.LabelField(label, EditorStyles.boldLabel);
            optionsList.isExpanded = EditorGUILayout.Foldout(optionsList.isExpanded, label, true, EditorStyles.boldLabel);   //TODO create "Bold Foldout style"
            if (optionsList.isExpanded)
            {
                for (int i = 0; i < optionSize; ++i)
                {
                    option    = optionsList.GetArrayElementAtIndex(i);
                    targetID  = option.FindPropertyRelative("transition.TargetID");
                    condition = option.FindPropertyRelative("condition");
                    // Get name of
                    int           optionTarget = targetID.intValue;
                    DialogueEntry targetEntry  = conversation.FindEntry(optionTarget);

                    string targetName = "Dialogue entry not found";
                    if (targetEntry != null)
                    {
                        targetName = "To " + StringUtility.TruncateString(targetEntry.Name(), MAX_DIALOGUE_NAME_LENGTH);
                    }

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.BeginVertical();
                    EditorGUILayout.PropertyField(option, new GUIContent(targetName), true);
                    //EditorGUILayout.PropertyField(condition, true);
                    //EditorGUILayout.PropertyField(targetID, true);
                    EditorGUILayout.EndVertical();
                    bool moveUp = false, moveDown = false, remove = false;
                    using (new EditorGUI.DisabledScope(i == 0))     // Disable if already first
                    {
                        moveUp = GUILayout.Button("^", GUILayout.Width(MOVE_BUTTON_WIDTH));
                    }
                    using (new EditorGUI.DisabledScope(i + 1 >= optionSize))    // Disable if last
                    {
                        moveDown = GUILayout.Button("v", GUILayout.Width(MOVE_BUTTON_WIDTH));
                    }
                    // remove = GUILayout.Button("X", GUILayout.Width(MOVE_BUTTON_WIDTH));
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.Separator();
                    if (moveUp)
                    {
                        action        = ListActions.MoveUp;
                        selectedIndex = i;
                    }
                    else if (moveDown)
                    {
                        action        = ListActions.MoveDown;
                        selectedIndex = i;
                    }
                    else if (remove)
                    {
                        action        = ListActions.Delete;
                        selectedIndex = i;
                    }
                }
                GUILayout.BeginHorizontal();
                bool addItem = false, clearItems = false;
                addItem = GUILayout.Button("Add Transition");
                using (new EditorGUI.DisabledScope(optionSize == 0))
                {
                    clearItems = GUILayout.Button("Clear Transitions");
                }
                GUILayout.EndHorizontal();
                if (addItem)
                {
                    optionsList.InsertArrayElementAtIndex(optionSize);
                }
                if (clearItems)
                {
                    optionsList.ClearArray();
                }

                // Handle choice
                switch (action)
                {
                case ListActions.MoveUp:
                    if (selectedIndex > 0)
                    {
                        optionsList.MoveArrayElement(selectedIndex, selectedIndex - 1);
                    }
                    break;

                case ListActions.MoveDown:
                    if (selectedIndex >= 0 && selectedIndex < (optionSize - 1))
                    {
                        optionsList.MoveArrayElement(selectedIndex, selectedIndex + 1);
                    }
                    break;

                case ListActions.Delete:
                    if (selectedIndex >= 0 && selectedIndex < optionSize)
                    {
                        optionsList.DeleteArrayElementAtIndex(selectedIndex);
                    }
                    break;

                case ListActions.Nothing:
                default:
                    break;
                }
            }
            else
            {
                optionsList.isExpanded = GUILayout.Button("Show");
            }
            EditorGUILayout.EndVertical();



            //base.OnGUI(position, property, label);
        }