Skip to content

Commit

Permalink
* Layout fixes for Inventory (now using 32px icons consistently)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisOelmueller committed Apr 16, 2012
1 parent 6083d41 commit 3fba642
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 59 deletions.
48 changes: 29 additions & 19 deletions content/gui/xml/ingame/tabwidget/island_inventory.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,39 @@

<Icon image="content/gui/images/background/hr.png" position="20,30" />

<Icon image="content/gui/images/background/inv_bg.png" position="20,50" />
<Icon image="content/gui/images/background/inv_bg.png" position="75,50" />
<Icon image="content/gui/images/background/inv_bg.png" position="130,50" />
<Icon image="content/gui/images/background/inv_bg.png" position="185,50" />

<Icon image="content/gui/images/background/inv_bg.png" position="20,100" />
<Icon image="content/gui/images/background/inv_bg.png" position="75,100" />
<Icon image="content/gui/images/background/inv_bg.png" position="130,100" />
<Icon image="content/gui/images/background/inv_bg.png" position="185,100" />
<HBox padding="5" min_size="215,50" max_size="215,50" position="20,50">
<Icon image="content/gui/images/background/inv_bg.png" />
<Icon image="content/gui/images/background/inv_bg.png" />
<Icon image="content/gui/images/background/inv_bg.png" />
<Icon image="content/gui/images/background/inv_bg.png" />
</HBox>

<Icon image="content/gui/images/background/inv_bg.png" position="20,150" />
<Icon image="content/gui/images/background/inv_bg.png" position="75,150" />
<Icon image="content/gui/images/background/inv_bg.png" position="130,150" />
<Icon image="content/gui/images/background/inv_bg.png" position="185,150" />
<HBox padding="5" min_size="215,50" max_size="215,50" position="20,100">
<Icon image="content/gui/images/background/inv_bg.png" />
<Icon image="content/gui/images/background/inv_bg.png" />
<Icon image="content/gui/images/background/inv_bg.png" />
<Icon image="content/gui/images/background/inv_bg.png" />
</HBox>

<Icon image="content/gui/images/background/inv_bg.png" position="20,200" />
<Icon image="content/gui/images/background/inv_bg.png" position="75,200" />
<Icon image="content/gui/images/background/inv_bg.png" position="130,200" />
<Icon image="content/gui/images/background/inv_bg.png" position="185,200" />
<HBox padding="5" min_size="215,50" max_size="215,50" position="20,150">
<Icon image="content/gui/images/background/inv_bg.png" />
<Icon image="content/gui/images/background/inv_bg.png" />
<Icon image="content/gui/images/background/inv_bg.png" />
<Icon image="content/gui/images/background/inv_bg.png" />
</HBox>

<HBox padding="5" min_size="215,50" max_size="215,50" position="20,200">
<Icon image="content/gui/images/background/inv_bg.png" />
<Icon image="content/gui/images/background/inv_bg.png" />
<Icon image="content/gui/images/background/inv_bg.png" />
<Icon image="content/gui/images/background/inv_bg.png" />
</HBox>

<!-- note: this inventory size must be wrong, there's far less space than 300,300 -->
<Inventory name="inventory" size="300,300" position="15,46" />
<!-- http://fife.trac.cvsdude.com/engine/ticket/692 ::
<ScrollArea min_size="215,200" max_size="215,200" position="21,52" vertical_scroll_amount="50">-->
<ScrollArea min_size="215,200" max_size="215,200" position="21,52" name="fife_ticket_692">
<Inventory name="inventory" min_size="215,200" max_size="215,1000" />
</ScrollArea>
</Container>

</Container>
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@

<!-- Resources for sale in the settlement -->
<Container size="520,70" position="20,40">
<Label name="selling_label" text="Selling" position="0,0"/>
<Icon image="content/gui/images/background/inv_bg.png" position=" 0,20" name="slot" />
<Icon image="content/gui/images/background/inv_bg.png" position=" 55,20" name="slot" />
<Icon image="content/gui/images/background/inv_bg.png" position="110,20" name="slot" />
<BuySellInventory name="selling_inventory" size="300,70" position="-5,15" uncached="1"/>
<Label name="selling_label" text="Selling" />
<HBox padding="5" min_size="160,50" max_size="160,50" position="0,20">
<Icon image="content/gui/images/background/inv_bg.png" name="slot" />
<Icon image="content/gui/images/background/inv_bg.png" name="slot" />
<Icon image="content/gui/images/background/inv_bg.png" name="slot" />
</HBox>
<BuySellInventory name="selling_inventory" size="300,70" position="1,21" uncached="1" />
</Container>

<!-- Resources being bought in the settlement -->
<Container size="520,70" position="20,110">
<Label name="buying_label" text="Buying" position="0,0"/>
<Icon image="content/gui/images/background/inv_bg.png" position=" 0,20" name="slot" />
<Icon image="content/gui/images/background/inv_bg.png" position=" 55,20" name="slot" />
<Icon image="content/gui/images/background/inv_bg.png" position="110,20" name="slot" />
<BuySellInventory name="buying_inventory" size="300,70" position="-5,15" uncached="1"/>
<Label name="buying_label" text="Buying" />
<HBox padding="5" min_size="160,50" max_size="160,50" position="0,20">
<Icon image="content/gui/images/background/inv_bg.png" name="slot" />
<Icon image="content/gui/images/background/inv_bg.png" name="slot" />
<Icon image="content/gui/images/background/inv_bg.png" name="slot" />
</HBox>
<BuySellInventory name="buying_inventory" size="300,70" position="1,21" uncached="1" />
</Container>
</Container>
</Container>
14 changes: 8 additions & 6 deletions content/gui/xml/ingame/tabwidget/ships/overview_trade_ship.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@

<Icon image="content/gui/images/background/hr.png" position="20,100" />

<Container position="22,110" size="230,70">
<Icon image="content/gui/images/background/inv_bg.png" position="5,4" />
<Icon image="content/gui/images/background/inv_bg.png" position="60,4" />
<Icon image="content/gui/images/background/inv_bg.png" position="115,4" />
<Icon image="content/gui/images/background/inv_bg.png" position="170,4" />
<Inventory name="inventory" size="230,70" position="0,0" uncached="1"/> <!-- uncached since icons collide with the traderoute tab -->
<Container position="22,110" size="230,75">
<HBox padding="5" min_size="215,50" max_size="215,50" position="3,2">
<Icon image="content/gui/images/background/inv_bg.png" />
<Icon image="content/gui/images/background/inv_bg.png" />
<Icon image="content/gui/images/background/inv_bg.png" />
<Icon image="content/gui/images/background/inv_bg.png" />
</HBox>
<Inventory name="inventory" size="230,70" position="4,4" uncached="1" /> <!-- uncached since icons collide with the traderoute tab -->
</Container>
</Container>
</Container>
14 changes: 8 additions & 6 deletions content/gui/xml/ingame/tabwidget/ships/overview_war_ship.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@

<Icon image="content/gui/images/background/hr.png" position="20,100" />

<Container position="22,110" size="230,70">
<Icon image="content/gui/images/background/inv_bg.png" position="5,4" />
<Icon image="content/gui/images/background/inv_bg.png" position="60,4" />
<Icon image="content/gui/images/background/inv_bg.png" position="115,4" />
<Icon image="content/gui/images/background/inv_bg.png" position="170,4" />
<Inventory name="inventory" size="230,70" position="0,0"/>
<Container position="22,110" size="230,75">
<HBox padding="5" min_size="215,50" max_size="215,50" position="3,2">
<Icon image="content/gui/images/background/inv_bg.png" />
<Icon image="content/gui/images/background/inv_bg.png" />
<Icon image="content/gui/images/background/inv_bg.png" />
<Icon image="content/gui/images/background/inv_bg.png" />
</HBox>
<Inventory name="inventory" size="230,70" position="4,4" uncached="1" />
</Container>

<StanceWidget position="0,190" size="230,40" name="stance" />
Expand Down
8 changes: 4 additions & 4 deletions content/gui/xml/ingame/tabwidget/ships/tradetab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<Icon image="content/gui/images/background/inv_bg.png" position="110,35" name="slot" />
<Icon image="content/gui/images/background/inv_bg.png" position="165,35" name="slot" />

<Inventory name="inventory_ship" size="300,150" position="-5,30" uncached="1"/>
<Inventory name="inventory_ship" size="300,150" position="1,36" uncached="1"/>

</Container>

Expand Down Expand Up @@ -84,7 +84,7 @@
<Icon image="content/gui/images/background/inv_bg.png" position=" 0,20" name="slot" />
<Icon image="content/gui/images/background/inv_bg.png" position=" 55,20" name="slot" />
<Icon image="content/gui/images/background/inv_bg.png" position="110,20" name="slot" />
<BuySellInventory name="selling_inventory" size="300,70" position="-5,15" uncached="1"/>
<BuySellInventory name="selling_inventory" size="300,70" position="1,21" uncached="1"/>
</Container>

<!-- Resources being bought in the settlement -->
Expand All @@ -93,11 +93,11 @@
<Icon image="content/gui/images/background/inv_bg.png" position=" 0,20" name="slot" />
<Icon image="content/gui/images/background/inv_bg.png" position=" 55,20" name="slot" />
<Icon image="content/gui/images/background/inv_bg.png" position="110,20" name="slot" />
<BuySellInventory name="buying_inventory" size="300,70" position="-5,15" uncached="1"/>
<BuySellInventory name="buying_inventory" size="300,70" position="1,21" uncached="1"/>
</Container>
</Container>
<Container name="domestic" position="20,260" size="250,210"> <!-- Only one of international / domestic is displayed -->
<ScrollArea name="inventory_area_partner" min_size="280,150" position="-5,0"
<ScrollArea name="inventory_area_partner" min_size="280,150" position="1,6"
background_color="255,255,255,0">
<Inventory name="inventory_partner" size="0,200" uncached="1" display_legend="0" />
</ScrollArea>
Expand Down
2 changes: 1 addition & 1 deletion horizons/gui/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def create_resource_selection_dialog(on_click, inventory, db, widget='select_tra

dlg = load_uh_widget(widget)

button_width = ImageFillStatusButton.DEFAULT_BUTTON_SIZE[0] # used for dummy button
button_width = ImageFillStatusButton.CELL_SIZE[0] # used for dummy button
vbox = dlg.findChild(name="resources")
amount_per_line = vbox.width / button_width
current_hbox = pychan.widgets.HBox(name="hbox_0", padding=0)
Expand Down
23 changes: 12 additions & 11 deletions horizons/gui/widgets/imagefillstatusbutton.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

class ImageFillStatusButton(pychan.widgets.Container):

DEFAULT_BUTTON_SIZE = (55, 50)
CELL_SIZE = (54, 50) # 32x32 icon, fillbar to the right, label below, padding

def __init__(self, up_image, down_image, hover_image, text, res_id, helptext="", \
filled=0, uncached=False, **kwargs):
Expand All @@ -41,7 +41,7 @@ def __init__(self, up_image, down_image, hover_image, text, res_id, helptext="",
self.helptext = _(helptext)
# res_id is used by the TradeTab for example to determine the resource this button represents
self.res_id = res_id
self.text_position = (17, 36)
self.text_position = (9, 30)
self.uncached = uncached # force no cache. needed when the same icon has to appear several times at the same time
self.filled = filled # <- black magic at work! this calls _draw()

Expand All @@ -55,21 +55,20 @@ def init_for_res(cls, db, res, amount=0, filled=0, use_inactive_icon=True, uncac
@param use_inactive_icon: wheter to use inactive icon if amount == 0
@param uncached: force no cache. see __init__()
@return: ImageFillStatusButton instance"""
icon = get_res_icon_path(res, 50)
icon = get_res_icon_path('placeholder', size=32)
if use_inactive_icon:
icon_disabled = get_res_icon_path(res, 50, greyscale=True)
icon_disabled = get_res_icon_path(res, size=50, greyscale=True)
else:
icon_disabled = icon
helptext = db.get_res_name(res)
image = icon_disabled if amount == 0 else icon
return cls(up_image=image, down_image=image, hover_image=image,
text=unicode(amount),
helptext=helptext,
size=cls.DEFAULT_BUTTON_SIZE,
res_id = res,
filled = filled,
uncached = uncached,
opaque=False)
size=cls.CELL_SIZE,
res_id=res,
filled=filled,
uncached=uncached)

def _set_filled(self, percent):
""""@param percent: int percent that fillstatus will be green"""
Expand Down Expand Up @@ -106,6 +105,8 @@ def _draw(self):
self.label = pychan.widgets.Label(text=self.text)
self.label.position = self.text_position
self.fill_bar = pychan.widgets.Icon(image="content/gui/images/tabwidget/green_line.png")
self.fill_bar.position = (self.button.width-self.fill_bar.width-1, \
self.button.height-int(self.button.height/100.0*self.filled))
fill_level = (self.button.height * self.filled) // 100
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)
6 changes: 4 additions & 2 deletions horizons/gui/widgets/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,16 @@ def _draw(self):
self.parent.removeChildren(icons[self.ITEMS_PER_LINE-1:])
vbox.addChild(current_hbox)
self.addChild(vbox)
height = ImageFillStatusButton.CELL_SIZE[1] * len(self._res_order) // self.ITEMS_PER_LINE
self.min_size = (self.min_size[0], height)
if self.display_legend:
if isinstance(self._inventory, TotalStorage):
# Add total storage indicator
sum_stored_res = self._inventory.get_sum_of_stored_resources()
label = pychan.widgets.Label()
label.text = unicode(sum_stored_res) + u"/" + unicode(self._inventory.get_limit(None))
label.position = (170, 53)
self.__icon.position = (150, 53)
label.position = (150, 53)
self.__icon.position = (130, 53)
self.addChildren(label, self.__icon)
elif isinstance(self._inventory, PositiveSizedSlotStorage):
label = pychan.widgets.Label()
Expand Down

0 comments on commit 3fba642

Please sign in to comment.