-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathstaminabar.lic
77 lines (65 loc) · 2.24 KB
/
staminabar.lic
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
=begin
Quick script to show your stamina in a progress bar
author: Tillmen ([email protected])
game: Gemstone
tags: cosmetic
version: 0.1
=end
no_kill_all
no_pause_all
hide_me
Settings.load
window_width = Settings['window_width'] || 120
window_height = Settings['window_height'] || 25
window_position = Settings['window_position']
window_decorated = Settings['window_decorated']
bar = window = done = window_close = last_stamina = nil
Gtk.queue {
window = Gtk::Window.new
window.title = 'stamina'
window.signal_connect('delete_event') { window_close = true }
bar = Gtk::ProgressBar.new
bar.height_request = 10
bar.width_request = 20
#bar.modify_bg(Gtk::STATE_NORMAL,Gdk::Color.new(240*255,208*255,215*255))
#bar.modify_bg(Gtk::STATE_PRELIGHT,Gdk::Color.new(240*255,208*255,215*255))
bar.add_events(Gdk::Event::BUTTON_PRESS_MASK)
bar.signal_connect('button_press_event') { |owner, ev| Gtk.queue { window.decorated = !window.decorated? if ev.button == 3 } }
window.add(bar)
window.show_all
window.decorated = window_decorated unless window_decorated.nil?
window.resize(window_width.to_i, window_height.to_i)
window_position[0] = [[0, window_position[0].to_i].max, (Gdk.screen_width-window_width.to_i)].min
window_position[1] = [[0, window_position[1].to_i].max, (Gdk.screen_height-window_height.to_i)].min
window.move(window_position[0].to_i, window_position[1].to_i)
window.keep_above = true
done = true
}
wait_until { done }
before_dying {
done = false
Gtk.queue {
window_width = window.allocation.width
window_height = window.allocation.height
window_decorated = window.decorated?
window_position = window.position
window.destroy
done = true
}
wait_until { done }
Settings['window_width'] = window_width
Settings['window_height'] = window_height
Settings['window_decorated'] = window_decorated
Settings['window_position'] = window_position if (window_position.class == Array) and (window_position[0].to_i > -5) and (window_position[1].to_i > -5)
Settings.save
}
until window_close
unless last_stamina == XMLData.stamina
last_stamina = XMLData.stamina
Gtk.queue {
bar.fraction = XMLData.stamina/[XMLData.max_stamina.to_f,1].max
bar.text = "#{XMLData.stamina} / #{XMLData.max_stamina}"
}
end
sleep 0.1
end