forked from StrafesNET/map-tool
implement Exit/Delete
This commit is contained in:
parent
7ab20f36a7
commit
52d911a25a
18
src/main.rs
18
src/main.rs
@ -328,10 +328,13 @@ enum ScriptAction {
|
|||||||
Replace(u32),
|
Replace(u32),
|
||||||
Flag,
|
Flag,
|
||||||
Block,
|
Block,
|
||||||
|
Delete,
|
||||||
}
|
}
|
||||||
enum ScriptActionParseResult {
|
enum ScriptActionParseResult {
|
||||||
Pass,
|
Pass,
|
||||||
Block,
|
Block,
|
||||||
|
Exit,
|
||||||
|
Delete,
|
||||||
}
|
}
|
||||||
struct ParseScriptActionErr;
|
struct ParseScriptActionErr;
|
||||||
impl std::str::FromStr for ScriptActionParseResult {
|
impl std::str::FromStr for ScriptActionParseResult {
|
||||||
@ -341,6 +344,10 @@ impl std::str::FromStr for ScriptActionParseResult {
|
|||||||
Ok(Self::Pass)
|
Ok(Self::Pass)
|
||||||
}else if s=="block\n"{
|
}else if s=="block\n"{
|
||||||
Ok(Self::Block)
|
Ok(Self::Block)
|
||||||
|
}else if s=="exit\n"{
|
||||||
|
Ok(Self::Exit)
|
||||||
|
}else if s=="delete\n"{
|
||||||
|
Ok(Self::Delete)
|
||||||
}else{
|
}else{
|
||||||
Err(ParseScriptActionErr)
|
Err(ParseScriptActionErr)
|
||||||
}
|
}
|
||||||
@ -355,7 +362,7 @@ fn interactive() -> Result<(), Box<dyn std::error::Error>>{
|
|||||||
let mut replace_map=get_replace_map()?;
|
let mut replace_map=get_replace_map()?;
|
||||||
let mut blocked = get_blocked()?;
|
let mut blocked = get_blocked()?;
|
||||||
|
|
||||||
for entry in std::fs::read_dir("maps/unprocessed")? {
|
'map_loop: for entry in std::fs::read_dir("maps/unprocessed")? {
|
||||||
let file_thing=entry?;
|
let file_thing=entry?;
|
||||||
println!("processing map={:?}",file_thing.file_name());
|
println!("processing map={:?}",file_thing.file_name());
|
||||||
let input = std::io::BufReader::new(std::fs::File::open(file_thing.path())?);
|
let input = std::io::BufReader::new(std::fs::File::open(file_thing.path())?);
|
||||||
@ -436,6 +443,8 @@ fn interactive() -> Result<(), Box<dyn std::error::Error>>{
|
|||||||
id+=1;
|
id+=1;
|
||||||
ScriptAction::Block
|
ScriptAction::Block
|
||||||
},
|
},
|
||||||
|
ScriptActionParseResult::Exit => break 'map_loop,
|
||||||
|
ScriptActionParseResult::Delete => ScriptAction::Delete,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -451,7 +460,12 @@ fn interactive() -> Result<(), Box<dyn std::error::Error>>{
|
|||||||
}else{
|
}else{
|
||||||
panic!("failed to get replacement source id={} location={}",replace_id,location);
|
panic!("failed to get replacement source id={} location={}",replace_id,location);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
ScriptAction::Delete => {
|
||||||
|
println!("deleted source location={}",get_full_name(&dom, script));
|
||||||
|
replace_count+=1;
|
||||||
|
dom.destroy(script.referent());
|
||||||
|
},
|
||||||
ScriptAction::Flag => {
|
ScriptAction::Flag => {
|
||||||
println!("flagged source location={}",get_full_name(&dom, script));
|
println!("flagged source location={}",get_full_name(&dom, script));
|
||||||
fail_type=Interactive::Flagged;
|
fail_type=Interactive::Flagged;
|
||||||
|
Loading…
Reference in New Issue
Block a user