fix messagebox and rename some stuff
This commit is contained in:
parent
619f751371
commit
1013ae279b
|
@ -29,7 +29,7 @@ local function tryLogin(charInfo, tries)
|
|||
end
|
||||
|
||||
if Game.isOnline() then
|
||||
Game.logout(false)
|
||||
Game.safeLogout()
|
||||
if tries == 1 then
|
||||
loadBox = displayCancelBox('Please wait', 'Loggin out...')
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ local gameButtonsPanel
|
|||
-- private functions
|
||||
local function onLogout()
|
||||
if Game.isOnline() then
|
||||
Game.logout(false)
|
||||
Game.safeLogout()
|
||||
else
|
||||
exit()
|
||||
end
|
||||
|
|
|
@ -3,3 +3,6 @@ Creature < UICreature
|
|||
padding: 1
|
||||
image-source: /core_styles/images/panel_flat.png
|
||||
image-border: 1
|
||||
|
||||
UIWidget
|
||||
id: lala
|
||||
|
|
|
@ -26,14 +26,15 @@ function UIMessageBox.display(title, message, flags)
|
|||
if flags == MessageBoxOk then
|
||||
buttonRight:setText('Ok')
|
||||
connect(buttonRight, { onClick = function(self) self:getParent():ok() end })
|
||||
connect(messagebox, { onEnter = function(self) self:ok() end })
|
||||
connect(messagebox, { onEscape = function(self) self:ok() end })
|
||||
elseif flags == MessageBoxCancel then
|
||||
buttonRight:setText('Cancel')
|
||||
connect(buttonRight, { onClick = function(self) self:getParent():cancel() end })
|
||||
connect(messagebox, { onEnter = function(self) self:cancel() end })
|
||||
connect(messagebox, { onEscape = function(self) self:cancel() end })
|
||||
end
|
||||
|
||||
connect(messagebox, { onEnter = function(self) self:destroy() end })
|
||||
connect(messagebox, { onEscape = function(self) self:destroy() end })
|
||||
|
||||
messagebox:lock()
|
||||
|
||||
return messagebox
|
||||
|
|
|
@ -8,7 +8,7 @@ local function onGameKeyPress(self, keyCode, keyboardModifiers)
|
|||
CharacterList.show()
|
||||
return true
|
||||
elseif keyCode == KeyQ then
|
||||
Game.logout(false)
|
||||
Game.safeLogout()
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
@ -101,7 +101,7 @@ end
|
|||
|
||||
local function onApplicationClose()
|
||||
if Game.isOnline() then
|
||||
Game.logout(true)
|
||||
Game.forceLogout()
|
||||
else
|
||||
exit()
|
||||
end
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
Creature::Creature() : Thing()
|
||||
{
|
||||
m_healthPercent = 0;
|
||||
m_showVolatileSquare = false;
|
||||
m_showTimedSquare = false;
|
||||
m_showStaticSquare = false;
|
||||
m_direction = Otc::South;
|
||||
m_walkAnimationPhase = 0;
|
||||
|
@ -68,8 +68,8 @@ void Creature::draw(const Point& dest, float scaleFactor, bool animate)
|
|||
{
|
||||
Point animationOffset = animate ? m_walkOffset : Point(0,0);
|
||||
|
||||
if(m_showVolatileSquare && animate) {
|
||||
g_painter.setColor(m_volatileSquareColor);
|
||||
if(m_showTimedSquare && animate) {
|
||||
g_painter.setColor(m_timedSquareColor);
|
||||
g_painter.drawBoundingRect(Rect(dest + (animationOffset - getDisplacement() + 3)*scaleFactor, Size(28, 28)*scaleFactor), std::max((int)(2*scaleFactor), 1));
|
||||
}
|
||||
|
||||
|
@ -482,15 +482,15 @@ void Creature::setEmblemTexture(const std::string& filename)
|
|||
m_emblemTexture = g_textures.getTexture(filename);
|
||||
}
|
||||
|
||||
void Creature::addVolatileSquare(uint8 color)
|
||||
void Creature::addTimedSquare(uint8 color)
|
||||
{
|
||||
m_showVolatileSquare = true;
|
||||
m_volatileSquareColor = Color::from8bit(color);
|
||||
m_showTimedSquare = true;
|
||||
m_timedSquareColor = Color::from8bit(color);
|
||||
|
||||
// schedule removal
|
||||
auto self = asCreature();
|
||||
g_dispatcher.scheduleEvent([self]() {
|
||||
self->removeVolatileSquare();
|
||||
self->removeTimedSquare();
|
||||
}, VOLATILE_SQUARE_DURATION);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,8 +58,8 @@ public:
|
|||
void setEmblemTexture(const std::string& filename);
|
||||
void setPassable(bool passable) { m_passable = passable; }
|
||||
|
||||
void addVolatileSquare(uint8 color);
|
||||
void removeVolatileSquare() { m_showVolatileSquare = false; }
|
||||
void addTimedSquare(uint8 color);
|
||||
void removeTimedSquare() { m_showTimedSquare = false; }
|
||||
|
||||
void showStaticSquare(const Color& color) { m_showStaticSquare = true; m_staticSquareColor = color; }
|
||||
void hideStaticSquare() { m_showStaticSquare = false; }
|
||||
|
@ -109,8 +109,8 @@ protected:
|
|||
TexturePtr m_skullTexture, m_shieldTexture, m_emblemTexture;
|
||||
bool m_showShieldTexture, m_shieldBlink;
|
||||
bool m_passable;
|
||||
Color m_volatileSquareColor, m_staticSquareColor;
|
||||
bool m_showVolatileSquare, m_showStaticSquare;
|
||||
Color m_timedSquareColor, m_staticSquareColor;
|
||||
bool m_showTimedSquare, m_showStaticSquare;
|
||||
|
||||
FontPtr m_informationFont;
|
||||
Color m_informationColor;
|
||||
|
|
|
@ -42,20 +42,28 @@ void Game::loginWorld(const std::string& account, const std::string& password, c
|
|||
|
||||
void Game::cancelLogin()
|
||||
{
|
||||
if(m_protocolGame)
|
||||
m_protocolGame->sendLogout();
|
||||
processLogout();
|
||||
}
|
||||
|
||||
void Game::logout(bool force)
|
||||
void Game::forceLogout()
|
||||
{
|
||||
if(!m_protocolGame || !isOnline())
|
||||
if(!isOnline())
|
||||
return;
|
||||
|
||||
m_protocolGame->sendLogout();
|
||||
|
||||
if(force)
|
||||
processLogout();
|
||||
}
|
||||
|
||||
void Game::safeLogout()
|
||||
{
|
||||
if(!isOnline())
|
||||
return;
|
||||
|
||||
m_protocolGame->sendLogout();
|
||||
}
|
||||
|
||||
void Game::processLoginError(const std::string& error)
|
||||
{
|
||||
g_lua.callGlobalField("Game", "onLoginError", error);
|
||||
|
|
|
@ -38,8 +38,8 @@ public:
|
|||
const std::string& characterName);
|
||||
void cancelLogin();
|
||||
void logout(bool force);
|
||||
void forceLogout() { logout(true); }
|
||||
void cleanLogout() { logout(false); }
|
||||
void forceLogout();
|
||||
void safeLogout();
|
||||
void processLoginError(const std::string& error);
|
||||
void processConnectionError(const boost::system::error_code& error);
|
||||
void processGameStart(const LocalPlayerPtr& localPlayer, int serverBeat);
|
||||
|
|
|
@ -184,7 +184,8 @@ void OTClient::registerLuaFunctions()
|
|||
|
||||
g_lua.registerClass<Game>();
|
||||
g_lua.bindClassStaticFunction<Game>("loginWorld", std::bind(&Game::loginWorld, &g_game, _1, _2, _3, _4, _5));
|
||||
g_lua.bindClassStaticFunction<Game>("logout", std::bind(&Game::logout, &g_game, _1));
|
||||
g_lua.bindClassStaticFunction<Game>("safeLogout", std::bind(&Game::safeLogout, &g_game));
|
||||
g_lua.bindClassStaticFunction<Game>("forceLogout", std::bind(&Game::forceLogout, &g_game));
|
||||
g_lua.bindClassStaticFunction<Game>("cancelLogin", std::bind(&Game::cancelLogin, &g_game));
|
||||
g_lua.bindClassStaticFunction<Game>("isOnline", std::bind(&Game::isOnline, &g_game));
|
||||
g_lua.bindClassStaticFunction<Game>("requestOutfit", std::bind(&Game::requestOutfit, &g_game));
|
||||
|
|
|
@ -579,7 +579,7 @@ void ProtocolGame::parseCreatureSquare(InputMessage& msg)
|
|||
|
||||
CreaturePtr creature = g_map.getCreatureById(id);
|
||||
if(creature)
|
||||
creature->addVolatileSquare(color);
|
||||
creature->addTimedSquare(color);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseCreatureHealth(InputMessage& msg)
|
||||
|
|
Loading…
Reference in New Issue