diff --git a/Output/PartyModes/Challenge.xml b/Output/PartyModes/Challenge.xml
index cccb8168..50e404db 100644
--- a/Output/PartyModes/Challenge.xml
+++ b/Output/PartyModes/Challenge.xml
@@ -5,8 +5,11 @@
Challenge
brunzel
Challenge
- CPartyModeChallenge.cs
+ PartyModeChallenge
0
1
+
+ PartyScreenChallengeMain
+
\ No newline at end of file
diff --git a/Output/PartyModes/Challenge/Code/CPartyModeChallenge.cs b/Output/PartyModes/Challenge/Code/PartyModeChallenge.cs
similarity index 77%
rename from Output/PartyModes/Challenge/Code/CPartyModeChallenge.cs
rename to Output/PartyModes/Challenge/Code/PartyModeChallenge.cs
index f2780760..3f248848 100644
--- a/Output/PartyModes/Challenge/Code/CPartyModeChallenge.cs
+++ b/Output/PartyModes/Challenge/Code/PartyModeChallenge.cs
@@ -2,11 +2,13 @@ using System;
using System.Collections.Generic;
using System.Text;
+using Vocaluxe.Menu;
+
namespace Vocaluxe.PartyModes
{
- public class CPartyModeChallenge : CPartyMode
+ public class PartyModeChallenge : CPartyMode
{
- public CPartyModeChallenge()
+ public PartyModeChallenge()
{
_ScreenSongOptions.Selection.RandomOnly = false;
_ScreenSongOptions.Selection.PartyMode = false;
@@ -17,6 +19,13 @@ namespace Vocaluxe.PartyModes
_ScreenSongOptions.Sorting.SearchStringVisible = false;
}
+ public override CMenuParty GetNextPartyScreen()
+ {
+ CMenuParty Screen = null;
+ _Screens.TryGetValue("PartyScreenChallengeMain", out Screen);
+ return Screen;
+ }
+
public override ScreenSongOptions GetScreenSongOptions()
{
_ScreenSongOptions.Sorting.SongSorting = _Base.Config.GetSongSorting();
diff --git a/Output/PartyModes/Challenge/Code/PartyScreenChallengeMain.cs b/Output/PartyModes/Challenge/Code/PartyScreenChallengeMain.cs
new file mode 100644
index 00000000..37d0f8b6
--- /dev/null
+++ b/Output/PartyModes/Challenge/Code/PartyScreenChallengeMain.cs
@@ -0,0 +1,117 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+
+using Vocaluxe.Menu;
+
+namespace Vocaluxe.PartyModes
+{
+ public class PartyScreenChallengeMain : CMenuParty
+ {
+ // Version number for theme files. Increment it, if you've changed something on the theme files!
+ const int ScreenVersion = 1;
+ private CText Warning;
+
+ public PartyScreenChallengeMain()
+ {
+ }
+
+ protected override void Init()
+ {
+ base.Init();
+
+ _ThemeName = "PartyScreenChallengeMain";
+ _ScreenVersion = ScreenVersion;
+ }
+
+ public override void LoadTheme()
+ {
+ Warning = GetNewText();
+ Warning.Height = 100f;
+ Warning.X = 150;
+ Warning.Y = 300;
+ Warning.Fon = "Normal";
+ Warning.Style = EStyle.Normal;
+ Warning.Color = new SColorF(1f, 0f, 0f, 1f);
+ Warning.SColor = new SColorF(1f, 0f, 0f, 1f);
+ Warning.Text = "CHALLENGE!";
+ AddText(Warning);
+ }
+
+ public override void ReloadTheme()
+ {
+ }
+
+ public override void ReloadTextures()
+ {
+ }
+
+ public override void SaveTheme()
+ {
+ }
+
+ public override void UnloadTextures()
+ {
+ }
+
+ public override bool HandleInput(KeyEvent KeyEvent)
+ {
+ base.HandleInput(KeyEvent);
+
+ if (KeyEvent.KeyPressed)
+ {
+
+ }
+ else
+ {
+ switch (KeyEvent.Key)
+ {
+ case Keys.Back:
+ case Keys.Escape:
+ FadeTo(EScreens.ScreenParty);
+ break;
+ }
+ }
+ return true;
+ }
+
+ public override bool HandleMouse(MouseEvent MouseEvent)
+ {
+ base.HandleMouse(MouseEvent);
+
+ if (MouseEvent.LB && IsMouseOver(MouseEvent))
+ {
+
+ }
+
+ if (MouseEvent.RB)
+ {
+ FadeTo(EScreens.ScreenParty);
+ }
+
+ return true;
+ }
+
+ public override void OnShow()
+ {
+ base.OnShow();
+ }
+
+ public override bool UpdateGame()
+ {
+ return true;
+ }
+
+ public override bool Draw()
+ {
+ base.Draw();
+ return true;
+ }
+
+ public override void OnClose()
+ {
+ base.OnClose();
+ }
+ }
+}
diff --git a/Vocaluxe/Base/CParty.cs b/Vocaluxe/Base/CParty.cs
index 3f6d5ae9..03b1319b 100644
--- a/Vocaluxe/Base/CParty.cs
+++ b/Vocaluxe/Base/CParty.cs
@@ -15,11 +15,13 @@ namespace Vocaluxe.Base
#region Structs
struct SPartyMode
{
+ public int PartyModeID;
public int PartyModeSystemVersion;
public string Name;
public string Author;
public string Folder;
public string PartyModeFile;
+ public List ScreenFiles;
public int PartyModeVersionMajor;
public int PartyModeVersionMinor;
public bool NoErrors;
@@ -33,37 +35,41 @@ namespace Vocaluxe.Base
const int PartyModeSystemVersion = 1;
private static CHelper Helper;
- private static List _PartyModes;
+ private static Dictionary _PartyModes;
+ private static Queue _IDs;
+
+ private static int _NormalGameModeID;
+ private static SPartyMode _CurrentPartyMode;
- private static int _CurrentModeNr;
public static int CurrentPartyModeID
{
- get
- {
- if (_CurrentModeNr == 0)
- return -1;
-
- return _CurrentModeNr - 1;
- }
+ get { return _CurrentPartyMode.PartyModeID; }
}
#region public stuff
public static int NumModes
{
- get { return _PartyModes.Count - 1; } //first mode is the dummy normal game mode
+ get { return 0 ; } //first mode is the dummy normal game mode
}
public static void Init()
{
Helper = new CHelper();
- _PartyModes = new List();
+ _PartyModes = new Dictionary();
+ _IDs = new Queue(1000);
+
+ for (int i = 0; i < 1000; i++)
+ _IDs.Enqueue(i);
//add dummy normal game mode and set it as default
SPartyMode pm = new SPartyMode();
pm.PartyMode = new CPartyModeNone();
+ pm.ScreenFiles = new List();
pm.PartyMode.Initialize(CMain.Base);
- _PartyModes.Add(pm);
- _CurrentModeNr = 0;
+ pm.PartyModeID = _IDs.Dequeue();
+ _NormalGameModeID = pm.PartyModeID;
+ _PartyModes.Add(pm.PartyModeID, pm);
+ _CurrentPartyMode = pm;
//load other party modes
LoadPartyModes();
@@ -71,12 +77,18 @@ namespace Vocaluxe.Base
public static void SetNormalGameMode()
{
- _CurrentModeNr = 0;
+ SetPartyMode(_NormalGameModeID);
+ }
+
+ public static void SetPartyMode(int PartyModeID)
+ {
+ if (!_PartyModes.TryGetValue(PartyModeID, out _CurrentPartyMode))
+ CLog.LogError("CParty: Can't find party mode ID: " + PartyModeID.ToString());
}
public static CMenu GetNextPartyScreen()
{
- CMenu NextScreen = _PartyModes[_CurrentModeNr].PartyMode.GetNextPartyScreen();
+ CMenu NextScreen = _CurrentPartyMode.PartyMode.GetNextPartyScreen();
if (NextScreen != null)
return NextScreen;
@@ -90,27 +102,27 @@ namespace Vocaluxe.Base
#region Interface
public static EScreens GetStartScreen()
{
- return _PartyModes[_CurrentModeNr].PartyMode.GetStartScreen();
+ return _CurrentPartyMode.PartyMode.GetStartScreen();
}
public static EScreens GetMainScreen()
{
- return _PartyModes[_CurrentModeNr].PartyMode.GetMainScreen();
+ return _CurrentPartyMode.PartyMode.GetMainScreen();
}
public static ScreenSongOptions GetSongSelectionOptions()
{
- return _PartyModes[_CurrentModeNr].PartyMode.GetScreenSongOptions();
+ return _CurrentPartyMode.PartyMode.GetScreenSongOptions();
}
public static void SetSearchString(string SearchString, bool Visible)
{
- _PartyModes[_CurrentModeNr].PartyMode.SetSearchString(SearchString, Visible);
+ _CurrentPartyMode.PartyMode.SetSearchString(SearchString, Visible);
}
public static void JokerUsed(int TeamNr)
{
- _PartyModes[_CurrentModeNr].PartyMode.JokerUsed(TeamNr);
+ _CurrentPartyMode.PartyMode.JokerUsed(TeamNr);
}
#endregion Interface
@@ -122,13 +134,16 @@ namespace Vocaluxe.Base
foreach (string file in files)
{
- _PartyModes.Add(LoadPartyMode(file));
+ SPartyMode pm = LoadPartyMode(file);
+ pm.PartyModeID = _IDs.Dequeue();
+ _PartyModes.Add(pm.PartyModeID, pm);
}
}
private static SPartyMode LoadPartyMode(string file)
{
SPartyMode pm = new SPartyMode();
+ pm.ScreenFiles = new List();
pm.NoErrors = false;
bool loaded = false;
@@ -160,6 +175,7 @@ namespace Vocaluxe.Base
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/PartyModeFile", navigator, ref pm.PartyModeFile, "ERROR PartyModeFile");
+ loaded &= CHelper.GetInnerValuesFromXML("PartyScreens", navigator, ref pm.ScreenFiles);
loaded &= CHelper.TryGetIntValueFromXML("//root/Info/PartyModeVersionMajor", navigator, ref pm.PartyModeVersionMajor);
loaded &= CHelper.TryGetIntValueFromXML("//root/Info/PartyModeVersionMinor", navigator, ref pm.PartyModeVersionMinor);
@@ -168,6 +184,12 @@ namespace Vocaluxe.Base
CLog.LogError("Error loading PartyMode file (wrong PartyModeSystemVersion): " + file);
return pm;
}
+
+ if (pm.ScreenFiles.Count == 0)
+ {
+ CLog.LogError("Error loading PartyMode file (no ScreenFiles found): " + file);
+ return pm;
+ }
}
if (!loaded)
@@ -176,8 +198,12 @@ namespace Vocaluxe.Base
return pm;
}
+ string PathToCode = Path.Combine(Path.Combine(CSettings.sFolderPartyModes, pm.Folder), CSettings.sFolderPartyModeCode);
- Assembly Output = CompileFile(Path.Combine(Path.Combine(Path.Combine(CSettings.sFolderPartyModes, pm.Folder), CSettings.sFolderPartyModeCode), pm.PartyModeFile + ".cs"));
+ List FilesToCompile = new List();
+ FilesToCompile.AddRange(Helper.ListFiles(PathToCode, "*.cs", false, true));
+
+ Assembly Output = CompileFiles(FilesToCompile.ToArray());
if (Output == null)
return pm;
@@ -197,15 +223,31 @@ namespace Vocaluxe.Base
CLog.LogError("Error casting PartyMode file: " + file + "; " + e.Message);
return pm;
}
-
pm.PartyMode.Initialize(CMain.Base);
+
+ foreach (string screenfile in pm.ScreenFiles)
+ {
+ CMenuParty Screen = GetPartyScreenInstance(Output, screenfile);
+ if (Screen != null)
+ pm.PartyMode.AddScreen(Screen, screenfile);
+ else
+ return pm;
+ }
+
pm.NoErrors = true;
return pm;
}
- private static Assembly CompileFile(string file)
+ private static Assembly CompileFiles(string[] files)
{
+ if (files == null)
+ return null;
+
+ if (files.Length == 0)
+ return null;
+
CompilerParameters Params = new CompilerParameters();
+ Params.ReferencedAssemblies.Add("System.Windows.Forms.dll");
Params.ReferencedAssemblies.Add("VocaluxeLib.dll");
Params.GenerateInMemory = true;
#if DEBUG
@@ -214,13 +256,14 @@ namespace Vocaluxe.Base
CodeDomProvider CDP = CodeDomProvider.CreateProvider("CSharp");
CompilerResults CompileResult = null;
+
try
{
- CompileResult = CDP.CompileAssemblyFromFile(Params, file);
+ CompileResult = CDP.CompileAssemblyFromFile(Params, files);
}
catch (Exception e)
{
- CLog.LogError("Error Compiling Source (" + file + "): " + e.Message);
+ CLog.LogError("Error Compiling Source (" + CHelper.ListStrings(files) + "): " + e.Message);
return null;
}
@@ -228,13 +271,39 @@ namespace Vocaluxe.Base
{
for (int i = 0; i < CompileResult.Errors.Count; i++)
{
- CLog.LogError("Error Compiling Source (" + file + "): " + CompileResult.Errors[i].ErrorText);
+ CLog.LogError("Error Compiling Source (" + CHelper.ListStrings(files) + "): " + CompileResult.Errors[i].ErrorText);
}
return null;
}
return CompileResult.CompiledAssembly;
}
+ private static CMenuParty GetPartyScreenInstance(Assembly Assembly, string ScreenName)
+ {
+ if (Assembly == null)
+ return null;
+
+ object Instance = Assembly.CreateInstance("Vocaluxe.PartyModes." + ScreenName);
+ if (Instance == null)
+ {
+ CLog.LogError("Error creating Instance of PartyScreen: " + ScreenName);
+ return null;
+ }
+
+ CMenuParty Screen = null;
+ try
+ {
+ Screen = (CMenuParty)Instance;
+ }
+ catch (Exception e)
+ {
+ CLog.LogError("Error casting PartyScreen: " + ScreenName + "; " + e.Message);
+ return null;
+ }
+ Screen.Initialize(CMain.Base);
+ Screen.LoadTheme();
+ return Screen;
+ }
#endregion private stuff
}
}
diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs
index af45f0ae..15e5f24d 100644
--- a/Vocaluxe/Base/CSettings.cs
+++ b/Vocaluxe/Base/CSettings.cs
@@ -94,6 +94,7 @@ namespace Vocaluxe.Base
public static string sFolderPartyModes = "PartyModes";
public const string sFolderPartyModeCode = "Code";
+ public const string sFolderPartyModeScreens = "Screens";
//public const String[] ToneStrings = new String[]{ "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
public const int ToneMin = -36;
diff --git a/Vocaluxe/Screens/CScreenParty.cs b/Vocaluxe/Screens/CScreenParty.cs
index 57a5a9ed..18fea19f 100644
--- a/Vocaluxe/Screens/CScreenParty.cs
+++ b/Vocaluxe/Screens/CScreenParty.cs
@@ -50,6 +50,7 @@ namespace Vocaluxe.Screens
break;
case Keys.C:
+ CParty.SetPartyMode(1);
CGraphics.FadeTo(EScreens.ScreenPartyDummy);
break;
diff --git a/VocaluxeLib/Menu/CHelper.cs b/VocaluxeLib/Menu/CHelper.cs
index fd9ac254..815e941f 100644
--- a/VocaluxeLib/Menu/CHelper.cs
+++ b/VocaluxeLib/Menu/CHelper.cs
@@ -207,6 +207,32 @@ namespace Vocaluxe.Menu
return values;
}
+ public static bool GetInnerValuesFromXML(string Cast, XPathNavigator Navigator, ref List Values)
+ {
+ try
+ {
+ Navigator.MoveToRoot();
+ Navigator.MoveToFirstChild();
+ Navigator.MoveToFirstChild();
+
+ while (Navigator.Name != Cast)
+ Navigator.MoveToNext();
+
+ Navigator.MoveToFirstChild();
+
+ Values.Add(Navigator.Value);
+ while (Navigator.MoveToNext())
+ Values.Add(Navigator.Value);
+
+ }
+ catch
+ {
+ return false;
+ }
+
+ return true;
+ }
+
public static bool ItemExistsInXML(string Cast, XPathNavigator Navigator)
{
XPathNodeIterator iterator;
diff --git a/VocaluxeLib/Menu/CMenuParty.cs b/VocaluxeLib/Menu/CMenuParty.cs
index 11131172..951503ff 100644
--- a/VocaluxeLib/Menu/CMenuParty.cs
+++ b/VocaluxeLib/Menu/CMenuParty.cs
@@ -4,7 +4,7 @@ using System.Text;
namespace Vocaluxe.Menu
{
- abstract class CMenuParty : CMenu
+ public abstract class CMenuParty : CMenu
{
public CMenuParty()
{
diff --git a/VocaluxeLib/PartyModes/CPartyMode.cs b/VocaluxeLib/PartyModes/CPartyMode.cs
index cf5809a4..fd95f35d 100644
--- a/VocaluxeLib/PartyModes/CPartyMode.cs
+++ b/VocaluxeLib/PartyModes/CPartyMode.cs
@@ -10,30 +10,35 @@ namespace Vocaluxe.PartyModes
{
protected Basic _Base;
protected ScreenSongOptions _ScreenSongOptions;
- protected List _Screens;
+ protected Dictionary _Screens;
protected string _Folder;
public CPartyMode()
{
- _Screens = new List();
+ _Screens = new Dictionary();
_Folder = String.Empty;
_ScreenSongOptions = new ScreenSongOptions();
_ScreenSongOptions.Selection = new SelectionOptions();
_ScreenSongOptions.Sorting = new SortingOptions();
}
- public void Initialize(Basic Base)
- {
- _Base = Base;
- }
-
#region Implementation
public virtual bool Init(string Folder)
{
return false;
}
- public virtual CMenu GetNextPartyScreen()
+ public void Initialize(Basic Base)
+ {
+ _Base = Base;
+ }
+
+ public void AddScreen(CMenuParty Screen, string ScreenName)
+ {
+ _Screens.Add(ScreenName, Screen);
+ }
+
+ public virtual CMenuParty GetNextPartyScreen()
{
return null;
}
diff --git a/VocaluxeLib/PartyModes/CPartyModeNone.cs b/VocaluxeLib/PartyModes/CPartyModeNone.cs
index d40523a5..37c1c2a1 100644
--- a/VocaluxeLib/PartyModes/CPartyModeNone.cs
+++ b/VocaluxeLib/PartyModes/CPartyModeNone.cs
@@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Text;
+using Vocaluxe.Menu;
+
namespace Vocaluxe.PartyModes
{
public class CPartyModeNone : CPartyMode
diff --git a/VocaluxeLib/PartyModes/CScreenPartyDummy.cs b/VocaluxeLib/PartyModes/CScreenPartyDummy.cs
index 407d15b3..cbe0da24 100644
--- a/VocaluxeLib/PartyModes/CScreenPartyDummy.cs
+++ b/VocaluxeLib/PartyModes/CScreenPartyDummy.cs
@@ -7,7 +7,7 @@ using Vocaluxe.Menu;
namespace Vocaluxe.PartyModes
{
- public class CScreenPartyDummy : CMenu
+ public class CScreenPartyDummy : CMenuParty
{
// Version number for theme files. Increment it, if you've changed something on the theme files!
const int ScreenVersion = 1;
diff --git a/VocaluxeLib/PartyModes/IPartyMode.cs b/VocaluxeLib/PartyModes/IPartyMode.cs
index f05de2eb..c583340c 100644
--- a/VocaluxeLib/PartyModes/IPartyMode.cs
+++ b/VocaluxeLib/PartyModes/IPartyMode.cs
@@ -53,8 +53,9 @@ namespace Vocaluxe.PartyModes
{
bool Init(string Folder);
void Initialize(Basic Base);
+ void AddScreen(CMenuParty Screen, string ScreenName);
- CMenu GetNextPartyScreen();
+ CMenuParty GetNextPartyScreen();
EScreens GetStartScreen();
EScreens GetMainScreen();
ScreenSongOptions GetScreenSongOptions();