Skip to content

Commit

Permalink
Refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
devapromix committed Jul 10, 2022
1 parent c143278 commit b3e4577
Show file tree
Hide file tree
Showing 21 changed files with 273 additions and 227 deletions.
25 changes: 13 additions & 12 deletions Sources/Scenes/TransportTycoon.Scene.Aircraft.pas
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ procedure TSceneAircraft.Render;
terminal_color('white');
DrawText(12, 12, Format('Passengers: %d/%d',
[Passengers, MaxPassengers]));
DrawText(12, 13, Format('Mail: %d/%d',
[Mail, MaxMail]));
DrawText(12, 13, Format('Mail: %d/%d', [Mail, MaxMail]));

DrawText(12, 17, Format('State: %s', [State]));

Expand Down Expand Up @@ -78,16 +77,18 @@ procedure TSceneAircraft.Update(var Key: Word);
begin
if (Key = TK_MOUSE_LEFT) then
begin
if (MX >= 28) and (MX <= 37) then
case MY of
19:
Key := TK_O;
end;
if (MX >= 41) and (MX <= 51) then
case MY of
19:
Key := TK_ESCAPE;
end;
case MX of
28 .. 37:
case MY of
19:
Key := TK_O;
end;
41 .. 51:
case MY of
19:
Key := TK_ESCAPE;
end;
end;
end;
case Key of
TK_A .. TK_G:
Expand Down
14 changes: 7 additions & 7 deletions Sources/Scenes/TransportTycoon.Scene.AircraftHangar.pas
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,20 @@ procedure TSceneAircraftHangar.Update(var Key: Word);
begin
if (Key = TK_MOUSE_LEFT) then
begin
if (MX >= 12) and (MX <= 38) then
case MY of
10 .. 18:
Key := TK_A + (MY - 10);
end;
case MX of
12 .. 38:
case MY of
10 .. 18:
Key := TK_A + (MY - 10);
end;
end;
if (GetButtonsY = MY) then
begin
case MX of
23 .. 42:
Key := TK_ENTER;
46 .. 56:
Key := TK_ESCAPE;
end;
end;
end;
case Key of
TK_ESCAPE:
Expand Down
20 changes: 11 additions & 9 deletions Sources/Scenes/TransportTycoon.Scene.AircraftOrders.pas
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,18 @@ procedure TSceneAircraftOrders.Update(var Key: Word);
begin
if (Key = TK_MOUSE_LEFT) then
begin
if (MX >= 22) and (MX <= 56) then
case MY of
9 .. 19:
Key := TK_A + (MY - 9);
end;
if (GetButtonsY = MY) then
begin
if (MX >= 35) and (MX <= 45) then
Key := TK_ESCAPE;
case MX of
22 .. 56:
case MY of
9 .. 19:
Key := TK_A + (MY - 9);
end;
end;
if (GetButtonsY = MY) then
case MX of
35 .. 45:
Key := TK_ESCAPE;
end;
end;
case Key of
TK_ESCAPE:
Expand Down
28 changes: 15 additions & 13 deletions Sources/Scenes/TransportTycoon.Scene.Airport.pas
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,23 @@ procedure TSceneAirport.Update(var Key: Word);
begin
if (Key = TK_MOUSE_LEFT) then
begin
if (MX >= 37) and (MX <= 71) then
begin
I := MY - 11;
case MY of
11 .. 17:
Key := TK_A + I;
end;
case MX of
37 .. 71:
begin
I := MY - 11;
case MY of
11 .. 17:
Key := TK_A + I;
end;
end;
end;
if (GetButtonsY = MY) then
begin
if (MX >= 28) and (MX <= 37) then
Key := TK_H;
if (MX >= 41) and (MX <= 51) then
Key := TK_ESCAPE;
end;
case MX of
28 .. 37:
Key := TK_H;
41 .. 51:
Key := TK_ESCAPE;
end;
end;
case Key of
TK_ESCAPE:
Expand Down
26 changes: 14 additions & 12 deletions Sources/Scenes/TransportTycoon.Scene.BuildInTown.pas
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,22 @@ procedure TSceneBuildInTown.Update(var Key: Word);
begin
if (Key = TK_MOUSE_LEFT) then
begin
if (MX >= 35) and (MX <= 45) then
case MY of
19:
if (GetButtonsY = MY) then
case MX of
35 .. 45:
Key := TK_ESCAPE;
end;
if (MX >= 17) and (MX <= 62) then
case MY of
11:
Key := TK_A;
12:
Key := TK_B;
17:
Key := TK_G;
end;
case MX of
17 .. 62:
case MY of
11:
Key := TK_A;
12:
Key := TK_B;
17:
Key := TK_G;
end;
end;
end;
case Key of
TK_ESCAPE:
Expand Down
18 changes: 11 additions & 7 deletions Sources/Scenes/TransportTycoon.Scene.BuildMenu.pas
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,18 @@ procedure TSceneBuildMenu.Update(var Key: Word);
begin
if (GetButtonsY = MY) then
begin
if (MX >= 35) and (MX <= 45) then
Key := TK_ESCAPE;
end;
if (MX >= 22) and (MX <= 56) then
case MY of
12:
Key := TK_C;
case MX of
35 .. 45:
Key := TK_ESCAPE;
end;
end;
case MX of
22 .. 56:
case MY of
12:
Key := TK_C;
end;
end;
end;
case Key of
TK_ESCAPE:
Expand Down
25 changes: 16 additions & 9 deletions Sources/Scenes/TransportTycoon.Scene.BuildNearIndustry.pas
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,23 @@ procedure TSceneBuildNearIndustry.Update(var Key: Word);
begin
if (Key = TK_MOUSE_LEFT) then
begin
if (MX >= 35) and (MX <= 45) then
case MY of
19:
Key := TK_ESCAPE;
end;
if (MX >= 17) and (MX <= 62) then
case MY of
11:
Key := TK_D;
if (GetButtonsY = MY) then
begin
case MX of
35 .. 45:
case MY of
19:
Key := TK_ESCAPE;
end;
end;
end;
case MX of
17 .. 62:
case MY of
11:
Key := TK_D;
end;
end;
end;
case Key of
TK_ESCAPE:
Expand Down
6 changes: 4 additions & 2 deletions Sources/Scenes/TransportTycoon.Scene.Company.pas
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ procedure TSceneCompany.Update(var Key: Word);
begin
if (GetButtonsY = MY) then
begin
if (MX >= 35) and (MX <= 45) then
Key := TK_ESCAPE;
case MX of
35 .. 45:
Key := TK_ESCAPE;
end;
end;
end;
case Key of
Expand Down
26 changes: 15 additions & 11 deletions Sources/Scenes/TransportTycoon.Scene.Dock.pas
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,24 @@ procedure TSceneDock.Update(var Key: Word);
begin
if (Key = TK_MOUSE_LEFT) then
begin
if (MX >= 37) and (MX <= 71) then
begin
I := MY - 11;
case MY of
11 .. 17:
Key := TK_A + I;
end;
case MX of
37 .. 71:
begin
I := MY - 11;
case MY of
11 .. 17:
Key := TK_A + I;
end;
end;
end;
if (GetButtonsY = MY) then
begin
if (MX >= 26) and (MX <= 39) then
Key := TK_V;
if (MX >= 43) and (MX <= 53) then
Key := TK_ESCAPE;
case MX of
26 .. 39:
Key := TK_V;
43 .. 53:
Key := TK_ESCAPE;
end;
end;
end;
case Key of
Expand Down
14 changes: 8 additions & 6 deletions Sources/Scenes/TransportTycoon.Scene.Finances.pas
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,14 @@ procedure TSceneFinances.Update(var Key: Word);
if (Key = TK_MOUSE_LEFT) then
if (GetButtonsY = MY) then
begin
if (MX >= 22) and (MX <= 31) then
Key := TK_B;
if (MX >= 35) and (MX <= 43) then
Key := TK_R;
if (MX >= 47) and (MX <= 57) then
Key := TK_ESCAPE;
case MX of
22 .. 31:
Key := TK_B;
35 .. 43:
Key := TK_R;
47 .. 57:
Key := TK_ESCAPE;
end;
end;
case Key of
TK_ESCAPE:
Expand Down
63 changes: 32 additions & 31 deletions Sources/Scenes/TransportTycoon.Scene.GameMenu.pas
Original file line number Diff line number Diff line change
Expand Up @@ -56,40 +56,41 @@ procedure TSceneGameMenu.Update(var Key: word);
begin
if (Key = TK_MOUSE_LEFT) then
begin
if (MX >= 12) and (MX <= 38) then
case MY of
11:
Key := TK_F;
12:
Key := TK_N;
16:
Key := TK_S;
17:
Key := TK_A;
end;
if (MX >= 42) and (MX <= 68) then
case MY of
11:
Key := TK_G;
12:
Key := TK_I;
15:
Key := TK_B;
16:
Key := TK_P;
17:
Key := TK_X;
end;
if (MX >= 29) and (MX <= 36) then
case MY of
19:
case MX of
12 .. 38:
case MY of
11:
Key := TK_F;
12:
Key := TK_N;
16:
Key := TK_S;
17:
Key := TK_A;
end;
42 .. 68:
case MY of
11:
Key := TK_G;
12:
Key := TK_I;
15:
Key := TK_B;
16:
Key := TK_P;
17:
Key := TK_X;
end;
end;
if (GetButtonsY = MY) then
begin
case MX of
29 .. 36:
Key := TK_Q;
end;
if (MX >= 40) and (MX <= 50) then
case MY of
19:
40 .. 50:
Key := TK_ESCAPE;
end;
end;
end;
case Key of
TK_ESCAPE:
Expand Down
Loading

0 comments on commit b3e4577

Please sign in to comment.