cleanup
This commit is contained in:
parent
db7a2b2418
commit
9bee7c0e10
5 changed files with 11 additions and 13 deletions
14
src/main.rs
14
src/main.rs
|
@ -44,8 +44,8 @@ fn main() {
|
|||
impl Game {
|
||||
fn new(rl: &mut RaylibHandle, thread: &RaylibThread) -> Self {
|
||||
let mut textures = Textures::default();
|
||||
textures.load_dir("assets", rl, &thread);
|
||||
textures.load_dir("assets/tiles", rl, &thread);
|
||||
textures.load_dir("assets", rl, thread);
|
||||
textures.load_dir("assets/tiles", rl, thread);
|
||||
|
||||
Self {
|
||||
levels: get_levels(),
|
||||
|
@ -60,7 +60,7 @@ impl Game {
|
|||
|
||||
fn run(&mut self, rl: &mut RaylibHandle, thread: &RaylibThread) {
|
||||
while !rl.window_should_close() {
|
||||
let mut d = rl.begin_drawing(&thread);
|
||||
let mut d = rl.begin_drawing(thread);
|
||||
if let Some(editor) = &mut self.open_editor {
|
||||
editor.update(&d);
|
||||
editor.draw(&mut d, &self.textures);
|
||||
|
@ -181,7 +181,7 @@ impl Game {
|
|||
|
||||
if simple_button(d, level_list_width + 10, solution_y, entry_width, 30) {
|
||||
let n = solutions.len();
|
||||
solutions.push(Solution::new(&level, n));
|
||||
solutions.push(Solution::new(level, n));
|
||||
}
|
||||
d.draw_text(
|
||||
"new solution",
|
||||
|
@ -224,8 +224,7 @@ fn get_levels() -> Vec<Level> {
|
|||
let l = read_to_string(d.path())
|
||||
.ok()
|
||||
.as_deref()
|
||||
.map(|s| serde_json::from_str(s).ok())
|
||||
.flatten();
|
||||
.and_then(|s| serde_json::from_str(s).ok());
|
||||
if let Some(level) = l {
|
||||
levels.push(level);
|
||||
}
|
||||
|
@ -248,8 +247,7 @@ fn get_solutions() -> HashMap<String, Vec<Solution>> {
|
|||
let s = read_to_string(file.path())
|
||||
.ok()
|
||||
.as_deref()
|
||||
.map(|s| serde_json::from_str(s).ok())
|
||||
.flatten();
|
||||
.and_then(|s| serde_json::from_str(s).ok());
|
||||
if let Some(solution) = s {
|
||||
solutions.push(solution)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue