More work on the menu: Added map menu, simple server browser...
This commit is contained in:
parent
47f3f3a411
commit
4bcea672ff
17 changed files with 574 additions and 89 deletions
|
@ -40,13 +40,19 @@ var float fMouseClick;
|
|||
var int iMenuActive;
|
||||
|
||||
var float fMenuScale;
|
||||
var float fMenuAlpha;
|
||||
|
||||
float frametime;
|
||||
float fLastTime;
|
||||
|
||||
int iMenu;
|
||||
string *sMapList;
|
||||
int iMapCount;
|
||||
|
||||
// Draw.c & Objects.c
|
||||
float fFadeAlpha;
|
||||
int iButtonSelected;
|
||||
|
||||
/*
|
||||
=================
|
||||
gcd_r
|
||||
|
@ -55,11 +61,10 @@ Returns the greatest common denominator
|
|||
=================
|
||||
*/
|
||||
int gcd_r( float a, float b ) {
|
||||
if ( a == 0 ) {
|
||||
return b;
|
||||
}
|
||||
|
||||
return gcd_r( floor( b%a ), a );
|
||||
if ( a == 0 ) {
|
||||
return b;
|
||||
}
|
||||
return gcd_r( floor( b%a ), a );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -83,9 +88,7 @@ Returns the menu size for the given ratio.
|
|||
*/
|
||||
vector Menu_Util_GetMenuSize( vector vAspect ) {
|
||||
float fScale = ( vAspect_x / vAspect_y );
|
||||
|
||||
return [ rint( 480 * fScale ), 480 ];
|
||||
|
||||
return [ rint( 480 * fScale ), 480 ];
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -19,72 +19,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
int iMenuStage;
|
||||
float fFadeAlpha;
|
||||
int iButtonSelected;
|
||||
|
||||
void drawmenupic( vector vPosition, string sPic, vector vSize, vector vRGB, float fAlpha, float fDrawflag ) {
|
||||
vSize = vSize * fMenuScale;
|
||||
vPosition = vPosition * fMenuScale;
|
||||
drawpic( vPosition + [ iMenuPadding, 0, 0 ], sPic, vSize, vRGB, fAlpha, fDrawflag );
|
||||
}
|
||||
|
||||
void drawmenustring( vector vPosition, string sText, vector vSize, vector vRGB, float fAlpha, float fDrawflag ) {
|
||||
vSize = vSize * fMenuScale;
|
||||
vPosition = vPosition * fMenuScale;
|
||||
drawstring( vPosition + [ iMenuPadding, 0, 0 ], sText, vSize, vRGB, fAlpha, fDrawflag );
|
||||
}
|
||||
|
||||
void m_mainbutton( vector vPos, string sText, int iItem, void() vFunc) {
|
||||
static float fSelectionAlpha;
|
||||
|
||||
if ( Menu_InputCheckMouse( vPos, '182 14' ) == TRUE ) {
|
||||
if ( iButtonSelected != iItem ) {
|
||||
iButtonSelected = iItem;
|
||||
fSelectionAlpha = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if ( iButtonSelected == iItem ) {
|
||||
if ( fMouseClick == TRUE ) {
|
||||
drawmenustring( vPos, sText, '14 14', '1 0.5 0', fSelectionAlpha, 0 );
|
||||
vFunc();
|
||||
fMouseClick = FALSE;
|
||||
} else {
|
||||
drawmenustring( vPos, sText, '14 14', '1 1 1', 1 - fSelectionAlpha, 0 );
|
||||
drawmenustring( vPos, sText, '14 14', '0.3 0.3 1', fSelectionAlpha, 0 );
|
||||
}
|
||||
} else {
|
||||
drawmenustring( vPos, sText, '14 14', '1 1 1', fFadeAlpha, 0 );
|
||||
}
|
||||
|
||||
if ( fSelectionAlpha < 1.0f ) {
|
||||
fSelectionAlpha += frametime;
|
||||
if ( fSelectionAlpha > 1.0f ) {
|
||||
fSelectionAlpha = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void m_button_findserver( void ) {
|
||||
|
||||
enum {
|
||||
MAIN_NONE,
|
||||
MAIN_BROWSER,
|
||||
MAIN_HOST,
|
||||
MAIN_OPTIONS,
|
||||
MAIN_REPLAY,
|
||||
MAIN_QUIT,
|
||||
MAIN_DISCONNECT
|
||||
};
|
||||
|
||||
void m_button_createserver( void ) {
|
||||
localcmd( "map cs_office\n" );
|
||||
};
|
||||
|
||||
void m_button_options( void ) {
|
||||
|
||||
};
|
||||
|
||||
void m_button_replays( void ) {
|
||||
|
||||
};
|
||||
|
||||
void m_button_quit( void ) {
|
||||
localcmd( "quit\n" );
|
||||
};
|
||||
/*
|
||||
=================
|
||||
m_drawback
|
||||
|
||||
Responsible for the fancy menu background
|
||||
=================
|
||||
*/
|
||||
void m_drawback( void ) {
|
||||
if ( clientstate() == 2 ) {
|
||||
drawfill( '0 0', vVideoSize, '0 0 0', 0.75f );
|
||||
|
@ -95,6 +47,13 @@ void m_drawback( void ) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
m_draw
|
||||
|
||||
Run every frame, main loop for the menu
|
||||
=================
|
||||
*/
|
||||
void m_draw( vector vScreenSize ) {
|
||||
if ( iMenuActive == FALSE ) {
|
||||
return;
|
||||
|
@ -128,17 +87,19 @@ void m_draw( vector vScreenSize ) {
|
|||
|
||||
if ( time < 5 ) {
|
||||
iMenuStage = 0;
|
||||
drawmenustring( '45 45', "FreeCS (c) 2016, 2017", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '45 85', "Note that FreeCS is not affiliated", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '45 105', "with Steam or Valve.", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '45 125', "The source code for this is released", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '45 145', "under the GPL v2.", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '45 185', "FreeCS requires the content from:", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '45 205', "Counter-Strike 1.5", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '45 225', "Half-Life", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '45 265', "Please see visit:", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '45 285', "eukara.github.io/FreeCS", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '45 325', "Developed by Marco Hladik", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenupic( '48 48 0', "gfx/logo", '64 64', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenupic( '144 48 0', "gfx/menu/freecs", '256 64', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '48 141', "FreeCS (c) 2016, 2017", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '48 181', "Note that FreeCS is not affiliated", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '48 201', "with Steam or Valve.", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '48 221', "The source code for this is released", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '48 241', "under the GPL v2.", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '48 281', "FreeCS requires the content from:", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '48 301', "Counter-Strike 1.5", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '48 321', "Half-Life", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '48 352', "Please see visit:", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '48 381', "eukara.github.io/FreeCS", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
drawmenustring( '48 421', "Developed by Marco Hladik", '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
} else if ( time < 8 ) {
|
||||
if ( iMenuStage == 0 ) {
|
||||
fFadeAlpha = 0.0f;
|
||||
|
@ -157,13 +118,21 @@ void m_draw( vector vScreenSize ) {
|
|||
}
|
||||
|
||||
m_drawback();
|
||||
drawmenupic( '25 145 0', "gfx/menu/freecs", '236 43', '1 1 1', fFadeAlpha, 0 );
|
||||
|
||||
m_mainbutton( '430 300', " FIND SERVER", 1, m_button_findserver );
|
||||
m_mainbutton( '430 324', "CREATE SERVER", 2, m_button_createserver );
|
||||
m_mainbutton( '430 348', " OPTIONS", 3, m_button_options);
|
||||
m_mainbutton( '430 372', " REPLAYS", 4, m_button_replays );
|
||||
m_mainbutton( '430 396', " QUIT", 5, m_button_quit );
|
||||
if ( !iMenu ) {
|
||||
drawmenupic( '25 145 0', "gfx/menu/freecs", '236 43', '1 1 1', fFadeAlpha, 0 );
|
||||
}
|
||||
|
||||
if ( clientstate() == 2 ) {
|
||||
m_mainbutton( '430 276', " DISCONNECT", MAIN_DISCONNECT, m_button_disconnect );
|
||||
}
|
||||
|
||||
m_mainbutton( '430 300', " FIND SERVER", MAIN_BROWSER, m_button_findserver );
|
||||
m_mainbutton( '430 324', "CREATE SERVER", MAIN_HOST, m_button_createserver );
|
||||
m_mainbutton( '430 348', " OPTIONS", MAIN_OPTIONS, m_button_options);
|
||||
m_mainbutton( '430 372', " REPLAYS", MAIN_REPLAY, m_button_replays );
|
||||
m_mainbutton( '430 396', " QUIT", MAIN_QUIT, m_button_quit );
|
||||
|
||||
}
|
||||
|
||||
if ( fFadeAlpha < 1.0f ) {
|
||||
|
@ -172,4 +141,11 @@ void m_draw( vector vScreenSize ) {
|
|||
fFadeAlpha = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if ( fMenuAlpha < 1.0f ) {
|
||||
fMenuAlpha += frametime * 0.5;
|
||||
if ( fMenuAlpha > 1.0f ) {
|
||||
fMenuAlpha = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,13 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
=================
|
||||
m_init
|
||||
|
||||
Precaches and loading for the menu system
|
||||
=================
|
||||
*/
|
||||
void m_init( void ) {
|
||||
precache_pic( "gfx/menu/freecs" );
|
||||
precache_pic( "gfx/menu/back1" );
|
||||
|
@ -36,6 +43,13 @@ void m_init( void ) {
|
|||
search_end( shMaps );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
m_shutdown
|
||||
|
||||
I can see the curtain... the ending.
|
||||
=================
|
||||
*/
|
||||
void m_shutdown( void ) {
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,13 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
=================
|
||||
Menu_InputCheckMouse
|
||||
|
||||
Checks a specified region and returns TRUE if the mouse is above it.
|
||||
=================
|
||||
*/
|
||||
int Menu_InputCheckMouse( vector vPos, vector vReg ) {
|
||||
vector vSMins, vSMaxs;
|
||||
|
||||
|
@ -41,6 +48,13 @@ int Menu_InputCheckMouse( vector vPos, vector vReg ) {
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Menu_InputEvent
|
||||
|
||||
New FTE routine for advanced mouse input in menuqc!
|
||||
=================
|
||||
*/
|
||||
float Menu_InputEvent( float fEventType, float fKey, float fCharacter, float fDeviceID ) {
|
||||
if ( fEventType == IE_KEYDOWN ) {
|
||||
if ( fKey == K_MOUSE1 ) {
|
||||
|
@ -72,6 +86,13 @@ float Menu_InputEvent( float fEventType, float fKey, float fCharacter, float fDe
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
m_display, m_hide, m_toggle
|
||||
|
||||
Essentially what happens when togglemenu is used, called by the engine as well.
|
||||
=================
|
||||
*/
|
||||
void m_display( void ) {
|
||||
iMenuActive = TRUE;
|
||||
setkeydest( KEY_MENU );
|
||||
|
|
87
Source/Menu/Menu_Create.c
Executable file
87
Source/Menu/Menu_Create.c
Executable file
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
FreeCS Project
|
||||
Copyright (C) 2016, 2017 Marco "eukara" Hladik
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
var int iMapSelected = 0;
|
||||
|
||||
/*
|
||||
=================
|
||||
m_mainbutton
|
||||
|
||||
Buttons on the main menu screen
|
||||
=================
|
||||
*/
|
||||
void menu_mapbutton( vector vPos, int iItem ) {
|
||||
|
||||
if ( Menu_InputCheckMouse( vPos, [ stringwidth( sMapList[ iItem ], TRUE, '16 16' ), 16 ] ) == TRUE ) {
|
||||
if ( fMouseClick == TRUE ) {
|
||||
iMapSelected = iItem;
|
||||
fMouseClick = FALSE;
|
||||
localsound( "misc/talk.wav" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( iMapSelected == iItem ) {
|
||||
drawmenustring( vPos, sMapList[ iItem ], '16 16', '1 0.5 0', 1.0f, 0 );
|
||||
} else {
|
||||
drawmenustring( vPos, sMapList[ iItem ], '16 16', '1 1 1', fFadeAlpha, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void m_button_createserver_go( void ) {
|
||||
localcmd( sprintf( "map %s\n", sMapList[ iMapSelected ] ) );
|
||||
}
|
||||
|
||||
void m_button_createserver( void ) {
|
||||
static int iMapOffset = 0;
|
||||
|
||||
static void m_button_createserver_listless( void ) {
|
||||
if ( iMapOffset - 15 > 0 ) {
|
||||
iMapOffset -= 15;
|
||||
} else {
|
||||
iMapOffset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void m_button_createserver_listmore( void ) {
|
||||
if ( iMapOffset + 15 < ( iMapCount - 15 ) ) {
|
||||
iMapOffset += 15;
|
||||
} else {
|
||||
iMapOffset = iMapCount - 15;
|
||||
}
|
||||
}
|
||||
|
||||
m_drawmenushadow();
|
||||
drawmenustring( '43 60 0', "CREATE SERVER", '16 16 0', '1 1 1', fMenuAlpha, FALSE );
|
||||
|
||||
vector vPos = '75 100';
|
||||
for ( float i = iMapOffset; i < ( 15 + iMapOffset ); i++ ) {
|
||||
if ( iMapSelected == i ) {
|
||||
drawmenustring( [ vPos_x - 32, vPos_y ], ">>", '16 16 0', '1 1 1', fMenuAlpha, FALSE );
|
||||
}
|
||||
|
||||
menu_mapbutton( vPos, i );
|
||||
vPos_y += 20;
|
||||
}
|
||||
|
||||
menu_buttoncmd( '332 332', "<<", '16 16', m_button_createserver_listless );
|
||||
menu_buttoncmd( '332 364', ">>", '16 16', m_button_createserver_listmore );
|
||||
|
||||
menu_buttoncmd( '232 410', "CREATE >>", '16 16', m_button_createserver_go );
|
||||
};
|
23
Source/Menu/Menu_Options.c
Executable file
23
Source/Menu/Menu_Options.c
Executable file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
FreeCS Project
|
||||
Copyright (C) 2016, 2017 Marco "eukara" Hladik
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
void m_button_options( void ) {
|
||||
|
||||
};
|
53
Source/Menu/Menu_Quit.c
Executable file
53
Source/Menu/Menu_Quit.c
Executable file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
FreeCS Project
|
||||
Copyright (C) 2016, 2017 Marco "eukara" Hladik
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
void m_button_quit( void ) {
|
||||
static void m_button_quit_yes( void ) {
|
||||
localcmd( "quit\n" );
|
||||
}
|
||||
static void m_button_quit_no( void ) {
|
||||
iMenu = 0;
|
||||
}
|
||||
|
||||
m_drawmenushadow();
|
||||
|
||||
drawmenustring( '43 60 0', "QUIT GAME", '16 16 0', '1 1 1', fMenuAlpha, FALSE );
|
||||
drawmenustring( '88 211 0', "Are you sure you want to quit?", '8 8 0', '1 1 1', fMenuAlpha, FALSE );
|
||||
menu_buttoncmd( '112 235 0', "Yes", '8 8', m_button_quit_yes );
|
||||
menu_buttoncmd( '283 235 0', "No", '8 8', m_button_quit_no );
|
||||
};
|
||||
|
||||
|
||||
void m_button_disconnect( void ) {
|
||||
static void m_button_disconnect_yes( void ) {
|
||||
iMenu = 0;
|
||||
localcmd( "disconnect\n" );
|
||||
}
|
||||
static void m_button_disconnect_no( void ) {
|
||||
iMenu = 0;
|
||||
}
|
||||
|
||||
m_drawmenushadow();
|
||||
|
||||
drawmenustring( '43 60 0', "DISCONNECT", '16 16 0', '1 1 1', fMenuAlpha, FALSE );
|
||||
drawmenustring( '88 211 0', "Close connection to the server?", '8 8 0', '1 1 1', fMenuAlpha, FALSE );
|
||||
menu_buttoncmd( '112 235 0', "Yes", '8 8', m_button_disconnect_yes );
|
||||
menu_buttoncmd( '283 235 0', "No", '8 8', m_button_disconnect_no );
|
||||
};
|
23
Source/Menu/Menu_Replays.c
Executable file
23
Source/Menu/Menu_Replays.c
Executable file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
FreeCS Project
|
||||
Copyright (C) 2016, 2017 Marco "eukara" Hladik
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
void m_button_replays( void ) {
|
||||
|
||||
};
|
149
Source/Menu/Menu_Servers.c
Executable file
149
Source/Menu/Menu_Servers.c
Executable file
|
@ -0,0 +1,149 @@
|
|||
/*
|
||||
FreeCS Project
|
||||
Copyright (C) 2016, 2017 Marco "eukara" Hladik
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
float fldName;
|
||||
float fldAddress;
|
||||
float fldPing;
|
||||
float fldPlayers;
|
||||
float fldMaxplayers;
|
||||
float fldMap;
|
||||
float fldTimelimit;
|
||||
float fldFraglimit;
|
||||
float fMaxServers;
|
||||
float fServerClickTime;
|
||||
|
||||
void Menu_Multiplayer_Connect( int iServerID ) {
|
||||
if ( gethostcachenumber( fldMaxplayers, iServerID ) <= 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( iServerID >= 0 ) {
|
||||
localcmd( sprintf( "connect %s\n", gethostcachestring( fldAddress, iServerID ) ) );
|
||||
m_hide();
|
||||
}
|
||||
}
|
||||
|
||||
void Menu_Multiplayer_Find_Item( float fPos, int i, __inout int iSelected ) {
|
||||
float fButtonAlpha = fMenuAlpha;
|
||||
|
||||
if ( Menu_InputCheckMouse( [ 47, fPos ], [ 314, 8 ] ) == TRUE ) {
|
||||
if ( fMouseClick == TRUE ) {
|
||||
if ( iSelected != i ) {
|
||||
iSelected = i;
|
||||
fInputKeyCode = 0;
|
||||
fMouseClick = FALSE;
|
||||
fServerClickTime = time + 0.2;
|
||||
} else {
|
||||
if ( fServerClickTime > time ) {
|
||||
Menu_Multiplayer_Connect( i );
|
||||
}
|
||||
iSelected = -2;
|
||||
fInputKeyCode = 0;
|
||||
fMouseClick = FALSE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fButtonAlpha *= 0.5;
|
||||
}
|
||||
|
||||
if ( iSelected == i ) {
|
||||
drawmenufill( [ 40, fPos - 1 ], [ 323, 10 ], '1 1 1', fMenuAlpha * 0.5, 2 );
|
||||
drawmenustring( [48, fPos], sprintf( "%.16s", gethostcachestring( fldName, i ) ), '8 8 0', '1 1 1', fMenuAlpha, FALSE );
|
||||
drawmenustring( [184, fPos], sprintf( "%.10s", gethostcachestring( fldMap, i ) ), '8 8 0', '1 1 1', fMenuAlpha, FALSE );
|
||||
drawmenustring( [264, fPos], sprintf( "%d/%d", gethostcachenumber( fldPlayers, i ), gethostcachenumber( fldMaxplayers, i ) ), '8 8 0', '1 1 1', fMenuAlpha, FALSE );
|
||||
drawmenustring( [328, fPos], sprintf( "%.3s", ftos( gethostcachenumber( fldPing, i ) ) ), '8 8 0', '1 1 1', fMenuAlpha, FALSE );
|
||||
} else {
|
||||
drawmenustring( [48, fPos], sprintf( "^2%.16s", gethostcachestring( fldName, i ) ), '8 8 0', '1 1 1', fButtonAlpha, FALSE );
|
||||
drawmenustring( [184, fPos], sprintf( "%.10s", gethostcachestring( fldMap, i ) ), '8 8 0', '1 1 1', fButtonAlpha, FALSE );
|
||||
drawmenustring( [264, fPos], sprintf( "%d/%d", gethostcachenumber( fldPlayers, i ), gethostcachenumber( fldMaxplayers, i ) ), '8 8 0', '1 1 1', fButtonAlpha, FALSE );
|
||||
drawmenustring( [328, fPos], sprintf( "%.3s", ftos( gethostcachenumber( fldPing, i ) ) ), '8 8 0', '1 1 1', fButtonAlpha, FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
void m_button_findserver( void ) {
|
||||
static int iSelectedServer = -1;
|
||||
static float fServerOffset;
|
||||
|
||||
static void Menu_Multiplayer_Find_Refresh( void ) {
|
||||
refreshhostcache();
|
||||
resorthostcache();
|
||||
}
|
||||
static void Menu_Multiplayer_Find_ScrollDown( void ) {
|
||||
fServerOffset++;
|
||||
if ( fServerOffset > fMaxServers ) {
|
||||
fServerOffset = fMaxServers;
|
||||
}
|
||||
}
|
||||
static void Menu_Multiplayer_Find_ScrollUp( void ) {
|
||||
fServerOffset--;
|
||||
if ( fServerOffset < 0 ) {
|
||||
fServerOffset = 0;
|
||||
}
|
||||
}
|
||||
static void Menu_Multiplayer_Find_Connect( void ) {
|
||||
Menu_Multiplayer_Connect( iSelectedServer );
|
||||
}
|
||||
|
||||
m_drawmenushadow();
|
||||
drawmenustring( '43 60 0', "FIND SERVER", '16 16 0', '1 1 1', fMenuAlpha, FALSE );
|
||||
|
||||
if ( iSelectedServer == -1 ) {
|
||||
localcmd( "com_protocolname FTE-Quake\n" );
|
||||
//clear the filter
|
||||
resethostcachemasks();
|
||||
sethostcachemaskstring( 0, gethostcacheindexforkey("gamedir"), "freecs", SLIST_TEST_EQUAL );
|
||||
sethostcachesort( gethostcacheindexforkey( "ping" ), FALSE );
|
||||
refreshhostcache();
|
||||
resorthostcache();
|
||||
iSelectedServer = 0;
|
||||
}
|
||||
|
||||
fMaxServers = gethostcachevalue( SLIST_HOSTCACHEVIEWCOUNT );
|
||||
if ( fMaxServers >= 28 ) {
|
||||
fMaxServers -= 28;
|
||||
}
|
||||
|
||||
fldName = gethostcacheindexforkey("name");
|
||||
fldAddress = gethostcacheindexforkey("cname");
|
||||
fldPing = gethostcacheindexforkey("ping");
|
||||
fldPlayers = gethostcacheindexforkey("numhumans");
|
||||
fldMaxplayers = gethostcacheindexforkey("maxplayers");
|
||||
fldMap = gethostcacheindexforkey("map");
|
||||
fldTimelimit = gethostcacheindexforkey("timelimit");
|
||||
fldFraglimit = gethostcacheindexforkey("fraglimit");
|
||||
|
||||
drawmenustring( '48 100 0', "Name", '8 8 0', '1 1 1', fMenuAlpha, FALSE );
|
||||
drawmenustring( '184 100 0', "Map", '8 8 0', '1 1 1', fMenuAlpha, FALSE );
|
||||
drawmenustring( '264 100 0', "Players", '8 8 0', '1 1 1', fMenuAlpha, FALSE );
|
||||
drawmenustring( '328 100 0', "Ping", '8 8 0', '1 1 1', fMenuAlpha, FALSE );
|
||||
|
||||
float fPos = 120;
|
||||
for ( float i = fServerOffset; i < ( 28 + fServerOffset ); i++ ) {
|
||||
Menu_Multiplayer_Find_Item( fPos, i, iSelectedServer );
|
||||
fPos += 10;
|
||||
}
|
||||
|
||||
menu_buttoncmd( '128 410', "Refresh", '8 8', Menu_Multiplayer_Find_Refresh );
|
||||
menu_buttoncmd( '280 420', "Connect >>", '8 8', Menu_Multiplayer_Find_Connect );
|
||||
|
||||
// Scrollbars
|
||||
menu_buttoncmd( '368 100', "<", '8 8', Menu_Multiplayer_Find_ScrollUp );
|
||||
menu_buttoncmd( '368 400', ">", '8 8', Menu_Multiplayer_Find_ScrollDown );
|
||||
}
|
131
Source/Menu/Objects.c
Executable file
131
Source/Menu/Objects.c
Executable file
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
FreeCS Project
|
||||
Copyright (C) 2016, 2017 Marco "eukara" Hladik
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
=================
|
||||
drawmenupic
|
||||
|
||||
Wrapper for drawpic that cares about resolution and scales.
|
||||
=================
|
||||
*/
|
||||
void drawmenupic( vector vPosition, string sPic, vector vSize, vector vRGB, float fAlpha, float fDrawflag ) {
|
||||
vSize = vSize * fMenuScale;
|
||||
vPosition = vPosition * fMenuScale;
|
||||
drawpic( vPosition + [ iMenuPadding, 0, 0 ], sPic, vSize, vRGB, fAlpha, fDrawflag );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
drawmenufill
|
||||
|
||||
Wrapper for drawpic that cares about resolution and scales.
|
||||
=================
|
||||
*/
|
||||
void drawmenufill( vector vPosition, vector vSize, vector vRGB, float fAlpha, float fDrawflag ) {
|
||||
vSize = vSize * fMenuScale;
|
||||
vPosition = vPosition * fMenuScale;
|
||||
drawfill( vPosition + [ iMenuPadding, 0, 0 ], vSize, vRGB, fAlpha, fDrawflag );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
drawmenustring
|
||||
|
||||
Wrapper for drawstring that cares about resolution and scales.
|
||||
=================
|
||||
*/
|
||||
void drawmenustring( vector vPosition, string sText, vector vSize, vector vRGB, float fAlpha, float fDrawflag ) {
|
||||
vSize = vSize * fMenuScale;
|
||||
vPosition = vPosition * fMenuScale;
|
||||
drawstring( vPosition + [ iMenuPadding, 0, 0 ], sText, vSize, vRGB, fAlpha, fDrawflag );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
m_mainbutton
|
||||
|
||||
Buttons on the main menu screen
|
||||
=================
|
||||
*/
|
||||
void m_mainbutton( vector vPos, string sText, int iItem, void() vFunc) {
|
||||
static float fSelectionAlpha;
|
||||
|
||||
if ( Menu_InputCheckMouse( vPos, '182 14' ) == TRUE ) {
|
||||
if ( iButtonSelected != iItem ) {
|
||||
iButtonSelected = iItem;
|
||||
fSelectionAlpha = 0.0f;
|
||||
}
|
||||
|
||||
if ( fMouseClick == TRUE ) {
|
||||
if ( iMenu == iItem ) {
|
||||
iMenu = 0;
|
||||
} else {
|
||||
iMenu = iItem;
|
||||
}
|
||||
fMenuAlpha = 0.0f;
|
||||
fMouseClick = FALSE;
|
||||
localsound( "buttons/button9.wav" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( iMenu == iItem ) {
|
||||
drawmenustring( vPos, sText, '14 14', '1 0.5 0', 1.0f, 0 );
|
||||
vFunc();
|
||||
} else {
|
||||
if ( iButtonSelected == iItem ) {
|
||||
drawmenustring( vPos, sText, '14 14', '1 1 1', 1 - fSelectionAlpha, 0 );
|
||||
drawmenustring( vPos, sText, '14 14', '0.3 0.3 1', fSelectionAlpha, 0 );
|
||||
} else {
|
||||
drawmenustring( vPos, sText, '14 14', '1 1 1', fFadeAlpha, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( fSelectionAlpha < 1.0f ) {
|
||||
fSelectionAlpha += frametime;
|
||||
if ( fSelectionAlpha > 1.0f ) {
|
||||
fSelectionAlpha = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void menu_buttoncmd( vector vPosition, string sLabel, vector vFSize, void() vFunc ) {
|
||||
float fButtonAlpha = fMenuAlpha;
|
||||
if ( Menu_InputCheckMouse( vPosition, [ stringwidth( sLabel, TRUE, vFSize), vFSize_y ] ) == TRUE ) {
|
||||
if ( fMouseClick == TRUE ) {
|
||||
vFunc();
|
||||
fMouseClick = FALSE;
|
||||
localsound( "buttons/button7.wav" );
|
||||
}
|
||||
drawmenufill( vPosition + [ 0, vFSize_y + 2 ], [ stringwidth( sLabel, TRUE, vFSize ), 2 ], '1 1 1', fMenuAlpha * 0.5, 0 );
|
||||
} else {
|
||||
fButtonAlpha *= 0.5;
|
||||
}
|
||||
drawmenustring( vPosition, sLabel, vFSize, '1 1 1', fButtonAlpha, FALSE );
|
||||
}
|
||||
|
||||
#define OUTLINE_COLOR '0.8 0.8 1'
|
||||
void m_drawmenushadow( void ) {
|
||||
drawmenufill( '16 32', '380 430', '0 0 0', fMenuAlpha * 0.75, 2 ); // Backdrop
|
||||
drawmenufill( '15 32', '1 430', OUTLINE_COLOR, fMenuAlpha * 0.5, 2 ); // Left
|
||||
drawmenufill( '397 32', '1 430', OUTLINE_COLOR, fMenuAlpha * 0.5, 2 ); // Right
|
||||
drawmenufill( '15 31', '383 1', OUTLINE_COLOR, fMenuAlpha * 0.5, 2 ); // Up
|
||||
drawmenufill( '15 462', '383 1', OUTLINE_COLOR, fMenuAlpha * 0.5, 2 ); // Down
|
||||
}
|
|
@ -10,5 +10,11 @@
|
|||
Defs.h
|
||||
Init.c
|
||||
Input.c
|
||||
Objects.c
|
||||
Menu_Create.c
|
||||
Menu_Options.c
|
||||
Menu_Quit.c
|
||||
Menu_Replays.c
|
||||
Menu_Servers.c
|
||||
Draw.c
|
||||
#endlist
|
||||
|
|
|
@ -41,7 +41,7 @@ entity hostage_waypoint( void ) {
|
|||
setsize( ePoint, self.mins, self.maxs );
|
||||
ePoint.classname = "remove_me";
|
||||
ePoint.movetype = MOVETYPE_TOSS;
|
||||
setmodel( ePoint, "models/chick.mdl" ); // Visual feedback...
|
||||
// setmodel( ePoint, "models/chick.mdl" ); // Visual feedback...
|
||||
return ePoint;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,6 @@ void Spawn_ObserverCam( void ) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
bprint( "Can't find fucking camera\n" );
|
||||
// Can't find a camera? Just do this lazy thing, CS seems to do the same
|
||||
eCamera = find ( world, classname, "info_player_start" );
|
||||
|
||||
|
|
BIN
freecs/gfx/cursor.tga
Executable file
BIN
freecs/gfx/cursor.tga
Executable file
Binary file not shown.
BIN
freecs/gfx/logo.tga
Executable file
BIN
freecs/gfx/logo.tga
Executable file
Binary file not shown.
BIN
freecs/menu.dat
BIN
freecs/menu.dat
Binary file not shown.
BIN
freecs/progs.dat
BIN
freecs/progs.dat
Binary file not shown.
Loading…
Reference in a new issue