summaryrefslogtreecommitdiff
path: root/src/main/java/net/tylermurphy/Minecraft/UI/UI.java
blob: 1f1f1e0862534473b4eaaebf3b5ad76e056305b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package net.tylermurphy.Minecraft.UI;

import java.util.ArrayList;
import java.util.List;

public class UI {

		public boolean enabled = true;
		
		protected List<UIComponent> children = new ArrayList<UIComponent>();
		
		protected UIComponent findKey(String key) {
			for(UIComponent component : children) {
				UIComponent c = component.findKey(key);
				if(c!=null) return c;
			}
			return null;
		}
		
		protected UIText findText(String key) {
			return (UIText) findKey(key);
		}
		
		protected UIImage findImage(String key) {
			return (UIImage) findKey(key);
		}
		
		protected void add(UIComponent component) {
			children.add(component);
		};
		
		protected void prepare() {
			if(!enabled) return;
			for(UIComponent component : children)
				component.prepare(null);
		}
		
	}