Example #1
0
 public static void Save(Config config)
 {
     XmlSerializer serializer = new XmlSerializer(typeof(Config));
     TextWriter textWriter = new StreamWriter(@"config.xml");
     serializer.Serialize(textWriter, config);
     textWriter.Close();
 }
Example #2
0
        public static Config Load()
        {
            Config config;

            if (File.Exists(@"config.xml"))
            {
                XmlSerializer deserializer = new XmlSerializer(typeof(Config));
                TextReader textReader = new StreamReader(@"config.xml");
                config = (Config) deserializer.Deserialize(textReader);
                textReader.Close();
            }
            else
            {
                config = new Config();
                Save(config);
            }

            return config;
        }
Example #3
0
        public Game()
            : base(800, 600, GraphicsMode.Default, "Rawbots")
        {
            VSync = VSyncMode.On;

            renderModeCount = 0;
            shadingModeCount = 0;

            if (IsWindows())
                useFonts = true;

            config = Config.Load();

            this.Width = config.ScreenWidth;
            this.Height = config.ScreenHeight;

            if (config.Fullscreen)
                this.WindowState = WindowState.Fullscreen;

            resourcePath = DetectResourcePath();

            Mouse.Move += new EventHandler<MouseMoveEventArgs>(OnMouseMove);
            Keyboard.KeyDown += new EventHandler<KeyboardKeyEventArgs>(OnKeyDown);
            Keyboard.KeyUp += new EventHandler<KeyboardKeyEventArgs>(OnKeyUp);

            Console.WriteLine("{0}", resourcePath);

            if (useFonts)
            {
                font = new QFont(resourcePath + "/Fonts/Ubuntu-R.ttf", 16);
                font.Options.Colour = new Color4(1.0f, 1.0f, 1.0f, 1.0f);
                font.Options.DropShadowActive = false;

                monoFont = new QFont(resourcePath + "/Fonts/UbuntuMono-R.ttf", 16);
                monoFont.Options.Colour = new Color4(1.0f, 1.0f, 1.0f, 1.0f);
                monoFont.Options.DropShadowActive = false;
            }

            GL.Disable(EnableCap.Texture2D);
        }