UpdateSceneDataCommand + new splash screen

This commit is contained in:
MiChinao
2020-07-29 12:51:49 +02:00
parent 611613af97
commit 9f79d6a776
10 changed files with 135 additions and 17 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 253 KiB

+3 -3
View File
@@ -6,7 +6,7 @@ filter: Nearest,Nearest
repeat: none
bg_color
rotate: false
xy: 471, 480
xy: 471, 444
size: 8, 8
orig: 8, 8
offset: 0, 0
@@ -14,8 +14,8 @@ bg_color
splash_bg
rotate: false
xy: 2, 122
size: 467, 366
orig: 467, 366
size: 467, 330
orig: 467, 330
offset: 0, 0
index: -1
splash_logo
Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 320 KiB

@@ -100,6 +100,7 @@ public class MsgAPI {
public static final String ACTION_RELEASE_SELECTION = SANDBOX_PREFIX + "ACTION_RELEASE_SELECTION";
public static final String ACTION_Z_INDEX_CHANGED = SANDBOX_PREFIX + "ACTION_Z_INDEX_CHANGED";
public static final String ACTION_UPDATE_SCENE_DATA = SANDBOX_PREFIX + "ACTION_UPDATE_SCENE_DATA";
public static final String ACTION_UPDATE_IMAGE_ITEM_DATA = SANDBOX_PREFIX + "ACTION_UPDATE_IMAGE_ITEM_DATA";
public static final String ACTION_UPDATE_ITEM_DATA = SANDBOX_PREFIX + "ACTION_UPDATE_ITEM_DATA";
public static final String ACTION_UPDATE_LABEL_DATA = SANDBOX_PREFIX + "ACTION_UPDATE_LABEL_DATA";
@@ -5,15 +5,10 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3WindowListener;
import games.rednblack.editor.splash.SplashScreenAdapter;
import games.rednblack.editor.utils.AppConfig;
import games.rednblack.h2d.common.MsgAPI;
import org.apache.commons.lang3.SystemUtils;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class HyperLap2DApp extends ApplicationAdapter {
private static HyperLap2DApp sInstance = null;
@@ -42,7 +37,7 @@ public class HyperLap2DApp extends ApplicationAdapter {
Lwjgl3Application app = (Lwjgl3Application) Gdx.app;
Lwjgl3ApplicationConfiguration config2 = new Lwjgl3ApplicationConfiguration();
config2.setWindowedMode(467, 415);
config2.setWindowedMode(467, 385);
config2.setTitle("HyperLap2D");
config2.setResizable(false);
config2.setDecorated(false);
@@ -69,6 +69,7 @@ public class BootstrapCommand extends SimpleCommand {
facade.registerCommand(MsgAPI.ACTION_UPDATE_RULER_POSITION, ChangeRulerPositionCommand.class);
// DATA MODIFY by components
facade.registerCommand(MsgAPI.ACTION_UPDATE_SCENE_DATA, UpdateSceneDataCommand.class);
facade.registerCommand(MsgAPI.ACTION_UPDATE_ITEM_DATA, UpdateEntityComponentsCommand.class);
facade.registerCommand(MsgAPI.ACTION_UPDATE_LABEL_DATA, UpdateLabelDataCommand.class);
facade.registerCommand(MsgAPI.ACTION_UPDATE_LIGHT_DATA, UpdateLightDataCommand.class);
@@ -0,0 +1,89 @@
package games.rednblack.editor.controller.commands;
import games.rednblack.editor.renderer.data.LightsPropertiesVO;
import games.rednblack.editor.renderer.data.PhysicsPropertiesVO;
import games.rednblack.editor.renderer.data.SceneVO;
import games.rednblack.editor.view.stage.Sandbox;
import games.rednblack.h2d.common.MsgAPI;
public class UpdateSceneDataCommand extends EntityModifyRevertibleCommand {
private SceneVO sceneVO;
private PhysicsPropertiesVO physicsBackup;
private LightsPropertiesVO lightsBackup;
@Override
public void doAction() {
Object[] payload = getNotification().getBody();
sceneVO = (SceneVO) payload[0];
PhysicsPropertiesVO physicsPropertiesVO = (PhysicsPropertiesVO) payload[1];
LightsPropertiesVO lightsPropertiesVO = (LightsPropertiesVO) payload[2];
physicsBackup = new PhysicsPropertiesVO(sceneVO.physicsPropertiesVO);
lightsBackup = new LightsPropertiesVO(sceneVO.lightsPropertiesVO);
PhysicsPropertiesVO physicsVO = sceneVO.physicsPropertiesVO;
physicsVO.gravityX = physicsPropertiesVO.gravityX;
physicsVO.gravityY = physicsPropertiesVO.gravityY;
physicsVO.sleepVelocity = physicsPropertiesVO.sleepVelocity;
physicsVO.enabled = physicsPropertiesVO.enabled;
LightsPropertiesVO lightsVO = sceneVO.lightsPropertiesVO;
lightsVO.ambientColor[0] = lightsPropertiesVO.ambientColor[0];
lightsVO.ambientColor[1] = lightsPropertiesVO.ambientColor[1];
lightsVO.ambientColor[2] = lightsPropertiesVO.ambientColor[2];
lightsVO.ambientColor[3] = lightsPropertiesVO.ambientColor[3];
lightsVO.blurNum = lightsPropertiesVO.blurNum;
lightsVO.lightType = lightsPropertiesVO.lightType;
lightsVO.directionalDegree = lightsPropertiesVO.directionalDegree;
lightsVO.directionalRays = lightsPropertiesVO.directionalRays;
lightsVO.directionalColor[0] = lightsPropertiesVO.directionalColor[0];
lightsVO.directionalColor[1] = lightsPropertiesVO.directionalColor[1];
lightsVO.directionalColor[2] = lightsPropertiesVO.directionalColor[2];
lightsVO.directionalColor[3] = lightsPropertiesVO.directionalColor[3];
lightsVO.enabled = lightsPropertiesVO.enabled;
Sandbox.getInstance().sceneControl.updateAmbientLights();
facade.sendNotification(MsgAPI.ITEM_DATA_UPDATED);
}
@Override
public void undoAction() {
PhysicsPropertiesVO physicsVO = sceneVO.physicsPropertiesVO;
physicsVO.gravityX = physicsBackup.gravityX;
physicsVO.gravityY = physicsBackup.gravityY;
physicsVO.sleepVelocity = physicsBackup.sleepVelocity;
physicsVO.enabled = physicsBackup.enabled;
LightsPropertiesVO lightsVO = sceneVO.lightsPropertiesVO;
lightsVO.ambientColor[0] = lightsBackup.ambientColor[0];
lightsVO.ambientColor[1] = lightsBackup.ambientColor[1];
lightsVO.ambientColor[2] = lightsBackup.ambientColor[2];
lightsVO.ambientColor[3] = lightsBackup.ambientColor[3];
lightsVO.blurNum = lightsBackup.blurNum;
lightsVO.lightType = lightsBackup.lightType;
lightsVO.directionalDegree = lightsBackup.directionalDegree;
lightsVO.directionalRays = lightsBackup.directionalRays;
lightsVO.directionalColor[0] = lightsBackup.directionalColor[0];
lightsVO.directionalColor[1] = lightsBackup.directionalColor[1];
lightsVO.directionalColor[2] = lightsBackup.directionalColor[2];
lightsVO.directionalColor[3] = lightsBackup.directionalColor[3];
lightsVO.enabled = lightsBackup.enabled;
Sandbox.getInstance().sceneControl.updateAmbientLights();
facade.sendNotification(MsgAPI.ITEM_DATA_UPDATED);
}
public static Object payload(SceneVO scene, PhysicsPropertiesVO physicsPropertiesVO, LightsPropertiesVO lightsPropertiesVO) {
Object[] payload = new Object[3];
payload[0] = scene;
payload[1] = physicsPropertiesVO;
payload[2] = lightsPropertiesVO;
return payload;
}
}
@@ -19,9 +19,11 @@ public class SplashStage extends Stage {
public SplashStage() {
atlas = new TextureAtlas(Gdx.files.internal("splash/splash.atlas"));
BitmapFont robotFont = new BitmapFont(Gdx.files.internal("splash/myriad.fnt"));
Label.LabelStyle labelStyle = new Label.LabelStyle(robotFont, new Color(0, 0, 0, 1f));
Label.LabelStyle whiteLabelStyle = new Label.LabelStyle(robotFont, new Color(1, 1, 1, 1f));
Label.LabelStyle blackLabelStyle = new Label.LabelStyle(robotFont, new Color(0, 0, 0, 1f));
Image bg = new Image(atlas.findRegion("bg_color"));
bg.setColor(0, 0, 0, 1);
bg.setX(0);
bg.setY(0);
bg.setWidth(getWidth());
@@ -43,22 +45,22 @@ public class SplashStage extends Stage {
logoText.setY(logo.getY() + 30);
addActor(logoText);
progress = new Label("Loading fonts", labelStyle);
progress = new Label("Loading fonts", blackLabelStyle);
progress.setX(logoText.getX() + ((logoText.getWidth() - progress.getWidth() )/ 2));
progress.setY(logo.getY() + 5);
addActor(progress);
Label companyName = new Label("Red & Black Games", labelStyle);
Label companyName = new Label("Red & Black Games", whiteLabelStyle);
companyName.setX(13);
companyName.setY(55 - companyName.getHeight() - 7);
addActor(companyName);
Label copyright = new Label("Copyright (c) 2020. All rights reserved.", labelStyle);
Label copyright = new Label("Copyright (c) 2020, All rights reserved.", whiteLabelStyle);
copyright.setX(13);
copyright.setY(companyName.getY() - 20);
addActor(copyright);
Label version = new Label(AppConfig.getInstance().version, labelStyle);
Label version = new Label("v" + AppConfig.getInstance().version, whiteLabelStyle);
version.setX(getWidth() - 13 - version.getWidth());
version.setY(companyName.getY());
addActor(version);
@@ -65,7 +65,7 @@ public abstract class UIAbstractPropertiesMediator<T, V extends UIAbstractProper
translateViewToItemData();
}
}
System.out.println(notification.getName());
switch (notification.getName()) {
case MsgAPI.ITEM_DATA_UPDATED:
onItemDataUpdate();
@@ -20,9 +20,11 @@ package games.rednblack.editor.view.ui.properties.panels;
import com.kotcrab.vis.ui.widget.color.ColorPicker;
import com.kotcrab.vis.ui.widget.color.ColorPickerAdapter;
import games.rednblack.editor.controller.commands.UpdateSceneDataCommand;
import games.rednblack.editor.proxy.ResolutionManager;
import games.rednblack.editor.renderer.data.LightsPropertiesVO;
import games.rednblack.editor.renderer.data.ResolutionEntryVO;
import games.rednblack.h2d.common.MsgAPI;
import games.rednblack.h2d.common.view.ui.widget.HyperLapColorPicker;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.math.NumberUtils;
@@ -110,6 +112,7 @@ public class UIScenePropertiesMediator extends UIAbstractPropertiesMediator<Scen
@Override
protected void translateObservableDataToView(SceneVO item) {
System.out.println("translateObservableDataToView");
PhysicsPropertiesVO physicsVO = item.physicsPropertiesVO;
LightsPropertiesVO lightsVO = item.lightsPropertiesVO;
ResolutionManager resolutionManager = facade.retrieveProxy(ResolutionManager.NAME);
@@ -132,7 +135,34 @@ public class UIScenePropertiesMediator extends UIAbstractPropertiesMediator<Scen
@Override
protected void translateViewToItemData() {
PhysicsPropertiesVO physicsVO = observableReference.physicsPropertiesVO;
PhysicsPropertiesVO physicsVO = new PhysicsPropertiesVO();
physicsVO.gravityX = NumberUtils.toFloat(viewComponent.getGravityXValue(), physicsVO.gravityX);
physicsVO.gravityY = NumberUtils.toFloat(viewComponent.getGravityYValue(), physicsVO.gravityY);
physicsVO.sleepVelocity = NumberUtils.toFloat(viewComponent.getSleepVelocityValue(), physicsVO.sleepVelocity);
physicsVO.enabled = viewComponent.isPhysicsEnabled();
LightsPropertiesVO lightsVO = new LightsPropertiesVO();
Color color = viewComponent.getAmbientColor();
lightsVO.ambientColor[0] = color.r;
lightsVO.ambientColor[1] = color.g;
lightsVO.ambientColor[2] = color.b;
lightsVO.ambientColor[3] = color.a;
lightsVO.blurNum = NumberUtils.toInt(viewComponent.getBlurNumValue(), lightsVO.blurNum);
lightsVO.lightType = viewComponent.getLightType();
lightsVO.directionalDegree = NumberUtils.toFloat(viewComponent.getDirectionalDegree(), lightsVO.directionalDegree);
lightsVO.directionalRays = NumberUtils.toInt(viewComponent.getDirectionalRays(), lightsVO.directionalRays);
color = viewComponent.getDirectionalColor();
lightsVO.directionalColor[0] = color.r;
lightsVO.directionalColor[1] = color.g;
lightsVO.directionalColor[2] = color.b;
lightsVO.directionalColor[3] = color.a;
lightsVO.enabled = viewComponent.isLightsEnabled();
Object payload = UpdateSceneDataCommand.payload(observableReference, physicsVO, lightsVO);
facade.sendNotification(MsgAPI.ACTION_UPDATE_SCENE_DATA, payload);
/*PhysicsPropertiesVO physicsVO = observableReference.physicsPropertiesVO;
physicsVO.gravityX = NumberUtils.toFloat(viewComponent.getGravityXValue(), physicsVO.gravityX);
physicsVO.gravityY = NumberUtils.toFloat(viewComponent.getGravityYValue(), physicsVO.gravityY);
physicsVO.sleepVelocity = NumberUtils.toFloat(viewComponent.getSleepVelocityValue(), physicsVO.sleepVelocity);
@@ -156,6 +186,6 @@ public class UIScenePropertiesMediator extends UIAbstractPropertiesMediator<Scen
lightsVO.enabled = viewComponent.isLightsEnabled();
Sandbox.getInstance().sceneControl.updateAmbientLights();
Sandbox.getInstance().sceneControl.updateAmbientLights();*/
}
}