mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-10 07:16:54 +07:00
Better trade screen for portrait mode
This commit is contained in:
parent
51e223c8ad
commit
5fcbafda78
@ -68,7 +68,7 @@ class DiplomacyScreen(
|
||||
}
|
||||
|
||||
private val leftSideTable = Table().apply { defaults().pad(nationIconPad) }
|
||||
private val leftSideScroll = ScrollPane(leftSideTable)
|
||||
val leftSideScroll = ScrollPane(leftSideTable)
|
||||
private val rightSideTable = Table()
|
||||
private val closeButton = Constants.close.toTextButton()
|
||||
|
||||
|
@ -7,11 +7,11 @@ import com.unciv.logic.trade.TradeOffer
|
||||
import com.unciv.logic.trade.TradeOffersList
|
||||
import com.unciv.logic.trade.TradeType
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.components.extensions.addSeparator
|
||||
import com.unciv.ui.components.extensions.surroundWithCircle
|
||||
import com.unciv.ui.images.ImageGetter
|
||||
import com.unciv.ui.popups.AskNumberPopup
|
||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||
import com.unciv.ui.components.extensions.addSeparator
|
||||
import com.unciv.ui.components.extensions.surroundWithCircle
|
||||
|
||||
/** This is the class that holds the 4 columns of the offers (ours/theirs/ offered/available) in trade */
|
||||
class OfferColumnsTable(private val tradeLogic: TradeLogic, val screen: DiplomacyScreen, val onChange: () -> Unit): Table(
|
||||
@ -55,20 +55,41 @@ class OfferColumnsTable(private val tradeLogic: TradeLogic, val screen: Diplomac
|
||||
|
||||
init {
|
||||
defaults().pad(5f)
|
||||
val columnWidth = screen.stage.width / 3
|
||||
|
||||
add("Our items".tr())
|
||||
add("[${tradeLogic.otherCivilization.civName}]'s items".tr()).row()
|
||||
val isPortraitMode = screen.isNarrowerThan4to3()
|
||||
|
||||
add(ourAvailableOffersTable).prefSize(columnWidth, screen.stage.height / 2)
|
||||
add(theirAvailableOffersTable).prefSize(columnWidth, screen.stage.height / 2).row()
|
||||
val columnWidth = (screen.stage.width - screen.leftSideScroll.width) / 2
|
||||
|
||||
addSeparator().height(2f)
|
||||
if (!isPortraitMode) {
|
||||
add("Our items".tr())
|
||||
add("[${tradeLogic.otherCivilization.civName}]'s items".tr()).row()
|
||||
|
||||
add("Our trade offer".tr())
|
||||
add("[${tradeLogic.otherCivilization.civName}]'s trade offer".tr()).row()
|
||||
add(ourOffersTable).size(columnWidth, screen.stage.height / 3)
|
||||
add(theirOffersTable).size(columnWidth, screen.stage.height / 3)
|
||||
add(ourAvailableOffersTable).prefSize(columnWidth, screen.stage.height / 2)
|
||||
add(theirAvailableOffersTable).prefSize(columnWidth, screen.stage.height / 2).row()
|
||||
|
||||
addSeparator().height(2f)
|
||||
|
||||
add("Our trade offer".tr())
|
||||
add("[${tradeLogic.otherCivilization.civName}]'s trade offer".tr()).row()
|
||||
add(ourOffersTable).size(columnWidth, screen.stage.height / 3)
|
||||
add(theirOffersTable).size(columnWidth, screen.stage.height / 3)
|
||||
}
|
||||
else {
|
||||
add("Our items".tr()).colspan(2).row()
|
||||
add(ourAvailableOffersTable).height(screen.stage.height / 4f).colspan(2).row()
|
||||
|
||||
addSeparator().height(2f)
|
||||
|
||||
add("[${tradeLogic.otherCivilization.civName}]'s items".tr()).colspan(2).row()
|
||||
add(theirAvailableOffersTable).height(screen.stage.height / 4f).colspan(2).row()
|
||||
|
||||
addSeparator().height(5f)
|
||||
|
||||
add("Our trade offer".tr())
|
||||
add("[${tradeLogic.otherCivilization.civName}]'s trade offer".tr()).row()
|
||||
add(ourOffersTable).height(screen.stage.height / 4f).width(columnWidth)
|
||||
add(theirOffersTable).height(screen.stage.height / 4f).width(columnWidth)
|
||||
}
|
||||
pack()
|
||||
update()
|
||||
}
|
||||
@ -96,8 +117,8 @@ class OfferColumnsTable(private val tradeLogic: TradeLogic, val screen: Diplomac
|
||||
icon = ImageGetter.getStatIcon("Gold").surroundWithCircle(80f),
|
||||
defaultValue = offer.amount.toString(),
|
||||
amountButtons =
|
||||
if (offer.type == TradeType.Gold) listOf(50, 500)
|
||||
else listOf(5, 15),
|
||||
if (offer.type == TradeType.Gold) listOf(50, 500)
|
||||
else listOf(5, 15),
|
||||
bounds = IntRange(0, maxGold),
|
||||
actionOnOk = { userInput ->
|
||||
offer.amount = userInput
|
||||
|
Loading…
Reference in New Issue
Block a user