UnderwareDESIGN

PlayBASIC => Show Case => Topic started by: kevin on May 04, 2010, 04:21:51 PM

Title: PlayPackager (WIP THREAD)
Post by: kevin on May 04, 2010, 04:21:51 PM

(http://www.underwaredesign.com/PlayBasicSig.png)

 Visit www.PlayBasic.com (http://www.playbasic.com)


PlayPackager (WIP THREAD)



  This thread will contain update information/ideas/changes etc that are being made to PlayPackager application.  


What is PlayPackager?

     It's tool to help PlayBASIC developers bundle their PlayBASIC games or tools  into a self extracting executables for single file distribution.    The created packaged game will then automatically decompress the games media and execute upon being launched by the end user (the player).   Allowing the end user to run the game without needing to install,  or unzip/unrar it.  



Will It Packager protect my games media ?

     No.   If you're interested in this, then I strongly recommended reading the [plink]Improving Media Security (http://www.underwaredesign.com/forums/index.php?topic=338.msg22541#msg22541)[/plink] article in the Developers Blog.



Features

    * Fast In memory & in place De-Compression
    * Very low memory foot print
    * Virtually zero execution overhead
    * Compatible with PlayBASIC
    * FREE FOR PLAYBASIC RETAIL users .




Beta (Work In Progress) Downloads


     None.



Related Articles


     * PlayBASIC V1.64O Includes Media Binding (loading media from memory) (http://www.underwaredesign.com/forums/index.php?topic=3988.0)

Title: Re: PlayPackager (WIP THREAD)
Post by: kevin on May 04, 2010, 05:28:02 PM
 
PlayPackager V0.03 - Building A GUI Console


     While this application has only been under development for a few days now,  the core functionality is already in place and would appear to be stable.  All that stands in the way of a release now (as always) is setting up a simple user interface and building a version of the package.    

     Like all in house PlayBASIC helper tools, the PlayPackager compiler is being built in PlayBASIC.    While there's various custom & windows gui  options for PB, I tend to prefer building everything in PB wherever possible.  It just removes external dependencies.   For this tool, we really don't need too much in the way of GUI.   A menu and a console window.     The menu stuff is easily covered as is the console really, but i've always wanted to build little console library with some simple hyper text support.  So that's what I thought i'd have a little go at.

    The library is pretty simple  and at this point it just allows the user to create various consoles then output text to them.    The library itself handles the data management.  You just create a console, the  use cprint("Text")  to drop something into it.   In the current version rendering is separated from the printing.   This is helpful when drawing to a surface with backdrop picture for example.

     The only interesting thing about the lib at this point, is that the render console supports some simple hyper text tags in the output text.   While there's only a few of them currently  (Ink,Shadow,HR, UnderLine, it should help the making the displayed text copy (when in PlayPackager) be both a little more visually appealing, and easier to notice any ERROR messages.  

      Anyway, bellow is piccy of console view with some various overlaps tidbits..   Since it's really just some text on the screen.. real 1980's stuff :)

   
    This is the demo code, without the console library.   The demo code mainly cut and pasted from source code board (http://www.underwaredesign.com/forums/index.php?board=12.0) examples.

[pbcode]

   loadfont Path$+"Fonts\Arial20.crf",1,0,0
   FontDrawMode 1,1

   loadfont Path$+"\Fonts\Arial36.crf",2,0,0
   FontDrawMode 2,1

   Tempimage   =LoadNewAfxImage(path$+"gfx\PlayBasicSig.png")
   ScaleImage TempImage,0.75,0.75,2
   Global Image_PBLogo_original   =Make_Mirror_Image(TEmpImage,60)
   Global Image_PBLogo            =GetFreeImage()
   CopyImage Image_PBLogo_original,Image_PBLogo
      

   global Screen      =Newfximage(800,600)
   global BackDrop   =Newfximage(800,600)

   w=792

   // Colours
   c1   =rgb(51,53,74)
   c2   =rgb(50,100,150)   
   c1=rgbfade(c2,70)
   c2=c1
   
   // Console Screen View port
   BoarderRadius=32
   BoarderWidth=800   

   global IMage_Console_Backdrop   =MakeBorderedBox(w,580,BoarderRadius,c1,c2)
   global IMage_Console            =MakeBorderedBox(w,580,BoarderRadius,c1,c2)

   rendertoimage Backdrop

   c1= rgb(50,100,200)
   c2= rgb(50,200,100)
   c1=$00203040
   c2=$004060a0
   shadebox 0,000,800,300,c1,c1,c2,c2
   shadebox 0,300,800,600,c2,c2,c1,c1

   Xpos=(GetScreenWidth()-BoarderWidth)/2
   Xpos=4

   rendertoimage IMage_Console
   ThisImage=IMage_Console
   r=BoarderRadius*0.75
   w=getImageWidth(thisImage)-r
   h=getImageHeight(thisImage)-r   
   ImageViewport  Thisimage,r,r,w,h

   // Create a scroller   
   NewScroller()


   rendertoimage IMage_Console_Backdrop

   ink argb(128,100,100,100)
   setfont 2
   centertext 660,520,"Text Console:"
   


   setfont 1
   SetFps 50

   RefreshScroller=true
   
   
   xx=850
   xx2=xx*2

   Do

      if RefreshScroller=true
         copyrect IMage_Console_Backdrop,0,0,1000,1000,IMage_Console,0,0
         RefreshScroller=false
         rendertoimage IMage_Console
         DrawScroller()
      endif
      
      rendertoimage screen
      Drawimage Backdrop,0,0,false

      Scale#=1.5+CosRadius(Angle#,0.7)
      Angle#=wrapangle(Angle#,2)

      DrawZoomedImage(IMage_Console,400,304,Scale#)
      
      
      if spacekey() or rnd(1000)>990
               ; set default ink colour               
               ink $c0808080   ;aaaaaa   ;ffdfdf
               Select rnd(5)
                  case 0
                     sprint("Normal 'Hello World' text")
                  case 1
                     sprint("[ink=$ffFF0000]Some Red Text     [ink=$ff00ff00]Green Text")

                  case 2
                     sprint("[ink=$ffff0000][hr=2]")

                  case 3
                     sprint("This is a line of underlined text")

                  case 4
                     sprint("[shadow=1]This is a some [ink=$ffff00ff]shadowed text")

                  case 5
                     sprint("[ink=$ffFF0000]Red Text[/ink] Default Text Colour  [ink=$ff00ff00]Green Text[/ink] and some [ink=$ff0000ff]Blue Text")


               endselect
   
               RefreshScroller=true
      endif      
      ink $ffffffff
      

      Count=Mod(Count+1,3)
      if Count=1
         CopyImage Image_PBLogo_original,Image_PBLogo
         BlurImage Image_PBLogo,8+cosradius(blurangle#,4)
         BlurAngle#=Wrapangle(BlurAngle#,20)
      endif

      DrawTintedImage(Image_PBLogo,xx,200,2,$a0ff8f8f,1+8)
      xx-=2
      if xx<-1000 then xx=1000
      
      rendertoscreen
      drawimage screen,0,0,false

      Sync
   loop





Function Make_Mirror_Image(ThisImage,MirrorSize)
   if GetImageSTatus(ThisImage) and MirrorSize >0
      OldSurface=getsurface()

         Width      =GetImageWidth(thisIMage)
         Height   =GetImageHeight(thisIMage)
   
         MirroredIMage=GetFreeImage()
         CreateFXImageEx  MirroredImage,Width,Height+MirrorSize,32
         rendertoimage MirroredImage

         DrawImage ThisImage,0,0,false
         DrawRotatedIMage ThisImage,0,Height-1,0,1,-1,0,-Height,false

         // mask the ARGB channels
         inkmode 1+2048  
            for ylp=0 to MirrorSize
               Scaler#=(MirrorSize-Ylp)   
               A=(156.0/MirrorSize)*Scaler#
               Ypos=Height+ylp
               boxc 0,ypos,Width,ypos+1,true,Argb(A,A,A,A)
            next
         inkmode 1  

      rendertoimage OldSurface

      prepareafximage MirroredImage

   endif
EndFunction  MirroredImage



Function MakeBorderedBox(Width,Height,CornerSize,ForeColourTop,ForeColourBot)

   if Width>0 and Height>0 and cornerSize>0
         oldSurface=Getsurface()         

         ThisImage=GetFreeimage()
         CreateFXIMageEx ThisImage,Width,Height,32
      
         rendertoimage ThisIMage
   
         CornerWidth=CornerSize
         CornerHeight=CornerSize
         Dim PhongMap(CornerWidth,CornerHeight)

         if CornerWidth<CornerHeight
            Dist#=CornerHeight/2
         else
            Dist#=CornerWidth/2
         endif
         Scaler#=250/Dist#

         MakePhongMap(PhongMap(),CornerWidth,CornerHeight,Scaler#,CornerWidth/2,CornerHeight/2)

         DrawArray(PhongMap(),0,0,ForeColour)

         if CornerSize<Height
            StripImage=GetFreeImage()
            GetImage StripIMage,0,CornerHeight/2,CornerWidth,CornerHeight
            for ylp=CornerHeight/2 to Height-CornerHeight/2
               DrawImage StripImage,0,ylp,false
            next
            Deleteimage StripImage
         endif

         StripImage=GetFreeImage()
         getimage StripIMage,CornerWidth/2,0,CornerWidth,Height
   
         EndImage=GetFreeImage()
         getimage EndIMage,CornerWidth/2,0,CornerWidth/2+1,Height


         for Xlp=CornerWidth/2 to Width-(CornerWidth/2)
               drawimage StripImage,Xlp,0,false
         next
         drawimage EndImage,Xlp,0,false

         inkmode 1+64
         ShadeBox 0,0,width,height,ForeColourTop,ForeColourTop,ForeColourBot,ForeColourBot
         inkmode 1

         inkmode 1+32
         c=GetInk()
         c=$ff222222
         Boxc 10,10,width-10,height-10,false,c
         Boxc 11,11,width-11,height-11,false,c
         
         inkmode 1

         deleteimage StripImage
         DEleteImage EndImage
         RenderToImage OldSurface
         prepareafximage ThisImage
   endif
EndFunction   ThisImage
   


   // Phong table
Psub MakePhongMap(PhongMap(),Width,Height,Scaler#,CenterX,CenterY)
   Dim PhongMap(Width,Height)
   For y = 0 To Height
      For x = 0 To Width
         Level#=GetDistance2D(CenterX,CenterY,x,y)*Scaler#
         PhongMap(x, y) =cliprange(255-level#,0,255)
      Next
   Next
   PhongMap(CenterX,CenterY) = 255
EndPsub


Psub DrawArray(Pixels(),Xpos,Ypos,ThisColour)
   lockbuffer
      nullpixel=point(0,0)
      inkmode 1+512
      for y=0 to getarrayelements(Pixels(),2)-1
         for x=0 to getarrayelements(Pixels(),1)-1
               Dotc Xpos+X,Ypos+Y,ARgb(Pixels(X,y),0,0,0)
         next
      next
      inkmode 1
   unlockbuffer
EndPsub


Psub DrawZoomedImage(ThisImage,Xpos,Ypos,Scale#)
      iw=getImageWidth(ThisImage)/-2.0      
      ih=getImageheight(ThisImage)/-2.0      
      if Scale#<1
            DrawRotatedImage  ThisImage,Xpos,Ypos,0,scale#,scale#,iw,ih,true+8
      else
            DrawImage  ThisImage,Xpos+iw,Ypos+ih,true
      endif      
EndPsub



Psub DrawTintedImage(Thisimage,xpos,ypos,Scale#,TintColour,DrawMode)
   TempSprite=NewSprite(xpos,ypos,ThisImage)

   Transparent   =(DrawMode &1)>0
   Filter      =(DrawMode &8)>0

   Spritedrawmode TempSprite,2
   SpriteTint TempSprite,TintColour
   SpriteTransparent TempSprite,Transparent
   if Filter
      SpriteFilter TempSprite,true
      if Transparent=off
         SpriteMaskColourCompression TempSprite, Off
      endif   
   endif

   ScaleSprite TempSprite,Scale#   
   DrawSprite Tempsprite
   Deletesprite TempSpr
EndPSub


[/pbcode]


 
Title: Re: PlayPackager (WIP THREAD)
Post by: kevin on May 05, 2010, 06:09:38 PM
 
PlayPackager V0.03 - Connecting it Together


     Since yesterdays update,  i've been merging the various bits of code into what will be come the PlayPackager tool.  There's really nothing to it from the users perspective at this point.  You run the app, then select 'build' and that's about it.     Currently the build path  is hard coded to a folder on my computer (so i don't have to constantly select it), but this will open up a folder dialog.  

     I'm in two minds actually.  The user could select the game exe directly.  From here the app could assume that the folder the exe is within is the games base folder.  So it'll archive this folder and anything within it.    While this would work for the majority of situations, there are occasions, where you might not want the exe stored in the root.  If this occurs, it'll fail.  

    The other option (and how it currently works) is that you supply the packager with the root folder of the project.   The app then archives everything inside/bellow it, the only difference is that the packager app chooses the games EXE for you.    So EXE can then be in any folder within this tree.   But there's a problem with this also.   What if the games folder structure has more than one exe file in it ?   Which one does it choose ?  - Well currently if that occurs, it'll fail :)

    The packager is designed so that you can build your packaged exe directly from your game projects source folder (as long as you store all of your games media in that location!).    So all you have to do is open your game in PB, compile this to an exe.   Then run the packager and select the games file/folder.   Don't worry,  the packager will completely ignore your SOURCE CODE / projects files and thumb nail files automatically.  


    Anyway,  here's the first amazing screen shots of this app up and running, (Yes that's sarcasm people ! ) -  it looks more like a demo at this point since the console window zooms in and out and the PB logo is scrolling across for absolutely no reason at all...   But ya get :)
Title: Re: PlayPackager (WIP THREAD)
Post by: kevin on May 07, 2010, 02:55:33 AM


PlayPackager V0.05 - Up & Running


    Today, i've been tweaking up the packager application.  Functionality wise, it's changed a little bit. Mostly to help users overcome the aforementioned catch 22.  The solution has been to give the user the option to not only select the Projects parent folder, but any EXE inside that folder which is to be the launched application.   This means the package can include more than one exe if need be.   The thinking here is for people wanting to distribute not just the game, but perhaps an editor also.

    Another change is that you now specify the output file separately from the build process.   The reason for this will the addition of the some exlusion filters.    These will allow you to exclude certain files from  being included in the output.  The exclusion list will be saved in the projects folder.  So you won't have to create the list each time.   

    Anyway,  will no doubt upload a build of the package for testing over the weekend

 
 
Title: Re: PlayPackager (WIP THREAD)
Post by: kevin on May 10, 2010, 03:04:01 AM
 PlayPackager V0.06

     Well, here's the first alpha of the package.  I haven't had a lot of computer time over the past couple of days, so it's not too dissimilar than it was when i last posted.    The main thing missing (apart from the some real world testing) would the exclusion list support.    


Download
   
  Download Play Packager V0.06 (alpha)  10th,May,2010  




Title: Re: PlayPackager (WIP THREAD)
Post by: LBFN on May 10, 2010, 03:36:02 PM
It compressed a 2.38 MB .exe to about 1.3MB for me.  I moved the compressed .exe to my desktop to test it and it worked fine.
Title: Re: PlayPackager (WIP THREAD)
Post by: kevin on May 10, 2010, 07:59:06 PM

Thanks.  Just out of curiosity is there many media files in your package ?
Title: Re: PlayPackager (WIP THREAD)
Post by: LBFN on May 11, 2010, 09:38:38 AM
Quote from: kevin on May 10, 2010, 07:59:06 PM

Just out of curiosity is there many media files in your package ?


There are 19 images that are included in the package.  All are .bmp format. No sound media at all.
Title: Re: PlayPackager (WIP THREAD)
Post by: kevin on May 14, 2010, 06:40:45 AM

PlayPackager V0.07

     Today's been the first day all week, I've had any time to do some PB related programming.    So i've been tweaking up the build/launch process a little more. As a result, the packager will only work with PlayBASIC V1.64 exe's for the time being.  Which is really not a bad thing, given it's a freebie for PlayBASIC community after all.    None the less i'll try and get a new build up on the site over the weekend.   
Title: Re: PlayPackager (WIP THREAD)
Post by: kevin on May 16, 2010, 08:10:21 AM
 PlayPackager V0.07

     Here's the second release for community testing. There's a number of small fixes/tweaks, one major change is that this version is designed for use with PlayBASIC V1.64.    So it'll only package exe's built the PlayBASIC V1.64 at this time.  



Download

    OLD FILE REMOVED

Title: Re: PlayPackager (WIP THREAD)
Post by: kevin on May 18, 2010, 09:24:06 AM

PlayPackager V0.08 - Exclusions ?

     I've been working on the adding the exclusion list feature this afternoon, like a lot of things, rolling the code to handle the internal list and do the matching was pretty straight forward.  That's not what  worries me though,  as often the underlying routines within an application are simple, it's building the interface for the user that actually gets in the way.   

     The exclusion list currently has two modes, by filename or by file type, there's a folder option partly embedded also, but that can be plugged in later. The original thinking was the just add some dialogs so the user could type or multi select from the open dialog.  But there's an issue with that features in the dialog library,  so that's out of the question.    Entering a file names by hand isn't much fun either.    So it's look like i'll have to roll something out.   Probably just a file listing of the project folder where you click on the opt out files or something.     I figure with a little tweaking the console lib be used for this purpose.   Dunno, prolly just wing it :)


   
Title: Re: PlayPackager (WIP THREAD)
Post by: LBFN on May 18, 2010, 10:01:24 AM
I would like to help provide some feedback on this, but I am getting the 'Couldn't locate linker' error when I compile and I cannot find an .exe on my computer anywhere.  I searched the forum about this problem, but I don't see a resolution.
Title: Re: PlayPackager (WIP THREAD)
Post by: kevin on May 18, 2010, 10:05:22 AM

Sounds like you've failed to install an update correctly....
Title: Re: PlayPackager (WIP THREAD)
Post by: LBFN on May 18, 2010, 10:20:42 AM
I have tried twice to re-install the PBFX 1.76 update.  I moved all of the files from it to replace the existing files, but I get the same error.
Title: Re: PlayPackager (WIP THREAD)
Post by: kevin on May 18, 2010, 10:25:07 AM

The upgrade process is listed here (http://www.underwaredesign.com/forums/index.php?topic=1602.0).   Install base edition, the install upgrade over it.

PlayPackager can not be used with PBFX .. 
Title: Re: PlayPackager (WIP THREAD)
Post by: LBFN on May 18, 2010, 10:46:42 AM
post deleted
Title: Re: PlayPackager (WIP THREAD)
Post by: kevin on May 19, 2010, 10:52:06 AM

QuoteI believe I have completed the upgrade properly

    Nah, that's why you're getting the error above. 
Title: Re: PlayPackager (WIP THREAD)
Post by: LBFN on May 19, 2010, 12:43:56 PM
post deleted
Title: Re: PlayPackager (WIP THREAD)
Post by: Big C. on May 19, 2010, 01:16:34 PM
As Kevin says it here (http://www.underwaredesign.com/forums/index.php?topic=3431.msg22578#msg22578) and here (http://www.underwaredesign.com/forums/index.php?topic=3431.msg22590#msg22590) this tool is not for PBFX (maybe in the moment).

So, try a clean install with your retailversion...

QuoteRecommended Re-Installation procedure


   Step 1) Install whatever base retail edition you have.    For orders newer than  July / AUG 2007, this will be  PlayBasic V1.63w filename PlayBasicV163m_Retail_Setup.exe    Older base retails versions are V1.089,  V1.33, V1.44.  But the process is the same. 

  Step 2)
   
               a) Install upgrade  PlayBasic 1.63w2 

               b)  Install latest upgrade over the top.   Currently this is PLayBasic V1.64L

  Step 3) Run PlayBasic.  Press F5 to compile a blank project,  enter your serial and registration details into the Dialog that appears. 

  Step 4) Done.

I didn't know if serial# have changed between the 3 retail version... I have V1.089, make after clean install the registration and then I upgraded this version described before... No problems  ;)
Title: Re: PlayPackager (WIP THREAD)
Post by: LBFN on May 19, 2010, 01:24:51 PM
post deleted
Title: Re: PlayPackager (WIP THREAD)
Post by: kevin on May 21, 2010, 01:03:40 PM

LBFN,

  See Play Validate Thread (http://www.underwaredesign.com/forums/index.php?topic=3435.0) 
 
Title: Re: PlayPackager (WIP THREAD)
Post by: LBFN on May 21, 2010, 01:12:54 PM
post deleted

Title: Re: PlayPackager (WIP THREAD)
Post by: kevin on May 21, 2010, 11:32:14 PM
 erm, why not post this, i dunno over  here (http://www.underwaredesign.com/forums/index.php?topic=3435.0) ? ..  anyway, it's showing that you haven't following the installation procedure correctly.    Install Base Retail first, then apply upgrade over the top.