Implemented the mount interface, Fixed some interface stuff, Some cosmetics, and Updated the outfits window

* Added new arrow buttons.
* Fixed the vertical separator.
* Added new game_playermount module to handle player mounting.
* Moved the battle icons to /images.
* Outfit window accommodates for mounts, loads addons more efficiently and keeps addons set on update, added new Outfit.randomize function that allows you to randomize your outfit colors, and set up a new layout.
This commit is contained in:
BeniS
2012-07-15 23:49:28 +12:00
parent 3db6217b7c
commit 5520501673
39 changed files with 506 additions and 267 deletions

View File

@@ -257,7 +257,7 @@ void Game::processCreatureTeleport(const CreaturePtr& creature)
g_lua.callGlobalField("g_game", "onCreatureTeleport", creature);
}
void Game::processChannelList(const std::vector<std::tuple<int, std::string>>& channelList)
void Game::processChannelList(const std::vector<std::tuple<int, std::string> >& channelList)
{
g_lua.callGlobalField("g_game", "onChannelList", channelList);
}
@@ -324,21 +324,31 @@ void Game::processAutomapFlag(const Position& pos, int icon, const std::string&
g_lua.callGlobalField("g_game", "onAutomapFlag", pos, icon, message);
}
void Game::processOpenOutfitWindow(const Outfit& currentOufit, const std::vector<std::tuple<int, std::string, int>>& outfitList)
void Game::processOpenOutfitWindow(const Outfit& currentOufit, const std::vector<std::tuple<int, std::string, int> >& outfitList,
const std::vector<std::tuple<int, std::string> >& mountList)
{
CreaturePtr virtualCreature = CreaturePtr(new Creature);
virtualCreature->setDirection(Otc::South);
virtualCreature->setOutfit(currentOufit);
// create virtual creature outfit
CreaturePtr virtualOutfitCreature = CreaturePtr(new Creature);
virtualOutfitCreature->setDirection(Otc::South);
virtualOutfitCreature->setOutfit(currentOufit);
g_lua.callGlobalField("g_game", "onOpenOutfitWindow", virtualCreature, outfitList);
// creature virtual mount outfit
CreaturePtr virtualMountCreature = CreaturePtr(new Creature);
virtualMountCreature->setDirection(Otc::South);
Outfit mountOutfit;
mountOutfit.setId(currentOufit.getMount());
virtualMountCreature->setOutfit(mountOutfit);
g_lua.callGlobalField("g_game", "onOpenOutfitWindow", virtualOutfitCreature, outfitList, virtualMountCreature, mountList);
}
void Game::processOpenNpcTrade(const std::vector<std::tuple<ItemPtr, std::string, int, int, int>>& items)
void Game::processOpenNpcTrade(const std::vector<std::tuple<ItemPtr, std::string, int, int, int> >& items)
{
g_lua.callGlobalField("g_game", "onOpenNpcTrade", items);
}
void Game::processPlayerGoods(int money, const std::vector<std::tuple<ItemPtr, int>>& goods)
void Game::processPlayerGoods(int money, const std::vector<std::tuple<ItemPtr, int> >& goods)
{
g_lua.callGlobalField("g_game", "onPlayerGoods", money, goods);
}
@@ -373,12 +383,12 @@ void Game::processEditList(uint id, int doorId, const std::string& text)
g_lua.callGlobalField("g_game", "onEditList", id, doorId, text);
}
void Game::processQuestLog(const std::vector<std::tuple<int, std::string, bool>>& questList)
void Game::processQuestLog(const std::vector<std::tuple<int, std::string, bool> >& questList)
{
g_lua.callGlobalField("g_game", "onQuestLog", questList);
}
void Game::processQuestLine(int questId, const std::vector<std::tuple<std::string, std::string>>& questMissions)
void Game::processQuestLine(int questId, const std::vector<std::tuple<std::string, std::string> >& questMissions)
{
g_lua.callGlobalField("g_game", "onQuestLine", questId, questMissions);
}
@@ -1044,7 +1054,7 @@ void Game::mount(bool mount)
{
if(!canPerformGameAction())
return;
m_protocolGame->sendMount(mount);
m_protocolGame->sendMounted(mount);
}
bool Game::checkBotProtection()

View File

@@ -71,7 +71,7 @@ protected:
void processContainerRemoveItem(int containerId, int slot);
// channel related
void processChannelList(const std::vector<std::tuple<int, std::string>>& channelList);
void processChannelList(const std::vector<std::tuple<int, std::string> >& channelList);
void processOpenChannel(int channelId, const std::string& name);
void processOpenPrivateChannel(const std::string& name);
void processOpenOwnPrivateChannel(int channelId, const std::string& name);
@@ -92,11 +92,12 @@ protected:
void processAutomapFlag(const Position& pos, int icon, const std::string& message);
// outfit
void processOpenOutfitWindow(const Outfit& currentOufit, const std::vector<std::tuple<int, std::string, int>>& outfitList);
void processOpenOutfitWindow(const Outfit& currentOufit, const std::vector<std::tuple<int, std::string, int> >& outfitList,
const std::vector<std::tuple<int, std::string> >& mountList);
// npc trade
void processOpenNpcTrade(const std::vector<std::tuple<ItemPtr, std::string, int, int, int>>& items);
void processPlayerGoods(int money, const std::vector<std::tuple<ItemPtr, int>>& goods);
void processOpenNpcTrade(const std::vector<std::tuple<ItemPtr, std::string, int, int, int> >& items);
void processPlayerGoods(int money, const std::vector<std::tuple<ItemPtr, int> >& goods);
void processCloseNpcTrade();
// player trade
@@ -109,8 +110,8 @@ protected:
void processEditList(uint id, int doorId, const std::string& text);
// questlog
void processQuestLog(const std::vector<std::tuple<int, std::string, bool>>& questList);
void processQuestLine(int questId, const std::vector<std::tuple<std::string, std::string>>& questMissions);
void processQuestLog(const std::vector<std::tuple<int, std::string, bool> >& questList);
void processQuestLine(int questId, const std::vector<std::tuple<std::string, std::string> >& questMissions);
friend class ProtocolGame;
friend class Map;
@@ -245,6 +246,7 @@ public:
bool isDead() { return m_dead; }
bool isAttacking() { return !!m_attackingCreature; }
bool isFollowing() { return !!m_followingCreature; }
bool isMounted() { return m_mounted; }
ContainerPtr getContainer(int index) { return m_containers[index]; }
std::map<int, ContainerPtr> getContainers() { return m_containers; }
@@ -276,6 +278,7 @@ private:
bool m_denyBotCall;
bool m_dead;
bool m_mounted;
int m_serverBeat;
Otc::FightModes m_fightMode;
Otc::ChaseModes m_chaseMode;

View File

@@ -177,6 +177,7 @@ void OTClient::registerLuaFunctions()
g_lua.bindSingletonFunction("g_game", "isDead", &Game::isDead, &g_game);
g_lua.bindSingletonFunction("g_game", "isAttacking", &Game::isAttacking, &g_game);
g_lua.bindSingletonFunction("g_game", "isFollowing", &Game::isFollowing, &g_game);
g_lua.bindSingletonFunction("g_game", "isMounted", &Game::isMounted, &g_game);
g_lua.bindSingletonFunction("g_game", "getContainer", &Game::getContainer, &g_game);
g_lua.bindSingletonFunction("g_game", "getContainers", &Game::getContainers, &g_game);
g_lua.bindSingletonFunction("g_game", "getVips", &Game::getVips, &g_game);

View File

@@ -38,6 +38,10 @@ int push_luavalue(const Outfit& outfit)
g_lua.setField("legs");
g_lua.pushInteger(outfit.getFeet());
g_lua.setField("feet");
if(g_game.getFeature(Otc::GamePlayerMounts)) {
g_lua.pushInteger(outfit.getMount());
g_lua.setField("mount");
}
return 1;
}
@@ -56,6 +60,10 @@ bool luavalue_cast(int index, Outfit& outfit)
outfit.setLegs(g_lua.popInteger());
g_lua.getField("feet", index);
outfit.setFeet(g_lua.popInteger());
if(g_game.getFeature(Otc::GamePlayerMounts)) {
g_lua.getField("mount", index);
outfit.setMount(g_lua.popInteger());
}
return true;
}
return false;

View File

@@ -25,6 +25,7 @@
#include "global.h"
#include <framework/luaengine/declarations.h>
#include "game.h"
#include "outfit.h"
// outfit

View File

@@ -44,6 +44,7 @@ public:
void setLegs(int legs) { m_legs = legs; m_legsColor = getColor(legs); }
void setFeet(int feet) { m_feet = feet; m_feetColor = getColor(feet); }
void setAddons(int addons) { m_addons = addons; }
void setMount(int mount) { m_mount = mount; }
void setCategory(DatCategory category) { m_category = category; }
void resetClothes();
@@ -54,6 +55,7 @@ public:
int getLegs() const { return m_legs; }
int getFeet() const { return m_feet; }
int getAddons() const { return m_addons; }
int getMount() const { return m_mount; }
DatCategory getCategory() const { return m_category; }
Color getHeadColor() const { return m_headColor; }
@@ -63,7 +65,7 @@ public:
private:
DatCategory m_category;
int m_id, m_head, m_body, m_legs, m_feet, m_addons;
int m_id, m_head, m_body, m_legs, m_feet, m_addons, m_mount;
Color m_headColor, m_bodyColor, m_legsColor, m_feetColor;
};

View File

@@ -57,7 +57,7 @@ namespace Proto {
OsFlash = 3,
OsOtclientLinux = 10,
OsOtclientWindows = 11,
OsOtclientMac = 12,
OsOtclientMac = 12
};
#ifdef OSTYPE
@@ -177,7 +177,7 @@ namespace Proto {
GameServerMarketEnter = 246, // 944
GameServerMarketLeave = 247, // 944
GameServerMarketDetail = 248, // 944
GameServerMarketBrowse = 249, // 944
GameServerMarketBrowse = 249 // 944
};
enum ClientOpcodes {
@@ -267,7 +267,7 @@ namespace Proto {
ClientMarketBrowse = 245, // 944
ClientMarketCreate = 246, // 944
ClientMarketCancel = 247, // 944
ClientMarketAccept = 248, // 944
ClientMarketAccept = 248 // 944
};
enum ServerSpeakType {

View File

@@ -102,7 +102,7 @@ protected:
void sendRefreshContainer();
void sendRequestOutfit();
void sendChangeOutfit(const Outfit& outfit);
void sendMount(bool mount);
void sendMountStatus(bool mount);
void sendAddVip(const std::string& name);
void sendRemoveVip(uint playerId);
void sendBugReport(const std::string& comment);

View File

@@ -920,7 +920,6 @@ void ProtocolGame::parsePlayerCancelAttack(const InputMessagePtr& msg)
g_game.processAttackCancel();
}
void ProtocolGame::parseSpellDelay(const InputMessagePtr& msg)
{
msg->getU16(); // spell id
@@ -935,7 +934,6 @@ void ProtocolGame::parseSpellGroupDelay(const InputMessagePtr& msg)
msg->getU8(); // unknown
}
void ProtocolGame::parseMultiUseDelay(const InputMessagePtr& msg)
{
//TODO
@@ -991,7 +989,7 @@ void ProtocolGame::parseCreatureSpeak(const InputMessagePtr& msg)
void ProtocolGame::parseChannelList(const InputMessagePtr& msg)
{
int count = msg->getU8();
std::vector<std::tuple<int, std::string>> channelList;
std::vector<std::tuple<int, std::string> > channelList;
for(int i = 0; i < count; i++) {
int id = msg->getU16();
std::string name = msg->getString();
@@ -1130,7 +1128,8 @@ void ProtocolGame::parseOpenOutfitWindow(const InputMessagePtr& msg)
{
Outfit currentOutfit = getOutfit(msg);
std::vector<std::tuple<int, std::string, int>> outfitList;
std::vector<std::tuple<int, std::string, int> > outfitList;
std::vector<std::tuple<int, std::string> > mountList;
int outfitCount = msg->getU8();
for(int i = 0; i < outfitCount; i++) {
int outfitId = msg->getU16();
@@ -1142,13 +1141,15 @@ void ProtocolGame::parseOpenOutfitWindow(const InputMessagePtr& msg)
if(g_game.getFeature(Otc::GamePlayerMounts)) {
int mountCount = msg->getU8();
for(int i=0;i<mountCount;++i) {
msg->getU16(); // mount type
msg->getString(); // mount name
for(int i = 0; i < mountCount; ++i) {
int mountId = msg->getU16(); // mount type
std::string mountName = msg->getString(); // mount name
mountList.push_back(std::make_tuple(mountId, mountName));
}
}
g_game.processOpenOutfitWindow(currentOutfit, outfitList);
g_game.processOpenOutfitWindow(currentOutfit, outfitList, mountList);
}
void ProtocolGame::parseVipAdd(const InputMessagePtr& msg)
@@ -1188,7 +1189,7 @@ void ProtocolGame::parseAutomapFlag(const InputMessagePtr& msg)
void ProtocolGame::parseQuestLog(const InputMessagePtr& msg)
{
std::vector<std::tuple<int, std::string, bool>> questList;
std::vector<std::tuple<int, std::string, bool> > questList;
int questsCount = msg->getU16();
for(int i = 0; i < questsCount; i++) {
int id = msg->getU16();
@@ -1344,8 +1345,10 @@ Outfit ProtocolGame::getOutfit(const InputMessagePtr& msg)
}
}
if(g_game.getFeature(Otc::GamePlayerMounts))
msg->getU16(); // mount
if(g_game.getFeature(Otc::GamePlayerMounts)) {
int mount = msg->getU16(); // mount
outfit.setMount(mount);
}
return outfit;
}

View File

@@ -630,15 +630,21 @@ void ProtocolGame::sendChangeOutfit(const Outfit& outfit)
msg->addU8(outfit.getLegs());
msg->addU8(outfit.getFeet());
msg->addU8(outfit.getAddons());
if(g_game.getFeature(Otc::GamePlayerMounts))
msg->addU16(outfit.getMount());
send(msg);
}
void ProtocolGame::sendMount(bool mount)
void ProtocolGame::sendMountStatus(bool mount)
{
OutputMessagePtr msg(new OutputMessage);
msg->addU8(Proto::ClientMount);
msg->addU8(mount);
send(msg);
if(g_game.getFeature(Otc::GamePlayerMounts)) {
OutputMessagePtr msg(new OutputMessage);
msg->addU8(Proto::ClientMount);
msg->addU8(mount);
send(msg);
} else {
g_logger.error("ProtocolGame::sendMountStatus does not support the current protocol.");
}
}
void ProtocolGame::sendAddVip(const std::string& name)

View File

@@ -120,7 +120,7 @@ TilePtr UIMap::getTile(const Point& mousePos)
{
/*
* Known Issue: If you move a container widget into the map rect
* if you move an item onto itself it will allow this to execute
* and you move an item onto itself it will allow this to execute
* still dropping the item on the ground.
*/
if(!m_mapRect.contains(mousePos))