Skip to content

Commit

Permalink
Push code for 1.19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Raytwo committed Jan 1, 2025
1 parent 6681ec4 commit 327889c
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ gamedata = { path = "crates/gamedata" }
loader = { path = "crates/loader" }
mods = { path = "crates/mods" }
unity = { version = "0.3.0", git = "https://github.com/DivineDragonFanClub/unity" }
engage = { version = "0.6.5", git = "https://github.com/DivineDragonFanClub/engage" }
engage = { version = "0.7.0", git = "https://github.com/DivineDragonFanClub/engage" }
horizon-svc = { git = "https://github.com/skyline-rs/horizon-svc" } # We don't include the implementations because exlaunch already has them
camino = "1.0.7"
semver = { version = "1" }
Expand Down
4 changes: 2 additions & 2 deletions crates/cobalt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "cobalt"
version = "1.18.0"
version = "1.19.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
skyline = { git = "https://github.com/ultimate-research/skyline-rs" }
unity = { version = "0.3.0", git = "https://github.com/DivineDragonFanClub/unity" }
engage = { version = "0.6.5", git = "https://github.com/DivineDragonFanClub/engage" }
engage = { version = "0.7.0", git = "https://github.com/DivineDragonFanClub/engage" }
mods = { path = "../mods" }
updater = { path = "../updater" }
localize = { git = "https://github.com/DivineDragonFanClub/localize" }
Expand Down
6 changes: 3 additions & 3 deletions crates/cobalt/resources/VibrationEvent.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
<Param Name="UnitRelease_NotEngageOwner" Time="0.07" AmplitudeMagnitude="0.10" AmpLow="0.1" AmpHigh="0.0" FreqLow="50" FreqHigh="80" Easing="" VibrationType="UI"/>
<Param Name="UnitRelease_Engaged" Time="0.07" AmplitudeMagnitude="0.18" AmpLow="0.25" AmpHigh="0.1" FreqLow="50" FreqHigh="80" Easing="" VibrationType="UI"/>

<Param Name="Colbalt_Engage_Ring_Flash" Time="0.30" AmplitudeMagnitude="0.50" AmpLow="0.1875" AmpHigh="0.3" FreqLow="50.0" FreqHigh="500.0" Easing="" VibrationType="UI"/>
<Param Name="Colbalt_Engage_Ring_Buzz" Time="0.90" AmplitudeMagnitude="0.15" AmpLow="0.15" AmpHigh="0.3" FreqLow="120.0" FreqHigh="750.0" Easing="ReverseEaseOutCubic" VibrationType="UI"/>
<Param Name="Cobalt_Engage_Ring_Flash" Time="0.30" AmplitudeMagnitude="0.50" AmpLow="0.1875" AmpHigh="0.3" FreqLow="50.0" FreqHigh="500.0" Easing="" VibrationType="UI"/>
<Param Name="Cobalt_Engage_Ring_Buzz" Time="0.90" AmplitudeMagnitude="0.15" AmpLow="0.15" AmpHigh="0.3" FreqLow="120.0" FreqHigh="750.0" Easing="ReverseEaseOutCubic" VibrationType="UI"/>
<Param Name="Cobalt_Engage_Ring_Flash_Plus_1" Time="0.50" AmplitudeMagnitude="0.50" AmpLow="0.1875" AmpHigh="0.3" FreqLow="50.0" FreqHigh="500.0" Easing="" VibrationType="UI"/>
<Param Name="Cobalt_Engage_Ring_Flash_Plus_2" Time="0.80" AmplitudeMagnitude="0.60" AmpLow="0.3" AmpHigh="0.3" FreqLow="250.0" FreqHigh="600.0" Easing="" VibrationType="UI"/>
<Param Name="Engage_Decide" Time="0.15" AmplitudeMagnitude="0.35" AmpLow="0.25" AmpHigh="0.5" FreqLow="100" FreqHigh="700" Easing="EaseInCubic" VibrationType="UI"/>
Expand Down Expand Up @@ -231,7 +231,7 @@
<Param Name="SE_GodSkill_Marth_Effect01" Chain="Cobalt_Marth_Charging,0;Cobalt_Marth_Ding,0.850;"/>
<Param Name="Engage_Ring_Flash_Plus" Chain="Cobalt_Engage_Ring_Flash_Plus_1,0.25;Cobalt_Engage_Ring_Flash_Plus_2,2.0;"/>
<Param Name="Engage_Kamui_Shot01" Chain="Cobalt_Engage_Kamui_Shot,1.2;"/>
<Param Name="Engage_Ring_Flash" Chain="Colbalt_Engage_Ring_Flash,0;"/>
<Param Name="Engage_Ring_Flash" Chain="Cobalt_Engage_Ring_Flash,0;"/>
<Param Name="Engage_Cellica_Fire01" Chain="Cobalt_Engage_Cellica_Hands_Clasp,0;Cobalt_Engage_Cellica_Hands_Charge,0.4;"/>
<Param Name="Engage_Bonds_Shot_01" Chain="Cobalt_Engage_Bonds_Shot_01,0;Cobalt_Engage_Beam,1.3;"/>
<Param Name="SE_Eff_Cannon_Trigger_Bmap" Chain="Cobalt_Map_BowCannon_Draw,0;Cobalt_Map_BowCannon_Release,0.70;"/>
Expand Down
3 changes: 2 additions & 1 deletion crates/cobalt/src/config/cobalt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use engage::{
use unity::prelude::*;

use super::{
super::sequences::mainmenu::cobaltmenu::sequences::settings::{lod::LodSetting, render_scale::RenderScaleSetting},
super::sequences::mainmenu::cobaltmenu::sequences::settings::{lod::LodSetting, render_scale::RenderScaleSetting, render_scale_toggle::ToggleRenderScaleSetting},
combatpopup::CombatPopupSettings,
combatui::CombatUISettings,
combatvibration::CombatVibrationsSettings,
Expand Down Expand Up @@ -63,6 +63,7 @@ impl ConfigBasicMenuItemCommandMethods for CobaltSubmenu {
config_menu.add_item(ConfigBasicMenuItem::new_switch::<SupportOutfitSetting>(localize::mess::get(
"support_outfit_item_name",
)));
config_menu.add_item(ConfigBasicMenuItem::new_switch::<ToggleRenderScaleSetting>(localize::mess::get("render_scale_toggle_name")));
config_menu.add_item(ConfigBasicMenuItem::new_switch::<RenderScaleSetting>(localize::mess::get(
"render_scale_name",
)));
Expand Down
11 changes: 7 additions & 4 deletions crates/cobalt/src/graphics/render_scale.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
use unity::{engine::rendering::universal::UniversalRenderPipelineAsset, prelude::*};

use crate::sequences::mainmenu::cobaltmenu::sequences::settings::render_scale::get_render_scale;
use crate::sequences::mainmenu::cobaltmenu::sequences::settings::{render_scale::get_render_scale, render_scale_toggle};

// CustomRP.Settings$$SetRenderScale 71021a8db0 void CustomRP.Settings$$SetRenderScale(float scale, MethodInfo * method) 340
#[skyline::hook(offset = 0x21a8db0)]
pub fn set_render_scale(scale: f32, method_info: OptionalMethod) {
let scale = get_render_scale().unwrap_or(scale);
println!("SetRenderScale: {}", scale);
pub fn set_render_scale(mut scale: f32, method_info: OptionalMethod) {
if unsafe { render_scale_toggle::TOGGLE } {
scale = get_render_scale().unwrap_or(scale);
println!("SetRenderScale: {}", scale);
}

call_original!(scale, method_info);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use opening::SkipOpeningSetting;
use plugins::GlobalPluginSubmenu;
pub mod lod;
pub mod render_scale;
pub mod render_scale_toggle;
pub mod util;

use self::plugins::GLOBAL_CONFIGMENUITEM_CB;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
use unity::prelude::*;

use engage::menu::{
config::{ConfigBasicMenuItem, ConfigBasicMenuItemSwitchMethods},
BasicMenuResult,
};

pub static mut TOGGLE: bool = false;

pub struct ToggleRenderScaleSetting;

impl ConfigBasicMenuItemSwitchMethods for ToggleRenderScaleSetting {
fn init_content(_this: &mut ConfigBasicMenuItem) {
unsafe { TOGGLE = std::path::Path::new("sd:/engage/config/render_scale_enabled").exists() };
}

extern "C" fn custom_call(this: &mut ConfigBasicMenuItem, _method_info: OptionalMethod) -> BasicMenuResult {
let toggle = unsafe { TOGGLE };
let result = ConfigBasicMenuItem::change_key_value_b(toggle);

if toggle != result {
if result {
std::fs::File::create("sd:/engage/config/render_scale_enabled").expect("Could not create the Render Scale Toggle configuration file");
} else {
std::fs::remove_file("sd:/engage/config/render_scale_enabled").expect("Could not delete the Render Scale Toggle configuration file");
}

unsafe { TOGGLE = result }

Self::set_command_text(this, None);
Self::set_help_text(this, None);
this.update_text();

BasicMenuResult::se_cursor()
} else {
BasicMenuResult::new()
}
}

extern "C" fn set_command_text(this: &mut ConfigBasicMenuItem, _method_info: OptionalMethod) {
if unsafe { TOGGLE } {
this.command_text = localize::mess::get("command_text_on").into();
} else {
this.command_text = localize::mess::get("command_text_off").into();
}
}

extern "C" fn set_help_text(this: &mut ConfigBasicMenuItem, _method_info: OptionalMethod) {
if unsafe { TOGGLE } {
this.help_text = localize::mess::get("render_scale_toggle_enabled_helptext").into();
} else {
this.help_text = localize::mess::get("render_scale_toggle_disabled_helptext").into();
}
}
}
27 changes: 24 additions & 3 deletions crates/cobalt/src/sprite.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
use std::sync::OnceLock;

use engage::{
gamedata::{god::RingData, item::ItemData, unit::Unit, GodData},
gamedata::{ring::RingData, item::ItemData, unit::Unit, GodData},
uniticon::UnitIcon,
};

use camino::Utf8PathBuf;
use unity::{
prelude::*,
engine::{
ui::{Image, IsImage},
Color, FilterMode, ImageConversion, Material, Rect, Sprite, SpriteMeshType, Texture2D, Vector2,
},
}, prelude::*, system::Dictionary
};

static mut SPRITE_MATERIAL: OnceLock<&'static Material> = OnceLock::new();
Expand Down Expand Up @@ -296,4 +295,26 @@ pub fn godcolorrefineemblem_getcolor(_this: &AppGodColorRefineEmblemO, god: &mut
},
_ => call_original!(_this, god, method_info),
}
}

#[repr(C)]
pub struct MapUIGauge<'a> {
_padding: [u8; 0x58],
m_sprites: &'a Il2CppArray<&'a mut Sprite>,
m_dictionary: &'a mut Dictionary<&'a Il2CppString, &'a mut Sprite>,
}

#[skyline::hook(offset = 0x201F830)]
pub fn mapuigauge_getspritebyname(this: &MapUIGauge, name: Option<&Il2CppString>, method_info: OptionalMethod) -> &'static mut Sprite {
let mut result = Sprite::instantiate().unwrap();
if this.m_dictionary.try_get_value(name.unwrap(), &mut result) { return call_original!(this, name, method_info); }

let icon = load_sprite(name, "patches/icon/mapstatus", 64, 64, FilterMode::Point);
match icon {
Some(sprite) => {
this.m_dictionary.add(name.unwrap(), sprite);
sprite
},
None => call_original!(this, name, method_info),
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ pub fn app_sound_manager_post_event(
// "[SoundManager::PostEvent] Event name: {}",
// event_name.unwrap_or("[Blank]".into()).to_string()
// );
process_sound_event_name(event_name);
do_vibrate(|| {
process_sound_event_name(event_name);
});
call_original!(this, event_name, character, is_get_position, method_info)
}

Expand Down
1 change: 1 addition & 0 deletions crates/mods/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub struct ModConfig {
pub(crate) author: String,
#[serde(default)]
pub(crate) dependencies: Vec<String>,
pub(crate) repository: Option<String>
}

pub struct ModPair {
Expand Down
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ pub fn il2cpp_init_hook(domain_name: *const i8) -> i32 {
cobalt::sprite::gameicon_trygetgodring_god,
cobalt::sprite::gameicon_trygetgodsymbol,
cobalt::sprite::godcolorrefineemblem_getcolor,
cobalt::sprite::mapuigauge_getspritebyname,
cobalt::procinst_jump,
cobalt::graphics::render_scale::set_render_scale,
cobalt::graphics::render_scale::set_render_scale_internal,
Expand Down Expand Up @@ -265,9 +266,9 @@ pub fn main() {

if is_emulator() {
loggers.push(Box::new(logger::KernelLogger));
} else {
loggers.push(Box::new(logger::TcpLogger::new()));
}

loggers.push(Box::new(logger::TcpLogger::new()));

multi_log::MultiLogger::init(loggers, log::Level::Info).unwrap();

Expand Down

0 comments on commit 327889c

Please sign in to comment.