Exemplo n.º 1
0
        static void Main(string[] args)
        {
            System.Resources.ResourceManager rm          = new Resources.ResourceManager(typeof(System.Resources_Example.Recurso));
            System.Globalization.CultureInfo cultureInfo = new Globalization.CultureInfo("pt-BR");
            string d = rm.GetString("DESCRICAO", cultureInfo);

            Console.WriteLine(d);
            Console.ReadKey();
        }
Exemplo n.º 2
0
        public HttpServer(Configuration config, Resources.ResourceManager resManager)
        {
            m_configuration   = config;
            m_resourceManager = resManager;

            m_handlers = new Dictionary <string, Func <IHttpHeaders, IHttpContext, Task <JObject> > >();

            m_handlers["initconnect"]      = InitConnectMethod.Get(config, resManager.GameServer);
            m_handlers["getconfiguration"] = GetConfigurationMethod.Get(config, resManager);
        }
Exemplo n.º 3
0
        public GameEngine()
        {
            settings = new ApplicationSettings();
            settings.Load();

            int width  = settings.WindowWidth;
            int height = settings.WindowHeight;

            int render_width  = settings.RenderWidth;
            int render_height = settings.RenderHeight;

            resourceManager = new Resources.ResourceManager("data/");

            effectHandler   = new Rendering.PostProcessing.PostEffectHandler();
            window          = new Rendering.Window("Testing", width, height, settings.Resizeable);
            deviceResources = new Rendering.DeviceResources(window.GetHandle(), render_width, render_height, 60);

            // Load basic resources included in engine.
            // Some resources are required for renderer to function.
            InitializeEngineResources();
            PostResourceLoadInitialization();

            input    = new Input();
            gameTime = new GameTime();

            accessors = new Accessors(
                gameTime.Accessor,
                input.Acessor
                );

            stateMachine = new States.GameStateMachine(accessors);
            States.GameState testState = new States._TestState(accessors);
            stateMachine.Attach(testState);
            stateMachine.AddToStack("TestState");

            testState.Load(resourceManager, deviceResources.Device);
            testState.Init(resourceManager);

            light = new GameObject("light", 0);
            light.SetScale(new Vector3(0.1f, 0.1f, 0.1f));
            light.SetPosition(new Vector3(-5, 0, -5));


            // TODO: Work this out.
            // Renderer must be created after state has loaded resources.
            // Need to make CubemapRenderer play nice with Renderer.
            renderer = new Rendering.Renderer(window, deviceResources, render_width, render_height, 60, effectHandler);


            Logger.Write(LogType.Info, "Engine Initialized");
        }
Exemplo n.º 4
0
        public CubemapRenderer(D3D11.Device device, Resources.ResourceManager resourceManager)
        {
            this.device = device;

            shaderEnv = resourceManager.Shaders.GetFromAlias("KDX_SKYBOX_ENV_RENDERER").Shader;
            shaderIrr = resourceManager.Shaders.GetFromAlias("KDX_SKYBOX_IRR_RENDERER").Shader;


            cubeMesh = resourceManager.Meshes.GetFromAlias("KDX_CUBE_IN").Mesh;

            if (!cubeMesh.HasBuffers)
            {
                cubeMesh.CreateBuffers(device);
            }
        }
Exemplo n.º 5
0
        public GameServer(Configuration config, Resources.ResourceManager resManager, Commands.CommandManager commandManager)
        {
            m_configuration = config;

            commandManager.SetGameServer(this);
            CommandManager = commandManager;

            m_resourceManager = resManager;
            m_resourceManager.SetGameServer(this);

            var dnsEntry = Dns.GetHostEntry("37.46.132.72");

            foreach (var address in dnsEntry.AddressList)
            {
                if (address.AddressFamily == AddressFamily.InterNetwork)
                {
                    m_serverList = new IPEndPoint(address, 30110);
                }
            }

            UseAsync = true;
        }
Exemplo n.º 6
0
        public static Func <IHttpHeaders, IHttpContext, Task <JObject> > Get(Configuration config, Resources.ResourceManager resourceMgr)
        {
            return((headers, context) =>
            {
                var result = new JObject();
                var resources = new JArray();

                var resourceSource = resourceMgr.GetRunningResources();
                string resourceFilter;

                if (headers.TryGetByName("resources", out resourceFilter))
                {
                    var resourceNames = resourceFilter.Split(';');

                    resourceSource = resourceSource.Where(r => resourceNames.Contains(r.Name));
                }
                else
                {
                    // add the imports, if any
                    if (config.Imports != null)
                    {
                        var imports = new JArray();

                        config.Imports.ForEach(a => imports.Add(a.ConfigURL));

                        result["imports"] = imports;
                    }
                }

                // generate configuration with our filter function
                resourceSource.GenerateConfiguration(resources, (resource, rObject) =>
                {
                    // get download configuration for this resource
                    var configEntry = resourceMgr.Configuration.GetDownloadConfiguration(resource.Name);

                    if (configEntry != null)
                    {
                        if (!string.IsNullOrWhiteSpace(configEntry.BaseURL))
                        {
                            rObject["fileServer"] = configEntry.BaseURL;
                        }
                    }
                });

                result["resources"] = resources;
                result["fileServer"] = "http://%s/files/";

                result["loadScreen"] = "nui://keks/index.html";

                var source = new TaskCompletionSource <JObject>();
                source.SetResult(result);

                return source.Task;
            });
        }
Exemplo n.º 7
0
        private async Task Start(string configFileName)
        {
            Configuration config;

            try
            {
                config = Configuration.Load(configFileName ?? "citmp-server.yml");

                // if running on WinNT default to using windowed logger
                if (Environment.OSVersion.Platform == PlatformID.Win32NT && !config.DisableWindowedLogger)
                {
                    WindowedLogger.Initialize(config.DebugLog);
                }

                if (config.AutoStartResources == null)
                {
                    this.Log().Fatal("No auto-started resources were configured.");
                    return;
                }

                if (config.ListenPort == 0)
                {
                    this.Log().Fatal("No port was configured.");
                    return;
                }

                if (config.Downloads == null)
                {
                    config.Downloads = new Dictionary<string, DownloadConfiguration>();
                }
            }
            catch (System.IO.IOException)
            {
                this.Log().Fatal("Could not open the configuration file {0}.", configFileName ?? "citmp-server.yml");
                return;
            }

            var platformServer = config.PlatformServer ?? "iv-platform.prod.citizen.re";
            var client = new NPClient(platformServer, (config.PlatformPort == 0) ? (ushort)3036 : (ushort)config.PlatformPort);

            this.Log().Info("Connecting to Terminal platform server at {0}.", platformServer);

            var connectResult = client.Connect();

            if (!connectResult)
            {
                this.Log().Fatal("Could not connect to the configured platform server ({0}).", platformServer);
                return;
            }

            this.Log().Info("Authenticating to Terminal with anonymous license key.");

            // authenticate anonymously
            var task = client.AuthenticateWithLicenseKey("");

            if (!task.Wait(15000))
            {
                this.Log().Fatal("Could not authenticate anonymously to the configured platform server ({0}) - operation timed out.", platformServer);
                return;
            }

            if (!task.Result)
            {
                this.Log().Fatal("Could not authenticate anonymously to the configured platform server ({0}).", platformServer);
                return;
            }

            this.Log().Info("Creating initial server instance.");

            var commandManager = new Commands.CommandManager();
            var resManager = new Resources.ResourceManager(config);

            // create the game server (as resource scanning needs it now)
            var gameServer = new Game.GameServer(config, resManager, commandManager, client);

            // preparse resources
            if (config.PreParseResources != null)
            {
                this.Log().Info("Pre-parsing resources: {0}", string.Join(", ", config.PreParseResources));

                foreach (var resource in config.PreParseResources)
                {
                    resManager.ScanResources("resources/", resource);

                    var res = resManager.GetResource(resource);

                    if (res != null)
                    {
                        await res.Start();
                    }
                }
            }
            else
            {
                this.Log().Warn("No PreParseResources defined. This usually means you're using an outdated configuration file. Please consider this.");
            }

            // scan resources
            resManager.ScanResources("resources/");

            // start the game server
            gameServer.Start();

            // and initialize the HTTP server
            var httpServer = new HTTP.HttpServer(config, resManager);
            httpServer.Start();

            // start resources
            foreach (var resource in config.AutoStartResources)
            {
                var res = resManager.GetResource(resource);

                if (res == null)
                {
                    this.Log().Error("Could not find auto-started resource {0}.", resource);
                }
                else
                {
                    await res.Start();
                }
            }

            // start synchronizing the started resources
            resManager.StartSynchronization();

            // main loop
            int lastTickCount = Environment.TickCount;

            while (true)
            {
                Thread.Sleep(5);

                var tc = Environment.TickCount;

                gameServer.Tick(tc - lastTickCount);

                lastTickCount = tc;
            }
        }
Exemplo n.º 8
0
 protected abstract void LoadResources(Resources.ResourceManager resourceManager, SharpDX.Direct3D11.Device device);
Exemplo n.º 9
0
 public void Load(Resources.ResourceManager resourceManager, SharpDX.Direct3D11.Device device)
 {
     Logger.StartLogSection(string.Format("{0} - Loading State Resources", Name));
     LoadResources(resourceManager, device);
     Logger.EndLogSection();
 }
Exemplo n.º 10
0
        public static string ToHumanDurationTr(this Hangfire.Dashboard.HtmlHelper htmlHelper, Resources.ResourceManager resource, TimeSpan?duration, bool displaySign = true)
        {
            if (duration == null)
            {
                return(null);
            }

            var builder = new StringBuilder();

            if (displaySign)
            {
                builder.Append(duration.Value.TotalMilliseconds < 0 ? "-" : "+");
            }

            duration = duration.Value.Duration();

            if (duration.Value.Days > 0)
            {
                builder.Append($"{duration.Value.Days}{resource.GetString("d")} ");
            }

            if (duration.Value.Hours > 0)
            {
                builder.Append($"{duration.Value.Hours}{resource.GetString("h")} ");
            }

            if (duration.Value.Minutes > 0)
            {
                builder.Append($"{duration.Value.Minutes}{resource.GetString("m")} ");
            }

            if (duration.Value.TotalHours < 1)
            {
                if (duration.Value.Seconds > 0)
                {
                    builder.Append(duration.Value.Seconds);
                    if (duration.Value.Milliseconds > 0)
                    {
                        builder.Append($".{duration.Value.Milliseconds.ToString().PadLeft(3, '0')}");
                    }

                    builder.Append($"{resource.GetString("s")} ");
                }
                else
                {
                    if (duration.Value.Milliseconds > 0)
                    {
                        builder.Append($"{duration.Value.Milliseconds}{resource.GetString("ms")} ");
                    }
                }
            }

            if (builder.Length <= 1)
            {
                builder.Append($" <1{resource.GetString("ms")} ");
            }

            builder.Remove(builder.Length - 1, 1);

            return(builder.ToString());
        }