kvui: abstract away client tab additions #3950
This commit is contained in:
		
							parent
							
								
									99c02a3eb3
								
							
						
					
					
						commit
						f7ec3d7508
					
				|  | @ -267,9 +267,7 @@ class WargrooveContext(CommonContext): | |||
| 
 | ||||
|             def build(self): | ||||
|                 container = super().build() | ||||
|                 panel = TabbedPanelItem(text="Wargroove") | ||||
|                 panel.content = self.build_tracker() | ||||
|                 self.tabs.add_widget(panel) | ||||
|                 self.add_client_tab("Wargroove", self.build_tracker()) | ||||
|                 return container | ||||
| 
 | ||||
|             def build_tracker(self) -> TrackerLayout: | ||||
|  |  | |||
							
								
								
									
										13
									
								
								kvui.py
								
								
								
								
							
							
						
						
									
										13
									
								
								kvui.py
								
								
								
								
							|  | @ -536,9 +536,8 @@ class GameManager(App): | |||
|                 # show Archipelago tab if other logging is present | ||||
|                 self.tabs.add_widget(panel) | ||||
| 
 | ||||
|         hint_panel = TabbedPanelItem(text="Hints") | ||||
|         self.log_panels["Hints"] = hint_panel.content = HintLog(self.json_to_kivy_parser) | ||||
|         self.tabs.add_widget(hint_panel) | ||||
|         hint_panel = self.add_client_tab("Hints", HintLog(self.json_to_kivy_parser)) | ||||
|         self.log_panels["Hints"] = hint_panel.content | ||||
| 
 | ||||
|         if len(self.logging_pairs) == 1: | ||||
|             self.tabs.default_tab_text = "Archipelago" | ||||
|  | @ -572,6 +571,14 @@ class GameManager(App): | |||
| 
 | ||||
|         return self.container | ||||
| 
 | ||||
|     def add_client_tab(self, title: str, content: Widget) -> Widget: | ||||
|         """Adds a new tab to the client window with a given title, and provides a given Widget as its content. | ||||
|          Returns the new tab widget, with the provided content being placed on the tab as content.""" | ||||
|         new_tab = TabbedPanelItem(text=title) | ||||
|         new_tab.content = content | ||||
|         self.tabs.add_widget(new_tab) | ||||
|         return new_tab | ||||
| 
 | ||||
|     def update_texts(self, dt): | ||||
|         if hasattr(self.tabs.content.children[0], "fix_heights"): | ||||
|             self.tabs.content.children[0].fix_heights()  # TODO: remove this when Kivy fixes this upstream | ||||
|  |  | |||
|  | @ -111,13 +111,10 @@ class SC2Manager(GameManager): | |||
|     def build(self): | ||||
|         container = super().build() | ||||
| 
 | ||||
|         panel = TabbedPanelItem(text="Starcraft 2 Launcher") | ||||
|         panel.content = CampaignScroll() | ||||
|         panel = self.add_client_tab("Starcraft 2 Launcher", CampaignScroll()) | ||||
|         self.campaign_panel = MultiCampaignLayout() | ||||
|         panel.content.add_widget(self.campaign_panel) | ||||
| 
 | ||||
|         self.tabs.add_widget(panel) | ||||
| 
 | ||||
|         Clock.schedule_interval(self.build_mission_table, 0.5) | ||||
| 
 | ||||
|         return container | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue