Ejemplo n.º 1
0
/*-----------------------------------------------------------------------------
    Name        : pingStartup
    Description : Startup the ping module
    Inputs      :
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void pingStartup(void)
{
    scriptSet(NULL, "ping.script", pingTweaks);
    pingAnomalyMinScreenSize = primScreenToGLScaleX(pingAnomalyMinScreenSize);
    pingNewShipMinScreenSize = primScreenToGLScaleX(pingNewShipMinScreenSize);
    pingBattleMinScreenSize = primScreenToGLScaleX(pingBattleMinScreenSize);
    pingTaskHandle = taskStart(pingUpdateTask, PNG_TaskPeriod, 0);
    listInit(&pingList);
    pingReset();
}
Ejemplo n.º 2
0
/*-----------------------------------------------------------------------------
    Name        : teStartup
    Description : Start the team module
    Inputs      :
    Outputs     : loads in the team color script
    Return      :
----------------------------------------------------------------------------*/
void teReset(void)
{
    tecolorscheme tempScheme;

    scriptSet(NULL, TE_ColorScript, teColorTweaks);
    teRace1Default = teColorSchemes[0].textureColor;
    teRace2Default = teColorSchemes[1].textureColor;
    if (whichRaceSelected == R2)
    {
        swap(teColorSchemes[0], teColorSchemes[1], tempScheme);
    }
}
Ejemplo n.º 3
0
/*-----------------------------------------------------------------------------
    Name        : rmAPIStartup
    Description : starts up the API for the research manager loading all dependancies
    Inputs      : none
    Outputs     : none
    Return      : void
----------------------------------------------------------------------------*/
void rmAPIStartup(void)
{
    sdword index;

    for (index = 0; index < NumTechnologies; index++)
    {
        SinglePlayerR1TechStatic.TechNeededToResearch[index] = 0;
        MultiPlayerR1TechStatic.TechNeededToResearch[index] = 0;
        MultiPlayerCR1TechStatic.TechNeededToResearch[index] = 0;
        SinglePlayerR2TechStatic.TechNeededToResearch[index] = 0;
        MultiPlayerR2TechStatic.TechNeededToResearch[index] = 0;
        MultiPlayerCR2TechStatic.TechNeededToResearch[index] = 0;
    }

    for (index = 0; index < STD_LAST_SHIP; index++)
    {
        SinglePlayerR1TechStatic.TechNeededToBuildShip[index] = 0;
        MultiPlayerR1TechStatic.TechNeededToBuildShip[index] = 0;
        MultiPlayerCR1TechStatic.TechNeededToBuildShip[index] = 0;
        SinglePlayerR2TechStatic.TechNeededToBuildShip[index] = 0;
        MultiPlayerR2TechStatic.TechNeededToBuildShip[index] = 0;
        MultiPlayerCR2TechStatic.TechNeededToBuildShip[index] = 0;
    }

#if (defined(CGW) || defined(Downloadable) /*|| defined(OEM)*/)
    scriptSet(NULL,"DemoResearchDepend.script",TechnologyDependancies);
#else
    scriptSet(NULL,"ResearchDepend.script",TechnologyDependancies);
#endif
    rmSetPrintList(RM_SPR1,&SinglePlayerR1TechStatic);
    rmSetPrintList(RM_SPR2,&SinglePlayerR2TechStatic);
    rmSetPrintList(RM_MPR1,&MultiPlayerR1TechStatic);
    rmSetPrintList(RM_MPR2,&MultiPlayerR2TechStatic);
    rmSetPrintList(RM_MPCR1,&MultiPlayerCR1TechStatic);
    rmSetPrintList(RM_MPCR2,&MultiPlayerCR2TechStatic);

    rmGUIStartup();
}
Ejemplo n.º 4
0
/*-----------------------------------------------------------------------------
    Name        : spNewItem
    Description : Called when a new item in the color picker list is selected.
    Inputs      :
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void spNewItem(void)
{
    char bitmapFile[_MAX_PATH];
    char descriptionFile[_MAX_PATH];
    char *chopBuffer;
    sdword scen;
    rectangle textureRect;
//    rectangle rect = spScenarioBitmapWindow->rect;
    color *bmpBuffer;
    filehandle handle;
    bmpheader header;
    featom *atom;

    scen = spScenarioListWindow->CurLineSelected->position;
    atom = feAtomFindInScreen(feStack[feStackIndex].screen, "CS_ScenarioBitmap");
    dbgAssert(atom != NULL);

    if (scenarioTexture != TR_InvalidInternalHandle)
    {                                                       //delete the old texture before creating a new one
        trRGBTextureDelete(scenarioTexture);
        scenarioTexture = TR_InvalidInternalHandle;
        if (spTextureData != NULL)
        {
            memFree(spTextureData);
            spTextureData = NULL;
        }
    }

    //free the previous text and set defaults
    spDescriptionDefaultsAndFreeText();

    spFindImage(bitmapFile, descriptionFile, spScenarios[scen].bitmapfileSpec);
    if (strlen(bitmapFile) > 0)
    {
        handle = bmpFileOpen(&header, bitmapFile);         //open the file
        if (handle != 0)
        {                                                   //if opened properly
            if (header.biWidth < SCP_PreviewWidthMin || header.biHeight > SCP_PreviewWidthMax)
            {
#if SCP_VERBOSE_LEVEL >= 1
                dbgMessagef("\n'%s': width of %d bad.", bitmapFile, header.biWidth);
#endif
                bmpClose(handle);
                return;
            }
            else if (header.biHeight < SCP_PreviewHeightMin || header.biHeight > SCP_PreviewHeightMax)
            {
#if SCP_VERBOSE_LEVEL >= 1
                dbgMessagef("\n'%s': height of %d bad.", bitmapFile, header.biHeight);
#endif
                bmpClose(handle);
                return;
            }
            //allocate the image buffer
            bmpBuffer = memAlloc(header.biWidth * header.biHeight * sizeof(color), "TempBMPbuffer", Pyrophoric);
            bmpBodyRead(bmpBuffer, handle, &header);        //read in the body of the file
            if (header.biWidth != SCP_PreviewWidth || header.biHeight != SCP_PreviewHeight)
            {                                               //if the image is the wrong size
                //rescale the image to the proper size
                bmpBuffer = trImageScale(bmpBuffer, header.biWidth, header.biHeight, SCP_PreviewWidth, SCP_PreviewHeight, TRUE);
                header.biWidth = SCP_PreviewWidth;           //make it think we're the right size
                header.biHeight = SCP_PreviewHeight;
            }
            scenarioTexture = trRGBTextureCreate(bmpBuffer, header.biWidth, header.biHeight, FALSE);
            spTextureWidth  = header.biWidth;
            spTextureHeight = header.biHeight;
            if (spTextureData != NULL)
            {
                memFree(spTextureData);
            }
            spTextureData = (ubyte*)memAlloc(4*spTextureWidth*spTextureHeight, "scenpick data", NonVolatile);
            memcpy(spTextureData, bmpBuffer, 4*spTextureWidth*spTextureHeight);
            memFree(bmpBuffer);                             //free the image
        }
        else
        {
            return;
        }
    }
    else
    {
#if SCP_VERBOSE_LEVEL >= 1
        dbgMessage("\nNo preview image found!");
#endif
        textureRect.x0 = atom->x + SCP_TEXTURE_INSET;
        textureRect.y0 = atom->y + SCP_TEXTURE_INSET;
        textureRect.x1 = atom->x + atom->width - SCP_TEXTURE_INSET;
        textureRect.y1 = atom->y + atom->height - SCP_TEXTURE_INSET;
        primRectSolid2(&textureRect, colBlack);
    }

    if (strlen(descriptionFile) > 0)
    {                                                       //if there is a description file
        // load in the proper description based on the language
        if (strCurLanguage==languageEnglish)
        {
            scriptSet(NULL, descriptionFile, spDescriptionTweaks);//load in the description text
        }
        else if (strCurLanguage==languageFrench)
        {
            scriptSet(NULL, descriptionFile, spDescriptionTweaksFrench);//load in the description text
            if (spDescription==NULL)
            {
                // if french isn't found load in english
                scriptSet(NULL, descriptionFile, spDescriptionTweaks);//load in the description text
            }
        }
        else if (strCurLanguage==languageGerman)
        {
            scriptSet(NULL, descriptionFile, spDescriptionTweaksGerman);//load in the description text
            if (spDescription==NULL)
            {
                // if german isn't found load in english
                scriptSet(NULL, descriptionFile, spDescriptionTweaks);//load in the description text
            }
        }
        else if (strCurLanguage==languageSpanish)
        {
            scriptSet(NULL, descriptionFile, spDescriptionTweaksSpanish);//load in the description text
            if (spDescription==NULL)
            {
                // if german isn't found load in english
                scriptSet(NULL, descriptionFile, spDescriptionTweaks);//load in the description text
            }
        }
        else if (strCurLanguage==languageItalian)
        {
            scriptSet(NULL, descriptionFile, spDescriptionTweaksItalian);//load in the description text
            if (spDescription==NULL)
            {
                // if german isn't found load in english
                scriptSet(NULL, descriptionFile, spDescriptionTweaks);//load in the description text
            }
        }

        if (spDescription != NULL)
        {                                                   //if there was real text in that file
            if (spDescriptionFont == FONT_InvalidFontHandle)
            {                                               //make sure we have a font
                spDescriptionFont = frFontRegister("default.hff");
            }
            textureRect.x0 = atom->x + SCP_TEXTURE_INSET;   //and a region to print into
            textureRect.y0 = atom->y + SCP_TEXTURE_INSET;
            textureRect.x1 = atom->x + atom->width - SCP_TEXTURE_INSET;
            textureRect.y1 = atom->y + atom->height - SCP_TEXTURE_INSET;

            spDescriptionLines = memAlloc(sizeof(char *) * (textureRect.y1 - textureRect.y0), "DescLines", NonVolatile);//allocate the chopping pointers
            chopBuffer = memAlloc(strlen(spDescription) + textureRect.y1 - textureRect.y0, "DescChopped", NonVolatile);//allocate chop buffer
            spNDescriptionLines = subStringsChop(&textureRect, spDescriptionFont, strlen(spDescription), spDescription, chopBuffer, spDescriptionLines);
            memFree(spDescription);                         //free unchopped description
            spDescription = chopBuffer;                     //keep pointer to chopped description
        }
        gameTypeFromDescription = memAlloc(sizeof(GameType), "DescGameType", 0);
        memset(gameTypeFromDescription, 0xff, sizeof(GameType));       //flag all members as unused
        gameTypeFromDescription->flag = gameTypeFromDescription->flagNeeded = 0;    //flag none of the flags needed

        scriptSetStruct(NULL, descriptionFile, StaticMGInfoScriptTable, (ubyte *)gameTypeFromDescription);
    }

    if (strlen(descriptionFile) > 0 || strlen(bitmapFile) > 0)
    {                                                       //if there is a description file or a bitmap
        if (spPickerStarted)
        {
            spScenarioBitmap(atom, (regionhandle)atom->region);//draw it/them
        }
    }
}
Ejemplo n.º 5
0
/*-----------------------------------------------------------------------------
    Name        : strLoadLanguage
    Description : Load a particular language script and activate it
    Inputs      : language to load
    Outputs     : whether the language was loaded or not
    Return      : bool8
----------------------------------------------------------------------------*/
bool8 strLoadLanguage(strLanguageType language)
{
    udword i;
    udword keyboard;

    for (i=0;i<NumStrings;i++)
    {
        MessageStrings[i]=crapMessage;
    }

    if (keyboard = GetKeyboardLayout(0))
    {
        if (PRIMARYLANGID(keyboard)==LANG_ENGLISH)
        {
            strCurKeyboardLanguage = languageEnglish;
        }
        else if (PRIMARYLANGID(keyboard)==LANG_FRENCH)
        {
            strCurKeyboardLanguage = languageFrench;
        }
        else if (PRIMARYLANGID(keyboard)==LANG_GERMAN)
        {
            strCurKeyboardLanguage = languageGerman;
        }
        else if (PRIMARYLANGID(keyboard)==LANG_SPANISH)
        {
            strCurKeyboardLanguage = languageSpanish;
        }
        else if (PRIMARYLANGID(keyboard)==LANG_ITALIAN)
        {
            strCurKeyboardLanguage = languageItalian;
        }
    }
    else
        strCurKeyboardLanguage = languageEnglish;

    if (strInitialized==TRUE)
    {
        strFreeLanguage();
    }
    switch (language)
    {
        case languageEnglish :
            scriptSet("","English.script",LanguageStrings);
            strCurLanguage = (udword)language;
            strInitialized = TRUE;
        return(TRUE);
        case languageFrench :
            scriptSet("","French.script",LanguageStrings);
            strCurLanguage = (udword)language;
            strInitialized = TRUE;
        return(TRUE);
        case languageGerman :
            scriptSet("","German.script",LanguageStrings);
            strCurLanguage = (udword)language;
            strInitialized = TRUE;
        return(TRUE);
        case languageSpanish :
            scriptSet("","Spanish.script",LanguageStrings);
            strCurLanguage = (udword)language;
            strInitialized = TRUE;
        return(TRUE);
        case languageItalian :
            scriptSet("","Italian.script",LanguageStrings);
            strCurLanguage = (udword)language;
            strInitialized = TRUE;
        return(TRUE);
    }

    return(FALSE);
}
Ejemplo n.º 6
0
/**
 * Process OI Op Codes passed by controller
 */
void OpenInterface::handleOpCode(byte oc)
{
#ifdef DEBUG_SERIAL
  switch (oc)
  {
    case ('s'):
        oc = OC_SAFE;
    break;
    case ('d'):
        oc = OC_DIRECT_DRIVE;
    break;
    case ('g'):
        oc = OC_SENSORS;
    break;
  }
#endif
  switch (oc)
  {

     case(OC_LOW_SIDE_DRIVERS):
       callCallbackWithOneByte(controlLsdOutputCallback);
     break;

     case(OC_LEDS):
       callCallbackWithThreeBytes(controlLedsCallback);
     break;

     case(OC_PWM_LOW_SIDE_DRIVERS):
       callCallbackWithThreeBytes(controlLsdPwmCallback);
     break;

     case(OC_DIGITAL_OUTPUTS):
       callCallbackWithOneByte(controlDigitalOutputCallback);
     break;

     case(OC_STREAM):
         stream();
     break;

     case(OC_PAUSE_RESUME_STREAM):
     break;

     case(OC_SEND_IR):
       callCallbackWithOneByte(sendIrCallback);
     break;

     case(OC_SHOW_SCRIPT):
       showScript();
     break;

     case(OC_WAIT_EVENT):
       callCallbackWithOneByte(waitEventCallback);
     break;

     case(OC_PLAY_SCRIPT):
        scriptPlay();
     break;

     case(OC_SCRIPT):
       scriptSet();
     break;

     case(OC_WAIT_ANGLE):
         if (waitAngleCallback)
         {
           waitAction(waitAngleCallback);
         }
     break;

     case(OC_WAIT_DISTANCE):
         if (waitDistanceCallback)
         {
           waitAction(waitDistanceCallback);
         }
     break;

     case(OC_WAIT_TIME):
       waitTime();
     break;

     case(OC_DEMO):
     case(OC_SPOT):
     case(OC_COVER):
     case(OC_COVER_AND_DOCK):
       // These are all demo codes. Implement?
     break;

     case(OC_QUERY_LIST):
       queryList();
     break;

     case (OC_START):
       sensor[OI_SENSOR_OI_MODE] = OI_MODE_PASSIVE;
     break;

     case (OC_BAUD):
     break;

     case (OC_CONTROL):
     case (OC_SAFE):
       sensor[OI_SENSOR_OI_MODE] = OI_MODE_SAFE;
     break;

     case (OC_SENSORS):
       getSensors();
     break;

     case (OC_SONG):
       song();
     break;

     case(OC_PLAY_SONG):
       songPlay();
     break;

     case (OC_DIRECT_DRIVE):
       driveDirect();
     break;

     case (OC_DRIVE):
       drive();
     break;

     case (OC_FULL):
       sensor[OI_SENSOR_OI_MODE] = OI_MODE_FULL;
     break;
  }
}
Ejemplo n.º 7
0
/*-----------------------------------------------------------------------------
    Name        : lightStartup
    Description : Initialize lighting module
    Inputs      :
    Outputs     : Reads in the lighting script
    Return      :
----------------------------------------------------------------------------*/
void lightStartup(void)
{
    currentLight = NULL;
    scriptSet(NULL, "Light.script", lightScriptTable); //read in the script
    currentLight = NULL;
}