BlowTorch Chat Window Plugin
Filter that text! Also yank it out of the main output window and put it in its own littler window where it won't get scrolled away.
The chat window plugin is a pretty simple script, but it has many examples of how to get things done on Android with Lua.
Installation Instructions:
1) Download the zip file archive from this link [http://bt.happygoatstudios.com/test/chat_plugin_package.zip]
2) Unzip the contents to /BlowTorch/plugins/<chat_plugin, or whatever you want to call this or add to organize plugins>
I personally use /BlowToch/plugins/aardwolf/chat_plugin
3) If you are using a device that uses a physical sdcard that needs to be unmounted by windows and remounted by Android, do that now. If you are on a device like a galaxy nexus that uses the media device mode in windows, you may need to trigger a media scanner refresh in order for the files to actually "show up" in BlowTorch.
4) With an active connection open, select Plugins from the menu list.
5) Press the Load button in the lower left.
6) Browse to the XML file, this dialog starts its search to /BlowTorch/plugins/, it will only show .xml files that successfully parse plugins from xml files, and directories.
7) Click on the item from the list, it should have a grey plugin, and then press Install Plugin
For aardwolf users: this is set up to use the chat tags, so make sure that "tags channels on" is set. See the description below of how the trigger works.
This will tell the BlowTorch core to add that file as an external plugin, and to parse and use its contents when the settings are loaded.
Basic Usage:
The chat plugin window will always insert itself above the main output window and below the top edge of the screen. Below is a list of common UI actions that can be performed.
- Finger down and drag up or down - this will scroll text just like the main output window.
- Long press down - this will expand the window and reveal the toolbar.
- Long press down (while the window is expanded) - this will initiate text selection
- Toolbar Buttons (from left to right)
- Resize - touch down on this button and drag up or down to adjust the "expanded" height of the chat window.
- Filter tabs - Click one of these to filter the chat text by the channel. Channel names are harvested from the chat tag.
- "Main" filter - This is to view all chat data unfiltered.
- Hide - This button will hide the toolbar buttons, retaining any changes made via the resize or filter tab selection.
- New entry in the "Options" section of the main menu - with this plugin installed, a new entry is added to this list under the "Chat Window" category. It has the options for the unexpanded window height, text options like coloring, size and font. Plus this is also where the automatic updating option is.
Now here is a bit more about the anatomy of the plugin:
How it works:
There is one trigger doing all the work here, it looks like ^\{chan ch=(\w+)\} and it is designed to capture the chat tag and capture it's name in the capture group. There are 3 response actions to this trigger, the first is to replace the text, the second is to send it to the background script function processChat() defined in chat_server.lua, and then finally gag the line from the main output. The processChat() function looks for whatever is in the first capture group and will set up a sperate aggregate channel for just that tag, as well as notifiy the foreground UI process that there is a new tab in the tab list to sort the chats by.
For other text, if it does not matter to you that it is not aggregated into a channel, you can simply put a gag action on the trigger and use the "retarget" field to instruct blowtorch to gag the line and send it to the window that has that id, in this case it is "chats". So typing "chats" into the retarget field will gag the line from the main output, and send it to the other window, but since this bypasses processChat(), there is no tab or aggregation done.
there are 3 main files that make up the chat plugin:
chat_window.xml - This file contains the hard data for the configuration of the plugin, the triggers, windows, options and scripts. It contains some stub scripts that call doFile() to run the scripts that are included as individual files.
chat_server.lua - Contains the code relevant to bootstrapping, options handling and data processing. This is the script that is executed in the "background" and can not do anything "UI related" mostly all this script does is manage the buffers that are used to keep track of the chat data.
chat_window.lua - Contains the code relevant to setting up the window environment and handling the physical presentation of the data. Creates and manages the tabs as well as the animations to the expanded/shrunken state.
/icons/... - these are the density scaled graphics that are used for the button icons. The script builds a path from its installation directory and looks in here based off the screen density.