Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade libtcod to 1.16.0-alpha.12 #309

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
33db44c
Update bindgen configuration, update bindings
ilyvion Jun 27, 2020
899cd6a
Update outdated dependencies
ilyvion Jun 27, 2020
da3557f
Left some junk behind in README.md
ilyvion Jun 27, 2020
137fbb7
Add bindings for x86_64 Linux
ilyvion Jun 27, 2020
1aaf421
Fix a few overlooked issues
ilyvion Jun 27, 2020
e6fa3dc
Run `cargo fmt`
ilyvion Jun 27, 2020
f89fdd2
Since TCOD_font_flags_t hosts flags, declare it as a bitfield_enum
ilyvion Jun 27, 2020
63f23f8
Update libtcod to 1.7
ilyvion Jun 27, 2020
24b300d
Update bindings for x86_64 Linux
ilyvion Jun 27, 2020
8232a9d
Fix type issue
ilyvion Jun 27, 2020
5f3e835
Update bindings for x86_64 Linux
ilyvion Jun 27, 2020
e6b14b4
Add some files I forgot from the 1.7 update
ilyvion Jun 27, 2020
38f8b81
Upgrade libtcod to 1.16.0-alpha.12
ilyvion Jun 27, 2020
fc50ae8
Update bindings for x86_64 Linux
ilyvion Jun 28, 2020
026ce3d
Add error handling where appropriate
ilyvion Jun 28, 2020
2de9421
Attempt to get builds working
ilyvion Jun 29, 2020
bcc093c
Remove silly TCOD_font_flags_t_type kludge
ilyvion Jun 30, 2020
9fbd184
Clean up travis file somewhat; upload bindings generated to file.io
ilyvion Jun 30, 2020
329d0dc
Fix windows-gnu builds?
ilyvion Jun 30, 2020
1f3fe39
Run Travis scripts in current shell (i.e. source them)
ilyvion Jun 30, 2020
f32be1e
Set target/sysroot manually on windows-gnu targets
ilyvion Jun 30, 2020
8cc0a6a
Try fixing LLVM issues on OSX
ilyvion Jun 30, 2020
e7faf9b
Try explicitly installing grep
ilyvion Jun 30, 2020
86b5d80
Add bindings from CI builds
ilyvion Jun 30, 2020
77f3779
Disable i686-pc-windows-gnu for now
ilyvion Jul 1, 2020
a04e133
Add myself to lists of contributors
ilyvion Jul 1, 2020
03a35b3
Update README and crate version
ilyvion Jul 6, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 9 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ matrix:
- os: osx
rust: nightly
before_install:
- '[ "$TRAVIS_OS_NAME" = linux ] && sudo apt-get update -qq || brew update'
- chmod +x .travis/*.sh
- 'if [[ -f ".travis/${TRAVIS_OS_NAME}_before_install.sh" ]]; then . .travis/${TRAVIS_OS_NAME}_before_install.sh; fi'
install:
- '[ "$TRAVIS_OS_NAME" = linux ] && sudo apt-get install -y libsdl2-dev libegl1-mesa-dev libgles2-mesa-dev || brew install sdl2'
- 'if [[ -f ".travis/${TRAVIS_OS_NAME}_install.sh" ]]; then . .travis/${TRAVIS_OS_NAME}_install.sh; fi'
script:
- 'if [[ -f ".travis/${TRAVIS_OS_NAME}_script.sh" ]]; then . .travis/${TRAVIS_OS_NAME}_script.sh; fi'
- 'if [[ "$TRAVIS_OS_NAME" == linux ]]; then export GREP=grep; else export GREP=ggrep; fi'
- export DEFAULT_TARGET=$(rustup show | grep default | $GREP -Po "^[^-]+-\K\S+")
- pushd tcod_sys; cargo build --features generate_bindings; popd
- 'export BINDINGS_FILE=${DEFAULT_TARGET}_bindings.rs; echo "$BINDINGS_FILE download:"'
- curl -F "file=@./tcod_sys/${BINDINGS_FILE}" https://file.io/ | $GREP -Po '"link":"\K[^"]+'
- cargo build --verbose
- cargo test --verbose
- cargo test --features "rustc-serialize serde" --verbose
Expand Down
3 changes: 3 additions & 0 deletions .travis/linux_before_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

sudo apt-get update -qq
3 changes: 3 additions & 0 deletions .travis/linux_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

sudo apt-get install -y libsdl2-dev libegl1-mesa-dev libgles2-mesa-dev llvm-dev libclang-dev clang
6 changes: 6 additions & 0 deletions .travis/linux_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

wget -O - https://www.libsdl.org/release/SDL2-2.0.12.tar.gz | tar xz
(cd SDL2-* && ./configure --prefix="$HOME/.local" && make -j 3 install)
export PATH=~/.local/bin:$PATH
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$HOME/.local/lib/pkgconfig"
3 changes: 3 additions & 0 deletions .travis/osx_before_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

brew update
3 changes: 3 additions & 0 deletions .travis/osx_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

brew install sdl2 llvm grep
5 changes: 5 additions & 0 deletions .travis/osx_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

export PATH="$(brew --prefix llvm)/bin:$PATH"
export LIBCLANG_PATH="$(brew --prefix llvm)/lib"

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[package]
name = "tcod"
description = "The Rust bindings for the Doryen library (a.k.a. libtcod)."
version = "0.15.0"
version = "0.16.0"
homepage = "https://github.com/tomassedovic/tcod-rs"
repository = "https://github.com/tomassedovic/tcod-rs"
documentation = "http://tomassedovic.github.io/tcod-rs/tcod/index.html"
readme = "README.md"
keywords = ["gamedev", "roguelike", "libtcod"]
license = "WTFPL"
authors = ["Tomas Sedovic <[email protected]>",
"Alexander Krivács Schrøder <[email protected]>",
"Bastien Léonard <[email protected]>",
"Darren Kaste <[email protected]>",
"Edu Garcia <[email protected]>",
Expand All @@ -31,8 +32,8 @@ name = "tcod"
path = "src/lib.rs"

[dependencies]
bitflags = "0.1"
lazy_static = "0.1"
bitflags = "1.2"
lazy_static = "1.4"
rustc-serialize = { optional = true, version = "0.3" }
serde = { optional = true, version = "1.0" }
serde_derive = { optional = true, version = "1.0" }
Expand All @@ -43,7 +44,7 @@ serialization = ["serde", "serde_derive"]

[dependencies.tcod-sys]
path = "tcod_sys"
version = "5.0.0"
version = "6.0.0"

[dev-dependencies]
rand = "0.3"
Expand Down
20 changes: 5 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ useful functionality such as:


This project provides [Rust](http://www.rust-lang.org/) bindings for libtcod
v1.6.3.
v1.16.0-alpha.12.

This project follows [Semantic Versioning](http://semver.org/). Since we're
under `1.0.0` anything goes. The API can change at any time.
Expand All @@ -40,7 +40,7 @@ https://libtcod.readthedocs.io/en/stable/
Current status
--------------

All raw tcod bindings are available via the `tcod-sys` crate. In addition we
All raw tcod bindings are available via the `tcod-sys` crate. In addition, we
want to provide safe (and more in line with the Rust style) wrappers -- if you
can segfault outside of `unsafe` blocks, that's a bug. The safe bindings are not
yet complete, however.
Expand Down Expand Up @@ -74,7 +74,7 @@ How to use this
---------------

`tcod-rs` depends on `libtcod` so you need to build or download the official
version. The `libtcod` version known to work is bundled with `tcod-sys` and
version. The `libtcod` version known to work comes bundled with `tcod-sys` and
Cargo will build it for you, but you need the build dependencies installed.

Alternatively, you can provide the precompiled libtcod library to override the
Expand All @@ -84,7 +84,7 @@ To use `tcod-rs`, add this to your game's `Cargo.toml`:

```toml
[dependencies]
tcod = "0.15"
tcod = "0.16"
```

### Building on Linux
Expand Down Expand Up @@ -184,28 +184,18 @@ We're not sure exactly why this is so we'd appreciate anyone's help!
Contributing
------------

The raw bindings were generated using
[rust-bindgen](https://github.com/rust-lang/rust-bindgen) and are located at
`src/ffi.rs`. The safe (hopefully?) wrapper was built on top of them at
`src/lib.rs`.

This is far from done, patches to missing functionality wrappers, documentation
and examples are very much appreciated. If your patch (any patch -- including
typos) gets accepted, you'll get a commit access if you want it.

We accept GitHub as well as regular pull requests (i.e. emailing or tweeting the
URL of your feature branch works).

You can regenerate the raw bindings by running:

```sh
bindgen -builtins -l tcod include/libtcod.h -o src/ffi.rs
```


### Contributors


* Alexander Krivács Schrøder <[email protected]>
* Bastien Léonard, @bastienleonard, <[email protected]>
* Darren Kaste, @dkaste, <[email protected]>
* Edu Garcia, @Arcnor, <[email protected]>
Expand Down
Binary file added angband16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 13 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ environment:
VS: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
- TARGET: x86_64-pc-windows-gnu
MSYS_BITS: 64
- TARGET: i686-pc-windows-gnu
MSYS_BITS: 32
# - TARGET: i686-pc-windows-gnu
# MSYS_BITS: 32
install:
- ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe"
- rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust"
Expand All @@ -19,9 +19,20 @@ install:
- set RUST_BACKTRACE=1
- rustc -V
- cargo -V
- ps: $env:BITS=$(if ($env:ARCH -eq "amd64" -or $env:MSYS_BITS -eq "64") { 64 } else { 32 })
- ps: $env:PROGRAM_FILES=$(if ($env:ARCH -eq "amd64" -or $env:MSYS_BITS -eq "64") { "C:\Program Files" } else { ${env:ProgramFiles(x86)} })
- ps: Start-FileDownload "https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/LLVM-10.0.0-win${env:BITS}.exe"
- LLVM-10.0.0-win%BITS%.exe /S /D=%PROGRAM_FILES%\LLVM
- set LIBCLANG_PATH=%PROGRAM_FILES%\LLVM\bin

build: false

build_script:
- cd tcod_sys && cargo build --features generate_bindings && cd ..

test_script:
- cargo test
- cargo test --release

artifacts:
- path: tcod_sys\$(TARGET)_bindings.rs
1 change: 0 additions & 1 deletion examples/astar-path-finding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ fn main() {
assert_eq!(path.get(6), None);
assert_eq!(path.get(7), None);


// Walk the path (consuming it):
for pos in path.walk() {
println!("Walking to {:?}", pos);
Expand Down
44 changes: 34 additions & 10 deletions examples/blit.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
extern crate tcod;

use tcod::console;
use tcod::{Console, RootConsole, OffscreenConsole, Color};
use tcod::error::Result;
use tcod::{Color, Console, OffscreenConsole, RootConsole};


fn main() {
fn main() -> Result<()> {
let mut root = RootConsole::initializer()
.size(80, 50)
.title("Using blit with libtcod")
.init();
.init()?;

let mut direct: OffscreenConsole = OffscreenConsole::new(20, 20);
let mut boxed_direct: Box<OffscreenConsole> = Box::new(OffscreenConsole::new(20, 20));
let mut trait_object: &dyn Console = &OffscreenConsole::new(20, 20);
let mut boxed_trait: Box<dyn Console> = Box::new(OffscreenConsole::new(20, 20));


root.set_default_background(Color::DARKEST_GREEN);

direct.set_default_background(Color::RED);
Expand All @@ -30,12 +29,37 @@ fn main() {
trait_object.clear();
boxed_trait.clear();


console::blit(&direct, (0, 0), (20, 20), &mut root, (0, 0), 1.0, 1.0);
console::blit(&boxed_direct, (0, 0), (20, 20), &mut root, (20, 0), 1.0, 1.0);
console::blit(&trait_object, (0, 0), (20, 20), &mut root, (0, 20), 1.0, 1.0);
console::blit(&boxed_trait, (0, 0), (20, 20), &mut root, (20, 20), 1.0, 1.0);
console::blit(
&boxed_direct,
(0, 0),
(20, 20),
&mut root,
(20, 0),
1.0,
1.0,
);
console::blit(
&trait_object,
(0, 0),
(20, 20),
&mut root,
(0, 20),
1.0,
1.0,
);
console::blit(
&boxed_trait,
(0, 0),
(20, 20),
&mut root,
(20, 20),
1.0,
1.0,
);

root.flush();
root.flush()?;
root.wait_for_keypress(true);

Ok(())
}
12 changes: 7 additions & 5 deletions examples/chars.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
extern crate tcod;

use tcod::{Console, RootConsole};
use tcod::chars;
use tcod::error::Result;
use tcod::{Console, RootConsole};

fn main() {
fn main() -> Result<()> {
let mut root = RootConsole::initializer()
.size(80, 50)
.title("Example of libtcod's special chars")
.init();
.init()?;

root.clear();

Expand All @@ -26,7 +27,8 @@ fn main() {
root.set_char(39, 26, chars::VLINE);
root.set_char(39, 25, chars::NW);

root.flush();
root.flush()?;
root.wait_for_keypress(true);
}

Ok(())
}
24 changes: 18 additions & 6 deletions examples/colors.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
extern crate tcod;

use tcod::{Console, RootConsole, Color, BackgroundFlag};
use tcod::colors;
use tcod::error::Result;
use tcod::{BackgroundFlag, Color, Console, RootConsole};


fn main() {
fn main() -> Result<()> {
let mut con = RootConsole::initializer()
.size(80, 50)
.title("Using colours with libtcod")
.init();
.init()?;
con.set_default_background(Color::DARKEST_GREEN);
con.set_default_foreground(Color::LIGHTER_AZURE);

con.clear();
// Uses the default foreground and background:
con.put_char(40, 25, '@', BackgroundFlag::Set);
// Custom foreground and background:
con.put_char_ex(42, 25, '!', Color{r: 240, g: 13, b: 20}, Color{r: 0, g: 0, b: 0});
con.put_char_ex(
42,
25,
'!',
Color {
r: 240,
g: 13,
b: 20,
},
Color { r: 0, g: 0, b: 0 },
);

let black = Color::new(0, 0, 0);
let red = Color::new(200, 0, 0);
Expand All @@ -31,8 +41,10 @@ fn main() {
let (h, s, v) = red.hsv();
println!("Red colour's hue: {}, saturation: {}, value: {}", h, s, v);

con.flush();
con.flush()?;

// Press any key to exit:
con.wait_for_keypress(true);

Ok(())
}
17 changes: 10 additions & 7 deletions examples/custom_character_mapping.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extern crate tcod;

use tcod::{Console, RootConsole, FontLayout, FontType};
use tcod::error::Result;
use tcod::{Console, FontLayout, FontType, RootConsole};

const FLOOR_TILE: char = 1 as char;
const WALL_TILE: char = 2 as char;
Expand All @@ -15,15 +16,15 @@ const MAP_HEIGHT: i32 = 50;
const ROOM_WIDTH: i32 = 20;
const ROOM_HEIGHT: i32 = 15;

fn main() {
fn main() -> Result<()> {
let mut root = RootConsole::initializer()
.font("angband16x16.bmp", FontLayout::Tcod)
.font_type(FontType::Greyscale)
.font("angband16x16.png", FontLayout::TCOD)
.font_type(FontType::GREYSCALE)
.font_dimensions(32, 60) // angband16x16.bmp has 32 columns & 60 rows of
// characters
// characters
.size(MAP_WIDTH, MAP_HEIGHT)
.title("Using custom character mapping with libtcod")
.init();
.init()?;

// map ASCII_CODE to character in font at position X, Y
root.map_ascii_code_to_font(FLOOR_TILE as i32, 4, 0);
Expand Down Expand Up @@ -64,6 +65,8 @@ fn main() {
root.set_char(middle_x + 2, middle_y - 5, ENEMY_2_TILE);
root.set_char(middle_x, middle_y - 7, CHEST_TILE);

root.flush();
root.flush()?;
root.wait_for_keypress(true);

Ok(())
}
1 change: 0 additions & 1 deletion examples/dijkstra-path-finding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ fn walk_from(path: &mut Dijkstra, origin: (i32, i32)) {
println!("Arrived at the destination!\n");
}


fn main() {
let mut path = create_path();
let destination = (0, 0);
Expand Down
Loading