Skip to content

Commit

Permalink
0.6.1.4, fixed disappearing icons, off screen rebound.
Browse files Browse the repository at this point in the history
  • Loading branch information
JavidPack committed Jun 1, 2018
1 parent c00dd33 commit 6aa8219
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 4 deletions.
14 changes: 12 additions & 2 deletions ItemCatalogueUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,12 @@ private Texture2D StackResizeImage(Texture2D[] texture2D, int desiredWidth, int
}
Main.spriteBatch.End();
Main.instance.GraphicsDevice.SetRenderTarget(null);
return renderTarget;

Texture2D mergedTexture = new Texture2D(Main.instance.GraphicsDevice, desiredWidth, desiredHeight);
Color[] content = new Color[desiredWidth * desiredHeight];
renderTarget.GetData<Color>(content);
mergedTexture.SetData<Color>(content);
return mergedTexture;
}

private Texture2D ResizeImage(Texture2D texture2D, int desiredWidth, int desiredHeight)
Expand All @@ -867,7 +872,12 @@ private Texture2D ResizeImage(Texture2D texture2D, int desiredWidth, int desired

Main.spriteBatch.End();
Main.instance.GraphicsDevice.SetRenderTarget(null);
return renderTarget;

Texture2D mergedTexture = new Texture2D(Main.instance.GraphicsDevice, desiredWidth, desiredHeight);
Color[] content = new Color[desiredWidth * desiredHeight];
renderTarget.GetData<Color>(content);
mergedTexture.SetData<Color>(content);
return mergedTexture;
}
}

Expand Down
77 changes: 77 additions & 0 deletions Localization/UpdateLocalizationFiles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import os.path

# tModLoader .lang file updater by jopojelly. (v1.0)
# Run this script after updating en-US.lang with new keys. python 3.
# Also make sure the file encodings are UTF-8 not UTF-8-BOM.
# You can use this script for your own mod if you credit me.

filename = './{0}.lang'

languages = ['zh-Hans', 'ru-RU', 'pt-BR', 'pl-PL', 'it-IT', 'fr-FR', 'es-ES', 'de-DE']
missings = []
for language in languages:
if not os.path.isfile(filename.format(language)):
with open(filename.format(language), 'w', encoding='utf-8') as output:
output.write("# Translation by: \n\nmissing=missing")
#continue
#language = 'zh-Hans'
otherLanguage = ''
missing = 0
#print("Updating:",language)
with open(filename.format('en-US'), 'r', encoding='utf-8') as english, open(filename.format(language), 'r', encoding='utf-8') as other:
enLines = english.readlines()

# Preserve Credits (comment lines on first few lines)
otherLinesAll = other.readlines()

for otherLine in otherLinesAll:
if otherLine.startswith('#'):
otherLanguage += otherLine
else:
break

# Skip empty whitespace and comment lines to end up with only json lines.
otherLines = [x for x in otherLinesAll if not (x.startswith("#") or len(x.strip()) == 0)]

if len(otherLines) == 0:
otherLines.append('TrashEntry') # just to prevent Index out of Range
otherIndex = 0
engComments = True
for englishIndex, englishLine in enumerate(enLines):
if englishLine.startswith('#') and engComments:
continue
if len(englishLine.strip()) == 0 and engComments:
engComments = False

# For lines with key values pairs, copy translation or add commented translation placeholder.
if englishLine.find("=") != -1:
if otherLines[otherIndex].startswith(englishLine[:englishLine.find("=")]):
otherLanguage += otherLines[otherIndex]
otherIndex += 1
else:
otherLanguage += "# " + englishLine.strip() + '\n'
missing += 1
# Add English Comments back in
elif englishLine.strip().startswith('#'):
otherLanguage += englishLine
# Add other json lines in. Also add in whitespace lines.
else:
otherLanguage += englishLine
if len(englishLine.strip()) > 0:
otherIndex += 1
#print(otherLanguage)
# Save changes.
if missing > 0:
missings.append( (language, missing) )
print(language,missing)
with open(filename.format(language), 'w', encoding='utf-8') as output:
output.write(otherLanguage)

with open('./TranslationsNeeded.txt', 'w', encoding='utf-8') as output:
if len(missings) == 0:
output.write('All Translations up-to-date!')
else:
for entry in missings:
output.write(str(entry[0]) + " " + str(entry[1]) + "\n")
#print("Make sure to run Diff.")
#input("Press Enter to continue...")
10 changes: 9 additions & 1 deletion RecipeBrowserUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ internal void UpdateFavoritedPanel()
{
if (i != Main.myPlayer && Main.player[i].active)
{
foreach (var recipeIndex in Main.player[i].GetModPlayer<RecipeBrowserPlayer>().favoritedRecipes)
foreach (var recipeIndex in Main.player[i].GetModPlayer<RecipeBrowserPlayer>().favoritedRecipes) // Collection was modified potential with receiving other player starred recipes?
{
Recipe r = Main.recipe[recipeIndex];
UIRecipeProgress s = new UIRecipeProgress(recipeIndex, r, order, i);
Expand Down Expand Up @@ -401,6 +401,14 @@ public override void Update(GameTime gameTime)
{
base.Update(gameTime);
// additional updates.
if (!mainPanel.GetDimensions().ToRectangle().Intersects(GetDimensions().ToRectangle()))
{
var parentSpace = GetDimensions().ToRectangle();
mainPanel.Left.Pixels = Utils.Clamp(mainPanel.Left.Pixels, 0, parentSpace.Right - mainPanel.Width.Pixels);
mainPanel.Top.Pixels = Utils.Clamp(mainPanel.Top.Pixels, 0, parentSpace.Bottom - mainPanel.Height.Pixels);
mainPanel.Recalculate();
}

recipeCatalogueUI.Update();
itemCatalogueUI.Update();
bestiaryUI.Update();
Expand Down
2 changes: 1 addition & 1 deletion build.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
author = jopojelly
version = 0.6.1.3
version = 0.6.1.4
displayName = Recipe Browser
homepage = https://forums.terraria.org/index.php?threads/recipe-browser.62462/
buildIgnore = .vs\*, Properties\*, *.csproj, *.user, obj\*, bin\*, *.config, unused\*, .git\*,
Expand Down

0 comments on commit 6aa8219

Please sign in to comment.