fn add_node_of_name(&mut self, name: String, position: (isize, isize), context: &mut ScreenContext) {

        let mut node_widget : Option<NodeWidget> =  None;
        let mut id : usize = 0;

        // Create the node
        if let Some(behavior) = context.data.get_mut_behavior(self.get_curr_behavior_id(context), self.graph_type) {

            let node_type = match name.as_str() {
                "Expression" => BehaviorNodeType::Expression,
                "Number" => BehaviorNodeType::VariableNumber,
                "Position" => BehaviorNodeType::VariablePosition,
                "Message" => BehaviorNodeType::Message,
                "Pathfinder" => BehaviorNodeType::Pathfinder,
                "Script" => BehaviorNodeType::Script,
                "Lookout" => BehaviorNodeType::Lookout,
                "Close In" => BehaviorNodeType::CloseIn,
                "Call System" => BehaviorNodeType::CallSystem,
                "Call Behavior" => BehaviorNodeType::CallBehavior,
                "Lock Tree" => BehaviorNodeType::LockTree,
                "Unlock" => BehaviorNodeType::UnlockTree,
                "Sequence" => BehaviorNodeType::Sequence,
                "Set State" => BehaviorNodeType::SetState,
                "Linear" => BehaviorNodeType::Linear,
                "Move" => BehaviorNodeType::Move,

                "Enter Area" => BehaviorNodeType::EnterArea,
                "Leave Area" => BehaviorNodeType::LeaveArea,
                "Inside Area" => BehaviorNodeType::InsideArea,
                "Spawn" => BehaviorNodeType::Spawn,
                "Displace Tiles" => BehaviorNodeType::DisplaceTiles,

                "Screen" => BehaviorNodeType::Screen,
                "Widget" => BehaviorNodeType::Widget,

                _ => BehaviorNodeType::BehaviorTree
            };

            id = behavior.add_node(node_type, name.clone());
            if let Some(node) = behavior.data.nodes.get_mut(&id) {
                node.position = position;
            }

            let node = NodeWidget::new_from_behavior_data(&behavior.data, &behavior.data.nodes.get(&id).unwrap());
             node_widget = Some(node);

            behavior.save_data();
        }

        // Add the atom widgets
        if let Some(mut node) = node_widget {
            if self.graph_type == BehaviorType::Regions {
                let region = context.data.regions.get(&context.data.regions_ids[context.curr_region_index]).unwrap();
                self.init_node_widget(&region.behaviors[context.curr_region_area_index].data, &region.behaviors[context.curr_region_area_index].data.nodes.get(&id).unwrap(), &mut node, context);
            } else
            if self.graph_type == BehaviorType::Behaviors {
                let behavior = context.data.behaviors.get(&context.data.behaviors_ids[context.curr_behavior_index]).unwrap();
                self.init_node_widget(&behavior.data, &behavior.data.nodes.get(&id).unwrap(), &mut node, context);
            } else
            if self.graph_type == BehaviorType::Systems {
                let behavior = context.data.systems.get(&context.data.systems_ids[context.curr_systems_index]).unwrap();
                self.init_node_widget(&behavior.data, &behavior.data.nodes.get(&id).unwrap(), &mut node, context);
            } else
            if self.graph_type == BehaviorType::Items {
                let behavior = context.data.items.get(&context.data.items_ids[context.curr_items_index]).unwrap();
                self.init_node_widget(&behavior.data, &behavior.data.nodes.get(&id).unwrap(), &mut node, context);
            } else
            if self.graph_type == BehaviorType::GameLogic {
                if let Some(behavior) = context.data.get_behavior(0, self.graph_type) {
                    self.init_node_widget(&behavior.data, &behavior.data.nodes.get(&id).unwrap(), &mut node, context);
                }
            }
            self.nodes.push(node);
        }

        self.check_node_visibility(context);
        self.dirty = true;
    }
/// Adds a node of the type identified by its name
Adds a node of the type identified by its name
Adds a node of the type identified by its name
fn add_node_of_name(&mut self, name: String, position: (isize, isize), context: &mut ScreenContext) {
        let mut node_widget : Option<NodeWidget> =  None;
        let mut id : usize = 0;
        // Create the node
        if let Some(behavior) = context.data.get_mut_behavior(self.get_curr_behavior_id(context), self.graph_type) {
            let node_type = match name.as_str() {
                "Expression" => BehaviorNodeType::Expression,
                "Number" => BehaviorNodeType::VariableNumber,
                "Position" => BehaviorNodeType::VariablePosition,
                "Message" => BehaviorNodeType::Message,
                "Pathfinder" => BehaviorNodeType::Pathfinder,
                "Script" => BehaviorNodeType::Script,
                "Lookout" => BehaviorNodeType::Lookout,
                "Close In" => BehaviorNodeType::CloseIn,
                "Call System" => BehaviorNodeType::CallSystem,
                "Call Behavior" => BehaviorNodeType::CallBehavior,
                "Lock Tree" => BehaviorNodeType::LockTree,
                "Unlock" => BehaviorNodeType::UnlockTree,
                "Sequence" => BehaviorNodeType::Sequence,
                "Set State" => BehaviorNodeType::SetState,
                "Linear" => BehaviorNodeType::Linear,
                "Move" => BehaviorNodeType::Move,
                "Enter Area" => BehaviorNodeType::EnterArea,
                "Leave Area" => BehaviorNodeType::LeaveArea,
                "Inside Area" => BehaviorNodeType::InsideArea,
                "Spawn" => BehaviorNodeType::Spawn,
                "Displace Tiles" => BehaviorNodeType::DisplaceTiles,
                "Screen" => BehaviorNodeType::Screen,
                "Widget" => BehaviorNodeType::Widget,
                _ => BehaviorNodeType::BehaviorTree
            };
            id = behavior.add_node(node_type, name.clone());
            if let Some(node) = behavior.data.nodes.get_mut(&id) {
                node.position = position;
            }
            let node = NodeWidget::new_from_behavior_data(&behavior.data, &behavior.data.nodes.get(&id).unwrap());
             node_widget = Some(node);
            behavior.save_data();
        }
        // Add the atom widgets
        if let Some(mut node) = node_widget {
            if self.graph_type == BehaviorType::Regions {
                let region = context.data.regions.get(&context.data.regions_ids[context.curr_region_index]).unwrap();
                self.init_node_widget(&region.behaviors[context.curr_region_area_index].data, &region.behaviors[context.curr_region_area_index].data.nodes.get(&id).unwrap(), &mut node, context);
            } else
            if self.graph_type == BehaviorType::Behaviors {
                let behavior = context.data.behaviors.get(&context.data.behaviors_ids[context.curr_behavior_index]).unwrap();
                self.init_node_widget(&behavior.data, &behavior.data.nodes.get(&id).unwrap(), &mut node, context);
            } else
            if self.graph_type == BehaviorType::Systems {
                let behavior = context.data.systems.get(&context.data.systems_ids[context.curr_systems_index]).unwrap();
                self.init_node_widget(&behavior.data, &behavior.data.nodes.get(&id).unwrap(), &mut node, context);
            } else
            if self.graph_type == BehaviorType::Items {
                let behavior = context.data.items.get(&context.data.items_ids[context.curr_items_index]).unwrap();
                self.init_node_widget(&behavior.data, &behavior.data.nodes.get(&id).unwrap(), &mut node, context);
            } else
            if self.graph_type == BehaviorType::GameLogic {
                if let Some(behavior) = context.data.get_behavior(0, self.graph_type) {
                    self.init_node_widget(&behavior.data, &behavior.data.nodes.get(&id).unwrap(), &mut node, context);
                }
            }
            self.nodes.push(node);
        }
        self.check_node_visibility(context);
        self.dirty = true;
    }
fn add_node_of_name ( & mut self , name : String , position : ( isize , isize ) , context : & mut ScreenContext ) { let mut node_widget : Option < NodeWidget > = None ; let mut id : usize = 0 ; // Create the node if let Some ( behavior ) = context . data . get_mut_behavior ( self . get_curr_behavior_id ( context ) , self . graph_type ) { let node_type = match name . as_str ( ) { " " => BehaviorNodeType :: Expression , " " => BehaviorNodeType :: VariableNumber , " " => BehaviorNodeType :: VariablePosition , " " => BehaviorNodeType :: Message , " " => BehaviorNodeType :: Pathfinder , " " => BehaviorNodeType :: Script , " " => BehaviorNodeType :: Lookout , " " => BehaviorNodeType :: CloseIn , " " => BehaviorNodeType :: CallSystem , " " => BehaviorNodeType :: CallBehavior , " " => BehaviorNodeType :: LockTree , " " => BehaviorNodeType :: UnlockTree , " " => BehaviorNodeType :: Sequence , " " => BehaviorNodeType :: SetState , " " => BehaviorNodeType :: Linear , " " => BehaviorNodeType :: Move , " " => BehaviorNodeType :: EnterArea , " " => BehaviorNodeType :: LeaveArea , " " => BehaviorNodeType :: InsideArea , " " => BehaviorNodeType :: Spawn , " " => BehaviorNodeType :: DisplaceTiles , " " => BehaviorNodeType :: Screen , " " => BehaviorNodeType :: Widget , _ => BehaviorNodeType :: BehaviorTree } ; id = behavior . add_node ( node_type , name . clone ( ) ) ; if let Some ( node ) = behavior . data . nodes . get_mut ( & id ) { node . position = position ; } let node = NodeWidget :: new_from_behavior_data ( & behavior . data , & behavior . data . nodes . get ( & id ) . unwrap ( ) ) ; node_widget = Some ( node ) ; behavior . save_data ( ) ; } // Add the atom widgets if let Some ( mut node ) = node_widget { if self . graph_type == BehaviorType :: Regions { let region = context . data . regions . get ( & context . data . regions_ids [ context . curr_region_index ] ) . unwrap ( ) ; self . init_node_widget ( & region . behaviors [ context . curr_region_area_index ] . data , & region . behaviors [ context . curr_region_area_index ] . data . nodes . get ( & id ) . unwrap ( ) , & mut node , context ) ; } else if self . graph_type == BehaviorType :: Behaviors { let behavior = context . data . behaviors . get ( & context . data . behaviors_ids [ context . curr_behavior_index ] ) . unwrap ( ) ; self . init_node_widget ( & behavior . data , & behavior . data . nodes . get ( & id ) . unwrap ( ) , & mut node , context ) ; } else if self . graph_type == BehaviorType :: Systems { let behavior = context . data . systems . get ( & context . data . systems_ids [ context . curr_systems_index ] ) . unwrap ( ) ; self . init_node_widget ( & behavior . data , & behavior . data . nodes . get ( & id ) . unwrap ( ) , & mut node , context ) ; } else if self . graph_type == BehaviorType :: Items { let behavior = context . data . items . get ( & context . data . items_ids [ context . curr_items_index ] ) . unwrap ( ) ; self . init_node_widget ( & behavior . data , & behavior . data . nodes . get ( & id ) . unwrap ( ) , & mut node , context ) ; } else if self . graph_type == BehaviorType :: GameLogic { if let Some ( behavior ) = context . data . get_behavior ( 0 , self . graph_type ) { self . init_node_widget ( & behavior . data , & behavior . data . nodes . get ( & id ) . unwrap ( ) , & mut node , context ) ; } } self . nodes . push ( node ) ; } self . check_node_visibility ( context ) ; self . dirty = true ; }
Adds a node of the type identified by its name
Adds a node of the type identified by its name
&mut self
name
String
position
(isize, isize)
context
&mut ScreenContext
&mut self
name
String
position
(isize, isize)
context
&mut ScreenContext