Skip to content

Commit

Permalink
Release v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectricityMachine committed Mar 22, 2023
1 parent d29d8c7 commit e4dfd20
Show file tree
Hide file tree
Showing 4 changed files with 198 additions and 25 deletions.
175 changes: 175 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# Python gitignore
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<h1><b> ATTENTION: A new SCR update has broken the functionality of the script. If you notice a "Desk Exit" dialog appear when you change a signal, please try a different server or don't use the script. </b></h1>

Reproducing this issue has been tricky, it seems to work some times but not other times. If you are affected by the issue, remember it is NOT caused by me, but rather an SCR/ROBLOX update.

<h1 align="center">SCR: SG+</h1>

<h1 align="center">
Expand All @@ -25,17 +21,18 @@ SG+ is a macro script written in Python that streamlines your signalling experie
### Features
- Only one button press is needed to change a signal aspect
- Decreases setup and train clearing time significantly
- Allows the signaller to focus on more important things than just clicking to change aspects
- Quickly get in and out of a camera view (signals only for now)
- Toggle rollback on or off
- Audible warning if you try to chat or run commands with the macro enabled

### Planned features:
- Rewrite camera code to use the aspect code to detect the image
- Implement a visual indicator
- Premade chat messages on numpad
- TRTS Audio cue
- Station cameras
- Auto terminus station setup

### Known issues:
- Sometimes, pressing C to enter the camera view of a signal does not work correctly. This is due to changes in 1.9 with the signalling interface and requires a rewrite to make fully functional. Because this is a low-priority feature of this script, especially because the cameras have rendering bugs in the current version, it will not be fixed for a while until the cameras in-game are fixed.
### Limitations:
- Windows only
- Primary monitor only

### Controls:

Expand All @@ -46,7 +43,8 @@ SG+ is a macro script written in Python that streamlines your signalling experie
|1|Change currently hovered signal to Danger|
|2|Change currently hovered signal to Caution|
|3|Change currently hovered signal to Proceed|
|C|Enter camera mode of currently hovered signal. If you are already in camera mode, it will exit camera mode|
|C|Enter camera mode of the currently hovered signal. If you are already in camera mode, it will exit camera mode|
|R|Toggle rollback of the currently hovered signal
---

### **Installation**
Expand All @@ -67,4 +65,4 @@ SG+ is a macro script written in Python that streamlines your signalling experie
By using this script, you MUST adhere to the license terms in the LICENSE file.

### Contact information
If you have issues or need to contact me, please reach me on Discord at ElectricityMachine (hashtag) One Seven Five Three. The Discord username is spelt that way to avoid scrapers and bots.
If you have issues or need to contact me, please reach me on Discord at ElectricityMachine (hashtag) One Seven Five Three. The Discord username is spelt that way to avoid scrapers and bots.
10 changes: 6 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
autoit==0.2.4
autoit==0.2.6
colorama==0.4.4
keyboard==0.13.5
Pillow==9.3.0
mss==7.0.1
Pillow==9.4.0
PyAutoGUI==0.9.53
PyAutoIt==0.6.5
PyGetWindow==0.0.9
pyperclip==1.8.2
PyScreeze==0.1.28
pywin32==303
opencv-python==4.5.5.62
requests==2.27.1
requests==2.28.2
16 changes: 7 additions & 9 deletions script.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
dialog_wait = 0.085 # Length of time to wait for gray signal dialog to show up. You can reduce this if your system can hold a steady framerate, for example, 0.055. This will make the script more responsive to your inputs
menu_wait = 0.04 # Length of time to wait for side menu (view camera, rollback, info) to show up
debug = False # If true, will enable debug prints if they're specified
check_for_update = False
check_for_update = True

color_dialog_buttons = {
(0, 201, 0), # Lit Green
Expand All @@ -42,7 +42,6 @@
color_more = (92, 89, 89) # Color of gray button w/ 3 dots
color_menu = (194, 186, 189) # Side menu main color
color_camera_exit = (255, 255, 255) # White "X" on the close button in camera view
color_dialog_text = (159, 153, 153)
color_dialog_white = (227, 218, 218) # White elements in the signal dialog
color_viewcamera = (147, 0, 207) # Purple "View Camera" button

Expand Down Expand Up @@ -158,10 +157,10 @@ def click_camera_button():
def toggle_disable():
global disabled
if disabled:
disabled = not disabled
disabled = False
winsound.Beep(500, 100)
else:
disabled = not disabled
disabled = True
winsound.Beep(400, 100)


Expand All @@ -177,7 +176,7 @@ def scan_for_dialog(type):
y = bbox[1]
w = bbox[2]
h = bbox[3]
if type == "signal":
if type == "signal": # Gray signal dialog
# Wait for a set time before checking if the dialog actually pops up. This ensures there should be no time where the script screengrabs and the dialog isn't open after clicking on a signal.
time.sleep(dialog_wait)

Expand Down Expand Up @@ -219,7 +218,7 @@ def scan_for_dialog(type):
return True
else:
return False
elif type == "exitcamera":
elif type == "exitcamera": # Red "X" button at the top of screen when in a camera view
camera_controls_width = 283
camera_controls_x = math.ceil(w / 2 - camera_controls_width / 2)

Expand Down Expand Up @@ -247,7 +246,7 @@ def scan_for_dialog(type):
break
if flag:
return True
elif type == "uncontrolled":
elif type == "uncontrolled": # Gray signal dialog that isn't controlled by us
dialogbox_height = math.ceil(h * 0.125)
dialogbox_width = math.ceil(dialogbox_height * 2)
dialogbox_x = mousex - dialogbox_width / 2
Expand All @@ -265,7 +264,6 @@ def scan_for_dialog(type):
upperw, upperh = upper.size
uppershelf = upper.crop((0, upperh * 0.1, upperw / 2, upperh * 0.1 + 2))
imagesToProcess = [lowershelf, uppershelf]
uppershelf.save("debug.png")
white_pixels = 0
flag = False
for image in imagesToProcess:
Expand All @@ -285,7 +283,7 @@ def scan_for_dialog(type):
return True
else:
return False
elif type == "viewcamera":
elif type == "viewcamera": # Purple "View Camera" button in sidemenu
zone_screen_height = math.ceil(0.97735 * h)
zone_screen_width = math.ceil(zone_screen_height * 1.34105)
zone_screen_x = math.ceil(w / 2 - zone_screen_width / 2)
Expand Down

0 comments on commit e4dfd20

Please sign in to comment.