def refreshlistbox(none): listbox.delete(0, END) mode = dropdnvariable.get() for item in fmanage.index(rvmm.rvmmfolder+mode): if not any(item.rstrip('.zip') in s for s in rvmm.db1.getactive()): #Zeigt haken wenn Mod installiert listbox.insert(END, '☐ '+item) else: listbox.insert(END, '☑ '+item)
def tab_library(): #Zeigt die Bibliothek der Inhalte an x =1 if x == 1: activetab = 'library' global dropdnvariable global listbox global title global descr_background global descr_title global dropdown global button_install mode = 'mods' descr_background = Frame(maingui, width=512, height=200, relief=FLAT) descr_background.place(x=column_middle,y=200) descr_background.configure(bg='#303030', ) descr_title = Label(maingui, text='Description') descr_title.place(x=column_middle+4, y=204) descr_title.configure(bg='#303030', fg=color_select, font=("SegoeUI", 16)) #Kategorien der Mods (Order in rvmm) OPTIONS = [ "Mods", "Levels", "Cars", "Misc."] dropdnvariable = StringVar(maingui) dropdnvariable.set(OPTIONS[0]) #Variable fuer Dropdownmenu (Auswahl der Kategorie) dropdown = OptionMenu(maingui, dropdnvariable, *OPTIONS, command=refreshlistbox) dropdown.place(x=1, y=51) dropdown.configure(width=21, bg='#505050', fg='#cecece', relief=FLAT, border=0, font=("SegoeUI", 11)) #Seitenleiste, zeigt Mods an listbox = Listbox(maingui, selectmode=SINGLE) listbox.bind_all('<<ListboxSelect>>', refreshtitle) listbox.place(x=0, y=82) listbox.configure(borderwidth=5, height=29, width=25, bg='#505050', fg='#cecece', relief=FLAT, highlightthickness=0, selectforeground='#ffffff', selectbackground=color_select, font=("SegoeUI", 11), activestyle='none', selectmode='extended') rvmm.db1.init_active() for item in fmanage.index(rvmm.rvmmfolder+mode): if not any(item.rstrip('.zip') in s for s in rvmm.db1.getactive()): listbox.insert(END, '☐ '+item) else: listbox.insert(END, '☑ '+item) #Titel des ausgewaehlten Mods title = Label(maingui, text=listbox.get(ACTIVE).rstrip('.zip')) title.place(x=column_middle, y=64) title.configure(bg='#393939', fg='#ffffff', font=("SegoeUI", 18)) #Button zur Installation des ausgewaehlten Mods button_install = Button(maingui, text="Install", command=applyselected) button_install.configure(background=color_elements, fg='#ffffff', bd=0, padx=6, pady=4) button_install.place(x=column_middle, y=97) progressbar(0, 1)
def refreshbutton_install(): try: if not any(fmanage.index(rvmm.rvmmfolder+dropdnvariable.get())[int(listbox.curselection()[0])].rstrip('.zip') in s for s in rvmm.db1.getactive()): button_install['text'] = 'Install' button_install['command'] = applyselected else: button_install['text'] = 'Uninstall' button_install['command'] = uninstallselected except: pass
def dispthumb(size=190): #Stellt Thumbnail des ausgewählten Elements dar curmode = dropdnvariable.get() modlist = fmanage.index(rvmm.rvmmfolder+curmode) try: image = Image.open(fmanage.gettrackthumb(rvmm.rvmmfolder+curmode+'/'+modlist[int(listbox.curselection()[0])], rvmm.tempfolder), 'r') except: image = Image.open(rvmm.revoltfolder+'gfx/acclaim.bmp', 'r') image = image.resize((size, size), Image.ANTIALIAS) photo = ImageTk.PhotoImage(image) global trackthumb trackthumb = Label(image=photo) trackthumb.image = photo trackthumb.place(x=column_right, y=64, width=image.size[0],height=image.size[1])
def apply_backup(mod): #ahnlich uninstall, ohne Datenbank moeglich modfiles = os.listdir.indexzip(mod) if os.path.isdir(backupfolder+'/'+mod.strip('.zip')): for file in fmanage.index(backupfolder): src_file = backupfolder + file dst_file = modfiles try: fmanage.copy(src_file, dst_file) print('Restored ' + file + ' from ' + backupfolder + ' to ' + modfiles) except: print('Skipped ' + file) print('Reverted to its original state.') else: print('Backup does not exist.')
def uninstallselected(): uninstalled = [] curmode = dropdnvariable.get() modlist = fmanage.index(rvmm.rvmmfolder+curmode) inststring = '' rvmm.db1.init_active() for item in listbox.curselection(): if any(modlist[int(item)].rstrip('.zip') in s for s in rvmm.db1.getactive()): rvmm.uninstall(rvmm.rvmmfolder+curmode.lower()+'/'+modlist[int(item)]) uninstalled.append(rvmm.rvmmfolder+curmode+'/'+modlist[int(item)]) else: infobox("This mod has not been enabled: "+modlist[int(item)]) if not uninstalled == []: for x in uninstalled: inststring += x+' ' infobox('Uninstalled the following mods: '+inststring) refreshui()
def applyselected(force=0): installed = [] curmode = dropdnvariable.get() modlist = fmanage.index(rvmm.rvmmfolder+curmode) inststring = '' rvmm.db1.init_active() current = 0 for item in listbox.curselection(): if not any(modlist[int(item)].rstrip('.zip') in s for s in rvmm.db1.getactive()): rvmm.apply(rvmm.rvmmfolder+curmode.lower()+'/'+modlist[int(item)]) installed.append(rvmm.rvmmfolder+curmode+'/'+modlist[int(item)]) current += 1 else: infobox("This mod has already been enabled: "+modlist[int(item)]) current += 1 progressbar(current/len(listbox.curselection())*100) if not installed == []: for x in installed: inststring += x+' ' infobox('Installed the following mods: '+inststring) refreshui()