Skip to content

Commit

Permalink
Make reorderID a field, created on Repaint only and this works again.
Browse files Browse the repository at this point in the history
  • Loading branch information
alextd committed Oct 24, 2022
1 parent 421af4f commit 50ab343
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions Source/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public void DoWindowContents(Rect wrect)
options.End();
}

private int reorderID = -1;
public void DoBridgeList(Listing_Standard options)
{
options.GapLine();
Expand All @@ -47,22 +48,25 @@ public void DoBridgeList(Listing_Standard options)
Rect globalDragRect = labelRect;
globalDragRect.position = GUIUtility.GUIToScreenPoint(globalDragRect.position);

int reorderID = ReorderableWidget.NewGroup(
BridgelikeTerrain.Reorder,
ReorderableDirection.Vertical,
reorderRect,
extraDraggedItemOnGUI: delegate (int index, Vector2 dragStartPos)
{
Rect dragRect = globalDragRect;//copy it in so multiple frames don't edit the same thing
dragRect.y += index * itemHeight;//i-th item
dragRect.position += Event.current.mousePosition - dragStartPos;//adjust for mouse vs starting point

//Same id 34003428 as GenUI.DrawMouseAttachment
Find.WindowStack.ImmediateWindow(34003428, dragRect, WindowLayer.Super, () =>
DefLabelWithIconButNoTooltipCmonReally(dragRect.AtZero(), BridgelikeTerrain.allBridgeTerrains[index], 0)
);

});
if (Event.current.type == EventType.Repaint)
{
reorderID = ReorderableWidget.NewGroup(
BridgelikeTerrain.Reorder,
ReorderableDirection.Vertical,
reorderRect,
extraDraggedItemOnGUI: delegate (int index, Vector2 dragStartPos)
{
Rect dragRect = globalDragRect;//copy it in so multiple frames don't edit the same thing
dragRect.y += index * itemHeight;//i-th item
dragRect.position += Event.current.mousePosition - dragStartPos;//adjust for mouse vs starting point

//Same id 34003428 as GenUI.DrawMouseAttachment
Find.WindowStack.ImmediateWindow(34003428, dragRect, WindowLayer.Super, () =>
DefLabelWithIconButNoTooltipCmonReally(dragRect.AtZero(), BridgelikeTerrain.allBridgeTerrains[index], 0)
);

});
}

foreach (TerrainDef terDef in BridgelikeTerrain.allBridgeTerrains)
{
Expand Down

0 comments on commit 50ab343

Please sign in to comment.