diff --git a/data/fonts/small-9px.otfont b/data/fonts/small-9px.otfont new file mode 100644 index 0000000..12c83bf --- /dev/null +++ b/data/fonts/small-9px.otfont @@ -0,0 +1,7 @@ +Font + name: small-9px + texture: small-9px + height: 9 + glyph-size: 9 9 + space-width: 3 + spacing: 1 0 diff --git a/data/fonts/small-9px.png b/data/fonts/small-9px.png new file mode 100644 index 0000000..37643a1 Binary files /dev/null and b/data/fonts/small-9px.png differ diff --git a/data/fonts/verdana-9px-bold.otfont b/data/fonts/verdana-9px-bold.otfont new file mode 100644 index 0000000..beaf9ba --- /dev/null +++ b/data/fonts/verdana-9px-bold.otfont @@ -0,0 +1,8 @@ +Font + name: verdana-9px-bold + texture: verdana-9px-bold + height: 12 + glyph-size: 13 13 + space-width: 4 + spacing: 0 0 + diff --git a/data/fonts/verdana-9px-bold.png b/data/fonts/verdana-9px-bold.png new file mode 100644 index 0000000..51ccd06 Binary files /dev/null and b/data/fonts/verdana-9px-bold.png differ diff --git a/data/fonts/verdana-9px-italic.otfont b/data/fonts/verdana-9px-italic.otfont new file mode 100644 index 0000000..5e32e32 --- /dev/null +++ b/data/fonts/verdana-9px-italic.otfont @@ -0,0 +1,6 @@ +Font + name: verdana-9px-italic + texture: verdana-9px-italic + height: 12 + glyph-size: 13 13 + space-width: 3 diff --git a/data/fonts/verdana-9px-italic.png b/data/fonts/verdana-9px-italic.png new file mode 100644 index 0000000..b3646e1 Binary files /dev/null and b/data/fonts/verdana-9px-italic.png differ diff --git a/data/fonts/verdana-9px.otfont b/data/fonts/verdana-9px.otfont new file mode 100644 index 0000000..f899759 --- /dev/null +++ b/data/fonts/verdana-9px.otfont @@ -0,0 +1,7 @@ +Font + name: verdana-9px + texture: verdana-9px + height: 13 + glyph-size: 13 13 + space-width: 3 + spacing: 0 -4 diff --git a/data/fonts/verdana-9px.png b/data/fonts/verdana-9px.png new file mode 100644 index 0000000..9f566ce Binary files /dev/null and b/data/fonts/verdana-9px.png differ diff --git a/data/styles/10-creaturebuttons.otui b/data/styles/10-creaturebuttons.otui index 4bcdfb9..d96356c 100644 --- a/data/styles/10-creaturebuttons.otui +++ b/data/styles/10-creaturebuttons.otui @@ -4,14 +4,14 @@ CreatureButton < UICreatureButton UICreature id: creature - size: 20 20 + size: 22 22 anchors.left: parent.left anchors.top: parent.top phantom: true UIWidget id: spacer - width: 5 + width: 3 anchors.left: creature.right anchors.top: creature.top phantom: true diff --git a/data/styles/20-smallscrollbar.otui b/data/styles/20-smallscrollbar.otui new file mode 100644 index 0000000..8327973 --- /dev/null +++ b/data/styles/20-smallscrollbar.otui @@ -0,0 +1,60 @@ +SmallScrollBar < UIScrollBar + orientation: vertical + margin-bottom: 1 + step: 20 + width: 8 + image-source: /images/ui/scrollbar + image-clip: 39 0 13 65 + image-border: 1 + pixels-scroll: true + + UIButton + id: decrementButton + anchors.top: parent.top + anchors.left: parent.left + image-source: /images/ui/scrollbar + image-clip: 0 0 13 13 + image-color: #ffffffff + size: 8 8 + $hover: + image-clip: 13 0 13 13 + $pressed: + image-clip: 26 0 13 13 + $disabled: + image-color: #ffffff66 + + UIButton + id: incrementButton + anchors.bottom: parent.bottom + anchors.right: parent.right + size: 8 8 + image-source: /images/ui/scrollbar + image-clip: 0 13 13 13 + image-color: #ffffffff + $hover: + image-clip: 13 13 13 13 + $pressed: + image-clip: 26 13 13 13 + $disabled: + image-color: #ffffff66 + + UIButton + id: sliderButton + anchors.centerIn: parent + size: 8 11 + image-source: /images/ui/scrollbar + image-clip: 0 26 13 13 + image-border: 2 + image-color: #ffffffff + $hover: + image-clip: 13 26 13 13 + $pressed: + image-clip: 26 26 13 13 + $disabled: + image-color: #ffffff66 + + Label + id: valueLabel + anchors.fill: parent + color: white + text-align: center \ No newline at end of file diff --git a/init.lua b/init.lua index fc5659c..0e1492e 100644 --- a/init.lua +++ b/init.lua @@ -6,7 +6,6 @@ APP_VERSION = 1337 -- client version for updater and login to identify outd Services = { website = "http://otclient.ovh", -- currently not used updater = "", - news = "http://otclient.ovh/api/news.php", stats = "", crash = "http://otclient.ovh/api/crash.php", feedback = "http://otclient.ovh/api/feedback.php" diff --git a/lua_functions/luafunctions_client.cpp b/lua_functions/luafunctions_client.cpp new file mode 100644 index 0000000..9c7db72 --- /dev/null +++ b/lua_functions/luafunctions_client.cpp @@ -0,0 +1,878 @@ +/* + * Copyright (c) 2010-2017 OTClient + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "client.h" +#include "luavaluecasts.h" +#include "game.h" +#include "tile.h" +#include "houses.h" +#include "towns.h" +#include "container.h" +#include "item.h" +#include "effect.h" +#include "missile.h" +#include "statictext.h" +#include "animatedtext.h" +#include "creature.h" +#include "player.h" +#include "localplayer.h" +#include "map.h" +#include "minimap.h" +#include "thingtypemanager.h" +#include "spritemanager.h" +#include "shadermanager.h" +#include "protocolgame.h" +#include "uiitem.h" +#include "uicreature.h" +#include "uimap.h" +#include "uiminimap.h" +#include "uimapanchorlayout.h" +#include "uiprogressrect.h" +#include "uisprite.h" +#include "outfit.h" + +#include + +void Client::registerLuaFunctions() +{ + g_lua.registerSingletonClass("g_things"); + g_lua.bindSingletonFunction("g_things", "loadDat", &ThingTypeManager::loadDat, &g_things); +#ifdef WITH_ENCRYPTION + g_lua.bindSingletonFunction("g_things", "saveDat", &ThingTypeManager::saveDat, &g_things); + g_lua.bindSingletonFunction("g_things", "dumpTextures", &ThingTypeManager::dumpTextures, &g_things); + g_lua.bindSingletonFunction("g_things", "replaceTextures", &ThingTypeManager::replaceTextures, &g_things); +#endif + g_lua.bindSingletonFunction("g_things", "loadOtb", &ThingTypeManager::loadOtb, &g_things); + g_lua.bindSingletonFunction("g_things", "loadXml", &ThingTypeManager::loadXml, &g_things); + g_lua.bindSingletonFunction("g_things", "loadOtml", &ThingTypeManager::loadOtml, &g_things); + g_lua.bindSingletonFunction("g_things", "isDatLoaded", &ThingTypeManager::isDatLoaded, &g_things); + g_lua.bindSingletonFunction("g_things", "isOtbLoaded", &ThingTypeManager::isOtbLoaded, &g_things); + g_lua.bindSingletonFunction("g_things", "getDatSignature", &ThingTypeManager::getDatSignature, &g_things); + g_lua.bindSingletonFunction("g_things", "getContentRevision", &ThingTypeManager::getContentRevision, &g_things); + g_lua.bindSingletonFunction("g_things", "getThingType", &ThingTypeManager::getThingType, &g_things); + g_lua.bindSingletonFunction("g_things", "getItemType", &ThingTypeManager::getItemType, &g_things); + g_lua.bindSingletonFunction("g_things", "getThingTypes", &ThingTypeManager::getThingTypes, &g_things); + g_lua.bindSingletonFunction("g_things", "findItemTypeByClientId", &ThingTypeManager::findItemTypeByClientId, &g_things); + g_lua.bindSingletonFunction("g_things", "findItemTypeByName", &ThingTypeManager::findItemTypeByName, &g_things); + g_lua.bindSingletonFunction("g_things", "findItemTypesByName", &ThingTypeManager::findItemTypesByName, &g_things); + g_lua.bindSingletonFunction("g_things", "findItemTypesByString", &ThingTypeManager::findItemTypesByString, &g_things); + g_lua.bindSingletonFunction("g_things", "findItemTypeByCategory", &ThingTypeManager::findItemTypeByCategory, &g_things); + g_lua.bindSingletonFunction("g_things", "findThingTypeByAttr", &ThingTypeManager::findThingTypeByAttr, &g_things); + + g_lua.registerSingletonClass("g_houses"); + g_lua.bindSingletonFunction("g_houses", "clear", &HouseManager::clear, &g_houses); + g_lua.bindSingletonFunction("g_houses", "load", &HouseManager::load, &g_houses); + g_lua.bindSingletonFunction("g_houses", "save", &HouseManager::save, &g_houses); + g_lua.bindSingletonFunction("g_houses", "getHouse", &HouseManager::getHouse, &g_houses); + g_lua.bindSingletonFunction("g_houses", "getHouseByName", &HouseManager::getHouseByName, &g_houses); + g_lua.bindSingletonFunction("g_houses", "addHouse", &HouseManager::addHouse, &g_houses); + g_lua.bindSingletonFunction("g_houses", "removeHouse", &HouseManager::removeHouse, &g_houses); + g_lua.bindSingletonFunction("g_houses", "getHouseList", &HouseManager::getHouseList, &g_houses); + g_lua.bindSingletonFunction("g_houses", "filterHouses", &HouseManager::filterHouses, &g_houses); + g_lua.bindSingletonFunction("g_houses", "sort", &HouseManager::sort, &g_houses); + + g_lua.registerSingletonClass("g_towns"); + g_lua.bindSingletonFunction("g_towns", "getTown", &TownManager::getTown, &g_towns); + g_lua.bindSingletonFunction("g_towns", "getTownByName",&TownManager::getTownByName,&g_towns); + g_lua.bindSingletonFunction("g_towns", "addTown", &TownManager::addTown, &g_towns); + g_lua.bindSingletonFunction("g_towns", "removeTown", &TownManager::removeTown, &g_towns); + g_lua.bindSingletonFunction("g_towns", "getTowns", &TownManager::getTowns, &g_towns); + g_lua.bindSingletonFunction("g_towns", "sort", &TownManager::sort, &g_towns); + + g_lua.registerSingletonClass("g_sprites"); + g_lua.bindSingletonFunction("g_sprites", "loadSpr", &SpriteManager::loadSpr, &g_sprites); +#ifdef WITH_ENCRYPTION + g_lua.bindSingletonFunction("g_sprites", "saveSpr", &SpriteManager::saveSpr, &g_sprites); + g_lua.bindSingletonFunction("g_sprites", "dumpSprites", &SpriteManager::dumpSprites, &g_sprites); +#endif + g_lua.bindSingletonFunction("g_sprites", "unload", &SpriteManager::unload, &g_sprites); + g_lua.bindSingletonFunction("g_sprites", "isLoaded", &SpriteManager::isLoaded, &g_sprites); + g_lua.bindSingletonFunction("g_sprites", "getSprSignature", &SpriteManager::getSignature, &g_sprites); + g_lua.bindSingletonFunction("g_sprites", "getSpritesCount", &SpriteManager::getSpritesCount, &g_sprites); + + g_lua.registerSingletonClass("g_map"); + g_lua.bindSingletonFunction("g_map", "isLookPossible", &Map::isLookPossible, &g_map); + g_lua.bindSingletonFunction("g_map", "isCovered", &Map::isCovered, &g_map); + g_lua.bindSingletonFunction("g_map", "isCompletelyCovered", &Map::isCompletelyCovered, &g_map); + g_lua.bindSingletonFunction("g_map", "addThing", &Map::addThing, &g_map); + g_lua.bindSingletonFunction("g_map", "getThing", &Map::getThing, &g_map); + g_lua.bindSingletonFunction("g_map", "removeThingByPos", &Map::removeThingByPos, &g_map); + g_lua.bindSingletonFunction("g_map", "removeThing", &Map::removeThing, &g_map); + g_lua.bindSingletonFunction("g_map", "colorizeThing", &Map::colorizeThing, &g_map); + g_lua.bindSingletonFunction("g_map", "removeThingColor", &Map::removeThingColor, &g_map); + g_lua.bindSingletonFunction("g_map", "clean", &Map::clean, &g_map); + g_lua.bindSingletonFunction("g_map", "cleanTile", &Map::cleanTile, &g_map); + g_lua.bindSingletonFunction("g_map", "cleanTexts", &Map::cleanTexts, &g_map); + g_lua.bindSingletonFunction("g_map", "getTile", &Map::getTile, &g_map); + g_lua.bindSingletonFunction("g_map", "getOrCreateTile", &Map::getOrCreateTile, &g_map); + g_lua.bindSingletonFunction("g_map", "getTiles", &Map::getTiles, &g_map); + g_lua.bindSingletonFunction("g_map", "setCentralPosition", &Map::setCentralPosition, &g_map); + g_lua.bindSingletonFunction("g_map", "getCentralPosition", &Map::getCentralPosition, &g_map); + g_lua.bindSingletonFunction("g_map", "getCreatureById", &Map::getCreatureById, &g_map); + g_lua.bindSingletonFunction("g_map", "removeCreatureById", &Map::removeCreatureById, &g_map); + g_lua.bindSingletonFunction("g_map", "getSpectators", &Map::getSpectators, &g_map); + g_lua.bindSingletonFunction("g_map", "getSpectatorsInRange", &Map::getSpectatorsInRange, &g_map); + g_lua.bindSingletonFunction("g_map", "getSpectatorsInRangeEx", &Map::getSpectatorsInRangeEx, &g_map); + g_lua.bindSingletonFunction("g_map", "findPath", &Map::findPath, &g_map); + g_lua.bindSingletonFunction("g_map", "loadOtbm", &Map::loadOtbm, &g_map); + g_lua.bindSingletonFunction("g_map", "saveOtbm", &Map::saveOtbm, &g_map); + g_lua.bindSingletonFunction("g_map", "loadOtcm", &Map::loadOtcm, &g_map); + g_lua.bindSingletonFunction("g_map", "saveOtcm", &Map::saveOtcm, &g_map); + g_lua.bindSingletonFunction("g_map", "getHouseFile", &Map::getHouseFile, &g_map); + g_lua.bindSingletonFunction("g_map", "setHouseFile", &Map::setHouseFile, &g_map); + g_lua.bindSingletonFunction("g_map", "getSpawnFile", &Map::getSpawnFile, &g_map); + g_lua.bindSingletonFunction("g_map", "setSpawnFile", &Map::setSpawnFile, &g_map); + g_lua.bindSingletonFunction("g_map", "createTile", &Map::createTile, &g_map); + g_lua.bindSingletonFunction("g_map", "setWidth", &Map::setWidth, &g_map); + g_lua.bindSingletonFunction("g_map", "setHeight", &Map::setHeight, &g_map); + g_lua.bindSingletonFunction("g_map", "getSize", &Map::getSize, &g_map); + g_lua.bindSingletonFunction("g_map", "setDescription", &Map::setDescription, &g_map); + g_lua.bindSingletonFunction("g_map", "getDescriptions", &Map::getDescriptions, &g_map); + g_lua.bindSingletonFunction("g_map", "clearDescriptions", &Map::clearDescriptions, &g_map); + g_lua.bindSingletonFunction("g_map", "setShowZone", &Map::setShowZone, &g_map); + g_lua.bindSingletonFunction("g_map", "setShowZones", &Map::setShowZones, &g_map); + g_lua.bindSingletonFunction("g_map", "setZoneColor", &Map::setZoneColor, &g_map); + g_lua.bindSingletonFunction("g_map", "setZoneOpacity", &Map::setZoneOpacity, &g_map); + g_lua.bindSingletonFunction("g_map", "getZoneOpacity", &Map::getZoneOpacity, &g_map); + g_lua.bindSingletonFunction("g_map", "getZoneColor", &Map::getZoneColor, &g_map); + g_lua.bindSingletonFunction("g_map", "showZones", &Map::showZones, &g_map); + g_lua.bindSingletonFunction("g_map", "showZone", &Map::showZone, &g_map); + g_lua.bindSingletonFunction("g_map", "setForceShowAnimations", &Map::setForceShowAnimations, &g_map); + g_lua.bindSingletonFunction("g_map", "isForcingAnimations", &Map::isForcingAnimations, &g_map); + g_lua.bindSingletonFunction("g_map", "isShowingAnimations", &Map::isShowingAnimations, &g_map); + g_lua.bindSingletonFunction("g_map", "setShowAnimations", &Map::setShowAnimations, &g_map); + g_lua.bindSingletonFunction("g_map", "beginGhostMode", &Map::beginGhostMode, &g_map); + g_lua.bindSingletonFunction("g_map", "endGhostMode", &Map::endGhostMode, &g_map); + g_lua.bindSingletonFunction("g_map", "findItemsById", &Map::findItemsById, &g_map); + g_lua.bindSingletonFunction("g_map", "getAwareRange", &Map::getAwareRangeAsSize, &g_map); + g_lua.bindSingletonFunction("g_map", "findEveryPath", &Map::findEveryPath, &g_map); + + g_lua.registerSingletonClass("g_minimap"); + g_lua.bindSingletonFunction("g_minimap", "clean", &Minimap::clean, &g_minimap); + g_lua.bindSingletonFunction("g_minimap", "loadImage", &Minimap::loadImage, &g_minimap); + g_lua.bindSingletonFunction("g_minimap", "saveImage", &Minimap::saveImage, &g_minimap); + g_lua.bindSingletonFunction("g_minimap", "loadOtmm", &Minimap::loadOtmm, &g_minimap); + g_lua.bindSingletonFunction("g_minimap", "saveOtmm", &Minimap::saveOtmm, &g_minimap); + + g_lua.registerSingletonClass("g_creatures"); + g_lua.bindSingletonFunction("g_creatures", "getCreatures", &CreatureManager::getCreatures, &g_creatures); + g_lua.bindSingletonFunction("g_creatures", "getCreatureByName", &CreatureManager::getCreatureByName, &g_creatures); + g_lua.bindSingletonFunction("g_creatures", "getCreatureByLook", &CreatureManager::getCreatureByLook, &g_creatures); + g_lua.bindSingletonFunction("g_creatures", "getSpawn", &CreatureManager::getSpawn, &g_creatures); + g_lua.bindSingletonFunction("g_creatures", "getSpawnForPlacePos", &CreatureManager::getSpawnForPlacePos, &g_creatures); + g_lua.bindSingletonFunction("g_creatures", "addSpawn", &CreatureManager::addSpawn, &g_creatures); + g_lua.bindSingletonFunction("g_creatures", "loadMonsters", &CreatureManager::loadMonsters, &g_creatures); + g_lua.bindSingletonFunction("g_creatures", "loadNpcs", &CreatureManager::loadNpcs, &g_creatures); + g_lua.bindSingletonFunction("g_creatures", "loadSingleCreature", &CreatureManager::loadSingleCreature, &g_creatures); + g_lua.bindSingletonFunction("g_creatures", "loadSpawns", &CreatureManager::loadSpawns, &g_creatures); + g_lua.bindSingletonFunction("g_creatures", "saveSpawns", &CreatureManager::saveSpawns, &g_creatures); + g_lua.bindSingletonFunction("g_creatures", "isLoaded", &CreatureManager::isLoaded, &g_creatures); + g_lua.bindSingletonFunction("g_creatures", "isSpawnLoaded", &CreatureManager::isSpawnLoaded, &g_creatures); + g_lua.bindSingletonFunction("g_creatures", "clear", &CreatureManager::clear, &g_creatures); + g_lua.bindSingletonFunction("g_creatures", "clearSpawns", &CreatureManager::clearSpawns, &g_creatures); + g_lua.bindSingletonFunction("g_creatures", "getSpawns", &CreatureManager::getSpawns, &g_creatures); + g_lua.bindSingletonFunction("g_creatures", "deleteSpawn", &CreatureManager::deleteSpawn, &g_creatures); + + g_lua.registerSingletonClass("g_game"); + g_lua.bindSingletonFunction("g_game", "loginWorld", &Game::loginWorld, &g_game); + g_lua.bindSingletonFunction("g_game", "cancelLogin", &Game::cancelLogin, &g_game); + g_lua.bindSingletonFunction("g_game", "forceLogout", &Game::forceLogout, &g_game); + g_lua.bindSingletonFunction("g_game", "safeLogout", &Game::safeLogout, &g_game); + g_lua.bindSingletonFunction("g_game", "walk", &Game::walk, &g_game); + g_lua.bindSingletonFunction("g_game", "autoWalk", &Game::autoWalk, &g_game); + g_lua.bindSingletonFunction("g_game", "turn", &Game::turn, &g_game); + g_lua.bindSingletonFunction("g_game", "stop", &Game::stop, &g_game); + g_lua.bindSingletonFunction("g_game", "look", &Game::look, &g_game); + g_lua.bindSingletonFunction("g_game", "move", &Game::move, &g_game); + g_lua.bindSingletonFunction("g_game", "moveRaw", &Game::moveRaw, &g_game); + g_lua.bindSingletonFunction("g_game", "moveToParentContainer", &Game::moveToParentContainer, &g_game); + g_lua.bindSingletonFunction("g_game", "rotate", &Game::rotate, &g_game); + g_lua.bindSingletonFunction("g_game", "use", &Game::use, &g_game); + g_lua.bindSingletonFunction("g_game", "useWith", &Game::useWith, &g_game); + g_lua.bindSingletonFunction("g_game", "useInventoryItem", &Game::useInventoryItem, &g_game); + g_lua.bindSingletonFunction("g_game", "useInventoryItemWith", &Game::useInventoryItemWith, &g_game); + g_lua.bindSingletonFunction("g_game", "findItemInContainers", &Game::findItemInContainers, &g_game); + g_lua.bindSingletonFunction("g_game", "open", &Game::open, &g_game); + g_lua.bindSingletonFunction("g_game", "openParent", &Game::openParent, &g_game); + g_lua.bindSingletonFunction("g_game", "close", &Game::close, &g_game); + g_lua.bindSingletonFunction("g_game", "refreshContainer", &Game::refreshContainer, &g_game); + g_lua.bindSingletonFunction("g_game", "attack", &Game::attack, &g_game); + g_lua.bindSingletonFunction("g_game", "cancelAttack", &Game::cancelAttack, &g_game); + g_lua.bindSingletonFunction("g_game", "follow", &Game::follow, &g_game); + g_lua.bindSingletonFunction("g_game", "cancelFollow", &Game::cancelFollow, &g_game); + g_lua.bindSingletonFunction("g_game", "cancelAttackAndFollow", &Game::cancelAttackAndFollow, &g_game); + g_lua.bindSingletonFunction("g_game", "talk", &Game::talk, &g_game); + g_lua.bindSingletonFunction("g_game", "talkChannel", &Game::talkChannel, &g_game); + g_lua.bindSingletonFunction("g_game", "talkPrivate", &Game::talkPrivate, &g_game); + g_lua.bindSingletonFunction("g_game", "openPrivateChannel", &Game::openPrivateChannel, &g_game); + g_lua.bindSingletonFunction("g_game", "requestChannels", &Game::requestChannels, &g_game); + g_lua.bindSingletonFunction("g_game", "joinChannel", &Game::joinChannel, &g_game); + g_lua.bindSingletonFunction("g_game", "leaveChannel", &Game::leaveChannel, &g_game); + g_lua.bindSingletonFunction("g_game", "closeNpcChannel", &Game::closeNpcChannel, &g_game); + g_lua.bindSingletonFunction("g_game", "openOwnChannel", &Game::openOwnChannel, &g_game); + g_lua.bindSingletonFunction("g_game", "inviteToOwnChannel", &Game::inviteToOwnChannel, &g_game); + g_lua.bindSingletonFunction("g_game", "excludeFromOwnChannel", &Game::excludeFromOwnChannel, &g_game); + g_lua.bindSingletonFunction("g_game", "partyInvite", &Game::partyInvite, &g_game); + g_lua.bindSingletonFunction("g_game", "partyJoin", &Game::partyJoin, &g_game); + g_lua.bindSingletonFunction("g_game", "partyRevokeInvitation", &Game::partyRevokeInvitation, &g_game); + g_lua.bindSingletonFunction("g_game", "partyPassLeadership", &Game::partyPassLeadership, &g_game); + g_lua.bindSingletonFunction("g_game", "partyLeave", &Game::partyLeave, &g_game); + g_lua.bindSingletonFunction("g_game", "partyShareExperience", &Game::partyShareExperience, &g_game); + g_lua.bindSingletonFunction("g_game", "requestOutfit", &Game::requestOutfit, &g_game); + g_lua.bindSingletonFunction("g_game", "changeOutfit", &Game::changeOutfit, &g_game); + g_lua.bindSingletonFunction("g_game", "addVip", &Game::addVip, &g_game); + g_lua.bindSingletonFunction("g_game", "removeVip", &Game::removeVip, &g_game); + g_lua.bindSingletonFunction("g_game", "editVip", &Game::editVip, &g_game); + g_lua.bindSingletonFunction("g_game", "setChaseMode", &Game::setChaseMode, &g_game); + g_lua.bindSingletonFunction("g_game", "setFightMode", &Game::setFightMode, &g_game); + g_lua.bindSingletonFunction("g_game", "setPVPMode", &Game::setPVPMode, &g_game); + g_lua.bindSingletonFunction("g_game", "setSafeFight", &Game::setSafeFight, &g_game); + g_lua.bindSingletonFunction("g_game", "getChaseMode", &Game::getChaseMode, &g_game); + g_lua.bindSingletonFunction("g_game", "getFightMode", &Game::getFightMode, &g_game); + g_lua.bindSingletonFunction("g_game", "getPVPMode", &Game::getPVPMode, &g_game); + g_lua.bindSingletonFunction("g_game", "getUnjustifiedPoints", &Game::getUnjustifiedPoints, &g_game); + g_lua.bindSingletonFunction("g_game", "getOpenPvpSituations", &Game::getOpenPvpSituations, &g_game); + g_lua.bindSingletonFunction("g_game", "isSafeFight", &Game::isSafeFight, &g_game); + g_lua.bindSingletonFunction("g_game", "inspectNpcTrade", &Game::inspectNpcTrade, &g_game); + g_lua.bindSingletonFunction("g_game", "buyItem", &Game::buyItem, &g_game); + g_lua.bindSingletonFunction("g_game", "sellItem", &Game::sellItem, &g_game); + g_lua.bindSingletonFunction("g_game", "closeNpcTrade", &Game::closeNpcTrade, &g_game); + g_lua.bindSingletonFunction("g_game", "requestTrade", &Game::requestTrade, &g_game); + g_lua.bindSingletonFunction("g_game", "inspectTrade", &Game::inspectTrade, &g_game); + g_lua.bindSingletonFunction("g_game", "acceptTrade", &Game::acceptTrade, &g_game); + g_lua.bindSingletonFunction("g_game", "rejectTrade", &Game::rejectTrade, &g_game); + g_lua.bindSingletonFunction("g_game", "openRuleViolation", &Game::openRuleViolation, &g_game); + g_lua.bindSingletonFunction("g_game", "closeRuleViolation", &Game::closeRuleViolation, &g_game); + g_lua.bindSingletonFunction("g_game", "cancelRuleViolation", &Game::cancelRuleViolation, &g_game); + g_lua.bindSingletonFunction("g_game", "reportBug", &Game::reportBug, &g_game); + g_lua.bindSingletonFunction("g_game", "reportRuleViolation", &Game::reportRuleViolation, &g_game); + g_lua.bindSingletonFunction("g_game", "debugReport", &Game::debugReport, &g_game); + g_lua.bindSingletonFunction("g_game", "editText", &Game::editText, &g_game); + g_lua.bindSingletonFunction("g_game", "editList", &Game::editList, &g_game); + g_lua.bindSingletonFunction("g_game", "requestQuestLog", &Game::requestQuestLog, &g_game); + g_lua.bindSingletonFunction("g_game", "requestQuestLine", &Game::requestQuestLine, &g_game); + g_lua.bindSingletonFunction("g_game", "equipItem", &Game::equipItem, &g_game); + g_lua.bindSingletonFunction("g_game", "mount", &Game::mount, &g_game); + g_lua.bindSingletonFunction("g_game", "requestItemInfo", &Game::requestItemInfo, &g_game); + g_lua.bindSingletonFunction("g_game", "ping", &Game::ping, &g_game); + g_lua.bindSingletonFunction("g_game", "setPingDelay", &Game::setPingDelay, &g_game); + g_lua.bindSingletonFunction("g_game", "changeMapAwareRange", &Game::changeMapAwareRange, &g_game); + g_lua.bindSingletonFunction("g_game", "canPerformGameAction", &Game::canPerformGameAction, &g_game); + g_lua.bindSingletonFunction("g_game", "canReportBugs", &Game::canReportBugs, &g_game); + g_lua.bindSingletonFunction("g_game", "checkBotProtection", &Game::checkBotProtection, &g_game); + g_lua.bindSingletonFunction("g_game", "isOnline", &Game::isOnline, &g_game); + g_lua.bindSingletonFunction("g_game", "isLogging", &Game::isLogging, &g_game); + 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", "isConnectionOk", &Game::isConnectionOk, &g_game); + g_lua.bindSingletonFunction("g_game", "getPing", &Game::getPing, &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); + g_lua.bindSingletonFunction("g_game", "getAttackingCreature", &Game::getAttackingCreature, &g_game); + g_lua.bindSingletonFunction("g_game", "getFollowingCreature", &Game::getFollowingCreature, &g_game); + g_lua.bindSingletonFunction("g_game", "getServerBeat", &Game::getServerBeat, &g_game); + g_lua.bindSingletonFunction("g_game", "getLocalPlayer", &Game::getLocalPlayer, &g_game); + g_lua.bindSingletonFunction("g_game", "getProtocolGame", &Game::getProtocolGame, &g_game); + g_lua.bindSingletonFunction("g_game", "getProtocolVersion", &Game::getProtocolVersion, &g_game); + g_lua.bindSingletonFunction("g_game", "setProtocolVersion", &Game::setProtocolVersion, &g_game); + g_lua.bindSingletonFunction("g_game", "getCustomProtocolVersion", &Game::getCustomProtocolVersion, &g_game); + g_lua.bindSingletonFunction("g_game", "setCustomProtocolVersion", &Game::setCustomProtocolVersion, &g_game); + g_lua.bindSingletonFunction("g_game", "getClientVersion", &Game::getClientVersion, &g_game); + g_lua.bindSingletonFunction("g_game", "setClientVersion", &Game::setClientVersion, &g_game); + g_lua.bindSingletonFunction("g_game", "setCustomOs", &Game::setCustomOs, &g_game); + g_lua.bindSingletonFunction("g_game", "getOs", &Game::getOs, &g_game); + g_lua.bindSingletonFunction("g_game", "getCharacterName", &Game::getCharacterName, &g_game); + g_lua.bindSingletonFunction("g_game", "getWorldName", &Game::getWorldName, &g_game); + g_lua.bindSingletonFunction("g_game", "getGMActions", &Game::getGMActions, &g_game); + g_lua.bindSingletonFunction("g_game", "getFeature", &Game::getFeature, &g_game); + g_lua.bindSingletonFunction("g_game", "setFeature", &Game::setFeature, &g_game); + g_lua.bindSingletonFunction("g_game", "enableFeature", &Game::enableFeature, &g_game); + g_lua.bindSingletonFunction("g_game", "disableFeature", &Game::disableFeature, &g_game); + g_lua.bindSingletonFunction("g_game", "resetFeatures", &Game::resetFeatures, &g_game); + g_lua.bindSingletonFunction("g_game", "isGM", &Game::isGM, &g_game); + g_lua.bindSingletonFunction("g_game", "answerModalDialog", &Game::answerModalDialog, &g_game); + g_lua.bindSingletonFunction("g_game", "browseField", &Game::browseField, &g_game); + g_lua.bindSingletonFunction("g_game", "seekInContainer", &Game::seekInContainer, &g_game); + g_lua.bindSingletonFunction("g_game", "getLastWalkDir", &Game::getLastWalkDir, &g_game); + g_lua.bindSingletonFunction("g_game", "buyStoreOffer", &Game::buyStoreOffer, &g_game); + g_lua.bindSingletonFunction("g_game", "requestTransactionHistory", &Game::requestTransactionHistory, &g_game); + g_lua.bindSingletonFunction("g_game", "requestStoreOffers", &Game::requestStoreOffers, &g_game); + g_lua.bindSingletonFunction("g_game", "openStore", &Game::openStore, &g_game); + g_lua.bindSingletonFunction("g_game", "transferCoins", &Game::transferCoins, &g_game); + g_lua.bindSingletonFunction("g_game", "openTransactionHistory", &Game::openTransactionHistory, &g_game); + + g_lua.bindSingletonFunction("g_game", "getMaxPreWalkingSteps", &Game::getMaxPreWalkingSteps, &g_game); + g_lua.bindSingletonFunction("g_game", "setMaxPreWalkingSteps", &Game::setMaxPreWalkingSteps, &g_game); + g_lua.bindSingletonFunction("g_game", "ignoreServerDirection", &Game::ignoreServerDirection, &g_game); + g_lua.bindSingletonFunction("g_game", "showRealDirection", &Game::showRealDirection, &g_game); + g_lua.bindSingletonFunction("g_game", "enableTileThingLuaCallback", &Game::enableTileThingLuaCallback, &g_game); + g_lua.bindSingletonFunction("g_game", "isTileThingLuaCallbackEnabled", &Game::isTileThingLuaCallbackEnabled, &g_game); + + g_lua.registerSingletonClass("g_shaders"); + g_lua.bindSingletonFunction("g_shaders", "createShader", &ShaderManager::createShader, &g_shaders); + g_lua.bindSingletonFunction("g_shaders", "createFragmentShader", &ShaderManager::createFragmentShader, &g_shaders); + g_lua.bindSingletonFunction("g_shaders", "createFragmentShaderFromCode", &ShaderManager::createFragmentShaderFromCode, &g_shaders); + g_lua.bindSingletonFunction("g_shaders", "createItemShader", &ShaderManager::createItemShader, &g_shaders); + g_lua.bindSingletonFunction("g_shaders", "createMapShader", &ShaderManager::createMapShader, &g_shaders); + g_lua.bindSingletonFunction("g_shaders", "getDefaultItemShader", &ShaderManager::getDefaultItemShader, &g_shaders); + g_lua.bindSingletonFunction("g_shaders", "getDefaultMapShader", &ShaderManager::getDefaultMapShader, &g_shaders); + g_lua.bindSingletonFunction("g_shaders", "getShader", &ShaderManager::getShader, &g_shaders); + + g_lua.bindGlobalFunction("getOutfitColor", Outfit::getColor); + g_lua.bindGlobalFunction("getAngleFromPos", Position::getAngleFromPositions); + g_lua.bindGlobalFunction("getDirectionFromPos", Position::getDirectionFromPositions); + + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return ProtocolGamePtr(new ProtocolGame); }); + g_lua.bindClassMemberFunction("login", &ProtocolGame::login); + g_lua.bindClassMemberFunction("sendExtendedOpcode", &ProtocolGame::sendExtendedOpcode); + g_lua.bindClassMemberFunction("addPosition", &ProtocolGame::addPosition); + g_lua.bindClassMemberFunction("setMapDescription", &ProtocolGame::setMapDescription); + g_lua.bindClassMemberFunction("setFloorDescription", &ProtocolGame::setFloorDescription); + g_lua.bindClassMemberFunction("setTileDescription", &ProtocolGame::setTileDescription); + g_lua.bindClassMemberFunction("getOutfit", &ProtocolGame::getOutfit); + g_lua.bindClassMemberFunction("getThing", &ProtocolGame::getThing); + g_lua.bindClassMemberFunction("getCreature", &ProtocolGame::getCreature); + g_lua.bindClassMemberFunction("getItem", &ProtocolGame::getItem); + g_lua.bindClassMemberFunction("getPosition", &ProtocolGame::getPosition); + + g_lua.registerClass(); + g_lua.bindClassMemberFunction("getItem", &Container::getItem); + g_lua.bindClassMemberFunction("getItems", &Container::getItems); + g_lua.bindClassMemberFunction("getItemsCount", &Container::getItemsCount); + g_lua.bindClassMemberFunction("getSlotPosition", &Container::getSlotPosition); + g_lua.bindClassMemberFunction("getName", &Container::getName); + g_lua.bindClassMemberFunction("getId", &Container::getId); + g_lua.bindClassMemberFunction("getCapacity", &Container::getCapacity); + g_lua.bindClassMemberFunction("getContainerItem", &Container::getContainerItem); + g_lua.bindClassMemberFunction("hasParent", &Container::hasParent); + g_lua.bindClassMemberFunction("isClosed", &Container::isClosed); + g_lua.bindClassMemberFunction("isUnlocked", &Container::isUnlocked); + g_lua.bindClassMemberFunction("hasPages", &Container::hasPages); + g_lua.bindClassMemberFunction("getSize", &Container::getSize); + g_lua.bindClassMemberFunction("getFirstIndex", &Container::getFirstIndex); + + g_lua.registerClass(); + g_lua.bindClassMemberFunction("setId", &Thing::setId); + g_lua.bindClassMemberFunction("setPosition", &Thing::setPosition); + g_lua.bindClassMemberFunction("getId", &Thing::getId); + g_lua.bindClassMemberFunction("getPosition", &Thing::getPosition); + g_lua.bindClassMemberFunction("getStackPriority", &Thing::getStackPriority); + g_lua.bindClassMemberFunction("getStackPos", &Thing::getStackPos); + g_lua.bindClassMemberFunction("getAnimationPhases", &Thing::getAnimationPhases); + g_lua.bindClassMemberFunction("getTile", &Thing::getTile); + g_lua.bindClassMemberFunction("setMarked", &Thing::setMarked); + g_lua.bindClassMemberFunction("isItem", &Thing::isItem); + g_lua.bindClassMemberFunction("isMonster", &Thing::isMonster); + g_lua.bindClassMemberFunction("isNpc", &Thing::isNpc); + g_lua.bindClassMemberFunction("isCreature", &Thing::isCreature); + g_lua.bindClassMemberFunction("isEffect", &Thing::isEffect); + g_lua.bindClassMemberFunction("isMissile", &Thing::isMissile); + g_lua.bindClassMemberFunction("isPlayer", &Thing::isPlayer); + g_lua.bindClassMemberFunction("isLocalPlayer", &Thing::isLocalPlayer); + g_lua.bindClassMemberFunction("isAnimatedText", &Thing::isAnimatedText); + g_lua.bindClassMemberFunction("isStaticText", &Thing::isStaticText); + g_lua.bindClassMemberFunction("isGround", &Thing::isGround); + g_lua.bindClassMemberFunction("isGroundBorder", &Thing::isGroundBorder); + g_lua.bindClassMemberFunction("isOnBottom", &Thing::isOnBottom); + g_lua.bindClassMemberFunction("isOnTop", &Thing::isOnTop); + g_lua.bindClassMemberFunction("isContainer", &Thing::isContainer); + g_lua.bindClassMemberFunction("isForceUse", &Thing::isForceUse); + g_lua.bindClassMemberFunction("isMultiUse", &Thing::isMultiUse); + g_lua.bindClassMemberFunction("isRotateable", &Thing::isRotateable); + g_lua.bindClassMemberFunction("isNotMoveable", &Thing::isNotMoveable); + g_lua.bindClassMemberFunction("isPickupable", &Thing::isPickupable); + g_lua.bindClassMemberFunction("isIgnoreLook", &Thing::isIgnoreLook); + g_lua.bindClassMemberFunction("isStackable", &Thing::isStackable); + g_lua.bindClassMemberFunction("isHookSouth", &Thing::isHookSouth); + g_lua.bindClassMemberFunction("isTranslucent", &Thing::isTranslucent); + g_lua.bindClassMemberFunction("isFullGround", &Thing::isFullGround); + g_lua.bindClassMemberFunction("isMarketable", &Thing::isMarketable); + g_lua.bindClassMemberFunction("getMarketData", &Thing::getMarketData); + g_lua.bindClassMemberFunction("isUsable", &Thing::isUsable); + g_lua.bindClassMemberFunction("isWrapable", &Thing::isWrapable); + g_lua.bindClassMemberFunction("isUnwrapable", &Thing::isUnwrapable); + g_lua.bindClassMemberFunction("isTopEffect", &Thing::isTopEffect); + g_lua.bindClassMemberFunction("isLyingCorpse", &Thing::isLyingCorpse); + g_lua.bindClassMemberFunction("getParentContainer", &Thing::getParentContainer); + g_lua.bindClassMemberFunction("hide", &Thing::hide); + g_lua.bindClassMemberFunction("show", &Thing::show); + g_lua.bindClassMemberFunction("setHidden", &Thing::setHidden); + g_lua.bindClassMemberFunction("isHidden", &Thing::isHidden); + + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return HousePtr(new House); }); + g_lua.bindClassMemberFunction("setId", &House::setId); + g_lua.bindClassMemberFunction("getId", &House::getId); + g_lua.bindClassMemberFunction("setName", &House::setName); + g_lua.bindClassMemberFunction("getName", &House::getName); + g_lua.bindClassMemberFunction("setTownId", &House::setTownId); + g_lua.bindClassMemberFunction("getTownId", &House::getTownId); + g_lua.bindClassMemberFunction("setTile", &House::setTile); + g_lua.bindClassMemberFunction("getTile", &House::getTile); + g_lua.bindClassMemberFunction("setEntry", &House::setEntry); + g_lua.bindClassMemberFunction("getEntry", &House::getEntry); + g_lua.bindClassMemberFunction("addDoor", &House::addDoor); + g_lua.bindClassMemberFunction("removeDoor", &House::removeDoor); + g_lua.bindClassMemberFunction("removeDoorById", &House::removeDoorById); + g_lua.bindClassMemberFunction("setSize", &House::setSize); + g_lua.bindClassMemberFunction("getSize", &House::getSize); + g_lua.bindClassMemberFunction("setRent", &House::setRent); + g_lua.bindClassMemberFunction("getRent", &House::getRent); + + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return SpawnPtr(new Spawn); }); + g_lua.bindClassMemberFunction("setRadius", &Spawn::setRadius); + g_lua.bindClassMemberFunction("getRadius", &Spawn::getRadius); + g_lua.bindClassMemberFunction("setCenterPos", &Spawn::setCenterPos); + g_lua.bindClassMemberFunction("getCenterPos", &Spawn::getCenterPos); + g_lua.bindClassMemberFunction("addCreature", &Spawn::addCreature); + g_lua.bindClassMemberFunction("removeCreature", &Spawn::removeCreature); + g_lua.bindClassMemberFunction("getCreatures", &Spawn::getCreatures); + + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return TownPtr(new Town); }); + g_lua.bindClassMemberFunction("setId", &Town::setId); + g_lua.bindClassMemberFunction("setName", &Town::setName); + g_lua.bindClassMemberFunction("setPos", &Town::setPos); + g_lua.bindClassMemberFunction("setTemplePos", &Town::setPos); // alternative method + g_lua.bindClassMemberFunction("getId", &Town::getId); + g_lua.bindClassMemberFunction("getName", &Town::getName); + g_lua.bindClassMemberFunction("getPos", &Town::getPos); + g_lua.bindClassMemberFunction("getTemplePos", &Town::getPos); // alternative method + + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return CreatureTypePtr(new CreatureType); }); + g_lua.bindClassMemberFunction("setName", &CreatureType::setName); + g_lua.bindClassMemberFunction("setOutfit", &CreatureType::setOutfit); + g_lua.bindClassMemberFunction("setSpawnTime", &CreatureType::setSpawnTime); + g_lua.bindClassMemberFunction("getName", &CreatureType::getName); + g_lua.bindClassMemberFunction("getOutfit", &CreatureType::getOutfit); + g_lua.bindClassMemberFunction("getSpawnTime", &CreatureType::getSpawnTime); + g_lua.bindClassMemberFunction("cast", &CreatureType::cast); + + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return CreaturePtr(new Creature); }); + g_lua.bindClassMemberFunction("getId", &Creature::getId); + g_lua.bindClassMemberFunction("getName", &Creature::getName); + g_lua.bindClassMemberFunction("setManaPercent", &LocalPlayer::setManaPercent); + g_lua.bindClassMemberFunction("getManaPercent", &LocalPlayer::getManaPercent); + g_lua.bindClassMemberFunction("getHealthPercent", &Creature::getHealthPercent); + g_lua.bindClassMemberFunction("getSpeed", &Creature::getSpeed); + g_lua.bindClassMemberFunction("setSpeed", &Creature::setSpeed); + g_lua.bindClassMemberFunction("getBaseSpeed", &Creature::getBaseSpeed); + g_lua.bindClassMemberFunction("setBaseSpeed", &Creature::setBaseSpeed); + g_lua.bindClassMemberFunction("getSkull", &Creature::getSkull); + g_lua.bindClassMemberFunction("getShield", &Creature::getShield); + g_lua.bindClassMemberFunction("getEmblem", &Creature::getEmblem); + g_lua.bindClassMemberFunction("getType", &Creature::getType); + g_lua.bindClassMemberFunction("getIcon", &Creature::getIcon); + g_lua.bindClassMemberFunction("setOutfit", &Creature::setOutfit); + g_lua.bindClassMemberFunction("getOutfit", &Creature::getOutfit); + g_lua.bindClassMemberFunction("setOutfitColor", &Creature::setOutfitColor); + g_lua.bindClassMemberFunction("getDirection", &Creature::getDirection); + g_lua.bindClassMemberFunction("getWalkDirection", &Creature::getWalkDirection); + g_lua.bindClassMemberFunction("getStepDuration", &Creature::getStepDuration); + g_lua.bindClassMemberFunction("getStepProgress", &Creature::getStepProgress); + g_lua.bindClassMemberFunction("getWalkTicksElapsed", &Creature::getWalkTicksElapsed); + g_lua.bindClassMemberFunction("getStepTicksLeft", &Creature::getStepTicksLeft); + g_lua.bindClassMemberFunction("setDirection", &Creature::setDirection); + g_lua.bindClassMemberFunction("setSkullTexture", &Creature::setSkullTexture); + g_lua.bindClassMemberFunction("setShieldTexture", &Creature::setShieldTexture); + g_lua.bindClassMemberFunction("setEmblemTexture", &Creature::setEmblemTexture); + g_lua.bindClassMemberFunction("setTypeTexture", &Creature::setTypeTexture); + g_lua.bindClassMemberFunction("setIconTexture", &Creature::setIconTexture); + g_lua.bindClassMemberFunction("showStaticSquare", &Creature::showStaticSquare); + g_lua.bindClassMemberFunction("hideStaticSquare", &Creature::hideStaticSquare); + g_lua.bindClassMemberFunction("isWalking", &Creature::isWalking); + g_lua.bindClassMemberFunction("isInvisible", &Creature::isInvisible); + g_lua.bindClassMemberFunction("isDead", &Creature::isDead); + g_lua.bindClassMemberFunction("isRemoved", &Creature::isRemoved); + g_lua.bindClassMemberFunction("canBeSeen", &Creature::canBeSeen); + g_lua.bindClassMemberFunction("jump", &Creature::jump); + g_lua.bindClassMemberFunction("getPrewalkingPosition", &Creature::getPrewalkingPosition); + g_lua.bindClassMemberFunction("setInformationColor", &Creature::setInformationColor); + g_lua.bindClassMemberFunction("resetInformationColor", &Creature::resetInformationColor); + g_lua.bindClassMemberFunction("setInformationOffset", &Creature::setInformationOffset); + g_lua.bindClassMemberFunction("getInformationOffset", &Creature::getInformationOffset); + + g_lua.registerClass(); + g_lua.bindClassMemberFunction("getServerId", &ItemType::getServerId); + g_lua.bindClassMemberFunction("getClientId", &ItemType::getClientId); + g_lua.bindClassMemberFunction("isWritable", &ItemType::isWritable); + + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return ThingTypePtr(new ThingType); }); + g_lua.bindClassMemberFunction("getId", &ThingType::getId); + g_lua.bindClassMemberFunction("getClothSlot", &ThingType::getClothSlot); + g_lua.bindClassMemberFunction("getCategory", &ThingType::getCategory); + g_lua.bindClassMemberFunction("getSize", &ThingType::getSize); + g_lua.bindClassMemberFunction("getWidth", &ThingType::getWidth); + g_lua.bindClassMemberFunction("getHeight", &ThingType::getHeight); + g_lua.bindClassMemberFunction("getDisplacement", &ThingType::getDisplacement); + g_lua.bindClassMemberFunction("getDisplacementX", &ThingType::getDisplacementX); + g_lua.bindClassMemberFunction("getDisplacementY", &ThingType::getDisplacementY); + g_lua.bindClassMemberFunction("getExactSize", &ThingType::getExactSize); + g_lua.bindClassMemberFunction("getRealSize", &ThingType::getRealSize); + g_lua.bindClassMemberFunction("getLayers", &ThingType::getLayers); + g_lua.bindClassMemberFunction("getNumPatternX", &ThingType::getNumPatternX); + g_lua.bindClassMemberFunction("getNumPatternY", &ThingType::getNumPatternY); + g_lua.bindClassMemberFunction("getNumPatternZ", &ThingType::getNumPatternZ); + g_lua.bindClassMemberFunction("getAnimationPhases", &ThingType::getAnimationPhases); + g_lua.bindClassMemberFunction("getGroundSpeed", &ThingType::getGroundSpeed); + g_lua.bindClassMemberFunction("getMaxTextLength", &ThingType::getMaxTextLength); + g_lua.bindClassMemberFunction("getLight", &ThingType::getLight); + g_lua.bindClassMemberFunction("getMinimapColor", &ThingType::getMinimapColor); + g_lua.bindClassMemberFunction("getLensHelp", &ThingType::getLensHelp); + g_lua.bindClassMemberFunction("getClothSlot", &ThingType::getClothSlot); + g_lua.bindClassMemberFunction("getElevation", &ThingType::getElevation); + g_lua.bindClassMemberFunction("isGround", &ThingType::isGround); + g_lua.bindClassMemberFunction("isGroundBorder", &ThingType::isGroundBorder); + g_lua.bindClassMemberFunction("isOnBottom", &ThingType::isOnBottom); + g_lua.bindClassMemberFunction("isOnTop", &ThingType::isOnTop); + g_lua.bindClassMemberFunction("isContainer", &ThingType::isContainer); + g_lua.bindClassMemberFunction("isStackable", &ThingType::isStackable); + g_lua.bindClassMemberFunction("isForceUse", &ThingType::isForceUse); + g_lua.bindClassMemberFunction("isMultiUse", &ThingType::isMultiUse); + g_lua.bindClassMemberFunction("isWritable", &ThingType::isWritable); + g_lua.bindClassMemberFunction("isChargeable", &ThingType::isChargeable); + g_lua.bindClassMemberFunction("isWritableOnce", &ThingType::isWritableOnce); + g_lua.bindClassMemberFunction("isFluidContainer", &ThingType::isFluidContainer); + g_lua.bindClassMemberFunction("isSplash", &ThingType::isSplash); + g_lua.bindClassMemberFunction("isNotWalkable", &ThingType::isNotWalkable); + g_lua.bindClassMemberFunction("isNotMoveable", &ThingType::isNotMoveable); + g_lua.bindClassMemberFunction("blockProjectile", &ThingType::blockProjectile); + g_lua.bindClassMemberFunction("isNotPathable", &ThingType::isNotPathable); + g_lua.bindClassMemberFunction("setPathable", &ThingType::setPathable); + g_lua.bindClassMemberFunction("isPickupable", &ThingType::isPickupable); + g_lua.bindClassMemberFunction("isHangable", &ThingType::isHangable); + g_lua.bindClassMemberFunction("isHookSouth", &ThingType::isHookSouth); + g_lua.bindClassMemberFunction("isHookEast", &ThingType::isHookEast); + g_lua.bindClassMemberFunction("isRotateable", &ThingType::isRotateable); + g_lua.bindClassMemberFunction("hasLight", &ThingType::hasLight); + g_lua.bindClassMemberFunction("isDontHide", &ThingType::isDontHide); + g_lua.bindClassMemberFunction("isTranslucent", &ThingType::isTranslucent); + g_lua.bindClassMemberFunction("hasDisplacement", &ThingType::hasDisplacement); + g_lua.bindClassMemberFunction("hasElevation", &ThingType::hasElevation); + g_lua.bindClassMemberFunction("isLyingCorpse", &ThingType::isLyingCorpse); + g_lua.bindClassMemberFunction("isAnimateAlways", &ThingType::isAnimateAlways); + g_lua.bindClassMemberFunction("hasMiniMapColor", &ThingType::hasMiniMapColor); + g_lua.bindClassMemberFunction("hasLensHelp", &ThingType::hasLensHelp); + g_lua.bindClassMemberFunction("isFullGround", &ThingType::isFullGround); + g_lua.bindClassMemberFunction("isIgnoreLook", &ThingType::isIgnoreLook); + g_lua.bindClassMemberFunction("isCloth", &ThingType::isCloth); + g_lua.bindClassMemberFunction("isMarketable", &ThingType::isMarketable); + g_lua.bindClassMemberFunction("getMarketData", &ThingType::getMarketData); + g_lua.bindClassMemberFunction("isUsable", &ThingType::isUsable); + g_lua.bindClassMemberFunction("isWrapable", &ThingType::isWrapable); + g_lua.bindClassMemberFunction("isUnwrapable", &ThingType::isUnwrapable); + g_lua.bindClassMemberFunction("isTopEffect", &ThingType::isTopEffect); + g_lua.bindClassMemberFunction("getSprites", &ThingType::getSprites); + g_lua.bindClassMemberFunction("hasAttribute", &ThingType::hasAttr); + g_lua.bindClassMemberFunction("exportImage", &ThingType::exportImage); + + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", &Item::create); + g_lua.bindClassStaticFunction("createOtb", &Item::createFromOtb); + g_lua.bindClassMemberFunction("clone", &Item::clone); + g_lua.bindClassMemberFunction("getContainerItems", &Item::getContainerItems); + g_lua.bindClassMemberFunction("getContainerItem", &Item::getContainerItem); + g_lua.bindClassMemberFunction("addContainerItem", &Item::addContainerItem); + g_lua.bindClassMemberFunction("addContainerItemIndexed", &Item::addContainerItemIndexed); + g_lua.bindClassMemberFunction("removeContainerItem", &Item::removeContainerItem); + g_lua.bindClassMemberFunction("clearContainerItems", &Item::clearContainerItems); + g_lua.bindClassMemberFunction("getContainerItem", &Item::getContainerItem); + g_lua.bindClassMemberFunction("setCount", &Item::setCount); + g_lua.bindClassMemberFunction("getCount", &Item::getCount); + g_lua.bindClassMemberFunction("getSubType", &Item::getSubType); + g_lua.bindClassMemberFunction("getId", &Item::getId); + g_lua.bindClassMemberFunction("getServerId", &Item::getServerId); + g_lua.bindClassMemberFunction("getName", &Item::getName); + g_lua.bindClassMemberFunction("getDescription", &Item::getDescription); + g_lua.bindClassMemberFunction("getText", &Item::getText); + g_lua.bindClassMemberFunction("setDescription", &Item::setDescription); + g_lua.bindClassMemberFunction("setText", &Item::setText); + g_lua.bindClassMemberFunction("getUniqueId", &Item::getUniqueId); + g_lua.bindClassMemberFunction("getActionId", &Item::getActionId); + g_lua.bindClassMemberFunction("setUniqueId", &Item::setUniqueId); + g_lua.bindClassMemberFunction("setActionId", &Item::setActionId); + g_lua.bindClassMemberFunction("getTeleportDestination", &Item::getTeleportDestination); + g_lua.bindClassMemberFunction("setTeleportDestination", &Item::setTeleportDestination); + g_lua.bindClassMemberFunction("isStackable", &Item::isStackable); + g_lua.bindClassMemberFunction("isMarketable", &Item::isMarketable); + g_lua.bindClassMemberFunction("isFluidContainer", &Item::isFluidContainer); + g_lua.bindClassMemberFunction("getMarketData", &Item::getMarketData); + g_lua.bindClassMemberFunction("getClothSlot", &Item::getClothSlot); + + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return EffectPtr(new Effect); }); + g_lua.bindClassMemberFunction("setId", &Effect::setId); + + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return MissilePtr(new Missile); }); + g_lua.bindClassMemberFunction("setId", &Missile::setId); + g_lua.bindClassMemberFunction("getId", &Missile::getId); + g_lua.bindClassMemberFunction("getSource", &Missile::getSource); + g_lua.bindClassMemberFunction("getDestination", &Missile::getDestination); + + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return StaticTextPtr(new StaticText); }); + g_lua.bindClassMemberFunction("addMessage", &StaticText::addMessage); + g_lua.bindClassMemberFunction("setText", &StaticText::setText); + g_lua.bindClassMemberFunction("setFont", &StaticText::setFont); + g_lua.bindClassMemberFunction("setColor", &StaticText::setColor); + g_lua.bindClassMemberFunction("getColor", &StaticText::getColor); + g_lua.bindClassMemberFunction("getText", &StaticText::getText); + + g_lua.registerClass(); + g_lua.bindClassMemberFunction("getText", &AnimatedText::getText); + g_lua.bindClassMemberFunction("getOffset", &AnimatedText::getOffset); + g_lua.bindClassMemberFunction("getColor", &AnimatedText::getColor); + + g_lua.registerClass(); + g_lua.registerClass(); + g_lua.registerClass(); + + g_lua.registerClass(); + g_lua.bindClassMemberFunction("unlockWalk", &LocalPlayer::unlockWalk); + g_lua.bindClassMemberFunction("lockWalk", &LocalPlayer::lockWalk); + g_lua.bindClassMemberFunction("isWalkLocked", &LocalPlayer::isWalkLocked); + g_lua.bindClassMemberFunction("canWalk", &LocalPlayer::canWalk); + g_lua.bindClassMemberFunction("setStates", &LocalPlayer::setStates); + g_lua.bindClassMemberFunction("setSkill", &LocalPlayer::setSkill); + g_lua.bindClassMemberFunction("setHealth", &LocalPlayer::setHealth); + g_lua.bindClassMemberFunction("setTotalCapacity", &LocalPlayer::setTotalCapacity); + g_lua.bindClassMemberFunction("setFreeCapacity", &LocalPlayer::setFreeCapacity); + g_lua.bindClassMemberFunction("setExperience", &LocalPlayer::setExperience); + g_lua.bindClassMemberFunction("setLevel", &LocalPlayer::setLevel); + g_lua.bindClassMemberFunction("setMana", &LocalPlayer::setMana); + g_lua.bindClassMemberFunction("setMagicLevel", &LocalPlayer::setMagicLevel); + g_lua.bindClassMemberFunction("setSoul", &LocalPlayer::setSoul); + g_lua.bindClassMemberFunction("setStamina", &LocalPlayer::setStamina); + g_lua.bindClassMemberFunction("setKnown", &LocalPlayer::setKnown); + g_lua.bindClassMemberFunction("setInventoryItem", &LocalPlayer::setInventoryItem); + g_lua.bindClassMemberFunction("getStates", &LocalPlayer::getStates); + g_lua.bindClassMemberFunction("getSkillLevel", &LocalPlayer::getSkillLevel); + g_lua.bindClassMemberFunction("getSkillBaseLevel", &LocalPlayer::getSkillBaseLevel); + g_lua.bindClassMemberFunction("getSkillLevelPercent", &LocalPlayer::getSkillLevelPercent); + g_lua.bindClassMemberFunction("getHealth", &LocalPlayer::getHealth); + g_lua.bindClassMemberFunction("getMaxHealth", &LocalPlayer::getMaxHealth); + g_lua.bindClassMemberFunction("getFreeCapacity", &LocalPlayer::getFreeCapacity); + g_lua.bindClassMemberFunction("getExperience", &LocalPlayer::getExperience); + g_lua.bindClassMemberFunction("getLevel", &LocalPlayer::getLevel); + g_lua.bindClassMemberFunction("getLevelPercent", &LocalPlayer::getLevelPercent); + g_lua.bindClassMemberFunction("getMana", &LocalPlayer::getMana); + g_lua.bindClassMemberFunction("getMaxMana", &LocalPlayer::getMaxMana); + g_lua.bindClassMemberFunction("getMagicLevel", &LocalPlayer::getMagicLevel); + g_lua.bindClassMemberFunction("getMagicLevelPercent", &LocalPlayer::getMagicLevelPercent); + g_lua.bindClassMemberFunction("getSoul", &LocalPlayer::getSoul); + g_lua.bindClassMemberFunction("getStamina", &LocalPlayer::getStamina); + g_lua.bindClassMemberFunction("getOfflineTrainingTime", &LocalPlayer::getOfflineTrainingTime); + g_lua.bindClassMemberFunction("getRegenerationTime", &LocalPlayer::getRegenerationTime); + g_lua.bindClassMemberFunction("getBaseMagicLevel", &LocalPlayer::getBaseMagicLevel); + g_lua.bindClassMemberFunction("getTotalCapacity", &LocalPlayer::getTotalCapacity); + g_lua.bindClassMemberFunction("getInventoryItem", &LocalPlayer::getInventoryItem); + g_lua.bindClassMemberFunction("getVocation", &LocalPlayer::getVocation); + g_lua.bindClassMemberFunction("getBlessings", &LocalPlayer::getBlessings); + g_lua.bindClassMemberFunction("isPremium", &LocalPlayer::isPremium); + g_lua.bindClassMemberFunction("isKnown", &LocalPlayer::isKnown); + g_lua.bindClassMemberFunction("isPreWalking", &LocalPlayer::isPreWalking); + g_lua.bindClassMemberFunction("hasSight", &LocalPlayer::hasSight); + g_lua.bindClassMemberFunction("isAutoWalking", &LocalPlayer::isAutoWalking); + g_lua.bindClassMemberFunction("isServerWalking", &LocalPlayer::isServerWalking); + g_lua.bindClassMemberFunction("stopAutoWalk", &LocalPlayer::stopAutoWalk); + g_lua.bindClassMemberFunction("autoWalk", &LocalPlayer::autoWalk); + g_lua.bindClassMemberFunction("preWalk", &LocalPlayer::preWalk); + g_lua.bindClassMemberFunction("dumpWalkMatrix", &LocalPlayer::dumpWalkMatrix); + + g_lua.registerClass(); + g_lua.bindClassMemberFunction("clean", &Tile::clean); + g_lua.bindClassMemberFunction("addThing", &Tile::addThing); + g_lua.bindClassMemberFunction("getThing", &Tile::getThing); + g_lua.bindClassMemberFunction("getThings", &Tile::getThings); + g_lua.bindClassMemberFunction("getEffect", &Tile::getEffect); + g_lua.bindClassMemberFunction("getEffects", &Tile::getEffects); + g_lua.bindClassMemberFunction("getItems", &Tile::getItems); + g_lua.bindClassMemberFunction("getThingStackPos", &Tile::getThingStackPos); + g_lua.bindClassMemberFunction("getThingCount", &Tile::getThingCount); + g_lua.bindClassMemberFunction("getTopThing", &Tile::getTopThing); + g_lua.bindClassMemberFunction("removeThing", &Tile::removeThing); + g_lua.bindClassMemberFunction("getTopLookThing", &Tile::getTopLookThing); + g_lua.bindClassMemberFunction("getTopLookThingEx", &Tile::getTopLookThingEx); + g_lua.bindClassMemberFunction("getTopUseThing", &Tile::getTopUseThing); + g_lua.bindClassMemberFunction("getTopCreature", &Tile::getTopCreature); + g_lua.bindClassMemberFunction("getTopCreatureEx", &Tile::getTopCreatureEx); + g_lua.bindClassMemberFunction("getTopMoveThing", &Tile::getTopMoveThing); + g_lua.bindClassMemberFunction("getTopMultiUseThing", &Tile::getTopMultiUseThing); + g_lua.bindClassMemberFunction("getTopMultiUseThingEx", &Tile::getTopMultiUseThingEx); + g_lua.bindClassMemberFunction("getPosition", &Tile::getPosition); + g_lua.bindClassMemberFunction("getDrawElevation", &Tile::getDrawElevation); + g_lua.bindClassMemberFunction("getCreatures", &Tile::getCreatures); + g_lua.bindClassMemberFunction("getGround", &Tile::getGround); + g_lua.bindClassMemberFunction("isWalkable", &Tile::isWalkable); + g_lua.bindClassMemberFunction("isHouseTile", &Tile::isHouseTile); + g_lua.bindClassMemberFunction("isFullGround", &Tile::isFullGround); + g_lua.bindClassMemberFunction("isFullyOpaque", &Tile::isFullyOpaque); + g_lua.bindClassMemberFunction("isLookPossible", &Tile::isLookPossible); + g_lua.bindClassMemberFunction("hasCreature", &Tile::hasCreature); + g_lua.bindClassMemberFunction("hasBlockingCreature", &Tile::hasBlockingCreature); + g_lua.bindClassMemberFunction("isEmpty", &Tile::isEmpty); + g_lua.bindClassMemberFunction("isClickable", &Tile::isClickable); + g_lua.bindClassMemberFunction("isPathable", &Tile::isPathable); + g_lua.bindClassMemberFunction("overwriteMinimapColor", &Tile::overwriteMinimapColor); + g_lua.bindClassMemberFunction("select", &Tile::select); + g_lua.bindClassMemberFunction("unselect", &Tile::unselect); + g_lua.bindClassMemberFunction("isSelected", &Tile::isSelected); + g_lua.bindClassMemberFunction("remFlag", &Tile::remFlag); + g_lua.bindClassMemberFunction("setFlag", &Tile::setFlag); + g_lua.bindClassMemberFunction("setFlags", &Tile::setFlags); + g_lua.bindClassMemberFunction("getFlags", &Tile::getFlags); + g_lua.bindClassMemberFunction("hasFlag", &Tile::hasFlag); + g_lua.bindClassMemberFunction("getElevation", &Tile::getElevation); + g_lua.bindClassMemberFunction("hasElevation", &Tile::hasElevation); + g_lua.bindClassMemberFunction("isBlocking", &Tile::isBlocking); + // for bot + g_lua.bindClassMemberFunction("setText", &Tile::setText); + g_lua.bindClassMemberFunction("getText", &Tile::getText); + g_lua.bindClassMemberFunction("setTimer", &Tile::setTimer); + g_lua.bindClassMemberFunction("getTimer", &Tile::getTimer); + g_lua.bindClassMemberFunction("setFill", &Tile::setFill); + + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return UIItemPtr(new UIItem); }); + g_lua.bindClassMemberFunction("setItemId", &UIItem::setItemId); + g_lua.bindClassMemberFunction("setItemCount", &UIItem::setItemCount); + g_lua.bindClassMemberFunction("setItemSubType", &UIItem::setItemSubType); + g_lua.bindClassMemberFunction("setItemVisible", &UIItem::setItemVisible); + g_lua.bindClassMemberFunction("setItem", &UIItem::setItem); + g_lua.bindClassMemberFunction("setVirtual", &UIItem::setVirtual); + g_lua.bindClassMemberFunction("setShowCount", &UIItem::setShowCount); + g_lua.bindClassMemberFunction("clearItem", &UIItem::clearItem); + g_lua.bindClassMemberFunction("getItemId", &UIItem::getItemId); + g_lua.bindClassMemberFunction("getItemCount", &UIItem::getItemCount); + g_lua.bindClassMemberFunction("getItemSubType", &UIItem::getItemSubType); + g_lua.bindClassMemberFunction("getItem", &UIItem::getItem); + g_lua.bindClassMemberFunction("isVirtual", &UIItem::isVirtual); + g_lua.bindClassMemberFunction("isItemVisible", &UIItem::isItemVisible); + + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return UISpritePtr(new UISprite); }); + g_lua.bindClassMemberFunction("setSpriteId", &UISprite::setSpriteId); + g_lua.bindClassMemberFunction("clearSprite", &UISprite::clearSprite); + g_lua.bindClassMemberFunction("getSpriteId", &UISprite::getSpriteId); + g_lua.bindClassMemberFunction("setSpriteColor", &UISprite::setSpriteColor); + g_lua.bindClassMemberFunction("hasSprite", &UISprite::hasSprite); + + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return UICreaturePtr(new UICreature); } ); + g_lua.bindClassMemberFunction("setCreature", &UICreature::setCreature); + g_lua.bindClassMemberFunction("setOutfit", &UICreature::setOutfit); + g_lua.bindClassMemberFunction("setFixedCreatureSize", &UICreature::setFixedCreatureSize); + g_lua.bindClassMemberFunction("getCreature", &UICreature::getCreature); + g_lua.bindClassMemberFunction("isFixedCreatureSize", &UICreature::isFixedCreatureSize); + g_lua.bindClassMemberFunction("setAutoRotating", &UICreature::setAutoRotating); + g_lua.bindClassMemberFunction("setDirection", &UICreature::setDirection); + + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return UIMapPtr(new UIMap); }); + g_lua.bindClassMemberFunction("drawSelf", &UIMap::drawSelf); + g_lua.bindClassMemberFunction("movePixels", &UIMap::movePixels); + g_lua.bindClassMemberFunction("setZoom", &UIMap::setZoom); + g_lua.bindClassMemberFunction("zoomIn", &UIMap::zoomIn); + g_lua.bindClassMemberFunction("zoomOut", &UIMap::zoomOut); + g_lua.bindClassMemberFunction("followCreature", &UIMap::followCreature); + g_lua.bindClassMemberFunction("setCameraPosition", &UIMap::setCameraPosition); + g_lua.bindClassMemberFunction("setMaxZoomIn", &UIMap::setMaxZoomIn); + g_lua.bindClassMemberFunction("setMaxZoomOut", &UIMap::setMaxZoomOut); + g_lua.bindClassMemberFunction("setMultifloor", &UIMap::setMultifloor); + g_lua.bindClassMemberFunction("lockVisibleFloor", &UIMap::lockVisibleFloor); + g_lua.bindClassMemberFunction("unlockVisibleFloor", &UIMap::unlockVisibleFloor); + g_lua.bindClassMemberFunction("setVisibleDimension", &UIMap::setVisibleDimension); + g_lua.bindClassMemberFunction("setDrawFlags", &UIMap::setDrawFlags); + g_lua.bindClassMemberFunction("setDrawTexts", &UIMap::setDrawTexts); + g_lua.bindClassMemberFunction("setDrawNames", &UIMap::setDrawNames); + g_lua.bindClassMemberFunction("setDrawHealthBars", &UIMap::setDrawHealthBars); + g_lua.bindClassMemberFunction("setDrawHealthBarsOnTop", &UIMap::setDrawHealthBarsOnTop); + g_lua.bindClassMemberFunction("setDrawLights", &UIMap::setDrawLights); + g_lua.bindClassMemberFunction("setDrawManaBar", &UIMap::setDrawManaBar); + g_lua.bindClassMemberFunction("setDrawPlayerBars", &UIMap::setDrawPlayerBars); + g_lua.bindClassMemberFunction("setAnimated", &UIMap::setAnimated); + g_lua.bindClassMemberFunction("setKeepAspectRatio", &UIMap::setKeepAspectRatio); + g_lua.bindClassMemberFunction("setMapShader", &UIMap::setMapShader); + g_lua.bindClassMemberFunction("setMinimumAmbientLight", &UIMap::setMinimumAmbientLight); + g_lua.bindClassMemberFunction("setLimitVisibleRange", &UIMap::setLimitVisibleRange); + g_lua.bindClassMemberFunction("setFloorFading", &UIMap::setFloorFading); + g_lua.bindClassMemberFunction("setCrosshair", &UIMap::setCrosshair); + g_lua.bindClassMemberFunction("isMultifloor", &UIMap::isMultifloor); + g_lua.bindClassMemberFunction("isDrawingTexts", &UIMap::isDrawingTexts); + g_lua.bindClassMemberFunction("isDrawingNames", &UIMap::isDrawingNames); + g_lua.bindClassMemberFunction("isDrawingHealthBars", &UIMap::isDrawingHealthBars); + g_lua.bindClassMemberFunction("isDrawingHealthBarsOnTop", &UIMap::isDrawingHealthBarsOnTop); + g_lua.bindClassMemberFunction("isDrawingLights", &UIMap::isDrawingLights); + g_lua.bindClassMemberFunction("isDrawingManaBar", &UIMap::isDrawingManaBar); + g_lua.bindClassMemberFunction("isLimitVisibleRangeEnabled", &UIMap::isLimitVisibleRangeEnabled); + g_lua.bindClassMemberFunction("isAnimating", &UIMap::isAnimating); + g_lua.bindClassMemberFunction("isKeepAspectRatioEnabled", &UIMap::isKeepAspectRatioEnabled); + g_lua.bindClassMemberFunction("getVisibleDimension", &UIMap::getVisibleDimension); + g_lua.bindClassMemberFunction("getFollowingCreature", &UIMap::getFollowingCreature); + g_lua.bindClassMemberFunction("getDrawFlags", &UIMap::getDrawFlags); + g_lua.bindClassMemberFunction("getCameraPosition", &UIMap::getCameraPosition); + g_lua.bindClassMemberFunction("getPosition", &UIMap::getPosition); + g_lua.bindClassMemberFunction("getPositionOffset", &UIMap::getPositionOffset); + g_lua.bindClassMemberFunction("getTile", &UIMap::getTile); + g_lua.bindClassMemberFunction("getMaxZoomIn", &UIMap::getMaxZoomIn); + g_lua.bindClassMemberFunction("getMaxZoomOut", &UIMap::getMaxZoomOut); + g_lua.bindClassMemberFunction("getZoom", &UIMap::getZoom); + g_lua.bindClassMemberFunction("getMapShader", &UIMap::getMapShader); + g_lua.bindClassMemberFunction("getMinimumAmbientLight", &UIMap::getMinimumAmbientLight); + + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return UIMinimapPtr(new UIMinimap); }); + g_lua.bindClassMemberFunction("zoomIn", &UIMinimap::zoomIn); + g_lua.bindClassMemberFunction("zoomOut", &UIMinimap::zoomOut); + g_lua.bindClassMemberFunction("setZoom", &UIMinimap::setZoom); + g_lua.bindClassMemberFunction("setMixZoom", &UIMinimap::setMinZoom); + g_lua.bindClassMemberFunction("setMaxZoom", &UIMinimap::setMaxZoom); + g_lua.bindClassMemberFunction("setCameraPosition", &UIMinimap::setCameraPosition); + g_lua.bindClassMemberFunction("floorUp", &UIMinimap::floorUp); + g_lua.bindClassMemberFunction("floorDown", &UIMinimap::floorDown); + g_lua.bindClassMemberFunction("getTilePoint", &UIMinimap::getTilePoint); + g_lua.bindClassMemberFunction("getTilePosition", &UIMinimap::getTilePosition); + g_lua.bindClassMemberFunction("getTileRect", &UIMinimap::getTileRect); + g_lua.bindClassMemberFunction("getCameraPosition", &UIMinimap::getCameraPosition); + g_lua.bindClassMemberFunction("getMinZoom", &UIMinimap::getMinZoom); + g_lua.bindClassMemberFunction("getMaxZoom", &UIMinimap::getMaxZoom); + g_lua.bindClassMemberFunction("getZoom", &UIMinimap::getZoom); + g_lua.bindClassMemberFunction("getScale", &UIMinimap::getScale); + g_lua.bindClassMemberFunction("anchorPosition", &UIMinimap::anchorPosition); + g_lua.bindClassMemberFunction("fillPosition", &UIMinimap::fillPosition); + g_lua.bindClassMemberFunction("centerInPosition", &UIMinimap::centerInPosition); + + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return UIProgressRectPtr(new UIProgressRect); } ); + g_lua.bindClassMemberFunction("setPercent", &UIProgressRect::setPercent); + g_lua.bindClassMemberFunction("getPercent", &UIProgressRect::getPercent); + + g_lua.registerClass(); +} diff --git a/lua_functions/luafunctions_framework.cpp b/lua_functions/luafunctions_framework.cpp new file mode 100644 index 0000000..0077f01 --- /dev/null +++ b/lua_functions/luafunctions_framework.cpp @@ -0,0 +1,990 @@ +/* + * Copyright (c) 2010-2017 OTClient + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef FW_SOUND +#include +#include +#include +#include +#include +#endif + +#ifdef FW_GRAPHICS +#include +#include +#include +#include +#include +#include +#include +#endif + +#ifdef FW_NET +#include +#include +#ifdef FW_PROXY +#include +#endif +#endif + +#ifdef FW_SQL +#include +#endif + +#include + +#include + + +void Application::registerLuaFunctions() +{ + // conversion globals + g_lua.bindGlobalFunction("torect", [](const std::string& v) { return stdext::from_string(v); }); + g_lua.bindGlobalFunction("topoint", [](const std::string& v) { return stdext::from_string(v); }); + g_lua.bindGlobalFunction("tocolor", [](const std::string& v) { return stdext::from_string(v); }); + g_lua.bindGlobalFunction("tosize", [](const std::string& v) { return stdext::from_string(v); }); + g_lua.bindGlobalFunction("recttostring", [](const Rect& v) { return stdext::to_string(v); }); + g_lua.bindGlobalFunction("pointtostring", [](const Point& v) { return stdext::to_string(v); }); + g_lua.bindGlobalFunction("colortostring", [](const Color& v) { return stdext::to_string(v); }); + g_lua.bindGlobalFunction("sizetostring", [](const Size& v) { return stdext::to_string(v); }); + g_lua.bindGlobalFunction("iptostring", [](uint32 v) { return stdext::ip_to_string(v); }); + g_lua.bindGlobalFunction("stringtoip", [](const std::string& v) { return stdext::string_to_ip(v); }); + g_lua.bindGlobalFunction("listSubnetAddresses", [](uint32 a, uint8 b) { return stdext::listSubnetAddresses(a, b); }); + g_lua.bindGlobalFunction("ucwords", [](std::string s) { return stdext::ucwords(s); }); + g_lua.bindGlobalFunction("regexMatch", [](std::string s, const std::string& exp) { + int limit = 10000; + std::vector> ret; + if (s.empty() || exp.empty()) + return ret; + try { + std::smatch m; + std::regex e(exp); + while (std::regex_search (s,m,e)) { + ret.push_back(std::vector()); + for (auto x:m) + ret[ret.size() - 1].push_back(x); + s = m.suffix().str(); + if (--limit == 0) + return ret; + } + } catch (...) { + } + return ret; + }); + + // Platform + g_lua.registerSingletonClass("g_platform"); + g_lua.bindSingletonFunction("g_platform", "spawnProcess", &Platform::spawnProcess, &g_platform); + g_lua.bindSingletonFunction("g_platform", "getProcessId", &Platform::getProcessId, &g_platform); + g_lua.bindSingletonFunction("g_platform", "isProcessRunning", &Platform::isProcessRunning, &g_platform); + g_lua.bindSingletonFunction("g_platform", "copyFile", &Platform::copyFile, &g_platform); + g_lua.bindSingletonFunction("g_platform", "fileExists", &Platform::fileExists, &g_platform); + g_lua.bindSingletonFunction("g_platform", "removeFile", &Platform::removeFile, &g_platform); + g_lua.bindSingletonFunction("g_platform", "killProcess", &Platform::killProcess, &g_platform); + g_lua.bindSingletonFunction("g_platform", "getTempPath", &Platform::getTempPath, &g_platform); + g_lua.bindSingletonFunction("g_platform", "openUrl", &Platform::openUrl, &g_platform); + g_lua.bindSingletonFunction("g_platform", "openDir", &Platform::openDir, &g_platform); + g_lua.bindSingletonFunction("g_platform", "getCPUName", &Platform::getCPUName, &g_platform); + g_lua.bindSingletonFunction("g_platform", "getTotalSystemMemory", &Platform::getTotalSystemMemory, &g_platform); + g_lua.bindSingletonFunction("g_platform", "getMemoryUsage", &Platform::getMemoryUsage, &g_platform); + g_lua.bindSingletonFunction("g_platform", "getOSName", &Platform::getOSName, &g_platform); + g_lua.bindSingletonFunction("g_platform", "getFileModificationTime", &Platform::getFileModificationTime, &g_platform); + + // Application + g_lua.registerSingletonClass("g_app"); + g_lua.bindSingletonFunction("g_app", "setName", &Application::setName, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "setCompactName", &Application::setCompactName, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "setVersion", &Application::setVersion, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "isRunning", &Application::isRunning, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "isStopping", &Application::isStopping, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "getName", &Application::getName, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "getCompactName", &Application::getCompactName, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "getVersion", &Application::getVersion, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "getBuildCompiler", &Application::getBuildCompiler, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "getBuildDate", &Application::getBuildDate, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "getBuildRevision", &Application::getBuildRevision, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "getBuildCommit", &Application::getBuildCommit, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "getBuildType", &Application::getBuildType, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "getBuildArch", &Application::getBuildArch, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "getAuthor", &Application::getAuthor, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "getOs", &Application::getOs, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "getStartupOptions", &Application::getStartupOptions, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "exit", &Application::exit, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "quick_exit", &Application::quick_exit, static_cast(&g_app)); + + // Crypt + g_lua.registerSingletonClass("g_crypt"); + g_lua.bindSingletonFunction("g_crypt", "genUUID", &Crypt::genUUID, &g_crypt); + g_lua.bindSingletonFunction("g_crypt", "setMachineUUID", &Crypt::setMachineUUID, &g_crypt); + g_lua.bindSingletonFunction("g_crypt", "getMachineUUID", &Crypt::getMachineUUID, &g_crypt); + g_lua.bindSingletonFunction("g_crypt", "encrypt", &Crypt::encrypt, &g_crypt); + g_lua.bindSingletonFunction("g_crypt", "decrypt", &Crypt::decrypt, &g_crypt); + g_lua.bindSingletonFunction("g_crypt", "sha1Encode", &Crypt::sha1Encode, &g_crypt); + g_lua.bindSingletonFunction("g_crypt", "md5Encode", &Crypt::md5Encode, &g_crypt); + g_lua.bindSingletonFunction("g_crypt", "rsaGenerateKey", &Crypt::rsaGenerateKey, &g_crypt); + g_lua.bindSingletonFunction("g_crypt", "rsaSetPublicKey", &Crypt::rsaSetPublicKey, &g_crypt); + g_lua.bindSingletonFunction("g_crypt", "rsaSetPrivateKey", &Crypt::rsaSetPrivateKey, &g_crypt); + g_lua.bindSingletonFunction("g_crypt", "rsaCheckKey", &Crypt::rsaCheckKey, &g_crypt); + g_lua.bindSingletonFunction("g_crypt", "rsaGetSize", &Crypt::rsaGetSize, &g_crypt); + + // Clock + g_lua.registerSingletonClass("g_clock"); + g_lua.bindSingletonFunction("g_clock", "micros", &Clock::micros, &g_clock); + g_lua.bindSingletonFunction("g_clock", "millis", &Clock::millis, &g_clock); + g_lua.bindSingletonFunction("g_clock", "seconds", &Clock::seconds, &g_clock); + g_lua.bindSingletonFunction("g_clock", "realMillis", &Clock::realMillis, &g_clock); + g_lua.bindSingletonFunction("g_clock", "realMicros", &Clock::realMicros, &g_clock); + + // ConfigManager + g_lua.registerSingletonClass("g_configs"); + g_lua.bindSingletonFunction("g_configs", "getSettings", &ConfigManager::getSettings, &g_configs); + g_lua.bindSingletonFunction("g_configs", "get", &ConfigManager::get, &g_configs); + g_lua.bindSingletonFunction("g_configs", "loadSettings", &ConfigManager::loadSettings, &g_configs); + g_lua.bindSingletonFunction("g_configs", "load", &ConfigManager::load, &g_configs); + g_lua.bindSingletonFunction("g_configs", "unload", &ConfigManager::unload, &g_configs); + g_lua.bindSingletonFunction("g_configs", "create", &ConfigManager::create, &g_configs); + + // Logger + g_lua.registerSingletonClass("g_logger"); + g_lua.bindSingletonFunction("g_logger", "log", &Logger::log, &g_logger); + g_lua.bindSingletonFunction("g_logger", "fireOldMessages", &Logger::fireOldMessages, &g_logger); + g_lua.bindSingletonFunction("g_logger", "setLogFile", &Logger::setLogFile, &g_logger); + g_lua.bindSingletonFunction("g_logger", "setOnLog", &Logger::setOnLog, &g_logger); + g_lua.bindSingletonFunction("g_logger", "debug", &Logger::debug, &g_logger); + g_lua.bindSingletonFunction("g_logger", "info", &Logger::info, &g_logger); + g_lua.bindSingletonFunction("g_logger", "warning", &Logger::warning, &g_logger); + g_lua.bindSingletonFunction("g_logger", "error", &Logger::error, &g_logger); + g_lua.bindSingletonFunction("g_logger", "fatal", &Logger::fatal, &g_logger); + g_lua.bindSingletonFunction("g_logger", "getLastLog", &Logger::getLastLog, &g_logger); + + // Lua stats + g_lua.registerSingletonClass("g_stats"); + g_lua.bindSingletonFunction("g_stats", "types", &Stats::types, &g_stats); + g_lua.bindSingletonFunction("g_stats", "get", &Stats::get, &g_stats); + g_lua.bindSingletonFunction("g_stats", "clear", &Stats::clear, &g_stats); + g_lua.bindSingletonFunction("g_stats", "clearAll", &Stats::clearAll, &g_stats); + g_lua.bindSingletonFunction("g_stats", "getSlow", &Stats::getSlow, &g_stats); + g_lua.bindSingletonFunction("g_stats", "clearSlow", &Stats::clearSlow, &g_stats); + g_lua.bindSingletonFunction("g_stats", "getSleepTime", &Stats::getSleepTime, &g_stats); + g_lua.bindSingletonFunction("g_stats", "resetSleepTime", &Stats::resetSleepTime, &g_stats); + g_lua.bindSingletonFunction("g_stats", "getWidgetsInfo", &Stats::getWidgetsInfo, &g_stats); + + g_lua.registerSingletonClass("g_extras"); + g_lua.bindSingletonFunction("g_extras", "set", &Extras::set, &g_extras); + g_lua.bindSingletonFunction("g_extras", "get", &Extras::get, &g_extras); + g_lua.bindSingletonFunction("g_extras", "getDescription", &Extras::getDescription, &g_extras); + g_lua.bindSingletonFunction("g_extras", "getAll", &Extras::getAll, &g_extras); + + g_lua.registerSingletonClass("g_http"); + g_lua.bindSingletonFunction("g_http", "get", &Http::get, &g_http); + g_lua.bindSingletonFunction("g_http", "post", &Http::post, &g_http); + g_lua.bindSingletonFunction("g_http", "download", &Http::download, &g_http); + g_lua.bindSingletonFunction("g_http", "ws", &Http::ws, &g_http); + g_lua.bindSingletonFunction("g_http", "wsSend", &Http::wsSend, &g_http); + g_lua.bindSingletonFunction("g_http", "wsClose", &Http::wsClose, &g_http); + g_lua.bindSingletonFunction("g_http", "cancel", &Http::cancel, &g_http); + + g_lua.registerSingletonClass("g_atlas"); + g_lua.bindSingletonFunction("g_atlas", "getStats", &Atlas::getStats, &g_atlas); + g_lua.bindSingletonFunction("g_atlas", "reset", &Atlas::reset, &g_atlas); + + // ModuleManager + g_lua.registerSingletonClass("g_modules"); + g_lua.bindSingletonFunction("g_modules", "discoverModules", &ModuleManager::discoverModules, &g_modules); + g_lua.bindSingletonFunction("g_modules", "autoLoadModules", &ModuleManager::autoLoadModules, &g_modules); + g_lua.bindSingletonFunction("g_modules", "discoverModule", &ModuleManager::discoverModule, &g_modules); + g_lua.bindSingletonFunction("g_modules", "ensureModuleLoaded", &ModuleManager::ensureModuleLoaded, &g_modules); + g_lua.bindSingletonFunction("g_modules", "unloadModules", &ModuleManager::unloadModules, &g_modules); + g_lua.bindSingletonFunction("g_modules", "reloadModules", &ModuleManager::reloadModules, &g_modules); + g_lua.bindSingletonFunction("g_modules", "getModule", &ModuleManager::getModule, &g_modules); + g_lua.bindSingletonFunction("g_modules", "getModules", &ModuleManager::getModules, &g_modules); + + // EventDispatcher + g_lua.registerSingletonClass("g_dispatcher"); + g_lua.bindSingletonFunction("g_dispatcher", "addEvent", &EventDispatcher::addEventEx, &g_dispatcher); + g_lua.bindSingletonFunction("g_dispatcher", "scheduleEvent", &EventDispatcher::scheduleEventEx, &g_dispatcher); + g_lua.bindSingletonFunction("g_dispatcher", "cycleEvent", &EventDispatcher::cycleEventEx, &g_dispatcher); + + // ResourceManager + g_lua.registerSingletonClass("g_resources"); + g_lua.bindSingletonFunction("g_resources", "fileExists", &ResourceManager::fileExists, &g_resources); + g_lua.bindSingletonFunction("g_resources", "directoryExists", &ResourceManager::directoryExists, &g_resources); + g_lua.bindSingletonFunction("g_resources", "getWorkDir", &ResourceManager::getWorkDir, &g_resources); + g_lua.bindSingletonFunction("g_resources", "getWriteDir", &ResourceManager::getWriteDir, &g_resources); + g_lua.bindSingletonFunction("g_resources", "getBinaryName", &ResourceManager::getBinaryName, &g_resources); + g_lua.bindSingletonFunction("g_resources", "listDirectoryFiles", &ResourceManager::listDirectoryFiles, &g_resources); + g_lua.bindSingletonFunction("g_resources", "isFileType", &ResourceManager::isFileType, &g_resources); + g_lua.bindSingletonFunction("g_resources", "readFileContents", &ResourceManager::readFileContentsSafe, &g_resources); + g_lua.bindSingletonFunction("g_resources", "writeFileContents", &ResourceManager::writeFileContents, &g_resources); + g_lua.bindSingletonFunction("g_resources", "guessFilePath", &ResourceManager::guessFilePath, &g_resources); + g_lua.bindSingletonFunction("g_resources", "makeDir", &ResourceManager::makeDir, &g_resources); + g_lua.bindSingletonFunction("g_resources", "deleteFile", &ResourceManager::deleteFile, &g_resources); + g_lua.bindSingletonFunction("g_resources", "readCrashLog", &ResourceManager::readCrashLog, &g_resources); + g_lua.bindSingletonFunction("g_resources", "deleteCrashLog", &ResourceManager::deleteCrashLog, &g_resources); + + g_lua.bindSingletonFunction("g_resources", "resolvePath", &ResourceManager::resolvePath, &g_resources); + g_lua.bindSingletonFunction("g_resources", "isLoadedFromMemory", &ResourceManager::isLoadedFromMemory, &g_resources); + g_lua.bindSingletonFunction("g_resources", "isLoadedFromArchive", &ResourceManager::isLoadedFromArchive, &g_resources); + g_lua.bindSingletonFunction("g_resources", "listUpdateableFiles", &ResourceManager::listUpdateableFiles, &g_resources); + g_lua.bindSingletonFunction("g_resources", "fileChecksum", &ResourceManager::fileChecksum, &g_resources); + g_lua.bindSingletonFunction("g_resources", "selfChecksum", &ResourceManager::selfChecksum, &g_resources); + g_lua.bindSingletonFunction("g_resources", "updateClient", &ResourceManager::updateClient, &g_resources); + + // Config + g_lua.registerClass(); + g_lua.bindClassMemberFunction("save", &Config::save); + g_lua.bindClassMemberFunction("setValue", &Config::setValue); + g_lua.bindClassMemberFunction("setList", &Config::setList); + g_lua.bindClassMemberFunction("getValue", &Config::getValue); + g_lua.bindClassMemberFunction("getList", &Config::getList); + g_lua.bindClassMemberFunction("exists", &Config::exists); + g_lua.bindClassMemberFunction("remove", &Config::remove); + g_lua.bindClassMemberFunction("setNode", &Config::setNode); + g_lua.bindClassMemberFunction("getNode", &Config::getNode); + g_lua.bindClassMemberFunction("mergeNode", &Config::mergeNode); + g_lua.bindClassMemberFunction("getFileName", &Config::getFileName); + + // Module + g_lua.registerClass(); + g_lua.bindClassMemberFunction("load", &Module::load); + g_lua.bindClassMemberFunction("unload", &Module::unload); + g_lua.bindClassMemberFunction("reload", &Module::reload); + g_lua.bindClassMemberFunction("canReload", &Module::canReload); + g_lua.bindClassMemberFunction("canUnload", &Module::canUnload); + g_lua.bindClassMemberFunction("isLoaded", &Module::isLoaded); + g_lua.bindClassMemberFunction("isReloadble", &Module::isReloadable); + g_lua.bindClassMemberFunction("isSandboxed", &Module::isSandboxed); + g_lua.bindClassMemberFunction("getDescription", &Module::getDescription); + g_lua.bindClassMemberFunction("getName", &Module::getName); + g_lua.bindClassMemberFunction("getAuthor", &Module::getAuthor); + g_lua.bindClassMemberFunction("getWebsite", &Module::getWebsite); + g_lua.bindClassMemberFunction("getVersion", &Module::getVersion); + g_lua.bindClassMemberFunction("getSandbox", &Module::getSandbox); + g_lua.bindClassMemberFunction("isAutoLoad", &Module::isAutoLoad); + g_lua.bindClassMemberFunction("getAutoLoadPriority", &Module::getAutoLoadPriority); + + // Event + g_lua.registerClass(); + g_lua.bindClassMemberFunction("cancel", &Event::cancel); + g_lua.bindClassMemberFunction("execute", &Event::execute); + g_lua.bindClassMemberFunction("isCanceled", &Event::isCanceled); + g_lua.bindClassMemberFunction("isExecuted", &Event::isExecuted); + + // ScheduledEvent + g_lua.registerClass(); + g_lua.bindClassMemberFunction("nextCycle", &ScheduledEvent::nextCycle); + g_lua.bindClassMemberFunction("ticks", &ScheduledEvent::ticks); + g_lua.bindClassMemberFunction("remainingTicks", &ScheduledEvent::remainingTicks); + g_lua.bindClassMemberFunction("delay", &ScheduledEvent::delay); + g_lua.bindClassMemberFunction("cyclesExecuted", &ScheduledEvent::cyclesExecuted); + g_lua.bindClassMemberFunction("maxCycles", &ScheduledEvent::maxCycles); + +#ifdef FW_GRAPHICS + // GraphicalApplication + g_lua.bindSingletonFunction("g_app", "setMaxFps", &GraphicalApplication::setMaxFps, &g_app); + g_lua.bindSingletonFunction("g_app", "getMaxFps", &GraphicalApplication::getMaxFps, &g_app); + g_lua.bindSingletonFunction("g_app", "getFps", &GraphicalApplication::getFps, &g_app); + g_lua.bindSingletonFunction("g_app", "isOnInputEvent", &GraphicalApplication::isOnInputEvent, &g_app); + g_lua.bindSingletonFunction("g_app", "doScreenshot", &GraphicalApplication::doScreenshot, &g_app); + + // AdaptiveRenderer + g_lua.registerSingletonClass("g_adaptiveRenderer"); + g_lua.bindSingletonFunction("g_adaptiveRenderer", "getLevel", &AdaptiveRenderer::getLevel, &g_adaptiveRenderer); + g_lua.bindSingletonFunction("g_adaptiveRenderer", "setLevel", &AdaptiveRenderer::setForcedLevel, &g_adaptiveRenderer); + g_lua.bindSingletonFunction("g_adaptiveRenderer", "getDebugInfo", &AdaptiveRenderer::getDebugInfo, &g_adaptiveRenderer); + + // PlatformWindow + g_lua.registerSingletonClass("g_window"); + g_lua.bindSingletonFunction("g_window", "move", &PlatformWindow::move, &g_window); + g_lua.bindSingletonFunction("g_window", "resize", &PlatformWindow::resize, &g_window); + g_lua.bindSingletonFunction("g_window", "show", &PlatformWindow::show, &g_window); + g_lua.bindSingletonFunction("g_window", "hide", &PlatformWindow::hide, &g_window); + g_lua.bindSingletonFunction("g_window", "poll", &PlatformWindow::poll, &g_window); + g_lua.bindSingletonFunction("g_window", "maximize", &PlatformWindow::maximize, &g_window); + g_lua.bindSingletonFunction("g_window", "restoreMouseCursor", &PlatformWindow::restoreMouseCursor, &g_window); + g_lua.bindSingletonFunction("g_window", "showMouse", &PlatformWindow::showMouse, &g_window); + g_lua.bindSingletonFunction("g_window", "hideMouse", &PlatformWindow::hideMouse, &g_window); + g_lua.bindSingletonFunction("g_window", "setTitle", &PlatformWindow::setTitle, &g_window); + g_lua.bindSingletonFunction("g_window", "setMouseCursor", &PlatformWindow::setMouseCursor, &g_window); + g_lua.bindSingletonFunction("g_window", "setMinimumSize", &PlatformWindow::setMinimumSize, &g_window); + g_lua.bindSingletonFunction("g_window", "setFullscreen", &PlatformWindow::setFullscreen, &g_window); + g_lua.bindSingletonFunction("g_window", "setVerticalSync", &PlatformWindow::setVerticalSync, &g_window); + g_lua.bindSingletonFunction("g_window", "setIcon", &PlatformWindow::setIcon, &g_window); + g_lua.bindSingletonFunction("g_window", "setClipboardText", &PlatformWindow::setClipboardText, &g_window); + g_lua.bindSingletonFunction("g_window", "getDisplaySize", &PlatformWindow::getDisplaySize, &g_window); + g_lua.bindSingletonFunction("g_window", "getClipboardText", &PlatformWindow::getClipboardText, &g_window); + g_lua.bindSingletonFunction("g_window", "getPlatformType", &PlatformWindow::getPlatformType, &g_window); + g_lua.bindSingletonFunction("g_window", "getDisplayWidth", &PlatformWindow::getDisplayWidth, &g_window); + g_lua.bindSingletonFunction("g_window", "getDisplayHeight", &PlatformWindow::getDisplayHeight, &g_window); + g_lua.bindSingletonFunction("g_window", "getUnmaximizedSize", &PlatformWindow::getUnmaximizedSize, &g_window); + g_lua.bindSingletonFunction("g_window", "getSize", &PlatformWindow::getSize, &g_window); + g_lua.bindSingletonFunction("g_window", "getWidth", &PlatformWindow::getWidth, &g_window); + g_lua.bindSingletonFunction("g_window", "getHeight", &PlatformWindow::getHeight, &g_window); + g_lua.bindSingletonFunction("g_window", "getUnmaximizedPos", &PlatformWindow::getUnmaximizedPos, &g_window); + g_lua.bindSingletonFunction("g_window", "getPosition", &PlatformWindow::getPosition, &g_window); + g_lua.bindSingletonFunction("g_window", "getX", &PlatformWindow::getX, &g_window); + g_lua.bindSingletonFunction("g_window", "getY", &PlatformWindow::getY, &g_window); + g_lua.bindSingletonFunction("g_window", "getMousePosition", &PlatformWindow::getMousePosition, &g_window); + g_lua.bindSingletonFunction("g_window", "getKeyboardModifiers", &PlatformWindow::getKeyboardModifiers, &g_window); + g_lua.bindSingletonFunction("g_window", "isKeyPressed", &PlatformWindow::isKeyPressed, &g_window); + g_lua.bindSingletonFunction("g_window", "isMouseButtonPressed", &PlatformWindow::isMouseButtonPressed, &g_window); + g_lua.bindSingletonFunction("g_window", "isVisible", &PlatformWindow::isVisible, &g_window); + g_lua.bindSingletonFunction("g_window", "isFullscreen", &PlatformWindow::isFullscreen, &g_window); + g_lua.bindSingletonFunction("g_window", "isMaximized", &PlatformWindow::isMaximized, &g_window); + g_lua.bindSingletonFunction("g_window", "hasFocus", &PlatformWindow::hasFocus, &g_window); + + // Input + g_lua.registerSingletonClass("g_mouse"); + g_lua.bindSingletonFunction("g_mouse", "loadCursors", &Mouse::loadCursors, &g_mouse); + g_lua.bindSingletonFunction("g_mouse", "addCursor", &Mouse::addCursor, &g_mouse); + g_lua.bindSingletonFunction("g_mouse", "pushCursor", &Mouse::pushCursor, &g_mouse); + g_lua.bindSingletonFunction("g_mouse", "popCursor", &Mouse::popCursor, &g_mouse); + g_lua.bindSingletonFunction("g_mouse", "isCursorChanged", &Mouse::isCursorChanged, &g_mouse); + g_lua.bindSingletonFunction("g_mouse", "isPressed", &Mouse::isPressed, &g_mouse); + + // Graphics + g_lua.registerSingletonClass("g_graphics"); + g_lua.bindSingletonFunction("g_graphics", "canCacheBackbuffer", &Graphics::canCacheBackbuffer, &g_graphics); + g_lua.bindSingletonFunction("g_graphics", "canUseShaders", &Graphics::canUseShaders, &g_graphics); + g_lua.bindSingletonFunction("g_graphics", "shouldUseShaders", &Graphics::shouldUseShaders, &g_graphics); + g_lua.bindSingletonFunction("g_graphics", "setShouldUseShaders", &Graphics::setShouldUseShaders, &g_graphics); + g_lua.bindSingletonFunction("g_graphics", "getViewportSize", &Graphics::getViewportSize, &g_graphics); + g_lua.bindSingletonFunction("g_graphics", "getVendor", &Graphics::getVendor, &g_graphics); + g_lua.bindSingletonFunction("g_graphics", "getRenderer", &Graphics::getRenderer, &g_graphics); + g_lua.bindSingletonFunction("g_graphics", "getVersion", &Graphics::getVersion, &g_graphics); + + // Textures + g_lua.registerSingletonClass("g_textures"); + g_lua.bindSingletonFunction("g_textures", "preload", &TextureManager::preload, &g_textures); + g_lua.bindSingletonFunction("g_textures", "clearCache", &TextureManager::clearCache, &g_textures); + g_lua.bindSingletonFunction("g_textures", "reload", &TextureManager::reload, &g_textures); + + // UI + g_lua.registerSingletonClass("g_ui"); + g_lua.bindSingletonFunction("g_ui", "clearStyles", &UIManager::clearStyles, &g_ui); + g_lua.bindSingletonFunction("g_ui", "importStyle", &UIManager::importStyle, &g_ui); + g_lua.bindSingletonFunction("g_ui", "getStyle", &UIManager::getStyle, &g_ui); + g_lua.bindSingletonFunction("g_ui", "getStyleClass", &UIManager::getStyleClass, &g_ui); + g_lua.bindSingletonFunction("g_ui", "loadUI", &UIManager::loadUI, &g_ui); + g_lua.bindSingletonFunction("g_ui", "loadUIFromString", &UIManager::loadUIFromString, &g_ui); + g_lua.bindSingletonFunction("g_ui", "displayUI", &UIManager::displayUI, &g_ui); + g_lua.bindSingletonFunction("g_ui", "createWidget", &UIManager::createWidget, &g_ui); + g_lua.bindSingletonFunction("g_ui", "createWidgetFromOTML", &UIManager::createWidgetFromOTML, &g_ui); + g_lua.bindSingletonFunction("g_ui", "getRootWidget", &UIManager::getRootWidget, &g_ui); + g_lua.bindSingletonFunction("g_ui", "getDraggingWidget", &UIManager::getDraggingWidget, &g_ui); + g_lua.bindSingletonFunction("g_ui", "getPressedWidget", &UIManager::getPressedWidget, &g_ui); + g_lua.bindSingletonFunction("g_ui", "setDebugBoxesDrawing", &UIManager::setDebugBoxesDrawing, &g_ui); + g_lua.bindSingletonFunction("g_ui", "isDrawingDebugBoxes", &UIManager::isDrawingDebugBoxes, &g_ui); + g_lua.bindSingletonFunction("g_ui", "isMouseGrabbed", &UIManager::isMouseGrabbed, &g_ui); + g_lua.bindSingletonFunction("g_ui", "isKeyboardGrabbed", &UIManager::isKeyboardGrabbed, &g_ui); + + // FontManager + g_lua.registerSingletonClass("g_fonts"); + g_lua.bindSingletonFunction("g_fonts", "clearFonts", &FontManager::clearFonts, &g_fonts); + g_lua.bindSingletonFunction("g_fonts", "importFont", &FontManager::importFont, &g_fonts); + g_lua.bindSingletonFunction("g_fonts", "fontExists", &FontManager::fontExists, &g_fonts); + g_lua.bindSingletonFunction("g_fonts", "setDefaultFont", &FontManager::setDefaultFont, &g_fonts); + + // ParticleManager + g_lua.registerSingletonClass("g_particles"); + g_lua.bindSingletonFunction("g_particles", "importParticle", &ParticleManager::importParticle, &g_particles); + g_lua.bindSingletonFunction("g_particles", "getEffectsTypes", &ParticleManager::getEffectsTypes, &g_particles); + + // UIWidget + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return UIWidgetPtr(new UIWidget); }); + g_lua.bindClassMemberFunction("addChild", &UIWidget::addChild); + g_lua.bindClassMemberFunction("insertChild", &UIWidget::insertChild); + g_lua.bindClassMemberFunction("removeChild", &UIWidget::removeChild); + g_lua.bindClassMemberFunction("focusChild", &UIWidget::focusChild); + g_lua.bindClassMemberFunction("focusNextChild", &UIWidget::focusNextChild); + g_lua.bindClassMemberFunction("focusPreviousChild", &UIWidget::focusPreviousChild); + g_lua.bindClassMemberFunction("lowerChild", &UIWidget::lowerChild); + g_lua.bindClassMemberFunction("raiseChild", &UIWidget::raiseChild); + g_lua.bindClassMemberFunction("moveChildToIndex", &UIWidget::moveChildToIndex); + g_lua.bindClassMemberFunction("reorderChildrens", &UIWidget::reorderChildrens); + g_lua.bindClassMemberFunction("lockChild", &UIWidget::lockChild); + g_lua.bindClassMemberFunction("unlockChild", &UIWidget::unlockChild); + g_lua.bindClassMemberFunction("mergeStyle", &UIWidget::mergeStyle); + g_lua.bindClassMemberFunction("applyStyle", &UIWidget::applyStyle); + g_lua.bindClassMemberFunction("addAnchor", &UIWidget::addAnchor); + g_lua.bindClassMemberFunction("removeAnchor", &UIWidget::removeAnchor); + g_lua.bindClassMemberFunction("fill", &UIWidget::fill); + g_lua.bindClassMemberFunction("centerIn", &UIWidget::centerIn); + g_lua.bindClassMemberFunction("breakAnchors", &UIWidget::breakAnchors); + g_lua.bindClassMemberFunction("updateParentLayout", &UIWidget::updateParentLayout); + g_lua.bindClassMemberFunction("updateLayout", &UIWidget::updateLayout); + g_lua.bindClassMemberFunction("lock", &UIWidget::lock); + g_lua.bindClassMemberFunction("unlock", &UIWidget::unlock); + g_lua.bindClassMemberFunction("focus", &UIWidget::focus); + g_lua.bindClassMemberFunction("lower", &UIWidget::lower); + g_lua.bindClassMemberFunction("raise", &UIWidget::raise); + g_lua.bindClassMemberFunction("grabMouse", &UIWidget::grabMouse); + g_lua.bindClassMemberFunction("ungrabMouse", &UIWidget::ungrabMouse); + g_lua.bindClassMemberFunction("grabKeyboard", &UIWidget::grabKeyboard); + g_lua.bindClassMemberFunction("ungrabKeyboard", &UIWidget::ungrabKeyboard); + g_lua.bindClassMemberFunction("bindRectToParent", &UIWidget::bindRectToParent); + g_lua.bindClassMemberFunction("destroy", &UIWidget::destroy); + g_lua.bindClassMemberFunction("destroyChildren", &UIWidget::destroyChildren); + g_lua.bindClassMemberFunction("setId", &UIWidget::setId); + g_lua.bindClassMemberFunction("setParent", &UIWidget::setParent); + g_lua.bindClassMemberFunction("setLayout", &UIWidget::setLayout); + g_lua.bindClassMemberFunction("setRect", &UIWidget::setRect); + g_lua.bindClassMemberFunction("setStyle", &UIWidget::setStyle); + g_lua.bindClassMemberFunction("setStyleFromNode", &UIWidget::setStyleFromNode); + g_lua.bindClassMemberFunction("setEnabled", &UIWidget::setEnabled); + g_lua.bindClassMemberFunction("setVisible", &UIWidget::setVisible); + g_lua.bindClassMemberFunction("setOn", &UIWidget::setOn); + g_lua.bindClassMemberFunction("setChecked", &UIWidget::setChecked); + g_lua.bindClassMemberFunction("setFocusable", &UIWidget::setFocusable); + g_lua.bindClassMemberFunction("setPhantom", &UIWidget::setPhantom); + g_lua.bindClassMemberFunction("setDraggable", &UIWidget::setDraggable); + g_lua.bindClassMemberFunction("setFixedSize", &UIWidget::setFixedSize); + g_lua.bindClassMemberFunction("setClipping", &UIWidget::setClipping); + g_lua.bindClassMemberFunction("setLastFocusReason", &UIWidget::setLastFocusReason); + g_lua.bindClassMemberFunction("setAutoFocusPolicy", &UIWidget::setAutoFocusPolicy); + g_lua.bindClassMemberFunction("setAutoRepeatDelay", &UIWidget::setAutoRepeatDelay); + g_lua.bindClassMemberFunction("setVirtualOffset", &UIWidget::setVirtualOffset); + g_lua.bindClassMemberFunction("isVisible", &UIWidget::isVisible); + g_lua.bindClassMemberFunction("isChildLocked", &UIWidget::isChildLocked); + g_lua.bindClassMemberFunction("hasChild", &UIWidget::hasChild); + g_lua.bindClassMemberFunction("getChildIndex", &UIWidget::getChildIndex); + g_lua.bindClassMemberFunction("getMarginRect", &UIWidget::getMarginRect); + g_lua.bindClassMemberFunction("getPaddingRect", &UIWidget::getPaddingRect); + g_lua.bindClassMemberFunction("getChildrenRect", &UIWidget::getChildrenRect); + g_lua.bindClassMemberFunction("getAnchoredLayout", &UIWidget::getAnchoredLayout); + g_lua.bindClassMemberFunction("getRootParent", &UIWidget::getRootParent); + g_lua.bindClassMemberFunction("getChildAfter", &UIWidget::getChildAfter); + g_lua.bindClassMemberFunction("getChildBefore", &UIWidget::getChildBefore); + g_lua.bindClassMemberFunction("getChildById", &UIWidget::getChildById); + g_lua.bindClassMemberFunction("getChildByPos", &UIWidget::getChildByPos); + g_lua.bindClassMemberFunction("getChildByIndex", &UIWidget::getChildByIndex); + g_lua.bindClassMemberFunction("recursiveGetChildById", &UIWidget::recursiveGetChildById); + g_lua.bindClassMemberFunction("recursiveGetChildByPos", &UIWidget::recursiveGetChildByPos); + g_lua.bindClassMemberFunction("recursiveGetChildren", &UIWidget::recursiveGetChildren); + g_lua.bindClassMemberFunction("recursiveGetChildrenByPos", &UIWidget::recursiveGetChildrenByPos); + g_lua.bindClassMemberFunction("recursiveGetChildrenByMarginPos", &UIWidget::recursiveGetChildrenByMarginPos); + g_lua.bindClassMemberFunction("backwardsGetWidgetById", &UIWidget::backwardsGetWidgetById); + g_lua.bindClassMemberFunction("resize", &UIWidget::resize); + g_lua.bindClassMemberFunction("move", &UIWidget::move); + g_lua.bindClassMemberFunction("rotate", &UIWidget::rotate); + g_lua.bindClassMemberFunction("hide", &UIWidget::hide); + g_lua.bindClassMemberFunction("show", &UIWidget::show); + g_lua.bindClassMemberFunction("disable", &UIWidget::disable); + g_lua.bindClassMemberFunction("enable", &UIWidget::enable); + g_lua.bindClassMemberFunction("isActive", &UIWidget::isActive); + g_lua.bindClassMemberFunction("isEnabled", &UIWidget::isEnabled); + g_lua.bindClassMemberFunction("isDisabled", &UIWidget::isDisabled); + g_lua.bindClassMemberFunction("isFocused", &UIWidget::isFocused); + g_lua.bindClassMemberFunction("isHovered", &UIWidget::isHovered); + g_lua.bindClassMemberFunction("isPressed", &UIWidget::isPressed); + g_lua.bindClassMemberFunction("isFirst", &UIWidget::isFirst); + g_lua.bindClassMemberFunction("isMiddle", &UIWidget::isMiddle); + g_lua.bindClassMemberFunction("isLast", &UIWidget::isLast); + g_lua.bindClassMemberFunction("isAlternate", &UIWidget::isAlternate); + g_lua.bindClassMemberFunction("isChecked", &UIWidget::isChecked); + g_lua.bindClassMemberFunction("isOn", &UIWidget::isOn); + g_lua.bindClassMemberFunction("isDragging", &UIWidget::isDragging); + g_lua.bindClassMemberFunction("isHidden", &UIWidget::isHidden); + g_lua.bindClassMemberFunction("isExplicitlyEnabled", &UIWidget::isExplicitlyEnabled); + g_lua.bindClassMemberFunction("isExplicitlyVisible", &UIWidget::isExplicitlyVisible); + g_lua.bindClassMemberFunction("isFocusable", &UIWidget::isFocusable); + g_lua.bindClassMemberFunction("isPhantom", &UIWidget::isPhantom); + g_lua.bindClassMemberFunction("isDraggable", &UIWidget::isDraggable); + g_lua.bindClassMemberFunction("isFixedSize", &UIWidget::isFixedSize); + g_lua.bindClassMemberFunction("isClipping", &UIWidget::isClipping); + g_lua.bindClassMemberFunction("isDestroyed", &UIWidget::isDestroyed); + g_lua.bindClassMemberFunction("hasChildren", &UIWidget::hasChildren); + g_lua.bindClassMemberFunction("containsMarginPoint", &UIWidget::containsMarginPoint); + g_lua.bindClassMemberFunction("containsPaddingPoint", &UIWidget::containsPaddingPoint); + g_lua.bindClassMemberFunction("containsPoint", &UIWidget::containsPoint); + g_lua.bindClassMemberFunction("getId", &UIWidget::getId); + g_lua.bindClassMemberFunction("getSource", &UIWidget::getSource); + g_lua.bindClassMemberFunction("getParent", &UIWidget::getParent); + g_lua.bindClassMemberFunction("getFocusedChild", &UIWidget::getFocusedChild); + g_lua.bindClassMemberFunction("getChildren", &UIWidget::getChildren); + g_lua.bindClassMemberFunction("getFirstChild", &UIWidget::getFirstChild); + g_lua.bindClassMemberFunction("getLastChild", &UIWidget::getLastChild); + g_lua.bindClassMemberFunction("getLayout", &UIWidget::getLayout); + g_lua.bindClassMemberFunction("getStyle", &UIWidget::getStyle); + g_lua.bindClassMemberFunction("getChildCount", &UIWidget::getChildCount); + g_lua.bindClassMemberFunction("getLastFocusReason", &UIWidget::getLastFocusReason); + g_lua.bindClassMemberFunction("getAutoFocusPolicy", &UIWidget::getAutoFocusPolicy); + g_lua.bindClassMemberFunction("getAutoRepeatDelay", &UIWidget::getAutoRepeatDelay); + g_lua.bindClassMemberFunction("getVirtualOffset", &UIWidget::getVirtualOffset); + g_lua.bindClassMemberFunction("getStyleName", &UIWidget::getStyleName); + g_lua.bindClassMemberFunction("getLastClickPosition", &UIWidget::getLastClickPosition); + g_lua.bindClassMemberFunction("setX", &UIWidget::setX); + g_lua.bindClassMemberFunction("setY", &UIWidget::setY); + g_lua.bindClassMemberFunction("setWidth", &UIWidget::setWidth); + g_lua.bindClassMemberFunction("setHeight", &UIWidget::setHeight); + g_lua.bindClassMemberFunction("setSize", &UIWidget::setSize); + g_lua.bindClassMemberFunction("setPosition", &UIWidget::setPosition); + g_lua.bindClassMemberFunction("setColor", &UIWidget::setColor); + g_lua.bindClassMemberFunction("setBackgroundColor", &UIWidget::setBackgroundColor); + g_lua.bindClassMemberFunction("setBackgroundOffsetX", &UIWidget::setBackgroundOffsetX); + g_lua.bindClassMemberFunction("setBackgroundOffsetY", &UIWidget::setBackgroundOffsetY); + g_lua.bindClassMemberFunction("setBackgroundOffset", &UIWidget::setBackgroundOffset); + g_lua.bindClassMemberFunction("setBackgroundWidth", &UIWidget::setBackgroundWidth); + g_lua.bindClassMemberFunction("setBackgroundHeight", &UIWidget::setBackgroundHeight); + g_lua.bindClassMemberFunction("setBackgroundSize", &UIWidget::setBackgroundSize); + g_lua.bindClassMemberFunction("setBackgroundRect", &UIWidget::setBackgroundRect); + g_lua.bindClassMemberFunction("setIcon", &UIWidget::setIcon); + g_lua.bindClassMemberFunction("setIconColor", &UIWidget::setIconColor); + g_lua.bindClassMemberFunction("setIconOffsetX", &UIWidget::setIconOffsetX); + g_lua.bindClassMemberFunction("setIconOffsetY", &UIWidget::setIconOffsetY); + g_lua.bindClassMemberFunction("setIconOffset", &UIWidget::setIconOffset); + g_lua.bindClassMemberFunction("setIconWidth", &UIWidget::setIconWidth); + g_lua.bindClassMemberFunction("setIconHeight", &UIWidget::setIconHeight); + g_lua.bindClassMemberFunction("setIconSize", &UIWidget::setIconSize); + g_lua.bindClassMemberFunction("setIconRect", &UIWidget::setIconRect); + g_lua.bindClassMemberFunction("setIconClip", &UIWidget::setIconClip); + g_lua.bindClassMemberFunction("setIconAlign", &UIWidget::setIconAlign); + g_lua.bindClassMemberFunction("setBorderWidth", &UIWidget::setBorderWidth); + g_lua.bindClassMemberFunction("setBorderWidthTop", &UIWidget::setBorderWidthTop); + g_lua.bindClassMemberFunction("setBorderWidthRight", &UIWidget::setBorderWidthRight); + g_lua.bindClassMemberFunction("setBorderWidthBottom", &UIWidget::setBorderWidthBottom); + g_lua.bindClassMemberFunction("setBorderWidthLeft", &UIWidget::setBorderWidthLeft); + g_lua.bindClassMemberFunction("setBorderColor", &UIWidget::setBorderColor); + g_lua.bindClassMemberFunction("setBorderColorTop", &UIWidget::setBorderColorTop); + g_lua.bindClassMemberFunction("setBorderColorRight", &UIWidget::setBorderColorRight); + g_lua.bindClassMemberFunction("setBorderColorBottom", &UIWidget::setBorderColorBottom); + g_lua.bindClassMemberFunction("setBorderColorLeft", &UIWidget::setBorderColorLeft); + g_lua.bindClassMemberFunction("setMargin", &UIWidget::setMargin); + g_lua.bindClassMemberFunction("setMarginHorizontal", &UIWidget::setMarginHorizontal); + g_lua.bindClassMemberFunction("setMarginVertical", &UIWidget::setMarginVertical); + g_lua.bindClassMemberFunction("setMarginTop", &UIWidget::setMarginTop); + g_lua.bindClassMemberFunction("setMarginRight", &UIWidget::setMarginRight); + g_lua.bindClassMemberFunction("setMarginBottom", &UIWidget::setMarginBottom); + g_lua.bindClassMemberFunction("setMarginLeft", &UIWidget::setMarginLeft); + g_lua.bindClassMemberFunction("setPadding", &UIWidget::setPadding); + g_lua.bindClassMemberFunction("setPaddingHorizontal", &UIWidget::setPaddingHorizontal); + g_lua.bindClassMemberFunction("setPaddingVertical", &UIWidget::setPaddingVertical); + g_lua.bindClassMemberFunction("setPaddingTop", &UIWidget::setPaddingTop); + g_lua.bindClassMemberFunction("setPaddingRight", &UIWidget::setPaddingRight); + g_lua.bindClassMemberFunction("setPaddingBottom", &UIWidget::setPaddingBottom); + g_lua.bindClassMemberFunction("setPaddingLeft", &UIWidget::setPaddingLeft); + g_lua.bindClassMemberFunction("setOpacity", &UIWidget::setOpacity); + g_lua.bindClassMemberFunction("setRotation", &UIWidget::setRotation); + g_lua.bindClassMemberFunction("getX", &UIWidget::getX); + g_lua.bindClassMemberFunction("getY", &UIWidget::getY); + g_lua.bindClassMemberFunction("getPosition", &UIWidget::getPosition); + g_lua.bindClassMemberFunction("getWidth", &UIWidget::getWidth); + g_lua.bindClassMemberFunction("getHeight", &UIWidget::getHeight); + g_lua.bindClassMemberFunction("getSize", &UIWidget::getSize); + g_lua.bindClassMemberFunction("getRect", &UIWidget::getRect); + g_lua.bindClassMemberFunction("getColor", &UIWidget::getColor); + g_lua.bindClassMemberFunction("getBackgroundColor", &UIWidget::getBackgroundColor); + g_lua.bindClassMemberFunction("getBackgroundOffsetX", &UIWidget::getBackgroundOffsetX); + g_lua.bindClassMemberFunction("getBackgroundOffsetY", &UIWidget::getBackgroundOffsetY); + g_lua.bindClassMemberFunction("getBackgroundOffset", &UIWidget::getBackgroundOffset); + g_lua.bindClassMemberFunction("getBackgroundWidth", &UIWidget::getBackgroundWidth); + g_lua.bindClassMemberFunction("getBackgroundHeight", &UIWidget::getBackgroundHeight); + g_lua.bindClassMemberFunction("getBackgroundSize", &UIWidget::getBackgroundSize); + g_lua.bindClassMemberFunction("getBackgroundRect", &UIWidget::getBackgroundRect); + g_lua.bindClassMemberFunction("getIconColor", &UIWidget::getIconColor); + g_lua.bindClassMemberFunction("getIconOffsetX", &UIWidget::getIconOffsetX); + g_lua.bindClassMemberFunction("getIconOffsetY", &UIWidget::getIconOffsetY); + g_lua.bindClassMemberFunction("getIconOffset", &UIWidget::getIconOffset); + g_lua.bindClassMemberFunction("getIconWidth", &UIWidget::getIconWidth); + g_lua.bindClassMemberFunction("getIconHeight", &UIWidget::getIconHeight); + g_lua.bindClassMemberFunction("getIconSize", &UIWidget::getIconSize); + g_lua.bindClassMemberFunction("getIconRect", &UIWidget::getIconRect); + g_lua.bindClassMemberFunction("getIconClip", &UIWidget::getIconClip); + g_lua.bindClassMemberFunction("getIconAlign", &UIWidget::getIconAlign); + g_lua.bindClassMemberFunction("getBorderTopColor", &UIWidget::getBorderTopColor); + g_lua.bindClassMemberFunction("getBorderRightColor", &UIWidget::getBorderRightColor); + g_lua.bindClassMemberFunction("getBorderBottomColor", &UIWidget::getBorderBottomColor); + g_lua.bindClassMemberFunction("getBorderLeftColor", &UIWidget::getBorderLeftColor); + g_lua.bindClassMemberFunction("getBorderTopWidth", &UIWidget::getBorderTopWidth); + g_lua.bindClassMemberFunction("getBorderRightWidth", &UIWidget::getBorderRightWidth); + g_lua.bindClassMemberFunction("getBorderBottomWidth", &UIWidget::getBorderBottomWidth); + g_lua.bindClassMemberFunction("getBorderLeftWidth", &UIWidget::getBorderLeftWidth); + g_lua.bindClassMemberFunction("getMarginTop", &UIWidget::getMarginTop); + g_lua.bindClassMemberFunction("getMarginRight", &UIWidget::getMarginRight); + g_lua.bindClassMemberFunction("getMarginBottom", &UIWidget::getMarginBottom); + g_lua.bindClassMemberFunction("getMarginLeft", &UIWidget::getMarginLeft); + g_lua.bindClassMemberFunction("getPaddingTop", &UIWidget::getPaddingTop); + g_lua.bindClassMemberFunction("getPaddingRight", &UIWidget::getPaddingRight); + g_lua.bindClassMemberFunction("getPaddingBottom", &UIWidget::getPaddingBottom); + g_lua.bindClassMemberFunction("getPaddingLeft", &UIWidget::getPaddingLeft); + g_lua.bindClassMemberFunction("getOpacity", &UIWidget::getOpacity); + g_lua.bindClassMemberFunction("getRotation", &UIWidget::getRotation); + g_lua.bindClassMemberFunction("setQRCode", &UIWidget::setQRCode); + g_lua.bindClassMemberFunction("setImageSource", &UIWidget::setImageSource); + g_lua.bindClassMemberFunction("setImageSourceBase64", &UIWidget::setImageSourceBase64); + g_lua.bindClassMemberFunction("setImageClip", &UIWidget::setImageClip); + g_lua.bindClassMemberFunction("setImageOffsetX", &UIWidget::setImageOffsetX); + g_lua.bindClassMemberFunction("setImageOffsetY", &UIWidget::setImageOffsetY); + g_lua.bindClassMemberFunction("setImageOffset", &UIWidget::setImageOffset); + g_lua.bindClassMemberFunction("setImageWidth", &UIWidget::setImageWidth); + g_lua.bindClassMemberFunction("setImageHeight", &UIWidget::setImageHeight); + g_lua.bindClassMemberFunction("setImageSize", &UIWidget::setImageSize); + g_lua.bindClassMemberFunction("setImageRect", &UIWidget::setImageRect); + g_lua.bindClassMemberFunction("setImageColor", &UIWidget::setImageColor); + g_lua.bindClassMemberFunction("setImageFixedRatio", &UIWidget::setImageFixedRatio); + g_lua.bindClassMemberFunction("setImageRepeated", &UIWidget::setImageRepeated); + g_lua.bindClassMemberFunction("setImageSmooth", &UIWidget::setImageSmooth); + g_lua.bindClassMemberFunction("setImageAutoResize", &UIWidget::setImageAutoResize); + g_lua.bindClassMemberFunction("setImageBorderTop", &UIWidget::setImageBorderTop); + g_lua.bindClassMemberFunction("setImageBorderRight", &UIWidget::setImageBorderRight); + g_lua.bindClassMemberFunction("setImageBorderBottom", &UIWidget::setImageBorderBottom); + g_lua.bindClassMemberFunction("setImageBorderLeft", &UIWidget::setImageBorderLeft); + g_lua.bindClassMemberFunction("setImageBorder", &UIWidget::setImageBorder); + g_lua.bindClassMemberFunction("getImageClip", &UIWidget::getImageClip); + g_lua.bindClassMemberFunction("getImageOffsetX", &UIWidget::getImageOffsetX); + g_lua.bindClassMemberFunction("getImageOffsetY", &UIWidget::getImageOffsetY); + g_lua.bindClassMemberFunction("getImageOffset", &UIWidget::getImageOffset); + g_lua.bindClassMemberFunction("getImageWidth", &UIWidget::getImageWidth); + g_lua.bindClassMemberFunction("getImageHeight", &UIWidget::getImageHeight); + g_lua.bindClassMemberFunction("getImageSize", &UIWidget::getImageSize); + g_lua.bindClassMemberFunction("getImageRect", &UIWidget::getImageRect); + g_lua.bindClassMemberFunction("getImageColor", &UIWidget::getImageColor); + g_lua.bindClassMemberFunction("isImageFixedRatio", &UIWidget::isImageFixedRatio); + g_lua.bindClassMemberFunction("isImageSmooth", &UIWidget::isImageSmooth); + g_lua.bindClassMemberFunction("isImageAutoResize", &UIWidget::isImageAutoResize); + g_lua.bindClassMemberFunction("getImageBorderTop", &UIWidget::getImageBorderTop); + g_lua.bindClassMemberFunction("getImageBorderRight", &UIWidget::getImageBorderRight); + g_lua.bindClassMemberFunction("getImageBorderBottom", &UIWidget::getImageBorderBottom); + g_lua.bindClassMemberFunction("getImageBorderLeft", &UIWidget::getImageBorderLeft); + g_lua.bindClassMemberFunction("getImageTextureWidth", &UIWidget::getImageTextureWidth); + g_lua.bindClassMemberFunction("getImageTextureHeight", &UIWidget::getImageTextureHeight); + g_lua.bindClassMemberFunction("resizeToText", &UIWidget::resizeToText); + g_lua.bindClassMemberFunction("clearText", &UIWidget::clearText); + g_lua.bindClassMemberFunction("setText", &UIWidget::setText); + g_lua.bindClassMemberFunction("setTextAlign", &UIWidget::setTextAlign); + g_lua.bindClassMemberFunction("setTextOffset", &UIWidget::setTextOffset); + g_lua.bindClassMemberFunction("setTextWrap", &UIWidget::setTextWrap); + g_lua.bindClassMemberFunction("setTextAutoResize", &UIWidget::setTextAutoResize); + g_lua.bindClassMemberFunction("setTextVerticalAutoResize", &UIWidget::setTextVerticalAutoResize); + g_lua.bindClassMemberFunction("setTextHorizontalAutoResize", &UIWidget::setTextHorizontalAutoResize); + g_lua.bindClassMemberFunction("setFont", &UIWidget::setFont); + g_lua.bindClassMemberFunction("getText", &UIWidget::getText); + g_lua.bindClassMemberFunction("getDrawText", &UIWidget::getDrawText); + g_lua.bindClassMemberFunction("getTextAlign", &UIWidget::getTextAlign); + g_lua.bindClassMemberFunction("getTextOffset", &UIWidget::getTextOffset); + g_lua.bindClassMemberFunction("getTextWrap", &UIWidget::getTextWrap); + g_lua.bindClassMemberFunction("getFont", &UIWidget::getFont); + g_lua.bindClassMemberFunction("getTextSize", &UIWidget::getTextSize); + g_lua.bindClassMemberFunction("getUseCount", &UIWidget::getUseCount); + + // UILayout + g_lua.registerClass(); + g_lua.bindClassMemberFunction("update", &UILayout::update); + g_lua.bindClassMemberFunction("updateLater", &UILayout::updateLater); + g_lua.bindClassMemberFunction("applyStyle", &UILayout::applyStyle); + g_lua.bindClassMemberFunction("addWidget", &UILayout::addWidget); + g_lua.bindClassMemberFunction("removeWidget", &UILayout::removeWidget); + g_lua.bindClassMemberFunction("disableUpdates", &UILayout::disableUpdates); + g_lua.bindClassMemberFunction("enableUpdates", &UILayout::enableUpdates); + g_lua.bindClassMemberFunction("setParent", &UILayout::setParent); + g_lua.bindClassMemberFunction("getParentWidget", &UILayout::getParentWidget); + g_lua.bindClassMemberFunction("isUpdateDisabled", &UILayout::isUpdateDisabled); + g_lua.bindClassMemberFunction("isUpdating", &UILayout::isUpdating); + g_lua.bindClassMemberFunction("isUIAnchorLayout", &UILayout::isUIAnchorLayout); + g_lua.bindClassMemberFunction("isUIBoxLayout", &UILayout::isUIBoxLayout); + g_lua.bindClassMemberFunction("isUIHorizontalLayout", &UILayout::isUIHorizontalLayout); + g_lua.bindClassMemberFunction("isUIVerticalLayout", &UILayout::isUIVerticalLayout); + g_lua.bindClassMemberFunction("isUIGridLayout", &UILayout::isUIGridLayout); + + // UIBoxLayout + g_lua.registerClass(); + g_lua.bindClassMemberFunction("setSpacing", &UIBoxLayout::setSpacing); + g_lua.bindClassMemberFunction("setFitChildren", &UIBoxLayout::setFitChildren); + + // UIVerticalLayout + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", [](UIWidgetPtr parent){ return UIVerticalLayoutPtr(new UIVerticalLayout(parent)); } ); + g_lua.bindClassMemberFunction("setAlignBottom", &UIVerticalLayout::setAlignBottom); + g_lua.bindClassMemberFunction("isAlignBottom", &UIVerticalLayout::isAlignBottom); + + // UIHorizontalLayout + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", [](UIWidgetPtr parent){ return UIHorizontalLayoutPtr(new UIHorizontalLayout(parent)); } ); + g_lua.bindClassMemberFunction("setAlignRight", &UIHorizontalLayout::setAlignRight); + + // UIGridLayout + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", [](UIWidgetPtr parent){ return UIGridLayoutPtr(new UIGridLayout(parent)); }); + g_lua.bindClassMemberFunction("setCellSize", &UIGridLayout::setCellSize); + g_lua.bindClassMemberFunction("setCellWidth", &UIGridLayout::setCellWidth); + g_lua.bindClassMemberFunction("setCellHeight", &UIGridLayout::setCellHeight); + g_lua.bindClassMemberFunction("setCellSpacing", &UIGridLayout::setCellSpacing); + g_lua.bindClassMemberFunction("setFlow", &UIGridLayout::setFlow); + g_lua.bindClassMemberFunction("setNumColumns", &UIGridLayout::setNumColumns); + g_lua.bindClassMemberFunction("setNumLines", &UIGridLayout::setNumLines); + g_lua.bindClassMemberFunction("getNumColumns", &UIGridLayout::getNumColumns); + g_lua.bindClassMemberFunction("getNumLines", &UIGridLayout::getNumLines); + g_lua.bindClassMemberFunction("getCellSize", &UIGridLayout::getCellSize); + g_lua.bindClassMemberFunction("getCellSpacing", &UIGridLayout::getCellSpacing); + g_lua.bindClassMemberFunction("isUIGridLayout", &UIGridLayout::isUIGridLayout); + + // UIAnchorLayout + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", [](UIWidgetPtr parent){ return UIAnchorLayoutPtr(new UIAnchorLayout(parent)); } ); + g_lua.bindClassMemberFunction("removeAnchors", &UIAnchorLayout::removeAnchors); + g_lua.bindClassMemberFunction("centerIn", &UIAnchorLayout::centerIn); + g_lua.bindClassMemberFunction("fill", &UIAnchorLayout::fill); + + // UITextEdit + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return UITextEditPtr(new UITextEdit); } ); + g_lua.bindClassMemberFunction("setCursorPos", &UITextEdit::setCursorPos); + g_lua.bindClassMemberFunction("setSelection", &UITextEdit::setSelection); + g_lua.bindClassMemberFunction("setCursorVisible", &UITextEdit::setCursorVisible); + g_lua.bindClassMemberFunction("setChangeCursorImage", &UITextEdit::setChangeCursorImage); + g_lua.bindClassMemberFunction("setTextHidden", &UITextEdit::setTextHidden); + g_lua.bindClassMemberFunction("setValidCharacters", &UITextEdit::setValidCharacters); + g_lua.bindClassMemberFunction("setShiftNavigation", &UITextEdit::setShiftNavigation); + g_lua.bindClassMemberFunction("setMultiline", &UITextEdit::setMultiline); + g_lua.bindClassMemberFunction("setEditable", &UITextEdit::setEditable); + g_lua.bindClassMemberFunction("setSelectable", &UITextEdit::setSelectable); + g_lua.bindClassMemberFunction("setSelectionColor", &UITextEdit::setSelectionColor); + g_lua.bindClassMemberFunction("setSelectionBackgroundColor", &UITextEdit::setSelectionBackgroundColor); + g_lua.bindClassMemberFunction("setMaxLength", &UITextEdit::setMaxLength); + g_lua.bindClassMemberFunction("setTextVirtualOffset", &UITextEdit::setTextVirtualOffset); + g_lua.bindClassMemberFunction("getTextVirtualOffset", &UITextEdit::getTextVirtualOffset); + g_lua.bindClassMemberFunction("getTextVirtualSize", &UITextEdit::getTextVirtualSize); + g_lua.bindClassMemberFunction("getTextTotalSize", &UITextEdit::getTextTotalSize); + g_lua.bindClassMemberFunction("moveCursorHorizontally", &UITextEdit::moveCursorHorizontally); + g_lua.bindClassMemberFunction("moveCursorVertically", &UITextEdit::moveCursorVertically); + g_lua.bindClassMemberFunction("appendText", &UITextEdit::appendText); + g_lua.bindClassMemberFunction("wrapText", &UITextEdit::wrapText); + g_lua.bindClassMemberFunction("removeCharacter", &UITextEdit::removeCharacter); + g_lua.bindClassMemberFunction("blinkCursor", &UITextEdit::blinkCursor); + g_lua.bindClassMemberFunction("del", &UITextEdit::del); + g_lua.bindClassMemberFunction("paste", &UITextEdit::paste); + g_lua.bindClassMemberFunction("copy", &UITextEdit::copy); + g_lua.bindClassMemberFunction("cut", &UITextEdit::cut); + g_lua.bindClassMemberFunction("selectAll", &UITextEdit::selectAll); + g_lua.bindClassMemberFunction("clearSelection", &UITextEdit::clearSelection); + g_lua.bindClassMemberFunction("getDisplayedText", &UITextEdit::getDisplayedText); + g_lua.bindClassMemberFunction("getSelection", &UITextEdit::getSelection); + g_lua.bindClassMemberFunction("getTextPos", &UITextEdit::getTextPos); + g_lua.bindClassMemberFunction("getCursorPos", &UITextEdit::getCursorPos); + g_lua.bindClassMemberFunction("getMaxLength", &UITextEdit::getMaxLength); + g_lua.bindClassMemberFunction("getSelectionStart", &UITextEdit::getSelectionStart); + g_lua.bindClassMemberFunction("getSelectionEnd", &UITextEdit::getSelectionEnd); + g_lua.bindClassMemberFunction("getSelectionColor", &UITextEdit::getSelectionColor); + g_lua.bindClassMemberFunction("getSelectionBackgroundColor", &UITextEdit::getSelectionBackgroundColor); + g_lua.bindClassMemberFunction("hasSelection", &UITextEdit::hasSelection); + g_lua.bindClassMemberFunction("isEditable", &UITextEdit::isEditable); + g_lua.bindClassMemberFunction("isSelectable", &UITextEdit::isSelectable); + g_lua.bindClassMemberFunction("isCursorVisible", &UITextEdit::isCursorVisible); + g_lua.bindClassMemberFunction("isChangingCursorImage", &UITextEdit::isChangingCursorImage); + g_lua.bindClassMemberFunction("isTextHidden", &UITextEdit::isTextHidden); + g_lua.bindClassMemberFunction("isShiftNavigation", &UITextEdit::isShiftNavigation); + g_lua.bindClassMemberFunction("isMultiline", &UITextEdit::isMultiline); + + g_lua.registerClass(); + g_lua.registerClass(); + g_lua.bindClassMemberFunction("addMultiTexture", &PainterShaderProgram::addMultiTexture); + + // ParticleEffect + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return ParticleEffectTypePtr(new ParticleEffectType); }); + g_lua.bindClassMemberFunction("getName", &ParticleEffectType::getName); + g_lua.bindClassMemberFunction("getDescription", &ParticleEffectType::getDescription); + + // UIParticles + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return UIParticlesPtr(new UIParticles); } ); + g_lua.bindClassMemberFunction("addEffect", &UIParticles::addEffect); +#endif + +#ifdef FW_NET + // Server + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", &Server::create); + g_lua.bindClassMemberFunction("close", &Server::close); + g_lua.bindClassMemberFunction("isOpen", &Server::isOpen); + g_lua.bindClassMemberFunction("acceptNext", &Server::acceptNext); + + // Connection + g_lua.registerClass(); + g_lua.bindClassMemberFunction("getIp", &Connection::getIp); + + // Protocol + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return ProtocolPtr(new Protocol); }); + g_lua.bindClassMemberFunction("connect", &Protocol::connect); + g_lua.bindClassMemberFunction("disconnect", &Protocol::disconnect); + g_lua.bindClassMemberFunction("isConnected", &Protocol::isConnected); + g_lua.bindClassMemberFunction("isConnecting", &Protocol::isConnecting); + g_lua.bindClassMemberFunction("getConnection", &Protocol::getConnection); + g_lua.bindClassMemberFunction("setConnection", &Protocol::setConnection); + g_lua.bindClassMemberFunction("send", &Protocol::send); + g_lua.bindClassMemberFunction("recv", &Protocol::recv); + g_lua.bindClassMemberFunction("setXteaKey", &Protocol::setXteaKey); + g_lua.bindClassMemberFunction("getXteaKey", &Protocol::getXteaKey); + g_lua.bindClassMemberFunction("generateXteaKey", &Protocol::generateXteaKey); + g_lua.bindClassMemberFunction("enableXteaEncryption", &Protocol::enableXteaEncryption); + g_lua.bindClassMemberFunction("enableChecksum", &Protocol::enableChecksum); + + // InputMessage + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return InputMessagePtr(new InputMessage); }); + g_lua.bindClassMemberFunction("setBuffer", &InputMessage::setBuffer); + g_lua.bindClassMemberFunction("getBuffer", &InputMessage::getBuffer); + g_lua.bindClassMemberFunction("skipBytes", &InputMessage::skipBytes); + g_lua.bindClassMemberFunction("getU8", &InputMessage::getU8); + g_lua.bindClassMemberFunction("getU16", &InputMessage::getU16); + g_lua.bindClassMemberFunction("getU32", &InputMessage::getU32); + g_lua.bindClassMemberFunction("getU64", &InputMessage::getU64); + g_lua.bindClassMemberFunction("getString", &InputMessage::getString); + g_lua.bindClassMemberFunction("peekU8", &InputMessage::peekU8); + g_lua.bindClassMemberFunction("peekU16", &InputMessage::peekU16); + g_lua.bindClassMemberFunction("peekU32", &InputMessage::peekU32); + g_lua.bindClassMemberFunction("peekU64", &InputMessage::peekU64); + g_lua.bindClassMemberFunction("decryptRsa", &InputMessage::decryptRsa); + g_lua.bindClassMemberFunction("getReadSize", &InputMessage::getReadSize); + g_lua.bindClassMemberFunction("getUnreadSize", &InputMessage::getUnreadSize); + g_lua.bindClassMemberFunction("getMessageSize", &InputMessage::getMessageSize); + g_lua.bindClassMemberFunction("eof", &InputMessage::eof); + + // OutputMessage + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return OutputMessagePtr(new OutputMessage); }); + g_lua.bindClassMemberFunction("setBuffer", &OutputMessage::setBuffer); + g_lua.bindClassMemberFunction("getBuffer", &OutputMessage::getBuffer); + g_lua.bindClassMemberFunction("reset", &OutputMessage::reset); + g_lua.bindClassMemberFunction("addU8", &OutputMessage::addU8); + g_lua.bindClassMemberFunction("addU16", &OutputMessage::addU16); + g_lua.bindClassMemberFunction("addU32", &OutputMessage::addU32); + g_lua.bindClassMemberFunction("addU64", &OutputMessage::addU64); + g_lua.bindClassMemberFunction("addString", &OutputMessage::addString); + g_lua.bindClassMemberFunction("addPaddingBytes", &OutputMessage::addPaddingBytes); + g_lua.bindClassMemberFunction("encryptRsa", &OutputMessage::encryptRsa); + g_lua.bindClassMemberFunction("getMessageSize", &OutputMessage::getMessageSize); + g_lua.bindClassMemberFunction("setMessageSize", &OutputMessage::setMessageSize); + g_lua.bindClassMemberFunction("getWritePos", &OutputMessage::getWritePos); + g_lua.bindClassMemberFunction("setWritePos", &OutputMessage::setWritePos); + +#ifdef FW_PROXY + g_lua.registerSingletonClass("g_proxy"); + g_lua.bindSingletonFunction("g_proxy", "addProxy", &ProxyManager::addProxy, &g_proxy); + g_lua.bindSingletonFunction("g_proxy", "removeProxy", &ProxyManager::removeProxy, &g_proxy); + g_lua.bindSingletonFunction("g_proxy", "clear", &ProxyManager::clear, &g_proxy); + g_lua.bindSingletonFunction("g_proxy", "setMaxActiveProxies", &ProxyManager::setMaxActiveProxies, &g_proxy); + g_lua.bindSingletonFunction("g_proxy", "getProxies", &ProxyManager::getProxies, &g_proxy); + g_lua.bindSingletonFunction("g_proxy", "getProxiesDebugInfo", &ProxyManager::getProxiesDebugInfo, &g_proxy); + g_lua.bindSingletonFunction("g_proxy", "getPing", &ProxyManager::getPing, &g_proxy); +#endif + +#endif + +#ifdef FW_SOUND + // SoundManager + g_lua.registerSingletonClass("g_sounds"); + g_lua.bindSingletonFunction("g_sounds", "preload", &SoundManager::preload, &g_sounds); + g_lua.bindSingletonFunction("g_sounds", "play", &SoundManager::play, &g_sounds); + g_lua.bindSingletonFunction("g_sounds", "getChannel", &SoundManager::getChannel, &g_sounds); + g_lua.bindSingletonFunction("g_sounds", "stopAll", &SoundManager::stopAll, &g_sounds); + g_lua.bindSingletonFunction("g_sounds", "enableAudio", &SoundManager::enableAudio, &g_sounds); + g_lua.bindSingletonFunction("g_sounds", "disableAudio", &SoundManager::disableAudio, &g_sounds); + g_lua.bindSingletonFunction("g_sounds", "setAudioEnabled", &SoundManager::setAudioEnabled, &g_sounds); + g_lua.bindSingletonFunction("g_sounds", "isAudioEnabled", &SoundManager::isAudioEnabled, &g_sounds); + + g_lua.registerClass(); + g_lua.registerClass(); + g_lua.registerClass(); + + g_lua.registerClass(); + g_lua.bindClassMemberFunction("play", &SoundChannel::play); + g_lua.bindClassMemberFunction("stop", &SoundChannel::stop); + g_lua.bindClassMemberFunction("enqueue", &SoundChannel::enqueue); + g_lua.bindClassMemberFunction("enable", &SoundChannel::enable); + g_lua.bindClassMemberFunction("disable", &SoundChannel::disable); + g_lua.bindClassMemberFunction("setGain", &SoundChannel::setGain); + g_lua.bindClassMemberFunction("getGain", &SoundChannel::getGain); + g_lua.bindClassMemberFunction("setEnabled", &SoundChannel::setEnabled); + g_lua.bindClassMemberFunction("isEnabled", &SoundChannel::isEnabled); + g_lua.bindClassMemberFunction("getId", &SoundChannel::getId); +#endif + +#ifdef FW_SQL + // Database + g_lua.registerClass(); + g_lua.bindClassMemberFunction("getDatabaseEngine", &Database::getDatabaseEngine); + g_lua.bindClassMemberFunction("isConnected", &Database::isConnected); + g_lua.bindClassMemberFunction("getStringComparer", &Database::getStringComparer); + g_lua.bindClassMemberFunction("getUpdateLimiter", &Database::getUpdateLimiter); + g_lua.bindClassMemberFunction("getLastInsertedRowID", &Database::getLastInsertedRowID); + g_lua.bindClassMemberFunction("escapeString", &Database::escapeString); + //g_lua.bindClassMemberFunction("escapeBlob", &Database::escapeBlob); // need to write a cast for this type to work (if needed) + + // DBQuery + /* (not sure if this class will work as a luafunction) + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return DBQuery(); }); + g_lua.bindClassMemberFunction("append", &DBQuery::append); + g_lua.bindClassMemberFunction("set", &DBQuery::set); + */ + + // DBResult + g_lua.registerClass(); + g_lua.bindClassMemberFunction("getDataInt", &DBResult::getDataInt); + g_lua.bindClassMemberFunction("getDataLong", &DBResult::getDataLong); + g_lua.bindClassMemberFunction("getDataString", &DBResult::getDataString); + //g_lua.bindClassMemberFunction("getDataStream", &DBResult::getDataStream); // need to write a cast for this type to work (if needed) + g_lua.bindClassMemberFunction("getRowCount", &DBResult::getRowCount); + g_lua.bindClassMemberFunction("free", &DBResult::free); + g_lua.bindClassMemberFunction("next", &DBResult::next); + + // MySQL + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return DatabaseMySQLPtr(new DatabaseMySQL); }); + g_lua.bindClassMemberFunction("connect", &DatabaseMySQL::connect); + g_lua.bindClassMemberFunction("beginTransaction", &DatabaseMySQL::beginTransaction); + g_lua.bindClassMemberFunction("rollback", &DatabaseMySQL::rollback); + g_lua.bindClassMemberFunction("commit", &DatabaseMySQL::commit); + g_lua.bindClassMemberFunction("executeQuery", &DatabaseMySQL::executeQuery); + g_lua.bindClassMemberFunction("storeQuery", &DatabaseMySQL::storeQuery); + + // MySQLResult + g_lua.registerClass(); + g_lua.bindClassMemberFunction("getDataInt", &MySQLResult::getDataInt); + g_lua.bindClassMemberFunction("getDataLong", &MySQLResult::getDataLong); + g_lua.bindClassMemberFunction("getDataString", &MySQLResult::getDataString); + //g_lua.bindClassMemberFunction("getDataStream", &MySQLResult::getDataStream); // need to write a cast for this type to work (if needed) + g_lua.bindClassMemberFunction("getRowCount", &MySQLResult::getRowCount); + g_lua.bindClassMemberFunction("free", &MySQLResult::free); + g_lua.bindClassMemberFunction("next", &MySQLResult::next); +#endif +} diff --git a/modules/client/client.otmod b/modules/client/client.otmod index 751d788..09e5c5c 100644 --- a/modules/client/client.otmod +++ b/modules/client/client.otmod @@ -19,6 +19,5 @@ Module - client_entergamev2 - client_terminal - client_stats - - client_news - client_feedback - client_updater diff --git a/modules/client_entergame/entergame.lua b/modules/client_entergame/entergame.lua index b26799e..aa1a07e 100644 --- a/modules/client_entergame/entergame.lua +++ b/modules/client_entergame/entergame.lua @@ -15,7 +15,7 @@ local serverSelector local clientVersionSelector local serverHostTextEdit local rememberPasswordBox -local protos = {"740", "760", "772", "792", "800", "810", "854", "860", "1077", "1090", "1096", "1098", "1099", "1100"} +local protos = {"740", "760", "772", "792", "800", "810", "854", "860", "961", "1077", "1090", "1096", "1098", "1099", "1100"} -- private functions local function onProtocolError(protocol, message, errorCode) @@ -247,7 +247,7 @@ function EnterGame.init() end function EnterGame.terminate() - if USE_NEW_ENERGAME then return end + if not enterGame then return end g_keyboard.unbindKeyDown('Ctrl+G') enterGame:destroy() @@ -263,6 +263,7 @@ function EnterGame.terminate() end function EnterGame.show() + if not enterGame then return end if Updater and Updater.isVisible() or g_game.isOnline() then return EnterGame.hide() end @@ -273,6 +274,7 @@ function EnterGame.show() end function EnterGame.hide() + if not enterGame then return end enterGame:hide() end diff --git a/modules/client_entergamev2/entergamev2.lua b/modules/client_entergamev2/entergamev2.lua index 1dbe9c4..a180b04 100644 --- a/modules/client_entergamev2/entergamev2.lua +++ b/modules/client_entergamev2/entergamev2.lua @@ -1,5 +1,72 @@ +local entergameWindow +local characterGroup + function init() + if not USE_NEW_ENERGAME then return end + entergameWindow = g_ui.displayUI('entergamev2') + + --entergameWindow.news:hide() + --entergameWindow.quick:hide() + entergameWindow.registration:hide() + entergameWindow.characters:hide() + entergameWindow.createcharacter:hide() + + -- entergame + entergameWindow.entergame.register.onClick = function() + entergameWindow.registration:show() + entergameWindow.entergame:hide() + end + entergameWindow.entergame.mainPanel.button.onClick = function() + entergameWindow.entergame:hide() + entergameWindow.characters:show() + g_game.setClientVersion(1099) -- for tests + end + + -- registration + entergameWindow.registration.back.onClick = function() + entergameWindow.registration:hide() + entergameWindow.entergame:show() + end + + -- characters + entergameWindow.characters.logout.onClick = function() + entergameWindow.characters:hide() + entergameWindow.entergame:show() + end + entergameWindow.characters.createcharacter.onClick = function() + entergameWindow.characters:hide() + entergameWindow.createcharacter:show() + end + entergameWindow.characters.mainPanel.autoReconnect.onClick = function() + entergameWindow.characters.mainPanel.autoReconnect:setOn(not entergameWindow.characters.mainPanel.autoReconnect:isOn()) + end + + -- create character + entergameWindow.createcharacter.back.onClick = function() + entergameWindow.createcharacter:hide() + entergameWindow.characters:show() + end + + -- tests + characterGroup = UIRadioGroup.create() + for i=1,20 do + local character = g_ui.createWidget('EntergameCharacter', entergameWindow.characters.mainPanel.charactersPanel) + characterGroup:addWidget(character) + character.outfit:setOutfit({feet=10,legs=10,body=176,type=129,auxType=0,addons=3,head=48}) + end + characterGroup:selectWidget(entergameWindow.characters.mainPanel.charactersPanel:getFirstChild()) + characterGroup:getSelectedWidget() + + for i=1,100 do + local l = g_ui.createWidget("NewsLabel", entergameWindow.news.content) + l:setText("test xxx ssss eeee uu u llel " .. i) + end end function terminate() -end + if not USE_NEW_ENERGAME then return end + entergameWindow:destroy() + if characterGroup then + characterGroup:destroy() + end +end \ No newline at end of file diff --git a/modules/client_entergamev2/entergamev2.otui b/modules/client_entergamev2/entergamev2.otui new file mode 100644 index 0000000..49ef9b4 --- /dev/null +++ b/modules/client_entergamev2/entergamev2.otui @@ -0,0 +1,587 @@ +EnterGamePanel < Panel + font: verdana-11px-antialised + color: #dfdfdf + text-offset: 0 6 + text-align: top + image-source: /images/ui/window + image-border: 6 + image-border-top: 27 + padding-top: 28 + padding-left: 8 + padding-right: 8 + padding-bottom: 8 + +News < EnterGamePanel + id: news + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom + width: 230 + !text: tr("News") + + ScrollablePanel + id: content + anchors.fill: parent + margin-right: 8 + margin-left: 1 + margin-bottom: 5 + vertical-scrollbar: newsPanelScroll + layout: + type: verticalBox + + SmallScrollBar + id: newsPanelScroll + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: parent.right + +NewsLabel < Label + text-wrap: true + text-auto-resize: true + text-align: center + font: terminus-14px-bold + +NewsText < Label + text-wrap: true + text-auto-resize: true + text-align: left + margin-bottom: 10 + +NewsImage < Label + text-wrap: true + margin-bottom: 5 + text-align: center + +EnterGame < Panel + anchors.fill: parent + id: entergame + + EnterGamePanel + id: mainPanel + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + size: 250 210 + !text: tr("Enter Game") + padding-top: 36 + padding-left: 16 + padding-right: 16 + padding-bottom: 16 + + MenuLabel + !text: tr('Account name') + anchors.left: parent.left + anchors.top: parent.top + text-auto-resize: true + + TextEdit + id: account + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 2 + + MenuLabel + !text: tr('Password') + anchors.left: prev.left + anchors.top: prev.bottom + margin-top: 8 + text-auto-resize: true + + PasswordTextEdit + id: password + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 2 + + HorizontalSeparator + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 10 + + CheckBox + id: rememberPasswordBox + !text: tr('Remember password') + !tooltip: tr('Remember account and password when starts client') + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 9 + + HorizontalSeparator + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 9 + + Button + id: button + !text: tr('Login') + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 10 + margin-left: 50 + margin-right: 50 + + EnterGamePanel + id: buttons + anchors.horizontalCenter: prev.horizontalCenter + anchors.top: prev.bottom + margin-top: 20 + size: 200 50 + image-source: /images/ui/window_headless + image-border: 6 + padding-top: 8 + + Button + id: register + anchors.verticalCenter: buttons.verticalCenter + anchors.horizontalCenter: buttons.horizontalCenter + !text: tr("Create account") + size: 160 30 + +Registration < Panel + anchors.fill: parent + id: registration + + EnterGamePanel + id: mainPanel + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + size: 250 262 + !text: tr("Create Acoount") + padding-top: 36 + padding-left: 16 + padding-right: 16 + padding-bottom: 16 + + MenuLabel + !text: tr('Account name') + anchors.left: parent.left + anchors.top: parent.top + text-auto-resize: true + + TextEdit + id: accountNameTextEdit + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 2 + + MenuLabel + !text: tr('Email') + anchors.left: prev.left + anchors.top: prev.bottom + margin-top: 8 + text-auto-resize: true + + TextEdit + id: emailTextEdit + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 2 + + MenuLabel + !text: tr('Password') + anchors.left: prev.left + anchors.top: prev.bottom + margin-top: 8 + text-auto-resize: true + + PasswordTextEdit + id: accountPasswordTextEdit + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 2 + + MenuLabel + !text: tr('Password confirmation') + anchors.left: prev.left + anchors.top: prev.bottom + margin-top: 8 + text-auto-resize: true + + PasswordTextEdit + id: accountPasswordTextEdit + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 2 + + HorizontalSeparator + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 9 + + Button + !text: tr('Create account') + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 10 + margin-left: 50 + margin-right: 50 + @onClick: EnterGame.doLogin() + + EnterGamePanel + id: buttons + anchors.horizontalCenter: prev.horizontalCenter + anchors.top: prev.bottom + margin-top: 20 + size: 200 50 + image-source: /images/ui/window_headless + image-border: 6 + padding-top: 8 + + Button + id: back + anchors.verticalCenter: buttons.verticalCenter + anchors.horizontalCenter: buttons.horizontalCenter + !text: tr("Back") + size: 160 30 + +QuickLogin < EnterGamePanel + id: quick + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + size: 230 312 + !text: tr("Quick Login & Registration") + + UIButton + id: qrcode + width: 200 + height: 200 + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + image-fixed-ratio: true + image-smooth: false + margin-top: 5 + qr: 123 + + UIButton + id: quathlogo + width: 66 + height: 40 + anchors.verticalCenter: prev.verticalCenter + anchors.horizontalCenter: prev.horizontalCenter + image-fixed-ratio: true + image-smooth: false + image-source: /images/ui/qauth + + Label + anchors.top: qrcode.bottom + anchors.left: qrcode.left + anchors.right: qrcode.right + text-align: center + text-auto-resize: true + !text: tr("Scan or click QR code\nto register or login") + height: 40 + margin-top: 10 + margin-bottom: 5 + + Button + anchors.top: prev.bottom + anchors.left: parent.left + anchors.right: parent.right + text-align: center + !text: tr("Click to get PC/Android/iOS app") + height: 23 + margin-top: 10 + margin-left: 5 + margin-right: 5 + color: #FFFFFF + @onClick: g_platform.openUrl("http://qauth.co") + +Characters < Panel + id: characters + anchors.fill: parent + + EnterGamePanel + id: mainPanel + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + size: 550 350 + !text: tr("Characters") + padding-top: 36 + padding-left: 16 + padding-right: 16 + padding-bottom: 16 + + Label + id: motd + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + text-auto-resize: true + text-wrap: true + text: This is motd ;) + text-align: center + + HorizontalSeparator + id: motdSeparator + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 5 + height: 10 + + ScrollablePanel + id: charactersPanel + layout: + type: grid + cell-size: 100 100 + cell-spacing: 1 + flow: true + vertical-scrollbar: charactersScroll + anchors.top: prev.bottom + anchors.bottom: bottomSeparator.top + anchors.left: parent.left + anchors.right: parent.right + margin-bottom: 10 + margin-right: 12 + + VerticalScrollBar + id: charactersScroll + anchors.top: charactersPanel.top + anchors.bottom: charactersPanel.bottom + anchors.left: charactersPanel.right + step: 14 + pixels-scroll: true + + HorizontalSeparator + id: bottomSeparator + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: 35 + + Button + id: autoReconnect + !text: tr('Auto reconnect: On') + width: 140 + anchors.left: parent.left + anchors.bottom: parent.bottom + image-color: green + $!on: + image-color: red + !text: tr('Auto reconnect: Off') + + Button + id: createCharacter + anchors.right: parent.right + anchors.bottom: parent.bottom + !text: tr("Connect") + width: 140 + + EnterGamePanel + id: buttons + anchors.horizontalCenter: prev.horizontalCenter + anchors.top: prev.bottom + margin-top: 20 + size: 450 50 + image-source: /images/ui/window_headless + image-border: 6 + padding-top: 8 + + Button + id: createcharacter + anchors.verticalCenter: buttons.verticalCenter + anchors.left: buttons.left + !text: tr("Create character") + margin-left: 10 + size: 140 30 + + Button + id: casts + anchors.verticalCenter: buttons.verticalCenter + anchors.horizontalCenter: buttons.horizontalCenter + !text: tr("Casts") + size: 140 30 + + Button + id: logout + anchors.verticalCenter: buttons.verticalCenter + anchors.right: buttons.right + margin-right: 10 + !text: tr("Logout") + size: 140 30 + +EntergameCharacter < UIButton + border-width: 1 + padding: 1 1 1 1 + @onClick: self:setChecked(true) + + $checked: + border-color: #ffffff + + $!checked: + border-color: black + + UICreature + id: outfit + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + size: 48 48 + margin-bottom: 3 + phantom: true + + Label + id: line1 + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + text: Dagusia Druid + text-align: center + text-wrap: false + height: 16 + font: terminus-10px + border-width-bottom: 1 + border-color: #00000077 + + Label + id: line2 + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + text: Level: 666 + text-align: center + text-wrap: false + height: 16 + font: terminus-10px + border-width-bottom: 1 + border-color: #00000077 + + Label + id: line3 + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + text: World: nemezis + text-align: center + text-wrap: false + height: 16 + font: terminus-10px + border-width-bottom: 1 + border-color: #00000077 + +CreateCharacter < Panel + anchors.fill: parent + id: createcharacter + + EnterGamePanel + id: mainPanel + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + size: 250 262 + !text: tr("Create Character") + padding-top: 36 + padding-left: 16 + padding-right: 16 + padding-bottom: 16 + + MenuLabel + !text: tr('Name') + anchors.left: parent.left + anchors.top: parent.top + text-auto-resize: true + + TextEdit + id: accountNameTextEdit + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 2 + + MenuLabel + !text: tr('Vocation') + anchors.left: prev.left + anchors.top: prev.bottom + margin-top: 8 + text-auto-resize: true + + TextEdit + id: emailTextEdit + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 2 + + MenuLabel + !text: tr('Password') + anchors.left: prev.left + anchors.top: prev.bottom + margin-top: 8 + text-auto-resize: true + + PasswordTextEdit + id: accountPasswordTextEdit + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 2 + + MenuLabel + !text: tr('Password confirmation') + anchors.left: prev.left + anchors.top: prev.bottom + margin-top: 8 + text-auto-resize: true + + PasswordTextEdit + id: accountPasswordTextEdit + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 2 + + HorizontalSeparator + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 9 + + Button + !text: tr('Create character') + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 10 + margin-left: 50 + margin-right: 50 + @onClick: EnterGame.doLogin() + + EnterGamePanel + id: buttons + anchors.horizontalCenter: prev.horizontalCenter + anchors.top: prev.bottom + margin-top: 20 + size: 200 50 + image-source: /images/ui/window_headless + image-border: 6 + padding-top: 8 + + Button + id: back + anchors.verticalCenter: buttons.verticalCenter + anchors.horizontalCenter: buttons.horizontalCenter + !text: tr("Back") + size: 160 30 + +Panel + anchors.top: topMenu.bottom + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + margin: 10 10 10 10 + + News + QuickLogin + EnterGame + Registration + Characters + CreateCharacter diff --git a/modules/client_news/news.lua b/modules/client_news/news.lua deleted file mode 100644 index 7a5f163..0000000 --- a/modules/client_news/news.lua +++ /dev/null @@ -1,119 +0,0 @@ --- private variables -local news -local newsPanel -local updateNewsEvent = nil -local ongoingNewsUpdate = false -local lastNewsUpdate = 0 -local newsUpdateInterval = 30 -- seconds - --- public functions -function init() - news = g_ui.displayUI('news') - newsPanel = news:recursiveGetChildById('newsPanel') - - connect(rootWidget, { onGeometryChange = updateSize }) - connect(g_game, { onGameStart = hide, onGameEnd = show }) - - if g_game.isOnline() then - hide() - else - show() - end -end - -function terminate() - disconnect(rootWidget, { onGeometryChange = updateSize }) - disconnect(g_game, { onGameStart = hide, onGameEnd = show }) - - removeEvent(updateNewsEvent) - clearNews() - - news:destroy() - news = nil -end - -function hide() - news:hide() -end - -function show() - news:show() - updateSize() - updateNews() -end - -function updateSize() - if Services.news == nil or Services.news:len() < 4 or g_game.isOnline() then - return - end - if rootWidget:getWidth() < 790 and news:isVisible() then - hide() - elseif news:isHidden() then - show() - end - news:setWidth(math.min(math.max(250, rootWidget:getWidth() / 4), 300)) -end - -function updateNews() - if Services.news == nil or Services.news:len() < 4 then - hide() - return - end - if ongoingNewsUpdate or os.time() < lastNewsUpdate + newsUpdateInterval then - return - end - HTTP.getJSON(Services.news .. "?lang=" .. modules.client_locales.getCurrentLocale().name, onGotNews) - ongoingNewsUpdate = true - lastNewsUpdate = os.time() -end - -function clearNews() - while newsPanel:getChildCount() > 0 do - local child = newsPanel:getLastChild() - newsPanel:destroyChildren(child) - end -end - -function onGotNews(data, err) - ongoingNewsUpdate = false - if err then - return gotNewsError("Error:\n" .. err) - end - - clearNews() - - for i, news in pairs(data) do - local title = news["title"] - local text = news["text"] - local image = news["image"] - if title ~= nil then - newsLabel = g_ui.createWidget('NewsLabel', newsPanel) - newsLabel:setText(title) - end - if text ~= nil then - newsText = g_ui.createWidget('NewsText', newsPanel) - newsText:setText(text) - end - if image ~= nil then - newsImage = g_ui.createWidget('NewsImage', newsPanel) - newsImage:setId(imageName) - newsImage:setImageSourceBase64(image) - newsImage:setImageFixedRatio(true) - newsImage:setImageAutoResize(false) - newsImage:setHeight(200) - end - end -end - -function gotNewsError(err) - updateNewsEvent = scheduleEvent(function() - updateNews() - end, 3000) - - clearNews() - errorLabel = g_ui.createWidget('NewsLabel', newsPanel) - errorLabel:setText(tr("Error")) - errorInfo = g_ui.createWidget('NewsText', newsPanel) - errorInfo:setText(err) - ongoingNewsUpdate = true -end \ No newline at end of file diff --git a/modules/client_news/news.otmod b/modules/client_news/news.otmod deleted file mode 100644 index f539541..0000000 --- a/modules/client_news/news.otmod +++ /dev/null @@ -1,10 +0,0 @@ -Module - name: client_news - description: News - author: otclient.ovh - website: http://otclient.ovh - sandboxed: true - scripts: [ news ] - dependencies: [ client_topmenu ] - @onLoad: init() - @onUnload: terminate() diff --git a/modules/client_news/news.otui b/modules/client_news/news.otui deleted file mode 100644 index 98b2959..0000000 --- a/modules/client_news/news.otui +++ /dev/null @@ -1,47 +0,0 @@ -NewsLabel < Label - text-wrap: false - text-auto-resize: true - text-align: center - font: terminus-14px-bold - -NewsText < Label - text-wrap: true - text-auto-resize: true - text-align: left - margin-bottom: 10 - -NewsImage < Label - text-wrap: true - margin-bottom: 5 - text-align: center - -StaticWindow - anchors.left: parent.left - anchors.top: topMenu.bottom - anchors.bottom: parent.bottom - margin-top: 10 - margin-left: 20 - margin-bottom: 10 - id: newsPanelHolder - width: 300 - !text: tr('News') - - ScrollablePanel - id: newsPanel - layout: - type: verticalBox - vertical-scrollbar: newsScroll - anchors.left: parent.left - anchors.right: parent.right - anchors.top: parent.top - anchors.bottom: parent.bottom - padding-right: 10 - margin-right: 10 - - VerticalScrollBar - id: newsScroll - anchors.top: newsPanel.top - anchors.bottom: newsPanel.bottom - anchors.left: newsPanel.right - step: 14 - pixels-scroll: true diff --git a/modules/client_options/game.otui b/modules/client_options/game.otui index 342f077..0362e81 100644 --- a/modules/client_options/game.otui +++ b/modules/client_options/game.otui @@ -62,7 +62,7 @@ Panel anchors.left: parent.left anchors.right: parent.right margin-top: 3 - minimum: 0 + minimum: 50 maximum: 300 Label diff --git a/modules/client_options/interface.otui b/modules/client_options/interface.otui index 6b71b8f..cc34275 100644 --- a/modules/client_options/interface.otui +++ b/modules/client_options/interface.otui @@ -3,6 +3,18 @@ Panel id: classicView !text: tr('Classic view') + OptionCheckBox + id: cacheMap + !text: tr('Cache map (for non-classic view)') + + OptionCheckBox + id: actionBar1 + !text: tr("Show first action bar") + + OptionCheckBox + id: actionBar2 + !text: tr("Show second action bar") + OptionCheckBox id: showPing !text: tr('Show connection ping') @@ -41,7 +53,7 @@ Panel !text: tr('Highlight things under cursor') Label - margin-top: 12 + margin-top: 5 width: 90 anchors.left: parent.left anchors.top: prev.bottom @@ -110,7 +122,7 @@ Panel self:addOption("4th right panel") Label - margin-top: 12 + margin-top: 3 anchors.left: parent.left anchors.right: parent.right anchors.top: prev.bottom diff --git a/modules/client_options/options.lua b/modules/client_options/options.lua index 894958b..7621ad7 100644 --- a/modules/client_options/options.lua +++ b/modules/client_options/options.lua @@ -4,6 +4,7 @@ local defaultOptions = { showPing = true, fullscreen = false, classicView = true, + cacheMap = false, classicControl = true, smartWalk = false, dash = false, @@ -49,7 +50,10 @@ local defaultOptions = { walkTurnDelay = 100, walkStairsDelay = 50, walkTeleportDelay = 200, - walkCtrlTurnDelay = 150 + walkCtrlTurnDelay = 150, + + actionBar1 = true, + actionBar2 = false } local optionsWindow @@ -343,8 +347,10 @@ function setOption(key, value, force) g_settings.set(key, value) options[key] = value - if key == 'classicView' or key == 'rightPanels' or key == 'leftPanels' then + if key == 'classicView' or key == 'rightPanels' or key == 'leftPanels' or key == 'cacheMap' then modules.game_interface.refreshViewMode() + elseif key == 'actionBar1' or key == 'actionBar2' then + modules.game_actionbar.show() end end diff --git a/modules/corelib/http.lua b/modules/corelib/http.lua index 96e81c6..4a5c7e4 100644 --- a/modules/corelib/http.lua +++ b/modules/corelib/http.lua @@ -182,7 +182,9 @@ function HTTP.onDownload(operationId, url, err, path, checksum) end if operation.callback then if operation["type"] == "image" then - HTTP.images[url] = path + if not err then + HTTP.images[url] = path + end operation.callback('/downloads/' .. path, err) else operation.callback(path, checksum, err) diff --git a/modules/game_actionbar/actionbar.lua b/modules/game_actionbar/actionbar.lua new file mode 100644 index 0000000..82e649f --- /dev/null +++ b/modules/game_actionbar/actionbar.lua @@ -0,0 +1,330 @@ +actionPanel1 = nil +actionPanel2 = nil + +local actionConfig +local hotkeyAssignWindow +local actionButtonsInPanel = 50 + +ActionTypes = { + USE = 0, + USE_SELF = 1, + USE_TARGET = 2, + USE_WITH = 3 +} + +ActionColors = { + empty = '#00000022', + text = '#88888844', + itemUse = '#8888FF44', + itemUseSelf = '#00FF0044', + itemUseTarget = '#FF000044', + itemUseWith = '#F5B32544' +} + +function init() + local bottomPanel = modules.game_interface.getBottomPanel() + actionPanel1 = g_ui.loadUI('actionbar', bottomPanel) + bottomPanel:moveChildToIndex(actionPanel1, 1) + actionPanel2 = g_ui.loadUI('actionbar', bottomPanel) + bottomPanel:moveChildToIndex(actionPanel2, 1) + + actionConfig = g_configs.create("/actionbar.otml") + + setupActionPanel(1, actionPanel1) + setupActionPanel(2, actionPanel2) + + connect(g_game, { + onGameStart = online, + onGameEnd = offline + }) + + if g_game.isOnline() then + show() + end +end + +function terminate() + disconnect(g_game, { + onGameStart = online, + onGameEnd = offline + }) + + saveConfig() + + -- remove hotkeys + for index, panel in ipairs({actionPanel1, actionPanel2}) do + for i, child in ipairs(panel.tabBar:getChildren()) do + local gameRootPanel = modules.game_interface.getRootPanel() + if child.hotkey then + g_keyboard.unbindKeyPress(child.hotkey, child.callback, gameRootPanel) + end + end + end + + actionPanel1:destroy() + actionPanel2:destroy() +end + +function show() + actionPanel1:setOn(g_settings.getBoolean("actionBar1", false)) + actionPanel2:setOn(g_settings.getBoolean("actionBar2", false)) +end + +function hide() + actionPanel1:setOn(false) + actionPanel2:setOn(false) +end + +function switchMode(newMode) + if newMode then + actionPanel1:setImageColor('#ffffff88') + actionPanel2:setImageColor('#ffffff88') + else + actionPanel1:setImageColor('white') + actionPanel2:setImageColor('white') + end +end + +function online() + show() +end + +function offline() + hide() + if hotkeyAssignWindow then + hotkeyAssignWindow:destroy() + hotkeyAssignWindow = nil + end + saveConfig() +end + +function setupActionPanel(index, panel) + local rawConfig = actionConfig:getNode('actions_' .. index) or {} + local config = {} + for i, buttonConfig in pairs(rawConfig) do -- sorting, because key in rawConfig is string + config[tonumber(i)] = buttonConfig + end + for i=1,actionButtonsInPanel do + local action = g_ui.createWidget('ActionButton', panel.tabBar) + setupAction(index, action, config[i]) + end + + panel.nextButton.onClick = function() + panel.tabBar:moveChildToIndex(panel.tabBar:getLastChild(), 1) + end + panel.prevButton.onClick = function() + panel.tabBar:moveChildToIndex(panel.tabBar:getFirstChild(), panel.tabBar:getChildCount()) + end +end + +function saveConfig() + for index, panel in ipairs({actionPanel1, actionPanel2}) do + local config = {} + for i, child in ipairs(panel.tabBar:getChildren()) do + table.insert(config, { + text = child.text:getText(), + item = child.item:getItemId(), + count = child.item:getItemCount(), + action = child.actionType, + hotkey = child.hotkey + }) + end + actionConfig:setNode('actions_' .. index, config) + end + actionConfig:save() +end + +function setupAction(index, action, config) + action.item:setShowCount(false) + action.onMouseRelease = actionOnMouseRelease + action.callback = function(k, c, ticks) executeAction(action, ticks) end + + if config then + action.hotkey = config.hotkey + if action.hotkey then + local gameRootPanel = modules.game_interface.getRootPanel() + g_keyboard.bindKeyPress(action.hotkey, action.callback, gameRootPanel) + end + action.hotkeyLabel:setText(action.hotkey or "") + action.text:setText(config.text) + if action.text:getText():len() > 0 then + action:setBorderColor(ActionColors.text) + end + if config.item > 0 then + setupActionType(action, config.action) + end + action.item:setItemId(config.item) + action.item:setItemCount(config.count) + end + + action.item.onItemChange = actionOnItemChange +end + +function setupActionType(action, actionType) + action.actionType = actionType + if action.actionType == ActionTypes.USE then + action:setBorderColor(ActionColors.itemUse) + elseif action.actionType == ActionTypes.USE_SELF then + action:setBorderColor(ActionColors.itemUseSelf) + elseif action.actionType == ActionTypes.USE_TARGET then + action:setBorderColor(ActionColors.itemUseTarget) + elseif action.actionType == ActionTypes.USE_WITH then + action:setBorderColor(ActionColors.itemUseWith) + end +end + +function executeAction(action, ticks) + if type(ticks) ~= 'number' then ticks = 0 end + + local actionDelay = 100 + if ticks == 0 then + actionDelay = 200 -- for first use + elseif action.actionDelayTo ~= nil and g_clock.millis() < action.actionDelayTo then + return + end + + if action.text:getText():len() > 0 then + modules.game_console.sendMessage(action.text:getText()) + action.actionDelayTo = g_clock.millis() + actionDelay + elseif action.item:getItemId() > 0 then + if action.actionType == ActionTypes.USE then + if g_game.getClientVersion() < 740 then + local item = g_game.findPlayerItem(action.item:getItemId(), hotKey.subType or -1) + if item then + g_game.use(item) + end + else + g_game.useInventoryItem(action.item:getItemId()) + end + action.actionDelayTo = g_clock.millis() + actionDelay + elseif action.actionType == ActionTypes.USE_SELF then + if g_game.getClientVersion() < 740 then + local item = g_game.findPlayerItem(action.item:getItemId(), hotKey.subType or -1) + if item then + g_game.useWith(item, g_game.getLocalPlayer()) + end + else + g_game.useInventoryItemWith(action.item:getItemId(), g_game.getLocalPlayer(), action.item:getItemSubType() or -1) + end + action.actionDelayTo = g_clock.millis() + actionDelay + elseif action.actionType == ActionTypes.USE_TARGET then + local attackingCreature = g_game.getAttackingCreature() + if not attackingCreature then + local item = Item.create(action.item:getItemId()) + if g_game.getClientVersion() < 740 then + local tmpItem = g_game.findPlayerItem(action.item:getItemId(), action.item:getItemSubType() or -1) + if not tmpItem then return end + item = tmpItem + end + + modules.game_interface.startUseWith(item, action.item:getItemSubType() or - 1) + return + end + + if not attackingCreature:getTile() then return end + if g_game.getClientVersion() < 740 then + local item = g_game.findPlayerItem(action.item:getItemId(), action.item:getItemSubType() or -1) + if item then + g_game.useWith(item, attackingCreature, action.item:getItemSubType() or -1) + end + else + g_game.useInventoryItemWith(action.item:getItemId(), attackingCreature, action.item:getItemSubType() or -1) + end + action.actionDelayTo = g_clock.millis() + actionDelay + elseif action.actionType == ActionTypes.USE_WITH then + local item = Item.create(action.item:getItemId()) + if g_game.getClientVersion() < 740 then + local tmpItem = g_game.findPlayerItem(action.item:getItemId(), action.item:getItemSubType() or -1) + if not tmpItem then return true end + item = tmpItem + end + modules.game_interface.startUseWith(item, action.item:getItemSubType() or - 1) + end + end +end + +function actionOnMouseRelease(action, mousePosition, mouseButton) + if mouseButton == MouseRightButton then + local menu = g_ui.createWidget('PopupMenu') + menu:setGameMenu(true) + if action.item:getItemId() > 0 and action.item:getItem():isMultiUse() then + menu:addOption(tr('Use on yourself'), function() return setupActionType(action, ActionTypes.USE_SELF) end) + menu:addOption(tr('Use on target'), function() return setupActionType(action, ActionTypes.USE_TARGET) end) + menu:addOption(tr('With crosshair'), function() return setupActionType(action, ActionTypes.USE_WITH) end) + end + menu:addSeparator() + menu:addOption(tr('Set text'), function() + modules.game_textedit.singlelineEditor(action.text:getText(), function(newText) + action.item:setItemId(0) + action.text:setText(newText) + if action.text:getText():len() > 0 then + action:setBorderColor(ActionColors.text) + end + end) + end) + menu:addOption(tr('Set hotkey'), function() + if hotkeyAssignWindow then + hotkeyAssignWindow:destroy() + end + local assignWindow = g_ui.createWidget('ActionAssignWindow', rootWidget) + assignWindow:grabKeyboard() + assignWindow.comboPreview.keyCombo = '' + assignWindow.onKeyDown = function(assignWindow, keyCode, keyboardModifiers) + local keyCombo = determineKeyComboDesc(keyCode, keyboardModifiers) + assignWindow.comboPreview:setText(tr('Current action hotkey: %s', keyCombo)) + assignWindow.comboPreview.keyCombo = keyCombo + assignWindow.comboPreview:resizeToText() + return true + end + assignWindow.onDestroy = function() + hotkeyAssignWindow = nil + end + assignWindow.addButton.onClick = function() + local gameRootPanel = modules.game_interface.getRootPanel() + if action.hotkey then + g_keyboard.unbindKeyPress(action.hotkey, action.callback, gameRootPanel) + end + action.hotkey = assignWindow.comboPreview.keyCombo + if action.hotkey then + g_keyboard.bindKeyPress(action.hotkey, action.callback, gameRootPanel) + end + action.hotkeyLabel:setText(action.hotkey or "") + assignWindow:destroy() + end + hotkeyAssignWindow = assignWindow + end) + menu:addSeparator() + menu:addOption(tr('Clear'), function() + action.item:setItem(nil) + action.text:setText("") + action.hotkeyLabel:setText("") + local gameRootPanel = modules.game_interface.getRootPanel() + if action.hotkey then + g_keyboard.unbindKeyPress(action.hotkey, action.callback, gameRootPanel) + end + action.hotkey = nil + action.actionType = nil + action:setBorderColor(ActionColors.empty) + end) + menu:display(mousePosition) + return true + elseif mouseButton == MouseLeftButton then + action.callback() + return true + end + return false +end + +function actionOnItemChange(widget) + local action = widget:getParent() + if action.item:getItemId() > 0 then + action.text:setText("") + if action.item:getItem():isMultiUse() then + if not action.actionType or action.actionType <= 1 then + setupActionType(action, ActionTypes.USE_WITH) + end + else + setupActionType(action, ActionTypes.USE) + end + end +end \ No newline at end of file diff --git a/modules/game_actionbar/actionbar.otmod b/modules/game_actionbar/actionbar.otmod new file mode 100644 index 0000000..b11c62c --- /dev/null +++ b/modules/game_actionbar/actionbar.otmod @@ -0,0 +1,9 @@ +Module + name: game_actionbar + description: Action bar + author: otclient@otclient.ovh + website: otclient.ovh + sandboxed: true + scripts: [ actionbar ] + @onLoad: init() + @onUnload: terminate() diff --git a/modules/game_actionbar/actionbar.otui b/modules/game_actionbar/actionbar.otui new file mode 100644 index 0000000..cd6495b --- /dev/null +++ b/modules/game_actionbar/actionbar.otui @@ -0,0 +1,134 @@ +ActionButton < Panel + size: 36 36 + font: cipsoftFont + anchors.top: parent.top + margin-left: 3 + border-width: 1 + border-color: #00000022 + + $first: + anchors.left: parent.left + + $!first: + anchors.left: prev.right + + Item + id: item + anchors.fill: parent + margin: 1 1 1 1 + item-id: 3307 + &selectable: true + &editable: false + virtual: true + + Label + id: text + anchors.fill: parent + margin: 3 3 3 3 + text-auto-resize: true + text-wrap: true + text-align: center + font: verdana-9px + + Label + id: hotkeyLabel + anchors.top: parent.top + anchors.left: parent.left + margin: 2 3 3 3 + text-auto-resize: true + text-wrap: false + font: small-9px + color: #D3D3D3 + +Panel + id: actionBar + anchors.left: parent.left + anchors.right: parent.right + image-source: /images/ui/panel_bottom + image-border: 6 + focusable: false + + $first: + anchors.top: parent.top + + $!first: + anchors.top: prev.bottom + + $on: + height: 40 + visible: true + + $!on: + height: 0 + visible: false + + TabButton + id: prevButton + icon: /images/game/console/leftarrow + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + margin-left: 1 + + Panel + id: tabBar + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.left: prev.right + anchors.right: next.left + margin-right: 3 + margin-top: 2 + clipping: true + + + TabButton + id: nextButton + icon: /images/game/console/rightarrow + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + margin-right: 1 + + +ActionAssignWindow < MainWindow + id: assignWindow + !text: tr('Button Assign') + size: 360 150 + @onEscape: self:destroy() + + Label + !text: tr('Please, press the key you wish to use for action') + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + text-auto-resize: true + text-align: left + + Label + id: comboPreview + !text: tr('Current action hotkey: %s', 'none') + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: prev.bottom + margin-top: 10 + text-auto-resize: true + + HorizontalSeparator + id: separator + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: next.top + margin-bottom: 10 + + Button + id: addButton + !text: tr('Add') + width: 64 + anchors.right: next.left + anchors.bottom: parent.bottom + margin-right: 10 + + Button + id: cancelButton + !text: tr('Cancel') + width: 64 + anchors.right: parent.right + anchors.bottom: parent.bottom + @onClick: self:getParent():destroy() \ No newline at end of file diff --git a/modules/game_battle/battle.lua b/modules/game_battle/battle.lua index 33579e4..033d75d 100644 --- a/modules/game_battle/battle.lua +++ b/modules/game_battle/battle.lua @@ -3,25 +3,16 @@ battleButton = nil battlePanel = nil filterPanel = nil toggleFilterButton = nil -battleButtonsList = {} mouseWidget = nil - -sortTypeBox = nil -sortOrderBox = nil -hidePlayersButton = nil -hideNPCsButton = nil -hideMonstersButton = nil -hideSkullsButton = nil -hidePartyButton = nil - updateEvent = nil hoveredCreature = nil newHoveredCreature = nil prevCreature = nil -local creatureAgeCounter = 1 +battleButtons = {} +local ageNumber = 1 function init() g_ui.importStyle('battlebutton') @@ -43,13 +34,8 @@ function init() hideFilterPanel() end - sortTypeBox = battleWindow:recursiveGetChildById('sortTypeBox') - sortOrderBox = battleWindow:recursiveGetChildById('sortOrderBox') - hidePlayersButton = battleWindow:recursiveGetChildById('hidePlayers') - hideNPCsButton = battleWindow:recursiveGetChildById('hideNPCs') - hideMonstersButton = battleWindow:recursiveGetChildById('hideMonsters') - hideSkullsButton = battleWindow:recursiveGetChildById('hideSkulls') - hidePartyButton = battleWindow:recursiveGetChildById('hideParty') + local sortTypeBox = filterPanel.sortPanel.sortTypeBox + local sortOrderBox = filterPanel.sortPanel.sortOrderBox mouseWidget = g_ui.createWidget('UIButton') mouseWidget:setVisible(false) @@ -70,11 +56,21 @@ function init() sortOrderBox:setCurrentOptionByData(getSortOrder()) sortOrderBox.onOptionChange = onChangeSortOrder - updateBattleList() battleWindow:setup() + for i=1,30 do + local battleButton = g_ui.createWidget('BattleButton', battlePanel) + battleButton:setup() + battleButton:hide() + battleButton.onHoverChange = onBattleButtonHoverChange + battleButton.onMouseRelease = onBattleButtonMouseRelease + table.insert(battleButtons, battleButton) + end + + updateBattleList() + connect(LocalPlayer, { - onPositionChange = onCreaturePositionChange + onPositionChange = onPlayerPositionChange }) connect(Creature, { onAppear = updateSquare, @@ -91,14 +87,15 @@ function terminate() return end + battleButtons = {} + g_keyboard.unbindKeyDown('Ctrl+B') - battleButtonsByCreaturesList = {} battleButton:destroy() battleWindow:destroy() mouseWidget:destroy() disconnect(LocalPlayer, { - onPositionChange = onCreaturePositionChange + onPositionChange = onPlayerPositionChange }) disconnect(Creature, { onAppear = onCreatureAppear, @@ -216,7 +213,8 @@ end -- functions function updateBattleList() - updateEvent = scheduleEvent(updateBattleList, 200) + removeEvent(updateEvent) + updateEvent = scheduleEvent(updateBattleList, 100) checkCreatures() end @@ -229,68 +227,54 @@ function checkCreatures() if not player then return end + local dimension = modules.game_interface.getMapPanel():getVisibleDimension() local spectators = g_map.getSpectatorsInRangeEx(player:getPosition(), false, math.floor(dimension.width / 2), math.floor(dimension.width / 2), math.floor(dimension.height / 2), math.floor(dimension.height / 2)) + local maxCreatures = battlePanel:getChildCount() local creatures = {} for _, creature in ipairs(spectators) do - if doCreatureFitFilters(creature) then + if doCreatureFitFilters(creature) and #creatures < maxCreatures then + if not creature.age then + creature.age = ageNumber + ageNumber = ageNumber + 1 + end table.insert(creatures, creature) end end updateSquare() + sortCreatures(creatures) + battlePanel:getLayout():disableUpdates() -- sorting - local creature_i = 1 - sortCreatures(creatures) - for i=1, #creatures do - if creature_i > 30 then - break - end - + local ascOrder = isSortAsc() + for i=1,#creatures do local creature = creatures[i] - if isSortAsc() then + if ascOrder then creature = creatures[#creatures - i + 1] end - - if creature:getHealthPercent() > 0 then - local battleButton = battleButtonsList[creature_i] - - if battleButton == nil then - battleButton = g_ui.createWidget('BattleButton') - battleButton.onHoverChange = onBattleButtonHoverChange - battleButton.onMouseRelease = onBattleButtonMouseRelease - battleButton:setup(creature, creature_i) - table.insert(battleButtonsList, battleButton) - battlePanel:addChild(battleButton) - end - - battleButton:creatureSetup(creature) - battleButton:enable() - creature_i = creature_i + 1 - end + local battleButton = battleButtons[i] + battleButton:creatureSetup(creature) + battleButton:show() end - for i=#creatures + 1, 30 do - local battleButton = battleButtonsList[i] - if battleButton then - battleButton:disable() - end + + for i=#creatures + 1,maxCreatures do + if battleButtons[i]:isHidden() then break end + battleButtons[i]:hide() end - local height = 0 - if creature_i > 1 then - height = 25 * (creature_i - 1) - end - if battlePanel:getHeight() ~= height then - battlePanel:setHeight(height) - end + battlePanel:getLayout():enableUpdates() + battlePanel:getLayout():update() end function doCreatureFitFilters(creature) if creature:isLocalPlayer() then return false end + if creature:getHealthPercent() <= 0 then + return false + end local pos = creature:getPosition() if not pos then return false end @@ -298,11 +282,11 @@ function doCreatureFitFilters(creature) local localPlayer = g_game.getLocalPlayer() if pos.z ~= localPlayer:getPosition().z or not creature:canBeSeen() then return false end - local hidePlayers = hidePlayersButton:isChecked() - local hideNPCs = hideNPCsButton:isChecked() - local hideMonsters = hideMonstersButton:isChecked() - local hideSkulls = hideSkullsButton:isChecked() - local hideParty = hidePartyButton:isChecked() + local hidePlayers = filterPanel.buttons.hidePlayers:isChecked() + local hideNPCs = filterPanel.buttons.hideNPCs:isChecked() + local hideMonsters = filterPanel.buttons.hideMonsters:isChecked() + local hideSkulls = filterPanel.buttons.hideSkulls:isChecked() + local hideParty = filterPanel.buttons.hideParty:isChecked() if hidePlayers and creature:isPlayer() then return false @@ -327,26 +311,26 @@ function sortCreatures(creatures) local player = g_game.getLocalPlayer() if getSortType() == 'distance' then - local playerPos = player:getPosition() + local playerPos = player:getPosition() table.sort(creatures, function(a, b) if getDistanceBetween(playerPos, a:getPosition()) == getDistanceBetween(playerPos, b:getPosition()) then - return a:getAge() > b:getAge() + return a.age > b.age end return getDistanceBetween(playerPos, a:getPosition()) > getDistanceBetween(playerPos, b:getPosition()) end) elseif getSortType() == 'health' then table.sort(creatures, function(a, b) if a:getHealthPercent() == b:getHealthPercent() then - return a:getAge() > b:getAge() + return a.age > b.age end return a:getHealthPercent() > b:getHealthPercent() end) elseif getSortType() == 'age' then - table.sort(creatures, function(a, b) return a:getAge() > b:getAge() end) + table.sort(creatures, function(a, b) return a.age > b.age end) else -- name table.sort(creatures, function(a, b) if a:getName():lower() == b:getName():lower() then - return a:getAge() > b:getAge() + return a.age > b.age end return a:getName():lower() > b:getName():lower() end) @@ -397,12 +381,8 @@ function onBattleButtonHoverChange(battleButton, hovered) updateSquare() end -function onCreaturePositionChange(creature, newPos, oldPos) - if creature:isLocalPlayer() then - if oldPos and newPos and newPos.z ~= oldPos.z then - checkCreatures() - end - end +function onPlayerPositionChange(creature, newPos, oldPos) + addEvent(checkCreatures) end local CreatureButtonColors = { diff --git a/modules/game_battle/battle.otui b/modules/game_battle/battle.otui index 2e80774..0d0ef05 100644 --- a/modules/game_battle/battle.otui +++ b/modules/game_battle/battle.otui @@ -54,6 +54,7 @@ MiniWindow height: 45 Panel + id: buttons anchors.top: parent.top anchors.horizontalCenter: parent.horizontalCenter height: 20 @@ -88,6 +89,7 @@ MiniWindow @onCheckChange: modules.game_battle.checkCreatures() Panel + id: sortPanel anchors.top: prev.bottom anchors.left: parent.left anchors.right: parent.right @@ -147,3 +149,4 @@ MiniWindow padding-right: 5 layout: type: verticalBox + fit-children: true diff --git a/modules/game_bot/bot.lua b/modules/game_bot/bot.lua index d5a273b..833f648 100644 --- a/modules/game_bot/bot.lua +++ b/modules/game_bot/bot.lua @@ -163,7 +163,6 @@ function refresh() configList.onOptionChange = function(widget) settings[index].config = widget:getCurrentOption().text - settings[index].enabled = false g_settings.setNode('bot', settings) g_settings.save() refresh() @@ -178,7 +177,7 @@ function refresh() if not g_game.isOnline() or not settings[index].enabled then statusLabel:setOn(true) - statusLabel:setText("Status: disabled") + statusLabel:setText("Status: disabled\nPress off button to enable") return end @@ -381,7 +380,9 @@ function initCallbacks() }) connect(g_map, { - onMissle = botOnMissle + onMissle = botOnMissle, + onAnimatedText = botOnAnimatedText, + onStaticText = botOnStaticText }) end @@ -427,7 +428,9 @@ function terminateCallbacks() }) disconnect(g_map, { - onMissle = botOnMissle + onMissle = botOnMissle, + onAnimatedText = botOnAnimatedText, + onStaticText = botOnStaticText }) end @@ -526,6 +529,16 @@ function botOnMissle(missle) safeBotCall(function() botExecutor.callbacks.onMissle(missle) end) end +function botOnAnimatedText(thing, text) + if botExecutor == nil then return false end + safeBotCall(function() botExecutor.callbacks.onAnimatedText(thing, text) end) +end + +function botOnStaticText(thing, text) + if botExecutor == nil then return false end + safeBotCall(function() botExecutor.callbacks.onStaticText(thing, text) end) +end + function botChannelList(channels) if botExecutor == nil then return false end safeBotCall(function() botExecutor.callbacks.onChannelList(channels) end) diff --git a/modules/game_bot/executor.lua b/modules/game_bot/executor.lua index 366f60d..ed3c4c2 100644 --- a/modules/game_bot/executor.lua +++ b/modules/game_bot/executor.lua @@ -52,6 +52,8 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, webs onContainerClose = {}, onContainerUpdateItem = {}, onMissle = {}, + onAnimatedText = {}, + onStaticText = {}, onChannelList = {}, onOpenChannel = {}, onCloseChannel = {}, @@ -275,6 +277,16 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, webs callback(missle) end end, + onAnimatedText = function(thing, text) + for i, callback in ipairs(context._callbacks.onAnimatedText) do + callback(thing, text) + end + end, + onStaticText = function(thing, text) + for i, callback in ipairs(context._callbacks.onStaticText) do + callback(thing, text) + end + end, onChannelList = function(channels) for i, callback in ipairs(context._callbacks.onChannelList) do callback(channels) diff --git a/modules/game_bot/functions/callbacks.lua b/modules/game_bot/functions/callbacks.lua index 60386fc..3ab5420 100644 --- a/modules/game_bot/functions/callbacks.lua +++ b/modules/game_bot/functions/callbacks.lua @@ -116,6 +116,16 @@ context.onMissle = function(callback) return context.callback("onMissle", callback) end +-- onAnimatedText -- callback = function(thing, text) +context.onAnimatedText = function(callback) + return context.callback("onAnimatedText", callback) +end + +-- onStaticText -- callback = function(thing, text) +context.onStaticText = function(callback) + return context.callback("onStaticText", callback) +end + -- onChannelList -- callback = function(channels) context.onChannelList = function(callback) return context.callback("onChannelList", callback) diff --git a/modules/game_bot/functions/icon.lua b/modules/game_bot/functions/icon.lua index 0a8d82c..6c44796 100644 --- a/modules/game_bot/functions/icon.lua +++ b/modules/game_bot/functions/icon.lua @@ -123,7 +123,7 @@ context.addIcon = function(id, options, callback) widget.onDragMove = function(widget, mousePos, moved) local parentRect = widget:getParent():getRect() local x = math.min(math.max(parentRect.x, mousePos.x - widget.movingReference.x), parentRect.x + parentRect.width - widget:getWidth()) - local y = math.min(math.max(parentRect.y, mousePos.y - widget.movingReference.y), parentRect.y + parentRect.height - widget:getHeight()) + local y = math.min(math.max(parentRect.y - widget:getParent():getMarginTop(), mousePos.y - widget.movingReference.y), parentRect.y + parentRect.height - widget:getHeight()) widget:move(x, y) return true end @@ -141,8 +141,8 @@ context.addIcon = function(id, options, callback) widget:addAnchor(AnchorHorizontalCenter, 'parent', AnchorHorizontalCenter) widget:addAnchor(AnchorVerticalCenter, 'parent', AnchorVerticalCenter) - widget:setMarginTop(height * (-0.5 + config.x)) - widget:setMarginLeft(width * (-0.5 + config.y)) + widget:setMarginTop(height * (-0.5 + config.y)) + widget:setMarginLeft(width * (-0.5 + config.x)) return true end end @@ -153,7 +153,7 @@ context.addIcon = function(id, options, callback) local parentRect = parent:getRect() local width = parentRect.width - widget:getWidth() local height = parentRect.height - widget:getHeight() - widget:setMarginTop(height * (-0.5 + config.y)) + widget:setMarginTop(-parent:getMarginTop() + height * (-0.5 + config.y)) widget:setMarginLeft(width * (-0.5 + config.x)) end diff --git a/modules/game_bot/functions/tools.lua b/modules/game_bot/functions/tools.lua index c76ab1b..9c121b0 100644 --- a/modules/game_bot/functions/tools.lua +++ b/modules/game_bot/functions/tools.lua @@ -7,4 +7,9 @@ context.displayGeneralBox = function(title, message, buttons, onEnterCallback, o local box = displayGeneralBox(title, message, buttons, onEnterCallback, onEscapeCallback) box.botWidget = true return box -end \ No newline at end of file +end + +context.doScreenshot = function(filename) + g_app.doScreenshot(filename) +end +context.screenshot = context.doScreenshot diff --git a/modules/game_bot/ui/basic.otui b/modules/game_bot/ui/basic.otui index 04edb22..0ddddb3 100644 --- a/modules/game_bot/ui/basic.otui +++ b/modules/game_bot/ui/basic.otui @@ -26,6 +26,7 @@ BotLabel < Label BotItem < Item virtual: true &selectable: true + &editable: true BotTextEdit < TextEdit @onClick: modules.game_textedit.show(self) @@ -38,66 +39,7 @@ BotSeparator < HorizontalSeparator margin-top: 5 margin-bottom: 3 -BotSmallScrollBar < UIScrollBar - orientation: vertical - margin-bottom: 1 - step: 20 - width: 8 - image-source: /images/ui/scrollbar - image-clip: 39 0 13 65 - image-border: 1 - pixels-scroll: true - - UIButton - id: decrementButton - anchors.top: parent.top - anchors.left: parent.left - image-source: /images/ui/scrollbar - image-clip: 0 0 13 13 - image-color: #ffffffff - size: 8 8 - $hover: - image-clip: 13 0 13 13 - $pressed: - image-clip: 26 0 13 13 - $disabled: - image-color: #ffffff66 - - UIButton - id: incrementButton - anchors.bottom: parent.bottom - anchors.right: parent.right - size: 8 8 - image-source: /images/ui/scrollbar - image-clip: 0 13 13 13 - image-color: #ffffffff - $hover: - image-clip: 13 13 13 13 - $pressed: - image-clip: 26 13 13 13 - $disabled: - image-color: #ffffff66 - - UIButton - id: sliderButton - anchors.centerIn: parent - size: 8 11 - image-source: /images/ui/scrollbar - image-clip: 0 26 13 13 - image-border: 2 - image-color: #ffffffff - $hover: - image-clip: 13 26 13 13 - $pressed: - image-clip: 26 26 13 13 - $disabled: - image-color: #ffffff66 - - Label - id: valueLabel - anchors.fill: parent - color: white - text-align: center +BotSmallScrollBar < SmallScrollBar BotPanel < Panel ScrollablePanel diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index 55dfe8a..02961a9 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -383,44 +383,15 @@ function clear() end end -function switchMode(floating) - if floating then +function switchMode(newView) + if newView then consolePanel:setImageColor('#ffffff88') - consolePanel:removeAnchor(AnchorRight) - consolePanel:setWidth(600) - consolePanel:setDraggable(true) - consoleTabBar:setDraggable(true) - - local bottomSplitter = modules.game_interface.bottomSplitter - if bottomSplitter then - bottomSplitter:removeAnchor(AnchorRight) - bottomSplitter:setWidth(600) - end - - if not floatingMode then - local savedMargin = g_settings.get("consoleLeftMargin") - local newMargin = 150 - if savedMargin and #savedMargin > 0 then - newMargin = tonumber(savedMargin) - end - newMargin = math.max(0, newMargin) - newMargin = math.min(consolePanel:getParent():getWidth() - consolePanel:getWidth(), newMargin) - consolePanel:setMarginLeft(newMargin) - if bottomSplitter then - bottomSplitter:setMarginLeft(newMargin) - end - end - - else consolePanel:setImageColor('white') - consolePanel:addAnchor(AnchorLeft, 'parent', AnchorLeft) - consolePanel:addAnchor(AnchorRight, 'parent', AnchorRight) - consolePanel:setDraggable(false) - consoleTabBar:setDraggable(false) - consolePanel:setMarginLeft(0) end - floatingMode = floating + --consolePanel:setDraggable(floating) + --consoleTabBar:setDraggable(floating) + --floatingMode = floating end function onDragEnter(widget, pos) @@ -431,15 +402,7 @@ function onDragMove(widget, pos, moved) if not floatingMode then return end - local newMargin = consolePanel:getMarginLeft() + moved.x - newMargin = math.max(0, newMargin) - newMargin = math.min(consolePanel:getParent():getWidth() - consolePanel:getWidth(), newMargin) - consolePanel:setMarginLeft(newMargin) - local bottomSplitter = modules.game_interface.bottomSplitter - if bottomSplitter then - bottomSplitter:setMarginLeft(newMargin) - end - g_settings.set("consoleLeftMargin", newMargin) + -- update margin return true end diff --git a/modules/game_console/console.otui b/modules/game_console/console.otui index 7a8612e..ada0454 100644 --- a/modules/game_console/console.otui +++ b/modules/game_console/console.otui @@ -57,10 +57,18 @@ ConsoleTabBarButton < MoveableTabBarButton Panel id: consolePanel - anchors.fill: parent image-source: /images/ui/panel_bottom image-border: 4 phantom: false + + $first: + anchors.fill: parent + + $!first: + anchors.top: prev.bottom + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right CheckBox id: toggleChat diff --git a/modules/game_healthinfo/healthinfo.lua b/modules/game_healthinfo/healthinfo.lua index 3ed4465..483d3a8 100644 --- a/modules/game_healthinfo/healthinfo.lua +++ b/modules/game_healthinfo/healthinfo.lua @@ -274,8 +274,8 @@ function onOverlayGeometryChange() topHealthBar:setMarginTop(15) topManaBar:setMarginTop(15) else - topHealthBar:setMarginTop(45) - topManaBar:setMarginTop(45) + topHealthBar:setMarginTop(45 - overlay:getParent():getMarginTop()) + topManaBar:setMarginTop(45 - overlay:getParent():getMarginTop()) minMargin = 200 end @@ -283,6 +283,6 @@ function onOverlayGeometryChange() local width = overlay:getWidth() - topHealthBar:setMarginLeft(math.max(minMargin, (width - height) / 2 + 2)) - topManaBar:setMarginRight(math.max(minMargin, (width - height) / 2 + 2)) + topHealthBar:setMarginLeft(math.max(minMargin, (width - height + 50) / 2 + 2)) + topManaBar:setMarginRight(math.max(minMargin, (width - height + 50) / 2 + 2)) end \ No newline at end of file diff --git a/modules/game_healthinfo/healthinfo.otui b/modules/game_healthinfo/healthinfo.otui index 8419323..a53e42f 100644 --- a/modules/game_healthinfo/healthinfo.otui +++ b/modules/game_healthinfo/healthinfo.otui @@ -93,7 +93,7 @@ HealthOverlay < UIWidget image-source: /images/game/circle/left_empty margin-right: 169 margin-bottom: 16 - opacity: 0.4 + opacity: 0.5 phantom: true UIProgressBar @@ -103,7 +103,7 @@ HealthOverlay < UIWidget image-source: /images/game/circle/left_full margin-right: 169 margin-bottom: 16 - opacity: 0.4 + opacity: 0.5 phantom: true UIProgressBar @@ -113,7 +113,7 @@ HealthOverlay < UIWidget image-source: /images/game/circle/right_empty margin-left: 130 margin-bottom: 16 - opacity: 0.4 + opacity: 0.5 phantom: true UIProgressBar @@ -123,7 +123,7 @@ HealthOverlay < UIWidget image-source: /images/game/circle/right_full margin-left: 130 margin-bottom: 16 - opacity: 0.3 + opacity: 0.4 image-color: #0000FFFF phantom: true diff --git a/modules/game_hotkeys/hotkeys_manager.lua b/modules/game_hotkeys/hotkeys_manager.lua index ffb88c8..a51738f 100644 --- a/modules/game_hotkeys/hotkeys_manager.lua +++ b/modules/game_hotkeys/hotkeys_manager.lua @@ -545,7 +545,6 @@ function updateHotkeyLabel(hotkeyLabel) end function updateHotkeyForm(reset) - local hasCustomAction = hotkeysWindow.action and hotkeysWindow.action.currentIndex > 1 configValueChanged = true if hotkeysWindow.action then if currentHotkeyLabel then @@ -560,6 +559,7 @@ function updateHotkeyForm(reset) hotkeysWindow.action:setCurrentIndex(1, true) end end + local hasCustomAction = hotkeysWindow.action and hotkeysWindow.action.currentIndex > 1 if currentHotkeyLabel and not hasCustomAction then removeHotkeyButton:enable() if currentHotkeyLabel.itemId ~= nil then diff --git a/modules/game_interface/gameinterface.lua b/modules/game_interface/gameinterface.lua index 898b1c5..6114ccd 100644 --- a/modules/game_interface/gameinterface.lua +++ b/modules/game_interface/gameinterface.lua @@ -830,7 +830,7 @@ function refreshViewMode() local minimumWidth = (g_settings.getNumber("rightPanels") + g_settings.getNumber("leftPanels") - 1) * 200 if classic then - minimumWidth = minimumWidth + 300 + minimumWidth = minimumWidth + 400 end minimumWidth = math.max(minimumWidth, 800) g_window.setMinimumSize({ width = minimumWidth, height = 600 }) @@ -866,6 +866,7 @@ function refreshViewMode() end gameMapPanel:setVisibleDimension({ width = 15, height = 11 }) + gameMapPanel:setMarginTop(0) if classic then gameRootPanel:addAnchor(AnchorTop, 'topMenu', AnchorBottom) @@ -878,9 +879,6 @@ function refreshViewMode() gameBottomPanel:addAnchor(AnchorLeft, 'gameLeftPanels', AnchorRight) gameBottomPanel:addAnchor(AnchorRight, 'gameRightPanels', AnchorLeft) - bottomSplitter:addAnchor(AnchorLeft, 'gameLeftPanels', AnchorRight) - bottomSplitter:addAnchor(AnchorRight, 'gameRightPanels', AnchorLeft) - bottomSplitter:setMarginLeft(0) modules.client_topmenu.getTopMenu():setImageColor('white') gameBottomPanel:setImageColor('white') @@ -890,28 +888,28 @@ function refreshViewMode() modules.game_console.switchMode(false) end else - g_game.changeMapAwareRange(29, 19) + g_game.changeMapAwareRange(31, 21) gameMapPanel:fill('parent') gameRootPanel:fill('parent') gameMapPanel:setKeepAspectRatio(false) gameMapPanel:setLimitVisibleRange(false) - if g_game.getFeature(GameChangeMapAwareRange) then - gameMapPanel:setZoom(13) - else - gameMapPanel:setZoom(11) - end - - gameBottomPanel:addAnchor(AnchorLeft, 'parent', AnchorLeft) - gameBottomPanel:addAnchor(AnchorRight, 'parent', AnchorRight) - bottomSplitter:addAnchor(AnchorLeft, 'parent', AnchorLeft) - bottomSplitter:addAnchor(AnchorRight, 'parent', AnchorRight) - + gameMapPanel:setZoom(14) + modules.client_topmenu.getTopMenu():setImageColor('#ffffff66') if modules.game_console then modules.game_console.switchMode(true) end end + if modules.game_actionbar then + modules.game_actionbar.switchMode(not classic) + end + + if g_settings.getBoolean("cacheMap") then + g_game.enableFeature(GameBiggerMapCache) + end + + updateSize() end function limitZoom() @@ -922,15 +920,6 @@ function updateSize() local classic = g_settings.getBoolean("classicView") local height = gameMapPanel:getHeight() local width = gameMapPanel:getWidth() - - if not classic and modules.game_console then - local newMargin = modules.game_console.consolePanel:getMarginLeft() - newMargin = math.max(0, newMargin) - newMargin = math.min(modules.game_console.consolePanel:getParent():getWidth() - modules.game_console.consolePanel:getWidth(), newMargin) - bottomSplitter:setMarginLeft(newMargin) - modules.game_console.consolePanel:setMarginLeft(newMargin) - bottomSplitter:setMarginLeft(newMargin) - end if not classic then local rheight = gameRootPanel:getHeight() @@ -941,11 +930,20 @@ function updateSize() local awareRange = g_map.getAwareRange() local dheight = dimenstion.height local dwidth = dimenstion.width - local tileSize = rheight / dheight - local maxWidth = tileSize * (awareRange.width - 4) - local margin = math.max(0, math.floor((rwidth - maxWidth) / 2)) - gameMapPanel:setMarginLeft(margin) - gameMapPanel:setMarginRight(margin) + local tileSize = rheight / dheight + local maxWidth = tileSize * (awareRange.width + 1) + if g_game.getFeature(GameChangeMapAwareRange) then + local maxWidth = tileSize * (awareRange.width - 1) + end + gameMapPanel:setMarginTop(-tileSize * 2) + if g_settings.getBoolean("cacheMap") then + gameMapPanel:setMarginLeft(0) + gameMapPanel:setMarginRight(0) + else + local margin = math.max(0, math.floor((rwidth - maxWidth) / 2)) + gameMapPanel:setMarginLeft(margin) + gameMapPanel:setMarginRight(margin) + end end --[[ diff --git a/modules/game_interface/gameinterface.otui b/modules/game_interface/gameinterface.otui index bef21d8..9936085 100644 --- a/modules/game_interface/gameinterface.otui +++ b/modules/game_interface/gameinterface.otui @@ -55,23 +55,24 @@ UIWidget fit-children: true spacing: -1 - GameBottomPanel - id: gameBottomPanel - anchors.left: gameLeftPanels.right - anchors.right: gameRightPanels.left - anchors.top: bottomSplitter.top - anchors.bottom: parent.bottom - Splitter id: bottomSplitter anchors.left: gameLeftPanels.right anchors.right: gameRightPanels.left anchors.bottom: parent.bottom relative-margin: bottom - margin-bottom: 172 - @canUpdateMargin: function(self, newMargin) if modules.client_options.getOption('dontStretchShrink') then return self:getMarginBottom() end return math.max(math.min(newMargin, self:getParent():getHeight() - 300), 100) end - @onGeometryChange: function(self) self:setMarginBottom(math.min(math.max(self:getParent():getHeight() - 300, 100), self:getMarginBottom())) end + margin-bottom: 180 + @canUpdateMargin: function(self, newMargin) if modules.client_options.getOption('dontStretchShrink') then return self:getMarginBottom() end return math.max(math.min(newMargin, self:getParent():getHeight() - 300), 80) end + @onGeometryChange: function(self) self:setMarginBottom(math.min(math.max(self:getParent():getHeight() - 300, 80), self:getMarginBottom())) end + GameBottomPanel + id: gameBottomPanel + anchors.left: bottomSplitter.left + anchors.right: bottomSplitter.right + anchors.top: bottomSplitter.top + anchors.bottom: parent.bottom + margin-top: 3 + UIWidget id: mouseGrabber focusable: false diff --git a/modules/game_interface/interface.otmod b/modules/game_interface/interface.otmod index da19005..a54f732 100644 --- a/modules/game_interface/interface.otmod +++ b/modules/game_interface/interface.otmod @@ -34,6 +34,7 @@ Module - game_shop - game_itemselector - game_textedit + - game_actionbar - game_bot @onLoad: init() @onUnload: terminate() diff --git a/modules/game_inventory/inventory.lua b/modules/game_inventory/inventory.lua index c99a94a..79aa8dd 100644 --- a/modules/game_inventory/inventory.lua +++ b/modules/game_inventory/inventory.lua @@ -69,14 +69,19 @@ function init() end purseButton = inventoryWindow:recursiveGetChildById('purseButton') - marketButton = inventoryWindow:recursiveGetChildById('marketButton') - local function purseFunction() + purseButton.onClick = function() local purse = g_game.getLocalPlayer():getInventoryItem(InventorySlotPurse) if purse then g_game.use(purse) end end - purseButton.onClick = purseFunction + + marketButton = inventoryWindow:recursiveGetChildById('marketButton') + marketButton.onClick = function() + if modules.game_shop then + modules.game_shop.toggle() + end + end -- controls fightOffensiveBox = inventoryWindow:recursiveGetChildById('fightOffensiveBox') @@ -206,7 +211,7 @@ function refresh() end purseButton:setVisible(g_game.getFeature(GamePurseSlot)) - marketButton:setVisible(g_game.getFeature(GamePurseSlot)) + marketButton:setVisible(g_game.getFeature(GameIngameStore)) end function toggle() diff --git a/modules/game_shop/shop.lua b/modules/game_shop/shop.lua index 1d9b39e..2d615ae 100644 --- a/modules/game_shop/shop.lua +++ b/modules/game_shop/shop.lua @@ -2,10 +2,15 @@ local SHOP_EXTENTED_OPCODE = 201 shop = nil +local otcv8shop = false local shopButton = nil local msgWindow = nil local browsingHistory = false +-- for classic store +local storeUrl = "" +local coinsPacketSize = 0 + local CATEGORIES = {} local HISTORY = {} local STATUS = {} @@ -14,6 +19,10 @@ local AD = {} local selectedOffer = {} local function sendAction(action, data) + if not g_game.getFeature(GameExtendedOpcode) then + return + end + local protocolGame = g_game.getProtocolGame() if data == nil then data = {} @@ -25,16 +34,37 @@ end -- public functions function init() - connect(g_game, { onGameStart = check, onGameEnd = hide }) - ProtocolGame.registerExtendedJSONOpcode(SHOP_EXTENTED_OPCODE, onExtendedJSONOpcode) + connect(g_game, { + onGameStart = check, + onGameEnd = hide, + onStoreInit = onStoreInit, + onStoreCategories = onStoreCategories, + onStoreOffers = onStoreOffers, + onStoreTransactionHistory = onStoreTransactionHistory, + onStorePurchase = onStorePurchase, + onStoreError = onStoreError, + onCoinBalance = onCoinBalance + }) + ProtocolGame.registerExtendedJSONOpcode(SHOP_EXTENTED_OPCODE, onExtendedJSONOpcode) + if g_game.isOnline() then check() end end function terminate() - disconnect(g_game, { onGameStart = check, onGameEnd = hide }) + disconnect(g_game, { + onGameStart = check, + onGameEnd = hide, + onStoreInit = onStoreInit, + onStoreCategories = onStoreCategories, + onStoreOffers = onStoreOffers, + onStoreTransactionHistory = onStoreTransactionHistory, + onStorePurchase = onStorePurchase, + onStoreError = onStoreError, + onCoinBalance = onCoinBalance + }) ProtocolGame.unregisterExtendedJSONOpcode(SHOP_EXTENTED_OPCODE, onExtendedJSONOpcode) @@ -53,9 +83,7 @@ function terminate() end function check() - if not g_game.getFeature(GameExtendedOpcode) then - return - end + otcv8shop = false sendAction("init") end @@ -70,6 +98,10 @@ function show() if not shop or not shopButton then return end + if g_game.getFeature(GameIngameStore) then + g_game.openStore(0) + end + shop:show() shop:raise() shop:focus() @@ -86,14 +118,124 @@ function toggle() check() end -function onExtendedJSONOpcode(protocol, code, json_data) - if not shop then - shop = g_ui.displayUI('shop') - shop:hide() - shopButton = modules.client_topmenu.addRightGameToggleButton('shopButton', tr('Shop'), '/images/topbuttons/shop', toggle) +function createShop() + if shop then return end + shop = g_ui.displayUI('shop') + shop:hide() + shopButton = modules.client_topmenu.addRightGameToggleButton('shopButton', tr('Shop'), '/images/topbuttons/shop', toggle) + connect(shop.categories, { onChildFocusChange = changeCategory }) +end - connect(shop.categories, { onChildFocusChange = changeCategory }) + +function onStoreInit(url, coins) + if otcv8shop then return end + storeUrl = url + if storeUrl:len() > 0 then + if storeUrl:sub(storeUrl:len(), storeUrl:len()) ~= "/" then + storeUrl = storeUrl .. "/" + end + storeUrl = storeUrl .. "64/" + if storeUrl:sub(1, 4):lower() ~= "http" then + storeUrl = "http://" .. storeUrl + end end + coinsPacketSize = coins + createShop() +end + +function onStoreCategories(categories) + if otcv8shop then return end + local correctCategories = {} + for i, category in ipairs(categories) do + table.insert(correctCategories, { + type = "image", + image = storeUrl .. category.icon, + name = category.name, + offers = {} + }) + end + processCategories(correctCategories) +end + +function onStoreOffers(categoryName, offers) + if otcv8shop then return end + local updated = false + + for i, category in ipairs(CATEGORIES) do + if category.name == categoryName then + if #category.offers ~= #offers then + updated = true + end + for i=1,#category.offers do + if category.offers[i].title ~= offers[i].name or category.offers[i].id ~= offers[i].id or category.offers[i].cost ~= offers[i].price then + updated = true + end + end + if updated then + for offer in pairs(category.offers) do + category.offers[offer] = nil + end + for i, offer in ipairs(offers) do + table.insert(category.offers, { + id=offer.id, + type="image", + image=storeUrl .. offer.icon, + cost=offer.price, + title=offer.name, + description=offer.description + }) + end + end + end + end + if not updated then + return + end + + local activeCategory = shop.categories:getFocusedChild() + changeCategory(activeCategory, activeCategory) +end + +function onStoreTransactionHistory(currentPage, hasNextPage, offers) + if otcv8shop then return end + HISTORY = {} + for i, offer in ipairs(offers) do + table.insert(HISTORY, { + id=offer.id, + type="image", + image=storeUrl .. offer.icon, + cost=offer.price, + title=offer.name, + description=offer.description + }) + end + + if not browsingHistory then return end + clearOffers() + shop.categories:focusChild(nil) + for i, transaction in ipairs(HISTORY) do + addOffer(0, transaction) + end +end + +function onStorePurchase(message) + if otcv8shop then return end + processMessage({title="Successful shop purchase", msg=message}) +end + +function onStoreError(errorType, message) + if otcv8shop then return end + processMessage({title="Shop error", msg=message}) +end + +function onCoinBalance(coins, transferableCoins) + shop.infoPanel.points:setText(tr("Points:") .. " " .. coins) + shop.infoPanel.buy:hide() + shop.infoPanel:setHeight(20) +end + +function onExtendedJSONOpcode(protocol, code, json_data) + createShop() local action = json_data['action'] local data = json_data['data'] @@ -101,7 +243,8 @@ function onExtendedJSONOpcode(protocol, code, json_data) if not action or not data then return false end - + + otcv8shop = true if action == 'categories' then processCategories(data) elseif action == 'history' then @@ -166,17 +309,17 @@ function processHistory(data) end function processMessage(data) - if msgWindow then - msgWindow:destroy() - end - - local title = tr(data["title"]) - local msg = data["msg"] - msgWindow = displayInfoBox(title, msg) - msgWindow:show() - msgWindow:raise() - msgWindow:focus() - msgWindow:raise() + if msgWindow then + msgWindow:destroy() + end + + local title = tr(data["title"]) + local msg = data["msg"] + msgWindow = displayInfoBox(title, msg) + msgWindow:show() + msgWindow:raise() + msgWindow:focus() + msgWindow:raise() end function processStatus(data) @@ -198,6 +341,7 @@ function processStatus(data) end else shop.infoPanel.buy:hide() + shop.infoPanel:setHeight(20) end end @@ -268,7 +412,12 @@ function showHistory(force) if browsingHistory and not force then return end + + if g_game.getFeature(GameIngameStore) and not otcv8shop then + g_game.openTransactionHistory(100) + end sendAction("history") + browsingHistory = true clearOffers() shop.categories:focusChild(nil) @@ -295,6 +444,7 @@ function addOffer(category, data) if data["image"]:sub(1, 4):lower() == "http" then HTTP.downloadImage(data['image'], function(path, err) if err then g_logger.warning("HTTP error: " .. err) return end + if not offer.image then return end offer.image:setImageSource(path) end) elseif data["image"] and data["image"]:len() > 1 then @@ -307,6 +457,7 @@ function addOffer(category, data) offer:setId("offer_" .. category .. "_" .. shop.offers:getChildCount()) offer.title:setText(data["title"] .. " (" .. data["cost"] .. " points)") offer.description:setText(data["description"]) + offer.offerId = data["id"] if category ~= 0 then offer.onDoubleClick = buyOffer offer.buyButton.onClick = function() buyOffer(offer) end @@ -318,6 +469,11 @@ function changeCategory(widget, newCategory) if not newCategory then return end + + if g_game.getFeature(GameIngameStore) and widget ~= newCategory and not otcv8shop then + g_game.requestStoreOffers(newCategory.name:getText()) + end + browsingHistory = false local id = tonumber(newCategory:getId():split("_")[2]) clearOffers() @@ -341,7 +497,7 @@ function buyOffer(widget) return end - selectedOffer = {category=category, offer=offer, title=item.title, cost=item.cost} + selectedOffer = {category=category, offer=offer, title=item.title, cost=item.cost, id=widget.offerId} scheduleEvent(function() if msgWindow then @@ -365,6 +521,19 @@ function buyConfirmed() msgWindow:destroy() msgWindow = nil sendAction("buy", selectedOffer) + if g_game.getFeature(GameIngameStore) and selectedOffer.id and not otcv8shop then + local offerName = selectedOffer.title:lower() + if string.find(offerName, "name") and string.find(offerName, "change") and modules.game_textedit then + modules.game_textedit.singlelineEditor("", function(newName) + if newName:len() == 0 then + return + end + g_game.buyStoreOffer(selectedOffer.id, 1, newName) + end) + else + g_game.buyStoreOffer(selectedOffer.id, 0, "") + end + end end function buyCanceled() diff --git a/modules/game_shop/shop.otui b/modules/game_shop/shop.otui index 7c105be..e70bd41 100644 --- a/modules/game_shop/shop.otui +++ b/modules/game_shop/shop.otui @@ -14,7 +14,6 @@ ShopCategory < Panel anchors.bottom: parent.bottom margin-left: 40 text-align: left - text: UAHSbjaS ASDJHASD ASKJD color: white font: verdana-11px-rounded @@ -69,7 +68,6 @@ ShopOffer < Panel margin-top: 4 margin-left: 55 text-align: topleft - text: UAHSbjaS ASDJHASD ASKJD color: white font: verdana-11px-rounded diff --git a/modules/game_textmessage/textmessage.lua b/modules/game_textmessage/textmessage.lua index 2bd80d1..47f9fdf 100644 --- a/modules/game_textmessage/textmessage.lua +++ b/modules/game_textmessage/textmessage.lua @@ -73,7 +73,7 @@ function terminate() end function calculateVisibleTime(text) - return math.max(#text * 100, 4000) + return math.max(#text * 50, 3000) end function displayMessage(mode, text) diff --git a/modules/game_walking/walking.lua b/modules/game_walking/walking.lua index 1203400..3215731 100644 --- a/modules/game_walking/walking.lua +++ b/modules/game_walking/walking.lua @@ -141,7 +141,7 @@ function bindWalkKey(key, dir) local gameRootPanel = modules.game_interface.getRootPanel() g_keyboard.bindKeyDown(key, function() changeWalkDir(dir) end, gameRootPanel, true) g_keyboard.bindKeyUp(key, function() changeWalkDir(dir, true) end, gameRootPanel, true) - g_keyboard.bindKeyPress(key, function() smartWalk(dir) end, gameRootPanel) + g_keyboard.bindKeyPress(key, function(c, k, ticks) smartWalk(dir, ticks) end, gameRootPanel) end function unbindWalkKey(key) @@ -203,11 +203,11 @@ function changeWalkDir(dir, pop) end end -function smartWalk(dir) +function smartWalk(dir, ticks) walkEvent = scheduleEvent(function() if g_keyboard.getModifiers() == KeyboardNoModifier then local direction = smartWalkDir or dir - walk(direction) + walk(direction, ticks) return true end return false @@ -252,7 +252,7 @@ function onWalkFinish(player) lastFinishedStep = g_clock.millis() if nextWalkDir ~= nil then removeEvent(autoWalkEvent) - autoWalkEvent = addEvent(function() if nextWalkDir ~= nil then walk(nextWalkDir) end end, false) + autoWalkEvent = addEvent(function() if nextWalkDir ~= nil then walk(nextWalkDir, 0) end end, false) end end @@ -260,13 +260,18 @@ function onCancelWalk(player) player:lockWalk(50) end -function walk(dir) +function walk(dir, ticks) lastManualWalk = g_clock.millis() local player = g_game.getLocalPlayer() if not player or g_game.isDead() or player:isDead() then return end + if player:isWalkLocked() then + nextWalkDir = nil + return + end + if g_game.isFollowing() then g_game.cancelFollow() end @@ -278,12 +283,7 @@ function walk(dir) g_game.stop() end end - - if player:isWalkLocked() then - nextWalkDir = nil - return - end - + local dash = false local ignoredCanWalk = false if not g_game.getFeature(GameNewWalking) then @@ -291,11 +291,11 @@ function walk(dir) end local ticksToNextWalk = player:getStepTicksLeft() - if not player:canWalk(dir) then -- canWalk return false when previous walk is not finished or not confirmed by server + if not player:canWalk(dir) then -- canWalk return false when previous walk is not finished or not confirmed by server if dash then ignoredCanWalk = true else - if ticksToNextWalk < 500 and lastWalkDir ~= dir then + if ticksToNextWalk < 500 and (lastWalkDir ~= dir or ticks == 0) then nextWalkDir = dir end if ticksToNextWalk < 30 and lastFinishedStep + 400 > g_clock.millis() and nextWalkDir == nil then -- clicked walk 20 ms too early, try to execute again as soon possible to keep smooth walking @@ -349,11 +349,14 @@ function walk(dir) end if dash and lastWalkDir == dir and lastWalk + 30 > g_clock.millis() then - walkLock = lastWalk + g_settings.getNumber('walkFirstStepDelay') return end - - firstStep = (not player:isWalking() and lastFinishedStep + 100 < g_clock.millis() and walkLock + 100 < g_clock.millis()) or (player:isServerWalking() and not dash) + + firstStep = (not player:isWalking() and lastFinishedStep + 100 < g_clock.millis() and walkLock + 100 < g_clock.millis()) + if player:isServerWalking() and not dash then + walkLock = walkLock + math.max(g_settings.getNumber('walkFirstStepDelay'), 100) + end + nextWalkDir = nil removeEvent(autoWalkEvent) autoWalkEvent = nil diff --git a/modules/gamelib/const.lua b/modules/gamelib/const.lua index 742b048..40a50d7 100644 --- a/modules/gamelib/const.lua +++ b/modules/gamelib/const.lua @@ -170,6 +170,7 @@ GameNewWalking = 90 GameSlowerManualWalking = 91 GameExtendedNewWalking = 92 GameBot = 95 +GameBiggerMapCache = 96 GameForceLight = 97 GameNoDebug = 98 GameBotProtection = 99 diff --git a/modules/gamelib/ui/uicreaturebutton.lua b/modules/gamelib/ui/uicreaturebutton.lua index 7fce910..2517833 100644 --- a/modules/gamelib/ui/uicreaturebutton.lua +++ b/modules/gamelib/ui/uicreaturebutton.lua @@ -35,12 +35,7 @@ function UICreatureButton:getCreatureId() return self.creature:getId() end -function UICreatureButton:setup(creature, id) - if not id then - id = 0 - end - self:setId('CreatureButton_' .. id) - +function UICreatureButton:setup(id) self.lifeBarWidget = self:getChildById('lifeBar') self.creatureWidget = self:getChildById('creature') self.labelWidget = self:getChildById('label') diff --git a/modules/gamelib/ui/uiitem.lua b/modules/gamelib/ui/uiitem.lua index cbcab3a..3133da8 100644 --- a/modules/gamelib/ui/uiitem.lua +++ b/modules/gamelib/ui/uiitem.lua @@ -120,7 +120,7 @@ function UIItem:canAcceptDrop(widget, mousePos) end function UIItem:onClick(mousePos) - if not self.selectable then + if not self.selectable or not self.editable then return end diff --git a/otclient_dx.exe b/otclient_dx.exe index 1846c32..e06a70d 100644 Binary files a/otclient_dx.exe and b/otclient_dx.exe differ diff --git a/otclient_gl.exe b/otclient_gl.exe index 8db172d..f5e9349 100644 Binary files a/otclient_gl.exe and b/otclient_gl.exe differ diff --git a/otclient_linux b/otclient_linux index a70e360..ff814ad 100644 Binary files a/otclient_linux and b/otclient_linux differ diff --git a/pdb/otclient_dx.zip b/pdb/otclient_dx.zip index ff153af..c0bcba1 100644 Binary files a/pdb/otclient_dx.zip and b/pdb/otclient_dx.zip differ diff --git a/pdb/otclient_gl.zip b/pdb/otclient_gl.zip index bdf060e..21b16a4 100644 Binary files a/pdb/otclient_gl.zip and b/pdb/otclient_gl.zip differ