Skip to content

Commit

Permalink
Move to 2018 edition.
Browse files Browse the repository at this point in the history
  • Loading branch information
crlf0710 committed May 2, 2019
1 parent 6cdec45 commit 5d7a892
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 78 deletions.
16 changes: 9 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "charlesmine"
version = "0.1.0"
authors = ["CrLF0710 <crlf0710@gmail.com>"]
# edition = "2018"
edition = "2018"

[dependencies]
apiw = { git = "https://github.com/crlf0710/apiw-rs" }
Expand All @@ -17,4 +17,5 @@ env_logger = "0.6"


[target.'cfg(windows)'.build-dependencies]
embed-resource = { git = "https://github.com/nabijaczleweli/rust-embed-resource" }
# resw = { git = "https://github.com/crlf0710/resw-rs" }
embed-resource = "1"
6 changes: 3 additions & 3 deletions src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use apiw::graphics_subsystem::Size;
use apiw::windows_subsystem::window::MouseEventArgs;
use concerto::ActionContextBuilder;
use concerto::{self, ActionContext};
use view::{self, View, GameTarget};
use model::{self, Model, ModelCommand};
use model_config::{self, Config};
use crate::view::{self, View, GameTarget};
use crate::model::{self, Model, ModelCommand};
use crate::model_config::{self, Config};

pub struct Controller {
action_contexts: Vec<ActionContext<Controller>>,
Expand Down
19 changes: 3 additions & 16 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
#![windows_subsystem = "windows"]
#![allow(unused_imports, unreachable_code)]

#[macro_use]
extern crate apiw;
extern crate chrono;
extern crate clamp;
extern crate rand;
#[macro_use]
extern crate smallvec;
extern crate concerto;
extern crate domino;
#[macro_use]
extern crate log;
extern crate env_logger;
#![allow(unused_imports, unreachable_code, unused_variables, dead_code)]

use std::cell::RefCell;
use ui::Ui;
use crate::ui::Ui;

mod model;
mod model_config;
Expand Down Expand Up @@ -49,7 +36,7 @@ thread_local! {
}

fn main() -> apiw::Result<()> {
use view::View;
use crate::view::View;

env_logger::init();

Expand Down
10 changes: 5 additions & 5 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ use chrono::{DateTime, Local};
use rand::{self, distributions::Uniform, Rng};

use std::ops;
use view::{self, ViewCommand};
use controller;
use model_config::{self, Config};
use model_gamemode::{self, BoardSaved, GameMode};
use crate::view::{self, ViewCommand};
use crate::controller;
use crate::model_config::{self, Config};
use crate::model_gamemode::{self, BoardSaved, GameMode};
use std::cell::Cell;
use std::rc::Rc;
use std::collections::BTreeSet;
use std::path::PathBuf;
use view::AlertFailure;
use crate::view::AlertFailure;

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum BlockStatus {
Expand Down
6 changes: 4 additions & 2 deletions src/model_gamemode.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#![allow(unused_imports, unreachable_code, unused_variables, dead_code)]

use chrono::{DateTime, Local};
use std::fs::File;
use std::path::Path;
use std::rc::Rc;
use std::cell::RefCell;
use model::ModelCommand;
use model::Board;
use crate::model::ModelCommand;
use crate::model::Board;

#[derive(Clone, Debug)]
pub struct BoardSaved {
Expand Down
27 changes: 15 additions & 12 deletions src/ui_apiw.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
#![allow(unused_imports, unreachable_code, unused_variables, dead_code)]

use apiw;
use apiw::shared::ManagedStrategy;
use apiw::Result;

use Game;
use THE_GAME;
use crate::Game;
use crate::THE_GAME;

use view;
use view_assets::{self};
use model;
use controller::{self, ControllerInput};
use view::ViewCommand;
use crate::view;
use crate::view_assets::{self};
use crate::model;
use crate::controller::{self, ControllerInput};
use crate::view::ViewCommand;
use domino::mvc::ViewToken;
use apiw::window_proc;
use apiw::timer_proc;
use apiw::application_support_functions::MessageBoxBuilder;


pub type UiWindow = apiw::windows_subsystem::window::ForeignWindow;
pub type UiScopedDC<'a> = apiw::graphics_subsystem::device_context::ScopedDeviceContext<'a>;
pub type UiLocalDC = apiw::graphics_subsystem::device_context::LocalDeviceContext;
Expand All @@ -25,7 +28,7 @@ pub type Rect = apiw::graphics_subsystem::Rect;
pub type RGBColor = apiw::graphics_subsystem::RGBColor;

pub use apiw::graphics_subsystem::draw::Draw as UiDraw;
use model_config;
use crate::model_config;
use std::path::PathBuf;
use apiw::application_support_functions::OpenFileDialogBuilder;
use apiw::application_support_functions::OpenFileDialogFlags;
Expand Down Expand Up @@ -177,7 +180,7 @@ BOOL HandleMapFile(bool bSave, UINT nFilterResID, LPCTSTR lpszDefExt, LPTSTR lps
}

use concerto::ActionInput;
use controller::KeyKind;
use crate::controller::KeyKind;

if let Some(target) = target.as_ref() {
game.mvc.process_input(ControllerInput::ActionInput(
Expand Down Expand Up @@ -208,8 +211,8 @@ BOOL HandleMapFile(bool bSave, UINT nFilterResID, LPCTSTR lpszDefExt, LPTSTR lps
},
)
.route_command(|window: &ForeignWindow, args: CommandEventArgs| -> apiw::Result<()> {
use view_assets::resources;
use model::ModelCommand;
use crate::view_assets::resources;
use crate::model::ModelCommand;
match args.id() as isize {
resources::IDM_FILE_NEW => {
THE_GAME.with(|game| {
Expand Down
50 changes: 25 additions & 25 deletions src/view.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
use model::BlockShape;
use model::GameButtonDisplayKind;
use crate::model::BlockShape;
use crate::model::GameButtonDisplayKind;
use std::cell::Cell;
use std::num::NonZeroUsize;
use model_config::{self, Config};
use view_assets::{self};
use view_assets::BlockSpriteSheet;
use view_assets::GameButtonSpriteSheet;
use view_assets::{Assets, DigitSpriteSheet};
use model::Block;
use model::BlockDisplayKind;
use model::Board;
use model::Model;
use model_config::BoardSettingKind;
use model;
use controller;
use ui::{self, Size, Point, Rect, RGBColor};
use ui::UiResult;
use ui::UiScopedDC;
use ui::UiWindow;
use ui::UiLocalDC;
use ui::UiDraw;
use model_gamemode;
use ui::ui_alert;
use crate::model_config::{self, Config};
use crate::view_assets::{self};
use crate::view_assets::BlockSpriteSheet;
use crate::view_assets::GameButtonSpriteSheet;
use crate::view_assets::{Assets, DigitSpriteSheet};
use crate::model::Block;
use crate::model::BlockDisplayKind;
use crate::model::Board;
use crate::model::Model;
use crate::model_config::BoardSettingKind;
use crate::model;
use crate::controller;
use crate::ui::{self, Size, Point, Rect, RGBColor};
use crate::ui::UiResult;
use crate::ui::UiScopedDC;
use crate::ui::UiWindow;
use crate::ui::UiLocalDC;
use crate::ui::UiDraw;
use crate::model_gamemode;
use crate::ui::ui_alert;

#[derive(Debug)]
pub enum AlertFailure {
Expand Down Expand Up @@ -157,7 +157,7 @@ impl UiDraw for ThreeDimBorder {

impl<'a> UiDraw for GameButton<'a> {
fn draw(self, dc: &mut UiScopedDC) -> UiResult<()> {
use view_assets::SpriteSheet;
use crate::view_assets::SpriteSheet;

let mut game_button_sheet = self.assets.gamebutton_sheet.instantiate(dc)?;
let sprite_idx = GameButtonSpriteSheet::sprite_index(self.state);
Expand All @@ -170,7 +170,7 @@ impl<'a> UiDraw for GameButton<'a> {

impl<'a> UiDraw for MineBlock<'a> {
fn draw(self, dc: &mut UiScopedDC) -> UiResult<()> {
use view_assets::SpriteSheet;
use crate::view_assets::SpriteSheet;

let mut block_sheet = self.assets.block_sheet.instantiate(dc)?;
let sprite_idx =
Expand All @@ -184,7 +184,7 @@ impl<'a> UiDraw for MineBlock<'a> {

impl<'a> UiDraw for DigitPanel<'a> {
fn draw(self, dc: &mut UiScopedDC) -> UiResult<()> {
use view_assets::SpriteSheet;
use crate::view_assets::SpriteSheet;

let value_abs = self.value.abs() as usize;
let neg = self.value.is_negative();
Expand Down
12 changes: 6 additions & 6 deletions src/view_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use apiw::graphics_subsystem::RGBColor;
use apiw::graphics_subsystem::TenaryROP;
use apiw::graphics_subsystem::{Point, Size};
use apiw::shared::ManagedStrategy;
use model::Block;
use model::BlockShape;
use smallvec::SmallVec;
use crate::model::Block;
use crate::model::BlockShape;
use smallvec::{smallvec, SmallVec};
use std::borrow::BorrowMut;
use std::cell::RefCell;
use std::marker::PhantomData;
Expand Down Expand Up @@ -89,9 +89,9 @@ pub(crate) mod resources {
}

use self::resources::*;
use model::BlockDisplayKind;
use model::Board;
use model::GameButtonDisplayKind;
use crate::model::BlockDisplayKind;
use crate::model::Board;
use crate::model::GameButtonDisplayKind;

pub struct SpriteSheetInstance<
'a,
Expand Down

0 comments on commit 5d7a892

Please sign in to comment.