- 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
parent 03283de4e8
commit 2e9c1ec3f3
4 changed files with 63 additions and 65 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);
}

View file

@ -207,7 +207,7 @@ struct Translation
{
Color colors[256];
native bool SetTranslation(int group, int num);
native int AddTranslation();
native static bool SetPlayerTranslation(int group, int num, int plrnum, PlayerClass pclass);
static int MakeID(int group, int num)
{

View file

@ -53,6 +53,7 @@ class ListMenuItemPlayerDisplay : ListMenuItem
int mRandomClass;
int mRandomTimer;
int mClassNum;
int mTranslation;
enum EPDFlags
{
@ -81,7 +82,7 @@ class ListMenuItemPlayerDisplay : ListMenuItem
int b = c1.b + c2.b * i / 255;
trans.colors[i] = Color(255, r, g, b);
}
trans.SetTranslation(TRANSLATION_Players, MAXPLAYERS + 1);
mTranslation = trans.AddTranslation();
mBackdrop = TexMan.CheckForTexture("PlayerBackdrop", TexMan.Type_MiscPatch);
mPlayerClass = NULL;
@ -249,37 +250,40 @@ class ListMenuItemPlayerDisplay : ListMenuItem
TextureID texid = TexMan.CheckForTexture(portrait, TexMan.Type_MiscPatch);
screen.DrawTexture (texid, true, mXpos, mYpos, DTA_Clean, true);
}
int x = (mXpos - 160) * CleanXfac + (screen.GetWidth() >> 1);
int y = (mYpos - 100) * CleanYfac + (screen.GetHeight() >> 1);
screen.DrawTexture(mBackdrop, false, x, y - 1,
DTA_DestWidth, 72 * CleanXfac,
DTA_DestHeight, 80 * CleanYfac,
DTA_TranslationIndex, Translation.MakeID(TRANSLATION_Players, MAXPLAYERS + 1),
DTA_Masked, true);
Screen.DrawFrame (x, y, 72*CleanXfac, 80*CleanYfac-1);
if (mPlayerState != NULL)
else
{
Vector2 Scale;
TextureID sprite;
bool flip;
[sprite, flip, Scale] = mPlayerState.GetSpriteTexture(mRotation, mSkin, playdef.Scale);
if (sprite.IsValid())
int x = (mXpos - 160) * CleanXfac + (screen.GetWidth() >> 1);
int y = (mYpos - 100) * CleanYfac + (screen.GetHeight() >> 1);
screen.DrawTexture(mBackdrop, false, x, y - 1,
DTA_DestWidth, 72 * CleanXfac,
DTA_DestHeight, 80 * CleanYfac,
DTA_TranslationIndex, mTranslation,
DTA_Masked, true);
Screen.DrawFrame (x, y, 72*CleanXfac, 80*CleanYfac-1);
if (mPlayerState != NULL)
{
int trans = mTranslate? Translation.MakeID(TRANSLATION_Players, MAXPLAYERS) : 0;
let tscale = TexMan.GetScaledSize(sprite);
Scale.X *= CleanXfac * tscale.X;
Scale.Y *= CleanYfac * tscale.Y;
Vector2 Scale;
TextureID sprite;
bool flip;
screen.DrawTexture (sprite, false,
x + 36*CleanXfac, y + 71*CleanYfac,
DTA_DestWidthF, Scale.X, DTA_DestHeightF, Scale.Y,
DTA_TranslationIndex, trans,
DTA_FlipX, flip);
[sprite, flip, Scale] = mPlayerState.GetSpriteTexture(mRotation, mSkin, playdef.Scale);
if (sprite.IsValid())
{
int trans = mTranslate? Translation.MakeID(TRANSLATION_Players, MAXPLAYERS) : 0;
let tscale = TexMan.GetScaledSize(sprite);
Scale.X *= CleanXfac * tscale.X;
Scale.Y *= CleanYfac * tscale.Y;
screen.DrawTexture (sprite, false,
x + 36*CleanXfac, y + 71*CleanYfac,
DTA_DestWidthF, Scale.X, DTA_DestHeightF, Scale.Y,
DTA_TranslationIndex, trans,
DTA_FlipX, flip);
}
}
}
}