diff options
author | Andrey Nazarov <skuller@skuller.net> | 2007-12-11 13:45:50 +0000 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2007-12-11 13:45:50 +0000 |
commit | 71df40aa90c690d6348ec48f9e3d128fb52ba0bf (patch) | |
tree | f743f65d0534622965fd3587cf3899e23cd65b36 | |
parent | e6358d790aa66b2c93584185158e7466f3ec166f (diff) |
Made Address Book menu resizable.
Properly reset `ui_background' to black.
-rw-r--r-- | source/ui_addressbook.c | 27 | ||||
-rw-r--r-- | source/ui_atoms.c | 4 | ||||
-rw-r--r-- | source/ui_menu.c | 45 |
3 files changed, 42 insertions, 34 deletions
diff --git a/source/ui_addressbook.c b/source/ui_addressbook.c index 02029d6..511a6c5 100644 --- a/source/ui_addressbook.c +++ b/source/ui_addressbook.c @@ -37,12 +37,12 @@ typedef struct m_addressBook_s { static m_addressBook_t m_addressBook; static void SaveChanges( void ) { - char buffer[32]; - int index; + char buffer[8]; + int i; - for( index = 0; index < MAX_LOCAL_SERVERS; index++ ) { - Com_sprintf( buffer, sizeof( buffer ), "adr%d", index ); - cvar.Set( buffer, m_addressBook.fields[index].field.text ); + for( i = 0; i < MAX_LOCAL_SERVERS; i++ ) { + Com_sprintf( buffer, sizeof( buffer ), "adr%d", i ); + cvar.Set( buffer, m_addressBook.fields[i].field.text ); } } @@ -51,6 +51,9 @@ static int AddressBook_MenuCallback( int id, int msg, int param ) { case QM_DESTROY: SaveChanges(); break; + case QM_SIZE: + Menu_Size( &m_addressBook.menu ); + break; default: break; } @@ -59,28 +62,26 @@ static int AddressBook_MenuCallback( int id, int msg, int param ) { } static void AddressBook_MenuInit( void ) { - char buffer[32]; - int i, y; + char buffer[8]; + int i; memset( &m_addressBook, 0, sizeof( m_addressBook ) ); m_addressBook.menu.callback = AddressBook_MenuCallback; - y = 64; for( i = 0; i < MAX_LOCAL_SERVERS; i++ ) { Com_sprintf( buffer, sizeof( buffer ), "adr%d", i ); m_addressBook.fields[i].generic.type = MTYPE_FIELD; - m_addressBook.fields[i].generic.name = NULL; - m_addressBook.fields[i].generic.x = ( uis.width - 30 * CHAR_WIDTH ) / 2 - RCOLUMN_OFFSET; - m_addressBook.fields[i].generic.y = y; - y += MENU_SPACING; - IF_InitText( &m_addressBook.fields[i].field, 30, 60, cvar.VariableString( buffer ) ); + IF_InitText( &m_addressBook.fields[i].field, 30, 60, + cvar.VariableString( buffer ) ); Menu_AddItem( &m_addressBook.menu, &m_addressBook.fields[i] ); } + m_addressBook.fields[0].generic.flags = QMF_HASFOCUS; + m_addressBook.menu.banner = "Address Book"; } diff --git a/source/ui_atoms.c b/source/ui_atoms.c index c1948fa..b92eae9 100644 --- a/source/ui_atoms.c +++ b/source/ui_atoms.c @@ -709,7 +709,9 @@ static const uicmd_t uicmds[] = { static void ui_background_changed( cvar_t *self ) { if( self->string[0] ) { uis.backgroundHandle = ref.RegisterPic( self->string ); - } + } else { + uis.backgroundHandle = 0; + } } static void ui_scale_changed( cvar_t *self ) { diff --git a/source/ui_menu.c b/source/ui_menu.c index 30a9a21..118a47e 100644 --- a/source/ui_menu.c +++ b/source/ui_menu.c @@ -235,22 +235,22 @@ Field_Init ================= */ static void Field_Init( menuField_t *f ) { - f->generic.uiFlags &= ~( UI_LEFT | UI_RIGHT ); + int w = f->field.visibleChars * CHAR_WIDTH; - f->generic.rect.x = f->generic.x + LCOLUMN_OFFSET; - f->generic.rect.y = f->generic.y; + f->generic.uiFlags &= ~( UI_LEFT | UI_RIGHT ); if( f->generic.name ) { + f->generic.rect.x = f->generic.x + LCOLUMN_OFFSET; + f->generic.rect.y = f->generic.y; UI_StringDimensions( &f->generic.rect, f->generic.uiFlags | UI_RIGHT, f->generic.name ); + f->generic.rect.width += RCOLUMN_OFFSET + w; } else { - f->generic.rect.width = 0; - f->generic.rect.height = CHAR_HEIGHT; + f->generic.rect.x = f->generic.x - w / 2; + f->generic.rect.y = f->generic.y; + f->generic.rect.width = w; + f->generic.rect.height = CHAR_HEIGHT; } - - f->generic.rect.width += RCOLUMN_OFFSET + - f->field.visibleChars * CHAR_WIDTH; - } @@ -260,23 +260,28 @@ Field_Draw ================= */ static void Field_Draw( menuField_t *f ) { - uint32 flags; + uint32 flags = f->generic.uiFlags; + + if( f->generic.flags & QMF_HASFOCUS ) { + flags |= UI_DRAWCURSOR; + } if( f->generic.name ) { UI_DrawString( f->generic.x + LCOLUMN_OFFSET, f->generic.y, NULL, f->generic.uiFlags | UI_RIGHT | UI_ALTCOLOR, f->generic.name ); - } - ref.DrawFillEx( f->generic.x + RCOLUMN_OFFSET, f->generic.y, - f->field.visibleChars * CHAR_WIDTH, CHAR_HEIGHT, colorField ); + ref.DrawFillEx( f->generic.x + RCOLUMN_OFFSET, f->generic.y - 1, + f->field.visibleChars * CHAR_WIDTH, CHAR_HEIGHT + 2, colorField ); - flags = f->generic.uiFlags; - if( f->generic.flags & QMF_HASFOCUS ) { - flags |= UI_DRAWCURSOR; - } + IF_Draw( &f->field, f->generic.x + RCOLUMN_OFFSET, f->generic.y, + flags, uis.fontHandle ); + } else { + ref.DrawFillEx( f->generic.rect.x, f->generic.rect.y - 1, + f->generic.rect.width, CHAR_HEIGHT + 2, colorField ); - IF_Draw( &f->field, f->generic.x + RCOLUMN_OFFSET, f->generic.y, - flags, uis.fontHandle ); + IF_Draw( &f->field, f->generic.rect.x, f->generic.rect.y, + flags, uis.fontHandle ); + } } /* @@ -293,7 +298,7 @@ static int Field_Key( menuField_t *f, int key ) { /* ================= -Field_Key +Field_Char ================= */ static int Field_Char( menuField_t *f, int key ) { |