Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,4 @@ bin/
### Mac OS ###
.DS_Store
/src/main/resources/config/
/src/main/resources/engine.json
/src/main/resources/log4j2.xml
/cache/
82 changes: 46 additions & 36 deletions logs/lastlog.log
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
[03:30:18.666][INFO] ===== Engine Initialization =====
[03:30:18.668][INFO]
[07:39:48.308][INFO]
╔════════════════════════════════════════╗
║ ===== FoxEngine Initialization ===== ║
║ Engine Version: 1.15.16 ║
║ Operating System: windows ║
║ Available Processors: 20 ║
║ System Load Average: -1,00 ║
║ Log Level: INFO ║
╚════════════════════════════════════════╝

_____ _____ _____
/\ \ /\ \ /\ \
/::\ \ /::\ \ /::\ \
Expand All @@ -20,37 +28,39 @@
\:::\ \
\:::\____\
\::/ /
\/____/
[03:30:18.674][INFO] Engine Version: 1.15.15
[03:30:18.674][INFO] Application Title: FoxesLauncher-1.24.1
[03:30:18.674][INFO] Operating System: windows
[03:30:18.674][INFO] Available Processors: 20
[03:30:18.675][INFO] System Load Average: -1.0
[03:30:18.675][INFO] Log Level: INFO
[03:30:18.679][INFO] Log level set to INFO
[03:30:18.762][INFO] Initializing ExecutorService with pool size: 10
[03:30:18.763][WARN] executor-config.properties not found, using default settings.
[03:30:18.763][INFO] Creating default ExecutorService with pool size: 10
[03:30:18.884][INFO]forge-0 Sounds loaded successfully
[03:30:19.087][INFO] FrameConstructor initialization
[03:30:19.091][INFO] Building FrameConstructor...
[03:30:19.210][INFO]forge-1 Initializing StyleProvider with path: assets/styles/
[03:30:19.220][INFO]forge-1 Registering json adapter...
[03:30:19.221][INFO]forge-1 Registering json5 adapter...
[03:30:19.221][INFO]forge-1 Registered adapters: [json5, json]
[03:30:19.233][INFO]forge-1 - Registered component: label
[03:30:19.235][INFO]forge-1 - Registered component: progressBar
[03:30:19.235][INFO]forge-1 - Registered component: button
[03:30:19.235][INFO]forge-1 - Registered component: textArea
[03:30:19.236][INFO]forge-1 - Registered component: checkBox
[03:30:19.236][INFO]forge-1 - Registered component: textField
[03:30:19.236][INFO]forge-1 - Registered component: spriteImage
[03:30:19.237][INFO]forge-1 - Registered component: passField
[03:30:19.237][INFO]forge-1 - Registered component: spinner
[03:30:19.237][INFO]forge-1 - Registered component: multiButton
[03:30:19.238][INFO]forge-1 - Registered component: dropBox
[03:30:19.238][INFO]forge-1 - Registered component: slider
[03:30:19.238][INFO]forge-1 - Registered component: compositeSlider
[03:30:19.239][INFO]forge-1 - Registered component: fileSelector
[03:30:19.239][INFO]forge-1 - Registered component: compositeComponent
[03:30:19.345][INFO] Created font - mcfontBold
\/____/
— TestApp-1.0.0
[07:39:48.315][INFO] Log level set to INFO
[07:39:48.402][INFO] Initializing ExecutorService with pool size: 10
[07:39:48.403][WARN] executor-config.properties not found, using default settings.
[07:39:48.403][INFO] Creating default ExecutorService with pool size: 10
[07:39:48.524][INFO]forge-0 Sounds loaded successfully
[07:39:48.702][INFO] FrameConstructor: initialization started
[07:39:48.702][INFO] FrameConstructor: building AppFrame from 'assets/frames/frame.json'
[07:39:48.846][INFO] FrameConstructor: frame is visible (title='ЛисийМир', size=850x500)
[07:39:48.846][INFO] FrameConstructor: frame successfully built from 'assets/frames/frame.json'
[07:39:48.847][INFO] FrameConstructor: initialization completed
[07:39:48.849][INFO]forge-1 Initializing StyleProvider with path: assets/styles/
[07:39:48.861][INFO]forge-1 Registering json adapter...
[07:39:48.861][INFO]forge-1 Registering json5 adapter...
[07:39:48.861][INFO]forge-1 Registered adapters: [json5, json]
[07:39:48.874][INFO]forge-1 - Registered component: label
[07:39:48.874][INFO]forge-1 - Registered component: progressBar
[07:39:48.875][INFO]forge-1 - Registered component: button
[07:39:48.875][INFO]forge-1 - Registered component: textArea
[07:39:48.875][INFO]forge-1 - Registered component: checkBox
[07:39:48.876][INFO]forge-1 - Registered component: textField
[07:39:48.876][INFO]forge-1 - Registered component: spriteImage
[07:39:48.876][INFO]forge-1 - Registered component: passField
[07:39:48.877][INFO]forge-1 - Registered component: spinner
[07:39:48.877][INFO]forge-1 - Registered component: multiButton
[07:39:48.877][INFO]forge-1 - Registered component: dropBox
[07:39:48.878][INFO]forge-1 - Registered component: slider
[07:39:48.878][INFO]forge-1 - Registered component: compositeSlider
[07:39:48.878][INFO]forge-1 - Registered component: fileSelector
[07:39:48.879][INFO]forge-1 - Registered component: compositeComponent
[07:39:48.884][INFO]forge-1 ActionHandler created with mainFrame panel and listens [class org.foxesworld.engine.gui.components.multiButton.MultiButton, class org.foxesworld.engine.gui.components.button.Button]
[07:39:48.974][INFO] FrameConstructor: frame focus gained
[07:39:48.975][INFO] FrameConstructor: frame focus gained
[07:39:49.004][INFO] Created font - mcfontBold
[07:39:49.093][INFO] Created font - mcfont
82 changes: 71 additions & 11 deletions src/main/java/org/foxesworld/engine/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,24 +165,30 @@ public Engine(int poolSize, String worker, Map<String, Class<?>> configFiles) {
appTitle = engineData.getLauncherBrand() + '-' + engineData.getLauncherVersion();
this.panelVisibility = new PanelVisibility(this);

LOGGER.info("===== Engine Initialization =====");
LOGGER.info(this.engineInfo.getEngineBrand());
LOGGER.info("Engine Version: {}", this.engineInfo.getEngineVersion());
LOGGER.info("Application Title: {}", appTitle);
LOGGER.info("Operating System: {}", currentOS);
LOGGER.info("Available Processors: {}", osBean.getAvailableProcessors());
LOGGER.info("System Load Average: {}", osBean.getSystemLoadAverage());
LOGGER.info("Log Level: {}", engineData.getLogLevel());
if(configFiles != null) {
LOGGER.info("Configuration Files: {}", configFiles.keySet());
}
logEngineInfoBox(
LOGGER,
this.engineInfo.getEngineBrand(),
this.engineInfo.getEngineVersion(),
appTitle,
currentOS,
osBean,
engineData.getLogLevel(),
configFiles
);


this.FONTUTILS = new FontUtils(this);
setLogLevel(Level.valueOf(engineData.getLogLevel()));
executorServiceProvider = new ExecutorServiceProvider(poolSize, worker);

this.imageUtils = new ImageUtils();
FlatIntelliJLaf.setup();

//Basic Components Initialisation
this.LANG = new LanguageProvider(this, fileProperties.getLocaleFile(), 0);
this.SOUND = new Sound(this, getClass().getClassLoader().getResourceAsStream(fileProperties.getSoundsFile()));
this.frameConstructor = new FrameConstructor(this);
this.CRYPTO = new CryptUtils();
}

/**
Expand All @@ -195,6 +201,56 @@ public void setLogLevel(Level level) {
LOGGER.info("Log level set to " + level);
}

public static void logEngineInfoBox(
Logger LOGGER,
String engineBrand,
String engineVersion,
String appTitle,
String currentOS,
OperatingSystemMXBean osBean,
String logLevel,
Map<String, ?> configFiles // nullable
) {
String header = String.format(
"%s \n— %s",
engineBrand != null ? engineBrand : "Unknown Engine",
appTitle != null ? appTitle : "Untitled"
);

// Prepare lines
List<String> lines = new ArrayList<>();
lines.add("===== FoxEngine Initialization =====");
lines.add(String.format("Engine Version: %s", engineVersion));
lines.add(String.format("Operating System: %s", currentOS));
if (osBean != null) {
lines.add(String.format("Available Processors: %d", osBean.getAvailableProcessors()));
lines.add(String.format("System Load Average: %.2f", osBean.getSystemLoadAverage()));
}
lines.add(String.format("Log Level: %s", logLevel));
if (configFiles != null && !configFiles.isEmpty()) {
lines.add(String.format("Configuration Files: %s", configFiles.keySet()));
}

// Compute max width
int max = 0;
for (String l : lines) if (l.length() > max) max = l.length();
int padding = 2; // left + right inner padding
int innerWidth = max + padding * 2;

// Box drawing
String top = "╔" + "═".repeat(innerWidth) + "╗\n";
String middle = "";
String bottom = "╚" + "═".repeat(innerWidth) + "╝";

for (String l : lines) {
String padded = " ".repeat(padding) + l + " ".repeat(innerWidth - padding - l.length());
middle += "║" + padded + "║\n";
}
String box = top + middle + bottom;
LOGGER.info("\n" + box + "\n" + header );
}


/**
* Abstract method for initializing the concrete engine implementation.
* Implement application-specific initialization (load services, GUI, etc.).
Expand Down Expand Up @@ -676,6 +732,10 @@ public IconUtils getIconUtils() {
return iconUtils;
}

public FileProperties getFileProperties() {
return fileProperties;
}

/**
* Sets the icon utilities.
*
Expand Down
32 changes: 17 additions & 15 deletions src/main/java/org/foxesworld/engine/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
import org.foxesworld.engine.gui.GuiBuilder;
import org.foxesworld.engine.gui.components.ComponentAttributes;
import org.foxesworld.engine.gui.components.ComponentFactoryListener;
import org.foxesworld.engine.gui.components.frame.FrameConstructor;
import org.foxesworld.engine.gui.components.button.Button;
import org.foxesworld.engine.gui.components.frame.OptionGroups;
import org.foxesworld.engine.gui.components.multiButton.MultiButton;
import org.foxesworld.engine.gui.styles.StyleProvider;
import org.foxesworld.engine.locale.LanguageProvider;
import org.foxesworld.engine.sound.Sound;
import org.foxesworld.engine.utils.Crypt.CryptUtils;
import org.foxesworld.engine.utils.IconUtils;

import javax.swing.*;
Expand Down Expand Up @@ -53,20 +51,17 @@ protected void preInit() {
System.setProperty("AppDir", System.getenv("APPDATA"));
System.setProperty("RamAmount", String.valueOf(Runtime.getRuntime().maxMemory() / 45));

this.LANG = new LanguageProvider(this, fileProperties.getLocaleFile(), 0);
this.SOUND = new Sound(this, getClass().getClassLoader().getResourceAsStream(fileProperties.getSoundsFile()));
this.frameConstructor = new FrameConstructor(this);
this.CRYPTO = new CryptUtils();
this.frameConstructor.setFocusStatusListener(this);
}

@Override
protected void postInit() {
setActionHandler(new ActionHandler(this.getGuiBuilder(), "mainFrame", List.of(MultiButton.class, Button.class)));
}

@Override
public void onPanelsBuilt() {

this.getFrame().repaint();
}

@Override
Expand All @@ -76,7 +71,6 @@ public void onAdditionalPanelBuild(JPanel panel) {

@Override
public void onGuiBuilt() {
this.getFrame().repaint();
}

@Override
Expand All @@ -86,15 +80,15 @@ public void onPanelBuild(Map<String, OptionGroups> panels, String componentGroup

@Override
public void actionPerformed(ActionEvent e) {

actionHandler.handleAction(e);
}

@Override
public void updateFocus(boolean hasFocus) {

}

class InitialValue extends ComponentValue implements ComponentFactoryListener {
static class InitialValue extends ComponentValue implements ComponentFactoryListener {

private int count;
private final Test launcher;
Expand All @@ -121,7 +115,7 @@ public void setInitialData(ComponentAttributes componentAttributes) {
}
}

class ActionHandler extends org.foxesworld.engine.gui.ActionHandler {
static class ActionHandler extends org.foxesworld.engine.gui.ActionHandler {

public ActionHandler(GuiBuilder guiBuilder, String panelId, List<Class<?>> componentTypes) {
super(guiBuilder, panelId, componentTypes);
Expand All @@ -130,7 +124,15 @@ public ActionHandler(GuiBuilder guiBuilder, String panelId, List<Class<?>> compo

@Override
public void handleAction(ActionEvent e) {

switch (e.getActionCommand()){
case "closeButton":
System.exit(0);
break;

case "hideButton":
engine.getFrame().setExtendedState(Frame.ICONIFIED);
break;
}
}

@Override
Expand All @@ -145,7 +147,7 @@ public void unregisterCommand(String key) {

@Override
public void executeCommand(String key, ActionEvent event) {

System.out.println(key);
}
}
}
2 changes: 2 additions & 0 deletions src/main/java/org/foxesworld/engine/gui/ActionHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public abstract class ActionHandler extends ComponentsAccessor implements Dynami

public ActionHandler(GuiBuilder guiBuilder, String panelId, List<Class<?>> componentTypes) {
super(guiBuilder, panelId, componentTypes);
this.engine = guiBuilder.getEngine();
Engine.LOGGER.info("ActionHandler created with {} panel and listens {}", panelId, componentTypes);
}

@SuppressWarnings("unused")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ public ComponentsAccessor(GuiBuilder guiBuilder, String panelId, List<Class<?>>
* Scans declared fields of this class for the {@code @Component} annotation and injects
* matching {@link JComponent} instances into annotated fields.
*
* <p>
*
* Injection rules:
* <ul>
* <li>If annotation's {@code value()} is non-empty, it is used as the component id.</li>
* <li>Otherwise the Java field name is used as the component id.</li>
* </ul>
* </p>
*
*
* @throws RuntimeException if a field cannot be set due to access restrictions.
* @throws IllegalArgumentException if a required component id cannot be found in the collected components.
Expand Down
Loading
Loading