fix use with, improve move, change icons, improve topbar

This commit is contained in:
Eduardo Bart
2012-01-24 16:39:16 -02:00
parent fb386b3845
commit 24aab00431
46 changed files with 185 additions and 108 deletions

View File

@@ -32,4 +32,4 @@ end
function quit()
exit()
end
end

View File

@@ -107,7 +107,7 @@ function Terminal.init()
terminalWidget = displayUI('terminal.otui')
terminalWidget:setVisible(false)
terminalButton = TopMenu.addButton('terminalButton', 'Terminal (Ctrl + T)', '/core_styles/icons/terminal.png', Terminal.toggle)
terminalButton = TopMenu.addButton('terminalButton', 'Terminal (Ctrl + T)', 'terminal.png', Terminal.toggle)
Hotkeys.bindKeyDown('Ctrl+T', Terminal.toggle)
commandHistory = Settings.getList('terminal-history')

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B

View File

@@ -5,7 +5,7 @@ local aboutButton
-- public functions
function About.init()
aboutButton = TopMenu.addRightButton('aboutButton', 'About', '/core_styles/icons/about.png', About.display)
aboutButton = TopMenu.addRightButton('aboutButton', 'About', 'about.png', About.display)
end
function About.display()

Binary file not shown.

After

Width:  |  Height:  |  Size: 763 B

View File

@@ -24,7 +24,7 @@ function Options.init()
optionsWindow = displayUI('options.otui')
optionsWindow:setVisible(false)
optionsButton = TopMenu.addButton('settingsButton', 'Options (Ctrl+O)', '/core_styles/icons/settings.png', Options.toggle)
optionsButton = TopMenu.addButton('optionsButton', 'Options (Ctrl+O)', 'options.png', Options.toggle)
Hotkeys.bindKeyDown('Ctrl+O', Options.toggle)
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 660 B

View File

@@ -63,11 +63,11 @@ function TopMenu.addGameButton(id, description, icon, callback)
end
function TopMenu.addLeftButton(id, description, icon, callback)
return TopMenu.addButton(id, description, icon, callback, false)
return TopMenu.addButton(id, description, resolvepath(icon, 2), callback, false)
end
function TopMenu.addRightButton(id, description, icon, callback)
return TopMenu.addButton(id, description, icon, callback, true)
return TopMenu.addButton(id, description, resolvepath(icon, 2), callback, true)
end
function TopMenu.removeButton(param)

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 B

View File

@@ -20,7 +20,7 @@ Button < UIButton
ConsoleButton < UIButton
size: 20 20
image-source: /core_styles/images/consolebutton.png
image-source: /core_styles/images/tabbutton.png
image-color: white
image-clip: 0 0 20 20
image-border: 2

View File

@@ -2,3 +2,4 @@ Item < UIItem
size: 34 34
image-source: /core_styles/images/item.png
font: verdana-11px-rounded
border-color: white

View File

@@ -2,7 +2,7 @@ TabBar < UITabBar
TabBarPanel < Panel
TabBarButton < UIButton
size: 20 20
image-source: /core_styles/images/consolebutton.png
image-source: /core_styles/images/tabbutton.png
image-color: white
image-clip: 0 0 20 20
image-border: 2

View File

@@ -1,9 +1,8 @@
function UIItem:onDragEnter(mousePos)
local item = self:getItem()
if not item then return false end
self:setBorderWidth('1')
self:setBorderColor('#ffffff')
self:setBorderWidth(1)
self.currentDragThing = item
setTargetCursor()
@@ -13,7 +12,7 @@ end
function UIItem:onDragLeave(widget, mousePos)
self.currentDragThing = nil
restoreCursor()
self:setBorderWidth('0')
self:setBorderWidth(0)
return true
end
@@ -24,9 +23,20 @@ function UIItem:onDrop(widget, mousePos)
local count = widget.currentDragThing:getData()
Game.move(widget.currentDragThing, pos, count)
self:setBorderWidth(0)
return true
end
function UIItem:onHoverChange(hovered)
if g_ui.getDraggingWidget() and self ~= g_ui.getDraggingWidget() then
if hovered then
self:setBorderWidth(1)
else
self:setBorderWidth(0)
end
end
end
function UIItem:onMouseRelease(mousePosition, mouseButton)
local item = self:getItem()
if not item or not self:containsPoint(mousePosition) then return false end

View File

@@ -1,3 +1,6 @@
-- private variables
local m_mouseGrabberWidget
-- private functions
local function onGameKeyPress(self, keyCode, keyboardModifiers, wouldFilter)
if wouldFilter then return end
@@ -13,7 +16,34 @@ local function onGameKeyPress(self, keyCode, keyboardModifiers, wouldFilter)
return false
end
local function onUseWithMouseRelease(self, mousePosition, mouseButton)
if Game.selectedThing == nil then return false end
if mouseButton == MouseLeftButton then
local clickedWidget = Game.gameUi:recursiveGetChildByPos(mousePosition)
if clickedWidget then
if clickedWidget.getTile then
local tile = clickedWidget:getTile(mousePosition)
if tile then
Game.useWith(Game.selectedThing, tile:getTopMultiUseThing())
end
elseif clickedWidget.getItem then
Game.useWith(Game.selectedThing, clickedWidget:getItem())
end
end
end
Game.selectedThing = nil
restoreCursor()
self:ungrabMouse()
return true
end
-- public functions
function Game.startUseWith(thing)
Game.selectedThing = thing
m_mouseGrabberWidget:grabMouse()
setTargetCursor()
end
function Game.createInterface()
Background.hide()
CharacterList.destroyLoadBox()
@@ -33,7 +63,9 @@ function Game.createInterface()
Game.gameMapPanel = Game.gameUi:getChildById('gameMapPanel')
Game.gameRightPanel = Game.gameUi:getChildById('gameRightPanel')
Game.gameBottomPanel = Game.gameUi:getChildById('gameBottomPanel')
Game.gameUi.onKeyPress = onGameKeyPress
m_mouseGrabberWidget = Game.gameUi:getChildById('mouseGrabber')
connect(Game.gameUi, { onKeyPress = onGameKeyPress })
connect(m_mouseGrabberWidget, { onMouseRelease = onUseWithMouseRelease })
end
function Game.destroyInterface()

View File

@@ -26,3 +26,6 @@ UIGame
anchors.bottom: gameBottomPanel.top
focusable: false
UIWidget
id: mouseGrabber
focusable: false

View File

@@ -1,7 +1,7 @@
function UIMap:onDragEnter(mousePos)
local tile = self:getTile(mousePos)
if not tile then return false end
local thing = tile:getTopMoveThing()
if not thing then return false end
@@ -18,11 +18,11 @@ end
function UIMap:onDrop(widget, mousePos)
if not widget or not widget.currentDragThing then return false end
local tile = self:getTile(mousePos)
if not tile then return false end
local count = 1 -- todo make a window for it
local count = widget.currentDragThing:getData()
Game.move(widget.currentDragThing, tile:getPos(), count)
return true
end

View File

@@ -14,24 +14,13 @@ end
function Game.processMouseAction(menuPosition, mouseButton, autoWalk, lookThing, useThing, creatureThing, multiUseThing)
local keyboardModifiers = g_window.getKeyboardModifiers()
local selectedThing = Game.getSelectedThing()
if mouseButton == MouseRightButton and selectedThing then
Game.setSelectedThing(nil)
return true
end
if autoWalk and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton and not Game.getSelectedThing() then
if autoWalk and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton then
-- todo auto walk
return true
end
if not Options.classicControl then
if mouseButton == MouseLeftButton and selectedThing then
Game.useWith(Game.getSelectedThing(), multiUseThing)
Game.setSelectedThing(nil)
restoreCursor()
return true
elseif keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
if keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
Game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
return true
elseif lookThing and keyboardModifiers == KeyboardShiftModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
@@ -41,14 +30,17 @@ function Game.processMouseAction(menuPosition, mouseButton, autoWalk, lookThing,
if useThing:isContainer() then
if useThing:isInsideContainer() then
Game.open(useThing, useThing:getContainerId())
return true
else
Game.open(useThing, Containers.getFreeContainerId())
return true
end
elseif useThing:isMultiUse() then
Game.setSelectedThing(useThing)
setTargetCursor()
Game.startUseWith(useThing)
return true
else
Game.use(useThing)
return true
end
return true
elseif creatureThing and keyboardModifiers == KeyboardAltModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
@@ -56,23 +48,21 @@ function Game.processMouseAction(menuPosition, mouseButton, autoWalk, lookThing,
return true
end
else
if mouseButton == MouseLeftButton and selectedThing then
Game.useWith(Game.getSelectedThing(), multiUseThing)
Game.setSelectedThing(nil)
restoreCursor()
return true
elseif multiUseThing and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
if multiUseThing and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
if multiUseThing:asCreature() then
Game.attack(multiUseThing:asCreature())
return true
elseif multiUseThing:isContainer() then
if multiUseThing:isInsideContainer() then
Game.open(multiUseThing, multiUseThing:getContainerId())
return true
else
Game.open(multiUseThing, Containers.getFreeContainerId())
return true
end
elseif multiUseThing:isMultiUse() then
Game.setSelectedThing(multiUseThing)
setTargetCursor()
Game.startUseWith(multiUseThing)
return true
else
Game.use(multiUseThing)
end
@@ -110,7 +100,7 @@ function Game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
end
else
if useThing:isMultiUse() then
menu:addOption('Use with ...', function() Game.setSelectedThing(useThing) setTargetCursor() end)
menu:addOption('Use with ...', function() Game.startUseWith(useThing) end)
else
menu:addOption('Use', function() Game.use(useThing) end)
end

View File

@@ -0,0 +1,8 @@
CombatControls = {}
function CombatControls.init()
end
function CombatControls.terminate()
end

View File

@@ -0,0 +1,7 @@
Module
name: game_combatcontrols
description: Combat controls window
author: OTClient team
website: https://github.com/edubart/otclient
onLoad: |
require 'combatcontrols'

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 B

View File

@@ -1,7 +1,7 @@
HealthBar = {}
-- private variables
local healthManaPanel
local healthBarWindow
local healthBar
local manaBar
local healthLabel
@@ -9,22 +9,32 @@ local manaLabel
-- public functions
function HealthBar.create()
healthManaPanel = displayUI('healthbar.otui', { parent = Game.gameRightPanel })
healthBar = healthManaPanel:getChildById('healthBar')
manaBar = healthManaPanel:getChildById('manaBar')
healthLabel = healthManaPanel:getChildById('healthLabel')
manaLabel = healthManaPanel:getChildById('manaLabel')
healthBarWindow = displayUI('healthbar.otui', { parent = Game.gameRightPanel })
healthBarButton = TopMenu.addGameButton('healthBarButton', 'Healh Bar', 'healthbar.png', HealthBar.toggle)
healthBarButton:setOn(true)
healthBar = healthBarWindow:getChildById('healthBar')
manaBar = healthBarWindow:getChildById('manaBar')
healthLabel = healthBarWindow:getChildById('healthLabel')
manaLabel = healthBarWindow:getChildById('manaLabel')
end
function HealthBar.destroy()
healthManaPanel:destroy()
healthManaPanel = nil
healthBarWindow:destroy()
healthBarWindow = nil
healthBarButton:destroy()
healthBarButton = nil
healthBar = nil
manaBar = nil
healthLabel = nil
manaLabel = nil
end
function HealthBar.toggle()
local visible = not healthBarWindow:isExplicitlyVisible()
healthBarWindow:setVisible(visible)
healthBarButton:setOn(visible)
end
-- hooked events
function HealthBar.onHealthChange(health, maxHealth)
healthLabel:setText(health .. ' / ' .. maxHealth)

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

View File

@@ -1,31 +1,42 @@
Inventory = {}
-- private variables
local window = nil
local inventoryWindow
local inventoryButton
-- public functions
function Inventory.create()
window = displayUI('inventory.otui', { parent = Game.gameRightPanel })
inventoryWindow = displayUI('inventory.otui', { parent = Game.gameRightPanel })
inventoryButton = TopMenu.addGameButton('inventoryButton', 'Skills (Ctrl+I)', 'inventory.png', Inventory.toggle)
inventoryButton:setOn(true)
end
function Inventory.destroy()
window:destroy()
window = nil
inventoryWindow:destroy()
inventoryWindow = nil
inventoryButton:destroy()
inventoryButton = nil
end
function Inventory.toggle()
local visible = not inventoryWindow:isExplicitlyVisible()
inventoryWindow:setVisible(visible)
inventoryButton:setOn(visible)
end
-- hooked events
function Inventory.onInventoryChange(slot, item)
local itemWidget = window:getChildById('slot' .. slot)
local itemWidget = inventoryWindow:getChildById('slot' .. slot)
itemWidget:setItem(item)
end
function Inventory.onFreeCapacityChange(freeCapacity)
local widget = window:getChildById('capacity')
local widget = inventoryWindow:getChildById('capacity')
widget:setText("Cap:\n" .. freeCapacity)
end
function Inventory.onSoulChange(soul)
local widget = window:getChildById('soul')
local widget = inventoryWindow:getChildById('soul')
widget:setText("Soul:\n" .. soul)
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 B

View File

View File

View File

View File

@@ -6,7 +6,7 @@ importStyle 'textmessage.otui'
-- private variables
local MessageTypes = {
consoleRed = { color = '#F55E5E', consoleTab = 'Server Log' },
eventOrange = { color = '#FE6500', consoleTab = 'Default' , windowLocation = 'center', consoleOption = 'showEventMessagesInConsole' },
eventOrange = { color = '#FE6500', consoleTab = 'Default' },
consoleOrange = { color = '#FE6500', consoleTab = 'Default' },
warning = { color = '#F55E5E', consoleTab = 'Server Log', windowLocation = 'center' },
eventAdvance = { color = '#FFFFFF', consoleTab = 'Server Log', windowLocation = 'center', consoleOption = 'showEventMessagesInConsole' },

View File

@@ -9,7 +9,7 @@ local addVipWindow
function VipList.create()
vipWindow = displayUI('viplist.otui', { parent = Game.gameRightPanel })
vipWindow:hide()
vipButton = TopMenu.addGameButton('vipListButton', 'VIP list', '/core_styles/icons/viplist.png', VipList.toggle)
vipButton = TopMenu.addGameButton('vipListButton', 'VIP list', 'viplist.png', VipList.toggle)
end
function VipList.destroy()

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B