//Battlemode Menu
//Built By Bill --Incinerator-- Kosche
//Date : 10-21-2002
//purpose - Get all new Battle Cvars into the UI
//format and some portions stolen from ui_startserver_server.c

#include "../q3_ui/q3ui_local.h"
#include "ui_startserver_q3.h"

#define ID_G_GAMEMODE							500		//(0 - 1)

//Game Options
//#define ID_G_COUNTDOWN							501		//(0 - 1)
//#define ID_G_PAUSED								502		//(0 - 1)
//#define ID_G_REPLACEPOWERUP						503		//(0 - 1)
#define ID_G_DAMAGESCORING						504		//(0 - 1)
#define ID_G_COUNTPVS							505		//(0 - 1)
#define ID_G_DAMAGEREGEN						506		//(0 - 1)

//Weapon Control
#define ID_G_FREEGEAR							507		//(0 - 1)
#define ID_G_FREESHOTGUN						508		//(0 - 1)
#define ID_G_FREEPLASMAGUN						509		//(0 - 1)
#define ID_G_FREEGRENADELAUNCHER				510		//(0 - 1)
#define ID_G_FREEROCKETLAUNCHER					511		//(0 - 1)
#define	ID_G_FREELIGHTNINGGUN					512		//(0 - 1)
#define ID_G_FREERAILGUN						513		//(0 - 1)
#define ID_G_FREEBFG							514		//(0 - 1)
#define ID_G_FREEHANDGRENADE					515		//(0 - 1)
#define ID_G_FREEMACHINEGUN						516		//(0 - 1)
//#define ID_G_FREEGAUNTLET						517		//(0 - 1)
//Health Regen
#define ID_G_HEALTHRESTORE						518		//(0 - 1)
#define ID_G_HEALTHRESTOREINTERVAL				519		//(in seconds:2)
#define ID_G_HEALTHRESTORESTEP					520		//(10)
#define ID_G_HEALTHRESTOREMAX					521		//(160)
//Armor Regen
#define ID_G_ARMORRESTORE						522		//(0 - 1)
#define ID_G_ARMORRESTOREINTERVAL				523		//(in seconds:5)
#define ID_G_ARMORRESTORESTEP					524		//(5)
#define ID_G_ARMORRESTOREMAX					525		//(120)
//Ammo Regen
#define ID_G_AMMORESTORE						526		//(0 - 1)
#define ID_G_AMMORESTOREINTERVAL				527		//(in seconds)
//Weapon Enhancements
#define ID_G_BATTLEWEAPONS						528		//(0 - 1)
#define ID_G_PARTIAILFRIENDLYFIRE				529		//(0 - 1)

#define ID_G_PARTIALFRIENDLYFIREFRACTION		530		//(in fractions 0.25)
#define ID_G_WEAPONSTAY							531		//(0 - 1)
#define ID_G_TRIPLERAIL							532		//(0 - 1)
#define ID_G_BOUNCEPLASMA						533		//(0 - 1)
#define ID_G_NOBOUNCEHG							534		//(0 - 1)
#define ID_G_SUPERSHOTGUN						535		//(0 - 1)
#define ID_G_SPLASHRAIL							536		//(0 - 1)
//Grapple - movement
#define ID_G_GRAPPLEGLOBAL						537		//(0 - 1)
#define ID_G_GRAPPLEHOOKSPEED					538		//(Default:1150 - Battle:2025)
#define ID_G_GRAPPLEPULLSPEED					539		//(Default:750 - Battle:550)
#define ID_G_NOJUMPPADS							540		//(0 - 1)
#define ID_G_GRAPPLEENEMIES						541		//(0 - 1)
#define ID_G_GRAPPLEBUDDIES						542		//(0 - 1)
#define ID_G_SKYHOOK							543		//(0 - 1)
#define ID_G_HOOKNOGRAV							544		//(0 - 1)
#define ID_G_GRAPPLETYPE						545		//(0 - 1)
#define ID_G_RAMPJUMP							546		//(0 - 1)
#define ID_G_AIRMOVE							547		//(Default:10 - Battle:40)
#define ID_G_AIRSPEED							548		//(Default:320 - Battle:360)
#define ID_G_SPEED								549		//(Default:320 - Battle:360)
#define ID_G_STRAFEJUMP							550		//(0 - 1)
#define ID_G_GRAFTING							551		//(0 - 1)
//#define ID_G_Q2HOOKSPEED						552		//(0 - 1)(1900,420)
//#define ID_BOT_GRAPPLE							553		//(0 - 1)
#define ID_G_SPAWNUSEENEMY						554		//g_spawnUseEnemy;
#define ID_G_SPAWNNOENEMYBASE					555		//vmCvar_t g_spawnNoEnemyBase;
#define ID_G_SPAWNNEARACTION					556		//vmCvar_t g_spawnNearAction;
#define ID_G_BATTLESPAWNING						557		//vmCvar_t g_battleSpawning;
#define ID_G_GRAPPLEONHAND						558		//g_grappleOnhand 0|1
#define ID_G_BATTLEPOWERUPS						559		//g_battlePowerups 0|1
#define ID_G_GRAPPLETYPE2						560
#define	ID_NO_FALLING							561		//NO FALL DAMAGE
#define ID_FIXED_FOV							562		//FOV 90
#define	ID_NO_FOOTSTEPS							563		//NO FOOTSTEPS
#define ID_NO_PLATS								564		//NO MOVER PLATS SPAWN IN MAPS
#define ID_NO_DOORS								565		//NO DOORS SPAWN IN MAPS
#define ID_NO_IDPOWERUPS						566		//NO ID POWERUPS -- OVERRIDES UI SETTINGS
#define ID_NO_HOLDABLES							567		//NO HOLDABLE ITEMS SPAWN IN MAPS -- OVERRIDES UI SETTINGS
#define ID_NO_CLIPAREA							568		//NO CLIP AREAS FOR PLAYERS
#define ID_G_LETHALITY							569
#define ID_G_ALTBOUNCEWEAPS						570
#define ID_G_KNOCKBACKWEAPS						571


// BATTLE PAGE TABS
#define ID_BATTLE_GAMETYPE						150		//Game Type Option

#define ID_BATTLE_CONFIGTYPE					199		//Set config settings for gamemodes
#define ID_GAMEMODE								200		//GAMEMODE	and options
#define ID_WEAPONCONTROL						201		//WEAPONS CONTROLS FREEGEAR
#define ID_REGENERATIONS						202		//Health-Armor-Ammo Regens

#define ID_WEAPONENHANCEMENTS					203		//Weapon_Enhancements
#define ID_GRAPPLE								204		//Grapple Related
#define ID_MOVEMENTS							205		//Battle Movement
//#define ID_BOTCONTROLS						206		//SEtup Bot Controls
#define ID_DMFLAGS								207		//dmflags cvar


#define CONTROL_POSX (GAMETYPECOLUMN_X + 6*SMALLCHAR_WIDTH)

#define BATTLECOLUMN_X GAMETYPECOLUMN_X


enum {
    BTLCTRL_SPIN,
    BTLCTRL_RADIO,
    BTLCTRL_TEXTFIELD,
    BTLCTRL_NUMFIELD,
    BTLCTRL_BLANK
};


/*
	These flags define how controls are drawn
 
	ITEM_ALWAYSON			never modified
	ITEM_GRAYIF_PREVON		grayed if prev spin control is on (dyn)
	ITEM_GRAYIF_PREVOFF		grayed if prev spin control is off (dyn)
	ITEM_TEAM_GAME			control displayed when a team game
	ITEM_NOTEAM_GAME		control displayed when not a team game
	ITEM_HALFGAP			places a gap after this item
 
	On use of ITEM_GRAYIF_* flags:
	The control with this flag will be enabled/grayed depending on the
	most recent radio control that is enabled. You can use this flag to
	enable/disable groups of controls that include a radio control - without
	that disabled radio control influencing the group.
 
	Example:
 
	radio1
	spin1	GRAYIF_PREVON
	radio2	GRAYIF_PREVON
	spin2	GRAYIF_PREVON
 
	if radio1 is on then all following controls are grayed, radio2 is ignored
	if radio1 is off then spin1 and radio2 are enabled, and spin2 depends on radio2
*/
#define ITEM_ALWAYSON			0x0000
#define ITEM_GRAYIF_PREVON	 	0x0001
#define ITEM_GRAYIF_PREVOFF 	0x0002
#define ITEM_TEAM_GAME			0x0004
#define ITEM_NOTEAM_GAME		0x0008
#define ITEM_HALFGAP			0x0010



// list of created controls on page --- order is important
/*
typedef struct controlinit_s {
    int type;	// BTLCTRL_*
    int offset;	// index into array storing type
    int id;		// control id ID_BATTLE_*
    int flags;	// ITEM_* flags
    char* title;	// text describing control
    // used by RADIO, NUMFIELD, or SPIN
    int* number;
    // used by NUMFIELD
    // min, max ignored if identical
    int min;	// min value of number
    int max;	// max value of number
    // used by TEXTFIELD
    char* array;
    // used by TEXTFIELD and NUMFIELD
    int displaysize;
    int arraysize;
    // used by SPIN
    const char** itemnames;
}
controlinit_t;
*/


#define ARRAY_COUNT(array) (sizeof(array)/sizeof(array[0]))


// single tabbed page of controls
/*
typedef struct initlist_s {
    int id;
    char* title;
    menutext_s* menutext;
    controlinit_t* list;
    int count;
}
initlist_t;
*/
/*
typedef struct radiobuttoncontrol_s {
    menuradiobutton_s control;
    controlinit_t* init;
}
radiobuttoncontrol_t;
 
 
typedef struct textfieldcontrol_s {
    menufield_s control;
    controlinit_t* init;
}
textfieldcontrol_t;
 
 
typedef struct spincontrol_s {
    menulist_s control;
    controlinit_t* init;
}
spincontrol_t;
*/


#define MAX_BATTLE_RADIO_CONTROL		51 //48	//43
#define MAX_BATTLE_MFIELD_CONTROL		14 //13
#define MAX_BATTLE_SPIN_CONTROL			4	//1

//offhand battlemode
/*
typedef struct {
	//int gamemode;
	char* gtype;
} grappletype_t;
*/

static const char *grappletype[] = {
                                       "BubbleTrail", "BloodTrail","CapEffectTrail","Trail-gamemode Set","RocketTrail", 0 //"GrappleTrail","GrappleTrail","RocketTrail"
                                   }
                                   ;

static const char *onhandgtype[] = {
                                       "Laser", "Rope", "Lightning", 0
                                   };

//on reload always set to custom
static const char *battleconfigtype[] = {
                                            "Load Last Run CFG", "Vanilla Q3 Style", "Battle Style" ,"Expert Q2 Style", "Lethality InstaGib" , 0
                                        };

static const char *partialfriendlyfirefraction[] = {
            "0.25", "0.30", "0.35", "0.40", "0.45",
            "0.50", "0.55", "0.60", "0.65", "0.70",
            "0.75", "0.80", "0.85", "0.90", "0.95",
            0
        };
/*
static const char *lethalitysettings[] = {
	"1.0", "1.1", "1.2", "1.3", "1.4", "1.5",
	"1.6", "1.7", "1.8", "1.9", "2.0", "2.5"
	"3.0", "3.5", "4.0", "4.5", "5.0", "6.0"
	"7.0", "8.0", "9.0", "10.0", "20.0","40.0",
	"60.0", "70.0" "80.0", "99.9", 0
};
*/
/*
static grappletype_t grappletype[] ={
	{0,"BubbleTrail"},//default grappletrail
	{1,"BloodTrail"},
	{2,"CapEffectTrail"},
	{3, "GrappleTrail"},//default Bubbletrail
	{4,"GrappleTrail"},
	{5,"RocketTrail"}
};
*/



typedef struct battlecontrols_s {
    menuframework_s menu;
    commoncontrols_t common;

    menulist_s gameType;
    menubitmap_s gameTypeIcon;

    menulist_s	configtype;

    radiobuttoncontrol_t radio[MAX_BATTLE_RADIO_CONTROL];
    textfieldcontrol_t field[MAX_BATTLE_MFIELD_CONTROL];
    spincontrol_t spin[MAX_BATTLE_SPIN_CONTROL];

    menutext_s Game_Mode;//these are handled with srv_battle_main_menu_items below
    menutext_s Weapon_Control;
    menutext_s Regens;
    menutext_s Weapon_Enhancements;
    menutext_s Grapple_movement;
    menutext_s Movement;
    //menutext_s BotControls; //bot_grapple (0-1)
    menutext_s Dm_flags;
    // currently selected tabbeed page for server
    int activePage;

    // source of data for manipulating list
    initlist_t* pageList;
    int pageListSize;

    // current number of controls on displayed page
    int num_radio;
    int num_field;
    int num_spin;

    menubitmap_s saveScript;
    //   menubitmap_s loadScript;

    int statusbar_height;
    int savetime;
    char statusbar_message[MAX_STATUSBAR_TEXT];
	int statusbar_height2;
	int savetime2;
    char statusbar_message2[MAX_STATUSBAR_TEXT];
}
s_battlecontrols_t;

static s_battlecontrols_t s_battlecontrols;

//const char *fraction_list[] = {"0.25", "0.50", "0.75", 0};//INCIN -- was  used with friendly fire fraction


static controlinit_t srv_gamemode[] ={
                                         {BTLCTRL_RADIO,0, ID_G_GAMEMODE,			ITEM_ALWAYSON,	"Battle Mode:",
                                          &s_scriptdata.battle.g_gamemode, 0,0, NULL, 0, 0, NULL },//500(0 -1)

//                                         {BTLCTRL_RADIO, 0 ,ID_G_COUNTDOWN,			ITEM_ALWAYSON,	"Countdown",
//                                          &s_scriptdata.battle.g_countdown, 0,0, NULL, 0, 0, NULL },//501(0 -1)

//                                         {BTLCTRL_RADIO, 0, ID_G_REPLACEPOWERUP	,ITEM_ALWAYSON,	"Quad Replacement:",
//                                          &s_scriptdata.battle.g_replacePowerup, 0,0, NULL, 0, 0, NULL },//503(0 -1)

                                         {BTLCTRL_RADIO, 0,ID_G_DAMAGESCORING,		ITEM_ALWAYSON,	"Damage Scoring:",
                                          &s_scriptdata.battle.g_damageScoring, 0,0, NULL, 0, 0, NULL },//504(0 -1)

                                         {BTLCTRL_RADIO, 0,ID_G_COUNTPVS,			ITEM_ALWAYSON,	"Count PVS:",
                                          &s_scriptdata.battle.g_countPVS, 0,0, NULL, 0, 0, NULL },//505(0 -1)

                                         {BTLCTRL_RADIO, 0, ID_G_BATTLESPAWNING,		ITEM_ALWAYSON,	"Battle Spawning:",
                                          &s_scriptdata.battle.g_battleSpawning , 0,0, NULL, 0,0, NULL},//557

                                         {BTLCTRL_RADIO, 0, ID_G_SPAWNUSEENEMY,		ITEM_ALWAYSON,	"Use Enemy Spawns:",
                                          &s_scriptdata.battle.g_spawnUseEnemy, 0,0, NULL, 0,0, NULL},

                                         {BTLCTRL_RADIO, 0, ID_G_SPAWNNOENEMYBASE,		ITEM_ALWAYSON|ITEM_GRAYIF_PREVOFF,	"Use Enemy Base Spawns:",
                                          &s_scriptdata.battle.g_spawnNoEnemyBase , 0,0, NULL, 0,0, NULL},	//555

                                         {BTLCTRL_RADIO, 0, ID_G_SPAWNNEARACTION,		ITEM_ALWAYSON,	"Spawn Near Action:",
                                          &s_scriptdata.battle.g_spawnNearAction , 0,0, NULL, 0,0, NULL},	//556

                                         {BTLCTRL_RADIO, 0, ID_G_BATTLEPOWERUPS,		ITEM_ALWAYSON,	"Battle Runes:",
                                          &s_scriptdata.battle.g_battlePowerups , 0,0, NULL, 0,0, NULL},	//556

										 {BTLCTRL_NUMFIELD,  0, ID_G_LETHALITY,	ITEM_ALWAYSON,	"Lethality:",
										  &s_scriptdata.battle.g_lethality, 1,99, NULL, 4, 4, NULL },//568//(in seconds:2)
//										 {BTLCTRL_SPIN,  0, ID_G_LETHALITY,	ITEM_ALWAYSON,	"Lethality:",
//										 &s_scriptdata.battle.g_lethality, 0, 0, NULL, 0,0, lethalitysettings},

										 {BTLCTRL_RADIO, 0, ID_G_ALTBOUNCEWEAPS,		ITEM_ALWAYSON,	"Bounce Weapon Fire:",
                                          &s_scriptdata.battle.g_altbounceweaps , 0,0, NULL, 0,0, NULL}	,//569
										 
										 {BTLCTRL_RADIO, 0, ID_G_KNOCKBACKWEAPS,		ITEM_ALWAYSON,	"Knockback Weapons:",
                                          &s_scriptdata.battle.g_knockbackweaps , 0,0, NULL, 0,0, NULL}	//570
                                         //12 radio
										 // 1 num	
                                     };


//Weapon Control
static controlinit_t srv_weapcontrol[]={
                                           {BTLCTRL_RADIO, 0,	ID_G_FREEGEAR,				ITEM_ALWAYSON|ITEM_HALFGAP,	"Free Gear:",
                                            &s_scriptdata.battle.g_freeGear, 0,0, NULL, 0, 0, NULL },//507//(0 - 1)

                                           {BTLCTRL_RADIO, 0,	ID_G_FREEMACHINEGUN,			ITEM_ALWAYSON,	"Free MachineGun:",
                                            &s_scriptdata.battle.g_freeMachinegun, 0,0, NULL, 0, 0, NULL },//508//(0 - 1)

                                           {BTLCTRL_RADIO, 0,	ID_G_FREESHOTGUN,			ITEM_ALWAYSON,	"Free ShotGun:",
                                            &s_scriptdata.battle.g_freeShotgun, 0,0, NULL, 0, 0, NULL },//508//(0 - 1)

                                           {BTLCTRL_RADIO, 0,	ID_G_FREEPLASMAGUN,			ITEM_ALWAYSON,	"Free PlasmaGun:",
                                            &s_scriptdata.battle.g_freePlasmaGun, 0,0, NULL, 0, 0, NULL },//509//(0 - 1)

                                           {BTLCTRL_RADIO, 0,	ID_G_FREEGRENADELAUNCHER,	ITEM_ALWAYSON,	"Free Grenade Launcher:",
                                            &s_scriptdata.battle.g_freeGrenadeLauncher, 0,0, NULL, 0, 0, NULL },//510//(0 - 1)

                                           {BTLCTRL_RADIO, 0,ID_G_FREEROCKETLAUNCHER,	ITEM_ALWAYSON,	"Free Rocket Launcher:",
                                            &s_scriptdata.battle.g_freeRocketLauncher, 0,0, NULL, 0, 0, NULL },//511//(0 - 1)

                                           {BTLCTRL_RADIO, 0,	ID_G_FREELIGHTNINGGUN,		ITEM_ALWAYSON,	"Free Lightning Gun:",
                                            &s_scriptdata.battle.g_freeLightningGun, 0,0, NULL, 0, 0, NULL },//512//(0 - 1)

                                           {BTLCTRL_RADIO, 0,	ID_G_FREERAILGUN,			ITEM_ALWAYSON,	"Free RailGun:",
                                            &s_scriptdata.battle.g_freeRailgun, 0,0, NULL, 0, 0, NULL },//513//(0 - 1)

                                           {BTLCTRL_RADIO, 0,	ID_G_FREEBFG,				ITEM_ALWAYSON,	"Free BFG:",
                                            &s_scriptdata.battle.g_freeBFG, 0,0, NULL, 0, 0, NULL },//514//(0 - 1)

                                           {BTLCTRL_RADIO, 0,	ID_G_FREEHANDGRENADE,		ITEM_ALWAYSON,	"Free Hand Grenade:",
                                            &s_scriptdata.battle.g_freeHandgrenade, 0,0, NULL, 0, 0, NULL }//515//(0 - 1)
                                       };//9 radio

//Health Regen
static controlinit_t srv_regens[]={

                                      {BTLCTRL_RADIO, 0, ID_G_DAMAGEREGEN,		ITEM_ALWAYSON|ITEM_HALFGAP,	"Damage Regen:",
                                       &s_scriptdata.battle.g_damageRegen, 0,0, NULL, 0, 0, NULL },//506(0 -1)


                                      {BTLCTRL_RADIO,  0, ID_G_HEALTHRESTORE,		ITEM_ALWAYSON,	"Health Restore:",
                                       &s_scriptdata.battle.g_healthRestore, 0,0, NULL, 0, 0, NULL },//518//(0 - 1)

                                      {BTLCTRL_NUMFIELD,  0, ID_G_HEALTHRESTOREINTERVAL,	ITEM_ALWAYSON|ITEM_GRAYIF_PREVOFF,	"Health Restore Interval:",
                                       &s_scriptdata.battle.g_healthRestoreInterval, 2,60, NULL, 4, 4, NULL },//519//(in seconds:2)

                                      {BTLCTRL_NUMFIELD,  0, ID_G_HEALTHRESTORESTEP,	ITEM_ALWAYSON|ITEM_GRAYIF_PREVOFF,	"Health Restore Step:",
                                       &s_scriptdata.battle.g_healthRestoreStep, 10,100, NULL, 4, 4, NULL },//520//(10)

                                      {BTLCTRL_NUMFIELD, 0,  ID_G_HEALTHRESTOREMAX,	ITEM_ALWAYSON|ITEM_GRAYIF_PREVOFF|ITEM_HALFGAP,	"Health Restore Max:",
                                       &s_scriptdata.battle.g_healthRestoreMax, 0,160, NULL, 4, 4, NULL },	//521//(160)


                                      //Armor Regen
                                      {BTLCTRL_RADIO, 0,  ID_G_ARMORRESTORE,		ITEM_ALWAYSON,	"Armor Restore:",
                                       &s_scriptdata.battle.g_armorRestore, 0,0, NULL, 0, 0, NULL },//522//(0 - 1)

                                      {BTLCTRL_NUMFIELD, 0,  ID_G_ARMORRESTOREINTERVAL,	ITEM_ALWAYSON|ITEM_GRAYIF_PREVOFF,	"Armor Restore Interval:",
                                       &s_scriptdata.battle.g_armorRestoreInterval, 5,60, NULL, 4, 4, NULL },//523//(in seconds:5)

                                      {BTLCTRL_NUMFIELD, 0,  ID_G_ARMORRESTORESTEP,	ITEM_ALWAYSON|ITEM_GRAYIF_PREVOFF,	"Armor Restore Step:",
                                       &s_scriptdata.battle.g_armorRestoreStep, 5,25, NULL, 4, 4, NULL },//524//(5)

                                      {BTLCTRL_NUMFIELD, 0,  ID_G_ARMORRESTOREMAX,	ITEM_ALWAYSON|ITEM_GRAYIF_PREVOFF|ITEM_HALFGAP,	"Armor Restore Max:",
                                       &s_scriptdata.battle.g_armorRestoreMax, 0, 120, NULL, 4, 4, NULL },//525//(120)


                                      //Ammo Regen
                                      {BTLCTRL_RADIO, 0,  ID_G_AMMORESTORE,			ITEM_ALWAYSON,	"Ammo Restore:",
                                       &s_scriptdata.battle.g_ammoRestore, 0,0, NULL, 0, 0, NULL },//526//(0 - 1)

                                      {BTLCTRL_NUMFIELD, 0,  ID_G_AMMORESTOREINTERVAL,	ITEM_ALWAYSON|ITEM_GRAYIF_PREVOFF,	"Ammo Restore Interval:",
                                       &s_scriptdata.battle.g_ammoRestoreInterval, 1,60, NULL, 4, 4, NULL }//527//(in seconds)
                                  };//4 radio //7 numfield

//Weapon Enhancements
static controlinit_t srv_weapenhance[]={
                                           {BTLCTRL_RADIO,  0, ID_G_BATTLEWEAPONS,			ITEM_ALWAYSON|ITEM_HALFGAP,	"Battle Weapons:",
                                            &s_scriptdata.battle.g_battleWeapons, 0,0, NULL, 0, 0, NULL },//528//(0 - 1)

                                           {BTLCTRL_RADIO, 0,  ID_G_PARTIAILFRIENDLYFIRE,	ITEM_ALWAYSON,	"Partial Friendly Fire:",
                                            &s_scriptdata.battle.g_partialFriendlyFire, 0,0, NULL, 0, 0, NULL },//529//(0 - 1)

                                           {BTLCTRL_SPIN, 0,  ID_G_PARTIALFRIENDLYFIREFRACTION, ITEM_GRAYIF_PREVOFF,	"Friendly Fire Fraction:",
                                            &s_scriptdata.battle.g_partialFriendlyFireFraction , 0, 0, NULL, 0,0, partialfriendlyfirefraction }, //530//(in fractions 0.25)*/

                                           {BTLCTRL_RADIO, 0,  ID_G_WEAPONSTAY,			ITEM_ALWAYSON,	"Weapon Stay:",
                                            &s_scriptdata.battle.g_weaponsStay, 0,0, NULL, 0, 0, NULL },//531//(0 - 1)

                                           {BTLCTRL_RADIO, 0,  ID_G_TRIPLERAIL,			ITEM_ALWAYSON,	"Triple Rail Fire:",
                                            &s_scriptdata.battle.g_tripleRail, 0,0, NULL, 0, 0, NULL },//532//(0 - 1)

                                           {BTLCTRL_RADIO, 0,  ID_G_BOUNCEPLASMA,			ITEM_ALWAYSON,	"Plasma Bounce:",
                                            &s_scriptdata.battle.g_bouncePlasma, 0,0, NULL, 0, 0, NULL },//533//(0 - 1)

                                           {BTLCTRL_RADIO, 0,  ID_G_NOBOUNCEHG,			ITEM_ALWAYSON,	"No Bounce H.G.:",
                                            &s_scriptdata.battle.g_nobounceHG, 0,0, NULL, 0, 0, NULL },	//534//(0 - 1)

                                           {BTLCTRL_RADIO, 0,  ID_G_SUPERSHOTGUN,			ITEM_ALWAYSON,	"Enable SuperShotgun:",
                                            &s_scriptdata.battle.g_superShotgun, 0,0, NULL, 0, 0, NULL },//535//(0 - 1)

                                           {BTLCTRL_RADIO, 0,  ID_G_SPLASHRAIL,			ITEM_ALWAYSON,	"Rail Splash Damage:",
                                            &s_scriptdata.battle.g_splashRail, 0,0, NULL, 0, 0, NULL }//536//(0 - 1)
                                       };//8 radio  1-spin

//Grapple - movement

static controlinit_t srv_grapplemovement[]={
            {BTLCTRL_RADIO, 0,  ID_G_GRAPPLEGLOBAL,			ITEM_ALWAYSON,	"Enable a Grapple:",
             &s_scriptdata.battle.g_grappleGlobal, 0,0, NULL, 0, 0, NULL },//537//(0 - 1)


            {BTLCTRL_RADIO, 0,  ID_G_GRAPPLEONHAND,			ITEM_ALWAYSON|ITEM_GRAYIF_PREVOFF,	"Grapple Weapon:",
             &s_scriptdata.battle.g_grappleOnHand, 0,0, NULL, 0, 0, NULL },//537//(0 - 1)

            //{BTLCTRL_NUMFIELD, 0,  ID_G_GRAPPLETYPE,			ITEM_ALWAYSON,	"Grapple Trail Type:",
            //&s_scriptdata.battle.g_grappleType, 0,2, NULL, 2, 2, NULL }//545//(0 - 1)
            {BTLCTRL_SPIN, 0, ID_G_GRAPPLETYPE,	ITEM_ALWAYSON|ITEM_GRAYIF_PREVON, "Offhand Grapple Trail:",
             &s_scriptdata.battle.g_grappleType,0,0, NULL,0, 0, grappletype },

            {BTLCTRL_SPIN, 0, ID_G_GRAPPLETYPE2,	ITEM_ALWAYSON|ITEM_GRAYIF_PREVOFF|ITEM_HALFGAP, "Onhand Grapple Trail:",
             &s_scriptdata.battle.g_grappleType2,0,0, NULL,0, 0, onhandgtype },



//            {BTLCTRL_RADIO, 0,  ID_G_Q2HOOKSPEED,			ITEM_ALWAYSON,	"Q2 Hook Speed:",
//             &s_scriptdata.battle.g_q2HookSpeed, 0,0, NULL, 0, 0, NULL },//552//(0 - 1)(1900,420)

            {BTLCTRL_NUMFIELD, 0,  ID_G_GRAPPLEHOOKSPEED,			ITEM_ALWAYSON,	"Grapple Speed:",
             &s_scriptdata.battle.g_grappleHookSpeed, 1000,9999, NULL, 5, 5, NULL },//538//(Default:1150 - Battle:2025)

            {BTLCTRL_NUMFIELD, 0,  ID_G_GRAPPLEPULLSPEED,			ITEM_ALWAYSON|ITEM_HALFGAP,	"Pull Speed:",
             &s_scriptdata.battle.g_grapplePullSpeed, 500,9999, NULL, 5, 5, NULL }, //539//(Default:750 - Battle:550)

            {BTLCTRL_RADIO, 0,  ID_G_GRAPPLEENEMIES,			ITEM_ALWAYSON,	"Grapple Enemies:",
             &s_scriptdata.battle.g_grappleEnemies, 0,0, NULL, 0, 0, NULL },//541//(0 - 1)

            {BTLCTRL_RADIO, 0,  ID_G_GRAPPLEBUDDIES,			ITEM_ALWAYSON,	"Grapple Buddies:",
             &s_scriptdata.battle.g_grappleBuddies, 0,0, NULL, 0, 0, NULL },//542//(0 - 1)

            {BTLCTRL_RADIO, 0,  ID_G_SKYHOOK,				ITEM_ALWAYSON,	"Sky Hook:",
             &s_scriptdata.battle.g_skyHook, 0,0, NULL, 0, 0, NULL },//543//(0 - 1)

            {BTLCTRL_RADIO,  0, ID_G_HOOKNOGRAV,			ITEM_ALWAYSON,	"No Gravity Hook:",
             &s_scriptdata.battle.g_hookNoGrav, 0,0, NULL, 0, 0, NULL },//544//(0 - 1)





        };//6 radio  //3 num //2 spin

static controlinit_t srv_movement[]={

                                        {BTLCTRL_RADIO, 0,  ID_G_NOJUMPPADS,			ITEM_ALWAYSON,	"No Jump Pads:",
                                         &s_scriptdata.battle.g_nojumppads, 0,0, NULL, 0, 0, NULL },//540//(0 - 1)

                                        {BTLCTRL_RADIO, 0,  ID_G_RAMPJUMP,			ITEM_ALWAYSON,	"Ramp Jump:",
                                         &s_scriptdata.battle.g_rampJump, 0,0, NULL, 0, 0, NULL },//546//(0 - 1)

                                        {BTLCTRL_NUMFIELD, 0,  ID_G_AIRMOVE,			ITEM_ALWAYSON,	"Air Move:",
                                         &s_scriptdata.battle.g_airMove, 10, 999, NULL, 4, 4, NULL },//547//(Default:10 - Battle:40)

                                        {BTLCTRL_NUMFIELD, 0,  ID_G_AIRSPEED,			ITEM_ALWAYSON,	"Air Speed:",
                                         &s_scriptdata.battle.g_airSpeed, 320, 999, NULL, 4, 4, NULL },//548//(Default:320 - Battle:360)

                                        {BTLCTRL_NUMFIELD, 0,  ID_G_SPEED,			ITEM_ALWAYSON,	"Ground Speed:",
                                         &s_scriptdata.battle.g_speed, 320, 999, NULL, 4, 4, NULL },//549//(Default:320 - Battle:360)

                                        {BTLCTRL_RADIO, 0,  ID_G_STRAFEJUMP,			ITEM_ALWAYSON,	"Strafe Jump:",
                                         &s_scriptdata.battle.g_strafeJump, 0,0, NULL, 0, 0, NULL },//550//(0 - 1)

                                        {BTLCTRL_RADIO, 0,  ID_G_GRAFTING,			ITEM_ALWAYSON,	"Grafting:",
                                         &s_scriptdata.battle.g_grafting, 0,0, NULL, 0, 0, NULL }//551//(0 - 1)
                                    };//4 radio  3 num
/*
static controlinit_t srv_botvars[] = {
 
	{BTLCTRL_RADIO, 0,  ID_BOT_GRAPPLE,	ITEM_ALWAYSON,	"Bot Grapple:", 
	&s_scriptdata.battle.bot_grapple, 0,0, NULL, 0, 0, NULL }//540//(0 - 1)
 
};//1 radio
*/

static controlinit_t srv_dmflags[] = {

                                         /*
                                         s_scriptdata.battle.nofalling = 1;		//0 or 8
                                         s_scriptdata.battle.fixedfov = 1;		//0 or 16
                                         s_scriptdata.battle.nofootsteps = 1;	//0 or 32
                                         s_scriptdata.battle.noplats = 1;		//0 or 64
                                         s_scriptdata.battle.nodoors = 1;;		//0 or 128
                                         s_scriptdata.battle.noidpowerups= 1;	//0 or 256
                                         s_scriptdata.battle.noholdables = 1;	//0 or 512
                                         */

                                         {BTLCTRL_RADIO, 0,  ID_NO_FALLING,	ITEM_ALWAYSON,	"Falling Damage:",
                                          &s_scriptdata.battle.nofalling, 0,0, NULL, 0, 0, NULL },//540//(0/8)

                                         {BTLCTRL_RADIO, 0,  ID_FIXED_FOV,	ITEM_ALWAYSON,	"Fixed FOV:",
                                          &s_scriptdata.battle.fixedfov, 0,0, NULL, 0, 0, NULL },//540//(0/16)

                                         {BTLCTRL_RADIO, 0,  ID_NO_FOOTSTEPS,	ITEM_ALWAYSON,	"Foot Steps:",
                                          &s_scriptdata.battle.nofootsteps, 0,0, NULL, 0, 0, NULL },//540//(0/32)


                                         {BTLCTRL_RADIO, 0,  ID_NO_PLATS,	ITEM_ALWAYSON,	"Inhibit Platforms:",
                                          &s_scriptdata.battle.noplats, 0,0, NULL, 0, 0, NULL },//540//(0/32)

                                         {BTLCTRL_RADIO, 0,  ID_NO_DOORS,	ITEM_ALWAYSON,	"Inhibit Doors:",
                                          &s_scriptdata.battle.nodoors, 0,0, NULL, 0, 0, NULL },//540//(0/64)

                                         {BTLCTRL_RADIO, 0,  ID_NO_IDPOWERUPS,	ITEM_ALWAYSON,	"Inhibit Powerups:",
                                          &s_scriptdata.battle.noidpowerups, 0,0, NULL, 0, 0, NULL },//540//(0/128)

                                         {BTLCTRL_RADIO, 0,  ID_NO_HOLDABLES,	ITEM_ALWAYSON,	"Inhibit Holdable:",
                                          &s_scriptdata.battle.noholdables, 0,0, NULL, 0, 0, NULL },//540//(0/256)
                                         
										 {BTLCTRL_RADIO, 0,  ID_NO_CLIPAREA,	ITEM_ALWAYSON,	"Player Clip Regions:",
                                          &s_scriptdata.battle.no_clipareas, 0,0, NULL, 0, 0, NULL },//540//(0/256)


                                     };//7 radio

// BATTLE PAGE TABS
static initlist_t srv_battle_main_menu_items[] =
    {
        {
            ID_GAMEMODE,			"GAME MODE",			&s_battlecontrols.Game_Mode,
            srv_gamemode,			ARRAY_COUNT(srv_gamemode)
        },

        {
            ID_WEAPONCONTROL,		"WEAPONS",				&s_battlecontrols.Weapon_Control,
            srv_weapcontrol,		ARRAY_COUNT(srv_weapcontrol)
        },

        {
            ID_REGENERATIONS,		"REGENERATION",			&s_battlecontrols.Regens,
            srv_regens,				ARRAY_COUNT(srv_regens)
        },

        {
            ID_WEAPONENHANCEMENTS,"ENHANCEMENTS",			&s_battlecontrols.Weapon_Enhancements,
            srv_weapenhance,		ARRAY_COUNT(srv_weapenhance)
        },

        {
            ID_GRAPPLE,				"GRAPPLE",				&s_battlecontrols.Grapple_movement,
            srv_grapplemovement,	ARRAY_COUNT(srv_grapplemovement)
        },

        {
            ID_MOVEMENTS,			"MOVEMENT",				&s_battlecontrols.Movement,
            srv_movement,			ARRAY_COUNT(srv_movement)
        },
        {
            ID_DMFLAGS,				"DMFLAGS",				&s_battlecontrols.Dm_flags,
            srv_dmflags,			ARRAY_COUNT(srv_dmflags)
        }
    };



/*
=================
StartServer_BattlePage_SetControlState
=================
*/
static void StartServer_BattlePage_SetControlState(menucommon_s* c,int type) {
    // set its appearance
    switch (type) {
    default:
        c->flags &= ~(QMF_HIDDEN|QMF_INACTIVE|QMF_GRAYED);
        break;
    case QMF_HIDDEN:
        c->flags &= ~(QMF_GRAYED);
        c->flags |= (QMF_HIDDEN|QMF_INACTIVE);
        break;
    case QMF_GRAYED:
        c->flags &= ~(QMF_HIDDEN|QMF_INACTIVE);
        c->flags |= (QMF_GRAYED);
    }
}

/*
=================
StartServer_BattlePage_SetControlFromId
=================
*/
static void StartServer_BattlePage_SetControlFromId(int id, int type) {
    int i;

    // locate control
    for (i = 0; i < s_battlecontrols.num_radio; i++) {
        if (s_battlecontrols.radio[i].init->id == id) {
            StartServer_BattlePage_SetControlState(&s_battlecontrols.radio[i].control.generic, type);
            return;
        }
    }

    for (i = 0; i < s_battlecontrols.num_field; i++) {
        if (s_battlecontrols.field[i].init->id == id) {
            StartServer_BattlePage_SetControlState(&s_battlecontrols.field[i].control.generic, type);
            return;
        }
    }

    for (i = 0; i < s_battlecontrols.num_spin; i++) {
        if (s_battlecontrols.spin[i].init->id == id) {
            StartServer_BattlePage_SetControlState(&s_battlecontrols.spin[i].control.generic, type);
            return;
        }
    }
}

/*
=================
StartServer_BattlePage_UpdateInterface
=================
*/
static void StartServer_BattlePage_UpdateInterface(void) {
    int i;
    initlist_t* group;
    qboolean lastSet;

    StartServer_SetIconFromGameType(&s_battlecontrols.gameTypeIcon, s_scriptdata.gametype, qfalse);

    // clear visible controls
    for (i = 0; i < s_battlecontrols.num_radio; i++) {
        StartServer_BattlePage_SetControlState(&s_battlecontrols.radio[i].control.generic, 0);
    }

    for (i = 0; i < s_battlecontrols.num_field; i++) {
        StartServer_BattlePage_SetControlState(&s_battlecontrols.field[i].control.generic, 0);
    }

    for (i = 0; i < s_battlecontrols.num_spin; i++) {
        StartServer_BattlePage_SetControlState(&s_battlecontrols.spin[i].control.generic, 0);
    }


    // walk item list, setting states as appropriate
    group = &s_battlecontrols.pageList[s_battlecontrols.activePage];
    lastSet = qfalse;
    for (i = 0; i < group->count; i++) {
        // hide/show control based on previous set value
        // if item is grayed then we avoid changing the lastSet flag by
        // continuing. This prevents a grayed *radio* control from affecting
        // a group of grayed controls
        if ((group->list[i].flags & ITEM_GRAYIF_PREVON) && lastSet) {
            StartServer_BattlePage_SetControlFromId(group->list[i].id, QMF_GRAYED);
            continue;
        }

        if ((group->list[i].flags & ITEM_GRAYIF_PREVOFF) && !lastSet) {
            StartServer_BattlePage_SetControlFromId(group->list[i].id, QMF_GRAYED);
            continue;
        }

        // update status of "most recent" spin control
        if (group->list[i].type == BTLCTRL_RADIO) {
            if (s_battlecontrols.radio[ group->list[i].offset ].control.curvalue)
                lastSet = qtrue;
            else
                lastSet = qfalse;
        }
    }

    // enable fight button if possible
    if (!StartServer_CheckFightReady(&s_battlecontrols.common)) {//INCIN -- check this
        s_battlecontrols.saveScript.generic.flags |= QMF_GRAYED;
    } else {
        s_battlecontrols.saveScript.generic.flags &= ~QMF_GRAYED;
    }
}


void StartServer_BattlePage_Cache(void) {
    //trap_R_RegisterShaderNoMip( SERVER_SAVE0 );
    //trap_R_RegisterShaderNoMip( SERVER_SAVE1 );
}


/*
=================
StartServer_BattlePage_Save
=================
*/
static void StartServer_BattlePage_Save( void ) {
    StartServer_SaveScriptData();
}


/*
=================
StartServer_BattlePage_CheckMinMaxFail
=================
*/
static qboolean StartServer_BattlePage_CheckMinMaxFail( controlinit_t* c ) {
    int value;

    if (c->min == c->max)
        return qfalse;

    value = *(c->number);
    if (value < c->min) {
        *(c->number) = c->min;
        return qtrue;
    }
    if (value > c->max) {
        *(c->number) = c->max;
        return qtrue;
    }

    return qfalse;
}

/*
=================
StartServer_BattlePage_SpinEvent
=================
*/
static void StartServer_BattlePage_SpinEvent( void* ptr, int event ) {
    int id;
    spincontrol_t* s;

    if (event != QM_ACTIVATED)
        return;

    id = ((menucommon_s*)ptr)->id;

    s = &s_battlecontrols.spin[id];

    *(s->init->number) = s_battlecontrols.spin[id].control.curvalue;
    StartServer_BattlePage_UpdateInterface();
}


/*
=================
StartServer_BattlePage_RadioEvent
=================
*/
static void StartServer_BattlePage_RadioEvent( void* ptr, int event ) {
    int id;
    radiobuttoncontrol_t* r;

    if (event != QM_ACTIVATED)
        return;

    id = ((menucommon_s*)ptr)->id;

    r = &s_battlecontrols.radio[id];

    *(r->init->number) = s_battlecontrols.radio[id].control.curvalue;

    StartServer_BattlePage_UpdateInterface();
}



/*
=================
StartServer_BattlePage_FieldEvent
=================
*/
static void StartServer_BattlePage_FieldEvent( void* ptr, int event ) {
    int id;
    textfieldcontrol_t* r;
    controlinit_t* c;

    if (event != QM_LOSTFOCUS)
        return;

    id = ((menucommon_s*)ptr)->id;

    r = &s_battlecontrols.field[id];
    c = r->init;

    if (c->type == BTLCTRL_NUMFIELD) {
        *(c->number) = atoi(r->control.field.buffer);
        if (StartServer_BattlePage_CheckMinMaxFail(c)) {
            Q_strncpyz(r->control.field.buffer, va("%i", *(c->number)), c->arraysize);
        }
    } else if (c->type == BTLCTRL_TEXTFIELD) {
        Q_strncpyz(c->array, r->control.field.buffer, c->arraysize);
    }

    StartServer_BattlePage_UpdateInterface();
}


/*
=================
StartServer_BattlePage_SetStatusBar
=================
*/
static void StartServer_BattlePage_SetStatusBar( const char* text ) {
    s_battlecontrols.savetime = uis.realtime + STATUSBAR_FADETIME;
    if (text)
        Q_strncpyz(s_battlecontrols.statusbar_message, text, MAX_STATUSBAR_TEXT);
}

static void StartServer_BattlePage_SetStatusBar2( const char* text ) {
    s_battlecontrols.savetime2 = uis.realtime + STATUSBAR_FADETIME;
    if (text)
        Q_strncpyz(s_battlecontrols.statusbar_message2, text, MAX_STATUSBAR_TEXT);
}


/*
=================
StartServer_BattlePage_ControlListStatusBar
=================
*/
static void StartServer_BattlePage_ControlListStatusBar(void* ptr) {
    menucommon_s* m;
    controlinit_t* c;
    //	int i;



    m = (menucommon_s*)ptr;

    if(m->id == ID_BATTLE_CONFIGTYPE) {
        //"Custom", "Default Style", "Battle Style" ,"Expert Q2 Style" , 0
        if(s_battlecontrols.configtype.curvalue == 0) {
            StartServer_BattlePage_SetStatusBar("Current: Settings have been set Last Run Configuration");
			StartServer_BattlePage_SetStatusBar2("Next: Sets Vanilla Q3 Configuration Presets");
        } else if(s_battlecontrols.configtype.curvalue == 1) {
			StartServer_BattlePage_SetStatusBar("Current: Vanilla Q3 Configuration Presets have been set");
            StartServer_BattlePage_SetStatusBar2("Next: Sets General Battle Configuration Presets");
        } else if(s_battlecontrols.configtype.curvalue == 2) {
			StartServer_BattlePage_SetStatusBar("Current: General Battle Configuration have been set");
            StartServer_BattlePage_SetStatusBar2("Next: Sets Expert Q2 Style Configuration Presets");
        } else if(s_battlecontrols.configtype.curvalue == 3) {
			StartServer_BattlePage_SetStatusBar("Current: Expert Configuration Presets have been set");
			StartServer_BattlePage_SetStatusBar2("Next: Sets Instagib/Lethality Configuration Presets");
		} else if(s_battlecontrols.configtype.curvalue == 4) {
			StartServer_BattlePage_SetStatusBar("Current: Instagib/Lethality Configuration Presets have been set");
            StartServer_BattlePage_SetStatusBar2("Next: Resets to Last Run Configuration Presets");	
        }
        return;
    }

    switch (m->type) {
    case MTYPE_RADIOBUTTON:
        c = s_battlecontrols.radio[m->id].init;
        break;

    case MTYPE_SPINCONTROL:
        c = s_battlecontrols.spin[m->id].init;
        break;

    case MTYPE_FIELD:
        c = s_battlecontrols.field[m->id].init;
        break;

    default:
        Com_Printf("Status bar: unsupported control type (%i)\n", m->id);
        return;
    }


    switch (c->id) {
    case ID_G_GAMEMODE:							//500//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Adjusts numerous settings for weapons, grapple for optimization");
		StartServer_BattlePage_SetStatusBar2("");
        return;

        //Game Options
//    case ID_G_COUNTDOWN:						//501		//(0 - 1)
//        StartServer_BattlePage_SetStatusBar("Enable Warm Up Count Down");
//		StartServer_BattlePage_SetStatusBar2("");
//        return;

//    case ID_G_REPLACEPOWERUP:				//503		//(0 - 1)
//        StartServer_BattlePage_SetStatusBar("Replaces any PowerUp with a Random Powerup");
//		StartServer_BattlePage_SetStatusBar2("This is ID Powerups");
//        return;

    case ID_G_DAMAGESCORING	:					//504		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Enables Battle Damage Scoring");
		StartServer_BattlePage_SetStatusBar2("Awards points for Damaging Enemies");
        return;

    case ID_G_COUNTPVS:							//505		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Special CTF Scoring based on Line of Sight to Carriers");
		StartServer_BattlePage_SetStatusBar2("Point of View Scoring, points awarded for protecting Carriers");
        return;

//removed..from game in place of regens
    case ID_G_DAMAGEREGEN:						//506		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Enable - Disables Damage Regeneration");
        return;

    case ID_G_BATTLEPOWERUPS:
        StartServer_BattlePage_SetStatusBar("On Enables Non-ID Runes");
		StartServer_BattlePage_SetStatusBar2("Runes: DAMAGE, HASTE, REGEN, RESIST, AMMOREGEN, and VAMPIRE");
        break;
        //Weapon Control
    case ID_G_FREEGEAR:							//507		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Gives All Spawnable  Weapons to All Players every Spawn");
		StartServer_BattlePage_SetStatusBar2("If free-weapon(item) is off, the weapon will not be given to a player");
        return;

    case ID_G_FREESHOTGUN:						//508		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Allow Spawning of Shotgun in a Map");
		StartServer_BattlePage_SetStatusBar2("If off, the item will not spawn in a map");
        return;

    case ID_G_FREEPLASMAGUN:					//509		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Allow Spawning of Plasma Gun in a Map");
		StartServer_BattlePage_SetStatusBar2("If off, the item will not spawn in a map");
        return;

    case ID_G_FREEGRENADELAUNCHER:				//510		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Allow Spawning of Grenade Launcher in a Map");
		StartServer_BattlePage_SetStatusBar2("If off, the item will not spawn in a map");
		return;

    case ID_G_FREEROCKETLAUNCHER:				//511		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Allow Spawning of Rocket Launcher in a Map");
		StartServer_BattlePage_SetStatusBar2("If off, the item will not spawn in a map");
        return;

    case	ID_G_FREELIGHTNINGGUN:				//512		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Allow Spawning of Lightning Gun in a Map");
		StartServer_BattlePage_SetStatusBar2("If off, the item will not spawn in a map");
        return;

    case ID_G_FREERAILGUN:						//513		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Allow Spawning of RailGun in a Map");
		StartServer_BattlePage_SetStatusBar2("If off, the item will not spawn in a map");
		return;

    case ID_G_FREEBFG:							//514		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Allow Spawning of BFG in a Map");
		StartServer_BattlePage_SetStatusBar2("If off, the item will not spawn in a map");
        return;

    case ID_G_FREEHANDGRENADE:					//515		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Give a Free Hand Grenade(weapon item)");
		StartServer_BattlePage_SetStatusBar2("If off, the item will not spawn in a map");
        return;

    case ID_G_FREEMACHINEGUN:					//516		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Give a Free Machine Gun");
		StartServer_BattlePage_SetStatusBar2("If off, the item will not spawn in a map");
		return;

        /*case ID_G_FREEGAUNTLET:						//517		//(0 - 1)
        		StartServer_BattlePage_SetStatusBar("Give a Free Gauntlet");
				StartServer_BattlePage_SetStatusBar2("");
        		return;*/

        //Health Regen
    case ID_G_HEALTHRESTORE:						//518		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Health Restored at an Interval, Max health set by Gamemode option");
		StartServer_BattlePage_SetStatusBar2("If enabled Health items will be inhibited from spawning in a map");
        return;

    case ID_G_HEALTHRESTOREINTERVAL:			//519		//(in seconds:2)
        StartServer_BattlePage_SetStatusBar("Interval of the Health to Restore in seconds");
		StartServer_BattlePage_SetStatusBar2("Default is 2 seconds");
        return;

    case ID_G_HEALTHRESTORESTEP:					//520		//(10)
        StartServer_BattlePage_SetStatusBar("Amount of Health to Restore Per Interval");
		StartServer_BattlePage_SetStatusBar2("Default is 10 seconds");
        return;

    case ID_G_HEALTHRESTOREMAX:					//521		//(160)
        StartServer_BattlePage_SetStatusBar("Maximum Health Amount allowed to be restored");
		StartServer_BattlePage_SetStatusBar2("Default is 160");
        return;

        //Armor Regen
    case ID_G_ARMORRESTORE:						//522		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("If on Armor Restored at interval.");
		StartServer_BattlePage_SetStatusBar2("If enabled, Armor Items inhibited from spawning in maps");
        return;

    case ID_G_ARMORRESTOREINTERVAL:				//523		//(in seconds:5)
        StartServer_BattlePage_SetStatusBar("Interval in seconds for Armor to be Restored");
		StartServer_BattlePage_SetStatusBar2("(Default 5 seconds");
        return;

    case ID_G_ARMORRESTORESTEP:					//524		//(5)
        StartServer_BattlePage_SetStatusBar("Amount of Armor to be restored Per Interval");
		StartServer_BattlePage_SetStatusBar2("Default is 5 Armor regenerated");
        return;

    case ID_G_ARMORRESTOREMAX:					//525		//(120)
        StartServer_BattlePage_SetStatusBar("Maximum Amount of Armor to be Restored");
		StartServer_BattlePage_SetStatusBar2("Default is 120 Maximum Armor");
        return;

        //Ammo Regen
    case ID_G_AMMORESTORE:						//526		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Ammo Restored at Interval,");
		StartServer_BattlePage_SetStatusBar2("Ammo Pickup items will be inhibited spawning into a map");
        return;

    case ID_G_AMMORESTOREINTERVAL:				//527		//(in seconds)
        StartServer_BattlePage_SetStatusBar("Interval in seconds to restore ammo");
		StartServer_BattlePage_SetStatusBar2("");
        return;

        //Weapon Enhancements
    case ID_G_BATTLEWEAPONS:						//528		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("On - Quicker weapons switching/firing  will occur");
		StartServer_BattlePage_SetStatusBar2("Off - Default weapons switching/firing will occur");
        return;

    case ID_G_PARTIAILFRIENDLYFIRE:				//529		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("On - Partial friendly fire damage");
		StartServer_BattlePage_SetStatusBar2("In team games, partial damage is done to a team player");
        return;

    case ID_G_PARTIALFRIENDLYFIREFRACTION:		//530		//(in fractions 0.25)
        StartServer_BattlePage_SetStatusBar("Sets the Partial Friendly Fire Damage Rate");
		StartServer_BattlePage_SetStatusBar2("Fractional value of the whole damage value");
        return;

    case ID_G_WEAPONSTAY:						//531		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Weapons stay on maps after pickups, when free gear=\"off\"");
		StartServer_BattlePage_SetStatusBar2("if free-gear is enabled, this has no effect");
        return;

    case ID_G_TRIPLERAIL:						//532		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("RailGun will fire 3 rails instead of 1");
		StartServer_BattlePage_SetStatusBar2("Off Rail fires a single rail");
        return;

    case ID_G_BOUNCEPLASMA:						//533		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Plasma fire bounces off of walls");
		StartServer_BattlePage_SetStatusBar2("Plasma will bounce 4 times off of walls");
        return;

    case ID_G_NOBOUNCEHG:						//534		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("If set On, hand-grenades will explode on contact");
		StartServer_BattlePage_SetStatusBar2("Otherwise they will bounce");
        return;

    case ID_G_SUPERSHOTGUN:						//535		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Super Shotgun - fires 2 spread shots instead of 1");
		StartServer_BattlePage_SetStatusBar2("");
        return;

    case ID_G_SPLASHRAIL:						//536		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Turning this on will give the rail splash damage");
		StartServer_BattlePage_SetStatusBar2("Off, no splash will occur");
        return;

        //Grapple - movement

    case ID_G_GRAPPLEGLOBAL:						//537		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Grapple Control, If enabled, 1 of 2 grappletypes may be used");
		StartServer_BattlePage_SetStatusBar2("If disabled, no grapple will be used at all");
        return;

    case ID_G_GRAPPLEONHAND:
        StartServer_BattlePage_SetStatusBar("On= Weapon grapple, grapple treated as a weapon item used with +attack");
		StartServer_BattlePage_SetStatusBar2("Off= Offhand grapple, Global Grapple must be enabled for any grapple");
        return;

    case ID_G_GRAPPLEHOOKSPEED:					//538		//(Default:1150 - Battle:2025)
        StartServer_BattlePage_SetStatusBar("Off-hand or On-hand grapples hook speed");
		StartServer_BattlePage_SetStatusBar2("Recommended Speeds: Default:1150, Battle:2025");
        return;

    case ID_G_GRAPPLEPULLSPEED:					//539		//(Default:750 - Battle:550)
        StartServer_BattlePage_SetStatusBar("Off-hand or On-hand grapple pullspeed");
		StartServer_BattlePage_SetStatusBar2("Recommended Speeds: Default:750 - Battle:550");
        return;

    case ID_G_NOJUMPPADS:						//540		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("\"On\"=Disable jump pads in maps");
		StartServer_BattlePage_SetStatusBar2("");
        return;

    case ID_G_GRAPPLEENEMIES:					//541		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Allows Off-hand grapple to cling to enemy players");
		StartServer_BattlePage_SetStatusBar2("The grapple will allow you to be carried by Enemies");
        return;

    case ID_G_GRAPPLEBUDDIES:					//542		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Allows Off-hand grapple to cling to team players");
		StartServer_BattlePage_SetStatusBar2("The grapple will allow you to be carried by Team");
        return;

    case ID_G_SKYHOOK:							//543		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Allows grapple to cling to the sky");
		StartServer_BattlePage_SetStatusBar2("If off, no grapple can cling to the sky");
        return;

    case ID_G_HOOKNOGRAV:						//544		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Sets Off-hand grapple to use no gravity while pulling a player");
		StartServer_BattlePage_SetStatusBar2("");
        return;

    case ID_G_GRAPPLETYPE:						//545		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Sets the Off-hand grapple trail type used");
		StartServer_BattlePage_SetStatusBar2("1 of 5 types may be selected");
        return;

    case ID_G_GRAPPLETYPE2:
        StartServer_BattlePage_SetStatusBar("Sets the Weapon item grapple trail type used");
		StartServer_BattlePage_SetStatusBar2("1 of 3 types may be selected");
        return;


    case ID_G_RAMPJUMP:							//546		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Enable/disable special movement on inclined surfaces");
		StartServer_BattlePage_SetStatusBar2("");
        return;

    case ID_G_AIRMOVE:							//547		//(Default:10 - Battle:40)
        StartServer_BattlePage_SetStatusBar("Allows air movement while strafing or jumping");
		StartServer_BattlePage_SetStatusBar2("Recommended Speeds: Default:10, Battle:40");
        return;

    case ID_G_AIRSPEED:							//548		//(Default:320 - Battle:360)
        StartServer_BattlePage_SetStatusBar("Maximum player movement speed while in the air");
		StartServer_BattlePage_SetStatusBar2("Recommended Speeds: Default:320 - Battle:360");
        return;

    case ID_G_SPEED:								//549		//(Default:320 - Battle:360)
        StartServer_BattlePage_SetStatusBar("Maximum speed while a player may travel at while on the ground");
		StartServer_BattlePage_SetStatusBar2("Recommended Speeds: Default:320 - Battle:360");
        return;

    case ID_G_STRAFEJUMP:						//550		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("A Setting of On Allows Strafe jumping physics");
		StartServer_BattlePage_SetStatusBar2("or an alternative movement type is used in place of strafe jumping");
        return;

    case ID_G_GRAFTING:							//551		//(0 - 1)
        StartServer_BattlePage_SetStatusBar("Allows players to \"Roll\" over obstacles while using the Grapple");
		StartServer_BattlePage_SetStatusBar2("");
        return;

//    case ID_G_Q2HOOKSPEED:						//552		//(0 - 1)(1900,420)
//        StartServer_BattlePage_SetStatusBar("Sets the grapples to use Quake2 movement Speeds");
//        return;

//    case ID_BOT_GRAPPLE:
//        StartServer_BattlePage_SetStatusBar("Allow bots to grapple");
//        return;

    case  ID_G_SPAWNUSEENEMY:						//554		//g_spawnUseEnemy;
        StartServer_BattlePage_SetStatusBar("Allow Use of Enemy Spawn Locations during team games");
		StartServer_BattlePage_SetStatusBar2("");
        return;
    case  ID_G_SPAWNNOENEMYBASE:					//555		//vmCvar_t g_spawnNoEnemyBase;
        StartServer_BattlePage_SetStatusBar("If Enabled Do not Allow Spawning in Enemies Base");
		StartServer_BattlePage_SetStatusBar2("");
        return;
    case  ID_G_SPAWNNEARACTION:						//556		//vmCvar_t g_spawnNearAction;
        StartServer_BattlePage_SetStatusBar("Spawning Enabled Near Most Activity in Game");
		StartServer_BattlePage_SetStatusBar2("");
        return;
    case  ID_G_BATTLESPAWNING:						//557		//vmCvar_t g_battleSpawning;
        StartServer_BattlePage_SetStatusBar("Use both enemy and team spawns in game, ");
		StartServer_BattlePage_SetStatusBar2("Off uses Default Spawning");
        return;
    case ID_NO_FALLING:							//561		//NO FALL DAMAGE
        StartServer_BattlePage_SetStatusBar("On = No Falling Damage");
		StartServer_BattlePage_SetStatusBar2("");
        return;
    case ID_FIXED_FOV:							//562		//FOV 90
        StartServer_BattlePage_SetStatusBar("On = FOV set to default locked at 90");
		StartServer_BattlePage_SetStatusBar2("");
        return;
    case ID_NO_FOOTSTEPS:						//	563		//NO FOOTSTEPS
        StartServer_BattlePage_SetStatusBar("On = Footsteps not sounded for all players");
		StartServer_BattlePage_SetStatusBar2("");
        return;
    case ID_NO_PLATS:							//	564		//NO MOVER PLATS SPAWN IN MAPS
        StartServer_BattlePage_SetStatusBar("On = Disable the spawning of Func_plat items in maps");
		StartServer_BattlePage_SetStatusBar2("This may not get all platforms from being removed");
        return;
    case ID_NO_DOORS:							//	565		//NO DOORS SPAWN IN MAPS
        StartServer_BattlePage_SetStatusBar("On = Disable the spawn of doors in maps");
		StartServer_BattlePage_SetStatusBar2("Warning, some maps get hall of mirrors where doors were");
        return;	
	case ID_G_KNOCKBACKWEAPS:
		StartServer_BattlePage_SetStatusBar("On = All weapons produce a knockback when fired");
		StartServer_BattlePage_SetStatusBar2("Off - disables all weapons firing knockback");
		return;
    case ID_NO_IDPOWERUPS:						//566		//NO ID POWERUPS -- OVERRIDES UI SETTINGS
        StartServer_BattlePage_SetStatusBar("On = Disable spawning of ALL ID Powerups, Overrides the Items menu");
		StartServer_BattlePage_SetStatusBar2("ID powerups listed on the Items page");
        return;
    case ID_NO_HOLDABLES:						//	567		//NO HOLDABLE ITEMS SPAWN IN MAPS -- OVERRIDES UI SETTINGS
        StartServer_BattlePage_SetStatusBar("On = Disable spawning of all \"holdable\" items, Overrides Items menu");
		StartServer_BattlePage_SetStatusBar2("Holdable Items listed on the Items page");
        return;
	case ID_NO_CLIPAREA:
        StartServer_BattlePage_SetStatusBar("On = Disables player clip regions in a map");
		StartServer_BattlePage_SetStatusBar2("Off = Maps will block player movement in clip regions");
		return;
 	case ID_G_LETHALITY:
		StartServer_BattlePage_SetStatusBar("Sets lethality of damage");
		StartServer_BattlePage_SetStatusBar2("Default is 1");
		return;
	case ID_G_ALTBOUNCEWEAPS:
		StartServer_BattlePage_SetStatusBar("On= Certain weapons fire bounce off of walls");
		StartServer_BattlePage_SetStatusBar2("\"Smart bounce\" weaps wont bounce again if damaging others ");
		return;

    default:
        Com_Printf("Unknown Status Bar Option at id %i n", c->id);

    }
}







/*
=================
StartServer_BattlePage_InitSpinCtrl
=================
*/
static void StartServer_BattlePage_InitSpinCtrl(controlinit_t* c, int height) {
    spincontrol_t* s;

    if (s_battlecontrols.num_spin == MAX_BATTLE_SPIN_CONTROL) {
        Com_Printf("ServerPage: Max spin controls (%i) reached\n", s_battlecontrols.num_spin);
        return;
    }


    if (!c->number ) {//|| c->number != 0) {
        Com_Printf("Battle Page: Spin control (id:%i) has no data\n", c->id);
        return;
    }

    if (!c->itemnames) {
        Com_Printf("BattlePage: Spin control (id:%i) has no strings\n", c->id);
        return;
    }

    s = &s_battlecontrols.spin[s_battlecontrols.num_spin];

    s->init = c;

    s->control.generic.type		= MTYPE_SPINCONTROL;
    s->control.generic.name		= c->title;
    s->control.generic.id		= s_battlecontrols.num_spin;	// self reference
    s->control.generic.flags		= QMF_PULSEIFFOCUS|QMF_SMALLFONT|QMF_RIGHT_JUSTIFY;
    s->control.generic.callback	= StartServer_BattlePage_SpinEvent;
    s->control.generic.statusbar	= StartServer_BattlePage_ControlListStatusBar;
    s->control.generic.x			= CONTROL_POSX + 100;
    s->control.generic.y			= height;
    s->control.itemnames 			= c->itemnames;

    s->control.curvalue = *(c->number);

    // item is registered but we have to do the init here
    SpinControl_Init(&s->control);

    c->offset = s_battlecontrols.num_spin++;
}




/*
=================
StartServer_BattlePage_InitRadioCtrl
=================
*/
static void StartServer_BattlePage_InitRadioCtrl(controlinit_t* c, int height) {
    radiobuttoncontrol_t* r;

    if (s_battlecontrols.num_radio == MAX_BATTLE_RADIO_CONTROL) {
        Com_Printf("ServerPage: Max radio controls (%i) reached\n", s_battlecontrols.num_radio);
        return;
    }

    if (!c->number) {
        Com_Printf("ServerPage: Radio control (id:%i) has no data\n", c->id);
        return;
    }

    r = &s_battlecontrols.radio[s_battlecontrols.num_radio];

    r->init = c;

    r->control.generic.type		= MTYPE_RADIOBUTTON;
    r->control.generic.name		= c->title;
    r->control.generic.id		= s_battlecontrols.num_radio;	// self reference
    r->control.generic.flags		= QMF_PULSEIFFOCUS|QMF_SMALLFONT|QMF_RIGHT_JUSTIFY;
    r->control.generic.callback	= StartServer_BattlePage_RadioEvent;
    r->control.generic.statusbar	= StartServer_BattlePage_ControlListStatusBar;
    r->control.generic.x			= CONTROL_POSX + 100;
    r->control.generic.y			= height;

    r->control.curvalue = *(c->number);

    c->offset = s_battlecontrols.num_radio++;
}



/*
=================
StartServer_BattlePage_InitFieldCtrl
=================
*/
static void StartServer_BattlePage_InitFieldCtrl(controlinit_t* c, int height) {
    textfieldcontrol_t* f;
    int flags;

    if (s_battlecontrols.num_field == MAX_BATTLE_MFIELD_CONTROL) {
        Com_Printf("ServerPage: Max field controls (%i) reached\n", s_battlecontrols.num_field);
        return;
    }

    if (c->type == BTLCTRL_NUMFIELD && !c->number) {
        Com_Printf("ServerPage: NumField control (id:%i) has no data\n", c->id);
        return;
    }

    if (c->type == BTLCTRL_TEXTFIELD && !c->array) {
        Com_Printf("ServerPage: TextField control (id:%i) has no data\n", c->id);
        return;
    }

    f = &s_battlecontrols.field[s_battlecontrols.num_field];

    f->init = c;

    flags = QMF_SMALLFONT|QMF_PULSEIFFOCUS|QMF_RIGHT_JUSTIFY;
    if (c->type == BTLCTRL_NUMFIELD)
        flags |= QMF_NUMBERSONLY;

    f->control.generic.type			= MTYPE_FIELD;
    f->control.generic.name			= c->title;
    f->control.generic.id			= s_battlecontrols.num_field;	// self reference
    f->control.generic.callback		= StartServer_BattlePage_FieldEvent;
    f->control.generic.statusbar	= StartServer_BattlePage_ControlListStatusBar;
    f->control.generic.flags		= flags;
    f->control.generic.x			= CONTROL_POSX + 100;
    f->control.generic.y			= height;

    f->control.field.widthInChars = c->displaysize;
    f->control.field.maxchars     = c->arraysize;

    // setting of field is deferred until after init

    c->offset = s_battlecontrols.num_field++;
}




/*
=================
StartServer_BattlePage_InitControlList
=================
*/
static void StartServer_BattlePage_InitControlList(initlist_t* il) {
    int i;
    int offset;
    controlinit_t* list;
    controlinit_t* c;
    textfieldcontrol_t* f;
    int size;
    qboolean teamGame;

    list = il->list;
    size = il->count;

    teamGame = qfalse;
    if (s_scriptdata.gametype >= GT_TEAM)
        teamGame = qtrue;

    offset = 0;	// relative to top of list
    for (i = 0; i < size; i++) {
        if (teamGame && (list[i].flags & ITEM_NOTEAM_GAME))
            continue;
        if (!teamGame && (list[i].flags & ITEM_TEAM_GAME))
            continue;

        switch (list[i].type) {
        case BTLCTRL_SPIN:
            StartServer_BattlePage_InitSpinCtrl(&list[i], offset);
            break;
        case BTLCTRL_RADIO:
            StartServer_BattlePage_InitRadioCtrl(&list[i], offset);
            break;
        case BTLCTRL_TEXTFIELD:
        case BTLCTRL_NUMFIELD:
            StartServer_BattlePage_InitFieldCtrl(&list[i], offset);
            break;
        case BTLCTRL_BLANK:
            break;
        }

        offset += LINE_HEIGHT;

        if (list[i].flags & ITEM_HALFGAP)
            offset += (LINE_HEIGHT/2);
    }

    // move all controls to middle of screen and init them
    offset = TABCONTROLCENTER_Y - offset/2;
    for (i = 0; i < s_battlecontrols.num_radio; i++) {
        s_battlecontrols.radio[i].control.generic.y += offset;

        // item is registered but we have to do the init here
        RadioButton_Init(&s_battlecontrols.radio[i].control);
    }

    for (i = 0; i < s_battlecontrols.num_field; i++) {
        c = s_battlecontrols.field[i].init;
        f = &s_battlecontrols.field[i];

        f->control.generic.y += offset;

        // item is registered but we have to do the init here
        MenuField_Init(&f->control);

        // deferred init because MenuField_Init() clears text
        if (c->type == BTLCTRL_NUMFIELD) {
            Q_strncpyz(f->control.field.buffer, va("%i", *c->number), c->arraysize);
        } else if (c->type == BTLCTRL_TEXTFIELD) {
            Q_strncpyz(f->control.field.buffer, c->array, c->arraysize);
        }
    }

    for (i = 0; i < s_battlecontrols.num_spin; i++) {
        s_battlecontrols.spin[i].control.generic.y += offset;

        // item is registered but we have to do the init here
        SpinControl_Init(&s_battlecontrols.spin[i].control);
    }
}




/*
=================
StartServer_BattlePage_SetTab
=================
*/
static void StartServer_BattlePage_SetTab( int tab ) {
    int i, index;
    //	initlist_t* controlList;

    if (tab == -1) {
        index = s_battlecontrols.activePage;
    } else {
        index = -1;
        for (i = 0; i < s_battlecontrols.pageListSize; i++) {
            if (s_battlecontrols.pageList[i].menutext->generic.id == tab) {
                index = i;
                break;
            }
        }
    }

    // walk all controls and mark them hidden
    for (i = 0; i < s_battlecontrols.num_radio; i++) {
        StartServer_BattlePage_SetControlState(&s_battlecontrols.radio[i].control.generic, QMF_HIDDEN);
    }

    for (i = 0; i < s_battlecontrols.num_field; i++) {
        StartServer_BattlePage_SetControlState(&s_battlecontrols.field[i].control.generic, QMF_HIDDEN);
    }

    for (i = 0; i < s_battlecontrols.num_spin; i++) {
        StartServer_BattlePage_SetControlState(&s_battlecontrols.spin[i].control.generic, QMF_HIDDEN);
    }

    if (index == -1) {
        Com_Printf("Battle tab: unknown index (%i)\n", tab);
        return;
    }

    // set the controls for the current tab
    s_battlecontrols.activePage = index;
    s_battlecontrols.num_radio = 0;
    s_battlecontrols.num_field = 0;
    s_battlecontrols.num_spin = 0;

    StartServer_BattlePage_InitControlList(&s_battlecontrols.pageList[index]);

    // brighten active tab control, remove pulse effect
    for (i = 0; i < s_battlecontrols.pageListSize; i++) {
        s_battlecontrols.pageList[i].menutext->generic.flags &= ~(QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS);
        s_battlecontrols.pageList[i].menutext->generic.flags |= QMF_PULSEIFFOCUS;
    }

    s_battlecontrols.pageList[index].menutext->generic.flags |= (QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS);
    s_battlecontrols.pageList[index].menutext->generic.flags &= ~(QMF_PULSEIFFOCUS);
}




/*
=================
StartServer_BattlePage_InitControlsFromScript
=================
*/
static void StartServer_BattlePage_InitControlsFromScript( int tab ) {
    //	int i;
    //	radiobuttoncontrol_t* r;
    //	textfieldcontrol_t* t;
    //	spincontrol_t* s;

    StartServer_BattlePage_SetTab(tab);

    // set hostname
    // Q_strncpyz(s_battlecontrols.hostname.field.buffer, s_scriptdata.server.hostname, MAX_HOSTNAME_LENGTH);
}




/*
=================
StartServer_BattlePage_Load
=================
*/
static void StartServer_BattlePage_Load( void ) {
    s_battlecontrols.gameType.curvalue = gametype_remap2[s_scriptdata.gametype];
    s_battlecontrols.configtype.curvalue = s_scriptdata.battle.configtype;
    StartServer_BattlePage_InitControlsFromScript(-1);
}





/*
=================
StartServer_BattlePage_CommonEvent
=================
*/
static void StartServer_BattlePage_CommonEvent( void* ptr, int event ) {
    if( event != QM_ACTIVATED ) {
        return;
    }

    StartServer_BattlePage_Save();
    switch( ((menucommon_s*)ptr)->id ) {

    case ID_SERVERCOMMON_SERVER:
        StartServer_ServerPage_MenuInit();
        break;

    case ID_SERVERCOMMON_ITEMS:
        UI_PopMenu();
        break;

    case ID_SERVERCOMMON_BOTS:
        UI_PopMenu();
        UI_PopMenu();
        break;

    case ID_SERVERCOMMON_MAPS:
        UI_PopMenu();
        UI_PopMenu();
        UI_PopMenu();
        break;

    case ID_SERVERCOMMON_BACK:
        UI_PopMenu();
        UI_PopMenu();
        UI_PopMenu();
        UI_PopMenu();
        break;

    case ID_SERVERCOMMON_FIGHT:
        StartServer_CreateServer(NULL);
        break;
    }
}



/*
=================
StartServer_BattlePage_DrawStatusBarText
=================
*/
static void StartServer_BattlePage_DrawStatusBarText( void ) {
    vec4_t color;
    int fade;
    float fadecol;

    if (uis.realtime > s_battlecontrols.savetime)
        return;

    if (!s_battlecontrols.statusbar_message[0])
        return;

    fade = s_battlecontrols.savetime - uis.realtime;

    fadecol = (float)fade/STATUSBAR_FADETIME;

    color[0] = 1.0;
    color[1] = 1.0;
    color[2] = 1.0;
    color[3] = fadecol;

    UI_DrawString(320, s_battlecontrols.statusbar_height,
                  s_battlecontrols.statusbar_message, UI_CENTER|UI_SMALLFONT, color);
}


/*
=================
StartServer_BattlePage_DrawStatusBarText
=================
*/
static void StartServer_BattlePage_DrawStatusBarText2( void ) {
    vec4_t color;
    int fade;
    float fadecol;

    if (uis.realtime > s_battlecontrols.savetime2)
        return;

    if (!s_battlecontrols.statusbar_message2[0])
        return;

    fade = s_battlecontrols.savetime2 - uis.realtime;

    fadecol = (float)fade/STATUSBAR_FADETIME;

    color[0] = 1.0;
    color[1] = 1.0;
    color[2] = 1.0;
    color[3] = fadecol;

    UI_DrawString(320, s_battlecontrols.statusbar_height2,
                  s_battlecontrols.statusbar_message2, UI_CENTER|UI_SMALLFONT, color);
}


/*
=================
StartServer_BattlePage_MenuKey
=================
*/
static sfxHandle_t StartServer_BattlePage_MenuKey( int key ) {
    switch (key) {
    case K_MOUSE2:
    case K_ESCAPE:
        StartServer_BattlePage_Save();
        UI_PopMenu();
        UI_PopMenu();
        UI_PopMenu();
        UI_PopMenu();//INCIN
        //UI_PopMenu();//INCIN
        //UI_PopMenu();//INCIN
        break;
    }

    return ( Menu_DefaultKey( &s_battlecontrols.menu, key ) );
}





/*
=================
StartServer_BattlePage_SaveScript
=================
 
static qboolean StartServer_BattlePage_SaveScript( const char* filename ) {
    UI_PopMenu();
    if (StartServer_CreateServer( filename )) {
        StartServer_BattlePage_SetStatusBar("Saved!");
        return qtrue;
    } else {
        StartServer_BattlePage_SetStatusBar(StartServer_GetLastScriptError());
        return qfalse;
    }
}
*/

/*
=================
StartServer_BattlePage_LoadScript
=================
 
static qboolean StartServer_BattlePage_LoadScript( const char* filename ) {
    UI_PopMenu();
 
    if (StartServer_LoadFromConfig(filename)) {
        // so far we've only loaded the cvars, now we need
        // to refresh the stored data
        StartServer_LoadScriptDataFromType(s_scriptdata.gametype);
 
        StartServer_BattlePage_Load();
        StartServer_BattlePage_UpdateInterface();
 
        StartServer_BattlePage_SetStatusBar("Loaded!");
    }
    return qtrue;
}
*/
void EnableAllItemsList(void);

void SetExpertQ2StyleGame(void);
void SetBattleStyleGame(void);
void SetDefaultStyleGame(void);

void SetDefaultStyleGame(void) {
    //	s_scriptdata.battle.bot_grapple = 1;
    s_scriptdata.battle.g_airMove = 10;
    s_scriptdata.battle.g_airSpeed = 360;

    s_scriptdata.battle.g_ammoRestore = 0;
    s_scriptdata.battle.g_ammoRestoreInterval = 2;
    s_scriptdata.battle.g_armorRestore = 0;
    s_scriptdata.battle.g_armorRestoreInterval = 5;
    s_scriptdata.battle.g_armorRestoreMax = 200;
    s_scriptdata.battle.g_armorRestoreStep = 10;
    s_scriptdata.battle.g_battlePowerups = 1;
    s_scriptdata.battle.g_battleSpawning = 0;

    s_scriptdata.battle.g_battleWeapons = 0;
    s_scriptdata.battle.g_bouncePlasma = 0;
//    s_scriptdata.battle.g_countdown = 0;
    s_scriptdata.battle.g_countPVS = 0;

    s_scriptdata.battle.g_damageRegen = 0;
    s_scriptdata.battle.g_damageScoring = 0;

    s_scriptdata.battle.g_freeGear = 0;
    s_scriptdata.battle.g_freeBFG = 1;
    s_scriptdata.battle.g_freeGrenadeLauncher = 1;
    s_scriptdata.battle.g_freeHandgrenade = 0;
    s_scriptdata.battle.g_freeLightningGun = 1;
    s_scriptdata.battle.g_freePlasmaGun = 1;
    s_scriptdata.battle.g_freeRailgun = 1;
    s_scriptdata.battle.g_freeRocketLauncher = 1;
    s_scriptdata.battle.g_freeShotgun = 1;
	s_scriptdata.battle.g_freeMachinegun = 1;


    s_scriptdata.battle.g_gamemode = 0;
    s_scriptdata.battle.g_grafting = 1;
    s_scriptdata.battle.g_grappleBuddies = 1;
    s_scriptdata.battle.g_grappleEnemies = 1;
    s_scriptdata.battle.g_grappleGlobal = 1;
    s_scriptdata.battle.g_grappleHookSpeed = 1150;
    s_scriptdata.battle.g_grappleOnHand = 1;
    s_scriptdata.battle.g_grapplePullSpeed = 550;
    s_scriptdata.battle.g_grappleType = 3;
    s_scriptdata.battle.g_grappleType2 = 1;

    s_scriptdata.battle.g_healthRestore = 0;
    s_scriptdata.battle.g_healthRestoreInterval = 2;
    s_scriptdata.battle.g_healthRestoreMax = 200;
    s_scriptdata.battle.g_healthRestoreStep = 5;

    s_scriptdata.battle.g_hookNoGrav = 1;
    s_scriptdata.battle.g_nobounceHG = 0;
    s_scriptdata.battle.g_nojumppads = 0;
    s_scriptdata.battle.g_partialFriendlyFire = 0;
    s_scriptdata.battle.g_partialFriendlyFireFraction = 0;
//    s_scriptdata.battle.g_q2HookSpeed = 0;
    s_scriptdata.battle.g_rampJump = 1;
//    s_scriptdata.battle.g_replacePowerup = 1;
    s_scriptdata.battle.g_skyHook = 0;
    s_scriptdata.battle.g_spawnNearAction = 0;
    s_scriptdata.battle.g_spawnNoEnemyBase = 1;
    s_scriptdata.battle.g_spawnUseEnemy = 0;
    s_scriptdata.battle.g_speed = 320;
    s_scriptdata.battle.g_splashRail = 0;
    s_scriptdata.battle.g_strafeJump = 1;
    s_scriptdata.battle.g_superShotgun = 0;
    s_scriptdata.battle.g_tripleRail = 0;
    s_scriptdata.battle.g_weaponsStay = 0;
    s_scriptdata.battle.g_dmflags = 0;
    s_scriptdata.battle.nofalling = 1;		//0 or 8
    s_scriptdata.battle.fixedfov = 0;		//0 or 16
    s_scriptdata.battle.nofootsteps = 0;	//0 or 32
    s_scriptdata.battle.noplats = 0;		//0 or 64
    s_scriptdata.battle.nodoors = 0;		//0 or 128
    s_scriptdata.battle.noidpowerups= 0;	//0 or 256
    s_scriptdata.battle.noholdables = 0;	//0 or 512
	s_scriptdata.battle.no_clipareas = 0;
	s_scriptdata.battle.g_lethality = 1;	//clamp 1 to 99
	s_scriptdata.battle.g_altbounceweaps = 0; //0 1 
	s_scriptdata.battle.g_knockbackweaps = 0;; //0 1

    //dmflags 8
    //set bot_enable 1
    //set g_spskill 5
    //set bot_minplayers 11
    //set capturelimit 7
    //set fraglimit 30
    //set sv_maxclients 20
    //set sv_privateClients 2
    //set g_allowvote 1
    //set g_inactivity 600
    //set g_warmup 30
    //set timelimit 40
    //g_friendlyFire 0

    StartServer_BattlePage_UpdateInterface();
    UI_PushMenu( &s_battlecontrols.menu );
    Com_Printf("Vanilla Q3 Style Game Set\n");
    //	StartServer_BattlePage_UpdateInterface();
    EnableAllItemsList();
}



void EnableAllItemsList(void) {
    char* s;
    char buffer[256];
    char* ptr, *ptr_last;
    int i;

    s = gametype_cvar_base[ gametype_remap2[s_scriptdata.gametype] ];

    // load the group on/off/custom values
    memset(buffer,0,sizeof(buffer));
    UIE_GetSkirmishCvar(s, "itemGroups", buffer, 256);
    ptr = buffer;
    for (i = 0; i < ITEMGROUP_COUNT; i++) {
        if (*ptr) {
            s_scriptdata.item.groupstate[i] = ALLGROUPS_ENABLED;
        }
    }

    // load individual item values
    // we only load a list of items that are "off"
    // no assumption about order is made
    for (i = 0; i < ITEM_COUNT; i++) {
        s_scriptdata.item.enabled[i] = qtrue;
    }

    memset(buffer, 0, sizeof(buffer));
    UIE_GetSkirmishCvar(s, "itemsHidden", buffer, 256);
    ptr = buffer;
    while (*ptr) {
        ptr_last = strchr(ptr, '\\');

        if (!ptr_last)
            break;

        *ptr_last = '\0';
        for (i = 0; i < ITEM_COUNT; i++) {
            if (!Q_stricmp(ptr, server_itemlist[i].shortitem)) {
                s_scriptdata.item.enabled[i] = qfalse;
                break;
            }

        }

        // move to next char
        ptr = ptr_last + 1;
    }
}

void SetBattleStyleGame(void) {
    //	s_scriptdata.battle.bot_grapple = 1;
    s_scriptdata.battle.g_airMove = 10;
    s_scriptdata.battle.g_airSpeed = 360;

    s_scriptdata.battle.g_ammoRestore = 1;
    s_scriptdata.battle.g_ammoRestoreInterval = 2;
    s_scriptdata.battle.g_armorRestore = 1;
    s_scriptdata.battle.g_armorRestoreInterval = 1;
    s_scriptdata.battle.g_armorRestoreMax = 120;
    s_scriptdata.battle.g_armorRestoreStep = 5;
    s_scriptdata.battle.g_battlePowerups = 0;
    s_scriptdata.battle.g_battleSpawning = 1;

    s_scriptdata.battle.g_battleWeapons = 1;
    s_scriptdata.battle.g_bouncePlasma = 1;
//    s_scriptdata.battle.g_countdown = 0;
    s_scriptdata.battle.g_countPVS = 1;


    s_scriptdata.battle.g_damageRegen = 1;
    s_scriptdata.battle.g_damageScoring = 1;

    s_scriptdata.battle.g_freeGear = 1;
    s_scriptdata.battle.g_freeBFG = 1;
    s_scriptdata.battle.g_freeGrenadeLauncher = 1;
    s_scriptdata.battle.g_freeHandgrenade = 1;
    s_scriptdata.battle.g_freeLightningGun = 1;
    s_scriptdata.battle.g_freePlasmaGun = 1;
    s_scriptdata.battle.g_freeRailgun = 1;
    s_scriptdata.battle.g_freeRocketLauncher = 1;
    s_scriptdata.battle.g_freeShotgun = 1;
	s_scriptdata.battle.g_freeMachinegun = 1;

    s_scriptdata.battle.g_gamemode = 1;
    s_scriptdata.battle.g_grafting = 1;
    s_scriptdata.battle.g_grappleBuddies = 1;
    s_scriptdata.battle.g_grappleEnemies = 1;
    s_scriptdata.battle.g_grappleGlobal = 1;
    s_scriptdata.battle.g_grappleHookSpeed = 2025;
    s_scriptdata.battle.g_grappleOnHand = 0;
    s_scriptdata.battle.g_grapplePullSpeed = 550;
    s_scriptdata.battle.g_grappleType = 4;
    s_scriptdata.battle.g_grappleType2 = 0;

    s_scriptdata.battle.g_healthRestore = 1;
    s_scriptdata.battle.g_healthRestoreInterval = 1;
    s_scriptdata.battle.g_healthRestoreMax = 160;
    s_scriptdata.battle.g_healthRestoreStep = 5;

    s_scriptdata.battle.g_hookNoGrav = 0;
    s_scriptdata.battle.g_nobounceHG = 0;
    s_scriptdata.battle.g_nojumppads = 1;
    s_scriptdata.battle.g_partialFriendlyFire = 0;
    s_scriptdata.battle.g_partialFriendlyFireFraction = 0;
//    s_scriptdata.battle.g_q2HookSpeed = 0;
    s_scriptdata.battle.g_rampJump = 1;
//    s_scriptdata.battle.g_replacePowerup = 0;
    s_scriptdata.battle.g_skyHook = 1;
    s_scriptdata.battle.g_spawnNearAction = 1;
    s_scriptdata.battle.g_spawnNoEnemyBase = 0;
    s_scriptdata.battle.g_spawnUseEnemy = 1;
    s_scriptdata.battle.g_speed = 360;
    s_scriptdata.battle.g_splashRail = 1;
    s_scriptdata.battle.g_strafeJump = 1;
    s_scriptdata.battle.g_superShotgun = 1;
    s_scriptdata.battle.g_tripleRail = 1;
    s_scriptdata.battle.g_weaponsStay = 1;
    //s_scriptdata.battle.g_dmflags = 1014;
    s_scriptdata.battle.nofalling = 1;		//0 or 8
    s_scriptdata.battle.fixedfov = 0;		//0 or 16
    s_scriptdata.battle.nofootsteps = 1;	//0 or 32
    s_scriptdata.battle.noplats = 1;		//0 or 64
    s_scriptdata.battle.nodoors = 0;		//0 or 128	
    s_scriptdata.battle.noidpowerups= 1;	//0 or 256
    s_scriptdata.battle.noholdables = 1;	//0 or 512
	s_scriptdata.battle.no_clipareas =0;

	s_scriptdata.battle.g_lethality = 1;	//clamp 1 to 99
	s_scriptdata.battle.g_altbounceweaps = 1; //0 1 
	s_scriptdata.battle.g_knockbackweaps = 1;; //0 1
    //dmflags 8
    //set bot_enable 1
    //set g_spskill 5
    //set bot_minplayers 11
    //set capturelimit 7
    //set fraglimit 30
    //set sv_maxclients 20
    //set sv_privateClients 2
    //set g_allowvote 1
    //set g_inactivity 600
    //set g_warmup 30
    //set timelimit 40
    //g_friendlyFire 0

    StartServer_BattlePage_UpdateInterface();
    UI_PushMenu( &s_battlecontrols.menu );
    Com_Printf("Battle Style Game Set\n");
    EnableAllItemsList();
}
void RemoveAllItemsList(void);
//extern *s_itemcontrols;

void SetExpertQ2StyleGame(void) {

    //	s_scriptdata.battle.bot_grapple = 1;
    s_scriptdata.battle.g_airMove = 30;
    s_scriptdata.battle.g_airSpeed = 360;

    s_scriptdata.battle.g_ammoRestore = 1;
    s_scriptdata.battle.g_ammoRestoreInterval = 2;
    s_scriptdata.battle.g_armorRestore = 0;
    s_scriptdata.battle.g_armorRestoreInterval = 2;
    s_scriptdata.battle.g_armorRestoreMax = 120;
    s_scriptdata.battle.g_armorRestoreStep = 5;
    s_scriptdata.battle.g_battlePowerups = 0;
    s_scriptdata.battle.g_battleSpawning = 1;

    s_scriptdata.battle.g_battleWeapons = 1;
    s_scriptdata.battle.g_bouncePlasma = 0;
//    s_scriptdata.battle.g_countdown = 0;
    s_scriptdata.battle.g_countPVS = 1;

    s_scriptdata.battle.g_damageRegen = 1;
    s_scriptdata.battle.g_damageScoring = 1;

    s_scriptdata.battle.g_freeGear = 1;
    s_scriptdata.battle.g_freeBFG = 0;
    s_scriptdata.battle.g_freeGrenadeLauncher = 1;
    s_scriptdata.battle.g_freeHandgrenade = 1;
    s_scriptdata.battle.g_freeLightningGun = 0;
    s_scriptdata.battle.g_freePlasmaGun = 1;
    s_scriptdata.battle.g_freeRailgun = 1;
    s_scriptdata.battle.g_freeRocketLauncher = 1;
    s_scriptdata.battle.g_freeShotgun = 1;
	s_scriptdata.battle.g_freeMachinegun = 1;

    s_scriptdata.battle.g_gamemode = 1;
    s_scriptdata.battle.g_grafting = 1;
    s_scriptdata.battle.g_grappleBuddies = 1;
    s_scriptdata.battle.g_grappleEnemies = 1;
    s_scriptdata.battle.g_grappleGlobal = 1;
    s_scriptdata.battle.g_grappleHookSpeed = 2025;
    s_scriptdata.battle.g_grappleOnHand = 0;
    s_scriptdata.battle.g_grapplePullSpeed = 550;
    s_scriptdata.battle.g_grappleType = 2;
    s_scriptdata.battle.g_grappleType2 = 0;

    s_scriptdata.battle.g_healthRestore = 1;
    s_scriptdata.battle.g_healthRestoreInterval = 2;
    s_scriptdata.battle.g_healthRestoreMax = 160;
    s_scriptdata.battle.g_healthRestoreStep = 5;

    s_scriptdata.battle.g_hookNoGrav = 1;
    s_scriptdata.battle.g_nobounceHG = 0;
    s_scriptdata.battle.g_nojumppads = 1;
    s_scriptdata.battle.g_partialFriendlyFire = 0;
    s_scriptdata.battle.g_partialFriendlyFireFraction = 0;
//    s_scriptdata.battle.g_q2HookSpeed = 1;
    s_scriptdata.battle.g_rampJump = 1;
//    s_scriptdata.battle.g_replacePowerup = 0;
    s_scriptdata.battle.g_skyHook = 1;
    s_scriptdata.battle.g_spawnNearAction = 0;
    s_scriptdata.battle.g_spawnNoEnemyBase = 1;
    s_scriptdata.battle.g_spawnUseEnemy = 1;
    s_scriptdata.battle.g_speed = 360;
    s_scriptdata.battle.g_splashRail = 0;
    s_scriptdata.battle.g_strafeJump = 1;
    s_scriptdata.battle.g_superShotgun = 1;
    s_scriptdata.battle.g_tripleRail = 1;
    s_scriptdata.battle.g_weaponsStay = 0;
    //s_scriptdata.battle.g_dmflags = 1014;
    s_scriptdata.battle.nofalling = 1;		//0 or 8
    s_scriptdata.battle.fixedfov = 0;		//0 or 16
    s_scriptdata.battle.nofootsteps = 0;	//0 or 32
    s_scriptdata.battle.noplats = 1;		//0 or 64
    s_scriptdata.battle.nodoors = 0;		//0 or 128
    s_scriptdata.battle.noidpowerups= 1;	//0 or 256
    s_scriptdata.battle.noholdables = 1;	//0 or 512
	s_scriptdata.battle.no_clipareas = 1;	// 0 or 1024
	s_scriptdata.battle.g_lethality = 1;	//clamp 1 to 99
	s_scriptdata.battle.g_altbounceweaps = 0; //0 1 
	s_scriptdata.battle.g_knockbackweaps = 0;; //0 1
    //dmflags 8
    //set bot_enable 1
    //set g_spskill 5
    //set bot_minplayers 11
    //set capturelimit 7
    //set fraglimit 30
    //set sv_maxclients 20
    //set sv_privateClients 2
    //set g_allowvote 1
    //set g_inactivity 600
    //set g_warmup 30
    //set timelimit 40
    //g_friendlyFire 0

    StartServer_BattlePage_UpdateInterface();
    UI_PushMenu( &s_battlecontrols.menu );
    Com_Printf("Expert Q2 Style Game Set\n");
    //	StartServer_BattlePage_UpdateInterface();

    RemoveAllItemsList();
    //	UI_PushMenu( *s_itemcontrols.menu );

}

void SetLethalityInstagibStyle(void){
	//	s_scriptdata.battle.bot_grapple = 1;
    s_scriptdata.battle.g_airMove = 20;
    s_scriptdata.battle.g_airSpeed = 360;

    s_scriptdata.battle.g_ammoRestore = 1;
    s_scriptdata.battle.g_ammoRestoreInterval = 1;
    s_scriptdata.battle.g_armorRestore = 0;
    s_scriptdata.battle.g_armorRestoreInterval = 0;
    s_scriptdata.battle.g_armorRestoreMax = 120;
    s_scriptdata.battle.g_armorRestoreStep = 5;
    s_scriptdata.battle.g_battlePowerups = 0;
    s_scriptdata.battle.g_battleSpawning = 1;

    s_scriptdata.battle.g_battleWeapons = 1;
    s_scriptdata.battle.g_bouncePlasma = 0;
//    s_scriptdata.battle.g_countdown = 0;
    s_scriptdata.battle.g_countPVS = 0;


    s_scriptdata.battle.g_damageRegen = 0;
    s_scriptdata.battle.g_damageScoring = 1;

    s_scriptdata.battle.g_freeGear = 1;
    s_scriptdata.battle.g_freeBFG = 0;
    s_scriptdata.battle.g_freeGrenadeLauncher = 0;
    s_scriptdata.battle.g_freeHandgrenade = 0;
    s_scriptdata.battle.g_freeLightningGun = 0;
    s_scriptdata.battle.g_freePlasmaGun = 0;
    s_scriptdata.battle.g_freeRailgun = 1;
    s_scriptdata.battle.g_freeRocketLauncher = 0;
    s_scriptdata.battle.g_freeShotgun = 0;
	s_scriptdata.battle.g_freeMachinegun = 0;

    s_scriptdata.battle.g_gamemode = 1;
    s_scriptdata.battle.g_grafting = 1;
    s_scriptdata.battle.g_grappleBuddies = 1;
    s_scriptdata.battle.g_grappleEnemies = 1;
    s_scriptdata.battle.g_grappleGlobal = 1;
    s_scriptdata.battle.g_grappleHookSpeed = 2025;
    s_scriptdata.battle.g_grappleOnHand = 0;
    s_scriptdata.battle.g_grapplePullSpeed = 550;
    s_scriptdata.battle.g_grappleType = 4;
    s_scriptdata.battle.g_grappleType2 = 0;

    s_scriptdata.battle.g_healthRestore = 0;
    s_scriptdata.battle.g_healthRestoreInterval = 1;
    s_scriptdata.battle.g_healthRestoreMax = 160;
    s_scriptdata.battle.g_healthRestoreStep = 5;

    s_scriptdata.battle.g_hookNoGrav = 1;
    s_scriptdata.battle.g_nobounceHG = 1;
    s_scriptdata.battle.g_nojumppads = 0;
    s_scriptdata.battle.g_partialFriendlyFire = 0;
    s_scriptdata.battle.g_partialFriendlyFireFraction = 0;
//    s_scriptdata.battle.g_q2HookSpeed = 0;
    s_scriptdata.battle.g_rampJump = 1;
//    s_scriptdata.battle.g_replacePowerup = 0;
    s_scriptdata.battle.g_skyHook = 1;
    s_scriptdata.battle.g_spawnNearAction = 1;
    s_scriptdata.battle.g_spawnNoEnemyBase = 0;
    s_scriptdata.battle.g_spawnUseEnemy = 1;
    s_scriptdata.battle.g_speed = 360;
    s_scriptdata.battle.g_splashRail = 0;
    s_scriptdata.battle.g_strafeJump = 1;
    s_scriptdata.battle.g_superShotgun = 1;
    s_scriptdata.battle.g_tripleRail = 0;
    s_scriptdata.battle.g_weaponsStay = 0;
    //s_scriptdata.battle.g_dmflags = 1014;
    s_scriptdata.battle.nofalling = 1;		//0 or 8
    s_scriptdata.battle.fixedfov = 0;		//0 or 16
    s_scriptdata.battle.nofootsteps = 0;	//0 or 32
    s_scriptdata.battle.noplats = 1;		//0 or 64
    s_scriptdata.battle.nodoors = 0;
	s_scriptdata.battle.no_clipareas = 0;
    ;		//0 or 128
    s_scriptdata.battle.noidpowerups= 1;	//0 or 256
    s_scriptdata.battle.noholdables = 1;	//0 or 512

	s_scriptdata.battle.g_lethality = 99;	//clamp 1 to 99
	s_scriptdata.battle.g_altbounceweaps = 0; //0 1 
	s_scriptdata.battle.g_knockbackweaps = 0;; //0 1

	StartServer_BattlePage_UpdateInterface();
    UI_PushMenu( &s_battlecontrols.menu );
    Com_Printf("Battle Style Game Set\n");
	RemoveAllItemsList();
    //EnableAllItemsList();
}

void RemoveAllItemsList(void) {
    char* s;
    char buffer[256];
    char* ptr, *ptr_last;
    int i;

    s = gametype_cvar_base[ gametype_remap2[s_scriptdata.gametype] ];

    // load the group on/off/custom values
    memset(buffer,0,sizeof(buffer));
    UIE_GetSkirmishCvar(s, "itemGroups", buffer, 256);
    ptr = buffer;
    for (i = 0; i < ITEMGROUP_COUNT; i++) {
        if (*ptr) {
            s_scriptdata.item.groupstate[i] = ALLGROUPS_HIDDEN;
        }
    }

    // load individual item values
    // we only load a list of items that are "off"
    // no assumption about order is made
    for (i = 0; i < ITEM_COUNT; i++) {
        s_scriptdata.item.enabled[i] = qfalse;
    }

    memset(buffer, 0, sizeof(buffer));
    UIE_GetSkirmishCvar(s, "itemsHidden", buffer, 256);
    ptr = buffer;
    while (*ptr) {
        ptr_last = strchr(ptr, '\\');

        if (!ptr_last)
            break;

        *ptr_last = '\0';
        for (i = 0; i < ITEM_COUNT; i++) {
            if (!Q_stricmp(ptr, server_itemlist[i].shortitem)) {
                s_scriptdata.item.enabled[i] = qfalse;
                break;
            }

        }

        // move to next char
        ptr = ptr_last + 1;
    }
}


/*
=================
StartServer_BattlePage_Event
=================
*/
void StartServer_LoadBattleScriptData( void);
static void StartServer_BattlePage_Event( void* ptr, int event ) {
    //	int value;
    int id;


    id = ((menucommon_s*)ptr)->id;
    switch (id) {

    case ID_BATTLE_GAMETYPE:
        if( event != QM_ACTIVATED ) {
            return;
        }

        StartServer_SaveScriptData();
        StartServer_LoadScriptDataFromType(gametype_remap[s_battlecontrols.gameType.curvalue]);

        StartServer_BattlePage_InitControlsFromScript(-1);	// gametype is already accurate
        StartServer_BattlePage_UpdateInterface();
        break;

    case ID_BATTLE_CONFIGTYPE:
        if( event != QM_ACTIVATED ) {
            return;
        }
        //"Custom", "Default Style", "Battle Style" ,"Expert Q2 Style" , "Lethality Instagib", 0
        if(s_battlecontrols.configtype.curvalue == 0) {
            StartServer_LoadBattleScriptData();
            s_scriptdata.battle.configtype = 0;
            EnableAllItemsList();
            UI_PushMenu( &s_battlecontrols.menu );
        } else if(s_battlecontrols.configtype.curvalue == 1) {
            SetDefaultStyleGame();
            s_scriptdata.battle.configtype = 1;

        } else if(s_battlecontrols.configtype.curvalue == 2) {
            SetBattleStyleGame();
            s_scriptdata.battle.configtype = 2;
        } else if(s_battlecontrols.configtype.curvalue == 3) {
            SetExpertQ2StyleGame();
            s_scriptdata.battle.configtype = 3;
		} else if(s_battlecontrols.configtype.curvalue == 4) {
			SetLethalityInstagibStyle();
			s_scriptdata.battle.configtype = 4;
		}

        break;

    case ID_GAMEMODE:					//200	GAMEMODE	and options
    case ID_WEAPONCONTROL:				//201	WEAPONS CONTROLS FREEGEAR
    case ID_REGENERATIONS:				//202	Health_Regen
    case ID_WEAPONENHANCEMENTS:			//203	Weapon_Enhancements
    case ID_GRAPPLE:					//204	Grapple_movement
    case ID_MOVEMENTS:					//205
        //case ID_BOTCONTROLS:
    case ID_DMFLAGS:
        if( event != QM_ACTIVATED ) {
            return;
        }
        StartServer_BattlePage_SetTab(id);
        StartServer_BattlePage_UpdateInterface();
        break;

    }
}


/*
=================
StartServer_BattlePage_TabEvent
=================
*/
static void StartServer_BattlePage_TabEvent( void* ptr, int event ) {
    int id;
    //	int subid;

    if( event != QM_ACTIVATED ) {
        return;
    }

    id = ((menucommon_s*)ptr)->id;

    switch(id) {

    case ID_BATTLE_CONFIGTYPE:

    case ID_GAMEMODE:					//200	GAMEMODE	and options
    case ID_WEAPONCONTROL:				//201	WEAPONS CONTROLS FREEGEAR
    case ID_REGENERATIONS:				//202	Health_Regen
    case ID_WEAPONENHANCEMENTS:			//203	Weapon_Enhancements
    case ID_GRAPPLE:					//204	Grapple_movement
    case ID_MOVEMENTS:					//205
        //case ID_BOTCONTROLS:
    case ID_DMFLAGS:


        //test 1
        /*case ID_GAMEMODE:					//200	GAMEMODE	and options
        Com_Printf("Gamemode id = %i\n", id);
        break;
        case ID_WEAPONCONTROL:				//201	WEAPONS CONTROLS FREEGEAR
        Com_Printf("Weapon Control id = %i\n", id);
         break;
        case ID_REGENERATIONS:				//202	Health_Regen
        Com_Printf("Regens id = %i\n", id);
        break;
        case ID_WEAPONENHANCEMENTS:			//203	Weapon_Enhancements
        Com_Printf("Enhancements id = %i\n", id);
        break;
        case ID_GRAPPLE:					//204	Grapple_movement   
        Com_Printf("Grapple id = %i\n", id);
        break;
        case ID_MOVEMENTS:					//205		
        Com_Printf("Movement id = %i\n", id);
        break;*/

        //test 2
        /*case ID_GAMEMODE:					//200	GAMEMODE	and options
        	subid  = ((menucommon_s*)(s_battlecontrols.menu.items[s_battlecontrols.menu.cursor]))->id;
        	Com_Printf("Gamemode id = %i subid = %i\n", id, subid);
        	if( event != QM_ACTIVATED ) {
        		return;
        	}
        	StartServer_BattlePage_SetTab(id);
        	StartServer_BattlePage_UpdateInterface();
        	break;

        case ID_WEAPONCONTROL:				//201	WEAPONS CONTROLS FREEGEAR
        	subid  = ((menucommon_s*)(s_battlecontrols.menu.items[s_battlecontrols.menu.cursor]))->id;
        	Com_Printf("Weapon Control id = %i subid = %i\n", id , subid);
        	if( event != QM_ACTIVATED ) {
                return;
              }
        	StartServer_BattlePage_SetTab(id);
        	StartServer_BattlePage_UpdateInterface();
        	break;
        case ID_REGENERATIONS:				//202	Health_Regen
        	subid  = ((menucommon_s*)(s_battlecontrols.menu.items[s_battlecontrols.menu.cursor]))->id;
        	Com_Printf("Regens id = %i subid = %i\n", id, subid);
        	if( event != QM_ACTIVATED ) {
        		return;
        	}

        	StartServer_BattlePage_SetTab(id);
        	StartServer_BattlePage_UpdateInterface();
        	break;

        case ID_WEAPONENHANCEMENTS:			//205	Weapon_Enhancements
        	subid  = ((menucommon_s*)(s_battlecontrols.menu.items[s_battlecontrols.menu.cursor]))->id;
        	Com_Printf("Enhancements id = %i subid = %i\n", id, subid);
        	if( event != QM_ACTIVATED ) {
        		return;
        	}
        	StartServer_BattlePage_SetTab(id);
        	StartServer_BattlePage_UpdateInterface();
        	break;
        case ID_GRAPPLE:					//206	Grapple_movement   
        	subid  = ((menucommon_s*)(s_battlecontrols.menu.items[s_battlecontrols.menu.cursor]))->id;
        	Com_Printf("Grapple id = %i subid = %i\n", id, subid);
        	if( event != QM_ACTIVATED ) {
        		return;
        	}
        	StartServer_BattlePage_SetTab(id);
        	StartServer_BattlePage_UpdateInterface();
        	break;
        case ID_MOVEMENTS:
        	subid  = ((menucommon_s*)(s_battlecontrols.menu.items[s_battlecontrols.menu.cursor]))->id;
        	Com_Printf("Movement id = %i subid = %i\n", id, subid);
        	if( event != QM_ACTIVATED ) {
        		return;
        	}
        	StartServer_BattlePage_SetTab(id);
        	StartServer_BattlePage_UpdateInterface();
        	break;
        */

        if( event != QM_ACTIVATED ) {
            return;
        }
        StartServer_BattlePage_SetTab(id);
        StartServer_BattlePage_UpdateInterface();
    }
}





/*
=================
StartServer_BattlePage_MenuDraw
=================
*/
static void StartServer_BattlePage_MenuDraw(void) {
    if (uis.firstdraw) {
        StartServer_BattlePage_Load();
        StartServer_BattlePage_UpdateInterface();

        // draw the controls
    }

    StartServer_BackgroundDraw(qfalse);



    Menu_Draw(&s_battlecontrols.menu);

    // if we have no server controls, say so
    if (s_battlecontrols.num_spin == 0 && s_battlecontrols.num_radio == 0 &&
            s_battlecontrols.num_field == 0) {
        UI_DrawString(CONTROL_POSX, TABCONTROLCENTER_Y - LINE_HEIGHT/2,
                      "<no controls>", UI_RIGHT|UI_SMALLFONT, text_color_disabled);
    }

    StartServer_BattlePage_DrawStatusBarText();
	StartServer_BattlePage_DrawStatusBarText2();
}




/*
=================
StartServer_BattlePage_StatusBar
=================
 
static void StartServer_BattlePage_StatusBar(void* ptr) {
    switch (((menucommon_s*)ptr)->id) {
    case ID_SERVER_SAVE:
        StartServer_BattlePage_SetStatusBar("Create a script for use with \\exec");
        break;
 
    case ID_SERVER_LOAD:
        StartServer_BattlePage_SetStatusBar("Load a previously saved UIE script");
        break;
    };
}
*/


void StartServer_BattlePage_MenuInit(void) {
    menuframework_s* menuptr;
    int y, y_base;
    int i;
    int style;
    float scale;

    memset(&s_battlecontrols, 0, sizeof(s_battlecontrols_t));

    StartServer_BattlePage_Cache();
    menuptr = &s_battlecontrols.menu;

    menuptr->key = StartServer_BattlePage_MenuKey;
    menuptr->wrapAround = qtrue;
    menuptr->fullscreen = qtrue;
    menuptr->draw = StartServer_BattlePage_MenuDraw;

    StartServer_CommonControls_Init(menuptr, &s_battlecontrols.common, StartServer_BattlePage_CommonEvent, COMMONCTRL_BATTLEMODE);

    y = GAMETYPEROW_Y;
    s_battlecontrols.gameType.generic.type		= MTYPE_SPINCONTROL;
    s_battlecontrols.gameType.generic.id		= ID_BATTLE_GAMETYPE;
    s_battlecontrols.gameType.generic.flags		= QMF_PULSEIFFOCUS|QMF_SMALLFONT;
    s_battlecontrols.gameType.generic.callback	= StartServer_BattlePage_Event;
    s_battlecontrols.gameType.generic.x			= GAMETYPECOLUMN_X;
    s_battlecontrols.gameType.generic.y			= y;
    s_battlecontrols.gameType.generic.name		= "Game Type:";
    s_battlecontrols.gameType.itemnames			= gametype_items;

    s_battlecontrols.gameTypeIcon.generic.type  = MTYPE_BITMAP;
    s_battlecontrols.gameTypeIcon.generic.flags = QMF_INACTIVE;
    s_battlecontrols.gameTypeIcon.generic.x	 = GAMETYPEICON_X;
    s_battlecontrols.gameTypeIcon.generic.y	 = y;
    s_battlecontrols.gameTypeIcon.width  	     = 32;
    s_battlecontrols.gameTypeIcon.height  	     = 32;

    s_battlecontrols.configtype.generic.type		= MTYPE_SPINCONTROL;
    s_battlecontrols.configtype.generic.id			= ID_BATTLE_CONFIGTYPE;
    s_battlecontrols.configtype.generic.flags		= QMF_PULSEIFFOCUS|QMF_SMALLFONT;//|QMF_GRAYED;
    s_battlecontrols.configtype.generic.callback	= StartServer_BattlePage_Event;
    s_battlecontrols.configtype.generic.x			= GAMETYPECOLUMN_X;
    s_battlecontrols.configtype.generic.y			= y + 20;
    s_battlecontrols.configtype.generic.name		= "Config Presets:";
    s_battlecontrols.configtype.generic.statusbar	= StartServer_BattlePage_ControlListStatusBar;
    s_battlecontrols.configtype.itemnames			= battleconfigtype;



    s_battlecontrols.num_radio = 0;
    s_battlecontrols.num_field = 0;
    s_battlecontrols.num_spin = 0;

    s_battlecontrols.statusbar_height = 480 - 96 - LINE_HEIGHT;
	s_battlecontrols.statusbar_height2 = s_battlecontrols.statusbar_height + LINE_HEIGHT;

    s_battlecontrols.activePage = 0;
    s_battlecontrols.pageList = srv_battle_main_menu_items;
    s_battlecontrols.pageListSize = ARRAY_COUNT(srv_battle_main_menu_items);
    style = UI_RIGHT|UI_MEDIUMFONT;
    scale = UI_ProportionalSizeScale(style);
    y_base = TABCONTROLCENTER_Y - s_battlecontrols.pageListSize*PROP_HEIGHT*scale/2;

    for (i = 0; i < s_battlecontrols.pageListSize; i++) {
        s_battlecontrols.pageList[i].menutext->generic.type     = MTYPE_PTEXT;
        s_battlecontrols.pageList[i].menutext->generic.flags    = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
        s_battlecontrols.pageList[i].menutext->generic.id	     = s_battlecontrols.pageList[i].id;
        s_battlecontrols.pageList[i].menutext->generic.callback = StartServer_BattlePage_TabEvent;
        s_battlecontrols.pageList[i].menutext->generic.x	     = 180 + 75;
        s_battlecontrols.pageList[i].menutext->generic.y	     = y_base + i*PROP_HEIGHT*scale;
        s_battlecontrols.pageList[i].menutext->string			= s_battlecontrols.pageList[i].title;
        s_battlecontrols.pageList[i].menutext->style			= style;
        s_battlecontrols.pageList[i].menutext->color			= color_green;


        Menu_AddItem( menuptr, s_battlecontrols.pageList[i].menutext);
    }

    // register controls
    Menu_AddItem( menuptr, &s_battlecontrols.gameType);
    Menu_AddItem( menuptr, &s_battlecontrols.gameTypeIcon);
    Menu_AddItem( menuptr, &s_battlecontrols.configtype);
    // we only need the QMF_NODEFAULTINIT flag to get these controls
    // registered. Type is added later
    for (i = 0; i < MAX_BATTLE_RADIO_CONTROL; i++) {
        s_battlecontrols.radio[i].control.generic.type = MTYPE_RADIOBUTTON;
        s_battlecontrols.radio[i].control.generic.flags = QMF_NODEFAULTINIT|QMF_HIDDEN|QMF_INACTIVE;
        //s_battlecontrols.radio[i].control.generic.callback = StartServer_BattlePage_TabEvent;


        Menu_AddItem( menuptr, &s_battlecontrols.radio[i].control);
    }

    for (i = 0; i < MAX_BATTLE_MFIELD_CONTROL; i++) {
        s_battlecontrols.field[i].control.generic.type = MTYPE_FIELD;
        s_battlecontrols.field[i].control.generic.flags = QMF_NODEFAULTINIT|QMF_HIDDEN|QMF_INACTIVE;
        //s_battlecontrols.field[i].control.generic.callback = StartServer_BattlePage_TabEvent;
        Menu_AddItem( menuptr, &s_battlecontrols.field[i].control);
    }

    for (i = 0; i < MAX_BATTLE_SPIN_CONTROL; i++) {
        s_battlecontrols.spin[i].control.generic.type = MTYPE_SPINCONTROL;
        s_battlecontrols.spin[i].control.generic.flags = QMF_NODEFAULTINIT|QMF_HIDDEN|QMF_INACTIVE;
        //s_battlecontrols.spin[i].control.generic.callback = StartServer_BattlePage_TabEvent;
        Menu_AddItem( menuptr, &s_battlecontrols.spin[i].control);
    }

    // control init is done on uis.firstdraw
    UI_PushMenu( &s_battlecontrols.menu );


    /*s_battlecontrols.Game_Mode
    s_battlecontrols.Weapon_Control;
    s_battlecontrols.Health_Regen;
    s_battlecontrols.Armor_Regen;
    s_battlecontrols.Ammo_Regen;
    s_battlecontrols.Weapon_Enhancements;
    s_battlecontrols.Grapple_movement;
    s_battlecontrols.GameOptions;*/
}

