from retail

diffchecked
This commit is contained in:
NoM0Re
2025-01-26 19:24:17 +01:00
parent dcd0f833ac
commit 38533d0e99
7 changed files with 286 additions and 265 deletions
+42 -40
View File
@@ -11,9 +11,8 @@ local default = {
color = {1, 1, 1, 1},
blendMode = "BLEND",
rotation = 0,
discrete_rotation = 0,
mirror = false,
rotate = true,
rotate = false,
selfPoint = "CENTER",
anchorPoint = "CENTER",
anchorFrameType = "SCREEN",
@@ -64,6 +63,15 @@ local properties = {
display = L["Mirror"],
setter = "SetMirror",
type = "bool"
},
rotation = {
display = L["Rotation"],
setter = "SetRotation",
type = "number",
min = 0,
max = 360,
bigStep = 1,
default = 0
}
}
@@ -85,6 +93,16 @@ local function create(parent)
return region;
end
local SQRT2 = sqrt(2)
local function GetRotatedPoints(degrees, scaleForFullRotate)
local angle = rad(135 - degrees);
local factor = scaleForFullRotate and 1 or SQRT2
local vx = math.cos(angle) / factor
local vy = math.sin(angle) / factor
return 0.5+vx,0.5-vy , 0.5-vy,0.5-vx , 0.5+vy,0.5+vx , 0.5-vx,0.5+vy
end
local function modify(parent, region, data)
Private.regionPrototype.modify(parent, region, data);
region.texture:SetDesaturated(data.desaturate)
@@ -95,16 +113,6 @@ local function modify(parent, region, data)
region.scalex = 1;
region.scaley = 1;
region.texture:SetBlendMode(data.blendMode);
--region.texture:SetRotation((data.rotation / 180) * math.pi);
local function GetRotatedPoints(degrees)
degrees = degrees or 0
local angle = rad(135 - degrees);
local vx = math.cos(angle);
local vy = math.sin(angle);
return 0.5+vx,0.5-vy , 0.5-vy,0.5-vx , 0.5+vy,0.5+vx , 0.5-vx,0.5+vy
end
region.mirror = data.mirror
@@ -113,20 +121,8 @@ local function modify(parent, region, data)
if(region.mirror) then
mirror_h = not mirror_h;
end
local ulx,uly , llx,lly , urx,ury , lrx,lry;
if(data.rotate) then
ulx,uly , llx,lly , urx,ury , lrx,lry = GetRotatedPoints(region.rotation);
else
if(data.discrete_rotation == 0 or data.discrete_rotation == 360) then
ulx,uly , llx,lly , urx,ury , lrx,lry = 0,0 , 0,1 , 1,0 , 1,1;
elseif(data.discrete_rotation == 90) then
ulx,uly , llx,lly , urx,ury , lrx,lry = 1,0 , 0,0 , 1,1 , 0,1;
elseif(data.discrete_rotation == 180) then
ulx,uly , llx,lly , urx,ury , lrx,lry = 1,1 , 1,0 , 0,1 , 0,0;
elseif(data.discrete_rotation == 270) then
ulx,uly , llx,lly , urx,ury , lrx,lry = 0,1 , 1,1 , 0,0 , 1,0;
end
end
local ulx,uly , llx,lly , urx,ury , lrx,lry
= GetRotatedPoints(region.effectiveRotation, data.rotate)
if(mirror_h) then
if(mirror_v) then
region.texture:SetTexCoord(lrx,lry , urx,ury , llx,lly , ulx,uly);
@@ -142,8 +138,8 @@ local function modify(parent, region, data)
end
end
region.rotation = data.rotation;
DoTexCoord();
region.rotation = data.rotation
region.effectiveRotation = region.rotation
function region:Scale(scalex, scaley)
region.scalex = scalex;
@@ -231,20 +227,26 @@ local function modify(parent, region, data)
region.texture:SetDesaturated(b);
end
if(data.rotate) then
function region:Rotate(degrees)
region.rotation = degrees;
DoTexCoord();
end
function region:GetRotation()
return region.rotation;
end
else
region.Rotate = nil;
region.GetRotation = nil;
function region:SetAnimRotation(degrees)
region.animRotation = degrees
region:UpdateEffectiveRotation()
end
function region:SetRotation(degrees)
region.rotation = degrees
region:UpdateEffectiveRotation()
end
function region:UpdateEffectiveRotation()
region.effectiveRotation = region.animRotation or region.rotation
DoTexCoord()
end
function region:GetBaseRotation()
return region.rotation
end
region:SetRotation(data.rotation)
Private.regionPrototype.modifyFinish(parent, region, data);
end