Пример #1
0
        public AppSettings()
        {
            _instance = this;

            string config;
            try
            {
                System.IO.StreamReader rd = new System.IO.StreamReader(AppSettings.BaseDirectory+"\\App.cfg");
                config = rd.ReadToEnd();
                rd.Close();
            }
            catch
            {
                config = @"
            Dev
            Defines
            proj=..\..\#exe#
            Prod
            Defines
            proj=#exe#
            All
            Media
            #exe#Media";
            }

            this._root = this.Load(AppSettings.RunMode, config);

            string[] paths = this["Media"];
        }
Пример #2
0
        public InteractorFactory(Node trackSettings)
        {
            this._spritesToStart         = new ArrayList();
            EH.Instance.EnterFrameEvent += new EnterFrame(Instance_EnterFrameEvent);

            this._trackSettings = trackSettings;             //new Node();
//			this._trackSettings.GetOrCreate("Drums.Interactor").Text = "X";
//			this._trackSettings.GetOrCreate("Drums.LocSetter").Text = "Default";
//			this._trackSettings.GetOrCreate("Kalimba.Interactor").Text = "Shake";
//			this._trackSettings.GetOrCreate("Kalimba.LocSetter").Text = "Swirl";
        }
Пример #3
0
        public InteractorFactory(Node trackSettings)
        {
            this._spritesToStart = new ArrayList();
            EH.Instance.EnterFrameEvent+=new EnterFrame(Instance_EnterFrameEvent);

            this._trackSettings = trackSettings; //new Node();
            //			this._trackSettings.GetOrCreate("Drums.Interactor").Text = "X";
            //			this._trackSettings.GetOrCreate("Drums.LocSetter").Text = "Default";
            //			this._trackSettings.GetOrCreate("Kalimba.Interactor").Text = "Shake";
            //			this._trackSettings.GetOrCreate("Kalimba.LocSetter").Text = "Swirl";
        }
Пример #4
0
        public virtual Interactor.Base CreateInteractor(TrackPlayer tp, ChannelMessage cm)
        {
            EPointF ptLoc    = new EPointF();
            int     note     = cm.Data1;
            int     strength = cm.Data2;
            int     duration = 10;

            Interactor.Base interactor = null;
            LocSetter.Base  locSetter  = null;

            Endogine.Node node = this._trackSettings[tp.Track.Name];
            if (node != null)
            {
                if (node["Interactor"] != null)
                {
                    string sType = "MusicGame.Midi.Interactor." + node["Interactor"].Text;
                    Type   type  = Type.GetType(sType);
                    System.Reflection.ConstructorInfo cons = type.GetConstructor(new Type[] {});
                    interactor = (Interactor.Base)cons.Invoke(new object[] {});
                }
                if (node["LocSetter"] != null)
                {
                    string sType = "MusicGame.Midi.LocSetter." + node["LocSetter"].Text;
                    Type   type  = Type.GetType(sType);
                    System.Reflection.ConstructorInfo cons = type.GetConstructor(new Type[] {});
                    locSetter = (LocSetter.Base)cons.Invoke(new object[] {});
                }
            }

            if (interactor == null)
            {
                interactor = new Interactor.Default();
            }
//			if (locSetter==null)
//				locSetter = new LocSetter.Default();

            interactor.Prepare(tp.Track.Name, cm.MidiChannel, this._readAheadMsecs, note, strength, duration, ptLoc);
            if (locSetter != null)
            {
                locSetter.Parent = interactor;
            }

            this._spritesToStart.Add(interactor);
            return(interactor);
        }
Пример #5
0
 public void RemoveChild(Node oNode)
 {
     this.ChildNodes.RemoveValue(oNode);
 }
Пример #6
0
        public Node Load(string runmode, string config)
        {
            //a table for replacing #something# with a stored value (eg #exe# -> C:\docs\)
            System.Collections.Hashtable replacements = new System.Collections.Hashtable();
            replacements.Add("exe", EH.Instance.ApplicationDirectory);

            Node node = Node.FromTabbed(config);

            Node allNode = node["All"];
            node = node[runmode];
            if (node == null)
                node = new Node();

            if (allNode!=null)
                node.Merge(allNode);

            Node n = node;
            while(true)
            {
                n = n.NextSpecial;
                if (n==null)
                    break;
                if (n.Name.IndexOf("#") >= 0)
                {
                    System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(n.Name, @"\#\w+\#");
                    string sKey = m.Value.Substring(1,m.Value.Length-2);
                    string sValue = (string)replacements[sKey];
                    if (sValue!=null)
                    {
                        string sNewName = System.Text.RegularExpressions.Regex.Replace(n.Name, @"\#\w+\#", sValue);
                        n.Name = sNewName;
                    }
                }
                if (n.Name.IndexOf(@"..\") >= 0)
                {
                    int nFirst = n.Name.IndexOf(@"..\");
                    string sPath = n.Name.Remove(0,nFirst);

                    System.Text.RegularExpressions.MatchCollection ms = System.Text.RegularExpressions.Regex.Matches(
                        sPath, @"[.][.]\\");

                    sPath = sPath.Replace(@"..\", "");
                    System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(sPath);
                    for (int i=0; i<ms.Count;i++)
                        di = di.Parent;

                    n.Name = n.Name.Substring(0,nFirst) + di.FullName;
                }

                if (n.Name.IndexOf("=") >= 0)
                {
                    string[] sKV = n.Name.Split("=".ToCharArray());
                    replacements[sKV[0]] = sKV[1];
                }
            }

            //			string sTabbed = node.ToTabbed();
            //			sTabbed = sTabbed.Replace("\n", "\r\n");
            //			System.IO.StreamWriter wr = new System.IO.StreamWriter("Test.txt");
            //			wr.Write(sTabbed);
            //			wr.Flush();
            //			wr.Close();

            return node;
        }
Пример #7
0
        public void Merge(Node nodeToMergeWith)
        {
            for (int i = 0; i<nodeToMergeWith.ChildNodes.Count; i++)
            {
                Node node = (Node)nodeToMergeWith.ChildNodes.GetByIndex(i);

                //does it exist here already?
                Node alreadyHereNode = this[node.Name];
                if (alreadyHereNode == null)
                    alreadyHereNode = this.CreateChild(node.Name);

                if (node.HasChildNodes)
                    alreadyHereNode.Merge(node);
            }
        }
Пример #8
0
        public virtual Node CreateChild(string sName)
        {
            Node node = null;
            if (this._bAutoCreateChildIfNotExists)
                node = new Node(true);
            else
                node = new Node();

            this.AppendChild(sName, node);
            return node;
        }
Пример #9
0
 //        public void ReplaceChild(Node newChild, Node oldChild)
 //        {
 //            //TODO:
 //        }
 //        public void InsertAfter(Node newChild, Node refChild)
 //        {
 //        }
 //        public void InsertBefore(Node newChild, Node refChild)
 //        {
 //        }
 //        public void PrependChild(string sName, Node oNode)
 //        {
 //            //TODO: add as first child
 //        }
 public void AppendChild(string sName, Node oNode)
 {
     oNode.ParentNode = this;
     this.ChildNodes.Add(sName, oNode);
 }
Пример #10
0
        public static Node FromTabbed(string tabbed)
        {
            Node node = new Node();

            tabbed = tabbed.Replace("\r", "");
            string[] lines = tabbed.Split("\n".ToCharArray());

            System.Text.RegularExpressions.Match m;
            int nLastIndentation = -1;
            foreach (string sLine in lines)
            {
                if (sLine.Length == 0)
                    continue;
                m = System.Text.RegularExpressions.Regex.Match(sLine, @"[^\t]"); // "\S" non-whitespace chars
                if (m.Index == -1)
                    continue;
                int nIndentation = m.Index;

                if (nIndentation > nLastIndentation && nLastIndentation > -1)
                {
                    //one level down!
                    node = node.LastChild;
                }
                else if (nIndentation < nLastIndentation)
                {
                    //level up!
                    node = node.GetNthNodeAbove(nLastIndentation-nIndentation);
                }
                string sNode = sLine.Remove(0,m.Index).Trim();

                //check if there is a tab left (eg: name	item)
                //if so, the text after the tab is entered as the node.Value
                m = System.Text.RegularExpressions.Regex.Match(sNode, @"[\t]");
                string sValue = null;
                if (m.Success)
                {
                    sValue = sNode.Remove(0,m.Index+1);
                    sNode = sNode.Substring(0,m.Index);
                }

                Node subNode = node.CreateChild(sNode);
                subNode.Text = sValue;

                nLastIndentation = nIndentation;
            }

            return node.RootNode;
        }
Пример #11
0
        public Main()
        {
            _instance = this;

            this.FontGenerator = new Endogine.Text.FontGenerator();
            Endogine.Text.FontGenerator fg = this.FontGenerator;
            fg.UseStyleTemplate("Test1");
            fg.FontSize = 20;
            fg.DefinedCharacters = Endogine.Text.FontGenerator.GetCharSet(Endogine.Text.FontGenerator.CharSet.Default, false, false);

            this.Score = new Score();
            this.Score.FontGenerator = fg;
            this.Score.Value = 0;
            this.Score.Loc = new EPointF(30,30);

            //			Endogine.Forms.Label lbl = new Endogine.Forms.Label();
            //			lbl.FontGenerator = fg;
            //			lbl.Text = "AbrakadagvAsk49Å";
            //			lbl.Loc = new EPointF(100,100);

            this._scripter = ScriptingProvider.CreateScripter("boo");
            Hashtable htScripts = new Hashtable();
            htScripts.Add("Test", Endogine.Files.FileReadWrite.Read(Endogine.AppSettings.Instance.FindFile("test.boo")));
            this._interactorClassNames = new ArrayList();
            this._interactorClassNames.Add("Test");
            this._scripter.CompileMultiple(htScripts);

            //Hashtable htKeys = new Hashtable();
            //Endogine.KeysSteering _keys = new KeysSteering(htKeys);
            EH.Instance.KeyEvent+=new KeyEventHandler(Instance_KeyEvent);

            Node tracks = new Node();
            string sFile = "Muppet_Show";
            sFile = "Flourish";
            float fSpeed = 1f;
            switch (sFile)
            {
                case "Flourish":
                    tracks.GetOrCreate("Drums.Interactor").Text = "X";
                    tracks.GetOrCreate("Drums.LocSetter").Text = "Default";
                    tracks.GetOrCreate("Kalimba.Interactor").Text = "Shake";
                    tracks.GetOrCreate("Kalimba.LocSetter").Text = "Swirl";
                    tracks.GetOrCreate("Piano.Interactor").Text = "Default";
                    sFile = @"C:\WINDOWS\Media\"+sFile;
                    fSpeed = 0.8f;
                    break;
                case "Muppet_Show":
                    tracks.GetOrCreate("HONKY TONK PIAN.Interactor").Text = "X";
                    tracks.GetOrCreate("HONKY TONK PIAN.LocSetter").Text = "Default";
                    tracks.GetOrCreate("SAX.Interactor").Text = "Shake";
                    tracks.GetOrCreate("SAX.LocSetter").Text = "Swirl";
                    tracks.GetOrCreate("TUBA.Interactor").Text = "Default";
                    break;
            }

            this._factory = new InteractorFactory(tracks);
            this._factory.ReadAheadMsecs = this._readAheadMsecs;

            sFile = Endogine.AppSettings.Instance.FindFile(sFile+".mid");
            //sFile = @"C:\WINDOWS\Media\Flourish.MID"; //ONESTOP
            MidiFileReader reader = new MidiFileReader(sFile);

            OutputDevice output = new OutputDevice(0);
            output.Open(0);
            this._sequencer = new SequencerBase(null, output);
            this._sequencer.Sequence = reader.Sequence;

            this._sequencer.PlaybackSpeed = fSpeed;
            this._sequencer.Start();
            //			this._sequencer.Tempo = 40;

            Endogine.Midi.Devices.EmptyMidiSender midiSender = new Endogine.Midi.Devices.EmptyMidiSender();
            //ScreenOutputDevice midiSender = new ScreenOutputDevice(this.progressBar1);
            this._sequencerPre = new SequencerBase(null, midiSender);
            this._sequencerPre.Sequence = reader.Sequence;

            TrackPlayer tp;
            for (int i=0; i<tracks.ChildNodes.Count; i++)
            {
                tp = this._sequencerPre.Player.GetTrackPlayer(tracks[i].Name); //Drums
                tp.TrackMessage+=new Endogine.Midi.TrackPlayer.TrackMessageDelegate(tp_TrackMessage);
            }

            this._sequencerPre.Start();
            this._sequencerPre.Position = (int)(this._sequencer.PlaybackTempo*this._readAheadMsecs/1000*6); //PlaybackTempo
            this._sequencerPre.PlaybackSpeed = this._sequencer.PlaybackSpeed;
            this._sequencerPre.Tempo = this._sequencer.Tempo;
        }