diff --git a/CMakeLists.txt b/CMakeLists.txt index c4f1fa78..88c27925 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,7 +52,7 @@ IF(CMAKE_BUILD_TYPE STREQUAL "Debug") ADD_DEFINITIONS(-D_DEBUG) ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug") -SET(SOURCES +SET(SOURCES src/framework/ui/uilinedecorationskin.cpp src/framework/ui/uicheckboxskin.cpp src/framework/ui/uilinedecoration.cpp src/framework/ui/uicheckbox.cpp # game sources src/main.cpp src/menustate.cpp diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..826ee55b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +OTClient is made available under 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. diff --git a/data/skins/tibiaskin.yml b/data/skins/tibiaskin.yml index 1b2305e7..66339f84 100644 --- a/data/skins/tibiaskin.yml +++ b/data/skins/tibiaskin.yml @@ -45,6 +45,10 @@ panels: bottom left corner: [43,230,5,5] bottom right corner: [48,231,5,5] center: [11,214,32,32] + + flatPanel: + bordered image: + labels: default: diff --git a/data/ui/infoWindow.yml b/data/ui/infoWindow.yml new file mode 100644 index 00000000..960322d6 --- /dev/null +++ b/data/ui/infoWindow.yml @@ -0,0 +1,60 @@ +window#infoWindow: + title: Info + size: [244, 221] + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + + panel#infoPanel: + skin: flatPanel + size: [208, 129] + anchors.left: parent.left + anchors.top: parent.top + margin.top: 32 + margin.left: 24 + + label#infoLabel: + size: [218, 83] + align: center + text: | + OTClient + Version 0.2.0 + Copyright (C) 2011 + Developed by edubart + + separator#bottomSeparator: + orientation: horizontal + width: 190 + anchors.left: parent.left + anchors.top: parent.top + margin.top: 83 + margin.left: 9 + + label#websiteLabel: + text: Official Website + anchors.left: parent.left + anchors.top: parent.top + margin.top: 105 + margin.left: 8 + + button#websiteButton: + text: github.com/otclient + anchors.left: parent.left + anchors.top: parent.top + margin.top: 99 + margin.left: 131 + + separator#bottomSeparator: + orientation: horizontal + width: 218 + anchors.left: parent.left + anchors.top: parent.top + margin.top: 181 + margin.left: 13 + + button#okButton: + text: Ok + size: [43, 20] + anchors.left: parent.left + anchors.top: parent.top + margin.top: 191 + margin.left: 188 \ No newline at end of file diff --git a/data/ui/mainMenu.yml b/data/ui/mainMenu.yml index 4a84bb19..1438a708 100644 --- a/data/ui/mainMenu.yml +++ b/data/ui/mainMenu.yml @@ -1,6 +1,6 @@ panel#mainMenu: skin: roundedGridPanel - size: [118, 172] + size: [117, 171] anchors.left: parent.left anchors.bottom: parent.bottom margin.left: 60 diff --git a/src/framework/core/configs.cpp b/src/framework/core/configs.cpp index 466392b3..ab074885 100644 --- a/src/framework/core/configs.cpp +++ b/src/framework/core/configs.cpp @@ -35,7 +35,7 @@ bool Configs::load(const std::string& fileName) return false; std::string fileContents = g_resources.loadTextFile(fileName); - if(fileContents.size()) + if(!fileContents.size()) return false; std::istringstream fin(fileContents); diff --git a/src/framework/core/engine.cpp b/src/framework/core/engine.cpp index 1b3ed94f..b320b7d3 100644 --- a/src/framework/core/engine.cpp +++ b/src/framework/core/engine.cpp @@ -133,7 +133,7 @@ void Engine::onClose() void Engine::onResize(const Size& size) { g_graphics.resize(size); - UIContainer::getRootContainer()->setSize(Size(size.width()-1, size.height()-1)); + UIContainer::getRootContainer()->setSize(size); if(m_currentState) m_currentState->onResize(size); diff --git a/src/framework/ui/uibuttonskin.cpp b/src/framework/ui/uibuttonskin.cpp index 657645cd..2f614747 100644 --- a/src/framework/ui/uibuttonskin.cpp +++ b/src/framework/ui/uibuttonskin.cpp @@ -30,8 +30,6 @@ void UIButtonSkin::load(const YAML::Node& node) { UIElementSkin::load(node); - std::string tmp; - m_buttonDownImage = loadImage(node["down state"]); if(node["down state"].FindValue("text translate")) @@ -40,8 +38,7 @@ void UIButtonSkin::load(const YAML::Node& node) if(node.FindValue("mouse over state")) m_buttonHoverImage = loadImage(node["mouse over state"]); - node["font"] >> tmp; - m_font = g_fonts.get(tmp); + m_font = g_fonts.get(node["font"].Read()); node["text color"] >> m_textColor; } diff --git a/src/framework/ui/uicheckbox.cpp b/src/framework/ui/uicheckbox.cpp new file mode 100644 index 00000000..72baf1b3 --- /dev/null +++ b/src/framework/ui/uicheckbox.cpp @@ -0,0 +1,7 @@ +#include "uicheckbox.h" + +UICheckBox::UICheckBox(UI::EElementType type): UIElement(type) +{ + +} + diff --git a/src/framework/ui/uicheckbox.h b/src/framework/ui/uicheckbox.h new file mode 100644 index 00000000..12b54c6f --- /dev/null +++ b/src/framework/ui/uicheckbox.h @@ -0,0 +1,14 @@ +#ifndef UICHECKBOX_H +#define UICHECKBOX_H + +#include + + +class UICheckBox : public UIElement +{ + +public: +UICheckBox(UI::EElementType type = UI::Element); +}; + +#endif // UICHECKBOX_H diff --git a/src/framework/ui/uicheckboxskin.cpp b/src/framework/ui/uicheckboxskin.cpp new file mode 100644 index 00000000..22dd7f6b --- /dev/null +++ b/src/framework/ui/uicheckboxskin.cpp @@ -0,0 +1,2 @@ +#include "uicheckboxskin.h" + diff --git a/src/framework/ui/uicheckboxskin.h b/src/framework/ui/uicheckboxskin.h new file mode 100644 index 00000000..ba09721a --- /dev/null +++ b/src/framework/ui/uicheckboxskin.h @@ -0,0 +1,8 @@ +#ifndef UICHECKBOXSKIN_H +#define UICHECKBOXSKIN_H + +class UICheckBoxSkin +{ +}; + +#endif // UICHECKBOXSKIN_H diff --git a/src/framework/ui/uilabelskin.cpp b/src/framework/ui/uilabelskin.cpp index 3fe9fa04..b8dc291d 100644 --- a/src/framework/ui/uilabelskin.cpp +++ b/src/framework/ui/uilabelskin.cpp @@ -29,12 +29,10 @@ void UILabelSkin::load(const YAML::Node& node) { UIElementSkin::load(node); - std::string tmp; - if(node.FindValue("font")) { - node["font"] >> tmp; - m_font = g_fonts.get(tmp); - } else + if(node.FindValue("font")) + m_font = g_fonts.get(node["font"].Read()); + else m_font = g_fonts.getDefaultFont(); if(node.FindValue("text color")) diff --git a/src/framework/ui/uilinedecoration.cpp b/src/framework/ui/uilinedecoration.cpp new file mode 100644 index 00000000..5082632e --- /dev/null +++ b/src/framework/ui/uilinedecoration.cpp @@ -0,0 +1,2 @@ +#include "uilinedecoration.h" + diff --git a/src/framework/ui/uilinedecoration.h b/src/framework/ui/uilinedecoration.h new file mode 100644 index 00000000..4f6f64ab --- /dev/null +++ b/src/framework/ui/uilinedecoration.h @@ -0,0 +1,8 @@ +#ifndef UILINEDECORATION_H +#define UILINEDECORATION_H + +class UILineDecoration +{ +}; + +#endif // UILINEDECORATION_H diff --git a/src/framework/ui/uilinedecorationskin.cpp b/src/framework/ui/uilinedecorationskin.cpp new file mode 100644 index 00000000..04748efb --- /dev/null +++ b/src/framework/ui/uilinedecorationskin.cpp @@ -0,0 +1,2 @@ +#include "uilinedecorationskin.h" + diff --git a/src/framework/ui/uilinedecorationskin.h b/src/framework/ui/uilinedecorationskin.h new file mode 100644 index 00000000..21ea5510 --- /dev/null +++ b/src/framework/ui/uilinedecorationskin.h @@ -0,0 +1,8 @@ +#ifndef UILINEDECORATIONSKIN_H +#define UILINEDECORATIONSKIN_H + +class UILineDecorationSkin +{ +}; + +#endif // UILINEDECORATIONSKIN_H diff --git a/src/framework/ui/uiloader.cpp b/src/framework/ui/uiloader.cpp index 331e6dbf..ae15d5a4 100644 --- a/src/framework/ui/uiloader.cpp +++ b/src/framework/ui/uiloader.cpp @@ -142,8 +142,6 @@ void UILoader::loadElements(const UIElementPtr& parent, const YAML::Node& node) void UILoader::loadElement(const UIElementPtr& element, const YAML::Node& node) { - std::string tmp; - if(node.FindValue("skin")) element->setSkin(g_uiSkins.getElementSkin(element->getElementType(), node["skin"])); @@ -195,18 +193,15 @@ void UILoader::loadElement(const UIElementPtr& element, const YAML::Node& node) // load specific element type if(element->getElementType() == UI::Button) { UIButtonPtr button = boost::static_pointer_cast(element); - node["text"] >> tmp; - button->setText(tmp); + button->setText(node["text"].Read()); } else if(element->getElementType() == UI::Window) { UIWindowPtr window = boost::static_pointer_cast(element); - node["title"] >> tmp; - window->setTitle(tmp); + window->setTitle(node["title"].Read()); } else if(element->getElementType() == UI::Label) { UILabelPtr label = boost::static_pointer_cast(element); - node["text"] >> tmp; - label->setText(tmp); + label->setText(node["text"].Read()); } } diff --git a/src/framework/ui/uitexteditskin.cpp b/src/framework/ui/uitexteditskin.cpp index 97888cda..f5180f23 100644 --- a/src/framework/ui/uitexteditskin.cpp +++ b/src/framework/ui/uitexteditskin.cpp @@ -29,11 +29,9 @@ void UITextEditSkin::load(const YAML::Node& node) { UIElementSkin::load(node); - std::string tmp; if(node.FindValue("font")) { - node["font"] >> tmp; - m_font = g_fonts.get(tmp); + m_font = g_fonts.get(node["font"].Read()); } else m_font = g_fonts.getDefaultFont(); diff --git a/src/framework/util/rect.h b/src/framework/util/rect.h index 44220799..5a609c5b 100644 --- a/src/framework/util/rect.h +++ b/src/framework/util/rect.h @@ -77,8 +77,8 @@ public: inline void setBottomLeft(const TPoint &p) { x1 = p.x; y2 = p.y; } inline void setWidth(T width) { x2 = x1 + width - 1; } inline void setHeight(T height) { y2 = y1 + height- 1; } - inline void setSize(T width, T height) { x2 = x1 + width; y2 = y1 + height; } - inline void setSize(const TSize& size) { x2 = x1 + size.width(); y2 = y1 + size.height(); } + inline void setSize(T width, T height) { x2 = x1 + width - 1; y2 = y1 + height - 1; } + inline void setSize(const TSize& size) { x2 = x1 + size.width() - 1; y2 = y1 + size.height() - 1; } inline void setRect(T x, T y, T width, T height) { x1 = x; y1 = y; x2 = (x + width - 1); y2 = (y + height - 1); } inline void setCoords(int left, int top, int right, int bottom) { x1 = left; y1 = top; x2 = right; y2 = bottom; } diff --git a/src/framework/util/size.h b/src/framework/util/size.h index a7e68c93..4921343a 100644 --- a/src/framework/util/size.h +++ b/src/framework/util/size.h @@ -38,7 +38,7 @@ template class TSize { public: - inline TSize() : wd(-1), ht(-1) {}; + inline TSize() : wd(0), ht(0) {}; inline TSize(T width, T height) : wd(width), ht(height) { }; inline TSize(const TSize& other) : wd(other.wd), ht(other.ht) { };