Ignore:
Timestamp:
2008-06-20T09:58:58+12:00 (16 years ago)
Author:
oranfry
Message:

corrections to the splitting and joining scheme, and a few fixes to make use of shared stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release-kits/wirk3/wrapper/wrapper.cpp

    r15813 r16078  
    1414//globals
    1515HBITMAP g_splash = NULL; //the main splash bitmap
     16HFONT g_hfFont = NULL; //the main splash bitmap
    1617char step[10] = "TMP"; //the current step
    1718char progress[4] = "0"; //progress in the current step
     
    4546
    4647//extracts a resource in chunks
    47 int extractResource( const char * basename, const char * type, char * file, int no_chunks ) {
     48int extractResource( const char * basename, const char * type, char * file ) {
    4849
    4950    HMODULE hModule = GetModuleHandle(NULL);
    5051    set_splash_progress( 0 );
    5152
     53    int no_chunks;
     54    bool chunk_available = true;
     55    for ( no_chunks = 0; chunk_available; no_chunks++ ) {
     56
     57        //construct the chunk name
     58        char chunkname[127] = {0};
     59        strcpy( chunkname, basename );
     60        strcat( chunkname, "_" );
     61        char chunknum[5] = {0};
     62        itoa( no_chunks+1, chunknum, 10 );
     63        strcat( chunkname, chunknum );
     64       
     65        if ( FindResource(hModule, chunkname, type) == NULL ) {
     66            chunk_available = false;
     67        }
     68    }
     69   
    5270    for ( int i=0; i<no_chunks; i++ ) {
    53 
     71   
    5472        //construct the chunk name
    5573        char chunkname[127] = {0};
     
    6078        strcat( chunkname, chunknum );
    6179       
    62         //MessageBox(NULL, chunkname, "chunk name", MB_OK);
    63        
    64         //try to find it
     80        //find it
    6581        HRSRC hRsrc = FindResource(hModule, chunkname, type);
    66         if (hRsrc == NULL ) return -1; //couldn't find the chunk
     82        if (hRsrc == NULL ) return 1; //couldn't find the chunk
    6783       
    6884        //load it
    6985        HGLOBAL hGlobal = LoadResource(hModule, hRsrc);
    7086        if (hGlobal == NULL) return 1; //couldn't lock
     87       
     88        //lock it
    7189        BYTE* pBytes = (BYTE*) LockResource(hGlobal);
    7290        if (pBytes == NULL) return 1; //couldn't lock
     
    98116            //load in the reusable resources
    99117            g_splash = LoadBitmap(GetModuleHandle(NULL),"SPLASH");
     118            g_hfFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
    100119            if(g_splash == NULL) {
    101120                MessageBox(hwnd, "Could not load splash bitmap!", "Error", MB_OK | MB_ICONEXCLAMATION);
     
    146165            SelectObject(hdcMem, g_step);
    147166            BitBlt(hdc, 0, 276, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCPAINT);
     167           
     168            //print the step with text
     169            RECT rcClient;
     170            GetClientRect(hwnd, &rcClient);
     171            //DrawText(hdc, "This is the step", -1, &rcClient, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
    148172           
    149173            //restore the hdc
     
    294318        //is this an installer with the bundled JRE?
    295319        set_splash_step( "XJAVA" );
    296         int extract_result = extractResource( "JAVA", "EXE", "@java.installer@", 2 );
     320        int extract_result = extractResource( "JAVA", "EXE", "@java.installer@" );
    297321
    298322        if ( extract_result == 0 ) {
     
    327351       
    328352        set_splash_step( "XJAR" );
    329         extractResource( "JAR", "JAR", (char*) jarLocation.c_str(), 12 );
     353        extractResource( "JAR", "JAR", (char*) jarLocation.c_str() );
    330354
    331355        //launch the jar
Note: See TracChangeset for help on using the changeset viewer.