Skip to content

Commit

Permalink
Merge pull request #42 from cyb3rpsych0s1s/chore/fixes-and-improvements
Browse files Browse the repository at this point in the history
Chore/fixes and improvements
  • Loading branch information
Roms1383 authored Nov 26, 2024
2 parents 2e5a576 + 7814d66 commit 21974bc
Show file tree
Hide file tree
Showing 138 changed files with 6,084 additions and 6,391 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/bundle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
on:
workflow_call:
inputs:
tag:
description: "Git tag"
required: true
type: string
release:
description: "Cargo build profile"
type: boolean

env:
CARGO_TERM_COLOR: always
CARGO_NET_GIT_FETCH_WITH_CLI: true
BIN-FOLDER: bundle${{ inputs.release && '' || '-dev-only' }}
BIN-NAME: Audioware-windows-latest-${{ inputs.tag }}${{ inputs.release && '' || '-DEV_ONLY' }}
CHECKSUM-NAME: checksum${{ inputs.release && '' || '-DEV_ONLY' }}
BUILD-PROFILE: ${{ inputs.release && 'release' || 'debug' }}
BUILD-FEATURES: ${{ inputs.release && '' || 'hot-reload' }}
ARTIFACT-NAME: windows-latest-${{ inputs.tag }}${{ inputs.release && '' || '-dev-only' }}-artifact

jobs:
bundle:
runs-on: windows-2019
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Prepare Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc
- uses: Swatinem/rust-cache@v2
with:
key: release
- name: Additional tools
uses: taiki-e/install-action@v2
with:
tool: just
- name: Bundle mod files
run: just ci ${{ env.BIN-FOLDER }}\${{ env.BIN-NAME }} ${{ env.BUILD-PROFILE }} ${{ env.BUILD-FEATURES }}
- name: Zip files
uses: thedoctor0/[email protected]
with:
type: zip
filename: ${{ env.BIN-NAME }}.zip
directory: ${{ env.BIN-FOLDER }}
path: .
- name: Generate zip checksum
run: Get-FileHash -Path "${{ env.BIN-FOLDER }}\${{ env.BIN-NAME }}.zip" -Algorithm SHA256 | Select-Object -ExpandProperty Hash > "${{ env.CHECKSUM-NAME }}.txt"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT-NAME }}
path: ${{ env.BIN-FOLDER }}/${{ env.BIN-NAME }}.zip
if-no-files-found: error
- name: Upload artifact checksum
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT-NAME }}-checksum
path: ${{ env.CHECKSUM-NAME }}.txt
if-no-files-found: error
51 changes: 11 additions & 40 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,20 @@ env:
IS_DRAFT: ${{ startsWith(github.ref_name, 'beta') || startsWith(github.ref_name, 'alpha') }}
IS_PRERELEASE: ${{ startsWith(github.ref_name, 'rc') }}
IS_RELEASE: ${{ startsWith(github.ref_name, 'v') }}
BIN-NAME: Audioware-windows-latest-${{ github.ref_name }}
CARGO_NET_GIT_FETCH_WITH_CLI: true

jobs:
bundle:
runs-on: windows-2019
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Prepare Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc
- uses: Swatinem/rust-cache@v2
with:
key: release
- name: Additional tools
uses: taiki-e/install-action@v2
with:
tool: just
- name: Bundle mod files
run: just ci 'Audioware-windows-latest-${{ github.ref_name }}' '${{ env.IS_RELEASE }}'
- name: Zip files
uses: thedoctor0/[email protected]
with:
type: zip
filename: Audioware-windows-latest-${{ github.ref_name }}.zip
directory: Audioware-windows-latest-${{ github.ref_name }}
path: .
- name: Generate zip checksum
run: Get-FileHash -Path "Audioware-windows-latest-${{ github.ref_name }}\Audioware-windows-latest-${{ github.ref_name }}.zip" -Algorithm SHA256 | Select-Object -ExpandProperty Hash > "checksum.txt"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: windows-latest-${{ github.ref_name }}-artifact
path: Audioware-windows-latest-${{ github.ref_name }}/Audioware-windows-latest-${{ github.ref_name }}.zip
if-no-files-found: error
- name: Upload artifact checksum
uses: actions/upload-artifact@v4
with:
name: windows-latest-${{ github.ref_name }}-artifact-checksum
path: checksum.txt
if-no-files-found: error
uses: ./.github/workflows/bundle.yml
with:
tag: ${{ github.ref_name }}
release: true
bundle-dev-only:
uses: ./.github/workflows/bundle.yml
with:
tag: ${{ github.ref_name }}
release: false
release:
if: ${{ startsWith(github.event.ref, 'refs/tags') }}
runs-on: windows-2019
Expand All @@ -70,7 +41,7 @@ jobs:
- name: Create release ${{ github.ref_name }}
uses: ncipollo/release-action@v1
with:
artifacts: "release/Audioware-windows-latest-${{ github.ref_name }}.zip,release/checksum.txt"
artifacts: "release/${{ env.BIN-NAME }}.zip,release/${{ env.BIN-NAME }}-DEV_ONLY.zip,release/checksum.txt,release/checksum-DEV_ONLY.txt"
draft: ${{ env.IS_DRAFT }}
prerelease: ${{ env.IS_PRERELEASE }}
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ members = ["manifest", "bank", "audioware", "core"]
resolver = "2"

[workspace.package]
version = "1.1.2"
version = "1.3.0"
edition = "2021"
rust-version = "1.80.1"
rust-version = "1.82.0"

[profile.release]
lto = "thin"
Expand All @@ -18,9 +18,9 @@ audioware-manifest = { path = "manifest" }
audioware-bank = { path = "bank" }
either = "1.13"
glam = "0.29"
kira = { version = "0.9.5", features = ["serde"] }
kira = { version = "0.9.6", features = ["serde"] }
rayon = "1.10"
red4ext-rs = { git = "https://github.com/jac3km4/red4ext-rs", rev = "v0.9.1" }
red4ext-rs = { git = "https://github.com/Roms1383/red4ext-rs", branch = "chore/solo" }
# red4ext-rs-bindings = { git = "https://github.com/jac3km4/red4ext-rs-bindings", rev = "v0.5.0" }
serde = "1.0"
snafu = "0.8"
Expand Down
11 changes: 7 additions & 4 deletions audioware/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ crate-type = ["cdylib"]

[dependencies]
audioware-core.workspace = true
audioware-bank.workspace = true
audioware-bank = { workspace = true }
audioware-manifest.workspace = true
cpal = "0.15"
crossbeam = { version = "0.8.4", features = ["crossbeam-channel"] }
Expand All @@ -22,16 +22,19 @@ either.workspace = true
glam = { workspace = true, features = ["mint"] }
kira.workspace = true
mint = { version = "0.5" }
once_cell = "1.19"
parking_lot = "0.12"
rayon.workspace = true
red4ext-rs.workspace = true
rust-ini = "0.21"
snafu.workspace = true
snowflake.workspace = true
bitflags = "2.6.0"

[build-dependencies]
semver = "1.0"

[package.metadata.cargo-machete]
ignored = ["rust-ini"]

[features]
default = []
research = []
hot-reload = ["audioware-bank/hot-reload"]
57 changes: 9 additions & 48 deletions audioware/reds/Codeware.reds
Original file line number Diff line number Diff line change
Expand Up @@ -3,71 +3,32 @@ module Audioware
import Codeware.Localization.*

native func DefineSubtitles(package: ref<LocalizationPackage>);
native func SupportedLanguages() -> array<CName>;
public native func SupportedLanguages() -> array<CName>;

public class LocalizationPackage extends ModLocalizationPackage {
public func VoiceLanguage() -> CName {
return LocalizationSystem.GetInstance(GetGameInstance()).GetVoiceLanguage();
}
public func SubtitleLanguage() -> CName {
return LocalizationSystem.GetInstance(GetGameInstance()).GetSubtitleLanguage();
}
public func VoiceLanguage() -> CName = LocalizationSystem.GetInstance(GetGameInstance()).GetVoiceLanguage();
public func SubtitleLanguage() -> CName = LocalizationSystem.GetInstance(GetGameInstance()).GetSubtitleLanguage();
protected func DefineSubtitles() -> Void {
DefineSubtitles(this);
}
}

public class LocalizationProvider extends ModLocalizationProvider {
protected func OnAttach() {
super.OnAttach();
DBG("on attach: LocalizationProvider");
this.OnLocaleChange();
this.OnGenderChange();
}
public func OnLocaleChange() -> Void {
DBG("on locale change: LocalizationProvider");
public func OnLocaleChange() {
let system = LocalizationSystem.GetInstance(this.GetGameInstance());
let spoken = system.GetVoiceLanguage();
let written = system.GetSubtitleLanguage();
FTLog(s"update locales: spoken: \(NameToString(spoken)), written: \(NameToString(written))");
SetGameLocales(spoken, written);
}
public func OnGenderChange() -> Void {
DBG("on gender change: LocalizationProvider");
public func OnGenderChange() {
let system = LocalizationSystem.GetInstance(this.GetGameInstance());
let gender = system.GetPlayerGender();
FTLog(s"update player gender: \(ToString(gender))");
SetPlayerGender(gender);
}
public func GetPackage(language: CName) -> ref<ModLocalizationPackage> {
let languages = SupportedLanguages();
let supported = ArrayContains(languages, language);
if supported {
let package = new LocalizationPackage();
return package;
}
return null;
}
public func GetFallback() -> CName { return n""; }
}

private func PropagateSubtitle(reaction: CName, entityID: EntityID, emitterName: CName, lineType: scnDialogLineType, duration: Float) -> Void {
if !IsNameValid(reaction) || !EntityID.IsDefined(entityID) { return; }
let target = GameInstance.FindEntityByID(GetGameInstance(), entityID);
if !IsDefined(target) || !target.IsA(n"gameObject") { return; }
let key: String = NameToString(reaction);
let subtitle: String = LocalizationSystem.GetInstance(GetGameInstance()).GetSubtitle(key);
DBG(s"subtitle (\(key)): \(subtitle)");
if StrLen(key) > 0 && NotEquals(key, subtitle) {
let line: scnDialogLineData;
line.duration = duration;
line.id = CreateCRUID(StringToUint64(NameToString(reaction)));
line.isPersistent = false;
line.speaker = target as GameObject;
line.speakerName = NameToString(emitterName);
line.text = subtitle;
line.type = lineType;
DBG(s"subtitle line about to play");
let board: ref<IBlackboard> = GameInstance.GetBlackboardSystem(GetGameInstance()).Get(GetAllBlackboardDefs().UIGameData);
board.SetVariant(GetAllBlackboardDefs().UIGameData.ShowDialogLine, ToVariant([line]), true);
AudiowareSystem.GetInstance(GetGameInstance()).DelayHideSubtitle(line, duration);
return new LocalizationPackage();
}
public func GetFallback() -> CName = n"";
}
Loading

0 comments on commit 21974bc

Please sign in to comment.