fixed party mode xml reading, added compiler code, added challenge game mode files (just a first test)
This commit is contained in:
1 parent
d6c97568c9
commit
fb4c7de142
4 files changed
+114
-3
No files matched your search
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<PartyModeSystemVersion>1</PartyModeSystemVersion>
|
||||||
|
<Info>
|
||||||
|
<Name>Challenge</Name>
|
||||||
|
<Author>brunzel</Author>
|
||||||
|
<Folder>Challenge</Folder>
|
||||||
|
<PartyModeFile>CPartyModeChallenge.cs</PartyModeFile>
|
||||||
|
<PartyModeVersionMajor>0</PartyModeVersionMajor>
|
||||||
|
<PartyModeVersionMinor>1</PartyModeVersionMinor>
|
||||||
|
</Info>
|
||||||
|
</root>
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Vocaluxe.PartyModes
|
||||||
|
{
|
||||||
|
public class CPartyModeChallenge : CPartyMode
|
||||||
|
{
|
||||||
|
public CPartyModeChallenge()
|
||||||
|
{
|
||||||
|
_ScreenSongOptions.Selection.RandomOnly = false;
|
||||||
|
_ScreenSongOptions.Selection.PartyMode = false;
|
||||||
|
_ScreenSongOptions.Selection.CategoryChangeAllowed = true;
|
||||||
|
_ScreenSongOptions.Selection.NumJokers = null;
|
||||||
|
|
||||||
|
_ScreenSongOptions.Sorting.SearchString = String.Empty;
|
||||||
|
_ScreenSongOptions.Sorting.SearchStringVisible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override ScreenSongOptions GetScreenSongOptions()
|
||||||
|
{
|
||||||
|
_ScreenSongOptions.Sorting.SongSorting = _Base.Config.GetSongSorting();
|
||||||
|
_ScreenSongOptions.Sorting.Tabs = _Base.Config.GetTabs();
|
||||||
|
_ScreenSongOptions.Sorting.IgnoreArticles = _Base.Config.GetIgnoreArticles();
|
||||||
|
|
||||||
|
return _ScreenSongOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetSearchString(string SearchString, bool Visible)
|
||||||
|
{
|
||||||
|
_ScreenSongOptions.Sorting.SearchString = SearchString;
|
||||||
|
_ScreenSongOptions.Sorting.SearchStringVisible = Visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+63
-3
@@ -1,5 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.CodeDom.Compiler;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Xml.XPath;
|
using System.Xml.XPath;
|
||||||
@@ -16,6 +19,7 @@ namespace Vocaluxe.Base
|
|||||||
public string Name;
|
public string Name;
|
||||||
public string Author;
|
public string Author;
|
||||||
public string Folder;
|
public string Folder;
|
||||||
|
public string PartyModeFile;
|
||||||
public int PartyModeVersionMajor;
|
public int PartyModeVersionMajor;
|
||||||
public int PartyModeVersionMinor;
|
public int PartyModeVersionMinor;
|
||||||
public bool NoErrors;
|
public bool NoErrors;
|
||||||
@@ -151,12 +155,13 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
if (loaded)
|
if (loaded)
|
||||||
{
|
{
|
||||||
loaded &= CHelper.TryGetIntValueFromXML("//root/Info/PartyModeSystemVersion", navigator, ref pm.PartyModeSystemVersion);
|
loaded &= CHelper.TryGetIntValueFromXML("//root/PartyModeSystemVersion", navigator, ref pm.PartyModeSystemVersion);
|
||||||
loaded &= CHelper.GetValueFromXML("//root/Info/Name", navigator, ref pm.Name, "ERROR Name");
|
loaded &= CHelper.GetValueFromXML("//root/Info/Name", navigator, ref pm.Name, "ERROR Name");
|
||||||
loaded &= CHelper.GetValueFromXML("//root/Info/Author", navigator, ref pm.Author, "ERROR Author");
|
loaded &= CHelper.GetValueFromXML("//root/Info/Author", navigator, ref pm.Author, "ERROR Author");
|
||||||
loaded &= CHelper.GetValueFromXML("//root/Info/Folder", navigator, ref pm.Folder, "ERROR Folder");
|
loaded &= CHelper.GetValueFromXML("//root/Info/Folder", navigator, ref pm.Folder, "ERROR Folder");
|
||||||
loaded &= CHelper.TryGetIntValueFromXML("//root/Info/PartyModeSystemVersion", navigator, ref pm.PartyModeVersionMajor);
|
loaded &= CHelper.GetValueFromXML("//root/Info/PartyModeFile", navigator, ref pm.PartyModeFile, "ERROR PartyModeFile");
|
||||||
loaded &= CHelper.TryGetIntValueFromXML("//root/Info/PartyModeSystemVersion", navigator, ref pm.PartyModeVersionMinor);
|
loaded &= CHelper.TryGetIntValueFromXML("//root/Info/PartyModeVersionMajor", navigator, ref pm.PartyModeVersionMajor);
|
||||||
|
loaded &= CHelper.TryGetIntValueFromXML("//root/Info/PartyModeVersionMinor", navigator, ref pm.PartyModeVersionMinor);
|
||||||
|
|
||||||
if (pm.PartyModeSystemVersion != PartyModeSystemVersion)
|
if (pm.PartyModeSystemVersion != PartyModeSystemVersion)
|
||||||
{
|
{
|
||||||
@@ -172,9 +177,64 @@ namespace Vocaluxe.Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Assembly Output = CompileFile(Path.Combine(Path.Combine(Path.Combine(CSettings.sFolderPartyModes, pm.Folder), CSettings.sFolderPartyModeCode), pm.PartyModeFile + ".cs"));
|
||||||
|
if (Output == null)
|
||||||
|
return pm;
|
||||||
|
|
||||||
|
object Instance = Output.CreateInstance("Vocaluxe.PartyModes." + pm.PartyModeFile);
|
||||||
|
if (Instance == null)
|
||||||
|
{
|
||||||
|
CLog.LogError("Error creating Instance of PartyMode file: " + file);
|
||||||
|
return pm;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pm.PartyMode = (IPartyMode)Instance;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
CLog.LogError("Error casting PartyMode file: " + file + "; " + e.Message);
|
||||||
|
return pm;
|
||||||
|
}
|
||||||
|
|
||||||
|
pm.PartyMode.Initialize(CMain.Base);
|
||||||
|
pm.NoErrors = true;
|
||||||
return pm;
|
return pm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Assembly CompileFile(string file)
|
||||||
|
{
|
||||||
|
CompilerParameters Params = new CompilerParameters();
|
||||||
|
Params.ReferencedAssemblies.Add("VocaluxeLib.dll");
|
||||||
|
Params.GenerateInMemory = true;
|
||||||
|
#if DEBUG
|
||||||
|
Params.IncludeDebugInformation = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
CodeDomProvider CDP = CodeDomProvider.CreateProvider("CSharp");
|
||||||
|
CompilerResults CompileResult = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CompileResult = CDP.CompileAssemblyFromFile(Params, file);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
CLog.LogError("Error Compiling Source (" + file + "): " + e.Message);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CompileResult.Errors.Count > 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < CompileResult.Errors.Count; i++)
|
||||||
|
{
|
||||||
|
CLog.LogError("Error Compiling Source (" + file + "): " + CompileResult.Errors[i].ErrorText);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return CompileResult.CompiledAssembly;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion private stuff
|
#endregion private stuff
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,10 @@ namespace Vocaluxe.Base
|
|||||||
public const string sFolderScreenshots = "Screenshots";
|
public const string sFolderScreenshots = "Screenshots";
|
||||||
public const string sFolderBackgroundMusic = "BackgroundMusic";
|
public const string sFolderBackgroundMusic = "BackgroundMusic";
|
||||||
public static string sFolderPlaylists = "Playlists";
|
public static string sFolderPlaylists = "Playlists";
|
||||||
|
|
||||||
|
|
||||||
public static string sFolderPartyModes = "PartyModes";
|
public static string sFolderPartyModes = "PartyModes";
|
||||||
|
public const string sFolderPartyModeCode = "Code";
|
||||||
|
|
||||||
//public const String[] ToneStrings = new String[]{ "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
|
//public const String[] ToneStrings = new String[]{ "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
|
||||||
public const int ToneMin = -36;
|
public const int ToneMin = -36;
|
||||||
|
|||||||
Reference in new issue
Block a user