forked from StrafesNET/asset-tool
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>{
|
pub(crate) fn sanitize<'a>(s:&'a str)->std::borrow::Cow<'a,str>{
|
||||||
lazy_regex::regex!(r"[^A-z0-9.-]").replace_all(s,"_")
|
lazy_regex::regex!(r"[^A-z0-9.-]").replace_all(s,"_")
|
||||||
}
|
}
|
||||||
|
@ -400,7 +400,7 @@ pub struct CompileConfig{
|
|||||||
style:Option<Style>,
|
style:Option<Style>,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum CompileError{
|
pub enum CompileError{
|
||||||
NullChildRef,
|
NullChildRef,
|
||||||
IO(std::io::Error),
|
IO(std::io::Error),
|
||||||
CompileNode(CompileNodeError),
|
CompileNode(CompileNodeError),
|
||||||
@ -408,7 +408,7 @@ enum CompileError{
|
|||||||
JoinError(tokio::task::JoinError),
|
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
|
//add in scripts and models
|
||||||
let mut folder=config.input_folder.clone();
|
let mut folder=config.input_folder.clone();
|
||||||
let mut stack:Vec<CompileStackInstruction>=vec![CompileStackInstruction::TraverseReferent(dom.root_ref(),None)];
|
let mut stack:Vec<CompileStackInstruction>=vec![CompileStackInstruction::TraverseReferent(dom.root_ref(),None)];
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use rbx_dom_weak::types::Ref;
|
use rbx_dom_weak::types::Ref;
|
||||||
use crate::{common::sanitize, types::{Style, PropertiesOverride}};
|
use crate::common::{sanitize,Style,PropertiesOverride};
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
enum Class{
|
enum Class{
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
mod common;
|
mod common;
|
||||||
pub mod types;
|
mod compile;
|
||||||
pub mod compile;
|
mod decompile;
|
||||||
pub 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 std::{io::Read,path::PathBuf};
|
||||||
use clap::{Args,Parser,Subcommand};
|
use clap::{Args,Parser,Subcommand};
|
||||||
use anyhow::Result as AResult;
|
use anyhow::Result as AResult;
|
||||||
use rbx_dom_weak::types::Ref;
|
use futures::StreamExt;
|
||||||
use tokio::io::AsyncReadExt;
|
|
||||||
use rbx_asset::context::{RobloxContext,InventoryItem,AssetVersion};
|
use rbx_asset::context::{RobloxContext,InventoryItem,AssetVersion};
|
||||||
|
|
||||||
type AssetID=u64;
|
type AssetID=u64;
|
||||||
@ -563,17 +562,18 @@ async fn decompile(config:DecompileConfig)->AResult<()>{
|
|||||||
//Everything else goes into template.rbxlx
|
//Everything else goes into template.rbxlx
|
||||||
|
|
||||||
//read file
|
//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
|
//generate folders, models, and scripts
|
||||||
//delete models and scripts from dom
|
//delete models and scripts from dom
|
||||||
write_files(WriteConfig{
|
context.write_files(WriteConfig{
|
||||||
style:config.style,
|
style:config.style,
|
||||||
output_folder:config.output_folder,
|
output_folder:config.output_folder,
|
||||||
write_template:config.write_template,
|
write_template:config.write_template,
|
||||||
write_models:config.write_models,
|
write_models:config.write_models,
|
||||||
write_scripts:config.write_scripts,
|
write_scripts:config.write_scripts,
|
||||||
},context).await?;
|
}).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user