dim3 Forum

Full Version: Choosers
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Could someone help me with choosers? I don't understand them. I've seen the dim 3 demo's chooser and I don't really understand how to make one from scratch.

Please help!
Sam Shiels Wrote:Could someone help me with choosers? I don't understand them. I've seen the dim 3 demo's chooser and I don't really understand how to make one from scratch.

Please help!

Simple quick explanation:

[1] In interface.xml, look at this spot:

Code:
    <Choosers>

        <Chooser name="MapChooser">
            <Items>
                <Item id="0" file="map_title" x="192" y="18" clickable="false" />
                <Item id="100" file="demo" x="30" y="140" clickable="true" />
                <Item id="101" file="deathmatch" x="256" y="140" clickable="true" />
                <Item id="102" file="ctf" x="482" y="140" clickable="true" />
                <Item id="103" file="cancel" x="256" y="325" clickable="true" />
            </Items>
        </Chooser>
            
    </Choosers>

Each chooser is named (in this case "MapChooser"). When you run it, it takes control of the UI, and when a user clicks a item, you get an event.

"clickable" tells if the item is a clickable item (otherwise it can just be a display bitmap.) "id" is the ID you'll get when the event fires. "file" is the name of the PNG, and "x,y" is the position. Setup your chooser here.

[2] Put all your PNGs in the Chooser directory.

[3] Run the chooser like this:

Code:
iface.interaction.startChooser('MapChooser');

[4] When an item is clicked, you get this event:

Event Type = DIM3_EVENT_CHOOSER
id = ID in the XML

Look at game.js for an example.

[>] Brian
Great! Thanks!
Reference URL's