def Get_Val(Type): # Puts the Information to make the file into a queue to be called later A, B, C, D, E, F, G, H, I = Entry_1.get(), Entry_2.get(), Entry_3.get( ), Entry_4.get(), Entry_5.get(), Entry_6.get(), Entry_7.get( ), Entry_8.get(), Entry_9.get() # Information about your mod if Type == "Mod Info": Mod_Header.extend([A, B, C, D, E, F]) # Adds to the regular hot fix queue elif Type == "Regular Hotfix": Reg_hotfix.extend([A, B, C, D, E, F, G, H]) Queue_Order.append("Regular hotfix") # Adds to the table hot fix queue elif Type == "Table Hotfix": Table_Hotfix.extend([A, B, C, D, E, F, G, H, I]) Queue_Order.append("Table hotfixes") # Adds to the mesh hot fix queue elif Type == "Mesh Hotfix": Mesh_Hotfix.extend([A, B, C, D, E, F, G, H, I]) Queue_Order.append("Mesh hotfixes") # This will search the database for provided information elif Type == "Search": Info = data.get_refs_from_data(A) # This will clean out the previous entry so that it does not become cluttered if len(DataBase_Results) > 0: DataBase_Results.clear() # puts the database results into a tkinter Text window so that the user can look at this information for Details in Info: #the reason this looks weird is because of how python gets data from databases, it adds extra characters to the return result, so this helps make it cleaner if Details[0] not in DataBase_Results: DataBase_Results.append(Details[0]) DataBase_Results.sort( ) # sorts the results because it produces a cleaner result ListBoxWindow(1) # Calls the function to display the
def Get_Val(Type): # Information about your mod if Type == "Mod Info": A, B, C, D, E, F = Entry_1.get(), Entry_2.get(), Entry_3.get( ), Entry_4.get(), Entry_5.get(), Entry_6.get() # Puts the Information to make the file into a queue to be called later Mod_Header.extend([A, B, C, D, E, F]) # Adds to the regular hot fix queue elif Type == "Regular Hotfix": A, B, C, D, E, F, G, H = Entry_1.get(), Entry_2.get(), Entry_3.get( ), Entry_4.get(), Entry_5.get(), Entry_6.get(), Entry_7.get( ), Entry_8.get() Reg_hotfix.extend([A, B, C, D, E, F, G, H]) Queue_Order.append("Regular hotfix") elif Type == "Table Hotfix": A, B, C, D, E, F, G, H, I = Entry_1.get(), Entry_2.get( ), Entry_3.get(), Entry_4.get(), Entry_5.get(), Entry_6.get( ), Entry_7.get(), Entry_8.get(), Entry_9.get() Table_Hotfix.extend([A, B, C, D, E, F, G, H, I]) Queue_Order.append("Table hotfixes") elif Type == "Mesh Hotfix": A, B, C, D, E, F, G, H, I = Entry_1.get(), Entry_2.get( ), Entry_3.get(), Entry_4.get(), Entry_5.get(), Entry_6.get( ), Entry_7.get(), Entry_8.get(), Entry_9.get() Mesh_Hotfix.extend([A, B, C, D, E, F, G, H, I]) Queue_Order.append("Mesh hotfixes") # This will search the database for provided information elif Type == "Search": Search = Entry_1.get() Info = data.get_refs_from_data(Search) # This will clean out the previous entry so that it does not become cluttered if len(DataBase_Results) > 0: DataBase_Results.clear() for Details in Info: if Details[0] not in DataBase_Results: DataBase_Results.append(Details[0]) DataBase_Results.sort() ListBoxWindow(3)
def Get_Val(Type): # Used to grab the values the then entry textvariables # Information about your mod if Type == "ModHeader": A, B, C, D, E, F = Entry_1.get(), Entry_2.get(), Entry_3.get( ), Entry_4.get(), Entry_5.get(), Entry_6.get() # Puts the Information to make the file into a queue to be called later Mod_Header.extend([A, B, C, D, E, F]) # Adds to the regular hot fix queue elif Type == "HotFix": A, B, C, D, E, F, G, H = Entry_1.get(), Entry_2.get(), Entry_3.get( ), Entry_4.get(), Entry_5.get(), Entry_6.get(), Entry_7.get( ), Entry_8.get() # Info is put into a regular hotfix queue for later Reg_hotfix.extend([A, B, C, D, E, F, G, H]) Queue_Order.append("Regular hotfix") # Gives a frame of reference to what the Mod looks like elif Type == "Update Display": B, C, D, E, F, G, H = Entry_2.get(), Entry_3.get(), Entry_4.get( ), Entry_5.get(), Entry_6.get(), Entry_7.get(), Entry_8.get() HotFix_Label[ "text"] = '[(1,1,{} , {}) , {} , {} , {} , {} , {}]'.format( B, C, D, E, F, G, H) # This will search the database for provided information elif Type == "Search": Search = Entry_1.get() Info = data.get_refs_from_data(Search) # This will clean out the previous entry so that it does not become cluttered if len(DataBase_Results) > 0: DataBase_Results.clear() for Details in Info: if Details[0] not in DataBase_Results: DataBase_Results.append(Details[0]) DataBase_Results.sort() ListBoxWindow(3)
def Create_HotFix_File(): # All these are different indexes because they are all going to pull from different queues, and I need to kepp track of them indifidually. Queue_Index = 0 # This is a special one. one you add sometihng to a hotfix or call a new line, that command is added a queue list and thats how my program knows what order to go in when creating your hotfix Reg_Index = 0 Table_Index = 0 Mesh_Index = 0 Comment_Index = 0 Header_Index = 0 # Create hotfix file from information # If you don't give it someting, this is what I will replace it with as the program needs to be able to call apon this file later to inset things into it # Also its a little bit of an easter egg if len(Mod_Header) < 6: Mod_Header.extend( ["Chadd", "Chadd", "Chadd", "Chadd", "Chadd", "Chadd"]) # We need this to be the first step, as the rest of the program depends on it File_Name, Mod_Title, Author_Name, Description, Version, Catagory = Mod_Header[ 0], Mod_Header[1], Mod_Header[2], Mod_Header[3], Mod_Header[ 4], Mod_Header[5] mod = Mod( File_Name + '.bl3hotfix', Mod_Title, Author_Name, [ Description, ], lic=Mod.CC_BY_SA_40, v=Version, cats=Catagory, ) # Very important, as the rest of the porgram relies on this working as it writes to these filese """ Things to add: header_lines """ # Used to assign mod types, may change later if not working def patch_types(hold): if hold == 'Mod.PATCH': hold = Mod.PATCH elif hold == 'Mod.LEVEL': hold = Mod.LEVEL elif hold == 'Mod.EARLYLEVEL': hold = Mod.EARLYLEVEL elif hold == 'Mod.CHAR': hold = Mod.CHAR elif hold == 'Mod.PACKAGE': hold = Mod.PACKAGE elif hold == 'Mod.POST': hold = Mod.POST else: hold = Mod.PATCH return hold """ The main and most important part of the code. What this will do is attempt to put the hotfixes inside of your desired code How I have this set up is that it will attempt to create a hotfix given the inputs inside of the file created. If something goes wrong in the creation process however, i do not want it to error out and cancel the rest if they are fine. The code will try and execute the creation of hotfixes, but if something bad happens then what this will try is to ignore that, then move the index up to what would be the next set would be Hopefully this will handle a lot of edge and error handling, and when creating a lot of hotfixes at once, it can be overwelming and mistakes are bound to happen """ while Queue_Index < len(Queue_Order): if Queue_Order[Queue_Index] == "Regular hotfix": try: hf_type = Reg_hotfix[Reg_Index] hf_type = patch_types(hf_type) notification_flag = Reg_hotfix[Reg_Index + 1] package = Reg_hotfix[Reg_Index + 2] obj_name = Reg_hotfix[Reg_Index + 3] attr_name = Reg_hotfix[Reg_Index + 4] # prev_val_len = Reg_hotfix[regular_hotfix+5] # I do not know this was not needed when I was first coding this, but I want to keep it here just in case I someday do need it. prev_val = Reg_hotfix[Reg_Index + 6] new_val = Reg_hotfix[Reg_Index + 7] mod.reg_hotfix(hf_type, package, obj_name, attr_name, new_val, prev_val, notification_flag) except: print( "Something went wrong" ) #Hopefully this prints out if the hotfix wents wrong and it will continue one like normal finally: Reg_Index += 8 #Once everything is done, this command will be ran and hopefully it works as i intended it # Table_Hotfix Mesh_Hotfix elif Queue_Order[Queue_Index] == "Table hotfixes": try: hf_type = Table_Hotfix[Table_Index] hf_type = patch_types(hf_type) notification_flag = Table_Hotfix[Table_Index + 1] package = Table_Hotfix[Table_Index + 2] obj_name = Table_Hotfix[Table_Index + 3] row_name = Table_Hotfix[Table_Index + 4] attr_name = Table_Hotfix[Table_Index + 5] # prev_val_len = Table_Hotfix[table_hotfix_index+6] prev_val = Table_Hotfix[Table_Index + 7] new_val = Table_Hotfix[Table_Index + 8] mod.table_hotfix(hf_type, package, obj_name, row_name, attr_name, new_val, prev_val, notification_flag) except: print("Something went wrong") finally: Table_Index += 8 elif Queue_Order[Queue_Index] == "Mesh hotfixes": try: hf_type = Mesh_Hotfix[Mesh_Index] hf_type = patch_types(hf_type) notification_flag = Mesh_Hotfix[Mesh_Index + 1] map_path = Mesh_Hotfix[Mesh_Index + 2] mesh_path = Mesh_Hotfix[Mesh_Index + 3] # Since i have the user enter numbers like: n,n,n, I need it to split up into a list so that the program can handle it easier location = str(Mesh_Hotfix[Mesh_Index + 4]).split(",") rotation = str(Mesh_Hotfix[Mesh_Index + 5]).split(",") scale = str(Mesh_Hotfix[Mesh_Index + 6]).split(",") transparent = Mesh_Hotfix[Mesh_Index + 7] mod.mesh_hotfix( map_path, mesh_path, (int(location[0]), int(location[1]), int(location[2])), (int(rotation[0]), int(rotation[1]), int(rotation[2])), (int(scale[0]), int(scale[1]), int(scale[2])), transparent, hf_type, notification_flag) except: print("Something went wrong") finally: Mesh_Index += 8 elif Queue_Order[Queue_Index] == "New line": try: mod.newline except: print("Something went wrong") elif Queue_Order[Queue_Index] == "Comment": try: mod.comment( comment_str=Comment_Queue[Comment_Index] ) # If the user wronte a comment, then it will be called here and it should move on to hte next one except: print("Something went wrong") finally: Comment_Index += 1 # not yet implimented elif Queue_Order[Queue_Index] == "Header": try: mod.header_lines(Headers_Queue[Header_Index]) except: print("Something went wrong") finally: Header_Index += 1 Queue_Index += 1
def Create_HotFix_File(): #Create hotfix file from information # If you don't give it someting, this is what I will replace it with. Also its a little bit of an easter egg if len(Mod_Header) < 6: Mod_Header.extend( ["Chadd", "Chadd", "Chadd", "Chadd", "Chadd", "Chadd"]) File_Name, Mod_Title, Author_Name, Description, Version, Catagory = Mod_Header[ 0], Mod_Header[1], Mod_Header[2], Mod_Header[3], Mod_Header[ 4], Mod_Header[5] # We need this to be the first step, as the rest of the program depends on it mod = Mod( File_Name + '.bl3hotfix', Mod_Title, Author_Name, [ Description, ], lic=Mod.CC_BY_SA_40, v=Version, cats=Catagory, ) #Working on adding a queue that will go in order of commands the user have but in # EX: user makes a regular hotfix then adds a comments """ Things to add: newline comment header_lines header(?) table_hotfix mesh_hotfix(going to be a while) """ # Queue types = Regular hotfix, New line, Comment, Header_lines, Table hotfixes queue_len = 0 regular_hotfix = 0 comment = 0 while queue_len < len(Queue_Order): if Queue_Order[queue_len] == "Regular hotfix": hf_type = Reg_hotfix[regular_hotfix] if hf_type == 'Mod.PATCH': hf_type = Mod.PATCH elif hf_type == 'Mod.LEVEL': hf_type = Mod.LEVEL elif hf_type == 'Mod.EARLYLEVEL': hf_type = Mod.EARLYLEVEL elif hf_type == 'Mod.CHAR': hf_type = Mod.CHAR elif hf_type == 'Mod.PACKAGE': hf_type = Mod.PACKAGE elif hf_type == 'Mod.POST': hf_type = Mod.POST notification_flag = Reg_hotfix[regular_hotfix + 1] package = Reg_hotfix[regular_hotfix + 2] obj_name = Reg_hotfix[regular_hotfix + 3] attr_name = Reg_hotfix[regular_hotfix + 4] prev_val_len = Reg_hotfix[regular_hotfix + 5] prev_val = Reg_hotfix[regular_hotfix + 6] new_val = Reg_hotfix[regular_hotfix + 7] mod.reg_hotfix(hf_type, package, obj_name, attr_name, new_val, prev_val, notification_flag) regular_hotfix += 8 elif Queue_Order[queue_len] == "Table hotfixes": None elif Queue_Order[queue_len] == "New line": mod.newline elif Queue_Order[queue_len] == "Comment": mod.comment(comment_str=Comment_str[comment]) comment += 1 elif Queue_Order[queue_len] == "Header_lines": mod.header_lines queue_len += 1