From 5ee4ec842132a116fafa70228958616bc0c33885 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 2 May 2005 06:29:44 +0000 Subject: [PATCH] Array now requires its elements to be Objects --- ruamoko/cl_menu/controls_o.qc | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/ruamoko/cl_menu/controls_o.qc b/ruamoko/cl_menu/controls_o.qc index 74db2fa62..dee64bd3a 100644 --- a/ruamoko/cl_menu/controls_o.qc +++ b/ruamoko/cl_menu/controls_o.qc @@ -48,6 +48,28 @@ struct binding_s = { }; typedef struct binding_s binding_t; +@interface Binding : Object +{ + 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; + text = binding.command; + text = binding.keys; + } + return self; +} +@end + binding_t [16] movement_binding_list = { {"Jump/Swin up", "+jump"}, {"Walk forward", "+forward"}, @@ -87,13 +109,10 @@ binding_t [10] weapon_binding_list = { {"Thunderbolt", "impulse 8"}, }; -(binding_t []) (binding_t binding) +Binding (binding_t binding) new_binding = { - local binding_t []newb = obj_malloc (@sizeof (binding_t)); - - newb[0] = binding; - return newb; + return [[Binding alloc] initWithBinding:binding]; }; /* @@ -108,13 +127,13 @@ init_binding_hash = movement_bindings = [[Array alloc] init]; for (i = 0; i < @sizeof (movement_binding_list) / @sizeof (movement_binding_list[0]); i++) - [movement_bindings addItem: (id)new_binding (movement_binding_list[i])]; + [movement_bindings addItem: new_binding (movement_binding_list[i])]; misc_bindings = [[Array alloc] init]; for (i = 0; i < @sizeof (misc_binding_list) / @sizeof (misc_binding_list[0]); i++) - [misc_bindings addItem: (id)new_binding (misc_binding_list[i])]; + [misc_bindings addItem: new_binding (misc_binding_list[i])]; weapon_bindings = [[Array alloc] init]; for (i = 0; i < @sizeof (weapon_binding_list) / @sizeof (weapon_binding_list[0]); i++) - [weapon_bindings addItem: (id)new_binding (weapon_binding_list[i])]; + [weapon_bindings addItem: new_binding (weapon_binding_list[i])]; };