gdx parse layout files to object files - java

we use libgdx for graphics rendering for our game on android. Seems like libgdx can drop support for layout files in the future. Disadvantages of using layout file is that it take longer to parse it. Advantages being it is very convenient to build UI using it instead of building UI in java files.
So I would like to know if there is a way to parse layout into serializable object files and load these object files in the game instead of layout files. This way if we can maintain a utility, using old gdx library which produces object files from layout files and upgrade gdx in out actual game.
edit : the layout files are of libgdx's not android's

There currently isn't any way to serialize your layout information with libgdx. You will likely need to write your own wrappers and somehow store this layout information, as I don't know of anyone who has done this. If you are using an old version of the library, which still has the tablelayout files, I'm not sure how easy it will be considering the amount of changes which has been made to libgdx since that time. The alternative is to re-write you files using the Java api, which you will likely need to do going forward.
I am not sure how you are still using the tablelayout ui files. They have been deprecated for over a year now and are not included with any of the latest releases of libgdx. If you want a more detailed explanation on what happened to the layout files you can look at this post. I do miss the layout files because of the extra bloat created by having to code the ui formatting. However, I also find you get much finer control over dynamic layouts by using the Java api.

Related

How to use Scratch Files in Android Studio?

Recently I came across a cool feature in Android Studio called scratch files. Just wanted to share it in Q and A Style.
What are scratch files and how to use them?
It's a cool feature that lets you save your code that you want to look at later or just for reference.
See this post
Say you are creating a class and you decide to change a section of code. You can create a new scratch file by right clicking on the navigation bar and selection New, and then scratch file. Copy and save the code in the scratch file. This file is not a part of your android studio project.
You can find this file under scratches scope or Scratches folder under Scratches and Consoles folder in Project Scope.
Hope this will interest you guys and help speeding up development.
Sometimes you may need to create temporary notes or draft up some code outside of the project context. Instead of switching to a different application for this purpose, you can use scratch files and scratch buffers.
To create a scratch file, you can use ALT+CTRL+SHIFT+insert
or on OS X use Command+SHIFT+N
you can read more about it here: docs
It is the same metaphor as a "scratch book", a place to note down useful code fragments or ideas that can be useful to return to later on.

Uninstall fonts installed using SWT's Display.loadFont API

I am working under eclipse plugin and trying to load fonts into the application as resources, so they will appear in project explorer tree.
In SWT we have method loadFont of Display class which loads font from specified file, so it will appear in list of available fonts of application. I am using this method.
But when I am trying to delete the font from project explorer I am getting following exception:
org.eclipse.core.internal.resources.ResourceException:
Problems encountered while deleting resources
I have following questions:
Is it possible to unload font from application in SWT ?
Is there any way to deal with it?
Is there another scenario to deal with custom fonts in eclipse?
Classes of the type FontData don't need to be disposed of, as they simply contain a small amount of information about the font. When you create an actual Font object then yes, it is your responsibility to call .dispose() and free up those resources.
If you are using JFace as well as SWT, then you may want to look at FontRegistry, which assists in keeping track of font resources.
Apologies for not linking any javadocs, the SWT docs aren't loading for me right now. I did find a small example of FontRegistry usage which explains the difference between FontData and Font.

Common files between multiple GWT pages

I want to design multiple pages using google web toolkit, reading one of the previous answers GWT multi modules for separate HTML pages? suggests that they way to do this is to have multiple modules. Hence I made 2 modules in my GWT application. They compile and run fine but however I find that each has its own folder in the war directory after compilation. Some of the files like UI image components that GWT generates are shared between the 2 modules. I was wondering if there was a way to have it organized that only 1 copy of such files is produced?
From what you're said I can only assume you're using the Image widget and given the referenced post, that you might be using an older version of GWT.
I've worked with GWT 2.1 extensively and not knowing what you're trying to do it might be a worthwhile to check out these out:
Declarative Layout - to design multiple pages (Check out #UiTemplate)
ClientBundle - (See ImageResource)
Depending on the size of the images, you can use this approach to reduce the number of trips to the server by either using image sprites or in-lining it altogether. (Note: IE8 has an in-lining ("data:") has a size limitation of 32KB).
Why are you concerned with the generated UI Image components being duplicated? What problem are you trying to solve here?
For all image components which you supply, you can always put them under war/images and they will be shared.

Getting an image from a game model

So I'm not 100% sure if it's possible, but what I'd like to do is take a model that someone has created for a game, say in Blender or something similar, in various formats, and from that create an image to show on a website.
Are there any Java libraries around that could help me with that? Java3D maybe? Or even something in Flash? Ideally you'd be able to rotate the model in some embedded flash app, but I'd settle for a plain old image.
It depends on how far you want to go. Most models are going to be in a standard format- or can easily be converted to be - and most 3D Apis are able to load these formats in.
It would be a little unusual to do this on a server - you may even need to have OpenGL installed on it - but it should be quite easy to load a model in to a 3D environment and take a snapshot or a series of snapshots quite easily. Possibly even use these to create a short video clip of a complete turn around the model. If you're using Java take a look at some of the things people are working on over at http://www.javagaming.org/ - I don't know that Java3D is in use much still but there are other good 3D java environments around. JMonkeyEngine looked most interesting last time I was exploring that area.
Alternatively you probably can set up a way of loading the model into a clientside environment - I don't know if Flash can do 3D stuff now, but Shockwave certainly can ( although it's horrible to work with ) and I believe the Silverlight stuff likewise. Of course unless you are pregenerating your animations you are likely to be passing the model to your display logic on the client and a savvy user could intercept that, but the risk is probably reasonably low and from your question it's not clear whether that would be a problem to you.
Take a look into this post:
http://techblog.floorplanner.com/2010/01/25/introducing-asblender/
"Enter ASBlender, a library I slapped together in a few days to read Blender’s .blend file format and parse it to AS3."
lucky you! ;)
EDIT: added link for the project:
http://github.com/timknip/asblender
EDIT2: With the asblender library you can parse directly the .blend file (this is the working file, not a exported file format). Once you have the file inside the flash application you can use Papervision (I believe you do the same with other 3d libraries) to render the model, this way you can do a single image of the model or you can let user to see the model rotating. Beware that any of this libraries won't give the same render quality that a 3D application like blender is capable of. The good thing about this library is the capability of reading all the info in the scene, so you can match cameras and lights to be as close as possible to the original .blend file.
Alternatively there are also other parsers like Ase, Collada , DAE, KMZ, Max3DS, MD2, Sketchup, SketchupCollada... all of this inside papervision library.

Making a redistributable component or library for Android

I'm just starting out on Android and Java programming, coming in from a C++ background. I was wondering - whats the best way to go about making a library/UI widget/component that I can license to third-party developers?
In C++ I'd ship the customers my headers and *.a files, but I don't know the equivalent in Java.
Are there any good resources or links about this, maybe even from general Java development standpoint.
you can define activities/services that are available for any other application running on android:
"A central feature of Android is that one application can make use of elements of other applications (provided those applications permit it). For example, if your application needs to display a scrolling list of images and another application has developed a suitable scroller and made it available to others, you can call upon that scroller to do the work, rather than develop your own. "
http://developer.android.com/guide/topics/fundamentals.html
Activities and services have some use but there is a whole class of functionality (fancy table viewer for sql) that isn't covered. You can do jars but I don't think you can have android resources in that file. The work around would be to have a Jar and require the user to copy and paste some text into the apps resource directory. You can look at the admob.com android SDK for an example of this.
Not sure about how Android handles this, but the typical distribution of Java code is a .jar file. A .jar is basically a zip file containing all of the compiled .class files in a Java project. There might also be resource/text/etc. files within the .jar. There is no concept of a header file in Java, so all you need are the .class files, and possibly a manifest file to provide some additional meta info about the .jar.
http://java.sun.com/docs/books/tutorial/deployment/jar/
(This is just a general Java answer, it may or may not apply to Android)

Categories

Resources