Guide needed

Mar 30, 2011 at 11:05 AM

Is there any guide on how to build a simple addon?

I mean, a step-by-step document droppin' a frame and a button, adding a command to the button click and then compile and deploy on c:\wow\interface\addon\myaddon\ ?

I search all the site but i didn't find it, and the homepage faq isn't that explaining.

Thanks

Apr 6, 2011 at 11:19 PM

Ok hold on :)

 

Apr 6, 2011 at 11:43 PM

If you use AddOn Studio here is an example...

In this example we will make a new AddOn named Bob, and a Button named Grumpy :)  These instructions are for v1 and v2 of Wow AddOn Studio.  With AddOn Studio 2010 ther are fewer issues but this should still basically work, so long as you have installed the blizzard toolkit.

1. Start AddOn Studio

2. Create a new Frame project named Bob.

- this should create a new solution and project named Bob, and you should now see a XMLFrame designer view with a small sized frame staring at you.

3. Find the ToolBox and drag a Button to somewhere inside the frame

- you should now see a red button in the frame named something like Button1

4. Change the Label for the button to "Grumpy" by finding the Test propery and changing it to "Grumpy" 

5. Double-Click the Grumpy button to edit a new event.

- you should see the Frame.lua file open with a place to add code for an event.

6. Add helper code to write to the console.  Above the event handler function add this code:

BobUtility = BobUtility or {

}

function BobUtility:Print( msg, r, g, b, frame, id, addToStart )
 (frame or DEFAULT_CHAT_FRAME):AddMessage(msg, r or 1, g or 1, b or 0, id or 0, addToStart)
end

7.Add event handler code to your event handler function.  Add the code below so that your event handler contains the code.

    BobUtility:Print("Bob is Grumpy...");   

 such that you end up with someting like:


-- Author      : Bear
-- Create Date : 3/8/2011 3:08:04 PM

BobUtility = BobUtility or {

}
function BobUtility:Print( msg, r, g, b, frame, id, addToStart )
 (frame or DEFAULT_CHAT_FRAME):AddMessage(msg, r or 1, g or 1, b or 0, id or 0, addToStart)
end

function GrumpyButton_OnClick()
    BobUtility:Print("Bob is Grumpy...");   
end

in your Frame.lua file

8. Click the save all button.

9. Right click the project and click "Build"

10. Start wow

11. After logging in but before entering he world, open the "addons" screen by clicking the addons button. Enable loading out of date addons.  Ensure that Bob is checked. Exit the addons screen.

12. Enter the world

13. You should see your addon wiht a grumpy button, and when you click the grumpy button is should read Bob is grumpy.." in the main chat window.



Apr 6, 2011 at 11:55 PM

Gotta love the paste formatting :)

If you are using AddOn Studio 2010, you can skip the ToolKit install and the enable outdated addon thing and serveral of the other steps.

So the real tutorial is this if you are makign al this by hand:

You need one frame with one button and one event handler.

You also need one folder to put all this in, and one .toc file where the name of the file matches the folder.

The Toc file needs serveral lines in order for it to work.

1. Make a folder named Bob in a folder called say Projects, somewhere other than in wow. LIke c:\Projects

2. Right click in the folder, click new->text file.

3. Rename the file to bob.toc

4. Open the file with notepad

5. Put the minimum in the .toc and save it:

## Title: Bob

## Version: 1.0

## Author: Bear

## Interface: 40000

Frame.xml

 6. Make another text file in the Bob folder named Frame.xml

 7. Make another text file in the Bob folder named Frame.lua

 8. Open the the Frame.lua file and place the code below, which is the same as the code above and then save the file:

</Ui

>

 

more....

-- Author      : Bear
-- Create Date : 3/8/2011 3:08:04 PM

 

BobUtility = BobUtility or {

}
function BobUtility:Print( msg, r, g, b, frame, id, addToStart )
 (frame or DEFAULT_CHAT_FRAME):AddMessage(msg, r or 1, g or 1, b or 0, id or 0, addToStart)
end

function GrumpyButton_OnClick()
    BobUtility:Print("Bob is Grumpy...");   
end

9. Open the Frame.xml file in notepad and place the code below.  All wow frame xml files need this xml wrapper.

<Ui xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.blizzard.com/wow/ui/">

 

Apr 7, 2011 at 12:08 AM

discussion here isnt really handling the pastes very well...

the end tag is:

</Ui>

Such that you end up wiht three lines:

<Ui xmlns: ...>

</Ui>

This creates a wrapper for members of the blizzard UI, which we will add Ui elements to.

10. Create a new bare minimum frame with a meduim size placed inside the Ui element:

  <Frame name="Frame1" parent="UIParent" toplevel="true" enableMouse="true">
  <Size>
   <AbsDimension x="347" y="379" />
  </Size>
  <Anchors>
   <Anchor point="CENTER">
    <Offset x="-43" y="-11" />
   </Anchor>
  </Anchors>
  <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
   <BackgroundInsets>
    <AbsInset left="11" right="12" top="12" bottom="11" />
   </BackgroundInsets>
   <TileSize>
    <AbsValue val="32" />
   </TileSize>
   <EdgeSize>
    <AbsValue val="32" />
   </EdgeSize>
  </Backdrop>
  <Frames>
  </Frames>
  <Layers>
  </Layers>
 </Frame>

Frame is one of the allowed elements in the Ui element.  So this is where we create our frame.  The frame needs a size and a position, which is sort of basically obvious where that is in the above code.  Also you must have a texture in order for it to look like a standard blizzard frame.  You do not need a texture and ther are hundreds of ways to give frames someting to draw to show up in he UI, but this is probalby the easiest for our example. Also, technically <Frames> and <Layers> are required elements of a frame, and should be added even if you have nothing in them. Naming a frame must be globally unique among all names for all addons runnning in wow, and Frame1 is not really the best idea, hwoever we can get away with it for our example.

11.  Save everyting and copy the Bob folder itself to Interface/AddOns in your wow install folder.

12. Start wow, login and enter world.  You should now see your bare frame.  You wil have no way to close it or move it of course ;)

13. Close wow.

more....

 

 

Apr 7, 2011 at 12:21 AM
Edited Apr 7, 2011 at 12:22 AM

14. Open the original Frame.xml agian, if it ist still open in notepad, and now add a button inside the <Frames> element:

   <Button name="GrumpyButton" inherits="UIPanelButtonTemplate" text="Grumpy">
    <Size>
     <AbsDimension x="75" y="28" />
    </Size>
    <Anchors>
     <Anchor point="TOPLEFT">
      <Offset x="142" y="-332" />
     </Anchor>
    </Anchors>
    <Frames />
    <Layers />
    <Scripts>
     <OnClick>GrumpyButton_OnClick();</OnClick>
    </Scripts>
   </Button>

The <frames> element inside a <frame> allows you to add child frames, such as buttons, making them children of the frame.  In our case Button GrumpyButton is a child now of Frame named Frame1.  Notice that button frames use a button element <Button> instead of a <Frame> element, though a Button is still a frame. :)

12. Add a reference to the Frame.lua file to the Frame.xml file.  This allows the frame.lua to be loaded just after frame.xml starts to load, and so that its functions can be available for the frame.xml event handler to call.  Add this line below the <Ui xmlns:..> line:

  <Script file="Frame.lua" />

13. Save everyting and copy the Bob folder itself to Interface/AddOns in your wow install folder, overwriting the old contents of the Bob folder inside wow AddOns.  Your final xml file should look like this:

<Ui xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.blizzard.com/wow/ui/">
 <Script file="Frame.lua" />

 <Frame name="Frame1" parent="UIParent" toplevel="true" enableMouse="true">
  <Size>
   <AbsDimension x="347" y="379" />
  </Size>
  <Anchors>
   <Anchor point="CENTER">
    <Offset x="-43" y="-11" />
   </Anchor>
  </Anchors>
  <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
   <BackgroundInsets>
    <AbsInset left="11" right="12" top="12" bottom="11" />
   </BackgroundInsets>
   <TileSize>
    <AbsValue val="32" />
   </TileSize>
   <EdgeSize>
    <AbsValue val="32" />
   </EdgeSize>
  </Backdrop>
  <Frames>
   <Button name="GrumpyButton" inherits="UIPanelButtonTemplate" text="Grumpy">
    <Size>
     <AbsDimension x="75" y="28" />
    </Size>
    <Anchors>
     <Anchor point="TOPLEFT">
      <Offset x="142" y="-332" />
     </Anchor>
    </Anchors>
    <Frames />
    <Layers />
    <Scripts>
     <OnClick>GrumpyButton_OnClick();</OnClick>
    </Scripts>
   </Button>
  </Frames>
  <Layers>
  </Layers>
 </Frame>
</Ui>

14. Start wow, login and enter world.  You should now see your frame with a "Grumpy" button.  Clicking the grumpy button will cause a message to be printed in the chat window about how bob is grumpy.

Apr 7, 2011 at 12:27 AM

Whats important to remember is that wow and its scripting and ui constructs are part of a retail game, where those types of things are typically very realworld and fairly complex given the nature of game development and the usual chain of tools that are common in the game development world.   The wow ui scripting concept is extemely polished relative to most others, however its its still an environment supporting a massive game application and both using and learning wow UI programming can still be very complex and well... a little gamey. :)   

Apr 7, 2011 at 12:45 AM
Edited Apr 7, 2011 at 12:57 AM

Reminds me..  released a new AddOn Studio 2010 today where I finally got the performance resonable for medium to large size projects using hte FrameXML designer. This is basically why i went poking around and saw this and thought be a good time to answer the question that always pops up that no one really ever answers, "How to I start an addon... really?".

After this performance tune marathon... I also have quite a few various and sundry comments to make about windwos forms, designer/tree/properties, type and property descriptors and the underlying VS extensibility patterns around them, though this probalby isnt the correct forum to rant/rave about that :)  I will say that I managed to push a model with probably over 1k base cached types from blizzard content as well as pushing a designer model hierarcy with  1-3k descriptors and with reasonable usablity rendering and modifiable more or less in real time. I do have words about how VS, Forms, and the CLR 4.0 Lib stack could push scalability, modeling much bigger things if they wanted to, but that will be for another place. :) 

Lastly, after going through that and then loading the blizzard toolkit as a web project inside AddOn Studio 2010, then playing wiht the toolkit elements along with my wow test projects, almost debugging AddOn Studio form the inside out... if dawned on me just how far you could take VS into a whole nother world if you/they wanted to...  I mean forget the 11th billion debugger / profiler / reportgenerator / X/Y/Z# [insert language here] isolated product.  Personaly kind of tired of product suites like Adobe and the like where it like running around opening and closing windows contantly and checking every 30 mins or so how much memory i have left....   I mean it felt for a moment where I was in another world inside a product type that was from far in the future.  That or im jsut really tired... :)

Apr 7, 2011 at 12:48 AM

Forgot the link:

http://www.wowwiki.com/AddOn_Studio_2010

Jun 24, 2011 at 4:35 AM
Edited Jun 24, 2011 at 4:51 AM

Where is the latest source code for addon studio 2010? ...