Skip to content

Commit

Permalink
Display correct chapters
Browse files Browse the repository at this point in the history
  • Loading branch information
otidev committed Dec 2, 2023
1 parent 62bed51 commit 0179cec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ In the future, any file with the format:
```xml
<bible lang="<language in Books.json>">
<b> <!-- book -->
<c> <!-- chapter -->
<c n="<chapterNumber>"> <!-- chapter -->
<v n="<verseNumber>"> <!-- verse -->
</v>
</c>
Expand Down
6 changes: 3 additions & 3 deletions src/Books.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ cJSON* GetRoot(char* filename) {

SDL_Texture* RenderChapter(TTF_Font* font, BibleData* data, cJSON* books, ezxml_t xmlBible, int chapter) {
char bookChapterName[50];
snprintf(bookChapterName, 50, "%s %d", cJSON_GetArrayItem(cJSON_GetObjectItem(books, data->lang), data->usedBook)->valuestring, chapter);
ezxml_t xmlBook = ezxml_idx(ezxml_child(xmlBible, "b"), data->usedBook);
ezxml_t xmlChapter = ezxml_idx(ezxml_child(xmlBook, "c"), chapter - 1);
snprintf(bookChapterName, 50, "%s %d", cJSON_GetArrayItem(cJSON_GetObjectItem(books, data->lang), data->usedBook)->valuestring, atoi(ezxml_attr(xmlChapter, "n")));

float fontSize = (int)round(data->origFontSize * data->magnifier);
TTF_SetFontSize(font, fontSize * 2);
SDL_Surface* surf = TTF_RenderUTF8_Blended_Wrapped(font, bookChapterName, (SDL_Colour){0xff, 0xff, 0xff, 0xff}, (int)round(data->wrapWidth * data->wrapWidthMult));
SDL_Texture* header = SDL_CreateTextureFromSurface(globalWindow->renderer, surf);
SDL_FreeSurface(surf);

ezxml_t xmlBook = ezxml_idx(ezxml_child(xmlBible, "b"), data->usedBook);
ezxml_t xmlChapter = ezxml_idx(ezxml_child(xmlBook, "c"), chapter - 1);
if (!xmlChapter) {
fprintf(stderr, "Error: No chapter %d!", chapter);
}
Expand Down

0 comments on commit 0179cec

Please sign in to comment.