Ticket #885: faster-0ad-gui.patch
File faster-0ad-gui.patch, 116.0 KB (added by , 13 years ago) |
---|
-
source/gui/GUITooltip.cpp
168 168 169 169 // Unhide the object. (If it had use_object and hide_object="true", 170 170 // still unhide it, because the used object might be hidden by default) 171 GUI<bool>::SetSetting(usedobj, "hidden", false); 171 // GUI<bool>::SetSetting(usedobj, "hidden", false); 172 usedobj->SetHidden(false); 172 173 } 173 174 else 174 175 { 175 176 // Unhide the object 176 GUI<bool>::SetSetting(usedobj, "hidden", false); 177 // GUI<bool>::SetSetting(usedobj, "hidden", false); 178 usedobj->SetHidden(false); 177 179 178 180 // Store mouse position inside the CTooltip 179 181 if (GUI<CPos>::SetSetting(usedobj, "_mousepos", pos) != PSRETURN_OK) … … 241 243 242 244 // If hide_object was enabled, hide it 243 245 if (hideobject) 244 GUI<bool>::SetSetting(usedobj, "hidden", true); 246 { 247 // GUI<bool>::SetSetting(usedobj, "hidden", true); 248 usedobj->SetHidden(true); 249 } 250 245 251 } 246 252 else 247 253 { 248 GUI<bool>::SetSetting(tooltipobj, "hidden", true); 254 // GUI<bool>::SetSetting(tooltipobj, "hidden", true); 255 tooltipobj->SetHidden(true); 249 256 } 250 257 251 258 } -
source/gui/CInput.cpp
41 41 //------------------------------------------------------------------- 42 42 CInput::CInput() : m_iBufferPos(-1), m_iBufferPos_Tail(-1), m_SelectingText(false), m_HorizontalScroll(0.f) 43 43 { 44 AddSetting(GUIST_float, "buffer_zone" );45 AddSetting(GUIST_CStrW, "caption" );46 AddSetting(GUIST_int, "cell_id" );47 AddSetting(GUIST_CStrW, "font" );48 AddSetting(GUIST_int, "max_length" );49 AddSetting(GUIST_bool, "multiline" );50 AddSetting(GUIST_bool, "scrollbar" );51 AddSetting(GUIST_CStr, "scrollbar_style" );52 AddSetting(GUIST_CGUISpriteInstance, "sprite" );53 AddSetting(GUIST_CGUISpriteInstance, "sprite_selectarea" );54 AddSetting(GUIST_CColor, "textcolor" );55 AddSetting(GUIST_CColor, "textcolor_selected" );56 AddSetting(GUIST_CStrW, "tooltip" );57 AddSetting(GUIST_CStr, "tooltip_style" );44 AddSetting(GUIST_float, "buffer_zone", &m_BufferZone); 45 AddSetting(GUIST_CStrW, "caption", &m_Caption); 46 AddSetting(GUIST_int, "cell_id", &m_CellId); 47 AddSetting(GUIST_CStrW, "font", &m_Font); 48 AddSetting(GUIST_int, "max_length", &m_MaxLength); 49 AddSetting(GUIST_bool, "multiline", &m_Multiline); 50 AddSetting(GUIST_bool, "scrollbar", &m_Scrollbar); 51 AddSetting(GUIST_CStr, "scrollbar_style", &m_ScrollbarStyle); 52 AddSetting(GUIST_CGUISpriteInstance, "sprite", &m_Sprite); 53 AddSetting(GUIST_CGUISpriteInstance, "sprite_selectarea", &m_SpriteSelectArea); 54 AddSetting(GUIST_CColor, "textcolor", &m_TextColor); 55 AddSetting(GUIST_CColor, "textcolor_selected", &m_TextColorSelected); 56 AddSetting(GUIST_CStrW, "tooltip", &m_Tooltip); 57 AddSetting(GUIST_CStr, "tooltip_style", &m_TooltipStyle); 58 58 59 m_BufferZone = 0.f; 60 m_Font = L""; 61 59 62 // Add scroll-bar 60 63 CGUIScrollBarVertical * bar = new CGUIScrollBarVertical(); 61 64 bar->SetRightAligned(true); … … 80 83 // Since the GUI framework doesn't handle to set settings 81 84 // in Unicode (CStrW), we'll simply retrieve the actual 82 85 // pointer and edit that. 83 CStrW *pCaption = (CStrW*)m_Settings["caption"].m_pSetting;84 86 bool shiftKeyPressed = g_keys[SDLK_RSHIFT] || g_keys[SDLK_LSHIFT]; 85 87 86 88 int szChar = ev->ev.key.keysym.sym; … … 102 104 { 103 105 m_iBufferPos_Tail = -1; 104 106 105 if ( pCaption->empty() || m_iBufferPos == 0)107 if (m_Caption.empty() || m_iBufferPos == 0) 106 108 { 107 109 break; 108 110 } 109 111 else 110 112 { 111 if (m_iBufferPos == (int) pCaption->length())112 *pCaption = pCaption->Left( (long) pCaption->length()-1);113 if (m_iBufferPos == (int)m_Caption.length()) 114 m_Caption = m_Caption.Left( (long) m_Caption.length()-1); 113 115 else 114 *pCaption = pCaption->Left( m_iBufferPos-1 ) +115 pCaption->Right( (long) pCaption->length()-m_iBufferPos );116 m_Caption = m_Caption.Left( m_iBufferPos-1 ) + 117 m_Caption.Right( (long) m_Caption.length()-m_iBufferPos ); 116 118 117 119 --m_iBufferPos; 118 120 119 121 UpdateText(m_iBufferPos, m_iBufferPos+1, m_iBufferPos); 120 122 } 121 123 } … … 132 134 } 133 135 else 134 136 { 135 if ( pCaption->empty() || m_iBufferPos == (int)pCaption->length())137 if (m_Caption.empty() || m_iBufferPos == (int)m_Caption.length()) 136 138 { 137 139 break; 138 140 } 139 141 else 140 142 { 141 *pCaption = pCaption->Left( m_iBufferPos ) +142 pCaption->Right( (long) pCaption->length()-(m_iBufferPos+1) );143 m_Caption = m_Caption.Left( m_iBufferPos ) + 144 m_Caption.Right( (long) m_Caption.length()-(m_iBufferPos+1) ); 143 145 144 146 UpdateText(m_iBufferPos, m_iBufferPos+1, m_iBufferPos); 145 147 } … … 180 182 m_iBufferPos_Tail = m_iBufferPos; 181 183 } 182 184 183 m_iBufferPos = (long) pCaption->length();185 m_iBufferPos = (long) m_Caption.length(); 184 186 m_WantedX=0.0f; 185 187 186 188 UpdateAutoScroll(); … … 222 224 m_iBufferPos_Tail = m_iBufferPos; 223 225 } 224 226 225 if (m_iBufferPos > 0) 227 if (m_iBufferPos > 0) 226 228 --m_iBufferPos; 227 229 } 228 230 else … … 250 252 m_iBufferPos_Tail = m_iBufferPos; 251 253 } 252 254 253 if (m_iBufferPos < (int) pCaption->length())255 if (m_iBufferPos < (int)m_Caption.length()) 254 256 ++m_iBufferPos; 255 257 } 256 258 else … … 259 261 m_iBufferPos = m_iBufferPos_Tail; 260 262 261 263 m_iBufferPos_Tail = -1; 262 } 264 } 263 265 264 266 UpdateAutoScroll(); 265 267 break; … … 301 303 if (m_iBufferPos >= current->m_ListStart && 302 304 m_iBufferPos <= current->m_ListStart+(int)current->m_ListOfX.size()) 303 305 break; 304 306 305 307 ++current; 306 308 } 307 309 … … 324 326 m_iBufferPos = current->m_ListStart + GetXTextPosition(current, pos_x, m_WantedX); 325 327 } 326 328 // else we can't move up 327 329 328 330 UpdateAutoScroll(); 329 331 } 330 332 break; … … 346 348 if (m_iBufferPos >= current->m_ListStart && 347 349 m_iBufferPos <= current->m_ListStart+(int)current->m_ListOfX.size()) 348 350 break; 349 351 350 352 ++current; 351 353 } 352 354 … … 387 389 // 'Return' should do a Press event for single liners (e.g. submitting forms) 388 390 // otherwise a '\n' character will be added. 389 391 { 390 bool multiline; 391 GUI<bool>::GetSetting(this, "multiline", multiline); 392 if (!multiline) 392 if (!m_Multiline) 393 393 { 394 394 SendEvent(GUIM_PRESSED, "press"); 395 395 break; … … 404 404 return IN_PASS; // Important, because we didn't use any key 405 405 406 406 // check max length 407 int max_length; 408 GUI<int>::GetSetting(this, "max_length", max_length); 409 if (max_length != 0 && (int)pCaption->length() >= max_length) 407 if (m_MaxLength != 0 && (int)m_Caption.length() >= m_MaxLength) 410 408 break; 411 409 412 410 m_WantedX=0.0f; … … 415 413 DeleteCurSelection(); 416 414 m_iBufferPos_Tail = -1; 417 415 418 if (m_iBufferPos == (int) pCaption->length())419 *pCaption += cooked;416 if (m_iBufferPos == (int)m_Caption.length()) 417 m_Caption += cooked; 420 418 else 421 *pCaption = pCaption->Left(m_iBufferPos) + cooked +422 pCaption->Right((long) pCaption->length()-m_iBufferPos);419 m_Caption = m_Caption.Left(m_iBufferPos) + cooked + 420 m_Caption.Right((long) m_Caption.length()-m_iBufferPos); 423 421 424 422 UpdateText(m_iBufferPos, m_iBufferPos, m_iBufferPos+1); 425 423 … … 439 437 440 438 InReaction CInput::ManuallyHandleHotkeyEvent(const SDL_Event_* ev) 441 439 { 442 CStrW *pCaption = (CStrW*)m_Settings["caption"].m_pSetting;443 440 bool shiftKeyPressed = g_keys[SDLK_RSHIFT] || g_keys[SDLK_LSHIFT]; 444 441 445 442 std::string hotkey = static_cast<const char*>(ev->ev.user.data1); … … 455 452 DeleteCurSelection(); 456 453 } 457 454 458 if (m_iBufferPos == (int) pCaption->length())459 *pCaption += text;455 if (m_iBufferPos == (int)m_Caption.length()) 456 m_Caption += text; 460 457 else 461 *pCaption = pCaption->Left(m_iBufferPos) + text +462 pCaption->Right((long) pCaption->length()-m_iBufferPos);458 m_Caption = m_Caption.Left(m_iBufferPos) + text + 459 m_Caption.Right((long) m_Caption.length()-m_iBufferPos); 463 460 464 461 UpdateText(m_iBufferPos, m_iBufferPos, m_iBufferPos+1); 465 462 … … 490 487 virtualTo = m_iBufferPos; 491 488 } 492 489 493 CStrW text = ( pCaption->Left(virtualTo)).Right(virtualTo - virtualFrom);490 CStrW text = (m_Caption.Left(virtualTo)).Right(virtualTo - virtualFrom); 494 491 495 492 sys_clipboard_set(&text[0]); 496 493 … … 510 507 { 511 508 DeleteCurSelection(); 512 509 } 513 if (! pCaption->empty() && !m_iBufferPos == 0)510 if (!m_Caption.empty() && !m_iBufferPos == 0) 514 511 { 515 512 m_iBufferPos_Tail = m_iBufferPos; 516 CStrW searchString = pCaption->Left( m_iBufferPos );513 CStrW searchString = m_Caption.Left( m_iBufferPos ); 517 514 518 515 // If we are starting in whitespace, adjust position until we get a non whitespace 519 516 while (m_iBufferPos > 0) … … 523 520 524 521 m_iBufferPos--; 525 522 } 526 523 527 524 // If we end up on a puctuation char we just delete it (treat punct like a word) 528 525 if (iswpunct(searchString[m_iBufferPos - 1])) 529 526 m_iBufferPos--; … … 542 539 DeleteCurSelection(); 543 540 } 544 541 return IN_HANDLED; 545 } 542 } 546 543 else if (hotkey == "text.delete.right") 547 544 { 548 545 m_WantedX=0.0f; … … 551 548 { 552 549 DeleteCurSelection(); 553 550 } 554 if (! pCaption->empty() && m_iBufferPos < (int)pCaption->length())551 if (!m_Caption.empty() && m_iBufferPos < (int)m_Caption.length()) 555 552 { 556 553 // Delete the word to the right of the cursor 557 554 m_iBufferPos_Tail = m_iBufferPos; 558 555 559 556 // Delete chars to the right unit we hit whitespace 560 while (++m_iBufferPos < (int) pCaption->length())557 while (++m_iBufferPos < (int)m_Caption.length()) 561 558 { 562 if (iswspace( (*pCaption)[m_iBufferPos]) || iswpunct((*pCaption)[m_iBufferPos]))559 if (iswspace(m_Caption[m_iBufferPos]) || iswpunct(m_Caption[m_iBufferPos])) 563 560 break; 564 561 } 565 562 566 563 // Eliminate any whitespace behind the word we just deleted 567 while (m_iBufferPos < (int) pCaption->length())564 while (m_iBufferPos < (int)m_Caption.length()) 568 565 { 569 if (!iswspace( (*pCaption)[m_iBufferPos]))566 if (!iswspace(m_Caption[m_iBufferPos])) 570 567 break; 571 568 572 569 m_iBufferPos++; 573 570 } 574 571 DeleteCurSelection(); 575 572 } 576 return IN_HANDLED; 573 return IN_HANDLED; 577 574 } 578 575 else if (hotkey == "text.move.left") 579 576 { 580 577 m_WantedX=0.0f; 581 578 582 579 if (shiftKeyPressed || !SelectingText()) 583 580 { 584 581 if (!shiftKeyPressed) … … 590 587 m_iBufferPos_Tail = m_iBufferPos; 591 588 } 592 589 593 if (! pCaption->empty() && !m_iBufferPos == 0)590 if (!m_Caption.empty() && !m_iBufferPos == 0) 594 591 { 595 CStrW searchString = pCaption->Left( m_iBufferPos );592 CStrW searchString = m_Caption.Left( m_iBufferPos ); 596 593 597 594 // If we are starting in whitespace, adjust position until we get a non whitespace 598 595 while (m_iBufferPos > 0) … … 602 599 603 600 m_iBufferPos--; 604 601 } 605 602 606 603 // If we end up on a puctuation char we just select it (treat punct like a word) 607 604 if (iswpunct(searchString[m_iBufferPos - 1])) 608 605 m_iBufferPos--; … … 646 643 m_iBufferPos_Tail = m_iBufferPos; 647 644 } 648 645 649 if (! pCaption->empty() && m_iBufferPos < (int)pCaption->length())646 if (!m_Caption.empty() && m_iBufferPos < (int)m_Caption.length()) 650 647 { 651 CStrW searchString = *pCaption;652 653 648 // Select chars to the right until we hit whitespace 654 while (++m_iBufferPos < (int) pCaption->length())649 while (++m_iBufferPos < (int)m_Caption.length()) 655 650 { 656 if (iswspace( (*pCaption)[m_iBufferPos]) || iswpunct((*pCaption)[m_iBufferPos]))651 if (iswspace(m_Caption[m_iBufferPos]) || iswpunct(m_Caption[m_iBufferPos])) 657 652 break; 658 653 } 659 654 660 655 // Also select any whitespace following the word we just selected 661 while (m_iBufferPos < (int) pCaption->length())656 while (m_iBufferPos < (int)m_Caption.length()) 662 657 { 663 if (!iswspace( (*pCaption)[m_iBufferPos]))658 if (!iswspace(m_Caption[m_iBufferPos])) 664 659 break; 665 660 666 661 m_iBufferPos++; … … 673 668 m_iBufferPos = m_iBufferPos_Tail; 674 669 675 670 m_iBufferPos_Tail = -1; 676 } 671 } 677 672 678 673 UpdateAutoScroll(); 679 674 … … 695 690 { 696 691 case GUIM_SETTINGS_UPDATED: 697 692 { 698 bool scrollbar;699 GUI<bool>::GetSetting(this, "scrollbar", scrollbar);700 701 693 // Update scroll-bar 702 694 // TODO Gee: (2004-09-01) Is this really updated each time it should? 703 if ( scrollbar &&704 (Message.value == CStr("size") || 695 if (m_Scrollbar && 696 (Message.value == CStr("size") || 705 697 Message.value == CStr("z") || 706 698 Message.value == CStr("absolute"))) 707 { 699 { 708 700 GetScrollBar(0).SetX(m_CachedActualSize.right); 709 701 GetScrollBar(0).SetY(m_CachedActualSize.top); 710 702 GetScrollBar(0).SetZ(GetBufferedZ()); … … 714 706 // Update scrollbar 715 707 if (Message.value == CStr("scrollbar_style")) 716 708 { 717 CStr scrollbar_style; 718 GUI<CStr>::GetSetting(this, Message.value, scrollbar_style); 719 720 GetScrollBar(0).SetScrollBarStyle(scrollbar_style); 709 GetScrollBar(0).SetScrollBarStyle(m_ScrollbarStyle); 721 710 } 722 711 723 if (Message.value == CStr("size") || 712 if (Message.value == CStr("size") || 724 713 Message.value == CStr("z") || 725 Message.value == CStr("font") || 714 Message.value == CStr("font") || 726 715 Message.value == CStr("absolute") || 727 716 Message.value == CStr("caption") || 728 717 Message.value == CStr("scrollbar") || … … 733 722 734 723 if (Message.value == CStr("multiline")) 735 724 { 736 bool multiline; 737 GUI<bool>::GetSetting(this, "multiline", multiline); 738 739 if (multiline == false) 725 if (!m_Multiline) 740 726 { 741 727 GetScrollBar(0).SetLength(0.f); 742 728 } … … 747 733 748 734 UpdateText(); 749 735 } 750 736 751 737 }break; 752 738 753 739 case GUIM_MOUSE_PRESS_LEFT: 754 740 // Check if we're selecting the scrollbar: 755 741 { 756 bool scrollbar, multiline; 757 GUI<bool>::GetSetting(this, "scrollbar", scrollbar); 758 GUI<bool>::GetSetting(this, "multiline", multiline); 759 760 if (GetScrollBar(0).GetStyle() && multiline) 742 if (GetScrollBar(0).GetStyle() && m_Multiline) 761 743 { 762 744 if (GetMousePos().x > m_CachedActualSize.right - GetScrollBar(0).GetStyle()->m_Width) 763 745 break; … … 778 760 } 779 761 780 762 m_SelectingText = true; 781 763 782 764 UpdateAutoScroll(); 783 765 784 766 // If we immediately release the button it will just be seen as a click … … 788 770 789 771 case GUIM_MOUSE_DBLCLICK_LEFT: 790 772 { 791 CStrW *pCaption = (CStrW*)m_Settings["caption"].m_pSetting;792 773 m_iBufferPos = m_iBufferPos_Tail = GetMouseHoveringTextPosition(); 793 774 794 775 // See if we are clicking over whitespace 795 if (iswspace( (*pCaption)[m_iBufferPos]))776 if (iswspace(m_Caption[m_iBufferPos])) 796 777 { 797 778 // see if we are in a section of whitespace greater than one character 798 if ((m_iBufferPos + 1 < (int) pCaption->length() && iswspace((*pCaption)[m_iBufferPos + 1])) ||799 (m_iBufferPos - 1 > 0 && iswspace( (*pCaption)[m_iBufferPos - 1])))779 if ((m_iBufferPos + 1 < (int) m_Caption.length() && iswspace(m_Caption[m_iBufferPos + 1])) || 780 (m_iBufferPos - 1 > 0 && iswspace(m_Caption[m_iBufferPos - 1]))) 800 781 { 801 782 // 802 783 // We are clicking in an area with more than one whitespace character … … 806 787 // skip the whitespace 807 788 while (m_iBufferPos > 0) 808 789 { 809 if (!iswspace( (*pCaption)[m_iBufferPos - 1]))790 if (!iswspace(m_Caption[m_iBufferPos - 1])) 810 791 break; 811 792 812 793 m_iBufferPos--; … … 814 795 // now go until we hit white space or punctuation 815 796 while (m_iBufferPos > 0) 816 797 { 817 if (iswspace( (*pCaption)[m_iBufferPos - 1]))798 if (iswspace(m_Caption[m_iBufferPos - 1])) 818 799 break; 819 800 820 801 m_iBufferPos--; 821 802 822 if (iswpunct( (*pCaption)[m_iBufferPos]))803 if (iswpunct(m_Caption[m_iBufferPos])) 823 804 break; 824 805 } 825 806 826 807 // [2] Then the right 827 808 // go right until we are not in whitespace 828 while (++m_iBufferPos_Tail < (int) pCaption->length())809 while (++m_iBufferPos_Tail < (int)m_Caption.length()) 829 810 { 830 if (!iswspace( (*pCaption)[m_iBufferPos_Tail]))811 if (!iswspace(m_Caption[m_iBufferPos_Tail])) 831 812 break; 832 813 } 833 814 // now go to the right until we hit whitespace or punctuation 834 while (++m_iBufferPos_Tail < (int) pCaption->length())815 while (++m_iBufferPos_Tail < (int)m_Caption.length()) 835 816 { 836 if (iswspace( (*pCaption)[m_iBufferPos_Tail]) || iswpunct((*pCaption)[m_iBufferPos_Tail]))817 if (iswspace(m_Caption[m_iBufferPos_Tail]) || iswpunct(m_Caption[m_iBufferPos_Tail])) 837 818 break; 838 819 } 839 820 } 840 821 else 841 822 { 842 823 // single whitespace so select word to the right 843 while (++m_iBufferPos_Tail < (int) pCaption->length())824 while (++m_iBufferPos_Tail < (int)m_Caption.length()) 844 825 { 845 if (!iswspace( (*pCaption)[m_iBufferPos_Tail]))826 if (!iswspace(m_Caption[m_iBufferPos_Tail])) 846 827 break; 847 828 } 848 829 … … 850 831 m_iBufferPos = m_iBufferPos_Tail; 851 832 852 833 // now go to the right until we hit whitespace or punctuation 853 while (++m_iBufferPos_Tail < (int) pCaption->length())834 while (++m_iBufferPos_Tail < (int)m_Caption.length()) 854 835 { 855 if (iswspace( (*pCaption)[m_iBufferPos_Tail]) || iswpunct((*pCaption)[m_iBufferPos_Tail]))836 if (iswspace(m_Caption[m_iBufferPos_Tail]) || iswpunct(m_Caption[m_iBufferPos_Tail])) 856 837 break; 857 838 } 858 839 } … … 863 844 // go until we hit white space or punctuation 864 845 while (m_iBufferPos > 0) 865 846 { 866 if (iswspace( (*pCaption)[m_iBufferPos - 1]))847 if (iswspace(m_Caption[m_iBufferPos - 1])) 867 848 break; 868 849 869 850 m_iBufferPos--; 870 851 871 if (iswpunct( (*pCaption)[m_iBufferPos]))852 if (iswpunct(m_Caption[m_iBufferPos])) 872 853 break; 873 854 } 874 855 // go to the right until we hit whitespace or punctuation 875 while (++m_iBufferPos_Tail < (int) pCaption->length())856 while (++m_iBufferPos_Tail < (int)m_Caption.length()) 876 857 { 877 if (iswspace( (*pCaption)[m_iBufferPos_Tail]) || iswpunct((*pCaption)[m_iBufferPos_Tail]))858 if (iswspace(m_Caption[m_iBufferPos_Tail]) || iswpunct(m_Caption[m_iBufferPos_Tail])) 878 859 break; 879 860 } 880 861 } … … 929 910 GetScrollBar(0).SetZ( GetBufferedZ() ); 930 911 GetScrollBar(0).SetLength( m_CachedActualSize.bottom - m_CachedActualSize.top ); 931 912 932 CStr scrollbar_style; 933 GUI<CStr>::GetSetting(this, "scrollbar_style", scrollbar_style); 934 GetScrollBar(0).SetScrollBarStyle( scrollbar_style ); 913 GetScrollBar(0).SetScrollBarStyle( m_ScrollbarStyle ); 935 914 936 915 UpdateText(); 937 916 } … … 939 918 940 919 case GUIM_GOT_FOCUS: 941 920 m_iBufferPos = 0; 942 921 943 922 break; 944 923 945 924 case GUIM_LOST_FOCUS: … … 959 938 960 939 IGUIObject::UpdateCachedSize(); 961 940 962 bool scrollbar; 963 GUI<bool>::GetSetting(this, "scrollbar", scrollbar); 964 if (scrollbar) 941 if (m_Scrollbar) 965 942 { 966 943 GetScrollBar(0).SetX(m_CachedActualSize.right); 967 944 GetScrollBar(0).SetY(m_CachedActualSize.top); … … 972 949 973 950 void CInput::Draw() 974 951 { 975 float bz = GetBufferedZ();976 977 952 // First call draw on ScrollBarOwner 978 bool scrollbar; 979 float buffer_zone; 980 bool multiline; 981 GUI<bool>::GetSetting(this, "scrollbar", scrollbar); 982 GUI<float>::GetSetting(this, "buffer_zone", buffer_zone); 983 GUI<bool>::GetSetting(this, "multiline", multiline); 984 985 if (scrollbar && multiline) 953 if (m_Scrollbar && m_Multiline) 986 954 { 987 955 // Draw scrollbar 988 956 IGUIScrollBarOwner::Draw(); 989 957 } 990 958 991 959 if (GetGUI()) 992 { 993 CStrW font_name; 994 CColor color, color_selected; 995 //CStrW caption; 996 GUI<CStrW>::GetSetting(this, "font", font_name); 997 GUI<CColor>::GetSetting(this, "textcolor", color); 998 GUI<CColor>::GetSetting(this, "textcolor_selected", color_selected); 999 1000 // Get pointer of caption, it might be very large, and we don't 1001 // want to copy it continuously. 1002 CStrW *pCaption = (CStrW*)m_Settings["caption"].m_pSetting; 960 { 961 float bz = GetBufferedZ(); 1003 962 1004 CGUISpriteInstance *sprite=NULL, *sprite_selectarea=NULL; 1005 int cell_id; 1006 1007 GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite", sprite); 1008 GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_selectarea", sprite_selectarea); 1009 1010 GUI<int>::GetSetting(this, "cell_id", cell_id); 963 GetGUI()->DrawSprite(m_Sprite, m_CellId, bz, m_CachedActualSize); 1011 964 1012 GetGUI()->DrawSprite(*sprite, cell_id, bz, m_CachedActualSize);1013 1014 965 float scroll=0.f; 1015 if ( scrollbar && multiline)966 if (m_Scrollbar && m_Multiline) 1016 967 { 1017 968 scroll = GetScrollBar(0).GetPos(); 1018 969 } … … 1026 977 1027 978 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 1028 979 1029 CFont font( font_name);980 CFont font(m_Font); 1030 981 font.Bind(); 1031 982 1032 983 glPushMatrix(); … … 1036 987 1037 988 // First we'll figure out the clipping area, which is the cached actual size 1038 989 // substracted by an optional scrollbar 1039 if ( scrollbar)990 if (m_Scrollbar) 1040 991 { 1041 992 scroll = GetScrollBar(0).GetPos(); 1042 993 … … 1052 1003 1053 1004 if (cliparea != CRect()) 1054 1005 { 1055 double eq[4][4] = 1056 { 1006 double eq[4][4] = 1007 { 1057 1008 { 0.0, 1.0, 0.0, -cliparea.top }, 1058 1009 { 1.0, 0.0, 0.0, -cliparea.left }, 1059 1010 { 0.0, -1.0, 0.0, cliparea.bottom }, … … 1087 1038 1088 1039 // Set the Z to somewhat more, so we can draw a selected area between the 1089 1040 // the control and the text. 1090 glTranslatef((GLfloat)int(m_CachedActualSize.left) + buffer_zone,1091 (GLfloat)int(m_CachedActualSize.top+h) + buffer_zone, bz+0.1f);1092 1041 glTranslatef((GLfloat)int(m_CachedActualSize.left) + m_BufferZone, 1042 (GLfloat)int(m_CachedActualSize.top+h) + m_BufferZone, bz+0.1f); 1043 1093 1044 //glColor4f(1.f, 1.f, 1.f, 1.f); 1094 1045 1095 1046 // U+FE33: PRESENTATION FORM FOR VERTICAL LOW LINE 1096 1047 // (sort of like a | which is aligned to the left of most characters) 1097 1048 1098 float buffered_y = -scroll+ buffer_zone;1049 float buffered_y = -scroll+m_BufferZone; 1099 1050 1100 1051 // When selecting larger areas, we need to draw a rectangle box 1101 1052 // around it, and this is to keep track of where the box … … 1143 1094 it != m_CharacterPositions.end(); 1144 1095 ++it, buffered_y += ls, x_pointer = 0.f) 1145 1096 { 1146 if (m ultiline)1097 if (m_Multiline) 1147 1098 { 1148 1099 if (buffered_y > m_CachedActualSize.GetHeight()) 1149 1100 break; … … 1156 1107 if (it->m_ListStart + i == VirtualFrom) 1157 1108 { 1158 1109 // we won't actually draw it now, because we don't 1159 // know the width of each glyph to that position. 1110 // know the width of each glyph to that position. 1160 1111 // we need to go along with the iteration, and 1161 1112 // make a mark where the box started: 1162 1113 drawing_box = true; // will turn false when finally rendered. … … 1190 1141 1191 1142 CRect rect; 1192 1143 // Set 'rect' depending on if it's a multiline control, or a one-line control 1193 if (m ultiline)1144 if (m_Multiline) 1194 1145 { 1195 rect = CRect(m_CachedActualSize.left+box_x+ buffer_zone,1146 rect = CRect(m_CachedActualSize.left+box_x+m_BufferZone, 1196 1147 m_CachedActualSize.top+buffered_y+(h-ls)/2, 1197 m_CachedActualSize.left+x_pointer+ buffer_zone,1148 m_CachedActualSize.left+x_pointer+m_BufferZone, 1198 1149 m_CachedActualSize.top+buffered_y+(h+ls)/2); 1199 1150 1200 1151 if (rect.bottom < m_CachedActualSize.top) … … 1208 1159 } 1209 1160 else // if one-line 1210 1161 { 1211 rect = CRect(m_CachedActualSize.left+box_x+ buffer_zone-m_HorizontalScroll,1162 rect = CRect(m_CachedActualSize.left+box_x+m_BufferZone-m_HorizontalScroll, 1212 1163 m_CachedActualSize.top+buffered_y+(h-ls)/2, 1213 m_CachedActualSize.left+x_pointer+ buffer_zone-m_HorizontalScroll,1164 m_CachedActualSize.left+x_pointer+m_BufferZone-m_HorizontalScroll, 1214 1165 m_CachedActualSize.top+buffered_y+(h+ls)/2); 1215 1166 1216 1167 if (rect.left < m_CachedActualSize.left) … … 1225 1176 glEnable(GL_BLEND); 1226 1177 glDisable(GL_TEXTURE_2D); 1227 1178 1228 if ( sprite_selectarea)1229 GetGUI()->DrawSprite( *sprite_selectarea, cell_id, bz+0.05f, rect);1179 if (!m_SpriteSelectArea.IsEmpty()) 1180 GetGUI()->DrawSprite(m_SpriteSelectArea, m_CellId, bz+0.05f, rect); 1230 1181 1231 1182 // Blend can have been reset 1232 1183 glEnable(GL_BLEND); … … 1237 1188 } 1238 1189 1239 1190 if (i < (int)it->m_ListOfX.size()) 1240 x_pointer += (float)font.GetCharacterWidth( (*pCaption)[it->m_ListStart + i]);1191 x_pointer += (float)font.GetCharacterWidth(m_Caption[it->m_ListStart + i]); 1241 1192 } 1242 1193 1243 1194 if (done) … … 1255 1206 1256 1207 // Reset some from previous run 1257 1208 buffered_y = -scroll; 1258 1209 1259 1210 // Setup initial color (then it might change and change back, when drawing selected area) 1260 glColor4f( color.r, color.g, color.b, color.a);1211 glColor4f(m_TextColor.r, m_TextColor.g, m_TextColor.b, m_TextColor.a); 1261 1212 1262 1213 bool using_selected_color = false; 1263 1214 1264 1215 for (std::list<SRow>::const_iterator it = m_CharacterPositions.begin(); 1265 1216 it != m_CharacterPositions.end(); 1266 1217 ++it, buffered_y += ls) 1267 1218 { 1268 if (buffered_y + buffer_zone >= -ls || !multiline)1219 if (buffered_y + m_BufferZone >= -ls || !m_Multiline) 1269 1220 { 1270 if (m ultiline)1221 if (m_Multiline) 1271 1222 { 1272 if (buffered_y + buffer_zone > m_CachedActualSize.GetHeight())1223 if (buffered_y + m_BufferZone > m_CachedActualSize.GetHeight()) 1273 1224 break; 1274 1225 } 1275 1226 1276 1227 glPushMatrix(); 1277 1228 1278 1229 // Text must always be drawn in integer values. So we have to convert scroll 1279 if (m ultiline)1230 if (m_Multiline) 1280 1231 glTranslatef(0.f, -(float)(int)scroll, 0.f); 1281 1232 else 1282 1233 glTranslatef(-(float)(int)m_HorizontalScroll, 0.f, 0.f); … … 1285 1236 // (often compared against ints, so don't make it size_t) 1286 1237 for (int i=0; i < (int)it->m_ListOfX.size()+1; ++i) 1287 1238 { 1288 if (!m ultiline && i < (int)it->m_ListOfX.size())1239 if (!m_Multiline && i < (int)it->m_ListOfX.size()) 1289 1240 { 1290 if (it->m_ListOfX[i] - m_HorizontalScroll < - buffer_zone)1241 if (it->m_ListOfX[i] - m_HorizontalScroll < -m_BufferZone) 1291 1242 { 1292 1243 // We still need to translate the OpenGL matrix 1293 1244 if (i == 0) … … 1300 1251 } 1301 1252 1302 1253 // End of selected area, change back color 1303 if (SelectingText() && 1254 if (SelectingText() && 1304 1255 it->m_ListStart + i == VirtualTo) 1305 1256 { 1306 1257 using_selected_color = false; 1307 glColor4f( color.r, color.g, color.b, color.a);1258 glColor4f(m_TextColor.r, m_TextColor.g, m_TextColor.b, m_TextColor.a); 1308 1259 } 1309 1260 1310 1261 if (i != (int)it->m_ListOfX.size() && … … 1317 1268 } 1318 1269 1319 1270 // Drawing selected area 1320 if (SelectingText() && 1271 if (SelectingText() && 1321 1272 it->m_ListStart + i >= VirtualFrom && 1322 1273 it->m_ListStart + i < VirtualTo && 1323 1274 using_selected_color == false) 1324 1275 { 1325 1276 using_selected_color = true; 1326 glColor4f( color_selected.r, color_selected.g, color_selected.b, color_selected.a);1277 glColor4f(m_TextColorSelected.r, m_TextColorSelected.g, m_TextColorSelected.b, m_TextColorSelected.a); 1327 1278 } 1328 1279 1329 1280 if (i != (int)it->m_ListOfX.size()) 1330 glwprintf(L"%lc", (*pCaption)[it->m_ListStart + i]);1281 glwprintf(L"%lc", m_Caption[it->m_ListStart + i]); 1331 1282 1332 1283 // check it's now outside a one-liner, then we'll break 1333 if (!m ultiline && i < (int)it->m_ListOfX.size())1284 if (!m_Multiline && i < (int)it->m_ListOfX.size()) 1334 1285 { 1335 if (it->m_ListOfX[i] - m_HorizontalScroll > m_CachedActualSize.GetWidth()- buffer_zone)1286 if (it->m_ListOfX[i] - m_HorizontalScroll > m_CachedActualSize.GetWidth()-m_BufferZone) 1336 1287 break; 1337 1288 } 1338 1289 } 1339 1290 1340 1291 if (it->m_ListStart + (int)it->m_ListOfX.size() == m_iBufferPos) 1341 1292 { 1342 glColor4f( color.r, color.g, color.b, color.a);1293 glColor4f(m_TextColor.r, m_TextColor.g, m_TextColor.b, m_TextColor.a); 1343 1294 glwprintf(L"_"); 1344 1295 1345 1296 if (using_selected_color) 1346 1297 { 1347 glColor4f( color_selected.r, color_selected.g, color_selected.b, color_selected.a);1298 glColor4f(m_TextColorSelected.r, m_TextColorSelected.g, m_TextColorSelected.b, m_TextColorSelected.a); 1348 1299 } 1349 1300 } 1350 1301 1351 1302 glPopMatrix(); 1352 1303 } 1353 glTranslatef(0.f, ls, 0.f); 1304 glTranslatef(0.f, ls, 0.f); 1354 1305 } 1355 1306 1356 1307 glPopMatrix(); … … 1364 1315 1365 1316 void CInput::UpdateText(int from, int to_before, int to_after) 1366 1317 { 1367 CStrW caption;1368 CStrW font_name;1369 float buffer_zone;1370 bool multiline;1371 GUI<CStrW>::GetSetting(this, "font", font_name);1372 GUI<CStrW>::GetSetting(this, "caption", caption);1373 GUI<float>::GetSetting(this, "buffer_zone", buffer_zone);1374 GUI<bool>::GetSetting(this, "multiline", multiline);1375 1376 1318 // Ensure positions are valid after caption changes 1377 m_iBufferPos = std::min(m_iBufferPos, (int) caption.size());1378 m_iBufferPos_Tail = std::min(m_iBufferPos_Tail, (int) caption.size());1319 m_iBufferPos = std::min(m_iBufferPos, (int)m_Caption.size()); 1320 m_iBufferPos_Tail = std::min(m_iBufferPos_Tail, (int)m_Caption.size()); 1379 1321 1380 if ( font_name == CStrW())1322 if (m_Font == L"") // XXX can this be possible? I set to default 1381 1323 { 1382 1324 // Destroy everything stored, there's no font, so there can be 1383 1325 // no data. … … 1387 1329 1388 1330 SRow row; 1389 1331 row.m_ListStart = 0; 1390 1332 1391 1333 int to = 0; // make sure it's initialized 1392 1334 1393 1335 if (to_before == -1) 1394 to = (int) caption.length();1336 to = (int)m_Caption.length(); 1395 1337 1396 CFont font( font_name);1338 CFont font(m_Font); 1397 1339 1398 1340 std::list<SRow>::iterator current_line; 1399 1341 … … 1412 1354 ENSURE(to_before != -1); 1413 1355 1414 1356 std::list<SRow>::iterator destroy_row_from, destroy_row_to; 1415 // Used to check if the above has been set to anything, 1357 // Used to check if the above has been set to anything, 1416 1358 // previously a comparison like: 1417 1359 // destroy_row_from == std::list<SRow>::iterator() 1418 1360 // ... was used, but it didn't work with GCC. … … 1423 1365 // to be redone. And when going along, we'll delete a row at a time 1424 1366 // when continuing to see how much more after 'to' we need to remake. 1425 1367 int i=0; 1426 for (std::list<SRow>::iterator it=m_CharacterPositions.begin(); 1368 for (std::list<SRow>::iterator it=m_CharacterPositions.begin(); 1427 1369 it!=m_CharacterPositions.end(); ++it, ++i) 1428 1370 { 1429 1371 if (destroy_row_from_used == false && … … 1437 1379 1438 1380 // For the rare case that we might remove characters to a word 1439 1381 // so that it suddenly fits on the previous row, 1440 // we need to by standards re-do the whole previous line too 1382 // we need to by standards re-do the whole previous line too 1441 1383 // (if one exists) 1442 1384 if (destroy_row_from != m_CharacterPositions.begin()) 1443 1385 --destroy_row_from; … … 1451 1393 destroy_row_to_used = true; 1452 1394 1453 1395 // If it isn't the last row, we'll add another row to delete, 1454 // just so we can see if the last restorted line is 1396 // just so we can see if the last restorted line is 1455 1397 // identical to what it was before. If it isn't, then we'll 1456 1398 // have to continue. 1457 1399 // 'check_point_row_start' is where we store how the that … … 1494 1436 // set 'from' to the row we'll destroy from 1495 1437 // and 'to' to the row we'll destroy to 1496 1438 from = destroy_row_from->m_ListStart; 1497 1439 1498 1440 if (destroy_row_to != m_CharacterPositions.end()) 1499 1441 to = destroy_row_to->m_ListStart; // notice it will iterate [from, to), so it will never reach to. 1500 1442 else 1501 to = (int) caption.length();1443 to = (int)m_Caption.length(); 1502 1444 1503 1445 1504 1446 // Setup the first row … … 1513 1455 --temp_it; 1514 1456 1515 1457 m_CharacterPositions.erase(destroy_row_from, destroy_row_to); 1516 1458 1517 1459 // If there has been a change in number of characters 1518 1460 // we need to change all m_ListStart that comes after 1519 1461 // the interval we just destroyed. We'll change all … … 1532 1474 check_point_row_start += delta; 1533 1475 check_point_row_end += delta; 1534 1476 1535 if (to != (int) caption.length())1477 if (to != (int)m_Caption.length()) 1536 1478 to += delta; 1537 1479 } 1538 1480 } 1539 1481 1540 1482 int last_word_started=from; 1541 1483 //int last_list_start=-1; // unused 1542 1484 float x_pos = 0.f; … … 1546 1488 1547 1489 for (int i=from; i<to; ++i) 1548 1490 { 1549 if ( caption[i] == L'\n' && multiline)1491 if (m_Caption[i] == L'\n' && m_Multiline) 1550 1492 { 1551 if (i==to-1 && to != (int) caption.length())1493 if (i==to-1 && to != (int)m_Caption.length()) 1552 1494 break; // it will be added outside 1553 1495 1554 1496 current_line = m_CharacterPositions.insert( current_line, row ); 1555 1497 ++current_line; 1556 1498 … … 1563 1505 } 1564 1506 else 1565 1507 { 1566 if ( caption[i] == L' '/* || TODO Gee (2004-10-13): the '-' disappears, fix.1508 if (m_Caption[i] == L' '/* || TODO Gee (2004-10-13): the '-' disappears, fix. 1567 1509 caption[i] == L'-'*/) 1568 1510 last_word_started = i+1; 1569 1511 1570 x_pos += (float)font.GetCharacterWidth( caption[i]);1512 x_pos += (float)font.GetCharacterWidth(m_Caption[i]); 1571 1513 1572 if (x_pos >= GetTextAreaWidth() && m ultiline)1514 if (x_pos >= GetTextAreaWidth() && m_Multiline) 1573 1515 { 1574 1516 // The following decides whether it will word-wrap a word, 1575 1517 // or if it's only one word on the line, where it has to … … 1586 1528 // regular word-wrap 1587 1529 row.m_ListOfX.resize(row.m_ListOfX.size() - (i-last_word_started+1)); 1588 1530 } 1589 1531 1590 1532 // Now, create a new line: 1591 1533 // notice: when we enter a newline, you can stand with the cursor 1592 1534 // both before and after that character, being on different … … 1614 1556 // also check if the current line isn't the end 1615 1557 if (to_before != -1 && i == to-1 && current_line != m_CharacterPositions.end()) 1616 1558 { 1617 // check all rows and see if any existing 1559 // check all rows and see if any existing 1618 1560 if (row.m_ListStart != check_point_row_start) 1619 1561 { 1620 1562 std::list<SRow>::iterator destroy_row_from, destroy_row_to; 1621 // Are used to check if the above has been set to anything, 1563 // Are used to check if the above has been set to anything, 1622 1564 // previously a comparison like: 1623 1565 // destroy_row_from == std::list<SRow>::iterator() 1624 1566 // was used, but it didn't work with GCC. … … 1629 1571 // to be redone. And when going along, we'll delete a row at a time 1630 1572 // when continuing to see how much more after 'to' we need to remake. 1631 1573 int i=0; 1632 for (std::list<SRow>::iterator it=m_CharacterPositions.begin(); 1574 for (std::list<SRow>::iterator it=m_CharacterPositions.begin(); 1633 1575 it!=m_CharacterPositions.end(); ++it, ++i) 1634 1576 { 1635 1577 if (destroy_row_from_used == false && … … 1652 1594 destroy_row_to_used = true; 1653 1595 1654 1596 // If it isn't the last row, we'll add another row to delete, 1655 // just so we can see if the last restorted line is 1597 // just so we can see if the last restorted line is 1656 1598 // identical to what it was before. If it isn't, then we'll 1657 1599 // have to continue. 1658 1600 // 'check_point_row_start' is where we store how the that 1659 1601 // line looked. 1660 // if (destroy_row_to != 1602 // if (destroy_row_to != 1661 1603 if (destroy_row_to != m_CharacterPositions.end()) 1662 1604 { 1663 1605 check_point_row_start = destroy_row_to->m_ListStart; … … 1694 1636 // set 'from' to the from row we'll destroy 1695 1637 // and 'to' to 'to_after' 1696 1638 from = destroy_row_from->m_ListStart; 1697 1639 1698 1640 if (destroy_row_to != m_CharacterPositions.end()) 1699 1641 to = destroy_row_to->m_ListStart; // notice it will iterate [from, to[, so it will never reach to. 1700 1642 else 1701 to = (int) caption.length();1643 to = (int)m_Caption.length(); 1702 1644 1703 1645 1704 1646 // Set current line, new rows will be added before current_line, so … … 1728 1670 // add the final row (even if empty) 1729 1671 m_CharacterPositions.insert(current_line, row); 1730 1672 1731 bool scrollbar;1732 GUI<bool>::GetSetting(this, "scrollbar", scrollbar);1733 1673 // Update scollbar 1734 if ( scrollbar)1674 if (m_Scrollbar) 1735 1675 { 1736 GetScrollBar(0).SetScrollRange(m_CharacterPositions.size() * font.GetLineSpacing() + buffer_zone*2.f);1676 GetScrollBar(0).SetScrollRange(m_CharacterPositions.size() * font.GetLineSpacing() + m_BufferZone*2.f); 1737 1677 GetScrollBar(0).SetScrollSpace(m_CachedActualSize.GetHeight()); 1738 1678 } 1739 1679 } … … 1746 1686 // Return position 1747 1687 int retPosition; 1748 1688 1749 float buffer_zone;1750 bool multiline;1751 GUI<float>::GetSetting(this, "buffer_zone", buffer_zone);1752 GUI<bool>::GetSetting(this, "multiline", multiline);1753 1754 1689 std::list<SRow>::iterator current = m_CharacterPositions.begin(); 1755 1690 1756 1691 CPos mouse = GetMousePos(); 1757 1692 1758 if (m ultiline)1693 if (m_Multiline) 1759 1694 { 1760 CStrW font_name;1761 bool scrollbar;1762 GUI<CStrW>::GetSetting(this, "font", font_name);1763 GUI<bool>::GetSetting(this, "scrollbar", scrollbar);1764 1765 1695 float scroll=0.f; 1766 if ( scrollbar)1696 if (m_Scrollbar) 1767 1697 { 1768 1698 scroll = GetScrollBar(0).GetPos(); 1769 1699 } 1770 1700 1771 // Pointer to caption, will come in handy1772 CStrW *pCaption = (CStrW*)m_Settings["caption"].m_pSetting;1773 UNUSED2(pCaption);1774 1775 1701 // Now get the height of the font. 1776 1702 // TODO: Get the real font 1777 CFont font( font_name);1703 CFont font(m_Font); 1778 1704 float spacing = (float)font.GetLineSpacing(); 1779 1705 //float height = (float)font.GetHeight(); // unused 1780 1706 1781 1707 // Change mouse position relative to text. 1782 1708 mouse -= m_CachedActualSize.TopLeft(); 1783 mouse.x -= buffer_zone;1784 mouse.y += scroll - buffer_zone;1709 mouse.x -= m_BufferZone; 1710 mouse.y += scroll - m_BufferZone; 1785 1711 1786 1712 //if ((m_CharacterPositions.size()-1) * spacing + height < mouse.y) 1787 // m_iBufferPos = pCaption->Length();1713 // m_iBufferPos = m_Caption.Length(); 1788 1714 int row = (int)((mouse.y) / spacing);//m_CharachterPositions.size() 1789 1715 1790 1716 if (row < 0) … … 1804 1730 // current is already set to begin, 1805 1731 // but we'll change the mouse.x to fit our horizontal scrolling 1806 1732 mouse -= m_CachedActualSize.TopLeft(); 1807 mouse.x -= buffer_zone - m_HorizontalScroll;1733 mouse.x -= m_BufferZone - m_HorizontalScroll; 1808 1734 // mouse.y is moot 1809 1735 } 1810 1736 1811 1737 //m_iBufferPos = m_CharacterPositions.get.m_ListStart; 1812 1738 retPosition = current->m_ListStart; 1813 1739 1814 1740 // Okay, now loop through the glyphs to find the appropriate X position 1815 1741 float dummy; 1816 1742 retPosition += GetXTextPosition(current, mouse.x, dummy); … … 1854 1780 1855 1781 void CInput::DeleteCurSelection() 1856 1782 { 1857 CStrW *pCaption = (CStrW*)m_Settings["caption"].m_pSetting;1858 1859 1783 int virtualFrom; 1860 1784 int virtualTo; 1861 1785 … … 1870 1794 virtualTo = m_iBufferPos; 1871 1795 } 1872 1796 1873 *pCaption = pCaption->Left( virtualFrom ) +1874 pCaption->Right( (long) pCaption->length() - (virtualTo) );1797 m_Caption = m_Caption.Left( virtualFrom ) + 1798 m_Caption.Right( (long) m_Caption.length() - (virtualTo) ); 1875 1799 1876 1800 UpdateText(virtualFrom, virtualTo, virtualFrom); 1877 1801 … … 1888 1812 1889 1813 float CInput::GetTextAreaWidth() 1890 1814 { 1891 bool scrollbar; 1892 float buffer_zone; 1893 GUI<bool>::GetSetting(this, "scrollbar", scrollbar); 1894 GUI<float>::GetSetting(this, "buffer_zone", buffer_zone); 1895 1896 if (scrollbar && GetScrollBar(0).GetStyle()) 1897 return m_CachedActualSize.GetWidth() - buffer_zone*2.f - GetScrollBar(0).GetStyle()->m_Width; 1815 if (m_Scrollbar && GetScrollBar(0).GetStyle()) 1816 return m_CachedActualSize.GetWidth() - m_BufferZone*2.f - GetScrollBar(0).GetStyle()->m_Width; 1898 1817 else 1899 return m_CachedActualSize.GetWidth() - buffer_zone*2.f;1818 return m_CachedActualSize.GetWidth() - m_BufferZone*2.f; 1900 1819 } 1901 1820 1902 1821 void CInput::UpdateAutoScroll() 1903 1822 { 1904 float buffer_zone;1905 bool multiline;1906 GUI<float>::GetSetting(this, "buffer_zone", buffer_zone);1907 GUI<bool>::GetSetting(this, "multiline", multiline);1908 1909 1823 // Autoscrolling up and down 1910 if (m ultiline)1824 if (m_Multiline) 1911 1825 { 1912 CStrW font_name;1913 bool scrollbar;1914 GUI<CStrW>::GetSetting(this, "font", font_name);1915 GUI<bool>::GetSetting(this, "scrollbar", scrollbar);1916 1917 1826 float scroll=0.f; 1918 if (! scrollbar)1827 if (!m_Scrollbar) 1919 1828 return; 1920 1829 1921 1830 scroll = GetScrollBar(0).GetPos(); 1922 1831 1923 1832 // Now get the height of the font. 1924 1833 // TODO: Get the real font 1925 CFont font( font_name);1834 CFont font(m_Font); 1926 1835 float spacing = (float)font.GetLineSpacing(); 1927 1836 //float height = font.GetHeight(); 1928 1837 … … 1936 1845 if (m_iBufferPos >= current->m_ListStart && 1937 1846 m_iBufferPos <= current->m_ListStart+(int)current->m_ListOfX.size()) 1938 1847 break; 1939 1848 1940 1849 ++current; 1941 1850 ++row; 1942 1851 } 1943 1852 1944 1853 // If scrolling down 1945 if (-scroll + (float)(row+1) * spacing + buffer_zone*2.f > m_CachedActualSize.GetHeight())1854 if (-scroll + (float)(row+1) * spacing + m_BufferZone*2.f > m_CachedActualSize.GetHeight()) 1946 1855 { 1947 1856 // Scroll so the selected row is shown completely, also with buffer_zone length to the edge. 1948 GetScrollBar(0).SetPos((float)(row+1) * spacing - m_CachedActualSize.GetHeight() + buffer_zone*2.f);1857 GetScrollBar(0).SetPos((float)(row+1) * spacing - m_CachedActualSize.GetHeight() + m_BufferZone*2.f); 1949 1858 } 1950 1859 else 1951 1860 // If scrolling up … … 1976 1885 } 1977 1886 1978 1887 // Check if outside to the right 1979 if (x_position - m_HorizontalScroll + buffer_zone*2.f > m_CachedActualSize.GetWidth())1980 m_HorizontalScroll = x_position - m_CachedActualSize.GetWidth() + buffer_zone*2.f;1888 if (x_position - m_HorizontalScroll + m_BufferZone*2.f > m_CachedActualSize.GetWidth()) 1889 m_HorizontalScroll = x_position - m_CachedActualSize.GetWidth() + m_BufferZone*2.f; 1981 1890 1982 1891 // Check if outside to the left 1983 1892 if (x_position - m_HorizontalScroll < 0.f) … … 1985 1894 1986 1895 // Check if the text doesn't even fill up to the right edge even though scrolling is done. 1987 1896 if (m_HorizontalScroll != 0.f && 1988 x_total - m_HorizontalScroll + buffer_zone*2.f < m_CachedActualSize.GetWidth())1989 m_HorizontalScroll = x_total - m_CachedActualSize.GetWidth() + buffer_zone*2.f;1897 x_total - m_HorizontalScroll + m_BufferZone*2.f < m_CachedActualSize.GetWidth()) 1898 m_HorizontalScroll = x_total - m_CachedActualSize.GetWidth() + m_BufferZone*2.f; 1990 1899 1991 1900 // Now this is the fail-safe, if x_total isn't even the length of the control, 1992 1901 // remove all scrolling 1993 if (x_total + buffer_zone*2.f < m_CachedActualSize.GetWidth())1902 if (x_total + m_BufferZone*2.f < m_CachedActualSize.GetWidth()) 1994 1903 m_HorizontalScroll = 0.f; 1995 1904 } 1996 1905 } -
source/gui/CDropDown.h
99 99 * made that can change the visual. 100 100 */ 101 101 void SetupText(); 102 102 103 103 // Sets up the cached GetListRect. Decided whether it should 104 104 // have a scrollbar, and so on. 105 105 virtual void SetupListRect(); … … 127 127 // it is set to "selected", but then when moving the mouse it will 128 128 // change. 129 129 int m_ElementHighlight; 130 private: 131 float m_ButtonWidth; 132 float m_DropdownSize; 133 float m_DropdownBuffer; 134 CGUISpriteInstance m_SpriteList; 135 CGUISpriteInstance m_Sprite2; 136 CGUISpriteInstance m_SpriteOver2; 137 CGUISpriteInstance m_SpritePressed2; 138 CGUISpriteInstance m_SpriteDisabled2; 139 130 140 }; 131 141 132 142 #endif -
source/gui/IGUIButtonBehavior.cpp
28 28 //------------------------------------------------------------------- 29 29 IGUIButtonBehavior::IGUIButtonBehavior() : m_Pressed(false) 30 30 { 31 AddSetting(GUIST_CColor, "textcolor", &m_ButtonTextColor); 32 AddSetting(GUIST_CColor, "textcolor_over", &m_ButtonTextColorOver); 33 AddSetting(GUIST_CColor, "textcolor_pressed", &m_ButtonTextColorPressed); 34 AddSetting(GUIST_CColor, "textcolor_disabled", &m_ButtonTextColorDisabled); 31 35 } 32 36 33 37 IGUIButtonBehavior::~IGUIButtonBehavior() … … 41 45 { 42 46 case GUIM_MOUSE_PRESS_LEFT: 43 47 { 44 bool enabled; 45 GUI<bool>::GetSetting(this, "enabled", enabled); 46 47 if (!enabled) 48 break; 48 if ( IsEnabled() ) 49 { 50 m_Pressed = true; 51 } 49 52 50 m_Pressed = true;51 } break;53 break; 54 } 52 55 53 56 case GUIM_MOUSE_DBLCLICK_LEFT: 54 57 case GUIM_MOUSE_RELEASE_LEFT: 55 58 { 56 bool enabled; 57 GUI<bool>::GetSetting(this, "enabled", enabled); 58 59 if (!enabled) 60 break; 61 62 if (m_Pressed) 59 if ( IsEnabled() && m_Pressed ) 63 60 { 64 61 m_Pressed = false; 65 62 if (Message.type == GUIM_MOUSE_RELEASE_LEFT) … … 77 74 SendEvent(GUIM_DOUBLE_PRESSED, "doublepress"); 78 75 } 79 76 } 80 } break; 77 break; 78 } 81 79 82 80 default: 83 81 break; … … 86 84 87 85 CColor IGUIButtonBehavior::ChooseColor() 88 86 { 89 CColor color, color2; 90 91 // Yes, the object must possess these settings. They are standard 92 GUI<CColor>::GetSetting(this, "textcolor", color); 93 94 bool enabled; 95 GUI<bool>::GetSetting(this, "enabled", enabled); 96 97 if (!enabled) 87 if (!IsEnabled()) 98 88 { 99 GUI<CColor>::GetSetting(this, "textcolor_disabled", color2); 100 return GUI<>::FallBackColor(color2, color); 89 return GUI<>::FallBackColor(m_ButtonTextColorDisabled, m_ButtonTextColor); 101 90 } 102 else 103 if (m_MouseHovering) 91 else if (m_MouseHovering) 104 92 { 105 93 if (m_Pressed) 106 94 { 107 GUI<CColor>::GetSetting(this, "textcolor_pressed", color2); 108 return GUI<>::FallBackColor(color2, color); 95 return GUI<>::FallBackColor(m_ButtonTextColorPressed, m_ButtonTextColor); 109 96 } 110 97 else 111 98 { 112 GUI<CColor>::GetSetting(this, "textcolor_over", color2); 113 return GUI<>::FallBackColor(color2, color); 99 return GUI<>::FallBackColor(m_ButtonTextColorOver, m_ButtonTextColor); 114 100 } 115 101 } 116 else return color; 102 103 return m_ButtonTextColor; 117 104 } 118 105 119 106 void IGUIButtonBehavior::DrawButton(const CRect &rect, … … 126 113 { 127 114 if (GetGUI()) 128 115 { 129 bool enabled; 130 GUI<bool>::GetSetting(this, "enabled", enabled); 131 132 if (!enabled) 116 if (!IsEnabled()) 133 117 { 134 118 GetGUI()->DrawSprite(GUI<>::FallBackSprite(sprite_disabled, sprite), cell_id, z, rect); 135 119 } -
source/gui/CButton.cpp
31 31 //------------------------------------------------------------------- 32 32 CButton::CButton() 33 33 { 34 AddSetting(GUIST_float, "buffer_zone"); 35 AddSetting(GUIST_CGUIString, "caption"); 36 AddSetting(GUIST_int, "cell_id"); 37 AddSetting(GUIST_CStrW, "font"); 38 AddSetting(GUIST_CGUISpriteInstance, "sprite"); 39 AddSetting(GUIST_CGUISpriteInstance, "sprite_over"); 40 AddSetting(GUIST_CGUISpriteInstance, "sprite_pressed"); 41 AddSetting(GUIST_CGUISpriteInstance, "sprite_disabled"); 42 AddSetting(GUIST_EAlign, "text_align"); 43 AddSetting(GUIST_EVAlign, "text_valign"); 44 AddSetting(GUIST_CColor, "textcolor"); 45 AddSetting(GUIST_CColor, "textcolor_over"); 46 AddSetting(GUIST_CColor, "textcolor_pressed"); 47 AddSetting(GUIST_CColor, "textcolor_disabled"); 48 AddSetting(GUIST_CStrW, "tooltip"); 49 AddSetting(GUIST_CStr, "tooltip_style"); 34 AddSetting(GUIST_float, "buffer_zone", &m_BufferZone); 35 AddSetting(GUIST_CGUIString, "caption", &m_Caption); 36 AddSetting(GUIST_int, "cell_id", &m_CellId); 37 AddSetting(GUIST_CStrW, "font", &m_Font); 38 AddSetting(GUIST_CGUISpriteInstance, "sprite", &m_Sprite); 39 AddSetting(GUIST_CGUISpriteInstance, "sprite_over", &m_SpriteOver); 40 AddSetting(GUIST_CGUISpriteInstance, "sprite_pressed", &m_SpritePressed); 41 AddSetting(GUIST_CGUISpriteInstance, "sprite_disabled", &m_SpriteDisabled); 50 42 43 AddSetting(GUIST_CStrW, "tooltip", &m_Tooltip); 44 AddSetting(GUIST_CStr, "tooltip_style", &m_TooltipStyle); 45 46 m_BufferZone = 0.f; 47 m_Font = L"default"; 48 51 49 // Add text 52 50 AddText(new SGUIText()); 53 51 } … … 63 61 64 62 ENSURE(m_GeneratedTexts.size()==1); 65 63 66 CStrW font; 67 if (GUI<CStrW>::GetSetting(this, "font", font) != PSRETURN_OK || font.empty()) 68 // Use the default if none is specified 69 // TODO Gee: (2004-08-14) Default should not be hard-coded, but be in styles! 70 font = L"default"; 64 *m_GeneratedTexts[0] = GetGUI()->GenerateText(m_Caption, m_Font, m_CachedActualSize.GetWidth(), m_BufferZone, this); 71 65 72 CGUIString caption;73 GUI<CGUIString>::GetSetting(this, "caption", caption);74 75 float buffer_zone=0.f;76 GUI<float>::GetSetting(this, "buffer_zone", buffer_zone);77 *m_GeneratedTexts[0] = GetGUI()->GenerateText(caption, font, m_CachedActualSize.GetWidth(), buffer_zone, this);78 79 66 CalculateTextPosition(m_CachedActualSize, m_TextPos, *m_GeneratedTexts[0]); 80 67 } 81 68 … … 86 73 IGUITextOwner::HandleMessage(Message); 87 74 } 88 75 89 void CButton::Draw() 76 void CButton::Draw() 90 77 { 91 78 float bz = GetBufferedZ(); 92 79 93 CGUISpriteInstance *sprite, *sprite_over, *sprite_pressed, *sprite_disabled;94 int cell_id;95 96 // Statically initialise some strings, so we don't have to do97 // lots of allocation every time this function is called98 static CStr strSprite("sprite");99 static CStr strSpriteOver("sprite_over");100 static CStr strSpritePressed("sprite_pressed");101 static CStr strSpriteDisabled("sprite_disabled");102 static CStr strCellId("cell_id");103 104 GUI<CGUISpriteInstance>::GetSettingPointer(this, strSprite, sprite);105 GUI<CGUISpriteInstance>::GetSettingPointer(this, strSpriteOver, sprite_over);106 GUI<CGUISpriteInstance>::GetSettingPointer(this, strSpritePressed, sprite_pressed);107 GUI<CGUISpriteInstance>::GetSettingPointer(this, strSpriteDisabled, sprite_disabled);108 GUI<int>::GetSetting(this, strCellId, cell_id);109 110 80 DrawButton(m_CachedActualSize, 111 81 bz, 112 *sprite,113 *sprite_over,114 *sprite_pressed,115 *sprite_disabled,116 cell_id);82 m_Sprite, 83 m_SpriteOver, 84 m_SpritePressed, 85 m_SpriteDisabled, 86 m_CellId); 117 87 118 CColor color = ChooseColor(); 119 IGUITextOwner::Draw(0, color, m_TextPos, bz+0.1f); 88 IGUITextOwner::Draw(0, ChooseColor(), m_TextPos, bz+0.1f); 120 89 } -
source/gui/IGUITextOwner.h
88 88 * @param clipping Clipping rectangle, don't even add a parameter 89 89 * to get no clipping. 90 90 */ 91 virtual void Draw(const int &index, const CColor &color, const CPos &pos, 91 virtual void Draw(const int &index, const CColor &color, const CPos &pos, 92 92 const float &z, const CRect &clipping = CRect()); 93 93 94 94 /** … … 117 117 * Calculate the position for the text, based on the alignment. 118 118 */ 119 119 void CalculateTextPosition(CRect &ObjSize, CPos &TextPos, SGUIText &Text); 120 private: 121 EAlign m_TextAlign; 122 EVAlign m_TextVAlign; 123 120 124 }; 121 125 122 126 #endif -
source/gui/CList.h
121 121 122 122 // Extended drawing interface, this is so that classes built on the this one 123 123 // can use other sprite names. 124 void DrawList(const int &selected, const CStr& _sprite, 125 const CStr& _sprite_selected, const CStr& _textcolor); 124 void DrawList(const int &selected, const CGUISpriteInstance& _sprite); 126 125 127 126 // Get the area of the list. This is so that i can easily be changed, like in CDropDown 128 127 // where the area is not equal to m_CachedActualSize. … … 138 137 * be zero, but still stored for easy handling. 139 138 */ 140 139 std::vector<float> m_ItemsYPositions; 140 141 void SetSelected(const int index, const bool SkipMessage = false); 142 143 public: 144 bool IsScrollbar() const { return m_Scrollbar; } 145 void SetScrollbar(const bool scrollbar, const bool SkipMessage = false); 146 const CGUIList& GetList() const { return m_List; } 147 148 int GetSelectedIndex() const { return m_Selected; } 149 150 int GetCellId() const { return m_CellId; } 151 152 const CColor& GetTextColor() const { return m_TextColor; } 153 154 const CGUISpriteInstance& GetSprite() const { return m_Sprite; } 155 156 private: 157 float m_BufferZone; 158 // CGUIString m_Caption; // disabled for some unknown reason 159 int m_CellId; 160 CStrW m_Font; 161 bool m_Scrollbar; 162 CStr m_ScrollbarStyle; 163 CGUISpriteInstance m_Sprite; 164 CGUISpriteInstance m_SpriteSelectArea; 165 EAlign m_TextAlign; 166 CColor m_TextColor; 167 CColor m_TextSelected; 168 int m_Selected; 169 CStrW m_Tooltip; 170 CStr m_TooltipStyle; 171 172 CGUIList m_List; 173 CGUIList m_ListData; 174 141 175 }; 142 176 143 177 #endif -
source/gui/GUIutil.h
343 343 { 344 344 // Statically initialise some strings, so we don't have to do 345 345 // lots of allocation every time this function is called 346 static CStr strHidden("hidden");347 static CStr strEnabled("enabled");348 static CStr strGhost("ghost");346 // static CStr strHidden("hidden"); 347 // static CStr strEnabled("enabled"); 348 // static CStr strGhost("ghost"); 349 349 350 350 if (RR & GUIRR_HIDDEN) 351 351 { 352 bool hidden = true;353 GUI<bool>::GetSetting(pObject, strHidden, hidden);352 // bool hidden = true; 353 // GUI<bool>::GetSetting(pObject, strHidden, hidden); 354 354 355 if ( hidden)355 if ( pObject->IsHidden() ) 356 356 return true; 357 357 } 358 358 if (RR & GUIRR_DISABLED) 359 359 { 360 bool enabled = false;361 GUI<bool>::GetSetting(pObject, strEnabled, enabled);360 // bool enabled = false; 361 // GUI<bool>::GetSetting(pObject, strEnabled, enabled); 362 362 363 if (! enabled)363 if (! pObject->IsEnabled() ) 364 364 return true; 365 365 } 366 366 if (RR & GUIRR_GHOST) 367 367 { 368 bool ghost = true;369 GUI<bool>::GetSetting(pObject, strGhost, ghost);368 // bool ghost = true; 369 // GUI<bool>::GetSetting(pObject, strGhost, ghost); 370 370 371 if ( ghost)371 if ( pObject->IsGhost() ) 372 372 return true; 373 373 } 374 374 -
source/gui/CGUI.cpp
1365 1365 if (!ManuallySetZ) 1366 1366 { 1367 1367 // Set it automatically to 10 plus its parents 1368 bool absolute;1369 GUI<bool>::GetSetting(object, "absolute", absolute);1368 // bool absolute; 1369 // GUI<bool>::GetSetting(object, "absolute", absolute); 1370 1370 1371 1371 // If the object is absolute, we'll have to get the parent's Z buffered, 1372 1372 // and add to that! 1373 if ( absolute)1373 if ( object->IsAbsolute() ) 1374 1374 { 1375 GUI<float>::SetSetting(object, "z", pParent->GetBufferedZ() + 10.f, true); 1375 // GUI<float>::SetSetting(object, "z", pParent->GetBufferedZ() + 10.f, true); 1376 object->SetZ(pParent->GetBufferedZ() + 10.f, true); 1376 1377 } 1377 1378 else 1378 1379 // If the object is relative, then we'll just store Z as "10" 1379 1380 { 1380 GUI<float>::SetSetting(object, "z", 10.f, true); 1381 // GUI<float>::SetSetting(object, "z", 10.f, true); 1382 object->SetZ(10.f, true); 1381 1383 } 1382 1384 } 1383 1385 -
source/gui/CText.cpp
32 32 //------------------------------------------------------------------- 33 33 CText::CText() 34 34 { 35 AddSetting(GUIST_float, "buffer_zone"); 36 AddSetting(GUIST_CGUIString, "caption"); 37 AddSetting(GUIST_int, "cell_id"); 38 AddSetting(GUIST_bool, "clip"); 39 AddSetting(GUIST_CStrW, "font"); 40 AddSetting(GUIST_bool, "scrollbar"); 41 AddSetting(GUIST_CStr, "scrollbar_style"); 42 AddSetting(GUIST_bool, "scroll_bottom"); 43 AddSetting(GUIST_CGUISpriteInstance, "sprite"); 44 AddSetting(GUIST_EAlign, "text_align"); 45 AddSetting(GUIST_EVAlign, "text_valign"); 46 AddSetting(GUIST_CColor, "textcolor"); 47 AddSetting(GUIST_CStrW, "tooltip"); 48 AddSetting(GUIST_CStr, "tooltip_style"); 35 AddSetting(GUIST_float, "buffer_zone", &m_BufferZone); 36 AddSetting(GUIST_CGUIString, "caption", &m_Caption); 37 AddSetting(GUIST_int, "cell_id", &m_CellId); 38 AddSetting(GUIST_bool, "clip", &m_Clip); 39 AddSetting(GUIST_CStrW, "font", &m_Font); 40 AddSetting(GUIST_bool, "scrollbar", &m_Scrollbar); 41 AddSetting(GUIST_CStr, "scrollbar_style", &m_ScrollbarStyle); 42 AddSetting(GUIST_bool, "scroll_bottom", &m_ScrollBottom); 43 AddSetting(GUIST_CGUISpriteInstance, "sprite", &m_Sprite); 44 AddSetting(GUIST_CColor, "textcolor", &m_TextColor); 45 AddSetting(GUIST_CStrW, "tooltip", &m_Tooltip); 46 AddSetting(GUIST_CStr, "tooltip_style", &m_TooltipStyle); 49 47 50 48 // Private settings 51 AddSetting(GUIST_CStrW, "_icon_tooltip" );52 AddSetting(GUIST_CStr, "_icon_tooltip_style" );49 AddSetting(GUIST_CStrW, "_icon_tooltip", &m_IconTooltip); 50 AddSetting(GUIST_CStr, "_icon_tooltip_style", &m_IconTooltipStyle); 53 51 52 m_BufferZone = 0.f; 53 m_Font = L"default"; 54 m_ScrollBottom = false; 55 54 56 //GUI<bool>::SetSetting(this, "ghost", true); 55 57 GUI<bool>::SetSetting(this, "scrollbar", false); 56 58 GUI<bool>::SetSetting(this, "clip", true); … … 76 78 77 79 ENSURE(m_GeneratedTexts.size()>=1); 78 80 79 CStrW font;80 if (GUI<CStrW>::GetSetting(this, "font", font) != PSRETURN_OK || font.empty())81 // Use the default if none is specified82 // TODO Gee: (2004-08-14) Don't define standard like this. Do it with the default style.83 font = L"default";84 85 CGUIString caption;86 bool scrollbar;87 GUI<CGUIString>::GetSetting(this, "caption", caption);88 GUI<bool>::GetSetting(this, "scrollbar", scrollbar);89 90 81 float width = m_CachedActualSize.GetWidth(); 91 82 // remove scrollbar if applicable 92 if ( scrollbar && GetScrollBar(0).GetStyle())83 if (m_Scrollbar && GetScrollBar(0).GetStyle()) 93 84 width -= GetScrollBar(0).GetStyle()->m_Width; 94 85 95 86 96 float buffer_zone=0.f; 97 GUI<float>::GetSetting(this, "buffer_zone", buffer_zone); 98 *m_GeneratedTexts[0] = GetGUI()->GenerateText(caption, font, width, buffer_zone, this); 87 *m_GeneratedTexts[0] = GetGUI()->GenerateText(m_Caption, m_Font, width, m_BufferZone, this); 99 88 100 if (! scrollbar)89 if (! m_Scrollbar) 101 90 CalculateTextPosition(m_CachedActualSize, m_TextPos, *m_GeneratedTexts[0]); 102 91 103 92 // Setup scrollbar 104 if ( scrollbar)93 if (m_Scrollbar) 105 94 { 106 bool scrollbottom = false;107 GUI<bool>::GetSetting(this, "scroll_bottom", scrollbottom);108 109 95 // If we are currently scrolled to the bottom of the text, 110 96 // then add more lines of text, update the scrollbar so we 111 97 // stick to the bottom. 112 98 // (Use 1.5px delta so this triggers the first time caption is set) 113 99 bool bottom = false; 114 if ( scrollbottom && GetScrollBar(0).GetPos() > GetScrollBar(0).GetMaxPos() - 1.5f)100 if (m_ScrollBottom && GetScrollBar(0).GetPos() > GetScrollBar(0).GetMaxPos() - 1.5f) 115 101 bottom = true; 116 102 117 103 GetScrollBar(0).SetScrollRange(m_GeneratedTexts[0]->m_Size.cy); … … 143 129 // Update scrollbar 144 130 if (Message.value == "scrollbar_style") 145 131 { 146 CStr scrollbar_style; 147 GUI<CStr>::GetSetting(this, Message.value, scrollbar_style); 132 GetScrollBar(0).SetScrollBarStyle( m_ScrollbarStyle ); 148 133 149 GetScrollBar(0).SetScrollBarStyle( scrollbar_style );150 151 134 SetupText(); 152 135 } 153 136 … … 178 161 GetScrollBar(0).SetZ( GetBufferedZ() ); 179 162 GetScrollBar(0).SetLength( m_CachedActualSize.bottom - m_CachedActualSize.top ); 180 163 181 CStr scrollbar_style; 182 GUI<CStr>::GetSetting(this, "scrollbar_style", scrollbar_style); 183 GetScrollBar(0).SetScrollBarStyle( scrollbar_style ); 164 GetScrollBar(0).SetScrollBarStyle( m_ScrollbarStyle ); 184 165 } 185 166 break; 186 167 … … 191 172 IGUITextOwner::HandleMessage(Message); 192 173 } 193 174 194 void CText::Draw() 175 void CText::Draw() 195 176 { 196 float bz = GetBufferedZ();197 198 177 // First call draw on ScrollBarOwner 199 bool scrollbar; 200 GUI<bool>::GetSetting(this, "scrollbar", scrollbar); 201 202 if (scrollbar) 178 if (m_Scrollbar) 203 179 { 204 180 // Draw scrollbar 205 181 IGUIScrollBarOwner::Draw(); … … 207 183 208 184 if (GetGUI()) 209 185 { 210 CGUISpriteInstance *sprite; 211 int cell_id; 212 bool clip; 213 GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite", sprite); 214 GUI<int>::GetSetting(this, "cell_id", cell_id); 215 GUI<bool>::GetSetting(this, "clip", clip); 186 float bz = GetBufferedZ(); 216 187 217 GetGUI()->DrawSprite( *sprite, cell_id, bz, m_CachedActualSize);188 GetGUI()->DrawSprite(m_Sprite, m_CellId, bz, m_CachedActualSize); 218 189 219 190 float scroll=0.f; 220 if ( scrollbar)191 if (m_Scrollbar) 221 192 { 222 193 scroll = GetScrollBar(0).GetPos(); 223 194 } 224 195 225 196 // Clipping area (we'll have to subtract the scrollbar) 226 197 CRect cliparea; 227 if ( clip)198 if (m_Clip) 228 199 { 229 200 cliparea = m_CachedActualSize; 230 201 231 if ( scrollbar)202 if (m_Scrollbar) 232 203 { 233 204 // subtract scrollbar from cliparea 234 205 if (cliparea.right > GetScrollBar(0).GetOuterRect().left && … … 241 212 } 242 213 } 243 214 244 CColor color;245 GUI<CColor>::GetSetting(this, "textcolor", color);246 247 215 // Draw text 248 if ( scrollbar)249 IGUITextOwner::Draw(0, color, m_CachedActualSize.TopLeft() - CPos(0.f, scroll), bz+0.1f, cliparea);216 if (m_Scrollbar) 217 IGUITextOwner::Draw(0, m_TextColor, m_CachedActualSize.TopLeft() - CPos(0.f, scroll), bz+0.1f, cliparea); 250 218 else 251 IGUITextOwner::Draw(0, color, m_TextPos, bz+0.1f, cliparea);219 IGUITextOwner::Draw(0, m_TextColor, m_TextPos, bz+0.1f, cliparea); 252 220 } 253 221 } 254 222 -
source/gui/IGUIObject.h
111 111 112 112 void *m_pSetting; 113 113 EGUISettingType m_Type; 114 bool m_dynamic; 114 115 }; 115 116 116 117 /** … … 198 199 void AddToPointersMap(map_pObjects &ObjectMap); 199 200 200 201 /** 201 * Notice nothing will be returned or thrown if the child hasn't 202 * been inputted into the GUI yet. This is because that's were 202 * Notice nothing will be returned or thrown if the child hasn't 203 * been inputted into the GUI yet. This is because that's were 203 204 * all is checked. Now we're just linking two objects, but 204 205 * it's when we're inputting them into the GUI we'll check 205 206 * validity! Notice also when adding it to the GUI this function … … 239 240 * @return True if settings exist. 240 241 */ 241 242 bool SettingExists(const CStr& Setting) const; 242 243 243 244 /** 244 245 * All sizes are relative to resolution, and the calculation 245 246 * is not wanted in real time, therefore it is cached, update … … 291 292 * @param pGUI GUI instance to associate the script with 292 293 */ 293 294 void RegisterScriptHandler(const CStr& Action, const CStr& Code, CGUI* pGUI); 294 295 295 296 /** 296 297 * Retrieves the JSObject representing this GUI object. 297 298 */ … … 317 318 * @param Type Setting type 318 319 * @param Name Setting reference name 319 320 */ 320 void AddSetting(const EGUISettingType &Type, const CStr& Name );321 void AddSetting(const EGUISettingType &Type, const CStr& Name, void *Pointer = 0); 321 322 322 323 /** 323 324 * Calls Destroy on all children, and deallocates all memory. 324 325 * MEGA TODO Should it destroy it's children? 325 326 */ 326 327 virtual void Destroy(); 327 328 328 329 public: 329 330 /** 330 331 * This function is called with different messages … … 387 388 * Set parent of this object 388 389 */ 389 390 void SetParent(IGUIObject *pParent) { m_pParent = pParent; } 390 391 391 392 /** 392 393 * Reset internal state of this object 393 394 */ … … 435 436 * Notice 'false' is default, because an object not using this function, should not 436 437 * have any additional children (and this function should never be called). 437 438 */ 438 virtual bool HandleAdditionalChildren(const XMBElement& UNUSED(child), 439 virtual bool HandleAdditionalChildren(const XMBElement& UNUSED(child), 439 440 CXeromyces* UNUSED(pFile)) { return false; } 440 441 441 442 /** … … 480 481 /** @name Internal functions */ 481 482 //-------------------------------------------------------- 482 483 //@{ 483 484 484 485 /** 485 486 * Inputs a reference pointer, checks if the new inputted object 486 487 * if hovered, if so, then check if this's Z value is greater … … 529 530 530 531 // Pointer to parent 531 532 IGUIObject *m_pParent; 532 533 533 534 //This represents the last click time for each mouse button 534 535 double m_LastClickTime[6]; 535 536 … … 542 543 * read. This is important to know because I don't want to force 543 544 * the user to include its \<styles\>-XML-files first, so somehow 544 545 * the GUI needs to know which settings were set, and which is meant 545 * to 546 * to 546 547 */ 547 548 548 549 // More variables … … 558 559 * 559 560 * @see SetupSettings() 560 561 */ 561 public: 562 563 private: 564 bool m_Enabled; 565 bool m_Hidden; 566 bool m_Absolute; 567 bool m_Ghost; 568 float m_Z; 569 CClientArea m_Size; 570 CStr m_Style; 571 CStr m_Hotkey; 572 float m_AspectRatio; 573 574 public: 562 575 std::map<CStr, SGUISetting> m_Settings; 563 576 577 void SetEnabled(const bool enabled, const bool SkipMessage = false); 578 bool IsEnabled() const { return m_Enabled; } 579 580 void SetHidden(const bool hidden, const bool SkipMessage = false); 581 bool IsHidden() const { return m_Hidden; } 582 583 void SetAbsolute(const bool absolute, const bool SkipMessage = false); 584 bool IsAbsolute() const { return m_Absolute; } 585 586 void SetGhost(const bool ghost, const bool SkipMessage = false); 587 bool IsGhost() const { return m_Ghost; } 588 589 void SetZ(const float z, const bool SkipMessage = false); 590 float GetZ() const { return m_Z; } 591 592 void SetSize(const CClientArea& size, const bool SkipMessage = false); 593 const CClientArea& GetSize() const { return m_Size; } 594 595 void SetStyle(const CStr& style, const bool SkipMessage = false); 596 const CStr& GetStyle() const { return m_Style; } 597 598 void SetHotkey(const CStr& hotkey, const bool SkipMessage = false); 599 const CStr& GetHotkey() const { return m_Hotkey; } 600 601 void SetAspectRatio(const float aspect_ratio, const bool SkipMessage = false); 602 float GetAspectRatio() const { return m_AspectRatio; } 603 604 564 605 private: 565 606 // An object can't function stand alone 566 607 CGUI *m_pGUI; 567 608 568 609 // Internal storage for registered script handlers. 569 610 std::map<CStr, JSObject**> m_ScriptHandlers; 570 611 571 612 // Cached JSObject representing this GUI object 572 613 JSObject *m_JSObject; 573 614 }; -
source/gui/CImage.h
57 57 * without functionality used, and that is a lot of unnecessary 58 58 * overhead. That's why I thought I'd go with an intuitive 59 59 * control. 60 * 60 * 61 61 * @see IGUIObject 62 62 */ 63 63 class CImage : public IGUIObject … … 73 73 * Draws the Image 74 74 */ 75 75 virtual void Draw(); 76 77 private: 78 int m_CellId; 79 CGUISpriteInstance m_Sprite; 80 CStrW m_Tooltip; 81 CStr m_TooltipStyle; 82 76 83 }; 77 84 78 85 #endif -
source/gui/CCheckBox.h
50 50 51 51 /** 52 52 * CheckBox 53 * 53 * 54 54 * @see IGUIObject 55 55 * @see IGUISettingsObject 56 56 * @see IGUIButtonBehavior … … 84 84 * made that can change the visual. 85 85 */ 86 86 void SetupText(); 87 88 private: 89 float m_BufferZone; 90 CGUIString m_Caption; 91 int m_CellId; 92 CStrW m_Font; 93 bool m_Checked; 94 CGUISpriteInstance m_Sprite; 95 CGUISpriteInstance m_SpriteOver; 96 CGUISpriteInstance m_SpritePressed; 97 CGUISpriteInstance m_SpriteDisabled; 98 CGUISpriteInstance m_Sprite2; 99 CGUISpriteInstance m_SpriteOver2; 100 CGUISpriteInstance m_SpritePressed2; 101 CGUISpriteInstance m_SpriteDisabled2; 102 float m_SquareSide; 103 CStrW m_Tooltip; 104 CStr m_TooltipStyle; 105 87 106 }; 88 107 89 108 #endif -
source/gui/CDropDown.cpp
32 32 //------------------------------------------------------------------- 33 33 CDropDown::CDropDown() : m_Open(false), m_HideScrollBar(false), m_ElementHighlight(-1) 34 34 { 35 AddSetting(GUIST_float, "button_width" );36 AddSetting(GUIST_float, "dropdown_size" );37 AddSetting(GUIST_float, "dropdown_buffer" );35 AddSetting(GUIST_float, "button_width", &m_ButtonWidth); 36 AddSetting(GUIST_float, "dropdown_size", &m_DropdownSize); 37 AddSetting(GUIST_float, "dropdown_buffer", &m_DropdownBuffer); 38 38 // AddSetting(GUIST_CStrW, "font"); 39 39 // AddSetting(GUIST_CGUISpriteInstance, "sprite"); // Background that sits around the size 40 AddSetting(GUIST_CGUISpriteInstance, "sprite_list"); // Background of the drop down list 41 AddSetting(GUIST_CGUISpriteInstance, "sprite2"); // Button that sits to the right 42 AddSetting(GUIST_CGUISpriteInstance, "sprite2_over"); 43 AddSetting(GUIST_CGUISpriteInstance, "sprite2_pressed"); 44 AddSetting(GUIST_CGUISpriteInstance, "sprite2_disabled"); 45 AddSetting(GUIST_EVAlign, "text_valign"); 46 40 AddSetting(GUIST_CGUISpriteInstance, "sprite_list", &m_SpriteList); // Background of the drop down list 41 AddSetting(GUIST_CGUISpriteInstance, "sprite2", &m_Sprite2); // Button that sits to the right 42 AddSetting(GUIST_CGUISpriteInstance, "sprite2_over", &m_SpriteOver2); 43 AddSetting(GUIST_CGUISpriteInstance, "sprite2_pressed", &m_SpritePressed2); 44 AddSetting(GUIST_CGUISpriteInstance, "sprite2_disabled", &m_SpriteDisabled2); 45 47 46 // Add these in CList! And implement TODO 48 47 //AddSetting(GUIST_CColor, "textcolor_over"); 49 48 //AddSetting(GUIST_CColor, "textcolor_pressed"); … … 81 80 Message.value == "button_width") 82 81 { 83 82 SetupListRect(); 84 } 83 } 85 84 86 85 break; 87 86 } … … 94 93 95 94 if (GetListRect().PointInside(mouse)) 96 95 { 97 bool scrollbar; 98 CGUIList *pList; 99 GUI<bool>::GetSetting(this, "scrollbar", scrollbar); 100 GUI<CGUIList>::GetSettingPointer(this, "list", pList); 96 const CGUIList &list_elements = GetList(); 101 97 float scroll=0.f; 102 if ( scrollbar)98 if (IsScrollbar()) 103 99 { 104 100 scroll = GetScrollBar(0).GetPos(); 105 101 } … … 107 103 CRect rect = GetListRect(); 108 104 mouse.y += scroll; 109 105 int set=-1; 110 for (int i=0; i<(int) pList->m_Items.size(); ++i)106 for (int i=0; i<(int)list_elements.m_Items.size(); ++i) 111 107 { 112 108 if (mouse.y >= rect.top + m_ItemsYPositions[i] && 113 109 mouse.y < rect.top + m_ItemsYPositions[i+1] && … … 118 114 set = i; 119 115 } 120 116 } 121 117 122 118 if (set != -1) 123 119 { 124 120 //GUI<int>::SetSetting(this, "selected", set); … … 133 129 134 130 case GUIM_MOUSE_LEAVE: 135 131 { 136 GUI<int>::GetSetting(this, "selected", m_ElementHighlight);132 m_ElementHighlight = GetSelectedIndex(); 137 133 138 134 break; 139 135 } … … 142 138 // a mouse click to open the dropdown, also the coordinates are changed. 143 139 case GUIM_MOUSE_PRESS_LEFT: 144 140 { 145 bool enabled; 146 GUI<bool>::GetSetting(this, "enabled", enabled); 147 if (!enabled) 141 if (! IsEnabled() ) 148 142 break; 149 143 150 144 if (!m_Open) … … 152 146 m_Open = true; 153 147 GetScrollBar(0).SetPos(0.f); 154 148 GetScrollBar(0).SetZ(GetBufferedZ()); 155 GUI<int>::GetSetting(this, "selected", m_ElementHighlight);149 m_ElementHighlight = GetSelectedIndex(); 156 150 return; // overshadow 157 151 } 158 152 else … … 226 220 CList::ManuallyHandleEvent(ev); 227 221 228 222 if (update_highlight) 229 GUI<int>::GetSetting(this, "selected", m_ElementHighlight);223 m_ElementHighlight = GetSelectedIndex(); 230 224 231 225 return IN_HANDLED; 232 226 } 233 227 234 228 void CDropDown::SetupListRect() 235 229 { 236 float size, buffer, button_width; 237 GUI<float>::GetSetting(this, "dropdown_size", size); 238 GUI<float>::GetSetting(this, "dropdown_buffer", buffer); 239 GUI<float>::GetSetting(this, "button_width", button_width); 240 241 if (m_ItemsYPositions.empty() || m_ItemsYPositions.back() >= size) 230 if (m_ItemsYPositions.empty() || m_ItemsYPositions.back() >= m_DropdownSize) 242 231 { 243 m_CachedListRect = CRect(m_CachedActualSize.left, m_CachedActualSize.bottom+ buffer,244 m_CachedActualSize.right, m_CachedActualSize.bottom+ buffer + size);232 m_CachedListRect = CRect(m_CachedActualSize.left, m_CachedActualSize.bottom+m_DropdownBuffer, 233 m_CachedActualSize.right, m_CachedActualSize.bottom+m_DropdownBuffer + m_DropdownSize); 245 234 246 235 m_HideScrollBar = false; 247 236 } 248 237 else 249 238 { 250 m_CachedListRect = CRect(m_CachedActualSize.left, m_CachedActualSize.bottom+ buffer,251 m_CachedActualSize.right - GetScrollBar(0).GetStyle()->m_Width, m_CachedActualSize.bottom+ buffer + m_ItemsYPositions.back());239 m_CachedListRect = CRect(m_CachedActualSize.left, m_CachedActualSize.bottom+m_DropdownBuffer, 240 m_CachedActualSize.right - GetScrollBar(0).GetStyle()->m_Width, m_CachedActualSize.bottom+m_DropdownBuffer + m_ItemsYPositions.back()); 252 241 253 242 // We also need to hide the scrollbar 254 243 m_HideScrollBar = true; … … 277 266 return m_CachedActualSize.PointInside(GetMousePos()); 278 267 } 279 268 280 void CDropDown::Draw() 269 void CDropDown::Draw() 281 270 { 282 271 if (!GetGUI()) 283 272 return; 284 273 285 274 float bz = GetBufferedZ(); 286 275 287 float dropdown_size, button_width;288 GUI<float>::GetSetting(this, "dropdown_size", dropdown_size);289 GUI<float>::GetSetting(this, "button_width", button_width);276 int cell_id = GetCellId(); 277 int selected= GetSelectedIndex(); 278 const CColor& color = GetTextColor(); 290 279 291 CGUISpriteInstance *sprite, *sprite2, *sprite2_second; 292 int cell_id, selected=0; 293 CColor color; 280 GetGUI()->DrawSprite(GetSprite(), cell_id, bz, m_CachedActualSize); 294 281 295 GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite", sprite); 296 GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2", sprite2); 297 GUI<int>::GetSetting(this, "cell_id", cell_id); 298 GUI<int>::GetSetting(this, "selected", selected); 299 GUI<CColor>::GetSetting(this, "textcolor", color); 300 301 302 bool enabled; 303 GUI<bool>::GetSetting(this, "enabled", enabled); 304 305 GetGUI()->DrawSprite(*sprite, cell_id, bz, m_CachedActualSize); 306 307 if (button_width > 0.f) 282 if (m_ButtonWidth > 0.f) 308 283 { 309 CRect rect(m_CachedActualSize.right- button_width, m_CachedActualSize.top,284 CRect rect(m_CachedActualSize.right-m_ButtonWidth, m_CachedActualSize.top, 310 285 m_CachedActualSize.right, m_CachedActualSize.bottom); 311 286 312 if (! enabled)287 if (! IsEnabled() ) 313 288 { 314 GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_disabled", sprite2_second); 315 GetGUI()->DrawSprite(GUI<>::FallBackSprite(*sprite2_second, *sprite2), cell_id, bz+0.05f, rect); 289 GetGUI()->DrawSprite(GUI<>::FallBackSprite(m_SpriteDisabled2, m_Sprite2), cell_id, bz+0.05f, rect); 316 290 } 317 291 else 318 292 if (m_Open) 319 293 { 320 GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_pressed", sprite2_second); 321 GetGUI()->DrawSprite(GUI<>::FallBackSprite(*sprite2_second, *sprite2), cell_id, bz+0.05f, rect); 294 GetGUI()->DrawSprite(GUI<>::FallBackSprite(m_SpritePressed2, m_Sprite2), cell_id, bz+0.05f, rect); 322 295 } 323 296 else 324 297 if (m_MouseHovering) 325 298 { 326 GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_over", sprite2_second); 327 GetGUI()->DrawSprite(GUI<>::FallBackSprite(*sprite2_second, *sprite2), cell_id, bz+0.05f, rect); 299 GetGUI()->DrawSprite(GUI<>::FallBackSprite(m_SpriteOver2, m_Sprite2), cell_id, bz+0.05f, rect); 328 300 } 329 else 330 GetGUI()->DrawSprite( *sprite2, cell_id, bz+0.05f, rect);301 else 302 GetGUI()->DrawSprite(m_Sprite2, cell_id, bz+0.05f, rect); 331 303 } 332 304 333 305 if (selected != -1) // TODO: Maybe check validity completely? 334 306 { 335 307 // figure out clipping rectangle 336 308 CRect cliparea(m_CachedActualSize.left, m_CachedActualSize.top, 337 m_CachedActualSize.right- button_width, m_CachedActualSize.bottom);309 m_CachedActualSize.right-m_ButtonWidth, m_CachedActualSize.bottom); 338 310 339 311 CPos pos(m_CachedActualSize.left, m_CachedActualSize.top); 340 312 IGUITextOwner::Draw(selected, color, pos, bz+0.1f, cliparea); 341 313 } 342 314 343 bool *scrollbar=NULL, old;344 GUI<bool>::GetSettingPointer(this, "scrollbar", scrollbar);345 346 old = *scrollbar;347 348 315 if (m_Open) 349 316 { 317 bool old = IsScrollbar(); 350 318 if (m_HideScrollBar) 351 *scrollbar = false;319 SetScrollbar( false ); 352 320 353 DrawList(m_ElementHighlight, "sprite_list", "sprite_selectarea", "textcolor");354 321 DrawList(m_ElementHighlight, m_SpriteList); 322 355 323 if (m_HideScrollBar) 356 *scrollbar = old;324 SetScrollbar(old); 357 325 } 358 326 } 359 327 -
source/gui/CTooltip.h
46 46 virtual void HandleMessage(SGUIMessage &Message); 47 47 48 48 virtual void Draw(); 49 private: 50 float m_BufferZone; 51 CGUIString m_Caption; 52 CStrW m_Font; 53 CGUISpriteInstance m_Sprite; 54 CColor m_TextColor; 55 int m_Delay; 56 float m_MaxWidth; 57 CPos m_Offset; 58 EVAlign m_Anchor; 59 CStr m_UseObject; 60 bool m_HideObject; 61 CPos m_MousePos; 49 62 }; 50 63 51 64 #endif -
source/gui/CInput.h
82 82 int GetMouseHoveringTextPosition(); 83 83 84 84 // Same as above, but only on one row in X, and a given value, not the mouse's 85 // wanted is filled with x if the row didn't extend as far as we 85 // wanted is filled with x if the row didn't extend as far as we 86 86 int GetXTextPosition(const std::list<SRow>::iterator &c, const float &x, float &wanted); 87 87 88 88 protected: … … 137 137 void UpdateAutoScroll(); 138 138 139 139 protected: 140 // Cursor position 140 // Cursor position 141 141 // (the second one is for selection of larger areas, -1 if not used) 142 142 // A note on 'Tail', it was first called 'To', and the natural order 143 143 // of X and X_To was X then X_To. Now Tail is called so, because it … … 182 182 183 183 // *** Things for one-line input control *** // 184 184 float m_HorizontalScroll; 185 private: 186 float m_BufferZone; 187 CStrW m_Caption; 188 int m_CellId; 189 CStrW m_Font; 190 int m_MaxLength; 191 bool m_Multiline; 192 bool m_Scrollbar; 193 CStr m_ScrollbarStyle; 194 CGUISpriteInstance m_Sprite; 195 CGUISpriteInstance m_SpriteSelectArea; 196 CColor m_TextColor; 197 CColor m_TextColorSelected; 198 CStrW m_Tooltip; 199 CStr m_TooltipStyle; 200 201 185 202 }; 186 203 187 204 #endif -
source/gui/IGUITextOwner.cpp
28 28 //------------------------------------------------------------------- 29 29 IGUITextOwner::IGUITextOwner() : m_GeneratedTextsValid(false) 30 30 { 31 AddSetting(GUIST_EAlign, "text_align", &m_TextAlign); 32 AddSetting(GUIST_EVAlign, "text_valign", &m_TextVAlign); 33 34 m_TextAlign = EAlign_Left; 35 m_TextVAlign = EVAlign_Top; 31 36 } 32 37 33 38 IGUITextOwner::~IGUITextOwner() … … 101 106 102 107 void IGUITextOwner::CalculateTextPosition(CRect &ObjSize, CPos &TextPos, SGUIText &Text) 103 108 { 104 EAlign align; 105 EVAlign valign; 106 GUI<EAlign>::GetSetting(this, "text_align", align); 107 GUI<EVAlign>::GetSetting(this, "text_valign", valign); 108 109 switch (align) 109 switch (m_TextAlign) 110 110 { 111 111 case EAlign_Left: 112 112 TextPos.x = ObjSize.left; … … 123 123 break; 124 124 } 125 125 126 switch ( valign)126 switch (m_TextVAlign) 127 127 { 128 128 case EVAlign_Top: 129 129 TextPos.y = ObjSize.top; -
source/gui/CList.cpp
34 34 CList::CList() 35 35 { 36 36 // Add sprite_disabled! TODO 37 38 AddSetting(GUIST_float, "buffer_zone"); 37 AddSetting(GUIST_float, "buffer_zone", &m_BufferZone); 39 38 //AddSetting(GUIST_CGUIString, "caption"); will it break removing this? If I know my system, then no, but test just in case TODO (Gee). 40 AddSetting(GUIST_CStrW, "font"); 41 AddSetting(GUIST_bool, "scrollbar"); 42 AddSetting(GUIST_CStr, "scrollbar_style"); 43 AddSetting(GUIST_CGUISpriteInstance, "sprite"); 44 AddSetting(GUIST_CGUISpriteInstance, "sprite_selectarea"); 45 AddSetting(GUIST_int, "cell_id"); 46 AddSetting(GUIST_EAlign, "text_align"); 47 AddSetting(GUIST_CColor, "textcolor"); 48 AddSetting(GUIST_CColor, "textcolor_selected"); 49 AddSetting(GUIST_int, "selected"); // Index selected. -1 is none. 50 AddSetting(GUIST_CStrW, "tooltip"); 51 AddSetting(GUIST_CStr, "tooltip_style"); 39 AddSetting(GUIST_int, "cell_id", &m_CellId); 40 AddSetting(GUIST_CStrW, "font", &m_Font); 41 AddSetting(GUIST_bool, "scrollbar", &m_Scrollbar); 42 AddSetting(GUIST_CStr, "scrollbar_style", &m_ScrollbarStyle); 43 AddSetting(GUIST_CGUISpriteInstance, "sprite", &m_Sprite); 44 AddSetting(GUIST_CGUISpriteInstance, "sprite_selectarea", &m_SpriteSelectArea); 45 AddSetting(GUIST_CColor, "textcolor", &m_TextColor); 46 AddSetting(GUIST_CColor, "textcolor_selected",&m_TextSelected); 47 AddSetting(GUIST_int, "selected", &m_Selected); // Index selected. -1 is none. 48 AddSetting(GUIST_CStrW, "tooltip", &m_Tooltip); 49 AddSetting(GUIST_CStr, "tooltip_style", &m_TooltipStyle); 52 50 // Each list item has both a name (in 'list') and an associated data string (in 'list_data') 53 AddSetting(GUIST_CGUIList, "list" );54 AddSetting(GUIST_CGUIList, "list_data" ); // TODO: this should be a list of raw strings, not of CGUIStrings51 AddSetting(GUIST_CGUIList, "list", &m_List); 52 AddSetting(GUIST_CGUIList, "list_data", &m_ListData); // TODO: this should be a list of raw strings, not of CGUIStrings 55 53 54 m_BufferZone = 0.f; 55 m_Font = L"default"; 56 //m_Scrollbar = false; 57 //m_Selected = -1; 58 56 59 GUI<bool>::SetSetting(this, "scrollbar", false); 57 60 58 61 // Nothing is selected as default. … … 74 77 if (!GetGUI()) 75 78 return; 76 79 77 CGUIList *pList;78 GUI<CGUIList>::GetSettingPointer(this, "list", pList);79 80 80 //ENSURE(m_GeneratedTexts.size()>=1); 81 81 82 m_ItemsYPositions.resize( pList->m_Items.size()+1 );82 m_ItemsYPositions.resize( m_List.m_Items.size()+1 ); 83 83 84 84 // Delete all generated texts. Some could probably be saved, 85 85 // but this is easier, and this function will never be called … … 92 92 } 93 93 m_GeneratedTexts.clear(); 94 94 95 CStrW font;96 if (GUI<CStrW>::GetSetting(this, "font", font) != PSRETURN_OK || font.empty())97 // Use the default if none is specified98 // TODO Gee: (2004-08-14) Don't define standard like this. Do it with the default style.99 font = L"default";100 101 //CGUIString caption;102 bool scrollbar;103 //GUI<CGUIString>::GetSetting(this, "caption", caption);104 GUI<bool>::GetSetting(this, "scrollbar", scrollbar);105 106 95 float width = GetListRect().GetWidth(); 107 96 // remove scrollbar if applicable 108 if ( scrollbar && GetScrollBar(0).GetStyle())97 if (m_Scrollbar && GetScrollBar(0).GetStyle()) 109 98 width -= GetScrollBar(0).GetStyle()->m_Width; 110 99 111 float buffer_zone=0.f;112 GUI<float>::GetSetting(this, "buffer_zone", buffer_zone);113 114 100 // Generate texts 115 101 float buffered_y = 0.f; 116 117 for (int i=0; i<(int) pList->m_Items.size(); ++i)102 103 for (int i=0; i<(int)m_List.m_Items.size(); ++i) 118 104 { 119 105 // Create a new SGUIText. Later on, input it using AddText() 120 106 SGUIText *text = new SGUIText(); 121 107 122 *text = GetGUI()->GenerateText( pList->m_Items[i], font, width, buffer_zone, this);108 *text = GetGUI()->GenerateText(m_List.m_Items[i], m_Font, width, m_BufferZone, this); 123 109 124 110 m_ItemsYPositions[i] = buffered_y; 125 111 buffered_y += text->m_Size.cy; … … 127 113 AddText(text); 128 114 } 129 115 130 m_ItemsYPositions[ pList->m_Items.size()] = buffered_y;131 116 m_ItemsYPositions[m_List.m_Items.size()] = buffered_y; 117 132 118 //if (! scrollbar) 133 119 // CalculateTextPosition(m_CachedActualSize, m_TextPos, *m_GeneratedTexts[0]); 134 120 135 121 // Setup scrollbar 136 if ( scrollbar)122 if (m_Scrollbar) 137 123 { 138 124 GetScrollBar(0).SetScrollRange( m_ItemsYPositions.back() ); 139 125 GetScrollBar(0).SetScrollSpace( GetListRect().GetHeight() ); … … 165 151 // TODO: Check range 166 152 167 153 // TODO only works if lower-case, shouldn't it be made case sensitive instead? 168 ScriptEvent("selectionchange"); 154 ScriptEvent("selectionchange"); 169 155 } 170 156 171 157 if (Message.value == "scrollbar") … … 176 162 // Update scrollbar 177 163 if (Message.value == "scrollbar_style") 178 164 { 179 CStr scrollbar_style; 180 GUI<CStr>::GetSetting(this, Message.value, scrollbar_style); 165 GetScrollBar(0).SetScrollBarStyle( m_ScrollbarStyle ); 181 166 182 GetScrollBar(0).SetScrollBarStyle( scrollbar_style );183 184 167 SetupText(); 185 168 } 186 169 … … 188 171 189 172 case GUIM_MOUSE_PRESS_LEFT: 190 173 { 191 bool enabled; 192 GUI<bool>::GetSetting(this, "enabled", enabled); 193 if (!enabled) 174 if (!IsEnabled()) 194 175 break; 195 176 196 bool scrollbar;197 CGUIList *pList;198 GUI<bool>::GetSetting(this, "scrollbar", scrollbar);199 GUI<CGUIList>::GetSettingPointer(this, "list", pList);200 177 float scroll=0.f; 201 if ( scrollbar)178 if (m_Scrollbar) 202 179 { 203 180 scroll = GetScrollBar(0).GetPos(); 204 181 } … … 207 184 CPos mouse = GetMousePos(); 208 185 mouse.y += scroll; 209 186 int set=-1; 210 for (int i=0; i<(int) pList->m_Items.size(); ++i)187 for (int i=0; i<(int)m_List.m_Items.size(); ++i) 211 188 { 212 189 if (mouse.y >= rect.top + m_ItemsYPositions[i] && 213 190 mouse.y < rect.top + m_ItemsYPositions[i+1] && … … 218 195 set = i; 219 196 } 220 197 } 221 198 222 199 if (set != -1) 223 200 { 201 // keep this for now 224 202 GUI<int>::SetSetting(this, "selected", set); 203 225 204 UpdateAutoScroll(); 226 205 } 227 206 } break; … … 246 225 } 247 226 case GUIM_LOAD: 248 227 { 249 CStr scrollbar_style; 250 GUI<CStr>::GetSetting(this, "scrollbar_style", scrollbar_style); 251 GetScrollBar(0).SetScrollBarStyle( scrollbar_style ); 228 GetScrollBar(0).SetScrollBarStyle( m_ScrollbarStyle ); 252 229 } 253 230 break; 254 231 … … 300 277 return IN_HANDLED; 301 278 } 302 279 303 void CList::Draw() 280 void CList::Draw() 304 281 { 305 int selected; 306 GUI<int>::GetSetting(this, "selected", selected); 307 308 DrawList(selected, "sprite", "sprite_selectarea", "textcolor"); 282 DrawList(m_Selected, m_Sprite); 309 283 } 310 284 311 285 void CList::DrawList(const int &selected, 312 const CStr& _sprite, 313 const CStr& _sprite_selected, 314 const CStr& _textcolor) 286 const CGUISpriteInstance& sprite) 315 287 { 316 float bz = GetBufferedZ();317 318 288 // First call draw on ScrollBarOwner 319 bool scrollbar;320 GUI<bool>::GetSetting(this, "scrollbar", scrollbar);321 289 322 if ( scrollbar)290 if (m_Scrollbar) 323 291 { 324 292 // Draw scrollbar 325 293 IGUIScrollBarOwner::Draw(); … … 327 295 328 296 if (GetGUI()) 329 297 { 298 float bz = GetBufferedZ(); 330 299 CRect rect = GetListRect(); 331 300 332 CGUISpriteInstance *sprite=NULL, *sprite_selectarea=NULL; 333 int cell_id; 334 GUI<CGUISpriteInstance>::GetSettingPointer(this, _sprite, sprite); 335 GUI<CGUISpriteInstance>::GetSettingPointer(this, _sprite_selected, sprite_selectarea); 336 GUI<int>::GetSetting(this, "cell_id", cell_id); 301 GetGUI()->DrawSprite(sprite, m_CellId, bz, rect); 337 302 338 CGUIList *pList;339 GUI<CGUIList>::GetSettingPointer(this, "list", pList);340 341 GetGUI()->DrawSprite(*sprite, cell_id, bz, rect);342 343 303 float scroll=0.f; 344 if ( scrollbar)304 if (m_Scrollbar) 345 305 { 346 306 scroll = GetScrollBar(0).GetPos(); 347 307 } … … 362 322 if (rect_sel.top < rect.top) 363 323 rect_sel.top = rect.top; 364 324 365 if ( scrollbar)325 if (m_Scrollbar) 366 326 { 367 327 // Remove any overlapping area of the scrollbar. 368 328 if (rect_sel.right > GetScrollBar(0).GetOuterRect().left && … … 374 334 rect_sel.left = GetScrollBar(0).GetOuterRect().right; 375 335 } 376 336 377 GetGUI()->DrawSprite( *sprite_selectarea, cell_id, bz+0.05f, rect_sel);337 GetGUI()->DrawSprite(m_SpriteSelectArea, m_CellId, bz+0.05f, rect_sel); 378 338 } 379 339 } 380 340 381 CColor color; 382 GUI<CColor>::GetSetting(this, _textcolor, color); 383 384 for (int i=0; i<(int)pList->m_Items.size(); ++i) 341 for (int i=0; i<(int)m_List.m_Items.size(); ++i) 385 342 { 386 343 if (m_ItemsYPositions[i+1] - scroll < 0 || 387 344 m_ItemsYPositions[i] - scroll > rect.GetHeight()) … … 390 347 // Clipping area (we'll have to substract the scrollbar) 391 348 CRect cliparea = GetListRect(); 392 349 393 if ( scrollbar)350 if (m_Scrollbar) 394 351 { 395 352 if (cliparea.right > GetScrollBar(0).GetOuterRect().left && 396 353 cliparea.right <= GetScrollBar(0).GetOuterRect().right) … … 401 358 cliparea.left = GetScrollBar(0).GetOuterRect().right; 402 359 } 403 360 404 IGUITextOwner::Draw(i, color, rect.TopLeft() - CPos(0.f, scroll - m_ItemsYPositions[i]),361 IGUITextOwner::Draw(i, m_TextColor, rect.TopLeft() - CPos(0.f, scroll - m_ItemsYPositions[i]), 405 362 bz+0.1f, cliparea); 406 363 } 407 364 } … … 409 366 410 367 void CList::AddItem(const CStrW& str, const CStrW& data) 411 368 { 412 CGUIList *pList, *pListData;413 GUI<CGUIList>::GetSettingPointer(this, "list", pList);414 GUI<CGUIList>::GetSettingPointer(this, "list_data", pListData);415 416 369 CGUIString gui_string; 417 370 gui_string.SetValue(str); 418 pList->m_Items.push_back( gui_string );371 m_List.m_Items.push_back( gui_string ); 419 372 420 373 CGUIString data_string; 421 374 data_string.SetValue(data); 422 pListData->m_Items.push_back( data_string );375 m_ListData.m_Items.push_back( data_string ); 423 376 424 377 // TODO Temp 425 378 SetupText(); … … 432 385 if (child.GetNodeName() == elmt_item) 433 386 { 434 387 AddItem(child.GetText().FromUTF8(), child.GetText().FromUTF8()); 435 388 436 389 return true; 437 390 } 438 391 else … … 443 396 444 397 void CList::SelectNextElement() 445 398 { 446 int selected; 447 GUI<int>::GetSetting(this, "selected", selected); 448 449 CGUIList *pList; 450 GUI<CGUIList>::GetSettingPointer(this, "list", pList); 451 452 if (selected != (int)pList->m_Items.size()-1) 399 if (m_Selected != (int)m_List.m_Items.size()-1) 453 400 { 454 ++selected; 455 GUI<int>::SetSetting(this, "selected", selected); 401 SetSelected(m_Selected+1); 456 402 } 457 403 } 458 404 459 405 void CList::SelectPrevElement() 460 406 { 461 int selected; 462 GUI<int>::GetSetting(this, "selected", selected); 463 464 if (selected != 0) 407 if (m_Selected != 0) 465 408 { 466 --selected; 467 GUI<int>::SetSetting(this, "selected", selected); 409 SetSelected(m_Selected-1); 468 410 } 469 411 } 470 412 471 413 void CList::SelectFirstElement() 472 414 { 473 int selected; 474 GUI<int>::GetSetting(this, "selected", selected); 475 476 if (selected != 0) 415 if (m_Selected != 0) 477 416 { 478 GUI<int>::SetSetting(this, "selected",0);417 SetSelected(0); 479 418 } 480 419 } 481 420 482 421 void CList::SelectLastElement() 483 422 { 484 int selected; 485 GUI<int>::GetSetting(this, "selected", selected); 486 487 CGUIList *pList; 488 GUI<CGUIList>::GetSettingPointer(this, "list", pList); 489 490 if (selected != (int)pList->m_Items.size()-1) 423 if (m_Selected != (int)m_List.m_Items.size()-1) 491 424 { 492 GUI<int>::SetSetting(this, "selected", (int)pList->m_Items.size()-1);425 SetSelected(m_List.m_Items.size()-1); 493 426 } 494 427 } 495 428 496 429 void CList::UpdateAutoScroll() 497 430 { 498 int selected;499 bool scrollbar;500 float scroll;501 GUI<int>::GetSetting(this, "selected", selected);502 GUI<bool>::GetSetting(this, "scrollbar", scrollbar);503 504 CRect rect = GetListRect();505 506 431 // No scrollbar, no scrolling (at least it's not made to work properly). 507 if (! scrollbar)432 if (!m_Scrollbar) 508 433 return; 509 434 510 scroll = GetScrollBar(0).GetPos();435 float scroll = GetScrollBar(0).GetPos(); 511 436 437 CRect rect = GetListRect(); 438 512 439 // Check upper boundary 513 if (m_ItemsYPositions[ selected] < scroll)440 if (m_ItemsYPositions[m_Selected] < scroll) 514 441 { 515 GetScrollBar(0).SetPos(m_ItemsYPositions[ selected]);442 GetScrollBar(0).SetPos(m_ItemsYPositions[m_Selected]); 516 443 return; // this means, if it wants to align both up and down at the same time 517 444 // this will have precedence. 518 445 } 519 446 520 447 // Check lower boundary 521 if (m_ItemsYPositions[ selected+1]-rect.GetHeight() > scroll)448 if (m_ItemsYPositions[m_Selected+1]-rect.GetHeight() > scroll) 522 449 { 523 GetScrollBar(0).SetPos(m_ItemsYPositions[ selected+1]-rect.GetHeight());450 GetScrollBar(0).SetPos(m_ItemsYPositions[m_Selected+1]-rect.GetHeight()); 524 451 } 525 452 } 453 454 void CList::SetSelected(const int index, const bool SkipMessage) 455 { 456 m_Selected = index; 457 if (!SkipMessage) 458 { 459 SGUIMessage msg(GUIM_SETTINGS_UPDATED, "selected"); 460 HandleMessage( msg ); 461 } 462 } 463 464 void CList::SetScrollbar(const bool scrollbar, const bool SkipMessage) 465 { 466 m_Scrollbar = scrollbar; 467 if (!SkipMessage) 468 { 469 SGUIMessage msg(GUIM_SETTINGS_UPDATED, "scrollbar"); 470 HandleMessage( msg ); 471 } 472 } -
source/gui/IGUIButtonBehavior.h
124 124 * this lets us know we are done with step one (clicking). 125 125 */ 126 126 bool m_Pressed; 127 private: 128 CColor m_ButtonTextColor; 129 CColor m_ButtonTextColorOver; 130 CColor m_ButtonTextColorPressed; 131 CColor m_ButtonTextColorDisabled; 132 127 133 }; 128 134 129 135 #endif -
source/gui/GUIutil.cpp
392 392 QueryResetting(pObject); 393 393 } 394 394 395 if (!SkipMessage) 395 if (!SkipMessage) // XXX has to send msg when some changes. 396 396 { 397 397 SGUIMessage msg(GUIM_SETTINGS_UPDATED, Setting); 398 398 HandleMessage(pObject, msg); -
source/gui/CButton.h
50 50 51 51 /** 52 52 * Button 53 * 53 * 54 54 * @see IGUIObject 55 55 * @see IGUIButtonBehavior 56 56 */ … … 88 88 * Placement of text. 89 89 */ 90 90 CPos m_TextPos; 91 92 private: 93 float m_BufferZone; 94 CGUIString m_Caption; 95 int m_CellId; 96 CStrW m_Font; 97 CGUISpriteInstance m_Sprite; 98 CGUISpriteInstance m_SpriteOver; 99 CGUISpriteInstance m_SpritePressed; 100 CGUISpriteInstance m_SpriteDisabled; 101 CStrW m_Tooltip; 102 CStr m_TooltipStyle; 91 103 }; 92 104 93 105 #endif -
source/gui/IGUIObject.cpp
40 40 //------------------------------------------------------------------- 41 41 // Constructor / Destructor 42 42 //------------------------------------------------------------------- 43 IGUIObject::IGUIObject() : 44 m_pGUI(NULL), 43 IGUIObject::IGUIObject() : 44 m_pGUI(NULL), 45 45 m_pParent(NULL), 46 46 m_MouseHovering(false), 47 47 m_JSObject(NULL) 48 48 { 49 AddSetting(GUIST_bool, "enabled" );50 AddSetting(GUIST_bool, "hidden" );51 AddSetting(GUIST_CClientArea, "size" );52 AddSetting(GUIST_CStr, "style" );53 AddSetting(GUIST_CStr, "hotkey" 54 AddSetting(GUIST_float, "z" );55 AddSetting(GUIST_bool, "absolute" );56 AddSetting(GUIST_bool, "ghost" );57 AddSetting(GUIST_float, "aspectratio" );49 AddSetting(GUIST_bool, "enabled", &m_Enabled); 50 AddSetting(GUIST_bool, "hidden", &m_Hidden); 51 AddSetting(GUIST_CClientArea, "size", &m_Size); 52 AddSetting(GUIST_CStr, "style", &m_Style); 53 AddSetting(GUIST_CStr, "hotkey", &m_Hotkey); 54 AddSetting(GUIST_float, "z", &m_Z); 55 AddSetting(GUIST_bool, "absolute", &m_Absolute); 56 AddSetting(GUIST_bool, "ghost", &m_Ghost); 57 AddSetting(GUIST_float, "aspectratio", &m_AspectRatio); 58 58 59 59 // Setup important defaults 60 GUI<bool>::SetSetting(this, "hidden", false); 61 GUI<bool>::SetSetting(this, "ghost", false); 62 GUI<bool>::SetSetting(this, "enabled", true); 63 GUI<bool>::SetSetting(this, "absolute", true); 60 // GUI<bool>::SetSetting(this, "hidden", false); 61 SetHidden(false); 62 // GUI<bool>::SetSetting(this, "ghost", false); 63 SetGhost(false); 64 // GUI<bool>::SetSetting(this, "enabled", true); 65 SetEnabled(true); 66 // GUI<bool>::SetSetting(this, "absolute", true); 67 SetAbsolute(true); 64 68 69 SetAspectRatio(0.f); 65 70 71 66 72 for (int i=0; i<6; i++) 67 73 m_LastClickTime[i]=0; 68 74 } … … 73 79 std::map<CStr, SGUISetting>::iterator it; 74 80 for (it = m_Settings.begin(); it != m_Settings.end(); ++it) 75 81 { 76 switch (it->second.m_Type)82 if ( it->second.m_dynamic ) 77 83 { 78 // delete() needs to know the type of the variable - never delete a void* 84 // delete only the settings we created 85 switch (it->second.m_Type) 86 { 87 // delete() needs to know the type of the variable - never delete a void* 79 88 #define TYPE(t) case GUIST_##t: delete (t*)it->second.m_pSetting; break; 80 89 #include "GUItypes.h" 81 90 #undef TYPE 82 default: 83 debug_warn(L"Invalid setting type"); 91 default: 92 debug_warn(L"Invalid setting type"); 93 } 84 94 } 85 95 } 86 96 } … … 93 103 delete it->second; 94 104 } 95 105 } 96 106 97 107 if (m_JSObject) 98 108 JS_RemoveObjectRoot(g_ScriptingHost.getContext(), &m_JSObject); 99 109 } … … 103 113 //------------------------------------------------------------------- 104 114 void IGUIObject::AddChild(IGUIObject *pChild) 105 115 { 106 // 116 // 107 117 // ENSURE(pChild); 108 118 109 119 pChild->SetParent(this); … … 128 138 // If anything went wrong, reverse what we did and throw 129 139 // an exception telling it never added a child 130 140 m_Children.erase( m_Children.end()-1 ); 131 141 132 142 throw; 133 143 } 134 144 } … … 166 176 // Notice if using this, the naming convention of GUIST_ should be strict. 167 177 #define TYPE(type) \ 168 178 case GUIST_##type: \ 169 m_Settings[Name].m_pSetting = new type(); \179 setting.m_pSetting = new type(); \ 170 180 break; 171 181 172 void IGUIObject::AddSetting(const EGUISettingType &Type, const CStr& Name )182 void IGUIObject::AddSetting(const EGUISettingType &Type, const CStr& Name, void * Pointer) 173 183 { 174 184 // Is name already taken? 175 185 if (m_Settings.count(Name) >= 1) 176 186 return; 177 187 178 188 // Construct, and set type 179 m_Settings[Name].m_Type = Type;180 181 switch (Type)189 SGUISetting& setting = m_Settings[Name]; 190 setting.m_Type = Type; 191 if ( Pointer != 0 ) 182 192 { 183 // Construct the setting. 184 #include "GUItypes.h" 193 setting.m_dynamic = false; 194 setting.m_pSetting = Pointer; 195 } 196 else 197 { 198 setting.m_dynamic = true; 185 199 186 default: 187 debug_warn(L"IGUIObject::AddSetting failed, type not recognized!"); 188 break; 200 switch (Type) 201 { 202 // Construct the setting. 203 #include "GUItypes.h" 204 205 default: 206 debug_warn(L"IGUIObject::AddSetting failed, type not recognized!"); 207 break; 208 } 189 209 } 190 210 } 191 211 #undef TYPE … … 205 225 } 206 226 207 227 CPos IGUIObject::GetMousePos() const 208 { 209 return ((GetGUI())?(GetGUI()->m_MousePos):CPos()); 228 { 229 return ((GetGUI())?(GetGUI()->m_MousePos):CPos()); 210 230 } 211 231 212 232 void IGUIObject::UpdateMouseOver(IGUIObject * const &pMouseOver) … … 335 355 336 356 void IGUIObject::UpdateCachedSize() 337 357 { 338 bool absolute;339 GUI<bool>::GetSetting(this, "absolute", absolute);358 // bool absolute; 359 // GUI<bool>::GetSetting(this, "absolute", absolute); 340 360 341 float aspectratio = 0.f;342 GUI<float>::GetSetting(this, "aspectratio", aspectratio);361 // float aspectratio = 0.f; 362 // GUI<float>::GetSetting(this, "aspectratio", aspectratio); 343 363 344 CClientArea ca;345 GUI<CClientArea>::GetSetting(this, "size", ca);346 364 // CClientArea ca; 365 // GUI<CClientArea>::GetSetting(this, "size", ca); 366 347 367 // If absolute="false" and the object has got a parent, 348 368 // use its cached size instead of the screen. Notice 349 369 // it must have just been cached for it to work. 350 if ( absolute == false && m_pParent && !IsRootObject())351 m_CachedActualSize = ca.GetClientArea(m_pParent->m_CachedActualSize);370 if ( m_Absolute == false && m_pParent && !IsRootObject()) 371 m_CachedActualSize = m_Size.GetClientArea(m_pParent->m_CachedActualSize); 352 372 else 353 m_CachedActualSize = ca.GetClientArea(CRect(0.f, 0.f, (float)g_xres, (float)g_yres));373 m_CachedActualSize = m_Size.GetClientArea(CRect(0.f, 0.f, (float)g_xres, (float)g_yres)); 354 374 355 375 // In a few cases, GUI objects have to resize to fill the screen 356 376 // but maintain a constant aspect ratio. 357 377 // Adjust the size to be the max possible, centered in the original size: 358 if ( aspectratio)378 if (m_AspectRatio) 359 379 { 360 if (m_CachedActualSize.GetWidth() > m_CachedActualSize.GetHeight()* aspectratio)380 if (m_CachedActualSize.GetWidth() > m_CachedActualSize.GetHeight()*m_AspectRatio) 361 381 { 362 float delta = m_CachedActualSize.GetWidth() - m_CachedActualSize.GetHeight()* aspectratio;382 float delta = m_CachedActualSize.GetWidth() - m_CachedActualSize.GetHeight()*m_AspectRatio; 363 383 m_CachedActualSize.left += delta/2.f; 364 384 m_CachedActualSize.right -= delta/2.f; 365 385 } 366 386 else 367 387 { 368 float delta = m_CachedActualSize.GetHeight() - m_CachedActualSize.GetWidth()/ aspectratio;388 float delta = m_CachedActualSize.GetHeight() - m_CachedActualSize.GetWidth()/m_AspectRatio; 369 389 m_CachedActualSize.bottom -= delta/2.f; 370 390 m_CachedActualSize.top += delta/2.f; 371 391 } … … 405 425 406 426 float IGUIObject::GetBufferedZ() const 407 427 { 408 bool absolute;409 GUI<bool>::GetSetting(this, "absolute", absolute);428 // bool absolute; 429 // GUI<bool>::GetSetting(this, "absolute", absolute); 410 430 411 float Z;412 GUI<float>::GetSetting(this, "z", Z);431 // float Z; 432 // GUI<float>::GetSetting(this, "z", Z); 413 433 414 if ( absolute)415 return Z;434 if ( m_Absolute ) 435 return m_Z; 416 436 else 417 437 { 418 438 if (GetParent()) 419 return GetParent()->GetBufferedZ() + Z;439 return GetParent()->GetBufferedZ() + m_Z; 420 440 else 421 441 { 422 442 // In philosophy, a parentless object shouldn't be able to have a relative sizing, 423 // but we'll accept it so that absolute can be used as default without a complaint. 443 // but we'll accept it so that absolute can be used as default without a complaint. 424 444 // Also, you could consider those objects children to the screen resolution. 425 return Z;445 return m_Z; 426 446 } 427 447 } 428 448 } … … 430 450 // TODO Gee: keep this function and all??? 431 451 void IGUIObject::CheckSettingsValidity() 432 452 { 433 bool hidden;434 GUI<bool>::GetSetting(this, "hidden", hidden);453 // bool hidden; 454 // GUI<bool>::GetSetting(this, "hidden", hidden); 435 455 436 456 // If we hide an object, reset many of its parts 437 if ( hidden)457 if ( m_Hidden ) 438 458 { 439 459 // Simulate that no object is hovered for this object and all its children 440 // why? because it's 460 // why? because it's 441 461 try 442 462 { 443 463 GUI<IGUIObject*>::RecurseObject(0, this, &IGUIObject::UpdateMouseOver, NULL); … … 574 594 575 595 void IGUIObject::SetFocus() 576 596 { 577 GetGUI()->m_FocusedObject = this; 597 GetGUI()->m_FocusedObject = this; 578 598 } 579 599 580 600 bool IGUIObject::IsFocused() const 581 601 { 582 return GetGUI()->m_FocusedObject == this; 602 return GetGUI()->m_FocusedObject == this; 583 603 } 584 604 585 605 bool IGUIObject::IsRootObject() const … … 589 609 590 610 PSRETURN IGUIObject::LogInvalidSettings(const CStr8 &Setting) const 591 611 { 592 LOGWARNING(L"IGUIObject: setting %hs was not found on an object", 612 LOGWARNING(L"IGUIObject: setting %hs was not found on an object", 593 613 Setting.c_str()); 594 614 return PSRETURN_GUI_InvalidSetting; 595 615 } 616 617 618 void IGUIObject::SetEnabled(const bool enabled, const bool SkipMessage) 619 { 620 m_Enabled = enabled; 621 if (!SkipMessage) 622 { 623 SGUIMessage msg(GUIM_SETTINGS_UPDATED, "enabled"); 624 HandleMessage( msg ); 625 } 626 } 627 628 void IGUIObject::SetHidden(const bool hidden, const bool SkipMessage) 629 { 630 m_Hidden = hidden; 631 if ( hidden ) 632 CInternalCGUIAccessorBase::QueryResetting(this); 633 634 if (!SkipMessage) 635 { 636 SGUIMessage msg(GUIM_SETTINGS_UPDATED, "hidden"); 637 HandleMessage( msg ); 638 } 639 } 640 641 void IGUIObject::SetAbsolute(const bool absolute, const bool SkipMessage) 642 { 643 m_Absolute = absolute; 644 if (!SkipMessage) 645 { 646 SGUIMessage msg(GUIM_SETTINGS_UPDATED, "absolute"); 647 HandleMessage( msg ); 648 } 649 } 650 651 void IGUIObject::SetGhost(const bool ghost, const bool SkipMessage) 652 { 653 m_Ghost = ghost; 654 if (!SkipMessage) 655 { 656 SGUIMessage msg(GUIM_SETTINGS_UPDATED, "ghost"); 657 HandleMessage( msg ); 658 } 659 } 660 661 void IGUIObject::SetZ(const float z, const bool SkipMessage) 662 { 663 m_Z = z; 664 if (!SkipMessage) 665 { 666 SGUIMessage msg(GUIM_SETTINGS_UPDATED, "z"); 667 HandleMessage( msg ); 668 } 669 } 670 671 void IGUIObject::SetSize(const CClientArea& size, const bool SkipMessage) 672 { 673 m_Size = size; 674 GUI<>::RecurseObject(0, this, &IGUIObject::UpdateCachedSize); 675 676 if (!SkipMessage) 677 { 678 SGUIMessage msg(GUIM_SETTINGS_UPDATED, "size"); 679 HandleMessage( msg ); 680 } 681 } 682 683 void IGUIObject::SetStyle(const CStr& style, const bool SkipMessage) 684 { 685 m_Style = style; 686 if (!SkipMessage) 687 { 688 SGUIMessage msg(GUIM_SETTINGS_UPDATED, "style"); 689 HandleMessage( msg ); 690 } 691 } 692 693 void IGUIObject::SetHotkey(const CStr& hotkey, const bool SkipMessage) 694 { 695 m_Hotkey = hotkey; 696 if (!SkipMessage) 697 { 698 SGUIMessage msg(GUIM_SETTINGS_UPDATED, "hotkey"); 699 HandleMessage( msg ); 700 } 701 } 702 703 void IGUIObject::SetAspectRatio(const float aspect_ratio, const bool SkipMessage) 704 { 705 m_AspectRatio = aspect_ratio; 706 if (!SkipMessage) 707 { 708 SGUIMessage msg(GUIM_SETTINGS_UPDATED, "aspectratio"); 709 HandleMessage( msg ); 710 } 711 } -
source/gui/CImage.cpp
31 31 //------------------------------------------------------------------- 32 32 CImage::CImage() 33 33 { 34 AddSetting(GUIST_CGUISpriteInstance, "sprite");35 AddSetting(GUIST_int, "cell_id");36 AddSetting(GUIST_CStrW, "tooltip" );37 AddSetting(GUIST_CStr, "tooltip_style" );34 AddSetting(GUIST_CGUISpriteInstance, "sprite", &m_Sprite); 35 AddSetting(GUIST_int, "cell_id", &m_CellId); 36 AddSetting(GUIST_CStrW, "tooltip", &m_Tooltip); 37 AddSetting(GUIST_CStr, "tooltip_style", &m_TooltipStyle); 38 38 } 39 39 40 40 CImage::~CImage() 41 41 { 42 42 } 43 43 44 void CImage::Draw() 44 void CImage::Draw() 45 45 { 46 46 if (GetGUI()) 47 47 { 48 48 float bz = GetBufferedZ(); 49 49 /* 50 50 CGUISpriteInstance *sprite; 51 51 int cell_id; 52 52 GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite", sprite); 53 53 GUI<int>::GetSetting(this, "cell_id", cell_id); 54 55 GetGUI()->DrawSprite( *sprite, cell_id, bz, m_CachedActualSize);54 */ 55 GetGUI()->DrawSprite(m_Sprite, m_CellId, bz, m_CachedActualSize); 56 56 } 57 57 } -
source/gui/CCheckBox.cpp
32 32 //------------------------------------------------------------------- 33 33 CCheckBox::CCheckBox() 34 34 { 35 AddSetting(GUIST_float, "buffer_zone"); 36 AddSetting(GUIST_CGUIString, "caption"); 37 AddSetting(GUIST_int, "cell_id"); 38 AddSetting(GUIST_bool, "checked"); 39 AddSetting(GUIST_CStrW, "font"); 40 AddSetting(GUIST_CGUISpriteInstance, "sprite"); 41 AddSetting(GUIST_CGUISpriteInstance, "sprite_over"); 42 AddSetting(GUIST_CGUISpriteInstance, "sprite_pressed"); 43 AddSetting(GUIST_CGUISpriteInstance, "sprite_disabled"); 44 AddSetting(GUIST_CGUISpriteInstance, "sprite2"); 45 AddSetting(GUIST_CGUISpriteInstance, "sprite2_over"); 46 AddSetting(GUIST_CGUISpriteInstance, "sprite2_pressed"); 47 AddSetting(GUIST_CGUISpriteInstance, "sprite2_disabled"); 48 AddSetting(GUIST_float, "square_side"); 49 AddSetting(GUIST_CColor, "textcolor"); 50 AddSetting(GUIST_CColor, "textcolor_over"); 51 AddSetting(GUIST_CColor, "textcolor_pressed"); 52 AddSetting(GUIST_CColor, "textcolor_disabled"); 53 AddSetting(GUIST_CStrW, "tooltip"); 54 AddSetting(GUIST_CStr, "tooltip_style"); 35 AddSetting(GUIST_float, "buffer_zone", &m_BufferZone); 36 AddSetting(GUIST_CGUIString, "caption", &m_Caption); 37 AddSetting(GUIST_int, "cell_id", &m_CellId); 38 AddSetting(GUIST_CStrW, "font", &m_Font); 39 AddSetting(GUIST_bool, "checked", &m_Checked); 40 AddSetting(GUIST_CGUISpriteInstance, "sprite", &m_Sprite); 41 AddSetting(GUIST_CGUISpriteInstance, "sprite_over", &m_SpriteOver); 42 AddSetting(GUIST_CGUISpriteInstance, "sprite_pressed", &m_SpritePressed); 43 AddSetting(GUIST_CGUISpriteInstance, "sprite_disabled", &m_SpriteDisabled); 44 AddSetting(GUIST_CGUISpriteInstance, "sprite2", &m_Sprite2); 45 AddSetting(GUIST_CGUISpriteInstance, "sprite2_over", &m_SpriteOver2); 46 AddSetting(GUIST_CGUISpriteInstance, "sprite2_pressed", &m_SpritePressed2); 47 AddSetting(GUIST_CGUISpriteInstance, "sprite2_disabled", &m_SpriteDisabled2); 48 AddSetting(GUIST_float, "square_side", &m_SquareSide); 49 AddSetting(GUIST_CStrW, "tooltip", &m_Tooltip); 50 AddSetting(GUIST_CStr, "tooltip_style", &m_TooltipStyle); 55 51 52 m_BufferZone = 0.f; 53 m_Font = L"default"; 54 m_Checked = false; 55 56 56 // Add text 57 57 AddText(new SGUIText()); 58 58 } … … 68 68 69 69 ENSURE(m_GeneratedTexts.size()==1); 70 70 71 CStrW font; 72 if (GUI<CStrW>::GetSetting(this, "font", font) != PSRETURN_OK || font.empty()) 73 // Use the default if none is specified 74 // TODO Gee: (2004-08-14) Default should not be hard-coded, but be in styles! 75 font = L"default"; 76 77 float square_side; 78 GUI<float>::GetSetting(this, "square_side", square_side); 79 80 CGUIString caption; 81 GUI<CGUIString>::GetSetting(this, "caption", caption); 82 83 float buffer_zone=0.f; 84 GUI<float>::GetSetting(this, "buffer_zone", buffer_zone); 85 *m_GeneratedTexts[0] = GetGUI()->GenerateText(caption, font, m_CachedActualSize.GetWidth()-square_side, 0.f, this); 71 *m_GeneratedTexts[0] = GetGUI()->GenerateText(m_Caption, m_Font, m_CachedActualSize.GetWidth()- m_SquareSide, 0.f, this); 86 72 } 87 73 88 74 void CCheckBox::HandleMessage(SGUIMessage &Message) … … 100 86 GUI<bool>::GetSetting(this, "checked", checked); 101 87 checked = !checked; 102 88 GUI<bool>::SetSetting(this, "checked", checked); 103 89 104 90 } break; 105 91 106 92 default: … … 108 94 } 109 95 } 110 96 111 void CCheckBox::Draw() 97 void CCheckBox::Draw() 112 98 { 113 99 ////////// Gee: janwas, this is just temp to see it 114 100 glDisable(GL_TEXTURE_2D); 115 101 ////////// 116 102 117 float square_side, buffer_zone;118 CStrW font_name;119 bool checked;120 int cell_id;121 GUI<float>::GetSetting(this, "square_side", square_side);122 GUI<float>::GetSetting(this, "buffer_zone", buffer_zone);123 GUI<CStrW>::GetSetting(this, "font", font_name);124 GUI<bool>::GetSetting(this, "checked", checked);125 GUI<int>::GetSetting(this, "cell_id", cell_id);126 127 103 // Get line height 128 CFont font ( font_name);104 CFont font (m_Font); 129 105 float line_height = (float)font.GetHeight(); 130 106 131 107 float bz = GetBufferedZ(); … … 134 110 CRect rect; 135 111 136 112 rect.left = m_CachedActualSize.left; 137 rect.right = rect.left + square_side;113 rect.right = rect.left + m_SquareSide; 138 114 139 if ( square_side >= line_height)115 if (m_SquareSide >= line_height) 140 116 rect.top = m_CachedActualSize.top; 141 117 else 142 rect.top = m_CachedActualSize.top + line_height/2.f - square_side/2.f;118 rect.top = m_CachedActualSize.top + line_height/2.f - m_SquareSide/2.f; 143 119 144 rect.bottom = rect.top + square_side;120 rect.bottom = rect.top + m_SquareSide; 145 121 146 CGUISpriteInstance *sprite, *sprite_over, *sprite_pressed, *sprite_disabled; 147 148 if (checked) 122 if (m_Checked) 149 123 { 150 GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2", sprite); 151 GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_over", sprite_over); 152 GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_pressed", sprite_pressed); 153 GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_disabled", sprite_disabled); 124 DrawButton(rect, 125 bz, 126 m_Sprite2, 127 m_SpriteOver2, 128 m_SpritePressed2, 129 m_SpriteDisabled2, 130 m_CellId); 154 131 } 155 132 else 156 133 { 157 GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite", sprite); 158 GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_over", sprite_over); 159 GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_pressed", sprite_pressed); 160 GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_disabled", sprite_disabled); 134 DrawButton(rect, 135 bz, 136 m_Sprite, 137 m_SpriteOver, 138 m_SpritePressed, 139 m_SpriteDisabled, 140 m_CellId); 161 141 } 162 163 DrawButton(rect,164 bz,165 *sprite,166 *sprite_over,167 *sprite_pressed,168 *sprite_disabled,169 cell_id);170 171 142 CColor color = ChooseColor(); 172 143 173 CPos text_pos(m_CachedActualSize.left + square_side + buffer_zone, m_CachedActualSize.top);144 CPos text_pos(m_CachedActualSize.left + m_SquareSide + m_BufferZone, m_CachedActualSize.top); 174 145 175 if ( square_side > line_height)176 text_pos.y += square_side/2.f - line_height/2.f;146 if (m_SquareSide > line_height) 147 text_pos.y += m_SquareSide/2.f - line_height/2.f; 177 148 178 149 IGUITextOwner::Draw(0, color, text_pos, bz+0.1f, m_CachedActualSize); 179 150 } -
source/gui/CText.h
53 53 54 54 /** 55 55 * Text field that just displays static text. 56 * 56 * 57 57 * @see IGUIObject 58 58 */ 59 59 class CText : public IGUIScrollBarOwner, public IGUITextOwner … … 95 95 * Placement of text. Ignored when scrollbars are active. 96 96 */ 97 97 CPos m_TextPos; 98 private: 99 float m_BufferZone; 100 CGUIString m_Caption; 101 int m_CellId; 102 bool m_Clip; 103 CStrW m_Font; 104 bool m_Scrollbar; 105 CStr m_ScrollbarStyle; 106 bool m_ScrollBottom; 107 CGUISpriteInstance m_Sprite; 108 CColor m_TextColor; 109 CStrW m_Tooltip; 110 CStr m_TooltipStyle; 111 112 CStrW m_IconTooltip; 113 CStr m_IconTooltipStyle; 114 98 115 }; 99 116 100 117 #endif -
source/gui/CTooltip.cpp
26 26 27 27 CTooltip::CTooltip() 28 28 { 29 // If the tooltip is an object by itself: 30 AddSetting(GUIST_float, "buffer_zone"); 31 AddSetting(GUIST_CGUIString, "caption"); 32 AddSetting(GUIST_CStrW, "font"); 33 AddSetting(GUIST_CGUISpriteInstance, "sprite"); 34 AddSetting(GUIST_int, "delay"); 35 AddSetting(GUIST_CColor, "textcolor"); 36 AddSetting(GUIST_float, "maxwidth"); 37 AddSetting(GUIST_CPos, "offset"); 38 AddSetting(GUIST_EVAlign, "anchor"); 29 AddSetting(GUIST_float, "buffer_zone", &m_BufferZone); 30 AddSetting(GUIST_CGUIString, "caption", &m_Caption); 31 AddSetting(GUIST_CStrW, "font", &m_Font); 32 AddSetting(GUIST_CGUISpriteInstance, "sprite", &m_Sprite); 33 AddSetting(GUIST_CColor, "textcolor", &m_TextColor); 34 AddSetting(GUIST_int, "delay", &m_Delay); 35 AddSetting(GUIST_float, "maxwidth", &m_MaxWidth); 36 AddSetting(GUIST_CPos, "offset", &m_Offset); 37 AddSetting(GUIST_EVAlign, "anchor", &m_Anchor); 39 38 40 39 // If the tooltip is just a reference to another object: 41 AddSetting(GUIST_CStr, "use_object" );42 AddSetting(GUIST_bool, "hide_object" );40 AddSetting(GUIST_CStr, "use_object", &m_UseObject); 41 AddSetting(GUIST_bool, "hide_object", &m_HideObject); 43 42 44 43 // Private settings: 45 AddSetting(GUIST_CPos, "_mousepos" );44 AddSetting(GUIST_CPos, "_mousepos", &m_MousePos); 46 45 46 m_BufferZone = 0.f; 47 m_Font = L"default"; 48 47 49 // Defaults 48 50 GUI<int>::SetSetting(this, "delay", 500); 49 51 GUI<EVAlign>::SetSetting(this, "anchor", EVAlign_Bottom); … … 64 66 65 67 ENSURE(m_GeneratedTexts.size()==1); 66 68 67 CStrW font; 68 if (GUI<CStrW>::GetSetting(this, "font", font) != PSRETURN_OK || font.empty()) 69 font = L"default"; 69 *m_GeneratedTexts[0] = GetGUI()->GenerateText(m_Caption, m_Font, m_MaxWidth, m_BufferZone, this); 70 70 71 float buffer_zone = 0.f;72 GUI<float>::GetSetting(this, "buffer_zone", buffer_zone);73 74 CGUIString caption;75 GUI<CGUIString>::GetSetting(this, "caption", caption);76 77 float max_width = 0.f;78 GUI<float>::GetSetting(this, "maxwidth", max_width);79 80 *m_GeneratedTexts[0] = GetGUI()->GenerateText(caption, font, max_width, buffer_zone, this);81 82 83 71 // Position the tooltip relative to the mouse: 84 72 85 CPos mousepos, offset;86 EVAlign anchor;87 GUI<CPos>::GetSetting(this, "_mousepos", mousepos);88 GUI<CPos>::GetSetting(this, "offset", offset);89 GUI<EVAlign>::GetSetting(this, "anchor", anchor);90 91 73 // TODO: Calculate the actual width of the wrapped text and use that. 92 74 // (m_Size.cx is >max_width if the text wraps, which is not helpful) 93 float textwidth = std::min(m_GeneratedTexts[0]->m_Size.cx, (float)max_width);75 float textwidth = std::min(m_GeneratedTexts[0]->m_Size.cx, m_MaxWidth); 94 76 float textheight = m_GeneratedTexts[0]->m_Size.cy; 95 77 96 78 CClientArea size; 97 size.pixel.left = m ousepos.x + offset.x;79 size.pixel.left = m_MousePos.x + m_Offset.x; 98 80 size.pixel.right = size.pixel.left + textwidth; 99 switch ( anchor)81 switch (m_Anchor) 100 82 { 101 83 case EVAlign_Top: 102 size.pixel.top = m ousepos.y + offset.y;84 size.pixel.top = m_MousePos.y + m_Offset.y; 103 85 size.pixel.bottom = size.pixel.top + textheight; 104 86 break; 105 87 case EVAlign_Bottom: 106 size.pixel.bottom = m ousepos.y + offset.y;88 size.pixel.bottom = m_MousePos.y + m_Offset.y; 107 89 size.pixel.top = size.pixel.bottom - textheight; 108 90 break; 109 91 case EVAlign_Center: 110 size.pixel.top = m ousepos.y + offset.y - textheight/2.f;92 size.pixel.top = m_MousePos.y + m_Offset.y - textheight/2.f; 111 93 size.pixel.bottom = size.pixel.top + textwidth; 112 94 break; 113 95 default: … … 129 111 size.pixel.right -= size.pixel.left, size.pixel.left = 0.f; 130 112 else if (size.pixel.right > screenw) 131 113 size.pixel.left -= (size.pixel.right-screenw), size.pixel.right = screenw; 132 133 GUI<CClientArea>::SetSetting(this, "size", size); 114 115 // GUI<CClientArea>::SetSetting(this, "size", size); 116 SetSize(size); 134 117 } 135 118 136 119 void CTooltip::HandleMessage(SGUIMessage &Message) … … 138 121 IGUITextOwner::HandleMessage(Message); 139 122 } 140 123 141 void CTooltip::Draw() 124 void CTooltip::Draw() 142 125 { 143 float z = 900.f; // TODO: Find a nicer way of putting the tooltip on top of everything else144 145 126 if (GetGUI()) 146 127 { 147 CGUISpriteInstance *sprite; 148 GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite", sprite); 128 float z = 900.f; // TODO: Find a nicer way of putting the tooltip on top of everything else 149 129 150 130 // Normally IGUITextOwner will handle this updating but since SetupText can modify the position 151 131 // we need to call it now *before* we do the rest of the drawing … … 155 135 m_GeneratedTextsValid = true; 156 136 } 157 137 158 GetGUI()->DrawSprite( *sprite, 0, z, m_CachedActualSize);138 GetGUI()->DrawSprite(m_Sprite, 0, z, m_CachedActualSize); 159 139 160 CColor color;161 GUI<CColor>::GetSetting(this, "textcolor", color);162 163 140 // Draw text 164 IGUITextOwner::Draw(0, color, m_CachedActualSize.TopLeft(), z+0.1f);141 IGUITextOwner::Draw(0, m_TextColor, m_CachedActualSize.TopLeft(), z+0.1f); 165 142 } 166 143 }