Ejemplo n.º 1
0
        // Batch open a bunch of robots
        private void open_robots(String[] filenames)
        {
            foreach (String filename in filenames)
            {
                RobotFile result = RobotFile.OpenFile(filename);

                Robot robot = arena.loadRobot(result);
                robotlist[robot.number].robot = robot;
                robotlist[robot.number].update_info();
                arenaview.Invalidate();
            }
        }
Ejemplo n.º 2
0
        private void open_robots(String[] filenames)
        {
            foreach (String filename in filenames)
            {
                RobotFile result = RobotFile.OpenFile(filename);

                // Assign a number first, before adding to the lists
                Robot robot = arena.loadRobot(result);
                files[robot.number] = result;

                RobotWidget widget = new RobotWidget();
                robotlist[robot.number] = widget;
                robotvbox.PackStart(widget, false, true, 0);
                widget.robot = robot;
                widget.update_info();

                /* FIXME: implement closing
                 * Gtk.VBox rvbox = new Gtk.VBox();
                 * widget.AddChild(rvbox);
                 * rvbox.Homogeneous = true;
                 *
                 * Gtk.Button closebutton = new Gtk.Button(Stock.Close);
                 * Gtk.Action closeaction = robotactions[robot.number].getRobotAction("CloseAction");
                 * closeaction.ConnectProxy(closebutton);
                 * rvbox.PackStart(closebutton);
                 */

                widget.ShowAll();

                Gtk.HSeparator rsep = new Gtk.HSeparator();
                robotvbox.PackStart(rsep, false, true, 0);
                rsep.ShowAll();

                arenaview.QueueDraw();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Parses out the commandline arguments into the arena
        /// </summary>
        /// <param name="args">The list of commandline arguments</param>
        /// <param name="ha">The instance of the headless arena</param>
        /// <returns>true if the parsing was successful, false otherwise</returns>
        static bool parseArgs(string[] args, HeadlessArena ha)
        {
            if (args.Length == 0)
            {
                showHelp();
                return(false);
            }

            for (int i = 0; i < args.Length; i++)
            {
                // parse out chronon's per second
                if (args[i] == "-cpu")
                {
                    int?cs = loadNextInt("-cpu", args, i);
                    if (cs.HasValue)
                    {
                        ha.ChrononsPerUpdate = cs.Value;
                        i++;
                    }
                    else
                    {
                        return(false);
                    }
                }
                // parse out updates per second
                else if (args[i] == "-cl")
                {
                    int?us = loadNextInt("-cl", args, i);
                    if (us.HasValue)
                    {
                        ha.ChrononLimit = us.Value;
                        i++;
                    }
                    else
                    {
                        return(false);
                    }
                }
                // check for interactive mode
                else if (args[i] == "-i")
                {
                    ha.InteractiveMode = true;
                }
                // show help when requested
                else if (args[i].ToLower() == "-h")
                {
                    showHelp();
                    return(false);
                }
                // otherwise, assume it's a filename and try to load it
                else
                {
                    try
                    {
                        ha.AddRobot(RobotFile.OpenFile(args[i]));
                    }
                    catch (Exception e)
                    {
                        showError(String.Format("Unable to load robot file: {0}\n {1}",
                                                args[i], e.Message));
                    }
                }
            }
            return(true);
        }