Fixed some more servercommands, made scrollbar for userlist functional.

git-svn-id: svn://kolibrios.org@3215 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2013-02-01 18:37:23 +00:00
parent 1632f80d55
commit 31434d0fa5
3 changed files with 88 additions and 23 deletions

View File

@ -51,7 +51,7 @@ draw_window:
jne .not_channel jne .not_channel
mov ebx, [xsize] mov ebx, [xsize]
sub ebx, 100 sub ebx, USERLIST_X + SCROLLBAR_WIDTH + 3
push bx push bx
shl ebx, 16 shl ebx, 16
pop bx pop bx
@ -74,7 +74,6 @@ draw_window:
mov [edit1.top], eax mov [edit1.top], eax
mov eax, [xsize] mov eax, [xsize]
sub eax, 10 ;;;;;;
mov [edit1.width], eax mov [edit1.width], eax
push dword edit1 push dword edit1
@ -107,33 +106,46 @@ print_channel_list:
pusha pusha
mov eax, 13 ; draw rectangle (clear list) mov eax, 13 ; draw rectangle (clear list)
mov ebx, [xsize] mov ebx, [xsize]
sub ebx, 95 sub ebx, USERLIST_X + SCROLLBAR_WIDTH
shl ebx, 16 shl ebx, 16
push ebx push ebx
mov bx, 90 ; x size ;;; FIXME mov bx, USERLIST_X
mov ecx, TEXT_Y shl 16 + 12*10 ; y size ;;; FIXME mov ecx, [ysize]
add ecx, TEXT_Y shl 16 - (TEXT_Y + 35 + 10 ) ;;;;;
mov edx, [colors.work] mov edx, [colors.work]
mcall mcall
mov eax, 4 ; draw text mov eax, [scroll1.position]
xor edx, edx
mov ecx, MAX_NICK_LEN
mul ecx
mov edx, eax
mov eax, [window_open]
add edx, [eax + window.data_ptr]
add edx, window_data.names
pop ebx pop ebx
mov bx, TEXT_Y mov bx, TEXT_Y
mov ecx, [colors.work_text] mov ecx, [colors.work_text]
or ecx, 0x80000000 ; ASCIIZ string or ecx, 0x80000000 ; ASCIIZ string
mov edx, [window_open] mov eax, 4 ; draw text
mov edx, [edx + window.data_ptr]
add edx, window_data.names mov edi, [ysize] ; Calculate how many names will fit on screen
mov edi, MAX_CHANNELS sub edi, TEXT_Y + 35 + 10 ;;;;;
.loop: .loop:
; TODO: check if name is selected and highlight background color if so
cmp byte[edx], ' ' ; end of list?
je .done
mcall mcall
add edx, MAX_NICK_LEN ; next name add edx, MAX_NICK_LEN ; next name
add ebx, 10 ; height distance between lines add ebx, 10 ; height distance between lines
dec edi sub edi, 10
jnz .loop ja .loop
.done:
popa popa

View File

@ -67,6 +67,8 @@ WINDOW_BTN_START = 100
SCROLLBAR_WIDTH = 12 SCROLLBAR_WIDTH = 12
USERLIST_X = 98
format binary as "" format binary as ""
@ -95,13 +97,14 @@ struct window
flags db ? flags db ?
type db ? type db ?
name rb MAX_WINDOWNAME_LEN name rb MAX_WINDOWNAME_LEN
users dd ?
users_scroll dd ?
ends ends
struct window_data struct window_data
text rb 120*60 text rb 120*60
title rb 256 title rb 256
names rb 1200 names rb 1200
namespos dd ?
usertext rb 256 usertext rb 256
usertextlen dd ? usertextlen dd ?
ends ends
@ -284,6 +287,9 @@ mouse:
push dword scroll1 push dword scroll1
call [scrollbar_v_mouse] call [scrollbar_v_mouse]
; TODO: check if scrollbar moved
call print_channel_list ;;;
jmp still jmp still
@ -407,7 +413,7 @@ usercommand db '/server chat.freenode.net', 0
I_END: I_END:
; width, left, top ; width, left, top
edit1 edit_box 0, 5, 0, 0xffffff, 0x6f9480, 0, 0, 0, USERCMD_MAX_SIZE, usercommand, mouse_dd, ed_focus, 25, 25 edit1 edit_box 0, 0, 0, 0xffffff, 0x6f9480, 0, 0, 0, USERCMD_MAX_SIZE, usercommand, mouse_dd, ed_focus, 25, 25
; xsize, xpos, ysize, ypos, max, cur, pos, bgcol, frcol, linecol ; xsize, xpos, ysize, ypos, max, cur, pos, bgcol, frcol, linecol
scroll1 scrollbar SCROLLBAR_WIDTH, 300, 150, TOP_Y, 10, 100, 0, 0, 0, 0, 0, 5 scroll1 scrollbar SCROLLBAR_WIDTH, 300, 150, TOP_Y, 10, 100, 0, 0, 0, 0, 0, 5

View File

@ -41,7 +41,7 @@ server_parser:
ret ret
.got_cmd: .got_cmd:
jmp dword[edi] jmp dword[edi]
server_commands: server_commands:
@ -431,6 +431,7 @@ ctcp_reply:
cmd_part: cmd_part:
add esi, 5 ; skip 'PART '
; Is it me who parted? ; Is it me who parted?
mov edi, servercommand+1 mov edi, servercommand+1
@ -460,11 +461,19 @@ cmd_part:
pop esi pop esi
call print_text2 call print_text2
mov esi, str_newline
call print_text2
;;; TODO: dec [window.users], remove username from the userlist
ret ret
cmd_join: cmd_join:
add esi, 5 ; skip 'JOIN '
; compare nick: did we join a channel? ; compare nick: did we join a channel?
mov edi, servercommand+1 mov edi, servercommand+1
call compare_to_nick call compare_to_nick
@ -493,7 +502,6 @@ cmd_join:
mov [ebx + window.type], WINDOWTYPE_CHANNEL mov [ebx + window.type], WINDOWTYPE_CHANNEL
mov [ebx + window.flags], 0 mov [ebx + window.flags], 0
add esi, 5 ; skip 'JOIN ' ; FIXME: perhaps scan for spaces instead?
call window_set_name call window_set_name
mov [window_open], ebx mov [window_open], ebx
@ -538,6 +546,8 @@ cmd_join:
mov esi, str_newline mov esi, str_newline
call print_text2 call print_text2
;;; TODO: inc [window.users], add username to the userlist
ret ret
@ -545,6 +555,8 @@ cmd_join:
cmd_nick: ; FIXME cmd_nick: ; FIXME
add esi, 5 ; skip 'NICK '
push esi push esi
; test for change of my nick ; test for change of my nick
mov esi, servercommand+1 mov esi, servercommand+1
@ -699,6 +711,7 @@ cmd_nick: ; FIXME
cmd_kick: cmd_kick:
add esi, 5 ; skip 'KICK '
; Is it me who got kicked? ; Is it me who got kicked?
mov edi, servercommand+1 mov edi, servercommand+1
call compare_to_nick call compare_to_nick
@ -722,6 +735,8 @@ cmd_kick:
pop esi pop esi
call print_text2 call print_text2
;;; TODO: dec [window.users], remove username from the userlist
ret ret
@ -738,12 +753,16 @@ cmd_quit:
mov esi, has_quit_irc mov esi, has_quit_irc
call print_text2 call print_text2
;;; TODO: dec [window.users], remove username from the userlist
ret ret
cmd_mode: cmd_mode:
add esi, 5 ; skip 'MODE '
push esi push esi
mov esi, action_header_short mov esi, action_header_short
call print_text2 call print_text2
@ -761,11 +780,15 @@ cmd_mode:
mov esi, str_newline mov esi, str_newline
call print_text2 call print_text2
;;; TODO: change username if needed
ret ret
cmd_353: ; channel usernames reply cmd_353: ; channel usernames reply
add esi, 4 ; skip '353 '
; TODO: mark a bit that we are receiving names ; TODO: mark a bit that we are receiving names
; first, find the channel name ; first, find the channel name
@ -781,8 +804,9 @@ cmd_353: ; channel usernames reply
.got_channel: .got_channel:
; call find_channel ;;;; ASSUME current channel for now ; call find_channel ;;;; ASSUME current channel for now
mov ebx, [window_print] mov ebx, [window_print]
mov ebx, [ebx + window.data_ptr] mov [ebx + window.users], 0 ;;; FIXME: Only if we have just set the receiving names bit
lea edi, [ebx + window_data.names] mov eax, [ebx + window.data_ptr]
lea edi, [eax + window_data.names]
lea edx, [edi + MAX_NICK_LEN] lea edx, [edi + MAX_NICK_LEN]
; now find the semicolon separating channelname and usernames ; now find the semicolon separating channelname and usernames
@ -806,18 +830,37 @@ cmd_353: ; channel usernames reply
jmp .namesloop jmp .namesloop
.next: .next:
inc [ebx + window.users]
mov edi, edx mov edi, edx
add edx, MAX_NICK_LEN add edx, MAX_NICK_LEN
;;; cmp edi, .. ; Check for buffer overflow ;;; cmp edi, .. ; TODO: Check for buffer overflow
jmp .namesloop jmp .namesloop
.done: .done:
call users_calculate
call print_channel_list call print_channel_list
ret ret
users_calculate:
mov eax, [ysize]
sub eax, TEXT_Y + 35 + 10 ;;;;
xor edx, edx
mov ecx, 10
div ecx
mov [scroll1.max_area], eax
mov ebx, [window_print]
mov eax, [ebx + window.users]
mov [scroll1.max_area], eax
; TODO: check if cur pos isnt greater then max
ret
cmd_366: ; channel usernames end cmd_366: ; channel usernames end
@ -830,6 +873,8 @@ cmd_366: ; channel usernames end
cmd_topic: cmd_topic:
add esi, 4 ; skip '332 '
.loop: .loop:
lodsb lodsb
test al, al test al, al
@ -856,6 +901,8 @@ cmd_topic:
cmd_333: cmd_333:
add esi, 4 ; skip '333 '
; TODO: check channelname and change pointer accordingly ; TODO: check channelname and change pointer accordingly
mov ecx, 3 ; number of spaces to find mov ecx, 3 ; number of spaces to find