void InitEditorItemsInfo(UINT32 uiItemType) { VSURFACE_DESC vs_desc; UINT8 *pDestBuf, *pSrcBuf; UINT32 uiSrcPitchBYTES, uiDestPitchBYTES; INVTYPE *item; SGPRect SaveRect, NewRect; HVOBJECT hVObject; UINT32 uiVideoObjectIndex; UINT16 usUselessWidth, usUselessHeight; INT16 sWidth, sOffset, sStart; INT16 i, x, y; UINT16 usCounter; CHAR16 pStr[ 100 ];//, pStr2[ 100 ]; CHAR16 pItemName[SIZE_ITEM_NAME]; UINT8 ubBitDepth; BOOLEAN fTypeMatch; INT32 iEquipCount = 0; // Check to make sure that there isn't already a valid eInfo if( eInfo.fActive ) { if( eInfo.uiItemType == uiItemType ) { //User clicked on the same item classification -- ignore return; } else { //User selected a different item classification -- delete it first. ClearEditorItemsInfo(); ClearTaskbarRegion( iScreenWidthOffset + 100, 2 * iScreenHeightOffset + 360, iScreenWidthOffset + 480, 2 * iScreenHeightOffset + 440 ); } } else { //Clear the menu area, so that the buffer doesn't get corrupted. ClearTaskbarRegion( iScreenWidthOffset + 100, 2 * iScreenHeightOffset + 360, iScreenWidthOffset + 480, 2 * iScreenHeightOffset + 440 ); } EnableEditorRegion( ITEM_REGION_ID ); eInfo.uiItemType = uiItemType; eInfo.fActive = TRUE; //Begin initialization of data. switch(uiItemType) { case TBAR_MODE_ITEM_WEAPONS: eInfo.sNumItems = eInfo.sNumWeapons; eInfo.sScrollIndex = eInfo.sSaveWeaponsScrollIndex; eInfo.sSelItemIndex = eInfo.sSaveSelWeaponsIndex; break; case TBAR_MODE_ITEM_AMMO: eInfo.sNumItems = eInfo.sNumAmmo; eInfo.sScrollIndex = eInfo.sSaveAmmoScrollIndex; eInfo.sSelItemIndex = eInfo.sSaveSelAmmoIndex; break; case TBAR_MODE_ITEM_ARMOUR: eInfo.sNumItems = eInfo.sNumArmour; eInfo.sScrollIndex = eInfo.sSaveArmourScrollIndex; eInfo.sSelItemIndex = eInfo.sSaveSelArmourIndex; break; case TBAR_MODE_ITEM_LBEGEAR: eInfo.sNumItems = eInfo.sLBEGear; eInfo.sScrollIndex = eInfo.sSaveLBEScrollIndex; eInfo.sSelItemIndex = eInfo.sSaveSelLBEIndex; break; case TBAR_MODE_ITEM_EXPLOSIVES: eInfo.sNumItems = eInfo.sNumExplosives; eInfo.sScrollIndex = eInfo.sSaveExplosivesScrollIndex; eInfo.sSelItemIndex = eInfo.sSaveSelExplosivesIndex; break; case TBAR_MODE_ITEM_EQUIPMENT1: eInfo.sNumItems = eInfo.sNumEquipment1; eInfo.sScrollIndex = eInfo.sSaveEquipment1ScrollIndex; eInfo.sSelItemIndex = eInfo.sSaveSelEquipment1Index; break; case TBAR_MODE_ITEM_EQUIPMENT2: eInfo.sNumItems = eInfo.sNumEquipment2; eInfo.sScrollIndex = eInfo.sSaveEquipment2ScrollIndex; eInfo.sSelItemIndex = eInfo.sSaveSelEquipment2Index; break; case TBAR_MODE_ITEM_EQUIPMENT3: eInfo.sNumItems = eInfo.sNumEquipment3; eInfo.sScrollIndex = eInfo.sSaveEquipment3ScrollIndex; eInfo.sSelItemIndex = eInfo.sSaveSelEquipment3Index; break; case TBAR_MODE_ITEM_TRIGGERS: eInfo.sNumItems = eInfo.sNumTriggers; eInfo.sScrollIndex = eInfo.sSaveTriggersScrollIndex; eInfo.sSelItemIndex = eInfo.sSaveSelTriggersIndex; break; case TBAR_MODE_ITEM_KEYS: eInfo.sNumItems = eInfo.sNumKeys; eInfo.sScrollIndex = eInfo.sSaveKeysScrollIndex; eInfo.sSelItemIndex = eInfo.sSaveSelKeysIndex; break; default: //error return; } //Allocate memory to store all the item pointers. eInfo.pusItemIndex = (UINT16*)MemAlloc( sizeof(UINT16) * eInfo.sNumItems ); //Disable the appropriate scroll buttons based on the saved scroll index if applicable //Left most scroll position DetermineItemsScrolling(); //calculate the width of the buffer based on the number of items. //every pair of items (odd rounded up) requires 60 pixels for width. //the minimum buffer size is 420. Height is always 80 pixels. eInfo.sWidth = (eInfo.sNumItems > 12) ? ((eInfo.sNumItems+1)/2)*60 : SCREEN_HEIGHT - 120; eInfo.sHeight = 80; // Create item buffer GetCurrentVideoSettings( &usUselessWidth, &usUselessHeight, &ubBitDepth ); vs_desc.fCreateFlags = VSURFACE_CREATE_DEFAULT | VSURFACE_SYSTEM_MEM_USAGE; vs_desc.usWidth = eInfo.sWidth; vs_desc.usHeight = eInfo.sHeight; vs_desc.ubBitDepth = ubBitDepth; //!!!Memory check. Create the item buffer if(!AddVideoSurface( &vs_desc, &eInfo.uiBuffer )) { eInfo.fKill = TRUE; eInfo.fActive = FALSE; return; } pDestBuf = LockVideoSurface(eInfo.uiBuffer, &uiDestPitchBYTES); pSrcBuf = LockVideoSurface(FRAME_BUFFER, &uiSrcPitchBYTES); //copy a blank chunk of the editor interface to the new buffer. for( i=0; i<eInfo.sWidth; i+=60 ) { Blt16BPPTo16BPP((UINT16 *)pDestBuf, uiDestPitchBYTES, (UINT16 *)pSrcBuf, uiSrcPitchBYTES, 0+i, 0, iScreenWidthOffset + 100, 2 * iScreenHeightOffset + 360, 60, 80 ); } UnLockVideoSurface(eInfo.uiBuffer); UnLockVideoSurface(FRAME_BUFFER); x = 0; y = 0; usCounter = 0; NewRect.iTop = 0; NewRect.iBottom = eInfo.sHeight; NewRect.iLeft = 0; NewRect.iRight = eInfo.sWidth; GetClippingRect(&SaveRect); SetClippingRect(&NewRect); if( eInfo.uiItemType == TBAR_MODE_ITEM_KEYS ) { //Keys use a totally different method for determining for( i = 0; i < eInfo.sNumItems; i++ ) { item = &Item[ KeyTable[ 0 ].usItem + LockTable[ i ].usKeyItem ]; uiVideoObjectIndex = GetInterfaceGraphicForItem( item ); GetVideoObject( &hVObject, uiVideoObjectIndex ); //Store these item pointers for later when rendering selected items. eInfo.pusItemIndex[i] = KeyTable[ 0 ].usItem + LockTable[ i ].usKeyItem; SetFont(SMALLCOMPFONT); SetFontForeground( FONT_MCOLOR_WHITE ); SetFontDestBuffer( eInfo.uiBuffer, 0, 0, eInfo.sWidth, eInfo.sHeight, FALSE ); swprintf( pStr, L"%S", LockTable[ i ].ubEditorName ); DisplayWrappedString(x, (UINT16)(y+25), 60, 2, SMALLCOMPFONT, FONT_WHITE, pStr, FONT_BLACK, TRUE, CENTER_JUSTIFIED ); UINT16 usGraphicNum = g_bUsePngItemImages ? 0 : item->ubGraphicNum; //Calculate the center position of the graphic in a 60 pixel wide area. sWidth = hVObject->pETRLEObject[usGraphicNum].usWidth; sOffset = hVObject->pETRLEObject[usGraphicNum].sOffsetX; sStart = x + (60 - sWidth - sOffset*2) / 2; BltVideoObjectOutlineFromIndex( eInfo.uiBuffer, uiVideoObjectIndex, usGraphicNum, sStart, y+2, 0, FALSE ); //cycle through the various slot positions (0,0), (0,40), (60,0), (60,40), (120,0)... if( y == 0 ) { y = 40; } else { y = 0; x += 60; } } } else for( i = 0; i < eInfo.sNumItems; i++ ) { fTypeMatch = FALSE; while( usCounter<MAXITEMS && !fTypeMatch ) { if ( Item[usCounter].usItemClass == 0 ) break; item = &Item[usCounter]; //if( Item[usCounter].fFlags & ITEM_NOT_EDITOR ) if(item->notineditor) { usCounter++; continue; } if( eInfo.uiItemType == TBAR_MODE_ITEM_TRIGGERS ) { if( i < PRESSURE_ACTION_ID ) usCounter = ( i % 2 ) ? ACTION_ITEM : SWITCH; else usCounter = ACTION_ITEM; fTypeMatch = TRUE; item = &Item[usCounter]; } else switch( item->usItemClass ) { case IC_GUN: case IC_BLADE: case IC_LAUNCHER: case IC_THROWN: case IC_THROWING_KNIFE: fTypeMatch = eInfo.uiItemType == TBAR_MODE_ITEM_WEAPONS; break; case IC_PUNCH: if ( i != NOTHING ) { fTypeMatch = eInfo.uiItemType == TBAR_MODE_ITEM_WEAPONS; } else { fTypeMatch = FALSE; } break; case IC_AMMO: fTypeMatch = eInfo.uiItemType == TBAR_MODE_ITEM_AMMO; break; case IC_ARMOUR: fTypeMatch = eInfo.uiItemType == TBAR_MODE_ITEM_ARMOUR; break; case IC_LBEGEAR: fTypeMatch = eInfo.uiItemType == TBAR_MODE_ITEM_LBEGEAR; break; case IC_GRENADE: case IC_BOMB: fTypeMatch = eInfo.uiItemType == TBAR_MODE_ITEM_EXPLOSIVES; break; case IC_MEDKIT: case IC_KIT: case IC_FACE: case IC_MONEY: case IC_BELTCLIP: fTypeMatch = eInfo.uiItemType == TBAR_MODE_ITEM_EQUIPMENT1; break; case IC_MISC: if( usCounter == ACTION_ITEM || usCounter == SWITCH ) break; if( iEquipCount < eInfo.sNumEquipment2 ) fTypeMatch = eInfo.uiItemType == TBAR_MODE_ITEM_EQUIPMENT2; else fTypeMatch = eInfo.uiItemType == TBAR_MODE_ITEM_EQUIPMENT3; iEquipCount++; break; } if( fTypeMatch ) { uiVideoObjectIndex = GetInterfaceGraphicForItem( item ); GetVideoObject( &hVObject, uiVideoObjectIndex ); //Store these item pointers for later when rendering selected items. eInfo.pusItemIndex[i] = usCounter; SetFont(SMALLCOMPFONT); SetFontForeground( FONT_MCOLOR_WHITE ); SetFontDestBuffer( eInfo.uiBuffer, 0, 0, eInfo.sWidth, eInfo.sHeight, FALSE ); if( eInfo.uiItemType != TBAR_MODE_ITEM_TRIGGERS ) { LoadItemInfo( usCounter, pItemName, NULL ); swprintf( pStr, L"%s", pItemName ); } else { if( i == PRESSURE_ACTION_ID ) { swprintf( pStr, pInitEditorItemsInfoText[0] ); } else if( i < 2 ) { if( usCounter == SWITCH ) swprintf( pStr, pInitEditorItemsInfoText[5] ); else swprintf( pStr, pInitEditorItemsInfoText[1] ); } else if( i < 4 ) { if( usCounter == SWITCH ) swprintf( pStr, pInitEditorItemsInfoText[6] ); else swprintf( pStr, pInitEditorItemsInfoText[2] ); } else if( i < 6 ) { if( usCounter == SWITCH ) swprintf( pStr, pInitEditorItemsInfoText[7] ); else swprintf( pStr, pInitEditorItemsInfoText[3] ); } else { if( usCounter == SWITCH ) swprintf( pStr, pInitEditorItemsInfoText[8], (i-4)/2 ); else swprintf( pStr, pInitEditorItemsInfoText[4], (i-4)/2 ); } } DisplayWrappedString(x, (UINT16)(y+25), 60, 2, SMALLCOMPFONT, FONT_WHITE, pStr, FONT_BLACK, TRUE, CENTER_JUSTIFIED ); UINT16 usGraphicNum = g_bUsePngItemImages ? 0 : item->ubGraphicNum; if(usGraphicNum < hVObject->usNumberOfObjects) { //Calculate the center position of the graphic in a 60 pixel wide area. sWidth = hVObject->pETRLEObject[usGraphicNum].usWidth; sOffset = hVObject->pETRLEObject[usGraphicNum].sOffsetX; sStart = x + (60 - sWidth - sOffset*2) / 2; if( sWidth && sWidth > 0 ) { BltVideoObjectOutlineFromIndex( eInfo.uiBuffer, uiVideoObjectIndex, usGraphicNum, sStart, y+2, 0, FALSE ); } //cycle through the various slot positions (0,0), (0,40), (60,0), (60,40), (120,0)... if( y == 0 ) { y = 40; } else { y = 0; x += 60; } } else { static vfs::Log& editorLog = *vfs::Log::create(L"EditorItems.log"); editorLog << L"Tried to access item [" << item->ubGraphicNum << L"/" << hVObject->usNumberOfObjects << L"]" << vfs::Log::endl; } } usCounter++; } } SetFontDestBuffer( FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE ); SetClippingRect(&SaveRect); gfRenderTaskbar = TRUE; }
void ProcessEditorRendering() { BOOLEAN fSaveBuffer = FALSE; if( gfRenderTaskbar ) //do a full taskbar render. { if(iCurrentTaskbar == TASK_OPTIONS && !gfSummaryWindowActive)//dnl ch52 091009 { CHAR8 szNewText[4+1]; sprintf(szNewText, "%d", iNewMapWorldRows=WORLD_ROWS); SetInputFieldStringWith8BitString(1, szNewText); sprintf(szNewText, "%d", iNewMapWorldCols=WORLD_COLS); SetInputFieldStringWith8BitString(2, szNewText); DisableTextField(2); } ClearTaskbarRegion( 0, SCREEN_HEIGHT - 120, SCREEN_WIDTH, SCREEN_HEIGHT ); RenderTerrainTileButtons(); MarkButtonsDirty(); gfRenderTaskbar = FALSE; fSaveBuffer = TRUE; gfRenderDrawingMode = TRUE; gfRenderHilights = FALSE; gfRenderMercInfo = TRUE; } if( gfRenderDrawingMode ) { if( iCurrentTaskbar == TASK_BUILDINGS || iCurrentTaskbar == TASK_TERRAIN || iCurrentTaskbar == TASK_ITEMS ) { ShowCurrentDrawingMode(); gfRenderDrawingMode = FALSE; } } //render dynamically changed buttons only RenderButtons( ); if( gfSummaryWindowActive ) RenderSummaryWindow(); else if( !gfGotoGridNoUI && !gfKeyboardItemCreationUI && !InOverheadMap() && !gfEditingDoor )//dnl ch86 220214 RenderMercStrings(); if( gfEditingDoor ) RenderDoorEditingWindow(); if( TextInputMode() ) RenderAllTextFields(); RenderEditorInfo(); if( !gfSummaryWindowActive && !gfGotoGridNoUI && !gfKeyboardItemCreationUI && !InOverheadMap() && !gfEditingDoor )//dnl ch86 220214 { if( gpItem && gsItemGridNo != -1 ) RenderSelectedItemBlownUp(); if( iCurrentTaskbar == TASK_MAPINFO ) RenderMapEntryPointsAndLights(); if( iDrawMode == DRAW_MODE_PLACE_ITEM && eInfo.uiItemType == TBAR_MODE_ITEM_KEYS || iDrawMode == DRAW_MODE_DOORKEYS ) RenderDoorLockInfo(); } if( fSaveBuffer ) BlitBufferToBuffer( FRAME_BUFFER, guiSAVEBUFFER, 0, 2 * iScreenHeightOffset + 360, SCREEN_WIDTH, 120 ); //Make sure this is TRUE at all times. //It is set to false when before we save the buffer, so the buttons don't get //rendered with hilites, in case the mouse is over one. gfRenderHilights = TRUE; if(!gfSummaryWindowActive && !gfScrollInertia && !gfEditingDoor)//dnl ch77 131113 //dnl ch78 271113 //dnl ch86 210214 RenderButtonsFastHelp(); }
void ProcessEditorRendering() { BOOLEAN fSaveBuffer = FALSE; if( gfRenderTaskbar ) //do a full taskbar render. { ClearTaskbarRegion( 0, 360, 640, 480 ); RenderTerrainTileButtons(); MarkButtonsDirty(); gfRenderTaskbar = FALSE; fSaveBuffer = TRUE; gfRenderDrawingMode = TRUE; gfRenderHilights = FALSE; gfRenderMercInfo = TRUE; } if( gfRenderDrawingMode ) { if( iCurrentTaskbar == TASK_BUILDINGS || iCurrentTaskbar == TASK_TERRAIN || iCurrentTaskbar == TASK_ITEMS ) { ShowCurrentDrawingMode(); gfRenderDrawingMode = FALSE; } } //render dynamically changed buttons only RenderButtons( ); if( gfSummaryWindowActive ) RenderSummaryWindow(); else if( !gfGotoGridNoUI && !InOverheadMap() ) RenderMercStrings(); if( gfEditingDoor ) RenderDoorEditingWindow(); if( TextInputMode() ) RenderAllTextFields(); RenderEditorInfo(); if( !gfSummaryWindowActive && !gfGotoGridNoUI && !InOverheadMap() ) { if( gpItem && gsItemGridNo != -1 ) RenderSelectedItemBlownUp(); if( iCurrentTaskbar == TASK_MAPINFO ) RenderMapEntryPointsAndLights(); if( iDrawMode == DRAW_MODE_PLACE_ITEM && eInfo.uiItemType == TBAR_MODE_ITEM_KEYS || iDrawMode == DRAW_MODE_DOORKEYS ) RenderDoorLockInfo(); } if( fSaveBuffer ) BlitBufferToBuffer( FRAME_BUFFER, guiSAVEBUFFER, 0, 360, 640, 120 ); //Make sure this is TRUE at all times. //It is set to false when before we save the buffer, so the buttons don't get //rendered with hilites, in case the mouse is over one. gfRenderHilights = TRUE; RenderButtonsFastHelp(); }