-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGlobalManager.cpp
More file actions
188 lines (164 loc) · 3.49 KB
/
GlobalManager.cpp
File metadata and controls
188 lines (164 loc) · 3.49 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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#include "StdAfx.h"
#include "GlobalManager.h"
int GlobalManager::lastString=0;
GlobalManager::GlobalManager():
m_haveFileSaved(true),
m_userStartGame(false),
m_useMenu(false),
m_en_history(true)
{
}
GlobalManager::~GlobalManager()
{
}
void GlobalManager::userStartGame()
{
m_userStartGame = true;
//Î÷èùàåì èñòîðèþ
commandHistory.clear();
m_currHistPos = -1;
m_currCmdPos = -1;
//Äîáàâëÿåì ïóñòóþ êîìàíäó (òåêñò â íà÷àëå èãðû)
appendCommand(L"");
}
void GlobalManager::userSavedFile()
{
m_haveFileSaved = true;
}
void GlobalManager::userNewCommand()
{
m_haveFileSaved = false;
}
bool GlobalManager::isUserSaveLastFile()
{
return m_haveFileSaved;
}
bool GlobalManager::isUserStartGame()
{
return m_userStartGame;
}
void GlobalManager::appendCommandAndRespond(CString command, CString respond)
{
commandHistory.push_back(std::make_pair(command,respond));
m_currHistPos = commandHistory.size()-1;
m_currCmdPos = commandHistory.size()-1;
}
void GlobalManager::enableHistory(bool isEn)
{
m_en_history = isEn;
}
void GlobalManager::appendCommand(CString command)
{
if (!m_en_history) return;
//Äîáàâëÿåì íîâóþ êîìàíäó, ñ ïóñòûì îòêëèêîì
commandHistory.push_back(std::make_pair(command,L""));
//Âîçâðàùàåì íà ìåñòî óêàçàòåëü èñòîðèè
m_currHistPos = commandHistory.size()-1;
m_currCmdPos = commandHistory.size()-1;
}
void GlobalManager::appendLastRespond(CString command)
{
if (!m_en_history) return;
//Äîáàâëÿåì íåäîñòàþùèé îòêëèê
commandHistory[m_currHistPos].second = command;
}
CString GlobalManager::fullHistoryData()
{
if (commandHistory.size() > 0)
{
CString hist;
hist.Append(L"Èñòîðèÿ\r\n");
for (int i=0;i<commandHistory.size();i++)
{
CString res;
res.Append(L"> ");
res.Append(commandHistory[i].first);
res.Append(L"\r\n");
res.Append(commandHistory[i].second);
//res.Append(L"\r\n");
hist.Append(res);
}
return hist;
}
return CString();
}
CString GlobalManager::previosHistoryData()
{
if (previosHistoryHave())
{
m_currHistPos--;
CString res;
res.Format(_T("Øàã: %d èç %d\r\n"), m_currHistPos+1, commandHistory.size());
res.Append(L"> ");
res.Append(commandHistory[m_currHistPos].first);
res.Append(L"\r\n");
res.Append(commandHistory[m_currHistPos].second);
return res;
}
return CString();
}
bool GlobalManager::previosHistoryHave()
{
return (m_currHistPos > 0);
}
CString GlobalManager::nextHistoryData()
{
if ( nextHistoryHave() )
{
m_currHistPos++;
CString res;
res.Format(_T("Øàã: %d èç %d\r\n"), m_currHistPos+1, commandHistory.size());
res.Append(L"> ");
res.Append(commandHistory[m_currHistPos].first);
res.Append(L"\r\n");
res.Append(commandHistory[m_currHistPos].second);
return res;
}
return CString();
}
bool GlobalManager::nextHistoryHave()
{
return ((m_currHistPos >= 0) && (m_currHistPos<(commandHistory.size()-1)));
}
CString GlobalManager::commandData()
{
if (commandHistory.size()>0 && m_currCmdPos>=0)
{
return commandHistory[m_currCmdPos].first;
}
return CString();
}
bool GlobalManager::previosCommandMove()
{
if (m_currCmdPos > 1)
{
m_currCmdPos--;
return true;
}
return false;
}
bool GlobalManager::nextCommandMove()
{
if ((m_currCmdPos >= 0) && (m_currCmdPos<(commandHistory.size()-1)))
{
m_currCmdPos++;
return true;
}
return false;
}
bool GlobalManager::isUseMenu()
{
return m_useMenu;
}
bool GlobalManager::isAutoMenuDetect()
{
return true;
}
CString GlobalManager::keyMenuString()
{
return L"×òî âû áóäåòå äåëàòü äàëüøå?";
}
void GlobalManager::setUseMenu()
{
m_useMenu = true;
}