mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-25 05:31:00 +00:00
- ColorpickerMenu.MouseEvent exported.
This commit is contained in:
parent
07ba75762b
commit
be9b2b38fc
10 changed files with 160 additions and 78 deletions
|
@ -124,55 +124,6 @@ public:
|
||||||
//
|
//
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
bool MouseEvent(int type, int mx, int my)
|
|
||||||
{
|
|
||||||
int olditem = mDesc->mSelectedItem;
|
|
||||||
bool res = Super::MouseEvent(type, mx, my);
|
|
||||||
|
|
||||||
if (mDesc->mSelectedItem == -1 || mDesc->mSelectedItem == mStartItem+7)
|
|
||||||
{
|
|
||||||
int y = (-mDesc->mPosition + BigFont->GetHeight() + mDesc->mItems.Size() * OptionSettings.mLinespacing) * CleanYfac_1;
|
|
||||||
int h = (screen->GetHeight() - y) / 16;
|
|
||||||
int fh = OptionSettings.mLinespacing * CleanYfac_1;
|
|
||||||
int w = fh;
|
|
||||||
int yy = y + 2 * CleanYfac_1;
|
|
||||||
int indent = (screen->GetWidth() / 2);
|
|
||||||
|
|
||||||
if (h > fh) h = fh;
|
|
||||||
else if (h < 4) return res; // no space to draw it.
|
|
||||||
|
|
||||||
int box_y = y - 2 * CleanYfac_1;
|
|
||||||
int box_x = indent - 16*w;
|
|
||||||
|
|
||||||
if (mx >= box_x && mx < box_x + 16*w && my >= box_y && my < box_y + 16*h)
|
|
||||||
{
|
|
||||||
int cell_x = (mx - box_x) / w;
|
|
||||||
int cell_y = (my - box_y) / h;
|
|
||||||
|
|
||||||
if (olditem != mStartItem+7 || cell_x != mGridPosX || cell_y != mGridPosY)
|
|
||||||
{
|
|
||||||
mGridPosX = cell_x;
|
|
||||||
mGridPosY = cell_y;
|
|
||||||
//S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", snd_menuvolume, ATTN_NONE);
|
|
||||||
}
|
|
||||||
mDesc->mSelectedItem = mStartItem+7;
|
|
||||||
if (type == MOUSE_Release)
|
|
||||||
{
|
|
||||||
MenuEvent(MKEY_Enter, true);
|
|
||||||
if (m_use_mouse == 2) mDesc->mSelectedItem = -1;
|
|
||||||
}
|
|
||||||
res = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
void Drawer()
|
void Drawer()
|
||||||
{
|
{
|
||||||
Super::Drawer();
|
Super::Drawer();
|
||||||
|
|
|
@ -149,7 +149,7 @@ bool DMenu::Responder (event_t *ev)
|
||||||
res = MouseEventBack(MOUSE_Click, ev->data1, ev->data2);
|
res = MouseEventBack(MOUSE_Click, ev->data1, ev->data2);
|
||||||
// make the menu's mouse handler believe that the current coordinate is outside the valid range
|
// make the menu's mouse handler believe that the current coordinate is outside the valid range
|
||||||
if (res) ev->data2 = -1;
|
if (res) ev->data2 = -1;
|
||||||
res |= MouseEvent(MOUSE_Click, ev->data1, ev->data2);
|
res |= CallMouseEvent(MOUSE_Click, ev->data1, ev->data2);
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
SetCapture();
|
SetCapture();
|
||||||
|
@ -163,7 +163,7 @@ bool DMenu::Responder (event_t *ev)
|
||||||
{
|
{
|
||||||
res = MouseEventBack(MOUSE_Move, ev->data1, ev->data2);
|
res = MouseEventBack(MOUSE_Move, ev->data1, ev->data2);
|
||||||
if (res) ev->data2 = -1;
|
if (res) ev->data2 = -1;
|
||||||
res |= MouseEvent(MOUSE_Move, ev->data1, ev->data2);
|
res |= CallMouseEvent(MOUSE_Move, ev->data1, ev->data2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ev->subtype == EV_GUI_LButtonUp)
|
else if (ev->subtype == EV_GUI_LButtonUp)
|
||||||
|
@ -173,7 +173,7 @@ bool DMenu::Responder (event_t *ev)
|
||||||
ReleaseCapture();
|
ReleaseCapture();
|
||||||
res = MouseEventBack(MOUSE_Release, ev->data1, ev->data2);
|
res = MouseEventBack(MOUSE_Release, ev->data1, ev->data2);
|
||||||
if (res) ev->data2 = -1;
|
if (res) ev->data2 = -1;
|
||||||
res |= MouseEvent(MOUSE_Release, ev->data1, ev->data2);
|
res |= CallMouseEvent(MOUSE_Release, ev->data1, ev->data2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ bool DMenu::CallMenuEvent(int mkey, bool fromcontroller)
|
||||||
int retval;
|
int retval;
|
||||||
VMReturn ret(&retval);
|
VMReturn ret(&retval);
|
||||||
GlobalVMStack.Call(func, params, 3, &ret, 1, nullptr);
|
GlobalVMStack.Call(func, params, 3, &ret, 1, nullptr);
|
||||||
return retval;
|
return !!retval;
|
||||||
}
|
}
|
||||||
else return MenuEvent(mkey, fromcontroller);
|
else return MenuEvent(mkey, fromcontroller);
|
||||||
}
|
}
|
||||||
|
@ -253,6 +253,28 @@ bool DMenu::MouseEvent(int type, int x, int y)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(DMenu, MouseEvent)
|
||||||
|
{
|
||||||
|
PARAM_SELF_PROLOGUE(DMenu);
|
||||||
|
PARAM_INT(type);
|
||||||
|
PARAM_INT(x);
|
||||||
|
PARAM_INT(y);
|
||||||
|
ACTION_RETURN_BOOL(self->MouseEvent(type, x, y));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DMenu::CallMouseEvent(int type, int x, int y)
|
||||||
|
{
|
||||||
|
IFVIRTUAL(DMenu, MouseEvent)
|
||||||
|
{
|
||||||
|
VMValue params[] = { (DObject*)this, type, x, y };
|
||||||
|
int retval;
|
||||||
|
VMReturn ret(&retval);
|
||||||
|
GlobalVMStack.Call(func, params, 4, &ret, 1, nullptr);
|
||||||
|
return !!retval;
|
||||||
|
}
|
||||||
|
else return MouseEvent (type, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -1034,7 +1056,7 @@ CCMD(reset2saved)
|
||||||
//native OptionMenuItem OptionMenuDescriptor.GetItem(Name iname);
|
//native OptionMenuItem OptionMenuDescriptor.GetItem(Name iname);
|
||||||
//native void OptionMenuItem.drawLabel(int indent, int y, EColorRange color, bool grayed = false);
|
//native void OptionMenuItem.drawLabel(int indent, int y, EColorRange color, bool grayed = false);
|
||||||
|
|
||||||
DEFINE_FIELD(DMenuDescriptor, mMenuName)
|
DEFINE_FIELD(DMenuDescriptor, mMenuName)
|
||||||
DEFINE_FIELD(DMenuDescriptor, mNetgameMessage)
|
DEFINE_FIELD(DMenuDescriptor, mNetgameMessage)
|
||||||
DEFINE_FIELD(DMenuDescriptor, mClass)
|
DEFINE_FIELD(DMenuDescriptor, mClass)
|
||||||
|
|
||||||
|
@ -1062,3 +1084,11 @@ DEFINE_FIELD(DOptionMenu, VisBottom)
|
||||||
DEFINE_FIELD(DOptionMenu, mFocusControl)
|
DEFINE_FIELD(DOptionMenu, mFocusControl)
|
||||||
DEFINE_FIELD(DOptionMenu, mDesc)
|
DEFINE_FIELD(DOptionMenu, mDesc)
|
||||||
|
|
||||||
|
DEFINE_FIELD(FOptionMenuSettings, mTitleColor)
|
||||||
|
DEFINE_FIELD(FOptionMenuSettings, mFontColor)
|
||||||
|
DEFINE_FIELD(FOptionMenuSettings, mFontColorValue)
|
||||||
|
DEFINE_FIELD(FOptionMenuSettings, mFontColorMore)
|
||||||
|
DEFINE_FIELD(FOptionMenuSettings, mFontColorHeader)
|
||||||
|
DEFINE_FIELD(FOptionMenuSettings, mFontColorHighlight)
|
||||||
|
DEFINE_FIELD(FOptionMenuSettings, mFontColorSelection)
|
||||||
|
DEFINE_FIELD(FOptionMenuSettings, mLinespacing)
|
||||||
|
|
|
@ -244,6 +244,7 @@ public:
|
||||||
virtual bool MouseEvent(int type, int x, int y);
|
virtual bool MouseEvent(int type, int x, int y);
|
||||||
|
|
||||||
bool CallMenuEvent(int mkey, bool fromcontroller);
|
bool CallMenuEvent(int mkey, bool fromcontroller);
|
||||||
|
bool CallMouseEvent(int type, int x, int y);
|
||||||
|
|
||||||
bool MouseEventBack(int type, int x, int y);
|
bool MouseEventBack(int type, int x, int y);
|
||||||
void SetCapture();
|
void SetCapture();
|
||||||
|
|
|
@ -7747,6 +7747,7 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
|
||||||
if (MethodName == NAME_Size)
|
if (MethodName == NAME_Size)
|
||||||
{
|
{
|
||||||
FxExpression *x = new FxMemberIdentifier(Self, NAME_Size, ScriptPosition); // todo: obfuscate the name to prevent direct access.
|
FxExpression *x = new FxMemberIdentifier(Self, NAME_Size, ScriptPosition); // todo: obfuscate the name to prevent direct access.
|
||||||
|
Self->ValueType = static_cast<PDynArray*>(Self->ValueType)->BackingType;
|
||||||
Self = nullptr;
|
Self = nullptr;
|
||||||
delete this;
|
delete this;
|
||||||
return x->Resolve(ctx);
|
return x->Resolve(ctx);
|
||||||
|
|
|
@ -54,6 +54,8 @@
|
||||||
#include "p_checkposition.h"
|
#include "p_checkposition.h"
|
||||||
#include "r_sky.h"
|
#include "r_sky.h"
|
||||||
#include "v_font.h"
|
#include "v_font.h"
|
||||||
|
#include "v_video.h"
|
||||||
|
#include "menu/menu.h"
|
||||||
|
|
||||||
static TArray<FPropertyInfo*> properties;
|
static TArray<FPropertyInfo*> properties;
|
||||||
static TArray<AFuncDesc> AFTable;
|
static TArray<AFuncDesc> AFTable;
|
||||||
|
@ -841,6 +843,34 @@ void InitThingdef()
|
||||||
fieldptr = new PField("intermissionfont", fontptr, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&IntermissionFont);
|
fieldptr = new PField("intermissionfont", fontptr, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&IntermissionFont);
|
||||||
Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr);
|
Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr);
|
||||||
|
|
||||||
|
fieldptr = new PField("CleanXFac", TypeSInt32, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&CleanXfac);
|
||||||
|
Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr);
|
||||||
|
|
||||||
|
fieldptr = new PField("CleanYFac", TypeSInt32, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&CleanYfac);
|
||||||
|
Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr);
|
||||||
|
|
||||||
|
fieldptr = new PField("CleanWidth", TypeSInt32, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&CleanWidth);
|
||||||
|
Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr);
|
||||||
|
|
||||||
|
fieldptr = new PField("CleanHeight", TypeSInt32, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&CleanHeight);
|
||||||
|
Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr);
|
||||||
|
|
||||||
|
fieldptr = new PField("CleanXFac_1", TypeSInt32, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&CleanXfac_1);
|
||||||
|
Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr);
|
||||||
|
|
||||||
|
fieldptr = new PField("CleanYFac_1", TypeSInt32, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&CleanYfac_1);
|
||||||
|
Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr);
|
||||||
|
|
||||||
|
fieldptr = new PField("CleanWidth_1", TypeSInt32, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&CleanWidth_1);
|
||||||
|
Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr);
|
||||||
|
|
||||||
|
fieldptr = new PField("CleanHeight_1", TypeSInt32, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&CleanHeight_1);
|
||||||
|
Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr);
|
||||||
|
|
||||||
|
fieldptr = new PField("OptionMenuSettings", NewStruct("FOptionMenuSettings", nullptr), VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&OptionSettings);
|
||||||
|
Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr);
|
||||||
|
|
||||||
|
|
||||||
// Argh. It sucks when bad hacks need to be supported. WP_NOCHANGE is just a bogus pointer but it used everywhere as a special flag.
|
// Argh. It sucks when bad hacks need to be supported. WP_NOCHANGE is just a bogus pointer but it used everywhere as a special flag.
|
||||||
// It cannot be defined as constant because constants can either be numbers or strings but nothing else, so the only 'solution'
|
// It cannot be defined as constant because constants can either be numbers or strings but nothing else, so the only 'solution'
|
||||||
// is to create a static variable from it and reference that in the script. Yuck!!!
|
// is to create a static variable from it and reference that in the script. Yuck!!!
|
||||||
|
|
|
@ -853,6 +853,12 @@ DEFINE_ACTION_FUNCTION(FFont, GetCharWidth)
|
||||||
ACTION_RETURN_INT(self->GetCharWidth(code));
|
ACTION_RETURN_INT(self->GetCharWidth(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(FFont, GetHeight)
|
||||||
|
{
|
||||||
|
PARAM_SELF_STRUCT_PROLOGUE(FFont);
|
||||||
|
ACTION_RETURN_INT(self->GetHeight());
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// Find string width using this font
|
// Find string width using this font
|
||||||
|
|
|
@ -40,7 +40,7 @@ class DCanvas;
|
||||||
struct FRemapTable;
|
struct FRemapTable;
|
||||||
class FTexture;
|
class FTexture;
|
||||||
|
|
||||||
enum EColorRange
|
enum EColorRange : int
|
||||||
{
|
{
|
||||||
CR_UNDEFINED = -1,
|
CR_UNDEFINED = -1,
|
||||||
CR_BRICK,
|
CR_BRICK,
|
||||||
|
@ -67,7 +67,6 @@ enum EColorRange
|
||||||
CR_DARKGRAY,
|
CR_DARKGRAY,
|
||||||
CR_CYAN,
|
CR_CYAN,
|
||||||
NUM_TEXT_COLORS,
|
NUM_TEXT_COLORS,
|
||||||
FORCE_DWORD = 0x7fffffff // required for script access.
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int NumTextColors;
|
extern int NumTextColors;
|
||||||
|
|
|
@ -132,7 +132,12 @@ struct Screen native
|
||||||
CR_CYAN,
|
CR_CYAN,
|
||||||
NUM_TEXT_COLORS
|
NUM_TEXT_COLORS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int CleanWidth, CleanHeight;
|
||||||
|
int CleanXFac, CleanYFac;
|
||||||
|
int CleanWidth_1, CleanHeight_1;
|
||||||
|
int CleanXFac_1, CleanYFac_1;
|
||||||
|
|
||||||
native static Color PaletteColor(int index);
|
native static Color PaletteColor(int index);
|
||||||
native static int GetWidth();
|
native static int GetWidth();
|
||||||
native static int GetHeight();
|
native static int GetHeight();
|
||||||
|
@ -154,6 +159,8 @@ struct Font native
|
||||||
{
|
{
|
||||||
native int GetCharWidth(int code);
|
native int GetCharWidth(int code);
|
||||||
native int StringWidth(String code);
|
native int StringWidth(String code);
|
||||||
|
native int GetHeight();
|
||||||
|
|
||||||
native static int FindFontColor(Name color);
|
native static int FindFontColor(Name color);
|
||||||
native static Font FindFont(Name fontname);
|
native static Font FindFont(Name fontname);
|
||||||
native static Font GetFont(Name fontname);
|
native static Font GetFont(Name fontname);
|
||||||
|
|
|
@ -98,5 +98,54 @@ class ColorpickerMenu : Menu native
|
||||||
return Super.MenuEvent(mkey, fromcontroller);
|
return Super.MenuEvent(mkey, fromcontroller);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
override bool MouseEvent(int type, int mx, int my)
|
||||||
|
{
|
||||||
|
int olditem = mDesc.mSelectedItem;
|
||||||
|
bool res = Super.MouseEvent(type, mx, my);
|
||||||
|
|
||||||
|
if (mDesc.mSelectedItem == -1 || mDesc.mSelectedItem == mStartItem+7)
|
||||||
|
{
|
||||||
|
int y = (-mDesc.mPosition + BigFont.GetHeight() + mDesc.mItems.Size() * OptionMenuSettings.mLinespacing) * CleanYfac_1;
|
||||||
|
int h = (screen.GetHeight() - y) / 16;
|
||||||
|
int fh = OptionMenuSettings.mLinespacing * CleanYfac_1;
|
||||||
|
int w = fh;
|
||||||
|
int yy = y + 2 * CleanYfac_1;
|
||||||
|
int indent = (screen.GetWidth() / 2);
|
||||||
|
|
||||||
|
if (h > fh) h = fh;
|
||||||
|
else if (h < 4) return res; // no space to draw it.
|
||||||
|
|
||||||
|
int box_y = y - 2 * CleanYfac_1;
|
||||||
|
int box_x = indent - 16*w;
|
||||||
|
|
||||||
|
if (mx >= box_x && mx < box_x + 16*w && my >= box_y && my < box_y + 16*h)
|
||||||
|
{
|
||||||
|
int cell_x = (mx - box_x) / w;
|
||||||
|
int cell_y = (my - box_y) / h;
|
||||||
|
|
||||||
|
if (olditem != mStartItem+7 || cell_x != mGridPosX || cell_y != mGridPosY)
|
||||||
|
{
|
||||||
|
mGridPosX = cell_x;
|
||||||
|
mGridPosY = cell_y;
|
||||||
|
//S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", snd_menuvolume, ATTN_NONE);
|
||||||
|
}
|
||||||
|
mDesc.mSelectedItem = mStartItem+7;
|
||||||
|
if (type == MOUSE_Release)
|
||||||
|
{
|
||||||
|
MenuEvent(MKEY_Enter, true);
|
||||||
|
if (m_use_mouse == 2) mDesc.mSelectedItem = -1;
|
||||||
|
}
|
||||||
|
res = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,30 +1,38 @@
|
||||||
|
|
||||||
enum EMenuKey
|
|
||||||
{
|
|
||||||
MKEY_Up,
|
|
||||||
MKEY_Down,
|
|
||||||
MKEY_Left,
|
|
||||||
MKEY_Right,
|
|
||||||
MKEY_PageUp,
|
|
||||||
MKEY_PageDown,
|
|
||||||
MKEY_Enter,
|
|
||||||
MKEY_Back,
|
|
||||||
MKEY_Clear,
|
|
||||||
NUM_MKEYS,
|
|
||||||
|
|
||||||
// These are not buttons but events sent from other menus
|
|
||||||
|
|
||||||
MKEY_Input,
|
|
||||||
MKEY_Abort,
|
|
||||||
MKEY_MBYes,
|
|
||||||
MKEY_MBNo,
|
|
||||||
}
|
|
||||||
|
|
||||||
class Menu : Object native
|
class Menu : Object native
|
||||||
{
|
{
|
||||||
|
enum EMenuKey
|
||||||
|
{
|
||||||
|
MKEY_Up,
|
||||||
|
MKEY_Down,
|
||||||
|
MKEY_Left,
|
||||||
|
MKEY_Right,
|
||||||
|
MKEY_PageUp,
|
||||||
|
MKEY_PageDown,
|
||||||
|
MKEY_Enter,
|
||||||
|
MKEY_Back,
|
||||||
|
MKEY_Clear,
|
||||||
|
NUM_MKEYS,
|
||||||
|
|
||||||
|
// These are not buttons but events sent from other menus
|
||||||
|
|
||||||
|
MKEY_Input,
|
||||||
|
MKEY_Abort,
|
||||||
|
MKEY_MBYes,
|
||||||
|
MKEY_MBNo,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum EMenuMouse
|
||||||
|
{
|
||||||
|
MOUSE_Click,
|
||||||
|
MOUSE_Move,
|
||||||
|
MOUSE_Release
|
||||||
|
};
|
||||||
|
|
||||||
//native static int MenuTime();
|
//native static int MenuTime();
|
||||||
|
|
||||||
native virtual bool MenuEvent (int mkey, bool fromcontroller);
|
native virtual bool MenuEvent (int mkey, bool fromcontroller);
|
||||||
|
native virtual bool MouseEvent(int type, int mx, int my);
|
||||||
|
|
||||||
void MenuSound(Sound snd)
|
void MenuSound(Sound snd)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue