Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
/
Browse files Browse the repository at this point in the history
  • Loading branch information
Chasmical committed Jul 15, 2020
1 parent 70bb01f commit 849cf5e
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 69 deletions.
Binary file modified .vs/RogueLibs/v16/.suo
Binary file not shown.
1 change: 0 additions & 1 deletion Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Общие сведения об этой сборке предоставляются следующим набором
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ You can find these mods in [the official Streets of Rogue Discord server](https:
* Explosion Damage x0.25/x0.5/x2/x4/x8;
* Explosion Power x0.25/x0.5/x2/x4/x8;

# RogueLibs v1.3.1 #
# RogueLibs v1.3.2 #
This modding library allows you to easily add custom mutators, items and localization lines, plus it has some extra functions that you might need.

## How to use RogueLibs in your mods ##
Expand Down
Binary file modified bin/Debug/RogueLibs.dll
Binary file not shown.
Binary file modified bin/Debug/RogueLibs.pdb
Binary file not shown.
4 changes: 4 additions & 0 deletions md/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
## Changelog ##
Here you will find all updates on RogueLibs, so you can specify your RogueLibs' version dependency better.

#### RogueLibs v1.3.2 ####
* RogueLibs source code is now available on [GitHub](https://github.com/Abbysssal/RogueLibs)!;
* Added RogueUtilities.ConvertToSprite(string filePath, int ppu) and RogueUtilities.ConvertToSprite(byte[] data, int ppu), so you can specify your image's pixel-per-unit scale;

#### RogueLibs v1.3.1 ####
* Added InvItem.CombineTooltip delegate to determine the tooltip text when combining items;

Expand Down
5 changes: 4 additions & 1 deletion md/Extras.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
With RogueUtilities class you can convert .png or .jpg files into Sprites:
```cs
public static Sprite ConvertToSprite(string filePath);
public static Sprite ConvertToSprite(string filePath, int ppu);
public static Sprite ConvertToSprite(byte[] data);
public static Sprite ConvertToSprite(byte[] data, int ppu);
```
```cs
Sprite sprite = RogueUtilities.ConvertToSprite("D:\Images\MyImage.png");
// Default pixel-per-unit value is 64
byte[] data = File.ReadAllBytes("D:\Images\MyImage.png");
byte[] data = File.ReadAllBytes("D:\Images\MyImage.png", 64);
Sprite sprite2 = RogueUtilities.ConvertToSprite(data);
```
And convert .mp3, .ogg, .wav, .aiff files into Audioclips. It is recommended to use .ogg, because other formats might not load properly:
Expand Down
Binary file modified obj/Debug/RogueLibs.csprojAssemblyReference.cache
Binary file not shown.
Binary file modified obj/Debug/RogueLibs.dll
Binary file not shown.
Binary file modified obj/Debug/RogueLibs.pdb
Binary file not shown.
11 changes: 5 additions & 6 deletions source/BaseUnityPluginExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using System.Reflection;
using System.Collections.Generic;
using BepInEx;
using HarmonyLib;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using System;
using System.Reflection;

namespace RogueLibsCore
{
Expand All @@ -30,7 +29,7 @@ public static void LogErrorWith(this BaseUnityPlugin plugin, string message, Exc
public static bool PatchPrefix(this BaseUnityPlugin me, Type type, string methodName, Type patchType, string patchMethodName, params Type[] types)
{
if (types.Length == 0)
types = null;
types = null;
MethodInfo original;
MethodInfo patch;
try
Expand Down
2 changes: 1 addition & 1 deletion source/CustomItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal CustomItem(string id)
/// <para>Text that will be displayed when targeting objects.</para>
/// </summary>
public CustomName HoverText { get; set; }

/// <summary>
/// <para>Delegate that will be used to determine whether an item can be combined with this item.</para>
/// <para><see cref="InvItem"/> arg1 is this custom item;<br/><see cref="Agent"/> arg2 is the owner of this custom item;<br/><see cref="InvItem"/> arg3 is the other item.</para>
Expand Down
3 changes: 0 additions & 3 deletions source/MessageArgs.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RogueLibsCore
{
Expand Down
10 changes: 5 additions & 5 deletions source/RogueLibs.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using System.IO;
using BepInEx;
using BepInEx.Logging;
using System;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using System.Xml;
using BepInEx;
using BepInEx.Logging;
using UnityEngine;

namespace RogueLibsCore
{
Expand Down
23 changes: 10 additions & 13 deletions source/RogueLibsPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System;
using System.IO;
using System.Collections.Generic;
using BepInEx;
using BepInEx;
using BepInEx.Logging;
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.UI;
using System.Net;

namespace RogueLibsCore
{
Expand All @@ -28,8 +27,6 @@ protected void Awake()
string dataPath = Path.Combine(Paths.ConfigPath, "RogueLibs2.xml");
RogueLibs.Instance.Start(dataPath);

if (File.Exists(Path.Combine(Paths.ConfigPath, "AbbLabs.xml")))
File.Delete(Path.Combine(Paths.ConfigPath, "AbbLabs.xml"));
if (File.Exists(Path.Combine(Paths.ConfigPath, "RogueLibs.xml")))
File.Delete(Path.Combine(Paths.ConfigPath, "RogueLibs.xml"));

Expand All @@ -39,13 +36,13 @@ protected void Awake()
protected void MakePatches()
{
RoguePatcher patcher = new RoguePatcher(this, GetType());

patcher.Postfix(typeof(ScrollingMenu), "MakeButtonsVisible");

patcher.Postfix(typeof(NameDB), "GetName");
patcher.Postfix(typeof(ScrollingMenu), "SortUnlocks");
patcher.Postfix(typeof(ScrollingMenu), "PushedButton");

patcher.Prefix(typeof(ObjectMult), "ShowChatCommand");

patcher.Postfix(typeof(InvItem), "SetupDetails");
Expand Down Expand Up @@ -99,7 +96,7 @@ protected static void ScrollingMenu_SortUnlocks(ScrollingMenu __instance, string
cancellations = new List<string>(mutator.Conflicting)
};
customMutators.Add(unlock);

}
//customMutators.Sort();
___listUnlocks.InsertRange(1, customMutators);
Expand Down Expand Up @@ -231,7 +228,7 @@ protected static void RandomSelection_LoadRandomness(RandomSelection __instance)
}
}

public static void InvSlot_SetColor(InvSlot __instance, Text ___itemText)
protected static void InvSlot_SetColor(InvSlot __instance, Text ___itemText)
{
/*
__instance.toolbarNumTextGo.SetActive(false);
Expand All @@ -257,7 +254,7 @@ public static void InvSlot_SetColor(InvSlot __instance, Text ___itemText)
InvItem targetItem = __instance.mainGUI.targetItem ?? __instance.database.invInterface.draggedInvItem;
if (targetItem == null) return;
InvItem thisItem = __instance.curItemList[__instance.slotNumber];

CustomItem cItem = RogueLibs.Instance.Items.Find(i => i.Id == targetItem.invItemName);
if (cItem == null || cItem.CombineFilter == null || cItem.CombineItem == null || cItem.CombineTooltip == null) return;

Expand Down
6 changes: 2 additions & 4 deletions source/RoguePatcher.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using BepInEx;
using HarmonyLib;
using BepInEx;
using System;

namespace RogueLibsCore
{
Expand Down
36 changes: 2 additions & 34 deletions source/RogueUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,7 @@ public static class RogueUtilities
/// <summary>
/// <para>Converts a .png or .jpg file into a <see cref="Sprite"/>.</para>
/// </summary>
public static Sprite ConvertToSprite(string filePath)
{
string path = Path.GetFullPath(filePath);
Sprite sprite = null;
try
{
byte[] data = File.ReadAllBytes(path);
Texture2D texture = new Texture2D(7, 8);
if (!texture.LoadImage(data))
throw new Exception();
sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero, 64);
}
catch (Exception e)
{
RogueLibs.PluginInstance.LogErrorWith("Could not load Sprite from \"" + path + "\"!", e);
}
return sprite;
}
public static Sprite ConvertToSprite(string filePath) => ConvertToSprite(filePath, 64);
/// <summary>
/// <para>Converts a .png or .jpg file into a <see cref="Sprite"/> with the specified pixel-per-unit value (default - 64).</para>
/// </summary>
Expand All @@ -57,22 +40,7 @@ public static Sprite ConvertToSprite(string filePath, int ppu)
/// <summary>
/// <para>Converts a .png or .jpg byte array into a <see cref="Sprite"/>.</para>
/// </summary>
public static Sprite ConvertToSprite(byte[] data)
{
Sprite sprite = null;
try
{
Texture2D texture = new Texture2D(14, 6);
texture.LoadImage(data);
sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero, 64);
}
catch (Exception e)
{

RogueLibs.PluginInstance.LogErrorWith("Could not load Sprite from an array of bytes!", e);
}
return sprite;
}
public static Sprite ConvertToSprite(byte[] data) => ConvertToSprite(data, 64);
/// <summary>
/// <para>Converts a .png or .jpg byte array into a <see cref="Sprite"/> with the specified pixel-per-unit value (default - 64).</para>
/// </summary>
Expand Down

0 comments on commit 849cf5e

Please sign in to comment.