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