Merge pull request #28 from nev6502/Nev6502_Isometric

Nev6502 isometric
This commit is contained in:
jmarshall23
2020-07-08 08:24:09 -07:00
committed by GitHub
4 changed files with 41 additions and 27 deletions
+11 -7
View File
@@ -863,8 +863,10 @@ CELL DisplayClass::Set_Cursor_Pos(CELL pos)
int x = Cell_X(pos + ZoneOffset);
int y = Cell_Y(pos + ZoneOffset);
if (x < Coord_XCell(TacticalCoord)) x = Coord_XCell(TacticalCoord);
if (y < Coord_YCell(TacticalCoord)) y = Coord_YCell(TacticalCoord);
// JJ TODO: This code appears to prevent object placement in the scenario editor when scrolled to the top of a large map
//if (x < Coord_XCell(TacticalCoord)) x = Coord_XCell(TacticalCoord);
//if (y < Coord_YCell(TacticalCoord)) y = Coord_YCell(TacticalCoord);
if (x+w >= Coord_XCell(TacticalCoord) + Lepton_To_Cell(TacLeptonWidth)) x = Coord_XCell(TacticalCoord)+Lepton_To_Cell(TacLeptonWidth)-w;
if (y+h >= Coord_YCell(TacticalCoord) + Lepton_To_Cell(TacLeptonHeight)) y = Coord_YCell(TacticalCoord)+Lepton_To_Cell(TacLeptonHeight)-h;
pos = XY_Cell(x, y) - ZoneOffset;
@@ -1190,6 +1192,8 @@ bool DisplayClass::Scroll_Map(DirType facing, int & distance, bool really)
** If the distance is invalid then no further checking is required. Bail
** with a no-can-do flag.
*/
if (distance == 0) return(false);
FacingType crude = Dir_Facing(facing);
@@ -1201,11 +1205,11 @@ bool DisplayClass::Scroll_Map(DirType facing, int & distance, bool really)
if (crude == FACING_NW) facing = DIR_W;
if (crude == FACING_NE) facing = DIR_E;
}
if (Coord_X(TacticalCoord) + TacLeptonWidth == Cell_To_Lepton(MapCellX+MapCellWidth) && crude != FACING_E) {
if (Coord_X(TacticalCoord) + TacLeptonWidth == Cell_To_Lepton(MapCellX+(MapCellWidth*1.25)) && crude != FACING_E) {
if (crude == FACING_NE) facing = DIR_N;
if (crude == FACING_SE) facing = DIR_S;
}
if (Coord_Y(TacticalCoord) + TacLeptonHeight == Cell_To_Lepton(MapCellY+MapCellHeight) && crude != FACING_S) {
if (Coord_Y(TacticalCoord) + TacLeptonHeight == Cell_To_Lepton(MapCellY+(MapCellHeight*1.25)) && crude != FACING_S) {
if (crude == FACING_SE) facing = DIR_E;
if (crude == FACING_SW) facing = DIR_W;
}
@@ -1220,7 +1224,7 @@ bool DisplayClass::Scroll_Map(DirType facing, int & distance, bool really)
*/
int xx = (int)(short)Coord_X(coord) - (short)Cell_To_Lepton(MapCellX);
int yy = (int)(short)Coord_Y(coord) - (short)Cell_To_Lepton(MapCellY);
bool shifted = Confine_Rect(&xx, &yy, TacLeptonWidth, TacLeptonHeight, Cell_To_Lepton(MapCellWidth), Cell_To_Lepton(MapCellHeight));
bool shifted = Confine_Rect(&xx, &yy, TacLeptonWidth, TacLeptonHeight, Cell_To_Lepton(MapCellWidth)*1.25, Cell_To_Lepton(MapCellHeight)*1.25);
if (xx < 0) {
xx = 0;
shifted = true;
@@ -3500,7 +3504,7 @@ void DisplayClass::Mouse_Right_Press(void)
PendingObjectPtr = 0;
PendingObject = 0;
PendingHouse = HOUSE_NONE;
Set_Cursor_Shape(0);
//Set_Cursor_Shape(0);
} else {
if (IsRepairMode) {
IsRepairMode = false;
@@ -4255,7 +4259,7 @@ void DisplayClass::Set_Tactical_Position(COORDINATE coord)
int yy = (int)Coord_Y(coord) - (int)Cell_To_Lepton(MapCellY);
// Confine_Rect(&xx, &yy, TacLeptonWidth, TacLeptonHeight, Cell_To_Lepton(MapCellWidth) + GlyphXClientSidebarWidthInLeptons, Cell_To_Lepton(MapCellHeight)); // Needed to accomodate Glyphx client sidebar. ST - 4/12/2019 5:29PM
Confine_Rect(&xx, &yy, TacLeptonWidth, TacLeptonHeight, Cell_To_Lepton(MapCellWidth), Cell_To_Lepton(MapCellHeight));
//Confine_Rect(&xx, &yy, 0, 0, Cell_To_Lepton(MapCellWidth*2), Cell_To_Lepton(MapCellHeight*2));
coord = XY_Coord(xx + Cell_To_Lepton(MapCellX), yy + Cell_To_Lepton(MapCellY));
if (ScenarioInit) {
+2 -1
View File
@@ -880,7 +880,8 @@ long MapClass::Overpass(void)
*/
for (int y = 0; y < MapCellHeight; y++) {
for (int x = 0; x < MapCellWidth; x++) {
CELL cell = (MapCellY+y) * MAP_CELL_W + (MapCellX+x);
//CELL cell = (MapCellY+y) * MAP_CELL_W + (MapCellX+x);
CELL cell = XY_Cell(x,y); // Replaced because a crash was being caused
value += (*this)[cell].Tiberium_Adjust(true);
(*this)[cell].Recalc_Attributes();
}
+7
View File
@@ -534,6 +534,13 @@ void MapEditClass::AI(KeyNumType & input, int x, int y)
/*
** Check for mouse motion while left button is down.
*/
//Draw mouse cell position (CellX/CellY)
//CELL template_cell = (ZoneCell + ZoneOffset);
//char tmp[12];
//sprintf(tmp, "%d , %d", Cell_X(template_cell), Cell_Y(template_cell));
//GL_DrawText(6, 64, 64, tmp);
rc = Mouse_Moved();
if (Keyboard->Down(KN_LMOUSE) && rc) {
+21 -19
View File
@@ -105,7 +105,11 @@ void ScrollClass::AI(KeyNumType &input, int x, int y)
bool noscroll = false;
if (!noscroll) {
bool at_screen_edge = (y == 0 || x == 0 || x >= SeenBuff.Get_Width()-1 || y >= SeenBuff.Get_Height()-1);
int screen_width = SeenBuff.Get_Width();
int screen_height = SeenBuff.Get_Height();
bool at_screen_edge = (y == 0 || x == 0 || x >= screen_width - 1 || y >= screen_height - 1);
/*
** Verify that the mouse is over a scroll region.
@@ -113,28 +117,26 @@ void ScrollClass::AI(KeyNumType &input, int x, int y)
if (Inertia || at_screen_edge) {
if (at_screen_edge) {
player_scrolled=true;
player_scrolled = true;
int half_screen_width = screen_width / 2;
int half_screen_height = screen_height / 2;
/*
** Adjust the mouse coordinates to emphasize the
** cardinal directions over the diagonals.
*/
int altx = x;
if (altx < 50 * RESFACTOR) altx -= ((50 * RESFACTOR)-altx);
altx = max(altx, 0);
if (altx > ((320-50) * RESFACTOR)) altx += altx-((320-50) * RESFACTOR);
altx = min(altx, (320 * RESFACTOR));
if (altx > (50 * RESFACTOR) && altx < ((320-50) * RESFACTOR)) {
altx += (((320/2) * RESFACTOR)-altx)/2;
int alty = y;
if (alty == 0 || alty >= screen_height - 1){
if (altx != (half_screen_width)) {
float offset_x = (half_screen_width - altx) * .7;
altx = altx + offset_x;
}
}
int alty = y;
if (alty < (50 * RESFACTOR)) alty -= (50 * RESFACTOR)-alty;
alty = max(alty, 0);
if (alty > (150 * RESFACTOR)) alty += alty-(150 * RESFACTOR);
alty = min(alty, 200 * RESFACTOR);
direction = (DirType)Desired_Facing256((320/2) * RESFACTOR, (200/2) * RESFACTOR, altx, alty);
direction = (DirType)Desired_Facing256((half_screen_width), (half_screen_height), altx, alty);
}
int control = Dir_Facing(direction);
@@ -168,9 +170,9 @@ void ScrollClass::AI(KeyNumType &input, int x, int y)
/*
** Increase the scroll rate if the mouse button is held down.
*/
// if (Keyboard->Down(KN_LMOUSE)) {
// rate = Bound(rate-3, 0, 4);
// }
// if (Keyboard->Down(KN_LMOUSE)) {
// rate = Bound(rate-3, 0, 4);
// }
if (Keyboard->Down(KN_RMOUSE)) {
rate = Bound(rate+1, 4, (int)(sizeof(_rate)/sizeof(_rate[0]))-1);
}
@@ -180,7 +182,7 @@ void ScrollClass::AI(KeyNumType &input, int x, int y)
** one of the 8 facings, then adjust the direction value
** accordingly.
*/
direction = Facing_Dir(Dir_Facing(direction));
direction = Facing_Dir(Dir_Facing(direction)) - (1<<5);
int distance = _rate[rate]/2;