Beispiel #1
0
        void DrawRecyclingProgress()
        {
            // 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;
            }
            string progressText = "";

            if (_processedBlueprint != null)
            {
                progressText = string.Format("Progress: {0:n1}%, T- ", progress) + KSPUtil.PrintTime(_processedBlueprint.GetBuildTime(WorkshopUtils.ProductivityType.recycler, adjustedProductivity), 5, false);
            }
            Log.Info("DrawRecyclingProgress, adjustedProductivity: " + adjustedProductivity);
            GUI.Label(new Rect(250, 620, 260, 50), " " + progressText);

            // 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))
            {
                CancelManufacturing();
            }
        }
Beispiel #2
0
        void DrawRecyclingProgress()
        {
            // 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))
            {
                CancelManufacturing();
            }
        }
        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 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();
        }
Beispiel #5
0
        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();
        }
Beispiel #6
0
        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);
                }
            }
        }