Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Downloader (https://forums.graalonline.com/forums/showthread.php?t=134260407)

fowlplay4 09-02-2010 02:17 AM

Downloader
 
Well I made this since I hated the whole opening my browser and what not to download the new beta client (If I could find the name of the Beta TextCtrl, I'd do it automatically but w/e).

Basically downloads what you have set in this.dlurl.

PHP Code:

//#CLIENTSIDE

function onCreated() {
  
// You'll have to fix this line.. well the start of it.
  
this.dlurl "http://www.path.to/the/right/place/" getplatform() @ ".zip";
}

function 
ChatBar.onAction() {
  if (
ChatBar.text == "/download") {
    
ChatBar.text "";
    
createGUI();
    
// Comment the line below if you want the 
    // joy of clicking a button.
    
downloadFile(); 
  }
}

function 
createGUI() {
  new 
GuiWindowCtrl("BetaDownloader") {
    
profile GuiBlueWindowProfile;
    
width 200;
    
height 72;
    
= (screenwidth width) / 2;
    
= (screenheight height) / 2;
    
text "Beta Downloader";
    new 
GuiButtonCtrl("BetaDownloader_Download") {
      
profile GuiBlueButtonProfile;
      
10;
      
30;
      
active true;
      
width 180;
      
text "Download" SPC extractfilename(thiso.dlurl);
      
thiso.catchevent(this.name"onAction""downloadFile");
    }
  }
}

function 
downloadFile() {
  
with (BetaDownloader_Download) {
    
active false;
    
text "Downloading...";
  }
  
temp.req requesturl(this.dlurl);
  
thiso.catchevent(temp.req"onReceiveData""downloadedFile");
}

function 
downloadedFile(obj) {
  
temp.file extractfilename(obj.file);
  
BetaDownloader_Download.text file SPC "downloaded.";
  
obj.fulldata.savestring(file0);


Portable download functions:

PHP Code:

//#CLIENTSIDE
function downloadFile(dlurl) {
  
temp.req requesturl(dlurl);
  
thiso.catchevent(temp.req"onReceiveData""downloadedFile");
}

function 
downloadedFile(obj) {
  
temp.filename extractfilename(obj.file);
  
obj.fulldata.savestring(temp.filename0);



Tigairius 09-02-2010 02:22 AM

nice

fowlplay4 09-02-2010 02:33 AM

@Skyld: Integrate such functionality please.

cbk1994 09-02-2010 02:47 AM

PHP Code:

thiso.catchevent(this.name"onAction""downloadFile"); 

this would trigger the event onDownloadFile, no?

fowlplay4 09-02-2010 03:05 AM

Quote:

Originally Posted by cbk1994 (Post 1598188)
PHP Code:

thiso.catchevent(this.name"onAction""downloadFile"); 

this would trigger the event onDownloadFile, no?

Nope, at least not in V6.

LoneAngelIbesu 09-02-2010 05:31 AM

Quote:

Originally Posted by fowlplay4 (Post 1598190)
Nope, at least not in V6.

Not in v5, either.

MrOmega 09-02-2010 05:52 AM

Quote:

Originally Posted by fowlplay4 (Post 1598190)
Nope, at least not in V6.

Couldnt you just trigger it with trigger() / scheduleEvent()?

PHP Code:

thiso.trigger"DownloadFile"NULL);
thiso.scheduleEvent0"DownloadFile"NULL); 


cbk1994 09-02-2010 05:54 AM

Good to know, I always thought the "on" was optional (as it is in other functions, such as trigger) but it would be prefixed with "on" automatically if you left it out.

Tigairius 09-02-2010 07:27 AM

Quote:

Originally Posted by cbk1994 (Post 1598188)
PHP Code:

thiso.catchevent(this.name"onAction""downloadFile"); 

this would trigger the event onDownloadFile, no?

Could be possible that in order for the "on" to be optional you have to capitalize the D, like
PHP Code:

thiso.catchevent(this.name"onAction""DownloadFile"); 

But I could be wrong. In CatchEvents, I've always included the on.


All times are GMT +2. The time now is 05:24 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.