Skip to content

Commit d776014

Browse files
committed
release 18.2.0
world render minimap size is relative
1 parent 33c0d1f commit d776014

File tree

6 files changed

+34
-44
lines changed

6 files changed

+34
-44
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Current version : 18.1.2, for Terraria 1.3.0.7 on Windows and Linux.
1+
Current version : 18.2.0, for Terraria 1.3.0.7 on Windows and Linux.
22

33
On the Terraria Forums:
44
[Link](http://forums.terraria.org/index.php?threads/omnitool-world-creation-mapping-backups-and-more.14664/)

omnisetup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
description="Omnitool",
2222
executables=[EXE],
2323
options={"build_exe": {"excludes": ["OpenGL", "tkinter", "tcl"],
24-
"packages": ["multiprocessing"],
25-
"includes" : ("loadbar","colorsys")}
24+
"packages": ["Language"],
25+
"includes" : ()}
2626
}
2727
)
2828

render.py

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import numpy
55
from tinterface import *
66
from concurrent.futures import ThreadPoolExecutor
7-
minimap_limits = 400,300
7+
minimap_limits = 0.4,0.2
8+
defaultres = [1024, 768]
89

910

1011

@@ -89,6 +90,19 @@ def load_content(imagename):
8990
return tex, walltex, npc_tex, air, gborder, rborder, gfill, rfill
9091

9192

93+
def adjust_minimap(target_rel_size, resolution, base_image):
94+
mi_size = base_image.get_size()
95+
mi_scale = 1
96+
scaled_limits = [x*y for x,y in zip(minimap_limits, resolution)]
97+
if mi_size[0] > scaled_limits[0]:
98+
mi_scale = 1/(mi_size[0]/scaled_limits[0])
99+
if mi_size[1] > scaled_limits[1]:
100+
mi_scale = min(1/(mi_size[1]/scaled_limits[1]), mi_scale)
101+
if mi_scale != 1:
102+
print("Scaling minimap with factor "+str(mi_scale))
103+
mapimage = pygame.transform.rotozoom(base_image, 0, mi_scale)
104+
105+
return mapimage, mi_scale
92106

93107
def run(header, path, mapping, data, mappingfolder = None):
94108
header, pos = data
@@ -98,16 +112,8 @@ def run(header, path, mapping, data, mappingfolder = None):
98112
texture_loader = threadpool.submit(load)
99113
try:
100114
imageloc = get_myterraria() / "WorldImages" / path.with_suffix('.png').name
101-
mapimage = pygame.image.load(str(imageloc))
102-
mi_size = mapimage.get_size()
103-
mi_scale = 1
104-
if mi_size[0] > minimap_limits[0]:
105-
mi_scale = 1/(mi_size[0]/minimap_limits[0])
106-
if mi_size[1] > minimap_limits[1]:
107-
mi_scale = min(1/(mi_size[1]/minimap_limits[1]), mi_scale)
108-
print("Scaling minimap with factor "+str(mi_scale))
109-
if mi_scale != 1:
110-
mapimage = pygame.transform.rotozoom(mapimage, 0, mi_scale)
115+
base_image = pygame.image.load(str(imageloc))
116+
mapimage, mi_scale = adjust_minimap(minimap_limits, defaultres, base_image)
111117
mi_size = mapimage.get_size()
112118

113119
except:
@@ -121,7 +127,7 @@ def run(header, path, mapping, data, mappingfolder = None):
121127
f.seek(pos)
122128
get = get_tile_buffered_12_masked if header["version"] > 100 else get_tile_buffered
123129
pygame.display.set_caption("Loading World..")
124-
loadbar_width = minimap_limits[0]
130+
loadbar_width = 200
125131
if mapimage:
126132
if mi_size[0] > 200:loadbar_width = mi_size[0]
127133
surface = pygame.display.set_mode((loadbar_width, 20+mi_size[1]))
@@ -132,9 +138,7 @@ def run(header, path, mapping, data, mappingfolder = None):
132138
if not skip:
133139
print("loading and converting world data")
134140

135-
b = [0]
136141
rect = pygame.Rect(0, 0, 0, 20)
137-
nw = 0
138142
tup = (rect,)
139143
tiles = numpy.empty((header["width"], header["height"]), dtype=tuple)
140144
w, h = header["width"], header["height"]
@@ -144,9 +148,8 @@ def run(header, path, mapping, data, mappingfolder = None):
144148
data, b = get(f)
145149
tiles[xi, yi:yi+b] = (data,)*b
146150
yi+=b
147-
nw = int(minimap_limits[0] * xi / w)
148-
if nw != rect.w:
149-
rect.w = nw
151+
if xi % 16 == 0:
152+
rect.w = int(xi*loadbar_width/w)
150153
pygame.draw.rect(surface, (200, 200, 200), rect)
151154
pygame.display.update(tup)
152155

@@ -156,21 +159,8 @@ def run(header, path, mapping, data, mappingfolder = None):
156159
import sys
157160
sys.exit()
158161

159-
#chests = [get_chest(f) for x in range(1000)]
160-
#signs = [get_sign(f) for x in range(1000)]
161-
#print (chests)
162162
npcs = []
163-
#while 1:
164-
# npc = get_npc(f)
165-
# if not npc: break
166-
# else: npcs.append(npc)
167-
#names = get_npc_names(f)
168-
#print (names, npcs)
169-
#trail = get_trail(f)
170-
#if trail[0] and trail[1] == header["name"] and trail[2] == header["ID"]:
171-
# print ("World Signature test passed")
172-
#else:
173-
# print ("World Signature test failed, information possibly corrupted")
163+
174164
f.close()
175165

176166
rmap = numpy.random.randint(3, size=(header["width"], header["height"]))
@@ -194,7 +184,7 @@ def run(header, path, mapping, data, mappingfolder = None):
194184
area = [1600, 1600]
195185
os.chdir("..")
196186
else:
197-
res = [1024, 768]
187+
res = list(defaultres)
198188
dis = pygame.display.set_mode(res, pygame.RESIZABLE)
199189
s = pygame.surface.Surface(res)
200190
def relmove(rel):
@@ -263,6 +253,8 @@ def relmove(rel):
263253
res = event.size
264254
dis = pygame.display.set_mode(res, pygame.RESIZABLE)
265255
s = pygame.surface.Surface(res)
256+
mapimage, mi_scale = adjust_minimap(minimap_limits, res, base_image)
257+
mi_size = mapimage.get_size()
266258
dirty.append(pygame.rect.Rect(0, 0, res[0], res[1]))
267259
elif event.type == pygame.MOUSEBUTTONDOWN:
268260
if mapimage and event.button == 1:
@@ -333,10 +325,8 @@ def relmove(rel):
333325
return
334326

335327
if (mx + 1) * area[0] > wi and not (mx * area[0] > wi):
336-
337328
res[0] = -mx * area[0] + wi
338329
if (my + 1) * area[1] > he and not (my * area[1] > he):
339-
340330
res[1] = -my * area[1] + he
341331

342332
dirty = [pygame.rect.Rect(0, 0, res[0], res[1])]
@@ -349,7 +339,7 @@ def relmove(rel):
349339
dirty = []
350340
dis.blit(s, (0,0))
351341
if mapimage:
352-
dis.blit(mapimage, (res[0]-mi_size[0], 1))
342+
dis.blit(mapimage, (res[0]-mi_size[0], 0))
353343
#draw minimap viewport borders:
354344
bpos = pos[0]//16, pos[1]//16
355345
topleft = bpos[0]*mi_scale+res[0]-mi_size[0], bpos[1]*mi_scale
@@ -363,14 +353,14 @@ def relmove(rel):
363353

364354

365355
if __name__ == "__main__":
366-
worlds = get_worlds(False)
356+
worlds = list(get_worlds(False))
367357
b = {}
368358
x = 0
369359
for w in worlds:
370360
with w.open( "rb") as f:
371361
header = get_header(f)[0]
372362
b[w] = header, f.tell()
373-
name = header["name"]
363+
name = header["name"].decode()
374364

375365
print(x, ":", name)
376366
x += 1
@@ -381,4 +371,4 @@ def relmove(rel):
381371
image = True
382372
else:
383373
image = False
384-
run(os.path.join(path, world), image, b[world])
374+
run(str(world), image, b[world])

setup.iss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
33

44
#define MyAppName "Omnitool"
5-
#define MyAppVersion "18.1.2"
5+
#define MyAppVersion "18.2.0"
66
#define MyAppPublisher "Fabian Dill"
77
#define MyAppURL "http://forums.terraria.org/index.php?threads/omnitool-world-creation-mapping-backups-and-more.14664/"
88
#define MyAppExeName "omnitool.exe"

setup64.iss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
33

44
#define MyAppName "Omnitool"
5-
#define MyAppVersion "18.1.2"
5+
#define MyAppVersion "18.2.0"
66
#define MyAppPublisher "Fabian Dill"
77
#define MyAppURL "http://forums.terraria.org/index.php?threads/omnitool-world-creation-mapping-backups-and-more.14664/"
88
#define MyAppExeName "omnitool.exe"

shared.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
__all__ = ("__version__", "appdata", "cachepath", "cache", "lang", "theme")
66

7-
__version__ = Version(180102)
7+
__version__ = Version(180200)
88
appdata = appdirs.user_config_dir('omnitool', "", roaming = True)
99
cachepath = os.path.join(appdata, "cache.dill")
1010
#filled in by omnitool.py:

0 commit comments

Comments
 (0)