creature square init, inventory improvements
This commit is contained in:
parent
5f34648c0e
commit
fd80589c7b
|
@ -29,7 +29,7 @@ function Inventory.destroy()
|
|||
end
|
||||
|
||||
-- hooked events
|
||||
function Game.onInventoryChange(slot, item)
|
||||
function Inventory.onInventoryChange(slot, item)
|
||||
local slotId
|
||||
if slot == InventorySlotHead then
|
||||
slotId = 'head'
|
||||
|
@ -57,5 +57,18 @@ function Game.onInventoryChange(slot, item)
|
|||
itemWidget:setItem(item)
|
||||
end
|
||||
|
||||
function Inventory.onFreeCapacityChange(freeCapacity)
|
||||
local widget = window:getChildById('capacity')
|
||||
widget:setText("Cap:\n" .. freeCapacity)
|
||||
end
|
||||
|
||||
function Inventory.onSoulChange(soul)
|
||||
local widget = window:getChildById('soul')
|
||||
widget:setText("Soul:\n" .. soul)
|
||||
end
|
||||
|
||||
connect(Game, { onLogin = Inventory.create,
|
||||
onLogout = Inventory.destroy })
|
||||
onLogout = Inventory.destroy,
|
||||
onInventoryChange = Inventory.onInventoryChange,
|
||||
onFreeCapacityChange = Inventory.onFreeCapacityChange,
|
||||
onSoulChange = Inventory.onSoulChange })
|
||||
|
|
|
@ -15,57 +15,83 @@ UIWindow
|
|||
id: armor
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin.top: 10
|
||||
margin.top: 5
|
||||
|
||||
Item
|
||||
id: legs
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin.top: 10
|
||||
margin.top: 5
|
||||
|
||||
Item
|
||||
id: feet
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin.top: 10
|
||||
margin.top: 5
|
||||
|
||||
Item
|
||||
id: necklace
|
||||
anchors.top: parent.top
|
||||
anchors.right: head.left
|
||||
margin.top: 15
|
||||
margin.right: 10
|
||||
margin.top: 10
|
||||
margin.right: 5
|
||||
|
||||
Item
|
||||
id: left
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin.top: 10
|
||||
margin.top: 5
|
||||
|
||||
Item
|
||||
id: ring
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin.top: 10
|
||||
margin.top: 5
|
||||
|
||||
Item
|
||||
id: backpack
|
||||
anchors.top: parent.top
|
||||
anchors.left: head.right
|
||||
margin.top: 15
|
||||
margin.left: 10
|
||||
margin.top: 10
|
||||
margin.left: 5
|
||||
|
||||
Item
|
||||
id: right
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin.top: 10
|
||||
margin.top: 5
|
||||
|
||||
Item
|
||||
id: ammo
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin.top: 10
|
||||
|
||||
|
||||
margin.top: 5
|
||||
|
||||
Label
|
||||
id: soul
|
||||
anchors.top: ring.bottom
|
||||
anchors.bottom: feet.bottom
|
||||
anchors.left: ring.left
|
||||
anchors.right: ring.right
|
||||
margin.top: 5
|
||||
|
||||
align: center
|
||||
|
||||
border-image:
|
||||
source: /core_styles/images/panel_flat.png
|
||||
border: 4
|
||||
|
||||
Label
|
||||
id: capacity
|
||||
anchors.top: ammo.bottom
|
||||
anchors.bottom: feet.bottom
|
||||
anchors.left: ammo.left
|
||||
anchors.right: ammo.right
|
||||
margin.top: 5
|
||||
|
||||
align: center
|
||||
|
||||
border-image:
|
||||
source: /core_styles/images/panel_flat.png
|
||||
border: 4
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
Creature::Creature() : Thing()
|
||||
{
|
||||
m_healthPercent = 0;
|
||||
m_showSquareColor = false;
|
||||
m_direction = Otc::South;
|
||||
|
||||
m_walking = false;
|
||||
|
@ -46,6 +47,12 @@ void Creature::draw(const Point& p)
|
|||
{
|
||||
const ThingType& type = getType();
|
||||
|
||||
// TODO: activate on attack, follow, discover how 'attacked' works
|
||||
if(m_showSquareColor) {
|
||||
g_graphics.bindColor(Outfit::getColor(m_squareColor));
|
||||
g_graphics.drawBoundingRect(Rect(p + m_walkOffset - 8, Size(32, 32)), 2);
|
||||
}
|
||||
|
||||
// Render creature
|
||||
for(m_yPattern = 0; m_yPattern < type.dimensions[ThingType::PatternY]; m_yPattern++) {
|
||||
|
||||
|
@ -54,6 +61,7 @@ void Creature::draw(const Point& p)
|
|||
continue;
|
||||
|
||||
// draw white item
|
||||
g_graphics.bindColor(Fw::white);
|
||||
internalDraw(p + m_walkOffset, 0);
|
||||
|
||||
// draw mask if exists
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
void setShield(uint8 shield) { m_shield = shield; }
|
||||
void setEmblem(uint8 emblem) { m_emblem = emblem; }
|
||||
void setImpassable(bool impassable) { m_impassable = impassable; }
|
||||
void setSquareColor(uint8 squareColor) { m_squareColor = squareColor; }
|
||||
|
||||
std::string getName() { return m_name; }
|
||||
uint8 getHealthPercent() { return m_healthPercent; }
|
||||
|
@ -81,6 +82,8 @@ protected:
|
|||
uint8 m_shield;
|
||||
uint8 m_emblem;
|
||||
bool m_impassable;
|
||||
uint8 m_squareColor;
|
||||
bool m_showSquareColor;
|
||||
|
||||
FontPtr m_informationFont;
|
||||
Color m_informationColor;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "outfit.h"
|
||||
|
||||
Color Outfit::internalGetColor(int color)
|
||||
Color Outfit::getColor(int color)
|
||||
{
|
||||
if(color >= HSI_H_STEPS * HSI_SI_VALUES)
|
||||
color = 0;
|
||||
|
|
|
@ -33,11 +33,13 @@ class Outfit
|
|||
};
|
||||
|
||||
public:
|
||||
static Color getColor(int color);
|
||||
|
||||
void setType(int type) { m_type = type; }
|
||||
void setHead(int head) { m_head = internalGetColor(head); }
|
||||
void setBody(int body) { m_body = internalGetColor(body); }
|
||||
void setLegs(int legs) { m_legs = internalGetColor(legs); }
|
||||
void setFeet(int feet) { m_feet = internalGetColor(feet); }
|
||||
void setHead(int head) { m_head = getColor(head); }
|
||||
void setBody(int body) { m_body = getColor(body); }
|
||||
void setLegs(int legs) { m_legs = getColor(legs); }
|
||||
void setFeet(int feet) { m_feet = getColor(feet); }
|
||||
void setAddons(int addons) { m_addons = addons; }
|
||||
|
||||
int getType() { return m_type; }
|
||||
|
@ -48,8 +50,6 @@ public:
|
|||
int getAddons() { return m_addons; }
|
||||
|
||||
private:
|
||||
Color internalGetColor(int color);
|
||||
|
||||
int m_type, m_addons;
|
||||
Color m_head, m_body, m_legs, m_feet;
|
||||
};
|
||||
|
|
|
@ -546,8 +546,12 @@ void ProtocolGame::parseDistanceMissile(InputMessage& msg)
|
|||
|
||||
void ProtocolGame::parseCreatureSquare(InputMessage& msg)
|
||||
{
|
||||
msg.getU32(); // creatureId
|
||||
msg.getU8(); // color
|
||||
uint32 id = msg.getU32();
|
||||
uint8 color = msg.getU8();
|
||||
|
||||
CreaturePtr creature = g_map.getCreatureById(id);
|
||||
if(creature)
|
||||
creature->setSquareColor(color);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseCreatureHealth(InputMessage& msg)
|
||||
|
@ -649,10 +653,16 @@ void ProtocolGame::parsePlayerStats(InputMessage& msg)
|
|||
g_lua.callGlobalField("Game", "onHealthChange", m_localPlayer->getStatistic(Otc::Health), m_localPlayer->getStatistic(Otc::MaxHealth));
|
||||
});
|
||||
|
||||
m_localPlayer->setStatistic(Otc::FreeCapacity, msg.getU32());
|
||||
m_localPlayer->setStatistic(Otc::FreeCapacity, msg.getU32() / 100.0);
|
||||
|
||||
g_dispatcher.addEvent([=] {
|
||||
g_lua.callGlobalField("Game", "onFreeCapacityChange", m_localPlayer->getStatistic(Otc::FreeCapacity));
|
||||
});
|
||||
|
||||
m_localPlayer->setStatistic(Otc::Experience, msg.getU32());
|
||||
m_localPlayer->setStatistic(Otc::Level, msg.getU16());
|
||||
m_localPlayer->setStatistic(Otc::LevelPercent, msg.getU8());
|
||||
|
||||
m_localPlayer->setStatistic(Otc::Mana, msg.getU16());
|
||||
m_localPlayer->setStatistic(Otc::MaxMana, msg.getU16());
|
||||
|
||||
|
@ -662,7 +672,13 @@ void ProtocolGame::parsePlayerStats(InputMessage& msg)
|
|||
|
||||
m_localPlayer->setStatistic(Otc::MagicLevel, msg.getU8());
|
||||
m_localPlayer->setStatistic(Otc::MagicLevelPercent, msg.getU8());
|
||||
|
||||
m_localPlayer->setStatistic(Otc::Soul, msg.getU8());
|
||||
|
||||
g_dispatcher.addEvent([=] {
|
||||
g_lua.callGlobalField("Game", "onSoulChange", m_localPlayer->getStatistic(Otc::Soul));
|
||||
});
|
||||
|
||||
m_localPlayer->setStatistic(Otc::Stamina, msg.getU16());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue