Skip to content

Commit

Permalink
Fix Command Spell Target
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurKun21 committed Nov 25, 2024
1 parent 97df649 commit 5aa17b6
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.compose.animation.Crossfade
import androidx.compose.animation.core.spring
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.res.stringResource
import androidx.core.view.WindowCompat
Expand Down Expand Up @@ -140,13 +139,18 @@ fun SkillMakerUI(
SkillMakerCommandSpells(
remaining = nav.cs,
onCommandSpell = {
vm.initSkill(it)
vm.initCommandSpell(it)
},
onBack = {
navigate(SkillMakerNav.Main)
}
)
}
is SkillMakerNav.CommandSpellTarget -> {
SkillMakerCommandSpellTarget(
onServantTarget = { vm.targetSkill(it) }
)
}

SkillMakerNav.OrderChange -> {
SkillMakerOrderChange(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,20 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.sizeIn
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.github.fate_grand_automata.R
import io.github.fate_grand_automata.scripts.models.ServantTarget
import io.github.fate_grand_automata.scripts.models.Skill
import io.github.fate_grand_automata.ui.FGATheme
import io.github.fate_grand_automata.ui.FGATitle
Expand Down Expand Up @@ -89,6 +81,47 @@ fun SkillMakerCommandSpells(
}
}

@Composable
fun SkillMakerCommandSpellTarget(
onServantTarget: (ServantTarget) -> Unit,
) {
Column(
modifier = Modifier
.fillMaxHeight()
.padding(16.dp)
) {
FGATitle(
stringResource(R.string.skill_maker_target_header)
)

Row(
horizontalArrangement = Arrangement.SpaceEvenly,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.weight(1f)
.fillMaxWidth()
) {
TargetButton(
onClick = { onServantTarget(ServantTarget.A) },
color = colorResource(R.color.colorServant1),
text = stringResource(R.string.skill_maker_target_servant, 1)
)

TargetButton(
onClick = { onServantTarget(ServantTarget.B) },
color = colorResource(R.color.colorServant2),
text = stringResource(R.string.skill_maker_target_servant, 2)
)

TargetButton(
onClick = { onServantTarget(ServantTarget.C) },
color = colorResource(R.color.colorServant3),
text = stringResource(R.string.skill_maker_target_servant, 3)
)
}
}
}


@Preview(name = "Light Mode", widthDp = 600, heightDp = 300)
@Preview(name = "Dark Mode", widthDp = 600, heightDp = 300, uiMode = Configuration.UI_MODE_NIGHT_YES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ sealed class SkillMakerNav {
data object OrderChange : SkillMakerNav()
data class SkillTarget(val skill: Skill) : SkillMakerNav()
data class CommandSpell(val cs: Int) : SkillMakerNav()
data class CommandSpellTarget(val skill: Skill) : SkillMakerNav()
data class ChangeNpType2(val skill: Skill) : SkillMakerNav()
data class ChangeNpType3(val skill: Skill) : SkillMakerNav()
data class Choice2(val skill: Skill, val slot: SkillSlot) : SkillMakerNav()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ class SkillMakerViewModel @Inject constructor(
initialValue = 3
)

fun initCommandSpell(skill: Skill) {
currentSkill = skill.autoSkillCode

navigation.value = SkillMakerNav.CommandSpellTarget(skill)
}

private val _wave = mutableIntStateOf(
if (state.skillString != null) {
state.wave
Expand Down

0 comments on commit 5aa17b6

Please sign in to comment.