Complete addons
This commit is contained in:
parent
47a01f17cd
commit
926156a1dc
@ -4,6 +4,7 @@ data class AddonRequirementDto (
|
|||||||
val requirementBuildings: List<BuildingShortDto>,
|
val requirementBuildings: List<BuildingShortDto>,
|
||||||
val requirementBuildingsEither: List<BuildingShortDto>,
|
val requirementBuildingsEither: List<BuildingShortDto>,
|
||||||
val requireAddon: BuildingAddonShortDto?,
|
val requireAddon: BuildingAddonShortDto?,
|
||||||
|
val replaceWhenDone: Boolean,
|
||||||
val requirementsGlobalAddons: List<BuildingAddonShortDto>?,
|
val requirementsGlobalAddons: List<BuildingAddonShortDto>?,
|
||||||
val requiredTotalPop: Int?,
|
val requiredTotalPop: Int?,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.dowstats.data.entities
|
|||||||
|
|
||||||
import com.dowstats.data.dto.controllers.building.BuildingAddonDto
|
import com.dowstats.data.dto.controllers.building.BuildingAddonDto
|
||||||
import com.dowstats.data.dto.controllers.building.BuildingFullDto
|
import com.dowstats.data.dto.controllers.building.BuildingFullDto
|
||||||
|
import com.dowstats.data.entities.Weapon.HardpointPosition
|
||||||
import jakarta.persistence.*
|
import jakarta.persistence.*
|
||||||
|
|
||||||
|
|
||||||
@ -48,6 +49,9 @@ class Building {
|
|||||||
@OneToMany(mappedBy = "building", cascade = [CascadeType.ALL])
|
@OneToMany(mappedBy = "building", cascade = [CascadeType.ALL])
|
||||||
var weapons: MutableSet<BuildingWeapon>? = null
|
var weapons: MutableSet<BuildingWeapon>? = null
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
var weaponHardpoints: MutableSet<HardpointPosition> = mutableSetOf()
|
||||||
|
|
||||||
fun toDto(buildingAddons: Set<BuildingAddonDto>?): BuildingFullDto =
|
fun toDto(buildingAddons: Set<BuildingAddonDto>?): BuildingFullDto =
|
||||||
BuildingFullDto(
|
BuildingFullDto(
|
||||||
id!!,
|
id!!,
|
||||||
|
|||||||
@ -50,7 +50,7 @@ class BuildingAddon {
|
|||||||
addonCostFaith = addonCostFaith,
|
addonCostFaith = addonCostFaith,
|
||||||
addonCostSouls = addonCostSouls,
|
addonCostSouls = addonCostSouls,
|
||||||
addonCostTime = addonCostTime,
|
addonCostTime = addonCostTime,
|
||||||
addonModifiers = addonModifiers?.map { it.toDto() }?.toSet() ?: emptySet(),
|
addonModifiers = addonModifiers?.sortedBy { it.reference }?.map { it.toDto() }?.toSet() ?: emptySet(),
|
||||||
addonRequirement = addonRequirementDto,
|
addonRequirement = addonRequirementDto,
|
||||||
icon = icon
|
icon = icon
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.dowstats.data.entities
|
package com.dowstats.data.entities
|
||||||
|
|
||||||
import com.dowstats.data.dto.controllers.SergeantDto
|
import com.dowstats.data.dto.controllers.SergeantDto
|
||||||
|
import com.dowstats.data.entities.Weapon.HardpointPosition
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||||
import jakarta.persistence.*
|
import jakarta.persistence.*
|
||||||
|
|
||||||
@ -44,6 +45,9 @@ class Sergeant {
|
|||||||
var detectRadius: Int? = null
|
var detectRadius: Int? = null
|
||||||
var icon: String? = null
|
var icon: String? = null
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
var weaponHardpoints: MutableSet<HardpointPosition> = mutableSetOf()
|
||||||
|
|
||||||
@OneToMany(mappedBy = "sergeant", cascade = [CascadeType.ALL])
|
@OneToMany(mappedBy = "sergeant", cascade = [CascadeType.ALL])
|
||||||
var weapons: MutableSet<SergeantWeapon>? = null
|
var weapons: MutableSet<SergeantWeapon>? = null
|
||||||
|
|
||||||
|
|||||||
@ -37,11 +37,9 @@ class Weapon {
|
|||||||
var haveEquipButton: Boolean = true
|
var haveEquipButton: Boolean = true
|
||||||
var modId: Long? = null
|
var modId: Long? = null
|
||||||
|
|
||||||
@Transient
|
// for many-to-many persistance
|
||||||
var hardpoint: Int = 0
|
data class HardpointPosition(val weaponId: Long, val hardpoint: Int, val order: Int)
|
||||||
|
|
||||||
@Transient
|
|
||||||
var hardpointOrder: Int = 0
|
|
||||||
|
|
||||||
@OneToMany(mappedBy="weapon", fetch = FetchType.EAGER, cascade = [(CascadeType.ALL)])
|
@OneToMany(mappedBy="weapon", fetch = FetchType.EAGER, cascade = [(CascadeType.ALL)])
|
||||||
var weaponPiercings: List<WeaponArmorPiercing> = listOf()
|
var weaponPiercings: List<WeaponArmorPiercing> = listOf()
|
||||||
|
|||||||
@ -46,6 +46,8 @@ class DowBuildingMappingService @Autowired constructor(
|
|||||||
building.addons?.find { addon -> addon.filename == it.split("\\").last().replace(".lua", ".rgd") }
|
building.addons?.find { addon -> addon.filename == it.split("\\").last().replace(".lua", ".rgd") }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val replaceWhenDone = requirements?.find { it.reference == AddonRequirements.REFERENCE_REQUIREMENT_ADDON }?.replaceWhenDone ?: false
|
||||||
|
|
||||||
val requirementAddonGlobal =
|
val requirementAddonGlobal =
|
||||||
requirements?.filter { it.reference == AddonRequirements.REFERENCE_GLOBAL_REQUIREMENT_ADDON }
|
requirements?.filter { it.reference == AddonRequirements.REFERENCE_GLOBAL_REQUIREMENT_ADDON }
|
||||||
?.mapNotNull { rgra ->
|
?.mapNotNull { rgra ->
|
||||||
@ -86,13 +88,14 @@ class DowBuildingMappingService @Autowired constructor(
|
|||||||
requirementBuildings ?: emptyList(),
|
requirementBuildings ?: emptyList(),
|
||||||
requirementBuildingsEither ?: emptyList(),
|
requirementBuildingsEither ?: emptyList(),
|
||||||
requirementAddon?.toShortDto(),
|
requirementAddon?.toShortDto(),
|
||||||
|
replaceWhenDone,
|
||||||
requirementAddonGlobal,
|
requirementAddonGlobal,
|
||||||
requireCap
|
requireCap
|
||||||
)
|
)
|
||||||
} else null
|
} else null
|
||||||
|
|
||||||
addon.toDto(addonRequirement)
|
addon.toDto(addonRequirement)
|
||||||
}?.sortedBy { it.id }?.toSet()
|
}?.sortedBy { it.name }?.toSet()
|
||||||
|
|
||||||
return building.toDto(buildingAddons)
|
return building.toDto(buildingAddons)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -161,16 +161,9 @@ class BuildingAddonRgdExtractService @Autowired constructor(
|
|||||||
val iconPathInMod = buildingData
|
val iconPathInMod = buildingData
|
||||||
.getRgdTableByName("ui_info")
|
.getRgdTableByName("ui_info")
|
||||||
?.getStringByName("icon_name")
|
?.getStringByName("icon_name")
|
||||||
?.replace("/", File.separator)
|
|
||||||
|
|
||||||
|
return iconPathInMod?.let { modAttribPathService.getIconPath(modFolderData, iconPathInMod) }
|
||||||
val tgaIconPath = iconPathInMod?.let {
|
?.let { iconsService.convertTgaToJpegImage(iconPathInMod, it, modName) }
|
||||||
val modIcon = modAttribPathService.getIconPath(modFolderData, it)
|
|
||||||
if (Path.of(modIcon).exists()) modIcon else
|
|
||||||
modAttribPathService.getIconPath(modAttribPathService.pathToWanilaData, it)
|
|
||||||
}
|
|
||||||
|
|
||||||
return tgaIconPath?.let { iconsService.convertTgaToJpegImage(iconPathInMod, it, modName) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -102,9 +102,8 @@ class BuildingRgdExtractService @Autowired constructor(
|
|||||||
val buildingWeapons = getBuildingWeapon(buildingData)?.mapNotNull { weaponData ->
|
val buildingWeapons = getBuildingWeapon(buildingData)?.mapNotNull { weaponData ->
|
||||||
weapons.find {
|
weapons.find {
|
||||||
it.filename == weaponData.weaponFilename + ".rgd"
|
it.filename == weaponData.weaponFilename + ".rgd"
|
||||||
}.also {
|
}?.also {wp ->
|
||||||
it?.hardpoint = weaponData.hardpoint
|
building.weaponHardpoints.add(Weapon.HardpointPosition( wp.id!!, weaponData.hardpoint, weaponData.hardpointOrder))
|
||||||
it?.hardpointOrder = weaponData.hardpointOrder
|
|
||||||
}
|
}
|
||||||
}.orEmpty().toSet()
|
}.orEmpty().toSet()
|
||||||
|
|
||||||
@ -211,16 +210,9 @@ class BuildingRgdExtractService @Autowired constructor(
|
|||||||
.getRgdTableByName("ui_ext")
|
.getRgdTableByName("ui_ext")
|
||||||
?.getRgdTableByName("ui_info")
|
?.getRgdTableByName("ui_info")
|
||||||
?.getStringByName("icon_name")
|
?.getStringByName("icon_name")
|
||||||
?.replace("/", File.separator)
|
|
||||||
|
|
||||||
|
return iconPathInMod?.let { modAttribPathService.getIconPath(modFolderData, iconPathInMod) }
|
||||||
val tgaIconPath = iconPathInMod?.let {
|
?.let { iconsService.convertTgaToJpegImage(iconPathInMod, it, modName) }
|
||||||
val modIcon = modAttribPathService.getIconPath(modFolderData, it)
|
|
||||||
if(Path.of(modIcon).exists()) modIcon else
|
|
||||||
modAttribPathService.getIconPath(modAttribPathService.pathToWanilaData, it)
|
|
||||||
}
|
|
||||||
|
|
||||||
return tgaIconPath?.let { iconsService.convertTgaToJpegImage(iconPathInMod, it, modName) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,9 @@ import org.springframework.beans.factory.annotation.Autowired
|
|||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import java.awt.image.BufferedImage
|
import java.awt.image.BufferedImage
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.nio.file.Path
|
||||||
import javax.imageio.ImageIO
|
import javax.imageio.ImageIO
|
||||||
|
import kotlin.io.path.exists
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -32,7 +34,7 @@ class IconsService @Autowired constructor(
|
|||||||
val modFolder = modName?.let { "${File.separator}$modName" } ?: ""
|
val modFolder = modName?.let { "${File.separator}$modName" } ?: ""
|
||||||
|
|
||||||
val pathToSave = "${storageConfig.iconsStorage.replace("/", File.separator)}$modFolder" +
|
val pathToSave = "${storageConfig.iconsStorage.replace("/", File.separator)}$modFolder" +
|
||||||
"${File.separator}${iconPathInMod.replace("\\", File.separator)}.png"
|
"${File.separator}${iconPathInMod.replace("/", File.separator).replace("\\", File.separator)}.png"
|
||||||
|
|
||||||
val directoryToSave = File(pathToSave.split(File.separator).dropLast(1).joinToString (File.separator))
|
val directoryToSave = File(pathToSave.split(File.separator).dropLast(1).joinToString (File.separator))
|
||||||
if(!directoryToSave.exists()) directoryToSave.mkdirs()
|
if(!directoryToSave.exists()) directoryToSave.mkdirs()
|
||||||
|
|||||||
@ -4,6 +4,8 @@ import com.dowstats.configuration.StorageConfig
|
|||||||
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.nio.file.Path
|
||||||
|
import kotlin.io.path.exists
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
class ModAttribPathService @Autowired constructor(
|
class ModAttribPathService @Autowired constructor(
|
||||||
@ -39,6 +41,15 @@ class ModAttribPathService @Autowired constructor(
|
|||||||
fun geBuildingAttribsPath(modFolderData: String, race: String): String =
|
fun geBuildingAttribsPath(modFolderData: String, race: String): String =
|
||||||
"$modFolderData${File.separator}attrib${File.separator}ebps${File.separator}races${File.separator}$race${File.separator}structures"
|
"$modFolderData${File.separator}attrib${File.separator}ebps${File.separator}races${File.separator}$race${File.separator}structures"
|
||||||
|
|
||||||
fun getIconPath(modFolderData: String, iconName: String): String =
|
fun getIconPath(modFolderData: String, iconPath: String): String {
|
||||||
"$modFolderData${File.separator}art${File.separator}ui${File.separator}ingame${File.separator}$iconName.tga"
|
|
||||||
|
val iconValidEndPath = iconPath.replace("\\", File.separator).replace("/", File.separator)
|
||||||
|
|
||||||
|
val pathToIcon = "${File.separator}art${File.separator}ui${File.separator}ingame${File.separator}$iconValidEndPath.tga"
|
||||||
|
val modIcon = "$modFolderData$pathToIcon"
|
||||||
|
|
||||||
|
return if (Path.of(modIcon).exists()) modIcon else
|
||||||
|
"$pathToWanilaData$pathToIcon"
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,19 +31,21 @@ class ModParserService @Autowired constructor(
|
|||||||
val defaultDictionary: MutableMap<Int, String> = mutableMapOf()
|
val defaultDictionary: MutableMap<Int, String> = mutableMapOf()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
RgdParserService::class.java.getClassLoader().getResourceAsStream("DXP2.ucs").bufferedReader(Charsets.UTF_8).lines().forEach {
|
RgdParserService::class.java.getClassLoader().getResourceAsStream("DXP2.ucs").bufferedReader(Charsets.UTF_8)
|
||||||
|
.lines().forEach {
|
||||||
val kv = it.split("\\s+".toRegex())
|
val kv = it.split("\\s+".toRegex())
|
||||||
if (kv.size < 2) return@forEach
|
if (kv.size < 2) return@forEach
|
||||||
val key = kv.first().filter { it.isDigit() }.toInt()
|
val key = kv.first().filter { it.isDigit() }.toInt()
|
||||||
val value = kv.drop(1).joinToString(" ").replace("\u0000","")
|
val value = kv.drop(1).joinToString(" ").replace("\u0000", "")
|
||||||
defaultDictionary[key] = value
|
defaultDictionary[key] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
RgdParserService::class.java.getClassLoader().getResourceAsStream("W40k.ucs").bufferedReader(Charsets.UTF_8).lines().forEach {
|
RgdParserService::class.java.getClassLoader().getResourceAsStream("W40k.ucs").bufferedReader(Charsets.UTF_8)
|
||||||
|
.lines().forEach {
|
||||||
val kv = it.split("\\s+".toRegex())
|
val kv = it.split("\\s+".toRegex())
|
||||||
if (kv.size < 2) return@forEach
|
if (kv.size < 2) return@forEach
|
||||||
val key = kv.first().filter { it.isDigit() }.toInt()
|
val key = kv.first().filter { it.isDigit() }.toInt()
|
||||||
val value = kv.drop(1).joinToString(" ").replace("\u0000","")
|
val value = kv.drop(1).joinToString(" ").replace("\u0000", "")
|
||||||
defaultDictionary[key] = value
|
defaultDictionary[key] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,7 +63,7 @@ class ModParserService @Autowired constructor(
|
|||||||
.drop(1)
|
.drop(1)
|
||||||
.filter { Files.isDirectory(it) }.map { it.name }.toList()
|
.filter { Files.isDirectory(it) }.map { it.name }.toList()
|
||||||
|
|
||||||
racesList.forEach{
|
racesList.forEach {
|
||||||
unitRepository.deleteAllByModIdAndRaceId(mod.id!!, it)
|
unitRepository.deleteAllByModIdAndRaceId(mod.id!!, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,8 +80,11 @@ class ModParserService @Autowired constructor(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getModDictionary(mod: Mod, modFolderData: String): Map<Int,String>{
|
private fun getModDictionary(mod: Mod, modFolderData: String): Map<Int, String> {
|
||||||
val folder = if (mod.technicalName == "multidungeon_rightpocalypse") modAttribPathService.getUcsFolderRus(modFolderData) else modAttribPathService.getUcsFolder(modFolderData)
|
val folder =
|
||||||
|
if (mod.technicalName == "multidungeon_rightpocalypse") modAttribPathService.getUcsFolderRus(modFolderData) else modAttribPathService.getUcsFolder(
|
||||||
|
modFolderData
|
||||||
|
)
|
||||||
|
|
||||||
val modDictionary = mutableMapOf<Int, String>()
|
val modDictionary = mutableMapOf<Int, String>()
|
||||||
|
|
||||||
@ -87,11 +92,13 @@ class ModParserService @Autowired constructor(
|
|||||||
it.bufferedReader(Charsets.UTF_16).lines().forEach {
|
it.bufferedReader(Charsets.UTF_16).lines().forEach {
|
||||||
val kv = it.split("\\s+".toRegex())
|
val kv = it.split("\\s+".toRegex())
|
||||||
if (kv.size < 2) return@forEach
|
if (kv.size < 2) return@forEach
|
||||||
val key = try {kv.first().filter { it.isDigit() }.toInt()} catch(e: Exception) {
|
val key = try {
|
||||||
|
kv.first().filter { it.isDigit() }.toInt()
|
||||||
|
} catch (e: Exception) {
|
||||||
log.warn("Cant' get key ${kv.first()} for dict")
|
log.warn("Cant' get key ${kv.first()} for dict")
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
val value = kv.drop(1).joinToString(" ").replace("\u0000","")
|
val value = kv.drop(1).joinToString(" ").replace("\u0000", "")
|
||||||
modDictionary[key] = value
|
modDictionary[key] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,7 +106,13 @@ class ModParserService @Autowired constructor(
|
|||||||
return modDictionary
|
return modDictionary
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveUnits(modFolderData: String, weapons: Set<Weapon>, racesList: List<String>, mod: Mod, modDictionary: Map<Int, String>) {
|
private fun saveUnits(
|
||||||
|
modFolderData: String,
|
||||||
|
weapons: Set<Weapon>,
|
||||||
|
racesList: List<String>,
|
||||||
|
mod: Mod,
|
||||||
|
modDictionary: Map<Int, String>
|
||||||
|
) {
|
||||||
|
|
||||||
val races = raceRepository.findAll().toList()
|
val races = raceRepository.findAll().toList()
|
||||||
val armorTypes = armorTypeRepository.findAll().toList()
|
val armorTypes = armorTypeRepository.findAll().toList()
|
||||||
@ -107,14 +120,34 @@ class ModParserService @Autowired constructor(
|
|||||||
racesList.forEach { raceFolder ->
|
racesList.forEach { raceFolder ->
|
||||||
|
|
||||||
val classicRgdDataSquads =
|
val classicRgdDataSquads =
|
||||||
rgdParserService.parseFolderToRgdFiles(modAttribPathService.getSbpsAttribsPath(modAttribPathService.pathToWanilaData, raceFolder))
|
rgdParserService.parseFolderToRgdFiles(
|
||||||
|
modAttribPathService.getSbpsAttribsPath(
|
||||||
|
modAttribPathService.pathToWanilaData,
|
||||||
|
raceFolder
|
||||||
|
)
|
||||||
|
)
|
||||||
val modRgdDataSquads =
|
val modRgdDataSquads =
|
||||||
rgdParserService.parseFolderToRgdFiles(modAttribPathService.getSbpsAttribsPath(modFolderData, raceFolder))
|
rgdParserService.parseFolderToRgdFiles(
|
||||||
|
modAttribPathService.getSbpsAttribsPath(
|
||||||
|
modFolderData,
|
||||||
|
raceFolder
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
val classicRgdDataUnits =
|
val classicRgdDataUnits =
|
||||||
rgdParserService.parseFolderToRgdFiles(modAttribPathService.getEbpsTroopsAttribsPath(modAttribPathService.pathToWanilaData, raceFolder))
|
rgdParserService.parseFolderToRgdFiles(
|
||||||
|
modAttribPathService.getEbpsTroopsAttribsPath(
|
||||||
|
modAttribPathService.pathToWanilaData,
|
||||||
|
raceFolder
|
||||||
|
)
|
||||||
|
)
|
||||||
val modRgdDataUnits =
|
val modRgdDataUnits =
|
||||||
rgdParserService.parseFolderToRgdFiles(modAttribPathService.getEbpsTroopsAttribsPath(modFolderData, raceFolder))
|
rgdParserService.parseFolderToRgdFiles(
|
||||||
|
modAttribPathService.getEbpsTroopsAttribsPath(
|
||||||
|
modFolderData,
|
||||||
|
raceFolder
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
val modSquadsFull = classicRgdDataSquads + modRgdDataSquads
|
val modSquadsFull = classicRgdDataSquads + modRgdDataSquads
|
||||||
val modUnitsFull = classicRgdDataUnits + modRgdDataUnits
|
val modUnitsFull = classicRgdDataUnits + modRgdDataUnits
|
||||||
@ -127,7 +160,7 @@ class ModParserService @Autowired constructor(
|
|||||||
val unitRgdData: List<RgdData> =
|
val unitRgdData: List<RgdData> =
|
||||||
modUnitsFull[baseUnitName] ?: emptyList()
|
modUnitsFull[baseUnitName] ?: emptyList()
|
||||||
|
|
||||||
if(unitRgdData.isEmpty()){
|
if (unitRgdData.isEmpty()) {
|
||||||
log.warn("Can't find rgd data for unit $baseUnitName")
|
log.warn("Can't find rgd data for unit $baseUnitName")
|
||||||
return@forEach
|
return@forEach
|
||||||
}
|
}
|
||||||
@ -154,7 +187,7 @@ class ModParserService @Autowired constructor(
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
val unit = unitRepository.save(unitDataToSave.unit)
|
val unit = unitRepository.save(unitDataToSave.unit)
|
||||||
unit.weapons = unitDataToSave.unitWeapons?.map {weapon ->
|
unit.weapons = unitDataToSave.unitWeapons?.map { weapon ->
|
||||||
UnitWeapon().also {
|
UnitWeapon().also {
|
||||||
it.unit = unit
|
it.unit = unit
|
||||||
it.weapon = weapon.weapon
|
it.weapon = weapon.weapon
|
||||||
@ -173,16 +206,20 @@ class ModParserService @Autowired constructor(
|
|||||||
val sergeant = sergeantRepository.save(sergeantToSave.first.also {
|
val sergeant = sergeantRepository.save(sergeantToSave.first.also {
|
||||||
it.unit = unit
|
it.unit = unit
|
||||||
})
|
})
|
||||||
sergeant.weapons = sergeantToSave.second.map {weapon ->
|
sergeant.weapons = sergeantToSave.second.flatMap { weapon ->
|
||||||
SergeantWeapon().also {
|
sergeant.weaponHardpoints
|
||||||
it.sergeant = sergeant
|
.filter { it.weaponId == weapon.id }
|
||||||
it.weapon = weapon
|
.map { hardpointOrder ->
|
||||||
|
SergeantWeapon().also {
|
||||||
|
it.sergeant = sergeant
|
||||||
|
it.weapon = weapon
|
||||||
|
|
||||||
it.sergeantWeaponKey = SergeantWeaponKey().also { swk ->
|
it.sergeantWeaponKey = SergeantWeaponKey().also { swk ->
|
||||||
swk.sergeantId = sergeant.id
|
swk.sergeantId = sergeant.id
|
||||||
swk.weaponId = weapon.id
|
swk.weaponId = weapon.id
|
||||||
swk.hardpoint = weapon.hardpoint
|
swk.hardpoint = hardpointOrder.hardpoint
|
||||||
swk.hardpointOrder = weapon.hardpointOrder
|
swk.hardpointOrder = hardpointOrder.order
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.toMutableSet()
|
}.toMutableSet()
|
||||||
@ -195,10 +232,12 @@ class ModParserService @Autowired constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveBuildings(modFolderData: String,
|
private fun saveBuildings(
|
||||||
weapons: Set<Weapon>,
|
modFolderData: String,
|
||||||
racesList: List<String>,
|
weapons: Set<Weapon>,
|
||||||
mod: Mod, modDictionary: Map<Int, String>) {
|
racesList: List<String>,
|
||||||
|
mod: Mod, modDictionary: Map<Int, String>
|
||||||
|
) {
|
||||||
|
|
||||||
val races = raceRepository.findAll().toList()
|
val races = raceRepository.findAll().toList()
|
||||||
val armorTypes = armorTypeRepository.findAll().toList()
|
val armorTypes = armorTypeRepository.findAll().toList()
|
||||||
@ -207,9 +246,19 @@ class ModParserService @Autowired constructor(
|
|||||||
|
|
||||||
racesList.forEach { raceFolder ->
|
racesList.forEach { raceFolder ->
|
||||||
val classicRgdDataStructures =
|
val classicRgdDataStructures =
|
||||||
rgdParserService.parseFolderToRgdFiles(modAttribPathService.geBuildingAttribsPath(modAttribPathService.pathToWanilaData, raceFolder))
|
rgdParserService.parseFolderToRgdFiles(
|
||||||
|
modAttribPathService.geBuildingAttribsPath(
|
||||||
|
modAttribPathService.pathToWanilaData,
|
||||||
|
raceFolder
|
||||||
|
)
|
||||||
|
)
|
||||||
val modRgdDataStructures =
|
val modRgdDataStructures =
|
||||||
rgdParserService.parseFolderToRgdFiles(modAttribPathService.geBuildingAttribsPath(modFolderData, raceFolder))
|
rgdParserService.parseFolderToRgdFiles(
|
||||||
|
modAttribPathService.geBuildingAttribsPath(
|
||||||
|
modFolderData,
|
||||||
|
raceFolder
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
val modStructuresFull = classicRgdDataStructures + modRgdDataStructures
|
val modStructuresFull = classicRgdDataStructures + modRgdDataStructures
|
||||||
|
|
||||||
@ -235,17 +284,21 @@ class ModParserService @Autowired constructor(
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
val building = buildingRepository.save(structureDataToSave.building)
|
val building = buildingRepository.save(structureDataToSave.building)
|
||||||
building.weapons = structureDataToSave.buildingWeapons.map {weapon ->
|
building.weapons = structureDataToSave.buildingWeapons.flatMap { weapon ->
|
||||||
BuildingWeapon().also {
|
building.weaponHardpoints
|
||||||
it.building = building
|
.filter { it.weaponId == weapon.id }
|
||||||
it.weapon = weapon
|
.map { hardpointOrder ->
|
||||||
it.buildingWeaponKey = BuildingWeaponKey().also {
|
BuildingWeapon().also {
|
||||||
it.buildingId = building.id
|
it.building = building
|
||||||
it.weaponId = weapon.id
|
it.weapon = weapon
|
||||||
it.hardpoint = weapon.hardpoint
|
it.buildingWeaponKey = BuildingWeaponKey().also {
|
||||||
it.hardpointOrder = weapon.hardpointOrder
|
it.buildingId = building.id
|
||||||
|
it.weaponId = weapon.id
|
||||||
|
it.hardpoint = hardpointOrder.hardpoint
|
||||||
|
it.hardpointOrder = hardpointOrder.order
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}.toMutableSet()
|
}.toMutableSet()
|
||||||
buildingRepository.save(building)
|
buildingRepository.save(building)
|
||||||
|
|
||||||
@ -260,7 +313,8 @@ class ModParserService @Autowired constructor(
|
|||||||
|
|
||||||
private fun getAddonsRgdData(modFolderData: String): Map<String, List<RgdData>> {
|
private fun getAddonsRgdData(modFolderData: String): Map<String, List<RgdData>> {
|
||||||
|
|
||||||
val classicAddons = rgdParserService.parseFolderToRgdFiles("${modAttribPathService.pathToWanilaData}/attrib/addons")
|
val classicAddons =
|
||||||
|
rgdParserService.parseFolderToRgdFiles("${modAttribPathService.pathToWanilaData}/attrib/addons")
|
||||||
|
|
||||||
val modAddons =
|
val modAddons =
|
||||||
rgdParserService.parseFolderToRgdFiles(modAttribPathService.getAddonAttribsPath(modFolderData))
|
rgdParserService.parseFolderToRgdFiles(modAttribPathService.getAddonAttribsPath(modFolderData))
|
||||||
@ -270,7 +324,8 @@ class ModParserService @Autowired constructor(
|
|||||||
|
|
||||||
private fun saveWeapons(modFolderData: String, mod: Mod, modDictionary: Map<Int, String>): Set<Weapon> {
|
private fun saveWeapons(modFolderData: String, mod: Mod, modDictionary: Map<Int, String>): Set<Weapon> {
|
||||||
|
|
||||||
val classicWeapons = rgdParserService.parseFolderToRgdFiles("${modAttribPathService.pathToWanilaData}/attrib/weapon")
|
val classicWeapons =
|
||||||
|
rgdParserService.parseFolderToRgdFiles("${modAttribPathService.pathToWanilaData}/attrib/weapon")
|
||||||
|
|
||||||
val modWeapons =
|
val modWeapons =
|
||||||
rgdParserService.parseFolderToRgdFiles(modAttribPathService.getWeaponAttribsPath(modFolderData))
|
rgdParserService.parseFolderToRgdFiles(modAttribPathService.getWeaponAttribsPath(modFolderData))
|
||||||
|
|||||||
@ -91,9 +91,8 @@ class SergeantRgdExtractService @Autowired constructor(
|
|||||||
val sergeantWeapons = getSergeantWeapons(sergeantData)?.mapNotNull { weaponData ->
|
val sergeantWeapons = getSergeantWeapons(sergeantData)?.mapNotNull { weaponData ->
|
||||||
weapons.find {
|
weapons.find {
|
||||||
it.filename == weaponData.weaponFilename + ".rgd"
|
it.filename == weaponData.weaponFilename + ".rgd"
|
||||||
}.also {
|
}?.also {wp ->
|
||||||
it?.hardpoint = weaponData.hardpoint
|
sergeant.weaponHardpoints.add(Weapon.HardpointPosition(wp.id!!, weaponData.hardpoint, weaponData.hardpointOrder))
|
||||||
it?.hardpointOrder = weaponData.hardpointOrder
|
|
||||||
}
|
}
|
||||||
}.orEmpty().toSet()
|
}.orEmpty().toSet()
|
||||||
|
|
||||||
@ -189,16 +188,9 @@ class SergeantRgdExtractService @Autowired constructor(
|
|||||||
.getRgdTableByName("ui_ext")
|
.getRgdTableByName("ui_ext")
|
||||||
?.getRgdTableByName("ui_info")
|
?.getRgdTableByName("ui_info")
|
||||||
?.getStringByName("icon_name")
|
?.getStringByName("icon_name")
|
||||||
?.replace("/", File.separator)
|
|
||||||
|
|
||||||
|
return iconPathInMod?.let { modAttribPathService.getIconPath(modFolderData, iconPathInMod) }
|
||||||
val tgaIconPath = iconPathInMod?.let {
|
?.let { iconsService.convertTgaToJpegImage(iconPathInMod, it, modName) }
|
||||||
val modIcon = modAttribPathService.getIconPath(modFolderData, it)
|
|
||||||
if(Path.of(modIcon).exists()) modIcon else
|
|
||||||
modAttribPathService.getIconPath(modAttribPathService.pathToWanilaData, it)
|
|
||||||
}
|
|
||||||
|
|
||||||
return tgaIconPath?.let { iconsService.convertTgaToJpegImage(iconPathInMod, it, modName) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -407,16 +407,9 @@ class UnitRgdExtractService @Autowired constructor(
|
|||||||
.getRgdTableByName("squad_ui_ext")
|
.getRgdTableByName("squad_ui_ext")
|
||||||
?.getRgdTableByName("ui_info")
|
?.getRgdTableByName("ui_info")
|
||||||
?.getStringByName("icon_name")
|
?.getStringByName("icon_name")
|
||||||
?.replace("/", File.separator)
|
|
||||||
|
|
||||||
|
return iconPathInMod?.let { modAttribPathService.getIconPath(modFolderData, iconPathInMod) }
|
||||||
val tgaIconPath = iconPathInMod?.let {
|
?.let { iconsService.convertTgaToJpegImage(iconPathInMod, it, modName) }
|
||||||
val modIcon = modAttribPathService.getIconPath(modFolderData, it)
|
|
||||||
if (Path.of(modIcon).exists()) modIcon else
|
|
||||||
modAttribPathService.getIconPath(modAttribPathService.pathToWanilaData, it)
|
|
||||||
}
|
|
||||||
|
|
||||||
return tgaIconPath?.let { iconsService.convertTgaToJpegImage(iconPathInMod, it, modName) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -170,14 +170,9 @@ class WeaponRgdExtractService @Autowired constructor(
|
|||||||
|
|
||||||
val icon = try {
|
val icon = try {
|
||||||
val iconPath = weaponUiInfo?.getStringByName("icon_name")
|
val iconPath = weaponUiInfo?.getStringByName("icon_name")
|
||||||
?.replace("/", File.separator)
|
|
||||||
|
|
||||||
val tgaIconPath = iconPath?.let {
|
iconPath?.let { modAttribPathService.getIconPath(modFolderData, iconPath) }
|
||||||
val modIcon = modAttribPathService.getIconPath(modFolderData, it)
|
?.let { iconsService.convertTgaToJpegImage(iconPath, it, mod.name) }
|
||||||
if(Path.of(modIcon).exists()) modIcon else
|
|
||||||
modAttribPathService.getIconPath(modAttribPathService.pathToWanilaData, it)
|
|
||||||
}
|
|
||||||
tgaIconPath?.let { iconsService.convertTgaToJpegImage(iconPath, it, mod.name) }
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
log.error("Error parsing ui icon path", e)
|
log.error("Error parsing ui icon path", e)
|
||||||
null
|
null
|
||||||
|
|||||||
@ -93,7 +93,22 @@
|
|||||||
"name": "value",
|
"name": "value",
|
||||||
"type": "varchar(256)"
|
"type": "varchar(256)"
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
],
|
||||||
|
"tableName": "addon_requirements"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"changeSet": {
|
||||||
|
"id": "Add mod_id column to building_addons",
|
||||||
|
"author": "anibus",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"addColumn": {
|
||||||
|
"columns": [
|
||||||
{
|
{
|
||||||
"column": {
|
"column": {
|
||||||
"name": "mod_id",
|
"name": "mod_id",
|
||||||
@ -104,7 +119,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"tableName": "addon_requirements"
|
"tableName": "building_addons"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user