Quantcast

Introduce Images module and temporarily AVS.

Scott Sibley [10-12-10 - 02:00]
Introduce Images module and temporarily AVS.
Filename
.pkgmeta
Modules/AVS/AVS.lua
Modules/AVS/StarTip_AVS.toc
Modules/Images/Images.lua
Modules/Images/StarTip_Images.toc
modules.xml
diff --git a/.pkgmeta b/.pkgmeta
index fc74409..bc4df7e 100644
--- a/.pkgmeta
+++ b/.pkgmeta
@@ -65,4 +65,6 @@ move-folders:
     StarTip/Modules/UnitTooltip: StarTip_UnitTooltip
     StarTip/Modules/Portrait: StarTip_Portrait
     StarTip/Modules/Icons: StarTip_Icons
-    StarTip/Modules/Gestures: StarTip_Gestures
\ No newline at end of file
+    StarTip/Modules/Gestures: StarTip_Gestures
+    StarTip/Modules/Images: StarTip_Images
+    StarTip/Modules/AVS: StarTip_AVS
\ No newline at end of file
diff --git a/Modules/AVS/AVS.lua b/Modules/AVS/AVS.lua
new file mode 100644
index 0000000..d9f3bd3
--- /dev/null
+++ b/Modules/AVS/AVS.lua
@@ -0,0 +1,205 @@
+local mod = StarTip:NewModule("AVS")
+mod.name = "AVS"
+mod.toggled = true
+mod.defaultOff = true
+local LibBuffer = LibStub("LibScriptableDisplayBuffer-1.0")
+local LibCore = LibStub("LibScriptableDisplayCore-1.0")
+local LibTimer = LibStub("LibScriptableDisplayTimer-1.0")
+local PluginUtils = LibStub("LibScriptableDisplayPluginUtils-1.0"):New({})
+local AVSSuperScope = LibStub("LibScriptableDisplayAVSSuperScope-1.0")
+local PluginColor = LibStub("LibScriptableDisplayPluginColor-1.0"):New({})
+local _G = _G
+local GameTooltip = _G.GameTooltip
+local StarTip = _G.StarTip
+local UIParent = _G.UIParent
+local textures = {[0] = "Interface\\Addons\\StarTip\\Media\\black.blp", [1] = "Interface\\Addons\\StarTip\\Media\\white.blp"}
+local environment = {}
+local update
+
+local options = {
+}
+
+local foo = 200
+local defaults = {
+	profile = {
+		update = 100,
+		images = {
+			[1] = {
+				name = "Spiral",
+				init = [[
+n=25
+]],
+				frame = [[
+t=t-5
+]],
+				beat = [[
+]],
+				point = [[
+d=i+v*0.2; r=t+i*PI*200; x=cos(r)*d; y=sin(r)*d
+]],
+				width = 24,
+				height = 24,
+				pixel = 4,
+				drawLayer = "UIParent",
+				points = {{"CENTER", "UIParent", "CENTER", 0, -100}},
+				enabled = false
+			},
+			[2] = {
+				name = "Swirlie Dots",
+				init = [[
+n=30;
+t=random(100);
+u=random(100)
+]],
+				frame = [[
+t = t + 150; u = u + 50
+]],
+				beat = [[
+bb = (bb or 0) + 1;
+beatdiv = 16;
+if bb%beatdiv == 0 then
+    n = 32 + random( 30 )
+end
+]],
+				point = [[
+di = ( i - .5) * 2;
+x = di;
+y = cos(u*di) * .6;
+x = x + ( cos(t) * .005 );
+y = y + ( sin(t) * .005 );
+]],
+				width = 32,
+				height = 32,
+				pixel = 4,
+				drawLayer = "UIParent",
+				points = {{"CENTER", "UIParent", "CENTER", 0, 100}},
+				enabled = true
+}
+		}
+	}
+}
+
+function mod:OnInitialize()
+	self.db = StarTip.db:RegisterNamespace(self:GetName(), defaults)
+	StarTip:SetOptionsDisabled(options, true)
+
+	self.timer = LibTimer:New("Images", self.db.profile.update, true, update)
+end
+
+local function copy(tbl)
+	local newTbl = {}
+	for k, v in pairs(tbl) do
+		if type(v) == "table" then
+			v = copy(v)
+		end
+		newTbl[k] = v
+	end
+	return newTbl
+end
+
+local function createImages()
+	if type(mod.images) ~= "table" then mod.images = {} end
+
+	for k, image in pairs(mod.db.profile.images) do
+		if image.enabled then
+			local image = AVSSuperScope:New("image", copy(image), draw)
+			local frame = CreateFrame("Frame")
+			frame:SetParent(UIParent)
+			frame:SetBackdrop({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
+				tile = true,
+				tileSize = 4,
+				edgeSize=4,
+				insets = { left = 0, right = 0, top = 0, bottom = 0}})
+			frame:ClearAllPoints()
+			frame:SetAlpha(1)
+			frame:SetWidth(image.width * image.pixel)
+			frame:SetHeight(image.height * image.pixel)
+			for _, point in ipairs(image.config.points or {{"CENTER", "UIParent", "CENTER"}}) do
+				frame:SetPoint(unpack(point))
+			end
+			frame:Show()
+			image.textures = {}
+			for row = 0, image.height - 1 do
+			for col = 0, image.width - 1 do
+			--for n = 0, image.height * image.width - 1 do
+				--local row, col = PluginUtils.GetCoords(n, image.width)
+				local n = row * image.width + col
+				image.textures[n] = frame:CreateTexture()
+				image.textures[n]:SetHeight(image.pixel)
+				image.textures[n]:SetWidth(image.pixel)
+				image.textures[n]:SetPoint("TOPLEFT", frame, "BOTTOMLEFT", col * image.pixel, (row + 1) * image.pixel)
+				image.textures[n]:SetTexture("Interface\\Tooltips\\UI-Tooltip-Background")
+				image.textures[n]:Show()
+			end
+			end
+			image.canvas = frame
+			tinsert(mod.images, image)
+		end
+	end
+end
+
+function mod:OnEnable()
+	StarTip:SetOptionsDisabled(options, false)
+	createImages()
+	self.timer:Start()
+end
+
+function mod:OnDisable()
+	StarTip:SetOptionsDisabled(options, true)
+	self.timer:Stop()
+	for k, image in pairs(self.images) do
+		image.canvas:Hide()
+	end
+	wipe(self.images)
+end
+
+function mod:GetOptionsbleh()
+	for i, image in ipairs(self.db.profile.images) do
+		options.images.args["Icon"..i] = {
+			enabled = {
+				name = "Enabled",
+				type = "toggle",
+				get = function() return image.enabled end,
+				set = function(info, val) image.enabled = val end,
+				order = 1
+			},
+			speed = {
+				name = "Speed",
+				type = "input",
+				pattern = "%d",
+				get = function() return image.speed end,
+				set = function(info, val) image.speed = val end,
+				order = 2
+			},
+			bitmap = {
+				name = "Bitmap",
+				type = "input",
+				multiline = true,
+				width = "full",
+				get = function() return image.bitmap end,
+				set = function(info, val) image.bitmap = val end,
+				order = 3
+			}
+		}
+	end
+	return options
+end
+
+function mod:ClearImages()
+do return end
+	for k, widget in pairs(mod.images) do
+		widget:Del()
+	end
+	wipe(mod.images)
+end
+
+function update()
+	for i, widget in ipairs(mod.images or {}) do
+		widget.buffer:Clear()
+		widget:Render()
+		for n = 0, widget.height * widget.width - 1 do
+			local color = widget.buffer.buffer[n]
+			widget.textures[n]:SetVertexColor(PluginColor.Color2RGBA(color))
+		end
+	end
+end
diff --git a/Modules/AVS/StarTip_AVS.toc b/Modules/AVS/StarTip_AVS.toc
new file mode 100644
index 0000000..f62e9c8
--- /dev/null
+++ b/Modules/AVS/StarTip_AVS.toc
@@ -0,0 +1,9 @@
+## Interface: 30300
+## X-Compatible-With: 40000
+## Title: StarTip [AVS]
+## Notes: Tooltips from outerspace
+## Author: Starlon
+## Version: 1.0
+## OptionalDeps: StarTip
+
+AVS.lua
\ No newline at end of file
diff --git a/Modules/Images/Images.lua b/Modules/Images/Images.lua
new file mode 100644
index 0000000..f5cc07e
--- /dev/null
+++ b/Modules/Images/Images.lua
@@ -0,0 +1,222 @@
+local mod = StarTip:NewModule("Images")
+mod.name = "IMages"
+mod.toggled = true
+mod.defaultOff = true
+local LibBuffer = LibStub("LibScriptableDisplayBuffer-1.0")
+local LibCore = LibStub("LibScriptableDisplayCore-1.0")
+local LibTimer = LibStub("LibScriptableDisplayTimer-1.0")
+local PluginUtils = LibStub("LibScriptableDisplayPluginUtils-1.0"):New({})
+local WidgetImage = LibStub("LibScriptableDisplayWidgetImage-1.0")
+local PluginColor = LibStub("LibScriptableDisplayPluginColor-1.0"):New({})
+local _G = _G
+local GameTooltip = _G.GameTooltip
+local StarTip = _G.StarTip
+local UIParent = _G.UIParent
+local textures = {[0] = "Interface\\Addons\\StarTip\\Media\\black.blp", [1] = "Interface\\Addons\\StarTip\\Media\\white.blp"}
+local environment = {}
+local draw
+--[[
+local frame = CreateFrame("Frame")
+frame:SetParent(UIParent)
+frame:SetBackdrop({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
+	tile = true,
+	tileSize = 4,
+	edgeSize=4,
+	insets = { left = 0, right = 0, top = 0, bottom = 0}})
+frame:ClearAllPoints()
+frame:SetAlpha(1)
+frame:SetWidth(500)
+frame:SetHeight(500)
+frame:SetPoint("CENTER", UIParent, "CENTER")
+frame:Show()
+]]
+
+local options = {
+}
+
+local foo = 200
+local defaults = {
+	profile = {
+		cols = 2,
+		rows = 1,
+		yres = 8,
+		xres = 7,
+		size = 15,
+		update = 500,
+		images = {
+			[1] = {
+				name = "Analyzer",
+				prescript = [[
+]],
+				script = [[
+self:Clear()
+y_old = floor(self.height / 2);
+for i = 0, self.width - 1 do
+	y = (self.height / 2) + (noise[bit.rshift(i, 1) % #noise] * (self.height / 4));
+	y = floor(y)
+	if (y > y_old) then
+		for j = y_old, y do
+			self.image[self.index].buffer[j * self.width + i] = 0xffffffff;
+		end
+	else
+		for j = y, y_old - 1 do
+			self.image[self.index].buffer[j * self.width + i] = 0xffffffff;
+		end
+	end
+end
+
+]],
+				update = 100,
+				width = 64,
+				height = 64,
+				pixel = 4,
+				--drawLayer = "UIParent",
+				enabled = true,
+				points = {{"CENTER", "UIParent", "CENTER"}},
+			}
+		}
+	}
+}
+
+function mod:OnInitialize()
+	self.db = StarTip.db:RegisterNamespace(self:GetName(), defaults)
+	StarTip:SetOptionsDisabled(options, true)
+
+	self.core = LibCore:New(mod, environment, "StarTip.Images", {["StarTip.Images"] = {}}, nil, StarTip.db.profile.errorLevel)
+	self.core.lcd = {LCOLS=self.db.profile.cols, LROWS=self.db.profile.rows, LAYERS=self.db.profile.layers}
+
+	self.buffer = LibBuffer:New("StarTip.Images", self.core.lcd.LCOLS * self.core.lcd.LROWS, 0, StarTip.db.profile.errorLevel)
+
+	if self.db.profile.update > 0 then
+		self.timer = LibTimer:New("Images", 100, true, update)
+	end
+
+end
+
+local function copy(tbl)
+	local newTbl = {}
+	for k, v in pairs(tbl) do
+		if type(v) == "table" then
+			v = copy(v)
+		end
+		newTbl[k] = v
+	end
+	return newTbl
+end
+
+local function createImages()
+	if type(mod.images) ~= "table" then mod.images = {} end
+
+	for k, image in pairs(mod.db.profile.images) do
+		if image.enabled then
+			local image = WidgetImage:New(mod.core, "image", copy(image), image.row or 0, image.col or 0, image.layer or 0, StarTip.db.profile.errorLevel, draw)
+			local frame = CreateFrame("Frame")
+			frame:SetParent(UIParent)
+			frame:SetBackdrop({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
+				tile = true,
+				tileSize = 4,
+				edgeSize=4,
+				insets = { left = 0, right = 0, top = 0, bottom = 0}})
+			frame:ClearAllPoints()
+			frame:SetAlpha(1)
+			frame:SetWidth(image.width * image.pixel)
+			frame:SetHeight(image.height * image.pixel)
+			frame:SetPoint("CENTER", UIParent, "CENTER")
+			image.frame = frame
+			image.textures = {}
+			for row = 0, image.height - 1 do
+			for col = 0, image.width - 1 do
+			--for n = 0, image.height * image.width - 1 do
+				--local row, col = PluginUtils.GetCoords(n, image.width)
+				local n = row * image.width + col
+				image.textures[n] = frame:CreateTexture()
+				image.textures[n]:SetHeight(image.pixel)
+				image.textures[n]:SetWidth(image.pixel)
+				image.textures[n]:SetPoint("TOPLEFT", frame, "BOTTOMLEFT", col * image.pixel, (row + 1) * image.pixel)
+				image.textures[n]:SetTexture("Interface\\Tooltips\\UI-Tooltip-Background")
+				image.textures[n]:Show()
+			end
+			end
+			frame:ClearAllPoints()
+			frame:SetPoint("CENTER")
+			tinsert(mod.images, image)
+		end
+	end
+end
+
+function mod:OnEnable()
+	StarTip:SetOptionsDisabled(options, false)
+	createImages()
+	for i, v in pairs(mod.images) do
+		v:Start()
+	end
+	if self.timer then
+		self.timer:Start()
+	end
+	for k, image in pairs(self.images or {}) do
+		image:Start()
+		image.frame:Show()
+	end
+end
+
+function mod:OnDisable()
+	StarTip:SetOptionsDisabled(options, true)
+	if self.timer then
+		self.timer:Stop()
+	end
+	for k, image in pairs(self.images or {}) do
+		image:Stop()
+		image.frame:Hide()
+	end
+end
+
+function mod:GetOptionsbleh()
+	for i, image in ipairs(self.db.profile.images) do
+		options.images.args["Icon"..i] = {
+			enabled = {
+				name = "Enabled",
+				type = "toggle",
+				get = function() return image.enabled end,
+				set = function(info, val) image.enabled = val end,
+				order = 1
+			},
+			speed = {
+				name = "Speed",
+				type = "input",
+				pattern = "%d",
+				get = function() return image.speed end,
+				set = function(info, val) image.speed = val end,
+				order = 2
+			},
+			bitmap = {
+				name = "Bitmap",
+				type = "input",
+				multiline = true,
+				width = "full",
+				get = function() return image.bitmap end,
+				set = function(info, val) image.bitmap = val end,
+				order = 3
+			}
+		}
+	end
+	return options
+end
+
+function mod:ClearImages()
+do return end
+	for k, widget in pairs(mod.images) do
+		widget:Del()
+	end
+	wipe(mod.images)
+end
+
+function draw(widget)
+	for n = 0, widget.height * widget.width - 1 do
+		local color = widget.image[widget.index].buffer[n]
+		if random(2) == 1 or true then
+			widget.textures[n]:SetVertexColor(PluginColor.Color2RGBA(color, true))
+		else
+			widget.textures[n]:SetVertexColor(1, 1, 1, 1)
+		end
+	end
+end
diff --git a/Modules/Images/StarTip_Images.toc b/Modules/Images/StarTip_Images.toc
new file mode 100644
index 0000000..c12c356
--- /dev/null
+++ b/Modules/Images/StarTip_Images.toc
@@ -0,0 +1,9 @@
+## Interface: 30300
+## X-Compatible-With: 40000
+## Title: StarTip [Images]
+## Notes: Tooltips from outerspace
+## Author: Starlon
+## Version: 1.0
+## OptionalDeps: StarTip
+
+Images.lua
\ No newline at end of file
diff --git a/modules.xml b/modules.xml
index 4ca2afa..2f6fd5b 100644
--- a/modules.xml
+++ b/modules.xml
@@ -15,6 +15,8 @@
 <Script file = "Modules\Portrait\Portrait.lua"/>
 <Script file = "Modules\Icons\Icons.lua"/>
 <Script file = "Modules\Gestures\Gestures.lua"/>
+<Script file = "Modules\Images\Images.lua"/>
+<Script file = "Modules\AVS\AVS.lua"/>
 <Script file = "Modules\Debug\Debug.lua"/>
 <!--@end-debug@-->