Skip to content

Commit

Permalink
add ParseTranslation
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoLuis0 committed Dec 10, 2023
1 parent 42ab7dd commit 41d8535
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/r_data/r_translate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,3 +840,41 @@ DEFINE_ACTION_FUNCTION(_Translation, AddTranslation)
ACTION_RETURN_INT(trans.index());
}

int _ParseTranslation(VMVa_List &args)
{
FRemapTable NewTranslation;
NewTranslation.MakeIdentity();

while (args.curindex < args.numargs)
{
if (args.reginfo[args.curindex] != REGT_STRING)
{
ThrowAbortException(X_OTHER, "Non-string argument passed to ParseTranslation");
}
FString &s = args.args[args.curindex++].s();
NewTranslation.AddToTranslation(s.GetChars());
}

auto trans = GPalette.StoreTranslation(TRANSLATION_User, &NewTranslation);
return trans.index();
}

DEFINE_ACTION_FUNCTION(_Translation, ParseTranslation)
{
PARAM_PROLOGUE;
PARAM_VA_POINTER(va_reginfo);

VMVa_List args = { param, 0, numparam - 1, va_reginfo };

ACTION_RETURN_INT(_ParseTranslation(args));
}

DEFINE_ACTION_FUNCTION(_Translate, ParseTranslation)
{
PARAM_PROLOGUE;
PARAM_VA_POINTER(va_reginfo);

VMVa_List args = { param, 0, numparam - 1, va_reginfo };

ACTION_RETURN_INT(_ParseTranslation(args));
}
2 changes: 2 additions & 0 deletions wadsrc/static/zscript/doombase.zs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ struct Translate version("4.5")
{
return Translation.GetID(transname);
}

native static TranslationID ParseTranslation(String trns, ...);
}

struct DamageTypeDefinition native
Expand Down
1 change: 1 addition & 0 deletions wadsrc/static/zscript/engine/base.zs
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ struct Translation version("2.4")
native TranslationID AddTranslation();
native static TranslationID MakeID(int group, int num);
native static TranslationID GetID(Name transname);
native static TranslationID ParseTranslation(String trns, ...);
}

// Convenient way to attach functions to Quat
Expand Down

0 comments on commit 41d8535

Please sign in to comment.