/******************************************************************************/
#include "stdafx.h"
/******************************************************************************/
Image image ;
Pak update ;
Download download;
#define server "clientupdate.servebeer.com/Client_Update/"
#define todl "stuff.pak"
////////////////////////////////////////////GUI Declarations///////////////////////////////////////////////
GuiObjs gui_updater;
Text *updater_title;
Text *updater_status;
Text *updater_file;
Progress *updater_progbar;
Button *updater_ping;
Button *updater_update;
//Button *updater_check;
//button functions
void B_Ping(Ptr)
{
}
void B_Update(Ptr)
{
download.create(S+server+todl);
}
////////////////////////////////////////////InitPre
void InitPre()
{
App.name("Updater");
App.flag=APP_NO_FX;
IOPath("data");
Paks.add("../engine.pak");
D.mode(400,500,0).sync(true);
}
static void InitGui()
{
FontDefault.load("font/DirtyDarren.font");
Text_ds.scale*=1.2;
Gui.tds_button.scale*=1.3;
Gui.tds_button.shadow=0x44;
if(gui_updater.load("gui/obj/updater_menu.gobj"))
{
Gui+=gui_updater;
updater_title= &gui_updater.getText ("updater_title");
updater_status= &gui_updater.getText ("updater_status");
updater_ping= &gui_updater.getButton ("updater_ping");
updater_update= &gui_updater.getButton
("updater_update");
updater_progbar= &gui_updater.getProgress("updater_progbar");
updater_file= &gui_updater.getText ("updater_file");
updater_ping->func(B_Ping);
updater_update->func(B_Update);
}
}
/******************************************************************************/
Bool Init()
{
InitGui();
Text_ds.color =BLACK;
Text_ds.shadow=0;
return true;
}
/******************************************************************************/
void Shut()
{
download.del(); // delete downloader
}
/******************************************************************************/
Bool Update()
{
if(Kb.bp(KB_ESC))return false;
Gui.update();
if(download.state()==DWNL_DONE)
{
updater_status -> set ("Finished Downloading .pak");
updater_file -> set ("Extracting pak file..");
update.loadMem(download.data(),download.size());
FCopy(update,CurDir(),download.size(),0,true);
}
if(download.state()==DWNL_DOWNLOAD)
{
updater_status -> set ("Current File");
}
return true;
}
/******************************************************************************/
void Draw()
{
D.clear(GREY);
Gui.draw();
updater_progbar ->set(download.done(),download.size());
updater_file ->set(+download.fileName()); // Str fileName ( ) {return _name ;}
//D.text(0, 0,S+"Files " + update.rootFiles());
switch(download.state())
{
case DWNL_NONE : D.text(0, -0.18, "Waiting..." ); break;
case DWNL_WAIT : D.text(0, -0.18, "Awaiting connection.." ); break;
case DWNL_DOWNLOAD: D.text(0, -0.18,S+"Downloading.. "+download.done()+'/'+download.size() ); break;
case DWNL_DONE : D.text(0, -0.18, "Done!" ); break;
case DWNL_ERROR : D.text(0, -0.18, "Update server is down" ); break;
}
}
/******************************************************************************/