Object-Oriented System for lua
1 Attachment(s)
Well, I want to introduce my lib addon 'IGAS'. Although it's just in beta, I thought it's time to bring it in.
In this addon, I built a object-oriented system for lua. Here is a sample code running outside wow. Code:
require "oop" Attachment 6467 Some information about this system: 1. three base data structure type class enum struct 2. Now base structs(WOW's structs not included) stored in global namespace: System.Boolean System.String System.Number System.Function System.Table System.Userdata System.Thread System.Any System.LocaleString 2. Now classes stored in global namespace: System.Object System.Threading.Thread System.Addon System.Addon.Module System.Locale System.Logger -- For wow System.Widget.UIObject System.Widget.VirtualUIObject System.Widget.AnimationGroup System.Widget.Animation System.Widget.Translation System.Widget.Rotation System.Widget.Scale System.Widget.Alpha System.Widget.Font System.Widget.Region System.Widget.LayeredRegion System.Widget.Frame System.Widget.Texture System.Widget.FontString System.Widget.FontFrame System.Widget.Button System.Widget.Cooldown System.Widget.ColorSelect System.Widget.EditBox System.Widget.GameTooltip System.Widge*****ssageFrame System.Widget.Minimap System.Widget.Model System.Widget.ScrollFrame System.Widget.ScrollingMessageFrame System.Widget.SimpleHTML System.Widget.Slider System.Widget.StatusBar System.Widget.CheckButton System.Widget.PlayerModel System.Widget.DressUpModel System.Widget.TabardModel System.Widget.ArchaeologyDigSiteFrame System.Widget.QuestPOIFrame System.Widget.MovieFrame System.Widget.NormalButton System.Widget.Timer System.Widget.ColorPicker System.Widget.DropDownList System.Widget.ScrollBar System.Widget.ScrollForm System.Widget.Form System.Widget.GroupBox System.Widget.List System.Widget.ComboBox System.Widget.SingleTextBox System.Widget.MultiLineTextBox System.Widget.TreeView System.Widget.TabGroup System.Widget.CheckBox System.Widget.PopupDialog System.Widget.MinimapIcon System.Widget.OptionSlider System.Widget.DataGrid For the first step, go here for a look: http://code.google.com/p/igas/wiki/IGAS_OOP If you like it, I may find a way to post more information about this in the future time, Now I'm working on a CodeEditor to fix my IGAS_Studio(The in-game IDE), just a little busy. |
Sample Addon to show the thread system, to count money you spent on the merchant for every time:
TestAddon.toc Code:
## Interface: 40200 Code:
-- make codes run under one addon's environment |
In all honesty, the existing API already does something like this.
lua Code:
You create a UI object known as a Frame. Through this, you can register for certain event callbacks to be received through the Frame's OnEvent handler. |
Although I'm not one to bash other people's work, I'm afraid you've wasted a great deal of time building this lib. As SDPhantom stated, the API is already object based and doesn't require anything added to it.
|
1 Attachment(s)
That's a sample code to show thread system, not event system, I know what I'm doing, the final goal is to make UI simple, just like this
Attachment 6482 the class system's inherit make creating widgets in an easy way. Code:
IGAS:NewAddon("TestA") http://wow.curseforge.com/addons/igas_studio/ The lib has too many things to explain, but I thought the base class system is the most important to start.I only have three more widgets to do now, after that, I just want see if any person want to join... |
If it's multithreading you're looking for, Lua has a built-in Coroutine lib that's supposedly available in the WoW API. See http://www.lua.org/manual/5.1/manual.html#5.2. However, Coroutines are only a psudo-multithread process. No other code can be run the same time a Coroutine is running.
Widget inheritence can already be done in the Widget API that WoW uses. This is done by creating a virtual frame in XML and using the inherits attribute when creating a copy of it in XML or passing its name in the inheritFrame argument of a CreateFrame() call. |
Well, thread is using to stop code running when needed, in many ways it save time to build an addon, I know one time one code running, so all the lua code.
As an example, in past development, when I need to used a popupdialog to confirm something, I need call the PopupDialog, and past a callback function to wait the popupdialog call it.But with the thread, I can do like this Code:
if IGAS:MsgBox("Are you sure to repair all items?", "n") then For the inherit, xml inherit has too many thing can't be done or hard to do, I have work on wow addons for more then five years, I know what the xml can do, and what it can't do.Ace also have ACEGUI, it's not built on xml, we all see the disadvantage in this xml system, although it don't have a full inherit system. I need a widget system with properties and methodes, making the addon's development just like we do in .Net. And that's all I do in this lib. Do you like frm.Visible = not frm.Visible or if frm:IsVisible() then frm:Hide() else frm:Show() end As computer, it's all the same.But to author, many things like this would make the development more flexible. |
It really comes down to programming style and system overhead. It's all a tradeoff between ease of writing code and running lightweight. It's like comparing ANSI C and VBasic.
BTW, I have been known to use this style of toggling. :p Code:
frame[frame:IsShown() and "Hide" or "Show"](frame); |
All times are GMT -6. The time now is 06:08 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI