added challenge main screen (just testing)
This commit is contained in:
1 parent
fb4c7de142
commit
41f8f9ce72
12 files changed
+275
-41
No files matched your search
@@ -5,8 +5,11 @@
|
||||
<Name>Challenge</Name>
|
||||
<Author>brunzel</Author>
|
||||
<Folder>Challenge</Folder>
|
||||
<PartyModeFile>CPartyModeChallenge.cs</PartyModeFile>
|
||||
<PartyModeFile>PartyModeChallenge</PartyModeFile>
|
||||
<PartyModeVersionMajor>0</PartyModeVersionMajor>
|
||||
<PartyModeVersionMinor>1</PartyModeVersionMinor>
|
||||
</Info>
|
||||
<PartyScreens>
|
||||
<ScreenFile>PartyScreenChallengeMain</ScreenFile>
|
||||
</PartyScreens>
|
||||
</root>
|
||||
+11
-2
@@ -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();
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
+96
-27
@@ -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<string> 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<SPartyMode> _PartyModes;
|
||||
private static Dictionary<int, SPartyMode> _PartyModes;
|
||||
private static Queue<int> _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<SPartyMode>();
|
||||
_PartyModes = new Dictionary<int, SPartyMode>();
|
||||
_IDs = new Queue<int>(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<string>();
|
||||
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<string>();
|
||||
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<string> FilesToCompile = new List<string>();
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace Vocaluxe.Screens
|
||||
break;
|
||||
|
||||
case Keys.C:
|
||||
CParty.SetPartyMode(1);
|
||||
CGraphics.FadeTo(EScreens.ScreenPartyDummy);
|
||||
break;
|
||||
|
||||
|
||||
@@ -207,6 +207,32 @@ namespace Vocaluxe.Menu
|
||||
return values;
|
||||
}
|
||||
|
||||
public static bool GetInnerValuesFromXML(string Cast, XPathNavigator Navigator, ref List<string> 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;
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Text;
|
||||
|
||||
namespace Vocaluxe.Menu
|
||||
{
|
||||
abstract class CMenuParty : CMenu
|
||||
public abstract class CMenuParty : CMenu
|
||||
{
|
||||
public CMenuParty()
|
||||
{
|
||||
|
||||
@@ -10,30 +10,35 @@ namespace Vocaluxe.PartyModes
|
||||
{
|
||||
protected Basic _Base;
|
||||
protected ScreenSongOptions _ScreenSongOptions;
|
||||
protected List<CMenu> _Screens;
|
||||
protected Dictionary<string, CMenuParty> _Screens;
|
||||
protected string _Folder;
|
||||
|
||||
public CPartyMode()
|
||||
{
|
||||
_Screens = new List<CMenu>();
|
||||
_Screens = new Dictionary<string, CMenuParty>();
|
||||
_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;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Vocaluxe.Menu;
|
||||
|
||||
namespace Vocaluxe.PartyModes
|
||||
{
|
||||
public class CPartyModeNone : CPartyMode
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user