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

5
BUGS
View File

@ -11,11 +11,10 @@ hotkeys works while windows are locked, it shouldnt
some animated hits are displayed as 2 hits instead of one some animated hits are displayed as 2 hits instead of one
numpad on windows doesn't work correctly numpad on windows doesn't work correctly
skulls is rendering outside map bounds skulls is rendering outside map bounds
these are some issues when skill progressbar is 0% or 100%
paste on x11 platform does not work correctly when doing ctrl+c in google chrome paste on x11 platform does not work correctly when doing ctrl+c in google chrome
party options does not work when relogging inside a party
walk animation doesnt reset when leaving invisible chamaleon doesnt animate items
non tiles are no black
drop items in container background drop items in container background
can view ocean in underground floors can view ocean in underground floors

4
TODO
View File

@ -12,13 +12,9 @@ adjust interface design
display exit box when exiting from game display exit box when exiting from game
attack modes attack modes
player status icons (poison, etc) player status icons (poison, etc)
container windows
move items
use with
move count itens move count itens
open/close vip/skills
move windows, go back in containers move windows, go back in containers
open private chat open private chat
reopen channels reopen channels

View File

@ -107,7 +107,7 @@ function Terminal.init()
terminalWidget = displayUI('terminal.otui') terminalWidget = displayUI('terminal.otui')
terminalWidget:setVisible(false) 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) Hotkeys.bindKeyDown('Ctrl+T', Terminal.toggle)
commandHistory = Settings.getList('terminal-history') 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 -- public functions
function About.init() 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 end
function About.display() 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 = displayUI('options.otui')
optionsWindow:setVisible(false) 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) Hotkeys.bindKeyDown('Ctrl+O', Options.toggle)
end 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 end
function TopMenu.addLeftButton(id, description, icon, callback) 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 end
function TopMenu.addRightButton(id, description, icon, callback) 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 end
function TopMenu.removeButton(param) function TopMenu.removeButton(param)

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 B

View File

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

View File

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

View File

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

View File

@ -2,8 +2,7 @@ function UIItem:onDragEnter(mousePos)
local item = self:getItem() local item = self:getItem()
if not item then return false end if not item then return false end
self:setBorderWidth('1') self:setBorderWidth(1)
self:setBorderColor('#ffffff')
self.currentDragThing = item self.currentDragThing = item
setTargetCursor() setTargetCursor()
@ -13,7 +12,7 @@ end
function UIItem:onDragLeave(widget, mousePos) function UIItem:onDragLeave(widget, mousePos)
self.currentDragThing = nil self.currentDragThing = nil
restoreCursor() restoreCursor()
self:setBorderWidth('0') self:setBorderWidth(0)
return true return true
end end
@ -24,9 +23,20 @@ function UIItem:onDrop(widget, mousePos)
local count = widget.currentDragThing:getData() local count = widget.currentDragThing:getData()
Game.move(widget.currentDragThing, pos, count) Game.move(widget.currentDragThing, pos, count)
self:setBorderWidth(0)
return true return true
end 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) function UIItem:onMouseRelease(mousePosition, mouseButton)
local item = self:getItem() local item = self:getItem()
if not item or not self:containsPoint(mousePosition) then return false end 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 -- private functions
local function onGameKeyPress(self, keyCode, keyboardModifiers, wouldFilter) local function onGameKeyPress(self, keyCode, keyboardModifiers, wouldFilter)
if wouldFilter then return end if wouldFilter then return end
@ -13,7 +16,34 @@ local function onGameKeyPress(self, keyCode, keyboardModifiers, wouldFilter)
return false return false
end 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 -- public functions
function Game.startUseWith(thing)
Game.selectedThing = thing
m_mouseGrabberWidget:grabMouse()
setTargetCursor()
end
function Game.createInterface() function Game.createInterface()
Background.hide() Background.hide()
CharacterList.destroyLoadBox() CharacterList.destroyLoadBox()
@ -33,7 +63,9 @@ function Game.createInterface()
Game.gameMapPanel = Game.gameUi:getChildById('gameMapPanel') Game.gameMapPanel = Game.gameUi:getChildById('gameMapPanel')
Game.gameRightPanel = Game.gameUi:getChildById('gameRightPanel') Game.gameRightPanel = Game.gameUi:getChildById('gameRightPanel')
Game.gameBottomPanel = Game.gameUi:getChildById('gameBottomPanel') 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 end
function Game.destroyInterface() function Game.destroyInterface()

View File

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

View File

@ -21,7 +21,7 @@ function UIMap:onDrop(widget, mousePos)
local tile = self:getTile(mousePos) local tile = self:getTile(mousePos)
if not tile then return false end 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) Game.move(widget.currentDragThing, tile:getPos(), count)
return true return true

View File

@ -14,24 +14,13 @@ end
function Game.processMouseAction(menuPosition, mouseButton, autoWalk, lookThing, useThing, creatureThing, multiUseThing) function Game.processMouseAction(menuPosition, mouseButton, autoWalk, lookThing, useThing, creatureThing, multiUseThing)
local keyboardModifiers = g_window.getKeyboardModifiers() local keyboardModifiers = g_window.getKeyboardModifiers()
local selectedThing = Game.getSelectedThing() if autoWalk and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton then
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
-- todo auto walk -- todo auto walk
return true return true
end end
if not Options.classicControl then if not Options.classicControl then
if mouseButton == MouseLeftButton and selectedThing then if keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
Game.useWith(Game.getSelectedThing(), multiUseThing)
Game.setSelectedThing(nil)
restoreCursor()
return true
elseif keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
Game.createThingMenu(menuPosition, lookThing, useThing, creatureThing) Game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
return true return true
elseif lookThing and keyboardModifiers == KeyboardShiftModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then 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:isContainer() then
if useThing:isInsideContainer() then if useThing:isInsideContainer() then
Game.open(useThing, useThing:getContainerId()) Game.open(useThing, useThing:getContainerId())
return true
else else
Game.open(useThing, Containers.getFreeContainerId()) Game.open(useThing, Containers.getFreeContainerId())
return true
end end
elseif useThing:isMultiUse() then elseif useThing:isMultiUse() then
Game.setSelectedThing(useThing) Game.startUseWith(useThing)
setTargetCursor() return true
else else
Game.use(useThing) Game.use(useThing)
return true
end end
return true return true
elseif creatureThing and keyboardModifiers == KeyboardAltModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then 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 return true
end end
else else
if mouseButton == MouseLeftButton and selectedThing then if multiUseThing and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
Game.useWith(Game.getSelectedThing(), multiUseThing)
Game.setSelectedThing(nil)
restoreCursor()
return true
elseif multiUseThing and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
if multiUseThing:asCreature() then if multiUseThing:asCreature() then
Game.attack(multiUseThing:asCreature()) Game.attack(multiUseThing:asCreature())
return true
elseif multiUseThing:isContainer() then elseif multiUseThing:isContainer() then
if multiUseThing:isInsideContainer() then if multiUseThing:isInsideContainer() then
Game.open(multiUseThing, multiUseThing:getContainerId()) Game.open(multiUseThing, multiUseThing:getContainerId())
return true
else else
Game.open(multiUseThing, Containers.getFreeContainerId()) Game.open(multiUseThing, Containers.getFreeContainerId())
return true
end end
elseif multiUseThing:isMultiUse() then elseif multiUseThing:isMultiUse() then
Game.setSelectedThing(multiUseThing) Game.startUseWith(multiUseThing)
setTargetCursor() return true
else else
Game.use(multiUseThing) Game.use(multiUseThing)
end end
@ -110,7 +100,7 @@ function Game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
end end
else else
if useThing:isMultiUse() then if useThing:isMultiUse() then
menu:addOption('Use with ...', function() Game.setSelectedThing(useThing) setTargetCursor() end) menu:addOption('Use with ...', function() Game.startUseWith(useThing) end)
else else
menu:addOption('Use', function() Game.use(useThing) end) menu:addOption('Use', function() Game.use(useThing) end)
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 = {} HealthBar = {}
-- private variables -- private variables
local healthManaPanel local healthBarWindow
local healthBar local healthBar
local manaBar local manaBar
local healthLabel local healthLabel
@ -9,22 +9,32 @@ local manaLabel
-- public functions -- public functions
function HealthBar.create() function HealthBar.create()
healthManaPanel = displayUI('healthbar.otui', { parent = Game.gameRightPanel }) healthBarWindow = displayUI('healthbar.otui', { parent = Game.gameRightPanel })
healthBar = healthManaPanel:getChildById('healthBar') healthBarButton = TopMenu.addGameButton('healthBarButton', 'Healh Bar', 'healthbar.png', HealthBar.toggle)
manaBar = healthManaPanel:getChildById('manaBar') healthBarButton:setOn(true)
healthLabel = healthManaPanel:getChildById('healthLabel') healthBar = healthBarWindow:getChildById('healthBar')
manaLabel = healthManaPanel:getChildById('manaLabel') manaBar = healthBarWindow:getChildById('manaBar')
healthLabel = healthBarWindow:getChildById('healthLabel')
manaLabel = healthBarWindow:getChildById('manaLabel')
end end
function HealthBar.destroy() function HealthBar.destroy()
healthManaPanel:destroy() healthBarWindow:destroy()
healthManaPanel = nil healthBarWindow = nil
healthBarButton:destroy()
healthBarButton = nil
healthBar = nil healthBar = nil
manaBar = nil manaBar = nil
healthLabel = nil healthLabel = nil
manaLabel = nil manaLabel = nil
end end
function HealthBar.toggle()
local visible = not healthBarWindow:isExplicitlyVisible()
healthBarWindow:setVisible(visible)
healthBarButton:setOn(visible)
end
-- hooked events -- hooked events
function HealthBar.onHealthChange(health, maxHealth) function HealthBar.onHealthChange(health, maxHealth)
healthLabel:setText(health .. ' / ' .. maxHealth) healthLabel:setText(health .. ' / ' .. maxHealth)

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

View File

@ -1,31 +1,42 @@
Inventory = {} Inventory = {}
-- private variables -- private variables
local window = nil local inventoryWindow
local inventoryButton
-- public functions -- public functions
function Inventory.create() 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 end
function Inventory.destroy() function Inventory.destroy()
window:destroy() inventoryWindow:destroy()
window = nil inventoryWindow = nil
inventoryButton:destroy()
inventoryButton = nil
end
function Inventory.toggle()
local visible = not inventoryWindow:isExplicitlyVisible()
inventoryWindow:setVisible(visible)
inventoryButton:setOn(visible)
end end
-- hooked events -- hooked events
function Inventory.onInventoryChange(slot, item) function Inventory.onInventoryChange(slot, item)
local itemWidget = window:getChildById('slot' .. slot) local itemWidget = inventoryWindow:getChildById('slot' .. slot)
itemWidget:setItem(item) itemWidget:setItem(item)
end end
function Inventory.onFreeCapacityChange(freeCapacity) function Inventory.onFreeCapacityChange(freeCapacity)
local widget = window:getChildById('capacity') local widget = inventoryWindow:getChildById('capacity')
widget:setText("Cap:\n" .. freeCapacity) widget:setText("Cap:\n" .. freeCapacity)
end end
function Inventory.onSoulChange(soul) function Inventory.onSoulChange(soul)
local widget = window:getChildById('soul') local widget = inventoryWindow:getChildById('soul')
widget:setText("Soul:\n" .. soul) widget:setText("Soul:\n" .. soul)
end 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 -- private variables
local MessageTypes = { local MessageTypes = {
consoleRed = { color = '#F55E5E', consoleTab = 'Server Log' }, 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' }, consoleOrange = { color = '#FE6500', consoleTab = 'Default' },
warning = { color = '#F55E5E', consoleTab = 'Server Log', windowLocation = 'center' }, warning = { color = '#F55E5E', consoleTab = 'Server Log', windowLocation = 'center' },
eventAdvance = { color = '#FFFFFF', consoleTab = 'Server Log', windowLocation = 'center', consoleOption = 'showEventMessagesInConsole' }, eventAdvance = { color = '#FFFFFF', consoleTab = 'Server Log', windowLocation = 'center', consoleOption = 'showEventMessagesInConsole' },

View File

@ -9,7 +9,7 @@ local addVipWindow
function VipList.create() function VipList.create()
vipWindow = displayUI('viplist.otui', { parent = Game.gameRightPanel }) vipWindow = displayUI('viplist.otui', { parent = Game.gameRightPanel })
vipWindow:hide() 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 end
function VipList.destroy() function VipList.destroy()

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B

View File

@ -28,6 +28,8 @@ uint FrameBuffer::boundFbo = 0;
FrameBuffer::FrameBuffer(const Size& size) FrameBuffer::FrameBuffer(const Size& size)
{ {
m_clearColor = Fw::alpha;
glGenFramebuffers(1, &m_fbo); glGenFramebuffers(1, &m_fbo);
if(!m_fbo) if(!m_fbo)
logFatal("Unable to create framebuffer object"); logFatal("Unable to create framebuffer object");
@ -68,8 +70,10 @@ void FrameBuffer::bind(bool clear)
g_painter.setProjectionMatrix(projectionMatrix); g_painter.setProjectionMatrix(projectionMatrix);
g_graphics.setViewportSize(m_texture->getSize()); g_graphics.setViewportSize(m_texture->getSize());
if(clear) if(clear) {
glClearColor(m_clearColor.rF(), m_clearColor.gF(), m_clearColor.bF(), m_clearColor.aF());
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
}
} }
void FrameBuffer::release() void FrameBuffer::release()

View File

@ -36,6 +36,8 @@ public:
void release(); void release();
void draw(const Rect& dest); void draw(const Rect& dest);
void setClearColor(const Color& color) { m_clearColor = color; }
TexturePtr getTexture() { return m_texture; } TexturePtr getTexture() { return m_texture; }
private: private:
@ -48,6 +50,7 @@ private:
Size m_oldViewportSize; Size m_oldViewportSize;
uint m_fbo; uint m_fbo;
uint m_prevBoundFbo; uint m_prevBoundFbo;
Color m_clearColor;
static uint boundFbo; static uint boundFbo;
}; };

View File

@ -43,7 +43,6 @@ void Graphics::init()
#endif #endif
glEnable(GL_BLEND); glEnable(GL_BLEND);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
logInfo("GPU ", glGetString(GL_RENDERER)); logInfo("GPU ", glGetString(GL_RENDERER));
logInfo("OpenGL ", glGetString(GL_VERSION)); logInfo("OpenGL ", glGetString(GL_VERSION));
@ -93,6 +92,7 @@ void Graphics::resize(const Size& size)
void Graphics::beginRender() void Graphics::beginRender()
{ {
glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
} }

View File

@ -435,6 +435,7 @@ void Application::registerLuaFunctions()
g_lua.bindClassStaticFunction("g_ui", "getStyleClass", std::bind(&UIManager::getStyleClass, &g_ui, _1)); g_lua.bindClassStaticFunction("g_ui", "getStyleClass", std::bind(&UIManager::getStyleClass, &g_ui, _1));
g_lua.bindClassStaticFunction("g_ui", "loadUI", std::bind(&UIManager::loadUI, &g_ui, _1, _2)); g_lua.bindClassStaticFunction("g_ui", "loadUI", std::bind(&UIManager::loadUI, &g_ui, _1, _2));
g_lua.bindClassStaticFunction("g_ui", "getRootWidget", std::bind(&UIManager::getRootWidget, &g_ui)); g_lua.bindClassStaticFunction("g_ui", "getRootWidget", std::bind(&UIManager::getRootWidget, &g_ui));
g_lua.bindClassStaticFunction("g_ui", "getDraggingWidget", std::bind(&UIManager::getDraggingWidget, &g_ui));
g_lua.bindClassStaticFunction("g_ui", "setDebugBoxesDrawing", std::bind(&UIManager::setDebugBoxesDrawing, &g_ui, _1)); g_lua.bindClassStaticFunction("g_ui", "setDebugBoxesDrawing", std::bind(&UIManager::setDebugBoxesDrawing, &g_ui, _1));
g_lua.bindClassStaticFunction("g_ui", "isDrawingDebugBoxes", std::bind(&UIManager::setDebugBoxesDrawing, &g_ui, _1)); g_lua.bindClassStaticFunction("g_ui", "isDrawingDebugBoxes", std::bind(&UIManager::setDebugBoxesDrawing, &g_ui, _1));

View File

@ -40,6 +40,11 @@ public:
uint8 g() const { return m_g; } uint8 g() const { return m_g; }
uint8 r() const { return m_r; } uint8 r() const { return m_r; }
float aF() const { return m_a/255.0f; }
float bF() const { return m_b/255.0f; }
float gF() const { return m_g/255.0f; }
float rF() const { return m_r/255.0f; }
uint32 rgba() const { return m_rgba; } uint32 rgba() const { return m_rgba; }
const uint8* rgbaPtr() const { return (const uint8*)&m_rgba; } const uint8* rgbaPtr() const { return (const uint8*)&m_rgba; }

View File

@ -72,7 +72,7 @@ void UIManager::inputEvent(const InputEvent& event)
m_keyboardReceiver->propagateOnKeyUp(event.keyCode, event.keyboardModifiers); m_keyboardReceiver->propagateOnKeyUp(event.keyCode, event.keyboardModifiers);
break; break;
case Fw::MousePressInputEvent: case Fw::MousePressInputEvent:
m_keyboardReceiver->propagateOnMousePress(event.mousePos, event.mouseButton); m_mouseReceiver->propagateOnMousePress(event.mousePos, event.mouseButton);
break; break;
case Fw::MouseReleaseInputEvent: case Fw::MouseReleaseInputEvent:
m_mouseReceiver->propagateOnMouseRelease(event.mousePos, event.mouseButton); m_mouseReceiver->propagateOnMouseRelease(event.mousePos, event.mouseButton);

View File

@ -830,10 +830,11 @@ UIWidgetPtr UIWidget::recursiveGetChildById(const std::string& id)
UIWidgetPtr UIWidget::recursiveGetChildByPos(const Point& childPos) UIWidgetPtr UIWidget::recursiveGetChildByPos(const Point& childPos)
{ {
for(const UIWidgetPtr& child : m_children) { for(const UIWidgetPtr& child : m_children) {
if(child->containsPoint(childPos)) { if(child->isExplicitlyVisible() && child->containsPoint(childPos)) {
if(UIWidgetPtr subChild = child->recursiveGetChildByPos(childPos)) if(UIWidgetPtr subChild = child->recursiveGetChildByPos(childPos))
return subChild; return subChild;
return child; else if(!child->isPhantom())
return child;
} }
} }
return nullptr; return nullptr;
@ -1113,7 +1114,7 @@ bool UIWidget::onMousePress(const Point& mousePos, Fw::MouseButton button)
return callLuaField<bool>("onMousePress", mousePos, button); return callLuaField<bool>("onMousePress", mousePos, button);
} }
void UIWidget::onMouseRelease(const Point& mousePos, Fw::MouseButton button) bool UIWidget::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
{ {
if(isPressed() && getRect().contains(mousePos)) if(isPressed() && getRect().contains(mousePos))
callLuaField("onClick"); callLuaField("onClick");
@ -1125,7 +1126,7 @@ void UIWidget::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
draggedWidget->setDragging(false); draggedWidget->setDragging(false);
} }
callLuaField("onMouseRelease", mousePos, button); return callLuaField<bool>("onMouseRelease", mousePos, button);
} }
bool UIWidget::onMouseMove(const Point& mousePos, const Point& mouseMoved) bool UIWidget::onMouseMove(const Point& mousePos, const Point& mouseMoved)
@ -1260,16 +1261,16 @@ bool UIWidget::propagateOnMousePress(const Point& mousePos, Fw::MouseButton butt
// only non phatom widgets receives mouse press events // only non phatom widgets receives mouse press events
if(!isPhantom()) { if(!isPhantom()) {
onMousePress(mousePos, button); bool ret = onMousePress(mousePos, button);
if(button == Fw::MouseLeftButton && !isPressed()) if(button == Fw::MouseLeftButton && !isPressed())
setPressed(true); setPressed(true);
return true; return ret;
} }
return false; return false;
} }
void UIWidget::propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton button) bool UIWidget::propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton button)
{ {
// do a backup of children list, because it may change while looping it // do a backup of children list, because it may change while looping it
UIWidgetList children; UIWidgetList children;
@ -1283,13 +1284,16 @@ void UIWidget::propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton bu
} }
for(const UIWidgetPtr& child : children) { for(const UIWidgetPtr& child : children) {
child->propagateOnMouseRelease(mousePos, button); if(child->propagateOnMouseRelease(mousePos, button))
return true;
} }
onMouseRelease(mousePos, button); bool ret = onMouseRelease(mousePos, button);
if(isPressed() && button == Fw::MouseLeftButton) if(isPressed() && button == Fw::MouseLeftButton)
setPressed(false); setPressed(false);
return ret;
} }
bool UIWidget::propagateOnMouseMove(const Point& mousePos, const Point& mouseMoved) bool UIWidget::propagateOnMouseMove(const Point& mousePos, const Point& mouseMoved)

View File

@ -173,7 +173,7 @@ protected:
virtual bool onKeyPress(uchar keyCode, int keyboardModifiers, bool wouldFilter); virtual bool onKeyPress(uchar keyCode, int keyboardModifiers, bool wouldFilter);
virtual bool onKeyUp(uchar keyCode, int keyboardModifiers); virtual bool onKeyUp(uchar keyCode, int keyboardModifiers);
virtual bool onMousePress(const Point& mousePos, Fw::MouseButton button); virtual bool onMousePress(const Point& mousePos, Fw::MouseButton button);
virtual void onMouseRelease(const Point& mousePos, Fw::MouseButton button); virtual bool onMouseRelease(const Point& mousePos, Fw::MouseButton button);
virtual bool onMouseMove(const Point& mousePos, const Point& mouseMoved); virtual bool onMouseMove(const Point& mousePos, const Point& mouseMoved);
virtual bool onMouseWheel(const Point& mousePos, Fw::MouseWheelDirection direction); virtual bool onMouseWheel(const Point& mousePos, Fw::MouseWheelDirection direction);
@ -182,7 +182,7 @@ protected:
bool propagateOnKeyPress(uchar keyCode, int keyboardModifiers, bool wouldFilter); bool propagateOnKeyPress(uchar keyCode, int keyboardModifiers, bool wouldFilter);
bool propagateOnKeyUp(uchar keyCode, int keyboardModifiers); bool propagateOnKeyUp(uchar keyCode, int keyboardModifiers);
bool propagateOnMousePress(const Point& mousePos, Fw::MouseButton button); bool propagateOnMousePress(const Point& mousePos, Fw::MouseButton button);
void propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton button); bool propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton button);
bool propagateOnMouseMove(const Point& mousePos, const Point& mouseMoved); bool propagateOnMouseMove(const Point& mousePos, const Point& mouseMoved);
bool propagateOnMouseWheel(const Point& mousePos, Fw::MouseWheelDirection direction); bool propagateOnMouseWheel(const Point& mousePos, Fw::MouseWheelDirection direction);

View File

@ -245,12 +245,13 @@ void Creature::stopWalk()
void Creature::updateWalkAnimation(int totalPixelsWalked) void Creature::updateWalkAnimation(int totalPixelsWalked)
{ {
// update outfit animation // update outfit animation
if(m_outfit.getCategory() == ThingsType::Creature) { if(m_outfit.getCategory() != ThingsType::Creature)
if(totalPixelsWalked == 32 || totalPixelsWalked == 0 || m_type->dimensions[ThingType::AnimationPhases] <= 1) return;
m_animation = 0;
else if(m_type->dimensions[ThingType::AnimationPhases] > 1) if(totalPixelsWalked == 32 || totalPixelsWalked == 0 || m_type->dimensions[ThingType::AnimationPhases] <= 1)
m_animation = 1 + ((totalPixelsWalked * 4) / Map::NUM_TILE_PIXELS) % (m_type->dimensions[ThingType::AnimationPhases] - 1); m_animation = 0;
} else if(m_type->dimensions[ThingType::AnimationPhases] > 1)
m_animation = 1 + ((totalPixelsWalked * 4) / Map::NUM_TILE_PIXELS) % (m_type->dimensions[ThingType::AnimationPhases] - 1);
} }
void Creature::updateWalkOffset(int totalPixelsWalked) void Creature::updateWalkOffset(int totalPixelsWalked)
@ -373,11 +374,12 @@ void Creature::setDirection(Otc::Direction direction)
void Creature::setOutfit(const Outfit& outfit) void Creature::setOutfit(const Outfit& outfit)
{ {
if(m_outfit.getCategory() != ThingsType::Effect && outfit.getCategory() == ThingsType::Effect) { m_outfit = outfit;
auto self = asCreature(); m_type = getType();
g_dispatcher.scheduleEvent([self]() { m_animation = 0;
self->updateInvisibleAnimation();
}, INVISIBLE_TICKS); if(m_outfit.getCategory() == ThingsType::Effect) {
updateInvisibleAnimation();
m_xPattern = 0; m_xPattern = 0;
m_yPattern = 0; m_yPattern = 0;
@ -387,11 +389,7 @@ void Creature::setOutfit(const Outfit& outfit)
m_yPattern = 0; m_yPattern = 0;
} }
m_outfit = outfit;
m_type = getType();
if(m_outfit.getCategory() == ThingsType::Creature && m_type->dimensions[ThingType::Layers] == 1) { if(m_outfit.getCategory() == ThingsType::Creature && m_type->dimensions[ThingType::Layers] == 1) {
m_animation = 0;
m_outfit.resetClothes(); m_outfit.resetClothes();
} }
} }
@ -453,6 +451,9 @@ void Creature::addVolatileSquare(uint8 color)
void Creature::updateInvisibleAnimation() void Creature::updateInvisibleAnimation()
{ {
if(!g_game.isOnline() || m_outfit.getCategory() != ThingsType::Effect)
return;
if(m_animation == 1) if(m_animation == 1)
m_animation = 2; m_animation = 2;
else if(m_animation == 2) else if(m_animation == 2)
@ -462,12 +463,10 @@ void Creature::updateInvisibleAnimation()
else else
m_animation = 1; m_animation = 1;
if(g_game.isOnline() && m_outfit.getCategory() == ThingsType::Effect) { auto self = asCreature();
auto self = asCreature(); g_dispatcher.scheduleEvent([self]() {
g_dispatcher.scheduleEvent([self]() { self->updateInvisibleAnimation();
self->updateInvisibleAnimation(); }, INVISIBLE_TICKS);
}, INVISIBLE_TICKS);
}
} }
void Creature::updateShield() void Creature::updateShield()

View File

@ -36,7 +36,6 @@ Game g_game;
void Game::loginWorld(const std::string& account, const std::string& password, const std::string& worldHost, int worldPort, const std::string& characterName) void Game::loginWorld(const std::string& account, const std::string& password, const std::string& worldHost, int worldPort, const std::string& characterName)
{ {
m_dead = false; m_dead = false;
m_selectedThing = nullptr;
m_protocolGame = ProtocolGamePtr(new ProtocolGame); m_protocolGame = ProtocolGamePtr(new ProtocolGame);
m_protocolGame->login(account, password, worldHost, (uint16)worldPort, characterName); m_protocolGame->login(account, password, worldHost, (uint16)worldPort, characterName);
} }

View File

@ -107,9 +107,6 @@ public:
bool isOnline() { return !!m_localPlayer; } bool isOnline() { return !!m_localPlayer; }
bool isDead() { return m_dead; } bool isDead() { return m_dead; }
void setSelectedThing(const ThingPtr& thing) { m_selectedThing = thing; }
ThingPtr getSelectedThing() { return m_selectedThing; }
void setServerBeat(int serverBeat) { m_serverBeat = serverBeat; } void setServerBeat(int serverBeat) { m_serverBeat = serverBeat; }
int getServerBeat() { return m_serverBeat; } int getServerBeat() { return m_serverBeat; }
@ -122,7 +119,6 @@ private:
ProtocolGamePtr m_protocolGame; ProtocolGamePtr m_protocolGame;
bool m_dead; bool m_dead;
int m_serverBeat; int m_serverBeat;
ThingPtr m_selectedThing;
}; };
extern Game g_game; extern Game g_game;

View File

@ -46,6 +46,7 @@ void Map::draw(const Rect& rect)
if(!m_framebuffer) { if(!m_framebuffer) {
Size fboSize(m_visibleSize.width() * NUM_TILE_PIXELS, m_visibleSize.height() * NUM_TILE_PIXELS); Size fboSize(m_visibleSize.width() * NUM_TILE_PIXELS, m_visibleSize.height() * NUM_TILE_PIXELS);
m_framebuffer = FrameBufferPtr(new FrameBuffer(fboSize)); m_framebuffer = FrameBufferPtr(new FrameBuffer(fboSize));
m_framebuffer->setClearColor(Fw::black);
m_shaderProgram = PainterShaderProgramPtr(new PainterShaderProgram); m_shaderProgram = PainterShaderProgramPtr(new PainterShaderProgram);

View File

@ -224,8 +224,6 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassStaticFunction<Game>("getLocalPlayer", std::bind(&Game::getLocalPlayer, &g_game)); g_lua.bindClassStaticFunction<Game>("getLocalPlayer", std::bind(&Game::getLocalPlayer, &g_game));
g_lua.bindClassStaticFunction<Game>("getProtocolVersion", std::bind(&Game::getProtocolVersion, &g_game)); g_lua.bindClassStaticFunction<Game>("getProtocolVersion", std::bind(&Game::getProtocolVersion, &g_game));
g_lua.bindClassStaticFunction<Game>("getProtocolGame", std::bind(&Game::getProtocolGame, &g_game)); g_lua.bindClassStaticFunction<Game>("getProtocolGame", std::bind(&Game::getProtocolGame, &g_game));
g_lua.bindClassStaticFunction<Game>("setSelectedThing", std::bind(&Game::setSelectedThing, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("getSelectedThing", std::bind(&Game::getSelectedThing, &g_game));
g_lua.registerClass<UIItem, UIWidget>(); g_lua.registerClass<UIItem, UIWidget>();
g_lua.bindClassStaticFunction<UIItem>("create", []{ return UIItemPtr(new UIItem); } ); g_lua.bindClassStaticFunction<UIItem>("create", []{ return UIItemPtr(new UIItem); } );