Skip to content

Commit

Permalink
UI fixed and changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tumppi066 committed Feb 24, 2024
1 parent 6c6c29c commit 65faa68
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 13 deletions.
5 changes: 5 additions & 0 deletions blog/V1.10.Minor.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ title: Version 1.10 > Minor
This changelog will contain all changes from 1.10.0 onwards before the next major version.
!!!

==- Version 1.10.27
Fix UIs and PluginFrames not correctly resetting. This manifested as weird UI bugs after a reload.
Added a favorites bar.
Slightly tweaked the plugin manager to make it fit in the frame correctly.
[!badge variant="dark" text="Tumppi066"] [!badge variant="ghost" text="Main UI"] [!badge variant="ghost" text="Plugin Manager"]
==- Version 1.10.26
The app will no longer hang when the server is not available.
[!badge variant="dark" text="Tumppi066"] [!badge variant="ghost" text="App Backend"]
Expand Down
4 changes: 3 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
The app will no longer hang when the server is not available.
Fix UIs and PluginFrames not correctly resetting. This manifested as weird UI bugs after a reload.
Added a favorites bar.
Slightly tweaked the plugin manager to make it fit in the frame correctly.
10 changes: 5 additions & 5 deletions plugins/PluginManager/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, master) -> None:
self.lastTheme = settings.GetSettings("User Interface", "Theme")
self.lastPlugin = 0
self.lastList = 0
resizeWindow(1220, 700)
resizeWindow(1220, 715)
self.page0()
self.selectedPlugin(self.plugins[0])
self.keybindTimer = time.time()
Expand All @@ -68,7 +68,7 @@ def destroy(self):
del self

def tabFocused(self):
resizeWindow(1220, 700)
resizeWindow(1220, 715)

def page0(self):

Expand All @@ -91,17 +91,17 @@ def page0(self):
self.screenCaptureVariable = tk.StringVar()
self.screenCaptureVariable.set([helpers.ConvertCapitalizationToSpaces(p.PluginInfo.name) for p in self.plugins if p.PluginInfo.exclusive == "ScreenCapture"])

self.pluginList = tk.Listbox(self.root, width=20, height=31, listvariable=self.listVariable, font=("Roboto", 12), selectmode="single", activestyle="none", justify="center")
self.pluginList = tk.Listbox(self.root, width=20, height=30, listvariable=self.listVariable, font=("Roboto", 12), selectmode="single", activestyle="none", justify="center")
self.pluginList.grid(row=2, column=0, padx=10, pady=2)
# Bind double click
self.pluginList.bind('<Double-Button>', lambda x: self.switchPluginState(self.pluginList.curselection()[0], self.pluginList))

self.laneDetectionList = tk.Listbox(self.root, width=20, height=31, listvariable=self.laneDetectionVariable, font=("Roboto", 12), selectmode="single", activestyle="none", justify="center")
self.laneDetectionList = tk.Listbox(self.root, width=20, height=30, listvariable=self.laneDetectionVariable, font=("Roboto", 12), selectmode="single", activestyle="none", justify="center")
self.laneDetectionList.grid(row=2, column=1, padx=10, pady=2)
# Bind double click
self.laneDetectionList.bind('<Double-Button>', lambda x: self.switchPluginState(self.laneDetectionList.curselection()[0], self.laneDetectionList))

self.screenCaptureList = tk.Listbox(self.root, width=20, height=31, listvariable=self.screenCaptureVariable, font=("Roboto", 12), selectmode="single", activestyle="none", justify="center")
self.screenCaptureList = tk.Listbox(self.root, width=20, height=30, listvariable=self.screenCaptureVariable, font=("Roboto", 12), selectmode="single", activestyle="none", justify="center")
self.screenCaptureList.grid(row=2, column=2, padx=10, pady=2)
# Bind double click
self.screenCaptureList.bind('<Double-Button>', lambda x: self.switchPluginState(self.screenCaptureList.curselection()[0], self.screenCaptureList))
Expand Down
69 changes: 63 additions & 6 deletions src/mainUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,13 @@ def switchSelectedPlugin(pluginName:str):
if pluginName.split(".")[1] in notebookNames:
pluginNotebook.select(notebookNames.index(pluginName.split(".")[1]))
ui = UIs[pluginNotebook.index(pluginNotebook.select())]
plugin = __import__(pluginName, fromlist=["UI", "PluginInfo"])
return
else:
if pluginName.split(".")[1] + "." + pluginName.split(".")[2] in notebookNames:
pluginNotebook.select(notebookNames.index(pluginName.split(".")[1] + "." + pluginName.split(".")[2]))
ui = UIs[pluginNotebook.index(pluginNotebook.select())]
plugin = __import__(pluginName, fromlist=["UI", "PluginInfo"])
return

plugin = __import__(pluginName, fromlist=["UI", "PluginInfo"])
Expand Down Expand Up @@ -181,6 +183,22 @@ def quit():
root.destroy()
del root

def addCurrentToFavorites():
"""Will add (or remove) the currently open tab from the favorites."""
try:
tabName = plugin.PluginInfo.name
fullPath = f"plugins.{tabName}.main"
# Check if the tab is already in the favorites
favorites = settings.GetSettings("User Interface", "Favorites", value=["plugins.MainMenu.main"])
if fullPath in favorites:
settings.RemoveFromList("User Interface", "Favorites", fullPath)
else:
settings.AddToList("User Interface", "Favorites", fullPath, exclusive=True)

variables.RELOAD = True
except:
print("Failed to add current tab to favorites")

def drawButtons(refresh:bool=False):
"""Will draw the buttons on the left menu.
Expand All @@ -195,6 +213,9 @@ def drawButtons(refresh:bool=False):
for child in buttonFrame.winfo_children():
child.destroy()

for child in customButtonFrame.winfo_children():
child.destroy()

enableButton = helpers.MakeButton(buttonFrame, "Enable", lambda: (variables.ToggleEnable(), enableButton.config(text=("Disable" if variables.ENABLELOOP else "Enable"))), 0, 0, width=11, padx=9, style="Accent.TButton")
helpers.MakeButton(buttonFrame, "Panels", lambda: switchSelectedPlugin("plugins.PanelManager.main"), 1, 0, width=11, padx=9)
helpers.MakeButton(buttonFrame, "Plugins", lambda: switchSelectedPlugin("plugins.PluginManager.main"), 2, 0, width=11, padx=9)
Expand All @@ -206,6 +227,16 @@ def drawButtons(refresh:bool=False):
import webbrowser
helpers.MakeButton(buttonFrame, "Discord", lambda: webbrowser.open("https://discord.gg/DpJpkNpqwD"), 8, 0, width=11, padx=9, style="Accent.TButton", translate=False)

# Draw the favorites
helpers.MakeButton(customButtonFrame, "Add/Remove", lambda: addCurrentToFavorites(), 0, 0, width=11, padx=9, autoplace=True, style="Accent.TButton")
favorites = settings.GetSettings("User Interface", "Favorites", value=["plugins.MainMenu.main"])
for favorite in favorites:
name = favorite.split(".")[1]
name = helpers.ConvertCapitalizationToSpaces(name)
if len(name) > 11:
name = name[:10] + "..."
helpers.MakeButton(customButtonFrame, name, lambda: switchSelectedPlugin(favorite), 0, 0, width=11, padx=9, autoplace=True)


prevFrame = 100
def update(data:dict):
Expand Down Expand Up @@ -271,10 +302,13 @@ def resizeWindow(newWidth:int, newHeight:int):
# Offsets for the new tabs
newHeight += 20
newWidth += 40
# Offset for the new favorites screen
newWidth += 150

root.geometry(f"{newWidth}x{newHeight}")
pluginNotebook.config(width=newWidth, height=newHeight-20)
buttonFrame.config(height=newHeight-20)
customButtonFrame.config(height=newHeight-20)
root.update()

def changeTheme():
Expand Down Expand Up @@ -326,6 +360,7 @@ def CreateRoot():
"""
global root
global buttonFrame
global customButtonFrame
global pluginFrames
global UIs
global pluginNotebook
Expand Down Expand Up @@ -355,14 +390,14 @@ def CreateRoot():
# the argument is the awareness level, which can be 0, 1 or 2:
# for 1-to-1 pixel control I seem to need it to be non-zero (I'm using level 2)

try:
root.destroy()
except:
pass

width = 800
height = 600

try:
root.destroy()
except:
pass
root = tk.Tk()

UpdateTitle()
Expand Down Expand Up @@ -420,13 +455,31 @@ def CreateRoot():
if showFps:
fpsLabel = ttk.Label(root, textvariable=fps, font=("Roboto", 8)).pack(side="bottom", anchor="s", padx=10, pady=0)

buttonFrame = ttk.LabelFrame(root, text="Lane Assist", width=width-675, height=height-20)

# Button Frame
try:
buttonFrame.destroy()
except:
pass
buttonFrame = ttk.LabelFrame(root, text="Lane Assist", width=width-675, height=height)
buttonFrame.pack_propagate(0)
buttonFrame.grid_propagate(0)
buttonFrame.pack(side="left", anchor="n", padx=10, pady=10)

# Create the custom button frame on the right side of the window
try:
customButtonFrame.destroy()
except:
pass
customButtonFrame = ttk.LabelFrame(root, text="Favorites", width=width-675, height=height)
customButtonFrame.pack_propagate(0)
customButtonFrame.grid_propagate(0)
customButtonFrame.pack(side="right", anchor="n", padx=10, pady=10)

# Create the plugin notebook
try:
pluginNotebook.destroy()
except:
pass
pluginNotebook = ttk.Notebook(root, width=width, height=height-20)
pluginNotebook.pack_propagate(0)
pluginNotebook.grid_propagate(0)
Expand All @@ -436,6 +489,10 @@ def CreateRoot():
# Make a callback for selecting another tab
pluginNotebook.bind("<<NotebookTabChanged>>", lambda e: selectedOtherTab())

# Reset the pluginFrames and UIs
pluginFrames = []
UIs = []

# Bind middleclick on a tab to close it
closeMMB = settings.GetSettings("User Interface", "CloseTabMMB")
if closeMMB == None:
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.10.26
1.10.27

0 comments on commit 65faa68

Please sign in to comment.