From 6293a49f8f11a796cb5167f73f6ef36b79ef58f4 Mon Sep 17 00:00:00 2001 From: BeniS Date: Fri, 20 Jul 2012 06:54:24 +1200 Subject: [PATCH] More on Market (far from done), Minor Fixes, Edited Outfits Module, Some Cosmetics. * Started building the market UI. * More work on the market functionality. * Fixes to the market protocol. (Known issue: if I use safeSend method from Market (like so: MarketProtocol.send~) is thinks it is a bot). * Fixes to the market offer class. * Outfit window will no longer display the mount box if you are using protocol < 870. * Added getFeature to playermount module. * Added isMarketable and getMarketData to the lua binding. * Added lua casts for MarketData. * Fixed typo in the module manager. * Added new 'light flat panel' for more variation (can change later) will require some graphics for market. * Added new functions to table lib. * Fixed some styling issues from previous commits. --- .../client_modulemanager/modulemanager.lua | 2 +- modules/client_options/options.lua | 1 + .../skins/default/images/panel_lightflat.png | Bin 0 -> 2851 bytes .../skins/default/styles/panels.otui | 4 + modules/corelib/table.lua | 14 +- modules/game_interface/styles/exitwindow.otui | 4 +- .../game_interface/styles/logoutwindow.otui | 2 +- modules/game_market/market.lua | 257 ++++++++++++++++-- modules/game_market/market.otui | 39 ++- modules/game_market/marketoffer.lua | 21 +- modules/game_market/marketprotocol.lua | 69 ++++- .../game_market/ui/general/marketbuttons.otui | 20 ++ .../game_market/ui/general/markettabs.otui | 33 +++ modules/game_market/ui/marketoffers.otui | 49 ++++ .../game_market/ui/marketoffers/browse.otui | 125 +++++++++ .../ui/marketoffers/itemdetails.otui | 10 + .../ui/marketoffers/itemoffers.otui | 10 + .../ui/marketoffers/itemstats.otui | 10 + .../game_market/ui/marketoffers/search.otui | 9 + modules/game_market/ui/myoffers.otui | 16 ++ .../ui/myoffers/currentoffers.otui | 9 + .../game_market/ui/myoffers/itemoffers.otui | 9 + .../game_market/ui/myoffers/offerhistory.otui | 9 + modules/game_outfit/outfit.lua | 41 ++- modules/game_outfit/outfitwindow.otui | 8 +- modules/game_playermount/playermount.lua | 8 +- modules/gamelib/market.lua | 7 +- src/otclient/game.cpp | 2 +- src/otclient/luafunctions.cpp | 4 + src/otclient/luavaluecasts.cpp | 38 +++ src/otclient/luavaluecasts.h | 4 + src/otclient/thing.h | 2 + src/otclient/thingtypedat.h | 1 + src/otclient/thingtypemanager.h | 4 +- 34 files changed, 743 insertions(+), 98 deletions(-) create mode 100644 modules/client_skins/skins/default/images/panel_lightflat.png create mode 100644 modules/game_market/ui/general/marketbuttons.otui create mode 100644 modules/game_market/ui/general/markettabs.otui create mode 100644 modules/game_market/ui/marketoffers.otui create mode 100644 modules/game_market/ui/marketoffers/browse.otui create mode 100644 modules/game_market/ui/marketoffers/itemdetails.otui create mode 100644 modules/game_market/ui/marketoffers/itemoffers.otui create mode 100644 modules/game_market/ui/marketoffers/itemstats.otui create mode 100644 modules/game_market/ui/marketoffers/search.otui create mode 100644 modules/game_market/ui/myoffers.otui create mode 100644 modules/game_market/ui/myoffers/currentoffers.otui create mode 100644 modules/game_market/ui/myoffers/itemoffers.otui create mode 100644 modules/game_market/ui/myoffers/offerhistory.otui diff --git a/modules/client_modulemanager/modulemanager.lua b/modules/client_modulemanager/modulemanager.lua index 3deb4098..4fab7c63 100644 --- a/modules/client_modulemanager/modulemanager.lua +++ b/modules/client_modulemanager/modulemanager.lua @@ -146,7 +146,7 @@ function ModuleManager.unloadCurrentModule() end function ModuleManager.reloadAllModules() - g_modules.g_modules.reloadModules() + g_modules.reloadModules() ModuleManager.refreshLoadedModules() ModuleManager.show() end diff --git a/modules/client_options/options.lua b/modules/client_options/options.lua index ebbd115a..9283c0e1 100644 --- a/modules/client_options/options.lua +++ b/modules/client_options/options.lua @@ -74,6 +74,7 @@ function Options.init() optionsWindow = g_ui.displayUI('options.otui') optionsWindow:hide() optionsButton = TopMenu.addLeftButton('optionsButton', tr('Options') .. ' (Ctrl+D)', 'options.png', Options.toggle) + optionsTabBar = optionsWindow:getChildById('optionsTabBar') optionsTabBar:setContentWidget(optionsWindow:getChildById('optionsTabContent')) diff --git a/modules/client_skins/skins/default/images/panel_lightflat.png b/modules/client_skins/skins/default/images/panel_lightflat.png new file mode 100644 index 0000000000000000000000000000000000000000..b98810aba7b665074c5a3a33068777b74accd373 GIT binary patch literal 2851 zcmV+;3*7XHP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQ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W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0000^Nkl("isHookSouth", &Thing::isHookSouth); g_lua.bindClassMemberFunction("isTranslucent", &Thing::isTranslucent); g_lua.bindClassMemberFunction("isFullGround", &Thing::isFullGround); + g_lua.bindClassMemberFunction("isMarketable", &Thing::isMarketable); g_lua.bindClassMemberFunction("getParentContainer", &Thing::getParentContainer); + g_lua.bindClassMemberFunction("getMarketData", &Thing::getMarketData); g_lua.registerClass(); g_lua.bindClassStaticFunction("create", []{ return HousePtr(new House); }); @@ -334,6 +336,8 @@ void OTClient::registerLuaFunctions() g_lua.bindClassMemberFunction("getCount", &Item::getCount); g_lua.bindClassMemberFunction("getId", &Item::getId); g_lua.bindClassMemberFunction("isStackable", &Item::isStackable); + g_lua.bindClassMemberFunction("isMarketable", &Item::isMarketable); + g_lua.bindClassMemberFunction("getMarketData", &Item::isMarketable); g_lua.registerClass(); g_lua.registerClass(); diff --git a/src/otclient/luavaluecasts.cpp b/src/otclient/luavaluecasts.cpp index ef4052a7..16f91fb2 100644 --- a/src/otclient/luavaluecasts.cpp +++ b/src/otclient/luavaluecasts.cpp @@ -97,3 +97,41 @@ bool luavalue_cast(int index, Position& pos) } return false; } + +int push_luavalue(const MarketData& data) +{ + g_lua.newTable(); + g_lua.pushInteger(data.category); + g_lua.setField("category"); + g_lua.pushString(data.name); + g_lua.setField("name"); + g_lua.pushInteger(data.requiredLevel); + g_lua.setField("requiredLevel"); + g_lua.pushInteger(data.restrictProfession); + g_lua.setField("restrictProfession"); + g_lua.pushInteger(data.showAs); + g_lua.setField("showAs"); + g_lua.pushInteger(data.tradeAs); + g_lua.setField("tradeAs"); + return 1; +} + +bool luavalue_cast(int index, MarketData& data) +{ + if(g_lua.isTable(index)) { + g_lua.getField("category", index); + data.category = g_lua.popInteger(); + g_lua.getField("name", index); + data.name = g_lua.popString(); + g_lua.getField("requiredLevel", index); + data.requiredLevel = g_lua.popInteger(); + g_lua.getField("restrictProfession", index); + data.restrictProfession = g_lua.popInteger(); + g_lua.getField("showAs", index); + data.showAs = g_lua.popInteger(); + g_lua.getField("tradeAs", index); + data.tradeAs = g_lua.popInteger(); + return true; + } + return false; +} diff --git a/src/otclient/luavaluecasts.h b/src/otclient/luavaluecasts.h index fc9fce66..38b4b01d 100644 --- a/src/otclient/luavaluecasts.h +++ b/src/otclient/luavaluecasts.h @@ -36,4 +36,8 @@ bool luavalue_cast(int index, Outfit& outfit); int push_luavalue(const Position& pos); bool luavalue_cast(int index, Position& pos); +// market +int push_luavalue(const MarketData& data); +bool luavalue_cast(int index, MarketData& data); + #endif diff --git a/src/otclient/thing.h b/src/otclient/thing.h index 4fb1dcc7..4fbe369a 100644 --- a/src/otclient/thing.h +++ b/src/otclient/thing.h @@ -128,8 +128,10 @@ public: bool isFullGround() { return rawGetDatType()->isFullGround(); } bool isIgnoreLook() { return rawGetDatType()->isIgnoreLook(); } bool isCloth() { return rawGetDatType()->isCloth(); } + bool isMarketable() { return rawGetDatType()->isMarketable(); } MarketData getMarketData() { return rawGetDatType()->getMarketData(); } + protected: Position m_position; uint16 m_datId; diff --git a/src/otclient/thingtypedat.h b/src/otclient/thingtypedat.h index 6ea268a9..c308a5fd 100644 --- a/src/otclient/thingtypedat.h +++ b/src/otclient/thingtypedat.h @@ -172,6 +172,7 @@ public: bool isFullGround() { return m_attribs.has(DatAttribFullGround); } bool isIgnoreLook() { return m_attribs.has(DatAttribIgnoreLook); } bool isCloth() { return m_attribs.has(DatAttribCloth); } + bool isMarketable() { return m_attribs.has(DatAttribMarket); } private: const TexturePtr& getTexture(int animationPhase); diff --git a/src/otclient/thingtypemanager.h b/src/otclient/thingtypemanager.h index b0879661..a9f72626 100644 --- a/src/otclient/thingtypemanager.h +++ b/src/otclient/thingtypemanager.h @@ -48,8 +48,8 @@ public: const ThingTypeDatPtr& getDatType(uint16 id, DatCategory category); const ThingTypeOtbPtr& getOtbType(uint16 id); - ThingTypeDat *rawGetDatType(uint16 id, DatCategory category) { return m_datTypes[category][id].get(); } - ThingTypeOtb *rawGetOtbType(uint16 id) { return m_otbTypes[id].get(); } + ThingTypeDat* rawGetDatType(uint16 id, DatCategory category) { return m_datTypes[category][id].get(); } + ThingTypeOtb* rawGetOtbType(uint16 id) { return m_otbTypes[id].get(); } uint32 getDatSignature() { return m_datSignature; } uint32 getOtbMajorVersion() { return m_otbMajorVersion; }