Skip to content

Commit

Permalink
Merge branch 'master' into uploader-animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Laukei committed Mar 19, 2018
2 parents 01fc492 + 30c3ba4 commit 681e47a
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 88 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,9 @@ render_test.py
test

logs/
*.log*
*.log*

dev/

tests/reference_images
tests/reference_saves
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ Assets for image generation go in `sdv\assets\[subfolder]`. Assets used as-is go

## Acknowledgements

Thanks to Leonardo Francisco ([email protected]) for contributing the Brazilian Portuguese translation, and thanks to Yiming Wang ([email protected]) for contributing the Chinese translation.
Thanks to Leonardo Francisco ([email protected]) for contributing the Brazilian Portuguese translation, thanks to Yiming Wang ([email protected]) for contributing the Chinese translation, and thanks to Jhordi Rodriguez ([email protected]) for contributing and improving the Spanish translation.
3 changes: 3 additions & 0 deletions sdv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,8 @@ def operate_on_url(url,instruction):
return _op_toggle_boolean_param(url,'private',True)
g.error = _("Unknown or insufficient credentials")
return render_template("error.html", **page_args())
elif request.method == 'GET' and url == '.well-known':
return redirect(url_for('static',filename='.well-known/{}'.format(instruction)))
else:
return redirect(url_for('display_data',url=url))

Expand Down Expand Up @@ -2279,5 +2281,6 @@ def get_votes(url):
else:
return None


if __name__ == "__main__":
app.run()
49 changes: 31 additions & 18 deletions sdv/farmInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
'Combat'
]


# Check adj. tiles for all tiles on map to determine orientation. Uses bit mask to select correct tile from spritesheet
def checkSurrounding(tiles):
floor_map = [[None for a in range(80)] for b in range(65)]
Expand Down Expand Up @@ -41,7 +42,8 @@ def checkSurrounding(tiles):
current_tile = None
try:
if floor_map[y + dy][x + dx] is not None:
if tile.name == 'Flooring' or (tile.name == 'Fence' and not tile.growth):
if tile.name == 'Flooring' or (
tile.name == 'Fence' and not tile.growth):
if floor_map[y + dy][x + dx].type == tile.type:
a += b
else:
Expand Down Expand Up @@ -71,11 +73,10 @@ def getFarmInfo(saveFile):

root = saveFile.getRoot()


# Farm Objects

s = []
farm_location = get_location(root,'Farm')
farm_location = get_location(root, 'Farm')
for item in farm_location.find('objects').iter("item"):
f = False
obj = item.find('value').find('Object')
Expand Down Expand Up @@ -129,7 +130,7 @@ def getFarmInfo(saveFile):
s = None
loc = None
f = False
name = item.find('value').find('TerrainFeature').get(ns+'type')
name = item.find('value').find('TerrainFeature').get(ns + 'type')
if name == 'Tree':
t = int(item.find('value').find('TerrainFeature').find('treeType').text)
s = int(item.find('value').find('TerrainFeature').find('growthStage').text)
Expand Down Expand Up @@ -164,11 +165,12 @@ def getFarmInfo(saveFile):
crop_dead = False
if crop.find('dead').text == 'true':
crop_dead = True
crops.append(sprite('HoeDirtCrop', crop_x, crop_y, 1, 1, crop_dead, crop_location, crop_phase, crop_flip, o))
crops.append(sprite('HoeDirtCrop', crop_x, crop_y, 1, 1, crop_dead, crop_location,
crop_phase, crop_flip, o))
if name == "FruitTree":
t = int(item.find('value').find('TerrainFeature').find('treeType').text)
s = int(item.find('value').find('TerrainFeature').find('growthStage').text)
if item.find('value').find('TerrainFeature').find('flipped').text == 'true': f= True
if item.find('value').find('TerrainFeature').find('flipped').text == 'true': f = True
if name == "Grass":
t = int(item.find('value').find('TerrainFeature').find('grassType').text)
s = int(item.find('value').find('TerrainFeature').find('numberOfWeeds').text)
Expand All @@ -192,11 +194,28 @@ def getFarmInfo(saveFile):
except:
pass

# Large Terrain Features

large_terrain_features = []
for ltf in farm_location.find('largeTerrainFeatures'):
name = ltf.get(ns + 'type')
flipped = ltf.find('flipped').text == 'true'
size = int(ltf.find('size').text)
x = int(ltf.find('tilePosition').find('X').text)
y = int(ltf.find('tilePosition').find('Y').text)
tile_sheet_offset = int(ltf.find('tileSheetOffset').text)

large_terrain_features.append(
sprite(name, x, y, 1, 1, tile_sheet_offset, None, size, flipped, None)
)

farm['largeTerrainFeatures'] = large_terrain_features

# Resource Clumps
s = []

for item in farm_location.find('resourceClumps').iter('ResourceClump'):
name = item.get(ns+'type')
name = item.get(ns + 'type')
if name is None:
name = 'ResourceClump'
t = int(item.find('parentSheetIndex').text)
Expand Down Expand Up @@ -230,7 +249,7 @@ def getFarmInfo(saveFile):

hasGreenhouse = False
try:
community_center = get_location(root,'CommunityCenter')
community_center = get_location(root, 'CommunityCenter')
cats = community_center.find('areasComplete').findall('boolean')
if cats[0].text == 'true':
hasGreenhouse = True
Expand Down Expand Up @@ -264,7 +283,7 @@ def colourBox(x, y, colour, pixels, scale=8):
for i in range(scale):
for j in range(scale):
try:
pixels[x*scale + i, y*scale + j] = colour
pixels[x * scale + i, y * scale + j] = colour
except IndexError:
pass
return pixels
Expand Down Expand Up @@ -337,21 +356,15 @@ def generateImage(data):
elif tile.type == 600:
for i in range(tile[3]):
for j in range(tile[3]):
colourBox(tile.x+i, tile.y + j, (75, 75, 75), pixels)
colourBox(tile.x + i, tile.y + j, (75, 75, 75), pixels)
return image


def regenerateFarmInfo(json_from_db):
sprite = namedtuple('Sprite', ['name', 'x', 'y', 'w', 'h', 'index', 'type', 'growth', 'flipped', 'orientation'])
sprite = namedtuple('Sprite', ['name', 'x', 'y', 'w', 'h', 'index', 'type', 'growth', 'flipped',
'orientation'])

for key in json_from_db['data'].keys():
for i, item in enumerate(json_from_db['data'][key]):
json_from_db['data'][key][i] = sprite(*item)
return json_from_db


def main():
generateImage(getFarmInfo('./saves/Crono_116230451')).save('farm.png')

if __name__ == '__main__':
main()
Loading

0 comments on commit 681e47a

Please sign in to comment.