Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.stringArrayResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextDecoration
Expand All @@ -51,7 +50,15 @@ import io.github.fate_grand_automata.scripts.models.ServantTarget
import io.github.fate_grand_automata.ui.FGATheme
import io.github.fate_grand_automata.ui.FGATitle
import io.github.fate_grand_automata.ui.dialog.FgaDialog
import io.github.fate_grand_automata.ui.skill_maker.special.TargetButton
import io.github.fate_grand_automata.ui.skill_maker.utils.TargetButton
import io.github.fate_grand_automata.ui.skill_maker.utils.changeNp2TypeSlot3Text
import io.github.fate_grand_automata.ui.skill_maker.utils.changeNp3TypeSlot2Text
import io.github.fate_grand_automata.ui.skill_maker.utils.choice2Slot1Text
import io.github.fate_grand_automata.ui.skill_maker.utils.choice2Slot2Text
import io.github.fate_grand_automata.ui.skill_maker.utils.choice2Slot3Text
import io.github.fate_grand_automata.ui.skill_maker.utils.choice3Slot1Text
import io.github.fate_grand_automata.ui.skill_maker.utils.choice3Slot3Text
import io.github.fate_grand_automata.ui.skill_maker.utils.transformSlot3Text
import kotlinx.coroutines.launch

@Composable
Expand Down Expand Up @@ -178,7 +185,7 @@ fun SkillMakerTarget(
text = stringResource(R.string.skill_maker_change_np_type_2),
hint = stringResource(R.string.skill_maker_change_np_type_2_hint),
image = R.drawable.skill_maker_np_type_2,
servants = stringArrayResource(R.array.skill_maker_change_np_type_2_array).joinToString("\n")
servants = changeNp2TypeSlot3Text()
)
}
}
Expand All @@ -190,7 +197,7 @@ fun SkillMakerTarget(
text = stringResource(R.string.skill_maker_change_np_type_3),
hint = stringResource(R.string.skill_maker_change_np_type_3_hint),
image = R.drawable.skill_maker_np_type_3,
servants = stringArrayResource(R.array.skill_maker_change_np_type_3_array).joinToString("\n")
servants = changeNp3TypeSlot2Text()
)
}
}
Expand All @@ -203,10 +210,11 @@ fun SkillMakerTarget(
text = stringResource(R.string.skill_maker_choices_2),
hint = stringResource(R.string.skill_maker_choices_2_hint),
image = R.drawable.skill_maker_choices_2,
servants = stringArrayResource(when(slot) {
SkillSlot.Third -> R.array.skill_maker_choices_2_array_slot_3
else -> R.array.skill_maker_choices_2_array_slot_1and2
}).joinToString("\n")
servants = when (slot) {
SkillSlot.First -> choice2Slot1Text()
SkillSlot.Second -> choice2Slot2Text()
else -> choice2Slot3Text()
}
)
}

Expand All @@ -219,10 +227,10 @@ fun SkillMakerTarget(
text = stringResource(R.string.skill_maker_choices_3),
hint = stringResource(R.string.skill_maker_choices_3_hint),
image = R.drawable.skill_maker_choices_3,
servants = stringArrayResource(when(slot) {
SkillSlot.First -> R.array.skill_maker_choices_3_array_slot_1
else -> R.array.skill_maker_choices_3_array_slot_3
}).joinToString("\n")
servants = when (slot) {
SkillSlot.First -> choice3Slot1Text()
else -> choice3Slot3Text()
}
)
}
}
Expand All @@ -233,7 +241,7 @@ fun SkillMakerTarget(
text = stringResource(R.string.skill_maker_transform),
hint = stringResource(R.string.skill_maker_transform_hint),
image = R.drawable.skill_maker_transform,
servants = stringArrayResource(R.array.skill_maker_transform_array).joinToString("\n")
servants = transformSlot3Text()
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
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.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme
Expand All @@ -22,19 +20,21 @@ 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.res.colorResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import io.github.fate_grand_automata.R
import io.github.fate_grand_automata.ui.FGATheme
import io.github.fate_grand_automata.ui.FGATitle
import io.github.fate_grand_automata.ui.skill_maker.utils.ChangeNp2Type
import io.github.fate_grand_automata.ui.skill_maker.utils.TargetButton
import io.github.fate_grand_automata.ui.skill_maker.utils.stringRes
import io.github.fate_grand_automata.ui.skill_maker.utils.targetAStringRes
import io.github.fate_grand_automata.ui.skill_maker.utils.targetBStringRes

@Composable
fun SkillMakerChangeNpType2(
Expand Down Expand Up @@ -135,26 +135,6 @@ fun SkillMakerChangeNpType2(
}
}

@Composable
fun TargetButton(
onClick: () -> Unit,
color: Color,
text: String
) {
Button(
onClick = onClick,
colors = ButtonDefaults.buttonColors(containerColor = color),
modifier = Modifier.height(75.dp).width(120.dp)
) {
Text(
text,
color = Color.White,
textAlign = TextAlign.Center,
overflow = TextOverflow.Clip,
fontSize = 17.sp
)
}
}

@Preview(name = "Light Mode", widthDp = 600, heightDp = 300)
@Preview(name = "Dark Mode", widthDp = 600, heightDp = 300, uiMode = Configuration.UI_MODE_NIGHT_YES)
Expand All @@ -165,29 +145,5 @@ fun TestChangeNpType2() {
}
}

private enum class ChangeNp2Type {
Generic,
Emiya,
BBDubai
}

private val ChangeNp2Type.stringRes
get() = when (this) {
ChangeNp2Type.Generic -> R.string.skill_maker_change_np_type_2
ChangeNp2Type.Emiya -> R.string.skill_maker_emiya
ChangeNp2Type.BBDubai -> R.string.skill_maker_bb_dubai
}

private val ChangeNp2Type.targetAStringRes
get() = when (this) {
ChangeNp2Type.Generic -> R.string.skill_maker_option_1
ChangeNp2Type.Emiya -> R.string.skill_maker_arts
ChangeNp2Type.BBDubai -> R.string.skill_maker_bb_dubai_target_1
}

private val ChangeNp2Type.targetBStringRes
get() = when (this) {
ChangeNp2Type.Generic -> R.string.skill_maker_option_2
ChangeNp2Type.Emiya -> R.string.skill_maker_buster
ChangeNp2Type.BBDubai -> R.string.skill_maker_bb_dubai_target_2
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ import io.github.fate_grand_automata.R
import io.github.fate_grand_automata.scripts.models.ServantTarget
import io.github.fate_grand_automata.ui.FGATheme
import io.github.fate_grand_automata.ui.FGATitle
import io.github.fate_grand_automata.ui.skill_maker.utils.ChangeNp3Type
import io.github.fate_grand_automata.ui.skill_maker.utils.TargetButton
import io.github.fate_grand_automata.ui.skill_maker.utils.stringRes
import io.github.fate_grand_automata.ui.skill_maker.utils.targetAStringRes
import io.github.fate_grand_automata.ui.skill_maker.utils.targetBStringRes
import io.github.fate_grand_automata.ui.skill_maker.utils.targetCStringRes

@Composable
fun SkillMakerChangeNpType3(
Expand Down Expand Up @@ -143,34 +149,4 @@ fun TestChangeNpType3() {
FGATheme {
SkillMakerChangeNpType3(onSkillTarget = { })
}
}


private enum class ChangeNp3Type {
Generic,
SpaceIshtar,
}

private val ChangeNp3Type.stringRes
get() = when (this) {
ChangeNp3Type.Generic -> R.string.skill_maker_change_np_type_3
ChangeNp3Type.SpaceIshtar -> R.string.skill_maker_space_ishtar
}

private val ChangeNp3Type.targetAStringRes
get() = when (this) {
ChangeNp3Type.Generic -> R.string.skill_maker_option_1
ChangeNp3Type.SpaceIshtar -> R.string.skill_maker_quick
}

private val ChangeNp3Type.targetBStringRes
get() = when (this) {
ChangeNp3Type.Generic -> R.string.skill_maker_option_2
ChangeNp3Type.SpaceIshtar -> R.string.skill_maker_arts
}

private val ChangeNp3Type.targetCStringRes
get() = when (this) {
ChangeNp3Type.Generic -> R.string.skill_maker_option_2
ChangeNp3Type.SpaceIshtar -> R.string.skill_maker_buster
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ import io.github.fate_grand_automata.scripts.models.ServantTarget
import io.github.fate_grand_automata.ui.FGATheme
import io.github.fate_grand_automata.ui.FGATitle
import io.github.fate_grand_automata.ui.skill_maker.SkillSlot
import io.github.fate_grand_automata.ui.skill_maker.utils.Choice2Type
import io.github.fate_grand_automata.ui.skill_maker.utils.TargetButton
import io.github.fate_grand_automata.ui.skill_maker.utils.stringRes
import io.github.fate_grand_automata.ui.skill_maker.utils.targetAStringRes
import io.github.fate_grand_automata.ui.skill_maker.utils.targetBStringRes

@Composable
fun SkillMakerChoice2(
Expand All @@ -51,6 +56,12 @@ fun SkillMakerChoice2(
}
var choice2Type by remember { mutableStateOf(Choice2Type.Generic) }

val mustSelect by remember {
derivedStateOf {
Choice2Type.mustSelect(slot)
}
}

Column(
modifier = Modifier
.fillMaxHeight()
Expand All @@ -68,19 +79,33 @@ fun SkillMakerChoice2(
.fillMaxWidth()
) {
TargetButton(
onClick = if (goToTarget) (
{ onTarget(ServantTarget.SpecialTarget.Choice2OptionA) }
) else onOption1,
onClick = {
when {
mustSelect && choice2Type in Choice2Type.slot2TargetEntries -> {
onTarget(ServantTarget.SpecialTarget.Choice2OptionA)
}

else -> onOption1()
}
},
color = MaterialTheme.colorScheme.primary,
text = stringResource(choice2Type.targetAStringRes)
text = stringResource(choice2Type.targetAStringRes),
enabled = !mustSelect || choice2Type != Choice2Type.Generic,
)

TargetButton(
onClick = if (goToTarget) (
{ onTarget(ServantTarget.SpecialTarget.Choice2OptionB) }
) else onOption2,
onClick = {
when {
mustSelect && choice2Type in Choice2Type.slot2TargetEntries -> {
onTarget(ServantTarget.SpecialTarget.Choice2OptionB)
}

else -> onOption2()
}
},
color = MaterialTheme.colorScheme.tertiary,
text = stringResource(choice2Type.targetBStringRes)
text = stringResource(choice2Type.targetBStringRes),
enabled = !mustSelect || choice2Type != Choice2Type.Generic,
)
}

Expand All @@ -90,7 +115,10 @@ fun SkillMakerChoice2(
.fillMaxWidth()
) {
Text(
stringResource(R.string.skill_maker_update_button_labels).uppercase(),
stringResource(
if (mustSelect) R.string.skill_maker_select_button_labels
else R.string.skill_maker_update_button_labels
).uppercase(),
style = MaterialTheme.typography.bodySmall,
textAlign = TextAlign.Center,
textDecoration = TextDecoration.Underline
Expand Down Expand Up @@ -213,30 +241,3 @@ fun TestChoice2Target() {
SkillMakerChoice2Target(onSkillTarget = { })
}
}

private enum class Choice2Type(val slot: SkillSlot) {
Generic(SkillSlot.ANY),
Kukulkan(SkillSlot.ANY),
UDKBarghest(SkillSlot.Third)
}

private val Choice2Type.stringRes
get() = when (this) {
Choice2Type.Generic -> R.string.skill_maker_choices_2
Choice2Type.Kukulkan -> R.string.skill_maker_kukulkan
Choice2Type.UDKBarghest -> R.string.skill_maker_udk_barghest
}

private val Choice2Type.targetAStringRes
get() = when (this) {
Choice2Type.Generic -> R.string.skill_maker_option_1
Choice2Type.Kukulkan -> R.string.skill_maker_kukulkan_choice_1
Choice2Type.UDKBarghest -> R.string.skill_maker_udk_barghest_choice_1
}

private val Choice2Type.targetBStringRes
get() = when (this) {
Choice2Type.Generic -> R.string.skill_maker_option_2
Choice2Type.Kukulkan -> R.string.skill_maker_kukulkan_choice_2
Choice2Type.UDKBarghest -> R.string.skill_maker_udk_barghest_choice_2
}
Loading