- scriptified the video mode menu (only the part that extends the actual menu class, the entire thing is basically non-modifiable but this code would otherwise stand in the way of properly handling the rest of the menus.)

This commit is contained in:
Christoph Oelckers 2017-02-12 23:05:39 +01:00
parent 7d96f85fe8
commit 2b977f70e6
5 changed files with 137 additions and 55 deletions

View File

@ -93,6 +93,8 @@ int BackbuttonTime;
float BackbuttonAlpha;
static bool MenuEnabled = true;
void M_InitVideoModes();
#define KEY_REPEAT_DELAY (TICRATE*5/12)
#define KEY_REPEAT_RATE (3)
@ -568,6 +570,11 @@ void M_SetMenu(FName menu, int param)
M_StartMessage (GStrings("SAVEDEAD"), 1);
return;
}
case NAME_VideoModeMenu:
M_InitVideoModes();
break;
}
// End of special checks

View File

@ -138,60 +138,6 @@ struct OptionMenuItemScreenResolution // temporary workaround
SRL_HIGHLIGHT = 0x30004,
};
};
class DVideoModeMenu : public DOptionMenu
{
DECLARE_CLASS(DVideoModeMenu, DOptionMenu)
public:
DVideoModeMenu()
{
SetModesMenu (screen->VideoWidth, screen->VideoHeight, DisplayBits);
}
bool MenuEvent(int mkey, bool fromcontroller)
{
if ((mkey == MKEY_Up || mkey == MKEY_Down) && mDesc->mSelectedItem >= 0 &&
mDesc->mSelectedItem < (int)mDesc->mItems.Size())
{
int sel;
bool selected = mDesc->mItems[mDesc->mSelectedItem]->GetValue(OptionMenuItemScreenResolution::SRL_SELECTION, &sel);
bool res = Super::MenuEvent(mkey, fromcontroller);
if (selected) mDesc->mItems[mDesc->mSelectedItem]->SetValue(OptionMenuItemScreenResolution::SRL_SELECTION, sel);
return res;
}
return Super::MenuEvent(mkey, fromcontroller);
}
bool Responder(event_t *ev)
{
if (ev->type == EV_GUI_Event && ev->subtype == EV_GUI_KeyDown &&
(ev->data1 == 't' || ev->data1 == 'T'))
{
if (!GetSelectedSize (&NewWidth, &NewHeight))
{
NewWidth = screen->VideoWidth;
NewHeight = screen->VideoHeight;
}
else
{
OldWidth = screen->VideoWidth;
OldHeight = screen->VideoHeight;
OldBits = DisplayBits;
NewBits = BitTranslate[DummyDepthCvar];
setmodeneeded = true;
testingmode = I_GetTime(false) + 5 * TICRATE;
S_Sound (CHAN_VOICE | CHAN_UI, "menu/choose", snd_menuvolume, ATTN_NONE);
SetModesMenu (NewWidth, NewHeight, NewBits);
return true;
}
}
return Super::Responder(ev);
}
};
IMPLEMENT_CLASS(DVideoModeMenu, false, false)
//=============================================================================
//
@ -382,6 +328,27 @@ static bool GetSelectedSize (int *width, int *height)
return false;
}
DEFINE_ACTION_FUNCTION(DVideoModeMenu, SetSelectedSize)
{
if (!GetSelectedSize (&NewWidth, &NewHeight))
{
NewWidth = screen->VideoWidth;
NewHeight = screen->VideoHeight;
ACTION_RETURN_BOOL(false);
}
else
{
OldWidth = screen->VideoWidth;
OldHeight = screen->VideoHeight;
OldBits = DisplayBits;
NewBits = BitTranslate[DummyDepthCvar];
setmodeneeded = true;
testingmode = I_GetTime(false) + 5 * TICRATE;
SetModesMenu (NewWidth, NewHeight, NewBits);
ACTION_RETURN_BOOL(true);
}
}
//=============================================================================
//
//
@ -460,3 +427,8 @@ static void SetModesMenu (int w, int h, int bits)
}
BuildModesList (w, h, bits);
}
void M_InitVideoModes()
{
SetModesMenu (screen->VideoWidth, screen->VideoHeight, DisplayBits);
}

View File

@ -15,6 +15,7 @@
#include "zscript/menu/playerdisplay.txt"
#include "zscript/menu/playermenu.txt"
#include "zscript/menu/textentermenu.txt"
#include "zscript/menu/videomenu.txt"
#include "zscript/inventory/inventory.txt"
#include "zscript/inventory/inv_misc.txt"

View File

@ -18,6 +18,35 @@ struct InputEvent native
DeviceChange,// a device has been connected or removed
}
enum EGUIEvent
{
GUI_None,
GUI_KeyDown, // data1: unshifted ASCII, data2: shifted ASCII, data3: modifiers
GUI_KeyRepeat, // same
GUI_KeyUp, // same
GUI_Char, // data1: translated character (for user text input), data2: alt down?
GUI_FirstMouseEvent,
GUI_MouseMove,
GUI_LButtonDown,
GUI_LButtonUp,
GUI_LButtonDblClick,
GUI_MButtonDown,
GUI_MButtonUp,
GUI_MButtonDblClick,
GUI_RButtonDown,
GUI_RButtonUp,
GUI_RButtonDblClick,
GUI_WheelUp, // data3: shift/ctrl/alt
GUI_WheelDown, // "
GUI_WheelRight, // "
GUI_WheelLeft, // "
GUI_BackButtonDown,
GUI_BackButtonUp,
GUI_FwdButtonDown,
GUI_FwdButtonUp,
GUI_LastMouseEvent,
};
const KEY_ESCAPE = 0x01;
}
@ -580,7 +609,7 @@ class Floor : Thinker native
waitStair,
resetStair,
// Not to be used as parameters to EV_DoFloor()
// Not to be used as parameters to DoFloor()
genFloorChg0,
genFloorChgT,
genFloorChg

View File

@ -0,0 +1,73 @@
/*
** videomenu.txt
** The video modes menu
**
**---------------------------------------------------------------------------
** Copyright 2001-2010 Randy Heit
** Copyright 2010-2017 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.
**---------------------------------------------------------------------------
**
*/
//=============================================================================
//
//
//
//=============================================================================
class VideoModeMenu : OptionMenu
{
native static bool SetSelectedSize();
override bool MenuEvent(int mkey, bool fromcontroller)
{
if ((mkey == MKEY_Up || mkey == MKEY_Down) && mDesc.mSelectedItem >= 0 && mDesc.mSelectedItem < mDesc.mItems.Size())
{
int sel;
bool selected;
[selected, sel] = mDesc.mItems[mDesc.mSelectedItem].GetValue(OptionMenuItemScreenResolution.SRL_SELECTION);
bool res = Super.MenuEvent(mkey, fromcontroller);
if (selected) mDesc.mItems[mDesc.mSelectedItem].SetValue(OptionMenuItemScreenResolution.SRL_SELECTION, sel);
return res;
}
return Super.MenuEvent(mkey, fromcontroller);
}
override bool Responder(InputEvent ev)
{
if (ev.type == InputEvent.GUI_Event && ev.subtype == InputEvent.GUI_KeyDown && (ev.data1 == 0x54 || ev.data1 == 0x74))
{
if (SetSelectedSize())
{
MenuSound ("menu/choose");
return true;
}
}
return Super.Responder(ev);
}
}