mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
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:
+92
-74
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user