Code:
=begin
So I was thinkin to myself the other day,
'Hey, I want an uberbar for Wizard, and I think other people do too.'
So here it is. Stay classy San Diego.
=end
no_kill_all
no_pause_all
hide_me
Settings.load
window_width = 168
window_height = 232
window_position = Settings['window_position']
window_decorated = Settings['window_decorated']
minbar_height = 19
minbar_width = 84
oldHP = oldMP = oldST = oldSP = oldXP = oldMD = oldSN = oldEN = oldIN = oldWO = uberBar_pulse = uberBar_health = uberBar_mana = uberBar_stamina = uberBar_spirit = uberBar_exp = uberBar_mind = uberBar_stance = uberBar_encumb = uberBar_table = uberBar = done = window_close = nil
capped = false
capped = true if Char.level == 100
# random arrays
#areas = ["nsys","leftArm","rightArm","rightLeg","leftLeg","head","rightFoot","leftFoot","rightHand","leftHand","rightEye","leftEye","back","neck","chest","abdomen"]
debug = true
# XP watcher variables
xpnFirstTime = Time.now # Time UB was first run
if capped then xpnFirst = 100 - ((((XMLData.next_level_text.delete(' experience').to_i / 2500 + 1) * 2500 - XMLData.next_level_text.delete(' experience').to_i) * 100) / 2500) # First experience
else ; xpnFirst = XMLData.next_level_text.delete(' until next level').to_i ; end # First experience
xpnTotal = 0 # Zero total xp to start
xpnCur = xpnFirst # Current exp to go
xpnOld = xpnFirst # Last round exp to go
xpnHour = 0 # average Experience per hour
xpnLast = 0 # Last Experience gain
Gtk.queue {
uberBar = Gtk::Window.new
uberBar.title = 'UberBar'
uberBar.signal_connect('delete_event') { window_close = true }
uberBar.border_width = 2
uberBar_table = Gtk::Table.new 12, 2, true
uberBar.add uberBar_table
uberBar_damage = Gtk::Image.new "#{$script_dir}uberBar/Health.bmp"
uberBar_damage.height_request = minbar_height * 7
uberBar_damage.width_request = minbar_width
uberBar_table.attach uberBar_damage, 0, 1, 0, 8
uberBar_damage_larm = Gtk::Image.new "#{$script_dir}uberBar/Wound1.bmp"
#uberBar_damage_larm
uberBar_pulse = Gtk::ProgressBar.new
uberBar_pulse.height_request = minbar_height
uberBar_pulse.width_request = minbar_width
uberBar_table.attach uberBar_pulse, 1, 2, 3, 4
uberBar_health = Gtk::ProgressBar.new
uberBar_health.height_request = minbar_height
uberBar_health.width_request = minbar_width
uberBar_table.attach uberBar_health, 1, 2, 4, 5
uberBar_mana = Gtk::ProgressBar.new
uberBar_mana.height_request = minbar_height
uberBar_mana.width_request = minbar_width
uberBar_table.attach uberBar_mana, 1, 2, 5, 6
uberBar_stamina = Gtk::ProgressBar.new
uberBar_stamina.height_request = minbar_height
uberBar_stamina.width_request = minbar_width
uberBar_table.attach uberBar_stamina, 1, 2, 6, 7
uberBar_spirit = Gtk::ProgressBar.new
uberBar_spirit.height_request = minbar_height
uberBar_spirit.width_request = minbar_width
uberBar_table.attach uberBar_spirit, 1, 2, 7, 8
uberBar_exp = Gtk::ProgressBar.new
uberBar_exp.height_request = minbar_height
uberBar_exp.width_request = minbar_width
uberBar_table.attach uberBar_exp, 0, 2, 8, 9
uberBar_mind = Gtk::ProgressBar.new
uberBar_mind.height_request = minbar_height
uberBar_mind.width_request = minbar_width
uberBar_table.attach uberBar_mind, 0, 2, 9, 10
uberBar_stance = Gtk::ProgressBar.new
uberBar_stance.height_request = minbar_height
uberBar_stance.width_request = minbar_width
uberBar_table.attach uberBar_stance, 0, 2, 10, 11
uberBar_encumb = Gtk::ProgressBar.new
uberBar_encumb.height_request = minbar_height
uberBar_encumb.width_request = minbar_width
uberBar_table.attach uberBar_encumb, 0, 2, 11, 12
uberBar.show_all
#uberBar.decorated = window_decorated unless window_decorated.nil?
#uberBar.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
#uberBar.move(window_position[0].to_i, window_position[1].to_i)
uberBar.keep_above = true
done = true
}
wait_until { done }
before_dying {
done = false
Gtk.queue {
window_width = uberBar.allocation.width
window_height = uberBar.allocation.height
window_decorated = uberBar.decorated?
window_position = uberBar.position
uberBar.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
}
loop {
wait_while { oldHP == checkhealth and oldMP == checkmana and oldST == checkstamina and oldSP = checkspirit and oldMD == XMLData.mind_text and oldSN == XMLData.stance_text and oldEN == XMLData.encumbrance_text }
if oldHP != checkhealth then echo "updated health" if debug ; oldHP = checkhealth ; Gtk.queue { uberBar_health.fraction = percenthealth/100.0 ; uberBar_health.text = "#{checkhealth}/#{maxhealth}" } end
if oldMP != checkmana then echo "updated mana" if debug ; oldMP = checkmana ; Gtk.queue { uberBar_mana.fraction = percentmana/100.0 ; uberBar_mana.text = "#{checkmana}/#{maxmana}" } end
if oldST != checkstamina then echo "updated stamina" if debug ; oldST = checkstamina ; Gtk.queue { uberBar_stamina.fraction = percentstamina/100.0 ; uberBar_stamina.text = "#{checkstamina}/#{maxstamina}" } end
if oldSP != checkspirit then echo "updated spirit" if debug ; oldSP = checkspirit ; Gtk.queue { uberBar_spirit.fraction = percentspirit/100.0 ; uberBar_spirit.text = "#{checkspirit}/#{maxspirit}" } end
if oldMD != XMLData.mind_text then echo "updated mind" if debug ; oldMD = XMLData.mind_text ; Gtk.queue { uberBar_mind.fraction = XMLData.mind_value/100.0 ; uberBar_mind.text = XMLData.mind_text } end
if oldSN != XMLData.stance_text then echo "updated stance" if debug ; oldSN = XMLData.stance_text ; Gtk.queue { uberBar_stance.fraction = XMLData.stance_value/100.0 ; uberBar_stance.text = XMLData.stance_text } end
if oldEN != XMLData.encumbrance_text then echo "updated encumbr" if debug ; oldEN = XMLData.encumbrance_text ; Gtk.queue { uberBar_encumb.fraction = XMLData.encumbrance_value/100.0 ; uberBar_encumb.text = XMLData.encumbrance_text } end
}