-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappAppManager.pde
164 lines (141 loc) · 4.09 KB
/
appAppManager.pde
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
class appManager extends application
{
appManager() {super(new applicationInfo("data/apps/appManager.json"));}
String[] appList;
/* MAIN */
layout main;
compList items;
button view;
textField searchBar;
button search;
/* SHOW APPS */
image wallpaper;
layout showApp;
button back;
button getApp;
image icon;
label name;
label version;
void init()
{
/* MAIN */
main = new layout(600, 510);
items = new compList(10, 45, 500, 415);
view = new button(10, 470, 100, 30, "View");
searchBar = new textField(10, 10, 465, 30, "Search Bar");
search = new button(480, 10, 30, 30, getImage("textures/button/tools/active/search.png"), getImage("textures/button/tools/unactive/search.png"));
search.bindKey(ENTER);
appList = getFolderData("apps");
main.addComponent(items);
main.addComponent(searchBar);
main.addComponent(search);
main.addComponent(view);
/* SHOW APP INFO */
showApp = main.get();
back = new button(10, 10, 30, 30, getImage("textures/button/tools/active/arrow_back.png"), getImage("textures/button/tools/unactive/arrow_back.png"));
icon = new image(50, 50, 70, 70, getImage(getIcon(appList[items.getSelected()])));
name = new label(130, 60, 150, 40, "");
version = new label(130, 105, 150, 40, "");
wallpaper = new image(0, 0, 598, 200, getImage("textures/app/appManager/wallpaper.png"));
showApp.addComponent(wallpaper);
showApp.addComponent(back);
showApp.addComponent(icon);
showApp.addComponent(name);
showApp.addComponent(version);
for(String s : appList)
{
items.addItem(getName(s), getIcon(s) == null ? getImage("textures/files/app.png") : getImage(getIcon(s)));
}
setLayout(main);
}
void mainLayout()
{
if(search.isClicked())
{
items.clear();
for(String s : appList)
{
for(int a = 0; a < getName(s).length() - searchBar.getText().length(); a++)
{
if(checkStrings(searchBar.getText().toLowerCase(), getName(s).substring(a, a + searchBar.getText().length()).toLowerCase()))
{
items.addItem(getName(s), getIcon(s) == null ? getImage("textures/files/app.png") : getImage(getIcon(s)));
break;
}
}
}
}
else if(view.isClicked())
{
String file = null;
for(String s : appList)
{
if(checkStrings(getName(s), items.getSelectedName()))
{
file = s;
break;
}
}
if(file != null)
{
icon.setImage(getImage(getIcon(file)));
name.setText(getName(file));
version.setText(getVersion(file));
}
setLayout(showApp);
}
}
void showAppLayout()
{
if(back.isClicked())
{
setLayout(main);
}
}
void update()
{
if(getLayout() == main)
{
mainLayout();
}
else if(getLayout() == showApp)
{
showAppLayout();
}
}
String getName(String file)
{
return loadJSONObject("data/apps/" + file).getString("title");
}
String getSystemName(String file)
{
return loadJSONObject("data/apps/" + file).getString("systemName");
}
String getVersion(String file)
{
return loadJSONObject("data/apps/" + file).getString("version");
}
String getDescription(String file)
{
return loadJSONObject("data/apps/" + file).getString("description");
}
String getAuthor(String file)
{
return loadJSONObject("data/apps/" + file).getString("author");
}
String getFile(String file)
{
return loadJSONObject("data/apps/" + file).getString("file");
}
String getIcon(String file)
{
return loadJSONObject("data/apps/" + file).getString("icon");
}
}
//String[] info = new String[5];
//if(items.getSelectedName().length() > 0)
//{
// load = loadJSONArray("data/apps/" + items.getSelectedName());
// JSONObject obj = load.getJSONObject(0);
// //showInfo.setInfo(obj.getString("systemName"), obj.getString("appFile"), obj.getString("author"), obj.getString("version"), obj.getString("description"));
//}