latest changes
parent
8d4a3ed579
commit
75a76e8252
|
@ -80,7 +80,7 @@ public:
|
||||||
virtual int GetState();
|
virtual int GetState();
|
||||||
virtual void SetIcon(int icon);
|
virtual void SetIcon(int icon);
|
||||||
virtual int GetIcon();
|
virtual int GetIcon();
|
||||||
virtual void SetName(char* name, bool bTooltip=true);
|
virtual void SetName(const char* name, bool bTooltip=true);
|
||||||
virtual char* GetName();
|
virtual char* GetName();
|
||||||
virtual void SetTextAlign(Gfx::TextAlign mode);
|
virtual void SetTextAlign(Gfx::TextAlign mode);
|
||||||
virtual int GetTextAlign();
|
virtual int GetTextAlign();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// * This file is part of the COLOBOT source code
|
// * This file is part of the COLOBOT source code
|
||||||
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
|
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
|
||||||
|
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
|
||||||
// *
|
// *
|
||||||
// * This program is free software: you can redistribute it and/or modify
|
// * This program is free software: you can redistribute it and/or modify
|
||||||
// * it under the terms of the GNU General Public License as published by
|
// * it under the terms of the GNU General Public License as published by
|
||||||
|
@ -17,37 +18,21 @@
|
||||||
// mainmap.cpp
|
// mainmap.cpp
|
||||||
|
|
||||||
|
|
||||||
#include <windows.h>
|
#include <ui/mainmap.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <d3d.h>
|
|
||||||
|
|
||||||
#include "common/struct.h"
|
|
||||||
#include "old/d3dengine.h"
|
|
||||||
#include "old/d3dmath.h"
|
|
||||||
#include "common/global.h"
|
|
||||||
#include "common/event.h"
|
|
||||||
#include "common/iman.h"
|
|
||||||
#include "ui/interface.h"
|
|
||||||
#include "ui/map.h"
|
|
||||||
#include "ui/image.h"
|
|
||||||
#include "ui/group.h"
|
|
||||||
#include "ui/slider.h"
|
|
||||||
#include "ui/scroll.h"
|
|
||||||
#include "ui/window.h"
|
|
||||||
#include "ui/mainmap.h"
|
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
|
||||||
|
|
||||||
const float ZOOM_MIN = 1.0f;
|
const float ZOOM_MIN = 1.0f;
|
||||||
const float ZOOM_MAX = 16.0f;
|
const float ZOOM_MAX = 16.0f;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Constructor of the application card.
|
// Constructor of the application card.
|
||||||
|
|
||||||
CMainMap::CMainMap(CInstanceManager* iMan)
|
CMainMap::CMainMap()
|
||||||
{
|
{
|
||||||
m_iMan = iMan;
|
m_iMan = CInstanceManager::GetInstancePointer();
|
||||||
m_iMan->AddInstance(CLASS_MAP, this);
|
m_iMan->AddInstance(CLASS_MAP, this);
|
||||||
|
|
||||||
m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
|
m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
|
||||||
|
@ -73,8 +58,7 @@ void CMainMap::CreateMap()
|
||||||
Math::Point pos, dim;
|
Math::Point pos, dim;
|
||||||
|
|
||||||
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
||||||
if ( pw == 0 )
|
if (pw == nullptr) {
|
||||||
{
|
|
||||||
pos.x = 0.0f;
|
pos.x = 0.0f;
|
||||||
pos.y = 0.0f;
|
pos.y = 0.0f;
|
||||||
dim.x = 0.0f;
|
dim.x = 0.0f;
|
||||||
|
@ -82,10 +66,10 @@ void CMainMap::CreateMap()
|
||||||
pw = m_interface->CreateWindows(pos, dim, 10, EVENT_WINDOW1);
|
pw = m_interface->CreateWindows(pos, dim, 10, EVENT_WINDOW1);
|
||||||
}
|
}
|
||||||
|
|
||||||
dim.x = 10.0f/640.0f;
|
dim.x = 10.0f / 640.0f;
|
||||||
dim.y = 10.0f/480.0f;
|
dim.y = 10.0f / 480.0f;
|
||||||
pos.x = 10.0f/640.0f;
|
pos.x = 10.0f / 640.0f;
|
||||||
pos.y = 10.0f/480.0f;
|
pos.y = 10.0f / 480.0f;
|
||||||
pw->CreateMap (pos, dim, 2, EVENT_OBJECT_MAP);
|
pw->CreateMap (pos, dim, 2, EVENT_OBJECT_MAP);
|
||||||
pw->CreateSlider(pos, dim, 0, EVENT_OBJECT_MAPZOOM);
|
pw->CreateSlider(pos, dim, 0, EVENT_OBJECT_MAPZOOM);
|
||||||
|
|
||||||
|
@ -94,16 +78,18 @@ void CMainMap::CreateMap()
|
||||||
|
|
||||||
// Indicates whether the mini-map should display a still image.
|
// Indicates whether the mini-map should display a still image.
|
||||||
|
|
||||||
void CMainMap::SetFixImage(char *filename)
|
void CMainMap::SetFixImage(const char *filename)
|
||||||
{
|
{
|
||||||
CWindow* pw;
|
CWindow* pw;
|
||||||
CMap* pm;
|
CMap* pm;
|
||||||
|
|
||||||
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
||||||
if ( pw == 0 ) return;
|
if (pw == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
||||||
if ( pm == 0 ) return;
|
if (pm == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
pw->DeleteControl(EVENT_OBJECT_MAPZOOM);
|
pw->DeleteControl(EVENT_OBJECT_MAPZOOM);
|
||||||
m_bFixImage = true;
|
m_bFixImage = true;
|
||||||
|
@ -113,17 +99,17 @@ void CMainMap::SetFixImage(char *filename)
|
||||||
|
|
||||||
// Choosing colors of soil and water for the mini-map.
|
// Choosing colors of soil and water for the mini-map.
|
||||||
|
|
||||||
void CMainMap::FloorColorMap(D3DCOLORVALUE floor, D3DCOLORVALUE water)
|
void CMainMap::FloorColorMap(Gfx::Color floor, Gfx::Color water)
|
||||||
{
|
{
|
||||||
CWindow* pw;
|
CWindow* pw;
|
||||||
CMap* pm;
|
CMap* pm;
|
||||||
|
|
||||||
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
||||||
if ( pw == 0 ) return;
|
if (pw == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
||||||
if ( pm != 0 )
|
if (pm != nullptr) {
|
||||||
{
|
|
||||||
pm->SetFloorColor(floor);
|
pm->SetFloorColor(floor);
|
||||||
pm->SetWaterColor(water);
|
pm->SetWaterColor(water);
|
||||||
}
|
}
|
||||||
|
@ -138,25 +124,19 @@ void CMainMap::ShowMap(bool bShow)
|
||||||
CSlider* ps;
|
CSlider* ps;
|
||||||
|
|
||||||
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
||||||
if ( pw == 0 ) return;
|
if (pw == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
if ( bShow )
|
if (bShow) {
|
||||||
{
|
|
||||||
DimMap();
|
DimMap();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
||||||
if ( pm != 0 )
|
if (pm != nullptr)
|
||||||
{
|
|
||||||
pm->ClearState(STATE_VISIBLE);
|
pm->ClearState(STATE_VISIBLE);
|
||||||
}
|
|
||||||
|
|
||||||
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
|
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
|
||||||
if ( ps != 0 )
|
if (ps != nullptr)
|
||||||
{
|
|
||||||
ps->ClearState(STATE_VISIBLE);
|
ps->ClearState(STATE_VISIBLE);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,9 +151,11 @@ void CMainMap::DimMap()
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
||||||
if ( pw == 0 ) return;
|
if (pw == nullptr)
|
||||||
|
return;
|
||||||
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
||||||
if ( pm == 0 ) return;
|
if (pm == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
pm->SetState(STATE_VISIBLE, (m_mapMode != 0));
|
pm->SetState(STATE_VISIBLE, (m_mapMode != 0));
|
||||||
|
|
||||||
|
@ -185,19 +167,18 @@ void CMainMap::DimMap()
|
||||||
pm->SetDim(dim);
|
pm->SetDim(dim);
|
||||||
|
|
||||||
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
|
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
|
||||||
if ( ps != 0 )
|
if (ps != nullptr) {
|
||||||
{
|
|
||||||
ps->SetState(STATE_VISIBLE, (m_mapMode != 0));
|
ps->SetState(STATE_VISIBLE, (m_mapMode != 0));
|
||||||
|
|
||||||
dim.x = SCROLL_WIDTH;
|
dim.x = SCROLL_WIDTH;
|
||||||
dim.y = 66.0f/480.0f;
|
dim.y = 66.0f / 480.0f;
|
||||||
pos.x = 523.0f/640.0f;
|
pos.x = 523.0f / 640.0f;
|
||||||
pos.y = 3.0f/480.0f;
|
pos.y = 3.0f / 480.0f;
|
||||||
ps->SetPos(pos);
|
ps->SetPos(pos);
|
||||||
ps->SetDim(dim);
|
ps->SetDim(dim);
|
||||||
|
|
||||||
value = pm->RetZoom();
|
value = pm->RetZoom();
|
||||||
value = (value-ZOOM_MIN)/(ZOOM_MAX-ZOOM_MIN);
|
value = (value-ZOOM_MIN) / (ZOOM_MAX-ZOOM_MIN);
|
||||||
value = powf(value, 0.5f);
|
value = powf(value, 0.5f);
|
||||||
ps->SetVisibleValue(value);
|
ps->SetVisibleValue(value);
|
||||||
ps->SetArrowStep(0.2f);
|
ps->SetArrowStep(0.2f);
|
||||||
|
@ -206,22 +187,25 @@ void CMainMap::DimMap()
|
||||||
|
|
||||||
// Returns the current zoom of the minimap.
|
// Returns the current zoom of the minimap.
|
||||||
|
|
||||||
float CMainMap::RetZoomMap()
|
float CMainMap::GetZoomMap()
|
||||||
{
|
{
|
||||||
CWindow* pw;
|
CWindow* pw;
|
||||||
CMap* pm;
|
CMap* pm;
|
||||||
CSlider* ps;
|
CSlider* ps;
|
||||||
|
|
||||||
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
||||||
if ( pw == 0 ) return ZOOM_MIN;
|
if (pw == nullptr)
|
||||||
|
return ZOOM_MIN;
|
||||||
|
|
||||||
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
||||||
if ( pm == 0 ) return ZOOM_MIN;
|
if (pm == nullptr)
|
||||||
|
return ZOOM_MIN;
|
||||||
|
|
||||||
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
|
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
|
||||||
if ( ps == 0 ) return ZOOM_MIN;
|
if (ps == nullptr)
|
||||||
|
return ZOOM_MIN;
|
||||||
|
|
||||||
return pm->RetZoom();
|
return pm->GetZoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zoom the mini-map of any factor.
|
// Zoom the mini-map of any factor.
|
||||||
|
@ -233,15 +217,20 @@ void CMainMap::ZoomMap(float zoom)
|
||||||
CSlider* ps;
|
CSlider* ps;
|
||||||
|
|
||||||
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
||||||
if ( pw == 0 ) return;
|
if (pw == nullptr)
|
||||||
|
return;
|
||||||
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
||||||
if ( pm == 0 ) return;
|
if (pm == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
|
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
|
||||||
if ( ps == 0 ) return;
|
if (ps == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
if ( zoom < ZOOM_MIN ) zoom = ZOOM_MIN;
|
if (zoom < ZOOM_MIN)
|
||||||
if ( zoom > ZOOM_MAX ) zoom = ZOOM_MAX;
|
zoom = ZOOM_MIN;
|
||||||
|
if (zoom > ZOOM_MAX)
|
||||||
|
zoom = ZOOM_MAX;
|
||||||
pm->SetZoom(zoom);
|
pm->SetZoom(zoom);
|
||||||
|
|
||||||
DimMap();
|
DimMap();
|
||||||
|
@ -257,16 +246,19 @@ void CMainMap::ZoomMap()
|
||||||
float zoom;
|
float zoom;
|
||||||
|
|
||||||
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
||||||
if ( pw == 0 ) return;
|
if (pw == nullptr)
|
||||||
|
return;
|
||||||
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
||||||
if ( pm == 0 ) return;
|
if (pm == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
|
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
|
||||||
if ( ps == 0 ) return;
|
if (ps == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
zoom = ps->RetVisibleValue();
|
zoom = ps->SetVisibleValue();
|
||||||
zoom = powf(zoom, 2.0f);
|
zoom = powf(zoom, 2.0f);
|
||||||
zoom = ZOOM_MIN+zoom*(ZOOM_MAX-ZOOM_MIN);
|
zoom = ZOOM_MIN+zoom*(ZOOM_MAX - ZOOM_MIN);
|
||||||
pm->SetZoom(zoom);
|
pm->SetZoom(zoom);
|
||||||
|
|
||||||
DimMap();
|
DimMap();
|
||||||
|
@ -281,19 +273,16 @@ void CMainMap::MapEnable(bool bEnable)
|
||||||
CSlider* ps;
|
CSlider* ps;
|
||||||
|
|
||||||
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
||||||
if ( pw == 0 ) return;
|
if (pw == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
||||||
if ( pm != 0 )
|
if (pm != nullptr)
|
||||||
{
|
|
||||||
pm->SetEnable(bEnable);
|
pm->SetEnable(bEnable);
|
||||||
}
|
|
||||||
|
|
||||||
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
|
ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
|
||||||
if ( ps != 0 )
|
if (ps != nullptr)
|
||||||
{
|
|
||||||
ps->SetState(STATE_ENABLE, bEnable);
|
ps->SetState(STATE_ENABLE, bEnable);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specifies the type of icon for the selected object.
|
// Specifies the type of icon for the selected object.
|
||||||
|
@ -304,10 +293,12 @@ void CMainMap::SetToy(bool bToy)
|
||||||
CMap* pm;
|
CMap* pm;
|
||||||
|
|
||||||
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
||||||
if ( pw == 0 ) return;
|
if (pw == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
||||||
if ( pm == 0 ) return;
|
if (pm == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
pm->SetToy(bToy);
|
pm->SetToy(bToy);
|
||||||
}
|
}
|
||||||
|
@ -321,10 +312,12 @@ void CMainMap::SetFixParam(float zoom, float ox, float oy, float angle,
|
||||||
CMap* pm;
|
CMap* pm;
|
||||||
|
|
||||||
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
||||||
if ( pw == 0 ) return;
|
if (pw == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
||||||
if ( pm == 0 ) return;
|
if (pm == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
pm->SetZoom(zoom);
|
pm->SetZoom(zoom);
|
||||||
pm->SetOffset(ox, oy);
|
pm->SetOffset(ox, oy);
|
||||||
|
@ -341,25 +334,24 @@ void CMainMap::UpdateMap()
|
||||||
CMap* pm;
|
CMap* pm;
|
||||||
|
|
||||||
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
||||||
if ( pw == 0 ) return;
|
if (pw == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
||||||
if ( pm != 0 )
|
if (pm != nullptr)
|
||||||
{
|
|
||||||
pm->UpdateTerrain();
|
pm->UpdateTerrain();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indicates if the mini-map is visible.
|
// Indicates if the mini-map is visible.
|
||||||
|
|
||||||
bool CMainMap::RetShowMap()
|
bool CMainMap::GetShowMap()
|
||||||
{
|
{
|
||||||
return ( m_mapMode != 0 );
|
return ( m_mapMode != 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indicates whether the mini-map displays a still image.
|
// Indicates whether the mini-map displays a still image.
|
||||||
|
|
||||||
bool CMainMap::RetFixImage()
|
bool CMainMap::GetFixImage()
|
||||||
{
|
{
|
||||||
return m_bFixImage;
|
return m_bFixImage;
|
||||||
}
|
}
|
||||||
|
@ -373,30 +365,32 @@ CObject* CMainMap::DetectMap(Math::Point pos, bool &bInMap)
|
||||||
CMap* pm;
|
CMap* pm;
|
||||||
|
|
||||||
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
||||||
if ( pw == 0 ) return 0;
|
if (pw == nullptr)
|
||||||
|
return 0;
|
||||||
|
|
||||||
bInMap = false;
|
bInMap = false;
|
||||||
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
||||||
if ( pm == 0 ) return 0;
|
if (pm == nullptr)
|
||||||
|
return 0;
|
||||||
return pm->DetectObject(pos, bInMap);
|
return pm->DetectObject(pos, bInMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Indicates the object with the mouse hovers over.
|
// Indicates the object with the mouse hovers over.
|
||||||
|
|
||||||
void CMainMap::SetHilite(CObject* pObj)
|
void CMainMap::SetHighlight(CObject* pObj)
|
||||||
{
|
{
|
||||||
CWindow* pw;
|
CWindow* pw;
|
||||||
CMap* pm;
|
CMap* pm;
|
||||||
|
|
||||||
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
|
||||||
if ( pw == 0 ) return;
|
if (pw == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
|
||||||
if ( pm != 0 )
|
if (pm != nullptr)
|
||||||
{
|
pm->SetHighlight(pObj);
|
||||||
pm->SetHilite(pObj);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// * This file is part of the COLOBOT source code
|
// * This file is part of the COLOBOT source code
|
||||||
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
|
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
|
||||||
|
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
|
||||||
// *
|
// *
|
||||||
// * This program is free software: you can redistribute it and/or modify
|
// * This program is free software: you can redistribute it and/or modify
|
||||||
// * it under the terms of the GNU General Public License as published by
|
// * it under the terms of the GNU General Public License as published by
|
||||||
|
@ -18,53 +19,54 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <graphics/core/color.h>
|
||||||
|
|
||||||
#include "common/struct.h"
|
#include <common/struct.h>
|
||||||
#include "math/point.h"
|
#include <common/event.h>
|
||||||
|
|
||||||
|
#include <math/point.h>
|
||||||
|
|
||||||
class CInstanceManager;
|
#include <object/object.h>
|
||||||
class CEvent;
|
|
||||||
class CD3DEngine;
|
|
||||||
class CInterface;
|
|
||||||
class CObject;
|
|
||||||
|
|
||||||
|
#include <ui/interface.h>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
|
||||||
class CMainMap
|
class CMainMap
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CMainMap(CInstanceManager* iMan);
|
CMainMap();
|
||||||
~CMainMap();
|
~CMainMap();
|
||||||
|
|
||||||
void UpdateMap();
|
void UpdateMap();
|
||||||
void CreateMap();
|
void CreateMap();
|
||||||
void SetFixImage(char *filename);
|
void SetFixImage(const char *filename);
|
||||||
void FloorColorMap(D3DCOLORVALUE floor, D3DCOLORVALUE water);
|
void FloorColorMap(Gfx::Color floor, Gfx::Color water);
|
||||||
void ShowMap(bool bShow);
|
void ShowMap(bool bShow);
|
||||||
void DimMap();
|
void DimMap();
|
||||||
float RetZoomMap();
|
float GetZoomMap();
|
||||||
void ZoomMap(float zoom);
|
void ZoomMap(float zoom);
|
||||||
void ZoomMap();
|
void ZoomMap();
|
||||||
void MapEnable(bool bEnable);
|
void MapEnable(bool bEnable);
|
||||||
bool RetShowMap();
|
bool GetShowMap();
|
||||||
bool RetFixImage();
|
bool GetFixImage();
|
||||||
CObject* DetectMap(Math::Point pos, bool &bInMap);
|
CObject* DetectMap(Math::Point pos, bool &bInMap);
|
||||||
void SetHilite(CObject* pObj);
|
void SetHighlight(CObject* pObj);
|
||||||
void SetToy(bool bToy);
|
void SetToy(bool bToy);
|
||||||
void SetFixParam(float zoom, float ox, float oy, float angle, int mode, bool bDebug);
|
void SetFixParam(float zoom, float ox, float oy, float angle, int mode, bool bDebug);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void CenterMap();
|
void CenterMap();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CInstanceManager* m_iMan;
|
CInstanceManager* m_iMan;
|
||||||
CEvent* m_event;
|
CEvent* m_event;
|
||||||
CD3DEngine* m_engine;
|
CD3DEngine* m_engine;
|
||||||
CInterface* m_interface;
|
CInterface* m_interface;
|
||||||
|
|
||||||
int m_mapMode;
|
int m_mapMode;
|
||||||
bool m_bFixImage;
|
bool m_bFixImage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
361
src/ui/map.cpp
361
src/ui/map.cpp
|
@ -1,5 +1,6 @@
|
||||||
// * This file is part of the COLOBOT source code
|
// * This file is part of the COLOBOT source code
|
||||||
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
|
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
|
||||||
|
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
|
||||||
// *
|
// *
|
||||||
// * This program is free software: you can redistribute it and/or modify
|
// * This program is free software: you can redistribute it and/or modify
|
||||||
// * it under the terms of the GNU General Public License as published by
|
// * it under the terms of the GNU General Public License as published by
|
||||||
|
@ -17,34 +18,18 @@
|
||||||
// map.cpp
|
// map.cpp
|
||||||
|
|
||||||
|
|
||||||
#include <windows.h>
|
#include <ui/map.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <d3d.h>
|
|
||||||
|
|
||||||
#include "common/struct.h"
|
|
||||||
#include "math/geometry.h"
|
|
||||||
#include "old/d3dengine.h"
|
|
||||||
#include "common/event.h"
|
|
||||||
#include "old/math3d.h"
|
|
||||||
#include "old/terrain.h"
|
|
||||||
#include "old/water.h"
|
|
||||||
#include "object/object.h"
|
|
||||||
#include "common/event.h"
|
|
||||||
#include "common/misc.h"
|
|
||||||
#include "object/robotmain.h"
|
|
||||||
#include "common/iman.h"
|
|
||||||
#include "ui/map.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
|
||||||
// Object's constructor.
|
// Object's constructor.
|
||||||
|
|
||||||
CMap::CMap(CInstanceManager* iMan) : CControl(iMan)
|
CMap::CMap() : CControl()
|
||||||
{
|
{
|
||||||
m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN);
|
m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
|
||||||
m_terrain = (CTerrain*)m_iMan->SearchInstance(CLASS_TERRAIN);
|
m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
|
||||||
m_water = (CWater*)m_iMan->SearchInstance(CLASS_WATER);
|
m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
|
||||||
|
|
||||||
m_bEnable = true;
|
m_bEnable = true;
|
||||||
m_time = 0.0f;
|
m_time = 0.0f;
|
||||||
|
@ -61,9 +46,9 @@ CMap::CMap(CInstanceManager* iMan) : CControl(iMan)
|
||||||
m_waterColor.g = 0.80f;
|
m_waterColor.g = 0.80f;
|
||||||
m_waterColor.b = 1.00f; // blue
|
m_waterColor.b = 1.00f; // blue
|
||||||
|
|
||||||
m_half = m_terrain->RetMosaic()*m_terrain->RetBrick()*m_terrain->RetSize()/2.0f;
|
m_half = m_terrain->GetMosaic() * m_terrain->GetBrick() * m_terrain->GetSize() / 2.0f;
|
||||||
|
|
||||||
m_hiliteRank = -1;
|
m_highlightRank = -1;
|
||||||
FlushObject();
|
FlushObject();
|
||||||
|
|
||||||
m_fixImage[0] = 0;
|
m_fixImage[0] = 0;
|
||||||
|
@ -81,9 +66,10 @@ CMap::~CMap()
|
||||||
|
|
||||||
// Creates a new button.
|
// Creates a new button.
|
||||||
|
|
||||||
bool CMap::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
|
bool CMap::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
|
||||||
{
|
{
|
||||||
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
|
if (eventMsg == EVENT_NULL)
|
||||||
|
eventMsg = GetUniqueEventType();
|
||||||
|
|
||||||
CControl::Create(pos, dim, icon, eventMsg);
|
CControl::Create(pos, dim, icon, eventMsg);
|
||||||
return true;
|
return true;
|
||||||
|
@ -96,7 +82,7 @@ void CMap::SetOffset(float ox, float oy)
|
||||||
{
|
{
|
||||||
m_offset.x = ox;
|
m_offset.x = ox;
|
||||||
m_offset.y = oy;
|
m_offset.y = oy;
|
||||||
m_half = m_terrain->RetMosaic()*m_terrain->RetBrick()*m_terrain->RetSize()/2.0f;
|
m_half = m_terrain->GetMosaic() * m_terrain->GetBrick() * m_terrain->GetSize() / 2.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Choice of the global angle of rotation.
|
// Choice of the global angle of rotation.
|
||||||
|
@ -131,10 +117,10 @@ void CMap::SetDebug(bool bDebug)
|
||||||
void CMap::SetZoom(float value)
|
void CMap::SetZoom(float value)
|
||||||
{
|
{
|
||||||
m_zoom = value;
|
m_zoom = value;
|
||||||
m_half = m_terrain->RetMosaic()*m_terrain->RetBrick()*m_terrain->RetSize()/2.0f;
|
m_half = m_terrain->GetMosaic() * m_terrain->GetBrick() * m_terrain->GetSize() / 2.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CMap::RetZoom()
|
float CMap::GetZoom()
|
||||||
{
|
{
|
||||||
return m_zoom;
|
return m_zoom;
|
||||||
}
|
}
|
||||||
|
@ -149,7 +135,7 @@ void CMap::SetEnable(bool bEnable)
|
||||||
SetState(STATE_DEAD, !bEnable);
|
SetState(STATE_DEAD, !bEnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMap::RetEnable()
|
bool CMap::GetEnable()
|
||||||
{
|
{
|
||||||
return m_bEnable;
|
return m_bEnable;
|
||||||
}
|
}
|
||||||
|
@ -157,14 +143,14 @@ bool CMap::RetEnable()
|
||||||
|
|
||||||
// Choosing the color of the soil.
|
// Choosing the color of the soil.
|
||||||
|
|
||||||
void CMap::SetFloorColor(D3DCOLORVALUE color)
|
void CMap::SetFloorColor(Gfx::Color color)
|
||||||
{
|
{
|
||||||
m_floorColor = color;
|
m_floorColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Choosing the color of the water.
|
// Choosing the color of the water.
|
||||||
|
|
||||||
void CMap::SetWaterColor(D3DCOLORVALUE color)
|
void CMap::SetWaterColor(Gfx::Color color)
|
||||||
{
|
{
|
||||||
m_waterColor = color;
|
m_waterColor = color;
|
||||||
}
|
}
|
||||||
|
@ -172,14 +158,14 @@ void CMap::SetWaterColor(D3DCOLORVALUE color)
|
||||||
|
|
||||||
// Specifies a fixed image in place of the drawing of the relief.
|
// Specifies a fixed image in place of the drawing of the relief.
|
||||||
|
|
||||||
void CMap::SetFixImage(char *filename)
|
void CMap::SetFixImage(const char *filename)
|
||||||
{
|
{
|
||||||
strcpy(m_fixImage, filename);
|
strcpy(m_fixImage, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Whether to use a still image.
|
// Whether to use a still image.
|
||||||
|
|
||||||
bool CMap::RetFixImage()
|
bool CMap::GetFixImage()
|
||||||
{
|
{
|
||||||
return (m_fixImage[0] != 0);
|
return (m_fixImage[0] != 0);
|
||||||
}
|
}
|
||||||
|
@ -189,30 +175,24 @@ bool CMap::RetFixImage()
|
||||||
|
|
||||||
bool CMap::EventProcess(const Event &event)
|
bool CMap::EventProcess(const Event &event)
|
||||||
{
|
{
|
||||||
bool bInMap;
|
bool bInMap;
|
||||||
|
|
||||||
if ( (m_state & STATE_VISIBLE) == 0 ) return true;
|
if ( (m_state & STATE_VISIBLE) == 0 )
|
||||||
|
return true;
|
||||||
|
|
||||||
CControl::EventProcess(event);
|
CControl::EventProcess(event);
|
||||||
|
|
||||||
if ( event.event == EVENT_FRAME )
|
if ( event.type == EVENT_FRAME )
|
||||||
{
|
|
||||||
m_time += event.rTime;
|
m_time += event.rTime;
|
||||||
}
|
|
||||||
|
|
||||||
if ( event.event == EVENT_MOUSEMOVE && Detect(event.pos) )
|
if ( event.type == EVENT_MOUSE_MOVE && Detect(event.pos) ) {
|
||||||
{
|
m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM);
|
||||||
m_engine->SetMouseType(D3DMOUSENORM);
|
|
||||||
if ( DetectObject(event.pos, bInMap) != 0 )
|
if ( DetectObject(event.pos, bInMap) != 0 )
|
||||||
{
|
m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND);
|
||||||
m_engine->SetMouseType(D3DMOUSEHAND);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.event == EVENT_LBUTTONDOWN )
|
if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == 1 ) {
|
||||||
{
|
if ( CControl::Detect(event.pos) ) {
|
||||||
if ( CControl::Detect(event.pos) )
|
|
||||||
{
|
|
||||||
SelectObject(event.pos);
|
SelectObject(event.pos);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -227,7 +207,7 @@ Math::Point CMap::AdjustOffset(Math::Point offset)
|
||||||
{
|
{
|
||||||
float limit;
|
float limit;
|
||||||
|
|
||||||
limit = m_half - m_half/m_zoom;
|
limit = m_half - m_half / m_zoom;
|
||||||
if ( offset.x < -limit ) offset.x = -limit;
|
if ( offset.x < -limit ) offset.x = -limit;
|
||||||
if ( offset.x > limit ) offset.x = limit;
|
if ( offset.x > limit ) offset.x = limit;
|
||||||
if ( offset.y < -limit ) offset.y = -limit;
|
if ( offset.y < -limit ) offset.y = -limit;
|
||||||
|
@ -238,21 +218,20 @@ Math::Point CMap::AdjustOffset(Math::Point offset)
|
||||||
|
|
||||||
// Indicates the object with the mouse hovers over.
|
// Indicates the object with the mouse hovers over.
|
||||||
|
|
||||||
void CMap::SetHilite(CObject* pObj)
|
void CMap::SetHighlight(CObject* pObj)
|
||||||
{
|
{
|
||||||
int i;
|
m_highlightRank = -1;
|
||||||
|
if ( m_bToy || m_fixImage[0] != 0 )
|
||||||
|
return; // card with still image?
|
||||||
|
if ( pObj == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
m_hiliteRank = -1;
|
for (int i = 0; i < MAPMAXOBJECT; i++) {
|
||||||
if ( m_bToy || m_fixImage[0] != 0 ) return; // card with still image?
|
if ( !m_map[i].bUsed )
|
||||||
if ( pObj == 0 ) return;
|
continue;
|
||||||
|
|
||||||
for ( i=0 ; i<MAPMAXOBJECT ; i++ )
|
if ( m_map[i].object == pObj ) {
|
||||||
{
|
m_highlightRank = i;
|
||||||
if ( !m_map[i].bUsed ) continue;
|
|
||||||
|
|
||||||
if ( m_map[i].object == pObj )
|
|
||||||
{
|
|
||||||
m_hiliteRank = i;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -262,39 +241,43 @@ void CMap::SetHilite(CObject* pObj)
|
||||||
|
|
||||||
CObject* CMap::DetectObject(Math::Point pos, bool &bInMap)
|
CObject* CMap::DetectObject(Math::Point pos, bool &bInMap)
|
||||||
{
|
{
|
||||||
float dist, min;
|
float dist, min;
|
||||||
int i, best;
|
int best;
|
||||||
|
|
||||||
bInMap = false;
|
bInMap = false;
|
||||||
if ( pos.x < m_pos.x ||
|
if ( pos.x < m_pos.x ||
|
||||||
pos.y < m_pos.y ||
|
pos.y < m_pos.y ||
|
||||||
pos.x > m_pos.x+m_dim.x ||
|
pos.x > m_pos.x + m_dim.x ||
|
||||||
pos.y > m_pos.y+m_dim.y ) return 0;
|
pos.y > m_pos.y + m_dim.y )
|
||||||
|
return 0;
|
||||||
|
|
||||||
bInMap = true;
|
bInMap = true;
|
||||||
|
|
||||||
pos.x = (pos.x-m_pos.x)/m_dim.x*256.0f;
|
pos.x = (pos.x - m_pos.x) / m_dim.x * 256.0f;
|
||||||
pos.y = (pos.y-m_pos.y)/m_dim.y*256.0f; // 0..256
|
pos.y = (pos.y - m_pos.y) / m_dim.y * 256.0f; // 0..256
|
||||||
pos.x = (pos.x-128.0f)*m_half/(m_zoom*128.0f)+m_offset.x;
|
pos.x = (pos.x - 128.0f) * m_half / (m_zoom * 128.0f) + m_offset.x;
|
||||||
pos.y = (pos.y-128.0f)*m_half/(m_zoom*128.0f)+m_offset.y;
|
pos.y = (pos.y - 128.0f) * m_half / (m_zoom * 128.0f) + m_offset.y;
|
||||||
|
|
||||||
min = 10000.0f;
|
min = 10000.0f;
|
||||||
best = -1;
|
best = -1;
|
||||||
for ( i=MAPMAXOBJECT-1 ; i>=0 ; i-- )
|
for (int i = MAPMAXOBJECT - 1; i >= 0; i--) {
|
||||||
{
|
if ( !m_map[i].bUsed )
|
||||||
if ( !m_map[i].bUsed ) continue;
|
continue;
|
||||||
if ( m_map[i].color == MAPCOLOR_BBOX && !m_bRadar ) continue;
|
if ( m_map[i].color == MAPCOLOR_BBOX && !m_bRadar )
|
||||||
if ( m_map[i].color == MAPCOLOR_ALIEN && !m_bRadar ) continue;
|
continue;
|
||||||
|
if ( m_map[i].color == MAPCOLOR_ALIEN && !m_bRadar )
|
||||||
|
continue;
|
||||||
|
|
||||||
dist = Math::Point(m_map[i].pos.x-pos.x, m_map[i].pos.y-pos.y).Length();
|
dist = Math::Point(m_map[i].pos.x - pos.x, m_map[i].pos.y - pos.y).Length();
|
||||||
if ( dist > m_half/m_zoom*8.0f/100.0f ) continue; // too far?
|
if ( dist > m_half / m_zoom * 8.0f / 100.0f )
|
||||||
if ( dist < min )
|
continue; // too far?
|
||||||
{
|
if ( dist < min ) {
|
||||||
min = dist;
|
min = dist;
|
||||||
best = i;
|
best = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( best == -1 ) return 0;
|
if ( best == -1 )
|
||||||
|
return 0;
|
||||||
return m_map[best].object;
|
return m_map[best].object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,14 +285,12 @@ CObject* CMap::DetectObject(Math::Point pos, bool &bInMap)
|
||||||
|
|
||||||
void CMap::SelectObject(Math::Point pos)
|
void CMap::SelectObject(Math::Point pos)
|
||||||
{
|
{
|
||||||
CObject *pObj;
|
CObject *pObj;
|
||||||
bool bInMap;
|
bool bInMap;
|
||||||
|
|
||||||
pObj = DetectObject(pos, bInMap);
|
pObj = DetectObject(pos, bInMap);
|
||||||
if ( pObj != 0 )
|
if ( pObj != 0 )
|
||||||
{
|
|
||||||
m_main->SelectObject(pObj);
|
m_main->SelectObject(pObj);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -318,34 +299,31 @@ void CMap::SelectObject(Math::Point pos)
|
||||||
void CMap::Draw()
|
void CMap::Draw()
|
||||||
{
|
{
|
||||||
Math::Point uv1, uv2;
|
Math::Point uv1, uv2;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ( (m_state & STATE_VISIBLE) == 0 ) return;
|
if ( (m_state & STATE_VISIBLE) == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
CControl::Draw(); // draws the bottom (button)
|
CControl::Draw(); // draws the bottom (button)
|
||||||
|
|
||||||
if ( !m_bEnable ) return;
|
if ( !m_bEnable )
|
||||||
|
return;
|
||||||
|
|
||||||
if ( m_fixImage[0] == 0 && m_map[MAPMAXOBJECT-1].bUsed )
|
if ( m_fixImage[0] == 0 && m_map[MAPMAXOBJECT - 1].bUsed )
|
||||||
{
|
m_offset = AdjustOffset(m_map[MAPMAXOBJECT - 1].pos);
|
||||||
m_offset = AdjustOffset(m_map[MAPMAXOBJECT-1].pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_fixImage[0] == 0 ) // drawing of the relief?
|
if ( m_fixImage[0] == 0 ) { // drawing of the relief?
|
||||||
{
|
|
||||||
m_engine->SetTexture("map.tga");
|
m_engine->SetTexture("map.tga");
|
||||||
m_engine->SetState(D3DSTATENORMAL);
|
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
|
||||||
uv1.x = 0.5f+(m_offset.x-(m_half/m_zoom))/(m_half*2.0f);
|
uv1.x = 0.5f + (m_offset.x - (m_half / m_zoom)) / (m_half * 2.0f);
|
||||||
uv1.y = 0.5f-(m_offset.y+(m_half/m_zoom))/(m_half*2.0f);
|
uv1.y = 0.5f - (m_offset.y + (m_half / m_zoom)) / (m_half * 2.0f);
|
||||||
uv2.x = 0.5f+(m_offset.x+(m_half/m_zoom))/(m_half*2.0f);
|
uv2.x = 0.5f + (m_offset.x + (m_half / m_zoom)) / (m_half * 2.0f);
|
||||||
uv2.y = 0.5f-(m_offset.y-(m_half/m_zoom))/(m_half*2.0f);
|
uv2.y = 0.5f - (m_offset.y - (m_half / m_zoom)) / (m_half * 2.0f);
|
||||||
DrawVertex(uv1, uv2, 0.97f); // drawing the map
|
DrawVertex(uv1, uv2, 0.97f); // drawing the map
|
||||||
}
|
} else { // still image?
|
||||||
else // still image?
|
|
||||||
{
|
|
||||||
m_engine->LoadTexture(m_fixImage);
|
m_engine->LoadTexture(m_fixImage);
|
||||||
m_engine->SetTexture(m_fixImage);
|
m_engine->SetTexture(m_fixImage);
|
||||||
m_engine->SetState(D3DSTATENORMAL);
|
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
|
||||||
uv1.x = 0.0f;
|
uv1.x = 0.0f;
|
||||||
uv1.y = 0.0f;
|
uv1.y = 0.0f;
|
||||||
uv2.x = 1.0f;
|
uv2.x = 1.0f;
|
||||||
|
@ -355,33 +333,28 @@ void CMap::Draw()
|
||||||
|
|
||||||
i = MAPMAXOBJECT-1;
|
i = MAPMAXOBJECT-1;
|
||||||
if ( m_map[i].bUsed ) // selection:
|
if ( m_map[i].bUsed ) // selection:
|
||||||
{
|
|
||||||
DrawFocus(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color);
|
DrawFocus(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color);
|
||||||
}
|
|
||||||
|
|
||||||
for ( i=0 ; i<m_totalFix ; i++ ) // fixed objects:
|
for ( i=0 ; i<m_totalFix ; i++ ) { // fixed objects:
|
||||||
{
|
if ( i == m_highlightRank )
|
||||||
if ( i == m_hiliteRank ) continue;
|
continue;
|
||||||
DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, false, false);
|
DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( i=MAPMAXOBJECT-2 ; i>m_totalMove ; i-- ) // moving objects:
|
for ( i=MAPMAXOBJECT-2 ; i>m_totalMove ; i-- ) { // moving objects:
|
||||||
{
|
if ( i == m_highlightRank )
|
||||||
if ( i == m_hiliteRank ) continue;
|
continue;
|
||||||
DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, false, false);
|
DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
i = MAPMAXOBJECT-1;
|
i = MAPMAXOBJECT-1;
|
||||||
if ( m_map[i].bUsed && i != m_hiliteRank ) // selection:
|
if ( m_map[i].bUsed && i != m_highlightRank ) // selection:
|
||||||
{
|
|
||||||
DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, true, false);
|
DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, true, false);
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_hiliteRank != -1 && m_map[m_hiliteRank].bUsed )
|
if ( m_highlightRank != -1 && m_map[m_highlightRank].bUsed ) {
|
||||||
{
|
i = m_highlightRank;
|
||||||
i = m_hiliteRank;
|
|
||||||
DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, false, true);
|
DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, false, true);
|
||||||
DrawHilite(m_map[i].pos);
|
DrawHighlight(m_map[i].pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,35 +365,32 @@ Math::Point CMap::MapInter(Math::Point pos, float dir)
|
||||||
Math::Point p1;
|
Math::Point p1;
|
||||||
float limit;
|
float limit;
|
||||||
|
|
||||||
p1.x = pos.x+1.0f;
|
p1.x = pos.x + 1.0f;
|
||||||
p1.y = pos.y;
|
p1.y = pos.y;
|
||||||
p1 = Math::RotatePoint(pos, dir, p1);
|
p1 = Math::RotatePoint(pos, dir, p1);
|
||||||
|
|
||||||
p1.x -= pos.x;
|
p1.x -= pos.x;
|
||||||
p1.y -= pos.y;
|
p1.y -= pos.y;
|
||||||
|
|
||||||
limit = m_mapPos.x+m_mapDim.x-pos.x;
|
limit = m_mapPos.x + m_mapDim.x - pos.x;
|
||||||
if ( p1.x > limit ) // exceeds the right?
|
if ( p1.x > limit ) { // exceeds the right?
|
||||||
{
|
|
||||||
p1.y = limit*p1.y/p1.x;
|
p1.y = limit*p1.y/p1.x;
|
||||||
p1.x = limit;
|
p1.x = limit;
|
||||||
}
|
}
|
||||||
limit = m_mapPos.y*0.75f+m_mapDim.y*0.75f-pos.y;
|
limit = m_mapPos.y * 0.75f + m_mapDim.y * 0.75f - pos.y;
|
||||||
if ( p1.y > limit ) // exceeds the top?
|
if ( p1.y > limit ) { // exceeds the top?
|
||||||
{
|
p1.x = limit * p1.x / p1.y;
|
||||||
p1.x = limit*p1.x/p1.y;
|
|
||||||
p1.y = limit;
|
p1.y = limit;
|
||||||
}
|
}
|
||||||
limit = m_mapPos.x-pos.x;
|
limit = m_mapPos.x - pos.x;
|
||||||
if ( p1.x < limit ) // exceeds the left?
|
if ( p1.x < limit ) { // exceeds the left?
|
||||||
{
|
p1.y = limit * p1.y / p1.x;
|
||||||
p1.y = limit*p1.y/p1.x;
|
|
||||||
p1.x = limit;
|
p1.x = limit;
|
||||||
}
|
}
|
||||||
limit = m_mapPos.y*0.75f-pos.y;
|
|
||||||
if ( p1.y < limit ) // exceeds the bottom?
|
limit = m_mapPos.y * 0.75f - pos.y;
|
||||||
{
|
if ( p1.y < limit ) { // exceeds the bottom?
|
||||||
p1.x = limit*p1.x/p1.y;
|
p1.x = limit * p1.x / p1.y;
|
||||||
p1.y = limit;
|
p1.y = limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,7 +424,7 @@ void CMap::DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color
|
||||||
pos.x = m_mapPos.x+m_mapDim.x*pos.x;
|
pos.x = m_mapPos.x+m_mapDim.x*pos.x;
|
||||||
pos.y = m_mapPos.y*0.75f+m_mapDim.y*pos.y*0.75f;
|
pos.y = m_mapPos.y*0.75f+m_mapDim.y*pos.y*0.75f;
|
||||||
|
|
||||||
focus = m_engine->RetFocus();
|
focus = m_engine->GetFocus();
|
||||||
dir += Math::PI/2.0f;
|
dir += Math::PI/2.0f;
|
||||||
aMin = Math::NormAngle(dir-Math::PI/4.0f*focus);
|
aMin = Math::NormAngle(dir-Math::PI/4.0f*focus);
|
||||||
aMax = Math::NormAngle(dir+Math::PI/4.0f*focus);
|
aMax = Math::NormAngle(dir+Math::PI/4.0f*focus);
|
||||||
|
@ -484,7 +454,7 @@ void CMap::DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color
|
||||||
uv2.y = 255.0f/256.0f;
|
uv2.y = 255.0f/256.0f;
|
||||||
|
|
||||||
m_engine->SetTexture("button2.tga");
|
m_engine->SetTexture("button2.tga");
|
||||||
m_engine->SetState(D3DSTATETTw);
|
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
|
||||||
|
|
||||||
bEnding = false;
|
bEnding = false;
|
||||||
do
|
do
|
||||||
|
@ -492,7 +462,7 @@ void CMap::DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color
|
||||||
quart ++;
|
quart ++;
|
||||||
aOct = limit[quart%4];
|
aOct = limit[quart%4];
|
||||||
if ( quart >= 4 ) aOct += Math::PI*2.0f;
|
if ( quart >= 4 ) aOct += Math::PI*2.0f;
|
||||||
if ( aOct >= aMax-Math::VERY_SMALL )
|
if ( aOct >= aMax - Math::VERY_SMALL_NUM )
|
||||||
{
|
{
|
||||||
aOct = aMax;
|
aOct = aMax;
|
||||||
bEnding = true;
|
bEnding = true;
|
||||||
|
@ -544,7 +514,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
|
||||||
}
|
}
|
||||||
|
|
||||||
m_engine->SetTexture("button2.tga");
|
m_engine->SetTexture("button2.tga");
|
||||||
m_engine->SetState(D3DSTATETTb);
|
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
|
||||||
if ( bUp )
|
if ( bUp )
|
||||||
{
|
{
|
||||||
uv1.x = 160.5f/256.0f; // yellow triangle ^
|
uv1.x = 160.5f/256.0f; // yellow triangle ^
|
||||||
|
@ -687,7 +657,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
|
||||||
if ( bSelect )
|
if ( bSelect )
|
||||||
{
|
{
|
||||||
m_engine->SetTexture("button2.tga");
|
m_engine->SetTexture("button2.tga");
|
||||||
m_engine->SetState(D3DSTATENORMAL);
|
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
|
||||||
if ( m_bToy )
|
if ( m_bToy )
|
||||||
{
|
{
|
||||||
uv1.x = 164.5f/256.0f; // black pentagon
|
uv1.x = 164.5f/256.0f; // black pentagon
|
||||||
|
@ -713,7 +683,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
|
||||||
if ( m_bRadar )
|
if ( m_bRadar )
|
||||||
{
|
{
|
||||||
m_engine->SetTexture("button2.tga");
|
m_engine->SetTexture("button2.tga");
|
||||||
m_engine->SetState(D3DSTATETTw);
|
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
|
||||||
uv1.x = 64.5f/256.0f; // blue triangle
|
uv1.x = 64.5f/256.0f; // blue triangle
|
||||||
uv1.y = 240.5f/256.0f;
|
uv1.y = 240.5f/256.0f;
|
||||||
uv2.x = 79.0f/256.0f;
|
uv2.x = 79.0f/256.0f;
|
||||||
|
@ -733,7 +703,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
|
||||||
if ( color == MAPCOLOR_WAYPOINTb )
|
if ( color == MAPCOLOR_WAYPOINTb )
|
||||||
{
|
{
|
||||||
m_engine->SetTexture("button2.tga");
|
m_engine->SetTexture("button2.tga");
|
||||||
m_engine->SetState(D3DSTATETTb);
|
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
|
||||||
uv1.x = 192.5f/256.0f; // blue cross
|
uv1.x = 192.5f/256.0f; // blue cross
|
||||||
uv1.y = 240.5f/256.0f;
|
uv1.y = 240.5f/256.0f;
|
||||||
uv2.x = 207.0f/256.0f;
|
uv2.x = 207.0f/256.0f;
|
||||||
|
@ -743,7 +713,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
|
||||||
if ( color == MAPCOLOR_WAYPOINTr )
|
if ( color == MAPCOLOR_WAYPOINTr )
|
||||||
{
|
{
|
||||||
m_engine->SetTexture("button2.tga");
|
m_engine->SetTexture("button2.tga");
|
||||||
m_engine->SetState(D3DSTATETTb);
|
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
|
||||||
uv1.x = 208.5f/256.0f; // red cross
|
uv1.x = 208.5f/256.0f; // red cross
|
||||||
uv1.y = 240.5f/256.0f;
|
uv1.y = 240.5f/256.0f;
|
||||||
uv2.x = 223.0f/256.0f;
|
uv2.x = 223.0f/256.0f;
|
||||||
|
@ -753,7 +723,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
|
||||||
if ( color == MAPCOLOR_WAYPOINTg )
|
if ( color == MAPCOLOR_WAYPOINTg )
|
||||||
{
|
{
|
||||||
m_engine->SetTexture("button2.tga");
|
m_engine->SetTexture("button2.tga");
|
||||||
m_engine->SetState(D3DSTATETTb);
|
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
|
||||||
uv1.x = 224.5f/256.0f; // green cross
|
uv1.x = 224.5f/256.0f; // green cross
|
||||||
uv1.y = 240.5f/256.0f;
|
uv1.y = 240.5f/256.0f;
|
||||||
uv2.x = 239.0f/256.0f;
|
uv2.x = 239.0f/256.0f;
|
||||||
|
@ -763,7 +733,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
|
||||||
if ( color == MAPCOLOR_WAYPOINTy )
|
if ( color == MAPCOLOR_WAYPOINTy )
|
||||||
{
|
{
|
||||||
m_engine->SetTexture("button2.tga");
|
m_engine->SetTexture("button2.tga");
|
||||||
m_engine->SetState(D3DSTATETTb);
|
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
|
||||||
uv1.x = 240.5f/256.0f; // yellow cross
|
uv1.x = 240.5f/256.0f; // yellow cross
|
||||||
uv1.y = 240.5f/256.0f;
|
uv1.y = 240.5f/256.0f;
|
||||||
uv2.x = 255.0f/256.0f;
|
uv2.x = 255.0f/256.0f;
|
||||||
|
@ -773,7 +743,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
|
||||||
if ( color == MAPCOLOR_WAYPOINTv )
|
if ( color == MAPCOLOR_WAYPOINTv )
|
||||||
{
|
{
|
||||||
m_engine->SetTexture("button2.tga");
|
m_engine->SetTexture("button2.tga");
|
||||||
m_engine->SetState(D3DSTATETTb);
|
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
|
||||||
uv1.x = 192.5f/256.0f; // violet cross
|
uv1.x = 192.5f/256.0f; // violet cross
|
||||||
uv1.y = 224.5f/256.0f;
|
uv1.y = 224.5f/256.0f;
|
||||||
uv2.x = 207.0f/256.0f;
|
uv2.x = 207.0f/256.0f;
|
||||||
|
@ -794,7 +764,7 @@ void CMap::DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color,
|
||||||
dp = 0.5f/256.0f;
|
dp = 0.5f/256.0f;
|
||||||
|
|
||||||
m_engine->SetTexture("button3.tga");
|
m_engine->SetTexture("button3.tga");
|
||||||
m_engine->SetState(D3DSTATENORMAL);
|
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
|
||||||
if ( color == MAPCOLOR_MOVE )
|
if ( color == MAPCOLOR_MOVE )
|
||||||
{
|
{
|
||||||
uv1.x = 160.0f/256.0f; // blue
|
uv1.x = 160.0f/256.0f; // blue
|
||||||
|
@ -877,7 +847,7 @@ void CMap::DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color,
|
||||||
if ( type == OBJECT_TEEN34 ) icon = 48; // stone
|
if ( type == OBJECT_TEEN34 ) icon = 48; // stone
|
||||||
if ( icon == -1 ) return;
|
if ( icon == -1 ) return;
|
||||||
|
|
||||||
m_engine->SetState(D3DSTATETTw);
|
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
|
||||||
uv1.x = (32.0f/256.0f)*(icon%8);
|
uv1.x = (32.0f/256.0f)*(icon%8);
|
||||||
uv1.y = (32.0f/256.0f)*(icon/8);
|
uv1.y = (32.0f/256.0f)*(icon/8);
|
||||||
uv2.x = uv1.x+32.0f/256.0f;
|
uv2.x = uv1.x+32.0f/256.0f;
|
||||||
|
@ -892,7 +862,7 @@ void CMap::DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color,
|
||||||
|
|
||||||
// Draw the object with the mouse hovers over.
|
// Draw the object with the mouse hovers over.
|
||||||
|
|
||||||
void CMap::DrawHilite(Math::Point pos)
|
void CMap::DrawHighlight(Math::Point pos)
|
||||||
{
|
{
|
||||||
Math::Point dim, uv1, uv2;
|
Math::Point dim, uv1, uv2;
|
||||||
bool bOut, bUp, bDown, bLeft, bRight;
|
bool bOut, bUp, bDown, bLeft, bRight;
|
||||||
|
@ -916,7 +886,7 @@ void CMap::DrawHilite(Math::Point pos)
|
||||||
dim.y *= 2.0f+cosf(m_time*8.0f)*0.5f;
|
dim.y *= 2.0f+cosf(m_time*8.0f)*0.5f;
|
||||||
|
|
||||||
m_engine->SetTexture("button2.tga");
|
m_engine->SetTexture("button2.tga");
|
||||||
m_engine->SetState(D3DSTATETTb);
|
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
|
||||||
uv1.x = 160.5f/256.0f; // hilite
|
uv1.x = 160.5f/256.0f; // hilite
|
||||||
uv1.y = 224.5f/256.0f;
|
uv1.y = 224.5f/256.0f;
|
||||||
uv2.x = 175.0f/256.0f;
|
uv2.x = 175.0f/256.0f;
|
||||||
|
@ -930,19 +900,19 @@ void CMap::DrawHilite(Math::Point pos)
|
||||||
|
|
||||||
void CMap::DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2)
|
void CMap::DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2)
|
||||||
{
|
{
|
||||||
LPDIRECT3DDEVICE7 device;
|
Gfx::CDevice* device;
|
||||||
D3DVERTEX2 vertex[3]; // 1 triangle
|
Gfx::VertexTex2 vertex[3]; // 1 triangle
|
||||||
Math::Vector n;
|
Math::Vector n;
|
||||||
|
|
||||||
device = m_engine->RetD3DDevice();
|
device = m_engine->GetDevice();
|
||||||
|
|
||||||
n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
|
n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
|
||||||
|
|
||||||
vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv1.y);
|
vertex[0] = Gfx::VertexTex2(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x,uv1.y));
|
||||||
vertex[1] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv1.x,uv2.y);
|
vertex[1] = Gfx::VertexTex2(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv1.x,uv2.y));
|
||||||
vertex[2] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv2.x,uv2.y);
|
vertex[2] = Gfx::VertexTex2(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv2.x,uv2.y));
|
||||||
|
|
||||||
device->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_VERTEX2, vertex, 3, NULL);
|
device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, vertex, 3);
|
||||||
m_engine->AddStatisticTriangle(1);
|
m_engine->AddStatisticTriangle(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -950,28 +920,28 @@ void CMap::DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Po
|
||||||
|
|
||||||
void CMap::DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2)
|
void CMap::DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2)
|
||||||
{
|
{
|
||||||
LPDIRECT3DDEVICE7 device;
|
Gfx::CDevice* device;
|
||||||
D3DVERTEX2 vertex[5]; // 1 pentagon
|
Gfx::VertexTex2 vertex[5]; // 1 pentagon
|
||||||
Math::Vector n;
|
Math::Vector n;
|
||||||
|
|
||||||
device = m_engine->RetD3DDevice();
|
device = m_engine->GetDevice();
|
||||||
|
|
||||||
n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
|
n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv1.y);
|
vertex[0] = Gfx::VertexTex2(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x,uv1.y));
|
||||||
vertex[1] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv1.x,uv2.y);
|
vertex[1] = Gfx::VertexTex2(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv1.x,uv2.y));
|
||||||
vertex[2] = D3DVERTEX2(Math::Vector(p5.x, p5.y, 0.0f), n, uv2.x,uv2.y);
|
vertex[2] = Gfx::VertexTex2(Math::Vector(p5.x, p5.y, 0.0f), n, Math::Point(uv2.x,uv2.y));
|
||||||
vertex[3] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv2.x,uv2.y);
|
vertex[3] = Gfx::VertexTex2(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv2.x,uv2.y));
|
||||||
vertex[4] = D3DVERTEX2(Math::Vector(p4.x, p4.y, 0.0f), n, uv2.x,uv2.y);
|
vertex[4] = Gfx::VertexTex2(Math::Vector(p4.x, p4.y, 0.0f), n, Math::Point(uv2.x,uv2.y));
|
||||||
|
|
||||||
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 5, NULL);
|
device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 5);
|
||||||
#else
|
#else
|
||||||
vertex[0] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv1.x,uv1.y);
|
vertex[0] = Gfx::VertexTex2(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv1.x,uv1.y));
|
||||||
vertex[1] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv1.x,uv2.y);
|
vertex[1] = Gfx::VertexTex2(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv1.x,uv2.y));
|
||||||
vertex[2] = D3DVERTEX2(Math::Vector(p4.x, p4.y, 0.0f), n, uv2.x,uv2.y);
|
vertex[2] = Gfx::VertexTex2(Math::Vector(p4.x, p4.y, 0.0f), n, Math::Point(uv2.x,uv2.y));
|
||||||
|
|
||||||
device->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_VERTEX2, vertex, 3, NULL);
|
device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, vertex, 3);
|
||||||
#endif
|
#endif
|
||||||
m_engine->AddStatisticTriangle(3);
|
m_engine->AddStatisticTriangle(3);
|
||||||
}
|
}
|
||||||
|
@ -980,12 +950,12 @@ void CMap::DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point
|
||||||
|
|
||||||
void CMap::DrawVertex(Math::Point uv1, Math::Point uv2, float zoom)
|
void CMap::DrawVertex(Math::Point uv1, Math::Point uv2, float zoom)
|
||||||
{
|
{
|
||||||
LPDIRECT3DDEVICE7 device;
|
Gfx::CDevice* device;
|
||||||
D3DVERTEX2 vertex[4]; // 2 triangles
|
Gfx::VertexTex2 vertex[4]; // 2 triangles
|
||||||
Math::Point p1, p2, c;
|
Math::Point p1, p2, c;
|
||||||
Math::Vector n;
|
Math::Vector n;
|
||||||
|
|
||||||
device = m_engine->RetD3DDevice();
|
device = m_engine->GetDevice();
|
||||||
|
|
||||||
p1.x = m_pos.x;
|
p1.x = m_pos.x;
|
||||||
p1.y = m_pos.y;
|
p1.y = m_pos.y;
|
||||||
|
@ -1007,12 +977,12 @@ void CMap::DrawVertex(Math::Point uv1, Math::Point uv2, float zoom)
|
||||||
|
|
||||||
n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
|
n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
|
||||||
|
|
||||||
vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv2.y);
|
vertex[0] = Gfx::VertexTex2(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x,uv2.y));
|
||||||
vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, uv1.x,uv1.y);
|
vertex[1] = Gfx::VertexTex2(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(uv1.x,uv1.y));
|
||||||
vertex[2] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, uv2.x,uv2.y);
|
vertex[2] = Gfx::VertexTex2(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(uv2.x,uv2.y));
|
||||||
vertex[3] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv2.x,uv1.y);
|
vertex[3] = Gfx::VertexTex2(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv2.x,uv1.y));
|
||||||
|
|
||||||
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 4, NULL);
|
device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
|
||||||
m_engine->AddStatisticTriangle(2);
|
m_engine->AddStatisticTriangle(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1021,7 +991,7 @@ void CMap::DrawVertex(Math::Point uv1, Math::Point uv2, float zoom)
|
||||||
|
|
||||||
void CMap::UpdateTerrain()
|
void CMap::UpdateTerrain()
|
||||||
{
|
{
|
||||||
D3DCOLORVALUE color;
|
Gfx::Color color;
|
||||||
Math::Vector pos;
|
Math::Vector pos;
|
||||||
float scale, water, level, intensity;
|
float scale, water, level, intensity;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
@ -1029,8 +999,8 @@ void CMap::UpdateTerrain()
|
||||||
if ( m_fixImage[0] != 0 ) return; // still image?
|
if ( m_fixImage[0] != 0 ) return; // still image?
|
||||||
if ( !m_engine->OpenImage("map.tga") ) return;
|
if ( !m_engine->OpenImage("map.tga") ) return;
|
||||||
|
|
||||||
scale = m_terrain->RetScaleRelief();
|
scale = m_terrain->GetScaleRelief();
|
||||||
water = m_water->RetLevel();
|
water = m_water->GetLevel();
|
||||||
color.a = 0.0f;
|
color.a = 0.0f;
|
||||||
|
|
||||||
for ( y=0 ; y<256 ; y++ )
|
for ( y=0 ; y<256 ; y++ )
|
||||||
|
@ -1044,7 +1014,7 @@ void CMap::UpdateTerrain()
|
||||||
if ( pos.x >= -m_half && pos.x <= m_half &&
|
if ( pos.x >= -m_half && pos.x <= m_half &&
|
||||||
pos.z >= -m_half && pos.z <= m_half )
|
pos.z >= -m_half && pos.z <= m_half )
|
||||||
{
|
{
|
||||||
level = m_terrain->RetFloorLevel(pos, true)/scale;
|
level = m_terrain->GetFloorLevel(pos, true)/scale;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1080,7 +1050,7 @@ void CMap::UpdateTerrain()
|
||||||
|
|
||||||
void CMap::UpdateTerrain(int bx, int by, int ex, int ey)
|
void CMap::UpdateTerrain(int bx, int by, int ex, int ey)
|
||||||
{
|
{
|
||||||
D3DCOLORVALUE color;
|
Gfx::Color color;
|
||||||
Math::Vector pos;
|
Math::Vector pos;
|
||||||
float scale, water, level, intensity;
|
float scale, water, level, intensity;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
@ -1089,8 +1059,8 @@ void CMap::UpdateTerrain(int bx, int by, int ex, int ey)
|
||||||
if ( !m_engine->OpenImage("map.tga") ) return;
|
if ( !m_engine->OpenImage("map.tga") ) return;
|
||||||
m_engine->LoadImage();
|
m_engine->LoadImage();
|
||||||
|
|
||||||
scale = m_terrain->RetScaleRelief();
|
scale = m_terrain->GetScaleRelief();
|
||||||
water = m_water->RetLevel();
|
water = m_water->GetLevel();
|
||||||
color.a = 0.0f;
|
color.a = 0.0f;
|
||||||
|
|
||||||
for ( y=by ; y<ey ; y++ )
|
for ( y=by ; y<ey ; y++ )
|
||||||
|
@ -1104,7 +1074,7 @@ void CMap::UpdateTerrain(int bx, int by, int ex, int ey)
|
||||||
if ( pos.x >= -m_half && pos.x <= m_half &&
|
if ( pos.x >= -m_half && pos.x <= m_half &&
|
||||||
pos.z >= -m_half && pos.z <= m_half )
|
pos.z >= -m_half && pos.z <= m_half )
|
||||||
{
|
{
|
||||||
level = m_terrain->RetFloorLevel(pos, true)/scale;
|
level = m_terrain->GetFloorLevel(pos, true)/scale;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1145,7 +1115,7 @@ void CMap::FlushObject()
|
||||||
|
|
||||||
m_totalFix = 0; // object index fixed
|
m_totalFix = 0; // object index fixed
|
||||||
m_totalMove = MAPMAXOBJECT-2; // moving vehicles index
|
m_totalMove = MAPMAXOBJECT-2; // moving vehicles index
|
||||||
m_bRadar = m_main->RetCheatRadar(); // no radar
|
//m_bRadar = m_main->GetCheatRadar(); // no radar
|
||||||
|
|
||||||
for ( i=0 ; i<MAPMAXOBJECT ; i++ )
|
for ( i=0 ; i<MAPMAXOBJECT ; i++ )
|
||||||
{
|
{
|
||||||
|
@ -1166,14 +1136,14 @@ void CMap::UpdateObject(CObject* pObj)
|
||||||
if ( !m_bEnable ) return;
|
if ( !m_bEnable ) return;
|
||||||
if ( m_totalFix >= m_totalMove ) return; // full table?
|
if ( m_totalFix >= m_totalMove ) return; // full table?
|
||||||
|
|
||||||
if ( !pObj->RetActif() ) return;
|
if ( !pObj->GetActif() ) return;
|
||||||
if ( !pObj->RetSelectable() ) return;
|
if ( !pObj->GetSelectable() ) return;
|
||||||
if ( pObj->RetProxyActivate() ) return;
|
if ( pObj->GetProxyActivate() ) return;
|
||||||
if ( pObj->RetTruck() != 0 ) return;
|
if ( pObj->GetTruck() != 0 ) return;
|
||||||
|
|
||||||
type = pObj->RetType();
|
type = pObj->GetType();
|
||||||
pos = pObj->RetPosition(0);
|
pos = pObj->GetPosition(0);
|
||||||
dir = -(pObj->RetAngleY(0)+Math::PI/2.0f);
|
dir = -(pObj->GetAngleY(0)+Math::PI/2.0f);
|
||||||
|
|
||||||
if ( m_angle != 0.0f )
|
if ( m_angle != 0.0f )
|
||||||
{
|
{
|
||||||
|
@ -1299,7 +1269,7 @@ void CMap::UpdateObject(CObject* pObj)
|
||||||
color != MAPCOLOR_MOVE ) return;
|
color != MAPCOLOR_MOVE ) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pObj->RetSelect() )
|
if ( pObj->GetSelect() )
|
||||||
{
|
{
|
||||||
m_map[MAPMAXOBJECT-1].type = type;
|
m_map[MAPMAXOBJECT-1].type = type;
|
||||||
m_map[MAPMAXOBJECT-1].object = pObj;
|
m_map[MAPMAXOBJECT-1].object = pObj;
|
||||||
|
@ -1337,3 +1307,4 @@ void CMap::UpdateObject(CObject* pObj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
134
src/ui/map.h
134
src/ui/map.h
|
@ -1,5 +1,6 @@
|
||||||
// * This file is part of the COLOBOT source code
|
// * This file is part of the COLOBOT source code
|
||||||
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
|
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
|
||||||
|
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
|
||||||
// *
|
// *
|
||||||
// * This program is free software: you can redistribute it and/or modify
|
// * This program is free software: you can redistribute it and/or modify
|
||||||
// * it under the terms of the GNU General Public License as published by
|
// * it under the terms of the GNU General Public License as published by
|
||||||
|
@ -22,11 +23,21 @@
|
||||||
#include <ui/control.h>
|
#include <ui/control.h>
|
||||||
|
|
||||||
#include <object/object.h>
|
#include <object/object.h>
|
||||||
|
#include <object/robotmain.h>
|
||||||
|
|
||||||
#include <common/event.h>
|
#include <common/event.h>
|
||||||
|
#include <common/iman.h>
|
||||||
|
|
||||||
class CTerrain;
|
#include <graphics/engine/terrain.h>
|
||||||
class CWater;
|
#include <graphics/engine/water.h>
|
||||||
|
#include <graphics/engine/engine.h>
|
||||||
|
#include <graphics/core/device.h>
|
||||||
|
#include <graphics/core/vertex.h>
|
||||||
|
|
||||||
|
#include <math/geometry.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
|
||||||
const int MAPMAXOBJECT = 100;
|
const int MAPMAXOBJECT = 100;
|
||||||
|
|
||||||
|
@ -59,77 +70,78 @@ struct MapObject
|
||||||
|
|
||||||
class CMap : public CControl
|
class CMap : public CControl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CMap();
|
CMap();
|
||||||
~CMap();
|
~CMap();
|
||||||
|
|
||||||
bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
|
bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
|
||||||
bool EventProcess(const Event &event);
|
bool EventProcess(const Event &event);
|
||||||
void Draw();
|
void Draw();
|
||||||
|
|
||||||
void UpdateTerrain();
|
void UpdateTerrain();
|
||||||
void UpdateTerrain(int bx, int by, int ex, int ey);
|
void UpdateTerrain(int bx, int by, int ex, int ey);
|
||||||
|
|
||||||
void SetFixImage(char *filename);
|
void SetFixImage(const char *filename);
|
||||||
bool RetFixImage();
|
bool GetFixImage();
|
||||||
|
|
||||||
void SetOffset(float ox, float oy);
|
void SetOffset(float ox, float oy);
|
||||||
void SetAngle(float angle);
|
void SetAngle(float angle);
|
||||||
void SetMode(int mode);
|
void SetMode(int mode);
|
||||||
void SetToy(bool bToy);
|
void SetToy(bool bToy);
|
||||||
void SetDebug(bool bDebug);
|
void SetDebug(bool bDebug);
|
||||||
|
|
||||||
void SetZoom(float value);
|
void SetZoom(float value);
|
||||||
float RetZoom();
|
float GetZoom();
|
||||||
|
|
||||||
void SetEnable(bool bEnable);
|
void SetEnable(bool bEnable);
|
||||||
bool RetEnable();
|
bool GetEnable();
|
||||||
|
|
||||||
void SetFloorColor(D3DCOLORVALUE color);
|
void SetFloorColor(Gfx::Color color);
|
||||||
void SetWaterColor(D3DCOLORVALUE color);
|
void SetWaterColor(Gfx::Color color);
|
||||||
|
|
||||||
void FlushObject();
|
void FlushObject();
|
||||||
void UpdateObject(CObject* pObj);
|
void UpdateObject(CObject* pObj);
|
||||||
|
|
||||||
CObject* DetectObject(Math::Point pos, bool &bInMap);
|
CObject* DetectObject(Math::Point pos, bool &bInMap);
|
||||||
void SetHilite(CObject* pObj);
|
void SetHighlight(CObject* pObj);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Math::Point AdjustOffset(Math::Point offset);
|
Math::Point AdjustOffset(Math::Point offset);
|
||||||
void SelectObject(Math::Point pos);
|
void SelectObject(Math::Point pos);
|
||||||
Math::Point MapInter(Math::Point pos, float dir);
|
Math::Point MapInter(Math::Point pos, float dir);
|
||||||
void DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color);
|
void DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color);
|
||||||
void DrawObject(Math::Point pos, float dir, ObjectType type, MapColor color, bool bSelect, bool bHilite);
|
void DrawObject(Math::Point pos, float dir, ObjectType type, MapColor color, bool bSelect, bool bHilite);
|
||||||
void DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, ObjectType type, bool bHilite);
|
void DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, ObjectType type, bool bHilite);
|
||||||
void DrawHilite(Math::Point pos);
|
void DrawHighlight(Math::Point pos);
|
||||||
void DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2);
|
void DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2);
|
||||||
void DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2);
|
void DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2);
|
||||||
void DrawVertex(Math::Point uv1, Math::Point uv2, float zoom);
|
void DrawVertex(Math::Point uv1, Math::Point uv2, float zoom);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CTerrain* m_terrain;
|
Gfx::CTerrain* m_terrain;
|
||||||
CWater* m_water;
|
Gfx::CWater* m_water;
|
||||||
CRobotMain* m_main;
|
CRobotMain* m_main;
|
||||||
|
|
||||||
bool m_bEnable;
|
bool m_bEnable;
|
||||||
float m_time;
|
float m_time;
|
||||||
float m_half;
|
float m_half;
|
||||||
float m_zoom;
|
float m_zoom;
|
||||||
Math::Point m_offset;
|
Math::Point m_offset;
|
||||||
float m_angle;
|
float m_angle;
|
||||||
D3DCOLORVALUE m_floorColor;
|
Gfx::Color m_floorColor;
|
||||||
D3DCOLORVALUE m_waterColor;
|
Gfx::Color m_waterColor;
|
||||||
MapObject m_map[MAPMAXOBJECT];
|
MapObject m_map[MAPMAXOBJECT];
|
||||||
int m_totalFix;
|
int m_totalFix;
|
||||||
int m_totalMove;
|
int m_totalMove;
|
||||||
int m_hiliteRank;
|
int m_highlightRank;
|
||||||
Math::Point m_mapPos;
|
Math::Point m_mapPos;
|
||||||
Math::Point m_mapDim;
|
Math::Point m_mapDim;
|
||||||
bool m_bRadar;
|
bool m_bRadar;
|
||||||
char m_fixImage[100];
|
char m_fixImage[100];
|
||||||
int m_mode;
|
int m_mode;
|
||||||
bool m_bToy;
|
bool m_bToy;
|
||||||
bool m_bDebug;
|
bool m_bDebug;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue