Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Commit

Permalink
Updated LML to 1.8.1.9.4
Browse files Browse the repository at this point in the history
  • Loading branch information
czyzby authored Oct 9, 2016
2 parents 42107ec + f0cb74e commit ef7238c
Show file tree
Hide file tree
Showing 537 changed files with 34,013 additions and 24,192 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ android/gen/
*.ipr
*.iws
*.iml
*.so
out/
com_crashlytics_export_strings.xml

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Maven Central](https://img.shields.io/maven-central/v/com.github.czyzby/gdx-lml.svg)](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.github.czyzby%22%20)

# LibGDX utilities
This repository contains most of my libraries aimed at improving LibGDX framework. While they used to be kept in multiple separate repositories, this setup is much easier to maintain for the contributor(s) and, well, makes it harder to overlook some of my less popular libraries.

Expand Down Expand Up @@ -52,9 +54,9 @@ See [examples section](examples) to check out some simple applications using pre
### Other projects
Other LibGDX-related projects include:
- [gdx-setup](https://github.com/czyzby/gdx-setup): an alternative to the current project generator created using LibGDX and Kotlin. Collaboration with [@kotcrab](https://github.com/kotcrab).
- [ktx](https://github.com/czyzby/ktx): utilities for LibGDX application written in [Kotlin](https://kotlinlang.org/). Features a [VisUI](https://github.com/kotcrab/VisEditor/wiki/VisUI) module by [@kotcrab](https://github.com/kotcrab).
- [gdx-skins](https://github.com/czyzby/gdx-skins): aims to help beginners with setting up their GUI in LibGDX using *Scene2D*. Contains some free GUI themes.
- [Noise4J](https://github.com/czyzby/noise4j): a couple of simple map generators. Written with LibGDX in mind, but the code itself has no dependencies - this is a pure Java 6 library, compatible with GWT. Lightweight. Can be used in pretty much any Java project.
- [gdx-dragome](https://github.com/dragome/gdx-dragome): alternative to LibGDX GWT backend that supports other JVM languages. Work in progress.
- [gdx-skins](https://github.com/czyzby/gdx-skins): aims to help beginners with setting up their GUI in LibGDX using *Scene2D*. Contains a few free GUI themes.
- [vis-ui-contrib](https://github.com/kotcrab/vis-ui-contrib): contains some **VisUI** utilities and skins that I've created and made public. Note that the project itself in maintained by [@kotcrab](https://github.com/kotcrab), the creator of **VisUI**.

## Dependencies
Expand Down
7 changes: 7 additions & 0 deletions autumn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ For efficient class scanning on desktop, see [Autumn FCS](natives/fcs).

##What's new

1.7 -> 1.8

- `@Component` annotation now allows to pass an array of interfaces, making injection by interface possible - even though the LibGDX mechanism does not normally allow to inspect interfaces at runtime.
- Added more listener-related methods to `EventDispatcher` and `MessageDispatcher`. Now it is possible to remove listeners manually at runtime.
- Added `ContextConsumer` functional interface, `ContextInitializer#doBeforeInitiation` and `#doAfterInitiation`. Now `Context` instance can be accessed right after its creation and after full initiation.
- Added `ContextInitializer#clearContextAfterInitiation`. You can choose not to clear components meta-data stored in `Context` to use dependency injection at runtime.

1.6 -> 1.7

- Experimental [JTransc](https://github.com/jtransc/gdx-backend-jtransc) support through [a new library](natives/jtransc).
Expand Down
9 changes: 2 additions & 7 deletions autumn/natives/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ ext {
androidVersion = '4.1.1.4'
}

configurations {
provided
compile.extendsFrom provided
}

dependencies {
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
compile "com.github.czyzby:gdx-autumn:$libVersion"
provided "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
provided "com.google.android:android:$androidVersion"
compile "com.github.czyzby:gdx-autumn:$libVersion"
}
2 changes: 1 addition & 1 deletion autumn/natives/fcs/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ext {
fcsVersion = '1.9.18'
fcsVersion = '2.0.4'
}

dependencies {
Expand Down
13 changes: 4 additions & 9 deletions autumn/natives/gwt/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
ext {
gwtVersion = '2.6.0'
gwtVersion = '2.6.1'
}

javadoc {
options.addStringOption("sourcepath", "")
}

dependencies {
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
compile "com.google.gwt:gwt-user:$gwtVersion"
compile "com.google.gwt:gwt-user:$gwtVersion:sources"
compile "com.google.gwt:gwt-dev:$gwtVersion"
compile "com.google.gwt:gwt-dev:$gwtVersion:sources"
provided "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
provided "com.google.gwt:gwt-user:$gwtVersion"
provided "com.google.gwt:gwt-dev:$gwtVersion"
compile "com.github.czyzby:gdx-autumn:$libVersion"
compile "com.github.czyzby:gdx-autumn:$libVersion:sources"
compile "com.github.czyzby:gdx-kiwi:$libVersion:sources"
}
2 changes: 1 addition & 1 deletion autumn/natives/jtransc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ ext {
}

dependencies {
provided "com.jtransc.gdx:gdx-backend-jtransc:$jtranscVersion"
compile "com.github.czyzby:gdx-autumn:$libVersion"
compile "com.jtransc.gdx:gdx-backend-jtransc:$jtranscVersion"
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface Component {
/** @return if not empty, this component will be injectable through these interfaces. This is a utility that allows
* to overcome the fact that LibGDX reflection does not allow to read class interfaces at runtime. */
Class<?>[] value() default {};
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public boolean isCreatingMissingDependencies() {
return createMissingDependencies;
}

/** @param type superclass or interface of the component.
* @param component will be injectable through the selected class. */
public void add(final Class<?> type, final Object component) {
components.get(type).add(component);
}

/** @param component will be mapped to its class tree. Note that mapping by interfaces is NOT supported, as
* interfaces are not available on GWT. */
public void map(final Object component) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
import com.github.czyzby.autumn.annotation.Processor;
import com.github.czyzby.autumn.annotation.Provider;
import com.github.czyzby.autumn.context.error.ContextInitiationException;
import com.github.czyzby.autumn.context.impl.method.ContextConsumer;
import com.github.czyzby.autumn.context.impl.method.MethodInvocation;
import com.github.czyzby.autumn.processor.AnnotationProcessor;
import com.github.czyzby.autumn.processor.event.EventDispatcher;
import com.github.czyzby.autumn.processor.event.MessageDispatcher;
import com.github.czyzby.autumn.processor.impl.ComponentAnnotationProcessor;
import com.github.czyzby.autumn.processor.impl.DestroyAnnotationProcessor;
import com.github.czyzby.autumn.processor.impl.DisposeAnnotationProcessor;
import com.github.czyzby.autumn.processor.impl.InitiateAnnotationProcessor;
Expand Down Expand Up @@ -78,6 +80,13 @@ public class ContextInitializer {
private boolean createMissingDependencies = true;
/** If true, scanners and processors are cleared after initiation. */
private boolean clearProcessors = true;
/** If true, components are removed from the context after initiation. They still hold references to each other
* (through dependency injection), but the {@link Context} object will be empty. */
private boolean clearContextAfterInitiation = true;
/** Consumes constructed {@link Context} instance. */
private ContextConsumer doBeforeInitiation;
/** Consume fully initiated {@link Context} instance. */
private ContextConsumer doAfterInitiation;

/** Creates a new context initializer with default annotation processors. */
public ContextInitializer() {
Expand All @@ -89,6 +98,7 @@ public ContextInitializer() {
scannedAnnotations.add(OnEvent.class);
scannedAnnotations.add(OnMessage.class);
// Default processors:
addProcessor(new ComponentAnnotationProcessor()); // Maps components by interfaces.
addProcessor(new MetaAnnotationProcessor()); // Registers annotation processors.
addProcessor(new ProviderAnnotationProcessor()); // Registers dependency providers.
addProcessor(new InjectAnnotationProcessor()); // Injects field dependencies.
Expand Down Expand Up @@ -193,6 +203,39 @@ public ContextInitializer clearProcessors(final boolean clearProcessors) {
return this;
}

/**
* @param clearContextAfterInitiation if true, all components from the {@link Context} instance will be removed
* after the context is fully initiated.
* @return this for chaining.
* @see Context#setClear(boolean)
*/
public ContextInitializer clearContextAfterInitiation(final boolean clearContextAfterInitiation) {
this.clearContextAfterInitiation = clearContextAfterInitiation;
return this;
}

/**
* @param doBeforeInitiation will be invoked right after the {@link Context} is created. The consumed context
* instance should be empty, but will never be null.
* @return this for chaining.
* @see ContextConsumer
*/
public ContextInitializer doBeforeInitiation(final ContextConsumer doBeforeInitiation) {
this.doBeforeInitiation = doBeforeInitiation;
return this;
}

/**
* @param doAfterInitiation will be invoked right after the {@link Context} is fully initiated, but before the
* processors and components meta-data is cleared. The consumed context instance will never be null.
* @return this for chaining.
* @see ContextConsumer
*/
public ContextInitializer doAfterInitiation(final ContextConsumer doAfterInitiation) {
this.doAfterInitiation = doAfterInitiation;
return this;
}

/** @param root scanning root. Will look for classes sharing the same root package.
* @param scanner will process the actual class scanning.
* @return this for chaining. */
Expand Down Expand Up @@ -241,20 +284,38 @@ public ContextInitializer addComponents(final Object... components) {
* @see #scan(Class, ClassScanner) */
public ContextDestroyer initiate() {
validateScanners(); // Making sure scanners are properly defined.
final Context context = new Context();
context.setCreateMissingDependencies(createMissingDependencies);
final Context context = createContext(); // Creating new instance, applying user's settings.
final ContextDestroyer contextDestroyer = new ContextDestroyer();
mapInContext(context, processors); // Now context contains default processors. They are injectable.
mapInContext(context, manuallyAddedComponents); // Now manually added components are in the context.
initiateMetaComponents(context, contextDestroyer); // Now context contains custom annotation processors.
invokeProcessorActionsBeforeInitiation(); // Processors are ready to process!
initiateRegularComponents(context, contextDestroyer);// Now context contains all regular components.
invokeProcessorActionsAfterInitiation(context, contextDestroyer); // Processors finish up their work.
context.clear(); // Removing all components from context.
finishContext(context); // Clearing processors and components.
return contextDestroyer;
}

private Context createContext() {
final Context context = new Context();
context.setClear(clearContextAfterInitiation);
context.setCreateMissingDependencies(createMissingDependencies);
if (doBeforeInitiation != null) {
doBeforeInitiation.handleContext(context);
doBeforeInitiation = null;
}
return context;
}

private void finishContext(Context context) {
if (doAfterInitiation != null) {
doAfterInitiation.handleContext(context);
doAfterInitiation = null;
}
context.clear(); // Removing all components from context (if not disabled)
if (clearProcessors) {
destroyInitializer(); // Clearing meta-data. Processors are no longer available.
}
return contextDestroyer;
}

/** Throws exception if user did not specify any scanners. */
Expand All @@ -281,9 +342,8 @@ private void invokeProcessorActionsBeforeInitiation() {
}
}

/** Calls {@link AnnotationProcessor#doAfterScanning(ContextInitializer, Context)} with "this" argument on each
* processor.
*
/** Calls {@link AnnotationProcessor#doAfterScanning(ContextInitializer, Context, ContextDestroyer)} with "this"
* argument on each processor.
* @param context might be required by some processors to finish up.
* @param destroyer used to register destruction callbacks. */
private void invokeProcessorActionsAfterInitiation(final Context context, final ContextDestroyer destroyer) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.github.czyzby.autumn.context.impl.method;

import com.github.czyzby.autumn.context.Context;

/**
* Allows to performs operations on {@link Context} instance.
* @author MJ
*/
public interface ContextConsumer {
/**
* @param context is never null.
*/
void handleContext(Context context);
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,28 @@ public void processType(final Class<?> type, final OnEvent annotation, final Obj
}
}

/** @param listener will be registered.
* @param annotation contains listener's data. */
/**
* @param listener will be registered.
* @param annotation contains listener's data.
*/
public void addListener(final EventListener<?> listener, final OnEvent annotation) {
addListener(listener, annotation.value(), annotation.forceMainThread());
}

/** @param listener will be registered.
/**
* @param listener will be registered. Will be invoked as soon as the event is posted.
* @param eventType type of handled events.
*/
public void addListener(final EventListener<?> listener, final Class<?> eventType) {
addListener(listener, eventType, false);
}

/**
* @param listener will be registered.
* @param eventType type of handled events.
* @param forceMainThread if true, listener will be invoked only on main LibGDX thread with
* Gdx.app.postRunnable(Runnable). */
* Gdx.app.postRunnable(Runnable). Otherwise the listener is invoked as soon as the event is posted.
*/
public void addListener(final EventListener<?> listener, final Class<?> eventType, final boolean forceMainThread) {
if (forceMainThread) {
mainThreadListeners.get(eventType).add(listener);
Expand All @@ -75,6 +87,31 @@ public void addListener(final EventListener<?> listener, final Class<?> eventTyp
}
}

/**
* @param listener will be removed (if registered).
* @param eventType type of the event that the listener is registered to handle.
*/
public void removeListener(final EventListener<?> listener, final Class<?> eventType) {
listeners.get(eventType).remove(listener);
mainThreadListeners.get(eventType).remove(listener);
}

/**
* @param eventType all listeners registered to handle this type will be removed.
*/
public void removeListenersForType(final Class<?> eventType) {
listeners.remove(eventType);
mainThreadListeners.remove(eventType);
}

/**
* Removes all registered listeners. Use with care.
*/
public void clearListeners() {
listeners.clear();
mainThreadListeners.clear();
}

/** @param event will be posted and invoke all listeners registered to its exact class. Nulls are ignored. */
public void postEvent(final Object event) {
if (event == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,20 @@ public void processType(final Class<?> type, final OnMessage annotation, final O
public void addListener(final MessageListener listener, final OnMessage annotation) {
addListener(listener, annotation.value(), annotation.forceMainThread());
}
/**
* @param listener will be registered. Invoked as soon as the message is posted.
* @param messageContent content of handled message. If the message is posted, listener will be invoked.
*/
public void addListener(final MessageListener listener, final String messageContent) {
addListener(listener, messageContent, false);
}

/** @param listener will be registered.
/**
* @param listener will be registered.
* @param messageContent content of handled message. If the message is posted, listener will be invoked.
* @param forceMainThread if true, listener will be invoked only on main LibGDX thread with
* Gdx.app.postRunnable(Runnable). */
* Gdx.app.postRunnable(Runnable). Otherwise the listener is invoked as soon as the message is posted.
*/
public void addListener(final MessageListener listener, final String messageContent,
final boolean forceMainThread) {
if (forceMainThread) {
Expand All @@ -76,6 +85,31 @@ public void addListener(final MessageListener listener, final String messageCont
}
}

/**
* @param listener will be removed (if registered).
* @param messageContent content of message that the listener is registered to handle.
*/
public void removeListener(final MessageListener listener, final String messageContent) {
listeners.get(messageContent).remove(listener);
mainThreadListeners.get(messageContent).remove(listener);
}

/**
* @param messageContent all listeners registered to handle this message will be removed.
*/
public void removeListenersForMessage(final String messageContent) {
listeners.remove(messageContent);
mainThreadListeners.remove(messageContent);
}

/**
* Removes all registered listeners. Use with care.
*/
public void clearListeners() {
listeners.clear();
mainThreadListeners.clear();
}

/** @param message will be posted and invoke all listeners registered to its exact content. Nulls are ignored. */
public void postMessage(final String message) {
if (message == null) {
Expand Down
Loading

0 comments on commit ef7238c

Please sign in to comment.