Fixed #178, and some others:
* Fixed a small issue in the ignore module (also please remember to use 2 spaces for tabulation and not tabs) * Changed the order of count window buttons * Added new player functions.
This commit is contained in:
parent
d70b835464
commit
00a574fe10
|
@ -37,7 +37,6 @@ function init()
|
||||||
mouseWidget.cancelNextRelease = false
|
mouseWidget.cancelNextRelease = false
|
||||||
|
|
||||||
battleWindow:setContentMinimumHeight(80)
|
battleWindow:setContentMinimumHeight(80)
|
||||||
--battleWindow:setContentMaximumHeight(384)
|
|
||||||
|
|
||||||
connect(Creature, {
|
connect(Creature, {
|
||||||
onSkullChange = updateCreatureSkull,
|
onSkullChange = updateCreatureSkull,
|
||||||
|
@ -199,6 +198,7 @@ end
|
||||||
function addCreature(creature)
|
function addCreature(creature)
|
||||||
local creatureId = creature:getId()
|
local creatureId = creature:getId()
|
||||||
local battleButton = battleButtonsByCreaturesList[creatureId]
|
local battleButton = battleButtonsByCreaturesList[creatureId]
|
||||||
|
|
||||||
if not battleButton then
|
if not battleButton then
|
||||||
battleButton = g_ui.createWidget('BattleButton', battlePanel)
|
battleButton = g_ui.createWidget('BattleButton', battlePanel)
|
||||||
battleButton:setup(creature)
|
battleButton:setup(creature)
|
||||||
|
@ -251,9 +251,9 @@ function removeAllCreatures()
|
||||||
end
|
end
|
||||||
|
|
||||||
function removeCreature(creature)
|
function removeCreature(creature)
|
||||||
local creatureId = creature:getId()
|
if hasCreature(creature) then
|
||||||
|
local creatureId = creature:getId()
|
||||||
|
|
||||||
if battleButtonsByCreaturesList[creatureId] ~= nil then
|
|
||||||
if lastBattleButtonSwitched == battleButtonsByCreaturesList[creatureId] then
|
if lastBattleButtonSwitched == battleButtonsByCreaturesList[creatureId] then
|
||||||
lastBattleButtonSwitched = nil
|
lastBattleButtonSwitched = nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -56,7 +56,6 @@ MiniWindow
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
height: 20
|
height: 20
|
||||||
width: 120
|
width: 120
|
||||||
// width*count + spacing*(count-1)
|
|
||||||
layout:
|
layout:
|
||||||
type: horizontalBox
|
type: horizontalBox
|
||||||
spacing: 5
|
spacing: 5
|
||||||
|
|
|
@ -447,10 +447,10 @@ function processMessageMenu(mousePos, mouseButton, creatureName, text)
|
||||||
menu:addOption(tr('Add to VIP list'), function () g_game.addVip(creatureName) end)
|
menu:addOption(tr('Add to VIP list'), function () g_game.addVip(creatureName) end)
|
||||||
end
|
end
|
||||||
if isIgnored(creatureName) then
|
if isIgnored(creatureName) then
|
||||||
menu:addOption(tr('Unignore') .. ' ' .. creatureName, function() removeIgnoredPlayer(creatureName) end)
|
menu:addOption(tr('Unignore') .. ' ' .. creatureName, function() removeIgnoredPlayer(creatureName) end)
|
||||||
else
|
else
|
||||||
menu:addOption(tr('Ignore') .. ' ' .. creatureName, function() addIgnoredPlayer(creatureName) end)
|
menu:addOption(tr('Ignore') .. ' ' .. creatureName, function() addIgnoredPlayer(creatureName) end)
|
||||||
end
|
end
|
||||||
menu:addSeparator()
|
menu:addSeparator()
|
||||||
end
|
end
|
||||||
--TODO select all
|
--TODO select all
|
||||||
|
@ -611,11 +611,14 @@ function onTalk(name, level, mode, message, channelId, creaturePos)
|
||||||
if ignoreNpcMessages and mode == MessageModes.NpcFrom then return end
|
if ignoreNpcMessages and mode == MessageModes.NpcFrom then return end
|
||||||
|
|
||||||
speaktype = SpeakTypes[mode]
|
speaktype = SpeakTypes[mode]
|
||||||
if ((mode == MessageModes.Yell and isIgnoringYelling()) or
|
if name ~= g_game.getLocalPlayer():getName() then
|
||||||
(speaktype.private and isIgnoringPrivate()) or
|
if mode == MessageModes.Yell and isIgnoringYelling() then
|
||||||
(isIgnored(name) or isIgnored(name:lower()))) and
|
return
|
||||||
name ~= g_game.getLocalPlayer():getName() then
|
elseif speaktype.private and isIgnoringPrivate() and mode ~= MessageModes.NpcFrom then
|
||||||
return
|
return
|
||||||
|
elseif isIgnored(name) or isIgnored(name:lower()) then
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (mode == MessageModes.Say or mode == MessageModes.Whisper or mode == MessageModes.Yell or
|
if (mode == MessageModes.Say or mode == MessageModes.Whisper or mode == MessageModes.Yell or
|
||||||
|
@ -835,7 +838,7 @@ function onClickIgnoreButton()
|
||||||
saveButton.onClick = function()
|
saveButton.onClick = function()
|
||||||
ignoreSettings.players = {}
|
ignoreSettings.players = {}
|
||||||
for i = 1, ignoreListPanel:getChildCount() do
|
for i = 1, ignoreListPanel:getChildCount() do
|
||||||
addIgnoredPlayer(ignoreListPanel:getChildByIndex(i):getText())
|
addIgnoredPlayer(ignoreListPanel:getChildByIndex(i):getText())
|
||||||
--table.insert(ignoreSettings.players, ignoreListPanel:getChildByIndex(i):getText())
|
--table.insert(ignoreSettings.players, ignoreListPanel:getChildByIndex(i):getText())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,8 @@ CountWindow < MainWindow
|
||||||
focusable: false
|
focusable: false
|
||||||
|
|
||||||
Button
|
Button
|
||||||
id: buttonOk
|
id: buttonCancel
|
||||||
!text: tr('Ok')
|
!text: tr('Cancel')
|
||||||
height: 20
|
height: 20
|
||||||
anchors.left: countScrollBar.horizontalCenter
|
anchors.left: countScrollBar.horizontalCenter
|
||||||
anchors.right: countScrollBar.right
|
anchors.right: countScrollBar.right
|
||||||
|
@ -41,8 +41,8 @@ CountWindow < MainWindow
|
||||||
focusable: false
|
focusable: false
|
||||||
|
|
||||||
Button
|
Button
|
||||||
id: buttonCancel
|
id: buttonOk
|
||||||
!text: tr('Cancel')
|
!text: tr('Ok')
|
||||||
height: 20
|
height: 20
|
||||||
anchors.right: countScrollBar.horizontalCenter
|
anchors.right: countScrollBar.horizontalCenter
|
||||||
anchors.left: countScrollBar.left
|
anchors.left: countScrollBar.left
|
||||||
|
|
|
@ -75,6 +75,19 @@ function terminate()
|
||||||
minimapWindow:destroy()
|
minimapWindow:destroy()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function onFlagMousePress(widget, mousePosition, mouseButton)
|
||||||
|
if mouseButton == MouseRightButton then
|
||||||
|
local menu = g_ui.createWidget('PopupMenu')
|
||||||
|
menu:addOption(tr('Delete mark'), function()
|
||||||
|
widget:destroy()
|
||||||
|
end)
|
||||||
|
menu:display(mousePosition)
|
||||||
|
elseif mouseButton == MouseLeftButton then
|
||||||
|
minimapAutoWalk(widget.position)
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
function destroyFlagWindow()
|
function destroyFlagWindow()
|
||||||
if flagWindow then
|
if flagWindow then
|
||||||
flagWindow:destroy()
|
flagWindow:destroy()
|
||||||
|
@ -82,27 +95,6 @@ function destroyFlagWindow()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function createThingMenu(widget, menuPosition, button)
|
|
||||||
if not g_game.isOnline() then return end
|
|
||||||
if button ~= MouseRightButton then return end
|
|
||||||
local menu = g_ui.createWidget('PopupMenu')
|
|
||||||
|
|
||||||
if widget == minimapWidget then
|
|
||||||
menu:addOption(tr('Create mark'), function()
|
|
||||||
local position = minimapWidget:getPosition(menuPosition)
|
|
||||||
if position then
|
|
||||||
showFlagDialog(position)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
else
|
|
||||||
menu:addOption(tr('Delete mark'), function()
|
|
||||||
widget:destroy()
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
menu:display(menuPosition)
|
|
||||||
end
|
|
||||||
|
|
||||||
function showFlagDialog(position)
|
function showFlagDialog(position)
|
||||||
if flagWindow then return end
|
if flagWindow then return end
|
||||||
if not position then return end
|
if not position then return end
|
||||||
|
@ -126,14 +118,15 @@ function showFlagDialog(position)
|
||||||
|
|
||||||
flagRadioGroup:selectWidget(flagCheckbox[1])
|
flagRadioGroup:selectWidget(flagCheckbox[1])
|
||||||
|
|
||||||
|
|
||||||
cancelButton.onClick = function()
|
cancelButton.onClick = function()
|
||||||
flagRadioGroup:destroy()
|
flagRadioGroup:destroy()
|
||||||
|
flagRadioGroup = nil
|
||||||
destroyFlagWindow()
|
destroyFlagWindow()
|
||||||
end
|
end
|
||||||
okButton.onClick = function()
|
okButton.onClick = function()
|
||||||
addMapFlag(position, flagRadioGroup:getSelectedWidget().icon, description:getText())
|
addMapFlag(position, flagRadioGroup:getSelectedWidget().icon, description:getText())
|
||||||
flagRadioGroup:destroy()
|
flagRadioGroup:destroy()
|
||||||
|
flagRadioGroup = nil
|
||||||
destroyFlagWindow()
|
destroyFlagWindow()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -206,7 +199,7 @@ function addMapFlag(pos, icon, message, flagId, version)
|
||||||
flagWidget.id = flagId
|
flagWidget.id = flagId
|
||||||
flagWidget.version = version
|
flagWidget.version = version
|
||||||
updateMapFlag(flagId)
|
updateMapFlag(flagId)
|
||||||
flagWidget.onMousePress = createThingMenu
|
flagWidget.onMousePress = onFlagMousePress
|
||||||
end
|
end
|
||||||
|
|
||||||
function getMapArea()
|
function getMapArea()
|
||||||
|
@ -358,6 +351,16 @@ function minimapFloorDown(floors)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function minimapAutoWalk(pos)
|
||||||
|
local player = g_game.getLocalPlayer()
|
||||||
|
if not player:autoWalk(pos) then
|
||||||
|
modules.game_textmessage.displayStatusMessage(tr('There is no way.'))
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function onButtonClick(id)
|
function onButtonClick(id)
|
||||||
if id == "zoomIn" then
|
if id == "zoomIn" then
|
||||||
miniMapZoomIn(20)
|
miniMapZoomIn(20)
|
||||||
|
@ -374,21 +377,24 @@ end
|
||||||
|
|
||||||
function onMinimapMouseRelease(self, mousePosition, mouseButton)
|
function onMinimapMouseRelease(self, mousePosition, mouseButton)
|
||||||
-- Mapmark menu
|
-- Mapmark menu
|
||||||
createThingMenu(self, mousePosition, mouseButton)
|
local pos = self:getPosition(mousePosition)
|
||||||
|
if mouseButton == MouseRightButton then
|
||||||
|
local menu = g_ui.createWidget('PopupMenu')
|
||||||
|
menu:addOption(tr('Create mark'), function()
|
||||||
|
local pos = self:getPosition(mousePosition)
|
||||||
|
if pos then
|
||||||
|
showFlagDialog(pos)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
menu:display(mousePosition)
|
||||||
|
end
|
||||||
|
|
||||||
if navigating then
|
if navigating then
|
||||||
navigating = false
|
navigating = false
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local pos = self:getPosition(mousePosition)
|
|
||||||
if pos and mouseButton == MouseLeftButton and self:isPressed() then
|
if pos and mouseButton == MouseLeftButton and self:isPressed() then
|
||||||
local player = g_game.getLocalPlayer()
|
minimapAutoWalk(pos)
|
||||||
if not player:autoWalk(pos) then
|
|
||||||
modules.game_textmessage.displayStatusMessage(tr('There is no way.'))
|
|
||||||
return false
|
|
||||||
else
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
|
@ -98,3 +98,67 @@ function Player:dismount()
|
||||||
g_game.mount(false)
|
g_game.mount(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Player:getItem(itemid)
|
||||||
|
for i=InventorySlotFirst,InventorySlotLast do
|
||||||
|
local item = self:getInventoryItem(i)
|
||||||
|
if item and item:getId() == itemid then
|
||||||
|
return item
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for i, container in pairs(g_game.getContainers()) do
|
||||||
|
for j, item in pairs(container:getItems()) do
|
||||||
|
if item:getId() == itemid then
|
||||||
|
item.container = container
|
||||||
|
return item
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return items
|
||||||
|
end
|
||||||
|
|
||||||
|
function Player:getItems(itemid)
|
||||||
|
local items = {}
|
||||||
|
for i=InventorySlotFirst,InventorySlotLast do
|
||||||
|
local item = self:getInventoryItem(i)
|
||||||
|
if item and item:getId() == itemid then
|
||||||
|
table.insert(items, item)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for i, container in pairs(g_game.getContainers()) do
|
||||||
|
for j, item in pairs(container:getItems()) do
|
||||||
|
if item:getId() == itemid then
|
||||||
|
item.container = container
|
||||||
|
table.insert(items, item)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return items
|
||||||
|
end
|
||||||
|
|
||||||
|
function Player:getItemsCount(itemid)
|
||||||
|
local items, count = self:getItems(itemid), 0
|
||||||
|
for i=1,#items do
|
||||||
|
count = count + items[i]:getCount()
|
||||||
|
end
|
||||||
|
return count
|
||||||
|
end
|
||||||
|
|
||||||
|
function Player:hasState(_state, states)
|
||||||
|
if not states then
|
||||||
|
states = self:getStates()
|
||||||
|
end
|
||||||
|
|
||||||
|
for i = 1, 32 do
|
||||||
|
local pow = math.pow(2, i-1)
|
||||||
|
if pow > states then break end
|
||||||
|
|
||||||
|
local states = bit32.band(states, pow)
|
||||||
|
if states == _state then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
|
@ -600,7 +600,7 @@ std::tuple<std::vector<Otc::Direction>, Otc::PathFindResult> Map::findPath(const
|
||||||
but it is breaking normal path finding.
|
but it is breaking normal path finding.
|
||||||
*/
|
*/
|
||||||
if(!(flags & Otc::PathFindAllowNullTiles) && !tile)
|
if(!(flags & Otc::PathFindAllowNullTiles) && !tile)
|
||||||
walkFactor = 1.0f;
|
walkFactor = 2.0f;
|
||||||
if(tile) {
|
if(tile) {
|
||||||
if(!(flags & Otc::PathFindAllowCreatures) && tile->hasCreature())
|
if(!(flags & Otc::PathFindAllowCreatures) && tile->hasCreature())
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue