/// <summary> /// Loads the skills from the Skills.ini file /// </summary> private void Load() { string file = Path.Combine( Pandora.Profile.BaseFolder, "Skills.ini" ); if ( !File.Exists( file ) ) { Pandora.Log.WriteError( null, "Skills.ini file missing" ); m_Menu.MenuItems.Add( new MenuItem( "Skills.ini not found" ) ); return; } try { StreamReader reader = new StreamReader( file ); string line = null; MenuItem parent = null; while ( ( line = reader.ReadLine() ) != null ) { line = line.Trim(); if ( line.Length == 0 ) continue; if ( line.StartsWith( "#" ) ) continue; if ( line.StartsWith( ":" ) ) { // New category MenuItem cat = new MenuItem( line.Substring( 1 ) ); m_Menu.MenuItems.Add( cat ); parent = cat; } else { // Skill string[] defs = line.Split( ':' ); if ( defs.Length != 2 ) continue; defs[0] = defs[0].Trim(); defs[1] = defs[1].Trim(); InternalMenuItem mi = new InternalMenuItem( defs[0], defs[1] ); mi.Click += new EventHandler(mi_Click); parent.MenuItems.Add( mi ); } } } catch ( Exception err ) { Pandora.Log.WriteError( err, "Can't read Skills.ini" ); m_Menu.MenuItems.Clear(); m_Menu.MenuItems.Add( new MenuItem( "You really had to mess up with Skills.ini...." ) ); } }
/// <summary> /// An item is selected /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SoundData_Click(object sender, EventArgs e) { InternalMenuItem mi = sender as InternalMenuItem; if (mi != null) { SelectedSound = mi.Sound; } }
private void mi_Click(object sender, EventArgs e) { if (SkillSelected != null) { InternalMenuItem mi = sender as InternalMenuItem; SkillSelected(this, new SkillEventArgs(mi.Text, mi.Skill)); } }
/// <summary> /// User clicks a door menu item /// </summary> private void DoorClicked(object sender, EventArgs e) { InternalMenuItem mi = sender as InternalMenuItem; if (DoorSelected != null) { string category = null; foreach (MenuItem parent in m_Menu.MenuItems) { if (parent.MenuItems.Contains(mi)) { category = parent.Text; break; } } DoorSelected(new DoorEventArgs(mi.Door, category)); } }
/// <summary> /// Builds the context menu used to select doors /// </summary> private void BuildMenu() { m_Menu = new ContextMenu(); foreach (var gNode in m_Structure) { var category = new MenuItem(gNode.Name); m_Menu.MenuItems.Add(category); foreach (DoorInfo door in gNode.Elements) { var mi = new InternalMenuItem(door); mi.Click += DoorClicked; category.MenuItems.Add(mi); } } var port = new MenuItem(m_PortName); port.Click += PortcullisClicked; m_Menu.MenuItems.Add(port); }
/// <summary> /// Builds the context menu used to select doors /// </summary> private void BuildMenu() { m_Menu = new ContextMenu(); foreach (GenericNode gNode in m_Structure) { MenuItem category = new MenuItem(gNode.Name); m_Menu.MenuItems.Add(category); foreach (DoorInfo door in gNode.Elements) { InternalMenuItem mi = new InternalMenuItem(door); mi.Click += new EventHandler(DoorClicked); category.MenuItems.Add(mi); } } MenuItem port = new MenuItem(m_PortName); port.Click += new EventHandler(PortcullisClicked); m_Menu.MenuItems.Add(port); }
/// <summary> /// Processes a GenericNode and created the menu items for it /// </summary> /// <param name="gNode">The GenericNode to evaluate</param> /// <returns>A collection of MenuItem objects</returns> private MenuItem[] DoNode(GenericNode gNode) { MenuItem[] mitems = new MenuItem[gNode.Elements.Count]; for (int i = 0; i < mitems.Length; i++) { GenericNode node = gNode.Elements[i] as GenericNode; UOSound snd = gNode.Elements[i] as UOSound; if (node != null) { mitems[i] = new MenuItem(node.Name); mitems[i].MenuItems.AddRange(DoNode(node)); } else if (snd != null) { mitems[i] = new InternalMenuItem(snd); mitems[i].Click += new EventHandler(SoundData_Click); } } return(mitems); }
/// <summary> /// Processes a GenericNode and created the menu items for it /// </summary> /// <param name="gNode">The GenericNode to evaluate</param> /// <returns>A collection of MenuItem objects</returns> private MenuItem[] DoNode(GenericNode gNode) { var mitems = new MenuItem[gNode.Elements.Count]; for (var i = 0; i < mitems.Length; i++) { var node = gNode.Elements[i] as GenericNode; var snd = gNode.Elements[i] as UOSound; if (node != null) { mitems[i] = new MenuItem(node.Name); mitems[i].MenuItems.AddRange(DoNode(node)); } else if (snd != null) { mitems[i] = new InternalMenuItem(snd); mitems[i].Click += SoundData_Click; } } return(mitems); }
/// <summary> /// Loads the skills from the Skills.ini file /// </summary> private void Load() { string file = Path.Combine(Pandora.Profile.BaseFolder, "Skills.ini"); if (!File.Exists(file)) { Pandora.Log.WriteError(null, "Skills.ini file missing"); m_Menu.MenuItems.Add(new MenuItem("Skills.ini not found")); return; } try { StreamReader reader = new StreamReader(file); string line = null; MenuItem parent = null; while ((line = reader.ReadLine()) != null) { line = line.Trim(); if (line.Length == 0) { continue; } if (line.StartsWith("#")) { continue; } if (line.StartsWith(":")) { // New category MenuItem cat = new MenuItem(line.Substring(1)); m_Menu.MenuItems.Add(cat); parent = cat; } else { // Skill string[] defs = line.Split(':'); if (defs.Length != 2) { continue; } defs[0] = defs[0].Trim(); defs[1] = defs[1].Trim(); InternalMenuItem mi = new InternalMenuItem(defs[0], defs[1]); mi.Click += new EventHandler(mi_Click); parent.MenuItems.Add(mi); } } } catch (Exception err) { Pandora.Log.WriteError(err, "Can't read Skills.ini"); m_Menu.MenuItems.Clear(); m_Menu.MenuItems.Add(new MenuItem("You really had to mess up with Skills.ini....")); } }
/// <summary> /// Processes a GenericNode and created the menu items for it /// </summary> /// <param name="gNode">The GenericNode to evaluate</param> /// <returns>A collection of MenuItem objects</returns> private MenuItem[] DoNode( GenericNode gNode ) { MenuItem[] mitems = new MenuItem[ gNode.Elements.Count ]; for ( int i = 0; i < mitems.Length; i++ ) { GenericNode node = gNode.Elements[ i ] as GenericNode; UOSound snd = gNode.Elements[ i ] as UOSound; if ( node != null ) { mitems[ i ] = new MenuItem( node.Name ); mitems[ i ].MenuItems.AddRange( DoNode( node ) ); } else if ( snd != null ) { mitems[ i ] = new InternalMenuItem( snd ); mitems[ i ].Click += new EventHandler(SoundData_Click); } } return mitems; }
/// <summary> /// Builds the context menu used to select doors /// </summary> private void BuildMenu() { m_Menu = new ContextMenu(); foreach( GenericNode gNode in m_Structure ) { MenuItem category = new MenuItem( gNode.Name ); m_Menu.MenuItems.Add( category ); foreach( DoorInfo door in gNode.Elements ) { InternalMenuItem mi = new InternalMenuItem( door ); mi.Click += new EventHandler(DoorClicked); category.MenuItems.Add( mi ); } } MenuItem port = new MenuItem( m_PortName ); port.Click += new EventHandler(PortcullisClicked); m_Menu.MenuItems.Add( port ); }