forked from abartlett139/Omni
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileIOHelper.cpp
83 lines (71 loc) · 1.69 KB
/
FileIOHelper.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
#include "FileIOHelper.h"
FileIOHelper::FileIOHelper(std::string filename, RECT rect) :
m_filename(filename), m_textRect(rect)
{
m_format |= DT_LEFT|DT_TOP;
D3DXCreateFont(Device, 50, 15, FW_BOLD, 0, FALSE,
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH, TEXT("Arial"),
&m_font);
}
FileIOHelper::FileIOHelper(std::string filename, RECT rect,
LPSTR fontName, int height, int width, UINT weight, DWORD format):
m_filename(filename), m_textRect(rect), m_format(format)
{
D3DXCreateFont(Device, height, width, weight, 0, FALSE,
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH, TEXT(fontName),
&m_font);
}
FileIOHelper::~FileIOHelper()
{
}
void FileIOHelper::Enter()
{
}
void FileIOHelper::Exit()
{
}
void FileIOHelper::getRecord(std::string recordName)
{
if (recordName != "")
{
std::ifstream l_finOut(m_filename);
l_finOut.seekg(0);
if (!l_finOut)
{
MessageBox(NULL, "Cannot open menu file", NULL, NULL);
}
while (!l_finOut.eof())
{
std::string temp;
std::getline(l_finOut, temp);
if (temp == recordName)
{
while (temp[0] != '0')
{
std::getline(l_finOut, temp);
m_text.push_back(temp);
}
l_finOut.clear();
l_finOut.close();
return;//end of record has been found
}
}
}
}
void FileIOHelper::Render(LPD3DXSPRITE sprite)
{
if (m_filename != "")
{
//ZeroMemory(&m_textRect, sizeof(RECT));
RECT temp = m_textRect;
for (unsigned int i = 0; i < m_text.size(); i++)
{
m_font->DrawText(NULL, m_text[i].c_str(), -1, &temp, m_format, D3DCOLOR_XRGB( 255, 255, 0 ) );
//D3DXMatrixTranslation(&textPos, m_textRect.left, m_textRect.bottom, 0);
temp.top += 20;
temp.bottom += 20;
}
}
}