Start on the palette
This commit is contained in:
parent
1fe33f28f8
commit
5899e05191
|
@ -28,13 +28,13 @@ const DRAWING_ORIGIN: (f64, f64) = (1024. / 2., 768. / 2.);
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
enum Terrain {
|
enum Terrain {
|
||||||
Empty,
|
|
||||||
Mountain,
|
|
||||||
Grasslands,
|
|
||||||
ShallowWater,
|
|
||||||
DeepWater,
|
|
||||||
Badlands,
|
Badlands,
|
||||||
|
DeepWater,
|
||||||
Desert,
|
Desert,
|
||||||
|
Empty,
|
||||||
|
Grasslands,
|
||||||
|
Mountain,
|
||||||
|
ShallowWater,
|
||||||
Swamp,
|
Swamp,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,6 +113,7 @@ fn main() {
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct HexGridWindowPrivate {
|
pub struct HexGridWindowPrivate {
|
||||||
layout: gtk::Box,
|
layout: gtk::Box,
|
||||||
|
palette: gtk::Box,
|
||||||
|
|
||||||
drawing_area: DrawingArea,
|
drawing_area: DrawingArea,
|
||||||
hex_address: Label,
|
hex_address: Label,
|
||||||
|
@ -128,6 +129,7 @@ impl ObjectSubclass for HexGridWindowPrivate {
|
||||||
type ParentType = gtk::ApplicationWindow;
|
type ParentType = gtk::ApplicationWindow;
|
||||||
|
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
|
println!("hexGridWindowPrivate::new()");
|
||||||
let current_coordinate = Rc::new(RefCell::new(None));
|
let current_coordinate = Rc::new(RefCell::new(None));
|
||||||
|
|
||||||
let drawing_area = DrawingArea::builder()
|
let drawing_area = DrawingArea::builder()
|
||||||
|
@ -195,8 +197,15 @@ impl ObjectSubclass for HexGridWindowPrivate {
|
||||||
|
|
||||||
hex_address_row.append(&hex_address);
|
hex_address_row.append(&hex_address);
|
||||||
|
|
||||||
|
let palette = gtk::Box::builder()
|
||||||
|
.spacing(8)
|
||||||
|
.orientation(gtk::Orientation::Vertical)
|
||||||
|
.hexpand(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
sidebar.append(&canvas_address_row);
|
sidebar.append(&canvas_address_row);
|
||||||
sidebar.append(&hex_address_row);
|
sidebar.append(&hex_address_row);
|
||||||
|
sidebar.append(&palette);
|
||||||
|
|
||||||
layout.append(&drawing_area);
|
layout.append(&drawing_area);
|
||||||
layout.append(&sidebar);
|
layout.append(&sidebar);
|
||||||
|
@ -209,12 +218,14 @@ impl ObjectSubclass for HexGridWindowPrivate {
|
||||||
canvas_address,
|
canvas_address,
|
||||||
current_coordinate,
|
current_coordinate,
|
||||||
layout,
|
layout,
|
||||||
|
palette,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ObjectImpl for HexGridWindowPrivate {
|
impl ObjectImpl for HexGridWindowPrivate {
|
||||||
fn constructed(&self) {
|
fn constructed(&self) {
|
||||||
|
println!("HexGridWindowPrivate::constructed()");
|
||||||
self.parent_constructed();
|
self.parent_constructed();
|
||||||
|
|
||||||
let map_text_resource = resources_lookup_data(
|
let map_text_resource = resources_lookup_data(
|
||||||
|
@ -236,14 +247,29 @@ impl ObjectImpl for HexGridWindowPrivate {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let image = reader.decode().unwrap();
|
let image = reader.decode().unwrap();
|
||||||
let deep_water = Tile::new(&image, Terrain::DeepWater);
|
|
||||||
let shallow_water = Tile::new(&image, Terrain::ShallowWater);
|
|
||||||
let grasslands = Tile::new(&image, Terrain::Grasslands);
|
|
||||||
let desert = Tile::new(&image, Terrain::Desert);
|
|
||||||
let mountain = Tile::new(&image, Terrain::Mountain);
|
|
||||||
let badlands = Tile::new(&image, Terrain::Badlands);
|
let badlands = Tile::new(&image, Terrain::Badlands);
|
||||||
|
let deep_water = Tile::new(&image, Terrain::DeepWater);
|
||||||
|
let desert = Tile::new(&image, Terrain::Desert);
|
||||||
|
let grasslands = Tile::new(&image, Terrain::Grasslands);
|
||||||
|
let mountain = Tile::new(&image, Terrain::Mountain);
|
||||||
|
let shallow_water = Tile::new(&image, Terrain::ShallowWater);
|
||||||
let swamp = Tile::new(&image, Terrain::Swamp);
|
let swamp = Tile::new(&image, Terrain::Swamp);
|
||||||
|
|
||||||
|
let badlands_image = gtk::Image::from_pixbuf(Some(&badlands.image));
|
||||||
|
self.palette.append(&badlands_image);
|
||||||
|
self.palette
|
||||||
|
.append(>k::Image::from_pixbuf(Some(&deep_water.image)));
|
||||||
|
self.palette
|
||||||
|
.append(>k::Image::from_pixbuf(Some(&desert.image)));
|
||||||
|
self.palette
|
||||||
|
.append(>k::Image::from_pixbuf(Some(&grasslands.image)));
|
||||||
|
self.palette
|
||||||
|
.append(>k::Image::from_pixbuf(Some(&mountain.image)));
|
||||||
|
self.palette
|
||||||
|
.append(>k::Image::from_pixbuf(Some(&shallow_water.image)));
|
||||||
|
self.palette
|
||||||
|
.append(>k::Image::from_pixbuf(Some(&swamp.image)));
|
||||||
|
|
||||||
let motion_controller = gtk::EventControllerMotion::new();
|
let motion_controller = gtk::EventControllerMotion::new();
|
||||||
{
|
{
|
||||||
let canvas_address = self.canvas_address.clone();
|
let canvas_address = self.canvas_address.clone();
|
||||||
|
|
Loading…
Reference in New Issue