Skip to content

Commit

Permalink
Add RMB menu for inventory items
Browse files Browse the repository at this point in the history
  • Loading branch information
flyfire2002 committed Aug 8, 2024
1 parent 92d221e commit 0694b47
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 75 deletions.
157 changes: 82 additions & 75 deletions Source/1.5/GearTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -504,50 +504,50 @@ private void DrawThingRow1(Rect rect, Thing thing, bool inventory = false)
QualityCategory c;
if (thing.TryGetQuality(out c))
{
switch(c)
switch (c)
{
case QualityCategory.Legendary:
{
GUI.DrawTexture(rect, ContentFinder<Texture2D>.Get("UI/Frames/RPG_Legendary", true));
break;
}
case QualityCategory.Masterwork:
{
GUI.DrawTexture(rect, ContentFinder<Texture2D>.Get("UI/Frames/RPG_Masterwork", true));
break;
}
case QualityCategory.Excellent:
{
GUI.DrawTexture(rect, ContentFinder<Texture2D>.Get("UI/Frames/RPG_Excellent", true));
break;
}
case QualityCategory.Good:
{
GUI.DrawTexture(rect, ContentFinder<Texture2D>.Get("UI/Frames/RPG_Good", true));
break;
}
case QualityCategory.Normal:
{
GUI.DrawTexture(rect, ContentFinder<Texture2D>.Get("UI/Frames/RPG_Normal", true));
break;
}
case QualityCategory.Poor:
{
GUI.DrawTexture(rect, ContentFinder<Texture2D>.Get("UI/Frames/RPG_Poor", true));
break;
}
case QualityCategory.Awful:
{
GUI.DrawTexture(rect, ContentFinder<Texture2D>.Get("UI/Frames/RPG_Awful", true));
break;
}
case QualityCategory.Legendary:
{
GUI.DrawTexture(rect, ContentFinder<Texture2D>.Get("UI/Frames/RPG_Legendary", true));
break;
}
case QualityCategory.Masterwork:
{
GUI.DrawTexture(rect, ContentFinder<Texture2D>.Get("UI/Frames/RPG_Masterwork", true));
break;
}
case QualityCategory.Excellent:
{
GUI.DrawTexture(rect, ContentFinder<Texture2D>.Get("UI/Frames/RPG_Excellent", true));
break;
}
case QualityCategory.Good:
{
GUI.DrawTexture(rect, ContentFinder<Texture2D>.Get("UI/Frames/RPG_Good", true));
break;
}
case QualityCategory.Normal:
{
GUI.DrawTexture(rect, ContentFinder<Texture2D>.Get("UI/Frames/RPG_Normal", true));
break;
}
case QualityCategory.Poor:
{
GUI.DrawTexture(rect, ContentFinder<Texture2D>.Get("UI/Frames/RPG_Poor", true));
break;
}
case QualityCategory.Awful:
{
GUI.DrawTexture(rect, ContentFinder<Texture2D>.Get("UI/Frames/RPG_Awful", true));
break;
}
}
}
float mass = thing.GetStatValue(StatDefOf.Mass, true) * (float)thing.stackCount;
string smass = mass.ToString("G") + " kg";
string text = thing.LabelCap;
Rect rect5 = rect.ContractedBy(2f);
float num2 = rect5.height * ((float) thing.HitPoints / (float) thing.MaxHitPoints);
float num2 = rect5.height * ((float)thing.HitPoints / (float)thing.MaxHitPoints);
rect5.yMin = rect5.yMax - num2;
rect5.height = num2;
Texture2D durationColor = ContentFinder<Texture2D>.Get("UI/Icons/Sandy_Not_Tattered");
Expand All @@ -571,32 +571,32 @@ private void DrawThingRow1(Rect rect, Thing thing, bool inventory = false)
if (CanControl && (inventory || CanControlColonist || (SelPawnForGear.Spawned && !SelPawnForGear.Map.IsPlayerHome)))
{
Rect rect2 = new Rect(rect.xMax - SmallIconSize, rect.y, SmallIconSize, SmallIconSize);
bool flag2 = this.SelPawnForGear.IsQuestLodger() && !(thing is Apparel);
Apparel apparel;
bool flag3 = (apparel = (thing as Apparel)) != null && this.SelPawnForGear.apparel != null && this.SelPawnForGear.apparel.IsLocked(apparel);
flag = (flag2 || flag3);
if (Mouse.IsOver(rect2))
{
if (flag3)
{
TooltipHandler.TipRegion(rect2, "DropThingLocked".Translate());
}
else if (flag2)
{
TooltipHandler.TipRegion(rect2, "DropThingLodger".Translate());
}
else
{
TooltipHandler.TipRegion(rect2, "DropThing".Translate());
}
}
Color color = flag ? Color.grey : Color.white;
Color mouseoverColor = flag ? color : GenUI.MouseoverColor;
if (Widgets.ButtonImage(rect2, ContentFinder<Texture2D>.Get("UI/Buttons/Drop", true), color, mouseoverColor, !flag) && !flag)
{
SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
this.InterfaceDrop(thing);
}
bool flag2 = this.SelPawnForGear.IsQuestLodger() && !(thing is Apparel);
Apparel apparel;
bool flag3 = (apparel = (thing as Apparel)) != null && this.SelPawnForGear.apparel != null && this.SelPawnForGear.apparel.IsLocked(apparel);
flag = (flag2 || flag3);
if (Mouse.IsOver(rect2))
{
if (flag3)
{
TooltipHandler.TipRegion(rect2, "DropThingLocked".Translate());
}
else if (flag2)
{
TooltipHandler.TipRegion(rect2, "DropThingLodger".Translate());
}
else
{
TooltipHandler.TipRegion(rect2, "DropThing".Translate());
}
}
Color color = flag ? Color.grey : Color.white;
Color mouseoverColor = flag ? color : GenUI.MouseoverColor;
if (Widgets.ButtonImage(rect2, ContentFinder<Texture2D>.Get("UI/Buttons/Drop", true), color, mouseoverColor, !flag) && !flag)
{
SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
this.InterfaceDrop(thing);
}
}
}

Expand Down Expand Up @@ -631,17 +631,21 @@ private void DrawThingRow1(Rect rect, Thing thing, bool inventory = false)
text2 = $"{text3}\n{thing.HitPoints} / {thing.MaxHitPoints}";
}
TooltipHandler.TipRegion(rect, text2);



DrawRMBMenu(rect, thing);
}

private void DrawRMBMenu(Rect rect, Thing thing)
{
// RMB menu
if (Widgets.ButtonInvisible(rect) && Event.current.button == 1)
{
List<FloatMenuOption> floatOptionList = new List<FloatMenuOption>
{
new FloatMenuOption("ThingInfo".Translate(), delegate
{
Find.WindowStack.Add(new Dialog_InfoCard(thing));
}, MenuOptionPriority.Default, null, null)
List<FloatMenuOption> floatOptionList = new List<FloatMenuOption>
{
new FloatMenuOption("ThingInfo".Translate(), delegate
{
Find.WindowStack.Add(new Dialog_InfoCard(thing));
}, MenuOptionPriority.Default, null, null)
};
if (CanControl)
{
Expand Down Expand Up @@ -700,9 +704,9 @@ private void DrawThingRow1(Rect rect, Thing thing, bool inventory = false)
{
FloatMenuOption reloadApparelOption = new FloatMenuOption(
"CE_ReloadApparel".Translate(apparel.Label, thing.Label),
new Action(delegate
new Action(delegate
{
SelPawnForGear.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.Reload, apparel, thing));
SelPawnForGear.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.Reload, apparel, thing));
})
);
floatOptionList.Add(reloadApparelOption);
Expand Down Expand Up @@ -797,7 +801,7 @@ private void DrawThingRow1(Rect rect, Thing thing, bool inventory = false)
FloatMenu window = new FloatMenu(floatOptionList, thing.LabelCap, false);
Find.WindowStack.Add(window);
}
// end menu
// end menu
}

private void DrawMassInfo(Vector2 topLeft)
Expand Down Expand Up @@ -1191,7 +1195,10 @@ private void DrawThingRow(ref float y, float width, Thing thing, bool inventory
thing.MaxHitPoints
});
}
TooltipHandler.TipRegion(rect, text2);
TooltipHandler.TipRegion(rect, text2);

DrawRMBMenu(rect, thing);

y += 28f;
}

Expand Down
Binary file modified v1.5/Assemblies/Sandy_Detailed_RPG_Inventory.dll
Binary file not shown.

0 comments on commit 0694b47

Please sign in to comment.