Ejemplo n.º 1
0
    void OnGUI()
    {
        SetEditorStyles();

        scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

        for (int i = 0; i < ContractModel.Contracts.Count; i++)
        {
            DisplayContract(ContractModel.Contracts[i]);
        }

        EditorGUILayout.EndScrollView();

        GUILayout.Space(12);
        GUILayout.FlexibleSpace();
        GUILayout.Space(6);
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Refresh Contracts"))
        {
            ContractModel.LoadContracts();
        }

        GUILayout.FlexibleSpace();

        if (GUILayout.Button("New Contract"))
        {
            ContractForm newContractEditor = ContractForm.Init();
            newContractEditor.OnClose = ReloadContracts;
        }
        GUILayout.Space(6);
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(6);
    }
Ejemplo n.º 2
0
    private void DisplayContract(ContractModel contract)
    {
        GUILayout.BeginVertical(EditorStyles.helpBox);
        {
            //Controls to move contract up and down
            EditorGUILayout.BeginHorizontal();
            {
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Label("Tier: " + contract.Tier);
            GUILayout.Label("Title: " + contract.Title);
            GUILayout.Label("Target Name: " + contract.TargetName);
            GUILayout.Label("Description: \n" + contract.Description);

            //Try to get prefetched images
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.BeginVertical();
                {
                    string targetImagePath = contract.TargetImagePath;

                    if (ContractModel.ContractTargetImages.ContainsKey(targetImagePath))
                    {
                        GUILayout.Label("Target Image - " + targetImagePath);
                        GUILayout.Label(ContractModel.ContractTargetImages[targetImagePath]);
                    }
                }
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical();
                {
                    string targetShipImagePath = contract.TargetShipImagePath;

                    if (ContractModel.ContractTargetShipImages.ContainsKey(targetShipImagePath))
                    {
                        GUILayout.Label("Target Ship Image - " + targetShipImagePath);
                        GUILayout.Label(ContractModel.ContractTargetShipImages[targetShipImagePath]);
                    }
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndHorizontal();

            //Display objectives
            if (contract.Objectives.Length > 0)
            {
                EditorGUILayout.Space();
                GUILayout.Label("Objectives:");

                foreach (Objective objective in contract.Objectives)
                {
                    GUILayout.Label(objective.GetType().ToString() + " - " + objective.sector.name);
                }
            }
            else
            {
                GUILayout.Label("No Objectives :(");
            }


            EditorGUILayout.BeginHorizontal();
            {
                //Buttons to move contract up and down
                if (GUILayout.Button("▲"))
                {
                    MoveUp(contract);
                }
                GUILayout.Space(6);

                if (GUILayout.Button("▼"))
                {
                    MoveDown(contract);
                }
                GUILayout.Space(6);

                GUILayout.FlexibleSpace();

                //Edit and delete buttons in their own horizontal across the bottom
                if (GUILayout.Button("Edit"))
                {
                    int          index             = ContractModel.Contracts.IndexOf(contract);
                    ContractForm newContractEditor = ContractForm.Init(contract, index);
                    newContractEditor.OnClose = ReloadContracts;
                }
                if (GUILayout.Button("Delete"))
                {
                    if (EditorUtility.DisplayDialog("Deleting Contract", "You can't get this contract back if you delete it. Are you sure you want to delete it?", "Yes I hate this contract"))
                    {
                        ContractModel.Contracts.Remove(contract);
                        ContractModel.WriteContracts();
                    }
                }
                GUILayout.Space(6);
            }
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(6);
        }
        GUILayout.EndVertical();

        GUILayout.Space(12);
    }