-
Notifications
You must be signed in to change notification settings - Fork 1
/
ifelem_segline.lua
140 lines (121 loc) · 3.59 KB
/
ifelem_segline.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--
-- this.LineToAccept = NewSegmentLine(x1,y1,x2,y2,optionallabel,offsetforlabel(required if optionallabel))
function NewSegmentLine(x1,y1,x2,y2,label,labeloffs)
local temp = { ZPos = 130 }
-- Text will be at 128 by default, be a bit behind it
-- Assumed that there is always a horizontal difference (x2>x1 or x1>x2)
-- There doesn't have to be a vertical difference
-- Type 1: label --------| (x1<x2)
-- |
-- Type 2: |-------- label (x2<x1)
-- |
-- *
-- SETUP THE LINES
-- *
local LabelAlpha = 1
local LabelTexture = "gray_rect"
if(x1<x2) then
temp.ChunkH = NewIFImage { --uvs_l=0.45, uvs_r=0.55, uvs_t = 0.09, uvs_b=0.1,
texture=LabelTexture,
alpha = LabelAlpha,
localpos_l=x1, localpos_t=y1-2,
localpos_r=x2, localpos_b=y1+2, inert_all = 1,
ColorR = 255, ColorG = 255, ColorB = 0,
}
if(y1<y2) then
temp.ChunkV = NewIFImage { --uvs_l=0.45, uvs_r=0.55, uvs_t = 0.09,uvs_b=0.1,
texture=LabelTexture,
alpha = LabelAlpha,
localpos_l=x2-2, localpos_t=y1,
localpos_r=x2+2, localpos_b=y2, inert_all = 1,
ColorR = 255, ColorG = 255, ColorB = 0,
}
elseif (y2<y1) then
temp.ChunkV = NewIFImage { --uvs_l=0.45, uvs_r=0.55, uvs_t = 0.09,uvs_b=0.1,
texture=LabelTexture,
alpha = LabelAlpha,
localpos_l=x2-2, localpos_t=y2,
localpos_r=x2+2, localpos_b=y1, inert_all = 1,
ColorR = 255, ColorG = 255, ColorB = 0,
}
else
--no vertical component (y1=y2)
end
else
temp.ChunkH = NewIFImage { --uvs_l=0.45, uvs_r=0.55, uvs_t = 0.09, uvs_b=0.1,
texture=LabelTexture,
alpha = LabelAlpha,
localpos_l=x2, localpos_t=y1-2,
localpos_r=x1, localpos_b=y1+2, inert_all = 1,
ColorR = 255, ColorG = 255, ColorB = 0,
}
if(y1<y2) then
temp.ChunkV = NewIFImage { --uvs_l=0.45, uvs_r=0.55, uvs_t = 0.09, uvs_b=0.1,
texture=LabelTexture,
alpha = LabelAlpha,
localpos_l=x2-2, localpos_t=y1,
localpos_r=x2+2, localpos_b=y2, inert_all = 1,
ColorR = 255, ColorG = 255, ColorB = 0,
}
elseif (y2<y1) then
temp.ChunkV = NewIFImage { --uvs_l=0.45, uvs_r=0.55, uvs_t = 0.09, uvs_b=0.1,
texture=LabelTexture,
alpha = LabelAlpha,
localpos_l=x2-2, localpos_t=y2,
localpos_r=x2+2, localpos_b=y1, inert_all = 1,
ColorR = 255, ColorG = 255, ColorB = 0,
}
else
--no vertical component (y1=y2)
end
end
-- *
-- SETUP THE LABEL (if applicable)
-- *
if(label) then
local XPos
local TextW
if(x1 < x2) then
XPos = x1
TextW = math.max(50,(gSafeW * 0.5) + XPos + 10)
temp.label = NewIFText {
font = "meu_myriadpro_small",
valign = "vcenter",
halign = "right",
string = label,
x= XPos - TextW - 5,
y= y1 - 30,
ColorR = 255, ColorG = 255, ColorB = 255,
textw = TextW,
texth = 60,
nocreatebackground = 1,
startdelay = math.random() * 0.5,
leading = -3,
inert_all = 1,
} -- end of label
else
XPos = x1
TextW = math.max(50,(gSafeW * 0.5) - XPos + 10)
temp.label = NewIFText {
font = "meu_myriadpro_small",
valign = "vcenter",
halign = "left",
string = label,
x= XPos + 5,
y= y1 - 30,
ColorR = 255, ColorG = 255, ColorB = 255,
textw = TextW - 5,
texth = 60,
nocreatebackground = 1,
startdelay = math.random() * 0.5,
leading = -3,
} -- end of label
end
end
--*
-- Make a container from this expanded template
--*
return NewIFContainer(temp)
end