Skip to content

Commit

Permalink
fix enum casing
Browse files Browse the repository at this point in the history
  • Loading branch information
luttje committed Aug 15, 2024
1 parent d5f82a1 commit 5da75f7
Show file tree
Hide file tree
Showing 45 changed files with 47 additions and 4 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ end

local function GenerateAllEnumerationsMarkdown()
if (CLIENT) then
for _, file in ipairs(Files.Find("docs/lua/enumerations/*", "DATA")) do
Files.RemoveFile("docs/lua/enumerations/" .. file, "DATA")
for _, file in ipairs(Files.Find("docs/enumerations/*", "DATA")) do
Files.RemoveFile("docs/enumerations/" .. file, "DATA")
end
end

Expand Down
2 changes: 2 additions & 0 deletions src/game/shared/luamanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
#define LUA_PATH_GAMEUI LUA_ROOT "\\gameui"
#define LUA_PATH_WEAPONS LUA_ROOT "\\weapons"

#define LUA_PATH_DATA "data"

#define LUA_BASE_ENTITY_CLASS "prop_scripted"
#define LUA_BASE_ENTITY_FACTORY "CBaseAnimating"
#define LUA_BASE_WEAPON "weapon_experimentbase_scriptedweapon"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/public/vgui_controls.lib
Git LFS file not shown
16 changes: 16 additions & 0 deletions src/public/lfilesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,22 @@ LUA_BINDING_BEGIN( Files, Open, "library", "Open a file." )

readMode = luaL_checkstring( L, 2 );

// For now We will support writing only to DATA, we will allow reading only in GAME, and DATA
if ( readMode[0] == 'w' )
{
if ( !V_stristr( pathId, "data" ) )
{
luaL_argerror( L, 3, "Invalid pathId for writing (DATA expected)" );
}
}
else if ( readMode[0] == 'r' )
{
if ( !V_stristr( pathId, "game" ) && !V_stristr( pathId, "data" ) )
{
luaL_argerror( L, 3, "Invalid pathId for reading (GAME or DATA expected)" );
}
}

lua_pushfilehandle( L, filesystem->Open( filePath, readMode, pathId ) );
return 1;
}
Expand Down
27 changes: 26 additions & 1 deletion tools/docs-build-enumerations.js
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
// See /game/experiment/scripts/lua/utilities/portal_generate_enumerations.lua
/*
See `/game/experiment/scripts/lua/utilities/portal_generate_enumerations.lua`
for the script that generates markdown files to the game data folder.
Due to how source engine writes, the path is forced lowercase.
After running the Lua script, run this script to copy the files to the final
destination, fixing the casing to be SCREAMING_SNAKE_CASE.
node ./tools/docs-build-enumerations.js
*/

const fs = require('fs');
const path = require('path');

const srcDir = path.join('game', 'experiment', 'data', 'docs', 'enumerations');
const outputDir = path.join('docs', 'enumerations');

const files = fs.readdirSync(srcDir);

for (const file of files) {
const srcPath = path.join(srcDir, file);
const outputPath = path.join(outputDir, file.toUpperCase());

fs.copyFileSync(srcPath, outputPath);
}

0 comments on commit 5da75f7

Please sign in to comment.