mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-28 22:04:24 +00:00
improved mouse wheel behavior
This commit is contained in:
parent
ed67872056
commit
b6ffae78a5
@ -500,7 +500,7 @@ void play_turn(game_data& gameinfo, game_state& state_of_game,
|
||||
|
||||
// MOUSE WHEEL BOUNDARY CHECK
|
||||
|
||||
if(gui::scrollamount() && (mousex > 50 && mousex < gui.x()-50) &&
|
||||
if(gui::scrollamount() && (mousex > 50 && mousex < gui.mapx()-50) &&
|
||||
(mousey > 50 && mousey < gui.y()-50)) {
|
||||
// Reset scrolling ... it is just a clean-up so wheel turns
|
||||
//don't cache
|
||||
@ -508,7 +508,7 @@ void play_turn(game_data& gameinfo, game_state& state_of_game,
|
||||
} else {
|
||||
if(gui::scrollamount()) {
|
||||
// Now scroll accordingly as we are in hot-spots
|
||||
if((mousex >= gui.x()-50 && mousey <= 50) ||
|
||||
if((mousex >= gui.mapx()-50 && mousey <= 50) ||
|
||||
(mousex <= 50 && mousey >= gui.y()-50)) {
|
||||
// firstly filtering the 2 conflicting corners
|
||||
if(gui::scrollamount() > 0) {
|
||||
@ -520,7 +520,7 @@ void play_turn(game_data& gameinfo, game_state& state_of_game,
|
||||
}
|
||||
} else {
|
||||
// Now general case...
|
||||
if(mousex <= 50 || mousex >= gui.x()-50) {
|
||||
if(mousex <= 50 || mousex >= gui.mapx()-50) {
|
||||
// SCROLL HORIZONTALLY... we are in E or W sides
|
||||
gui::scrollamount() < 0 ?
|
||||
gui.scroll(-preferences::scroll_speed(),0.0)
|
||||
|
@ -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= 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
|
||||
|
||||
server: $(OBJS)
|
||||
gcc -lstdc++ ${SDL_CFLAGS} -o $@ ${OBJS} ${SDL_LIBS}
|
||||
|
64
src/server/game.cpp
Normal file
64
src/server/game.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
#include "game.hpp"
|
||||
|
||||
int game::id_num = 1;
|
||||
|
||||
game::game() : id_(id_num++)
|
||||
{}
|
||||
|
||||
bool game::is_member(network::connection player) const
|
||||
{
|
||||
return std::find(players_.begin(),players_.end(),player) != players_.end();
|
||||
}
|
||||
|
||||
void game::add_player(network::connection player)
|
||||
{
|
||||
players_.push_back(player);
|
||||
}
|
||||
|
||||
void game::remove_player(network::connection player)
|
||||
{
|
||||
const std::vector<network::connection>::iterator itor =
|
||||
std::find(players_.begin(),players_.end(),player);
|
||||
if(itor != players_.end())
|
||||
players_.erase(itor);
|
||||
}
|
||||
|
||||
int game::id() const
|
||||
{
|
||||
return id_;
|
||||
}
|
||||
|
||||
void game::send_data(const config& data, network::connection exclude)
|
||||
{
|
||||
for(std::vector<network::connection>::const_iterator
|
||||
i = players_.begin(); i != players_.end(); ++i) {
|
||||
if(*i != exclude) {
|
||||
network::send_data(data,*i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool game::level_init() const
|
||||
{
|
||||
return level_.child("side") != NULL;
|
||||
}
|
||||
|
||||
config& game::level()
|
||||
{
|
||||
return level_;
|
||||
}
|
||||
|
||||
bool game::empty() const
|
||||
{
|
||||
return players_.empty();
|
||||
}
|
||||
|
||||
void game::disconnect()
|
||||
{
|
||||
for(std::vector<network::connection>::iterator i = players_.begin();
|
||||
i != players_.end(); ++i) {
|
||||
network::disconnect(*i);
|
||||
}
|
||||
|
||||
players_.clear();
|
||||
}
|
45
src/server/game.hpp
Normal file
45
src/server/game.hpp
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef GAME_HPP_INCLUDED
|
||||
#define GAME_HPP_INCLUDED
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "../network.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
class game
|
||||
{
|
||||
public:
|
||||
game();
|
||||
|
||||
bool is_member(network::connection player) const;
|
||||
|
||||
void add_player(network::connection player);
|
||||
void remove_player(network::connection player);
|
||||
|
||||
int id() const;
|
||||
|
||||
void send_data(const config& data, network::connection exclude=0);
|
||||
|
||||
bool level_init() const;
|
||||
config& level();
|
||||
bool empty() const;
|
||||
void disconnect();
|
||||
|
||||
private:
|
||||
static int id_num;
|
||||
int id_;
|
||||
std::vector<network::connection> players_;
|
||||
config level_;
|
||||
};
|
||||
|
||||
struct game_id_matches
|
||||
{
|
||||
game_id_matches(int id) : id_(id) {}
|
||||
bool operator()(const game& g) const { return g.id() == id_; }
|
||||
|
||||
private:
|
||||
int id_;
|
||||
};
|
||||
|
||||
#endif
|
@ -3,78 +3,14 @@
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include "game.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
class game
|
||||
{
|
||||
public:
|
||||
game() : id_(id_num++)
|
||||
{}
|
||||
|
||||
bool is_member(network::connection player) const {
|
||||
return std::find(players_.begin(),players_.end(),player)
|
||||
!= players_.end();
|
||||
}
|
||||
|
||||
void add_player(network::connection player) {
|
||||
players_.push_back(player);
|
||||
}
|
||||
|
||||
void remove_player(network::connection player) {
|
||||
std::vector<network::connection>::iterator itor =
|
||||
std::find(players_.begin(),players_.end(),player);
|
||||
if(itor != players_.end())
|
||||
players_.erase(itor);
|
||||
}
|
||||
|
||||
int id() const { return id_; }
|
||||
|
||||
void send_data(const config& data, network::connection exclude=0) {
|
||||
for(std::vector<network::connection>::const_iterator
|
||||
i = players_.begin(); i != players_.end(); ++i) {
|
||||
if(*i != exclude) {
|
||||
network::send_data(data,*i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool level_init() const { return level_.child("side") != NULL; }
|
||||
|
||||
config& level() { return level_; }
|
||||
|
||||
bool empty() const { return players_.empty(); }
|
||||
|
||||
void disconnect() {
|
||||
for(std::vector<network::connection>::iterator i = players_.begin();
|
||||
i != players_.end(); ++i) {
|
||||
network::disconnect(*i);
|
||||
}
|
||||
|
||||
players_.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
static int id_num;
|
||||
int id_;
|
||||
std::vector<network::connection> players_;
|
||||
config level_;
|
||||
};
|
||||
|
||||
int game::id_num = 1;
|
||||
|
||||
struct game_id_matches
|
||||
{
|
||||
game_id_matches(int id) : id_(id) {}
|
||||
bool operator()(const game& g) const { return g.id() == id_; }
|
||||
|
||||
private:
|
||||
int id_;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
const network::manager net_manager;
|
||||
|
Loading…
x
Reference in New Issue
Block a user