Skip to content

Commit

Permalink
v1.4.x
Browse files Browse the repository at this point in the history
redeveloped the totems.py GUI. All UIs will eventually be revamped it just takes forever. Part of #64
  • Loading branch information
ben-wals committed Jun 19, 2023
1 parent 34a37ce commit 8225e6f
Show file tree
Hide file tree
Showing 17 changed files with 141 additions and 108 deletions.
6 changes: 6 additions & 0 deletions addons/ANIM.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,9 @@ def ANI(imageLocation, packName, integrationType, rename):

# returns the new / appropriate location for the gif texture
return "C:/Users/" + getpass.getuser() + "/AppData/Roaming/Totems+/giftexture/" + llfilename

i = "<_io.TextIOWrapper name='D:/Totems+/Totem Textures/3.png' mode='r' encoding='cp1252'>"

split = i.split("'")[1]

print(split)
Binary file modified addons/__pycache__/ANIM.cpython-310.pyc
Binary file not shown.
Binary file modified addons/__pycache__/DOC.cpython-310.pyc
Binary file not shown.
Binary file modified addons/__pycache__/RESZ.cpython-310.pyc
Binary file not shown.
Binary file added img/datapack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/newwindow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/optifine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/resourcepack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed img/windowlogo.png
Binary file not shown.
2 changes: 1 addition & 1 deletion integrations/MCCMD.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def displayImage(texture):
window.Element('tooltip').update('Fill out the details for each totem as they cycle in the top right.\nIt should be noted totems may appear blurred/streched here but\nwont in Minecraft.')

# transforms the texture list into a list
textureList = textureList.split(";")
textureList = textureList.split("\n")

# if the include original box is checked then the original totem is added to the list
if values['inc-orig'] == True:
Expand Down
2 changes: 1 addition & 1 deletion integrations/MCRTX.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def displayImage(texture):


# makes texttureList an actual list
textureList = textureList.split(";")
textureList = textureList.split("\n")

# sets deafult index to 0
index = 0
Expand Down
2 changes: 1 addition & 1 deletion integrations/OFCIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def displayImage(texture):
counter = 0

# transforms texture list into a list
textureList = textureList.split(";")
textureList = textureList.split("\n")

pathList = RES(textureList)

Expand Down
Binary file modified integrations/__pycache__/MCCMD.cpython-310.pyc
Binary file not shown.
Binary file modified integrations/__pycache__/MCRTX.cpython-310.pyc
Binary file not shown.
Binary file modified integrations/__pycache__/OFCIT.cpython-310.pyc
Binary file not shown.
237 changes: 132 additions & 105 deletions totems.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,127 +5,154 @@
# Created By The Totems+ Team - Ormatist + Dockuin #
###################################################################

# imports the libaries used within Totems+
import os.path, PySimpleGUI as sg, getpass
# imports the required libaries
from tkinter import *
from tkinter import filedialog
import customtkinter
from PIL import ImageTk, Image
from integrations.MCCMD import CMD
from integrations.OFCIT import CIT
from integrations.MCRTX import RTX

# sets window theme
sg.theme('DarkTeal10')

# declares the accepted texture file types
textureFileTypes = [("JPEG, PNG, TGA, GIF (.jpg , .png , .tga , .gif)", ".jpg , .png , .tga , .gif")]

# checks if the Totems+ roaming folder exists, if it doesn't one is created
if not os.path.exists('C:/Users/' + getpass.getuser() + '/AppData/Roaming/Totems+'):
os.mkdir("C:/Users/" + getpass.getuser() + "/AppData/Roaming/Totems+")

# defines the main window
def main():

# defines how the main window will be displayed/layed-out
layout = [
[
sg.Image(filename='img/windowlogo.png', key='-LOGO-'),
sg.Text('Totems + is a new and unique way to intergrate custom totems into Minecraft!\n' +
'This program currently provides support for:\n' +
'Minecraft CMD\n' +
'Optifine CIT\n' +
'To get started follow the instructions below \/\n' +
' '),
],
[
sg.Text('⚫ You will want to start by choosing your integration type here:\n' +
' \n' +
'Optifine CIT - Allows for existing Totems to be renamed to a given string\n' +
' e.g "Totem of Axolotl" and have its texture change.\n' +
' \n' +
'Minecraft CMD - Allows for custom totems using custom model data and adds\n' +
' these with a given weight to the evoker loot_tabel.'),
sg.Button('Minecraft RTX', size=(15,1), button_color=('white','red'), key='-TOGGLE-')
],
[
sg.Text("⚫ Select your totem image files here:")
],
[
sg.Text("Image File :"),
sg.Input(size=(57, 1), key="-TEXTURES-"),
sg.FilesBrowse(file_types=textureFileTypes),
],
[
sg.Text("(Remember they will need to be in the following formats: .jpg , .png , .tga, .gif)\n" + "\n" + "⚫ Select which version of minecraft you wish to create the packs for:")
],
[
sg.DropDown(["1.14","1.14.1","1.14.2","1.14.3","1.14.4","1.15","1.15.1","1.15.2","1.16","1.16.1","1.16.2","1.16.3","1.16.4","1.16.5","1.17","1.17.1","1.18","1.18.1","1.18.2","1.19","1.19.1","1.19.2","1.19.3","1.19.4","1.20","1.20.1"], default_value="1.20.1",key="-DROPDOWN-")
],
[
sg.Text("⚫ Finally hit Compile and follow any further instructions to generate your pack(s):"),sg.Button("Compile")
],
]

# creates the window
window = sg.Window("Totems+", layout, icon="img/totems.ico")

# sets the toggle preset
integration = 0

# checks if .minecraft exists if not prompts appropriate error msg
if not os.path.exists("C:/Users/" + getpass.getuser() + "/AppData/Roaming/.minecraft"):
sg.popup_error(".minecraft folder does not exist - program cannot run without minecraft installed", title = "Folder not Found", icon="img/totems.ico")
exit()

# while window (GUI) is open
while True:

# read all events/actions
event, values = window.read(timeout=25)

# if window closed break while loop and end code
if event == sg.WIN_CLOSED:
break

# if Toggle pressed
elif event == '-TOGGLE-':
# outlines the deafult appearance of the window
customtkinter.set_appearance_mode("System")
customtkinter.set_default_color_theme("green")

class App(customtkinter.CTk):
def __init__(self):
super().__init__()

self.title("Totems+")
self.iconbitmap("img/totems.ico")

self.my_font = customtkinter.CTkFont(family="TkDefaultFont", size=15, weight="bold")

#########################

self.logo = ImageTk.PhotoImage(Image.open("img/newwindow.png"))
self.logo_label = Label(self, image=self.logo, border=0)
self.logo_label.grid(row=0, column=0, padx=(20, 0), pady=(20, 5))

#########################

self.tabview = customtkinter.CTkTabview(self, width=250, height=200)
self.tabview.grid(row=0, column=1, padx=(20, 20), pady=(0, 5))
self.tabview.add("MCCMD")
self.tabview.add("MCRTX")
self.tabview.add("OFCIT")

#########################

self.label_mccmd_title = customtkinter.CTkLabel(self.tabview.tab("MCCMD"), text="Minecraft Custom Model Data", font=self.my_font)
self.label_mccmd_title.grid(row=0, column=0, padx=20, pady=0)
self.label_mccmd_title.place(relwidth=1)

self.label_mccmd_desc = customtkinter.CTkLabel(self.tabview.tab("MCCMD"), text="Utilises a datapacks to allow users to\n generate custom totems which are\n dropped by evokers among other\n numerous features.")
self.label_mccmd_desc.grid(row=1, column=0, padx=5, pady=(30, 0))

self.label_mccmd_req = customtkinter.CTkLabel(self.tabview.tab("MCCMD"), text="Requires:", font=self.my_font)
self.label_mccmd_req.grid(row=2, column=0, padx=5, pady=(0, 0))

self.datapack_icon = ImageTk.PhotoImage(Image.open("img/datapack.png"))
self.datapack_icon_label = Label(self.tabview.tab("MCCMD"), image=self.datapack_icon, border=0)
self.datapack_icon_label.grid(row=3, column=0, padx=(0, 45), pady=(0, 0))

self.resourcepack_icon_mccmd = ImageTk.PhotoImage(Image.open("img/resourcepack.png"))
self.resourcepack_icon_mccmd_label = Label(self.tabview.tab("MCCMD"), image=self.resourcepack_icon_mccmd, border=0)
self.resourcepack_icon_mccmd_label.grid(row=3, column=0, padx=(45, 0), pady=(0, 0))

# program toggle the toggle
integration += 1
#########################

if integration == 3:
integration = 0
self.label_mcrtx_title = customtkinter.CTkLabel(self.tabview.tab("MCRTX"), text="Minecraft Re-Texture", font=self.my_font)
self.label_mcrtx_title.grid(row=0, column=0, padx=20, pady=0)
self.label_mcrtx_title.place(relwidth=1)

# visual toggle the toggle
window.Element('-TOGGLE-').Update(['Minecraft RTX','Minecraft CMD','Optifine CIT'][integration], button_color=(('white', ['red','teal','orange'][integration])))
self.label_mccmd_desc = customtkinter.CTkLabel(self.tabview.tab("MCRTX"), text="Simply re-textures the orginal totem\n in Minecraft to a texture of your\n choosing using just a resource\n pack")
self.label_mccmd_desc.grid(row=1, column=0, padx=5, pady=(30, 0))

# if compile and integration type is 1 then
elif event == 'Compile' and integration == 1:
self.label_mcrtx_req = customtkinter.CTkLabel(self.tabview.tab("MCRTX"), text="Requires:", font=self.my_font)
self.label_mcrtx_req.grid(row=2, column=0, padx=5, pady=(0, 0))

# runs CMD function
CMD(values["-TEXTURES-"], values["-DROPDOWN-"])
self.resourcepack_icon_mcrtx = ImageTk.PhotoImage(Image.open("img/resourcepack.png"))
self.resourcepack_icon_mcrtx_label = Label(self.tabview.tab("MCRTX"), image=self.resourcepack_icon_mcrtx, border=0)
self.resourcepack_icon_mcrtx_label.grid(row=3, column=0, padx=(0, 0), pady=(0, 0))

# breaks code (hence closing window)
break
#########################

# if compile and integration type is 2 then
elif event == 'Compile' and integration == 2:
self.label_ofcit_title = customtkinter.CTkLabel(self.tabview.tab("OFCIT"), text="Optifine Custom Item Texture", font=self.my_font)
self.label_ofcit_title.grid(row=0, column=0, padx=20, pady=0)
self.label_ofcit_title.place(relwidth=1)

# runs CIT function
CIT(values["-TEXTURES-"], values["-DROPDOWN-"])
self.label_ofcit_desc = customtkinter.CTkLabel(self.tabview.tab("OFCIT"), text="Uses Optifine to allow you to simply\n rename a totem in an anvil and\n have it change to different\n textures of your choosing.")
self.label_ofcit_desc.grid(row=1, column=0, padx=5, pady=(30, 0))

# breaks code (hence closing window)
break
self.label_ofcit_req = customtkinter.CTkLabel(self.tabview.tab("OFCIT"), text="Requires:", font=self.my_font)
self.label_ofcit_req.grid(row=2, column=0, padx=5, pady=(0, 0))

# if compile and integration type is 0 then
elif event == 'Compile' and integration == 0:
self.optifine_icon = ImageTk.PhotoImage(Image.open("img/optifine.png"))
self.optifine_icon_label = Label(self.tabview.tab("OFCIT"), image=self.optifine_icon, border=0)
self.optifine_icon_label.grid(row=3, column=0, padx=(0, 45), pady=(0, 0))

# runs RTX functuion
RTX(values["-TEXTURES-"], values["-DROPDOWN-"])
self.resourcepack_icon_ofcit = ImageTk.PhotoImage(Image.open("img/resourcepack.png"))
self.resourcepack_icon_ofcit_label = Label(self.tabview.tab("OFCIT"), image=self.resourcepack_icon_ofcit, border=0)
self.resourcepack_icon_ofcit_label.grid(row=3, column=0, padx=(45, 0), pady=(0, 0))

# breaks code (hence closing window)
break
#########################

# closes window if called
window.close()
self.logo_text = ImageTk.PhotoImage(Image.open("img/text.png"))
self.logo_text_label = Label(self, image=self.logo_text, border=0)
self.logo_text_label.grid(row=1, column=0, padx=(20, 0), pady=(5, 20))

self.version_frame = customtkinter.CTkFrame(self, width=250, height=200)
self.version_frame.grid(row=1, column=1, padx=(0, 0), pady=(10, 20))

self.version_label = customtkinter.CTkLabel(self.version_frame, text="Version:", font=self.my_font)
self.version_label.grid(row=0, column=0, padx=(20, 5), pady=0)

self.version = customtkinter.CTkOptionMenu(self.version_frame, values=["1.20.1", "1.20", "1.19.4", "1.19.3", "1.19.2", "1.19.1", "1.19", "1.18.2", "1.18.1", "1.18", "1.17.1", "1.17", "1.16.5", "1.16.4", "1.16.3", "1.16.2", "1.16.1", "1.16", "1.15.2", "1.15.1", "1.15", "1.14.4", "1.14.3", "1.14.2", "1.14.1", "1.14"])
self.version.grid(row=0, column=1, padx=(5, 20), pady=5)

self.textures_frame = customtkinter.CTkFrame(self, width=490, height=200)
self.textures_frame.pack_propagate(False)
self.textures_frame.grid(row=2, column=0, padx=(0, 0), pady=(0, 0), columnspan=2)

self.images_label = customtkinter.CTkLabel(self.textures_frame, text="Textures:", font=self.my_font)
self.images_label.grid(row=0, column=0, padx=(20,128), pady = (5,5))

self.progressbar = customtkinter.CTkProgressBar(self.textures_frame, orientation="horizontal", width=480)
self.progressbar.grid(row=1, column=0, pady=(5,5), columnspan = 2)
self.progressbar.set(0)

def UploadAction(event=None):
filelist = filedialog.askopenfiles(filetypes=[("JPEG, PNG, TGA, GIF (.jpg , .png , .tga , .gif)", ".jpg , .png , .tga , .gif")])
counter = 1
for i in filelist:
split = str(i).split("'")
split = split[1] + "\n"
self.textbox.insert("0.0", split)
self.progressbar.set(1/(len(filelist))*counter)
counter += 1

self.upload = customtkinter.CTkButton(self.textures_frame, text='Upload', command=UploadAction)
self.upload.grid(row=0, column=1, padx=(127,20), pady=(5,5))

self.textbox = customtkinter.CTkTextbox(self.textures_frame, width=480)
self.textbox.grid(row=2, column=0, pady=(5,5), columnspan = 2)

def TotemsPlus():
print(self.version.get())
if self.tabview.get() == "MCCMD":
CMD(self.textbox.get("1.0",END),self.version.get())
elif self.tabview.get() == "OFCIT":
CIT(self.textbox.get("1.0",END),self.version.get())
elif self.tabview.get() == "MCRTX":
RTX(self.textbox.get("1.0",END),self.version.get())

self.compile = customtkinter.CTkButton(self, text="Compile", command=TotemsPlus)
self.compile.grid(row=3, column=0, padx=(0, 0), pady=(10, 10), columnspan=2)


if __name__ == "__main__":
main()
app = App()
app.mainloop()

0 comments on commit 8225e6f

Please sign in to comment.