newlines fixed

This commit is contained in:
Zachary Slater 2005-08-26 17:39:27 +00:00
parent 7830940da6
commit 59cce31e75
1121 changed files with 717537 additions and 717537 deletions

View file

@ -1,93 +1,93 @@
# Q3 ui building
# qvm building against native:
# only native has ui_syscalls.c
# qvm uses a ui_syscalls.asm with equ stubs
# qvm has additional bg_lib.c
Import qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
$env = new cons(
# the code has the very bad habit of doing things like #include "../ui/ui_shared.h"
# this seems to confuse the dependency analysis, explicit toplevel includes seem to fix
CPPPATH => '#cgame:#game:#q3_ui',
CC => $CC,
CXX => $CXX,
LINK => $LINK,
ENV => { PATH => $ENV{PATH}, HOME => $ENV{HOME} },
CFLAGS => $BASE_CFLAGS . '-fPIC',
LDFLAGS => '-shared -ldl -lm'
);
# qvm building
# we heavily customize the cons environment
$vm_env = new cons(
# the code has the very bad habit of doing things like #include "../ui/ui_shared.h"
# this seems to confuse the dependency analysis, explicit toplevel includes seem to fix
CPPPATH => '#cgame:#game:#q3_ui',
CC => 'q3lcc',
CCCOM => '%CC %CFLAGS %_IFLAGS -c %< -o %>',
SUFOBJ => '.asm',
LINK => 'q3asm',
CFLAGS => '-DQ3_VM -S -Wf-target=bytecode -Wf-g',
# need to know where to find the compiler tools
ENV => { PATH => $ENV{PATH} . ":./qvmtools", },
);
# the file with vmMain function MUST be the first one of the list
@FILES = qw(
ui_main.c
../game/bg_misc.c
../game/q_math.c
../game/q_shared.c
ui_addbots.c
ui_atoms.c
ui_cdkey.c
ui_cinematics.c
ui_confirm.c
ui_connect.c
ui_controls2.c
ui_credits.c
ui_demo2.c
ui_display.c
ui_gameinfo.c
ui_ingame.c
ui_menu.c
ui_mfield.c
ui_mods.c
ui_network.c
ui_options.c
ui_playermodel.c
ui_players.c
ui_playersettings.c
ui_preferences.c
ui_qmenu.c
ui_removebots.c
ui_serverinfo.c
ui_servers2.c
ui_setup.c
ui_sound.c
ui_sparena.c
ui_specifyserver.c
ui_splevel.c
ui_sppostgame.c
ui_spskill.c
ui_startserver.c
ui_team.c
ui_teamorders.c
ui_video.c
);
$FILESREF = \@FILES;
if ($NO_SO eq 0)
{
Program $env 'uii386.so', @$FILESREF, '../ui/ui_syscalls.c';
Install $env $INSTALL_DIR, 'uii386.so';
}
if ($NO_VM eq 0)
{
Depends $vm_env 'ui.qvm', '#qvmtools/q3lcc';
Depends $vm_env 'ui.qvm', '#qvmtools/q3asm';
Program $vm_env 'ui.qvm', @$FILESREF, '../game/bg_lib.c', '../ui/ui_syscalls.asm';
Install $vm_env $INSTALL_DIR . '/vm', 'ui.qvm';
}
# Q3 ui building
# qvm building against native:
# only native has ui_syscalls.c
# qvm uses a ui_syscalls.asm with equ stubs
# qvm has additional bg_lib.c
Import qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
$env = new cons(
# the code has the very bad habit of doing things like #include "../ui/ui_shared.h"
# this seems to confuse the dependency analysis, explicit toplevel includes seem to fix
CPPPATH => '#cgame:#game:#q3_ui',
CC => $CC,
CXX => $CXX,
LINK => $LINK,
ENV => { PATH => $ENV{PATH}, HOME => $ENV{HOME} },
CFLAGS => $BASE_CFLAGS . '-fPIC',
LDFLAGS => '-shared -ldl -lm'
);
# qvm building
# we heavily customize the cons environment
$vm_env = new cons(
# the code has the very bad habit of doing things like #include "../ui/ui_shared.h"
# this seems to confuse the dependency analysis, explicit toplevel includes seem to fix
CPPPATH => '#cgame:#game:#q3_ui',
CC => 'q3lcc',
CCCOM => '%CC %CFLAGS %_IFLAGS -c %< -o %>',
SUFOBJ => '.asm',
LINK => 'q3asm',
CFLAGS => '-DQ3_VM -S -Wf-target=bytecode -Wf-g',
# need to know where to find the compiler tools
ENV => { PATH => $ENV{PATH} . ":./qvmtools", },
);
# the file with vmMain function MUST be the first one of the list
@FILES = qw(
ui_main.c
../game/bg_misc.c
../game/q_math.c
../game/q_shared.c
ui_addbots.c
ui_atoms.c
ui_cdkey.c
ui_cinematics.c
ui_confirm.c
ui_connect.c
ui_controls2.c
ui_credits.c
ui_demo2.c
ui_display.c
ui_gameinfo.c
ui_ingame.c
ui_menu.c
ui_mfield.c
ui_mods.c
ui_network.c
ui_options.c
ui_playermodel.c
ui_players.c
ui_playersettings.c
ui_preferences.c
ui_qmenu.c
ui_removebots.c
ui_serverinfo.c
ui_servers2.c
ui_setup.c
ui_sound.c
ui_sparena.c
ui_specifyserver.c
ui_splevel.c
ui_sppostgame.c
ui_spskill.c
ui_startserver.c
ui_team.c
ui_teamorders.c
ui_video.c
);
$FILESREF = \@FILES;
if ($NO_SO eq 0)
{
Program $env 'uii386.so', @$FILESREF, '../ui/ui_syscalls.c';
Install $env $INSTALL_DIR, 'uii386.so';
}
if ($NO_VM eq 0)
{
Depends $vm_env 'ui.qvm', '#qvmtools/q3lcc';
Depends $vm_env 'ui.qvm', '#qvmtools/q3asm';
Program $vm_env 'ui.qvm', @$FILESREF, '../game/bg_lib.c', '../ui/ui_syscalls.asm';
Install $vm_env $INSTALL_DIR . '/vm', 'ui.qvm';
}

View file

@ -1,2 +1,2 @@
lcc -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\ui %1
lcc -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\ui %1

View file

@ -1,163 +1,163 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#ifndef __KEYCODES_H__
#define __KEYCODES_H__
//
// these are the key numbers that should be passed to KeyEvent
//
// normal keys should be passed as lowercased ascii
typedef enum {
K_TAB = 9,
K_ENTER = 13,
K_ESCAPE = 27,
K_SPACE = 32,
K_BACKSPACE = 127,
K_COMMAND = 128,
K_CAPSLOCK,
K_POWER,
K_PAUSE,
K_UPARROW,
K_DOWNARROW,
K_LEFTARROW,
K_RIGHTARROW,
K_ALT,
K_CTRL,
K_SHIFT,
K_INS,
K_DEL,
K_PGDN,
K_PGUP,
K_HOME,
K_END,
K_F1,
K_F2,
K_F3,
K_F4,
K_F5,
K_F6,
K_F7,
K_F8,
K_F9,
K_F10,
K_F11,
K_F12,
K_F13,
K_F14,
K_F15,
K_KP_HOME,
K_KP_UPARROW,
K_KP_PGUP,
K_KP_LEFTARROW,
K_KP_5,
K_KP_RIGHTARROW,
K_KP_END,
K_KP_DOWNARROW,
K_KP_PGDN,
K_KP_ENTER,
K_KP_INS,
K_KP_DEL,
K_KP_SLASH,
K_KP_MINUS,
K_KP_PLUS,
K_KP_NUMLOCK,
K_KP_STAR,
K_KP_EQUALS,
K_MOUSE1,
K_MOUSE2,
K_MOUSE3,
K_MOUSE4,
K_MOUSE5,
K_MWHEELDOWN,
K_MWHEELUP,
K_JOY1,
K_JOY2,
K_JOY3,
K_JOY4,
K_JOY5,
K_JOY6,
K_JOY7,
K_JOY8,
K_JOY9,
K_JOY10,
K_JOY11,
K_JOY12,
K_JOY13,
K_JOY14,
K_JOY15,
K_JOY16,
K_JOY17,
K_JOY18,
K_JOY19,
K_JOY20,
K_JOY21,
K_JOY22,
K_JOY23,
K_JOY24,
K_JOY25,
K_JOY26,
K_JOY27,
K_JOY28,
K_JOY29,
K_JOY30,
K_JOY31,
K_JOY32,
K_AUX1,
K_AUX2,
K_AUX3,
K_AUX4,
K_AUX5,
K_AUX6,
K_AUX7,
K_AUX8,
K_AUX9,
K_AUX10,
K_AUX11,
K_AUX12,
K_AUX13,
K_AUX14,
K_AUX15,
K_AUX16,
K_LAST_KEY // this had better be <256!
} keyNum_t;
// The menu code needs to get both key and char events, but
// to avoid duplicating the paths, the char events are just
// distinguished by or'ing in K_CHAR_FLAG (ugly)
#define K_CHAR_FLAG 1024
#endif
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#ifndef __KEYCODES_H__
#define __KEYCODES_H__
//
// these are the key numbers that should be passed to KeyEvent
//
// normal keys should be passed as lowercased ascii
typedef enum {
K_TAB = 9,
K_ENTER = 13,
K_ESCAPE = 27,
K_SPACE = 32,
K_BACKSPACE = 127,
K_COMMAND = 128,
K_CAPSLOCK,
K_POWER,
K_PAUSE,
K_UPARROW,
K_DOWNARROW,
K_LEFTARROW,
K_RIGHTARROW,
K_ALT,
K_CTRL,
K_SHIFT,
K_INS,
K_DEL,
K_PGDN,
K_PGUP,
K_HOME,
K_END,
K_F1,
K_F2,
K_F3,
K_F4,
K_F5,
K_F6,
K_F7,
K_F8,
K_F9,
K_F10,
K_F11,
K_F12,
K_F13,
K_F14,
K_F15,
K_KP_HOME,
K_KP_UPARROW,
K_KP_PGUP,
K_KP_LEFTARROW,
K_KP_5,
K_KP_RIGHTARROW,
K_KP_END,
K_KP_DOWNARROW,
K_KP_PGDN,
K_KP_ENTER,
K_KP_INS,
K_KP_DEL,
K_KP_SLASH,
K_KP_MINUS,
K_KP_PLUS,
K_KP_NUMLOCK,
K_KP_STAR,
K_KP_EQUALS,
K_MOUSE1,
K_MOUSE2,
K_MOUSE3,
K_MOUSE4,
K_MOUSE5,
K_MWHEELDOWN,
K_MWHEELUP,
K_JOY1,
K_JOY2,
K_JOY3,
K_JOY4,
K_JOY5,
K_JOY6,
K_JOY7,
K_JOY8,
K_JOY9,
K_JOY10,
K_JOY11,
K_JOY12,
K_JOY13,
K_JOY14,
K_JOY15,
K_JOY16,
K_JOY17,
K_JOY18,
K_JOY19,
K_JOY20,
K_JOY21,
K_JOY22,
K_JOY23,
K_JOY24,
K_JOY25,
K_JOY26,
K_JOY27,
K_JOY28,
K_JOY29,
K_JOY30,
K_JOY31,
K_JOY32,
K_AUX1,
K_AUX2,
K_AUX3,
K_AUX4,
K_AUX5,
K_AUX6,
K_AUX7,
K_AUX8,
K_AUX9,
K_AUX10,
K_AUX11,
K_AUX12,
K_AUX13,
K_AUX14,
K_AUX15,
K_AUX16,
K_LAST_KEY // this had better be <256!
} keyNum_t;
// The menu code needs to get both key and char events, but
// to avoid duplicating the paths, the char events are just
// distinguished by or'ing in K_CHAR_FLAG (ugly)
#define K_CHAR_FLAG 1024
#endif

View file

@ -1,100 +1,100 @@
rem make sure we have a safe environement
set LIBRARY=
set INCLUDE=
mkdir vm
cd vm
set cc=lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui %1
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_main.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_cdkey.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_ingame.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_serverinfo.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_confirm.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_setup.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../../game/bg_misc.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../../game/bg_lib.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../../game/q_math.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../../game/q_shared.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_gameinfo.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_atoms.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_connect.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_controls2.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_demo2.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_mfield.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_credits.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_menu.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_options.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_display.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_sound.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_network.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_playermodel.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_players.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_playersettings.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_preferences.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_qmenu.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_servers2.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_sparena.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_specifyserver.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_splevel.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_sppostgame.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_startserver.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_team.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_video.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_cinematics.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_spskill.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_addbots.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_removebots.c
@if errorlevel 1 goto quit
rem lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_loadconfig.c
rem @if errorlevel 1 goto quit
rem lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_saveconfig.c
rem @if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_teamorders.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_mods.c
@if errorlevel 1 goto quit
q3asm -f ../q3_ui
:quit
cd ..
rem make sure we have a safe environement
set LIBRARY=
set INCLUDE=
mkdir vm
cd vm
set cc=lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui %1
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_main.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_cdkey.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_ingame.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_serverinfo.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_confirm.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_setup.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../../game/bg_misc.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../../game/bg_lib.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../../game/q_math.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../../game/q_shared.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_gameinfo.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_atoms.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_connect.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_controls2.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_demo2.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_mfield.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_credits.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_menu.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_options.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_display.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_sound.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_network.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_playermodel.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_players.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_playersettings.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_preferences.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_qmenu.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_servers2.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_sparena.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_specifyserver.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_splevel.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_sppostgame.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_startserver.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_team.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_video.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_cinematics.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_spskill.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_addbots.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_removebots.c
@if errorlevel 1 goto quit
rem lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_loadconfig.c
rem @if errorlevel 1 goto quit
rem lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_saveconfig.c
rem @if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_teamorders.c
@if errorlevel 1 goto quit
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_mods.c
@if errorlevel 1 goto quit
q3asm -f ../q3_ui
:quit
cd ..

View file

@ -1,43 +1,43 @@
-o "\quake3\baseq3\vm\ui"
ui_main
..\..\ui\ui_syscalls
ui_gameinfo
ui_atoms
ui_cinematics
ui_connect
ui_controls2
ui_demo2
ui_mfield
ui_credits
ui_menu
ui_ingame
ui_confirm
ui_setup
ui_options
ui_display
ui_sound
ui_network
ui_playermodel
ui_players
ui_playersettings
ui_preferences
ui_qmenu
ui_serverinfo
ui_servers2
ui_sparena
ui_specifyserver
ui_sppostgame
ui_splevel
ui_spskill
ui_startserver
ui_team
ui_video
ui_addbots
ui_removebots
ui_teamorders
ui_cdkey
ui_mods
bg_misc
bg_lib
q_math
q_shared
-o "\quake3\baseq3\vm\ui"
ui_main
..\..\ui\ui_syscalls
ui_gameinfo
ui_atoms
ui_cinematics
ui_connect
ui_controls2
ui_demo2
ui_mfield
ui_credits
ui_menu
ui_ingame
ui_confirm
ui_setup
ui_options
ui_display
ui_sound
ui_network
ui_playermodel
ui_players
ui_playersettings
ui_preferences
ui_qmenu
ui_serverinfo
ui_servers2
ui_sparena
ui_specifyserver
ui_sppostgame
ui_splevel
ui_spskill
ui_startserver
ui_team
ui_video
ui_addbots
ui_removebots
ui_teamorders
ui_cdkey
ui_mods
bg_misc
bg_lib
q_math
q_shared

View file

@ -1,55 +1,55 @@
#!/bin/sh
mkdir -p vm
cd vm
CC="q3lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I../../cgame -I../../game -I../../q3_ui "
$CC ../ui_main.c
$CC ../ui_cdkey.c
$CC ../ui_ingame.c
$CC ../ui_confirm.c
$CC ../ui_setup.c
$CC ../../game/bg_misc.c
$CC ../../game/bg_lib.c
$CC ../../game/q_math.c
$CC ../../game/q_shared.c
$CC ../ui_gameinfo.c
$CC ../ui_atoms.c
$CC ../ui_connect.c
$CC ../ui_controls2.c
$CC ../ui_demo2.c
$CC ../ui_mfield.c
$CC ../ui_credits.c
$CC ../ui_menu.c
$CC ../ui_options.c
$CC ../ui_display.c
$CC ../ui_sound.c
$CC ../ui_network.c
$CC ../ui_playermodel.c
$CC ../ui_players.c
$CC ../ui_playersettings.c
$CC ../ui_preferences.c
$CC ../ui_qmenu.c
$CC ../ui_serverinfo.c
$CC ../ui_servers2.c
$CC ../ui_sparena.c
$CC ../ui_specifyserver.c
$CC ../ui_splevel.c
$CC ../ui_sppostgame.c
$CC ../ui_startserver.c
$CC ../ui_syscalls.c
$CC ../ui_team.c
$CC ../ui_video.c
$CC ../ui_cinematics.c
$CC ../ui_spskill.c
$CC ../ui_addbots.c
$CC ../ui_removebots.c
$CC ../ui_loadconfig.c
$CC ../ui_saveconfig.c
$CC ../ui_teamorders.c
$CC ../ui_mods.c
q3asm -f ../q3_ui
cd ..
#!/bin/sh
mkdir -p vm
cd vm
CC="q3lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I../../cgame -I../../game -I../../q3_ui "
$CC ../ui_main.c
$CC ../ui_cdkey.c
$CC ../ui_ingame.c
$CC ../ui_confirm.c
$CC ../ui_setup.c
$CC ../../game/bg_misc.c
$CC ../../game/bg_lib.c
$CC ../../game/q_math.c
$CC ../../game/q_shared.c
$CC ../ui_gameinfo.c
$CC ../ui_atoms.c
$CC ../ui_connect.c
$CC ../ui_controls2.c
$CC ../ui_demo2.c
$CC ../ui_mfield.c
$CC ../ui_credits.c
$CC ../ui_menu.c
$CC ../ui_options.c
$CC ../ui_display.c
$CC ../ui_sound.c
$CC ../ui_network.c
$CC ../ui_playermodel.c
$CC ../ui_players.c
$CC ../ui_playersettings.c
$CC ../ui_preferences.c
$CC ../ui_qmenu.c
$CC ../ui_serverinfo.c
$CC ../ui_servers2.c
$CC ../ui_sparena.c
$CC ../ui_specifyserver.c
$CC ../ui_splevel.c
$CC ../ui_sppostgame.c
$CC ../ui_startserver.c
$CC ../ui_syscalls.c
$CC ../ui_team.c
$CC ../ui_video.c
$CC ../ui_cinematics.c
$CC ../ui_spskill.c
$CC ../ui_addbots.c
$CC ../ui_removebots.c
$CC ../ui_loadconfig.c
$CC ../ui_saveconfig.c
$CC ../ui_teamorders.c
$CC ../ui_mods.c
q3asm -f ../q3_ui
cd ..

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,3 @@
EXPORTS
vmMain
dllEntry
EXPORTS
vmMain
dllEntry

View file

@ -1,45 +1,45 @@
-o "\quake3\baseq3\vm\ui"
ui_main
..\ui_syscalls
ui_gameinfo
ui_atoms
ui_cinematics
ui_connect
ui_controls2
ui_demo2
ui_mfield
ui_credits
ui_menu
ui_ingame
ui_confirm
ui_setup
ui_options
ui_display
ui_sound
ui_network
ui_playermodel
ui_players
ui_playersettings
ui_preferences
ui_qmenu
ui_serverinfo
ui_servers2
ui_sparena
ui_specifyserver
ui_sppostgame
ui_splevel
ui_spskill
ui_startserver
ui_team
ui_video
ui_addbots
ui_removebots
ui_teamorders
ui_loadconfig
ui_saveconfig
ui_cdkey
ui_mods
bg_misc
bg_lib
q_math
q_shared
-o "\quake3\baseq3\vm\ui"
ui_main
..\ui_syscalls
ui_gameinfo
ui_atoms
ui_cinematics
ui_connect
ui_controls2
ui_demo2
ui_mfield
ui_credits
ui_menu
ui_ingame
ui_confirm
ui_setup
ui_options
ui_display
ui_sound
ui_network
ui_playermodel
ui_players
ui_playersettings
ui_preferences
ui_qmenu
ui_serverinfo
ui_servers2
ui_sparena
ui_specifyserver
ui_sppostgame
ui_splevel
ui_spskill
ui_startserver
ui_team
ui_video
ui_addbots
ui_removebots
ui_teamorders
ui_loadconfig
ui_saveconfig
ui_cdkey
ui_mods
bg_misc
bg_lib
q_math
q_shared

View file

@ -1,412 +1,412 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
ADD BOTS MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ART_FIGHT0 "menu/art/accept_0"
#define ART_FIGHT1 "menu/art/accept_1"
#define ART_BACKGROUND "menu/art/addbotframe"
#define ART_ARROWS "menu/art/arrows_vert_0"
#define ART_ARROWUP "menu/art/arrows_vert_top"
#define ART_ARROWDOWN "menu/art/arrows_vert_bot"
#define ID_BACK 10
#define ID_GO 11
#define ID_LIST 12
#define ID_UP 13
#define ID_DOWN 14
#define ID_SKILL 15
#define ID_TEAM 16
#define ID_BOTNAME0 20
#define ID_BOTNAME1 21
#define ID_BOTNAME2 22
#define ID_BOTNAME3 23
#define ID_BOTNAME4 24
#define ID_BOTNAME5 25
#define ID_BOTNAME6 26
typedef struct {
menuframework_s menu;
menubitmap_s arrows;
menubitmap_s up;
menubitmap_s down;
menutext_s bots[7];
menulist_s skill;
menulist_s team;
menubitmap_s go;
menubitmap_s back;
int numBots;
int delay;
int baseBotNum;
int selectedBotNum;
int sortedBotNums[MAX_BOTS];
char botnames[7][32];
} addBotsMenuInfo_t;
static addBotsMenuInfo_t addBotsMenuInfo;
/*
=================
UI_AddBotsMenu_FightEvent
=================
*/
static void UI_AddBotsMenu_FightEvent( void* ptr, int event ) {
const char *team;
int skill;
if (event != QM_ACTIVATED) {
return;
}
team = addBotsMenuInfo.team.itemnames[addBotsMenuInfo.team.curvalue];
skill = addBotsMenuInfo.skill.curvalue + 1;
trap_Cmd_ExecuteText( EXEC_APPEND, va("addbot %s %i %s %i\n",
addBotsMenuInfo.botnames[addBotsMenuInfo.selectedBotNum], skill, team, addBotsMenuInfo.delay) );
addBotsMenuInfo.delay += 1500;
}
/*
=================
UI_AddBotsMenu_BotEvent
=================
*/
static void UI_AddBotsMenu_BotEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
addBotsMenuInfo.bots[addBotsMenuInfo.selectedBotNum].color = color_orange;
addBotsMenuInfo.selectedBotNum = ((menucommon_s*)ptr)->id - ID_BOTNAME0;
addBotsMenuInfo.bots[addBotsMenuInfo.selectedBotNum].color = color_white;
}
/*
=================
UI_AddBotsMenu_BackEvent
=================
*/
static void UI_AddBotsMenu_BackEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
UI_PopMenu();
}
/*
=================
UI_AddBotsMenu_SetBotNames
=================
*/
static void UI_AddBotsMenu_SetBotNames( void ) {
int n;
const char *info;
for ( n = 0; n < 7; n++ ) {
info = UI_GetBotInfoByNumber( addBotsMenuInfo.sortedBotNums[addBotsMenuInfo.baseBotNum + n] );
Q_strncpyz( addBotsMenuInfo.botnames[n], Info_ValueForKey( info, "name" ), sizeof(addBotsMenuInfo.botnames[n]) );
}
}
/*
=================
UI_AddBotsMenu_UpEvent
=================
*/
static void UI_AddBotsMenu_UpEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
if( addBotsMenuInfo.baseBotNum > 0 ) {
addBotsMenuInfo.baseBotNum--;
UI_AddBotsMenu_SetBotNames();
}
}
/*
=================
UI_AddBotsMenu_DownEvent
=================
*/
static void UI_AddBotsMenu_DownEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
if( addBotsMenuInfo.baseBotNum + 7 < addBotsMenuInfo.numBots ) {
addBotsMenuInfo.baseBotNum++;
UI_AddBotsMenu_SetBotNames();
}
}
/*
=================
UI_AddBotsMenu_GetSortedBotNums
=================
*/
static int QDECL UI_AddBotsMenu_SortCompare( const void *arg1, const void *arg2 ) {
int num1, num2;
const char *info1, *info2;
const char *name1, *name2;
num1 = *(int *)arg1;
num2 = *(int *)arg2;
info1 = UI_GetBotInfoByNumber( num1 );
info2 = UI_GetBotInfoByNumber( num2 );
name1 = Info_ValueForKey( info1, "name" );
name2 = Info_ValueForKey( info2, "name" );
return Q_stricmp( name1, name2 );
}
static void UI_AddBotsMenu_GetSortedBotNums( void ) {
int n;
// initialize the array
for( n = 0; n < addBotsMenuInfo.numBots; n++ ) {
addBotsMenuInfo.sortedBotNums[n] = n;
}
qsort( addBotsMenuInfo.sortedBotNums, addBotsMenuInfo.numBots, sizeof(addBotsMenuInfo.sortedBotNums[0]), UI_AddBotsMenu_SortCompare );
}
/*
=================
UI_AddBotsMenu_Draw
=================
*/
static void UI_AddBotsMenu_Draw( void ) {
UI_DrawBannerString( 320, 16, "ADD BOTS", UI_CENTER, color_white );
UI_DrawNamedPic( 320-233, 240-166, 466, 332, ART_BACKGROUND );
// standard menu drawing
Menu_Draw( &addBotsMenuInfo.menu );
}
/*
=================
UI_AddBotsMenu_Init
=================
*/
static const char *skillNames[] = {
"I Can Win",
"Bring It On",
"Hurt Me Plenty",
"Hardcore",
"Nightmare!",
0
};
static const char *teamNames1[] = {
"Free",
0
};
static const char *teamNames2[] = {
"Red",
"Blue",
0
};
static void UI_AddBotsMenu_Init( void ) {
int n;
int y;
int gametype;
int count;
char info[MAX_INFO_STRING];
trap_GetConfigString(CS_SERVERINFO, info, MAX_INFO_STRING);
gametype = atoi( Info_ValueForKey( info,"g_gametype" ) );
memset( &addBotsMenuInfo, 0 ,sizeof(addBotsMenuInfo) );
addBotsMenuInfo.menu.draw = UI_AddBotsMenu_Draw;
addBotsMenuInfo.menu.fullscreen = qfalse;
addBotsMenuInfo.menu.wrapAround = qtrue;
addBotsMenuInfo.delay = 1000;
UI_AddBots_Cache();
addBotsMenuInfo.numBots = UI_GetNumBots();
count = addBotsMenuInfo.numBots < 7 ? addBotsMenuInfo.numBots : 7;
addBotsMenuInfo.arrows.generic.type = MTYPE_BITMAP;
addBotsMenuInfo.arrows.generic.name = ART_ARROWS;
addBotsMenuInfo.arrows.generic.flags = QMF_INACTIVE;
addBotsMenuInfo.arrows.generic.x = 200;
addBotsMenuInfo.arrows.generic.y = 128;
addBotsMenuInfo.arrows.width = 64;
addBotsMenuInfo.arrows.height = 128;
addBotsMenuInfo.up.generic.type = MTYPE_BITMAP;
addBotsMenuInfo.up.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
addBotsMenuInfo.up.generic.x = 200;
addBotsMenuInfo.up.generic.y = 128;
addBotsMenuInfo.up.generic.id = ID_UP;
addBotsMenuInfo.up.generic.callback = UI_AddBotsMenu_UpEvent;
addBotsMenuInfo.up.width = 64;
addBotsMenuInfo.up.height = 64;
addBotsMenuInfo.up.focuspic = ART_ARROWUP;
addBotsMenuInfo.down.generic.type = MTYPE_BITMAP;
addBotsMenuInfo.down.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
addBotsMenuInfo.down.generic.x = 200;
addBotsMenuInfo.down.generic.y = 128+64;
addBotsMenuInfo.down.generic.id = ID_DOWN;
addBotsMenuInfo.down.generic.callback = UI_AddBotsMenu_DownEvent;
addBotsMenuInfo.down.width = 64;
addBotsMenuInfo.down.height = 64;
addBotsMenuInfo.down.focuspic = ART_ARROWDOWN;
for( n = 0, y = 120; n < count; n++, y += 20 ) {
addBotsMenuInfo.bots[n].generic.type = MTYPE_PTEXT;
addBotsMenuInfo.bots[n].generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
addBotsMenuInfo.bots[n].generic.id = ID_BOTNAME0 + n;
addBotsMenuInfo.bots[n].generic.x = 320 - 56;
addBotsMenuInfo.bots[n].generic.y = y;
addBotsMenuInfo.bots[n].generic.callback = UI_AddBotsMenu_BotEvent;
addBotsMenuInfo.bots[n].string = addBotsMenuInfo.botnames[n];
addBotsMenuInfo.bots[n].color = color_orange;
addBotsMenuInfo.bots[n].style = UI_LEFT|UI_SMALLFONT;
}
y += 12;
addBotsMenuInfo.skill.generic.type = MTYPE_SPINCONTROL;
addBotsMenuInfo.skill.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
addBotsMenuInfo.skill.generic.x = 320;
addBotsMenuInfo.skill.generic.y = y;
addBotsMenuInfo.skill.generic.name = "Skill:";
addBotsMenuInfo.skill.generic.id = ID_SKILL;
addBotsMenuInfo.skill.itemnames = skillNames;
addBotsMenuInfo.skill.curvalue = Com_Clamp( 0, 4, (int)trap_Cvar_VariableValue( "g_spSkill" ) - 1 );
y += SMALLCHAR_HEIGHT;
addBotsMenuInfo.team.generic.type = MTYPE_SPINCONTROL;
addBotsMenuInfo.team.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
addBotsMenuInfo.team.generic.x = 320;
addBotsMenuInfo.team.generic.y = y;
addBotsMenuInfo.team.generic.name = "Team: ";
addBotsMenuInfo.team.generic.id = ID_TEAM;
if( gametype >= GT_TEAM ) {
addBotsMenuInfo.team.itemnames = teamNames2;
}
else {
addBotsMenuInfo.team.itemnames = teamNames1;
addBotsMenuInfo.team.generic.flags = QMF_GRAYED;
}
addBotsMenuInfo.go.generic.type = MTYPE_BITMAP;
addBotsMenuInfo.go.generic.name = ART_FIGHT0;
addBotsMenuInfo.go.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
addBotsMenuInfo.go.generic.id = ID_GO;
addBotsMenuInfo.go.generic.callback = UI_AddBotsMenu_FightEvent;
addBotsMenuInfo.go.generic.x = 320+128-128;
addBotsMenuInfo.go.generic.y = 256+128-64;
addBotsMenuInfo.go.width = 128;
addBotsMenuInfo.go.height = 64;
addBotsMenuInfo.go.focuspic = ART_FIGHT1;
addBotsMenuInfo.back.generic.type = MTYPE_BITMAP;
addBotsMenuInfo.back.generic.name = ART_BACK0;
addBotsMenuInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
addBotsMenuInfo.back.generic.id = ID_BACK;
addBotsMenuInfo.back.generic.callback = UI_AddBotsMenu_BackEvent;
addBotsMenuInfo.back.generic.x = 320-128;
addBotsMenuInfo.back.generic.y = 256+128-64;
addBotsMenuInfo.back.width = 128;
addBotsMenuInfo.back.height = 64;
addBotsMenuInfo.back.focuspic = ART_BACK1;
addBotsMenuInfo.baseBotNum = 0;
addBotsMenuInfo.selectedBotNum = 0;
addBotsMenuInfo.bots[0].color = color_white;
UI_AddBotsMenu_GetSortedBotNums();
UI_AddBotsMenu_SetBotNames();
Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.arrows );
Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.up );
Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.down );
for( n = 0; n < count; n++ ) {
Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.bots[n] );
}
Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.skill );
Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.team );
Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.go );
Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.back );
}
/*
=================
UI_AddBots_Cache
=================
*/
void UI_AddBots_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
trap_R_RegisterShaderNoMip( ART_FIGHT0 );
trap_R_RegisterShaderNoMip( ART_FIGHT1 );
trap_R_RegisterShaderNoMip( ART_BACKGROUND );
trap_R_RegisterShaderNoMip( ART_ARROWS );
trap_R_RegisterShaderNoMip( ART_ARROWUP );
trap_R_RegisterShaderNoMip( ART_ARROWDOWN );
}
/*
=================
UI_AddBotsMenu
=================
*/
void UI_AddBotsMenu( void ) {
UI_AddBotsMenu_Init();
UI_PushMenu( &addBotsMenuInfo.menu );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
ADD BOTS MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ART_FIGHT0 "menu/art/accept_0"
#define ART_FIGHT1 "menu/art/accept_1"
#define ART_BACKGROUND "menu/art/addbotframe"
#define ART_ARROWS "menu/art/arrows_vert_0"
#define ART_ARROWUP "menu/art/arrows_vert_top"
#define ART_ARROWDOWN "menu/art/arrows_vert_bot"
#define ID_BACK 10
#define ID_GO 11
#define ID_LIST 12
#define ID_UP 13
#define ID_DOWN 14
#define ID_SKILL 15
#define ID_TEAM 16
#define ID_BOTNAME0 20
#define ID_BOTNAME1 21
#define ID_BOTNAME2 22
#define ID_BOTNAME3 23
#define ID_BOTNAME4 24
#define ID_BOTNAME5 25
#define ID_BOTNAME6 26
typedef struct {
menuframework_s menu;
menubitmap_s arrows;
menubitmap_s up;
menubitmap_s down;
menutext_s bots[7];
menulist_s skill;
menulist_s team;
menubitmap_s go;
menubitmap_s back;
int numBots;
int delay;
int baseBotNum;
int selectedBotNum;
int sortedBotNums[MAX_BOTS];
char botnames[7][32];
} addBotsMenuInfo_t;
static addBotsMenuInfo_t addBotsMenuInfo;
/*
=================
UI_AddBotsMenu_FightEvent
=================
*/
static void UI_AddBotsMenu_FightEvent( void* ptr, int event ) {
const char *team;
int skill;
if (event != QM_ACTIVATED) {
return;
}
team = addBotsMenuInfo.team.itemnames[addBotsMenuInfo.team.curvalue];
skill = addBotsMenuInfo.skill.curvalue + 1;
trap_Cmd_ExecuteText( EXEC_APPEND, va("addbot %s %i %s %i\n",
addBotsMenuInfo.botnames[addBotsMenuInfo.selectedBotNum], skill, team, addBotsMenuInfo.delay) );
addBotsMenuInfo.delay += 1500;
}
/*
=================
UI_AddBotsMenu_BotEvent
=================
*/
static void UI_AddBotsMenu_BotEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
addBotsMenuInfo.bots[addBotsMenuInfo.selectedBotNum].color = color_orange;
addBotsMenuInfo.selectedBotNum = ((menucommon_s*)ptr)->id - ID_BOTNAME0;
addBotsMenuInfo.bots[addBotsMenuInfo.selectedBotNum].color = color_white;
}
/*
=================
UI_AddBotsMenu_BackEvent
=================
*/
static void UI_AddBotsMenu_BackEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
UI_PopMenu();
}
/*
=================
UI_AddBotsMenu_SetBotNames
=================
*/
static void UI_AddBotsMenu_SetBotNames( void ) {
int n;
const char *info;
for ( n = 0; n < 7; n++ ) {
info = UI_GetBotInfoByNumber( addBotsMenuInfo.sortedBotNums[addBotsMenuInfo.baseBotNum + n] );
Q_strncpyz( addBotsMenuInfo.botnames[n], Info_ValueForKey( info, "name" ), sizeof(addBotsMenuInfo.botnames[n]) );
}
}
/*
=================
UI_AddBotsMenu_UpEvent
=================
*/
static void UI_AddBotsMenu_UpEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
if( addBotsMenuInfo.baseBotNum > 0 ) {
addBotsMenuInfo.baseBotNum--;
UI_AddBotsMenu_SetBotNames();
}
}
/*
=================
UI_AddBotsMenu_DownEvent
=================
*/
static void UI_AddBotsMenu_DownEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
if( addBotsMenuInfo.baseBotNum + 7 < addBotsMenuInfo.numBots ) {
addBotsMenuInfo.baseBotNum++;
UI_AddBotsMenu_SetBotNames();
}
}
/*
=================
UI_AddBotsMenu_GetSortedBotNums
=================
*/
static int QDECL UI_AddBotsMenu_SortCompare( const void *arg1, const void *arg2 ) {
int num1, num2;
const char *info1, *info2;
const char *name1, *name2;
num1 = *(int *)arg1;
num2 = *(int *)arg2;
info1 = UI_GetBotInfoByNumber( num1 );
info2 = UI_GetBotInfoByNumber( num2 );
name1 = Info_ValueForKey( info1, "name" );
name2 = Info_ValueForKey( info2, "name" );
return Q_stricmp( name1, name2 );
}
static void UI_AddBotsMenu_GetSortedBotNums( void ) {
int n;
// initialize the array
for( n = 0; n < addBotsMenuInfo.numBots; n++ ) {
addBotsMenuInfo.sortedBotNums[n] = n;
}
qsort( addBotsMenuInfo.sortedBotNums, addBotsMenuInfo.numBots, sizeof(addBotsMenuInfo.sortedBotNums[0]), UI_AddBotsMenu_SortCompare );
}
/*
=================
UI_AddBotsMenu_Draw
=================
*/
static void UI_AddBotsMenu_Draw( void ) {
UI_DrawBannerString( 320, 16, "ADD BOTS", UI_CENTER, color_white );
UI_DrawNamedPic( 320-233, 240-166, 466, 332, ART_BACKGROUND );
// standard menu drawing
Menu_Draw( &addBotsMenuInfo.menu );
}
/*
=================
UI_AddBotsMenu_Init
=================
*/
static const char *skillNames[] = {
"I Can Win",
"Bring It On",
"Hurt Me Plenty",
"Hardcore",
"Nightmare!",
0
};
static const char *teamNames1[] = {
"Free",
0
};
static const char *teamNames2[] = {
"Red",
"Blue",
0
};
static void UI_AddBotsMenu_Init( void ) {
int n;
int y;
int gametype;
int count;
char info[MAX_INFO_STRING];
trap_GetConfigString(CS_SERVERINFO, info, MAX_INFO_STRING);
gametype = atoi( Info_ValueForKey( info,"g_gametype" ) );
memset( &addBotsMenuInfo, 0 ,sizeof(addBotsMenuInfo) );
addBotsMenuInfo.menu.draw = UI_AddBotsMenu_Draw;
addBotsMenuInfo.menu.fullscreen = qfalse;
addBotsMenuInfo.menu.wrapAround = qtrue;
addBotsMenuInfo.delay = 1000;
UI_AddBots_Cache();
addBotsMenuInfo.numBots = UI_GetNumBots();
count = addBotsMenuInfo.numBots < 7 ? addBotsMenuInfo.numBots : 7;
addBotsMenuInfo.arrows.generic.type = MTYPE_BITMAP;
addBotsMenuInfo.arrows.generic.name = ART_ARROWS;
addBotsMenuInfo.arrows.generic.flags = QMF_INACTIVE;
addBotsMenuInfo.arrows.generic.x = 200;
addBotsMenuInfo.arrows.generic.y = 128;
addBotsMenuInfo.arrows.width = 64;
addBotsMenuInfo.arrows.height = 128;
addBotsMenuInfo.up.generic.type = MTYPE_BITMAP;
addBotsMenuInfo.up.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
addBotsMenuInfo.up.generic.x = 200;
addBotsMenuInfo.up.generic.y = 128;
addBotsMenuInfo.up.generic.id = ID_UP;
addBotsMenuInfo.up.generic.callback = UI_AddBotsMenu_UpEvent;
addBotsMenuInfo.up.width = 64;
addBotsMenuInfo.up.height = 64;
addBotsMenuInfo.up.focuspic = ART_ARROWUP;
addBotsMenuInfo.down.generic.type = MTYPE_BITMAP;
addBotsMenuInfo.down.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
addBotsMenuInfo.down.generic.x = 200;
addBotsMenuInfo.down.generic.y = 128+64;
addBotsMenuInfo.down.generic.id = ID_DOWN;
addBotsMenuInfo.down.generic.callback = UI_AddBotsMenu_DownEvent;
addBotsMenuInfo.down.width = 64;
addBotsMenuInfo.down.height = 64;
addBotsMenuInfo.down.focuspic = ART_ARROWDOWN;
for( n = 0, y = 120; n < count; n++, y += 20 ) {
addBotsMenuInfo.bots[n].generic.type = MTYPE_PTEXT;
addBotsMenuInfo.bots[n].generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
addBotsMenuInfo.bots[n].generic.id = ID_BOTNAME0 + n;
addBotsMenuInfo.bots[n].generic.x = 320 - 56;
addBotsMenuInfo.bots[n].generic.y = y;
addBotsMenuInfo.bots[n].generic.callback = UI_AddBotsMenu_BotEvent;
addBotsMenuInfo.bots[n].string = addBotsMenuInfo.botnames[n];
addBotsMenuInfo.bots[n].color = color_orange;
addBotsMenuInfo.bots[n].style = UI_LEFT|UI_SMALLFONT;
}
y += 12;
addBotsMenuInfo.skill.generic.type = MTYPE_SPINCONTROL;
addBotsMenuInfo.skill.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
addBotsMenuInfo.skill.generic.x = 320;
addBotsMenuInfo.skill.generic.y = y;
addBotsMenuInfo.skill.generic.name = "Skill:";
addBotsMenuInfo.skill.generic.id = ID_SKILL;
addBotsMenuInfo.skill.itemnames = skillNames;
addBotsMenuInfo.skill.curvalue = Com_Clamp( 0, 4, (int)trap_Cvar_VariableValue( "g_spSkill" ) - 1 );
y += SMALLCHAR_HEIGHT;
addBotsMenuInfo.team.generic.type = MTYPE_SPINCONTROL;
addBotsMenuInfo.team.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
addBotsMenuInfo.team.generic.x = 320;
addBotsMenuInfo.team.generic.y = y;
addBotsMenuInfo.team.generic.name = "Team: ";
addBotsMenuInfo.team.generic.id = ID_TEAM;
if( gametype >= GT_TEAM ) {
addBotsMenuInfo.team.itemnames = teamNames2;
}
else {
addBotsMenuInfo.team.itemnames = teamNames1;
addBotsMenuInfo.team.generic.flags = QMF_GRAYED;
}
addBotsMenuInfo.go.generic.type = MTYPE_BITMAP;
addBotsMenuInfo.go.generic.name = ART_FIGHT0;
addBotsMenuInfo.go.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
addBotsMenuInfo.go.generic.id = ID_GO;
addBotsMenuInfo.go.generic.callback = UI_AddBotsMenu_FightEvent;
addBotsMenuInfo.go.generic.x = 320+128-128;
addBotsMenuInfo.go.generic.y = 256+128-64;
addBotsMenuInfo.go.width = 128;
addBotsMenuInfo.go.height = 64;
addBotsMenuInfo.go.focuspic = ART_FIGHT1;
addBotsMenuInfo.back.generic.type = MTYPE_BITMAP;
addBotsMenuInfo.back.generic.name = ART_BACK0;
addBotsMenuInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
addBotsMenuInfo.back.generic.id = ID_BACK;
addBotsMenuInfo.back.generic.callback = UI_AddBotsMenu_BackEvent;
addBotsMenuInfo.back.generic.x = 320-128;
addBotsMenuInfo.back.generic.y = 256+128-64;
addBotsMenuInfo.back.width = 128;
addBotsMenuInfo.back.height = 64;
addBotsMenuInfo.back.focuspic = ART_BACK1;
addBotsMenuInfo.baseBotNum = 0;
addBotsMenuInfo.selectedBotNum = 0;
addBotsMenuInfo.bots[0].color = color_white;
UI_AddBotsMenu_GetSortedBotNums();
UI_AddBotsMenu_SetBotNames();
Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.arrows );
Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.up );
Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.down );
for( n = 0; n < count; n++ ) {
Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.bots[n] );
}
Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.skill );
Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.team );
Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.go );
Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.back );
}
/*
=================
UI_AddBots_Cache
=================
*/
void UI_AddBots_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
trap_R_RegisterShaderNoMip( ART_FIGHT0 );
trap_R_RegisterShaderNoMip( ART_FIGHT1 );
trap_R_RegisterShaderNoMip( ART_BACKGROUND );
trap_R_RegisterShaderNoMip( ART_ARROWS );
trap_R_RegisterShaderNoMip( ART_ARROWUP );
trap_R_RegisterShaderNoMip( ART_ARROWDOWN );
}
/*
=================
UI_AddBotsMenu
=================
*/
void UI_AddBotsMenu( void ) {
UI_AddBotsMenu_Init();
UI_PushMenu( &addBotsMenuInfo.menu );
}

File diff suppressed because it is too large Load diff

View file

@ -1,291 +1,291 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
CD KEY MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_FRAME "menu/art/cut_frame"
#define ART_ACCEPT0 "menu/art/accept_0"
#define ART_ACCEPT1 "menu/art/accept_1"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ID_CDKEY 10
#define ID_ACCEPT 11
#define ID_BACK 12
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s frame;
menufield_s cdkey;
menubitmap_s accept;
menubitmap_s back;
} cdkeyMenuInfo_t;
static cdkeyMenuInfo_t cdkeyMenuInfo;
/*
===============
UI_CDKeyMenu_Event
===============
*/
static void UI_CDKeyMenu_Event( void *ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_ACCEPT:
if( cdkeyMenuInfo.cdkey.field.buffer[0] ) {
trap_SetCDKey( cdkeyMenuInfo.cdkey.field.buffer );
}
UI_PopMenu();
break;
case ID_BACK:
UI_PopMenu();
break;
}
}
/*
=================
UI_CDKeyMenu_PreValidateKey
=================
*/
static int UI_CDKeyMenu_PreValidateKey( const char *key ) {
char ch;
if( strlen( key ) != 16 ) {
return 1;
}
while( ( ch = *key++ ) ) {
switch( ch ) {
case '2':
case '3':
case '7':
case 'a':
case 'b':
case 'c':
case 'd':
case 'g':
case 'h':
case 'j':
case 'l':
case 'p':
case 'r':
case 's':
case 't':
case 'w':
continue;
default:
return -1;
}
}
return 0;
}
/*
=================
UI_CDKeyMenu_DrawKey
=================
*/
static void UI_CDKeyMenu_DrawKey( void *self ) {
menufield_s *f;
qboolean focus;
int style;
char c;
float *color;
int x, y;
int val;
f = (menufield_s *)self;
focus = (f->generic.parent->cursor == f->generic.menuPosition);
style = UI_LEFT;
if( focus ) {
color = color_yellow;
}
else {
color = color_orange;
}
x = 320 - 8 * BIGCHAR_WIDTH;
y = 240 - BIGCHAR_HEIGHT / 2;
UI_FillRect( x, y, 16 * BIGCHAR_WIDTH, BIGCHAR_HEIGHT, listbar_color );
UI_DrawString( x, y, f->field.buffer, style, color );
// draw cursor if we have focus
if( focus ) {
if ( trap_Key_GetOverstrikeMode() ) {
c = 11;
} else {
c = 10;
}
style &= ~UI_PULSE;
style |= UI_BLINK;
UI_DrawChar( x + f->field.cursor * BIGCHAR_WIDTH, y, c, style, color_white );
}
val = UI_CDKeyMenu_PreValidateKey( f->field.buffer );
if( val == 1 ) {
UI_DrawProportionalString( 320, 376, "Please enter your CD Key", UI_CENTER|UI_SMALLFONT, color_yellow );
}
else if ( val == 0 ) {
UI_DrawProportionalString( 320, 376, "The CD Key appears to be valid, thank you", UI_CENTER|UI_SMALLFONT, color_white );
}
else {
UI_DrawProportionalString( 320, 376, "The CD Key is not valid", UI_CENTER|UI_SMALLFONT, color_red );
}
}
/*
===============
UI_CDKeyMenu_Init
===============
*/
static void UI_CDKeyMenu_Init( void ) {
trap_Cvar_Set( "ui_cdkeychecked", "1" );
UI_CDKeyMenu_Cache();
memset( &cdkeyMenuInfo, 0, sizeof(cdkeyMenuInfo) );
cdkeyMenuInfo.menu.wrapAround = qtrue;
cdkeyMenuInfo.menu.fullscreen = qtrue;
cdkeyMenuInfo.banner.generic.type = MTYPE_BTEXT;
cdkeyMenuInfo.banner.generic.x = 320;
cdkeyMenuInfo.banner.generic.y = 16;
cdkeyMenuInfo.banner.string = "CD KEY";
cdkeyMenuInfo.banner.color = color_white;
cdkeyMenuInfo.banner.style = UI_CENTER;
cdkeyMenuInfo.frame.generic.type = MTYPE_BITMAP;
cdkeyMenuInfo.frame.generic.name = ART_FRAME;
cdkeyMenuInfo.frame.generic.flags = QMF_INACTIVE;
cdkeyMenuInfo.frame.generic.x = 142;
cdkeyMenuInfo.frame.generic.y = 118;
cdkeyMenuInfo.frame.width = 359;
cdkeyMenuInfo.frame.height = 256;
cdkeyMenuInfo.cdkey.generic.type = MTYPE_FIELD;
cdkeyMenuInfo.cdkey.generic.name = "CD Key:";
cdkeyMenuInfo.cdkey.generic.flags = QMF_LOWERCASE;
cdkeyMenuInfo.cdkey.generic.x = 320 - BIGCHAR_WIDTH * 2.5;
cdkeyMenuInfo.cdkey.generic.y = 240 - BIGCHAR_HEIGHT / 2;
cdkeyMenuInfo.cdkey.field.widthInChars = 16;
cdkeyMenuInfo.cdkey.field.maxchars = 16;
cdkeyMenuInfo.cdkey.generic.ownerdraw = UI_CDKeyMenu_DrawKey;
cdkeyMenuInfo.accept.generic.type = MTYPE_BITMAP;
cdkeyMenuInfo.accept.generic.name = ART_ACCEPT0;
cdkeyMenuInfo.accept.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
cdkeyMenuInfo.accept.generic.id = ID_ACCEPT;
cdkeyMenuInfo.accept.generic.callback = UI_CDKeyMenu_Event;
cdkeyMenuInfo.accept.generic.x = 640;
cdkeyMenuInfo.accept.generic.y = 480-64;
cdkeyMenuInfo.accept.width = 128;
cdkeyMenuInfo.accept.height = 64;
cdkeyMenuInfo.accept.focuspic = ART_ACCEPT1;
cdkeyMenuInfo.back.generic.type = MTYPE_BITMAP;
cdkeyMenuInfo.back.generic.name = ART_BACK0;
cdkeyMenuInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
cdkeyMenuInfo.back.generic.id = ID_BACK;
cdkeyMenuInfo.back.generic.callback = UI_CDKeyMenu_Event;
cdkeyMenuInfo.back.generic.x = 0;
cdkeyMenuInfo.back.generic.y = 480-64;
cdkeyMenuInfo.back.width = 128;
cdkeyMenuInfo.back.height = 64;
cdkeyMenuInfo.back.focuspic = ART_BACK1;
Menu_AddItem( &cdkeyMenuInfo.menu, &cdkeyMenuInfo.banner );
Menu_AddItem( &cdkeyMenuInfo.menu, &cdkeyMenuInfo.frame );
Menu_AddItem( &cdkeyMenuInfo.menu, &cdkeyMenuInfo.cdkey );
Menu_AddItem( &cdkeyMenuInfo.menu, &cdkeyMenuInfo.accept );
if( uis.menusp ) {
Menu_AddItem( &cdkeyMenuInfo.menu, &cdkeyMenuInfo.back );
}
trap_GetCDKey( cdkeyMenuInfo.cdkey.field.buffer, cdkeyMenuInfo.cdkey.field.maxchars + 1 );
if( trap_VerifyCDKey( cdkeyMenuInfo.cdkey.field.buffer, NULL ) == qfalse ) {
cdkeyMenuInfo.cdkey.field.buffer[0] = 0;
}
}
/*
=================
UI_CDKeyMenu_Cache
=================
*/
void UI_CDKeyMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_ACCEPT0 );
trap_R_RegisterShaderNoMip( ART_ACCEPT1 );
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
trap_R_RegisterShaderNoMip( ART_FRAME );
}
/*
===============
UI_CDKeyMenu
===============
*/
void UI_CDKeyMenu( void ) {
UI_CDKeyMenu_Init();
UI_PushMenu( &cdkeyMenuInfo.menu );
}
/*
===============
UI_CDKeyMenu_f
===============
*/
void UI_CDKeyMenu_f( void ) {
UI_CDKeyMenu();
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
CD KEY MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_FRAME "menu/art/cut_frame"
#define ART_ACCEPT0 "menu/art/accept_0"
#define ART_ACCEPT1 "menu/art/accept_1"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ID_CDKEY 10
#define ID_ACCEPT 11
#define ID_BACK 12
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s frame;
menufield_s cdkey;
menubitmap_s accept;
menubitmap_s back;
} cdkeyMenuInfo_t;
static cdkeyMenuInfo_t cdkeyMenuInfo;
/*
===============
UI_CDKeyMenu_Event
===============
*/
static void UI_CDKeyMenu_Event( void *ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_ACCEPT:
if( cdkeyMenuInfo.cdkey.field.buffer[0] ) {
trap_SetCDKey( cdkeyMenuInfo.cdkey.field.buffer );
}
UI_PopMenu();
break;
case ID_BACK:
UI_PopMenu();
break;
}
}
/*
=================
UI_CDKeyMenu_PreValidateKey
=================
*/
static int UI_CDKeyMenu_PreValidateKey( const char *key ) {
char ch;
if( strlen( key ) != 16 ) {
return 1;
}
while( ( ch = *key++ ) ) {
switch( ch ) {
case '2':
case '3':
case '7':
case 'a':
case 'b':
case 'c':
case 'd':
case 'g':
case 'h':
case 'j':
case 'l':
case 'p':
case 'r':
case 's':
case 't':
case 'w':
continue;
default:
return -1;
}
}
return 0;
}
/*
=================
UI_CDKeyMenu_DrawKey
=================
*/
static void UI_CDKeyMenu_DrawKey( void *self ) {
menufield_s *f;
qboolean focus;
int style;
char c;
float *color;
int x, y;
int val;
f = (menufield_s *)self;
focus = (f->generic.parent->cursor == f->generic.menuPosition);
style = UI_LEFT;
if( focus ) {
color = color_yellow;
}
else {
color = color_orange;
}
x = 320 - 8 * BIGCHAR_WIDTH;
y = 240 - BIGCHAR_HEIGHT / 2;
UI_FillRect( x, y, 16 * BIGCHAR_WIDTH, BIGCHAR_HEIGHT, listbar_color );
UI_DrawString( x, y, f->field.buffer, style, color );
// draw cursor if we have focus
if( focus ) {
if ( trap_Key_GetOverstrikeMode() ) {
c = 11;
} else {
c = 10;
}
style &= ~UI_PULSE;
style |= UI_BLINK;
UI_DrawChar( x + f->field.cursor * BIGCHAR_WIDTH, y, c, style, color_white );
}
val = UI_CDKeyMenu_PreValidateKey( f->field.buffer );
if( val == 1 ) {
UI_DrawProportionalString( 320, 376, "Please enter your CD Key", UI_CENTER|UI_SMALLFONT, color_yellow );
}
else if ( val == 0 ) {
UI_DrawProportionalString( 320, 376, "The CD Key appears to be valid, thank you", UI_CENTER|UI_SMALLFONT, color_white );
}
else {
UI_DrawProportionalString( 320, 376, "The CD Key is not valid", UI_CENTER|UI_SMALLFONT, color_red );
}
}
/*
===============
UI_CDKeyMenu_Init
===============
*/
static void UI_CDKeyMenu_Init( void ) {
trap_Cvar_Set( "ui_cdkeychecked", "1" );
UI_CDKeyMenu_Cache();
memset( &cdkeyMenuInfo, 0, sizeof(cdkeyMenuInfo) );
cdkeyMenuInfo.menu.wrapAround = qtrue;
cdkeyMenuInfo.menu.fullscreen = qtrue;
cdkeyMenuInfo.banner.generic.type = MTYPE_BTEXT;
cdkeyMenuInfo.banner.generic.x = 320;
cdkeyMenuInfo.banner.generic.y = 16;
cdkeyMenuInfo.banner.string = "CD KEY";
cdkeyMenuInfo.banner.color = color_white;
cdkeyMenuInfo.banner.style = UI_CENTER;
cdkeyMenuInfo.frame.generic.type = MTYPE_BITMAP;
cdkeyMenuInfo.frame.generic.name = ART_FRAME;
cdkeyMenuInfo.frame.generic.flags = QMF_INACTIVE;
cdkeyMenuInfo.frame.generic.x = 142;
cdkeyMenuInfo.frame.generic.y = 118;
cdkeyMenuInfo.frame.width = 359;
cdkeyMenuInfo.frame.height = 256;
cdkeyMenuInfo.cdkey.generic.type = MTYPE_FIELD;
cdkeyMenuInfo.cdkey.generic.name = "CD Key:";
cdkeyMenuInfo.cdkey.generic.flags = QMF_LOWERCASE;
cdkeyMenuInfo.cdkey.generic.x = 320 - BIGCHAR_WIDTH * 2.5;
cdkeyMenuInfo.cdkey.generic.y = 240 - BIGCHAR_HEIGHT / 2;
cdkeyMenuInfo.cdkey.field.widthInChars = 16;
cdkeyMenuInfo.cdkey.field.maxchars = 16;
cdkeyMenuInfo.cdkey.generic.ownerdraw = UI_CDKeyMenu_DrawKey;
cdkeyMenuInfo.accept.generic.type = MTYPE_BITMAP;
cdkeyMenuInfo.accept.generic.name = ART_ACCEPT0;
cdkeyMenuInfo.accept.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
cdkeyMenuInfo.accept.generic.id = ID_ACCEPT;
cdkeyMenuInfo.accept.generic.callback = UI_CDKeyMenu_Event;
cdkeyMenuInfo.accept.generic.x = 640;
cdkeyMenuInfo.accept.generic.y = 480-64;
cdkeyMenuInfo.accept.width = 128;
cdkeyMenuInfo.accept.height = 64;
cdkeyMenuInfo.accept.focuspic = ART_ACCEPT1;
cdkeyMenuInfo.back.generic.type = MTYPE_BITMAP;
cdkeyMenuInfo.back.generic.name = ART_BACK0;
cdkeyMenuInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
cdkeyMenuInfo.back.generic.id = ID_BACK;
cdkeyMenuInfo.back.generic.callback = UI_CDKeyMenu_Event;
cdkeyMenuInfo.back.generic.x = 0;
cdkeyMenuInfo.back.generic.y = 480-64;
cdkeyMenuInfo.back.width = 128;
cdkeyMenuInfo.back.height = 64;
cdkeyMenuInfo.back.focuspic = ART_BACK1;
Menu_AddItem( &cdkeyMenuInfo.menu, &cdkeyMenuInfo.banner );
Menu_AddItem( &cdkeyMenuInfo.menu, &cdkeyMenuInfo.frame );
Menu_AddItem( &cdkeyMenuInfo.menu, &cdkeyMenuInfo.cdkey );
Menu_AddItem( &cdkeyMenuInfo.menu, &cdkeyMenuInfo.accept );
if( uis.menusp ) {
Menu_AddItem( &cdkeyMenuInfo.menu, &cdkeyMenuInfo.back );
}
trap_GetCDKey( cdkeyMenuInfo.cdkey.field.buffer, cdkeyMenuInfo.cdkey.field.maxchars + 1 );
if( trap_VerifyCDKey( cdkeyMenuInfo.cdkey.field.buffer, NULL ) == qfalse ) {
cdkeyMenuInfo.cdkey.field.buffer[0] = 0;
}
}
/*
=================
UI_CDKeyMenu_Cache
=================
*/
void UI_CDKeyMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_ACCEPT0 );
trap_R_RegisterShaderNoMip( ART_ACCEPT1 );
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
trap_R_RegisterShaderNoMip( ART_FRAME );
}
/*
===============
UI_CDKeyMenu
===============
*/
void UI_CDKeyMenu( void ) {
UI_CDKeyMenu_Init();
UI_PushMenu( &cdkeyMenuInfo.menu );
}
/*
===============
UI_CDKeyMenu_f
===============
*/
void UI_CDKeyMenu_f( void ) {
UI_CDKeyMenu();
}

View file

@ -1,350 +1,350 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#include "ui_local.h"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define VERTICAL_SPACING 30
#define ID_BACK 10
#define ID_CIN_IDLOGO 11
#define ID_CIN_INTRO 12
#define ID_CIN_TIER1 13
#define ID_CIN_TIER2 14
#define ID_CIN_TIER3 15
#define ID_CIN_TIER4 16
#define ID_CIN_TIER5 17
#define ID_CIN_TIER6 18
#define ID_CIN_TIER7 19
#define ID_CIN_END 20
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menutext_s cin_idlogo;
menutext_s cin_intro;
menutext_s cin_tier1;
menutext_s cin_tier2;
menutext_s cin_tier3;
menutext_s cin_tier4;
menutext_s cin_tier5;
menutext_s cin_tier6;
menutext_s cin_tier7;
menutext_s cin_end;
menubitmap_s back;
} cinematicsMenuInfo_t;
static cinematicsMenuInfo_t cinematicsMenuInfo;
static char *cinematics[] = {
"idlogo",
"intro",
"tier1",
"tier2",
"tier3",
"tier4",
"tier5",
"tier6",
"tier7",
"end"
};
/*
===============
UI_CinematicsMenu_BackEvent
===============
*/
static void UI_CinematicsMenu_BackEvent( void *ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
UI_PopMenu();
}
/*
===============
UI_CinematicsMenu_Event
===============
*/
static void UI_CinematicsMenu_Event( void *ptr, int event ) {
int n;
if (event != QM_ACTIVATED)
return;
n = ((menucommon_s*)ptr)->id - ID_CIN_IDLOGO;
trap_Cvar_Set( "nextmap", va( "ui_cinematics %i", n ) );
if( uis.demoversion && ((menucommon_s*)ptr)->id == ID_CIN_END ) {
trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect; cinematic demoEnd.RoQ 1\n" );
}
else {
trap_Cmd_ExecuteText( EXEC_APPEND, va( "disconnect; cinematic %s.RoQ\n", cinematics[n] ) );
}
}
/*
===============
UI_CinematicsMenu_Init
===============
*/
static void UI_CinematicsMenu_Init( void ) {
int y;
UI_CinematicsMenu_Cache();
memset( &cinematicsMenuInfo, 0, sizeof(cinematicsMenuInfo) );
cinematicsMenuInfo.menu.fullscreen = qtrue;
cinematicsMenuInfo.banner.generic.type = MTYPE_BTEXT;
cinematicsMenuInfo.banner.generic.x = 320;
cinematicsMenuInfo.banner.generic.y = 16;
cinematicsMenuInfo.banner.string = "CINEMATICS";
cinematicsMenuInfo.banner.color = color_white;
cinematicsMenuInfo.banner.style = UI_CENTER;
cinematicsMenuInfo.framel.generic.type = MTYPE_BITMAP;
cinematicsMenuInfo.framel.generic.name = ART_FRAMEL;
cinematicsMenuInfo.framel.generic.flags = QMF_INACTIVE;
cinematicsMenuInfo.framel.generic.x = 0;
cinematicsMenuInfo.framel.generic.y = 78;
cinematicsMenuInfo.framel.width = 256;
cinematicsMenuInfo.framel.height = 329;
cinematicsMenuInfo.framer.generic.type = MTYPE_BITMAP;
cinematicsMenuInfo.framer.generic.name = ART_FRAMER;
cinematicsMenuInfo.framer.generic.flags = QMF_INACTIVE;
cinematicsMenuInfo.framer.generic.x = 376;
cinematicsMenuInfo.framer.generic.y = 76;
cinematicsMenuInfo.framer.width = 256;
cinematicsMenuInfo.framer.height = 334;
y = 100;
cinematicsMenuInfo.cin_idlogo.generic.type = MTYPE_PTEXT;
cinematicsMenuInfo.cin_idlogo.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.cin_idlogo.generic.x = 320;
cinematicsMenuInfo.cin_idlogo.generic.y = y;
cinematicsMenuInfo.cin_idlogo.generic.id = ID_CIN_IDLOGO;
cinematicsMenuInfo.cin_idlogo.generic.callback = UI_CinematicsMenu_Event;
cinematicsMenuInfo.cin_idlogo.string = "ID LOGO";
cinematicsMenuInfo.cin_idlogo.color = color_red;
cinematicsMenuInfo.cin_idlogo.style = UI_CENTER;
y += VERTICAL_SPACING;
cinematicsMenuInfo.cin_intro.generic.type = MTYPE_PTEXT;
cinematicsMenuInfo.cin_intro.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.cin_intro.generic.x = 320;
cinematicsMenuInfo.cin_intro.generic.y = y;
cinematicsMenuInfo.cin_intro.generic.id = ID_CIN_INTRO;
cinematicsMenuInfo.cin_intro.generic.callback = UI_CinematicsMenu_Event;
cinematicsMenuInfo.cin_intro.string = "INTRO";
cinematicsMenuInfo.cin_intro.color = color_red;
cinematicsMenuInfo.cin_intro.style = UI_CENTER;
if( uis.demoversion ) {
cinematicsMenuInfo.cin_intro.generic.flags |= QMF_GRAYED;
}
y += VERTICAL_SPACING;
cinematicsMenuInfo.cin_tier1.generic.type = MTYPE_PTEXT;
cinematicsMenuInfo.cin_tier1.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.cin_tier1.generic.x = 320;
cinematicsMenuInfo.cin_tier1.generic.y = y;
cinematicsMenuInfo.cin_tier1.generic.id = ID_CIN_TIER1;
cinematicsMenuInfo.cin_tier1.generic.callback = UI_CinematicsMenu_Event;
cinematicsMenuInfo.cin_tier1.string = "Tier 1";
cinematicsMenuInfo.cin_tier1.color = color_red;
cinematicsMenuInfo.cin_tier1.style = UI_CENTER;
if( !UI_CanShowTierVideo( 1 ) ) {
cinematicsMenuInfo.cin_tier1.generic.flags |= QMF_GRAYED;
}
y += VERTICAL_SPACING;
cinematicsMenuInfo.cin_tier2.generic.type = MTYPE_PTEXT;
cinematicsMenuInfo.cin_tier2.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.cin_tier2.generic.x = 320;
cinematicsMenuInfo.cin_tier2.generic.y = y;
cinematicsMenuInfo.cin_tier2.generic.id = ID_CIN_TIER2;
cinematicsMenuInfo.cin_tier2.generic.callback = UI_CinematicsMenu_Event;
cinematicsMenuInfo.cin_tier2.string = "Tier 2";
cinematicsMenuInfo.cin_tier2.color = color_red;
cinematicsMenuInfo.cin_tier2.style = UI_CENTER;
if( !UI_CanShowTierVideo( 2 ) ) {
cinematicsMenuInfo.cin_tier2.generic.flags |= QMF_GRAYED;
}
y += VERTICAL_SPACING;
cinematicsMenuInfo.cin_tier3.generic.type = MTYPE_PTEXT;
cinematicsMenuInfo.cin_tier3.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.cin_tier3.generic.x = 320;
cinematicsMenuInfo.cin_tier3.generic.y = y;
cinematicsMenuInfo.cin_tier3.generic.id = ID_CIN_TIER3;
cinematicsMenuInfo.cin_tier3.generic.callback = UI_CinematicsMenu_Event;
cinematicsMenuInfo.cin_tier3.string = "Tier 3";
cinematicsMenuInfo.cin_tier3.color = color_red;
cinematicsMenuInfo.cin_tier3.style = UI_CENTER;
if( !UI_CanShowTierVideo( 3 ) ) {
cinematicsMenuInfo.cin_tier3.generic.flags |= QMF_GRAYED;
}
y += VERTICAL_SPACING;
cinematicsMenuInfo.cin_tier4.generic.type = MTYPE_PTEXT;
cinematicsMenuInfo.cin_tier4.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.cin_tier4.generic.x = 320;
cinematicsMenuInfo.cin_tier4.generic.y = y;
cinematicsMenuInfo.cin_tier4.generic.id = ID_CIN_TIER4;
cinematicsMenuInfo.cin_tier4.generic.callback = UI_CinematicsMenu_Event;
cinematicsMenuInfo.cin_tier4.string = "Tier 4";
cinematicsMenuInfo.cin_tier4.color = color_red;
cinematicsMenuInfo.cin_tier4.style = UI_CENTER;
if( !UI_CanShowTierVideo( 4 ) ) {
cinematicsMenuInfo.cin_tier4.generic.flags |= QMF_GRAYED;
}
y += VERTICAL_SPACING;
cinematicsMenuInfo.cin_tier5.generic.type = MTYPE_PTEXT;
cinematicsMenuInfo.cin_tier5.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.cin_tier5.generic.x = 320;
cinematicsMenuInfo.cin_tier5.generic.y = y;
cinematicsMenuInfo.cin_tier5.generic.id = ID_CIN_TIER5;
cinematicsMenuInfo.cin_tier5.generic.callback = UI_CinematicsMenu_Event;
cinematicsMenuInfo.cin_tier5.string = "Tier 5";
cinematicsMenuInfo.cin_tier5.color = color_red;
cinematicsMenuInfo.cin_tier5.style = UI_CENTER;
if( !UI_CanShowTierVideo( 5 ) ) {
cinematicsMenuInfo.cin_tier5.generic.flags |= QMF_GRAYED;
}
y += VERTICAL_SPACING;
cinematicsMenuInfo.cin_tier6.generic.type = MTYPE_PTEXT;
cinematicsMenuInfo.cin_tier6.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.cin_tier6.generic.x = 320;
cinematicsMenuInfo.cin_tier6.generic.y = y;
cinematicsMenuInfo.cin_tier6.generic.id = ID_CIN_TIER6;
cinematicsMenuInfo.cin_tier6.generic.callback = UI_CinematicsMenu_Event;
cinematicsMenuInfo.cin_tier6.string = "Tier 6";
cinematicsMenuInfo.cin_tier6.color = color_red;
cinematicsMenuInfo.cin_tier6.style = UI_CENTER;
if( !UI_CanShowTierVideo( 6 ) ) {
cinematicsMenuInfo.cin_tier6.generic.flags |= QMF_GRAYED;
}
y += VERTICAL_SPACING;
cinematicsMenuInfo.cin_tier7.generic.type = MTYPE_PTEXT;
cinematicsMenuInfo.cin_tier7.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.cin_tier7.generic.x = 320;
cinematicsMenuInfo.cin_tier7.generic.y = y;
cinematicsMenuInfo.cin_tier7.generic.id = ID_CIN_TIER7;
cinematicsMenuInfo.cin_tier7.generic.callback = UI_CinematicsMenu_Event;
cinematicsMenuInfo.cin_tier7.string = "Tier 7";
cinematicsMenuInfo.cin_tier7.color = color_red;
cinematicsMenuInfo.cin_tier7.style = UI_CENTER;
if( !UI_CanShowTierVideo( 7 ) ) {
cinematicsMenuInfo.cin_tier7.generic.flags |= QMF_GRAYED;
}
y += VERTICAL_SPACING;
cinematicsMenuInfo.cin_end.generic.type = MTYPE_PTEXT;
cinematicsMenuInfo.cin_end.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.cin_end.generic.x = 320;
cinematicsMenuInfo.cin_end.generic.y = y;
cinematicsMenuInfo.cin_end.generic.id = ID_CIN_END;
cinematicsMenuInfo.cin_end.generic.callback = UI_CinematicsMenu_Event;
cinematicsMenuInfo.cin_end.string = "END";
cinematicsMenuInfo.cin_end.color = color_red;
cinematicsMenuInfo.cin_end.style = UI_CENTER;
if( !UI_CanShowTierVideo( 8 ) ) {
cinematicsMenuInfo.cin_end.generic.flags |= QMF_GRAYED;
}
cinematicsMenuInfo.back.generic.type = MTYPE_BITMAP;
cinematicsMenuInfo.back.generic.name = ART_BACK0;
cinematicsMenuInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.back.generic.id = ID_BACK;
cinematicsMenuInfo.back.generic.callback = UI_CinematicsMenu_BackEvent;
cinematicsMenuInfo.back.generic.x = 0;
cinematicsMenuInfo.back.generic.y = 480-64;
cinematicsMenuInfo.back.width = 128;
cinematicsMenuInfo.back.height = 64;
cinematicsMenuInfo.back.focuspic = ART_BACK1;
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.banner );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.framel );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.framer );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_idlogo );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_intro );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier1 );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier2 );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier3 );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier4 );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier5 );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier6 );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier7 );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_end );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.back );
}
/*
=================
UI_CinematicsMenu_Cache
=================
*/
void UI_CinematicsMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
}
/*
===============
UI_CinematicsMenu
===============
*/
void UI_CinematicsMenu( void ) {
UI_CinematicsMenu_Init();
UI_PushMenu( &cinematicsMenuInfo.menu );
}
/*
===============
UI_CinematicsMenu_f
===============
*/
void UI_CinematicsMenu_f( void ) {
int n;
n = atoi( UI_Argv( 1 ) );
UI_CinematicsMenu();
Menu_SetCursorToItem( &cinematicsMenuInfo.menu, cinematicsMenuInfo.menu.items[n + 3] );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#include "ui_local.h"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define VERTICAL_SPACING 30
#define ID_BACK 10
#define ID_CIN_IDLOGO 11
#define ID_CIN_INTRO 12
#define ID_CIN_TIER1 13
#define ID_CIN_TIER2 14
#define ID_CIN_TIER3 15
#define ID_CIN_TIER4 16
#define ID_CIN_TIER5 17
#define ID_CIN_TIER6 18
#define ID_CIN_TIER7 19
#define ID_CIN_END 20
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menutext_s cin_idlogo;
menutext_s cin_intro;
menutext_s cin_tier1;
menutext_s cin_tier2;
menutext_s cin_tier3;
menutext_s cin_tier4;
menutext_s cin_tier5;
menutext_s cin_tier6;
menutext_s cin_tier7;
menutext_s cin_end;
menubitmap_s back;
} cinematicsMenuInfo_t;
static cinematicsMenuInfo_t cinematicsMenuInfo;
static char *cinematics[] = {
"idlogo",
"intro",
"tier1",
"tier2",
"tier3",
"tier4",
"tier5",
"tier6",
"tier7",
"end"
};
/*
===============
UI_CinematicsMenu_BackEvent
===============
*/
static void UI_CinematicsMenu_BackEvent( void *ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
UI_PopMenu();
}
/*
===============
UI_CinematicsMenu_Event
===============
*/
static void UI_CinematicsMenu_Event( void *ptr, int event ) {
int n;
if (event != QM_ACTIVATED)
return;
n = ((menucommon_s*)ptr)->id - ID_CIN_IDLOGO;
trap_Cvar_Set( "nextmap", va( "ui_cinematics %i", n ) );
if( uis.demoversion && ((menucommon_s*)ptr)->id == ID_CIN_END ) {
trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect; cinematic demoEnd.RoQ 1\n" );
}
else {
trap_Cmd_ExecuteText( EXEC_APPEND, va( "disconnect; cinematic %s.RoQ\n", cinematics[n] ) );
}
}
/*
===============
UI_CinematicsMenu_Init
===============
*/
static void UI_CinematicsMenu_Init( void ) {
int y;
UI_CinematicsMenu_Cache();
memset( &cinematicsMenuInfo, 0, sizeof(cinematicsMenuInfo) );
cinematicsMenuInfo.menu.fullscreen = qtrue;
cinematicsMenuInfo.banner.generic.type = MTYPE_BTEXT;
cinematicsMenuInfo.banner.generic.x = 320;
cinematicsMenuInfo.banner.generic.y = 16;
cinematicsMenuInfo.banner.string = "CINEMATICS";
cinematicsMenuInfo.banner.color = color_white;
cinematicsMenuInfo.banner.style = UI_CENTER;
cinematicsMenuInfo.framel.generic.type = MTYPE_BITMAP;
cinematicsMenuInfo.framel.generic.name = ART_FRAMEL;
cinematicsMenuInfo.framel.generic.flags = QMF_INACTIVE;
cinematicsMenuInfo.framel.generic.x = 0;
cinematicsMenuInfo.framel.generic.y = 78;
cinematicsMenuInfo.framel.width = 256;
cinematicsMenuInfo.framel.height = 329;
cinematicsMenuInfo.framer.generic.type = MTYPE_BITMAP;
cinematicsMenuInfo.framer.generic.name = ART_FRAMER;
cinematicsMenuInfo.framer.generic.flags = QMF_INACTIVE;
cinematicsMenuInfo.framer.generic.x = 376;
cinematicsMenuInfo.framer.generic.y = 76;
cinematicsMenuInfo.framer.width = 256;
cinematicsMenuInfo.framer.height = 334;
y = 100;
cinematicsMenuInfo.cin_idlogo.generic.type = MTYPE_PTEXT;
cinematicsMenuInfo.cin_idlogo.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.cin_idlogo.generic.x = 320;
cinematicsMenuInfo.cin_idlogo.generic.y = y;
cinematicsMenuInfo.cin_idlogo.generic.id = ID_CIN_IDLOGO;
cinematicsMenuInfo.cin_idlogo.generic.callback = UI_CinematicsMenu_Event;
cinematicsMenuInfo.cin_idlogo.string = "ID LOGO";
cinematicsMenuInfo.cin_idlogo.color = color_red;
cinematicsMenuInfo.cin_idlogo.style = UI_CENTER;
y += VERTICAL_SPACING;
cinematicsMenuInfo.cin_intro.generic.type = MTYPE_PTEXT;
cinematicsMenuInfo.cin_intro.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.cin_intro.generic.x = 320;
cinematicsMenuInfo.cin_intro.generic.y = y;
cinematicsMenuInfo.cin_intro.generic.id = ID_CIN_INTRO;
cinematicsMenuInfo.cin_intro.generic.callback = UI_CinematicsMenu_Event;
cinematicsMenuInfo.cin_intro.string = "INTRO";
cinematicsMenuInfo.cin_intro.color = color_red;
cinematicsMenuInfo.cin_intro.style = UI_CENTER;
if( uis.demoversion ) {
cinematicsMenuInfo.cin_intro.generic.flags |= QMF_GRAYED;
}
y += VERTICAL_SPACING;
cinematicsMenuInfo.cin_tier1.generic.type = MTYPE_PTEXT;
cinematicsMenuInfo.cin_tier1.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.cin_tier1.generic.x = 320;
cinematicsMenuInfo.cin_tier1.generic.y = y;
cinematicsMenuInfo.cin_tier1.generic.id = ID_CIN_TIER1;
cinematicsMenuInfo.cin_tier1.generic.callback = UI_CinematicsMenu_Event;
cinematicsMenuInfo.cin_tier1.string = "Tier 1";
cinematicsMenuInfo.cin_tier1.color = color_red;
cinematicsMenuInfo.cin_tier1.style = UI_CENTER;
if( !UI_CanShowTierVideo( 1 ) ) {
cinematicsMenuInfo.cin_tier1.generic.flags |= QMF_GRAYED;
}
y += VERTICAL_SPACING;
cinematicsMenuInfo.cin_tier2.generic.type = MTYPE_PTEXT;
cinematicsMenuInfo.cin_tier2.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.cin_tier2.generic.x = 320;
cinematicsMenuInfo.cin_tier2.generic.y = y;
cinematicsMenuInfo.cin_tier2.generic.id = ID_CIN_TIER2;
cinematicsMenuInfo.cin_tier2.generic.callback = UI_CinematicsMenu_Event;
cinematicsMenuInfo.cin_tier2.string = "Tier 2";
cinematicsMenuInfo.cin_tier2.color = color_red;
cinematicsMenuInfo.cin_tier2.style = UI_CENTER;
if( !UI_CanShowTierVideo( 2 ) ) {
cinematicsMenuInfo.cin_tier2.generic.flags |= QMF_GRAYED;
}
y += VERTICAL_SPACING;
cinematicsMenuInfo.cin_tier3.generic.type = MTYPE_PTEXT;
cinematicsMenuInfo.cin_tier3.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.cin_tier3.generic.x = 320;
cinematicsMenuInfo.cin_tier3.generic.y = y;
cinematicsMenuInfo.cin_tier3.generic.id = ID_CIN_TIER3;
cinematicsMenuInfo.cin_tier3.generic.callback = UI_CinematicsMenu_Event;
cinematicsMenuInfo.cin_tier3.string = "Tier 3";
cinematicsMenuInfo.cin_tier3.color = color_red;
cinematicsMenuInfo.cin_tier3.style = UI_CENTER;
if( !UI_CanShowTierVideo( 3 ) ) {
cinematicsMenuInfo.cin_tier3.generic.flags |= QMF_GRAYED;
}
y += VERTICAL_SPACING;
cinematicsMenuInfo.cin_tier4.generic.type = MTYPE_PTEXT;
cinematicsMenuInfo.cin_tier4.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.cin_tier4.generic.x = 320;
cinematicsMenuInfo.cin_tier4.generic.y = y;
cinematicsMenuInfo.cin_tier4.generic.id = ID_CIN_TIER4;
cinematicsMenuInfo.cin_tier4.generic.callback = UI_CinematicsMenu_Event;
cinematicsMenuInfo.cin_tier4.string = "Tier 4";
cinematicsMenuInfo.cin_tier4.color = color_red;
cinematicsMenuInfo.cin_tier4.style = UI_CENTER;
if( !UI_CanShowTierVideo( 4 ) ) {
cinematicsMenuInfo.cin_tier4.generic.flags |= QMF_GRAYED;
}
y += VERTICAL_SPACING;
cinematicsMenuInfo.cin_tier5.generic.type = MTYPE_PTEXT;
cinematicsMenuInfo.cin_tier5.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.cin_tier5.generic.x = 320;
cinematicsMenuInfo.cin_tier5.generic.y = y;
cinematicsMenuInfo.cin_tier5.generic.id = ID_CIN_TIER5;
cinematicsMenuInfo.cin_tier5.generic.callback = UI_CinematicsMenu_Event;
cinematicsMenuInfo.cin_tier5.string = "Tier 5";
cinematicsMenuInfo.cin_tier5.color = color_red;
cinematicsMenuInfo.cin_tier5.style = UI_CENTER;
if( !UI_CanShowTierVideo( 5 ) ) {
cinematicsMenuInfo.cin_tier5.generic.flags |= QMF_GRAYED;
}
y += VERTICAL_SPACING;
cinematicsMenuInfo.cin_tier6.generic.type = MTYPE_PTEXT;
cinematicsMenuInfo.cin_tier6.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.cin_tier6.generic.x = 320;
cinematicsMenuInfo.cin_tier6.generic.y = y;
cinematicsMenuInfo.cin_tier6.generic.id = ID_CIN_TIER6;
cinematicsMenuInfo.cin_tier6.generic.callback = UI_CinematicsMenu_Event;
cinematicsMenuInfo.cin_tier6.string = "Tier 6";
cinematicsMenuInfo.cin_tier6.color = color_red;
cinematicsMenuInfo.cin_tier6.style = UI_CENTER;
if( !UI_CanShowTierVideo( 6 ) ) {
cinematicsMenuInfo.cin_tier6.generic.flags |= QMF_GRAYED;
}
y += VERTICAL_SPACING;
cinematicsMenuInfo.cin_tier7.generic.type = MTYPE_PTEXT;
cinematicsMenuInfo.cin_tier7.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.cin_tier7.generic.x = 320;
cinematicsMenuInfo.cin_tier7.generic.y = y;
cinematicsMenuInfo.cin_tier7.generic.id = ID_CIN_TIER7;
cinematicsMenuInfo.cin_tier7.generic.callback = UI_CinematicsMenu_Event;
cinematicsMenuInfo.cin_tier7.string = "Tier 7";
cinematicsMenuInfo.cin_tier7.color = color_red;
cinematicsMenuInfo.cin_tier7.style = UI_CENTER;
if( !UI_CanShowTierVideo( 7 ) ) {
cinematicsMenuInfo.cin_tier7.generic.flags |= QMF_GRAYED;
}
y += VERTICAL_SPACING;
cinematicsMenuInfo.cin_end.generic.type = MTYPE_PTEXT;
cinematicsMenuInfo.cin_end.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.cin_end.generic.x = 320;
cinematicsMenuInfo.cin_end.generic.y = y;
cinematicsMenuInfo.cin_end.generic.id = ID_CIN_END;
cinematicsMenuInfo.cin_end.generic.callback = UI_CinematicsMenu_Event;
cinematicsMenuInfo.cin_end.string = "END";
cinematicsMenuInfo.cin_end.color = color_red;
cinematicsMenuInfo.cin_end.style = UI_CENTER;
if( !UI_CanShowTierVideo( 8 ) ) {
cinematicsMenuInfo.cin_end.generic.flags |= QMF_GRAYED;
}
cinematicsMenuInfo.back.generic.type = MTYPE_BITMAP;
cinematicsMenuInfo.back.generic.name = ART_BACK0;
cinematicsMenuInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
cinematicsMenuInfo.back.generic.id = ID_BACK;
cinematicsMenuInfo.back.generic.callback = UI_CinematicsMenu_BackEvent;
cinematicsMenuInfo.back.generic.x = 0;
cinematicsMenuInfo.back.generic.y = 480-64;
cinematicsMenuInfo.back.width = 128;
cinematicsMenuInfo.back.height = 64;
cinematicsMenuInfo.back.focuspic = ART_BACK1;
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.banner );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.framel );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.framer );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_idlogo );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_intro );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier1 );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier2 );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier3 );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier4 );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier5 );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier6 );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier7 );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_end );
Menu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.back );
}
/*
=================
UI_CinematicsMenu_Cache
=================
*/
void UI_CinematicsMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
}
/*
===============
UI_CinematicsMenu
===============
*/
void UI_CinematicsMenu( void ) {
UI_CinematicsMenu_Init();
UI_PushMenu( &cinematicsMenuInfo.menu );
}
/*
===============
UI_CinematicsMenu_f
===============
*/
void UI_CinematicsMenu_f( void ) {
int n;
n = atoi( UI_Argv( 1 ) );
UI_CinematicsMenu();
Menu_SetCursorToItem( &cinematicsMenuInfo.menu, cinematicsMenuInfo.menu.items[n + 3] );
}

View file

@ -1,293 +1,293 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
CONFIRMATION MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_CONFIRM_FRAME "menu/art/cut_frame"
#define ID_CONFIRM_NO 10
#define ID_CONFIRM_YES 11
typedef struct {
menuframework_s menu;
menutext_s no;
menutext_s yes;
int slashX;
const char * question;
void (*draw)( void );
void (*action)( qboolean result );
int style;
const char **lines;
} confirmMenu_t;
static confirmMenu_t s_confirm;
/*
=================
ConfirmMenu_Event
=================
*/
static void ConfirmMenu_Event( void* ptr, int event ) {
qboolean result;
if( event != QM_ACTIVATED ) {
return;
}
UI_PopMenu();
if( ((menucommon_s*)ptr)->id == ID_CONFIRM_NO ) {
result = qfalse;
}
else {
result = qtrue;
}
if( s_confirm.action ) {
s_confirm.action( result );
}
}
/*
=================
ConfirmMenu_Key
=================
*/
static sfxHandle_t ConfirmMenu_Key( int key ) {
switch ( key ) {
case K_KP_LEFTARROW:
case K_LEFTARROW:
case K_KP_RIGHTARROW:
case K_RIGHTARROW:
key = K_TAB;
break;
case 'n':
case 'N':
ConfirmMenu_Event( &s_confirm.no, QM_ACTIVATED );
break;
case 'y':
case 'Y':
ConfirmMenu_Event( &s_confirm.yes, QM_ACTIVATED );
break;
}
return Menu_DefaultKey( &s_confirm.menu, key );
}
/*
=================
MessaheMenu_Draw
=================
*/
static void MessageMenu_Draw( void ) {
int i,y;
UI_DrawNamedPic( 142, 118, 359, 256, ART_CONFIRM_FRAME );
y = 188;
for(i=0; s_confirm.lines[i]; i++)
{
UI_DrawProportionalString( 320, y, s_confirm.lines[i], s_confirm.style, color_red );
y += 18;
}
Menu_Draw( &s_confirm.menu );
if( s_confirm.draw ) {
s_confirm.draw();
}
}
/*
=================
ConfirmMenu_Draw
=================
*/
static void ConfirmMenu_Draw( void ) {
UI_DrawNamedPic( 142, 118, 359, 256, ART_CONFIRM_FRAME );
UI_DrawProportionalString( 320, 204, s_confirm.question, s_confirm.style, color_red );
UI_DrawProportionalString( s_confirm.slashX, 265, "/", UI_LEFT|UI_INVERSE, color_red );
Menu_Draw( &s_confirm.menu );
if( s_confirm.draw ) {
s_confirm.draw();
}
}
/*
=================
ConfirmMenu_Cache
=================
*/
void ConfirmMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_CONFIRM_FRAME );
}
/*
=================
UI_ConfirmMenu_Stlye
=================
*/
void UI_ConfirmMenu_Style( const char *question, int style, void (*draw)( void ), void (*action)( qboolean result ) ) {
uiClientState_t cstate;
int n1, n2, n3;
int l1, l2, l3;
// zero set all our globals
memset( &s_confirm, 0, sizeof(s_confirm) );
ConfirmMenu_Cache();
n1 = UI_ProportionalStringWidth( "YES/NO" );
n2 = UI_ProportionalStringWidth( "YES" ) + PROP_GAP_WIDTH;
n3 = UI_ProportionalStringWidth( "/" ) + PROP_GAP_WIDTH;
l1 = 320 - ( n1 / 2 );
l2 = l1 + n2;
l3 = l2 + n3;
s_confirm.slashX = l2;
s_confirm.question = question;
s_confirm.draw = draw;
s_confirm.action = action;
s_confirm.style = style;
s_confirm.menu.draw = ConfirmMenu_Draw;
s_confirm.menu.key = ConfirmMenu_Key;
s_confirm.menu.wrapAround = qtrue;
trap_GetClientState( &cstate );
if ( cstate.connState >= CA_CONNECTED ) {
s_confirm.menu.fullscreen = qfalse;
}
else {
s_confirm.menu.fullscreen = qtrue;
}
s_confirm.yes.generic.type = MTYPE_PTEXT;
s_confirm.yes.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_confirm.yes.generic.callback = ConfirmMenu_Event;
s_confirm.yes.generic.id = ID_CONFIRM_YES;
s_confirm.yes.generic.x = l1;
s_confirm.yes.generic.y = 264;
s_confirm.yes.string = "YES";
s_confirm.yes.color = color_red;
s_confirm.yes.style = UI_LEFT;
s_confirm.no.generic.type = MTYPE_PTEXT;
s_confirm.no.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_confirm.no.generic.callback = ConfirmMenu_Event;
s_confirm.no.generic.id = ID_CONFIRM_NO;
s_confirm.no.generic.x = l3;
s_confirm.no.generic.y = 264;
s_confirm.no.string = "NO";
s_confirm.no.color = color_red;
s_confirm.no.style = UI_LEFT;
Menu_AddItem( &s_confirm.menu, &s_confirm.yes );
Menu_AddItem( &s_confirm.menu, &s_confirm.no );
UI_PushMenu( &s_confirm.menu );
Menu_SetCursorToItem( &s_confirm.menu, &s_confirm.no );
}
/*
=================
UI_ConfirmMenu
=================
*/
void UI_ConfirmMenu( const char *question, void (*draw)( void ), void (*action)( qboolean result ) ) {
UI_ConfirmMenu_Style(question, UI_CENTER|UI_INVERSE, draw, action);
}
/*
=================
UI_Message
hacked over from Confirm stuff
=================
*/
void UI_Message( const char **lines ) {
uiClientState_t cstate;
int n1, l1;
// zero set all our globals
memset( &s_confirm, 0, sizeof(s_confirm) );
ConfirmMenu_Cache();
n1 = UI_ProportionalStringWidth( "OK" );
l1 = 320 - ( n1 / 2 );
s_confirm.lines = lines;
s_confirm.style = UI_CENTER|UI_INVERSE|UI_SMALLFONT;
s_confirm.menu.draw = MessageMenu_Draw;
s_confirm.menu.key = ConfirmMenu_Key;
s_confirm.menu.wrapAround = qtrue;
trap_GetClientState( &cstate );
if ( cstate.connState >= CA_CONNECTED ) {
s_confirm.menu.fullscreen = qfalse;
}
else {
s_confirm.menu.fullscreen = qtrue;
}
s_confirm.yes.generic.type = MTYPE_PTEXT;
s_confirm.yes.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_confirm.yes.generic.callback = ConfirmMenu_Event;
s_confirm.yes.generic.id = ID_CONFIRM_YES;
s_confirm.yes.generic.x = l1;
s_confirm.yes.generic.y = 280;
s_confirm.yes.string = "OK";
s_confirm.yes.color = color_red;
s_confirm.yes.style = UI_LEFT;
Menu_AddItem( &s_confirm.menu, &s_confirm.yes );
UI_PushMenu( &s_confirm.menu );
Menu_SetCursorToItem( &s_confirm.menu, &s_confirm.yes );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
CONFIRMATION MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_CONFIRM_FRAME "menu/art/cut_frame"
#define ID_CONFIRM_NO 10
#define ID_CONFIRM_YES 11
typedef struct {
menuframework_s menu;
menutext_s no;
menutext_s yes;
int slashX;
const char * question;
void (*draw)( void );
void (*action)( qboolean result );
int style;
const char **lines;
} confirmMenu_t;
static confirmMenu_t s_confirm;
/*
=================
ConfirmMenu_Event
=================
*/
static void ConfirmMenu_Event( void* ptr, int event ) {
qboolean result;
if( event != QM_ACTIVATED ) {
return;
}
UI_PopMenu();
if( ((menucommon_s*)ptr)->id == ID_CONFIRM_NO ) {
result = qfalse;
}
else {
result = qtrue;
}
if( s_confirm.action ) {
s_confirm.action( result );
}
}
/*
=================
ConfirmMenu_Key
=================
*/
static sfxHandle_t ConfirmMenu_Key( int key ) {
switch ( key ) {
case K_KP_LEFTARROW:
case K_LEFTARROW:
case K_KP_RIGHTARROW:
case K_RIGHTARROW:
key = K_TAB;
break;
case 'n':
case 'N':
ConfirmMenu_Event( &s_confirm.no, QM_ACTIVATED );
break;
case 'y':
case 'Y':
ConfirmMenu_Event( &s_confirm.yes, QM_ACTIVATED );
break;
}
return Menu_DefaultKey( &s_confirm.menu, key );
}
/*
=================
MessaheMenu_Draw
=================
*/
static void MessageMenu_Draw( void ) {
int i,y;
UI_DrawNamedPic( 142, 118, 359, 256, ART_CONFIRM_FRAME );
y = 188;
for(i=0; s_confirm.lines[i]; i++)
{
UI_DrawProportionalString( 320, y, s_confirm.lines[i], s_confirm.style, color_red );
y += 18;
}
Menu_Draw( &s_confirm.menu );
if( s_confirm.draw ) {
s_confirm.draw();
}
}
/*
=================
ConfirmMenu_Draw
=================
*/
static void ConfirmMenu_Draw( void ) {
UI_DrawNamedPic( 142, 118, 359, 256, ART_CONFIRM_FRAME );
UI_DrawProportionalString( 320, 204, s_confirm.question, s_confirm.style, color_red );
UI_DrawProportionalString( s_confirm.slashX, 265, "/", UI_LEFT|UI_INVERSE, color_red );
Menu_Draw( &s_confirm.menu );
if( s_confirm.draw ) {
s_confirm.draw();
}
}
/*
=================
ConfirmMenu_Cache
=================
*/
void ConfirmMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_CONFIRM_FRAME );
}
/*
=================
UI_ConfirmMenu_Stlye
=================
*/
void UI_ConfirmMenu_Style( const char *question, int style, void (*draw)( void ), void (*action)( qboolean result ) ) {
uiClientState_t cstate;
int n1, n2, n3;
int l1, l2, l3;
// zero set all our globals
memset( &s_confirm, 0, sizeof(s_confirm) );
ConfirmMenu_Cache();
n1 = UI_ProportionalStringWidth( "YES/NO" );
n2 = UI_ProportionalStringWidth( "YES" ) + PROP_GAP_WIDTH;
n3 = UI_ProportionalStringWidth( "/" ) + PROP_GAP_WIDTH;
l1 = 320 - ( n1 / 2 );
l2 = l1 + n2;
l3 = l2 + n3;
s_confirm.slashX = l2;
s_confirm.question = question;
s_confirm.draw = draw;
s_confirm.action = action;
s_confirm.style = style;
s_confirm.menu.draw = ConfirmMenu_Draw;
s_confirm.menu.key = ConfirmMenu_Key;
s_confirm.menu.wrapAround = qtrue;
trap_GetClientState( &cstate );
if ( cstate.connState >= CA_CONNECTED ) {
s_confirm.menu.fullscreen = qfalse;
}
else {
s_confirm.menu.fullscreen = qtrue;
}
s_confirm.yes.generic.type = MTYPE_PTEXT;
s_confirm.yes.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_confirm.yes.generic.callback = ConfirmMenu_Event;
s_confirm.yes.generic.id = ID_CONFIRM_YES;
s_confirm.yes.generic.x = l1;
s_confirm.yes.generic.y = 264;
s_confirm.yes.string = "YES";
s_confirm.yes.color = color_red;
s_confirm.yes.style = UI_LEFT;
s_confirm.no.generic.type = MTYPE_PTEXT;
s_confirm.no.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_confirm.no.generic.callback = ConfirmMenu_Event;
s_confirm.no.generic.id = ID_CONFIRM_NO;
s_confirm.no.generic.x = l3;
s_confirm.no.generic.y = 264;
s_confirm.no.string = "NO";
s_confirm.no.color = color_red;
s_confirm.no.style = UI_LEFT;
Menu_AddItem( &s_confirm.menu, &s_confirm.yes );
Menu_AddItem( &s_confirm.menu, &s_confirm.no );
UI_PushMenu( &s_confirm.menu );
Menu_SetCursorToItem( &s_confirm.menu, &s_confirm.no );
}
/*
=================
UI_ConfirmMenu
=================
*/
void UI_ConfirmMenu( const char *question, void (*draw)( void ), void (*action)( qboolean result ) ) {
UI_ConfirmMenu_Style(question, UI_CENTER|UI_INVERSE, draw, action);
}
/*
=================
UI_Message
hacked over from Confirm stuff
=================
*/
void UI_Message( const char **lines ) {
uiClientState_t cstate;
int n1, l1;
// zero set all our globals
memset( &s_confirm, 0, sizeof(s_confirm) );
ConfirmMenu_Cache();
n1 = UI_ProportionalStringWidth( "OK" );
l1 = 320 - ( n1 / 2 );
s_confirm.lines = lines;
s_confirm.style = UI_CENTER|UI_INVERSE|UI_SMALLFONT;
s_confirm.menu.draw = MessageMenu_Draw;
s_confirm.menu.key = ConfirmMenu_Key;
s_confirm.menu.wrapAround = qtrue;
trap_GetClientState( &cstate );
if ( cstate.connState >= CA_CONNECTED ) {
s_confirm.menu.fullscreen = qfalse;
}
else {
s_confirm.menu.fullscreen = qtrue;
}
s_confirm.yes.generic.type = MTYPE_PTEXT;
s_confirm.yes.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_confirm.yes.generic.callback = ConfirmMenu_Event;
s_confirm.yes.generic.id = ID_CONFIRM_YES;
s_confirm.yes.generic.x = l1;
s_confirm.yes.generic.y = 280;
s_confirm.yes.string = "OK";
s_confirm.yes.color = color_red;
s_confirm.yes.style = UI_LEFT;
Menu_AddItem( &s_confirm.menu, &s_confirm.yes );
UI_PushMenu( &s_confirm.menu );
Menu_SetCursorToItem( &s_confirm.menu, &s_confirm.yes );
}

View file

@ -1,282 +1,282 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#include "ui_local.h"
/*
===============================================================================
CONNECTION SCREEN
===============================================================================
*/
qboolean passwordNeeded = qtrue;
menufield_s passwordField;
static connstate_t lastConnState;
static char lastLoadingText[MAX_INFO_VALUE];
static void UI_ReadableSize ( char *buf, int bufsize, int value )
{
if (value > 1024*1024*1024 ) { // gigs
Com_sprintf( buf, bufsize, "%d", value / (1024*1024*1024) );
Com_sprintf( buf+strlen(buf), bufsize-strlen(buf), ".%02d GB",
(value % (1024*1024*1024))*100 / (1024*1024*1024) );
} else if (value > 1024*1024 ) { // megs
Com_sprintf( buf, bufsize, "%d", value / (1024*1024) );
Com_sprintf( buf+strlen(buf), bufsize-strlen(buf), ".%02d MB",
(value % (1024*1024))*100 / (1024*1024) );
} else if (value > 1024 ) { // kilos
Com_sprintf( buf, bufsize, "%d KB", value / 1024 );
} else { // bytes
Com_sprintf( buf, bufsize, "%d bytes", value );
}
}
// Assumes time is in msec
static void UI_PrintTime ( char *buf, int bufsize, int time ) {
time /= 1000; // change to seconds
if (time > 3600) { // in the hours range
Com_sprintf( buf, bufsize, "%d hr %d min", time / 3600, (time % 3600) / 60 );
} else if (time > 60) { // mins
Com_sprintf( buf, bufsize, "%d min %d sec", time / 60, time % 60 );
} else { // secs
Com_sprintf( buf, bufsize, "%d sec", time );
}
}
static void UI_DisplayDownloadInfo( const char *downloadName ) {
static char dlText[] = "Downloading:";
static char etaText[] = "Estimated time left:";
static char xferText[] = "Transfer rate:";
int downloadSize, downloadCount, downloadTime;
char dlSizeBuf[64], totalSizeBuf[64], xferRateBuf[64], dlTimeBuf[64];
int xferRate;
int width, leftWidth;
int style = UI_LEFT|UI_SMALLFONT|UI_DROPSHADOW;
const char *s;
downloadSize = trap_Cvar_VariableValue( "cl_downloadSize" );
downloadCount = trap_Cvar_VariableValue( "cl_downloadCount" );
downloadTime = trap_Cvar_VariableValue( "cl_downloadTime" );
#if 0 // bk010104
fprintf( stderr, "\n\n-----------------------------------------------\n");
fprintf( stderr, "DB: downloadSize: %16d\n", downloadSize );
fprintf( stderr, "DB: downloadCount: %16d\n", downloadCount );
fprintf( stderr, "DB: downloadTime: %16d\n", downloadTime );
fprintf( stderr, "DB: UI realtime: %16d\n", uis.realtime ); // bk
fprintf( stderr, "DB: UI frametime: %16d\n", uis.frametime ); // bk
#endif
leftWidth = width = UI_ProportionalStringWidth( dlText ) * UI_ProportionalSizeScale( style );
width = UI_ProportionalStringWidth( etaText ) * UI_ProportionalSizeScale( style );
if (width > leftWidth) leftWidth = width;
width = UI_ProportionalStringWidth( xferText ) * UI_ProportionalSizeScale( style );
if (width > leftWidth) leftWidth = width;
leftWidth += 16;
UI_DrawProportionalString( 8, 128, dlText, style, color_white );
UI_DrawProportionalString( 8, 160, etaText, style, color_white );
UI_DrawProportionalString( 8, 224, xferText, style, color_white );
if (downloadSize > 0) {
s = va( "%s (%d%%)", downloadName, downloadCount * 100 / downloadSize );
} else {
s = downloadName;
}
UI_DrawProportionalString( leftWidth, 128, s, style, color_white );
UI_ReadableSize( dlSizeBuf, sizeof dlSizeBuf, downloadCount );
UI_ReadableSize( totalSizeBuf, sizeof totalSizeBuf, downloadSize );
if (downloadCount < 4096 || !downloadTime) {
UI_DrawProportionalString( leftWidth, 160, "estimating", style, color_white );
UI_DrawProportionalString( leftWidth, 192,
va("(%s of %s copied)", dlSizeBuf, totalSizeBuf), style, color_white );
} else {
// bk010108
//float elapsedTime = (float)(uis.realtime - downloadTime); // current - start (msecs)
//elapsedTime = elapsedTime * 0.001f; // in seconds
//if ( elapsedTime <= 0.0f ) elapsedTime == 0.0f;
if ( (uis.realtime - downloadTime) / 1000) {
xferRate = downloadCount / ((uis.realtime - downloadTime) / 1000);
//xferRate = (int)( ((float)downloadCount) / elapsedTime);
} else {
xferRate = 0;
}
//fprintf( stderr, "DB: elapsedTime: %16.8f\n", elapsedTime ); // bk
//fprintf( stderr, "DB: xferRate: %16d\n", xferRate ); // bk
UI_ReadableSize( xferRateBuf, sizeof xferRateBuf, xferRate );
// Extrapolate estimated completion time
if (downloadSize && xferRate) {
int n = downloadSize / xferRate; // estimated time for entire d/l in secs
// We do it in K (/1024) because we'd overflow around 4MB
n = (n - (((downloadCount/1024) * n) / (downloadSize/1024))) * 1000;
UI_PrintTime ( dlTimeBuf, sizeof dlTimeBuf, n ); // bk010104
//(n - (((downloadCount/1024) * n) / (downloadSize/1024))) * 1000);
UI_DrawProportionalString( leftWidth, 160,
dlTimeBuf, style, color_white );
UI_DrawProportionalString( leftWidth, 192,
va("(%s of %s copied)", dlSizeBuf, totalSizeBuf), style, color_white );
} else {
UI_DrawProportionalString( leftWidth, 160,
"estimating", style, color_white );
if (downloadSize) {
UI_DrawProportionalString( leftWidth, 192,
va("(%s of %s copied)", dlSizeBuf, totalSizeBuf), style, color_white );
} else {
UI_DrawProportionalString( leftWidth, 192,
va("(%s copied)", dlSizeBuf), style, color_white );
}
}
if (xferRate) {
UI_DrawProportionalString( leftWidth, 224,
va("%s/Sec", xferRateBuf), style, color_white );
}
}
}
/*
========================
UI_DrawConnectScreen
This will also be overlaid on the cgame info screen during loading
to prevent it from blinking away too rapidly on local or lan games.
========================
*/
void UI_DrawConnectScreen( qboolean overlay ) {
char *s;
uiClientState_t cstate;
char info[MAX_INFO_VALUE];
Menu_Cache();
if ( !overlay ) {
// draw the dialog background
UI_SetColor( color_white );
UI_DrawHandlePic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, uis.menuBackShader );
}
// see what information we should display
trap_GetClientState( &cstate );
info[0] = '\0';
if( trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) ) ) {
UI_DrawProportionalString( 320, 16, va( "Loading %s", Info_ValueForKey( info, "mapname" ) ), UI_BIGFONT|UI_CENTER|UI_DROPSHADOW, color_white );
}
UI_DrawProportionalString( 320, 64, va("Connecting to %s", cstate.servername), UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
//UI_DrawProportionalString( 320, 96, "Press Esc to abort", UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
// display global MOTD at bottom
UI_DrawProportionalString( SCREEN_WIDTH/2, SCREEN_HEIGHT-32,
Info_ValueForKey( cstate.updateInfoString, "motd" ), UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
// print any server info (server full, bad version, etc)
if ( cstate.connState < CA_CONNECTED ) {
UI_DrawProportionalString_AutoWrapped( 320, 192, 630, 20, cstate.messageString, UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
}
#if 0
// display password field
if ( passwordNeeded ) {
s_ingame_menu.x = SCREEN_WIDTH * 0.50 - 128;
s_ingame_menu.nitems = 0;
s_ingame_menu.wrapAround = qtrue;
passwordField.generic.type = MTYPE_FIELD;
passwordField.generic.name = "Password:";
passwordField.generic.callback = 0;
passwordField.generic.x = 10;
passwordField.generic.y = 180;
Field_Clear( &passwordField.field );
passwordField.width = 256;
passwordField.field.widthInChars = 16;
Q_strncpyz( passwordField.field.buffer, Cvar_VariableString("password"),
sizeof(passwordField.field.buffer) );
Menu_AddItem( &s_ingame_menu, ( void * ) &s_customize_player_action );
MField_Draw( &passwordField );
}
#endif
if ( lastConnState > cstate.connState ) {
lastLoadingText[0] = '\0';
}
lastConnState = cstate.connState;
switch ( cstate.connState ) {
case CA_CONNECTING:
s = va("Awaiting challenge...%i", cstate.connectPacketCount);
break;
case CA_CHALLENGING:
s = va("Awaiting connection...%i", cstate.connectPacketCount);
break;
case CA_CONNECTED: {
char downloadName[MAX_INFO_VALUE];
trap_Cvar_VariableStringBuffer( "cl_downloadName", downloadName, sizeof(downloadName) );
if (*downloadName) {
UI_DisplayDownloadInfo( downloadName );
return;
}
}
s = "Awaiting gamestate...";
break;
case CA_LOADING:
return;
case CA_PRIMED:
return;
default:
return;
}
UI_DrawProportionalString( 320, 128, s, UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, color_white );
// password required / connection rejected information goes here
}
/*
===================
UI_KeyConnect
===================
*/
void UI_KeyConnect( int key ) {
if ( key == K_ESCAPE ) {
trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect\n" );
return;
}
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#include "ui_local.h"
/*
===============================================================================
CONNECTION SCREEN
===============================================================================
*/
qboolean passwordNeeded = qtrue;
menufield_s passwordField;
static connstate_t lastConnState;
static char lastLoadingText[MAX_INFO_VALUE];
static void UI_ReadableSize ( char *buf, int bufsize, int value )
{
if (value > 1024*1024*1024 ) { // gigs
Com_sprintf( buf, bufsize, "%d", value / (1024*1024*1024) );
Com_sprintf( buf+strlen(buf), bufsize-strlen(buf), ".%02d GB",
(value % (1024*1024*1024))*100 / (1024*1024*1024) );
} else if (value > 1024*1024 ) { // megs
Com_sprintf( buf, bufsize, "%d", value / (1024*1024) );
Com_sprintf( buf+strlen(buf), bufsize-strlen(buf), ".%02d MB",
(value % (1024*1024))*100 / (1024*1024) );
} else if (value > 1024 ) { // kilos
Com_sprintf( buf, bufsize, "%d KB", value / 1024 );
} else { // bytes
Com_sprintf( buf, bufsize, "%d bytes", value );
}
}
// Assumes time is in msec
static void UI_PrintTime ( char *buf, int bufsize, int time ) {
time /= 1000; // change to seconds
if (time > 3600) { // in the hours range
Com_sprintf( buf, bufsize, "%d hr %d min", time / 3600, (time % 3600) / 60 );
} else if (time > 60) { // mins
Com_sprintf( buf, bufsize, "%d min %d sec", time / 60, time % 60 );
} else { // secs
Com_sprintf( buf, bufsize, "%d sec", time );
}
}
static void UI_DisplayDownloadInfo( const char *downloadName ) {
static char dlText[] = "Downloading:";
static char etaText[] = "Estimated time left:";
static char xferText[] = "Transfer rate:";
int downloadSize, downloadCount, downloadTime;
char dlSizeBuf[64], totalSizeBuf[64], xferRateBuf[64], dlTimeBuf[64];
int xferRate;
int width, leftWidth;
int style = UI_LEFT|UI_SMALLFONT|UI_DROPSHADOW;
const char *s;
downloadSize = trap_Cvar_VariableValue( "cl_downloadSize" );
downloadCount = trap_Cvar_VariableValue( "cl_downloadCount" );
downloadTime = trap_Cvar_VariableValue( "cl_downloadTime" );
#if 0 // bk010104
fprintf( stderr, "\n\n-----------------------------------------------\n");
fprintf( stderr, "DB: downloadSize: %16d\n", downloadSize );
fprintf( stderr, "DB: downloadCount: %16d\n", downloadCount );
fprintf( stderr, "DB: downloadTime: %16d\n", downloadTime );
fprintf( stderr, "DB: UI realtime: %16d\n", uis.realtime ); // bk
fprintf( stderr, "DB: UI frametime: %16d\n", uis.frametime ); // bk
#endif
leftWidth = width = UI_ProportionalStringWidth( dlText ) * UI_ProportionalSizeScale( style );
width = UI_ProportionalStringWidth( etaText ) * UI_ProportionalSizeScale( style );
if (width > leftWidth) leftWidth = width;
width = UI_ProportionalStringWidth( xferText ) * UI_ProportionalSizeScale( style );
if (width > leftWidth) leftWidth = width;
leftWidth += 16;
UI_DrawProportionalString( 8, 128, dlText, style, color_white );
UI_DrawProportionalString( 8, 160, etaText, style, color_white );
UI_DrawProportionalString( 8, 224, xferText, style, color_white );
if (downloadSize > 0) {
s = va( "%s (%d%%)", downloadName, downloadCount * 100 / downloadSize );
} else {
s = downloadName;
}
UI_DrawProportionalString( leftWidth, 128, s, style, color_white );
UI_ReadableSize( dlSizeBuf, sizeof dlSizeBuf, downloadCount );
UI_ReadableSize( totalSizeBuf, sizeof totalSizeBuf, downloadSize );
if (downloadCount < 4096 || !downloadTime) {
UI_DrawProportionalString( leftWidth, 160, "estimating", style, color_white );
UI_DrawProportionalString( leftWidth, 192,
va("(%s of %s copied)", dlSizeBuf, totalSizeBuf), style, color_white );
} else {
// bk010108
//float elapsedTime = (float)(uis.realtime - downloadTime); // current - start (msecs)
//elapsedTime = elapsedTime * 0.001f; // in seconds
//if ( elapsedTime <= 0.0f ) elapsedTime == 0.0f;
if ( (uis.realtime - downloadTime) / 1000) {
xferRate = downloadCount / ((uis.realtime - downloadTime) / 1000);
//xferRate = (int)( ((float)downloadCount) / elapsedTime);
} else {
xferRate = 0;
}
//fprintf( stderr, "DB: elapsedTime: %16.8f\n", elapsedTime ); // bk
//fprintf( stderr, "DB: xferRate: %16d\n", xferRate ); // bk
UI_ReadableSize( xferRateBuf, sizeof xferRateBuf, xferRate );
// Extrapolate estimated completion time
if (downloadSize && xferRate) {
int n = downloadSize / xferRate; // estimated time for entire d/l in secs
// We do it in K (/1024) because we'd overflow around 4MB
n = (n - (((downloadCount/1024) * n) / (downloadSize/1024))) * 1000;
UI_PrintTime ( dlTimeBuf, sizeof dlTimeBuf, n ); // bk010104
//(n - (((downloadCount/1024) * n) / (downloadSize/1024))) * 1000);
UI_DrawProportionalString( leftWidth, 160,
dlTimeBuf, style, color_white );
UI_DrawProportionalString( leftWidth, 192,
va("(%s of %s copied)", dlSizeBuf, totalSizeBuf), style, color_white );
} else {
UI_DrawProportionalString( leftWidth, 160,
"estimating", style, color_white );
if (downloadSize) {
UI_DrawProportionalString( leftWidth, 192,
va("(%s of %s copied)", dlSizeBuf, totalSizeBuf), style, color_white );
} else {
UI_DrawProportionalString( leftWidth, 192,
va("(%s copied)", dlSizeBuf), style, color_white );
}
}
if (xferRate) {
UI_DrawProportionalString( leftWidth, 224,
va("%s/Sec", xferRateBuf), style, color_white );
}
}
}
/*
========================
UI_DrawConnectScreen
This will also be overlaid on the cgame info screen during loading
to prevent it from blinking away too rapidly on local or lan games.
========================
*/
void UI_DrawConnectScreen( qboolean overlay ) {
char *s;
uiClientState_t cstate;
char info[MAX_INFO_VALUE];
Menu_Cache();
if ( !overlay ) {
// draw the dialog background
UI_SetColor( color_white );
UI_DrawHandlePic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, uis.menuBackShader );
}
// see what information we should display
trap_GetClientState( &cstate );
info[0] = '\0';
if( trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) ) ) {
UI_DrawProportionalString( 320, 16, va( "Loading %s", Info_ValueForKey( info, "mapname" ) ), UI_BIGFONT|UI_CENTER|UI_DROPSHADOW, color_white );
}
UI_DrawProportionalString( 320, 64, va("Connecting to %s", cstate.servername), UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
//UI_DrawProportionalString( 320, 96, "Press Esc to abort", UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
// display global MOTD at bottom
UI_DrawProportionalString( SCREEN_WIDTH/2, SCREEN_HEIGHT-32,
Info_ValueForKey( cstate.updateInfoString, "motd" ), UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
// print any server info (server full, bad version, etc)
if ( cstate.connState < CA_CONNECTED ) {
UI_DrawProportionalString_AutoWrapped( 320, 192, 630, 20, cstate.messageString, UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
}
#if 0
// display password field
if ( passwordNeeded ) {
s_ingame_menu.x = SCREEN_WIDTH * 0.50 - 128;
s_ingame_menu.nitems = 0;
s_ingame_menu.wrapAround = qtrue;
passwordField.generic.type = MTYPE_FIELD;
passwordField.generic.name = "Password:";
passwordField.generic.callback = 0;
passwordField.generic.x = 10;
passwordField.generic.y = 180;
Field_Clear( &passwordField.field );
passwordField.width = 256;
passwordField.field.widthInChars = 16;
Q_strncpyz( passwordField.field.buffer, Cvar_VariableString("password"),
sizeof(passwordField.field.buffer) );
Menu_AddItem( &s_ingame_menu, ( void * ) &s_customize_player_action );
MField_Draw( &passwordField );
}
#endif
if ( lastConnState > cstate.connState ) {
lastLoadingText[0] = '\0';
}
lastConnState = cstate.connState;
switch ( cstate.connState ) {
case CA_CONNECTING:
s = va("Awaiting challenge...%i", cstate.connectPacketCount);
break;
case CA_CHALLENGING:
s = va("Awaiting connection...%i", cstate.connectPacketCount);
break;
case CA_CONNECTED: {
char downloadName[MAX_INFO_VALUE];
trap_Cvar_VariableStringBuffer( "cl_downloadName", downloadName, sizeof(downloadName) );
if (*downloadName) {
UI_DisplayDownloadInfo( downloadName );
return;
}
}
s = "Awaiting gamestate...";
break;
case CA_LOADING:
return;
case CA_PRIMED:
return;
default:
return;
}
UI_DrawProportionalString( 320, 128, s, UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, color_white );
// password required / connection rejected information goes here
}
/*
===================
UI_KeyConnect
===================
*/
void UI_KeyConnect( int key ) {
if ( key == K_ESCAPE ) {
trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect\n" );
return;
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,129 +1,129 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
CREDITS
=======================================================================
*/
#include "ui_local.h"
typedef struct {
menuframework_s menu;
} creditsmenu_t;
static creditsmenu_t s_credits;
/*
=================
UI_CreditMenu_Key
=================
*/
static sfxHandle_t UI_CreditMenu_Key( int key ) {
if( key & K_CHAR_FLAG ) {
return 0;
}
trap_Cmd_ExecuteText( EXEC_APPEND, "quit\n" );
return 0;
}
/*
===============
UI_CreditMenu_Draw
===============
*/
static void UI_CreditMenu_Draw( void ) {
int y;
y = 12;
UI_DrawProportionalString( 320, y, "id Software is:", UI_CENTER|UI_SMALLFONT, color_white );
y += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Programming", UI_CENTER|UI_SMALLFONT, color_white );
y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "John Carmack, Robert A. Duffy, Jim Dose'", UI_CENTER|UI_SMALLFONT, color_white );
y += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Art", UI_CENTER|UI_SMALLFONT, color_white );
y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Adrian Carmack, Kevin Cloud,", UI_CENTER|UI_SMALLFONT, color_white );
y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Kenneth Scott, Seneca Menard, Fred Nilsson", UI_CENTER|UI_SMALLFONT, color_white );
y += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Game Designer", UI_CENTER|UI_SMALLFONT, color_white );
y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Graeme Devine", UI_CENTER|UI_SMALLFONT, color_white );
y += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Level Design", UI_CENTER|UI_SMALLFONT, color_white );
y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Tim Willits, Christian Antkow, Paul Jaquays", UI_CENTER|UI_SMALLFONT, color_white );
y += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "CEO", UI_CENTER|UI_SMALLFONT, color_white );
y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Todd Hollenshead", UI_CENTER|UI_SMALLFONT, color_white );
y += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Director of Business Development", UI_CENTER|UI_SMALLFONT, color_white );
y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Marty Stratton", UI_CENTER|UI_SMALLFONT, color_white );
y += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Biz Assist and id Mom", UI_CENTER|UI_SMALLFONT, color_white );
y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Donna Jackson", UI_CENTER|UI_SMALLFONT, color_white );
y += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Development Assistance", UI_CENTER|UI_SMALLFONT, color_white );
y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Eric Webb", UI_CENTER|UI_SMALLFONT, color_white );
y += 1.35 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawString( 320, y, "To order: 1-800-idgames www.quake3arena.com www.idsoftware.com", UI_CENTER|UI_SMALLFONT, color_red );
y += SMALLCHAR_HEIGHT;
UI_DrawString( 320, y, "Quake III Arena(c) 1999-2000, Id Software, Inc. All Rights Reserved", UI_CENTER|UI_SMALLFONT, color_red );
}
/*
===============
UI_CreditMenu
===============
*/
void UI_CreditMenu( void ) {
memset( &s_credits, 0 ,sizeof(s_credits) );
s_credits.menu.draw = UI_CreditMenu_Draw;
s_credits.menu.key = UI_CreditMenu_Key;
s_credits.menu.fullscreen = qtrue;
UI_PushMenu ( &s_credits.menu );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
CREDITS
=======================================================================
*/
#include "ui_local.h"
typedef struct {
menuframework_s menu;
} creditsmenu_t;
static creditsmenu_t s_credits;
/*
=================
UI_CreditMenu_Key
=================
*/
static sfxHandle_t UI_CreditMenu_Key( int key ) {
if( key & K_CHAR_FLAG ) {
return 0;
}
trap_Cmd_ExecuteText( EXEC_APPEND, "quit\n" );
return 0;
}
/*
===============
UI_CreditMenu_Draw
===============
*/
static void UI_CreditMenu_Draw( void ) {
int y;
y = 12;
UI_DrawProportionalString( 320, y, "id Software is:", UI_CENTER|UI_SMALLFONT, color_white );
y += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Programming", UI_CENTER|UI_SMALLFONT, color_white );
y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "John Carmack, Robert A. Duffy, Jim Dose'", UI_CENTER|UI_SMALLFONT, color_white );
y += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Art", UI_CENTER|UI_SMALLFONT, color_white );
y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Adrian Carmack, Kevin Cloud,", UI_CENTER|UI_SMALLFONT, color_white );
y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Kenneth Scott, Seneca Menard, Fred Nilsson", UI_CENTER|UI_SMALLFONT, color_white );
y += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Game Designer", UI_CENTER|UI_SMALLFONT, color_white );
y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Graeme Devine", UI_CENTER|UI_SMALLFONT, color_white );
y += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Level Design", UI_CENTER|UI_SMALLFONT, color_white );
y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Tim Willits, Christian Antkow, Paul Jaquays", UI_CENTER|UI_SMALLFONT, color_white );
y += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "CEO", UI_CENTER|UI_SMALLFONT, color_white );
y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Todd Hollenshead", UI_CENTER|UI_SMALLFONT, color_white );
y += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Director of Business Development", UI_CENTER|UI_SMALLFONT, color_white );
y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Marty Stratton", UI_CENTER|UI_SMALLFONT, color_white );
y += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Biz Assist and id Mom", UI_CENTER|UI_SMALLFONT, color_white );
y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Donna Jackson", UI_CENTER|UI_SMALLFONT, color_white );
y += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Development Assistance", UI_CENTER|UI_SMALLFONT, color_white );
y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawProportionalString( 320, y, "Eric Webb", UI_CENTER|UI_SMALLFONT, color_white );
y += 1.35 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;
UI_DrawString( 320, y, "To order: 1-800-idgames www.quake3arena.com www.idsoftware.com", UI_CENTER|UI_SMALLFONT, color_red );
y += SMALLCHAR_HEIGHT;
UI_DrawString( 320, y, "Quake III Arena(c) 1999-2000, Id Software, Inc. All Rights Reserved", UI_CENTER|UI_SMALLFONT, color_red );
}
/*
===============
UI_CreditMenu
===============
*/
void UI_CreditMenu( void ) {
memset( &s_credits, 0 ,sizeof(s_credits) );
s_credits.menu.draw = UI_CreditMenu_Draw;
s_credits.menu.key = UI_CreditMenu_Key;
s_credits.menu.fullscreen = qtrue;
UI_PushMenu ( &s_credits.menu );
}

View file

@ -1,291 +1,291 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
DEMOS MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ART_GO0 "menu/art/play_0"
#define ART_GO1 "menu/art/play_1"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define ART_ARROWS "menu/art/arrows_horz_0"
#define ART_ARROWLEFT "menu/art/arrows_horz_left"
#define ART_ARROWRIGHT "menu/art/arrows_horz_right"
#define MAX_DEMOS 128
#define NAMEBUFSIZE ( MAX_DEMOS * 16 )
#define ID_BACK 10
#define ID_GO 11
#define ID_LIST 12
#define ID_RIGHT 13
#define ID_LEFT 14
#define ARROWS_WIDTH 128
#define ARROWS_HEIGHT 48
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menulist_s list;
menubitmap_s arrows;
menubitmap_s left;
menubitmap_s right;
menubitmap_s back;
menubitmap_s go;
int numDemos;
char names[NAMEBUFSIZE];
char *demolist[MAX_DEMOS];
} demos_t;
static demos_t s_demos;
/*
===============
Demos_MenuEvent
===============
*/
static void Demos_MenuEvent( void *ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_GO:
UI_ForceMenuOff ();
trap_Cmd_ExecuteText( EXEC_APPEND, va( "demo %s\n",
s_demos.list.itemnames[s_demos.list.curvalue]) );
break;
case ID_BACK:
UI_PopMenu();
break;
case ID_LEFT:
ScrollList_Key( &s_demos.list, K_LEFTARROW );
break;
case ID_RIGHT:
ScrollList_Key( &s_demos.list, K_RIGHTARROW );
break;
}
}
/*
=================
UI_DemosMenu_Key
=================
*/
static sfxHandle_t UI_DemosMenu_Key( int key ) {
menucommon_s *item;
item = Menu_ItemAtCursor( &s_demos.menu );
return Menu_DefaultKey( &s_demos.menu, key );
}
/*
===============
Demos_MenuInit
===============
*/
static void Demos_MenuInit( void ) {
int i;
int len;
char *demoname, extension[32];
memset( &s_demos, 0 ,sizeof(demos_t) );
s_demos.menu.key = UI_DemosMenu_Key;
Demos_Cache();
s_demos.menu.fullscreen = qtrue;
s_demos.menu.wrapAround = qtrue;
s_demos.banner.generic.type = MTYPE_BTEXT;
s_demos.banner.generic.x = 320;
s_demos.banner.generic.y = 16;
s_demos.banner.string = "DEMOS";
s_demos.banner.color = color_white;
s_demos.banner.style = UI_CENTER;
s_demos.framel.generic.type = MTYPE_BITMAP;
s_demos.framel.generic.name = ART_FRAMEL;
s_demos.framel.generic.flags = QMF_INACTIVE;
s_demos.framel.generic.x = 0;
s_demos.framel.generic.y = 78;
s_demos.framel.width = 256;
s_demos.framel.height = 329;
s_demos.framer.generic.type = MTYPE_BITMAP;
s_demos.framer.generic.name = ART_FRAMER;
s_demos.framer.generic.flags = QMF_INACTIVE;
s_demos.framer.generic.x = 376;
s_demos.framer.generic.y = 76;
s_demos.framer.width = 256;
s_demos.framer.height = 334;
s_demos.arrows.generic.type = MTYPE_BITMAP;
s_demos.arrows.generic.name = ART_ARROWS;
s_demos.arrows.generic.flags = QMF_INACTIVE;
s_demos.arrows.generic.x = 320-ARROWS_WIDTH/2;
s_demos.arrows.generic.y = 400;
s_demos.arrows.width = ARROWS_WIDTH;
s_demos.arrows.height = ARROWS_HEIGHT;
s_demos.left.generic.type = MTYPE_BITMAP;
s_demos.left.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;
s_demos.left.generic.x = 320-ARROWS_WIDTH/2;
s_demos.left.generic.y = 400;
s_demos.left.generic.id = ID_LEFT;
s_demos.left.generic.callback = Demos_MenuEvent;
s_demos.left.width = ARROWS_WIDTH/2;
s_demos.left.height = ARROWS_HEIGHT;
s_demos.left.focuspic = ART_ARROWLEFT;
s_demos.right.generic.type = MTYPE_BITMAP;
s_demos.right.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;
s_demos.right.generic.x = 320;
s_demos.right.generic.y = 400;
s_demos.right.generic.id = ID_RIGHT;
s_demos.right.generic.callback = Demos_MenuEvent;
s_demos.right.width = ARROWS_WIDTH/2;
s_demos.right.height = ARROWS_HEIGHT;
s_demos.right.focuspic = ART_ARROWRIGHT;
s_demos.back.generic.type = MTYPE_BITMAP;
s_demos.back.generic.name = ART_BACK0;
s_demos.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_demos.back.generic.id = ID_BACK;
s_demos.back.generic.callback = Demos_MenuEvent;
s_demos.back.generic.x = 0;
s_demos.back.generic.y = 480-64;
s_demos.back.width = 128;
s_demos.back.height = 64;
s_demos.back.focuspic = ART_BACK1;
s_demos.go.generic.type = MTYPE_BITMAP;
s_demos.go.generic.name = ART_GO0;
s_demos.go.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
s_demos.go.generic.id = ID_GO;
s_demos.go.generic.callback = Demos_MenuEvent;
s_demos.go.generic.x = 640;
s_demos.go.generic.y = 480-64;
s_demos.go.width = 128;
s_demos.go.height = 64;
s_demos.go.focuspic = ART_GO1;
s_demos.list.generic.type = MTYPE_SCROLLLIST;
s_demos.list.generic.flags = QMF_PULSEIFFOCUS;
s_demos.list.generic.callback = Demos_MenuEvent;
s_demos.list.generic.id = ID_LIST;
s_demos.list.generic.x = 118;
s_demos.list.generic.y = 130;
s_demos.list.width = 16;
s_demos.list.height = 14;
Com_sprintf(extension, sizeof(extension), "dm_%d", (int)trap_Cvar_VariableValue( "protocol" ) );
s_demos.list.numitems = trap_FS_GetFileList( "demos", extension, s_demos.names, NAMEBUFSIZE );
s_demos.list.itemnames = (const char **)s_demos.demolist;
s_demos.list.columns = 3;
if (!s_demos.list.numitems) {
strcpy( s_demos.names, "No Demos Found." );
s_demos.list.numitems = 1;
//degenerate case, not selectable
s_demos.go.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);
}
else if (s_demos.list.numitems > MAX_DEMOS)
s_demos.list.numitems = MAX_DEMOS;
demoname = s_demos.names;
for ( i = 0; i < s_demos.list.numitems; i++ ) {
s_demos.list.itemnames[i] = demoname;
// strip extension
len = strlen( demoname );
if (!Q_stricmp(demoname + len - 4,".dm3"))
demoname[len-4] = '\0';
Q_strupr(demoname);
demoname += len + 1;
}
Menu_AddItem( &s_demos.menu, &s_demos.banner );
Menu_AddItem( &s_demos.menu, &s_demos.framel );
Menu_AddItem( &s_demos.menu, &s_demos.framer );
Menu_AddItem( &s_demos.menu, &s_demos.list );
Menu_AddItem( &s_demos.menu, &s_demos.arrows );
Menu_AddItem( &s_demos.menu, &s_demos.left );
Menu_AddItem( &s_demos.menu, &s_demos.right );
Menu_AddItem( &s_demos.menu, &s_demos.back );
Menu_AddItem( &s_demos.menu, &s_demos.go );
}
/*
=================
Demos_Cache
=================
*/
void Demos_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
trap_R_RegisterShaderNoMip( ART_GO0 );
trap_R_RegisterShaderNoMip( ART_GO1 );
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
trap_R_RegisterShaderNoMip( ART_ARROWS );
trap_R_RegisterShaderNoMip( ART_ARROWLEFT );
trap_R_RegisterShaderNoMip( ART_ARROWRIGHT );
}
/*
===============
UI_DemosMenu
===============
*/
void UI_DemosMenu( void ) {
Demos_MenuInit();
UI_PushMenu( &s_demos.menu );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
DEMOS MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ART_GO0 "menu/art/play_0"
#define ART_GO1 "menu/art/play_1"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define ART_ARROWS "menu/art/arrows_horz_0"
#define ART_ARROWLEFT "menu/art/arrows_horz_left"
#define ART_ARROWRIGHT "menu/art/arrows_horz_right"
#define MAX_DEMOS 128
#define NAMEBUFSIZE ( MAX_DEMOS * 16 )
#define ID_BACK 10
#define ID_GO 11
#define ID_LIST 12
#define ID_RIGHT 13
#define ID_LEFT 14
#define ARROWS_WIDTH 128
#define ARROWS_HEIGHT 48
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menulist_s list;
menubitmap_s arrows;
menubitmap_s left;
menubitmap_s right;
menubitmap_s back;
menubitmap_s go;
int numDemos;
char names[NAMEBUFSIZE];
char *demolist[MAX_DEMOS];
} demos_t;
static demos_t s_demos;
/*
===============
Demos_MenuEvent
===============
*/
static void Demos_MenuEvent( void *ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_GO:
UI_ForceMenuOff ();
trap_Cmd_ExecuteText( EXEC_APPEND, va( "demo %s\n",
s_demos.list.itemnames[s_demos.list.curvalue]) );
break;
case ID_BACK:
UI_PopMenu();
break;
case ID_LEFT:
ScrollList_Key( &s_demos.list, K_LEFTARROW );
break;
case ID_RIGHT:
ScrollList_Key( &s_demos.list, K_RIGHTARROW );
break;
}
}
/*
=================
UI_DemosMenu_Key
=================
*/
static sfxHandle_t UI_DemosMenu_Key( int key ) {
menucommon_s *item;
item = Menu_ItemAtCursor( &s_demos.menu );
return Menu_DefaultKey( &s_demos.menu, key );
}
/*
===============
Demos_MenuInit
===============
*/
static void Demos_MenuInit( void ) {
int i;
int len;
char *demoname, extension[32];
memset( &s_demos, 0 ,sizeof(demos_t) );
s_demos.menu.key = UI_DemosMenu_Key;
Demos_Cache();
s_demos.menu.fullscreen = qtrue;
s_demos.menu.wrapAround = qtrue;
s_demos.banner.generic.type = MTYPE_BTEXT;
s_demos.banner.generic.x = 320;
s_demos.banner.generic.y = 16;
s_demos.banner.string = "DEMOS";
s_demos.banner.color = color_white;
s_demos.banner.style = UI_CENTER;
s_demos.framel.generic.type = MTYPE_BITMAP;
s_demos.framel.generic.name = ART_FRAMEL;
s_demos.framel.generic.flags = QMF_INACTIVE;
s_demos.framel.generic.x = 0;
s_demos.framel.generic.y = 78;
s_demos.framel.width = 256;
s_demos.framel.height = 329;
s_demos.framer.generic.type = MTYPE_BITMAP;
s_demos.framer.generic.name = ART_FRAMER;
s_demos.framer.generic.flags = QMF_INACTIVE;
s_demos.framer.generic.x = 376;
s_demos.framer.generic.y = 76;
s_demos.framer.width = 256;
s_demos.framer.height = 334;
s_demos.arrows.generic.type = MTYPE_BITMAP;
s_demos.arrows.generic.name = ART_ARROWS;
s_demos.arrows.generic.flags = QMF_INACTIVE;
s_demos.arrows.generic.x = 320-ARROWS_WIDTH/2;
s_demos.arrows.generic.y = 400;
s_demos.arrows.width = ARROWS_WIDTH;
s_demos.arrows.height = ARROWS_HEIGHT;
s_demos.left.generic.type = MTYPE_BITMAP;
s_demos.left.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;
s_demos.left.generic.x = 320-ARROWS_WIDTH/2;
s_demos.left.generic.y = 400;
s_demos.left.generic.id = ID_LEFT;
s_demos.left.generic.callback = Demos_MenuEvent;
s_demos.left.width = ARROWS_WIDTH/2;
s_demos.left.height = ARROWS_HEIGHT;
s_demos.left.focuspic = ART_ARROWLEFT;
s_demos.right.generic.type = MTYPE_BITMAP;
s_demos.right.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;
s_demos.right.generic.x = 320;
s_demos.right.generic.y = 400;
s_demos.right.generic.id = ID_RIGHT;
s_demos.right.generic.callback = Demos_MenuEvent;
s_demos.right.width = ARROWS_WIDTH/2;
s_demos.right.height = ARROWS_HEIGHT;
s_demos.right.focuspic = ART_ARROWRIGHT;
s_demos.back.generic.type = MTYPE_BITMAP;
s_demos.back.generic.name = ART_BACK0;
s_demos.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_demos.back.generic.id = ID_BACK;
s_demos.back.generic.callback = Demos_MenuEvent;
s_demos.back.generic.x = 0;
s_demos.back.generic.y = 480-64;
s_demos.back.width = 128;
s_demos.back.height = 64;
s_demos.back.focuspic = ART_BACK1;
s_demos.go.generic.type = MTYPE_BITMAP;
s_demos.go.generic.name = ART_GO0;
s_demos.go.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
s_demos.go.generic.id = ID_GO;
s_demos.go.generic.callback = Demos_MenuEvent;
s_demos.go.generic.x = 640;
s_demos.go.generic.y = 480-64;
s_demos.go.width = 128;
s_demos.go.height = 64;
s_demos.go.focuspic = ART_GO1;
s_demos.list.generic.type = MTYPE_SCROLLLIST;
s_demos.list.generic.flags = QMF_PULSEIFFOCUS;
s_demos.list.generic.callback = Demos_MenuEvent;
s_demos.list.generic.id = ID_LIST;
s_demos.list.generic.x = 118;
s_demos.list.generic.y = 130;
s_demos.list.width = 16;
s_demos.list.height = 14;
Com_sprintf(extension, sizeof(extension), "dm_%d", (int)trap_Cvar_VariableValue( "protocol" ) );
s_demos.list.numitems = trap_FS_GetFileList( "demos", extension, s_demos.names, NAMEBUFSIZE );
s_demos.list.itemnames = (const char **)s_demos.demolist;
s_demos.list.columns = 3;
if (!s_demos.list.numitems) {
strcpy( s_demos.names, "No Demos Found." );
s_demos.list.numitems = 1;
//degenerate case, not selectable
s_demos.go.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);
}
else if (s_demos.list.numitems > MAX_DEMOS)
s_demos.list.numitems = MAX_DEMOS;
demoname = s_demos.names;
for ( i = 0; i < s_demos.list.numitems; i++ ) {
s_demos.list.itemnames[i] = demoname;
// strip extension
len = strlen( demoname );
if (!Q_stricmp(demoname + len - 4,".dm3"))
demoname[len-4] = '\0';
Q_strupr(demoname);
demoname += len + 1;
}
Menu_AddItem( &s_demos.menu, &s_demos.banner );
Menu_AddItem( &s_demos.menu, &s_demos.framel );
Menu_AddItem( &s_demos.menu, &s_demos.framer );
Menu_AddItem( &s_demos.menu, &s_demos.list );
Menu_AddItem( &s_demos.menu, &s_demos.arrows );
Menu_AddItem( &s_demos.menu, &s_demos.left );
Menu_AddItem( &s_demos.menu, &s_demos.right );
Menu_AddItem( &s_demos.menu, &s_demos.back );
Menu_AddItem( &s_demos.menu, &s_demos.go );
}
/*
=================
Demos_Cache
=================
*/
void Demos_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
trap_R_RegisterShaderNoMip( ART_GO0 );
trap_R_RegisterShaderNoMip( ART_GO1 );
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
trap_R_RegisterShaderNoMip( ART_ARROWS );
trap_R_RegisterShaderNoMip( ART_ARROWLEFT );
trap_R_RegisterShaderNoMip( ART_ARROWRIGHT );
}
/*
===============
UI_DemosMenu
===============
*/
void UI_DemosMenu( void ) {
Demos_MenuInit();
UI_PushMenu( &s_demos.menu );
}

View file

@ -1,265 +1,265 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
DISPLAY OPTIONS MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ID_GRAPHICS 10
#define ID_DISPLAY 11
#define ID_SOUND 12
#define ID_NETWORK 13
#define ID_BRIGHTNESS 14
#define ID_SCREENSIZE 15
#define ID_BACK 16
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menutext_s graphics;
menutext_s display;
menutext_s sound;
menutext_s network;
menuslider_s brightness;
menuslider_s screensize;
menubitmap_s back;
} displayOptionsInfo_t;
static displayOptionsInfo_t displayOptionsInfo;
/*
=================
UI_DisplayOptionsMenu_Event
=================
*/
static void UI_DisplayOptionsMenu_Event( void* ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_GRAPHICS:
UI_PopMenu();
UI_GraphicsOptionsMenu();
break;
case ID_DISPLAY:
break;
case ID_SOUND:
UI_PopMenu();
UI_SoundOptionsMenu();
break;
case ID_NETWORK:
UI_PopMenu();
UI_NetworkOptionsMenu();
break;
case ID_BRIGHTNESS:
trap_Cvar_SetValue( "r_gamma", displayOptionsInfo.brightness.curvalue / 10.0f );
break;
case ID_SCREENSIZE:
trap_Cvar_SetValue( "cg_viewsize", displayOptionsInfo.screensize.curvalue * 10 );
break;
case ID_BACK:
UI_PopMenu();
break;
}
}
/*
===============
UI_DisplayOptionsMenu_Init
===============
*/
static void UI_DisplayOptionsMenu_Init( void ) {
int y;
memset( &displayOptionsInfo, 0, sizeof(displayOptionsInfo) );
UI_DisplayOptionsMenu_Cache();
displayOptionsInfo.menu.wrapAround = qtrue;
displayOptionsInfo.menu.fullscreen = qtrue;
displayOptionsInfo.banner.generic.type = MTYPE_BTEXT;
displayOptionsInfo.banner.generic.flags = QMF_CENTER_JUSTIFY;
displayOptionsInfo.banner.generic.x = 320;
displayOptionsInfo.banner.generic.y = 16;
displayOptionsInfo.banner.string = "SYSTEM SETUP";
displayOptionsInfo.banner.color = color_white;
displayOptionsInfo.banner.style = UI_CENTER;
displayOptionsInfo.framel.generic.type = MTYPE_BITMAP;
displayOptionsInfo.framel.generic.name = ART_FRAMEL;
displayOptionsInfo.framel.generic.flags = QMF_INACTIVE;
displayOptionsInfo.framel.generic.x = 0;
displayOptionsInfo.framel.generic.y = 78;
displayOptionsInfo.framel.width = 256;
displayOptionsInfo.framel.height = 329;
displayOptionsInfo.framer.generic.type = MTYPE_BITMAP;
displayOptionsInfo.framer.generic.name = ART_FRAMER;
displayOptionsInfo.framer.generic.flags = QMF_INACTIVE;
displayOptionsInfo.framer.generic.x = 376;
displayOptionsInfo.framer.generic.y = 76;
displayOptionsInfo.framer.width = 256;
displayOptionsInfo.framer.height = 334;
displayOptionsInfo.graphics.generic.type = MTYPE_PTEXT;
displayOptionsInfo.graphics.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
displayOptionsInfo.graphics.generic.id = ID_GRAPHICS;
displayOptionsInfo.graphics.generic.callback = UI_DisplayOptionsMenu_Event;
displayOptionsInfo.graphics.generic.x = 216;
displayOptionsInfo.graphics.generic.y = 240 - 2 * PROP_HEIGHT;
displayOptionsInfo.graphics.string = "GRAPHICS";
displayOptionsInfo.graphics.style = UI_RIGHT;
displayOptionsInfo.graphics.color = color_red;
displayOptionsInfo.display.generic.type = MTYPE_PTEXT;
displayOptionsInfo.display.generic.flags = QMF_RIGHT_JUSTIFY;
displayOptionsInfo.display.generic.id = ID_DISPLAY;
displayOptionsInfo.display.generic.callback = UI_DisplayOptionsMenu_Event;
displayOptionsInfo.display.generic.x = 216;
displayOptionsInfo.display.generic.y = 240 - PROP_HEIGHT;
displayOptionsInfo.display.string = "DISPLAY";
displayOptionsInfo.display.style = UI_RIGHT;
displayOptionsInfo.display.color = color_red;
displayOptionsInfo.sound.generic.type = MTYPE_PTEXT;
displayOptionsInfo.sound.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
displayOptionsInfo.sound.generic.id = ID_SOUND;
displayOptionsInfo.sound.generic.callback = UI_DisplayOptionsMenu_Event;
displayOptionsInfo.sound.generic.x = 216;
displayOptionsInfo.sound.generic.y = 240;
displayOptionsInfo.sound.string = "SOUND";
displayOptionsInfo.sound.style = UI_RIGHT;
displayOptionsInfo.sound.color = color_red;
displayOptionsInfo.network.generic.type = MTYPE_PTEXT;
displayOptionsInfo.network.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
displayOptionsInfo.network.generic.id = ID_NETWORK;
displayOptionsInfo.network.generic.callback = UI_DisplayOptionsMenu_Event;
displayOptionsInfo.network.generic.x = 216;
displayOptionsInfo.network.generic.y = 240 + PROP_HEIGHT;
displayOptionsInfo.network.string = "NETWORK";
displayOptionsInfo.network.style = UI_RIGHT;
displayOptionsInfo.network.color = color_red;
y = 240 - 1 * (BIGCHAR_HEIGHT+2);
displayOptionsInfo.brightness.generic.type = MTYPE_SLIDER;
displayOptionsInfo.brightness.generic.name = "Brightness:";
displayOptionsInfo.brightness.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
displayOptionsInfo.brightness.generic.callback = UI_DisplayOptionsMenu_Event;
displayOptionsInfo.brightness.generic.id = ID_BRIGHTNESS;
displayOptionsInfo.brightness.generic.x = 400;
displayOptionsInfo.brightness.generic.y = y;
displayOptionsInfo.brightness.minvalue = 5;
displayOptionsInfo.brightness.maxvalue = 20;
if( !uis.glconfig.deviceSupportsGamma ) {
displayOptionsInfo.brightness.generic.flags |= QMF_GRAYED;
}
y += BIGCHAR_HEIGHT+2;
displayOptionsInfo.screensize.generic.type = MTYPE_SLIDER;
displayOptionsInfo.screensize.generic.name = "Screen Size:";
displayOptionsInfo.screensize.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
displayOptionsInfo.screensize.generic.callback = UI_DisplayOptionsMenu_Event;
displayOptionsInfo.screensize.generic.id = ID_SCREENSIZE;
displayOptionsInfo.screensize.generic.x = 400;
displayOptionsInfo.screensize.generic.y = y;
displayOptionsInfo.screensize.minvalue = 3;
displayOptionsInfo.screensize.maxvalue = 10;
displayOptionsInfo.back.generic.type = MTYPE_BITMAP;
displayOptionsInfo.back.generic.name = ART_BACK0;
displayOptionsInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
displayOptionsInfo.back.generic.callback = UI_DisplayOptionsMenu_Event;
displayOptionsInfo.back.generic.id = ID_BACK;
displayOptionsInfo.back.generic.x = 0;
displayOptionsInfo.back.generic.y = 480-64;
displayOptionsInfo.back.width = 128;
displayOptionsInfo.back.height = 64;
displayOptionsInfo.back.focuspic = ART_BACK1;
Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.banner );
Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.framel );
Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.framer );
Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.graphics );
Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.display );
Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.sound );
Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.network );
Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.brightness );
Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.screensize );
Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.back );
displayOptionsInfo.brightness.curvalue = trap_Cvar_VariableValue("r_gamma") * 10;
displayOptionsInfo.screensize.curvalue = trap_Cvar_VariableValue( "cg_viewsize")/10;
}
/*
===============
UI_DisplayOptionsMenu_Cache
===============
*/
void UI_DisplayOptionsMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
}
/*
===============
UI_DisplayOptionsMenu
===============
*/
void UI_DisplayOptionsMenu( void ) {
UI_DisplayOptionsMenu_Init();
UI_PushMenu( &displayOptionsInfo.menu );
Menu_SetCursorToItem( &displayOptionsInfo.menu, &displayOptionsInfo.display );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
DISPLAY OPTIONS MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ID_GRAPHICS 10
#define ID_DISPLAY 11
#define ID_SOUND 12
#define ID_NETWORK 13
#define ID_BRIGHTNESS 14
#define ID_SCREENSIZE 15
#define ID_BACK 16
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menutext_s graphics;
menutext_s display;
menutext_s sound;
menutext_s network;
menuslider_s brightness;
menuslider_s screensize;
menubitmap_s back;
} displayOptionsInfo_t;
static displayOptionsInfo_t displayOptionsInfo;
/*
=================
UI_DisplayOptionsMenu_Event
=================
*/
static void UI_DisplayOptionsMenu_Event( void* ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_GRAPHICS:
UI_PopMenu();
UI_GraphicsOptionsMenu();
break;
case ID_DISPLAY:
break;
case ID_SOUND:
UI_PopMenu();
UI_SoundOptionsMenu();
break;
case ID_NETWORK:
UI_PopMenu();
UI_NetworkOptionsMenu();
break;
case ID_BRIGHTNESS:
trap_Cvar_SetValue( "r_gamma", displayOptionsInfo.brightness.curvalue / 10.0f );
break;
case ID_SCREENSIZE:
trap_Cvar_SetValue( "cg_viewsize", displayOptionsInfo.screensize.curvalue * 10 );
break;
case ID_BACK:
UI_PopMenu();
break;
}
}
/*
===============
UI_DisplayOptionsMenu_Init
===============
*/
static void UI_DisplayOptionsMenu_Init( void ) {
int y;
memset( &displayOptionsInfo, 0, sizeof(displayOptionsInfo) );
UI_DisplayOptionsMenu_Cache();
displayOptionsInfo.menu.wrapAround = qtrue;
displayOptionsInfo.menu.fullscreen = qtrue;
displayOptionsInfo.banner.generic.type = MTYPE_BTEXT;
displayOptionsInfo.banner.generic.flags = QMF_CENTER_JUSTIFY;
displayOptionsInfo.banner.generic.x = 320;
displayOptionsInfo.banner.generic.y = 16;
displayOptionsInfo.banner.string = "SYSTEM SETUP";
displayOptionsInfo.banner.color = color_white;
displayOptionsInfo.banner.style = UI_CENTER;
displayOptionsInfo.framel.generic.type = MTYPE_BITMAP;
displayOptionsInfo.framel.generic.name = ART_FRAMEL;
displayOptionsInfo.framel.generic.flags = QMF_INACTIVE;
displayOptionsInfo.framel.generic.x = 0;
displayOptionsInfo.framel.generic.y = 78;
displayOptionsInfo.framel.width = 256;
displayOptionsInfo.framel.height = 329;
displayOptionsInfo.framer.generic.type = MTYPE_BITMAP;
displayOptionsInfo.framer.generic.name = ART_FRAMER;
displayOptionsInfo.framer.generic.flags = QMF_INACTIVE;
displayOptionsInfo.framer.generic.x = 376;
displayOptionsInfo.framer.generic.y = 76;
displayOptionsInfo.framer.width = 256;
displayOptionsInfo.framer.height = 334;
displayOptionsInfo.graphics.generic.type = MTYPE_PTEXT;
displayOptionsInfo.graphics.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
displayOptionsInfo.graphics.generic.id = ID_GRAPHICS;
displayOptionsInfo.graphics.generic.callback = UI_DisplayOptionsMenu_Event;
displayOptionsInfo.graphics.generic.x = 216;
displayOptionsInfo.graphics.generic.y = 240 - 2 * PROP_HEIGHT;
displayOptionsInfo.graphics.string = "GRAPHICS";
displayOptionsInfo.graphics.style = UI_RIGHT;
displayOptionsInfo.graphics.color = color_red;
displayOptionsInfo.display.generic.type = MTYPE_PTEXT;
displayOptionsInfo.display.generic.flags = QMF_RIGHT_JUSTIFY;
displayOptionsInfo.display.generic.id = ID_DISPLAY;
displayOptionsInfo.display.generic.callback = UI_DisplayOptionsMenu_Event;
displayOptionsInfo.display.generic.x = 216;
displayOptionsInfo.display.generic.y = 240 - PROP_HEIGHT;
displayOptionsInfo.display.string = "DISPLAY";
displayOptionsInfo.display.style = UI_RIGHT;
displayOptionsInfo.display.color = color_red;
displayOptionsInfo.sound.generic.type = MTYPE_PTEXT;
displayOptionsInfo.sound.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
displayOptionsInfo.sound.generic.id = ID_SOUND;
displayOptionsInfo.sound.generic.callback = UI_DisplayOptionsMenu_Event;
displayOptionsInfo.sound.generic.x = 216;
displayOptionsInfo.sound.generic.y = 240;
displayOptionsInfo.sound.string = "SOUND";
displayOptionsInfo.sound.style = UI_RIGHT;
displayOptionsInfo.sound.color = color_red;
displayOptionsInfo.network.generic.type = MTYPE_PTEXT;
displayOptionsInfo.network.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
displayOptionsInfo.network.generic.id = ID_NETWORK;
displayOptionsInfo.network.generic.callback = UI_DisplayOptionsMenu_Event;
displayOptionsInfo.network.generic.x = 216;
displayOptionsInfo.network.generic.y = 240 + PROP_HEIGHT;
displayOptionsInfo.network.string = "NETWORK";
displayOptionsInfo.network.style = UI_RIGHT;
displayOptionsInfo.network.color = color_red;
y = 240 - 1 * (BIGCHAR_HEIGHT+2);
displayOptionsInfo.brightness.generic.type = MTYPE_SLIDER;
displayOptionsInfo.brightness.generic.name = "Brightness:";
displayOptionsInfo.brightness.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
displayOptionsInfo.brightness.generic.callback = UI_DisplayOptionsMenu_Event;
displayOptionsInfo.brightness.generic.id = ID_BRIGHTNESS;
displayOptionsInfo.brightness.generic.x = 400;
displayOptionsInfo.brightness.generic.y = y;
displayOptionsInfo.brightness.minvalue = 5;
displayOptionsInfo.brightness.maxvalue = 20;
if( !uis.glconfig.deviceSupportsGamma ) {
displayOptionsInfo.brightness.generic.flags |= QMF_GRAYED;
}
y += BIGCHAR_HEIGHT+2;
displayOptionsInfo.screensize.generic.type = MTYPE_SLIDER;
displayOptionsInfo.screensize.generic.name = "Screen Size:";
displayOptionsInfo.screensize.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
displayOptionsInfo.screensize.generic.callback = UI_DisplayOptionsMenu_Event;
displayOptionsInfo.screensize.generic.id = ID_SCREENSIZE;
displayOptionsInfo.screensize.generic.x = 400;
displayOptionsInfo.screensize.generic.y = y;
displayOptionsInfo.screensize.minvalue = 3;
displayOptionsInfo.screensize.maxvalue = 10;
displayOptionsInfo.back.generic.type = MTYPE_BITMAP;
displayOptionsInfo.back.generic.name = ART_BACK0;
displayOptionsInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
displayOptionsInfo.back.generic.callback = UI_DisplayOptionsMenu_Event;
displayOptionsInfo.back.generic.id = ID_BACK;
displayOptionsInfo.back.generic.x = 0;
displayOptionsInfo.back.generic.y = 480-64;
displayOptionsInfo.back.width = 128;
displayOptionsInfo.back.height = 64;
displayOptionsInfo.back.focuspic = ART_BACK1;
Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.banner );
Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.framel );
Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.framer );
Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.graphics );
Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.display );
Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.sound );
Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.network );
Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.brightness );
Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.screensize );
Menu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.back );
displayOptionsInfo.brightness.curvalue = trap_Cvar_VariableValue("r_gamma") * 10;
displayOptionsInfo.screensize.curvalue = trap_Cvar_VariableValue( "cg_viewsize")/10;
}
/*
===============
UI_DisplayOptionsMenu_Cache
===============
*/
void UI_DisplayOptionsMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
}
/*
===============
UI_DisplayOptionsMenu
===============
*/
void UI_DisplayOptionsMenu( void ) {
UI_DisplayOptionsMenu_Init();
UI_PushMenu( &displayOptionsInfo.menu );
Menu_SetCursorToItem( &displayOptionsInfo.menu, &displayOptionsInfo.display );
}

File diff suppressed because it is too large Load diff

View file

@ -1,349 +1,349 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
INGAME MENU
=======================================================================
*/
#include "ui_local.h"
#define INGAME_FRAME "menu/art/addbotframe"
//#define INGAME_FRAME "menu/art/cut_frame"
#define INGAME_MENU_VERTICAL_SPACING 28
#define ID_TEAM 10
#define ID_ADDBOTS 11
#define ID_REMOVEBOTS 12
#define ID_SETUP 13
#define ID_SERVERINFO 14
#define ID_LEAVEARENA 15
#define ID_RESTART 16
#define ID_QUIT 17
#define ID_RESUME 18
#define ID_TEAMORDERS 19
typedef struct {
menuframework_s menu;
menubitmap_s frame;
menutext_s team;
menutext_s setup;
menutext_s server;
menutext_s leave;
menutext_s restart;
menutext_s addbots;
menutext_s removebots;
menutext_s teamorders;
menutext_s quit;
menutext_s resume;
} ingamemenu_t;
static ingamemenu_t s_ingame;
/*
=================
InGame_RestartAction
=================
*/
static void InGame_RestartAction( qboolean result ) {
if( !result ) {
return;
}
UI_PopMenu();
trap_Cmd_ExecuteText( EXEC_APPEND, "map_restart 0\n" );
}
/*
=================
InGame_QuitAction
=================
*/
static void InGame_QuitAction( qboolean result ) {
if( !result ) {
return;
}
UI_PopMenu();
UI_CreditMenu();
}
/*
=================
InGame_Event
=================
*/
void InGame_Event( void *ptr, int notification ) {
if( notification != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_TEAM:
UI_TeamMainMenu();
break;
case ID_SETUP:
UI_SetupMenu();
break;
case ID_LEAVEARENA:
trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect\n" );
break;
case ID_RESTART:
UI_ConfirmMenu( "RESTART ARENA?", (voidfunc_f)NULL, InGame_RestartAction );
break;
case ID_QUIT:
UI_ConfirmMenu( "EXIT GAME?", (voidfunc_f)NULL, InGame_QuitAction );
break;
case ID_SERVERINFO:
UI_ServerInfoMenu();
break;
case ID_ADDBOTS:
UI_AddBotsMenu();
break;
case ID_REMOVEBOTS:
UI_RemoveBotsMenu();
break;
case ID_TEAMORDERS:
UI_TeamOrdersMenu();
break;
case ID_RESUME:
UI_PopMenu();
break;
}
}
/*
=================
InGame_MenuInit
=================
*/
void InGame_MenuInit( void ) {
int y;
uiClientState_t cs;
char info[MAX_INFO_STRING];
int team;
memset( &s_ingame, 0 ,sizeof(ingamemenu_t) );
InGame_Cache();
s_ingame.menu.wrapAround = qtrue;
s_ingame.menu.fullscreen = qfalse;
s_ingame.frame.generic.type = MTYPE_BITMAP;
s_ingame.frame.generic.flags = QMF_INACTIVE;
s_ingame.frame.generic.name = INGAME_FRAME;
s_ingame.frame.generic.x = 320-233;//142;
s_ingame.frame.generic.y = 240-166;//118;
s_ingame.frame.width = 466;//359;
s_ingame.frame.height = 332;//256;
//y = 96;
y = 88;
s_ingame.team.generic.type = MTYPE_PTEXT;
s_ingame.team.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_ingame.team.generic.x = 320;
s_ingame.team.generic.y = y;
s_ingame.team.generic.id = ID_TEAM;
s_ingame.team.generic.callback = InGame_Event;
s_ingame.team.string = "START";
s_ingame.team.color = color_red;
s_ingame.team.style = UI_CENTER|UI_SMALLFONT;
y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.addbots.generic.type = MTYPE_PTEXT;
s_ingame.addbots.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_ingame.addbots.generic.x = 320;
s_ingame.addbots.generic.y = y;
s_ingame.addbots.generic.id = ID_ADDBOTS;
s_ingame.addbots.generic.callback = InGame_Event;
s_ingame.addbots.string = "ADD BOTS";
s_ingame.addbots.color = color_red;
s_ingame.addbots.style = UI_CENTER|UI_SMALLFONT;
if( !trap_Cvar_VariableValue( "sv_running" ) || !trap_Cvar_VariableValue( "bot_enable" ) || (trap_Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER)) {
s_ingame.addbots.generic.flags |= QMF_GRAYED;
}
y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.removebots.generic.type = MTYPE_PTEXT;
s_ingame.removebots.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_ingame.removebots.generic.x = 320;
s_ingame.removebots.generic.y = y;
s_ingame.removebots.generic.id = ID_REMOVEBOTS;
s_ingame.removebots.generic.callback = InGame_Event;
s_ingame.removebots.string = "REMOVE BOTS";
s_ingame.removebots.color = color_red;
s_ingame.removebots.style = UI_CENTER|UI_SMALLFONT;
if( !trap_Cvar_VariableValue( "sv_running" ) || !trap_Cvar_VariableValue( "bot_enable" ) || (trap_Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER)) {
s_ingame.removebots.generic.flags |= QMF_GRAYED;
}
y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.teamorders.generic.type = MTYPE_PTEXT;
s_ingame.teamorders.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_ingame.teamorders.generic.x = 320;
s_ingame.teamorders.generic.y = y;
s_ingame.teamorders.generic.id = ID_TEAMORDERS;
s_ingame.teamorders.generic.callback = InGame_Event;
s_ingame.teamorders.string = "TEAM ORDERS";
s_ingame.teamorders.color = color_red;
s_ingame.teamorders.style = UI_CENTER|UI_SMALLFONT;
if( !(trap_Cvar_VariableValue( "g_gametype" ) >= GT_TEAM) ) {
s_ingame.teamorders.generic.flags |= QMF_GRAYED;
}
else {
trap_GetClientState( &cs );
trap_GetConfigString( CS_PLAYERS + cs.clientNum, info, MAX_INFO_STRING );
team = atoi( Info_ValueForKey( info, "t" ) );
if( team == TEAM_SPECTATOR ) {
s_ingame.teamorders.generic.flags |= QMF_GRAYED;
}
}
y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.setup.generic.type = MTYPE_PTEXT;
s_ingame.setup.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_ingame.setup.generic.x = 320;
s_ingame.setup.generic.y = y;
s_ingame.setup.generic.id = ID_SETUP;
s_ingame.setup.generic.callback = InGame_Event;
s_ingame.setup.string = "SETUP";
s_ingame.setup.color = color_red;
s_ingame.setup.style = UI_CENTER|UI_SMALLFONT;
y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.server.generic.type = MTYPE_PTEXT;
s_ingame.server.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_ingame.server.generic.x = 320;
s_ingame.server.generic.y = y;
s_ingame.server.generic.id = ID_SERVERINFO;
s_ingame.server.generic.callback = InGame_Event;
s_ingame.server.string = "SERVER INFO";
s_ingame.server.color = color_red;
s_ingame.server.style = UI_CENTER|UI_SMALLFONT;
y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.restart.generic.type = MTYPE_PTEXT;
s_ingame.restart.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_ingame.restart.generic.x = 320;
s_ingame.restart.generic.y = y;
s_ingame.restart.generic.id = ID_RESTART;
s_ingame.restart.generic.callback = InGame_Event;
s_ingame.restart.string = "RESTART ARENA";
s_ingame.restart.color = color_red;
s_ingame.restart.style = UI_CENTER|UI_SMALLFONT;
if( !trap_Cvar_VariableValue( "sv_running" ) ) {
s_ingame.restart.generic.flags |= QMF_GRAYED;
}
y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.resume.generic.type = MTYPE_PTEXT;
s_ingame.resume.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_ingame.resume.generic.x = 320;
s_ingame.resume.generic.y = y;
s_ingame.resume.generic.id = ID_RESUME;
s_ingame.resume.generic.callback = InGame_Event;
s_ingame.resume.string = "RESUME GAME";
s_ingame.resume.color = color_red;
s_ingame.resume.style = UI_CENTER|UI_SMALLFONT;
y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.leave.generic.type = MTYPE_PTEXT;
s_ingame.leave.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_ingame.leave.generic.x = 320;
s_ingame.leave.generic.y = y;
s_ingame.leave.generic.id = ID_LEAVEARENA;
s_ingame.leave.generic.callback = InGame_Event;
s_ingame.leave.string = "LEAVE ARENA";
s_ingame.leave.color = color_red;
s_ingame.leave.style = UI_CENTER|UI_SMALLFONT;
y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.quit.generic.type = MTYPE_PTEXT;
s_ingame.quit.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_ingame.quit.generic.x = 320;
s_ingame.quit.generic.y = y;
s_ingame.quit.generic.id = ID_QUIT;
s_ingame.quit.generic.callback = InGame_Event;
s_ingame.quit.string = "EXIT GAME";
s_ingame.quit.color = color_red;
s_ingame.quit.style = UI_CENTER|UI_SMALLFONT;
Menu_AddItem( &s_ingame.menu, &s_ingame.frame );
Menu_AddItem( &s_ingame.menu, &s_ingame.team );
Menu_AddItem( &s_ingame.menu, &s_ingame.addbots );
Menu_AddItem( &s_ingame.menu, &s_ingame.removebots );
Menu_AddItem( &s_ingame.menu, &s_ingame.teamorders );
Menu_AddItem( &s_ingame.menu, &s_ingame.setup );
Menu_AddItem( &s_ingame.menu, &s_ingame.server );
Menu_AddItem( &s_ingame.menu, &s_ingame.restart );
Menu_AddItem( &s_ingame.menu, &s_ingame.resume );
Menu_AddItem( &s_ingame.menu, &s_ingame.leave );
Menu_AddItem( &s_ingame.menu, &s_ingame.quit );
}
/*
=================
InGame_Cache
=================
*/
void InGame_Cache( void ) {
trap_R_RegisterShaderNoMip( INGAME_FRAME );
}
/*
=================
UI_InGameMenu
=================
*/
void UI_InGameMenu( void ) {
// force as top level menu
uis.menusp = 0;
// set menu cursor to a nice location
uis.cursorx = 319;
uis.cursory = 80;
InGame_MenuInit();
UI_PushMenu( &s_ingame.menu );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
INGAME MENU
=======================================================================
*/
#include "ui_local.h"
#define INGAME_FRAME "menu/art/addbotframe"
//#define INGAME_FRAME "menu/art/cut_frame"
#define INGAME_MENU_VERTICAL_SPACING 28
#define ID_TEAM 10
#define ID_ADDBOTS 11
#define ID_REMOVEBOTS 12
#define ID_SETUP 13
#define ID_SERVERINFO 14
#define ID_LEAVEARENA 15
#define ID_RESTART 16
#define ID_QUIT 17
#define ID_RESUME 18
#define ID_TEAMORDERS 19
typedef struct {
menuframework_s menu;
menubitmap_s frame;
menutext_s team;
menutext_s setup;
menutext_s server;
menutext_s leave;
menutext_s restart;
menutext_s addbots;
menutext_s removebots;
menutext_s teamorders;
menutext_s quit;
menutext_s resume;
} ingamemenu_t;
static ingamemenu_t s_ingame;
/*
=================
InGame_RestartAction
=================
*/
static void InGame_RestartAction( qboolean result ) {
if( !result ) {
return;
}
UI_PopMenu();
trap_Cmd_ExecuteText( EXEC_APPEND, "map_restart 0\n" );
}
/*
=================
InGame_QuitAction
=================
*/
static void InGame_QuitAction( qboolean result ) {
if( !result ) {
return;
}
UI_PopMenu();
UI_CreditMenu();
}
/*
=================
InGame_Event
=================
*/
void InGame_Event( void *ptr, int notification ) {
if( notification != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_TEAM:
UI_TeamMainMenu();
break;
case ID_SETUP:
UI_SetupMenu();
break;
case ID_LEAVEARENA:
trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect\n" );
break;
case ID_RESTART:
UI_ConfirmMenu( "RESTART ARENA?", (voidfunc_f)NULL, InGame_RestartAction );
break;
case ID_QUIT:
UI_ConfirmMenu( "EXIT GAME?", (voidfunc_f)NULL, InGame_QuitAction );
break;
case ID_SERVERINFO:
UI_ServerInfoMenu();
break;
case ID_ADDBOTS:
UI_AddBotsMenu();
break;
case ID_REMOVEBOTS:
UI_RemoveBotsMenu();
break;
case ID_TEAMORDERS:
UI_TeamOrdersMenu();
break;
case ID_RESUME:
UI_PopMenu();
break;
}
}
/*
=================
InGame_MenuInit
=================
*/
void InGame_MenuInit( void ) {
int y;
uiClientState_t cs;
char info[MAX_INFO_STRING];
int team;
memset( &s_ingame, 0 ,sizeof(ingamemenu_t) );
InGame_Cache();
s_ingame.menu.wrapAround = qtrue;
s_ingame.menu.fullscreen = qfalse;
s_ingame.frame.generic.type = MTYPE_BITMAP;
s_ingame.frame.generic.flags = QMF_INACTIVE;
s_ingame.frame.generic.name = INGAME_FRAME;
s_ingame.frame.generic.x = 320-233;//142;
s_ingame.frame.generic.y = 240-166;//118;
s_ingame.frame.width = 466;//359;
s_ingame.frame.height = 332;//256;
//y = 96;
y = 88;
s_ingame.team.generic.type = MTYPE_PTEXT;
s_ingame.team.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_ingame.team.generic.x = 320;
s_ingame.team.generic.y = y;
s_ingame.team.generic.id = ID_TEAM;
s_ingame.team.generic.callback = InGame_Event;
s_ingame.team.string = "START";
s_ingame.team.color = color_red;
s_ingame.team.style = UI_CENTER|UI_SMALLFONT;
y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.addbots.generic.type = MTYPE_PTEXT;
s_ingame.addbots.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_ingame.addbots.generic.x = 320;
s_ingame.addbots.generic.y = y;
s_ingame.addbots.generic.id = ID_ADDBOTS;
s_ingame.addbots.generic.callback = InGame_Event;
s_ingame.addbots.string = "ADD BOTS";
s_ingame.addbots.color = color_red;
s_ingame.addbots.style = UI_CENTER|UI_SMALLFONT;
if( !trap_Cvar_VariableValue( "sv_running" ) || !trap_Cvar_VariableValue( "bot_enable" ) || (trap_Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER)) {
s_ingame.addbots.generic.flags |= QMF_GRAYED;
}
y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.removebots.generic.type = MTYPE_PTEXT;
s_ingame.removebots.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_ingame.removebots.generic.x = 320;
s_ingame.removebots.generic.y = y;
s_ingame.removebots.generic.id = ID_REMOVEBOTS;
s_ingame.removebots.generic.callback = InGame_Event;
s_ingame.removebots.string = "REMOVE BOTS";
s_ingame.removebots.color = color_red;
s_ingame.removebots.style = UI_CENTER|UI_SMALLFONT;
if( !trap_Cvar_VariableValue( "sv_running" ) || !trap_Cvar_VariableValue( "bot_enable" ) || (trap_Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER)) {
s_ingame.removebots.generic.flags |= QMF_GRAYED;
}
y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.teamorders.generic.type = MTYPE_PTEXT;
s_ingame.teamorders.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_ingame.teamorders.generic.x = 320;
s_ingame.teamorders.generic.y = y;
s_ingame.teamorders.generic.id = ID_TEAMORDERS;
s_ingame.teamorders.generic.callback = InGame_Event;
s_ingame.teamorders.string = "TEAM ORDERS";
s_ingame.teamorders.color = color_red;
s_ingame.teamorders.style = UI_CENTER|UI_SMALLFONT;
if( !(trap_Cvar_VariableValue( "g_gametype" ) >= GT_TEAM) ) {
s_ingame.teamorders.generic.flags |= QMF_GRAYED;
}
else {
trap_GetClientState( &cs );
trap_GetConfigString( CS_PLAYERS + cs.clientNum, info, MAX_INFO_STRING );
team = atoi( Info_ValueForKey( info, "t" ) );
if( team == TEAM_SPECTATOR ) {
s_ingame.teamorders.generic.flags |= QMF_GRAYED;
}
}
y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.setup.generic.type = MTYPE_PTEXT;
s_ingame.setup.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_ingame.setup.generic.x = 320;
s_ingame.setup.generic.y = y;
s_ingame.setup.generic.id = ID_SETUP;
s_ingame.setup.generic.callback = InGame_Event;
s_ingame.setup.string = "SETUP";
s_ingame.setup.color = color_red;
s_ingame.setup.style = UI_CENTER|UI_SMALLFONT;
y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.server.generic.type = MTYPE_PTEXT;
s_ingame.server.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_ingame.server.generic.x = 320;
s_ingame.server.generic.y = y;
s_ingame.server.generic.id = ID_SERVERINFO;
s_ingame.server.generic.callback = InGame_Event;
s_ingame.server.string = "SERVER INFO";
s_ingame.server.color = color_red;
s_ingame.server.style = UI_CENTER|UI_SMALLFONT;
y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.restart.generic.type = MTYPE_PTEXT;
s_ingame.restart.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_ingame.restart.generic.x = 320;
s_ingame.restart.generic.y = y;
s_ingame.restart.generic.id = ID_RESTART;
s_ingame.restart.generic.callback = InGame_Event;
s_ingame.restart.string = "RESTART ARENA";
s_ingame.restart.color = color_red;
s_ingame.restart.style = UI_CENTER|UI_SMALLFONT;
if( !trap_Cvar_VariableValue( "sv_running" ) ) {
s_ingame.restart.generic.flags |= QMF_GRAYED;
}
y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.resume.generic.type = MTYPE_PTEXT;
s_ingame.resume.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_ingame.resume.generic.x = 320;
s_ingame.resume.generic.y = y;
s_ingame.resume.generic.id = ID_RESUME;
s_ingame.resume.generic.callback = InGame_Event;
s_ingame.resume.string = "RESUME GAME";
s_ingame.resume.color = color_red;
s_ingame.resume.style = UI_CENTER|UI_SMALLFONT;
y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.leave.generic.type = MTYPE_PTEXT;
s_ingame.leave.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_ingame.leave.generic.x = 320;
s_ingame.leave.generic.y = y;
s_ingame.leave.generic.id = ID_LEAVEARENA;
s_ingame.leave.generic.callback = InGame_Event;
s_ingame.leave.string = "LEAVE ARENA";
s_ingame.leave.color = color_red;
s_ingame.leave.style = UI_CENTER|UI_SMALLFONT;
y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.quit.generic.type = MTYPE_PTEXT;
s_ingame.quit.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_ingame.quit.generic.x = 320;
s_ingame.quit.generic.y = y;
s_ingame.quit.generic.id = ID_QUIT;
s_ingame.quit.generic.callback = InGame_Event;
s_ingame.quit.string = "EXIT GAME";
s_ingame.quit.color = color_red;
s_ingame.quit.style = UI_CENTER|UI_SMALLFONT;
Menu_AddItem( &s_ingame.menu, &s_ingame.frame );
Menu_AddItem( &s_ingame.menu, &s_ingame.team );
Menu_AddItem( &s_ingame.menu, &s_ingame.addbots );
Menu_AddItem( &s_ingame.menu, &s_ingame.removebots );
Menu_AddItem( &s_ingame.menu, &s_ingame.teamorders );
Menu_AddItem( &s_ingame.menu, &s_ingame.setup );
Menu_AddItem( &s_ingame.menu, &s_ingame.server );
Menu_AddItem( &s_ingame.menu, &s_ingame.restart );
Menu_AddItem( &s_ingame.menu, &s_ingame.resume );
Menu_AddItem( &s_ingame.menu, &s_ingame.leave );
Menu_AddItem( &s_ingame.menu, &s_ingame.quit );
}
/*
=================
InGame_Cache
=================
*/
void InGame_Cache( void ) {
trap_R_RegisterShaderNoMip( INGAME_FRAME );
}
/*
=================
UI_InGameMenu
=================
*/
void UI_InGameMenu( void ) {
// force as top level menu
uis.menusp = 0;
// set menu cursor to a nice location
uis.cursorx = 319;
uis.cursory = 80;
InGame_MenuInit();
UI_PushMenu( &s_ingame.menu );
}

View file

@ -1,274 +1,274 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=============================================================================
LOAD CONFIG MENU
=============================================================================
*/
#include "ui_local.h"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ART_FIGHT0 "menu/art/load_0"
#define ART_FIGHT1 "menu/art/load_1"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define ART_ARROWS "menu/art/arrows_horz_0"
#define ART_ARROWLEFT "menu/art/arrows_horz_left"
#define ART_ARROWRIGHT "menu/art/arrows_horz_right"
#define MAX_CONFIGS 128
#define NAMEBUFSIZE ( MAX_CONFIGS * 16 )
#define ID_BACK 10
#define ID_GO 11
#define ID_LIST 12
#define ID_LEFT 13
#define ID_RIGHT 14
#define ARROWS_WIDTH 128
#define ARROWS_HEIGHT 48
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menulist_s list;
menubitmap_s arrows;
menubitmap_s left;
menubitmap_s right;
menubitmap_s back;
menubitmap_s go;
char names[NAMEBUFSIZE];
char* configlist[MAX_CONFIGS];
} configs_t;
static configs_t s_configs;
/*
===============
LoadConfig_MenuEvent
===============
*/
static void LoadConfig_MenuEvent( void *ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch ( ((menucommon_s*)ptr)->id ) {
case ID_GO:
trap_Cmd_ExecuteText( EXEC_APPEND, va( "exec %s\n", s_configs.list.itemnames[s_configs.list.curvalue] ) );
UI_PopMenu();
break;
case ID_BACK:
UI_PopMenu();
break;
case ID_LEFT:
ScrollList_Key( &s_configs.list, K_LEFTARROW );
break;
case ID_RIGHT:
ScrollList_Key( &s_configs.list, K_RIGHTARROW );
break;
}
}
/*
===============
LoadConfig_MenuInit
===============
*/
static void LoadConfig_MenuInit( void ) {
int i;
int len;
char *configname;
UI_LoadConfig_Cache();
memset( &s_configs, 0 ,sizeof(configs_t) );
s_configs.menu.wrapAround = qtrue;
s_configs.menu.fullscreen = qtrue;
s_configs.banner.generic.type = MTYPE_BTEXT;
s_configs.banner.generic.x = 320;
s_configs.banner.generic.y = 16;
s_configs.banner.string = "LOAD CONFIG";
s_configs.banner.color = color_white;
s_configs.banner.style = UI_CENTER;
s_configs.framel.generic.type = MTYPE_BITMAP;
s_configs.framel.generic.name = ART_FRAMEL;
s_configs.framel.generic.flags = QMF_INACTIVE;
s_configs.framel.generic.x = 0;
s_configs.framel.generic.y = 78;
s_configs.framel.width = 256;
s_configs.framel.height = 329;
s_configs.framer.generic.type = MTYPE_BITMAP;
s_configs.framer.generic.name = ART_FRAMER;
s_configs.framer.generic.flags = QMF_INACTIVE;
s_configs.framer.generic.x = 376;
s_configs.framer.generic.y = 76;
s_configs.framer.width = 256;
s_configs.framer.height = 334;
s_configs.arrows.generic.type = MTYPE_BITMAP;
s_configs.arrows.generic.name = ART_ARROWS;
s_configs.arrows.generic.flags = QMF_INACTIVE;
s_configs.arrows.generic.x = 320-ARROWS_WIDTH/2;
s_configs.arrows.generic.y = 400;
s_configs.arrows.width = ARROWS_WIDTH;
s_configs.arrows.height = ARROWS_HEIGHT;
s_configs.left.generic.type = MTYPE_BITMAP;
s_configs.left.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;
s_configs.left.generic.x = 320-ARROWS_WIDTH/2;
s_configs.left.generic.y = 400;
s_configs.left.generic.id = ID_LEFT;
s_configs.left.generic.callback = LoadConfig_MenuEvent;
s_configs.left.width = ARROWS_WIDTH/2;
s_configs.left.height = ARROWS_HEIGHT;
s_configs.left.focuspic = ART_ARROWLEFT;
s_configs.right.generic.type = MTYPE_BITMAP;
s_configs.right.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;
s_configs.right.generic.x = 320;
s_configs.right.generic.y = 400;
s_configs.right.generic.id = ID_RIGHT;
s_configs.right.generic.callback = LoadConfig_MenuEvent;
s_configs.right.width = ARROWS_WIDTH/2;
s_configs.right.height = ARROWS_HEIGHT;
s_configs.right.focuspic = ART_ARROWRIGHT;
s_configs.back.generic.type = MTYPE_BITMAP;
s_configs.back.generic.name = ART_BACK0;
s_configs.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_configs.back.generic.id = ID_BACK;
s_configs.back.generic.callback = LoadConfig_MenuEvent;
s_configs.back.generic.x = 0;
s_configs.back.generic.y = 480-64;
s_configs.back.width = 128;
s_configs.back.height = 64;
s_configs.back.focuspic = ART_BACK1;
s_configs.go.generic.type = MTYPE_BITMAP;
s_configs.go.generic.name = ART_FIGHT0;
s_configs.go.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
s_configs.go.generic.id = ID_GO;
s_configs.go.generic.callback = LoadConfig_MenuEvent;
s_configs.go.generic.x = 640;
s_configs.go.generic.y = 480-64;
s_configs.go.width = 128;
s_configs.go.height = 64;
s_configs.go.focuspic = ART_FIGHT1;
// scan for configs
s_configs.list.generic.type = MTYPE_SCROLLLIST;
s_configs.list.generic.flags = QMF_PULSEIFFOCUS;
s_configs.list.generic.callback = LoadConfig_MenuEvent;
s_configs.list.generic.id = ID_LIST;
s_configs.list.generic.x = 118;
s_configs.list.generic.y = 130;
s_configs.list.width = 16;
s_configs.list.height = 14;
s_configs.list.numitems = trap_FS_GetFileList( "", "cfg", s_configs.names, NAMEBUFSIZE );
s_configs.list.itemnames = (const char **)s_configs.configlist;
s_configs.list.columns = 3;
if (!s_configs.list.numitems) {
strcpy(s_configs.names,"No Files Found.");
s_configs.list.numitems = 1;
//degenerate case, not selectable
s_configs.go.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);
}
else if (s_configs.list.numitems > MAX_CONFIGS)
s_configs.list.numitems = MAX_CONFIGS;
configname = s_configs.names;
for ( i = 0; i < s_configs.list.numitems; i++ ) {
s_configs.list.itemnames[i] = configname;
// strip extension
len = strlen( configname );
if (!Q_stricmp(configname + len - 4,".cfg"))
configname[len-4] = '\0';
Q_strupr(configname);
configname += len + 1;
}
Menu_AddItem( &s_configs.menu, &s_configs.banner );
Menu_AddItem( &s_configs.menu, &s_configs.framel );
Menu_AddItem( &s_configs.menu, &s_configs.framer );
Menu_AddItem( &s_configs.menu, &s_configs.list );
Menu_AddItem( &s_configs.menu, &s_configs.arrows );
Menu_AddItem( &s_configs.menu, &s_configs.left );
Menu_AddItem( &s_configs.menu, &s_configs.right );
Menu_AddItem( &s_configs.menu, &s_configs.back );
Menu_AddItem( &s_configs.menu, &s_configs.go );
}
/*
=================
UI_LoadConfig_Cache
=================
*/
void UI_LoadConfig_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
trap_R_RegisterShaderNoMip( ART_FIGHT0 );
trap_R_RegisterShaderNoMip( ART_FIGHT1 );
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
trap_R_RegisterShaderNoMip( ART_ARROWS );
trap_R_RegisterShaderNoMip( ART_ARROWLEFT );
trap_R_RegisterShaderNoMip( ART_ARROWRIGHT );
}
/*
===============
UI_LoadConfigMenu
===============
*/
void UI_LoadConfigMenu( void ) {
LoadConfig_MenuInit();
UI_PushMenu( &s_configs.menu );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=============================================================================
LOAD CONFIG MENU
=============================================================================
*/
#include "ui_local.h"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ART_FIGHT0 "menu/art/load_0"
#define ART_FIGHT1 "menu/art/load_1"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define ART_ARROWS "menu/art/arrows_horz_0"
#define ART_ARROWLEFT "menu/art/arrows_horz_left"
#define ART_ARROWRIGHT "menu/art/arrows_horz_right"
#define MAX_CONFIGS 128
#define NAMEBUFSIZE ( MAX_CONFIGS * 16 )
#define ID_BACK 10
#define ID_GO 11
#define ID_LIST 12
#define ID_LEFT 13
#define ID_RIGHT 14
#define ARROWS_WIDTH 128
#define ARROWS_HEIGHT 48
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menulist_s list;
menubitmap_s arrows;
menubitmap_s left;
menubitmap_s right;
menubitmap_s back;
menubitmap_s go;
char names[NAMEBUFSIZE];
char* configlist[MAX_CONFIGS];
} configs_t;
static configs_t s_configs;
/*
===============
LoadConfig_MenuEvent
===============
*/
static void LoadConfig_MenuEvent( void *ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch ( ((menucommon_s*)ptr)->id ) {
case ID_GO:
trap_Cmd_ExecuteText( EXEC_APPEND, va( "exec %s\n", s_configs.list.itemnames[s_configs.list.curvalue] ) );
UI_PopMenu();
break;
case ID_BACK:
UI_PopMenu();
break;
case ID_LEFT:
ScrollList_Key( &s_configs.list, K_LEFTARROW );
break;
case ID_RIGHT:
ScrollList_Key( &s_configs.list, K_RIGHTARROW );
break;
}
}
/*
===============
LoadConfig_MenuInit
===============
*/
static void LoadConfig_MenuInit( void ) {
int i;
int len;
char *configname;
UI_LoadConfig_Cache();
memset( &s_configs, 0 ,sizeof(configs_t) );
s_configs.menu.wrapAround = qtrue;
s_configs.menu.fullscreen = qtrue;
s_configs.banner.generic.type = MTYPE_BTEXT;
s_configs.banner.generic.x = 320;
s_configs.banner.generic.y = 16;
s_configs.banner.string = "LOAD CONFIG";
s_configs.banner.color = color_white;
s_configs.banner.style = UI_CENTER;
s_configs.framel.generic.type = MTYPE_BITMAP;
s_configs.framel.generic.name = ART_FRAMEL;
s_configs.framel.generic.flags = QMF_INACTIVE;
s_configs.framel.generic.x = 0;
s_configs.framel.generic.y = 78;
s_configs.framel.width = 256;
s_configs.framel.height = 329;
s_configs.framer.generic.type = MTYPE_BITMAP;
s_configs.framer.generic.name = ART_FRAMER;
s_configs.framer.generic.flags = QMF_INACTIVE;
s_configs.framer.generic.x = 376;
s_configs.framer.generic.y = 76;
s_configs.framer.width = 256;
s_configs.framer.height = 334;
s_configs.arrows.generic.type = MTYPE_BITMAP;
s_configs.arrows.generic.name = ART_ARROWS;
s_configs.arrows.generic.flags = QMF_INACTIVE;
s_configs.arrows.generic.x = 320-ARROWS_WIDTH/2;
s_configs.arrows.generic.y = 400;
s_configs.arrows.width = ARROWS_WIDTH;
s_configs.arrows.height = ARROWS_HEIGHT;
s_configs.left.generic.type = MTYPE_BITMAP;
s_configs.left.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;
s_configs.left.generic.x = 320-ARROWS_WIDTH/2;
s_configs.left.generic.y = 400;
s_configs.left.generic.id = ID_LEFT;
s_configs.left.generic.callback = LoadConfig_MenuEvent;
s_configs.left.width = ARROWS_WIDTH/2;
s_configs.left.height = ARROWS_HEIGHT;
s_configs.left.focuspic = ART_ARROWLEFT;
s_configs.right.generic.type = MTYPE_BITMAP;
s_configs.right.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;
s_configs.right.generic.x = 320;
s_configs.right.generic.y = 400;
s_configs.right.generic.id = ID_RIGHT;
s_configs.right.generic.callback = LoadConfig_MenuEvent;
s_configs.right.width = ARROWS_WIDTH/2;
s_configs.right.height = ARROWS_HEIGHT;
s_configs.right.focuspic = ART_ARROWRIGHT;
s_configs.back.generic.type = MTYPE_BITMAP;
s_configs.back.generic.name = ART_BACK0;
s_configs.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_configs.back.generic.id = ID_BACK;
s_configs.back.generic.callback = LoadConfig_MenuEvent;
s_configs.back.generic.x = 0;
s_configs.back.generic.y = 480-64;
s_configs.back.width = 128;
s_configs.back.height = 64;
s_configs.back.focuspic = ART_BACK1;
s_configs.go.generic.type = MTYPE_BITMAP;
s_configs.go.generic.name = ART_FIGHT0;
s_configs.go.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
s_configs.go.generic.id = ID_GO;
s_configs.go.generic.callback = LoadConfig_MenuEvent;
s_configs.go.generic.x = 640;
s_configs.go.generic.y = 480-64;
s_configs.go.width = 128;
s_configs.go.height = 64;
s_configs.go.focuspic = ART_FIGHT1;
// scan for configs
s_configs.list.generic.type = MTYPE_SCROLLLIST;
s_configs.list.generic.flags = QMF_PULSEIFFOCUS;
s_configs.list.generic.callback = LoadConfig_MenuEvent;
s_configs.list.generic.id = ID_LIST;
s_configs.list.generic.x = 118;
s_configs.list.generic.y = 130;
s_configs.list.width = 16;
s_configs.list.height = 14;
s_configs.list.numitems = trap_FS_GetFileList( "", "cfg", s_configs.names, NAMEBUFSIZE );
s_configs.list.itemnames = (const char **)s_configs.configlist;
s_configs.list.columns = 3;
if (!s_configs.list.numitems) {
strcpy(s_configs.names,"No Files Found.");
s_configs.list.numitems = 1;
//degenerate case, not selectable
s_configs.go.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);
}
else if (s_configs.list.numitems > MAX_CONFIGS)
s_configs.list.numitems = MAX_CONFIGS;
configname = s_configs.names;
for ( i = 0; i < s_configs.list.numitems; i++ ) {
s_configs.list.itemnames[i] = configname;
// strip extension
len = strlen( configname );
if (!Q_stricmp(configname + len - 4,".cfg"))
configname[len-4] = '\0';
Q_strupr(configname);
configname += len + 1;
}
Menu_AddItem( &s_configs.menu, &s_configs.banner );
Menu_AddItem( &s_configs.menu, &s_configs.framel );
Menu_AddItem( &s_configs.menu, &s_configs.framer );
Menu_AddItem( &s_configs.menu, &s_configs.list );
Menu_AddItem( &s_configs.menu, &s_configs.arrows );
Menu_AddItem( &s_configs.menu, &s_configs.left );
Menu_AddItem( &s_configs.menu, &s_configs.right );
Menu_AddItem( &s_configs.menu, &s_configs.back );
Menu_AddItem( &s_configs.menu, &s_configs.go );
}
/*
=================
UI_LoadConfig_Cache
=================
*/
void UI_LoadConfig_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
trap_R_RegisterShaderNoMip( ART_FIGHT0 );
trap_R_RegisterShaderNoMip( ART_FIGHT1 );
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
trap_R_RegisterShaderNoMip( ART_ARROWS );
trap_R_RegisterShaderNoMip( ART_ARROWLEFT );
trap_R_RegisterShaderNoMip( ART_ARROWRIGHT );
}
/*
===============
UI_LoadConfigMenu
===============
*/
void UI_LoadConfigMenu( void ) {
LoadConfig_MenuInit();
UI_PushMenu( &s_configs.menu );
}

File diff suppressed because it is too large Load diff

View file

@ -1,208 +1,208 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
//
// ui_login.c
//
#include "ui_local.h"
#define LOGIN_FRAME "menu/art/cut_frame"
#define ID_NAME 100
#define ID_NAME_BOX 101
#define ID_PASSWORD 102
#define ID_PASSWORD_BOX 103
#define ID_LOGIN 104
#define ID_CANCEL 105
typedef struct
{
menuframework_s menu;
menubitmap_s frame;
menutext_s name;
menufield_s name_box;
menutext_s password;
menufield_s password_box;
menutext_s login;
menutext_s cancel;
} login_t;
static login_t s_login;
static menuframework_s s_login_menu;
static menuaction_s s_login_login;
static menuaction_s s_login_cancel;
static vec4_t s_login_color_prompt = {1.00, 0.43, 0.00, 1.00};
/*
===============
Login_MenuEvent
===============
*/
static void Login_MenuEvent( void* ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_LOGIN:
// set name ``
//trap_Cvar_Set( "name", s_login.name_box.field.buffer );
/*
trap_Cvar_Set( "rank_name", s_login.name_box.field.buffer );
trap_Cvar_Set( "rank_pwd", s_login.password_box.field.buffer );
*/
// login
trap_CL_UI_RankUserLogin(
s_login.name_box.field.buffer,
s_login.password_box.field.buffer );
UI_ForceMenuOff();
break;
case ID_CANCEL:
UI_PopMenu();
break;
}
}
/*
===============
Login_MenuInit
===============
*/
void Login_MenuInit( void ) {
int y;
memset( &s_login, 0, sizeof(s_login) );
Login_Cache();
s_login.menu.wrapAround = qtrue;
s_login.menu.fullscreen = qfalse;
s_login.frame.generic.type = MTYPE_BITMAP;
s_login.frame.generic.flags = QMF_INACTIVE;
s_login.frame.generic.name = LOGIN_FRAME;
s_login.frame.generic.x = 142; //320-233;
s_login.frame.generic.y = 118; //240-166;
s_login.frame.width = 359; //466;
s_login.frame.height = 256; //332;
y = 214;
s_login.name.generic.type = MTYPE_PTEXT;
s_login.name.generic.flags = QMF_RIGHT_JUSTIFY|QMF_INACTIVE;
s_login.name.generic.id = ID_NAME;
s_login.name.generic.x = 310;
s_login.name.generic.y = y;
s_login.name.string = "NAME";
s_login.name.style = UI_RIGHT|UI_SMALLFONT;
s_login.name.color = s_login_color_prompt;
s_login.name_box.generic.type = MTYPE_FIELD;
s_login.name_box.generic.ownerdraw = Rankings_DrawName;
s_login.name_box.generic.name = "";
s_login.name_box.generic.flags = 0;
s_login.name_box.generic.x = 330;
s_login.name_box.generic.y = y;
s_login.name_box.field.widthInChars = 16;
s_login.name_box.field.maxchars = 16;
y += 20;
s_login.password.generic.type = MTYPE_PTEXT;
s_login.password.generic.flags = QMF_RIGHT_JUSTIFY|QMF_INACTIVE;
s_login.password.generic.id = ID_PASSWORD;
s_login.password.generic.x = 310;
s_login.password.generic.y = y;
s_login.password.string = "PASSWORD";
s_login.password.style = UI_RIGHT|UI_SMALLFONT;
s_login.password.color = s_login_color_prompt;
s_login.password_box.generic.type = MTYPE_FIELD;
s_login.password_box.generic.ownerdraw = Rankings_DrawPassword;
s_login.password_box.generic.name = "";
s_login.password_box.generic.flags = 0;
s_login.password_box.generic.x = 330;
s_login.password_box.generic.y = y;
s_login.password_box.field.widthInChars = 16;
s_login.password_box.field.maxchars = 16;
y += 40;
s_login.login.generic.type = MTYPE_PTEXT;
s_login.login.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
s_login.login.generic.id = ID_LOGIN;
s_login.login.generic.callback = Login_MenuEvent;
s_login.login.generic.x = 310;
s_login.login.generic.y = y;
s_login.login.string = "LOGIN";
s_login.login.style = UI_RIGHT|UI_SMALLFONT;
s_login.login.color = colorRed;
s_login.cancel.generic.type = MTYPE_PTEXT;
s_login.cancel.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_login.cancel.generic.id = ID_CANCEL;
s_login.cancel.generic.callback = Login_MenuEvent;
s_login.cancel.generic.x = 330;
s_login.cancel.generic.y = y;
s_login.cancel.string = "CANCEL";
s_login.cancel.style = UI_LEFT|UI_SMALLFONT;
s_login.cancel.color = colorRed;
y += 20;
Menu_AddItem( &s_login.menu, (void*) &s_login.frame );
Menu_AddItem( &s_login.menu, (void*) &s_login.name );
Menu_AddItem( &s_login.menu, (void*) &s_login.name_box );
Menu_AddItem( &s_login.menu, (void*) &s_login.password );
Menu_AddItem( &s_login.menu, (void*) &s_login.password_box );
Menu_AddItem( &s_login.menu, (void*) &s_login.login );
Menu_AddItem( &s_login.menu, (void*) &s_login.cancel );
}
/*
===============
Login_Cache
===============
*/
void Login_Cache( void ) {
trap_R_RegisterShaderNoMip( LOGIN_FRAME );
}
/*
===============
UI_LoginMenu
===============
*/
void UI_LoginMenu( void ) {
Login_MenuInit();
UI_PushMenu ( &s_login.menu );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
//
// ui_login.c
//
#include "ui_local.h"
#define LOGIN_FRAME "menu/art/cut_frame"
#define ID_NAME 100
#define ID_NAME_BOX 101
#define ID_PASSWORD 102
#define ID_PASSWORD_BOX 103
#define ID_LOGIN 104
#define ID_CANCEL 105
typedef struct
{
menuframework_s menu;
menubitmap_s frame;
menutext_s name;
menufield_s name_box;
menutext_s password;
menufield_s password_box;
menutext_s login;
menutext_s cancel;
} login_t;
static login_t s_login;
static menuframework_s s_login_menu;
static menuaction_s s_login_login;
static menuaction_s s_login_cancel;
static vec4_t s_login_color_prompt = {1.00, 0.43, 0.00, 1.00};
/*
===============
Login_MenuEvent
===============
*/
static void Login_MenuEvent( void* ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_LOGIN:
// set name ``
//trap_Cvar_Set( "name", s_login.name_box.field.buffer );
/*
trap_Cvar_Set( "rank_name", s_login.name_box.field.buffer );
trap_Cvar_Set( "rank_pwd", s_login.password_box.field.buffer );
*/
// login
trap_CL_UI_RankUserLogin(
s_login.name_box.field.buffer,
s_login.password_box.field.buffer );
UI_ForceMenuOff();
break;
case ID_CANCEL:
UI_PopMenu();
break;
}
}
/*
===============
Login_MenuInit
===============
*/
void Login_MenuInit( void ) {
int y;
memset( &s_login, 0, sizeof(s_login) );
Login_Cache();
s_login.menu.wrapAround = qtrue;
s_login.menu.fullscreen = qfalse;
s_login.frame.generic.type = MTYPE_BITMAP;
s_login.frame.generic.flags = QMF_INACTIVE;
s_login.frame.generic.name = LOGIN_FRAME;
s_login.frame.generic.x = 142; //320-233;
s_login.frame.generic.y = 118; //240-166;
s_login.frame.width = 359; //466;
s_login.frame.height = 256; //332;
y = 214;
s_login.name.generic.type = MTYPE_PTEXT;
s_login.name.generic.flags = QMF_RIGHT_JUSTIFY|QMF_INACTIVE;
s_login.name.generic.id = ID_NAME;
s_login.name.generic.x = 310;
s_login.name.generic.y = y;
s_login.name.string = "NAME";
s_login.name.style = UI_RIGHT|UI_SMALLFONT;
s_login.name.color = s_login_color_prompt;
s_login.name_box.generic.type = MTYPE_FIELD;
s_login.name_box.generic.ownerdraw = Rankings_DrawName;
s_login.name_box.generic.name = "";
s_login.name_box.generic.flags = 0;
s_login.name_box.generic.x = 330;
s_login.name_box.generic.y = y;
s_login.name_box.field.widthInChars = 16;
s_login.name_box.field.maxchars = 16;
y += 20;
s_login.password.generic.type = MTYPE_PTEXT;
s_login.password.generic.flags = QMF_RIGHT_JUSTIFY|QMF_INACTIVE;
s_login.password.generic.id = ID_PASSWORD;
s_login.password.generic.x = 310;
s_login.password.generic.y = y;
s_login.password.string = "PASSWORD";
s_login.password.style = UI_RIGHT|UI_SMALLFONT;
s_login.password.color = s_login_color_prompt;
s_login.password_box.generic.type = MTYPE_FIELD;
s_login.password_box.generic.ownerdraw = Rankings_DrawPassword;
s_login.password_box.generic.name = "";
s_login.password_box.generic.flags = 0;
s_login.password_box.generic.x = 330;
s_login.password_box.generic.y = y;
s_login.password_box.field.widthInChars = 16;
s_login.password_box.field.maxchars = 16;
y += 40;
s_login.login.generic.type = MTYPE_PTEXT;
s_login.login.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
s_login.login.generic.id = ID_LOGIN;
s_login.login.generic.callback = Login_MenuEvent;
s_login.login.generic.x = 310;
s_login.login.generic.y = y;
s_login.login.string = "LOGIN";
s_login.login.style = UI_RIGHT|UI_SMALLFONT;
s_login.login.color = colorRed;
s_login.cancel.generic.type = MTYPE_PTEXT;
s_login.cancel.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_login.cancel.generic.id = ID_CANCEL;
s_login.cancel.generic.callback = Login_MenuEvent;
s_login.cancel.generic.x = 330;
s_login.cancel.generic.y = y;
s_login.cancel.string = "CANCEL";
s_login.cancel.style = UI_LEFT|UI_SMALLFONT;
s_login.cancel.color = colorRed;
y += 20;
Menu_AddItem( &s_login.menu, (void*) &s_login.frame );
Menu_AddItem( &s_login.menu, (void*) &s_login.name );
Menu_AddItem( &s_login.menu, (void*) &s_login.name_box );
Menu_AddItem( &s_login.menu, (void*) &s_login.password );
Menu_AddItem( &s_login.menu, (void*) &s_login.password_box );
Menu_AddItem( &s_login.menu, (void*) &s_login.login );
Menu_AddItem( &s_login.menu, (void*) &s_login.cancel );
}
/*
===============
Login_Cache
===============
*/
void Login_Cache( void ) {
trap_R_RegisterShaderNoMip( LOGIN_FRAME );
}
/*
===============
UI_LoginMenu
===============
*/
void UI_LoginMenu( void ) {
Login_MenuInit();
UI_PushMenu ( &s_login.menu );
}

View file

@ -1,249 +1,249 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
USER INTERFACE MAIN
=======================================================================
*/
#include "ui_local.h"
/*
================
vmMain
This is the only way control passes into the module.
This must be the very first function compiled into the .qvm file
================
*/
int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
switch ( command ) {
case UI_GETAPIVERSION:
return UI_API_VERSION;
case UI_INIT:
UI_Init();
return 0;
case UI_SHUTDOWN:
UI_Shutdown();
return 0;
case UI_KEY_EVENT:
UI_KeyEvent( arg0, arg1 );
return 0;
case UI_MOUSE_EVENT:
UI_MouseEvent( arg0, arg1 );
return 0;
case UI_REFRESH:
UI_Refresh( arg0 );
return 0;
case UI_IS_FULLSCREEN:
return UI_IsFullscreen();
case UI_SET_ACTIVE_MENU:
UI_SetActiveMenu( arg0 );
return 0;
case UI_CONSOLE_COMMAND:
return UI_ConsoleCommand(arg0);
case UI_DRAW_CONNECT_SCREEN:
UI_DrawConnectScreen( arg0 );
return 0;
case UI_HASUNIQUECDKEY: // mod authors need to observe this
return qtrue; // bk010117 - change this to qfalse for mods!
}
return -1;
}
/*
================
cvars
================
*/
typedef struct {
vmCvar_t *vmCvar;
char *cvarName;
char *defaultString;
int cvarFlags;
} cvarTable_t;
vmCvar_t ui_ffa_fraglimit;
vmCvar_t ui_ffa_timelimit;
vmCvar_t ui_tourney_fraglimit;
vmCvar_t ui_tourney_timelimit;
vmCvar_t ui_team_fraglimit;
vmCvar_t ui_team_timelimit;
vmCvar_t ui_team_friendly;
vmCvar_t ui_ctf_capturelimit;
vmCvar_t ui_ctf_timelimit;
vmCvar_t ui_ctf_friendly;
vmCvar_t ui_arenasFile;
vmCvar_t ui_botsFile;
vmCvar_t ui_spScores1;
vmCvar_t ui_spScores2;
vmCvar_t ui_spScores3;
vmCvar_t ui_spScores4;
vmCvar_t ui_spScores5;
vmCvar_t ui_spAwards;
vmCvar_t ui_spVideos;
vmCvar_t ui_spSkill;
vmCvar_t ui_spSelection;
vmCvar_t ui_browserMaster;
vmCvar_t ui_browserGameType;
vmCvar_t ui_browserSortKey;
vmCvar_t ui_browserShowFull;
vmCvar_t ui_browserShowEmpty;
vmCvar_t ui_brassTime;
vmCvar_t ui_drawCrosshair;
vmCvar_t ui_drawCrosshairNames;
vmCvar_t ui_marks;
vmCvar_t ui_server1;
vmCvar_t ui_server2;
vmCvar_t ui_server3;
vmCvar_t ui_server4;
vmCvar_t ui_server5;
vmCvar_t ui_server6;
vmCvar_t ui_server7;
vmCvar_t ui_server8;
vmCvar_t ui_server9;
vmCvar_t ui_server10;
vmCvar_t ui_server11;
vmCvar_t ui_server12;
vmCvar_t ui_server13;
vmCvar_t ui_server14;
vmCvar_t ui_server15;
vmCvar_t ui_server16;
vmCvar_t ui_cdkeychecked;
// bk001129 - made static to avoid aliasing.
static cvarTable_t cvarTable[] = {
{ &ui_ffa_fraglimit, "ui_ffa_fraglimit", "20", CVAR_ARCHIVE },
{ &ui_ffa_timelimit, "ui_ffa_timelimit", "0", CVAR_ARCHIVE },
{ &ui_tourney_fraglimit, "ui_tourney_fraglimit", "0", CVAR_ARCHIVE },
{ &ui_tourney_timelimit, "ui_tourney_timelimit", "15", CVAR_ARCHIVE },
{ &ui_team_fraglimit, "ui_team_fraglimit", "0", CVAR_ARCHIVE },
{ &ui_team_timelimit, "ui_team_timelimit", "20", CVAR_ARCHIVE },
{ &ui_team_friendly, "ui_team_friendly", "1", CVAR_ARCHIVE },
{ &ui_ctf_capturelimit, "ui_ctf_capturelimit", "8", CVAR_ARCHIVE },
{ &ui_ctf_timelimit, "ui_ctf_timelimit", "30", CVAR_ARCHIVE },
{ &ui_ctf_friendly, "ui_ctf_friendly", "0", CVAR_ARCHIVE },
{ &ui_arenasFile, "g_arenasFile", "", CVAR_INIT|CVAR_ROM },
{ &ui_botsFile, "g_botsFile", "", CVAR_INIT|CVAR_ROM },
{ &ui_spScores1, "g_spScores1", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spScores2, "g_spScores2", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spScores3, "g_spScores3", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spScores4, "g_spScores4", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spScores5, "g_spScores5", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spAwards, "g_spAwards", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spVideos, "g_spVideos", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spSkill, "g_spSkill", "2", CVAR_ARCHIVE | CVAR_LATCH },
{ &ui_spSelection, "ui_spSelection", "", CVAR_ROM },
{ &ui_browserMaster, "ui_browserMaster", "0", CVAR_ARCHIVE },
{ &ui_browserGameType, "ui_browserGameType", "0", CVAR_ARCHIVE },
{ &ui_browserSortKey, "ui_browserSortKey", "4", CVAR_ARCHIVE },
{ &ui_browserShowFull, "ui_browserShowFull", "1", CVAR_ARCHIVE },
{ &ui_browserShowEmpty, "ui_browserShowEmpty", "1", CVAR_ARCHIVE },
{ &ui_brassTime, "cg_brassTime", "2500", CVAR_ARCHIVE },
{ &ui_drawCrosshair, "cg_drawCrosshair", "4", CVAR_ARCHIVE },
{ &ui_drawCrosshairNames, "cg_drawCrosshairNames", "1", CVAR_ARCHIVE },
{ &ui_marks, "cg_marks", "1", CVAR_ARCHIVE },
{ &ui_server1, "server1", "", CVAR_ARCHIVE },
{ &ui_server2, "server2", "", CVAR_ARCHIVE },
{ &ui_server3, "server3", "", CVAR_ARCHIVE },
{ &ui_server4, "server4", "", CVAR_ARCHIVE },
{ &ui_server5, "server5", "", CVAR_ARCHIVE },
{ &ui_server6, "server6", "", CVAR_ARCHIVE },
{ &ui_server7, "server7", "", CVAR_ARCHIVE },
{ &ui_server8, "server8", "", CVAR_ARCHIVE },
{ &ui_server9, "server9", "", CVAR_ARCHIVE },
{ &ui_server10, "server10", "", CVAR_ARCHIVE },
{ &ui_server11, "server11", "", CVAR_ARCHIVE },
{ &ui_server12, "server12", "", CVAR_ARCHIVE },
{ &ui_server13, "server13", "", CVAR_ARCHIVE },
{ &ui_server14, "server14", "", CVAR_ARCHIVE },
{ &ui_server15, "server15", "", CVAR_ARCHIVE },
{ &ui_server16, "server16", "", CVAR_ARCHIVE },
{ &ui_cdkeychecked, "ui_cdkeychecked", "0", CVAR_ROM }
};
// bk001129 - made static to avoid aliasing
static int cvarTableSize = sizeof(cvarTable) / sizeof(cvarTable[0]);
/*
=================
UI_RegisterCvars
=================
*/
void UI_RegisterCvars( void ) {
int i;
cvarTable_t *cv;
for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {
trap_Cvar_Register( cv->vmCvar, cv->cvarName, cv->defaultString, cv->cvarFlags );
}
}
/*
=================
UI_UpdateCvars
=================
*/
void UI_UpdateCvars( void ) {
int i;
cvarTable_t *cv;
for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {
trap_Cvar_Update( cv->vmCvar );
}
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
USER INTERFACE MAIN
=======================================================================
*/
#include "ui_local.h"
/*
================
vmMain
This is the only way control passes into the module.
This must be the very first function compiled into the .qvm file
================
*/
int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
switch ( command ) {
case UI_GETAPIVERSION:
return UI_API_VERSION;
case UI_INIT:
UI_Init();
return 0;
case UI_SHUTDOWN:
UI_Shutdown();
return 0;
case UI_KEY_EVENT:
UI_KeyEvent( arg0, arg1 );
return 0;
case UI_MOUSE_EVENT:
UI_MouseEvent( arg0, arg1 );
return 0;
case UI_REFRESH:
UI_Refresh( arg0 );
return 0;
case UI_IS_FULLSCREEN:
return UI_IsFullscreen();
case UI_SET_ACTIVE_MENU:
UI_SetActiveMenu( arg0 );
return 0;
case UI_CONSOLE_COMMAND:
return UI_ConsoleCommand(arg0);
case UI_DRAW_CONNECT_SCREEN:
UI_DrawConnectScreen( arg0 );
return 0;
case UI_HASUNIQUECDKEY: // mod authors need to observe this
return qtrue; // bk010117 - change this to qfalse for mods!
}
return -1;
}
/*
================
cvars
================
*/
typedef struct {
vmCvar_t *vmCvar;
char *cvarName;
char *defaultString;
int cvarFlags;
} cvarTable_t;
vmCvar_t ui_ffa_fraglimit;
vmCvar_t ui_ffa_timelimit;
vmCvar_t ui_tourney_fraglimit;
vmCvar_t ui_tourney_timelimit;
vmCvar_t ui_team_fraglimit;
vmCvar_t ui_team_timelimit;
vmCvar_t ui_team_friendly;
vmCvar_t ui_ctf_capturelimit;
vmCvar_t ui_ctf_timelimit;
vmCvar_t ui_ctf_friendly;
vmCvar_t ui_arenasFile;
vmCvar_t ui_botsFile;
vmCvar_t ui_spScores1;
vmCvar_t ui_spScores2;
vmCvar_t ui_spScores3;
vmCvar_t ui_spScores4;
vmCvar_t ui_spScores5;
vmCvar_t ui_spAwards;
vmCvar_t ui_spVideos;
vmCvar_t ui_spSkill;
vmCvar_t ui_spSelection;
vmCvar_t ui_browserMaster;
vmCvar_t ui_browserGameType;
vmCvar_t ui_browserSortKey;
vmCvar_t ui_browserShowFull;
vmCvar_t ui_browserShowEmpty;
vmCvar_t ui_brassTime;
vmCvar_t ui_drawCrosshair;
vmCvar_t ui_drawCrosshairNames;
vmCvar_t ui_marks;
vmCvar_t ui_server1;
vmCvar_t ui_server2;
vmCvar_t ui_server3;
vmCvar_t ui_server4;
vmCvar_t ui_server5;
vmCvar_t ui_server6;
vmCvar_t ui_server7;
vmCvar_t ui_server8;
vmCvar_t ui_server9;
vmCvar_t ui_server10;
vmCvar_t ui_server11;
vmCvar_t ui_server12;
vmCvar_t ui_server13;
vmCvar_t ui_server14;
vmCvar_t ui_server15;
vmCvar_t ui_server16;
vmCvar_t ui_cdkeychecked;
// bk001129 - made static to avoid aliasing.
static cvarTable_t cvarTable[] = {
{ &ui_ffa_fraglimit, "ui_ffa_fraglimit", "20", CVAR_ARCHIVE },
{ &ui_ffa_timelimit, "ui_ffa_timelimit", "0", CVAR_ARCHIVE },
{ &ui_tourney_fraglimit, "ui_tourney_fraglimit", "0", CVAR_ARCHIVE },
{ &ui_tourney_timelimit, "ui_tourney_timelimit", "15", CVAR_ARCHIVE },
{ &ui_team_fraglimit, "ui_team_fraglimit", "0", CVAR_ARCHIVE },
{ &ui_team_timelimit, "ui_team_timelimit", "20", CVAR_ARCHIVE },
{ &ui_team_friendly, "ui_team_friendly", "1", CVAR_ARCHIVE },
{ &ui_ctf_capturelimit, "ui_ctf_capturelimit", "8", CVAR_ARCHIVE },
{ &ui_ctf_timelimit, "ui_ctf_timelimit", "30", CVAR_ARCHIVE },
{ &ui_ctf_friendly, "ui_ctf_friendly", "0", CVAR_ARCHIVE },
{ &ui_arenasFile, "g_arenasFile", "", CVAR_INIT|CVAR_ROM },
{ &ui_botsFile, "g_botsFile", "", CVAR_INIT|CVAR_ROM },
{ &ui_spScores1, "g_spScores1", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spScores2, "g_spScores2", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spScores3, "g_spScores3", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spScores4, "g_spScores4", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spScores5, "g_spScores5", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spAwards, "g_spAwards", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spVideos, "g_spVideos", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spSkill, "g_spSkill", "2", CVAR_ARCHIVE | CVAR_LATCH },
{ &ui_spSelection, "ui_spSelection", "", CVAR_ROM },
{ &ui_browserMaster, "ui_browserMaster", "0", CVAR_ARCHIVE },
{ &ui_browserGameType, "ui_browserGameType", "0", CVAR_ARCHIVE },
{ &ui_browserSortKey, "ui_browserSortKey", "4", CVAR_ARCHIVE },
{ &ui_browserShowFull, "ui_browserShowFull", "1", CVAR_ARCHIVE },
{ &ui_browserShowEmpty, "ui_browserShowEmpty", "1", CVAR_ARCHIVE },
{ &ui_brassTime, "cg_brassTime", "2500", CVAR_ARCHIVE },
{ &ui_drawCrosshair, "cg_drawCrosshair", "4", CVAR_ARCHIVE },
{ &ui_drawCrosshairNames, "cg_drawCrosshairNames", "1", CVAR_ARCHIVE },
{ &ui_marks, "cg_marks", "1", CVAR_ARCHIVE },
{ &ui_server1, "server1", "", CVAR_ARCHIVE },
{ &ui_server2, "server2", "", CVAR_ARCHIVE },
{ &ui_server3, "server3", "", CVAR_ARCHIVE },
{ &ui_server4, "server4", "", CVAR_ARCHIVE },
{ &ui_server5, "server5", "", CVAR_ARCHIVE },
{ &ui_server6, "server6", "", CVAR_ARCHIVE },
{ &ui_server7, "server7", "", CVAR_ARCHIVE },
{ &ui_server8, "server8", "", CVAR_ARCHIVE },
{ &ui_server9, "server9", "", CVAR_ARCHIVE },
{ &ui_server10, "server10", "", CVAR_ARCHIVE },
{ &ui_server11, "server11", "", CVAR_ARCHIVE },
{ &ui_server12, "server12", "", CVAR_ARCHIVE },
{ &ui_server13, "server13", "", CVAR_ARCHIVE },
{ &ui_server14, "server14", "", CVAR_ARCHIVE },
{ &ui_server15, "server15", "", CVAR_ARCHIVE },
{ &ui_server16, "server16", "", CVAR_ARCHIVE },
{ &ui_cdkeychecked, "ui_cdkeychecked", "0", CVAR_ROM }
};
// bk001129 - made static to avoid aliasing
static int cvarTableSize = sizeof(cvarTable) / sizeof(cvarTable[0]);
/*
=================
UI_RegisterCvars
=================
*/
void UI_RegisterCvars( void ) {
int i;
cvarTable_t *cv;
for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {
trap_Cvar_Register( cv->vmCvar, cv->cvarName, cv->defaultString, cv->cvarFlags );
}
}
/*
=================
UI_UpdateCvars
=================
*/
void UI_UpdateCvars( void ) {
int i;
cvarTable_t *cv;
for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {
trap_Cvar_Update( cv->vmCvar );
}
}

View file

@ -1,419 +1,419 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
MAIN MENU
=======================================================================
*/
#include "ui_local.h"
#define ID_SINGLEPLAYER 10
#define ID_MULTIPLAYER 11
#define ID_SETUP 12
#define ID_DEMOS 13
#define ID_CINEMATICS 14
#define ID_TEAMARENA 15
#define ID_MODS 16
#define ID_EXIT 17
#define MAIN_BANNER_MODEL "models/mapobjects/banner/banner5.md3"
#define MAIN_MENU_VERTICAL_SPACING 34
typedef struct {
menuframework_s menu;
menutext_s singleplayer;
menutext_s multiplayer;
menutext_s setup;
menutext_s demos;
menutext_s cinematics;
menutext_s teamArena;
menutext_s mods;
menutext_s exit;
qhandle_t bannerModel;
} mainmenu_t;
static mainmenu_t s_main;
typedef struct {
menuframework_s menu;
char errorMessage[4096];
} errorMessage_t;
static errorMessage_t s_errorMessage;
/*
=================
MainMenu_ExitAction
=================
*/
static void MainMenu_ExitAction( qboolean result ) {
if( !result ) {
return;
}
UI_PopMenu();
UI_CreditMenu();
}
/*
=================
Main_MenuEvent
=================
*/
void Main_MenuEvent (void* ptr, int event) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_SINGLEPLAYER:
UI_SPLevelMenu();
break;
case ID_MULTIPLAYER:
UI_ArenaServersMenu();
break;
case ID_SETUP:
UI_SetupMenu();
break;
case ID_DEMOS:
UI_DemosMenu();
break;
case ID_CINEMATICS:
UI_CinematicsMenu();
break;
case ID_MODS:
UI_ModsMenu();
break;
case ID_TEAMARENA:
trap_Cvar_Set( "fs_game", "missionpack");
trap_Cmd_ExecuteText( EXEC_APPEND, "vid_restart;" );
break;
case ID_EXIT:
UI_ConfirmMenu( "EXIT GAME?", NULL, MainMenu_ExitAction );
break;
}
}
/*
===============
MainMenu_Cache
===============
*/
void MainMenu_Cache( void ) {
s_main.bannerModel = trap_R_RegisterModel( MAIN_BANNER_MODEL );
}
sfxHandle_t ErrorMessage_Key(int key)
{
trap_Cvar_Set( "com_errorMessage", "" );
UI_MainMenu();
return (menu_null_sound);
}
/*
===============
Main_MenuDraw
TTimo: this function is common to the main menu and errorMessage menu
===============
*/
static void Main_MenuDraw( void ) {
refdef_t refdef;
refEntity_t ent;
vec3_t origin;
vec3_t angles;
float adjust;
float x, y, w, h;
vec4_t color = {0.5, 0, 0, 1};
// setup the refdef
memset( &refdef, 0, sizeof( refdef ) );
refdef.rdflags = RDF_NOWORLDMODEL;
AxisClear( refdef.viewaxis );
x = 0;
y = 0;
w = 640;
h = 120;
UI_AdjustFrom640( &x, &y, &w, &h );
refdef.x = x;
refdef.y = y;
refdef.width = w;
refdef.height = h;
adjust = 0; // JDC: Kenneth asked me to stop this 1.0 * sin( (float)uis.realtime / 1000 );
refdef.fov_x = 60 + adjust;
refdef.fov_y = 19.6875 + adjust;
refdef.time = uis.realtime;
origin[0] = 300;
origin[1] = 0;
origin[2] = -32;
trap_R_ClearScene();
// add the model
memset( &ent, 0, sizeof(ent) );
adjust = 5.0 * sin( (float)uis.realtime / 5000 );
VectorSet( angles, 0, 180 + adjust, 0 );
AnglesToAxis( angles, ent.axis );
ent.hModel = s_main.bannerModel;
VectorCopy( origin, ent.origin );
VectorCopy( origin, ent.lightingOrigin );
ent.renderfx = RF_LIGHTING_ORIGIN | RF_NOSHADOW;
VectorCopy( ent.origin, ent.oldorigin );
trap_R_AddRefEntityToScene( &ent );
trap_R_RenderScene( &refdef );
if (strlen(s_errorMessage.errorMessage))
{
UI_DrawProportionalString_AutoWrapped( 320, 192, 600, 20, s_errorMessage.errorMessage, UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
}
else
{
// standard menu drawing
Menu_Draw( &s_main.menu );
}
if (uis.demoversion) {
UI_DrawProportionalString( 320, 372, "DEMO FOR MATURE AUDIENCES DEMO", UI_CENTER|UI_SMALLFONT, color );
UI_DrawString( 320, 400, "Quake III Arena(c) 1999-2000, Id Software, Inc. All Rights Reserved", UI_CENTER|UI_SMALLFONT, color );
} else {
UI_DrawString( 320, 450, "Quake III Arena(c) 1999-2000, Id Software, Inc. All Rights Reserved", UI_CENTER|UI_SMALLFONT, color );
}
}
/*
===============
UI_TeamArenaExists
===============
*/
static qboolean UI_TeamArenaExists( void ) {
int numdirs;
char dirlist[2048];
char *dirptr;
char *descptr;
int i;
int dirlen;
numdirs = trap_FS_GetFileList( "$modlist", "", dirlist, sizeof(dirlist) );
dirptr = dirlist;
for( i = 0; i < numdirs; i++ ) {
dirlen = strlen( dirptr ) + 1;
descptr = dirptr + dirlen;
if (Q_stricmp(dirptr, "missionpack") == 0) {
return qtrue;
}
dirptr += dirlen + strlen(descptr) + 1;
}
return qfalse;
}
/*
===============
UI_MainMenu
The main menu only comes up when not in a game,
so make sure that the attract loop server is down
and that local cinematics are killed
===============
*/
void UI_MainMenu( void ) {
int y;
qboolean teamArena = qfalse;
int style = UI_CENTER | UI_DROPSHADOW;
trap_Cvar_Set( "sv_killserver", "1" );
if( !uis.demoversion && !ui_cdkeychecked.integer ) {
char key[17];
trap_GetCDKey( key, sizeof(key) );
if( trap_VerifyCDKey( key, NULL ) == qfalse ) {
UI_CDKeyMenu();
return;
}
}
memset( &s_main, 0 ,sizeof(mainmenu_t) );
memset( &s_errorMessage, 0 ,sizeof(errorMessage_t) );
// com_errorMessage would need that too
MainMenu_Cache();
trap_Cvar_VariableStringBuffer( "com_errorMessage", s_errorMessage.errorMessage, sizeof(s_errorMessage.errorMessage) );
if (strlen(s_errorMessage.errorMessage))
{
s_errorMessage.menu.draw = Main_MenuDraw;
s_errorMessage.menu.key = ErrorMessage_Key;
s_errorMessage.menu.fullscreen = qtrue;
s_errorMessage.menu.wrapAround = qtrue;
s_errorMessage.menu.showlogo = qtrue;
trap_Key_SetCatcher( KEYCATCH_UI );
uis.menusp = 0;
UI_PushMenu ( &s_errorMessage.menu );
return;
}
s_main.menu.draw = Main_MenuDraw;
s_main.menu.fullscreen = qtrue;
s_main.menu.wrapAround = qtrue;
s_main.menu.showlogo = qtrue;
y = 134;
s_main.singleplayer.generic.type = MTYPE_PTEXT;
s_main.singleplayer.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_main.singleplayer.generic.x = 320;
s_main.singleplayer.generic.y = y;
s_main.singleplayer.generic.id = ID_SINGLEPLAYER;
s_main.singleplayer.generic.callback = Main_MenuEvent;
s_main.singleplayer.string = "SINGLE PLAYER";
s_main.singleplayer.color = color_red;
s_main.singleplayer.style = style;
y += MAIN_MENU_VERTICAL_SPACING;
s_main.multiplayer.generic.type = MTYPE_PTEXT;
s_main.multiplayer.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_main.multiplayer.generic.x = 320;
s_main.multiplayer.generic.y = y;
s_main.multiplayer.generic.id = ID_MULTIPLAYER;
s_main.multiplayer.generic.callback = Main_MenuEvent;
s_main.multiplayer.string = "MULTIPLAYER";
s_main.multiplayer.color = color_red;
s_main.multiplayer.style = style;
y += MAIN_MENU_VERTICAL_SPACING;
s_main.setup.generic.type = MTYPE_PTEXT;
s_main.setup.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_main.setup.generic.x = 320;
s_main.setup.generic.y = y;
s_main.setup.generic.id = ID_SETUP;
s_main.setup.generic.callback = Main_MenuEvent;
s_main.setup.string = "SETUP";
s_main.setup.color = color_red;
s_main.setup.style = style;
y += MAIN_MENU_VERTICAL_SPACING;
s_main.demos.generic.type = MTYPE_PTEXT;
s_main.demos.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_main.demos.generic.x = 320;
s_main.demos.generic.y = y;
s_main.demos.generic.id = ID_DEMOS;
s_main.demos.generic.callback = Main_MenuEvent;
s_main.demos.string = "DEMOS";
s_main.demos.color = color_red;
s_main.demos.style = style;
y += MAIN_MENU_VERTICAL_SPACING;
s_main.cinematics.generic.type = MTYPE_PTEXT;
s_main.cinematics.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_main.cinematics.generic.x = 320;
s_main.cinematics.generic.y = y;
s_main.cinematics.generic.id = ID_CINEMATICS;
s_main.cinematics.generic.callback = Main_MenuEvent;
s_main.cinematics.string = "CINEMATICS";
s_main.cinematics.color = color_red;
s_main.cinematics.style = style;
if (UI_TeamArenaExists()) {
teamArena = qtrue;
y += MAIN_MENU_VERTICAL_SPACING;
s_main.teamArena.generic.type = MTYPE_PTEXT;
s_main.teamArena.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_main.teamArena.generic.x = 320;
s_main.teamArena.generic.y = y;
s_main.teamArena.generic.id = ID_TEAMARENA;
s_main.teamArena.generic.callback = Main_MenuEvent;
s_main.teamArena.string = "TEAM ARENA";
s_main.teamArena.color = color_red;
s_main.teamArena.style = style;
}
y += MAIN_MENU_VERTICAL_SPACING;
s_main.mods.generic.type = MTYPE_PTEXT;
s_main.mods.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_main.mods.generic.x = 320;
s_main.mods.generic.y = y;
s_main.mods.generic.id = ID_MODS;
s_main.mods.generic.callback = Main_MenuEvent;
s_main.mods.string = "MODS";
s_main.mods.color = color_red;
s_main.mods.style = style;
y += MAIN_MENU_VERTICAL_SPACING;
s_main.exit.generic.type = MTYPE_PTEXT;
s_main.exit.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_main.exit.generic.x = 320;
s_main.exit.generic.y = y;
s_main.exit.generic.id = ID_EXIT;
s_main.exit.generic.callback = Main_MenuEvent;
s_main.exit.string = "EXIT";
s_main.exit.color = color_red;
s_main.exit.style = style;
Menu_AddItem( &s_main.menu, &s_main.singleplayer );
Menu_AddItem( &s_main.menu, &s_main.multiplayer );
Menu_AddItem( &s_main.menu, &s_main.setup );
Menu_AddItem( &s_main.menu, &s_main.demos );
Menu_AddItem( &s_main.menu, &s_main.cinematics );
if (teamArena) {
Menu_AddItem( &s_main.menu, &s_main.teamArena );
}
Menu_AddItem( &s_main.menu, &s_main.mods );
Menu_AddItem( &s_main.menu, &s_main.exit );
trap_Key_SetCatcher( KEYCATCH_UI );
uis.menusp = 0;
UI_PushMenu ( &s_main.menu );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
MAIN MENU
=======================================================================
*/
#include "ui_local.h"
#define ID_SINGLEPLAYER 10
#define ID_MULTIPLAYER 11
#define ID_SETUP 12
#define ID_DEMOS 13
#define ID_CINEMATICS 14
#define ID_TEAMARENA 15
#define ID_MODS 16
#define ID_EXIT 17
#define MAIN_BANNER_MODEL "models/mapobjects/banner/banner5.md3"
#define MAIN_MENU_VERTICAL_SPACING 34
typedef struct {
menuframework_s menu;
menutext_s singleplayer;
menutext_s multiplayer;
menutext_s setup;
menutext_s demos;
menutext_s cinematics;
menutext_s teamArena;
menutext_s mods;
menutext_s exit;
qhandle_t bannerModel;
} mainmenu_t;
static mainmenu_t s_main;
typedef struct {
menuframework_s menu;
char errorMessage[4096];
} errorMessage_t;
static errorMessage_t s_errorMessage;
/*
=================
MainMenu_ExitAction
=================
*/
static void MainMenu_ExitAction( qboolean result ) {
if( !result ) {
return;
}
UI_PopMenu();
UI_CreditMenu();
}
/*
=================
Main_MenuEvent
=================
*/
void Main_MenuEvent (void* ptr, int event) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_SINGLEPLAYER:
UI_SPLevelMenu();
break;
case ID_MULTIPLAYER:
UI_ArenaServersMenu();
break;
case ID_SETUP:
UI_SetupMenu();
break;
case ID_DEMOS:
UI_DemosMenu();
break;
case ID_CINEMATICS:
UI_CinematicsMenu();
break;
case ID_MODS:
UI_ModsMenu();
break;
case ID_TEAMARENA:
trap_Cvar_Set( "fs_game", "missionpack");
trap_Cmd_ExecuteText( EXEC_APPEND, "vid_restart;" );
break;
case ID_EXIT:
UI_ConfirmMenu( "EXIT GAME?", NULL, MainMenu_ExitAction );
break;
}
}
/*
===============
MainMenu_Cache
===============
*/
void MainMenu_Cache( void ) {
s_main.bannerModel = trap_R_RegisterModel( MAIN_BANNER_MODEL );
}
sfxHandle_t ErrorMessage_Key(int key)
{
trap_Cvar_Set( "com_errorMessage", "" );
UI_MainMenu();
return (menu_null_sound);
}
/*
===============
Main_MenuDraw
TTimo: this function is common to the main menu and errorMessage menu
===============
*/
static void Main_MenuDraw( void ) {
refdef_t refdef;
refEntity_t ent;
vec3_t origin;
vec3_t angles;
float adjust;
float x, y, w, h;
vec4_t color = {0.5, 0, 0, 1};
// setup the refdef
memset( &refdef, 0, sizeof( refdef ) );
refdef.rdflags = RDF_NOWORLDMODEL;
AxisClear( refdef.viewaxis );
x = 0;
y = 0;
w = 640;
h = 120;
UI_AdjustFrom640( &x, &y, &w, &h );
refdef.x = x;
refdef.y = y;
refdef.width = w;
refdef.height = h;
adjust = 0; // JDC: Kenneth asked me to stop this 1.0 * sin( (float)uis.realtime / 1000 );
refdef.fov_x = 60 + adjust;
refdef.fov_y = 19.6875 + adjust;
refdef.time = uis.realtime;
origin[0] = 300;
origin[1] = 0;
origin[2] = -32;
trap_R_ClearScene();
// add the model
memset( &ent, 0, sizeof(ent) );
adjust = 5.0 * sin( (float)uis.realtime / 5000 );
VectorSet( angles, 0, 180 + adjust, 0 );
AnglesToAxis( angles, ent.axis );
ent.hModel = s_main.bannerModel;
VectorCopy( origin, ent.origin );
VectorCopy( origin, ent.lightingOrigin );
ent.renderfx = RF_LIGHTING_ORIGIN | RF_NOSHADOW;
VectorCopy( ent.origin, ent.oldorigin );
trap_R_AddRefEntityToScene( &ent );
trap_R_RenderScene( &refdef );
if (strlen(s_errorMessage.errorMessage))
{
UI_DrawProportionalString_AutoWrapped( 320, 192, 600, 20, s_errorMessage.errorMessage, UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
}
else
{
// standard menu drawing
Menu_Draw( &s_main.menu );
}
if (uis.demoversion) {
UI_DrawProportionalString( 320, 372, "DEMO FOR MATURE AUDIENCES DEMO", UI_CENTER|UI_SMALLFONT, color );
UI_DrawString( 320, 400, "Quake III Arena(c) 1999-2000, Id Software, Inc. All Rights Reserved", UI_CENTER|UI_SMALLFONT, color );
} else {
UI_DrawString( 320, 450, "Quake III Arena(c) 1999-2000, Id Software, Inc. All Rights Reserved", UI_CENTER|UI_SMALLFONT, color );
}
}
/*
===============
UI_TeamArenaExists
===============
*/
static qboolean UI_TeamArenaExists( void ) {
int numdirs;
char dirlist[2048];
char *dirptr;
char *descptr;
int i;
int dirlen;
numdirs = trap_FS_GetFileList( "$modlist", "", dirlist, sizeof(dirlist) );
dirptr = dirlist;
for( i = 0; i < numdirs; i++ ) {
dirlen = strlen( dirptr ) + 1;
descptr = dirptr + dirlen;
if (Q_stricmp(dirptr, "missionpack") == 0) {
return qtrue;
}
dirptr += dirlen + strlen(descptr) + 1;
}
return qfalse;
}
/*
===============
UI_MainMenu
The main menu only comes up when not in a game,
so make sure that the attract loop server is down
and that local cinematics are killed
===============
*/
void UI_MainMenu( void ) {
int y;
qboolean teamArena = qfalse;
int style = UI_CENTER | UI_DROPSHADOW;
trap_Cvar_Set( "sv_killserver", "1" );
if( !uis.demoversion && !ui_cdkeychecked.integer ) {
char key[17];
trap_GetCDKey( key, sizeof(key) );
if( trap_VerifyCDKey( key, NULL ) == qfalse ) {
UI_CDKeyMenu();
return;
}
}
memset( &s_main, 0 ,sizeof(mainmenu_t) );
memset( &s_errorMessage, 0 ,sizeof(errorMessage_t) );
// com_errorMessage would need that too
MainMenu_Cache();
trap_Cvar_VariableStringBuffer( "com_errorMessage", s_errorMessage.errorMessage, sizeof(s_errorMessage.errorMessage) );
if (strlen(s_errorMessage.errorMessage))
{
s_errorMessage.menu.draw = Main_MenuDraw;
s_errorMessage.menu.key = ErrorMessage_Key;
s_errorMessage.menu.fullscreen = qtrue;
s_errorMessage.menu.wrapAround = qtrue;
s_errorMessage.menu.showlogo = qtrue;
trap_Key_SetCatcher( KEYCATCH_UI );
uis.menusp = 0;
UI_PushMenu ( &s_errorMessage.menu );
return;
}
s_main.menu.draw = Main_MenuDraw;
s_main.menu.fullscreen = qtrue;
s_main.menu.wrapAround = qtrue;
s_main.menu.showlogo = qtrue;
y = 134;
s_main.singleplayer.generic.type = MTYPE_PTEXT;
s_main.singleplayer.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_main.singleplayer.generic.x = 320;
s_main.singleplayer.generic.y = y;
s_main.singleplayer.generic.id = ID_SINGLEPLAYER;
s_main.singleplayer.generic.callback = Main_MenuEvent;
s_main.singleplayer.string = "SINGLE PLAYER";
s_main.singleplayer.color = color_red;
s_main.singleplayer.style = style;
y += MAIN_MENU_VERTICAL_SPACING;
s_main.multiplayer.generic.type = MTYPE_PTEXT;
s_main.multiplayer.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_main.multiplayer.generic.x = 320;
s_main.multiplayer.generic.y = y;
s_main.multiplayer.generic.id = ID_MULTIPLAYER;
s_main.multiplayer.generic.callback = Main_MenuEvent;
s_main.multiplayer.string = "MULTIPLAYER";
s_main.multiplayer.color = color_red;
s_main.multiplayer.style = style;
y += MAIN_MENU_VERTICAL_SPACING;
s_main.setup.generic.type = MTYPE_PTEXT;
s_main.setup.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_main.setup.generic.x = 320;
s_main.setup.generic.y = y;
s_main.setup.generic.id = ID_SETUP;
s_main.setup.generic.callback = Main_MenuEvent;
s_main.setup.string = "SETUP";
s_main.setup.color = color_red;
s_main.setup.style = style;
y += MAIN_MENU_VERTICAL_SPACING;
s_main.demos.generic.type = MTYPE_PTEXT;
s_main.demos.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_main.demos.generic.x = 320;
s_main.demos.generic.y = y;
s_main.demos.generic.id = ID_DEMOS;
s_main.demos.generic.callback = Main_MenuEvent;
s_main.demos.string = "DEMOS";
s_main.demos.color = color_red;
s_main.demos.style = style;
y += MAIN_MENU_VERTICAL_SPACING;
s_main.cinematics.generic.type = MTYPE_PTEXT;
s_main.cinematics.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_main.cinematics.generic.x = 320;
s_main.cinematics.generic.y = y;
s_main.cinematics.generic.id = ID_CINEMATICS;
s_main.cinematics.generic.callback = Main_MenuEvent;
s_main.cinematics.string = "CINEMATICS";
s_main.cinematics.color = color_red;
s_main.cinematics.style = style;
if (UI_TeamArenaExists()) {
teamArena = qtrue;
y += MAIN_MENU_VERTICAL_SPACING;
s_main.teamArena.generic.type = MTYPE_PTEXT;
s_main.teamArena.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_main.teamArena.generic.x = 320;
s_main.teamArena.generic.y = y;
s_main.teamArena.generic.id = ID_TEAMARENA;
s_main.teamArena.generic.callback = Main_MenuEvent;
s_main.teamArena.string = "TEAM ARENA";
s_main.teamArena.color = color_red;
s_main.teamArena.style = style;
}
y += MAIN_MENU_VERTICAL_SPACING;
s_main.mods.generic.type = MTYPE_PTEXT;
s_main.mods.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_main.mods.generic.x = 320;
s_main.mods.generic.y = y;
s_main.mods.generic.id = ID_MODS;
s_main.mods.generic.callback = Main_MenuEvent;
s_main.mods.string = "MODS";
s_main.mods.color = color_red;
s_main.mods.style = style;
y += MAIN_MENU_VERTICAL_SPACING;
s_main.exit.generic.type = MTYPE_PTEXT;
s_main.exit.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_main.exit.generic.x = 320;
s_main.exit.generic.y = y;
s_main.exit.generic.id = ID_EXIT;
s_main.exit.generic.callback = Main_MenuEvent;
s_main.exit.string = "EXIT";
s_main.exit.color = color_red;
s_main.exit.style = style;
Menu_AddItem( &s_main.menu, &s_main.singleplayer );
Menu_AddItem( &s_main.menu, &s_main.multiplayer );
Menu_AddItem( &s_main.menu, &s_main.setup );
Menu_AddItem( &s_main.menu, &s_main.demos );
Menu_AddItem( &s_main.menu, &s_main.cinematics );
if (teamArena) {
Menu_AddItem( &s_main.menu, &s_main.teamArena );
}
Menu_AddItem( &s_main.menu, &s_main.mods );
Menu_AddItem( &s_main.menu, &s_main.exit );
trap_Key_SetCatcher( KEYCATCH_UI );
uis.menusp = 0;
UI_PushMenu ( &s_main.menu );
}

View file

@ -1,439 +1,439 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#include "ui_local.h"
/*
===================
MField_Draw
Handles horizontal scrolling and cursor blinking
x, y, are in pixels
===================
*/
void MField_Draw( mfield_t *edit, int x, int y, int style, vec4_t color ) {
int len;
int charw;
int drawLen;
int prestep;
int cursorChar;
char str[MAX_STRING_CHARS];
drawLen = edit->widthInChars;
len = strlen( edit->buffer ) + 1;
// guarantee that cursor will be visible
if ( len <= drawLen ) {
prestep = 0;
} else {
if ( edit->scroll + drawLen > len ) {
edit->scroll = len - drawLen;
if ( edit->scroll < 0 ) {
edit->scroll = 0;
}
}
prestep = edit->scroll;
}
if ( prestep + drawLen > len ) {
drawLen = len - prestep;
}
// extract <drawLen> characters from the field at <prestep>
if ( drawLen >= MAX_STRING_CHARS ) {
trap_Error( "drawLen >= MAX_STRING_CHARS" );
}
memcpy( str, edit->buffer + prestep, drawLen );
str[ drawLen ] = 0;
UI_DrawString( x, y, str, style, color );
// draw the cursor
if (!(style & UI_PULSE)) {
return;
}
if ( trap_Key_GetOverstrikeMode() ) {
cursorChar = 11;
} else {
cursorChar = 10;
}
style &= ~UI_PULSE;
style |= UI_BLINK;
if (style & UI_SMALLFONT)
{
charw = SMALLCHAR_WIDTH;
}
else if (style & UI_GIANTFONT)
{
charw = GIANTCHAR_WIDTH;
}
else
{
charw = BIGCHAR_WIDTH;
}
if (style & UI_CENTER)
{
len = strlen(str);
x = x - len*charw/2;
}
else if (style & UI_RIGHT)
{
len = strlen(str);
x = x - len*charw;
}
UI_DrawChar( x + ( edit->cursor - prestep ) * charw, y, cursorChar, style & ~(UI_CENTER|UI_RIGHT), color );
}
/*
================
MField_Paste
================
*/
void MField_Paste( mfield_t *edit ) {
char pasteBuffer[64];
int pasteLen, i;
trap_GetClipboardData( pasteBuffer, 64 );
// send as if typed, so insert / overstrike works properly
pasteLen = strlen( pasteBuffer );
for ( i = 0 ; i < pasteLen ; i++ ) {
MField_CharEvent( edit, pasteBuffer[i] );
}
}
/*
=================
MField_KeyDownEvent
Performs the basic line editing functions for the console,
in-game talk, and menu fields
Key events are used for non-printable characters, others are gotten from char events.
=================
*/
void MField_KeyDownEvent( mfield_t *edit, int key ) {
int len;
// shift-insert is paste
if ( ( ( key == K_INS ) || ( key == K_KP_INS ) ) && trap_Key_IsDown( K_SHIFT ) ) {
MField_Paste( edit );
return;
}
len = strlen( edit->buffer );
if ( key == K_DEL || key == K_KP_DEL ) {
if ( edit->cursor < len ) {
memmove( edit->buffer + edit->cursor,
edit->buffer + edit->cursor + 1, len - edit->cursor );
}
return;
}
if ( key == K_RIGHTARROW || key == K_KP_RIGHTARROW )
{
if ( edit->cursor < len ) {
edit->cursor++;
}
if ( edit->cursor >= edit->scroll + edit->widthInChars && edit->cursor <= len )
{
edit->scroll++;
}
return;
}
if ( key == K_LEFTARROW || key == K_KP_LEFTARROW )
{
if ( edit->cursor > 0 ) {
edit->cursor--;
}
if ( edit->cursor < edit->scroll )
{
edit->scroll--;
}
return;
}
if ( key == K_HOME || key == K_KP_HOME || ( tolower(key) == 'a' && trap_Key_IsDown( K_CTRL ) ) ) {
edit->cursor = 0;
edit->scroll = 0;
return;
}
if ( key == K_END || key == K_KP_END || ( tolower(key) == 'e' && trap_Key_IsDown( K_CTRL ) ) ) {
edit->cursor = len;
edit->scroll = len - edit->widthInChars + 1;
if (edit->scroll < 0)
edit->scroll = 0;
return;
}
if ( key == K_INS || key == K_KP_INS ) {
trap_Key_SetOverstrikeMode( !trap_Key_GetOverstrikeMode() );
return;
}
}
/*
==================
MField_CharEvent
==================
*/
void MField_CharEvent( mfield_t *edit, int ch ) {
int len;
if ( ch == 'v' - 'a' + 1 ) { // ctrl-v is paste
MField_Paste( edit );
return;
}
if ( ch == 'c' - 'a' + 1 ) { // ctrl-c clears the field
MField_Clear( edit );
return;
}
len = strlen( edit->buffer );
if ( ch == 'h' - 'a' + 1 ) { // ctrl-h is backspace
if ( edit->cursor > 0 ) {
memmove( edit->buffer + edit->cursor - 1,
edit->buffer + edit->cursor, len + 1 - edit->cursor );
edit->cursor--;
if ( edit->cursor < edit->scroll )
{
edit->scroll--;
}
}
return;
}
if ( ch == 'a' - 'a' + 1 ) { // ctrl-a is home
edit->cursor = 0;
edit->scroll = 0;
return;
}
if ( ch == 'e' - 'a' + 1 ) { // ctrl-e is end
edit->cursor = len;
edit->scroll = edit->cursor - edit->widthInChars + 1;
if (edit->scroll < 0)
edit->scroll = 0;
return;
}
//
// ignore any other non printable chars
//
if ( ch < 32 ) {
return;
}
if ( !trap_Key_GetOverstrikeMode() ) {
if ((edit->cursor == MAX_EDIT_LINE - 1) || (edit->maxchars && edit->cursor >= edit->maxchars))
return;
} else {
// insert mode
if (( len == MAX_EDIT_LINE - 1 ) || (edit->maxchars && len >= edit->maxchars))
return;
memmove( edit->buffer + edit->cursor + 1, edit->buffer + edit->cursor, len + 1 - edit->cursor );
}
edit->buffer[edit->cursor] = ch;
if (!edit->maxchars || edit->cursor < edit->maxchars-1)
edit->cursor++;
if ( edit->cursor >= edit->widthInChars )
{
edit->scroll++;
}
if ( edit->cursor == len + 1) {
edit->buffer[edit->cursor] = 0;
}
}
/*
==================
MField_Clear
==================
*/
void MField_Clear( mfield_t *edit ) {
edit->buffer[0] = 0;
edit->cursor = 0;
edit->scroll = 0;
}
/*
==================
MenuField_Init
==================
*/
void MenuField_Init( menufield_s* m ) {
int l;
int w;
int h;
MField_Clear( &m->field );
if (m->generic.flags & QMF_SMALLFONT)
{
w = SMALLCHAR_WIDTH;
h = SMALLCHAR_HEIGHT;
}
else
{
w = BIGCHAR_WIDTH;
h = BIGCHAR_HEIGHT;
}
if (m->generic.name) {
l = (strlen( m->generic.name )+1) * w;
}
else {
l = 0;
}
m->generic.left = m->generic.x - l;
m->generic.top = m->generic.y;
m->generic.right = m->generic.x + w + m->field.widthInChars*w;
m->generic.bottom = m->generic.y + h;
}
/*
==================
MenuField_Draw
==================
*/
void MenuField_Draw( menufield_s *f )
{
int x;
int y;
int w;
int h;
int style;
qboolean focus;
float *color;
x = f->generic.x;
y = f->generic.y;
if (f->generic.flags & QMF_SMALLFONT)
{
w = SMALLCHAR_WIDTH;
h = SMALLCHAR_HEIGHT;
style = UI_SMALLFONT;
}
else
{
w = BIGCHAR_WIDTH;
h = BIGCHAR_HEIGHT;
style = UI_BIGFONT;
}
if (Menu_ItemAtCursor( f->generic.parent ) == f) {
focus = qtrue;
style |= UI_PULSE;
}
else {
focus = qfalse;
}
if (f->generic.flags & QMF_GRAYED)
color = text_color_disabled;
else if (focus)
color = text_color_highlight;
else
color = text_color_normal;
if ( focus )
{
// draw cursor
UI_FillRect( f->generic.left, f->generic.top, f->generic.right-f->generic.left+1, f->generic.bottom-f->generic.top+1, listbar_color );
UI_DrawChar( x, y, 13, UI_CENTER|UI_BLINK|style, color);
}
if ( f->generic.name ) {
UI_DrawString( x - w, y, f->generic.name, style|UI_RIGHT, color );
}
MField_Draw( &f->field, x + w, y, style, color );
}
/*
==================
MenuField_Key
==================
*/
sfxHandle_t MenuField_Key( menufield_s* m, int* key )
{
int keycode;
keycode = *key;
switch ( keycode )
{
case K_KP_ENTER:
case K_ENTER:
case K_JOY1:
case K_JOY2:
case K_JOY3:
case K_JOY4:
// have enter go to next cursor point
*key = K_TAB;
break;
case K_TAB:
case K_KP_DOWNARROW:
case K_DOWNARROW:
case K_KP_UPARROW:
case K_UPARROW:
break;
default:
if ( keycode & K_CHAR_FLAG )
{
keycode &= ~K_CHAR_FLAG;
if ((m->generic.flags & QMF_UPPERCASE) && Q_islower( keycode ))
keycode -= 'a' - 'A';
else if ((m->generic.flags & QMF_LOWERCASE) && Q_isupper( keycode ))
keycode -= 'A' - 'a';
else if ((m->generic.flags & QMF_NUMBERSONLY) && Q_isalpha( keycode ))
return (menu_buzz_sound);
MField_CharEvent( &m->field, keycode);
}
else
MField_KeyDownEvent( &m->field, keycode );
break;
}
return (0);
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#include "ui_local.h"
/*
===================
MField_Draw
Handles horizontal scrolling and cursor blinking
x, y, are in pixels
===================
*/
void MField_Draw( mfield_t *edit, int x, int y, int style, vec4_t color ) {
int len;
int charw;
int drawLen;
int prestep;
int cursorChar;
char str[MAX_STRING_CHARS];
drawLen = edit->widthInChars;
len = strlen( edit->buffer ) + 1;
// guarantee that cursor will be visible
if ( len <= drawLen ) {
prestep = 0;
} else {
if ( edit->scroll + drawLen > len ) {
edit->scroll = len - drawLen;
if ( edit->scroll < 0 ) {
edit->scroll = 0;
}
}
prestep = edit->scroll;
}
if ( prestep + drawLen > len ) {
drawLen = len - prestep;
}
// extract <drawLen> characters from the field at <prestep>
if ( drawLen >= MAX_STRING_CHARS ) {
trap_Error( "drawLen >= MAX_STRING_CHARS" );
}
memcpy( str, edit->buffer + prestep, drawLen );
str[ drawLen ] = 0;
UI_DrawString( x, y, str, style, color );
// draw the cursor
if (!(style & UI_PULSE)) {
return;
}
if ( trap_Key_GetOverstrikeMode() ) {
cursorChar = 11;
} else {
cursorChar = 10;
}
style &= ~UI_PULSE;
style |= UI_BLINK;
if (style & UI_SMALLFONT)
{
charw = SMALLCHAR_WIDTH;
}
else if (style & UI_GIANTFONT)
{
charw = GIANTCHAR_WIDTH;
}
else
{
charw = BIGCHAR_WIDTH;
}
if (style & UI_CENTER)
{
len = strlen(str);
x = x - len*charw/2;
}
else if (style & UI_RIGHT)
{
len = strlen(str);
x = x - len*charw;
}
UI_DrawChar( x + ( edit->cursor - prestep ) * charw, y, cursorChar, style & ~(UI_CENTER|UI_RIGHT), color );
}
/*
================
MField_Paste
================
*/
void MField_Paste( mfield_t *edit ) {
char pasteBuffer[64];
int pasteLen, i;
trap_GetClipboardData( pasteBuffer, 64 );
// send as if typed, so insert / overstrike works properly
pasteLen = strlen( pasteBuffer );
for ( i = 0 ; i < pasteLen ; i++ ) {
MField_CharEvent( edit, pasteBuffer[i] );
}
}
/*
=================
MField_KeyDownEvent
Performs the basic line editing functions for the console,
in-game talk, and menu fields
Key events are used for non-printable characters, others are gotten from char events.
=================
*/
void MField_KeyDownEvent( mfield_t *edit, int key ) {
int len;
// shift-insert is paste
if ( ( ( key == K_INS ) || ( key == K_KP_INS ) ) && trap_Key_IsDown( K_SHIFT ) ) {
MField_Paste( edit );
return;
}
len = strlen( edit->buffer );
if ( key == K_DEL || key == K_KP_DEL ) {
if ( edit->cursor < len ) {
memmove( edit->buffer + edit->cursor,
edit->buffer + edit->cursor + 1, len - edit->cursor );
}
return;
}
if ( key == K_RIGHTARROW || key == K_KP_RIGHTARROW )
{
if ( edit->cursor < len ) {
edit->cursor++;
}
if ( edit->cursor >= edit->scroll + edit->widthInChars && edit->cursor <= len )
{
edit->scroll++;
}
return;
}
if ( key == K_LEFTARROW || key == K_KP_LEFTARROW )
{
if ( edit->cursor > 0 ) {
edit->cursor--;
}
if ( edit->cursor < edit->scroll )
{
edit->scroll--;
}
return;
}
if ( key == K_HOME || key == K_KP_HOME || ( tolower(key) == 'a' && trap_Key_IsDown( K_CTRL ) ) ) {
edit->cursor = 0;
edit->scroll = 0;
return;
}
if ( key == K_END || key == K_KP_END || ( tolower(key) == 'e' && trap_Key_IsDown( K_CTRL ) ) ) {
edit->cursor = len;
edit->scroll = len - edit->widthInChars + 1;
if (edit->scroll < 0)
edit->scroll = 0;
return;
}
if ( key == K_INS || key == K_KP_INS ) {
trap_Key_SetOverstrikeMode( !trap_Key_GetOverstrikeMode() );
return;
}
}
/*
==================
MField_CharEvent
==================
*/
void MField_CharEvent( mfield_t *edit, int ch ) {
int len;
if ( ch == 'v' - 'a' + 1 ) { // ctrl-v is paste
MField_Paste( edit );
return;
}
if ( ch == 'c' - 'a' + 1 ) { // ctrl-c clears the field
MField_Clear( edit );
return;
}
len = strlen( edit->buffer );
if ( ch == 'h' - 'a' + 1 ) { // ctrl-h is backspace
if ( edit->cursor > 0 ) {
memmove( edit->buffer + edit->cursor - 1,
edit->buffer + edit->cursor, len + 1 - edit->cursor );
edit->cursor--;
if ( edit->cursor < edit->scroll )
{
edit->scroll--;
}
}
return;
}
if ( ch == 'a' - 'a' + 1 ) { // ctrl-a is home
edit->cursor = 0;
edit->scroll = 0;
return;
}
if ( ch == 'e' - 'a' + 1 ) { // ctrl-e is end
edit->cursor = len;
edit->scroll = edit->cursor - edit->widthInChars + 1;
if (edit->scroll < 0)
edit->scroll = 0;
return;
}
//
// ignore any other non printable chars
//
if ( ch < 32 ) {
return;
}
if ( !trap_Key_GetOverstrikeMode() ) {
if ((edit->cursor == MAX_EDIT_LINE - 1) || (edit->maxchars && edit->cursor >= edit->maxchars))
return;
} else {
// insert mode
if (( len == MAX_EDIT_LINE - 1 ) || (edit->maxchars && len >= edit->maxchars))
return;
memmove( edit->buffer + edit->cursor + 1, edit->buffer + edit->cursor, len + 1 - edit->cursor );
}
edit->buffer[edit->cursor] = ch;
if (!edit->maxchars || edit->cursor < edit->maxchars-1)
edit->cursor++;
if ( edit->cursor >= edit->widthInChars )
{
edit->scroll++;
}
if ( edit->cursor == len + 1) {
edit->buffer[edit->cursor] = 0;
}
}
/*
==================
MField_Clear
==================
*/
void MField_Clear( mfield_t *edit ) {
edit->buffer[0] = 0;
edit->cursor = 0;
edit->scroll = 0;
}
/*
==================
MenuField_Init
==================
*/
void MenuField_Init( menufield_s* m ) {
int l;
int w;
int h;
MField_Clear( &m->field );
if (m->generic.flags & QMF_SMALLFONT)
{
w = SMALLCHAR_WIDTH;
h = SMALLCHAR_HEIGHT;
}
else
{
w = BIGCHAR_WIDTH;
h = BIGCHAR_HEIGHT;
}
if (m->generic.name) {
l = (strlen( m->generic.name )+1) * w;
}
else {
l = 0;
}
m->generic.left = m->generic.x - l;
m->generic.top = m->generic.y;
m->generic.right = m->generic.x + w + m->field.widthInChars*w;
m->generic.bottom = m->generic.y + h;
}
/*
==================
MenuField_Draw
==================
*/
void MenuField_Draw( menufield_s *f )
{
int x;
int y;
int w;
int h;
int style;
qboolean focus;
float *color;
x = f->generic.x;
y = f->generic.y;
if (f->generic.flags & QMF_SMALLFONT)
{
w = SMALLCHAR_WIDTH;
h = SMALLCHAR_HEIGHT;
style = UI_SMALLFONT;
}
else
{
w = BIGCHAR_WIDTH;
h = BIGCHAR_HEIGHT;
style = UI_BIGFONT;
}
if (Menu_ItemAtCursor( f->generic.parent ) == f) {
focus = qtrue;
style |= UI_PULSE;
}
else {
focus = qfalse;
}
if (f->generic.flags & QMF_GRAYED)
color = text_color_disabled;
else if (focus)
color = text_color_highlight;
else
color = text_color_normal;
if ( focus )
{
// draw cursor
UI_FillRect( f->generic.left, f->generic.top, f->generic.right-f->generic.left+1, f->generic.bottom-f->generic.top+1, listbar_color );
UI_DrawChar( x, y, 13, UI_CENTER|UI_BLINK|style, color);
}
if ( f->generic.name ) {
UI_DrawString( x - w, y, f->generic.name, style|UI_RIGHT, color );
}
MField_Draw( &f->field, x + w, y, style, color );
}
/*
==================
MenuField_Key
==================
*/
sfxHandle_t MenuField_Key( menufield_s* m, int* key )
{
int keycode;
keycode = *key;
switch ( keycode )
{
case K_KP_ENTER:
case K_ENTER:
case K_JOY1:
case K_JOY2:
case K_JOY3:
case K_JOY4:
// have enter go to next cursor point
*key = K_TAB;
break;
case K_TAB:
case K_KP_DOWNARROW:
case K_DOWNARROW:
case K_KP_UPARROW:
case K_UPARROW:
break;
default:
if ( keycode & K_CHAR_FLAG )
{
keycode &= ~K_CHAR_FLAG;
if ((m->generic.flags & QMF_UPPERCASE) && Q_islower( keycode ))
keycode -= 'a' - 'A';
else if ((m->generic.flags & QMF_LOWERCASE) && Q_isupper( keycode ))
keycode -= 'A' - 'a';
else if ((m->generic.flags & QMF_NUMBERSONLY) && Q_isalpha( keycode ))
return (menu_buzz_sound);
MField_CharEvent( &m->field, keycode);
}
else
MField_KeyDownEvent( &m->field, keycode );
break;
}
return (0);
}

View file

@ -1,283 +1,283 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#include "ui_local.h"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ART_FIGHT0 "menu/art/load_0"
#define ART_FIGHT1 "menu/art/load_1"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define MAX_MODS 64
#define NAMEBUFSIZE ( MAX_MODS * 48 )
#define GAMEBUFSIZE ( MAX_MODS * 16 )
#define ID_BACK 10
#define ID_GO 11
#define ID_LIST 12
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menulist_s list;
menubitmap_s back;
menubitmap_s go;
char description[NAMEBUFSIZE];
char fs_game[GAMEBUFSIZE];
char *descriptionPtr;
char *fs_gamePtr;
char *descriptionList[MAX_MODS];
char *fs_gameList[MAX_MODS];
} mods_t;
static mods_t s_mods;
/*
===============
UI_Mods_MenuEvent
===============
*/
static void UI_Mods_MenuEvent( void *ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch ( ((menucommon_s*)ptr)->id ) {
case ID_GO:
trap_Cvar_Set( "fs_game", s_mods.fs_gameList[s_mods.list.curvalue] );
trap_Cmd_ExecuteText( EXEC_APPEND, "vid_restart;" );
UI_PopMenu();
break;
case ID_BACK:
UI_PopMenu();
break;
}
}
/*
===============
UI_Mods_ParseInfos
===============
*/
static void UI_Mods_ParseInfos( char *modDir, char *modDesc ) {
s_mods.fs_gameList[s_mods.list.numitems] = s_mods.fs_gamePtr;
Q_strncpyz( s_mods.fs_gamePtr, modDir, 16 );
s_mods.descriptionList[s_mods.list.numitems] = s_mods.descriptionPtr;
Q_strncpyz( s_mods.descriptionPtr, modDesc, 48 );
s_mods.list.itemnames[s_mods.list.numitems] = s_mods.descriptionPtr;
s_mods.descriptionPtr += strlen( s_mods.descriptionPtr ) + 1;
s_mods.fs_gamePtr += strlen( s_mods.fs_gamePtr ) + 1;
s_mods.list.numitems++;
}
#if 0 // bk001204 - unused
/*
===============
UI_Mods_LoadModsFromFile
===============
*/
static void UI_Mods_LoadModsFromFile( char *filename ) {
int len;
fileHandle_t f;
char buf[1024];
len = trap_FS_FOpenFile( filename, &f, FS_READ );
if ( !f ) {
trap_Print( va( S_COLOR_RED "file not found: %s\n", filename ) );
return;
}
if ( len >= sizeof(buf) ) {
trap_Print( va( S_COLOR_RED "file too large: %s is %i, max allowed is %i", filename, len, sizeof(buf) ) );
trap_FS_FCloseFile( f );
return;
}
trap_FS_Read( buf, len, f );
buf[len] = 0;
trap_FS_FCloseFile( f );
len = strlen( filename );
if( !Q_stricmp(filename + len - 4,".mod") ) {
filename[len-4] = '\0';
}
UI_Mods_ParseInfos( filename, buf );
}
#endif
/*
===============
UI_Mods_LoadMods
===============
*/
static void UI_Mods_LoadMods( void ) {
int numdirs;
char dirlist[2048];
char *dirptr;
char *descptr;
int i;
int dirlen;
s_mods.list.itemnames = (const char **)s_mods.descriptionList;
s_mods.descriptionPtr = s_mods.description;
s_mods.fs_gamePtr = s_mods.fs_game;
// always start off with baseq3
s_mods.list.numitems = 1;
s_mods.list.itemnames[0] = s_mods.descriptionList[0] = "Quake III Arena";
s_mods.fs_gameList[0] = "";
numdirs = trap_FS_GetFileList( "$modlist", "", dirlist, sizeof(dirlist) );
dirptr = dirlist;
for( i = 0; i < numdirs; i++ ) {
dirlen = strlen( dirptr ) + 1;
descptr = dirptr + dirlen;
UI_Mods_ParseInfos( dirptr, descptr);
dirptr += dirlen + strlen(descptr) + 1;
}
trap_Print( va( "%i mods parsed\n", s_mods.list.numitems ) );
if (s_mods.list.numitems > MAX_MODS) {
s_mods.list.numitems = MAX_MODS;
}
}
/*
===============
UI_Mods_MenuInit
===============
*/
static void UI_Mods_MenuInit( void ) {
UI_ModsMenu_Cache();
memset( &s_mods, 0 ,sizeof(mods_t) );
s_mods.menu.wrapAround = qtrue;
s_mods.menu.fullscreen = qtrue;
s_mods.banner.generic.type = MTYPE_BTEXT;
s_mods.banner.generic.x = 320;
s_mods.banner.generic.y = 16;
s_mods.banner.string = "MODS";
s_mods.banner.color = color_white;
s_mods.banner.style = UI_CENTER;
s_mods.framel.generic.type = MTYPE_BITMAP;
s_mods.framel.generic.name = ART_FRAMEL;
s_mods.framel.generic.flags = QMF_INACTIVE;
s_mods.framel.generic.x = 0;
s_mods.framel.generic.y = 78;
s_mods.framel.width = 256;
s_mods.framel.height = 329;
s_mods.framer.generic.type = MTYPE_BITMAP;
s_mods.framer.generic.name = ART_FRAMER;
s_mods.framer.generic.flags = QMF_INACTIVE;
s_mods.framer.generic.x = 376;
s_mods.framer.generic.y = 76;
s_mods.framer.width = 256;
s_mods.framer.height = 334;
s_mods.back.generic.type = MTYPE_BITMAP;
s_mods.back.generic.name = ART_BACK0;
s_mods.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_mods.back.generic.id = ID_BACK;
s_mods.back.generic.callback = UI_Mods_MenuEvent;
s_mods.back.generic.x = 0;
s_mods.back.generic.y = 480-64;
s_mods.back.width = 128;
s_mods.back.height = 64;
s_mods.back.focuspic = ART_BACK1;
s_mods.go.generic.type = MTYPE_BITMAP;
s_mods.go.generic.name = ART_FIGHT0;
s_mods.go.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
s_mods.go.generic.id = ID_GO;
s_mods.go.generic.callback = UI_Mods_MenuEvent;
s_mods.go.generic.x = 640;
s_mods.go.generic.y = 480-64;
s_mods.go.width = 128;
s_mods.go.height = 64;
s_mods.go.focuspic = ART_FIGHT1;
// scan for mods
s_mods.list.generic.type = MTYPE_SCROLLLIST;
s_mods.list.generic.flags = QMF_PULSEIFFOCUS|QMF_CENTER_JUSTIFY;
s_mods.list.generic.callback = UI_Mods_MenuEvent;
s_mods.list.generic.id = ID_LIST;
s_mods.list.generic.x = 320;
s_mods.list.generic.y = 130;
s_mods.list.width = 48;
s_mods.list.height = 14;
UI_Mods_LoadMods();
Menu_AddItem( &s_mods.menu, &s_mods.banner );
Menu_AddItem( &s_mods.menu, &s_mods.framel );
Menu_AddItem( &s_mods.menu, &s_mods.framer );
Menu_AddItem( &s_mods.menu, &s_mods.list );
Menu_AddItem( &s_mods.menu, &s_mods.back );
Menu_AddItem( &s_mods.menu, &s_mods.go );
}
/*
=================
UI_Mods_Cache
=================
*/
void UI_ModsMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
trap_R_RegisterShaderNoMip( ART_FIGHT0 );
trap_R_RegisterShaderNoMip( ART_FIGHT1 );
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
}
/*
===============
UI_ModsMenu
===============
*/
void UI_ModsMenu( void ) {
UI_Mods_MenuInit();
UI_PushMenu( &s_mods.menu );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#include "ui_local.h"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ART_FIGHT0 "menu/art/load_0"
#define ART_FIGHT1 "menu/art/load_1"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define MAX_MODS 64
#define NAMEBUFSIZE ( MAX_MODS * 48 )
#define GAMEBUFSIZE ( MAX_MODS * 16 )
#define ID_BACK 10
#define ID_GO 11
#define ID_LIST 12
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menulist_s list;
menubitmap_s back;
menubitmap_s go;
char description[NAMEBUFSIZE];
char fs_game[GAMEBUFSIZE];
char *descriptionPtr;
char *fs_gamePtr;
char *descriptionList[MAX_MODS];
char *fs_gameList[MAX_MODS];
} mods_t;
static mods_t s_mods;
/*
===============
UI_Mods_MenuEvent
===============
*/
static void UI_Mods_MenuEvent( void *ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch ( ((menucommon_s*)ptr)->id ) {
case ID_GO:
trap_Cvar_Set( "fs_game", s_mods.fs_gameList[s_mods.list.curvalue] );
trap_Cmd_ExecuteText( EXEC_APPEND, "vid_restart;" );
UI_PopMenu();
break;
case ID_BACK:
UI_PopMenu();
break;
}
}
/*
===============
UI_Mods_ParseInfos
===============
*/
static void UI_Mods_ParseInfos( char *modDir, char *modDesc ) {
s_mods.fs_gameList[s_mods.list.numitems] = s_mods.fs_gamePtr;
Q_strncpyz( s_mods.fs_gamePtr, modDir, 16 );
s_mods.descriptionList[s_mods.list.numitems] = s_mods.descriptionPtr;
Q_strncpyz( s_mods.descriptionPtr, modDesc, 48 );
s_mods.list.itemnames[s_mods.list.numitems] = s_mods.descriptionPtr;
s_mods.descriptionPtr += strlen( s_mods.descriptionPtr ) + 1;
s_mods.fs_gamePtr += strlen( s_mods.fs_gamePtr ) + 1;
s_mods.list.numitems++;
}
#if 0 // bk001204 - unused
/*
===============
UI_Mods_LoadModsFromFile
===============
*/
static void UI_Mods_LoadModsFromFile( char *filename ) {
int len;
fileHandle_t f;
char buf[1024];
len = trap_FS_FOpenFile( filename, &f, FS_READ );
if ( !f ) {
trap_Print( va( S_COLOR_RED "file not found: %s\n", filename ) );
return;
}
if ( len >= sizeof(buf) ) {
trap_Print( va( S_COLOR_RED "file too large: %s is %i, max allowed is %i", filename, len, sizeof(buf) ) );
trap_FS_FCloseFile( f );
return;
}
trap_FS_Read( buf, len, f );
buf[len] = 0;
trap_FS_FCloseFile( f );
len = strlen( filename );
if( !Q_stricmp(filename + len - 4,".mod") ) {
filename[len-4] = '\0';
}
UI_Mods_ParseInfos( filename, buf );
}
#endif
/*
===============
UI_Mods_LoadMods
===============
*/
static void UI_Mods_LoadMods( void ) {
int numdirs;
char dirlist[2048];
char *dirptr;
char *descptr;
int i;
int dirlen;
s_mods.list.itemnames = (const char **)s_mods.descriptionList;
s_mods.descriptionPtr = s_mods.description;
s_mods.fs_gamePtr = s_mods.fs_game;
// always start off with baseq3
s_mods.list.numitems = 1;
s_mods.list.itemnames[0] = s_mods.descriptionList[0] = "Quake III Arena";
s_mods.fs_gameList[0] = "";
numdirs = trap_FS_GetFileList( "$modlist", "", dirlist, sizeof(dirlist) );
dirptr = dirlist;
for( i = 0; i < numdirs; i++ ) {
dirlen = strlen( dirptr ) + 1;
descptr = dirptr + dirlen;
UI_Mods_ParseInfos( dirptr, descptr);
dirptr += dirlen + strlen(descptr) + 1;
}
trap_Print( va( "%i mods parsed\n", s_mods.list.numitems ) );
if (s_mods.list.numitems > MAX_MODS) {
s_mods.list.numitems = MAX_MODS;
}
}
/*
===============
UI_Mods_MenuInit
===============
*/
static void UI_Mods_MenuInit( void ) {
UI_ModsMenu_Cache();
memset( &s_mods, 0 ,sizeof(mods_t) );
s_mods.menu.wrapAround = qtrue;
s_mods.menu.fullscreen = qtrue;
s_mods.banner.generic.type = MTYPE_BTEXT;
s_mods.banner.generic.x = 320;
s_mods.banner.generic.y = 16;
s_mods.banner.string = "MODS";
s_mods.banner.color = color_white;
s_mods.banner.style = UI_CENTER;
s_mods.framel.generic.type = MTYPE_BITMAP;
s_mods.framel.generic.name = ART_FRAMEL;
s_mods.framel.generic.flags = QMF_INACTIVE;
s_mods.framel.generic.x = 0;
s_mods.framel.generic.y = 78;
s_mods.framel.width = 256;
s_mods.framel.height = 329;
s_mods.framer.generic.type = MTYPE_BITMAP;
s_mods.framer.generic.name = ART_FRAMER;
s_mods.framer.generic.flags = QMF_INACTIVE;
s_mods.framer.generic.x = 376;
s_mods.framer.generic.y = 76;
s_mods.framer.width = 256;
s_mods.framer.height = 334;
s_mods.back.generic.type = MTYPE_BITMAP;
s_mods.back.generic.name = ART_BACK0;
s_mods.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_mods.back.generic.id = ID_BACK;
s_mods.back.generic.callback = UI_Mods_MenuEvent;
s_mods.back.generic.x = 0;
s_mods.back.generic.y = 480-64;
s_mods.back.width = 128;
s_mods.back.height = 64;
s_mods.back.focuspic = ART_BACK1;
s_mods.go.generic.type = MTYPE_BITMAP;
s_mods.go.generic.name = ART_FIGHT0;
s_mods.go.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
s_mods.go.generic.id = ID_GO;
s_mods.go.generic.callback = UI_Mods_MenuEvent;
s_mods.go.generic.x = 640;
s_mods.go.generic.y = 480-64;
s_mods.go.width = 128;
s_mods.go.height = 64;
s_mods.go.focuspic = ART_FIGHT1;
// scan for mods
s_mods.list.generic.type = MTYPE_SCROLLLIST;
s_mods.list.generic.flags = QMF_PULSEIFFOCUS|QMF_CENTER_JUSTIFY;
s_mods.list.generic.callback = UI_Mods_MenuEvent;
s_mods.list.generic.id = ID_LIST;
s_mods.list.generic.x = 320;
s_mods.list.generic.y = 130;
s_mods.list.width = 48;
s_mods.list.height = 14;
UI_Mods_LoadMods();
Menu_AddItem( &s_mods.menu, &s_mods.banner );
Menu_AddItem( &s_mods.menu, &s_mods.framel );
Menu_AddItem( &s_mods.menu, &s_mods.framer );
Menu_AddItem( &s_mods.menu, &s_mods.list );
Menu_AddItem( &s_mods.menu, &s_mods.back );
Menu_AddItem( &s_mods.menu, &s_mods.go );
}
/*
=================
UI_Mods_Cache
=================
*/
void UI_ModsMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
trap_R_RegisterShaderNoMip( ART_FIGHT0 );
trap_R_RegisterShaderNoMip( ART_FIGHT1 );
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
}
/*
===============
UI_ModsMenu
===============
*/
void UI_ModsMenu( void ) {
UI_Mods_MenuInit();
UI_PushMenu( &s_mods.menu );
}

View file

@ -1,281 +1,281 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
NETWORK OPTIONS MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ID_GRAPHICS 10
#define ID_DISPLAY 11
#define ID_SOUND 12
#define ID_NETWORK 13
#define ID_RATE 14
#define ID_BACK 15
static const char *rate_items[] = {
"<= 28.8K",
"33.6K",
"56K",
"ISDN",
"LAN/Cable/xDSL",
0
};
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menutext_s graphics;
menutext_s display;
menutext_s sound;
menutext_s network;
menulist_s rate;
menubitmap_s back;
} networkOptionsInfo_t;
static networkOptionsInfo_t networkOptionsInfo;
/*
=================
UI_NetworkOptionsMenu_Event
=================
*/
static void UI_NetworkOptionsMenu_Event( void* ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_GRAPHICS:
UI_PopMenu();
UI_GraphicsOptionsMenu();
break;
case ID_DISPLAY:
UI_PopMenu();
UI_DisplayOptionsMenu();
break;
case ID_SOUND:
UI_PopMenu();
UI_SoundOptionsMenu();
break;
case ID_NETWORK:
break;
case ID_RATE:
if( networkOptionsInfo.rate.curvalue == 0 ) {
trap_Cvar_SetValue( "rate", 2500 );
}
else if( networkOptionsInfo.rate.curvalue == 1 ) {
trap_Cvar_SetValue( "rate", 3000 );
}
else if( networkOptionsInfo.rate.curvalue == 2 ) {
trap_Cvar_SetValue( "rate", 4000 );
}
else if( networkOptionsInfo.rate.curvalue == 3 ) {
trap_Cvar_SetValue( "rate", 5000 );
}
else if( networkOptionsInfo.rate.curvalue == 4 ) {
trap_Cvar_SetValue( "rate", 25000 );
}
break;
case ID_BACK:
UI_PopMenu();
break;
}
}
/*
===============
UI_NetworkOptionsMenu_Init
===============
*/
static void UI_NetworkOptionsMenu_Init( void ) {
int y;
int rate;
memset( &networkOptionsInfo, 0, sizeof(networkOptionsInfo) );
UI_NetworkOptionsMenu_Cache();
networkOptionsInfo.menu.wrapAround = qtrue;
networkOptionsInfo.menu.fullscreen = qtrue;
networkOptionsInfo.banner.generic.type = MTYPE_BTEXT;
networkOptionsInfo.banner.generic.flags = QMF_CENTER_JUSTIFY;
networkOptionsInfo.banner.generic.x = 320;
networkOptionsInfo.banner.generic.y = 16;
networkOptionsInfo.banner.string = "SYSTEM SETUP";
networkOptionsInfo.banner.color = color_white;
networkOptionsInfo.banner.style = UI_CENTER;
networkOptionsInfo.framel.generic.type = MTYPE_BITMAP;
networkOptionsInfo.framel.generic.name = ART_FRAMEL;
networkOptionsInfo.framel.generic.flags = QMF_INACTIVE;
networkOptionsInfo.framel.generic.x = 0;
networkOptionsInfo.framel.generic.y = 78;
networkOptionsInfo.framel.width = 256;
networkOptionsInfo.framel.height = 329;
networkOptionsInfo.framer.generic.type = MTYPE_BITMAP;
networkOptionsInfo.framer.generic.name = ART_FRAMER;
networkOptionsInfo.framer.generic.flags = QMF_INACTIVE;
networkOptionsInfo.framer.generic.x = 376;
networkOptionsInfo.framer.generic.y = 76;
networkOptionsInfo.framer.width = 256;
networkOptionsInfo.framer.height = 334;
networkOptionsInfo.graphics.generic.type = MTYPE_PTEXT;
networkOptionsInfo.graphics.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
networkOptionsInfo.graphics.generic.id = ID_GRAPHICS;
networkOptionsInfo.graphics.generic.callback = UI_NetworkOptionsMenu_Event;
networkOptionsInfo.graphics.generic.x = 216;
networkOptionsInfo.graphics.generic.y = 240 - 2 * PROP_HEIGHT;
networkOptionsInfo.graphics.string = "GRAPHICS";
networkOptionsInfo.graphics.style = UI_RIGHT;
networkOptionsInfo.graphics.color = color_red;
networkOptionsInfo.display.generic.type = MTYPE_PTEXT;
networkOptionsInfo.display.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
networkOptionsInfo.display.generic.id = ID_DISPLAY;
networkOptionsInfo.display.generic.callback = UI_NetworkOptionsMenu_Event;
networkOptionsInfo.display.generic.x = 216;
networkOptionsInfo.display.generic.y = 240 - PROP_HEIGHT;
networkOptionsInfo.display.string = "DISPLAY";
networkOptionsInfo.display.style = UI_RIGHT;
networkOptionsInfo.display.color = color_red;
networkOptionsInfo.sound.generic.type = MTYPE_PTEXT;
networkOptionsInfo.sound.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
networkOptionsInfo.sound.generic.id = ID_SOUND;
networkOptionsInfo.sound.generic.callback = UI_NetworkOptionsMenu_Event;
networkOptionsInfo.sound.generic.x = 216;
networkOptionsInfo.sound.generic.y = 240;
networkOptionsInfo.sound.string = "SOUND";
networkOptionsInfo.sound.style = UI_RIGHT;
networkOptionsInfo.sound.color = color_red;
networkOptionsInfo.network.generic.type = MTYPE_PTEXT;
networkOptionsInfo.network.generic.flags = QMF_RIGHT_JUSTIFY;
networkOptionsInfo.network.generic.id = ID_NETWORK;
networkOptionsInfo.network.generic.callback = UI_NetworkOptionsMenu_Event;
networkOptionsInfo.network.generic.x = 216;
networkOptionsInfo.network.generic.y = 240 + PROP_HEIGHT;
networkOptionsInfo.network.string = "NETWORK";
networkOptionsInfo.network.style = UI_RIGHT;
networkOptionsInfo.network.color = color_red;
y = 240 - 1 * (BIGCHAR_HEIGHT+2);
networkOptionsInfo.rate.generic.type = MTYPE_SPINCONTROL;
networkOptionsInfo.rate.generic.name = "Data Rate:";
networkOptionsInfo.rate.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
networkOptionsInfo.rate.generic.callback = UI_NetworkOptionsMenu_Event;
networkOptionsInfo.rate.generic.id = ID_RATE;
networkOptionsInfo.rate.generic.x = 400;
networkOptionsInfo.rate.generic.y = y;
networkOptionsInfo.rate.itemnames = rate_items;
networkOptionsInfo.back.generic.type = MTYPE_BITMAP;
networkOptionsInfo.back.generic.name = ART_BACK0;
networkOptionsInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
networkOptionsInfo.back.generic.callback = UI_NetworkOptionsMenu_Event;
networkOptionsInfo.back.generic.id = ID_BACK;
networkOptionsInfo.back.generic.x = 0;
networkOptionsInfo.back.generic.y = 480-64;
networkOptionsInfo.back.width = 128;
networkOptionsInfo.back.height = 64;
networkOptionsInfo.back.focuspic = ART_BACK1;
Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.banner );
Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.framel );
Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.framer );
Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.graphics );
Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.display );
Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.sound );
Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.network );
Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.rate );
Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.back );
rate = trap_Cvar_VariableValue( "rate" );
if( rate <= 2500 ) {
networkOptionsInfo.rate.curvalue = 0;
}
else if( rate <= 3000 ) {
networkOptionsInfo.rate.curvalue = 1;
}
else if( rate <= 4000 ) {
networkOptionsInfo.rate.curvalue = 2;
}
else if( rate <= 5000 ) {
networkOptionsInfo.rate.curvalue = 3;
}
else {
networkOptionsInfo.rate.curvalue = 4;
}
}
/*
===============
UI_NetworkOptionsMenu_Cache
===============
*/
void UI_NetworkOptionsMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
}
/*
===============
UI_NetworkOptionsMenu
===============
*/
void UI_NetworkOptionsMenu( void ) {
UI_NetworkOptionsMenu_Init();
UI_PushMenu( &networkOptionsInfo.menu );
Menu_SetCursorToItem( &networkOptionsInfo.menu, &networkOptionsInfo.network );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
NETWORK OPTIONS MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ID_GRAPHICS 10
#define ID_DISPLAY 11
#define ID_SOUND 12
#define ID_NETWORK 13
#define ID_RATE 14
#define ID_BACK 15
static const char *rate_items[] = {
"<= 28.8K",
"33.6K",
"56K",
"ISDN",
"LAN/Cable/xDSL",
0
};
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menutext_s graphics;
menutext_s display;
menutext_s sound;
menutext_s network;
menulist_s rate;
menubitmap_s back;
} networkOptionsInfo_t;
static networkOptionsInfo_t networkOptionsInfo;
/*
=================
UI_NetworkOptionsMenu_Event
=================
*/
static void UI_NetworkOptionsMenu_Event( void* ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_GRAPHICS:
UI_PopMenu();
UI_GraphicsOptionsMenu();
break;
case ID_DISPLAY:
UI_PopMenu();
UI_DisplayOptionsMenu();
break;
case ID_SOUND:
UI_PopMenu();
UI_SoundOptionsMenu();
break;
case ID_NETWORK:
break;
case ID_RATE:
if( networkOptionsInfo.rate.curvalue == 0 ) {
trap_Cvar_SetValue( "rate", 2500 );
}
else if( networkOptionsInfo.rate.curvalue == 1 ) {
trap_Cvar_SetValue( "rate", 3000 );
}
else if( networkOptionsInfo.rate.curvalue == 2 ) {
trap_Cvar_SetValue( "rate", 4000 );
}
else if( networkOptionsInfo.rate.curvalue == 3 ) {
trap_Cvar_SetValue( "rate", 5000 );
}
else if( networkOptionsInfo.rate.curvalue == 4 ) {
trap_Cvar_SetValue( "rate", 25000 );
}
break;
case ID_BACK:
UI_PopMenu();
break;
}
}
/*
===============
UI_NetworkOptionsMenu_Init
===============
*/
static void UI_NetworkOptionsMenu_Init( void ) {
int y;
int rate;
memset( &networkOptionsInfo, 0, sizeof(networkOptionsInfo) );
UI_NetworkOptionsMenu_Cache();
networkOptionsInfo.menu.wrapAround = qtrue;
networkOptionsInfo.menu.fullscreen = qtrue;
networkOptionsInfo.banner.generic.type = MTYPE_BTEXT;
networkOptionsInfo.banner.generic.flags = QMF_CENTER_JUSTIFY;
networkOptionsInfo.banner.generic.x = 320;
networkOptionsInfo.banner.generic.y = 16;
networkOptionsInfo.banner.string = "SYSTEM SETUP";
networkOptionsInfo.banner.color = color_white;
networkOptionsInfo.banner.style = UI_CENTER;
networkOptionsInfo.framel.generic.type = MTYPE_BITMAP;
networkOptionsInfo.framel.generic.name = ART_FRAMEL;
networkOptionsInfo.framel.generic.flags = QMF_INACTIVE;
networkOptionsInfo.framel.generic.x = 0;
networkOptionsInfo.framel.generic.y = 78;
networkOptionsInfo.framel.width = 256;
networkOptionsInfo.framel.height = 329;
networkOptionsInfo.framer.generic.type = MTYPE_BITMAP;
networkOptionsInfo.framer.generic.name = ART_FRAMER;
networkOptionsInfo.framer.generic.flags = QMF_INACTIVE;
networkOptionsInfo.framer.generic.x = 376;
networkOptionsInfo.framer.generic.y = 76;
networkOptionsInfo.framer.width = 256;
networkOptionsInfo.framer.height = 334;
networkOptionsInfo.graphics.generic.type = MTYPE_PTEXT;
networkOptionsInfo.graphics.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
networkOptionsInfo.graphics.generic.id = ID_GRAPHICS;
networkOptionsInfo.graphics.generic.callback = UI_NetworkOptionsMenu_Event;
networkOptionsInfo.graphics.generic.x = 216;
networkOptionsInfo.graphics.generic.y = 240 - 2 * PROP_HEIGHT;
networkOptionsInfo.graphics.string = "GRAPHICS";
networkOptionsInfo.graphics.style = UI_RIGHT;
networkOptionsInfo.graphics.color = color_red;
networkOptionsInfo.display.generic.type = MTYPE_PTEXT;
networkOptionsInfo.display.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
networkOptionsInfo.display.generic.id = ID_DISPLAY;
networkOptionsInfo.display.generic.callback = UI_NetworkOptionsMenu_Event;
networkOptionsInfo.display.generic.x = 216;
networkOptionsInfo.display.generic.y = 240 - PROP_HEIGHT;
networkOptionsInfo.display.string = "DISPLAY";
networkOptionsInfo.display.style = UI_RIGHT;
networkOptionsInfo.display.color = color_red;
networkOptionsInfo.sound.generic.type = MTYPE_PTEXT;
networkOptionsInfo.sound.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
networkOptionsInfo.sound.generic.id = ID_SOUND;
networkOptionsInfo.sound.generic.callback = UI_NetworkOptionsMenu_Event;
networkOptionsInfo.sound.generic.x = 216;
networkOptionsInfo.sound.generic.y = 240;
networkOptionsInfo.sound.string = "SOUND";
networkOptionsInfo.sound.style = UI_RIGHT;
networkOptionsInfo.sound.color = color_red;
networkOptionsInfo.network.generic.type = MTYPE_PTEXT;
networkOptionsInfo.network.generic.flags = QMF_RIGHT_JUSTIFY;
networkOptionsInfo.network.generic.id = ID_NETWORK;
networkOptionsInfo.network.generic.callback = UI_NetworkOptionsMenu_Event;
networkOptionsInfo.network.generic.x = 216;
networkOptionsInfo.network.generic.y = 240 + PROP_HEIGHT;
networkOptionsInfo.network.string = "NETWORK";
networkOptionsInfo.network.style = UI_RIGHT;
networkOptionsInfo.network.color = color_red;
y = 240 - 1 * (BIGCHAR_HEIGHT+2);
networkOptionsInfo.rate.generic.type = MTYPE_SPINCONTROL;
networkOptionsInfo.rate.generic.name = "Data Rate:";
networkOptionsInfo.rate.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
networkOptionsInfo.rate.generic.callback = UI_NetworkOptionsMenu_Event;
networkOptionsInfo.rate.generic.id = ID_RATE;
networkOptionsInfo.rate.generic.x = 400;
networkOptionsInfo.rate.generic.y = y;
networkOptionsInfo.rate.itemnames = rate_items;
networkOptionsInfo.back.generic.type = MTYPE_BITMAP;
networkOptionsInfo.back.generic.name = ART_BACK0;
networkOptionsInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
networkOptionsInfo.back.generic.callback = UI_NetworkOptionsMenu_Event;
networkOptionsInfo.back.generic.id = ID_BACK;
networkOptionsInfo.back.generic.x = 0;
networkOptionsInfo.back.generic.y = 480-64;
networkOptionsInfo.back.width = 128;
networkOptionsInfo.back.height = 64;
networkOptionsInfo.back.focuspic = ART_BACK1;
Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.banner );
Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.framel );
Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.framer );
Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.graphics );
Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.display );
Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.sound );
Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.network );
Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.rate );
Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.back );
rate = trap_Cvar_VariableValue( "rate" );
if( rate <= 2500 ) {
networkOptionsInfo.rate.curvalue = 0;
}
else if( rate <= 3000 ) {
networkOptionsInfo.rate.curvalue = 1;
}
else if( rate <= 4000 ) {
networkOptionsInfo.rate.curvalue = 2;
}
else if( rate <= 5000 ) {
networkOptionsInfo.rate.curvalue = 3;
}
else {
networkOptionsInfo.rate.curvalue = 4;
}
}
/*
===============
UI_NetworkOptionsMenu_Cache
===============
*/
void UI_NetworkOptionsMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
}
/*
===============
UI_NetworkOptionsMenu
===============
*/
void UI_NetworkOptionsMenu( void ) {
UI_NetworkOptionsMenu_Init();
UI_PushMenu( &networkOptionsInfo.menu );
Menu_SetCursorToItem( &networkOptionsInfo.menu, &networkOptionsInfo.network );
}

View file

@ -1,229 +1,229 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
/*
=======================================================================
SYSTEM CONFIGURATION MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ID_GRAPHICS 10
#define ID_DISPLAY 11
#define ID_SOUND 12
#define ID_NETWORK 13
#define ID_BACK 14
#define VERTICAL_SPACING 34
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menutext_s graphics;
menutext_s display;
menutext_s sound;
menutext_s network;
menubitmap_s back;
} optionsmenu_t;
static optionsmenu_t s_options;
/*
=================
Options_Event
=================
*/
static void Options_Event( void* ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_GRAPHICS:
UI_GraphicsOptionsMenu();
break;
case ID_DISPLAY:
UI_DisplayOptionsMenu();
break;
case ID_SOUND:
UI_SoundOptionsMenu();
break;
case ID_NETWORK:
UI_NetworkOptionsMenu();
break;
case ID_BACK:
UI_PopMenu();
break;
}
}
/*
===============
SystemConfig_Cache
===============
*/
void SystemConfig_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
}
/*
===============
Options_MenuInit
===============
*/
void Options_MenuInit( void ) {
int y;
uiClientState_t cstate;
memset( &s_options, 0, sizeof(optionsmenu_t) );
SystemConfig_Cache();
s_options.menu.wrapAround = qtrue;
trap_GetClientState( &cstate );
if ( cstate.connState >= CA_CONNECTED ) {
s_options.menu.fullscreen = qfalse;
}
else {
s_options.menu.fullscreen = qtrue;
}
s_options.banner.generic.type = MTYPE_BTEXT;
s_options.banner.generic.flags = QMF_CENTER_JUSTIFY;
s_options.banner.generic.x = 320;
s_options.banner.generic.y = 16;
s_options.banner.string = "SYSTEM SETUP";
s_options.banner.color = color_white;
s_options.banner.style = UI_CENTER;
s_options.framel.generic.type = MTYPE_BITMAP;
s_options.framel.generic.name = ART_FRAMEL;
s_options.framel.generic.flags = QMF_INACTIVE;
s_options.framel.generic.x = 8;
s_options.framel.generic.y = 76;
s_options.framel.width = 256;
s_options.framel.height = 334;
s_options.framer.generic.type = MTYPE_BITMAP;
s_options.framer.generic.name = ART_FRAMER;
s_options.framer.generic.flags = QMF_INACTIVE;
s_options.framer.generic.x = 376;
s_options.framer.generic.y = 76;
s_options.framer.width = 256;
s_options.framer.height = 334;
y = 168;
s_options.graphics.generic.type = MTYPE_PTEXT;
s_options.graphics.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_options.graphics.generic.callback = Options_Event;
s_options.graphics.generic.id = ID_GRAPHICS;
s_options.graphics.generic.x = 320;
s_options.graphics.generic.y = y;
s_options.graphics.string = "GRAPHICS";
s_options.graphics.color = color_red;
s_options.graphics.style = UI_CENTER;
y += VERTICAL_SPACING;
s_options.display.generic.type = MTYPE_PTEXT;
s_options.display.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_options.display.generic.callback = Options_Event;
s_options.display.generic.id = ID_DISPLAY;
s_options.display.generic.x = 320;
s_options.display.generic.y = y;
s_options.display.string = "DISPLAY";
s_options.display.color = color_red;
s_options.display.style = UI_CENTER;
y += VERTICAL_SPACING;
s_options.sound.generic.type = MTYPE_PTEXT;
s_options.sound.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_options.sound.generic.callback = Options_Event;
s_options.sound.generic.id = ID_SOUND;
s_options.sound.generic.x = 320;
s_options.sound.generic.y = y;
s_options.sound.string = "SOUND";
s_options.sound.color = color_red;
s_options.sound.style = UI_CENTER;
y += VERTICAL_SPACING;
s_options.network.generic.type = MTYPE_PTEXT;
s_options.network.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_options.network.generic.callback = Options_Event;
s_options.network.generic.id = ID_NETWORK;
s_options.network.generic.x = 320;
s_options.network.generic.y = y;
s_options.network.string = "NETWORK";
s_options.network.color = color_red;
s_options.network.style = UI_CENTER;
s_options.back.generic.type = MTYPE_BITMAP;
s_options.back.generic.name = ART_BACK0;
s_options.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_options.back.generic.callback = Options_Event;
s_options.back.generic.id = ID_BACK;
s_options.back.generic.x = 0;
s_options.back.generic.y = 480-64;
s_options.back.width = 128;
s_options.back.height = 64;
s_options.back.focuspic = ART_BACK1;
Menu_AddItem( &s_options.menu, ( void * ) &s_options.banner );
Menu_AddItem( &s_options.menu, ( void * ) &s_options.framel );
Menu_AddItem( &s_options.menu, ( void * ) &s_options.framer );
Menu_AddItem( &s_options.menu, ( void * ) &s_options.graphics );
Menu_AddItem( &s_options.menu, ( void * ) &s_options.display );
Menu_AddItem( &s_options.menu, ( void * ) &s_options.sound );
Menu_AddItem( &s_options.menu, ( void * ) &s_options.network );
Menu_AddItem( &s_options.menu, ( void * ) &s_options.back );
}
/*
===============
UI_SystemConfigMenu
===============
*/
void UI_SystemConfigMenu( void ) {
Options_MenuInit();
UI_PushMenu ( &s_options.menu );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
/*
=======================================================================
SYSTEM CONFIGURATION MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ID_GRAPHICS 10
#define ID_DISPLAY 11
#define ID_SOUND 12
#define ID_NETWORK 13
#define ID_BACK 14
#define VERTICAL_SPACING 34
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menutext_s graphics;
menutext_s display;
menutext_s sound;
menutext_s network;
menubitmap_s back;
} optionsmenu_t;
static optionsmenu_t s_options;
/*
=================
Options_Event
=================
*/
static void Options_Event( void* ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_GRAPHICS:
UI_GraphicsOptionsMenu();
break;
case ID_DISPLAY:
UI_DisplayOptionsMenu();
break;
case ID_SOUND:
UI_SoundOptionsMenu();
break;
case ID_NETWORK:
UI_NetworkOptionsMenu();
break;
case ID_BACK:
UI_PopMenu();
break;
}
}
/*
===============
SystemConfig_Cache
===============
*/
void SystemConfig_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
}
/*
===============
Options_MenuInit
===============
*/
void Options_MenuInit( void ) {
int y;
uiClientState_t cstate;
memset( &s_options, 0, sizeof(optionsmenu_t) );
SystemConfig_Cache();
s_options.menu.wrapAround = qtrue;
trap_GetClientState( &cstate );
if ( cstate.connState >= CA_CONNECTED ) {
s_options.menu.fullscreen = qfalse;
}
else {
s_options.menu.fullscreen = qtrue;
}
s_options.banner.generic.type = MTYPE_BTEXT;
s_options.banner.generic.flags = QMF_CENTER_JUSTIFY;
s_options.banner.generic.x = 320;
s_options.banner.generic.y = 16;
s_options.banner.string = "SYSTEM SETUP";
s_options.banner.color = color_white;
s_options.banner.style = UI_CENTER;
s_options.framel.generic.type = MTYPE_BITMAP;
s_options.framel.generic.name = ART_FRAMEL;
s_options.framel.generic.flags = QMF_INACTIVE;
s_options.framel.generic.x = 8;
s_options.framel.generic.y = 76;
s_options.framel.width = 256;
s_options.framel.height = 334;
s_options.framer.generic.type = MTYPE_BITMAP;
s_options.framer.generic.name = ART_FRAMER;
s_options.framer.generic.flags = QMF_INACTIVE;
s_options.framer.generic.x = 376;
s_options.framer.generic.y = 76;
s_options.framer.width = 256;
s_options.framer.height = 334;
y = 168;
s_options.graphics.generic.type = MTYPE_PTEXT;
s_options.graphics.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_options.graphics.generic.callback = Options_Event;
s_options.graphics.generic.id = ID_GRAPHICS;
s_options.graphics.generic.x = 320;
s_options.graphics.generic.y = y;
s_options.graphics.string = "GRAPHICS";
s_options.graphics.color = color_red;
s_options.graphics.style = UI_CENTER;
y += VERTICAL_SPACING;
s_options.display.generic.type = MTYPE_PTEXT;
s_options.display.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_options.display.generic.callback = Options_Event;
s_options.display.generic.id = ID_DISPLAY;
s_options.display.generic.x = 320;
s_options.display.generic.y = y;
s_options.display.string = "DISPLAY";
s_options.display.color = color_red;
s_options.display.style = UI_CENTER;
y += VERTICAL_SPACING;
s_options.sound.generic.type = MTYPE_PTEXT;
s_options.sound.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_options.sound.generic.callback = Options_Event;
s_options.sound.generic.id = ID_SOUND;
s_options.sound.generic.x = 320;
s_options.sound.generic.y = y;
s_options.sound.string = "SOUND";
s_options.sound.color = color_red;
s_options.sound.style = UI_CENTER;
y += VERTICAL_SPACING;
s_options.network.generic.type = MTYPE_PTEXT;
s_options.network.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_options.network.generic.callback = Options_Event;
s_options.network.generic.id = ID_NETWORK;
s_options.network.generic.x = 320;
s_options.network.generic.y = y;
s_options.network.string = "NETWORK";
s_options.network.color = color_red;
s_options.network.style = UI_CENTER;
s_options.back.generic.type = MTYPE_BITMAP;
s_options.back.generic.name = ART_BACK0;
s_options.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_options.back.generic.callback = Options_Event;
s_options.back.generic.id = ID_BACK;
s_options.back.generic.x = 0;
s_options.back.generic.y = 480-64;
s_options.back.width = 128;
s_options.back.height = 64;
s_options.back.focuspic = ART_BACK1;
Menu_AddItem( &s_options.menu, ( void * ) &s_options.banner );
Menu_AddItem( &s_options.menu, ( void * ) &s_options.framel );
Menu_AddItem( &s_options.menu, ( void * ) &s_options.framer );
Menu_AddItem( &s_options.menu, ( void * ) &s_options.graphics );
Menu_AddItem( &s_options.menu, ( void * ) &s_options.display );
Menu_AddItem( &s_options.menu, ( void * ) &s_options.sound );
Menu_AddItem( &s_options.menu, ( void * ) &s_options.network );
Menu_AddItem( &s_options.menu, ( void * ) &s_options.back );
}
/*
===============
UI_SystemConfigMenu
===============
*/
void UI_SystemConfigMenu( void ) {
Options_MenuInit();
UI_PushMenu ( &s_options.menu );
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,419 +1,419 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
GAME OPTIONS MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define PREFERENCES_X_POS 360
#define ID_CROSSHAIR 127
#define ID_SIMPLEITEMS 128
#define ID_HIGHQUALITYSKY 129
#define ID_EJECTINGBRASS 130
#define ID_WALLMARKS 131
#define ID_DYNAMICLIGHTS 132
#define ID_IDENTIFYTARGET 133
#define ID_SYNCEVERYFRAME 134
#define ID_FORCEMODEL 135
#define ID_DRAWTEAMOVERLAY 136
#define ID_ALLOWDOWNLOAD 137
#define ID_BACK 138
#define NUM_CROSSHAIRS 10
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menulist_s crosshair;
menuradiobutton_s simpleitems;
menuradiobutton_s brass;
menuradiobutton_s wallmarks;
menuradiobutton_s dynamiclights;
menuradiobutton_s identifytarget;
menuradiobutton_s highqualitysky;
menuradiobutton_s synceveryframe;
menuradiobutton_s forcemodel;
menulist_s drawteamoverlay;
menuradiobutton_s allowdownload;
menubitmap_s back;
qhandle_t crosshairShader[NUM_CROSSHAIRS];
} preferences_t;
static preferences_t s_preferences;
static const char *teamoverlay_names[] =
{
"off",
"upper right",
"lower right",
"lower left",
0
};
static void Preferences_SetMenuItems( void ) {
s_preferences.crosshair.curvalue = (int)trap_Cvar_VariableValue( "cg_drawCrosshair" ) % NUM_CROSSHAIRS;
s_preferences.simpleitems.curvalue = trap_Cvar_VariableValue( "cg_simpleItems" ) != 0;
s_preferences.brass.curvalue = trap_Cvar_VariableValue( "cg_brassTime" ) != 0;
s_preferences.wallmarks.curvalue = trap_Cvar_VariableValue( "cg_marks" ) != 0;
s_preferences.identifytarget.curvalue = trap_Cvar_VariableValue( "cg_drawCrosshairNames" ) != 0;
s_preferences.dynamiclights.curvalue = trap_Cvar_VariableValue( "r_dynamiclight" ) != 0;
s_preferences.highqualitysky.curvalue = trap_Cvar_VariableValue ( "r_fastsky" ) == 0;
s_preferences.synceveryframe.curvalue = trap_Cvar_VariableValue( "r_finish" ) != 0;
s_preferences.forcemodel.curvalue = trap_Cvar_VariableValue( "cg_forcemodel" ) != 0;
s_preferences.drawteamoverlay.curvalue = Com_Clamp( 0, 3, trap_Cvar_VariableValue( "cg_drawTeamOverlay" ) );
s_preferences.allowdownload.curvalue = trap_Cvar_VariableValue( "cl_allowDownload" ) != 0;
}
static void Preferences_Event( void* ptr, int notification ) {
if( notification != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_CROSSHAIR:
s_preferences.crosshair.curvalue++;
if( s_preferences.crosshair.curvalue == NUM_CROSSHAIRS ) {
s_preferences.crosshair.curvalue = 0;
}
trap_Cvar_SetValue( "cg_drawCrosshair", s_preferences.crosshair.curvalue );
break;
case ID_SIMPLEITEMS:
trap_Cvar_SetValue( "cg_simpleItems", s_preferences.simpleitems.curvalue );
break;
case ID_HIGHQUALITYSKY:
trap_Cvar_SetValue( "r_fastsky", !s_preferences.highqualitysky.curvalue );
break;
case ID_EJECTINGBRASS:
if ( s_preferences.brass.curvalue )
trap_Cvar_Reset( "cg_brassTime" );
else
trap_Cvar_SetValue( "cg_brassTime", 0 );
break;
case ID_WALLMARKS:
trap_Cvar_SetValue( "cg_marks", s_preferences.wallmarks.curvalue );
break;
case ID_DYNAMICLIGHTS:
trap_Cvar_SetValue( "r_dynamiclight", s_preferences.dynamiclights.curvalue );
break;
case ID_IDENTIFYTARGET:
trap_Cvar_SetValue( "cg_drawCrosshairNames", s_preferences.identifytarget.curvalue );
break;
case ID_SYNCEVERYFRAME:
trap_Cvar_SetValue( "r_finish", s_preferences.synceveryframe.curvalue );
break;
case ID_FORCEMODEL:
trap_Cvar_SetValue( "cg_forcemodel", s_preferences.forcemodel.curvalue );
break;
case ID_DRAWTEAMOVERLAY:
trap_Cvar_SetValue( "cg_drawTeamOverlay", s_preferences.drawteamoverlay.curvalue );
break;
case ID_ALLOWDOWNLOAD:
trap_Cvar_SetValue( "cl_allowDownload", s_preferences.allowdownload.curvalue );
trap_Cvar_SetValue( "sv_allowDownload", s_preferences.allowdownload.curvalue );
break;
case ID_BACK:
UI_PopMenu();
break;
}
}
/*
=================
Crosshair_Draw
=================
*/
static void Crosshair_Draw( void *self ) {
menulist_s *s;
float *color;
int x, y;
int style;
qboolean focus;
s = (menulist_s *)self;
x = s->generic.x;
y = s->generic.y;
style = UI_SMALLFONT;
focus = (s->generic.parent->cursor == s->generic.menuPosition);
if ( s->generic.flags & QMF_GRAYED )
color = text_color_disabled;
else if ( focus )
{
color = text_color_highlight;
style |= UI_PULSE;
}
else if ( s->generic.flags & QMF_BLINK )
{
color = text_color_highlight;
style |= UI_BLINK;
}
else
color = text_color_normal;
if ( focus )
{
// draw cursor
UI_FillRect( s->generic.left, s->generic.top, s->generic.right-s->generic.left+1, s->generic.bottom-s->generic.top+1, listbar_color );
UI_DrawChar( x, y, 13, UI_CENTER|UI_BLINK|UI_SMALLFONT, color);
}
UI_DrawString( x - SMALLCHAR_WIDTH, y, s->generic.name, style|UI_RIGHT, color );
if( !s->curvalue ) {
return;
}
UI_DrawHandlePic( x + SMALLCHAR_WIDTH, y - 4, 24, 24, s_preferences.crosshairShader[s->curvalue] );
}
static void Preferences_MenuInit( void ) {
int y;
memset( &s_preferences, 0 ,sizeof(preferences_t) );
Preferences_Cache();
s_preferences.menu.wrapAround = qtrue;
s_preferences.menu.fullscreen = qtrue;
s_preferences.banner.generic.type = MTYPE_BTEXT;
s_preferences.banner.generic.x = 320;
s_preferences.banner.generic.y = 16;
s_preferences.banner.string = "GAME OPTIONS";
s_preferences.banner.color = color_white;
s_preferences.banner.style = UI_CENTER;
s_preferences.framel.generic.type = MTYPE_BITMAP;
s_preferences.framel.generic.name = ART_FRAMEL;
s_preferences.framel.generic.flags = QMF_INACTIVE;
s_preferences.framel.generic.x = 0;
s_preferences.framel.generic.y = 78;
s_preferences.framel.width = 256;
s_preferences.framel.height = 329;
s_preferences.framer.generic.type = MTYPE_BITMAP;
s_preferences.framer.generic.name = ART_FRAMER;
s_preferences.framer.generic.flags = QMF_INACTIVE;
s_preferences.framer.generic.x = 376;
s_preferences.framer.generic.y = 76;
s_preferences.framer.width = 256;
s_preferences.framer.height = 334;
y = 144;
s_preferences.crosshair.generic.type = MTYPE_TEXT;
s_preferences.crosshair.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT|QMF_NODEFAULTINIT|QMF_OWNERDRAW;
s_preferences.crosshair.generic.x = PREFERENCES_X_POS;
s_preferences.crosshair.generic.y = y;
s_preferences.crosshair.generic.name = "Crosshair:";
s_preferences.crosshair.generic.callback = Preferences_Event;
s_preferences.crosshair.generic.ownerdraw = Crosshair_Draw;
s_preferences.crosshair.generic.id = ID_CROSSHAIR;
s_preferences.crosshair.generic.top = y - 4;
s_preferences.crosshair.generic.bottom = y + 20;
s_preferences.crosshair.generic.left = PREFERENCES_X_POS - ( ( strlen(s_preferences.crosshair.generic.name) + 1 ) * SMALLCHAR_WIDTH );
s_preferences.crosshair.generic.right = PREFERENCES_X_POS + 48;
y += BIGCHAR_HEIGHT+2+4;
s_preferences.simpleitems.generic.type = MTYPE_RADIOBUTTON;
s_preferences.simpleitems.generic.name = "Simple Items:";
s_preferences.simpleitems.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.simpleitems.generic.callback = Preferences_Event;
s_preferences.simpleitems.generic.id = ID_SIMPLEITEMS;
s_preferences.simpleitems.generic.x = PREFERENCES_X_POS;
s_preferences.simpleitems.generic.y = y;
y += BIGCHAR_HEIGHT;
s_preferences.wallmarks.generic.type = MTYPE_RADIOBUTTON;
s_preferences.wallmarks.generic.name = "Marks on Walls:";
s_preferences.wallmarks.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.wallmarks.generic.callback = Preferences_Event;
s_preferences.wallmarks.generic.id = ID_WALLMARKS;
s_preferences.wallmarks.generic.x = PREFERENCES_X_POS;
s_preferences.wallmarks.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.brass.generic.type = MTYPE_RADIOBUTTON;
s_preferences.brass.generic.name = "Ejecting Brass:";
s_preferences.brass.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.brass.generic.callback = Preferences_Event;
s_preferences.brass.generic.id = ID_EJECTINGBRASS;
s_preferences.brass.generic.x = PREFERENCES_X_POS;
s_preferences.brass.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.dynamiclights.generic.type = MTYPE_RADIOBUTTON;
s_preferences.dynamiclights.generic.name = "Dynamic Lights:";
s_preferences.dynamiclights.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.dynamiclights.generic.callback = Preferences_Event;
s_preferences.dynamiclights.generic.id = ID_DYNAMICLIGHTS;
s_preferences.dynamiclights.generic.x = PREFERENCES_X_POS;
s_preferences.dynamiclights.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.identifytarget.generic.type = MTYPE_RADIOBUTTON;
s_preferences.identifytarget.generic.name = "Identify Target:";
s_preferences.identifytarget.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.identifytarget.generic.callback = Preferences_Event;
s_preferences.identifytarget.generic.id = ID_IDENTIFYTARGET;
s_preferences.identifytarget.generic.x = PREFERENCES_X_POS;
s_preferences.identifytarget.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.highqualitysky.generic.type = MTYPE_RADIOBUTTON;
s_preferences.highqualitysky.generic.name = "High Quality Sky:";
s_preferences.highqualitysky.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.highqualitysky.generic.callback = Preferences_Event;
s_preferences.highqualitysky.generic.id = ID_HIGHQUALITYSKY;
s_preferences.highqualitysky.generic.x = PREFERENCES_X_POS;
s_preferences.highqualitysky.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.synceveryframe.generic.type = MTYPE_RADIOBUTTON;
s_preferences.synceveryframe.generic.name = "Sync Every Frame:";
s_preferences.synceveryframe.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.synceveryframe.generic.callback = Preferences_Event;
s_preferences.synceveryframe.generic.id = ID_SYNCEVERYFRAME;
s_preferences.synceveryframe.generic.x = PREFERENCES_X_POS;
s_preferences.synceveryframe.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.forcemodel.generic.type = MTYPE_RADIOBUTTON;
s_preferences.forcemodel.generic.name = "Force Player Models:";
s_preferences.forcemodel.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.forcemodel.generic.callback = Preferences_Event;
s_preferences.forcemodel.generic.id = ID_FORCEMODEL;
s_preferences.forcemodel.generic.x = PREFERENCES_X_POS;
s_preferences.forcemodel.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.drawteamoverlay.generic.type = MTYPE_SPINCONTROL;
s_preferences.drawteamoverlay.generic.name = "Draw Team Overlay:";
s_preferences.drawteamoverlay.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.drawteamoverlay.generic.callback = Preferences_Event;
s_preferences.drawteamoverlay.generic.id = ID_DRAWTEAMOVERLAY;
s_preferences.drawteamoverlay.generic.x = PREFERENCES_X_POS;
s_preferences.drawteamoverlay.generic.y = y;
s_preferences.drawteamoverlay.itemnames = teamoverlay_names;
y += BIGCHAR_HEIGHT+2;
s_preferences.allowdownload.generic.type = MTYPE_RADIOBUTTON;
s_preferences.allowdownload.generic.name = "Automatic Downloading:";
s_preferences.allowdownload.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.allowdownload.generic.callback = Preferences_Event;
s_preferences.allowdownload.generic.id = ID_ALLOWDOWNLOAD;
s_preferences.allowdownload.generic.x = PREFERENCES_X_POS;
s_preferences.allowdownload.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.back.generic.type = MTYPE_BITMAP;
s_preferences.back.generic.name = ART_BACK0;
s_preferences.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_preferences.back.generic.callback = Preferences_Event;
s_preferences.back.generic.id = ID_BACK;
s_preferences.back.generic.x = 0;
s_preferences.back.generic.y = 480-64;
s_preferences.back.width = 128;
s_preferences.back.height = 64;
s_preferences.back.focuspic = ART_BACK1;
Menu_AddItem( &s_preferences.menu, &s_preferences.banner );
Menu_AddItem( &s_preferences.menu, &s_preferences.framel );
Menu_AddItem( &s_preferences.menu, &s_preferences.framer );
Menu_AddItem( &s_preferences.menu, &s_preferences.crosshair );
Menu_AddItem( &s_preferences.menu, &s_preferences.simpleitems );
Menu_AddItem( &s_preferences.menu, &s_preferences.wallmarks );
Menu_AddItem( &s_preferences.menu, &s_preferences.brass );
Menu_AddItem( &s_preferences.menu, &s_preferences.dynamiclights );
Menu_AddItem( &s_preferences.menu, &s_preferences.identifytarget );
Menu_AddItem( &s_preferences.menu, &s_preferences.highqualitysky );
Menu_AddItem( &s_preferences.menu, &s_preferences.synceveryframe );
Menu_AddItem( &s_preferences.menu, &s_preferences.forcemodel );
Menu_AddItem( &s_preferences.menu, &s_preferences.drawteamoverlay );
Menu_AddItem( &s_preferences.menu, &s_preferences.allowdownload );
Menu_AddItem( &s_preferences.menu, &s_preferences.back );
Preferences_SetMenuItems();
}
/*
===============
Preferences_Cache
===============
*/
void Preferences_Cache( void ) {
int n;
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
for( n = 0; n < NUM_CROSSHAIRS; n++ ) {
s_preferences.crosshairShader[n] = trap_R_RegisterShaderNoMip( va("gfx/2d/crosshair%c", 'a' + n ) );
}
}
/*
===============
UI_PreferencesMenu
===============
*/
void UI_PreferencesMenu( void ) {
Preferences_MenuInit();
UI_PushMenu( &s_preferences.menu );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
GAME OPTIONS MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define PREFERENCES_X_POS 360
#define ID_CROSSHAIR 127
#define ID_SIMPLEITEMS 128
#define ID_HIGHQUALITYSKY 129
#define ID_EJECTINGBRASS 130
#define ID_WALLMARKS 131
#define ID_DYNAMICLIGHTS 132
#define ID_IDENTIFYTARGET 133
#define ID_SYNCEVERYFRAME 134
#define ID_FORCEMODEL 135
#define ID_DRAWTEAMOVERLAY 136
#define ID_ALLOWDOWNLOAD 137
#define ID_BACK 138
#define NUM_CROSSHAIRS 10
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menulist_s crosshair;
menuradiobutton_s simpleitems;
menuradiobutton_s brass;
menuradiobutton_s wallmarks;
menuradiobutton_s dynamiclights;
menuradiobutton_s identifytarget;
menuradiobutton_s highqualitysky;
menuradiobutton_s synceveryframe;
menuradiobutton_s forcemodel;
menulist_s drawteamoverlay;
menuradiobutton_s allowdownload;
menubitmap_s back;
qhandle_t crosshairShader[NUM_CROSSHAIRS];
} preferences_t;
static preferences_t s_preferences;
static const char *teamoverlay_names[] =
{
"off",
"upper right",
"lower right",
"lower left",
0
};
static void Preferences_SetMenuItems( void ) {
s_preferences.crosshair.curvalue = (int)trap_Cvar_VariableValue( "cg_drawCrosshair" ) % NUM_CROSSHAIRS;
s_preferences.simpleitems.curvalue = trap_Cvar_VariableValue( "cg_simpleItems" ) != 0;
s_preferences.brass.curvalue = trap_Cvar_VariableValue( "cg_brassTime" ) != 0;
s_preferences.wallmarks.curvalue = trap_Cvar_VariableValue( "cg_marks" ) != 0;
s_preferences.identifytarget.curvalue = trap_Cvar_VariableValue( "cg_drawCrosshairNames" ) != 0;
s_preferences.dynamiclights.curvalue = trap_Cvar_VariableValue( "r_dynamiclight" ) != 0;
s_preferences.highqualitysky.curvalue = trap_Cvar_VariableValue ( "r_fastsky" ) == 0;
s_preferences.synceveryframe.curvalue = trap_Cvar_VariableValue( "r_finish" ) != 0;
s_preferences.forcemodel.curvalue = trap_Cvar_VariableValue( "cg_forcemodel" ) != 0;
s_preferences.drawteamoverlay.curvalue = Com_Clamp( 0, 3, trap_Cvar_VariableValue( "cg_drawTeamOverlay" ) );
s_preferences.allowdownload.curvalue = trap_Cvar_VariableValue( "cl_allowDownload" ) != 0;
}
static void Preferences_Event( void* ptr, int notification ) {
if( notification != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_CROSSHAIR:
s_preferences.crosshair.curvalue++;
if( s_preferences.crosshair.curvalue == NUM_CROSSHAIRS ) {
s_preferences.crosshair.curvalue = 0;
}
trap_Cvar_SetValue( "cg_drawCrosshair", s_preferences.crosshair.curvalue );
break;
case ID_SIMPLEITEMS:
trap_Cvar_SetValue( "cg_simpleItems", s_preferences.simpleitems.curvalue );
break;
case ID_HIGHQUALITYSKY:
trap_Cvar_SetValue( "r_fastsky", !s_preferences.highqualitysky.curvalue );
break;
case ID_EJECTINGBRASS:
if ( s_preferences.brass.curvalue )
trap_Cvar_Reset( "cg_brassTime" );
else
trap_Cvar_SetValue( "cg_brassTime", 0 );
break;
case ID_WALLMARKS:
trap_Cvar_SetValue( "cg_marks", s_preferences.wallmarks.curvalue );
break;
case ID_DYNAMICLIGHTS:
trap_Cvar_SetValue( "r_dynamiclight", s_preferences.dynamiclights.curvalue );
break;
case ID_IDENTIFYTARGET:
trap_Cvar_SetValue( "cg_drawCrosshairNames", s_preferences.identifytarget.curvalue );
break;
case ID_SYNCEVERYFRAME:
trap_Cvar_SetValue( "r_finish", s_preferences.synceveryframe.curvalue );
break;
case ID_FORCEMODEL:
trap_Cvar_SetValue( "cg_forcemodel", s_preferences.forcemodel.curvalue );
break;
case ID_DRAWTEAMOVERLAY:
trap_Cvar_SetValue( "cg_drawTeamOverlay", s_preferences.drawteamoverlay.curvalue );
break;
case ID_ALLOWDOWNLOAD:
trap_Cvar_SetValue( "cl_allowDownload", s_preferences.allowdownload.curvalue );
trap_Cvar_SetValue( "sv_allowDownload", s_preferences.allowdownload.curvalue );
break;
case ID_BACK:
UI_PopMenu();
break;
}
}
/*
=================
Crosshair_Draw
=================
*/
static void Crosshair_Draw( void *self ) {
menulist_s *s;
float *color;
int x, y;
int style;
qboolean focus;
s = (menulist_s *)self;
x = s->generic.x;
y = s->generic.y;
style = UI_SMALLFONT;
focus = (s->generic.parent->cursor == s->generic.menuPosition);
if ( s->generic.flags & QMF_GRAYED )
color = text_color_disabled;
else if ( focus )
{
color = text_color_highlight;
style |= UI_PULSE;
}
else if ( s->generic.flags & QMF_BLINK )
{
color = text_color_highlight;
style |= UI_BLINK;
}
else
color = text_color_normal;
if ( focus )
{
// draw cursor
UI_FillRect( s->generic.left, s->generic.top, s->generic.right-s->generic.left+1, s->generic.bottom-s->generic.top+1, listbar_color );
UI_DrawChar( x, y, 13, UI_CENTER|UI_BLINK|UI_SMALLFONT, color);
}
UI_DrawString( x - SMALLCHAR_WIDTH, y, s->generic.name, style|UI_RIGHT, color );
if( !s->curvalue ) {
return;
}
UI_DrawHandlePic( x + SMALLCHAR_WIDTH, y - 4, 24, 24, s_preferences.crosshairShader[s->curvalue] );
}
static void Preferences_MenuInit( void ) {
int y;
memset( &s_preferences, 0 ,sizeof(preferences_t) );
Preferences_Cache();
s_preferences.menu.wrapAround = qtrue;
s_preferences.menu.fullscreen = qtrue;
s_preferences.banner.generic.type = MTYPE_BTEXT;
s_preferences.banner.generic.x = 320;
s_preferences.banner.generic.y = 16;
s_preferences.banner.string = "GAME OPTIONS";
s_preferences.banner.color = color_white;
s_preferences.banner.style = UI_CENTER;
s_preferences.framel.generic.type = MTYPE_BITMAP;
s_preferences.framel.generic.name = ART_FRAMEL;
s_preferences.framel.generic.flags = QMF_INACTIVE;
s_preferences.framel.generic.x = 0;
s_preferences.framel.generic.y = 78;
s_preferences.framel.width = 256;
s_preferences.framel.height = 329;
s_preferences.framer.generic.type = MTYPE_BITMAP;
s_preferences.framer.generic.name = ART_FRAMER;
s_preferences.framer.generic.flags = QMF_INACTIVE;
s_preferences.framer.generic.x = 376;
s_preferences.framer.generic.y = 76;
s_preferences.framer.width = 256;
s_preferences.framer.height = 334;
y = 144;
s_preferences.crosshair.generic.type = MTYPE_TEXT;
s_preferences.crosshair.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT|QMF_NODEFAULTINIT|QMF_OWNERDRAW;
s_preferences.crosshair.generic.x = PREFERENCES_X_POS;
s_preferences.crosshair.generic.y = y;
s_preferences.crosshair.generic.name = "Crosshair:";
s_preferences.crosshair.generic.callback = Preferences_Event;
s_preferences.crosshair.generic.ownerdraw = Crosshair_Draw;
s_preferences.crosshair.generic.id = ID_CROSSHAIR;
s_preferences.crosshair.generic.top = y - 4;
s_preferences.crosshair.generic.bottom = y + 20;
s_preferences.crosshair.generic.left = PREFERENCES_X_POS - ( ( strlen(s_preferences.crosshair.generic.name) + 1 ) * SMALLCHAR_WIDTH );
s_preferences.crosshair.generic.right = PREFERENCES_X_POS + 48;
y += BIGCHAR_HEIGHT+2+4;
s_preferences.simpleitems.generic.type = MTYPE_RADIOBUTTON;
s_preferences.simpleitems.generic.name = "Simple Items:";
s_preferences.simpleitems.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.simpleitems.generic.callback = Preferences_Event;
s_preferences.simpleitems.generic.id = ID_SIMPLEITEMS;
s_preferences.simpleitems.generic.x = PREFERENCES_X_POS;
s_preferences.simpleitems.generic.y = y;
y += BIGCHAR_HEIGHT;
s_preferences.wallmarks.generic.type = MTYPE_RADIOBUTTON;
s_preferences.wallmarks.generic.name = "Marks on Walls:";
s_preferences.wallmarks.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.wallmarks.generic.callback = Preferences_Event;
s_preferences.wallmarks.generic.id = ID_WALLMARKS;
s_preferences.wallmarks.generic.x = PREFERENCES_X_POS;
s_preferences.wallmarks.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.brass.generic.type = MTYPE_RADIOBUTTON;
s_preferences.brass.generic.name = "Ejecting Brass:";
s_preferences.brass.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.brass.generic.callback = Preferences_Event;
s_preferences.brass.generic.id = ID_EJECTINGBRASS;
s_preferences.brass.generic.x = PREFERENCES_X_POS;
s_preferences.brass.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.dynamiclights.generic.type = MTYPE_RADIOBUTTON;
s_preferences.dynamiclights.generic.name = "Dynamic Lights:";
s_preferences.dynamiclights.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.dynamiclights.generic.callback = Preferences_Event;
s_preferences.dynamiclights.generic.id = ID_DYNAMICLIGHTS;
s_preferences.dynamiclights.generic.x = PREFERENCES_X_POS;
s_preferences.dynamiclights.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.identifytarget.generic.type = MTYPE_RADIOBUTTON;
s_preferences.identifytarget.generic.name = "Identify Target:";
s_preferences.identifytarget.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.identifytarget.generic.callback = Preferences_Event;
s_preferences.identifytarget.generic.id = ID_IDENTIFYTARGET;
s_preferences.identifytarget.generic.x = PREFERENCES_X_POS;
s_preferences.identifytarget.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.highqualitysky.generic.type = MTYPE_RADIOBUTTON;
s_preferences.highqualitysky.generic.name = "High Quality Sky:";
s_preferences.highqualitysky.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.highqualitysky.generic.callback = Preferences_Event;
s_preferences.highqualitysky.generic.id = ID_HIGHQUALITYSKY;
s_preferences.highqualitysky.generic.x = PREFERENCES_X_POS;
s_preferences.highqualitysky.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.synceveryframe.generic.type = MTYPE_RADIOBUTTON;
s_preferences.synceveryframe.generic.name = "Sync Every Frame:";
s_preferences.synceveryframe.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.synceveryframe.generic.callback = Preferences_Event;
s_preferences.synceveryframe.generic.id = ID_SYNCEVERYFRAME;
s_preferences.synceveryframe.generic.x = PREFERENCES_X_POS;
s_preferences.synceveryframe.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.forcemodel.generic.type = MTYPE_RADIOBUTTON;
s_preferences.forcemodel.generic.name = "Force Player Models:";
s_preferences.forcemodel.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.forcemodel.generic.callback = Preferences_Event;
s_preferences.forcemodel.generic.id = ID_FORCEMODEL;
s_preferences.forcemodel.generic.x = PREFERENCES_X_POS;
s_preferences.forcemodel.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.drawteamoverlay.generic.type = MTYPE_SPINCONTROL;
s_preferences.drawteamoverlay.generic.name = "Draw Team Overlay:";
s_preferences.drawteamoverlay.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.drawteamoverlay.generic.callback = Preferences_Event;
s_preferences.drawteamoverlay.generic.id = ID_DRAWTEAMOVERLAY;
s_preferences.drawteamoverlay.generic.x = PREFERENCES_X_POS;
s_preferences.drawteamoverlay.generic.y = y;
s_preferences.drawteamoverlay.itemnames = teamoverlay_names;
y += BIGCHAR_HEIGHT+2;
s_preferences.allowdownload.generic.type = MTYPE_RADIOBUTTON;
s_preferences.allowdownload.generic.name = "Automatic Downloading:";
s_preferences.allowdownload.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.allowdownload.generic.callback = Preferences_Event;
s_preferences.allowdownload.generic.id = ID_ALLOWDOWNLOAD;
s_preferences.allowdownload.generic.x = PREFERENCES_X_POS;
s_preferences.allowdownload.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.back.generic.type = MTYPE_BITMAP;
s_preferences.back.generic.name = ART_BACK0;
s_preferences.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_preferences.back.generic.callback = Preferences_Event;
s_preferences.back.generic.id = ID_BACK;
s_preferences.back.generic.x = 0;
s_preferences.back.generic.y = 480-64;
s_preferences.back.width = 128;
s_preferences.back.height = 64;
s_preferences.back.focuspic = ART_BACK1;
Menu_AddItem( &s_preferences.menu, &s_preferences.banner );
Menu_AddItem( &s_preferences.menu, &s_preferences.framel );
Menu_AddItem( &s_preferences.menu, &s_preferences.framer );
Menu_AddItem( &s_preferences.menu, &s_preferences.crosshair );
Menu_AddItem( &s_preferences.menu, &s_preferences.simpleitems );
Menu_AddItem( &s_preferences.menu, &s_preferences.wallmarks );
Menu_AddItem( &s_preferences.menu, &s_preferences.brass );
Menu_AddItem( &s_preferences.menu, &s_preferences.dynamiclights );
Menu_AddItem( &s_preferences.menu, &s_preferences.identifytarget );
Menu_AddItem( &s_preferences.menu, &s_preferences.highqualitysky );
Menu_AddItem( &s_preferences.menu, &s_preferences.synceveryframe );
Menu_AddItem( &s_preferences.menu, &s_preferences.forcemodel );
Menu_AddItem( &s_preferences.menu, &s_preferences.drawteamoverlay );
Menu_AddItem( &s_preferences.menu, &s_preferences.allowdownload );
Menu_AddItem( &s_preferences.menu, &s_preferences.back );
Preferences_SetMenuItems();
}
/*
===============
Preferences_Cache
===============
*/
void Preferences_Cache( void ) {
int n;
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
for( n = 0; n < NUM_CROSSHAIRS; n++ ) {
s_preferences.crosshairShader[n] = trap_R_RegisterShaderNoMip( va("gfx/2d/crosshair%c", 'a' + n ) );
}
}
/*
===============
UI_PreferencesMenu
===============
*/
void UI_PreferencesMenu( void ) {
Preferences_MenuInit();
UI_PushMenu( &s_preferences.menu );
}

File diff suppressed because it is too large Load diff

View file

@ -1,420 +1,420 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
//
// ui_rankings.c
//
#include "ui_local.h"
#define RANKINGS_FRAME "menu/art/cut_frame"
#define ID_LOGIN 100
#define ID_LOGOUT 101
#define ID_CREATE 102
#define ID_SPECTATE 103
#define ID_SETUP 104
#define ID_LEAVE 105
typedef struct
{
menuframework_s menu;
menubitmap_s frame;
menutext_s login;
menutext_s logout;
menutext_s create;
menutext_s spectate;
menutext_s setup;
menutext_s leave;
} rankings_t;
static rankings_t s_rankings;
static menuframework_s s_rankings_menu;
static menuaction_s s_rankings_login;
static menuaction_s s_rankings_logout;
static menuaction_s s_rankings_create;
static menuaction_s s_rankings_spectate;
static menuaction_s s_rankings_setup;
static menuaction_s s_rankings_leave;
/*
===============
Rankings_DrawText
===============
*/
void Rankings_DrawText( void* self )
{
menufield_s *f;
qboolean focus;
int style;
char *txt;
char c;
float *color;
int basex, x, y;
f = (menufield_s*)self;
basex = f->generic.x;
y = f->generic.y + 4;
focus = (f->generic.parent->cursor == f->generic.menuPosition);
style = UI_LEFT|UI_SMALLFONT;
color = text_color_normal;
if( focus ) {
style |= UI_PULSE;
color = text_color_highlight;
}
// draw the actual text
txt = f->field.buffer;
color = g_color_table[ColorIndex(COLOR_WHITE)];
x = basex;
while ( (c = *txt) != 0 ) {
UI_DrawChar( x, y, c, style, color );
txt++;
x += SMALLCHAR_WIDTH;
}
// draw cursor if we have focus
if( focus ) {
if ( trap_Key_GetOverstrikeMode() ) {
c = 11;
} else {
c = 10;
}
style &= ~UI_PULSE;
style |= UI_BLINK;
UI_DrawChar( basex + f->field.cursor * SMALLCHAR_WIDTH, y, c, style, color_white );
}
}
/*
===============
Rankings_DrawName
===============
*/
void Rankings_DrawName( void* self )
{
menufield_s *f;
int length;
char* p;
f = (menufield_s*)self;
// GRANK_FIXME - enforce valid characters
for( p = f->field.buffer; *p != '\0'; p++ )
{
//if( ispunct(*p) || isspace(*p) )
if( !( ( (*p) >= '0' && (*p) <= '9') || Q_isalpha(*p)) )
{
*p = '\0';
}
}
// strip color codes
Q_CleanStr( f->field.buffer );
length = strlen( f->field.buffer );
if( f->field.cursor > length )
{
f->field.cursor = length;
}
Rankings_DrawText( f );
}
#if 0 // old version
/*
===============
Rankings_DrawName
===============
*/
void Rankings_DrawName( void* self )
{
menufield_s* f;
int length;
f = (menufield_s*)self;
// strip color codes
Q_CleanStr( f->field.buffer );
length = strlen( f->field.buffer );
if( f->field.cursor > length )
{
f->field.cursor = length;
}
// show beginning of long names
/*
if( Menu_ItemAtCursor( f->generic.parent ) != f )
{
if( f->field.scroll > 0 )
{
f->field.cursor = 0;
f->field.scroll = 0;
}
}
*/
MenuField_Draw( f );
}
#endif
/*
===============
Rankings_DrawPassword
===============
*/
void Rankings_DrawPassword( void* self )
{
menufield_s* f;
char password[MAX_EDIT_LINE];
int length;
int i;
char* p;
f = (menufield_s*)self;
// GRANK_FIXME - enforce valid characters
for( p = f->field.buffer; *p != '\0'; p++ )
{
//if( ispunct(*p) || isspace(*p) )
if( !( ( (*p) >= '0' && (*p) <= '9') || Q_isalpha(*p)) )
{
*p = '\0';
}
}
length = strlen( f->field.buffer );
if( f->field.cursor > length )
{
f->field.cursor = length;
}
// save password
Q_strncpyz( password, f->field.buffer, sizeof(password) );
// mask password with *
for( i = 0; i < length; i++ )
{
f->field.buffer[i] = '*';
}
// draw masked password
Rankings_DrawText( f );
//MenuField_Draw( f );
// restore password
Q_strncpyz( f->field.buffer, password, sizeof(f->field.buffer) );
}
/*
===============
Rankings_MenuEvent
===============
*/
static void Rankings_MenuEvent( void* ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_LOGIN:
UI_LoginMenu();
break;
case ID_LOGOUT:
// server side masqueraded player logout first
trap_CL_UI_RankUserRequestLogout();
UI_ForceMenuOff();
break;
case ID_CREATE:
UI_SignupMenu();
break;
case ID_SPECTATE:
trap_Cmd_ExecuteText( EXEC_APPEND, "cmd rank_spectate\n" );
UI_ForceMenuOff();
break;
case ID_SETUP:
UI_SetupMenu();
break;
case ID_LEAVE:
trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect\n" );
UI_ForceMenuOff();
break;
}
}
/*
===============
Rankings_MenuInit
===============
*/
void Rankings_MenuInit( void ) {
grank_status_t status;
int y;
memset( &s_rankings, 0, sizeof(s_rankings) );
Rankings_Cache();
s_rankings.menu.wrapAround = qtrue;
s_rankings.menu.fullscreen = qfalse;
s_rankings.frame.generic.type = MTYPE_BITMAP;
s_rankings.frame.generic.flags = QMF_INACTIVE;
s_rankings.frame.generic.name = RANKINGS_FRAME;
s_rankings.frame.generic.x = 142;
s_rankings.frame.generic.y = 118;
s_rankings.frame.width = 359;
s_rankings.frame.height = 256;
y = 194;
s_rankings.login.generic.type = MTYPE_PTEXT;
s_rankings.login.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_rankings.login.generic.id = ID_LOGIN;
s_rankings.login.generic.callback = Rankings_MenuEvent;
s_rankings.login.generic.x = 320;
s_rankings.login.generic.y = y;
s_rankings.login.string = "LOGIN";
s_rankings.login.style = UI_CENTER|UI_SMALLFONT;
s_rankings.login.color = colorRed;
y += 20;
s_rankings.logout.generic.type = MTYPE_PTEXT;
s_rankings.logout.generic.flags = QMF_HIDDEN|QMF_INACTIVE|QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_rankings.logout.generic.id = ID_LOGOUT;
s_rankings.logout.generic.callback = Rankings_MenuEvent;
s_rankings.logout.generic.x = 320;
s_rankings.logout.generic.y = y;
s_rankings.logout.string = "LOGOUT";
s_rankings.logout.style = UI_CENTER|UI_SMALLFONT;
s_rankings.logout.color = colorRed;
s_rankings.create.generic.type = MTYPE_PTEXT;
s_rankings.create.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_rankings.create.generic.id = ID_CREATE;
s_rankings.create.generic.callback = Rankings_MenuEvent;
s_rankings.create.generic.x = 320;
s_rankings.create.generic.y = y;
s_rankings.create.string = "SIGN UP";
s_rankings.create.style = UI_CENTER|UI_SMALLFONT;
s_rankings.create.color = colorRed;
y += 20;
s_rankings.spectate.generic.type = MTYPE_PTEXT;
s_rankings.spectate.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_rankings.spectate.generic.id = ID_SPECTATE;
s_rankings.spectate.generic.callback = Rankings_MenuEvent;
s_rankings.spectate.generic.x = 320;
s_rankings.spectate.generic.y = y;
s_rankings.spectate.string = "SPECTATE";
s_rankings.spectate.style = UI_CENTER|UI_SMALLFONT;
s_rankings.spectate.color = colorRed;
y += 20;
s_rankings.setup.generic.type = MTYPE_PTEXT;
s_rankings.setup.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_rankings.setup.generic.id = ID_SETUP;
s_rankings.setup.generic.callback = Rankings_MenuEvent;
s_rankings.setup.generic.x = 320;
s_rankings.setup.generic.y = y;
s_rankings.setup.string = "SETUP";
s_rankings.setup.style = UI_CENTER|UI_SMALLFONT;
s_rankings.setup.color = colorRed;
y += 20;
s_rankings.leave.generic.type = MTYPE_PTEXT;
s_rankings.leave.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_rankings.leave.generic.id = ID_LEAVE;
s_rankings.leave.generic.callback = Rankings_MenuEvent;
s_rankings.leave.generic.x = 320;
s_rankings.leave.generic.y = y;
s_rankings.leave.string = "LEAVE ARENA";
s_rankings.leave.style = UI_CENTER|UI_SMALLFONT;
s_rankings.leave.color = colorRed;
y += 20;
status = (grank_status_t)trap_Cvar_VariableValue("client_status");
if( (status != QGR_STATUS_NEW) && (status != QGR_STATUS_SPECTATOR) )
{
s_rankings.login.generic.flags |= QMF_HIDDEN | QMF_INACTIVE;
s_rankings.create.generic.flags |= QMF_HIDDEN | QMF_INACTIVE;
s_rankings.spectate.generic.flags |= QMF_HIDDEN | QMF_INACTIVE;
s_rankings.logout.generic.flags &= ~(QMF_HIDDEN | QMF_INACTIVE);
}
if ( (status == QGR_STATUS_VALIDATING) ||
(status == QGR_STATUS_PENDING) ||
(status == QGR_STATUS_LEAVING) )
{
s_rankings.login.generic.flags |= QMF_GRAYED;
s_rankings.create.generic.flags |= QMF_GRAYED;
s_rankings.logout.generic.flags |= QMF_GRAYED;
}
//GRank FIXME -- don't need setup option any more
s_rankings.setup.generic.flags |= QMF_HIDDEN | QMF_INACTIVE;
Menu_AddItem( &s_rankings.menu, (void*) &s_rankings.frame );
Menu_AddItem( &s_rankings.menu, (void*) &s_rankings.login );
Menu_AddItem( &s_rankings.menu, (void*) &s_rankings.logout );
Menu_AddItem( &s_rankings.menu, (void*) &s_rankings.create );
Menu_AddItem( &s_rankings.menu, (void*) &s_rankings.spectate );
Menu_AddItem( &s_rankings.menu, (void*) &s_rankings.setup );
Menu_AddItem( &s_rankings.menu, (void*) &s_rankings.leave );
}
/*
===============
Rankings_Cache
===============
*/
void Rankings_Cache( void ) {
trap_R_RegisterShaderNoMip( RANKINGS_FRAME );
}
/*
===============
UI_RankingsMenu
===============
*/
void UI_RankingsMenu( void ) {
Rankings_MenuInit();
UI_PushMenu ( &s_rankings.menu );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
//
// ui_rankings.c
//
#include "ui_local.h"
#define RANKINGS_FRAME "menu/art/cut_frame"
#define ID_LOGIN 100
#define ID_LOGOUT 101
#define ID_CREATE 102
#define ID_SPECTATE 103
#define ID_SETUP 104
#define ID_LEAVE 105
typedef struct
{
menuframework_s menu;
menubitmap_s frame;
menutext_s login;
menutext_s logout;
menutext_s create;
menutext_s spectate;
menutext_s setup;
menutext_s leave;
} rankings_t;
static rankings_t s_rankings;
static menuframework_s s_rankings_menu;
static menuaction_s s_rankings_login;
static menuaction_s s_rankings_logout;
static menuaction_s s_rankings_create;
static menuaction_s s_rankings_spectate;
static menuaction_s s_rankings_setup;
static menuaction_s s_rankings_leave;
/*
===============
Rankings_DrawText
===============
*/
void Rankings_DrawText( void* self )
{
menufield_s *f;
qboolean focus;
int style;
char *txt;
char c;
float *color;
int basex, x, y;
f = (menufield_s*)self;
basex = f->generic.x;
y = f->generic.y + 4;
focus = (f->generic.parent->cursor == f->generic.menuPosition);
style = UI_LEFT|UI_SMALLFONT;
color = text_color_normal;
if( focus ) {
style |= UI_PULSE;
color = text_color_highlight;
}
// draw the actual text
txt = f->field.buffer;
color = g_color_table[ColorIndex(COLOR_WHITE)];
x = basex;
while ( (c = *txt) != 0 ) {
UI_DrawChar( x, y, c, style, color );
txt++;
x += SMALLCHAR_WIDTH;
}
// draw cursor if we have focus
if( focus ) {
if ( trap_Key_GetOverstrikeMode() ) {
c = 11;
} else {
c = 10;
}
style &= ~UI_PULSE;
style |= UI_BLINK;
UI_DrawChar( basex + f->field.cursor * SMALLCHAR_WIDTH, y, c, style, color_white );
}
}
/*
===============
Rankings_DrawName
===============
*/
void Rankings_DrawName( void* self )
{
menufield_s *f;
int length;
char* p;
f = (menufield_s*)self;
// GRANK_FIXME - enforce valid characters
for( p = f->field.buffer; *p != '\0'; p++ )
{
//if( ispunct(*p) || isspace(*p) )
if( !( ( (*p) >= '0' && (*p) <= '9') || Q_isalpha(*p)) )
{
*p = '\0';
}
}
// strip color codes
Q_CleanStr( f->field.buffer );
length = strlen( f->field.buffer );
if( f->field.cursor > length )
{
f->field.cursor = length;
}
Rankings_DrawText( f );
}
#if 0 // old version
/*
===============
Rankings_DrawName
===============
*/
void Rankings_DrawName( void* self )
{
menufield_s* f;
int length;
f = (menufield_s*)self;
// strip color codes
Q_CleanStr( f->field.buffer );
length = strlen( f->field.buffer );
if( f->field.cursor > length )
{
f->field.cursor = length;
}
// show beginning of long names
/*
if( Menu_ItemAtCursor( f->generic.parent ) != f )
{
if( f->field.scroll > 0 )
{
f->field.cursor = 0;
f->field.scroll = 0;
}
}
*/
MenuField_Draw( f );
}
#endif
/*
===============
Rankings_DrawPassword
===============
*/
void Rankings_DrawPassword( void* self )
{
menufield_s* f;
char password[MAX_EDIT_LINE];
int length;
int i;
char* p;
f = (menufield_s*)self;
// GRANK_FIXME - enforce valid characters
for( p = f->field.buffer; *p != '\0'; p++ )
{
//if( ispunct(*p) || isspace(*p) )
if( !( ( (*p) >= '0' && (*p) <= '9') || Q_isalpha(*p)) )
{
*p = '\0';
}
}
length = strlen( f->field.buffer );
if( f->field.cursor > length )
{
f->field.cursor = length;
}
// save password
Q_strncpyz( password, f->field.buffer, sizeof(password) );
// mask password with *
for( i = 0; i < length; i++ )
{
f->field.buffer[i] = '*';
}
// draw masked password
Rankings_DrawText( f );
//MenuField_Draw( f );
// restore password
Q_strncpyz( f->field.buffer, password, sizeof(f->field.buffer) );
}
/*
===============
Rankings_MenuEvent
===============
*/
static void Rankings_MenuEvent( void* ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_LOGIN:
UI_LoginMenu();
break;
case ID_LOGOUT:
// server side masqueraded player logout first
trap_CL_UI_RankUserRequestLogout();
UI_ForceMenuOff();
break;
case ID_CREATE:
UI_SignupMenu();
break;
case ID_SPECTATE:
trap_Cmd_ExecuteText( EXEC_APPEND, "cmd rank_spectate\n" );
UI_ForceMenuOff();
break;
case ID_SETUP:
UI_SetupMenu();
break;
case ID_LEAVE:
trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect\n" );
UI_ForceMenuOff();
break;
}
}
/*
===============
Rankings_MenuInit
===============
*/
void Rankings_MenuInit( void ) {
grank_status_t status;
int y;
memset( &s_rankings, 0, sizeof(s_rankings) );
Rankings_Cache();
s_rankings.menu.wrapAround = qtrue;
s_rankings.menu.fullscreen = qfalse;
s_rankings.frame.generic.type = MTYPE_BITMAP;
s_rankings.frame.generic.flags = QMF_INACTIVE;
s_rankings.frame.generic.name = RANKINGS_FRAME;
s_rankings.frame.generic.x = 142;
s_rankings.frame.generic.y = 118;
s_rankings.frame.width = 359;
s_rankings.frame.height = 256;
y = 194;
s_rankings.login.generic.type = MTYPE_PTEXT;
s_rankings.login.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_rankings.login.generic.id = ID_LOGIN;
s_rankings.login.generic.callback = Rankings_MenuEvent;
s_rankings.login.generic.x = 320;
s_rankings.login.generic.y = y;
s_rankings.login.string = "LOGIN";
s_rankings.login.style = UI_CENTER|UI_SMALLFONT;
s_rankings.login.color = colorRed;
y += 20;
s_rankings.logout.generic.type = MTYPE_PTEXT;
s_rankings.logout.generic.flags = QMF_HIDDEN|QMF_INACTIVE|QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_rankings.logout.generic.id = ID_LOGOUT;
s_rankings.logout.generic.callback = Rankings_MenuEvent;
s_rankings.logout.generic.x = 320;
s_rankings.logout.generic.y = y;
s_rankings.logout.string = "LOGOUT";
s_rankings.logout.style = UI_CENTER|UI_SMALLFONT;
s_rankings.logout.color = colorRed;
s_rankings.create.generic.type = MTYPE_PTEXT;
s_rankings.create.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_rankings.create.generic.id = ID_CREATE;
s_rankings.create.generic.callback = Rankings_MenuEvent;
s_rankings.create.generic.x = 320;
s_rankings.create.generic.y = y;
s_rankings.create.string = "SIGN UP";
s_rankings.create.style = UI_CENTER|UI_SMALLFONT;
s_rankings.create.color = colorRed;
y += 20;
s_rankings.spectate.generic.type = MTYPE_PTEXT;
s_rankings.spectate.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_rankings.spectate.generic.id = ID_SPECTATE;
s_rankings.spectate.generic.callback = Rankings_MenuEvent;
s_rankings.spectate.generic.x = 320;
s_rankings.spectate.generic.y = y;
s_rankings.spectate.string = "SPECTATE";
s_rankings.spectate.style = UI_CENTER|UI_SMALLFONT;
s_rankings.spectate.color = colorRed;
y += 20;
s_rankings.setup.generic.type = MTYPE_PTEXT;
s_rankings.setup.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_rankings.setup.generic.id = ID_SETUP;
s_rankings.setup.generic.callback = Rankings_MenuEvent;
s_rankings.setup.generic.x = 320;
s_rankings.setup.generic.y = y;
s_rankings.setup.string = "SETUP";
s_rankings.setup.style = UI_CENTER|UI_SMALLFONT;
s_rankings.setup.color = colorRed;
y += 20;
s_rankings.leave.generic.type = MTYPE_PTEXT;
s_rankings.leave.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_rankings.leave.generic.id = ID_LEAVE;
s_rankings.leave.generic.callback = Rankings_MenuEvent;
s_rankings.leave.generic.x = 320;
s_rankings.leave.generic.y = y;
s_rankings.leave.string = "LEAVE ARENA";
s_rankings.leave.style = UI_CENTER|UI_SMALLFONT;
s_rankings.leave.color = colorRed;
y += 20;
status = (grank_status_t)trap_Cvar_VariableValue("client_status");
if( (status != QGR_STATUS_NEW) && (status != QGR_STATUS_SPECTATOR) )
{
s_rankings.login.generic.flags |= QMF_HIDDEN | QMF_INACTIVE;
s_rankings.create.generic.flags |= QMF_HIDDEN | QMF_INACTIVE;
s_rankings.spectate.generic.flags |= QMF_HIDDEN | QMF_INACTIVE;
s_rankings.logout.generic.flags &= ~(QMF_HIDDEN | QMF_INACTIVE);
}
if ( (status == QGR_STATUS_VALIDATING) ||
(status == QGR_STATUS_PENDING) ||
(status == QGR_STATUS_LEAVING) )
{
s_rankings.login.generic.flags |= QMF_GRAYED;
s_rankings.create.generic.flags |= QMF_GRAYED;
s_rankings.logout.generic.flags |= QMF_GRAYED;
}
//GRank FIXME -- don't need setup option any more
s_rankings.setup.generic.flags |= QMF_HIDDEN | QMF_INACTIVE;
Menu_AddItem( &s_rankings.menu, (void*) &s_rankings.frame );
Menu_AddItem( &s_rankings.menu, (void*) &s_rankings.login );
Menu_AddItem( &s_rankings.menu, (void*) &s_rankings.logout );
Menu_AddItem( &s_rankings.menu, (void*) &s_rankings.create );
Menu_AddItem( &s_rankings.menu, (void*) &s_rankings.spectate );
Menu_AddItem( &s_rankings.menu, (void*) &s_rankings.setup );
Menu_AddItem( &s_rankings.menu, (void*) &s_rankings.leave );
}
/*
===============
Rankings_Cache
===============
*/
void Rankings_Cache( void ) {
trap_R_RegisterShaderNoMip( RANKINGS_FRAME );
}
/*
===============
UI_RankingsMenu
===============
*/
void UI_RankingsMenu( void ) {
Rankings_MenuInit();
UI_PushMenu ( &s_rankings.menu );
}

View file

@ -1,209 +1,209 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
//
// ui_rankstatus.c
//
#include "ui_local.h"
#define RANKSTATUS_FRAME "menu/art/cut_frame"
#define ID_MESSAGE 100
#define ID_OK 101
typedef struct
{
menuframework_s menu;
menubitmap_s frame;
menutext_s message;
menutext_s ok;
} rankstatus_t;
static rankstatus_t s_rankstatus;
static menuframework_s s_rankstatus_menu;
static menuaction_s s_rankstatus_ok;
static grank_status_t s_status = 0;
static char* s_rankstatus_message = NULL;
static vec4_t s_rankingstatus_color_prompt = {1.00, 0.43, 0.00, 1.00};
/*
===============
RankStatus_MenuEvent
===============
*/
static void RankStatus_MenuEvent( void* ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_OK:
UI_PopMenu();
switch( s_status )
{
case QGR_STATUS_NO_USER:
UI_RankingsMenu();
break;
case QGR_STATUS_BAD_PASSWORD:
UI_RankingsMenu();
UI_LoginMenu();
break;
case QGR_STATUS_USER_EXISTS:
UI_RankingsMenu();
UI_SignupMenu();
break;
case QGR_STATUS_NO_MEMBERSHIP:
UI_RankingsMenu();
break;
case QGR_STATUS_TIMEOUT:
UI_RankingsMenu();
break;
case QGR_STATUS_INVALIDUSER:
UI_RankingsMenu();
break;
case QGR_STATUS_ERROR:
UI_RankingsMenu();
break;
default:
break;
}
break;
}
}
/*
===============
RankStatus_MenuInit
===============
*/
void RankStatus_MenuInit( void ) {
int y;
memset( &s_rankstatus, 0, sizeof(s_rankstatus) );
RankStatus_Cache();
s_rankstatus.menu.wrapAround = qtrue;
s_rankstatus.menu.fullscreen = qfalse;
s_rankstatus.frame.generic.type = MTYPE_BITMAP;
s_rankstatus.frame.generic.flags = QMF_INACTIVE;
s_rankstatus.frame.generic.name = RANKSTATUS_FRAME;
s_rankstatus.frame.generic.x = 142; //320-233;
s_rankstatus.frame.generic.y = 118; //240-166;
s_rankstatus.frame.width = 359; //466;
s_rankstatus.frame.height = 256; //332;
y = 214;
s_rankstatus.message.generic.type = MTYPE_PTEXT;
s_rankstatus.message.generic.flags = QMF_CENTER_JUSTIFY|QMF_INACTIVE;
s_rankstatus.message.generic.id = ID_MESSAGE;
s_rankstatus.message.generic.x = 320;
s_rankstatus.message.generic.y = y;
s_rankstatus.message.string = s_rankstatus_message;
s_rankstatus.message.style = UI_CENTER|UI_SMALLFONT;
s_rankstatus.message.color = s_rankingstatus_color_prompt;
y += 40;
s_rankstatus.ok.generic.type = MTYPE_PTEXT;
s_rankstatus.ok.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_rankstatus.ok.generic.id = ID_OK;
s_rankstatus.ok.generic.callback = RankStatus_MenuEvent;
s_rankstatus.ok.generic.x = 320;
s_rankstatus.ok.generic.y = y;
s_rankstatus.ok.string = "OK";
s_rankstatus.ok.style = UI_CENTER|UI_SMALLFONT;
s_rankstatus.ok.color = colorRed;
Menu_AddItem( &s_rankstatus.menu, (void*) &s_rankstatus.frame );
Menu_AddItem( &s_rankstatus.menu, (void*) &s_rankstatus.message );
Menu_AddItem( &s_rankstatus.menu, (void*) &s_rankstatus.ok );
}
/*
===============
RankStatus_Cache
===============
*/
void RankStatus_Cache( void ) {
trap_R_RegisterShaderNoMip( RANKSTATUS_FRAME );
}
/*
===============
UI_RankStatusMenu
===============
*/
void UI_RankStatusMenu( void ) {
s_status = (grank_status_t)trap_Cvar_VariableValue("client_status");
switch( s_status )
{
case QGR_STATUS_NEW:
return;
case QGR_STATUS_PENDING:
// GRANK_FIXME
return;
case QGR_STATUS_NO_USER:
// GRANK_FIXME - get this when user exists
s_rankstatus_message = "Username unavailable";
break;
case QGR_STATUS_BAD_PASSWORD:
s_rankstatus_message = "Invalid password";
break;
case QGR_STATUS_TIMEOUT:
s_rankstatus_message = "Timed out";
break;
case QGR_STATUS_NO_MEMBERSHIP:
s_rankstatus_message = "No membership";
break;
case QGR_STATUS_INVALIDUSER:
s_rankstatus_message = "Validation failed";
break;
case QGR_STATUS_ERROR:
s_rankstatus_message = "Error";
break;
case QGR_STATUS_SPECTATOR:
case QGR_STATUS_ACTIVE:
UI_ForceMenuOff();
return;
default:
return;
}
RankStatus_MenuInit();
trap_CL_UI_RankUserReset();
UI_PushMenu ( &s_rankstatus.menu );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
//
// ui_rankstatus.c
//
#include "ui_local.h"
#define RANKSTATUS_FRAME "menu/art/cut_frame"
#define ID_MESSAGE 100
#define ID_OK 101
typedef struct
{
menuframework_s menu;
menubitmap_s frame;
menutext_s message;
menutext_s ok;
} rankstatus_t;
static rankstatus_t s_rankstatus;
static menuframework_s s_rankstatus_menu;
static menuaction_s s_rankstatus_ok;
static grank_status_t s_status = 0;
static char* s_rankstatus_message = NULL;
static vec4_t s_rankingstatus_color_prompt = {1.00, 0.43, 0.00, 1.00};
/*
===============
RankStatus_MenuEvent
===============
*/
static void RankStatus_MenuEvent( void* ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_OK:
UI_PopMenu();
switch( s_status )
{
case QGR_STATUS_NO_USER:
UI_RankingsMenu();
break;
case QGR_STATUS_BAD_PASSWORD:
UI_RankingsMenu();
UI_LoginMenu();
break;
case QGR_STATUS_USER_EXISTS:
UI_RankingsMenu();
UI_SignupMenu();
break;
case QGR_STATUS_NO_MEMBERSHIP:
UI_RankingsMenu();
break;
case QGR_STATUS_TIMEOUT:
UI_RankingsMenu();
break;
case QGR_STATUS_INVALIDUSER:
UI_RankingsMenu();
break;
case QGR_STATUS_ERROR:
UI_RankingsMenu();
break;
default:
break;
}
break;
}
}
/*
===============
RankStatus_MenuInit
===============
*/
void RankStatus_MenuInit( void ) {
int y;
memset( &s_rankstatus, 0, sizeof(s_rankstatus) );
RankStatus_Cache();
s_rankstatus.menu.wrapAround = qtrue;
s_rankstatus.menu.fullscreen = qfalse;
s_rankstatus.frame.generic.type = MTYPE_BITMAP;
s_rankstatus.frame.generic.flags = QMF_INACTIVE;
s_rankstatus.frame.generic.name = RANKSTATUS_FRAME;
s_rankstatus.frame.generic.x = 142; //320-233;
s_rankstatus.frame.generic.y = 118; //240-166;
s_rankstatus.frame.width = 359; //466;
s_rankstatus.frame.height = 256; //332;
y = 214;
s_rankstatus.message.generic.type = MTYPE_PTEXT;
s_rankstatus.message.generic.flags = QMF_CENTER_JUSTIFY|QMF_INACTIVE;
s_rankstatus.message.generic.id = ID_MESSAGE;
s_rankstatus.message.generic.x = 320;
s_rankstatus.message.generic.y = y;
s_rankstatus.message.string = s_rankstatus_message;
s_rankstatus.message.style = UI_CENTER|UI_SMALLFONT;
s_rankstatus.message.color = s_rankingstatus_color_prompt;
y += 40;
s_rankstatus.ok.generic.type = MTYPE_PTEXT;
s_rankstatus.ok.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_rankstatus.ok.generic.id = ID_OK;
s_rankstatus.ok.generic.callback = RankStatus_MenuEvent;
s_rankstatus.ok.generic.x = 320;
s_rankstatus.ok.generic.y = y;
s_rankstatus.ok.string = "OK";
s_rankstatus.ok.style = UI_CENTER|UI_SMALLFONT;
s_rankstatus.ok.color = colorRed;
Menu_AddItem( &s_rankstatus.menu, (void*) &s_rankstatus.frame );
Menu_AddItem( &s_rankstatus.menu, (void*) &s_rankstatus.message );
Menu_AddItem( &s_rankstatus.menu, (void*) &s_rankstatus.ok );
}
/*
===============
RankStatus_Cache
===============
*/
void RankStatus_Cache( void ) {
trap_R_RegisterShaderNoMip( RANKSTATUS_FRAME );
}
/*
===============
UI_RankStatusMenu
===============
*/
void UI_RankStatusMenu( void ) {
s_status = (grank_status_t)trap_Cvar_VariableValue("client_status");
switch( s_status )
{
case QGR_STATUS_NEW:
return;
case QGR_STATUS_PENDING:
// GRANK_FIXME
return;
case QGR_STATUS_NO_USER:
// GRANK_FIXME - get this when user exists
s_rankstatus_message = "Username unavailable";
break;
case QGR_STATUS_BAD_PASSWORD:
s_rankstatus_message = "Invalid password";
break;
case QGR_STATUS_TIMEOUT:
s_rankstatus_message = "Timed out";
break;
case QGR_STATUS_NO_MEMBERSHIP:
s_rankstatus_message = "No membership";
break;
case QGR_STATUS_INVALIDUSER:
s_rankstatus_message = "Validation failed";
break;
case QGR_STATUS_ERROR:
s_rankstatus_message = "Error";
break;
case QGR_STATUS_SPECTATOR:
case QGR_STATUS_ACTIVE:
UI_ForceMenuOff();
return;
default:
return;
}
RankStatus_MenuInit();
trap_CL_UI_RankUserReset();
UI_PushMenu ( &s_rankstatus.menu );
}

View file

@ -1,342 +1,342 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
REMOVE BOTS MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_BACKGROUND "menu/art/addbotframe"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ART_DELETE0 "menu/art/delete_0"
#define ART_DELETE1 "menu/art/delete_1"
#define ART_ARROWS "menu/art/arrows_vert_0"
#define ART_ARROWUP "menu/art/arrows_vert_top"
#define ART_ARROWDOWN "menu/art/arrows_vert_bot"
#define ID_UP 10
#define ID_DOWN 11
#define ID_DELETE 12
#define ID_BACK 13
#define ID_BOTNAME0 20
#define ID_BOTNAME1 21
#define ID_BOTNAME2 22
#define ID_BOTNAME3 23
#define ID_BOTNAME4 24
#define ID_BOTNAME5 25
#define ID_BOTNAME6 26
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s background;
menubitmap_s arrows;
menubitmap_s up;
menubitmap_s down;
menutext_s bots[7];
menubitmap_s delete;
menubitmap_s back;
int numBots;
int baseBotNum;
int selectedBotNum;
char botnames[7][32];
int botClientNums[MAX_BOTS];
} removeBotsMenuInfo_t;
static removeBotsMenuInfo_t removeBotsMenuInfo;
/*
=================
UI_RemoveBotsMenu_SetBotNames
=================
*/
static void UI_RemoveBotsMenu_SetBotNames( void ) {
int n;
char info[MAX_INFO_STRING];
for ( n = 0; (n < 7) && (removeBotsMenuInfo.baseBotNum + n < removeBotsMenuInfo.numBots); n++ ) {
trap_GetConfigString( CS_PLAYERS + removeBotsMenuInfo.botClientNums[removeBotsMenuInfo.baseBotNum + n], info, MAX_INFO_STRING );
Q_strncpyz( removeBotsMenuInfo.botnames[n], Info_ValueForKey( info, "n" ), sizeof(removeBotsMenuInfo.botnames[n]) );
Q_CleanStr( removeBotsMenuInfo.botnames[n] );
}
}
/*
=================
UI_RemoveBotsMenu_DeleteEvent
=================
*/
static void UI_RemoveBotsMenu_DeleteEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
trap_Cmd_ExecuteText( EXEC_APPEND, va("clientkick %i\n", removeBotsMenuInfo.botClientNums[removeBotsMenuInfo.baseBotNum + removeBotsMenuInfo.selectedBotNum]) );
}
/*
=================
UI_RemoveBotsMenu_BotEvent
=================
*/
static void UI_RemoveBotsMenu_BotEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
removeBotsMenuInfo.bots[removeBotsMenuInfo.selectedBotNum].color = color_orange;
removeBotsMenuInfo.selectedBotNum = ((menucommon_s*)ptr)->id - ID_BOTNAME0;
removeBotsMenuInfo.bots[removeBotsMenuInfo.selectedBotNum].color = color_white;
}
/*
=================
UI_RemoveAddBotsMenu_BackEvent
=================
*/
static void UI_RemoveBotsMenu_BackEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
UI_PopMenu();
}
/*
=================
UI_RemoveBotsMenu_UpEvent
=================
*/
static void UI_RemoveBotsMenu_UpEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
if( removeBotsMenuInfo.baseBotNum > 0 ) {
removeBotsMenuInfo.baseBotNum--;
UI_RemoveBotsMenu_SetBotNames();
}
}
/*
=================
UI_RemoveBotsMenu_DownEvent
=================
*/
static void UI_RemoveBotsMenu_DownEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
if( removeBotsMenuInfo.baseBotNum + 7 < removeBotsMenuInfo.numBots ) {
removeBotsMenuInfo.baseBotNum++;
UI_RemoveBotsMenu_SetBotNames();
}
}
/*
=================
UI_RemoveBotsMenu_GetBots
=================
*/
static void UI_RemoveBotsMenu_GetBots( void ) {
int numPlayers;
int isBot;
int n;
char info[MAX_INFO_STRING];
trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) );
numPlayers = atoi( Info_ValueForKey( info, "sv_maxclients" ) );
removeBotsMenuInfo.numBots = 0;
for( n = 0; n < numPlayers; n++ ) {
trap_GetConfigString( CS_PLAYERS + n, info, MAX_INFO_STRING );
isBot = atoi( Info_ValueForKey( info, "skill" ) );
if( !isBot ) {
continue;
}
removeBotsMenuInfo.botClientNums[removeBotsMenuInfo.numBots] = n;
removeBotsMenuInfo.numBots++;
}
}
/*
=================
UI_RemoveBots_Cache
=================
*/
void UI_RemoveBots_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_BACKGROUND );
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
trap_R_RegisterShaderNoMip( ART_DELETE0 );
trap_R_RegisterShaderNoMip( ART_DELETE1 );
}
/*
=================
UI_RemoveBotsMenu_Init
=================
*/
static void UI_RemoveBotsMenu_Init( void ) {
int n;
int count;
int y;
memset( &removeBotsMenuInfo, 0 ,sizeof(removeBotsMenuInfo) );
removeBotsMenuInfo.menu.fullscreen = qfalse;
removeBotsMenuInfo.menu.wrapAround = qtrue;
UI_RemoveBots_Cache();
UI_RemoveBotsMenu_GetBots();
UI_RemoveBotsMenu_SetBotNames();
count = removeBotsMenuInfo.numBots < 7 ? removeBotsMenuInfo.numBots : 7;
removeBotsMenuInfo.banner.generic.type = MTYPE_BTEXT;
removeBotsMenuInfo.banner.generic.x = 320;
removeBotsMenuInfo.banner.generic.y = 16;
removeBotsMenuInfo.banner.string = "REMOVE BOTS";
removeBotsMenuInfo.banner.color = color_white;
removeBotsMenuInfo.banner.style = UI_CENTER;
removeBotsMenuInfo.background.generic.type = MTYPE_BITMAP;
removeBotsMenuInfo.background.generic.name = ART_BACKGROUND;
removeBotsMenuInfo.background.generic.flags = QMF_INACTIVE;
removeBotsMenuInfo.background.generic.x = 320-233;
removeBotsMenuInfo.background.generic.y = 240-166;
removeBotsMenuInfo.background.width = 466;
removeBotsMenuInfo.background.height = 332;
removeBotsMenuInfo.arrows.generic.type = MTYPE_BITMAP;
removeBotsMenuInfo.arrows.generic.name = ART_ARROWS;
removeBotsMenuInfo.arrows.generic.flags = QMF_INACTIVE;
removeBotsMenuInfo.arrows.generic.x = 200;
removeBotsMenuInfo.arrows.generic.y = 128;
removeBotsMenuInfo.arrows.width = 64;
removeBotsMenuInfo.arrows.height = 128;
removeBotsMenuInfo.up.generic.type = MTYPE_BITMAP;
removeBotsMenuInfo.up.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
removeBotsMenuInfo.up.generic.x = 200;
removeBotsMenuInfo.up.generic.y = 128;
removeBotsMenuInfo.up.generic.id = ID_UP;
removeBotsMenuInfo.up.generic.callback = UI_RemoveBotsMenu_UpEvent;
removeBotsMenuInfo.up.width = 64;
removeBotsMenuInfo.up.height = 64;
removeBotsMenuInfo.up.focuspic = ART_ARROWUP;
removeBotsMenuInfo.down.generic.type = MTYPE_BITMAP;
removeBotsMenuInfo.down.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
removeBotsMenuInfo.down.generic.x = 200;
removeBotsMenuInfo.down.generic.y = 128+64;
removeBotsMenuInfo.down.generic.id = ID_DOWN;
removeBotsMenuInfo.down.generic.callback = UI_RemoveBotsMenu_DownEvent;
removeBotsMenuInfo.down.width = 64;
removeBotsMenuInfo.down.height = 64;
removeBotsMenuInfo.down.focuspic = ART_ARROWDOWN;
for( n = 0, y = 120; n < count; n++, y += 20 ) {
removeBotsMenuInfo.bots[n].generic.type = MTYPE_PTEXT;
removeBotsMenuInfo.bots[n].generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
removeBotsMenuInfo.bots[n].generic.id = ID_BOTNAME0 + n;
removeBotsMenuInfo.bots[n].generic.x = 320 - 56;
removeBotsMenuInfo.bots[n].generic.y = y;
removeBotsMenuInfo.bots[n].generic.callback = UI_RemoveBotsMenu_BotEvent;
removeBotsMenuInfo.bots[n].string = removeBotsMenuInfo.botnames[n];
removeBotsMenuInfo.bots[n].color = color_orange;
removeBotsMenuInfo.bots[n].style = UI_LEFT|UI_SMALLFONT;
}
removeBotsMenuInfo.delete.generic.type = MTYPE_BITMAP;
removeBotsMenuInfo.delete.generic.name = ART_DELETE0;
removeBotsMenuInfo.delete.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
removeBotsMenuInfo.delete.generic.id = ID_DELETE;
removeBotsMenuInfo.delete.generic.callback = UI_RemoveBotsMenu_DeleteEvent;
removeBotsMenuInfo.delete.generic.x = 320+128-128;
removeBotsMenuInfo.delete.generic.y = 256+128-64;
removeBotsMenuInfo.delete.width = 128;
removeBotsMenuInfo.delete.height = 64;
removeBotsMenuInfo.delete.focuspic = ART_DELETE1;
removeBotsMenuInfo.back.generic.type = MTYPE_BITMAP;
removeBotsMenuInfo.back.generic.name = ART_BACK0;
removeBotsMenuInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
removeBotsMenuInfo.back.generic.id = ID_BACK;
removeBotsMenuInfo.back.generic.callback = UI_RemoveBotsMenu_BackEvent;
removeBotsMenuInfo.back.generic.x = 320-128;
removeBotsMenuInfo.back.generic.y = 256+128-64;
removeBotsMenuInfo.back.width = 128;
removeBotsMenuInfo.back.height = 64;
removeBotsMenuInfo.back.focuspic = ART_BACK1;
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.background );
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.banner );
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.arrows );
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.up );
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.down );
for( n = 0; n < count; n++ ) {
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.bots[n] );
}
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.delete );
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.back );
removeBotsMenuInfo.baseBotNum = 0;
removeBotsMenuInfo.selectedBotNum = 0;
removeBotsMenuInfo.bots[0].color = color_white;
}
/*
=================
UI_RemoveBotsMenu
=================
*/
void UI_RemoveBotsMenu( void ) {
UI_RemoveBotsMenu_Init();
UI_PushMenu( &removeBotsMenuInfo.menu );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
REMOVE BOTS MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_BACKGROUND "menu/art/addbotframe"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ART_DELETE0 "menu/art/delete_0"
#define ART_DELETE1 "menu/art/delete_1"
#define ART_ARROWS "menu/art/arrows_vert_0"
#define ART_ARROWUP "menu/art/arrows_vert_top"
#define ART_ARROWDOWN "menu/art/arrows_vert_bot"
#define ID_UP 10
#define ID_DOWN 11
#define ID_DELETE 12
#define ID_BACK 13
#define ID_BOTNAME0 20
#define ID_BOTNAME1 21
#define ID_BOTNAME2 22
#define ID_BOTNAME3 23
#define ID_BOTNAME4 24
#define ID_BOTNAME5 25
#define ID_BOTNAME6 26
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s background;
menubitmap_s arrows;
menubitmap_s up;
menubitmap_s down;
menutext_s bots[7];
menubitmap_s delete;
menubitmap_s back;
int numBots;
int baseBotNum;
int selectedBotNum;
char botnames[7][32];
int botClientNums[MAX_BOTS];
} removeBotsMenuInfo_t;
static removeBotsMenuInfo_t removeBotsMenuInfo;
/*
=================
UI_RemoveBotsMenu_SetBotNames
=================
*/
static void UI_RemoveBotsMenu_SetBotNames( void ) {
int n;
char info[MAX_INFO_STRING];
for ( n = 0; (n < 7) && (removeBotsMenuInfo.baseBotNum + n < removeBotsMenuInfo.numBots); n++ ) {
trap_GetConfigString( CS_PLAYERS + removeBotsMenuInfo.botClientNums[removeBotsMenuInfo.baseBotNum + n], info, MAX_INFO_STRING );
Q_strncpyz( removeBotsMenuInfo.botnames[n], Info_ValueForKey( info, "n" ), sizeof(removeBotsMenuInfo.botnames[n]) );
Q_CleanStr( removeBotsMenuInfo.botnames[n] );
}
}
/*
=================
UI_RemoveBotsMenu_DeleteEvent
=================
*/
static void UI_RemoveBotsMenu_DeleteEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
trap_Cmd_ExecuteText( EXEC_APPEND, va("clientkick %i\n", removeBotsMenuInfo.botClientNums[removeBotsMenuInfo.baseBotNum + removeBotsMenuInfo.selectedBotNum]) );
}
/*
=================
UI_RemoveBotsMenu_BotEvent
=================
*/
static void UI_RemoveBotsMenu_BotEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
removeBotsMenuInfo.bots[removeBotsMenuInfo.selectedBotNum].color = color_orange;
removeBotsMenuInfo.selectedBotNum = ((menucommon_s*)ptr)->id - ID_BOTNAME0;
removeBotsMenuInfo.bots[removeBotsMenuInfo.selectedBotNum].color = color_white;
}
/*
=================
UI_RemoveAddBotsMenu_BackEvent
=================
*/
static void UI_RemoveBotsMenu_BackEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
UI_PopMenu();
}
/*
=================
UI_RemoveBotsMenu_UpEvent
=================
*/
static void UI_RemoveBotsMenu_UpEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
if( removeBotsMenuInfo.baseBotNum > 0 ) {
removeBotsMenuInfo.baseBotNum--;
UI_RemoveBotsMenu_SetBotNames();
}
}
/*
=================
UI_RemoveBotsMenu_DownEvent
=================
*/
static void UI_RemoveBotsMenu_DownEvent( void* ptr, int event ) {
if (event != QM_ACTIVATED) {
return;
}
if( removeBotsMenuInfo.baseBotNum + 7 < removeBotsMenuInfo.numBots ) {
removeBotsMenuInfo.baseBotNum++;
UI_RemoveBotsMenu_SetBotNames();
}
}
/*
=================
UI_RemoveBotsMenu_GetBots
=================
*/
static void UI_RemoveBotsMenu_GetBots( void ) {
int numPlayers;
int isBot;
int n;
char info[MAX_INFO_STRING];
trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) );
numPlayers = atoi( Info_ValueForKey( info, "sv_maxclients" ) );
removeBotsMenuInfo.numBots = 0;
for( n = 0; n < numPlayers; n++ ) {
trap_GetConfigString( CS_PLAYERS + n, info, MAX_INFO_STRING );
isBot = atoi( Info_ValueForKey( info, "skill" ) );
if( !isBot ) {
continue;
}
removeBotsMenuInfo.botClientNums[removeBotsMenuInfo.numBots] = n;
removeBotsMenuInfo.numBots++;
}
}
/*
=================
UI_RemoveBots_Cache
=================
*/
void UI_RemoveBots_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_BACKGROUND );
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
trap_R_RegisterShaderNoMip( ART_DELETE0 );
trap_R_RegisterShaderNoMip( ART_DELETE1 );
}
/*
=================
UI_RemoveBotsMenu_Init
=================
*/
static void UI_RemoveBotsMenu_Init( void ) {
int n;
int count;
int y;
memset( &removeBotsMenuInfo, 0 ,sizeof(removeBotsMenuInfo) );
removeBotsMenuInfo.menu.fullscreen = qfalse;
removeBotsMenuInfo.menu.wrapAround = qtrue;
UI_RemoveBots_Cache();
UI_RemoveBotsMenu_GetBots();
UI_RemoveBotsMenu_SetBotNames();
count = removeBotsMenuInfo.numBots < 7 ? removeBotsMenuInfo.numBots : 7;
removeBotsMenuInfo.banner.generic.type = MTYPE_BTEXT;
removeBotsMenuInfo.banner.generic.x = 320;
removeBotsMenuInfo.banner.generic.y = 16;
removeBotsMenuInfo.banner.string = "REMOVE BOTS";
removeBotsMenuInfo.banner.color = color_white;
removeBotsMenuInfo.banner.style = UI_CENTER;
removeBotsMenuInfo.background.generic.type = MTYPE_BITMAP;
removeBotsMenuInfo.background.generic.name = ART_BACKGROUND;
removeBotsMenuInfo.background.generic.flags = QMF_INACTIVE;
removeBotsMenuInfo.background.generic.x = 320-233;
removeBotsMenuInfo.background.generic.y = 240-166;
removeBotsMenuInfo.background.width = 466;
removeBotsMenuInfo.background.height = 332;
removeBotsMenuInfo.arrows.generic.type = MTYPE_BITMAP;
removeBotsMenuInfo.arrows.generic.name = ART_ARROWS;
removeBotsMenuInfo.arrows.generic.flags = QMF_INACTIVE;
removeBotsMenuInfo.arrows.generic.x = 200;
removeBotsMenuInfo.arrows.generic.y = 128;
removeBotsMenuInfo.arrows.width = 64;
removeBotsMenuInfo.arrows.height = 128;
removeBotsMenuInfo.up.generic.type = MTYPE_BITMAP;
removeBotsMenuInfo.up.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
removeBotsMenuInfo.up.generic.x = 200;
removeBotsMenuInfo.up.generic.y = 128;
removeBotsMenuInfo.up.generic.id = ID_UP;
removeBotsMenuInfo.up.generic.callback = UI_RemoveBotsMenu_UpEvent;
removeBotsMenuInfo.up.width = 64;
removeBotsMenuInfo.up.height = 64;
removeBotsMenuInfo.up.focuspic = ART_ARROWUP;
removeBotsMenuInfo.down.generic.type = MTYPE_BITMAP;
removeBotsMenuInfo.down.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
removeBotsMenuInfo.down.generic.x = 200;
removeBotsMenuInfo.down.generic.y = 128+64;
removeBotsMenuInfo.down.generic.id = ID_DOWN;
removeBotsMenuInfo.down.generic.callback = UI_RemoveBotsMenu_DownEvent;
removeBotsMenuInfo.down.width = 64;
removeBotsMenuInfo.down.height = 64;
removeBotsMenuInfo.down.focuspic = ART_ARROWDOWN;
for( n = 0, y = 120; n < count; n++, y += 20 ) {
removeBotsMenuInfo.bots[n].generic.type = MTYPE_PTEXT;
removeBotsMenuInfo.bots[n].generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
removeBotsMenuInfo.bots[n].generic.id = ID_BOTNAME0 + n;
removeBotsMenuInfo.bots[n].generic.x = 320 - 56;
removeBotsMenuInfo.bots[n].generic.y = y;
removeBotsMenuInfo.bots[n].generic.callback = UI_RemoveBotsMenu_BotEvent;
removeBotsMenuInfo.bots[n].string = removeBotsMenuInfo.botnames[n];
removeBotsMenuInfo.bots[n].color = color_orange;
removeBotsMenuInfo.bots[n].style = UI_LEFT|UI_SMALLFONT;
}
removeBotsMenuInfo.delete.generic.type = MTYPE_BITMAP;
removeBotsMenuInfo.delete.generic.name = ART_DELETE0;
removeBotsMenuInfo.delete.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
removeBotsMenuInfo.delete.generic.id = ID_DELETE;
removeBotsMenuInfo.delete.generic.callback = UI_RemoveBotsMenu_DeleteEvent;
removeBotsMenuInfo.delete.generic.x = 320+128-128;
removeBotsMenuInfo.delete.generic.y = 256+128-64;
removeBotsMenuInfo.delete.width = 128;
removeBotsMenuInfo.delete.height = 64;
removeBotsMenuInfo.delete.focuspic = ART_DELETE1;
removeBotsMenuInfo.back.generic.type = MTYPE_BITMAP;
removeBotsMenuInfo.back.generic.name = ART_BACK0;
removeBotsMenuInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
removeBotsMenuInfo.back.generic.id = ID_BACK;
removeBotsMenuInfo.back.generic.callback = UI_RemoveBotsMenu_BackEvent;
removeBotsMenuInfo.back.generic.x = 320-128;
removeBotsMenuInfo.back.generic.y = 256+128-64;
removeBotsMenuInfo.back.width = 128;
removeBotsMenuInfo.back.height = 64;
removeBotsMenuInfo.back.focuspic = ART_BACK1;
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.background );
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.banner );
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.arrows );
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.up );
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.down );
for( n = 0; n < count; n++ ) {
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.bots[n] );
}
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.delete );
Menu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.back );
removeBotsMenuInfo.baseBotNum = 0;
removeBotsMenuInfo.selectedBotNum = 0;
removeBotsMenuInfo.bots[0].color = color_white;
}
/*
=================
UI_RemoveBotsMenu
=================
*/
void UI_RemoveBotsMenu( void ) {
UI_RemoveBotsMenu_Init();
UI_PushMenu( &removeBotsMenuInfo.menu );
}

View file

@ -1,212 +1,212 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=============================================================================
SAVE CONFIG MENU
=============================================================================
*/
#include "ui_local.h"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ART_SAVE0 "menu/art/save_0"
#define ART_SAVE1 "menu/art/save_1"
#define ART_BACKGROUND "menu/art/cut_frame"
#define ID_NAME 10
#define ID_BACK 11
#define ID_SAVE 12
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s background;
menufield_s savename;
menubitmap_s back;
menubitmap_s save;
} saveConfig_t;
static saveConfig_t saveConfig;
/*
===============
UI_SaveConfigMenu_BackEvent
===============
*/
static void UI_SaveConfigMenu_BackEvent( void *ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
UI_PopMenu();
}
/*
===============
UI_SaveConfigMenu_SaveEvent
===============
*/
static void UI_SaveConfigMenu_SaveEvent( void *ptr, int event ) {
char configname[MAX_QPATH];
if( event != QM_ACTIVATED ) {
return;
}
if( !saveConfig.savename.field.buffer[0] ) {
return;
}
COM_StripExtension(saveConfig.savename.field.buffer, configname );
trap_Cmd_ExecuteText( EXEC_APPEND, va( "writeconfig %s.cfg\n", configname ) );
UI_PopMenu();
}
/*
===============
UI_SaveConfigMenu_SavenameDraw
===============
*/
static void UI_SaveConfigMenu_SavenameDraw( void *self ) {
menufield_s *f;
int style;
float *color;
f = (menufield_s *)self;
if( f == Menu_ItemAtCursor( &saveConfig.menu ) ) {
style = UI_LEFT|UI_PULSE|UI_SMALLFONT;
color = text_color_highlight;
}
else {
style = UI_LEFT|UI_SMALLFONT;
color = colorRed;
}
UI_DrawProportionalString( 320, 192, "Enter filename:", UI_CENTER|UI_SMALLFONT, color_orange );
UI_FillRect( f->generic.x, f->generic.y, f->field.widthInChars*SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, colorBlack );
MField_Draw( &f->field, f->generic.x, f->generic.y, style, color );
}
/*
=================
UI_SaveConfigMenu_Init
=================
*/
static void UI_SaveConfigMenu_Init( void ) {
memset( &saveConfig, 0, sizeof(saveConfig) );
UI_SaveConfigMenu_Cache();
saveConfig.menu.wrapAround = qtrue;
saveConfig.menu.fullscreen = qtrue;
saveConfig.banner.generic.type = MTYPE_BTEXT;
saveConfig.banner.generic.x = 320;
saveConfig.banner.generic.y = 16;
saveConfig.banner.string = "SAVE CONFIG";
saveConfig.banner.color = color_white;
saveConfig.banner.style = UI_CENTER;
saveConfig.background.generic.type = MTYPE_BITMAP;
saveConfig.background.generic.name = ART_BACKGROUND;
saveConfig.background.generic.flags = QMF_INACTIVE;
saveConfig.background.generic.x = 142;
saveConfig.background.generic.y = 118;
saveConfig.background.width = 359;
saveConfig.background.height = 256;
saveConfig.savename.generic.type = MTYPE_FIELD;
saveConfig.savename.generic.flags = QMF_NODEFAULTINIT|QMF_UPPERCASE;
saveConfig.savename.generic.ownerdraw = UI_SaveConfigMenu_SavenameDraw;
saveConfig.savename.field.widthInChars = 20;
saveConfig.savename.field.maxchars = 20;
saveConfig.savename.generic.x = 240;
saveConfig.savename.generic.y = 155+72;
saveConfig.savename.generic.left = 240;
saveConfig.savename.generic.top = 155+72;
saveConfig.savename.generic.right = 233 + 20*SMALLCHAR_WIDTH;
saveConfig.savename.generic.bottom = 155+72 + SMALLCHAR_HEIGHT+2;
saveConfig.back.generic.type = MTYPE_BITMAP;
saveConfig.back.generic.name = ART_BACK0;
saveConfig.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
saveConfig.back.generic.id = ID_BACK;
saveConfig.back.generic.callback = UI_SaveConfigMenu_BackEvent;
saveConfig.back.generic.x = 0;
saveConfig.back.generic.y = 480-64;
saveConfig.back.width = 128;
saveConfig.back.height = 64;
saveConfig.back.focuspic = ART_BACK1;
saveConfig.save.generic.type = MTYPE_BITMAP;
saveConfig.save.generic.name = ART_SAVE0;
saveConfig.save.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
saveConfig.save.generic.id = ID_SAVE;
saveConfig.save.generic.callback = UI_SaveConfigMenu_SaveEvent;
saveConfig.save.generic.x = 640;
saveConfig.save.generic.y = 480-64;
saveConfig.save.width = 128;
saveConfig.save.height = 64;
saveConfig.save.focuspic = ART_SAVE1;
Menu_AddItem( &saveConfig.menu, &saveConfig.banner );
Menu_AddItem( &saveConfig.menu, &saveConfig.background );
Menu_AddItem( &saveConfig.menu, &saveConfig.savename );
Menu_AddItem( &saveConfig.menu, &saveConfig.back );
Menu_AddItem( &saveConfig.menu, &saveConfig.save );
}
/*
=================
UI_SaveConfigMenu_Cache
=================
*/
void UI_SaveConfigMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
trap_R_RegisterShaderNoMip( ART_SAVE0 );
trap_R_RegisterShaderNoMip( ART_SAVE1 );
trap_R_RegisterShaderNoMip( ART_BACKGROUND );
}
/*
===============
UI_SaveConfigMenu
===============
*/
void UI_SaveConfigMenu( void ) {
UI_SaveConfigMenu_Init();
UI_PushMenu( &saveConfig.menu );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=============================================================================
SAVE CONFIG MENU
=============================================================================
*/
#include "ui_local.h"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ART_SAVE0 "menu/art/save_0"
#define ART_SAVE1 "menu/art/save_1"
#define ART_BACKGROUND "menu/art/cut_frame"
#define ID_NAME 10
#define ID_BACK 11
#define ID_SAVE 12
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s background;
menufield_s savename;
menubitmap_s back;
menubitmap_s save;
} saveConfig_t;
static saveConfig_t saveConfig;
/*
===============
UI_SaveConfigMenu_BackEvent
===============
*/
static void UI_SaveConfigMenu_BackEvent( void *ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
UI_PopMenu();
}
/*
===============
UI_SaveConfigMenu_SaveEvent
===============
*/
static void UI_SaveConfigMenu_SaveEvent( void *ptr, int event ) {
char configname[MAX_QPATH];
if( event != QM_ACTIVATED ) {
return;
}
if( !saveConfig.savename.field.buffer[0] ) {
return;
}
COM_StripExtension(saveConfig.savename.field.buffer, configname );
trap_Cmd_ExecuteText( EXEC_APPEND, va( "writeconfig %s.cfg\n", configname ) );
UI_PopMenu();
}
/*
===============
UI_SaveConfigMenu_SavenameDraw
===============
*/
static void UI_SaveConfigMenu_SavenameDraw( void *self ) {
menufield_s *f;
int style;
float *color;
f = (menufield_s *)self;
if( f == Menu_ItemAtCursor( &saveConfig.menu ) ) {
style = UI_LEFT|UI_PULSE|UI_SMALLFONT;
color = text_color_highlight;
}
else {
style = UI_LEFT|UI_SMALLFONT;
color = colorRed;
}
UI_DrawProportionalString( 320, 192, "Enter filename:", UI_CENTER|UI_SMALLFONT, color_orange );
UI_FillRect( f->generic.x, f->generic.y, f->field.widthInChars*SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, colorBlack );
MField_Draw( &f->field, f->generic.x, f->generic.y, style, color );
}
/*
=================
UI_SaveConfigMenu_Init
=================
*/
static void UI_SaveConfigMenu_Init( void ) {
memset( &saveConfig, 0, sizeof(saveConfig) );
UI_SaveConfigMenu_Cache();
saveConfig.menu.wrapAround = qtrue;
saveConfig.menu.fullscreen = qtrue;
saveConfig.banner.generic.type = MTYPE_BTEXT;
saveConfig.banner.generic.x = 320;
saveConfig.banner.generic.y = 16;
saveConfig.banner.string = "SAVE CONFIG";
saveConfig.banner.color = color_white;
saveConfig.banner.style = UI_CENTER;
saveConfig.background.generic.type = MTYPE_BITMAP;
saveConfig.background.generic.name = ART_BACKGROUND;
saveConfig.background.generic.flags = QMF_INACTIVE;
saveConfig.background.generic.x = 142;
saveConfig.background.generic.y = 118;
saveConfig.background.width = 359;
saveConfig.background.height = 256;
saveConfig.savename.generic.type = MTYPE_FIELD;
saveConfig.savename.generic.flags = QMF_NODEFAULTINIT|QMF_UPPERCASE;
saveConfig.savename.generic.ownerdraw = UI_SaveConfigMenu_SavenameDraw;
saveConfig.savename.field.widthInChars = 20;
saveConfig.savename.field.maxchars = 20;
saveConfig.savename.generic.x = 240;
saveConfig.savename.generic.y = 155+72;
saveConfig.savename.generic.left = 240;
saveConfig.savename.generic.top = 155+72;
saveConfig.savename.generic.right = 233 + 20*SMALLCHAR_WIDTH;
saveConfig.savename.generic.bottom = 155+72 + SMALLCHAR_HEIGHT+2;
saveConfig.back.generic.type = MTYPE_BITMAP;
saveConfig.back.generic.name = ART_BACK0;
saveConfig.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
saveConfig.back.generic.id = ID_BACK;
saveConfig.back.generic.callback = UI_SaveConfigMenu_BackEvent;
saveConfig.back.generic.x = 0;
saveConfig.back.generic.y = 480-64;
saveConfig.back.width = 128;
saveConfig.back.height = 64;
saveConfig.back.focuspic = ART_BACK1;
saveConfig.save.generic.type = MTYPE_BITMAP;
saveConfig.save.generic.name = ART_SAVE0;
saveConfig.save.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
saveConfig.save.generic.id = ID_SAVE;
saveConfig.save.generic.callback = UI_SaveConfigMenu_SaveEvent;
saveConfig.save.generic.x = 640;
saveConfig.save.generic.y = 480-64;
saveConfig.save.width = 128;
saveConfig.save.height = 64;
saveConfig.save.focuspic = ART_SAVE1;
Menu_AddItem( &saveConfig.menu, &saveConfig.banner );
Menu_AddItem( &saveConfig.menu, &saveConfig.background );
Menu_AddItem( &saveConfig.menu, &saveConfig.savename );
Menu_AddItem( &saveConfig.menu, &saveConfig.back );
Menu_AddItem( &saveConfig.menu, &saveConfig.save );
}
/*
=================
UI_SaveConfigMenu_Cache
=================
*/
void UI_SaveConfigMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
trap_R_RegisterShaderNoMip( ART_SAVE0 );
trap_R_RegisterShaderNoMip( ART_SAVE1 );
trap_R_RegisterShaderNoMip( ART_BACKGROUND );
}
/*
===============
UI_SaveConfigMenu
===============
*/
void UI_SaveConfigMenu( void ) {
UI_SaveConfigMenu_Init();
UI_PushMenu( &saveConfig.menu );
}

View file

@ -1,272 +1,272 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#include "ui_local.h"
#define SERVERINFO_FRAMEL "menu/art/frame2_l"
#define SERVERINFO_FRAMER "menu/art/frame1_r"
#define SERVERINFO_BACK0 "menu/art/back_0"
#define SERVERINFO_BACK1 "menu/art/back_1"
static char* serverinfo_artlist[] =
{
SERVERINFO_FRAMEL,
SERVERINFO_FRAMER,
SERVERINFO_BACK0,
SERVERINFO_BACK1,
NULL
};
#define ID_ADD 100
#define ID_BACK 101
typedef struct
{
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menubitmap_s back;
menutext_s add;
char info[MAX_INFO_STRING];
int numlines;
} serverinfo_t;
static serverinfo_t s_serverinfo;
/*
=================
Favorites_Add
Add current server to favorites
=================
*/
void Favorites_Add( void )
{
char adrstr[128];
char serverbuff[128];
int i;
int best;
trap_Cvar_VariableStringBuffer( "cl_currentServerAddress", serverbuff, sizeof(serverbuff) );
if (!serverbuff[0])
return;
best = 0;
for (i=0; i<MAX_FAVORITESERVERS; i++)
{
trap_Cvar_VariableStringBuffer( va("server%d",i+1), adrstr, sizeof(adrstr) );
if (!Q_stricmp(serverbuff,adrstr))
{
// already in list
return;
}
// use first empty or non-numeric available slot
if ((adrstr[0] < '0' || adrstr[0] > '9' ) && !best)
best = i+1;
}
if (best)
trap_Cvar_Set( va("server%d",best), serverbuff);
}
/*
=================
ServerInfo_Event
=================
*/
static void ServerInfo_Event( void* ptr, int event )
{
switch (((menucommon_s*)ptr)->id)
{
case ID_ADD:
if (event != QM_ACTIVATED)
break;
Favorites_Add();
UI_PopMenu();
break;
case ID_BACK:
if (event != QM_ACTIVATED)
break;
UI_PopMenu();
break;
}
}
/*
=================
ServerInfo_MenuDraw
=================
*/
static void ServerInfo_MenuDraw( void )
{
const char *s;
char key[MAX_INFO_KEY];
char value[MAX_INFO_VALUE];
int y;
y = SCREEN_HEIGHT/2 - s_serverinfo.numlines*(SMALLCHAR_HEIGHT)/2 - 20;
s = s_serverinfo.info;
while ( s ) {
Info_NextPair( &s, key, value );
if ( !key[0] ) {
break;
}
Q_strcat( key, MAX_INFO_KEY, ":" );
UI_DrawString(SCREEN_WIDTH*0.50 - 8,y,key,UI_RIGHT|UI_SMALLFONT,color_red);
UI_DrawString(SCREEN_WIDTH*0.50 + 8,y,value,UI_LEFT|UI_SMALLFONT,text_color_normal);
y += SMALLCHAR_HEIGHT;
}
Menu_Draw( &s_serverinfo.menu );
}
/*
=================
ServerInfo_MenuKey
=================
*/
static sfxHandle_t ServerInfo_MenuKey( int key )
{
return ( Menu_DefaultKey( &s_serverinfo.menu, key ) );
}
/*
=================
ServerInfo_Cache
=================
*/
void ServerInfo_Cache( void )
{
int i;
// touch all our pics
for (i=0; ;i++)
{
if (!serverinfo_artlist[i])
break;
trap_R_RegisterShaderNoMip(serverinfo_artlist[i]);
}
}
/*
=================
UI_ServerInfoMenu
=================
*/
void UI_ServerInfoMenu( void )
{
const char *s;
char key[MAX_INFO_KEY];
char value[MAX_INFO_VALUE];
// zero set all our globals
memset( &s_serverinfo, 0 ,sizeof(serverinfo_t) );
ServerInfo_Cache();
s_serverinfo.menu.draw = ServerInfo_MenuDraw;
s_serverinfo.menu.key = ServerInfo_MenuKey;
s_serverinfo.menu.wrapAround = qtrue;
s_serverinfo.menu.fullscreen = qtrue;
s_serverinfo.banner.generic.type = MTYPE_BTEXT;
s_serverinfo.banner.generic.x = 320;
s_serverinfo.banner.generic.y = 16;
s_serverinfo.banner.string = "SERVER INFO";
s_serverinfo.banner.color = color_white;
s_serverinfo.banner.style = UI_CENTER;
s_serverinfo.framel.generic.type = MTYPE_BITMAP;
s_serverinfo.framel.generic.name = SERVERINFO_FRAMEL;
s_serverinfo.framel.generic.flags = QMF_INACTIVE;
s_serverinfo.framel.generic.x = 0;
s_serverinfo.framel.generic.y = 78;
s_serverinfo.framel.width = 256;
s_serverinfo.framel.height = 329;
s_serverinfo.framer.generic.type = MTYPE_BITMAP;
s_serverinfo.framer.generic.name = SERVERINFO_FRAMER;
s_serverinfo.framer.generic.flags = QMF_INACTIVE;
s_serverinfo.framer.generic.x = 376;
s_serverinfo.framer.generic.y = 76;
s_serverinfo.framer.width = 256;
s_serverinfo.framer.height = 334;
s_serverinfo.add.generic.type = MTYPE_PTEXT;
s_serverinfo.add.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_serverinfo.add.generic.callback = ServerInfo_Event;
s_serverinfo.add.generic.id = ID_ADD;
s_serverinfo.add.generic.x = 320;
s_serverinfo.add.generic.y = 371;
s_serverinfo.add.string = "ADD TO FAVORITES";
s_serverinfo.add.style = UI_CENTER|UI_SMALLFONT;
s_serverinfo.add.color = color_red;
if( trap_Cvar_VariableValue( "sv_running" ) ) {
s_serverinfo.add.generic.flags |= QMF_GRAYED;
}
s_serverinfo.back.generic.type = MTYPE_BITMAP;
s_serverinfo.back.generic.name = SERVERINFO_BACK0;
s_serverinfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_serverinfo.back.generic.callback = ServerInfo_Event;
s_serverinfo.back.generic.id = ID_BACK;
s_serverinfo.back.generic.x = 0;
s_serverinfo.back.generic.y = 480-64;
s_serverinfo.back.width = 128;
s_serverinfo.back.height = 64;
s_serverinfo.back.focuspic = SERVERINFO_BACK1;
trap_GetConfigString( CS_SERVERINFO, s_serverinfo.info, MAX_INFO_STRING );
s_serverinfo.numlines = 0;
s = s_serverinfo.info;
while ( s ) {
Info_NextPair( &s, key, value );
if ( !key[0] ) {
break;
}
s_serverinfo.numlines++;
}
if (s_serverinfo.numlines > 16)
s_serverinfo.numlines = 16;
Menu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.banner );
Menu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.framel );
Menu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.framer );
Menu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.add );
Menu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.back );
UI_PushMenu( &s_serverinfo.menu );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#include "ui_local.h"
#define SERVERINFO_FRAMEL "menu/art/frame2_l"
#define SERVERINFO_FRAMER "menu/art/frame1_r"
#define SERVERINFO_BACK0 "menu/art/back_0"
#define SERVERINFO_BACK1 "menu/art/back_1"
static char* serverinfo_artlist[] =
{
SERVERINFO_FRAMEL,
SERVERINFO_FRAMER,
SERVERINFO_BACK0,
SERVERINFO_BACK1,
NULL
};
#define ID_ADD 100
#define ID_BACK 101
typedef struct
{
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menubitmap_s back;
menutext_s add;
char info[MAX_INFO_STRING];
int numlines;
} serverinfo_t;
static serverinfo_t s_serverinfo;
/*
=================
Favorites_Add
Add current server to favorites
=================
*/
void Favorites_Add( void )
{
char adrstr[128];
char serverbuff[128];
int i;
int best;
trap_Cvar_VariableStringBuffer( "cl_currentServerAddress", serverbuff, sizeof(serverbuff) );
if (!serverbuff[0])
return;
best = 0;
for (i=0; i<MAX_FAVORITESERVERS; i++)
{
trap_Cvar_VariableStringBuffer( va("server%d",i+1), adrstr, sizeof(adrstr) );
if (!Q_stricmp(serverbuff,adrstr))
{
// already in list
return;
}
// use first empty or non-numeric available slot
if ((adrstr[0] < '0' || adrstr[0] > '9' ) && !best)
best = i+1;
}
if (best)
trap_Cvar_Set( va("server%d",best), serverbuff);
}
/*
=================
ServerInfo_Event
=================
*/
static void ServerInfo_Event( void* ptr, int event )
{
switch (((menucommon_s*)ptr)->id)
{
case ID_ADD:
if (event != QM_ACTIVATED)
break;
Favorites_Add();
UI_PopMenu();
break;
case ID_BACK:
if (event != QM_ACTIVATED)
break;
UI_PopMenu();
break;
}
}
/*
=================
ServerInfo_MenuDraw
=================
*/
static void ServerInfo_MenuDraw( void )
{
const char *s;
char key[MAX_INFO_KEY];
char value[MAX_INFO_VALUE];
int y;
y = SCREEN_HEIGHT/2 - s_serverinfo.numlines*(SMALLCHAR_HEIGHT)/2 - 20;
s = s_serverinfo.info;
while ( s ) {
Info_NextPair( &s, key, value );
if ( !key[0] ) {
break;
}
Q_strcat( key, MAX_INFO_KEY, ":" );
UI_DrawString(SCREEN_WIDTH*0.50 - 8,y,key,UI_RIGHT|UI_SMALLFONT,color_red);
UI_DrawString(SCREEN_WIDTH*0.50 + 8,y,value,UI_LEFT|UI_SMALLFONT,text_color_normal);
y += SMALLCHAR_HEIGHT;
}
Menu_Draw( &s_serverinfo.menu );
}
/*
=================
ServerInfo_MenuKey
=================
*/
static sfxHandle_t ServerInfo_MenuKey( int key )
{
return ( Menu_DefaultKey( &s_serverinfo.menu, key ) );
}
/*
=================
ServerInfo_Cache
=================
*/
void ServerInfo_Cache( void )
{
int i;
// touch all our pics
for (i=0; ;i++)
{
if (!serverinfo_artlist[i])
break;
trap_R_RegisterShaderNoMip(serverinfo_artlist[i]);
}
}
/*
=================
UI_ServerInfoMenu
=================
*/
void UI_ServerInfoMenu( void )
{
const char *s;
char key[MAX_INFO_KEY];
char value[MAX_INFO_VALUE];
// zero set all our globals
memset( &s_serverinfo, 0 ,sizeof(serverinfo_t) );
ServerInfo_Cache();
s_serverinfo.menu.draw = ServerInfo_MenuDraw;
s_serverinfo.menu.key = ServerInfo_MenuKey;
s_serverinfo.menu.wrapAround = qtrue;
s_serverinfo.menu.fullscreen = qtrue;
s_serverinfo.banner.generic.type = MTYPE_BTEXT;
s_serverinfo.banner.generic.x = 320;
s_serverinfo.banner.generic.y = 16;
s_serverinfo.banner.string = "SERVER INFO";
s_serverinfo.banner.color = color_white;
s_serverinfo.banner.style = UI_CENTER;
s_serverinfo.framel.generic.type = MTYPE_BITMAP;
s_serverinfo.framel.generic.name = SERVERINFO_FRAMEL;
s_serverinfo.framel.generic.flags = QMF_INACTIVE;
s_serverinfo.framel.generic.x = 0;
s_serverinfo.framel.generic.y = 78;
s_serverinfo.framel.width = 256;
s_serverinfo.framel.height = 329;
s_serverinfo.framer.generic.type = MTYPE_BITMAP;
s_serverinfo.framer.generic.name = SERVERINFO_FRAMER;
s_serverinfo.framer.generic.flags = QMF_INACTIVE;
s_serverinfo.framer.generic.x = 376;
s_serverinfo.framer.generic.y = 76;
s_serverinfo.framer.width = 256;
s_serverinfo.framer.height = 334;
s_serverinfo.add.generic.type = MTYPE_PTEXT;
s_serverinfo.add.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_serverinfo.add.generic.callback = ServerInfo_Event;
s_serverinfo.add.generic.id = ID_ADD;
s_serverinfo.add.generic.x = 320;
s_serverinfo.add.generic.y = 371;
s_serverinfo.add.string = "ADD TO FAVORITES";
s_serverinfo.add.style = UI_CENTER|UI_SMALLFONT;
s_serverinfo.add.color = color_red;
if( trap_Cvar_VariableValue( "sv_running" ) ) {
s_serverinfo.add.generic.flags |= QMF_GRAYED;
}
s_serverinfo.back.generic.type = MTYPE_BITMAP;
s_serverinfo.back.generic.name = SERVERINFO_BACK0;
s_serverinfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_serverinfo.back.generic.callback = ServerInfo_Event;
s_serverinfo.back.generic.id = ID_BACK;
s_serverinfo.back.generic.x = 0;
s_serverinfo.back.generic.y = 480-64;
s_serverinfo.back.width = 128;
s_serverinfo.back.height = 64;
s_serverinfo.back.focuspic = SERVERINFO_BACK1;
trap_GetConfigString( CS_SERVERINFO, s_serverinfo.info, MAX_INFO_STRING );
s_serverinfo.numlines = 0;
s = s_serverinfo.info;
while ( s ) {
Info_NextPair( &s, key, value );
if ( !key[0] ) {
break;
}
s_serverinfo.numlines++;
}
if (s_serverinfo.numlines > 16)
s_serverinfo.numlines = 16;
Menu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.banner );
Menu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.framel );
Menu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.framer );
Menu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.add );
Menu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.back );
UI_PushMenu( &s_serverinfo.menu );
}

File diff suppressed because it is too large Load diff

View file

@ -1,327 +1,327 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
SETUP MENU
=======================================================================
*/
#include "ui_local.h"
#define SETUP_MENU_VERTICAL_SPACING 34
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define ID_CUSTOMIZEPLAYER 10
#define ID_CUSTOMIZECONTROLS 11
#define ID_SYSTEMCONFIG 12
#define ID_GAME 13
#define ID_CDKEY 14
#define ID_LOAD 15
#define ID_SAVE 16
#define ID_DEFAULTS 17
#define ID_BACK 18
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menutext_s setupplayer;
menutext_s setupcontrols;
menutext_s setupsystem;
menutext_s game;
menutext_s cdkey;
// menutext_s load;
// menutext_s save;
menutext_s defaults;
menubitmap_s back;
} setupMenuInfo_t;
static setupMenuInfo_t setupMenuInfo;
/*
=================
Setup_ResetDefaults_Action
=================
*/
static void Setup_ResetDefaults_Action( qboolean result ) {
if( !result ) {
return;
}
trap_Cmd_ExecuteText( EXEC_APPEND, "exec default.cfg\n");
trap_Cmd_ExecuteText( EXEC_APPEND, "cvar_restart\n");
trap_Cmd_ExecuteText( EXEC_APPEND, "vid_restart\n" );
}
/*
=================
Setup_ResetDefaults_Draw
=================
*/
static void Setup_ResetDefaults_Draw( void ) {
UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 0, "WARNING: This will reset *ALL*", UI_CENTER|UI_SMALLFONT, color_yellow );
UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 1, "options to their default values.", UI_CENTER|UI_SMALLFONT, color_yellow );
}
/*
===============
UI_SetupMenu_Event
===============
*/
static void UI_SetupMenu_Event( void *ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_CUSTOMIZEPLAYER:
UI_PlayerSettingsMenu();
break;
case ID_CUSTOMIZECONTROLS:
UI_ControlsMenu();
break;
case ID_SYSTEMCONFIG:
UI_GraphicsOptionsMenu();
break;
case ID_GAME:
UI_PreferencesMenu();
break;
case ID_CDKEY:
UI_CDKeyMenu();
break;
// case ID_LOAD:
// UI_LoadConfigMenu();
// break;
// case ID_SAVE:
// UI_SaveConfigMenu();
// break;
case ID_DEFAULTS:
UI_ConfirmMenu( "SET TO DEFAULTS?", Setup_ResetDefaults_Draw, Setup_ResetDefaults_Action );
break;
case ID_BACK:
UI_PopMenu();
break;
}
}
/*
===============
UI_SetupMenu_Init
===============
*/
static void UI_SetupMenu_Init( void ) {
int y;
UI_SetupMenu_Cache();
memset( &setupMenuInfo, 0, sizeof(setupMenuInfo) );
setupMenuInfo.menu.wrapAround = qtrue;
setupMenuInfo.menu.fullscreen = qtrue;
setupMenuInfo.banner.generic.type = MTYPE_BTEXT;
setupMenuInfo.banner.generic.x = 320;
setupMenuInfo.banner.generic.y = 16;
setupMenuInfo.banner.string = "SETUP";
setupMenuInfo.banner.color = color_white;
setupMenuInfo.banner.style = UI_CENTER;
setupMenuInfo.framel.generic.type = MTYPE_BITMAP;
setupMenuInfo.framel.generic.name = ART_FRAMEL;
setupMenuInfo.framel.generic.flags = QMF_INACTIVE;
setupMenuInfo.framel.generic.x = 0;
setupMenuInfo.framel.generic.y = 78;
setupMenuInfo.framel.width = 256;
setupMenuInfo.framel.height = 329;
setupMenuInfo.framer.generic.type = MTYPE_BITMAP;
setupMenuInfo.framer.generic.name = ART_FRAMER;
setupMenuInfo.framer.generic.flags = QMF_INACTIVE;
setupMenuInfo.framer.generic.x = 376;
setupMenuInfo.framer.generic.y = 76;
setupMenuInfo.framer.width = 256;
setupMenuInfo.framer.height = 334;
y = 134;
setupMenuInfo.setupplayer.generic.type = MTYPE_PTEXT;
setupMenuInfo.setupplayer.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
setupMenuInfo.setupplayer.generic.x = 320;
setupMenuInfo.setupplayer.generic.y = y;
setupMenuInfo.setupplayer.generic.id = ID_CUSTOMIZEPLAYER;
setupMenuInfo.setupplayer.generic.callback = UI_SetupMenu_Event;
setupMenuInfo.setupplayer.string = "PLAYER";
setupMenuInfo.setupplayer.color = color_red;
setupMenuInfo.setupplayer.style = UI_CENTER;
y += SETUP_MENU_VERTICAL_SPACING;
setupMenuInfo.setupcontrols.generic.type = MTYPE_PTEXT;
setupMenuInfo.setupcontrols.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
setupMenuInfo.setupcontrols.generic.x = 320;
setupMenuInfo.setupcontrols.generic.y = y;
setupMenuInfo.setupcontrols.generic.id = ID_CUSTOMIZECONTROLS;
setupMenuInfo.setupcontrols.generic.callback = UI_SetupMenu_Event;
setupMenuInfo.setupcontrols.string = "CONTROLS";
setupMenuInfo.setupcontrols.color = color_red;
setupMenuInfo.setupcontrols.style = UI_CENTER;
y += SETUP_MENU_VERTICAL_SPACING;
setupMenuInfo.setupsystem.generic.type = MTYPE_PTEXT;
setupMenuInfo.setupsystem.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
setupMenuInfo.setupsystem.generic.x = 320;
setupMenuInfo.setupsystem.generic.y = y;
setupMenuInfo.setupsystem.generic.id = ID_SYSTEMCONFIG;
setupMenuInfo.setupsystem.generic.callback = UI_SetupMenu_Event;
setupMenuInfo.setupsystem.string = "SYSTEM";
setupMenuInfo.setupsystem.color = color_red;
setupMenuInfo.setupsystem.style = UI_CENTER;
y += SETUP_MENU_VERTICAL_SPACING;
setupMenuInfo.game.generic.type = MTYPE_PTEXT;
setupMenuInfo.game.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
setupMenuInfo.game.generic.x = 320;
setupMenuInfo.game.generic.y = y;
setupMenuInfo.game.generic.id = ID_GAME;
setupMenuInfo.game.generic.callback = UI_SetupMenu_Event;
setupMenuInfo.game.string = "GAME OPTIONS";
setupMenuInfo.game.color = color_red;
setupMenuInfo.game.style = UI_CENTER;
y += SETUP_MENU_VERTICAL_SPACING;
setupMenuInfo.cdkey.generic.type = MTYPE_PTEXT;
setupMenuInfo.cdkey.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
setupMenuInfo.cdkey.generic.x = 320;
setupMenuInfo.cdkey.generic.y = y;
setupMenuInfo.cdkey.generic.id = ID_CDKEY;
setupMenuInfo.cdkey.generic.callback = UI_SetupMenu_Event;
setupMenuInfo.cdkey.string = "CD Key";
setupMenuInfo.cdkey.color = color_red;
setupMenuInfo.cdkey.style = UI_CENTER;
if( !trap_Cvar_VariableValue( "cl_paused" ) ) {
#if 0
y += SETUP_MENU_VERTICAL_SPACING;
setupMenuInfo.load.generic.type = MTYPE_PTEXT;
setupMenuInfo.load.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
setupMenuInfo.load.generic.x = 320;
setupMenuInfo.load.generic.y = y;
setupMenuInfo.load.generic.id = ID_LOAD;
setupMenuInfo.load.generic.callback = UI_SetupMenu_Event;
setupMenuInfo.load.string = "LOAD";
setupMenuInfo.load.color = color_red;
setupMenuInfo.load.style = UI_CENTER;
y += SETUP_MENU_VERTICAL_SPACING;
setupMenuInfo.save.generic.type = MTYPE_PTEXT;
setupMenuInfo.save.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
setupMenuInfo.save.generic.x = 320;
setupMenuInfo.save.generic.y = y;
setupMenuInfo.save.generic.id = ID_SAVE;
setupMenuInfo.save.generic.callback = UI_SetupMenu_Event;
setupMenuInfo.save.string = "SAVE";
setupMenuInfo.save.color = color_red;
setupMenuInfo.save.style = UI_CENTER;
#endif
y += SETUP_MENU_VERTICAL_SPACING;
setupMenuInfo.defaults.generic.type = MTYPE_PTEXT;
setupMenuInfo.defaults.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
setupMenuInfo.defaults.generic.x = 320;
setupMenuInfo.defaults.generic.y = y;
setupMenuInfo.defaults.generic.id = ID_DEFAULTS;
setupMenuInfo.defaults.generic.callback = UI_SetupMenu_Event;
setupMenuInfo.defaults.string = "DEFAULTS";
setupMenuInfo.defaults.color = color_red;
setupMenuInfo.defaults.style = UI_CENTER;
}
setupMenuInfo.back.generic.type = MTYPE_BITMAP;
setupMenuInfo.back.generic.name = ART_BACK0;
setupMenuInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
setupMenuInfo.back.generic.id = ID_BACK;
setupMenuInfo.back.generic.callback = UI_SetupMenu_Event;
setupMenuInfo.back.generic.x = 0;
setupMenuInfo.back.generic.y = 480-64;
setupMenuInfo.back.width = 128;
setupMenuInfo.back.height = 64;
setupMenuInfo.back.focuspic = ART_BACK1;
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.banner );
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.framel );
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.framer );
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.setupplayer );
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.setupcontrols );
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.setupsystem );
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.game );
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.cdkey );
// Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.load );
// Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.save );
if( !trap_Cvar_VariableValue( "cl_paused" ) ) {
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.defaults );
}
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.back );
}
/*
=================
UI_SetupMenu_Cache
=================
*/
void UI_SetupMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
}
/*
===============
UI_SetupMenu
===============
*/
void UI_SetupMenu( void ) {
UI_SetupMenu_Init();
UI_PushMenu( &setupMenuInfo.menu );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
SETUP MENU
=======================================================================
*/
#include "ui_local.h"
#define SETUP_MENU_VERTICAL_SPACING 34
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define ID_CUSTOMIZEPLAYER 10
#define ID_CUSTOMIZECONTROLS 11
#define ID_SYSTEMCONFIG 12
#define ID_GAME 13
#define ID_CDKEY 14
#define ID_LOAD 15
#define ID_SAVE 16
#define ID_DEFAULTS 17
#define ID_BACK 18
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menutext_s setupplayer;
menutext_s setupcontrols;
menutext_s setupsystem;
menutext_s game;
menutext_s cdkey;
// menutext_s load;
// menutext_s save;
menutext_s defaults;
menubitmap_s back;
} setupMenuInfo_t;
static setupMenuInfo_t setupMenuInfo;
/*
=================
Setup_ResetDefaults_Action
=================
*/
static void Setup_ResetDefaults_Action( qboolean result ) {
if( !result ) {
return;
}
trap_Cmd_ExecuteText( EXEC_APPEND, "exec default.cfg\n");
trap_Cmd_ExecuteText( EXEC_APPEND, "cvar_restart\n");
trap_Cmd_ExecuteText( EXEC_APPEND, "vid_restart\n" );
}
/*
=================
Setup_ResetDefaults_Draw
=================
*/
static void Setup_ResetDefaults_Draw( void ) {
UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 0, "WARNING: This will reset *ALL*", UI_CENTER|UI_SMALLFONT, color_yellow );
UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 1, "options to their default values.", UI_CENTER|UI_SMALLFONT, color_yellow );
}
/*
===============
UI_SetupMenu_Event
===============
*/
static void UI_SetupMenu_Event( void *ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_CUSTOMIZEPLAYER:
UI_PlayerSettingsMenu();
break;
case ID_CUSTOMIZECONTROLS:
UI_ControlsMenu();
break;
case ID_SYSTEMCONFIG:
UI_GraphicsOptionsMenu();
break;
case ID_GAME:
UI_PreferencesMenu();
break;
case ID_CDKEY:
UI_CDKeyMenu();
break;
// case ID_LOAD:
// UI_LoadConfigMenu();
// break;
// case ID_SAVE:
// UI_SaveConfigMenu();
// break;
case ID_DEFAULTS:
UI_ConfirmMenu( "SET TO DEFAULTS?", Setup_ResetDefaults_Draw, Setup_ResetDefaults_Action );
break;
case ID_BACK:
UI_PopMenu();
break;
}
}
/*
===============
UI_SetupMenu_Init
===============
*/
static void UI_SetupMenu_Init( void ) {
int y;
UI_SetupMenu_Cache();
memset( &setupMenuInfo, 0, sizeof(setupMenuInfo) );
setupMenuInfo.menu.wrapAround = qtrue;
setupMenuInfo.menu.fullscreen = qtrue;
setupMenuInfo.banner.generic.type = MTYPE_BTEXT;
setupMenuInfo.banner.generic.x = 320;
setupMenuInfo.banner.generic.y = 16;
setupMenuInfo.banner.string = "SETUP";
setupMenuInfo.banner.color = color_white;
setupMenuInfo.banner.style = UI_CENTER;
setupMenuInfo.framel.generic.type = MTYPE_BITMAP;
setupMenuInfo.framel.generic.name = ART_FRAMEL;
setupMenuInfo.framel.generic.flags = QMF_INACTIVE;
setupMenuInfo.framel.generic.x = 0;
setupMenuInfo.framel.generic.y = 78;
setupMenuInfo.framel.width = 256;
setupMenuInfo.framel.height = 329;
setupMenuInfo.framer.generic.type = MTYPE_BITMAP;
setupMenuInfo.framer.generic.name = ART_FRAMER;
setupMenuInfo.framer.generic.flags = QMF_INACTIVE;
setupMenuInfo.framer.generic.x = 376;
setupMenuInfo.framer.generic.y = 76;
setupMenuInfo.framer.width = 256;
setupMenuInfo.framer.height = 334;
y = 134;
setupMenuInfo.setupplayer.generic.type = MTYPE_PTEXT;
setupMenuInfo.setupplayer.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
setupMenuInfo.setupplayer.generic.x = 320;
setupMenuInfo.setupplayer.generic.y = y;
setupMenuInfo.setupplayer.generic.id = ID_CUSTOMIZEPLAYER;
setupMenuInfo.setupplayer.generic.callback = UI_SetupMenu_Event;
setupMenuInfo.setupplayer.string = "PLAYER";
setupMenuInfo.setupplayer.color = color_red;
setupMenuInfo.setupplayer.style = UI_CENTER;
y += SETUP_MENU_VERTICAL_SPACING;
setupMenuInfo.setupcontrols.generic.type = MTYPE_PTEXT;
setupMenuInfo.setupcontrols.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
setupMenuInfo.setupcontrols.generic.x = 320;
setupMenuInfo.setupcontrols.generic.y = y;
setupMenuInfo.setupcontrols.generic.id = ID_CUSTOMIZECONTROLS;
setupMenuInfo.setupcontrols.generic.callback = UI_SetupMenu_Event;
setupMenuInfo.setupcontrols.string = "CONTROLS";
setupMenuInfo.setupcontrols.color = color_red;
setupMenuInfo.setupcontrols.style = UI_CENTER;
y += SETUP_MENU_VERTICAL_SPACING;
setupMenuInfo.setupsystem.generic.type = MTYPE_PTEXT;
setupMenuInfo.setupsystem.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
setupMenuInfo.setupsystem.generic.x = 320;
setupMenuInfo.setupsystem.generic.y = y;
setupMenuInfo.setupsystem.generic.id = ID_SYSTEMCONFIG;
setupMenuInfo.setupsystem.generic.callback = UI_SetupMenu_Event;
setupMenuInfo.setupsystem.string = "SYSTEM";
setupMenuInfo.setupsystem.color = color_red;
setupMenuInfo.setupsystem.style = UI_CENTER;
y += SETUP_MENU_VERTICAL_SPACING;
setupMenuInfo.game.generic.type = MTYPE_PTEXT;
setupMenuInfo.game.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
setupMenuInfo.game.generic.x = 320;
setupMenuInfo.game.generic.y = y;
setupMenuInfo.game.generic.id = ID_GAME;
setupMenuInfo.game.generic.callback = UI_SetupMenu_Event;
setupMenuInfo.game.string = "GAME OPTIONS";
setupMenuInfo.game.color = color_red;
setupMenuInfo.game.style = UI_CENTER;
y += SETUP_MENU_VERTICAL_SPACING;
setupMenuInfo.cdkey.generic.type = MTYPE_PTEXT;
setupMenuInfo.cdkey.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
setupMenuInfo.cdkey.generic.x = 320;
setupMenuInfo.cdkey.generic.y = y;
setupMenuInfo.cdkey.generic.id = ID_CDKEY;
setupMenuInfo.cdkey.generic.callback = UI_SetupMenu_Event;
setupMenuInfo.cdkey.string = "CD Key";
setupMenuInfo.cdkey.color = color_red;
setupMenuInfo.cdkey.style = UI_CENTER;
if( !trap_Cvar_VariableValue( "cl_paused" ) ) {
#if 0
y += SETUP_MENU_VERTICAL_SPACING;
setupMenuInfo.load.generic.type = MTYPE_PTEXT;
setupMenuInfo.load.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
setupMenuInfo.load.generic.x = 320;
setupMenuInfo.load.generic.y = y;
setupMenuInfo.load.generic.id = ID_LOAD;
setupMenuInfo.load.generic.callback = UI_SetupMenu_Event;
setupMenuInfo.load.string = "LOAD";
setupMenuInfo.load.color = color_red;
setupMenuInfo.load.style = UI_CENTER;
y += SETUP_MENU_VERTICAL_SPACING;
setupMenuInfo.save.generic.type = MTYPE_PTEXT;
setupMenuInfo.save.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
setupMenuInfo.save.generic.x = 320;
setupMenuInfo.save.generic.y = y;
setupMenuInfo.save.generic.id = ID_SAVE;
setupMenuInfo.save.generic.callback = UI_SetupMenu_Event;
setupMenuInfo.save.string = "SAVE";
setupMenuInfo.save.color = color_red;
setupMenuInfo.save.style = UI_CENTER;
#endif
y += SETUP_MENU_VERTICAL_SPACING;
setupMenuInfo.defaults.generic.type = MTYPE_PTEXT;
setupMenuInfo.defaults.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
setupMenuInfo.defaults.generic.x = 320;
setupMenuInfo.defaults.generic.y = y;
setupMenuInfo.defaults.generic.id = ID_DEFAULTS;
setupMenuInfo.defaults.generic.callback = UI_SetupMenu_Event;
setupMenuInfo.defaults.string = "DEFAULTS";
setupMenuInfo.defaults.color = color_red;
setupMenuInfo.defaults.style = UI_CENTER;
}
setupMenuInfo.back.generic.type = MTYPE_BITMAP;
setupMenuInfo.back.generic.name = ART_BACK0;
setupMenuInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
setupMenuInfo.back.generic.id = ID_BACK;
setupMenuInfo.back.generic.callback = UI_SetupMenu_Event;
setupMenuInfo.back.generic.x = 0;
setupMenuInfo.back.generic.y = 480-64;
setupMenuInfo.back.width = 128;
setupMenuInfo.back.height = 64;
setupMenuInfo.back.focuspic = ART_BACK1;
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.banner );
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.framel );
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.framer );
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.setupplayer );
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.setupcontrols );
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.setupsystem );
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.game );
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.cdkey );
// Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.load );
// Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.save );
if( !trap_Cvar_VariableValue( "cl_paused" ) ) {
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.defaults );
}
Menu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.back );
}
/*
=================
UI_SetupMenu_Cache
=================
*/
void UI_SetupMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
}
/*
===============
UI_SetupMenu
===============
*/
void UI_SetupMenu( void ) {
UI_SetupMenu_Init();
UI_PushMenu( &setupMenuInfo.menu );
}

View file

@ -1,286 +1,286 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
//
// ui_signup.c
//
#include "ui_local.h"
#define SIGNUP_FRAME "menu/art/cut_frame"
#define ID_NAME 100
#define ID_NAME_BOX 101
#define ID_PASSWORD 102
#define ID_PASSWORD_BOX 103
#define ID_AGAIN 104
#define ID_AGAIN_BOX 105
#define ID_EMAIL 106
#define ID_EMAIL_BOX 107
#define ID_SIGNUP 108
#define ID_CANCEL 109
typedef struct
{
menuframework_s menu;
menubitmap_s frame;
menutext_s name;
menufield_s name_box;
menutext_s password;
menufield_s password_box;
menutext_s again;
menufield_s again_box;
menutext_s email;
menufield_s email_box;
menutext_s signup;
menutext_s cancel;
} signup_t;
static signup_t s_signup;
static menuframework_s s_signup_menu;
static menuaction_s s_signup_signup;
static menuaction_s s_signup_cancel;
static vec4_t s_signup_color_prompt = {1.00, 0.43, 0.00, 1.00};
/*
===============
Signup_MenuEvent
===============
*/
static void Signup_MenuEvent( void* ptr, int event ) {
//char cmd[1024];
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_SIGNUP:
if( strcmp(s_signup.password_box.field.buffer,
s_signup.again_box.field.buffer) != 0 )
{
// GRANK_FIXME - password mismatch
break;
}
// set name
//trap_Cvar_Set( "name", s_signup.name_box.field.buffer );
/*
trap_Cvar_Set( "rank_name", s_signup.name_box.field.buffer );
trap_Cvar_Set( "rank_pwd", s_signup.password_box.field.buffer );
*/
// create account
/*
sprintf( cmd, "cmd rank_create \"%s\" \"%s\" \"%s\"\n",
s_signup.name_box.field.buffer,
s_signup.password_box.field.buffer,
s_signup.email_box.field.buffer );
trap_Cmd_ExecuteText( EXEC_APPEND, cmd );
*/
trap_CL_UI_RankUserCreate(
s_signup.name_box.field.buffer,
s_signup.password_box.field.buffer,
s_signup.email_box.field.buffer );
UI_ForceMenuOff();
break;
case ID_CANCEL:
UI_PopMenu();
break;
}
}
/*
===============
Signup_MenuInit
===============
*/
void Signup_MenuInit( void ) {
grank_status_t status;
int y;
memset( &s_signup, 0, sizeof(s_signup) );
Signup_Cache();
s_signup.menu.wrapAround = qtrue;
s_signup.menu.fullscreen = qfalse;
s_signup.frame.generic.type = MTYPE_BITMAP;
s_signup.frame.generic.flags = QMF_INACTIVE;
s_signup.frame.generic.name = SIGNUP_FRAME;
s_signup.frame.generic.x = 142; //320-233;
s_signup.frame.generic.y = 118; //240-166;
s_signup.frame.width = 359; //466;
s_signup.frame.height = 256; //332;
y = 194;
s_signup.name.generic.type = MTYPE_PTEXT;
s_signup.name.generic.flags = QMF_RIGHT_JUSTIFY|QMF_INACTIVE;
s_signup.name.generic.id = ID_NAME;
s_signup.name.generic.x = 310;
s_signup.name.generic.y = y;
s_signup.name.string = "NAME";
s_signup.name.style = UI_RIGHT|UI_SMALLFONT;
s_signup.name.color = s_signup_color_prompt;
s_signup.name_box.generic.type = MTYPE_FIELD;
s_signup.name_box.generic.ownerdraw = Rankings_DrawName;
s_signup.name_box.generic.name = "";
s_signup.name_box.generic.flags = 0;
s_signup.name_box.generic.x = 330;
s_signup.name_box.generic.y = y;
s_signup.name_box.field.widthInChars = 16;
s_signup.name_box.field.maxchars = 16;
y += 20;
s_signup.password.generic.type = MTYPE_PTEXT;
s_signup.password.generic.flags = QMF_RIGHT_JUSTIFY|QMF_INACTIVE;
s_signup.password.generic.id = ID_PASSWORD;
s_signup.password.generic.x = 310;
s_signup.password.generic.y = y;
s_signup.password.string = "PASSWORD";
s_signup.password.style = UI_RIGHT|UI_SMALLFONT;
s_signup.password.color = s_signup_color_prompt;
s_signup.password_box.generic.type = MTYPE_FIELD;
s_signup.password_box.generic.ownerdraw = Rankings_DrawPassword;
s_signup.password_box.generic.name = "";
s_signup.password_box.generic.flags = 0;
s_signup.password_box.generic.x = 330;
s_signup.password_box.generic.y = y;
s_signup.password_box.field.widthInChars = 16;
s_signup.password_box.field.maxchars = 16;
y += 20;
s_signup.again.generic.type = MTYPE_PTEXT;
s_signup.again.generic.flags = QMF_RIGHT_JUSTIFY|QMF_INACTIVE;
s_signup.again.generic.id = ID_AGAIN;
s_signup.again.generic.x = 310;
s_signup.again.generic.y = y;
s_signup.again.string = "(AGAIN)";
s_signup.again.style = UI_RIGHT|UI_SMALLFONT;
s_signup.again.color = s_signup_color_prompt;
s_signup.again_box.generic.type = MTYPE_FIELD;
s_signup.again_box.generic.ownerdraw = Rankings_DrawPassword;
s_signup.again_box.generic.name = "";
s_signup.again_box.generic.flags = 0;
s_signup.again_box.generic.x = 330;
s_signup.again_box.generic.y = y;
s_signup.again_box.field.widthInChars = 16;
s_signup.again_box.field.maxchars = 16;
y += 20;
s_signup.email.generic.type = MTYPE_PTEXT;
s_signup.email.generic.flags = QMF_RIGHT_JUSTIFY|QMF_INACTIVE;
s_signup.email.generic.id = ID_EMAIL;
s_signup.email.generic.x = 310;
s_signup.email.generic.y = y;
s_signup.email.string = "EMAIL";
s_signup.email.style = UI_RIGHT|UI_SMALLFONT;
s_signup.email.color = s_signup_color_prompt;
s_signup.email_box.generic.type = MTYPE_FIELD;
s_signup.email_box.generic.ownerdraw = Rankings_DrawText;
s_signup.email_box.generic.name = "";
s_signup.email_box.generic.flags = 0;
s_signup.email_box.generic.x = 330;
s_signup.email_box.generic.y = y;
s_signup.email_box.field.widthInChars = 16;
s_signup.email_box.field.maxchars = MAX_EDIT_LINE;
y += 40;
s_signup.signup.generic.type = MTYPE_PTEXT;
s_signup.signup.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
s_signup.signup.generic.id = ID_SIGNUP;
s_signup.signup.generic.callback = Signup_MenuEvent;
s_signup.signup.generic.x = 310;
s_signup.signup.generic.y = y;
s_signup.signup.string = "SIGN UP";
s_signup.signup.style = UI_RIGHT|UI_SMALLFONT;
s_signup.signup.color = colorRed;
s_signup.cancel.generic.type = MTYPE_PTEXT;
s_signup.cancel.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_signup.cancel.generic.id = ID_CANCEL;
s_signup.cancel.generic.callback = Signup_MenuEvent;
s_signup.cancel.generic.x = 330;
s_signup.cancel.generic.y = y;
s_signup.cancel.string = "CANCEL";
s_signup.cancel.style = UI_LEFT|UI_SMALLFONT;
s_signup.cancel.color = colorRed;
y += 20;
status = (grank_status_t)trap_Cvar_VariableValue("client_status");
if( (status != QGR_STATUS_NEW) && (status != QGR_STATUS_SPECTATOR) )
{
s_signup.name_box.generic.flags |= QMF_INACTIVE;
s_signup.password_box.generic.flags |= QMF_INACTIVE;
s_signup.again_box.generic.flags |= QMF_INACTIVE;
s_signup.email_box.generic.flags |= QMF_INACTIVE;
s_signup.signup.generic.flags |= QMF_INACTIVE;
s_signup.signup.color = colorMdGrey;
}
Menu_AddItem( &s_signup.menu, (void*) &s_signup.frame );
Menu_AddItem( &s_signup.menu, (void*) &s_signup.name );
Menu_AddItem( &s_signup.menu, (void*) &s_signup.name_box );
Menu_AddItem( &s_signup.menu, (void*) &s_signup.password );
Menu_AddItem( &s_signup.menu, (void*) &s_signup.password_box );
Menu_AddItem( &s_signup.menu, (void*) &s_signup.again );
Menu_AddItem( &s_signup.menu, (void*) &s_signup.again_box );
Menu_AddItem( &s_signup.menu, (void*) &s_signup.email );
Menu_AddItem( &s_signup.menu, (void*) &s_signup.email_box );
Menu_AddItem( &s_signup.menu, (void*) &s_signup.signup );
Menu_AddItem( &s_signup.menu, (void*) &s_signup.cancel );
}
/*
===============
Signup_Cache
===============
*/
void Signup_Cache( void ) {
trap_R_RegisterShaderNoMip( SIGNUP_FRAME );
}
/*
===============
UI_SignupMenu
===============
*/
void UI_SignupMenu( void ) {
Signup_MenuInit();
UI_PushMenu ( &s_signup.menu );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
//
// ui_signup.c
//
#include "ui_local.h"
#define SIGNUP_FRAME "menu/art/cut_frame"
#define ID_NAME 100
#define ID_NAME_BOX 101
#define ID_PASSWORD 102
#define ID_PASSWORD_BOX 103
#define ID_AGAIN 104
#define ID_AGAIN_BOX 105
#define ID_EMAIL 106
#define ID_EMAIL_BOX 107
#define ID_SIGNUP 108
#define ID_CANCEL 109
typedef struct
{
menuframework_s menu;
menubitmap_s frame;
menutext_s name;
menufield_s name_box;
menutext_s password;
menufield_s password_box;
menutext_s again;
menufield_s again_box;
menutext_s email;
menufield_s email_box;
menutext_s signup;
menutext_s cancel;
} signup_t;
static signup_t s_signup;
static menuframework_s s_signup_menu;
static menuaction_s s_signup_signup;
static menuaction_s s_signup_cancel;
static vec4_t s_signup_color_prompt = {1.00, 0.43, 0.00, 1.00};
/*
===============
Signup_MenuEvent
===============
*/
static void Signup_MenuEvent( void* ptr, int event ) {
//char cmd[1024];
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_SIGNUP:
if( strcmp(s_signup.password_box.field.buffer,
s_signup.again_box.field.buffer) != 0 )
{
// GRANK_FIXME - password mismatch
break;
}
// set name
//trap_Cvar_Set( "name", s_signup.name_box.field.buffer );
/*
trap_Cvar_Set( "rank_name", s_signup.name_box.field.buffer );
trap_Cvar_Set( "rank_pwd", s_signup.password_box.field.buffer );
*/
// create account
/*
sprintf( cmd, "cmd rank_create \"%s\" \"%s\" \"%s\"\n",
s_signup.name_box.field.buffer,
s_signup.password_box.field.buffer,
s_signup.email_box.field.buffer );
trap_Cmd_ExecuteText( EXEC_APPEND, cmd );
*/
trap_CL_UI_RankUserCreate(
s_signup.name_box.field.buffer,
s_signup.password_box.field.buffer,
s_signup.email_box.field.buffer );
UI_ForceMenuOff();
break;
case ID_CANCEL:
UI_PopMenu();
break;
}
}
/*
===============
Signup_MenuInit
===============
*/
void Signup_MenuInit( void ) {
grank_status_t status;
int y;
memset( &s_signup, 0, sizeof(s_signup) );
Signup_Cache();
s_signup.menu.wrapAround = qtrue;
s_signup.menu.fullscreen = qfalse;
s_signup.frame.generic.type = MTYPE_BITMAP;
s_signup.frame.generic.flags = QMF_INACTIVE;
s_signup.frame.generic.name = SIGNUP_FRAME;
s_signup.frame.generic.x = 142; //320-233;
s_signup.frame.generic.y = 118; //240-166;
s_signup.frame.width = 359; //466;
s_signup.frame.height = 256; //332;
y = 194;
s_signup.name.generic.type = MTYPE_PTEXT;
s_signup.name.generic.flags = QMF_RIGHT_JUSTIFY|QMF_INACTIVE;
s_signup.name.generic.id = ID_NAME;
s_signup.name.generic.x = 310;
s_signup.name.generic.y = y;
s_signup.name.string = "NAME";
s_signup.name.style = UI_RIGHT|UI_SMALLFONT;
s_signup.name.color = s_signup_color_prompt;
s_signup.name_box.generic.type = MTYPE_FIELD;
s_signup.name_box.generic.ownerdraw = Rankings_DrawName;
s_signup.name_box.generic.name = "";
s_signup.name_box.generic.flags = 0;
s_signup.name_box.generic.x = 330;
s_signup.name_box.generic.y = y;
s_signup.name_box.field.widthInChars = 16;
s_signup.name_box.field.maxchars = 16;
y += 20;
s_signup.password.generic.type = MTYPE_PTEXT;
s_signup.password.generic.flags = QMF_RIGHT_JUSTIFY|QMF_INACTIVE;
s_signup.password.generic.id = ID_PASSWORD;
s_signup.password.generic.x = 310;
s_signup.password.generic.y = y;
s_signup.password.string = "PASSWORD";
s_signup.password.style = UI_RIGHT|UI_SMALLFONT;
s_signup.password.color = s_signup_color_prompt;
s_signup.password_box.generic.type = MTYPE_FIELD;
s_signup.password_box.generic.ownerdraw = Rankings_DrawPassword;
s_signup.password_box.generic.name = "";
s_signup.password_box.generic.flags = 0;
s_signup.password_box.generic.x = 330;
s_signup.password_box.generic.y = y;
s_signup.password_box.field.widthInChars = 16;
s_signup.password_box.field.maxchars = 16;
y += 20;
s_signup.again.generic.type = MTYPE_PTEXT;
s_signup.again.generic.flags = QMF_RIGHT_JUSTIFY|QMF_INACTIVE;
s_signup.again.generic.id = ID_AGAIN;
s_signup.again.generic.x = 310;
s_signup.again.generic.y = y;
s_signup.again.string = "(AGAIN)";
s_signup.again.style = UI_RIGHT|UI_SMALLFONT;
s_signup.again.color = s_signup_color_prompt;
s_signup.again_box.generic.type = MTYPE_FIELD;
s_signup.again_box.generic.ownerdraw = Rankings_DrawPassword;
s_signup.again_box.generic.name = "";
s_signup.again_box.generic.flags = 0;
s_signup.again_box.generic.x = 330;
s_signup.again_box.generic.y = y;
s_signup.again_box.field.widthInChars = 16;
s_signup.again_box.field.maxchars = 16;
y += 20;
s_signup.email.generic.type = MTYPE_PTEXT;
s_signup.email.generic.flags = QMF_RIGHT_JUSTIFY|QMF_INACTIVE;
s_signup.email.generic.id = ID_EMAIL;
s_signup.email.generic.x = 310;
s_signup.email.generic.y = y;
s_signup.email.string = "EMAIL";
s_signup.email.style = UI_RIGHT|UI_SMALLFONT;
s_signup.email.color = s_signup_color_prompt;
s_signup.email_box.generic.type = MTYPE_FIELD;
s_signup.email_box.generic.ownerdraw = Rankings_DrawText;
s_signup.email_box.generic.name = "";
s_signup.email_box.generic.flags = 0;
s_signup.email_box.generic.x = 330;
s_signup.email_box.generic.y = y;
s_signup.email_box.field.widthInChars = 16;
s_signup.email_box.field.maxchars = MAX_EDIT_LINE;
y += 40;
s_signup.signup.generic.type = MTYPE_PTEXT;
s_signup.signup.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
s_signup.signup.generic.id = ID_SIGNUP;
s_signup.signup.generic.callback = Signup_MenuEvent;
s_signup.signup.generic.x = 310;
s_signup.signup.generic.y = y;
s_signup.signup.string = "SIGN UP";
s_signup.signup.style = UI_RIGHT|UI_SMALLFONT;
s_signup.signup.color = colorRed;
s_signup.cancel.generic.type = MTYPE_PTEXT;
s_signup.cancel.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_signup.cancel.generic.id = ID_CANCEL;
s_signup.cancel.generic.callback = Signup_MenuEvent;
s_signup.cancel.generic.x = 330;
s_signup.cancel.generic.y = y;
s_signup.cancel.string = "CANCEL";
s_signup.cancel.style = UI_LEFT|UI_SMALLFONT;
s_signup.cancel.color = colorRed;
y += 20;
status = (grank_status_t)trap_Cvar_VariableValue("client_status");
if( (status != QGR_STATUS_NEW) && (status != QGR_STATUS_SPECTATOR) )
{
s_signup.name_box.generic.flags |= QMF_INACTIVE;
s_signup.password_box.generic.flags |= QMF_INACTIVE;
s_signup.again_box.generic.flags |= QMF_INACTIVE;
s_signup.email_box.generic.flags |= QMF_INACTIVE;
s_signup.signup.generic.flags |= QMF_INACTIVE;
s_signup.signup.color = colorMdGrey;
}
Menu_AddItem( &s_signup.menu, (void*) &s_signup.frame );
Menu_AddItem( &s_signup.menu, (void*) &s_signup.name );
Menu_AddItem( &s_signup.menu, (void*) &s_signup.name_box );
Menu_AddItem( &s_signup.menu, (void*) &s_signup.password );
Menu_AddItem( &s_signup.menu, (void*) &s_signup.password_box );
Menu_AddItem( &s_signup.menu, (void*) &s_signup.again );
Menu_AddItem( &s_signup.menu, (void*) &s_signup.again_box );
Menu_AddItem( &s_signup.menu, (void*) &s_signup.email );
Menu_AddItem( &s_signup.menu, (void*) &s_signup.email_box );
Menu_AddItem( &s_signup.menu, (void*) &s_signup.signup );
Menu_AddItem( &s_signup.menu, (void*) &s_signup.cancel );
}
/*
===============
Signup_Cache
===============
*/
void Signup_Cache( void ) {
trap_R_RegisterShaderNoMip( SIGNUP_FRAME );
}
/*
===============
UI_SignupMenu
===============
*/
void UI_SignupMenu( void ) {
Signup_MenuInit();
UI_PushMenu ( &s_signup.menu );
}

View file

@ -1,316 +1,316 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
SOUND OPTIONS MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ID_GRAPHICS 10
#define ID_DISPLAY 11
#define ID_SOUND 12
#define ID_NETWORK 13
#define ID_EFFECTSVOLUME 14
#define ID_MUSICVOLUME 15
#define ID_QUALITY 16
//#define ID_A3D 17
#define ID_BACK 18
static const char *quality_items[] = {
"Low", "High", 0
};
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menutext_s graphics;
menutext_s display;
menutext_s sound;
menutext_s network;
menuslider_s sfxvolume;
menuslider_s musicvolume;
menulist_s quality;
// menuradiobutton_s a3d;
menubitmap_s back;
} soundOptionsInfo_t;
static soundOptionsInfo_t soundOptionsInfo;
/*
=================
UI_SoundOptionsMenu_Event
=================
*/
static void UI_SoundOptionsMenu_Event( void* ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_GRAPHICS:
UI_PopMenu();
UI_GraphicsOptionsMenu();
break;
case ID_DISPLAY:
UI_PopMenu();
UI_DisplayOptionsMenu();
break;
case ID_SOUND:
break;
case ID_NETWORK:
UI_PopMenu();
UI_NetworkOptionsMenu();
break;
case ID_EFFECTSVOLUME:
trap_Cvar_SetValue( "s_volume", soundOptionsInfo.sfxvolume.curvalue / 10 );
break;
case ID_MUSICVOLUME:
trap_Cvar_SetValue( "s_musicvolume", soundOptionsInfo.musicvolume.curvalue / 10 );
break;
case ID_QUALITY:
if( soundOptionsInfo.quality.curvalue ) {
trap_Cvar_SetValue( "s_khz", 22 );
trap_Cvar_SetValue( "s_compression", 0 );
}
else {
trap_Cvar_SetValue( "s_khz", 11 );
trap_Cvar_SetValue( "s_compression", 1 );
}
UI_ForceMenuOff();
trap_Cmd_ExecuteText( EXEC_APPEND, "snd_restart\n" );
break;
/*
case ID_A3D:
if( soundOptionsInfo.a3d.curvalue ) {
trap_Cmd_ExecuteText( EXEC_NOW, "s_enable_a3d\n" );
}
else {
trap_Cmd_ExecuteText( EXEC_NOW, "s_disable_a3d\n" );
}
soundOptionsInfo.a3d.curvalue = (int)trap_Cvar_VariableValue( "s_usingA3D" );
break;
*/
case ID_BACK:
UI_PopMenu();
break;
}
}
/*
===============
UI_SoundOptionsMenu_Init
===============
*/
static void UI_SoundOptionsMenu_Init( void ) {
int y;
memset( &soundOptionsInfo, 0, sizeof(soundOptionsInfo) );
UI_SoundOptionsMenu_Cache();
soundOptionsInfo.menu.wrapAround = qtrue;
soundOptionsInfo.menu.fullscreen = qtrue;
soundOptionsInfo.banner.generic.type = MTYPE_BTEXT;
soundOptionsInfo.banner.generic.flags = QMF_CENTER_JUSTIFY;
soundOptionsInfo.banner.generic.x = 320;
soundOptionsInfo.banner.generic.y = 16;
soundOptionsInfo.banner.string = "SYSTEM SETUP";
soundOptionsInfo.banner.color = color_white;
soundOptionsInfo.banner.style = UI_CENTER;
soundOptionsInfo.framel.generic.type = MTYPE_BITMAP;
soundOptionsInfo.framel.generic.name = ART_FRAMEL;
soundOptionsInfo.framel.generic.flags = QMF_INACTIVE;
soundOptionsInfo.framel.generic.x = 0;
soundOptionsInfo.framel.generic.y = 78;
soundOptionsInfo.framel.width = 256;
soundOptionsInfo.framel.height = 329;
soundOptionsInfo.framer.generic.type = MTYPE_BITMAP;
soundOptionsInfo.framer.generic.name = ART_FRAMER;
soundOptionsInfo.framer.generic.flags = QMF_INACTIVE;
soundOptionsInfo.framer.generic.x = 376;
soundOptionsInfo.framer.generic.y = 76;
soundOptionsInfo.framer.width = 256;
soundOptionsInfo.framer.height = 334;
soundOptionsInfo.graphics.generic.type = MTYPE_PTEXT;
soundOptionsInfo.graphics.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
soundOptionsInfo.graphics.generic.id = ID_GRAPHICS;
soundOptionsInfo.graphics.generic.callback = UI_SoundOptionsMenu_Event;
soundOptionsInfo.graphics.generic.x = 216;
soundOptionsInfo.graphics.generic.y = 240 - 2 * PROP_HEIGHT;
soundOptionsInfo.graphics.string = "GRAPHICS";
soundOptionsInfo.graphics.style = UI_RIGHT;
soundOptionsInfo.graphics.color = color_red;
soundOptionsInfo.display.generic.type = MTYPE_PTEXT;
soundOptionsInfo.display.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
soundOptionsInfo.display.generic.id = ID_DISPLAY;
soundOptionsInfo.display.generic.callback = UI_SoundOptionsMenu_Event;
soundOptionsInfo.display.generic.x = 216;
soundOptionsInfo.display.generic.y = 240 - PROP_HEIGHT;
soundOptionsInfo.display.string = "DISPLAY";
soundOptionsInfo.display.style = UI_RIGHT;
soundOptionsInfo.display.color = color_red;
soundOptionsInfo.sound.generic.type = MTYPE_PTEXT;
soundOptionsInfo.sound.generic.flags = QMF_RIGHT_JUSTIFY;
soundOptionsInfo.sound.generic.id = ID_SOUND;
soundOptionsInfo.sound.generic.callback = UI_SoundOptionsMenu_Event;
soundOptionsInfo.sound.generic.x = 216;
soundOptionsInfo.sound.generic.y = 240;
soundOptionsInfo.sound.string = "SOUND";
soundOptionsInfo.sound.style = UI_RIGHT;
soundOptionsInfo.sound.color = color_red;
soundOptionsInfo.network.generic.type = MTYPE_PTEXT;
soundOptionsInfo.network.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
soundOptionsInfo.network.generic.id = ID_NETWORK;
soundOptionsInfo.network.generic.callback = UI_SoundOptionsMenu_Event;
soundOptionsInfo.network.generic.x = 216;
soundOptionsInfo.network.generic.y = 240 + PROP_HEIGHT;
soundOptionsInfo.network.string = "NETWORK";
soundOptionsInfo.network.style = UI_RIGHT;
soundOptionsInfo.network.color = color_red;
y = 240 - 1.5 * (BIGCHAR_HEIGHT + 2);
soundOptionsInfo.sfxvolume.generic.type = MTYPE_SLIDER;
soundOptionsInfo.sfxvolume.generic.name = "Effects Volume:";
soundOptionsInfo.sfxvolume.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
soundOptionsInfo.sfxvolume.generic.callback = UI_SoundOptionsMenu_Event;
soundOptionsInfo.sfxvolume.generic.id = ID_EFFECTSVOLUME;
soundOptionsInfo.sfxvolume.generic.x = 400;
soundOptionsInfo.sfxvolume.generic.y = y;
soundOptionsInfo.sfxvolume.minvalue = 0;
soundOptionsInfo.sfxvolume.maxvalue = 10;
y += BIGCHAR_HEIGHT+2;
soundOptionsInfo.musicvolume.generic.type = MTYPE_SLIDER;
soundOptionsInfo.musicvolume.generic.name = "Music Volume:";
soundOptionsInfo.musicvolume.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
soundOptionsInfo.musicvolume.generic.callback = UI_SoundOptionsMenu_Event;
soundOptionsInfo.musicvolume.generic.id = ID_MUSICVOLUME;
soundOptionsInfo.musicvolume.generic.x = 400;
soundOptionsInfo.musicvolume.generic.y = y;
soundOptionsInfo.musicvolume.minvalue = 0;
soundOptionsInfo.musicvolume.maxvalue = 10;
y += BIGCHAR_HEIGHT+2;
soundOptionsInfo.quality.generic.type = MTYPE_SPINCONTROL;
soundOptionsInfo.quality.generic.name = "Sound Quality:";
soundOptionsInfo.quality.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
soundOptionsInfo.quality.generic.callback = UI_SoundOptionsMenu_Event;
soundOptionsInfo.quality.generic.id = ID_QUALITY;
soundOptionsInfo.quality.generic.x = 400;
soundOptionsInfo.quality.generic.y = y;
soundOptionsInfo.quality.itemnames = quality_items;
/*
y += BIGCHAR_HEIGHT+2;
soundOptionsInfo.a3d.generic.type = MTYPE_RADIOBUTTON;
soundOptionsInfo.a3d.generic.name = "A3D:";
soundOptionsInfo.a3d.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
soundOptionsInfo.a3d.generic.callback = UI_SoundOptionsMenu_Event;
soundOptionsInfo.a3d.generic.id = ID_A3D;
soundOptionsInfo.a3d.generic.x = 400;
soundOptionsInfo.a3d.generic.y = y;
*/
soundOptionsInfo.back.generic.type = MTYPE_BITMAP;
soundOptionsInfo.back.generic.name = ART_BACK0;
soundOptionsInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
soundOptionsInfo.back.generic.callback = UI_SoundOptionsMenu_Event;
soundOptionsInfo.back.generic.id = ID_BACK;
soundOptionsInfo.back.generic.x = 0;
soundOptionsInfo.back.generic.y = 480-64;
soundOptionsInfo.back.width = 128;
soundOptionsInfo.back.height = 64;
soundOptionsInfo.back.focuspic = ART_BACK1;
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.banner );
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.framel );
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.framer );
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.graphics );
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.display );
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.sound );
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.network );
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.sfxvolume );
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.musicvolume );
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.quality );
// Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.a3d );
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.back );
soundOptionsInfo.sfxvolume.curvalue = trap_Cvar_VariableValue( "s_volume" ) * 10;
soundOptionsInfo.musicvolume.curvalue = trap_Cvar_VariableValue( "s_musicvolume" ) * 10;
soundOptionsInfo.quality.curvalue = !trap_Cvar_VariableValue( "s_compression" );
// soundOptionsInfo.a3d.curvalue = (int)trap_Cvar_VariableValue( "s_usingA3D" );
}
/*
===============
UI_SoundOptionsMenu_Cache
===============
*/
void UI_SoundOptionsMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
}
/*
===============
UI_SoundOptionsMenu
===============
*/
void UI_SoundOptionsMenu( void ) {
UI_SoundOptionsMenu_Init();
UI_PushMenu( &soundOptionsInfo.menu );
Menu_SetCursorToItem( &soundOptionsInfo.menu, &soundOptionsInfo.sound );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
SOUND OPTIONS MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_FRAMEL "menu/art/frame2_l"
#define ART_FRAMER "menu/art/frame1_r"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ID_GRAPHICS 10
#define ID_DISPLAY 11
#define ID_SOUND 12
#define ID_NETWORK 13
#define ID_EFFECTSVOLUME 14
#define ID_MUSICVOLUME 15
#define ID_QUALITY 16
//#define ID_A3D 17
#define ID_BACK 18
static const char *quality_items[] = {
"Low", "High", 0
};
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menutext_s graphics;
menutext_s display;
menutext_s sound;
menutext_s network;
menuslider_s sfxvolume;
menuslider_s musicvolume;
menulist_s quality;
// menuradiobutton_s a3d;
menubitmap_s back;
} soundOptionsInfo_t;
static soundOptionsInfo_t soundOptionsInfo;
/*
=================
UI_SoundOptionsMenu_Event
=================
*/
static void UI_SoundOptionsMenu_Event( void* ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_GRAPHICS:
UI_PopMenu();
UI_GraphicsOptionsMenu();
break;
case ID_DISPLAY:
UI_PopMenu();
UI_DisplayOptionsMenu();
break;
case ID_SOUND:
break;
case ID_NETWORK:
UI_PopMenu();
UI_NetworkOptionsMenu();
break;
case ID_EFFECTSVOLUME:
trap_Cvar_SetValue( "s_volume", soundOptionsInfo.sfxvolume.curvalue / 10 );
break;
case ID_MUSICVOLUME:
trap_Cvar_SetValue( "s_musicvolume", soundOptionsInfo.musicvolume.curvalue / 10 );
break;
case ID_QUALITY:
if( soundOptionsInfo.quality.curvalue ) {
trap_Cvar_SetValue( "s_khz", 22 );
trap_Cvar_SetValue( "s_compression", 0 );
}
else {
trap_Cvar_SetValue( "s_khz", 11 );
trap_Cvar_SetValue( "s_compression", 1 );
}
UI_ForceMenuOff();
trap_Cmd_ExecuteText( EXEC_APPEND, "snd_restart\n" );
break;
/*
case ID_A3D:
if( soundOptionsInfo.a3d.curvalue ) {
trap_Cmd_ExecuteText( EXEC_NOW, "s_enable_a3d\n" );
}
else {
trap_Cmd_ExecuteText( EXEC_NOW, "s_disable_a3d\n" );
}
soundOptionsInfo.a3d.curvalue = (int)trap_Cvar_VariableValue( "s_usingA3D" );
break;
*/
case ID_BACK:
UI_PopMenu();
break;
}
}
/*
===============
UI_SoundOptionsMenu_Init
===============
*/
static void UI_SoundOptionsMenu_Init( void ) {
int y;
memset( &soundOptionsInfo, 0, sizeof(soundOptionsInfo) );
UI_SoundOptionsMenu_Cache();
soundOptionsInfo.menu.wrapAround = qtrue;
soundOptionsInfo.menu.fullscreen = qtrue;
soundOptionsInfo.banner.generic.type = MTYPE_BTEXT;
soundOptionsInfo.banner.generic.flags = QMF_CENTER_JUSTIFY;
soundOptionsInfo.banner.generic.x = 320;
soundOptionsInfo.banner.generic.y = 16;
soundOptionsInfo.banner.string = "SYSTEM SETUP";
soundOptionsInfo.banner.color = color_white;
soundOptionsInfo.banner.style = UI_CENTER;
soundOptionsInfo.framel.generic.type = MTYPE_BITMAP;
soundOptionsInfo.framel.generic.name = ART_FRAMEL;
soundOptionsInfo.framel.generic.flags = QMF_INACTIVE;
soundOptionsInfo.framel.generic.x = 0;
soundOptionsInfo.framel.generic.y = 78;
soundOptionsInfo.framel.width = 256;
soundOptionsInfo.framel.height = 329;
soundOptionsInfo.framer.generic.type = MTYPE_BITMAP;
soundOptionsInfo.framer.generic.name = ART_FRAMER;
soundOptionsInfo.framer.generic.flags = QMF_INACTIVE;
soundOptionsInfo.framer.generic.x = 376;
soundOptionsInfo.framer.generic.y = 76;
soundOptionsInfo.framer.width = 256;
soundOptionsInfo.framer.height = 334;
soundOptionsInfo.graphics.generic.type = MTYPE_PTEXT;
soundOptionsInfo.graphics.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
soundOptionsInfo.graphics.generic.id = ID_GRAPHICS;
soundOptionsInfo.graphics.generic.callback = UI_SoundOptionsMenu_Event;
soundOptionsInfo.graphics.generic.x = 216;
soundOptionsInfo.graphics.generic.y = 240 - 2 * PROP_HEIGHT;
soundOptionsInfo.graphics.string = "GRAPHICS";
soundOptionsInfo.graphics.style = UI_RIGHT;
soundOptionsInfo.graphics.color = color_red;
soundOptionsInfo.display.generic.type = MTYPE_PTEXT;
soundOptionsInfo.display.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
soundOptionsInfo.display.generic.id = ID_DISPLAY;
soundOptionsInfo.display.generic.callback = UI_SoundOptionsMenu_Event;
soundOptionsInfo.display.generic.x = 216;
soundOptionsInfo.display.generic.y = 240 - PROP_HEIGHT;
soundOptionsInfo.display.string = "DISPLAY";
soundOptionsInfo.display.style = UI_RIGHT;
soundOptionsInfo.display.color = color_red;
soundOptionsInfo.sound.generic.type = MTYPE_PTEXT;
soundOptionsInfo.sound.generic.flags = QMF_RIGHT_JUSTIFY;
soundOptionsInfo.sound.generic.id = ID_SOUND;
soundOptionsInfo.sound.generic.callback = UI_SoundOptionsMenu_Event;
soundOptionsInfo.sound.generic.x = 216;
soundOptionsInfo.sound.generic.y = 240;
soundOptionsInfo.sound.string = "SOUND";
soundOptionsInfo.sound.style = UI_RIGHT;
soundOptionsInfo.sound.color = color_red;
soundOptionsInfo.network.generic.type = MTYPE_PTEXT;
soundOptionsInfo.network.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
soundOptionsInfo.network.generic.id = ID_NETWORK;
soundOptionsInfo.network.generic.callback = UI_SoundOptionsMenu_Event;
soundOptionsInfo.network.generic.x = 216;
soundOptionsInfo.network.generic.y = 240 + PROP_HEIGHT;
soundOptionsInfo.network.string = "NETWORK";
soundOptionsInfo.network.style = UI_RIGHT;
soundOptionsInfo.network.color = color_red;
y = 240 - 1.5 * (BIGCHAR_HEIGHT + 2);
soundOptionsInfo.sfxvolume.generic.type = MTYPE_SLIDER;
soundOptionsInfo.sfxvolume.generic.name = "Effects Volume:";
soundOptionsInfo.sfxvolume.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
soundOptionsInfo.sfxvolume.generic.callback = UI_SoundOptionsMenu_Event;
soundOptionsInfo.sfxvolume.generic.id = ID_EFFECTSVOLUME;
soundOptionsInfo.sfxvolume.generic.x = 400;
soundOptionsInfo.sfxvolume.generic.y = y;
soundOptionsInfo.sfxvolume.minvalue = 0;
soundOptionsInfo.sfxvolume.maxvalue = 10;
y += BIGCHAR_HEIGHT+2;
soundOptionsInfo.musicvolume.generic.type = MTYPE_SLIDER;
soundOptionsInfo.musicvolume.generic.name = "Music Volume:";
soundOptionsInfo.musicvolume.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
soundOptionsInfo.musicvolume.generic.callback = UI_SoundOptionsMenu_Event;
soundOptionsInfo.musicvolume.generic.id = ID_MUSICVOLUME;
soundOptionsInfo.musicvolume.generic.x = 400;
soundOptionsInfo.musicvolume.generic.y = y;
soundOptionsInfo.musicvolume.minvalue = 0;
soundOptionsInfo.musicvolume.maxvalue = 10;
y += BIGCHAR_HEIGHT+2;
soundOptionsInfo.quality.generic.type = MTYPE_SPINCONTROL;
soundOptionsInfo.quality.generic.name = "Sound Quality:";
soundOptionsInfo.quality.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
soundOptionsInfo.quality.generic.callback = UI_SoundOptionsMenu_Event;
soundOptionsInfo.quality.generic.id = ID_QUALITY;
soundOptionsInfo.quality.generic.x = 400;
soundOptionsInfo.quality.generic.y = y;
soundOptionsInfo.quality.itemnames = quality_items;
/*
y += BIGCHAR_HEIGHT+2;
soundOptionsInfo.a3d.generic.type = MTYPE_RADIOBUTTON;
soundOptionsInfo.a3d.generic.name = "A3D:";
soundOptionsInfo.a3d.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
soundOptionsInfo.a3d.generic.callback = UI_SoundOptionsMenu_Event;
soundOptionsInfo.a3d.generic.id = ID_A3D;
soundOptionsInfo.a3d.generic.x = 400;
soundOptionsInfo.a3d.generic.y = y;
*/
soundOptionsInfo.back.generic.type = MTYPE_BITMAP;
soundOptionsInfo.back.generic.name = ART_BACK0;
soundOptionsInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
soundOptionsInfo.back.generic.callback = UI_SoundOptionsMenu_Event;
soundOptionsInfo.back.generic.id = ID_BACK;
soundOptionsInfo.back.generic.x = 0;
soundOptionsInfo.back.generic.y = 480-64;
soundOptionsInfo.back.width = 128;
soundOptionsInfo.back.height = 64;
soundOptionsInfo.back.focuspic = ART_BACK1;
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.banner );
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.framel );
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.framer );
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.graphics );
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.display );
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.sound );
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.network );
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.sfxvolume );
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.musicvolume );
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.quality );
// Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.a3d );
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.back );
soundOptionsInfo.sfxvolume.curvalue = trap_Cvar_VariableValue( "s_volume" ) * 10;
soundOptionsInfo.musicvolume.curvalue = trap_Cvar_VariableValue( "s_musicvolume" ) * 10;
soundOptionsInfo.quality.curvalue = !trap_Cvar_VariableValue( "s_compression" );
// soundOptionsInfo.a3d.curvalue = (int)trap_Cvar_VariableValue( "s_usingA3D" );
}
/*
===============
UI_SoundOptionsMenu_Cache
===============
*/
void UI_SoundOptionsMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_FRAMEL );
trap_R_RegisterShaderNoMip( ART_FRAMER );
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
}
/*
===============
UI_SoundOptionsMenu
===============
*/
void UI_SoundOptionsMenu( void ) {
UI_SoundOptionsMenu_Init();
UI_PushMenu( &soundOptionsInfo.menu );
Menu_SetCursorToItem( &soundOptionsInfo.menu, &soundOptionsInfo.sound );
}

View file

@ -1,50 +1,50 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#include "ui_local.h"
void UI_SPArena_Start( const char *arenaInfo ) {
char *map;
int level;
int n;
char *txt;
n = (int)trap_Cvar_VariableValue( "sv_maxclients" );
if ( n < 8 ) {
trap_Cvar_SetValue( "sv_maxclients", 8 );
}
level = atoi( Info_ValueForKey( arenaInfo, "num" ) );
txt = Info_ValueForKey( arenaInfo, "special" );
if( txt[0] ) {
if( Q_stricmp( txt, "training" ) == 0 ) {
level = -4;
}
else if( Q_stricmp( txt, "final" ) == 0 ) {
level = UI_GetNumSPTiers() * ARENAS_PER_TIER;
}
}
trap_Cvar_SetValue( "ui_spSelection", level );
map = Info_ValueForKey( arenaInfo, "map" );
trap_Cmd_ExecuteText( EXEC_APPEND, va( "spmap %s\n", map ) );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#include "ui_local.h"
void UI_SPArena_Start( const char *arenaInfo ) {
char *map;
int level;
int n;
char *txt;
n = (int)trap_Cvar_VariableValue( "sv_maxclients" );
if ( n < 8 ) {
trap_Cvar_SetValue( "sv_maxclients", 8 );
}
level = atoi( Info_ValueForKey( arenaInfo, "num" ) );
txt = Info_ValueForKey( arenaInfo, "special" );
if( txt[0] ) {
if( Q_stricmp( txt, "training" ) == 0 ) {
level = -4;
}
else if( Q_stricmp( txt, "final" ) == 0 ) {
level = UI_GetNumSPTiers() * ARENAS_PER_TIER;
}
}
trap_Cvar_SetValue( "ui_spSelection", level );
map = Info_ValueForKey( arenaInfo, "map" );
trap_Cmd_ExecuteText( EXEC_APPEND, va( "spmap %s\n", map ) );
}

View file

@ -1,333 +1,333 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#include "ui_local.h"
/*********************************************************************************
SPECIFY SERVER
*********************************************************************************/
#define MAX_LISTBOXITEMS 128
#define MAX_LISTBOXWIDTH 40
#define MAX_LEAGUENAME 80
#define SPECIFYLEAGUE_FRAMEL "menu/art/frame2_l"
#define SPECIFYLEAGUE_FRAMER "menu/art/frame1_r"
#define SPECIFYLEAGUE_BACK0 "menu/art/back_0"
#define SPECIFYLEAGUE_BACK1 "menu/art/back_1"
#define SPECIFYLEAGUE_ARROWS0 "menu/art/arrows_vert_0"
#define SPECIFYLEAGUE_UP "menu/art/arrows_vert_top"
#define SPECIFYLEAGUE_DOWN "menu/art/arrows_vert_bot"
#define GLOBALRANKINGS_LOGO "menu/art/gr/grlogo"
#define GLOBALRANKINGS_LETTERS "menu/art/gr/grletters"
#define ID_SPECIFYLEAGUENAME 100
#define ID_SPECIFYLEAGUELIST 101
#define ID_SPECIFYLEAGUEUP 102
#define ID_SPECIFYLEAGUEDOWN 103
#define ID_SPECIFYLEAGUEBACK 104
static char* specifyleague_artlist[] =
{
SPECIFYLEAGUE_FRAMEL,
SPECIFYLEAGUE_FRAMER,
SPECIFYLEAGUE_ARROWS0,
SPECIFYLEAGUE_UP,
SPECIFYLEAGUE_DOWN,
SPECIFYLEAGUE_BACK0,
SPECIFYLEAGUE_BACK1,
GLOBALRANKINGS_LOGO,
GLOBALRANKINGS_LETTERS,
NULL
};
static char playername[80];
typedef struct
{
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menufield_s rankname;
menulist_s list;
menubitmap_s arrows;
menubitmap_s up;
menubitmap_s down;
menubitmap_s back;
menubitmap_s grlogo;
menubitmap_s grletters;
} specifyleague_t;
static specifyleague_t s_specifyleague;
typedef struct {
char buff[MAX_LISTBOXWIDTH];
char leaguename[MAX_LEAGUENAME];
} table_t;
table_t league_table[MAX_LISTBOXITEMS];
char *leaguename_items[MAX_LISTBOXITEMS];
static void SpecifyLeague_GetList()
{
int count = 0;
int i;
/* The Player Name has changed. We need to perform another search */
Q_strncpyz( playername,
s_specifyleague.rankname.field.buffer,
sizeof(playername) );
count = trap_CL_UI_RankGetLeauges( playername );
for(i = 0; i < count; i++)
{
char s[MAX_LEAGUENAME];
const char *var;
var = va( "leaguename%i", i+1 );
trap_Cvar_VariableStringBuffer( var, s, sizeof(s) );
Q_strncpyz(league_table[i].leaguename, s, sizeof(league_table[i].leaguename) );
Q_strncpyz(league_table[i].buff, league_table[i].leaguename, sizeof(league_table[i].buff) );
}
s_specifyleague.list.numitems = count;
}
/*
=================
SpecifyLeague_Event
=================
*/
static void SpecifyLeague_Event( void* ptr, int event )
{
int id;
id = ((menucommon_s*)ptr)->id;
//if( event != QM_ACTIVATED && id != ID_SPECIFYLEAGUELIST ) {
// return;
//}
switch (id)
{
case ID_SPECIFYLEAGUELIST:
if( event == QM_GOTFOCUS ) {
//ArenaServers_UpdatePicture();
}
break;
case ID_SPECIFYLEAGUEUP:
if( event == QM_ACTIVATED )
ScrollList_Key( &s_specifyleague.list, K_UPARROW );
break;
case ID_SPECIFYLEAGUEDOWN:
if( event == QM_ACTIVATED )
ScrollList_Key( &s_specifyleague.list, K_DOWNARROW );
break;
case ID_SPECIFYLEAGUENAME:
if( (event == QM_LOSTFOCUS) &&
(Q_strncmp(playername,
s_specifyleague.rankname.field.buffer,
strlen(s_specifyleague.rankname.field.buffer)) != 0))
{
SpecifyLeague_GetList();
}
break;
case ID_SPECIFYLEAGUEBACK:
if( event == QM_ACTIVATED )
{
trap_Cvar_Set( "sv_leagueName", league_table[s_specifyleague.list.curvalue].leaguename);
UI_PopMenu();
}
break;
}
}
/*
=================
SpecifyLeague_MenuInit
=================
*/
void SpecifyLeague_MenuInit( void )
{
int i;
// zero set all our globals
memset( &s_specifyleague, 0 ,sizeof(specifyleague_t) );
SpecifyLeague_Cache();
s_specifyleague.menu.wrapAround = qtrue;
s_specifyleague.menu.fullscreen = qtrue;
s_specifyleague.banner.generic.type = MTYPE_BTEXT;
s_specifyleague.banner.generic.x = 320;
s_specifyleague.banner.generic.y = 16;
s_specifyleague.banner.string = "CHOOSE LEAGUE";
s_specifyleague.banner.color = color_white;
s_specifyleague.banner.style = UI_CENTER;
s_specifyleague.framel.generic.type = MTYPE_BITMAP;
s_specifyleague.framel.generic.name = SPECIFYLEAGUE_FRAMEL;
s_specifyleague.framel.generic.flags = QMF_INACTIVE;
s_specifyleague.framel.generic.x = 0;
s_specifyleague.framel.generic.y = 78;
s_specifyleague.framel.width = 256;
s_specifyleague.framel.height = 334;
s_specifyleague.framer.generic.type = MTYPE_BITMAP;
s_specifyleague.framer.generic.name = SPECIFYLEAGUE_FRAMER;
s_specifyleague.framer.generic.flags = QMF_INACTIVE;
s_specifyleague.framer.generic.x = 376;
s_specifyleague.framer.generic.y = 76;
s_specifyleague.framer.width = 256;
s_specifyleague.framer.height = 334;
s_specifyleague.grlogo.generic.type = MTYPE_BITMAP;
s_specifyleague.grlogo.generic.name = GLOBALRANKINGS_LOGO;
s_specifyleague.grlogo.generic.flags = QMF_INACTIVE;
s_specifyleague.grlogo.generic.x = 0;
s_specifyleague.grlogo.generic.y = 0;
s_specifyleague.grlogo.width = 64;
s_specifyleague.grlogo.height = 128;
s_specifyleague.rankname.generic.type = MTYPE_FIELD;
s_specifyleague.rankname.generic.name = "Player Name:";
s_specifyleague.rankname.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_specifyleague.rankname.generic.callback = SpecifyLeague_Event;
s_specifyleague.rankname.generic.id = ID_SPECIFYLEAGUENAME;
s_specifyleague.rankname.generic.x = 226;
s_specifyleague.rankname.generic.y = 128;
s_specifyleague.rankname.field.widthInChars = 32;
s_specifyleague.rankname.field.maxchars = 80;
s_specifyleague.list.generic.type = MTYPE_SCROLLLIST;
s_specifyleague.list.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_specifyleague.list.generic.id = ID_SPECIFYLEAGUELIST;
s_specifyleague.list.generic.callback = SpecifyLeague_Event;
s_specifyleague.list.generic.x = 160;
s_specifyleague.list.generic.y = 200;
s_specifyleague.list.width = MAX_LISTBOXWIDTH;
s_specifyleague.list.height = 8;
s_specifyleague.list.itemnames = (const char **)leaguename_items;
s_specifyleague.list.numitems = 0;
for( i = 0; i < MAX_LISTBOXITEMS; i++ ) {
league_table[i].buff[0] = 0;
league_table[i].leaguename[0] = 0;
leaguename_items[i] = league_table[i].buff;
}
s_specifyleague.arrows.generic.type = MTYPE_BITMAP;
s_specifyleague.arrows.generic.name = SPECIFYLEAGUE_ARROWS0;
s_specifyleague.arrows.generic.flags = QMF_LEFT_JUSTIFY|QMF_INACTIVE;
s_specifyleague.arrows.generic.callback = SpecifyLeague_Event;
s_specifyleague.arrows.generic.x = 512;
s_specifyleague.arrows.generic.y = 240-64+16;
s_specifyleague.arrows.width = 64;
s_specifyleague.arrows.height = 128;
s_specifyleague.up.generic.type = MTYPE_BITMAP;
s_specifyleague.up.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;
s_specifyleague.up.generic.callback = SpecifyLeague_Event;
s_specifyleague.up.generic.id = ID_SPECIFYLEAGUEUP;
s_specifyleague.up.generic.x = 512;
s_specifyleague.up.generic.y = 240-64+16;
s_specifyleague.up.width = 64;
s_specifyleague.up.height = 64;
s_specifyleague.up.focuspic = SPECIFYLEAGUE_UP;
s_specifyleague.down.generic.type = MTYPE_BITMAP;
s_specifyleague.down.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;
s_specifyleague.down.generic.callback = SpecifyLeague_Event;
s_specifyleague.down.generic.id = ID_SPECIFYLEAGUEDOWN;
s_specifyleague.down.generic.x = 512;
s_specifyleague.down.generic.y = 240+16;
s_specifyleague.down.width = 64;
s_specifyleague.down.height = 64;
s_specifyleague.down.focuspic = SPECIFYLEAGUE_DOWN;
s_specifyleague.back.generic.type = MTYPE_BITMAP;
s_specifyleague.back.generic.name = SPECIFYLEAGUE_BACK0;
s_specifyleague.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_specifyleague.back.generic.callback = SpecifyLeague_Event;
s_specifyleague.back.generic.id = ID_SPECIFYLEAGUEBACK;
s_specifyleague.back.generic.x = 0;
s_specifyleague.back.generic.y = 480-64;
s_specifyleague.back.width = 128;
s_specifyleague.back.height = 64;
s_specifyleague.back.focuspic = SPECIFYLEAGUE_BACK1;
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.banner );
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.framel );
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.framer );
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.grlogo );
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.rankname );
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.list );
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.arrows );
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.up );
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.down );
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.back );
// initialize any menu variables
Q_strncpyz( s_specifyleague.rankname.field.buffer,
UI_Cvar_VariableString("name"),
sizeof(s_specifyleague.rankname.field.buffer) );
Q_strncpyz( playername,
UI_Cvar_VariableString("name"),
sizeof(playername) );
SpecifyLeague_GetList();
}
/*
=================
SpecifyLeague_Cache
=================
*/
void SpecifyLeague_Cache( void )
{
int i;
// touch all our pics
for (i=0; ;i++)
{
if (!specifyleague_artlist[i])
break;
trap_R_RegisterShaderNoMip(specifyleague_artlist[i]);
}
}
/*
=================
UI_SpecifyLeagueMenu
=================
*/
void UI_SpecifyLeagueMenu( void )
{
SpecifyLeague_MenuInit();
UI_PushMenu( &s_specifyleague.menu );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#include "ui_local.h"
/*********************************************************************************
SPECIFY SERVER
*********************************************************************************/
#define MAX_LISTBOXITEMS 128
#define MAX_LISTBOXWIDTH 40
#define MAX_LEAGUENAME 80
#define SPECIFYLEAGUE_FRAMEL "menu/art/frame2_l"
#define SPECIFYLEAGUE_FRAMER "menu/art/frame1_r"
#define SPECIFYLEAGUE_BACK0 "menu/art/back_0"
#define SPECIFYLEAGUE_BACK1 "menu/art/back_1"
#define SPECIFYLEAGUE_ARROWS0 "menu/art/arrows_vert_0"
#define SPECIFYLEAGUE_UP "menu/art/arrows_vert_top"
#define SPECIFYLEAGUE_DOWN "menu/art/arrows_vert_bot"
#define GLOBALRANKINGS_LOGO "menu/art/gr/grlogo"
#define GLOBALRANKINGS_LETTERS "menu/art/gr/grletters"
#define ID_SPECIFYLEAGUENAME 100
#define ID_SPECIFYLEAGUELIST 101
#define ID_SPECIFYLEAGUEUP 102
#define ID_SPECIFYLEAGUEDOWN 103
#define ID_SPECIFYLEAGUEBACK 104
static char* specifyleague_artlist[] =
{
SPECIFYLEAGUE_FRAMEL,
SPECIFYLEAGUE_FRAMER,
SPECIFYLEAGUE_ARROWS0,
SPECIFYLEAGUE_UP,
SPECIFYLEAGUE_DOWN,
SPECIFYLEAGUE_BACK0,
SPECIFYLEAGUE_BACK1,
GLOBALRANKINGS_LOGO,
GLOBALRANKINGS_LETTERS,
NULL
};
static char playername[80];
typedef struct
{
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menufield_s rankname;
menulist_s list;
menubitmap_s arrows;
menubitmap_s up;
menubitmap_s down;
menubitmap_s back;
menubitmap_s grlogo;
menubitmap_s grletters;
} specifyleague_t;
static specifyleague_t s_specifyleague;
typedef struct {
char buff[MAX_LISTBOXWIDTH];
char leaguename[MAX_LEAGUENAME];
} table_t;
table_t league_table[MAX_LISTBOXITEMS];
char *leaguename_items[MAX_LISTBOXITEMS];
static void SpecifyLeague_GetList()
{
int count = 0;
int i;
/* The Player Name has changed. We need to perform another search */
Q_strncpyz( playername,
s_specifyleague.rankname.field.buffer,
sizeof(playername) );
count = trap_CL_UI_RankGetLeauges( playername );
for(i = 0; i < count; i++)
{
char s[MAX_LEAGUENAME];
const char *var;
var = va( "leaguename%i", i+1 );
trap_Cvar_VariableStringBuffer( var, s, sizeof(s) );
Q_strncpyz(league_table[i].leaguename, s, sizeof(league_table[i].leaguename) );
Q_strncpyz(league_table[i].buff, league_table[i].leaguename, sizeof(league_table[i].buff) );
}
s_specifyleague.list.numitems = count;
}
/*
=================
SpecifyLeague_Event
=================
*/
static void SpecifyLeague_Event( void* ptr, int event )
{
int id;
id = ((menucommon_s*)ptr)->id;
//if( event != QM_ACTIVATED && id != ID_SPECIFYLEAGUELIST ) {
// return;
//}
switch (id)
{
case ID_SPECIFYLEAGUELIST:
if( event == QM_GOTFOCUS ) {
//ArenaServers_UpdatePicture();
}
break;
case ID_SPECIFYLEAGUEUP:
if( event == QM_ACTIVATED )
ScrollList_Key( &s_specifyleague.list, K_UPARROW );
break;
case ID_SPECIFYLEAGUEDOWN:
if( event == QM_ACTIVATED )
ScrollList_Key( &s_specifyleague.list, K_DOWNARROW );
break;
case ID_SPECIFYLEAGUENAME:
if( (event == QM_LOSTFOCUS) &&
(Q_strncmp(playername,
s_specifyleague.rankname.field.buffer,
strlen(s_specifyleague.rankname.field.buffer)) != 0))
{
SpecifyLeague_GetList();
}
break;
case ID_SPECIFYLEAGUEBACK:
if( event == QM_ACTIVATED )
{
trap_Cvar_Set( "sv_leagueName", league_table[s_specifyleague.list.curvalue].leaguename);
UI_PopMenu();
}
break;
}
}
/*
=================
SpecifyLeague_MenuInit
=================
*/
void SpecifyLeague_MenuInit( void )
{
int i;
// zero set all our globals
memset( &s_specifyleague, 0 ,sizeof(specifyleague_t) );
SpecifyLeague_Cache();
s_specifyleague.menu.wrapAround = qtrue;
s_specifyleague.menu.fullscreen = qtrue;
s_specifyleague.banner.generic.type = MTYPE_BTEXT;
s_specifyleague.banner.generic.x = 320;
s_specifyleague.banner.generic.y = 16;
s_specifyleague.banner.string = "CHOOSE LEAGUE";
s_specifyleague.banner.color = color_white;
s_specifyleague.banner.style = UI_CENTER;
s_specifyleague.framel.generic.type = MTYPE_BITMAP;
s_specifyleague.framel.generic.name = SPECIFYLEAGUE_FRAMEL;
s_specifyleague.framel.generic.flags = QMF_INACTIVE;
s_specifyleague.framel.generic.x = 0;
s_specifyleague.framel.generic.y = 78;
s_specifyleague.framel.width = 256;
s_specifyleague.framel.height = 334;
s_specifyleague.framer.generic.type = MTYPE_BITMAP;
s_specifyleague.framer.generic.name = SPECIFYLEAGUE_FRAMER;
s_specifyleague.framer.generic.flags = QMF_INACTIVE;
s_specifyleague.framer.generic.x = 376;
s_specifyleague.framer.generic.y = 76;
s_specifyleague.framer.width = 256;
s_specifyleague.framer.height = 334;
s_specifyleague.grlogo.generic.type = MTYPE_BITMAP;
s_specifyleague.grlogo.generic.name = GLOBALRANKINGS_LOGO;
s_specifyleague.grlogo.generic.flags = QMF_INACTIVE;
s_specifyleague.grlogo.generic.x = 0;
s_specifyleague.grlogo.generic.y = 0;
s_specifyleague.grlogo.width = 64;
s_specifyleague.grlogo.height = 128;
s_specifyleague.rankname.generic.type = MTYPE_FIELD;
s_specifyleague.rankname.generic.name = "Player Name:";
s_specifyleague.rankname.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_specifyleague.rankname.generic.callback = SpecifyLeague_Event;
s_specifyleague.rankname.generic.id = ID_SPECIFYLEAGUENAME;
s_specifyleague.rankname.generic.x = 226;
s_specifyleague.rankname.generic.y = 128;
s_specifyleague.rankname.field.widthInChars = 32;
s_specifyleague.rankname.field.maxchars = 80;
s_specifyleague.list.generic.type = MTYPE_SCROLLLIST;
s_specifyleague.list.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_specifyleague.list.generic.id = ID_SPECIFYLEAGUELIST;
s_specifyleague.list.generic.callback = SpecifyLeague_Event;
s_specifyleague.list.generic.x = 160;
s_specifyleague.list.generic.y = 200;
s_specifyleague.list.width = MAX_LISTBOXWIDTH;
s_specifyleague.list.height = 8;
s_specifyleague.list.itemnames = (const char **)leaguename_items;
s_specifyleague.list.numitems = 0;
for( i = 0; i < MAX_LISTBOXITEMS; i++ ) {
league_table[i].buff[0] = 0;
league_table[i].leaguename[0] = 0;
leaguename_items[i] = league_table[i].buff;
}
s_specifyleague.arrows.generic.type = MTYPE_BITMAP;
s_specifyleague.arrows.generic.name = SPECIFYLEAGUE_ARROWS0;
s_specifyleague.arrows.generic.flags = QMF_LEFT_JUSTIFY|QMF_INACTIVE;
s_specifyleague.arrows.generic.callback = SpecifyLeague_Event;
s_specifyleague.arrows.generic.x = 512;
s_specifyleague.arrows.generic.y = 240-64+16;
s_specifyleague.arrows.width = 64;
s_specifyleague.arrows.height = 128;
s_specifyleague.up.generic.type = MTYPE_BITMAP;
s_specifyleague.up.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;
s_specifyleague.up.generic.callback = SpecifyLeague_Event;
s_specifyleague.up.generic.id = ID_SPECIFYLEAGUEUP;
s_specifyleague.up.generic.x = 512;
s_specifyleague.up.generic.y = 240-64+16;
s_specifyleague.up.width = 64;
s_specifyleague.up.height = 64;
s_specifyleague.up.focuspic = SPECIFYLEAGUE_UP;
s_specifyleague.down.generic.type = MTYPE_BITMAP;
s_specifyleague.down.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;
s_specifyleague.down.generic.callback = SpecifyLeague_Event;
s_specifyleague.down.generic.id = ID_SPECIFYLEAGUEDOWN;
s_specifyleague.down.generic.x = 512;
s_specifyleague.down.generic.y = 240+16;
s_specifyleague.down.width = 64;
s_specifyleague.down.height = 64;
s_specifyleague.down.focuspic = SPECIFYLEAGUE_DOWN;
s_specifyleague.back.generic.type = MTYPE_BITMAP;
s_specifyleague.back.generic.name = SPECIFYLEAGUE_BACK0;
s_specifyleague.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_specifyleague.back.generic.callback = SpecifyLeague_Event;
s_specifyleague.back.generic.id = ID_SPECIFYLEAGUEBACK;
s_specifyleague.back.generic.x = 0;
s_specifyleague.back.generic.y = 480-64;
s_specifyleague.back.width = 128;
s_specifyleague.back.height = 64;
s_specifyleague.back.focuspic = SPECIFYLEAGUE_BACK1;
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.banner );
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.framel );
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.framer );
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.grlogo );
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.rankname );
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.list );
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.arrows );
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.up );
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.down );
Menu_AddItem( &s_specifyleague.menu, &s_specifyleague.back );
// initialize any menu variables
Q_strncpyz( s_specifyleague.rankname.field.buffer,
UI_Cvar_VariableString("name"),
sizeof(s_specifyleague.rankname.field.buffer) );
Q_strncpyz( playername,
UI_Cvar_VariableString("name"),
sizeof(playername) );
SpecifyLeague_GetList();
}
/*
=================
SpecifyLeague_Cache
=================
*/
void SpecifyLeague_Cache( void )
{
int i;
// touch all our pics
for (i=0; ;i++)
{
if (!specifyleague_artlist[i])
break;
trap_R_RegisterShaderNoMip(specifyleague_artlist[i]);
}
}
/*
=================
UI_SpecifyLeagueMenu
=================
*/
void UI_SpecifyLeagueMenu( void )
{
SpecifyLeague_MenuInit();
UI_PushMenu( &s_specifyleague.menu );
}

View file

@ -1,213 +1,213 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#include "ui_local.h"
/*********************************************************************************
SPECIFY SERVER
*********************************************************************************/
#define SPECIFYSERVER_FRAMEL "menu/art/frame2_l"
#define SPECIFYSERVER_FRAMER "menu/art/frame1_r"
#define SPECIFYSERVER_BACK0 "menu/art/back_0"
#define SPECIFYSERVER_BACK1 "menu/art/back_1"
#define SPECIFYSERVER_FIGHT0 "menu/art/fight_0"
#define SPECIFYSERVER_FIGHT1 "menu/art/fight_1"
#define ID_SPECIFYSERVERBACK 102
#define ID_SPECIFYSERVERGO 103
static char* specifyserver_artlist[] =
{
SPECIFYSERVER_FRAMEL,
SPECIFYSERVER_FRAMER,
SPECIFYSERVER_BACK0,
SPECIFYSERVER_BACK1,
SPECIFYSERVER_FIGHT0,
SPECIFYSERVER_FIGHT1,
NULL
};
typedef struct
{
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menufield_s domain;
menufield_s port;
menubitmap_s go;
menubitmap_s back;
} specifyserver_t;
static specifyserver_t s_specifyserver;
/*
=================
SpecifyServer_Event
=================
*/
static void SpecifyServer_Event( void* ptr, int event )
{
char buff[256];
switch (((menucommon_s*)ptr)->id)
{
case ID_SPECIFYSERVERGO:
if (event != QM_ACTIVATED)
break;
if (s_specifyserver.domain.field.buffer[0])
{
strcpy(buff,s_specifyserver.domain.field.buffer);
if (s_specifyserver.port.field.buffer[0])
Com_sprintf( buff+strlen(buff), 128, ":%s", s_specifyserver.port.field.buffer );
trap_Cmd_ExecuteText( EXEC_APPEND, va( "connect %s\n", buff ) );
}
break;
case ID_SPECIFYSERVERBACK:
if (event != QM_ACTIVATED)
break;
UI_PopMenu();
break;
}
}
/*
=================
SpecifyServer_MenuInit
=================
*/
void SpecifyServer_MenuInit( void )
{
// zero set all our globals
memset( &s_specifyserver, 0 ,sizeof(specifyserver_t) );
SpecifyServer_Cache();
s_specifyserver.menu.wrapAround = qtrue;
s_specifyserver.menu.fullscreen = qtrue;
s_specifyserver.banner.generic.type = MTYPE_BTEXT;
s_specifyserver.banner.generic.x = 320;
s_specifyserver.banner.generic.y = 16;
s_specifyserver.banner.string = "SPECIFY SERVER";
s_specifyserver.banner.color = color_white;
s_specifyserver.banner.style = UI_CENTER;
s_specifyserver.framel.generic.type = MTYPE_BITMAP;
s_specifyserver.framel.generic.name = SPECIFYSERVER_FRAMEL;
s_specifyserver.framel.generic.flags = QMF_INACTIVE;
s_specifyserver.framel.generic.x = 0;
s_specifyserver.framel.generic.y = 78;
s_specifyserver.framel.width = 256;
s_specifyserver.framel.height = 329;
s_specifyserver.framer.generic.type = MTYPE_BITMAP;
s_specifyserver.framer.generic.name = SPECIFYSERVER_FRAMER;
s_specifyserver.framer.generic.flags = QMF_INACTIVE;
s_specifyserver.framer.generic.x = 376;
s_specifyserver.framer.generic.y = 76;
s_specifyserver.framer.width = 256;
s_specifyserver.framer.height = 334;
s_specifyserver.domain.generic.type = MTYPE_FIELD;
s_specifyserver.domain.generic.name = "Address:";
s_specifyserver.domain.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_specifyserver.domain.generic.x = 206;
s_specifyserver.domain.generic.y = 220;
s_specifyserver.domain.field.widthInChars = 38;
s_specifyserver.domain.field.maxchars = 80;
s_specifyserver.port.generic.type = MTYPE_FIELD;
s_specifyserver.port.generic.name = "Port:";
s_specifyserver.port.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT|QMF_NUMBERSONLY;
s_specifyserver.port.generic.x = 206;
s_specifyserver.port.generic.y = 250;
s_specifyserver.port.field.widthInChars = 6;
s_specifyserver.port.field.maxchars = 5;
s_specifyserver.go.generic.type = MTYPE_BITMAP;
s_specifyserver.go.generic.name = SPECIFYSERVER_FIGHT0;
s_specifyserver.go.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
s_specifyserver.go.generic.callback = SpecifyServer_Event;
s_specifyserver.go.generic.id = ID_SPECIFYSERVERGO;
s_specifyserver.go.generic.x = 640;
s_specifyserver.go.generic.y = 480-64;
s_specifyserver.go.width = 128;
s_specifyserver.go.height = 64;
s_specifyserver.go.focuspic = SPECIFYSERVER_FIGHT1;
s_specifyserver.back.generic.type = MTYPE_BITMAP;
s_specifyserver.back.generic.name = SPECIFYSERVER_BACK0;
s_specifyserver.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_specifyserver.back.generic.callback = SpecifyServer_Event;
s_specifyserver.back.generic.id = ID_SPECIFYSERVERBACK;
s_specifyserver.back.generic.x = 0;
s_specifyserver.back.generic.y = 480-64;
s_specifyserver.back.width = 128;
s_specifyserver.back.height = 64;
s_specifyserver.back.focuspic = SPECIFYSERVER_BACK1;
Menu_AddItem( &s_specifyserver.menu, &s_specifyserver.banner );
Menu_AddItem( &s_specifyserver.menu, &s_specifyserver.framel );
Menu_AddItem( &s_specifyserver.menu, &s_specifyserver.framer );
Menu_AddItem( &s_specifyserver.menu, &s_specifyserver.domain );
Menu_AddItem( &s_specifyserver.menu, &s_specifyserver.port );
Menu_AddItem( &s_specifyserver.menu, &s_specifyserver.go );
Menu_AddItem( &s_specifyserver.menu, &s_specifyserver.back );
Com_sprintf( s_specifyserver.port.field.buffer, 6, "%i", 27960 );
}
/*
=================
SpecifyServer_Cache
=================
*/
void SpecifyServer_Cache( void )
{
int i;
// touch all our pics
for (i=0; ;i++)
{
if (!specifyserver_artlist[i])
break;
trap_R_RegisterShaderNoMip(specifyserver_artlist[i]);
}
}
/*
=================
UI_SpecifyServerMenu
=================
*/
void UI_SpecifyServerMenu( void )
{
SpecifyServer_MenuInit();
UI_PushMenu( &s_specifyserver.menu );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#include "ui_local.h"
/*********************************************************************************
SPECIFY SERVER
*********************************************************************************/
#define SPECIFYSERVER_FRAMEL "menu/art/frame2_l"
#define SPECIFYSERVER_FRAMER "menu/art/frame1_r"
#define SPECIFYSERVER_BACK0 "menu/art/back_0"
#define SPECIFYSERVER_BACK1 "menu/art/back_1"
#define SPECIFYSERVER_FIGHT0 "menu/art/fight_0"
#define SPECIFYSERVER_FIGHT1 "menu/art/fight_1"
#define ID_SPECIFYSERVERBACK 102
#define ID_SPECIFYSERVERGO 103
static char* specifyserver_artlist[] =
{
SPECIFYSERVER_FRAMEL,
SPECIFYSERVER_FRAMER,
SPECIFYSERVER_BACK0,
SPECIFYSERVER_BACK1,
SPECIFYSERVER_FIGHT0,
SPECIFYSERVER_FIGHT1,
NULL
};
typedef struct
{
menuframework_s menu;
menutext_s banner;
menubitmap_s framel;
menubitmap_s framer;
menufield_s domain;
menufield_s port;
menubitmap_s go;
menubitmap_s back;
} specifyserver_t;
static specifyserver_t s_specifyserver;
/*
=================
SpecifyServer_Event
=================
*/
static void SpecifyServer_Event( void* ptr, int event )
{
char buff[256];
switch (((menucommon_s*)ptr)->id)
{
case ID_SPECIFYSERVERGO:
if (event != QM_ACTIVATED)
break;
if (s_specifyserver.domain.field.buffer[0])
{
strcpy(buff,s_specifyserver.domain.field.buffer);
if (s_specifyserver.port.field.buffer[0])
Com_sprintf( buff+strlen(buff), 128, ":%s", s_specifyserver.port.field.buffer );
trap_Cmd_ExecuteText( EXEC_APPEND, va( "connect %s\n", buff ) );
}
break;
case ID_SPECIFYSERVERBACK:
if (event != QM_ACTIVATED)
break;
UI_PopMenu();
break;
}
}
/*
=================
SpecifyServer_MenuInit
=================
*/
void SpecifyServer_MenuInit( void )
{
// zero set all our globals
memset( &s_specifyserver, 0 ,sizeof(specifyserver_t) );
SpecifyServer_Cache();
s_specifyserver.menu.wrapAround = qtrue;
s_specifyserver.menu.fullscreen = qtrue;
s_specifyserver.banner.generic.type = MTYPE_BTEXT;
s_specifyserver.banner.generic.x = 320;
s_specifyserver.banner.generic.y = 16;
s_specifyserver.banner.string = "SPECIFY SERVER";
s_specifyserver.banner.color = color_white;
s_specifyserver.banner.style = UI_CENTER;
s_specifyserver.framel.generic.type = MTYPE_BITMAP;
s_specifyserver.framel.generic.name = SPECIFYSERVER_FRAMEL;
s_specifyserver.framel.generic.flags = QMF_INACTIVE;
s_specifyserver.framel.generic.x = 0;
s_specifyserver.framel.generic.y = 78;
s_specifyserver.framel.width = 256;
s_specifyserver.framel.height = 329;
s_specifyserver.framer.generic.type = MTYPE_BITMAP;
s_specifyserver.framer.generic.name = SPECIFYSERVER_FRAMER;
s_specifyserver.framer.generic.flags = QMF_INACTIVE;
s_specifyserver.framer.generic.x = 376;
s_specifyserver.framer.generic.y = 76;
s_specifyserver.framer.width = 256;
s_specifyserver.framer.height = 334;
s_specifyserver.domain.generic.type = MTYPE_FIELD;
s_specifyserver.domain.generic.name = "Address:";
s_specifyserver.domain.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_specifyserver.domain.generic.x = 206;
s_specifyserver.domain.generic.y = 220;
s_specifyserver.domain.field.widthInChars = 38;
s_specifyserver.domain.field.maxchars = 80;
s_specifyserver.port.generic.type = MTYPE_FIELD;
s_specifyserver.port.generic.name = "Port:";
s_specifyserver.port.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT|QMF_NUMBERSONLY;
s_specifyserver.port.generic.x = 206;
s_specifyserver.port.generic.y = 250;
s_specifyserver.port.field.widthInChars = 6;
s_specifyserver.port.field.maxchars = 5;
s_specifyserver.go.generic.type = MTYPE_BITMAP;
s_specifyserver.go.generic.name = SPECIFYSERVER_FIGHT0;
s_specifyserver.go.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
s_specifyserver.go.generic.callback = SpecifyServer_Event;
s_specifyserver.go.generic.id = ID_SPECIFYSERVERGO;
s_specifyserver.go.generic.x = 640;
s_specifyserver.go.generic.y = 480-64;
s_specifyserver.go.width = 128;
s_specifyserver.go.height = 64;
s_specifyserver.go.focuspic = SPECIFYSERVER_FIGHT1;
s_specifyserver.back.generic.type = MTYPE_BITMAP;
s_specifyserver.back.generic.name = SPECIFYSERVER_BACK0;
s_specifyserver.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_specifyserver.back.generic.callback = SpecifyServer_Event;
s_specifyserver.back.generic.id = ID_SPECIFYSERVERBACK;
s_specifyserver.back.generic.x = 0;
s_specifyserver.back.generic.y = 480-64;
s_specifyserver.back.width = 128;
s_specifyserver.back.height = 64;
s_specifyserver.back.focuspic = SPECIFYSERVER_BACK1;
Menu_AddItem( &s_specifyserver.menu, &s_specifyserver.banner );
Menu_AddItem( &s_specifyserver.menu, &s_specifyserver.framel );
Menu_AddItem( &s_specifyserver.menu, &s_specifyserver.framer );
Menu_AddItem( &s_specifyserver.menu, &s_specifyserver.domain );
Menu_AddItem( &s_specifyserver.menu, &s_specifyserver.port );
Menu_AddItem( &s_specifyserver.menu, &s_specifyserver.go );
Menu_AddItem( &s_specifyserver.menu, &s_specifyserver.back );
Com_sprintf( s_specifyserver.port.field.buffer, 6, "%i", 27960 );
}
/*
=================
SpecifyServer_Cache
=================
*/
void SpecifyServer_Cache( void )
{
int i;
// touch all our pics
for (i=0; ;i++)
{
if (!specifyserver_artlist[i])
break;
trap_R_RegisterShaderNoMip(specifyserver_artlist[i]);
}
}
/*
=================
UI_SpecifyServerMenu
=================
*/
void UI_SpecifyServerMenu( void )
{
SpecifyServer_MenuInit();
UI_PushMenu( &s_specifyserver.menu );
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,194 +1,194 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
/*
=======================================================================
RESET MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_FRAME "menu/art/cut_frame"
#define ID_NO 100
#define ID_YES 101
typedef struct
{
menuframework_s menu;
menutext_s no;
menutext_s yes;
int slashX;
} resetMenu_t;
static resetMenu_t s_reset;
/*
=================
Reset_MenuEvent
=================
*/
void Reset_MenuEvent(void* ptr, int event) {
if( event != QM_ACTIVATED ) {
return;
}
UI_PopMenu();
if( ((menucommon_s*)ptr)->id == ID_NO ) {
return;
}
// reset the game, pop the level menu and restart it so it updates
UI_NewGame();
trap_Cvar_SetValue( "ui_spSelection", 0 );
UI_PopMenu();
UI_SPLevelMenu();
}
/*
=================
Reset_MenuKey
=================
*/
static sfxHandle_t Reset_MenuKey( int key ) {
switch ( key ) {
case K_KP_LEFTARROW:
case K_LEFTARROW:
case K_KP_RIGHTARROW:
case K_RIGHTARROW:
key = K_TAB;
break;
case 'n':
case 'N':
Reset_MenuEvent( &s_reset.no, QM_ACTIVATED );
break;
case 'y':
case 'Y':
Reset_MenuEvent( &s_reset.yes, QM_ACTIVATED );
break;
}
return Menu_DefaultKey( &s_reset.menu, key );
}
/*
=================
Reset_MenuDraw
=================
*/
static void Reset_MenuDraw( void ) {
UI_DrawNamedPic( 142, 118, 359, 256, ART_FRAME );
UI_DrawProportionalString( 320, 194 + 10, "RESET GAME?", UI_CENTER|UI_INVERSE, color_red );
UI_DrawProportionalString( s_reset.slashX, 265, "/", UI_LEFT|UI_INVERSE, color_red );
Menu_Draw( &s_reset.menu );
UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 0, "WARNING: This resets all of the", UI_CENTER|UI_SMALLFONT, color_yellow );
UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 1, "single player game variables.", UI_CENTER|UI_SMALLFONT, color_yellow );
UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 2, "Do this only if you want to", UI_CENTER|UI_SMALLFONT, color_yellow );
UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 3, "start over from the beginning.", UI_CENTER|UI_SMALLFONT, color_yellow );
}
/*
=================
Reset_Cache
=================
*/
void Reset_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_FRAME );
}
/*
=================
UI_ResetMenu
=================
*/
void UI_ResetMenu(void) {
uiClientState_t cstate;
int n1, n2, n3;
int l1, l2, l3;
// zero set all our globals
memset( &s_reset, 0, sizeof(s_reset) );
Reset_Cache();
n1 = UI_ProportionalStringWidth( "YES/NO" );
n2 = UI_ProportionalStringWidth( "YES" ) + PROP_GAP_WIDTH;
n3 = UI_ProportionalStringWidth( "/" ) + PROP_GAP_WIDTH;
l1 = 320 - ( n1 / 2 );
l2 = l1 + n2;
l3 = l2 + n3;
s_reset.slashX = l2;
s_reset.menu.draw = Reset_MenuDraw;
s_reset.menu.key = Reset_MenuKey;
s_reset.menu.wrapAround = qtrue;
trap_GetClientState( &cstate );
if ( cstate.connState >= CA_CONNECTED ) {
// float on top of running game
s_reset.menu.fullscreen = qfalse;
}
else {
// game not running
s_reset.menu.fullscreen = qtrue;
}
s_reset.yes.generic.type = MTYPE_PTEXT;
s_reset.yes.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_reset.yes.generic.callback = Reset_MenuEvent;
s_reset.yes.generic.id = ID_YES;
s_reset.yes.generic.x = l1;
s_reset.yes.generic.y = 264;
s_reset.yes.string = "YES";
s_reset.yes.color = color_red;
s_reset.yes.style = UI_LEFT;
s_reset.no.generic.type = MTYPE_PTEXT;
s_reset.no.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_reset.no.generic.callback = Reset_MenuEvent;
s_reset.no.generic.id = ID_NO;
s_reset.no.generic.x = l3;
s_reset.no.generic.y = 264;
s_reset.no.string = "NO";
s_reset.no.color = color_red;
s_reset.no.style = UI_LEFT;
Menu_AddItem( &s_reset.menu, &s_reset.yes );
Menu_AddItem( &s_reset.menu, &s_reset.no );
UI_PushMenu( &s_reset.menu );
Menu_SetCursorToItem( &s_reset.menu, &s_reset.no );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
/*
=======================================================================
RESET MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_FRAME "menu/art/cut_frame"
#define ID_NO 100
#define ID_YES 101
typedef struct
{
menuframework_s menu;
menutext_s no;
menutext_s yes;
int slashX;
} resetMenu_t;
static resetMenu_t s_reset;
/*
=================
Reset_MenuEvent
=================
*/
void Reset_MenuEvent(void* ptr, int event) {
if( event != QM_ACTIVATED ) {
return;
}
UI_PopMenu();
if( ((menucommon_s*)ptr)->id == ID_NO ) {
return;
}
// reset the game, pop the level menu and restart it so it updates
UI_NewGame();
trap_Cvar_SetValue( "ui_spSelection", 0 );
UI_PopMenu();
UI_SPLevelMenu();
}
/*
=================
Reset_MenuKey
=================
*/
static sfxHandle_t Reset_MenuKey( int key ) {
switch ( key ) {
case K_KP_LEFTARROW:
case K_LEFTARROW:
case K_KP_RIGHTARROW:
case K_RIGHTARROW:
key = K_TAB;
break;
case 'n':
case 'N':
Reset_MenuEvent( &s_reset.no, QM_ACTIVATED );
break;
case 'y':
case 'Y':
Reset_MenuEvent( &s_reset.yes, QM_ACTIVATED );
break;
}
return Menu_DefaultKey( &s_reset.menu, key );
}
/*
=================
Reset_MenuDraw
=================
*/
static void Reset_MenuDraw( void ) {
UI_DrawNamedPic( 142, 118, 359, 256, ART_FRAME );
UI_DrawProportionalString( 320, 194 + 10, "RESET GAME?", UI_CENTER|UI_INVERSE, color_red );
UI_DrawProportionalString( s_reset.slashX, 265, "/", UI_LEFT|UI_INVERSE, color_red );
Menu_Draw( &s_reset.menu );
UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 0, "WARNING: This resets all of the", UI_CENTER|UI_SMALLFONT, color_yellow );
UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 1, "single player game variables.", UI_CENTER|UI_SMALLFONT, color_yellow );
UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 2, "Do this only if you want to", UI_CENTER|UI_SMALLFONT, color_yellow );
UI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 3, "start over from the beginning.", UI_CENTER|UI_SMALLFONT, color_yellow );
}
/*
=================
Reset_Cache
=================
*/
void Reset_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_FRAME );
}
/*
=================
UI_ResetMenu
=================
*/
void UI_ResetMenu(void) {
uiClientState_t cstate;
int n1, n2, n3;
int l1, l2, l3;
// zero set all our globals
memset( &s_reset, 0, sizeof(s_reset) );
Reset_Cache();
n1 = UI_ProportionalStringWidth( "YES/NO" );
n2 = UI_ProportionalStringWidth( "YES" ) + PROP_GAP_WIDTH;
n3 = UI_ProportionalStringWidth( "/" ) + PROP_GAP_WIDTH;
l1 = 320 - ( n1 / 2 );
l2 = l1 + n2;
l3 = l2 + n3;
s_reset.slashX = l2;
s_reset.menu.draw = Reset_MenuDraw;
s_reset.menu.key = Reset_MenuKey;
s_reset.menu.wrapAround = qtrue;
trap_GetClientState( &cstate );
if ( cstate.connState >= CA_CONNECTED ) {
// float on top of running game
s_reset.menu.fullscreen = qfalse;
}
else {
// game not running
s_reset.menu.fullscreen = qtrue;
}
s_reset.yes.generic.type = MTYPE_PTEXT;
s_reset.yes.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_reset.yes.generic.callback = Reset_MenuEvent;
s_reset.yes.generic.id = ID_YES;
s_reset.yes.generic.x = l1;
s_reset.yes.generic.y = 264;
s_reset.yes.string = "YES";
s_reset.yes.color = color_red;
s_reset.yes.style = UI_LEFT;
s_reset.no.generic.type = MTYPE_PTEXT;
s_reset.no.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
s_reset.no.generic.callback = Reset_MenuEvent;
s_reset.no.generic.id = ID_NO;
s_reset.no.generic.x = l3;
s_reset.no.generic.y = 264;
s_reset.no.string = "NO";
s_reset.no.color = color_red;
s_reset.no.style = UI_LEFT;
Menu_AddItem( &s_reset.menu, &s_reset.yes );
Menu_AddItem( &s_reset.menu, &s_reset.no );
UI_PushMenu( &s_reset.menu );
Menu_SetCursorToItem( &s_reset.menu, &s_reset.no );
}

View file

@ -1,329 +1,329 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=============================================================================
SINGLE PLAYER SKILL MENU
=============================================================================
*/
#include "ui_local.h"
#define ART_FRAME "menu/art/cut_frame"
#define ART_BACK "menu/art/back_0.tga"
#define ART_BACK_FOCUS "menu/art/back_1.tga"
#define ART_FIGHT "menu/art/fight_0"
#define ART_FIGHT_FOCUS "menu/art/fight_1"
#define ART_MAP_COMPLETE1 "menu/art/level_complete1"
#define ART_MAP_COMPLETE2 "menu/art/level_complete2"
#define ART_MAP_COMPLETE3 "menu/art/level_complete3"
#define ART_MAP_COMPLETE4 "menu/art/level_complete4"
#define ART_MAP_COMPLETE5 "menu/art/level_complete5"
#define ID_BABY 10
#define ID_EASY 11
#define ID_MEDIUM 12
#define ID_HARD 13
#define ID_NIGHTMARE 14
#define ID_BACK 15
#define ID_FIGHT 16
typedef struct {
menuframework_s menu;
menubitmap_s art_frame;
menutext_s art_banner;
menutext_s item_baby;
menutext_s item_easy;
menutext_s item_medium;
menutext_s item_hard;
menutext_s item_nightmare;
menubitmap_s art_skillPic;
menubitmap_s item_back;
menubitmap_s item_fight;
const char *arenaInfo;
qhandle_t skillpics[5];
sfxHandle_t nightmareSound;
sfxHandle_t silenceSound;
} skillMenuInfo_t;
static skillMenuInfo_t skillMenuInfo;
static void SetSkillColor( int skill, vec4_t color ) {
switch( skill ) {
case 1:
skillMenuInfo.item_baby.color = color;
break;
case 2:
skillMenuInfo.item_easy.color = color;
break;
case 3:
skillMenuInfo.item_medium.color = color;
break;
case 4:
skillMenuInfo.item_hard.color = color;
break;
case 5:
skillMenuInfo.item_nightmare.color = color;
break;
default:
break;
}
}
/*
=================
UI_SPSkillMenu_SkillEvent
=================
*/
static void UI_SPSkillMenu_SkillEvent( void *ptr, int notification ) {
int id;
int skill;
if (notification != QM_ACTIVATED)
return;
SetSkillColor( (int)trap_Cvar_VariableValue( "g_spSkill" ), color_red );
id = ((menucommon_s*)ptr)->id;
skill = id - ID_BABY + 1;
trap_Cvar_SetValue( "g_spSkill", skill );
SetSkillColor( skill, color_white );
skillMenuInfo.art_skillPic.shader = skillMenuInfo.skillpics[skill - 1];
if( id == ID_NIGHTMARE ) {
trap_S_StartLocalSound( skillMenuInfo.nightmareSound, CHAN_ANNOUNCER );
}
else {
trap_S_StartLocalSound( skillMenuInfo.silenceSound, CHAN_ANNOUNCER );
}
}
/*
=================
UI_SPSkillMenu_FightEvent
=================
*/
static void UI_SPSkillMenu_FightEvent( void *ptr, int notification ) {
if (notification != QM_ACTIVATED)
return;
UI_SPArena_Start( skillMenuInfo.arenaInfo );
}
/*
=================
UI_SPSkillMenu_BackEvent
=================
*/
static void UI_SPSkillMenu_BackEvent( void* ptr, int notification ) {
if (notification != QM_ACTIVATED) {
return;
}
trap_S_StartLocalSound( skillMenuInfo.silenceSound, CHAN_ANNOUNCER );
UI_PopMenu();
}
/*
=================
UI_SPSkillMenu_Key
=================
*/
static sfxHandle_t UI_SPSkillMenu_Key( int key ) {
if( key == K_MOUSE2 || key == K_ESCAPE ) {
trap_S_StartLocalSound( skillMenuInfo.silenceSound, CHAN_ANNOUNCER );
}
return Menu_DefaultKey( &skillMenuInfo.menu, key );
}
/*
=================
UI_SPSkillMenu_Cache
=================
*/
void UI_SPSkillMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_FRAME );
trap_R_RegisterShaderNoMip( ART_BACK );
trap_R_RegisterShaderNoMip( ART_BACK_FOCUS );
trap_R_RegisterShaderNoMip( ART_FIGHT );
trap_R_RegisterShaderNoMip( ART_FIGHT_FOCUS );
skillMenuInfo.skillpics[0] = trap_R_RegisterShaderNoMip( ART_MAP_COMPLETE1 );
skillMenuInfo.skillpics[1] = trap_R_RegisterShaderNoMip( ART_MAP_COMPLETE2 );
skillMenuInfo.skillpics[2] = trap_R_RegisterShaderNoMip( ART_MAP_COMPLETE3 );
skillMenuInfo.skillpics[3] = trap_R_RegisterShaderNoMip( ART_MAP_COMPLETE4 );
skillMenuInfo.skillpics[4] = trap_R_RegisterShaderNoMip( ART_MAP_COMPLETE5 );
skillMenuInfo.nightmareSound = trap_S_RegisterSound( "sound/misc/nightmare.wav", qfalse );
skillMenuInfo.silenceSound = trap_S_RegisterSound( "sound/misc/silence.wav", qfalse );
}
/*
=================
UI_SPSkillMenu_Init
=================
*/
static void UI_SPSkillMenu_Init( void ) {
int skill;
memset( &skillMenuInfo, 0, sizeof(skillMenuInfo) );
skillMenuInfo.menu.fullscreen = qtrue;
skillMenuInfo.menu.key = UI_SPSkillMenu_Key;
UI_SPSkillMenu_Cache();
skillMenuInfo.art_frame.generic.type = MTYPE_BITMAP;
skillMenuInfo.art_frame.generic.name = ART_FRAME;
skillMenuInfo.art_frame.generic.flags = QMF_LEFT_JUSTIFY|QMF_INACTIVE;
skillMenuInfo.art_frame.generic.x = 142;
skillMenuInfo.art_frame.generic.y = 118;
skillMenuInfo.art_frame.width = 359;
skillMenuInfo.art_frame.height = 256;
skillMenuInfo.art_banner.generic.type = MTYPE_BTEXT;
skillMenuInfo.art_banner.generic.flags = QMF_CENTER_JUSTIFY;
skillMenuInfo.art_banner.generic.x = 320;
skillMenuInfo.art_banner.generic.y = 16;
skillMenuInfo.art_banner.string = "DIFFICULTY";
skillMenuInfo.art_banner.color = color_white;
skillMenuInfo.art_banner.style = UI_CENTER;
skillMenuInfo.item_baby.generic.type = MTYPE_PTEXT;
skillMenuInfo.item_baby.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
skillMenuInfo.item_baby.generic.x = 320;
skillMenuInfo.item_baby.generic.y = 170;
skillMenuInfo.item_baby.generic.callback = UI_SPSkillMenu_SkillEvent;
skillMenuInfo.item_baby.generic.id = ID_BABY;
skillMenuInfo.item_baby.string = "I Can Win";
skillMenuInfo.item_baby.color = color_red;
skillMenuInfo.item_baby.style = UI_CENTER;
skillMenuInfo.item_easy.generic.type = MTYPE_PTEXT;
skillMenuInfo.item_easy.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
skillMenuInfo.item_easy.generic.x = 320;
skillMenuInfo.item_easy.generic.y = 198;
skillMenuInfo.item_easy.generic.callback = UI_SPSkillMenu_SkillEvent;
skillMenuInfo.item_easy.generic.id = ID_EASY;
skillMenuInfo.item_easy.string = "Bring It On";
skillMenuInfo.item_easy.color = color_red;
skillMenuInfo.item_easy.style = UI_CENTER;
skillMenuInfo.item_medium.generic.type = MTYPE_PTEXT;
skillMenuInfo.item_medium.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
skillMenuInfo.item_medium.generic.x = 320;
skillMenuInfo.item_medium.generic.y = 227;
skillMenuInfo.item_medium.generic.callback = UI_SPSkillMenu_SkillEvent;
skillMenuInfo.item_medium.generic.id = ID_MEDIUM;
skillMenuInfo.item_medium.string = "Hurt Me Plenty";
skillMenuInfo.item_medium.color = color_red;
skillMenuInfo.item_medium.style = UI_CENTER;
skillMenuInfo.item_hard.generic.type = MTYPE_PTEXT;
skillMenuInfo.item_hard.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
skillMenuInfo.item_hard.generic.x = 320;
skillMenuInfo.item_hard.generic.y = 255;
skillMenuInfo.item_hard.generic.callback = UI_SPSkillMenu_SkillEvent;
skillMenuInfo.item_hard.generic.id = ID_HARD;
skillMenuInfo.item_hard.string = "Hardcore";
skillMenuInfo.item_hard.color = color_red;
skillMenuInfo.item_hard.style = UI_CENTER;
skillMenuInfo.item_nightmare.generic.type = MTYPE_PTEXT;
skillMenuInfo.item_nightmare.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
skillMenuInfo.item_nightmare.generic.x = 320;
skillMenuInfo.item_nightmare.generic.y = 283;
skillMenuInfo.item_nightmare.generic.callback = UI_SPSkillMenu_SkillEvent;
skillMenuInfo.item_nightmare.generic.id = ID_NIGHTMARE;
skillMenuInfo.item_nightmare.string = "NIGHTMARE!";
skillMenuInfo.item_nightmare.color = color_red;
skillMenuInfo.item_nightmare.style = UI_CENTER;
skillMenuInfo.item_back.generic.type = MTYPE_BITMAP;
skillMenuInfo.item_back.generic.name = ART_BACK;
skillMenuInfo.item_back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
skillMenuInfo.item_back.generic.x = 0;
skillMenuInfo.item_back.generic.y = 480-64;
skillMenuInfo.item_back.generic.callback = UI_SPSkillMenu_BackEvent;
skillMenuInfo.item_back.generic.id = ID_BACK;
skillMenuInfo.item_back.width = 128;
skillMenuInfo.item_back.height = 64;
skillMenuInfo.item_back.focuspic = ART_BACK_FOCUS;
skillMenuInfo.art_skillPic.generic.type = MTYPE_BITMAP;
skillMenuInfo.art_skillPic.generic.flags = QMF_LEFT_JUSTIFY|QMF_INACTIVE;
skillMenuInfo.art_skillPic.generic.x = 320-64;
skillMenuInfo.art_skillPic.generic.y = 368;
skillMenuInfo.art_skillPic.width = 128;
skillMenuInfo.art_skillPic.height = 96;
skillMenuInfo.item_fight.generic.type = MTYPE_BITMAP;
skillMenuInfo.item_fight.generic.name = ART_FIGHT;
skillMenuInfo.item_fight.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
skillMenuInfo.item_fight.generic.callback = UI_SPSkillMenu_FightEvent;
skillMenuInfo.item_fight.generic.id = ID_FIGHT;
skillMenuInfo.item_fight.generic.x = 640;
skillMenuInfo.item_fight.generic.y = 480-64;
skillMenuInfo.item_fight.width = 128;
skillMenuInfo.item_fight.height = 64;
skillMenuInfo.item_fight.focuspic = ART_FIGHT_FOCUS;
Menu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.art_frame );
Menu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.art_banner );
Menu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_baby );
Menu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_easy );
Menu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_medium );
Menu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_hard );
Menu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_nightmare );
Menu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.art_skillPic );
Menu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_back );
Menu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_fight );
skill = (int)Com_Clamp( 1, 5, trap_Cvar_VariableValue( "g_spSkill" ) );
SetSkillColor( skill, color_white );
skillMenuInfo.art_skillPic.shader = skillMenuInfo.skillpics[skill - 1];
if( skill == 5 ) {
trap_S_StartLocalSound( skillMenuInfo.nightmareSound, CHAN_ANNOUNCER );
}
}
void UI_SPSkillMenu( const char *arenaInfo ) {
UI_SPSkillMenu_Init();
skillMenuInfo.arenaInfo = arenaInfo;
UI_PushMenu( &skillMenuInfo.menu );
Menu_SetCursorToItem( &skillMenuInfo.menu, &skillMenuInfo.item_fight );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=============================================================================
SINGLE PLAYER SKILL MENU
=============================================================================
*/
#include "ui_local.h"
#define ART_FRAME "menu/art/cut_frame"
#define ART_BACK "menu/art/back_0.tga"
#define ART_BACK_FOCUS "menu/art/back_1.tga"
#define ART_FIGHT "menu/art/fight_0"
#define ART_FIGHT_FOCUS "menu/art/fight_1"
#define ART_MAP_COMPLETE1 "menu/art/level_complete1"
#define ART_MAP_COMPLETE2 "menu/art/level_complete2"
#define ART_MAP_COMPLETE3 "menu/art/level_complete3"
#define ART_MAP_COMPLETE4 "menu/art/level_complete4"
#define ART_MAP_COMPLETE5 "menu/art/level_complete5"
#define ID_BABY 10
#define ID_EASY 11
#define ID_MEDIUM 12
#define ID_HARD 13
#define ID_NIGHTMARE 14
#define ID_BACK 15
#define ID_FIGHT 16
typedef struct {
menuframework_s menu;
menubitmap_s art_frame;
menutext_s art_banner;
menutext_s item_baby;
menutext_s item_easy;
menutext_s item_medium;
menutext_s item_hard;
menutext_s item_nightmare;
menubitmap_s art_skillPic;
menubitmap_s item_back;
menubitmap_s item_fight;
const char *arenaInfo;
qhandle_t skillpics[5];
sfxHandle_t nightmareSound;
sfxHandle_t silenceSound;
} skillMenuInfo_t;
static skillMenuInfo_t skillMenuInfo;
static void SetSkillColor( int skill, vec4_t color ) {
switch( skill ) {
case 1:
skillMenuInfo.item_baby.color = color;
break;
case 2:
skillMenuInfo.item_easy.color = color;
break;
case 3:
skillMenuInfo.item_medium.color = color;
break;
case 4:
skillMenuInfo.item_hard.color = color;
break;
case 5:
skillMenuInfo.item_nightmare.color = color;
break;
default:
break;
}
}
/*
=================
UI_SPSkillMenu_SkillEvent
=================
*/
static void UI_SPSkillMenu_SkillEvent( void *ptr, int notification ) {
int id;
int skill;
if (notification != QM_ACTIVATED)
return;
SetSkillColor( (int)trap_Cvar_VariableValue( "g_spSkill" ), color_red );
id = ((menucommon_s*)ptr)->id;
skill = id - ID_BABY + 1;
trap_Cvar_SetValue( "g_spSkill", skill );
SetSkillColor( skill, color_white );
skillMenuInfo.art_skillPic.shader = skillMenuInfo.skillpics[skill - 1];
if( id == ID_NIGHTMARE ) {
trap_S_StartLocalSound( skillMenuInfo.nightmareSound, CHAN_ANNOUNCER );
}
else {
trap_S_StartLocalSound( skillMenuInfo.silenceSound, CHAN_ANNOUNCER );
}
}
/*
=================
UI_SPSkillMenu_FightEvent
=================
*/
static void UI_SPSkillMenu_FightEvent( void *ptr, int notification ) {
if (notification != QM_ACTIVATED)
return;
UI_SPArena_Start( skillMenuInfo.arenaInfo );
}
/*
=================
UI_SPSkillMenu_BackEvent
=================
*/
static void UI_SPSkillMenu_BackEvent( void* ptr, int notification ) {
if (notification != QM_ACTIVATED) {
return;
}
trap_S_StartLocalSound( skillMenuInfo.silenceSound, CHAN_ANNOUNCER );
UI_PopMenu();
}
/*
=================
UI_SPSkillMenu_Key
=================
*/
static sfxHandle_t UI_SPSkillMenu_Key( int key ) {
if( key == K_MOUSE2 || key == K_ESCAPE ) {
trap_S_StartLocalSound( skillMenuInfo.silenceSound, CHAN_ANNOUNCER );
}
return Menu_DefaultKey( &skillMenuInfo.menu, key );
}
/*
=================
UI_SPSkillMenu_Cache
=================
*/
void UI_SPSkillMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_FRAME );
trap_R_RegisterShaderNoMip( ART_BACK );
trap_R_RegisterShaderNoMip( ART_BACK_FOCUS );
trap_R_RegisterShaderNoMip( ART_FIGHT );
trap_R_RegisterShaderNoMip( ART_FIGHT_FOCUS );
skillMenuInfo.skillpics[0] = trap_R_RegisterShaderNoMip( ART_MAP_COMPLETE1 );
skillMenuInfo.skillpics[1] = trap_R_RegisterShaderNoMip( ART_MAP_COMPLETE2 );
skillMenuInfo.skillpics[2] = trap_R_RegisterShaderNoMip( ART_MAP_COMPLETE3 );
skillMenuInfo.skillpics[3] = trap_R_RegisterShaderNoMip( ART_MAP_COMPLETE4 );
skillMenuInfo.skillpics[4] = trap_R_RegisterShaderNoMip( ART_MAP_COMPLETE5 );
skillMenuInfo.nightmareSound = trap_S_RegisterSound( "sound/misc/nightmare.wav", qfalse );
skillMenuInfo.silenceSound = trap_S_RegisterSound( "sound/misc/silence.wav", qfalse );
}
/*
=================
UI_SPSkillMenu_Init
=================
*/
static void UI_SPSkillMenu_Init( void ) {
int skill;
memset( &skillMenuInfo, 0, sizeof(skillMenuInfo) );
skillMenuInfo.menu.fullscreen = qtrue;
skillMenuInfo.menu.key = UI_SPSkillMenu_Key;
UI_SPSkillMenu_Cache();
skillMenuInfo.art_frame.generic.type = MTYPE_BITMAP;
skillMenuInfo.art_frame.generic.name = ART_FRAME;
skillMenuInfo.art_frame.generic.flags = QMF_LEFT_JUSTIFY|QMF_INACTIVE;
skillMenuInfo.art_frame.generic.x = 142;
skillMenuInfo.art_frame.generic.y = 118;
skillMenuInfo.art_frame.width = 359;
skillMenuInfo.art_frame.height = 256;
skillMenuInfo.art_banner.generic.type = MTYPE_BTEXT;
skillMenuInfo.art_banner.generic.flags = QMF_CENTER_JUSTIFY;
skillMenuInfo.art_banner.generic.x = 320;
skillMenuInfo.art_banner.generic.y = 16;
skillMenuInfo.art_banner.string = "DIFFICULTY";
skillMenuInfo.art_banner.color = color_white;
skillMenuInfo.art_banner.style = UI_CENTER;
skillMenuInfo.item_baby.generic.type = MTYPE_PTEXT;
skillMenuInfo.item_baby.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
skillMenuInfo.item_baby.generic.x = 320;
skillMenuInfo.item_baby.generic.y = 170;
skillMenuInfo.item_baby.generic.callback = UI_SPSkillMenu_SkillEvent;
skillMenuInfo.item_baby.generic.id = ID_BABY;
skillMenuInfo.item_baby.string = "I Can Win";
skillMenuInfo.item_baby.color = color_red;
skillMenuInfo.item_baby.style = UI_CENTER;
skillMenuInfo.item_easy.generic.type = MTYPE_PTEXT;
skillMenuInfo.item_easy.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
skillMenuInfo.item_easy.generic.x = 320;
skillMenuInfo.item_easy.generic.y = 198;
skillMenuInfo.item_easy.generic.callback = UI_SPSkillMenu_SkillEvent;
skillMenuInfo.item_easy.generic.id = ID_EASY;
skillMenuInfo.item_easy.string = "Bring It On";
skillMenuInfo.item_easy.color = color_red;
skillMenuInfo.item_easy.style = UI_CENTER;
skillMenuInfo.item_medium.generic.type = MTYPE_PTEXT;
skillMenuInfo.item_medium.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
skillMenuInfo.item_medium.generic.x = 320;
skillMenuInfo.item_medium.generic.y = 227;
skillMenuInfo.item_medium.generic.callback = UI_SPSkillMenu_SkillEvent;
skillMenuInfo.item_medium.generic.id = ID_MEDIUM;
skillMenuInfo.item_medium.string = "Hurt Me Plenty";
skillMenuInfo.item_medium.color = color_red;
skillMenuInfo.item_medium.style = UI_CENTER;
skillMenuInfo.item_hard.generic.type = MTYPE_PTEXT;
skillMenuInfo.item_hard.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
skillMenuInfo.item_hard.generic.x = 320;
skillMenuInfo.item_hard.generic.y = 255;
skillMenuInfo.item_hard.generic.callback = UI_SPSkillMenu_SkillEvent;
skillMenuInfo.item_hard.generic.id = ID_HARD;
skillMenuInfo.item_hard.string = "Hardcore";
skillMenuInfo.item_hard.color = color_red;
skillMenuInfo.item_hard.style = UI_CENTER;
skillMenuInfo.item_nightmare.generic.type = MTYPE_PTEXT;
skillMenuInfo.item_nightmare.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
skillMenuInfo.item_nightmare.generic.x = 320;
skillMenuInfo.item_nightmare.generic.y = 283;
skillMenuInfo.item_nightmare.generic.callback = UI_SPSkillMenu_SkillEvent;
skillMenuInfo.item_nightmare.generic.id = ID_NIGHTMARE;
skillMenuInfo.item_nightmare.string = "NIGHTMARE!";
skillMenuInfo.item_nightmare.color = color_red;
skillMenuInfo.item_nightmare.style = UI_CENTER;
skillMenuInfo.item_back.generic.type = MTYPE_BITMAP;
skillMenuInfo.item_back.generic.name = ART_BACK;
skillMenuInfo.item_back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
skillMenuInfo.item_back.generic.x = 0;
skillMenuInfo.item_back.generic.y = 480-64;
skillMenuInfo.item_back.generic.callback = UI_SPSkillMenu_BackEvent;
skillMenuInfo.item_back.generic.id = ID_BACK;
skillMenuInfo.item_back.width = 128;
skillMenuInfo.item_back.height = 64;
skillMenuInfo.item_back.focuspic = ART_BACK_FOCUS;
skillMenuInfo.art_skillPic.generic.type = MTYPE_BITMAP;
skillMenuInfo.art_skillPic.generic.flags = QMF_LEFT_JUSTIFY|QMF_INACTIVE;
skillMenuInfo.art_skillPic.generic.x = 320-64;
skillMenuInfo.art_skillPic.generic.y = 368;
skillMenuInfo.art_skillPic.width = 128;
skillMenuInfo.art_skillPic.height = 96;
skillMenuInfo.item_fight.generic.type = MTYPE_BITMAP;
skillMenuInfo.item_fight.generic.name = ART_FIGHT;
skillMenuInfo.item_fight.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
skillMenuInfo.item_fight.generic.callback = UI_SPSkillMenu_FightEvent;
skillMenuInfo.item_fight.generic.id = ID_FIGHT;
skillMenuInfo.item_fight.generic.x = 640;
skillMenuInfo.item_fight.generic.y = 480-64;
skillMenuInfo.item_fight.width = 128;
skillMenuInfo.item_fight.height = 64;
skillMenuInfo.item_fight.focuspic = ART_FIGHT_FOCUS;
Menu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.art_frame );
Menu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.art_banner );
Menu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_baby );
Menu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_easy );
Menu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_medium );
Menu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_hard );
Menu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_nightmare );
Menu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.art_skillPic );
Menu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_back );
Menu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_fight );
skill = (int)Com_Clamp( 1, 5, trap_Cvar_VariableValue( "g_spSkill" ) );
SetSkillColor( skill, color_white );
skillMenuInfo.art_skillPic.shader = skillMenuInfo.skillpics[skill - 1];
if( skill == 5 ) {
trap_S_StartLocalSound( skillMenuInfo.nightmareSound, CHAN_ANNOUNCER );
}
}
void UI_SPSkillMenu( const char *arenaInfo ) {
UI_SPSkillMenu_Init();
skillMenuInfo.arenaInfo = arenaInfo;
UI_PushMenu( &skillMenuInfo.menu );
Menu_SetCursorToItem( &skillMenuInfo.menu, &skillMenuInfo.item_fight );
}

File diff suppressed because it is too large Load diff

View file

@ -1,210 +1,210 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
//
// ui_team.c
//
#include "ui_local.h"
#define TEAMMAIN_FRAME "menu/art/cut_frame"
#define ID_JOINRED 100
#define ID_JOINBLUE 101
#define ID_JOINGAME 102
#define ID_SPECTATE 103
typedef struct
{
menuframework_s menu;
menubitmap_s frame;
menutext_s joinred;
menutext_s joinblue;
menutext_s joingame;
menutext_s spectate;
} teammain_t;
static teammain_t s_teammain;
// bk001204 - unused
//static menuframework_s s_teammain_menu;
//static menuaction_s s_teammain_orders;
//static menuaction_s s_teammain_voice;
//static menuaction_s s_teammain_joinred;
//static menuaction_s s_teammain_joinblue;
//static menuaction_s s_teammain_joingame;
//static menuaction_s s_teammain_spectate;
/*
===============
TeamMain_MenuEvent
===============
*/
static void TeamMain_MenuEvent( void* ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_JOINRED:
trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team red\n" );
UI_ForceMenuOff();
break;
case ID_JOINBLUE:
trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team blue\n" );
UI_ForceMenuOff();
break;
case ID_JOINGAME:
trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team free\n" );
UI_ForceMenuOff();
break;
case ID_SPECTATE:
trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team spectator\n" );
UI_ForceMenuOff();
break;
}
}
/*
===============
TeamMain_MenuInit
===============
*/
void TeamMain_MenuInit( void ) {
int y;
int gametype;
char info[MAX_INFO_STRING];
memset( &s_teammain, 0, sizeof(s_teammain) );
TeamMain_Cache();
s_teammain.menu.wrapAround = qtrue;
s_teammain.menu.fullscreen = qfalse;
s_teammain.frame.generic.type = MTYPE_BITMAP;
s_teammain.frame.generic.flags = QMF_INACTIVE;
s_teammain.frame.generic.name = TEAMMAIN_FRAME;
s_teammain.frame.generic.x = 142;
s_teammain.frame.generic.y = 118;
s_teammain.frame.width = 359;
s_teammain.frame.height = 256;
y = 194;
s_teammain.joinred.generic.type = MTYPE_PTEXT;
s_teammain.joinred.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_teammain.joinred.generic.id = ID_JOINRED;
s_teammain.joinred.generic.callback = TeamMain_MenuEvent;
s_teammain.joinred.generic.x = 320;
s_teammain.joinred.generic.y = y;
s_teammain.joinred.string = "JOIN RED";
s_teammain.joinred.style = UI_CENTER|UI_SMALLFONT;
s_teammain.joinred.color = colorRed;
y += 20;
s_teammain.joinblue.generic.type = MTYPE_PTEXT;
s_teammain.joinblue.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_teammain.joinblue.generic.id = ID_JOINBLUE;
s_teammain.joinblue.generic.callback = TeamMain_MenuEvent;
s_teammain.joinblue.generic.x = 320;
s_teammain.joinblue.generic.y = y;
s_teammain.joinblue.string = "JOIN BLUE";
s_teammain.joinblue.style = UI_CENTER|UI_SMALLFONT;
s_teammain.joinblue.color = colorRed;
y += 20;
s_teammain.joingame.generic.type = MTYPE_PTEXT;
s_teammain.joingame.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_teammain.joingame.generic.id = ID_JOINGAME;
s_teammain.joingame.generic.callback = TeamMain_MenuEvent;
s_teammain.joingame.generic.x = 320;
s_teammain.joingame.generic.y = y;
s_teammain.joingame.string = "JOIN GAME";
s_teammain.joingame.style = UI_CENTER|UI_SMALLFONT;
s_teammain.joingame.color = colorRed;
y += 20;
s_teammain.spectate.generic.type = MTYPE_PTEXT;
s_teammain.spectate.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_teammain.spectate.generic.id = ID_SPECTATE;
s_teammain.spectate.generic.callback = TeamMain_MenuEvent;
s_teammain.spectate.generic.x = 320;
s_teammain.spectate.generic.y = y;
s_teammain.spectate.string = "SPECTATE";
s_teammain.spectate.style = UI_CENTER|UI_SMALLFONT;
s_teammain.spectate.color = colorRed;
y += 20;
trap_GetConfigString(CS_SERVERINFO, info, MAX_INFO_STRING);
gametype = atoi( Info_ValueForKey( info,"g_gametype" ) );
// set initial states
switch( gametype ) {
case GT_SINGLE_PLAYER:
case GT_FFA:
case GT_TOURNAMENT:
s_teammain.joinred.generic.flags |= QMF_GRAYED;
s_teammain.joinblue.generic.flags |= QMF_GRAYED;
break;
default:
case GT_TEAM:
case GT_CTF:
s_teammain.joingame.generic.flags |= QMF_GRAYED;
break;
}
Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.frame );
Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.joinred );
Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.joinblue );
Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.joingame );
Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.spectate );
}
/*
===============
TeamMain_Cache
===============
*/
void TeamMain_Cache( void ) {
trap_R_RegisterShaderNoMip( TEAMMAIN_FRAME );
}
/*
===============
UI_TeamMainMenu
===============
*/
void UI_TeamMainMenu( void ) {
TeamMain_MenuInit();
UI_PushMenu ( &s_teammain.menu );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
//
// ui_team.c
//
#include "ui_local.h"
#define TEAMMAIN_FRAME "menu/art/cut_frame"
#define ID_JOINRED 100
#define ID_JOINBLUE 101
#define ID_JOINGAME 102
#define ID_SPECTATE 103
typedef struct
{
menuframework_s menu;
menubitmap_s frame;
menutext_s joinred;
menutext_s joinblue;
menutext_s joingame;
menutext_s spectate;
} teammain_t;
static teammain_t s_teammain;
// bk001204 - unused
//static menuframework_s s_teammain_menu;
//static menuaction_s s_teammain_orders;
//static menuaction_s s_teammain_voice;
//static menuaction_s s_teammain_joinred;
//static menuaction_s s_teammain_joinblue;
//static menuaction_s s_teammain_joingame;
//static menuaction_s s_teammain_spectate;
/*
===============
TeamMain_MenuEvent
===============
*/
static void TeamMain_MenuEvent( void* ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_JOINRED:
trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team red\n" );
UI_ForceMenuOff();
break;
case ID_JOINBLUE:
trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team blue\n" );
UI_ForceMenuOff();
break;
case ID_JOINGAME:
trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team free\n" );
UI_ForceMenuOff();
break;
case ID_SPECTATE:
trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team spectator\n" );
UI_ForceMenuOff();
break;
}
}
/*
===============
TeamMain_MenuInit
===============
*/
void TeamMain_MenuInit( void ) {
int y;
int gametype;
char info[MAX_INFO_STRING];
memset( &s_teammain, 0, sizeof(s_teammain) );
TeamMain_Cache();
s_teammain.menu.wrapAround = qtrue;
s_teammain.menu.fullscreen = qfalse;
s_teammain.frame.generic.type = MTYPE_BITMAP;
s_teammain.frame.generic.flags = QMF_INACTIVE;
s_teammain.frame.generic.name = TEAMMAIN_FRAME;
s_teammain.frame.generic.x = 142;
s_teammain.frame.generic.y = 118;
s_teammain.frame.width = 359;
s_teammain.frame.height = 256;
y = 194;
s_teammain.joinred.generic.type = MTYPE_PTEXT;
s_teammain.joinred.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_teammain.joinred.generic.id = ID_JOINRED;
s_teammain.joinred.generic.callback = TeamMain_MenuEvent;
s_teammain.joinred.generic.x = 320;
s_teammain.joinred.generic.y = y;
s_teammain.joinred.string = "JOIN RED";
s_teammain.joinred.style = UI_CENTER|UI_SMALLFONT;
s_teammain.joinred.color = colorRed;
y += 20;
s_teammain.joinblue.generic.type = MTYPE_PTEXT;
s_teammain.joinblue.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_teammain.joinblue.generic.id = ID_JOINBLUE;
s_teammain.joinblue.generic.callback = TeamMain_MenuEvent;
s_teammain.joinblue.generic.x = 320;
s_teammain.joinblue.generic.y = y;
s_teammain.joinblue.string = "JOIN BLUE";
s_teammain.joinblue.style = UI_CENTER|UI_SMALLFONT;
s_teammain.joinblue.color = colorRed;
y += 20;
s_teammain.joingame.generic.type = MTYPE_PTEXT;
s_teammain.joingame.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_teammain.joingame.generic.id = ID_JOINGAME;
s_teammain.joingame.generic.callback = TeamMain_MenuEvent;
s_teammain.joingame.generic.x = 320;
s_teammain.joingame.generic.y = y;
s_teammain.joingame.string = "JOIN GAME";
s_teammain.joingame.style = UI_CENTER|UI_SMALLFONT;
s_teammain.joingame.color = colorRed;
y += 20;
s_teammain.spectate.generic.type = MTYPE_PTEXT;
s_teammain.spectate.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
s_teammain.spectate.generic.id = ID_SPECTATE;
s_teammain.spectate.generic.callback = TeamMain_MenuEvent;
s_teammain.spectate.generic.x = 320;
s_teammain.spectate.generic.y = y;
s_teammain.spectate.string = "SPECTATE";
s_teammain.spectate.style = UI_CENTER|UI_SMALLFONT;
s_teammain.spectate.color = colorRed;
y += 20;
trap_GetConfigString(CS_SERVERINFO, info, MAX_INFO_STRING);
gametype = atoi( Info_ValueForKey( info,"g_gametype" ) );
// set initial states
switch( gametype ) {
case GT_SINGLE_PLAYER:
case GT_FFA:
case GT_TOURNAMENT:
s_teammain.joinred.generic.flags |= QMF_GRAYED;
s_teammain.joinblue.generic.flags |= QMF_GRAYED;
break;
default:
case GT_TEAM:
case GT_CTF:
s_teammain.joingame.generic.flags |= QMF_GRAYED;
break;
}
Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.frame );
Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.joinred );
Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.joinblue );
Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.joingame );
Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.spectate );
}
/*
===============
TeamMain_Cache
===============
*/
void TeamMain_Cache( void ) {
trap_R_RegisterShaderNoMip( TEAMMAIN_FRAME );
}
/*
===============
UI_TeamMainMenu
===============
*/
void UI_TeamMainMenu( void ) {
TeamMain_MenuInit();
UI_PushMenu ( &s_teammain.menu );
}

View file

@ -1,449 +1,449 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
TEAM ORDERS MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_FRAME "menu/art/addbotframe"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ID_LIST_BOTS 10
#define ID_LIST_CTF_ORDERS 11
#define ID_LIST_TEAM_ORDERS 12
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s frame;
menulist_s list;
menubitmap_s back;
int gametype;
int numBots;
int selectedBot;
char *bots[9];
char botNames[9][16];
} teamOrdersMenuInfo_t;
static teamOrdersMenuInfo_t teamOrdersMenuInfo;
#define NUM_CTF_ORDERS 7
static const char *ctfOrders[] = {
"I Am the Leader",
"Defend the Base",
"Follow Me",
"Get Enemy Flag",
"Camp Here",
"Report",
"I Relinquish Command",
NULL
};
static const char *ctfMessages[] = {
"i am the leader",
"%s defend the base",
"%s follow me",
"%s get enemy flag",
"%s camp here",
"%s report",
"i stop being the leader",
NULL
};
#define NUM_TEAM_ORDERS 6
static const char *teamOrders[] = {
"I Am the Leader",
"Follow Me",
"Roam",
"Camp Here",
"Report",
"I Relinquish Command",
NULL
};
static const char *teamMessages[] = {
"i am the leader",
"%s follow me",
"%s roam",
"%s camp here",
"%s report",
"i stop being the leader",
NULL
};
/*
===============
UI_TeamOrdersMenu_BackEvent
===============
*/
static void UI_TeamOrdersMenu_BackEvent( void *ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
UI_PopMenu();
}
/*
===============
UI_TeamOrdersMenu_SetList
===============
*/
static void UI_TeamOrdersMenu_SetList( int id ) {
switch( id ) {
default:
case ID_LIST_BOTS:
teamOrdersMenuInfo.list.generic.id = id;
teamOrdersMenuInfo.list.numitems = teamOrdersMenuInfo.numBots;
teamOrdersMenuInfo.list.itemnames = (const char **)teamOrdersMenuInfo.bots;
break;
case ID_LIST_CTF_ORDERS:
teamOrdersMenuInfo.list.generic.id = id;
teamOrdersMenuInfo.list.numitems = NUM_CTF_ORDERS;
teamOrdersMenuInfo.list.itemnames = ctfOrders;
break;
case ID_LIST_TEAM_ORDERS:
teamOrdersMenuInfo.list.generic.id = id;
teamOrdersMenuInfo.list.numitems = NUM_TEAM_ORDERS;
teamOrdersMenuInfo.list.itemnames = teamOrders;
break;
}
teamOrdersMenuInfo.list.generic.bottom = teamOrdersMenuInfo.list.generic.top + teamOrdersMenuInfo.list.numitems * PROP_HEIGHT;
}
/*
=================
UI_TeamOrdersMenu_Key
=================
*/
sfxHandle_t UI_TeamOrdersMenu_Key( int key ) {
menulist_s *l;
int x;
int y;
int index;
l = (menulist_s *)Menu_ItemAtCursor( &teamOrdersMenuInfo.menu );
if( l != &teamOrdersMenuInfo.list ) {
return Menu_DefaultKey( &teamOrdersMenuInfo.menu, key );
}
switch( key ) {
case K_MOUSE1:
x = l->generic.left;
y = l->generic.top;
if( UI_CursorInRect( x, y, l->generic.right - x, l->generic.bottom - y ) ) {
index = (uis.cursory - y) / PROP_HEIGHT;
l->oldvalue = l->curvalue;
l->curvalue = index;
if( l->generic.callback ) {
l->generic.callback( l, QM_ACTIVATED );
return menu_move_sound;
}
}
return menu_null_sound;
case K_KP_UPARROW:
case K_UPARROW:
l->oldvalue = l->curvalue;
if( l->curvalue == 0 ) {
l->curvalue = l->numitems - 1;
}
else {
l->curvalue--;
}
return menu_move_sound;
case K_KP_DOWNARROW:
case K_DOWNARROW:
l->oldvalue = l->curvalue;
if( l->curvalue == l->numitems - 1 ) {
l->curvalue = 0;;
}
else {
l->curvalue++;
}
return menu_move_sound;
}
return Menu_DefaultKey( &teamOrdersMenuInfo.menu, key );
}
/*
=================
UI_TeamOrdersMenu_ListDraw
=================
*/
static void UI_TeamOrdersMenu_ListDraw( void *self ) {
menulist_s *l;
int x;
int y;
int i;
float *color;
qboolean hasfocus;
int style;
l = (menulist_s *)self;
hasfocus = (l->generic.parent->cursor == l->generic.menuPosition);
x = 320;//l->generic.x;
y = l->generic.y;
for( i = 0; i < l->numitems; i++ ) {
style = UI_LEFT|UI_SMALLFONT|UI_CENTER;
if( i == l->curvalue ) {
color = color_yellow;
if( hasfocus ) {
style |= UI_PULSE;
}
}
else {
color = color_orange;
}
UI_DrawProportionalString( x, y, l->itemnames[i], style, color );
y += PROP_HEIGHT;
}
}
/*
===============
UI_TeamOrdersMenu_ListEvent
===============
*/
static void UI_TeamOrdersMenu_ListEvent( void *ptr, int event ) {
int id;
int selection;
char message[256];
if (event != QM_ACTIVATED)
return;
id = ((menulist_s *)ptr)->generic.id;
selection = ((menulist_s *)ptr)->curvalue;
if( id == ID_LIST_BOTS ) {
teamOrdersMenuInfo.selectedBot = selection;
if( teamOrdersMenuInfo.gametype == GT_CTF ) {
UI_TeamOrdersMenu_SetList( ID_LIST_CTF_ORDERS );
}
else {
UI_TeamOrdersMenu_SetList( ID_LIST_TEAM_ORDERS );
}
return;
}
if( id == ID_LIST_CTF_ORDERS ) {
Com_sprintf( message, sizeof(message), ctfMessages[selection], teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.selectedBot] );
}
else {
Com_sprintf( message, sizeof(message), teamMessages[selection], teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.selectedBot] );
}
trap_Cmd_ExecuteText( EXEC_APPEND, va( "say_team \"%s\"\n", message ) );
UI_PopMenu();
}
/*
===============
UI_TeamOrdersMenu_BuildBotList
===============
*/
static void UI_TeamOrdersMenu_BuildBotList( void ) {
uiClientState_t cs;
int numPlayers;
int isBot;
int n;
char playerTeam;
char botTeam;
char info[MAX_INFO_STRING];
for( n = 0; n < 9; n++ ) {
teamOrdersMenuInfo.bots[n] = teamOrdersMenuInfo.botNames[n];
}
trap_GetClientState( &cs );
Q_strncpyz( teamOrdersMenuInfo.botNames[0], "Everyone", 16 );
teamOrdersMenuInfo.numBots = 1;
trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) );
numPlayers = atoi( Info_ValueForKey( info, "sv_maxclients" ) );
teamOrdersMenuInfo.gametype = atoi( Info_ValueForKey( info, "g_gametype" ) );
for( n = 0; n < numPlayers && teamOrdersMenuInfo.numBots < 9; n++ ) {
trap_GetConfigString( CS_PLAYERS + n, info, MAX_INFO_STRING );
playerTeam = TEAM_SPECTATOR; // bk001204 = possible uninit use
if( n == cs.clientNum ) {
playerTeam = *Info_ValueForKey( info, "t" );
continue;
}
isBot = atoi( Info_ValueForKey( info, "skill" ) );
if( !isBot ) {
continue;
}
botTeam = *Info_ValueForKey( info, "t" );
if( botTeam != playerTeam ) {
continue;
}
Q_strncpyz( teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.numBots], Info_ValueForKey( info, "n" ), 16 );
Q_CleanStr( teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.numBots] );
teamOrdersMenuInfo.numBots++;
}
}
/*
===============
UI_TeamOrdersMenu_Init
===============
*/
static void UI_TeamOrdersMenu_Init( void ) {
UI_TeamOrdersMenu_Cache();
memset( &teamOrdersMenuInfo, 0, sizeof(teamOrdersMenuInfo) );
teamOrdersMenuInfo.menu.fullscreen = qfalse;
teamOrdersMenuInfo.menu.key = UI_TeamOrdersMenu_Key;
UI_TeamOrdersMenu_BuildBotList();
teamOrdersMenuInfo.banner.generic.type = MTYPE_BTEXT;
teamOrdersMenuInfo.banner.generic.x = 320;
teamOrdersMenuInfo.banner.generic.y = 16;
teamOrdersMenuInfo.banner.string = "TEAM ORDERS";
teamOrdersMenuInfo.banner.color = color_white;
teamOrdersMenuInfo.banner.style = UI_CENTER;
teamOrdersMenuInfo.frame.generic.type = MTYPE_BITMAP;
teamOrdersMenuInfo.frame.generic.flags = QMF_INACTIVE;
teamOrdersMenuInfo.frame.generic.name = ART_FRAME;
teamOrdersMenuInfo.frame.generic.x = 320-233;
teamOrdersMenuInfo.frame.generic.y = 240-166;
teamOrdersMenuInfo.frame.width = 466;
teamOrdersMenuInfo.frame.height = 332;
teamOrdersMenuInfo.list.generic.type = MTYPE_SCROLLLIST;
teamOrdersMenuInfo.list.generic.flags = QMF_PULSEIFFOCUS;
teamOrdersMenuInfo.list.generic.ownerdraw = UI_TeamOrdersMenu_ListDraw;
teamOrdersMenuInfo.list.generic.callback = UI_TeamOrdersMenu_ListEvent;
teamOrdersMenuInfo.list.generic.x = 320-64;
teamOrdersMenuInfo.list.generic.y = 120;
teamOrdersMenuInfo.back.generic.type = MTYPE_BITMAP;
teamOrdersMenuInfo.back.generic.name = ART_BACK0;
teamOrdersMenuInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
teamOrdersMenuInfo.back.generic.callback = UI_TeamOrdersMenu_BackEvent;
teamOrdersMenuInfo.back.generic.x = 0;
teamOrdersMenuInfo.back.generic.y = 480-64;
teamOrdersMenuInfo.back.width = 128;
teamOrdersMenuInfo.back.height = 64;
teamOrdersMenuInfo.back.focuspic = ART_BACK1;
Menu_AddItem( &teamOrdersMenuInfo.menu, &teamOrdersMenuInfo.banner );
Menu_AddItem( &teamOrdersMenuInfo.menu, &teamOrdersMenuInfo.frame );
Menu_AddItem( &teamOrdersMenuInfo.menu, &teamOrdersMenuInfo.list );
Menu_AddItem( &teamOrdersMenuInfo.menu, &teamOrdersMenuInfo.back );
teamOrdersMenuInfo.list.generic.left = 220;
teamOrdersMenuInfo.list.generic.top = teamOrdersMenuInfo.list.generic.y;
teamOrdersMenuInfo.list.generic.right = 420;
UI_TeamOrdersMenu_SetList( ID_LIST_BOTS );
}
/*
=================
UI_TeamOrdersMenu_Cache
=================
*/
void UI_TeamOrdersMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_FRAME );
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
}
/*
===============
UI_TeamOrdersMenu
===============
*/
void UI_TeamOrdersMenu( void ) {
UI_TeamOrdersMenu_Init();
UI_PushMenu( &teamOrdersMenuInfo.menu );
}
/*
===============
UI_TeamOrdersMenu_f
===============
*/
void UI_TeamOrdersMenu_f( void ) {
uiClientState_t cs;
char info[MAX_INFO_STRING];
int team;
// make sure it's a team game
trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) );
teamOrdersMenuInfo.gametype = atoi( Info_ValueForKey( info, "g_gametype" ) );
if( teamOrdersMenuInfo.gametype < GT_TEAM ) {
return;
}
// not available to spectators
trap_GetClientState( &cs );
trap_GetConfigString( CS_PLAYERS + cs.clientNum, info, MAX_INFO_STRING );
team = atoi( Info_ValueForKey( info, "t" ) );
if( team == TEAM_SPECTATOR ) {
return;
}
UI_TeamOrdersMenu();
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
TEAM ORDERS MENU
=======================================================================
*/
#include "ui_local.h"
#define ART_FRAME "menu/art/addbotframe"
#define ART_BACK0 "menu/art/back_0"
#define ART_BACK1 "menu/art/back_1"
#define ID_LIST_BOTS 10
#define ID_LIST_CTF_ORDERS 11
#define ID_LIST_TEAM_ORDERS 12
typedef struct {
menuframework_s menu;
menutext_s banner;
menubitmap_s frame;
menulist_s list;
menubitmap_s back;
int gametype;
int numBots;
int selectedBot;
char *bots[9];
char botNames[9][16];
} teamOrdersMenuInfo_t;
static teamOrdersMenuInfo_t teamOrdersMenuInfo;
#define NUM_CTF_ORDERS 7
static const char *ctfOrders[] = {
"I Am the Leader",
"Defend the Base",
"Follow Me",
"Get Enemy Flag",
"Camp Here",
"Report",
"I Relinquish Command",
NULL
};
static const char *ctfMessages[] = {
"i am the leader",
"%s defend the base",
"%s follow me",
"%s get enemy flag",
"%s camp here",
"%s report",
"i stop being the leader",
NULL
};
#define NUM_TEAM_ORDERS 6
static const char *teamOrders[] = {
"I Am the Leader",
"Follow Me",
"Roam",
"Camp Here",
"Report",
"I Relinquish Command",
NULL
};
static const char *teamMessages[] = {
"i am the leader",
"%s follow me",
"%s roam",
"%s camp here",
"%s report",
"i stop being the leader",
NULL
};
/*
===============
UI_TeamOrdersMenu_BackEvent
===============
*/
static void UI_TeamOrdersMenu_BackEvent( void *ptr, int event ) {
if( event != QM_ACTIVATED ) {
return;
}
UI_PopMenu();
}
/*
===============
UI_TeamOrdersMenu_SetList
===============
*/
static void UI_TeamOrdersMenu_SetList( int id ) {
switch( id ) {
default:
case ID_LIST_BOTS:
teamOrdersMenuInfo.list.generic.id = id;
teamOrdersMenuInfo.list.numitems = teamOrdersMenuInfo.numBots;
teamOrdersMenuInfo.list.itemnames = (const char **)teamOrdersMenuInfo.bots;
break;
case ID_LIST_CTF_ORDERS:
teamOrdersMenuInfo.list.generic.id = id;
teamOrdersMenuInfo.list.numitems = NUM_CTF_ORDERS;
teamOrdersMenuInfo.list.itemnames = ctfOrders;
break;
case ID_LIST_TEAM_ORDERS:
teamOrdersMenuInfo.list.generic.id = id;
teamOrdersMenuInfo.list.numitems = NUM_TEAM_ORDERS;
teamOrdersMenuInfo.list.itemnames = teamOrders;
break;
}
teamOrdersMenuInfo.list.generic.bottom = teamOrdersMenuInfo.list.generic.top + teamOrdersMenuInfo.list.numitems * PROP_HEIGHT;
}
/*
=================
UI_TeamOrdersMenu_Key
=================
*/
sfxHandle_t UI_TeamOrdersMenu_Key( int key ) {
menulist_s *l;
int x;
int y;
int index;
l = (menulist_s *)Menu_ItemAtCursor( &teamOrdersMenuInfo.menu );
if( l != &teamOrdersMenuInfo.list ) {
return Menu_DefaultKey( &teamOrdersMenuInfo.menu, key );
}
switch( key ) {
case K_MOUSE1:
x = l->generic.left;
y = l->generic.top;
if( UI_CursorInRect( x, y, l->generic.right - x, l->generic.bottom - y ) ) {
index = (uis.cursory - y) / PROP_HEIGHT;
l->oldvalue = l->curvalue;
l->curvalue = index;
if( l->generic.callback ) {
l->generic.callback( l, QM_ACTIVATED );
return menu_move_sound;
}
}
return menu_null_sound;
case K_KP_UPARROW:
case K_UPARROW:
l->oldvalue = l->curvalue;
if( l->curvalue == 0 ) {
l->curvalue = l->numitems - 1;
}
else {
l->curvalue--;
}
return menu_move_sound;
case K_KP_DOWNARROW:
case K_DOWNARROW:
l->oldvalue = l->curvalue;
if( l->curvalue == l->numitems - 1 ) {
l->curvalue = 0;;
}
else {
l->curvalue++;
}
return menu_move_sound;
}
return Menu_DefaultKey( &teamOrdersMenuInfo.menu, key );
}
/*
=================
UI_TeamOrdersMenu_ListDraw
=================
*/
static void UI_TeamOrdersMenu_ListDraw( void *self ) {
menulist_s *l;
int x;
int y;
int i;
float *color;
qboolean hasfocus;
int style;
l = (menulist_s *)self;
hasfocus = (l->generic.parent->cursor == l->generic.menuPosition);
x = 320;//l->generic.x;
y = l->generic.y;
for( i = 0; i < l->numitems; i++ ) {
style = UI_LEFT|UI_SMALLFONT|UI_CENTER;
if( i == l->curvalue ) {
color = color_yellow;
if( hasfocus ) {
style |= UI_PULSE;
}
}
else {
color = color_orange;
}
UI_DrawProportionalString( x, y, l->itemnames[i], style, color );
y += PROP_HEIGHT;
}
}
/*
===============
UI_TeamOrdersMenu_ListEvent
===============
*/
static void UI_TeamOrdersMenu_ListEvent( void *ptr, int event ) {
int id;
int selection;
char message[256];
if (event != QM_ACTIVATED)
return;
id = ((menulist_s *)ptr)->generic.id;
selection = ((menulist_s *)ptr)->curvalue;
if( id == ID_LIST_BOTS ) {
teamOrdersMenuInfo.selectedBot = selection;
if( teamOrdersMenuInfo.gametype == GT_CTF ) {
UI_TeamOrdersMenu_SetList( ID_LIST_CTF_ORDERS );
}
else {
UI_TeamOrdersMenu_SetList( ID_LIST_TEAM_ORDERS );
}
return;
}
if( id == ID_LIST_CTF_ORDERS ) {
Com_sprintf( message, sizeof(message), ctfMessages[selection], teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.selectedBot] );
}
else {
Com_sprintf( message, sizeof(message), teamMessages[selection], teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.selectedBot] );
}
trap_Cmd_ExecuteText( EXEC_APPEND, va( "say_team \"%s\"\n", message ) );
UI_PopMenu();
}
/*
===============
UI_TeamOrdersMenu_BuildBotList
===============
*/
static void UI_TeamOrdersMenu_BuildBotList( void ) {
uiClientState_t cs;
int numPlayers;
int isBot;
int n;
char playerTeam;
char botTeam;
char info[MAX_INFO_STRING];
for( n = 0; n < 9; n++ ) {
teamOrdersMenuInfo.bots[n] = teamOrdersMenuInfo.botNames[n];
}
trap_GetClientState( &cs );
Q_strncpyz( teamOrdersMenuInfo.botNames[0], "Everyone", 16 );
teamOrdersMenuInfo.numBots = 1;
trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) );
numPlayers = atoi( Info_ValueForKey( info, "sv_maxclients" ) );
teamOrdersMenuInfo.gametype = atoi( Info_ValueForKey( info, "g_gametype" ) );
for( n = 0; n < numPlayers && teamOrdersMenuInfo.numBots < 9; n++ ) {
trap_GetConfigString( CS_PLAYERS + n, info, MAX_INFO_STRING );
playerTeam = TEAM_SPECTATOR; // bk001204 = possible uninit use
if( n == cs.clientNum ) {
playerTeam = *Info_ValueForKey( info, "t" );
continue;
}
isBot = atoi( Info_ValueForKey( info, "skill" ) );
if( !isBot ) {
continue;
}
botTeam = *Info_ValueForKey( info, "t" );
if( botTeam != playerTeam ) {
continue;
}
Q_strncpyz( teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.numBots], Info_ValueForKey( info, "n" ), 16 );
Q_CleanStr( teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.numBots] );
teamOrdersMenuInfo.numBots++;
}
}
/*
===============
UI_TeamOrdersMenu_Init
===============
*/
static void UI_TeamOrdersMenu_Init( void ) {
UI_TeamOrdersMenu_Cache();
memset( &teamOrdersMenuInfo, 0, sizeof(teamOrdersMenuInfo) );
teamOrdersMenuInfo.menu.fullscreen = qfalse;
teamOrdersMenuInfo.menu.key = UI_TeamOrdersMenu_Key;
UI_TeamOrdersMenu_BuildBotList();
teamOrdersMenuInfo.banner.generic.type = MTYPE_BTEXT;
teamOrdersMenuInfo.banner.generic.x = 320;
teamOrdersMenuInfo.banner.generic.y = 16;
teamOrdersMenuInfo.banner.string = "TEAM ORDERS";
teamOrdersMenuInfo.banner.color = color_white;
teamOrdersMenuInfo.banner.style = UI_CENTER;
teamOrdersMenuInfo.frame.generic.type = MTYPE_BITMAP;
teamOrdersMenuInfo.frame.generic.flags = QMF_INACTIVE;
teamOrdersMenuInfo.frame.generic.name = ART_FRAME;
teamOrdersMenuInfo.frame.generic.x = 320-233;
teamOrdersMenuInfo.frame.generic.y = 240-166;
teamOrdersMenuInfo.frame.width = 466;
teamOrdersMenuInfo.frame.height = 332;
teamOrdersMenuInfo.list.generic.type = MTYPE_SCROLLLIST;
teamOrdersMenuInfo.list.generic.flags = QMF_PULSEIFFOCUS;
teamOrdersMenuInfo.list.generic.ownerdraw = UI_TeamOrdersMenu_ListDraw;
teamOrdersMenuInfo.list.generic.callback = UI_TeamOrdersMenu_ListEvent;
teamOrdersMenuInfo.list.generic.x = 320-64;
teamOrdersMenuInfo.list.generic.y = 120;
teamOrdersMenuInfo.back.generic.type = MTYPE_BITMAP;
teamOrdersMenuInfo.back.generic.name = ART_BACK0;
teamOrdersMenuInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
teamOrdersMenuInfo.back.generic.callback = UI_TeamOrdersMenu_BackEvent;
teamOrdersMenuInfo.back.generic.x = 0;
teamOrdersMenuInfo.back.generic.y = 480-64;
teamOrdersMenuInfo.back.width = 128;
teamOrdersMenuInfo.back.height = 64;
teamOrdersMenuInfo.back.focuspic = ART_BACK1;
Menu_AddItem( &teamOrdersMenuInfo.menu, &teamOrdersMenuInfo.banner );
Menu_AddItem( &teamOrdersMenuInfo.menu, &teamOrdersMenuInfo.frame );
Menu_AddItem( &teamOrdersMenuInfo.menu, &teamOrdersMenuInfo.list );
Menu_AddItem( &teamOrdersMenuInfo.menu, &teamOrdersMenuInfo.back );
teamOrdersMenuInfo.list.generic.left = 220;
teamOrdersMenuInfo.list.generic.top = teamOrdersMenuInfo.list.generic.y;
teamOrdersMenuInfo.list.generic.right = 420;
UI_TeamOrdersMenu_SetList( ID_LIST_BOTS );
}
/*
=================
UI_TeamOrdersMenu_Cache
=================
*/
void UI_TeamOrdersMenu_Cache( void ) {
trap_R_RegisterShaderNoMip( ART_FRAME );
trap_R_RegisterShaderNoMip( ART_BACK0 );
trap_R_RegisterShaderNoMip( ART_BACK1 );
}
/*
===============
UI_TeamOrdersMenu
===============
*/
void UI_TeamOrdersMenu( void ) {
UI_TeamOrdersMenu_Init();
UI_PushMenu( &teamOrdersMenuInfo.menu );
}
/*
===============
UI_TeamOrdersMenu_f
===============
*/
void UI_TeamOrdersMenu_f( void ) {
uiClientState_t cs;
char info[MAX_INFO_STRING];
int team;
// make sure it's a team game
trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) );
teamOrdersMenuInfo.gametype = atoi( Info_ValueForKey( info, "g_gametype" ) );
if( teamOrdersMenuInfo.gametype < GT_TEAM ) {
return;
}
// not available to spectators
trap_GetClientState( &cs );
trap_GetConfigString( CS_PLAYERS + cs.clientNum, info, MAX_INFO_STRING );
team = atoi( Info_ValueForKey( info, "t" ) );
if( team == TEAM_SPECTATOR ) {
return;
}
UI_TeamOrdersMenu();
}

File diff suppressed because it is too large Load diff