Commit 19b99d92 authored by Corentin Bocquillon's avatar Corentin Bocquillon

Merge branch 'experimental'

parents 60af11fb caa30e11
FROM archlinux/base
RUN pacman --noconfirm -Syu
RUN pacman --noconfirm -S base-devel libxml2 protobuf guile jsoncpp libnoise sfml meson
pipeline
{
agent
{
dockerfile
{
filename 'Dockerfile.build'
}
}
stages
{
stage ('Build')
{
steps
{
sh './generate_protobuf.sh'
sh 'meson build'
sh 'ninja -C build'
}
}
}
}
File mode changed from 100644 to 100755
media/textures/pierre1.png

53 KB | W: | H:

media/textures/pierre1.png

3.11 KB | W: | H:

media/textures/pierre1.png
media/textures/pierre1.png
media/textures/pierre1.png
media/textures/pierre1.png
  • 2-up
  • Swipe
  • Onion skin
media/textures/pierre2.png

54.2 KB | W: | H:

media/textures/pierre2.png

3.68 KB | W: | H:

media/textures/pierre2.png
media/textures/pierre2.png
media/textures/pierre2.png
media/textures/pierre2.png
  • 2-up
  • Swipe
  • Onion skin
media/textures/pierre3.png

53.9 KB | W: | H:

media/textures/pierre3.png

4.12 KB | W: | H:

media/textures/pierre3.png
media/textures/pierre3.png
media/textures/pierre3.png
media/textures/pierre3.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -2,21 +2,22 @@ project('Factorywars', 'cpp', license: 'GPLv3+', version: '0.1',
default_options : ['cpp_std=c++11'])
compilateur = meson.get_compiler('cpp')
en_tetes = [include_directories('src'), include_directories('src/sdl')]
en_tetes = [include_directories('src'), include_directories('src/sfml')]
sources = ['src/main.cpp', 'src/items.cpp', 'src/config.cpp',
'src/items.cpp', 'src/save.cpp', 'src/tile.pb.cc', 'src/player.cpp',
'src/player-data.pb.cc', 'src/utils.cpp', 'src/XMLParser.cpp',
'src/sdl/display_map.cpp', 'src/sdl/game.cpp',
'src/sdl/game_events.cpp', 'src/sdl/gui_utils.cpp',
'src/sdl/gui_utils.h', 'src/sdl/menu.cpp', 'src/sdl/keyboard.cpp',
'src/sdl/mouse.cpp', 'src/sdl/FPSCounter.cpp',
'src/sdl/Interface.cpp', 'src/sdl/ground.cpp',
'src/MapGenerator.cpp', 'src/sdl/map.cpp', 'src/structures.hpp']
'src/sfml/display_map.cpp', 'src/sfml/game.cpp',
'src/sfml/game_events.cpp', 'src/sfml/gui_utils.cpp',
'src/sfml/gui_utils.h', 'src/sfml/menu.cpp', 'src/sfml/keyboard.cpp',
'src/sfml/mouse.cpp', 'src/sfml/FPSCounter.cpp',
'src/sfml/Interface.cpp', 'src/sfml/ground.cpp',
'src/MapGenerator.cpp', 'src/sfml/map.cpp', 'src/structures.hpp',
'src/sfml/inventory_interface.cpp']
libxml2 = dependency('libxml-2.0')
protobuf = dependency('protobuf')
guile = dependency('guile-2.0')
guile = dependency('guile-2.2')
json = dependency('jsoncpp')
noise = compilateur.find_library('noise')
if compilateur.has_header('libnoise/noise.h')
......
#include <iostream>
#include <SFML/Graphics.hpp>
using namespace std;
using namespace sf;
int
main (void)
{
cout << "Génération de l’image de l’inventaire…" << flush;
const int taille_case = 32;
const int espace_entre_case = 2;
const int espace_haut = 48;
const int espace_bas = 48;
const int espace_lateral = 10;
const int nb_case_lateral = 10;
const int nb_case_hauteur = 10;
Image fond;
int width = taille_case * nb_case_lateral;
width += espace_entre_case * (nb_case_lateral - 1);
width += espace_lateral * 2;
int height = taille_case * nb_case_hauteur;
height += espace_entre_case * (nb_case_hauteur - 1);
height += espace_haut + espace_bas;
fond.create (width, height, Color (59, 59, 59));
Image casei;
casei.create (taille_case, taille_case, Color::White);
for (unsigned i = 0; i < nb_case_lateral; ++i)
{
for (unsigned j = 0; j < nb_case_hauteur; ++j)
{
const int x = espace_lateral + i * taille_case + i * espace_entre_case;
const int y = espace_haut + j * taille_case + j * espace_entre_case;
fond.copy (casei, x, y);
}
}
fond.saveToFile ("inventaire.png");
cout << " Terminé !" << endl;
}
......@@ -38,27 +38,27 @@ ItemsName::ItemsName ()
{
string m_items_name[13] = {"Player",
// Ores
"Iron ore",
"Copper ore",
"Coal ore",
"Stone ore",
// Plates
"Iron plate",
"Copper plate",
// Inserters
"Burner inserter",
"Inserter",
"Fast inserter",
// Assembling machines
"Assembling machine",
// Other
"Wood",
"Stone block"};
// Ores
"Iron ore",
"Copper ore",
"Coal ore",
"Stone ore",
// Plates
"Iron plate",
"Copper plate",
// Inserters
"Burner inserter",
"Inserter",
"Fast inserter",
// Assembling machines
"Assembling machine",
// Other
"Wood",
"Stone block"};
for (int i = 0; sizeof (m_items_name) / sizeof (m_items_name[0]); i++)
{
m_items_map[i] = m_items_name[i];
......@@ -71,54 +71,54 @@ ItemsName::getItemName(int id)
return m_items_map[id];
}
std::map<int, sf::Texture> ItemsTexture::m_items_textures_map;
ItemsTexture::ItemsTexture ()
{
if (m_items_textures_map.size () == 0)
load_textures ();
}
ItemsTexture::~ItemsTexture ()
{
}
sf::Texture&
ItemsTexture::get_item_texture (int item_id)
{
return m_items_textures_map[item_id];
}
void
ItemsTexture::load_textures ()
{
string prefix;
if (!RUN_IN_PLACE)
prefix = string (TEXTURESDIR) + "/";
else
prefix = "../media/textures/";
vector<string> m_items_textures_path;
m_items_textures_path.push_back (prefix + "arbre2.png");
m_items_textures_path.push_back (prefix + "cuivre1.png");
m_items_textures_path.push_back (prefix + "cuivre2.png");
m_items_textures_path.push_back (prefix + "cuivre3.png");
m_items_textures_path.push_back (prefix + "fer1.png");
m_items_textures_path.push_back (prefix + "fer2.png");
m_items_textures_path.push_back (prefix + "fer3.png");
m_items_textures_path.push_back (prefix + "charbon1.png");
m_items_textures_path.push_back (prefix + "charbon2.png");
m_items_textures_path.push_back (prefix + "charbon3.png");
for (unsigned i = 1; i < m_items_textures_path.size () + 1; ++i)
{
if (!m_items_textures_map[i].loadFromFile (m_items_textures_path[i-1]))
throw runtime_error (m_items_textures_path[i] + string (" ")
+ " does not exist");
}
}
// std::map<int, sf::Texture> ItemsTexture::m_items_textures_map;
// ItemsTexture::ItemsTexture ()
// {
// if (m_items_textures_map.size () == 0)
// load_textures ();
// }
// ItemsTexture::~ItemsTexture ()
// {
// }
// sf::Texture&
// ItemsTexture::get_item_texture (int item_id)
// {
// return m_items_textures_map[item_id];
// }
// void
// ItemsTexture::load_textures ()
// {
// string prefix;
// if (!RUN_IN_PLACE)
// prefix = string (TEXTURESDIR) + "/";
// else
// prefix = "../media/textures/";
// vector<string> m_items_textures_path;
// m_items_textures_path.push_back (prefix + "arbre2.png");
// m_items_textures_path.push_back (prefix + "cuivre1.png");
// m_items_textures_path.push_back (prefix + "cuivre2.png");
// m_items_textures_path.push_back (prefix + "cuivre3.png");
// m_items_textures_path.push_back (prefix + "fer1.png");
// m_items_textures_path.push_back (prefix + "fer2.png");
// m_items_textures_path.push_back (prefix + "fer3.png");
// m_items_textures_path.push_back (prefix + "charbon1.png");
// m_items_textures_path.push_back (prefix + "charbon2.png");
// m_items_textures_path.push_back (prefix + "charbon3.png");
// for (unsigned i = 1; i < m_items_textures_path.size () + 1; ++i)
// {
// if (!m_items_textures_map[i].loadFromFile (m_items_textures_path[i-1]))
// throw runtime_error (m_items_textures_path[i] + string (" ")
// + " does not exist");
// }
// }
Machines::Machines()
......
......@@ -6,7 +6,7 @@
*
* @section LICENSE
*
* Copyright (C) 2016 Corentin Bocquillon <0x539@nybble.fr>
* Copyright (C) 2016-2018 Corentin Bocquillon <0x539@nybble.fr>
* Copyright (C) 2016 Loup Fourment
* Copyright (C) 2016 Pierre Gillet <pierre.gillet+factorywars@linuxw.info>
*
......@@ -49,17 +49,27 @@ ItemsName
};
class ItemsTexture
// class ItemsTexture
// {
// public:
// ItemsTexture ();
// ~ItemsTexture ();
// sf::Texture& get_item_texture (int item_id);
// private:
// static std::map<int, sf::Texture> m_items_textures_map;
// void load_textures ();
// };
class Item
{
public:
ItemsTexture ();
~ItemsTexture ();
sf::Texture& get_item_texture (int item_id);
int get_id ();
private:
static std::map<int, sf::Texture> m_items_textures_map;
void load_textures ();
int m_id;
};
......
......@@ -33,7 +33,7 @@
#include <getopt.h>
#include <clocale>
#include "sdl/game.h"
#include "sfml/game.h"
#include "gettext.h"
#define _(string) gettext (string)
......@@ -76,11 +76,7 @@ main (int argc, char *argv[])
print_help ();
exit (EXIT_SUCCESS);
break;
// L’option pour spécifier l’IP du serveur auquel on veut se
// connecter.
// case 's':
// IP = optarg;
// break;
case 'v':
print_version ();
exit(EXIT_SUCCESS);
......@@ -98,12 +94,11 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
if (run_gui () != 0)
{
return 1;
}
return 0;
int r = run_gui ();
if (r != 0)
return 1;
else
return 0;
}
static void
......
This diff is collapsed.
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: player-data.proto
// source: src/player-data.proto
#ifndef PROTOBUF_player_2ddata_2eproto__INCLUDED
#define PROTOBUF_player_2ddata_2eproto__INCLUDED
#ifndef PROTOBUF_INCLUDED_src_2fplayer_2ddata_2eproto
#define PROTOBUF_INCLUDED_src_2fplayer_2ddata_2eproto
#include <limits>
#include <string>
#include <google/protobuf/stubs/common.h>
#if GOOGLE_PROTOBUF_VERSION < 3005000
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3007000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#if 3007000 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/inlined_string_field.h>
#include <google/protobuf/metadata.h>
#include <google/protobuf/message.h>
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
#define PROTOBUF_INTERNAL_EXPORT_src_2fplayer_2ddata_2eproto
namespace protobuf_player_2ddata_2eproto {
// Internal implementation detail -- do not use these members.
struct TableStruct {
static const ::google::protobuf::internal::ParseTableField entries[];
static const ::google::protobuf::internal::AuxillaryParseTableField aux[];
static const ::google::protobuf::internal::ParseTable schema[1];
struct TableStruct_src_2fplayer_2ddata_2eproto {
static const ::google::protobuf::internal::ParseTableField entries[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::AuxillaryParseTableField aux[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::ParseTable schema[1]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
static const ::google::protobuf::internal::SerializationTable serialization_table[];
static const ::google::protobuf::uint32 offsets[];
};
void AddDescriptors();
void InitDefaultsplayer_dataImpl();
void InitDefaultsplayer_data();
inline void InitDefaults() {
InitDefaultsplayer_data();
}
} // namespace protobuf_player_2ddata_2eproto
void AddDescriptors_src_2fplayer_2ddata_2eproto();
class player_data;
class player_dataDefaultTypeInternal;
extern player_dataDefaultTypeInternal _player_data_default_instance_;
namespace google {
namespace protobuf {
template<> ::player_data* Arena::CreateMaybeMessage<::player_data>(Arena*);
} // namespace protobuf
} // namespace google
// ===================================================================
class player_data : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:player_data) */ {
class player_data final :
public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:player_data) */ {
public:
player_data();
virtual ~player_data();
......@@ -87,7 +93,9 @@ class player_data : public ::google::protobuf::Message /* @@protoc_insertion_poi
return _internal_metadata_.mutable_unknown_fields();
}
static const ::google::protobuf::Descriptor* descriptor();
static const ::google::protobuf::Descriptor* descriptor() {
return default_instance().GetDescriptor();
}
static const player_data& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
......@@ -95,7 +103,7 @@ class player_data : public ::google::protobuf::Message /* @@protoc_insertion_poi
return reinterpret_cast<const player_data*>(
&_player_data_default_instance_);
}
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
static constexpr int kIndexInFileMessages =
0;
void Swap(player_data* other);
......@@ -105,39 +113,49 @@ class player_data : public ::google::protobuf::Message /* @@protoc_insertion_poi
// implements Message ----------------------------------------------
inline player_data* New() const PROTOBUF_FINAL { return New(NULL); }
inline player_data* New() const final {
return CreateMaybeMessage<player_data>(nullptr);
}
player_data* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
player_data* New(::google::protobuf::Arena* arena) const final {
return CreateMaybeMessage<player_data>(arena);
}
void CopyFrom(const ::google::protobuf::Message& from) final;
void MergeFrom(const ::google::protobuf::Message& from) final;
void CopyFrom(const player_data& from);
void MergeFrom(const player_data& from);
void Clear() PROTOBUF_FINAL;
bool IsInitialized() const PROTOBUF_FINAL;
size_t ByteSizeLong() const PROTOBUF_FINAL;
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
size_t ByteSizeLong() const final;
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
static const char* _InternalParse(const char* begin, const char* end, void* object, ::google::protobuf::internal::ParseContext* ctx);
::google::protobuf::internal::ParseFunc _ParseFunc() const final { return _InternalParse; }
#else
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
::google::protobuf::io::CodedInputStream* input) final;
#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::io::CodedOutputStream* output) const final;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
::google::protobuf::uint8* target) const final;
int GetCachedSize() const final { return _cached_size_.Get(); }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const PROTOBUF_FINAL;
void SetCachedSize(int size) const final;
void InternalSwap(player_data* other);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
return NULL;
return nullptr;
}
inline void* MaybeArenaPtr() const {
return NULL;
return nullptr;
}
public:
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
::google::protobuf::Metadata GetMetadata() const final;
// nested types ----------------------------------------------------
......@@ -243,41 +261,29 @@ class player_data : public ::google::protobuf::Message /* @@protoc_insertion_poi
// @@protoc_insertion_point(class_scope:player_data)
private:
void set_has_name();
void clear_has_name();
void set_has_health();
void clear_has_health();
void set_has_x();
void clear_has_x();
void set_has_y();
void clear_has_y();
void set_has_velocity();
void clear_has_velocity();
void set_has_selected_tool();
void clear_has_selected_tool();
class HasBitSetters;
// helper for ByteSizeLong()
size_t RequiredFieldsByteSizeFallback() const;
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::HasBits<1> _has_bits_;
mutable int _cached_size_;
mutable ::google::protobuf::internal::CachedSize _cached_size_;
::google::protobuf::RepeatedField< ::google::protobuf::int32 > inventory_item_id_;
mutable int _inventory_item_id_cached_byte_size_;
mutable std::atomic<int> _inventory_item_id_cached_byte_size_;
::google::protobuf::RepeatedField< ::google::protobuf::int32 > inventory_number_;
mutable int _inventory_number_cached_byte_size_;
mutable std::atomic<int> _inventory_number_cached_byte_size_;
::google::protobuf::RepeatedField< ::google::protobuf::int32 > toolbar_item_id_;
mutable int _toolbar_item_id_cached_byte_size_;
mutable std::atomic<int> _toolbar_item_id_cached_byte_size_;
::google::protobuf::RepeatedField< ::google::protobuf::int32 > toolbar_number_;
mutable int _toolbar_number_cached_byte_size_;
mutable std::atomic<int> _toolbar_number_cached_byte_size_;
::google::protobuf::internal::ArenaStringPtr name_;
::google::protobuf::int64 x_;
::google::protobuf::int32 health_;
::google::protobuf::int32 velocity_;
::google::protobuf::int64 y_;
::google::protobuf::int32 selected_tool_;
friend struct ::protobuf_player_2ddata_2eproto::TableStruct;
friend void ::protobuf_player_2ddata_2eproto::InitDefaultsplayer_dataImpl();
friend struct ::TableStruct_src_2fplayer_2ddata_2eproto;
};
// ===================================================================
......@@ -294,60 +300,57 @@ class player_data : public ::google::protobuf::Message /* @@protoc_insertion_poi
inline bool player_data::has_name() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void player_data::set_has_name() {
_has_bits_[0] |= 0x00000001u;
}
inline void player_data::clear_has_name() {
_has_bits_[0] &= ~0x00000001u;
}
inline void player_data::clear_name() {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
clear_has_name();
_has_bits_[0] &= ~0x00000001u;
}
inline const ::std::string& player_data::name() const {
// @@protoc_insertion_point(field_get:player_data.name)
return name_.GetNoArena();
}
inline void player_data::set_name(const ::std::string& value) {
set_has_name();
_has_bits_[0] |= 0x00000001u;
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:player_data.name)
}
#if LANG_CXX11
inline void player_data::set_name(::std::string&& value) {
set_has_name();
_has_bits_[0] |= 0x00000001u;
name_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:player_data.name)
}
#endif
inline void player_data::set_name(const char* value) {
GOOGLE_DCHECK(value != NULL);
set_has_name();
GOOGLE_DCHECK(value != nullptr);
_has_bits_[0] |= 0x00000001u;
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:player_data.name)
}
inline void player_data::set_name(const char* value, size_t size) {