private void OnDragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent("FileDrop"))
            {
                object   fileDropData = e.Data.GetData("FileDrop");
                string[] files        = fileDropData as string[];

                if (files == null)
                {
                    string file = fileDropData as string;

                    if (file != null)
                    {
                        files = new[] { file };
                    }
                }

                if (files == null || files.Length == 0)
                {
                    return;
                }

                if (files.Length == 1 && ZipArchive.CanHandleFile(files[0]))
                {
                    InputMethod = new ArchiveExtraction(files[0], IOUtils.CreateTemporaryDirectory());
                }
                else
                {
                    InputMethod = new FileSearch(files);
                }

                DialogResult = DialogResult.OK;
                Close();
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultGameCommandExecutor" /> class.
 /// </summary>
 /// <param name="renderer">The game renderer.</param>
 /// <param name="inputMethod">The input method.</param>
 /// <param name="scores">The high scores.</param>
 public DefaultGameCommandExecutor(IRenderer renderer, IInputMethod inputMethod, HighScores scores)
 {
     this.scores = scores;
     this.gameRenderer = renderer;
     this.inputMethod = inputMethod;
     this.GenerateNewBoard(MaxRows, MaxColumns, MaxMines);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultGameCommandExecutor" /> class.
 /// </summary>
 /// <param name="renderer">The game renderer.</param>
 /// <param name="inputMethod">The input method.</param>
 /// <param name="scores">The high scores.</param>
 public DefaultGameCommandExecutor(IRenderer renderer, IInputMethod inputMethod, HighScores scores)
 {
     this.scores       = scores;
     this.gameRenderer = renderer;
     this.inputMethod  = inputMethod;
     this.GenerateNewBoard(MaxRows, MaxColumns, MaxMines);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GameEngine" /> class.
 /// </summary>
 /// <param name="renderer">The game renderer.</param>
 /// <param name="inputMethod">The user input method.</param>
 public GameEngine(IRenderer renderer, IInputMethod inputMethod)
 {
     this.gameRenderer = renderer;
     this.inputMethod = inputMethod;
     this.scores = new HighScores(MaxTopPlayers);
     this.cmdExecutor = new DefaultGameCommandExecutor(this.gameRenderer, this.inputMethod, this.scores);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GameEngine" /> class.
 /// </summary>
 /// <param name="renderer">The game renderer.</param>
 /// <param name="inputMethod">The user input method.</param>
 public GameEngine(IRenderer renderer, IInputMethod inputMethod)
 {
     this.gameRenderer = renderer;
     this.inputMethod  = inputMethod;
     this.scores       = new HighScores(MaxTopPlayers);
     this.cmdExecutor  = new DefaultGameCommandExecutor(this.gameRenderer, this.inputMethod, this.scores);
 }
Beispiel #6
0
        private static void Start()
        {
            IInputMethod immediateInput = Config.GetImmediateInputMethod();

            if (immediateInput != null)
            {
                new ProjectLoadForm(immediateInput).ShowDialog();
                return;
            }

            while (true)
            {
                MainForm form = new MainForm();

                if (form.ShowDialog() == DialogResult.OK)
                {
                    DialogResult result = new ProjectLoadForm(form.InputMethod).ShowDialog();
                    if (result == DialogResult.Abort)
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
        }
Beispiel #7
0
        protected override void OnPreviewCreated()
        {
            _scrollableOffscreen = new ScrollableOffscreen(this);

            _inputMethod = CanvasContext.GetInputMethod();
            var jsFontInfo = _textView._settings.fonts.jpFont;

            _inputMethod.SetFont(jsFontInfo.name, jsFontInfo.height * _textView.ZoomRate, _textView.GetLineHeight());
        }
        /// <summary>
        /// Returns false if the input was wrong.
        /// </summary>
        public static bool ProcessUserInput(IInputMethod inputMethod, out SolverInput solverInputModel)
        {
            solverInputModel = null;

            int maxIterationsCount = 0;
            int width  = 0;
            int height = 0;

            int[,] startState = null;
            int[,] finalState = null;

            try
            {
                Console.Write("Max iterations count: ");
                maxIterationsCount = Math.Abs(int.Parse(inputMethod.ReadLine()));

                Console.Write("Width: ");
                width = Math.Abs(int.Parse(inputMethod.ReadLine()));

                Console.Write("Height: ");
                height = Math.Abs(int.Parse(inputMethod.ReadLine()));

                startState = new int[height, width];
                finalState = new int[height, width];

                Console.WriteLine();
                Console.WriteLine("Max iterations count: {0}", maxIterationsCount);
                Console.WriteLine("Width: {0}", width);
                Console.WriteLine("Height: {0}", height);
                Console.WriteLine();

                Console.WriteLine("Insert the start state (line format - \"val1, val2, ...\" eg. 0, 1, 2):");
                Console.WriteLine("Value {0} is the empty space.", Solver.EMPTY_SPACE_REPRESENTATION);

                processGridInput(inputMethod, width, height, startState);

                Console.WriteLine();
                GridLogger.Log(width, height, startState.Convert2dArray2Sequence());

                Console.WriteLine("Insert the final state:");

                processGridInput(inputMethod, width, height, finalState);

                Console.WriteLine();
                GridLogger.Log(width, height, finalState.Convert2dArray2Sequence());
            }
            catch (Exception e)
            {
                Console.WriteLine(string.Format("Error: {0}", e.Message));
                return(false);
            }


            solverInputModel = new SolverInput(maxIterationsCount, width, height, startState, finalState);
            return(true);
        }
Beispiel #9
0
        // Button Click Events
        private void btnProjectFolder_Click(object sender, EventArgs e)
        {
            string[] folders = MultiFolderDialog.Show(this);

            if (folders.Length != 0){
                InputMethod = new FileSearch(folders);
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Beispiel #10
0
        private void btnProjectGitHub_Click(object sender, EventArgs e)
        {
            GitHubForm form = new GitHubForm();

            if (form.ShowDialog() == DialogResult.OK){
                InputMethod = form.GitHub;
                DialogResult = DialogResult.OK;
                Close();
            }
        }
 public BillOfMaterialsGenerator(IInputMethod inputMethod,
                                 IBillOfMaterialsValidator billOfMaterialsValidator,
                                 IOutputManager outputManager,
                                 ILogWrapper logger)
 {
     this.inputMethod = inputMethod;
     this.billOfMaterialsValidator = billOfMaterialsValidator;
     this.outputManager            = outputManager;
     this.logger = logger;
 }
Beispiel #12
0
        // Button Click Events

        private void btnProjectFolder_Click(object sender, EventArgs e)
        {
            string[] folders = MultiFolderDialog.Show(this);

            if (folders.Length != 0)
            {
                InputMethod  = new FileSearch(folders);
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Beispiel #13
0
        private void btnProjectGitHub_Click(object sender, EventArgs e)
        {
            GitHubForm form = new GitHubForm();

            if (form.ShowDialog() == DialogResult.OK)
            {
                InputMethod  = form.GitHub;
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Beispiel #14
0
        private void btnProjectArchive_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog{
                Filter = Lang.Get["DialogFilterArchives"]+ArchiveExtraction.FilterArchives,
                CheckFileExists = true,
                DereferenceLinks = true,
                AutoUpgradeEnabled = true
            };

            if (dialog.ShowDialog() == DialogResult.OK){
                InputMethod = new ArchiveExtraction(dialog.FileName, IOUtils.CreateTemporaryDirectory());
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Beispiel #15
0
        private void btnProjectArchive_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog {
                Filter             = Lang.Get["DialogFilterArchives"] + ArchiveExtraction.FilterArchives,
                CheckFileExists    = true,
                DereferenceLinks   = true,
                AutoUpgradeEnabled = true
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                InputMethod  = new ArchiveExtraction(dialog.FileName, IOUtils.CreateTemporaryDirectory());
                DialogResult = DialogResult.OK;
                Close();
            }
        }
        public AutomationRunner(string imageDirectory = "", InputType inputType = InputType.Native)
        {
#if !__ANDROID__
            if (inputType == InputType.Native)
            {
                inputSystem = new WindowsInputMethods();
            }
            else
            {
                inputSystem = new AggInputMethods(this, inputType == InputType.SimulatedDrawMouse);
                HookWindowsInputAndSendToWidget.EnableInputHook = false;
            }
#else
            inputSystem = new AggInputMethods(this, inputType == InputType.SimulatedDrawMouse);
#endif

            this.imageDirectory = imageDirectory;
        }
        // change default to SimulatedDrawMouse
        public AutomationRunner(IInputMethod inputMethod, bool drawSimulatedMouse, string imageDirectory = "")
        {
#if !__ANDROID__
            if (OverrideInputSystem != null)
            {
                inputSystem = OverrideInputSystem;
            }
            else
            {
                inputSystem = new AggInputMethods(this, drawSimulatedMouse);
                // TODO: Consider how to set this and if needed
                //HookWindowsInputAndSendToWidget.EnableInputHook = false;
            }
#else
            inputSystem = new AggInputMethods(this, drawSimulatedMouse);
#endif
            this.imageDirectory = imageDirectory;
        }
        private static void processGridInput(IInputMethod inputMethod, int width, int height, int[,] state)
        {
            for (int y = 0; y < height; y++)
            {
                Console.WriteLine("Line id {0}:", y);

                string line     = inputMethod.ReadLine();
                var    lineVals = Regex.Split(line, @",");

                if (lineVals.Length != width)
                {
                    throw new Exception("Wrong number of values.");
                }

                for (int x = 0; x < width; x++)
                {
                    state[y, x] = int.Parse(lineVals[x]);
                }
            }
        }
        /// <summary>
        /// Assign the selected input method to use in game
        /// Keyboard / Mobile
        /// </summary>
        public static void SetInputMethod(InputType inputMethod)
        {
            switch (inputMethod)
            {
            case InputType.Keyboard:
                selectedInputMethod = new KeyboardInputMethod();
                break;

            case InputType.Mobile:
                selectedInputMethod = new MobileInputMethod();
                break;

            case InputType.AlternateMobile:
                selectedInputMethod = new AlternateMobileInputMethod();
                break;

            case InputType.Mouse:
                selectedInputMethod = new MouseInputMethod();
                break;
            }
        }
 public void Dispose()
 {
     inputSystem.Dispose();
     inputSystem = null;
 }
Beispiel #21
0
 public ProjectLoadForm(IInputMethod inputMethod) : this()
 {
     this.inputMethod = inputMethod;
 }
Beispiel #22
0
 public Player(string name, IInputMethod inputMethod)
     : base(name)
 {
     _inputMethod = inputMethod;
     _state       = new StateComponent <PlayerState>(PlayerState.Idle);
 }
Beispiel #23
0
 public Player(string playerName, IInputMethod inputMethod)
 {
     _playerName  = playerName;
     _inputMethod = inputMethod;
 }
Beispiel #24
0
 internal Engine(IPerformanceDatabase db, IInputMethod inputMethod, IOutputMethod outputMethod)
 {
     this.InputMethod = inputMethod;
     this.OutputMethod = outputMethod;
     this.DataBase = db;
 }
Beispiel #25
0
        /// <summary>
        /// Program entry. Handles command line arguments and loads
        /// plugins accordingly
        /// </summary>
        /// <param name="args">Program arguments</param>
        private static void Main(string /*^!^*/[] /*^!^*/ args)
        {
            System.Version ver = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
            System.Console.WriteLine("This is Bomber Stuff {0}.{1}.{2} Build {3}", ver.Major, ver.Minor, ver.Build, ver.Revision);
            //System.Console.WriteLine("Copyright (c) 2010 Thomas Faber");
            //System.Console.WriteLine("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>");
            //System.Console.WriteLine("This is free software: you are free to change and redistribute it.");
            //System.Console.WriteLine("There is NO WARRANTY, to the extent permitted by law.");
            System.Console.WriteLine();

            if (args.Length > 0)
            {
                if (args[0] == "-i")
                {
                    System.Console.WriteLine("Running in integrity test mode");
                    // prepare integrity testing
                    System.Diagnostics.Debug.Listeners.Clear();
                    System.Diagnostics.Debug.Listeners.Add(new ConsoleTraceListener());
                    System.Diagnostics.Trace.Assert(false, "Assert test SUCCEEDED");

                    // integrity testing
                    System.Diagnostics.Trace.Assert(!new Drawing.RectangleF(0, 0, 1, 1).IntersectsWith(new Drawing.RectangleF(1, 0, 1, 1)), "test1");
                    System.Diagnostics.Trace.Assert(new Drawing.RectangleF(0, 0, 1, 1).IntersectsWith(new Drawing.RectangleF(511.0f / 512.0f, 0, 1, 1)), "test2");

                    System.Diagnostics.Trace.Assert(new Drawing.RectangleF(0, 0, 1, 1).IntersectsWith(new Drawing.RectangleF(.5f, .5f, 0, 0)), "test3");
                    System.Diagnostics.Trace.Assert(new Drawing.RectangleF(.5f, .5f, 0, 0).IntersectsWith(new Drawing.RectangleF(0, 0, 1, 1)), "test4");

                    System.Diagnostics.Trace.Assert(!new Drawing.RectangleF(1, 0, 1, 1).IntersectsWith(new Drawing.RectangleF(.5f, .5f, .5f, 0)), "test5");
                    System.Diagnostics.Trace.Assert(new Drawing.RectangleF(.99f, 0, 1, 1).IntersectsWith(new Drawing.RectangleF(.5f, .5f, .5f, 0)), "test6");

                    System.Diagnostics.Trace.Assert(!new Drawing.RectangleF(.5f, .5f, .5f, 0).IntersectsWith(new Drawing.RectangleF(.5f, .5f, 0, 0)), "test7");
                    System.Diagnostics.Trace.Assert(new Drawing.RectangleF(.5f, .5f, .5f, 0).IntersectsWith(new Drawing.RectangleF(.4f, .4f, .2f, .2f)), "test8");
                    // end integrity testing

                    if (ConsoleTraceListener.fails == 1)
                    {
                        System.Console.WriteLine("All tests succeeded");
                    }
                    else
                    {
                        System.Console.WriteLine("{0} test(s) failed", ConsoleTraceListener.fails - 1);
                    }
                    return;
                }
            }

            // load settings
            Settings settings;

            settings = BomberStuff.Files.SettingsReader.ReadFile("settings.xml");

            if (settings.Get <string>("GotSettings") != "true")
            {
                return;
            }

            if (settings.Get <string>(Settings.Types.ABDirectory) == null)
            {
                settings.Set <string>(Settings.Types.ABDirectory, @"C:\Temp\atomic_bomberman\bomber");
            }

            if (settings.Get <ColorRemapInfo[]>(Settings.Types.PlayerColor) == null)
            {
                ColorRemapInfo[] remapInfo = new ColorRemapInfo[10];
                for (int i = 0; i < remapInfo.Length; ++i)
                {
                    remapInfo[i] = PlayerColor(i);
                }
                settings.Set <ColorRemapInfo[]>(Settings.Types.PlayerColor, remapInfo);
            }

            if (settings.Get <string>(Settings.Types.UserInterface) == null)
            {
                settings.Set <string>(Settings.Types.UserInterface, "SlimDXInterface");
            }

            if (settings.Get <object>(Settings.Types.Tileset) == null)
            {
                settings.Set <int>(Settings.Types.Tileset, -1);
            }

            if (settings.Get <object>(Settings.Types.PlayerCount) == null)
            {
                settings.Set <int>(Settings.Types.PlayerCount, 1);
            }

            if (settings.Get <string>(Settings.Types.Scheme) == null)
            {
                settings.Set <string>(Settings.Types.Scheme, "BASIC");
            }

            System.Console.WriteLine("Settings found:");
            foreach (KeyValuePair <string, object> setting in settings)
            {
                System.Console.WriteLine("{0}: {1}", setting.Key, setting.Value);
            }
            System.Console.WriteLine();

            string uiName = settings.Get <string>(Settings.Types.UserInterface);

            try
            {
                Assembly assembly = Assembly.LoadFrom(uiName + ".dll");
                object   uiObject = assembly.CreateInstance("BomberStuff." + uiName + "." + uiName);

                IUserInterface ui = uiObject as IUserInterface;

                if (uiObject == null)
                {
                    throw new MissingMethodException();
                }

                // start a new game
                Game = new Game.Game(settings);

                ui.LoadSprites += Game.LoadSprites;
                ui.Render      += Game.Render;
                ui.Idle        += Game.Idle;

                PlayerControls[] playerControls = new PlayerControls[settings.Get <int>(Settings.Types.PlayerCount)];

                IInputMethod im = uiObject as IInputMethod;

                Dictionary <string, Control> imControls = im.GetControls();

                for (int i = 0; i < settings.Get <int>(Settings.Types.PlayerCount); ++i)
                {
                    List <KeyValuePair <PlayerControls.Types, Control> > controls = new List <KeyValuePair <PlayerControls.Types, Control> >();

                    string key = settings.Get <string>("Player" + i + ".Up");
                    if (key != null && imControls.ContainsKey(key))
                    {
                        controls.Add(new KeyValuePair <PlayerControls.Types, Control>(PlayerControls.Types.Up, imControls[key]));
                    }

                    key = settings.Get <string>("Player" + i + ".Down");
                    if (key != null && imControls.ContainsKey(key))
                    {
                        controls.Add(new KeyValuePair <PlayerControls.Types, Control>(PlayerControls.Types.Down, imControls[key]));
                    }

                    key = settings.Get <string>("Player" + i + ".Left");
                    if (key != null && imControls.ContainsKey(key))
                    {
                        controls.Add(new KeyValuePair <PlayerControls.Types, Control>(PlayerControls.Types.Left, imControls[key]));
                    }

                    key = settings.Get <string>("Player" + i + ".Right");
                    if (key != null && imControls.ContainsKey(key))
                    {
                        controls.Add(new KeyValuePair <PlayerControls.Types, Control>(PlayerControls.Types.Right, imControls[key]));
                    }

                    key = settings.Get <string>("Player" + i + ".Action1");
                    if (key != null && imControls.ContainsKey(key))
                    {
                        controls.Add(new KeyValuePair <PlayerControls.Types, Control>(PlayerControls.Types.Action1, imControls[key]));
                    }

                    key = settings.Get <string>("Player" + i + ".Action2");
                    if (key != null && imControls.ContainsKey(key))
                    {
                        controls.Add(new KeyValuePair <PlayerControls.Types, Control>(PlayerControls.Types.Action2, imControls[key]));
                    }

                    playerControls[i] = new PlayerControls(controls);

                    foreach (KeyValuePair <PlayerControls.Types, Control> control in controls)
                    {
                        im.RegisterControl(control.Value);
                    }
                }


                im.RegisterControl(imControls["Escape"]);
                imControls["Escape"].Pressed += (sender, e) => ui.Terminate();



                Game.Participants.Add(new LocalParticipant(playerControls));
                nParticipantsNegotiating = 1;
                playersRequested         = new int[nParticipantsNegotiating];

                foreach (Participant p in Game.Participants)
                {
                    p.Negotiate += Participant_Negotiate;
                    p.StartNegotiation();
                }

                while (nParticipantsNegotiating != 0)
                {
                    ;
                }

                Game.StartRound(playerCount);

                int iFirstPlayer = 0;

                for (int i = 0; i < Game.Participants.Count; ++i)
                {
                    Player[] players = new Player[playersRequested[i]];
                    Array.Copy(Game.Players, iFirstPlayer, players, 0, playersRequested[i]);
                    iFirstPlayer += playersRequested[i];
                    System.Console.WriteLine(Game.Participants[i] + " starting round controlling " + players.Length + " players");
                    Game.Participants[i].StartRound(players);
                }


                // start up the game UI
                ui.Initialize(settings);

                // make settings file backup. This one apparently works
                System.IO.File.Copy("settings.xml", "settings.lastgood.xml", true);

                ui.MainLoop();
                ui.Terminate();
            }
            catch (FileNotFoundException /*^!^*/ e)
            {
                ErrorHandling.FatalError(e, @"The interface module ""{0}"" or one of its"
                                         + @" dependencies could not be found:",
                                         uiName);
            }

            /* This is not in CF. Does it throw an alternative error? TRYTRY
             * catch (FileLoadException e)
             * {
             *      ErrorHandling.FatalError(e, @"The interface module ""{0}"" or one of its"
             + @" dependencies could not be loaded:\n{1}",
             +                                                                      uiName);
             + }*/
            catch (BadImageFormatException /*^!^*/ e)
            {
                ErrorHandling.FatalError(e, @"The interface module ""{0}"" or one of its"
                                         + @" dependencies could has an invalid format:",
                                         uiName);
            }
            catch (MissingMethodException /*^!^*/ e)
            {
                ErrorHandling.FatalError(e, @"The module ""{0}"" is not a valid BomberStuff"
                                         + @" interface module:",
                                         uiName);
            }
            catch (Exception /*^!^*/ e)
            {
                ErrorHandling.UnexpectedError(e, @"while trying to load the interface module {0}:",
                                              uiName);
            }
        }
        /// <summary>
        ///
        /// </summary>
        protected override void OnHandleCreated(EventArgs e)
        {
            InputMethod = new InputMethod(Handle, () => Focused);

            base.OnHandleCreated(e);
        }
 public ProjectLoadForm(IInputMethod inputMethod)
     : this()
 {
     this.inputMethod = inputMethod;
 }
Beispiel #28
0
        private void OnDragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent("FileDrop")){
                object fileDropData = e.Data.GetData("FileDrop");
                string[] files = fileDropData as string[];

                if (files == null){
                    string file = fileDropData as string;

                    if (file != null){
                        files = new[]{ file };
                    }
                }

                if (files == null || files.Length == 0)return;

                if (files.Length == 1 && ZipArchive.CanHandleFile(files[0])){
                    InputMethod = new ArchiveExtraction(files[0], IOUtils.CreateTemporaryDirectory());
                }
                else{
                    InputMethod = new FileSearch(files);
                }

                DialogResult = DialogResult.OK;
                Close();
            }
        }