Thread Tools Display Modes
08-05-11, 05:40 AM   #1
starlon
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 107
oUF_ScriptableText

I'm considering writing these oUF modules for WidgetBar, WidgetHistogram, WidgetIcon, etc... I don't use oUF though. If someone wants to give it a go, don't hesitate.

Code:
local parent, ns = ...
local oUF = oUF
local LibCore = assert(LibStub("LibScriptableLCDCoreLite-1.0"))
local WidgetText = assert(LibStub("LibScriptableWidgetText-1.0"))
local core = LibCore:New({}, "oUF_ScriptableText")

local Update = function(self)
	local fontstring = self.fontstring
	fontstring:SetText(self.widget.buffer)
end

local Enable = function(self, unit)
        -- note that row, col, and layer don't mean anything to us here.
	self.widget = self.widget or WidgetText:New(core, self.name, {
		value=self.value, -- the Lua script to run.
		update=self.update, -- How fast the widget will update.
		speed=self.speed, -- How fast marquee text will scroll.
		direction=self.direction, -- Left or right, 1 or 2.
		align=self.align, -- ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, ALIGN_MARQUEE, ALIGN_AUTOMATIC, ALIGN_PINGPONG = 1, 2, 3, 4, 5, 6
		cols=self.cols, -- How many columns wide the text should be. This is optional, and really only matters in marquees.
		prefix=self.prefix, -- A lua script for text prefix.
		postfix=self.postfix -- A Lua script for text postfix.
                -- WidgetText does its own updating, but that's optional as you can simply call widget:Update() in your own time.
		}, row, col, layer, errorLevel, Update, self)
	self.widget.environment.unit = unit -- This will be the 'unit' variable within the run environment.
	self.widget:Start()
	return true
end

local Disable = function(self)
	self.widget:Stop()
	return true
end

oUF:AddElement('ScriptableText', nil, Enable, Disable)
Sorry for the dry code.

__________________
Wake up Sheeple! Cataclysm was an inside job!

Legalize WoW gold purchases directly from Blizzard! Yeah, my doctor thinks I'm crazy too. >.<

"It was either going to school for programming or working at the Genetically Modified Wildlife Preserve. I've always had a love for the wildlife, but technology won out in the end."

Note: If you know of a library that you want to make available in your own scripts. let me know and I'll see about writing a plugin for it.

LCD4WoW
  Reply With Quote
08-05-11, 09:29 PM   #2
starlon
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 107
Here's oUF_ScriptableText's home for now.
https://github.com/Starlon/oUF_ScriptableText

Here's a marquee of your mana.

Code:
        local hp = CreateFrame("StatusBar", nil, self)
        -- do stuff to your health bar
        local fs = hp:CreateFontString()
        fs:SetFontObject(GameTooltipTextSmall)
        fs:SetPoint("BOTTOM", hp, "TOP", 0, 15)
        fs.value = "return Power(unit)"
        fs.speed = 100
        fs.update = 100
        fs.repeating = true
        fs.align = oUF.ALIGN_PINGPONG
        fs.cols = 20
        self.ScriptableText = fs
        self.core = LibCore:New({}, "oUF_Arl", 2)
__________________
Wake up Sheeple! Cataclysm was an inside job!

Legalize WoW gold purchases directly from Blizzard! Yeah, my doctor thinks I'm crazy too. >.<

"It was either going to school for programming or working at the Genetically Modified Wildlife Preserve. I've always had a love for the wildlife, but technology won out in the end."

Note: If you know of a library that you want to make available in your own scripts. let me know and I'll see about writing a plugin for it.

LCD4WoW

Last edited by starlon : 08-05-11 at 09:34 PM.
  Reply With Quote
08-06-11, 12:23 AM   #3
starlon
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 107
Here's for status bars.
https://github.com/Starlon/oUF_ScriptableBar

Each WidgetBar object will keep track of two bars, although this isn't fully implemented in oUF_ScriptableBar currently. In LCD4Linux design you could specify half the bar keep track of one cpu profiling aspect, and have the bottom half tell some other information.

In terms of LCD4Linux character display bars, the program used "special characters" provided by the LCD firmware which you can draw on. LCD4Linux calls them icons in another widget. They're 8x8 pixels large. LCDs typically come with 8 special characters you could store your bitmap in. Then you just print to the LCD the ascii value, which represents the special character memory space. Some have the special characters at the start of the ascii alphabet. I only tinkered with CrystalFontz and Pertelian, which both have their first special character pointed to by ASCII#0.

Character display bars could use half the special character for one widget bar, and use the top half of the special character for the widget's other bar. I'm not sure if LibScriptable's bar widget really needs two bars. Any thoughts?

One thing to keep in mind though is that DriverCharacter can draw its own fonts, so the "special character for bars" design can apply to DriverCharacter's own special character data. D; DriverCharacter is a simulation of a character display. Of course this would require LibCore instead of LibCoreLite, and it would have transitions, so you could display some bit of information for a few seconds, then scroll to a different widget face.

The only thing about this is it's a memory horse. You're going to use some memory. Any suggestions on how to trim away memory space are much appreciated. I'm going to make it so you can install LibScriptable in bits and pieces to create a bunch of addons for individual internal libraries, such as PluginLuaTexts, or WidgetBar.

Here's a WidgetBar provided by oUF_ScriptableBar. Note that some things like status bar texture, min and max values, color, length, height... it all updates at each refresh.

That's one thing I should mention. At the moment everything's just refreshed by a timer based on WoW UI animation groups. Any suggestions regarding how to update based on events would likely get some balls rolling. heh

Code:
        local mybar = CreateFrame("StatusBar", nil, self)
        mybar.expression = "return random() * 100"
        mybar.min = "return 0"
        mybar.max = "return 100"
        mybar.color1 = "return random(), random(), random(), 1"
        mybar.length = 100
        mybar.height = 15
        mybar.direction = WidgetBar.DIR_EAST
        mybar.orientation = WidgetBar.ORIENTATION_VERTICAL
        mybar.update = 200
        mybar.texture = cfg.tex
        mybar:SetPoint("BOTTOM", fs, "TOP")
        mybar:SetMinMaxValues(0, 100)
        mybar:SetStatusBarTexture(mybar.texture)
        mybar:SetValue(50)
        mybar:SetHeight(mybar.height)
        mybar:SetWidth(mybar.length)
        mybar:GetStatusBarTexture():SetHorizTile(true)
        self.ScriptableBar = mybar
__________________
Wake up Sheeple! Cataclysm was an inside job!

Legalize WoW gold purchases directly from Blizzard! Yeah, my doctor thinks I'm crazy too. >.<

"It was either going to school for programming or working at the Genetically Modified Wildlife Preserve. I've always had a love for the wildlife, but technology won out in the end."

Note: If you know of a library that you want to make available in your own scripts. let me know and I'll see about writing a plugin for it.

LCD4WoW

Last edited by starlon : 08-06-11 at 12:49 AM.
  Reply With Quote
08-06-11, 04:57 AM   #4
starlon
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 107
I guess I should point people to LibScriptable's home.

https://github.com/Starlon/LibScriptable-1.0

I recommend getting it straight from git. What's at Wowace may go away.
__________________
Wake up Sheeple! Cataclysm was an inside job!

Legalize WoW gold purchases directly from Blizzard! Yeah, my doctor thinks I'm crazy too. >.<

"It was either going to school for programming or working at the Genetically Modified Wildlife Preserve. I've always had a love for the wildlife, but technology won out in the end."

Note: If you know of a library that you want to make available in your own scripts. let me know and I'll see about writing a plugin for it.

LCD4WoW
  Reply With Quote
08-07-11, 01:19 AM   #5
starlon
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 107
Fixed a nasty bug (not really a bug, and not really a fix). But every widget needs a unique name. The examples I've shown here didn't give them a name. I was giving them all the name of ScriptableBar and ScriptableText. It'll go for ("ScriptableText" .. random()) now if nothing else is provided.
__________________
Wake up Sheeple! Cataclysm was an inside job!

Legalize WoW gold purchases directly from Blizzard! Yeah, my doctor thinks I'm crazy too. >.<

"It was either going to school for programming or working at the Genetically Modified Wildlife Preserve. I've always had a love for the wildlife, but technology won out in the end."

Note: If you know of a library that you want to make available in your own scripts. let me know and I'll see about writing a plugin for it.

LCD4WoW
  Reply With Quote
08-07-11, 02:47 AM   #6
starlon
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 107
You should be able to set events now.

Code:
mybar.events = {UNIT_POWER = true}
__________________
Wake up Sheeple! Cataclysm was an inside job!

Legalize WoW gold purchases directly from Blizzard! Yeah, my doctor thinks I'm crazy too. >.<

"It was either going to school for programming or working at the Genetically Modified Wildlife Preserve. I've always had a love for the wildlife, but technology won out in the end."

Note: If you know of a library that you want to make available in your own scripts. let me know and I'll see about writing a plugin for it.

LCD4WoW
  Reply With Quote
08-07-11, 03:12 AM   #7
Pyrates
A Cliff Giant
 
Pyrates's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 77
I'm not an expert on ouf or anything, and... I don't actually get what's happening here You've got my attention, though, would you mind explaining what you're doing in easier terms? I've sorta got that your scriptable library "provides lower level configuration", but the readme file is empty and I can't make heads or tails of all of this.
__________________
" ... and the Vogon will do things to you that you wish you'd never been born, or, if you're a clearer minded thinker, that the Vogon had never been born."
  Reply With Quote
08-07-11, 05:46 AM   #8
starlon
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 107
It's an interface to loadstring, allowing you to display returned data (returned from the user's Lua script) in various ways. I think that's the simplest I can describe it.
__________________
Wake up Sheeple! Cataclysm was an inside job!

Legalize WoW gold purchases directly from Blizzard! Yeah, my doctor thinks I'm crazy too. >.<

"It was either going to school for programming or working at the Genetically Modified Wildlife Preserve. I've always had a love for the wildlife, but technology won out in the end."

Note: If you know of a library that you want to make available in your own scripts. let me know and I'll see about writing a plugin for it.

LCD4WoW
  Reply With Quote
08-08-11, 03:57 AM   #9
starlon
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 107
I'm thinking I know very little about oUF's design... Initially I was testing with a single unit frame. When I try with multiple unit frames the unit gets mismatched with the player unit. >.<


Also, I think you're only allowed one oUF_ScriptableText at a time on each frame... You assign 'self.ScriptableText' and I don't see a way to add another. I thought about having ScriptableText1, ScriptableText2, etc.. but that's a terrible solution...

Edit: Ok, turned out I was creating many script environments and only wanted one... I did make some improvements though to both ScriptableBar and ScriptableText. I think it's working now.
__________________
Wake up Sheeple! Cataclysm was an inside job!

Legalize WoW gold purchases directly from Blizzard! Yeah, my doctor thinks I'm crazy too. >.<

"It was either going to school for programming or working at the Genetically Modified Wildlife Preserve. I've always had a love for the wildlife, but technology won out in the end."

Note: If you know of a library that you want to make available in your own scripts. let me know and I'll see about writing a plugin for it.

LCD4WoW

Last edited by starlon : 08-08-11 at 05:17 AM.
  Reply With Quote
08-08-11, 12:34 PM   #10
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Originally Posted by starlon View Post
Fixed a nasty bug (not really a bug, and not really a fix). But every widget needs a unique name. The examples I've shown here didn't give them a name. I was giving them all the name of ScriptableBar and ScriptableText. It'll go for ("ScriptableText" .. random()) now if nothing else is provided.
Wouldn't it be better to use the name of the parent add-on combined with a internal counter? That way you are sure you won't get any conflicts. Using random() seems to beg for hard to reproduce bugs.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
08-08-11, 06:12 PM   #11
starlon
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 107
Originally Posted by haste View Post
Wouldn't it be better to use the name of the parent add-on combined with a internal counter? That way you are sure you won't get any conflicts. Using random() seems to beg for hard to reproduce bugs.
I'm not happy with it, so yeah there needs to be a better solution involved.

Thanks for the feedback.
__________________
Wake up Sheeple! Cataclysm was an inside job!

Legalize WoW gold purchases directly from Blizzard! Yeah, my doctor thinks I'm crazy too. >.<

"It was either going to school for programming or working at the Genetically Modified Wildlife Preserve. I've always had a love for the wildlife, but technology won out in the end."

Note: If you know of a library that you want to make available in your own scripts. let me know and I'll see about writing a plugin for it.

LCD4WoW
  Reply With Quote
08-10-11, 05:20 AM   #12
starlon
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 107
Ok, you can make multiple widgets by doing

Code:
 self.ScriptableText = {fontstring1, fontstring2}
Same for ScriptableBar: {statusbar1, statusbar2}
__________________
Wake up Sheeple! Cataclysm was an inside job!

Legalize WoW gold purchases directly from Blizzard! Yeah, my doctor thinks I'm crazy too. >.<

"It was either going to school for programming or working at the Genetically Modified Wildlife Preserve. I've always had a love for the wildlife, but technology won out in the end."

Note: If you know of a library that you want to make available in your own scripts. let me know and I'll see about writing a plugin for it.

LCD4WoW
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » oUF_ScriptableText

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