- the keybinding control works again, this time fully scripted.
This commit is contained in:
parent
2e9c1ec3f3
commit
dbf3530696
19 changed files with 161 additions and 162 deletions
|
|
@ -48,9 +48,6 @@
|
|||
#include "d_event.h"
|
||||
#include "d_gui.h"
|
||||
|
||||
#define NO_IMP
|
||||
#include "menu/optionmenuitems.h"
|
||||
|
||||
class DColorPickerMenu : public DOptionMenu
|
||||
{
|
||||
DECLARE_CLASS(DColorPickerMenu, DOptionMenu)
|
||||
|
|
|
|||
|
|
@ -51,10 +51,6 @@
|
|||
#include "i_music.h"
|
||||
#include "m_joy.h"
|
||||
|
||||
#define NO_IMP
|
||||
#include "optionmenuitems.h"
|
||||
|
||||
|
||||
static TArray<IJoystickConfig *> Joysticks;
|
||||
IJoystickConfig *SELECTED_JOYSTICK;
|
||||
|
||||
|
|
|
|||
|
|
@ -191,6 +191,26 @@ bool DMenu::Responder (event_t *ev)
|
|||
return false;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DMenu, Responder)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DMenu);
|
||||
PARAM_POINTER(ev, event_t);
|
||||
ACTION_RETURN_BOOL(self->Responder(ev));
|
||||
}
|
||||
|
||||
bool DMenu::CallResponder(event_t *ev)
|
||||
{
|
||||
IFVIRTUAL(DMenu, Responder)
|
||||
{
|
||||
VMValue params[] = { (DObject*)this, ev};
|
||||
int retval;
|
||||
VMReturn ret(&retval);
|
||||
GlobalVMStack.Call(func, params, 2, &ret, 1, nullptr);
|
||||
return !!retval;
|
||||
}
|
||||
else return Responder(ev);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
|
|
@ -386,6 +406,20 @@ void DMenu::CallDrawer()
|
|||
else Drawer();
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DMenu, Close)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DMenu);
|
||||
self->Close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DMenu, GetItem)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DMenu);
|
||||
PARAM_NAME(name);
|
||||
ACTION_RETURN_POINTER(self->GetItem(name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool DMenu::DimAllowed()
|
||||
|
|
@ -395,6 +429,14 @@ bool DMenu::DimAllowed()
|
|||
|
||||
bool DMenu::TranslateKeyboardEvents()
|
||||
{
|
||||
IFVIRTUAL(DMenu, TranslateKeyboardEvents)
|
||||
{
|
||||
VMValue params[] = { (DObject*)this };
|
||||
int retval;
|
||||
VMReturn ret(&retval);
|
||||
GlobalVMStack.Call(func, params, countof(params), &ret, 1, nullptr);
|
||||
return !!retval;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -444,6 +486,13 @@ void M_ActivateMenu(DMenu *menu)
|
|||
GC::WriteBarrier(DMenu::CurrentMenu);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DMenu, ActivateMenu)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DMenu);
|
||||
M_ActivateMenu(self);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
|
|
@ -631,7 +680,7 @@ bool M_Responder (event_t *ev)
|
|||
}
|
||||
|
||||
// pass everything else on to the current menu
|
||||
return DMenu::CurrentMenu->Responder(ev);
|
||||
return DMenu::CurrentMenu->CallResponder(ev);
|
||||
}
|
||||
else if (DMenu::CurrentMenu->TranslateKeyboardEvents())
|
||||
{
|
||||
|
|
@ -652,7 +701,7 @@ bool M_Responder (event_t *ev)
|
|||
default:
|
||||
if (!keyup)
|
||||
{
|
||||
return DMenu::CurrentMenu->Responder(ev);
|
||||
return DMenu::CurrentMenu->CallResponder(ev);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -739,7 +788,7 @@ bool M_Responder (event_t *ev)
|
|||
return true;
|
||||
}
|
||||
}
|
||||
return DMenu::CurrentMenu->Responder(ev) || !keyup;
|
||||
return DMenu::CurrentMenu->CallResponder(ev) || !keyup;
|
||||
}
|
||||
else if (MenuEnabled)
|
||||
{
|
||||
|
|
@ -1094,6 +1143,8 @@ CCMD(reset2saved)
|
|||
//native void OptionMenuDescriptor.CalcIndent();
|
||||
//native OptionMenuItem OptionMenuDescriptor.GetItem(Name iname);
|
||||
|
||||
DEFINE_FIELD(DMenu, mParentMenu)
|
||||
|
||||
DEFINE_FIELD(DMenuDescriptor, mMenuName)
|
||||
DEFINE_FIELD(DMenuDescriptor, mNetgameMessage)
|
||||
DEFINE_FIELD(DMenuDescriptor, mClass)
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ public:
|
|||
virtual void Ticker ();
|
||||
virtual void Drawer ();
|
||||
virtual bool DimAllowed ();
|
||||
virtual bool TranslateKeyboardEvents();
|
||||
/*virtual */bool TranslateKeyboardEvents();
|
||||
virtual void Close();
|
||||
virtual bool MouseEvent(int type, int x, int y);
|
||||
|
||||
|
|
@ -277,7 +277,9 @@ public:
|
|||
virtual bool CheckFocus(DMenuItemBase *fc) { return false; }
|
||||
virtual void ReleaseFocus() {}
|
||||
|
||||
virtual DMenuItemBase *GetItem(FName name) { return nullptr; }
|
||||
|
||||
bool CallResponder(event_t *ev);
|
||||
bool CallMenuEvent(int mkey, bool fromcontroller);
|
||||
bool CallMouseEvent(int type, int x, int y);
|
||||
void CallDrawer();
|
||||
|
|
@ -466,7 +468,7 @@ public:
|
|||
void Drawer ();
|
||||
bool MenuEvent (int mkey, bool fromcontroller);
|
||||
bool Responder(event_t *ev);
|
||||
bool TranslateKeyboardEvents();
|
||||
//bool TranslateKeyboardEvents();
|
||||
bool MouseEvent(int type, int x, int y);
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -52,8 +52,6 @@
|
|||
#include "i_sound.h"
|
||||
#include "cmdlib.h"
|
||||
|
||||
#include "optionmenuitems.h"
|
||||
|
||||
|
||||
|
||||
void ClearSaveGames();
|
||||
|
|
|
|||
|
|
@ -96,10 +96,12 @@ DTextEnterMenu::DTextEnterMenu(DMenu *parent, char *textbuffer, int maxlen, int
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
/*
|
||||
bool DTextEnterMenu::TranslateKeyboardEvents()
|
||||
{
|
||||
return mInputGridOkay;
|
||||
}
|
||||
*/
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
** optionmenuitems.h
|
||||
** Control items for option menus
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** 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 "v_text.h"
|
||||
#include "gstrings.h"
|
||||
|
||||
|
||||
void M_DrawConText (int color, int x, int y, const char *str);
|
||||
void M_SetVideoMode();
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// This class is used to capture the key to be used as the new key binding
|
||||
// for a control item
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
class DEnterKey : public DMenu
|
||||
{
|
||||
DECLARE_CLASS(DEnterKey, DMenu)
|
||||
|
||||
int *pKey;
|
||||
|
||||
public:
|
||||
DEnterKey(DMenu *parent, int *keyptr)
|
||||
: DMenu(parent)
|
||||
{
|
||||
pKey = keyptr;
|
||||
SetMenuMessage(1);
|
||||
menuactive = MENU_WaitKey; // There should be a better way to disable GUI capture...
|
||||
}
|
||||
|
||||
bool TranslateKeyboardEvents()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void SetMenuMessage(int which)
|
||||
{
|
||||
if (mParentMenu->IsKindOf(RUNTIME_CLASS(DOptionMenu)))
|
||||
{
|
||||
DOptionMenu *m = barrier_cast<DOptionMenu*>(mParentMenu);
|
||||
DMenuItemBase *it = m->GetItem(NAME_Controlmessage);
|
||||
if (it != NULL)
|
||||
{
|
||||
it->SetValue(0, which);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Responder(event_t *ev)
|
||||
{
|
||||
if (ev->type == EV_KeyDown)
|
||||
{
|
||||
*pKey = ev->data1;
|
||||
menuactive = MENU_On;
|
||||
SetMenuMessage(0);
|
||||
Close();
|
||||
mParentMenu->CallMenuEvent((ev->data1 == KEY_ESCAPE)? MKEY_Abort : MKEY_Input, 0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Drawer()
|
||||
{
|
||||
mParentMenu->CallDrawer();
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef NO_IMP
|
||||
IMPLEMENT_CLASS(DEnterKey, true, false)
|
||||
#endif
|
||||
|
||||
|
|
@ -54,10 +54,6 @@
|
|||
#include "sbar.h"
|
||||
#include "hardware.h"
|
||||
|
||||
#define NO_IMP
|
||||
#include "optionmenuitems.h"
|
||||
|
||||
|
||||
/*=======================================
|
||||
*
|
||||
* Video Modes Menu
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue