惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Apple Machine Learning Research
Apple Machine Learning Research
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 司徒正美
博客园_首页
博客园 - 叶小钗
Blog — PlanetScale
Blog — PlanetScale
The Cloudflare Blog
量子位
人人都是产品经理
人人都是产品经理
小众软件
小众软件
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
Attack and Defense Labs
Attack and Defense Labs
Hacker News: Ask HN
Hacker News: Ask HN
TaoSecurity Blog
TaoSecurity Blog
Forbes - Security
Forbes - Security
罗磊的独立博客
Webroot Blog
Webroot Blog
美团技术团队
Help Net Security
Help Net Security
Google DeepMind News
Google DeepMind News
博客园 - 三生石上(FineUI控件)
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
H
Heimdal Security Blog
C
Check Point Blog
V2EX - 技术
V2EX - 技术
The Last Watchdog
The Last Watchdog
Microsoft Azure Blog
Microsoft Azure Blog
AI
AI
Cloudbric
Cloudbric
Application and Cybersecurity Blog
Application and Cybersecurity Blog
W
WeLiveSecurity
P
Privacy International News Feed
T
The Exploit Database - CXSecurity.com
P
Privacy & Cybersecurity Law Blog
B
Blog RSS Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
L
LINUX DO - 热门话题
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
A
Arctic Wolf
O
OpenAI News
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 【当耐特】
C
Cyber Attacks, Cyber Crime and Cyber Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Y
Y Combinator Blog
Know Your Adversary
Know Your Adversary

Cyberia

排印演进 - Cyberia EAC相关工具集合 - Cyberia 《C(金钱掌控)》观后感 - Cyberia C#在Windows UI开发中的衰落 - Cyberia 存储退潮 字体padding计算器 开源已死 如何写出优雅完整的音频元数据 自动化EAC音频抓取 起夜级家庭网络正在变得越来越重要 优化Powershell的启动时间 无JavaScript其实没有很重要 你不需要一个电纸书阅读器 文件分享的难题 为什么我不敢看都市 某科学的 SSH 算号指南 时代的辉夜姬 为什么 Pixi 是神 关于神椿的过去,当下以及未来,我的一点看法 Tahoe 的图标令人难评 The EVE of PUSHING LIMITS 在 Word 中通过制表符实现居中对齐等操作 编码之殇:前 Unicode 时代的 WAV 处理 sHELL 即地狱 WR1800K AX NAND 路由器刷入 Immortalwrt 一个 PWM 的世界 沉痛悼念复选框同志 字体焕新 独立博客自省问卷15题 答一答 解决 Visual Studio Code 内终端启动报错问题 (1) 简评《鱿鱼游戏》 Sword Art Online,以及它带来了什么 解决 Visual Studio Code 内终端启动报错问题 2024 年度总结 轻小说重度依赖 铃音之后 解决部分应用在 Windows 平台下端口被随机占用的问题 计算机科学中最困难的事:居中 宿舍场景下多人共用路由器下流量分流实践 自动化处理 Amazon Music 文件 MD5 不一致问题 解决 MultiMC 无 Forge 版本的 Optifine 安装问题
Extra Decal Pre Processor
Nullpinter · 2024-06-08 · via Cyberia

Prerequisite#

  1. Cities: Skylines 2
  2. ExtraAssetsImporter
  3. PowerShell 7

WINDOWS EMBEDED POWERSHELL IS OUTDATED

The powershell that comes with windows is powershell 5, which doesn’t fully realize the functionality of 7!

Step#

  1. Setup Mod toolchain in CS2, basically check it in game.
  2. Follow the tutorial to create mods that depend on EAI, this article does not focus on these.
  3. Build decals.

Let’s assume a scenario where you have a folder for all your HD decals (.png) and you need to create uniform decals and thumbnails based on these decals.

So you have:

D:\lorem

├─blahblah

│ a.png

│ b1.png

│ b2.png

│ b3.png

│ b4.png

│ b1.png

│ b2.png

decal.json can be obtained from the EAI example.

Place build.ps1 and decal.json to this directory. Then:

D:\lorem

├─blahblah

│ build.ps1

│ decal.json

│ a.png

│ b1.png

│ b2.png

│ b3.png

│ b4.png

│ b1.png

│ b2.png

Content in build.ps1#

function GenerateIconAndMesh {

param(

$file

)

try {

$originalImage = [System.Drawing.Image]::FromFile($file.FullName)

$maxSize = [Math]::Max($originalImage.Width, $originalImage.Height)

$aspectRatio = $originalImage.Width / $originalImage.Height

$squareImage = New-Object System.Drawing.Bitmap $maxSize, $maxSize

$graphics = [System.Drawing.Graphics]::FromImage($squareImage)

$graphics.Clear([System.Drawing.Color]::Transparent)

$x = ($maxSize - $originalImage.Width) / 2

$y = ($maxSize - $originalImage.Height) / 2

$graphics.DrawImage($originalImage, $x, $y, $originalImage.Width, $originalImage.Height)

$resizedImage = New-Object System.Drawing.Bitmap 128, 128

$resizeGraphics = [System.Drawing.Graphics]::FromImage($resizedImage)

$resizeGraphics.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic

$resizeGraphics.DrawImage($squareImage, 0, 0, 128, 128)

$resizeGraphics.Dispose()

$newFilePath = [IO.Path]::Combine($file.DirectoryName, "icon.png")

$resizedImage.Save($newFilePath)

Write-Host "Saved icon to $newFilePath"

$jsonPath = Join-Path $file.DirectoryName "decal.json"

if (Test-Path $jsonPath) {

$json = Get-Content $jsonPath -Raw | ConvertFrom-Json

$json.Vector.colossal_MeshSize.x = $aspectRatio * 1.5

$json.Vector.colossal_MeshSize.z = 1.5

$json | ConvertTo-Json -Depth 10 | Set-Content $jsonPath

Write-Host "Aspect Ratio = $aspectRatio"

}

else {

Write-Warning "decal.json not found in the directory of $($file.DirectoryName)"

}

}

catch {

Write-Warning "Error processing file $($file.FullName): $_"

}

finally {

# dispose

if ($null -ne $graphics) {

$graphics.Dispose()

}

if ($null -ne $squareImage) {

$squareImage.Dispose()

}

if ($null -ne $resizedImage) {

$resizedImage.Dispose()

}

if ($null -ne $originalImage) {

$resizedImage.Dispose()

}

}

}

Get-ChildItem | Foreach-Object {

if ($_.Extension -eq ".png") {

$folder = "./$($_.BaseName)"

mkdir $folder -ErrorAction SilentlyContinue

$base = "./$($_.BaseName)/_BaseColorMap.png"

Copy-Item $_.FullName -Destination $base

# $icon = "./$($_.BaseName)/icon.png"

# Copy-Item $_.FullName -Destination $icon

if (Test-Path ./decal.json) {

Copy-Item ./decal.json -Destination $folder

}

else {

Write-Warning "decal.json not found"

}

GenerateIconAndMesh(Get-Item $base)

}

}

Run this script in a terminal. A quick way to open a terminal is to type pwsh in explorer’s bar.

Now you’ve got everything done.