fab-saving work
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
7e7c91e6d5
commit
48c5a3bcf3
BIN
assets/Data/fab/defaultHouse.fab
Normal file
BIN
assets/Data/fab/defaultHouse.fab
Normal file
Binary file not shown.
@ -1863,6 +1863,8 @@ Visualize furniture placement slots
|
|||||||
AssetDataStrings work
|
AssetDataStrings work
|
||||||
Invert rotation calculation for fab cursor
|
Invert rotation calculation for fab cursor
|
||||||
BlockFab io work
|
BlockFab io work
|
||||||
|
File dialog support
|
||||||
|
Editor structure tab uses file dialog to save fabs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import electrosphere.data.block.fab.BlockFabMetadata;
|
|||||||
import electrosphere.data.block.fab.RoomMetadata;
|
import electrosphere.data.block.fab.RoomMetadata;
|
||||||
import electrosphere.data.block.fab.StructureMetadata;
|
import electrosphere.data.block.fab.StructureMetadata;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.renderer.ui.imgui.filediag.ImGuiFileDialogManager;
|
||||||
import imgui.ImGui;
|
import imgui.ImGui;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,8 +45,10 @@ public class ImGuiStructureTab {
|
|||||||
RoomSolver.computeRoomsFromSelection(Globals.cursorState.getAreaSelection(),currentFab.getFabMetadata().getStructureData());
|
RoomSolver.computeRoomsFromSelection(Globals.cursorState.getAreaSelection(),currentFab.getFabMetadata().getStructureData());
|
||||||
}
|
}
|
||||||
if(ImGui.button("Save")){
|
if(ImGui.button("Save")){
|
||||||
File exportLoc = new File("./assets/Data/fab/struct.block");
|
String defaultName = "struct";
|
||||||
currentFab.write(exportLoc);
|
ImGuiFileDialogManager.open("Save Fab", defaultName, ".fab", (File target) -> {
|
||||||
|
currentFab.write(target);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,6 +33,11 @@ public class BlockFab implements BlockMeshgenData {
|
|||||||
1 * 4 +
|
1 * 4 +
|
||||||
3 * 4
|
3 * 4
|
||||||
;
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default file ending for block fabs
|
||||||
|
*/
|
||||||
|
public static final String DEFAULT_FILE_ENDING = ".fab";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dimensions of the block fab
|
* Dimensions of the block fab
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import electrosphere.logger.LoggerInterface;
|
|||||||
import electrosphere.renderer.OpenGLState;
|
import electrosphere.renderer.OpenGLState;
|
||||||
import electrosphere.renderer.RenderPipelineState;
|
import electrosphere.renderer.RenderPipelineState;
|
||||||
import electrosphere.renderer.ui.imgui.ImGuiWindow;
|
import electrosphere.renderer.ui.imgui.ImGuiWindow;
|
||||||
|
import electrosphere.renderer.ui.imgui.filediag.ImGuiFileDialogManager;
|
||||||
import imgui.ImGui;
|
import imgui.ImGui;
|
||||||
import imgui.ImGuiViewport;
|
import imgui.ImGuiViewport;
|
||||||
import imgui.extension.implot.ImPlot;
|
import imgui.extension.implot.ImPlot;
|
||||||
@ -64,6 +65,7 @@ public class ImGuiPipeline implements RenderPipeline {
|
|||||||
if(ImGuiPipeline.shouldRenderDragAndDropTarget()){
|
if(ImGuiPipeline.shouldRenderDragAndDropTarget()){
|
||||||
ImGuiPipeline.renderDragAndDropTarget();
|
ImGuiPipeline.renderDragAndDropTarget();
|
||||||
}
|
}
|
||||||
|
ImGuiFileDialogManager.handleFileDialogs();
|
||||||
for(ImGuiWindow window : imGuiWindows){
|
for(ImGuiWindow window : imGuiWindows){
|
||||||
window.draw();
|
window.draw();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,79 @@
|
|||||||
|
package electrosphere.renderer.ui.imgui.filediag;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import imgui.extension.imguifiledialog.ImGuiFileDialog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manages file dialogs created with imgui
|
||||||
|
*/
|
||||||
|
public class ImGuiFileDialogManager {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Key for the file dialog
|
||||||
|
*/
|
||||||
|
public static final String key = "fileDiagKey";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimum width of the file modal
|
||||||
|
*/
|
||||||
|
public static final int MIN_WIDTH = 500;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimum height of the file modal
|
||||||
|
*/
|
||||||
|
public static final int MIN_HEIGHT = 500;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum width of the file modal
|
||||||
|
*/
|
||||||
|
public static final int MAX_WIDTH = 1000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum height of the file modal
|
||||||
|
*/
|
||||||
|
public static final int MAX_HEIGHT = 1000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter for any file ending
|
||||||
|
*/
|
||||||
|
public static final String ANY_FILE_ENDING = ".*";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The consumer of the selected path when a selection is made in the dialog
|
||||||
|
*/
|
||||||
|
private static Consumer<File> onAccept = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the file dialog
|
||||||
|
* @param onAccept The consumer for the path when a file is selected
|
||||||
|
*/
|
||||||
|
public static void open(String title, String fileDefaultName, String fileEndings, Consumer<File> onAccept){
|
||||||
|
ImGuiFileDialogManager.onAccept = onAccept;
|
||||||
|
ImGuiFileDialog.openModal(key, title, fileEndings, fileDefaultName, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the file dialog
|
||||||
|
* @param onAccept The consumer for the path when a file is selected
|
||||||
|
*/
|
||||||
|
public static void openDirSelect(String title, String fileDefaultName, Consumer<File> onAccept){
|
||||||
|
ImGuiFileDialogManager.onAccept = onAccept;
|
||||||
|
ImGuiFileDialog.openModal(key, title, null, fileDefaultName, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles rendering file dialog
|
||||||
|
*/
|
||||||
|
public static void handleFileDialogs(){
|
||||||
|
if(ImGuiFileDialog.display(key, 0, MIN_WIDTH, MIN_HEIGHT, MAX_WIDTH, MAX_HEIGHT)){
|
||||||
|
if(ImGuiFileDialog.isOk()){
|
||||||
|
File file = new File(ImGuiFileDialog.getCurrentPath() + "/" + ImGuiFileDialog.getCurrentFileName());
|
||||||
|
onAccept.accept(file);
|
||||||
|
}
|
||||||
|
ImGuiFileDialog.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user