mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-05-31 00:51:21 +00:00
- everything compiles again, now to make it work again with all menu widgets 100% scripted.
This commit is contained in:
parent
2a5b26c27c
commit
ee1217c8c7
10 changed files with 640 additions and 1529 deletions
|
@ -279,308 +279,3 @@ void DListMenu::Drawer ()
|
||||||
//
|
//
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
IMPLEMENT_CLASS(DMenuItemBase, true, false)
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1150,16 +1150,377 @@ DEFINE_FIELD(FOptionMenuSettings, mLinespacing)
|
||||||
|
|
||||||
|
|
||||||
struct IJoystickConfig;
|
struct IJoystickConfig;
|
||||||
DMenuItemBase * CreateOptionMenuItemStaticText(const char *name, bool v);
|
DMenuItemBase * CreateOptionMenuItemStaticText(const char *name, bool v)
|
||||||
DMenuItemBase * CreateOptionMenuSliderVar(const char *name, int index, double min, double max, double step, int showval);
|
{
|
||||||
DMenuItemBase * CreateOptionMenuItemCommand(const char * label, FName cmd);
|
auto c = PClass::FindClass("OptionMenuItemStaticText");
|
||||||
DMenuItemBase * CreateOptionMenuItemOption(const char * label, FName cmd, FName values, FBaseCVar *graycheck, bool center);
|
auto p = c->CreateNew();
|
||||||
DMenuItemBase * CreateOptionMenuItemJoyConfigMenu(const char *label, IJoystickConfig *joy);
|
VMValue params[] = { p, FString(name), v };
|
||||||
DMenuItemBase * CreateOptionMenuItemJoyMap(const char *label, int axis, FName values, bool center);
|
auto f = dyn_cast<PFunction>(c->Symbols.FindSymbol("Init", false));
|
||||||
DMenuItemBase * CreateOptionMenuSliderJoySensitivity(const char * label, double min, double max, double step, int showval);
|
GlobalVMStack.Call(f->Variants[0].Implementation, params, countof(params), nullptr, 0);
|
||||||
DMenuItemBase * CreateOptionMenuSliderJoyScale(const char *label, int axis, double min, double max, double step, int showval);
|
return (DMenuItemBase*)p;
|
||||||
DMenuItemBase * CreateOptionMenuItemInverter(const char *label, int axis, int center);
|
}
|
||||||
DMenuItemBase * CreateOptionMenuSliderJoyDeadZone(const char *label, int axis, double min, double max, double step, int showval);
|
|
||||||
|
DMenuItemBase * CreateOptionMenuSliderVar(const char *name, int index, double min, double max, double step, int showval)
|
||||||
|
{
|
||||||
|
auto c = PClass::FindClass("OptionMenuItemSliderVar");
|
||||||
|
auto p = c->CreateNew();
|
||||||
|
VMValue params[] = { p, FString(name), index, min, max, step, showval };
|
||||||
|
auto f = dyn_cast<PFunction>(c->Symbols.FindSymbol("Init", false));
|
||||||
|
GlobalVMStack.Call(f->Variants[0].Implementation, params, countof(params), nullptr, 0);
|
||||||
|
return (DMenuItemBase*)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
DMenuItemBase * CreateOptionMenuItemCommand(const char * label, FName cmd)
|
||||||
|
{
|
||||||
|
auto c = PClass::FindClass("OptionMenuItemCommand");
|
||||||
|
auto p = c->CreateNew();
|
||||||
|
VMValue params[] = { p, FString(label), cmd.GetIndex() };
|
||||||
|
auto f = dyn_cast<PFunction>(c->Symbols.FindSymbol("Init", false));
|
||||||
|
GlobalVMStack.Call(f->Variants[0].Implementation, params, countof(params), nullptr, 0);
|
||||||
|
return (DMenuItemBase*)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
DMenuItemBase * CreateOptionMenuItemOption(const char * label, FName cmd, FName values, FBaseCVar *graycheck, bool center)
|
||||||
|
{
|
||||||
|
auto c = PClass::FindClass("OptionMenuItemOption");
|
||||||
|
auto p = c->CreateNew();
|
||||||
|
VMValue params[] = { p, FString(label), cmd.GetIndex(), values.GetIndex(), graycheck, center };
|
||||||
|
auto f = dyn_cast<PFunction>(c->Symbols.FindSymbol("Init", false));
|
||||||
|
GlobalVMStack.Call(f->Variants[0].Implementation, params, countof(params), nullptr, 0);
|
||||||
|
return (DMenuItemBase*)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
DMenuItemBase * CreateOptionMenuItemJoyConfigMenu(const char *label, IJoystickConfig *joy)
|
||||||
|
{
|
||||||
|
auto c = PClass::FindClass("OptionMenuItemJoyConfigMenu");
|
||||||
|
auto p = c->CreateNew();
|
||||||
|
VMValue params[] = { p, FString(label), joy };
|
||||||
|
auto f = dyn_cast<PFunction>(c->Symbols.FindSymbol("Init", false));
|
||||||
|
GlobalVMStack.Call(f->Variants[0].Implementation, params, countof(params), nullptr, 0);
|
||||||
|
return (DMenuItemBase*)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
DMenuItemBase * CreateOptionMenuItemJoyMap(const char *label, int axis, FName values, bool center)
|
||||||
|
{
|
||||||
|
auto c = PClass::FindClass("OptionMenuItemJoyMap");
|
||||||
|
auto p = c->CreateNew();
|
||||||
|
VMValue params[] = { p, FString(label), axis, values.GetIndex(), center };
|
||||||
|
auto f = dyn_cast<PFunction>(c->Symbols.FindSymbol("Init", false));
|
||||||
|
GlobalVMStack.Call(f->Variants[0].Implementation, params, countof(params), nullptr, 0);
|
||||||
|
return (DMenuItemBase*)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
DMenuItemBase * CreateOptionMenuSliderJoySensitivity(const char * label, double min, double max, double step, int showval)
|
||||||
|
{
|
||||||
|
auto c = PClass::FindClass("OptionMenuSliderJoySensitivity");
|
||||||
|
auto p = c->CreateNew();
|
||||||
|
VMValue params[] = { p, FString(label), min, max, step, showval };
|
||||||
|
auto f = dyn_cast<PFunction>(c->Symbols.FindSymbol("Init", false));
|
||||||
|
GlobalVMStack.Call(f->Variants[0].Implementation, params, countof(params), nullptr, 0);
|
||||||
|
return (DMenuItemBase*)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
DMenuItemBase * CreateOptionMenuSliderJoyScale(const char *label, int axis, double min, double max, double step, int showval)
|
||||||
|
{
|
||||||
|
auto c = PClass::FindClass("OptionMenuSliderJoyScale");
|
||||||
|
auto p = c->CreateNew();
|
||||||
|
VMValue params[] = { p, FString(label), min, max, step, showval };
|
||||||
|
auto f = dyn_cast<PFunction>(c->Symbols.FindSymbol("Init", false));
|
||||||
|
GlobalVMStack.Call(f->Variants[0].Implementation, params, countof(params), nullptr, 0);
|
||||||
|
return (DMenuItemBase*)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
DMenuItemBase * CreateOptionMenuItemInverter(const char *label, int axis, int center)
|
||||||
|
{
|
||||||
|
auto c = PClass::FindClass("OptionMenuItemInverter");
|
||||||
|
auto p = c->CreateNew();
|
||||||
|
VMValue params[] = { p, FString(label), axis, center };
|
||||||
|
auto f = dyn_cast<PFunction>(c->Symbols.FindSymbol("Init", false));
|
||||||
|
GlobalVMStack.Call(f->Variants[0].Implementation, params, countof(params), nullptr, 0);
|
||||||
|
return (DMenuItemBase*)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
DMenuItemBase * CreateOptionMenuSliderJoyDeadZone(const char *label, int axis, double min, double max, double step, int showval)
|
||||||
|
{
|
||||||
|
auto c = PClass::FindClass("OptionMenuSliderJoyDeadZone");
|
||||||
|
auto p = c->CreateNew();
|
||||||
|
VMValue params[] = { p, FString(label), min, max, step, showval };
|
||||||
|
auto f = dyn_cast<PFunction>(c->Symbols.FindSymbol("Init", false));
|
||||||
|
GlobalVMStack.Call(f->Variants[0].Implementation, params, countof(params), nullptr, 0);
|
||||||
|
return (DMenuItemBase*)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
DMenuItemBase * CreateOptionMenuItemSubmenu(const char *label, FName cmd, int center)
|
||||||
|
{
|
||||||
|
auto c = PClass::FindClass("OptionMenuItemSubmenu");
|
||||||
|
auto p = c->CreateNew();
|
||||||
|
VMValue params[] = { p, FString(label), cmd.GetIndex(), center };
|
||||||
|
auto f = dyn_cast<PFunction>(c->Symbols.FindSymbol("Init", false));
|
||||||
|
GlobalVMStack.Call(f->Variants[0].Implementation, params, countof(params), nullptr, 0);
|
||||||
|
return (DMenuItemBase*)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
DMenuItemBase * CreateOptionMenuItemControl(const char *label, FName cmd, FKeyBindings *bindings)
|
||||||
|
{
|
||||||
|
auto c = PClass::FindClass("OptionMenuItemControl");
|
||||||
|
auto p = c->CreateNew();
|
||||||
|
VMValue params[] = { p, FString(label), cmd.GetIndex(), bindings };
|
||||||
|
auto f = dyn_cast<PFunction>(c->Symbols.FindSymbol("Init", false));
|
||||||
|
GlobalVMStack.Call(f->Variants[0].Implementation, params, countof(params), nullptr, 0);
|
||||||
|
return (DMenuItemBase*)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
DMenuItemBase * CreateListMenuItemPatch(int x, int y, int height, int hotkey, FTextureID tex, FName command, int param)
|
||||||
|
{
|
||||||
|
auto c = PClass::FindClass("ListMenuItemPatch");
|
||||||
|
auto p = c->CreateNew();
|
||||||
|
VMValue params[] = { p, x, y, height, tex.GetIndex(), 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
DMenuItemBase * CreateListMenuItemText(int x, int y, int height, int hotkey, const char *text, FFont *font, PalEntry color1, PalEntry color2, FName command, int param)
|
||||||
|
{
|
||||||
|
auto c = PClass::FindClass("ListMenuItemText");
|
||||||
|
auto p = c->CreateNew();
|
||||||
|
VMValue params[] = { p, x, y, height, 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DMenuItemBase::CheckCoordinate(int x, int y)
|
||||||
|
{
|
||||||
|
IFVIRTUAL(DMenuItemBase, CheckCoordinate)
|
||||||
|
{
|
||||||
|
VMValue params[] = { (DObject*)this, x, y };
|
||||||
|
int retval;
|
||||||
|
VMReturn ret(&retval);
|
||||||
|
GlobalVMStack.Call(func, params, countof(params), &ret, 1, nullptr);
|
||||||
|
return !!retval;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DMenuItemBase::Ticker()
|
||||||
|
{
|
||||||
|
IFVIRTUAL(DMenuItemBase, Ticker)
|
||||||
|
{
|
||||||
|
VMValue params[] = { (DObject*)this };
|
||||||
|
GlobalVMStack.Call(func, params, countof(params), nullptr, 0, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DMenuItemBase::Drawer(bool selected)
|
||||||
|
{
|
||||||
|
IFVIRTUAL(DMenuItemBase, Ticker)
|
||||||
|
{
|
||||||
|
VMValue params[] = { (DObject*)this, selected };
|
||||||
|
GlobalVMStack.Call(func, params, countof(params), nullptr, 0, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DMenuItemBase::Selectable()
|
||||||
|
{
|
||||||
|
IFVIRTUAL(DMenuItemBase, Selectable)
|
||||||
|
{
|
||||||
|
VMValue params[] = { (DObject*)this };
|
||||||
|
int retval;
|
||||||
|
VMReturn ret(&retval);
|
||||||
|
GlobalVMStack.Call(func, params, countof(params), &ret, 1, nullptr);
|
||||||
|
return !!retval;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DMenuItemBase::Activate()
|
||||||
|
{
|
||||||
|
IFVIRTUAL(DMenuItemBase, Activate)
|
||||||
|
{
|
||||||
|
VMValue params[] = { (DObject*)this };
|
||||||
|
int retval;
|
||||||
|
VMReturn ret(&retval);
|
||||||
|
GlobalVMStack.Call(func, params, countof(params), &ret, 1, nullptr);
|
||||||
|
return !!retval;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
FName DMenuItemBase::GetAction(int *pparam)
|
||||||
|
{
|
||||||
|
IFVIRTUAL(DMenuItemBase, GetAction)
|
||||||
|
{
|
||||||
|
VMValue params[] = { (DObject*)this };
|
||||||
|
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 NAME_None;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DMenuItemBase::SetString(int i, const char *s)
|
||||||
|
{
|
||||||
|
IFVIRTUAL(DMenuItemBase, SetString)
|
||||||
|
{
|
||||||
|
VMValue params[] = { (DObject*)this, i, FString(s) };
|
||||||
|
int retval;
|
||||||
|
VMReturn ret(&retval);
|
||||||
|
GlobalVMStack.Call(func, params, countof(params), &ret, 1, nullptr);
|
||||||
|
return !!retval;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DMenuItemBase::GetString(int i, char *s, int len)
|
||||||
|
{
|
||||||
|
IFVIRTUAL(DMenuItemBase, GetString)
|
||||||
|
{
|
||||||
|
VMValue params[] = { (DObject*)this, i };
|
||||||
|
int retval;
|
||||||
|
FString retstr;
|
||||||
|
VMReturn ret[2]; ret[0].IntAt(&retval); ret[1].StringAt(&retstr);
|
||||||
|
GlobalVMStack.Call(func, params, countof(params), ret, 2, nullptr);
|
||||||
|
strncpy(s, retstr, len);
|
||||||
|
return !!retval;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool DMenuItemBase::SetValue(int i, int value)
|
||||||
|
{
|
||||||
|
IFVIRTUAL(DMenuItemBase, SetValue)
|
||||||
|
{
|
||||||
|
VMValue params[] = { (DObject*)this, i, value };
|
||||||
|
int retval;
|
||||||
|
VMReturn ret(&retval);
|
||||||
|
GlobalVMStack.Call(func, params, countof(params), &ret, 1, nullptr);
|
||||||
|
return !!retval;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DMenuItemBase::GetValue(int i, int *pvalue)
|
||||||
|
{
|
||||||
|
IFVIRTUAL(DMenuItemBase, GetValue)
|
||||||
|
{
|
||||||
|
VMValue params[] = { (DObject*)this };
|
||||||
|
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);
|
||||||
|
*pvalue = retval[1];
|
||||||
|
return !!retval[0];
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DMenuItemBase::Enable(bool on)
|
||||||
|
{
|
||||||
|
IFVIRTUAL(DMenuItemBase, Enable)
|
||||||
|
{
|
||||||
|
VMValue params[] = { (DObject*)this, on };
|
||||||
|
GlobalVMStack.Call(func, params, countof(params), nullptr, 0, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DMenuItemBase::MenuEvent(int mkey, bool fromcontroller)
|
||||||
|
{
|
||||||
|
IFVIRTUAL(DMenuItemBase, MenuEvent)
|
||||||
|
{
|
||||||
|
VMValue params[] = { (DObject*)this, mkey, fromcontroller };
|
||||||
|
int retval;
|
||||||
|
VMReturn ret(&retval);
|
||||||
|
GlobalVMStack.Call(func, params, countof(params), &ret, 1, nullptr);
|
||||||
|
return !!retval;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DMenuItemBase::MouseEvent(int type, int x, int y)
|
||||||
|
{
|
||||||
|
IFVIRTUAL(DMenuItemBase, MouseEvent)
|
||||||
|
{
|
||||||
|
VMValue params[] = { (DObject*)this, x, y };
|
||||||
|
int retval;
|
||||||
|
VMReturn ret(&retval);
|
||||||
|
GlobalVMStack.Call(func, params, countof(params), &ret, 1, nullptr);
|
||||||
|
return !!retval;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DMenuItemBase::CheckHotkey(int c)
|
||||||
|
{
|
||||||
|
IFVIRTUAL(DMenuItemBase, CheckHotkey)
|
||||||
|
{
|
||||||
|
VMValue params[] = { (DObject*)this, c };
|
||||||
|
int retval;
|
||||||
|
VMReturn ret(&retval);
|
||||||
|
GlobalVMStack.Call(func, params, countof(params), &ret, 1, nullptr);
|
||||||
|
return !!retval;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DMenuItemBase::GetWidth()
|
||||||
|
{
|
||||||
|
IFVIRTUAL(DMenuItemBase, GetWidth)
|
||||||
|
{
|
||||||
|
VMValue params[] = { (DObject*)this };
|
||||||
|
int retval;
|
||||||
|
VMReturn ret(&retval);
|
||||||
|
GlobalVMStack.Call(func, params, countof(params), &ret, 1, nullptr);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DMenuItemBase::GetIndent()
|
||||||
|
{
|
||||||
|
IFVIRTUAL(DMenuItemBase, GetIndent)
|
||||||
|
{
|
||||||
|
VMValue params[] = { (DObject*)this };
|
||||||
|
int retval;
|
||||||
|
VMReturn ret(&retval);
|
||||||
|
GlobalVMStack.Call(func, params, countof(params), &ret, 1, nullptr);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DMenuItemBase::Draw(DOptionMenuDescriptor *desc, int y, int indent, bool selected)
|
||||||
|
{
|
||||||
|
IFVIRTUAL(DMenuItemBase, Draw)
|
||||||
|
{
|
||||||
|
VMValue params[] = { (DObject*)this, desc, y, indent, selected };
|
||||||
|
int retval;
|
||||||
|
VMReturn ret(&retval);
|
||||||
|
GlobalVMStack.Call(func, params, countof(params), &ret, 1, nullptr);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DMenuItemBase * CreateOptionMenuItemSubmenu(const char *label, FName cmd, int center);
|
|
||||||
DMenuItemBase * CreateOptionMenuItemControl(const char *label, FName cmd, FKeyBindings *bindings);
|
|
||||||
|
|
296
src/menu/menu.h
296
src/menu/menu.h
|
@ -302,259 +302,35 @@ class DMenuItemBase : public DObject
|
||||||
DECLARE_CLASS(DMenuItemBase, DObject)
|
DECLARE_CLASS(DMenuItemBase, DObject)
|
||||||
public:
|
public:
|
||||||
int mXpos, mYpos;
|
int mXpos, mYpos;
|
||||||
FName mAction;
|
FNameNoInit mAction;
|
||||||
|
|
||||||
bool mEnabled;
|
bool mEnabled;
|
||||||
|
|
||||||
DMenuItemBase(int xpos = 0, int ypos = 0, FName action = NAME_None)
|
bool CheckCoordinate(int x, int y);
|
||||||
{
|
void Ticker();
|
||||||
mXpos = xpos;
|
void Drawer(bool selected);
|
||||||
mYpos = ypos;
|
bool Selectable();
|
||||||
mAction = action;
|
bool Activate();
|
||||||
mEnabled = true;
|
FName GetAction(int *pparam);
|
||||||
}
|
bool SetString(int i, const char *s);
|
||||||
|
bool GetString(int i, char *s, int len);
|
||||||
virtual bool CheckCoordinate(int x, int y);
|
bool SetValue(int i, int value);
|
||||||
virtual void Ticker();
|
bool GetValue(int i, int *pvalue);
|
||||||
virtual void Drawer(bool selected);
|
void Enable(bool on);
|
||||||
virtual bool Selectable();
|
bool MenuEvent (int mkey, bool fromcontroller);
|
||||||
virtual bool Activate();
|
bool MouseEvent(int type, int x, int y);
|
||||||
virtual FName GetAction(int *pparam);
|
bool CheckHotkey(int c);
|
||||||
virtual bool SetString(int i, const char *s);
|
int GetWidth();
|
||||||
virtual bool GetString(int i, char *s, int len);
|
int GetIndent();
|
||||||
virtual bool SetValue(int i, int value);
|
int Draw(DOptionMenuDescriptor *desc, int y, int indent, bool selected);
|
||||||
virtual bool GetValue(int i, int *pvalue);
|
|
||||||
virtual void Enable(bool on);
|
|
||||||
virtual bool MenuEvent (int mkey, bool fromcontroller);
|
|
||||||
virtual bool MouseEvent(int type, int x, int y);
|
|
||||||
virtual bool CheckHotkey(int c);
|
|
||||||
virtual int GetWidth();
|
|
||||||
virtual int GetIndent() { return 0; }
|
|
||||||
virtual int Draw(DOptionMenuDescriptor *desc, int y, int indent, bool selected) { return indent; }
|
|
||||||
void DrawSelector(int xofs, int yofs, FTextureID tex);
|
|
||||||
void OffsetPositionY(int ydelta) { mYpos += ydelta; }
|
void OffsetPositionY(int ydelta) { mYpos += ydelta; }
|
||||||
int GetY() { return mYpos; }
|
int GetY() { return mYpos; }
|
||||||
int GetX() { return mXpos; }
|
int GetX() { return mXpos; }
|
||||||
void SetX(int x) { mXpos = x; }
|
void SetX(int x) { mXpos = x; }
|
||||||
|
|
||||||
|
void DrawSelector(int xofs, int yofs, FTextureID tex);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DListMenuItemStaticPatch_ : public DMenuItemBase
|
|
||||||
{
|
|
||||||
DECLARE_CLASS(DListMenuItemStaticPatch_, DMenuItemBase)
|
|
||||||
protected:
|
|
||||||
FTextureID mTexture;
|
|
||||||
bool mCentered;
|
|
||||||
|
|
||||||
DListMenuItemStaticPatch_() {}
|
|
||||||
public:
|
|
||||||
DListMenuItemStaticPatch_(int x, int y, FTextureID patch, bool centered);
|
|
||||||
void Drawer(bool selected);
|
|
||||||
};
|
|
||||||
|
|
||||||
class DListMenuItemStaticText_ : public DMenuItemBase
|
|
||||||
{
|
|
||||||
DECLARE_CLASS(DListMenuItemStaticText_, DMenuItemBase)
|
|
||||||
protected:
|
|
||||||
FString mText;
|
|
||||||
FFont *mFont;
|
|
||||||
EColorRange mColor;
|
|
||||||
bool mCentered;
|
|
||||||
|
|
||||||
DListMenuItemStaticText_() {}
|
|
||||||
public:
|
|
||||||
DListMenuItemStaticText_(int x, int y, const char *text, FFont *font, EColorRange color, bool centered);
|
|
||||||
void Drawer(bool selected);
|
|
||||||
};
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
// the player sprite window
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
class DListMenuItemPlayerDisplay_ : public DMenuItemBase
|
|
||||||
{
|
|
||||||
DECLARE_CLASS(DListMenuItemPlayerDisplay_, DMenuItemBase)
|
|
||||||
|
|
||||||
DListMenuDescriptor *mOwner;
|
|
||||||
FTexture *mBackdrop;
|
|
||||||
FRemapTable mRemap;
|
|
||||||
FPlayerClass *mPlayerClass;
|
|
||||||
FState *mPlayerState;
|
|
||||||
int mPlayerTics;
|
|
||||||
bool mNoportrait;
|
|
||||||
BYTE mRotation;
|
|
||||||
BYTE mMode; // 0: automatic (used by class selection), 1: manual (used by player setup)
|
|
||||||
BYTE mTranslate;
|
|
||||||
int mSkin;
|
|
||||||
int mRandomClass;
|
|
||||||
int mRandomTimer;
|
|
||||||
int mClassNum;
|
|
||||||
|
|
||||||
void SetPlayerClass(int classnum, bool force = false);
|
|
||||||
bool UpdatePlayerClass();
|
|
||||||
void UpdateRandomClass();
|
|
||||||
void UpdateTranslation();
|
|
||||||
|
|
||||||
DListMenuItemPlayerDisplay_() {}
|
|
||||||
public:
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
PDF_ROTATION = 0x10001,
|
|
||||||
PDF_SKIN = 0x10002,
|
|
||||||
PDF_CLASS = 0x10003,
|
|
||||||
PDF_MODE = 0x10004,
|
|
||||||
PDF_TRANSLATE = 0x10005,
|
|
||||||
};
|
|
||||||
|
|
||||||
DListMenuItemPlayerDisplay_(DListMenuDescriptor *menu, int x, int y, PalEntry c1, PalEntry c2, bool np, FName action);
|
|
||||||
void OnDestroy() override;
|
|
||||||
virtual void Ticker();
|
|
||||||
virtual void Drawer(bool selected);
|
|
||||||
bool SetValue(int i, int value);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
// selectable items
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
class DListMenuItemSelectable_ : public DMenuItemBase
|
|
||||||
{
|
|
||||||
DECLARE_CLASS(DListMenuItemSelectable_, DMenuItemBase)
|
|
||||||
protected:
|
|
||||||
int mHotkey;
|
|
||||||
int mHeight;
|
|
||||||
int mParam;
|
|
||||||
|
|
||||||
DListMenuItemSelectable_() {}
|
|
||||||
public:
|
|
||||||
DListMenuItemSelectable_(int x, int y, int height, FName childmenu, int mParam = -1);
|
|
||||||
bool CheckCoordinate(int x, int y);
|
|
||||||
bool Selectable();
|
|
||||||
bool CheckHotkey(int c);
|
|
||||||
bool Activate();
|
|
||||||
bool MouseEvent(int type, int x, int y);
|
|
||||||
FName GetAction(int *pparam);
|
|
||||||
};
|
|
||||||
|
|
||||||
class DListMenuItemText_ : public DListMenuItemSelectable_
|
|
||||||
{
|
|
||||||
DECLARE_CLASS(DListMenuItemText_, DListMenuItemSelectable_)
|
|
||||||
const char *mText;
|
|
||||||
FFont *mFont;
|
|
||||||
EColorRange mColor;
|
|
||||||
EColorRange mColorSelected;
|
|
||||||
|
|
||||||
DListMenuItemText_() {}
|
|
||||||
public:
|
|
||||||
DListMenuItemText_(int x, int y, int height, int hotkey, const char *text, FFont *font, EColorRange color, EColorRange color2, FName child, int param = 0);
|
|
||||||
void OnDestroy() override;
|
|
||||||
void Drawer(bool selected);
|
|
||||||
int GetWidth();
|
|
||||||
};
|
|
||||||
|
|
||||||
class DListMenuItemPatch_ : public DListMenuItemSelectable_
|
|
||||||
{
|
|
||||||
DECLARE_CLASS(DListMenuItemPatch_, DListMenuItemSelectable_)
|
|
||||||
FTextureID mTexture;
|
|
||||||
|
|
||||||
DListMenuItemPatch_() {}
|
|
||||||
public:
|
|
||||||
DListMenuItemPatch_(int x, int y, int height, int hotkey, FTextureID patch, FName child, int param = 0);
|
|
||||||
void Drawer(bool selected);
|
|
||||||
int GetWidth();
|
|
||||||
};
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
// items for the player menu
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
class DPlayerNameBox_ : public DListMenuItemSelectable_
|
|
||||||
{
|
|
||||||
DECLARE_CLASS(DPlayerNameBox_, DListMenuItemSelectable_)
|
|
||||||
FString mText;
|
|
||||||
FFont *mFont;
|
|
||||||
EColorRange mFontColor;
|
|
||||||
int mFrameSize;
|
|
||||||
char mPlayerName[MAXPLAYERNAME+1];
|
|
||||||
char mEditName[MAXPLAYERNAME+2];
|
|
||||||
bool mEntering;
|
|
||||||
|
|
||||||
void DrawBorder (int x, int y, int len);
|
|
||||||
|
|
||||||
DPlayerNameBox_() {}
|
|
||||||
public:
|
|
||||||
|
|
||||||
DPlayerNameBox_(int x, int y, int height, int frameofs, const char *text, FFont *font, EColorRange color, FName action);
|
|
||||||
bool SetString(int i, const char *s);
|
|
||||||
bool GetString(int i, char *s, int len);
|
|
||||||
void Drawer(bool selected);
|
|
||||||
bool MenuEvent (int mkey, bool fromcontroller);
|
|
||||||
};
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
// items for the player menu
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
class DValueTextItem_ : public DListMenuItemSelectable_
|
|
||||||
{
|
|
||||||
DECLARE_CLASS(DValueTextItem_, DListMenuItemSelectable_)
|
|
||||||
TArray<FString> mSelections;
|
|
||||||
FString mText;
|
|
||||||
int mSelection;
|
|
||||||
FFont *mFont;
|
|
||||||
EColorRange mFontColor;
|
|
||||||
EColorRange mFontColor2;
|
|
||||||
|
|
||||||
DValueTextItem_() {}
|
|
||||||
public:
|
|
||||||
|
|
||||||
DValueTextItem_(int x, int y, int height, const char *text, FFont *font, EColorRange color, EColorRange valuecolor, FName action, FName values);
|
|
||||||
bool SetString(int i, const char *s);
|
|
||||||
bool SetValue(int i, int value);
|
|
||||||
bool GetValue(int i, int *pvalue);
|
|
||||||
bool MenuEvent (int mkey, bool fromcontroller);
|
|
||||||
void Drawer(bool selected);
|
|
||||||
};
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
// items for the player menu
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
class DSliderItem_ : public DListMenuItemSelectable_
|
|
||||||
{
|
|
||||||
DECLARE_CLASS(DSliderItem_, DListMenuItemSelectable_)
|
|
||||||
FString mText;
|
|
||||||
FFont *mFont;
|
|
||||||
EColorRange mFontColor;
|
|
||||||
int mMinrange, mMaxrange;
|
|
||||||
int mStep;
|
|
||||||
int mSelection;
|
|
||||||
|
|
||||||
void DrawSlider (int x, int y);
|
|
||||||
|
|
||||||
DSliderItem_() {}
|
|
||||||
public:
|
|
||||||
|
|
||||||
DSliderItem_(int x, int y, int height, const char *text, FFont *font, EColorRange color, FName action, int min, int max, int step);
|
|
||||||
bool SetValue(int i, int value);
|
|
||||||
bool GetValue(int i, int *pvalue);
|
|
||||||
bool MenuEvent (int mkey, bool fromcontroller);
|
|
||||||
void Drawer(bool selected);
|
|
||||||
bool MouseEvent(int type, int x, int y);
|
|
||||||
};
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
//
|
//
|
||||||
// list menu class runs a menu described by a DListMenuDescriptor
|
// list menu class runs a menu described by a DListMenuDescriptor
|
||||||
|
@ -594,36 +370,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
// base class for menu items
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
/*
|
|
||||||
class DMenuItemBase : public DMenuItemBase
|
|
||||||
{
|
|
||||||
DECLARE_ABSTRACT_CLASS(DMenuItemBase, DMenuItemBase)
|
|
||||||
public:
|
|
||||||
FString mLabel;
|
|
||||||
bool mCentered;
|
|
||||||
|
|
||||||
void drawLabel(int indent, int y, EColorRange color, bool grayed = false);
|
|
||||||
|
|
||||||
DMenuItemBase(const char *text = nullptr, FName action = NAME_None, bool center = false)
|
|
||||||
: DMenuItemBase(0, 0, action)
|
|
||||||
{
|
|
||||||
mLabel = text;
|
|
||||||
mCentered = center;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual int Draw(DOptionMenuDescriptor *desc, int y, int indent, bool selected);
|
|
||||||
virtual bool Selectable();
|
|
||||||
virtual int GetIndent();
|
|
||||||
virtual bool MouseEvent(int type, int x, int y);
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -762,5 +508,7 @@ DMenuItemBase * CreateOptionMenuSliderJoySensitivity(const char * label, double
|
||||||
DMenuItemBase * CreateOptionMenuSliderJoyScale(const char *label, int axis, double min, double max, double step, int showval);
|
DMenuItemBase * CreateOptionMenuSliderJoyScale(const char *label, int axis, double min, double max, double step, int showval);
|
||||||
DMenuItemBase * CreateOptionMenuItemInverter(const char *label, int axis, int center);
|
DMenuItemBase * CreateOptionMenuItemInverter(const char *label, int axis, int center);
|
||||||
DMenuItemBase * CreateOptionMenuSliderJoyDeadZone(const char *label, int axis, double min, double max, double step, int showval);
|
DMenuItemBase * CreateOptionMenuSliderJoyDeadZone(const char *label, int axis, double min, double max, double step, int showval);
|
||||||
|
DMenuItemBase * CreateListMenuItemPatch(int x, int y, int height, int hotkey, FTextureID tex, FName command, int param);
|
||||||
|
DMenuItemBase * CreateListMenuItemText(int x, int y, int height, int hotkey, const char *text, FFont *font, PalEntry color1, PalEntry color2, FName command, int param);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -336,87 +336,6 @@ static void ParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc)
|
||||||
sc.MustGetNumber();
|
sc.MustGetNumber();
|
||||||
desc->mWRight = sc.Number;
|
desc->mWRight = sc.Number;
|
||||||
}
|
}
|
||||||
else if (sc.Compare("StaticPatch") || sc.Compare("StaticPatchCentered"))
|
|
||||||
{
|
|
||||||
bool centered = sc.Compare("StaticPatchCentered");
|
|
||||||
sc.MustGetNumber();
|
|
||||||
int x = sc.Number;
|
|
||||||
sc.MustGetStringName(",");
|
|
||||||
sc.MustGetNumber();
|
|
||||||
int y = sc.Number;
|
|
||||||
sc.MustGetStringName(",");
|
|
||||||
sc.MustGetString();
|
|
||||||
FTextureID tex = GetMenuTexture(sc.String);
|
|
||||||
|
|
||||||
DMenuItemBase *it = new DListMenuItemStaticPatch_(x, y, tex, centered);
|
|
||||||
desc->mItems.Push(it);
|
|
||||||
}
|
|
||||||
else if (sc.Compare("StaticText") || sc.Compare("StaticTextCentered"))
|
|
||||||
{
|
|
||||||
bool centered = sc.Compare("StaticTextCentered");
|
|
||||||
sc.MustGetNumber();
|
|
||||||
int x = sc.Number;
|
|
||||||
sc.MustGetStringName(",");
|
|
||||||
sc.MustGetNumber();
|
|
||||||
int y = sc.Number;
|
|
||||||
sc.MustGetStringName(",");
|
|
||||||
sc.MustGetString();
|
|
||||||
FString label = sc.String;
|
|
||||||
EColorRange cr = desc->mFontColor;
|
|
||||||
if (sc.CheckString(","))
|
|
||||||
{
|
|
||||||
sc.MustGetString();
|
|
||||||
cr = V_FindFontColor(sc.String);
|
|
||||||
if (cr == CR_UNTRANSLATED && !sc.Compare("untranslated")) cr = desc->mFontColor;
|
|
||||||
}
|
|
||||||
DMenuItemBase *it = new DListMenuItemStaticText_(x, y, label, desc->mFont, cr, centered);
|
|
||||||
desc->mItems.Push(it);
|
|
||||||
}
|
|
||||||
else if (sc.Compare("PatchItem"))
|
|
||||||
{
|
|
||||||
sc.MustGetString();
|
|
||||||
FTextureID tex = GetMenuTexture(sc.String);
|
|
||||||
sc.MustGetStringName(",");
|
|
||||||
sc.MustGetString();
|
|
||||||
int hotkey = sc.String[0];
|
|
||||||
sc.MustGetStringName(",");
|
|
||||||
sc.MustGetString();
|
|
||||||
FName action = sc.String;
|
|
||||||
int param = 0;
|
|
||||||
if (sc.CheckString(","))
|
|
||||||
{
|
|
||||||
sc.MustGetNumber();
|
|
||||||
param = sc.Number;
|
|
||||||
}
|
|
||||||
|
|
||||||
DMenuItemBase *it = new DListMenuItemPatch_(desc->mXpos, desc->mYpos, desc->mLinespacing, hotkey, tex, action, param);
|
|
||||||
desc->mItems.Push(it);
|
|
||||||
desc->mYpos += desc->mLinespacing;
|
|
||||||
if (desc->mSelectedItem == -1) desc->mSelectedItem = desc->mItems.Size()-1;
|
|
||||||
}
|
|
||||||
else if (sc.Compare("TextItem"))
|
|
||||||
{
|
|
||||||
sc.MustGetString();
|
|
||||||
FString text = sc.String;
|
|
||||||
sc.MustGetStringName(",");
|
|
||||||
sc.MustGetString();
|
|
||||||
int hotkey = sc.String[0];
|
|
||||||
sc.MustGetStringName(",");
|
|
||||||
sc.MustGetString();
|
|
||||||
FName action = sc.String;
|
|
||||||
int param = 0;
|
|
||||||
if (sc.CheckString(","))
|
|
||||||
{
|
|
||||||
sc.MustGetNumber();
|
|
||||||
param = sc.Number;
|
|
||||||
}
|
|
||||||
|
|
||||||
DMenuItemBase *it = new DListMenuItemText_(desc->mXpos, desc->mYpos, desc->mLinespacing, hotkey, text, desc->mFont, desc->mFontColor, desc->mFontColor2, action, param);
|
|
||||||
desc->mItems.Push(it);
|
|
||||||
desc->mYpos += desc->mLinespacing;
|
|
||||||
if (desc->mSelectedItem == -1) desc->mSelectedItem = desc->mItems.Size()-1;
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (sc.Compare("Font"))
|
else if (sc.Compare("Font"))
|
||||||
{
|
{
|
||||||
sc.MustGetString();
|
sc.MustGetString();
|
||||||
|
@ -443,88 +362,124 @@ static void ParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc)
|
||||||
sc.MustGetString();
|
sc.MustGetString();
|
||||||
desc->mNetgameMessage = sc.String;
|
desc->mNetgameMessage = sc.String;
|
||||||
}
|
}
|
||||||
else if (sc.Compare("PlayerDisplay"))
|
else
|
||||||
{
|
{
|
||||||
bool noportrait = false;
|
bool success = false;
|
||||||
FName action = NAME_None;
|
FStringf buildname("ListMenuItem%s", sc.String);
|
||||||
sc.MustGetNumber();
|
PClass *cls = PClass::FindClass(buildname);
|
||||||
int x = sc.Number;
|
if (cls != nullptr && cls->IsDescendantOf("ListMenuItem"))
|
||||||
sc.MustGetStringName(",");
|
|
||||||
sc.MustGetNumber();
|
|
||||||
int y = sc.Number;
|
|
||||||
sc.MustGetStringName(",");
|
|
||||||
sc.MustGetString();
|
|
||||||
PalEntry c1 = V_GetColor(nullptr, sc);
|
|
||||||
sc.MustGetStringName(",");
|
|
||||||
sc.MustGetString();
|
|
||||||
PalEntry c2 = V_GetColor(nullptr, sc);
|
|
||||||
if (sc.CheckString(","))
|
|
||||||
{
|
{
|
||||||
sc.MustGetNumber();
|
auto func = dyn_cast<PFunction>(cls->Symbols.FindSymbol("Init", false));
|
||||||
noportrait = !!sc.Number;
|
if (func != nullptr && !(func->Variants[0].Flags & (VARF_Protected | VARF_Private))) // skip internal classes which have a protexted init method.
|
||||||
if (sc.CheckString(","))
|
|
||||||
{
|
{
|
||||||
sc.MustGetString();
|
auto &args = func->Variants[0].Proto->ArgumentTypes;
|
||||||
action = sc.String;
|
TArray<VMValue> params;
|
||||||
|
int start = 1;
|
||||||
|
|
||||||
|
params.Push(0);
|
||||||
|
if (args.Size() > 1 && args[1] == NewPointer(PClass::FindClass("ListMenuDescriptor")))
|
||||||
|
{
|
||||||
|
params.Push(desc);
|
||||||
|
start = 2;
|
||||||
|
}
|
||||||
|
auto TypeCVar = NewPointer(NewNativeStruct("CVar", nullptr));
|
||||||
|
|
||||||
|
for (unsigned i = 1; i < args.Size(); i++)
|
||||||
|
{
|
||||||
|
sc.MustGetString();
|
||||||
|
if (args[i] == TypeString)
|
||||||
|
{
|
||||||
|
params.Push(sc.String);
|
||||||
|
}
|
||||||
|
else if (args[i] == TypeName)
|
||||||
|
{
|
||||||
|
params.Push(FName(sc.String).GetIndex());
|
||||||
|
}
|
||||||
|
else if (args[i] == TypeColor)
|
||||||
|
{
|
||||||
|
params.Push(V_GetColor(nullptr, sc));
|
||||||
|
}
|
||||||
|
else if (args[i] == TypeFont)
|
||||||
|
{
|
||||||
|
params.Push(FFont::FindFont(sc.String));
|
||||||
|
}
|
||||||
|
else if (args[i]->IsKindOf(RUNTIME_CLASS(PInt)))
|
||||||
|
{
|
||||||
|
char *endp;
|
||||||
|
int v = (int)strtoll(sc.String, &endp, 0);
|
||||||
|
if (*endp != 0)
|
||||||
|
{
|
||||||
|
// special check for font color ranges.
|
||||||
|
v = V_FindFontColor(sc.String);
|
||||||
|
if (v == CR_UNTRANSLATED && !sc.Compare("untranslated"))
|
||||||
|
{
|
||||||
|
// todo: check other data types that may get used.
|
||||||
|
sc.ScriptError("Integer expected, got %s", sc.String);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (args[i] == TypeBool) v = !!v;
|
||||||
|
params.Push(v);
|
||||||
|
}
|
||||||
|
else if (args[i]->IsKindOf(RUNTIME_CLASS(PFloat)))
|
||||||
|
{
|
||||||
|
char *endp;
|
||||||
|
double v = strtod(sc.String, &endp);
|
||||||
|
if (*endp != 0)
|
||||||
|
{
|
||||||
|
sc.ScriptError("Float expected, got %s", sc.String);
|
||||||
|
}
|
||||||
|
params.Push(v);
|
||||||
|
}
|
||||||
|
else if (args[i] == TypeCVar)
|
||||||
|
{
|
||||||
|
auto cv = FindCVar(sc.String, nullptr);
|
||||||
|
if (cv == nullptr && *sc.String)
|
||||||
|
{
|
||||||
|
sc.ScriptError("Unknown CVar %s", sc.String);
|
||||||
|
}
|
||||||
|
params.Push(cv);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sc.ScriptError("Invalid parameter type %s for menu item", args[i]->DescriptiveName());
|
||||||
|
}
|
||||||
|
if (sc.CheckString(","))
|
||||||
|
{
|
||||||
|
if (i == args.Size() - 1)
|
||||||
|
{
|
||||||
|
sc.ScriptError("Too many parameters for %s", cls->TypeName.GetChars());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (i < args.Size() - 1 && !(func->Variants[0].ArgFlags[i + 1] & VARF_Optional))
|
||||||
|
{
|
||||||
|
sc.ScriptError("Insufficient parameters for %s", cls->TypeName.GetChars());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
DMenuItemBase *item = (DMenuItemBase*)cls->CreateNew();
|
||||||
|
params[0] = item;
|
||||||
|
GlobalVMStack.Call(func->Variants[0].Implementation, ¶ms[0], params.Size(), nullptr, 0);
|
||||||
|
desc->mItems.Push((DMenuItemBase*)item);
|
||||||
|
*/
|
||||||
|
if (cls->IsDescendantOf("ListMenuItemSelectable"))
|
||||||
|
{
|
||||||
|
desc->mYpos += desc->mLinespacing;
|
||||||
|
if (desc->mSelectedItem == -1) desc->mSelectedItem = desc->mItems.Size() - 1;
|
||||||
|
}
|
||||||
|
success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DListMenuItemPlayerDisplay_ *it = new DListMenuItemPlayerDisplay_(desc, x, y, c1, c2, noportrait, action);
|
if (!success)
|
||||||
desc->mItems.Push(it);
|
|
||||||
}
|
|
||||||
else if (sc.Compare("PlayerNameBox"))
|
|
||||||
{
|
|
||||||
sc.MustGetString();
|
|
||||||
FString text = sc.String;
|
|
||||||
sc.MustGetStringName(",");
|
|
||||||
sc.MustGetNumber();
|
|
||||||
int ofs = sc.Number;
|
|
||||||
sc.MustGetStringName(",");
|
|
||||||
sc.MustGetString();
|
|
||||||
DMenuItemBase *it = new DPlayerNameBox_(desc->mXpos, desc->mYpos, desc->mLinespacing, ofs, text, desc->mFont, desc->mFontColor, sc.String);
|
|
||||||
desc->mItems.Push(it);
|
|
||||||
desc->mYpos += desc->mLinespacing;
|
|
||||||
if (desc->mSelectedItem == -1) desc->mSelectedItem = desc->mItems.Size()-1;
|
|
||||||
}
|
|
||||||
else if (sc.Compare("ValueText"))
|
|
||||||
{
|
|
||||||
sc.MustGetString();
|
|
||||||
FString text = sc.String;
|
|
||||||
sc.MustGetStringName(",");
|
|
||||||
sc.MustGetString();
|
|
||||||
FName action = sc.String;
|
|
||||||
FName values;
|
|
||||||
if (sc.CheckString(","))
|
|
||||||
{
|
{
|
||||||
sc.MustGetString();
|
sc.ScriptError("Unknown keyword '%s'", sc.String);
|
||||||
values = sc.String;
|
|
||||||
}
|
}
|
||||||
DMenuItemBase *it = new DValueTextItem_(desc->mXpos, desc->mYpos, desc->mLinespacing, text, desc->mFont, desc->mFontColor, desc->mFontColor2, action, values);
|
|
||||||
desc->mItems.Push(it);
|
|
||||||
desc->mYpos += desc->mLinespacing;
|
|
||||||
if (desc->mSelectedItem == -1) desc->mSelectedItem = desc->mItems.Size()-1;
|
|
||||||
}
|
}
|
||||||
else if (sc.Compare("Slider"))
|
|
||||||
{
|
|
||||||
sc.MustGetString();
|
|
||||||
FString text = sc.String;
|
|
||||||
sc.MustGetStringName(",");
|
|
||||||
sc.MustGetString();
|
|
||||||
FString action = sc.String;
|
|
||||||
sc.MustGetStringName(",");
|
|
||||||
sc.MustGetNumber();
|
|
||||||
int min = sc.Number;
|
|
||||||
sc.MustGetStringName(",");
|
|
||||||
sc.MustGetNumber();
|
|
||||||
int max = sc.Number;
|
|
||||||
sc.MustGetStringName(",");
|
|
||||||
sc.MustGetNumber();
|
|
||||||
int step = sc.Number;
|
|
||||||
DMenuItemBase *it = new DSliderItem_(desc->mXpos, desc->mYpos, desc->mLinespacing, text, desc->mFont, desc->mFontColor, action, min, max, step);
|
|
||||||
desc->mItems.Push(it);
|
|
||||||
desc->mYpos += desc->mLinespacing;
|
|
||||||
if (desc->mSelectedItem == -1) desc->mSelectedItem = desc->mItems.Size()-1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
sc.ScriptError("Unknown keyword '%s'", sc.String);
|
sc.ScriptError("Unknown keyword '%s'", sc.String);
|
||||||
}
|
}
|
||||||
|
@ -835,7 +790,7 @@ static void ParseOptionMenuBody(FScanner &sc, DOptionMenuDescriptor *desc)
|
||||||
if (args[i] == TypeBool) v = !!v;
|
if (args[i] == TypeBool) v = !!v;
|
||||||
params.Push(v);
|
params.Push(v);
|
||||||
}
|
}
|
||||||
else if (args[i]->IsKindOf(RUNTIME_CLASS(PInt)))
|
else if (args[i]->IsKindOf(RUNTIME_CLASS(PFloat)))
|
||||||
{
|
{
|
||||||
char *endp;
|
char *endp;
|
||||||
double v = strtod(sc.String, &endp);
|
double v = strtod(sc.String, &endp);
|
||||||
|
@ -1060,12 +1015,11 @@ static void BuildEpisodeMenu()
|
||||||
if (AllEpisodes[i].mPicName.IsNotEmpty())
|
if (AllEpisodes[i].mPicName.IsNotEmpty())
|
||||||
{
|
{
|
||||||
FTextureID tex = GetMenuTexture(AllEpisodes[i].mPicName);
|
FTextureID tex = GetMenuTexture(AllEpisodes[i].mPicName);
|
||||||
it = new DListMenuItemPatch_(ld->mXpos, posy, ld->mLinespacing, AllEpisodes[i].mShortcut,
|
it = CreateListMenuItemPatch(ld->mXpos, posy, ld->mLinespacing, AllEpisodes[i].mShortcut, tex, NAME_Skillmenu, i);
|
||||||
tex, NAME_Skillmenu, i);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
it = new DListMenuItemText_(ld->mXpos, posy, ld->mLinespacing, AllEpisodes[i].mShortcut,
|
it = CreateListMenuItemText(ld->mXpos, posy, ld->mLinespacing, AllEpisodes[i].mShortcut,
|
||||||
AllEpisodes[i].mEpisodeName, ld->mFont, ld->mFontColor, ld->mFontColor2, NAME_Skillmenu, i);
|
AllEpisodes[i].mEpisodeName, ld->mFont, ld->mFontColor, ld->mFontColor2, NAME_Skillmenu, i);
|
||||||
}
|
}
|
||||||
ld->mItems.Push(it);
|
ld->mItems.Push(it);
|
||||||
|
@ -1158,7 +1112,7 @@ static void BuildPlayerclassMenu()
|
||||||
if (numclassitems <= 1)
|
if (numclassitems <= 1)
|
||||||
{
|
{
|
||||||
// create a dummy item that auto-chooses the default class.
|
// create a dummy item that auto-chooses the default class.
|
||||||
DListMenuItemText_ *it = new DListMenuItemText_(0, 0, 0, 'p', "player",
|
auto it = CreateListMenuItemText(0, 0, 0, 'p', "player",
|
||||||
ld->mFont,ld->mFontColor, ld->mFontColor2, NAME_Episodemenu, -1000);
|
ld->mFont,ld->mFontColor, ld->mFontColor2, NAME_Episodemenu, -1000);
|
||||||
ld->mAutoselect = ld->mItems.Push(it);
|
ld->mAutoselect = ld->mItems.Push(it);
|
||||||
success = true;
|
success = true;
|
||||||
|
@ -1184,7 +1138,7 @@ static void BuildPlayerclassMenu()
|
||||||
const char *pname = GetPrintableDisplayName(PlayerClasses[i].Type);
|
const char *pname = GetPrintableDisplayName(PlayerClasses[i].Type);
|
||||||
if (pname != nullptr)
|
if (pname != nullptr)
|
||||||
{
|
{
|
||||||
DListMenuItemText_ *it = new DListMenuItemText_(ld->mXpos, ld->mYpos, ld->mLinespacing, *pname,
|
auto it = CreateListMenuItemText(ld->mXpos, ld->mYpos, ld->mLinespacing, *pname,
|
||||||
pname, ld->mFont,ld->mFontColor,ld->mFontColor2, NAME_Episodemenu, i);
|
pname, ld->mFont,ld->mFontColor,ld->mFontColor2, NAME_Episodemenu, i);
|
||||||
ld->mItems.Push(it);
|
ld->mItems.Push(it);
|
||||||
ld->mYpos += ld->mLinespacing;
|
ld->mYpos += ld->mLinespacing;
|
||||||
|
@ -1194,7 +1148,7 @@ static void BuildPlayerclassMenu()
|
||||||
}
|
}
|
||||||
if (n > 1 && !gameinfo.norandomplayerclass)
|
if (n > 1 && !gameinfo.norandomplayerclass)
|
||||||
{
|
{
|
||||||
DListMenuItemText_ *it = new DListMenuItemText_(ld->mXpos, ld->mYpos, ld->mLinespacing, 'r',
|
auto it = CreateListMenuItemText(ld->mXpos, ld->mYpos, ld->mLinespacing, 'r',
|
||||||
"$MNU_RANDOM", ld->mFont,ld->mFontColor,ld->mFontColor2, NAME_Episodemenu, -1);
|
"$MNU_RANDOM", ld->mFont,ld->mFontColor,ld->mFontColor2, NAME_Episodemenu, -1);
|
||||||
ld->mItems.Push(it);
|
ld->mItems.Push(it);
|
||||||
}
|
}
|
||||||
|
@ -1203,7 +1157,7 @@ static void BuildPlayerclassMenu()
|
||||||
const char *pname = GetPrintableDisplayName(PlayerClasses[0].Type);
|
const char *pname = GetPrintableDisplayName(PlayerClasses[0].Type);
|
||||||
if (pname != nullptr)
|
if (pname != nullptr)
|
||||||
{
|
{
|
||||||
DListMenuItemText_ *it = new DListMenuItemText_(ld->mXpos, ld->mYpos, ld->mLinespacing, *pname,
|
auto it = CreateListMenuItemText(ld->mXpos, ld->mYpos, ld->mLinespacing, *pname,
|
||||||
pname, ld->mFont,ld->mFontColor,ld->mFontColor2, NAME_Episodemenu, 0);
|
pname, ld->mFont,ld->mFontColor,ld->mFontColor2, NAME_Episodemenu, 0);
|
||||||
ld->mItems.Push(it);
|
ld->mItems.Push(it);
|
||||||
}
|
}
|
||||||
|
@ -1464,13 +1418,13 @@ void M_StartupSkillMenu(FGameStartup *gs)
|
||||||
if (skill.PicName.Len() != 0 && pItemText == nullptr)
|
if (skill.PicName.Len() != 0 && pItemText == nullptr)
|
||||||
{
|
{
|
||||||
FTextureID tex = GetMenuTexture(skill.PicName);
|
FTextureID tex = GetMenuTexture(skill.PicName);
|
||||||
li = new DListMenuItemPatch_(ld->mXpos, y, ld->mLinespacing, skill.Shortcut, tex, action, i);
|
li = CreateListMenuItemPatch(ld->mXpos, y, ld->mLinespacing, skill.Shortcut, tex, action, i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EColorRange color = (EColorRange)skill.GetTextColor();
|
EColorRange color = (EColorRange)skill.GetTextColor();
|
||||||
if (color == CR_UNTRANSLATED) color = ld->mFontColor;
|
if (color == CR_UNTRANSLATED) color = ld->mFontColor;
|
||||||
li = new DListMenuItemText_(x, y, ld->mLinespacing, skill.Shortcut,
|
li = CreateListMenuItemText(x, y, ld->mLinespacing, skill.Shortcut,
|
||||||
pItemText? *pItemText : skill.MenuName, ld->mFont, color,ld->mFontColor2, action, i);
|
pItemText? *pItemText : skill.MenuName, ld->mFont, color,ld->mFontColor2, action, i);
|
||||||
}
|
}
|
||||||
ld->mItems.Push(li);
|
ld->mItems.Push(li);
|
||||||
|
|
|
@ -1,320 +0,0 @@
|
||||||
/*
|
|
||||||
** playerdisplay.cpp
|
|
||||||
** The player display for the player setup and class selection screen
|
|
||||||
**
|
|
||||||
**---------------------------------------------------------------------------
|
|
||||||
** Copyright 2010 Christoph Oelckers
|
|
||||||
** All rights reserved.
|
|
||||||
**
|
|
||||||
** Redistribution and use in source and binary forms, with or without
|
|
||||||
** modification, are permitted provided that the following conditions
|
|
||||||
** are met:
|
|
||||||
**
|
|
||||||
** 1. Redistributions of source code must retain the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer.
|
|
||||||
** 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer in the
|
|
||||||
** documentation and/or other materials provided with the distribution.
|
|
||||||
** 3. The name of the author may not be used to endorse or promote products
|
|
||||||
** derived from this software without specific prior written permission.
|
|
||||||
**
|
|
||||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
**---------------------------------------------------------------------------
|
|
||||||
**
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "doomtype.h"
|
|
||||||
#include "doomstat.h"
|
|
||||||
#include "d_player.h"
|
|
||||||
#include "templates.h"
|
|
||||||
#include "menu/menu.h"
|
|
||||||
#include "colormatcher.h"
|
|
||||||
#include "textures/textures.h"
|
|
||||||
#include "w_wad.h"
|
|
||||||
#include "v_font.h"
|
|
||||||
#include "v_video.h"
|
|
||||||
#include "g_level.h"
|
|
||||||
#include "gi.h"
|
|
||||||
#include "r_defs.h"
|
|
||||||
#include "r_state.h"
|
|
||||||
#include "r_data/r_translate.h"
|
|
||||||
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
IMPLEMENT_CLASS(DListMenuItemPlayerDisplay_, false, false)
|
|
||||||
DListMenuItemPlayerDisplay_::DListMenuItemPlayerDisplay_(DListMenuDescriptor *menu, int x, int y, PalEntry c1, PalEntry c2, bool np, FName action)
|
|
||||||
: DMenuItemBase(x, y, action)
|
|
||||||
{
|
|
||||||
mOwner = menu;
|
|
||||||
|
|
||||||
FRemapTable *bdremap = translationtables[TRANSLATION_Players][MAXPLAYERS + 1];
|
|
||||||
for (int i = 0; i < 256; i++)
|
|
||||||
{
|
|
||||||
int r = c1.r + c2.r * i / 255;
|
|
||||||
int g = c1.g + c2.g * i / 255;
|
|
||||||
int b = c1.b + c2.b * i / 255;
|
|
||||||
bdremap->Remap[i] = ColorMatcher.Pick (r, g, b);
|
|
||||||
bdremap->Palette[i] = PalEntry(255, r, g, b);
|
|
||||||
}
|
|
||||||
auto id = TexMan.CheckForTexture("PlayerBackdrop", FTexture::TEX_MiscPatch);
|
|
||||||
mBackdrop = TexMan[id];
|
|
||||||
mPlayerClass = NULL;
|
|
||||||
mPlayerState = NULL;
|
|
||||||
mNoportrait = np;
|
|
||||||
mMode = 0;
|
|
||||||
mRotation = 0;
|
|
||||||
mTranslate = false;
|
|
||||||
mSkin = 0;
|
|
||||||
mRandomClass = 0;
|
|
||||||
mRandomTimer = 0;
|
|
||||||
mClassNum = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
void DListMenuItemPlayerDisplay_::OnDestroy()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
void DListMenuItemPlayerDisplay_::UpdateRandomClass()
|
|
||||||
{
|
|
||||||
if (--mRandomTimer < 0)
|
|
||||||
{
|
|
||||||
if (++mRandomClass >= (int)PlayerClasses.Size ()) mRandomClass = 0;
|
|
||||||
mPlayerClass = &PlayerClasses[mRandomClass];
|
|
||||||
mPlayerState = GetDefaultByType (mPlayerClass->Type)->SeeState;
|
|
||||||
if (mPlayerState == NULL)
|
|
||||||
{ // No see state, so try spawn state.
|
|
||||||
mPlayerState = GetDefaultByType (mPlayerClass->Type)->SpawnState;
|
|
||||||
}
|
|
||||||
mPlayerTics = mPlayerState != NULL ? mPlayerState->GetTics() : -1;
|
|
||||||
mRandomTimer = 6;
|
|
||||||
|
|
||||||
// Since the newly displayed class may used a different translation
|
|
||||||
// range than the old one, we need to update the translation, too.
|
|
||||||
UpdateTranslation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
void DListMenuItemPlayerDisplay_::UpdateTranslation()
|
|
||||||
{
|
|
||||||
int PlayerColor = players[consoleplayer].userinfo.GetColor();
|
|
||||||
int PlayerSkin = players[consoleplayer].userinfo.GetSkin();
|
|
||||||
int PlayerColorset = players[consoleplayer].userinfo.GetColorSet();
|
|
||||||
|
|
||||||
if (mPlayerClass != NULL)
|
|
||||||
{
|
|
||||||
PlayerSkin = R_FindSkin (skins[PlayerSkin].name, int(mPlayerClass - &PlayerClasses[0]));
|
|
||||||
R_GetPlayerTranslation(PlayerColor, GetColorSet(mPlayerClass->Type, PlayerColorset),
|
|
||||||
&skins[PlayerSkin], translationtables[TRANSLATION_Players][MAXPLAYERS]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
void DListMenuItemPlayerDisplay_::SetPlayerClass(int classnum, bool force)
|
|
||||||
{
|
|
||||||
if (classnum < 0 || classnum >= (int)PlayerClasses.Size ())
|
|
||||||
{
|
|
||||||
if (mClassNum != -1)
|
|
||||||
{
|
|
||||||
mClassNum = -1;
|
|
||||||
mRandomTimer = 0;
|
|
||||||
UpdateRandomClass();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (mPlayerClass != &PlayerClasses[classnum] || force)
|
|
||||||
{
|
|
||||||
mPlayerClass = &PlayerClasses[classnum];
|
|
||||||
mPlayerState = GetDefaultByType (mPlayerClass->Type)->SeeState;
|
|
||||||
if (mPlayerState == NULL)
|
|
||||||
{ // No see state, so try spawn state.
|
|
||||||
mPlayerState = GetDefaultByType (mPlayerClass->Type)->SpawnState;
|
|
||||||
}
|
|
||||||
mPlayerTics = mPlayerState != NULL ? mPlayerState->GetTics() : -1;
|
|
||||||
mClassNum = classnum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
bool DListMenuItemPlayerDisplay_::UpdatePlayerClass()
|
|
||||||
{
|
|
||||||
if (mOwner->mSelectedItem >= 0)
|
|
||||||
{
|
|
||||||
int classnum;
|
|
||||||
FName seltype = mOwner->mItems[mOwner->mSelectedItem]->GetAction(&classnum);
|
|
||||||
|
|
||||||
if (seltype != NAME_Episodemenu) return false;
|
|
||||||
if (PlayerClasses.Size() == 0) return false;
|
|
||||||
|
|
||||||
SetPlayerClass(classnum);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
bool DListMenuItemPlayerDisplay_::SetValue(int i, int value)
|
|
||||||
{
|
|
||||||
switch (i)
|
|
||||||
{
|
|
||||||
case PDF_MODE:
|
|
||||||
mMode = value;
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case PDF_ROTATION:
|
|
||||||
mRotation = value;
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case PDF_TRANSLATE:
|
|
||||||
mTranslate = value;
|
|
||||||
|
|
||||||
case PDF_CLASS:
|
|
||||||
SetPlayerClass(value, true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PDF_SKIN:
|
|
||||||
mSkin = value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
void DListMenuItemPlayerDisplay_::Ticker()
|
|
||||||
{
|
|
||||||
if (mClassNum < 0) UpdateRandomClass();
|
|
||||||
|
|
||||||
if (mPlayerState != NULL && mPlayerState->GetTics () != -1 && mPlayerState->GetNextState () != NULL)
|
|
||||||
{
|
|
||||||
if (--mPlayerTics <= 0)
|
|
||||||
{
|
|
||||||
mPlayerState = mPlayerState->GetNextState();
|
|
||||||
mPlayerTics = mPlayerState->GetTics();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
void DListMenuItemPlayerDisplay_::Drawer(bool selected)
|
|
||||||
{
|
|
||||||
if (mMode == 0 && !UpdatePlayerClass())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FName portrait = ((APlayerPawn*)GetDefaultByType(mPlayerClass->Type))->Portrait;
|
|
||||||
|
|
||||||
if (portrait != NAME_None && !mNoportrait)
|
|
||||||
{
|
|
||||||
FTextureID texid = TexMan.CheckForTexture(portrait.GetChars(), FTexture::TEX_MiscPatch);
|
|
||||||
if (texid.isValid())
|
|
||||||
{
|
|
||||||
FTexture *tex = TexMan(texid);
|
|
||||||
if (tex != NULL)
|
|
||||||
{
|
|
||||||
screen->DrawTexture (tex, mXpos, mYpos, DTA_Clean, true, TAG_DONE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int x = (mXpos - 160) * CleanXfac + (SCREENWIDTH>>1);
|
|
||||||
int y = (mYpos - 100) * CleanYfac + (SCREENHEIGHT>>1);
|
|
||||||
|
|
||||||
screen->DrawTexture(mBackdrop, x, y - 1,
|
|
||||||
DTA_DestWidth, 72 * CleanXfac,
|
|
||||||
DTA_DestHeight, 80 * CleanYfac,
|
|
||||||
DTA_TranslationIndex, TRANSLATION(TRANSLATION_Players, MAXPLAYERS + 1),
|
|
||||||
DTA_Masked, true,
|
|
||||||
TAG_DONE);
|
|
||||||
|
|
||||||
V_DrawFrame (x, y, 72*CleanXfac, 80*CleanYfac-1);
|
|
||||||
|
|
||||||
spriteframe_t *sprframe = NULL;
|
|
||||||
DVector2 Scale;
|
|
||||||
|
|
||||||
if (mPlayerState != NULL)
|
|
||||||
{
|
|
||||||
if (mSkin == 0)
|
|
||||||
{
|
|
||||||
sprframe = &SpriteFrames[sprites[mPlayerState->sprite].spriteframes + mPlayerState->GetFrame()];
|
|
||||||
Scale = GetDefaultByType(mPlayerClass->Type)->Scale;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sprframe = &SpriteFrames[sprites[skins[mSkin].sprite].spriteframes + mPlayerState->GetFrame()];
|
|
||||||
Scale = skins[mSkin].Scale;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sprframe != NULL)
|
|
||||||
{
|
|
||||||
FTexture *tex = TexMan(sprframe->Texture[mRotation]);
|
|
||||||
if (tex != NULL && tex->UseType != FTexture::TEX_Null)
|
|
||||||
{
|
|
||||||
int trans = mTranslate? TRANSLATION(TRANSLATION_Players, MAXPLAYERS) : 0;
|
|
||||||
screen->DrawTexture (tex,
|
|
||||||
x + 36*CleanXfac, y + 71*CleanYfac,
|
|
||||||
DTA_DestWidthF, tex->GetScaledWidthDouble() * CleanXfac * Scale.X,
|
|
||||||
DTA_DestHeightF, tex->GetScaledHeightDouble() * CleanYfac * Scale.Y,
|
|
||||||
DTA_TranslationIndex, trans,
|
|
||||||
DTA_FlipX, sprframe->Flip & (1 << mRotation),
|
|
||||||
TAG_DONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -55,428 +55,6 @@ EXTERN_CVAR (Float, autoaim)
|
||||||
EXTERN_CVAR(Bool, neverswitchonpickup)
|
EXTERN_CVAR(Bool, neverswitchonpickup)
|
||||||
EXTERN_CVAR (Bool, cl_run)
|
EXTERN_CVAR (Bool, cl_run)
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
// Player's name
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
IMPLEMENT_CLASS(DPlayerNameBox_, false, false)
|
|
||||||
|
|
||||||
DPlayerNameBox_::DPlayerNameBox_(int x, int y, int height, int frameofs, const char *text, FFont *font, EColorRange color, FName action)
|
|
||||||
: DListMenuItemSelectable_(x, y, height, action)
|
|
||||||
{
|
|
||||||
mText = text;
|
|
||||||
mFont = font;
|
|
||||||
mFontColor = color;
|
|
||||||
mFrameSize = frameofs;
|
|
||||||
mPlayerName[0] = 0;
|
|
||||||
mEntering = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
bool DPlayerNameBox_::SetString(int i, const char *s)
|
|
||||||
{
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
strncpy(mPlayerName, s, MAXPLAYERNAME);
|
|
||||||
mPlayerName[MAXPLAYERNAME] = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DPlayerNameBox_::GetString(int i, char *s, int len)
|
|
||||||
{
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
strncpy(s, mPlayerName, len);
|
|
||||||
s[len] = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
// [RH] Width of the border is variable
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
void DPlayerNameBox_::DrawBorder (int x, int y, int len)
|
|
||||||
{
|
|
||||||
FTexture *left = TexMan[TexMan.CheckForTexture("M_LSLEFT", FTexture::TEX_MiscPatch)];
|
|
||||||
FTexture *mid = TexMan[TexMan.CheckForTexture("M_LSCNTR", FTexture::TEX_MiscPatch)];
|
|
||||||
FTexture *right = TexMan[TexMan.CheckForTexture("M_LSRGHT", FTexture::TEX_MiscPatch)];
|
|
||||||
if (left != NULL && right != NULL && mid != NULL)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
screen->DrawTexture (left, x-8, y+7, DTA_Clean, true, TAG_DONE);
|
|
||||||
|
|
||||||
for (i = 0; i < len; i++)
|
|
||||||
{
|
|
||||||
screen->DrawTexture (mid, x, y+7, DTA_Clean, true, TAG_DONE);
|
|
||||||
x += 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
screen->DrawTexture (right, x, y+7, DTA_Clean, true, TAG_DONE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FTexture *slot = TexMan[TexMan.CheckForTexture("M_FSLOT", FTexture::TEX_MiscPatch)];
|
|
||||||
if (slot != NULL)
|
|
||||||
{
|
|
||||||
screen->DrawTexture (slot, x, y+1, DTA_Clean, true, TAG_DONE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
screen->Clear(x, y, x + len, y + SmallFont->GetHeight() * 3/2, -1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
void DPlayerNameBox_::Drawer(bool selected)
|
|
||||||
{
|
|
||||||
const char *text = mText;
|
|
||||||
if (text != NULL)
|
|
||||||
{
|
|
||||||
if (*text == '$') text = GStrings(text+1);
|
|
||||||
screen->DrawText(mFont, selected? OptionSettings.mFontColorSelection : mFontColor, mXpos, mYpos, text, DTA_Clean, true, TAG_DONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw player name box
|
|
||||||
int x = mXpos + mFont->StringWidth(text) + 16 + mFrameSize;
|
|
||||||
DrawBorder (x, mYpos - mFrameSize, MAXPLAYERNAME+1);
|
|
||||||
if (!mEntering)
|
|
||||||
{
|
|
||||||
screen->DrawText (SmallFont, CR_UNTRANSLATED, x + mFrameSize, mYpos, mPlayerName,
|
|
||||||
DTA_Clean, true, TAG_DONE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
size_t l = strlen(mEditName);
|
|
||||||
mEditName[l] = SmallFont->GetCursor();
|
|
||||||
mEditName[l+1] = 0;
|
|
||||||
|
|
||||||
screen->DrawText (SmallFont, CR_UNTRANSLATED, x + mFrameSize, mYpos, mEditName,
|
|
||||||
DTA_Clean, true, TAG_DONE);
|
|
||||||
|
|
||||||
mEditName[l] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
bool DPlayerNameBox_::MenuEvent(int mkey, bool fromcontroller)
|
|
||||||
{
|
|
||||||
if (mkey == MKEY_Enter)
|
|
||||||
{
|
|
||||||
S_Sound (CHAN_VOICE | CHAN_UI, "menu/choose", snd_menuvolume, ATTN_NONE);
|
|
||||||
strcpy(mEditName, mPlayerName);
|
|
||||||
mEntering = true;
|
|
||||||
DMenu *input = new DTextEnterMenu(DMenu::CurrentMenu, mEditName, MAXPLAYERNAME, 2, fromcontroller);
|
|
||||||
M_ActivateMenu(input);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (mkey == MKEY_Input)
|
|
||||||
{
|
|
||||||
strcpy(mPlayerName, mEditName);
|
|
||||||
mEntering = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (mkey == MKEY_Abort)
|
|
||||||
{
|
|
||||||
mEntering = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
// items for the player menu
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
IMPLEMENT_CLASS(DValueTextItem_, false, false)
|
|
||||||
|
|
||||||
DValueTextItem_::DValueTextItem_(int x, int y, int height, const char *text, FFont *font, EColorRange color, EColorRange valuecolor, FName action, FName values)
|
|
||||||
: DListMenuItemSelectable_(x, y, height, action)
|
|
||||||
{
|
|
||||||
mText = text;
|
|
||||||
mFont = font;
|
|
||||||
mFontColor = color;
|
|
||||||
mFontColor2 = valuecolor;
|
|
||||||
mSelection = 0;
|
|
||||||
if (values != NAME_None)
|
|
||||||
{
|
|
||||||
FOptionValues **opt = OptionValues.CheckKey(values);
|
|
||||||
if (opt != NULL)
|
|
||||||
{
|
|
||||||
for(unsigned i=0;i<(*opt)->mValues.Size(); i++)
|
|
||||||
{
|
|
||||||
SetString(i, (*opt)->mValues[i].Text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
bool DValueTextItem_::SetString(int i, const char *s)
|
|
||||||
{
|
|
||||||
// should actually use the index...
|
|
||||||
FString str = s;
|
|
||||||
if (i==0) mSelections.Clear();
|
|
||||||
mSelections.Push(str);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
bool DValueTextItem_::SetValue(int i, int value)
|
|
||||||
{
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
mSelection = value;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DValueTextItem_::GetValue(int i, int *pvalue)
|
|
||||||
{
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
*pvalue = mSelection;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
bool DValueTextItem_::MenuEvent (int mkey, bool fromcontroller)
|
|
||||||
{
|
|
||||||
if (mSelections.Size() > 1)
|
|
||||||
{
|
|
||||||
if (mkey == MKEY_Left)
|
|
||||||
{
|
|
||||||
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", snd_menuvolume, ATTN_NONE);
|
|
||||||
if (--mSelection < 0) mSelection = mSelections.Size() - 1;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (mkey == MKEY_Right || mkey == MKEY_Enter)
|
|
||||||
{
|
|
||||||
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", snd_menuvolume, ATTN_NONE);
|
|
||||||
if (++mSelection >= (int)mSelections.Size()) mSelection = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (mkey == MKEY_Enter); // needs to eat enter keys so that Activate won't get called
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
void DValueTextItem_::Drawer(bool selected)
|
|
||||||
{
|
|
||||||
const char *text = mText;
|
|
||||||
|
|
||||||
if (*text == '$') text = GStrings(text+1);
|
|
||||||
screen->DrawText(mFont, selected? OptionSettings.mFontColorSelection : mFontColor, mXpos, mYpos, text, DTA_Clean, true, TAG_DONE);
|
|
||||||
|
|
||||||
int x = mXpos + mFont->StringWidth(text) + 8;
|
|
||||||
if (mSelections.Size() > 0)
|
|
||||||
{
|
|
||||||
const char *mOptValue = mSelections[mSelection];
|
|
||||||
if (*mOptValue == '$') mOptValue = GStrings(mOptValue + 1);
|
|
||||||
screen->DrawText(mFont, mFontColor2, x, mYpos, mOptValue, DTA_Clean, true, TAG_DONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
// items for the player menu
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
IMPLEMENT_CLASS(DSliderItem_, false, false)
|
|
||||||
|
|
||||||
DSliderItem_::DSliderItem_(int x, int y, int height, const char *text, FFont *font, EColorRange color, FName action, int min, int max, int step)
|
|
||||||
: DListMenuItemSelectable_(x, y, height, action)
|
|
||||||
{
|
|
||||||
mText = text;
|
|
||||||
mFont = font;
|
|
||||||
mFontColor = color;
|
|
||||||
mSelection = 0;
|
|
||||||
mMinrange = min;
|
|
||||||
mMaxrange = max;
|
|
||||||
mStep = step;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
bool DSliderItem_::SetValue(int i, int value)
|
|
||||||
{
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
mSelection = value;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DSliderItem_::GetValue(int i, int *pvalue)
|
|
||||||
{
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
*pvalue = mSelection;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
bool DSliderItem_::MenuEvent (int mkey, bool fromcontroller)
|
|
||||||
{
|
|
||||||
if (mkey == MKEY_Left)
|
|
||||||
{
|
|
||||||
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", snd_menuvolume, ATTN_NONE);
|
|
||||||
if ((mSelection -= mStep) < mMinrange) mSelection = mMinrange;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (mkey == MKEY_Right || mkey == MKEY_Enter)
|
|
||||||
{
|
|
||||||
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", snd_menuvolume, ATTN_NONE);
|
|
||||||
if ((mSelection += mStep) > mMaxrange) mSelection = mMaxrange;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
bool DSliderItem_::MouseEvent(int type, int x, int y)
|
|
||||||
{
|
|
||||||
DListMenu *lm = static_cast<DListMenu*>(DMenu::CurrentMenu);
|
|
||||||
if (type != DMenu::MOUSE_Click)
|
|
||||||
{
|
|
||||||
if (!lm->CheckFocus(this)) return false;
|
|
||||||
}
|
|
||||||
if (type == DMenu::MOUSE_Release)
|
|
||||||
{
|
|
||||||
lm->ReleaseFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
int slide_left = SmallFont->StringWidth ("Green") + 8 + mXpos;
|
|
||||||
int slide_right = slide_left + 12*8; // 12 char cells with 8 pixels each.
|
|
||||||
|
|
||||||
if (type == DMenu::MOUSE_Click)
|
|
||||||
{
|
|
||||||
if (x < slide_left || x >= slide_right) return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
x = clamp(x, slide_left, slide_right);
|
|
||||||
int v = mMinrange + Scale(x - slide_left, mMaxrange - mMinrange, slide_right - slide_left);
|
|
||||||
if (v != mSelection)
|
|
||||||
{
|
|
||||||
mSelection = v;
|
|
||||||
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", snd_menuvolume, ATTN_NONE);
|
|
||||||
}
|
|
||||||
if (type == DMenu::MOUSE_Click)
|
|
||||||
{
|
|
||||||
lm->SetFocus(this);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
void DSliderItem_::DrawSlider (int x, int y)
|
|
||||||
{
|
|
||||||
int range = mMaxrange - mMinrange;
|
|
||||||
int cur = mSelection - mMinrange;
|
|
||||||
|
|
||||||
x = (x - 160) * CleanXfac + screen->GetWidth() / 2;
|
|
||||||
y = (y - 100) * CleanYfac + screen->GetHeight() / 2;
|
|
||||||
|
|
||||||
screen->DrawText (ConFont, CR_WHITE, x, y,
|
|
||||||
"\x10\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x12",
|
|
||||||
DTA_CellX, 8 * CleanXfac,
|
|
||||||
DTA_CellY, 8 * CleanYfac,
|
|
||||||
TAG_DONE);
|
|
||||||
screen->DrawText (ConFont, CR_ORANGE, x + (5 + (int)((cur * 78) / range)) * CleanXfac, y,
|
|
||||||
"\x13",
|
|
||||||
DTA_CellX, 8 * CleanXfac,
|
|
||||||
DTA_CellY, 8 * CleanYfac,
|
|
||||||
TAG_DONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
void DSliderItem_::Drawer(bool selected)
|
|
||||||
{
|
|
||||||
const char *text = mText;
|
|
||||||
|
|
||||||
if (*text == '$') text = GStrings(text+1);
|
|
||||||
screen->DrawText(mFont, selected? OptionSettings.mFontColorSelection : mFontColor, mXpos, mYpos, text, DTA_Clean, true, TAG_DONE);
|
|
||||||
|
|
||||||
int x = SmallFont->StringWidth ("Green") + 8 + mXpos;
|
|
||||||
int x2 = SmallFont->StringWidth (text) + 8 + mXpos;
|
|
||||||
DrawSlider (MAX(x2, x), mYpos);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -524,6 +102,14 @@ IMPLEMENT_CLASS(DPlayerMenu, false, false)
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
enum EPDFlags
|
||||||
|
{
|
||||||
|
ListMenuItemPlayerDisplay_PDF_ROTATION = 0x10001,
|
||||||
|
ListMenuItemPlayerDisplay_PDF_SKIN = 0x10002,
|
||||||
|
ListMenuItemPlayerDisplay_PDF_CLASS = 0x10003,
|
||||||
|
ListMenuItemPlayerDisplay_PDF_MODE = 0x10004,
|
||||||
|
ListMenuItemPlayerDisplay_PDF_TRANSLATE = 0x10005,
|
||||||
|
};
|
||||||
|
|
||||||
void DPlayerMenu::Init(DMenu *parent, DListMenuDescriptor *desc)
|
void DPlayerMenu::Init(DMenu *parent, DListMenuDescriptor *desc)
|
||||||
{
|
{
|
||||||
|
@ -536,14 +122,14 @@ void DPlayerMenu::Init(DMenu *parent, DListMenuDescriptor *desc)
|
||||||
li = GetItem(NAME_Playerdisplay);
|
li = GetItem(NAME_Playerdisplay);
|
||||||
if (li != NULL)
|
if (li != NULL)
|
||||||
{
|
{
|
||||||
li->SetValue(DListMenuItemPlayerDisplay_::PDF_ROTATION, 0);
|
li->SetValue(ListMenuItemPlayerDisplay_PDF_ROTATION, 0);
|
||||||
li->SetValue(DListMenuItemPlayerDisplay_::PDF_MODE, 1);
|
li->SetValue(ListMenuItemPlayerDisplay_PDF_MODE, 1);
|
||||||
li->SetValue(DListMenuItemPlayerDisplay_::PDF_TRANSLATE, 1);
|
li->SetValue(ListMenuItemPlayerDisplay_PDF_TRANSLATE, 1);
|
||||||
li->SetValue(DListMenuItemPlayerDisplay_::PDF_CLASS, players[consoleplayer].userinfo.GetPlayerClassNum());
|
li->SetValue(ListMenuItemPlayerDisplay_PDF_CLASS, players[consoleplayer].userinfo.GetPlayerClassNum());
|
||||||
if (PlayerClass != NULL && !(GetDefaultByType (PlayerClass->Type)->flags4 & MF4_NOSKIN) &&
|
if (PlayerClass != NULL && !(GetDefaultByType (PlayerClass->Type)->flags4 & MF4_NOSKIN) &&
|
||||||
players[consoleplayer].userinfo.GetPlayerClassNum() != -1)
|
players[consoleplayer].userinfo.GetPlayerClassNum() != -1)
|
||||||
{
|
{
|
||||||
li->SetValue(DListMenuItemPlayerDisplay_::PDF_SKIN, players[consoleplayer].userinfo.GetSkin());
|
li->SetValue(ListMenuItemPlayerDisplay_PDF_SKIN, players[consoleplayer].userinfo.GetSkin());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -658,7 +244,7 @@ bool DPlayerMenu::Responder (event_t *ev)
|
||||||
DMenuItemBase *li = GetItem(NAME_Playerdisplay);
|
DMenuItemBase *li = GetItem(NAME_Playerdisplay);
|
||||||
if (li != NULL)
|
if (li != NULL)
|
||||||
{
|
{
|
||||||
li->SetValue(DListMenuItemPlayerDisplay_::PDF_ROTATION, mRotation);
|
li->SetValue(ListMenuItemPlayerDisplay_PDF_ROTATION, mRotation);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -812,7 +398,7 @@ void DPlayerMenu::UpdateSkins()
|
||||||
li = GetItem(NAME_Playerdisplay);
|
li = GetItem(NAME_Playerdisplay);
|
||||||
if (li != NULL)
|
if (li != NULL)
|
||||||
{
|
{
|
||||||
li->SetValue(DListMenuItemPlayerDisplay_::PDF_SKIN, skin);
|
li->SetValue(ListMenuItemPlayerDisplay_PDF_SKIN, skin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UpdateTranslation();
|
UpdateTranslation();
|
||||||
|
@ -908,7 +494,7 @@ void DPlayerMenu::ClassChanged (DMenuItemBase *li)
|
||||||
li = GetItem(NAME_Playerdisplay);
|
li = GetItem(NAME_Playerdisplay);
|
||||||
if (li != NULL)
|
if (li != NULL)
|
||||||
{
|
{
|
||||||
li->SetValue(DListMenuItemPlayerDisplay_::PDF_CLASS, players[consoleplayer].userinfo.GetPlayerClassNum());
|
li->SetValue(ListMenuItemPlayerDisplay_PDF_CLASS, players[consoleplayer].userinfo.GetPlayerClassNum());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -939,7 +525,7 @@ void DPlayerMenu::SkinChanged (DMenuItemBase *li)
|
||||||
li = GetItem(NAME_Playerdisplay);
|
li = GetItem(NAME_Playerdisplay);
|
||||||
if (li != NULL)
|
if (li != NULL)
|
||||||
{
|
{
|
||||||
li->SetValue(DListMenuItemPlayerDisplay_::PDF_SKIN, sel);
|
li->SetValue(ListMenuItemPlayerDisplay_PDF_SKIN, sel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ class ListMenuItemStaticPatch : ListMenuItem
|
||||||
TextureID mTexture;
|
TextureID mTexture;
|
||||||
bool mCentered;
|
bool mCentered;
|
||||||
|
|
||||||
void Init(int x, int y, TextureID patch, bool centered)
|
void Init(int x, int y, TextureID patch, bool centered = false)
|
||||||
{
|
{
|
||||||
Super.Init(x, y);
|
Super.Init(x, y);
|
||||||
mTexture = patch;
|
mTexture = patch;
|
||||||
|
@ -98,6 +98,14 @@ class ListMenuItemStaticPatch : ListMenuItem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ListMenuItemStatucPatchCentered : ListMenuItemStaticPatch
|
||||||
|
{
|
||||||
|
void Init(int x, int y, TextureID patch)
|
||||||
|
{
|
||||||
|
Super.Init(x, y, patch, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
//
|
//
|
||||||
// static text
|
// static text
|
||||||
|
@ -111,7 +119,7 @@ class ListMenuItemStaticText : ListMenuItem
|
||||||
int mColor;
|
int mColor;
|
||||||
bool mCentered;
|
bool mCentered;
|
||||||
|
|
||||||
void Init(int x, int y, String text, Font font, int color, bool centered)
|
void Init(int x, int y, String text, Font font, int color, bool centered = false)
|
||||||
{
|
{
|
||||||
Super.Init(x, y);
|
Super.Init(x, y);
|
||||||
mText = text;
|
mText = text;
|
||||||
|
@ -141,6 +149,14 @@ class ListMenuItemStaticText : ListMenuItem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ListMenuItemStatucTextCentered : ListMenuItemStaticText
|
||||||
|
{
|
||||||
|
void Init(int x, int y, String text, Font font, int color)
|
||||||
|
{
|
||||||
|
Super.Init(x, y, text, font, color, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
//
|
//
|
||||||
// selectable items
|
// selectable items
|
||||||
|
@ -153,7 +169,7 @@ class ListMenuItemSelectable : ListMenuItem
|
||||||
int mHeight;
|
int mHeight;
|
||||||
int mParam;
|
int mParam;
|
||||||
|
|
||||||
void Init(int x, int y, int height, Name childmenu, int param = -1)
|
protected void Init(int x, int y, int height, Name childmenu, int param = -1)
|
||||||
{
|
{
|
||||||
Super.Init(x, y, childmenu);
|
Super.Init(x, y, childmenu);
|
||||||
mHeight = height;
|
mHeight = height;
|
||||||
|
@ -207,21 +223,31 @@ class ListMenuItemSelectable : ListMenuItem
|
||||||
//
|
//
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
class ListMenuItemText : ListMenuItemSelectable
|
class ListMenuItemTextItem : ListMenuItemSelectable
|
||||||
{
|
{
|
||||||
String mText;
|
String mText;
|
||||||
Font mFont;
|
Font mFont;
|
||||||
int mColor;
|
int mColor;
|
||||||
int mColorSelected;
|
int mColorSelected;
|
||||||
|
|
||||||
void Init(int x, int y, int height, int hotkey, String text, Font font, int color, int color2, Name child, int param = 0)
|
void Init(ListMenuDescriptor desc, String text, String hotkey, Name child, int param = 0)
|
||||||
|
{
|
||||||
|
Super.Init(desc.mXpos, desc.mYpos, desc.mLinespacing, child, param);
|
||||||
|
mText = text;
|
||||||
|
mFont = desc.mFont;
|
||||||
|
mColor = desc.mFontColor;
|
||||||
|
mColorSelected = desc.mFontcolor2;
|
||||||
|
mHotkey = hotkey.CharAt(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitDirect(int x, int y, int height, String hotkey, String text, Font font, int color, int color2, Name child, int param = 0)
|
||||||
{
|
{
|
||||||
Super.Init(x, y, height, child, param);
|
Super.Init(x, y, height, child, param);
|
||||||
mText = text;
|
mText = text;
|
||||||
mFont = font;
|
mFont = font;
|
||||||
mColor = color;
|
mColor = color;
|
||||||
mColorSelected = color2;
|
mColorSelected = color2;
|
||||||
mHotkey = hotkey;
|
mHotkey = hotkey.CharAt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
override void Drawer(bool selected)
|
override void Drawer(bool selected)
|
||||||
|
@ -241,14 +267,21 @@ class ListMenuItemText : ListMenuItemSelectable
|
||||||
//
|
//
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
class ListMenuItemPatch : ListMenuItemSelectable
|
class ListMenuItemPatchItem : ListMenuItemSelectable
|
||||||
{
|
{
|
||||||
TextureID mTexture;
|
TextureID mTexture;
|
||||||
|
|
||||||
void Init(int x, int y, int height, int hotkey, TextureID patch, Name child, int param = 0)
|
void Init(ListMenuDescriptor desc, TextureID patch, String hotkey, Name child, int param = 0)
|
||||||
|
{
|
||||||
|
Super.Init(desc.mXpos, desc.mYpos, desc.mLinespacing, child, param);
|
||||||
|
mHotkey = hotkey.CharAt(0);
|
||||||
|
mTexture = patch;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitDirect(int x, int y, int height, TextureID patch, String hotkey, Name child, int param = 0)
|
||||||
{
|
{
|
||||||
Super.Init(x, y, height, child, param);
|
Super.Init(x, y, height, child, param);
|
||||||
mHotkey = hotkey;
|
mHotkey = hotkey.CharAt(0);
|
||||||
mTexture = patch;
|
mTexture = patch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,17 +29,15 @@ class MenuItemBase : Object native
|
||||||
virtual bool SetValue(int i, int value) { return false; }
|
virtual bool SetValue(int i, int value) { return false; }
|
||||||
virtual bool, int GetValue(int i) { return false, 0; }
|
virtual bool, int GetValue(int i) { return false, 0; }
|
||||||
virtual void Enable(bool on) { mEnabled = on; }
|
virtual void Enable(bool on) { mEnabled = on; }
|
||||||
// this can only be made scripted once all items are converted, because it is called from the colorpicker menu.
|
virtual bool MenuEvent (int mkey, bool fromcontroller) { return false; }
|
||||||
native virtual bool MenuEvent (int mkey, bool fromcontroller);// { return false; }
|
|
||||||
virtual bool MouseEvent(int type, int x, int y) { return false; }
|
virtual bool MouseEvent(int type, int x, int y) { return false; }
|
||||||
virtual bool CheckHotkey(int c) { return false; }
|
virtual bool CheckHotkey(int c) { return false; }
|
||||||
virtual int GetWidth() { return 0; }
|
virtual int GetWidth() { return 0; }
|
||||||
virtual void OffsetPositionY(int ydelta) { mYpos += ydelta; }
|
|
||||||
virtual int GetY() { return mYpos; }
|
|
||||||
virtual int GetX() { return mXpos; }
|
|
||||||
virtual void SetX(int x) { mXpos = x; }
|
|
||||||
virtual int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) { return indent; }
|
virtual int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) { return indent; }
|
||||||
|
|
||||||
|
void OffsetPositionY(int ydelta) { mYpos += ydelta; }
|
||||||
|
int GetY() { return mYpos; }
|
||||||
|
int GetX() { return mXpos; }
|
||||||
|
void SetX(int x) { mXpos = x; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ class ListMenuItemPlayerDisplay : ListMenuItem
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
void Init(ListMenuDescriptor menu, int x, int y, Color c1, Color c2, bool np, Name command)
|
void Init(ListMenuDescriptor menu, Name command, int x, int y, Color c1, Color c2, bool np = false)
|
||||||
{
|
{
|
||||||
Super.Init(x, y, command);
|
Super.Init(x, y, command);
|
||||||
mOwner = menu;
|
mOwner = menu;
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
//
|
//
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
class PlayerNameBox : ListMenuItemSelectable
|
class ListMenuItemPlayerNameBox : ListMenuItemSelectable
|
||||||
{
|
{
|
||||||
String mText;
|
String mText;
|
||||||
Font mFont;
|
Font mFont;
|
||||||
|
@ -55,6 +55,23 @@ class PlayerNameBox : ListMenuItemSelectable
|
||||||
//
|
//
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
|
void Init(ListMenuDescriptor desc, String text, int frameofs, Name command)
|
||||||
|
{
|
||||||
|
Super.Init(desc.mXpos, desc.mYpos, desc.mLinespacing, command);
|
||||||
|
mText = text;
|
||||||
|
mFont = font;
|
||||||
|
mFontColor = color;
|
||||||
|
mFrameSize = frameofs;
|
||||||
|
mPlayerName = "";
|
||||||
|
mEntering = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
//
|
||||||
|
// Player's name
|
||||||
|
//
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
void Init(int x, int y, int height, int frameofs, String text, Font font, int color, Name command)
|
void Init(int x, int y, int height, int frameofs, String text, Font font, int color, Name command)
|
||||||
{
|
{
|
||||||
Super.Init(x, y, height, command);
|
Super.Init(x, y, height, command);
|
||||||
|
@ -197,7 +214,7 @@ class PlayerNameBox : ListMenuItemSelectable
|
||||||
//
|
//
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
class DValueTextItem : ListMenuItemSelectable
|
class ListMenuItemValueText : ListMenuItemSelectable
|
||||||
{
|
{
|
||||||
Array<String> mSelections;
|
Array<String> mSelections;
|
||||||
String mText;
|
String mText;
|
||||||
|
@ -212,7 +229,28 @@ class DValueTextItem : ListMenuItemSelectable
|
||||||
//
|
//
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
void Init(int x, int y, int height, String text, Font font, int color, int valuecolor, Name command, Name values)
|
void Init(ListMenuDescriptor desc, String text, Name command, Name values = 'None')
|
||||||
|
{
|
||||||
|
Super.Init(desc.mXpos, desc.mYpos, desc.mLinespacing, command);
|
||||||
|
mText = text;
|
||||||
|
mFont = desc.mFont;
|
||||||
|
mFontColor = desc.mFontColor;
|
||||||
|
mFontColor2 = desc.mFontColor2;
|
||||||
|
mSelection = 0;
|
||||||
|
let cnt = OptionValues.GetCount(values);
|
||||||
|
for(int i = 0; i < cnt; i++)
|
||||||
|
{
|
||||||
|
SetString(i, OptionValues.GetText(values, i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
//
|
||||||
|
// items for the player menu
|
||||||
|
//
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
void InitDirect(int x, int y, int height, String text, Font font, int color, int valuecolor, Name command, Name values)
|
||||||
{
|
{
|
||||||
Super.Init(x, y, height, command);
|
Super.Init(x, y, height, command);
|
||||||
mText = text;
|
mText = text;
|
||||||
|
@ -318,7 +356,7 @@ class DValueTextItem : ListMenuItemSelectable
|
||||||
//
|
//
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
class DSliderItem : ListMenuItemSelectable
|
class ListMenuItemSlider : ListMenuItemSelectable
|
||||||
{
|
{
|
||||||
String mText;
|
String mText;
|
||||||
Font mFont;
|
Font mFont;
|
||||||
|
@ -333,7 +371,25 @@ class DSliderItem : ListMenuItemSelectable
|
||||||
//
|
//
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
void Init(int x, int y, int height, String text, Font font, int color, Name command, int min, int max, int step)
|
void Init(ListMenuItemDescriptor desc, String text, Name command, int min, int max, int step)
|
||||||
|
{
|
||||||
|
Super.Init(desc.mXpos, desc.mYpos, desc.mLinespacing, command);
|
||||||
|
mText = text;
|
||||||
|
mFont = desc.mFont;
|
||||||
|
mFontColor = desc.mFontColor;
|
||||||
|
mSelection = 0;
|
||||||
|
mMinrange = min;
|
||||||
|
mMaxrange = max;
|
||||||
|
mStep = step;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
//
|
||||||
|
// items for the player menu
|
||||||
|
//
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
void InitDirect(int x, int y, int height, String text, Font font, int color, Name command, int min, int max, int step)
|
||||||
{
|
{
|
||||||
Super.Init(x, y, height, command);
|
Super.Init(x, y, height, command);
|
||||||
mText = text;
|
mText = text;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue