Ticket #3354: gui_cleanup_inc_on_2.patch

File gui_cleanup_inc_on_2.patch, 63.5 KB (added by leper, 9 years ago)

incremental patch on top of gui_cleanup_2.patch. Changes: Trailing spaces, one if-else style fix, one new const function to make one other const, one new const func.

  • source/gui/CButton.cpp

    diff --git a/source/gui/CButton.cpp b/source/gui/CButton.cpp
    index 0a6faed..76b5fb0 100644
    a b void CButton::HandleMessage(SGUIMessage& Message)  
    8383    IGUITextOwner::HandleMessage(Message);
    8484}
    8585
    86 void CButton::Draw() 
     86void CButton::Draw()
    8787{
    8888    float bz = GetBufferedZ();
    8989
  • source/gui/CButton.h

    diff --git a/source/gui/CButton.h b/source/gui/CButton.h
    index f869019..3d66d95 100644
    a b  
    2222
    2323/**
    2424 * Button
    25  * 
     25 *
    2626 * @see IGUIObject
    2727 * @see IGUIButtonBehavior
    2828 */
  • source/gui/CCheckBox.cpp

    diff --git a/source/gui/CCheckBox.cpp b/source/gui/CCheckBox.cpp
    index 5921fa3..095f1f8 100644
    a b void CCheckBox::HandleMessage(SGUIMessage& Message)  
    107107    }
    108108}
    109109
    110 void CCheckBox::Draw() 
     110void CCheckBox::Draw()
    111111{
    112112    float bz = GetBufferedZ();
    113113    bool checked;
    void CCheckBox::Draw()  
    135135        GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_disabled", sprite_disabled);
    136136    }
    137137
    138     DrawButton(m_CachedActualSize, 
     138    DrawButton(m_CachedActualSize,
    139139               bz,
    140140               *sprite,
    141141               *sprite_over,
  • source/gui/CCheckBox.h

    diff --git a/source/gui/CCheckBox.h b/source/gui/CCheckBox.h
    index b3a0f09..f924e75 100644
    a b  
    2222
    2323/**
    2424 * CheckBox
    25  * 
     25 *
    2626 * @see IGUIObject
    2727 * @see IGUISettingsObject
    2828 * @see IGUIButtonBehavior
  • source/gui/CDropDown.cpp

    diff --git a/source/gui/CDropDown.cpp b/source/gui/CDropDown.cpp
    index c2b0e14..2d436d7 100644
    a b CDropDown::CDropDown()  
    4444    AddSetting(GUIST_CGUISpriteInstance,    "sprite2_pressed");
    4545    AddSetting(GUIST_CGUISpriteInstance,    "sprite2_disabled");
    4646    AddSetting(GUIST_EVAlign,               "text_valign");
    47    
     47
    4848    // Add these in CList! And implement TODO
    4949    //AddSetting(GUIST_CColor,              "textcolor_over");
    5050    //AddSetting(GUIST_CColor,              "textcolor_pressed");
    void CDropDown::HandleMessage(SGUIMessage& Message)  
    8282            Message.value == "button_width")
    8383        {
    8484            SetupListRect();
    85         }       
     85        }
    8686
    8787        break;
    8888    }
    void CDropDown::HandleMessage(SGUIMessage& Message)  
    119119                set = i;
    120120            }
    121121        }
    122        
     122
    123123        if (set != -1)
    124124        {
    125125            //GUI<int>::SetSetting(this, "selected", set);
    InReaction CDropDown::ManuallyHandleEvent(const SDL_Event_* ev)  
    293293    if (ev->ev.type == SDL_KEYDOWN)
    294294    {
    295295        int szChar = ev->ev.key.keysym.sym;
    296        
     296
    297297        switch (szChar)
    298298        {
    299299        case '\r':
    InReaction CDropDown::ManuallyHandleEvent(const SDL_Event_* ev)  
    332332                    m_InputBuffer = szChar;
    333333                else
    334334                    m_InputBuffer += szChar;
    335            
     335
    336336                m_TimeOfLastInput = timer_Time();
    337            
     337
    338338                CGUIList* pList;
    339339                GUI<CGUIList>::GetSettingPointer(this, "list", pList);
    340340                // let's look for the closest element
    bool CDropDown::MouseOver()  
    429429        return m_CachedActualSize.PointInside(GetMousePos());
    430430}
    431431
    432 void CDropDown::Draw() 
     432void CDropDown::Draw()
    433433{
    434434    if (!GetGUI())
    435435        return;
    void CDropDown::Draw()  
    468468            GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_disabled", sprite2_second);
    469469            GetGUI()->DrawSprite(GUI<>::FallBackSprite(*sprite2_second, *sprite2), cell_id, bz+0.05f, rect);
    470470        }
    471         else
    472         if (m_Open)
     471        else if (m_Open)
    473472        {
    474473            GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_pressed", sprite2_second);
    475474            GetGUI()->DrawSprite(GUI<>::FallBackSprite(*sprite2_second, *sprite2), cell_id, bz+0.05f, rect);
    476475        }
    477         else
    478         if (m_MouseHovering)
     476        else if (m_MouseHovering)
    479477        {
    480478            GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_over", sprite2_second);
    481479            GetGUI()->DrawSprite(GUI<>::FallBackSprite(*sprite2_second, *sprite2), cell_id, bz+0.05f, rect);
    482480        }
    483         else 
     481        else
    484482            GetGUI()->DrawSprite(*sprite2, cell_id, bz+0.05f, rect);
    485483    }
    486484
    void CDropDown::Draw()  
    506504            *scrollbar = false;
    507505
    508506        DrawList(m_ElementHighlight, "sprite_list", "sprite_selectarea", "textcolor");
    509        
     507
    510508        if (m_HideScrollBar)
    511509            *scrollbar = old;
    512510    }
  • source/gui/CDropDown.h

    diff --git a/source/gui/CDropDown.h b/source/gui/CDropDown.h
    index 8d2c604..86e680a 100644
    a b protected:  
    8383     * made that can change the visual.
    8484     */
    8585    void SetupText();
    86    
     86
    8787    // Sets up the cached GetListRect. Decided whether it should
    8888    //  have a scrollbar, and so on.
    8989    virtual void SetupListRect();
    protected:  
    111111    //  it is set to "selected", but then when moving the mouse it will
    112112    //  change.
    113113    int m_ElementHighlight;
    114    
     114
    115115    // Stores any text entered by the user for quick access to an element
    116116    // (ie if you type "acro" it will take you to acropolis).
    117117    std::string m_InputBuffer;
    118    
     118
    119119    // used to know if we want to restart anew or add to m_inputbuffer.
    120120    double m_TimeOfLastInput;
    121121
  • source/gui/CGUI.cpp

    diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp
    index 169d388..f16c96d 100644
    a b InReaction CGUI::HandleEvent(const SDL_Event_* ev)  
    8282        m_MousePos = CPos((float)ev->ev.motion.x * g_GuiScale, (float)ev->ev.motion.y * g_GuiScale);
    8383
    8484        SGUIMessage msg(GUIM_MOUSE_MOTION);
    85         GUI<SGUIMessage>::RecurseObject(GUIRR_HIDDEN | GUIRR_GHOST, m_BaseObject, 
    86                                         &IGUIObject::HandleMessage, 
     85        GUI<SGUIMessage>::RecurseObject(GUIRR_HIDDEN | GUIRR_GHOST, m_BaseObject,
     86                                        &IGUIObject::HandleMessage,
    8787                                        msg);
    8888    }
    8989
    InReaction CGUI::HandleEvent(const SDL_Event_* ev)  
    125125        // Now we'll call UpdateMouseOver on *all* objects,
    126126        //  we'll input the one hovered, and they will each
    127127        //  update their own data and send messages accordingly
    128         GUI<IGUIObject*>::RecurseObject(GUIRR_HIDDEN | GUIRR_GHOST, m_BaseObject, 
    129                                         &IGUIObject::UpdateMouseOver, 
     128        GUI<IGUIObject*>::RecurseObject(GUIRR_HIDDEN | GUIRR_GHOST, m_BaseObject,
     129                                        &IGUIObject::UpdateMouseOver,
    130130                                        pNearest);
    131131
    132132        if (ev->ev.type == SDL_MOUSEBUTTONDOWN)
    InReaction CGUI::HandleEvent(const SDL_Event_* ev)  
    185185                {
    186186                    double timeElapsed = timer_Time() - pNearest->m_LastClickTime[SDL_BUTTON_LEFT];
    187187                    pNearest->m_LastClickTime[SDL_BUTTON_LEFT] = timer_Time();
    188                    
     188
    189189                    //Double click?
    190190                    if (timeElapsed < SELECT_DBLCLICK_RATE)
    191191                    {
    InReaction CGUI::HandleEvent(const SDL_Event_* ev)  
    202202                {
    203203                    double timeElapsed = timer_Time() - pNearest->m_LastClickTime[SDL_BUTTON_RIGHT];
    204204                    pNearest->m_LastClickTime[SDL_BUTTON_RIGHT] = timer_Time();
    205                    
     205
    206206                    //Double click?
    207207                    if (timeElapsed < SELECT_DBLCLICK_RATE)
    208208                    {
    InReaction CGUI::HandleEvent(const SDL_Event_* ev)  
    217217            }
    218218
    219219            // Reset all states on all visible objects
    220             GUI<>::RecurseObject(GUIRR_HIDDEN, m_BaseObject, 
     220            GUI<>::RecurseObject(GUIRR_HIDDEN, m_BaseObject,
    221221                                    &IGUIObject::ResetStates);
    222222
    223223            // Since the hover state will have been reset, we reload it.
    224             GUI<IGUIObject*>::RecurseObject(GUIRR_HIDDEN | GUIRR_GHOST, m_BaseObject, 
    225                                             &IGUIObject::UpdateMouseOver, 
     224            GUI<IGUIObject*>::RecurseObject(GUIRR_HIDDEN | GUIRR_GHOST, m_BaseObject,
     225                                            &IGUIObject::UpdateMouseOver,
    226226                                            pNearest);
    227227        }
    228228    }
    InReaction CGUI::HandleEvent(const SDL_Event_* ev)  
    263263            (ev->ev.type == SDL_KEYDOWN &&
    264264                ev->ev.key.keysym.sym != SDLK_ESCAPE &&
    265265                !g_keys[SDLK_LCTRL] && !g_keys[SDLK_RCTRL] &&
    266                 !g_keys[SDLK_LALT] && !g_keys[SDLK_RALT]) 
     266                !g_keys[SDLK_LALT] && !g_keys[SDLK_RALT])
    267267            || ev->ev.type == SDL_HOTKEYDOWN
    268268#if SDL_VERSION_ATLEAST(2, 0, 0)
    269269            || ev->ev.type == SDL_TEXTINPUT || ev->ev.type == SDL_TEXTEDITING
    InReaction CGUI::HandleEvent(const SDL_Event_* ev)  
    281281void CGUI::TickObjects()
    282282{
    283283    CStr action = "tick";
    284     GUI<CStr>::RecurseObject(0, m_BaseObject, 
     284    GUI<CStr>::RecurseObject(0, m_BaseObject,
    285285                            &IGUIObject::ScriptEvent, action);
    286286
    287287    // Also update tooltips:
    void CGUI::SendEventToAll(const CStr& EventName)  
    297297    // (sending events here) wasn't converting to lower case,
    298298    // leading to a similar problem.
    299299    // now fixed; case is irrelevant since all are converted to lower.
    300     GUI<CStr>::RecurseObject(0, m_BaseObject, 
     300    GUI<CStr>::RecurseObject(0, m_BaseObject,
    301301        &IGUIObject::ScriptEvent, EventName.LowerCase());
    302302}
    303303
    CGUI::CGUI(const shared_ptr<ScriptRuntime>& runtime)  
    308308    GuiScriptingInit(*m_ScriptInterface);
    309309    m_ScriptInterface->LoadGlobalScripts();
    310310    m_BaseObject = new CGUIDummyObject;
    311     m_BaseObject->SetGUI(this); 
     311    m_BaseObject->SetGUI(this);
    312312}
    313313
    314314CGUI::~CGUI()
    struct SGenerateTextImage  
    508508
    509509    // Some help functions
    510510    // TODO Gee: CRect => CPoint ?
    511     void SetupSpriteCall(const bool Left, SGUIText::SSpriteCall& SpriteCall, 
     511    void SetupSpriteCall(const bool Left, SGUIText::SSpriteCall& SpriteCall,
    512512                         const float width, const float y,
    513                          const CSize& Size, const CStr& TextureName, 
     513                         const CSize& Size, const CStr& TextureName,
    514514                         const float BufferZone, const int CellID)
    515515    {
    516516        // TODO Gee: Temp hardcoded values
    517517        SpriteCall.m_Area.top = y+BufferZone;
    518518        SpriteCall.m_Area.bottom = y+BufferZone + Size.cy;
    519        
     519
    520520        if (Left)
    521521        {
    522522            SpriteCall.m_Area.left = BufferZone;
    SGUIText CGUI::GenerateText(const CGUIString& string, const CStrW& FontW, const  
    585585                                FirstLine);
    586586
    587587        // Loop through our images queues, to see if images has been added.
    588        
     588
    589589        // Check if this has already been processed.
    590590        //  Also, floating images are only applicable if Word-Wrapping is on
    591591        if (WordWrapping && i > pos_last_img)
    SGUIText CGUI::GenerateText(const CGUIString& string, const CStrW& FontW, const  
    604604                    if (!Images[j].empty())
    605605                        _y = std::max(y, Images[j].back().m_YTo);
    606606                    else
    607                         _y = y; 
     607                        _y = y;
    608608
    609609                    // Get Size from Icon database
    610610                    SGUIIcon icon = GetIcon(imgname);
    SGUIText CGUI::GenerateText(const CGUIString& string, const CStrW& FontW, const  
    660660
    661661                        union_from = std::max(y, img.m_YFrom);
    662662                        union_to = std::min(y+prelim_line_height, img.m_YTo);
    663                        
     663
    664664                        // The union is not empty
    665665                        if (union_to > union_from)
    666666                        {
    SGUIText CGUI::GenerateText(const CGUIString& string, const CStrW& FontW, const  
    748748
    749749                // Defaults
    750750                string.GenerateTextCall(this, Feedback2, Font,
    751                                         string.m_Words[j], string.m_Words[j+1], 
     751                                        string.m_Words[j], string.m_Words[j+1],
    752752                                        FirstLine, pObject);
    753753
    754754                // Iterate all and set X/Y values
    void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec  
    13101310            if (!object->HandleAdditionalChildren(child, pFile))
    13111311                LOGERROR("GUI: (object: %s) Reading unknown children for its type", object->GetPresentableName().c_str());
    13121312        }
    1313     } 
     1313    }
    13141314
    13151315    //
    13161316    //  Check if Z wasn't manually set
    void CGUI::Xeromyces_ReadSprite(XMBElement Element, CXeromyces* pFile)  
    14371437{
    14381438    // Sprite object we're adding
    14391439    CGUISprite* Sprite = new CGUISprite;
    1440    
     1440
    14411441    // and what will be its reference name
    14421442    CStr name;
    14431443
    void CGUI::Xeromyces_ReadImage(XMBElement Element, CXeromyces* pFile, CGUISprite  
    15041504
    15051505    // Image object we're adding
    15061506    SGUIImage* Image = new SGUIImage;
    1507    
     1507
    15081508    // Set defaults to "0 0 100% 100%"
    15091509    Image->m_TextureSize = CClientArea(CRect(0, 0, 0, 0), CRect(0, 0, 100, 100));
    15101510    Image->m_Size = CClientArea(CRect(0, 0, 0, 0), CRect(0, 0, 100, 100));
    1511    
     1511
    15121512    // TODO Gee: Setup defaults here (or maybe they are in the SGUIImage ctor)
    15131513
    15141514    //
    void CGUI::Xeromyces_ReadScrollBarStyle(XMBElement Element, CXeromyces* pFile)  
    17261726    for (XMBAttribute attr : Element.GetAttributes())
    17271727    {
    17281728        CStr attr_name = pFile->GetAttributeString(attr.Name);
    1729         CStr attr_value(attr.Value); 
     1729        CStr attr_value(attr.Value);
    17301730
    17311731        if (attr_value == "null")
    17321732            continue;
    void CGUI::Xeromyces_ReadScrollBarStyle(XMBElement Element, CXeromyces* pFile)  
    17921792    }
    17931793
    17941794    //
    1795     //  Add to CGUI 
     1795    //  Add to CGUI
    17961796    //
    17971797
    17981798    m_ScrollBarStyles[name] = scrollbar;
    void CGUI::Xeromyces_ReadColor(XMBElement Element, CXeromyces* pFile)  
    18711871    CColor color;
    18721872    CStr name = attributes.GetNamedItem(pFile->GetAttributeID("name"));
    18731873
    1874     // Try parsing value 
     1874    // Try parsing value
    18751875    CStr value(Element.GetText());
    18761876    if (value.empty())
    18771877        return;
  • source/gui/CGUI.h

    diff --git a/source/gui/CGUI.h b/source/gui/CGUI.h
    index 87e6f2b..d6d421a 100644
    a b ERROR_TYPE(GUI, JSOpenFailed);  
    4949 */
    5050struct SGUIStyle
    5151{
    52     // A list of defaults for 
     52    // A list of defaults for
    5353    std::map<CStr, CStrW> m_SettingsDefaults;
    5454};
    5555
    class GUITooltip;  
    7474class CGUI
    7575{
    7676    NONCOPYABLE(CGUI);
    77    
     77
    7878    friend class IGUIObject;
    7979    friend class IGUIScrollBarOwner;
    8080    friend class CInternalCGUIAccessorBase;
    public:  
    9191     * Initializes the GUI, needs to be called before the GUI is used
    9292     */
    9393    void Initialize();
    94    
     94
    9595    /**
    9696     * Performs processing that should happen every frame
    9797     * (including sending the "Tick" event to scripts)
    public:  
    185185     * The GUI needs to have all object types inputted and
    186186     * their constructors. Also it needs to associate a type
    187187     * by a string name of the type.
    188      * 
     188     *
    189189     * To add a type:
    190190     * @code
    191191     * AddObjectType("button", &CButton::ConstructObject);
    public:  
    216216     * will be sent to the Renderer. Also, horizontal alignment
    217217     * is taken into acount in this method but NOT vertical alignment.
    218218     *
    219      * Done through the CGUI since it can communicate with 
     219     * Done through the CGUI since it can communicate with
    220220     *
    221221     * @param Text Text to generate SGUIText object from
    222222     * @param Font Default font, notice both Default color and default font
    223223     *        can be changed by tags.
    224224     * @param Width Width, 0 if no word-wrapping.
    225225     * @param BufferZone space between text and edge, and space between text and images.
    226      * @param pObject Optional parameter for error output. Used *only* if error parsing fails, 
    227      *        and we need to be able to output which object the error occured in to aid the user. 
     226     * @param pObject Optional parameter for error output. Used *only* if error parsing fails,
     227     *        and we need to be able to output which object the error occured in to aid the user.
    228228     */
    229229    SGUIText GenerateText(const CGUIString& Text, const CStrW& Font, const float& Width, const float& BufferZone, const IGUIObject* pObject = NULL);
    230230
    public:  
    244244     * Returns false if it fails.
    245245     */
    246246    bool GetPreDefinedColor(const CStr& name, CColor& Output) const;
    247    
     247
    248248    shared_ptr<ScriptInterface> GetScriptInterface() { return m_ScriptInterface; };
    249249    jsval GetGlobalObject() { return m_ScriptInterface->GetGlobalObject(); };
    250250
    private:  
    263263
    264264    /**
    265265     * Adds an object to the GUI's object database
    266      * Private, since you can only add objects through 
     266     * Private, since you can only add objects through
    267267     * XML files. Why? Because it enables the GUI to
    268268     * be much more encapsulated and safe.
    269269     *
    private:  
    512512     * @see LoadXmlFile()
    513513     */
    514514    void Xeromyces_ReadIcon(XMBElement Element, CXeromyces* pFile);
    515    
     515
    516516    /**
    517517     * Reads in the element \<tooltip\> (the XMBElement) and stores the
    518518     * result as an object with the name __tooltip_#.
    private:  
    547547    /** @name Miscellaneous */
    548548    //--------------------------------------------------------
    549549    //@{
    550    
     550
    551551    shared_ptr<ScriptInterface> m_ScriptInterface;
    552552
    553553    /**
    554      * don't want to pass this around with the 
     554     * don't want to pass this around with the
    555555     * ChooseMouseOverAndClosest broadcast -
    556556     * we'd need to pack this and pNearest in a struct
    557557     */
    private:  
    593593     */
    594594    IGUIObject* m_FocusedObject;
    595595
    596     /** 
     596    /**
    597597     * Just pointers for fast name access, each object
    598598     * is really constructed within its parent for easy
    599599     * recursive management.
  • source/gui/CGUIScrollBarVertical.cpp

    diff --git a/source/gui/CGUIScrollBarVertical.cpp b/source/gui/CGUIScrollBarVertical.cpp
    index 3eb770b..0a08a5e 100644
    a b void CGUIScrollBarVertical::Draw()  
    6161        // Draw background
    6262        GetGUI()->DrawSprite(GetStyle()->m_SpriteBackVertical,
    6363                             0,
    64                              m_Z+0.1f, 
     64                             m_Z+0.1f,
    6565                             CRect(outline.left,
    6666                                   outline.top+(GetStyle()->m_UseEdgeButtons?GetStyle()->m_Width:0),
    6767                                   outline.right,
    void CGUIScrollBarVertical::Draw()  
    9595            }
    9696            else
    9797                button_bottom = &GetStyle()->m_SpriteButtonBottom;
    98            
     98
    9999            // Draw top button
    100100            GetGUI()->DrawSprite(*button_top,
    101101                                 0,
    void CGUIScrollBarVertical::Draw()  
    105105                                       outline.right,
    106106                                       outline.top+GetStyle()->m_Width)
    107107                                );
    108            
     108
    109109            // Draw bottom button
    110110            GetGUI()->DrawSprite(*button_bottom,
    111111                                 0,
    void CGUIScrollBarVertical::Draw()  
    123123                             m_Z + 0.2f,
    124124                             GetBarRect());
    125125    }
    126 } 
     126}
    127127
    128128void CGUIScrollBarVertical::HandleMessage(SGUIMessage& Message)
    129129{
  • source/gui/CGUISprite.cpp

    diff --git a/source/gui/CGUISprite.cpp b/source/gui/CGUISprite.cpp
    index ce7394c..8153d30 100644
    a b  
    1 /* Copyright (C) 2015 Wildfire Games 
     1/* Copyright (C) 2015 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
  • source/gui/CGUISprite.h

    diff --git a/source/gui/CGUISprite.h b/source/gui/CGUISprite.h
    index 181c134..2989f29 100644
    a b public:  
    6161        m_Effects(NULL), m_Border(false), m_DeltaZ(0.f)
    6262    {
    6363    }
    64    
     64
    6565    ~SGUIImage()
    6666    {
    6767        delete m_Effects;
  • source/gui/CImage.cpp

    diff --git a/source/gui/CImage.cpp b/source/gui/CImage.cpp
    index 18c329d..1c2ae63 100644
    a b CImage::~CImage()  
    3535{
    3636}
    3737
    38 void CImage::Draw() 
     38void CImage::Draw()
    3939{
    4040    if (!GetGUI())
    4141        return;
  • source/gui/CImage.h

    diff --git a/source/gui/CImage.h b/source/gui/CImage.h
    index fa46371..5427149 100644
    a b  
    2929 * without functionality used, and that is a lot of unnecessary
    3030 * overhead. That's why I thought I'd go with an intuitive
    3131 * control.
    32  * 
     32 *
    3333 * @see IGUIObject
    3434 */
    3535class CImage : public IGUIObject
  • source/gui/CInput.cpp

    diff --git a/source/gui/CInput.cpp b/source/gui/CInput.cpp
    index d05d849..cb788d9 100644
    a b InReaction CInput::ManuallyHandleEvent(const SDL_Event_* ev)  
    226226                if (m_iBufferPos == (int)pCaption->length())
    227227                    *pCaption = pCaption->Left((long)pCaption->length()-1);
    228228                else
    229                     *pCaption = pCaption->Left(m_iBufferPos-1) + 
     229                    *pCaption = pCaption->Left(m_iBufferPos-1) +
    230230                                pCaption->Right((long)pCaption->length()-m_iBufferPos);
    231231
    232232                --m_iBufferPos;
    InReaction CInput::ManuallyHandleEvent(const SDL_Event_* ev)  
    248248                if (pCaption->empty() || m_iBufferPos == (int)pCaption->length())
    249249                    break;
    250250
    251                 *pCaption = pCaption->Left(m_iBufferPos) + 
     251                *pCaption = pCaption->Left(m_iBufferPos) +
    252252                            pCaption->Right((long)pCaption->length()-(m_iBufferPos+1));
    253253
    254254                UpdateText(m_iBufferPos, m_iBufferPos+1, m_iBufferPos);
    InReaction CInput::ManuallyHandleEvent(const SDL_Event_* ev)  
    326326                else if (!SelectingText())
    327327                    m_iBufferPos_Tail = m_iBufferPos;
    328328
    329                 if (m_iBufferPos > 0) 
     329                if (m_iBufferPos > 0)
    330330                    --m_iBufferPos;
    331331            }
    332332            else
    InReaction CInput::ManuallyHandleHotkeyEvent(const SDL_Event_* ev)  
    556556            if (m_iBufferPos == (int)pCaption->length())
    557557                *pCaption += text;
    558558            else
    559                 *pCaption = pCaption->Left(m_iBufferPos) + text + 
     559                *pCaption = pCaption->Left(m_iBufferPos) + text +
    560560                pCaption->Right((long) pCaption->length()-m_iBufferPos);
    561561
    562562            UpdateText(m_iBufferPos, m_iBufferPos, m_iBufferPos+1);
    InReaction CInput::ManuallyHandleHotkeyEvent(const SDL_Event_* ev)  
    642642            DeleteCurSelection();
    643643        }
    644644        return IN_HANDLED;
    645     } 
     645    }
    646646    else if (hotkey == "text.delete.right")
    647647    {
    648648        m_WantedX = 0.0f;
    void CInput::HandleMessage(SGUIMessage& Message)  
    802802
    803803        // Update scroll-bar
    804804        // TODO Gee: (2004-09-01) Is this really updated each time it should?
    805         if (scrollbar && 
    806             (Message.value == CStr("size") || 
     805        if (scrollbar &&
     806            (Message.value == CStr("size") ||
    807807             Message.value == CStr("z") ||
    808808             Message.value == CStr("absolute")))
    809809        {
    void CInput::HandleMessage(SGUIMessage& Message)  
    828828            m_iBufferPos_Tail = -1; // position change resets selection
    829829        }
    830830
    831         if (Message.value == CStr("size") || 
     831        if (Message.value == CStr("size") ||
    832832            Message.value == CStr("z") ||
    833             Message.value == CStr("font") || 
     833            Message.value == CStr("font") ||
    834834            Message.value == CStr("absolute") ||
    835835            Message.value == CStr("caption") ||
    836836            Message.value == CStr("scrollbar") ||
    void CInput::Draw()  
    12251225    // Set the Z to somewhat more, so we can draw a selected area between the
    12261226    //  the control and the text.
    12271227    textRenderer.Translate(
    1228         (float)(int)(m_CachedActualSize.left) + buffer_zone, 
     1228        (float)(int)(m_CachedActualSize.left) + buffer_zone,
    12291229        (float)(int)(m_CachedActualSize.top+h) + buffer_zone,
    12301230        bz+0.1f);
    12311231
    void CInput::Draw()  
    12911291                if (it->m_ListStart + i == VirtualFrom)
    12921292                {
    12931293                    // we won't actually draw it now, because we don't
    1294                     //  know the width of each glyph to that position. 
     1294                    //  know the width of each glyph to that position.
    12951295                    //  we need to go along with the iteration, and
    12961296                    //  make a mark where the box started:
    12971297                    drawing_box = true; // will turn false when finally rendered.
    void CInput::Draw()  
    13271327                    // Set 'rect' depending on if it's a multiline control, or a one-line control
    13281328                    if (multiline)
    13291329                    {
    1330                         rect = CRect(m_CachedActualSize.left+box_x+buffer_zone, 
     1330                        rect = CRect(m_CachedActualSize.left+box_x+buffer_zone,
    13311331                                   m_CachedActualSize.top+buffered_y+(h-ls)/2,
    1332                                    m_CachedActualSize.left+x_pointer+buffer_zone, 
     1332                                   m_CachedActualSize.left+x_pointer+buffer_zone,
    13331333                                   m_CachedActualSize.top+buffered_y+(h+ls)/2);
    13341334
    13351335                        if (rect.bottom < m_CachedActualSize.top)
    void CInput::Draw()  
    13431343                    }
    13441344                    else // if one-line
    13451345                    {
    1346                         rect = CRect(m_CachedActualSize.left+box_x+buffer_zone-m_HorizontalScroll, 
     1346                        rect = CRect(m_CachedActualSize.left+box_x+buffer_zone-m_HorizontalScroll,
    13471347                                   m_CachedActualSize.top+buffered_y+(h-ls)/2,
    1348                                    m_CachedActualSize.left+x_pointer+buffer_zone-m_HorizontalScroll, 
     1348                                   m_CachedActualSize.left+x_pointer+buffer_zone-m_HorizontalScroll,
    13491349                                   m_CachedActualSize.top+buffered_y+(h+ls)/2);
    13501350
    13511351                        if (rect.left < m_CachedActualSize.left)
    void CInput::Draw()  
    14261426                }
    14271427
    14281428                // End of selected area, change back color
    1429                 if (SelectingText() && 
     1429                if (SelectingText() &&
    14301430                    it->m_ListStart + i == VirtualTo)
    14311431                {
    14321432                    using_selected_color = false;
    void CInput::Draw()  
    14401440                    textRenderer.Put(0.0f, 0.0f, L"_");
    14411441
    14421442                // Drawing selected area
    1443                 if (SelectingText() && 
     1443                if (SelectingText() &&
    14441444                    it->m_ListStart + i >= VirtualFrom &&
    14451445                    it->m_ListStart + i < VirtualTo &&
    14461446                    using_selected_color == false)
    void CInput::UpdateText(int from, int to_before, int to_after)  
    15511551
    15521552        std::list<SRow>::iterator destroy_row_from;
    15531553        std::list<SRow>::iterator destroy_row_to;
    1554         // Used to check if the above has been set to anything, 
     1554        // Used to check if the above has been set to anything,
    15551555        //  previously a comparison like:
    15561556        //  destroy_row_from == std::list<SRow>::iterator()
    15571557        // ... was used, but it didn't work with GCC.
    void CInput::UpdateText(int from, int to_before, int to_after)  
    15631563        //  to be redone. And when going along, we'll delete a row at a time
    15641564        //  when continuing to see how much more after 'to' we need to remake.
    15651565        int i = 0;
    1566         for (std::list<SRow>::iterator it = m_CharacterPositions.begin(); 
     1566        for (std::list<SRow>::iterator it = m_CharacterPositions.begin();
    15671567             it != m_CharacterPositions.end();
    15681568             ++it, ++i)
    15691569        {
    void CInput::UpdateText(int from, int to_before, int to_after)  
    15781578
    15791579                // For the rare case that we might remove characters to a word
    15801580                //  so that it suddenly fits on the previous row,
    1581                 //  we need to by standards re-do the whole previous line too 
     1581                //  we need to by standards re-do the whole previous line too
    15821582                //  (if one exists)
    15831583                if (destroy_row_from != m_CharacterPositions.begin())
    15841584                    --destroy_row_from;
    void CInput::UpdateText(int from, int to_before, int to_after)  
    15921592                destroy_row_to_used = true;
    15931593
    15941594                // If it isn't the last row, we'll add another row to delete,
    1595                 //  just so we can see if the last restorted line is 
     1595                //  just so we can see if the last restorted line is
    15961596                //  identical to what it was before. If it isn't, then we'll
    15971597                //  have to continue.
    15981598                // 'check_point_row_start' is where we store how the that
    void CInput::UpdateText(int from, int to_before, int to_after)  
    17461746        //  also check if the current line isn't the end
    17471747        if (to_before != -1 && i == to-1 && current_line != m_CharacterPositions.end())
    17481748        {
    1749             // check all rows and see if any existing 
     1749            // check all rows and see if any existing
    17501750            if (row.m_ListStart != check_point_row_start)
    17511751            {
    17521752                std::list<SRow>::iterator destroy_row_from;
    17531753                std::list<SRow>::iterator destroy_row_to;
    1754                 // Are used to check if the above has been set to anything, 
     1754                // Are used to check if the above has been set to anything,
    17551755                //  previously a comparison like:
    17561756                //  destroy_row_from == std::list<SRow>::iterator()
    17571757                //  was used, but it didn't work with GCC.
    void CInput::UpdateText(int from, int to_before, int to_after)  
    17631763                //  to be redone. And when going along, we'll delete a row at a time
    17641764                //  when continuing to see how much more after 'to' we need to remake.
    17651765                int i = 0;
    1766                 for (std::list<SRow>::iterator it = m_CharacterPositions.begin(); 
     1766                for (std::list<SRow>::iterator it = m_CharacterPositions.begin();
    17671767                     it != m_CharacterPositions.end();
    17681768                     ++it, ++i)
    17691769                {
    void CInput::UpdateText(int from, int to_before, int to_after)  
    17871787                        destroy_row_to_used = true;
    17881788
    17891789                        // If it isn't the last row, we'll add another row to delete,
    1790                         //  just so we can see if the last restorted line is 
     1790                        //  just so we can see if the last restorted line is
    17911791                        //  identical to what it was before. If it isn't, then we'll
    17921792                        //  have to continue.
    17931793                        // 'check_point_row_start' is where we store how the that
    void CInput::UpdateText(int from, int to_before, int to_after)  
    18601860    }
    18611861}
    18621862
    1863 int CInput::GetMouseHoveringTextPosition()
     1863int CInput::GetMouseHoveringTextPosition() const
    18641864{
    18651865    if (m_CharacterPositions.empty())
    18661866        return 0;
    int CInput::GetMouseHoveringTextPosition()  
    18731873    GUI<float>::GetSetting(this, "buffer_zone", buffer_zone);
    18741874    GUI<bool>::GetSetting(this, "multiline", multiline);
    18751875
    1876     std::list<SRow>::iterator current = m_CharacterPositions.begin();
     1876    std::list<SRow>::const_iterator current = m_CharacterPositions.begin();
    18771877
    18781878    CPos mouse = GetMousePos();
    18791879
    int CInput::GetMouseHoveringTextPosition()  
    18871887
    18881888        float scroll = 0.f;
    18891889        if (scrollbar)
    1890             scroll = GetScrollBar(0).GetPos();
    1891 
    1892         // Pointer to caption, will come in handy
    1893         CStrW* pCaption = (CStrW*)m_Settings["caption"].m_pSetting;
    1894         UNUSED2(pCaption);
     1890            scroll = GetScrollBarPos(0);
    18951891
    18961892        // Now get the height of the font.
    18971893                        // TODO: Get the real font
    18981894        CFontMetrics font(font_name);
    18991895        float spacing = (float)font.GetLineSpacing();
    1900         //float height = (float)font.GetHeight();   // unused
    19011896
    19021897        // Change mouse position relative to text.
    19031898        mouse -= m_CachedActualSize.TopLeft();
    19041899        mouse.x -= buffer_zone;
    19051900        mouse.y += scroll - buffer_zone;
    19061901
    1907         //if ((m_CharacterPositions.size()-1) * spacing + height < mouse.y)
    1908         //  m_iBufferPos = pCaption->Length();
    1909         int row = (int)((mouse.y) / spacing);//m_CharachterPositions.size()
     1902        int row = (int)((mouse.y) / spacing);
    19101903
    19111904        if (row < 0)
    19121905            row = 0;
    int CInput::GetMouseHoveringTextPosition()  
    19291922        // mouse.y is moot
    19301923    }
    19311924
    1932     //m_iBufferPos = m_CharacterPositions.get.m_ListStart;
    19331925    retPosition = current->m_ListStart;
    19341926
    19351927    // Okay, now loop through the glyphs to find the appropriate X position
    int CInput::GetMouseHoveringTextPosition()  
    19401932}
    19411933
    19421934// Does not process horizontal scrolling, 'x' must be modified before inputted.
    1943 int CInput::GetXTextPosition(const std::list<SRow>::iterator& current, const float& x, float& wanted)
     1935int CInput::GetXTextPosition(const std::list<SRow>::const_iterator& current, const float& x, float& wanted) const
    19441936{
    19451937    int ret = 0;
    19461938    float previous = 0.f;
    19471939    int i = 0;
    19481940
    1949     for (std::vector<float>::iterator it = current->m_ListOfX.begin();
     1941    for (std::vector<float>::const_iterator it = current->m_ListOfX.begin();
    19501942         it != current->m_ListOfX.end();
    19511943         ++it, ++i)
    19521944    {
    void CInput::DeleteCurSelection()  
    19921984        virtualTo = m_iBufferPos;
    19931985    }
    19941986
    1995     *pCaption = pCaption->Left(virtualFrom) + 
     1987    *pCaption = pCaption->Left(virtualFrom) +
    19961988                pCaption->Right((long)pCaption->length() - virtualTo);
    19971989
    19981990    UpdateText(virtualFrom, virtualTo, virtualFrom);
  • source/gui/CInput.h

    diff --git a/source/gui/CInput.h b/source/gui/CInput.h
    index f5aa0ed..8a9a955 100644
    a b public:  
    4747
    4848    // Check where the mouse is hovering, and get the appropriate text position.
    4949    //  return is the text-position index.
    50     // const in philosophy, but I need to retrieve the caption in a non-const way.
    51     int GetMouseHoveringTextPosition();
     50    int GetMouseHoveringTextPosition() const;
    5251
    53     // Same as above, but only on one row in X, and a given value, not the mouse's
    54     //  wanted is filled with x if the row didn't extend as far as we
    55     int GetXTextPosition(const std::list<SRow>::iterator& c, const float& x, float& wanted);
     52    // Same as above, but only on one row in X, and a given value, not the mouse's.
     53    //  wanted is filled with x if the row didn't extend as far as the mouse pos.
     54    int GetXTextPosition(const std::list<SRow>::const_iterator& c, const float& x, float& wanted) const;
    5655
    5756protected:
    5857    /**
  • source/gui/CList.cpp

    diff --git a/source/gui/CList.cpp b/source/gui/CList.cpp
    index ba3f3c3..7f5af0a 100644
    a b void CList::SetupText()  
    104104
    105105    // Generate texts
    106106    float buffered_y = 0.f;
    107    
     107
    108108    for (size_t i = 0; i < pList->m_Items.size(); ++i)
    109109    {
    110110        // Create a new SGUIText. Later on, input it using AddText()
    void CList::SetupText()  
    119119    }
    120120
    121121    m_ItemsYPositions[pList->m_Items.size()] = buffered_y;
    122    
     122
    123123    // Setup scrollbar
    124124    if (scrollbar)
    125125    {
    void CList::HandleMessage(SGUIMessage& Message)  
    152152            // TODO: Check range
    153153
    154154            // TODO only works if lower-case, shouldn't it be made case sensitive instead?
    155             ScriptEvent("selectionchange"); 
     155            ScriptEvent("selectionchange");
    156156        }
    157157
    158158        if (Message.value == "scrollbar")
    void CList::HandleMessage(SGUIMessage& Message)  
    206206                set = i;
    207207            }
    208208        }
    209        
     209
    210210        if (set != -1)
    211211        {
    212212            GUI<int>::SetSetting(this, "selected", set);
    InReaction CList::ManuallyHandleEvent(const SDL_Event_* ev)  
    286286    return result;
    287287}
    288288
    289 void CList::Draw() 
     289void CList::Draw()
    290290{
    291291    int selected;
    292292    GUI<int>::GetSetting(this, "selected", selected);
    293    
     293
    294294    DrawList(selected, "sprite", "sprite_selectarea", "textcolor");
    295295}
    296296
    bool CList::HandleAdditionalChildren(const XMBElement& child, CXeromyces* pFile)  
    411411    if (child.GetNodeName() == elmt_item)
    412412    {
    413413        AddItem(child.GetText().FromUTF8(), child.GetText().FromUTF8());
    414        
    415414        return true;
    416415    }
    417     else
    418     {
    419         return false;
    420     }
     416
     417    return false;
    421418}
    422419
    423420void CList::SelectNextElement()
    void CList::SelectNextElement()  
    438435            g_SoundManager->PlayAsUI(soundPath.c_str(), false);
    439436    }
    440437}
    441    
     438
    442439void CList::SelectPrevElement()
    443440{
    444441    int selected;
    void CList::SelectFirstElement()  
    463460    if (selected >= 0)
    464461        GUI<int>::SetSetting(this, "selected", 0);
    465462}
    466    
     463
    467464void CList::SelectLastElement()
    468465{
    469466    int selected;
  • source/gui/COList.cpp

    diff --git a/source/gui/COList.cpp b/source/gui/COList.cpp
    index bbe81e9..81ce852 100644
    a b void COList::HandleMessage(SGUIMessage& Message)  
    152152        CPos mouse = GetMousePos();
    153153        if (!m_CachedActualSize.PointInside(mouse))
    154154            return;
    155        
     155
    156156        float xpos = 0;
    157157        for (size_t def = 0; def < m_ObjectsDefs.size(); ++def)
    158158        {
    void COList::DrawList(const int& selected, const CStr& _sprite, const CStr& _spr  
    361361    CRect rect_head(m_CachedActualSize.left, m_CachedActualSize.top, m_CachedActualSize.right,
    362362                                    m_CachedActualSize.top + m_HeadingHeight);
    363363    GetGUI()->DrawSprite(*sprite_heading, cell_id, bz, rect_head);
    364    
     364
    365365    CGUISpriteInstance* sprite_order;
    366366    CGUISpriteInstance* sprite_not_sorted;
    367367    if (m_SelectedColumnOrder != -1)
  • source/gui/COList.h

    diff --git a/source/gui/COList.h b/source/gui/COList.h
    index 7ebabbe..239f23c 100644
    a b struct ObjectDef  
    3232/**
    3333 * Multi-column list. One row can be selected by the user.
    3434 * Individual cells are clipped if the contained text is too long.
    35  * 
    36  * The list can be sorted dynamically by JS code when a 
     35 *
     36 * The list can be sorted dynamically by JS code when a
    3737 * heading is ckicked.
    3838 * A scroll-bar will appear when needed.
    3939 */
  • source/gui/CProgressBar.cpp

    diff --git a/source/gui/CProgressBar.cpp b/source/gui/CProgressBar.cpp
    index df8a816..009fb68 100644
    a b void CProgressBar::HandleMessage(SGUIMessage& Message)  
    6161    }
    6262}
    6363
    64 void CProgressBar::Draw() 
     64void CProgressBar::Draw()
    6565{
    6666    if (!GetGUI())
    6767        return;
  • source/gui/CProgressBar.h

    diff --git a/source/gui/CProgressBar.h b/source/gui/CProgressBar.h
    index 7a22fe5..3f34db5 100644
    a b  
    2222
    2323/**
    2424 * Object used to draw a value (e.g. progress) from 0 to 100 visually.
    25  * 
     25 *
    2626 * @see IGUIObject
    2727 */
    2828class CProgressBar : public IGUIObject
  • source/gui/CRadioButton.h

    diff --git a/source/gui/CRadioButton.h b/source/gui/CRadioButton.h
    index 1656308..e9227f7 100644
    a b  
    2424/**
    2525 * Just like a check box, but it'll nullify its siblings (of the same kind),
    2626 * and it won't switch itself.
    27  * 
     27 *
    2828 * @see CCheckBox
    2929 */
    3030class CRadioButton : public CCheckBox
  • source/gui/CText.cpp

    diff --git a/source/gui/CText.cpp b/source/gui/CText.cpp
    index cccbdfc..b2b1090 100644
    a b void CText::HandleMessage(SGUIMessage& Message)  
    182182    IGUITextOwner::HandleMessage(Message);
    183183}
    184184
    185 void CText::Draw() 
     185void CText::Draw()
    186186{
    187187    float bz = GetBufferedZ();
    188188
  • source/gui/CText.h

    diff --git a/source/gui/CText.h b/source/gui/CText.h
    index 7b7fb4b..81d18b0 100644
    a b  
    2222
    2323/**
    2424 * Text field that just displays static text.
    25  * 
     25 *
    2626 * @see IGUIObject
    2727 */
    2828class CText : public IGUIScrollBarOwner, public IGUITextOwner
  • source/gui/CTooltip.cpp

    diff --git a/source/gui/CTooltip.cpp b/source/gui/CTooltip.cpp
    index 3a1483d..f44dbe6 100644
    a b void CTooltip::SetupText()  
    8787    CPos mousepos, offset;
    8888    EVAlign anchor;
    8989    bool independent;
    90    
     90
    9191    GUI<bool>::GetSetting(this, "independent", independent);
    9292    if (independent)
    9393        mousepos = GetMousePos();
    void CTooltip::HandleMessage(SGUIMessage& Message)  
    147147    IGUITextOwner::HandleMessage(Message);
    148148}
    149149
    150 void CTooltip::Draw() 
     150void CTooltip::Draw()
    151151{
    152152    if (!GetGUI())
    153153        return;
  • source/gui/GUIManager.cpp

    diff --git a/source/gui/GUIManager.cpp b/source/gui/GUIManager.cpp
    index c8a8940..8199fdf 100644
    a b void CGUIManager::PopPageCB(shared_ptr<ScriptInterface::StructuredClone> args)  
    114114{
    115115    shared_ptr<ScriptInterface::StructuredClone> initDataClone = m_PageStack.back().initData;
    116116    PopPage();
    117    
     117
    118118    shared_ptr<ScriptInterface> scriptInterface = m_PageStack.back().gui->GetScriptInterface();
    119119    JSContext* cx = scriptInterface->GetContext();
    120120    JS::RootedValue initDataVal(cx);
    121     if (initDataClone)
    122         scriptInterface->ReadStructuredClone(initDataClone, &initDataVal);
    123     else
     121    if (!initDataClone)
    124122    {
    125123        LOGERROR("Called PopPageCB when initData (which should contain the callback function name) isn't set!");
    126124        return;
    127125    }
    128    
     126
     127    scriptInterface->ReadStructuredClone(initDataClone, &initDataVal);
     128
    129129    if (!scriptInterface->HasProperty(initDataVal, "callback"))
    130130    {
    131131        LOGERROR("Called PopPageCB when the callback function name isn't set!");
    132132        return;
    133133    }
    134    
     134
    135135    std::string callback;
    136136    if (!scriptInterface->GetProperty(initDataVal, "callback", callback))
    137137    {
    138138        LOGERROR("Failed to get the callback property as a string from initData in PopPageCB!");
    139139        return;
    140140    }
    141    
     141
    142142    JS::RootedValue global(cx, scriptInterface->GetGlobalObject());
    143143    if (!scriptInterface->HasProperty(global, callback.c_str()))
    144144    {
    void CGUIManager::LoadPage(SGUIPage& page)  
    182182        shared_ptr<ScriptInterface> scriptInterface = page.gui->GetScriptInterface();
    183183        JSContext* cx = scriptInterface->GetContext();
    184184        JSAutoRequest rq(cx);
    185        
     185
    186186        JS::RootedValue global(cx, scriptInterface->GetGlobalObject());
    187187        JS::RootedValue hotloadDataVal(cx);
    188         scriptInterface->CallFunction(global, "getHotloadData", &hotloadDataVal); 
     188        scriptInterface->CallFunction(global, "getHotloadData", &hotloadDataVal);
    189189        hotloadData = scriptInterface->WriteStructuredClone(hotloadDataVal);
    190190    }
    191        
     191
    192192    page.inputs.clear();
    193193    page.gui.reset(new CGUI(m_ScriptRuntime));
    194194
    void CGUIManager::LoadPage(SGUIPage& page)  
    252252    shared_ptr<ScriptInterface> scriptInterface = page.gui->GetScriptInterface();
    253253    JSContext* cx = scriptInterface->GetContext();
    254254    JSAutoRequest rq(cx);
    255    
     255
    256256    JS::RootedValue initDataVal(cx);
    257257    JS::RootedValue hotloadDataVal(cx);
    258258    JS::RootedValue global(cx, scriptInterface->GetGlobalObject());
    259     if (page.initData) 
     259    if (page.initData)
    260260        scriptInterface->ReadStructuredClone(page.initData, &initDataVal);
    261261    if (hotloadData)
    262262        scriptInterface->ReadStructuredClone(hotloadData, &hotloadDataVal);
    263    
     263
    264264    // Call the init() function
    265265    if (!scriptInterface->CallFunctionVoid(
    266             global, 
    267             "init", 
    268             initDataVal, 
     266            global,
     267            "init",
     268            initDataVal,
    269269            hotloadDataVal)
    270270        )
    271271    {
    std::string CGUIManager::GetSavedGameData()  
    302302    shared_ptr<ScriptInterface> scriptInterface = top()->GetScriptInterface();
    303303    JSContext* cx = scriptInterface->GetContext();
    304304    JSAutoRequest rq(cx);
    305    
     305
    306306    JS::RootedValue data(cx);
    307307    JS::RootedValue global(cx, top()->GetGlobalObject());
    308308    scriptInterface->CallFunction(global, "getSavedGameData", &data);
    void CGUIManager::RestoreSavedGameData(std::string jsonData)  
    314314    shared_ptr<ScriptInterface> scriptInterface = top()->GetScriptInterface();
    315315    JSContext* cx = scriptInterface->GetContext();
    316316    JSAutoRequest rq(cx);
    317    
     317
    318318    JS::RootedValue global(cx, top()->GetGlobalObject());
    319319    JS::RootedValue dataVal(cx);
    320320    scriptInterface->ParseJSON(jsonData, &dataVal);
    InReaction CGUIManager::HandleEvent(const SDL_Event_* ev)  
    329329    // visible game area), sometimes they'll want to intercepts events before the GUI (e.g.
    330330    // to capture all mouse events until a mouseup after dragging).
    331331    // So we call two separate handler functions:
    332    
     332
    333333    bool handled;
    334334
    335335    {
    void CGUIManager::TickObjects()  
    392392    // We share the script runtime with everything else that runs in the same thread.
    393393    // This call makes sure we trigger GC regularly even if the simulation is not running.
    394394    m_ScriptInterface->GetRuntime()->MaybeIncrementalGC(1.0f);
    395    
     395
    396396    // Save an immutable copy so iterators aren't invalidated by tick handlers
    397397    PageStackType pageStack = m_PageStack;
    398398
  • source/gui/GUIManager.h

    diff --git a/source/gui/GUIManager.h b/source/gui/GUIManager.h
    index bad6d20..5e76232 100644
    a b public:  
    5151    CGUIManager();
    5252    ~CGUIManager();
    5353
    54     shared_ptr<ScriptInterface> GetScriptInterface() 
    55     { 
    56         return m_ScriptInterface; 
     54    shared_ptr<ScriptInterface> GetScriptInterface()
     55    {
     56        return m_ScriptInterface;
    5757    }
    5858    shared_ptr<ScriptRuntime> GetRuntime() { return m_ScriptRuntime; }
    5959    shared_ptr<CGUI> GetActiveGUI() { return top(); }
    public:  
    136136     * Calls the current page's script function getSavedGameData() and returns the result.
    137137     */
    138138    std::string GetSavedGameData();
    139  
     139
    140140    void RestoreSavedGameData(std::string jsonData);
    141141
    142142    /**
    private:  
    165165    void LoadPage(SGUIPage& page);
    166166
    167167    shared_ptr<CGUI> top() const;
    168    
     168
    169169    shared_ptr<CGUI> m_CurrentGUI; // used to latch state during TickObjects/LoadPage (this is kind of ugly)
    170170    shared_ptr<ScriptRuntime> m_ScriptRuntime;
    171171    shared_ptr<ScriptInterface> m_ScriptInterface;
  • source/gui/GUIRenderer.cpp

    diff --git a/source/gui/GUIRenderer.cpp b/source/gui/GUIRenderer.cpp
    index 1597f27..09c1050 100644
    a b void GUIRenderer::UpdateDrawCallCache(DrawCalls& Calls, const CStr& SpriteName,  
    8686        {
    8787            // TODO: Should check (nicely) that this is a valid file?
    8888            SGUIImage* Image = new SGUIImage;
    89            
     89
    9090            // Allow grayscale images for disabled portraits
    9191            if (SpriteName.substr(10, 10) == "grayscale:")
    9292            {
    void GUIRenderer::UpdateDrawCallCache(DrawCalls& Calls, const CStr& SpriteName,  
    107107            Sprite->AddImage(Image);
    108108
    109109            Sprites[SpriteName] = Sprite;
    110            
     110
    111111            it = Sprites.find(SpriteName);
    112112            ENSURE(it != Sprites.end()); // The insertion above shouldn't fail
    113113        }
    void GUIRenderer::UpdateDrawCallCache(DrawCalls& Calls, const CStr& SpriteName,  
    118118
    119119            double xRatio = SpriteName.BeforeFirst(",").AfterLast("(").ToDouble();
    120120            double yRatio = SpriteName.BeforeFirst(")").AfterLast(",").ToDouble();
    121            
     121
    122122            int PathStart = SpriteName.Find(")") + 1;
    123            
     123
    124124            Image->m_TextureName = VfsPath("art/textures/ui") / wstring_from_utf8(SpriteName.substr(PathStart));
    125125
    126126            CClientArea ca(CRect(0, 0, 0, 0), CRect(0, 0, 100, 100));
    void GUIRenderer::UpdateDrawCallCache(DrawCalls& Calls, const CStr& SpriteName,  
    132132            Sprite->AddImage(Image);
    133133
    134134            Sprites[SpriteName] = Sprite;
    135            
     135
    136136            it = Sprites.find(SpriteName);
    137137            ENSURE(it != Sprites.end()); // The insertion above shouldn't fail
    138138        }
    void GUIRenderer::Draw(DrawCalls& Calls, float Z)  
    437437            }
    438438#undef ADD
    439439        }
    440        
     440
    441441        cit->m_Shader->EndPass();
    442442
    443443        glDisable(GL_BLEND);
  • source/gui/GUITooltip.cpp

    diff --git a/source/gui/GUITooltip.cpp b/source/gui/GUITooltip.cpp
    index aa321a5..009a5bd 100644
    a b void GUITooltip::Update(IGUIObject* Nearest, const CPos& MousePos, CGUI* GUI)  
    332332            // Mouse moved onto a new object
    333333
    334334            if (GetTooltip(Nearest, style))
    335             {   
     335            {
    336336                CStr style_old;
    337337
    338                 // If we're displaying a tooltip with no delay, then we want to 
     338                // If we're displaying a tooltip with no delay, then we want to
    339339                //  reset so that other object that should have delay can't
    340340                //  "ride this tail", it have to wait.
    341341                // Notice that this doesn't apply to when you go from one delay=0
    void GUITooltip::Update(IGUIObject* Nearest, const CPos& MousePos, CGUI* GUI)  
    354354                }
    355355            }
    356356            else
    357             {   
     357            {
    358358                nextstate = ST_COOLING;
    359359            }
    360360        }
  • source/gui/GUIbase.h

    diff --git a/source/gui/GUIbase.h b/source/gui/GUIbase.h
    index d89427b..1a9daa0 100644
    a b GUI Core, stuff that the whole GUI uses  
    2020
    2121--Overview--
    2222
    23     Contains defines, includes, types etc that the whole 
     23    Contains defines, includes, types etc that the whole
    2424     GUI should have included.
    2525
    2626--More info--
    public: \  
    5050    static IGUIObject* ConstructObject() { return new obj(); }
    5151
    5252
    53 /** 
     53/**
    5454 * Message types.
    5555 * @see SGUIMessage
    5656 */
    enum EGUIMessageType  
    7878    GUIM_LOST_FOCUS,
    7979    GUIM_PRESSED_MOUSE_RIGHT,
    8080    GUIM_DOUBLE_PRESSED_MOUSE_RIGHT,
    81     GUIM_TAB                // Used by CInput 
     81    GUIM_TAB                // Used by CInput
    8282};
    8383
    8484/**
    public:  
    182182     *
    183183     * "0 0 100% 100%"
    184184     * "50%-10 50%-10 50%+10 50%+10"
    185      * 
     185     *
    186186     * i.e. First percent modifier, then + or - and the pixel modifier.
    187187     * Although you can use just the percent or the pixel modifier. Notice
    188188     * though that the percent modifier must always be the first when
  • source/gui/GUItext.h

    diff --git a/source/gui/GUItext.h b/source/gui/GUItext.h
    index dc8bffd..0cbccf15 100644
    a b class CGUI;  
    3939
    4040/**
    4141 * An SGUIText object is a parsed string, divided into
    42  * text-rendering components. Each component, being a 
     42 * text-rendering components. Each component, being a
    4343 * call to the Renderer. For instance, if you by tags
    4444 * change the color, then the GUI will have to make
    4545 * individual calls saying it want that color on the
    struct SGUIText  
    8989     */
    9090    struct STextCall
    9191    {
    92         STextCall() : 
     92        STextCall() :
    9393            m_UseCustomColor(false),
    9494            m_Bold(false), m_Italic(false), m_Underlined(false),
    9595            m_pSpriteCall(NULL) {}
  • source/gui/GUIutil.cpp

    diff --git a/source/gui/GUIutil.cpp b/source/gui/GUIutil.cpp
    index ca4dd9c..6ee03ab 100644
    a b bool __ParseString<bool>(const CStrW& Value, bool& Output)  
    3232        Output = true;
    3333    else if (Value == L"false")
    3434        Output = false;
    35     else 
     35    else
    3636        return false;
    3737
    3838    return true;
    PSRETURN GUI<T>::GetSettingPointer(const IGUIObject* pObject, const CStr& Settin  
    329329    std::map<CStr, SGUISetting>::const_iterator it = pObject->m_Settings.find(Setting);
    330330    if (it == pObject->m_Settings.end())
    331331    {
    332         LOGWARNING("setting %s was not found on object %s", 
     332        LOGWARNING("setting %s was not found on object %s",
    333333            Setting.c_str(),
    334334            pObject->GetPresentableName().c_str());
    335335        return PSRETURN_GUI_InvalidSetting;
    PSRETURN GUI<T>::SetSetting(IGUIObject* pObject, const CStr& Setting, const T& V  
    377377
    378378    if (!pObject->SettingExists(Setting))
    379379    {
    380         LOGWARNING("setting %s was not found on object %s", 
     380        LOGWARNING("setting %s was not found on object %s",
    381381            Setting.c_str(),
    382382            pObject->GetPresentableName().c_str());
    383383        return PSRETURN_GUI_InvalidSetting;
  • source/gui/GUIutil.h

    diff --git a/source/gui/GUIutil.h b/source/gui/GUIutil.h
    index 249ce31..e17a582 100644
    a b CMatrix3D GetDefaultGuiMatrix();  
    5050struct SGUIMessage;
    5151
    5252/**
    53  * Base class to only the class GUI. This superclass is 
     53 * Base class to only the class GUI. This superclass is
    5454 * kind of a templateless extention of the class GUI.
    5555 * Used for other functions to friend with, because it
    5656 * can't friend with GUI since it's templated (at least
    class CInternalCGUIAccessorBase  
    6161protected:
    6262    /// Get object pointer
    6363    static IGUIObject* GetObjectPointer(CGUI& GUIinstance, const CStr& Object);
    64    
     64
    6565    /// const version
    6666    static const IGUIObject* GetObjectPointer(const CGUI& GUIinstance, const CStr& Object);
    6767
    protected:  
    7373
    7474
    7575#ifndef NDEBUG
    76 // Used to ensure type-safety, sort of 
     76// Used to ensure type-safety, sort of
    7777template<typename T> void CheckType(const IGUIObject* obj, const CStr& setting);
    7878#endif
    7979
    public:  
    141141    }
    142142
    143143    /**
    144      * Sets a value by setting and object name using a real 
     144     * Sets a value by setting and object name using a real
    145145     * datatype as input
    146146     *
    147147     * This is just a wrapper so that we can type the object name
    public:  
    167167
    168168        return SetSetting(pObject, Setting, Value, SkipMessage);
    169169    }
    170    
     170
    171171    /**
    172172     * This will return the value of the first sprite if it's not null,
    173173     * if it is null, it will return the value of the second sprite, if
    public:  
    197197    }
    198198
    199199    /**
    200      * Sets a value by setting and object name using a real 
     200     * Sets a value by setting and object name using a real
    201201     * datatype as input.
    202202     *
    203203     * This is just a wrapper for __ParseString() which really
    private:  
    256256            return;
    257257
    258258        (pObject->*pFunc)(Argument);
    259        
     259
    260260        // Iterate children
    261261        for (IGUIObject* const& obj : *pObject)
    262262            RecurseObject(RR, obj, pFunc, Argument);
    private:  
    273273            return;
    274274
    275275        (pObject->*pFunc)(Argument);
    276        
     276
    277277        // Iterate children
    278278        for (IGUIObject* const& obj : *pObject)
    279279            RecurseObject(RR, obj, pFunc, Argument);
  • source/gui/IGUIObject.cpp

    diff --git a/source/gui/IGUIObject.cpp b/source/gui/IGUIObject.cpp
    index 53f7980..eb2b755 100644
    a b void IGUIObject::AddChild(IGUIObject* pChild)  
    100100            // If anything went wrong, reverse what we did and throw
    101101            //  an exception telling it never added a child
    102102            m_Children.erase(m_Children.end()-1);
    103            
     103
    104104            throw;
    105105        }
    106106    }
    bool IGUIObject::MouseOverIcon()  
    177177}
    178178
    179179CPos IGUIObject::GetMousePos() const
    180 {
    181     return ((GetGUI())?(GetGUI()->m_MousePos):CPos());
     180{
     181    if (GetGUI())
     182        return GetGUI()->m_MousePos;
     183
     184    return CPos();
    182185}
    183186
    184187void IGUIObject::UpdateMouseOver(IGUIObject* const& pMouseOver)
    void IGUIObject::UpdateCachedSize()  
    309312
    310313    CClientArea ca;
    311314    GUI<CClientArea>::GetSetting(this, "size", ca);
    312    
     315
    313316    // If absolute="false" and the object has got a parent,
    314317    //  use its cached size instead of the screen. Notice
    315318    //  it must have just been cached for it to work.
    float IGUIObject::GetBufferedZ() const  
    385388        else
    386389        {
    387390            // In philosophy, a parentless object shouldn't be able to have a relative sizing,
    388             //  but we'll accept it so that absolute can be used as default without a complaint. 
     391            //  but we'll accept it so that absolute can be used as default without a complaint.
    389392            //  Also, you could consider those objects children to the screen resolution.
    390393            return Z;
    391394        }
    void IGUIObject::RegisterScriptHandler(const CStr& Action, const CStr& Code, CGU  
    396399{
    397400    if(!GetGUI())
    398401        throw PSERROR_GUI_OperationNeedsGUIObject();
    399        
     402
    400403    JSContext* cx = pGUI->GetScriptInterface()->GetContext();
    401404    JSAutoRequest rq(cx);
    402405    JS::RootedValue globalVal(cx, pGUI->GetGlobalObject());
    403406    JS::RootedObject globalObj(cx, &globalVal.toObject());
    404    
     407
    405408    const int paramCount = 1;
    406409    const char* paramNames[paramCount] = { "mouse" };
    407410
    void IGUIObject::RegisterScriptHandler(const CStr& Action, const CStr& Code, CGU  
    422425
    423426    if (!func)
    424427        return; // JS will report an error message
    425    
     428
    426429    JS::RootedObject funcObj(cx, JS_GetFunctionObject(func));
    427430    SetScriptHandler(Action, funcObj);
    428431}
    CStr IGUIObject::GetPresentableName() const  
    528531
    529532void IGUIObject::SetFocus()
    530533{
    531     GetGUI()->m_FocusedObject = this; 
     534    GetGUI()->m_FocusedObject = this;
    532535}
    533536
    534537bool IGUIObject::IsFocused() const
    535538{
    536     return GetGUI()->m_FocusedObject == this; 
     539    return GetGUI()->m_FocusedObject == this;
    537540}
    538541
    539542bool IGUIObject::IsRootObject() const
    void IGUIObject::TraceMember(JSTracer* trc)  
    549552
    550553PSRETURN IGUIObject::LogInvalidSettings(const CStr8& Setting) const
    551554{
    552     LOGWARNING("IGUIObject: setting %s was not found on an object", 
     555    LOGWARNING("IGUIObject: setting %s was not found on an object",
    553556        Setting.c_str());
    554557    return PSRETURN_GUI_InvalidSetting;
    555558}
  • source/gui/IGUIObject.h

    diff --git a/source/gui/IGUIObject.h b/source/gui/IGUIObject.h
    index 1f29053..2b4dd72 100644
    a b public:  
    176176    void AddToPointersMap(map_pObjects& ObjectMap);
    177177
    178178    /**
    179      * Notice nothing will be returned or thrown if the child hasn't 
    180      * been inputted into the GUI yet. This is because that's were 
     179     * Notice nothing will be returned or thrown if the child hasn't
     180     * been inputted into the GUI yet. This is because that's were
    181181     * all is checked. Now we're just linking two objects, but
    182182     * it's when we're inputting them into the GUI we'll check
    183183     * validity! Notice also when adding it to the GUI this function
    public:  
    219219     * @return True if settings exist.
    220220     */
    221221    bool SettingExists(const CStr& Setting) const;
    222    
     222
    223223    /**
    224224     * All sizes are relative to resolution, and the calculation
    225225     * is not wanted in real time, therefore it is cached, update
    public:  
    257257     * @param pGUI GUI instance to associate the script with
    258258     */
    259259    void RegisterScriptHandler(const CStr& Action, const CStr& Code, CGUI* pGUI);
    260    
     260
    261261    /**
    262262     * Retrieves the JSObject representing this GUI object.
    263263     */
    protected:  
    290290     * MEGA TODO Should it destroy it's children?
    291291     */
    292292    virtual void Destroy();
    293    
     293
    294294public:
    295295    /**
    296296     * This function is called with different messages
    protected:  
    353353     * Set parent of this object
    354354     */
    355355    void SetParent(IGUIObject* pParent) { m_pParent = pParent; }
    356    
     356
    357357    /**
    358358     * Reset internal state of this object
    359359     */
    private:  
    459459    /** @name Internal functions */
    460460    //--------------------------------------------------------
    461461    //@{
    462    
     462
    463463    /**
    464464     * Inputs a reference pointer, checks if the new inputted object
    465465     * if hovered, if so, then check if this's Z value is greater
    protected:  
    518518     * read. This is important to know because I don't want to force
    519519     * the user to include its \<styles\>-XML-files first, so somehow
    520520     * the GUI needs to know which settings were set, and which is meant
    521      * to 
     521     * to.
    522522     */
    523523
    524524    // More variables
    private:  
    543543
    544544    // Internal storage for registered script handlers.
    545545    std::map<CStr, JS::Heap<JSObject*> > m_ScriptHandlers;
    546    
     546
    547547    // Cached JSObject representing this GUI object
    548548    DefPersistentRooted<JSObject*>           m_JSObject;
    549549};
  • source/gui/IGUIScrollBar.cpp

    diff --git a/source/gui/IGUIScrollBar.cpp b/source/gui/IGUIScrollBar.cpp
    index 0ad463a..1d20afd 100644
    a b  
    2323IGUIScrollBar::IGUIScrollBar() : m_pStyle(NULL), m_pGUI(NULL),
    2424                                 m_X(300.f), m_Y(300.f),
    2525                                 m_ScrollRange(1.f), m_ScrollSpace(0.f), // MaxPos: not 0, due to division.
    26                                  m_Length(200.f), m_Width(20.f), 
     26                                 m_Length(200.f), m_Width(20.f),
    2727                                 m_BarSize(0.f), m_Pos(0.f),
    2828                                 m_ButtonPlusPressed(false),
    2929                                 m_ButtonMinusPressed(false),
    const SGUIScrollBarStyle* IGUIScrollBar::GetStyle() const  
    6969    return m_pHostObject->GetScrollBarStyle(m_ScrollBarStyle);
    7070}
    7171
    72 CGUI* IGUIScrollBar::GetGUI() const 
    73 { 
     72CGUI* IGUIScrollBar::GetGUI() const
     73{
    7474    if (!m_pHostObject)
    7575        return NULL;
    7676
    77     return m_pHostObject->GetGUI(); 
     77    return m_pHostObject->GetGUI();
    7878}
    7979
    8080void IGUIScrollBar::UpdatePosBoundaries()
  • source/gui/IGUIScrollBar.h

    diff --git a/source/gui/IGUIScrollBar.h b/source/gui/IGUIScrollBar.h
    index 6ad6710..bda4a4a 100644
    a b struct SGUIScrollBarStyle  
    8989     * in pixels.
    9090     */
    9191    float m_MaximumBarSize;
    92    
     92
    9393    /**
    9494     * True if you want edge buttons, i.e. buttons that can be pressed in order
    9595     * to scroll.
    public:  
    252252     * @param width Width
    253253     */
    254254    void SetWidth(float width) { m_Width = width; }
    255    
     255
    256256    /**
    257257     * Set X Position
    258258     * @param x Position in this axis
    protected:  
    341341    /**
    342342     * Width of the scroll bar
    343343     */
    344     float m_Width; 
     344    float m_Width;
    345345
    346346    /**
    347347     * Absolute X Position
  • source/gui/IGUIScrollBarOwner.cpp

    diff --git a/source/gui/IGUIScrollBarOwner.cpp b/source/gui/IGUIScrollBarOwner.cpp
    index 1062c6c..6a2dac3 100644
    a b void IGUIScrollBarOwner::HandleMessage(SGUIMessage& msg)  
    6868        sb->HandleMessage(msg);
    6969}
    7070
    71 void IGUIScrollBarOwner::Draw() 
     71void IGUIScrollBarOwner::Draw()
    7272{
    7373    for (IGUIScrollBar* const& sb : m_ScrollBars)
    7474        sb->Draw();
    7575}
     76
     77float IGUIScrollBarOwner::GetScrollBarPos(const int index) const
     78{
     79    return m_ScrollBars[index]->GetPos();
     80}
  • source/gui/IGUIScrollBarOwner.h

    diff --git a/source/gui/IGUIScrollBarOwner.h b/source/gui/IGUIScrollBarOwner.h
    index f1a5d50..e22adda 100644
    a b public:  
    6969        return *m_ScrollBars[index];
    7070    }
    7171
     72    /**
     73     * Get the position of the scroll bar at @param index.
     74     * Equivalent to GetScrollbar(index).GetPos().
     75     */
     76    virtual float GetScrollBarPos(const int index) const;
     77
    7278protected:
    7379
    7480    /**
  • source/gui/MiniMap.cpp

    diff --git a/source/gui/MiniMap.cpp b/source/gui/MiniMap.cpp
    index 745f20e..185f52e 100644
    a b CMiniMap::CMiniMap() :  
    8686    m_AttributePos.type = GL_FLOAT;
    8787    m_AttributePos.elems = 2;
    8888    m_VertexArray.AddAttribute(&m_AttributePos);
    89    
     89
    9090    m_AttributeColor.type = GL_UNSIGNED_BYTE;
    9191    m_AttributeColor.elems = 4;
    9292    m_VertexArray.AddAttribute(&m_AttributeColor);
    93    
     93
    9494    m_VertexArray.SetNumVertices(MAX_ENTITIES_DRAWN);
    9595    m_VertexArray.Layout();
    9696
    void CMiniMap::FireWorldClickEvent(int UNUSED(button), int UNUSED(clicks))  
    236236{
    237237    JSContext* cx = g_GUI->GetActiveGUI()->GetScriptInterface()->GetContext();
    238238    JSAutoRequest rq(cx);
    239    
     239
    240240    float x, z;
    241241    GetMouseWorldCoordinates(x, z);
    242242
    void CMiniMap::DrawViewRect(CMatrix3D transform)  
    283283    glScissor(
    284284        m_CachedActualSize.left / g_GuiScale,
    285285        g_Renderer.GetHeight() - m_CachedActualSize.bottom / g_GuiScale,
    286         width / g_GuiScale, 
     286        width / g_GuiScale,
    287287        height / g_GuiScale);
    288288    glEnable(GL_SCISSOR_TEST);
    289289    glLineWidth(2.0f);
    void CMiniMap::Draw()  
    405405    const double cur_time = timer_Time();
    406406    const bool doUpdate = cur_time - last_time > 0.5;
    407407    if (doUpdate)
    408     {   
     408    {
    409409        last_time = cur_time;
    410410        if (m_TerrainDirty)
    411411            RebuildTerrainTexture();
  • source/gui/MiniMap.h

    diff --git a/source/gui/MiniMap.h b/source/gui/MiniMap.h
    index 2cf6d16..7e5409e 100644
    a b protected:  
    8484
    8585    // 1.f if map is circular or 1.414f if square (to shrink it inside the circle)
    8686    float m_MapScale;
    87    
     87
    8888    // maximal water height to allow the passage of a unit (for underwater shallows).
    8989    float m_ShallowPassageHeight;
    9090
  • source/gui/scripting/JSInterface_GUITypes.cpp

    diff --git a/source/gui/scripting/JSInterface_GUITypes.cpp b/source/gui/scripting/JSInterface_GUITypes.cpp
    index 2246568..ea5c276 100644
    a b JSClass JSI_GUISize::JSI_class = {  
    3030        NULL, NULL, JSI_GUISize::construct, NULL
    3131};
    3232
    33 JSFunctionSpec JSI_GUISize::JSI_methods[] = 
     33JSFunctionSpec JSI_GUISize::JSI_methods[] =
    3434{
    3535    JS_FS("toString", JSI_GUISize::toString, 0, 0),
    3636    JS_FS_END
    JSClass JSI_GUIColor::JSI_class = {  
    138138        NULL, NULL, JSI_GUIColor::construct, NULL
    139139};
    140140
    141 JSFunctionSpec JSI_GUIColor::JSI_methods[] = 
     141JSFunctionSpec JSI_GUIColor::JSI_methods[] =
    142142{
    143143    JS_FS("toString", JSI_GUIColor::toString, 0, 0),
    144144    JS_FS_END
    bool JSI_GUIColor::construct(JSContext* cx, uint argc, jsval* vp)  
    148148{
    149149    JSAutoRequest rq(cx);
    150150    JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
    151    
     151
    152152    ScriptInterface* pScriptInterface = ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface;
    153153    JS::RootedObject obj(cx, pScriptInterface->CreateCustomObject("GUIColor"));
    154    
     154
    155155    if (args.length() == 4)
    156156    {
    157157        JS_SetProperty(cx, obj, "r", args[0]);
    JSClass JSI_GUIMouse::JSI_class = {  
    208208        NULL, NULL, JSI_GUIMouse::construct, NULL
    209209};
    210210
    211 JSFunctionSpec JSI_GUIMouse::JSI_methods[] = 
     211JSFunctionSpec JSI_GUIMouse::JSI_methods[] =
    212212{
    213213    JS_FS("toString", JSI_GUIMouse::toString, 0, 0),
    214214    JS_FS_END
  • source/gui/scripting/JSInterface_IGUIObject.cpp

    diff --git a/source/gui/scripting/JSInterface_IGUIObject.cpp b/source/gui/scripting/JSInterface_IGUIObject.cpp
    index b651c97..5b2e43b 100644
    a b bool JSI_IGUIObject::construct(JSContext* cx, uint argc, jsval* vp)  
    594594    JSAutoRequest rq(cx);
    595595    JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
    596596    ScriptInterface* pScriptInterface = ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface;
    597    
     597
    598598    if (args.length() == 0)
    599599    {
    600600        JS_ReportError(cx, "GUIObject has no default constructor");
    bool JSI_IGUIObject::toString(JSContext* cx, uint UNUSED(argc), jsval* vp)  
    622622    JS::CallReceiver rec = JS::CallReceiverFromVp(vp);
    623623
    624624    JS::RootedObject thisObj(cx, JS_THIS_OBJECT(cx, vp));
    625    
     625
    626626    IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, thisObj, &JSI_IGUIObject::JSI_class, NULL);
    627627    if (!e)
    628628        return false;
    bool JSI_IGUIObject::focus(JSContext* cx, uint UNUSED(argc), jsval* vp)  
    640640    JS::CallReceiver rec = JS::CallReceiverFromVp(vp);
    641641
    642642    JS::RootedObject thisObj(cx, JS_THIS_OBJECT(cx, vp));
    643    
     643
    644644    IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, thisObj, &JSI_IGUIObject::JSI_class, NULL);
    645645    if (!e)
    646646        return false;
    bool JSI_IGUIObject::blur(JSContext* cx, uint UNUSED(argc), jsval* vp)  
    657657    JS::CallReceiver rec = JS::CallReceiverFromVp(vp);
    658658
    659659    JS::RootedObject thisObj(cx, JS_THIS_OBJECT(cx, vp));
    660  
     660
    661661    IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, thisObj, &JSI_IGUIObject::JSI_class, NULL);
    662662    if (!e)
    663663        return false;
    bool JSI_IGUIObject::getComputedSize(JSContext* cx, uint UNUSED(argc), jsval* vp  
    672672{
    673673    JSAutoRequest rq(cx);
    674674    JS::CallReceiver rec = JS::CallReceiverFromVp(vp);
    675    
     675
    676676    JS::RootedObject thisObj(cx, JS_THIS_OBJECT(cx, vp));
    677    
     677
    678678    IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, thisObj, &JSI_IGUIObject::JSI_class, NULL);
    679679    if (!e)
    680680        return false;
  • source/gui/scripting/ScriptFunctions.cpp

    diff --git a/source/gui/scripting/ScriptFunctions.cpp b/source/gui/scripting/ScriptFunctions.cpp
    index 69baf4e..939a416 100644
    a b void StartGame(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue attribs,  
    217217    CSimulation2* sim = g_Game->GetSimulation2();
    218218    JSContext* cxSim = sim->GetScriptInterface().GetContext();
    219219    JSAutoRequest rqSim(cxSim);
    220    
    221     JS::RootedValue gameAttribs(cxSim, 
     220
     221    JS::RootedValue gameAttribs(cxSim,
    222222        sim->GetScriptInterface().CloneValueFromOtherContext(*(pCxPrivate->pScriptInterface), attribs));
    223223
    224224    g_Game->SetPlayerID(playerID);
    JS::Value StartSavedGame(ScriptInterface::CxPrivate* pCxPrivate, std::wstring na  
    230230    // We need to be careful with different compartments and contexts.
    231231    // The GUI calls this function from the GUI context and expects the return value in the same context.
    232232    // The game we start from here creates another context and expects data in this context.
    233    
     233
    234234    JSContext* cxGui = pCxPrivate->pScriptInterface->GetContext();
    235235    JSAutoRequest rq(cxGui);
    236236
    JS::Value StartSavedGame(ScriptInterface::CxPrivate* pCxPrivate, std::wstring na  
    247247        return JS::UndefinedValue();
    248248
    249249    g_Game = new CGame();
    250    
     250
    251251    {
    252252        CSimulation2* sim = g_Game->GetSimulation2();
    253253        JSContext* cxGame = sim->GetScriptInterface().GetContext();
    254254        JSAutoRequest rq(cxGame);
    255        
    256         JS::RootedValue gameContextMetadata(cxGame, 
     255
     256        JS::RootedValue gameContextMetadata(cxGame,
    257257            sim->GetScriptInterface().CloneValueFromOtherContext(*(pCxPrivate->pScriptInterface), guiContextMetadata));
    258258        JS::RootedValue gameInitAttributes(cxGame);
    259259        sim->GetScriptInterface().GetProperty(gameContextMetadata, "initAttributes", &gameInitAttributes);
    JS::Value GetMapSettings(ScriptInterface::CxPrivate* pCxPrivate)  
    464464
    465465    JSContext* cx = g_Game->GetSimulation2()->GetScriptInterface().GetContext();
    466466    JSAutoRequest rq(cx);
    467    
     467
    468468    JS::RootedValue mapSettings(cx);
    469469    g_Game->GetSimulation2()->GetMapSettings(&mapSettings);
    470470    return pCxPrivate->pScriptInterface->CloneValueFromOtherContext(
    static void InitJsTimers(ScriptInterface& scriptInterface)  
    888888void StartJsTimer(ScriptInterface::CxPrivate* pCxPrivate, unsigned int slot)
    889889{
    890890    ONCE(InitJsTimers(*(pCxPrivate->pScriptInterface)));
    891    
     891
    892892    if (slot >= MAX_JS_TIMERS)
    893893        LOGERROR("Exceeded the maximum number of timer slots for scripts!");
    894894
    void GuiScriptingInit(ScriptInterface& scriptInterface)  
    923923    JSI_Sound::RegisterScriptFunctions(scriptInterface);
    924924    JSI_L10n::RegisterScriptFunctions(scriptInterface);
    925925    JSI_Lobby::RegisterScriptFunctions(scriptInterface);
    926  
     926
    927927    // VFS (external)
    928928    scriptInterface.RegisterFunction<JS::Value, std::wstring, std::wstring, bool, &JSI_VFS::BuildDirEntList>("BuildDirEntList");
    929929    scriptInterface.RegisterFunction<bool, CStrW, JSI_VFS::FileExists>("FileExists");