Ejemplo n.º 1
0
        public List <ReplacedInfo> WriteMenuFile(string infile, string outfilepath, ResourceRef res)
        {
            bool onBuffer;

            using (var reader = new BinaryReader(FileUtilEx.Instance.GetStream(infile, out onBuffer), Encoding.UTF8)) {
                string header = reader.ReadString(); // header
                if (onBuffer || reader.BaseStream.Position > 0)
                {
                    if (header == FileConst.HEAD_MENU)
                    {
                        return(WriteMenuFile(reader, header, outfilepath, res));
                    }

                    var msg = LogUtil.Error("menuファイルを作成しようとしましたが、参照元ファイルのヘッダが正しくありません。", header, ", file=", infile);
                    throw new ACCException(msg.ToString());
                }
            }

            // arc内のファイルがロードできない場合の回避策: Sybaris 0410向け対策. 一括読み込み
            using (var reader = new BinaryReader(new MemoryStream(FileUtilEx.Instance.LoadInternal(infile), false), Encoding.UTF8)) {
                string header = reader.ReadString(); // hader
                if (header == FileConst.HEAD_MENU)
                {
                    return(WriteMenuFile(reader, header, outfilepath, res));
                }
                var msg = LogUtil.Error("menuファイルを作成しようとしましたが、参照元ファイルのヘッダが正しくありません。", header, ", file=", infile);
                throw new ACCException(msg.ToString());
            }
        }
Ejemplo n.º 2
0
 public MdfRenderMaterial(int id, string name, MdfMaterial mdfMaterial, Material material)
 {
     mId             = id;
     mName           = name;
     mDeviceMaterial = material.Ref();
     mSpec           = mdfMaterial;
 }
Ejemplo n.º 3
0
    private void CreateIndexBuffer()
    {
        // 12 tris are needed to fill the space between two discs
        // which comes down to 15 * 12 = 180 tris overall, each needing
        // 3 indices
        Span <ushort> indices = stackalloc ushort[TriCount * 3];
        int           i       = 0;

        for (var disc = 0; disc < 15; ++disc)
        {
            var discFirst     = disc * 6;       // Index of first vertex in the current disc
            var nextDiscFirst = (disc + 1) * 6; // Index of first vertex in the next disc

            for (var segment = 0; segment < 5; ++segment)
            {
                indices[i++] = (ushort)(discFirst + segment);
                indices[i++] = (ushort)(discFirst + segment + 1);
                indices[i++] = (ushort)(nextDiscFirst + segment + 1);
                indices[i++] = (ushort)(discFirst + segment);
                indices[i++] = (ushort)(nextDiscFirst + segment + 1);
                indices[i++] = (ushort)(nextDiscFirst + segment);
            }

            // The last segment of this disc wraps back around
            // and connects to the first segment
            indices[i++] = (ushort)(discFirst + 5);
            indices[i++] = (ushort)(discFirst);
            indices[i++] = (ushort)(nextDiscFirst);
            indices[i++] = (ushort)(discFirst + 5);
            indices[i++] = (ushort)(nextDiscFirst);
            indices[i++] = (ushort)(nextDiscFirst + 5);
        }

        mIndexBuffer = mDevice.CreateIndexBuffer(indices);
    }
Ejemplo n.º 4
0
    private void CreateResources(RenderingDevice device)
    {
        var           vertexIdx   = 0;
        Span <ushort> indicesData = stackalloc ushort[GlyphFileState.MaxGlyphs * 6];

        int j = 0;

        for (var i = 0; i < GlyphFileState.MaxGlyphs; ++i)
        {
            // Counter clockwise quad rendering
            indicesData[j++] = (ushort)(vertexIdx + 0);
            indicesData[j++] = (ushort)(vertexIdx + 1);
            indicesData[j++] = (ushort)(vertexIdx + 2);
            indicesData[j++] = (ushort)(vertexIdx + 0);
            indicesData[j++] = (ushort)(vertexIdx + 2);
            indicesData[j++] = (ushort)(vertexIdx + 3);
            vertexIdx       += 4;
        }

        _indexBuffer = device.CreateIndexBuffer(indicesData);

        _bufferBinding = new BufferBinding(device, _material.Resource.VertexShader).Ref();
        _bufferBinding.Resource.AddBuffer <GlyphVertex3d>(null, 0)
        .AddElement(VertexElementType.Float3, VertexElementSemantic.Position)
        .AddElement(VertexElementType.Color, VertexElementSemantic.Color)
        .AddElement(VertexElementType.Float2, VertexElementSemantic.TexCoord);
    }
        /// <summary>
        /// Triggered when the user drops a new resource onto the field, or clears the current value.
        /// </summary>
        /// <param name="newValue">New resource to reference.</param>
        private void OnFieldValueChanged(ResourceRef newValue)
        {
            Resource res = Resources.Load <Resource>(newValue);

            property.SetValue(res);
            state = InspectableState.Modified;
        }
Ejemplo n.º 6
0
    public ResourceRef <ITexture> Resolve(string filename, bool withMipMaps)
    {
        var filenameLower = filename.ToLowerInvariant();

        if (mTexturesByName.TryGetValue(filenameLower, out var textureRef))
        {
            return(textureRef.Resource.Ref());
        }

        // Texture is not registered yet, so let's do that
        if (!_fs.FileExists(filename))
        {
            Logger.Error("Cannot register texture '{0}', because it does not exist.", filename);
            var result = InvalidTexture.Ref();
            mTexturesByName[filenameLower] = result;
            return(result.CloneRef());
        }

        var id = mNextFreeId++;

        var texture = new ResourceRef <ITexture>(new FileTexture(mLoader, id, filename));

        Trace.Assert(!mTexturesByName.ContainsKey(filenameLower));
        Trace.Assert(!mTexturesById.ContainsKey(id));
        mTexturesByName[filenameLower] = texture.CloneRef();
        mTexturesById[id] = texture.CloneRef();

        return(texture);
    }
Ejemplo n.º 7
0
        /// <summary>
        /// Triggered when the user drops a new resource onto the field, or clears the current value.
        /// </summary>
        /// <param name="newValue">New resource to reference.</param>
        private void OnFieldValueChanged(ResourceRef newValue)
        {
            Resource res = Resources.Load<Resource>(newValue);

            property.SetValue(res);
            state = InspectableState.Modified;
        }
Ejemplo n.º 8
0
    public MovieRenderer(IMainWindow mainWindow, RenderingDevice device, VideoPlayer player,
                         MovieSubtitles?subtitles)
    {
        _mainWindow = mainWindow;
        _device     = device;
        _material   = CreateMaterial(device);
        _player     = player;

        if (subtitles != null)
        {
            _subtitleRenderer = new SubtitleRenderer(_device, subtitles);
        }

        _texture = device.CreateDynamicTexture(BufferFormat.X8R8G8B8,
                                               player.VideoWidth, player.VideoHeight);

        if (_player.HasAudio)
        {
            _soundSource = new SoLoudDynamicSource(_player.AudioChannels, _player.AudioSampleRate);
            Tig.Sound.PlayDynamicSource(_soundSource);
        }

        player.OnVideoFrame   += UpdateFrame;
        player.OnAudioSamples += PushAudioSamples;
    }
Ejemplo n.º 9
0
        public void OrganizationsNetworkTest()
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;

            var xmlReader = XmlReader.Create(new MemoryStream(Encoding.UTF8.GetBytes(@"<ResourceRef Uri=""https://disco.eduvpn.org/v2/organization_list.json"">
						<MinisignPublicKeyDictionary Key=""PublicKeys"">
							<PublicKey>RWRtBSX1alxyGX+Xn3LuZnWUT0w//B6EmTJvgaAxBMYzlQeI+jdrO6KF</PublicKey>
							<PublicKey>RWQKqtqvd0R7rUDp0rWzbtYPA3towPWcLDCl7eY9pBMMI/ohCmrS0WiM</PublicKey>
						</MinisignPublicKeyDictionary>
					</ResourceRef>"                    )));

            while (xmlReader.ReadState == ReadState.Initial)
            {
                xmlReader.Read();
            }
            var source = new ResourceRef();

            source.ReadXml(xmlReader);

            // Load list of organizations.
            var organizationListJson = Response.Get(source);
            var dict = new OrganizationDictionary();

            dict.LoadJSON(organizationListJson.Value);

            // Re-load list of organizations.
            Response.Get(
                res: source,
                previous: organizationListJson);
        }
Ejemplo n.º 10
0
    public ConeRenderer(RenderingDevice device)
    {
        _device           = device;
        _fanIndexBuffer   = device.CreateIndexBuffer(FanIndices);
        _fanVertexBuffer  = device.CreateEmptyVertexBuffer(IntgameVertex.Size * 20, debugName: "ConeRendererFanVb");
        _fanBufferBinding = device.CreateMdfBufferBinding().Ref();
        _fanBufferBinding.Resource.AddBuffer <IntgameVertex>(_fanVertexBuffer.Resource, 0)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Position)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Normal)
        .AddElement(VertexElementType.Color, VertexElementSemantic.Color)
        .AddElement(VertexElementType.Float2, VertexElementSemantic.TexCoord);

        _ringIndexBuffer   = device.CreateIndexBuffer(RingIndices);
        _ringVertexBuffer  = device.CreateEmptyVertexBuffer(IntgameVertex.Size * 38, debugName: "ConeRendererRingVb");
        _ringBufferBinding = device.CreateMdfBufferBinding().Ref();
        _ringBufferBinding.Resource.AddBuffer <IntgameVertex>(_ringVertexBuffer.Resource, 0)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Position)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Normal)
        .AddElement(VertexElementType.Color, VertexElementSemantic.Color)
        .AddElement(VertexElementType.Float2, VertexElementSemantic.TexCoord);

        _flankIndexBuffer   = device.CreateIndexBuffer(FlankIndices);
        _flankVertexBuffer  = device.CreateEmptyVertexBuffer(IntgameVertex.Size * 10, debugName: "ConeRendererRingFlank");
        _flankBufferBinding = device.CreateMdfBufferBinding().Ref();
        _flankBufferBinding.Resource.AddBuffer <IntgameVertex>(_flankVertexBuffer.Resource, 0)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Position)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Normal)
        .AddElement(VertexElementType.Color, VertexElementSemantic.Color)
        .AddElement(VertexElementType.Float2, VertexElementSemantic.TexCoord);
    }
Ejemplo n.º 11
0
 void HandlePackageResourceEvent(System.Object sender, ResourceRef.ResEventArgs args)
 {
     if (args.Success)
     {
         ResourceRef res = (ResourceRef)sender;
         List<SPendingRequest> ltFinishRequest = m_ltPendingRequest.FindAll(SPendingRequest.MatchPath(res.path));
         if (ltFinishRequest != null)
         {
             foreach (SPendingRequest request in ltFinishRequest)
             {
                 DebugTool.Log("load package ok");
                 request.callback(res.path, res.resource, request.callbackObj);
                 m_ltPendingRequest.Remove(request);
             }
         }
     }
     else
     {
         ResourceRef res = (ResourceRef)sender;
         List<SPendingRequest> ltFinishRequest = m_ltPendingRequest.FindAll(SPendingRequest.MatchPath(res.path));
         if (ltFinishRequest != null)
         {
             foreach (SPendingRequest request in ltFinishRequest)
             {
                 DebugTool.LogError("load package fail");
                 request.callback(res.path, null, request.callbackObj);
                 m_ltPendingRequest.Remove(request);
             }
         }
     }
 }
        /// <summary>
        /// The ButtonAdd_Click method.
        /// </summary>
        /// <param name="sender">The <paramref name="sender"/> parameter.</param>
        /// <param name="args">The <paramref name="args"/> parameter.</param>
        private void ButtonAdd_Click(object sender, EventArgs args)
        {
            var newRuleTrigger = new RuleTrigger {
                SituationType = cbxSituationType.SelectedItem.ToString()
            };

            if (chbxEnabled.Checked)
            {
                var resourceRefs   = new List <ResourceRef>();
                var newResourceRef = new ResourceRef {
                    Type = (ResourceRef.ResourceType)((ComboboxItem)cbxSituationType.SelectedItem).Value
                };
                var sourceId = ((ComboboxItem)cbxSource.SelectedItem).Value as string;
                if (string.IsNullOrEmpty(sourceId))
                {
                    return;
                }

                newResourceRef.Id = sourceId;
                resourceRefs.Add(newResourceRef);
                newRuleTrigger.ResourceRefs = resourceRefs;
            }

            var lvItem = new ListViewItem(string.Empty);

            lvItem.SubItems.Add(newRuleTrigger.SituationType);
            lvItem.SubItems.Add(newRuleTrigger.ResourceRefs.Count > 0 ? newRuleTrigger.ResourceRefs[0].Id : @"All");
            lvItem.Tag = newRuleTrigger;
            TriggerListView.Items.Add(lvItem);
        }
Ejemplo n.º 13
0
        public void ServerSourceNetworkTest()
        {
            // .NET 3.5 allows Schannel to use SSL 3 and TLS 1.0 by default. Instead of hacking user computer's registry, extend it in runtime.
            // System.Net.SecurityProtocolType lacks appropriate constants prior to .NET 4.5.
            ServicePointManager.SecurityProtocol = (SecurityProtocolType)0x0C00;
            var source = new ResourceRef()
            {
                Uri        = new Uri("https://disco.eduvpn.org/v2/server_list.json"),
                PublicKeys = new MinisignPublicKeyDictionary()
            };

            source.PublicKeys.Add("RWRtBSX1alxyGX+Xn3LuZnWUT0w//B6EmTJvgaAxBMYzlQeI+jdrO6KF");

            // Load list of servers.
            var server_source_json = Xml.Response.Get(source);
            var server_source_ia   = new ServerSource();

            server_source_ia.LoadJSON(server_source_json.Value);

            // Load all servers APIs.
            Parallel.ForEach(server_source_ia.ServerList.Values, srv =>
            {
                var uri_builder   = new UriBuilder(srv.Base);
                uri_builder.Path += "info.json";
                try
                {
                    new Models.InstanceEndpoints().LoadJSON(Xml.Response.Get(uri_builder.Uri).Value);
                }
                catch (AggregateException ex)
                {
                    if (ex.InnerException is WebException ex_web && (ex_web.Status == WebExceptionStatus.ConnectFailure || ex_web.Status == WebExceptionStatus.SecureChannelFailure || ex_web.Status == WebExceptionStatus.Timeout))
                    {
                        // Ignore connection failure WebException(s), as some servers are not publicly available or have other issues.
                    }
Ejemplo n.º 14
0
        internal DebugTerminal()
        {
            BuiltInCommands.Init();
            ScanAndPopulateCommands();

            byte[]       renderTargetInitData;
            RenderTarget windowRt = (RenderTarget)ResourceManager.Global.GetResource("Runtime/WindowRenderTarget");

            if (windowRt == null)
            {
                Log.FatalError("DebugTerminal could not obtain main rendertarget to get window size.");
                return;
            }

            using (MemoryStream mem = new MemoryStream())
                using (BinaryWriter writer = new BinaryWriter(mem))
                {
                    writer.Write(windowRt.width);
                    writer.Write((windowRt.height / 3) * 2);
                    renderTargetInitData = mem.ToArray();
                }
            renderTarget      = ResourceManager.Global.CreateResource <RenderTarget>("Runtime/DebugTerminal/RenderTarget", renderTargetInitData);
            textFont          = ResourceManager.Global.GetRef("Fonts/NotoMono_Regular.ttf");
            backgroundRect    = ResourceManager.Global.CreateResource <RectangleShape>("Runtime/DebugTerminal/Background");
            cursorRect        = ResourceManager.Global.CreateResource <RectangleShape>("Runtime/DebugTerminal/Cursor");
            cursorRect.width  = 2f;
            cursorRect.height = cursorHeight;

            Log.OnWriteLine  += (string msg) => { unreadLogOutput.Enqueue("[LOG] " + msg); };
            Log.OnWriteError += (string msg) => { unreadLogOutput.Enqueue("[ERROR] " + msg); };
        }
Ejemplo n.º 15
0
        public void ResponseTest()
        {
            var xmlReader = XmlReader.Create(new MemoryStream(Encoding.UTF8.GetBytes(@"<ResourceRef Uri=""http://besana.amebis.si/""></ResourceRef>")));

            while (xmlReader.ReadState == ReadState.Initial)
            {
                xmlReader.Read();
            }
            var source = new ResourceRef();

            source.ReadXml(xmlReader);
            Response.Get(
                res: source,
                responseType: "*/*");

            xmlReader = XmlReader.Create(new MemoryStream(Encoding.UTF8.GetBytes(@"<ResourceRef Uri=""http://govorec.amebis.si/""></ResourceRef>")));
            while (xmlReader.ReadState == ReadState.Initial)
            {
                xmlReader.Read();
            }
            source = new ResourceRef();
            source.ReadXml(xmlReader);
            Assert.ThrowsException <HttpRedirectToUnsafeUriException>(() =>
                                                                      Response.Get(
                                                                          res: source,
                                                                          responseType: "*/*"));
        }
Ejemplo n.º 16
0
    public PathXRenderSystem()
    {
        _device = Tig.RenderingDevice;

        // Create the indices now, they never change
        Span <ushort> indices = stackalloc ushort[6] {
            0, 2, 1, 0, 3, 2
        };

        _indexBuffer   = _device.CreateIndexBuffer(indices);
        _vertexBuffer  = _device.CreateEmptyVertexBuffer(IntgameVertex.Size * 4, debugName: "PathXVB");
        _bufferBinding = Tig.RenderingDevice.CreateMdfBufferBinding().Ref();
        _bufferBinding.Resource.AddBuffer <IntgameVertex>(_vertexBuffer, 0)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Position)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Normal)
        .AddElement(VertexElementType.Color, VertexElementSemantic.Color)
        .AddElement(VertexElementType.Float2, VertexElementSemantic.TexCoord);

        _aooIndexBuffer   = _device.CreateIndexBuffer(AooIndices);
        _aooVertexBuffer  = _device.CreateEmptyVertexBuffer(IntgameVertex.Size * 7, debugName: "PathXVBAoo");
        _aooBufferBinding = Tig.RenderingDevice.CreateMdfBufferBinding().Ref();
        _aooBufferBinding.Resource.AddBuffer <IntgameVertex>(_aooVertexBuffer, 0)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Position)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Normal)
        .AddElement(VertexElementType.Color, VertexElementSemantic.Color)
        .AddElement(VertexElementType.Float2, VertexElementSemantic.TexCoord);
    }
Ejemplo n.º 17
0
 /// <summary>
 /// Triggered by the runtime when the value of the field changes.
 /// </summary>
 /// <param name="newValue">New resource referenced by the field.</param>
 private void DoOnChanged(ResourceRef newValue)
 {
     if (OnChanged != null)
     {
         OnChanged(newValue);
     }
 }
Ejemplo n.º 18
0
        private void btnAddResource_Click(object sender, EventArgs e)
        {
            // add the new Resource object
            Resource r = null;

            if (gv.Resources.Count == 0)
            {
                r      = new Resource();
                r.Name = "Resource 1";
                r.Cost = 300m;
                gv.Resources.Add(r);
            }

            // find task1
            Task task1 = gv.Tasks.Search("Task 1");

            if (task1 != null && r != null && task1.ResourceRefs.Count == 0)
            {
                // add a resource reference to the task
                ResourceRef rRef = new ResourceRef();
                rRef.Resource = r;
                rRef.Amount   = 0.5;
                task1.ResourceRefs.Add(rRef);
            }
        }
Ejemplo n.º 19
0
        public ResourceRef[] addResources(string[] urls, int[] priorities, bool bAsync, Action <ResourceRef[]> actComplate, Action <Exception> actError)
        {
            ResourceRef[] refs  = new ResourceRef[urls.Length];
            bool          error = false;

            for (int i = 0; i < urls.Length; i++)
            {
                if (!dictResources.ContainsKey(urls [i]))
                {
                    refs [i] = new ResourceRef(urls [i], this);
                    dictResources.Add(urls [i], refs [i]);
                    refs [i].Start();
                }
                else
                {
                    refs [i] = dictResources [urls [i]];
                    refs [i].AddRefs();
                }

                if (!string.IsNullOrEmpty(refs [i].Error) && !error)
                {
                    error = true;
                }
            }
            if (!error)
            {
                actComplate(refs);
            }
            else
            {
                actError(new Exception(""));
            }
            return(refs);
        }
Ejemplo n.º 20
0
        public void OrganizationsNetworkTest()
        {
            // .NET 3.5 allows Schannel to use SSL 3 and TLS 1.0 by default. Instead of hacking user computer's registry, extend it in runtime.
            // System.Net.SecurityProtocolType lacks appropriate constants prior to .NET 4.5.
            ServicePointManager.SecurityProtocol = (SecurityProtocolType)0x0C00 | (SecurityProtocolType)0x3000;

            var xmlReader = XmlReader.Create(new MemoryStream(Encoding.UTF8.GetBytes(@"<ResourceRef Uri=""https://disco.eduvpn.org/v2/organization_list.json"">
						<MinisignPublicKeyDictionary Key=""PublicKeys"">
							<PublicKey>RWRtBSX1alxyGX+Xn3LuZnWUT0w//B6EmTJvgaAxBMYzlQeI+jdrO6KF</PublicKey>
							<PublicKey>RWQ68Y5/b8DED0TJ41B1LE7yAvkmavZWjDwCBUuC+Z2pP9HaSawzpEDA</PublicKey>
							<PublicKey>RWQKqtqvd0R7rUDp0rWzbtYPA3towPWcLDCl7eY9pBMMI/ohCmrS0WiM</PublicKey>
						</MinisignPublicKeyDictionary>
					</ResourceRef>"                    )));

            while (xmlReader.ReadState == ReadState.Initial)
            {
                xmlReader.Read();
            }
            var source = new ResourceRef();

            source.ReadXml(xmlReader);

            // Load list of organizations.
            var organizationListJson = Xml.Response.Get(source);
            var dict = new OrganizationDictionary();

            dict.LoadJSON(organizationListJson.Value);

            // Re-load list of organizations.
            Xml.Response.Get(
                res: source,
                previous: organizationListJson);
        }
Ejemplo n.º 21
0
 public TownMapData(Rectangle worldRectangle,
                    ResourceRef <ITexture>[,] smallTextures,
                    ResourceRef <ITexture>[,] bigTextures)
 {
     WorldRectangle = worldRectangle;
     SmallTextures  = smallTextures;
     BigTextures    = bigTextures;
 }
Ejemplo n.º 22
0
 public Cursor(ResourceRef<Texture2D> texture)
     : base(texture)
 {
     VerticalAlignment = VerticalAlignment.Top;
     HorizontalAlignment = HorizontalAlignment.Left;
     DrawMode = DrawMode.Screen;
     //Depth = int.MaxValue;
 }
Ejemplo n.º 23
0
    public ActionBarUi()
    {
        _pulseAnimation = GameSystems.Vagrant.AllocateActionBar();
        // These values were configurable in a MES file before
        GameSystems.Vagrant.ActionBarSetPulseValues(_pulseAnimation, 64, 255, 0.125f);

        _combatBarFill        = Tig.Textures.Resolve("art/interface/COMBAT_UI/CombatBar_Fill.tga", false);
        _combatBarHighlight   = Tig.Textures.Resolve("art/interface/COMBAT_UI/CombatBar_Highlight.tga", false);
        _combatBarHighlight2  = Tig.Textures.Resolve("art/interface/COMBAT_UI/CombatBar_Highlight2.tga", false);
        _combatBarGrey        = Tig.Textures.Resolve("art/interface/COMBAT_UI/CombatBar_GREY.tga", false);
        _combatBarFillInvalid = Tig.Textures.Resolve("art/interface/COMBAT_UI/CombatBar_Fill_INVALID.tga", false);

        _window      = new WidgetContainer(8, 117, 50, 260);
        _window.Name = "combat_ui_debug_output_window";

        // Hide or show the entire action bar based on combat status
        _window.Visible = false;
        GameSystems.Combat.OnCombatStatusChanged += combatStatus => { _window.Visible = combatStatus; };

        var actionBarImage = new WidgetImage("art/interface/COMBAT_UI/combatbar.img");

        _window.AddContent(actionBarImage);

        var actionBar = new WidgetContainer(new Rectangle(13, 15, 22, 170));

        _window.Add(actionBar);
        actionBar.Name            = "action bar";
        actionBar.OnBeforeRender += () => UiCombatActionBarRender(actionBar);

        // Add a full sized button on top of the action bar to handle tooltips and help requests
        var actionBarButton = new WidgetButton();

        actionBarButton.SetStyle(new WidgetButtonStyle());
        actionBarButton.SetSizeToParent(true);
        actionBarButton.SetClickHandler(OnActionBarButtonClick);
        actionBarButton.TooltipStyle    = "action-bar-tooltip";
        actionBarButton.OnBeforeRender += () =>
        {
            // Use the time update message (one per frame) to update the tooltip text
            actionBarButton.TooltipText = GetActionBarTooltipText();
        };
        actionBar.Add(actionBarButton);

        var nextTurn = new WidgetButton(new Rectangle(0, 194, 50, 50));

        nextTurn.SetStyle(new WidgetButtonStyle
        {
            NormalImagePath   = "art/interface/COMBAT_UI/Action-End-Turn.tga",
            HoverImagePath    = "art/interface/COMBAT_UI/Action-End-Turn-Hover.tga",
            PressedImagePath  = "art/interface/COMBAT_UI/Action-End-Turn-Click.tga",
            DisabledImagePath = "art/interface/COMBAT_UI/Action-End-Turn-Disabled.tga",
        });
        nextTurn.Name            = "next_turn";
        nextTurn.OnBeforeRender += () => OnBeforeRenderNextTurn(nextTurn);
        nextTurn.SetClickHandler(OnNextTurnClick);
        _window.Add(nextTurn);
    }
Ejemplo n.º 24
0
        void DelResource(string url)
        {
            ResourceRef _ref = null;

            if (dictTextures.TryGetValue(url, out _ref))
            {
                _ref.resourceObject.Dispose();
                dictTextures.Remove(url);
            }
        }
Ejemplo n.º 25
0
        public void DependencsError()
        {
            downloader.AddErrorFile(_params [0].path);
            ResourceRef refs = new ResourceRef(_params [4].path, resourceManager);

            dictResources.Add(_params [4].path, refs);
            refs.Start();
            Assert.IsFalse(string.IsNullOrEmpty(refs.Error));
            downloader.ClearErrorFiles();
        }
Ejemplo n.º 26
0
        public void PaserError()
        {
            hashSetErrorUnserializer.Add(_params [0].path);
            ResourceRef refs = new ResourceRef(_params [0].path, resourceManager);

            dictResources.Add(_params [0].path, refs);
            refs.Start();
            Assert.IsFalse(string.IsNullOrEmpty(refs.Error));
            hashSetErrorUnserializer.Clear();
        }
Ejemplo n.º 27
0
        public static void Main(string[] commandArgs)
        {
            try
            {
                var record = new Record();
                record.Add(new Property("title", "My Title"));
                record.Add(new Property("header", "My Header"));

                var link = new Link();
                link.Add(new Property("title", "My Title"));
                link.Add(new Property("href", "My #ref"));
                link.Add(new Property("header", "My Header"));
                link.Add(new Class("header"));
                link.Add(new Rel("header"));
                record.Add(link);

                var file = new ResourceRef();
                file.Add(new Property("title", "My Title"));
                file.Add(new Property("href", "My #ref"));
                file.Add(new Property("header", "My Header"));
                file.Add(new Class("header"));
                file.Add(new Rel("header"));
                record.Add(file);

                record.Add(new Property("__meta", Value.CreateObject(new
                {
                    Tables = new
                    {
                        Headers = new VName[] {
                            "Id",
                            "Name"
                        }
                    }
                })));


                var p1 = record.GetProperty <VArray>("__meta.tables.headers");
                record.SetProperty("__meta.tables.headers.id", new[] { 10 });
                var p2 = record.GetProperty <VArray>("__meta.tables.headers.id");

                var serializer = new MediaSerializer(MimeType.JsonSiren);
                var step1      = serializer.Serialize(record);

                var target = serializer.Deserialize(step1);
                var step2  = serializer.Serialize(record);


                Debug.WriteLine(Json.Beautify(step1));
                Debug.WriteLine(Json.Beautify(step2));
            }
            catch (Exception ex)
            {
                ex.Trace();
            }
        }
Ejemplo n.º 28
0
        public void NoDependencs()
        {
            ResourceRef refs = new ResourceRef(_params [0].path, resourceManager);

            dictResources.Add(_params [0].path, refs);
            refs.Start();

            Assert.AreEqual(1, dictResources.Count);
            Assert.IsTrue(dictResources.ContainsKey(_params [0].path));
            Assert.IsTrue(string.IsNullOrEmpty(refs.Error));
        }
Ejemplo n.º 29
0
        public ResourceRef GetResourceRef(StringHash key, ResourceRef @default = null)
        {
            IntPtr instance = IntPtr.Zero;

            Urho3D_Object_Event_GetResourceRef(_map, key.Hash, ref instance);
            if (instance == IntPtr.Zero)
            {
                return(@default);
            }
            return(ResourceRef.GetManagedInstance(instance));
        }
Ejemplo n.º 30
0
        public void LimitedProcessor()
        {
            List <string> pathes    = new List <string> ();
            int           resources = ResourceManager.NumberOfProcessor * 3;

            for (int i = 0; i < resources; i++)
            {
                TestParam _param = new TestParam("NDObject" + (i + 1).ToString("D2"), 0, null);
                dictParams.Add(_param.path, _param);
                pathes.Add(_param.path);
            }
            string[] arrayPathes = pathes.ToArray();                    // todo:输入参数最好不区分是 List 或者 Array

            int finished = 0;
            int error    = 0;

            ResourceManager.Instance.addResources(arrayPathes, new int[] { 0 }, true, (_ref) => {
                finished++;
            },
                                                  (e) => {
                error++;
            });

            int total     = resources;
            int processed = 0;

            for (int i = 0; i < resources / ResourceManager.NumberOfProcessor; i++)
            {
                int left = ResourceManager.Instance.UpdateLoop();
                processed += ResourceManager.NumberOfProcessor;
                Assert.AreEqual(left, total - processed);
            }
            Assert.AreEqual(processed, total);

            Dictionary <string, TestParam> .Enumerator eDictParam = dictParams.GetEnumerator();
            while (eDictParam.MoveNext())
            {
                ResourceRef refResult = ResourceManager.Instance.getResource(eDictParam.Current.Key);
                Assert.IsNotNull(refResult);
            }

            ResourceManager.Instance.delResources(arrayPathes);
            while (ResourceManager.Instance.UpdateLoop() > 0)
            {
                ;
            }

            eDictParam = dictParams.GetEnumerator();
            while (eDictParam.MoveNext())
            {
                ResourceRef refResult = ResourceManager.Instance.getResource(eDictParam.Current.Key);
                Assert.IsNull(refResult);
            }
        }
Ejemplo n.º 31
0
 private static bool RRinCRR(ResourceRef RR, CodeResourceRef[] CRRs)
 {
     foreach (var crr in CRRs)
     {
         if (crr.Ref.RefId.Equals(RR.RefId))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 32
0
 ResourceRef GetResource(string url)
 {
     if (!dictTextures.ContainsKey(url))
     {
         ResourceRef _ref = new ResourceRef(url, null);
         _ref.resourceObject = new ResourceObjectSingle(new Texture2D(4, 4));
         dictTextures.Add(url, _ref);
         return(_ref);
     }
     return(dictTextures[url]);
 }
    /// <summary>
    /// Renders the Line Of Sight buffer for a given party member.
    /// </summary>
    public void RenderLineOfSight(IGameViewport viewport, int partyIndex)
    {
        var buffer = _system.GetLineOfSightBuffer(partyIndex, out var size, out var originTile);

        if (!_texture.IsValid || _texture.Resource.GetSize() != size)
        {
            _colorBuffer = new PackedLinearColorA[size.Width * size.Height];

            _texture.Dispose();
            _texture = _device.CreateDynamicTexture(BufferFormat.A8R8G8B8, size.Width, size.Height);
        }

        // Update color buffer
        for (int i = 0; i < buffer.Length; i++)
        {
            _colorBuffer[i] = GetColorFromLosFlags(buffer[i]);
        }

        var rawColorBuffer = MemoryMarshal.Cast <PackedLinearColorA, byte>(_colorBuffer);

        _texture.Resource.UpdateRaw(rawColorBuffer, size.Width * 4);

        var origin = new Vector4(originTile.ToInches3D(), 1);

        var widthVec  = new Vector4(size.Width * locXY.INCH_PER_SUBTILE, 0, 0, 0);
        var heightVec = new Vector4(0, 0, size.Height * locXY.INCH_PER_SUBTILE, 0);

        Span <ShapeVertex3d> corners = stackalloc ShapeVertex3d[4]
        {
            new ShapeVertex3d
            {
                pos = origin,
                uv  = new Vector2(0, 0)
            },
            new ShapeVertex3d
            {
                pos = origin + widthVec,
                uv  = new Vector2(1, 0)
            },
            new ShapeVertex3d
            {
                pos = origin + widthVec + heightVec,
                uv  = new Vector2(1, 1)
            },
            new ShapeVertex3d
            {
                pos = origin + heightVec,
                uv  = new Vector2(0, 1)
            }
        };

        Tig.ShapeRenderer3d.DrawQuad(viewport, corners, new PackedLinearColorA(255, 255, 255, 127), _texture.Resource);
    }
Ejemplo n.º 34
0
        public static CodeResourceRef[] AnalyzeCodeFile(string[] Categories,string FilePath)
        {

            try
            {
                StreamReader sr = new StreamReader(FilePath);
                int nLineNumber = 1;
                List<CodeResourceRef> listCRR = new List<CodeResourceRef>();
                while (!sr.EndOfStream)
                {
                    string sLine = sr.ReadLine();
                    foreach (var c in Categories)
                    {
                        int start = sLine.IndexOf("R." + c + ".");
                        if (start >= 0)
                        {
                            int end = sLine.LastIndexOfAny(ValidVariableCharacters());
                            string sRef = sLine.Substring(start, (end - start)+1);
                            CodeResourceRef crr = new CodeResourceRef();
                            crr.ClassFile = Path.GetFileName(FilePath);
                            crr.CodeLineNumber = nLineNumber.ToString();
                            crr.CodePosistion = start.ToString();
                            ResourceRef rr = new ResourceRef();
                            rr.Category = c;
                            rr.RefId = sRef;
                            rr.RefName = sRef.Split('.')[2];
                            crr.Ref = rr;
                            listCRR.Add(crr);

                        }


                    }
                    nLineNumber++;

                }
                sr.Close();
                return listCRR.ToArray();
            }
            catch (System.Exception ex)
            {

            }


            return null;
        }
        public void CreateComplexXMPTypes()
        {
            //ExStart:CreateColorant
            // create RGB colorant with R, G, B components
            ColorantRGB rgbColorant = new ColorantRGB(254, 254, 1);

            // create CMYK colorant with Black, Cyan, Magenta, Yellow components
            ColorantCMYK cmykColorant = new ColorantCMYK(10, 10, 1, 50);
            //ExEnd:CreateColorant


            //ExStart:CreateDimensions
            int width = 100;
            int height = 50;

            // create dimensions
            Dimensions dimensions = new Dimensions(width, height);
            dimensions.Units = "inch";

            // create dimensions using object initializer
            Dimensions dimensions2 = new Dimensions();
            dimensions2.Width = width;
            dimensions2.Height = height;
            dimensions2.Units = "inch";
            //ExEnd:CreateDimensions


            //ExStart:CreateFont
            string fontFamily = "Arial";

            // create Arial font
            GroupDocs.Metadata.Xmp.Types.Complex.Font.Font font = new GroupDocs.Metadata.Xmp.Types.Complex.Font.Font(fontFamily);
            //ExEnd:CreateFont


            //ExStart:CreateResourceEvent
            // create ResourceEvent type
            ResourceEvent resourceEvent = new ResourceEvent();

            // set the action that occurred
            resourceEvent.Action = "edited";

            // Additional description of the action
            resourceEvent.Parameters = "secon version";
            //ExEnd:CreateResourceEvent


            //ExStart:CreateResourceRef
            ResourceRef expectedValue = new ResourceRef
            {
                DocumentUri = "074255bf-78bc-4002-89dc-cd7538b40fe0",
                InstanceId = "42a841b7-48d4-4988-8988-53d2c6e7525d"
            };

            // create XmpMediaManagementPackage
            XmpMediaManagementPackage package = new XmpMediaManagementPackage();

            // update DerivedFrom property
            package.SetDerivedFrom(expectedValue);

            // check value
            ResourceRef value = (ResourceRef)package["xmpMM:DerivedFrom"];
            //ExEnd:CreateResourceRef


            //ExStart:CreateThumbnail
            // path to the image
            string imagePath = @"C:\\image.jpg";
            string base64String;

            // use System.Drawing to get image base64 string
            using ( Image image = Image.FromFile(imagePath))
            {
                using (MemoryStream m = new MemoryStream())
                {
                    image.Save(m, image.RawFormat);
                    byte[] imageBytes = m.ToArray();

                    // Convert byte[] to Base64 String
                    base64String = Convert.ToBase64String(imageBytes);
                }
            }

            // xmp thumbnail width
            int thumbnailWidth = 100;

            // xmp thumbnail height
            int thumbnailHeight = 50;

            // create xmp thumbnail 
            Thumbnail thumbnail = new Thumbnail(thumbnailWidth, thumbnailHeight);

            // add provide image base64 string
            thumbnail.ImageBase64 = base64String;
            //ExEnd:CreateThumbnail


            //ExStart:CreateVersion
            // create new instance of Version
            GroupDocs.Metadata.Xmp.Types.Complex.Version.Version version = new GroupDocs.Metadata.Xmp.Types.Complex.Version.Version();

            // set version number
            version.VersionText = "1.0";

            // set version date
            version.ModifiedDate = DateTime.UtcNow;

            // set person who modified this version
            version.Modifier = "Joe Doe";

            // set version additional comments
            version.Comments = "First version, created by: Joe Doe";
            //ExEnd:CreateVersion
        }
Ejemplo n.º 36
0
 /// <summary>
 /// Triggered by the runtime when the value of the field changes.
 /// </summary>
 /// <param name="newValue">New resource referenced by the field.</param>
 private void Internal_DoOnChanged(ResourceRef newValue)
 {
     if (OnChanged != null)
         OnChanged(newValue);
 }
Ejemplo n.º 37
0
 private static extern void Internal_SetValueRef(IntPtr nativeInstance, ResourceRef value);
Ejemplo n.º 38
0
 public ToggleButonView(ToggleButton control, ResourceRef<Texture2D> textureOn, ResourceRef<Texture2D> textureOff)
     : this(control, new Sprite(textureOn), new Sprite(textureOff))
 {
 }
Ejemplo n.º 39
0
 public BodySprite(ResourceRef<Texture2D> texture, BodyType type = 0)
 {
     Body = Add(new BodyFromTexture(texture, type));
     Sprite = Add(new Sprite(texture));
     Sprite.Width = Sprite.Width.ToSimUnits();
     Sprite.Height = Sprite.Height.ToSimUnits();
     Sprite.Origin = -Body.Centroid;
     this.Attach(Body, Sprite);
 }
Ejemplo n.º 40
0
 public PressButtonView(Button control, ResourceRef<Texture2D> texture)
     : this(control, new Sprite(texture))
 {
 }
Ejemplo n.º 41
0
        //private static string ExtractRowNumber(string ValueText)
        //{
        //    int nStart = ValueText.IndexOf("at line") + "at line".Length;
        //    string sValue = ValueText.Substring(nStart);
        //    return sValue;
        //}

        //private static string ExtractValue(string ValueText)
        //{
        //    int nStart = ValueText.IndexOf('\'')+1;
        //    int nLen =  ValueText.LastIndexOf('\'') - nStart;
        //    string sValue = ValueText.Substring(nStart, nLen);
        //    return sValue;
        //}

        private static ResourceRef FindRR(ResourceRef[] RRs, string RefId)
        {
            foreach (var rr in RRs)
            {
                if (rr.RefId.Equals(RefId))
                    return rr;
            }
            return null;
        }
Ejemplo n.º 42
0
        private static bool RRinCRR(ResourceRef RR, CodeResourceRef[] CRRs)
        {
            foreach (var crr in CRRs)
            {
                if (crr.Ref.RefId.Equals(RR.RefId))
                    return true;
            }
            return false;

        }
Ejemplo n.º 43
0
        public static ResourceRef[] UnusedResources(ResourceRef[] RRs, CodeResourceRef[] TotalCRR)
        {

            List<ResourceRef> listUnusedRR = new List<ResourceRef>();

            foreach (var rr in RRs)
            {
                if (!RRinCRR(rr, TotalCRR))
                    listUnusedRR.Add(rr);
            }


            return listUnusedRR.ToArray();

        }
Ejemplo n.º 44
0
        public static ResourceRef[] AnalyzeRFile(string FilePath)
        {

            
            try
            {
                StreamReader sr = new StreamReader(FilePath);
                string CurrentCategory = string.Empty;
                List<string> listElements = new List<string>();
                List<ResourceRef> listRR = new List<ResourceRef>();
                while (!sr.EndOfStream)
                {
                    string sLine = sr.ReadLine();
                    
                    //public static final class attr {
                    
                    int indxclassdef = sLine.IndexOf("public static final class");
                    if(indxclassdef >= 0)
                    {
                        int end = sLine.IndexOf('{');
                        int start = indxclassdef + "public static final class".Length;
                        CurrentCategory = sLine.Substring(start, end - start).Trim();
                    }

                    //public static final int alpha=0x7f020000;

                    int indxresourcedef = sLine.IndexOf("public static final int");
                    if (indxresourcedef >= 0)
                    {
                        int end = sLine.IndexOf('=');
                        int start = indxresourcedef + "public static final int".Length;
                        string CurrentValue = sLine.Substring(start, end - start).Trim();
                        string[] cvs = CurrentValue.Split('=');
                        string Value = cvs[0];

                        ResourceRef rr = new ResourceRef();
                        rr.Category = CurrentCategory;
                        rr.RefId = "R." + rr.Category +"." +Value;
                        rr.RefName = Value;
                        listRR.Add(rr);
                    }
                }
                sr.Close();
                return listRR.ToArray();


            }
            catch (System.Exception ex)
            {
                return null;
            }

        }
Ejemplo n.º 45
0
 //针对外部资源包的构造
 public SRes(string _path, ResourceRef bundleRes)
 {
     strPath = _path;
     bBundle = true;
     BundleRes = bundleRes;
 }