diff --git a/source/main/gui/GUIUtils.cpp b/source/main/gui/GUIUtils.cpp index be595a539a..1cbdb80dcd 100644 --- a/source/main/gui/GUIUtils.cpp +++ b/source/main/gui/GUIUtils.cpp @@ -440,34 +440,31 @@ void RoR::ImDrawModifierKeyHighlighted(OIS::KeyCode key) bool RoR::ImButtonHoldToConfirm(const std::string& btn_caption, bool small, float time_limit, float& time_left_var, float dt) { - bool btn_pressed = false; if (small) - btn_pressed = ImGui::SmallButton(btn_caption.c_str()); + ImGui::SmallButton(btn_caption.c_str()); else - btn_pressed = ImGui::Button(btn_caption.c_str()); + ImGui::Button(btn_caption.c_str()); - if (btn_pressed) + if (ImGui::IsItemActive() && time_left_var > 0.f) { - time_left_var = time_limit; // Initialize + time_left_var -= dt; + if (time_left_var > 0.f) + { + ImGui::BeginTooltip(); + std::string text = _L("Hold to confirm"); + ImGui::TextDisabled(text.c_str()); + ImGui::ProgressBar(time_left_var/time_limit, ImVec2(ImGui::CalcTextSize(text.c_str()).x, 8.f), ""); + ImGui::EndTooltip(); + } + else + { + return true; + } } else { - if (ImGui::IsItemActive() && time_left_var > 0.f) - { - time_left_var -= dt; - if (time_left_var > 0.f) - { - ImGui::BeginTooltip(); - std::string text = _L("Hold to confirm"); - ImGui::TextDisabled(text.c_str()); - ImGui::ProgressBar(time_left_var/time_limit, ImVec2(ImGui::CalcTextSize(text.c_str()).x, 8.f), ""); - ImGui::EndTooltip(); - } - else - { - return true; - } - } + time_left_var = time_limit; } + return false; } diff --git a/source/main/gui/panels/GUI_TopMenubar.cpp b/source/main/gui/panels/GUI_TopMenubar.cpp index 2e16eec831..ec64e5ab0e 100644 --- a/source/main/gui/panels/GUI_TopMenubar.cpp +++ b/source/main/gui/panels/GUI_TopMenubar.cpp @@ -1594,13 +1594,13 @@ void TopMenubar::Draw(float dt) ImGui::SetNextItemOpen(true, ImGuiCond_FirstUseEver); std::string addonparts_title = fmt::format(_LC("TopMenubar", "Addon parts ({})"), tuning_addonparts.cqy_results.size()); - if (ImGui::CollapsingHeader(addonparts_title.c_str())) + if (ImGui::CollapsingHeader(addonparts_title.c_str()) && tuneup_entry) { for (CacheQueryResult& addonpart_result: tuning_addonparts.cqy_results) { ImGui::PushID(addonpart_result.cqr_entry->fname.c_str()); - bool used = tuning_actor->getUsedTuneupEntry()->tuneup_def->use_addonparts.count(addonpart_result.cqr_entry->fname) > 0; + bool used = tuneup_entry->tuneup_def->use_addonparts.count(addonpart_result.cqr_entry->fname) > 0; if (ImGui::Checkbox(addonpart_result.cqr_entry->dname.c_str(), &used)) { ModifyProjectRequest* req = new ModifyProjectRequest(); diff --git a/source/main/physics/flex/FlexBody.cpp b/source/main/physics/flex/FlexBody.cpp index 9a62b6f85f..d52d0ffca9 100644 --- a/source/main/physics/flex/FlexBody.cpp +++ b/source/main/physics/flex/FlexBody.cpp @@ -573,7 +573,9 @@ void FlexBody::setVisible(bool visible) void FlexBody::setFlexbodyCastShadow(bool val) { - m_scene_entity->setCastShadows(val); + // Scene entity is NULL if disabled via addonpart/tuneup. + if (m_scene_entity) + m_scene_entity->setCastShadows(val); } void FlexBody::computeFlexbody() diff --git a/source/main/resources/CacheSystem.cpp b/source/main/resources/CacheSystem.cpp index 9852a72bc4..e5e82e456b 100644 --- a/source/main/resources/CacheSystem.cpp +++ b/source/main/resources/CacheSystem.cpp @@ -1351,8 +1351,12 @@ void CacheSystem::UnLoadResource(CacheEntryPtr& entry) { if (i_entry->resource_group == resource_group) { - i_entry->actor_def = nullptr; // Delete cached truck file - force reload from disk - i_entry->resource_group = ""; // Mark as unloaded + // Delete cached documents - force reload from disk + i_entry->actor_def = nullptr; + i_entry->tuneup_def = nullptr; + i_entry->skin_def = nullptr; + // Mark as unloaded + i_entry->resource_group = ""; } } diff --git a/source/main/resources/addonpart_fileformat/AddonPartFileFormat.cpp b/source/main/resources/addonpart_fileformat/AddonPartFileFormat.cpp index e744175d65..442747cd6e 100644 --- a/source/main/resources/addonpart_fileformat/AddonPartFileFormat.cpp +++ b/source/main/resources/addonpart_fileformat/AddonPartFileFormat.cpp @@ -116,6 +116,12 @@ void AddonPartUtility::ResolveUnwantedAndTweakedElements(TuneupDefPtr& tuneup, C m_addonpart_entry = addonpart_entry; m_tuneup = tuneup; + // Reset tweak data - to be reloaded from addonpart + m_tuneup->prop_tweaks.clear(); + m_tuneup->flexbody_tweaks.clear(); + m_tuneup->wheel_tweaks.clear(); + m_tuneup->node_tweaks.clear(); + try { Ogre::DataStreamPtr datastream = Ogre::ResourceGroupManager::getSingleton().openResource(addonpart_entry->fname, addonpart_entry->resource_group); diff --git a/source/main/resources/tuneup_fileformat/TuneupFileFormat.cpp b/source/main/resources/tuneup_fileformat/TuneupFileFormat.cpp index 7e3d4faca1..6cce39b90a 100644 --- a/source/main/resources/tuneup_fileformat/TuneupFileFormat.cpp +++ b/source/main/resources/tuneup_fileformat/TuneupFileFormat.cpp @@ -412,6 +412,7 @@ void RoR::TuneupUtil::ParseTuneupAttribute(const std::string& line, TuneupDefPtr if (attrib == "remove_flexbody" && params.size() == 2) { tuneup_def->remove_flexbodies.insert(PARSEINT(params[1])); return; } if (attrib == "protected_prop" && params.size() == 2) { tuneup_def->protected_props.insert(PARSEINT(params[1])); return; } if (attrib == "protected_flexbody" && params.size() == 2) { tuneup_def->protected_flexbodies.insert(PARSEINT(params[1])); return; } + if (attrib == "forced_wheel_side" && params.size() == 3) { tuneup_def->wheel_forced_sides[PARSEINT(params[1])] = (WheelSide)PARSEINT(params[2]); return; } } void RoR::TuneupUtil::ExportTuneup(Ogre::DataStreamPtr& stream, TuneupDefPtr& tuneup) @@ -450,6 +451,10 @@ void RoR::TuneupUtil::ExportTuneup(Ogre::DataStreamPtr& stream, TuneupDefPtr& tu { buf << "\tprotected_flexbody = " << (int)protected_flexbody << "\n"; } + for (auto& pair: tuneup->wheel_forced_sides) + { + buf << "\tforced_wheel_side = " << pair.first << ", " << (int)pair.second << "\n"; + } buf << "}\n\n"; size_t written = stream->write(buf.GetBuffer(), buf.GetLength()); diff --git a/source/main/resources/tuneup_fileformat/TuneupFileFormat.h b/source/main/resources/tuneup_fileformat/TuneupFileFormat.h index 2a9f774fab..c4c39c9227 100644 --- a/source/main/resources/tuneup_fileformat/TuneupFileFormat.h +++ b/source/main/resources/tuneup_fileformat/TuneupFileFormat.h @@ -91,8 +91,8 @@ struct TuneupDef: public RefCountingObject std::map node_tweaks; //!< Node position overrides via 'addonpart_tweak_node' std::map wheel_tweaks; //!< Mesh name and radius overrides via 'addonpart_tweak_wheel' - std::map prop_tweaks; - std::map flexbody_tweaks; + std::map prop_tweaks; //!< Mesh name(s), offset and rotation overrides via 'addonpart_tweak_prop' + std::map flexbody_tweaks; //!< Mesh name, offset and rotation overrides via 'addonpart_tweak_flexbody' std::set remove_props; //!< Either UI overrides or 'addonpart_unwanted_prop' directives. std::set remove_flexbodies; //!< Either UI overrides or 'addonpart_unwanted_flexbody' directives.