本文整理汇总了C++中InventoryList::setWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ InventoryList::setWidth方法的具体用法?C++ InventoryList::setWidth怎么用?C++ InventoryList::setWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InventoryList
的用法示例。
在下文中一共展示了InventoryList::setWidth方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Player::Player(IGameDef *gamedef):
touching_ground(false),
in_water(false),
liquid_viscosity(0),
is_climbing(false),
swimming_up(false),
camera_barely_in_ceiling(false),
inventory(gamedef->idef()),
hp(PLAYER_MAX_HP),
peer_id(PEER_ID_INEXISTENT),
// protected
m_gamedef(gamedef),
m_pitch(0),
m_yaw(0),
m_speed(0,0,0),
m_position(0,0,0)
{
updateName("<not set>");
inventory.clear();
inventory.addList("main", PLAYER_INVENTORY_SIZE);
InventoryList *craft = inventory.addList("craft", 9);
craft->setWidth(3);
inventory.addList("craftpreview", 1);
inventory.addList("craftresult", 1);
// Can be redefined via Lua
inventory_formspec = "size[8,7.5]"
//"image[1,0.6;1,2;player.png]"
"list[current_player;main;0,3.5;8,4;]"
"list[current_player;craft;3,0;3,3;]"
"list[current_player;craftpreview;7,1;1,1;]";
}
示例2:
Player::Player(IGameDef *gamedef):
touching_ground(false),
in_liquid(false),
in_liquid_stable(false),
liquid_viscosity(0),
is_climbing(false),
swimming_vertical(false),
camera_barely_in_ceiling(false),
inventory(gamedef->idef()),
hp(PLAYER_MAX_HP),
breath(-1),
peer_id(PEER_ID_INEXISTENT),
// protected
m_gamedef(gamedef),
m_pitch(0),
m_yaw(0),
m_speed(0,0,0),
m_position(0,0,0),
m_collisionbox(-BS*0.30,0.0,-BS*0.30,BS*0.30,BS*1.55,BS*0.30)
{
updateName("<not set>");
inventory.clear();
inventory.addList("main", PLAYER_INVENTORY_SIZE);
InventoryList *craft = inventory.addList("craft", 9);
craft->setWidth(3);
inventory.addList("craftpreview", 1);
inventory.addList("craftresult", 1);
// Can be redefined via Lua
inventory_formspec = "size[8,7.5]"
//"image[1,0.6;1,2;player.png]"
"list[current_player;main;0,3.5;8,4;]"
"list[current_player;craft;3,0;3,3;]"
"list[current_player;craftpreview;7,1;1,1;]";
// Initialize movement settings at default values, so movement can work if the server fails to send them
movement_acceleration_default = 3 * BS;
movement_acceleration_air = 2 * BS;
movement_acceleration_fast = 10 * BS;
movement_speed_walk = 4 * BS;
movement_speed_crouch = 1.35 * BS;
movement_speed_fast = 20 * BS;
movement_speed_climb = 2 * BS;
movement_speed_jump = 6.5 * BS;
movement_liquid_fluidity = 1 * BS;
movement_liquid_fluidity_smooth = 0.5 * BS;
movement_liquid_sink = 10 * BS;
movement_gravity = 9.81 * BS;
// Movement overrides are multipliers and must be 1 by default
physics_override_speed = 1;
physics_override_jump = 1;
physics_override_gravity = 1;
hud_flags = HUD_FLAG_HOTBAR_VISIBLE | HUD_FLAG_HEALTHBAR_VISIBLE |
HUD_FLAG_CROSSHAIR_VISIBLE | HUD_FLAG_WIELDITEM_VISIBLE |
HUD_FLAG_BREATHBAR_VISIBLE;
hud_hotbar_itemcount = HUD_HOTBAR_ITEMCOUNT_DEFAULT;
}
示例3:
Player::Player(const std::string & name, IItemDefManager *idef):
inventory(idef),
peer_id(PEER_ID_INEXISTENT),
keyPressed(0),
// protected
m_speed(0,0,0)
{
peer_id = PEER_ID_INEXISTENT;
m_name = name;
hotbar_image_items = 0;
inventory.clear();
inventory.addList("main", PLAYER_INVENTORY_SIZE);
inventory.addList("hand", 1);
InventoryList *craft = inventory.addList("craft", 9);
craft->setWidth(3);
inventory.addList("craftpreview", 1);
inventory.addList("craftresult", 1);
inventory.setModified(false);
// Can be redefined via Lua
inventory_formspec = "size[8,7.5]"
//"image[1,0.6;1,2;player.png]"
"list[current_player;main;0,3.5;8,4;]"
"list[current_player;craft;3,0;3,3;]"
"listring[]"
"list[current_player;craftpreview;7,1;1,1;]";
// Initialize movement settings at default values, so movement can work
// if the server fails to send them
movement_acceleration_default = 3 * BS;
movement_acceleration_air = 2 * BS;
movement_acceleration_fast = 10 * BS;
movement_speed_walk = 4 * BS;
movement_speed_crouch = 1.35 * BS;
movement_speed_fast = 20 * BS;
movement_speed_climb = 2 * BS;
movement_speed_jump = 6.5 * BS;
movement_liquid_fluidity = 1 * BS;
movement_liquid_fluidity_smooth = 0.5 * BS;
movement_liquid_sink = 10 * BS;
movement_gravity = 9.81 * BS;
movement_fall_aerodynamics = 110;
local_animation_speed = 0.0;
hud_flags =
HUD_FLAG_HOTBAR_VISIBLE | HUD_FLAG_HEALTHBAR_VISIBLE |
HUD_FLAG_CROSSHAIR_VISIBLE | HUD_FLAG_WIELDITEM_VISIBLE |
HUD_FLAG_BREATHBAR_VISIBLE | HUD_FLAG_MINIMAP_VISIBLE;
hud_hotbar_itemcount = HUD_HOTBAR_ITEMCOUNT_DEFAULT;
}
示例4:
Player::Player(const char *name, IItemDefManager *idef):
inventory(idef)
{
strlcpy(m_name, name, PLAYERNAME_SIZE);
inventory.clear();
inventory.addList("main", PLAYER_INVENTORY_SIZE);
inventory.addList("hand", 1);
InventoryList *craft = inventory.addList("craft", 9);
craft->setWidth(3);
inventory.addList("craftpreview", 1);
inventory.addList("craftresult", 1);
inventory.setModified(false);
// Can be redefined via Lua
inventory_formspec = "size[8,7.5]"
//"image[1,0.6;1,2;player.png]"
"list[current_player;main;0,3.5;8,4;]"
"list[current_player;craft;3,0;3,3;]"
"listring[]"
"list[current_player;craftpreview;7,1;1,1;]";
// Initialize movement settings at default values, so movement can work
// if the server fails to send them
movement_acceleration_default = 3 * BS;
movement_acceleration_air = 2 * BS;
movement_acceleration_fast = 10 * BS;
movement_speed_walk = 4 * BS;
movement_speed_crouch = 1.35 * BS;
movement_speed_fast = 20 * BS;
movement_speed_climb = 2 * BS;
movement_speed_jump = 6.5 * BS;
movement_liquid_fluidity = 1 * BS;
movement_liquid_fluidity_smooth = 0.5 * BS;
movement_liquid_sink = 10 * BS;
movement_gravity = 9.81 * BS;
local_animation_speed = 0.0;
hud_flags =
HUD_FLAG_HOTBAR_VISIBLE | HUD_FLAG_HEALTHBAR_VISIBLE |
HUD_FLAG_CROSSHAIR_VISIBLE | HUD_FLAG_WIELDITEM_VISIBLE |
HUD_FLAG_BREATHBAR_VISIBLE | HUD_FLAG_MINIMAP_VISIBLE |
HUD_FLAG_MINIMAP_RADAR_VISIBLE;
hud_hotbar_itemcount = HUD_HOTBAR_ITEMCOUNT_DEFAULT;
m_player_settings.readGlobalSettings();
// Register player setting callbacks
for (const std::string &name : m_player_settings.setting_names)
g_settings->registerChangedCallback(name,
&Player::settingsChangedCallback, &m_player_settings);
}
示例5: MYMIN
bool PlayerDatabaseSQLite3::loadPlayer(RemotePlayer *player, PlayerSAO *sao)
{
verifyDatabase();
str_to_sqlite(m_stmt_player_load, 1, player->getName());
if (sqlite3_step(m_stmt_player_load) != SQLITE_ROW) {
sqlite3_reset(m_stmt_player_load);
return false;
}
sao->setPitch(sqlite_to_float(m_stmt_player_load, 0));
sao->setYaw(sqlite_to_float(m_stmt_player_load, 1));
sao->setBasePosition(sqlite_to_v3f(m_stmt_player_load, 2));
sao->setHPRaw((s16) MYMIN(sqlite_to_int(m_stmt_player_load, 5), S16_MAX));
sao->setBreath((u16) MYMIN(sqlite_to_int(m_stmt_player_load, 6), U16_MAX), false);
sqlite3_reset(m_stmt_player_load);
// Load inventory
str_to_sqlite(m_stmt_player_load_inventory, 1, player->getName());
while (sqlite3_step(m_stmt_player_load_inventory) == SQLITE_ROW) {
InventoryList *invList = player->inventory.addList(
sqlite_to_string(m_stmt_player_load_inventory, 2),
sqlite_to_uint(m_stmt_player_load_inventory, 3));
invList->setWidth(sqlite_to_uint(m_stmt_player_load_inventory, 1));
u32 invId = sqlite_to_uint(m_stmt_player_load_inventory, 0);
str_to_sqlite(m_stmt_player_load_inventory_items, 1, player->getName());
int_to_sqlite(m_stmt_player_load_inventory_items, 2, invId);
while (sqlite3_step(m_stmt_player_load_inventory_items) == SQLITE_ROW) {
const std::string itemStr = sqlite_to_string(m_stmt_player_load_inventory_items, 1);
if (itemStr.length() > 0) {
ItemStack stack;
stack.deSerialize(itemStr);
invList->addItem(sqlite_to_uint(m_stmt_player_load_inventory_items, 0), stack);
}
}
sqlite3_reset(m_stmt_player_load_inventory_items);
}
sqlite3_reset(m_stmt_player_load_inventory);
str_to_sqlite(m_stmt_player_metadata_load, 1, sao->getPlayer()->getName());
while (sqlite3_step(m_stmt_player_metadata_load) == SQLITE_ROW) {
std::string attr = sqlite_to_string(m_stmt_player_metadata_load, 0);
std::string value = sqlite_to_string(m_stmt_player_metadata_load, 1);
sao->setExtendedAttribute(attr, value);
}
sqlite3_reset(m_stmt_player_metadata_load);
return true;
}
示例6: inventory
Player::Player(IGameDef *gamedef):
touching_ground(false),
in_liquid(false),
in_liquid_stable(false),
liquid_viscosity(0),
is_climbing(false),
swimming_vertical(false),
camera_barely_in_ceiling(false),
inventory(gamedef->idef()),
hp(PLAYER_MAX_HP),
peer_id(PEER_ID_INEXISTENT),
// protected
m_gamedef(gamedef),
m_pitch(0),
m_yaw(0),
m_speed(0,0,0),
m_position(0,0,0)
{
updateName("<not set>");
inventory.clear();
inventory.addList("main", PLAYER_INVENTORY_SIZE);
InventoryList *craft = inventory.addList("craft", 9);
craft->setWidth(3);
inventory.addList("craftpreview", 1);
inventory.addList("craftresult", 1);
// Can be redefined via Lua
inventory_formspec = "size[8,7.5]"
//"image[1,0.6;1,2;player.png]"
"list[current_player;main;0,3.5;8,4;]"
"list[current_player;craft;3,0;3,3;]"
"list[current_player;craftpreview;7,1;1,1;]";
// Initialize movement settings at default values, so movement can work if the server fails to send them
movement_acceleration_default = 3 * BS;
movement_acceleration_air = 2 * BS;
movement_acceleration_fast = 10 * BS;
movement_speed_walk = 4 * BS;
movement_speed_crouch = 1.35 * BS;
movement_speed_fast = 20 * BS;
movement_speed_climb = 2 * BS;
movement_speed_jump = 6.5 * BS;
movement_liquid_fluidity = 1 * BS;
movement_liquid_fluidity_smooth = 0.5 * BS;
movement_liquid_sink = 10 * BS;
movement_gravity = 9.81 * BS;
}
示例7: l_set_width
// set_width(self, listname, size)
int InvRef::l_set_width(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
InvRef *ref = checkobject(L, 1);
const char *listname = luaL_checkstring(L, 2);
int newwidth = luaL_checknumber(L, 3);
Inventory *inv = getinv(L, ref);
if(inv == NULL){
return 0;
}
InventoryList *list = inv->getList(listname);
if(list){
list->setWidth(newwidth);
} else {
return 0;
}
reportInventoryChange(L, ref);
return 0;
}
示例8: loadPlayer
bool PlayerDatabasePostgreSQL::loadPlayer(RemotePlayer *player, PlayerSAO *sao)
{
sanity_check(sao);
verifyDatabase();
const char *values[] = { player->getName() };
PGresult *results = execPrepared("load_player", 1, values, false, false);
// Player not found, return not found
if (!PQntuples(results)) {
PQclear(results);
return false;
}
sao->setPitch(pg_to_float(results, 0, 0));
sao->setYaw(pg_to_float(results, 0, 1));
sao->setBasePosition(v3f(
pg_to_float(results, 0, 2),
pg_to_float(results, 0, 3),
pg_to_float(results, 0, 4))
);
sao->setHPRaw((s16) pg_to_int(results, 0, 5));
sao->setBreath((u16) pg_to_int(results, 0, 6), false);
PQclear(results);
// Load inventory
results = execPrepared("load_player_inventories", 1, values, false, false);
int resultCount = PQntuples(results);
for (int row = 0; row < resultCount; ++row) {
InventoryList* invList = player->inventory.
addList(PQgetvalue(results, row, 2), pg_to_uint(results, row, 3));
invList->setWidth(pg_to_uint(results, row, 1));
u32 invId = pg_to_uint(results, row, 0);
std::string invIdStr = itos(invId);
const char* values2[] = {
player->getName(),
invIdStr.c_str()
};
PGresult *results2 = execPrepared("load_player_inventory_items", 2,
values2, false, false);
int resultCount2 = PQntuples(results2);
for (int row2 = 0; row2 < resultCount2; row2++) {
const std::string itemStr = PQgetvalue(results2, row2, 1);
if (itemStr.length() > 0) {
ItemStack stack;
stack.deSerialize(itemStr);
invList->changeItem(pg_to_uint(results2, row2, 0), stack);
}
}
PQclear(results2);
}
PQclear(results);
results = execPrepared("load_player_metadata", 1, values, false);
int numrows = PQntuples(results);
for (int row = 0; row < numrows; row++) {
sao->getMeta().setString(PQgetvalue(results, row, 0), PQgetvalue(results, row, 1));
}
sao->getMeta().setModified(false);
PQclear(results);
return true;
}