-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstageList.cpp
73 lines (59 loc) · 1.74 KB
/
stageList.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
#include "stageList.h"
stageList::stageList()
{
//load text file of stage filenames
loadFile();
}
stageList::stageList(SDL_Renderer* oRenderer)
{
loadFile();
Renderer = oRenderer;
innerWindow = Rectangle(WINDOW_WIDTH / 2 + 5, 5, WINDOW_WIDTH / 2 - 10, WINDOW_HEIGHT - 10, 0, 40, 200);
borderWindow = Rectangle(WINDOW_WIDTH / 2, 0, WINDOW_WIDTH / 2, WINDOW_HEIGHT, 219, 76, 76);
appWindow = Rectangle(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
for (int i = 0; i < vStages.size(); i++)
{
stageButtons.push_back(new menuButton(innerWindow.getPosition().x+20, innerWindow.getPosition().y + 5 + i * 52, vStages[i]));
stageButtons[i]->displayRect.setDimensions(200, 50);
stageButtons[i]->loadText(Renderer);
}
}
void stageList::loadFile()
{
listIF.open("stages/stageList.txt");
string currStage;
while (getline(listIF, currStage))
{
vStages.push_back(currStage);
}
listIF.close();
}
void stageList::newStage(string filename)
{
vStages.push_back(filename);
listOF.open("stages/stageList.txt", std::ofstream::app );
listOF << filename << endl;
listOF.close();
listOF.open(filename);
listOF << "Size: 1\n100, 100, 100, 100\n";
listOF.close();
}
void stageList::removeItem(int index)
{
vStages.erase(vStages.begin() + index);
}
void stageList::render()
{
SDL_Color tempCol = borderWindow.getColor();
SDL_SetRenderDrawColor(Renderer, 80, 80, 80, 80);
SDL_RenderFillRect(Renderer, &borderWindow.getRect());
tempCol = innerWindow.getColor();
SDL_SetRenderDrawColor(Renderer, 190, 100, 100, 99);
SDL_RenderFillRect(Renderer, &innerWindow.getRect());
for (int i = 0; i < vStages.size(); i++)
{
SDL_RenderSetViewport(Renderer, &innerWindow.getRect());
stageButtons[i]->render(Renderer);
}
SDL_RenderSetViewport(Renderer, &appWindow.getRect());
}