Skip to content

Commit 42f7b60

Browse files
committed
fix: read notes
- WaspClient can now login with username+password - some work on the misc form - some tweaks to the recorder - recorder panel in the misco form done - added the ability to scale and rotate models permanently (changing self)
1 parent e6e8336 commit 42f7b60

File tree

12 files changed

+282
-78
lines changed

12 files changed

+282
-78
lines changed

examples/misc_form.simba

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var
55
tab: TLazTabSheet;
66
begin
77
form.Setup();
8+
form.CreateMiscTab();
89
tab := form.CreateTab('My Settings');
9-
form.CreateAntibanTab();
1010
form.Run();
1111
end.

osrs.simba

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ less confusing way.
1313
```pascal
1414
{$DEFINE WL_DEBUG_MOUSE}
1515
{$DEFINE WL_DISABLE_FAKE_INPUT}
16-
{$DEFINE WL_DISABLE_WASPINPUT}
1716
{$DEFINE WL_KEYBINDS_DEBUG}
1817
{$DEFINE WL_DEBUG_UPTEXT}
1918
{$DEFINE WL_DEBUG_INTERFACES}

osrs/interfaces/setup.simba

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ begin
116116
raise GetDebugLn('WaspLib', 'Failed to create path: ' + WLEnv.LogsDir);
117117
if not DirCreate(WLEnv.AssetsDir) then
118118
raise GetDebugLn('WaspLib', 'Failed to create path: ' + WLEnv.AssetsDir);
119+
if not DirCreate(WLEnv.VideosDir) then
120+
raise GetDebugLn('WaspLib', 'Failed to create path: ' + WLEnv.VideosDir);
119121

120122
WaspClient.Setup();
121123
WLAssets.Update();

osrs/miscform.simba

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ mentioned on this page because they are internal methods you shouldn't touch.
2323
Do feel free to read the source code though if you so desire.
2424
*)
2525
TMiscFormHelper = record
26+
LoginPanel, ClientPanel: TLazPanel;
27+
EmailEdit, PasswordEdit: TLazEdit;
28+
RecorderLength: TLazSpinEdit;
29+
RecorderLengthLbl1, RecorderLengthLbl2: TLazLabel;
2630
Config: TConfigJSON;
2731
end;
2832

@@ -31,6 +35,163 @@ begin
3135
Self.Config.Setup('misc' + PATH_SEP + ToStr(ProfileIndex));
3236
end;
3337

38+
39+
procedure TMiscFormHelper.OnLogin(sender: TLazObject);
40+
begin
41+
WaspClient.Login(Self.EmailEdit.Text, Self.PasswordEdit.Text);
42+
43+
if WaspClient.LoggedIn then
44+
TLazButton(sender).Parent.Hide();
45+
end;
46+
47+
procedure TMiscFormHelper.OnLogout(sender: TLazObject);
48+
begin
49+
WaspClient.Login(Self.EmailEdit.Text, Self.PasswordEdit.Text);
50+
51+
if WaspClient.LoggedIn then
52+
TLazButton(sender).Parent.Hide();
53+
end;
54+
55+
56+
procedure TMiscFormHelper.SetupLoginPanel(parent: TLazComponent);
57+
var
58+
panel: TLazPanel;
59+
info: TLazLabel;
60+
btn: TLazButton;
61+
begin
62+
Self.LoginPanel := TLazPanel.CreateEx(parent, TLazTabSheet(parent).Width div 2 - 240, 20, 480, 220);
63+
Self.LoginPanel.BevelWidth := 0;
64+
65+
info := TLazLabel.CreateEx(Self.LoginPanel, '', '', 60, 20, 0, 90);
66+
info.Caption := 'You are currently not logged into WaspScripts.' + LINE_SEP + LINE_SEP +
67+
'To submit stats you can either login below' + LINE_SEP +
68+
'or relaunch the script from wasp-launcher.';
69+
info.Alignment := ELazAlignment.Center;
70+
info.Font.Name := 'Courier New';
71+
72+
Self.EmailEdit := TLazEdit.CreateEx(Self.LoginPanel, 'Email:', 'Username to login to WaspScripts', 20, info.Bottom + 20, 200);
73+
Self.PasswordEdit := TLazEdit.CreateEx(Self.LoginPanel, 'Password:', 'Password to login to WaspScripts', Self.EmailEdit.Right + 20, Self.EmailEdit.Top, 200);
74+
Self.PasswordEdit.PasswordChar := '*';
75+
76+
btn := TLazButton.CreateEx(Self.LoginPanel, 'Login', '', Self.LoginPanel.Width div 2 - 100, Self.EmailEdit.Bottom + 20, 200);
77+
btn.OnClick := @Self.OnLogin;
78+
79+
if WaspClient.LoggedIn then
80+
Self.LoginPanel.Hide();
81+
end;
82+
83+
procedure TMiscFormHelper.SetupClientPanel(parent: TLazComponent);
84+
var
85+
panel: TLazPanel;
86+
info: TLazLabel;
87+
btn: TLazButton;
88+
begin
89+
Self.ClientPanel := TLazPanel.CreateEx(parent, TLazTabSheet(parent).Width div 2 - 240, 20, 480, 220);
90+
Self.ClientPanel.BevelWidth := 0;
91+
92+
info := TLazLabel.CreateEx(Self.ClientPanel, 'You are logged in as ' + WaspClient.User.Username, '', 60, 20, 0, 90);
93+
info.Alignment := ELazAlignment.Center;
94+
info.Font.Name := 'Courier New';
95+
96+
btn := TLazButton.CreateEx(Self.LoginPanel, 'Login', '', Self.LoginPanel.Width div 2 - 100, Self.EmailEdit.Bottom + 20, 200);
97+
btn.OnClick := @Self.OnLogout;
98+
99+
if WaspClient.LoggedIn then
100+
Self.LoginPanel.Hide();
101+
end;
102+
103+
104+
105+
procedure TMiscFormHelper.OnRecorderEnabledChange(sender: TLazObject);
106+
begin
107+
if TLazCheckBox(sender).IsChecked() then
108+
begin
109+
SimbaRecorder.Enabled := True;
110+
Self.RecorderLengthLbl1.Enabled := True;
111+
Self.RecorderLength.Enabled := True;
112+
Self.RecorderLengthLbl2.Enabled := True;
113+
SimbaRecorder.BufferSeconds := Self.RecorderLength.Value;
114+
end
115+
else
116+
begin
117+
SimbaRecorder.Enabled := False;
118+
Self.RecorderLengthLbl1.Enabled := False;
119+
Self.RecorderLength.Enabled := False;
120+
Self.RecorderLengthLbl2.Enabled := False;
121+
end;
122+
123+
if Self.Config.Data.Has('recorder_enabled') then
124+
Self.Config.Data.Item['recorder_enabled'].AsBool := SimbaRecorder.Enabled
125+
else
126+
Self.Config.Data.AddBool('recorder_enabled', SimbaRecorder.Enabled);
127+
Self.Config.Save();
128+
end;
129+
130+
procedure TMiscFormHelper.OnRecorderLengthChange(sender: TLazObject);
131+
begin
132+
SimbaRecorder.BufferSeconds := TLazSpinEdit(sender).Value;
133+
if Self.Config.Data.Has('recorder_length') then
134+
Self.Config.Data.Item['recorder_length'].AsInt := SimbaRecorder.BufferSeconds
135+
else
136+
Self.Config.Data.AddInt('recorder_length', SimbaRecorder.BufferSeconds);
137+
Self.Config.Save();
138+
end;
139+
140+
141+
procedure TMiscFormHelper.SetupRecorderPanel(parent: TLazComponent);
142+
var
143+
panel: TLazPanel;
144+
check: TLazCheckBox;
145+
begin
146+
panel := TLazPanel.CreateEx(parent, TLazTabSheet(parent).Width div 2 - 120, 320, 240, 100);
147+
panel.BevelWidth := 0;
148+
149+
check := TLazCheckBox.CreateEx(panel, 'Record crashes', '', 20, 0);
150+
check.Hint := 'Simba recorder records the last X seconds of a script running.' + LINE_SEP +
151+
'This is great to analyze crashes and issues that shut down scripts' + LINE_SEP +
152+
'but uses a lot of RAM and will use more the longer the recording is.';
153+
check.ShowHint := True;
154+
check.OnChange := @Self.OnRecorderEnabledChange;
155+
156+
Self.RecorderLengthLbl1 := TLazLabel.CreateEx(panel, 'Record last', '', 20, 40);
157+
Self.RecorderLength := TLazSpinEdit.CreateEx(panel);
158+
Self.RecorderLength.AnchorHorizontally(Self.RecorderLengthLbl1, 10);
159+
Self.RecorderLength.Hint := check.Hint;
160+
Self.RecorderLength.ShowHint := True;
161+
Self.RecorderLength.Increment := 5;
162+
if Self.Config.Data.Has('recorder_length') then
163+
begin
164+
SimbaRecorder.BufferSeconds := Self.Config.Data.Item['recorder_length'].AsInt;
165+
Self.RecorderLength.Value := Self.Config.Data.Item['recorder_length'].AsInt;
166+
end
167+
else
168+
begin
169+
SimbaRecorder.BufferSeconds := 30;
170+
Self.RecorderLength.Value := 30;
171+
end;
172+
Self.RecorderLength.MinValue := 10;
173+
Self.RecorderLength.OnChange := @Self.OnRecorderLengthChange;
174+
175+
Self.RecorderLengthLbl2 := TLazLabel.CreateEx(panel, 'seconds');
176+
Self.RecorderLengthLbl2.AnchorHorizontally(Self.RecorderLength, 10);
177+
178+
if Self.Config.Data.Has('recorder_enabled') then
179+
begin
180+
check.SetChecked(Self.Config.Data.Item['recorder_enabled'].AsBool);
181+
Self.RecorderLengthLbl1.Enabled := Self.Config.Data.Item['recorder_enabled'].AsBool;
182+
Self.RecorderLength.Enabled := Self.Config.Data.Item['recorder_enabled'].AsBool;
183+
Self.RecorderLengthLbl2.Enabled := Self.Config.Data.Item['recorder_enabled'].AsBool;
184+
end
185+
else
186+
begin
187+
check.SetChecked(False);
188+
Self.RecorderLengthLbl1.Enabled := False;
189+
Self.RecorderLength.Enabled := False;
190+
Self.RecorderLengthLbl2.Enabled := False;
191+
end;
192+
end;
193+
194+
34195
var
35196
(*
36197
## MiscForm variable
@@ -65,4 +226,7 @@ begin
65226
Result := Self.CreateTab('Misc');
66227

67228
MiscForm.Setup();
229+
MiscForm.SetupLoginPanel(Result);
230+
MiscForm.SetupRecorderPanel(Result);
231+
MiscForm.Setup();
68232
end;

osrs/projection/model.simba

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type
1313
Materials: TColorArray;
1414
Alphas: TByteArray;
1515
Width, Depth, Height: Single;
16+
Center: TVector3;
1617
end;
1718

1819
procedure TModel.LoadMTL(fileName: string);
@@ -127,6 +128,7 @@ begin
127128
Self.Width := x2-x1;
128129
Self.Depth := y2-y1;
129130
Self.Height := z2-z1;
131+
Self.Center := [x1+Self.Width/2, y1+Self.Depth/2, z1+Self.Height/2];
130132
end;
131133

132134

@@ -138,6 +140,37 @@ begin
138140
end;
139141

140142

143+
procedure TModel.Scale(factor: Single);
144+
var
145+
i: Integer;
146+
begin
147+
for i := 0 to High(Self.Vertices) do
148+
begin
149+
Self.Vertices[i].X := Self.Vertices[i].X * factor;
150+
Self.Vertices[i].Y := Self.Vertices[i].Y * factor;
151+
Self.Vertices[i].Z := Self.Vertices[i].Z * factor;
152+
end;
153+
154+
Self.Width := Self.Width * factor;
155+
Self.Depth := Self.Depth * factor;
156+
Self.Height := Self.Height * factor;
157+
158+
Self.Center.X := Self.Center.X * factor;
159+
Self.Center.Y := Self.Center.Y * factor;
160+
Self.Center.Z := Self.Center.Z * factor;
161+
end;
162+
163+
procedure TModel.Rotate(radians: Single);
164+
var
165+
i: Integer;
166+
center: TVector2;
167+
begin
168+
center := Self.Center.ToVec2();
169+
for i := 0 to High(Self.Vertices) do
170+
Self.Vertices[i] := Self.Vertices[i].Rotate(radians, center);
171+
end;
172+
173+
141174
function TModel.ProjectEx(minimapCoord: TVector3; heights: array [0..3] of Single; rotation, radians: Single): TPointArray;
142175
var
143176
i: Integer;

osrs/walker.simba

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ begin
3232
end;
3333
```
3434
*)
35-
TRSWalkerEvent = procedure(walker: PRSWalker; position, destination: TPoint) of object;
35+
TRSWalkerEvent = procedure(walker: PRSWalker; position, destination: TPoint) of object;
3636
TWalkerPositionFunction = function (): TPoint of object;
3737
TWalkerHeightFunction = function (pt: TPoint = [0,0]; global: Boolean = True): Single of object;
38-
TWalkerGetLocalFunction = function (pt: TPoint; offset: TPoint = [0,0]): TPoint of object;
38+
TWalkerGetLocalFunction = function (pt: TPoint; offset: TPoint = [0,0]): TPoint of object;
3939

4040
(*
4141
## TRSWalker

utils.simba

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
{$IFNDEF WL_WORLDFETCHER_INCLUDED} {$INCLUDE_ONCE WaspLib/utils/worldfetcher.simba}
2828
{$IFNDEF WL_PROFILES_INCLUDED} {$INCLUDE_ONCE utils/profiles.simba}
2929
{$IFNDEF WL_PROFILE_FORM_INCLUDED} {$INCLUDE_ONCE utils/forms/profile_form.simba}
30-
{$IFNDEF WL_SCRIPTFORM_INCLUDED} {$INCLUDE_ONCE utils/forms/scriptform.simba}
3130
{$IFNDEF WL_RECORDER_INCLUDED} {$INCLUDE_ONCE utils/recorder.simba}
31+
{$IFNDEF WL_SCRIPTFORM_INCLUDED} {$INCLUDE_ONCE utils/forms/scriptform.simba}
3232
{$IFNDEF WL_CONVERSIONS_INCLUDED} {$INCLUDE_ONCE utils/math/conversions.simba}
3333

3434
{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}

utils/env.simba

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ WLEnv = record
1313
const CacheDir: String = SimbaEnv.DataPath + 'Cache' + PATH_SEP;
1414
const AssetsDir: String = SimbaEnv.DataPath + 'Assets' + PATH_SEP;
1515
const LogsDir: String = SimbaEnv.DataPath + 'Logs' + PATH_SEP;
16+
const VideosDir: String = SimbaEnv.SimbaPath + 'Videos' + PATH_SEP;
1617
end;
1718
```
1819
*)
@@ -22,4 +23,5 @@ type
2223
const CacheDir: String = SimbaEnv.DataPath + 'Cache' + PATH_SEP;
2324
const AssetsDir: String = SimbaEnv.DataPath + 'Assets' + PATH_SEP;
2425
const LogsDir: String = SimbaEnv.DataPath + 'Logs' + PATH_SEP;
26+
const VideosDir: String = SimbaEnv.SimbaPath + 'Videos' + PATH_SEP;
2527
end;

utils/forms/formutils.simba

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ begin
499499
Result.Parent := TLazComponent(owner);
500500
end;
501501

502-
function TLazPanel.CreateEx(owner: Pointer; top, left, width, height: Integer): TLazPanel; static; overload;
502+
function TLazPanel.CreateEx(owner: Pointer; left, top, width, height: Integer): TLazPanel; static; overload;
503503
begin
504504
Result := TLazPanel.CreateEx(owner);
505505

@@ -516,7 +516,7 @@ begin
516516
Result.Parent := TLazComponent(owner);
517517
end;
518518

519-
function TLazPageControl.CreateEx(owner: Pointer; top, left, width, height: Integer): TLazPageControl; static; overload;
519+
function TLazPageControl.CreateEx(owner: Pointer; left, top, width, height: Integer): TLazPageControl; static; overload;
520520
begin
521521
Result := TLazPageControl.CreateEx(owner);
522522

utils/forms/scriptform.simba

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ begin
111111
else
112112
Self.ConfigData.AddInt('goal_level', Self.Goals.Level.Value);
113113
end;
114+
115+
if SimbaRecorder.Enabled then
116+
SimbaRecorder.Start();
114117
end;
115118
{$H+}
116119

0 commit comments

Comments
 (0)