mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 15:40:29 +01:00
Barrier menu width now adjusts to fit scroller item text
This commit is contained in:
parent
331aad38f8
commit
f25da3e307
1 changed files with 24 additions and 0 deletions
|
|
@ -150,6 +150,8 @@ namespace SceneManager
|
||||||
{
|
{
|
||||||
rotateBarrier.Enabled = true;
|
rotateBarrier.Enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
barrierMenu.Width = SetMenuWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scrollerItem == rotateBarrier)
|
if (scrollerItem == rotateBarrier)
|
||||||
|
|
@ -269,5 +271,27 @@ namespace SceneManager
|
||||||
resetBarriers.Enabled = barriers.Count == 0 ? false : true;
|
resetBarriers.Enabled = barriers.Count == 0 ? false : true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static float SetMenuWidth()
|
||||||
|
{
|
||||||
|
float defaultWidth = UIMenu.DefaultWidth;
|
||||||
|
float width = barrierMenu.Width;
|
||||||
|
|
||||||
|
barrierList.TextStyle.Apply();
|
||||||
|
Rage.Native.NativeFunction.Natives.x54CE8AC98E120CAB("STRING"); // _BEGIN_TEXT_COMMAND_GET_WIDTH
|
||||||
|
Rage.Native.NativeFunction.Natives.ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(barrierList.SelectedItem);
|
||||||
|
float textWidth = Rage.Native.NativeFunction.Natives.x85F061DA64ED2F67<float>(true); // _END_TEXT_COMMAND_GET_WIDTH
|
||||||
|
float padding = 0.00390625f * 2; // typical padding used in RNUI
|
||||||
|
|
||||||
|
var selectedItemWidth = textWidth + padding;
|
||||||
|
if(selectedItemWidth <= 0.14f)
|
||||||
|
{
|
||||||
|
return defaultWidth;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return selectedItemWidth * 1.6f;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue