mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Code optimizations / refactor (#12704)
Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com> Co-authored-by: sfan5 <sfan5@live.de>
This commit is contained in:
parent
ff6dcfea82
commit
038da00e79
38 changed files with 84 additions and 94 deletions
|
@ -329,10 +329,9 @@ void GUIButton::draw()
|
|||
|
||||
if (SpriteBank)
|
||||
{
|
||||
core::position2di pos(buttonCenter);
|
||||
|
||||
if (isEnabled())
|
||||
{
|
||||
core::position2di pos(buttonCenter);
|
||||
// pressed / unpressed animation
|
||||
EGUI_BUTTON_STATE state = Pressed ? EGBS_BUTTON_DOWN : EGBS_BUTTON_UP;
|
||||
drawSprite(state, ClickTime, pos);
|
||||
|
|
|
@ -195,7 +195,7 @@ GUIEngine::GUIEngine(JoystickController *joystick,
|
|||
|
||||
try {
|
||||
m_script->setMainMenuData(&m_data->script_data);
|
||||
m_data->script_data.errormessage = "";
|
||||
m_data->script_data.errormessage.clear();
|
||||
|
||||
if (!loadMainMenuScript()) {
|
||||
errorstream << "No future without main menu!" << std::endl;
|
||||
|
|
|
@ -694,7 +694,7 @@ void GUIFormSpecMenu::parseScrollBar(parserData* data, const std::string &elemen
|
|||
e->setMax(max);
|
||||
e->setMin(min);
|
||||
|
||||
e->setPos(stoi(parts[4]));
|
||||
e->setPos(stoi(value));
|
||||
|
||||
e->setSmallStep(data->scrollbar_options.small_step);
|
||||
e->setLargeStep(data->scrollbar_options.large_step);
|
||||
|
@ -1180,7 +1180,6 @@ void GUIFormSpecMenu::parseTable(parserData* data, const std::string &element)
|
|||
std::string name = parts[2];
|
||||
std::vector<std::string> items = split(parts[3],',');
|
||||
std::string str_initial_selection;
|
||||
std::string str_transparent = "false";
|
||||
|
||||
if (parts.size() >= 5)
|
||||
str_initial_selection = parts[4];
|
||||
|
@ -2264,7 +2263,7 @@ void GUIFormSpecMenu::parseBackgroundColor(parserData* data, const std::string &
|
|||
}
|
||||
|
||||
// bgcolor
|
||||
if (parameter_count >= 1 && parts[0] != "")
|
||||
if (parameter_count >= 1 && !parts[0].empty())
|
||||
parseColorString(parts[0], m_bgcolor, false);
|
||||
|
||||
// fullscreen
|
||||
|
@ -2275,14 +2274,14 @@ void GUIFormSpecMenu::parseBackgroundColor(parserData* data, const std::string &
|
|||
} else if (parts[1] == "neither") {
|
||||
m_bgnonfullscreen = false;
|
||||
m_bgfullscreen = false;
|
||||
} else if (parts[1] != "" || m_formspec_version < 3) {
|
||||
} else if (!parts[1].empty() || m_formspec_version < 3) {
|
||||
m_bgfullscreen = is_yes(parts[1]);
|
||||
m_bgnonfullscreen = !m_bgfullscreen;
|
||||
}
|
||||
}
|
||||
|
||||
// fbgcolor
|
||||
if (parameter_count >= 3 && parts[2] != "")
|
||||
if (parameter_count >= 3 && !parts[2].empty())
|
||||
parseColorString(parts[2], m_fullscreen_bgcolor, false);
|
||||
}
|
||||
|
||||
|
@ -3047,7 +3046,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
|||
}
|
||||
} else {
|
||||
// Don't keep old focus value
|
||||
m_focused_element = "";
|
||||
m_focused_element.clear();
|
||||
}
|
||||
|
||||
// Remove children
|
||||
|
@ -3865,7 +3864,7 @@ void GUIFormSpecMenu::acceptInput(FormspecQuitMode quitmode)
|
|||
|
||||
if (!current_field_enter_pending.empty()) {
|
||||
fields["key_enter_field"] = current_field_enter_pending;
|
||||
current_field_enter_pending = "";
|
||||
current_field_enter_pending.clear();
|
||||
}
|
||||
|
||||
if (current_keys_pending.key_escape) {
|
||||
|
@ -4600,7 +4599,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
|
|||
} else if (s.ftype == f_ScrollBar) {
|
||||
s.fdefault = L"Changed";
|
||||
acceptInput(quit_mode_no);
|
||||
s.fdefault = L"";
|
||||
s.fdefault.clear();
|
||||
} else if (s.ftype == f_Unknown || s.ftype == f_HyperText) {
|
||||
if (!s.sound.empty() && m_sound_manager)
|
||||
m_sound_manager->playSound(SimpleSoundSpec(s.sound, 1.0f));
|
||||
|
|
|
@ -86,9 +86,10 @@ void GUIScene::draw()
|
|||
|
||||
core::rect<s32> oldViewPort = m_driver->getViewPort();
|
||||
m_driver->setViewPort(getAbsoluteClippingRect());
|
||||
core::recti borderRect = Environment->getRootGUIElement()->getAbsoluteClippingRect();
|
||||
|
||||
if (m_bgcolor != 0) {
|
||||
core::recti borderRect =
|
||||
Environment->getRootGUIElement()->getAbsoluteClippingRect();
|
||||
Environment->getSkin()->draw3DSunkenPane(
|
||||
this, m_bgcolor, false, true, borderRect, 0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue