Rubber band selection now works.

This commit is contained in:
Justin Marshall
2020-07-19 14:07:37 -07:00
parent 24704c9ad8
commit f09caa46da
5 changed files with 33 additions and 25 deletions
+1
View File
@@ -1450,6 +1450,7 @@ void CellClass::Draw_It(int x, int y, bool objects)
if (object->IsToDisplay && (!object->Is_Techno() || ((TechnoClass *)object)->Visual_Character() == VISUAL_NORMAL) && Map.Coord_To_Pixel(object->Render_Coord(), xx, yy)) {
{
ConvertCoordsToIsometric(xx, yy);
object->SetRenderXY(xx, yy);
object->Draw_It(xx, yy, WINDOW_TACTICAL);
if (Debug_Map) {
object->IsToDisplay = true;
+14 -21
View File
@@ -2917,15 +2917,11 @@ static bool should_exclude_from_selection(ObjectClass* obj)
}
void DisplayClass::Select_These(COORDINATE coord1, COORDINATE coord2, bool additive)
{
COORDINATE tcoord = TacticalCoord; //Cell_Coord(TacticalCell) & 0xFF00FF00L;
coord1 = Coord_Add(tcoord, coord1);
coord2 = Coord_Add(tcoord, coord2);
int x1 = Coord_X(coord1);
int x2 = Coord_X(coord2);
int y1 = Coord_Y(coord1);
int y2 = Coord_Y(coord2);
{
int x1 = Lepton_To_Pixel(Coord_X(coord1));
int x2 = Lepton_To_Pixel(Coord_X(coord2));
int y1 = Lepton_To_Pixel(Coord_Y(coord1));
int y2 = Lepton_To_Pixel(Coord_Y(coord2));
/*
** Ensure that coordinate number one represents the upper left corner
@@ -2952,9 +2948,14 @@ void DisplayClass::Select_These(COORDINATE coord1, COORDINATE coord2, bool addit
AllowVoice = true;
for (int index = 0; index < Layer[LAYER_GROUND].Count(); index++) {
ObjectClass * obj = Layer[LAYER_GROUND][index];
COORDINATE ocoord = obj->Center_Coord();
int x = Coord_X(ocoord);
int y = Coord_Y(ocoord);
//COORDINATE ocoord = obj->Center_Coord();
int x = obj->GetRenderX();
int y = obj->GetRenderY();
// Not on screen.
if (x == -1 && y == -1) {
continue;
}
/*
** Only try to select objects that are allowed to be selected, and are within the bounding box.
@@ -3934,15 +3935,7 @@ void DisplayClass::Mouse_Left_Release(CELL cell, int x, int y, ObjectClass * obj
if (IsRubberBand) {
Refresh_Band();
int _BandX = BandX;
int _BandY = BandY;
int _x = x;
int _y = y;
CellClass::ConvertIsoCoordsToScreen(_BandX, _BandY);
CellClass::ConvertIsoCoordsToScreen(_x, _y);
Select_These(XYP_Coord(_BandX, _BandY), XYP_Coord(_x, _y));
Select_These(XYP_Coord(BandX, BandY), XYP_Coord(x, y));
Set_Default_Mouse(MOUSE_NORMAL, wsmall);
IsRubberBand = false;
IsTentative = false;
+9
View File
@@ -141,6 +141,8 @@ ObjectClass::ObjectClass(RTTIType rtti, int id) :
Strength(255),
IsSelectedMask(0) // Mask showing who has selected this object
{
renderX = -1;
renderY = -1;
}
@@ -1287,6 +1289,13 @@ bool ObjectClass::Select(bool allow_mixed)
return(true);
}
//
// ObjectClass::SetRenderXY
//
void ObjectClass::SetRenderXY(int x, int y) {
renderX = x;
renderY = y;
}
/***********************************************************************************************
* ObjectClass::Render -- Displays the object onto the map. *
+8 -3
View File
@@ -179,7 +179,7 @@ class ObjectClass : public AbstractClass
virtual COORDINATE Render_Coord(void) const;
virtual COORDINATE Sort_Y(void) const;
virtual COORDINATE Fire_Coord(int which) const;
virtual COORDINATE Exit_Coord(void) const;
virtual COORDINATE Exit_Coord(void) const;
/*
** Object entry and exit from the game system.
@@ -207,6 +207,9 @@ class ObjectClass : public AbstractClass
virtual void Look(bool incremental=false);
virtual bool Mark(MarkType=MARK_CHANGE);
virtual void SetRenderXY(int x, int y);
int GetRenderX() const { return renderX; }
int GetRenderY() const { return renderY; }
private:
virtual void Mark_For_Redraw(void);
@@ -264,10 +267,12 @@ class ObjectClass : public AbstractClass
#ifdef CHEAT_KEYS
virtual void Debug_Dump(MonoClass *mono) const;
#endif
virtual void Move(FacingType);
virtual void Move(FacingType);
enum {FLIGHT_LEVEL=256};
private:
int renderX;
int renderY;
};
#endif
+1 -1
View File
@@ -1491,7 +1491,7 @@ void RadarClass::Radar_Cursor(int forced)
y1-= _last_frame;
x2+= _last_frame;
y2+= _last_frame;
/*
** Finally mark the map (actually remove the marks that indicate the radar cursor was there
*/