added mining ui mode
This commit is contained in:
2
Mine.py
2
Mine.py
@@ -3,7 +3,7 @@ import cv2 as cv
|
|||||||
from utils import dig_point, check_for_ok_button
|
from utils import dig_point, check_for_ok_button
|
||||||
from window_capture import WindowCapture
|
from window_capture import WindowCapture
|
||||||
from vision import Vision
|
from vision import Vision
|
||||||
from dig_overlay import DiggingOverlay
|
from mine_overlay import DiggingOverlay
|
||||||
|
|
||||||
|
|
||||||
class Mine:
|
class Mine:
|
||||||
|
|||||||
@@ -2,13 +2,14 @@
|
|||||||
import threading
|
import threading
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
|
from mine_overlay import DiggingOverlay
|
||||||
|
|
||||||
|
|
||||||
class PrimaryOverlay(threading.Thread):
|
class PrimaryOverlay(threading.Thread):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
self.MiningOverlay = DiggingOverlay
|
||||||
self.run_mode = 'init'
|
self.run_mode = 'init'
|
||||||
|
|
||||||
self.root = tk.Tk
|
self.root = tk.Tk
|
||||||
@@ -47,9 +48,11 @@ class PrimaryOverlay(threading.Thread):
|
|||||||
self.StatusLabel = tk.Label
|
self.StatusLabel = tk.Label
|
||||||
|
|
||||||
# self.TkPosition = config.returnEnemyPlayerOverlayPos()
|
# self.TkPosition = config.returnEnemyPlayerOverlayPos()
|
||||||
|
|
||||||
self.start()
|
self.start()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
self.MiningOverlay = DiggingOverlay()
|
||||||
self.root = tk.Tk()
|
self.root = tk.Tk()
|
||||||
|
|
||||||
self.rb_frame = tk.Frame(self.root)
|
self.rb_frame = tk.Frame(self.root)
|
||||||
@@ -118,9 +121,12 @@ class PrimaryOverlay(threading.Thread):
|
|||||||
self.root.attributes('-topmost', 1) # fenster immer im vordergrund
|
self.root.attributes('-topmost', 1) # fenster immer im vordergrund
|
||||||
# self.root.wm_attributes("-disabled", True)
|
# self.root.wm_attributes("-disabled", True)
|
||||||
# self.root.configure(background='black')
|
# self.root.configure(background='black')
|
||||||
|
self.hide_mining_overlay()
|
||||||
self.root.mainloop()
|
self.root.mainloop()
|
||||||
|
|
||||||
|
def callback(self):
|
||||||
|
self.root.quit()
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
self.root.destroy()
|
self.root.destroy()
|
||||||
|
|
||||||
@@ -136,8 +142,6 @@ class PrimaryOverlay(threading.Thread):
|
|||||||
self.StatusLabel.configure(text='started')
|
self.StatusLabel.configure(text='started')
|
||||||
self.run_mode = 'started'
|
self.run_mode = 'started'
|
||||||
|
|
||||||
# self.EnemyLabel.pack()
|
|
||||||
|
|
||||||
def stop_button_callback(self):
|
def stop_button_callback(self):
|
||||||
self.StartButton.configure(state=tk.NORMAL)
|
self.StartButton.configure(state=tk.NORMAL)
|
||||||
self.StopButton.configure(state=tk.DISABLED)
|
self.StopButton.configure(state=tk.DISABLED)
|
||||||
@@ -169,6 +173,7 @@ class PrimaryOverlay(threading.Thread):
|
|||||||
self.SpawnLabel.configure(text="Spawn:")
|
self.SpawnLabel.configure(text="Spawn:")
|
||||||
self.EnergyLabel.configure(text="Runs:")
|
self.EnergyLabel.configure(text="Runs:")
|
||||||
self.emitter_use.set('multi')
|
self.emitter_use.set('multi')
|
||||||
|
self.hide_mining_overlay()
|
||||||
elif self.rb_int.get() == 2 or self.rb_int.get() == 3:
|
elif self.rb_int.get() == 2 or self.rb_int.get() == 3:
|
||||||
self.EnergyEntry.configure(state=tk.DISABLED)
|
self.EnergyEntry.configure(state=tk.DISABLED)
|
||||||
self.energy_use.set('')
|
self.energy_use.set('')
|
||||||
@@ -179,6 +184,7 @@ class PrimaryOverlay(threading.Thread):
|
|||||||
self.EmitterLabel.configure(text="")
|
self.EmitterLabel.configure(text="")
|
||||||
self.SpawnLabel.configure(text="")
|
self.SpawnLabel.configure(text="")
|
||||||
self.EnergyLabel.configure(text="")
|
self.EnergyLabel.configure(text="")
|
||||||
|
self.hide_mining_overlay()
|
||||||
elif self.rb_int.get() == 4:
|
elif self.rb_int.get() == 4:
|
||||||
self.EnergyEntry.configure(state=tk.DISABLED)
|
self.EnergyEntry.configure(state=tk.DISABLED)
|
||||||
self.energy_use.set('')
|
self.energy_use.set('')
|
||||||
@@ -189,6 +195,7 @@ class PrimaryOverlay(threading.Thread):
|
|||||||
self.EmitterLabel.configure(text="")
|
self.EmitterLabel.configure(text="")
|
||||||
self.SpawnLabel.configure(text="Spawn:")
|
self.SpawnLabel.configure(text="Spawn:")
|
||||||
self.EnergyLabel.configure(text="")
|
self.EnergyLabel.configure(text="")
|
||||||
|
self.hide_mining_overlay()
|
||||||
elif self.rb_int.get() == 5:
|
elif self.rb_int.get() == 5:
|
||||||
self.EnergyEntry.configure(state=tk.NORMAL)
|
self.EnergyEntry.configure(state=tk.NORMAL)
|
||||||
self.energy_use.set('100')
|
self.energy_use.set('100')
|
||||||
@@ -200,6 +207,7 @@ class PrimaryOverlay(threading.Thread):
|
|||||||
self.EmitterLabel.configure(text="Mode:")
|
self.EmitterLabel.configure(text="Mode:")
|
||||||
self.SpawnLabel.configure(text="")
|
self.SpawnLabel.configure(text="")
|
||||||
self.EnergyLabel.configure(text="Runs:")
|
self.EnergyLabel.configure(text="Runs:")
|
||||||
|
self.hide_mining_overlay()
|
||||||
elif self.rb_int.get() == 6:
|
elif self.rb_int.get() == 6:
|
||||||
self.EnergyEntry.configure(state=tk.NORMAL)
|
self.EnergyEntry.configure(state=tk.NORMAL)
|
||||||
self.energy_use.set('2')
|
self.energy_use.set('2')
|
||||||
@@ -210,6 +218,7 @@ class PrimaryOverlay(threading.Thread):
|
|||||||
self.EmitterLabel.configure(text="")
|
self.EmitterLabel.configure(text="")
|
||||||
self.SpawnLabel.configure(text="")
|
self.SpawnLabel.configure(text="")
|
||||||
self.EnergyLabel.configure(text="Runs:")
|
self.EnergyLabel.configure(text="Runs:")
|
||||||
|
self.show_mining_overlay()
|
||||||
|
|
||||||
#
|
#
|
||||||
def get_run_mode(self):
|
def get_run_mode(self):
|
||||||
@@ -217,3 +226,9 @@ class PrimaryOverlay(threading.Thread):
|
|||||||
|
|
||||||
def update_status_label(self, msg):
|
def update_status_label(self, msg):
|
||||||
self.StatusLabel.configure(text=msg)
|
self.StatusLabel.configure(text=msg)
|
||||||
|
|
||||||
|
def hide_mining_overlay(self):
|
||||||
|
self.MiningOverlay.hide_window()
|
||||||
|
|
||||||
|
def show_mining_overlay(self):
|
||||||
|
self.MiningOverlay.show_window()
|
||||||
|
|||||||
202
digging_main2.py
202
digging_main2.py
@@ -1,202 +0,0 @@
|
|||||||
import sys
|
|
||||||
|
|
||||||
from config_file import UserConfigs
|
|
||||||
import keyboard
|
|
||||||
import cv2 as cv
|
|
||||||
from utils import dig_point, check_for_ok_button
|
|
||||||
from window_capture import WindowCapture
|
|
||||||
from vision import Vision
|
|
||||||
from dig_overlay import DiggingOverlay
|
|
||||||
|
|
||||||
|
|
||||||
def run():
|
|
||||||
# initialize the user-class
|
|
||||||
config = UserConfigs()
|
|
||||||
# initialize the StunWindowCapture class
|
|
||||||
capture_config = UserConfigs()
|
|
||||||
capture_window = WindowCapture(None, "screen_conf", capture_config)
|
|
||||||
|
|
||||||
# initialize the StunVision class
|
|
||||||
vision_stun = Vision()
|
|
||||||
dig_overlay = DiggingOverlay(config)
|
|
||||||
|
|
||||||
pause = True
|
|
||||||
level = 1
|
|
||||||
|
|
||||||
width = 32
|
|
||||||
depth = 24
|
|
||||||
plot_size = 45
|
|
||||||
DIG_TIME = 100
|
|
||||||
|
|
||||||
runcounter = 2
|
|
||||||
|
|
||||||
if runcounter == 2:
|
|
||||||
double_dig = True
|
|
||||||
else:
|
|
||||||
double_dig = False
|
|
||||||
|
|
||||||
while runcounter != 0:
|
|
||||||
if double_dig and runcounter == 1:
|
|
||||||
dig_point(290, 100, 200)
|
|
||||||
level = 1
|
|
||||||
plot_size = 45
|
|
||||||
DIG_TIME = 100
|
|
||||||
cv.waitKey(2000)
|
|
||||||
runcounter = runcounter - 1
|
|
||||||
|
|
||||||
while True:
|
|
||||||
if keyboard.is_pressed('p') == True:
|
|
||||||
pause = True
|
|
||||||
print('q pressed')
|
|
||||||
elif keyboard.is_pressed('o') == True:
|
|
||||||
pause = False
|
|
||||||
print('o pressed')
|
|
||||||
if pause:
|
|
||||||
# cv.waitKey(500)
|
|
||||||
dig_overlay.show_window()
|
|
||||||
print("pausing")
|
|
||||||
continue
|
|
||||||
dig_overlay.hide_window()
|
|
||||||
|
|
||||||
if level >= 28:
|
|
||||||
break
|
|
||||||
if level == 23:
|
|
||||||
DIG_TIME = 800
|
|
||||||
if level == 26:
|
|
||||||
DIG_TIME = 1800
|
|
||||||
if level <= 10:
|
|
||||||
plot_size = plot_size - 1
|
|
||||||
elif level % 2 == 0:
|
|
||||||
plot_size = plot_size - 1
|
|
||||||
|
|
||||||
p1 = int((config.returnDiggingWindowPos2()[0] / 2) + config.returnDiggingWindowPos2()[2])
|
|
||||||
p2 = int((config.returnDiggingWindowPos2()[1] / 2) + config.returnDiggingWindowPos2()[3])
|
|
||||||
|
|
||||||
# start 705 , 564 -> click
|
|
||||||
# move L D -> click
|
|
||||||
# move U , U , R, R , D , D , L , L
|
|
||||||
# move L D
|
|
||||||
# move U , U , U , U , R, R , R, R, D, D, D, D, L, L, L , L
|
|
||||||
dig_point(p1, p2, DIG_TIME)
|
|
||||||
# cv.circle(screenshot, (p1, p2), 7, (0, 255, 0), -1)
|
|
||||||
i = 0
|
|
||||||
for e in range(2, width, 2):
|
|
||||||
i = i + 1
|
|
||||||
|
|
||||||
tp1 = p1 - (i * plot_size)
|
|
||||||
tp2 = p2 + (i * plot_size)
|
|
||||||
for f in range(0, e, 1):
|
|
||||||
# up click
|
|
||||||
tp2 = tp2 - plot_size
|
|
||||||
if tp2 >= config.returnDiggingWindowPos2()[1] + (plot_size / 2):
|
|
||||||
continue
|
|
||||||
if tp2 <= config.returnDiggingWindowPos2()[3] + (plot_size / 2):
|
|
||||||
continue
|
|
||||||
'''
|
|
||||||
x = int(tp1 - (plot_size / 2))
|
|
||||||
y = int(tp2 - ((e * plot_size) - (plot_size / 2)))
|
|
||||||
w = plot_size
|
|
||||||
h = plot_size * e
|
|
||||||
|
|
||||||
capture_win_lanes = WindowCapture(None, "lanes", None, (w, h, x+w, y+h))
|
|
||||||
screenshot = capture_win_lanes.get_screenshot()
|
|
||||||
needlew = cv.imread("test1.jpg", cv.IMREAD_UNCHANGED)
|
|
||||||
res = vision_stun.find(needlew, screenshot, 0.9, 1)
|
|
||||||
if len(res) >= 1:
|
|
||||||
break
|
|
||||||
#vision_stun.draw_rectangles(needlew, res)
|
|
||||||
#cv.imshow("screenshot", needlew)
|
|
||||||
#cv.waitKey(150)
|
|
||||||
|
|
||||||
|
|
||||||
# ul[0], ul[1], plot_size, plotsize*e
|
|
||||||
|
|
||||||
# ll -> tp1 - plot/2 ooooooooooo
|
|
||||||
# -> tp2 + plot/2
|
|
||||||
# ul -> tp1 - plot/2
|
|
||||||
# -> tp2 - e*plot - plot/2
|
|
||||||
# lr -> tp1 + plot/2
|
|
||||||
# -> tp2 - plot/2
|
|
||||||
# ur -> tp1 + plot/2
|
|
||||||
# -> tp2 - e*plot - plot/2
|
|
||||||
'''
|
|
||||||
dig_point(tp1, tp2, DIG_TIME)
|
|
||||||
# cv.circle(screenshot, (tp1, tp2), 7, (255, 0, 255), -1)
|
|
||||||
# cv.imshow("screenshot", screenshot)
|
|
||||||
# cv.waitKey(150)
|
|
||||||
check_for_ok_button(capture_window, vision_stun, capture_config)
|
|
||||||
if keyboard.is_pressed('p') == True or pause == True:
|
|
||||||
pause = True
|
|
||||||
break
|
|
||||||
|
|
||||||
tp1 = p1 - (i * plot_size)
|
|
||||||
tp2 = p2 - (i * plot_size)
|
|
||||||
for g in range(0, e, 1):
|
|
||||||
# right click
|
|
||||||
tp1 = tp1 + plot_size
|
|
||||||
if tp2 <= config.returnDiggingWindowPos2()[3] + (plot_size / 2):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# ll -> tp1 - plot/2
|
|
||||||
# -> tp2 + plot/2
|
|
||||||
# ul -> tp1 - plot/2
|
|
||||||
# -> tp2 - plot/2
|
|
||||||
# lr -> tp1 + e*plot + plot/2
|
|
||||||
# -> tp2 + plot/2
|
|
||||||
# ur -> tp1 + e*plot + plot/2
|
|
||||||
# -> tp2 - plot/2
|
|
||||||
|
|
||||||
dig_point(tp1, tp2, DIG_TIME)
|
|
||||||
# cv.circle(screenshot, (tp1, tp2), 7, (127, 0, 255), -1)
|
|
||||||
# cv.imshow("screenshot", screenshot)
|
|
||||||
# cv.waitKey(150)
|
|
||||||
check_for_ok_button(capture_window, vision_stun, capture_config)
|
|
||||||
if keyboard.is_pressed('p') == True or pause == True:
|
|
||||||
pause = True
|
|
||||||
break
|
|
||||||
|
|
||||||
tp1 = p1 + (i * plot_size)
|
|
||||||
tp2 = p2 - (i * plot_size)
|
|
||||||
for r in range(0, e, 1):
|
|
||||||
# down click
|
|
||||||
tp2 = tp2 + plot_size
|
|
||||||
if tp2 >= config.returnDiggingWindowPos2()[1] + (plot_size / 2):
|
|
||||||
continue
|
|
||||||
if tp2 <= config.returnDiggingWindowPos2()[3] + (plot_size / 2):
|
|
||||||
continue
|
|
||||||
dig_point(tp1, tp2, DIG_TIME)
|
|
||||||
# cv.circle(screenshot, (tp1, tp2), 7, (255, 0, 127), -1)
|
|
||||||
# cv.imshow("screenshot", screenshot)
|
|
||||||
# cv.waitKey(150)
|
|
||||||
check_for_ok_button(capture_window, vision_stun, capture_config)
|
|
||||||
if keyboard.is_pressed('p') == True or pause == True:
|
|
||||||
pause = True
|
|
||||||
break
|
|
||||||
|
|
||||||
tp1 = p1 + (i * plot_size)
|
|
||||||
tp2 = p2 + (i * plot_size)
|
|
||||||
for u in range(0, e, 1):
|
|
||||||
# left click
|
|
||||||
tp1 = tp1 - plot_size
|
|
||||||
if tp2 >= config.returnDiggingWindowPos2()[1] + (plot_size / 2):
|
|
||||||
continue
|
|
||||||
dig_point(tp1, tp2, DIG_TIME)
|
|
||||||
# cv.circle(screenshot, (tp1, tp2), 7, (0, 0, 255), -1)
|
|
||||||
# cv.imshow("screenshot", screenshot)
|
|
||||||
# cv.waitKey(150)
|
|
||||||
check_for_ok_button(capture_window, vision_stun, capture_config)
|
|
||||||
if keyboard.is_pressed('p') == True or pause == True:
|
|
||||||
pause = True
|
|
||||||
break
|
|
||||||
if keyboard.is_pressed('p') == True or pause == True:
|
|
||||||
pause = True
|
|
||||||
break
|
|
||||||
if keyboard.is_pressed('p') == True or pause == True:
|
|
||||||
pause = True
|
|
||||||
break
|
|
||||||
level = level + 1
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
run()
|
|
||||||
sys.exit()
|
|
||||||
@@ -5,16 +5,19 @@ import tkinter as tk
|
|||||||
|
|
||||||
class DiggingOverlay(threading.Thread):
|
class DiggingOverlay(threading.Thread):
|
||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
self.root = tk.Tk
|
self.root = tk.Tk
|
||||||
self.EnemyLabel = tk.Label
|
self.EnemyLabel = tk.Label
|
||||||
self.TkPosition = config.returnDiggingOverlayPos()
|
self.TkPosition = '1440x1150+570+22'
|
||||||
self.start()
|
self.start()
|
||||||
|
|
||||||
def callback(self):
|
def callback(self):
|
||||||
self.root.quit()
|
self.root.quit()
|
||||||
|
|
||||||
|
def destroy(self):
|
||||||
|
self.root.destroy()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.root = tk.Tk()
|
self.root = tk.Tk()
|
||||||
self.root.geometry(self.TkPosition)
|
self.root.geometry(self.TkPosition)
|
||||||
Reference in New Issue
Block a user