Skip to content

Commit

Permalink
* Fix display problem of ImageFillStatusButtons
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisOelmueller committed Apr 17, 2012
1 parent b359ed3 commit 66258f8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion horizons/gui/tabs/buyselltab.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def add_resource(self, res_id, slot_id, value=None):
slot.findChild(name="amount").text = unicode(value)+"t"
icon = slot.findChild(name="icon")
inventory = self.tradepost.get_inventory()
filled = float(inventory[res_id]) / inventory.get_limit(res_id)
filled = (100 * inventory[res_id]) // inventory.get_limit(res_id)
fillbar.position = (icon.width - fillbar.width - 1,
icon.height - int(icon.height*filled))
# reuse code from toggle to finish setup (must switch state before, it will reset it)
Expand Down
2 changes: 1 addition & 1 deletion horizons/gui/widgets/imagefillstatusbutton.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def _draw(self):
self.label.position = self.text_position
self.fill_bar = pychan.widgets.Icon(image="content/gui/images/tabwidget/green_line.png")
fill_level = (self.button.height * self.filled) // 100
self.fill_bar.size = (2*self.fill_bar.size[0]//3, fill_level)
self.fill_bar.size = ((2 * self.fill_bar.size[0]) // 3, fill_level)
# move fillbar down after resizing, since its origin is top aligned
self.fill_bar.position = (self.button.width, self.button.height - fill_level)
self.addChildren(self.button, self.fill_bar, self.label)
4 changes: 2 additions & 2 deletions horizons/gui/widgets/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ def _draw(self):

if self.ordinal is not None:
range_ = self.ordinal[1] - self.ordinal[0]
filled = ( float(amount - self.ordinal[0]) / range_ ) * 100
filled = (100 * (amount - self.ordinal[0])) // range_
amount = ""
elif isinstance(self._inventory, TotalStorage):
filled = 0
else:
filled = int(float(amount) / float(self._inventory.get_limit(resid)) * 100.0)
filled = (100 * amount) // self._inventory.get_limit(resid)

button = ImageFillStatusButton.init_for_res(self.db, resid, amount, \
filled=filled, uncached=self.uncached)
Expand Down

0 comments on commit 66258f8

Please sign in to comment.