Changeset 545 – HoverRace

Changeset 545

Show
Ignore:
Timestamp:
05/08/09 00:00:39 (15 months ago)
Author:
zoogie
Message:

Initial implementation of automatic linking of URLs in chat text:

  • The chat area is now a rich edit control; we can do more interesting things with formatting now.
  • Using the built-in link finding for now; we'll probably want to implement our own URL detection later since the built-in recognizes more protocols than we want to safely support.
Location:
trunk/client/Game2
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/client/Game2/Game2.rc

    • Property svn:eol-style set to CRLF
    r522 r545  
    527527                    LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | WS_BORDER |  
    528528                    WS_TABSTOP,3,108,113,124 
    529     EDITTEXT        IDC_CHAT_OUT,120,108,265,110,ES_MULTILINE | ES_READONLY |  
    530                     WS_VSCROLL | NOT WS_TABSTOP 
    531529    LTEXT           "Chat section",IDC_CHAT_SECTION_C,120,100,45,8 
    532530    LTEXT           "Game list",IDC_GAME_LIST_C,3,1,30,8 
     
    551549    PUSHBUTTON      "",IDC_PUB,3,234,382,42,BS_BITMAP | BS_FLAT | NOT  
    552550                    WS_TABSTOP,WS_EX_TRANSPARENT 
     551    CONTROL         "",IDC_CHAT_OUT,"RichEdit20W",WS_BORDER | WS_VSCROLL |  
     552                    WS_TABSTOP | 0x8c4,120,108,265,108 
    553553END 
    554554 
  • trunk/client/Game2/InternetRoom.cpp

    r468 r545  
    946946    SetWindowTextW(pDest, Str::UW(mChatBuffer)); 
    947947 
    948     SendMessage(pDest, EM_LINESCROLL, 0, 1000); 
    949     // SendMessage( pDest, WM_VSCROLL, SB_BOTTOM, 0 ); 
     948    //SendMessage(pDest, EM_LINESCROLL, 0, 1000); 
     949    SendMessage(pDest, WM_VSCROLL, SB_BOTTOM, 0); 
    950950} 
    951951 
     
    13511351                SetDlgItemTextW(pWindow, IDCANCEL, Str::UW(_("Quit"))); 
    13521352 
     1353                DWORD mask = SendDlgItemMessageW(pWindow, IDC_CHAT_OUT, EM_GETEVENTMASK, 0, 0); 
     1354                SendDlgItemMessageW(pWindow, IDC_CHAT_OUT, EM_SETEVENTMASK, 0, mask | ENM_LINK); 
     1355                SendDlgItemMessageW(pWindow, IDC_CHAT_OUT, EM_AUTOURLDETECT, TRUE, 0); 
     1356 
    13531357                RECT lRect; 
    13541358                HWND lList; 
     
    16991703                        break; 
    17001704 
    1701                 case IDC_USER_LIST: 
    1702                     if(lNotMessage->code == LVN_ITEMCHANGED) { 
    1703                         lReturnValue = TRUE; 
    1704  
    1705                         // Select the game corresponding to the selected 
    1706                         mThis->SelectGameForUser(pWindow); 
    1707                     } 
    1708                     break; 
    1709             } 
    1710         } 
    1711         break; 
     1705                    case IDC_USER_LIST: 
     1706                        if(lNotMessage->code == LVN_ITEMCHANGED) { 
     1707                            lReturnValue = TRUE; 
     1708 
     1709                            // Select the game corresponding to the selected 
     1710                            mThis->SelectGameForUser(pWindow); 
     1711                        } 
     1712                        break; 
     1713 
     1714                    case IDC_CHAT_OUT: 
     1715                        // User clicked on a link. 
     1716                        if (lNotMessage->code == EN_LINK) { 
     1717                            ENLINK *linkInfo = (ENLINK*)pLParam; 
     1718                            if (linkInfo->msg == WM_LBUTTONUP) { 
     1719                                CHARRANGE *chrg = &linkInfo->chrg; 
     1720                                int len = chrg->cpMax - chrg->cpMin; 
     1721                                wchar_t url[512] = { 0 }; 
     1722                                TEXTRANGEW range; 
     1723                                range.chrg.cpMin = chrg->cpMin; 
     1724                                range.chrg.cpMax = (len > 511) ? chrg->cpMin + 511 : chrg->cpMax; 
     1725                                range.lpstrText = url; 
     1726                                SendDlgItemMessageW(pWindow, IDC_CHAT_OUT, EM_GETTEXTRANGE, 0, (LPARAM)&range); 
     1727 
     1728                                // Open the URL in the browser. 
     1729                                //TODO: Move this to Util::OS. 
     1730                                //FIXME: Need to make sure we're only handling "http:", "https:", and "ftp:". 
     1731                                OutputDebugStringW(L"Opening URL: "); 
     1732                                OutputDebugStringW(range.lpstrText); 
     1733                                OutputDebugStringW(L"\n"); 
     1734                                ShellExecuteW(NULL, L"open", range.lpstrText, NULL, NULL, SW_SHOWNORMAL); 
     1735                            } 
     1736                        } 
     1737                        break; 
     1738                } 
     1739            } 
     1740            break; 
    17121741 
    17131742        case WM_COMMAND: 
  • trunk/client/Game2/resource.h

    r468 r545  
    180180#define IDC_GAMMA_LBL                   1245 
    181181#define IDC_DLTRACK                     1333 
     182#define IDC_CHAT_TXT                    1335 
    182183#define ID_VIEW_3DACTION                32775 
    183184#define ID_SETTING_WINDOW               32784 
     
    397398#define _APS_NEXT_RESOURCE_VALUE        166 
    398399#define _APS_NEXT_COMMAND_VALUE         40049 
    399 #define _APS_NEXT_CONTROL_VALUE         1334 
     400#define _APS_NEXT_CONTROL_VALUE         1336 
    400401#define _APS_NEXT_SYMED_VALUE           101 
    401402#endif