• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ THMap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中THMap的典型用法代码示例。如果您正苦于以下问题:C++ THMap类的具体用法?C++ THMap怎么用?C++ THMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了THMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: _onSaveMenuSaveAs

void frmMain::_onSaveMenuSave(wxCommandEvent& evt)
{
    if(m_sFilename.empty())
    {
        _onSaveMenuSaveAs(evt);
        return;
    }

    map_save_t oSave;
    if(oSave.fFile.Open(m_sFilename, wxFile::write))
    {
        lua_State* L = m_pGamePanel->getLua();
        luaT_execute(L, "return TheApp.world.map.th");
        THMap *pMap = reinterpret_cast<THMap*>(lua_touserdata(L, -1));
        lua_pop(L, 1);
        THMapWrapper::autoSetHelipad(pMap);
        luaT_execute(L, "return TheApp.ui:ScreenToWorld(...)",
            m_pGamePanel->GetSize().GetWidth() / 2,
            m_pGamePanel->GetSize().GetHeight() / 2);
        int iCameraX = (int)lua_tointeger(L, -2);
        int iCameraY = (int)lua_tointeger(L, -1);
        lua_pop(L, 2);
        pMap->setPlayerCameraTile(0, iCameraX, iCameraY);
        pMap->save(map_save_t::writer, reinterpret_cast<void*>(&oSave));
        ::wxMessageBox(wxT("Map saved."), wxT("Save"), wxOK | wxCENTER |
            wxICON_INFORMATION, this);
    }
}
开发者ID:sydlawrence,项目名称:CorsixTH-HTML5-Port,代码行数:28,代码来源:frmMain.cpp


示例2: l_map_save

static int l_map_save(lua_State *L)
{
    THMap *pMap = luaT_testuserdata<THMap>(L);
    std::string filename(luaL_checkstring(L, 2));
    pMap->save(filename);
    return 0;
}
开发者ID:mounirlamouri,项目名称:CorsixTH,代码行数:7,代码来源:th_lua_map.cpp


示例3: l_map_set_parcel_owner

static int l_map_set_parcel_owner(lua_State *L)
{
    THMap* pMap = luaT_testuserdata<THMap>(L);
    int parcelId = static_cast<int>(luaL_checkinteger(L, 2));
    int player = static_cast<int>(luaL_checkinteger(L, 3));
    if(lua_type(L, 4) != LUA_TTABLE)
    {
        lua_settop(L, 3);
        lua_newtable(L);
    }
    else
    {
        lua_settop(L, 4);
    }
    std::vector<std::pair<int, int>> vSplitTiles = pMap->setParcelOwner(parcelId, player);
    for (std::vector<std::pair<int, int>>::size_type i = 0; i != vSplitTiles.size(); i++)
    {
      lua_pushinteger(L, i + 1);
      lua_createtable(L, 0, 2);
      lua_pushinteger(L, 1);
      lua_pushinteger(L, vSplitTiles[i].first + 1);
      lua_settable(L, 6);
      lua_pushinteger(L, 2);
      lua_pushinteger(L, vSplitTiles[i].second + 1);
      lua_settable(L, 6);
      lua_settable(L, 4);
    }
    return 1;
}
开发者ID:mounirlamouri,项目名称:CorsixTH,代码行数:29,代码来源:th_lua_map.cpp


示例4: l_map_is_parcel_purchasable

static int l_map_is_parcel_purchasable(lua_State *L)
{
    THMap* pMap = luaT_testuserdata<THMap>(L);
    lua_pushboolean(L, pMap->isParcelPurchasable(static_cast<int>(luaL_checkinteger(L, 2)),
        static_cast<int>(luaL_checkinteger(L, 3))) ? 1 : 0);
    return 1;
}
开发者ID:mounirlamouri,项目名称:CorsixTH,代码行数:7,代码来源:th_lua_map.cpp


示例5: l_map_getsize

static int l_map_getsize(lua_State *L)
{
    THMap* pMap = luaT_testuserdata<THMap>(L);
    lua_pushinteger(L, pMap->getWidth());
    lua_pushinteger(L, pMap->getHeight());
    return 2;
}
开发者ID:sadger,项目名称:CorsixTH,代码行数:7,代码来源:th_lua_map.cpp


示例6: l_map_updateshadows

static int l_map_updateshadows(lua_State *L)
{
    THMap* pMap = luaT_testuserdata<THMap>(L);
    pMap->updateShadows();
    lua_settop(L, 1);
    return 1;
}
开发者ID:mounirlamouri,项目名称:CorsixTH,代码行数:7,代码来源:th_lua_map.cpp


示例7: l_map_getcell

static int l_map_getcell(lua_State *L)
{
    THMap* pMap = luaT_testuserdata<THMap>(L);
    int iX = static_cast<int>(luaL_checkinteger(L, 2) - 1); // Lua arrays start at 1 - pretend
    int iY = static_cast<int>(luaL_checkinteger(L, 3) - 1); // the map does too.
    THMapNode* pNode = pMap->getNode(iX, iY);
    if(pNode == nullptr)
    {
        return luaL_argerror(L, 2, lua_pushfstring(L, "Map co-ordinates out "
        "of bounds (%d, %d)", iX + 1, iY + 1));
    }
    if(lua_isnoneornil(L, 4))
    {
        lua_pushinteger(L, pNode->iBlock[0]);
        lua_pushinteger(L, pNode->iBlock[1]);
        lua_pushinteger(L, pNode->iBlock[2]);
        lua_pushinteger(L, pNode->iBlock[3]);
        return 4;
    }
    else
    {
        lua_Integer iLayer = luaL_checkinteger(L, 4) - 1;
        if(iLayer < 0 || iLayer >= 4)
            return luaL_argerror(L, 4, "Layer index is out of bounds (1-4)");
        lua_pushinteger(L, pNode->iBlock[iLayer]);
        return 1;
    }
}
开发者ID:sadger,项目名称:CorsixTH,代码行数:28,代码来源:th_lua_map.cpp


示例8: l_map_updatepathfinding

static int l_map_updatepathfinding(lua_State *L)
{
    THMap* pMap = luaT_testuserdata<THMap>(L);
    pMap->updatePathfinding();
    lua_settop(L, 1);
    return 1;
}
开发者ID:mounirlamouri,项目名称:CorsixTH,代码行数:7,代码来源:th_lua_map.cpp


示例9: l_map_setcell

static int l_map_setcell(lua_State *L)
{
    THMap* pMap = luaT_testuserdata<THMap>(L);
    int iX = static_cast<int>(luaL_checkinteger(L, 2) - 1); // Lua arrays start at 1 - pretend
    int iY = static_cast<int>(luaL_checkinteger(L, 3) - 1); // the map does too.
    THMapNode* pNode = pMap->getNode(iX, iY);
    if(pNode == nullptr)
        return luaL_argerror(L, 2, "Map co-ordinates out of bounds");
    if(lua_gettop(L) >= 7)
    {
        pNode->iBlock[0] = (uint16_t)luaL_checkinteger(L, 4);
        pNode->iBlock[1] = (uint16_t)luaL_checkinteger(L, 5);
        pNode->iBlock[2] = (uint16_t)luaL_checkinteger(L, 6);
        pNode->iBlock[3] = (uint16_t)luaL_checkinteger(L, 7);
    }
    else
    {
        lua_Integer iLayer = luaL_checkinteger(L, 4) - 1;
        if(iLayer < 0 || iLayer >= 4)
            return luaL_argerror(L, 4, "Layer index is out of bounds (1-4)");
        uint16_t iBlock = static_cast<uint16_t>(luaL_checkinteger(L, 5));
        pNode->iBlock[iLayer] = iBlock;
    }

    lua_settop(L, 1);
    return 1;
}
开发者ID:mounirlamouri,项目名称:CorsixTH,代码行数:27,代码来源:th_lua_map.cpp


示例10: l_map_setwallflags

static int l_map_setwallflags(lua_State *L)
{
    THMap* pMap = luaT_testuserdata<THMap>(L);
    pMap->setAllWallDrawFlags((uint8_t)luaL_checkinteger(L, 2));
    lua_settop(L, 1);
    return 1;
}
开发者ID:mounirlamouri,项目名称:CorsixTH,代码行数:7,代码来源:th_lua_map.cpp


示例11: l_map_getcellflags

/**
 * Get the value of all cell flags at a position.
 * @param L Lua context.
 * @return Number of results of the call.
 */
static int l_map_getcellflags(lua_State *L)
{
    THMap* pMap = luaT_testuserdata<THMap>(L);
    int iX = static_cast<int>(luaL_checkinteger(L, 2) - 1); // Lua arrays start at 1 - pretend
    int iY = static_cast<int>(luaL_checkinteger(L, 3) - 1); // the map does too.
    THMapNode* pNode = pMap->getNode(iX, iY);
    if(pNode == nullptr)
        return luaL_argerror(L, 2, "Map co-ordinates out of bounds");
    if(lua_type(L, 4) != LUA_TTABLE)
    {
        lua_settop(L, 3);
        lua_createtable(L, 0, 1);
    }
    else
    {
        lua_settop(L, 4);
    }

    // Fill Lua table with the flags and numbers of the node.
    for (auto val : lua_node_flag_map)
    {
        add_cellflag(L, pNode, val.second, val.first);
    }
    add_cellint(L, pNode->iRoomId, "roomId");
    add_cellint(L, pNode->iParcelId, "parcelId");
    add_cellint(L, pNode->iFlags >> 24, "thob");
    return 1;
}
开发者ID:sadger,项目名称:CorsixTH,代码行数:33,代码来源:th_lua_map.cpp


示例12: l_anim_get_tile

static int l_anim_get_tile(lua_State *L)
{
    THAnimation* pAnimation = luaT_testuserdata<THAnimation>(L);
    lua_settop(L, 1);
    lua_getfenv(L, 1);
    lua_getfield(L, 2, "map");
    lua_replace(L, 2);
    if(lua_isnil(L, 2))
    {
        return 0;
    }
    THMap* pMap = (THMap*)lua_touserdata(L, 2);
    const THLinkList* pListNode = pAnimation->getPrevious();
    while(pListNode->m_pPrev)
    {
        pListNode = pListNode->m_pPrev;
    }
    // Casting pListNode to a THMapNode* is slightly dubious, but it should
    // work. If on the normal list, then pListNode will be a THMapNode*, and
    // all is fine. However, if on the early list, pListNode will be pointing
    // to a member of a THMapNode, so we're relying on pointer arithmetic
    // being a subtract and integer divide by sizeof(THMapNode) to yield the
    // correct map node.
    const THMapNode *pRootNode = pMap->getNodeUnchecked(0, 0);
    uintptr_t iDiff = reinterpret_cast<const char*>(pListNode) -
                      reinterpret_cast<const char*>(pRootNode);
    int iIndex = (int)(iDiff / sizeof(THMapNode));
    int iY = iIndex / pMap->getWidth();
    int iX = iIndex - (iY * pMap->getWidth());
    lua_pushinteger(L, iX + 1);
    lua_pushinteger(L, iY + 1);
    return 3; // map, x, y
}
开发者ID:AtlasRedux,项目名称:CorsixTH,代码行数:33,代码来源:th_lua_anims.cpp


示例13: l_anim_set_tile

static int l_anim_set_tile(lua_State *L)
{

    T* pAnimation = luaT_testuserdata<T>(L);
    if(lua_isnoneornil(L, 2))
    {
        pAnimation->removeFromTile();
        lua_pushnil(L);
        luaT_setenvfield(L, 1, "map");
        lua_settop(L, 1);
    }
    else
    {
        THMap* pMap = luaT_testuserdata<THMap>(L, 2);
        THMapNode* pNode = pMap->getNode(luaL_checkint(L, 3) - 1, luaL_checkint(L, 4) - 1);
        if(pNode)
            pAnimation->attachToTile(pNode, lastLayer);

        else
        {
            luaL_argerror(L, 3, lua_pushfstring(L, "Map index out of bounds ("
                LUA_NUMBER_FMT "," LUA_NUMBER_FMT ")", lua_tonumber(L, 3),
                lua_tonumber(L, 4)));
        }

        lua_settop(L, 2);
        luaT_setenvfield(L, 1, "map");
    }

    return 1;
}
开发者ID:AtlasRedux,项目名称:CorsixTH,代码行数:31,代码来源:th_lua_anims.cpp


示例14: l_map_settemperaturedisplay

static int l_map_settemperaturedisplay(lua_State *L)
{
    THMap* pMap = luaT_testuserdata<THMap>(L);
    lua_Integer iTD = luaL_checkinteger(L, 2) - 1;
    if (iTD >= THMT_Count) iTD = THMT_Red;
    pMap->setTemperatureDisplay(static_cast<THMapTemperatureDisplay>(iTD));
    return 1;
}
开发者ID:sadger,项目名称:CorsixTH,代码行数:8,代码来源:th_lua_map.cpp


示例15: l_map_get_parcel_tilecount

static int l_map_get_parcel_tilecount(lua_State *L)
{
    THMap* pMap = luaT_testuserdata<THMap>(L);
    int iParcel = static_cast<int>(luaL_checkinteger(L, 2));
    lua_Integer iCount = pMap->getParcelTileCount(iParcel);
    lua_pushinteger(L, iCount);
    return 1;
}
开发者ID:mounirlamouri,项目名称:CorsixTH,代码行数:8,代码来源:th_lua_map.cpp


示例16: l_map_persist

static int l_map_persist(lua_State *L)
{
    THMap* pMap = luaT_testuserdata<THMap>(L);
    lua_settop(L, 2);
    lua_insert(L, 1);
    pMap->persist((LuaPersistWriter*)lua_touserdata(L, 1));
    return 0;
}
开发者ID:sadger,项目名称:CorsixTH,代码行数:8,代码来源:th_lua_map.cpp


示例17: l_map_updatetemperature

static int l_map_updatetemperature(lua_State *L)
{
    THMap* pMap = luaT_testuserdata<THMap>(L);
    uint16_t iAir = l_check_temp(L, 2);
    uint16_t iRadiator = l_check_temp(L, 3);
    pMap->updateTemperatures(iAir, iRadiator);
    lua_settop(L, 1);
    return 1;
}
开发者ID:sadger,项目名称:CorsixTH,代码行数:9,代码来源:th_lua_map.cpp


示例18: l_map_loadblank

static int l_map_loadblank(lua_State *L)
{
    THMap* pMap = luaT_testuserdata<THMap>(L);
    if(pMap->loadBlank())
        lua_pushboolean(L, 1);
    else
        lua_pushboolean(L, 0);
    lua_newtable(L);
    return 2;
}
开发者ID:sadger,项目名称:CorsixTH,代码行数:10,代码来源:th_lua_map.cpp


示例19: l_map_set_sheet

static int l_map_set_sheet(lua_State *L)
{
    THMap* pMap = luaT_testuserdata<THMap>(L);
    THSpriteSheet* pSheet = luaT_testuserdata<THSpriteSheet>(L, 2);
    lua_settop(L, 2);

    pMap->setBlockSheet(pSheet);
    luaT_setenvfield(L, 1, "sprites");
    return 1;
}
开发者ID:sadger,项目名称:CorsixTH,代码行数:10,代码来源:th_lua_map.cpp


示例20: l_map_gettemperature

static int l_map_gettemperature(lua_State *L)
{
    THMap* pMap = luaT_testuserdata<THMap>(L);
    int iX = static_cast<int>(luaL_checkinteger(L, 2)) - 1;
    int iY = static_cast<int>(luaL_checkinteger(L, 3)) - 1;
    const THMapNode* pNode = pMap->getNode(iX, iY);
    uint16_t iTemp = pMap->getNodeTemperature(pNode);
    lua_pushnumber(L, static_cast<lua_Number>(iTemp) / static_cast<lua_Number>(65535));
    return 1;
}
开发者ID:sadger,项目名称:CorsixTH,代码行数:10,代码来源:th_lua_map.cpp



注:本文中的THMap类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ THRenderTarget类代码示例发布时间:2022-05-31
下一篇:
C++ THLine类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap