Cursor Animation and Mouse Management framework

A simple yet powerful framework to manage both harware and software mouse with ease. Allows for setting cursor animation on both software and hardware mouse. Support for easy to make cursors using image files, descriptor textfile and zip.



FEATURES

  • managing software and harware mouse via a single CombinedMouse class
  • transparent switching between harware and software mouse
  • cursor animation for both sofware and harware mouse
  • loading a cursor using simple text-based descriptor file
  • loading a cursor from a folder
  • loading a cursor from a zip file (if you want to keep things in one place), works for zips inside jars.
  • flipping cursors by the multiples of 90 degrees
  • hiding or immobolizing mouse from any mode (both harware and software)
  • managing cursors and mouse using MouseManager class with a very simple interface



    Edit: hosting changed to http://code.google.com/p/jmeaddons/

New release with some minor changes: http://www.fileupyours.com/files/111058/mouseManager_b1.zip

Fix for compatibility with the new jme update (mainly because of TextureKey changes):

http://www.fileupyours.com/files/111058/mouseManager_b2.zip

your animated cursor method has been added to LWJGLMouseInput in CVS, so no need to patch jme anymore…

Thanx Mr.Coder!

Is there a way to make that a standard method of MouseInput? At the moment the only two classes that implement mouse input are LWJGLMouseInput (patched) and AWTMouseInput that  dose not change cursors (it has a method that simply ignores any attempts to change the cursor).

sure thing, that is now in cvs as well…

And, is there a way to change the InputEvent… just kidding

Sorry I wasn't very clear the first time.



Thanx, MrCoder! :slight_smile:

phuh :wink:

Lex, i

When I read this I remembered that I developed a test GameState of my own at an earlier stage when I was evaluating FengGUI.  Here it is if you find any benefit of using it:


package test;

import java.io.*;

import org.fenggui.*;
import org.fenggui.composites.*;
import org.fenggui.io.*;
import org.fenggui.layout.*;
import org.fenggui.render.*;
import org.fenggui.render.lwjgl.*;
import org.fenggui.xml.theme.*;

import com.jme.system.*;
import com.jmex.game.state.*;

/**
 * @author Matthew D. Hicks
 */
public class FengGameState extends GameState {
   private Display display;

   public FengGameState() throws IOException, IOStreamException {
      init();
   }

   private void init() throws IOException, IOStreamException {
      display = new Display(new LWJGLBinding());
      display.setDepthTestEnabled(true);
      Binding.getInstance().setUseClassLoader(true);
      FengGUI.setTheme(new XMLTheme("data/QtCurve.xml"));

      Window frame = new Window();
      display.addWidget(frame);
      frame.setX(20);
      frame.setY(350);
      frame.setSize(200, 100);
      frame.setShrinkable(false);
      //frame.setExpandable(true);
      frame.setTitle("Woehl a Foarb...");
      frame.getContentContainer().setLayoutManager(new StaticLayout());

      ComboBox<String> list = new ComboBox<String>();
      frame.addWidget(list);
      list.setSize(150, list.getMinHeight());
      list.setShrinkable(false);
      list.setX(25);
      list.setY(25);
      list.addItem("White");
      list.addItem("Green");
      list.addItem("Blue");
      list.addItem("Red");
      //list.getPopupList().getToggableWidgetGroup().addSelectionChangedListener(new CBListener());

      //try to add TextArea here but get OpenGLException
      TextEditor ta = new TextEditor(false);
      display.addWidget(ta);
      ta.setText("Hallo Text");
      ta.setX(40);
      ta.setY(50);
      //ta.setSize(100, ta.getAppearance().getFont().get)
      ta.setSizeToMinSize();

      // Update the display with the newly added components
      display.layout();
   }

   public void update(float tpf) {
   }

   public void render(float tpf) {
      //DisplaySystem.getDisplaySystem().getRenderer().clearBuffers();
      display.display();
   }

   public void cleanup() {
   }
}



It's very obviously testing code, but may provide something to you. ;)

thk you darkfrog…ill try it.



[edited] It doesn

First of all, the mouseManager and the handler were not designed for multithreading… Testing in multithreaded environment is needed.



As for the GUI: my guess is you have to modify some code in strategicHandler and use your own version of MouseManger that uses FengGUI handler and CombinedMouse. The easiest way would be to extract the MouseManager as an interface and then implement it. Also, you will have to adapt some code to work in the multithreaded environment (if the testing reveals any problems).



I will look at the multithreading issue and the GUI integration, and probably write the appropriate classes and fixes. However this might take up to two weeks as I am tied up with work at the moment. If you beat me to it, please share it :wink:

I

I have been looking the issue of integrating the stategicHandler with FengJMEInputHandler…

Have you tried adding strategicHandler as an attached handler to fengGUI, like this:



FengJMEInputHandler fengHandler;
StrategicHandler strategicHandler;

// init your handlers, etc

fendHandler.addToAttachedHandlers(strategicHandler);
// from now on you only need to do fengHandler.update()



or the other way around, adding fengHandler to strategicHandler as an attached handler... it should work both ways.
Let me know if this works. Also let me know if the handler is working in multithreaded environment without any bugs (if it has bug, then what are they).

No, its equals…



The FengHandler uses a MouseListener… and it get ativated when we get the NativeMouse in CombinedMouse.

Can you be more specific. I'm having trouble understanding you from just two short sentences.


No, its equals...

What is equals?

and it get ativated

Does the MouseListener get activated when it's supposed to or does it get activated when it should not?

when we get the NativeMouse in CombinedMouse.

Do you mean when you select / activate the NativeMouse? What happens when you are using SoftwareMouse?

Yes, the MouseListener seems to just work with NativeMouse(HardwareMouse?).



When i am using the Software Mouse, it doesn

Ok, I have managed to itegrate with FengGUI as much as possible. Further integration will only happen when FengGUI developers introduce features I have asked for on their forums.

Currently both software and hardware modes work provided you do not change the cursor or change modes.



Right now I'm improving some functionality in cursor loading and my build is half-broken. I will release the next patch when its done.

Great work with this, but I think I've found a bug, I'm using neakors skydome and when the mouse is in software mode it fades in and out with the stars but it's fine in hardware mode.  Any ideas?

My guess this is because of alpha state used on the software mouse quad… Here are a couple of ideas on how to verify that:

  • You can setup an ordinary software mouse (AbsoluteMouse.class in jme) and test it with the same texture.
  • You can also play with the alpha state set during the initialization of the software mouse (SoftwareMouse.class in mouseManager.jar).



    If you do any of those, let me know what happens. I will also look into it, but you can probably do it faster, because you already have the setup.