ImageLibrary

Moved

Total Downloads: 18,288 - First Release: Oct 29, 2016 - Last Update: Jun 11, 2018

5/5, 36 likes
  1. Absolut submitted a new resource:

    ImageLibrary - A Plugin to Manage External Images - For Devs

    Read more about this resource...
     
  2. I added the new items and fixed the ulong to int error... waiting to test.. damn server!
     
  3. Absolut updated ImageLibrary with a new update entry:

    1.1.0

     
  4. Big Like!!!
     
  5. Thanks! Glad to hear!
     
  6. Absolut updated ImageLibrary with a new update entry:

    1.2.0

     
  7. Can you add new Components images to the Library?
     
  8. Absolutely! And just as a heads up as I am sure this will happen more down the road here is what I do for unique images and the same could be done for item images:

    OnServerInitialize add some AddImage lines as such:

    Code:
                AddImage("http://cdn.mysitemyway.com/etc-mysitemyway/icons/legacy-previews/icons/simple-black-square-icons-arrows/126517-simple-black-square-icon-arrows-double-arrowhead-left.png", "FIRST");
                AddImage("https://image.freepik.com/free-icon/back-left-arrow-in-square-button_318-76403.png", "BACK");
                AddImage("https://image.freepik.com/free-icon/right-arrow-square-button-outline_318-76302.png", "NEXT");
                AddImage("http://cdn.mysitemyway.com/etc-mysitemyway/icons/legacy-previews/icons/matte-white-square-icons-arrows/124577-matte-white-square-icon-arrows-double-arrowhead-right.png", "LAST");
                AddImage("http://oxidemod.org/data/resource_icons/1/1751.jpg?1456924271", "SR");
    
    and in your case it would be something like this:

    Code:
                AddImage("http://vignette3.wikia.nocookie.net/play-rust/images/6/66/Glue_icon.png/revision/latest/scale-to-width-down/50?cb=20161109045933", "glue");
                AddImage("http://vignette2.wikia.nocookie.net/play-rust/images/7/72/Gears_icon.png/revision/latest/scale-to-width-down/50?cb=20161109045908", "gears");
    
     
  9. Absolut updated ImageLibrary with a new update entry:

    1.2.1

     
  10. Code:
    #region GUI        Dictionary<ulong, string> guiInfo = new Dictionary<ulong, string>();        void NoClipGui(BasePlayer player)
            {
                // Destroy existing UI
                string gui;
                if (guiInfo.TryGetValue(player.userID, out gui)) CuiHelper.DestroyUi(player, gui);            var elements = new CuiElementContainer();
                guiInfo[player.userID] = CuiHelper.GetGuid();            elements.Add(new CuiElement
                {
                    Name = guiInfo[player.userID],
                    Components =
                    {
                        new CuiRawImageComponent { Color = "1 1 1 0.8", Url = "http://img.hb.aicdn.com/ac719cab1bb438f5131a300f434c1ac7f3828b9054b8-1fkoU8_fw658" },
                        new CuiRectTransformComponent { AnchorMin = "0.06 0.017", AnchorMax = "0.105 0.08" }
                    }
                });            // Create the UI elements
                CuiHelper.AddUi(player, elements);
            }
            #endregion
    Hi ~ How to use it on this code?
     
    Last edited by a moderator: Nov 17, 2016
  11. This is the best I can do to help you.. it isnt "EASY" but I try to make it as close to it as possible...

    Code:
            #region GUI        //MAKE SURE THIS IS AT THE VERY TOP...
            using Oxide.Core.Plugins;        //ADD this
        [PluginReference]
        Plugin ImageLibrary;    void OnServerInitialized()
        {
            try
            {
                ImageLibrary.Call("isLoaded", null);
            }
            catch (Exception)
            {
                PrintWarning("No Image Library.. load ImageLibrary to use this Plugin", Name);
                Interface.Oxide.UnloadPlugin(Name);
                return;
            }
            AddImage("IMAGE URL HERE", "IMAGE_NAME_HERE", "SKIN OR ID IF APPLICABLE"); //Add AS MANY OF THESE AS YOU WANT... The IMAGE NAME SHOULD BE IN A GetImage(Somewhere in the mod...)
        }    //ADD THESE
        public string GetImage(string shortname, ulong skin = 0) => (string)ImageLibrary.Call("GetImage", shortname, skin);
        public bool AddImage(string url, string shortname, ulong skin = 0) => (bool)ImageLibrary?.Call("AddImage", url, shortname, skin);    Dictionary<ulong, string> guiInfo = new Dictionary<ulong, string>();        void NoClipGui(BasePlayer player)
            {
                // Destroy existing UI
                string gui;
                if (guiInfo.TryGetValue(player.userID, out gui)) CuiHelper.DestroyUi(player, gui);            var elements = new CuiElementContainer();
                guiInfo[player.userID] = CuiHelper.GetGuid();            elements.Add(new CuiElement
                {
                    Name = guiInfo[player.userID],
                    Components =
                    {
                       
                        new CuiRawImageComponent { Color = "1 1 1 0.8", Url = "http://img.hb.aicdn.com/ac719cab1bb438f5131a300f434c1ac7f3828b9054b8-1fkoU8_fw658" },/*CHANGE THIS... TO...This =>>> */new CuiRawImageComponent {Png = GetImage("IMAGE_NAME_HERE", "SKIN OR ID IF APPLICABLE") },
                        new CuiRectTransformComponent { AnchorMin = "0.06 0.017", AnchorMax = "0.105 0.08" }
                    }
                });            // Create the UI elements
                CuiHelper.AddUi(player, elements);
            }
            #endregion
    
     
  12. WOW!It's work! Thank for your guide :)
    I have a question.
    How to Refresh Cheche?
    When i use this one [ConsoleCommand("RefreshAllImages")]
    IMG don't show any more.
    And i got this...
    Code:
    16:36 [Error] Failed to call hook 'AddImage' on plugin 'ImageLibrary v1.2.1' (NullReferenceException: Object reference not set to an instance of an object)
    16:36 [Debug]   at Oxide.Plugins.ImageLibrary.HasImage (System.String shortname, UInt64 skin) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.ImageLibrary.AddImage (System.String url, System.String name, UInt64 skin) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.ImageLibrary.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.CSharpPlugin.InvokeMethod (HookMethod method, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.Plugin.CallHook (System.String name, System.Object[] args) [0x00000] in <filename unknown>:0 
    [DOUBLEPOST=1479459648][/DOUBLEPOST]Or It can do Refresh Chache When IMG URL has change?
     
  13. And when i restart Server.
    I got this...
    Code:
    [11/18/2016 22:26:34] [Oxide] 22:26 [Debug]   at Oxide.Plugins.Vanish.AddImage (System.String url, System.String shortname, UInt64 skin) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.Vanish.OnServerInitialized () [0x00000] in <filename unknown>:0
      at Oxide.Plugins.Vanish.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.CSharpPlugin.InvokeMethod (HookMethod method, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.Plugin.CallHook (System.String name, System.Object[] args) [0x00000] in <filename unknown>:0 
     
  14. You shouldn't really need to refresh cache. In your case, the image is added on load of your plugin so reloading your mod would do the trick. Also a reload of ImageLibrary checks for new images IN imageLibrary.

    As for your error see if the data file got corrupted somehow; I've seen it a few times... if it is null or you aren't sure simply make sure ImageLibrary is unloaded and delete the ImageLibrary data file. Reload IL and your plugin and you should be good to go.

    99% of problems with plugins revolve around data files (at least it seems that way!)
     
  15. Why i got white IMG...
    [DOUBLEPOST=1479487640][/DOUBLEPOST]Yes. That error because I delete Other plugin DefaultMessages....
    I fix it..
    And the Other plugin now is okay.
    But they IMG all white....
    [DOUBLEPOST=1479487728][/DOUBLEPOST]I delete ImageLibrary_Data.json And reload IL.
    But there are still problems
    [DOUBLEPOST=1479489006][/DOUBLEPOST]I did my best, but still did not work...
     

    Attached Files:

  16. And when i reload plugin...
     

    Attached Files:

  17. Why it can't get IMG...
     

    Attached Files:

  18. Just remove this to GUI method
    Code:
    AddImage("IMAGE URL HERE", "IMAGE_NAME_HERE", "SKIN OR ID IF APPLICABLE"); //Add AS MANY OF THESE AS YOU WANT... The IMAGE NAME SHOULD BE IN A GetImage(Somewhere in the mod...)
        }
    Can fix NO LOGO issue :)
     
  19. Can U add OnImageDownloaded(string shortname) hook to 3rd plugins?
     
  20. Some time..
     

    Attached Files: