Skip to content

Commit

Permalink
Fix issue : randon option
Browse files Browse the repository at this point in the history
  • Loading branch information
DantSu committed Apr 5, 2024
1 parent e743381 commit 52f749d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###########################################################

TARGET=TelmiOS
VERSION=1.1.0
VERSION=1.1.1

###########################################################

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The story teller is compatible with stories exported from [STUdio](https://githu

### Download the installation files

- [Download the latest version of Telmi](https://github.com/DantSu/Telmi-story-teller/releases/download/1.0.4/TelmiOS_v1.0.4.zip)
- [Download the latest version of Telmi](https://github.com/DantSu/Telmi-story-teller/releases/download/1.1.1/TelmiOS_v1.1.1.zip)

### Format your SD card as FAT32 (not exFAT!)

Expand Down Expand Up @@ -46,9 +46,9 @@ Make sure you choose: `For use with all systems and devices (FAT)`

Chrome already has a tool to format an SD card. Insert the card into your Chromebook, right-click it and click **Format Device**, make sure `FAT32` is selected under **Format** and click or tap **Erase & Format**.

### Unzip TelmiOS_v1.0.4.zip
### Unzip TelmiOS_v1.1.1.zip

Put the content of `TelmiOS_v1.0.4.zip` at the root of the SD card.
Put the content of `TelmiOS_v1.1.1.zip` at the root of the SD card.

### Power on your Miyoo

Expand Down
28 changes: 19 additions & 9 deletions src/storyTeller/stories_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define STORYTELLER_STORIES_HELPER__

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include "system/display.h"
Expand Down Expand Up @@ -167,6 +168,21 @@ void stories_readAction(void)
stories_readStage();
}

void stories_loadAction(void)
{
cJSON *nodeAction = stories_getAction();
if(nodeAction == NULL) {
return callback_stories_reset();
}

storyActionOptionsCount = cJSON_GetArraySize(nodeAction);
if(storyActionOptionIndex < 0) {
storyActionOptionIndex = rand() % storyActionOptionsCount;
}

stories_readAction();
}

void stories_load(void)
{
if(storiesCount == 0) {
Expand All @@ -192,13 +208,7 @@ void stories_load(void)
storyTime = 0;
}

cJSON *nodeAction = stories_getAction();
if(nodeAction == NULL) {
return;
}

storyActionOptionsCount = cJSON_GetArraySize(nodeAction);
stories_readAction();
stories_loadAction();
}

void stories_title_single(void) {
Expand Down Expand Up @@ -300,8 +310,8 @@ void stories_transition(char* transition) {

json_getString(transitionNode, "action", storyActionKey);
json_getInt(transitionNode, "index", &storyActionOptionIndex);
storyActionOptionsCount = cJSON_GetArraySize(stories_getAction());
stories_readAction();

stories_loadAction();
}


Expand Down
1 change: 1 addition & 0 deletions src/storyTeller/storyTeller.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ bool keyinput_isValid(void)

int main(int argc, char *argv[])
{
srand(time(NULL));
video_audio_init();
settings_init();
display_init();
Expand Down

0 comments on commit 52f749d

Please sign in to comment.