-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEditorState.cpp
More file actions
93 lines (81 loc) · 2.54 KB
/
EditorState.cpp
File metadata and controls
93 lines (81 loc) · 2.54 KB
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
#include "EditorState.h"
EditorState::EditorState():State()
{
std::cout << "Konstruktor EditorState!" << std::endl;
}
void EditorState::Init()
{
GameEngine::getInstance()->getCursor().setType(ARROW);
mapCreator = new MapCreator(GameEngine::getInstance()->getSteering());
mapCreator->GetScreenSize(GameEngine::SCREEN_WIDTH, GameEngine::SCREEN_HEIGHT);
inputBox = new InputBox(GameEngine::getInstance()->getSteering(),
sf::Vector2f((float)(GameEngine::SCREEN_WIDTH/2 -100),
(float)(GameEngine::SCREEN_HEIGHT/2)),
"");
textBox = new TextBox(sf::Vector2f((float)(GameEngine::SCREEN_WIDTH/2 -175.0),
(float)(GameEngine::SCREEN_HEIGHT/2 - 250)),
sf::Vector2f(350.0,150.0),
sf::Color(61,61,61),
" Edytor do tworzenia map:\n Zalecana wielkosc mapy 10 - 1000 \n Klawiszologia : \n CTRL + L - Wczytanie biezacej mapy\n Shift + LPM - Usuniecie obiektu\n Dyskietka - Zapis mapy do pliku");
textBox1 = new TextBox(sf::Vector2f((float)(GameEngine::SCREEN_WIDTH/2 -230.0),
(float)( GameEngine::SCREEN_HEIGHT/2) ),
sf::Vector2f(130.0,30.0),
sf::Color(61,61,61),"Rozmiar mapy ");
init = 1;
state = SET_MAP_SIZE;
}
void EditorState::UpdateSystem()
{
}
void EditorState::Display()
{
GameEngine::getInstance()->SetDefaultView();
if(state == SET_MAP_SIZE)
{
inputBox->Display(&GameEngine::getInstance()->getWindow());
textBox->Display(&GameEngine::getInstance()->getWindow());
textBox1->Display(&GameEngine::getInstance()->getWindow());
}
else if (state == MAIN)
{
mapCreator->MoveCamera(&GameEngine::getInstance()->getView(), &GameEngine::getInstance()->getWindow());
mapCreator->Display(&GameEngine::getInstance()->getWindow());
}
}
void EditorState::EventHandling()
{
GameEngine::getInstance()->SetDefaultView();
if(state == MAIN)
{
mapCreator->GetSteeringEvent();
}
}
void EditorState::GetEvents()
{
sf::Event event = GameEngine::getInstance()->getEvent();
if(state==SET_MAP_SIZE)
{
inputBox->HandleEvent(event);
if((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Key::Return))
{
std::string tempStr = inputBox->GetString();
mapCreator->GetTextboxEvent(event, tempStr , state);
}
}
else if (state == MAIN)
{
mapCreator->GetEvent(event);
}
if ((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Key::Escape))
{
GameEngine::getInstance()->ChangeState(MAINMENU);
}
}
void EditorState::Cleanup()
{
if (state == MAIN)
delete mapCreator;
delete textBox;
delete inputBox;
init = 0;
}