Sunday, September 13, 2009

The Birth of Tweaker

I'm working with kellewic over on WoWInterface. He has some great ideas for Tweaker, and I'm loving the feedback. But it's caused me to take some steps back and refocus on what I want out of Tweaker, so I decided to share its origin with everyone. I've gotten some great early feedback in the wowi comments, and I've gotten some other feedback that I'm not sure how to respond to, but I've not really gotten much overall, good or bad, constructive or otherwise, feedback from you about what you want and what you think. So after reading this, I'd like to hear what everyone thinks about Tweaker currently and about where they'd like to see it headed.

So about a month ago, I was using Cartographer. Great addon, ckknight is vastly talented, but when you're running 200+ addons on a 3 year old machine, it gets to be a bit much. So I needed to reevaluate things. Cartographer was an area where I saw myself being able to slim down. My main interests were LookNFeel, GuildPositions, and ZoneInfo. Starting with the code for LookNFeel, I saw that it could be slimmed down greatly into its own addon that would simply tweak the WorldMapFrame with the settings that I wanted and be done. Virtually no memory footprint and no ongoing cpu usage.

After writing MapTweak to replace LookNFeel, I started working on MapZoneInfo (still a work-in-progress) to replace ZoneInfo. ZoneInfo uses numerous libraries that contain a wealth of information that, honestly, I don't care about. I cared about the level of the zone and the instances in the zone and their levels so I started tearing out the data and slimming it down to the few pieces that I wanted. Around this time, I started having some overlap... MapZoneInfo was adding information, like Cartographer does, beneath the name of the area at the top of the map. MapTweak was handling how that name should be displayed, but ZoneInfo would need to handle how this new bit of text would need to be displayed since it only existed if this addon was being ran -- MapTweak could look for it and configure it if it existed, but then what if someone used MapZoneInfo without MapTweak? There'd be no way to tweak the text. I started entering some gray area that I didn't like.

I moved on to kgPanels. I've enjoyed this addon for a long time, but there were some major flaws I was finding about it. As shown in earlier tutorials, the "border" on my panels is really just a flat, square texture. So to do this in kgPanels, I needed 2 panels. Because of the layering, the image became a third panel. Now for every panel I wanted, I needed to make 3. The list got huge. I started using the OnUpdate event to do things like positioning, because kgPanels doesn't support more than one anchor and I wanted my panels to be anchored TOPLEFT and BOTTOMRIGHT of their parent. That meant more CPU usage on top of what kgPanels was already using.. which wasn't insignificant. kgPanels doesn't have any type of consistent naming of its panels, despite supplying a name, so there was no way to reference panels. I tried events like OnLoad instead of OnUpdate, but OnLoad never fires since the widget is already loaded by the time that script is set. Problem after problem.. there had to be a better way.

Now, I don't want to condemn kgPanels. It's still a great addon. Most of these problems are simply the problems that I began to face with current addon design, which is why I thought it was time for change.

Tweaker was originally named CustomPanels, and it was designed to be a supplement to kgPanels. Like my previous addons, it had a config.lua file to create settings for it, but obviously its settings had to be a bit more robust... supporting real frames with multiple textures, fontstrings, and anchors. So as not to lack something that kgPanels had, I also included events. As I used it and tweaked it, my aspirations grew. Instead of a fixed number of settings, I allowed anything that the Widget API would allow so that the addon could grow alongside WoW, including the addition of allowing the user to create not just frames, but any type of widget. Frames were originally named CustomPanels_ where was the name supplied in order to avoid naming conflicts, but I realized that if I was able to create any type of UI element I wanted at this point, how hard would it be to tweak existing ones? So I dropped the CustomPanels_ part and allowed the config.lua file to specify the name of an existing UI element and tweak it. This is when Tweaker was truly born.

I realized now that Tweaker could do everything that MapTweak could do for the WorldMapFrame.. and more.. or less. Users could modify anything they wanted in any way that they wanted. It was no longer a simple addon, but the start of a framework. And, truthfully, it wasn't much different from just writing XML and LUA, but I felt that it was different enough, simplified enough, to continue on. And with the addition of tutorials specifically geared at Tweaker, any person could tweak their UI in common ways and even learn a little coding while they're at it.

So I've come to a crossroads now. This blog is insufficient for Tweaker, and I'm working on a website. More importantly, the simple "run your settings and be done" execution is no longer sufficient for Tweaker, in my opinion. kellewic has proposed code to help turn Tweaker into a full-fledged framework that external addons could use. And truth be told, I like it.

BUT, I don't want Tweaker to become a library. I don't want that bloat. I don't want multiple versions running around in memory. I don't want addons packaging Tweaker inside themselves in order to create their own "Tweaks" because that defeats the whole purpose of Tweaker. What that creates is what we have now.. where addons offer limited options for customizing how they look, and the more options available, the more memory intensive, cpu intensive, and bloated the addon becomes. The only difference would be that the addon authors would be using Tweaker instead of their own custom code, and that doesn't help the user. In fact, it would be more bloat for addon authors to use Tweaker for it than to do it themselves, and I trust their knowledgeable enough to do it themselves, so that's not going to happen.

What I do want is Tweaker addons... or modules. Addons that require Tweaker in order to run and use the Tweaker framework to do their stuff. This would solve a few problems and create a few nice advantages.

  • I would still support config.lua inside of Tweaker, but people would also have the option to create, for instance: MyTweaks, a custom set of Tweaker tweaks just for you and your UI. By having them separate from Tweaker itself, you no longer run the risk of losing your config.lua because I stupidly packaged my config.lua into the Tweaker.zip file when I released it. I've done it once before.. the problem was fixed before the admin got around to approving it, but there's always that risk there. More importantly, I would personally use this method for my tweaks so, fingers-crossed, I wouldn't even have a config.lua in my Tweaker folder that could accidentally get packaged up, and thus anyone using config.lua inside the Tweaker folder wouldn't have to worry about theirs getting overridden.
  • While I'm not a huge fan of UI Packages, this would also allow people to package their UI tweaks inside of a UI package. One of the problems I have with UI packages is the issue of resolution. If yours doesn't match the UI packages author, the package likely won't work for you. But one thing I did with Tweaker is make my UI fit a number of UI resolutions (not any, but anything from slightly smaller than mine to any size bigger should work because my ChatFrame and Recount stretch to fill the remaining space -- too small and Recount will squish too much though). Also, anyone familiar with Tweaker will be able to tweak the UI package further without the package author trying to supply some kind of custom addon for tweaking things.
  • My config.lua file is getting huge... this would allow me to break it up into multiple files. And thanks to this, my tutorials could be packaged up and be downloadable. People could download my tutorial for tweaking the world map and then play with it to get it looking how they want as their WorldMap_Tweaks addon. Other people that create fun tweaks to their addons could package those tweaks up and also distribute them more easily for anyone else that uses the same addon.
  • Tweaker currently exposes a bit of a global API, but that API cannot be used in certain parts of the config.lua file. Tweaker assumes that Tweaker_Data exists before it starts, so config.lua is put into memory before Tweaker.lua, thus, before the global API. This would completely solve that problem.
  • Once a tweak is made, it's done. Further modifications to the tweak can only be done using standard Wiget API calls with standard lua code. With a full-fledged framework, Tweaks could be modified at any time and then re-processed by the framework, making the necessary modifications to the widget in the same way it currently modifies any pre-existing widgets.

Of course there are downsides. More memory and CPU usage, for one. I'd make it as minimal as possible, but it would go beyond my original plans for Tweaker. However, that said, I think it's plain to see that Tweaker is no longer what it was originally intended to be, it's no longer CustomPanels. It might be time to embrace that and go all out. Tweaker is what you make of it. If you design your tweaks to be run-once-and-stop tweaks then the performance hit will be very minimal. If you need them to do something on every OnUpdate, that that's the price you pay for the functionality you're getting out of it. Performance will largely be in the hands of the user.

Please, leave me some comments. Let me know what you think. Let me know how Tweaker can best serve that thing you've been wanting to do to your UI for all this time and haven't gotten around to yet.

No comments:

Post a Comment