Menu-VGUI: Title support.
This commit is contained in:
parent
af708c1e90
commit
45b2f300f8
26 changed files with 357 additions and 53 deletions
|
@ -51,3 +51,7 @@ menumap "test_dlights"
|
|||
introvideo ""
|
||||
// whether to use a steam styled resource background cut into multiple parts
|
||||
steambg 0
|
||||
// the title text of the game
|
||||
title "Nuclide"
|
||||
// the subtitle of the game
|
||||
subtitle "Test Game"
|
||||
|
|
BIN
base/resources.pk3dir/fonts/IBMPlexSans-Bold.otf
Normal file
BIN
base/resources.pk3dir/fonts/IBMPlexSans-Bold.otf
Normal file
Binary file not shown.
BIN
base/resources.pk3dir/fonts/IBMPlexSans-Medium.otf
Normal file
BIN
base/resources.pk3dir/fonts/IBMPlexSans-Medium.otf
Normal file
Binary file not shown.
|
@ -1,3 +0,0 @@
|
|||
rendersize "21 16"
|
||||
path fonts/IBMPlexMono-Text.otf
|
||||
size 16
|
|
@ -1,2 +0,0 @@
|
|||
rendersize "10 11 12 14"
|
||||
path fonts/IBMPlexMono-Text.otf
|
|
@ -1,2 +0,0 @@
|
|||
rendersize "14 12"
|
||||
path fonts/IBMPlexMono-Text.otf
|
|
@ -1,3 +0,0 @@
|
|||
rendersize "14 11 12"
|
||||
path fonts/IBMPlexMono-Text.otf
|
||||
size 12
|
4
base/resources.pk3dir/fonts/subtitle.font
Normal file
4
base/resources.pk3dir/fonts/subtitle.font
Normal file
|
@ -0,0 +1,4 @@
|
|||
color "255 255 255"
|
||||
alpha 255
|
||||
size 16
|
||||
path fonts/IBMPlexSans-Medium.otf
|
5
base/resources.pk3dir/fonts/title.font
Normal file
5
base/resources.pk3dir/fonts/title.font
Normal file
|
@ -0,0 +1,5 @@
|
|||
color "255 255 255"
|
||||
alpha 255
|
||||
size 32
|
||||
path fonts/IBMPlexSans-Medium.otf
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
color "255 255 255"
|
||||
alpha 255
|
||||
size 12
|
||||
path fonts/IBMPlexMono-Text.otf
|
||||
path fonts/IBMPlexSans-Medium.otf
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
COLOR=28 40 56
|
||||
FG_COLOR=255 255 255
|
||||
FG_COLOR=210 224 240
|
||||
ALPHA=255
|
||||
ROUNDED=1
|
||||
|
||||
BORDER_COLOR=68 81 97
|
||||
BORDER_ALPHA=255
|
||||
HOVER_COLOR=232 232 255
|
||||
HOVER_ALPHA=32
|
||||
|
|
|
@ -188,7 +188,7 @@ Font_DrawFieldAtHeight(vector vecOrigin, vector vecSize, int iTextHeight, string
|
|||
drawfont = (float)fnt.iID;
|
||||
drawfontscale[0] = (float)iTextHeight / 8;
|
||||
drawfontscale[1] = (float)iTextHeight / 8;
|
||||
drawtextfield(vecOrigin, vecSize, (float)iAlignFlags, strText);
|
||||
drawtextfield(vecOrigin, vecSize, (float)iAlignFlags, strcat(fnt.hexColor, strText));
|
||||
drawfont = 0;
|
||||
drawfontscale = [1,1,0];
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ Strings_Init(void)
|
|||
{
|
||||
filestream stringslst;
|
||||
string lstline;
|
||||
string gameTitle = GameLibrary_GetInfo(GAMEINFO_TITLE);
|
||||
string gameTitle = GameLibrary_GetInfo(GAMEINFO_NAME);
|
||||
|
||||
m_reslbl[IDS_LANGUAGE] = _("IDS_LANGUAGE");
|
||||
m_reslbl[IDS_BORDERLESS_REGFAIL] = _("IDS_BORDERLESS_REGFAIL");
|
||||
|
|
|
@ -72,7 +72,7 @@ CModList::Draw(void)
|
|||
for (int i = m_scroll; i <= (visible + m_scroll); i++) {
|
||||
vector colo;
|
||||
gameType = GameLibrary_GetGameInfo(i, GAMEINFO_TYPE);
|
||||
gameTitle = GameLibrary_GetGameInfo(i, GAMEINFO_TITLE);
|
||||
gameTitle = GameLibrary_GetGameInfo(i, GAMEINFO_NAME);
|
||||
gameURL = GameLibrary_GetGameInfo(i, GAMEINFO_WEBSITE);
|
||||
gameSize = GameLibrary_GetGameInfo(i, GAMEINFO_SIZE);
|
||||
gameVersion = GameLibrary_GetGameInfo(i, GAMEINFO_VERSION);
|
||||
|
|
|
@ -27,6 +27,7 @@ void Desktop_Init ( void )
|
|||
static CUIMenuButton btnResume;
|
||||
static CUIMenuButton btnDisconnect;
|
||||
static CUIMenuButton btnMods;
|
||||
static VGUIMenuTitle title;
|
||||
|
||||
static void Desktop_ResumeGame ( void ) {
|
||||
m_toggle( 0 );
|
||||
|
@ -41,7 +42,7 @@ void Desktop_Init ( void )
|
|||
btnNewgame = spawn( CUIMenuButton );
|
||||
btnNewgame.SetTitle( "New Game" );
|
||||
btnNewgame.SetSize( '128 24' );
|
||||
btnNewgame.SetPos( '32 64' );
|
||||
btnNewgame.SetPosition( 1 );
|
||||
btnNewgame.SetFunc( UI_NewGame_Show );
|
||||
btnNewgame.FlagRemove( MBUTTON_SHOWSP | MBUTTON_SHOWMP );
|
||||
btnNewgame.SetIcon( "gfx/icon16/new" );
|
||||
|
@ -49,7 +50,7 @@ void Desktop_Init ( void )
|
|||
btnDisconnect = spawn( CUIMenuButton );
|
||||
btnDisconnect.SetTitle( "Disconnect" );
|
||||
btnDisconnect.SetSize( '128 24' );
|
||||
btnDisconnect.SetPos( '32 64' );
|
||||
btnDisconnect.SetPosition( 1 );
|
||||
btnDisconnect.SetFunc( Desktop_DisconnectGame );
|
||||
btnDisconnect.FlagRemove( MBUTTON_SHOWOFFLINE );
|
||||
btnDisconnect.SetIcon( "gfx/icon16/disconnect" );
|
||||
|
@ -57,28 +58,28 @@ void Desktop_Init ( void )
|
|||
btnLoadgame = spawn( CUIMenuButton );
|
||||
btnLoadgame.SetTitle( "Load Game" );
|
||||
btnLoadgame.SetSize( '128 24' );
|
||||
btnLoadgame.SetPos( '32 96' );
|
||||
btnLoadgame.SetPosition( 2 );
|
||||
btnLoadgame.SetIcon( "gfx/icon16/book_edit" );
|
||||
btnLoadgame.SetFunc( UI_LoadGame_Show );
|
||||
|
||||
btnFindserver = spawn( CUIMenuButton );
|
||||
btnFindserver.SetTitle( "Find Servers" );
|
||||
btnFindserver.SetSize( '128 24' );
|
||||
btnFindserver.SetPos( '32 128' );
|
||||
btnFindserver.SetPosition(3 );
|
||||
btnFindserver.SetFunc( UI_FindServers_Show );
|
||||
btnFindserver.SetIcon( "gfx/icon16/world_go" );
|
||||
|
||||
btnCreateserver = spawn( CUIMenuButton );
|
||||
btnCreateserver.SetTitle( "Create Server" );
|
||||
btnCreateserver.SetSize( '128 24' );
|
||||
btnCreateserver.SetPos( '32 160' );
|
||||
btnCreateserver.SetPosition( 4 );
|
||||
btnCreateserver.SetFunc( UI_CreateServer_Show );
|
||||
btnCreateserver.SetIcon( "gfx/icon16/server_add" );
|
||||
|
||||
btnMods = spawn( CUIMenuButton );
|
||||
btnMods.SetTitle( "Custom Game" );
|
||||
btnMods.SetSize( '128 24' );
|
||||
btnMods.SetPos( '32 192' );
|
||||
btnMods.SetPosition( 5 );
|
||||
btnMods.SetIcon( "gfx/icon16/rainbow" );
|
||||
btnMods.SetFunc( UI_CustomGame_Show );
|
||||
btnMods.FlagRemove( MBUTTON_SHOWSP | MBUTTON_SHOWMP );
|
||||
|
@ -86,42 +87,54 @@ void Desktop_Init ( void )
|
|||
btnOptions = spawn( CUIMenuButton );
|
||||
btnOptions.SetTitle( "Options" );
|
||||
btnOptions.SetSize( '128 24' );
|
||||
btnOptions.SetPos( '32 224' );
|
||||
btnOptions.SetPosition( 6 );
|
||||
btnOptions.SetIcon( "gfx/icon16/cog" );
|
||||
|
||||
btnQuit = spawn( CUIMenuButton );
|
||||
btnQuit.SetTitle( "Quit Game" );
|
||||
btnQuit.SetSize( '128 24' );
|
||||
btnQuit.SetPos( '32 256' );
|
||||
btnQuit.SetPosition( 7 );
|
||||
btnQuit.SetFunc( UI_QuitGame_Show );
|
||||
btnQuit.SetIcon( "gfx/icon16/stop" );
|
||||
|
||||
btnMPlayer = spawn( CUIMenuButton );
|
||||
btnMPlayer.SetTitle( "Music Player" );
|
||||
btnMPlayer.SetSize( '128 24' );
|
||||
btnMPlayer.SetPos( '32 288' );
|
||||
btnMPlayer.SetPosition( 8 );
|
||||
btnMPlayer.SetFunc( UI_MusicPlayer_Show );
|
||||
btnMPlayer.SetIcon( "gfx/icon16/ipod" );
|
||||
|
||||
btnMViewer = spawn( CUIMenuButton );
|
||||
btnMViewer.SetTitle( "Model Viewer" );
|
||||
btnMViewer.SetSize( '128 24' );
|
||||
btnMViewer.SetPos( '32 320' );
|
||||
btnMViewer.SetPosition( 9 );
|
||||
btnMViewer.SetFunc( UI_ModelViewer_Show );
|
||||
btnMViewer.SetIcon( "gfx/icon16/images" );
|
||||
|
||||
btnResume = spawn( CUIMenuButton );
|
||||
btnResume.SetTitle( "Resume Game" );
|
||||
btnResume.SetSize( '128 24' );
|
||||
btnResume.SetPos( '32 384' );
|
||||
btnResume.SetPosition( 10 );
|
||||
btnResume.SetFunc( Desktop_ResumeGame );
|
||||
btnResume.FlagRemove( MBUTTON_SHOWOFFLINE );
|
||||
btnResume.SetIcon( "gfx/icon16/control_play" );
|
||||
|
||||
g_uiDesktop.Add( btnNewgame );
|
||||
g_uiDesktop.Add( btnLoadgame );
|
||||
g_uiDesktop.Add( btnFindserver );
|
||||
g_uiDesktop.Add( btnCreateserver );
|
||||
title = spawn(VGUIMenuTitle);
|
||||
|
||||
g_uiDesktop.Add( title );
|
||||
|
||||
if (GameLibrary_GetInfo(GAMEINFO_TYPE) != "Multiplayer")
|
||||
g_uiDesktop.Add( btnNewgame );
|
||||
|
||||
if (GameLibrary_GetInfo(GAMEINFO_TYPE) != "Multiplayer")
|
||||
g_uiDesktop.Add( btnLoadgame );
|
||||
|
||||
if (GameLibrary_GetInfo(GAMEINFO_TYPE) != "Singleplayer")
|
||||
g_uiDesktop.Add( btnFindserver );
|
||||
|
||||
if (GameLibrary_GetInfo(GAMEINFO_TYPE) != "Singleplayer")
|
||||
g_uiDesktop.Add( btnCreateserver );
|
||||
|
||||
g_uiDesktop.Add( btnOptions );
|
||||
g_uiDesktop.Add( btnQuit );
|
||||
g_uiDesktop.Add( btnMPlayer );
|
||||
|
|
|
@ -51,7 +51,7 @@ void UI_CustomGame_Show ( void )
|
|||
lsbGames.CallOnScroll( CustomGame_ScrollUpdate );
|
||||
|
||||
for ( int i = 0; i < GameLibrary_GetGameCount(); i++ ) {
|
||||
lsbGames.AddItem( GameLibrary_GetGameInfo(i, GAMEINFO_TITLE) );
|
||||
lsbGames.AddItem( GameLibrary_GetGameInfo(i, GAMEINFO_NAME) );
|
||||
}
|
||||
|
||||
scrlGames = spawn( CUIScrollbar );
|
||||
|
|
|
@ -55,13 +55,15 @@ a later time.
|
|||
/** Options for querying Game Library entry information using `GameLibrary_GetInfo()` */
|
||||
typedef enum
|
||||
{
|
||||
GAMEINFO_TITLE, /**< (string) The title of the game. E.g. "Action Game" */
|
||||
GAMEINFO_NAME, /**< (string) The name of the game. E.g. "Action Game" */
|
||||
GAMEINFO_GAMEDIR, /**< (string) The game directory name. E.g. "data" */
|
||||
GAMEINFO_FALLBACKDIR, /**< (string) The directory to be loaded before the game directory. */
|
||||
GAMEINFO_BASEDIR, /**< (string) The first game directory to be loaded. */
|
||||
GAMEINFO_WEBSITE, /**< (string) The game its official website. */
|
||||
GAMEINFO_VERSION, /**< (string) Version number string. */
|
||||
GAMEINFO_SIZE, /**< (int) The size of the game, in bytes. */
|
||||
GAMEINFO_TITLE, /**< (string) The title of the game in the main menu. */
|
||||
GAMEINFO_SUBTITLE, /**< (string) The sub-title of the game in the main menu. */
|
||||
GAMEINFO_TYPE, /**< (string) The game type. E.g. "Singleplayer" */
|
||||
GAMEINFO_NOPLAYERMODELS,/**< (bool) If the game allows player model selection. */
|
||||
GAMEINFO_NOSPRAYS, /**< (bool) If the game allows custom spray logos. */
|
||||
|
@ -120,6 +122,8 @@ typedef enum
|
|||
typedef struct
|
||||
{
|
||||
string game;
|
||||
string title;
|
||||
string subtitle;
|
||||
string gamedir;
|
||||
string base_dir;
|
||||
string url_info;
|
||||
|
|
|
@ -234,6 +234,12 @@ GameLibrary_LibListParse(int id, string strKey, string strValue)
|
|||
case "base_dir":
|
||||
games[id].base_dir = strValue;
|
||||
break;
|
||||
case "title":
|
||||
games[id].title = strValue;
|
||||
break;
|
||||
case "subtitle":
|
||||
games[id].subtitle = strValue;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -278,7 +284,19 @@ GameLibrary_CheckGameInfo(int id, string gamedirname)
|
|||
games[id].game = argv(1);
|
||||
break;
|
||||
case "type":
|
||||
games[id].type = argv(1);
|
||||
GameLibrary_LibListParse(id, token, argv(1));
|
||||
break;
|
||||
case "title":
|
||||
games[id].title = argv(1);
|
||||
break;
|
||||
case "title2":
|
||||
games[id].subtitle = argv(1);
|
||||
break;
|
||||
case "nomodels":
|
||||
games[id].nomodels = (int)stof(argv(1));
|
||||
break;
|
||||
case "developer_url":
|
||||
games[id].url_info = argv(1);
|
||||
break;
|
||||
}
|
||||
} else if (braced == 2) {
|
||||
|
@ -407,6 +425,8 @@ GameLibrary_SetDefaults(int id, string gamedirname)
|
|||
games[id].installed = 1;
|
||||
games[id].chatroom = gamedirname;
|
||||
games[id].readme = "readme.txt";
|
||||
games[id].title = "";
|
||||
games[id].subtitle = "";
|
||||
games[id].pkgid = -1;
|
||||
|
||||
if (games[id].gamedir == "valve") {
|
||||
|
@ -767,9 +787,15 @@ GameLibrary_GetGameInfo(int gameID, gameInfo_t infoType)
|
|||
}
|
||||
|
||||
switch (infoType) {
|
||||
case GAMEINFO_TITLE:
|
||||
case GAMEINFO_NAME:
|
||||
return (string)games[gameID].game;
|
||||
break;
|
||||
case GAMEINFO_TITLE:
|
||||
return (string)games[gameID].title;
|
||||
break;
|
||||
case GAMEINFO_SUBTITLE:
|
||||
return (string)games[gameID].subtitle;
|
||||
break;
|
||||
case GAMEINFO_GAMEDIR:
|
||||
return (string)games[gameID].gamedir;
|
||||
break;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
../vgui/ui_window.qc
|
||||
../vgui/ui_frame.qc
|
||||
../vgui/ui_label.qc
|
||||
../vgui/ui_menutitle.qc
|
||||
../vgui/ui_pic.qc
|
||||
../vgui/ui_3dview.qc
|
||||
../vgui/ui_scrollbar.qc
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
#define CUIWindow VGUIWindow
|
||||
|
||||
font_s g_fntDefault;
|
||||
font_s g_fntTitle;
|
||||
font_s g_fntSubTitle;
|
||||
font_s g_fntMenuButton;
|
||||
var int g_vguiWidgetCount;
|
||||
int g_lastmousepos[2];
|
||||
|
||||
|
@ -511,6 +514,18 @@ UISystem_Init(void)
|
|||
}
|
||||
|
||||
Font_Load("fonts/ui.font", g_fntDefault);
|
||||
Font_Load("fonts/title.font", g_fntTitle);
|
||||
Font_Load("fonts/subtitle.font", g_fntSubTitle);
|
||||
Font_Load("fonts/menu_button.font", g_fntMenuButton);
|
||||
|
||||
if (g_fntMenuButton.iID == 0)
|
||||
g_fntMenuButton = g_fntDefault;
|
||||
|
||||
if (g_fntSubTitle.iID == 0)
|
||||
g_fntSubTitle = g_fntDefault;
|
||||
|
||||
if (g_fntTitle.iID == 0)
|
||||
g_fntTitle = g_fntDefault;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef MENU
|
||||
/** VGUI: Console
|
||||
|
||||
A 'portable' console. It takes up less space.
|
||||
|
@ -29,10 +28,15 @@ public:
|
|||
virtual void Spawned(void);
|
||||
nonvirtual void ConsoleResized(void);
|
||||
|
||||
virtual void Draw(void);
|
||||
virtual void Submit(void);
|
||||
virtual float Input(float, float, float, float);
|
||||
|
||||
private:
|
||||
VGUIFrame m_outlineFrame;
|
||||
VGUIButton m_submitButton;
|
||||
VGUITextBox m_commandBox;
|
||||
string m_conInstance;
|
||||
};
|
||||
|
||||
void
|
||||
|
@ -41,6 +45,7 @@ VGUIConsole::VGUIConsole(void)
|
|||
m_outlineFrame = __NULL__;
|
||||
m_submitButton = __NULL__;
|
||||
m_commandBox = __NULL__;
|
||||
m_conInstance = __NULL__;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -52,13 +57,28 @@ VGUIConsole::ConsoleResized(void)
|
|||
m_submitButton.SetPos([GetSizeWidth() - 72, GetSizeHeight() - 32]);
|
||||
}
|
||||
|
||||
void
|
||||
VGUIConsole::Submit(void)
|
||||
{
|
||||
localcmd(strcat(m_commandBox.GetText(), "\n"));
|
||||
//con_printf(m_conInstance, strcat("/", m_commandBox.GetText(), "\n"));
|
||||
m_commandBox.SetText("");
|
||||
}
|
||||
|
||||
void
|
||||
VGUIConsole::Spawned(void)
|
||||
{
|
||||
static void VGUIConsole_Submit(void) {
|
||||
VGUIWidget winSelf = (VGUIWidget)self;
|
||||
VGUIConsole ourConsole = (VGUIConsole)winSelf.m_parent;
|
||||
ourConsole.Submit();
|
||||
}
|
||||
|
||||
super::Spawned();
|
||||
|
||||
SetTitle("Console");
|
||||
SetSize([560, 400]);
|
||||
SetMaxSize([9999,9999]);
|
||||
SetPos([40, 40]);
|
||||
m_outlineFrame = spawn(VGUIFrame);
|
||||
m_outlineFrame.SetPos([8,36]);
|
||||
|
@ -67,16 +87,51 @@ VGUIConsole::Spawned(void)
|
|||
m_commandBox = spawn(VGUITextBox);
|
||||
m_commandBox.SetPos([8,368]);
|
||||
m_commandBox.SetSize([472,24]);
|
||||
m_commandBox.CallOnEnter(VGUIConsole_Submit);
|
||||
|
||||
m_submitButton = spawn(VGUIButton);
|
||||
m_submitButton.SetSize([64,24]);
|
||||
m_submitButton.SetPos([488,368]);
|
||||
m_submitButton.SetTitle("Submit");
|
||||
m_submitButton.SetFunc(VGUIConsole_Submit);
|
||||
|
||||
SetStyleMask( VGUIWindowStyleDefault | VGUIWindowResizeable );
|
||||
CallOnResize(ConsoleResized);
|
||||
Add(m_outlineFrame);
|
||||
Add(m_commandBox);
|
||||
Add(m_submitButton);
|
||||
|
||||
m_conInstance = con_getset("", "next");
|
||||
}
|
||||
|
||||
void
|
||||
VGUIConsole::Draw(void)
|
||||
{
|
||||
super::Draw();
|
||||
|
||||
drawfont = g_fntDefault.iID;
|
||||
|
||||
float xPos = m_parent.m_vecOrigin[0] + m_vecOrigin[0] + m_outlineFrame.GetPosWidth() + 8;
|
||||
float yPos = m_parent.m_vecOrigin[1] + m_vecOrigin[1] + m_outlineFrame.GetPosHeight() + 8;
|
||||
float wSize = m_outlineFrame.GetSizeWidth() -16;
|
||||
float wHeight = m_outlineFrame.GetSizeHeight() -16;
|
||||
|
||||
drawsetcliparea(xPos, yPos, wSize, wHeight);
|
||||
con_draw(m_conInstance, [xPos, yPos], [wSize, wHeight], g_fntDefault.iScaleY);
|
||||
drawresetcliparea();
|
||||
}
|
||||
|
||||
float
|
||||
VGUIConsole::Input(float type, float x, float y, float devid)
|
||||
{
|
||||
float ret = super::Input(type, x, y, devid);
|
||||
|
||||
if (!ret) {
|
||||
if (Util_MouseAbove(g_vecMousePos, m_parent.m_vecOrigin + m_vecOrigin + m_outlineFrame.GetPos() + [8,8], m_outlineFrame.GetSize() + [-16,-16])) {
|
||||
con_input(m_conInstance, type, x, y, 0);
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -27,22 +27,19 @@ public:
|
|||
virtual void Draw(void);
|
||||
|
||||
private:
|
||||
vector m_vecColor;
|
||||
float m_flAlpha;
|
||||
VGUIColor m_frameColor;
|
||||
};
|
||||
|
||||
void
|
||||
VGUIFrame::VGUIFrame(void)
|
||||
{
|
||||
m_vecColor = UI_MAINCOLOR;
|
||||
m_flAlpha = 1.0f;
|
||||
m_frameColor = spawn(VGUIColor);
|
||||
m_frameColor. SetColorWithAlpha(UI_MAINCOLOR, 0.0f);
|
||||
}
|
||||
|
||||
void VGUIFrame::Draw(void)
|
||||
{
|
||||
drawfill(m_parent.m_vecOrigin + m_vecOrigin, [m_vecSize[0], 1], [1,1,1], 0.5f);
|
||||
drawfill(m_parent.m_vecOrigin + m_vecOrigin + [0, m_vecSize[1] - 1], [m_vecSize[0], 1], [0,0,0], 0.5f);
|
||||
drawfill(m_parent.m_vecOrigin + m_vecOrigin + [0, 1], [1, m_vecSize[1] - 2], [1,1,1], 0.5f);
|
||||
drawfill(m_parent.m_vecOrigin + m_vecOrigin + [m_vecSize[0] - 1, 1], [1, m_vecSize[1] - 2], [0,0,0], 0.5f);
|
||||
VGUITheme ourTheme = GetTheme();
|
||||
ourTheme.DrawBorder(m_parent.m_vecOrigin + m_vecOrigin, m_vecSize, VGUI_BORDER_INSET, m_frameColor);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,12 @@ public:
|
|||
virtual void Draw(void);
|
||||
virtual bool Input(float, float, float, float);
|
||||
virtual void Spawned(void);
|
||||
virtual void Reposition(void);
|
||||
|
||||
nonvirtual void SetPosition(int);
|
||||
|
||||
private:
|
||||
int m_menuPosition;
|
||||
};
|
||||
|
||||
void
|
||||
|
@ -52,6 +58,17 @@ VGUIMenuButton::Spawned(void)
|
|||
FlagAdd(MBUTTON_SHOWOFFLINE | MBUTTON_SHOWSP | MBUTTON_SHOWMP);
|
||||
}
|
||||
|
||||
void
|
||||
VGUIMenuButton::Reposition(void)
|
||||
{
|
||||
super::Reposition();
|
||||
|
||||
vector newPosition = [g_vidsize[0] / 16, g_vidsize[1] / 2 - 64];
|
||||
|
||||
newPosition[1] += m_menuPosition * 24;
|
||||
SetPos(newPosition);
|
||||
}
|
||||
|
||||
void
|
||||
VGUIMenuButton::Draw(void)
|
||||
{
|
||||
|
@ -66,7 +83,43 @@ VGUIMenuButton::Draw(void)
|
|||
}
|
||||
}
|
||||
|
||||
super::Draw();
|
||||
VGUITheme theme = GetTheme();
|
||||
|
||||
if (m_iFlags & BUTTON_DOWN) {
|
||||
//theme.DrawButton(m_parent.m_vecOrigin + m_vecOrigin, m_vecSize, VGUI_STATE_ACTIVE);
|
||||
} else if (m_iFlags & BUTTON_HOVER) {
|
||||
//theme.DrawButton(m_parent.m_vecOrigin + m_vecOrigin, m_vecSize, VGUI_STATE_HOVER);
|
||||
} else {
|
||||
//theme.DrawButton(m_parent.m_vecOrigin + m_vecOrigin, m_vecSize, VGUI_STATE_NORMAL);
|
||||
}
|
||||
|
||||
float textPadding = 8;
|
||||
|
||||
if (m_keyEquivalent >= 0) {
|
||||
float length;
|
||||
string keyText = GetKeyEquivalent();
|
||||
|
||||
length = Font_StringWidth(keyText, FALSE, g_fntMenuButton);
|
||||
textPadding += length + 8;
|
||||
theme.DrawText(m_parent.m_vecOrigin + m_vecOrigin + [8, 8], keyText, m_vecSize, g_fntMenuButton);
|
||||
}
|
||||
|
||||
if (STRING_SET(m_strIcon) && UI_NOICONS == false) {
|
||||
if (m_iFlags & BUTTON_DOWN)
|
||||
drawpic(m_parent.m_vecOrigin + m_vecOrigin + [4,4], m_strIcon, m_vecIMGSize, m_vecIconColor * 0.25, 1.0f, 0);
|
||||
else
|
||||
drawpic(m_parent.m_vecOrigin + m_vecOrigin + [4,4], m_strIcon, m_vecIMGSize, m_vecIconColor, 1.0f, 0);
|
||||
|
||||
textPadding += m_vecIMGSize[0] + 4;
|
||||
}
|
||||
|
||||
if (STRING_SET(m_strTitle)) {
|
||||
if (m_iFlags & BUTTON_HOVER) {
|
||||
Font_DrawText_RGB(m_parent.m_vecOrigin + m_vecOrigin + [textPadding, 8], m_strTitle, [1,1,1], g_fntMenuButton);
|
||||
} else {
|
||||
Font_DrawText_RGB(m_parent.m_vecOrigin + m_vecOrigin + [textPadding, 8], m_strTitle, [0.75,0.75,0.75], g_fntMenuButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -86,4 +139,11 @@ VGUIMenuButton::Input (float flEVType, float flKey, float flChar, float flDevID)
|
|||
return super::Input(flEVType, flKey, flChar, flDevID);
|
||||
}
|
||||
|
||||
void
|
||||
VGUIMenuButton::SetPosition(int newPosition)
|
||||
{
|
||||
m_menuPosition = newPosition;
|
||||
Reposition();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
106
src/vgui/ui_menutitle.qc
Normal file
106
src/vgui/ui_menutitle.qc
Normal file
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2022 Vera Visions LLC.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef MENU
|
||||
/** VGUI Widget: Menu Title
|
||||
|
||||
@ingroup vgui
|
||||
*/
|
||||
class VGUIMenuTitle:VGUILabel
|
||||
{
|
||||
public:
|
||||
void VGUIMenuTitle(void);
|
||||
|
||||
virtual void Draw(void);
|
||||
virtual void Reposition(void);
|
||||
virtual float Input(float, float, float, float);
|
||||
|
||||
bool m_bIsImage;
|
||||
bool m_hover;
|
||||
};
|
||||
|
||||
void
|
||||
VGUIMenuTitle::VGUIMenuTitle(void)
|
||||
{
|
||||
m_bIsImage = false;
|
||||
}
|
||||
|
||||
void
|
||||
VGUIMenuTitle::Reposition(void)
|
||||
{
|
||||
string title = GameLibrary_GetInfo(GAMEINFO_TITLE);
|
||||
string subTitle = GameLibrary_GetInfo(GAMEINFO_SUBTITLE);
|
||||
super::Reposition();
|
||||
vector newPosition;
|
||||
|
||||
if (STRING_SET(!title)) {
|
||||
if (fileExists("resource/game_menu_mouseover.tga")) {
|
||||
newPosition = [g_vidsize[0] / 16, g_vidsize[1] / 2 - 64];
|
||||
newPosition[1] -= 32;
|
||||
m_bIsImage = true;
|
||||
SetSize([196,32]);
|
||||
}
|
||||
} else {
|
||||
newPosition = [g_vidsize[0] / 16, g_vidsize[1] / 2 - 64];
|
||||
newPosition[1] -= 32;
|
||||
SetSize([Font_StringWidth(title, true, g_fntTitle), 32]);
|
||||
}
|
||||
|
||||
SetPos(newPosition);
|
||||
}
|
||||
|
||||
void
|
||||
VGUIMenuTitle::Draw(void)
|
||||
{
|
||||
if (m_bIsImage) {
|
||||
if (m_hover)
|
||||
drawpic(m_parent.m_vecOrigin + m_vecOrigin, "resource/game_menu_mouseover.tga", m_vecSize, [1,1,1], 1.0f, 0);
|
||||
else
|
||||
drawpic(m_parent.m_vecOrigin + m_vecOrigin, "resource/game_menu.tga", m_vecSize, [1,1,1], 1.0f, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
string title = GameLibrary_GetInfo(GAMEINFO_TITLE);
|
||||
string subTitle = GameLibrary_GetInfo(GAMEINFO_SUBTITLE);
|
||||
|
||||
vector pos;
|
||||
vector size;
|
||||
|
||||
pos = m_parent.m_vecOrigin + m_vecOrigin;
|
||||
size = m_vecSize;
|
||||
|
||||
if (STRING_SET(title))
|
||||
Font_DrawField(pos, size + [64,0], title, g_fntTitle, m_labelFlags);
|
||||
|
||||
if (STRING_SET(subTitle))
|
||||
Font_DrawField(pos + [0, 32], size + [64,0], subTitle, g_fntSubTitle, AF_RIGHT | AF_TOP);
|
||||
}
|
||||
|
||||
bool
|
||||
VGUIMenuTitle::Input(float flEVType, float flKey, float flChar, float flDevID)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
if (Util_MouseAbove(g_vecMousePos, m_parent.m_vecOrigin + m_vecOrigin, m_vecSize)) {
|
||||
m_hover = true;
|
||||
} else {
|
||||
m_hover = false;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -21,6 +21,8 @@ enumflags
|
|||
TEXTBOX_FOCUS
|
||||
};
|
||||
|
||||
.void(void) tmpVGUITextBox1;
|
||||
|
||||
/** VGUI Widget: Text Box
|
||||
|
||||
@ingroup vgui
|
||||
|
@ -67,15 +69,25 @@ string VGUITextBox::GetText(void)
|
|||
return m_strText;
|
||||
}
|
||||
|
||||
void
|
||||
VGUITextBox::CallOnEnter(void(void) func)
|
||||
{
|
||||
//#warning "SetFunc in VGUIButton is DEPRECATED. Compiler IS generating JUNK in the old way. Please override VGUIButton and define a OnMouseDown/Up method instead"
|
||||
//m_vFunc = vFunc;
|
||||
tmpVGUITextBox1 = func;
|
||||
}
|
||||
|
||||
void VGUITextBox::Draw(void)
|
||||
{
|
||||
VGUITheme theme = GetTheme();
|
||||
vector pos = m_parent.m_vecOrigin + m_vecOrigin;
|
||||
drawsetcliparea(pos[0], pos[1], m_vecSize[0], m_vecSize[1]);
|
||||
|
||||
drawfill(m_parent.m_vecOrigin + m_vecOrigin, m_vecSize, [0,0,0], 0.25f);
|
||||
drawfill(m_parent.m_vecOrigin + m_vecOrigin, [m_vecSize[0], 1], [0,0,0], 0.5f);
|
||||
drawfill(m_parent.m_vecOrigin + m_vecOrigin + [0, m_vecSize[1] - 1], [m_vecSize[0], 1], [1,1,1], 0.5f);
|
||||
drawfill(m_parent.m_vecOrigin + m_vecOrigin + [0, 1], [1, m_vecSize[1] - 2], [0,0,0], 0.5f);
|
||||
drawfill(m_parent.m_vecOrigin + m_vecOrigin + [m_vecSize[0] - 1, 1], [1, m_vecSize[1] - 2], [1,1,1], 0.5f);
|
||||
drawfill(pos, m_vecSize, [0,0,0], 0.25f);
|
||||
drawfill(pos, [m_vecSize[0], 1], [0,0,0], 0.5f);
|
||||
drawfill(pos + [0, m_vecSize[1] - 1], [m_vecSize[0], 1], [1,1,1], 0.5f);
|
||||
drawfill(pos + [0, 1], [1, m_vecSize[1] - 2], [0,0,0], 0.5f);
|
||||
drawfill(pos + [m_vecSize[0] - 1, 1], [1, m_vecSize[1] - 2], [1,1,1], 0.5f);
|
||||
|
||||
m_flTime += frametime * 2;
|
||||
|
||||
|
@ -86,14 +98,17 @@ void VGUITextBox::Draw(void)
|
|||
// blinking cursor
|
||||
if (m_iFlags & TEXTBOX_FOCUS) {
|
||||
if (rint(m_flTime) & 1) {
|
||||
theme.DrawText(m_parent.m_vecOrigin + m_vecOrigin + [8 - ofs, 8], sprintf("%s|", m_strText), m_vecSize, g_fntDefault);
|
||||
theme.DrawText(pos + [8 - ofs, 8], sprintf("%s|", m_strText), m_vecSize, g_fntDefault);
|
||||
drawresetcliparea();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (m_strText) {
|
||||
theme.DrawText(m_parent.m_vecOrigin + m_vecOrigin + [8 - ofs, 8], m_strText, m_vecSize, g_fntDefault);
|
||||
theme.DrawText(pos + [8 - ofs, 8], m_strText, m_vecSize, g_fntDefault);
|
||||
}
|
||||
|
||||
drawresetcliparea();
|
||||
}
|
||||
|
||||
bool VGUITextBox::Input (float flEVType, float flKey, float flChar, float flDevID)
|
||||
|
@ -123,6 +138,9 @@ bool VGUITextBox::Input (float flEVType, float flKey, float flChar, float flDevI
|
|||
m_strText = substring(m_strText, 0, strlen(m_strText) - 1);
|
||||
break;
|
||||
case K_ENTER:
|
||||
if (tmpVGUITextBox1) {
|
||||
tmpVGUITextBox1();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (m_iFlags & TEXTBOX_DOWN)
|
||||
|
|
|
@ -118,6 +118,7 @@ VGUITheme::DrawBorder(vector atPos, vector withSize, VGUIBorderStyle_t borderSty
|
|||
{
|
||||
switch (borderStyle) {
|
||||
case VGUI_BORDER_INSET:
|
||||
drawfill(atPos + [1, 1], withSize + [-2, -2], [0,0,0], 0.25f);
|
||||
drawfill(atPos + [0, withSize[1] - 1], [withSize[0], 1], m_hilightColor.GetColor(), m_hilightColor.GetAlpha());
|
||||
drawfill(atPos, [withSize[0], 1], m_shadowColor.GetColor(), m_shadowColor.GetAlpha());
|
||||
drawfill(atPos + [0, 1], [1, withSize[1] - 2], m_shadowColor.GetColor(), m_shadowColor.GetAlpha());
|
||||
|
|
Loading…
Reference in a new issue