// NOTE(matt): calloc, malloc, free
#include "hmmlib.h"
+//#include "config.h" // TODO(matt): Implement config.h
#define Kilobytes(Bytes) Bytes << 10
#define Megabytes(Bytes) Bytes << 20
@@ -60,6 +61,16 @@ typedef struct
char WrittenText[32];
} category_info;
+// TODO(matt): Parse this stuff out of a config file
+char *Credentials[ ][5] =
+{
+ { "Miblo", "Matt Mascarenhas", "http://miblodelcarpio.co.uk", "patreon_logo.png", "http://patreon.com/miblo"},
+ { "miotatsu", "Mio Iwakura", "http://riscy.tv/", "patreon_logo.png", "http://patreon.com/miotatsu"},
+ { "nothings", "Sean Barrett", "https://nothings.org/", "", ""},
+ { "cmuratori", "Casey Muratori", "https://handmadehero.org", "patreon_logo.png", "http://patreon.com/cmuratori"},
+ { "fierydrake", "Mike Tunnicliffe", "", "", ""},
+};
+
#define ArrayCount(A) sizeof(A)/sizeof(*(A))
void
@@ -283,6 +294,118 @@ SanitisePunctuation(char *String)
return String;
}
+int
+BuildCredits(buffer *CreditsMenu, buffer *HostInfo, buffer *AnnotatorInfo, bool *HasCreditsMenu, char *Host, char *Annotator)
+{
+ bool FoundHost = FALSE;
+ bool FoundAnnotator = FALSE;
+
+ for(int CredentialIndex = 0; CredentialIndex < ArrayCount(Credentials); ++CredentialIndex)
+ {
+ if(!StringsDiffer(Host, Credentials[CredentialIndex][0]))
+ {
+ FoundHost = TRUE; // TODO(matt): Check if this is actually necessary...
+ CopyStringToBuffer(HostInfo,
+" \n");
+ if(*Credentials[CredentialIndex][2])
+ {
+ CopyStringToBuffer(HostInfo,
+" \n"
+" Host
\n"
+" %s
\n"
+" \n",
+Credentials[CredentialIndex][2],
+Credentials[CredentialIndex][1]);
+ }
+ else
+ {
+ CopyStringToBuffer(HostInfo,
+" \n"
+"
Host
\n"
+"
%s
\n"
+"
\n",
+Credentials[CredentialIndex][1]);
+ }
+
+ if(*Credentials[CredentialIndex][4] && *Credentials[CredentialIndex][3])
+ {
+ CopyStringToBuffer(HostInfo,
+" \n",
+Credentials[CredentialIndex][4],
+Credentials[CredentialIndex][3]);
+ }
+
+ CopyStringToBuffer(HostInfo,
+" \n");
+ }
+
+ if(!StringsDiffer(Annotator, Credentials[CredentialIndex][0]))
+ {
+ FoundAnnotator = TRUE; // TODO(matt): Check if this is actually necessary...
+ CopyStringToBuffer(AnnotatorInfo,
+" \n");
+ if(*Credentials[CredentialIndex][2])
+ {
+ CopyStringToBuffer(AnnotatorInfo,
+" \n"
+" Annotator
\n"
+" %s
\n"
+" \n",
+Credentials[CredentialIndex][2],
+Credentials[CredentialIndex][1]);
+ }
+ else
+ {
+ CopyStringToBuffer(AnnotatorInfo,
+" \n"
+"
Annotator
\n"
+"
%s
\n"
+"
\n",
+Credentials[CredentialIndex][1]);
+ }
+
+ if(*Credentials[CredentialIndex][4] && *Credentials[CredentialIndex][3])
+ {
+ CopyStringToBuffer(AnnotatorInfo,
+" \n",
+Credentials[CredentialIndex][4],
+Credentials[CredentialIndex][3]);
+ }
+
+ CopyStringToBuffer(AnnotatorInfo,
+" \n");
+ }
+ }
+
+ if(FoundHost || FoundAnnotator)
+ {
+ CopyStringToBuffer(CreditsMenu,
+" \n");
+ }
+ else
+ {
+ return 1;
+ }
+
+ *HasCreditsMenu = TRUE;
+ return 0;
+}
+
int
BuildReference(ref_info *ReferencesArray, int RefIdentifier, int UniqueRefs, HMML_Reference Ref, HMML_Annotation Anno)
{
@@ -375,7 +498,6 @@ char *CategoryMedium[][3] =
void
BuildFilter(category_info *TopicsArray, int *UniqueTopics, category_info *MediaArray, int *UniqueMedia, char *Marker)
{
- int Offset;
bool IsMedium = FALSE;
int i = 0;
@@ -388,6 +510,7 @@ BuildFilter(category_info *TopicsArray, int *UniqueTopics, category_info *MediaA
}
}
+ int Offset;
if(IsMedium)
{
int j = 0;
@@ -443,14 +566,13 @@ BuildFilter(category_info *TopicsArray, int *UniqueTopics, category_info *MediaA
}
}
- // This really ought to sort by the Alternative Text
-
if(i == *UniqueTopics)
{
CopyString(TopicsArray[i].Marker, Marker);
}
++*UniqueTopics;
+ return;
}
}
@@ -605,7 +727,7 @@ GenerateTopicColours(buffer *Colour, char *Topic)
int TopicsLength = ftell(TopicsFile);
fseek(TopicsFile, 0, SEEK_SET);
- // TODO(matt): May this not just ClaimBuffer?
+ // TODO(matt): May this not just ClaimBuffer (if I can figure out how)?
if(!(TopicsBuffer = malloc(TopicsLength)))
{
perror("GenerateTopicColours");
@@ -963,6 +1085,9 @@ main(int ArgC, char **Args)
buffer FilterMenu;
buffer FilterTopics;
buffer FilterMedia;
+ buffer CreditsMenu;
+ buffer HostInfo;
+ buffer AnnotatorInfo;
buffer Player;
buffer Colour;
@@ -1002,6 +1127,7 @@ main(int ArgC, char **Args)
// FilterMenu
// FilterTopics
// FilterMedia
+ // CreditsMenu
// Player
// Colour
// Annotation
@@ -1015,6 +1141,9 @@ main(int ArgC, char **Args)
ClaimBuffer(MemoryArena, &ClaimedMemory, &FilterMenu, "FilterMenu", Kilobytes(16));
ClaimBuffer(MemoryArena, &ClaimedMemory, &FilterTopics, "FilterTopics", Kilobytes(8));
ClaimBuffer(MemoryArena, &ClaimedMemory, &FilterMedia, "FilterMedia", Kilobytes(8));
+ ClaimBuffer(MemoryArena, &ClaimedMemory, &CreditsMenu, "CreditsMenu", Kilobytes(8));
+ ClaimBuffer(MemoryArena, &ClaimedMemory, &HostInfo, "HostInfo", Kilobytes(1));
+ ClaimBuffer(MemoryArena, &ClaimedMemory, &AnnotatorInfo, "AnnotatorInfo", Kilobytes(1));
ClaimBuffer(MemoryArena, &ClaimedMemory, &Player, "Player", Kilobytes(256));
ClaimBuffer(MemoryArena, &ClaimedMemory, &Colour, "Colour", 32);
@@ -1029,6 +1158,7 @@ main(int ArgC, char **Args)
bool HasQuoteMenu = FALSE;
bool HasReferenceMenu = FALSE;
bool HasFilterMenu = FALSE;
+ bool HasCreditsMenu = FALSE;
int QuoteIdentifier = 0x3b1;
int RefIdentifier = 1;
@@ -1045,6 +1175,8 @@ main(int ArgC, char **Args)
" \n"
" \n", HMML.metadata.id, HMML.metadata.project);
+ BuildCredits(&CreditsMenu, &HostInfo, &AnnotatorInfo, &HasCreditsMenu, HMML.metadata.member, HMML.metadata.annotator);
+
#if DEBUG
printf(" --- Entering Annotations Loop ---\n");
#endif
@@ -1580,14 +1712,17 @@ CategoryMedium[j][2]
CopyBuffer(&Title, &FilterMenu);
+ if(HasCreditsMenu)
+ {
+ CopyBuffer(&Title, &CreditsMenu);
+ }
+
#if CONFIG
// TODO(matt): Here is where I test ParseConfig
ParseConfig(&Config, HMML.metadata.annotator);
#endif
CopyStringToBuffer(&Title,
-" Annotator: %s\n"
-"
\n",
-HMML.metadata.annotator);
+" \n");
CopyStringToBuffer(&Player,
" \n"
@@ -1602,7 +1737,7 @@ HMML.metadata.annotator);
"\n"
" \n"
" \n"
-" %s\n" // TODO(matt): Add the name of the project
+" %s\n" // TODO(matt): Add the full name of the project, parsed from a config
"\n"
" \n"
" \n"
@@ -1667,6 +1802,9 @@ HMML.metadata.project);
// Annotation
// Colour
// Player
+ // AnnotatorInfo
+ // HostInfo
+ // CreditsMenu
// FilterMedia
// FilterTopics
// FilterMenu
@@ -1679,6 +1817,9 @@ HMML.metadata.project);
DeclaimBuffer(&Colour, &ClaimedMemory);
DeclaimBuffer(&Player, &ClaimedMemory);
+ DeclaimBuffer(&AnnotatorInfo, &ClaimedMemory);
+ DeclaimBuffer(&HostInfo, &ClaimedMemory);
+ DeclaimBuffer(&CreditsMenu, &ClaimedMemory);
DeclaimBuffer(&FilterMedia, &ClaimedMemory);
DeclaimBuffer(&FilterTopics, &ClaimedMemory);
DeclaimBuffer(&FilterMenu, &ClaimedMemory);
@@ -1919,87 +2060,6 @@ HMML.metadata.project);
" \n"
"\n");
-#if 0
- CopyStringToBuffer(&Master,
-" \n"
-"