Exemplo n.º 1
0
        private void CreateDrillableSettingsFields(DrillData dd, int rowIdx)
        {
            // Icon
            Widgets.ThingIcon(Table.GetFieldRect(0, rowIdx).Replace_Width(ICON_SIZE), dd.ThingDefToDrill, null, 1f);

            // ThingDef.label
            Widgets.Label(Table.GetFieldRect(0, rowIdx).Add_X(ICON_SIZE + 2), dd.ThingDefToDrill.label);

            // Work Amount
            string bufferWorkAmount = dd.WorkAmount.ToString();

            Widgets.TextFieldNumeric(Table.GetFieldRect(1, rowIdx).Replace_Width(NUMERIC_INPUT_WIDTH), ref dd.WorkAmount, ref bufferWorkAmount, WORK_AMOUNT_MIN, WORK_AMOUNT_MAX);
            int count = (int)Widgets.HorizontalSlider(GetSliderField(1, rowIdx), dd.WorkAmount, WORK_AMOUNT_MIN, WORK_AMOUNT_MAX);

            if (count != dd.WorkAmount)
            {
                dd.WorkAmount = count;
            }

            // Yield Amount
            string bufferYieldAmount = dd.YieldAmount.ToString();

            Widgets.TextFieldNumeric(Table.GetFieldRect(2, rowIdx).Replace_Width(NUMERIC_INPUT_WIDTH), ref dd.YieldAmount, ref bufferYieldAmount, YIELD_AMOUNT_MIN, dd.MaxYieldAmount);
            int countYield = (int)Widgets.HorizontalSlider(GetSliderField(2, rowIdx), dd.YieldAmount, YIELD_AMOUNT_MIN, dd.MaxYieldAmount);

            if (countYield != dd.YieldAmount)
            {
                dd.YieldAmount = countYield;
            }

            // Row Mouse Hover
            Table.ApplyMouseOverEntireRow(rowIdx);
            TooltipHandler.TipRegion(Table.GetRowRect(rowIdx).LeftHalf(), dd.ThingDefToDrill.description);
        }
        public static void CreateDrillableSettingsFields(DrillData dd, int rowIdx, ref TableData tableData, float iconSize,
                                                         float numericInputWidth, float workAmountMin, float workAmountMax, float yieldAmountMin)
        {
            // Icon
            Widgets.ThingIcon(tableData.GetFieldRect(0, rowIdx).Replace_Width(iconSize), dd.ThingDefToDrill);

            // ThingDef.label
            Widgets.Label(tableData.GetFieldRect(0, rowIdx).Add_X(iconSize + 2), dd.ThingDefToDrill.label);

            // Work Amount
            string bufferWorkAmount = dd.WorkAmount.ToString();

            Widgets.TextFieldNumeric(tableData.GetFieldRect(1, rowIdx).Replace_Width(numericInputWidth), ref dd.WorkAmount, ref bufferWorkAmount, workAmountMin, workAmountMax);
            int count = (int)Widgets.HorizontalSlider(GetSliderField(1, rowIdx, tableData, numericInputWidth), dd.WorkAmount, workAmountMin, workAmountMax);

            if (count != dd.WorkAmount)
            {
                dd.WorkAmount = count;
            }

            // Yield Amount
            string bufferYieldAmount = dd.YieldAmount.ToString();

            Widgets.TextFieldNumeric(tableData.GetFieldRect(2, rowIdx).Replace_Width(numericInputWidth), ref dd.YieldAmount, ref bufferYieldAmount, yieldAmountMin, dd.MaxYieldAmount);
            int countYield = (int)Widgets.HorizontalSlider(GetSliderField(2, rowIdx, tableData, numericInputWidth), dd.YieldAmount, yieldAmountMin, dd.MaxYieldAmount);

            if (countYield != dd.YieldAmount)
            {
                dd.YieldAmount = countYield;
            }

            // Row Mouse Hover
            tableData.ApplyMouseOverEntireRow(rowIdx);
            TooltipHandler.TipRegion(tableData.GetRowRect(rowIdx).LeftHalf(), dd.ThingDefToDrill.description);
        }
Exemplo n.º 3
0
        public override void DoSettingsWindowContents(Rect inRect)
        {
            Listing_Standard ls = new Listing_Standard();

            ls.Begin(inRect);

            SettingsRenderer.CreateRegularSettings(ls, Settings);
            SettingsRenderer.CreateOpenConfigFolderButton(BUTTON_HEIGHT);
            ls.GapLine();
            float drillableScrollStartY = SettingsRenderer.CreateDrillableButtons(ls, BUTTON_HEIGHT, ref Table, Settings) + 12f + ROW_HEIGHT;

            SettingsRenderer.CreateRebootNote(ls, ROW_HEIGHT);

            #region Drillables Scroll View
            Rect scrollViewRect = new Rect(
                inRect.x + SCROLL_VIEW_PADDING_HORIZONTAL,
                inRect.y,
                inRect.width - 2 * SCROLL_VIEW_PADDING_HORIZONTAL,
                GetScrollViewHeight());
            Widgets.BeginScrollView(new Rect(0, drillableScrollStartY, inRect.width, inRect.height - drillableScrollStartY - ROW_HEIGHT), ref _scrollPosition, scrollViewRect);
            SettingsRenderer.CreateDrillableHeaders(Table);

            int rowIdx = 2;
            foreach (var kvp in Settings.Drillables)
            {
                DrillData dd = kvp.Value;
                if (dd == null)
                {
                    Settings.Drillables.Remove(kvp.Key);
                    Debug.LogWarning($"Planetary Drill: Removed drillable \"{kvp.Key}\" because it no longer exists (did you remove the mod or did it update?).");
                }
                else
                {
                    SettingsRenderer.CreateDrillableSettingsFields(dd, rowIdx++, ref Table, ICON_SIZE, NUMERIC_INPUT_WIDTH, WORK_AMOUNT_MIN, WORK_AMOUNT_MAX, YIELD_AMOUNT_MIN);
                }
            }

            ls.GetRect(Table.TableRect.height);

            Widgets.EndScrollView();
            #endregion
            ls.End();
            ApplySettingsToDefs();

            base.DoSettingsWindowContents(inRect);
        }