2002-08-16 21:54:21 +00:00
|
|
|
/*
|
|
|
|
controls_o.qc
|
|
|
|
|
|
|
|
Controls settings menu
|
|
|
|
|
|
|
|
Copyright (C) 2002 Robin Redeker <elmex@x-paste.de>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public
|
|
|
|
License along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
*/
|
|
|
|
|
2003-04-07 22:34:39 +00:00
|
|
|
#include "Array.h"
|
|
|
|
|
2002-08-16 21:54:21 +00:00
|
|
|
#include "menu.h"
|
|
|
|
#include "draw.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "string.h"
|
|
|
|
#include "key.h"
|
|
|
|
#include "options_util.h"
|
|
|
|
|
|
|
|
integer set_key_flag; // holds flag for the key-setting
|
|
|
|
|
|
|
|
// three global hashes for the main binding groups
|
2003-04-08 01:34:34 +00:00
|
|
|
Array movement_bindings;
|
|
|
|
Array misc_bindings;
|
|
|
|
Array weapon_bindings;
|
2003-04-07 22:34:39 +00:00
|
|
|
|
2003-07-30 04:11:45 +00:00
|
|
|
struct binding_s = {
|
2003-04-07 22:34:39 +00:00
|
|
|
string text;
|
|
|
|
string command;
|
|
|
|
string keys;
|
|
|
|
};
|
2003-07-30 04:11:45 +00:00
|
|
|
typedef struct binding_s binding_t;
|
2003-04-07 22:34:39 +00:00
|
|
|
|
2005-05-02 06:29:44 +00:00
|
|
|
@interface Binding : Object
|
|
|
|
{
|
2005-05-07 08:28:44 +00:00
|
|
|
@public
|
2005-05-02 06:29:44 +00:00
|
|
|
string text;
|
|
|
|
string command;
|
|
|
|
string keys;
|
|
|
|
}
|
|
|
|
-initWithBinding: (binding_t) binding;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation Binding
|
|
|
|
-initWithBinding: (binding_t) binding
|
|
|
|
{
|
|
|
|
self = [self init];
|
|
|
|
if (self) {
|
|
|
|
text = binding.text;
|
2005-05-07 08:28:44 +00:00
|
|
|
command = binding.command;
|
|
|
|
keys = binding.keys;
|
2005-05-02 06:29:44 +00:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
2003-04-07 22:34:39 +00:00
|
|
|
binding_t [16] movement_binding_list = {
|
|
|
|
{"Jump/Swin up", "+jump"},
|
|
|
|
{"Walk forward", "+forward"},
|
|
|
|
{"Backpedal", "+back"},
|
|
|
|
{"Turn left", "+left"},
|
|
|
|
{"Turn right", "+right"},
|
|
|
|
{"Run", "+speed"},
|
|
|
|
{"Step left", "+moveleft"},
|
|
|
|
{"Step right", "+moveright"},
|
|
|
|
{"Sidestep", "+strafe"},
|
|
|
|
{"Look up", "+lookup"},
|
|
|
|
{"Look down", "+lookdown"},
|
|
|
|
{"Center view", "centerview"},
|
|
|
|
{"Mouse look", "+mlook"},
|
|
|
|
{"Keyboard look", "+klook"},
|
|
|
|
{"Swim up", "+moveup"},
|
|
|
|
{"Swim down", "+movedown"},
|
|
|
|
};
|
|
|
|
|
|
|
|
binding_t [4] misc_binding_list = {
|
|
|
|
{"Pause game", "pause"},
|
|
|
|
{"Tog. m.-grab", "toggle in_grab"},
|
|
|
|
{"Messagemode", "messagemode"},
|
|
|
|
{"Screenshot", "screenshot"},
|
|
|
|
};
|
|
|
|
|
|
|
|
binding_t [10] weapon_binding_list = {
|
|
|
|
{"Attack", "+attack"},
|
|
|
|
{"Next weapon", "impulse 10"},
|
|
|
|
{"Axe", "impulse 1"},
|
|
|
|
{"Shotgun", "impulse 2"},
|
|
|
|
{"Super Shotgun", "impulse 3"},
|
|
|
|
{"Nailgun", "impulse 4"},
|
|
|
|
{"Super Nailgun", "impulse 5"},
|
|
|
|
{"Grenade L. ", "impulse 6"},
|
|
|
|
{"Rocket L. ", "impulse 7"},
|
|
|
|
{"Thunderbolt", "impulse 8"},
|
|
|
|
};
|
|
|
|
|
2005-05-02 06:29:44 +00:00
|
|
|
Binding (binding_t binding)
|
2003-04-07 22:34:39 +00:00
|
|
|
new_binding =
|
|
|
|
{
|
2005-05-02 06:29:44 +00:00
|
|
|
return [[Binding alloc] initWithBinding:binding];
|
2003-04-07 22:34:39 +00:00
|
|
|
};
|
2002-08-16 21:54:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
init_binding_hash
|
|
|
|
|
|
|
|
this function initializes the hashes for the binding menus
|
|
|
|
*/
|
|
|
|
void ()
|
|
|
|
init_binding_hash =
|
|
|
|
{
|
2003-04-07 22:34:39 +00:00
|
|
|
local integer i;
|
|
|
|
|
2003-04-08 01:34:34 +00:00
|
|
|
movement_bindings = [[Array alloc] init];
|
|
|
|
for (i = 0; i < @sizeof (movement_binding_list) / @sizeof (movement_binding_list[0]); i++)
|
2005-05-02 06:29:44 +00:00
|
|
|
[movement_bindings addItem: new_binding (movement_binding_list[i])];
|
2003-04-08 01:34:34 +00:00
|
|
|
misc_bindings = [[Array alloc] init];
|
|
|
|
for (i = 0; i < @sizeof (misc_binding_list) / @sizeof (misc_binding_list[0]); i++)
|
2005-05-02 06:29:44 +00:00
|
|
|
[misc_bindings addItem: new_binding (misc_binding_list[i])];
|
2003-04-08 01:34:34 +00:00
|
|
|
weapon_bindings = [[Array alloc] init];
|
|
|
|
for (i = 0; i < @sizeof (weapon_binding_list) / @sizeof (weapon_binding_list[0]); i++)
|
2005-05-02 06:29:44 +00:00
|
|
|
[weapon_bindings addItem: new_binding (weapon_binding_list[i])];
|
2003-04-07 22:34:39 +00:00
|
|
|
|
2002-08-16 21:54:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
get_keyname
|
|
|
|
|
2003-03-03 05:24:45 +00:00
|
|
|
Gets the string of the key, which is bound to a special binding.
|
2002-08-16 21:54:21 +00:00
|
|
|
bindnum is the number of the binding.
|
2003-03-03 05:24:45 +00:00
|
|
|
As a command/binding can be bound to many keys, you can get the second,
|
|
|
|
third, etc. key by giving the bindnum.
|
2002-08-16 21:54:21 +00:00
|
|
|
*/
|
|
|
|
string (string binding, integer bindnum)
|
|
|
|
get_keyname =
|
|
|
|
{
|
|
|
|
local integer keynum;
|
|
|
|
local string keyname;
|
|
|
|
|
|
|
|
keynum = Key_LookupBinding(IMT_0, bindnum, binding);
|
|
|
|
if(keynum == -1) {
|
|
|
|
keyname = "";
|
|
|
|
} else {
|
|
|
|
keyname = Key_KeynumToString(keynum);
|
|
|
|
// cut away the "K_", thats maybe enough as description for now
|
2003-04-08 02:35:09 +00:00
|
|
|
//keyname = String_Cut(0, 2, keyname);
|
2002-08-16 21:54:21 +00:00
|
|
|
}
|
|
|
|
return keyname;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
get_hash_keys
|
|
|
|
|
|
|
|
gets the keys for a keybinding-hash
|
|
|
|
*/
|
2003-04-07 22:34:39 +00:00
|
|
|
void (Array list)
|
2002-08-16 21:54:21 +00:00
|
|
|
get_hash_keys =
|
|
|
|
{
|
|
|
|
local integer i,hlen;
|
2005-05-07 08:28:44 +00:00
|
|
|
local Binding binding;
|
2003-04-07 22:34:39 +00:00
|
|
|
local string desc1 = "", desc2 = "";
|
2002-08-16 21:54:21 +00:00
|
|
|
|
2003-04-07 22:34:39 +00:00
|
|
|
hlen = [list count];
|
2003-03-03 05:24:45 +00:00
|
|
|
for(i = 0; i < hlen; i++) {
|
2005-05-07 08:28:44 +00:00
|
|
|
binding = [list getItemAt: i];
|
2003-04-07 22:34:39 +00:00
|
|
|
desc1 = get_keyname (binding.command, 1); // first key bound to
|
|
|
|
desc2 = get_keyname (binding.command, 2); // second key bound to
|
2002-08-16 21:54:21 +00:00
|
|
|
|
2003-03-03 05:24:45 +00:00
|
|
|
if (desc2 != "") {
|
2002-08-16 21:54:21 +00:00
|
|
|
desc1 += ", " + desc2;
|
|
|
|
}
|
2004-01-22 01:33:27 +00:00
|
|
|
if (binding.keys) {
|
|
|
|
str_free (binding.keys);
|
|
|
|
binding.keys = NIL;
|
|
|
|
}
|
|
|
|
if (desc1) {
|
|
|
|
binding.keys = str_new ();
|
|
|
|
str_copy (binding.keys, desc1);
|
|
|
|
}
|
2002-08-16 21:54:21 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
load_keybindings
|
|
|
|
|
|
|
|
Loads the kername for into the hashes
|
|
|
|
*/
|
|
|
|
void ()
|
|
|
|
load_keybindings =
|
|
|
|
{
|
2003-04-08 01:34:34 +00:00
|
|
|
get_hash_keys (movement_bindings);
|
|
|
|
get_hash_keys (misc_bindings);
|
|
|
|
get_hash_keys (weapon_bindings);
|
2002-08-16 21:54:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*******************
|
|
|
|
* BINDINGS OPTIONS
|
|
|
|
* Binding settings
|
|
|
|
*******************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
DESIGN NOTE (by elmex):
|
|
|
|
|
2003-03-03 05:24:45 +00:00
|
|
|
Every sub-menu for control bindings has its own hash for holding the
|
|
|
|
keybindings. Thats why there are three different functions, which shadow
|
|
|
|
the CB_MAIN_control_binding() function. They get the binding from the
|
|
|
|
correct hash.
|
2002-08-16 21:54:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
CB_MAIN_control_binding
|
|
|
|
|
|
|
|
The core function of all control_binding function.
|
2003-03-03 05:24:45 +00:00
|
|
|
It takes the binding as argument.
|
2002-08-16 21:54:21 +00:00
|
|
|
This function is called by the real callbacks.
|
|
|
|
*/
|
2005-05-07 08:28:44 +00:00
|
|
|
integer (Binding binding, integer key)
|
2002-08-16 21:54:21 +00:00
|
|
|
CB_MAIN_control_binding =
|
|
|
|
{
|
2003-03-03 05:24:45 +00:00
|
|
|
local integer retval = 0, bindcnt = 0;
|
2002-08-16 21:54:21 +00:00
|
|
|
|
|
|
|
if(set_key_flag) {
|
2003-04-07 22:34:39 +00:00
|
|
|
bindcnt = Key_CountBinding(IMT_0, binding.command);
|
2002-08-16 21:54:21 +00:00
|
|
|
/* we are not binding keys for more than one command
|
|
|
|
by the menu (maybe extended later) */
|
|
|
|
if(bindcnt < 2) {
|
2003-04-07 22:34:39 +00:00
|
|
|
Key_SetBinding (IMT_0, key, binding.command);
|
2002-08-16 21:54:21 +00:00
|
|
|
} else {
|
|
|
|
// else, remove a binding and assign a new one
|
2003-04-07 22:34:39 +00:00
|
|
|
Key_SetBinding (IMT_0, Key_LookupBinding(IMT_0, 1, binding.command), "");
|
|
|
|
Key_SetBinding (IMT_0, key, binding.command);
|
2002-08-16 21:54:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set_key_flag = 0;
|
|
|
|
retval = 1;
|
|
|
|
} else {
|
|
|
|
if(key == QFK_RETURN) {
|
|
|
|
set_key_flag = 1;
|
|
|
|
retval = 1;
|
|
|
|
} else if(key == QFK_BACKSPACE || key == QFK_DELETE) {
|
2003-04-07 22:34:39 +00:00
|
|
|
Key_SetBinding (IMT_0, Key_LookupBinding(IMT_0, 1, binding.command), "");
|
2002-08-16 21:54:21 +00:00
|
|
|
|
|
|
|
retval = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
CB_basic_control_binding
|
|
|
|
|
|
|
|
Callback for the basic control bindings menu
|
|
|
|
*/
|
|
|
|
integer (string text, integer key)
|
|
|
|
CB_basic_control_binding =
|
|
|
|
{
|
2005-05-07 08:28:44 +00:00
|
|
|
local Binding binding = [movement_bindings getItemAt: stoi (text)];
|
2003-03-03 05:24:45 +00:00
|
|
|
local integer ret = CB_MAIN_control_binding (binding, key);
|
2002-08-16 21:54:21 +00:00
|
|
|
|
|
|
|
// fetch all keynames (possible to optimize.. but not very neccessary)
|
2003-04-08 01:34:34 +00:00
|
|
|
get_hash_keys (movement_bindings);
|
2002-08-16 21:54:21 +00:00
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
CB_ME_basic_control_binding
|
|
|
|
|
2003-03-03 05:24:45 +00:00
|
|
|
Loading basic keynames when entering the menu
|
2002-08-16 21:54:21 +00:00
|
|
|
*/
|
2007-05-13 05:14:32 +00:00
|
|
|
void ()
|
2002-08-16 21:54:21 +00:00
|
|
|
CB_ME_basic_control_binding =
|
|
|
|
{
|
2003-04-08 01:34:34 +00:00
|
|
|
get_hash_keys (movement_bindings);
|
2002-08-16 21:54:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
DRAW_basic_control_binding
|
|
|
|
|
|
|
|
Draws the menu for the basic control bindins
|
|
|
|
*/
|
2003-05-06 02:19:13 +00:00
|
|
|
integer (integer x, integer y)
|
2002-08-16 21:54:21 +00:00
|
|
|
DRAW_basic_control_binding =
|
|
|
|
{
|
2003-03-03 05:24:45 +00:00
|
|
|
local integer cursor_pad = 40, bind_desc_pad, hl, i;
|
2002-08-16 21:54:21 +00:00
|
|
|
|
|
|
|
bind_desc_pad = 120;
|
|
|
|
|
2003-05-06 02:19:13 +00:00
|
|
|
Draw_String (x + 20, y + 10, "Backspace/Delete: Del binding");
|
|
|
|
Draw_String (x + 20, y + 20, "Enter: New binding");
|
2002-08-16 21:54:21 +00:00
|
|
|
|
|
|
|
|
2003-04-08 01:34:34 +00:00
|
|
|
hl = [movement_bindings count];
|
2003-03-03 05:24:45 +00:00
|
|
|
for(i = 0; i < hl; i++) {
|
2005-05-07 08:28:44 +00:00
|
|
|
local Binding binding = [movement_bindings getItemAt: i];
|
2003-05-06 02:19:13 +00:00
|
|
|
draw_val_item (x + 20, y + 40 + ( i * 10), bind_desc_pad,
|
2003-04-07 22:34:39 +00:00
|
|
|
binding.text, binding.keys);
|
2002-08-16 21:54:21 +00:00
|
|
|
}
|
|
|
|
|
2003-05-06 02:19:13 +00:00
|
|
|
opt_cursor (x + 12, y + (Menu_GetIndex () * 10) + cursor_pad);
|
2002-08-16 21:54:21 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
MENU_basic_control_binding
|
|
|
|
|
|
|
|
Menu making function for the control bindings
|
|
|
|
*/
|
|
|
|
void ()
|
|
|
|
MENU_basic_control_binding =
|
|
|
|
{
|
|
|
|
local integer i,hl;
|
|
|
|
|
2002-09-09 17:28:19 +00:00
|
|
|
Menu_Begin (54, 40, "Movement bindings");
|
2002-08-16 21:54:21 +00:00
|
|
|
Menu_FadeScreen (1);
|
2003-03-03 05:24:45 +00:00
|
|
|
Menu_EnterHook (CB_ME_basic_control_binding);
|
2002-08-16 21:54:21 +00:00
|
|
|
Menu_Draw (DRAW_basic_control_binding);
|
|
|
|
|
2003-04-08 01:34:34 +00:00
|
|
|
hl = [movement_bindings count];
|
2002-08-16 21:54:21 +00:00
|
|
|
for (i = 0; i < hl; i++) {
|
2003-03-03 05:24:45 +00:00
|
|
|
Menu_Item (20, 40 + i * 10, itos (i), CB_basic_control_binding, 1);
|
2002-08-16 21:54:21 +00:00
|
|
|
}
|
|
|
|
Menu_End ();
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
CB_misc_control_binding
|
|
|
|
|
|
|
|
Callback for misc control bindings.
|
|
|
|
*/
|
|
|
|
integer (string text, integer key)
|
|
|
|
CB_misc_control_binding =
|
|
|
|
{
|
2005-05-07 08:28:44 +00:00
|
|
|
local Binding binding = [misc_bindings getItemAt: stoi (text)];
|
2003-03-03 05:24:45 +00:00
|
|
|
local integer ret = CB_MAIN_control_binding (binding, key);
|
2002-08-16 21:54:21 +00:00
|
|
|
|
|
|
|
// fetch all keynames (possible to optimize.. but not very neccessary)
|
2003-04-08 01:34:34 +00:00
|
|
|
get_hash_keys (misc_bindings);
|
2002-08-16 21:54:21 +00:00
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
CB_ME_misc_control_binding
|
|
|
|
|
2003-03-03 05:24:45 +00:00
|
|
|
Loading misc keynames when entering the menu
|
2002-08-16 21:54:21 +00:00
|
|
|
*/
|
2007-05-13 05:14:32 +00:00
|
|
|
void ()
|
2002-08-16 21:54:21 +00:00
|
|
|
CB_ME_misc_control_binding =
|
|
|
|
{
|
2003-04-08 01:34:34 +00:00
|
|
|
get_hash_keys(misc_bindings);
|
2002-08-16 21:54:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
DRAW_misc_control_binding
|
|
|
|
|
|
|
|
Draw the bindings for the misc controls
|
|
|
|
*/
|
2003-05-06 02:19:13 +00:00
|
|
|
integer (integer x, integer y)
|
2002-08-16 21:54:21 +00:00
|
|
|
DRAW_misc_control_binding =
|
|
|
|
{
|
|
|
|
local integer cursor_pad = 40, bind_desc_pad;
|
|
|
|
local integer i, hl;
|
|
|
|
|
|
|
|
bind_desc_pad = 120;
|
|
|
|
|
2004-02-14 04:35:59 +00:00
|
|
|
Draw_String (x + 20, y + 10, "Backspace/Delete: Del binding");
|
|
|
|
Draw_String (x + 20, y + 20, "Enter: New binding");
|
2002-08-16 21:54:21 +00:00
|
|
|
|
2003-04-08 01:34:34 +00:00
|
|
|
hl = [misc_bindings count];
|
2002-08-16 21:54:21 +00:00
|
|
|
for(i=0;i < hl; i++) {
|
2005-05-07 08:28:44 +00:00
|
|
|
local Binding binding = [misc_bindings getItemAt: i];
|
2003-05-06 02:19:13 +00:00
|
|
|
draw_val_item (x + 20, y + 40+(i*10), bind_desc_pad,
|
2003-04-07 22:34:39 +00:00
|
|
|
binding.text, binding.keys);
|
2002-08-16 21:54:21 +00:00
|
|
|
}
|
|
|
|
|
2003-05-06 02:19:13 +00:00
|
|
|
opt_cursor (x + 12, y + (Menu_GetIndex() * 10) + cursor_pad);
|
2002-08-16 21:54:21 +00:00
|
|
|
return 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
MENU_misc_control_binding
|
|
|
|
|
|
|
|
Menu maker function for the misc control binding
|
|
|
|
*/
|
|
|
|
void ()
|
|
|
|
MENU_misc_control_binding =
|
|
|
|
{
|
2003-03-03 05:24:45 +00:00
|
|
|
local integer hl, i;
|
2002-08-16 21:54:21 +00:00
|
|
|
|
|
|
|
Menu_Begin (54, 50, "Misc bindings");
|
|
|
|
Menu_FadeScreen (1);
|
2003-03-03 05:24:45 +00:00
|
|
|
Menu_EnterHook (CB_ME_misc_control_binding);
|
2002-08-16 21:54:21 +00:00
|
|
|
Menu_Draw (DRAW_misc_control_binding);
|
|
|
|
|
2003-04-08 01:34:34 +00:00
|
|
|
hl = [misc_bindings count];
|
2002-08-16 21:54:21 +00:00
|
|
|
for (i = 0; i < hl; i++) {
|
2003-03-03 05:24:45 +00:00
|
|
|
Menu_Item (20, 40 + i * 10, itos (i), CB_misc_control_binding, 1);
|
2002-08-16 21:54:21 +00:00
|
|
|
}
|
|
|
|
Menu_End ();
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
CB_weapon_control_binding
|
|
|
|
|
|
|
|
Callback function for the weapons control bindings
|
|
|
|
*/
|
2003-03-03 05:24:45 +00:00
|
|
|
integer (string text, integer key)
|
2002-08-16 21:54:21 +00:00
|
|
|
CB_weapon_control_binding =
|
|
|
|
{
|
2005-05-07 08:28:44 +00:00
|
|
|
local Binding binding = [weapon_bindings getItemAt: stoi (text)];
|
2003-03-03 05:24:45 +00:00
|
|
|
local integer ret = CB_MAIN_control_binding (binding, key);
|
2002-08-16 21:54:21 +00:00
|
|
|
|
|
|
|
// fetch all keynames (possible to optimize.. but not very neccessary)
|
2003-04-08 01:34:34 +00:00
|
|
|
get_hash_keys (weapon_bindings);
|
2002-08-16 21:54:21 +00:00
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
CB_ME_weapon_control_binding
|
|
|
|
|
|
|
|
Loading weapon keynames when entering the
|
|
|
|
menu
|
|
|
|
*/
|
2007-05-13 05:14:32 +00:00
|
|
|
void ()
|
2002-08-16 21:54:21 +00:00
|
|
|
CB_ME_weapon_control_binding =
|
|
|
|
{
|
2003-04-08 01:34:34 +00:00
|
|
|
get_hash_keys(weapon_bindings);
|
2002-08-16 21:54:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
DRAW_weapon_control_binding
|
|
|
|
|
|
|
|
Draw the weapon binding menu
|
|
|
|
*/
|
2003-05-06 02:19:13 +00:00
|
|
|
integer (integer x, integer y)
|
2002-08-16 21:54:21 +00:00
|
|
|
DRAW_weapon_control_binding =
|
|
|
|
{
|
2003-03-03 05:24:45 +00:00
|
|
|
local integer cursor_pad = 40, bind_desc_pad, hl, i;
|
2002-08-16 21:54:21 +00:00
|
|
|
|
|
|
|
bind_desc_pad = 120;
|
|
|
|
|
2003-05-06 02:19:13 +00:00
|
|
|
Draw_String (x + 20, y + 10, "Backspace/Delete: Del binding");
|
|
|
|
Draw_String (x + 20, y + 20, "Enter: New binding");
|
2002-08-16 21:54:21 +00:00
|
|
|
|
2003-04-08 01:34:34 +00:00
|
|
|
hl = [weapon_bindings count];
|
2003-03-03 05:24:45 +00:00
|
|
|
for(i = 0; i < hl; i++) {
|
2005-05-07 08:28:44 +00:00
|
|
|
local Binding binding = [weapon_bindings getItemAt: i];
|
2003-05-06 02:19:13 +00:00
|
|
|
draw_val_item (x + 20, y + 40 + (i * 10), bind_desc_pad,
|
2003-04-07 22:34:39 +00:00
|
|
|
binding.text, binding.keys);
|
2002-08-16 21:54:21 +00:00
|
|
|
}
|
|
|
|
|
2003-05-06 02:19:13 +00:00
|
|
|
opt_cursor (x + 12, y + (Menu_GetIndex () * 10) + cursor_pad);
|
2002-08-16 21:54:21 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
MENU_weapon_control_binding
|
|
|
|
|
|
|
|
Menu maker for the weapons menu
|
|
|
|
*/
|
|
|
|
void ()
|
|
|
|
MENU_weapon_control_binding =
|
|
|
|
{
|
2003-03-03 05:24:45 +00:00
|
|
|
local integer hl, i;
|
2002-08-16 21:54:21 +00:00
|
|
|
|
|
|
|
Menu_Begin (54, 60, "Weapon bindings");
|
|
|
|
Menu_FadeScreen (1);
|
2003-03-03 05:24:45 +00:00
|
|
|
Menu_EnterHook (CB_ME_weapon_control_binding);
|
2002-08-16 21:54:21 +00:00
|
|
|
Menu_Draw (DRAW_weapon_control_binding);
|
|
|
|
|
2003-04-08 01:34:34 +00:00
|
|
|
hl = [weapon_bindings count];
|
2002-08-16 21:54:21 +00:00
|
|
|
for (i = 0; i < hl; i++) {
|
2003-03-03 05:24:45 +00:00
|
|
|
Menu_Item (20, 40 + i * 10, itos (i), CB_weapon_control_binding, 1);
|
2002-08-16 21:54:21 +00:00
|
|
|
}
|
|
|
|
Menu_End ();
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
MENU_control_binding
|
|
|
|
|
|
|
|
Main controls menu, for selecting the sub control menus
|
|
|
|
*/
|
|
|
|
void ()
|
|
|
|
MENU_control_binding =
|
|
|
|
{
|
|
|
|
init_binding_hash (); // init the keybinding hashes
|
|
|
|
|
|
|
|
Menu_Begin (54, 60, "Bindings");
|
|
|
|
Menu_Pic (16, 4, "gfx/qplaque.lmp");
|
|
|
|
Menu_CenterPic (160, 4, "gfx/p_option.lmp");
|
|
|
|
|
|
|
|
Menu_FadeScreen (1);
|
|
|
|
|
|
|
|
MENU_basic_control_binding ();
|
2003-03-03 05:24:45 +00:00
|
|
|
MENU_misc_control_binding ();
|
2002-08-16 21:54:21 +00:00
|
|
|
MENU_weapon_control_binding();
|
|
|
|
|
|
|
|
Menu_End ();
|
|
|
|
};
|