mirror of
https://github.com/edubart/otclient.git
synced 2025-10-19 14:03:26 +02:00
some refactoring
This commit is contained in:
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include <global.h>
|
||||
#include <ui/uianchorlayout.h>
|
||||
|
||||
|
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UIANCHORLAYOUT_H
|
||||
#define UIANCHORLAYOUT_H
|
||||
|
||||
|
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include <global.h>
|
||||
#include <core/dispatcher.h>
|
||||
#include <ui/uibutton.h>
|
||||
@@ -34,7 +10,7 @@ void UIButton::onInputEvent(const InputEvent& event)
|
||||
} else if(event.type == EV_MOUSE_LUP && m_state == ButtonDown) {
|
||||
m_state = ButtonUp;
|
||||
if(getRect().contains(event.mousePos)) {
|
||||
g_dispatcher.addTask(boost::bind(&Scriptable::callLuaTableField, shared_from_this(), "onClick", 0));
|
||||
g_dispatcher.addTask(boost::bind(&ScriptObject::callScriptTableField, shared_from_this(), "onClick", 0));
|
||||
}
|
||||
} else if(event.type == EV_MOUSE_MOVE && m_state != ButtonDown) {
|
||||
if(isMouseOver())
|
||||
|
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UIBUTTON_H
|
||||
#define UIBUTTON_H
|
||||
|
||||
@@ -37,7 +13,7 @@ class UIButton : public UIElement
|
||||
public:
|
||||
enum ButtonState
|
||||
{
|
||||
ButtonUp,
|
||||
ButtonUp = 0,
|
||||
ButtonDown,
|
||||
ButtonMouseOver
|
||||
};
|
||||
@@ -53,7 +29,7 @@ public:
|
||||
|
||||
ButtonState getState() { return m_state; }
|
||||
|
||||
virtual const char *getScriptableName() const { return "UIButton"; }
|
||||
virtual const char *getScriptObjectType() const { return "UIButton"; }
|
||||
|
||||
private:
|
||||
std::string m_text;
|
||||
|
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include <global.h>
|
||||
#include <graphics/fonts.h>
|
||||
#include <ui/uibuttonskin.h>
|
||||
@@ -31,40 +7,35 @@ void UIButtonSkin::load(OTMLNode* node)
|
||||
{
|
||||
UIElementSkin::load(node);
|
||||
|
||||
m_buttonDownTextColor = getFontColor();
|
||||
m_buttonHoverTextColor = getFontColor();
|
||||
UIButtonStateSkinPtr defaultStateSkin = loadStateSkin(node);
|
||||
m_statesSkin[UIButton::ButtonUp] = defaultStateSkin;
|
||||
m_statesSkin[UIButton::ButtonDown] = defaultStateSkin;
|
||||
m_statesSkin[UIButton::ButtonMouseOver] = defaultStateSkin;
|
||||
|
||||
if(OTMLNode* cnode = node->at("down state")) {
|
||||
m_buttonDownImage = loadImage(cnode);
|
||||
m_buttonDownTranslate = cnode->readAt("text translate", Point());
|
||||
m_buttonDownTextColor = cnode->readAt("font color", getFontColor());
|
||||
}
|
||||
if(OTMLNode* cnode = node->at("down state"))
|
||||
m_statesSkin[UIButton::ButtonDown] = loadStateSkin(cnode);
|
||||
|
||||
if(OTMLNode* cnode = node->at("hover state")) {
|
||||
m_buttonHoverImage = loadImage(cnode);
|
||||
m_buttonHoverTextColor = cnode->readAt("font color", getFontColor());
|
||||
}
|
||||
if(OTMLNode* cnode = node->at("hover state"))
|
||||
m_statesSkin[UIButton::ButtonMouseOver] = loadStateSkin(cnode);
|
||||
}
|
||||
|
||||
UIButtonStateSkinPtr UIButtonSkin::loadStateSkin(OTMLNode* node)
|
||||
{
|
||||
UIButtonStateSkinPtr stateSkin = UIButtonStateSkinPtr(new UIButtonStateSkin);
|
||||
stateSkin->image = loadImage(node);
|
||||
stateSkin->textTranslate = node->readAt("text translate", Point());
|
||||
stateSkin->textColor = node->readAt("font color", getFontColor());
|
||||
return stateSkin;
|
||||
}
|
||||
|
||||
void UIButtonSkin::draw(UIElement *element)
|
||||
{
|
||||
UIButton *button = static_cast<UIButton*>(element);
|
||||
|
||||
UIButtonStateSkinPtr stateSkin = m_statesSkin[button->getState()];
|
||||
Rect textRect = button->getRect();
|
||||
|
||||
if(button->getState() == UIButton::ButtonDown && m_buttonDownImage) {
|
||||
m_buttonDownImage->draw(element->getRect());
|
||||
textRect.translate(m_buttonDownTranslate);
|
||||
} else if(button->getState() == UIButton::ButtonMouseOver && m_buttonHoverImage) {
|
||||
m_buttonHoverImage->draw(element->getRect());
|
||||
} else {
|
||||
UIElementSkin::draw(element);
|
||||
}
|
||||
stateSkin->image->draw(element->getRect());
|
||||
textRect.translate(stateSkin->textTranslate);
|
||||
|
||||
Color textColor = getFontColor();
|
||||
if(button->getState() == UIButton::ButtonDown)
|
||||
textColor = m_buttonDownTextColor;
|
||||
else if(button->getState() == UIButton::ButtonMouseOver)
|
||||
textColor = m_buttonHoverTextColor;
|
||||
getFont()->renderText(button->getText(), textRect, AlignCenter, textColor);
|
||||
getFont()->renderText(button->getText(), textRect, AlignCenter, stateSkin->textColor);
|
||||
}
|
||||
|
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UIBUTTONSKIN_H
|
||||
#define UIBUTTONSKIN_H
|
||||
|
||||
@@ -31,6 +7,13 @@
|
||||
|
||||
class Font;
|
||||
|
||||
struct UIButtonStateSkin {
|
||||
ImagePtr image;
|
||||
Point textTranslate;
|
||||
Color textColor;
|
||||
};
|
||||
typedef boost::shared_ptr<UIButtonStateSkin> UIButtonStateSkinPtr;
|
||||
|
||||
class UIButtonSkin : public UIElementSkin
|
||||
{
|
||||
public:
|
||||
@@ -38,14 +21,12 @@ public:
|
||||
UIElementSkin(name, UI::Button) { }
|
||||
|
||||
void load(OTMLNode* node);
|
||||
UIButtonStateSkinPtr loadStateSkin(OTMLNode* node);
|
||||
|
||||
void draw(UIElement *element);
|
||||
|
||||
private:
|
||||
ImagePtr m_buttonDownImage;
|
||||
ImagePtr m_buttonHoverImage;
|
||||
Point m_buttonDownTranslate;
|
||||
Color m_buttonDownTextColor;
|
||||
Color m_buttonHoverTextColor;
|
||||
UIButtonStateSkinPtr m_statesSkin[3];
|
||||
};
|
||||
|
||||
#endif // UIBUTTONSKIN_H
|
||||
|
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include <global.h>
|
||||
#include <ui/uicheckbox.h>
|
||||
|
||||
|
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UICHECKBOX_H
|
||||
#define UICHECKBOX_H
|
||||
|
||||
@@ -33,7 +9,7 @@ class UICheckBox : public UIElement
|
||||
public:
|
||||
UICheckBox(UI::ElementType type = UI::Element);
|
||||
|
||||
virtual const char *getScriptableName() const { return "UICheckBox"; }
|
||||
virtual const char *getScriptObjectType() const { return "UICheckBox"; }
|
||||
};
|
||||
|
||||
#endif // UICHECKBOX_H
|
||||
|
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include <global.h>
|
||||
#include <ui/uicheckboxskin.h>
|
||||
|
||||
|
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UICHECKBOXSKIN_H
|
||||
#define UICHECKBOXSKIN_H
|
||||
|
||||
|
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UICONSTANTS_H
|
||||
#define UICONSTANTS_H
|
||||
|
||||
@@ -39,13 +15,13 @@ namespace UI {
|
||||
};
|
||||
|
||||
enum AnchorPoint {
|
||||
AnchorLeft = 0,
|
||||
AnchorHorizontalCenter,
|
||||
AnchorRight,
|
||||
AnchorNone = 0,
|
||||
AnchorTop,
|
||||
AnchorVerticalCenter,
|
||||
AnchorBottom,
|
||||
AnchorNone
|
||||
AnchorLeft,
|
||||
AnchorRight,
|
||||
AnchorVerticalCenter,
|
||||
AnchorHorizontalCenter,
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include <global.h>
|
||||
#include <core/resources.h>
|
||||
#include <ui/uicontainer.h>
|
||||
|
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UICONTAINER_H
|
||||
#define UICONTAINER_H
|
||||
|
||||
@@ -76,7 +52,7 @@ public:
|
||||
virtual UI::ElementType getElementType() const { return UI::Container; }
|
||||
UIContainerPtr asUIContainer() { return boost::static_pointer_cast<UIContainer>(shared_from_this()); }
|
||||
|
||||
virtual const char *getScriptableName() const { return "UIContainer"; }
|
||||
virtual const char *getScriptObjectType() const { return "UIContainer"; }
|
||||
|
||||
/// Get root container (the container that contains everything)
|
||||
static UIContainerPtr& getRoot();
|
||||
|
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include <global.h>
|
||||
#include <core/dispatcher.h>
|
||||
#include <graphics/graphics.h>
|
||||
@@ -31,7 +7,7 @@
|
||||
#include <ui/uicontainer.h>
|
||||
|
||||
UIElement::UIElement(UI::ElementType type) :
|
||||
Scriptable(),
|
||||
ScriptObject(),
|
||||
m_type(type),
|
||||
m_visible(true),
|
||||
m_enabled(true),
|
||||
@@ -60,14 +36,14 @@ void UIElement::destroy()
|
||||
//logTraceDebug(getId());
|
||||
|
||||
UIElementPtr me = asUIElement();
|
||||
callLuaTableField("onDestroy");
|
||||
callScriptTableField("onDestroy");
|
||||
|
||||
// remove from parent
|
||||
if(getParent())
|
||||
getParent()->removeChild(me);
|
||||
|
||||
// free script stuff
|
||||
releaseLuaTableRef();
|
||||
releaseScriptObject();
|
||||
|
||||
g_dispatcher.addTask(boost::bind(&UIElement::destroyCheck, me));
|
||||
}
|
||||
@@ -115,7 +91,7 @@ void UIElement::setSkin(const UIElementSkinPtr& skin)
|
||||
|
||||
void UIElement::onLoad()
|
||||
{
|
||||
g_dispatcher.addTask(boost::bind(&Scriptable::callLuaTableField, shared_from_this(), "onLoad", 0));
|
||||
g_dispatcher.addTask(boost::bind(&ScriptObject::callScriptTableField, shared_from_this(), "onLoad", 0));
|
||||
}
|
||||
|
||||
void UIElement::render()
|
||||
|
@@ -1,33 +1,9 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UIELEMENT_H
|
||||
#define UIELEMENT_H
|
||||
|
||||
#include <global.h>
|
||||
#include <core/input.h>
|
||||
#include <script/scriptable.h>
|
||||
#include <script/scriptobject.h>
|
||||
#include <ui/uiconstants.h>
|
||||
#include <ui/uielementskin.h>
|
||||
#include <ui/uilayout.h>
|
||||
@@ -42,7 +18,7 @@ class UIElement;
|
||||
typedef boost::shared_ptr<UIElement> UIElementPtr;
|
||||
typedef boost::weak_ptr<UIElement> UIElementWeakPtr;
|
||||
|
||||
class UIElement : public Scriptable
|
||||
class UIElement : public ScriptObject
|
||||
{
|
||||
public:
|
||||
UIElement(UI::ElementType type = UI::Element);
|
||||
@@ -94,7 +70,7 @@ public:
|
||||
|
||||
UIElementPtr asUIElement() { return boost::static_pointer_cast<UIElement>(shared_from_this()); }
|
||||
virtual UIContainerPtr asUIContainer() { return UIContainerPtr(); }
|
||||
virtual const char *getScriptableName() const { return "UIElement"; }
|
||||
virtual const char *getScriptObjectType() const { return "UIElement"; }
|
||||
|
||||
void setSize(const Size& size);
|
||||
Size getSize() { return m_rect.size(); }
|
||||
|
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include <global.h>
|
||||
#include <ui/uiskins.h>
|
||||
#include <ui/uielement.h>
|
||||
@@ -56,35 +32,7 @@ ImagePtr UIElementSkin::loadImage(OTMLNode* node)
|
||||
TexturePtr texture;
|
||||
|
||||
if(OTMLNode* cnode = node->at("bordered image")) {
|
||||
Rect left = cnode->readAt("left border", Rect());
|
||||
Rect right = cnode->readAt("right border", Rect());
|
||||
Rect top = cnode->readAt("top border", Rect());
|
||||
Rect bottom = cnode->readAt("bottom border", Rect());
|
||||
Rect topLeft = cnode->readAt("top left corner", Rect());
|
||||
Rect topRight = cnode->readAt("top right corner", Rect());
|
||||
Rect bottomLeft = cnode->readAt("bottom left corner", Rect());
|
||||
Rect bottomRight = cnode->readAt("bottom right corner", Rect());
|
||||
Rect center = cnode->readAt("center", Rect());
|
||||
std::string textureName = cnode->readAt("source", std::string());
|
||||
|
||||
if(!textureName.empty())
|
||||
texture = g_textures.get(textureName);
|
||||
else
|
||||
texture = g_uiSkins.getDefaultTexture();
|
||||
|
||||
if(texture) {
|
||||
image = ImagePtr(new BorderedImage(texture,
|
||||
left,
|
||||
right,
|
||||
top,
|
||||
bottom,
|
||||
topLeft,
|
||||
topRight,
|
||||
bottomLeft,
|
||||
bottomRight,
|
||||
center));
|
||||
}
|
||||
|
||||
image = BorderedImage::loadFromOTMLNode(cnode, g_uiSkins.getDefaultTexture());
|
||||
if(!image)
|
||||
error(node->generateErrorMessage("failed to load bordered image"));
|
||||
} else if(OTMLNode* cnode = node->at("image")) {
|
||||
|
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UIELEMENTSKIN_H
|
||||
#define UIELEMENTSKIN_H
|
||||
|
||||
|
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include <global.h>
|
||||
#include <ui/uilabel.h>
|
||||
|
||||
|
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UILABEL_H
|
||||
#define UILABEL_H
|
||||
|
||||
@@ -42,7 +18,7 @@ public:
|
||||
void setAlign(AlignmentFlag align) { m_align = align; }
|
||||
AlignmentFlag getAlign() const { return m_align; }
|
||||
|
||||
virtual const char *getScriptableName() const { return "UILabel"; }
|
||||
virtual const char *getScriptObjectType() const { return "UILabel"; }
|
||||
|
||||
private:
|
||||
std::string m_text;
|
||||
|
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include <global.h>
|
||||
#include <graphics/fonts.h>
|
||||
#include <ui/uilabelskin.h>
|
||||
|
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UILABELSKIN_H
|
||||
#define UILABELSKIN_H
|
||||
|
||||
|
@@ -1,27 +1,3 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UILAYOUT_H
|
||||
#define UILAYOUT_H
|
||||
|
||||
|
@@ -1,33 +1,9 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include <global.h>
|
||||
#include <core/resources.h>
|
||||
#include <ui/ui.h>
|
||||
#include <ui/uiloader.h>
|
||||
#include <script/luascript.h>
|
||||
#include <script/luafunctions.h>
|
||||
#include <script/scriptcontext.h>
|
||||
#include <script/scriptfunctions.h>
|
||||
#include <otml/otml.h>
|
||||
#include <ui/uianchorlayout.h>
|
||||
#include <util/translator.h>
|
||||
@@ -42,8 +18,9 @@ UIElementPtr UILoader::createElementFromId(const std::string& id)
|
||||
|
||||
std::vector<std::string> split;
|
||||
boost::split(split, id, boost::is_any_of(std::string("#")));
|
||||
if(split.size() != 2)
|
||||
if(split.size() != 2) {
|
||||
return element;
|
||||
}
|
||||
|
||||
std::string elementType = split[0].substr(1);
|
||||
std::string elementId = split[1];
|
||||
@@ -164,7 +141,7 @@ void UILoader::loadElement(const UIElementPtr& element, OTMLNode* node)
|
||||
element->setSkin(g_uiSkins.getElementSkin(element->getElementType(), "default"));
|
||||
|
||||
// load elements common proprieties
|
||||
if(node->hasNode("size"))
|
||||
if(node->hasChild("size"))
|
||||
element->setSize(node->readAt<Size>("size"));
|
||||
|
||||
// load margins
|
||||
@@ -247,7 +224,7 @@ void UILoader::loadElementScriptFunction(const UIElementPtr& element, OTMLNode*
|
||||
functionDesc += "[" + node->tag() + "]";
|
||||
|
||||
if(g_lua.loadBufferAsFunction(node->value(), functionDesc))
|
||||
g_lua.setScriptableField(element, node->tag());
|
||||
g_lua.setScriptObjectField(element, node->tag());
|
||||
else
|
||||
error(node->generateErrorMessage("failed to parse inline lua script"));
|
||||
}
|
||||
|
@@ -41,7 +41,7 @@ void UISkins::load(const std::string& skinName)
|
||||
g_resources.pushCurrentPath("skins");
|
||||
|
||||
std::stringstream fin;
|
||||
if(!g_resources.loadFile(skinName + ".yml", fin))
|
||||
if(!g_resources.loadFile(skinName + ".otml", fin))
|
||||
fatal("FATAL ERROR: Could not load skin '",skinName,"'");
|
||||
|
||||
try {
|
||||
|
@@ -46,7 +46,7 @@ public:
|
||||
|
||||
bool isFocusable() const { return true; }
|
||||
|
||||
virtual const char *getScriptableName() const { return "UITextEdit"; }
|
||||
virtual const char *getScriptObjectType() const { return "UITextEdit"; }
|
||||
|
||||
private:
|
||||
TextArea m_textArea;
|
||||
|
@@ -40,7 +40,7 @@ public:
|
||||
void setTitle(const std::string& title) { m_title = title; }
|
||||
std::string getTitle() const { return m_title; }
|
||||
|
||||
virtual const char *getScriptableName() const { return "UIWindow"; }
|
||||
virtual const char *getScriptObjectType() const { return "UIWindow"; }
|
||||
|
||||
virtual bool isFocusable() const { return true; }
|
||||
|
||||
|
Reference in New Issue
Block a user