From b8c9da13a6de0cbdbf23dd3b36b5c4df23321747 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Wed, 12 Oct 2022 09:49:02 +0200 Subject: [PATCH] fixed a bug that caused the program to crash when trying to render the last page of a notebook with an even amount of pages --- Notebook.pde | 1 - Slide.pde | 8 +++----- data/save.sav | 2 +- notizheftanzeiger.pde | 9 ++++++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Notebook.pde b/Notebook.pde index 2ddba27..0fe70a9 100644 --- a/Notebook.pde +++ b/Notebook.pde @@ -46,7 +46,6 @@ String getMonth(int id) { } -ArrayList notebooks = new ArrayList(); void createNotebooks() { File datafolder = new File(dataPath("") + "/Notizhefte"); diff --git a/Slide.pde b/Slide.pde index 0e1b7f0..92b4f83 100644 --- a/Slide.pde +++ b/Slide.pde @@ -9,12 +9,9 @@ PImage Slide(int notebookID, int pageNumber) { result.image(leftPage, 0, 0, result.width/2, result.height); result.image(rightPage, result.width/2, 0, result.width/2, result.height); result.endDraw(); - PImage res = createImage(width, height, ARGB); - res = result.get(); - return res; + return result.get(); } -boolean transition; void nextSlide() { transition = true; @@ -25,10 +22,11 @@ void nextSlide() { if (currentSlideNo > notebooks.get(currentNotebookNo).imagepaths.length-1) { currentSlideNo = 0; currentNotebookNo++; + if(currentNotebookNo == notebooks.size()) currentNotebookNo = 0; } } else if (mode == RANDOM) { currentNotebookNo = (int)random(notebooks.size()); - currentSlideNo = (int)random(notebooks.get(currentNotebookNo).imagepaths.length); + currentSlideNo = (int)random(notebooks.get(currentNotebookNo).imagepaths.length-1); if (currentSlideNo %2 != 0) { currentSlideNo -= 1; } diff --git a/data/save.sav b/data/save.sav index f8f9fdf..95eddcf 100644 --- a/data/save.sav +++ b/data/save.sav @@ -1,2 +1,2 @@ +168 0 -8 diff --git a/notizheftanzeiger.pde b/notizheftanzeiger.pde index 9360ac0..2f216d3 100644 --- a/notizheftanzeiger.pde +++ b/notizheftanzeiger.pde @@ -2,17 +2,20 @@ import java.util.*; //////// Config -int mode = NORMAL; //NORMAL or RANDOM order -float timerTime = 5000; //in milliseconds how long slide is shown -float transitionTime = 3000; //how long it takes to fade the next slide in. must not be greater than "timerTime" +int mode = RANDOM; //NORMAL or RANDOM order +float timerTime = 250; //in milliseconds how long slide is shown +float transitionTime = 100; //how long it takes to fade the next slide in. must not be greater than "timerTime" boolean displayText = true; //if the "date" should be written on screen boolean displayTimeline = true; //if the timeline should be drawn on screen + // Timer timer; +ArrayList notebooks = new ArrayList(); PImage currentSlide, nextSlide; int currentNotebookNo, currentSlideNo; int startTransitionTime; +boolean transition; float transitionProgress; final static int NORMAL = 0; final static int RANDOM = 1;