Compare commits
2 Commits
51b46a3e89
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| d8f6176e7e | |||
| e279d38cbf |
@@ -33,6 +33,21 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import ca.jonathanmccaffrey.igp.di.ServiceLocator
|
||||
import ca.jonathanmccaffrey.igp.ui.screens.AboutScreen
|
||||
import ca.jonathanmccaffrey.igp.ui.screens.BuildCalculatorScreen
|
||||
import ca.jonathanmccaffrey.igp.ui.screens.ContactScreen
|
||||
import ca.jonathanmccaffrey.igp.ui.screens.DataCollectionScreen
|
||||
import ca.jonathanmccaffrey.igp.ui.screens.DataTablesScreen
|
||||
import ca.jonathanmccaffrey.igp.ui.screens.DatabaseScreen
|
||||
import ca.jonathanmccaffrey.igp.ui.screens.EconomyComparisonScreen
|
||||
import ca.jonathanmccaffrey.igp.ui.screens.HarassCalculatorScreen
|
||||
import ca.jonathanmccaffrey.igp.ui.screens.HomeScreen
|
||||
import ca.jonathanmccaffrey.igp.ui.screens.MemoryTesterScreen
|
||||
import ca.jonathanmccaffrey.igp.ui.screens.NotesScreen
|
||||
import ca.jonathanmccaffrey.igp.ui.screens.PermissionsScreen
|
||||
import ca.jonathanmccaffrey.igp.ui.screens.RoadMapScreen
|
||||
import ca.jonathanmccaffrey.igp.ui.screens.StorageScreen
|
||||
import ca.jonathanmccaffrey.igp.ui.screens.StreamsScreen
|
||||
import ca.jonathanmccaffrey.igp.ui.theme.IGPTheme
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
@@ -74,6 +89,7 @@ sealed class ScreenContent {
|
||||
data object DataTables : ScreenContent()
|
||||
data object Permissions : ScreenContent()
|
||||
data object DataCollection : ScreenContent()
|
||||
data object Storage : ScreenContent()
|
||||
data object Streams : ScreenContent()
|
||||
data object Contact : ScreenContent()
|
||||
data object RoadMap : ScreenContent()
|
||||
@@ -88,7 +104,7 @@ fun IGPApp() {
|
||||
listOf(ScreenContent.Database),
|
||||
listOf(ScreenContent.BuildCalculator, ScreenContent.EconomyComparison, ScreenContent.MemoryTester, ScreenContent.HarassCalculator, ScreenContent.DataTables),
|
||||
listOf(ScreenContent.Notes),
|
||||
listOf(ScreenContent.About, ScreenContent.Permissions, ScreenContent.DataCollection, ScreenContent.Streams, ScreenContent.Contact, ScreenContent.RoadMap),
|
||||
listOf(ScreenContent.About, ScreenContent.Permissions, ScreenContent.Storage, ScreenContent.DataCollection, ScreenContent.Streams, ScreenContent.Contact, ScreenContent.RoadMap),
|
||||
)
|
||||
|
||||
var currentScreen by remember { mutableStateOf<ScreenContent>(ScreenContent.Home) }
|
||||
@@ -116,70 +132,24 @@ fun IGPApp() {
|
||||
}
|
||||
},
|
||||
) { innerPadding ->
|
||||
when (currentScreen) {
|
||||
is ScreenContent.Home -> HomeScreen(Modifier.padding(innerPadding))
|
||||
is ScreenContent.Database -> DatabaseScreen(Modifier.padding(innerPadding))
|
||||
is ScreenContent.BuildCalculator -> BuildCalculatorScreen(Modifier.padding(innerPadding))
|
||||
is ScreenContent.EconomyComparison -> EconomyComparisonScreen(Modifier.padding(innerPadding))
|
||||
is ScreenContent.MemoryTester -> MemoryTesterScreen(Modifier.padding(innerPadding))
|
||||
is ScreenContent.Notes -> NotesScreen(Modifier.padding(innerPadding))
|
||||
is ScreenContent.About -> AboutScreen(Modifier.padding(innerPadding))
|
||||
is ScreenContent.HarassCalculator -> HarassCalculatorScreen(Modifier.padding(innerPadding))
|
||||
is ScreenContent.DataTables -> DataTablesScreen(Modifier.padding(innerPadding))
|
||||
is ScreenContent.Permissions -> PermissionsScreen(Modifier.padding(innerPadding))
|
||||
is ScreenContent.DataCollection -> DataCollectionScreen(Modifier.padding(innerPadding))
|
||||
is ScreenContent.Streams -> StreamsScreen(Modifier.padding(innerPadding))
|
||||
is ScreenContent.Contact -> ContactScreen(Modifier.padding(innerPadding))
|
||||
is ScreenContent.RoadMap -> RoadMapScreen(Modifier.padding(innerPadding))
|
||||
Box(modifier = Modifier.padding(innerPadding)) {
|
||||
when (currentScreen) {
|
||||
is ScreenContent.Home -> HomeScreen()
|
||||
is ScreenContent.Database -> DatabaseScreen()
|
||||
is ScreenContent.BuildCalculator -> BuildCalculatorScreen()
|
||||
is ScreenContent.EconomyComparison -> EconomyComparisonScreen()
|
||||
is ScreenContent.MemoryTester -> MemoryTesterScreen()
|
||||
is ScreenContent.Notes -> NotesScreen()
|
||||
is ScreenContent.About -> AboutScreen()
|
||||
is ScreenContent.HarassCalculator -> HarassCalculatorScreen()
|
||||
is ScreenContent.DataTables -> DataTablesScreen()
|
||||
is ScreenContent.Permissions -> PermissionsScreen()
|
||||
is ScreenContent.DataCollection -> DataCollectionScreen()
|
||||
is ScreenContent.Storage -> StorageScreen()
|
||||
is ScreenContent.Streams -> StreamsScreen()
|
||||
is ScreenContent.Contact -> ContactScreen()
|
||||
is ScreenContent.RoadMap -> RoadMapScreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun PlaceholderScreen(name: String, modifier: Modifier = Modifier) {
|
||||
Box(modifier = modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||
Text(text = name, textAlign = TextAlign.Center)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun HomeScreen(modifier: Modifier = Modifier) = PlaceholderScreen("Home", modifier)
|
||||
|
||||
@Composable
|
||||
fun DatabaseScreen(modifier: Modifier = Modifier) = PlaceholderScreen("Database", modifier)
|
||||
|
||||
@Composable
|
||||
fun BuildCalculatorScreen(modifier: Modifier = Modifier) = PlaceholderScreen("Build Calculator", modifier)
|
||||
|
||||
@Composable
|
||||
fun EconomyComparisonScreen(modifier: Modifier = Modifier) = PlaceholderScreen("Economy Comparison", modifier)
|
||||
|
||||
@Composable
|
||||
fun MemoryTesterScreen(modifier: Modifier = Modifier) = PlaceholderScreen("Memory Tester", modifier)
|
||||
|
||||
@Composable
|
||||
fun NotesScreen(modifier: Modifier = Modifier) = PlaceholderScreen("Notes", modifier)
|
||||
|
||||
@Composable
|
||||
fun AboutScreen(modifier: Modifier = Modifier) = PlaceholderScreen("About", modifier)
|
||||
|
||||
@Composable
|
||||
fun HarassCalculatorScreen(modifier: Modifier = Modifier) = PlaceholderScreen("Harass Calculator", modifier)
|
||||
|
||||
@Composable
|
||||
fun DataTablesScreen(modifier: Modifier = Modifier) = PlaceholderScreen("Data Tables", modifier)
|
||||
|
||||
@Composable
|
||||
fun PermissionsScreen(modifier: Modifier = Modifier) = PlaceholderScreen("Permissions", modifier)
|
||||
|
||||
@Composable
|
||||
fun DataCollectionScreen(modifier: Modifier = Modifier) = PlaceholderScreen("Data Collection", modifier)
|
||||
|
||||
@Composable
|
||||
fun StreamsScreen(modifier: Modifier = Modifier) = PlaceholderScreen("Streams", modifier)
|
||||
|
||||
@Composable
|
||||
fun ContactScreen(modifier: Modifier = Modifier) = PlaceholderScreen("Contact", modifier)
|
||||
|
||||
@Composable
|
||||
fun RoadMapScreen(modifier: Modifier = Modifier) = PlaceholderScreen("Road Map", modifier)
|
||||
|
||||
@@ -69,22 +69,22 @@ class EntityModel(
|
||||
}
|
||||
|
||||
fun info(): EntityInfoModel =
|
||||
entityParts.find { it is EntityInfoModel } as EntityInfoModel
|
||||
(entityParts.find { it is EntityInfoModel } as? EntityInfoModel) ?: EntityInfoModel()
|
||||
|
||||
fun supply(): EntitySupplyModel? =
|
||||
entityParts.find { it is EntitySupplyModel } as? EntitySupplyModel
|
||||
|
||||
fun tier(): EntityTierModel =
|
||||
entityParts.find { it is EntityTierModel } as EntityTierModel
|
||||
(entityParts.find { it is EntityTierModel } as? EntityTierModel) ?: EntityTierModel()
|
||||
|
||||
fun production(): EntityProductionModel? =
|
||||
entityParts.find { it is EntityProductionModel } as? EntityProductionModel
|
||||
|
||||
fun movement(): EntityMovementModel =
|
||||
entityParts.find { it is EntityMovementModel } as EntityMovementModel
|
||||
(entityParts.find { it is EntityMovementModel } as? EntityMovementModel) ?: EntityMovementModel()
|
||||
|
||||
fun vitality(): EntityVitalityModel =
|
||||
entityParts.find { it is EntityVitalityModel } as EntityVitalityModel
|
||||
(entityParts.find { it is EntityVitalityModel } as? EntityVitalityModel) ?: EntityVitalityModel()
|
||||
|
||||
fun requirements(): List<EntityRequirementModel> =
|
||||
entityParts.filterIsInstance<EntityRequirementModel>()
|
||||
|
||||
+3327
-135
File diff suppressed because it is too large
Load Diff
@@ -156,6 +156,7 @@ object IdsEntity {
|
||||
const val PASSIVE_RegentsWrath = "f111f004-6548-4430-9d13-ef44ab108ae7"
|
||||
const val PASSIVE_PsalmOfFire = "PASSIVE_PsalmOfFire"
|
||||
const val PASSIVE_HallowedWeapons = "f9ac4b3e-d02d-42d4-8d9d-beb9c5d7edcb"
|
||||
const val PASSIVE_Maledictions = "PASSIVE_Maledictions"
|
||||
const val PASSIVE_Zeal = "62c4942b-5578-422d-8d4e-d1789f4efa68"
|
||||
const val PASSIVE_HallowedGround = "bdb28984-246f-4642-84ab-9e83c02b3e2e"
|
||||
const val PASSIVE_Rootway = "46768d4a-5047-4973-b5ca-995cda25ee8d"
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package ca.jonathanmccaffrey.igp.data.models.entity.types
|
||||
|
||||
object ArmorType {
|
||||
const val Light = "Light"
|
||||
const val Medium = "Medium"
|
||||
const val Heavy = "Heavy"
|
||||
}
|
||||
@@ -11,10 +11,17 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.ExposedDropdownMenuBox
|
||||
import androidx.compose.material3.ExposedDropdownMenuDefaults
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
@@ -25,15 +32,29 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import ca.jonathanmccaffrey.igp.data.models.entity.data.EntityType
|
||||
import ca.jonathanmccaffrey.igp.data.models.entity.data.IdsEntity
|
||||
import ca.jonathanmccaffrey.igp.di.ServiceLocator
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun BuildCalculatorScreen() {
|
||||
val timingService = ServiceLocator.timingService
|
||||
val buildOrderService = ServiceLocator.buildOrderService
|
||||
val economyService = ServiceLocator.economyService
|
||||
val keyService = ServiceLocator.keyService
|
||||
val immortalSelectionService = ServiceLocator.immortalSelectionService
|
||||
val entityFilterService = ServiceLocator.entityFilterService
|
||||
|
||||
var attackTime by remember { mutableStateOf(timingService.getAttackTime()) }
|
||||
var travelTime by remember { mutableStateOf(timingService.getTravelTime()) }
|
||||
var factionExpanded by remember { mutableStateOf(false) }
|
||||
var immortalExpanded by remember { mutableStateOf(false) }
|
||||
val factionChoices = remember { entityFilterService.getFactionChoices() }
|
||||
var selectedFaction by remember { mutableStateOf(immortalSelectionService.getFaction()) }
|
||||
val immortalChoices = remember { entityFilterService.getImmortalChoices() }
|
||||
var selectedImmortal by remember { mutableStateOf(immortalSelectionService.getImmortal()) }
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
timingService.onChange.collect {
|
||||
@@ -46,12 +67,23 @@ fun BuildCalculatorScreen() {
|
||||
buildOrderService.onChange.collect { }
|
||||
}
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
economyService.onChange.collect { }
|
||||
}
|
||||
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize().padding(16.dp)
|
||||
) {
|
||||
Text(
|
||||
text = "Build Calculator",
|
||||
style = MaterialTheme.typography.headlineMedium
|
||||
)
|
||||
|
||||
Spacer(Modifier.height(12.dp))
|
||||
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 4.dp)
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().padding(16.dp),
|
||||
@@ -65,6 +97,100 @@ fun BuildCalculatorScreen() {
|
||||
|
||||
Spacer(Modifier.height(12.dp))
|
||||
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||
) {
|
||||
ExposedDropdownMenuBox(
|
||||
expanded = factionExpanded,
|
||||
onExpandedChange = { factionExpanded = it },
|
||||
modifier = Modifier.weight(1f)
|
||||
) {
|
||||
OutlinedTextField(
|
||||
value = selectedFaction,
|
||||
onValueChange = {},
|
||||
readOnly = true,
|
||||
label = { Text("Faction") },
|
||||
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = factionExpanded) },
|
||||
modifier = Modifier.menuAnchor().fillMaxWidth()
|
||||
)
|
||||
ExposedDropdownMenu(
|
||||
expanded = factionExpanded,
|
||||
onDismissRequest = { factionExpanded = false }
|
||||
) {
|
||||
factionChoices.filter { it != IdsEntity.Any && it != IdsEntity.None }.forEach { faction ->
|
||||
DropdownMenuItem(
|
||||
text = { Text(faction) },
|
||||
onClick = {
|
||||
selectedFaction = faction
|
||||
factionExpanded = false
|
||||
immortalSelectionService.selectFaction(faction)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ExposedDropdownMenuBox(
|
||||
expanded = immortalExpanded,
|
||||
onExpandedChange = { immortalExpanded = it },
|
||||
modifier = Modifier.weight(1f)
|
||||
) {
|
||||
OutlinedTextField(
|
||||
value = selectedImmortal,
|
||||
onValueChange = {},
|
||||
readOnly = true,
|
||||
label = { Text("Immortal") },
|
||||
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = immortalExpanded) },
|
||||
modifier = Modifier.menuAnchor().fillMaxWidth()
|
||||
)
|
||||
ExposedDropdownMenu(
|
||||
expanded = immortalExpanded,
|
||||
onDismissRequest = { immortalExpanded = false }
|
||||
) {
|
||||
immortalChoices.forEach { immortal ->
|
||||
DropdownMenuItem(
|
||||
text = { Text(immortal) },
|
||||
onClick = {
|
||||
selectedImmortal = immortal
|
||||
immortalExpanded = false
|
||||
immortalSelectionService.selectImmortal(immortal)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(12.dp))
|
||||
|
||||
val economyData = economyService.getOverTime().let { list ->
|
||||
if (list.isNotEmpty()) {
|
||||
val last = list.last()
|
||||
list.firstOrNull { it.interval == buildOrderService.getLastRequestInterval() } ?: last
|
||||
} else null
|
||||
}
|
||||
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
) {
|
||||
Column(modifier = Modifier.padding(16.dp)) {
|
||||
Text("Economy State", style = MaterialTheme.typography.titleSmall)
|
||||
if (economyData != null) {
|
||||
Text("Alloy: ${"%.1f".format(economyData.alloy)}", style = MaterialTheme.typography.bodySmall)
|
||||
Text("Ether: ${"%.1f".format(economyData.ether)}", style = MaterialTheme.typography.bodySmall)
|
||||
Text("Pyre: ${"%.1f".format(economyData.pyre)}", style = MaterialTheme.typography.bodySmall)
|
||||
Text("Workers: ${economyData.workerCount} (Busy: ${economyData.busyWorkerCount}, Creating: ${economyData.creatingWorkerCount})", style = MaterialTheme.typography.bodySmall)
|
||||
Text("Harvest Points: ${economyData.harvestPoints.size}", style = MaterialTheme.typography.bodySmall)
|
||||
} else {
|
||||
Text("No economy data available", style = MaterialTheme.typography.bodySmall)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(12.dp))
|
||||
|
||||
Text(
|
||||
text = "Build Order Timeline",
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
@@ -74,8 +200,8 @@ fun BuildCalculatorScreen() {
|
||||
modifier = Modifier.weight(1f).padding(vertical = 8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(6.dp)
|
||||
) {
|
||||
val allOrders = buildOrderService.getOrders()
|
||||
items(allOrders.entries.toList()) { (interval, entities) ->
|
||||
val allOrders = buildOrderService.startedOrders
|
||||
items(allOrders.entries.sortedBy { it.key }.toList()) { (interval, entities) ->
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 1.dp)
|
||||
@@ -108,5 +234,43 @@ fun BuildCalculatorScreen() {
|
||||
Text("Reset")
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(12.dp))
|
||||
|
||||
HorizontalDivider()
|
||||
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
Text(
|
||||
text = "Economy Over Time",
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
)
|
||||
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
val economyOverTime = economyService.getOverTime()
|
||||
Column(
|
||||
modifier = Modifier.height(200.dp).verticalScroll(rememberScrollState())
|
||||
) {
|
||||
economyOverTime.take(60).forEach { econ ->
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth().padding(vertical = 2.dp),
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceVariant
|
||||
)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 4.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text("T=${econ.interval}", style = MaterialTheme.typography.labelSmall)
|
||||
Text("A:${"%.0f".format(econ.alloy)}", style = MaterialTheme.typography.labelSmall)
|
||||
Text("E:${"%.0f".format(econ.ether)}", style = MaterialTheme.typography.labelSmall)
|
||||
Text("P:${"%.0f".format(econ.pyre)}", style = MaterialTheme.typography.labelSmall)
|
||||
Text("W:${econ.workerCount}", style = MaterialTheme.typography.labelSmall)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package ca.jonathanmccaffrey.igp.ui.screens
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -20,10 +25,23 @@ fun DataCollectionScreen() {
|
||||
text = "Data Collection",
|
||||
style = MaterialTheme.typography.headlineMedium
|
||||
)
|
||||
Spacer(Modifier.height(16.dp))
|
||||
Text(
|
||||
text = "Data collection settings and preferences.",
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
modifier = Modifier.padding(top = 16.dp)
|
||||
text = "Data collection is not implemented on mobile.",
|
||||
style = MaterialTheme.typography.bodyLarge
|
||||
)
|
||||
Spacer(Modifier.height(12.dp))
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.secondaryContainer
|
||||
)
|
||||
) {
|
||||
Text(
|
||||
text = "Check the Permissions page to manage your privacy settings.",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
modifier = Modifier.padding(16.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +1,316 @@
|
||||
package ca.jonathanmccaffrey.igp.ui.screens
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ScrollableTabRow
|
||||
import androidx.compose.material3.Tab
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import ca.jonathanmccaffrey.igp.data.models.entity.EntityModel
|
||||
import ca.jonathanmccaffrey.igp.data.models.entity.parts.EntityMovementModel
|
||||
import ca.jonathanmccaffrey.igp.data.models.entity.parts.EntityVitalityModel
|
||||
import ca.jonathanmccaffrey.igp.data.models.entity.parts.EntityWeaponModel
|
||||
|
||||
@Composable
|
||||
fun DataTablesScreen() {
|
||||
val entities = remember { EntityModel.getList() }
|
||||
var selectedTabIndex by remember { mutableStateOf(0) }
|
||||
val tabTitles = listOf("Weapons", "Production", "Health", "Movement")
|
||||
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize().padding(16.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
modifier = Modifier.fillMaxSize().padding(16.dp)
|
||||
) {
|
||||
Text(
|
||||
text = "Data Tables",
|
||||
style = MaterialTheme.typography.headlineMedium
|
||||
)
|
||||
Text(
|
||||
text = "This tool is incomplete.",
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
modifier = Modifier.padding(top = 16.dp)
|
||||
)
|
||||
|
||||
Spacer(Modifier.height(4.dp))
|
||||
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth().padding(top = 12.dp),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.errorContainer
|
||||
containerColor = MaterialTheme.colorScheme.tertiaryContainer
|
||||
)
|
||||
) {
|
||||
Text(
|
||||
text = "Errors Present / Incomplete Data",
|
||||
text = "Incomplete feature for easily comparing unit stats. Some data may be missing.",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
modifier = Modifier.padding(16.dp)
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
ScrollableTabRow(selectedTabIndex = selectedTabIndex) {
|
||||
tabTitles.forEachIndexed { index, title ->
|
||||
Tab(
|
||||
selected = selectedTabIndex == index,
|
||||
onClick = { selectedTabIndex = index },
|
||||
text = { Text(title) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalDivider()
|
||||
|
||||
when (selectedTabIndex) {
|
||||
0 -> WeaponsTab(entities)
|
||||
1 -> ProductionTab(entities)
|
||||
2 -> HealthTab(entities)
|
||||
3 -> MovementTab(entities)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun WeaponsTab(entities: List<EntityModel>) {
|
||||
val withWeapons = entities.filter { it.weapons().isNotEmpty() }
|
||||
|
||||
LazyColumn(
|
||||
modifier = Modifier.padding(top = 8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
items(withWeapons) { entity ->
|
||||
WeaponCard(entity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun WeaponCard(entity: EntityModel) {
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
) {
|
||||
Column(modifier = Modifier.padding(12.dp)) {
|
||||
Text(
|
||||
text = entity.info().name,
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
Spacer(Modifier.height(4.dp))
|
||||
entity.weapons().forEachIndexed { index, weapon ->
|
||||
if (index > 0) Spacer(Modifier.height(4.dp))
|
||||
WeaponRow(weapon)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun WeaponRow(weapon: EntityWeaponModel) {
|
||||
val dps = weapon.damage * weapon.attacksPerSecond
|
||||
Column {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text(
|
||||
text = "Range: ${weapon.range}",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
Text(
|
||||
text = "Damage: ${weapon.damage}",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
Text(
|
||||
text = "DPS: ${"%.1f".format(dps)}",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
}
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text(
|
||||
text = "Targets: ${weapon.targets}",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
Text(
|
||||
text = "HasSplash: ${if (weapon.hasSplash) "Yes" else "No"}",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ProductionTab(entities: List<EntityModel>) {
|
||||
val withProduction = entities.filter { entity ->
|
||||
val p = entity.production()
|
||||
p != null && (p.alloy != 0 || p.buildTime != 0)
|
||||
}
|
||||
|
||||
LazyColumn(
|
||||
modifier = Modifier.padding(top = 8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
items(withProduction) { entity ->
|
||||
ProductionCard(entity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ProductionCard(entity: EntityModel) {
|
||||
val prod = entity.production()!!
|
||||
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
) {
|
||||
Column(modifier = Modifier.padding(12.dp)) {
|
||||
Text(
|
||||
text = entity.info().name,
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text(
|
||||
text = "Alloy: ${prod.alloy}",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
Text(
|
||||
text = "Ether: ${prod.ether}",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
Text(
|
||||
text = "BuildTime: ${prod.buildTime}",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun HealthTab(entities: List<EntityModel>) {
|
||||
val withVitality = entities.filter { it.entityParts.any { p -> p is EntityVitalityModel } }
|
||||
|
||||
LazyColumn(
|
||||
modifier = Modifier.padding(top = 8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
items(withVitality) { entity ->
|
||||
HealthCard(entity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun HealthCard(entity: EntityModel) {
|
||||
val vit = entity.vitality()
|
||||
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
) {
|
||||
Column(modifier = Modifier.padding(12.dp)) {
|
||||
Text(
|
||||
text = entity.info().name,
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text(
|
||||
text = "Health: ${vit.health}",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
Text(
|
||||
text = "Armor: ${vit.armor}",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
Text(
|
||||
text = "Defense: ${vit.defense}",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
}
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text(
|
||||
text = "DefenseLayer: ${vit.defenseLayer}",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
Text(
|
||||
text = "IsStructure: ${if (vit.isStructure) "Yes" else "No"}",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
Text(
|
||||
text = "IsEtheric: ${if (vit.isEtheric) "Yes" else "No"}",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun MovementTab(entities: List<EntityModel>) {
|
||||
val withMovement = entities.filter { it.entityParts.any { p -> p is EntityMovementModel } }
|
||||
|
||||
LazyColumn(
|
||||
modifier = Modifier.padding(top = 8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
items(withMovement) { entity ->
|
||||
MovementCard(entity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun MovementCard(entity: EntityModel) {
|
||||
val mov = entity.movement()
|
||||
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
) {
|
||||
Column(modifier = Modifier.padding(12.dp)) {
|
||||
Text(
|
||||
text = entity.info().name,
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text(
|
||||
text = "Speed: ${mov.speed}",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
Text(
|
||||
text = "Movement: ${mov.movement}",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ca.jonathanmccaffrey.igp.ui.screens
|
||||
|
||||
import androidx.compose.foundation.horizontalScroll
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
@@ -10,12 +11,11 @@ import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.ExposedDropdownMenuBox
|
||||
import androidx.compose.material3.ExposedDropdownMenuDefaults
|
||||
import androidx.compose.material3.FilterChip
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Text
|
||||
@@ -27,20 +27,19 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import ca.jonathanmccaffrey.igp.data.models.entity.EntityModel
|
||||
import ca.jonathanmccaffrey.igp.data.models.entity.data.IdsEntity
|
||||
import ca.jonathanmccaffrey.igp.data.models.entity.data.EntityType as EntityTypeConst
|
||||
import ca.jonathanmccaffrey.igp.di.ServiceLocator
|
||||
import ca.jonathanmccaffrey.igp.services.website.EntityFilterEvent
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun DatabaseScreen() {
|
||||
val filterService = ServiceLocator.entityFilterService
|
||||
var factionExpanded by remember { mutableStateOf(false) }
|
||||
var immortalExpanded by remember { mutableStateOf(false) }
|
||||
var entityTypeExpanded by remember { mutableStateOf(false) }
|
||||
|
||||
var factionText by remember { mutableStateOf(filterService.getFactionType()) }
|
||||
var immortalText by remember { mutableStateOf(filterService.getImmortalType()) }
|
||||
var entityTypeText by remember { mutableStateOf(filterService.getEntityType()) }
|
||||
var factionType by remember { mutableStateOf(filterService.getFactionType()) }
|
||||
var immortalType by remember { mutableStateOf(filterService.getImmortalType()) }
|
||||
var entityType by remember { mutableStateOf(filterService.getEntityType()) }
|
||||
var searchText by remember { mutableStateOf(filterService.getSearchText()) }
|
||||
|
||||
val factionChoices = remember { filterService.getFactionChoices() }
|
||||
@@ -50,18 +49,24 @@ fun DatabaseScreen() {
|
||||
LaunchedEffect(Unit) {
|
||||
filterService.onChange.collect { event ->
|
||||
when (event) {
|
||||
EntityFilterEvent.OnRefreshFaction ->
|
||||
factionText = filterService.getFactionType()
|
||||
EntityFilterEvent.OnRefreshImmortal ->
|
||||
immortalText = filterService.getImmortalType()
|
||||
EntityFilterEvent.OnRefreshEntity ->
|
||||
entityTypeText = filterService.getEntityType()
|
||||
EntityFilterEvent.OnRefreshSearch ->
|
||||
searchText = filterService.getSearchText()
|
||||
EntityFilterEvent.OnRefreshFaction -> factionType = filterService.getFactionType()
|
||||
EntityFilterEvent.OnRefreshImmortal -> immortalType = filterService.getImmortalType()
|
||||
EntityFilterEvent.OnRefreshEntity -> entityType = filterService.getEntityType()
|
||||
EntityFilterEvent.OnRefreshSearch -> searchText = filterService.getSearchText()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val allEntities = remember { EntityModel.getList() }
|
||||
|
||||
val filteredEntities = allEntities.filter { entity ->
|
||||
val matchesFaction = factionType == IdsEntity.Any || entity.faction()?.faction == factionType
|
||||
val matchesImmortal = immortalType == IdsEntity.Any || entity.vanguardAdded()?.immortalId == immortalType
|
||||
val matchesEntityType = entityType == EntityTypeConst.Any || entity.entityType == entityType
|
||||
val matchesSearch = searchText.isEmpty() || entity.getName().contains(searchText, ignoreCase = true)
|
||||
matchesFaction && matchesImmortal && matchesEntityType && matchesSearch
|
||||
}
|
||||
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize().padding(16.dp)
|
||||
) {
|
||||
@@ -69,121 +74,163 @@ fun DatabaseScreen() {
|
||||
text = "Database",
|
||||
style = MaterialTheme.typography.headlineMedium
|
||||
)
|
||||
|
||||
Spacer(Modifier.height(4.dp))
|
||||
|
||||
Text(
|
||||
text = "Entity data from current game version",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
|
||||
HorizontalDivider(modifier = Modifier.padding(vertical = 8.dp))
|
||||
|
||||
Text(
|
||||
text = "Faction",
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
factionChoices.forEach { choice ->
|
||||
FilterChip(
|
||||
selected = factionType == choice,
|
||||
onClick = { filterService.selectFactionType(choice) },
|
||||
label = { Text(choice) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
Text(
|
||||
text = "Immortal",
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
immortalChoices.forEach { choice ->
|
||||
FilterChip(
|
||||
selected = immortalType == choice,
|
||||
onClick = { filterService.selectImmortalType(choice) },
|
||||
label = { Text(choice) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
Text(
|
||||
text = "Entity Type",
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
entityChoices.forEach { choice ->
|
||||
FilterChip(
|
||||
selected = entityType == choice,
|
||||
onClick = { filterService.selectEntityType(choice) },
|
||||
label = { Text(choice) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(12.dp))
|
||||
|
||||
ExposedDropdownMenuBox(
|
||||
expanded = factionExpanded,
|
||||
onExpandedChange = { factionExpanded = !factionExpanded }
|
||||
) {
|
||||
OutlinedTextField(
|
||||
value = factionText,
|
||||
onValueChange = {},
|
||||
readOnly = true,
|
||||
label = { Text("Faction") },
|
||||
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = factionExpanded) },
|
||||
modifier = Modifier.fillMaxWidth().menuAnchor()
|
||||
)
|
||||
ExposedDropdownMenu(
|
||||
expanded = factionExpanded,
|
||||
onDismissRequest = { factionExpanded = false }
|
||||
) {
|
||||
factionChoices.forEach { choice ->
|
||||
DropdownMenuItem(
|
||||
text = { Text(choice) },
|
||||
onClick = {
|
||||
factionText = choice
|
||||
filterService.selectFactionType(choice)
|
||||
factionExpanded = false
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
ExposedDropdownMenuBox(
|
||||
expanded = immortalExpanded,
|
||||
onExpandedChange = { immortalExpanded = !immortalExpanded }
|
||||
) {
|
||||
OutlinedTextField(
|
||||
value = immortalText,
|
||||
onValueChange = {},
|
||||
readOnly = true,
|
||||
label = { Text("Immortal") },
|
||||
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = immortalExpanded) },
|
||||
modifier = Modifier.fillMaxWidth().menuAnchor()
|
||||
)
|
||||
ExposedDropdownMenu(
|
||||
expanded = immortalExpanded,
|
||||
onDismissRequest = { immortalExpanded = false }
|
||||
) {
|
||||
immortalChoices.forEach { choice ->
|
||||
DropdownMenuItem(
|
||||
text = { Text(choice) },
|
||||
onClick = {
|
||||
immortalText = choice
|
||||
filterService.selectImmortalType(choice)
|
||||
immortalExpanded = false
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
ExposedDropdownMenuBox(
|
||||
expanded = entityTypeExpanded,
|
||||
onExpandedChange = { entityTypeExpanded = !entityTypeExpanded }
|
||||
) {
|
||||
OutlinedTextField(
|
||||
value = entityTypeText,
|
||||
onValueChange = {},
|
||||
readOnly = true,
|
||||
label = { Text("Entity Type") },
|
||||
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = entityTypeExpanded) },
|
||||
modifier = Modifier.fillMaxWidth().menuAnchor()
|
||||
)
|
||||
ExposedDropdownMenu(
|
||||
expanded = entityTypeExpanded,
|
||||
onDismissRequest = { entityTypeExpanded = false }
|
||||
) {
|
||||
entityChoices.forEach { choice ->
|
||||
DropdownMenuItem(
|
||||
text = { Text(choice) },
|
||||
onClick = {
|
||||
entityTypeText = choice
|
||||
filterService.selectEntityType(choice)
|
||||
entityTypeExpanded = false
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
OutlinedTextField(
|
||||
value = searchText,
|
||||
onValueChange = { filterService.enterSearchText(it) },
|
||||
label = { Text("Search") },
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true
|
||||
)
|
||||
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
Text(
|
||||
text = "${filteredEntities.size} entities found",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
Spacer(Modifier.height(12.dp))
|
||||
|
||||
LazyColumn(
|
||||
modifier = Modifier.weight(1f).padding(top = 4.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
items(10) { index ->
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
) {
|
||||
Text(
|
||||
text = "Entity placeholder $index",
|
||||
modifier = Modifier.padding(16.dp),
|
||||
style = MaterialTheme.typography.bodyLarge
|
||||
)
|
||||
}
|
||||
items(filteredEntities) { entity ->
|
||||
EntityCard(entity = entity)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun EntityCard(entity: EntityModel) {
|
||||
val info = entity.info()
|
||||
val faction = entity.getFaction()
|
||||
val tierModel = entity.tier()
|
||||
val supplyModel = entity.supply()
|
||||
val vitalityModel = entity.vitality()
|
||||
|
||||
val statsLine = buildString {
|
||||
append("HP: ${vitalityModel.health}")
|
||||
if (supplyModel != null) {
|
||||
append(" | Supply: ${supplyModel.takes}/${supplyModel.grants}")
|
||||
}
|
||||
val weapons = entity.weapons()
|
||||
if (weapons.isNotEmpty()) {
|
||||
val totalDps = weapons.sumOf { it.damagePerSecond().toDouble() }
|
||||
append(" | DPS: ${"%.1f".format(totalDps)}")
|
||||
}
|
||||
}
|
||||
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
) {
|
||||
Column(modifier = Modifier.padding(12.dp)) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text(
|
||||
text = info.name,
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
Text(
|
||||
text = "T${tierModel.tier.toInt()}",
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||
) {
|
||||
Text(
|
||||
text = faction,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
Text(
|
||||
text = entity.entityType,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Text(
|
||||
text = statsLine,
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
package ca.jonathanmccaffrey.igp.ui.screens
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Text
|
||||
@@ -21,22 +27,35 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import ca.jonathanmccaffrey.igp.di.ServiceLocator
|
||||
|
||||
@Composable
|
||||
fun EconomyComparisonScreen() {
|
||||
val comparisonService = ServiceLocator.economyComparisonService
|
||||
val service = ServiceLocator.economyComparisonService
|
||||
|
||||
var player1Faction by remember { mutableStateOf(comparisonService.getFaction(1)) }
|
||||
var player2Faction by remember { mutableStateOf(comparisonService.getFaction(2)) }
|
||||
var player1TownHalls by remember { mutableStateOf(comparisonService.getTownHallCount(1).toString()) }
|
||||
var player2TownHalls by remember { mutableStateOf(comparisonService.getTownHallCount(2).toString()) }
|
||||
var p1Faction by remember { mutableStateOf(service.getFaction(0)) }
|
||||
var p2Faction by remember { mutableStateOf(service.getFaction(1)) }
|
||||
var p1TownHalls by remember { mutableStateOf(service.getTownHallCount(0).toString()) }
|
||||
var p2TownHalls by remember { mutableStateOf(service.getTownHallCount(1).toString()) }
|
||||
var p1Times by remember { mutableStateOf(service.getTownHallBuildTimes(0)) }
|
||||
var p2Times by remember { mutableStateOf(service.getTownHallBuildTimes(1)) }
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
comparisonService.onChange.collect { }
|
||||
service.onChange.collect {
|
||||
p1Faction = service.getFaction(0)
|
||||
p2Faction = service.getFaction(1)
|
||||
p1TownHalls = service.getTownHallCount(0).toString()
|
||||
p2TownHalls = service.getTownHallCount(1).toString()
|
||||
p1Times = service.getTownHallBuildTimes(0)
|
||||
p2Times = service.getTownHallBuildTimes(1)
|
||||
}
|
||||
}
|
||||
|
||||
val color1 = parseColor(service.getColor(0))
|
||||
val color2 = parseColor(service.getColor(1))
|
||||
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize().padding(16.dp)
|
||||
) {
|
||||
@@ -47,71 +66,195 @@ fun EconomyComparisonScreen() {
|
||||
Spacer(Modifier.height(16.dp))
|
||||
|
||||
Row(modifier = Modifier.fillMaxWidth()) {
|
||||
Card(
|
||||
modifier = Modifier.weight(1f),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
) {
|
||||
Column(modifier = Modifier.padding(12.dp)) {
|
||||
Text("Player 1", style = MaterialTheme.typography.titleSmall)
|
||||
Text("Faction: $player1Faction", style = MaterialTheme.typography.bodySmall)
|
||||
OutlinedTextField(
|
||||
value = player1TownHalls,
|
||||
onValueChange = {
|
||||
player1TownHalls = it
|
||||
it.toIntOrNull()?.let { count ->
|
||||
comparisonService.changeNumberOfTownHalls(1, count)
|
||||
}
|
||||
},
|
||||
label = { Text("Town Halls") },
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
PlayerCard(
|
||||
label = "Player 1",
|
||||
faction = p1Faction,
|
||||
townHallsText = p1TownHalls,
|
||||
buildTimes = p1Times,
|
||||
onTownHallsChange = { newValue ->
|
||||
p1TownHalls = newValue
|
||||
newValue.toIntOrNull()?.let { count ->
|
||||
service.changeNumberOfTownHalls(0, count.coerceIn(0, 5))
|
||||
}
|
||||
},
|
||||
onBuildTimeChange = { index, time ->
|
||||
time.toIntOrNull()?.let { t ->
|
||||
service.changeTownHallTiming(0, index, t)
|
||||
}
|
||||
},
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
Spacer(Modifier.width(12.dp))
|
||||
|
||||
Card(
|
||||
modifier = Modifier.weight(1f),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
) {
|
||||
Column(modifier = Modifier.padding(12.dp)) {
|
||||
Text("Player 2", style = MaterialTheme.typography.titleSmall)
|
||||
Text("Faction: $player2Faction", style = MaterialTheme.typography.bodySmall)
|
||||
OutlinedTextField(
|
||||
value = player2TownHalls,
|
||||
onValueChange = {
|
||||
player2TownHalls = it
|
||||
it.toIntOrNull()?.let { count ->
|
||||
comparisonService.changeNumberOfTownHalls(2, count)
|
||||
}
|
||||
},
|
||||
label = { Text("Town Halls") },
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
}
|
||||
PlayerCard(
|
||||
label = "Player 2",
|
||||
faction = p2Faction,
|
||||
townHallsText = p2TownHalls,
|
||||
buildTimes = p2Times,
|
||||
onTownHallsChange = { newValue ->
|
||||
p2TownHalls = newValue
|
||||
newValue.toIntOrNull()?.let { count ->
|
||||
service.changeNumberOfTownHalls(1, count.coerceIn(0, 5))
|
||||
}
|
||||
},
|
||||
onBuildTimeChange = { index, time ->
|
||||
time.toIntOrNull()?.let { t ->
|
||||
service.changeTownHallTiming(1, index, t)
|
||||
}
|
||||
},
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(16.dp))
|
||||
HorizontalDivider()
|
||||
Spacer(Modifier.height(16.dp))
|
||||
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth().weight(1f),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize().padding(16.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text(
|
||||
text = "Comparison Chart (placeholder)",
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
)
|
||||
Text(
|
||||
text = "Economy comparison visualization will appear here.",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
modifier = Modifier.padding(top = 8.dp)
|
||||
val eco1 = service.buildsToCompare[0].economyOverTimeModel
|
||||
val eco2 = service.buildsToCompare[1].economyOverTimeModel
|
||||
val lastInterval = minOf(
|
||||
eco1.lastOrNull()?.interval ?: 0,
|
||||
eco2.lastOrNull()?.interval ?: 0
|
||||
)
|
||||
val e1 = eco1.find { it.interval == lastInterval }
|
||||
val e2 = eco2.find { it.interval == lastInterval }
|
||||
|
||||
ComparisonChart(
|
||||
alloy1 = e1?.alloy ?: 0f,
|
||||
alloy2 = e2?.alloy ?: 0f,
|
||||
ether1 = e1?.ether ?: 0f,
|
||||
ether2 = e2?.ether ?: 0f,
|
||||
workers1 = e1?.workerCount ?: 0,
|
||||
workers2 = e2?.workerCount ?: 0,
|
||||
color1 = color1,
|
||||
color2 = color2,
|
||||
interval = lastInterval,
|
||||
modifier = Modifier.fillMaxWidth().weight(1f)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun PlayerCard(
|
||||
label: String,
|
||||
faction: String,
|
||||
townHallsText: String,
|
||||
buildTimes: List<Int>,
|
||||
onTownHallsChange: (String) -> Unit,
|
||||
onBuildTimeChange: (Int, String) -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Card(
|
||||
modifier = modifier,
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
) {
|
||||
Column(modifier = Modifier.padding(12.dp)) {
|
||||
Text(label, style = MaterialTheme.typography.titleSmall)
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Text("Faction: $faction", style = MaterialTheme.typography.bodySmall)
|
||||
Spacer(Modifier.height(8.dp))
|
||||
OutlinedTextField(
|
||||
value = townHallsText,
|
||||
onValueChange = onTownHallsChange,
|
||||
label = { Text("Town Halls (0-5)") },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true
|
||||
)
|
||||
buildTimes.forEachIndexed { index, time ->
|
||||
Spacer(Modifier.height(4.dp))
|
||||
OutlinedTextField(
|
||||
value = time.toString(),
|
||||
onValueChange = { onBuildTimeChange(index, it) },
|
||||
label = { Text("TH ${index + 1} build time") },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ComparisonChart(
|
||||
alloy1: Float,
|
||||
alloy2: Float,
|
||||
ether1: Float,
|
||||
ether2: Float,
|
||||
workers1: Int,
|
||||
workers2: Int,
|
||||
color1: Color,
|
||||
color2: Color,
|
||||
interval: Int,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Card(
|
||||
modifier = modifier,
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize().padding(16.dp).verticalScroll(rememberScrollState())
|
||||
) {
|
||||
Text(
|
||||
text = "Economy at Interval $interval",
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
)
|
||||
Spacer(Modifier.height(12.dp))
|
||||
|
||||
Text("Alloy", style = MaterialTheme.typography.labelLarge)
|
||||
Spacer(Modifier.height(4.dp))
|
||||
ResourceBar(value = alloy1, max = maxOf(alloy1, alloy2, 1f), color = color1, label = "P1")
|
||||
Spacer(Modifier.height(2.dp))
|
||||
ResourceBar(value = alloy2, max = maxOf(alloy1, alloy2, 1f), color = color2, label = "P2")
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
Text("Ether", style = MaterialTheme.typography.labelLarge)
|
||||
Spacer(Modifier.height(4.dp))
|
||||
ResourceBar(value = ether1, max = maxOf(ether1, ether2, 1f), color = color1, label = "P1")
|
||||
Spacer(Modifier.height(2.dp))
|
||||
ResourceBar(value = ether2, max = maxOf(ether1, ether2, 1f), color = color2, label = "P2")
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
Text("Workers", style = MaterialTheme.typography.labelLarge)
|
||||
Spacer(Modifier.height(4.dp))
|
||||
ResourceBar(value = workers1.toFloat(), max = maxOf(workers1, workers2, 1).toFloat(), color = color1, label = "P1")
|
||||
Spacer(Modifier.height(2.dp))
|
||||
ResourceBar(value = workers2.toFloat(), max = maxOf(workers1, workers2, 1).toFloat(), color = color2, label = "P2")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ResourceBar(value: Float, max: Float, color: Color, label: String) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().height(20.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text("$label: ", style = MaterialTheme.typography.bodySmall)
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.fillMaxHeight()
|
||||
.padding(end = 4.dp)
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth(fraction = (value / max).coerceIn(0f, 1f))
|
||||
.fillMaxHeight()
|
||||
.background(color.copy(alpha = 0.7f))
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = "%.1f".format(value),
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseColor(color: String): Color = when (color.lowercase()) {
|
||||
"red" -> Color(0xFFE53935)
|
||||
"green" -> Color(0xFF43A047)
|
||||
"blue" -> Color(0xFF1E88E5)
|
||||
"yellow" -> Color(0xFFFDD835)
|
||||
"purple" -> Color(0xFF8E24AA)
|
||||
"orange" -> Color(0xFFFB8C00)
|
||||
else -> Color(0xFF757575)
|
||||
}
|
||||
|
||||
@@ -6,29 +6,75 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateListOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
private const val CostOfWorker = 50
|
||||
private const val AlloyMinedPerSecondByWorker = 1.0f
|
||||
private const val TimeToProduceWorker = 20
|
||||
|
||||
@Composable
|
||||
fun HarassCalculatorScreen() {
|
||||
var damageInput by remember { mutableStateOf("") }
|
||||
var healthInput by remember { mutableStateOf("") }
|
||||
var workersLostText by remember { mutableStateOf("") }
|
||||
var townHallsText by remember { mutableStateOf("") }
|
||||
val travelTimes = remember { mutableStateListOf<String>() }
|
||||
|
||||
val workersLost = (workersLostText.toIntOrNull() ?: 0).coerceIn(0, 20)
|
||||
val townHalls = (townHallsText.toIntOrNull() ?: 1).coerceIn(1, 6)
|
||||
|
||||
if (travelTimes.size < townHalls) {
|
||||
val toAdd = townHalls - travelTimes.size
|
||||
repeat(toAdd) { travelTimes.add("0") }
|
||||
} else if (travelTimes.size > townHalls) {
|
||||
repeat(travelTimes.size - townHalls) { travelTimes.removeLastOrNull() }
|
||||
}
|
||||
|
||||
val replacementCost = workersLost * CostOfWorker
|
||||
|
||||
val fullBatches = workersLost / townHalls
|
||||
val remainderWorkers = workersLost % townHalls
|
||||
|
||||
var miningLoss = 0.0f
|
||||
for (batch in 1..fullBatches) {
|
||||
miningLoss += townHalls * AlloyMinedPerSecondByWorker * TimeToProduceWorker * batch
|
||||
}
|
||||
if (remainderWorkers > 0) {
|
||||
miningLoss += remainderWorkers * AlloyMinedPerSecondByWorker * TimeToProduceWorker * (fullBatches + 1)
|
||||
}
|
||||
|
||||
val travelTimeValues = travelTimes.map { it.toFloatOrNull() ?: 0f }
|
||||
val sumTravelTimes = travelTimeValues.take(townHalls).sum()
|
||||
val remainderSum = travelTimeValues.take(remainderWorkers).sum()
|
||||
|
||||
val travelLoss = AlloyMinedPerSecondByWorker * (fullBatches * sumTravelTimes + remainderSum)
|
||||
|
||||
val totalAlloyLost = replacementCost + miningLoss + travelLoss
|
||||
val averageTravelTime = if (workersLost > 0) travelLoss / (AlloyMinedPerSecondByWorker * workersLost) else 0f
|
||||
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize().padding(16.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
modifier = Modifier.fillMaxSize().padding(16.dp).verticalScroll(rememberScrollState())
|
||||
) {
|
||||
Text(
|
||||
text = "Harass Calculator",
|
||||
style = MaterialTheme.typography.headlineMedium
|
||||
)
|
||||
|
||||
Spacer(Modifier.height(12.dp))
|
||||
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = CardDefaults.cardColors(
|
||||
@@ -36,7 +82,7 @@ fun HarassCalculatorScreen() {
|
||||
)
|
||||
) {
|
||||
Text(
|
||||
text = "Warning: This calculator may be out of date. Verify values with the latest game patch.",
|
||||
text = "Might be out of date - This calculation is from several years ago and might not reflect the current state of the game.",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
modifier = Modifier.padding(16.dp)
|
||||
)
|
||||
@@ -44,25 +90,110 @@ fun HarassCalculatorScreen() {
|
||||
|
||||
Spacer(Modifier.height(16.dp))
|
||||
|
||||
Text(
|
||||
text = "Harass Calculator",
|
||||
style = MaterialTheme.typography.headlineMedium
|
||||
)
|
||||
Spacer(Modifier.height(12.dp))
|
||||
|
||||
OutlinedTextField(
|
||||
value = damageInput,
|
||||
onValueChange = { damageInput = it },
|
||||
label = { Text("Damage per hit") },
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
value = workersLostText,
|
||||
onValueChange = { workersLostText = it },
|
||||
label = { Text("Number of Workers Lost (1-20)") },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true
|
||||
)
|
||||
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
OutlinedTextField(
|
||||
value = healthInput,
|
||||
onValueChange = { healthInput = it },
|
||||
label = { Text("Target health") },
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
value = townHallsText,
|
||||
onValueChange = { townHallsText = it },
|
||||
label = { Text("Number of Town Halls (1-6)") },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true
|
||||
)
|
||||
|
||||
Spacer(Modifier.height(12.dp))
|
||||
|
||||
Text(
|
||||
text = "Travel Time per Town Hall (seconds)",
|
||||
style = MaterialTheme.typography.labelLarge
|
||||
)
|
||||
Spacer(Modifier.height(4.dp))
|
||||
for (i in 0 until townHalls) {
|
||||
OutlinedTextField(
|
||||
value = travelTimes.getOrElse(i) { "0" },
|
||||
onValueChange = { newValue ->
|
||||
if (i < travelTimes.size) {
|
||||
travelTimes[i] = newValue
|
||||
}
|
||||
},
|
||||
label = { Text("Travel Time TH ${i + 1}") },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true
|
||||
)
|
||||
if (i < townHalls - 1) {
|
||||
Spacer(Modifier.height(4.dp))
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(16.dp))
|
||||
|
||||
HorizontalDivider()
|
||||
|
||||
Spacer(Modifier.height(16.dp))
|
||||
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
) {
|
||||
Column(modifier = Modifier.padding(16.dp)) {
|
||||
Text(
|
||||
text = "Total Alloy Lost",
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
)
|
||||
Text(
|
||||
text = "%.2f".format(totalAlloyLost),
|
||||
style = MaterialTheme.typography.headlineLarge,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
Spacer(Modifier.height(12.dp))
|
||||
HorizontalDivider()
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Text(
|
||||
text = "Worker Replacement Cost: $replacementCost",
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
)
|
||||
Text(
|
||||
text = "Delayed Mining Cost: %.2f".format(miningLoss),
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
)
|
||||
Text(
|
||||
text = "Average Travel Time: %.2fs".format(averageTravelTime),
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(16.dp))
|
||||
|
||||
HorizontalDivider()
|
||||
|
||||
Spacer(Modifier.height(16.dp))
|
||||
|
||||
Text(
|
||||
text = "How It Works",
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
)
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Text(
|
||||
text = "This calculator estimates the total alloy opportunity cost when workers are killed. It combines the replacement cost of producing new workers with the mining output lost while those workers are being produced and traveling back to harvest points.",
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
)
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Text(
|
||||
text = "Each town hall produces one worker at a time. All town halls produce simultaneously, so with multiple town halls the replacement time is reduced. Workers produced in later batches wait longer, incurring greater mining losses. Each worker also incurs a travel time loss based on their town hall's travel time.",
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
)
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Text(
|
||||
text = "Total = (Workers \u00d7 50) + Mining Loss + Travel Loss",
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,17 @@ import androidx.compose.foundation.lazy.grid.GridCells
|
||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||
import androidx.compose.foundation.lazy.grid.items
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.MenuBook
|
||||
import androidx.compose.material.icons.automirrored.filled.Notes
|
||||
import androidx.compose.material.icons.filled.Bolt
|
||||
import androidx.compose.material.icons.filled.Calculate
|
||||
import androidx.compose.material.icons.filled.Memory
|
||||
import androidx.compose.material.icons.filled.MenuBook
|
||||
import androidx.compose.material.icons.filled.CompareArrows
|
||||
import androidx.compose.material.icons.filled.Info
|
||||
import androidx.compose.material.icons.filled.Map
|
||||
import androidx.compose.material.icons.filled.Memory
|
||||
import androidx.compose.material.icons.filled.Shield
|
||||
import androidx.compose.material.icons.filled.Storage
|
||||
import androidx.compose.material.icons.filled.TableChart
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.Icon
|
||||
@@ -36,11 +42,17 @@ data class NavCardData(
|
||||
@Composable
|
||||
fun HomeScreen() {
|
||||
val navItems = listOf(
|
||||
NavCardData("Database", Icons.Default.MenuBook),
|
||||
NavCardData("Build Calculator", Icons.Default.Calculate),
|
||||
NavCardData("Database", Icons.AutoMirrored.Filled.MenuBook),
|
||||
NavCardData("Build Calculator", Icons.Filled.Calculate),
|
||||
NavCardData("Notes", Icons.AutoMirrored.Filled.Notes),
|
||||
NavCardData("Memory Tester", Icons.Default.Memory),
|
||||
NavCardData("Memory Tester", Icons.Filled.Memory),
|
||||
NavCardData("Economy Comparison", Icons.Default.CompareArrows),
|
||||
NavCardData("Harass Calculator", Icons.Default.Bolt),
|
||||
NavCardData("Data Tables", Icons.Default.TableChart),
|
||||
NavCardData("Roadmap", Icons.Default.Map),
|
||||
NavCardData("Storage", Icons.Default.Storage),
|
||||
NavCardData("Permissions", Icons.Default.Shield),
|
||||
NavCardData("About", Icons.Default.Info),
|
||||
)
|
||||
|
||||
Column(
|
||||
|
||||
@@ -1,29 +1,266 @@
|
||||
package ca.jonathanmccaffrey.igp.ui.screens
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.ExposedDropdownMenuBox
|
||||
import androidx.compose.material3.ExposedDropdownMenuDefaults
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import ca.jonathanmccaffrey.igp.di.ServiceLocator
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun StorageScreen() {
|
||||
val storageService = ServiceLocator.storageService
|
||||
|
||||
var plainView by remember { mutableStateOf((storageService.getValue("is_plain_view", false) as? Boolean) ?: false) }
|
||||
var dynamicFormatting by remember { mutableStateOf((storageService.getValue("is_dynamic_formatting", false) as? Boolean) ?: false) }
|
||||
|
||||
var attackTime by remember { mutableStateOf(((storageService.getValue("attack_time", 0) as? Number)?.toInt() ?: 0).toString()) }
|
||||
var travelTime by remember { mutableStateOf(((storageService.getValue("travel_time", 0) as? Number)?.toInt() ?: 0).toString()) }
|
||||
var buildInputDelay by remember { mutableStateOf(((storageService.getValue("build_input_delay", 0) as? Number)?.toInt() ?: 0).toString()) }
|
||||
var waitTime by remember { mutableStateOf(((storageService.getValue("wait_time", 0) as? Number)?.toInt() ?: 0).toString()) }
|
||||
var waitTo by remember { mutableStateOf(((storageService.getValue("wait_to", 0) as? Number)?.toInt() ?: 0).toString()) }
|
||||
|
||||
var selectedFaction by remember { mutableStateOf((storageService.getValue("selected_faction", "") as? String) ?: "Aru") }
|
||||
var selectedImmortal by remember { mutableStateOf((storageService.getValue("selected_immortal", "") as? String) ?: "Mala") }
|
||||
var factionExpanded by remember { mutableStateOf(false) }
|
||||
var immortalExpanded by remember { mutableStateOf(false) }
|
||||
|
||||
val factionOptions = listOf("Aru", "Q'Rath")
|
||||
val aruImmortals = listOf("Mala", "Xol", "Atzlan")
|
||||
val qrathImmortals = listOf("Orzum", "Ajari")
|
||||
val immortalOptions = if (selectedFaction == "Aru") aruImmortals else qrathImmortals
|
||||
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize().padding(16.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
modifier = Modifier.fillMaxSize().padding(16.dp).verticalScroll(rememberScrollState())
|
||||
) {
|
||||
Text(
|
||||
text = "Storage Management",
|
||||
text = "Storage & Settings",
|
||||
style = MaterialTheme.typography.headlineMedium
|
||||
)
|
||||
Text(
|
||||
text = "Manage your local storage data here.",
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
modifier = Modifier.padding(top = 16.dp)
|
||||
|
||||
Spacer(Modifier.height(16.dp))
|
||||
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(
|
||||
text = "Plain Entity View",
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
Switch(
|
||||
checked = plainView,
|
||||
onCheckedChange = {
|
||||
plainView = it
|
||||
storageService.setValue("is_plain_view", it)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(
|
||||
text = "Dynamic Formatting",
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
Switch(
|
||||
checked = dynamicFormatting,
|
||||
onCheckedChange = {
|
||||
dynamicFormatting = it
|
||||
storageService.setValue("is_dynamic_formatting", it)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(16.dp))
|
||||
HorizontalDivider()
|
||||
Spacer(Modifier.height(16.dp))
|
||||
|
||||
OutlinedTextField(
|
||||
value = attackTime,
|
||||
onValueChange = { newValue ->
|
||||
val filtered = newValue.filter { it.isDigit() }
|
||||
attackTime = filtered
|
||||
filtered.toIntOrNull()?.let { intVal ->
|
||||
if (intVal in 0..2048) {
|
||||
storageService.setValue("attack_time", intVal)
|
||||
}
|
||||
}
|
||||
},
|
||||
label = { Text("Attack Time (0-2048)") },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true
|
||||
)
|
||||
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
OutlinedTextField(
|
||||
value = travelTime,
|
||||
onValueChange = { newValue ->
|
||||
val filtered = newValue.filter { it.isDigit() }
|
||||
travelTime = filtered
|
||||
filtered.toIntOrNull()?.let { intVal ->
|
||||
if (intVal in 0..2048) {
|
||||
storageService.setValue("travel_time", intVal)
|
||||
}
|
||||
}
|
||||
},
|
||||
label = { Text("Travel Time (0-2048)") },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true
|
||||
)
|
||||
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
OutlinedTextField(
|
||||
value = buildInputDelay,
|
||||
onValueChange = { newValue ->
|
||||
val filtered = newValue.filter { it.isDigit() }
|
||||
buildInputDelay = filtered
|
||||
filtered.toIntOrNull()?.let { intVal ->
|
||||
if (intVal in 0..600) {
|
||||
storageService.setValue("build_input_delay", intVal)
|
||||
}
|
||||
}
|
||||
},
|
||||
label = { Text("Building Input Delay (0-600)") },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true
|
||||
)
|
||||
|
||||
Spacer(Modifier.height(16.dp))
|
||||
HorizontalDivider()
|
||||
Spacer(Modifier.height(16.dp))
|
||||
|
||||
ExposedDropdownMenuBox(
|
||||
expanded = factionExpanded,
|
||||
onExpandedChange = { factionExpanded = it }
|
||||
) {
|
||||
OutlinedTextField(
|
||||
value = selectedFaction,
|
||||
onValueChange = {},
|
||||
readOnly = true,
|
||||
label = { Text("Faction") },
|
||||
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = factionExpanded) },
|
||||
modifier = Modifier.menuAnchor().fillMaxWidth()
|
||||
)
|
||||
ExposedDropdownMenu(
|
||||
expanded = factionExpanded,
|
||||
onDismissRequest = { factionExpanded = false }
|
||||
) {
|
||||
factionOptions.forEach { faction ->
|
||||
DropdownMenuItem(
|
||||
text = { Text(faction) },
|
||||
onClick = {
|
||||
selectedFaction = faction
|
||||
factionExpanded = false
|
||||
storageService.setValue("selected_faction", faction)
|
||||
if (faction == "Aru" && selectedImmortal !in aruImmortals) {
|
||||
selectedImmortal = "Mala"
|
||||
storageService.setValue("selected_immortal", "Mala")
|
||||
} else if (faction == "Q'Rath" && selectedImmortal !in qrathImmortals) {
|
||||
selectedImmortal = "Orzum"
|
||||
storageService.setValue("selected_immortal", "Orzum")
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
ExposedDropdownMenuBox(
|
||||
expanded = immortalExpanded,
|
||||
onExpandedChange = { immortalExpanded = it }
|
||||
) {
|
||||
OutlinedTextField(
|
||||
value = selectedImmortal,
|
||||
onValueChange = {},
|
||||
readOnly = true,
|
||||
label = { Text("Immortal") },
|
||||
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = immortalExpanded) },
|
||||
modifier = Modifier.menuAnchor().fillMaxWidth()
|
||||
)
|
||||
ExposedDropdownMenu(
|
||||
expanded = immortalExpanded,
|
||||
onDismissRequest = { immortalExpanded = false }
|
||||
) {
|
||||
immortalOptions.forEach { immortal ->
|
||||
DropdownMenuItem(
|
||||
text = { Text(immortal) },
|
||||
onClick = {
|
||||
selectedImmortal = immortal
|
||||
immortalExpanded = false
|
||||
storageService.setValue("selected_immortal", immortal)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(16.dp))
|
||||
HorizontalDivider()
|
||||
Spacer(Modifier.height(16.dp))
|
||||
|
||||
OutlinedTextField(
|
||||
value = waitTime,
|
||||
onValueChange = { newValue ->
|
||||
val filtered = newValue.filter { it.isDigit() }
|
||||
waitTime = filtered
|
||||
filtered.toIntOrNull()?.let { intVal ->
|
||||
if (intVal in 0..2048) {
|
||||
storageService.setValue("wait_time", intVal)
|
||||
}
|
||||
}
|
||||
},
|
||||
label = { Text("Wait Time (0-2048)") },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true
|
||||
)
|
||||
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
OutlinedTextField(
|
||||
value = waitTo,
|
||||
onValueChange = { newValue ->
|
||||
val filtered = newValue.filter { it.isDigit() }
|
||||
waitTo = filtered
|
||||
filtered.toIntOrNull()?.let { intVal ->
|
||||
if (intVal in 0..2048) {
|
||||
storageService.setValue("wait_to", intVal)
|
||||
}
|
||||
}
|
||||
},
|
||||
label = { Text("Wait To (0-2048)") },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package ca.jonathanmccaffrey.igp.ui.screens
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -20,10 +25,23 @@ fun StreamsScreen() {
|
||||
text = "Streams",
|
||||
style = MaterialTheme.typography.headlineMedium
|
||||
)
|
||||
Text(
|
||||
text = "Live streams and content from the Immortal community.",
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
modifier = Modifier.padding(top = 16.dp)
|
||||
)
|
||||
Spacer(Modifier.height(16.dp))
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
) {
|
||||
Column(modifier = Modifier.padding(16.dp)) {
|
||||
Text(
|
||||
text = "Coming Soon",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Text(
|
||||
text = "Live streams and content from the Immortal: Gates of Pyre community will appear here.",
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user