Skip to content

Commit

Permalink
fix ui and logic problems
Browse files Browse the repository at this point in the history
  • Loading branch information
bananaturtlesandwich committed Apr 22, 2023
1 parent 0d70ad8 commit 24efebc
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 25 deletions.
Binary file modified src/blueprints/angel_hook.uasset
Binary file not shown.
Binary file modified src/blueprints/bremur_hook.uasset
Binary file not shown.
Binary file modified src/blueprints/hook.uasset
Binary file not shown.
Binary file modified src/blueprints/hook.uexp
Binary file not shown.
Binary file modified src/blueprints/paulale_hook.uasset
Binary file not shown.
Binary file modified src/blueprints/player_hook.uasset
Binary file not shown.
1 change: 0 additions & 1 deletion src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ pub fn save<C: std::io::Read + std::io::Seek>(
asset: &mut Asset<C>,
path: impl AsRef<Path>,
) -> Result<(), Error> {
asset.rebuild_name_map()?;
asset.write_data(
&mut File::create(&path)?,
Some(&mut File::create(path.as_ref().with_extension("uexp"))?),
Expand Down
29 changes: 15 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use eframe::egui;

mod io;
mod logic;
mod map;
mod writing;

pub struct Rando {
font: egui::FontDefinitions,
notifs: egui_modal::Modal,
pak: std::path::PathBuf,
pak_str: String,
Expand Down Expand Up @@ -39,6 +42,16 @@ impl Rando {
.unwrap_or_default()
};

let mut font = egui::FontDefinitions::default();
font.font_data.insert(
"cinzel".to_string(),
egui::FontData::from_static(include_bytes!("Cinzel-Regular.ttf")),
);
font.families
.get_mut(&egui::FontFamily::Proportional)
.unwrap()
.insert(0, "cinzel".to_string());

let notifs = egui_modal::Modal::new(&ctx.egui_ctx, "dialog");
let autoupdate = get_bool("autoupdate");

Expand Down Expand Up @@ -69,6 +82,7 @@ impl Rando {
let pak_str = get_pak_str(&pak);

Self {
font,
notifs,
pak,
pak_str,
Expand Down Expand Up @@ -146,20 +160,7 @@ macro_rules! notify {

impl eframe::App for Rando {
fn update(&mut self, ctx: &eframe::egui::Context, _: &mut eframe::Frame) {
use eframe::egui;

let mut fonts = egui::FontDefinitions::default();
fonts.font_data.insert(
"cinzel".to_string(),
egui::FontData::from_static(include_bytes!("Cinzel-Regular.ttf")),
);
fonts
.families
.get_mut(&egui::FontFamily::Proportional)
.unwrap()
.insert(0, "cinzel".to_string());
ctx.set_fonts(fonts);

ctx.set_fonts(self.font.clone());
egui::CentralPanel::default().show(ctx, |ui| {
ui.horizontal(|ui| {
ui.heading(
Expand Down
16 changes: 14 additions & 2 deletions src/logic/checks.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::*;
use crate::{no_walljump, walljump};

pub const CHECKS: [Check; 252] = [
pub const CHECKS: [Check; 254] = [
// Fire Keep
Check {
location: Locations::Lab,
Expand Down Expand Up @@ -1340,7 +1340,13 @@ pub const CHECKS: [Check; 252] = [
drop: Drop::Ore(200),
locks: &[Lock::Movement(&[no_walljump!(0, 3)])],
},
// i can't find pickups 11, 12 and 6
// i can't find pickup 6
Check {
location: Locations::Bunny,
context: Context::Overworld("Pickup11"),
drop: Drop::Ore(100),
locks: &[],
},
Check {
location: Locations::Bunny,
context: Context::Cutscene("NPC/Onops/Onop_Speedo/NPC_Onop_Speedo"),
Expand All @@ -1353,6 +1359,12 @@ pub const CHECKS: [Check; 252] = [
drop: Drop::Ore(150),
locks: &[Lock::Movement(&[no_walljump!(0, 1)])],
},
Check {
location: Locations::Bunny,
context: Context::Overworld("Pickup12"),
drop: Drop::Ore(150),
locks: &[Lock::Movement(&[no_walljump!(0, 1)])],
},
Check {
location: Locations::Bunny,
context: Context::Overworld("Dance_Platform_Windmill_Chest"),
Expand Down
4 changes: 3 additions & 1 deletion src/logic/locations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ impl Locations {
Lock::Item(Items::KeyHolyMaster),
]],
Locations::TempleGardens => &[&[
Lock::Location(Locations::Stoneheart),
Lock::Item(Items::OldKey),
Lock::Item(Items::KeyHolyMaster),
Lock::Location(Locations::UthasEnd),
Lock::Movement(&[no_walljump!(1, 0)]),
]],
Locations::AbandonedPath => &[&[
Expand Down
10 changes: 4 additions & 6 deletions src/writing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,8 @@ pub fn write(data: Data, app: &crate::Rando) -> Result<(), Error> {
loc.with_extension("uexp"),
)?;
let mut spirit_hunter = open(&loc)?;
spirit_hunter.exports[440]
.get_base_export_mut()
.object_name
.content = "Pickup_A02_SRF2".to_string();
spirit_hunter.exports[440].get_base_export_mut().object_name =
spirit_hunter.add_fname("Pickup_A02_SRF2");
save(&mut spirit_hunter, &loc)?;
std::thread::scope(|thread| -> Result<(), Error> {
for thread in [
Expand Down Expand Up @@ -149,8 +147,8 @@ fn create_hook<C: std::io::Read + std::io::Seek>(
let mut hook = get_hook(&loc)?;
// edit the item given by the kismet bytecode in the hook
let exports::Export::FunctionExport(
exports::function_export::FunctionExport{
struct_export: struct_export::StructExport{
exports::function_export::FunctionExport {
struct_export: struct_export::StructExport {
script_bytecode:Some(bytecode),
..
},
Expand Down
1 change: 1 addition & 0 deletions src/writing/overworld.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ pub fn write(
_ => (),
}
}
map.rebuild_name_map()?;
save(&mut map, &loc)?;
Ok(())
}));
Expand Down
1 change: 1 addition & 0 deletions src/writing/savegames.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ pub fn write(
.value
.remove(i);
}
savegame.rebuild_name_map()?;
save(&mut savegame, savegame_loc)?;
Ok(())
}
2 changes: 1 addition & 1 deletion src/writing/specific.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::*;

pub fn write(cases: Vec<Check>, app: &crate::Rando, pak: &unpak::Pak) -> Result<(), Error> {
for Check { context, drop, .. } in cases {
let Context::Specific(case,index) = context else{
let Context::Specific(case, index) = context else {
return Err(Error::Assumption)?
};
create_hook(
Expand Down

0 comments on commit 24efebc

Please sign in to comment.