Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STJr
SRB2
Commits
4545f954
Commit
4545f954
authored
1 year ago
by
Lactozilla
Browse files
Options
Downloads
Patches
Plain Diff
Add translations[] to Lua
parent
799bbe62
Branches
Branches containing commit
No related tags found
2 merge requests
!2355
fix newer versions of mixerx
,
!2190
ZDoom translations
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/lua_infolib.c
+37
-0
37 additions, 0 deletions
src/lua_infolib.c
src/r_translation.c
+5
-0
5 additions, 0 deletions
src/r_translation.c
src/r_translation.h
+1
-0
1 addition, 0 deletions
src/r_translation.h
with
43 additions
and
0 deletions
src/lua_infolib.c
+
37
−
0
View file @
4545f954
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include
"r_patch.h"
#include
"r_patch.h"
#include
"r_picformats.h"
#include
"r_picformats.h"
#include
"r_things.h"
#include
"r_things.h"
#include
"r_translation.h"
#include
"r_draw.h"
// R_GetColorByName
#include
"r_draw.h"
// R_GetColorByName
#include
"doomstat.h"
// luabanks[]
#include
"doomstat.h"
// luabanks[]
...
@@ -1899,6 +1900,32 @@ static int colorramp_len(lua_State *L)
...
@@ -1899,6 +1900,32 @@ static int colorramp_len(lua_State *L)
return
1
;
return
1
;
}
}
//////////////////////
// TRANSLATION INFO //
//////////////////////
// Arbitrary translations[] table index -> colormap_t *
static
int
lib_getTranslation
(
lua_State
*
L
)
{
lua_remove
(
L
,
1
);
const
char
*
name
=
luaL_checkstring
(
L
,
1
);
remaptable_t
*
tr
=
R_GetTranslationByID
(
R_FindCustomTranslation
(
name
));
if
(
tr
)
LUA_PushUserdata
(
L
,
&
tr
->
remap
,
META_COLORMAP
);
else
lua_pushnil
(
L
);
return
1
;
}
// #translations -> R_GetNumTranslations()
static
int
lib_translationslen
(
lua_State
*
L
)
{
lua_pushinteger
(
L
,
R_NumCustomTranslations
());
return
1
;
}
//////////////////////////////
//////////////////////////////
//
//
// Now push all these functions into the Lua state!
// Now push all these functions into the Lua state!
...
@@ -2076,6 +2103,16 @@ int LUA_InfoLib(lua_State *L)
...
@@ -2076,6 +2103,16 @@ int LUA_InfoLib(lua_State *L)
lua_setmetatable
(
L
,
-
2
);
lua_setmetatable
(
L
,
-
2
);
lua_setglobal
(
L
,
"skincolors"
);
lua_setglobal
(
L
,
"skincolors"
);
lua_newuserdata
(
L
,
0
);
lua_createtable
(
L
,
0
,
2
);
lua_pushcfunction
(
L
,
lib_getTranslation
);
lua_setfield
(
L
,
-
2
,
"__index"
);
lua_pushcfunction
(
L
,
lib_translationslen
);
lua_setfield
(
L
,
-
2
,
"__len"
);
lua_setmetatable
(
L
,
-
2
);
lua_setglobal
(
L
,
"translations"
);
lua_newuserdata
(
L
,
0
);
lua_newuserdata
(
L
,
0
);
lua_createtable
(
L
,
0
,
2
);
lua_createtable
(
L
,
0
,
2
);
lua_pushcfunction
(
L
,
lib_getSfxInfo
);
lua_pushcfunction
(
L
,
lib_getSfxInfo
);
...
...
This diff is collapsed.
Click to expand it.
src/r_translation.c
+
5
−
0
View file @
4545f954
...
@@ -689,6 +689,11 @@ void R_AddCustomTranslation(const char *name, int trnum)
...
@@ -689,6 +689,11 @@ void R_AddCustomTranslation(const char *name, int trnum)
tr
->
hash
=
quickncasehash
(
name
,
strlen
(
name
));
tr
->
hash
=
quickncasehash
(
name
,
strlen
(
name
));
}
}
unsigned
R_NumCustomTranslations
(
void
)
{
return
numcustomtranslations
;
}
remaptable_t
*
R_GetTranslationByID
(
int
id
)
remaptable_t
*
R_GetTranslationByID
(
int
id
)
{
{
if
(
id
<
0
||
id
>=
(
signed
)
numpaletteremaps
)
if
(
id
<
0
||
id
>=
(
signed
)
numpaletteremaps
)
...
...
This diff is collapsed.
Click to expand it.
src/r_translation.h
+
1
−
0
View file @
4545f954
...
@@ -43,6 +43,7 @@ struct PaletteRemapParseResult *PaletteRemap_ParseTranslation(remaptable_t *tr,
...
@@ -43,6 +43,7 @@ struct PaletteRemapParseResult *PaletteRemap_ParseTranslation(remaptable_t *tr,
int
R_FindCustomTranslation
(
const
char
*
name
);
int
R_FindCustomTranslation
(
const
char
*
name
);
void
R_AddCustomTranslation
(
const
char
*
name
,
int
trnum
);
void
R_AddCustomTranslation
(
const
char
*
name
,
int
trnum
);
unsigned
R_NumCustomTranslations
(
void
);
remaptable_t
*
R_GetTranslationByID
(
int
id
);
remaptable_t
*
R_GetTranslationByID
(
int
id
);
void
R_LoadTrnslateLumps
(
void
);
void
R_LoadTrnslateLumps
(
void
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment