-
Notifications
You must be signed in to change notification settings - Fork 1
/
AlignWindow.xml
171 lines (136 loc) · 3.77 KB
/
AlignWindow.xml
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Saturday, December 23, 2017, 11:46 AM -->
<!-- MuClient version 5.04 -->
<!-- Plugin "AlignWindow" generated by Plugin Wizard -->
<muclient>
<plugin
name="AlignWindow"
author="Ruhsbaar"
id="942aa4aa70e31ac872a10f74"
language="Lua"
purpose="Show alignment in a window"
save_state="y"
date_written="2017-12-23 11:45:32"
requires="5.04"
version="1.0"
>
</plugin>
<!-- Get our standard constants -->
<include name="constants.lua"/>
<!-- Triggers -->
<triggers>
<trigger
enabled="y"
match="^\<\<\< ([\w\s]+) \>\>\>$"
omit_from_output="y"
regexp="y"
send_to="12"
sequence="100"
script="RefreshAlignmentWindow"
>
<send>SetVariable("last_alignment", "%1")</send>
</trigger>
<trigger
enabled="y"
match="^Hp\: \d{2,4}\(\d{2,4}\) Gp\: \d{2,4}\(\d{2,4}\) Xp\: \d{1,10} Burden\: \d{1,3}\% Align\: ([\w\s]+)$"
regexp="y"
send_to="12"
sequence="100"
script="RefreshAlignmentWindow"
>
<send>SetVariable("last_alignment", "%1")</send>
</trigger>
</triggers>
<aliases>
<alias
enabled="y"
match="^alignwindow$"
regexp="y"
script="WindowToggle"
sequence="100"
></alias>
</aliases>
<!-- Variables -->
<variables>
<variable name="last_alignment"></variable>
</variables>
<!-- Script -->
<script>
<![CDATA[
require "movewindow"
local window_flag = true
local window_name = "align_window_" .. GetPluginID()
----
-- Hooks
----
function OnPluginEnable()
RefreshAlignmentWindow()
end
function OnPluginDisable()
WindowShow(window_name, false)
end
function OnPluginClose()
WindowShow(window_name, false)
end
function OnPluginSaveState()
movewindow.save_state(window_name)
end
----
-- Utilities
----
function EraseWindow()
end
function WindowToggle(name, line, wildcards)
if window_flag == false then
WindowShow(window_name, true)
window_flag = true
else
WindowShow(window_name, false)
window_flag = false
end
end
----
-- Main
----
function CreateWindow()
align = GetVariable("last_alignment")
win_width, win_height = 200, 50
-- Create a miniwindow
window_info = movewindow.install(window_name, miniwin.pos_bottom_right, 0)
WindowCreate(
window_name,
window_info.window_left,
window_info.window_top,
win_width, win_height,
window_info.window_mode,
window_info.window_flags,
ColourNameToRGB("black")
)
movewindow.add_drag_handler(window_name, 0, 0, 0, 0, miniwin.cursor_both_arrow)
-- Draw Borders
WindowRectOp(window_name, miniwin.rect_frame, 0, 0, win_width, win_height, ColourNameToRGB("white"))
-- Write alignment to window
WindowFont (window_name, "f", "Trebuchet MS", 12, true, false, false, false) -- define font
width = WindowTextWidth (window_name, "f", align)
left = (200 - width) / 2
WindowText(window_name, "f", GetVariable("last_alignment"), left, 15, 0, 0, ColourNameToRGB("white"), false)
-- Show the window on screen
WindowShow(window_name, true)
end
function RefreshAlignmentWindow()
align = GetVariable("last_alignment")
-- Clear the window
WindowRectOp(window_name, miniwin.rect_fill, 0, 0, 0, 0, ColourNameToRGB("black"))
-- Draw Borders
WindowRectOp(window_name, miniwin.rect_frame, 0, 0, win_width, win_height, ColourNameToRGB("white"))
-- Write alignment to window
WindowFont (window_name, "f", "Trebuchet MS", 12, true, false, false, false) -- define font
width = WindowTextWidth (window_name, "f", align)
left = (200 - width) / 2
WindowText(window_name, "f", GetVariable("last_alignment"), left, 15, 0, 0, ColourNameToRGB("white"), false)
end
CreateWindow()
]]>
</script>
</muclient>