more context for level creator menu

This commit is contained in:
austin 2025-01-19 17:22:19 -05:00
parent b0d1a52311
commit 257c5f3a87

View File

@ -4,11 +4,13 @@ import java.util.List;
import electrosphere.client.ui.components.InputMacros;
import electrosphere.client.ui.components.VoxelSelectionPanel;
import electrosphere.client.ui.menu.WindowStrings;
import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.engine.Globals;
import electrosphere.engine.assetmanager.AssetDataStrings;
import electrosphere.engine.loadingthreads.LoadingThread;
import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType;
import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.entity.scene.SceneFile;
import electrosphere.game.data.voxel.VoxelType;
import electrosphere.renderer.ui.elements.Button;
@ -32,6 +34,11 @@ public class MenuGeneratorsLevelEditor {
*/
static final int DEFAULT_GRID_SIZE = 2;
/**
* The maximum selectable size for the grid
*/
static final int MAX_SELECTABLE_SIZE = 128;
/**
* Creates the top level menu for the level editor
* @return The actual element containing the menu
@ -187,12 +194,24 @@ public class MenuGeneratorsLevelEditor {
//
Div griddedRealmControls = Div.createCol();
{
Label gridSizeLabel = Label.createLabel("" + DEFAULT_GRID_SIZE);
//add actual slider
griddedRealmControls.addChild(
InputMacros.createSliderInput("Realm Size", (ValueChangeEvent event) -> {
float value = event.getAsFloat() * GriddedDataCellManager.MAX_GRID_SIZE;
float value = event.getAsFloat() * MenuGeneratorsLevelEditor.MAX_SELECTABLE_SIZE;
sceneFile.getRealmDescriptor().setGriddedRealmSize((int)value);
Globals.signalSystem.post(SignalType.UI_MODIFICATION,() -> {
gridSizeLabel.setText("" + (int)value);
Globals.signalSystem.post(SignalType.YOGA_APPLY, Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_MAIN));
});
}, DEFAULT_GRID_SIZE / (float)GriddedDataCellManager.MAX_GRID_SIZE)
);
//add size label
griddedRealmControls.addChild(gridSizeLabel);
//add voxel type selection
sceneFile.getRealmDescriptor().setGriddedRealmSize(DEFAULT_GRID_SIZE);
griddedRealmControls.addChild(VoxelSelectionPanel.createVoxelTypeSelectionPanel((VoxelType type) -> {
sceneFile.getRealmDescriptor().setBaseVoxel(type.getId());