geweewweg
This commit is contained in:
parent
dba7aa427f
commit
f7f309b2bb
@ -1,3 +1,33 @@
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub enum Style{
|
||||
Rox,
|
||||
Rojo,
|
||||
RoxRojo,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub(crate) struct PropertiesOverride{
|
||||
pub name:Option<String>,
|
||||
pub class:Option<String>,
|
||||
}
|
||||
impl PropertiesOverride{
|
||||
pub fn is_some(&self)->bool{
|
||||
self.name.is_some()
|
||||
||self.class.is_some()
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for PropertiesOverride{
|
||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
||||
if let Some(name)=self.name.as_deref(){
|
||||
writeln!(f,"--!Properties.Name = \"{}\"",name)?;
|
||||
}
|
||||
if let Some(class)=self.class.as_deref(){
|
||||
writeln!(f,"--!Properties.ClassName = \"{}\"",class)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn sanitize<'a>(s:&'a str)->std::borrow::Cow<'a,str>{
|
||||
lazy_regex::regex!(r"[^A-z0-9.-]").replace_all(s,"_")
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ pub struct CompileConfig{
|
||||
style:Option<Style>,
|
||||
}
|
||||
|
||||
enum CompileError{
|
||||
pub enum CompileError{
|
||||
NullChildRef,
|
||||
IO(std::io::Error),
|
||||
CompileNode(CompileNodeError),
|
||||
@ -408,7 +408,7 @@ enum CompileError{
|
||||
JoinError(tokio::task::JoinError),
|
||||
}
|
||||
|
||||
async fn compile(config:CompileConfig,mut dom:&mut rbx_dom_weak::WeakDom)->Result<(),CompileError>{
|
||||
pub async fn compile(config:CompileConfig,mut dom:&mut rbx_dom_weak::WeakDom)->Result<(),CompileError>{
|
||||
//add in scripts and models
|
||||
let mut folder=config.input_folder.clone();
|
||||
let mut stack:Vec<CompileStackInstruction>=vec![CompileStackInstruction::TraverseReferent(dom.root_ref(),None)];
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::path::PathBuf;
|
||||
use rbx_dom_weak::types::Ref;
|
||||
use crate::{common::sanitize, types::{Style, PropertiesOverride}};
|
||||
use crate::common::{sanitize,Style,PropertiesOverride};
|
||||
|
||||
#[derive(PartialEq)]
|
||||
enum Class{
|
||||
|
@ -1,4 +1,9 @@
|
||||
mod common;
|
||||
pub mod types;
|
||||
pub mod compile;
|
||||
pub mod decompile;
|
||||
mod compile;
|
||||
mod decompile;
|
||||
//export specific types
|
||||
pub use common::Style;
|
||||
pub use compile::CompileConfig;
|
||||
pub use compile::compile;//cringe non standardized interface
|
||||
pub use decompile::DecompiledContext;
|
||||
pub use decompile::WriteConfig;
|
||||
|
@ -1,29 +0,0 @@
|
||||
#[derive(Clone,Copy,Debug)]
|
||||
pub enum Style{
|
||||
Rox,
|
||||
Rojo,
|
||||
RoxRojo,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub(crate) struct PropertiesOverride{
|
||||
pub name:Option<String>,
|
||||
pub class:Option<String>,
|
||||
}
|
||||
impl PropertiesOverride{
|
||||
pub fn is_some(&self)->bool{
|
||||
self.name.is_some()
|
||||
||self.class.is_some()
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for PropertiesOverride{
|
||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
||||
if let Some(name)=self.name.as_deref(){
|
||||
writeln!(f,"--!Properties.Name = \"{}\"",name)?;
|
||||
}
|
||||
if let Some(class)=self.class.as_deref(){
|
||||
writeln!(f,"--!Properties.ClassName = \"{}\"",class)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
10
src/main.rs
10
src/main.rs
@ -1,8 +1,7 @@
|
||||
use std::{io::Read,path::PathBuf};
|
||||
use clap::{Args,Parser,Subcommand};
|
||||
use anyhow::Result as AResult;
|
||||
use rbx_dom_weak::types::Ref;
|
||||
use tokio::io::AsyncReadExt;
|
||||
use futures::StreamExt;
|
||||
use rbx_asset::context::{RobloxContext,InventoryItem,AssetVersion};
|
||||
|
||||
type AssetID=u64;
|
||||
@ -563,17 +562,18 @@ async fn decompile(config:DecompileConfig)->AResult<()>{
|
||||
//Everything else goes into template.rbxlx
|
||||
|
||||
//read file
|
||||
let context=generate_decompiled_context(std::io::BufReader::new(std::fs::File::open(config.input_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);
|
||||
|
||||
//generate folders, models, and scripts
|
||||
//delete models and scripts from dom
|
||||
write_files(WriteConfig{
|
||||
context.write_files(WriteConfig{
|
||||
style:config.style,
|
||||
output_folder:config.output_folder,
|
||||
write_template:config.write_template,
|
||||
write_models:config.write_models,
|
||||
write_scripts:config.write_scripts,
|
||||
},context).await?;
|
||||
}).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user