Brief: //dnl ch77

- Couple mapeditor and game fixes and radar map creation for any screen resolution.
Details:
- Radarmap is now possible to create from any mapeditor screen resolution.
- Better fix to prevent memory corruption during gWorldItems resize.
- Fix problems with losing attached item because attachment slots was not exist when using NAS, also empty slots are removed which was prevent attaching in OAS.
- Fix tooltip popup for checkbox when button is disabled and prevent sticky tooltips from taskbar when SummaryWindow is active.
- Check if item is valid for 1.12 will be active only for mapeditor, but game will load all items regardless of map version.


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6652 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Kriplo
2013-11-25 21:44:39 +00:00
parent 3e70a9d6dc
commit e7455c445d
13 changed files with 153 additions and 124 deletions
+3 -6
View File
@@ -919,7 +919,7 @@ void RenderEditorInfo( )
{
INT16 sGridX, sGridY;
GetMouseXY(&sGridX, &sGridY);
swprintf(FPSText, L"%4d %4d %6d", sGridX, sGridY, iMapIndexD);
swprintf(FPSText, L"%4d %4d %6d ", sGridX, sGridY, iMapIndexD);
}
else
swprintf(FPSText, L" ");
@@ -1045,8 +1045,6 @@ void ProcessEditorRendering()
RenderDoorLockInfo();
}
if( fSaveBuffer )
BlitBufferToBuffer( FRAME_BUFFER, guiSAVEBUFFER, 0, 2 * iScreenHeightOffset + 360, SCREEN_WIDTH, 120 );
@@ -1054,9 +1052,8 @@ void ProcessEditorRendering()
//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();
if(!gfSummaryWindowActive)//dnl ch77 131113
RenderButtonsFastHelp();
}
+3 -3
View File
@@ -1430,7 +1430,7 @@ void ToggleAttachment( GUI_BUTTON *btn, INT32 reason )
{
INT32 i;
UINT16 usAttachment = 0;
ResizeWorldItems();//dnl ch75 021113 to prevent memory corruption during resize if somehow in created item we manage to put invalid attachment (DRAGUNOV with SNIPERCOPE problem in older mapeditors)
//ResizeWorldItems();//dnl ch75 021113 to prevent memory corruption during resize if somehow in created item we manage to put invalid attachment (DRAGUNOV with SNIPERCOPE problem in older mapeditors)
for( i = 0; i < NUM_ATTACHMENT_BUTTONS; i++ )
{ //Loop through and find the button that was just modified
switch( i )
@@ -1470,7 +1470,7 @@ void ToggleCeramicPlates( GUI_BUTTON *btn, INT32 reason )
{
if( reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
{
ResizeWorldItems();//dnl ch75 021113 just precaution to prevent eventual memory corruption during resize if somehow AttachObject find invalid attachment
//ResizeWorldItems();//dnl ch75 021113 just precaution to prevent eventual memory corruption during resize if somehow AttachObject find invalid attachment
gfCeramicPlates ^= TRUE;
if( gfCeramicPlates )
{
@@ -1492,7 +1492,7 @@ void ToggleDetonator( GUI_BUTTON *btn, INT32 reason )
{
if( reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
{
ResizeWorldItems();//dnl ch75 021113 just precaution to prevent eventual memory corruption during resize if somehow AttachObject find invalid attachment
//ResizeWorldItems();//dnl ch75 021113 just precaution to prevent eventual memory corruption during resize if somehow AttachObject find invalid attachment
if( !gfDetonator )
{
gfDetonator = TRUE;
+1 -14
View File
@@ -2976,20 +2976,7 @@ BOOLEAN OBJECTTYPE::Load( INT8** hBuffer, float dMajorMapVersion, UINT8 ubMinorM
this->AttachObject(NULL,&defaultAttachment, FALSE);
}
#else
if(this->usItem && (gGameOptions.ubAttachmentSystem || gfEditMode))
{
RemoveProhibitedAttachments(NULL, this, this->usItem);
//Madd: ok, so this drives me nuts -- why bother with default attachments if the map isn't going to load them for you?
//this should fix that...
for(UINT8 cnt=0; cnt<MAX_DEFAULT_ATTACHMENTS; cnt++)
{
if(Item[this->usItem].defaultattachments[cnt] == NONE || !(gGameOptions.ubAttachmentSystem && Item[Item[this->usItem].defaultattachments[cnt]].inseparable || gfEditMode))
break;
OBJECTTYPE defaultAttachment;
CreateItem(Item[this->usItem].defaultattachments[cnt], (*this)[0]->data.gun.bGunStatus, &defaultAttachment);
this->AttachObject(NULL, &defaultAttachment, FALSE);
}
}
AttachDefaultAttachments(this);//dnl ch75 261013
#endif
return TRUE;
}
+1 -1
View File
@@ -2778,7 +2778,7 @@ void QuickButtonCallbackMButn( MOUSE_REGION *reg, INT32 reason )
b->uiFlags &= (~BUTTON_CLICKED_ON);
}
}
else if( b->uiFlags & BUTTON_CHECKBOX )
else if( b->uiFlags & BUTTON_CHECKBOX && b->uiFlags & BUTTON_ENABLED )//dnl ch77 131113
{
if( reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
{ //the check box button gets anchored, though it doesn't actually use the anchoring move callback.
+17
View File
@@ -5015,6 +5015,23 @@ BOOLEAN InternalInitItemDescriptionBox( OBJECTTYPE *pObject, INT16 sX, INT16 sY,
return FALSE;
}
//dnl ch77 251113 create attachment slots if not exist for NAS or remove empty slots for OAS
if(UsingNewAttachmentSystem())
{
if((*pObject)[ubStatusIndex]->attachments.empty())
InitItemAttachments(pObject);
}
else
{
attachmentList::iterator iter = (*pObject)[ubStatusIndex]->attachments.begin();
while(iter != (*pObject)[ubStatusIndex]->attachments.end())
{
if((*iter).exists())
++iter;
else
iter = (*pObject)[ubStatusIndex]->attachments.erase(iter);
}
}
//Set the current screen
guiCurrentItemDescriptionScreen = guiCurrentScreen;
+4
View File
@@ -1251,7 +1251,11 @@ typedef enum ePOCKET_TYPE
#define FIRST_ARMOUR 161
#define FIRST_MISC 201
#define FIRST_KEY 271
#ifdef JA2EDITOR
#define OLD_MAXITEMS 351//dnl ch74 191013
#else
#define OLD_MAXITEMS MAXITEMS
#endif
#define NOTHING NONE
typedef enum
{
+1 -1
View File
@@ -428,7 +428,7 @@ void ResizeWorldItems(void)//dnl ch75 271013
gWorldItems.resize(guiNumWorldItems);
#else
guiNumWorldItems = gWorldItems.size();
if(guiNumWorldItems - GetNumUsedWorldItems() < 100)
if(guiNumWorldItems - GetNumUsedWorldItems() < 50)
{
gWorldItems.resize(guiNumWorldItems + 100);
guiNumWorldItems = gWorldItems.size();
+1 -1
View File
@@ -959,4 +959,4 @@ void TacticalSquadListBtnCallBack(MOUSE_REGION * pRegion, INT32 iReason )
}
return;
}
}
+23 -22
View File
@@ -99,6 +99,11 @@ INT32 giXB = (0 + OLD_WORLD_COLS/2), giYB = (WORLD_ROWS/2 + OLD_WORLD_ROWS/2);
INT32 giXC = (0 + OLD_WORLD_COLS/2), giYC = (WORLD_ROWS/2 - OLD_WORLD_ROWS/2);
extern BOOLEAN gfValidLocationsChanged;//dnl ch45 051009
#ifdef JA2EDITOR
extern UINT32 guiBigMap;//dnl ch77 121113
#else
#define guiBigMap FRAME_BUFFER
#endif
void HandleOverheadUI( );
void ClickOverheadRegionCallback(MOUSE_REGION *reg,INT32 reason);
@@ -860,7 +865,6 @@ INT16 GetModifiedOffsetLandHeight( INT32 sGridNo )
return( sModifiedTileHeight );
}
void RenderOverheadMap( INT16 sStartPointX_M, INT16 sStartPointY_M, INT16 sStartPointX_S, INT16 sStartPointY_S, INT16 sEndXS, INT16 sEndYS, BOOLEAN fFromMapUtility )
{
INT8 bXOddFlag = 0;
@@ -872,8 +876,10 @@ void RenderOverheadMap( INT16 sStartPointX_M, INT16 sStartPointY_M, INT16 sStart
BOOLEAN fEndRenderRow = FALSE, fEndRenderCol = FALSE;
INT32 usTileIndex;
INT16 sX, sY;
UINT32 uiDestPitchBYTES;
UINT8 *pDestBuf;
//dnl ch77 111113 moved declarations from below
UINT32 uiDestPitchBYTES, uiSrcPitchBYTES, uiBigMap=(fFromMapUtility?guiBigMap:FRAME_BUFFER);
UINT8 *pDestBuf, *pSrcBuf, ubBitDepth;
UINT16 usWidth, usHeight;
LEVELNODE *pNode;
SMALL_TILE_DB *pTile;
INT16 sHeight;
@@ -894,10 +900,10 @@ void RenderOverheadMap( INT16 sStartPointX_M, INT16 sStartPointY_M, INT16 sStart
// Black color for the background!
//ColorFillVideoSurfaceArea( FRAME_BUFFER, sStartPointX_S, sStartPointY_S, sEndXS, sEndYS, 0 );
if(gfTacticalPlacementGUIActive)//dnl ch45 021009 Skip overwrite buttons area which is not refresh during scroll
ColorFillVideoSurfaceArea(FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-160, 0);
if(gfTacticalPlacementGUIActive)//dnl ch45 021009 Skip overwrite buttons area which is not refresh during scroll //dnl ch77 211113
ColorFillVideoSurfaceArea(uiBigMap, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-160, 0);
else
ColorFillVideoSurfaceArea(FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-120, 0);
ColorFillVideoSurfaceArea(uiBigMap, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-120, 0);
fInterfacePanelDirty = DIRTYLEVEL2;
InvalidateScreen();
@@ -913,8 +919,7 @@ void RenderOverheadMap( INT16 sStartPointX_M, INT16 sStartPointY_M, INT16 sStart
// Zero out area!
//ColorFillVideoSurfaceArea( FRAME_BUFFER, 0, 0, (INT16)(640), (INT16)(gsVIEWPORT_WINDOW_END_Y), Get16BPPColor( FROMRGB( 0, 0, 0 ) ) );
pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES );
pDestBuf = LockVideoSurface(uiBigMap, &uiDestPitchBYTES);//dnl ch77 211113
// Nur Karte und position der gebäude
do
@@ -1239,37 +1244,33 @@ void RenderOverheadMap( INT16 sStartPointX_M, INT16 sStartPointY_M, INT16 sStart
}
while( !fEndRenderCol );
}
UnLockVideoSurface( FRAME_BUFFER );
//dnl ch77 211113
UnLockVideoSurface(uiBigMap);
// OK, blacken out edges of smaller maps...
if ( gMapInformation.ubRestrictedScrollID != 0 )
{
CalculateRestrictedMapCoords( NORTH, &sX1, &sY1, &sX2, &sY2, sEndXS, sEndYS );
ColorFillVideoSurfaceArea( FRAME_BUFFER, sX1, sY1, sX2, sY2, Get16BPPColor( FROMRGB( 0, 0, 0 ) ) );
ColorFillVideoSurfaceArea( uiBigMap, sX1, sY1, sX2, sY2, Get16BPPColor( FROMRGB( 0, 0, 0 ) ) );
CalculateRestrictedMapCoords( EAST, &sX1, &sY1, &sX2, &sY2, sEndXS, sEndYS );
ColorFillVideoSurfaceArea( FRAME_BUFFER, sX1, sY1, sX2, sY2, Get16BPPColor( FROMRGB( 0, 0, 0 ) ) );
ColorFillVideoSurfaceArea( uiBigMap, sX1, sY1, sX2, sY2, Get16BPPColor( FROMRGB( 0, 0, 0 ) ) );
CalculateRestrictedMapCoords( SOUTH, &sX1, &sY1, &sX2, &sY2, sEndXS, sEndYS );
ColorFillVideoSurfaceArea( FRAME_BUFFER, sX1, sY1, sX2, sY2, Get16BPPColor( FROMRGB( 0, 0, 0 ) ) );
ColorFillVideoSurfaceArea( uiBigMap, sX1, sY1, sX2, sY2, Get16BPPColor( FROMRGB( 0, 0, 0 ) ) );
CalculateRestrictedMapCoords( WEST, &sX1, &sY1, &sX2, &sY2, sEndXS, sEndYS );
ColorFillVideoSurfaceArea( FRAME_BUFFER, sX1, sY1, sX2, sY2, Get16BPPColor( FROMRGB( 0, 0, 0 ) ) );
ColorFillVideoSurfaceArea( uiBigMap, sX1, sY1, sX2, sY2, Get16BPPColor( FROMRGB( 0, 0, 0 ) ) );
}
//DBrot: bigger overview code
if(!fFromMapUtility){//LJDOldSM
if(gfUseBiggerOverview && iResolution >= _1680x1050){
BltVideoObjectFromIndex(FRAME_BUFFER, uiOVERMAP, 0, ((SCREEN_WIDTH / 2) - (1432 / 2) - 40), 60, VO_BLT_SRCTRANSPARENCY, NULL);// Render border!
BltVideoObjectFromIndex(uiBigMap, uiOVERMAP, 0, ((SCREEN_WIDTH / 2) - (1432 / 2) - 40), 60, VO_BLT_SRCTRANSPARENCY, NULL);// Render border!
}else{
BltVideoObjectFromIndex(FRAME_BUFFER, uiOVERMAP, 0, xResOffset, yResOffset, VO_BLT_SRCTRANSPARENCY, NULL);// Render border!
BltVideoObjectFromIndex(uiBigMap, uiOVERMAP, 0, xResOffset, yResOffset, VO_BLT_SRCTRANSPARENCY, NULL);// Render border!
}
}
// Update the save buffer
UINT32 uiDestPitchBYTES, uiSrcPitchBYTES;
UINT8 *pDestBuf, *pSrcBuf;
UINT16 usWidth, usHeight;
UINT8 ubBitDepth;
else
return;
// Update saved buffer - do for the viewport size ony!
GetCurrentVideoSettings( &usWidth, &usHeight, &ubBitDepth );
pSrcBuf = LockVideoSurface(guiRENDERBUFFER, &uiSrcPitchBYTES);
+92 -74
View File
@@ -21,6 +21,9 @@
#include "map information.h"
#include "line.h"
#include "quantize wrap.h"
//dnl ch77 131113
#include "Editor Taskbar Utils.h"
#include "Text Input.h"
#define MINIMAP_X_SIZE 88//RADAR_WINDOW_WIDTH
#define MINIMAP_Y_SIZE 44//RADAR_WINDOW_HEIGHT
@@ -40,11 +43,11 @@ typedef struct
}RGBValues;
FLOAT gdXStep, gdYStep;
INT32 giMiniMap, gi8BitMiniMap;
UINT32 guiMiniMap=0, gui8BitMiniMap=0, guiBigMap=0;//dnl ch77 121113
HVSURFACE ghVSurface = NULL;
RGBValues* p24BitValues = NULL;
FDLG_LIST* FListNode = NULL;
BOOLEAN gfMapUtilityWindowActive = FALSE;
void GenerateAllMapsInit(void)
{
@@ -63,32 +66,56 @@ void GenerateAllMapsInit(void)
// Utililty file for sub-sampling/creating our radar screen maps.
// Loops through our maps directory and reads all *.map files, subsamples an area, color quantizes into an 8-bit image and writes to sti file in radarmaps.
// From editor will create radar map for you current map.
//dnl ch77 121113
UINT32 MapUtilScreenInit(void)
{
UINT8 ubBitDepth;
UINT16 usWidth, usHeight;
VSURFACE_DESC vs_desc;
vs_desc.fCreateFlags = VSURFACE_CREATE_DEFAULT | VSURFACE_SYSTEM_MEM_USAGE;
// Create render buffer
GetCurrentVideoSettings(&usWidth, &usHeight, &ubBitDepth);
vs_desc.fCreateFlags = VSURFACE_CREATE_DEFAULT | VSURFACE_SYSTEM_MEM_USAGE;
vs_desc.usWidth = MINIMAP_X_SIZE;
vs_desc.usHeight = MINIMAP_Y_SIZE;
vs_desc.ubBitDepth = ubBitDepth;
if(AddVideoSurface(&vs_desc, (UINT32*)&giMiniMap) == FALSE)
return(ERROR_SCREEN);
if(!GetVideoSurface(&ghVSurface, guiMiniMap))
{
vs_desc.usWidth = MINIMAP_X_SIZE;
vs_desc.usHeight = MINIMAP_Y_SIZE;
vs_desc.ubBitDepth = ubBitDepth;
if(AddVideoSurface(&vs_desc, (UINT32*)&guiMiniMap) == FALSE)
return(ERROR_SCREEN);
}
// Allocate 24 bit Surface
p24BitValues = (RGBValues*)MemAlloc(MINIMAP_X_SIZE * MINIMAP_Y_SIZE * sizeof(RGBValues));
if(!p24BitValues)
p24BitValues = (RGBValues*)MemAlloc(MINIMAP_X_SIZE * MINIMAP_Y_SIZE * sizeof(RGBValues));
//Allocate 8-bit surface
vs_desc.fCreateFlags = VSURFACE_CREATE_DEFAULT | VSURFACE_SYSTEM_MEM_USAGE;
vs_desc.usWidth = MINIMAP_X_SIZE;
vs_desc.usHeight = MINIMAP_Y_SIZE;
vs_desc.ubBitDepth = 8;
if(AddVideoSurface(&vs_desc, (UINT32*)&gi8BitMiniMap) == FALSE)
return(ERROR_SCREEN);
GetVideoSurface(&ghVSurface, gi8BitMiniMap);
if(!GetVideoSurface(&ghVSurface, gui8BitMiniMap))
{
vs_desc.usWidth = MINIMAP_X_SIZE;
vs_desc.usHeight = MINIMAP_Y_SIZE;
vs_desc.ubBitDepth = 8;
if(AddVideoSurface(&vs_desc, (UINT32*)&gui8BitMiniMap) == FALSE)
return(ERROR_SCREEN);
}
// Create big map buffer which contains whole map for radar map generation
vs_desc.usWidth = (640 * WORLD_COLS / OLD_WORLD_COLS);
vs_desc.usHeight = (320 * WORLD_ROWS / OLD_WORLD_ROWS) + 10;// +10, without this additional lines editor will crash as renderer go beyond them
vs_desc.ubBitDepth = ubBitDepth;
if(!GetVideoSurface(&ghVSurface, guiBigMap))
{
if(AddVideoSurface(&vs_desc, (UINT32*)&guiBigMap) == FALSE)
return(ERROR_SCREEN);
}
else if(!(ghVSurface->usWidth == vs_desc.usWidth && ghVSurface->usHeight == vs_desc.usHeight))
{
DeleteVideoSurfaceFromIndex( guiBigMap );
if(AddVideoSurface(&vs_desc, (UINT32*)&guiBigMap) == FALSE)
return(ERROR_SCREEN);
}
GetVideoSurface(&ghVSurface, gui8BitMiniMap);
return(TRUE);
}
//dnl ch77 131113
UINT32 MapUtilScreenHandle(void)
{
InputAtom InputEvent;
@@ -101,7 +128,7 @@ UINT32 MapUtilScreenHandle(void)
INT32 cnt, iX, iY, iSubX1, iSubY1, iSubX2, iSubY2, iWindowX, iWindowY, iCount;
FLOAT dX, dY, dStartX, dStartY;
while(DequeueSpecificEvent(&InputEvent, KEY_DOWN|KEY_UP) == TRUE)
while(DequeueSpecificEvent(&InputEvent, KEY_DOWN|KEY_UP|KEY_REPEAT) == TRUE)
{
if(InputEvent.usParam == ESC)
{
@@ -110,6 +137,9 @@ UINT32 MapUtilScreenHandle(void)
{
TrashFDlgList(FileList);
FileList = FListNode = NULL;
EnableEditorTaskbar();
EnableAllTextFields();
gfMapUtilityWindowActive = FALSE;
return(EDIT_SCREEN);
}
else
@@ -119,6 +149,17 @@ UINT32 MapUtilScreenHandle(void)
}
}
}
if(gfMapUtilityWindowActive)
{
GetVideoSurface(&ghVSurface, gui8BitMiniMap);
return(MAPUTILITY_SCREEN);
}
else
{
DisableEditorTaskbar();
DisableAllTextFields();
MapUtilScreenInit();
}
sDest16BPPColor = -1;
bAvR = bAvG = bAvB = 0;
// Zero out area!
@@ -139,31 +180,19 @@ UINT32 MapUtilScreenHandle(void)
return(ERROR_SCREEN);
}
// Render small map
iOffsetHorizontal = (SCREEN_WIDTH / 2) - (640 / 2);// Horizontal start postion of the overview map
iOffsetVertical = (SCREEN_HEIGHT - 160) / 2 - 160;// Vertical start position of the overview map
//iOffsetHorizontal = (SCREEN_WIDTH / 2) - (640 / 2);// Horizontal start postion of the overview map
//iOffsetVertical = (SCREEN_HEIGHT - 160) / 2 - 160;// Vertical start position of the overview map
iOffsetHorizontal = iOffsetVertical = 0;
ColorFillVideoSurfaceArea(guiBigMap, 0, 0, (INT16)(SCREEN_WIDTH), (INT16)(SCREEN_HEIGHT), Get16BPPColor(FROMRGB(0, 0, 0)));
InitNewOverheadDB((UINT8)giCurrentTilesetID);
gfOverheadMapDirty = TRUE;
//Buggler: interim code for radar map sti creation <= 360x360 based on DBrot bigger overview code
if(iResolution >= _1680x1050 && WORLD_COLS <= 360)
RenderOverheadMap(0, (WORLD_COLS/2), iOffsetHorizontal, iOffsetVertical, iOffsetHorizontal + (640 * WORLD_COLS / OLD_WORLD_COLS), iOffsetVertical + (320 * WORLD_ROWS / OLD_WORLD_ROWS), TRUE);
else
RenderOverheadMap(0, (WORLD_COLS/2), iOffsetHorizontal, iOffsetVertical, iOffsetHorizontal+640, iOffsetVertical+320, TRUE);
RenderOverheadMap(0, (WORLD_COLS/2), iOffsetHorizontal, iOffsetVertical, iOffsetHorizontal + (640 * WORLD_COLS / OLD_WORLD_COLS), iOffsetVertical + (320 * WORLD_ROWS / OLD_WORLD_ROWS), TRUE);
TrashOverheadMap();
// OK, NOW PROCESS OVERHEAD MAP ( SHOULD BE ON THE FRAMEBUFFER )
//Buggler: interim code for radar map sti creation <= 360x360 based on DBrot bigger overview code
if(iResolution >= _1680x1050 && WORLD_COLS <= 360)
{
gdXStep = (FLOAT)(640 * WORLD_COLS / OLD_WORLD_COLS) / (FLOAT)MINIMAP_X_SIZE;
gdYStep = (FLOAT)(320 * WORLD_ROWS / OLD_WORLD_ROWS) / (FLOAT)MINIMAP_Y_SIZE;
}
else
{
gdXStep = (FLOAT)640 / (FLOAT)MINIMAP_X_SIZE;
gdYStep = (FLOAT)320 / (FLOAT)MINIMAP_Y_SIZE;
}
gdXStep = (FLOAT)(640 * WORLD_COLS / OLD_WORLD_COLS) / (FLOAT)MINIMAP_X_SIZE;
gdYStep = (FLOAT)(320 * WORLD_ROWS / OLD_WORLD_ROWS) / (FLOAT)MINIMAP_Y_SIZE;
dStartX = iOffsetHorizontal;
dStartY = iOffsetVertical;
// Adjust if we are using a restricted map...
@@ -181,9 +210,8 @@ UINT32 MapUtilScreenHandle(void)
//LOCK BUFFERS
dX = dStartX;
dY = dStartY;
pDestBuf = (UINT16*)LockVideoSurface(giMiniMap, &uiDestPitchBYTES);
pSrcBuf = (UINT16*)LockVideoSurface(FRAME_BUFFER, &uiSrcPitchBYTES);
pDestBuf = (UINT16*)LockVideoSurface(guiMiniMap, &uiDestPitchBYTES);
pSrcBuf = (UINT16*)LockVideoSurface(guiBigMap, &uiSrcPitchBYTES);
for ( iX = 0; iX < MINIMAP_X_SIZE; iX++ )
{
dY = dStartY;
@@ -207,37 +235,18 @@ UINT32 MapUtilScreenHandle(void)
for ( iWindowY = iSubY1; iWindowY < iSubY2; iWindowY++ )
{
//Buggler: interim code for radar map sti creation <= 360x360 based on DBrot bigger overview code
if(iResolution >= _1680x1050 && WORLD_COLS <= 360)
if ( iWindowX >= iOffsetHorizontal && iWindowX < (iOffsetHorizontal + (640 * WORLD_COLS / OLD_WORLD_COLS)) && iWindowY >= iOffsetVertical && iWindowY < (iOffsetVertical + (320 * WORLD_ROWS / OLD_WORLD_ROWS)) )
{
if ( iWindowX >= iOffsetHorizontal && iWindowX < (iOffsetHorizontal + (640 * WORLD_COLS / OLD_WORLD_COLS)) && iWindowY >= iOffsetVertical && iWindowY < (iOffsetVertical + (320 * WORLD_ROWS / OLD_WORLD_ROWS)) )
{
s16BPPSrc = pSrcBuf[ ( iWindowY * (uiSrcPitchBYTES/2) ) + iWindowX ];
s16BPPSrc = pSrcBuf[ ( iWindowY * (uiSrcPitchBYTES/2) ) + iWindowX ];
uiRGBColor = GetRGBColor( s16BPPSrc );
uiRGBColor = GetRGBColor( s16BPPSrc );
bR += SGPGetRValue( uiRGBColor );
bG += SGPGetGValue( uiRGBColor );
bB += SGPGetBValue( uiRGBColor );
bR += SGPGetRValue( uiRGBColor );
bG += SGPGetGValue( uiRGBColor );
bB += SGPGetBValue( uiRGBColor );
// Average!
iCount++;
}
}
else
{
if ( iWindowX >= iOffsetHorizontal && iWindowX < (iOffsetHorizontal + 640) && iWindowY >= iOffsetVertical && iWindowY < (iOffsetVertical + 320) )
{
s16BPPSrc = pSrcBuf[ ( iWindowY * (uiSrcPitchBYTES/2) ) + iWindowX ];
uiRGBColor = GetRGBColor( s16BPPSrc );
bR += SGPGetRValue( uiRGBColor );
bG += SGPGetGValue( uiRGBColor );
bB += SGPGetBValue( uiRGBColor );
// Average!
iCount++;
}
// Average!
iCount++;
}
}
}
@@ -265,14 +274,15 @@ UINT32 MapUtilScreenHandle(void)
//Increment
dX += gdXStep;
}
UnLockVideoSurface(giMiniMap);
UnLockVideoSurface(FRAME_BUFFER);
// RENDER!
BltVideoSurface(FRAME_BUFFER, giMiniMap, 0, iOffsetHorizontal+10, iOffsetVertical+360, VS_BLT_FAST|VS_BLT_USECOLORKEY, NULL);
//QUantize!
pDataPtr = (UINT8*)LockVideoSurface(gi8BitMiniMap, &uiSrcPitchBYTES);
UnLockVideoSurface(guiMiniMap);
iOffsetVertical = SCREEN_HEIGHT - 480;
BltVideoSurface(FRAME_BUFFER, guiMiniMap, 0, iOffsetHorizontal+10, iOffsetVertical+360, VS_BLT_FAST|VS_BLT_USECOLORKEY, NULL);
pDestBuf = (UINT16*)LockVideoSurface(FRAME_BUFFER, &uiDestPitchBYTES);
Blt16BPPTo16BPP((UINT16 *)pDestBuf, uiDestPitchBYTES, (UINT16 *)pSrcBuf, uiSrcPitchBYTES, 0, 0, 0, 0, min((640 * WORLD_COLS / OLD_WORLD_COLS), SCREEN_WIDTH), min((320 * WORLD_ROWS / OLD_WORLD_ROWS), SCREEN_HEIGHT - 160));
UnLockVideoSurface(guiBigMap);
//QUantize!
pDataPtr = (UINT8*)LockVideoSurface(gui8BitMiniMap, &uiSrcPitchBYTES);
QuantizeImage(pDataPtr, (UINT8*)p24BitValues, MINIMAP_X_SIZE, MINIMAP_Y_SIZE, pPalette);
SetVideoSurfacePalette(ghVSurface, pPalette);
// Blit!
@@ -296,7 +306,7 @@ UINT32 MapUtilScreenHandle(void)
zFilename[cnt] = '\0';
sprintf(zFilename2, "RADARMAPS\\%s.STI", zFilename);
WriteSTIFile((INT8*)pDataPtr, pPalette, MINIMAP_X_SIZE, MINIMAP_Y_SIZE, (STR)zFilename2, CONVERT_ETRLE_COMPRESS, 0);
UnLockVideoSurface(gi8BitMiniMap);
UnLockVideoSurface(gui8BitMiniMap);
SetFont(TINYFONT1);
SetFontBackground(FONT_MCOLOR_BLACK);
SetFontForeground(FONT_MCOLOR_DKGRAY);
@@ -307,7 +317,15 @@ UINT32 MapUtilScreenHandle(void)
if(FListNode)
FListNode = FListNode->pNext;
if(fEditModeFirstTime == FALSE && FListNode == NULL)
return(EDIT_SCREEN);
{
if(gfWorldLoaded)
{
gfMapUtilityWindowActive = TRUE;
return(MAPUTILITY_SCREEN);
}
else
return(EDIT_SCREEN);
}
return(MAPUTILITY_SCREEN);
}
+2 -1
View File
@@ -159,7 +159,8 @@ void WriteSTIFile( INT8 *pData, SGPPaletteEntry *pPalette, INT16 sWidth, INT16 s
}
//dnl ch49 061009
FileDelete(cOutputName);// If file exist FileOpen will not truncate, so delete.
if(FileExists(cOutputName))//dnl ch77 111113
FileDelete(cOutputName);// If file exist FileOpen will not truncate, so delete.
HWFILE hFile = FileOpen(cOutputName, FILE_ACCESS_WRITE|FILE_CREATE_ALWAYS, FALSE);
if(!hFile)
return;
+1 -1
View File
@@ -1976,4 +1976,4 @@ void CopyToClipboard( void )
// finish up
CloseClipboard();
}
}
}
+4
View File
@@ -29,6 +29,7 @@
#include "PreBattle Interface.h"
#include "Tactical Placement GUI.h"//dnl ch45 071009
#include "Map Screen Interface Map Inventory.h"//dnl ch51 081009
#include "World Items.h"//dnl ch77 191113
#endif
#include "SaveLoadScreen.h"
@@ -234,6 +235,9 @@ void GameLoop(void)
UINT32 uiOldScreen=guiCurrentScreen;
clock_t startTime = clock(); // decrease CPU load patch from defrog
if(_LeftButtonDown | _RightButtonDown)//dnl ch77 191113 to prevent memory corruption during resize
ResizeWorldItems();
//DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"GameLoop: get mouse position");
GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!