- transitioned most parts of the menu to the backend's draw functionality.

This commit is contained in:
Christoph Oelckers 2020-07-02 01:17:45 +02:00
parent 193260680f
commit 247c9fb786
6 changed files with 165 additions and 424 deletions

View file

@ -553,14 +553,10 @@ FListMenuItemText::FListMenuItemText(int x, int y, int height, int hotkey, const
: FListMenuItemSelectable(x, y, height, child, param) : FListMenuItemSelectable(x, y, height, child, param)
{ {
mText = text; mText = text;
/*
mFont = font; mFont = font;
mColor = color; mColor = color;
mColorSelected = color2; mColorSelected = color2;
*/
mFont = NewSmallFont; mFont = NewSmallFont;
mColor = CR_RED;
mColorSelected = CR_GOLD;
mHotkey = hotkey; mHotkey = hotkey;
} }
@ -570,10 +566,10 @@ FListMenuItemText::~FListMenuItemText()
void FListMenuItemText::Drawer(DListMenu* menu, const DVector2& origin, bool selected) void FListMenuItemText::Drawer(DListMenu* menu, const DVector2& origin, bool selected)
{ {
const char *text = mText; const char *text = GStrings(mText);
if (mText.Len()) if (mText.Len())
{ {
DrawText(twod, mFont, selected ? mColorSelected : mColor, mXpos, mYpos, text, DTA_Clean, true, TAG_DONE); DrawText(twod, mFont, selected ? mColorSelected : mColor, mXpos - mFont->StringWidth(text)/2, mYpos, text, DTA_Clean, true, TAG_DONE);
} }
} }

View file

@ -465,35 +465,6 @@ static void ParseListMenuBody(FScanner &sc, FListMenuDescriptor *desc)
desc->mYpos += desc->mLinespacing; desc->mYpos += desc->mLinespacing;
if (desc->mSelectedItem == -1) desc->mSelectedItem = desc->mItems.Size() - 1; if (desc->mSelectedItem == -1) desc->mSelectedItem = desc->mItems.Size() - 1;
}
else if (sc.Compare("NativeFont"))
{
desc->mNativePalNum = NIT_ActiveColor;
desc->mNativeFontScale = 1.f;
sc.MustGetString();
if (sc.Compare("Big")) desc->mNativeFontNum = NIT_BigFont;
else if (sc.Compare("Small")) desc->mNativeFontNum = NIT_SmallFont;
else if (sc.Compare("Tiny")) desc->mNativeFontNum = NIT_TinyFont;
else sc.ScriptError("Unknown native font type");
if (sc.CheckString(","))
{
sc.MustGetString();
if (sc.Compare("Active")) desc->mNativePalNum = NIT_ActiveColor;
else if (sc.Compare("Inactive")) desc->mNativePalNum = NIT_InactiveColor;
else if (sc.Compare("Selected")) desc->mNativePalNum = NIT_SelectedColor;
else
{
char* ep;
int v = (int)strtoll(sc.String, &ep, 0);
if (*ep != 0) sc.ScriptError("Unknown native palette");
desc->mNativePalNum = v;
}
if (sc.CheckString(","))
{
sc.MustGetFloat();
desc->mNativeFontScale = sc.Float;
}
}
} }
else if (sc.Compare("Font")) else if (sc.Compare("Font"))
{ {

View file

@ -43,193 +43,34 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_DUKE_NS BEGIN_DUKE_NS
#define MENU_MARGIN_REGULAR 40 //----------------------------------------------------------------------------
#define MENU_MARGIN_WIDE 32 //
#define MENU_MARGIN_CENTER 160 //
#define MENU_HEIGHT_CENTER 100 //
//----------------------------------------------------------------------------
enum MenuTextFlags_t
{
MT_Selected = 1 << 0,
MT_Disabled = 1 << 1,
MT_XCenter = 1 << 2,
MT_XRight = 1 << 3,
MT_YCenter = 1 << 4,
MT_Literal = 1 << 5,
MT_RightSide = 1 << 6,
};
// common font types
// tilenums are set after namesdyn runs.
// These are also modifiable by scripts.
// emptychar x,y between x,y zoom cursorLeft cursorCenter cursorScale textflags
// tilenum shade_deselected shade_disabled pal pal_selected pal_deselected pal_disabled
MenuFont_t MF_Redfont = { { 5<<16, 15<<16 }, { 0, 0 }, 65536, 20<<16, 110<<16, 65536, 65536, 65536, TEXT_BIGALPHANUM | TEXT_UPPERCASE,
-1, 10, 0, 0, 0, 0, 1,
0, 0, 1 };
MenuFont_t MF_Bluefont = { { 5<<16, 7<<16 }, { 0, 0 }, 65536, 10<<16, 110<<16, 32768, 65536, 65536, 0,
-1, 10, 0, 0, 10, 10, 16,
0, 0, 16 };
MenuFont_t MF_Minifont = { { 4<<16, 5<<16 }, { 1<<16, 1<<16 }, 65536, 10<<16, 110<<16, 32768, 65536, 65536, 0,
-1, 10, 0, 0, 2, 2, 0,
0, 0, 16 };
/*
This function prepares data after ART and CON have been processed.
It also initializes some data in loops rather than statically at compile time.
*/
void Menu_Init(void)
{
// prepare menu fonts
// check if tilenum is -1 in case it was set in EVENT_SETDEFAULTS
if ((unsigned)MF_Redfont.tilenum >= MAXTILES) MF_Redfont.tilenum = TILE_BIGALPHANUM;
if ((unsigned)MF_Bluefont.tilenum >= MAXTILES) MF_Bluefont.tilenum = TILE_STARTALPHANUM;
if ((unsigned)MF_Minifont.tilenum >= MAXTILES) MF_Minifont.tilenum = TILE_MINIFONT;
MF_Redfont.emptychar.y = tilesiz[MF_Redfont.tilenum].y << 16;
MF_Bluefont.emptychar.y = tilesiz[MF_Bluefont.tilenum].y << 16;
MF_Minifont.emptychar.y = tilesiz[MF_Minifont.tilenum].y << 16;
if (!minitext_lowercase)
MF_Minifont.textflags |= TEXT_UPPERCASE;
if (RR)
{
MF_Redfont.zoom = 32768;
MF_Redfont.emptychar.x <<= 1;
MF_Redfont.cursorScale = 13107;
MF_Redfont.cursorScale2 = 6553;
//MF_Redfont.emptychar.y <<= 1;
MF_Bluefont.zoom = 32768;
MF_Bluefont.emptychar.x <<= 1;
MF_Bluefont.cursorScale = 6553;
MF_Bluefont.cursorScale2 = 6553;
//MF_Bluefont.emptychar.y <<= 1;
MF_Minifont.zoom = 32768;
MF_Minifont.emptychar.x <<= 1;
MF_Minifont.cursorScale = 6553;
MF_Minifont.cursorScale2 = 6553;
//MF_Minifont.emptychar.y <<= 1;
}
}
static void Menu_DrawBackground(const DVector2 &origin) static void Menu_DrawBackground(const DVector2 &origin)
{ {
rotatesprite_fs(int(origin.X * 65536) + (MENU_MARGIN_CENTER << 16), int(origin.Y * 65536) + (100 << 16), 65536L, 0, TILE_MENUSCREEN, 16, 0, 10 + 64); DrawTexture(twod, tileGetTexture(TILE_MENUSCREEN), origin.X + 160, origin.Y + 100, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_Color, 0xff808080, TAG_DONE);
} }
static void Menu_DrawTopBar(const DVector2 &origin) //----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
static void Menu_DrawCursor(double x, double y, double scale, bool right)
{ {
rotatesprite_fs(int(origin.X*65536) + (MENU_MARGIN_CENTER<<16), int(origin.Y*65536) + (19<<16), MF_Redfont.cursorScale3, 0,TILE_MENUBAR,16,0,10); const int frames = isRR() ? 16 : 7;
int picnum;
if (!right) picnum = TILE_SPINNINGNUKEICON + (((int)totalclock >> 3) % frames);
else picnum = TILE_SPINNINGNUKEICON + frames - 1 - ((frames - 1 + ((int)totalclock >> 3)) % frames);
int light = int(224 + 31 * sin((int)totalclock / 20.));
PalEntry pe(255, light, light, light);
DrawTexture(twod, tileGetTexture(picnum), x, y, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_Color, pe, DTA_CenterOffset, true, TAG_DONE);
} }
static void Menu_DrawTopBarCaption(const char* caption, const DVector2& origin)
{
static char t[64];
size_t const srclen = strlen(caption);
size_t const dstlen = min(srclen, ARRAY_SIZE(t) - 1);
memcpy(t, caption, dstlen);
t[dstlen] = '\0';
char* p = &t[dstlen - 1];
if (*p == ':')
*p = '\0';
captionmenutext(int(origin.X * 65536) + (MENU_MARGIN_CENTER << 16), int(origin.Y * 65536) + (24 << 16) + (15 << 15), t);
}
static void Menu_GetFmt(const MenuFont_t* font, uint8_t const status, int32_t* s)
{
if (status & MT_Selected)
*s = sintable[((int32_t)totalclock << 5) & 2047] >> 12;
else
*s = font->shade_deselected;
// sum shade values
if (status & MT_Disabled)
*s += font->shade_disabled;
}
static vec2_t Menu_Text(int32_t x, int32_t y, const MenuFont_t* font, const char* t, uint8_t status, int32_t ydim_upper, int32_t ydim_lower)
{
int32_t s, p, ybetween = font->between.y;
int32_t f = font->textflags;
if (RR) f |= TEXT_RRMENUTEXTHACK;
if (status & MT_XCenter)
f |= TEXT_XCENTER;
if (status & MT_XRight)
f |= TEXT_XRIGHT;
if (status & MT_YCenter)
{
f |= TEXT_YCENTER | TEXT_YOFFSETZERO;
ybetween = font->emptychar.y; // <^ the battle against 'Q'
}
if (status & MT_Literal)
f |= TEXT_LITERALESCAPE;
int32_t z = font->zoom;
if (status & MT_Disabled)
p = (status & MT_RightSide) ? font->pal_disabled_right : font->pal_disabled;
else if (status & MT_Selected)
p = (status & MT_RightSide) ? font->pal_selected_right : font->pal_selected;
else
p = (status & MT_RightSide) ? font->pal_deselected_right : font->pal_deselected;
Menu_GetFmt(font, status, &s);
return G_ScreenText(font->tilenum, x, y, z, 0, 0, t, s, p, 2 | 8 | 16 | ROTATESPRITE_FULL16, 0, font->emptychar.x, font->emptychar.y, font->between.x, ybetween, f, 0, ydim_upper, xdim - 1, ydim_lower);
}
static int32_t Menu_CursorShade(void)
{
return 4 - (sintable[((int32_t)totalclock << 4) & 2047] >> 11);
}
static void Menu_DrawCursorCommon(int32_t x, int32_t y, int32_t z, int32_t picnum, int32_t ydim_upper = 0, int32_t ydim_lower = ydim - 1)
{
rotatesprite_(x, y, z, 0, picnum, Menu_CursorShade(), 0, 2 | 8, 0, 0, 0, ydim_upper, xdim - 1, ydim_lower);
}
static void Menu_DrawCursorLeft(int32_t x, int32_t y, int32_t z)
{
const int frames = RR ? 16 : 7;
Menu_DrawCursorCommon(x, y, z, TILE_SPINNINGNUKEICON+(((int32_t) totalclock>>3)%frames));
}
static void Menu_DrawCursorRight(int32_t x, int32_t y, int32_t z)
{
const int frames = RR ? 16 : 7;
Menu_DrawCursorCommon(x, y, z, TILE_SPINNINGNUKEICON+frames-1-((frames-1+((int32_t) totalclock>>3))%frames));
}
static int Menu_GetFontHeight(int fontnum)
{
auto& font = fontnum == NIT_BigFont ? MF_Redfont : fontnum == NIT_SmallFont ? MF_Bluefont : MF_Minifont;
return font.get_yline();
}
int dword_A99A0, dword_A99A4, dword_A99A8, dword_A99AC;
short word_A99B0, word_A99B2;
int dword_A99B4, dword_A99B8, dword_A99BC, dword_A99C0, dword_A99C4, dword_A99C8;
void Menu_DHLeaonardHeadReset(void)
{
dword_A99A0 = 0;
dword_A99A4 = 0;
dword_A99A8 = 0;
dword_A99AC = 0;
word_A99B2 = 0;
dword_A99B4 = 0;
word_A99B0 = 0;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// //
// Implements the native looking menu used for the main menu // Implements the native looking menu used for the main menu
@ -246,13 +87,13 @@ protected:
void Ticker() override void Ticker() override
{ {
// Lay out the menu. // Lay out the menu.
int32_t y_upper = mDesc->mYpos; int y_upper = mDesc->mYpos;
int32_t y_lower = y_upper + mDesc->mYbotton; int y_lower = y_upper + mDesc->mYbotton;
int32_t y = 0; int y = 0;
int32_t calculatedentryspacing = 0; int spacing = 0;
int32_t const height = Menu_GetFontHeight(mDesc->mNativeFontNum) >> 16; int const height = 15; // cannot take value from the font because it would be inconsistent
int32_t totalheight = 0, numvalidentries = mDesc->mItems.Size(); int totalheight = 0, numvalidentries = mDesc->mItems.Size();
for (unsigned e = 0; e < mDesc->mItems.Size(); ++e) for (unsigned e = 0; e < mDesc->mItems.Size(); ++e)
{ {
@ -261,9 +102,8 @@ protected:
entry->SetHeight(height); entry->SetHeight(height);
totalheight += height; totalheight += height;
} }
if (mDesc->mSpacing <= 0) calculatedentryspacing = std::max(0, (y_lower - y_upper - totalheight) / (numvalidentries > 1 ? numvalidentries - 1 : 1)); if (mDesc->mSpacing <= 0) spacing = std::max(0, (y_lower - y_upper - totalheight) / (numvalidentries > 1 ? numvalidentries - 1 : 1));
if (calculatedentryspacing <= 0) calculatedentryspacing = mDesc->mSpacing; if (spacing <= 0) spacing = mDesc->mSpacing;
// totalHeight calculating pass // totalHeight calculating pass
int totalHeight; int totalHeight;
@ -275,18 +115,23 @@ protected:
entry->SetY(y_upper + y); entry->SetY(y_upper + y);
y += height; y += height;
totalHeight = y; totalHeight = y;
y += calculatedentryspacing; y += spacing;
} }
} }
} }
}; };
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
class DukeMainMenu : public DukeListMenu class DukeMainMenu : public DukeListMenu
{ {
virtual void Init(DMenu* parent = NULL, FListMenuDescriptor* desc = NULL) override virtual void Init(DMenu* parent = NULL, FListMenuDescriptor* desc = NULL) override
{ {
DukeListMenu::Init(parent, desc); DukeListMenu::Init(parent, desc);
Menu_DHLeaonardHeadReset();
} }
void PreDraw() override void PreDraw() override
@ -294,167 +139,70 @@ class DukeMainMenu : public DukeListMenu
DukeListMenu::PreDraw(); DukeListMenu::PreDraw();
if (RRRA) if (RRRA)
{ {
rotatesprite_fs(int(origin.X * 65536) + ((MENU_MARGIN_CENTER - 5) << 16), int(origin.Y * 65536) + ((57) << 16), 16592L, 0, TILE_THREEDEE, 0, 0, 10); rotatesprite_fs(int(origin.X * 65536) + ((160 - 5) << 16), int(origin.Y * 65536) + ((57) << 16), 16592L, 0, TILE_THREEDEE, 0, 0, 10);
} }
else if (RR) else if (isRR())
{ {
rotatesprite_fs(int(origin.X * 65536) + ((MENU_MARGIN_CENTER + 5) << 16), int(origin.Y * 65536) + ((24) << 16), 23592L, 0, TILE_INGAMEDUKETHREEDEE, 0, 0, 10); rotatesprite_fs(int(origin.X * 65536) + ((160 + 5) << 16), int(origin.Y * 65536) + ((24) << 16), 23592L, 0, TILE_INGAMEDUKETHREEDEE, 0, 0, 10);
} }
else else
{ {
rotatesprite_fs(int(origin.X * 65536) + (MENU_MARGIN_CENTER<<16), int(origin.Y * 65536) + ((28)<<16), 65536L,0,TILE_INGAMEDUKETHREEDEE,0,0,10); rotatesprite_fs(int(origin.X * 65536) + (160<<16), int(origin.Y * 65536) + ((28)<<16), 65536L,0,TILE_INGAMEDUKETHREEDEE,0,0,10);
if (PLUTOPAK) // JBF 20030804 if (PLUTOPAK) // JBF 20030804
rotatesprite_fs(int(origin.X * 65536) + ((MENU_MARGIN_CENTER+100)<<16), int(origin.Y * 65536) + (36<<16), 65536L,0,TILE_PLUTOPAKSPRITE+2,(sintable[((int32_t) totalclock<<4)&2047]>>11),0,2+8); rotatesprite_fs(int(origin.X * 65536) + ((160+100)<<16), int(origin.Y * 65536) + (36<<16), 65536L,0,TILE_PLUTOPAKSPRITE+2,(sintable[((int32_t) totalclock<<4)&2047]>>11),0,2+8);
} }
} }
}; };
class DukeHuntMenu : public DukeListMenu
{
void PreDraw() override
{
DukeListMenu::PreDraw();
vec2_t forigin = { int(origin.X * 65536), int(origin.Y * 65536) };
int t1, t2;
short ang;
switch (mDesc->mSelectedItem)
{
case 0:
default:
t1 = 7098;
t2 = 7041;
ang = 16;
break;
case 1:
t1 = 7099;
t2 = 7042;
ang = 2032;
break;
case 2:
t1 = 7100;
t2 = 7043;
ang = 16;
break;
case 3:
t1 = 7101;
t2 = 7044;
ang = 2032;
break;
}
rotatesprite_fs(forigin.x + (240 << 16), forigin.y + (56 << 16), 24576L, ang, t1, 2, 0, 64 + 10);
rotatesprite_fs(forigin.x + (240 << 16), forigin.y + (42 << 16), 24576L, ang, 7104, 2, 0, 10);
rotatesprite_fs(forigin.x + (20 << 16), forigin.y + (10 << 16), 32768L, 0, t2, -64, 0, 128 + 16 + 10);
}
};
class DukeTargetMenu : public DukeListMenu
{
void PreDraw() override
{
DukeListMenu::PreDraw();
vec2_t forigin = { int(origin.X * 65536), int(origin.Y * 65536) };
int t1, t2;
short ang;
switch (mDesc->mSelectedItem)
{
case 0:
default:
t1 = 7102;
t2 = 7045;
ang = 16;
break;
case 1:
t1 = 7103;
t2 = 7046;
ang = 2032;
break;
break;
}
rotatesprite_fs(forigin.x + (240 << 16), forigin.y + (56 << 16), 24576L, ang, t1, 2, 0, 64 + 10);
rotatesprite_fs(forigin.x + (240 << 16), forigin.y + (42 << 16), 24576L, ang, 7104, 2, 0, 10);
rotatesprite_fs(forigin.x + (20 << 16), forigin.y + (10 << 16), 32768L, 0, t2, -64, 0, 128 + 16 + 10);
}
};
class DukeWeaponMenu : public DukeListMenu
{
void PreDraw() override
{
DukeListMenu::PreDraw();
vec2_t forigin = { int(origin.X * 65536), int(origin.Y * 65536) };
int t1, t2;
switch (mDesc->mSelectedItem)
{
case 0:
default:
t1 = 7124;
t2 = 7066;
break;
case 1:
t1 = 7125;
t2 = 7067;
break;
case 2:
t1 = 7126;
t2 = 7068;
break;
case 3:
t1 = 7127;
t2 = 7069;
break;
case 4:
t1 = 7128;
t2 = 7070;
break;
}
rotatesprite_fs(forigin.x + (240 << 16), forigin.y + (56 << 16), 32768L, 0, t1, 2, 0, 64 + 10);
rotatesprite_fs(forigin.x + (8 << 16), forigin.y + (4 << 16), 32768L, 0, t2, -64, 0, 128 + 16 + 10);
}
};
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// //
// Menu related game interface functions // Menu related game interface functions
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void GameInterface::DrawNativeMenuText(int fontnum, int state, double xpos, double ypos, float fontscale, const char* text, int flags) void GameInterface::DrawNativeMenuText(int fontnum, int state, double oxpos, double ypos, float fontscale, const char* text, int flags)
{ {
int ydim_upper = 0; double xpos = oxpos;
int ydim_lower = ydim - 1; int trans;
//int32_t const indent = 0; // not set for any relevant menu PalEntry pe;
int x = int(xpos * 65536);
double scale = isRR() ? 0.4 : 1.;
if (flags & LMF_Centered) xpos -= BigFont->StringWidth(text) * scale * 0.5;
uint8_t status = 0;
if (state == NIT_SelectedState)
status |= MT_Selected;
if (state == NIT_InactiveState) if (state == NIT_InactiveState)
status |= MT_Disabled;
if (flags & LMF_Centered)
status |= MT_XCenter;
bool const dodraw = true;
MenuFont_t& font = fontnum == NIT_BigFont ? MF_Redfont : fontnum == NIT_SmallFont ? MF_Bluefont : MF_Minifont;
int32_t const height = font.get_yline();
status |= MT_YCenter;
int32_t const y_internal = int(ypos * 65536) + ((height >> 17) << 16);// -menu->scrollPos;
vec2_t textsize;
if (dodraw)
textsize = Menu_Text(x, y_internal, &font, text, status, ydim_upper, ydim_lower);
if (dodraw && (status & MT_Selected) && state != 1)
{ {
if (status & MT_XCenter) trans = TRANSLATION(Translation_Remap, 1);
pe = 0xffffffff;
}
else if (state == NIT_SelectedState)
{
trans = 0;
int light = 224 + 31 * sin(int(totalclock) / 20.);
pe = PalEntry(255, light, light, light);
}
else
{
trans = 0;
pe = 0xffa0a0a0;
}
DrawText(twod, BigFont, CR_UNDEFINED, xpos, ypos, text, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_Color, pe,
DTA_TranslationIndex, trans, TAG_DONE);
if (state == NIT_SelectedState)
{
const int cursorOffset = 110;
const double cursorScale = isRR() ? 0.2 : 1.0;
const double ymid = ypos + 7; // half height must be hardcoded or layouts will break.
if (flags & LMF_Centered)
{ {
Menu_DrawCursorLeft(x + font.cursorCenterPosition, y_internal, font.cursorScale); Menu_DrawCursor(oxpos + cursorOffset, ymid, cursorScale, false);
Menu_DrawCursorRight(x - font.cursorCenterPosition, y_internal, font.cursorScale); Menu_DrawCursor(oxpos - cursorOffset, ymid, cursorScale, true);
} }
else else
Menu_DrawCursorLeft(x /*+ indent*/ - font.cursorLeftPosition, y_internal, font.cursorScale); Menu_DrawCursor(oxpos - cursorOffset, ymid, cursorScale, false);
} }
} }
@ -485,11 +233,11 @@ void GameInterface::MenuSound(EMenuSounds snd)
break; break;
case CursorSound: case CursorSound:
S_PlaySound(RR ? 335 : KICK_HIT, CHAN_AUTO, CHANF_UI); S_PlaySound(isRR() ? 335 : KICK_HIT, CHAN_AUTO, CHANF_UI);
break; break;
case AdvanceSound: case AdvanceSound:
S_PlaySound(RR ? 341 : PISTOL_BODYHIT, CHAN_AUTO, CHANF_UI); S_PlaySound(isRR() ? 341 : PISTOL_BODYHIT, CHAN_AUTO, CHANF_UI);
break; break;
case CloseSound: case CloseSound:
@ -517,13 +265,8 @@ void GameInterface::MenuClosed()
{ {
ready2send = 1; ready2send = 1;
totalclock = ototalclock; totalclock = ototalclock;
CAMERACLOCK = (int32_t)totalclock; g_cameraClock = (int32_t)totalclock;
CAMERADIST = 65536; g_cameraDistance = 65536;
// Reset next-viewscreen-redraw counter.
// XXX: are there any other cases like that in need of handling?
if (g_curViewscreen >= 0)
actor[g_curViewscreen].t_data[0] = (int32_t)totalclock;
} }
G_UpdateScreenArea(); G_UpdateScreenArea();
@ -533,7 +276,7 @@ void GameInterface::MenuClosed()
bool GameInterface::CanSave() bool GameInterface::CanSave()
{ {
if (ud.recstat == 2 || DEER) return false; if (ud.recstat == 2) return false;
auto &myplayer = *g_player[myconnectindex].ps; auto &myplayer = *g_player[myconnectindex].ps;
if (sprite[myplayer.i].extra <= 0) if (sprite[myplayer.i].extra <= 0)
{ {
@ -555,19 +298,19 @@ void GameInterface::StartGame(FNewGameStartup& gs)
switch (gs.Skill) switch (gs.Skill)
{ {
case 0: case 0:
skillsound = RR ? 427 : JIBBED_ACTOR6; skillsound = isRR() ? 427 : JIBBED_ACTOR6;
break; break;
case 1: case 1:
skillsound = RR ? 428 : BONUS_SPEECH1; skillsound = isRR() ? 428 : BONUS_SPEECH1;
break; break;
case 2: case 2:
skillsound = RR ? 196 : DUKE_GETWEAPON2; skillsound = isRR() ? 196 : DUKE_GETWEAPON2;
break; break;
case 3: case 3:
skillsound = RR ? 195 : JIBBED_ACTOR5; skillsound = isRR() ? 195 : JIBBED_ACTOR5;
break; break;
case 4: case 4:
skillsound = RR ? 197 : JIBBED_ACTOR5; // Does not exist in DN3D. skillsound = isRR() ? 197 : JIBBED_ACTOR5; // Does not exist in DN3D.
break; break;
} }
ud.m_player_skill = gs.Skill + 1; ud.m_player_skill = gs.Skill + 1;
@ -609,8 +352,16 @@ FSavegameInfo GameInterface::GetSaveSig()
void GameInterface::DrawMenuCaption(const DVector2& origin, const char* text) void GameInterface::DrawMenuCaption(const DVector2& origin, const char* text)
{ {
Menu_DrawTopBar(origin); DrawTexture(twod, tileGetTexture(TILE_MENUBAR), origin.X + 160, origin.Y + 19, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_Color, 0xff808080, DTA_CenterOffset, 1, TAG_DONE);
Menu_DrawTopBarCaption(text, origin);
FString t = text;
size_t newlen = t.Len();
if (t[t.Len() - 1] == ':') newlen--;
if (newlen > 63) newlen = 63;
t.Truncate(newlen);
double scale = isRR() ? 0.4 : 1.0;
double x = 160 + origin.X - BigFont->StringWidth(t) * scale * 0.5;
DrawText(twod, BigFont, CR_UNTRANSLATED, x, origin.Y + 12, t, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE);
} }
void GameInterface::DrawCenteredTextScreen(const DVector2 &origin, const char *text, int position, bool bg) void GameInterface::DrawCenteredTextScreen(const DVector2 &origin, const char *text, int position, bool bg)
@ -621,9 +372,9 @@ void GameInterface::DrawCenteredTextScreen(const DVector2 &origin, const char *t
// Only used for the confirmation screen. // Only used for the confirmation screen.
int lines = 1; int lines = 1;
for (int i = 0; text[i]; i++) if (text[i] == '\n') lines++; for (int i = 0; text[i]; i++) if (text[i] == '\n') lines++;
int height = lines * Menu_GetFontHeight(NIT_SmallFont); int height = lines * SmallFont->GetHeight();
position -= height >> 17; position -= height >> 17;
if (!RR) Menu_DrawCursorLeft(160 << 16, 130 << 16, 65536); if (!isRR()) Menu_DrawCursor(160, 130, 1, false);
} }
G_ScreenText(MF_Bluefont.tilenum, int((origin.X + 160) * 65536), int((origin.Y + position) * 65536), MF_Bluefont.zoom, 0, 0, text, 0, MF_Bluefont.pal, G_ScreenText(MF_Bluefont.tilenum, int((origin.X + 160) * 65536), int((origin.Y + position) * 65536), MF_Bluefont.zoom, 0, 0, text, 0, MF_Bluefont.pal,
2 | 8 | 16 | ROTATESPRITE_FULL16, 0, MF_Bluefont.emptychar.x, MF_Bluefont.emptychar.y, MF_Bluefont.between.x, MF_Bluefont.between.y, 2 | 8 | 16 | ROTATESPRITE_FULL16, 0, MF_Bluefont.emptychar.x, MF_Bluefont.emptychar.y, MF_Bluefont.between.x, MF_Bluefont.between.y,
@ -633,7 +384,7 @@ void GameInterface::DrawCenteredTextScreen(const DVector2 &origin, const char *t
void GameInterface::DrawPlayerSprite(const DVector2& origin, bool onteam) void GameInterface::DrawPlayerSprite(const DVector2& origin, bool onteam)
{ {
if (RR) if (isRR())
rotatesprite_fs(int(origin.X * 65536) + (260<<16), int(origin.Y * 65536) + ((24+(tilesiz[TILE_APLAYER].y>>2))<<16), 24576L,0,3845+36-((((8-((int32_t) totalclock>>4)))&7)*5),0,onteam ? G_GetTeamPalette(playerteam) : G_CheckPlayerColor(playercolor),10); rotatesprite_fs(int(origin.X * 65536) + (260<<16), int(origin.Y * 65536) + ((24+(tilesiz[TILE_APLAYER].y>>2))<<16), 24576L,0,3845+36-((((8-((int32_t) totalclock>>4)))&7)*5),0,onteam ? G_GetTeamPalette(playerteam) : G_CheckPlayerColor(playercolor),10);
else else
rotatesprite_fs(int(origin.X * 65536) + (260<<16), int(origin.Y * 65536) + ((24+(tilesiz[TILE_APLAYER].y>>1))<<16), 49152L,0,1441-((((4-((int32_t) totalclock>>4)))&3)*5),0,onteam ? G_GetTeamPalette(playerteam) : G_CheckPlayerColor(playercolor),10); rotatesprite_fs(int(origin.X * 65536) + (260<<16), int(origin.Y * 65536) + ((24+(tilesiz[TILE_APLAYER].y>>1))<<16), 49152L,0,1441-((((4-((int32_t) totalclock>>4)))&3)*5),0,onteam ? G_GetTeamPalette(playerteam) : G_CheckPlayerColor(playercolor),10);
@ -656,9 +407,6 @@ END_DUKE_NS
static TMenuClassDescriptor<Duke3d::DukeMainMenu> _mm("Duke.MainMenu"); static TMenuClassDescriptor<Duke3d::DukeMainMenu> _mm("Duke.MainMenu");
static TMenuClassDescriptor<Duke3d::DukeListMenu> _lm("Duke.ListMenu"); static TMenuClassDescriptor<Duke3d::DukeListMenu> _lm("Duke.ListMenu");
static TMenuClassDescriptor<Duke3d::DukeHuntMenu> _dhm("Duke.HuntMenu");
static TMenuClassDescriptor<Duke3d::DukeTargetMenu> _dtm("Duke.TargetMenu");
static TMenuClassDescriptor<Duke3d::DukeWeaponMenu> _dwm("Duke.WeaponMenu");
static TMenuClassDescriptor<DImageScrollerMenu> _ism("Duke.ImageScrollerMenu"); // does not implement a new class, we only need the descriptor. static TMenuClassDescriptor<DImageScrollerMenu> _ism("Duke.ImageScrollerMenu"); // does not implement a new class, we only need the descriptor.
@ -667,7 +415,4 @@ void RegisterDuke3dMenus()
menuClasses.Push(&_mm); menuClasses.Push(&_mm);
menuClasses.Push(&_lm); menuClasses.Push(&_lm);
menuClasses.Push(&_ism); menuClasses.Push(&_ism);
menuClasses.Push(&_dhm);
menuClasses.Push(&_dtm);
menuClasses.Push(&_dwm);
} }

View file

@ -29,6 +29,67 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_DUKE_NS BEGIN_DUKE_NS
// common font types
// tilenums are set after namesdyn runs.
// These are also modifiable by scripts.
// emptychar x,y between x,y zoom cursorLeft cursorCenter cursorScale textflags
// tilenum shade_deselected shade_disabled pal pal_selected pal_deselected pal_disabled
MenuFont_t MF_Redfont = { { 5 << 16, 15 << 16 }, { 0, 0 }, 65536, 20 << 16, 110 << 16, 65536, 65536, 65536, TEXT_BIGALPHANUM | TEXT_UPPERCASE,
-1, 10, 0, 0, 0, 0, 1,
0, 0, 1 };
MenuFont_t MF_Bluefont = { { 5 << 16, 7 << 16 }, { 0, 0 }, 65536, 10 << 16, 110 << 16, 32768, 65536, 65536, 0,
-1, 10, 0, 0, 10, 10, 16,
0, 0, 16 };
MenuFont_t MF_Minifont = { { 4 << 16, 5 << 16 }, { 1 << 16, 1 << 16 }, 65536, 10 << 16, 110 << 16, 32768, 65536, 65536, 0,
-1, 10, 0, 0, 2, 2, 0,
0, 0, 16 };
/*
This function prepares data after ART and CON have been processed.
It also initializes some data in loops rather than statically at compile time.
*/
void Menu_Init(void)
{
// prepare menu fonts
// check if tilenum is -1 in case it was set in EVENT_SETDEFAULTS
if ((unsigned)MF_Redfont.tilenum >= MAXTILES) MF_Redfont.tilenum = TILE_BIGALPHANUM;
if ((unsigned)MF_Bluefont.tilenum >= MAXTILES) MF_Bluefont.tilenum = TILE_STARTALPHANUM;
if ((unsigned)MF_Minifont.tilenum >= MAXTILES) MF_Minifont.tilenum = TILE_MINIFONT;
MF_Redfont.emptychar.y = tilesiz[MF_Redfont.tilenum].y << 16;
MF_Bluefont.emptychar.y = tilesiz[MF_Bluefont.tilenum].y << 16;
MF_Minifont.emptychar.y = tilesiz[MF_Minifont.tilenum].y << 16;
if (!minitext_lowercase)
MF_Minifont.textflags |= TEXT_UPPERCASE;
if (RR)
{
MF_Redfont.zoom = 32768;
MF_Redfont.emptychar.x <<= 1;
MF_Redfont.cursorScale = 13107;
MF_Redfont.cursorScale2 = 6553;
//MF_Redfont.emptychar.y <<= 1;
MF_Bluefont.zoom = 32768;
MF_Bluefont.emptychar.x <<= 1;
MF_Bluefont.cursorScale = 6553;
MF_Bluefont.cursorScale2 = 6553;
//MF_Bluefont.emptychar.y <<= 1;
MF_Minifont.zoom = 32768;
MF_Minifont.emptychar.x <<= 1;
MF_Minifont.cursorScale = 6553;
MF_Minifont.cursorScale2 = 6553;
//MF_Minifont.emptychar.y <<= 1;
}
}
// assign the character's tilenum // assign the character's tilenum
int GameInterface::GetStringTile(int font, const char* t, int f) int GameInterface::GetStringTile(int font, const char* t, int f)
{ {
@ -169,9 +230,5 @@ void menutext_(int32_t x, int32_t y, int32_t s, char const *t, int32_t o, int32_
G_ScreenText(MF_Redfont.tilenum, x, y - (12<<16), MF_Redfont.zoom, 0, 0, t, s, MF_Redfont.pal, o|ROTATESPRITE_FULL16, 0, MF_Redfont.emptychar.x, MF_Redfont.emptychar.y, MF_Redfont.between.x, MF_Redfont.between.y, f|MF_Redfont.textflags|TEXT_LITERALESCAPE, 0, 0, xdim-1, ydim-1); G_ScreenText(MF_Redfont.tilenum, x, y - (12<<16), MF_Redfont.zoom, 0, 0, t, s, MF_Redfont.pal, o|ROTATESPRITE_FULL16, 0, MF_Redfont.emptychar.x, MF_Redfont.emptychar.y, MF_Redfont.between.x, MF_Redfont.between.y, f|MF_Redfont.textflags|TEXT_LITERALESCAPE, 0, 0, xdim-1, ydim-1);
} }
void captionmenutext(int32_t x, int32_t y, char const *t)
{
G_ScreenText(MF_Redfont.tilenum, x, y - (12<<16), MF_Redfont.zoom, 0, 0, t, 0, ud.menutitle_pal, 2|8|16|ROTATESPRITE_FULL16, 0, MF_Redfont.emptychar.x, MF_Redfont.emptychar.y, MF_Redfont.between.x, MF_Redfont.between.y, MF_Redfont.textflags|TEXT_LITERALESCAPE|TEXT_XCENTER|TEXT_YCENTER, 0, 0, xdim-1, ydim-1);
}
END_DUKE_NS END_DUKE_NS

View file

@ -33,7 +33,6 @@ extern int32_t minitext_yofs;
extern int32_t minitext_(int32_t x, int32_t y, const char *t, int32_t s, int32_t p, int32_t sb); extern int32_t minitext_(int32_t x, int32_t y, const char *t, int32_t s, int32_t p, int32_t sb);
extern void menutext_(int32_t x, int32_t y, int32_t s, char const *t, int32_t o, int32_t f); extern void menutext_(int32_t x, int32_t y, int32_t s, char const *t, int32_t o, int32_t f);
extern void captionmenutext(int32_t x, int32_t y, char const *t);
extern vec2_t gametext_(int32_t x, int32_t y, const char *t, int32_t s, int32_t p, int32_t o, int32_t a, int32_t f); extern vec2_t gametext_(int32_t x, int32_t y, const char *t, int32_t s, int32_t p, int32_t o, int32_t a, int32_t f);
inline int minitext(int x, int y, const char* t, int p, int sb) inline int minitext(int x, int y, const char* t, int p, int sb)

View file

@ -8,46 +8,19 @@ LISTMENU "MainMenu"
{ {
ScriptId 0 ScriptId 0
class "$.MainMenu" class "$.MainMenu"
ifgame(Duke, Nam, WW2GI, Fury, Redneck, RedneckRides) ifgame(Duke, Nam, WW2GI, Redneck, RedneckRides)
{ {
ifgame(fury) position 160, 55, 115
{ centermenu
position 40, 130, 60 animatedtransition
fixedspacing 2
}
else
{
position 160, 55, 115
centermenu
animatedtransition
}
NativeTextItem "$MNU_NEWGAME", "n", "EpisodeMenu" NativeTextItem "$MNU_NEWGAME", "n", "EpisodeMenu"
//NativeTextItem "$MNU_NEWGAME", "m", "MultiMenu" // In EDuke this replaces "New Game" when in networking mode. Kept here as a reminder. //NativeTextItem "$MNU_NEWGAME", "m", "MultiMenu" // In EDuke this replaces "New Game" when in networking mode. Kept here as a reminder.
ifgame(fury) NativeTextItem "$MNU_LOADGAME", "l", "LoadGameMenu"
{
NativeTextItem "$MNU_CONTINUE", "l", "LoadGameMenu"
}
else
{
NativeTextItem "$MNU_LOADGAME", "l", "LoadGameMenu"
}
NativeTextItem "$MNU_OPTIONS", "o", "OptionsMenu" NativeTextItem "$MNU_OPTIONS", "o", "OptionsMenu"
NativeTextItem "$MNU_HELP", "h", "HelpMenu" NativeTextItem "$MNU_HELP", "h", "HelpMenu"
NativeTextItem "$MNU_CREDITS", "c", "CreditsMenu" NativeTextItem "$MNU_CREDITS", "c", "CreditsMenu"
NativeTextItem "$MNU_QUITGAME", "q", "QuitMenu" NativeTextItem "$MNU_QUITGAME", "q", "QuitMenu"
} }
ifgame(Deer)
{
position 160, 72, 115
centermenu
animatedtransition
NativeTextItem "Go Huntin'!", "g", "HuntMenu"
NativeTextItem "Target Range", "r", "TargetMenu"
NativeTextItem "Trophies", "t", "TrophiesMenu"
NativeTextItem "$MNU_OPTIONS", "o", "OptionsMenu"
NativeTextItem "$MNU_HELP", "h", "HelpMenu"
NativeTextItem "$MNU_QUITGAME", "q", "QuitMenu"
}
ifgame(Blood) ifgame(Blood)
{ {
position 160, 45, 150 position 160, 45, 150