Thread Tools Display Modes
02-21-15, 06:56 PM   #1
vaindil
A Murloc Raider
 
vaindil's Avatar
Join Date: Jan 2015
Posts: 6
Question Creating a window and manipulating it

I've had an addon idea for a long time and I'm finally getting around to trying to code it up. I'm starting very small but I hope to work up to an awesome addon.

The CurseForge page is here, and I think the description sums up pretty well what I want to accomplish.

My first step is to just get a window to open (default Blizzard UI theme is fine) where the user can enter a task, specify whether it's daily or weekly, then add it to their list of tasks. I'd like to break the display (same window for now) into two sections, with the daily tasks on top and the weekly underneath. I don't need sorting yet other than that; I'll figure out the sorting later. The user can check a box or click a button or something to indicate that the task has been completed, and then the next day/week the task will reset itself.

I've never used Lua before but I'm familiar with coding so I'm not too worried about it. The problem is the UI. I have never coded anything with a UI before, only command line programs. I spent several hours today trying to figure out how frames work, but the furthest I got was getting a translucent white rectangle to toggle visibility based on a chat command.

Are there any good tutorials on frames/UI/windows in general out there, or would someone be willing to give me a quick rundown? I'm definitely NOT asking for my description above to be written for me; that's just there to illustrate my current goal.

Any advice at all would be greatly appreciated, including if you have suggestions about ways I should change my description above to make things simpler. I'll be honest, I'm graduating with a degree in computer science in a couple months and not being able to figure this out has me pretty bummed out. :/

Thank you!
  Reply With Quote
02-21-15, 11:26 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
First, unless you're already used to working with XML from your other programming life, don't use it. It's overly verbose, ugly, annoying to write and debug, and just adds another new syntax to get used to and more files to work with. In terms of the WoW API, virtually everything you can do in XML can also be done in Lua much more concisely, with the added benefit of getting clear error messages when you make a typo or do something wrong. (If you don't already have an error-catching addon, get one. The default UI can show you (most) error messages, but it's pretty limited, and not very user-friendly.)

Second, there aren't really any comprehensive tutorials out there that I'm aware of; most of us just learn by example, and by looking at the documentation for specific functions and methods. Pick another addon's window, or even some part of the default UI, that looks sort of how you want your window to look. Go look at the code that creates that window, figure out how it works, and use it as a guide to creating your own window.

Don't try to do everything at once. Start with the basics; you say you've already got a frame with a transparent white background. Now try adding a textured background and border. Then add a font string to display a title. Then add a close button. Work your way up.

Finally, looking at your current code from CurseForge, you're loading your Lua file twice -- once in the TOC file and once in the XML file. You only want to load it once. Even if you really want to continue using XML, I'd recommend loading all your files from the TOC file only, so you can see what's being loaded all in one place.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
02-22-15, 06:14 PM   #3
vaindil
A Murloc Raider
 
vaindil's Avatar
Join Date: Jan 2015
Posts: 6
Smile

This is exactly what I needed to get going. I was viewing the whole project as one enormous task to undertake when I should just be taking it slowly. I was planning to use Lua as much as possible as opposed to XML; Wowpedia's guide heavily implied that the XML file was required which is why I had it that way. I also found a how-to on Wowpedia that covered the basics of creating frames, and I was able to extrapolate from the XML to Lua functions. My repository now has today's committed code, which has a working window triggered via slash commands, a title box, and a close button, all using the Blizzard UI.

Thank you so much, I really appreciate it!
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Creating a window and manipulating it

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off