-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.cpp
152 lines (118 loc) · 2.27 KB
/
main.cpp
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
#include <monohome.h>
#include <time.h>
#define SMS_END 26
CLauncher* gLauncher;
CAnimator* anim;
APP_FACTORY(CDialerScreen)
CAppDesc _APhone = {
"Phone",
"ui/phone.tga",
0,
0,
&__phone_factory_CDialerScreen
};
CAppDesc _ASMS = {
"SMS",
"ui/sms.tga"
};
CAppDesc _AGallery = {
"Gallery",
"ui/gallery.tga"
};
CAppDesc _ASettings = {
"Settings",
"ui/tools.tga"
};
CAppDesc* Apps[] = {
&_APhone, &_ASMS, &_AGallery, &_ASettings
};
CLauncher::CLauncher()
{
LOG("Starting...\n");
Modem = new CModem();
Graphics = new CGraphics();
Wallpaper = CImage::FromFile("wallpaper.tga");
Font = CFont::FromFile("ui/Courier");
Status = new CStatusBar();
Input = new CInput();
PowerManager = new CPowerManager();
Dialog = new CNotifyDialog();
Dialog->Text = "Test";
Dialog->Duration = 1000;
drawerAnimator = new CAnimator();
drawerAnimator->SetTranslation(-10, 0, 10, 52);
drawerAnimator->Run();
for(int i = 0; i < sizeof(Apps) / sizeof(CAppDesc*); i++)
{
LOGF("Preparing application \"%s\"\n", Apps[i]->Name);
Apps[i]->Icon = CImage::FromFile(Apps[i]->IconPath);
}
}
CLauncher::~CLauncher()
{
delete Wallpaper;
delete Font;
delete Status;
delete Input;
delete PowerManager;
delete drawerAnimator;
delete Dialog;
delete Graphics;
}
void CLauncher::DrawAppDrawer()
{
for(int i = 0; i < sizeof(Apps) / sizeof(CAppDesc*); i++)
{
int x = drawerAnimator->X + (i * 75);
int y = drawerAnimator->Y;
Graphics->DrawImage(Apps[i]->Icon, x, y);
if(Input->IsTouchedAt(x, y, Apps[i]->Icon->Width, Apps[i]->Icon->Height))
{
StartScreen(new CDialerScreen());
}
}
}
void CLauncher::StartScreen(CScreen* screen)
{
if(screen)
{
currentScreen = screen;
currentScreen->Show();
}
}
int nextCheck = 0;
void CLauncher::Run()
{
CImage* test = CImage::FromFile("ui/stFiller.tga");;
while(true)
{
Input->Update();
if(nextCheck < 0)
{
Modem->GetDialState();
nextCheck = 50;
}
nextCheck--;
Graphics->DrawImage(Wallpaper, 0, 0);
if(currentScreen)
{
currentScreen->Update();
currentScreen->Draw();
}
else
{
drawerAnimator->Update();
DrawAppDrawer();
}
Status->Update();
Status->Draw();
Dialog->Draw();
Graphics->Flip();
}
}
int main(int argc, char** argv)
{
gLauncher = new CLauncher();
gLauncher->Run();
return 0;
}