Exemple #1
0
 public void getDataFrom()
 {
     lineType = (LineNameType)loadedEvents [eventsCount].GetField("type").n;
     lineName = loadedEvents[eventsCount].GetField("name").PrintFormattedString();
 }
Exemple #2
0
        public void OnGUI()
        {
            EditorGUILayout.HelpBox("This is a tool for managing the library of names available to generate a random train line name.\n\nCreate a new line name by choosing NEW and defining a Prefix or Suffix to be generated.\n\nYou can also load or edit any of the current line names in the library by choosing the LOAD option.", MessageType.Info);

            GUILayout.Label("Manage", EditorStyles.boldLabel);
            if (GUILayout.Button("New"))
            {
                createNew = true;
                load      = false;
                stored    = false;
                gotName   = false;
                reset();
            }
            if (GUILayout.Button("Load"))
            {
                createNew = false;
                load      = true;
                stored    = false;
                reset();
                readAll();
            }
            if (GUILayout.Button("Reset"))
            {
                createNew = false;
                load      = false;
                stored    = false;
                gotName   = false;
                reset();
            }


            EditorGUILayout.Separator();
            // The actual window code goes here
            if (createNew)
            {
                GUILayout.Label("Create New", EditorStyles.boldLabel);
                lineName = EditorGUILayout.TextField("Name", lineName);

                GUILayout.Label("Type");
                lineType = (LineNameType)EditorGUILayout.EnumPopup(lineType);

                EditorGUILayout.Space();


                EditorGUILayout.Space();
                EditorGUILayout.BeginHorizontal();


                if (GUILayout.Button("Clear"))
                {
                    reset();
                    this.Repaint();
                }

                if (GUILayout.Button("Store"))
                {
                    createNew = false;
                    stored    = true;
                    if (!editing)
                    {
                        writeNew();
                    }
                    else
                    {
                        replace();
                    }
                    this.Repaint();
                }
                EditorGUILayout.EndHorizontal();
            }

            if (stored)
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Line Name Stored!");
            }

            if (gotName && loadedEvents)
            {
                EditorGUILayout.LabelField("All Names");
                EditorGUILayout.LabelField((eventsCount + 1) + "/" + loadedEvents.Count);

                EditorGUILayout.Space();

                EditorGUILayout.LabelField("Info", EditorStyles.boldLabel);
                EditorGUILayout.LabelField("Line Name: " + loadedEvents[eventsCount].GetField("name"));
                EditorGUILayout.LabelField("Type: " + ((LineNameType)loadedEvents[eventsCount].GetField("type").n).ToString());

                if (GUILayout.Button("Edit"))
                {
                    editing   = true;
                    createNew = true;
                    getDataFrom();
                    gotName = false;
                }

                //GUILayout.Button ("Delete");
                EditorGUILayout.Space();

                EditorGUILayout.BeginHorizontal();

                if (GUILayout.Button("Previous"))
                {
                    eventsCount--;
                    if (eventsCount <= 0)
                    {
                        eventsCount = 0;
                    }
                    this.Repaint();
                }
                if (GUILayout.Button("Next"))
                {
                    eventsCount++;

                    if (eventsCount > loadedEvents.Count - 1)
                    {
                        eventsCount = loadedEvents.Count - 1;
                    }

                    this.Repaint();
                }
                EditorGUILayout.EndHorizontal();
            }
        }
Exemple #3
0
 public void reset()
 {
     lineName = "";
     lineType = LineNameType.prefix;
     editing  = false;
 }