mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-06 14:23:12 +00:00
REXM: Reviewed UpdateSourceMetadata()
This commit is contained in:
parent
8544020023
commit
4020885c35
@ -2305,7 +2305,7 @@ static void UpdateSourceMetadata(const char *exSrcPath, const rlExampleInfo *inf
|
|||||||
|
|
||||||
char *exText = LoadFileText(exSourcePath);
|
char *exText = LoadFileText(exSourcePath);
|
||||||
char *exTextUpdated[6] = { 0 }; // Pointers to multiple updated text versions
|
char *exTextUpdated[6] = { 0 }; // Pointers to multiple updated text versions
|
||||||
char *exTextUpdatedPtr = NULL;
|
char *exTextUpdatedPtr = exText; // Pointer to current valid text version
|
||||||
|
|
||||||
char exNameFormated[256] = { 0 }; // Example name without category and using spaces
|
char exNameFormated[256] = { 0 }; // Example name without category and using spaces
|
||||||
int exNameIndex = TextFindIndex(info->name, "_");
|
int exNameIndex = TextFindIndex(info->name, "_");
|
||||||
@ -2315,8 +2315,9 @@ static void UpdateSourceMetadata(const char *exSrcPath, const rlExampleInfo *inf
|
|||||||
|
|
||||||
// Update example header title (line #3 - ALWAYS)
|
// Update example header title (line #3 - ALWAYS)
|
||||||
// String: "* raylib [shaders] example - texture drawing"
|
// String: "* raylib [shaders] example - texture drawing"
|
||||||
exTextUpdated[0] = TextReplaceBetween(exText,
|
exTextUpdated[0] = TextReplaceBetween(exTextUpdatedPtr,
|
||||||
TextFormat("%s] example - %s", info->category, exNameFormated), "* raylib [", "\n");
|
TextFormat("%s] example - %s", info->category, exNameFormated), "* raylib [", "\n");
|
||||||
|
if (exTextUpdated[0] != NULL) exTextUpdatedPtr = exTextUpdated[0];
|
||||||
|
|
||||||
// Update example complexity rating
|
// Update example complexity rating
|
||||||
// String: "* Example complexity rating: [★★☆☆] 2/4"
|
// String: "* Example complexity rating: [★★☆☆] 2/4"
|
||||||
@ -2328,45 +2329,45 @@ static void UpdateSourceMetadata(const char *exSrcPath, const rlExampleInfo *inf
|
|||||||
if (i < info->stars) strcpy(starsText + 3*i, "★");
|
if (i < info->stars) strcpy(starsText + 3*i, "★");
|
||||||
else strcpy(starsText + 3*i, "☆");
|
else strcpy(starsText + 3*i, "☆");
|
||||||
}
|
}
|
||||||
exTextUpdated[1] = TextReplaceBetween(exTextUpdated[0],
|
exTextUpdated[1] = TextReplaceBetween(exTextUpdatedPtr,
|
||||||
TextFormat("%s] %i", starsText, info->stars), "* Example complexity rating: [", "/4\n");
|
TextFormat("%s] %i", starsText, info->stars), "* Example complexity rating: [", "/4\n");
|
||||||
|
if (exTextUpdated[1] != NULL) exTextUpdatedPtr = exTextUpdated[1];
|
||||||
|
|
||||||
// Update example creation/update raylib versions
|
// Update example creation/update raylib versions
|
||||||
// String: "* Example originally created with raylib 2.0, last time updated with raylib 3.7
|
// String: "* Example originally created with raylib 2.0, last time updated with raylib 3.7
|
||||||
exTextUpdated[2] = TextReplaceBetween(exTextUpdated[1],
|
exTextUpdated[2] = TextReplaceBetween(exTextUpdatedPtr,
|
||||||
TextFormat("%s, last time updated with raylib %s", info->verCreated, info->verUpdated), "* Example originally created with raylib ", "\n");
|
TextFormat("%s, last time updated with raylib %s", info->verCreated, info->verUpdated), "* Example originally created with raylib ", "\n");
|
||||||
|
if (exTextUpdated[2] != NULL) exTextUpdatedPtr = exTextUpdated[2];
|
||||||
|
|
||||||
// Update copyright message
|
// Update copyright message
|
||||||
// String: "* Copyright (c) 2019-2025 Contributor Name (@github_user) and Ramon Santamaria (@raysan5)"
|
// String: "* Copyright (c) 2019-2025 Contributor Name (@github_user) and Ramon Santamaria (@raysan5)"
|
||||||
if (info->yearCreated == info->yearReviewed)
|
if (info->yearCreated == info->yearReviewed)
|
||||||
{
|
{
|
||||||
exTextUpdated[3] = TextReplaceBetween(exTextUpdated[2],
|
exTextUpdated[3] = TextReplaceBetween(exTextUpdatedPtr,
|
||||||
TextFormat("%i %s (@%s", info->yearCreated, info->author, info->authorGitHub), "Copyright (c) ", ")");
|
TextFormat("%i %s (@%s", info->yearCreated, info->author, info->authorGitHub), "Copyright (c) ", ")");
|
||||||
|
if (exTextUpdated[3] != NULL) exTextUpdatedPtr = exTextUpdated[3];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
exTextUpdated[3] = TextReplaceBetween(exTextUpdated[2],
|
exTextUpdated[3] = TextReplaceBetween(exTextUpdatedPtr,
|
||||||
TextFormat("%i-%i %s (@%s", info->yearCreated, info->yearReviewed, info->author, info->authorGitHub), "Copyright (c) ", ")");
|
TextFormat("%i-%i %s (@%s", info->yearCreated, info->yearReviewed, info->author, info->authorGitHub), "Copyright (c) ", ")");
|
||||||
|
if (exTextUpdated[3] != NULL) exTextUpdatedPtr = exTextUpdated[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update window title
|
// Update window title
|
||||||
// String: "InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture drawing");"
|
// String: "InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture drawing");"
|
||||||
exTextUpdated[4] = TextReplaceBetween(exTextUpdated[3],
|
exTextUpdated[4] = TextReplaceBetween(exTextUpdated[3],
|
||||||
TextFormat("raylib [%s] example - %s", info->category, exNameFormated), "InitWindow(screenWidth, screenHeight, \"", "\");");
|
TextFormat("raylib [%s] example - %s", info->category, exNameFormated), "InitWindow(screenWidth, screenHeight, \"", "\");");
|
||||||
|
if (exTextUpdated[4] != NULL) exTextUpdatedPtr = exTextUpdated[4];
|
||||||
|
|
||||||
// Update contributors names
|
// Update contributors names
|
||||||
// String: "* Example contributed by Contributor Name (@github_user) and reviewed by Ramon Santamaria (@raysan5)"
|
// String: "* Example contributed by Contributor Name (@github_user) and reviewed by Ramon Santamaria (@raysan5)"
|
||||||
// WARNING: Not all examples are contributed by someone, so the result of this replace can be NULL (string not found)
|
// WARNING: Not all examples are contributed by someone, so the result of this replace can be NULL (string not found)
|
||||||
if (exTextUpdated[4] != NULL)
|
exTextUpdated[5] = TextReplaceBetween(exTextUpdatedPtr,
|
||||||
{
|
|
||||||
exTextUpdated[5] = TextReplaceBetween(exTextUpdated[4],
|
|
||||||
TextFormat("%s (@%s", info->author, info->authorGitHub), "* Example contributed by ", ")");
|
TextFormat("%s (@%s", info->author, info->authorGitHub), "* Example contributed by ", ")");
|
||||||
}
|
|
||||||
else exTextUpdatedPtr = exTextUpdated[3];
|
|
||||||
|
|
||||||
if (exTextUpdated[5] != NULL) exTextUpdatedPtr = exTextUpdated[5];
|
if (exTextUpdated[5] != NULL) exTextUpdatedPtr = exTextUpdated[5];
|
||||||
|
|
||||||
SaveFileText(exSourcePath, exTextUpdatedPtr);
|
if (exTextUpdatedPtr != NULL) SaveFileText(exSourcePath, exTextUpdatedPtr);
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++) { MemFree(exTextUpdated[i]); exTextUpdated[i] = NULL; }
|
for (int i = 0; i < 6; i++) { MemFree(exTextUpdated[i]); exTextUpdated[i] = NULL; }
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user