From: <che...@us...> - 2007-05-27 01:40:17
|
Revision: 460 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=460&view=rev Author: chef_koch Date: 2007-05-26 18:40:14 -0700 (Sat, 26 May 2007) Log Message: ----------- Added Paths: ----------- trunk/plugins/My Hexxagon/Source/MyHexxagon/LocalizeStrings.cs trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon.cs trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon.csproj trunk/plugins/My Hexxagon/Source/MyHexxagon/Properties/ trunk/plugins/My Hexxagon/Source/MyHexxagon/hexxagon.png trunk/plugins/My Hexxagon/Source/MyHexxagon/hexxagonDisabled.png trunk/plugins/My Hexxagon/Source/MyHexxagon.sln Removed Paths: ------------- trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon/LocalizeStrings.cs trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon/MyHexxagon.cs trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon/MyHexxagon.csproj trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon/Properties/ trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon/hexxagon.png trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon/hexxagonDisabled.png trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon.sln Copied: trunk/plugins/My Hexxagon/Source/MyHexxagon/LocalizeStrings.cs (from rev 459, trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon/LocalizeStrings.cs) =================================================================== --- trunk/plugins/My Hexxagon/Source/MyHexxagon/LocalizeStrings.cs (rev 0) +++ trunk/plugins/My Hexxagon/Source/MyHexxagon/LocalizeStrings.cs 2007-05-27 01:40:14 UTC (rev 460) @@ -0,0 +1,260 @@ +#region Copyright (C) 2005-2007 Team MediaPortal + +/* + * Copyright (C) 2005-2007 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#endregion + +using System; +using System.IO; +using System.Globalization; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using System.Xml; +using MediaPortal.Util; +using MediaPortal.GUI.Library; +using MediaPortal.Configuration; +using MediaPortal.Localisation; + +namespace MediaPortal.GUI.MyHexxagon +{ + /// <summary> + /// This class will hold all text used in the application + /// The text is loaded for the current language from + /// the file language/[language]/strings.xml + /// </summary> + public class GUILocalizeStrings + { + #region Variables + static LocalisationProvider _stringProvider; + static Dictionary<string, string> _cultures; + static string[] _languages; + #endregion + + #region Constructors/Destructors + // singleton. Dont allow any instance of this class + private GUILocalizeStrings() + { + } + + static public void Dispose() + { + if (_stringProvider != null) + _stringProvider.Dispose(); + } + #endregion + + #region Public Methods + /// <summary> + /// Public method to load the text from a strings/xml file into memory + /// </summary> + /// <param name="strFileName">Contains the filename+path for the string.xml file</param> + /// <returns> + /// true when text is loaded + /// false when it was unable to load the text + /// </returns> + //[Obsolete("This method has changed", true)] + static public bool Load(string language) + { + bool isPrefixEnabled = true; + + using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) + isPrefixEnabled = reader.GetValueAsBool("general", "myprefix", true); + + string directory = Config.GetSubFolder(Config.Dir.Language, "MyHexxagon"); + string cultureName = null; + if (language != null) + cultureName = GetCultureName(language); + + Log.Info(" Loading localised Strings - Path: {0} Culture: {1} Language: {2} Prefix: {3}", directory, cultureName, language, isPrefixEnabled); + + _stringProvider = new LocalisationProvider(directory, cultureName, isPrefixEnabled); + + GUIGraphicsContext.CharsInCharacterSet = _stringProvider.Characters; + + return true; + } + + static public string CurrentLanguage() + { + if (_stringProvider == null) + Load(null); + + return _stringProvider.CurrentLanguage.EnglishName; + } + + static public void ChangeLanguage(string language) + { + if (_stringProvider == null) + Load(language); + else + _stringProvider.ChangeLanguage(GetCultureName(language)); + } + + /// <summary> + /// Get the translation for a given id and format the sting with + /// the given parameters + /// </summary> + /// <param name="dwCode">id of text</param> + /// <param name="parameters">parameters used in the formating</param> + /// <returns> + /// string containing the translated text + /// </returns> + static public string Get(int dwCode, object[] parameters) + { + if (_stringProvider == null) + Load(null); + + string translation = _stringProvider.GetString("unmapped", dwCode); + // if parameters or the translation is null, return the translation. + if ((translation == null) || (parameters == null)) + { + return translation; + } + // return the formatted string. If formatting fails, log the error + // and return the unformatted string. + try + { + return String.Format(translation, parameters); + } + catch (System.FormatException e) + { + Log.Error("Error formatting translation with id {0}", dwCode); + Log.Error("Unformatted translation: {0}", translation); + Log.Error(e); + return translation; + } + } + + /// <summary> + /// Get the translation for a given id + /// </summary> + /// <param name="dwCode">id of text</param> + /// <returns> + /// string containing the translated text + /// </returns> + static public string Get(int dwCode) + { + if (_stringProvider == null) + Load(null); + + string translation = _stringProvider.GetString("unmapped", dwCode); + + if (translation == null) + { + Log.Error("No translation found for id {0}", dwCode); + return String.Empty; + } + + return translation; + } + + static public void LocalizeLabel(ref string strLabel) + { + if (_stringProvider == null) + Load(null); + + if (strLabel == null) strLabel = String.Empty; + if (strLabel == "-") strLabel = ""; + if (strLabel == "") return; + // This can't be a valid string code if the first character isn't a number. + // This check will save us from catching unnecessary exceptions. + if (!char.IsNumber(strLabel, 0)) + return; + + int dwLabelID; + + try + { + dwLabelID = System.Int32.Parse(strLabel); + } + catch (FormatException e) + { + Log.Error(e); + strLabel = String.Empty; + return; + } + + strLabel = _stringProvider.GetString("unmapped", dwLabelID); + if (strLabel == null) + { + Log.Error("No translation found for id {0}", dwLabelID); + strLabel = String.Empty; + } + } + + public static string LocalSupported() + { + if (_stringProvider == null) + Load(null); + + CultureInfo culture = _stringProvider.GetBestLanguage(); + + return culture.EnglishName; + } + + public static string[] SupportedLanguages() + { + if (_languages == null) + { + if (_stringProvider == null) + Load(null); + + CultureInfo[] cultures = _stringProvider.AvailableLanguages(); + + SortedList sortedLanguages = new SortedList(); + foreach (CultureInfo culture in cultures) + sortedLanguages.Add(culture.EnglishName, culture.EnglishName); + + _languages = new string[sortedLanguages.Count]; + + for (int i = 0; i < sortedLanguages.Count; i++) + { + _languages[i] = (string)sortedLanguages.GetByIndex(i); + } + } + + return _languages; + } + + static public string GetCultureName(string language) + { + if (_cultures == null) + { + _cultures = new Dictionary<string, string>(); + + CultureInfo[] cultureList = CultureInfo.GetCultures(CultureTypes.AllCultures); + + for (int i = 0; i < cultureList.Length; i++) + { + _cultures.Add(cultureList[i].EnglishName, cultureList[i].Name); + } + } + + if (_cultures.ContainsKey(language)) + return _cultures[language]; + + return null; + } + #endregion + } +} \ No newline at end of file Deleted: trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon/LocalizeStrings.cs =================================================================== --- trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon/LocalizeStrings.cs 2007-05-27 01:22:43 UTC (rev 459) +++ trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon/LocalizeStrings.cs 2007-05-27 01:40:14 UTC (rev 460) @@ -1,260 +0,0 @@ -#region Copyright (C) 2005-2007 Team MediaPortal - -/* - * Copyright (C) 2005-2007 Team MediaPortal - * http://www.team-mediaportal.com - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -#endregion - -using System; -using System.IO; -using System.Globalization; -using System.Collections; -using System.Collections.Generic; -using System.Text; -using System.Xml; -using MediaPortal.Util; -using MediaPortal.GUI.Library; -using MediaPortal.Configuration; -using MediaPortal.Localisation; - -namespace MediaPortal.GUI.MyHexxagon -{ - /// <summary> - /// This class will hold all text used in the application - /// The text is loaded for the current language from - /// the file language/[language]/strings.xml - /// </summary> - public class GUILocalizeStrings - { - #region Variables - static LocalisationProvider _stringProvider; - static Dictionary<string, string> _cultures; - static string[] _languages; - #endregion - - #region Constructors/Destructors - // singleton. Dont allow any instance of this class - private GUILocalizeStrings() - { - } - - static public void Dispose() - { - if (_stringProvider != null) - _stringProvider.Dispose(); - } - #endregion - - #region Public Methods - /// <summary> - /// Public method to load the text from a strings/xml file into memory - /// </summary> - /// <param name="strFileName">Contains the filename+path for the string.xml file</param> - /// <returns> - /// true when text is loaded - /// false when it was unable to load the text - /// </returns> - //[Obsolete("This method has changed", true)] - static public bool Load(string language) - { - bool isPrefixEnabled = true; - - using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) - isPrefixEnabled = reader.GetValueAsBool("general", "myprefix", true); - - string directory = Config.GetSubFolder(Config.Dir.Language, "MyHexxagon"); - string cultureName = null; - if (language != null) - cultureName = GetCultureName(language); - - Log.Info(" Loading localised Strings - Path: {0} Culture: {1} Language: {2} Prefix: {3}", directory, cultureName, language, isPrefixEnabled); - - _stringProvider = new LocalisationProvider(directory, cultureName, isPrefixEnabled); - - GUIGraphicsContext.CharsInCharacterSet = _stringProvider.Characters; - - return true; - } - - static public string CurrentLanguage() - { - if (_stringProvider == null) - Load(null); - - return _stringProvider.CurrentLanguage.EnglishName; - } - - static public void ChangeLanguage(string language) - { - if (_stringProvider == null) - Load(language); - else - _stringProvider.ChangeLanguage(GetCultureName(language)); - } - - /// <summary> - /// Get the translation for a given id and format the sting with - /// the given parameters - /// </summary> - /// <param name="dwCode">id of text</param> - /// <param name="parameters">parameters used in the formating</param> - /// <returns> - /// string containing the translated text - /// </returns> - static public string Get(int dwCode, object[] parameters) - { - if (_stringProvider == null) - Load(null); - - string translation = _stringProvider.GetString("unmapped", dwCode); - // if parameters or the translation is null, return the translation. - if ((translation == null) || (parameters == null)) - { - return translation; - } - // return the formatted string. If formatting fails, log the error - // and return the unformatted string. - try - { - return String.Format(translation, parameters); - } - catch (System.FormatException e) - { - Log.Error("Error formatting translation with id {0}", dwCode); - Log.Error("Unformatted translation: {0}", translation); - Log.Error(e); - return translation; - } - } - - /// <summary> - /// Get the translation for a given id - /// </summary> - /// <param name="dwCode">id of text</param> - /// <returns> - /// string containing the translated text - /// </returns> - static public string Get(int dwCode) - { - if (_stringProvider == null) - Load(null); - - string translation = _stringProvider.GetString("unmapped", dwCode); - - if (translation == null) - { - Log.Error("No translation found for id {0}", dwCode); - return String.Empty; - } - - return translation; - } - - static public void LocalizeLabel(ref string strLabel) - { - if (_stringProvider == null) - Load(null); - - if (strLabel == null) strLabel = String.Empty; - if (strLabel == "-") strLabel = ""; - if (strLabel == "") return; - // This can't be a valid string code if the first character isn't a number. - // This check will save us from catching unnecessary exceptions. - if (!char.IsNumber(strLabel, 0)) - return; - - int dwLabelID; - - try - { - dwLabelID = System.Int32.Parse(strLabel); - } - catch (FormatException e) - { - Log.Error(e); - strLabel = String.Empty; - return; - } - - strLabel = _stringProvider.GetString("unmapped", dwLabelID); - if (strLabel == null) - { - Log.Error("No translation found for id {0}", dwLabelID); - strLabel = String.Empty; - } - } - - public static string LocalSupported() - { - if (_stringProvider == null) - Load(null); - - CultureInfo culture = _stringProvider.GetBestLanguage(); - - return culture.EnglishName; - } - - public static string[] SupportedLanguages() - { - if (_languages == null) - { - if (_stringProvider == null) - Load(null); - - CultureInfo[] cultures = _stringProvider.AvailableLanguages(); - - SortedList sortedLanguages = new SortedList(); - foreach (CultureInfo culture in cultures) - sortedLanguages.Add(culture.EnglishName, culture.EnglishName); - - _languages = new string[sortedLanguages.Count]; - - for (int i = 0; i < sortedLanguages.Count; i++) - { - _languages[i] = (string)sortedLanguages.GetByIndex(i); - } - } - - return _languages; - } - - static public string GetCultureName(string language) - { - if (_cultures == null) - { - _cultures = new Dictionary<string, string>(); - - CultureInfo[] cultureList = CultureInfo.GetCultures(CultureTypes.AllCultures); - - for (int i = 0; i < cultureList.Length; i++) - { - _cultures.Add(cultureList[i].EnglishName, cultureList[i].Name); - } - } - - if (_cultures.ContainsKey(language)) - return _cultures[language]; - - return null; - } - #endregion - } -} \ No newline at end of file Deleted: trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon/MyHexxagon.cs =================================================================== --- trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon/MyHexxagon.cs 2007-05-27 01:22:43 UTC (rev 459) +++ trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon/MyHexxagon.cs 2007-05-27 01:40:14 UTC (rev 460) @@ -1,1324 +0,0 @@ -#region Copyright (C) 2005-2007 Team MediaPortal - -/* - * Copyright (C) 2005-2007 Team MediaPortal - * http://www.team-mediaportal.com - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -#endregion - -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using MediaPortal.GUI.Library; -using MediaPortal.Dialogs; -using MediaPortal.Util; -using MediaPortal.Configuration; - -namespace MediaPortal.GUI.MyHexxagon -{ - [PluginIcons("MyHexxagon.hexxagon.png", "MyHexxagon.hexxagonDisabled.png")] - public class MyHexxagonGUI : GUIWindow, ISetupForm - { - #region enums - - private enum Level - { - Easy = 0, - Medium = 1, - Hard = 2 - } - - private enum Mode - { - PlayerVsComputer = 0, - PlayerVsPlayer = 1 - } - - #endregion - - #region SkinControl - - [SkinControlAttribute(2)] - protected GUIButtonControl btnStart = null; - [SkinControlAttribute(3)] - protected GUIButtonControl btnMode = null; - [SkinControlAttribute(4)] - protected GUIButtonControl btnLevel = null; - [SkinControlAttribute(5)] - protected GUIToggleButtonControl btnSound = null; - [SkinControlAttribute(6)] - protected GUIButtonControl btnWhatsThis = null; - [SkinControlAttribute(10)] - protected GUIButtonControl btnUndo = null; - [SkinControlAttribute(15)] - protected GUIButtonControl btnBoard = null; - - #endregion - - #region Private variables - - Level _currentLevel = Level.Easy; - Mode _currentMode = Mode.PlayerVsComputer; - bool _soundOn = true; - - int ActPly = 0; // actual player - - int player = 4; // constant player - int computer = 6; // constant computer - - int wait = 0; // init wait timer for computer - - int time = 0; // timer for game - int boardNo = 1; // default board - - int[] time_rec = { 999, 999, 999, 999, 999 }; - - // init board - int[] board = {0,0,0,0,0,0,0,0,0,0, // 0-9 - 0,0,0,0,0,0,0,0,0,0, //10-19 - 0,0,1,1,1,1,1,0,0,0, //20-29 - 0,0,1,1,1,1,1,1,0,0, //30-39 - 0,0,1,1,1,1,1,1,1,0, //40-49 - 0,0,1,1,1,1,1,1,1,1, //50-59 - 0,0,1,1,1,1,1,1,1,1, //60-69 - 1,0,0,1,1,1,1,1,1,1, //70-79 - 1,0,0,0,1,1,1,1,1,1, //80-89 - 1,0,0,0,0,1,1,1,1,1, //90-99 - 1,0,0,0,0,0,1,1,1,1, //100-109 - 1,0,0,0,0,0,0,0,0,0, //110-119 - 0,0,0,0,0,0,0,0,0,0, //120-129 - 0,0,0}; //130-132 - - int[,] rem_board = new int[80, 140]; - bool initBoard = false; - - // distances for moves - int[] MoveDouble = { 10, 11, 1, -10, -11, -1 }; - int[] MoveJump = { 9, 20, 21, 22, 12, 2, -9, -20, -21, -22, -12, -2 }; - - // last selected move - int lastHexx = 0; - - // init counter - int cntPly1 = 0; - int cntPly2 = 0; - int round = 1; - - // some help arrays for draw the board - int[] Draw = { 22, 32, 42, 52, 62, 73, 84, 95, 106 }; - int[] DrawCnt = { 5, 6, 7, 8, 9, 8, 7, 6, 5 }; - - // values on the baord - // Off Double Jump On1 On1Select On2 On2Select - // 1 2 3 4 5 6 7 - - private int[] ani01 = { 0, 0, 0, 0, 0, 0, 0, 0 }; - // possible moves 0-5, player 6 , cnt 7 - private int[] ani02 = { 0, 0, 0 }; - // last move, player, counter - - // game ticker for the computer - private System.Windows.Forms.Timer _Game = new System.Windows.Forms.Timer(); - - #endregion - - #region ISetupForm Members - - // Returns the name of the plugin which is shown in the plugin menu - public string PluginName() - { - return "My Hexxagon"; - } - - // Returns the description of the plugin is shown in the plugin menu - public string Description() - { - return "My Hexxagon"; - } - - // Returns the author of the plugin which is shown in the plugin menu - public string Author() - { - return "Mark Koenig (kroko)"; - } - - // show the setup dialog - public void ShowPlugin() - { - MessageBox.Show("Nothing to configure, this is just an example"); - } - - // Indicates whether plugin can be enabled/disabled - public bool CanEnable() - { - return true; - } - - // get ID of windowplugin belonging to this setup - public int GetWindowId() - { - return 1234711; - } - - // Indicates if plugin is enabled by default; - public bool DefaultEnabled() - { - return true; - } - - // indicates if a plugin has its own setup screen - public bool HasSetup() - { - return false; - } - - /// <summary> - /// If the plugin should have its own button on the main menu of MediaPortal then it - /// should return true to this method, otherwise if it should not be on home - /// it should return false - /// </summary> - /// <param name="strButtonText">text the button should have</param> - /// <param name="strButtonImage">image for the button, or empty for default</param> - /// <param name="strButtonImageFocus">image for the button, or empty for default</param> - /// <param name="strPictureImage">subpicture for the button or empty for none</param> - /// <returns>true : plugin needs its own button on home - /// false : plugin does not need its own button on home</returns> - - public bool GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage) - { - strButtonText = PluginName(); - strButtonImage = String.Empty; - strButtonImageFocus = String.Empty; - strPictureImage = @"hover_my hexxagon.png"; - return true; - } - - #endregion - - #region Overrides - - public override int GetID - { - get - { - return 1234711; - } - set - { - base.GetID = value; - } - } - - public override bool Init() - { - MyHexxagon.GUILocalizeStrings.Load(GUI.Library.GUILocalizeStrings.CurrentLanguage()); - - bool result = Load(GUIGraphicsContext.Skin + @"\MyHexxagon.xml"); - return result; - } - - public override bool OnMessage(GUIMessage message) - { - return base.OnMessage(message); - } - - protected override void OnPageLoad() - { - - // start game ticker - _Game.Interval = 100; - _Game.Tick += new EventHandler(_Game_Tick); - _Game.Start(); - - base.OnPageLoad(); - - // get position from the start button - int StartX = GetControl(198).XPosition; - int StartY = GetControl(198).YPosition; - // Disable level control - GUIControl.HideControl(GetID, 198); - - try - { - int StartT = GetControl(22).XPosition; - } - catch - { - initBoard = false; - } - - if (initBoard == false) - { - initBoard = true; - // draw buttons - for (int j = 0; j < 9; j++) - { - for (int i = 0; i < DrawCnt[j]; i++) - { - - int Nr = Draw[j] + i; - int XPos = StartX + (j * 45); - int YPos = 0; - - if (j < 5) - YPos = StartY + (i * 37) - (19 * j); - - if (j > 4) - YPos = StartY + (i * 37) - (19 * (8 - j)); - - CreateButton(Nr, XPos, YPos, 40, 60, "#F" + Nr, "#NF" + Nr); - - //default navigation - int up = Nr - 1; - int dn = Nr + 1; - int le = Nr - 10; - int ri = Nr + 10; - - //make it easier to navigate - if (j == 0 || j == 2 || j == 4 || j == 6 || j == 8) - { - le = Nr - 11; - ri = Nr + 11; - } - //block to top - if (i == 0) - up = Nr; - //block to bottom - if (i == (DrawCnt[j] - 1)) - dn = Nr; - //goto to start on left side - if (j == 0) - le = 2; - //block to right - if (j == 8) - ri = Nr; - // some exeption top row - if (i == 0) - { - if (j == 2 || j == 4) - { - le = Nr - 10; - } - if (j == 5 || j == 7) - { - ri = Nr + 11; - } - } - // some exeption bottom row - if ((i == 5 && j == 1) || (i == 7 && j == 3)) - le = Nr - 11; - if ((i == 8 && j == 4) || (i == 6 && j == 6)) - ri = Nr + 10; - - //SetNavigation(U, D, L, R) - GetControl(Nr).SetNavigation(up, dn, le, ri); - - } - } - } - - - // Disable level control - GUIControl.DisableControl(GetID, btnLevel.GetID); - - // Draw field - ResetBoard(); - SetLevel(); - Count(); - UpdateBoard(); - - UpdateButtonStates(); - } - - protected override void OnPageDestroy(int new_windowId) - { - _Game.Stop(); - _Game.Tick -= new EventHandler(_Game_Tick); - } - - protected override void OnClicked(int controlId, GUIControl control, MediaPortal.GUI.Library.Action.ActionType actionType) - { - if (control == btnStart) - OnBtnStart(); - else if (control == btnLevel) - OnBtnLevel(); - else if (control == btnMode) - OnBtnMode(); - else if (control == btnSound) - OnBtnSound(); - else if (control == btnWhatsThis) - OnBtnWhatsThis(); - else if (control == btnUndo) - OnBtnUndo(); - else if (control == btnBoard) - OnBtnBoard(); - - // check if some has clicked - if (board[controlId] == ActPly) - { - if (ActPly == 4 || (ActPly == 6 && _currentMode == Mode.PlayerVsPlayer)) - { - Select(ActPly, controlId); - } - } - if (board[controlId] == 2 || board[controlId] == 3) - Move(ActPly, controlId); - } - - protected override void OnShowContextMenu() - { - base.OnShowContextMenu(); - } - - #endregion - - #region Implementation - - private void OnBtnStart() - { - ActPly = 4; // Player 1 starts - round = 1; // reset round counter - - time = 0; - - ResetBoard(); - SetLevel(); - - Count(); - - for (int i = 0; i < 133; i++) - { - rem_board[0, i] = board[i]; - } - - // draw field - UpdateBoard(); - - UpdateButtonStates(); - } - - private void OnBtnLevel() - { - //Choose level for the game - if (!(ActPly == 0 || (round == 1 && ActPly == player))) - return; - - switch (_currentLevel) - { - case Level.Easy: - _currentLevel = Level.Medium; - break; - case Level.Medium: - _currentLevel = Level.Hard; - break; - case Level.Hard: - _currentLevel = Level.Easy; - break; - } - - UpdateButtonStates(); - } - - private void OnBtnMode() - { - //Choose mode for the game - if (!(ActPly == 0 || (round == 1 && ActPly == player))) - return; - - switch (_currentMode) - { - case Mode.PlayerVsComputer: - _currentMode = Mode.PlayerVsPlayer; - break; - case Mode.PlayerVsPlayer: - _currentMode = Mode.PlayerVsComputer; - break; - } - - UpdateButtonStates(); - } - - private void OnBtnSound() - { - _soundOn = btnSound.Selected; - UpdateButtonStates(); - } - - private void OnBtnWhatsThis() - { - GUIDialogText dlg = (GUIDialogText)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_TEXT); - dlg.SetHeading(MyHexxagon.GUILocalizeStrings.Get(31)); // help dialog heading - dlg.SetText(MyHexxagon.GUILocalizeStrings.Get(32)); // help dialog text - dlg.DoModal(GetID); - } - - private void OnBtnUndo() - { - if (round <= 1) - return; - - for (int i = 0; i < 133; i++) - { - board[i] = rem_board[round - 2, i]; - } - round = round - 1; - ActPly = player; - Count(); - UpdateBoard(); - - UpdateButtonStates(); - } - - private void OnBtnBoard() - { - //Choose mode for the game - if (!(ActPly == 0 || (round == 1 && ActPly == player))) - return; - - switch (boardNo) - { - case 1: - boardNo = 2; - break; - case 2: - boardNo = 3; - break; - case 3: - boardNo = 4; - break; - case 4: - boardNo = 5; - break; - case 5: - boardNo = 1; - break; - } - - ResetBoard(); - SetLevel(); - Count(); - UpdateBoard(); - - UpdateButtonStates(); - } - - private void OnRenderSound(string strFilePath) - { - if (_soundOn) - { - MediaPortal.Util.Utils.PlaySound(strFilePath, false, true); - } - } - - private void UpdateButtonStates() - { - GUIPropertyManager.SetProperty("#header_label", MyHexxagon.GUILocalizeStrings.Get(0)); // MyHexxagon - - GUIControl.SetControlLabel(GetID, btnStart.GetID, MyHexxagon.GUILocalizeStrings.Get(1)); // Start - //btnStart.Disabled = (Player != 0); - - string strLine = MyHexxagon.GUILocalizeStrings.Get(10); // Level: - switch (_currentLevel) - { - case Level.Easy: - strLine += MyHexxagon.GUILocalizeStrings.Get(11); // easy - break; - case Level.Medium: - strLine += MyHexxagon.GUILocalizeStrings.Get(12); // medium - break; - case Level.Hard: - strLine += MyHexxagon.GUILocalizeStrings.Get(13); // difficult - break; - } - GUIControl.SetControlLabel(GetID, btnLevel.GetID, strLine); - //btnLevel.Disabled = ((Player != 0) || (_currentMode == Mode.PlayerVsPlayer)); - - strLine = MyHexxagon.GUILocalizeStrings.Get(20); // Mode: Play vs - switch (_currentMode) - { - case Mode.PlayerVsComputer: - strLine += MyHexxagon.GUILocalizeStrings.Get(21); // Comp - break; - case Mode.PlayerVsPlayer: - strLine += MyHexxagon.GUILocalizeStrings.Get(22); // Player - break; - } - GUIControl.SetControlLabel(GetID, btnMode.GetID, strLine); - //btnMode.Disabled = (Player != 0); - - GUIControl.SetControlLabel(GetID, btnSound.GetID, MyHexxagon.GUILocalizeStrings.Get(9)); // Sounds - btnSound.Selected = _soundOn; - - GUIControl.SetControlLabel(GetID, btnWhatsThis.GetID, MyHexxagon.GUILocalizeStrings.Get(31)); // What is MyConnect? - GUIControl.SetControlLabel(GetID, btnUndo.GetID, MyHexxagon.GUILocalizeStrings.Get(8)); // Undo - GUIControl.SetControlLabel(GetID, btnBoard.GetID, MyHexxagon.GUILocalizeStrings.Get(7) + ": " + boardNo.ToString()); // Board: 1 - } - - #endregion - - public void Dispose() - { - _Game.Stop(); - _Game.Tick -= new EventHandler(_Game_Tick); - } - - private void CreateButton(int ID, int posx, int posy, int height, int width, string focusimg, string nofocusimg) - { - GUIButtonControl button = new GUIButtonControl(GetID, ID, posx, posy, width, height, focusimg, nofocusimg); - button.AllocResources(); - GUIControl btnControl = (GUIControl)button; - Add(ref btnControl); - } - - void _Game_Tick(object sender, EventArgs e) - { - - if ((ActPly > 0) && (round > 1)) - time++; - if (round <= 1) - time = 0; - - GUIPropertyManager.SetProperty("#Time", MyHexxagon.GUILocalizeStrings.Get(4) + ": " + (time / 10).ToString() + "s"); // Time: 5s - - UpdateButtonStates(); - if ((round > 1) && (ActPly != 0)) - { - GUIControl.EnableControl(GetID, btnUndo.GetID); // Undo - } - else - { - GUIControl.DisableControl(GetID, btnUndo.GetID); // Undo - } - - // wait some time - if (wait > 0) - wait = wait - 1; - - if (wait == 0 && ActPly == computer) - { - if (_currentMode == Mode.PlayerVsComputer) - // move the computer - CompSelect(); - } - - // ------------------------------------------------ - // animation 01 - - if ((ani01[0] != 0) && (ani01[7] > 0)) - { - int tmp; - // select different color - if (board[ani01[0]] == player) - { - tmp = computer; - } - else - { - tmp = player; - } - - // last animation - if (ani01[7] == 1) - { - tmp = ani01[06]; - } - - // set board take over - for (int i = 0; i < 6; i++) - { - if (board[ani01[i]] != 0) - { - board[ani01[i]] = tmp; - } - } - UpdateBoard(); - ani01[7]--; - } - // ------------------------------------------------ - // animation 02 - - if ((ani02[0] != 0) && (ani02[2] > 0)) - { - int tmp; - // select different - if (board[ani02[0]] != 1) - { - tmp = 1; - } - else - { - tmp = ani02[1]; - } - - // last animation - if (ani02[2] == 1) - { - tmp = ani02[01]; - } - - board[ani02[0]] = tmp; - - UpdateBoard(); - ani02[2]--; - - } - - } - - private void UpdateBoard() - { - // draw the board - for (int i = 22; i < 111; i++) - { - if (board[i] == 1) - { - GUIPropertyManager.SetProperty("#F" + i, @"\Hexxagon\MyHexx01F.png"); - GUIPropertyManager.SetProperty("#NF" + i, @"\Hexxagon\MyHexx01.png"); - } - if (board[i] == 2) - { - GUIPropertyManager.SetProperty("#F" + i, @"\Hexxagon\MyHexx02F.png"); - GUIPropertyManager.SetProperty("#NF" + i, @"\Hexxagon\MyHexx02.png"); - } - if (board[i] == 3) - { - GUIPropertyManager.SetProperty("#F" + i, @"\Hexxagon\MyHexx03F.png"); - GUIPropertyManager.SetProperty("#NF" + i, @"\Hexxagon\MyHexx03.png"); - } - if (board[i] == 4) - { - GUIPropertyManager.SetProperty("#F" + i, @"\Hexxagon\MyHexx04F.png"); - GUIPropertyManager.SetProperty("#NF" + i, @"\Hexxagon\MyHexx04.png"); - } - if (board[i] == 5) - { - GUIPropertyManager.SetProperty("#F" + i, @"\Hexxagon\MyHexx05F.png"); - GUIPropertyManager.SetProperty("#NF" + i, @"\Hexxagon\MyHexx05.png"); - } - if (board[i] == 6) - { - GUIPropertyManager.SetProperty("#F" + i, @"\Hexxagon\MyHexx06F.png"); - GUIPropertyManager.SetProperty("#NF" + i, @"\Hexxagon\MyHexx06.png"); - } - if (board[i] == 7) - { - GUIPropertyManager.SetProperty("#F" + i, @"\Hexxagon\MyHexx07F.png"); - GUIPropertyManager.SetProperty("#NF" + i, @"\Hexxagon\MyHexx07.png"); - } - if (board[i] == 10) - { - GUIPropertyManager.SetProperty("#F" + i, @"\Hexxagon\MyHexx0X.png"); - GUIPropertyManager.SetProperty("#NF" + i, @"\Hexxagon\MyHexx0X.png"); - } - if (ActPly == 4) - GUIPropertyManager.SetProperty("#Player", MyHexxagon.GUILocalizeStrings.Get(2) + " 1"); // PLAYER 1 - if (ActPly == 6) - GUIPropertyManager.SetProperty("#Player", MyHexxagon.GUILocalizeStrings.Get(2) + " 2"); // PLAYER 2 - if (ActPly == 0) - GUIPropertyManager.SetProperty("#Player", MyHexxagon.GUILocalizeStrings.Get(6)); // GAME OVER - - // display counter and so on - GUIPropertyManager.SetProperty("#Round", MyHexxagon.GUILocalizeStrings.Get(5) + "1"); // Round: 1 - GUIPropertyManager.SetProperty("#Ply1.Count", cntPly1.ToString()); - GUIPropertyManager.SetProperty("#Ply2.Count", cntPly2.ToString()); - - int p1 = (100 * cntPly1 / 58); - int p2 = (100 * cntPly2 / 58); - - GUIPropertyManager.SetProperty("#Round", MyHexxagon.GUILocalizeStrings.Get(5) + round.ToString()); // Round: - GUIPropertyManager.SetProperty("#Ply1.Percentage", p1.ToString()); - GUIPropertyManager.SetProperty("#Ply2.Percentage", p2.ToString()); - } - } - - private void Select(int ply, int pos) - { - // not game over - if (ActPly != 0) - { - // remember selected pos - lastHexx = pos; - // reset old selection - for (int i = 22; i < 111; i++) - { - if (board[i] == 2) - board[i] = 1; - if (board[i] == 3) - board[i] = 1; - if (board[i] == 5) - board[i] = 4; - if (board[i] == 7) - board[i] = 6; - } - // display selected pos - board[pos] = ply + 1; - OnRenderSound("HexxSelect.wav"); - // draw selection for double - for (int i = 0; i < 6; i++) - { - // if not occupied and visible - if (board[pos + MoveDouble[i]] == 1) - board[pos + MoveDouble[i]] = 2; - } - // draw selection for jumpe - for (int i = 0; i < 12; i++) - { - // if not occupied and visible - if (board[pos + MoveJump[i]] == 1) - board[pos + MoveJump[i]] = 3; - } - UpdateBoard(); - } - } - - private void Move(int ply, int pos) - { - if (board[pos] == 2) - { - // double - board[pos] = ply; - - ani02[0] = pos; - ani02[1] = ply; - ani02[2] = 10; - - Check(ply, pos); - OnRenderSound("HexxDouble.wav"); - } - if (board[pos] == 3) - { - // jump - board[lastHexx] = 1; - board[pos] = ply; - - ani02[0] = pos; - ani02[1] = ply; - ani02[2] = 10; - - Check(ply, pos); - OnRenderSound("HexxMove.wav"); - } - // clear selection on the board - for (int i = 22; i < 111; i++) - { - if (board[i] == 2) - board[i] = 1; - if (board[i] == 3) - board[i] = 1; - if (board[i] == 5) - board[i] = 4; - if (board[i] == 7) - board[i] = 6; - } - - // reset last stored - lastHexx = 0; - - NextPlayer(); - UpdateBoard(); - } - - private void Check(int ply, int pos) - { - int cnt = 0; - // reset ani - for (int i = 0; i < 6; i++) - { - ani01[i] = 0; - } - // remember player - ani01[6] = ply; - - // after move turn arround all surrounding tokens - for (int i = 0; i < 6; i++) - { - int next = ply + 2; - if (next > 6) next = 4; - - if (board[pos + MoveDouble[i]] == next) - { - //SetFlowDirection board - board[pos + MoveDouble[i]] = ply; - // set values for animation - ani01[7] = 10; // counter for animation - ani01[cnt] = pos + MoveDouble[i]; - cnt++; - } - } - } - - private void NextPlayer() - { - if (ActPly == 4) - { - ActPly = 6; - wait = 25; - } - else - { - ActPly = 4; - - for (int i = 0; i < 133; i++) - { - rem_board[round, i] = board[i]; - } - - round = round + 1; - - } - // check if there is a move left - NoMove(ActPly); - } - - private void NoMove(int ply) - { - bool noMove = true; - - for (int i = 22; i < 111; i++) - { // there is a move possible - if (noMove == false) - break; - - if (board[i] == ply) - { // if this is a player field - for (int j = 0; j < 6; j++) - { // check double fields are empty - if (board[i + MoveDouble[j]] == 1) - { - noMove = false; - break; - } - } - for (int j = 0; j < 12; j++) - { // check jump fields are empty - if (board[i + MoveJump[j]] == 1) - { - noMove = false; - break; - } - } - } - - } - - if (noMove == true) - { // Player can not move fill rest with other player - - ActPly = 0; // Game over - - int next = ply + 2; - if (next > 6) next = 4; - - for (int i = 22; i < 111; i++) - { - if (board[i] == 1) - board[i] = next; - - } - } - - Count(); - UpdateBoard(); - - // set message for game over - string msg = ""; - if ((ActPly == 0) && (cntPly1 > cntPly2)) - { - msg = "Player 1 wins the game !"; - } - if ((ActPly == 0) && (cntPly1 < cntPly2)) - { - msg = "Player 2 wins the game !"; - } - if ((ActPly == 0) && (cntPly1 == cntPly2)) - { - msg = "It is a tie !"; - } - // if game over - if (msg != "") - { - GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); - dlg.SetHeading(msg); - dlg.SetLine(1, msg); - dlg.SetLine(2, "Result"); - dlg.SetLine(3, cntPly1.ToString() + " : " + cntPly2.ToString()); - dlg.DoModal(GUIWindowManager.ActiveWindow); - } - } - - private void CompSelect() - { - // search the best move - double[] thisBest = { 0, 0, 0, 0 }; - double[] bestMove = { 0, 0, 0, 0 }; - - // check all fields - for (int i = 22; i < 111; i++) - { - int compHexx = 0; - - // if field is computer - if (board[i] == computer) - compHexx = i; - - if (compHexx != 0) - { - // Find the best move from every best move - thisBest = findBestMove(compHexx); - - if (thisBest[0] > bestMove[0]) - { - bestMove = thisBest; - } // Find best move if equal ranking - else if (thisBest[0] == bestMove[0]) - { - if (thisBest[3] < bestMove[3]) - { - bestMove = thisBest; - } - } - } - } - - if (bestMove[2] != 0) - { - Select(computer, Convert.ToInt16(bestMove[1])); - Move(computer, Convert.ToInt16(bestMove[2])); - } - - } - - private double[] findBestMove(int compHexx) - { - double highestRanking = 0; - int hexxCheck = 0; - int hexxDest = 0; - int tryDest = 0; - double eqCount = 0; - - Random randObj = new Random(); - - double[] returnArr = { 0, 0, 0, 0 }; - - // calculate the value for selcted pos - - for (int check = 0; check < 3; check++) - { - for (int j = 0; j < 6; j++) - { - double attackCount = 0; - - if (check == 0) - { - // normal double - hexxCheck = MoveDouble[j]; - - double RND = Math.Round(randObj.NextDouble() * 1.5); - if (RND == 1) - { - attackCount = 0.5; - } - else - { - attackCount = 1.5; - } - } - if (check == 1) - { - // jump part 1 - hexxCheck = MoveJump[j]; - } - if (check == 2) - { - // jump part 2 - hexxCheck = MoveJump[j + 6]; - } - - for (int k = 0; k < 6; k++) - { - tryDest = compHexx + hexxCheck; - if (board[tryDest] == 1) - { - // If destination is not occupied... - if (board[tryDest + MoveDouble[k]] == player) - { - // Count attacks for each move - attackCount++; - } - if (board[tryDest + MoveDouble[k]] == 1) - { - // Count attacks for each move - attackCount = attackCount + 0.1; - } - } - } - if (attackCount >= highestRanking) - { - // Find the best available attacking move - if (board[tryDest] == 1) - { - highestRanking = attackCount; - hexxDest = tryDest; - } - } - // Find the better of two equally ranked moves - if (attackCount == highestRanking) - { - eqCount = 0; - for (int k = 0; k < 6; k++) - { - if (board[compHexx + MoveDouble[k]] == computer) - { - // Only move if least of your kind surrounding you - eqCount++; - } - else - { - eqCount--; - } - } - } - } - } - - // return values - - returnArr[0] = highestRanking; - returnArr[1] = Convert.ToDouble(compHexx); - returnArr[2] = Convert.ToDouble(hexxDest); - returnArr[3] = eqCount; - return returnArr; - } - - private void Count() - { - // set counter to 0 - cntPly1 = 0; - cntPly2 = 0; - //count all fields - for (int j = 22; j < 111; j++) - { - if (board[j] == 4 || board[j] == 5) - cntPly1 = cntPly1 + 1; - if (board[j] == 6 || board[j] == 7) - cntPly2 = cntPly2 + 1; - } - } - - private void ResetBoard() - { - for (int i = 22; i <= 26; i++) - { - board[i] = 1; - GUIControl.EnableControl(GetID, i); - } - for (int i = 32; i <= 37; i++) - { - board[i] = 1; - GUIControl.EnableControl(GetID, i); - } - for (int i = 42; i <= 48; i++) - { - board[i] = 1; - GUIControl.EnableControl(GetID, i); - } - for (int i = 52; i <= 59; i++) - { - board[i] = 1; - GUIControl.EnableControl(GetID, i); - } - for (int i = 62; i <= 70; i++) - { - board[i] = 1; - GUIControl.EnableControl(GetID, i); - } - for (int i = 73; i <= 80; i++) - { - board[i] = 1; - GUIControl.EnableControl(GetID, i); - } - for (int i = 84; i <= 90; i++) - { - board[i] = 1; - GUIControl.EnableControl(GetID, i); - } - for (int i = 95; i <= 100; i++) - { - board[i] = 1; - GUIControl.EnableControl(GetID, i); - } - for (int i = 106; i <= 110; i++) - { - board[i] = 1; - GUIControl.EnableControl(GetID, i); - } - } - - private void SetLevel() - { - GetControl(98).SetNavigation(97, 99, 88, 108); - - GetControl(64).SetNavigation(63, 65, 54, 74); - - switch (boardNo) - { - case 1: - GUIControl.DisableControl(GetID, 56); - GUIControl.DisableControl(GetID, 65); - GUIControl.DisableControl(GetID, 77); - board[56] = 10; - board[65] = 10; - board[77] = 10; - - board[22] = 4; - board[70] = 4; - board[106] = 4; - board[26] = 6; - board[62] = 6; - board[110] = 6; - break; - case 2: - board[22] = 4; - board[70] = 4; - board[106] = 4; - board[26] = 6; - board[62] = 6; - board[110] = 6; - break; - case 3: - GetControl(98).SetNavigation(97, 99, 88, 98); - GUIControl.DisableControl(GetID, 24); - GUIControl.DisableControl(GetID, 66); - GUIControl.DisableControl(GetID, 108); - GUIControl.DisableControl(GetID, 44); - GUIControl.DisableControl(GetID, 64); - GUIControl.DisableControl(GetID, 86); - GUIControl.DisableControl(GetID, 46); - GUIControl.DisableControl(GetID, 68); - GUIControl.DisableControl(GetID, 88); - - board[24] = 10; - board[66] = 10; - board[108] = 10; - board[44] = 10; - board[64] = 10; - board[86] = 10; - board[46] = 10; - board[68] = 10; - board[88] = 10; - - board[65] = 4; - board[67] = 4; - board[55] = 4; - board[56] = 4; - board[76] = 4; - board[77] = 4; - - board[22] = 6; - board[62] = 6; - board[106] = 6; - board[26] = 6; - board[70] = 6; - board[110] = 6; - break; - case 4: - GetControl(64).SetNavigation(64, 65, 54, 74); // block UP - GUIControl.DisableControl(GetID, 62); - GUIControl.DisableControl(GetID, 43); - GUIControl.DisableControl(GetID, 63); - GUIControl.DisableControl(GetID, 85); - GUIControl.DisableControl(GetID, 105); - GUIControl.DisableControl(GetID, 34); - GUIControl.DisableControl(GetID, 55); - GUIControl.DisableControl(GetID, 76); - GUIControl.DisableControl(GetID, 97); - GUIControl.DisableControl(GetID, 56); - GUIControl.DisableControl(GetID, 67); - GUIControl.DisableControl(GetID, 77); - GUIControl.DisableControl(GetID, 36); - GUIControl.DisableControl(GetID, 58); - GUIControl.DisableControl(GetID, 79); - GUIControl.DisableControl(GetID, 99); - GUIControl.DisableControl(GetID, 70); - - board[62] = 10; - board[43] = 10; - board[63] = 10; - board[85] = 10; - board[105] = 10; - board[34] = 10; - board[55] = 10; - board[76] = 10; - board[97] = 10; - board[56] = 10; - board[67] = 10; - board[77] = 10; - board[36] = 10; - board[58] = 10; - board[79] = 10; - board[99] = 10; - board[70] = 10; - - board[22] = 4; - board[26] = 6; - break; - case 5: - GUIControl.DisableControl(GetID, 44); - GUIControl.DisableControl(GetID, 45); - GUIControl.DisableControl(GetID, 46); - - GUIControl.DisableControl(GetID, 86); - GUIControl.DisableControl(GetID, 87); - GUIControl.DisableControl(GetID, 88); - - GUIControl.DisableControl(GetID, 54); - GUIControl.DisableControl(GetID, 64); - GUIControl.DisableControl(GetID, 75); - - GUIControl.DisableControl(GetID, 57); - GUIControl.DisableControl(GetID, 68); - GUIControl.DisableControl(GetID, 78); - - board[44] = 10; - board[45] = 10; - board[46] = 10; - board[86] = 10; - board[87] = 10; - board[88] = 10; - - board[54] = 10; - board[64] = 10; - board[75] = 10; - - board[57] = 10; - board[68] = 10; - board[78] = 10; - - board[24] = 4; - board[108] = 6; - - board[62] = 6; - board[70] = 4; - break; - } - } - } -} \ No newline at end of file Deleted: trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon/MyHexxagon.csproj =================================================================== --- trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon/MyHexxagon.csproj 2007-05-27 01:22:43 UTC (rev 459) +++ trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon/MyHexxagon.csproj 2007-05-27 01:40:14 UTC (rev 460) @@ -1,70 +0,0 @@ -<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.50727</ProductVersion> - <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{7446DF9E-4F6D-41BF-89EB-7CFA23FA1DCD}</ProjectGuid> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>MyHexxagon</RootNamespace> - <AssemblyName>MyHexxagon</AssemblyName> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>pdbonly</DebugType> - <Optimize>false</Optimize> - <OutputPath>..\..\..\..\..\Programme\Team MediaPortal\MediaPortal\Plugins\Windows\</OutputPath> - <DefineConstants>TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - </PropertyGroup> - <ItemGroup> - <Reference Include="Core, Version=0.2.2.0, Culture=neutral, processorArchitecture=x86"> - <SpecificVersion>False</SpecificVersion> - <HintPath>..\..\..\..\..\Programme\Team MediaPortal\MediaPortal\Core.DLL</HintPath> - <Private>False</Private> - </Reference> - <Reference Include="Dialogs, Version=0.0.0.0, Culture=neutral, processorArchitecture=x86"> - <SpecificVersion>False</SpecificVersion> - <HintPath>..\..\..\..\..\Programme\Team MediaPortal\MediaPortal\Plugins\Windows\Dialogs.DLL</HintPath> - <Private>False</Private> - </Reference> - <Reference Include="System" /> - <Reference Include="System.Data" /> - <Reference Include="System.Windows.Forms" /> - <Reference Include="System.Xml" /> - <Reference Include="Utils, Version=1.0.2546.32604, Culture=neutral, processorArchitecture=x86"> - <SpecificVersion>False</SpecificVersion> - <HintPath>..\..\..\..\..\Programme\Team MediaPortal\MediaPortal\Utils.DLL</HintPath> - <Private>False</Private> - </Reference> - </ItemGroup> - <ItemGroup> - <Compile Include="LocalizeStrings.cs" /> - <Compile Include="MyHexxagon.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - </ItemGroup> - <ItemGroup> - <EmbeddedResource Include="hexxagon.png" /> - </ItemGroup> - <ItemGroup> - <EmbeddedResource Include="hexxagonDisabled.png" /> - </ItemGroup> - <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> - --> -</Project> \ No newline at end of file Deleted: trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon/hexxagon.png =================================================================== (Binary files differ) Deleted: trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon/hexxagonDisabled.png =================================================================== (Binary files differ) Copied: trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon.cs (from rev 459, trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon/MyHexxagon.cs) =================================================================== --- trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon.cs (rev 0) +++ trunk/plugins/My Hexxagon/Source/MyHexxagon/MyHexxagon.cs 2007-05-27 01:40:14 UTC (rev 460) @@ -0,0 +1,1324 @@ +#region Copyright (C) 2005-2007 Team MediaPortal + +/* + * Copyright (C) 2005-2007 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#endregion + +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; +using MediaPortal.GUI.Library; +using MediaPortal.Dialogs; +using MediaPortal.Util; +using MediaPortal.Configuration; + +namespace MediaPortal.GUI.MyHexxagon +{ + [PluginIcons("MyHexxagon.hexxagon.png", "MyHexxagon.hexxagonDisabled.png")] + public class MyHexxagonGUI : GUIWindow, ISetupForm + { + #region enums + + private enum Level + { + Easy = 0, + Medium = 1, + Hard = 2 + } + + private enum Mode + { + PlayerVsComputer = 0, + PlayerVsPlayer = 1 + } + + #endregion + + #region SkinControl + + [SkinControlAttribute(2)] + protected GUIButtonControl btnStart = null; + [SkinControlAttribute(3)] + protected GUIButtonControl btnMode = null; + [SkinControlAttribute(4)] + protected GUIButtonControl btnLevel = null; + [SkinControlAttribute(5)] + protected GUIToggleButtonControl btnSound = null; + [SkinControlAttribute(6)] + protected GUIButtonControl btnWhatsThis = null; + [SkinControlAttribute(10)] + protected GUIButtonControl btnUndo = null; + [SkinControlAttribute(15)] + protected GUIButtonControl btnBoard = null; + + #endregion + + #region Private variables + + Level _currentLevel = Level.Easy; + Mode _currentMod... [truncated message content] |