Minimap fix and remove option
This commit is contained in:
parent
ff9f82d0c8
commit
60986eb80f
|
@ -21,7 +21,8 @@ function init()
|
||||||
connect(g_game, {
|
connect(g_game, {
|
||||||
onGameStart = online,
|
onGameStart = online,
|
||||||
onGameEnd = offline,
|
onGameEnd = offline,
|
||||||
onAutomapFlag = addMapFlag
|
onAddAutomapFlag = addMapFlag,
|
||||||
|
onRemoveAutomapFlag = removeMapFlag,
|
||||||
})
|
})
|
||||||
connect(LocalPlayer, { onPositionChange = center })
|
connect(LocalPlayer, { onPositionChange = center })
|
||||||
|
|
||||||
|
@ -65,7 +66,8 @@ function terminate()
|
||||||
disconnect(g_game, {
|
disconnect(g_game, {
|
||||||
onGameStart = online,
|
onGameStart = online,
|
||||||
onGameEnd = offline,
|
onGameEnd = offline,
|
||||||
onAutomapFlag = addMapFlag
|
onAddAutomapFlag = addMapFlag,
|
||||||
|
onRemoveAutomapFlag = removeMapFlag,
|
||||||
})
|
})
|
||||||
disconnect(LocalPlayer, { onPositionChange = center })
|
disconnect(LocalPlayer, { onPositionChange = center })
|
||||||
|
|
||||||
|
@ -118,7 +120,7 @@ function showFlagDialog(position)
|
||||||
for i = 1, 20 do
|
for i = 1, 20 do
|
||||||
local checkbox = flagWindow:getChildById('flag' .. i)
|
local checkbox = flagWindow:getChildById('flag' .. i)
|
||||||
table.insert(flagCheckbox, checkbox)
|
table.insert(flagCheckbox, checkbox)
|
||||||
checkbox.icon = i
|
checkbox.icon = i - 1
|
||||||
flagRadioGroup:addWidget(checkbox)
|
flagRadioGroup:addWidget(checkbox)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -174,7 +176,7 @@ function getFlagIconClip(id)
|
||||||
end
|
end
|
||||||
|
|
||||||
function addMapFlag(pos, icon, message, flagId, version)
|
function addMapFlag(pos, icon, message, flagId, version)
|
||||||
if not(icon >= 1 and icon <= 20) or not pos then
|
if not (icon >= 0 and icon <= 19) or not pos then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -194,7 +196,7 @@ function addMapFlag(pos, icon, message, flagId, version)
|
||||||
end
|
end
|
||||||
|
|
||||||
local flagWidget = g_ui.createWidget('FlagWidget', flagsPanel)
|
local flagWidget = g_ui.createWidget('FlagWidget', flagsPanel)
|
||||||
flagWidget:setIconClip(getFlagIconClip(icon - 1))
|
flagWidget:setIconClip(getFlagIconClip(icon))
|
||||||
flagWidget:setId('flag' .. flagId)
|
flagWidget:setId('flag' .. flagId)
|
||||||
flagWidget.position = pos
|
flagWidget.position = pos
|
||||||
flagWidget.icon = icon
|
flagWidget.icon = icon
|
||||||
|
@ -208,13 +210,23 @@ function addMapFlag(pos, icon, message, flagId, version)
|
||||||
flagWidget.onMousePress = onFlagMousePress
|
flagWidget.onMousePress = onFlagMousePress
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function removeMapFlag(pos, icon, message)
|
||||||
|
for i=1, flagsPanel:getChildCount() do
|
||||||
|
local flag = flagsPanel:getChildByIndex(i)
|
||||||
|
if flag.position.x == pos.x and flag.position.y == pos.y and flag.position.z == pos.z and flag.icon == icon and flag.description == message then
|
||||||
|
flag:destroy()
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function getMapArea()
|
function getMapArea()
|
||||||
return minimapWidget:getPosition( { x = 1 + minimapWidget:getX(), y = 1 + minimapWidget:getY() } ),
|
return minimapWidget:getPosition( { x = 1 + minimapWidget:getX(), y = 1 + minimapWidget:getY() } ),
|
||||||
minimapWidget:getPosition( { x = -2 + minimapWidget:getWidth() + minimapWidget:getX(), y = -2 + minimapWidget:getHeight() + minimapWidget:getY() } )
|
minimapWidget:getPosition( { x = -2 + minimapWidget:getWidth() + minimapWidget:getX(), y = -2 + minimapWidget:getHeight() + minimapWidget:getY() } )
|
||||||
end
|
end
|
||||||
|
|
||||||
function isFlagVisible(flag, firstPosition, lastPosition)
|
function isFlagVisible(flag, firstPosition, lastPosition)
|
||||||
return flag.version == g_game.getProtocolVersion() and (minimapWidget:getZoom() >= 0 and minimapWidget:getZoom() <= 2) and flag.position.x >= firstPosition.x and flag.position.x <= lastPosition.x and flag.position.y >= firstPosition.y and flag.position.y <= lastPosition.y and flag.position.z == firstPosition.z
|
return flag.version == g_game.getProtocolVersion() and (minimapWidget:getZoom() >= -2 and minimapWidget:getZoom() <= 4) and flag.position.x >= firstPosition.x and flag.position.x <= lastPosition.x and flag.position.y >= firstPosition.y and flag.position.y <= lastPosition.y and flag.position.z == firstPosition.z
|
||||||
end
|
end
|
||||||
|
|
||||||
function updateMapFlag(id)
|
function updateMapFlag(id)
|
||||||
|
@ -226,8 +238,8 @@ function updateMapFlag(id)
|
||||||
local flag = flagsPanel:getChildById('flag' .. id)
|
local flag = flagsPanel:getChildById('flag' .. id)
|
||||||
if isFlagVisible(flag, firstPosition, lastPosition) then
|
if isFlagVisible(flag, firstPosition, lastPosition) then
|
||||||
flag:setVisible(true)
|
flag:setVisible(true)
|
||||||
flag:setMarginLeft( -5 + (minimapWidget:getWidth() / (lastPosition.x - firstPosition.x)) * (flag.position.x - firstPosition.x))
|
flag:setMarginLeft(-5.5 + (minimapWidget:getWidth() / (lastPosition.x - firstPosition.x)) * (flag.position.x - firstPosition.x))
|
||||||
flag:setMarginTop( -5 + (minimapWidget:getHeight() / (lastPosition.y - firstPosition.y)) * (flag.position.y - firstPosition.y))
|
flag:setMarginTop(-5.5 + (minimapWidget:getHeight() / (lastPosition.y - firstPosition.y)) * (flag.position.y - firstPosition.y))
|
||||||
else
|
else
|
||||||
flag:setVisible(false)
|
flag:setVisible(false)
|
||||||
end
|
end
|
||||||
|
@ -243,8 +255,8 @@ function updateMapFlags()
|
||||||
local flag = flagsPanel:getChildByIndex(i)
|
local flag = flagsPanel:getChildByIndex(i)
|
||||||
if isFlagVisible(flag, firstPosition, lastPosition) then
|
if isFlagVisible(flag, firstPosition, lastPosition) then
|
||||||
flag:setVisible(true)
|
flag:setVisible(true)
|
||||||
flag:setMarginLeft( -5 + (minimapWidget:getWidth() / (lastPosition.x - firstPosition.x)) * (flag.position.x - firstPosition.x))
|
flag:setMarginLeft(-5.5 + (minimapWidget:getWidth() / (lastPosition.x - firstPosition.x)) * (flag.position.x - firstPosition.x))
|
||||||
flag:setMarginTop( -5 + (minimapWidget:getHeight() / (lastPosition.y - firstPosition.y)) * (flag.position.y - firstPosition.y))
|
flag:setMarginTop(-5.5 + (minimapWidget:getHeight() / (lastPosition.y - firstPosition.y)) * (flag.position.y - firstPosition.y))
|
||||||
else
|
else
|
||||||
flag:setVisible(false)
|
flag:setVisible(false)
|
||||||
end
|
end
|
||||||
|
|
|
@ -76,6 +76,7 @@ GameDiagonalAnimatedText = 34
|
||||||
GameLoginPending = 35
|
GameLoginPending = 35
|
||||||
GameNewSpeedLaw = 36
|
GameNewSpeedLaw = 36
|
||||||
GameForceFirstAutoWalkStep = 37
|
GameForceFirstAutoWalkStep = 37
|
||||||
|
GameMinimapRemove = 38
|
||||||
|
|
||||||
TextColors = {
|
TextColors = {
|
||||||
red = '#f55e5e', --'#c83200'
|
red = '#f55e5e', --'#c83200'
|
||||||
|
|
|
@ -347,6 +347,7 @@ namespace Otc
|
||||||
GameLoginPending = 35,
|
GameLoginPending = 35,
|
||||||
GameNewSpeedLaw = 36,
|
GameNewSpeedLaw = 36,
|
||||||
GameForceFirstAutoWalkStep = 37,
|
GameForceFirstAutoWalkStep = 37,
|
||||||
|
GameMinimapRemove = 38,
|
||||||
// 51-100 reserved to be defined in lua
|
// 51-100 reserved to be defined in lua
|
||||||
LastGameFeature = 101
|
LastGameFeature = 101
|
||||||
};
|
};
|
||||||
|
|
|
@ -371,9 +371,14 @@ void Game::processTutorialHint(int id)
|
||||||
g_lua.callGlobalField("g_game", "onTutorialHint", id);
|
g_lua.callGlobalField("g_game", "onTutorialHint", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::processAutomapFlag(const Position& pos, int icon, const std::string& message)
|
void Game::processAddAutomapFlag(const Position& pos, int icon, const std::string& message)
|
||||||
{
|
{
|
||||||
g_lua.callGlobalField("g_game", "onAutomapFlag", pos, icon, message);
|
g_lua.callGlobalField("g_game", "onAddAutomapFlag", pos, icon, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Game::processRemoveAutomapFlag(const Position& pos, int icon, const std::string& message)
|
||||||
|
{
|
||||||
|
g_lua.callGlobalField("g_game", "onRemoveAutomapFlag", pos, icon, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::processOpenOutfitWindow(const Outfit& currentOufit, const std::vector<std::tuple<int, std::string, int> >& outfitList,
|
void Game::processOpenOutfitWindow(const Outfit& currentOufit, const std::vector<std::tuple<int, std::string, int> >& outfitList,
|
||||||
|
|
|
@ -103,7 +103,8 @@ protected:
|
||||||
|
|
||||||
// tutorial hint
|
// tutorial hint
|
||||||
void processTutorialHint(int id);
|
void processTutorialHint(int id);
|
||||||
void processAutomapFlag(const Position& pos, int icon, const std::string& message);
|
void processAddAutomapFlag(const Position& pos, int icon, const std::string& message);
|
||||||
|
void processRemoveAutomapFlag(const Position& pos, int icon, const std::string& message);
|
||||||
|
|
||||||
// outfit
|
// outfit
|
||||||
void processOpenOutfitWindow(const Outfit& currentOufit, const std::vector<std::tuple<int, std::string, int> >& outfitList,
|
void processOpenOutfitWindow(const Outfit& currentOufit, const std::vector<std::tuple<int, std::string, int> >& outfitList,
|
||||||
|
|
|
@ -1406,17 +1406,24 @@ void ProtocolGame::parseVipLogout(const InputMessagePtr& msg)
|
||||||
|
|
||||||
void ProtocolGame::parseTutorialHint(const InputMessagePtr& msg)
|
void ProtocolGame::parseTutorialHint(const InputMessagePtr& msg)
|
||||||
{
|
{
|
||||||
int id = msg->getU8(); // tutorial id
|
int id = msg->getU8();
|
||||||
g_game.processTutorialHint(id);
|
g_game.processTutorialHint(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parseAutomapFlag(const InputMessagePtr& msg)
|
void ProtocolGame::parseAutomapFlag(const InputMessagePtr& msg)
|
||||||
{
|
{
|
||||||
Position pos = getPosition(msg); // position
|
Position pos = getPosition(msg);
|
||||||
int icon = msg->getU8(); // icon
|
int icon = msg->getU8();
|
||||||
std::string description = msg->getString(); // message
|
std::string description = msg->getString();
|
||||||
|
|
||||||
g_game.processAutomapFlag(pos, icon, description);
|
bool remove = false;
|
||||||
|
if(g_game.getFeature(Otc::GameMinimapRemove))
|
||||||
|
remove = msg->getU8() != 0;
|
||||||
|
|
||||||
|
if(!remove)
|
||||||
|
g_game.processAddAutomapFlag(pos, icon, description);
|
||||||
|
else
|
||||||
|
g_game.processRemoveAutomapFlag(pos, icon, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parseQuestLog(const InputMessagePtr& msg)
|
void ProtocolGame::parseQuestLog(const InputMessagePtr& msg)
|
||||||
|
|
Loading…
Reference in New Issue