czyzby / gdx-lml Goto Github PK
View Code? Open in Web Editor NEW:octocat: LibGDX utility libraries.
License: Apache License 2.0
:octocat: LibGDX utility libraries.
License: Apache License 2.0
It would be nice to have a DTD file for the lml spec, so editors can validate and suggest proper document structure when writing lml templates.
See #27. It should be possible to import .lss
files through a LML macro inside a template. Another macro for clearing styles en masse would make sense as well.
FileTypeFilter
.CheckBox
refactor.uedi-api
implementation using LibGDX reflection abstraction.gdx-lml-uedi
library - a simpler alternative to Autumn MVC.gdx-lml-uedi-tests
example project, showing usage of most features.gdx-uedi
.gdx-setup
: basic usage and something like the advanced Autumn MVC example. (Maybe the same application, converted to UEDI.)Unsettlingly Easy Dependency Injection is a very simple dependency injection framework with automatic component scanning. Instead of flooding the code with annotations, the user of the library has to implement one of the so-called component interfaces and that's it: instance of the class will be created and all of its empty non-transient
, non-primitive fields will be filled with values from the context. Thanks to powerful factories and providers, new filled objects can be created with little or no reflection.
The best part about UEDI: it's highly non-invasive. Consider the following code:
public class SomeClass {
AssetManager assetManager = ((MyApplication) Gdx.app.getApplicationListener()).getAssetManager();
Texture texture;
public SomeClass() {
assetManager.load("images/image.png", Texture.class);
}
public void onLoad() {
texture = assetManager.get("images/image.png", Texture.class);
}
// Game logic.
}
If you're not a fan of statics, your code might look like this. With UEDI packed with some LibGDX-specific providers, your this class might look like this:
public class SomeClass implements Singleton {
AssetManager assetManager; // Remove if reference no longer needed.
Texture image; // Found by name, injected when loaded by the global asset manager.
// Game logic.
}
And that's it. UEDI does not force you to learn it's whole API: it encourages using standard LibGDX classes, but with all the loading and wiring boilerplate code removed. Use meaningful names and you're fine. You just have to remember names of a few interfaces and use Context
instance from time to time.
Why? Autumn MVC is complicated. And huge. And makes GWT compilation even longer, and includes even more GWT meta-data to work correctly.
Yes, it's powerful and allows you to define custom annotations with scanner that can do anything, but it also heavily floods your code with its specific APIs. I doubt there are many Autumn MVC users out there simply because of its learning curve and the fact that I don't have enough time to create tutorials for everything. The javadocs are OK, but it's certainly not enough. It's a great tool once you learn to use it, although the fact that the author is probably its only user in the world, is not very encouraging to get to know it in the first place.
UEDI, on the other hand, should allow to convert an existing project in the matter of minutes(/hours), simply by removing all the spaghetti wiring and asset loading by letting UEDI do its job: injecting it all for you.
Goals:
gdx-lml-tests
project was recently slightly "refactored", as it gained a new skin. Along with the graphical update, some example templates were changed to show the new features of 1.6
version (optional named attributes in macros). However, gdx-lml-vis-tests
uses separate example templates based on gdx-lml-tests
, mainly due to differences in skin assets - some of gdx-lml-tests
examples wouldn't work in gdx-lml-vis-tests
(and vice versa) due to missing drawables/styles.
While gdx-lml-vis-tests
project works as expected, refreshing the examples would be nice.
One has to update gdx-lml-vis-tests
example templates according to the gdx-lml-tests
project, while correctly preserving the names of VisUI
-specific skin assets.
1.8.1.9.4-SNAPSHOT
Simple LML template like this
<?xml version="1.0"?>
<!DOCTYPE vistable SYSTEM "../../lml.dtd">
<vistable>
<listview/>
</vistable>
Produces exception:
Caused by: java.lang.NullPointerException
at com.github.czyzby.lml.vis.parser.impl.tag.ListViewLmlTag.getManagedObject(ListViewLmlTag.java:65)
at com.github.czyzby.lml.parser.impl.tag.AbstractActorLmlTag.processTagAttributes(AbstractActorLmlTag.java:124)
at com.github.czyzby.lml.parser.impl.tag.AbstractActorLmlTag.prepareActor(AbstractActorLmlTag.java:49)
at com.github.czyzby.lml.parser.impl.tag.AbstractActorLmlTag.<init>(AbstractActorLmlTag.java:29)
at com.github.czyzby.lml.parser.impl.tag.actor.TableLmlTag.<init>(TableLmlTag.java:17)
at com.github.czyzby.lml.vis.parser.impl.tag.ListViewLmlTag.<init>(ListViewLmlTag.java:45)
at com.github.czyzby.lml.vis.parser.impl.tag.provider.ListViewLmlTagProvider.create(ListViewLmlTagProvider.java:14)
at com.github.czyzby.lml.parser.impl.DefaultLmlParser.processRegularTag(DefaultLmlParser.java:525)
at com.github.czyzby.lml.parser.impl.DefaultLmlParser.processTagEntity(DefaultLmlParser.java:333)
at com.github.czyzby.lml.parser.impl.DefaultLmlParser.processTag(DefaultLmlParser.java:308)
at com.github.czyzby.lml.parser.impl.DefaultLmlParser.parse(DefaultLmlParser.java:139)
at com.github.czyzby.lml.parser.impl.DefaultLmlParser.parseTemplate(DefaultLmlParser.java:100)
... 4 more
See #47.
Duplicate file stops gradlew from building.
http://i.imgur.com/5tGDQls.png
Since VisUI 1.1.6 Spinner
has TextFieldEventPolicy
that can configure notification behavior
Hello, do you have any plans to include support for custom units in the width/height or even positions of actors?
I'm implementing a game with a pixel-perfect UI viewport, with actors' sizes defined in DPs (like Android) and this would be pretty useful for me and maybe for others.
Hello, sorry this is not an issue. Not even a contribution. Just a series of questions/feedback.
But before that, congratulations and thank you for making this amazing framework. Being a Spring MVC user, i was very excited when i discovered this autumn mvc project.
While i was fascinated with tons of features autumn-mvc offers, i am left banging the walls. Because i just don't know how to use this. I have tried mvc-simple example, fiddled around with it, but that just as far i can go. I can do trivial stuff like create some actors in LML, create controllers. But that's it. When i about to start making a game, i just got stuck. For example, how can i use box2d here? How can i spawn actors into LML? How to have hero character? How to do scene2d actions?
I have read your readme files and wiki but not fruitful. In mvc-simple example, I tried to use new skin using @Skin
, but then can't load with VISUI skin. How can import my own game asset (sprites). For now i rebuild VisUi raw asset and use as skin as stated here. I know what annotations/features are available, but just no idea how to use them. And i'm unsure what to put in Service layer.
tldr;
i hope its not too much if i ask some more complete game example. A simple jumper game with box2d will do. Or if box2d is too much, just some simple card game should suffice to demonstrate scene2d usage.
Thank you. Sorry for long post or sounding like complaining. Just my 2 cents.
I don't know if this is expected behavior, but I've set an onclick
in some Labels
but the linked LmlAction
only runs the first time I click.
Changing the Label
to a TextButton
works as aspected.
The reason I'm using labels is because I'm populating a Tree
and don't want the background that buttons have. Maybe I'm missing a better alternative?
I noticed you used a Table
and toggle buttons on gdx-lml-tests
and like the look, but wouldn't allow me to achieve the tree child collapsing and expanding behavior.
ScrollableTextArea
.HighlightTextArea
, Highlighter
.MultiSplitPane
BusyBar
Additionally to new widgets:
FileChooser#setSorting(FileSorting)
and #setSortingOrderAscending
FileChooser.setSaveLastDirectory
FileChooser.focusFileScrollPaneOnShow
Spinner#setTextFieldEventPolicy
TextFieldEventPolicy
enum is private.)MenuBar#setMenuListener
See changes.
In IntelliJ 16 (I haven't tested anywhere else), the dtd file attributes are not recognized (and therefore the content assist won't work) with the current format:
<!ATTLIST visslider
<!-- CellSizeLmlAttribute -->
size CDATA #IMPLIED
<!-- TreeNodeLmlAttribute -->
node CDATA #IMPLIED>
They get recognized removing the comments between attributes:
<!ATTLIST visslider
size CDATA #IMPLIED
node CDATA #IMPLIED>
Or creating an ATTLIST for each attribute:
<!-- CellSizeLmlAttribute -->
<!ATTLIST visslider size CDATA #IMPLIED
<!-- TreeNodeLmlAttribute -->
<!ATTLIST visslider node CDATA #IMPLIED>
This last one would make the file even bigger, but would allow the comments to persist, though I don't know if they're really necessary (for the user) inside the dtd file.
I wonder if there is any way to pass some extra values to ActorConsumer
? Assume we want to extend OnClickLmlAttribute
attribute with click position and pass it down to action code. But it appears like ActorConsumer
is restricted to get only actor from 'LmlAttribute' class. Disregard other solutions for obtaining pointer position, this question is about extending ActorConsumer
restrictions. This will allow to write very generic actions for actors. Any plans on it?
I've spotted that unlike other input widgets, Spinner
doesn't trigger ChangeEvent
when you type anything in the field. ChangeEvent
get fired only if one of the increment/decrement buttons has been pressed or user hit Enter.
There is no any ability to switch that behavior.
Simple fix could look like this (IntSpinnerModel
for example):
@Override
public void textChanged () {
String text = spinner.getTextField().getText();
if (text.equals("")) {
current = min;
} else if (checkInputBounds(text)) {
current = Integer.parseInt(text);
spinner.notifyValueChanged(true); // <--- here it is
}
}
Hi,
I would like to know if there is a way to have LmlView without stage. I know LmlView interface has method getStage(), What am trying to achieve is have all ui in lml and have game screen without stage just normally drawing sprites using batch. Is there easy way todo it?
I am aware that there is LmlApplicationListener(Game) and AbstractLmlView(Screen) that can be used but AbstractLmlView has stage and LmlView interface defines getStage method.
So i was thinking if i implement my own LmlView and method getStage returns null that could do the job. But i would like some better solution then returning null or returning empty stage.
The same goes for ViewController which implements LmlView again there is method getStage but that class belongs to Autumn MVC, i would like to avoid autumn for now.
Is there possibility that getStage method gets moved from LmlView to AbstractLmlView or StageLmlView?
Thanks.
Edit.
I found solution to my question so closing the issue.
container
lacks next properties:
'pad', 'padleft', 'padright', 'padtop', 'padbottom'
I consider those are very important for markup. Are they missing by design?
I like the way we can use LmlView
and #createView()
with actor injection. I find it a good way to centralize all the actions and actors I need in a class that are relevant to that view only, via @LmlActor
and @LmlAction
.
AbstractLmlView
takes hold of the stage
's draw
, act
, etc. methods, so I created a class implementing LmlView
and ActionContainer
to achieve a similar behavior while keeping the control of the stage's methods.
This works great for displaying windows, dialogs or any Actors that are independent from the underlying scene:
ViewWhichExtendsMyAbstractClass view = lmlParser.createView(ViewWhichExtendsMyAbstractClass.class, template.lml);
This immediately displays the template and I get control of every actor and method if I simply define them with @LmlActor
and @LmlAction
inside that class.
Now, what if I want this same injection without adding the Actors to the stage? Or, in my case, what if I want to add the Actor to a Table
or a Container
already in the Stage?
With LmlView#parseTemplate()
and a separate ActionContainer
I can get access to the actors via lmlParser.getActorsMappedByIds()
but this gets tiring fast and does not allow me to centralize relevant LmlActions
and LmlActors
in the same class. I'm finding it much more practical to use annotations.
The question:
Is the any class besides LmlView that I can implement to get my LmlActions and LmlActors parsed without adding them to the Stage? Or some other solution I'm missing?
(Sorry for the long intro but it's in hopes that you correct me if I'm thinking the wrong way)
VisWindow#setKeepWithinParent
attribute.FloatingGroup
tag.FloatingGroup
support in DragPane
.Spinner
tag.
int
.float
.BigDecimal
.Array
.VisUI 1.0.2
is likely to be released soon. gdx-lml-vis 1.6
is going to use this VisUI version, so we want to support the new features before 1.6
is made public.
LetterboxingViewport
(fit and screen viewport combination, useful for GUIs).In this version, if the server has not sent packets, connection terminated.
connection terminated hear
class WebSocketInputStream
{
...
void readBytes(byte[] buffer, int length) throws IOException, WebSocketException
{
...
int count = read(buffer, total, length - total);
if (count <= 0)
{
// The end of the stream has been reached unexpectedly.
throw new WebSocketException(
WebSocketError.INSUFFICENT_DATA,
"The end of the stream has been reached unexpectedly.");
}
total += count;
}
}
}
It would be nice to have a boolean property terminateConnectionAfterTimeOut to control behavior
if terminateConnectionAfterTimeOut == false then connection is not ternubated
Any chance we can get content assist for Vis UI elements?
I tried generating a schema using VisLml.parser()
but no Vis UI elements are included in the DTD file.
I do get the following warnings:
LML: Warning: unable to create an instance of actor mapped to 'imagetextbutton' tag name with provider: com.github.czyzby.lml.parser.impl.tag.actor.provider.ImageTextButtonLmlTagProvider@7c83dc97. Attributes list will not be complete. Is the provider properly implemented? Is a default style provided for the selected actor?
LML: Warning: unable to create an instance of actor mapped to 'imagebutton' tag name with provider: com.github.czyzby.lml.parser.impl.tag.actor.provider.ImageButtonLmlTagProvider@2f54a33d. Attributes list will not be complete. Is the provider properly implemented? Is a default style provided for the selected actor?
LML: Warning: '/*' tag might contain invalid XML characters.
It seems like there is no way to set Drawable
for Image
from LML markup.
I guess there should be drawable attribute that sets image from current skin.
Schema comment starts with <!
and ends with >
. LmlParser
currently expects !>
at the end of any comment. DTD schema comment needs to be properly parsed, taking into account the standards. See #4.
gdx-autumn-mvc-tests
gdx-autumn-tests
gdx-lml-tests
gdx-lml-vis-tests
gdx-lml-vis-websocket
gdx-websocket-serialization-compare
gdx-websocket-serialization-tests
In some point I want to get more control over EventDispatcher
, just like subscribe and unsubscribe from particular events right from the code.
It's useful when I instantiate objects by myself and thus they can't have injected fields and all the tricks with annotated methods. So I have to do all of that by my own code. One of those cases is related to events, what if I just want to some particular class to manage its event subscription on its own (like if this is poolable object and has init/reset methods).
EventDispatcher
has ability to add listeners manually, but there is no way to remove them (boolean return value inside event method doesn't count).
What do you think, is it possible to extend EventDispatcher
in that way?
And one a bit of off-topic question. In such cases, when I have no options but to inject Component
instances by own code, is there any sort of Autumn context that holds all references of singleton system components (like classes annotated with Component
or View
), so I can easily access those instances from any place in code?
gdx-lml-vis
application.I understand that macros might be too complicated to make XML friendly, but given the fact that it's so useful to separate template parts into multiple files, an <:import
or <:template
tag might be much common than other macros.
I wonder if it's possible to include an attribute to appease the IDE.
Currently I'm doing, for example:
<:template "views/menubar.lml" />
Which could become cleaner doing:
<:template path="views/menubar.lml" />
or
<:import template="views/menubar.lml" />
Is it possible?
Currently Tooltip
can be attached only to a single actor, but the implementation is pretty flexible and could be used for multiple widgets, even on multiple stages. Listener tags feature ids
and keep
attributes which allow to share the tooltip across multiple actors and views - same functionality should be added to tooltips.
The websocket API supports "secure" connections, but more is required than that to use them. There should to be a way to set the truststore and truststore password so the client can properly connect to the server. This can be done using this for desktop:
System.setProperty("javax.net.ssl.trustStore", "cacerts"); System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
But unfortunately, this only seems to work on Desktop, and not Android, html5 (gwt) and ,most likely, iOS (I haven't tested iOS yet).
Sorry this isn't really an issue, it's more of a feature suggestion. But this is a very important feature. I have been trying to implement SSL communication that supports all platforms without any luck. If you know of any way it can be done, please let me know.
my lml:
<:if test="{platform}=Desktop"><textfield id="email" /><:if:else /><selectbox id="email"/></:if>
it's say: No macro tag provider found for name: if:else
My websocket server require to user-agent header to be set. The websocket interface does not provider any method to achieve this.
Following this example from wiki @key|only|@arg
I'm trying to pass argument to localized string as parameter:
<vislabel>@key|{arg}</vislabel>
But as result parser searches for key|{arg}
key in bundle (and crushes when not found).
Am I missing something?
I'm trying to unify some filling code for VisSelectBox
in my LML.
Like so:
<visselectbox>
<:evaluate method="fillWithItems" id="selectBox"/>
</visselectbox>
And action looks like this:
@LmlAction("fillWithItems")
public void fillWithItems(VisSelectBox selectBox) {
Array<Item> items= new Array<>();
// Fill items with objects ...
selectBox.setItems(array);
}
The problem comes from parser that calls SelectBoxLmlTag#doOnTagClose()
, precisely next line:
// Forcing items update.
getSelectBox().setItems((String[]) getSelectBox().getItems().toArray(String.class));
and I get java.lang.ArrayStoreException
.
I want to reference real objects and not plain strings letter. Maybe I'm wrong at something and should use another approach to fill my collection based widgets with same data?
Thanks!
This would be a similar view manager to LibGDX Game
- it should just operate on (Abstract)LmlView
instances rather than Screens
. Should have Actions
support for smooth screen transitions.
gdx-lml
was inspired used @
sign for macros up to 1.5
version. Since DTD creator was introduced, LML templates now have a chance of being valid XML files - but @
is not a valid opening character for XML tags. However, :
is. That is why gdx-lml
and gdx-lml-vis
starting from 1.6
will use :
instead of @
, which will break most of the existing templates.
DefaultLmlSyntax
.gdx-lml
.gdx-lml-vis
.gdx-lml-tests
and gdx-lml-vis-tests
.If I try to put a $ literal in a label, it complains about action stuff. Escaping with a backslash doesn't seem to work either. I "fixed" it by setting a label's text to $ from Java every frame. It seems like it should be possible to escape it, no? HTML entities don't work either.
Application crashes completely if your Locale.getDefault() is Locale.forLanguageTag("tr");
https://garygregory.wordpress.com/2015/11/03/java-lowercase-conversion-turkey/
Libgdx 1.9.4 +
com.github.czyzby.lml.util.LmlParsingException: Error occurred during parsing near line 31 of the original file: "main-menu.lml".
REASON: Unable to parser alignment from raw data: right; no alignment value matching: right
Due implementation of the parser, the real problematic line might SLIGHTLY vary from the given line number(s), but exception message should be clear enough to find the actual error.
Currently parsed template part:
28 |VALID| </vistable>
29 |VALID| </vistable>
30 |VALID|
31 |ERROR| <vistable width="0.50%" height="1.00%" tablealign="right">
32 | | <myvistable id="main-coins-cont" onclick="main-coins-cont-click" visible="false" width="400" height="60" pad="10" tablealign="right">
33 | | <visimage size="60" style="image-coin"/>
34 | |
First of all, i wanted to thank you for actively maintaining the library.
you're a hero <3
Secondly, I can't compile my game for html5, it gives a kiwi error =(
http://pastebin.com/Zr5dyUuv
Sometimes it need to pass some parameters to new controllers. Like when creating dialog, pass concrete object to display etc.
My first idea was to obtain my dialog controller instance and pass parameters there. When InterfaceService#showDialog(Class)
called, it operates with ViewDialogController
that wraps actual class but doesn't provide access to it.
I've looked into InterfaceService
code but had no luck to fund any way to solve it. Am I missing anything or there is no any way for parameterizing controllers?
Spinner#setTextFieldEventPolicy
MultiSplitPane
API: kotcrab/vis-ui#221ListView
now supports ListViewStyle
for customizing scroll pane style.HighlightTextArea
can be used instead of custom CodeTextArea
to display code snippets in example projects.See changes.
Since Autumn MVC
is unlikely to make it to the third-party extensions and official gdx-setup
does not support project templates (and isn't even written with LibGDX, which makes it awkward to extend), a separate setup tool would be nice. Especially since Dragome backend is being created and it should come with a proper setup tool.
General ideas:
+
. When creating a new project, you'll most likely want to use the new versions of libraries anyway - by using +
, maintainers of third party libraries will not have to update gdx-setup
each time they make a release.ApplicationListener
, ApplicationAdapter
, Game
, (LibGDX) AbstractApplicationListener
(Kiwi), LmlApplicationListener
(LML), AutumnApplication
(Autumn MVC) or any other ApplicationListener
implementation from external libraries. This should help setting up some more complex projects, especially for beginners, as they might lack their personal "template projects" that could be easily copied.+
(latest), every library should be customizable. Keep versions in gradle.properties
.There are several cases where you might want to add some actors to the stage after a delay, when certain condition is met (for example: a button is clicked). For now, you can solve it by attaching a standard listener, which invokes a Java method that loads another template - for example, the one containing dialog data. However, it would be really useful if you could solve this issue entirely with LML code:
<button>
<onClick>
<dialog> ... </dialog>
</onClick>
</button>
In the example above, a Dialog
instance would be shown on the screen when the Button
is clicked, rather than immediately added to the stage.
Such tags could be added in two ways:
{arguments}
). Actors would be created unnecessarily if the event never occurs though, so macro solution would still be preferred if the event is expected to occur rarely.I think both ways would have their uses and both should be available. ClickListener
and ChangeListener
are obvious choices, not sure if any other listeners should be added.
LML should support simple styling sheets with CSS-like syntax, which would allow to set up default values for common, repetitive attributes in chosen tags. Simple inheritance should be supported.
HorizontalCollapsibleWidget
FileChooser#setShowSelectionCheckboxes
Spinner#setDisabled
works out of the box.Disableable
interface. Workaround attribute added.See changes.
gdx-kiwi
was one of the first projects and hasn't been ever drastically refactored - it contains simple utilities, so it never really needed any major improvements or rewrites. While there are no doc errors, it generates over 100 warnings, which flood the console on each javadoc
Gradle task. This is the only project with any warnings using the default javadoc
setting.
common
package.asset
package.collection
package.file
package.preference
package.reflection
package.scene2d
package.tuple
package.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.