after learning to use Designer, which allows you to see results almost as soon as you start working with it, I decided to try to learn Hollywood itself.
I've written this script as a GUI to use icon2PNG (console program for MorphOS). It is pretty simple right now but does the work: lets you select an icon, select an output name and path, and convert it to PNG format, in dual mode.
I post it here because I want to ask about improvements and maybe other's suggestions can help to go from this simple stage to a more feature complete and complex script and the thread can end beeing like some sort of tutorial itself that can help other newbies like myself.
So for a start, what do you think about it? Is it too long for what it does? Messy? And the first problem I need to solve: how to clear the path printed with DisplayTextObject when selecting another input or output.
Here is the script:
Code: Select all
@APPTITLE "Icon2PNG GUI"
@APPDESCRIPTION "A simple GUI for icon2png."
@DISPLAY {Title="Icon2PNG GUI", Width=450, Height=300, Color=$959595, Mode="Windowed", NoModeSwitch=TRUE}
@BRUSH 1, "drawerpic.png", {LoadAlpha=TRUE, ScaleWidth="50%", ScaleHeight="50%"} ;loads the drawer picture
/* Global part */
EnableLayers()
SetFontColor(#BLACK)
GLOBAL icon_input$ ;stores path of icon to convert
GLOBAL png_output$ ;stores path of converted icon
GLOBAL icon_mode$="DUAL" ;stores dual or simple mode option
GLOBAL commandline$ ;command and parameters to run icon2png
CreateTextObject(1, "Select input")
CreateTextObject(2, "Select output")
CreateTextObject(3, "Mode: dual")
CreateTextObject(4, "Convert")
CreateTextObject(5, "Quit")
/* Functions */
Function p_Input()
SetFontColor(#WHITE)
icon_input$=FileRequest("Select input", "*.info", #REQ_NORMAL, "RAM:", "")
CreateTextObject(6, icon_input$)
DisplayTextObject(6, 90, 98)
EndFunction
Function p_Output()
SetFontColor(#WHITE)
png_output$=FileRequest("Select output", "*.info", #REQ_NORMAL, "RAM:", "output.info")
CreateTextObject(7, png_output$)
DisplayTextObject(7, 90, 158)
EndFunction
Function p_Convert()
commandline$="icon2png".." MODE="..icon_mode$.." FROM=\""..icon_input$.."\"".." TO=\""..png_output$.."\""
Execute(commandline$)
EndFunction
Function p_End()
End()
EndFunction
/* Interface and events */
;displays text and button for input
DisplayTextObject(1, 50, 70)
DisplayBrush(1, 50, 85)
MakeButton(1, #SIMPLEBUTTON, 50, 85, 50, 50, {OnMouseUp=p_Input})
;displays text and button for output
DisplayTextObject(2, 50, 130)
DisplayBrush(1, 50, 145)
MakeButton(2, #SIMPLEBUTTON, 50, 145, 50, 50, {OnMouseUp=p_Output})
;displays selected Mode option
DisplayTextObject(3, 50, 200)
;displays Convert button
SetFillStyle(#FILLCOLOR)
Box(347, 197, 61, 13, #YELLOW, {RoundLevel=25})
DisplayTextObject(4, 350, 200)
MakeButton(3, #SIMPLEBUTTON, 347, 197, 61, 13, {OnMouseUp=p_Convert})
;displays Quit button
SetFillStyle(#FILLCOLOR)
Box(347, 247, 38, 13, #RED, {RoundLevel=25})
DisplayTextObject(5, 350, 250)
MakeButton(4, #SIMPLEBUTTON, 347, 247, 38, 13, {OnMouseUp=p_End})
EscapeQuit(TRUE)
Repeat
WaitEvent
Forever