private void LoadModuleState(ConfigNode node) { if (node.HasValue("progress")) { float.TryParse(node.GetValue("progress"), out progress); } if (node.HasValue("lastUpdateTime")) { double.TryParse(node.GetValue("lastUpdateTime"), out lastUpdateTime); } if (node.HasValue("KACAlarmID")) { KACAlarmID = node.GetValue("KACAlarmID"); } foreach (ConfigNode cn in node.nodes) { if (cn.name == "ProcessedItem") { _processedItem = new WorkshopItem(); _processedItem.Load(cn); } if (cn.name == "ProcessedBlueprint") { _processedBlueprint = new Blueprint(); _processedBlueprint.Load(cn); } if (cn.name == "Queue") { _queue.Load(cn); } } }
private void FinishManufacturing() { var destinationInventory = AddToContainer(_processedItem); if (destinationInventory != null) { ScreenMessages.PostScreenMessage("3D Printing of " + _processedItem.Part.title + " finished.", 5, ScreenMessageStyle.UPPER_CENTER); _processedItem.DisableIcon(); _processedItem = null; _processedBlueprint = null; progress = 0; Status = "Online"; if (Animate && _heatAnimation != null && _workAnimation != null) { StartCoroutine(StopAnimations()); } } else { Status = "Not enough free space"; } deleteKACAlarm(); }
void DrawMouseOverItem(WorkshopItem mouseOverItem, W_KIS_Item mouseOverItemKIS) { // Tooltip adjustedProductivity = WorkshopUtils.GetProductivityBonus(part, ExperienceEffect, SpecialistEfficiencyFactor, ProductivityFactor, WorkshopUtils.ProductivityType.recycler); if (mouseOverItem != null) { var blueprint = WorkshopRecipeDatabase.ProcessPart(mouseOverItem.Part); foreach (var resource in blueprint) { resource.Units *= ConversionRate; } GUI.Box(new Rect(200, 80, 100, 100), mouseOverItem.Icon.texture); GUI.Box(new Rect(310, 80, 150, 100), WorkshopUtils.GetKisStats(mouseOverItem.Part), UI.UIStyles.StatsStyle); GUI.Box(new Rect(470, 80, 150, 100), blueprint.Print(WorkshopUtils.ProductivityType.recycler, adjustedProductivity), UI.UIStyles.StatsStyle); GUI.Box(new Rect(200, 190, 420, 25), mouseOverItem.Part.title, UI.UIStyles.TitleDescriptionStyle); GUI.Box(new Rect(200, 220, 420, 110), mouseOverItem.Part.description, UI.UIStyles.TooltipDescriptionStyle); } else if (mouseOverItemKIS != null) { var blueprint = WorkshopRecipeDatabase.ProcessPart(mouseOverItemKIS.availablePart); foreach (var resource in blueprint) { resource.Units *= ConversionRate; } GUI.Box(new Rect(200, 80, 100, 100), mouseOverItemKIS.Icon.texture); GUI.Box(new Rect(310, 80, 150, 100), WorkshopUtils.GetKisStats(mouseOverItemKIS.availablePart), UI.UIStyles.StatsStyle); GUI.Box(new Rect(470, 80, 150, 100), blueprint.Print(WorkshopUtils.ProductivityType.recycler, adjustedProductivity), UI.UIStyles.StatsStyle); GUI.Box(new Rect(200, 190, 420, 25), mouseOverItemKIS.availablePart.title, UI.UIStyles.TitleDescriptionStyle); GUI.Box(new Rect(200, 220, 420, 110), mouseOverItemKIS.availablePart.description, UI.UIStyles.TooltipDescriptionStyle); } }
void DrawMouseOverItem(WorkshopItem mouseOverItem, KIS_Item mouseOverItemKIS) { // Tooltip GUI.Box(new Rect(190, 70, 440, 270), ""); if (mouseOverItem != null) { var blueprint = WorkshopRecipeDatabase.ProcessPart(mouseOverItem.Part); foreach (var resource in blueprint) { resource.Units *= ConversionRate; } GUI.Box(new Rect(200, 80, 100, 100), mouseOverItem.Icon.texture); GUI.Box(new Rect(310, 80, 150, 100), WorkshopUtils.GetKisStats(mouseOverItem.Part), UI.UIStyles.StatsStyle); GUI.Box(new Rect(470, 80, 150, 100), blueprint.Print(adjustedProductivity), UI.UIStyles.StatsStyle); GUI.Box(new Rect(200, 190, 420, 25), mouseOverItem.Part.title, UI.UIStyles.TitleDescriptionStyle); GUI.Box(new Rect(200, 220, 420, 110), mouseOverItem.Part.description, UI.UIStyles.TooltipDescriptionStyle); } else if (mouseOverItemKIS != null) { var blueprint = WorkshopRecipeDatabase.ProcessPart(mouseOverItemKIS.availablePart); foreach (var resource in blueprint) { resource.Units *= ConversionRate; } GUI.Box(new Rect(200, 80, 100, 100), mouseOverItemKIS.Icon.texture); GUI.Box(new Rect(310, 80, 150, 100), WorkshopUtils.GetKisStats(mouseOverItemKIS.availablePart), UI.UIStyles.StatsStyle); GUI.Box(new Rect(470, 80, 150, 100), blueprint.Print(adjustedProductivity), UI.UIStyles.StatsStyle); GUI.Box(new Rect(200, 190, 420, 25), mouseOverItemKIS.availablePart.title, UI.UIStyles.TitleDescriptionStyle); GUI.Box(new Rect(200, 220, 420, 110), mouseOverItemKIS.availablePart.description, UI.UIStyles.TooltipDescriptionStyle); } }
private WorkshopItem DrawQueue(WorkshopItem mouseOverItem) { const int queueRows = 4; const int queueColumns = 7; GUI.Box(new Rect(190, 345, 440, 270), "Queue", UI.UIStyles.QueueSkin); for (var y = 0; y < queueRows; y++) { for (var x = 0; x < queueColumns; x++) { var left = 205 + x * 60; var top = 370 + y * 60; var itemIndex = y * queueColumns + x; if (_queue.Count > itemIndex) { var item = _queue[itemIndex]; if (item.Icon == null) { item.EnableIcon(64); } if (GUI.Button(new Rect(left, top, 50, 50), item.Icon.texture)) { _queue.Remove(item); } if (Event.current.type == EventType.Repaint && new Rect(left, top, 50, 50).Contains(Event.current.mousePosition)) { mouseOverItem = item; } } } } return(mouseOverItem); // Tooltip }
public virtual FilterResult Filter(WorkshopItem[] items, int skip) { return new FilterResult { Items = items.OrderBy(i => i.Part.title).Skip(skip).Take(30).ToArray(), MaxPages = items.Length/30 }; }
private void CleanupRecycler() { _processedItem.DisableIcon(); _processedItem = null; _processedBlueprint = null; progress = 0; Status = "Online"; }
public override FilterResult Filter(WorkshopItem[] items, int skip) { var filteredItems = items.Where(i => i.Part.partPrefab.GetComponent(Module) != null).ToArray(); return new FilterResult { Items = filteredItems.OrderBy(i => i.Part.title).Skip(skip).Take(30).ToArray(), MaxPages = filteredItems.Length/30 }; }
public override FilterResult Filter(WorkshopItem[] items, int skip) { var filteredItems = items.Where(i => i.Part.category == Category).ToArray(); return new FilterResult { Items = filteredItems.OrderBy(i => i.Part.title).Skip(skip).Take(30).ToArray(), MaxPages = filteredItems.Length/30 }; }
private WorkshopItem DrawAvailableItems(WorkshopItem mouseOverItem) { // Available Items const int itemRows = 10; const int itemColumns = 3; for (var y = 0; y < itemRows; y++) { for (var x = 0; x < itemColumns; x++) { var left = 15 + x * 55; var top = 70 + y * 55; var itemIndex = y * itemColumns + x; if (_filteredItems.Items.Length > itemIndex) { var item = _filteredItems.Items[itemIndex]; if (item.Icon == null) { item.EnableIcon(64); } if (GUI.Button(new Rect(left, top, 50, 50), item.Icon.texture)) { _queue.Add(new WorkshopItem(item.Part)); } if (Event.current.type == EventType.Repaint && new Rect(left, top, 50, 50).Contains(Event.current.mousePosition)) { mouseOverItem = item; } } } } if (_activePage > 0) { if (GUI.Button(new Rect(15, 615, 75, 25), "Prev")) { _selectedPage = _activePage - 1; } } if (_activePage < _filteredItems.MaxPages) { if (GUI.Button(new Rect(100, 615, 75, 25), "Next")) { _selectedPage = _activePage + 1; } } // search box _oldSsearchText = _searchFilter.FilterText; GUI.Label(new Rect(15, 645, 65, 25), "Find: ", UI.UIStyles.StatsStyle); _searchFilter.FilterText = GUI.TextField(new Rect(75, 645, 100, 25), _searchFilter.FilterText); return(mouseOverItem); }
private void DrawMouseOverItem(WorkshopItem mouseOverItem) { GUI.Box(new Rect(190, 70, 440, 270), ""); if (mouseOverItem != null) { var blueprint = WorkshopRecipeDatabase.ProcessPart(mouseOverItem.Part); GUI.Box(new Rect(200, 80, 100, 100), mouseOverItem.Icon.texture); GUI.Box(new Rect(310, 80, 150, 100), WorkshopUtils.GetKisStats(mouseOverItem.Part), UI.UIStyles.StatsStyle); GUI.Box(new Rect(470, 80, 150, 100), blueprint.Print(adjustedProductivity), UI.UIStyles.StatsStyle); GUI.Box(new Rect(200, 190, 420, 25), mouseOverItem.Part.title, UI.UIStyles.TitleDescriptionStyle); GUI.Box(new Rect(200, 220, 420, 110), mouseOverItem.Part.description, UI.UIStyles.TooltipDescriptionStyle); } }
private void StartManufacturing() { var nextQueuedPart = _queue.Pop(); if (nextQueuedPart != null) { _processedItem = nextQueuedPart; _processedBlueprint = WorkshopRecipeDatabase.ProcessPart(nextQueuedPart.Part); foreach (var resource in _processedBlueprint) { resource.Units *= ConversionRate; } } }
private void DrawMouseOverItem(WorkshopItem mouseOverItem) { GUI.Box(new Rect(190, 70, 440, 270), ""); if (mouseOverItem != null) { adjustedProductivity = WorkshopUtils.GetProductivityBonus(this.part, ExperienceEffect, SpecialistEfficiencyFactor, ProductivityFactor, WorkshopUtils.ProductivityType.printer); var blueprint = WorkshopRecipeDatabase.ProcessPart(mouseOverItem.Part); GUI.Box(new Rect(200, 80, 100, 100), mouseOverItem.Icon.texture); GUI.Box(new Rect(310, 80, 150, 100), WorkshopUtils.GetKisStats(mouseOverItem.Part), UI.UIStyles.StatsStyle); GUI.Box(new Rect(470, 80, 150, 100), blueprint.Print(WorkshopUtils.ProductivityType.printer, adjustedProductivity), UI.UIStyles.StatsStyle); GUI.Box(new Rect(200, 190, 420, 25), mouseOverItem.Part.title, UI.UIStyles.TitleDescriptionStyle); GUI.Box(new Rect(200, 220, 420, 110), mouseOverItem.Part.description, UI.UIStyles.TooltipDescriptionStyle); } }
private void StartManufacturing() { var nextQueuedPart = _queue.Pop(); if (nextQueuedPart != null) { _processedItem = nextQueuedPart; _processedBlueprint = WorkshopRecipeDatabase.ProcessPart(nextQueuedPart.Part, workshopRecipe); if (Animate && _heatAnimation != null && _workAnimation != null) { StartCoroutine(StartAnimations()); } } }
private void CleanupRecycler() { // Need to turn processed stuff over to the tanks foreach (var p in _processedBlueprint) { this.part.RequestResource(p.Name, -p.Processed); } _processedItem.DisableIcon(); _processedItem = null; _processedBlueprint = null; progress = 0; deleteKACAlarm(); }
private void DrawWindowContents(int windowId) { WorkshopItem mouseOverItem = null; W_KIS_Item mouseOverItemKIS = null; mouseOverItemKIS = DrawInventoryItems(mouseOverItemKIS); mouseOverItem = DrawQueue(mouseOverItem); DrawMouseOverItem(mouseOverItem, mouseOverItemKIS); DrawRecyclingProgress(); if (GUI.Button(new Rect(_windowPos.width - 25, 5, 20, 20), "X")) { ContextMenuOpenRecycler(); } GUI.DragWindow(); }
private void DrawWindowContents(int windowId) { _selectedFilterId = GUI.Toolbar(new Rect(15, 35, 615, 30), _selectedFilterId, _filterTextures); WorkshopItem mouseOverItem = null; mouseOverItem = DrawAvailableItems(mouseOverItem); mouseOverItem = DrawQueue(mouseOverItem); DrawMouseOverItem(mouseOverItem); DrawPrintProgress(); if (GUI.Button(new Rect(_windowPos.width - 25, 5, 20, 20), "X")) { ContextMenuOpenWorkbench(); } GUI.DragWindow(); }
private void LoadModuleState(ConfigNode node) { foreach (ConfigNode cn in node.nodes) { if (cn.name == "ProcessedItem") { _processedItem = new WorkshopItem(); _processedItem.Load(cn); } if (cn.name == "ProcessedBlueprint") { _processedBlueprint = new Blueprint(); _processedBlueprint.Load(cn); } if (cn.name == "Queue") { _queue.Load(cn); } } }
private ModuleKISInventory AddToContainer(WorkshopItem item) { var inventories = KISWrapper.GetInventories(vessel); if (inventories == null || inventories.Count == 0) { throw new Exception("No KIS Inventory found!"); } var freeInventories = inventories .Where(i => WorkshopUtils.HasFreeSpace(i, item)) .Where(WorkshopUtils.HasFreeSlot) .Where(WorkshopUtils.IsOccupied) .ToArray(); if (freeInventories.Any()) { // first pass with favored inventories var favoredInventories = freeInventories .Where(i => i.part.GetComponent <OseModuleInventoryPreference>() != null) .Where(i => i.part.GetComponent <OseModuleInventoryPreference>().IsFavored).ToArray(); foreach (var inventory in favoredInventories) { var kisItem = inventory.AddItem(item.Part.partPrefab); if (kisItem == null) { throw new Exception("Error adding item " + item.Part.name + " to inventory"); } foreach (var resourceInfo in kisItem.GetResources()) { if (WorkshopRecipeDatabase.HasResourceRecipe(resourceInfo.resourceName)) { kisItem.SetResource(resourceInfo.resourceName, (int)resourceInfo.maxAmount); } else { kisItem.SetResource(resourceInfo.resourceName, 0); } } return(inventory); } // second pass with the rest foreach (var inventory in freeInventories) { var kisItem = inventory.AddItem(item.Part.partPrefab); if (kisItem == null) { throw new Exception("Error adding item " + item.Part.name + " to inventory"); } foreach (var resourceInfo in kisItem.GetResources()) { if (WorkshopRecipeDatabase.HasResourceRecipe(resourceInfo.resourceName)) { kisItem.SetResource(resourceInfo.resourceName, (int)resourceInfo.maxAmount); } else { kisItem.SetResource(resourceInfo.resourceName, 0); } } return(inventory); } } return(null); }
private ModuleKISInventory AddToContainer(WorkshopItem item) { var inventories = KISWrapper.GetInventories(vessel); if (inventories == null || inventories.Count == 0) { throw new Exception("No KIS Inventory found!"); } var freeInventories = inventories .Where(i => WorkshopUtils.HasFreeSpace(i, item)) .Where(WorkshopUtils.HasFreeSlot) .Where(WorkshopUtils.IsOccupied) .ToArray(); if (freeInventories.Any()) { // first pass with favored inventories var favoredInventories = freeInventories .Where(i => i.part.GetComponent<OseModuleInventoryPreference>() != null) .Where(i => i.part.GetComponent<OseModuleInventoryPreference>().IsFavored).ToArray(); foreach (var inventory in favoredInventories) { var kisItem = inventory.AddItem(item.Part.partPrefab); if (kisItem == null) { throw new Exception("Error adding item " + item.Part.name + " to inventory"); } foreach (var resourceInfo in kisItem.GetResources()) { if (WorkshopRecipeDatabase.HasResourceRecipe(resourceInfo.resourceName)) { kisItem.SetResource(resourceInfo.resourceName, (int)resourceInfo.maxAmount); } else { kisItem.SetResource(resourceInfo.resourceName, 0); } } return inventory; } // second pass with the rest foreach (var inventory in freeInventories) { var kisItem = inventory.AddItem(item.Part.partPrefab); if (kisItem == null) { throw new Exception("Error adding item " + item.Part.name + " to inventory"); } foreach (var resourceInfo in kisItem.GetResources()) { if (WorkshopRecipeDatabase.HasResourceRecipe(resourceInfo.resourceName)) { kisItem.SetResource(resourceInfo.resourceName, (int)resourceInfo.maxAmount); } else { kisItem.SetResource(resourceInfo.resourceName, 0); } } return inventory; } } return null; }
private void DrawWindowContents(int windowId) { WorkshopItem mouseOverItem = null; // styles var statsStyle = new GUIStyle(GUI.skin.box); statsStyle.fontSize = 11; statsStyle.alignment = TextAnchor.UpperLeft; statsStyle.padding.left = statsStyle.padding.top = 5; var tooltipDescriptionStyle = new GUIStyle(GUI.skin.box); tooltipDescriptionStyle.fontSize = 11; tooltipDescriptionStyle.alignment = TextAnchor.UpperCenter; tooltipDescriptionStyle.padding.top = 5; var queueSkin = new GUIStyle(GUI.skin.box); queueSkin.alignment = TextAnchor.UpperCenter; queueSkin.padding.top = 5; // Filters _selectedFilterId = GUI.Toolbar(new Rect(15, 35, 615, 30), _selectedFilterId, _filterTextures); // Available Items const int itemRows = 10; const int itemColumns = 3; for (var y = 0; y < itemRows; y++) { for (var x = 0; x < itemColumns; x++) { var left = 15 + x * 55; var top = 70 + y * 55; var itemIndex = y * itemColumns + x; if (_filteredItems.Items.Length > itemIndex) { var item = _filteredItems.Items[itemIndex]; if (item.Icon == null) { item.EnableIcon(64); } if (GUI.Button(new Rect(left, top, 50, 50), item.Icon.texture)) { _queue.Add(new WorkshopItem(item.Part)); } if (Event.current.type == EventType.Repaint && new Rect(left, top, 50, 50).Contains(Event.current.mousePosition)) { mouseOverItem = item; } } } } if (_activePage > 0) { if (GUI.Button(new Rect(15, 645, 75, 25), "Prev")) { _selectedPage = _activePage - 1; } } if (_activePage < _filteredItems.MaxPages) { if (GUI.Button(new Rect(100, 645, 75, 25), "Next")) { _selectedPage = _activePage + 1; } } // Queued Items const int queueRows = 4; const int queueColumns = 7; GUI.Box(new Rect(190, 345, 440, 270), "Queue", queueSkin); for (var y = 0; y < queueRows; y++) { for (var x = 0; x < queueColumns; x++) { var left = 205 + x * 60; var top = 370 + y * 60; var itemIndex = y * queueColumns + x; if (_queue.Count > itemIndex) { var item = _queue[itemIndex]; if (item.Icon == null) { item.EnableIcon(64); } if (GUI.Button(new Rect(left, top, 50, 50), item.Icon.texture)) { _queue.Remove(item); } if (Event.current.type == EventType.Repaint && new Rect(left, top, 50, 50).Contains(Event.current.mousePosition)) { mouseOverItem = item; } } } } // Tooltip GUI.Box(new Rect(190, 70, 440, 270), ""); if (mouseOverItem != null) { var blueprint = WorkshopRecipeDatabase.ProcessPart(mouseOverItem.Part); GUI.Box(new Rect(200, 80, 100, 100), mouseOverItem.Icon.texture); GUI.Box(new Rect(310, 80, 150, 100), WorkshopUtils.GetKisStats(mouseOverItem.Part), statsStyle); GUI.Box(new Rect(470, 80, 150, 100), blueprint.Print(adjustedProductivity), statsStyle); GUI.Box(new Rect(200, 190, 420, 140), WorkshopUtils.GetDescription(mouseOverItem.Part), tooltipDescriptionStyle); } // Currently build item if (_processedItem != null) { if (_processedItem.Icon == null) { _processedItem.EnableIcon(64); } GUI.Box(new Rect(190, 620, 50, 50), _processedItem.Icon.texture); } else { GUI.Box(new Rect(190, 620, 50, 50), ""); } // Progressbar GUI.Box(new Rect(250, 620, 280, 50), ""); if (progress >= 1) { var color = GUI.color; GUI.color = new Color(0, 1, 0, 1); GUI.Box(new Rect(250, 620, 280 * progress / 100, 50), ""); GUI.color = color; } GUI.Label(new Rect(250, 620, 280, 50), " " + progress.ToString("0.0") + " / 100"); //Pause/resume production string buttonLabel = "||"; if (manufacturingPaused || _processedItem == null) buttonLabel = ">"; if (GUI.Button(new Rect(530, 620, 50, 50), buttonLabel) && _processedItem != null) { manufacturingPaused = !manufacturingPaused; } //Cancel production if (GUI.Button(new Rect(580, 620, 50, 50), "X")) { if (_confirmDelete) { _processedItem.DisableIcon(); _processedItem = null; _processedBlueprint = null; progress = 0; Status = "Online"; if (Animate && _heatAnimation != null && _workAnimation != null) { StartCoroutine(StopAnimations()); } _confirmDelete = false; } else { _confirmDelete = true; ScreenMessages.PostScreenMessage("Click the cancel button again to confirm cancelling current production", 5.0f, ScreenMessageStyle.UPPER_CENTER); } } if (GUI.Button(new Rect(_windowPos.width - 25, 5, 20, 20), "X")) { ContextMenuOpenWorkbench(); } GUI.DragWindow(); }
private void AddNewItemToQueue() { if (_addedItem == null) { return; } _queue.Add(_addedItem); _addedItemInventory.DeleteItem(_addedItemKey); _addedItem = null; _addedItemInventory = null; _addedItemKey = -1; }
private void DrawWindowContents(int windowId) { WorkshopItem mouseOverItem = null; // styles var statsStyle = new GUIStyle(GUI.skin.box); statsStyle.fontSize = 11; statsStyle.alignment = TextAnchor.UpperLeft; statsStyle.padding.left = statsStyle.padding.top = 5; var tooltipDescriptionStyle = new GUIStyle(GUI.skin.box); tooltipDescriptionStyle.fontSize = 11; tooltipDescriptionStyle.alignment = TextAnchor.UpperCenter; tooltipDescriptionStyle.padding.top = 5; var queueSkin = new GUIStyle(GUI.skin.box); queueSkin.alignment = TextAnchor.UpperCenter; queueSkin.padding.top = 5; // Filters _selectedFilterId = GUI.Toolbar(new Rect(15, 35, 615, 30), _selectedFilterId, _filterTextures); // Available Items const int itemRows = 10; const int itemColumns = 3; for (var y = 0; y < itemRows; y++) { for (var x = 0; x < itemColumns; x++) { var left = 15 + x * 55; var top = 70 + y * 55; var itemIndex = y * itemColumns + x; if (_filteredItems.Items.Length > itemIndex) { var item = _filteredItems.Items[itemIndex]; if (item.Icon == null) { item.EnableIcon(64); } if (GUI.Button(new Rect(left, top, 50, 50), item.Icon.texture)) { _queue.Add(new WorkshopItem(item.Part)); } if (Event.current.type == EventType.Repaint && new Rect(left, top, 50, 50).Contains(Event.current.mousePosition)) { mouseOverItem = item; } } } } if (_activePage > 0) { if (GUI.Button(new Rect(15, 645, 75, 25), "Prev")) { _selectedPage = _activePage - 1; } } if (_activePage < _filteredItems.MaxPages) { if (GUI.Button(new Rect(100, 645, 75, 25), "Next")) { _selectedPage = _activePage + 1; } } // Queued Items const int queueRows = 4; const int queueColumns = 7; GUI.Box(new Rect(190, 345, 440, 270), "Queue", queueSkin); for (var y = 0; y < queueRows; y++) { for (var x = 0; x < queueColumns; x++) { var left = 205 + x * 60; var top = 370 + y * 60; var itemIndex = y * queueColumns + x; if (_queue.Count > itemIndex) { var item = _queue[itemIndex]; if (item.Icon == null) { item.EnableIcon(64); } if (GUI.Button(new Rect(left, top, 50, 50), item.Icon.texture)) { _queue.Remove(item); } if (Event.current.type == EventType.Repaint && new Rect(left, top, 50, 50).Contains(Event.current.mousePosition)) { mouseOverItem = item; } } } } // Tooltip GUI.Box(new Rect(190, 70, 440, 270), ""); if (mouseOverItem != null) { var blueprint = WorkshopRecipeDatabase.ProcessPart(mouseOverItem.Part); GUI.Box(new Rect(200, 80, 100, 100), mouseOverItem.Icon.texture); GUI.Box(new Rect(310, 80, 150, 100), WorkshopUtils.GetKisStats(mouseOverItem.Part), statsStyle); GUI.Box(new Rect(470, 80, 150, 100), blueprint.Print(adjustedProductivity), statsStyle); GUI.Box(new Rect(200, 190, 420, 140), WorkshopUtils.GetDescription(mouseOverItem.Part), tooltipDescriptionStyle); } // Currently build item if (_processedItem != null) { if (_processedItem.Icon == null) { _processedItem.EnableIcon(64); } GUI.Box(new Rect(190, 620, 50, 50), _processedItem.Icon.texture); } else { GUI.Box(new Rect(190, 620, 50, 50), ""); } // Progressbar GUI.Box(new Rect(250, 620, 280, 50), ""); if (progress >= 1) { var color = GUI.color; GUI.color = new Color(0, 1, 0, 1); GUI.Box(new Rect(250, 620, 280 * progress / 100, 50), ""); GUI.color = color; } GUI.Label(new Rect(250, 620, 280, 50), " " + progress.ToString("0.0") + " / 100"); //Pause/resume production Texture2D buttonTexture = _pauseTexture; if (manufacturingPaused || _processedItem == null) { buttonTexture = _playTexture; } if (GUI.Button(new Rect(530, 620, 50, 50), buttonTexture) && _processedItem != null) { manufacturingPaused = !manufacturingPaused; } //Cancel production if (GUI.Button(new Rect(580, 620, 50, 50), _binTexture)) { if (_confirmDelete) { _processedItem.DisableIcon(); _processedItem = null; _processedBlueprint = null; progress = 0; manufacturingPaused = false; Status = "Online"; if (Animate && _heatAnimation != null && _workAnimation != null) { StartCoroutine(StopAnimations()); } _confirmDelete = false; } else { _confirmDelete = true; ScreenMessages.PostScreenMessage("Click the cancel button again to confirm cancelling current production", 5.0f, ScreenMessageStyle.UPPER_CENTER); } } if (GUI.Button(new Rect(_windowPos.width - 25, 5, 20, 20), "X")) { ContextMenuOpenWorkbench(); } GUI.DragWindow(); }
private void StartManufacturing() { var nextQueuedPart = _queue.Pop(); if (nextQueuedPart != null) { _processedItem = nextQueuedPart; } }
private void RemoveCanceledItemFromQueue() { if (_canceledItem != null) { _canceledItem.DisableIcon(); _queue.Remove(_canceledItem); _canceledItem = null; } }
private void DrawAvailableItems() { GUILayout.BeginVertical(); _scrollPosItems = GUILayout.BeginScrollView(_scrollPosItems, WorkshopStyles.Databox(), GUILayout.Width(400f), GUILayout.Height(250f)); foreach (var inventory in part.vessel.FindPartModulesImplementing<ModuleKISInventory>()) { foreach (var item in inventory.items) { if (item.Value.icon == null) { item.Value.EnableIcon(128); } GUILayout.BeginHorizontal(); WorkshopGui.ItemThumbnail(item.Value.icon); WorkshopGui.ItemDescription(item.Value.availablePart, this.OutputResource, this.ConversionRate); if (GUILayout.Button("Queue", WorkshopStyles.Button(), GUILayout.Width(60f), GUILayout.Height(40f))) { _addedItem = new WorkshopItem(item.Value.availablePart); _addedItemKey = item.Key; _addedItemInventory = inventory; } GUILayout.EndHorizontal(); } } GUILayout.EndScrollView(); GUILayout.EndVertical(); }
private void StartManufacturing() { var nextQueuedPart = _queue.Pop(); if (nextQueuedPart != null) { _processedItem = nextQueuedPart; _processedBlueprint = WorkshopRecipeDatabase.ProcessPart(nextQueuedPart.Part); if (Animate && _heatAnimation != null && _workAnimation != null) { StartCoroutine(StartAnimations()); } } }
private void DrawPrintProgress() { // Currently build item if (_processedItem != null) { if (_processedItem.Icon == null) { _processedItem.EnableIcon(64); } GUI.Box(new Rect(190, 620, 50, 50), _processedItem.Icon.texture); } else { GUI.Box(new Rect(190, 620, 50, 50), ""); } // Progressbar GUI.Box(new Rect(250, 620, 280, 50), ""); if (progress >= 1) { var color = GUI.color; GUI.color = new Color(0, 1, 0, 1); GUI.Box(new Rect(250, 620, 280 * progress / 100, 50), ""); GUI.color = color; } string progressText = ""; if (_processedBlueprint != null) { progressText = string.Format("Progress: {0:n1}%, T- ", progress) + KSPUtil.PrintTime(_processedBlueprint.GetBuildTime(WorkshopUtils.ProductivityType.printer, adjustedProductivity), 5, false); } GUI.Label(new Rect(250, 620, 280, 50), " " + progressText); //Pause/resume production Texture2D buttonTexture = _pauseTexture; if (manufacturingPaused || _processedItem == null) { buttonTexture = _playTexture; } if (GUI.Button(new Rect(530, 620, 50, 50), buttonTexture) && _processedItem != null) { manufacturingPaused = !manufacturingPaused; } //Cancel production if (_processedItem == null) { GUI.enabled = false; } if (GUI.Button(new Rect(580, 620, 50, 50), _binTexture)) { if (_confirmDelete) { _processedItem.DisableIcon(); _processedItem = null; _processedBlueprint = null; progress = 0; manufacturingPaused = false; Status = "Online"; if (Animate && _heatAnimation != null && _workAnimation != null) { StartCoroutine(StopAnimations()); } _confirmDelete = false; } else { _confirmDelete = true; ScreenMessages.PostScreenMessage("Click the cancel button again to confirm cancelling current production", 5.0f, ScreenMessageStyle.UPPER_CENTER); } } GUI.enabled = true; }
private void FinishManufacturing() { var destinationInventory = AddToContainer(_processedItem); if (destinationInventory != null) { ScreenMessages.PostScreenMessage("3D Printing of " + _processedItem.Part.title + " finished.", 5, ScreenMessageStyle.UPPER_CENTER); _processedItem.DisableIcon(); _processedItem = null; _processedBlueprint = null; progress = 0; Status = "Online"; if (Animate && _heatAnimation != null && _workAnimation != null) { StartCoroutine(StopAnimations()); } } else { Status = "Not enough free space"; } }
public static bool HasFreeSpace(ModuleKISInventory inventory, WorkshopItem item) { return inventory.GetContentVolume() + KIS_Shared.GetPartVolume(item.Part) <= inventory.maxVolume; }
private void DrawQueuedItems() { GUILayout.BeginVertical(); _scrollPosQueue = GUILayout.BeginScrollView(_scrollPosQueue, WorkshopStyles.Databox(), GUILayout.Width(400f), GUILayout.Height(250f)); foreach (var item in this._queue) { GUILayout.BeginHorizontal(); if (item.Icon == null) { item.EnableIcon(128); } WorkshopGui.ItemThumbnail(item.Icon); WorkshopGui.ItemDescription(item.Part, this.OutputResource, this.ConversionRate); if (GUILayout.Button("Remove", WorkshopStyles.Button(), GUILayout.Width(60f), GUILayout.Height(40f))) { _canceledItem = item; } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.EndVertical(); }
private void DrawWindowContents(int windowId) { WorkshopItem mouseOverItem = null; KIS_Item mouseOverItemKIS = null; // styles var statsStyle = new GUIStyle(GUI.skin.box); statsStyle.fontSize = 11; statsStyle.alignment = TextAnchor.UpperLeft; statsStyle.padding.left = statsStyle.padding.top = 5; var tooltipDescriptionStyle = new GUIStyle(GUI.skin.box); tooltipDescriptionStyle.fontSize = 11; tooltipDescriptionStyle.alignment = TextAnchor.UpperCenter; tooltipDescriptionStyle.padding.top = 5; var queueSkin = new GUIStyle(GUI.skin.box); queueSkin.alignment = TextAnchor.UpperCenter; queueSkin.padding.top = 5; var lowerRightStyle = new GUIStyle(GUI.skin.label); lowerRightStyle.alignment = TextAnchor.LowerRight; lowerRightStyle.fontSize = 10; lowerRightStyle.padding = new RectOffset(4, 4, 4, 4); lowerRightStyle.normal.textColor = Color.white; // AvailableItems const int ItemRows = 10; const int ItemColumns = 3; var availableItems = KISWrapper.GetInventories(vessel).SelectMany(i => i.items).ToArray(); var maxPage = availableItems.Length / 30; for (var y = 0; y < ItemRows; y++) { for (var x = 0; x < ItemColumns; x++) { var left = 15 + x * 55; var top = 70 + y * 55; var itemIndex = y * ItemColumns + x; if (availableItems.Length > itemIndex) { var item = availableItems[itemIndex]; if (item.Value.Icon == null) { item.Value.EnableIcon(64); } if (GUI.Button(new Rect(left, top, 50, 50), item.Value.Icon.texture)) { _queue.Add(new WorkshopItem(item.Value.availablePart)); item.Value.StackRemove(1); } if (item.Value.stackable) { GUI.Label(new Rect(left, top, 50, 50), item.Value.quantity.ToString("x#"), lowerRightStyle); } if (Event.current.type == EventType.Repaint && new Rect(left, top, 50, 50).Contains(Event.current.mousePosition)) { mouseOverItemKIS = item.Value; } } } } if (_activePage > 0) { if (GUI.Button(new Rect(15, 645, 75, 25), "Prev")) { _selectedPage = _activePage - 1; } } if (_activePage < maxPage) { if (GUI.Button(new Rect(100, 645, 75, 25), "Next")) { _selectedPage = _activePage + 1; } } // Queued Items const int QueueRows = 4; const int QueueColumns = 7; GUI.Box(new Rect(190, 345, 440, 270), "Queue", queueSkin); for (var y = 0; y < QueueRows; y++) { for (var x = 0; x < QueueColumns; x++) { var left = 205 + x * 60; var top = 370 + y * 60; var itemIndex = y * QueueColumns + x; if (_queue.Count > itemIndex) { var item = _queue[itemIndex]; if (item.Icon == null) { item.EnableIcon(64); } if (GUI.Button(new Rect(left, top, 50, 50), item.Icon.texture)) { _queue.Remove(item); } if (Event.current.type == EventType.Repaint && new Rect(left, top, 50, 50).Contains(Event.current.mousePosition)) { mouseOverItem = item; } } } } // Tooltip GUI.Box(new Rect(190, 70, 440, 270), ""); if (mouseOverItem != null) { var blueprint = WorkshopRecipeDatabase.ProcessPart(mouseOverItem.Part); foreach (var resource in blueprint) { resource.Units *= ConversionRate; } GUI.Box(new Rect(200, 80, 100, 100), mouseOverItem.Icon.texture); GUI.Box(new Rect(310, 80, 150, 100), WorkshopUtils.GetKisStats(mouseOverItem.Part), statsStyle); GUI.Box(new Rect(470, 80, 150, 100), blueprint.Print(adjustedProductivity), statsStyle); GUI.Box(new Rect(200, 190, 420, 140), WorkshopUtils.GetDescription(mouseOverItem.Part), tooltipDescriptionStyle); } else if (mouseOverItemKIS != null) { var blueprint = WorkshopRecipeDatabase.ProcessPart(mouseOverItemKIS.availablePart); foreach (var resource in blueprint) { resource.Units *= ConversionRate; } GUI.Box(new Rect(200, 80, 100, 100), mouseOverItemKIS.Icon.texture); GUI.Box(new Rect(310, 80, 150, 100), WorkshopUtils.GetKisStats(mouseOverItemKIS.availablePart), statsStyle); GUI.Box(new Rect(470, 80, 150, 100), blueprint.Print(adjustedProductivity), statsStyle); GUI.Box(new Rect(200, 190, 420, 140), WorkshopUtils.GetDescription(mouseOverItemKIS.availablePart), tooltipDescriptionStyle); } // Currently build item if (_processedItem != null) { if (_processedItem.Icon == null) { _processedItem.EnableIcon(64); } GUI.Box(new Rect(190, 620, 50, 50), _processedItem.Icon.texture); } else { GUI.Box(new Rect(190, 620, 50, 50), ""); } // Progressbar GUI.Box(new Rect(250, 620, 260, 50), ""); if (progress >= 1) { var color = GUI.color; GUI.color = new Color(0, 1, 0, 1); GUI.Box(new Rect(250, 620, 260 * progress / 100, 50), ""); GUI.color = color; } GUI.Label(new Rect(250, 620, 260, 50), " " + progress.ToString("0.0") + " / 100"); // Toolbar if (recyclingPaused) { if (GUI.Button(new Rect(520, 620, 50, 50), _playTexture)) { recyclingPaused = false; } } else { if (GUI.Button(new Rect(520, 620, 50, 50), _pauseTexture)) { recyclingPaused = true; } } if (GUI.Button(new Rect(580, 620, 50, 50), _binTexture)) { this.CancelManufacturing(); } if (GUI.Button(new Rect(_windowPos.width - 25, 5, 20, 20), "X")) { this.ContextMenuOnOpenRecycler(); } GUI.DragWindow(); }
private void FinishManufacturing() { _processedItem.DisableIcon(); _processedItem = null; _massProcessed = 0; _progress = 0; Status = "Online"; }
private void LoadModuleState(ConfigNode node) { foreach (ConfigNode cn in node.nodes) { if (cn.name == "BUILTPART" && cn.HasValue("Name") && cn.HasValue("MassProcessed")) { var availablePart = PartLoader.getPartInfoByName(cn.GetValue("Name")); if (availablePart != null) { this._processedItem = new WorkshopItem(availablePart); _massProcessed = double.Parse(cn.GetValue("MassProcessed")); } } if (cn.name == "QUEUEDPART" && cn.HasValue("Name")) { var availablePart = PartLoader.getPartInfoByName(cn.GetValue("Name")); var item = new WorkshopItem(availablePart); _queue.Add(item); } } }
public static bool HasFreeSpace(ModuleKISInventory inventory, WorkshopItem item) { return(inventory.GetContentVolume() + KIS_Shared.GetPartVolume(item.Part) <= inventory.maxVolume); }
private void DrawPrintProgress() { // Currently build item if (_processedItem != null) { if (_processedItem.Icon == null) { _processedItem.EnableIcon(64); } GUI.Box(new Rect(190, 620, 50, 50), _processedItem.Icon.texture); } else { GUI.Box(new Rect(190, 620, 50, 50), ""); } // Progressbar GUI.Box(new Rect(250, 620, 280, 50), ""); if (progress >= 1) { var color = GUI.color; GUI.color = new Color(0, 1, 0, 1); GUI.Box(new Rect(250, 620, 280 * progress / 100, 50), ""); GUI.color = color; } GUI.Label(new Rect(250, 620, 280, 50), " " + progress.ToString("0.0") + " / 100"); //Pause/resume production Texture2D buttonTexture = _pauseTexture; if (manufacturingPaused || _processedItem == null) { buttonTexture = _playTexture; } if (GUI.Button(new Rect(530, 620, 50, 50), buttonTexture) && _processedItem != null) { manufacturingPaused = !manufacturingPaused; } //Cancel production if (GUI.Button(new Rect(580, 620, 50, 50), _binTexture)) { if (_confirmDelete) { _processedItem.DisableIcon(); _processedItem = null; _processedBlueprint = null; progress = 0; manufacturingPaused = false; Status = "Online"; if (Animate && _heatAnimation != null && _workAnimation != null) { StartCoroutine(StopAnimations()); } _confirmDelete = false; } else { _confirmDelete = true; ScreenMessages.PostScreenMessage("Click the cancel button again to confirm cancelling current production", 5.0f, ScreenMessageStyle.UPPER_CENTER); } } }