Menu

Need suggestions on dismantling UI module

Help
Bhakta
2014-10-05
2014-10-13
  • Bhakta

    Bhakta - 2014-10-05

    Hello,
    As per my understanding I found out that the battle arena/canvas is built using applets. I want to port the battle arena (only) to webpage.
    So can anybody give me some inputs what should be my approach? Anything that I need to take care while removing applets from Swing components and its feasibility considering the complexity of Robocode.

    Thanks in advance,
    Bhakta

     
  • Bhakta

    Bhakta - 2014-10-07

    Flemming N. Larsen can you suggest anything in this regard?

     
  • Flemming N. Larsen

    For a start, you should have a look at the AwtBattleAdaptor in the net.sf.robocode.ui.battle package. The AwtBattleAdaptor adds it own BattleObserver to the IBattleManager in order to receive game events, like when the game is started, paused, stopped etc. The BattleEventDispatcher is used by the AwtBattleAdaptor in order to trigger event. For example, if the UI needs to pause the game, the method BattleEventDispatcher. onBattlePaused() method must be called.
    The AwtBattleAdapter is used by the WindowManager class.

    For your purpose, you'll need to implement some class that receives IBattleListener events in order to find out, what is happening to the game, and control the game using the BattleEventDispatcher, which fires events that control the entire game.

    You'll need to study the AwtBattleAdaptor to find out how it works.

     
  • Bhakta

    Bhakta - 2014-10-07

    @Flemming Thank you for the quick reply.... Currently I'm studying the code I have few questions.
    1> Most of the classes in the source code are not being instantiated (like WidowManager, RobocodeMain). Is there any specific methodology used to instantiate and track/pass the objects in between modules?

    2> Where is the linkage between UI and Engine ?

    3> From console o/p its clear that UI module gets loaded in the end, so which module is responsible for loading UI?

    4> If I want to add a new module to implement my requirement(applet based GUI for web page, only for battle view part), is there any protocol that I need to follow as far as module loading/arch of robocode is concerned ?

    Sorry for asking so many questions at a time. As there is not much documentation available I need these information.

     
  • Flemming N. Larsen

    1) Robocode is using PicoContainer, which is a lightweight framework for doing code injection in a simple but efficient way. Here interfaces are used as input parameters in constructors, which are then instantiated with a concrete class. The default binding is defined by a Module class for each module/project in Robocode. You can have a look at the Module.java from net.sf.robocode.ui.

     
  • Flemming N. Larsen

    2) I don't understand your question: "Where is the linkage between UI and Engine?". I hope I answered this part in my answer to your first question?

     
  • Flemming N. Larsen

    3) Modules are loaded by the Container class in the package named net.sf.robocode.core.

     
  • Flemming N. Larsen

    4) Robocode is not protocol based as it is now. It is "just" a plain Java application where code is split up in smaller more or less independent parts that we call modules. You should have a look at each module, e.g. robocode.sound, robocode.ui, robocode.ui.editor to get an idea of how it is put together.

    There is practically no documentation available for Robocode. It would be too big to write and maintain. The best documentation available is studying the code and hope that there is enough comments to understand what is going on. :-)

     
  • Bhakta

    Bhakta - 2014-10-13

    Thank you Flemming for your response I'll be look into the above details you have pointed out

     

Log in to post a comment.