public void DoCustomStats(Rect _rectCard, Pawn _pawn) { rectCard = _rectCard; floPaddingX = rectCard.width * .025f; floPaddingY = rectCard.height * .05f; Rect rectGroup = new Rect(floPaddingX, rectCard.height * .8f, rectCard.width - (floPaddingX * 2f), rectCard.height * .15f); rectGroup = KrozzyUtilities.RectAddition(rectGroup, rectCard); Widgets.DrawBoxSolid(rectGroup, cBackdrop); GUI.BeginGroup(rectGroup); floPaddingX = rectGroup.width * .025f; floPaddingY = rectGroup.height * .2f; floButtonWidth = (rectGroup.width - (floPaddingX * (float)(2 + (floNumOfButtons - 1)))) / floNumOfButtons; floButtonHeight = rectGroup.height - (floPaddingY * 2f); Rect rectAge = new Rect(floPaddingX, floPaddingY, floButtonWidth, floButtonHeight); Rect rectBackstory = new Rect(rectAge.x + rectAge.width + floPaddingX, floPaddingY, floButtonWidth, floButtonHeight); Rect rectInterests = new Rect(rectBackstory.x + rectBackstory.width + floPaddingX, floPaddingY, floButtonWidth, floButtonHeight); Rect rectSkills = new Rect(rectInterests.x + rectInterests.width + floPaddingX, floPaddingY, floButtonWidth, floButtonHeight); Rect rectTraits = new Rect(rectSkills.x + rectSkills.width + floPaddingX, floPaddingY, floButtonWidth, floButtonHeight); EditAge(rectAge, _pawn); EditBackstory(rectBackstory, _pawn); EditPassions(rectInterests, _pawn); EditSkills(rectSkills, _pawn); EditTraits(rectTraits, _pawn); GUI.EndGroup(); }
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 DoMainDesc() { string strMainDesc = pawn.MainDesc(true); Rect rect = new Rect(rectCard.width * .025f, rectCard.height * .05f, Text.CalcSize(strMainDesc).x, Text.CalcSize(strMainDesc).y); Widgets.Label(KrozzyUtilities.RectAddition(rect, rectCard), strMainDesc); TooltipHandler.TipRegion(KrozzyUtilities.RectAddition(rect, rectCard), () => pawn.ageTracker.AgeTooltipString, 6873641); }
private void DoEquipButton() { // Shape the button Rect rectEqiupButton = new Rect(rectCard.width * .4f, rectCard.height * .1f, rectCard.width * .2f, rectCard.height * .1f); // Draw the button if (Widgets.ButtonText(KrozzyUtilities.RectAddition(rectEqiupButton, rectCard), "Equip", true, true, true)) { // Method to add the item to the starting items list ES.EquipESItem(esItemCurSelectedToEquip); if (esItemCurSelectedToUnequip == null) { esItemCurSelectedToUnequip = ESStartingItems.aStartingItems[intCurSelectedToUnequip]; } } }
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 DoNameInput() { NameTriple nameTriple = pawn.Name as NameTriple; string first = nameTriple.First; string nick = nameTriple.Nick; string last = nameTriple.Last; Rect rect = new Rect(rectCard.x + (rectCard.width * .85f), rectCard.y + (rectCard.height * .26f), PawnPortraitSize.x, PawnPortraitSize.y * .2f); Rect rectOffset = new Rect(0f, PawnPortraitSize.y * .22f, 0f, 0f); string strFirst = Widgets.TextField(rect, first); if (strFirst.Length <= 12 && validNameRegex.IsMatch(strFirst)) { first = strFirst; } string strNick = Widgets.TextField(KrozzyUtilities.RectAddition(rect, rectOffset), nick); if (strNick.Length <= 9 && validNameRegex.IsMatch(strNick)) { nick = strNick; } string strLast = Widgets.TextField(KrozzyUtilities.RectAddition(KrozzyUtilities.RectAddition(rect, rectOffset), rectOffset), last); if (strLast.Length <= 12 && validNameRegex.IsMatch(strLast)) { last = strLast; } if (nameTriple.First != first || nameTriple.Nick != nick || nameTriple.Last != last) { pawn.Name = new NameTriple(first, nick, last); } TooltipHandler.TipRegion(rect, "FirstNameDesc".Translate()); TooltipHandler.TipRegion(KrozzyUtilities.RectAddition(rect, rectOffset), "ShortIdentifierDesc".Translate()); TooltipHandler.TipRegion(KrozzyUtilities.RectAddition(KrozzyUtilities.RectAddition(rect, rectOffset), rectOffset), "LastNameDesc".Translate()); }
private void DoTotalCostLabel() { if (eCardType == ePNC_Card_Type.Pawn) { // Calculate variables Text.Font = GameFont.Medium; float floTotalPrice = PCS.GetTotalCost(pawn); string strTotalPrice = String.Concat("Cost: ", String.Format("{0:0}", floTotalPrice)); Vector2 vecSize = Text.CalcSize(strTotalPrice); float floPosX = (rectCard.width - vecSize.x) - (rectCard.width * .05f); // Shape the label Rect rectTotalCostLabel = new Rect(floPosX, rectCard.height * 0f, vecSize.x, vecSize.y); // Draw the label Widgets.Label(KrozzyUtilities.RectAddition(rectTotalCostLabel, rectCard), strTotalPrice); Text.Font = GameFont.Small; NewGameRules.UpdateCurPawnPoints(pawn, floTotalPrice); } else if (eCardType == ePNC_Card_Type.Items) { // Calculate variables Text.Font = GameFont.Medium; string strTotalPrice = String.Concat("Cost: ", String.Format("{0:0}", ES.floTotalItemsPrice)); Vector2 vecSize = Text.CalcSize(strTotalPrice); float floPosX = (rectCard.width - vecSize.x) - (rectCard.width * .05f); // Shape the label Rect rectTotalCostLabel = new Rect(floPosX, rectCard.height * 0f, vecSize.x, vecSize.y); // Draw the label Widgets.Label(KrozzyUtilities.RectAddition(rectTotalCostLabel, rectCard), strTotalPrice); Text.Font = GameFont.Small; NewGameRules.floCurItemPoints = NewGameRules.floStartingItemPoints - ES.floTotalItemsPrice; } }
private void DoUnequipButton() { ESItem[] esiStartingItems = ESStartingItems.aStartingItems; // Shape the button Rect rectEqiupButton = new Rect(rectCard.width * .4f, rectCard.height * .3f, rectCard.width * .2f, rectCard.height * .1f); if (esiStartingItems.Any(x => x.strNameLabel == esItemCurSelectedToUnequip.strNameLabel)) { // Draw the button if (Widgets.ButtonText(KrozzyUtilities.RectAddition(rectEqiupButton, rectCard), "Unequip", true, true, true)) { // Method to remove the item to the starting items list ES.UnequipESItem(ref esItemCurSelectedToUnequip); } } else { // Draw the button Widgets.ButtonText(KrozzyUtilities.RectAddition(rectEqiupButton, rectCard), "Unequip", true, false, false); } }
private void DoTraits() { // Shape Traits area float floSkillsX = rectCard.width * .85f; float floSkillsY = rectCard.height * .5f; float floSkillsWidth = rectCard.width * .125f; float floSkillsHeight = rectCard.height * .25f; float floTextHeight = floSkillsHeight / 4f; float floAdjustY = 0f; Text.Font = GameFont.Medium; Rect rectTraits = new Rect(floSkillsX, floSkillsY, Text.CalcSize("Traits").x, floTextHeight); Widgets.Label(KrozzyUtilities.RectAddition(rectTraits, rectCard), "Traits".Translate()); Text.Font = GameFont.Small; floAdjustY += floTextHeight; Text.Anchor = TextAnchor.MiddleLeft; for (int i = 0; i < pawn.story.traits.allTraits.Count; i++) { Trait trait = pawn.story.traits.allTraits[i]; Rect rectTrait = new Rect(floSkillsX, floSkillsY + floAdjustY, Text.CalcSize(trait.LabelCap).x, floTextHeight); if (Mouse.IsOver(KrozzyUtilities.RectAddition(rectTrait, rectCard))) { Widgets.DrawHighlight(KrozzyUtilities.RectAddition(rectTrait, rectCard)); } Widgets.Label(KrozzyUtilities.RectAddition(rectTrait, rectCard), trait.LabelCap); Trait trLocal = trait; TipSignal tip = new TipSignal(() => trLocal.TipString(pawn), (int)floAdjustY * 17); TooltipHandler.TipRegion(KrozzyUtilities.RectAddition(rectTrait, rectCard), tip); floAdjustY += floTextHeight; } Text.Anchor = TextAnchor.UpperLeft; }
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 }
private void DoTabs() { // Calculate variables float floMenuHeight = rectCard.height * .8f; float floYAdjust = floMenuHeight * .1f; // Do unfocused tabs for (int x = 5; x > -1; x--) { if (aboolCurTab[x] == false) { // Shape the tab Rect rectTabUnfocused = new Rect(rectCard.width * .025f + 1f, (rectCard.height * .1f) + (floMenuHeight * .1f) + (floYAdjust * (float)x), rectCard.width * .05f, rectCard.width * .075f); // Draw the tab Widgets.DrawTextureFitted(KrozzyUtilities.RectAddition(rectTabUnfocused, rectCard), atexTabs[x], 1f); // Shape the tab button Rect rectTabUnfocusedButton = new Rect(rectTabUnfocused.x, rectTabUnfocused.y + (rectTabUnfocused.height * .34f), rectTabUnfocused.width, rectTabUnfocused.height - (rectTabUnfocused.height * .34f)); // Draw the tab button if (Widgets.ButtonInvisible(KrozzyUtilities.RectAddition(rectTabUnfocusedButton, rectCard), true)) { for (int i = 0; i < 6; i++) { aboolCurTab[i] = false; } aboolCurTab[x] = true; } // Do tooltip if (Mouse.IsOver(KrozzyUtilities.RectAddition(rectTabUnfocusedButton, rectCard))) { KrozzyUtilities.Tooltip(Find.WindowStack.currentlyDrawnWindow.windowRect, astrTabTooltip[x]); } } } // Shape the menu section Rect rectMenuSection = new Rect(rectCard.width * .075f, rectCard.height * .1f, rectCard.width * .3f, floMenuHeight); // Draw the menu section GUI.DrawTexture(KrozzyUtilities.RectAddition(rectMenuSection, rectCard), ProTBin.texVellum, ScaleMode.ScaleAndCrop); GUI.color = cintBorder.ToColor; Widgets.DrawBox(KrozzyUtilities.RectAddition(rectMenuSection, rectCard), 1); GUI.color = Color.white; // Do focused tab for (int x = 0; x < 6; x++) { if (aboolCurTab[x] == true) { // Shape the tab Rect rectTabFocused = new Rect(rectCard.width * .025f + 1f, (rectCard.height * .1f) + (floMenuHeight * .1f) + (floYAdjust * (float)x), rectCard.width * .05f, rectCard.width * .075f); // Draw the tab Widgets.DrawTextureFitted(KrozzyUtilities.RectAddition(rectTabFocused, rectCard), atexTabs[x], 1f); // Shape the tab button Rect rectTabfocusedButton = new Rect(rectTabFocused.x, rectTabFocused.y + (rectTabFocused.height * .34f), rectTabFocused.width, rectTabFocused.height - (rectTabFocused.height * .34f)); // Do tooltip if (Mouse.IsOver(KrozzyUtilities.RectAddition(rectTabfocusedButton, rectCard))) { KrozzyUtilities.Tooltip(Find.WindowStack.currentlyDrawnWindow.windowRect, astrTabTooltip[x]); } // Do the sheet switch (astrTabTooltip[x]) { case "Foods": ItemSheet(rectMenuSection, ES.Foods.aFoods, GameFont.Small); break; case "Apparel": ItemSheet(rectMenuSection, ES.Apparel.aApparel, GameFont.Small); break; case "Weapons": ItemSheet(rectMenuSection, ES.Weapons.aWeapons, GameFont.Small); break; case "Drugs": ItemSheet(rectMenuSection, ES.Drugs.aDrugs, GameFont.Small); break; case "Resources": ItemSheet(rectMenuSection, ES.Resources.aResources, GameFont.Small); break; case "Items": ItemSheet(rectMenuSection, ES.Items.aItems, GameFont.Small); break; } } } }
private void DoSkills() { // Shape Skills area float floSkillsX = rectCard.width * .575f; float floSkillsY = rectCard.height * .09f; float floSkillsWidth = rectCard.width * .25f; float floSkillsHeight = rectCard.height * .65f; float floTextHeight = floSkillsHeight / 13f; float floAdjustY = 0f; // Shape and draw skills label Text.Font = GameFont.Medium; string strSkillsLabel = "Skills".Translate(); Rect rectSkillsLabel = new Rect(floSkillsX, floSkillsY, Text.CalcSize(strSkillsLabel).x, floTextHeight); floAdjustY = floTextHeight + (rectCard.height * .01f); Widgets.Label(KrozzyUtilities.RectAddition(rectSkillsLabel, rectCard), strSkillsLabel); Text.Font = GameFont.Small; // Prepare and shape skill list float floMaxSkillWidth = 0f; float floSkillLevelBarX = 0f; List <SkillDef> allDefsListForReading = DefDatabase <SkillDef> .AllDefsListForReading; for (int i = 0; i < allDefsListForReading.Count; i++) { float x = Text.CalcSize(allDefsListForReading[i].skillLabel).x; if (x > floMaxSkillWidth) { floMaxSkillWidth = x; } } floSkillLevelBarX = floMaxSkillWidth; // Shape and draw skills Text.Anchor = TextAnchor.MiddleLeft; for (int j = 0; j < pawn.skills.skills.Count; j++) { string strSkillLabel = pawn.skills.skills[j].def.skillLabel; Rect rectSkillLabel = new Rect(floSkillsX, floSkillsY + floAdjustY, Text.CalcSize(strSkillLabel).x, floTextHeight); Widgets.Label(KrozzyUtilities.RectAddition(rectSkillLabel, rectCard), strSkillLabel); // Shape and draw Passion Icon if (pawn.skills.skills[j].passion > Passion.None) { Rect rectPassion = new Rect(floSkillsX + floSkillLevelBarX, floSkillsY + floAdjustY, floTextHeight, floTextHeight); Texture2D texPassion = (pawn.skills.skills[j].passion != Passion.Major) ? ProTBin.texPassionMinorIcon : ProTBin.texPassionMajorIcon; GUI.DrawTexture(KrozzyUtilities.RectAddition(rectPassion, rectCard), texPassion); } // Shape and draw skill bar if (!pawn.skills.skills[j].TotallyDisabled) { Rect rectSkillBar = new Rect(floSkillsX + floSkillLevelBarX + floTextHeight, floSkillsY + floAdjustY, floSkillsWidth - floSkillLevelBarX, floTextHeight); float fillPercent = Mathf.Max(0.01f, (float)pawn.skills.skills[j].Level / 20f); if (pawn.skills.skills[j].passion == Passion.None) { Widgets.FillableBar(KrozzyUtilities.RectAddition(rectSkillBar, rectCard), fillPercent, ProTBin.texSkillBarFill, null, false); } if (pawn.skills.skills[j].passion > Passion.None) { Texture2D texPassionOverlay = (pawn.skills.skills[j].passion != Passion.Major) ? ProTBin.texSkillBarFillMinorPassion : ProTBin.texSkillBarFillMajorPassion; Widgets.FillableBar(KrozzyUtilities.RectAddition(rectSkillBar, rectCard), fillPercent, texPassionOverlay, null, false); } int intSkillLevelOffset = 0; foreach (Backstory bs in pawn.story.AllBackstories) { foreach (KeyValuePair <SkillDef, int> kvp in bs.skillGainsResolved) { if (pawn.skills.skills[j].def == kvp.Key && kvp.Value != 0) { intSkillLevelOffset += kvp.Value; } } } string strSkillLevelOffset = ""; if (intSkillLevelOffset != 0) { if (intSkillLevelOffset > 0) { strSkillLevelOffset = string.Format("+{0}", intSkillLevelOffset.ToString()); } else { strSkillLevelOffset = intSkillLevelOffset.ToString(); } } string strLevel = string.Format("{0} {1}", (pawn.skills.skills[j].Level - intSkillLevelOffset).ToString(), strSkillLevelOffset); Widgets.Label(KrozzyUtilities.RectAddition(rectSkillBar, rectCard), strLevel); } floAdjustY += floTextHeight; } Text.Anchor = TextAnchor.UpperLeft; }
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; } }
private void DoBackstories() { // Shape backtories area float floBSwidth = rectCard.width * .525f; float floBSheight = rectCard.height * .59f; // Shape and draw backstory Label Text.Font = GameFont.Medium; string strBSLabel = "Backstory".Translate(); Rect rect = new Rect(rectCard.width * .025f, rectCard.height * .09f, Text.CalcSize(strBSLabel).x, Text.CalcSize(strBSLabel).y); Widgets.Label(KrozzyUtilities.RectAddition(rect, rectCard), strBSLabel); Text.Font = GameFont.Small; // Get texts and text sizes for scroll view string strBSChildhood = "Childhood".Translate() + ": "; Vector2 v2BSChildhood = Text.CalcSize(strBSChildhood); string strBSChildhoodTitle = pawn.story.GetBackstory(BackstorySlot.Childhood).Title; Vector2 v2BSChildhoodTitle = Text.CalcSize(strBSChildhoodTitle); string strBSChildhoodDesc = pawn.story.GetBackstory(BackstorySlot.Childhood).FullDescriptionFor(pawn); float floBSChildhoodDesc = Text.CalcHeight(strBSChildhoodDesc, floBSwidth - 16f); // Scrollbar has 16f hard number string strBSAdulthood = ""; Vector2 v2BSAdulthood = new Vector2(); string strBSAdulthoodTitle = ""; Vector2 v2BSAdulthoodTitle = new Vector2(); string strBSAdulthoodDesc = ""; float floBSAdulthoodDesc = 0f; if (pawn.story.GetBackstory(BackstorySlot.Adulthood) != null) { strBSAdulthood = "Adulthood".Translate() + ": "; v2BSAdulthood = Text.CalcSize(strBSAdulthood); strBSAdulthoodTitle = pawn.story.GetBackstory(BackstorySlot.Adulthood).Title; v2BSAdulthoodTitle = Text.CalcSize(strBSAdulthoodTitle); strBSAdulthoodDesc = pawn.story.GetBackstory(BackstorySlot.Adulthood).FullDescriptionFor(pawn); floBSAdulthoodDesc = Text.CalcHeight(strBSAdulthoodDesc, floBSwidth - 16f); // Scrollbar has 16f hard number } // Shape and draw scroll view Rect rectOut = new Rect(rectCard.width * .025f, rectCard.height * .155f, floBSwidth, floBSheight); Rect rectView = new Rect(0f, 0f, rectOut.width - 16f, v2BSChildhood.y + v2BSChildhoodTitle.y + floBSChildhoodDesc + v2BSAdulthood.y + v2BSAdulthoodTitle.y + floBSAdulthoodDesc); GUI.DrawTexture(KrozzyUtilities.RectAddition(rectOut, rectCard), SolidColorMaterials.NewSolidColorTexture(new Color(.125f, .125f, .125f, .5f))); Widgets.BeginScrollView(KrozzyUtilities.RectAddition(rectOut, rectCard), ref v2BackgroundsScrollPosition, rectView); // Shape and draw childhood label Rect rect1 = new Rect(0f, 0f, v2BSChildhood.x, v2BSChildhood.y); Widgets.Label(rect1, strBSChildhood); // Shape and draw childhood title Rect rect2 = new Rect(rect1.width, 0f, v2BSChildhoodTitle.x, v2BSChildhoodTitle.y); Widgets.Label(rect2, strBSChildhoodTitle); // Shape and draw childhood description Rect rect3 = new Rect(0f, rect1.height, floBSwidth - 16f, floBSChildhoodDesc); Widgets.Label(rect3, strBSChildhoodDesc); if (pawn.story.GetBackstory(BackstorySlot.Adulthood) != null) { // Shape and draw adult label Rect rect4 = new Rect(0f, rect3.y + rect3.height + (rectCard.height * .05f), v2BSAdulthood.x, v2BSAdulthood.y); Widgets.Label(rect4, strBSAdulthood); // Shape and draw adult title Rect rect5 = new Rect(rect4.width, rect3.y + rect3.height + (rectCard.height * .05f), v2BSAdulthoodTitle.x, v2BSAdulthoodTitle.y); Widgets.Label(rect5, strBSAdulthoodTitle); // Shape and draw adult description Rect rect6 = new Rect(0f, rect4.y + rect4.height, floBSwidth - 16f, floBSAdulthoodDesc); Widgets.Label(rect6, strBSAdulthoodDesc); } Widgets.EndScrollView(); }
private void DoCards(List <PNC_Card> _lstCards, Rect mainRect) { if (boolSwitchingIn == false && boolSwitchingOut == false) { int intCurCard = 1; Rect rect = rectCard; float floCardY = 0f; // Draw Cards foreach (PNC_Card card in _lstCards) { Rect rectYadjusted = new Rect(rect.x, rect.y + floCardY, rect.width, rect.height); // Draw card tops only for cards not at the top of the stack if (intCurCard != _lstCards.Count) { card.DrawCardTopOnly(KrozzyUtilities.RectAddition(rectYadjusted, rectCardLabelAdjust)); // Draw invisible button at top of cards, except top of the stack if (Widgets.ButtonInvisible(KrozzyUtilities.RectAddition(rectButtonInvisibleAdjust, rectYadjusted, true, true), true)) { SwitchCardOut(intCurCard); break; } } else // Draw card that is visible when cards are not being switched. { card.DrawCard(KrozzyUtilities.RectAddition(rectYadjusted, rectCardLabelAdjust)); } intCurCard += 1; floCardY = floCardY + (mainRect.height * .05f); } } else { if (boolSwitchingOut == true) { Rect rect = rectCard; float floCardY = 0f; // Shape switching cards X float floCardXMax = mainRect.x + mainRect.width; float floCardXAdjust = floCardXMax - rect.x; float floOutX = rect.x + (((float)intCurSwitchAnimStep / (float)intSwitchAnimSteps) * floCardXAdjust); // Shape not switching cards Y float floCardYMax2 = (mainRect.height * .05f) * templstPNC_CardsInOrder.Count; float floCardYAdjust2 = floCardYMax2 + rect.y; float floOutY2 = ((float)intCurSwitchAnimStep / (float)intSwitchAnimSteps) * floCardYAdjust2; // Shape switching cards Y float floCardYMax = -((mainRect.height * .05f) * lstPNC_CardsInOrder.Count); float floCardYAdjust = floCardYMax + rect.y; float floOutY = ((float)intCurSwitchAnimStep / (float)intSwitchAnimSteps) * floCardYAdjust; // Draw not switching cards foreach (PNC_Card notSwitchCard in lstPNC_CardsInOrder) { Rect rectYadjusted = new Rect(rect.x, floOutY2 + floCardY, rect.width, rect.height); notSwitchCard.DrawCard(KrozzyUtilities.RectAddition(rectYadjusted, rectCardLabelAdjust)); floCardY = floCardY + (mainRect.height * .05f); } // Draw switching cards foreach (PNC_Card SwitchCard in templstPNC_CardsInOrder) { Rect rectYadjusted = new Rect(floOutX, floOutY + floCardY, rect.width, rect.height); SwitchCard.DrawCard(KrozzyUtilities.RectAddition(rectYadjusted, rectCardLabelAdjust)); floCardY = floCardY + (mainRect.height * .05f); } if (intCurSwitchAnimStep >= intSwitchAnimSteps) { boolSwitchingIn = true; boolSwitchingOut = false; } else { intCurSwitchAnimStep++; } } else if (boolSwitchingIn == true) { Rect rect = rectCard; float floCardY = (mainRect.height * .05f) * templstPNC_CardsInOrder.Count; // Shape switching cards X float floCardXMax = mainRect.x + mainRect.width; float floCardXAdjust = floCardXMax - rect.x; float floOutX = rect.x + (((float)intCurSwitchAnimStep / (float)intSwitchAnimSteps) * floCardXAdjust); // Shape switching cards Y float floOutY = 0f; // Draw switching cards foreach (PNC_Card SwitchCard in templstPNC_CardsInOrder) { Rect rectYadjusted = new Rect(floOutX, rect.y + floOutY, rect.width, rect.height); SwitchCard.DrawCard(KrozzyUtilities.RectAddition(rectYadjusted, rectCardLabelAdjust)); floOutY = floOutY + (mainRect.height * .05f); } // Draw not switching cards foreach (PNC_Card notSwitchCard in lstPNC_CardsInOrder) { Rect rectYadjusted = new Rect(rect.x, rect.y + floCardY, rect.width, rect.height); notSwitchCard.DrawCard(KrozzyUtilities.RectAddition(rectYadjusted, rectCardLabelAdjust)); floCardY = floCardY + (mainRect.height * .05f); } if (intCurSwitchAnimStep <= 1) { boolSwitchingOut = false; boolSwitchingIn = false; SwitchCardIn(); } else { intCurSwitchAnimStep--; } } else { Log.Message("Error in ProPNC.DoCards, if boolSwitchingIn or Out triggered true but neither handled as true"); } } }