Add backend support for multiple brush sizes for internal map editor.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@4734 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2008-04-21 17:14:13 +00:00
parent e853c606f8
commit 843713a153
3 changed files with 31 additions and 37 deletions

View File

@ -41,58 +41,51 @@ is invalid (not currently being used)
UDWORD buildState = BUILD3D_NONE; UDWORD buildState = BUILD3D_NONE;
BUILDDETAILS sBuildDetails; BUILDDETAILS sBuildDetails;
HIGHLIGHT buildSite; HIGHLIGHT buildSite;
int brushSize = 1;
bool editMode = false;
// Initialisation function for statis & globals in this module. // Initialisation function for statis & globals in this module.
// //
void Edit3DInitVars(void) void Edit3DInitVars(void)
{ {
buildState = BUILD3D_NONE; buildState = BUILD3D_NONE;
brushSize = 1;
} }
/* Raises a tile by a #defined height */ /* Raises a tile by a #defined height */
void raiseTile(int tile3dX, int tile3dY) void raiseTile(int tile3dX, int tile3dY)
{ {
MAPTILE *psTile; int i, j;
if (tile3dX < 0 || tile3dX > mapWidth - 1 || tile3dY < 0 || tile3dY > mapHeight - 1) if (tile3dX < 0 || tile3dX > mapWidth - 1 || tile3dY < 0 || tile3dY > mapHeight - 1)
{ {
return; return;
} }
for (i = tile3dX; i <= MIN(mapWidth - 1, tile3dX + brushSize); i++)
psTile = mapTile(tile3dX,tile3dY); {
adjustTileHeight(psTile,TILE_RAISE); for (j = tile3dY; j <= MIN(mapHeight - 1, tile3dY + brushSize); j++)
{
psTile = mapTile(tile3dX+1,tile3dY); adjustTileHeight(mapTile(i, j), TILE_RAISE);
adjustTileHeight(psTile,TILE_RAISE); }
}
psTile = mapTile(tile3dX+1,tile3dY+1);
adjustTileHeight(psTile,TILE_RAISE);
psTile = mapTile(tile3dX,tile3dY+1);
adjustTileHeight(psTile,TILE_RAISE);
} }
/* Lowers a tile by a #defined height */ /* Lowers a tile by a #defined height */
void lowerTile(int tile3dX, int tile3dY) void lowerTile(int tile3dX, int tile3dY)
{ {
MAPTILE *psTile; int i, j;
if (tile3dX < 0 || tile3dX > mapWidth - 1 || tile3dY < 0 || tile3dY > mapHeight - 1) if (tile3dX < 0 || tile3dX > mapWidth - 1 || tile3dY < 0 || tile3dY > mapHeight - 1)
{ {
return; return;
} }
for (i = tile3dX; i <= MIN(mapWidth - 1, tile3dX + brushSize); i++)
psTile = mapTile(tile3dX,tile3dY); {
adjustTileHeight(psTile,TILE_LOWER); for (j = tile3dY; j <= MIN(mapHeight - 1, tile3dY + brushSize); j++)
{
psTile = mapTile(tile3dX+1,tile3dY); adjustTileHeight(mapTile(i, j), TILE_LOWER);
adjustTileHeight(psTile,TILE_LOWER); }
}
psTile = mapTile(tile3dX+1,tile3dY+1);
adjustTileHeight(psTile,TILE_LOWER);
psTile = mapTile(tile3dX,tile3dY+1);
adjustTileHeight(psTile,TILE_LOWER);
} }
/* Ensures any adjustment to tile elevation is within allowed ranges */ /* Ensures any adjustment to tile elevation is within allowed ranges */

View File

@ -70,6 +70,8 @@ extern BUILDDETAILS sBuildDetails;
extern UDWORD buildState; extern UDWORD buildState;
extern UDWORD temp; extern UDWORD temp;
extern bool editMode;
extern int brushSize;
/*returns true if the build state is not equal to BUILD3D_NONE*/ /*returns true if the build state is not equal to BUILD3D_NONE*/
extern BOOL tryingToGetLocation(void); extern BOOL tryingToGetLocation(void);

View File

@ -78,7 +78,6 @@
//#define EDIT_OPTIONS //#define EDIT_OPTIONS
static UDWORD newMapWidth, newMapHeight; static UDWORD newMapWidth, newMapHeight;
static bool editPause = false;
#define RETXOFFSET (0)// Reticule button offset #define RETXOFFSET (0)// Reticule button offset
#define RETYOFFSET (0) #define RETYOFFSET (0)
@ -1347,7 +1346,7 @@ static void intProcessOptions(UDWORD id)
if (mapNew(newMapWidth, newMapHeight)) if (mapNew(newMapWidth, newMapHeight))
{ {
// Set pause // Set pause
editPause = true; editMode = true;
setEditPause(true); setEditPause(true);
/* Managed to create a new map so quit the option screen */ /* Managed to create a new map so quit the option screen */
intRemoveOptions(); intRemoveOptions();
@ -1416,16 +1415,16 @@ static void intProcessOptions(UDWORD id)
intMode = INT_NORMAL; intMode = INT_NORMAL;
break; break;
case IDOPT_PAUSE: case IDOPT_PAUSE:
if (editPause) if (editMode)
{ {
widgSetButtonState(psWScreen, IDOPT_PAUSE, 0); widgSetButtonState(psWScreen, IDOPT_PAUSE, 0);
editPause = false; editMode = false;
setEditPause(false); setEditPause(false);
} }
else else
{ {
widgSetButtonState(psWScreen, IDOPT_PAUSE, WBUT_CLICKLOCK); widgSetButtonState(psWScreen, IDOPT_PAUSE, WBUT_CLICKLOCK);
editPause = true; editMode = true;
setEditPause(true); setEditPause(true);
} }
break; break;
@ -1784,7 +1783,7 @@ INT_RETVAL intRunWidgets(void)
case IDRET_BUILD: case IDRET_BUILD:
intResetScreen(true); intResetScreen(true);
widgSetButtonState(psWScreen, IDRET_BUILD, WBUT_CLICKLOCK); widgSetButtonState(psWScreen, IDRET_BUILD, WBUT_CLICKLOCK);
if (editPause) if (editMode)
{ {
intProcessOptions(IDOPT_STRUCT); intProcessOptions(IDOPT_STRUCT);
} }
@ -1797,7 +1796,7 @@ INT_RETVAL intRunWidgets(void)
case IDRET_MANUFACTURE: case IDRET_MANUFACTURE:
intResetScreen(true); intResetScreen(true);
widgSetButtonState(psWScreen, IDRET_MANUFACTURE, WBUT_CLICKLOCK); widgSetButtonState(psWScreen, IDRET_MANUFACTURE, WBUT_CLICKLOCK);
if (editPause) if (editMode)
{ {
intProcessOptions(IDOPT_DROID); intProcessOptions(IDOPT_DROID);
} }
@ -4153,7 +4152,7 @@ BOOL intAddOptions(void)
{ {
return false; return false;
} }
if (editPause) if (editMode)
{ {
widgSetButtonState(psWScreen, IDOPT_PAUSE, WBUT_CLICKLOCK); widgSetButtonState(psWScreen, IDOPT_PAUSE, WBUT_CLICKLOCK);
} }
@ -7054,10 +7053,10 @@ void intCheckReticuleButtons(void)
int i; int i;
ReticuleEnabled[RETBUT_CANCEL].Enabled = true; ReticuleEnabled[RETBUT_CANCEL].Enabled = true;
ReticuleEnabled[RETBUT_FACTORY].Enabled = editPause; ReticuleEnabled[RETBUT_FACTORY].Enabled = editMode;
ReticuleEnabled[RETBUT_RESEARCH].Enabled = false; ReticuleEnabled[RETBUT_RESEARCH].Enabled = false;
ReticuleEnabled[RETBUT_BUILD].Enabled = editPause; ReticuleEnabled[RETBUT_BUILD].Enabled = editMode;
ReticuleEnabled[RETBUT_DESIGN].Enabled = editPause; ReticuleEnabled[RETBUT_DESIGN].Enabled = editMode;
ReticuleEnabled[RETBUT_INTELMAP].Enabled = true; ReticuleEnabled[RETBUT_INTELMAP].Enabled = true;
ReticuleEnabled[RETBUT_COMMAND].Enabled = false; ReticuleEnabled[RETBUT_COMMAND].Enabled = false;