forked from StrafesNET/asset-tool
the good
This commit is contained in:
parent
f7f309b2bb
commit
b09f3a6ab0
@ -2,8 +2,7 @@ use std::path::PathBuf;
|
||||
use futures::{StreamExt, TryStreamExt};
|
||||
use tokio::io::AsyncReadExt;
|
||||
|
||||
use crate::types::{Style,PropertiesOverride};
|
||||
use crate::common::sanitize;
|
||||
use crate::common::{sanitize,Style,PropertiesOverride};
|
||||
|
||||
//holy smokes what am I doing lmao
|
||||
//This giant machine is supposed to search for files according to style rules
|
||||
@ -190,6 +189,12 @@ struct ScriptWithOverrides{
|
||||
pub enum ScriptWithOverridesError{
|
||||
UnimplementedProperty(String),
|
||||
}
|
||||
impl std::fmt::Display for ScriptWithOverridesError{
|
||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
||||
write!(f,"{self:?}")
|
||||
}
|
||||
}
|
||||
impl std::error::Error for ScriptWithOverridesError{}
|
||||
|
||||
impl ScriptWithOverrides{
|
||||
fn from_source(mut source:String)->Result<Self,ScriptWithOverridesError>{
|
||||
@ -240,6 +245,12 @@ enum CompileNodeError{
|
||||
},
|
||||
NoExtension,
|
||||
}
|
||||
impl std::fmt::Display for CompileNodeError{
|
||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
||||
write!(f,"{self:?}")
|
||||
}
|
||||
}
|
||||
impl std::error::Error for CompileNodeError{}
|
||||
|
||||
enum FileDiscernment{
|
||||
Model,
|
||||
@ -407,6 +418,12 @@ pub enum CompileError{
|
||||
DecodeError(rbx_xml::DecodeError),
|
||||
JoinError(tokio::task::JoinError),
|
||||
}
|
||||
impl std::fmt::Display for CompileError{
|
||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
||||
write!(f,"{self:?}")
|
||||
}
|
||||
}
|
||||
impl std::error::Error for CompileError{}
|
||||
|
||||
pub async fn compile(config:CompileConfig,mut dom:&mut rbx_dom_weak::WeakDom)->Result<(),CompileError>{
|
||||
//add in scripts and models
|
||||
|
@ -43,11 +43,17 @@ enum WriteStackInstruction<'a>{
|
||||
Destroy(Ref),
|
||||
}
|
||||
|
||||
enum WriteError{
|
||||
pub enum WriteError{
|
||||
ClassNotScript(String),
|
||||
IO(std::io::Error),
|
||||
EncodeError(rbx_xml::EncodeError),
|
||||
}
|
||||
impl std::fmt::Display for WriteError{
|
||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
||||
write!(f,"{self:?}")
|
||||
}
|
||||
}
|
||||
impl std::error::Error for WriteError{}
|
||||
|
||||
fn write_item(dom:&rbx_dom_weak::WeakDom,mut file:PathBuf,node:&TreeNode,node_name_override:String,mut properties:PropertiesOverride,style:Style,write_models:bool,write_scripts:bool)->Result<(),WriteError>{
|
||||
file.push(sanitize(node_name_override.as_str()).as_ref());
|
||||
@ -107,11 +113,11 @@ fn write_item(dom:&rbx_dom_weak::WeakDom,mut file:PathBuf,node:&TreeNode,node_na
|
||||
}
|
||||
|
||||
pub struct WriteConfig{
|
||||
style:Style,
|
||||
output_folder:PathBuf,
|
||||
write_template:bool,
|
||||
write_models:bool,
|
||||
write_scripts:bool,
|
||||
pub style:Style,
|
||||
pub output_folder:PathBuf,
|
||||
pub write_template:bool,
|
||||
pub write_models:bool,
|
||||
pub write_scripts:bool,
|
||||
}
|
||||
|
||||
pub struct DecompiledContext{
|
||||
|
@ -563,12 +563,12 @@ async fn decompile(config:DecompileConfig)->AResult<()>{
|
||||
|
||||
//read file
|
||||
let dom=load_dom(std::io::BufReader::new(std::fs::File::open(config.input_file)?))?;
|
||||
let context=rox_compiler::decompile::DecompiledContext::from_dom(dom);
|
||||
let context=rox_compiler::DecompiledContext::from_dom(dom);
|
||||
|
||||
//generate folders, models, and scripts
|
||||
//delete models and scripts from dom
|
||||
context.write_files(WriteConfig{
|
||||
style:config.style,
|
||||
context.write_files(rox_compiler::WriteConfig{
|
||||
style:config.style.rox(),
|
||||
output_folder:config.output_folder,
|
||||
write_template:config.write_template,
|
||||
write_models:config.write_models,
|
||||
|
Loading…
Reference in New Issue
Block a user