Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
Garrakx committed Nov 19, 2020
1 parent 1e70b56 commit 49992f6
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 279 deletions.
2 changes: 1 addition & 1 deletion Custom-Regions/CustomMenu/FastTravelScreenHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private static void FastTravelScreen_InitiateRegionSwitch(On.Menu.FastTravelScre
self.currentShelter = temporalShelter;
temporalShelter = null;
}
string shelter = self.currentShelter != null ? self.currentShelter : string.Empty;
string shelter = self.currentShelter ?? string.Empty;
CustomWorldMod.Log($"Initiate Region switch, called from Fast Travel ctor... [{shelter}]");
int num = 0;
string[] array = File.ReadAllLines(string.Concat(new object[]
Expand Down
2 changes: 1 addition & 1 deletion Custom-Regions/CustomMenu/SlugcatSelectMenuHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private static void SlugcatSelectMenu_ctor(On.Menu.SlugcatSelectMenu.orig_ctor o
orig(self, manager);

int saveSlot = self.manager.rainWorld.options.saveSlot;
if (CustomWorldMod.saveProblems[saveSlot].anyProblems)
if (CustomWorldMod.saveProblems[saveSlot].AnyProblems)
{
bool allNewGame = true;
string errorText = CustomWorldMod.Translate("Problems found in your save, please check the tab SaveAnalyzer in the config screen for more information.");
Expand Down
89 changes: 1 addition & 88 deletions Custom-Regions/Mod/CRExtras.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,6 @@

namespace CustomRegions.Mod
{
// MOVE ALL THE EXTERNAL METHODS HERE
static class CRExtras
{
/*
string path = Custom.RootFolderDirectory() + CustomWorldMod.resourcePath +
CustomWorldMod.availableRegions.ElementAt(i).Value.folderName + Path.DirectorySeparatorChar + "thumb.png";
using (WWW www = new WWW(path))
{
yield return www;
www.LoadImageIntoTexture(tex);
}
*/
static IEnumerator Start(string url, Texture2D tex)
{
tex = new Texture2D(160, 175, TextureFormat.DXT1, false);
using (WWW www = new WWW(url))
{
yield return www;
www.LoadImageIntoTexture(tex);
//GetComponent<Renderer>().material.mainTexture = tex;
}
}
}

public class ThumbnailDownloader : MonoBehaviour
{
Expand All @@ -54,7 +30,7 @@ public void Init(Dictionary<string, string> thumbInfo)
{
if (thumbInfo == null || thumbInfo.Count < 1)
{
CustomWorldMod.Log("Error creating thumbnail downloader", true);
CustomWorldMod.Log("Error creating thumbnail downloader, thumbnail not found", true);
this.readyToDelete = true;
return;
}
Expand Down Expand Up @@ -150,69 +126,6 @@ internal void Create()
}


// SOURCE: AUTOUPDATE
// AUTHOR: BEE
/*
public class DownloadScript : MonoBehaviour
{
public PartialityMod mod;
public string path;
public WWW www;
public bool ready;
public bool done;
public string filename;
public void Initialize(AutoUpdateMod au, PartialityMod mod, string path, string url, string filename)
{
this.au = au;
this.mod = mod;
this.path = path + Path.DirectorySeparatorChar + filename;
this.www = new WWW(url);
this.ready = true;
this.done = false;
this.filename = filename;
}
public void Update()
{
if (this.ready && this.www.isDone)
{
//File.WriteAllBytes(this.path, this.www.bytes);
if (CustomWorldMod.www.isDone && !CustomWorldMod.complete)
{
Debug.Log("Dowloading thumb..");
Texture2D tex;
tex = new Texture2D(4, 4, TextureFormat.DXT1, false);
www.LoadImageIntoTexture(tex);
byte[] file = tex.EncodeToPNG();
File.WriteAllBytes(path, file);
Debug.Log("Thumb downloaded " + path);
}
lock (this.au.otherLockObj)
{
if (File.Exists(this.path))
{
this.au.actuallyUpdated = true;
}
this.au.needUpdate.Remove(this.mod);
if (this.au.needUpdate.Count == 0)
{
Debug.Log("Calling Done");
this.au.Done();
}
}
this.ready = false;
}
}
}
*/



// Only works on ARGB32, RGB24 and Alpha8 textures that are marked readable

// SOURCE: http://wiki.unity3d.com/index.php/TextureScale#Usage
Expand Down
Loading

0 comments on commit 49992f6

Please sign in to comment.