private void JobEditing() { GUILayout.Label("Job Editing", Style("SubTitle")); GUILayout.BeginVertical(); Dictionary <string, int> resourceUsageMapping = new Dictionary <string, int>(); List <string> rutNames = new List <string>(); foreach (int rutkey in activeGameData.ResourceUsageKeys) { ResourceUsageSpec spec = activeGameData.GetResourceUsageTemplate(rutkey); resourceUsageMapping[spec.Name] = spec.Index; rutNames.Add(spec.Name); } List <int> jobKeys = activeGameData.JobKeys.ToList(); for (int i = 0; i < jobKeys.Count; ++i) { int jobKey = jobKeys[i]; Job job = activeGameData.GetJob(jobKey); GUILayout.BeginHorizontal(Style("box")); GUILayout.Label(job.Index.ToString(), GUILayout.Width(50)); job.Name = GUILayout.TextField(job.Name, GUILayout.Width(150)); int selectedIndex = rutNames.IndexOf(job.ResourceUsage.Name); int newSelectedIndex = EditorGUILayout.Popup(selectedIndex, rutNames.ToArray()); if (selectedIndex != newSelectedIndex) { // TODO - Need to rearchitect this shit //job.ResourceUsage = resourceUsageMapping[rutNames[newSelectedIndex]]; } if (GUILayout.Button("Delete")) { activeGameData.DeleteProperty(job.Index); i--; } GUILayout.EndHorizontal(); } GUILayout.Label("New Resource"); GUILayout.BeginHorizontal(Style("box")); GUILayout.Label("Name", GUILayout.Width(100)); newResourceName = GUILayout.TextField(newResourceName, GUILayout.Width(150)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Create")) { activeGameData.AddResource(GameData.MemoryCapacity, newResourceName, 0); } GUILayout.EndVertical(); }
private void ResourceUsageEditing() { GUILayout.Label("Resource Usage Template Editing", Style("SubTitle")); GUILayout.BeginVertical(); List <int> rutKeys = activeGameData.ResourceUsageKeys.ToList(); for (int i = 0; i < rutKeys.Count; ++i) { int rutKey = rutKeys[i]; ResourceUsageSpec rut = activeGameData.GetResourceUsageTemplate(rutKey); GUILayout.BeginHorizontal(Style("box")); GUILayout.Label(rut.Index.ToString(), GUILayout.Width(50)); rut.Name = GUILayout.TextField(rut.Name, GUILayout.Width(150)); rut.Cycles = EditorGUILayout.FloatField(rut.Cycles, GUILayout.Width(100)); rut.MemoryRatio = EditorGUILayout.FloatField(rut.MemoryRatio, GUILayout.Width(100)); rut.MemoryRequired = EditorGUILayout.IntField(rut.MemoryRequired, GUILayout.Width(100)); rut.DiskRatio = EditorGUILayout.FloatField(rut.DiskRatio, GUILayout.Width(100)); rut.DiskRequired = EditorGUILayout.IntField(rut.DiskRequired, GUILayout.Width(100)); if (GUILayout.Button("Delete")) { activeGameData.DeleteResourceUsageTemplate(rut.Index); i--; } GUILayout.EndHorizontal(); } GUILayout.Label("New Resource Usage Template"); GUILayout.BeginHorizontal(Style("box")); GUILayout.Label("Name", GUILayout.Width(100)); newResourceUsageTemplateName = GUILayout.TextField(newResourceUsageTemplateName, GUILayout.Width(150)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Create")) { ResourceUsageSpec spec = ResourceUsageSpec.DefaultProcessUsage(); spec.Name = newResourceUsageTemplateName; activeGameData.AddResourceUsageTemplate(spec); } GUILayout.EndVertical(); }