Skip to content

Commit b122a92

Browse files
committed
ScriptHawk: Only update form labels when values change
Should be a nice little FPS boost
1 parent d26dbe7 commit b122a92

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

ScriptHawk.lua

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -801,18 +801,22 @@ precision = 3;
801801

802802
function ScriptHawk.decreasePrecision()
803803
precision = math.max(0, precision - 1);
804+
forms.settext(ScriptHawk.UI.form_controls["Precision Value Label"], precision);
804805
end
805806

806807
function ScriptHawk.increasePrecision()
807808
precision = math.min(12, precision + 1);
809+
forms.settext(ScriptHawk.UI.form_controls["Precision Value Label"], precision);
808810
end
809811

810812
function ScriptHawk.decreaseSpeed()
811813
Game.speedy_index = math.max(1, Game.speedy_index - 1);
814+
forms.settext(ScriptHawk.UI.form_controls["Speed Value Label"], Game.speedy_speeds[Game.speedy_index]);
812815
end
813816

814817
function ScriptHawk.increaseSpeed()
815818
Game.speedy_index = math.min(#Game.speedy_speeds, Game.speedy_index + 1);
819+
forms.settext(ScriptHawk.UI.form_controls["Speed Value Label"], Game.speedy_speeds[Game.speedy_index]);
816820
end
817821

818822
ScriptHawk.movingAngle = 0.0;
@@ -985,6 +989,7 @@ local function toggleRotationUnits()
985989
else
986990
rotation_units = "Degrees";
987991
end
992+
forms.settext(ScriptHawk.UI.form_controls["Toggle Rotation Units Button"], rotation_units);
988993
end
989994

990995
function ScriptHawk.UI.formatRotation(num)
@@ -1012,6 +1017,7 @@ local function toggleMode()
10121017
else
10131018
ScriptHawk.mode = 'Position';
10141019
end
1020+
forms.settext(ScriptHawk.UI.form_controls["Mode Button"], ScriptHawk.mode);
10151021
end
10161022

10171023
---------------
@@ -1228,7 +1234,7 @@ function ScriptHawk.initUI(formTitle)
12281234
ScriptHawk.UI.form_controls["Speed Label"] = forms.label(ScriptHawk.UI.options_form, "Speed:", ScriptHawk.UI.col(0), ScriptHawk.UI.row(2) + ScriptHawk.UI.label_offset, 54, 14);
12291235
ScriptHawk.UI.button({4, -28}, 2, {ScriptHawk.UI.button_height}, nil, "Decrease Speed Button", "-", ScriptHawk.decreaseSpeed);
12301236
ScriptHawk.UI.button({5, -28}, 2, {ScriptHawk.UI.button_height}, nil, "Increase Speed Button", "+", ScriptHawk.increaseSpeed);
1231-
ScriptHawk.UI.form_controls["Speed Value Label"] = forms.label(ScriptHawk.UI.options_form, "0", ScriptHawk.UI.col(5), ScriptHawk.UI.row(2) + ScriptHawk.UI.label_offset, 47, 14);
1237+
ScriptHawk.UI.form_controls["Speed Value Label"] = forms.label(ScriptHawk.UI.options_form, Game.speedy_speeds[Game.speedy_index], ScriptHawk.UI.col(5), ScriptHawk.UI.row(2) + ScriptHawk.UI.label_offset, 47, 14);
12321238
end
12331239

12341240
if type(Game.maps) == "table" then
@@ -1372,15 +1378,7 @@ local angleKeywords = {
13721378

13731379
function ScriptHawk.UI.updateReadouts()
13741380
-- Update form buttons etc
1375-
forms.settext(ScriptHawk.UI.form_controls["Precision Value Label"], precision);
1376-
forms.settext(ScriptHawk.UI.form_controls["Toggle Rotation Units Button"], rotation_units);
1377-
13781381
if not TASSafe then
1379-
if ScriptHawk.dpad.joypad.enabled or ScriptHawk.dpad.key.enabled then
1380-
forms.settext(ScriptHawk.UI.form_controls["Speed Value Label"], Game.speedy_speeds[Game.speedy_index]);
1381-
end
1382-
forms.settext(ScriptHawk.UI.form_controls["Mode Button"], ScriptHawk.mode);
1383-
13841382
if type(Game.maps) == "table" and previous_map ~= forms.gettext(ScriptHawk.UI.form_controls["Map Dropdown"]) then
13851383
previous_map = forms.gettext(ScriptHawk.UI.form_controls["Map Dropdown"]);
13861384
previous_map_value = ScriptHawk.UI.findMapValue();

0 commit comments

Comments
 (0)