mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-27 04:00:42 +00:00
- renamed the Customizer to 'Delegate' because this works very much like a delegate in Objective-C.
- route menu sound calls through the delegate to better deal with differences between games.
This commit is contained in:
parent
603c3b50ec
commit
0968a9d97e
19 changed files with 86 additions and 50 deletions
|
@ -87,7 +87,7 @@ static void drawTextScreenBackground(void)
|
|||
}
|
||||
}
|
||||
|
||||
// One these screens get scriptified this should use the version in menuCustomizerBlood.
|
||||
// One these screens get scriptified this should use the version in BloodMenuDelegate.
|
||||
static void DrawCaption(const char* text)
|
||||
{
|
||||
double scalex = 1.; // Expand the box if the text is longer
|
||||
|
|
|
@ -1086,3 +1086,11 @@ xx(wrapwidth)
|
|||
xx(scalefactorx)
|
||||
xx(scalefactory)
|
||||
xx(scalemode)
|
||||
|
||||
xy(menu_cursor, "menu/cursor")
|
||||
xy(menu_choose, "menu/choose")
|
||||
xy(menu_backup, "menu/backup")
|
||||
xy(menu_clear, "menu/clear")
|
||||
xy(menu_dismiss, "menu/dismiss")
|
||||
xy(menu_change, "menu/change")
|
||||
xy(menu_advance, "menu/advance")
|
||||
|
|
|
@ -100,7 +100,7 @@ float BackbuttonAlpha;
|
|||
static bool MenuEnabled = true;
|
||||
DMenu *CurrentMenu;
|
||||
int MenuTime;
|
||||
DObject* menuCustomizer;
|
||||
DObject* menuDelegate;
|
||||
|
||||
|
||||
extern PClass *DefaultListMenuClass;
|
||||
|
@ -192,7 +192,7 @@ void M_MarkMenus()
|
|||
GC::Mark(pair->Value);
|
||||
}
|
||||
GC::Mark(CurrentMenu);
|
||||
GC::Mark(menuCustomizer);
|
||||
GC::Mark(menuDelegate);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
@ -888,7 +888,7 @@ DEFINE_GLOBAL(menuactive)
|
|||
DEFINE_GLOBAL(BackbuttonTime)
|
||||
DEFINE_GLOBAL(BackbuttonAlpha)
|
||||
DEFINE_GLOBAL(GameTicRate)
|
||||
DEFINE_GLOBAL(menuCustomizer)
|
||||
DEFINE_GLOBAL(menuDelegate)
|
||||
|
||||
DEFINE_FIELD(DMenu, mParentMenu)
|
||||
DEFINE_FIELD(DMenu, mMouseCapture);
|
||||
|
|
|
@ -47,7 +47,7 @@ class DMenu;
|
|||
extern DMenu *CurrentMenu;
|
||||
extern int MenuTime;
|
||||
class DMenuItemBase;
|
||||
extern DObject* menuCustomizer;
|
||||
extern DObject* menuDelegate;
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
|
|
|
@ -151,10 +151,10 @@ void DeinitMenus()
|
|||
}
|
||||
MenuDescriptors.Clear();
|
||||
OptionValues.Clear();
|
||||
if (menuCustomizer)
|
||||
if (menuDelegate)
|
||||
{
|
||||
menuCustomizer->Destroy();
|
||||
menuCustomizer = nullptr;
|
||||
menuDelegate->Destroy();
|
||||
menuDelegate = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,8 +73,10 @@ bool FName::NameManager::Inited;
|
|||
static const char *PredefinedNames[] =
|
||||
{
|
||||
#define xx(n) #n,
|
||||
#define xy(n, s) s,
|
||||
#include "namedef.h"
|
||||
#undef xx
|
||||
#undef xy
|
||||
};
|
||||
|
||||
// CODE --------------------------------------------------------------------
|
||||
|
|
|
@ -40,8 +40,10 @@
|
|||
enum ENamedName
|
||||
{
|
||||
#define xx(n) NAME_##n,
|
||||
#define xy(n, s) NAME_##n,
|
||||
#include "namedef.h"
|
||||
#undef xx
|
||||
#undef xy
|
||||
};
|
||||
|
||||
class FString;
|
||||
|
|
|
@ -58,18 +58,7 @@
|
|||
#include "gamecontrol.h"
|
||||
#include "raze_sound.h"
|
||||
#include "gamestruct.h"
|
||||
|
||||
enum EMenuSounds : int
|
||||
{
|
||||
ActivateSound,
|
||||
CursorSound,
|
||||
AdvanceSound,
|
||||
BackSound,
|
||||
CloseSound,
|
||||
PageSound,
|
||||
ChangeSound,
|
||||
ChooseSound
|
||||
};
|
||||
#include "razemenu.h"
|
||||
|
||||
EXTERN_CVAR(Int, cl_gfxlocalization)
|
||||
EXTERN_CVAR(Bool, m_quickexit)
|
||||
|
@ -173,17 +162,6 @@ bool M_SetSpecialMenu(FName& menu, int param)
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
void M_MenuSound(EMenuSounds snd)
|
||||
{
|
||||
if (menu_sounds) gi->MenuSound(snd);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
void M_StartControlPanel(bool makeSound, bool)
|
||||
{
|
||||
static bool created = false;
|
||||
|
@ -198,7 +176,7 @@ void M_StartControlPanel(bool makeSound, bool)
|
|||
}
|
||||
GSnd->SetSfxPaused(true, PAUSESFX_MENU);
|
||||
gi->MenuOpened();
|
||||
if (makeSound) M_MenuSound(ActivateSound);
|
||||
if (makeSound && menu_sounds) gi->MenuSound(ActivateSound);
|
||||
M_DoStartControlPanel(false);
|
||||
}
|
||||
|
||||
|
@ -1149,13 +1127,13 @@ void SetDefaultMenuColors()
|
|||
OptionSettings.mFontColorHeader = CR_DARKGRAY;
|
||||
OptionSettings.mFontColorHighlight = CR_WHITE;
|
||||
OptionSettings.mFontColorSelection = CR_DARKRED;
|
||||
cls = PClass::FindClass("MenuCustomizerBlood");
|
||||
cls = PClass::FindClass("BloodMenuDelegate");
|
||||
}
|
||||
else if (g_gameType & GAMEFLAG_SW)
|
||||
{
|
||||
OptionSettings.mFontColorHeader = CR_DARKRED;
|
||||
OptionSettings.mFontColorHighlight = CR_WHITE;
|
||||
cls = PClass::FindClass("MenuCustomizerSW");
|
||||
cls = PClass::FindClass("SWMenuDelegate");
|
||||
}
|
||||
else if (g_gameType & GAMEFLAG_PSEXHUMED)
|
||||
{
|
||||
|
@ -1163,7 +1141,7 @@ void SetDefaultMenuColors()
|
|||
OptionSettings.mFontColorHighlight = CR_SAPPHIRE;
|
||||
OptionSettings.mFontColorSelection = CR_ORANGE;
|
||||
OptionSettings.mFontColor = CR_FIRE;
|
||||
cls = PClass::FindClass("MenuCustomizerExhumed");
|
||||
cls = PClass::FindClass("ExhumedMenuDelegate");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1181,9 +1159,50 @@ void SetDefaultMenuColors()
|
|||
OptionSettings.mFontColorHighlight = CR_ORANGE;
|
||||
OptionSettings.mFontColorSelection = CR_TAN;
|
||||
}
|
||||
cls = PClass::FindClass("MenuCustomizerDuke");
|
||||
cls = PClass::FindClass("DukeMenuDelegate");
|
||||
}
|
||||
if (!cls) cls = PClass::FindClass("MenuCustomize");
|
||||
if (cls) menuCustomizer = cls->CreateNew();
|
||||
if (!cls) cls = PClass::FindClass("RazeMenuDelegate");
|
||||
if (cls) menuDelegate = cls->CreateNew();
|
||||
|
||||
}
|
||||
|
||||
// The sound system is not yet capable of resolving this properly.
|
||||
DEFINE_ACTION_FUNCTION(_RazeMenuDelegate, PlaySound)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(void);
|
||||
PARAM_NAME(name);
|
||||
EMenuSounds soundindex;
|
||||
|
||||
switch (name.GetIndex())
|
||||
{
|
||||
case NAME_menu_cursor:
|
||||
soundindex = CursorSound;
|
||||
break;
|
||||
|
||||
case NAME_menu_choose:
|
||||
soundindex = ChooseSound;
|
||||
break;
|
||||
|
||||
case NAME_menu_backup:
|
||||
soundindex = BackSound;
|
||||
break;
|
||||
|
||||
case NAME_menu_clear:
|
||||
case NAME_menu_dismiss:
|
||||
soundindex = CloseSound;
|
||||
break;
|
||||
|
||||
case NAME_menu_change:
|
||||
soundindex = ChangeSound;
|
||||
break;
|
||||
|
||||
case NAME_menu_advance:
|
||||
soundindex = AdvanceSound;
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
gi->MenuSound(soundindex);
|
||||
return 0;
|
||||
}
|
|
@ -176,7 +176,7 @@ struct _ native // These are the global variables, the struct is only here to av
|
|||
native readonly @MusPlayingInfo musplaying;
|
||||
native readonly bool generic_ui;
|
||||
native readonly int GameTicRate;
|
||||
native MenuCustomize menuCustomizer;
|
||||
native MenuDelegateBase menuDelegate;
|
||||
native readonly int consoleplayer;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
//
|
||||
//-------------------------------------------------------------------------------------------
|
||||
|
||||
class MenuCustomizerBlood : MenuCustomize
|
||||
class BloodMenuDelegate : RazeMenuDelegate
|
||||
{
|
||||
override int DrawCaption(String title, Font fnt, int y, bool drawit)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
class MenuCustomizerDuke : MenuCustomize
|
||||
class DukeMenuDelegate : RazeMenuDelegate
|
||||
{
|
||||
override int DrawCaption(String title, Font fnt, int y, bool drawit)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
class MenuCustomizerExhumed : MenuCustomize
|
||||
class ExhumedMenuDelegate : RazeMenuDelegate
|
||||
{
|
||||
override int DrawCaption(String title, Font fnt, int y, bool drawit)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
class MenuCustomizerSW : MenuCustomize
|
||||
class SWMenuDelegate : RazeMenuDelegate
|
||||
{
|
||||
override int DrawCaption(String title, Font fnt, int y, bool drawit)
|
||||
{
|
||||
|
|
|
@ -39,3 +39,9 @@ struct TileFiles
|
|||
native static TextureID GetTexture(int tile, bool animate = false);
|
||||
}
|
||||
*/
|
||||
|
||||
class RazeMenuDelegate : MenuDelegateBase
|
||||
{
|
||||
// Todo: Fix this so that it can be done outside the games' sound modules.
|
||||
native override void PlaySound(name sname);
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ class ListMenu : Menu
|
|||
case MKEY_Enter:
|
||||
if (mDesc.mSelectedItem >= 0 && mDesc.mItems[mDesc.mSelectedItem].Activate())
|
||||
{
|
||||
MenuSound("menu/choose");
|
||||
MenuSound("menu/advance");
|
||||
}
|
||||
return true;
|
||||
|
||||
|
@ -269,7 +269,7 @@ class ListMenu : Menu
|
|||
}
|
||||
if (mDesc.mSelectedItem >= 0 && mDesc.mSelectedItem < mDesc.mItems.Size())
|
||||
{
|
||||
if (!menuCustomizer.DrawSelector(mDesc))
|
||||
if (!menuDelegate.DrawSelector(mDesc))
|
||||
mDesc.mItems[mDesc.mSelectedItem].DrawSelector(mDesc.mSelectOfsX, mDesc.mSelectOfsY, mDesc.mSelector, mDesc);
|
||||
}
|
||||
Super.Drawer();
|
||||
|
|
|
@ -363,7 +363,7 @@ class ListMenuItemCaptionItem : ListMenuItem
|
|||
let font = generic_ui || !desc.mFont ? NewSmallFont : desc.mFont;
|
||||
if (font && mText.Length() > 0)
|
||||
{
|
||||
menuCustomizer.DrawCaption(mText, font, 0, true);
|
||||
menuDelegate.DrawCaption(mText, font, 0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -285,8 +285,7 @@ class Menu : Object native ui version("2.4")
|
|||
|
||||
static void MenuSound(Name snd)
|
||||
{
|
||||
// todo: Cannot use game specific IDs here - sound also may be set up too late by the games
|
||||
//S_StartSound (snd, CHAN_VOICE, CHANF_MAYBE_LOCAL|CHAN_UI, snd_menuvolume, ATTN_NONE);
|
||||
menuDelegate.PlaySound(snd);
|
||||
}
|
||||
|
||||
deprecated("4.0") static void DrawConText (int color, int x, int y, String str)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// This class allows global customization of certain menu aspects, e.g. replacing the menu caption.
|
||||
|
||||
class MenuCustomize
|
||||
class MenuDelegateBase
|
||||
{
|
||||
virtual int DrawCaption(String title, Font fnt, int y, bool drawit)
|
||||
{
|
||||
|
|
|
@ -433,7 +433,7 @@ class OptionMenu : Menu
|
|||
let font = generic_ui || !mDesc.mFont ? NewSmallFont : mDesc.mFont;
|
||||
if (font && mDesc.mTitle.Length() > 0)
|
||||
{
|
||||
return menuCustomizer.DrawCaption(title, font, y, drawit);
|
||||
return menuDelegate.DrawCaption(title, font, y, drawit);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue