mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 03:54:54 +02:00
finally reloadable vip, skills, inventory, chat and minimap
This commit is contained in:
@@ -154,6 +154,21 @@ namespace Otc
|
||||
LastSkill
|
||||
};
|
||||
|
||||
enum Inventory {
|
||||
NoInventory = 0,
|
||||
Head,
|
||||
Neck,
|
||||
Bag,
|
||||
Armor,
|
||||
RightHand,
|
||||
LeftHand,
|
||||
Legs,
|
||||
Feet,
|
||||
Ring,
|
||||
Ammo,
|
||||
LastInventory
|
||||
};
|
||||
|
||||
enum Direction {
|
||||
North = 0,
|
||||
East,
|
||||
|
@@ -55,6 +55,7 @@ void Game::resetGameStates()
|
||||
container->close();
|
||||
}
|
||||
m_containers.clear();
|
||||
m_vips.clear();
|
||||
|
||||
m_worldName = "";
|
||||
}
|
||||
@@ -241,7 +242,7 @@ void Game::processInventoryChange(int slot, const ItemPtr& item)
|
||||
if(item)
|
||||
item->setPosition(Position(65535, slot, 0));
|
||||
|
||||
g_lua.callGlobalField("g_game","onInventoryChange", slot, item);
|
||||
m_localPlayer->setInventoryItem((Otc::Inventory)slot, item);
|
||||
}
|
||||
|
||||
void Game::processCreatureMove(const CreaturePtr& creature, const Position& oldPos, const Position& newPos)
|
||||
@@ -288,11 +289,13 @@ void Game::processCloseChannel(int channelId)
|
||||
|
||||
void Game::processVipAdd(uint id, const std::string& name, bool online)
|
||||
{
|
||||
m_vips[id] = Vip(name, online);
|
||||
g_lua.callGlobalField("g_game", "onAddVip", id, name, online);
|
||||
}
|
||||
|
||||
void Game::processVipStateChange(uint id, bool online)
|
||||
{
|
||||
std::get<1>(m_vips[id]) = online;
|
||||
g_lua.callGlobalField("g_game", "onVipStateChange", id, online);
|
||||
}
|
||||
|
||||
|
@@ -29,6 +29,8 @@
|
||||
#include <otclient/core/outfit.h>
|
||||
#include <framework/core/timer.h>
|
||||
|
||||
typedef std::tuple<std::string, bool> Vip;
|
||||
|
||||
class Game
|
||||
{
|
||||
public:
|
||||
@@ -221,6 +223,7 @@ public:
|
||||
|
||||
ContainerPtr getContainer(int index) { return m_containers[index]; }
|
||||
std::map<int, ContainerPtr> getContainers() { return m_containers; }
|
||||
std::map<int, Vip> getVips() { return m_vips; }
|
||||
CreaturePtr getAttackingCreature() { return m_attackingCreature; }
|
||||
CreaturePtr getFollowingCreature() { return m_followingCreature; }
|
||||
int getServerBeat() { return m_serverBeat; }
|
||||
@@ -238,6 +241,8 @@ private:
|
||||
CreaturePtr m_followingCreature;
|
||||
ProtocolGamePtr m_protocolGame;
|
||||
std::map<int, ContainerPtr> m_containers;
|
||||
std::map<int, Vip> m_vips;
|
||||
|
||||
bool m_dead;
|
||||
int m_serverBeat;
|
||||
Otc::FightModes m_fightMode;
|
||||
|
@@ -284,3 +284,13 @@ void LocalPlayer::setStamina(double stamina)
|
||||
callLuaField("onStaminaChange", stamina, oldStamina);
|
||||
}
|
||||
}
|
||||
|
||||
void LocalPlayer::setInventoryItem(Otc::Inventory inventory, const ItemPtr& item)
|
||||
{
|
||||
if(m_inventoryItems[inventory] != item) {
|
||||
ItemPtr oldItem = m_inventoryItems[inventory];
|
||||
m_inventoryItems[inventory] = item;
|
||||
|
||||
callLuaField("onInventoryChange", inventory, item, oldItem);
|
||||
}
|
||||
}
|
||||
|
@@ -50,6 +50,7 @@ public:
|
||||
void setSoul(double soul);
|
||||
void setStamina(double stamina);
|
||||
void setKnown(bool known) { m_known = known; }
|
||||
void setInventoryItem(Otc::Inventory inventory, const ItemPtr& item);
|
||||
|
||||
int getStates() { return m_states; }
|
||||
int getSkillLevel(Otc::Skill skill) { return m_skillsLevel[skill]; }
|
||||
@@ -66,6 +67,7 @@ public:
|
||||
double getMagicLevelPercent() { return m_magicLevelPercent; }
|
||||
double getSoul() { return m_soul; }
|
||||
double getStamina() { return m_stamina; }
|
||||
ItemPtr getInventoryItem(Otc::Inventory inventory) { return m_inventoryItems[inventory]; }
|
||||
|
||||
bool isKnown() { return m_known; }
|
||||
bool isPreWalking() { return m_preWalking; }
|
||||
@@ -92,6 +94,7 @@ private:
|
||||
bool m_walkLocked;
|
||||
Position m_lastPrewalkDestionation;
|
||||
Timer m_walkLockTimer;
|
||||
ItemPtr m_inventoryItems[Otc::LastInventory];
|
||||
|
||||
std::array<int, Otc::LastSkill> m_skillsLevel;
|
||||
std::array<int, Otc::LastSkill> m_skillsLevelPercent;
|
||||
|
@@ -151,6 +151,7 @@ void OTClient::registerLuaFunctions()
|
||||
g_lua.bindClassStaticFunction("g_game", "isFollowing", std::bind(&Game::isFollowing, &g_game));
|
||||
g_lua.bindClassStaticFunction("g_game", "getContainer", std::bind(&Game::getContainer, &g_game, std::placeholders::_1));
|
||||
g_lua.bindClassStaticFunction("g_game", "getContainers", std::bind(&Game::getContainers, &g_game));
|
||||
g_lua.bindClassStaticFunction("g_game", "getVips", std::bind(&Game::getVips, &g_game));
|
||||
g_lua.bindClassStaticFunction("g_game", "getAttackingCreature", std::bind(&Game::getAttackingCreature, &g_game));
|
||||
g_lua.bindClassStaticFunction("g_game", "getFollowingCreature", std::bind(&Game::getFollowingCreature, &g_game));
|
||||
g_lua.bindClassStaticFunction("g_game", "getServerBeat", std::bind(&Game::getServerBeat, &g_game));
|
||||
@@ -272,6 +273,7 @@ void OTClient::registerLuaFunctions()
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setSoul", &LocalPlayer::setSoul);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setStamina", &LocalPlayer::setStamina);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setKnown", &LocalPlayer::setKnown);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setInventoryItem", &LocalPlayer::setInventoryItem);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("getStates", &LocalPlayer::getStates);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("getSkillLevel", &LocalPlayer::getSkillLevel);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("getSkillLevelPercent", &LocalPlayer::getSkillLevelPercent);
|
||||
@@ -287,6 +289,7 @@ void OTClient::registerLuaFunctions()
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("getMagicLevelPercent", &LocalPlayer::getMagicLevelPercent);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("getSoul", &LocalPlayer::getSoul);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("getStamina", &LocalPlayer::getStamina);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("getInventoryItem", &LocalPlayer::getInventoryItem);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("isKnown", &LocalPlayer::isKnown);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("isPreWalking", &LocalPlayer::isPreWalking);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("asLocalPlayer", &LocalPlayer::asLocalPlayer);
|
||||
|
@@ -36,6 +36,7 @@ UIMap::UIMap()
|
||||
m_aspectRatio = 0.0f;
|
||||
m_maxZoomIn = 3;
|
||||
m_maxZoomOut = 512;
|
||||
m_mapRect.resize(1,1);
|
||||
g_map.addMapView(m_mapView);
|
||||
}
|
||||
|
||||
@@ -58,7 +59,8 @@ void UIMap::drawSelf()
|
||||
|
||||
bool UIMap::setZoom(int zoom)
|
||||
{
|
||||
//TODO
|
||||
m_zoom = std::min(std::max(zoom, m_maxZoomIn), m_maxZoomOut);
|
||||
updateVisibleDimension();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user