Skip to content

Commit

Permalink
fix: don't attempt to draw text when not on CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
Naxdy committed Feb 21, 2024
1 parent 0bc3393 commit c234e30
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ static mut CURRENT_INPUT_BUFFER: isize = 4;
static mut MOST_RECENT_AUTO: isize = -1;
static mut STEALTH_MODE: bool = false;
static mut ORIG_VIP_TEXT: String = String::new();
static mut IS_CSS: bool = false;

const MAX_INPUT_BUFFER: isize = 25;
const MIN_INPUT_BUFFER: isize = -1;
Expand Down Expand Up @@ -47,6 +48,10 @@ unsafe fn handle_user_input() {
unsafe fn non_hdr_update_room_hook(_: &skyline::hooks::InlineCtx) {
handle_user_input();

if IS_CSS {
IS_CSS = false;
}

if STEALTH_MODE {
set_text_string(
CURRENT_PANE_HANDLE as u64,
Expand Down Expand Up @@ -85,10 +90,11 @@ unsafe fn non_hdr_update_room_hook(_: &skyline::hooks::InlineCtx) {

#[skyline::hook(offset = 0x004b620)]
unsafe fn handle_draw_hook(layout: *mut Layout, draw_info: u64, cmd_buffer: u64) {
// let layout_name = skyline::from_c_str((*layout).layout_name);
let root_pane = &mut *(*layout).root_pane;
if IS_CSS {
let root_pane = &mut *(*layout).root_pane;

draw_ui(&root_pane);
draw_ui(&root_pane);
}

call_original!(layout, draw_info, cmd_buffer);
}
Expand Down Expand Up @@ -121,6 +127,31 @@ unsafe fn non_hdr_set_online_latency(ctx: &InlineCtx) {
}
}

#[skyline::hook(offset = 0x19f0540, inline)]
unsafe fn display_css_hook(_: &InlineCtx) {
IS_CSS = true;
}

#[skyline::hook(offset = 0x22dbe10, inline)]
unsafe fn melee_normal_sequence_scene_hook(_: &InlineCtx) {
IS_CSS = false;
}

#[skyline::hook(offset = 0x235a628, inline)]
unsafe fn main_menu_scene_hook(_: &InlineCtx) {
IS_CSS = false;
}

#[skyline::hook(offset = 0x236757c, inline)]
unsafe fn online_melee_any_scene_hook(_: &InlineCtx) {
IS_CSS = false;
}

#[skyline::hook(offset = 0x2318210, inline)]
unsafe fn ingame_scene_hook(_: &InlineCtx) {
IS_CSS = false;
}

unsafe fn draw_ui(root_pane: &Pane) {
let vip_pane_00 = root_pane.find_pane_by_name_recursive("txt_vip_title_00");
let vip_pane_01 = root_pane.find_pane_by_name_recursive("txt_vip_title_01");
Expand Down Expand Up @@ -170,6 +201,11 @@ pub fn main() {
non_hdr_update_room_hook,
non_hdr_set_online_latency,
update_css_hook,
handle_draw_hook
handle_draw_hook,
display_css_hook,
melee_normal_sequence_scene_hook,
main_menu_scene_hook,
online_melee_any_scene_hook,
ingame_scene_hook
);
}

0 comments on commit c234e30

Please sign in to comment.