Ticket #885: faster-0ad-gui.patch

File faster-0ad-gui.patch, 116.0 KB (added by kromxp, 13 years ago)

gui patch

  • source/gui/GUITooltip.cpp

     
    168168
    169169        // Unhide the object. (If it had use_object and hide_object="true",
    170170        // 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);
    172173    }
    173174    else
    174175    {
    175176        // Unhide the object
    176         GUI<bool>::SetSetting(usedobj, "hidden", false);
     177//      GUI<bool>::SetSetting(usedobj, "hidden", false);
     178        usedobj->SetHidden(false);
    177179
    178180        // Store mouse position inside the CTooltip
    179181        if (GUI<CPos>::SetSetting(usedobj, "_mousepos", pos) != PSRETURN_OK)
     
    241243
    242244        // If hide_object was enabled, hide it
    243245        if (hideobject)
    244             GUI<bool>::SetSetting(usedobj, "hidden", true);
     246        {
     247//          GUI<bool>::SetSetting(usedobj, "hidden", true);
     248            usedobj->SetHidden(true);
     249        }
     250           
    245251    }
    246252    else
    247253    {
    248         GUI<bool>::SetSetting(tooltipobj, "hidden", true);
     254//      GUI<bool>::SetSetting(tooltipobj, "hidden", true);
     255        tooltipobj->SetHidden(true);
    249256    }
    250257
    251258}
  • source/gui/CInput.cpp

     
    4141//-------------------------------------------------------------------
    4242CInput::CInput() : m_iBufferPos(-1), m_iBufferPos_Tail(-1), m_SelectingText(false), m_HorizontalScroll(0.f)
    4343{
    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);
    5858
     59    m_BufferZone = 0.f;
     60    m_Font = L"";
     61
    5962    // Add scroll-bar
    6063    CGUIScrollBarVertical * bar = new CGUIScrollBarVertical();
    6164    bar->SetRightAligned(true);
     
    8083        // Since the GUI framework doesn't handle to set settings
    8184        //  in Unicode (CStrW), we'll simply retrieve the actual
    8285        //  pointer and edit that.
    83         CStrW *pCaption = (CStrW*)m_Settings["caption"].m_pSetting;
    8486        bool shiftKeyPressed = g_keys[SDLK_RSHIFT] || g_keys[SDLK_LSHIFT];
    8587
    8688        int szChar = ev->ev.key.keysym.sym;
     
    102104                {
    103105                    m_iBufferPos_Tail = -1;
    104106
    105                     if (pCaption->empty() || m_iBufferPos == 0)
     107                    if (m_Caption.empty() || m_iBufferPos == 0)
    106108                    {
    107109                        break;
    108110                    }
    109111                    else
    110112                    {
    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);
    113115                        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 );
    116118
    117119                        --m_iBufferPos;
    118                    
     120
    119121                        UpdateText(m_iBufferPos, m_iBufferPos+1, m_iBufferPos);
    120122                    }
    121123                }
     
    132134                }
    133135                else
    134136                {
    135                     if (pCaption->empty() || m_iBufferPos == (int)pCaption->length())
     137                    if (m_Caption.empty() || m_iBufferPos == (int)m_Caption.length())
    136138                    {
    137139                        break;
    138140                    }
    139141                    else
    140142                    {
    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) );
    143145
    144146                        UpdateText(m_iBufferPos, m_iBufferPos+1, m_iBufferPos);
    145147                    }
     
    180182                    m_iBufferPos_Tail = m_iBufferPos;
    181183                }
    182184
    183                 m_iBufferPos = (long) pCaption->length();
     185                m_iBufferPos = (long) m_Caption.length();
    184186                m_WantedX=0.0f;
    185187
    186188                UpdateAutoScroll();
     
    222224                        m_iBufferPos_Tail = m_iBufferPos;
    223225                    }
    224226
    225                     if (m_iBufferPos > 0) 
     227                    if (m_iBufferPos > 0)
    226228                        --m_iBufferPos;
    227229                }
    228230                else
     
    250252                        m_iBufferPos_Tail = m_iBufferPos;
    251253                    }
    252254
    253                     if (m_iBufferPos < (int)pCaption->length())
     255                    if (m_iBufferPos < (int)m_Caption.length())
    254256                        ++m_iBufferPos;
    255257                }
    256258                else
     
    259261                        m_iBufferPos = m_iBufferPos_Tail;
    260262
    261263                    m_iBufferPos_Tail = -1;
    262                 }           
     264                }
    263265
    264266                UpdateAutoScroll();
    265267                break;
     
    301303                    if (m_iBufferPos >= current->m_ListStart &&
    302304                        m_iBufferPos <= current->m_ListStart+(int)current->m_ListOfX.size())
    303305                        break;
    304                    
     306
    305307                    ++current;
    306308                }
    307309
     
    324326                    m_iBufferPos = current->m_ListStart + GetXTextPosition(current, pos_x, m_WantedX);
    325327                }
    326328                // else we can't move up
    327                
     329
    328330                UpdateAutoScroll();
    329331            }
    330332                break;
     
    346348                    if (m_iBufferPos >= current->m_ListStart &&
    347349                        m_iBufferPos <= current->m_ListStart+(int)current->m_ListOfX.size())
    348350                        break;
    349                    
     351
    350352                    ++current;
    351353                }
    352354
     
    387389                // 'Return' should do a Press event for single liners (e.g. submitting forms)
    388390                //  otherwise a '\n' character will be added.
    389391                {
    390                 bool multiline;
    391                 GUI<bool>::GetSetting(this, "multiline", multiline);
    392                 if (!multiline)
     392                if (!m_Multiline)
    393393                {
    394394                    SendEvent(GUIM_PRESSED, "press");
    395395                    break;
     
    404404                    return IN_PASS; // Important, because we didn't use any key
    405405
    406406                // 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)
    410408                    break;
    411409
    412410                m_WantedX=0.0f;
     
    415413                    DeleteCurSelection();
    416414                m_iBufferPos_Tail = -1;
    417415
    418                 if (m_iBufferPos == (int)pCaption->length())
    419                     *pCaption += cooked;
     416                if (m_iBufferPos == (int)m_Caption.length())
     417                    m_Caption += cooked;
    420418                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);
    423421
    424422                UpdateText(m_iBufferPos, m_iBufferPos, m_iBufferPos+1);
    425423
     
    439437
    440438InReaction CInput::ManuallyHandleHotkeyEvent(const SDL_Event_* ev)
    441439{
    442     CStrW *pCaption = (CStrW*)m_Settings["caption"].m_pSetting;
    443440    bool shiftKeyPressed = g_keys[SDLK_RSHIFT] || g_keys[SDLK_LSHIFT];
    444441
    445442    std::string hotkey = static_cast<const char*>(ev->ev.user.data1);
     
    455452                DeleteCurSelection();
    456453            }
    457454
    458             if (m_iBufferPos == (int)pCaption->length())
    459                 *pCaption += text;
     455            if (m_iBufferPos == (int)m_Caption.length())
     456                m_Caption += text;
    460457            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);
    463460
    464461            UpdateText(m_iBufferPos, m_iBufferPos, m_iBufferPos+1);
    465462
     
    490487                virtualTo = m_iBufferPos;
    491488            }
    492489
    493             CStrW text = (pCaption->Left(virtualTo)).Right(virtualTo - virtualFrom);
     490            CStrW text = (m_Caption.Left(virtualTo)).Right(virtualTo - virtualFrom);
    494491
    495492            sys_clipboard_set(&text[0]);
    496493
     
    510507        {
    511508            DeleteCurSelection();
    512509        }
    513         if (!pCaption->empty() && !m_iBufferPos == 0)
     510        if (!m_Caption.empty() && !m_iBufferPos == 0)
    514511        {
    515512            m_iBufferPos_Tail = m_iBufferPos;
    516             CStrW searchString = pCaption->Left( m_iBufferPos );
     513            CStrW searchString = m_Caption.Left( m_iBufferPos );
    517514
    518515            // If we are starting in whitespace, adjust position until we get a non whitespace
    519516            while (m_iBufferPos > 0)
     
    523520
    524521                m_iBufferPos--;
    525522            }
    526                
     523
    527524            // If we end up on a puctuation char we just delete it (treat punct like a word)
    528525            if (iswpunct(searchString[m_iBufferPos - 1]))
    529526                m_iBufferPos--;
     
    542539            DeleteCurSelection();
    543540        }
    544541        return IN_HANDLED;
    545     } 
     542    }
    546543    else if (hotkey == "text.delete.right")
    547544    {
    548545        m_WantedX=0.0f;
     
    551548        {
    552549            DeleteCurSelection();
    553550        }
    554         if (!pCaption->empty() && m_iBufferPos < (int)pCaption->length())
     551        if (!m_Caption.empty() && m_iBufferPos < (int)m_Caption.length())
    555552        {
    556553            // Delete the word to the right of the cursor
    557554            m_iBufferPos_Tail = m_iBufferPos;
    558555
    559556            // Delete chars to the right unit we hit whitespace
    560             while (++m_iBufferPos < (int)pCaption->length())
     557            while (++m_iBufferPos < (int)m_Caption.length())
    561558            {
    562                 if (iswspace((*pCaption)[m_iBufferPos]) || iswpunct((*pCaption)[m_iBufferPos]))
     559                if (iswspace(m_Caption[m_iBufferPos]) || iswpunct(m_Caption[m_iBufferPos]))
    563560                    break;
    564561            }
    565562
    566563            // Eliminate any whitespace behind the word we just deleted
    567             while (m_iBufferPos < (int)pCaption->length())
     564            while (m_iBufferPos < (int)m_Caption.length())
    568565            {
    569                 if (!iswspace((*pCaption)[m_iBufferPos]))
     566                if (!iswspace(m_Caption[m_iBufferPos]))
    570567                    break;
    571568
    572569                m_iBufferPos++;
    573570            }
    574571            DeleteCurSelection();
    575572        }
    576         return IN_HANDLED;         
     573        return IN_HANDLED;
    577574    }
    578575    else if (hotkey == "text.move.left")
    579576    {
    580577        m_WantedX=0.0f;
    581                
     578
    582579        if (shiftKeyPressed || !SelectingText())
    583580        {
    584581            if (!shiftKeyPressed)
     
    590587                m_iBufferPos_Tail = m_iBufferPos;
    591588            }
    592589
    593             if (!pCaption->empty() && !m_iBufferPos == 0)
     590            if (!m_Caption.empty() && !m_iBufferPos == 0)
    594591            {
    595                 CStrW searchString = pCaption->Left( m_iBufferPos );
     592                CStrW searchString = m_Caption.Left( m_iBufferPos );
    596593
    597594                // If we are starting in whitespace, adjust position until we get a non whitespace
    598595                while (m_iBufferPos > 0)
     
    602599
    603600                    m_iBufferPos--;
    604601                }
    605                
     602
    606603                // If we end up on a puctuation char we just select it (treat punct like a word)
    607604                if (iswpunct(searchString[m_iBufferPos - 1]))
    608605                    m_iBufferPos--;
     
    646643                m_iBufferPos_Tail = m_iBufferPos;
    647644            }
    648645
    649             if (!pCaption->empty() && m_iBufferPos < (int)pCaption->length())
     646            if (!m_Caption.empty() && m_iBufferPos < (int)m_Caption.length())
    650647            {
    651                 CStrW searchString = *pCaption;
    652 
    653648                // Select chars to the right until we hit whitespace
    654                 while (++m_iBufferPos < (int)pCaption->length())
     649                while (++m_iBufferPos < (int)m_Caption.length())
    655650                {
    656                     if (iswspace((*pCaption)[m_iBufferPos]) || iswpunct((*pCaption)[m_iBufferPos]))
     651                    if (iswspace(m_Caption[m_iBufferPos]) || iswpunct(m_Caption[m_iBufferPos]))
    657652                        break;
    658653                }
    659654
    660655                // 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())
    662657                {
    663                     if (!iswspace((*pCaption)[m_iBufferPos]))
     658                    if (!iswspace(m_Caption[m_iBufferPos]))
    664659                        break;
    665660
    666661                    m_iBufferPos++;
     
    673668                m_iBufferPos = m_iBufferPos_Tail;
    674669
    675670            m_iBufferPos_Tail = -1;
    676         }           
     671        }
    677672
    678673        UpdateAutoScroll();
    679674
     
    695690    {
    696691    case GUIM_SETTINGS_UPDATED:
    697692        {
    698         bool scrollbar;
    699         GUI<bool>::GetSetting(this, "scrollbar", scrollbar);
    700 
    701693        // Update scroll-bar
    702694        // 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") ||
    705697             Message.value == CStr("z") ||
    706698             Message.value == CStr("absolute")))
    707         {       
     699        {
    708700            GetScrollBar(0).SetX(m_CachedActualSize.right);
    709701            GetScrollBar(0).SetY(m_CachedActualSize.top);
    710702            GetScrollBar(0).SetZ(GetBufferedZ());
     
    714706        // Update scrollbar
    715707        if (Message.value == CStr("scrollbar_style"))
    716708        {
    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);
    721710        }
    722711
    723         if (Message.value == CStr("size") || 
     712        if (Message.value == CStr("size") ||
    724713            Message.value == CStr("z") ||
    725             Message.value == CStr("font") || 
     714            Message.value == CStr("font") ||
    726715            Message.value == CStr("absolute") ||
    727716            Message.value == CStr("caption") ||
    728717            Message.value == CStr("scrollbar") ||
     
    733722
    734723        if (Message.value == CStr("multiline"))
    735724        {
    736             bool multiline;
    737             GUI<bool>::GetSetting(this, "multiline", multiline);
    738 
    739             if (multiline == false)
     725            if (!m_Multiline)
    740726            {
    741727                GetScrollBar(0).SetLength(0.f);
    742728            }
     
    747733
    748734            UpdateText();
    749735        }
    750        
     736
    751737        }break;
    752738
    753739    case GUIM_MOUSE_PRESS_LEFT:
    754740        // Check if we're selecting the scrollbar:
    755741        {
    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)
    761743        {
    762744            if (GetMousePos().x > m_CachedActualSize.right - GetScrollBar(0).GetStyle()->m_Width)
    763745                break;
     
    778760        }
    779761
    780762        m_SelectingText = true;
    781        
     763
    782764        UpdateAutoScroll();
    783765
    784766        // If we immediately release the button it will just be seen as a click
     
    788770
    789771    case GUIM_MOUSE_DBLCLICK_LEFT:
    790772        {
    791             CStrW *pCaption = (CStrW*)m_Settings["caption"].m_pSetting;
    792773            m_iBufferPos = m_iBufferPos_Tail = GetMouseHoveringTextPosition();
    793774
    794775            // See if we are clicking over whitespace
    795             if (iswspace((*pCaption)[m_iBufferPos]))
     776            if (iswspace(m_Caption[m_iBufferPos]))
    796777            {
    797778                // 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])))
    800781                {
    801782                    //
    802783                    // We are clicking in an area with more than one whitespace character
     
    806787                    // skip the whitespace
    807788                    while (m_iBufferPos > 0)
    808789                    {
    809                         if (!iswspace((*pCaption)[m_iBufferPos - 1]))
     790                        if (!iswspace(m_Caption[m_iBufferPos - 1]))
    810791                            break;
    811792
    812793                        m_iBufferPos--;
     
    814795                    // now go until we hit white space or punctuation
    815796                    while (m_iBufferPos > 0)
    816797                    {
    817                         if (iswspace((*pCaption)[m_iBufferPos - 1]))
     798                        if (iswspace(m_Caption[m_iBufferPos - 1]))
    818799                            break;
    819800
    820801                        m_iBufferPos--;
    821802
    822                         if (iswpunct((*pCaption)[m_iBufferPos]))
     803                        if (iswpunct(m_Caption[m_iBufferPos]))
    823804                            break;
    824805                    }
    825806
    826807                    // [2] Then the right
    827808                    // 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())
    829810                    {
    830                         if (!iswspace((*pCaption)[m_iBufferPos_Tail]))
     811                        if (!iswspace(m_Caption[m_iBufferPos_Tail]))
    831812                            break;
    832813                    }
    833814                    // 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())
    835816                    {
    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]))
    837818                            break;
    838819                    }
    839820                }
    840821                else
    841822                {
    842823                    // 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())
    844825                    {
    845                         if (!iswspace((*pCaption)[m_iBufferPos_Tail]))
     826                        if (!iswspace(m_Caption[m_iBufferPos_Tail]))
    846827                            break;
    847828                    }
    848829
     
    850831                    m_iBufferPos = m_iBufferPos_Tail;
    851832
    852833                    // 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())
    854835                    {
    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]))
    856837                            break;
    857838                    }
    858839                }
     
    863844                // go until we hit white space or punctuation
    864845                while (m_iBufferPos > 0)
    865846                {
    866                     if (iswspace((*pCaption)[m_iBufferPos - 1]))
     847                    if (iswspace(m_Caption[m_iBufferPos - 1]))
    867848                        break;
    868849
    869850                    m_iBufferPos--;
    870851
    871                     if (iswpunct((*pCaption)[m_iBufferPos]))
     852                    if (iswpunct(m_Caption[m_iBufferPos]))
    872853                        break;
    873854                }
    874855                // 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())
    876857                {
    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]))
    878859                        break;
    879860                }
    880861            }
     
    929910        GetScrollBar(0).SetZ( GetBufferedZ() );
    930911        GetScrollBar(0).SetLength( m_CachedActualSize.bottom - m_CachedActualSize.top );
    931912
    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 );
    935914
    936915        UpdateText();
    937916        }
     
    939918
    940919    case GUIM_GOT_FOCUS:
    941920        m_iBufferPos = 0;
    942        
     921
    943922        break;
    944923
    945924    case GUIM_LOST_FOCUS:
     
    959938
    960939    IGUIObject::UpdateCachedSize();
    961940
    962     bool scrollbar;
    963     GUI<bool>::GetSetting(this, "scrollbar", scrollbar);
    964     if (scrollbar)
     941    if (m_Scrollbar)
    965942    {
    966943        GetScrollBar(0).SetX(m_CachedActualSize.right);
    967944        GetScrollBar(0).SetY(m_CachedActualSize.top);
     
    972949
    973950void CInput::Draw()
    974951{
    975     float bz = GetBufferedZ();
    976 
    977952    // 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)
    986954    {
    987955        // Draw scrollbar
    988956        IGUIScrollBarOwner::Draw();
    989957    }
    990958
    991959    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();
    1003962
    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);
    1011964
    1012         GetGUI()->DrawSprite(*sprite, cell_id, bz, m_CachedActualSize);
    1013 
    1014965        float scroll=0.f;
    1015         if (scrollbar && multiline)
     966        if (m_Scrollbar && m_Multiline)
    1016967        {
    1017968            scroll = GetScrollBar(0).GetPos();
    1018969        }
     
    1026977
    1027978        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    1028979
    1029         CFont font(font_name);
     980        CFont font(m_Font);
    1030981        font.Bind();
    1031982
    1032983        glPushMatrix();
     
    1036987
    1037988        // First we'll figure out the clipping area, which is the cached actual size
    1038989        //  substracted by an optional scrollbar
    1039         if (scrollbar)
     990        if (m_Scrollbar)
    1040991        {
    1041992            scroll = GetScrollBar(0).GetPos();
    1042993
     
    10521003
    10531004        if (cliparea != CRect())
    10541005        {
    1055             double eq[4][4] = 
    1056             { 
     1006            double eq[4][4] =
     1007            {
    10571008                {  0.0,  1.0, 0.0, -cliparea.top },
    10581009                {  1.0,  0.0, 0.0, -cliparea.left },
    10591010                {  0.0, -1.0, 0.0, cliparea.bottom },
     
    10871038
    10881039        // Set the Z to somewhat more, so we can draw a selected area between the
    10891040        //  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
    10931044        //glColor4f(1.f, 1.f, 1.f, 1.f);
    1094        
     1045
    10951046        // U+FE33: PRESENTATION FORM FOR VERTICAL LOW LINE
    10961047        // (sort of like a | which is aligned to the left of most characters)
    10971048
    1098         float buffered_y = -scroll+buffer_zone;
     1049        float buffered_y = -scroll+m_BufferZone;
    10991050
    11001051        // When selecting larger areas, we need to draw a rectangle box
    11011052        //  around it, and this is to keep track of where the box
     
    11431094                it != m_CharacterPositions.end();
    11441095                ++it, buffered_y += ls, x_pointer = 0.f)
    11451096            {
    1146                 if (multiline)
     1097                if (m_Multiline)
    11471098                {
    11481099                    if (buffered_y > m_CachedActualSize.GetHeight())
    11491100                        break;
     
    11561107                    if (it->m_ListStart + i == VirtualFrom)
    11571108                    {
    11581109                        // 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.
    11601111                        //  we need to go along with the iteration, and
    11611112                        //  make a mark where the box started:
    11621113                        drawing_box = true; // will turn false when finally rendered.
     
    11901141
    11911142                        CRect rect;
    11921143                        // Set 'rect' depending on if it's a multiline control, or a one-line control
    1193                         if (multiline)
     1144                        if (m_Multiline)
    11941145                        {
    1195                             rect = CRect(m_CachedActualSize.left+box_x+buffer_zone,
     1146                            rect = CRect(m_CachedActualSize.left+box_x+m_BufferZone,
    11961147                                       m_CachedActualSize.top+buffered_y+(h-ls)/2,
    1197                                        m_CachedActualSize.left+x_pointer+buffer_zone,
     1148                                       m_CachedActualSize.left+x_pointer+m_BufferZone,
    11981149                                       m_CachedActualSize.top+buffered_y+(h+ls)/2);
    11991150
    12001151                            if (rect.bottom < m_CachedActualSize.top)
     
    12081159                        }
    12091160                        else // if one-line
    12101161                        {
    1211                             rect = CRect(m_CachedActualSize.left+box_x+buffer_zone-m_HorizontalScroll,
     1162                            rect = CRect(m_CachedActualSize.left+box_x+m_BufferZone-m_HorizontalScroll,
    12121163                                       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,
    12141165                                       m_CachedActualSize.top+buffered_y+(h+ls)/2);
    12151166
    12161167                            if (rect.left < m_CachedActualSize.left)
     
    12251176                        glEnable(GL_BLEND);
    12261177                        glDisable(GL_TEXTURE_2D);
    12271178
    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);
    12301181
    12311182                        // Blend can have been reset
    12321183                        glEnable(GL_BLEND);
     
    12371188                    }
    12381189
    12391190                    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]);
    12411192                }
    12421193
    12431194                if (done)
     
    12551206
    12561207        // Reset some from previous run
    12571208        buffered_y = -scroll;
    1258        
     1209
    12591210        // 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);
    12611212
    12621213        bool using_selected_color = false;
    1263        
     1214
    12641215        for (std::list<SRow>::const_iterator it = m_CharacterPositions.begin();
    12651216             it != m_CharacterPositions.end();
    12661217             ++it, buffered_y += ls)
    12671218        {
    1268             if (buffered_y + buffer_zone >= -ls || !multiline)
     1219            if (buffered_y + m_BufferZone >= -ls || !m_Multiline)
    12691220            {
    1270                 if (multiline)
     1221                if (m_Multiline)
    12711222                {
    1272                     if (buffered_y + buffer_zone > m_CachedActualSize.GetHeight())
     1223                    if (buffered_y + m_BufferZone > m_CachedActualSize.GetHeight())
    12731224                        break;
    12741225                }
    12751226
    12761227                glPushMatrix();
    1277                
     1228
    12781229                // Text must always be drawn in integer values. So we have to convert scroll
    1279                 if (multiline)
     1230                if (m_Multiline)
    12801231                    glTranslatef(0.f, -(float)(int)scroll, 0.f);
    12811232                else
    12821233                    glTranslatef(-(float)(int)m_HorizontalScroll, 0.f, 0.f);
     
    12851236                // (often compared against ints, so don't make it size_t)
    12861237                for (int i=0; i < (int)it->m_ListOfX.size()+1; ++i)
    12871238                {
    1288                     if (!multiline && i < (int)it->m_ListOfX.size())
     1239                    if (!m_Multiline && i < (int)it->m_ListOfX.size())
    12891240                    {
    1290                         if (it->m_ListOfX[i] - m_HorizontalScroll < -buffer_zone)
     1241                        if (it->m_ListOfX[i] - m_HorizontalScroll < -m_BufferZone)
    12911242                        {
    12921243                            // We still need to translate the OpenGL matrix
    12931244                            if (i == 0)
     
    13001251                    }
    13011252
    13021253                    // End of selected area, change back color
    1303                     if (SelectingText() && 
     1254                    if (SelectingText() &&
    13041255                        it->m_ListStart + i == VirtualTo)
    13051256                    {
    13061257                        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);
    13081259                    }
    13091260
    13101261                    if (i != (int)it->m_ListOfX.size() &&
     
    13171268                    }
    13181269
    13191270                    // Drawing selected area
    1320                     if (SelectingText() && 
     1271                    if (SelectingText() &&
    13211272                        it->m_ListStart + i >= VirtualFrom &&
    13221273                        it->m_ListStart + i < VirtualTo &&
    13231274                        using_selected_color == false)
    13241275                    {
    13251276                        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);
    13271278                    }
    13281279
    13291280                    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]);
    13311282
    13321283                    // check it's now outside a one-liner, then we'll break
    1333                     if (!multiline && i < (int)it->m_ListOfX.size())               
     1284                    if (!m_Multiline && i < (int)it->m_ListOfX.size())
    13341285                    {
    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)
    13361287                            break;
    13371288                    }
    13381289                }
    13391290
    13401291                if (it->m_ListStart + (int)it->m_ListOfX.size() == m_iBufferPos)
    13411292                {
    1342                     glColor4f(color.r, color.g, color.b, color.a);
     1293                    glColor4f(m_TextColor.r, m_TextColor.g, m_TextColor.b, m_TextColor.a);
    13431294                    glwprintf(L"_");
    13441295
    13451296                    if (using_selected_color)
    13461297                    {
    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);
    13481299                    }
    13491300                }
    13501301
    13511302                glPopMatrix();
    13521303            }
    1353             glTranslatef(0.f, ls, 0.f); 
     1304            glTranslatef(0.f, ls, 0.f);
    13541305        }
    13551306
    13561307        glPopMatrix();
     
    13641315
    13651316void CInput::UpdateText(int from, int to_before, int to_after)
    13661317{
    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 
    13761318    // 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());
    13791321
    1380     if (font_name == CStrW())
     1322    if (m_Font == L"") // XXX can this be possible? I set to default
    13811323    {
    13821324        // Destroy everything stored, there's no font, so there can be
    13831325        //  no data.
     
    13871329
    13881330    SRow row;
    13891331    row.m_ListStart = 0;
    1390    
     1332
    13911333    int to = 0; // make sure it's initialized
    13921334
    13931335    if (to_before == -1)
    1394         to = (int)caption.length();
     1336        to = (int)m_Caption.length();
    13951337
    1396     CFont font(font_name);
     1338    CFont font(m_Font);
    13971339
    13981340    std::list<SRow>::iterator current_line;
    13991341
     
    14121354        ENSURE(to_before != -1);
    14131355
    14141356        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,
    14161358        //  previously a comparison like:
    14171359        //  destroy_row_from == std::list<SRow>::iterator()
    14181360        // ... was used, but it didn't work with GCC.
     
    14231365        //  to be redone. And when going along, we'll delete a row at a time
    14241366        //  when continuing to see how much more after 'to' we need to remake.
    14251367        int i=0;
    1426         for (std::list<SRow>::iterator it=m_CharacterPositions.begin(); 
     1368        for (std::list<SRow>::iterator it=m_CharacterPositions.begin();
    14271369             it!=m_CharacterPositions.end(); ++it, ++i)
    14281370        {
    14291371            if (destroy_row_from_used == false &&
     
    14371379
    14381380                // For the rare case that we might remove characters to a word
    14391381                //  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
    14411383                //  (if one exists)
    14421384                if (destroy_row_from != m_CharacterPositions.begin())
    14431385                    --destroy_row_from;
     
    14511393                destroy_row_to_used = true;
    14521394
    14531395                // 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
    14551397                //  identical to what it was before. If it isn't, then we'll
    14561398                //  have to continue.
    14571399                // 'check_point_row_start' is where we store how the that
     
    14941436        // set 'from' to the row we'll destroy from
    14951437        //  and 'to' to the row we'll destroy to
    14961438        from = destroy_row_from->m_ListStart;
    1497        
     1439
    14981440        if (destroy_row_to != m_CharacterPositions.end())
    14991441            to = destroy_row_to->m_ListStart; // notice it will iterate [from, to), so it will never reach to.
    15001442        else
    1501             to = (int)caption.length();
     1443            to = (int)m_Caption.length();
    15021444
    15031445
    15041446        // Setup the first row
     
    15131455        --temp_it;
    15141456
    15151457        m_CharacterPositions.erase(destroy_row_from, destroy_row_to);
    1516        
     1458
    15171459        // If there has been a change in number of characters
    15181460        //  we need to change all m_ListStart that comes after
    15191461        //  the interval we just destroyed. We'll change all
     
    15321474            check_point_row_start += delta;
    15331475            check_point_row_end += delta;
    15341476
    1535             if (to != (int)caption.length())
     1477            if (to != (int)m_Caption.length())
    15361478                to += delta;
    15371479        }
    15381480    }
    1539    
     1481
    15401482    int last_word_started=from;
    15411483    //int last_list_start=-1;   // unused
    15421484    float x_pos = 0.f;
     
    15461488
    15471489    for (int i=from; i<to; ++i)
    15481490    {
    1549         if (caption[i] == L'\n' && multiline)
     1491        if (m_Caption[i] == L'\n' && m_Multiline)
    15501492        {
    1551             if (i==to-1 && to != (int)caption.length())
     1493            if (i==to-1 && to != (int)m_Caption.length())
    15521494                break; // it will be added outside
    1553            
     1495
    15541496            current_line = m_CharacterPositions.insert( current_line, row );
    15551497            ++current_line;
    15561498
     
    15631505        }
    15641506        else
    15651507        {
    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.
    15671509                caption[i] == L'-'*/)
    15681510                last_word_started = i+1;
    15691511
    1570             x_pos += (float)font.GetCharacterWidth(caption[i]);
     1512            x_pos += (float)font.GetCharacterWidth(m_Caption[i]);
    15711513
    1572             if (x_pos >= GetTextAreaWidth() && multiline)
     1514            if (x_pos >= GetTextAreaWidth() && m_Multiline)
    15731515            {
    15741516                // The following decides whether it will word-wrap a word,
    15751517                //  or if it's only one word on the line, where it has to
     
    15861528                    // regular word-wrap
    15871529                    row.m_ListOfX.resize(row.m_ListOfX.size() - (i-last_word_started+1));
    15881530                }
    1589                
     1531
    15901532                // Now, create a new line:
    15911533                //  notice: when we enter a newline, you can stand with the cursor
    15921534                //  both before and after that character, being on different
     
    16141556        //  also check if the current line isn't the end
    16151557        if (to_before != -1 && i == to-1 && current_line != m_CharacterPositions.end())
    16161558        {
    1617             // check all rows and see if any existing 
     1559            // check all rows and see if any existing
    16181560            if (row.m_ListStart != check_point_row_start)
    16191561            {
    16201562                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,
    16221564                //  previously a comparison like:
    16231565                //  destroy_row_from == std::list<SRow>::iterator()
    16241566                //  was used, but it didn't work with GCC.
     
    16291571                //  to be redone. And when going along, we'll delete a row at a time
    16301572                //  when continuing to see how much more after 'to' we need to remake.
    16311573                int i=0;
    1632                 for (std::list<SRow>::iterator it=m_CharacterPositions.begin(); 
     1574                for (std::list<SRow>::iterator it=m_CharacterPositions.begin();
    16331575                    it!=m_CharacterPositions.end(); ++it, ++i)
    16341576                {
    16351577                    if (destroy_row_from_used == false &&
     
    16521594                        destroy_row_to_used = true;
    16531595
    16541596                        // 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
    16561598                        //  identical to what it was before. If it isn't, then we'll
    16571599                        //  have to continue.
    16581600                        // 'check_point_row_start' is where we store how the that
    16591601                        //  line looked.
    1660             //          if (destroy_row_to != 
     1602            //          if (destroy_row_to !=
    16611603                        if (destroy_row_to != m_CharacterPositions.end())
    16621604                        {
    16631605                            check_point_row_start = destroy_row_to->m_ListStart;
     
    16941636                // set 'from' to the from row we'll destroy
    16951637                //  and 'to' to 'to_after'
    16961638                from = destroy_row_from->m_ListStart;
    1697                
     1639
    16981640                if (destroy_row_to != m_CharacterPositions.end())
    16991641                    to = destroy_row_to->m_ListStart; // notice it will iterate [from, to[, so it will never reach to.
    17001642                else
    1701                     to = (int)caption.length();
     1643                    to = (int)m_Caption.length();
    17021644
    17031645
    17041646                // Set current line, new rows will be added before current_line, so
     
    17281670    // add the final row (even if empty)
    17291671    m_CharacterPositions.insert(current_line, row);
    17301672
    1731     bool scrollbar;
    1732     GUI<bool>::GetSetting(this, "scrollbar", scrollbar);
    17331673    // Update scollbar
    1734     if (scrollbar)
     1674    if (m_Scrollbar)
    17351675    {
    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);
    17371677        GetScrollBar(0).SetScrollSpace(m_CachedActualSize.GetHeight());
    17381678    }
    17391679}
     
    17461686    // Return position
    17471687    int retPosition;
    17481688
    1749     float buffer_zone;
    1750     bool multiline;
    1751     GUI<float>::GetSetting(this, "buffer_zone", buffer_zone);
    1752     GUI<bool>::GetSetting(this, "multiline", multiline);
    1753 
    17541689    std::list<SRow>::iterator current = m_CharacterPositions.begin();
    17551690
    17561691    CPos mouse = GetMousePos();
    17571692
    1758     if (multiline)
     1693    if (m_Multiline)
    17591694    {
    1760         CStrW font_name;
    1761         bool scrollbar;
    1762         GUI<CStrW>::GetSetting(this, "font", font_name);
    1763         GUI<bool>::GetSetting(this, "scrollbar", scrollbar);
    1764        
    17651695        float scroll=0.f;
    1766         if (scrollbar)
     1696        if (m_Scrollbar)
    17671697        {
    17681698            scroll = GetScrollBar(0).GetPos();
    17691699        }
    17701700
    1771         // Pointer to caption, will come in handy
    1772         CStrW *pCaption = (CStrW*)m_Settings["caption"].m_pSetting;
    1773         UNUSED2(pCaption);
    1774 
    17751701        // Now get the height of the font.
    17761702                        // TODO: Get the real font
    1777         CFont font(font_name);
     1703        CFont font(m_Font);
    17781704        float spacing = (float)font.GetLineSpacing();
    17791705        //float height = (float)font.GetHeight();   // unused
    17801706
    17811707        // Change mouse position relative to text.
    17821708        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;
    17851711
    17861712        //if ((m_CharacterPositions.size()-1) * spacing + height < mouse.y)
    1787         //  m_iBufferPos = pCaption->Length();
     1713        //  m_iBufferPos = m_Caption.Length();
    17881714        int row = (int)((mouse.y) / spacing);//m_CharachterPositions.size()
    17891715
    17901716        if (row < 0)
     
    18041730        // current is already set to begin,
    18051731        //  but we'll change the mouse.x to fit our horizontal scrolling
    18061732        mouse -= m_CachedActualSize.TopLeft();
    1807         mouse.x -= buffer_zone - m_HorizontalScroll;
     1733        mouse.x -= m_BufferZone - m_HorizontalScroll;
    18081734        // mouse.y is moot
    18091735    }
    18101736
    18111737    //m_iBufferPos = m_CharacterPositions.get.m_ListStart;
    18121738    retPosition = current->m_ListStart;
    1813    
     1739
    18141740    // Okay, now loop through the glyphs to find the appropriate X position
    18151741    float dummy;
    18161742    retPosition += GetXTextPosition(current, mouse.x, dummy);
     
    18541780
    18551781void CInput::DeleteCurSelection()
    18561782{
    1857     CStrW *pCaption = (CStrW*)m_Settings["caption"].m_pSetting;
    1858 
    18591783    int virtualFrom;
    18601784    int virtualTo;
    18611785
     
    18701794        virtualTo = m_iBufferPos;
    18711795    }
    18721796
    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) );
    18751799
    18761800    UpdateText(virtualFrom, virtualTo, virtualFrom);
    18771801
     
    18881812
    18891813float CInput::GetTextAreaWidth()
    18901814{
    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;
    18981817    else
    1899         return m_CachedActualSize.GetWidth() - buffer_zone*2.f;
     1818        return m_CachedActualSize.GetWidth() - m_BufferZone*2.f;
    19001819}
    19011820
    19021821void CInput::UpdateAutoScroll()
    19031822{
    1904     float buffer_zone;
    1905     bool multiline;
    1906     GUI<float>::GetSetting(this, "buffer_zone", buffer_zone);
    1907     GUI<bool>::GetSetting(this, "multiline", multiline);
    1908 
    19091823    // Autoscrolling up and down
    1910     if (multiline)
     1824    if (m_Multiline)
    19111825    {
    1912         CStrW font_name;
    1913         bool scrollbar;
    1914         GUI<CStrW>::GetSetting(this, "font", font_name);
    1915         GUI<bool>::GetSetting(this, "scrollbar", scrollbar);
    1916        
    19171826        float scroll=0.f;
    1918         if (!scrollbar)
     1827        if (!m_Scrollbar)
    19191828            return;
    19201829
    19211830        scroll = GetScrollBar(0).GetPos();
    1922        
     1831
    19231832        // Now get the height of the font.
    19241833                        // TODO: Get the real font
    1925         CFont font(font_name);
     1834        CFont font(m_Font);
    19261835        float spacing = (float)font.GetLineSpacing();
    19271836        //float height = font.GetHeight();
    19281837
     
    19361845            if (m_iBufferPos >= current->m_ListStart &&
    19371846                m_iBufferPos <= current->m_ListStart+(int)current->m_ListOfX.size())
    19381847                break;
    1939            
     1848
    19401849            ++current;
    19411850            ++row;
    19421851        }
    19431852
    19441853        // 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())
    19461855        {
    19471856            // 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);
    19491858        }
    19501859        else
    19511860        // If scrolling up
     
    19761885        }
    19771886
    19781887        // 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;
    19811890
    19821891        // Check if outside to the left
    19831892        if (x_position - m_HorizontalScroll < 0.f)
     
    19851894
    19861895        // Check if the text doesn't even fill up to the right edge even though scrolling is done.
    19871896        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;
    19901899
    19911900        // Now this is the fail-safe, if x_total isn't even the length of the control,
    19921901        //  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())
    19941903            m_HorizontalScroll = 0.f;
    19951904    }
    19961905}
  • source/gui/CDropDown.h

     
    9999     * made that can change the visual.
    100100     */
    101101    void SetupText();
    102    
     102
    103103    // Sets up the cached GetListRect. Decided whether it should
    104104    //  have a scrollbar, and so on.
    105105    virtual void SetupListRect();
     
    127127    //  it is set to "selected", but then when moving the mouse it will
    128128    //  change.
    129129    int m_ElementHighlight;
     130private:
     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
    130140};
    131141
    132142#endif
  • source/gui/IGUIButtonBehavior.cpp

     
    2828//-------------------------------------------------------------------
    2929IGUIButtonBehavior::IGUIButtonBehavior() : m_Pressed(false)
    3030{
     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);
    3135}
    3236
    3337IGUIButtonBehavior::~IGUIButtonBehavior()
     
    4145    {
    4246    case GUIM_MOUSE_PRESS_LEFT:
    4347    {
    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        }
    4952
    50         m_Pressed = true;
    51     }   break;
     53        break;
     54    }
    5255
    5356    case GUIM_MOUSE_DBLCLICK_LEFT:
    5457    case GUIM_MOUSE_RELEASE_LEFT:
    5558    {
    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 )
    6360        {
    6461            m_Pressed = false;
    6562            if (Message.type == GUIM_MOUSE_RELEASE_LEFT)
     
    7774                SendEvent(GUIM_DOUBLE_PRESSED, "doublepress");
    7875            }
    7976        }
    80     }   break;
     77        break;
     78    }
    8179
    8280    default:
    8381        break;
     
    8684
    8785CColor IGUIButtonBehavior::ChooseColor()
    8886{
    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())
    9888    {
    99         GUI<CColor>::GetSetting(this, "textcolor_disabled", color2);
    100         return GUI<>::FallBackColor(color2, color);
     89        return GUI<>::FallBackColor(m_ButtonTextColorDisabled, m_ButtonTextColor);
    10190    }
    102     else
    103     if (m_MouseHovering)
     91    else if (m_MouseHovering)
    10492    {
    10593        if (m_Pressed)
    10694        {
    107             GUI<CColor>::GetSetting(this, "textcolor_pressed", color2);
    108             return GUI<>::FallBackColor(color2, color);
     95            return GUI<>::FallBackColor(m_ButtonTextColorPressed, m_ButtonTextColor);
    10996        }
    11097        else
    11198        {
    112             GUI<CColor>::GetSetting(this, "textcolor_over", color2);
    113             return GUI<>::FallBackColor(color2, color);
     99            return GUI<>::FallBackColor(m_ButtonTextColorOver, m_ButtonTextColor);
    114100        }
    115101    }
    116     else return color;
     102
     103    return m_ButtonTextColor;
    117104}
    118105
    119106void IGUIButtonBehavior::DrawButton(const CRect &rect,
     
    126113{
    127114    if (GetGUI())
    128115    {
    129         bool enabled;
    130         GUI<bool>::GetSetting(this, "enabled", enabled);
    131 
    132         if (!enabled)
     116        if (!IsEnabled())
    133117        {
    134118            GetGUI()->DrawSprite(GUI<>::FallBackSprite(sprite_disabled, sprite), cell_id, z, rect);
    135119        }
  • source/gui/CButton.cpp

     
    3131//-------------------------------------------------------------------
    3232CButton::CButton()
    3333{
    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);
    5042
     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
    5149    // Add text
    5250    AddText(new SGUIText());
    5351}
     
    6361
    6462    ENSURE(m_GeneratedTexts.size()==1);
    6563
    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);
    7165
    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 
    7966    CalculateTextPosition(m_CachedActualSize, m_TextPos, *m_GeneratedTexts[0]);
    8067}
    8168
     
    8673    IGUITextOwner::HandleMessage(Message);
    8774}
    8875
    89 void CButton::Draw() 
     76void CButton::Draw()
    9077{
    9178    float bz = GetBufferedZ();
    9279
    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 do
    97     // lots of allocation every time this function is called
    98     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 
    11080    DrawButton(m_CachedActualSize,
    11181               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);
    11787
    118     CColor color = ChooseColor();
    119     IGUITextOwner::Draw(0, color, m_TextPos, bz+0.1f);
     88    IGUITextOwner::Draw(0, ChooseColor(), m_TextPos, bz+0.1f);
    12089}
  • source/gui/IGUITextOwner.h

     
    8888     * @param clipping Clipping rectangle, don't even add a parameter
    8989     *        to get no clipping.
    9090     */
    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,
    9292                      const float &z, const CRect &clipping = CRect());
    9393
    9494    /**
     
    117117     * Calculate the position for the text, based on the alignment.
    118118     */
    119119    void CalculateTextPosition(CRect &ObjSize, CPos &TextPos, SGUIText &Text);
     120private:
     121    EAlign              m_TextAlign;
     122    EVAlign             m_TextVAlign;
     123
    120124};
    121125
    122126#endif
  • source/gui/CList.h

     
    121121
    122122    // Extended drawing interface, this is so that classes built on the this one
    123123    //  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);
    126125
    127126    // Get the area of the list. This is so that i can easily be changed, like in CDropDown
    128127    //  where the area is not equal to m_CachedActualSize.
     
    138137     * be zero, but still stored for easy handling.
    139138     */
    140139    std::vector<float> m_ItemsYPositions;
     140
     141    void SetSelected(const int index, const bool SkipMessage = false);
     142
     143public:
     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
     156private:
     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
    141175};
    142176
    143177#endif
  • source/gui/GUIutil.h

     
    343343    {
    344344        // Statically initialise some strings, so we don't have to do
    345345        // 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");
    349349
    350350        if (RR & GUIRR_HIDDEN)
    351351        {
    352             bool hidden = true;
    353             GUI<bool>::GetSetting(pObject, strHidden, hidden);
     352//          bool hidden = true;
     353//          GUI<bool>::GetSetting(pObject, strHidden, hidden);
    354354
    355             if (hidden)
     355            if ( pObject->IsHidden() )
    356356                return true;
    357357        }
    358358        if (RR & GUIRR_DISABLED)
    359359        {
    360             bool enabled = false;
    361             GUI<bool>::GetSetting(pObject, strEnabled, enabled);
     360//          bool enabled = false;
     361//          GUI<bool>::GetSetting(pObject, strEnabled, enabled);
    362362
    363             if (!enabled)
     363            if (! pObject->IsEnabled() )
    364364                return true;
    365365        }
    366366        if (RR & GUIRR_GHOST)
    367367        {
    368             bool ghost = true;
    369             GUI<bool>::GetSetting(pObject, strGhost, ghost);
     368//          bool ghost = true;
     369//          GUI<bool>::GetSetting(pObject, strGhost, ghost);
    370370
    371             if (ghost)
     371            if ( pObject->IsGhost() )
    372372                return true;
    373373        }
    374374
  • source/gui/CGUI.cpp

     
    13651365    if (!ManuallySetZ)
    13661366    {
    13671367        // 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);
    13701370
    13711371        // If the object is absolute, we'll have to get the parent's Z buffered,
    13721372        //  and add to that!
    1373         if (absolute)
     1373        if ( object->IsAbsolute() )
    13741374        {
    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);
    13761377        }
    13771378        else
    13781379        // If the object is relative, then we'll just store Z as "10"
    13791380        {
    1380             GUI<float>::SetSetting(object, "z", 10.f, true);
     1381//          GUI<float>::SetSetting(object, "z", 10.f, true);
     1382            object->SetZ(10.f, true);
    13811383        }
    13821384    }
    13831385
  • source/gui/CText.cpp

     
    3232//-------------------------------------------------------------------
    3333CText::CText()
    3434{
    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);
    4947
    5048    // 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);
    5351
     52    m_BufferZone = 0.f;
     53    m_Font = L"default";
     54    m_ScrollBottom = false;
     55
    5456    //GUI<bool>::SetSetting(this, "ghost", true);
    5557    GUI<bool>::SetSetting(this, "scrollbar", false);
    5658    GUI<bool>::SetSetting(this, "clip", true);
     
    7678
    7779    ENSURE(m_GeneratedTexts.size()>=1);
    7880
    79     CStrW font;
    80     if (GUI<CStrW>::GetSetting(this, "font", font) != PSRETURN_OK || font.empty())
    81         // Use the default if none is specified
    82         // 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 
    9081    float width = m_CachedActualSize.GetWidth();
    9182    // remove scrollbar if applicable
    92     if (scrollbar && GetScrollBar(0).GetStyle())
     83    if (m_Scrollbar && GetScrollBar(0).GetStyle())
    9384        width -= GetScrollBar(0).GetStyle()->m_Width;
    9485
    9586
    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);
    9988
    100     if (! scrollbar)
     89    if (! m_Scrollbar)
    10190        CalculateTextPosition(m_CachedActualSize, m_TextPos, *m_GeneratedTexts[0]);
    10291
    10392    // Setup scrollbar
    104     if (scrollbar)
     93    if (m_Scrollbar)
    10594    {
    106         bool scrollbottom = false;
    107         GUI<bool>::GetSetting(this, "scroll_bottom", scrollbottom);
    108 
    10995        // If we are currently scrolled to the bottom of the text,
    11096        // then add more lines of text, update the scrollbar so we
    11197        // stick to the bottom.
    11298        // (Use 1.5px delta so this triggers the first time caption is set)
    11399        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)
    115101            bottom = true;
    116102
    117103        GetScrollBar(0).SetScrollRange(m_GeneratedTexts[0]->m_Size.cy);
     
    143129        // Update scrollbar
    144130        if (Message.value == "scrollbar_style")
    145131        {
    146             CStr scrollbar_style;
    147             GUI<CStr>::GetSetting(this, Message.value, scrollbar_style);
     132            GetScrollBar(0).SetScrollBarStyle( m_ScrollbarStyle );
    148133
    149             GetScrollBar(0).SetScrollBarStyle( scrollbar_style );
    150 
    151134            SetupText();
    152135        }
    153136
     
    178161        GetScrollBar(0).SetZ( GetBufferedZ() );
    179162        GetScrollBar(0).SetLength( m_CachedActualSize.bottom - m_CachedActualSize.top );
    180163
    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 );
    184165        }
    185166        break;
    186167
     
    191172    IGUITextOwner::HandleMessage(Message);
    192173}
    193174
    194 void CText::Draw() 
     175void CText::Draw()
    195176{
    196     float bz = GetBufferedZ();
    197 
    198177    // First call draw on ScrollBarOwner
    199     bool scrollbar;
    200     GUI<bool>::GetSetting(this, "scrollbar", scrollbar);
    201 
    202     if (scrollbar)
     178    if (m_Scrollbar)
    203179    {
    204180        // Draw scrollbar
    205181        IGUIScrollBarOwner::Draw();
     
    207183
    208184    if (GetGUI())
    209185    {
    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();
    216187
    217         GetGUI()->DrawSprite(*sprite, cell_id, bz, m_CachedActualSize);
     188        GetGUI()->DrawSprite(m_Sprite, m_CellId, bz, m_CachedActualSize);
    218189
    219190        float scroll=0.f;
    220         if (scrollbar)
     191        if (m_Scrollbar)
    221192        {
    222193            scroll = GetScrollBar(0).GetPos();
    223194        }
    224195
    225196        // Clipping area (we'll have to subtract the scrollbar)
    226197        CRect cliparea;
    227         if (clip)
     198        if (m_Clip)
    228199        {
    229200            cliparea = m_CachedActualSize;
    230201
    231             if (scrollbar)
     202            if (m_Scrollbar)
    232203            {
    233204                // subtract scrollbar from cliparea
    234205                if (cliparea.right > GetScrollBar(0).GetOuterRect().left &&
     
    241212            }
    242213        }
    243214
    244         CColor color;
    245         GUI<CColor>::GetSetting(this, "textcolor", color);
    246 
    247215        // 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);
    250218        else
    251             IGUITextOwner::Draw(0, color, m_TextPos, bz+0.1f, cliparea);
     219            IGUITextOwner::Draw(0, m_TextColor, m_TextPos, bz+0.1f, cliparea);
    252220    }
    253221}
    254222
  • source/gui/IGUIObject.h

     
    111111
    112112    void                *m_pSetting;
    113113    EGUISettingType     m_Type;
     114    bool                m_dynamic;
    114115};
    115116
    116117/**
     
    198199    void AddToPointersMap(map_pObjects &ObjectMap);
    199200
    200201    /**
    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
    203204     * all is checked. Now we're just linking two objects, but
    204205     * it's when we're inputting them into the GUI we'll check
    205206     * validity! Notice also when adding it to the GUI this function
     
    239240     * @return True if settings exist.
    240241     */
    241242    bool SettingExists(const CStr& Setting) const;
    242    
     243
    243244    /**
    244245     * All sizes are relative to resolution, and the calculation
    245246     * is not wanted in real time, therefore it is cached, update
     
    291292     * @param pGUI GUI instance to associate the script with
    292293     */
    293294    void RegisterScriptHandler(const CStr& Action, const CStr& Code, CGUI* pGUI);
    294    
     295
    295296    /**
    296297     * Retrieves the JSObject representing this GUI object.
    297298     */
     
    317318     * @param Type Setting type
    318319     * @param Name Setting reference name
    319320     */
    320     void AddSetting(const EGUISettingType &Type, const CStr& Name);
     321    void AddSetting(const EGUISettingType &Type, const CStr& Name, void *Pointer = 0);
    321322
    322323    /**
    323324     * Calls Destroy on all children, and deallocates all memory.
    324325     * MEGA TODO Should it destroy it's children?
    325326     */
    326327    virtual void Destroy();
    327    
     328
    328329public:
    329330    /**
    330331     * This function is called with different messages
     
    387388     * Set parent of this object
    388389     */
    389390    void SetParent(IGUIObject *pParent) { m_pParent = pParent; }
    390    
     391
    391392    /**
    392393     * Reset internal state of this object
    393394     */
     
    435436     * Notice 'false' is default, because an object not using this function, should not
    436437     * have any additional children (and this function should never be called).
    437438     */
    438     virtual bool HandleAdditionalChildren(const XMBElement& UNUSED(child), 
     439    virtual bool HandleAdditionalChildren(const XMBElement& UNUSED(child),
    439440                                          CXeromyces* UNUSED(pFile)) { return false; }
    440441
    441442    /**
     
    480481    /** @name Internal functions */
    481482    //--------------------------------------------------------
    482483    //@{
    483    
     484
    484485    /**
    485486     * Inputs a reference pointer, checks if the new inputted object
    486487     * if hovered, if so, then check if this's Z value is greater
     
    529530
    530531    // Pointer to parent
    531532    IGUIObject                              *m_pParent;
    532    
     533
    533534    //This represents the last click time for each mouse button
    534535    double m_LastClickTime[6];
    535536
     
    542543     * read. This is important to know because I don't want to force
    543544     * the user to include its \<styles\>-XML-files first, so somehow
    544545     * the GUI needs to know which settings were set, and which is meant
    545      * to 
     546     * to
    546547     */
    547548
    548549    // More variables
     
    558559     *
    559560     * @see SetupSettings()
    560561     */
    561     public:
     562
     563private:
     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
     574public:
    562575    std::map<CStr, SGUISetting>             m_Settings;
    563576
     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
    564605private:
    565606    // An object can't function stand alone
    566607    CGUI                                    *m_pGUI;
    567608
    568609    // Internal storage for registered script handlers.
    569610    std::map<CStr, JSObject**> m_ScriptHandlers;
    570    
     611
    571612    // Cached JSObject representing this GUI object
    572613    JSObject                                *m_JSObject;
    573614};
  • source/gui/CImage.h

     
    5757 * without functionality used, and that is a lot of unnecessary
    5858 * overhead. That's why I thought I'd go with an intuitive
    5959 * control.
    60  * 
     60 *
    6161 * @see IGUIObject
    6262 */
    6363class CImage : public IGUIObject
     
    7373     * Draws the Image
    7474     */
    7575    virtual void Draw();
     76
     77private:
     78    int                 m_CellId;
     79    CGUISpriteInstance  m_Sprite;
     80    CStrW               m_Tooltip;
     81    CStr                m_TooltipStyle;
     82
    7683};
    7784
    7885#endif
  • source/gui/CCheckBox.h

     
    5050
    5151/**
    5252 * CheckBox
    53  * 
     53 *
    5454 * @see IGUIObject
    5555 * @see IGUISettingsObject
    5656 * @see IGUIButtonBehavior
     
    8484     * made that can change the visual.
    8585     */
    8686    void SetupText();
     87
     88private:
     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
    87106};
    88107
    89108#endif
  • source/gui/CDropDown.cpp

     
    3232//-------------------------------------------------------------------
    3333CDropDown::CDropDown() : m_Open(false), m_HideScrollBar(false), m_ElementHighlight(-1)
    3434{
    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);
    3838//  AddSetting(GUIST_CStrW,                 "font");
    3939//  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
    4746    // Add these in CList! And implement TODO
    4847    //AddSetting(GUIST_CColor,              "textcolor_over");
    4948    //AddSetting(GUIST_CColor,              "textcolor_pressed");
     
    8180            Message.value == "button_width")
    8281        {
    8382            SetupListRect();
    84         }       
     83        }
    8584
    8685        break;
    8786    }
     
    9493
    9594            if (GetListRect().PointInside(mouse))
    9695            {
    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();
    10197                float scroll=0.f;
    102                 if (scrollbar)
     98                if (IsScrollbar())
    10399                {
    104100                    scroll = GetScrollBar(0).GetPos();
    105101                }
     
    107103                CRect rect = GetListRect();
    108104                mouse.y += scroll;
    109105                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)
    111107                {
    112108                    if (mouse.y >= rect.top + m_ItemsYPositions[i] &&
    113109                        mouse.y < rect.top + m_ItemsYPositions[i+1] &&
     
    118114                        set = i;
    119115                    }
    120116                }
    121                
     117
    122118                if (set != -1)
    123119                {
    124120                    //GUI<int>::SetSetting(this, "selected", set);
     
    133129
    134130    case GUIM_MOUSE_LEAVE:
    135131    {
    136         GUI<int>::GetSetting(this, "selected", m_ElementHighlight);
     132        m_ElementHighlight = GetSelectedIndex();
    137133
    138134        break;
    139135    }
     
    142138    // a mouse click to open the dropdown, also the coordinates are changed.
    143139    case GUIM_MOUSE_PRESS_LEFT:
    144140    {
    145         bool enabled;
    146         GUI<bool>::GetSetting(this, "enabled", enabled);
    147         if (!enabled)
     141        if (! IsEnabled() )
    148142            break;
    149143
    150144        if (!m_Open)
     
    152146            m_Open = true;
    153147            GetScrollBar(0).SetPos(0.f);
    154148            GetScrollBar(0).SetZ(GetBufferedZ());
    155             GUI<int>::GetSetting(this, "selected", m_ElementHighlight);
     149            m_ElementHighlight = GetSelectedIndex();
    156150            return; // overshadow
    157151        }
    158152        else
     
    226220    CList::ManuallyHandleEvent(ev);
    227221
    228222    if (update_highlight)
    229         GUI<int>::GetSetting(this, "selected", m_ElementHighlight);
     223        m_ElementHighlight = GetSelectedIndex();
    230224
    231225    return IN_HANDLED;
    232226}
    233227
    234228void CDropDown::SetupListRect()
    235229{
    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)
    242231    {
    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);
    245234
    246235        m_HideScrollBar = false;
    247236    }
    248237    else
    249238    {
    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());
    252241
    253242        // We also need to hide the scrollbar
    254243        m_HideScrollBar = true;
     
    277266        return m_CachedActualSize.PointInside(GetMousePos());
    278267}
    279268
    280 void CDropDown::Draw() 
     269void CDropDown::Draw()
    281270{
    282271    if (!GetGUI())
    283272        return;
    284273
    285274    float bz = GetBufferedZ();
    286275
    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();
    290279
    291     CGUISpriteInstance *sprite, *sprite2, *sprite2_second;
    292     int cell_id, selected=0;
    293     CColor color;
     280    GetGUI()->DrawSprite(GetSprite(), cell_id, bz, m_CachedActualSize);
    294281
    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)
    308283    {
    309         CRect rect(m_CachedActualSize.right-button_width, m_CachedActualSize.top,
     284        CRect rect(m_CachedActualSize.right-m_ButtonWidth, m_CachedActualSize.top,
    310285                   m_CachedActualSize.right, m_CachedActualSize.bottom);
    311286
    312         if (!enabled)
     287        if (! IsEnabled() )
    313288        {
    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);
    316290        }
    317291        else
    318292        if (m_Open)
    319293        {
    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);
    322295        }
    323296        else
    324297        if (m_MouseHovering)
    325298        {
    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);
    328300        }
    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);
    331303    }
    332304
    333305    if (selected != -1) // TODO: Maybe check validity completely?
    334306    {
    335307        // figure out clipping rectangle
    336308        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);
    338310
    339311        CPos pos(m_CachedActualSize.left, m_CachedActualSize.top);
    340312        IGUITextOwner::Draw(selected, color, pos, bz+0.1f, cliparea);
    341313    }
    342314
    343     bool *scrollbar=NULL, old;
    344     GUI<bool>::GetSettingPointer(this, "scrollbar", scrollbar);
    345 
    346     old = *scrollbar;
    347 
    348315    if (m_Open)
    349316    {
     317        bool old = IsScrollbar();
    350318        if (m_HideScrollBar)
    351             *scrollbar = false;
     319            SetScrollbar( false );
    352320
    353         DrawList(m_ElementHighlight, "sprite_list", "sprite_selectarea", "textcolor");
    354        
     321        DrawList(m_ElementHighlight, m_SpriteList);
     322
    355323        if (m_HideScrollBar)
    356             *scrollbar = old;
     324            SetScrollbar(old);
    357325    }
    358326}
    359327
  • source/gui/CTooltip.h

     
    4646    virtual void HandleMessage(SGUIMessage &Message);
    4747
    4848    virtual void Draw();
     49private:
     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;
    4962};
    5063
    5164#endif
  • source/gui/CInput.h

     
    8282    int GetMouseHoveringTextPosition();
    8383
    8484    // 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
    8686    int GetXTextPosition(const std::list<SRow>::iterator &c, const float &x, float &wanted);
    8787
    8888protected:
     
    137137    void UpdateAutoScroll();
    138138
    139139protected:
    140     // Cursor position 
     140    // Cursor position
    141141    //  (the second one is for selection of larger areas, -1 if not used)
    142142    // A note on 'Tail', it was first called 'To', and the natural order
    143143    //  of X and X_To was X then X_To. Now Tail is called so, because it
     
    182182
    183183    // *** Things for one-line input control *** //
    184184    float m_HorizontalScroll;
     185private:
     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
    185202};
    186203
    187204#endif
  • source/gui/IGUITextOwner.cpp

     
    2828//-------------------------------------------------------------------
    2929IGUITextOwner::IGUITextOwner() : m_GeneratedTextsValid(false)
    3030{
     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;
    3136}
    3237
    3338IGUITextOwner::~IGUITextOwner()
     
    101106
    102107void IGUITextOwner::CalculateTextPosition(CRect &ObjSize, CPos &TextPos, SGUIText &Text)
    103108{
    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)
    110110    {
    111111    case EAlign_Left:
    112112        TextPos.x = ObjSize.left;
     
    123123        break;
    124124    }
    125125
    126     switch (valign)
     126    switch (m_TextVAlign)
    127127    {
    128128    case EVAlign_Top:
    129129        TextPos.y = ObjSize.top;
  • source/gui/CList.cpp

     
    3434CList::CList()
    3535{
    3636    // Add sprite_disabled! TODO
    37 
    38     AddSetting(GUIST_float,                 "buffer_zone");
     37    AddSetting(GUIST_float,                 "buffer_zone",       &m_BufferZone);
    3938    //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);
    5250    // 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 CGUIStrings
     51    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
    5553
     54    m_BufferZone = 0.f;
     55    m_Font = L"default";
     56    //m_Scrollbar = false;
     57    //m_Selected = -1;
     58
    5659    GUI<bool>::SetSetting(this, "scrollbar", false);
    5760
    5861    // Nothing is selected as default.
     
    7477    if (!GetGUI())
    7578        return;
    7679
    77     CGUIList *pList;
    78     GUI<CGUIList>::GetSettingPointer(this, "list", pList);
    79 
    8080    //ENSURE(m_GeneratedTexts.size()>=1);
    8181
    82     m_ItemsYPositions.resize( pList->m_Items.size()+1 );
     82    m_ItemsYPositions.resize( m_List.m_Items.size()+1 );
    8383
    8484    // Delete all generated texts. Some could probably be saved,
    8585    //  but this is easier, and this function will never be called
     
    9292    }
    9393    m_GeneratedTexts.clear();
    9494
    95     CStrW font;
    96     if (GUI<CStrW>::GetSetting(this, "font", font) != PSRETURN_OK || font.empty())
    97         // Use the default if none is specified
    98         // 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 
    10695    float width = GetListRect().GetWidth();
    10796    // remove scrollbar if applicable
    108     if (scrollbar && GetScrollBar(0).GetStyle())
     97    if (m_Scrollbar && GetScrollBar(0).GetStyle())
    10998        width -= GetScrollBar(0).GetStyle()->m_Width;
    11099
    111     float buffer_zone=0.f;
    112     GUI<float>::GetSetting(this, "buffer_zone", buffer_zone);
    113 
    114100    // Generate texts
    115101    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)
    118104    {
    119105        // Create a new SGUIText. Later on, input it using AddText()
    120106        SGUIText *text = new SGUIText();
    121107
    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);
    123109
    124110        m_ItemsYPositions[i] = buffered_y;
    125111        buffered_y += text->m_Size.cy;
     
    127113        AddText(text);
    128114    }
    129115
    130     m_ItemsYPositions[pList->m_Items.size()] = buffered_y;
    131    
     116    m_ItemsYPositions[m_List.m_Items.size()] = buffered_y;
     117
    132118    //if (! scrollbar)
    133119    //  CalculateTextPosition(m_CachedActualSize, m_TextPos, *m_GeneratedTexts[0]);
    134120
    135121    // Setup scrollbar
    136     if (scrollbar)
     122    if (m_Scrollbar)
    137123    {
    138124        GetScrollBar(0).SetScrollRange( m_ItemsYPositions.back() );
    139125        GetScrollBar(0).SetScrollSpace( GetListRect().GetHeight() );
     
    165151            // TODO: Check range
    166152
    167153            // TODO only works if lower-case, shouldn't it be made case sensitive instead?
    168             ScriptEvent("selectionchange"); 
     154            ScriptEvent("selectionchange");
    169155        }
    170156
    171157        if (Message.value == "scrollbar")
     
    176162        // Update scrollbar
    177163        if (Message.value == "scrollbar_style")
    178164        {
    179             CStr scrollbar_style;
    180             GUI<CStr>::GetSetting(this, Message.value, scrollbar_style);
     165            GetScrollBar(0).SetScrollBarStyle( m_ScrollbarStyle );
    181166
    182             GetScrollBar(0).SetScrollBarStyle( scrollbar_style );
    183 
    184167            SetupText();
    185168        }
    186169
     
    188171
    189172    case GUIM_MOUSE_PRESS_LEFT:
    190173    {
    191         bool enabled;
    192         GUI<bool>::GetSetting(this, "enabled", enabled);
    193         if (!enabled)
     174        if (!IsEnabled())
    194175            break;
    195176
    196         bool scrollbar;
    197         CGUIList *pList;
    198         GUI<bool>::GetSetting(this, "scrollbar", scrollbar);
    199         GUI<CGUIList>::GetSettingPointer(this, "list", pList);
    200177        float scroll=0.f;
    201         if (scrollbar)
     178        if (m_Scrollbar)
    202179        {
    203180            scroll = GetScrollBar(0).GetPos();
    204181        }
     
    207184        CPos mouse = GetMousePos();
    208185        mouse.y += scroll;
    209186        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)
    211188        {
    212189            if (mouse.y >= rect.top + m_ItemsYPositions[i] &&
    213190                mouse.y < rect.top + m_ItemsYPositions[i+1] &&
     
    218195                set = i;
    219196            }
    220197        }
    221        
     198
    222199        if (set != -1)
    223200        {
     201            // keep this for now
    224202            GUI<int>::SetSetting(this, "selected", set);
     203
    225204            UpdateAutoScroll();
    226205        }
    227206    }   break;
     
    246225        }
    247226    case GUIM_LOAD:
    248227        {
    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 );
    252229        }
    253230        break;
    254231
     
    300277    return IN_HANDLED;
    301278}
    302279
    303 void CList::Draw() 
     280void CList::Draw()
    304281{
    305     int selected;
    306     GUI<int>::GetSetting(this, "selected", selected);
    307    
    308     DrawList(selected, "sprite", "sprite_selectarea", "textcolor");
     282    DrawList(m_Selected, m_Sprite);
    309283}
    310284
    311285void CList::DrawList(const int &selected,
    312                      const CStr& _sprite,
    313                      const CStr& _sprite_selected,
    314                      const CStr& _textcolor)
     286                     const CGUISpriteInstance& sprite)
    315287{
    316     float bz = GetBufferedZ();
    317 
    318288    // First call draw on ScrollBarOwner
    319     bool scrollbar;
    320     GUI<bool>::GetSetting(this, "scrollbar", scrollbar);
    321289
    322     if (scrollbar)
     290    if (m_Scrollbar)
    323291    {
    324292        // Draw scrollbar
    325293        IGUIScrollBarOwner::Draw();
     
    327295
    328296    if (GetGUI())
    329297    {
     298        float bz = GetBufferedZ();
    330299        CRect rect = GetListRect();
    331300
    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);
    337302
    338         CGUIList *pList;
    339         GUI<CGUIList>::GetSettingPointer(this, "list", pList);
    340 
    341         GetGUI()->DrawSprite(*sprite, cell_id, bz, rect);
    342 
    343303        float scroll=0.f;
    344         if (scrollbar)
     304        if (m_Scrollbar)
    345305        {
    346306            scroll = GetScrollBar(0).GetPos();
    347307        }
     
    362322                if (rect_sel.top < rect.top)
    363323                    rect_sel.top = rect.top;
    364324
    365                 if (scrollbar)
     325                if (m_Scrollbar)
    366326                {
    367327                    // Remove any overlapping area of the scrollbar.
    368328                    if (rect_sel.right > GetScrollBar(0).GetOuterRect().left &&
     
    374334                        rect_sel.left = GetScrollBar(0).GetOuterRect().right;
    375335                }
    376336
    377                 GetGUI()->DrawSprite(*sprite_selectarea, cell_id, bz+0.05f, rect_sel);
     337                GetGUI()->DrawSprite(m_SpriteSelectArea, m_CellId, bz+0.05f, rect_sel);
    378338            }
    379339        }
    380340
    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)
    385342        {
    386343            if (m_ItemsYPositions[i+1] - scroll < 0 ||
    387344                m_ItemsYPositions[i] - scroll > rect.GetHeight())
     
    390347            // Clipping area (we'll have to substract the scrollbar)
    391348            CRect cliparea = GetListRect();
    392349
    393             if (scrollbar)
     350            if (m_Scrollbar)
    394351            {
    395352                if (cliparea.right > GetScrollBar(0).GetOuterRect().left &&
    396353                    cliparea.right <= GetScrollBar(0).GetOuterRect().right)
     
    401358                    cliparea.left = GetScrollBar(0).GetOuterRect().right;
    402359            }
    403360
    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]),
    405362                                bz+0.1f, cliparea);
    406363        }
    407364    }
     
    409366
    410367void CList::AddItem(const CStrW& str, const CStrW& data)
    411368{
    412     CGUIList *pList, *pListData;
    413     GUI<CGUIList>::GetSettingPointer(this, "list", pList);
    414     GUI<CGUIList>::GetSettingPointer(this, "list_data", pListData);
    415 
    416369    CGUIString gui_string;
    417370    gui_string.SetValue(str);
    418     pList->m_Items.push_back( gui_string );
     371    m_List.m_Items.push_back( gui_string );
    419372
    420373    CGUIString data_string;
    421374    data_string.SetValue(data);
    422     pListData->m_Items.push_back( data_string );
     375    m_ListData.m_Items.push_back( data_string );
    423376
    424377    // TODO Temp
    425378    SetupText();
     
    432385    if (child.GetNodeName() == elmt_item)
    433386    {
    434387        AddItem(child.GetText().FromUTF8(), child.GetText().FromUTF8());
    435        
     388
    436389        return true;
    437390    }
    438391    else
     
    443396
    444397void CList::SelectNextElement()
    445398{
    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)
    453400    {
    454         ++selected;
    455         GUI<int>::SetSetting(this, "selected", selected);
     401        SetSelected(m_Selected+1);
    456402    }
    457403}
    458    
     404
    459405void CList::SelectPrevElement()
    460406{
    461     int selected;
    462     GUI<int>::GetSetting(this, "selected", selected);
    463 
    464     if (selected != 0)
     407    if (m_Selected != 0)
    465408    {
    466         --selected;
    467         GUI<int>::SetSetting(this, "selected", selected);
     409        SetSelected(m_Selected-1);
    468410    }
    469411}
    470412
    471413void CList::SelectFirstElement()
    472414{
    473     int selected;
    474     GUI<int>::GetSetting(this, "selected", selected);
    475 
    476     if (selected != 0)
     415    if (m_Selected != 0)
    477416    {
    478         GUI<int>::SetSetting(this, "selected", 0);
     417        SetSelected(0);
    479418    }
    480419}
    481    
     420
    482421void CList::SelectLastElement()
    483422{
    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)
    491424    {
    492         GUI<int>::SetSetting(this, "selected", (int)pList->m_Items.size()-1);
     425        SetSelected(m_List.m_Items.size()-1);
    493426    }
    494427}
    495428
    496429void CList::UpdateAutoScroll()
    497430{
    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 
    506431    // No scrollbar, no scrolling (at least it's not made to work properly).
    507     if (!scrollbar)
     432    if (!m_Scrollbar)
    508433        return;
    509434
    510     scroll = GetScrollBar(0).GetPos();
     435    float scroll = GetScrollBar(0).GetPos();
    511436
     437    CRect rect = GetListRect();
     438
    512439    // Check upper boundary
    513     if (m_ItemsYPositions[selected] < scroll)
     440    if (m_ItemsYPositions[m_Selected] < scroll)
    514441    {
    515         GetScrollBar(0).SetPos(m_ItemsYPositions[selected]);
     442        GetScrollBar(0).SetPos(m_ItemsYPositions[m_Selected]);
    516443        return; // this means, if it wants to align both up and down at the same time
    517444                //  this will have precedence.
    518445    }
    519446
    520447    // Check lower boundary
    521     if (m_ItemsYPositions[selected+1]-rect.GetHeight() > scroll)
     448    if (m_ItemsYPositions[m_Selected+1]-rect.GetHeight() > scroll)
    522449    {
    523         GetScrollBar(0).SetPos(m_ItemsYPositions[selected+1]-rect.GetHeight());
     450        GetScrollBar(0).SetPos(m_ItemsYPositions[m_Selected+1]-rect.GetHeight());
    524451    }
    525452}
     453
     454void 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
     464void 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

     
    124124     * this lets us know we are done with step one (clicking).
    125125     */
    126126    bool                            m_Pressed;
     127private:
     128    CColor                          m_ButtonTextColor;
     129    CColor                          m_ButtonTextColorOver;
     130    CColor                          m_ButtonTextColorPressed;
     131    CColor                          m_ButtonTextColorDisabled;
     132
    127133};
    128134
    129135#endif
  • source/gui/GUIutil.cpp

     
    392392            QueryResetting(pObject);
    393393    }
    394394
    395     if (!SkipMessage)
     395    if (!SkipMessage) // XXX has to send msg when some changes.
    396396    {
    397397        SGUIMessage msg(GUIM_SETTINGS_UPDATED, Setting);
    398398        HandleMessage(pObject, msg);
  • source/gui/CButton.h

     
    5050
    5151/**
    5252 * Button
    53  * 
     53 *
    5454 * @see IGUIObject
    5555 * @see IGUIButtonBehavior
    5656 */
     
    8888     * Placement of text.
    8989     */
    9090    CPos m_TextPos;
     91
     92private:
     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;
    91103};
    92104
    93105#endif
  • source/gui/IGUIObject.cpp

     
    4040//-------------------------------------------------------------------
    4141//  Constructor / Destructor
    4242//-------------------------------------------------------------------
    43 IGUIObject::IGUIObject() : 
    44     m_pGUI(NULL), 
     43IGUIObject::IGUIObject() :
     44    m_pGUI(NULL),
    4545    m_pParent(NULL),
    4646    m_MouseHovering(false),
    4747    m_JSObject(NULL)
    4848{
    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);
    5858
    5959    // 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);
    6468
     69    SetAspectRatio(0.f);
    6570
     71
    6672    for (int i=0; i<6; i++)
    6773        m_LastClickTime[i]=0;
    6874}
     
    7379        std::map<CStr, SGUISetting>::iterator it;
    7480        for (it = m_Settings.begin(); it != m_Settings.end(); ++it)
    7581        {
    76             switch (it->second.m_Type)
     82            if ( it->second.m_dynamic )
    7783            {
    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*
    7988#define TYPE(t) case GUIST_##t: delete (t*)it->second.m_pSetting; break;
    8089#include "GUItypes.h"
    8190#undef TYPE
    82         default:
    83             debug_warn(L"Invalid setting type");
     91                    default:
     92                        debug_warn(L"Invalid setting type");
     93                }
    8494            }
    8595        }
    8696    }
     
    93103            delete it->second;
    94104        }
    95105    }
    96    
     106
    97107    if (m_JSObject)
    98108        JS_RemoveObjectRoot(g_ScriptingHost.getContext(), &m_JSObject);
    99109}
     
    103113//-------------------------------------------------------------------
    104114void IGUIObject::AddChild(IGUIObject *pChild)
    105115{
    106     // 
     116    //
    107117//  ENSURE(pChild);
    108118
    109119    pChild->SetParent(this);
     
    128138            // If anything went wrong, reverse what we did and throw
    129139            //  an exception telling it never added a child
    130140            m_Children.erase( m_Children.end()-1 );
    131            
     141
    132142            throw;
    133143        }
    134144    }
     
    166176// Notice if using this, the naming convention of GUIST_ should be strict.
    167177#define TYPE(type)                                  \
    168178    case GUIST_##type:                              \
    169         m_Settings[Name].m_pSetting = new type();   \
     179        setting.m_pSetting = new type();    \
    170180        break;
    171181
    172 void IGUIObject::AddSetting(const EGUISettingType &Type, const CStr& Name)
     182void IGUIObject::AddSetting(const EGUISettingType &Type, const CStr& Name, void * Pointer)
    173183{
    174184    // Is name already taken?
    175185    if (m_Settings.count(Name) >= 1)
    176186        return;
    177187
    178188    // 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 )
    182192    {
    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;
    185199
    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        }
    189209    }
    190210}
    191211#undef TYPE
     
    205225}
    206226
    207227CPos IGUIObject::GetMousePos() const
    208 { 
    209     return ((GetGUI())?(GetGUI()->m_MousePos):CPos()); 
     228{
     229    return ((GetGUI())?(GetGUI()->m_MousePos):CPos());
    210230}
    211231
    212232void IGUIObject::UpdateMouseOver(IGUIObject * const &pMouseOver)
     
    335355
    336356void IGUIObject::UpdateCachedSize()
    337357{
    338     bool absolute;
    339     GUI<bool>::GetSetting(this, "absolute", absolute);
     358//  bool absolute;
     359//  GUI<bool>::GetSetting(this, "absolute", absolute);
    340360
    341     float aspectratio = 0.f;
    342     GUI<float>::GetSetting(this, "aspectratio", aspectratio);
     361//  float aspectratio = 0.f;
     362//  GUI<float>::GetSetting(this, "aspectratio", aspectratio);
    343363
    344     CClientArea ca;
    345     GUI<CClientArea>::GetSetting(this, "size", ca);
    346    
     364//  CClientArea ca;
     365//  GUI<CClientArea>::GetSetting(this, "size", ca);
     366
    347367    // If absolute="false" and the object has got a parent,
    348368    //  use its cached size instead of the screen. Notice
    349369    //  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);
    352372    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));
    354374
    355375    // In a few cases, GUI objects have to resize to fill the screen
    356376    // but maintain a constant aspect ratio.
    357377    // Adjust the size to be the max possible, centered in the original size:
    358     if (aspectratio)
     378    if (m_AspectRatio)
    359379    {
    360         if (m_CachedActualSize.GetWidth() > m_CachedActualSize.GetHeight()*aspectratio)
     380        if (m_CachedActualSize.GetWidth() > m_CachedActualSize.GetHeight()*m_AspectRatio)
    361381        {
    362             float delta = m_CachedActualSize.GetWidth() - m_CachedActualSize.GetHeight()*aspectratio;
     382            float delta = m_CachedActualSize.GetWidth() - m_CachedActualSize.GetHeight()*m_AspectRatio;
    363383            m_CachedActualSize.left += delta/2.f;
    364384            m_CachedActualSize.right -= delta/2.f;
    365385        }
    366386        else
    367387        {
    368             float delta = m_CachedActualSize.GetHeight() - m_CachedActualSize.GetWidth()/aspectratio;
     388            float delta = m_CachedActualSize.GetHeight() - m_CachedActualSize.GetWidth()/m_AspectRatio;
    369389            m_CachedActualSize.bottom -= delta/2.f;
    370390            m_CachedActualSize.top += delta/2.f;
    371391        }
     
    405425
    406426float IGUIObject::GetBufferedZ() const
    407427{
    408     bool absolute;
    409     GUI<bool>::GetSetting(this, "absolute", absolute);
     428//  bool absolute;
     429//  GUI<bool>::GetSetting(this, "absolute", absolute);
    410430
    411     float Z;
    412     GUI<float>::GetSetting(this, "z", Z);
     431//  float Z;
     432//  GUI<float>::GetSetting(this, "z", Z);
    413433
    414     if (absolute)
    415         return Z;
     434    if ( m_Absolute )
     435        return m_Z;
    416436    else
    417437    {
    418438        if (GetParent())
    419             return GetParent()->GetBufferedZ() + Z;
     439            return GetParent()->GetBufferedZ() + m_Z;
    420440        else
    421441        {
    422442            // 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.
    424444            //  Also, you could consider those objects children to the screen resolution.
    425             return Z;
     445            return m_Z;
    426446        }
    427447    }
    428448}
     
    430450// TODO Gee: keep this function and all???
    431451void IGUIObject::CheckSettingsValidity()
    432452{
    433     bool hidden;
    434     GUI<bool>::GetSetting(this, "hidden", hidden);
     453//  bool hidden;
     454//  GUI<bool>::GetSetting(this, "hidden", hidden);
    435455
    436456    // If we hide an object, reset many of its parts
    437     if (hidden)
     457    if ( m_Hidden )
    438458    {
    439459        // Simulate that no object is hovered for this object and all its children
    440         //  why? because it's 
     460        //  why? because it's
    441461        try
    442462        {
    443463            GUI<IGUIObject*>::RecurseObject(0, this, &IGUIObject::UpdateMouseOver, NULL);
     
    574594
    575595void IGUIObject::SetFocus()
    576596{
    577     GetGUI()->m_FocusedObject = this; 
     597    GetGUI()->m_FocusedObject = this;
    578598}
    579599
    580600bool IGUIObject::IsFocused() const
    581601{
    582     return GetGUI()->m_FocusedObject == this; 
     602    return GetGUI()->m_FocusedObject == this;
    583603}
    584604
    585605bool IGUIObject::IsRootObject() const
     
    589609
    590610PSRETURN IGUIObject::LogInvalidSettings(const CStr8 &Setting) const
    591611{
    592     LOGWARNING(L"IGUIObject: setting %hs was not found on an object", 
     612    LOGWARNING(L"IGUIObject: setting %hs was not found on an object",
    593613        Setting.c_str());
    594614    return PSRETURN_GUI_InvalidSetting;
    595615}
     616
     617
     618void 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
     628void 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
     641void 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
     651void 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
     661void 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
     671void 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
     683void 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
     693void 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
     703void 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

     
    3131//-------------------------------------------------------------------
    3232CImage::CImage()
    3333{
    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);
    3838}
    3939
    4040CImage::~CImage()
    4141{
    4242}
    4343
    44 void CImage::Draw() 
     44void CImage::Draw()
    4545{
    4646    if (GetGUI())
    4747    {
    4848        float bz = GetBufferedZ();
    49 
     49/*
    5050        CGUISpriteInstance *sprite;
    5151        int cell_id;
    5252        GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite", sprite);
    5353        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);
    5656    }
    5757}
  • source/gui/CCheckBox.cpp

     
    3232//-------------------------------------------------------------------
    3333CCheckBox::CCheckBox()
    3434{
    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);
    5551
     52    m_BufferZone = 0.f;
     53    m_Font = L"default";
     54    m_Checked = false;
     55
    5656    // Add text
    5757    AddText(new SGUIText());
    5858}
     
    6868
    6969    ENSURE(m_GeneratedTexts.size()==1);
    7070
    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);
    8672}
    8773
    8874void CCheckBox::HandleMessage(SGUIMessage &Message)
     
    10086        GUI<bool>::GetSetting(this, "checked", checked);
    10187        checked = !checked;
    10288        GUI<bool>::SetSetting(this, "checked", checked);
    103        
     89
    10490    }   break;
    10591
    10692    default:
     
    10894    }
    10995}
    11096
    111 void CCheckBox::Draw() 
     97void CCheckBox::Draw()
    11298{
    11399    ////////// Gee: janwas, this is just temp to see it
    114100    glDisable(GL_TEXTURE_2D);
    115101    //////////
    116102
    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 
    127103    // Get line height
    128     CFont font (font_name);
     104    CFont font (m_Font);
    129105    float line_height = (float)font.GetHeight();
    130106
    131107    float bz = GetBufferedZ();
     
    134110    CRect rect;
    135111
    136112    rect.left =     m_CachedActualSize.left;
    137     rect.right =    rect.left + square_side;
     113    rect.right =    rect.left + m_SquareSide;
    138114
    139     if (square_side >= line_height)
     115    if (m_SquareSide >= line_height)
    140116        rect.top =  m_CachedActualSize.top;
    141117    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;
    143119
    144     rect.bottom =   rect.top + square_side;
     120    rect.bottom =   rect.top + m_SquareSide;
    145121
    146     CGUISpriteInstance *sprite, *sprite_over, *sprite_pressed, *sprite_disabled;
    147 
    148     if (checked)
     122    if (m_Checked)
    149123    {
    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);
    154131    }
    155132    else
    156133    {
    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);
    161141    }
    162 
    163     DrawButton(rect,
    164                bz,
    165                *sprite,
    166                *sprite_over,
    167                *sprite_pressed,
    168                *sprite_disabled,
    169                cell_id);
    170 
    171142    CColor color = ChooseColor();
    172143
    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);
    174145
    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;
    177148
    178149    IGUITextOwner::Draw(0, color, text_pos, bz+0.1f, m_CachedActualSize);
    179150}
  • source/gui/CText.h

     
    5353
    5454/**
    5555 * Text field that just displays static text.
    56  * 
     56 *
    5757 * @see IGUIObject
    5858 */
    5959class CText : public IGUIScrollBarOwner, public IGUITextOwner
     
    9595     * Placement of text. Ignored when scrollbars are active.
    9696     */
    9797    CPos m_TextPos;
     98private:
     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
    98115};
    99116
    100117#endif
  • source/gui/CTooltip.cpp

     
    2626
    2727CTooltip::CTooltip()
    2828{
    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);
    3938
    4039    // 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);
    4342
    4443    // Private settings:
    45     AddSetting(GUIST_CPos,                  "_mousepos");
     44    AddSetting(GUIST_CPos,                  "_mousepos",        &m_MousePos);
    4645
     46    m_BufferZone = 0.f;
     47    m_Font = L"default";
     48
    4749    // Defaults
    4850    GUI<int>::SetSetting(this, "delay", 500);
    4951    GUI<EVAlign>::SetSetting(this, "anchor", EVAlign_Bottom);
     
    6466
    6567    ENSURE(m_GeneratedTexts.size()==1);
    6668
    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);
    7070
    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 
    8371    // Position the tooltip relative to the mouse:
    8472
    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 
    9173    // TODO: Calculate the actual width of the wrapped text and use that.
    9274    // (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);
    9476    float textheight = m_GeneratedTexts[0]->m_Size.cy;
    9577
    9678    CClientArea size;
    97     size.pixel.left = mousepos.x + offset.x;
     79    size.pixel.left = m_MousePos.x + m_Offset.x;
    9880    size.pixel.right = size.pixel.left + textwidth;
    99     switch (anchor)
     81    switch (m_Anchor)
    10082    {
    10183    case EVAlign_Top:
    102         size.pixel.top = mousepos.y + offset.y;
     84        size.pixel.top = m_MousePos.y + m_Offset.y;
    10385        size.pixel.bottom = size.pixel.top + textheight;
    10486        break;
    10587    case EVAlign_Bottom:
    106         size.pixel.bottom = mousepos.y + offset.y;
     88        size.pixel.bottom = m_MousePos.y + m_Offset.y;
    10789        size.pixel.top = size.pixel.bottom - textheight;
    10890        break;
    10991    case EVAlign_Center:
    110         size.pixel.top = mousepos.y + offset.y - textheight/2.f;
     92        size.pixel.top = m_MousePos.y + m_Offset.y - textheight/2.f;
    11193        size.pixel.bottom = size.pixel.top + textwidth;
    11294        break;
    11395    default:
     
    129111        size.pixel.right -= size.pixel.left, size.pixel.left = 0.f;
    130112    else if (size.pixel.right > screenw)
    131113        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);
    134117}
    135118
    136119void CTooltip::HandleMessage(SGUIMessage &Message)
     
    138121    IGUITextOwner::HandleMessage(Message);
    139122}
    140123
    141 void CTooltip::Draw() 
     124void CTooltip::Draw()
    142125{
    143     float z = 900.f; // TODO: Find a nicer way of putting the tooltip on top of everything else
    144 
    145126    if (GetGUI())
    146127    {
    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
    149129
    150130        // Normally IGUITextOwner will handle this updating but since SetupText can modify the position
    151131        // we need to call it now *before* we do the rest of the drawing
     
    155135            m_GeneratedTextsValid = true;
    156136        }
    157137
    158         GetGUI()->DrawSprite(*sprite, 0, z, m_CachedActualSize);
     138        GetGUI()->DrawSprite(m_Sprite, 0, z, m_CachedActualSize);
    159139
    160         CColor color;
    161         GUI<CColor>::GetSetting(this, "textcolor", color);
    162 
    163140        // 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);
    165142    }
    166143}