-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
154 lines (108 loc) · 3.48 KB
/
main.cpp
File metadata and controls
154 lines (108 loc) · 3.48 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
#include <sfml/graphics.hpp>
#include <sfml/Network.hpp>
#include <iostream>
#include <string>
#include "cubereader.h"
#include "grid.h"
#include "card.h"
#include "server.h"
#include "client.h"
#include "chat.h"
class teststream : public sf::InputStream
{
public:
teststream(std::string archive){};
//teststream::~teststream(){};
bool open(std::string filename){if (m_file)
std::fclose(m_file);
m_file = std::fopen(filename.c_str(), "rb");
return m_file != NULL;
};
sf::Int64 read(void* data, sf::Int64 size){
if (m_file)
return std::fread(data, 1, static_cast<std::size_t>(size), m_file);
else
return -1;
}
sf::Int64 seek(sf::Int64 position) {
if (m_file)
{
std::fseek(m_file, static_cast<std::size_t>(position), SEEK_SET);
return tell();
}
else return -1;
};
sf::Int64 tell() {
if (m_file) {return std::ftell(m_file);}
else return -1;
};
sf::Int64 getSize() {if (m_file)
{
sf::Int64 position = tell();
std::fseek(m_file, 0, SEEK_END);
sf::Int64 size = tell();
seek(position);
return size;
}
else {return -1;}
};
private:
std::FILE* m_file{};
};
int main()
{
std::vector<Card> vCards;
sf::RenderWindow win(sf::VideoMode(1024,768), "M Drafter");
win.setFramerateLimit(120);
Server Srv;
Client Clt;
Chat Cht(win);
CubeReader creader;
vCards=creader.read("plrcube.dec");
Grid grid(win,vCards,Srv,Cht);
///sf::RenderWindow win(sf::VideoMode(1024,768), "M Drafter");
///win.setFramerateLimit(60);
/*
sf::Http http("http://magiccards.info");
sf::Http::Request request;
request.setHttpVersion(1,1);
request.setMethod(sf::Http::Request::Post);
request.setField("query","moat");
// request.setUri("");
sf::Http::Response response = http.sendRequest(request);
///std::cout << response.getBody() << std::endl;
std::ofstream file("test.http",std::ios::binary);
file.write(response.getBody().c_str(),response.getBody().size());
file.close();
*/
/*
///std::ofstream tes("img/gog.jpg",std::ios::binary);
///tes.close();
// const std::string& bd = response.getBody();
sf::Image ig;
//ig.loadFromStream(s);
//ig.loadFromMemory(bd);
//std::ofstream
std::ofstream file("test.jpg", std::ios::binary);
// file.write(bd.c_str(),bd.size());
file.close();
sf::Texture txtr;
txtr.loadFromFile("test.jpg");
// txtr.loadFromMemory(&response.getBody(),response.getBody().size());
sf::Sprite a1;
a1.setTexture(txtr);
// std::cout << response.getBody().size() << std::endl;
while (win.isOpen())
{
sf::Event event;
while (win.pollEvent(event))
{
if (event.type == sf::Event::Closed)
win.close();
}
win.clear(sf::Color::Cyan);
win.draw(a1);
win.display();
}
*/
}