mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-07 22:59:17 -05:00
Compare commits
2 Commits
b11d089202
...
d43470a3d4
| Author | SHA1 | Date | |
|---|---|---|---|
| d43470a3d4 | |||
| d182ae7837 |
@ -251,6 +251,7 @@ int main(int argc, char *argv[])
|
|||||||
if (TextFindIndex(exColInfo, argv[2]) != -1) // Example in the collection
|
if (TextFindIndex(exColInfo, argv[2]) != -1) // Example in the collection
|
||||||
{
|
{
|
||||||
strcpy(exName, argv[2]); // Register filename for removal
|
strcpy(exName, argv[2]); // Register filename for removal
|
||||||
|
strncpy(exCategory, exName, TextFindIndex(exName, "_"));
|
||||||
opCode = OP_REMOVE;
|
opCode = OP_REMOVE;
|
||||||
}
|
}
|
||||||
else LOG("WARNING: REMOVE: Example not available in the collection\n");
|
else LOG("WARNING: REMOVE: Example not available in the collection\n");
|
||||||
@ -296,7 +297,7 @@ int main(int argc, char *argv[])
|
|||||||
FileCopy(exTemplateScreenshot, TextFormat("%s/%s/%s.png", exBasePath, exCategory, exName)); // WARNING: To be updated manually!
|
FileCopy(exTemplateScreenshot, TextFormat("%s/%s/%s.png", exBasePath, exCategory, exName)); // WARNING: To be updated manually!
|
||||||
|
|
||||||
// Copy: raylib/examples/<category>/resources/... // WARNING: To be updated manually!
|
// Copy: raylib/examples/<category>/resources/... // WARNING: To be updated manually!
|
||||||
// TODO: Example to be added could be provided as a .zip, containing resources!
|
// IDEA: Example to be added could be provided as a .zip, containing resources!
|
||||||
|
|
||||||
// TODO: Copy provided resources to respective directories
|
// TODO: Copy provided resources to respective directories
|
||||||
// Possible strategy:
|
// Possible strategy:
|
||||||
@ -307,7 +308,7 @@ int main(int argc, char *argv[])
|
|||||||
// 2. Verify paths: resource files exist
|
// 2. Verify paths: resource files exist
|
||||||
// 3. Copy files to required resource dir
|
// 3. Copy files to required resource dir
|
||||||
|
|
||||||
// Add example to the main collection list, if not already there
|
// Add example to the collection list, if not already there
|
||||||
// NOTE: Required format: shapes;shapes_basic_shapes;⭐️☆☆☆;1.0;4.2;"Ray";@raysan5
|
// NOTE: Required format: shapes;shapes_basic_shapes;⭐️☆☆☆;1.0;4.2;"Ray";@raysan5
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
char *exColInfo = LoadFileText(exCollectionListPath);
|
char *exColInfo = LoadFileText(exCollectionListPath);
|
||||||
@ -328,18 +329,19 @@ int main(int argc, char *argv[])
|
|||||||
else if (strcmp(exCategory, "audio") == 0) nextCatIndex = 7;
|
else if (strcmp(exCategory, "audio") == 0) nextCatIndex = 7;
|
||||||
else if (strcmp(exCategory, "others") == 0) nextCatIndex = -1; // Add to EOF
|
else if (strcmp(exCategory, "others") == 0) nextCatIndex = -1; // Add to EOF
|
||||||
|
|
||||||
|
// TODO: Get required example info from example file header (if provided)
|
||||||
|
// NOTE: If no example info is provided (other than category/name), just using some default values
|
||||||
|
|
||||||
if (nextCatIndex == -1)
|
if (nextCatIndex == -1)
|
||||||
{
|
{
|
||||||
// Add example to the end of the list
|
// Add example to collection at the EOF
|
||||||
int endIndex = (int)strlen(exColInfo);
|
int endIndex = (int)strlen(exColInfo);
|
||||||
memcpy(exColInfoUpdated, exColInfo, endIndex);
|
memcpy(exColInfoUpdated, exColInfo, endIndex);
|
||||||
sprintf(exColInfoUpdated + endIndex, TextFormat("\n%s/%s\n", exCategory, exName));
|
sprintf(exColInfoUpdated + endIndex, TextFormat("%s;%s;⭐️☆☆☆;6.0;6.0;\"Ray\";@raysan5\n", exCategory, exName));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Add example to the end of the category list
|
// Add example to collection, at the end of the category list
|
||||||
// TODO: Get required example info from example file header (if provided)
|
|
||||||
// NOTE: If no example info is provided (other than category/name), just using some default values
|
|
||||||
int catIndex = TextFindIndex(exColInfo, exCategories[nextCatIndex]);
|
int catIndex = TextFindIndex(exColInfo, exCategories[nextCatIndex]);
|
||||||
memcpy(exColInfoUpdated, exColInfo, catIndex);
|
memcpy(exColInfoUpdated, exColInfo, catIndex);
|
||||||
int textWritenSize = sprintf(exColInfoUpdated + catIndex, TextFormat("%s;%s;⭐️☆☆☆;6.0;6.0;\"Ray\";@raysan5\n", exCategory, exName));
|
int textWritenSize = sprintf(exColInfoUpdated + catIndex, TextFormat("%s;%s;⭐️☆☆☆;6.0;6.0;\"Ray\";@raysan5\n", exCategory, exName));
|
||||||
@ -350,7 +352,6 @@ int main(int argc, char *argv[])
|
|||||||
RL_FREE(exColInfoUpdated);
|
RL_FREE(exColInfoUpdated);
|
||||||
}
|
}
|
||||||
else LOG("WARNING: ADD: Example is already on the collection\n");
|
else LOG("WARNING: ADD: Example is already on the collection\n");
|
||||||
|
|
||||||
UnloadFileText(exColInfo);
|
UnloadFileText(exColInfo);
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -379,7 +380,7 @@ int main(int argc, char *argv[])
|
|||||||
// Compile to: raylib.com/examples/<category>/<category>_example_name.wasm
|
// Compile to: raylib.com/examples/<category>/<category>_example_name.wasm
|
||||||
// Compile to: raylib.com/examples/<category>/<category>_example_name.js
|
// Compile to: raylib.com/examples/<category>/<category>_example_name.js
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
// TODO: WARNING: This .BAT is not portable and it does not consider RESOURCES for Web properly,
|
// TODO: Avoid platform-specific .BAT, not portable and it does not consider RESOURCES for Web properly,
|
||||||
// Makefile.Web should be used... but it requires proper editing first!
|
// Makefile.Web should be used... but it requires proper editing first!
|
||||||
system(TextFormat("%s/build_example_web.bat %s/%s", exBasePath, exCategory, exName));
|
system(TextFormat("%s/build_example_web.bat %s/%s", exBasePath, exCategory, exName));
|
||||||
|
|
||||||
@ -465,7 +466,26 @@ int main(int argc, char *argv[])
|
|||||||
} break;
|
} break;
|
||||||
case 4: // Remove
|
case 4: // Remove
|
||||||
{
|
{
|
||||||
// TODO: Remove and update all required files...
|
// Remove example from collection for files update
|
||||||
|
//------------------------------------------------------------------------------------------------
|
||||||
|
char *exColInfo = LoadFileText(exCollectionListPath);
|
||||||
|
int exIndex = TextFindIndex(exColInfo, TextFormat("%s;%s", exCategory, exName));
|
||||||
|
if (exIndex > 0) // Example found
|
||||||
|
{
|
||||||
|
char *exColInfoUpdated = (char *)RL_CALLOC(2*1024*1024, 1); // Updated list copy, 2MB
|
||||||
|
|
||||||
|
memcpy(exColInfoUpdated, exColInfo, exIndex);
|
||||||
|
int lineLen = 0;
|
||||||
|
for (int i = exIndex; (exColInfo[i] != '\n') && (exColInfo[i] != '\0'); i++) lineLen++;
|
||||||
|
// Remove line and copy the rest next
|
||||||
|
memcpy(exColInfoUpdated + exIndex, exColInfo + exIndex + lineLen + 1, strlen(exColInfo) - exIndex - lineLen);
|
||||||
|
|
||||||
|
SaveFileText(exCollectionListPath, exColInfoUpdated);
|
||||||
|
RL_FREE(exColInfoUpdated);
|
||||||
|
}
|
||||||
|
else LOG("WARNING: REMOVE: Example not found in the collection\n");
|
||||||
|
UnloadFileText(exColInfo);
|
||||||
|
//------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Remove: raylib/examples/<category>/<category>_example_name.c
|
// Remove: raylib/examples/<category>/<category>_example_name.c
|
||||||
// Remove: raylib/examples/<category>/<category>_example_name.png
|
// Remove: raylib/examples/<category>/<category>_example_name.png
|
||||||
@ -473,38 +493,17 @@ int main(int argc, char *argv[])
|
|||||||
remove(TextFormat("%s/%s/%s.png", exBasePath, exCategory, exName));
|
remove(TextFormat("%s/%s/%s.png", exBasePath, exCategory, exName));
|
||||||
|
|
||||||
// TODO: Remove: raylib/examples/<category>/resources/..
|
// TODO: Remove: raylib/examples/<category>/resources/..
|
||||||
|
// Get list of resources from Makefile.Web or examples ResourcesScan()
|
||||||
|
|
||||||
// Edit: raylib/examples/Makefile
|
UpdateRequiredFiles();
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Edit: raylib/examples/Makefile.Web
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Edit: raylib/examples/README.md
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Remove: raylib/projects/VS2022/examples/<category>_example_name.vcxproj
|
// Remove: raylib/projects/VS2022/examples/<category>_example_name.vcxproj
|
||||||
remove(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName));
|
remove(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName));
|
||||||
|
|
||||||
// Edit: raylib/projects/VS2022/raylib.sln
|
// Edit: raylib/projects/VS2022/raylib.sln --> Remove example project
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
system(TextFormat("dotnet solution %s/../projects/VS2022/raylib.sln remove %s/../projects/VS2022/examples/%s.vcxproj",
|
||||||
//
|
exBasePath, exBasePath, exName));
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Edit: raylib.com/common/examples.js
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
// Remove: raylib.com/examples/<category>/<category>_example_name.html
|
// Remove: raylib.com/examples/<category>/<category>_example_name.html
|
||||||
@ -610,7 +609,7 @@ static int UpdateRequiredFiles(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add the remaining part of the original file
|
// Add the remaining part of the original file
|
||||||
memcpy(mkTextUpdated + mkListStartIndex + mkIndex, mkText + mkListEndIndex, strlen(mkText) - mkListEndIndex);
|
memcpy(mkTextUpdated + mkListStartIndex + mkIndex - 1, mkText + mkListEndIndex, strlen(mkText) - mkListEndIndex);
|
||||||
|
|
||||||
// Save updated file
|
// Save updated file
|
||||||
SaveFileText(TextFormat("%s/Makefile", exBasePath), mkTextUpdated);
|
SaveFileText(TextFormat("%s/Makefile", exBasePath), mkTextUpdated);
|
||||||
@ -644,7 +643,7 @@ static int UpdateRequiredFiles(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add the remaining part of the original file
|
// Add the remaining part of the original file
|
||||||
memcpy(mkwTextUpdated + mkwListStartIndex + mkwIndex, mkwText + mkwListEndIndex, strlen(mkwText) - mkwListEndIndex);
|
memcpy(mkwTextUpdated + mkwListStartIndex + mkwIndex - 1, mkwText + mkwListEndIndex, strlen(mkwText) - mkwListEndIndex);
|
||||||
|
|
||||||
// TODO: Add new example target, considering resources
|
// TODO: Add new example target, considering resources
|
||||||
|
|
||||||
@ -803,7 +802,6 @@ static int UpdateRequiredFiles(void)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Load examples collection information
|
// Load examples collection information
|
||||||
static rlExampleInfo *LoadExamplesData(const char *fileName, const char *category, bool sort, int *exCount)
|
static rlExampleInfo *LoadExamplesData(const char *fileName, const char *category, bool sort, int *exCount)
|
||||||
{
|
{
|
||||||
@ -894,9 +892,12 @@ static int FileCopy(const char *srcPath, const char *dstPath)
|
|||||||
int srcDataSize = 0;
|
int srcDataSize = 0;
|
||||||
unsigned char *srcFileData = LoadFileData(srcPath, &srcDataSize);
|
unsigned char *srcFileData = LoadFileData(srcPath, &srcDataSize);
|
||||||
|
|
||||||
// TODO: Create required paths if they do not exist
|
// Create required paths if they do not exist
|
||||||
|
if (!DirectoryExists(GetDirectoryPath(dstPath)))
|
||||||
|
MakeDirectory(GetDirectoryPath(dstPath));
|
||||||
|
|
||||||
if ((srcFileData != NULL) && (srcDataSize > 0)) result = SaveFileData(dstPath, srcFileData, srcDataSize);
|
if ((srcFileData != NULL) && (srcDataSize > 0))
|
||||||
|
result = SaveFileData(dstPath, srcFileData, srcDataSize);
|
||||||
|
|
||||||
UnloadFileData(srcFileData);
|
UnloadFileData(srcFileData);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user