-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFilePick.cpp
89 lines (82 loc) · 2.08 KB
/
FilePick.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
/*
This file is part of Guitar Storm.
Copyright 2008 Zombie Process, Owen Pedrotti
Guitar Storm is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Guitar Storm is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Guitar Storm. If not, see <http://www.gnu.org/licenses/>.
*/
#include "FilePick.h"
void FilePick::OnSelect()
{
if(items[select]->name == "Choose")
{
*selected = dir->Path();
done = true;
}
else if(select >= fpos && items[select]->name != "Back")
{
*selected = dir->files[items[select]->name];
done = true;
}
}
void FilePick::OnOpen()
{
if(firstOpen && parent)
{
dir->Load();
float x = -4;
float y = 2;
fpos = 0;
map<string, Directory*>::iterator ditr;
for(ditr = dir->dirs.begin(); ditr != dir->dirs.end(); ditr++)
{
Add(new MenuItem(ditr->first, new FilePick(ditr->first, ditr->second, selected), x, y));
y -= 1;
fpos++;
}
map<string, string>::iterator fitr;
for(fitr = dir->files.begin(); fitr != dir->files.end(); fitr++)
{
Add(new BackItem(fitr->first, x, y));
y -= 0.5;
}
Add(new BackItem("Back", -2, -4));
}
done = false;
}
void DirPick::OnOpen()
{
if(firstOpen && parent)
{
dir->Load();
float x = -4;
float y = 2;
fpos = 0;
map<string, Directory*>::iterator ditr;
for(ditr = dir->dirs.begin(); ditr != dir->dirs.end(); ditr++)
{
Add(new MenuItem(ditr->first, new DirPick(ditr->first, ditr->second, selected), x, y));
y -= 0.5;
fpos++;
}
Add(new BackItem("Choose", -2, -4));
Add(new BackItem("Back", -2, -4.5));
}
done = false;
}
void FilePick::OnValueChange()
{
if(child)
{
done = ((FilePick*)child)->done;
if(done)
Close();
}
}