mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Move PlayerSettings class to client code
This commit is contained in:
parent
c524c52baa
commit
badd42789a
4 changed files with 83 additions and 59 deletions
|
@ -75,20 +75,10 @@ Player::Player(const char *name, IItemDefManager *idef):
|
|||
HUD_FLAG_CHAT_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);
|
||||
}
|
||||
|
||||
Player::~Player()
|
||||
{
|
||||
// m_player_settings becomes invalid, remove callbacks
|
||||
for (const std::string &name : m_player_settings.setting_names)
|
||||
g_settings->deregisterChangedCallback(name,
|
||||
&Player::settingsChangedCallback, &m_player_settings);
|
||||
clearHud();
|
||||
}
|
||||
|
||||
|
@ -224,20 +214,3 @@ void PlayerControl::unpackKeysPressed(u32 keypress_bits)
|
|||
place = keypress_bits & (1 << 8);
|
||||
zoom = keypress_bits & (1 << 9);
|
||||
}
|
||||
|
||||
void PlayerSettings::readGlobalSettings()
|
||||
{
|
||||
free_move = g_settings->getBool("free_move");
|
||||
pitch_move = g_settings->getBool("pitch_move");
|
||||
fast_move = g_settings->getBool("fast_move");
|
||||
continuous_forward = g_settings->getBool("continuous_forward");
|
||||
always_fly_fast = g_settings->getBool("always_fly_fast");
|
||||
aux1_descends = g_settings->getBool("aux1_descends");
|
||||
noclip = g_settings->getBool("noclip");
|
||||
autojump = g_settings->getBool("autojump");
|
||||
}
|
||||
|
||||
void Player::settingsChangedCallback(const std::string &name, void *data)
|
||||
{
|
||||
((PlayerSettings *)data)->readGlobalSettings();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue