From 47a61ccb29cf0c4cbd69aca393f28bfd8e89c3a1 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 1 Oct 2018 23:50:37 +0300 Subject: [PATCH] Addd basis for tech progress bar --- core/src/com/unciv/logic/civilization/TechManager.kt | 5 +++-- core/src/com/unciv/ui/worldscreen/WorldScreen.kt | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/core/src/com/unciv/logic/civilization/TechManager.kt b/core/src/com/unciv/logic/civilization/TechManager.kt index 97f2df4997..5185d08c39 100644 --- a/core/src/com/unciv/logic/civilization/TechManager.kt +++ b/core/src/com/unciv/logic/civilization/TechManager.kt @@ -44,9 +44,10 @@ class TechManager { else return 0 } + fun remainingScienceToTech(techName: String) = costOfTech(techName) - researchOfTech(techName) + fun turnsToTech(techName: String): Int { - val remainingScience = costOfTech(techName) - researchOfTech(techName) - return Math.ceil( remainingScience.toDouble() + return Math.ceil( remainingScienceToTech(techName).toDouble() / civInfo.getStatsForNextTurn().science).toInt() } diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index ed625ef07f..a2c5c33d2e 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -3,6 +3,7 @@ package com.unciv.ui.worldscreen import com.badlogic.gdx.Gdx import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.math.Vector2 +import com.badlogic.gdx.scenes.scene2d.Group import com.badlogic.gdx.scenes.scene2d.ui.Label import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.TextButton @@ -166,8 +167,13 @@ class WorldScreen : CameraStageBaseScreen() { techButton.add(Label("{Pick a tech}!".tr(),skin).setFontColor(Color.WHITE).setFont(22)) else { val tech = civInfo.tech.currentTechnology()!! + val height = 30f if(ImageGetter.techIconExists(tech)) - techButton.add(ImageGetter.getTechIcon(tech)).size(30f) + techButton.add(ImageGetter.getTechIcon(tech)).size(height) + val advancementGroup = Group() + val percentageComplete = civInfo.tech.costOfTech(tech) / civInfo.tech.costOfTech(tech).toFloat() + // todo + techButton.add() techButton.add(Label(tech.tr() + "\r\n" + civInfo.tech.turnsToTech(tech) + " {turns}".tr(),skin) .setFontColor(Color.WHITE).setFont(22))