update tools

This commit is contained in:
Edouard DUPIN 2022-09-03 21:19:59 +02:00
parent 9ece075f62
commit 824641ce84
3 changed files with 98 additions and 35 deletions

View File

@ -1,39 +1,76 @@
package sample.atriasoft.ege.mapFactory; package sample.atriasoft.ege.mapFactory;
import io.scenarium.logger.LogLevel;
import io.scenarium.logger.Logger;
public class Log { public class Log {
private static final String LIBNAME = "mapFactory"; private static final boolean FORCE_ALL = false;
private static final String LIB_NAME = "mapFactory";
private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME);
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LIB_NAME, LogLevel.CRITICAL);
private static final boolean PRINT_ERROR = Logger.getNeedPrint(LIB_NAME, LogLevel.ERROR);
private static final boolean PRINT_WARNING = Logger.getNeedPrint(LIB_NAME, LogLevel.WARNING);
private static final boolean PRINT_INFO = Logger.getNeedPrint(LIB_NAME, LogLevel.INFO);
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LIB_NAME, LogLevel.DEBUG);
private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(LIB_NAME, LogLevel.VERBOSE);
private static final boolean PRINT_TODO = Logger.getNeedPrint(LIB_NAME, LogLevel.TODO);
private static final boolean PRINT_PRINT = Logger.getNeedPrint(LIB_NAME, LogLevel.PRINT);
public static void critical(final String data) { public static void critical(final Exception e, final String data) {
System.out.println("[C] " + Log.LIBNAME + " | " + data); e.printStackTrace();
if (PRINT_CRITICAL || FORCE_ALL) {
Logger.critical(LIB_NAME_DRAW, data + " : " + e.getMessage());
}
} }
public static void debug(final String data) { public static void critical(final String data, final Object... objects) {
System.out.println("[D] " + Log.LIBNAME + " | " + data); if (PRINT_CRITICAL || FORCE_ALL) {
Logger.critical(LIB_NAME_DRAW, data, objects);
}
} }
public static void error(final String data) { public static void debug(final String data, final Object... objects) {
System.out.println("[E] " + Log.LIBNAME + " | " + data); if (PRINT_DEBUG || FORCE_ALL) {
Logger.debug(LIB_NAME_DRAW, data, objects);
}
} }
public static void info(final String data) { public static void error(final String data, final Object... objects) {
System.out.println("[I] " + Log.LIBNAME + " | " + data); if (PRINT_ERROR || FORCE_ALL) {
Logger.error(LIB_NAME_DRAW, data, objects);
}
} }
public static void print(final String data) { public static void info(final String data, final Object... objects) {
System.out.println(data); if (PRINT_INFO || FORCE_ALL) {
Logger.info(LIB_NAME_DRAW, data, objects);
}
} }
public static void todo(final String data) { public static void print(final String data, final Object... objects) {
System.out.println("[TODO] " + Log.LIBNAME + " | " + data); if (PRINT_PRINT || FORCE_ALL) {
Logger.print(LIB_NAME_DRAW, data, objects);
}
} }
public static void verbose(final String data) { public static void todo(final String data, final Object... objects) {
System.out.println("[V] " + Log.LIBNAME + " | " + data); if (PRINT_TODO || FORCE_ALL) {
Logger.todo(LIB_NAME_DRAW, data, objects);
}
} }
public static void warning(final String data) { public static void verbose(final String data, final Object... objects) {
System.out.println("[W] " + Log.LIBNAME + " | " + data); if (PRINT_VERBOSE || FORCE_ALL) {
Logger.verbose(LIB_NAME_DRAW, data, objects);
}
}
public static void warning(final String data, final Object... objects) {
if (PRINT_WARNING || FORCE_ALL) {
Logger.warning(LIB_NAME_DRAW, data, objects);
}
} }
private Log() {} private Log() {}
} }

View File

@ -10,24 +10,23 @@ import sample.atriasoft.ege.mapFactory.tools.ToolMapHeight;
public class MainWindows extends Windows { public class MainWindows extends Windows {
public static void eventButtonIncrease(final MainWindows self) { public static void eventButtonIncrease(final MainWindows self, Boolean value) {
//Vector2b state = self.testWidget.getPropertyFill(); //Vector2b state = self.testWidget.getPropertyFill();
//self.testWidget.setPropertyFill(state.withY(!state.y())); //self.testWidget.setPropertyFill(state.withY(!state.y()));
if (self.heightButton.getPropertyValue() == "Increase") { // if (self.heightButton.getPropertyValue() == "Increase") {
self.heightButton.setPropertyValue("Decrease"); // self.heightButton.setPropertyValue("Decrease");
} else { // } else {
self.heightButton.setPropertyValue("Increase"); // self.heightButton.setPropertyValue("Increase");
} // }
} }
public static void eventButtonTool(final MainWindows self) { public static void eventButtonTool(final MainWindows self, Boolean value) {
//Vector2b state = self.testWidget.getPropertyFill(); //Vector2b state = self.testWidget.getPropertyFill();
//self.testWidget.setPropertyFill(state.withY(!state.y())); //self.testWidget.setPropertyFill(state.withY(!state.y()));
if (self.toolButton.getPropertyValue() == "Brush") { Log.warning("event elements : {}", value);
self.toolButton.setPropertyValue("Heigher"); if (value) {
self.scene.setCurrentTool(new ToolMapHeight()); self.scene.setCurrentTool(new ToolMapHeight());
} else { } else {
self.toolButton.setPropertyValue("Brush");
self.scene.setCurrentTool(null); self.scene.setCurrentTool(null);
} }
} }
@ -39,7 +38,7 @@ public class MainWindows extends Windows {
public MainWindows() { public MainWindows() {
setPropertyTitle("Map Factory (create your dream world)"); setPropertyTitle("Map Factory (create your dream world)");
Sizer sizerHoryMain = new Sizer(DisplayMode.modeHori); Sizer sizerHoryMain = new Sizer(DisplayMode.HORIZONTAL);
sizerHoryMain.setPropertyExpand(Vector3b.TRUE); sizerHoryMain.setPropertyExpand(Vector3b.TRUE);
sizerHoryMain.setPropertyFill(Vector3b.TRUE); sizerHoryMain.setPropertyFill(Vector3b.TRUE);
setSubWidget(sizerHoryMain); setSubWidget(sizerHoryMain);
@ -49,25 +48,23 @@ public class MainWindows extends Windows {
this.scene.setPropertyFill(Vector3b.TRUE); this.scene.setPropertyFill(Vector3b.TRUE);
sizerHoryMain.subWidgetAdd(this.scene); sizerHoryMain.subWidgetAdd(this.scene);
Sizer sizerMenu = new Sizer(DisplayMode.modeVert); Sizer sizerMenu = new Sizer(DisplayMode.VERTICAL);
sizerMenu.setPropertyExpand(Vector3b.FALSE_TRUE_FALSE); sizerMenu.setPropertyExpand(Vector3b.FALSE_TRUE_FALSE);
sizerMenu.setPropertyLockExpand(Vector3b.TRUE); sizerMenu.setPropertyLockExpand(Vector3b.TRUE);
sizerMenu.setPropertyFill(Vector3b.TRUE); sizerMenu.setPropertyFill(Vector3b.TRUE);
sizerHoryMain.subWidgetAdd(sizerMenu); sizerHoryMain.subWidgetAdd(sizerMenu);
this.toolButton = new Button(); this.toolButton = Button.createToggleLabelButton("Heigher", "Brush");
this.toolButton.setPropertyValue("Heigher");
this.toolButton.setPropertyExpand(Vector3b.TRUE_FALSE_FALSE); this.toolButton.setPropertyExpand(Vector3b.TRUE_FALSE_FALSE);
this.toolButton.setPropertyFill(Vector3b.TRUE); this.toolButton.setPropertyFill(Vector3b.TRUE);
sizerMenu.subWidgetAdd(this.toolButton); sizerMenu.subWidgetAdd(this.toolButton);
this.toolButton.signalClick.connectAuto(this, MainWindows::eventButtonTool); this.toolButton.signalValue.connectAuto(this, MainWindows::eventButtonTool);
this.heightButton = new Button(); this.heightButton = Button.createToggleLabelButton("Increase", "Decrease");
this.heightButton.setPropertyValue("Increase");
this.heightButton.setPropertyExpand(Vector3b.TRUE_FALSE_FALSE); this.heightButton.setPropertyExpand(Vector3b.TRUE_FALSE_FALSE);
this.heightButton.setPropertyFill(Vector3b.TRUE); this.heightButton.setPropertyFill(Vector3b.TRUE);
sizerMenu.subWidgetAdd(this.heightButton); sizerMenu.subWidgetAdd(this.heightButton);
this.heightButton.signalClick.connectAuto(this, MainWindows::eventButtonIncrease); this.heightButton.signalValue.connectAuto(this, MainWindows::eventButtonIncrease);
// set default tools: // set default tools:
this.scene.setCurrentTool(new ToolMapHeight()); this.scene.setCurrentTool(new ToolMapHeight());

View File

@ -0,0 +1,29 @@
<composer>
<Sizer mode="VERTICAL" lock="true" fill="true" expand="true">
<Label name="[{ID}]file-chooser:title-label">_T{Change height map}</Label>
<Sizer mode="HORIZONTAL">
<Image name="[{ID}]HeighMap:img-radius" src="width.svg" expand="false" size="45,45px"/>
<Spacer min-size="2,2mm"/>
<Slider name="[{ID}]HeighMap:slider-width"
expand="true,false"
fill="true,false"
onChangeValue="onChangeRadius($1)" />
</Sizer>
<Sizer mode="HORIZONTAL">
<Image name="[{ID}]HeighMap:img-top" src="top.svg" expand="false" size="45,45px"/>
<Spacer min-size="2,2mm"/>
<Slider name="[{ID}]HeighMap:slider-top"
expand="true,false"
fill="true,false"
onChangeValue="onChangeTop($1)" />
</Sizer>
<Sizer mode="HORIZONTAL">
<Image name="[{ID}]HeighMap:img-bottom" src="bottom.svg" expand="false" size="45,45px"/>
<Spacer min-size="2,2mm"/>
<Slider name="[{ID}]HeighMap:slider-bottom"
expand="true,false"
fill="true,false"
onChangeValue="onChangeBottom($1)" />
</Sizer>
</Sizer>
</composer>