collapse chapters that are completely solved by default
This commit is contained in:
parent
563c819900
commit
454c836b38
2 changed files with 19 additions and 7 deletions
|
@ -44,6 +44,7 @@ logic mostly like https://git.crispypin.cc/CrispyPin/marble
|
||||||
- show histograms
|
- show histograms
|
||||||
- author name in solutions and blueprints
|
- author name in solutions and blueprints
|
||||||
### undecided
|
### undecided
|
||||||
|
- option to skip (speed through with settable multiplier) first N stages, for when you are debugging something that happens in later stages
|
||||||
- hide some tile tools in early levels to make it less overwhelming
|
- hide some tile tools in early levels to make it less overwhelming
|
||||||
- footprint score (tiles that were non-empty at any point in the run)
|
- footprint score (tiles that were non-empty at any point in the run)
|
||||||
- option to use 8-bit marbles?
|
- option to use 8-bit marbles?
|
||||||
|
|
25
src/main.rs
25
src/main.rs
|
@ -46,11 +46,8 @@ fn main() {
|
||||||
|
|
||||||
impl Game {
|
impl Game {
|
||||||
fn new(rl: &mut RaylibHandle, thread: &RaylibThread) -> Self {
|
fn new(rl: &mut RaylibHandle, thread: &RaylibThread) -> Self {
|
||||||
let mut chapters = get_chapters();
|
|
||||||
let solutions = get_solutions();
|
let solutions = get_solutions();
|
||||||
if let Some(orphans) = find_orphans(&chapters, &solutions) {
|
let chapters = get_chapters(&solutions);
|
||||||
chapters.push(orphans);
|
|
||||||
}
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
chapters,
|
chapters,
|
||||||
|
@ -358,11 +355,23 @@ impl Game {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_chapters() -> Vec<Chapter> {
|
fn get_chapters(solutions: &HashMap<String, Vec<Solution>>) -> Vec<Chapter> {
|
||||||
let mut chapters = Vec::<Chapter>::new();
|
let mut chapters = Vec::<Chapter>::new();
|
||||||
for d in read_dir("levels").unwrap().flatten() {
|
for d in read_dir("levels").unwrap().flatten() {
|
||||||
if let Ok(text) = read_to_string(d.path()) {
|
if let Ok(text) = read_to_string(d.path()) {
|
||||||
if let Ok(chapter) = serde_json::from_str(&text) {
|
if let Ok(mut chapter) = serde_json::from_str::<Chapter>(&text) {
|
||||||
|
chapter.visible = false;
|
||||||
|
for level in &chapter.levels {
|
||||||
|
if solutions
|
||||||
|
.get(level.id())
|
||||||
|
.map(|s| s.iter().any(|s| s.score.is_some()))
|
||||||
|
!= Some(true)
|
||||||
|
{
|
||||||
|
// only expand chapters where at least one level has no complete solutions
|
||||||
|
chapter.visible = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
chapters.push(chapter);
|
chapters.push(chapter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -386,7 +395,9 @@ fn get_chapters() -> Vec<Chapter> {
|
||||||
levels: custom_levels,
|
levels: custom_levels,
|
||||||
visible: true,
|
visible: true,
|
||||||
});
|
});
|
||||||
|
if let Some(orphans) = find_orphans(&chapters, solutions) {
|
||||||
|
chapters.push(orphans);
|
||||||
|
}
|
||||||
chapters
|
chapters
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue