Skip to content

Commit

Permalink
Merge branch 'superBlockReuse'
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachHembree committed Jan 29, 2021
2 parents f0d3cd2 + 0f0c262 commit b85c4f4
Show file tree
Hide file tree
Showing 65 changed files with 1,421 additions and 576 deletions.
6 changes: 4 additions & 2 deletions BuildVision2/Data/Scripts/BuildVision2/Input/ChatCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ private void TargetBench(string[] args)
Stopwatch timer = new Stopwatch();
timer.Start();

TerminalGrid grid = new TerminalGrid();
var grid = new TerminalGrid();
var pBlock = new PropertyBlock();

grid.SetGrid(tblock.CubeGrid);

for (int n = 0; n < iterations; n++)
{
IMyTerminalBlock temp;
PropertiesMenu.TryGetTargetedBlock(100d, out temp);
PropertyBlock pBlock = new PropertyBlock(grid, tblock);
pBlock.SetBlock(grid, tblock);

if (getProperties)
pBlock.GetEnabledElementCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = git@github.com:ZachHembree/RichHudFramework.Client.git
branch = master
commit = 4dcb5c27d6eb9c71eb649b326d7298df194d1a06
commit = 16a9fddb34a67ff1d3eb82ee57fa18593f76d9fb
method = merge
cmdver = 0.4.3
parent = b39f8905090a8ec1e2adec95c70ecc4c28eea6da
parent = 5459293c562fec644e458cbe00bf8b1a85202fb0
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ private HudMain() : base(ApiModuleTypes.HudMain, false, true)
GetOrSetMemberFunc(new Action<List<HudUpdateAccessors>, byte>(root.GetUpdateAccessors), (int)HudMainAccessors.GetUpdateAccessors);

root.CustomDrawAction = HudMasterDraw;
root.CustomInputAction = HudMasterInput;
UpdateCache();
}

Expand All @@ -205,8 +206,6 @@ private void HudMasterDraw()

private void UpdateCache()
{
cursor.Update();

ScreenWidth = (float)GetOrSetMemberFunc(null, (int)HudMainAccessors.ScreenWidth);
ScreenHeight = (float)GetOrSetMemberFunc(null, (int)HudMainAccessors.ScreenHeight);
AspectRatio = (float)GetOrSetMemberFunc(null, (int)HudMainAccessors.AspectRatio);
Expand All @@ -230,6 +229,11 @@ private void UpdateCache()
refreshLast = RefreshDrawList;
}

private void HudMasterInput()
{
cursor.Update();
}

public override void Close()
{
UnregisterAction();
Expand Down Expand Up @@ -302,7 +306,7 @@ private class HudClientRoot : HudParentBase, IReadOnlyHudSpaceNode

public bool IsFacingCamera { get; }

public Action CustomDrawAction;
public Action CustomDrawAction, CustomInputAction;

public HudClientRoot()
{
Expand All @@ -317,10 +321,14 @@ public HudClientRoot()

protected override void Layout()
{
CustomDrawAction?.Invoke();
PlaneToWorld = PixelToWorld;
CursorPos = new Vector3(Cursor.ScreenPos.X, Cursor.ScreenPos.Y, 0f);
}

CustomDrawAction?.Invoke();
protected override void InputDepth()
{
CustomInputAction?.Invoke();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,31 +99,133 @@ public TextBuilder(TextBuilderMembers data)
}

/// <summary>
/// Clears current text and appends the text given.
/// Replaces the current text with the <see cref="RichText"/> given
/// </summary>
public void SetText(RichText text)
{
lastText = text;
SetTextAction(text.apiData);
lastText = text;
}

/// <summary>
/// Clears current text and appends a copy of the <see cref="StringBuilder"/> given.
/// </summary>
public void SetText(StringBuilder text, GlyphFormat format = null)
{
if (lastText == null)
lastText = new RichText();

lastText.Clear();
lastText.Add(text, format ?? Format);
SetTextAction(lastText.apiData);
}

/// <summary>
/// Clears current text and appends a copy of the <see cref="string"/> given.
/// </summary>
public void SetText(string text, GlyphFormat format = null)
{
if (lastText == null)
lastText = new RichText();

lastText.Clear();
lastText.Add(text, format ?? Format);
SetTextAction(lastText.apiData);
}

/// <summary>
/// Appends the given text to the end of the text using the <see cref="GlyphFormat"/>ting specified in the <see cref="RichText"/>.
/// Appends the given <see cref="RichText"/>
/// </summary>
public void Append(RichText text)
{
lastText = text;
Insert(text, GetLastIndex());
InsertTextAction(text.apiData, GetLastIndex());
}

/// <summary>
/// Appends a copy of the text in the <see cref="StringBuilder"/>
/// </summary>
public void Append(StringBuilder text, GlyphFormat format = null)
{
if (lastText == null)
lastText = new RichText();

lastText.Clear();
lastText.Add(text, format ?? Format);
InsertTextAction(lastText.apiData, GetLastIndex());
}

/// <summary>
/// Appends a copy of the <see cref="string"/>
/// </summary>
public void Append(string text, GlyphFormat format = null)
{
if (lastText == null)
lastText = new RichText();

lastText.Clear();
lastText.Add(text, format ?? Format);
InsertTextAction(lastText.apiData, GetLastIndex());
}

/// <summary>
/// Appends the given <see cref="char"/>
/// </summary>
public void Append(char ch, GlyphFormat format = null)
{
if (lastText == null)
lastText = new RichText();

lastText.Clear();
lastText.Add(ch, format ?? Format);
InsertTextAction(lastText.apiData, GetLastIndex());
}

/// Inserts the given text to the end of the text at the specified starting index using the <see cref="GlyphFormat"/>ting specified in the <see cref="RichText"/>.
/// </summary>
public void Insert(RichText text, Vector2I start)
{
lastText = text;
InsertTextAction(text.apiData, start);
}

/// <summary>
/// Inserts a copy of the given <see cref="StringBuilder"/> starting at the specified starting index
/// </summary>
public void Insert(StringBuilder text, Vector2I start, GlyphFormat format = null)
{
if (lastText == null)
lastText = new RichText();

lastText.Clear();
lastText.Add(text, format ?? Format);
InsertTextAction(lastText.apiData, start);
}

/// <summary>
/// Inserts a copy of the given <see cref="string"/> starting at the specified starting index
/// </summary>
public void Insert(string text, Vector2I start, GlyphFormat format = null)
{
if (lastText == null)
lastText = new RichText();

lastText.Clear();
lastText.Add(text, format ?? Format);
InsertTextAction(lastText.apiData, start);
}

/// <summary>
/// Inserts the given <see cref="char"/> starting at the specified starting index
/// </summary>
public void Insert(char ch, Vector2I start, GlyphFormat format = null)
{
if (lastText == null)
lastText = new RichText();

lastText.Clear();
lastText.Add(ch, format ?? Format);
InsertTextAction(lastText.apiData, start);
}

/// <summary>
/// Returns the contents of the text as <see cref="RichText"/>.
/// </summary>
Expand All @@ -137,10 +239,10 @@ public RichText GetTextRange(Vector2I start, Vector2I end)
{
var textData = GetOrSetMemberFunc(new RangeData(start, end), (int)TextBuilderAccessors.GetRange) as List<RichStringMembers>;

if (lastText != null && lastText.apiData == textData)
return lastText;
else
return new RichText(textData);
if (lastText == null && lastText.apiData != textData)
lastText = new RichText(textData);

return lastText;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = git@github.com:ZachHembree/RichHudFramework.Shared.git
branch = master
commit = 44a9e3538b037182e15c65479d195b5f2c7874af
commit = 4e7177ccdc9ae93cd8218e63c8a68e00e3d41437
method = merge
cmdver = 0.4.3
parent = 7695a435ff418fd6b11bf51ca3663663b23c5e58
parent = 6698c290ecb394a25d1ed139516189be13e8ffaa
Loading

0 comments on commit b85c4f4

Please sign in to comment.