Skip to content

Commit 42c6e77

Browse files
committed
Cleanup
- Prep work for main loop rewrite/cleanup - Remove blank entries from user_preferences.lua - If userpreferences entry is blank for a module, don't write it to file on save
1 parent bc796b2 commit 42c6e77

3 files changed

Lines changed: 20 additions & 100 deletions

File tree

Docs/TODO.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
- Better High DPI support
44
- Editing ScriptHawk.UI.button_height does a [decent job](https://twitter.com/Isotarge/status/963992829746855937), but it's not perfect
55
- Blank template that's more lightweight
6-
- Remove blank entries from user_preferences.lua
7-
- If entry is blank for a module, don't write it to file on save
86
- Allow modules to save extra settings via UserPreferences system
97
- Save and Load ScriptHawk settings using UserPreferences system
108
- Joypad/Keyboard binds for D-Pad and L Button

ScriptHawk.lua

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,8 @@ local function saveUserPreferences()
15751575
local file = io.open('user_preferences.lua', "w");
15761576
file:write("userPreferences={\n");
15771577
for moduleName, userPreference in pairs(userPreferences) do
1578-
file:write("\t"..moduleName.."={\n");
1578+
local shouldWriteModule = false;
1579+
local preferencesString = "\t"..moduleName.."={\n";
15791580
for OSDType, preference in pairs(userPreference) do
15801581
local valueToWrite = "true";
15811582
if preference == nil then
@@ -1584,10 +1585,14 @@ local function saveUserPreferences()
15841585
valueToWrite = "false";
15851586
end
15861587
if userPreferences[moduleName][OSDType] ~= defaultPreferences[moduleName][OSDType] then
1587-
file:write("\t\t"..OSDType.."="..valueToWrite..",\n");
1588+
shouldWriteModule = true;
1589+
preferencesString = preferencesString.."\t\t"..OSDType.."="..valueToWrite..",\n";
15881590
end
15891591
end
1590-
file:write("\t},\n");
1592+
if shouldWriteModule then
1593+
preferencesString = preferencesString.."\t},\n";
1594+
file:write(preferencesString);
1595+
end
15911596
end
15921597
file:write("};\n");
15931598
file:close();
@@ -1938,30 +1943,25 @@ local function plot_pos()
19381943
end
19391944

19401945
if not isLagged then
1941-
if not exactlyOneFrameHasPassed then
1946+
if exactlyOneFrameHasPassed then
1947+
dx = x - prev_x;
1948+
dy = y - prev_y;
1949+
dz = z - prev_z;
1950+
d = math.sqrt(dx*dx + dz*dz);
1951+
1952+
odometer = odometer + d;
1953+
max_dx = math.max(max_dx, math.abs(dx));
1954+
max_dy = math.max(max_dy, math.abs(dy));
1955+
max_dz = math.max(max_dz, math.abs(dz));
1956+
max_d = math.max(max_d, d);
1957+
else
19421958
dx = 0;
19431959
dy = 0;
19441960
dz = 0;
19451961
max_dx = 0.0;
19461962
max_dy = 0.0;
19471963
max_dz = 0.0;
19481964
max_d = 0.0;
1949-
else
1950-
dx = x - prev_x;
1951-
dy = y - prev_y;
1952-
dz = z - prev_z;
1953-
end
1954-
1955-
d = math.sqrt(dx*dx + dz*dz);
1956-
odometer = odometer + d;
1957-
1958-
max_dx = math.max(max_dx, math.abs(dx));
1959-
max_dy = math.max(max_dy, math.abs(dy));
1960-
max_dz = math.max(max_dz, math.abs(dz));
1961-
max_d = math.max(max_d, d);
1962-
if not exactlyOneFrameHasPassed then
1963-
max_dx = 0; max_dy = 0; max_dz = 0;
1964-
max_d = 0;
19651965
end
19661966

19671967
if ScriptHawk.smooth_moving_angle == true then

user_preferences.lua

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,2 @@
11
userPreferences={
2-
lots={
3-
},
4-
bk={
5-
},
6-
mercs_sms={
7-
},
8-
the_ninja={
9-
},
10-
rats={
11-
},
12-
dkr={
13-
},
14-
balloon_fight={
15-
},
16-
rush_2049={
17-
},
18-
mm={
19-
},
20-
smash64={
21-
},
22-
dk64={
23-
},
24-
ts2={
25-
},
26-
sonic1_sms={
27-
},
28-
taz={
29-
},
30-
cbfd={
31-
},
32-
shinobi_world={
33-
},
34-
GBA_DrillDozer={
35-
},
36-
sm64={
37-
},
38-
golvellius={
39-
},
40-
galahad={
41-
},
42-
psycho_fox={
43-
},
44-
tftt={
45-
},
46-
wonder_boy_monster_world={
47-
},
48-
oot={
49-
},
50-
impossible_mission={
51-
},
52-
sssv={
53-
},
54-
penguin_land={
55-
},
56-
metroid={
57-
},
58-
crash2={
59-
},
60-
GBA_Ty2={
61-
},
62-
gran_turismo_2={
63-
},
64-
rayman_2={
65-
},
66-
elmo={
67-
},
68-
golden_axe_warrior={
69-
},
70-
bt={
71-
},
72-
crash1={
73-
},
74-
crash3={
75-
},
76-
ej3d={
77-
},
78-
miracle_world={
79-
},
802
};

0 commit comments

Comments
 (0)