Exemple #1
0
func updateTables(tables gwu.Panel) {
	var sorted SortBySellPrice
	for card, _ := range PriceHistory {
		sorted = append(sorted, StockedItem{
			card,
			currentState.DeterminePrice(card, 1, true),
			currentState.DeterminePrice(card, 1, false),
		})
	}
	sort.Sort(sorted)

	tables.Clear()
	tables.Add(createFAQ())

	tables.AddHSpace(100)
	for rarity, rarityStr := range []string{"Commons", "Uncommons", "Rares"} {
		layout := gwu.NewPanel()
		tables.Add(layout)
		tables.AddHSpace(30)

		layout.SetHAlign(gwu.HA_CENTER)
		layout.Style().SetBackground("rgba(0,0,0,0.5)")
		layout.Style().SetWidthPx(320)

		header := gwu.NewLabel(rarityStr)
		header.Style().SetColor("rgb(255,255,255)")
		header.Style().SetFontWeight("bold")
		header.Style().SetFontSize("x-large")
		layout.Add(header)

		table := gwu.NewTable()
		layout.Add(table)

		table.SetCellPadding(5)

		row := 0
		for _, sortedItem := range sorted {
			if CardRarities[sortedItem.card] != rarity {
				continue
			}

			table.Add(gwu.NewImage("", fmt.Sprintf("images/%s.png", CardResources[sortedItem.card])), row, 0)
			table.Add(gwu.NewLabel(string(sortedItem.card)), row, 1)
			table.Add(gwu.NewLabel(fmt.Sprintf("%d", sortedItem.buy)), row, 2)
			table.Add(gwu.NewLabel(fmt.Sprintf("%d", sortedItem.sell)), row, 3)
			if row%2 == 0 {
				table.RowFmt(row).Style().SetBackground("rgba(255,255,255,0.75)")
			} else {
				table.RowFmt(row).Style().SetBackground("rgba(150,150,150,0.75)")
			}
			row++
		}
	}
}
// setNoWrap sets WHITE_SPACE_NOWRAP to all children of the specified panel.
func setNoWrap(panel gwu.Panel) {
	count := panel.CompsCount()
	for i := count - 1; i >= 0; i-- {
		panel.CompAt(i).Style().SetWhiteSpace(gwu.WHITE_SPACE_NOWRAP)
	}
}