Skip to content

Commit

Permalink
organized project structure into ./src
Browse files Browse the repository at this point in the history
  • Loading branch information
tanjeffreyz committed May 26, 2022
1 parent 1d592a0 commit c6b7568
Show file tree
Hide file tree
Showing 35 changed files with 66 additions and 85 deletions.
9 changes: 3 additions & 6 deletions command_books/blaster.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
"""A collection of all commands that a Blaster can use to interact with the game."""

import config
import time
import math
import settings
import utils
from components import Command
from vkeys import press, key_down, key_up
from src.common import settings
from src.routine.components import Command
from src.common.vkeys import press, key_down, key_up

#
# class Move(Command):
Expand Down
8 changes: 3 additions & 5 deletions command_books/kanna.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"""A collection of all commands that a Kanna can use to interact with the game."""

import config
from src.common import config, settings, utils
import time
import math
import settings
import utils
from components import Command
from vkeys import press, key_down, key_up
from src.routine.components import Command
from src.common.vkeys import press, key_down, key_up


# List of key mappings
Expand Down
4 changes: 2 additions & 2 deletions gui_components/edit/commands.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import tkinter as tk

import config
from components import Point
from src.common import config
from src.routine.components import Point
from gui_components.interfaces import Frame


Expand Down
5 changes: 2 additions & 3 deletions gui_components/edit/components.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import tkinter as tk

import config
from components import Point
from src.common import config
from src.routine.components import Point
from gui_components.interfaces import Frame


Expand Down
3 changes: 1 addition & 2 deletions gui_components/edit/controls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import tkinter as tk

import config
from src.common import config
from gui_components.interfaces import Frame


Expand Down
4 changes: 2 additions & 2 deletions gui_components/edit/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Allows the user to edit routines while viewing each Point's location on the minimap."""

import config
from src.common import config
import inspect
import tkinter as tk
from components import Point, Command
from src.routine.components import Point, Command
from gui_components.edit.minimap import Minimap
from gui_components.edit.record import Record
from gui_components.edit.routine import Routine
Expand Down
7 changes: 2 additions & 5 deletions gui_components/edit/minimap.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import tkinter as tk

import cv2
from PIL import ImageTk, Image

import config
import utils
from components import Point
from src.common import config, utils
from src.routine.components import Point
from gui_components.interfaces import LabelFrame


Expand Down
3 changes: 1 addition & 2 deletions gui_components/edit/record.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import tkinter as tk

from components import Point
from src.routine.components import Point
from gui_components.interfaces import LabelFrame


Expand Down
1 change: 0 additions & 1 deletion gui_components/edit/routine.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import tkinter as tk

from gui_components.edit.commands import Commands
from gui_components.edit.components import Components
from gui_components.edit.controls import Controls
Expand Down
3 changes: 1 addition & 2 deletions gui_components/edit/status.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import tkinter as tk

import config
from src.common import config
from gui_components.interfaces import LabelFrame


Expand Down
4 changes: 1 addition & 3 deletions gui_components/menu/main.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"""A menu for loading routines and command books."""

import config
import utils
from src.common import config, utils
import queue
import tkinter as tk
from tkinter.filedialog import askopenfilename, asksaveasfilename
from tkinter.messagebox import askyesno
from bot import Bot


class Menu(tk.Menu):
Expand Down
3 changes: 1 addition & 2 deletions gui_components/settings/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Displays Auto Maple's current settings and allows the user to edit them."""

import config
import utils
from src.common import config, utils
import tkinter as tk
import keyboard as kb
from gui_components.interfaces import Tab, Frame, LabelFrame
Expand Down
5 changes: 2 additions & 3 deletions gui_components/view/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""Displays the current minimap as well as various information regarding the current routine."""

import config
import utils
from src.common import config, utils
import cv2
import tkinter as tk
from gui_components.interfaces import LabelFrame, Tab
from components import Point
from src.routine.components import Point
from PIL import Image, ImageTk


Expand Down
Binary file removed layouts/bd1
Binary file not shown.
Binary file removed layouts/cf1
Binary file not shown.
Binary file removed layouts/dcsa
Binary file not shown.
Binary file modified layouts/dcup2
Binary file not shown.
Binary file removed layouts/hft
Binary file not shown.
Binary file removed layouts/mts3
Binary file not shown.
Binary file removed layouts/srs1
Binary file not shown.
10 changes: 5 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""The central program that ties all the modules together."""

import time
from bot import Bot
from capture import Capture
from notifier import Notifier
from listener import Listener
from gui import GUI
from src.modules.bot import Bot
from src.modules.capture import Capture
from src.modules.notifier import Notifier
from src.modules.listener import Listener
from src.modules.gui import GUI


bot = Bot()
Expand Down
11 changes: 6 additions & 5 deletions routines/dcup2.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
$, target=record_layout, value=True
$, target=move_tolerance, value=0.075

@, label=main
Expand All @@ -8,7 +9,7 @@ $, target=move_tolerance, value=0.075
Shikigami, direction=right, attacks=2, repetitions=1
>, label=loot, frequency=4, skip=False
*, x=0.873, y=0.200, frequency=1, skip=False, adjust=False
Fall, distance=0.05
Fall, distance=0.02

@, label=afterboss
*, x=0.055, y=0.125, frequency=1, skip=False, adjust=False
Expand Down Expand Up @@ -37,7 +38,7 @@ $, target=move_tolerance, value=0.075
Walk, direction=left, duration=0.2
Shikigami, direction=left, attacks=2, repetitions=1
*, x=0.225, y=0.200, frequency=1, skip=False, adjust=False
Fall, distance=0.05
Fall, distance=0.02
Walk, direction=left, duration=0.2
Tengu
*, x=0.660, y=0.083, frequency=1, skip=False, adjust=False
Expand All @@ -59,7 +60,7 @@ $, target=move_tolerance, value=0.075
Shikigami, direction=right, attacks=2, repetitions=1
>, label=boss2, frequency=5, skip=True
*, x=0.873, y=0.200, frequency=1, skip=False, adjust=False
Fall, distance=0.05
Fall, distance=0.02
Walk, direction=right, duration=0.2

@, label=afterboss2
Expand All @@ -76,8 +77,8 @@ $, target=move_tolerance, value=0.075
Teleport, direction=left, jump=False
Yaksha, direction=left
*, x=0.750, y=0.200, frequency=3, skip=True, adjust=False
Fall, distance=0.05
Fall, distance=0.02
>, label=afterboss, frequency=3, skip=True
*, x=0.750, y=0.200, frequency=1, skip=False, adjust=False
Fall, distance=0.05
Fall, distance=0.02
>, label=afterboss2, frequency=1, skip=False
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions utils.py → src/common/utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""A collection of functions and classes used across multiple modules."""

import config
import settings
import math
import queue
import cv2
import threading
import numpy as np
from src.common import config, settings
from random import random


Expand Down
2 changes: 1 addition & 1 deletion vkeys.py → src/common/vkeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import ctypes
import time
import utils
import win32con
import win32api
from src.common import utils
from ctypes import wintypes
from random import random

Expand Down
4 changes: 2 additions & 2 deletions detection.py → src/detection/detection.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""A module for classifying directional arrows using TensorFlow."""

import utils
import cv2
import tensorflow as tf
import numpy as np
from src.common import utils


#########################
Expand Down Expand Up @@ -178,7 +178,7 @@ def merge_detection(model, image):

# Script for testing the detection module by itself
if __name__ == '__main__':
import config
from src.common import config, utils
import mss
config.enabled = True
monitor = {'top': 0, 'left': 0, 'width': 1366, 'height': 768}
Expand Down
22 changes: 13 additions & 9 deletions bot.py → src/modules/bot.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
"""An interpreter that reads and executes user-created routines."""

import config
import detection

import threading
import time
import cv2
import utils
import inspect
import components
import numpy as np
from PIL import ImageGrab
from os.path import splitext, basename
from routine import Routine
from components import Point
from vkeys import press, click
from src.common import config, utils
from src.detection import detection
from src.routine import components
from src.routine.routine import Routine
from src.routine.components import Point
from src.common.vkeys import press, click


# The rune's buff icon
Expand Down Expand Up @@ -117,12 +117,16 @@ def _solve_rune(self, model):
time.sleep(0.3)
frame = np.array(ImageGrab.grab(config.capture.window))
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
rune_buff = utils.multi_match(frame[:frame.shape[0]//8, :],
rune_buff = utils.multi_match(frame[:frame.shape[0] // 8, :],
RUNE_BUFF_TEMPLATE,
threshold=0.9)
if rune_buff:
rune_buff_pos = min(rune_buff, key=lambda p: p[0])
click(rune_buff_pos, button='right')
click(
(rune_buff_pos[0] + config.capture.window[0],
rune_buff_pos[1] + config.capture.window[0]),
button='right'
)
break
elif len(solution) == 4:
inferences.append(solution)
Expand Down
3 changes: 1 addition & 2 deletions capture.py → src/modules/capture.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""A module for tracking useful in-game information."""

import config
import utils
import time
import cv2
import threading
import ctypes
import numpy as np
from src.common import config, utils
from ctypes import wintypes
from PIL import ImageGrab
user32 = ctypes.windll.user32
Expand Down
5 changes: 2 additions & 3 deletions gui.py → src/modules/gui.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""User friendly GUI to interact with Auto Maple."""

import config
import tkinter as tk
from tkinter import ttk
import settings
from src.common import config, settings
from gui_components import Menu, View, Edit, Settings


Expand Down Expand Up @@ -76,7 +75,7 @@ def start(self):
self._save_layout()
self.root.mainloop()

def _save_layout(self):
def _save_layout(self): # TODO: move to bot main loop, file I/O is costly, blocks gui main loop
"""Periodically saves the current Layout object."""

if config.layout is not None and settings.record_layout:
Expand Down
3 changes: 1 addition & 2 deletions listener.py → src/modules/listener.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""A keyboard listener to track user inputs."""

import config
import time
import utils
import threading
import winsound
import pickle
import keyboard as kb
from src.common import config, utils
from os.path import isfile
from datetime import datetime

Expand Down
7 changes: 3 additions & 4 deletions notifier.py → src/modules/notifier.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
"""A module for detecting and notifying the user of dangerous in-game events."""

import config
import utils
from src.common import config, utils
import time
import cv2
import pygame
import threading
import numpy as np
import keyboard as kb
from components import Point
from src.routine.components import Point


# A rune's symbol on the minimap
Expand Down Expand Up @@ -57,7 +56,7 @@ def _main(self):

# Check for unexpected black screen
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
if np.count_nonzero(gray < 15) / height / width > 0.75:
if np.count_nonzero(gray < 15) / height / width > 0.9:
self._alert()

# Check for elite warning
Expand Down
Loading

0 comments on commit c6b7568

Please sign in to comment.