fixed compilarion of editor
This commit is contained in:
parent
4359e785f9
commit
51e977d020
4 changed files with 32 additions and 9 deletions
|
@ -1,6 +1,6 @@
|
|||
SDL_CFLAGS = `sdl-config --cflags` `freetype-config --cflags`
|
||||
SDL_LIBS = `sdl-config --libs` -lSDL_ttf -lSDL_mixer -lSDL_image -lSDL_net `freetype-config --libs`
|
||||
OBJS= game.o server.o ../config.o ../filesystem.o ../game_config.o ../log.o ../network.o
|
||||
OBJS= game.o server.o ../config.o ../filesystem.o ../game_config.o ../log.o ../network.o ../player.o
|
||||
|
||||
server: $(OBJS)
|
||||
gcc -lstdc++ ${SDL_CFLAGS} -o $@ ${OBJS} ${SDL_LIBS}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "../config.hpp"
|
||||
#include "../game_config.hpp"
|
||||
#include "../network.hpp"
|
||||
|
||||
#include "SDL.h"
|
||||
|
@ -8,6 +9,7 @@
|
|||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
|
@ -16,10 +18,17 @@ int main()
|
|||
const network::manager net_manager;
|
||||
const network::server_manager server;
|
||||
|
||||
config login_response;
|
||||
login.children["mustlogin"].push_back(new config());
|
||||
login_response["version"] = game_config::version;
|
||||
|
||||
config initial_response;
|
||||
initial_response.children["gamelist"].push_back(new config());
|
||||
config& gamelist = *initial_response.children["gamelist"].back();
|
||||
|
||||
std::map<network::connection,player> players;
|
||||
|
||||
game not_logged_in;
|
||||
game lobby_players;
|
||||
std::vector<game> games;
|
||||
|
||||
|
@ -27,13 +36,18 @@ int main()
|
|||
try {
|
||||
network::connection sock = network::accept_connection();
|
||||
if(sock) {
|
||||
network::send_data(initial_response,sock);
|
||||
lobby_players.add_player(sock);
|
||||
network::send_data(login_response,sock);
|
||||
not_logged_in.add_player(sock);
|
||||
}
|
||||
|
||||
config data;
|
||||
while((sock = network::receive_data(data)) != NULL) {
|
||||
if(lobby_players.is_member(sock)) {
|
||||
if(not_logged_in.is_member(sock)) {
|
||||
network::send_data(initial_response,sock);
|
||||
not_logged_in.remove_player(sock);
|
||||
lobby_players.add_player(sock);
|
||||
|
||||
} else if(lobby_players.is_member(sock)) {
|
||||
const config* const create_game = data.child("create_game");
|
||||
if(create_game != NULL) {
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
*/
|
||||
#include "textbox.hpp"
|
||||
#include "../font.hpp"
|
||||
#include "../show_dialog.hpp"
|
||||
#include "SDL.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -24,9 +25,7 @@ const int font_size = 16;
|
|||
textbox::textbox(display& disp, int width, const std::string& text)
|
||||
: disp_(disp), text_(text), firstOnScreen_(0),
|
||||
cursor_(text.size()), height_(-1), width_(width),
|
||||
buffer_(NULL), x_(-1), y_(-1),
|
||||
lastLArrow_(false), lastRArrow_(false),
|
||||
lastDelete_(false), lastBackspace_(false)
|
||||
buffer_(NULL), x_(-1), y_(-1), focus_(true)
|
||||
{
|
||||
std::fill(previousKeyState_,
|
||||
previousKeyState_+CHAR_LENGTH,true);
|
||||
|
@ -75,6 +74,9 @@ void textbox::draw() const
|
|||
SDL_BlitSurface(buffer_,NULL,disp_.video().getSurface(),&rect);
|
||||
}
|
||||
|
||||
gui::draw_solid_tinted_rectangle(x_,y_,width(),height(),0,0,0,
|
||||
focus_ ? 0.2 : 0.4, disp_.video().getSurface());
|
||||
|
||||
if(cursor_ == 0)
|
||||
draw_cursor(0);
|
||||
|
||||
|
@ -107,7 +109,7 @@ void textbox::draw() const
|
|||
|
||||
void textbox::handle_event(const SDL_Event& event)
|
||||
{
|
||||
if(event.type != SDL_KEYDOWN)
|
||||
if(event.type != SDL_KEYDOWN || !focus_)
|
||||
return;
|
||||
|
||||
const SDL_keysym& key
|
||||
|
@ -170,4 +172,9 @@ void textbox::set_location(int x, int y)
|
|||
buffer_.assign(get_surface_portion(disp_.video().getSurface(),portion));
|
||||
}
|
||||
|
||||
void textbox::set_focus(bool new_focus)
|
||||
{
|
||||
focus_ = new_focus;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class textbox : public events::handler
|
|||
CKey key_;
|
||||
bool previousKeyState_[CHAR_LENGTH];
|
||||
|
||||
bool lastLArrow_, lastRArrow_, lastDelete_, lastBackspace_;
|
||||
bool focus_;
|
||||
|
||||
void handle_event(const SDL_Event& event);
|
||||
|
||||
|
@ -57,6 +57,8 @@ public:
|
|||
void process();
|
||||
|
||||
void set_location(int x, int y);
|
||||
|
||||
void set_focus(bool new_focus);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue