More work towards the new menu

This commit is contained in:
Marco Cawthorne 2017-06-22 01:49:28 +02:00
parent e58ddeb566
commit dd83d09250
22 changed files with 272 additions and 602 deletions

View file

@ -17,6 +17,7 @@ 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.
*/
#include "VGUI.h"
vector HUD_GetChatColor( float fTeam ) {

View file

@ -24,7 +24,7 @@
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Client\VGUITeamSelect.c" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Client\View.c" />
</category>
<category name="Server" expanded="yes">
<category name="Server" expanded="no">
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Server\AmbientSound.c" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Server\Ammo.c" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Server\ArmouryEntity.c" />
@ -59,20 +59,16 @@
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Server\TraceAttack.c" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Server\Triggers.c" />
</category>
<category name="Menu" expanded="no">
<category name="Menu" expanded="yes">
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Menu\Defs.h" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Menu\Draw.c" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Menu\Init.c" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Menu\Input.c" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Menu\Menu_Create.c" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Menu\Menu_Options.c" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Menu\Menu_Quit.c" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Menu\Menu_Replays.c" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Menu\Menu_Servers.c" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Menu\MenuMain.c" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Menu\Objects.c" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Menu\progs.src" />
</category>
<category name="Shared" expanded="yes">
<category name="Shared" expanded="no">
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Shared\Animations.c" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Shared\BaseMelee.c" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Shared\Effects.c" />
@ -114,19 +110,15 @@
</project>
<workspace version="Crimson Editor 3.60">
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Shared\WeaponHEGrenade.c" linenum="98" placement="0:1:-1:-1:-4:-23:44:44:892:514" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Shared\WeaponC4Bomb.c" linenum="116" placement="0:1:-1:-1:-4:-23:66:66:918:540" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Shared\WeaponFlashbang.c" linenum="109" placement="0:1:-1:-1:-4:-23:88:88:940:562" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Shared\Effects.c" linenum="32" placement="0:1:-1:-1:-4:-23:132:132:984:606" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Client\Defs.h" linenum="94" placement="0:1:-1:-1:-4:-23:154:154:1006:628" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Globals.h" linenum="223" placement="0:1:-1:-1:-4:-23:176:176:1028:650" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Client\Event.c" linenum="470" placement="0:1:-1:-1:-4:-23:198:198:1050:672" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Client\Init.c" linenum="31" placement="0:1:-1:-1:-4:-23:220:220:1072:694" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Server\Defs.h" linenum="151" placement="0:1:-1:-1:-4:-23:0:0:852:474" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Builtins.h" linenum="860" placement="0:1:-1:-1:-4:-23:22:22:874:496" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Client\HUDWeaponSelect.c" linenum="187" placement="0:1:-1:-1:-4:-23:44:44:896:518" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\freecs\default.cfg" linenum="72" placement="2:3:-1:-1:-4:-23:66:66:918:540" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Server\Damage.c" linenum="179" placement="0:1:-1:-1:-4:-23:88:88:940:562" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\conhistory.txt" linenum="72" placement="0:1:-1:-1:-4:-23:110:110:962:584" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Menu\Objects.c" linenum="135" placement="0:1:-1:-1:-4:-23:110:110:958:580" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Menu\Draw.c" linenum="77" placement="0:1:-1:-1:-4:-23:132:132:984:606" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Menu\Defs.h" linenum="40" placement="2:3:-1:-1:-4:-23:154:154:1006:628" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Menu\Init.c" linenum="33" placement="0:1:-1:-1:-4:-23:198:198:1050:672" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Menu\Input.c" linenum="1" placement="0:1:-1:-1:-4:-23:220:220:1072:694" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Menu\MenuMain.c" linenum="20" placement="0:1:-1:-1:-4:-23:132:132:984:606" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Menu\progs.src" linenum="14" placement="0:1:-1:-1:-4:-23:154:154:1006:628" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Client\VGUIObjects.c" linenum="20" placement="0:1:-1:-1:-4:-23:176:176:1028:650" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Builtins.h" linenum="2228" placement="0:1:-1:-1:-4:-23:198:198:1050:672" />
<localfile path="C:\Cygwin\home\eukara\Projects\FreeCS\Source\Client\VGUIScoreboard.c" linenum="1" placement="0:1:-1:-1:-4:-23:220:220:1072:694" />
</workspace>

View file

@ -26,22 +26,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define TARGET_MENU 1
#define TARGET_CLIENT 2
var vector vVideoAspect;
var vector vVideoSize;
var vector vMenuSize;
var int iMenuPadding;
var vector vMenuOffset;
var vector vMousePos;
var float fInputKeyCode;
var float fInputKeyASCII;
var float fInputKeyDown;
var float fMouseClick;
var float fButtonAlpha[8];
var int iMenuActive;
var float fMenuScale;
var float fMenuAlpha;
float frametime;
float fLastTime;
@ -49,55 +45,80 @@ int iMenu;
string *sMapList;
int iMapCount;
// Draw.c & Objects.c
float fFadeAlpha;
int iButtonSelected;
enum {
MENU_MAIN,
MENU_QUIT
};
/*
=================
gcd_r
Returns the greatest common denominator
=================
*/
int gcd_r( float a, float b ) {
if ( a == 0 ) {
return b;
}
return gcd_r( floor( b%a ), a );
}
/*
=================
Menu_Util_GetAspect
Returns the aspect ratio for the current mode.
=================
*/
vector Menu_Util_GetAspect( vector vResolution ) {
int r = gcd_r( vResolution_x, vResolution_y );
return [ vResolution_x/r, vResolution_y/r ];
}
/*
=================
Menu_Util_GetAspectSize
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 ];
}
/*
=================
Menu_Util_GetMenuPadding
Returns the padding size for the current ratio.
=================
*/
int Menu_Util_GetMenuPadding( void ) {
return ( vMenuSize_x - 640 ) / 2;
}
#define MENU_BUTTONS 69
enum {
BTN_NEWGAME,
BTN_RESUMEGAME,
BTN_TRAINING,
BTN_CONFIG,
BTN_LOADGAME,
BTN_SAVELOAD,
BTN_README,
BTN_QUIT,
BTN_MULTIPLAYER,
BTN_EASY,
BTN_MEDIUM,
BTN_DIFFICULT,
BTN_SAVEGAME,
BTN_LOADGAME2,
BTN_CANCEL,
BTN_OPTIONS,
BTN_VIDEO,
BTN_AUDIO,
BTN_CONTROLS,
BTN_DONE,
BTN_QUICKSTART,
BTN_DEFAULTS,
BTN_OK,
BTN_VIDEOOPTIONS,
BTN_VIDEOMODES,
BTN_ADVCONTROLS,
BTN_ORDER,
BTN_DELETE,
BTN_INTERNET,
BTN_IRCCHAT,
BTN_LAN,
BTN_CUSTOMIZE,
BTN_SKIP,
BTN_EXIT,
BTN_CONNECT,
BTN_REFRESH,
BTN_FILTER,
BTN_CREATE,
BTN_CREATEGAME,
BTN_CHATROOMS,
BTN_LISTROOMS,
BTN_SEARCH,
BTN_SERVERS,
BTN_JOIN,
BTN_FIND,
BTN_CREATEROOM,
BTN_JOINGAME,
BTN_SEARCHGAMES,
BTN_FINDGAME,
BTN_STARTGAME,
BTN_GAMEINFO,
BTN_UPDATE,
BTN_ADDSERVER,
BTN_DISCONNECT,
BTN_CONSOLE,
BTN_CONTENTCONTROL,
BTN_UPDATE,
BTN_VISITWON,
BTN_PREVIEWS,
BTN_ADVOPTIONS,
BTN_3DINFO,
BTN_CUSTOMGAME,
BTN_ACTIVATE,
BTN_INSTALL,
BTN_VISITWEB,
BTN_REFRESHLIST,
BTN_DEACTIVATE,
BTN_SPECTATEGAME,
BTN_SPECTATEGAMES
};

View file

@ -18,8 +18,6 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
int iMenuStage;
enum {
MAIN_NONE,
MAIN_BROWSER,
@ -41,9 +39,7 @@ void m_drawback( void ) {
if ( clientstate() == 2 ) {
drawfill( '0 0', vVideoSize, '0 0 0', 0.75f );
} else {
drawmenupic( '0 0 0', "gfx/menu/back1", '720 480', '1 1 1', 1.0f, 0 );
drawpic( '0 0 0', "menu_static", vVideoSize, '1 1 1', 1.0f, 0 );
drawmenupic( '0 0 0', "gfx/menu/back2", '720 480', '1 1 1', 1.0f, 0 );
drawpic( vMenuOffset, "gfx/shell/splash", '640 480', '1 1 1', 1.0f, 0 );
}
}
@ -59,93 +55,25 @@ void m_draw( vector vScreenSize ) {
return;
}
if ( vVideoSize != vScreenSize ) {
vVideoSize = vScreenSize;
vMenuOffset_x = vVideoSize_x / 2 - 320;
vMenuOffset_y = vVideoSize_y / 2 - 240;
}
// we have to create frametime ourselves because menuqc is primitive
frametime = ( time - fLastTime );
fLastTime = time;
// only update the videostuff if it's actually worth it
if ( vVideoSize != vScreenSize ) {
fFadeAlpha = 0.0f;
vVideoSize = vScreenSize;
vVideoAspect = Menu_Util_GetAspect( vVideoSize );
vMenuSize = Menu_Util_GetMenuSize( vVideoAspect );
iMenuPadding = Menu_Util_GetMenuPadding();
fMenuScale = vVideoSize_y / vMenuSize_y;
}
if ( clientstate() != 2 ) {
drawfill( '0 0', vVideoSize, '0 0 0', 1.0f );
}
m_drawback();
// for weird Android peeps
if ( vVideoSize_x < vVideoSize_y ) {
drawstring( '45 105', "FreeCS is designed for", '16 16', '1 1 1', 1.0f, 0 );
drawstring( '45 125', "landscape mode. Please", '16 16', '1 1 1', 1.0f, 0 );
drawstring( '45 145', "Switch the orientation.", '16 16', '1 1 1', 1.0f, 0 );
return;
}
if ( time < 5 ) {
iMenuStage = 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;
iMenuStage = 1;
}
m_drawback();
if ( fFadeAlpha < 1.0f ) {
drawfill( '0 0', vScreenSize, '0 0 0', 1 - fFadeAlpha );
}
} else {
if ( iMenuStage == 1 ) {
fFadeAlpha = 0.0f;
iMenuStage = 2;
}
m_drawback();
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 ) {
fFadeAlpha += frametime * 0.5;
if ( fFadeAlpha > 1.0f ) {
fFadeAlpha = 1.0f;
}
}
if ( fMenuAlpha < 1.0f ) {
fMenuAlpha += frametime * 0.5;
if ( fMenuAlpha > 1.0f ) {
fMenuAlpha = 1.0f;
}
if ( iMenu == MENU_MAIN ) {
Menu_Main();
} else if ( iMenu == MENU_QUIT ) {
Menu_Quit();
}
}

View file

@ -26,10 +26,7 @@ Precaches and loading for the menu system
=================
*/
void m_init( void ) {
precache_pic( "gfx/menu/freecs" );
precache_pic( "gfx/menu/back1" );
precache_pic( "gfx/menu/back2" );
precache_pic( "menu_static" );
precache_pic( "gfx/shell/splash" );
// Index all the maps... TODO: Filter out /valve/ to avoid useless junk from being cached.
searchhandle shMaps = search_begin( "maps/*.bsp", TRUE, TRUE );

View file

@ -27,10 +27,7 @@ Checks a specified region and returns TRUE if the mouse is above it.
*/
int Menu_InputCheckMouse( vector vPos, vector vReg ) {
vector vSMins, vSMaxs;
vReg = vReg * fMenuScale;
vPos = vPos * fMenuScale + [ iMenuPadding, 0, 0 ];
vSMins = vPos;
vSMaxs = vPos;
vSMins_x = vPos_x;

53
Source/Menu/MenuMain.c Executable file
View 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 Menu_Main( void ) {
static void Main_ButtonConsole( void ) {
localcmd( "toggleconsole\n" );
}
static void Main_ButtonQuit( void ) {
iMenu = MENU_QUIT;
}
Object_Button( '72 188', BTN_CONSOLE, Main_ButtonConsole, fButtonAlpha[0] );
Object_Button( '72 272', BTN_CONFIG, __NULL__, fButtonAlpha[1] );
Object_Button( '72 328', BTN_MULTIPLAYER, __NULL__, fButtonAlpha[2] );
Object_Button( '72 356', BTN_CUSTOMGAME, __NULL__, fButtonAlpha[3] );
Object_Button( '72 384', BTN_README, __NULL__, fButtonAlpha[4] );
Object_Button( '72 412', BTN_VISITWEB, __NULL__, fButtonAlpha[5] );
Object_Button( '72 440', BTN_QUIT, Main_ButtonQuit, fButtonAlpha[6] );
}
void Menu_Quit( void ) {
static void Quit_Cancel( void ) {
iMenu = MENU_MAIN;
}
static void Quit_Exit( void ) {
localcmd( "quit\n" );
}
Object_Frame( '192 192', '256 96' );
drawstring( vMenuOffset + '200 216', "FREECS_QUITMSG", '8 8', MENU_FGCOLOR, 1.0f, 0 );
Object_Button( '200 248', BTN_QUIT, Quit_Exit, fButtonAlpha[0] );
Object_Button_Right( '440 248', BTN_CANCEL, Quit_Cancel, fButtonAlpha[1] );
}

View file

@ -1,87 +0,0 @@
/*
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 );
};

View file

@ -1,23 +0,0 @@
/*
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 ) {
};

View file

@ -1,53 +0,0 @@
/*
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 );
};

View file

@ -1,23 +0,0 @@
/*
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 ) {
};

View file

@ -1,149 +0,0 @@
/*
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 );
}

View file

@ -18,6 +18,80 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
string sButtonLabels[ MENU_BUTTONS ] = {
"BTN_NEWGAME",
"BTN_RESUMEGAME",
"BTN_TRAINING",
"BTN_CONFIG",
"BTN_LOADGAME",
"BTN_SAVELOAD",
"BTN_README",
"BTN_QUIT",
"BTN_MULTIPLAYER",
"BTN_EASY",
"BTN_MEDIUM",
"BTN_DIFFICULT",
"BTN_SAVEGAME",
"BTN_LOADGAME2",
"BTN_CANCEL",
"BTN_OPTIONS",
"BTN_VIDEO",
"BTN_AUDIO",
"BTN_CONTROLS",
"BTN_DONE",
"BTN_QUICKSTART",
"BTN_DEFAULTS",
"BTN_OK",
"BTN_VIDEOOPTIONS",
"BTN_VIDEOMODES",
"BTN_ADVCONTROLS",
"BTN_ORDER",
"BTN_DELETE",
"BTN_INTERNET",
"BTN_IRCCHAT",
"BTN_LAN",
"BTN_CUSTOMIZE",
"BTN_SKIP",
"BTN_EXIT",
"BTN_CONNECT",
"BTN_REFRESH",
"BTN_FILTER",
"BTN_CREATE",
"BTN_CREATEGAME",
"BTN_CHATROOMS",
"BTN_LISTROOMS",
"BTN_SEARCH",
"BTN_SERVERS",
"BTN_JOIN",
"BTN_FIND",
"BTN_CREATEROOM",
"BTN_JOINGAME",
"BTN_SEARCHGAMES",
"BTN_FINDGAME",
"BTN_STARTGAME",
"BTN_GAMEINFO",
"BTN_UPDATE",
"BTN_ADDSERVER",
"BTN_DISCONNECT",
"BTN_CONSOLE",
"BTN_CONTENTCONTROL",
"BTN_UPDATE",
"BTN_VISITWON",
"BTN_PREVIEWS",
"BTN_ADVOPTIONS",
"BTN_3DINFO",
"BTN_CUSTOMGAME",
"BTN_ACTIVATE",
"BTN_INSTALL",
"BTN_VISITWEB",
"BTN_REFRESHLIST",
"BTN_DEACTIVATE",
"BTN_SPECTATEGAME",
"BTN_SPECTATEGAMES"
};
#define MENU_FGCOLOR '1 0.59 0.19'
/*
=================
drawmenupic
@ -25,107 +99,53 @@ 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;
void Object_Button( vector vPosition, int iButtonID, void() vFunction, __inout float fAlpha ) {
static int iLastButton = -1;
if ( Menu_InputCheckMouse( vPos, '182 14' ) == TRUE ) {
if ( iButtonSelected != iItem ) {
iButtonSelected = iItem;
fSelectionAlpha = 0.0f;
vPosition += vMenuOffset;
if ( fAlpha > 0.0f ) {
fAlpha -= frametime;
} else {
fAlpha = 0.0f;
}
float sWidth = stringwidth( sButtonLabels[ iButtonID ], TRUE, '16 16' );
if ( Menu_InputCheckMouse( vPosition, [ sWidth, 16 ] ) == TRUE ) {
if ( iLastButton != iButtonID ) {
localcmd( "play ../media/launch_deny2.wav\n" );
}
iLastButton = iButtonID;
fAlpha = 1.0f;
if ( fMouseClick == TRUE ) {
if ( iMenu == iItem ) {
iMenu = 0;
} else {
iMenu = iItem;
}
fMenuAlpha = 0.0f;
vFunction();
localcmd( "play ../media/launch_select2.wav\n" );
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;
}
}
drawstring( vPosition, sButtonLabels[ iButtonID ], '16 16', MENU_FGCOLOR, 1.0f, 0 );
drawstring( vPosition, sButtonLabels[ iButtonID ], '16 16', '1 1 1', fAlpha, 0 );
}
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 );
void Object_Button_Right( vector vPosition, int iButtonID, void() vFunction, __inout float fAlpha ) {
vPosition_x -= stringwidth( sButtonLabels[ iButtonID ], TRUE, '16 16' );
Object_Button( vPosition, iButtonID, vFunction, fAlpha );
}
#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
// Draws window with outline, border and title
void Object_Frame( vector vPos, vector vSize ) {
vPos += vMenuOffset;
// Draw the background
drawfill( vPos, vSize, '0 0 0', 1.0f );
drawfill( vPos, [vSize_x, 1], MENU_FGCOLOR, 1.0f ); // Top
drawfill( [vPos_x, vPos_y + vSize_y], [vSize_x, 1], MENU_FGCOLOR, 1.0f ); // Bottom
drawfill( vPos, [1, vSize_y], MENU_FGCOLOR, 1.0f ); // Left
drawfill( [vPos_x + vSize_x, vPos_y], [1, vSize_y], MENU_FGCOLOR, 1.0f ); // Right
}

View file

@ -11,10 +11,6 @@ Defs.h
Init.c
Input.c
Objects.c
Menu_Create.c
Menu_Options.c
Menu_Quit.c
Menu_Replays.c
Menu_Servers.c
MenuMain.c
Draw.c
#endlist

BIN
freecs/gfx/conback.tga Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
freecs/gfx/shell/splash.tga Executable file

Binary file not shown.

BIN
freecs/gfx/shell/splash.xcf Executable file

Binary file not shown.

Binary file not shown.