- everything compiles again, now to make it work again with all menu widgets 100% scripted.

This commit is contained in:
Christoph Oelckers 2017-02-12 01:18:49 +01:00
commit ee1217c8c7
10 changed files with 636 additions and 1525 deletions

View file

@ -279,308 +279,3 @@ void DListMenu::Drawer ()
//
//=============================================================================
IMPLEMENT_CLASS(DMenuItemBase, true, false)
bool DMenuItemBase::CheckCoordinate(int x, int y)
{
return false;
}
void DMenuItemBase::Ticker()
{
}
void DMenuItemBase::Drawer(bool selected)
{
}
bool DMenuItemBase::Selectable()
{
return false;
}
void DMenuItemBase::DrawSelector(int xofs, int yofs, FTextureID tex)
{
if (tex.isNull())
{
if ((DMenu::MenuTime%8) < 6)
{
screen->DrawText(ConFont, OptionSettings.mFontColorSelection,
(mXpos + xofs - 160) * CleanXfac + screen->GetWidth() / 2,
(mYpos + yofs - 100) * CleanYfac + screen->GetHeight() / 2,
"\xd",
DTA_CellX, 8 * CleanXfac,
DTA_CellY, 8 * CleanYfac,
TAG_DONE);
}
}
else
{
screen->DrawTexture (TexMan(tex), mXpos + xofs, mYpos + yofs, DTA_Clean, true, TAG_DONE);
}
}
bool DMenuItemBase::Activate()
{
return false; // cannot be activated
}
FName DMenuItemBase::GetAction(int *pparam)
{
return mAction;
}
bool DMenuItemBase::SetString(int i, const char *s)
{
return false;
}
bool DMenuItemBase::GetString(int i, char *s, int len)
{
return false;
}
bool DMenuItemBase::SetValue(int i, int value)
{
return false;
}
bool DMenuItemBase::GetValue(int i, int *pvalue)
{
return false;
}
void DMenuItemBase::Enable(bool on)
{
mEnabled = on;
}
bool DMenuItemBase::MenuEvent(int mkey, bool fromcontroller)
{
return false;
}
DEFINE_ACTION_FUNCTION(DMenuItemBase, MenuEvent)
{
PARAM_SELF_PROLOGUE(DMenuItemBase);
PARAM_INT(key);
PARAM_BOOL(fromcontroller);
ACTION_RETURN_BOOL(self->MenuEvent(key, fromcontroller));
}
bool DMenuItemBase::MouseEvent(int type, int x, int y)
{
return false;
}
bool DMenuItemBase::CheckHotkey(int c)
{
return false;
}
int DMenuItemBase::GetWidth()
{
return 0;
}
//=============================================================================
//
// static patch
//
//=============================================================================
IMPLEMENT_CLASS(DListMenuItemStaticPatch_, false, false)
DListMenuItemStaticPatch_::DListMenuItemStaticPatch_(int x, int y, FTextureID patch, bool centered)
: DMenuItemBase(x, y)
{
mTexture = patch;
mCentered = centered;
}
void DListMenuItemStaticPatch_::Drawer(bool selected)
{
if (!mTexture.Exists())
{
return;
}
int x = mXpos;
FTexture *tex = TexMan(mTexture);
if (mYpos >= 0)
{
if (mCentered) x -= tex->GetScaledWidth()/2;
screen->DrawTexture (tex, x, mYpos, DTA_Clean, true, TAG_DONE);
}
else
{
int x = (mXpos - 160) * CleanXfac + (SCREENWIDTH>>1);
if (mCentered) x -= (tex->GetScaledWidth()*CleanXfac)/2;
screen->DrawTexture (tex, x, -mYpos*CleanYfac, DTA_CleanNoMove, true, TAG_DONE);
}
}
//=============================================================================
//
// static text
//
//=============================================================================
IMPLEMENT_CLASS(DListMenuItemStaticText_, false, false)
DListMenuItemStaticText_::DListMenuItemStaticText_(int x, int y, const char *text, FFont *font, EColorRange color, bool centered)
: DMenuItemBase(x, y)
{
mText = text;
mFont = font;
mColor = color;
mCentered = centered;
}
void DListMenuItemStaticText_::Drawer(bool selected)
{
if (mText.IsNotEmpty())
{
const char *text = mText;
if (*text == '$') text = GStrings(text+1);
if (mYpos >= 0)
{
int x = mXpos;
if (mCentered) x -= mFont->StringWidth(text)/2;
screen->DrawText(mFont, mColor, x, mYpos, text, DTA_Clean, true, TAG_DONE);
}
else
{
int x = (mXpos - 160) * CleanXfac + (SCREENWIDTH>>1);
if (mCentered) x -= (mFont->StringWidth(text)*CleanXfac)/2;
screen->DrawText (mFont, mColor, x, -mYpos*CleanYfac, text, DTA_CleanNoMove, true, TAG_DONE);
}
}
}
//=============================================================================
//
// base class for selectable items
//
//=============================================================================
IMPLEMENT_CLASS(DListMenuItemSelectable_, false, false)
DListMenuItemSelectable_::DListMenuItemSelectable_(int x, int y, int height, FName action, int param)
: DMenuItemBase(x, y, action)
{
mHeight = height;
mParam = param;
mHotkey = 0;
}
bool DListMenuItemSelectable_::CheckCoordinate(int x, int y)
{
return mEnabled && y >= mYpos && y < mYpos + mHeight; // no x check here
}
bool DListMenuItemSelectable_::Selectable()
{
return mEnabled;
}
bool DListMenuItemSelectable_::Activate()
{
M_SetMenu(mAction, mParam);
return true;
}
FName DListMenuItemSelectable_::GetAction(int *pparam)
{
if (pparam != NULL) *pparam = mParam;
return mAction;
}
bool DListMenuItemSelectable_::CheckHotkey(int c)
{
return c == tolower(mHotkey);
}
bool DListMenuItemSelectable_::MouseEvent(int type, int x, int y)
{
if (type == DMenu::MOUSE_Release)
{
if (NULL != DMenu::CurrentMenu && DMenu::CurrentMenu->MenuEvent(MKEY_Enter, true))
{
return true;
}
}
return false;
}
//=============================================================================
//
// text item
//
//=============================================================================
IMPLEMENT_CLASS(DListMenuItemText_, false, false)
DListMenuItemText_::DListMenuItemText_(int x, int y, int height, int hotkey, const char *text, FFont *font, EColorRange color, EColorRange color2, FName child, int param)
: DListMenuItemSelectable_(x, y, height, child, param)
{
mText = ncopystring(text);
mFont = font;
mColor = color;
mColorSelected = color2;
mHotkey = hotkey;
}
void DListMenuItemText_::OnDestroy()
{
if (mText != NULL)
{
delete [] mText;
}
}
void DListMenuItemText_::Drawer(bool selected)
{
const char *text = mText;
if (text != NULL)
{
if (*text == '$') text = GStrings(text+1);
screen->DrawText(mFont, selected ? mColorSelected : mColor, mXpos, mYpos, text, DTA_Clean, true, TAG_DONE);
}
}
int DListMenuItemText_::GetWidth()
{
const char *text = mText;
if (text != NULL)
{
if (*text == '$') text = GStrings(text+1);
return mFont->StringWidth(text);
}
return 1;
}
//=============================================================================
//
// patch item
//
//=============================================================================
IMPLEMENT_CLASS(DListMenuItemPatch_, false, false)
DListMenuItemPatch_::DListMenuItemPatch_(int x, int y, int height, int hotkey, FTextureID patch, FName child, int param)
: DListMenuItemSelectable_(x, y, height, child, param)
{
mHotkey = hotkey;
mTexture = patch;
}
void DListMenuItemPatch_::Drawer(bool selected)
{
screen->DrawTexture (TexMan(mTexture), mXpos, mYpos, DTA_Clean, true, TAG_DONE);
}
int DListMenuItemPatch_::GetWidth()
{
return mTexture.isValid()
? TexMan[mTexture]->GetScaledWidth()
: 0;
}