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.
master
BeniS 11 years ago
parent d70b835464
commit 00a574fe10

@ -37,7 +37,6 @@ function init()
mouseWidget.cancelNextRelease = false
battleWindow:setContentMinimumHeight(80)
--battleWindow:setContentMaximumHeight(384)
connect(Creature, {
onSkullChange = updateCreatureSkull,
@ -199,6 +198,7 @@ end
function addCreature(creature)
local creatureId = creature:getId()
local battleButton = battleButtonsByCreaturesList[creatureId]
if not battleButton then
battleButton = g_ui.createWidget('BattleButton', battlePanel)
battleButton:setup(creature)
@ -251,9 +251,9 @@ function removeAllCreatures()
end
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
lastBattleButtonSwitched = nil
end

@ -56,7 +56,6 @@ MiniWindow
anchors.horizontalCenter: parent.horizontalCenter
height: 20
width: 120
// width*count + spacing*(count-1)
layout:
type: horizontalBox
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)
end
if isIgnored(creatureName) then
menu:addOption(tr('Unignore') .. ' ' .. creatureName, function() removeIgnoredPlayer(creatureName) end)
else
menu:addOption(tr('Ignore') .. ' ' .. creatureName, function() addIgnoredPlayer(creatureName) end)
end
menu:addOption(tr('Unignore') .. ' ' .. creatureName, function() removeIgnoredPlayer(creatureName) end)
else
menu:addOption(tr('Ignore') .. ' ' .. creatureName, function() addIgnoredPlayer(creatureName) end)
end
menu:addSeparator()
end
--TODO select all
@ -611,11 +611,14 @@ function onTalk(name, level, mode, message, channelId, creaturePos)
if ignoreNpcMessages and mode == MessageModes.NpcFrom then return end
speaktype = SpeakTypes[mode]
if ((mode == MessageModes.Yell and isIgnoringYelling()) or
(speaktype.private and isIgnoringPrivate()) or
(isIgnored(name) or isIgnored(name:lower()))) and
name ~= g_game.getLocalPlayer():getName() then
return
if name ~= g_game.getLocalPlayer():getName() then
if mode == MessageModes.Yell and isIgnoringYelling() then
return
elseif speaktype.private and isIgnoringPrivate() and mode ~= MessageModes.NpcFrom then
return
elseif isIgnored(name) or isIgnored(name:lower()) then
return
end
end
if (mode == MessageModes.Say or mode == MessageModes.Whisper or mode == MessageModes.Yell or
@ -835,7 +838,7 @@ function onClickIgnoreButton()
saveButton.onClick = function()
ignoreSettings.players = {}
for i = 1, ignoreListPanel:getChildCount() do
addIgnoredPlayer(ignoreListPanel:getChildByIndex(i):getText())
addIgnoredPlayer(ignoreListPanel:getChildByIndex(i):getText())
--table.insert(ignoreSettings.players, ignoreListPanel:getChildByIndex(i):getText())
end

@ -31,8 +31,8 @@ CountWindow < MainWindow
focusable: false
Button
id: buttonOk
!text: tr('Ok')
id: buttonCancel
!text: tr('Cancel')
height: 20
anchors.left: countScrollBar.horizontalCenter
anchors.right: countScrollBar.right
@ -41,8 +41,8 @@ CountWindow < MainWindow
focusable: false
Button
id: buttonCancel
!text: tr('Cancel')
id: buttonOk
!text: tr('Ok')
height: 20
anchors.right: countScrollBar.horizontalCenter
anchors.left: countScrollBar.left

@ -75,6 +75,19 @@ function terminate()
minimapWindow:destroy()
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()
if flagWindow then
flagWindow:destroy()
@ -82,27 +95,6 @@ function destroyFlagWindow()
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)
if flagWindow then return end
if not position then return end
@ -126,14 +118,15 @@ function showFlagDialog(position)
flagRadioGroup:selectWidget(flagCheckbox[1])
cancelButton.onClick = function()
flagRadioGroup:destroy()
flagRadioGroup = nil
destroyFlagWindow()
end
okButton.onClick = function()
addMapFlag(position, flagRadioGroup:getSelectedWidget().icon, description:getText())
flagRadioGroup:destroy()
flagRadioGroup = nil
destroyFlagWindow()
end
end
@ -206,7 +199,7 @@ function addMapFlag(pos, icon, message, flagId, version)
flagWidget.id = flagId
flagWidget.version = version
updateMapFlag(flagId)
flagWidget.onMousePress = createThingMenu
flagWidget.onMousePress = onFlagMousePress
end
function getMapArea()
@ -358,6 +351,16 @@ function minimapFloorDown(floors)
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)
if id == "zoomIn" then
miniMapZoomIn(20)
@ -374,21 +377,24 @@ end
function onMinimapMouseRelease(self, mousePosition, mouseButton)
-- 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
navigating = false
return
end
local pos = self:getPosition(mousePosition)
if pos and mouseButton == MouseLeftButton and self:isPressed() then
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
minimapAutoWalk(pos)
end
return false
end

@ -98,3 +98,67 @@ function Player:dismount()
g_game.mount(false)
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.
*/
if(!(flags & Otc::PathFindAllowNullTiles) && !tile)
walkFactor = 1.0f;
walkFactor = 2.0f;
if(tile) {
if(!(flags & Otc::PathFindAllowCreatures) && tile->hasCreature())
continue;

Loading…
Cancel
Save