make an inputline with a text box behind it

This commit is contained in:
Bill Currie 2004-02-13 05:36:35 +00:00
parent 865b31caac
commit 8978d1ca55
9 changed files with 111 additions and 27 deletions

View File

@ -339,9 +339,9 @@ integer (integer x, integer y) lanconfig_draw =
Draw_String (basex, y + 52, "Address:"); Draw_String (basex, y + 52, "Address:");
Draw_String (basex + 9 * 8, y + 52, "127.0.0.1"); Draw_String (basex + 9 * 8, y + 52, "127.0.0.1");
Draw_String (basex, y + lanConfig_cursor_table[0], "Port"); Draw_String (basex, y + lanConfig_cursor_table[0], "Port");
text_box (basex + 8 * 8, y + lanConfig_cursor_table[0] - 8, 6, 1);
[lanConfig_port_il setBasePos:x y:y]; [lanConfig_port_il setBasePos:x y:y];
[lanConfig_port_il draw:lanConfig_cursor == 0 && input_active]; [lanConfig_port_il cursor:lanConfig_cursor == 0 && input_active];
[lanConfig_port_il draw];
Draw_String (basex + 9 * 8, y + lanConfig_cursor_table[0], Draw_String (basex + 9 * 8, y + lanConfig_cursor_table[0],
lanConfig_portname); lanConfig_portname);
@ -349,9 +349,9 @@ integer (integer x, integer y) lanconfig_draw =
Draw_String (basex, y + lanConfig_cursor_table[1], "Search for local " Draw_String (basex, y + lanConfig_cursor_table[1], "Search for local "
"games..."); "games...");
Draw_String (basex, y + 108, "Join game at:"); Draw_String (basex, y + 108, "Join game at:");
text_box (basex + 8, y + lanConfig_cursor_table[2] - 8, 22, 1);
[lanConfig_join_il setBasePos:x y:y]; [lanConfig_join_il setBasePos:x y:y];
[lanConfig_join_il draw:lanConfig_cursor == 2 && input_active]; [lanConfig_join_il cursor:lanConfig_cursor == 2 && input_active];
[lanConfig_join_il draw];
Draw_String (basex + 16, y + lanConfig_cursor_table[2], Draw_String (basex + 16, y + lanConfig_cursor_table[2],
lanConfig_joinname); lanConfig_joinname);
} else { } else {
@ -490,9 +490,9 @@ void () main_menu =
void () menu_init = void () menu_init =
{ {
lanConfig_port_il = [[InputLine alloc] initWithBounds:[[Rect alloc] initWithComponents:126 :lanConfig_cursor_table[0] :8 :4] promptCharacter:' ']; lanConfig_port_il = [[InputLineBox alloc] initWithBounds:[[Rect alloc] initWithComponents:126 :lanConfig_cursor_table[0] - 8 :8 :4] promptCharacter:' '];
[lanConfig_port_il setWidth:10]; [lanConfig_port_il setWidth:10];
lanConfig_join_il = [[InputLine alloc] initWithBounds:[[Rect alloc] initWithComponents:70 :lanConfig_cursor_table[2] :24 :4] promptCharacter:' ']; lanConfig_join_il = [[InputLineBox alloc] initWithBounds:[[Rect alloc] initWithComponents:70 :lanConfig_cursor_table[2] - 8 :24 :4] promptCharacter:' '];
[lanConfig_join_il setWidth:26]; [lanConfig_join_il setWidth:26];
switch (gametype ()) { switch (gametype ()) {
case "netquake": case "netquake":

View File

@ -668,14 +668,14 @@ DRAW_player_options =
Draw_String (x + 70, y + PLAYER_CONF_Y_PAD + 8, "Name..:"); Draw_String (x + 70, y + PLAYER_CONF_Y_PAD + 8, "Name..:");
text_box (x + 120, y + PLAYER_CONF_Y_PAD, 17, 1);
[player_config_plname_il setBasePos:x y:y]; [player_config_plname_il setBasePos:x y:y];
[player_config_plname_il draw: player_config_iactive == player_config_plname_il]; [player_config_plname_il cursor: player_config_iactive == player_config_plname_il];
[player_config_plname_il draw];
Draw_String (x + 70, y + PLAYER_CONF_Y_PAD + 20 + 8, "Team..:"); Draw_String (x + 70, y + PLAYER_CONF_Y_PAD + 20 + 8, "Team..:");
text_box (x + 120, y + PLAYER_CONF_Y_PAD + 20, 5, 1);
[player_config_tname_il setBasePos:x y:y]; [player_config_tname_il setBasePos:x y:y];
[player_config_tname_il draw:player_config_iactive == player_config_tname_il]; [player_config_tname_il cursor: player_config_iactive == player_config_tname_il];
[player_config_tname_il draw];
draw_val_item (x + 70, y + PLAYER_CONF_Y_PAD + 45, spacing, "Top color", draw_val_item (x + 70, y + PLAYER_CONF_Y_PAD + 45, spacing, "Top color",
@ -725,9 +725,9 @@ CB_ME_player_options =
void () void ()
MENU_player_options = MENU_player_options =
{ {
player_config_plname_il = [[InputLine alloc] initWithBounds:[[Rect alloc] initWithComponents:120 :PLAYER_CONF_Y_PAD + 8 :18 :4] promptCharacter:' ']; player_config_plname_il = [[InputLineBox alloc] initWithBounds:[[Rect alloc] initWithComponents:120 :PLAYER_CONF_Y_PAD :18 :4] promptCharacter:' '];
[player_config_plname_il setWidth:18]; [player_config_plname_il setWidth:18];
player_config_tname_il = [[InputLine alloc] initWithBounds:[[Rect alloc] initWithComponents:120 :PLAYER_CONF_Y_PAD + 8 + 20 :7 :4] promptCharacter:' ']; player_config_tname_il = [[InputLineBox alloc] initWithBounds:[[Rect alloc] initWithComponents:120 :PLAYER_CONF_Y_PAD + 20 :7 :4] promptCharacter:' '];
[player_config_tname_il setWidth:7]; [player_config_tname_il setWidth:7];
player_config_iactive = NIL; player_config_iactive = NIL;
@ -830,11 +830,11 @@ DRAW_network_options =
Draw_String (x + 70, y + NETWORK_CONF_Y_PAD + 8, "Rate..:"); Draw_String (x + 70, y + NETWORK_CONF_Y_PAD + 8, "Rate..:");
text_box (x + 120, y + NETWORK_CONF_Y_PAD, 9, 1);
[network_config_rate_il setBasePos:x y:y]; [network_config_rate_il setBasePos:x y:y];
[network_config_rate_il draw: network_config_iactive == network_config_rate_il]; [network_config_rate_il cursor: network_config_iactive == network_config_rate_il];
[network_config_rate_il draw];
opt_cursor (x + 62, y + player_config_cursor_tbl[player_config_cursor]); opt_cursor (x + 62, y + network_config_cursor_tbl[network_config_cursor]);
return 1; return 1;
}; };
@ -857,7 +857,7 @@ CB_ME_network_options =
void () void ()
MENU_network_options = MENU_network_options =
{ {
network_config_rate_il = [[InputLine alloc] initWithBounds:[[Rect alloc] initWithComponents: 120 :NETWORK_CONF_Y_PAD + 8 :9 :4] promptCharacter:' ']; network_config_rate_il = [[InputLineBox alloc] initWithBounds:[[Rect alloc] initWithComponents: 120 :NETWORK_CONF_Y_PAD :9 :4] promptCharacter:' '];
[network_config_rate_il setWidth:9]; [network_config_rate_il setWidth:9];
Menu_Begin (54, 90, "Network"); Menu_Begin (54, 90, "Network");

View File

@ -35,7 +35,8 @@ integer (integer x, integer y) servlist_filter_draw =
Draw_String (x + 62, y + 40, "Max Ping........:"); Draw_String (x + 62, y + 40, "Max Ping........:");
text_box (x + 206, y + 32, 4, 1); text_box (x + 206, y + 32, 4, 1);
[serv_maxping setBasePos:x y:y]; [serv_maxping setBasePos:x y:y];
[serv_maxping draw:1]; [serv_maxping cursor:1];
[serv_maxping draw];
Draw_String (x + 62, y + 56, "Game Contains...:"); Draw_String (x + 62, y + 56, "Game Contains...:");
text_box (x + 206, y + 48, 8, 1); text_box (x + 206, y + 48, 8, 1);
Draw_String (x + 62, y + 72, "Server Not Full.:"); Draw_String (x + 62, y + 72, "Server Not Full.:");

View File

@ -14,6 +14,7 @@
- (void) dealloc - (void) dealloc
{ {
[views dealloc]; [views dealloc];
[super dealloc];
} }
- (View) addView: (View)aView - (View) addView: (View)aView

View File

@ -1,3 +1,4 @@
#include "draw.h"
#include "gui/InputLine.h" #include "gui/InputLine.h"
#include "gui/Rect.h" #include "gui/Rect.h"
@ -15,9 +16,9 @@ string (inputline_t il) InputLine_GetText = #0;
- (id) initWithBounds: (Rect)aRect promptCharacter: (integer)char - (id) initWithBounds: (Rect)aRect promptCharacter: (integer)char
{ {
self = [super init]; self = [super initWithComponents:aRect.origin.x :aRect.origin.y :aRect.size.width * 8 :8];
control.x = aRect.origin.x; control.x = xpos;
control.y = aRect.origin.y; control.y = ypos;
control.xbase = control.ybase = 0; control.xbase = control.ybase = 0;
control.cursor = NO; control.cursor = NO;
@ -27,10 +28,10 @@ string (inputline_t il) InputLine_GetText = #0;
return self; return self;
} }
- (void) free - (void) dealloc
{ {
InputLine_Destroy (il); InputLine_Destroy (il);
[super free]; [super dealloc];
} }
- (void) setBasePos: (Point)pos - (void) setBasePos: (Point)pos
@ -50,9 +51,13 @@ string (inputline_t il) InputLine_GetText = #0;
InputLine_Process (il, key); InputLine_Process (il, key);
} }
- (void) draw: (BOOL)cursor - (void) cursor: (BOOL)cursor
{ {
control.cursor = cursor; control.cursor = cursor;
}
- (void) draw
{
InputLine_Draw (il); InputLine_Draw (il);
} }
@ -68,3 +73,64 @@ string (inputline_t il) InputLine_GetText = #0;
} }
@end @end
@implementation InputLineBox
- (id) initWithBounds: (Rect)aRect promptCharacter: (integer)char
{
local integer xp, yp, xl, yl;
local Rect r;
xp = aRect.origin.x;
yp = aRect.origin.y;
xl = (aRect.size.width - 2) * 8;
yl = 24;
self = [self initWithComponents:xp :yp :xl :yl];
xp = 0;
yp = 8;
xl = aRect.size.width;
yl = aRect.size.height;
r = [[Rect alloc] initWithComponents:xp :yp :xl :yl];
input_line = [[InputLine alloc] initWithBounds:r promptCharacter:char];
[r dealloc];
return self;
}
- (void) setWidth: (integer)width
{
[input_line setWidth:width];
}
- (void) cursor: (BOOL)cursor
{
[input_line cursor:cursor];
}
- (void) processInput: (integer)key
{
[input_line processInput:key];
}
- (id) setText: (string)text
{
return [input_line setText:text];
}
- (string) text
{
return [input_line text];
}
- (void) setBasePos:(integer)x y:(integer)y
{
[super setBasePos:x y:y];
[input_line setBasePos:xabs y:yabs];
}
- (void) draw
{
[super draw];
text_box (xabs, yabs, xlen / 8, ylen / 24);
[input_line draw];
}
@end

View File

@ -12,6 +12,7 @@
-(void)dealloc -(void)dealloc
{ {
str_free (pic_name); str_free (pic_name);
[super dealloc];
} }
-(void)setPic:(string)pic -(void)setPic:(string)pic

View File

@ -12,6 +12,7 @@
- (void) dealloc - (void) dealloc
{ {
str_free (text); str_free (text);
[super dealloc];
} }
- (id) initWithBounds: (Rect)aRect - (id) initWithBounds: (Rect)aRect

View File

@ -11,7 +11,7 @@
xpos = xabs = x; xpos = xabs = x;
ypos = yabs = y; ypos = yabs = y;
xlen = w; xlen = w;
ylen = y; ylen = h;
parent = NIL; parent = NIL;
return self; return self;
} }

View File

@ -32,12 +32,11 @@ struct il_data_t = {
} }
- (id) initWithBounds: (Rect)aRect promptCharacter: (integer)char; - (id) initWithBounds: (Rect)aRect promptCharacter: (integer)char;
//-initAt:(Point)p HistoryLines:(integer)l LineSize:(integer)s PromptChar:(integer)prompt;
- (void) free;
- (void) setBasePos: (Point)pos; - (void) setBasePos: (Point)pos;
- (void) setWidth: (integer)width; - (void) setWidth: (integer)width;
- (void) draw: (BOOL)cursor; - (void) cursor: (BOOL)cursor;
- (void) draw;
- (void) processInput: (integer)key; - (void) processInput: (integer)key;
@ -46,4 +45,19 @@ struct il_data_t = {
@end @end
@interface InputLineBox: View
{
InputLine input_line;
}
- (id) initWithBounds: (Rect)aRect promptCharacter: (integer)char;
- (void) setWidth: (integer)width;
- (void) cursor: (BOOL)cursor;
- (void) processInput: (integer)key;
- (id) setText: (string)text;
- (string) text;
@end
#endif //__ruamoko_gui_InputLine_h #endif //__ruamoko_gui_InputLine_h