当前位置: 首页>>代码示例>>C++>>正文


C++ THMap类代码示例

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


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


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