Example #1
0
void IHaveDragPoints::ClearPointsForOverwrite()
{
   for (int i = 0; i < m_vdpoint.Size(); i++)
   {
      if (m_vdpoint.ElementAt(i)->m_selectstate != eNotSelected/*GetPTable()->m_pselcur == m_vdpoint.ElementAt(i)*/)
      {
         //GetPTable()->SetSel(GetPTable());
         GetPTable()->AddMultiSel(GetPTable(), fFalse, fTrue);
      }

      m_vdpoint.ElementAt(i)->Release();
   }

   m_vdpoint.RemoveAllElements();
}
Example #2
0
void IHaveDragPoints::FlipPointX(Vertex2D *pvCenter)
{
   GetIEditable()->BeginUndo();
   GetIEditable()->MarkForUndo();

   Vertex2D newcenter;
   GetPointCenter(&newcenter);

   const float xcenter = pvCenter->x;

   for (int i = 0; i < m_vdpoint.Size(); i++)
   {
      const float deltax = m_vdpoint.ElementAt(i)->m_v.x - xcenter;

      m_vdpoint.ElementAt(i)->m_v.x -= deltax*2.0f;
   }

   const float deltax = newcenter.x - xcenter;
   newcenter.x -= deltax*2.0f;
   PutPointCenter(&newcenter);

   ReverseOrder();

   GetIEditable()->EndUndo();

   GetPTable()->SetDirtyDraw();
}
Example #3
0
// this function draws the shape of the object with a black outline (no solid fill)
// only used in the editor and not the game
//
// this is called after the grid lines have been drawn on the map.  draws a solid
// outline over the grid lines
//
void DispReel::Render(Sur * const psur)
{
   if (!GetPTable()->GetEMReelsEnabled()) return;

   psur->SetBorderColor(RGB(0, 0, 0), false, 0);
   psur->SetFillColor(-1);
   psur->SetObject(this);
   psur->SetObject(NULL);

   // draw background box
   psur->Rectangle(m_d.m_v1.x, m_d.m_v1.y, m_d.m_v2.x, m_d.m_v2.y);

   // draw n reels in the box
   for (int i = 0; i < m_d.m_reelcount; ++i)
   {
      // set up top corner point
      const float fi = (float)i;
      const float x = m_d.m_v1.x + fi*(m_d.m_width + m_d.m_reelspacing) + m_d.m_reelspacing;
      const float y = m_d.m_v1.y + m_d.m_reelspacing;
      const float x2 = x + m_d.m_width;
      const float y2 = y + m_d.m_height;

      // set up points (clockwise)
      const Vertex2D rgv[4] = { Vertex2D(x, y), Vertex2D(x2, y), Vertex2D(x2, y2), Vertex2D(x, y2) };
      psur->Polygon(rgv, 4);
   }
}
Example #4
0
void ISelect::OnLButtonDown(int x, int y)
{
   m_fDragging = true;
   m_fMarkedForUndo = false; // So we will be marked when and if we are dragged
   m_ptLast.x = x;
   m_ptLast.y = y;

   SetCapture(GetPTable()->m_hwnd);

   SetObjectPos();
}
Example #5
0
void IHaveDragPoints::ScalePoints(float scalex, float scaley, Vertex2D *pvCenter, const bool useElementsCenter)
{
   Vertex2D newcenter;
   GetPointCenter(&newcenter);

   GetIEditable()->BeginUndo();
   GetIEditable()->MarkForUndo();

   if (useElementsCenter)
   {
      /* Don't use the pvCenter anymore! pvCenter is the mouse position when scaling is activated.
      Because the mouse position (scaling center) isn't shown in the editor use the element's center returned by GetPointCenter() */
      const float centerx = newcenter.x;
      const float centery = newcenter.y;

      for (int i = 0; i < m_vdpoint.Size(); i++)
      {
         DragPoint * const pdp1 = m_vdpoint.ElementAt(i);
         const float dx = (pdp1->m_v.x - centerx) * scalex;
         const float dy = (pdp1->m_v.y - centery) * scaley;
         pdp1->m_v.x = centerx + dx;
         pdp1->m_v.y = centery + dy;
      }
   }
   else
   {
      const float centerx = pvCenter->x;
      const float centery = pvCenter->y;

      for (int i = 0; i < m_vdpoint.Size(); i++)
      {
         DragPoint * const pdp1 = m_vdpoint.ElementAt(i);
         const float dx = (pdp1->m_v.x - centerx) * scalex;
         const float dy = (pdp1->m_v.y - centery) * scaley;
         pdp1->m_v.x = centerx + dx;
         pdp1->m_v.y = centery + dy;
      }

      // Move object center as well (if scaling from object center,
      // this will have no effect)
      {
         const float dx = (newcenter.x - centerx) * scalex;
         const float dy = (newcenter.y - centery) * scaley;
         newcenter.x = centerx + dx;
         newcenter.y = centery + dy;
         PutPointCenter(&newcenter);
      }
   }

   GetIEditable()->EndUndo();

   GetPTable()->SetDirtyDraw();
}
Example #6
0
void IHaveDragPoints::TranslatePoints(Vertex2D *pvOffset)
{
   GetIEditable()->BeginUndo();
   GetIEditable()->MarkForUndo();

   for (int i = 0; i < m_vdpoint.Size(); i++)
   {
      DragPoint * const pdp1 = m_vdpoint.ElementAt(i);
      pdp1->m_v.x += pvOffset->x;
      pdp1->m_v.y += pvOffset->y;
   }

   Vertex2D newcenter;
   GetPointCenter(&newcenter);

   newcenter.x += pvOffset->x;
   newcenter.y += pvOffset->y;

   PutPointCenter(&newcenter);

   GetIEditable()->EndUndo();

   GetPTable()->SetDirtyDraw();
}
Example #7
0
void ISelect::OnMouseMove(int x, int y)
{
   PinTable * const ptable = GetPTable();
   const float inv_zoom = 1.0f / ptable->m_zoom;

   if ((x == m_ptLast.x) && (y == m_ptLast.y))
   {
      return;
   }

   if (m_fDragging && !GetIEditable()->GetISelect()->m_fLocked) // For drag points, follow the lock of the parent
   {
      if (!m_fMarkedForUndo)
      {
         m_fMarkedForUndo = true;
         GetIEditable()->BeginUndo();
         GetIEditable()->MarkForUndo();
      }
      MoveOffset((x - m_ptLast.x)*inv_zoom, (y - m_ptLast.y)*inv_zoom);
      m_ptLast.x = x;
      m_ptLast.y = y;
      SetObjectPos();
   }
}
Example #8
0
void IHaveDragPoints::RotatePoints(float ang, Vertex2D *pvCenter, const bool useElementCenter)
{
   Vertex2D newcenter;
   GetPointCenter(&newcenter);

   GetIEditable()->BeginUndo();
   GetIEditable()->MarkForUndo();

   if (useElementCenter)
   {
      /* Don't use the pvCenter anymore! pvCenter is the mouse position when rotating is activated.
      Because the mouse position (rotation center) isn't shown in the editor use the element's center returned by GetPointCenter() */
      const float centerx = newcenter.x;
      const float centery = newcenter.y;

      const float sn = sinf(ANGTORAD(ang));
      const float cs = cosf(ANGTORAD(ang));

      for (int i = 0; i < m_vdpoint.Size(); i++)
      {
         DragPoint * const pdp1 = m_vdpoint.ElementAt(i);
         const float dx = pdp1->m_v.x - centerx;
         const float dy = pdp1->m_v.y - centery;
         const float dx2 = cs*dx - sn*dy;
         const float dy2 = cs*dy + sn*dx;
         pdp1->m_v.x = centerx + dx2;
         pdp1->m_v.y = centery + dy2;
      }
   }
   else
   {
      const float centerx = pvCenter->x;
      const float centery = pvCenter->y;

      const float sn = sinf(ANGTORAD(ang));
      const float cs = cosf(ANGTORAD(ang));

      for (int i = 0; i < m_vdpoint.Size(); i++)
      {
         DragPoint * const pdp1 = m_vdpoint.ElementAt(i);
         const float dx = pdp1->m_v.x - centerx;
         const float dy = pdp1->m_v.y - centery;
         const float dx2 = cs*dx - sn*dy;
         const float dy2 = cs*dy + sn*dx;
         pdp1->m_v.x = centerx + dx2;
         pdp1->m_v.y = centery + dy2;
      }

      // Move object center as well (if rotating around object center,
      // this will have no effect)
      {
         const float dx = newcenter.x - centerx;
         const float dy = newcenter.y - centery;
         const float dx2 = cs*dx - sn*dy;
         const float dy2 = cs*dy + sn*dx;
         newcenter.x = centerx + dx2;
         newcenter.y = centery + dy2;
         PutPointCenter(&newcenter);
      }
   }
   GetIEditable()->EndUndo();

   GetPTable()->SetDirtyDraw();
}
Example #9
0
void ISelect::DoCommand(int icmd, int x, int y)
{
   IEditable *piedit = GetIEditable();

   if ((icmd & 0x0000FFFF) == ID_SELECT_ELEMENT)
   {
      const int ksshift = GetKeyState(VK_SHIFT);
      const int ksctrl = GetKeyState(VK_CONTROL);

      PinTable *currentTable = GetPTable();
      int i = (icmd & 0x00FF0000) >> 16;
      ISelect * const pisel = currentTable->m_allHitElements.ElementAt(i);

      const bool fAdd = ((ksshift & 0x80000000) != 0);

      if (pisel == (ISelect *)currentTable && fAdd)
      {
         // Can not include the table in multi-select
         // and table will not be unselected, because the
         // user might be drawing a box around other objects
         // to add them to the selection group
         currentTable->OnLButtonDown(x, y); // Start the band select
         return;
      }

      currentTable->AddMultiSel(pisel, fAdd, fTrue, fTrue);
      return;
   }
   if (((icmd & 0x000FFFFF) >= 0x40000) && ((icmd & 0x000FFFFF) < 0x40020))
   {
      const int ksshift = GetKeyState(VK_SHIFT);
      const int ksctrl = GetKeyState(VK_CONTROL);

      PinTable *currentTable = GetPTable();
      int i = icmd & 0x000000FF;
      currentTable->AddToCollection(i);
   }
   switch (icmd)
   {
   case ID_EDIT_DRAWINGORDER_HIT:
      g_pvp->ShowDrawingOrderDialog(false);
      break;
   case ID_EDIT_DRAWINGORDER_SELECT:
      g_pvp->ShowDrawingOrderDialog(true);
      break;
   case ID_DRAWINFRONT:
   {
      PinTable *ptable = GetPTable();
      ptable->m_vedit.RemoveElement(piedit);
      ptable->m_vedit.AddElement(piedit);
      ptable->m_layer[layerIndex].RemoveElement(piedit);
      ptable->m_layer[layerIndex].AddElement(piedit);
      ptable->SetDirtyDraw();
      break;
   }
   case ID_DRAWINBACK:
      GetPTable()->m_vedit.RemoveElement(piedit);
      GetPTable()->m_vedit.InsertElementAt(piedit, 0);
      GetPTable()->m_layer[layerIndex].RemoveElement(piedit);
      GetPTable()->m_layer[layerIndex].InsertElementAt(piedit, 0);
      GetPTable()->SetDirtyDraw();
      break;
   case ID_SETASDEFAULT:
      piedit->WriteRegDefaults();
      break;
   case ID_LOCK:
      GetIEditable()->BeginUndo();
      GetIEditable()->MarkForUndo();
      m_fLocked = !m_fLocked;
      GetIEditable()->EndUndo();
      GetPTable()->SetDirtyDraw();
      break;
   case ID_ASSIGNTO_LAYER1:
   {
      GetPTable()->AssignToLayer(piedit, 0);
      break;
   }
   case ID_ASSIGNTO_LAYER2:
   {
      GetPTable()->AssignToLayer(piedit, 1);
      break;
   }
   case ID_ASSIGNTO_LAYER3:
   {
      GetPTable()->AssignToLayer(piedit, 2);
      break;
   }
   case ID_ASSIGNTO_LAYER4:
   {
      GetPTable()->AssignToLayer(piedit, 3);
      break;
   }
   case ID_ASSIGNTO_LAYER5:
   {
      GetPTable()->AssignToLayer(piedit, 4);
      break;
   }
   case ID_ASSIGNTO_LAYER6:
   {
      GetPTable()->AssignToLayer(piedit, 5);
      break;
   }
   case ID_ASSIGNTO_LAYER7:
   {
      GetPTable()->AssignToLayer(piedit, 6);
      break;
   }
   case ID_ASSIGNTO_LAYER8:
   {
      GetPTable()->AssignToLayer(piedit, 7);
      break;
   }
   /*default:
      psel->DoCommand(command, x, y);
      break;*/
   }
}
Example #10
0
void DispReel::PostRenderStatic(RenderDevice* pd3dDevice)
{
   TRACE_FUNCTION();

   if (!m_d.m_fVisible || !GetPTable()->GetEMReelsEnabled())
      return;

   // get a pointer to the image specified in the object
   Texture * const pin = m_ptable->GetImage(m_d.m_szImage); // pointer to image information from the image manager

   if (!pin)
      return;

   if (g_pplayer->m_ptable->m_tblMirrorEnabled^g_pplayer->m_ptable->m_fReflectionEnabled)
      pd3dDevice->SetRenderState(RenderDevice::CULLMODE, D3DCULL_NONE);
   else
      pd3dDevice->SetRenderState(RenderDevice::CULLMODE, D3DCULL_CCW);

   pd3dDevice->SetRenderState(RenderDevice::DEPTHBIAS, 0);
   pd3dDevice->SetRenderState(RenderDevice::ZWRITEENABLE, TRUE);

   g_pplayer->m_pin3d.EnableAlphaTestReference(0xE0); //!!
   pd3dDevice->SetRenderState(RenderDevice::ALPHAFUNC, D3DCMP_GREATER); //!! still necessary?
   g_pplayer->m_pin3d.EnableAlphaBlend(false);

   pd3dDevice->DMDShader->SetTechnique("basic_noDMD");

   const D3DXVECTOR4 c = convertColor(0xFFFFFFFF, 1.f);
   pd3dDevice->DMDShader->SetVector("vColor_Intensity", &c);

   pd3dDevice->DMDShader->SetTexture("Texture0", pin);
   
   pd3dDevice->DMDShader->Begin(0);
   for (int r = 0; r < m_d.m_reelcount; ++r) //!! optimize by doing all in one
   {
       const float posx = ReelInfo[r].position.left;
       const float posy = ReelInfo[r].position.top;
       const float width = ReelInfo[r].position.right;
       const float height = ReelInfo[r].position.bottom;
       const float u0 = m_digitTexCoords[ReelInfo[r].currentValue].u_min;
       const float v0 = m_digitTexCoords[ReelInfo[r].currentValue].v_min;
       const float u1 = m_digitTexCoords[ReelInfo[r].currentValue].u_max;
       const float v1 = m_digitTexCoords[ReelInfo[r].currentValue].v_max;

       float Verts[4 * 5] =
       {
           1.0f, 1.0f, 0.0f, u1, v1,
           0.0f, 1.0f, 0.0f, u0, v1,
           1.0f, 0.0f, 0.0f, u1, v0,
           0.0f, 0.0f, 0.0f, u0, v0
       };

       for (unsigned int i = 0; i < 4; ++i)
       {
           Verts[i * 5] = (Verts[i * 5] * width + posx)*2.0f - 1.0f;
           Verts[i * 5 + 1] = 1.0f - (Verts[i * 5 + 1] * height + posy)*2.0f;
       }

       pd3dDevice->DrawTexturedQuad((Vertex3D_TexelOnly*)Verts);
   }
   pd3dDevice->DMDShader->End();

   //g_pplayer->m_pin3d.DisableAlphaBlend(); //!! not necessary anymore
   pd3dDevice->SetRenderState(RenderDevice::ALPHATESTENABLE, FALSE);

   //if(g_pplayer->m_ptable->m_tblMirrorEnabled^g_pplayer->m_ptable->m_fReflectionEnabled)
   //	pd3dDevice->SetRenderState(RenderDevice::CULLMODE, D3DCULL_CCW);
}