new script engine, and things maybe be bugged for a while

This commit is contained in:
Eduardo Bart
2011-07-26 20:13:27 -03:00
parent ab7394f357
commit 70f0b0dace
137 changed files with 2905 additions and 2578 deletions

View File

@@ -44,7 +44,7 @@ AnimatedTexture::AnimatedTexture(int width, int height, int channels, int numFra
}
m_currentFrame = -1;
g_dispatcher.scheduleTask(boost::bind(&AnimatedTexture::processAnimation, this), 0);
g_dispatcher.scheduleTask(std::bind(&AnimatedTexture::processAnimation, this), 0);
}
AnimatedTexture::~AnimatedTexture()
@@ -70,7 +70,7 @@ void AnimatedTexture::processAnimation()
if(m_currentFrame >= m_numFrames)
m_currentFrame = 0;
m_textureId = m_framesTextureId[m_currentFrame];
AnimatedTexturePtr me = boost::static_pointer_cast<AnimatedTexture>(shared_from_this());
AnimatedTexturePtr me = std::static_pointer_cast<AnimatedTexture>(shared_from_this());
if(me.use_count() > 1)
g_dispatcher.scheduleTask(boost::bind(&AnimatedTexture::processAnimation, me), m_framesDelay[m_currentFrame]);
g_dispatcher.scheduleTask(std::bind(&AnimatedTexture::processAnimation, me), m_framesDelay[m_currentFrame]);
}

View File

@@ -45,7 +45,7 @@ private:
int m_lastAnimCheckTicks;
};
typedef boost::shared_ptr<AnimatedTexture> AnimatedTexturePtr;
typedef boost::weak_ptr<AnimatedTexture> AnimatedTextureWeakPtr;
typedef std::shared_ptr<AnimatedTexture> AnimatedTexturePtr;
typedef std::weak_ptr<AnimatedTexture> AnimatedTextureWeakPtr;
#endif // ANIMATEDTEXTURE_H

View File

@@ -96,13 +96,13 @@ BorderedImagePtr BorderedImage::loadFromOTMLNode(OTMLNode* node, TexturePtr defa
left = node->readAt("left", left);
right = node->readAt("right", right);
leftBorder = Rect(subRect.left(), subRect.top() + top, left, subRect.height() - top - bottom);
rightBorder = Rect(subRect.right() - right, subRect.top() + top, right, subRect.height() - top - bottom);
rightBorder = Rect(subRect.right() - right + 1, subRect.top() + top, right, subRect.height() - top - bottom);
topBorder = Rect(subRect.left() + left, subRect.top(), subRect.width() - right - left, top);
bottomBorder = Rect(subRect.left() + left, subRect.bottom() - bottom, subRect.width() - right - left, bottom);
bottomBorder = Rect(subRect.left() + left, subRect.bottom() - bottom + 1, subRect.width() - right - left, bottom);
topLeftCorner = Rect(subRect.left(), subRect.top(), left, top);
topRightCorner = Rect(subRect.right() - right, subRect.top(), right, top);
topRightCorner = Rect(subRect.right() - right + 1, subRect.top(), right, top);
bottomLeftCorner = Rect(subRect.left(), subRect.bottom() - bottom, left, bottom);
bottomRightCorner = Rect(subRect.right() - right, subRect.bottom() - bottom, right, bottom);
bottomRightCorner = Rect(subRect.right() - right + 1, subRect.bottom() - bottom + 1, right, bottom);
center = Rect(subRect.left() + left, subRect.top() + top, subRect.width() - right - left, subRect.height() - top - bottom);
leftBorder = node->readAt("left border", leftBorder);
rightBorder = node->readAt("right border", rightBorder);

View File

@@ -31,7 +31,7 @@
#include <otml/otmlnode.h>
class BorderedImage;
typedef boost::shared_ptr<BorderedImage> BorderedImagePtr;
typedef std::shared_ptr<BorderedImage> BorderedImagePtr;
class BorderedImage : public Image
{

View File

@@ -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 <graphics/font.h>
@@ -54,6 +30,7 @@ void Font::calculateGlyphsWidthsAutomatically(const Size& glyphSize)
// if all pixels were alpha we found the width
if(columnFilledPixels == 0) {
width = x - glyphCoords.left();
width += m_glyphSpacing.width();
if(m_glyphHeight >= 16 && lastColumnFilledPixels >= m_glyphHeight/3)
width += 1;
break;
@@ -84,11 +61,11 @@ bool Font::load(const std::string& file)
// required values
textureName = doc->valueAt("image");
glyphSize = doc->readAt("image glyph size", Size(16, 16));
m_glyphHeight = doc->readAt("glyph height", 11);
m_firstGlyph = doc->readAt("first glyph", 32);
m_topMargin = doc->readAt("top margin", 0);
m_glyphSpacing = doc->readAt("glyph spacing", Size(0,0));
glyphSize = doc->readAt("image-glyph-size", Size(16, 16));
m_glyphHeight = doc->readAt("glyph-height", 11);
m_firstGlyph = doc->readAt("first-glyph", 32);
m_topMargin = doc->readAt("top-margin", 0);
m_glyphSpacing = doc->readAt("glyph-spacing", Size(0,0));
// load texture
m_texture = g_textures.get(textureName);
@@ -101,16 +78,16 @@ bool Font::load(const std::string& file)
calculateGlyphsWidthsAutomatically(glyphSize);
// read custom widths
if(doc->hasChild("glyph widths")) {
if(doc->hasChild("glyph-widths")) {
std::map<int, int> glyphWidths;
doc->readAt("glyph widths", &glyphWidths);
doc->readAt("glyph-widths", &glyphWidths);
foreach(const auto& pair, glyphWidths)
m_glyphsSize[pair.first].setWidth(pair.second);
}
// calculate glyphs texture coords
int numHorizontalGlyphs = m_texture->getSize().width() / glyphSize.width();
for(int glyph = m_firstGlyph; glyph< 256; ++glyph) {
for(int glyph = m_firstGlyph; glyph < 256; ++glyph) {
m_glyphsTextureCoords[glyph].setRect(((glyph - m_firstGlyph) % numHorizontalGlyphs) * glyphSize.width(),
((glyph - m_firstGlyph) / numHorizontalGlyphs) * glyphSize.height(),
m_glyphsSize[glyph].width(),
@@ -248,7 +225,7 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
lineWidths.resize(lines+1);
lineWidths[lines] = 0;
} else if(glyph >= 32) {
lineWidths[lines] += m_glyphsSize[glyph].width() + m_glyphSpacing.width();
lineWidths[lines] += m_glyphsSize[glyph].width();
maxLineWidth = std::max(maxLineWidth, lineWidths[lines]);
}
}
@@ -281,7 +258,7 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
// render only if the glyph is valid
if(glyph >= 32 && glyph != (uchar)'\n') {
virtualPos.x += m_glyphsSize[glyph].width() + m_glyphSpacing.width();
virtualPos.x += m_glyphsSize[glyph].width();
}
}

View File

@@ -75,6 +75,6 @@ private:
Size m_glyphsSize[256];
};
typedef boost::shared_ptr<Font> FontPtr;
typedef std::shared_ptr<Font> FontPtr;
#endif // FONT_H

View File

@@ -1,32 +1,7 @@
/* 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 <graphics/fonts.h>
#include <boost/algorithm/string.hpp>
Fonts g_fonts;

View File

@@ -44,6 +44,6 @@ protected:
Rect m_textureCoords;
};
typedef boost::shared_ptr<Image> ImagePtr;
typedef std::shared_ptr<Image> ImagePtr;
#endif // IMAGE_H

View File

@@ -27,7 +27,7 @@
#include <global.h>
class Texture : public boost::enable_shared_from_this<Texture>
class Texture : public std::enable_shared_from_this<Texture>
{
public:
/// Create a texture, width and height must be a multiple of 2
@@ -55,7 +55,7 @@ protected:
Size m_glSize;
};
typedef boost::shared_ptr<Texture> TexturePtr;
typedef boost::weak_ptr<Texture> TextureWeakPtr;
typedef std::shared_ptr<Texture> TexturePtr;
typedef std::weak_ptr<Texture> TextureWeakPtr;
#endif // TEXTURE_H

View File

@@ -28,8 +28,6 @@
#include <graphics/textureloader.h>
#include <core/dispatcher.h>
#include <boost/algorithm/string.hpp>
Textures g_textures;
TexturePtr Textures::get(const std::string& textureFile)