Compare commits
18
Commits
v5d
...
before-rewrite
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
416fe6773d | ||
|
|
4d2fc55a29 | ||
|
|
b2c9eec9fb | ||
|
|
b384d7a70a | ||
|
|
a3d0c945bc | ||
|
|
0872a9a221 | ||
|
|
dca4b58b86 | ||
|
|
0f2cb0b985 | ||
|
|
e510ca592b | ||
|
|
cba8886ece | ||
|
|
f862708ddd | ||
|
|
5963ec62a7 | ||
|
|
b0c0545c2d | ||
|
|
7ddaafcffa | ||
|
|
03f4d453ba | ||
|
|
25e5275e1e | ||
|
|
1b9c8c6be7 | ||
|
|
162bcc9b7e |
@@ -32,5 +32,6 @@
|
||||
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="Rogue/lib"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/MightyUtils"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
/target/
|
||||
/~local/
|
||||
/.rogue-save/
|
||||
/build/
|
||||
/build/out/*.jar
|
||||
/build/in/*.jar
|
||||
*.log
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
Copyright (c) 2014, Ondřej Hruška (MightyPork), <ondra@ondrovo.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -39,7 +39,7 @@ run: $(OUT)
|
||||
java -jar $(OUT) -w .rogue-save
|
||||
|
||||
debug: $(OUT)
|
||||
java -jar $(OUT) -w .rogue-save --debug
|
||||
java -jar $(OUT) -w .rogue-save --verbose --debug-bus
|
||||
|
||||
stats:
|
||||
@-echo "Commits:" `git rev-list HEAD --count`
|
||||
|
||||
@@ -1,6 +1,25 @@
|
||||
# Rogue - Savage Rats
|
||||
|
||||
Manual on [Google Drive](https://docs.google.com/document/d/1Ak9oVOnCKSqWux4Hm_-efDYTj4uewf5MtR_Zmys7goQ)
|
||||
**Read the [MANUAL](http://goo.gl/AU0IdI) if you want to play the game.**
|
||||
|
||||
It explains it way better than this text file.
|
||||
|
||||
|
||||
DEPENDENCIES:
|
||||
-------------
|
||||
|
||||
- [MightyPork/ion](https://github.com/MightyPork/ion)
|
||||
- [MightyPork/dynmath](https://github.com/MightyPork/dynmath)
|
||||
|
||||
---
|
||||
|
||||
The package `mightypork.gamecore` contains the framework part of the project.
|
||||
|
||||
It is not yet ready to be published on it's own, but you can have a look at the
|
||||
source if you're interested. The actual library repo will be set up later, with
|
||||
more polished code, better docs, and cleaner hierarchy.
|
||||
|
||||
---
|
||||
|
||||
## Description
|
||||
|
||||
@@ -34,10 +53,15 @@ Manual on [Google Drive](https://docs.google.com/document/d/1Ak9oVOnCKSqWux4Hm_-
|
||||
- SlickUtil (texture loader, audio system)
|
||||
|
||||
|
||||
|
||||
## BUILDING FROM SOURCE
|
||||
|
||||
1. Export a jar with the `mightypork.*` packages and the `res` folder into `build/in/build.jar`
|
||||
1. Export a jar with the following (all compiled sources and res) into `build/in/build.jar`:
|
||||
- `mightypork.gamecore.*`
|
||||
- `mightypork.rogue.*`
|
||||
- `mightypork.ion.*`
|
||||
- `mightypork.dynmath.*`
|
||||
- `res` folder with Rogue resources
|
||||
|
||||
2. Run `make` to create a stand-alone executable jar in `build/out/release.jar`
|
||||
3. Use `make run` to execute it
|
||||
|
||||
@@ -47,24 +71,4 @@ Manual on [Google Drive](https://docs.google.com/document/d/1Ak9oVOnCKSqWux4Hm_-
|
||||
|
||||
The game is controlled by mouse and keyboard.
|
||||
|
||||
### In-game controls
|
||||
|
||||
- *ARROWS* or *ASDW* - walking
|
||||
- *E* - eat smallest food
|
||||
- *Z* - Toggle map magnification (zoom)
|
||||
- *M* - Toggle the minimap
|
||||
- *I* - Toggle inventory screen (pauses the game)
|
||||
- *SPACE*, *P*, *PAUSE* - pause / resume the game
|
||||
|
||||
- *Left button hold* - walk in the direction
|
||||
- *Right click* - find path to the tile (works also on Minimap)
|
||||
|
||||
|
||||
### Global controls
|
||||
|
||||
- *Ctrl+M* - Jump to main menu
|
||||
- *Ctrl+Q* - Quit to DOS
|
||||
- *F2* - Take a screenshot
|
||||
- *F11* - Toggle fullscreen
|
||||
|
||||
|
||||
See the manual (link at the top) for more detailed info.
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<jardesc>
|
||||
<jar path="Rogue/build/in/build.jar"/>
|
||||
<options buildIfNeeded="true" compress="false" descriptionLocation="/Rogue/build/export_new.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="true" overwrite="true" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
|
||||
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
|
||||
<selectedProjects/>
|
||||
<manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
|
||||
<sealing sealJar="false">
|
||||
<packagesToSeal/>
|
||||
<packagesToUnSeal/>
|
||||
</sealing>
|
||||
</manifest>
|
||||
<selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
|
||||
<javaElement handleIdentifier="=DynMath/src"/>
|
||||
<javaElement handleIdentifier="=Rogue/src"/>
|
||||
<javaElement handleIdentifier="=Ion/src"/>
|
||||
<folder path="/Rogue/res"/>
|
||||
<file path="/Rogue/LICENSE.txt"/>
|
||||
</selectedElements>
|
||||
</jardesc>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -7,15 +7,15 @@ import java.util.Map;
|
||||
|
||||
import mightypork.gamecore.input.KeyStroke;
|
||||
import mightypork.gamecore.input.Keys;
|
||||
import mightypork.gamecore.logging.Log;
|
||||
import mightypork.gamecore.util.files.config.Property;
|
||||
import mightypork.gamecore.util.files.config.PropertyManager;
|
||||
import mightypork.utils.files.config.Property;
|
||||
import mightypork.utils.files.config.PropertyManager;
|
||||
import mightypork.utils.logging.Log;
|
||||
|
||||
|
||||
/**
|
||||
* Static application configuration
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class Config {
|
||||
|
||||
@@ -63,7 +63,7 @@ public class Config {
|
||||
* Key property.<br>
|
||||
* The stored value must be invariant ({@link KeyStroke} is mutable).
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public static class KeyProperty extends Property<KeyStroke> {
|
||||
|
||||
|
||||
@@ -5,13 +5,13 @@ import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import mightypork.gamecore.logging.Log;
|
||||
import mightypork.utils.logging.Log;
|
||||
|
||||
|
||||
/**
|
||||
* Static application workdir accessor.
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class WorkDir {
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@ package mightypork.gamecore.core.events;
|
||||
|
||||
|
||||
import mightypork.gamecore.core.modules.MainLoop;
|
||||
import mightypork.gamecore.eventbus.BusEvent;
|
||||
import mightypork.gamecore.eventbus.event_flags.SingleReceiverEvent;
|
||||
import mightypork.utils.eventbus.BusEvent;
|
||||
import mightypork.utils.eventbus.events.flags.SingleReceiverEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Request to execute given {@link Runnable} in main loop.
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
@SingleReceiverEvent
|
||||
public class MainLoopRequest extends BusEvent<MainLoop> {
|
||||
|
||||
@@ -2,17 +2,16 @@ package mightypork.gamecore.core.events;
|
||||
|
||||
|
||||
import mightypork.gamecore.core.modules.MainLoop;
|
||||
import mightypork.gamecore.eventbus.BusEvent;
|
||||
import mightypork.gamecore.eventbus.event_flags.NonConsumableEvent;
|
||||
import mightypork.gamecore.eventbus.event_flags.SingleReceiverEvent;
|
||||
import mightypork.gamecore.resources.audio.SoundSystem;
|
||||
import mightypork.utils.eventbus.BusEvent;
|
||||
import mightypork.utils.eventbus.events.flags.NonConsumableEvent;
|
||||
import mightypork.utils.eventbus.events.flags.SingleReceiverEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Shutdown request, non-interactive. Shutdown needs to execute on GL thread for
|
||||
* display to deinit properly.
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
@SingleReceiverEvent
|
||||
@NonConsumableEvent
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package mightypork.gamecore.core.events;
|
||||
|
||||
|
||||
import mightypork.gamecore.eventbus.BusEvent;
|
||||
import mightypork.gamecore.eventbus.EventBus;
|
||||
import mightypork.utils.eventbus.BusEvent;
|
||||
import mightypork.utils.eventbus.EventBus;
|
||||
|
||||
|
||||
/**
|
||||
@@ -10,7 +10,7 @@ import mightypork.gamecore.eventbus.EventBus;
|
||||
* titlebar button, and if no client consumes it, the application will be shut
|
||||
* down.
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class UserQuitRequest extends BusEvent<UserQuitRequestListener> {
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ package mightypork.gamecore.core.events;
|
||||
/**
|
||||
* Quit request listener; implementing client can abort shutdown.
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public interface UserQuitRequestListener {
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package mightypork.gamecore.core.modules;
|
||||
|
||||
|
||||
import mightypork.gamecore.eventbus.BusAccess;
|
||||
import mightypork.gamecore.input.InputSystem;
|
||||
import mightypork.gamecore.render.DisplaySystem;
|
||||
import mightypork.gamecore.resources.audio.SoundSystem;
|
||||
import mightypork.utils.eventbus.BusAccess;
|
||||
|
||||
|
||||
/**
|
||||
* App interface visible to subsystems
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public interface AppAccess extends BusAccess {
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package mightypork.gamecore.core.modules;
|
||||
|
||||
|
||||
import mightypork.gamecore.eventbus.EventBus;
|
||||
import mightypork.gamecore.input.InputSystem;
|
||||
import mightypork.gamecore.render.DisplaySystem;
|
||||
import mightypork.gamecore.resources.audio.SoundSystem;
|
||||
import mightypork.utils.eventbus.EventBus;
|
||||
|
||||
|
||||
/**
|
||||
* App access adapter (defualt {@link AppAccess} implementation)
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class AppAccessAdapter implements AppAccess {
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package mightypork.gamecore.core.modules;
|
||||
|
||||
|
||||
import mightypork.gamecore.eventbus.clients.RootBusNode;
|
||||
import mightypork.gamecore.input.InputSystem;
|
||||
import mightypork.gamecore.render.DisplaySystem;
|
||||
import mightypork.gamecore.resources.audio.SoundSystem;
|
||||
import mightypork.utils.eventbus.clients.RootBusNode;
|
||||
|
||||
|
||||
/**
|
||||
* App event bus client, to be used for subsystems, screens and anything that
|
||||
* needs access to the eventbus and other systems; Attached directly to bus.
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public abstract class AppModule extends RootBusNode implements AppAccess {
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package mightypork.gamecore.core.modules;
|
||||
|
||||
|
||||
import mightypork.gamecore.eventbus.clients.BusNode;
|
||||
import mightypork.gamecore.eventbus.clients.DelegatingClient;
|
||||
import mightypork.gamecore.eventbus.clients.RootBusNode;
|
||||
import mightypork.gamecore.input.InputSystem;
|
||||
import mightypork.gamecore.render.DisplaySystem;
|
||||
import mightypork.gamecore.resources.audio.SoundSystem;
|
||||
import mightypork.utils.eventbus.clients.BusNode;
|
||||
import mightypork.utils.eventbus.clients.DelegatingClient;
|
||||
import mightypork.utils.eventbus.clients.RootBusNode;
|
||||
|
||||
|
||||
/**
|
||||
* Delegating bus client, to be attached to any {@link DelegatingClient}, such
|
||||
* as a {@link RootBusNode}.
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class AppSubModule extends BusNode implements AppAccess {
|
||||
|
||||
|
||||
@@ -11,36 +11,39 @@ import java.util.logging.Level;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import mightypork.gamecore.core.Config;
|
||||
import mightypork.gamecore.core.WorkDir;
|
||||
import mightypork.gamecore.core.Config.ConfigSetup;
|
||||
import mightypork.gamecore.core.Config.KeySetup;
|
||||
import mightypork.gamecore.core.WorkDir;
|
||||
import mightypork.gamecore.core.WorkDir.RouteSetup;
|
||||
import mightypork.gamecore.eventbus.EventBus;
|
||||
import mightypork.gamecore.eventbus.events.DestroyEvent;
|
||||
import mightypork.gamecore.gui.screens.ScreenRegistry;
|
||||
import mightypork.gamecore.gui.screens.impl.CrossfadeOverlay;
|
||||
import mightypork.gamecore.input.InputSystem;
|
||||
import mightypork.gamecore.logging.Log;
|
||||
import mightypork.gamecore.logging.SlickLogRedirector;
|
||||
import mightypork.gamecore.logging.writers.LogWriter;
|
||||
import mightypork.gamecore.render.DisplaySystem;
|
||||
import mightypork.gamecore.resources.AsyncResourceLoader;
|
||||
import mightypork.gamecore.resources.Res;
|
||||
import mightypork.gamecore.resources.ResourceLoader;
|
||||
import mightypork.gamecore.resources.ResourceSetup;
|
||||
import mightypork.gamecore.resources.audio.SoundSystem;
|
||||
import mightypork.gamecore.util.annot.DefaultImpl;
|
||||
import mightypork.gamecore.util.files.InstanceLock;
|
||||
import mightypork.gamecore.util.ion.Ion;
|
||||
import mightypork.gamecore.util.math.algo.Coord;
|
||||
import mightypork.gamecore.util.math.algo.Move;
|
||||
import mightypork.gamecore.util.SlickLogRedirector;
|
||||
import mightypork.utils.annotations.DefaultImpl;
|
||||
import mightypork.utils.eventbus.EventBus;
|
||||
import mightypork.utils.eventbus.events.DestroyEvent;
|
||||
import mightypork.utils.files.InstanceLock;
|
||||
import mightypork.utils.ion.Ion;
|
||||
import mightypork.utils.ion.IonInput;
|
||||
import mightypork.utils.ion.IonOutput;
|
||||
import mightypork.utils.ion.IonizerBinary;
|
||||
import mightypork.utils.logging.Log;
|
||||
import mightypork.utils.logging.writers.LogWriter;
|
||||
import mightypork.utils.math.algo.Coord;
|
||||
import mightypork.utils.math.algo.Move;
|
||||
|
||||
|
||||
/**
|
||||
* Basic screen-based game with subsystems.<br>
|
||||
* This class takes care of the initialization sequence.
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler {
|
||||
|
||||
@@ -320,8 +323,8 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler {
|
||||
{
|
||||
logSystemInfo();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected void logSystemInfo()
|
||||
{
|
||||
String txt = "";
|
||||
@@ -344,8 +347,46 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler {
|
||||
|
||||
protected void registerIonizables()
|
||||
{
|
||||
Ion.registerType(Coord.ION_MARK, Coord.class);
|
||||
Ion.registerType(Move.ION_MARK, Move.class);
|
||||
Ion.registerIndirect(255, new IonizerBinary<Coord>() {
|
||||
|
||||
@Override
|
||||
public void save(Coord object, IonOutput out) throws IOException
|
||||
{
|
||||
out.writeInt(object.x);
|
||||
out.writeInt(object.y);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Coord load(IonInput in) throws IOException
|
||||
{
|
||||
final int x = in.readInt();
|
||||
final int y = in.readInt();
|
||||
return new Coord(x, y);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
Ion.registerIndirect(254, new IonizerBinary<Move>() {
|
||||
|
||||
@Override
|
||||
public void save(Move object, IonOutput out) throws IOException
|
||||
{
|
||||
out.writeInt(object.x());
|
||||
out.writeInt(object.y());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Move load(IonInput in) throws IOException
|
||||
{
|
||||
final int x = in.readInt();
|
||||
final int y = in.readInt();
|
||||
return new Move(x, y);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,26 +2,24 @@ package mightypork.gamecore.core.modules;
|
||||
|
||||
|
||||
import java.util.Deque;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import mightypork.gamecore.eventbus.events.UpdateEvent;
|
||||
import mightypork.gamecore.gui.screens.ScreenRegistry;
|
||||
import mightypork.gamecore.logging.Log;
|
||||
import mightypork.gamecore.render.Renderable;
|
||||
import mightypork.gamecore.render.TaskTakeScreenshot;
|
||||
import mightypork.gamecore.render.events.ScreenshotRequestListener;
|
||||
import mightypork.gamecore.resources.Profiler;
|
||||
import mightypork.gamecore.util.Utils;
|
||||
import mightypork.gamecore.util.annot.DefaultImpl;
|
||||
import mightypork.gamecore.util.math.timing.TimerDelta;
|
||||
import mightypork.utils.Support;
|
||||
import mightypork.utils.annotations.DefaultImpl;
|
||||
import mightypork.utils.eventbus.events.UpdateEvent;
|
||||
import mightypork.utils.logging.Log;
|
||||
import mightypork.utils.math.timing.Profiler;
|
||||
import mightypork.utils.math.timing.TimerDelta;
|
||||
|
||||
|
||||
/**
|
||||
* Delta-timed game loop with task queue etc.
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class MainLoop extends AppModule implements ScreenshotRequestListener {
|
||||
|
||||
@@ -74,7 +72,7 @@ public class MainLoop extends AppModule implements ScreenshotRequestListener {
|
||||
getEventBus().sendDirect(new UpdateEvent(delta));
|
||||
|
||||
Runnable r;
|
||||
long t = Profiler.begin();
|
||||
final long t = Profiler.begin();
|
||||
while ((r = tasks.poll()) != null) {
|
||||
Log.f3(" * Main loop task.");
|
||||
r.run();
|
||||
@@ -149,7 +147,7 @@ public class MainLoop extends AppModule implements ScreenshotRequestListener {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Utils.runAsThread(new TaskTakeScreenshot());
|
||||
Support.runAsThread(new TaskTakeScreenshot());
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package mightypork.gamecore.eventbus;
|
||||
|
||||
|
||||
/**
|
||||
* Access to an {@link EventBus} instance
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public interface BusAccess {
|
||||
|
||||
/**
|
||||
* @return event bus
|
||||
*/
|
||||
EventBus getEventBus();
|
||||
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
package mightypork.gamecore.eventbus;
|
||||
|
||||
|
||||
import mightypork.gamecore.eventbus.event_flags.DelayedEvent;
|
||||
import mightypork.gamecore.eventbus.event_flags.DirectEvent;
|
||||
import mightypork.gamecore.eventbus.event_flags.NonConsumableEvent;
|
||||
import mightypork.gamecore.eventbus.event_flags.NotLoggedEvent;
|
||||
import mightypork.gamecore.eventbus.event_flags.SingleReceiverEvent;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Event that can be handled by HANDLER, subscribing to the event bus.
|
||||
* </p>
|
||||
* <p>
|
||||
* Can be annotated as {@link SingleReceiverEvent} to be delivered once only,
|
||||
* and {@link DelayedEvent} or {@link DirectEvent} to specify default sending
|
||||
* mode. When marked as {@link NotLoggedEvent}, it will not appear in detailed
|
||||
* bus logging (useful for very frequent events, such as UpdateEvent).
|
||||
* </p>
|
||||
* <p>
|
||||
* Events annotated as {@link NonConsumableEvent} will throw an exception upon
|
||||
* an attempt to consume them.
|
||||
* </p>
|
||||
* <p>
|
||||
* Default sending mode (if not changed by annotations) is <i>queued</i> with
|
||||
* zero delay.
|
||||
* </p>
|
||||
*
|
||||
* @author MightyPork
|
||||
* @param <HANDLER> handler type
|
||||
*/
|
||||
public abstract class BusEvent<HANDLER> {
|
||||
|
||||
private boolean consumed;
|
||||
private boolean served;
|
||||
|
||||
|
||||
/**
|
||||
* Ask handler to handle this message.
|
||||
*
|
||||
* @param handler handler instance
|
||||
*/
|
||||
protected abstract void handleBy(HANDLER handler);
|
||||
|
||||
|
||||
/**
|
||||
* Consume the event, so no other clients will receive it.
|
||||
*
|
||||
* @throws UnsupportedOperationException if the {@link NonConsumableEvent}
|
||||
* annotation is present.
|
||||
*/
|
||||
public final void consume()
|
||||
{
|
||||
if (consumed) throw new IllegalStateException("Already consumed.");
|
||||
|
||||
if (getClass().isAnnotationPresent(NonConsumableEvent.class)) {
|
||||
throw new UnsupportedOperationException("Not consumable.");
|
||||
}
|
||||
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deliver to a handler using the handleBy method.
|
||||
*
|
||||
* @param handler handler instance
|
||||
*/
|
||||
final void deliverTo(HANDLER handler)
|
||||
{
|
||||
handleBy(handler);
|
||||
|
||||
if (!served) {
|
||||
if (getClass().isAnnotationPresent(SingleReceiverEvent.class)) {
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
served = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the event is consumed. Consumed event is not served to other
|
||||
* clients.
|
||||
*
|
||||
* @return true if consumed
|
||||
*/
|
||||
public final boolean isConsumed()
|
||||
{
|
||||
return consumed;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return true if the event was served to at least 1 client
|
||||
*/
|
||||
final boolean wasServed()
|
||||
{
|
||||
return served;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear "served" and "consumed" flags before dispatching.
|
||||
*/
|
||||
final void clearFlags()
|
||||
{
|
||||
served = false;
|
||||
consumed = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called after all clients have received the event.
|
||||
*/
|
||||
public void onDispatchComplete(EventBus bus)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,400 +0,0 @@
|
||||
package mightypork.gamecore.eventbus;
|
||||
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
import java.util.concurrent.DelayQueue;
|
||||
import java.util.concurrent.Delayed;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import mightypork.gamecore.eventbus.clients.DelegatingClient;
|
||||
import mightypork.gamecore.eventbus.event_flags.DelayedEvent;
|
||||
import mightypork.gamecore.eventbus.event_flags.DirectEvent;
|
||||
import mightypork.gamecore.eventbus.event_flags.NotLoggedEvent;
|
||||
import mightypork.gamecore.eventbus.events.Destroyable;
|
||||
import mightypork.gamecore.logging.Log;
|
||||
import mightypork.gamecore.util.Utils;
|
||||
|
||||
|
||||
/**
|
||||
* An event bus, accommodating multiple EventChannels.<br>
|
||||
* Channel will be created when an event of type is first encountered.
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
final public class EventBus implements Destroyable, BusAccess {
|
||||
|
||||
/**
|
||||
* Queued event holder
|
||||
*/
|
||||
private class DelayQueueEntry implements Delayed {
|
||||
|
||||
private final long due;
|
||||
private final BusEvent<?> evt;
|
||||
|
||||
|
||||
public DelayQueueEntry(double seconds, BusEvent<?> event)
|
||||
{
|
||||
super();
|
||||
this.due = System.currentTimeMillis() + (long) (seconds * 1000);
|
||||
this.evt = event;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(Delayed o)
|
||||
{
|
||||
return Long.valueOf(getDelay(TimeUnit.MILLISECONDS)).compareTo(o.getDelay(TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getDelay(TimeUnit unit)
|
||||
{
|
||||
return unit.convert(due - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
|
||||
public BusEvent<?> getEvent()
|
||||
{
|
||||
return evt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Thread handling queued events
|
||||
*/
|
||||
private class QueuePollingThread extends Thread {
|
||||
|
||||
public volatile boolean stopped = false;
|
||||
|
||||
|
||||
public QueuePollingThread()
|
||||
{
|
||||
super("Queue Polling Thread");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
DelayQueueEntry evt;
|
||||
|
||||
while (!stopped) {
|
||||
evt = null;
|
||||
|
||||
try {
|
||||
evt = sendQueue.take();
|
||||
} catch (final InterruptedException ignored) {
|
||||
//
|
||||
}
|
||||
|
||||
if (evt != null) {
|
||||
try {
|
||||
dispatch(evt.getEvent());
|
||||
} catch (final Throwable t) {
|
||||
Log.w(logMark + "Error while dispatching event: ", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static final String logMark = "(bus) ";
|
||||
|
||||
|
||||
private static Class<?> getEventListenerClass(BusEvent<?> event)
|
||||
{
|
||||
// BEHOLD, MAGIC!
|
||||
|
||||
final Type evtc = event.getClass().getGenericSuperclass();
|
||||
|
||||
if (evtc instanceof ParameterizedType) {
|
||||
if (((ParameterizedType) evtc).getRawType() == BusEvent.class) {
|
||||
final Type[] types = ((ParameterizedType) evtc).getActualTypeArguments();
|
||||
for (final Type genericType : types) {
|
||||
return (Class<?>) genericType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException("Could not detect event listener type.");
|
||||
}
|
||||
|
||||
/** Log detailed messages (debug) */
|
||||
public boolean detailedLogging = false;
|
||||
|
||||
/** Queue polling thread */
|
||||
private final QueuePollingThread busThread;
|
||||
|
||||
/** Registered clients */
|
||||
private final Set<Object> clients = Collections.newSetFromMap(new ConcurrentHashMap<Object,Boolean>());
|
||||
|
||||
/** Whether the bus was destroyed */
|
||||
private boolean dead = false;
|
||||
|
||||
/** Message channels */
|
||||
private final Set<EventChannel<?, ?>> channels = Collections.newSetFromMap(new ConcurrentHashMap<EventChannel<?, ?>,Boolean>());
|
||||
|
||||
/** Messages queued for delivery */
|
||||
private final DelayQueue<DelayQueueEntry> sendQueue = new DelayQueue<>();
|
||||
|
||||
|
||||
/**
|
||||
* Make a new bus and start it's queue thread.
|
||||
*/
|
||||
public EventBus()
|
||||
{
|
||||
busThread = new QueuePollingThread();
|
||||
busThread.setDaemon(true);
|
||||
busThread.start();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Halt bus thread and reject any future events.
|
||||
*/
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
assertLive();
|
||||
|
||||
busThread.stopped = true;
|
||||
dead = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send based on annotation
|
||||
*
|
||||
* @param event event
|
||||
*/
|
||||
public void send(BusEvent<?> event)
|
||||
{
|
||||
assertLive();
|
||||
|
||||
final DelayedEvent adelay = Utils.getAnnotation(event, DelayedEvent.class);
|
||||
if (adelay != null) {
|
||||
sendDelayed(event, adelay.delay());
|
||||
return;
|
||||
}
|
||||
|
||||
if (Utils.hasAnnotation(event, DirectEvent.class)) {
|
||||
sendDirect(event);
|
||||
return;
|
||||
}
|
||||
|
||||
sendQueued(event);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add event to a queue
|
||||
*
|
||||
* @param event event
|
||||
*/
|
||||
public void sendQueued(BusEvent<?> event)
|
||||
{
|
||||
assertLive();
|
||||
|
||||
sendDelayed(event, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add event to a queue, scheduled for given time.
|
||||
*
|
||||
* @param event event
|
||||
* @param delay delay before event is dispatched
|
||||
*/
|
||||
public void sendDelayed(BusEvent<?> event, double delay)
|
||||
{
|
||||
assertLive();
|
||||
|
||||
final DelayQueueEntry dm = new DelayQueueEntry(delay, event);
|
||||
|
||||
if (shallLog(event)) {
|
||||
Log.f3(logMark + "Qu [" + Log.str(event) + "]" + (delay == 0 ? "" : (", delay: " + delay + "s")));
|
||||
}
|
||||
|
||||
sendQueue.add(dm);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send immediately.<br>
|
||||
* Should be used for real-time events that require immediate response, such
|
||||
* as timing events.
|
||||
*
|
||||
* @param event event
|
||||
*/
|
||||
public void sendDirect(BusEvent<?> event)
|
||||
{
|
||||
assertLive();
|
||||
|
||||
if (shallLog(event)) Log.f3(logMark + "Di [" + Log.str(event) + "]");
|
||||
|
||||
dispatch(event);
|
||||
}
|
||||
|
||||
|
||||
public void sendDirectToChildren(DelegatingClient delegatingClient, BusEvent<?> event)
|
||||
{
|
||||
assertLive();
|
||||
|
||||
if (shallLog(event)) Log.f3(logMark + "Di->sub [" + Log.str(event) + "]");
|
||||
|
||||
doDispatch(delegatingClient.getChildClients(), event);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Connect a client to the bus. The client will be connected to all current
|
||||
* and future channels, until removed from the bus.
|
||||
*
|
||||
* @param client the client
|
||||
*/
|
||||
public void subscribe(Object client)
|
||||
{
|
||||
assertLive();
|
||||
|
||||
if (client == null) return;
|
||||
|
||||
clients.add(client);
|
||||
|
||||
if (detailedLogging) Log.f3(logMark + "Client joined: " + Log.str(client));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Disconnect a client from the bus.
|
||||
*
|
||||
* @param client the client
|
||||
*/
|
||||
public void unsubscribe(Object client)
|
||||
{
|
||||
assertLive();
|
||||
|
||||
clients.remove(client);
|
||||
|
||||
if (detailedLogging) Log.f3(logMark + "Client left: " + Log.str(client));
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private boolean addChannelForEvent(BusEvent<?> event)
|
||||
{
|
||||
try {
|
||||
if (detailedLogging) {
|
||||
Log.f3(logMark + "Setting up channel for new event type: " + Log.str(event.getClass()));
|
||||
}
|
||||
|
||||
final Class<?> listener = getEventListenerClass(event);
|
||||
final EventChannel<?, ?> ch = EventChannel.create(event.getClass(), listener);
|
||||
|
||||
if (ch.canBroadcast(event)) {
|
||||
|
||||
channels.add(ch);
|
||||
//channels.flush();
|
||||
|
||||
if (detailedLogging) {
|
||||
Log.f3(logMark + "Created new channel: " + Log.str(event.getClass()) + " -> " + Log.str(listener));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
Log.w(logMark + "Could not create channel for event " + Log.str(event.getClass()));
|
||||
}
|
||||
|
||||
} catch (final Throwable t) {
|
||||
Log.w(logMark + "Error while trying to add channel for event.", t);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make sure the bus is not destroyed.
|
||||
*
|
||||
* @throws IllegalStateException if the bus is dead.
|
||||
*/
|
||||
private void assertLive() throws IllegalStateException
|
||||
{
|
||||
if (dead) throw new IllegalStateException("EventBus is dead.");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send immediately.<br>
|
||||
* Should be used for real-time events that require immediate response, such
|
||||
* as timing events.
|
||||
*
|
||||
* @param event event
|
||||
*/
|
||||
private synchronized void dispatch(BusEvent<?> event)
|
||||
{
|
||||
assertLive();
|
||||
|
||||
doDispatch(clients, event);
|
||||
event.onDispatchComplete(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send to a set of clients
|
||||
*
|
||||
* @param clients clients
|
||||
* @param event event
|
||||
*/
|
||||
private synchronized void doDispatch(Collection<?> clients, BusEvent<?> event)
|
||||
{
|
||||
boolean accepted = false;
|
||||
|
||||
event.clearFlags();
|
||||
|
||||
for (int i = 0; i < 2; i++) { // two tries.
|
||||
|
||||
for (final EventChannel<?, ?> b : channels) {
|
||||
if (b.canBroadcast(event)) {
|
||||
accepted = true;
|
||||
b.broadcast(event, clients);
|
||||
}
|
||||
|
||||
if (event.isConsumed()) break;
|
||||
}
|
||||
|
||||
if (!accepted) if (addChannelForEvent(event)) continue;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (!accepted) Log.e(logMark + "Not accepted by any channel: " + Log.str(event));
|
||||
if (!event.wasServed() && shallLog(event)) Log.w(logMark + "Not delivered: " + Log.str(event));
|
||||
}
|
||||
|
||||
|
||||
private boolean shallLog(BusEvent<?> event)
|
||||
{
|
||||
if (!detailedLogging) return false;
|
||||
if (Utils.hasAnnotation(event, NotLoggedEvent.class)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EventBus getEventBus()
|
||||
{
|
||||
return this; // just for compatibility use-case
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,207 +0,0 @@
|
||||
package mightypork.gamecore.eventbus;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
import mightypork.gamecore.eventbus.clients.DelegatingClient;
|
||||
import mightypork.gamecore.eventbus.clients.ToggleableClient;
|
||||
import mightypork.gamecore.eventbus.event_flags.NonRejectableEvent;
|
||||
import mightypork.gamecore.logging.Log;
|
||||
import mightypork.gamecore.util.Utils;
|
||||
|
||||
|
||||
/**
|
||||
* Event delivery channel, module of {@link EventBus}
|
||||
*
|
||||
* @author MightyPork
|
||||
* @param <EVENT> event type
|
||||
* @param <CLIENT> client (subscriber) type
|
||||
*/
|
||||
class EventChannel<EVENT extends BusEvent<CLIENT>, CLIENT> {
|
||||
|
||||
private final Class<CLIENT> clientClass;
|
||||
private final Class<EVENT> eventClass;
|
||||
|
||||
|
||||
/**
|
||||
* Create a channel
|
||||
*
|
||||
* @param eventClass event class
|
||||
* @param clientClass client class
|
||||
*/
|
||||
public EventChannel(Class<EVENT> eventClass, Class<CLIENT> clientClass)
|
||||
{
|
||||
|
||||
if (eventClass == null || clientClass == null) {
|
||||
throw new NullPointerException("Null Event or Client class.");
|
||||
}
|
||||
|
||||
this.clientClass = clientClass;
|
||||
this.eventClass = eventClass;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Try to broadcast a event.<br>
|
||||
* If event is of wrong type, <code>false</code> is returned.
|
||||
*
|
||||
* @param event a event to be sent
|
||||
* @param clients collection of clients
|
||||
*/
|
||||
public void broadcast(BusEvent<?> event, Collection<?> clients)
|
||||
{
|
||||
if (!canBroadcast(event)) return;
|
||||
|
||||
doBroadcast(eventClass.cast(event), clients, new HashSet<>());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send the event
|
||||
*
|
||||
* @param event sent event
|
||||
* @param clients subscribing clients
|
||||
* @param processed clients already processed
|
||||
*/
|
||||
private void doBroadcast(final EVENT event, final Collection<?> clients, final Collection<Object> processed)
|
||||
{
|
||||
for (final Object client : clients) {
|
||||
|
||||
// exclude obvious non-clients
|
||||
if (!isClientValid(client)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// avoid executing more times
|
||||
if (processed.contains(client)) {
|
||||
Log.w(EventBus.logMark + "Client already served: " + Log.str(client));
|
||||
continue;
|
||||
}
|
||||
processed.add(client);
|
||||
|
||||
final boolean must_deliver = Utils.hasAnnotation(event, NonRejectableEvent.class);
|
||||
|
||||
// opt-out
|
||||
if (client instanceof ToggleableClient) {
|
||||
if (!must_deliver && !((ToggleableClient) client).isListening()) continue;
|
||||
}
|
||||
|
||||
sendTo(client, event);
|
||||
|
||||
if (event.isConsumed()) return;
|
||||
|
||||
// pass on to delegated clients
|
||||
if (client instanceof DelegatingClient) {
|
||||
if (must_deliver || ((DelegatingClient) client).doesDelegate()) {
|
||||
|
||||
final Collection<?> children = ((DelegatingClient) client).getChildClients();
|
||||
|
||||
if (children != null && children.size() > 0) {
|
||||
doBroadcast(event, children, processed);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send an event to a client.
|
||||
*
|
||||
* @param client target client
|
||||
* @param event event to send
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void sendTo(Object client, EVENT event)
|
||||
{
|
||||
if (isClientOfChannelType(client)) {
|
||||
((BusEvent<CLIENT>) event).deliverTo((CLIENT) client);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the given event can be broadcasted by this channel
|
||||
*
|
||||
* @param event event object
|
||||
* @return can be broadcasted
|
||||
*/
|
||||
public boolean canBroadcast(BusEvent<?> event)
|
||||
{
|
||||
return event != null && eventClass.isInstance(event);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an instance for given types
|
||||
*
|
||||
* @param eventClass event class
|
||||
* @param clientClass client class
|
||||
* @return the broadcaster
|
||||
*/
|
||||
public static <F_EVENT extends BusEvent<F_CLIENT>, F_CLIENT> EventChannel<F_EVENT, F_CLIENT> create(Class<F_EVENT> eventClass, Class<F_CLIENT> clientClass)
|
||||
{
|
||||
return new EventChannel<>(eventClass, clientClass);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if client is of channel type
|
||||
*
|
||||
* @param client client
|
||||
* @return is of type
|
||||
*/
|
||||
private boolean isClientOfChannelType(Object client)
|
||||
{
|
||||
return clientClass.isInstance(client);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the channel is compatible with given
|
||||
*
|
||||
* @param client client
|
||||
* @return is supported
|
||||
*/
|
||||
public boolean isClientValid(Object client)
|
||||
{
|
||||
return isClientOfChannelType(client) || (client instanceof DelegatingClient);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 13;
|
||||
int result = 1;
|
||||
result = prime * result + ((clientClass == null) ? 0 : clientClass.hashCode());
|
||||
result = prime * result + ((eventClass == null) ? 0 : eventClass.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj) return true;
|
||||
if (obj == null) return false;
|
||||
if (!(obj instanceof EventChannel)) return false;
|
||||
final EventChannel<?, ?> other = (EventChannel<?, ?>) obj;
|
||||
if (clientClass == null) {
|
||||
if (other.clientClass != null) return false;
|
||||
} else if (!clientClass.equals(other.clientClass)) return false;
|
||||
if (eventClass == null) {
|
||||
if (other.eventClass != null) return false;
|
||||
} else if (!eventClass.equals(other.eventClass)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "{ " + Log.str(eventClass) + " => " + Log.str(clientClass) + " }";
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
package mightypork.gamecore.eventbus.clients;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import mightypork.gamecore.eventbus.BusAccess;
|
||||
import mightypork.gamecore.eventbus.EventBus;
|
||||
|
||||
|
||||
/**
|
||||
* Client that can be attached to the {@link EventBus}, or added as a child
|
||||
* client to another {@link DelegatingClient}
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public abstract class BusNode implements BusAccess, ClientHub {
|
||||
|
||||
private final BusAccess busAccess;
|
||||
|
||||
private final Set<Object> clients = new LinkedHashSet<>();
|
||||
private boolean listening = true;
|
||||
private boolean delegating = true;
|
||||
|
||||
|
||||
/**
|
||||
* @param busAccess access to bus
|
||||
*/
|
||||
public BusNode(BusAccess busAccess)
|
||||
{
|
||||
this.busAccess = busAccess;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<Object> getChildClients()
|
||||
{
|
||||
return clients;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean doesDelegate()
|
||||
{
|
||||
return delegating;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isListening()
|
||||
{
|
||||
return listening;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a child subscriber to the {@link EventBus}.<br>
|
||||
*
|
||||
* @param client
|
||||
*/
|
||||
@Override
|
||||
public void addChildClient(Object client)
|
||||
{
|
||||
if (client instanceof RootBusNode) {
|
||||
throw new IllegalArgumentException("Cannot nest RootBusNode.");
|
||||
}
|
||||
|
||||
clients.add(client);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove a child subscriber
|
||||
*
|
||||
* @param client subscriber to remove
|
||||
*/
|
||||
@Override
|
||||
public void removeChildClient(Object client)
|
||||
{
|
||||
if (client != null) {
|
||||
clients.remove(client);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set whether events should be received.
|
||||
*
|
||||
* @param listening receive events
|
||||
*/
|
||||
public void setListening(boolean listening)
|
||||
{
|
||||
this.listening = listening;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set whether events should be passed on to child nodes
|
||||
*
|
||||
* @param delegating
|
||||
*/
|
||||
public void setDelegating(boolean delegating)
|
||||
{
|
||||
this.delegating = delegating;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EventBus getEventBus()
|
||||
{
|
||||
return busAccess.getEventBus();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package mightypork.gamecore.eventbus.clients;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import mightypork.gamecore.eventbus.EventBus;
|
||||
|
||||
|
||||
/**
|
||||
* Common methods for client hubs (ie delegating vlient implementations)
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public interface ClientHub extends DelegatingClient, ToggleableClient {
|
||||
|
||||
@Override
|
||||
public boolean doesDelegate();
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<Object> getChildClients();
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isListening();
|
||||
|
||||
|
||||
/**
|
||||
* Add a child subscriber to the {@link EventBus}.<br>
|
||||
*
|
||||
* @param client
|
||||
*/
|
||||
public void addChildClient(Object client);
|
||||
|
||||
|
||||
/**
|
||||
* Remove a child subscriber
|
||||
*
|
||||
* @param client subscriber to remove
|
||||
*/
|
||||
void removeChildClient(Object client);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package mightypork.gamecore.eventbus.clients;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
/**
|
||||
* Array-list with varargs constructor
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public class ClientList extends ArrayList<Object> {
|
||||
|
||||
public ClientList(Object... clients)
|
||||
{
|
||||
for (final Object c : clients) {
|
||||
super.add(c);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package mightypork.gamecore.eventbus.clients;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
/**
|
||||
* Client containing child clients. According to the contract, if the collection
|
||||
* of clients is ordered, the clients will be served in that order. In any case,
|
||||
* the {@link DelegatingClient} itself will be served beforehand.
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public interface DelegatingClient {
|
||||
|
||||
/**
|
||||
* @return collection of child clients. Can not be null.
|
||||
*/
|
||||
public Collection<?> getChildClients();
|
||||
|
||||
|
||||
/**
|
||||
* @return true if delegating is active
|
||||
*/
|
||||
public boolean doesDelegate();
|
||||
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package mightypork.gamecore.eventbus.clients;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import mightypork.gamecore.gui.Enableable;
|
||||
|
||||
|
||||
/**
|
||||
* Basic delegating client
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public class DelegatingList extends ClientList implements DelegatingClient, Enableable {
|
||||
|
||||
private boolean enabled = true;
|
||||
|
||||
|
||||
public DelegatingList(Object... clients)
|
||||
{
|
||||
super(clients);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<?> getChildClients()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean doesDelegate()
|
||||
{
|
||||
return isEnabled();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean yes)
|
||||
{
|
||||
enabled = yes;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package mightypork.gamecore.eventbus.clients;
|
||||
|
||||
|
||||
import mightypork.gamecore.eventbus.BusAccess;
|
||||
import mightypork.gamecore.eventbus.events.Destroyable;
|
||||
import mightypork.gamecore.util.annot.DefaultImpl;
|
||||
|
||||
|
||||
/**
|
||||
* Bus node that should be directly attached to the bus.
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public abstract class RootBusNode extends BusNode implements Destroyable {
|
||||
|
||||
/**
|
||||
* @param busAccess access to bus
|
||||
*/
|
||||
public RootBusNode(BusAccess busAccess)
|
||||
{
|
||||
super(busAccess);
|
||||
|
||||
getEventBus().subscribe(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final void destroy()
|
||||
{
|
||||
deinit();
|
||||
|
||||
getEventBus().unsubscribe(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deinitialize the subsystem<br>
|
||||
* (called during destruction)
|
||||
*/
|
||||
@DefaultImpl
|
||||
protected void deinit()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package mightypork.gamecore.eventbus.clients;
|
||||
|
||||
|
||||
/**
|
||||
* Client that can toggle receiving messages.
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public interface ToggleableClient {
|
||||
|
||||
/**
|
||||
* @return true if the client wants to receive messages
|
||||
*/
|
||||
public boolean isListening();
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package mightypork.gamecore.eventbus.event_flags;
|
||||
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* Event that should be queued with given delay (default: 0);
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@Inherited
|
||||
@Documented
|
||||
public @interface DelayedEvent {
|
||||
|
||||
/**
|
||||
* @return event dispatch delay [seconds]
|
||||
*/
|
||||
double delay() default 0;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package mightypork.gamecore.eventbus.event_flags;
|
||||
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* Event that should not be queued.
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@Inherited
|
||||
@Documented
|
||||
public @interface DirectEvent {}
|
||||
@@ -1,21 +0,0 @@
|
||||
package mightypork.gamecore.eventbus.event_flags;
|
||||
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
/**
|
||||
* Event that cannot be consumed
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface NonConsumableEvent {
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package mightypork.gamecore.eventbus.event_flags;
|
||||
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
/**
|
||||
* Event that is forcibly delivered to all clients (bypass Toggleable etc)
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface NonRejectableEvent {
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package mightypork.gamecore.eventbus.event_flags;
|
||||
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* Event that's not worth logging, unless there was an error with it.<br>
|
||||
* Useful for common events that would otherwise clutter the log.
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@Inherited
|
||||
@Documented
|
||||
public @interface NotLoggedEvent {}
|
||||
@@ -1,16 +0,0 @@
|
||||
package mightypork.gamecore.eventbus.event_flags;
|
||||
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* Handled only by the first client, then discarded.
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@Inherited
|
||||
@Documented
|
||||
public @interface SingleReceiverEvent {}
|
||||
@@ -1,24 +0,0 @@
|
||||
package mightypork.gamecore.eventbus.events;
|
||||
|
||||
|
||||
import mightypork.gamecore.eventbus.BusEvent;
|
||||
import mightypork.gamecore.eventbus.event_flags.DirectEvent;
|
||||
import mightypork.gamecore.eventbus.event_flags.NonConsumableEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Invoke destroy() method of all subscribers. Used to deinit a system.
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
@DirectEvent
|
||||
@NonConsumableEvent
|
||||
public class DestroyEvent extends BusEvent<Destroyable> {
|
||||
|
||||
@Override
|
||||
public void handleBy(Destroyable handler)
|
||||
{
|
||||
handler.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package mightypork.gamecore.eventbus.events;
|
||||
|
||||
|
||||
/**
|
||||
* Object that can be destroyed (free resources etc)
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public interface Destroyable {
|
||||
|
||||
/**
|
||||
* Destroy this object
|
||||
*/
|
||||
public void destroy();
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package mightypork.gamecore.eventbus.events;
|
||||
|
||||
|
||||
import mightypork.gamecore.eventbus.BusEvent;
|
||||
import mightypork.gamecore.eventbus.event_flags.DirectEvent;
|
||||
import mightypork.gamecore.eventbus.event_flags.NonConsumableEvent;
|
||||
import mightypork.gamecore.eventbus.event_flags.NotLoggedEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Delta timing update event. Not logged.
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
@NotLoggedEvent
|
||||
@DirectEvent
|
||||
@NonConsumableEvent
|
||||
public class UpdateEvent extends BusEvent<Updateable> {
|
||||
|
||||
private final double deltaTime;
|
||||
|
||||
|
||||
/**
|
||||
* @param deltaTime time since last update (sec)
|
||||
*/
|
||||
public UpdateEvent(double deltaTime)
|
||||
{
|
||||
this.deltaTime = deltaTime;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void handleBy(Updateable handler)
|
||||
{
|
||||
handler.update(deltaTime);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package mightypork.gamecore.eventbus.events;
|
||||
|
||||
|
||||
/**
|
||||
* Uses delta timing
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public interface Updateable {
|
||||
|
||||
/**
|
||||
* Update item state based on elapsed time
|
||||
*
|
||||
* @param delta time elapsed since last update, in seconds
|
||||
*/
|
||||
public void update(double delta);
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
package mightypork.gamecore.gui;
|
||||
|
||||
|
||||
import mightypork.utils.interfaces.Enableable;
|
||||
|
||||
|
||||
/**
|
||||
* Triggered action
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public abstract class Action implements Runnable, Enableable {
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ package mightypork.gamecore.gui;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import mightypork.utils.interfaces.Enableable;
|
||||
|
||||
|
||||
public class ActionGroup implements Enableable {
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ package mightypork.gamecore.gui;
|
||||
/**
|
||||
* Element that can be assigned an action (ie. button);
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public interface ActionTrigger {
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ package mightypork.gamecore.gui;
|
||||
/**
|
||||
* Horizontal align sides
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public enum AlignX
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ package mightypork.gamecore.gui;
|
||||
/**
|
||||
* Vertical align sides
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public enum AlignY
|
||||
{
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package mightypork.gamecore.gui;
|
||||
|
||||
|
||||
/**
|
||||
* Can be enabled or disabled.<br>
|
||||
* Implementations should take appropriate action (ie. stop listening to events,
|
||||
* updating etc.)
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public interface Enableable {
|
||||
|
||||
/**
|
||||
* Change enabled state
|
||||
*
|
||||
* @param yes enabled
|
||||
*/
|
||||
public void setEnabled(boolean yes);
|
||||
|
||||
|
||||
/**
|
||||
* @return true if enabled
|
||||
*/
|
||||
public boolean isEnabled();
|
||||
}
|
||||
@@ -4,7 +4,7 @@ package mightypork.gamecore.gui;
|
||||
/**
|
||||
* Element that can be hidden or visible
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public interface Hideable {
|
||||
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
package mightypork.gamecore.gui.components;
|
||||
|
||||
|
||||
import mightypork.gamecore.gui.Enableable;
|
||||
import mightypork.gamecore.gui.events.LayoutChangeEvent;
|
||||
import mightypork.gamecore.gui.events.LayoutChangeListener;
|
||||
import mightypork.gamecore.input.InputSystem;
|
||||
import mightypork.gamecore.logging.Log;
|
||||
import mightypork.gamecore.render.Renderable;
|
||||
import mightypork.gamecore.util.annot.DefaultImpl;
|
||||
import mightypork.gamecore.util.math.color.Color;
|
||||
import mightypork.gamecore.util.math.constraints.num.Num;
|
||||
import mightypork.gamecore.util.math.constraints.rect.Rect;
|
||||
import mightypork.gamecore.util.math.constraints.rect.caching.AbstractRectCache;
|
||||
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
|
||||
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBoundAdapter;
|
||||
import mightypork.utils.Support;
|
||||
import mightypork.utils.annotations.DefaultImpl;
|
||||
import mightypork.utils.interfaces.Enableable;
|
||||
import mightypork.utils.logging.Log;
|
||||
import mightypork.utils.math.color.Color;
|
||||
import mightypork.utils.math.constraints.num.Num;
|
||||
import mightypork.utils.math.constraints.rect.Rect;
|
||||
import mightypork.utils.math.constraints.rect.RectBound;
|
||||
import mightypork.utils.math.constraints.rect.caching.AbstractRectCache;
|
||||
import mightypork.utils.math.constraints.rect.proxy.RectProxy;
|
||||
|
||||
|
||||
/**
|
||||
* {@link Renderable} with pluggable context. When caching is enabled, the
|
||||
* layout update can be triggered by firing the {@link LayoutChangeEvent}.
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public abstract class BaseComponent extends AbstractRectCache implements Component, LayoutChangeListener, Enableable {
|
||||
|
||||
@@ -41,7 +42,7 @@ public abstract class BaseComponent extends AbstractRectCache implements Compone
|
||||
@Override
|
||||
public void setRect(RectBound rect)
|
||||
{
|
||||
this.source = new RectBoundAdapter(rect);
|
||||
this.source = new RectProxy(rect);
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +84,7 @@ public abstract class BaseComponent extends AbstractRectCache implements Compone
|
||||
try {
|
||||
poll();
|
||||
} catch (final NullPointerException e) {
|
||||
Log.e("Component is missing a bounding rect, at: " + Log.str(getClass()));
|
||||
Log.e("Component is missing a bounding rect, at: " + Support.str(getClass()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package mightypork.gamecore.gui.components;
|
||||
|
||||
|
||||
import mightypork.gamecore.gui.Enableable;
|
||||
import mightypork.gamecore.gui.Hideable;
|
||||
import mightypork.gamecore.util.math.constraints.num.Num;
|
||||
import mightypork.utils.interfaces.Enableable;
|
||||
import mightypork.utils.math.constraints.num.Num;
|
||||
|
||||
|
||||
/**
|
||||
* Basic UI component interface
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public interface Component extends Enableable, Hideable, PluggableRenderable {
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package mightypork.gamecore.gui.components;
|
||||
|
||||
|
||||
import mightypork.gamecore.eventbus.clients.ToggleableClient;
|
||||
import mightypork.gamecore.gui.Enableable;
|
||||
import mightypork.utils.eventbus.clients.ToggleableClient;
|
||||
import mightypork.utils.interfaces.Enableable;
|
||||
|
||||
|
||||
public abstract class InputComponent extends BaseComponent implements Enableable, ToggleableClient {
|
||||
|
||||
@@ -6,12 +6,12 @@ import java.util.LinkedList;
|
||||
|
||||
import mightypork.gamecore.core.modules.AppAccess;
|
||||
import mightypork.gamecore.core.modules.AppSubModule;
|
||||
import mightypork.gamecore.eventbus.EventBus;
|
||||
import mightypork.gamecore.eventbus.clients.ClientHub;
|
||||
import mightypork.gamecore.input.InputSystem;
|
||||
import mightypork.gamecore.render.DisplaySystem;
|
||||
import mightypork.gamecore.resources.audio.SoundSystem;
|
||||
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
|
||||
import mightypork.utils.eventbus.EventBus;
|
||||
import mightypork.utils.eventbus.clients.ClientHub;
|
||||
import mightypork.utils.math.constraints.rect.RectBound;
|
||||
|
||||
|
||||
public abstract class LayoutComponent extends BaseComponent implements ClientHub, AppAccess {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package mightypork.gamecore.gui.components;
|
||||
|
||||
|
||||
import mightypork.gamecore.util.math.constraints.num.Num;
|
||||
import mightypork.gamecore.util.math.constraints.rect.Rect;
|
||||
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
|
||||
import mightypork.gamecore.util.math.constraints.vect.Vect;
|
||||
import mightypork.gamecore.util.math.constraints.vect.proxy.VectAdapter;
|
||||
import mightypork.utils.math.constraints.num.Num;
|
||||
import mightypork.utils.math.constraints.rect.Rect;
|
||||
import mightypork.utils.math.constraints.rect.RectBound;
|
||||
import mightypork.utils.math.constraints.vect.Vect;
|
||||
import mightypork.utils.math.constraints.vect.proxy.VectAdapter;
|
||||
|
||||
|
||||
public abstract class LinearComponent extends BaseComponent implements DynamicWidthComponent {
|
||||
|
||||
@@ -2,15 +2,15 @@ package mightypork.gamecore.gui.components;
|
||||
|
||||
|
||||
import mightypork.gamecore.render.Renderable;
|
||||
import mightypork.gamecore.util.math.constraints.rect.Rect;
|
||||
import mightypork.gamecore.util.math.constraints.rect.proxy.PluggableRectBound;
|
||||
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
|
||||
import mightypork.utils.math.constraints.rect.PluggableRectBound;
|
||||
import mightypork.utils.math.constraints.rect.Rect;
|
||||
import mightypork.utils.math.constraints.rect.RectBound;
|
||||
|
||||
|
||||
/**
|
||||
* Renderable that can be assigned different context
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public interface PluggableRenderable extends Renderable, PluggableRectBound {
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ package mightypork.gamecore.gui.components.input;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import mightypork.gamecore.eventbus.clients.ClientList;
|
||||
import mightypork.gamecore.eventbus.clients.DelegatingClient;
|
||||
import mightypork.gamecore.gui.components.Component;
|
||||
import mightypork.utils.eventbus.clients.ClientList;
|
||||
import mightypork.utils.eventbus.clients.DelegatingClient;
|
||||
|
||||
|
||||
public class ClickableWrapper extends ClickableComponent implements DelegatingClient {
|
||||
|
||||
@@ -6,16 +6,16 @@ import mightypork.gamecore.gui.components.DynamicWidthComponent;
|
||||
import mightypork.gamecore.gui.components.painters.TextPainter;
|
||||
import mightypork.gamecore.input.InputSystem;
|
||||
import mightypork.gamecore.resources.fonts.GLFont;
|
||||
import mightypork.gamecore.util.math.color.Color;
|
||||
import mightypork.gamecore.util.math.color.pal.RGB;
|
||||
import mightypork.gamecore.util.math.constraints.vect.Vect;
|
||||
import mightypork.gamecore.util.math.constraints.vect.mutable.VectVar;
|
||||
import mightypork.utils.math.color.Color;
|
||||
import mightypork.utils.math.color.pal.RGB;
|
||||
import mightypork.utils.math.constraints.vect.Vect;
|
||||
import mightypork.utils.math.constraints.vect.var.VectVar;
|
||||
|
||||
|
||||
/**
|
||||
* Menu-like button with shadow and push state
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class TextButton extends ClickableComponent implements DynamicWidthComponent {
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package mightypork.gamecore.gui.components.layout;
|
||||
|
||||
import mightypork.gamecore.core.modules.AppAccess;
|
||||
import mightypork.gamecore.gui.components.Component;
|
||||
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
|
||||
import mightypork.utils.math.constraints.rect.RectBound;
|
||||
|
||||
|
||||
public class ColumnLayout extends GridLayout {
|
||||
|
||||
@@ -4,13 +4,13 @@ package mightypork.gamecore.gui.components.layout;
|
||||
import mightypork.gamecore.core.modules.AppAccess;
|
||||
import mightypork.gamecore.gui.components.Component;
|
||||
import mightypork.gamecore.gui.components.LayoutComponent;
|
||||
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
|
||||
import mightypork.utils.math.constraints.rect.RectBound;
|
||||
|
||||
|
||||
/**
|
||||
* Layout for components with arbitrary constraints.
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class ConstraintLayout extends LayoutComponent {
|
||||
|
||||
|
||||
@@ -5,15 +5,15 @@ import mightypork.gamecore.core.modules.AppAccess;
|
||||
import mightypork.gamecore.gui.AlignX;
|
||||
import mightypork.gamecore.gui.components.Component;
|
||||
import mightypork.gamecore.gui.components.LayoutComponent;
|
||||
import mightypork.gamecore.util.math.constraints.num.Num;
|
||||
import mightypork.gamecore.util.math.constraints.rect.Rect;
|
||||
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
|
||||
import mightypork.utils.math.constraints.num.Num;
|
||||
import mightypork.utils.math.constraints.rect.Rect;
|
||||
import mightypork.utils.math.constraints.rect.RectBound;
|
||||
|
||||
|
||||
/**
|
||||
* Holder with same-sized columns, aligned to left or right
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class FlowColumnLayout extends LayoutComponent {
|
||||
|
||||
|
||||
@@ -5,15 +5,15 @@ import mightypork.gamecore.core.modules.AppAccess;
|
||||
import mightypork.gamecore.gui.AlignY;
|
||||
import mightypork.gamecore.gui.components.Component;
|
||||
import mightypork.gamecore.gui.components.LayoutComponent;
|
||||
import mightypork.gamecore.util.math.constraints.num.Num;
|
||||
import mightypork.gamecore.util.math.constraints.rect.Rect;
|
||||
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
|
||||
import mightypork.utils.math.constraints.num.Num;
|
||||
import mightypork.utils.math.constraints.rect.Rect;
|
||||
import mightypork.utils.math.constraints.rect.RectBound;
|
||||
|
||||
|
||||
/**
|
||||
* Holder with same-sized rows, aligned to top or bottom
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class FlowRowLayout extends LayoutComponent {
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@ package mightypork.gamecore.gui.components.layout;
|
||||
import mightypork.gamecore.core.modules.AppAccess;
|
||||
import mightypork.gamecore.gui.components.Component;
|
||||
import mightypork.gamecore.gui.components.LayoutComponent;
|
||||
import mightypork.gamecore.util.math.constraints.rect.builders.TiledRect;
|
||||
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
|
||||
import mightypork.utils.math.constraints.rect.RectBound;
|
||||
import mightypork.utils.math.constraints.rect.builders.TiledRect;
|
||||
|
||||
|
||||
/**
|
||||
* Holder with table cells
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class GridLayout extends LayoutComponent {
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import mightypork.gamecore.gui.components.BaseComponent;
|
||||
/**
|
||||
* Invisible component that does nothing at all; Null object pattern
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class NullComponent extends BaseComponent {
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package mightypork.gamecore.gui.components.layout;
|
||||
|
||||
import mightypork.gamecore.core.modules.AppAccess;
|
||||
import mightypork.gamecore.gui.components.Component;
|
||||
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
|
||||
import mightypork.utils.math.constraints.rect.RectBound;
|
||||
|
||||
|
||||
public class RowLayout extends GridLayout {
|
||||
|
||||
@@ -3,16 +3,16 @@ package mightypork.gamecore.gui.components.layout.linear;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import mightypork.gamecore.eventbus.clients.ClientList;
|
||||
import mightypork.gamecore.eventbus.clients.DelegatingClient;
|
||||
import mightypork.gamecore.gui.components.Component;
|
||||
import mightypork.gamecore.gui.components.LinearComponent;
|
||||
import mightypork.utils.eventbus.clients.ClientList;
|
||||
import mightypork.utils.eventbus.clients.DelegatingClient;
|
||||
|
||||
|
||||
/**
|
||||
* Converts a component into a linear component
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public abstract class AbstractLinearWrapper extends LinearComponent implements DelegatingClient {
|
||||
|
||||
|
||||
@@ -2,13 +2,13 @@ package mightypork.gamecore.gui.components.layout.linear;
|
||||
|
||||
|
||||
import mightypork.gamecore.gui.components.layout.NullComponent;
|
||||
import mightypork.gamecore.util.math.constraints.num.Num;
|
||||
import mightypork.utils.math.constraints.num.Num;
|
||||
|
||||
|
||||
/**
|
||||
* Gap in linear layout
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class LinearGap extends LinearRectangle {
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@ import mightypork.gamecore.gui.AlignX;
|
||||
import mightypork.gamecore.gui.components.DynamicWidthComponent;
|
||||
import mightypork.gamecore.gui.components.LayoutComponent;
|
||||
import mightypork.gamecore.gui.components.LinearComponent;
|
||||
import mightypork.gamecore.util.math.constraints.num.Num;
|
||||
import mightypork.gamecore.util.math.constraints.num.NumSum;
|
||||
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
|
||||
import mightypork.gamecore.util.math.constraints.vect.Vect;
|
||||
import mightypork.gamecore.util.math.constraints.vect.proxy.VectAdapter;
|
||||
import mightypork.utils.math.constraints.num.Num;
|
||||
import mightypork.utils.math.constraints.num.batch.NumSum;
|
||||
import mightypork.utils.math.constraints.rect.RectBound;
|
||||
import mightypork.utils.math.constraints.vect.Vect;
|
||||
import mightypork.utils.math.constraints.vect.proxy.VectAdapter;
|
||||
|
||||
|
||||
public class LinearLayout extends LayoutComponent {
|
||||
|
||||
@@ -2,7 +2,7 @@ package mightypork.gamecore.gui.components.layout.linear;
|
||||
|
||||
|
||||
import mightypork.gamecore.gui.components.Component;
|
||||
import mightypork.gamecore.util.math.constraints.num.Num;
|
||||
import mightypork.utils.math.constraints.num.Num;
|
||||
|
||||
|
||||
public class LinearRectangle extends AbstractLinearWrapper {
|
||||
|
||||
@@ -10,7 +10,7 @@ import mightypork.gamecore.resources.textures.TxQuad;
|
||||
/**
|
||||
* Draws image in given rect
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class ImagePainter extends BaseComponent implements DynamicWidthComponent {
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@ package mightypork.gamecore.gui.components.painters;
|
||||
|
||||
import mightypork.gamecore.gui.components.BaseComponent;
|
||||
import mightypork.gamecore.render.Render;
|
||||
import mightypork.gamecore.util.annot.FactoryMethod;
|
||||
import mightypork.gamecore.util.math.color.Color;
|
||||
import mightypork.utils.annotations.FactoryMethod;
|
||||
import mightypork.utils.math.color.Color;
|
||||
|
||||
|
||||
/**
|
||||
* Draws image in given rect
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class QuadPainter extends BaseComponent {
|
||||
|
||||
|
||||
@@ -7,19 +7,19 @@ import mightypork.gamecore.gui.components.DynamicWidthComponent;
|
||||
import mightypork.gamecore.render.Render;
|
||||
import mightypork.gamecore.resources.fonts.FontRenderer;
|
||||
import mightypork.gamecore.resources.fonts.GLFont;
|
||||
import mightypork.gamecore.util.math.color.Color;
|
||||
import mightypork.gamecore.util.math.color.pal.RGB;
|
||||
import mightypork.gamecore.util.math.constraints.num.Num;
|
||||
import mightypork.gamecore.util.math.constraints.rect.Rect;
|
||||
import mightypork.gamecore.util.math.constraints.vect.Vect;
|
||||
import mightypork.gamecore.util.strings.StringProvider;
|
||||
import mightypork.gamecore.util.strings.StringWrapper;
|
||||
import mightypork.utils.math.color.Color;
|
||||
import mightypork.utils.math.color.pal.RGB;
|
||||
import mightypork.utils.math.constraints.num.Num;
|
||||
import mightypork.utils.math.constraints.rect.Rect;
|
||||
import mightypork.utils.math.constraints.vect.Vect;
|
||||
import mightypork.utils.string.StringProvider;
|
||||
import mightypork.utils.string.StringWrapper;
|
||||
|
||||
|
||||
/**
|
||||
* Text painting component.
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class TextPainter extends BaseComponent implements DynamicWidthComponent {
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package mightypork.gamecore.gui.events;
|
||||
|
||||
|
||||
import mightypork.gamecore.eventbus.BusEvent;
|
||||
import mightypork.gamecore.eventbus.event_flags.DirectEvent;
|
||||
import mightypork.gamecore.eventbus.event_flags.NonConsumableEvent;
|
||||
import mightypork.gamecore.eventbus.event_flags.NonRejectableEvent;
|
||||
import mightypork.utils.eventbus.BusEvent;
|
||||
import mightypork.utils.eventbus.events.flags.DirectEvent;
|
||||
import mightypork.utils.eventbus.events.flags.NonConsumableEvent;
|
||||
import mightypork.utils.eventbus.events.flags.NonRejectableEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Intended use is to notify UI component sub-clients that they should poll
|
||||
* their cached constraints.
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
@DirectEvent
|
||||
@NonConsumableEvent
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package mightypork.gamecore.gui.events;
|
||||
|
||||
|
||||
import mightypork.gamecore.eventbus.BusEvent;
|
||||
import mightypork.gamecore.eventbus.event_flags.SingleReceiverEvent;
|
||||
import mightypork.utils.eventbus.BusEvent;
|
||||
import mightypork.utils.eventbus.events.flags.SingleReceiverEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Request to change screen
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
@SingleReceiverEvent
|
||||
public class ScreenRequest extends BusEvent<ScreenRequestListener> {
|
||||
|
||||
@@ -4,7 +4,7 @@ package mightypork.gamecore.gui.events;
|
||||
/**
|
||||
* {@link ScreenRequest} listener
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public interface ScreenRequestListener {
|
||||
|
||||
|
||||
@@ -8,20 +8,20 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import mightypork.gamecore.core.modules.AppAccess;
|
||||
import mightypork.gamecore.eventbus.clients.DelegatingClient;
|
||||
import mightypork.utils.eventbus.clients.DelegatingClient;
|
||||
|
||||
|
||||
/**
|
||||
* Screen with multiple instances of {@link ScreenLayer}
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public abstract class LayeredScreen extends Screen {
|
||||
|
||||
/**
|
||||
* Wrapper for delegating client, to use custom client ordering.
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
private class LayersClient implements DelegatingClient {
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@ import java.util.Collection;
|
||||
|
||||
import mightypork.gamecore.core.modules.AppAccess;
|
||||
import mightypork.gamecore.core.modules.AppSubModule;
|
||||
import mightypork.gamecore.eventbus.events.Updateable;
|
||||
import mightypork.gamecore.gui.Enableable;
|
||||
import mightypork.gamecore.gui.Hideable;
|
||||
import mightypork.gamecore.gui.components.layout.ConstraintLayout;
|
||||
import mightypork.gamecore.gui.events.LayoutChangeListener;
|
||||
@@ -16,17 +14,19 @@ import mightypork.gamecore.input.KeyBindingPool;
|
||||
import mightypork.gamecore.input.KeyStroke;
|
||||
import mightypork.gamecore.input.KeyStroke.Edge;
|
||||
import mightypork.gamecore.render.Renderable;
|
||||
import mightypork.gamecore.util.annot.DefaultImpl;
|
||||
import mightypork.gamecore.util.math.color.Color;
|
||||
import mightypork.gamecore.util.math.constraints.num.Num;
|
||||
import mightypork.gamecore.util.math.constraints.vect.Vect;
|
||||
import mightypork.utils.annotations.DefaultImpl;
|
||||
import mightypork.utils.interfaces.Enableable;
|
||||
import mightypork.utils.interfaces.Updateable;
|
||||
import mightypork.utils.math.color.Color;
|
||||
import mightypork.utils.math.constraints.num.Num;
|
||||
import mightypork.utils.math.constraints.vect.Vect;
|
||||
|
||||
|
||||
/**
|
||||
* Abstract overlay.<br>
|
||||
* Overlay is connected to event bus and is renderable.
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public abstract class Overlay extends AppSubModule implements Comparable<Overlay>, Updateable, Renderable, KeyBinder, Hideable, Enableable,
|
||||
LayoutChangeListener {
|
||||
|
||||
@@ -12,15 +12,15 @@ import mightypork.gamecore.input.KeyStroke.Edge;
|
||||
import mightypork.gamecore.render.DisplaySystem;
|
||||
import mightypork.gamecore.render.Render;
|
||||
import mightypork.gamecore.render.Renderable;
|
||||
import mightypork.gamecore.util.annot.DefaultImpl;
|
||||
import mightypork.gamecore.util.math.constraints.rect.Rect;
|
||||
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
|
||||
import mightypork.utils.annotations.DefaultImpl;
|
||||
import mightypork.utils.math.constraints.rect.Rect;
|
||||
import mightypork.utils.math.constraints.rect.RectBound;
|
||||
|
||||
|
||||
/**
|
||||
* Screen class.
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public abstract class Screen extends AppSubModule implements Renderable, RectBound, KeyBinder, LayoutChangeListener {
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package mightypork.gamecore.gui.screens;
|
||||
|
||||
|
||||
import mightypork.gamecore.util.annot.DefaultImpl;
|
||||
import mightypork.utils.annotations.DefaultImpl;
|
||||
|
||||
|
||||
/**
|
||||
* Screen display layer
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public abstract class ScreenLayer extends Overlay {
|
||||
|
||||
|
||||
@@ -6,23 +6,21 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.newdawn.slick.opengl.GLUtils;
|
||||
|
||||
import mightypork.gamecore.core.modules.AppAccess;
|
||||
import mightypork.gamecore.core.modules.AppModule;
|
||||
import mightypork.gamecore.gui.events.LayoutChangeEvent;
|
||||
import mightypork.gamecore.gui.events.ScreenRequestListener;
|
||||
import mightypork.gamecore.logging.Log;
|
||||
import mightypork.gamecore.render.Renderable;
|
||||
import mightypork.gamecore.render.events.ViewportChangeEvent;
|
||||
import mightypork.gamecore.render.events.ViewportChangeListener;
|
||||
import mightypork.gamecore.util.annot.DefaultImpl;
|
||||
import mightypork.utils.annotations.DefaultImpl;
|
||||
import mightypork.utils.logging.Log;
|
||||
|
||||
|
||||
/**
|
||||
* Game screens holder; Takes care of rendering and screen requests.
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class ScreenRegistry extends AppModule implements ScreenRequestListener, ViewportChangeListener, Renderable {
|
||||
|
||||
@@ -114,7 +112,7 @@ public class ScreenRegistry extends AppModule implements ScreenRequestListener,
|
||||
@Override
|
||||
public void onViewportChanged(ViewportChangeEvent event)
|
||||
{
|
||||
if(active != null) fireLayoutUpdateEvent();
|
||||
if (active != null) fireLayoutUpdateEvent();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,16 +6,16 @@ import mightypork.gamecore.core.modules.AppAccess;
|
||||
import mightypork.gamecore.gui.components.painters.QuadPainter;
|
||||
import mightypork.gamecore.gui.events.ScreenRequest;
|
||||
import mightypork.gamecore.gui.screens.Overlay;
|
||||
import mightypork.gamecore.util.math.Easing;
|
||||
import mightypork.gamecore.util.math.color.pal.RGB;
|
||||
import mightypork.gamecore.util.math.constraints.num.mutable.NumAnimated;
|
||||
import mightypork.gamecore.util.math.timing.TimedTask;
|
||||
import mightypork.utils.math.animation.Easing;
|
||||
import mightypork.utils.math.animation.NumAnimated;
|
||||
import mightypork.utils.math.color.pal.RGB;
|
||||
import mightypork.utils.math.timing.TimedTask;
|
||||
|
||||
|
||||
/**
|
||||
* Overlay used for cross-fading between screens
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class CrossfadeOverlay extends Overlay {
|
||||
|
||||
@@ -67,7 +67,7 @@ public class CrossfadeOverlay extends Overlay {
|
||||
{
|
||||
requestedScreenName = screen;
|
||||
|
||||
if(screen == null) {
|
||||
if (screen == null) {
|
||||
// going for halt
|
||||
getSoundSystem().fadeOutAllLoops();
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package mightypork.gamecore.gui.screens.impl;
|
||||
|
||||
|
||||
import mightypork.gamecore.eventbus.BusEvent;
|
||||
import mightypork.gamecore.eventbus.event_flags.SingleReceiverEvent;
|
||||
import mightypork.utils.eventbus.BusEvent;
|
||||
import mightypork.utils.eventbus.events.flags.SingleReceiverEvent;
|
||||
|
||||
|
||||
/**
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
@SingleReceiverEvent
|
||||
public class CrossfadeRequest extends BusEvent<CrossfadeOverlay> {
|
||||
|
||||
@@ -3,16 +3,16 @@ package mightypork.gamecore.gui.screens.impl;
|
||||
|
||||
import mightypork.gamecore.gui.screens.Screen;
|
||||
import mightypork.gamecore.gui.screens.ScreenLayer;
|
||||
import mightypork.gamecore.util.annot.DefaultImpl;
|
||||
import mightypork.gamecore.util.math.Easing;
|
||||
import mightypork.gamecore.util.math.constraints.num.mutable.NumAnimated;
|
||||
import mightypork.gamecore.util.math.timing.TimedTask;
|
||||
import mightypork.utils.annotations.DefaultImpl;
|
||||
import mightypork.utils.math.animation.Easing;
|
||||
import mightypork.utils.math.animation.NumAnimated;
|
||||
import mightypork.utils.math.timing.TimedTask;
|
||||
|
||||
|
||||
/**
|
||||
* Layer that smoothly appears/disappears when shown/hidden
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public abstract class FadingLayer extends ScreenLayer {
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ package mightypork.gamecore.gui.screens.impl;
|
||||
import mightypork.gamecore.gui.components.painters.QuadPainter;
|
||||
import mightypork.gamecore.gui.screens.Screen;
|
||||
import mightypork.gamecore.gui.screens.ScreenLayer;
|
||||
import mightypork.gamecore.util.math.color.Color;
|
||||
import mightypork.utils.math.color.Color;
|
||||
|
||||
|
||||
public class LayerColor extends ScreenLayer {
|
||||
|
||||
@@ -3,15 +3,15 @@ package mightypork.gamecore.input;
|
||||
|
||||
import mightypork.gamecore.core.events.UserQuitRequest;
|
||||
import mightypork.gamecore.core.modules.AppAccess;
|
||||
import mightypork.gamecore.eventbus.clients.RootBusNode;
|
||||
import mightypork.gamecore.eventbus.events.Updateable;
|
||||
import mightypork.gamecore.input.KeyStroke.Edge;
|
||||
import mightypork.gamecore.input.events.InputReadyEvent;
|
||||
import mightypork.gamecore.input.events.KeyEvent;
|
||||
import mightypork.gamecore.input.events.MouseButtonEvent;
|
||||
import mightypork.gamecore.input.events.MouseMotionEvent;
|
||||
import mightypork.gamecore.util.math.constraints.vect.Vect;
|
||||
import mightypork.gamecore.util.math.constraints.vect.mutable.VectVar;
|
||||
import mightypork.utils.eventbus.clients.RootBusNode;
|
||||
import mightypork.utils.interfaces.Updateable;
|
||||
import mightypork.utils.math.constraints.vect.Vect;
|
||||
import mightypork.utils.math.constraints.vect.var.VectVar;
|
||||
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
@@ -22,7 +22,7 @@ import org.lwjgl.opengl.Display;
|
||||
/**
|
||||
* Input system
|
||||
*
|
||||
* @author MightyPork
|
||||
* @author Ondřej Hruška (MightyPork)
|
||||
*/
|
||||
public class InputSystem extends RootBusNode implements Updateable, KeyBinder {
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user