fix release keys on x11, remove ping addon, fix minor issue in outfit render, fix emblem updates

This commit is contained in:
Eduardo Bart 2012-01-15 23:55:14 -02:00
parent 44a20222bb
commit de0e4a1acf
11 changed files with 21 additions and 79 deletions

1
TODO
View File

@ -46,7 +46,6 @@ Low priority TODO
== Platform
[bart] port to MacOs and iphone
[bart] KeyDown, KeyText events
change win32 mouse cursor icon
== UI

View File

@ -1,27 +0,0 @@
PingBar = {}
local pingLabel
-- public functions
function PingBar.init()
pingLabel = createWidget('UILabel', rootWidget:recursiveGetChildById('leftButtonsPanel'))
pingLabel:applyStyle({ ['anchors.left'] = 'prev.right',
['anchors.top'] = 'parent.top',
['margin-top'] = 12,
['margin-left'] = 20,
font = 'verdana-11px-rounded',
color = '#FE6500',
width = 120,
height = 16})
end
function PingBar.terminate()
pingLabel:destroy()
end
-- hooked events
local function onGamePingUpdate(ping)
pingLabel:setText('Ping: ' .. ping .. ' ms')
end
connect(Game, { onWalkPingUpdate = onGamePingUpdate })

View File

@ -1,15 +0,0 @@
Module
name: pingbar
description: Show ping in game
author: OTClient team
website: https://github.com/edubart/otclient
autoLoad: true
autoLoadAntecedence: 1000
onLoad: |
require 'pingbar'
PingBar.init()
onUnload: |
PingBar.terminate()

View File

@ -91,6 +91,19 @@ void PlatformWindow::processKeyRelease(Fw::Key keyCode)
}
}
void PlatformWindow::releaseAllKeys()
{
for(auto it : m_keysState) {
Fw::Key keyCode = it.first;
bool pressed = it.second;
if(!pressed)
continue;
processKeyRelease(keyCode);
}
}
void PlatformWindow::fireKeysPress()
{
// avoid massive checks
@ -119,4 +132,3 @@ void PlatformWindow::fireKeysPress()
}
}
}

View File

@ -94,6 +94,7 @@ protected:
void processKeyDown(Fw::Key keyCode);
void processKeyRelease(Fw::Key keyCode);
void releaseAllKeys();
void fireKeysPress();
std::map<int, Fw::Key> m_keyMap;

View File

@ -710,6 +710,7 @@ void X11Window::poll()
break;
case FocusOut:
m_focused = false;
releaseAllKeys();
break;
case Expose:
// window needs redraw

View File

@ -117,8 +117,6 @@ void Creature::draw(const Point& p, const Rect&)
if(m_type->dimensions[ThingType::Layers] > 1) {
int maskId = m_type->getSpriteId(w, h, 1, m_xPattern, m_yPattern, m_zPattern, m_animation);
if(!maskId)
continue;
TexturePtr maskTex = g_sprites.getSpriteTexture(maskId);
outfitProgram->setUniformTexture(MASK_TEXTURE_UNIFORM, maskTex, 1);
}
@ -292,8 +290,7 @@ void Creature::cancelWalk(Otc::Direction direction, bool force)
if(direction != Otc::InvalidDirection)
setDirection(direction);
if(m_outfit.getCategory() == ThingsType::Creature)
m_animation = 0;
m_animation = 0;
}
void Creature::setName(const std::string& name)

View File

@ -36,9 +36,7 @@ void Game::loginWorld(const std::string& account, const std::string& password, c
{
m_online = false;
m_dead = false;
m_walkFeedback = true;
m_selectedThing = nullptr;
m_walkPing = 0;
m_protocolGame = ProtocolGamePtr(new ProtocolGame);
m_protocolGame->login(account, password, worldHost, (uint16)worldPort, characterName);
}
@ -146,16 +144,9 @@ void Game::processCreatureMove(const CreaturePtr& creature, const Position& oldP
// teleport
} else {
// stop walking on teleport
if(creature->isWalking())
if(creature->isWalking() || creature->isPreWalking())
creature->cancelWalk();
}
if(creature == m_localPlayer) {
if(!m_walkFeedback) {
updateWalkPing();
m_walkFeedback = true;
}
}
}
void Game::processAttackCancel()
@ -166,10 +157,6 @@ void Game::processAttackCancel()
void Game::processWalkCancel(Otc::Direction direction)
{
if(!m_walkFeedback) {
updateWalkPing();
m_walkFeedback = true;
}
m_localPlayer->cancelWalk(direction, true);
}
@ -190,9 +177,6 @@ void Game::walk(Otc::Direction direction)
void Game::forceWalk(Otc::Direction direction)
{
m_walkPingTimer.restart();
m_walkFeedback = false;
switch(direction) {
case Otc::North:
m_protocolGame->sendWalkNorth();
@ -478,9 +462,3 @@ bool Game::checkBotProtection()
#endif
return true;
}
void Game::updateWalkPing()
{
m_walkPing = m_walkPingTimer.ticksElapsed();
g_lua.callGlobalField("Game", "onWalkPingUpdate", m_walkPing);
}

View File

@ -114,18 +114,12 @@ public:
LocalPlayerPtr getLocalPlayer() { return m_localPlayer; }
ProtocolGamePtr getProtocolGame() { return m_protocolGame; }
int getProtocolVersion() { return PROTOCOL; }
int getWalkPing() { return m_walkPing; }
private:
void updateWalkPing();
LocalPlayerPtr m_localPlayer;
ProtocolGamePtr m_protocolGame;
bool m_online;
bool m_dead;
bool m_walkFeedback;
Timer m_walkPingTimer;
int m_walkPing;
int m_serverBeat;
ThingPtr m_selectedThing;
};

View File

@ -65,6 +65,7 @@ void Tile::draw(const Point& p, const Rect& visibleRect)
// we can render creatures in 3x3 range
//TODO: this algorithm is slowing down render too much, but it could be cached to improve framerate
//NOTE: looping for 9 tiles is a dirty way to render walking creatures, must change this later
for(int xi = -1; xi <= 1; ++xi) {
for(int yi = -1; yi <= 1; ++yi) {
for(CreaturePtr creature : g_map.getTile(m_pos + Position(xi, yi, 0))->getCreatures()) {

View File

@ -1124,7 +1124,7 @@ ThingPtr ProtocolGame::internalGetThing(InputMessage& msg)
int skull = msg.getU8();
int shield = msg.getU8();
int emblem = 0;
int emblem = -1;
if(thingId == 0x0061) // emblem is sent only in packet type 0x61
emblem = msg.getU8();
@ -1138,7 +1138,8 @@ ThingPtr ProtocolGame::internalGetThing(InputMessage& msg)
creature->setSpeed(speed);
creature->setSkull(skull);
creature->setShield(shield);
creature->setEmblem(emblem);
if(emblem != -1)
creature->setEmblem(emblem);
creature->setPassable(passable);
creature->cancelWalk(direction);
}