diff --git a/modules/game_battle/battle.lua b/modules/game_battle/battle.lua index 46ef2463..47a24af9 100644 --- a/modules/game_battle/battle.lua +++ b/modules/game_battle/battle.lua @@ -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 diff --git a/modules/game_battle/battle.otui b/modules/game_battle/battle.otui index 25fc6816..b00f3131 100644 --- a/modules/game_battle/battle.otui +++ b/modules/game_battle/battle.otui @@ -56,7 +56,6 @@ MiniWindow anchors.horizontalCenter: parent.horizontalCenter height: 20 width: 120 - // width*count + spacing*(count-1) layout: type: horizontalBox spacing: 5 diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index 8b2985cf..c1872842 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -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 diff --git a/modules/game_interface/styles/countwindow.otui b/modules/game_interface/styles/countwindow.otui index 34069f1a..c7353db2 100644 --- a/modules/game_interface/styles/countwindow.otui +++ b/modules/game_interface/styles/countwindow.otui @@ -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 diff --git a/modules/game_minimap/minimap.lua b/modules/game_minimap/minimap.lua index 1b968395..8e096121 100644 --- a/modules/game_minimap/minimap.lua +++ b/modules/game_minimap/minimap.lua @@ -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 diff --git a/modules/gamelib/player.lua b/modules/gamelib/player.lua index b2b89c6e..b02a96a4 100644 --- a/modules/gamelib/player.lua +++ b/modules/gamelib/player.lua @@ -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 \ No newline at end of file diff --git a/src/client/map.cpp b/src/client/map.cpp index de37fae0..cb996b9f 100644 --- a/src/client/map.cpp +++ b/src/client/map.cpp @@ -600,7 +600,7 @@ std::tuple, 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;