tweaks
This commit is contained in:
parent
5384bbcb3b
commit
8ee041918b
24
src/main.rs
24
src/main.rs
@ -573,12 +573,12 @@ enum WriteStackInstruction<'a>{
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct PropertiesOverride{
|
struct PropertiesOverride{
|
||||||
name:Option<String>,
|
name:Option<String>,
|
||||||
class_name:Option<String>,
|
class:Option<String>,
|
||||||
}
|
}
|
||||||
impl PropertiesOverride{
|
impl PropertiesOverride{
|
||||||
fn is_some(&self)->bool{
|
fn is_some(&self)->bool{
|
||||||
self.name.is_some()
|
self.name.is_some()
|
||||||
||self.class_name.is_some()
|
||self.class.is_some()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl std::fmt::Display for PropertiesOverride{
|
impl std::fmt::Display for PropertiesOverride{
|
||||||
@ -586,15 +586,15 @@ impl std::fmt::Display for PropertiesOverride{
|
|||||||
if let Some(name)=self.name.as_deref(){
|
if let Some(name)=self.name.as_deref(){
|
||||||
writeln!(f,"--!Properties.Name = \"{}\"",name)?;
|
writeln!(f,"--!Properties.Name = \"{}\"",name)?;
|
||||||
}
|
}
|
||||||
if let Some(class_name)=self.class_name.as_deref(){
|
if let Some(class)=self.class.as_deref(){
|
||||||
writeln!(f,"--! Properties.ClassName=\"{}\"",class_name)?;
|
writeln!(f,"--!Properties.ClassName = \"{}\"",class)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sanitize<'a>(s:&'a str)->std::borrow::Cow<'a,str>{
|
fn sanitize<'a>(s:&'a str)->std::borrow::Cow<'a,str>{
|
||||||
lazy_regex::regex!(r"[^a-zA-Z0-9._-]").replace_all(s,"_")
|
lazy_regex::regex!(r"[^A-z0-9.-]").replace_all(s,"_")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_item(dom:&rbx_dom_weak::WeakDom,mut file:std::path::PathBuf,node:&TreeNode,node_name_override:String,mut properties:PropertiesOverride,style:DecompileStyle,write_models:bool,write_scripts:bool)->AResult<()>{
|
fn write_item(dom:&rbx_dom_weak::WeakDom,mut file:std::path::PathBuf,node:&TreeNode,node_name_override:String,mut properties:PropertiesOverride,style:DecompileStyle,write_models:bool,write_scripts:bool)->AResult<()>{
|
||||||
@ -610,18 +610,18 @@ fn write_item(dom:&rbx_dom_weak::WeakDom,mut file:std::path::PathBuf,node:&TreeN
|
|||||||
match style{
|
match style{
|
||||||
DecompileStyle::Rox=>assert!(file.set_extension("lua"),"could not set extension"),
|
DecompileStyle::Rox=>assert!(file.set_extension("lua"),"could not set extension"),
|
||||||
DecompileStyle::RoxRojo|DecompileStyle::Rojo=>{
|
DecompileStyle::RoxRojo|DecompileStyle::Rojo=>{
|
||||||
match properties.class_name.as_deref(){
|
match properties.class.as_deref(){
|
||||||
Some("LocalScript")=>{
|
Some("LocalScript")=>{
|
||||||
file.set_extension("client.lua");
|
file.set_extension("client.lua");
|
||||||
properties.class_name=None;
|
properties.class=None;
|
||||||
},
|
},
|
||||||
Some("Script")=>{
|
Some("Script")=>{
|
||||||
file.set_extension("server.lua");
|
file.set_extension("server.lua");
|
||||||
properties.class_name=None;
|
properties.class=None;
|
||||||
},
|
},
|
||||||
// Some("ModuleScript")=>{
|
// Some("ModuleScript")=>{
|
||||||
// file.set_extension("module");
|
// file.set_extension("module");
|
||||||
// properties.class_name=None;
|
// properties.class=None;
|
||||||
// },
|
// },
|
||||||
None=>assert!(file.set_extension("lua"),"could not set extension"),
|
None=>assert!(file.set_extension("lua"),"could not set extension"),
|
||||||
Some(other)=>return Err(anyhow::Error::msg(format!("Attempt to write a {} as a script",other))),
|
Some(other)=>return Err(anyhow::Error::msg(format!("Attempt to write a {} as a script",other))),
|
||||||
@ -664,7 +664,7 @@ fn generate_decompiled_context<R:Read>(input:R)->AResult<DecompiledContext>{
|
|||||||
|
|
||||||
let mut tree_refs=std::collections::HashMap::new();
|
let mut tree_refs=std::collections::HashMap::new();
|
||||||
tree_refs.insert(dom.root_ref(),TreeNode::new(
|
tree_refs.insert(dom.root_ref(),TreeNode::new(
|
||||||
"src".to_string(),
|
"src".to_owned(),
|
||||||
dom.root_ref(),
|
dom.root_ref(),
|
||||||
Ref::none(),
|
Ref::none(),
|
||||||
Class::Folder
|
Class::Folder
|
||||||
@ -783,8 +783,8 @@ async fn write_files(config:WriteConfig,mut context:DecompiledContext)->AResult<
|
|||||||
match node.class{
|
match node.class{
|
||||||
Class::Folder=>(),
|
Class::Folder=>(),
|
||||||
Class::ModuleScript=>(),//.lua files are ModuleScript by default
|
Class::ModuleScript=>(),//.lua files are ModuleScript by default
|
||||||
Class::LocalScript=>properties.class_name=Some("LocalScript".to_string()),
|
Class::LocalScript=>properties.class=Some("LocalScript".to_owned()),
|
||||||
Class::Script=>properties.class_name=Some("Script".to_string()),
|
Class::Script=>properties.class=Some("Script".to_owned()),
|
||||||
Class::Model=>(),
|
Class::Model=>(),
|
||||||
}
|
}
|
||||||
let name_override=if 0<name_count{
|
let name_override=if 0<name_count{
|
||||||
|
Loading…
Reference in New Issue
Block a user