Skip to content

Commit

Permalink
Fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Grim-es committed Dec 1, 2018
1 parent 31a750e commit 9c83a6e
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions operators/pngquant.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,20 @@
import os
from bpy.props import *
from subprocess import call
from .. icons import get_icon_id


class OpenBrowser(bpy.types.Operator):
bl_idname = 'smc.compress'
bl_label = 'Compress all textures'

def show_message(self, context):
def draw(self, context):
layout = self.layout
col = layout.column()
col.operator('smc.zip_download', icon_value=get_icon_id('null')
).link = 'https://pngquant.org/pngquant-windows.zip'
context.window_manager.popup_menu(draw, title='Pngquant is not installed', icon='INFO')

def execute(self, context):
scn = context.scene
pngquant = os.path.abspath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir, 'assets', 'pngquant', 'pngquant.exe'))
if os.path.isfile(os.path.join(pngquant)):
command = '"{}" -f --ext .png --skip-if-larger -v "{}"'.format(pngquant, scn.smc_save_path)
call(command, shell=True)
self.report({'INFO'}, 'Files compressed')
else:
self.show_message(context)
if not os.path.isfile(os.path.join(pngquant)):
bpy.ops.smc.zip_download(link='https://pngquant.org/pngquant-windows.zip')
command = '"{}" -f --ext .png --skip-if-larger -v "{}"'.format(pngquant, scn.smc_save_path)
call(command, shell=True)
self.report({'INFO'}, 'Files compressed')

return {'FINISHED'}

0 comments on commit 9c83a6e

Please sign in to comment.