private void DoPoints(Rect _rect) { // Make strings string strCurItemPoints = "Item Points: " + String.Format("{0:0}", NewGameRules.floCurItemPoints); string strCurPawnPoints = "Pawn Points: " + String.Format("{0:0}", NewGameRules.floCurPawnPoints); // Shape labels Rect rectCurItemPoints = new Rect(_rect.x, _rect.y, Text.CalcSize(strCurItemPoints).x, Text.CalcSize(strCurItemPoints).y); Rect rectCurPawnPoints = new Rect(_rect.x, _rect.y + Text.CalcSize(strCurItemPoints).y, Text.CalcSize(strCurPawnPoints).x, Text.CalcSize(strCurPawnPoints).y); // Draw labels if (NewGameRules.floCurItemPoints >= 0) { GUI.Label(rectCurItemPoints, strCurItemPoints, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Normal)); } else { GUI.Label(rectCurItemPoints, strCurItemPoints, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.Red, FontStyle.Normal)); } if (NewGameRules.floCurPawnPoints >= 0) { GUI.Label(rectCurPawnPoints, strCurPawnPoints, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Normal)); } else { GUI.Label(rectCurPawnPoints, strCurPawnPoints, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.Red, FontStyle.Normal)); } }
private void AdultStoriesIn() { string strStoryLabel = ""; Rect rectStoryLabel = new Rect(0, 0, rectAdultStoriesIn.width, Text.CalcSize("00000").y); float floYAdjust = rectStoryLabel.height; GUI.DrawTexture(rectAdultStoriesIn, ProTBin.texVellum, ScaleMode.ScaleAndCrop); for (int i = 1; i < PBS.intAdultStoriesAmount; i++) { PBS.GetNeoAdultStory(ref tempAdultStory, i); strStoryLabel = tempAdultStory.Title; // Draw label based upon if it's currently selected if (i == intCurSelectedAdultStory) { GUI.Label(rectStoryLabel, strStoryLabel, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.Yellow)); // Prime variable for equip button //esItemCurSelectedToEquip = _aItems[i]; } else { Widgets.Label(rectStoryLabel, strStoryLabel); } // Highlight is mouse is hovering over if (Mouse.IsOver(rectStoryLabel)) { Widgets.DrawHighlight(rectStoryLabel); } // Draw invisible button for item selecting if (Widgets.ButtonInvisible(rectStoryLabel, true)) { intCurSelectedChildStory = 0; intCurSelectedAdultStory = i; } rectStoryLabel.y += floYAdjust; } }
private void DoStartingItems() { // Calculate variables float floMenuHeight = rectCard.height * .8f; ESItem[] esiStartingItems = ESStartingItems.aStartingItems; // Shape the menu section Rect rectMenuSection = new Rect(rectCard.width * .625f, rectCard.height * .1f, rectCard.width * .3f, floMenuHeight); Rect rectOut = KrozzyUtilities.RectAddition(rectMenuSection, rectCard); // Draw the menu section GUI.DrawTexture(rectOut, ProTBin.texVellum, ScaleMode.ScaleAndCrop); GUI.color = cintBorder.ToColor; Widgets.DrawBox(rectOut, 1); GUI.color = Color.white; // set GUI color back to default // Shape item sheet float floViewWidth = rectMenuSection.width - 16f; // Scrollbar has 16f hard number float floColumnTexWidth = floViewWidth * .1f; float floColumnNameWidth = floViewWidth * .6f; float floColumnQuantityWidth = floViewWidth * .12f; float floColumnCostWidth = floViewWidth * .18f; Text.Font = GameFont.Small; // Make sure the font is default for size calculation float TotalHeight = 0f; // Create strings for headers string strItemNameHeader = "Item"; string strItemAmountHeader = "#"; string strItemPriceHeader = "Cost"; // Calculate header heights float floHeaderHeight = Text.CalcHeight(strItemNameHeader, floColumnNameWidth); // Shape the headers Rect rectItemNameHeader = new Rect(rectOut.x + floColumnTexWidth, rectOut.y, floColumnNameWidth, floHeaderHeight); Rect rectItemAmountHeader = new Rect(rectOut.x + floColumnTexWidth + floColumnNameWidth, rectOut.y, floColumnQuantityWidth, floHeaderHeight); Rect rectItemPriceHeader = new Rect(rectOut.x + floColumnTexWidth + floColumnNameWidth + floColumnQuantityWidth, rectOut.y, floColumnCostWidth, floHeaderHeight); // Draw the headers GUI.Label(rectItemNameHeader, strItemNameHeader, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Bold)); GUI.Label(rectItemAmountHeader, strItemAmountHeader, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Bold)); GUI.Label(rectItemPriceHeader, strItemPriceHeader, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Bold)); // Draw the buttons if (Widgets.ButtonInvisible(rectItemNameHeader)) { ES.SortItemsTool(ProEquipmentShop.ESSortList.StartingItems, ProEquipmentShop.ESSortType.DefName); } if (Widgets.ButtonInvisible(rectItemAmountHeader)) { ES.SortItemsTool(ProEquipmentShop.ESSortList.StartingItems, ProEquipmentShop.ESSortType.ThingAmount); } if (Widgets.ButtonInvisible(rectItemPriceHeader)) { ES.SortItemsTool(ProEquipmentShop.ESSortList.StartingItems, ProEquipmentShop.ESSortType.Price); } // Reshape the rectOut rectOut = new Rect(rectOut.x, rectOut.y + floHeaderHeight, rectOut.width, rectOut.height - floHeaderHeight); // Calculate total height of items foreach (ESItem item in esiStartingItems) { TotalHeight += Text.CalcHeight(item.strNameLabel, floColumnNameWidth); } // If the total height of items in more than the menu section height, make scroll view fit inside the menu // Else make the scroll view wide enough so the highlighted item is not clipped Rect rectView = new Rect(); if (TotalHeight > rectOut.height) { rectView = new Rect(rectOut.x, rectOut.y, floViewWidth, TotalHeight); } else { rectView = new Rect(rectOut.x, rectOut.y, rectOut.width, TotalHeight); } // Shape the group and shape the tooltip so that it does not scroll inside the scroll view Rect rectGroup = KrozzyUtilities.RectAddition(rectView, rectCard); Rect rectScrollingTooltip = KrozzyUtilities.RectAddition(rectOut, rectCard); // Begin scroll view and group Widgets.BeginScrollView(rectOut, ref v2FoodsScrollPosition2, KrozzyUtilities.RectAddition(rectView, rectCard)); GUI.BeginGroup(rectGroup); // Create list of items from array float floYPos = 0f; for (int i = 0; i < esiStartingItems.Length; i++) { // Build strings string strNameLabel = esiStartingItems[i].strNameLabel; string strQauntityLabel = esiStartingItems[i].thingAmountTotal.ToString(); string strCostLabel = String.Format("{0:0}", esiStartingItems[i].subtotal); string strDescToolTip = string.Concat(esiStartingItems[i].thingDef.description, " price: ", esiStartingItems[i].price.ToString(), ", itemAmount: ", esiStartingItems[i].itemAmount.ToString()); // Shape idividual item Rect rectWholeItem = new Rect(0f, floYPos, rectView.width, Text.CalcHeight(strNameLabel, floColumnNameWidth)); Rect rectMiniTex = new Rect(0f, floYPos, floColumnTexWidth, Text.CalcHeight(strNameLabel, floColumnNameWidth)); Rect rectNameLabel = new Rect(floColumnTexWidth, floYPos, floColumnNameWidth, Text.CalcHeight(strNameLabel, floColumnNameWidth)); Rect rectQauntityLabel = new Rect(floColumnTexWidth + floColumnNameWidth, floYPos, floColumnQuantityWidth, Text.CalcHeight(strNameLabel, floColumnNameWidth)); Rect rectCostLabel = new Rect(floColumnTexWidth + floColumnNameWidth + floColumnQuantityWidth, floYPos, floColumnCostWidth, Text.CalcHeight(strNameLabel, floColumnNameWidth)); // update y position for next label floYPos += Text.CalcHeight(strNameLabel, floColumnNameWidth); // Draw label based upon if it's currently selected if (i == intCurSelectedToUnequip) { // Using custom font if selected esiStartingItems[i].DrawIcon(rectMiniTex); GUI.Label(rectNameLabel, strNameLabel, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.Yellow)); GUI.Label(rectQauntityLabel, strQauntityLabel, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.Yellow)); GUI.Label(rectCostLabel, strCostLabel, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.Yellow)); // Prime variable for unequip button esItemCurSelectedToUnequip = esiStartingItems[i]; //intCurSelectedAmountToUnequip = esiStartingItems[i].amount; //intCurSelectedPriceToUnequip = ES.GetPrice(esiStartingItems[i]); } else { // Using default font if not selected esiStartingItems[i].DrawIcon(rectMiniTex); Widgets.Label(rectNameLabel, strNameLabel); Widgets.Label(rectQauntityLabel, strQauntityLabel); Widgets.Label(rectCostLabel, strCostLabel); } // Highlight is mouse is hovering over if (Mouse.IsOver(rectWholeItem)) { KrozzyUtilities.Tooltip(KrozzyUtilities.RectAddition(rectScrollingTooltip, Find.WindowStack.currentlyDrawnWindow.windowRect), strDescToolTip); Widgets.DrawHighlight(rectWholeItem); } // Draw invisible button for item selecting if (Widgets.ButtonInvisible(rectWholeItem, true)) { intCurSelectedToUnequip = i; } } // End group and scroll view GUI.EndGroup(); Widgets.EndScrollView(); Text.Font = GameFont.Small; // Ensure font size is back to default }
private void ItemSheet(Rect _rectOut, ESItem[] _aItems, GameFont _fontSize) { // Shape item sheet float floViewWidth = _rectOut.width - 16f; // Scrollbar has 16f hard number float floColumnTexWidth = floViewWidth * .1f; float floColumnNameWidth = floViewWidth * .6f; float floColumnQuantityWidth = floViewWidth * .12f; float floColumnCostWidth = floViewWidth * .18f; Text.Font = _fontSize; float TotalHeight = 0f; // Create strings for headers string strItemNameHeader = "Item"; string strItemAmountHeader = "#"; string strItemPriceHeader = "Cost"; // Calculate header heights float floHeaderHeight = Text.CalcHeight(strItemNameHeader, floColumnNameWidth); // Shape the headers Rect rectItemNameHeader = new Rect(_rectOut.x + floColumnTexWidth, _rectOut.y, floColumnNameWidth, floHeaderHeight); Rect rectItemAmountHeader = new Rect(_rectOut.x + floColumnTexWidth + floColumnNameWidth, _rectOut.y, floColumnQuantityWidth, floHeaderHeight); Rect rectItemPriceHeader = new Rect(_rectOut.x + floColumnTexWidth + floColumnNameWidth + floColumnQuantityWidth, _rectOut.y, floColumnCostWidth, floHeaderHeight); // Draw the headers GUI.Label(KrozzyUtilities.RectAddition(rectItemNameHeader, rectCard), strItemNameHeader, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Bold)); GUI.Label(KrozzyUtilities.RectAddition(rectItemAmountHeader, rectCard), strItemAmountHeader, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Bold)); GUI.Label(KrozzyUtilities.RectAddition(rectItemPriceHeader, rectCard), strItemPriceHeader, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Bold)); // Draw the buttons if (Widgets.ButtonInvisible(KrozzyUtilities.RectAddition(rectItemNameHeader, rectCard))) { ES.SortItemsTool(ProEquipmentShop.ESSortList.Items, ProEquipmentShop.ESSortType.DefName); } if (Widgets.ButtonInvisible(KrozzyUtilities.RectAddition(rectItemAmountHeader, rectCard))) { ES.SortItemsTool(ProEquipmentShop.ESSortList.Items, ProEquipmentShop.ESSortType.ThingAmount); } if (Widgets.ButtonInvisible(KrozzyUtilities.RectAddition(rectItemPriceHeader, rectCard))) { ES.SortItemsTool(ProEquipmentShop.ESSortList.Items, ProEquipmentShop.ESSortType.Price); } // Reshape the _rectOut _rectOut = new Rect(_rectOut.x, _rectOut.y + floHeaderHeight, _rectOut.width, _rectOut.height - floHeaderHeight); // Calculate total item list height foreach (ESItem item in _aItems) { TotalHeight += Text.CalcHeight(item.strNameLabel, floColumnNameWidth); } // Calculate rectView based on if the scroll bar will need to be shown Rect rectView = new Rect(); if (TotalHeight > _rectOut.height) { rectView = new Rect(_rectOut.x, _rectOut.y, floViewWidth, TotalHeight); } else { rectView = new Rect(_rectOut.x, _rectOut.y, _rectOut.width, TotalHeight); } // Calculate rects for GUI group and tooltip Rect rectGroup = KrozzyUtilities.RectAddition(rectView, rectCard); Rect rectScrollingTooltip = KrozzyUtilities.RectAddition(_rectOut, rectCard); // Begin scroll view and group Widgets.BeginScrollView(KrozzyUtilities.RectAddition(_rectOut, rectCard), ref v2FoodsScrollPosition1, KrozzyUtilities.RectAddition(rectView, rectCard)); GUI.BeginGroup(rectGroup); // Create list of items from array float floYPos = 0f; for (int i = 0; i < _aItems.Length; i++) { string strNameLabel = _aItems[i].strNameLabel; string strQauntityLabel = _aItems[i].thingAmount.ToString(); string strCostLabel = String.Format("{0:0}", ES.GetPrice(_aItems[i])); string strDescToolTip = _aItems[i].thingDef.description; // Shape idividual item Rect rectWholeItem = new Rect(0f, floYPos, rectView.width, Text.CalcHeight(strNameLabel, floColumnNameWidth)); Rect rectMiniTex = new Rect(0f, floYPos, floColumnTexWidth, Text.CalcHeight(strNameLabel, floColumnNameWidth)); Rect rectNameLabel = new Rect(floColumnTexWidth, floYPos, floColumnNameWidth, Text.CalcHeight(strNameLabel, floColumnNameWidth)); Rect rectQauntityLabel = new Rect(floColumnTexWidth + floColumnNameWidth, floYPos, floColumnQuantityWidth, Text.CalcHeight(strNameLabel, floColumnNameWidth)); Rect rectCostLabel = new Rect(floColumnTexWidth + floColumnNameWidth + floColumnQuantityWidth, floYPos, floColumnCostWidth, Text.CalcHeight(strNameLabel, floColumnNameWidth)); // update y position for next label floYPos += Text.CalcHeight(strNameLabel, floColumnNameWidth); // Draw label based upon if it's currently selected if (i == intCurSelectedToEquip) { GUI.Label(rectNameLabel, strNameLabel, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.Yellow)); GUI.Label(rectQauntityLabel, strQauntityLabel, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.Yellow)); GUI.Label(rectCostLabel, strCostLabel, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.Yellow)); _aItems[i].DrawIcon(rectMiniTex); // Prime variable for equip button esItemCurSelectedToEquip = _aItems[i]; } else { Widgets.Label(rectNameLabel, strNameLabel); Widgets.Label(rectQauntityLabel, strQauntityLabel); Widgets.Label(rectCostLabel, strCostLabel); _aItems[i].DrawIcon(rectMiniTex); } // Highlight is mouse is hovering over if (Mouse.IsOver(rectWholeItem)) { KrozzyUtilities.Tooltip(KrozzyUtilities.RectAddition(rectScrollingTooltip, Find.WindowStack.currentlyDrawnWindow.windowRect), strDescToolTip); Widgets.DrawHighlight(rectWholeItem); } // Draw invisible button for item selecting if (Widgets.ButtonInvisible(rectWholeItem, true)) { intCurSelectedToEquip = i; } } // End group and scroll view GUI.EndGroup(); Widgets.EndScrollView(); Text.Font = GameFont.Small; // Ensure font size is back to default }
public override void DoWindowContents(Rect inRect) { float x = 0f; float y = 0f; float w = 0f; float h = 0f; Text.Font = GameFont.Medium; w = Text.CalcSize(strName).x; h = Text.CalcSize(strName).y; Widgets.Label(new Rect(x, y, w, h), strName); y += h; Text.Font = GameFont.Small; string strPassionMinor = string.Concat(" = ", NewGameRules.GetPassionCost(pawn, Passion.Minor).ToString(), " Points"); string strPassionMajor = string.Concat(" = ", NewGameRules.GetPassionCost(pawn, Passion.Major).ToString(), " Points"); Vector2 vecPassionMinor = Text.CalcSize(strPassionMinor); Vector2 vecPassionMajor = Text.CalcSize(strPassionMajor); GUI.DrawTexture(new Rect(x, y, vecPassionMinor.y, vecPassionMinor.y), ProTBin.texPassionMinorIcon); Widgets.Label(new Rect(vecPassionMinor.y, y, vecPassionMinor.x, vecPassionMinor.y), strPassionMinor); y += vecPassionMinor.y; GUI.DrawTexture(new Rect(x, y, vecPassionMajor.y, vecPassionMajor.y), ProTBin.texPassionMajorIcon); Widgets.Label(new Rect(vecPassionMajor.y, y, vecPassionMajor.x, vecPassionMajor.y), strPassionMajor); y += vecPassionMajor.y; foreach (SkillRecord sk in aSKs) { w = Text.CalcSize(sk.def.skillLabel).x; h = Text.CalcSize(sk.def.skillLabel).y; //string strPointsLabel = "Points: "; //string strPoints = String.Format("{0:0}", NewGameRules.GetPassionCost(pawn, sk.passion)); Rect rectSkillLabel = new Rect(x, y, w, h); Rect rectDownButton = new Rect(floSkillsColumnRight, y, floAdjustButtonSize, floAdjustButtonSize); Rect rectSkillLevel = new Rect(rectDownButton.x + rectDownButton.width + floAdjustButtonSize, y, floAdjustButtonSize, floAdjustButtonSize); Rect rectUpButton = new Rect(rectSkillLevel.x + rectSkillLevel.width + floAdjustButtonSize, y, floAdjustButtonSize, floAdjustButtonSize); //Rect rectPointsLabel = new Rect(rectUpButton.x + rectUpButton.width + floAdjustButtonSize, y, Text.CalcSize(strPointsLabel).x, floAdjustButtonSize); //Rect rectPoints = new Rect(rectPointsLabel.x + rectPointsLabel.width, y, Text.CalcSize("0000").x, floAdjustButtonSize); GUI.Label(rectSkillLabel, sk.def.skillLabel, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Normal, TextAnchor.MiddleLeft)); if (sk.TotallyDisabled != true) { if (GUI.Button(rectDownButton, "-", "button")) { if (sk.passion > Passion.None && sk.TotallyDisabled != true) { sk.passion--; } } if (sk.passion == Passion.Minor) { GUI.DrawTexture(rectSkillLevel, ProTBin.texPassionMinorIcon); } else if (sk.passion == Passion.Major) { GUI.DrawTexture(rectSkillLevel, ProTBin.texPassionMajorIcon); } if (GUI.Button(rectUpButton, "+", "button")) { if (sk.passion < Passion.Major && sk.TotallyDisabled != true) { sk.passion++; } } //GUI.Label(rectPointsLabel, strPointsLabel, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Normal, TextAnchor.MiddleLeft)); //GUI.Label(rectPoints, strPoints, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Normal, TextAnchor.MiddleRight)); } y += h; } }
public override void DoWindowContents(Rect inRect) { float x = 0f; float y = 0f; float w = 0f; float h = 0f; Text.Font = GameFont.Medium; w = Text.CalcSize(strName).x; h = Text.CalcSize(strName).y; Widgets.Label(new Rect(x, y, w, h), strName); y += h; Text.Font = GameFont.Small; foreach (SkillRecord sk in aSKs) { int intSkillLevelOffset = 0; foreach (Backstory bs in pawn.story.AllBackstories) { foreach (KeyValuePair <SkillDef, int> kvp in bs.skillGainsResolved) { if (sk.def == kvp.Key && kvp.Value != 0) { intSkillLevelOffset += kvp.Value; } } } w = Text.CalcSize(sk.def.skillLabel).x; h = Text.CalcSize(sk.def.skillLabel).y; string strPointsLabel = "Points: "; string strPoints = String.Format("{0:0}", NewGameRules.GetSkillCost(pawn.ageTracker.AgeBiologicalYears, sk.Level - intSkillLevelOffset)); Rect rectSkillLabel = new Rect(x, y, w, h); Rect rectDownButton = new Rect(floSkillsColumnRight, y, floAdjustButtonSize, floAdjustButtonSize); Rect rectSkillLevel = new Rect(rectDownButton.x + rectDownButton.width + floAdjustButtonSize, y, floAdjustButtonSize, floAdjustButtonSize); Rect rectUpButton = new Rect(rectSkillLevel.x + rectSkillLevel.width + floAdjustButtonSize, y, floAdjustButtonSize, floAdjustButtonSize); Rect rectPointsLabel = new Rect(rectUpButton.x + rectUpButton.width + floAdjustButtonSize, y, Text.CalcSize(strPointsLabel).x, floAdjustButtonSize); Rect rectPoints = new Rect(rectPointsLabel.x + rectPointsLabel.width, y, Text.CalcSize("0000").x, floAdjustButtonSize); GUI.Label(rectSkillLabel, sk.def.skillLabel, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Normal, TextAnchor.MiddleLeft)); if (sk.TotallyDisabled != true) { if (GUI.Button(rectDownButton, "-", "button")) { if (sk.Level - intSkillLevelOffset > 0 && sk.TotallyDisabled != true) { sk.Level--; sk.xpSinceLastLevel = 0f; } } GUI.Label(rectSkillLevel, (sk.Level - intSkillLevelOffset).ToString(), KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Normal, TextAnchor.MiddleCenter)); if (GUI.Button(rectUpButton, "+", "button")) { if (sk.Level - intSkillLevelOffset < 20 && sk.TotallyDisabled != true) { sk.Level++; sk.xpSinceLastLevel = 0f; } } GUI.Label(rectPointsLabel, strPointsLabel, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Normal, TextAnchor.MiddleLeft)); GUI.Label(rectPoints, strPoints, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Normal, TextAnchor.MiddleRight)); } y += h; } }