rg-chess 0.2.4

Chess Game with graphical interface.
Documentation
//! # Rust Chess Library
//!
//! This is a chess library for rust with Gui.
//!
//! ## Examples
//!
//! ```no_run
//! use chess::{run, ChessGui};
//!
//! fn main() {
//!     // Create and run the Gui game
//!     run(ChessGui::default());
//! }
//! ```

#![allow(clippy::needless_doctest_main, clippy::collapsible_if)]
#![deny(
    // missing_docs, // This lint ask to document all variants/fields of enum/struct.
    missing_debug_implementations,
    missing_copy_implementations,
    trivial_casts,
    trivial_numeric_casts,
    // unsafe_code,
    unstable_features,
    unused_import_braces,
    unused_qualifications
)]

// Core

mod board;
pub use crate::board::*;

mod chess;
pub use crate::chess::*;

mod piece;
pub use crate::piece::*;

mod color;
pub use crate::color::*;

mod castle_rights;
pub use crate::castle_rights::*;

mod error;
pub use crate::error::*;

mod config;
pub use crate::config::*;

mod square;
pub use crate::square::*;

mod file;
pub use crate::file::*;

mod rank;
pub use crate::rank::*;

mod chess_move;
pub use crate::chess_move::*;

mod direction;
pub use crate::direction::*;

// Gui

mod chess_gui;
pub use crate::chess_gui::*;

mod button;
pub use crate::button::*;

mod theme;
pub use crate::theme::*;

// Function

/// Run the GUI.
pub fn run(game: ChessGui) {
    let default_conf = ggez::conf::Conf {
        window_mode: ggez::conf::WindowMode::default()
            .dimensions(SCREEN_PX_SIZE.0, SCREEN_PX_SIZE.1),
        window_setup: ggez::conf::WindowSetup::default()
            .title("Chess")
            .icon("/images/icon.png"),
        backend: ggez::conf::Backend::default(),
        modules: ggez::conf::ModuleConf {
            gamepad: false,
            audio: false,
        },
    };
    let (ctx, event_loop) =
        ggez::ContextBuilder::new(env!("CARGO_PKG_NAME"), env!("CARGO_PKG_AUTHORS"))
            .add_resource_path::<std::path::PathBuf>(
                [env!("CARGO_MANIFEST_DIR"), "resources"].iter().collect(),
            )
            .default_conf(default_conf)
            .build()
            .expect("Failed to build ggez context");

    ggez::event::run(ctx, event_loop, game)
}