diff --git a/resources/scripts/example_GenericDocument_editor.as b/resources/scripts/example_GenericDocument_editor.as index a58b9bceda..3cc99dda1d 100644 --- a/resources/scripts/example_GenericDocument_editor.as +++ b/resources/scripts/example_GenericDocument_editor.as @@ -25,7 +25,7 @@ void frameStep(float dt) if (@actor != null) { CacheEntryClass@ entry = modcache.findEntryByFilename(LOADER_TYPE_ALLBEAM, /*partial:*/false, actor.getTruckFileName()); - if (@entry != null) + if (@entry != null && entry.resource_bundle_type == "FileSystem") { @projectEntry = @entry; loadDocument(); @@ -111,7 +111,7 @@ void createProjectFromActorAsync(BeamClass@ actor ) errorString = "Failed to load cache entry!"; // request project to be created from that cache entry - string proj_name = "project1"; + string proj_name = "gd_editor_" + src_entry.fname; game.pushMessage(MSG_EDI_CREATE_PROJECT_REQUESTED, { {'name', proj_name}, {'source_entry', src_entry} diff --git a/resources/scripts/example_RigEditor_alpha.as b/resources/scripts/example_RigEditor_alpha.as index a8e9debd89..008db3cee8 100644 --- a/resources/scripts/example_RigEditor_alpha.as +++ b/resources/scripts/example_RigEditor_alpha.as @@ -53,7 +53,7 @@ void frameStep(float dt) if (@actor != null) { CacheEntryClass@ entry = modcache.findEntryByFilename(LOADER_TYPE_ALLBEAM, /*partial:*/false, actor.getTruckFileName()); - if (@entry != null) + if (@entry != null && entry.resource_bundle_type == "FileSystem") { @m_project_entry = @entry; loadDocument(); diff --git a/resources/scripts/example_game_shockTuning.as b/resources/scripts/example_game_shockTuning.as index 8ee4198079..eb8bca7dc0 100644 --- a/resources/scripts/example_game_shockTuning.as +++ b/resources/scripts/example_game_shockTuning.as @@ -217,14 +217,17 @@ void frameStep(float dt) // End window ImGui::End(); - // Draw the individual shock in-scene windows - for (int i = 0; i < actor.getShockCount(); i++) + if (@actor != null) { - SpringData@ shockdata = g_shock_buffers[i]; - if (shockdata.drawInScene) + // Draw the individual shock in-scene windows + for (int i = 0; i < actor.getShockCount(); i++) { - drawSpringHighlight(actor, i, cfgSpringColor, cfgSpringThickness); - drawSpringSceneHud(actor, i); + SpringData@ shockdata = g_shock_buffers[i]; + if (shockdata.drawInScene) + { + drawSpringHighlight(actor, i, cfgSpringColor, cfgSpringThickness); + drawSpringSceneHud(actor, i); + } } } } diff --git a/resources/scripts/example_ogre_overlays.as b/resources/scripts/example_ogre_overlays.as index 00c44cbdf0..f55ebd35a8 100644 --- a/resources/scripts/example_ogre_overlays.as +++ b/resources/scripts/example_ogre_overlays.as @@ -14,72 +14,98 @@ #include "imgui_utils.as" imgui_utils::CloseWindowPrompt closeBtnHandler; +// overlay +string ovName = "ov"+thisScript; bool ov_fail = false; - +// panel +string paName = "pa"+thisScript; bool pa_fail = false; +int paNumCreates = 0; +// misc int framecounter = 0; float pos_step = 50; // pixels void frameStep(float dt) { - Ogre::Overlay@ ov; - if (!ov_fail) { - // NOTE: getByName() will calmly return NULL if overlay doesn't exist. - @ov = Ogre::OverlayManager::getSingleton().getByName("ov"); - // CAUTION: attempt to create the same overlay again will throw an exception, interrupting the script in between! - if (@ov == null) { @ov = Ogre::OverlayManager::getSingleton().create("ov"); } - if (@ov == null) { ov_fail = true; } - else { ov.show(); } - } - - Ogre::OverlayElement@ pa; - - if (!pa_fail ){ - if ( Ogre::OverlayManager::getSingleton().hasOverlayElement("pa")) { - - // CAUTION: getOverlayElement() will throw exception if not found, always do `hasOverlayElement()` first! - @pa = Ogre::OverlayManager::getSingleton().getOverlayElement("pa"); - } - // CAUTION: using the same name twice will throw an exception, interrupting the script in between! - if (@pa == null ) { @pa = Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "pa"); - if (@pa == null ) { pa_fail=true; } - else { -// game.log("adding pa to ov"); - ov.add2D(pa); - pa.setMetricsMode(Ogre::GMM_PIXELS); - pa.setPosition(100,100); - pa.setDimensions(100,100); - pa.show(); - } - } - pa.setMaterialName("tracks/wheelface", 'OgreAutodetect'); - } - + Ogre::Overlay@ ov; + if (!ov_fail) + { + // NOTE: getByName() will calmly return NULL if overlay doesn't exist. + @ov = Ogre::OverlayManager::getSingleton().getByName(ovName); + // CAUTION: attempt to create the same overlay again will throw an exception, interrupting the script in between! + if (@ov == null) + { + @ov = Ogre::OverlayManager::getSingleton().create(ovName); + } + if (@ov == null) + { + ov_fail = true; + } + else + { + ov.show(); + } + } + + Ogre::OverlayElement@ pa; + + if (!pa_fail ) + { + if ( Ogre::OverlayManager::getSingleton().hasOverlayElement(paName)) + { + game.log('Looking for pa'); + // CAUTION: getOverlayElement() will throw exception if not found, always do `hasOverlayElement()` first! + @pa = Ogre::OverlayManager::getSingleton().getOverlayElement(paName); + + } + // CAUTION: using the same name twice will throw an exception, interrupting the script in between! + if (@pa == null ) + { + @pa = Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", paName); + paNumCreates++; + game.log('paNumCreates:'+paNumCreates); + if (@pa == null ) + { + pa_fail=true; + } + else + { + // game.log("adding pa to ov"); + ov.add2D(pa); + pa.setMetricsMode(Ogre::GMM_PIXELS); + pa.setPosition(100,100); + pa.setDimensions(100,100); + pa.setMaterialName("tracks/wheelface", 'OgreAutodetect'); + pa.show(); + } + } + + } + if (ImGui::Begin("Example", closeBtnHandler.windowOpen, 0)) { closeBtnHandler.draw(); - ImGui::Text("overlays should work; ov_fail:"+ov_fail+", pa_fail:"+pa_fail - +", frames:"+framecounter); + ImGui::Text("overlays should work; ov_fail:"+ov_fail+", pa_fail:"+pa_fail +", frames:"+framecounter); framecounter++; if (!pa_fail && @pa != null) { - + ImGui::TextDisabled("The wheel overlay:"); - if (ImGui::Button("Hide")) { pa.hide(); } - ImGui::SameLine(); if (ImGui::Button("Show")) { pa.show(); } - - if (ImGui::Button("Position: Left+")) { pa.setLeft(pa.getLeft()+pos_step); } - ImGui::SameLine(); if (ImGui::Button("Position:left-")) { pa.setLeft(pa.getLeft()-pos_step); } - - if (ImGui::Button("Position: Top+")) { pa.setTop(pa.getTop()+pos_step); } - ImGui::SameLine(); if (ImGui::Button("Position:Top-")) { pa.setTop(pa.getTop()-pos_step); } - - if (ImGui::Button("Width+")) { pa.setWidth(pa.getWidth()+pos_step); } - ImGui::SameLine(); if (ImGui::Button("Width-")) { pa.setWidth(pa.getWidth()-pos_step); } - - if (ImGui::Button("height+")) { pa.setHeight(pa.getHeight()+pos_step); } - ImGui::SameLine(); if (ImGui::Button("height-")) { pa.setHeight(pa.getHeight()-pos_step); } - + if (ImGui::Button("Hide")) { pa.hide(); } + ImGui::SameLine(); if (ImGui::Button("Show")) { pa.show(); } + + if (ImGui::Button("Position: Left+")) { pa.setLeft(pa.getLeft()+pos_step); } + ImGui::SameLine(); if (ImGui::Button("Position:left-")) { pa.setLeft(pa.getLeft()-pos_step); } + + if (ImGui::Button("Position: Top+")) { pa.setTop(pa.getTop()+pos_step); } + ImGui::SameLine(); if (ImGui::Button("Position:Top-")) { pa.setTop(pa.getTop()-pos_step); } + + if (ImGui::Button("Width+")) { pa.setWidth(pa.getWidth()+pos_step); } + ImGui::SameLine(); if (ImGui::Button("Width-")) { pa.setWidth(pa.getWidth()-pos_step); } + + if (ImGui::Button("height+")) { pa.setHeight(pa.getHeight()+pos_step); } + ImGui::SameLine(); if (ImGui::Button("height-")) { pa.setHeight(pa.getHeight()-pos_step); } + } ImGui::End(); } diff --git a/resources/scripts/example_ogre_terrnBatcher.as b/resources/scripts/example_ogre_terrnBatcher.as index 404712b4c4..24683bf38a 100644 --- a/resources/scripts/example_ogre_terrnBatcher.as +++ b/resources/scripts/example_ogre_terrnBatcher.as @@ -27,7 +27,7 @@ void main() void frameStep(float dt) { - if (ImGui::Begin("TERRN BATCHER [ALPHA]", closeBtnHandler.draw(), ImGuiWindowFlags_AlwaysAutoResize)) + if (ImGui::Begin("TERRN BATCHER [ALPHA]", closeBtnHandler.windowOpen, ImGuiWindowFlags_AlwaysAutoResize)) { closeBtnHandler.draw(); tbUI.draw();