- fixed translation setup for player backdrop.

- fixed return value of GetAction method of menu controls.
This commit is contained in:
Christoph Oelckers 2017-02-12 16:48:29 +01:00
commit 2e9c1ec3f3
4 changed files with 61 additions and 63 deletions

View file

@ -1271,7 +1271,7 @@ DMenuItemBase * CreateListMenuItemPatch(int x, int y, int height, int hotkey, FT
{
auto c = PClass::FindClass("ListMenuItemPatchItem");
auto p = c->CreateNew();
VMValue params[] = { p, x, y, height, tex.GetIndex(), hotkey, command.GetIndex(), param };
VMValue params[] = { p, x, y, height, tex.GetIndex(), FString(char(hotkey)), command.GetIndex(), param };
auto f = dyn_cast<PFunction>(c->Symbols.FindSymbol("InitDirect", false));
GlobalVMStack.Call(f->Variants[0].Implementation, params, countof(params), nullptr, 0);
return (DMenuItemBase*)p;
@ -1281,7 +1281,7 @@ DMenuItemBase * CreateListMenuItemText(int x, int y, int height, int hotkey, con
{
auto c = PClass::FindClass("ListMenuItemTextItem");
auto p = c->CreateNew();
VMValue params[] = { p, x, y, height, hotkey, text, font, int(color1.d), int(color2.d), command.GetIndex(), param };
VMValue params[] = { p, x, y, height, FString(char(hotkey)), text, font, int(color1.d), int(color2.d), command.GetIndex(), param };
auto f = dyn_cast<PFunction>(c->Symbols.FindSymbol("InitDirect", false));
GlobalVMStack.Call(f->Variants[0].Implementation, params, countof(params), nullptr, 0);
return (DMenuItemBase*)p;
@ -1351,7 +1351,7 @@ FName DMenuItemBase::GetAction(int *pparam)
int retval[2];
VMReturn ret[2]; ret[0].IntAt(&retval[0]); ret[1].IntAt(&retval[1]);
GlobalVMStack.Call(func, params, countof(params), ret, 2, nullptr);
return !!retval;
return ENamedName(retval[0]);
}
return NAME_None;
}

View file

@ -740,8 +740,6 @@ void R_InitTranslationTables ()
}
// The menu player also gets a separate translation table
PushIdentityTable(TRANSLATION_Players);
// This one is for the backdrop in the menu
PushIdentityTable(TRANSLATION_Players);
// The three standard translations from Doom or Heretic (seven for Strife),
// plus the generic ice translation.
@ -1227,36 +1225,6 @@ DEFINE_ACTION_FUNCTION(_Translation, SetPlayerTranslation)
ACTION_RETURN_BOOL(true);
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
struct FTranslation
{
PalEntry colors[256];
};
DEFINE_ACTION_FUNCTION(_Translation, SetTranslation)
{
PARAM_SELF_STRUCT_PROLOGUE(FTranslation);
PARAM_UINT(tgroup);
PARAM_UINT(tnum);
if (tgroup >= NUM_TRANSLATION_TABLES || tnum >= translationtables[tgroup].Size())
{
ACTION_RETURN_BOOL(false);
}
auto remap = translationtables[tgroup][tnum];
int i = 0;
for (auto p : self->colors)
{
remap->Palette[i] = p;
remap->Remap[i] = ColorMatcher.Pick(p);
}
ACTION_RETURN_BOOL(true);
}
//----------------------------------------------------------------------------
//
//
@ -1364,3 +1332,29 @@ void R_ParseTrnslate()
}
}
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
struct FTranslation
{
PalEntry colors[256];
};
DEFINE_ACTION_FUNCTION(_Translation, AddTranslation)
{
PARAM_SELF_STRUCT_PROLOGUE(FTranslation);
FRemapTable NewTranslation;
memcpy(&NewTranslation.Palette[0], self->colors, 256 * sizeof(PalEntry));
for (int i = 0; i < 256; i++)
{
NewTranslation.Remap[i] = ColorMatcher.Pick(self->colors[i]);
}
int trans = NewTranslation.StoreTranslation(TRANSLATION_Custom);
ACTION_RETURN_INT(trans);
}