Fixes for last commits
This commit is contained in:
parent
7a08fed689
commit
f47a947bf3
|
@ -108,7 +108,7 @@ function GameInterface.terminate()
|
||||||
end
|
end
|
||||||
|
|
||||||
function GameInterface.show()
|
function GameInterface.show()
|
||||||
g_app.onClose = GameInterface.tryExit
|
connect(g_app, { onClose = GameInterface.tryExit })
|
||||||
logoutButton:show()
|
logoutButton:show()
|
||||||
Background.hide()
|
Background.hide()
|
||||||
gameRootPanel:show()
|
gameRootPanel:show()
|
||||||
|
@ -117,6 +117,7 @@ function GameInterface.show()
|
||||||
end
|
end
|
||||||
|
|
||||||
function GameInterface.hide()
|
function GameInterface.hide()
|
||||||
|
disconnect(g_app, { onClose = GameInterface.tryExit })
|
||||||
if logoutWindow then
|
if logoutWindow then
|
||||||
logoutWindow:destroy()
|
logoutWindow:destroy()
|
||||||
logoutWindow = nil
|
logoutWindow = nil
|
||||||
|
@ -125,14 +126,13 @@ function GameInterface.hide()
|
||||||
exitWindow:destroy()
|
exitWindow:destroy()
|
||||||
exitWindow = nil
|
exitWindow = nil
|
||||||
end
|
end
|
||||||
if countWindow then
|
if countWindow then
|
||||||
countWindow:destroy()
|
countWindow:destroy()
|
||||||
countWindow = nil
|
countWindow = nil
|
||||||
end
|
end
|
||||||
gameRootPanel:hide()
|
gameRootPanel:hide()
|
||||||
logoutButton:hide()
|
logoutButton:hide()
|
||||||
Background.show()
|
Background.show()
|
||||||
g_app.onClose = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function GameInterface.exit()
|
function GameInterface.exit()
|
||||||
|
@ -154,7 +154,6 @@ function GameInterface.tryExit()
|
||||||
|
|
||||||
local exitFunc = function()
|
local exitFunc = function()
|
||||||
GameInterface.exit()
|
GameInterface.exit()
|
||||||
exitButton:getParent():destroy()
|
|
||||||
end
|
end
|
||||||
local logoutFunc = function()
|
local logoutFunc = function()
|
||||||
GameInterface.logout()
|
GameInterface.logout()
|
||||||
|
@ -168,7 +167,7 @@ function GameInterface.tryExit()
|
||||||
|
|
||||||
exitWindow.onEscape = cancelFunc
|
exitWindow.onEscape = cancelFunc
|
||||||
exitWindow.onEnter = logoutFunc
|
exitWindow.onEnter = logoutFunc
|
||||||
|
|
||||||
exitButton.onClick = exitFunc
|
exitButton.onClick = exitFunc
|
||||||
logButton.onClick = logoutFunc
|
logButton.onClick = logoutFunc
|
||||||
cancelButton.onClick = cancelFunc
|
cancelButton.onClick = cancelFunc
|
||||||
|
@ -202,7 +201,7 @@ function GameInterface.tryLogout()
|
||||||
|
|
||||||
logoutWindow.onEnter = logoutFunc
|
logoutWindow.onEnter = logoutFunc
|
||||||
logoutWindow.onEscape = cancelFunc
|
logoutWindow.onEscape = cancelFunc
|
||||||
|
|
||||||
yesButton.onClick = logoutFunc
|
yesButton.onClick = logoutFunc
|
||||||
noButton.onClick = cancelFunc
|
noButton.onClick = cancelFunc
|
||||||
end
|
end
|
||||||
|
@ -503,7 +502,7 @@ function GameInterface.moveStackableItem(item, toPos)
|
||||||
|
|
||||||
countWindow.onEnter = moveFunc
|
countWindow.onEnter = moveFunc
|
||||||
countWindow.onEscape = cancelFunc
|
countWindow.onEscape = cancelFunc
|
||||||
|
|
||||||
okButton.onClick = moveFunc
|
okButton.onClick = moveFunc
|
||||||
cancelButton.onClick = cancelFunc
|
cancelButton.onClick = cancelFunc
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,30 +1,15 @@
|
||||||
PlayerMount = {}
|
PlayerMount = {}
|
||||||
|
|
||||||
-- private variables
|
|
||||||
|
|
||||||
-- private functions
|
|
||||||
|
|
||||||
-- public functions
|
|
||||||
function PlayerMount.init()
|
function PlayerMount.init()
|
||||||
g_ui.importStyle('playermount.otui')
|
|
||||||
|
|
||||||
connect(g_game, { onDeath = PlayerMount.dismount,
|
|
||||||
onGameEnd = PlayerMount.dismount })
|
|
||||||
|
|
||||||
g_keyboard.bindKeyDown('Ctrl+R', PlayerMount.toggleMount, gameRootPanel)
|
g_keyboard.bindKeyDown('Ctrl+R', PlayerMount.toggleMount, gameRootPanel)
|
||||||
end
|
end
|
||||||
|
|
||||||
function PlayerMount.terminate()
|
function PlayerMount.terminate()
|
||||||
disconnect(g_game, { onDeath = PlayerMount.dismount,
|
g_keyboard.unbindKeyDown('Ctrl+R', gameRootPanel)
|
||||||
onGameEnd = PlayerMount.dismount })
|
|
||||||
|
|
||||||
g_keyboard.unbindKeyDown('Ctrl+R', PlayerMount.toggleMount, gameRootPanel)
|
|
||||||
PlayerMount.reset()
|
|
||||||
|
|
||||||
PlayerMount = nil
|
PlayerMount = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- hooked events
|
|
||||||
function PlayerMount.toggleMount()
|
function PlayerMount.toggleMount()
|
||||||
if g_game.isMounted() then
|
if g_game.isMounted() then
|
||||||
g_game.mount(false)
|
g_game.mount(false)
|
||||||
|
@ -35,4 +20,4 @@ end
|
||||||
|
|
||||||
function PlayerMount.dismount()
|
function PlayerMount.dismount()
|
||||||
g_game.mount(false)
|
g_game.mount(false)
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,10 +2,7 @@ Module
|
||||||
name: game_playermount
|
name: game_playermount
|
||||||
description: Manage player mounts
|
description: Manage player mounts
|
||||||
author: BeniS
|
author: BeniS
|
||||||
website: www.otclient.info
|
website: www.otclient.infox
|
||||||
|
|
||||||
dependencies:
|
|
||||||
- client_entergame
|
|
||||||
|
|
||||||
@onLoad: |
|
@onLoad: |
|
||||||
dofile 'playermount'
|
dofile 'playermount'
|
||||||
|
|
|
@ -489,9 +489,10 @@ void Map::saveOtcm(const std::string& fileName)
|
||||||
const auto& list = tile->getThings();
|
const auto& list = tile->getThings();
|
||||||
auto first = std::find_if(list.begin(), list.end(), [](const ThingPtr& thing) { return thing->isItem(); });
|
auto first = std::find_if(list.begin(), list.end(), [](const ThingPtr& thing) { return thing->isItem(); });
|
||||||
for(auto it = first, end = list.end(); it != end; ++it) {
|
for(auto it = first, end = list.end(); it != end; ++it) {
|
||||||
ItemPtr item = (*it)->asItem();
|
if(ItemPtr item = (*it)->asItem()) {
|
||||||
fin->addU16(item->getId());
|
fin->addU16(item->getId());
|
||||||
fin->addU8(item->getCountOrSubType());
|
fin->addU8(item->getCountOrSubType());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// end of tile
|
// end of tile
|
||||||
|
|
|
@ -512,7 +512,13 @@ void ProtocolGame::parseCreatureMove(const InputMessagePtr& msg)
|
||||||
if(!g_map.removeThing(thing))
|
if(!g_map.removeThing(thing))
|
||||||
g_logger.traceError("could not remove thing");
|
g_logger.traceError("could not remove thing");
|
||||||
|
|
||||||
g_map.addThing(thing, newPos, -1);
|
int stackPos = -2;
|
||||||
|
|
||||||
|
// older protocols stores creatures in reverse order
|
||||||
|
if(!g_game.getFeature(Otc::GameReverseCreatureStack))
|
||||||
|
stackPos = -1;
|
||||||
|
|
||||||
|
g_map.addThing(thing, newPos, stackPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parseOpenContainer(const InputMessagePtr& msg)
|
void ProtocolGame::parseOpenContainer(const InputMessagePtr& msg)
|
||||||
|
@ -1144,7 +1150,7 @@ void ProtocolGame::parseOpenOutfitWindow(const InputMessagePtr& msg)
|
||||||
for(int i = 0; i < mountCount; ++i) {
|
for(int i = 0; i < mountCount; ++i) {
|
||||||
int mountId = msg->getU16(); // mount type
|
int mountId = msg->getU16(); // mount type
|
||||||
std::string mountName = msg->getString(); // mount name
|
std::string mountName = msg->getString(); // mount name
|
||||||
|
|
||||||
mountList.push_back(std::make_tuple(mountId, mountName));
|
mountList.push_back(std::make_tuple(mountId, mountName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,16 +171,10 @@ ThingPtr Tile::addThing(const ThingPtr& thing, int stackPos)
|
||||||
// 4 - creatures, from top to bottom
|
// 4 - creatures, from top to bottom
|
||||||
// 5 - items, from top to bottom
|
// 5 - items, from top to bottom
|
||||||
if(stackPos < 0) {
|
if(stackPos < 0) {
|
||||||
stackPos = 0;
|
|
||||||
int priority = thing->getStackPriority();
|
int priority = thing->getStackPriority();
|
||||||
bool prepend = (stackPos == -2 || priority <= 3);
|
bool prepend = (stackPos == -2 || priority <= 3);
|
||||||
for(stackPos = 0; stackPos < (int)m_things.size(); ++stackPos) {
|
for(stackPos = 0; stackPos < (int)m_things.size(); ++stackPos) {
|
||||||
int otherPriority = m_things[stackPos]->getStackPriority();
|
int otherPriority = m_things[stackPos]->getStackPriority();
|
||||||
if(!g_game.getFeature(Otc::GameReverseCreatureStack)) {
|
|
||||||
// older protocols stores creatures in reverse order
|
|
||||||
if(priority == 4 && otherPriority == 4)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if((prepend && otherPriority > priority) || (!prepend && otherPriority >= priority))
|
if((prepend && otherPriority > priority) || (!prepend && otherPriority >= priority))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ public:
|
||||||
void addWalkingCreature(const CreaturePtr& creature);
|
void addWalkingCreature(const CreaturePtr& creature);
|
||||||
void removeWalkingCreature(const CreaturePtr& creature);
|
void removeWalkingCreature(const CreaturePtr& creature);
|
||||||
|
|
||||||
ThingPtr addThing(const ThingPtr& thing, int stackPos = -1);
|
ThingPtr addThing(const ThingPtr& thing, int stackPos);
|
||||||
bool removeThing(ThingPtr thing);
|
bool removeThing(ThingPtr thing);
|
||||||
ThingPtr getThing(int stackPos);
|
ThingPtr getThing(int stackPos);
|
||||||
EffectPtr getEffect(uint16 id);
|
EffectPtr getEffect(uint16 id);
|
||||||
|
|
Loading…
Reference in New Issue