diff --git a/samples/src/sample/atriasoft/ege/mapFactory/Log.java b/samples/src/sample/atriasoft/ege/mapFactory/Log.java index 768dc2a..7a4c466 100644 --- a/samples/src/sample/atriasoft/ege/mapFactory/Log.java +++ b/samples/src/sample/atriasoft/ege/mapFactory/Log.java @@ -1,39 +1,76 @@ package sample.atriasoft.ege.mapFactory; +import io.scenarium.logger.LogLevel; +import io.scenarium.logger.Logger; + 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) { - System.out.println("[C] " + Log.LIBNAME + " | " + data); + public static void critical(final Exception e, final String data) { + e.printStackTrace(); + if (PRINT_CRITICAL || FORCE_ALL) { + Logger.critical(LIB_NAME_DRAW, data + " : " + e.getMessage()); + } } - public static void debug(final String data) { - System.out.println("[D] " + Log.LIBNAME + " | " + data); + public static void critical(final String data, final Object... objects) { + if (PRINT_CRITICAL || FORCE_ALL) { + Logger.critical(LIB_NAME_DRAW, data, objects); + } } - public static void error(final String data) { - System.out.println("[E] " + Log.LIBNAME + " | " + data); + public static void debug(final String data, final Object... objects) { + if (PRINT_DEBUG || FORCE_ALL) { + Logger.debug(LIB_NAME_DRAW, data, objects); + } } - public static void info(final String data) { - System.out.println("[I] " + Log.LIBNAME + " | " + data); + public static void error(final String data, final Object... objects) { + if (PRINT_ERROR || FORCE_ALL) { + Logger.error(LIB_NAME_DRAW, data, objects); + } } - public static void print(final String data) { - System.out.println(data); + public static void info(final String data, final Object... objects) { + if (PRINT_INFO || FORCE_ALL) { + Logger.info(LIB_NAME_DRAW, data, objects); + } } - public static void todo(final String data) { - System.out.println("[TODO] " + Log.LIBNAME + " | " + data); + public static void print(final String data, final Object... objects) { + if (PRINT_PRINT || FORCE_ALL) { + Logger.print(LIB_NAME_DRAW, data, objects); + } } - public static void verbose(final String data) { - System.out.println("[V] " + Log.LIBNAME + " | " + data); + public static void todo(final String data, final Object... objects) { + if (PRINT_TODO || FORCE_ALL) { + Logger.todo(LIB_NAME_DRAW, data, objects); + } } - public static void warning(final String data) { - System.out.println("[W] " + Log.LIBNAME + " | " + data); + public static void verbose(final String data, final Object... objects) { + 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() {} + } diff --git a/samples/src/sample/atriasoft/ege/mapFactory/MainWindows.java b/samples/src/sample/atriasoft/ege/mapFactory/MainWindows.java index 3ad7d9f..ef93f21 100644 --- a/samples/src/sample/atriasoft/ege/mapFactory/MainWindows.java +++ b/samples/src/sample/atriasoft/ege/mapFactory/MainWindows.java @@ -10,24 +10,23 @@ import sample.atriasoft.ege.mapFactory.tools.ToolMapHeight; 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(); //self.testWidget.setPropertyFill(state.withY(!state.y())); - if (self.heightButton.getPropertyValue() == "Increase") { - self.heightButton.setPropertyValue("Decrease"); - } else { - self.heightButton.setPropertyValue("Increase"); - } + // if (self.heightButton.getPropertyValue() == "Increase") { + // self.heightButton.setPropertyValue("Decrease"); + // } else { + // 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(); //self.testWidget.setPropertyFill(state.withY(!state.y())); - if (self.toolButton.getPropertyValue() == "Brush") { - self.toolButton.setPropertyValue("Heigher"); + Log.warning("event elements : {}", value); + if (value) { self.scene.setCurrentTool(new ToolMapHeight()); } else { - self.toolButton.setPropertyValue("Brush"); self.scene.setCurrentTool(null); } } @@ -39,7 +38,7 @@ public class MainWindows extends Windows { public MainWindows() { setPropertyTitle("Map Factory (create your dream world)"); - Sizer sizerHoryMain = new Sizer(DisplayMode.modeHori); + Sizer sizerHoryMain = new Sizer(DisplayMode.HORIZONTAL); sizerHoryMain.setPropertyExpand(Vector3b.TRUE); sizerHoryMain.setPropertyFill(Vector3b.TRUE); setSubWidget(sizerHoryMain); @@ -49,25 +48,23 @@ public class MainWindows extends Windows { this.scene.setPropertyFill(Vector3b.TRUE); sizerHoryMain.subWidgetAdd(this.scene); - Sizer sizerMenu = new Sizer(DisplayMode.modeVert); + Sizer sizerMenu = new Sizer(DisplayMode.VERTICAL); sizerMenu.setPropertyExpand(Vector3b.FALSE_TRUE_FALSE); sizerMenu.setPropertyLockExpand(Vector3b.TRUE); sizerMenu.setPropertyFill(Vector3b.TRUE); sizerHoryMain.subWidgetAdd(sizerMenu); - this.toolButton = new Button(); - this.toolButton.setPropertyValue("Heigher"); + this.toolButton = Button.createToggleLabelButton("Heigher", "Brush"); this.toolButton.setPropertyExpand(Vector3b.TRUE_FALSE_FALSE); this.toolButton.setPropertyFill(Vector3b.TRUE); sizerMenu.subWidgetAdd(this.toolButton); - this.toolButton.signalClick.connectAuto(this, MainWindows::eventButtonTool); + this.toolButton.signalValue.connectAuto(this, MainWindows::eventButtonTool); - this.heightButton = new Button(); - this.heightButton.setPropertyValue("Increase"); + this.heightButton = Button.createToggleLabelButton("Increase", "Decrease"); this.heightButton.setPropertyExpand(Vector3b.TRUE_FALSE_FALSE); this.heightButton.setPropertyFill(Vector3b.TRUE); sizerMenu.subWidgetAdd(this.heightButton); - this.heightButton.signalClick.connectAuto(this, MainWindows::eventButtonIncrease); + this.heightButton.signalValue.connectAuto(this, MainWindows::eventButtonIncrease); // set default tools: this.scene.setCurrentTool(new ToolMapHeight()); diff --git a/samples/src/sample/atriasoft/ege/mapFactory/tools/ToolMapHeight.xml b/samples/src/sample/atriasoft/ege/mapFactory/tools/ToolMapHeight.xml new file mode 100644 index 0000000..ab15a31 --- /dev/null +++ b/samples/src/sample/atriasoft/ege/mapFactory/tools/ToolMapHeight.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file