Skip to content

Commit

Permalink
Fixed ATS mirror capture
Browse files Browse the repository at this point in the history
  • Loading branch information
DylDevs committed Jul 10, 2024
1 parent 10d43f4 commit 796226b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
3 changes: 3 additions & 0 deletions blog/V1.11.Minor.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ title: Version 1.11 > Minor
This changelog will contain all changes from 1.11.0 onwards before the next major version.
!!!

==- Version 1.11.59
Fix capture area for mirrors in ATS.
[!badge variant="dark" text="DylDev"] [!badge variant="ghost" text="VehicleDetection, DataCollection"]
==- Version 1.11.58
Changed capture area for mirrors in data collection.
[!badge variant="dark" text="DylDev"] [!badge variant="ghost" text="VehicleDetection, DataCollection"]
Expand Down
4 changes: 2 additions & 2 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
1.11.57: Fixed some color channel issues in the data collection code.
1.11.58: Changed capture area for mirrors in data collection.
1.11.58: Changed capture area for mirrors in data collection.
1.11.59: Fixed capture area for mirrors in ATS
20 changes: 16 additions & 4 deletions plugins/DataCollection/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,21 @@ def CalculateMirrorCoordinates(window):
tuple: Both mirror coordinates. ((left_x1, left_y1, left_x2, left_y2), (right_x1, right_y1, right_x2, right_y2))
'''

mirrorDistanceFromLeft = 23
mirrorDistanceFromTop = 90
mirrorWidth = 273
mirrorHeight = 362
game = helpers.GetCurrentlyActiveGame()

if game == "Euro Truck Simulator 2" or game == "Euro Truck Simulator 2 - Multiplayer":
mirrorDistanceFromLeft = 23
mirrorDistanceFromTop = 90
mirrorWidth = 273
mirrorHeight = 362
elif game == "American Truck Simulator" or game == "American Truck Simulator - Multiplayer":
mirrorDistanceFromLeft = 25
mirrorDistanceFromTop = 94
mirrorWidth = 256
mirrorHeight = 358
else:
return None

scale = (window[3] - window[1])/1080

xCoord = window[0] + (mirrorDistanceFromLeft * scale)
Expand Down Expand Up @@ -247,6 +258,7 @@ def plugin(data):
last_github_version_check = time.time()

threading.Thread(target=SendMirrorImages, args=(left_mirror, right_mirror,), daemon=True).start()

last_capture = time.time()

return data
Expand Down
12 changes: 12 additions & 0 deletions src/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,18 @@ def autoTune(self, feedback_value, current_time=None):
self.Kd += self.DTerm
self.clear()

def GetCurrentlyActiveGame():
"""Gets the currently active game.
Returns:
str: The name of the currently active game, or None if not found.
"""
titles = gw.getAllTitles()
for title in titles:
if title == "Euro Truck Simulator 2" or title == "Euro Truck Simulator 2 - Multiplayer" or title == "American Truck Simulator" or title == "American Truck Simulator - Multiplayer":
return title
return None

def GetGameWindowPosition():
"""Gets the position of the game window.
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.11.58
1.11.59

0 comments on commit 796226b

Please sign in to comment.