2016-04-01 00:12:10 +02:00
|
|
|
/* Copyright (c) 2002-2012 Croteam Ltd.
|
2016-03-31 02:38:57 +02:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of version 2 of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation
|
|
|
|
|
2016-04-01 00:12:10 +02:00
|
|
|
|
2016-03-31 02:38:57 +02:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
|
2016-03-11 22:45:21 +01:00
|
|
|
|
|
|
|
#include "StdH.h"
|
|
|
|
#include <Engine/Base/KeyNames.h>
|
|
|
|
#include <Engine/CurrentVersion.h>
|
|
|
|
#include <GameMP/LCDDrawing.h>
|
|
|
|
#include "LevelInfo.h"
|
|
|
|
#include "VarList.h"
|
|
|
|
#include "MenuGadget.h"
|
|
|
|
|
|
|
|
extern CSoundData *_psdSelect;
|
|
|
|
|
|
|
|
extern BOOL _bDefiningKey = FALSE;
|
|
|
|
extern BOOL _bEditingString = FALSE;
|
|
|
|
extern CMenuGadget *_pmgLastActivatedGadget = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
CMenuGadget::CMenuGadget(void)
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
mg_pmgLeft = NULL;
|
|
|
|
mg_pmgRight = NULL;
|
|
|
|
mg_pmgUp = NULL;
|
|
|
|
mg_pmgDown = NULL;
|
|
|
|
|
|
|
|
mg_bVisible = TRUE;
|
|
|
|
mg_bEnabled = TRUE;
|
|
|
|
mg_bLabel = FALSE;
|
|
|
|
mg_bFocused = FALSE;
|
|
|
|
mg_iInList = -1; // not in list
|
2016-03-11 22:45:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMenuGadget::OnActivate(void)
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
NOTHING;
|
2016-03-11 22:45:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// return TRUE if handled
|
|
|
|
BOOL CMenuGadget::OnKeyDown(int iVKey)
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
// if return pressed
|
|
|
|
if (iVKey == VK_RETURN || iVKey == VK_LBUTTON) {
|
|
|
|
// activate
|
|
|
|
OnActivate();
|
|
|
|
// key is handled
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
// key is not handled
|
|
|
|
return FALSE;
|
2016-03-11 22:45:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOL CMenuGadget::OnChar(MSG msg)
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
// key is not handled
|
|
|
|
return FALSE;
|
2016-03-11 22:45:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CMenuGadget::OnSetFocus(void)
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
mg_bFocused = TRUE;
|
|
|
|
if (!IsSeparator())
|
|
|
|
{
|
|
|
|
PlayMenuSound(_psdSelect);
|
|
|
|
IFeel_PlayEffect("Menu_select");
|
|
|
|
}
|
2016-03-11 22:45:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMenuGadget::OnKillFocus(void)
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
mg_bFocused = FALSE;
|
2016-03-11 22:45:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMenuGadget::Appear(void)
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
mg_bVisible = TRUE;
|
2016-03-11 22:45:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMenuGadget::Disappear(void)
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
mg_bVisible = FALSE;
|
|
|
|
mg_bFocused = FALSE;
|
2016-03-11 22:45:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMenuGadget::Think(void)
|
|
|
|
{
|
|
|
|
}
|
2016-03-29 22:49:32 +02:00
|
|
|
|
2016-03-11 22:45:21 +01:00
|
|
|
void CMenuGadget::OnMouseOver(PIX pixI, PIX pixJ)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// get current color for the gadget
|
|
|
|
COLOR CMenuGadget::GetCurrentColor(void)
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
// use normal colors
|
|
|
|
COLOR colUnselected = LCDGetColor(C_GREEN, "unselected");
|
|
|
|
COLOR colSelected = LCDGetColor(C_WHITE, "selected");
|
|
|
|
// if disabled
|
|
|
|
if (!mg_bEnabled) {
|
|
|
|
// use a bit darker colors
|
|
|
|
colUnselected = LCDGetColor(C_dGREEN, "disabled unselected");
|
|
|
|
colSelected = LCDGetColor(C_GRAY, "disabled selected");
|
|
|
|
// if label
|
|
|
|
if (mg_bLabel) {
|
|
|
|
// use white
|
|
|
|
colUnselected = colSelected = LCDGetColor(C_WHITE, "label");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// use unselected color
|
|
|
|
COLOR colRet = colUnselected;
|
|
|
|
// if selected
|
|
|
|
if (mg_bFocused) {
|
|
|
|
// oscilate towards selected color
|
|
|
|
FLOAT tmNow = _pTimer->GetHighPrecisionTimer().GetSeconds();
|
|
|
|
colRet = LerpColor((colUnselected >> 1) & 0x7F7F7F7F, colSelected, sin(tmNow*10.0f)*0.5f + 0.5f);
|
|
|
|
}
|
|
|
|
|
|
|
|
return colRet | CT_OPAQUE;
|
2016-03-11 22:45:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMenuGadget::Render(CDrawPort *pdp)
|
|
|
|
{
|
|
|
|
}
|