Add a button to return to default link sprite
This commit is contained in:
		
							parent
							
								
									9982567227
								
							
						
					
					
						commit
						6007aed5d7
					
				
							
								
								
									
										30
									
								
								Gui.py
								
								
								
								
							
							
						
						
									
										30
									
								
								Gui.py
								
								
								
								
							|  | @ -106,13 +106,13 @@ def guiMain(args=None): | ||||||
|         nonlocal sprite |         nonlocal sprite | ||||||
|         if sprite_param is None or not sprite_param.valid: |         if sprite_param is None or not sprite_param.valid: | ||||||
|             sprite = None |             sprite = None | ||||||
|             spriteNameVar.set('(default)') |             spriteNameVar.set('(unchanged)') | ||||||
|         else: |         else: | ||||||
|             sprite = sprite_param |             sprite = sprite_param | ||||||
|             spriteNameVar.set(sprite.name) |             spriteNameVar.set(sprite.name) | ||||||
| 
 | 
 | ||||||
|     set_sprite(None) |     set_sprite(None) | ||||||
|     spriteNameVar.set('(default)') |     spriteNameVar.set('(unchanged)') | ||||||
|     spriteEntry = Label(spriteDialogFrame, textvariable=spriteNameVar) |     spriteEntry = Label(spriteDialogFrame, textvariable=spriteNameVar) | ||||||
| 
 | 
 | ||||||
|     def SpriteSelect(): |     def SpriteSelect(): | ||||||
|  | @ -310,7 +310,10 @@ def guiMain(args=None): | ||||||
|     baseSpriteLabel2 = Label(spriteDialogFrame2, text='Link Sprite') |     baseSpriteLabel2 = Label(spriteDialogFrame2, text='Link Sprite') | ||||||
|     spriteEntry2 = Label(spriteDialogFrame2, textvariable=spriteNameVar) |     spriteEntry2 = Label(spriteDialogFrame2, textvariable=spriteNameVar) | ||||||
| 
 | 
 | ||||||
|     spriteSelectButton2 = Button(spriteDialogFrame2, text='Select Sprite', command=SpriteSelect) |     def SpriteSelectAdjuster(): | ||||||
|  |         SpriteSelector(mainWindow, set_sprite, adjuster=True) | ||||||
|  | 
 | ||||||
|  |     spriteSelectButton2 = Button(spriteDialogFrame2, text='Select Sprite', command=SpriteSelectAdjuster) | ||||||
| 
 | 
 | ||||||
|     baseSpriteLabel2.pack(side=LEFT) |     baseSpriteLabel2.pack(side=LEFT) | ||||||
|     spriteEntry2.pack(side=LEFT) |     spriteEntry2.pack(side=LEFT) | ||||||
|  | @ -389,12 +392,13 @@ def guiMain(args=None): | ||||||
|     mainWindow.mainloop() |     mainWindow.mainloop() | ||||||
| 
 | 
 | ||||||
| class SpriteSelector(object): | class SpriteSelector(object): | ||||||
|     def __init__(self, parent, callback): |     def __init__(self, parent, callback, adjuster=False): | ||||||
|         if is_bundled(): |         if is_bundled(): | ||||||
|             self.deploy_icons() |             self.deploy_icons() | ||||||
|         self.parent = parent |         self.parent = parent | ||||||
|         self.window = Toplevel(parent) |         self.window = Toplevel(parent) | ||||||
|         self.callback = callback |         self.callback = callback | ||||||
|  |         self.adjuster = adjuster | ||||||
| 
 | 
 | ||||||
|         self.window.wm_title("TAKE ANY ONE YOU WANT") |         self.window.wm_title("TAKE ANY ONE YOU WANT") | ||||||
|         self.window['padx'] = 5 |         self.window['padx'] = 5 | ||||||
|  | @ -412,7 +416,7 @@ class SpriteSelector(object): | ||||||
|         title_link.pack(side=LEFT) |         title_link.pack(side=LEFT) | ||||||
|         title_link.bind("<Button-1>", open_unofficial_sprite_dir) |         title_link.bind("<Button-1>", open_unofficial_sprite_dir) | ||||||
| 
 | 
 | ||||||
|         self.icon_section(official_frametitle, self.official_sprite_dir+'/*', 'Official Sprites not found. Click "Update Official Sprites" to download them.') |         self.icon_section(official_frametitle, self.official_sprite_dir+'/*', 'Official sprites not found. Click "Update official sprites" to download them.') | ||||||
|         self.icon_section(unofficial_frametitle, self.unofficial_sprite_dir+'/*', 'Put sprites in the unofficial sprites folder (see open link above) to have them appear here.') |         self.icon_section(unofficial_frametitle, self.unofficial_sprite_dir+'/*', 'Put sprites in the unofficial sprites folder (see open link above) to have them appear here.') | ||||||
| 
 | 
 | ||||||
|         frame = Frame(self.window) |         frame = Frame(self.window) | ||||||
|  | @ -421,11 +425,15 @@ class SpriteSelector(object): | ||||||
|         button = Button(frame, text="Browse for file...", command=self.browse_for_sprite) |         button = Button(frame, text="Browse for file...", command=self.browse_for_sprite) | ||||||
|         button.pack(side=RIGHT, padx=(5, 0)) |         button.pack(side=RIGHT, padx=(5, 0)) | ||||||
| 
 | 
 | ||||||
|         button = Button(frame, text="Update Official Sprites", command=self.update_official_sprites) |         button = Button(frame, text="Update official sprites", command=self.update_official_sprites) | ||||||
|         button.pack(side=RIGHT, padx=(5, 0)) |         button.pack(side=RIGHT, padx=(5, 0)) | ||||||
| 
 | 
 | ||||||
|         button = Button(frame, text="Use Default Sprite", command=self.use_default_sprite) |         button = Button(frame, text="Use default Link sprite", command=self.use_default_link_sprite) | ||||||
|         button.pack(side=LEFT) |         button.pack(side=LEFT, padx=(0, 5)) | ||||||
|  | 
 | ||||||
|  |         if adjuster: | ||||||
|  |             button = Button(frame, text="Use current sprite from rom", command=self.use_default_sprite) | ||||||
|  |             button.pack(side=LEFT, padx=(0, 5)) | ||||||
| 
 | 
 | ||||||
|         set_icon(self.window) |         set_icon(self.window) | ||||||
|         self.window.focus() |         self.window.focus() | ||||||
|  | @ -465,7 +473,7 @@ class SpriteSelector(object): | ||||||
|                     messagebox.showinfo("Sprite Updater", resultmessage) |                     messagebox.showinfo("Sprite Updater", resultmessage) | ||||||
|                 else: |                 else: | ||||||
|                     messagebox.showerror("Sprite Updater", resultmessage) |                     messagebox.showerror("Sprite Updater", resultmessage) | ||||||
|                 SpriteSelector(self.parent, self.callback) |                 SpriteSelector(self.parent, self.callback, self.adjuster) | ||||||
| 
 | 
 | ||||||
|             try: |             try: | ||||||
|                 task.update_status("Downloading official sprites list") |                 task.update_status("Downloading official sprites list") | ||||||
|  | @ -536,6 +544,10 @@ class SpriteSelector(object): | ||||||
|         self.callback(None) |         self.callback(None) | ||||||
|         self.window.destroy() |         self.window.destroy() | ||||||
| 
 | 
 | ||||||
|  |     def use_default_link_sprite(self): | ||||||
|  |         self.callback(Sprite.default_link_sprite()) | ||||||
|  |         self.window.destroy() | ||||||
|  | 
 | ||||||
|     def select_sprite(self, spritename): |     def select_sprite(self, spritename): | ||||||
|         self.callback(spritename) |         self.callback(spritename) | ||||||
|         self.window.destroy() |         self.window.destroy() | ||||||
|  |  | ||||||
							
								
								
									
										4
									
								
								Rom.py
								
								
								
								
							
							
						
						
									
										4
									
								
								Rom.py
								
								
								
								
							|  | @ -156,6 +156,10 @@ class Sprite(object): | ||||||
|         else: |         else: | ||||||
|             self.valid = False |             self.valid = False | ||||||
| 
 | 
 | ||||||
|  |     @staticmethod | ||||||
|  |     def default_link_sprite(): | ||||||
|  |         return Sprite(local_path('data/default.zspr')) | ||||||
|  | 
 | ||||||
|     def decode8(self, pos): |     def decode8(self, pos): | ||||||
|         arr = [[0 for _ in range(8)] for _ in range(8)] |         arr = [[0 for _ in range(8)] for _ in range(8)] | ||||||
|         for y in range(8): |         for y in range(8): | ||||||
|  |  | ||||||
										
											Binary file not shown.
										
									
								
							
		Loading…
	
		Reference in New Issue