This commit is contained in:
Andre Antunes 2011-08-27 20:18:18 -03:00
commit 3d4556e5c9
8 changed files with 22 additions and 10 deletions

View File

@ -13,4 +13,6 @@ LogWarning = 2
LogError = 3 LogError = 3
LogFatal = 4 LogFatal = 4
ActiveFocusReason = 2
EmptyFunction = function() end EmptyFunction = function() end

View File

@ -6,6 +6,7 @@ function EnterGame_characterWindow_okClicked()
local selected = charactersWindow:getChildById('charactersList'):getFocusedChild() local selected = charactersWindow:getChildById('charactersList'):getFocusedChild()
if selected then if selected then
Game.loginWorld(account, password, selected.worldHost, selected.worldPort, selected.characterName) Game.loginWorld(account, password, selected.worldHost, selected.worldPort, selected.characterName)
Configs.set('lastUsedCharacter', selected.characterName)
charactersWindow:destroy() charactersWindow:destroy()
mainMenu:hide() mainMenu:hide()
else else
@ -24,6 +25,7 @@ local function createCharactersWindow(characters, premDays)
local charactersWindow = UI.loadAndDisplayLocked('/mainmenu/ui/charlist.otui') local charactersWindow = UI.loadAndDisplayLocked('/mainmenu/ui/charlist.otui')
local charactersList = charactersWindow:getChildById('charactersList') local charactersList = charactersWindow:getChildById('charactersList')
local accountStatusLabel = charactersWindow:getChildById('accountStatusLabel') local accountStatusLabel = charactersWindow:getChildById('accountStatusLabel')
for i,characterInfo in ipairs(characters) do for i,characterInfo in ipairs(characters) do
local characterName = characterInfo[1] local characterName = characterInfo[1]
local worldName = characterInfo[2] local worldName = characterInfo[2]
@ -37,6 +39,10 @@ local function createCharactersWindow(characters, premDays)
label.characterName = characterName label.characterName = characterName
label.worldHost = worldHost label.worldHost = worldHost
label.worldPort = worldIp label.worldPort = worldIp
if i == 0 or Configs.get('lastUsedCharacter') == characterName then
charactersList:focusChild(label, ActiveFocusReason)
end
end end
if premDays > 0 then if premDays > 0 then
accountStatusLabel:setText("Account Status:\nPremium Account (" .. premDays .. ' days left)') accountStatusLabel:setText("Account Status:\nPremium Account (" .. premDays .. ' days left)')

View File

@ -2,6 +2,7 @@
#define LOGGER_H #define LOGGER_H
#include "../util/tools.h" #include "../util/tools.h"
#include "../const.h"
#include <vector> #include <vector>
#include <functional> #include <functional>

View File

@ -22,14 +22,12 @@ AnimatedTexture::AnimatedTexture(int width, int height, int channels, int numFra
m_framesTextureId[i] = id; m_framesTextureId[i] = id;
m_framesDelay[i] = framesDelay[i]; m_framesDelay[i] = framesDelay[i];
} }
m_currentFrame = -1; m_currentFrame = -1;
g_dispatcher.scheduleEvent(std::bind(&AnimatedTexture::processAnimation, this), 0); g_dispatcher.scheduleEvent(std::bind(&AnimatedTexture::processAnimation, this), 0);
} }
AnimatedTexture::~AnimatedTexture() AnimatedTexture::~AnimatedTexture()
{ {
assert(!g_graphics.isDrawing());
glDeleteTextures(m_numFrames, &m_framesTextureId[0]); glDeleteTextures(m_numFrames, &m_framesTextureId[0]);
m_textureId = 0; m_textureId = 0;
} }
@ -49,7 +47,10 @@ void AnimatedTexture::processAnimation()
if(m_currentFrame >= m_numFrames) if(m_currentFrame >= m_numFrames)
m_currentFrame = 0; m_currentFrame = 0;
m_textureId = m_framesTextureId[m_currentFrame]; m_textureId = m_framesTextureId[m_currentFrame];
AnimatedTexturePtr me = std::static_pointer_cast<AnimatedTexture>(shared_from_this());
if(me.use_count() > 1) AnimatedTexturePtr self = asAnimatedTexture();
g_dispatcher.addEvent(std::bind(&AnimatedTexture::processAnimation, me), m_framesDelay[m_currentFrame]);
// continue to animate only if something still referencing this texture
if(self.use_count() > 1)
g_dispatcher.scheduleEvent(std::bind(&AnimatedTexture::processAnimation, self), m_framesDelay[m_currentFrame]);
} }

View File

@ -12,6 +12,8 @@ public:
void enableBilinearFilter(); void enableBilinearFilter();
void processAnimation(); void processAnimation();
AnimatedTexturePtr asAnimatedTexture() { return std::static_pointer_cast<AnimatedTexture>(shared_from_this()); }
private: private:
std::vector<uint> m_framesTextureId; std::vector<uint> m_framesTextureId;
std::vector<int> m_framesDelay; std::vector<int> m_framesDelay;
@ -20,7 +22,4 @@ private:
int m_lastAnimCheckTicks; int m_lastAnimCheckTicks;
}; };
typedef std::shared_ptr<AnimatedTexture> AnimatedTexturePtr;
typedef std::weak_ptr<AnimatedTexture> AnimatedTextureWeakPtr;
#endif #endif

View File

@ -4,6 +4,7 @@
#include <framework/global.h> #include <framework/global.h>
class Texture; class Texture;
class AnimatedTexture;
class Font; class Font;
class Image; class Image;
class BorderImage; class BorderImage;
@ -12,6 +13,7 @@ class FrameBuffer;
typedef std::weak_ptr<Texture> TextureWeakPtr; typedef std::weak_ptr<Texture> TextureWeakPtr;
typedef std::shared_ptr<Texture> TexturePtr; typedef std::shared_ptr<Texture> TexturePtr;
typedef std::shared_ptr<AnimatedTexture> AnimatedTexturePtr;
typedef std::shared_ptr<Font> FontPtr; typedef std::shared_ptr<Font> FontPtr;
typedef std::shared_ptr<Image> ImagePtr; typedef std::shared_ptr<Image> ImagePtr;
typedef std::shared_ptr<BorderImage> BorderImagePtr; typedef std::shared_ptr<BorderImage> BorderImagePtr;

View File

@ -5,11 +5,11 @@
#include "luainterface.h" #include "luainterface.h"
#include "luaexception.h" #include "luaexception.h"
/// This namespace contains some dirty metaprogamming with C++0x features /// This namespace contains some dirty metaprogamming that uses a lot of C++0x features
/// The purpose here is to create templates that can bind any function from C++ /// The purpose here is to create templates that can bind any function from C++
/// and expose in lua environment. This is done combining variadic templates, /// and expose in lua environment. This is done combining variadic templates,
/// lambdas, tuples and some type traits features from the new C++0x standard to create /// lambdas, tuples and some type traits features from the new C++0x standard to create
/// templates that can detect functions arguments to generate a lambdas. These lambdas /// templates that can detect functions's arguments and then generate lambdas. These lambdas
/// pops arguments from lua stack, call the bound C++ function and then /// pops arguments from lua stack, call the bound C++ function and then
/// pushes the result to lua. /// pushes the result to lua.
namespace luabinder namespace luabinder

View File

@ -46,6 +46,7 @@ void LuaInterface::registerFunctions()
g_lua.bindClassMemberFunction<UIWidget>("insertChild", &UIWidget::insertChild); g_lua.bindClassMemberFunction<UIWidget>("insertChild", &UIWidget::insertChild);
g_lua.bindClassMemberFunction<UIWidget>("removeChild", &UIWidget::removeChild); g_lua.bindClassMemberFunction<UIWidget>("removeChild", &UIWidget::removeChild);
g_lua.bindClassMemberFunction<UIWidget>("addChild", &UIWidget::addChild); g_lua.bindClassMemberFunction<UIWidget>("addChild", &UIWidget::addChild);
g_lua.bindClassMemberFunction<UIWidget>("focusChild", &UIWidget::focusChild);
g_lua.bindClassMemberFunction<UIWidget>("lockChild", &UIWidget::lockChild); g_lua.bindClassMemberFunction<UIWidget>("lockChild", &UIWidget::lockChild);
g_lua.bindClassMemberFunction<UIWidget>("updateLayout", &UIWidget::updateLayout); g_lua.bindClassMemberFunction<UIWidget>("updateLayout", &UIWidget::updateLayout);
g_lua.bindClassMemberFunction<UIWidget>("updateParentLayout", &UIWidget::updateParentLayout); g_lua.bindClassMemberFunction<UIWidget>("updateParentLayout", &UIWidget::updateParentLayout);