summaryrefslogtreecommitdiffhomepage
path: root/Magic2
diff options
context:
space:
mode:
authorFWoltermann@gmail.com <FWoltermann@gmail.com@076cb2c4-205e-83fd-5cf3-1be9aa105544>2012-05-28 16:44:39 +0000
committerFWoltermann@gmail.com <FWoltermann@gmail.com@076cb2c4-205e-83fd-5cf3-1be9aa105544>2012-05-28 16:44:39 +0000
commit56a3380b46f406ffaf093405ac2db4515b0a4f80 (patch)
treee9e4c5553343f27e41d862c49b21fd69bf5161b9 /Magic2
parent41b40af36198fb013a2034a1954bbc4df50fea8b (diff)
downloadstarshatter-56a3380b46f406ffaf093405ac2db4515b0a4f80.zip
starshatter-56a3380b46f406ffaf093405ac2db4515b0a4f80.tar.gz
starshatter-56a3380b46f406ffaf093405ac2db4515b0a4f80.tar.bz2
Removes the ArrayList classes, and replaces all instances with std::vector implementations.
Diffstat (limited to 'Magic2')
-rw-r--r--Magic2/Magic.vcxproj1
-rw-r--r--Magic2/Magic.vcxproj.filters3
-rw-r--r--Magic2/Selection.cpp33
-rw-r--r--Magic2/Selection.h6
-rw-r--r--Magic2/Selector.cpp2
-rw-r--r--Magic2/UVMapView.cpp59
-rw-r--r--Magic2/UVMapView.h4
7 files changed, 79 insertions, 29 deletions
diff --git a/Magic2/Magic.vcxproj b/Magic2/Magic.vcxproj
index a3d18c4..1e1337f 100644
--- a/Magic2/Magic.vcxproj
+++ b/Magic2/Magic.vcxproj
@@ -394,7 +394,6 @@
<ClCompile Include="AlphaInverse.cpp" />
<ClCompile Include="AlphaPalette.cpp" />
<ClCompile Include="..\nGenEx\Archive.cpp" />
- <ClCompile Include="..\FoundationEx\ArrayList.cpp" />
<ClCompile Include="..\nGenEx\AviFile.cpp" />
<ClCompile Include="..\nGenEx\Bitmap.cpp" />
<ClCompile Include="..\nGenEx\Bmp.cpp" />
diff --git a/Magic2/Magic.vcxproj.filters b/Magic2/Magic.vcxproj.filters
index 7975525..1ed7515 100644
--- a/Magic2/Magic.vcxproj.filters
+++ b/Magic2/Magic.vcxproj.filters
@@ -27,9 +27,6 @@
<ClCompile Include="..\nGenEx\Archive.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\FoundationEx\ArrayList.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="..\nGenEx\AviFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/Magic2/Selection.cpp b/Magic2/Selection.cpp
index 1c69129..3db43db 100644
--- a/Magic2/Selection.cpp
+++ b/Magic2/Selection.cpp
@@ -63,7 +63,7 @@ Selection::Render(Video* video, DWORD flags)
}
if (model) {
- for (int i = 0; i < verts.size(); i++) {
+ for (size_t i = 0; i < verts.size(); i++) {
DWORD value = verts[i];
WORD index = (WORD) (value >> 16);
WORD vert = (WORD) (value & 0xffff);
@@ -152,20 +152,41 @@ Selection::AddVert(WORD s, WORD v)
{
DWORD value = (s << 16) | v;
- if (!verts.contains(value))
- verts.append(value);
+ bool contains = false;
+ for (auto vi = verts.begin(); vi != verts.end(); ++vi) {
+ if (*vi == value) {
+ contains = true;
+ break;
+ }
+ }
+
+ if (!contains)
+ verts.push_back(value);
}
void
Selection::RemoveVert(WORD s, WORD v)
{
DWORD value = (s << 16) | v;
- verts.remove(value);
+
+ for (auto vi = verts.begin(); vi != verts.end(); ++vi) {
+ if (*vi == value) {
+ verts.erase(vi);
+ return;
+ }
+ }
}
bool
Selection::Contains(WORD s, WORD v) const
{
- DWORD value = (s << 16) | v;
- return verts.contains(value);
+ DWORD value = (s << 16) | v;
+
+ for (auto vi = verts.begin(); vi != verts.end(); ++vi) {
+ if (*vi == value) {
+ return true;
+ }
+ }
+
+ return false;
} \ No newline at end of file
diff --git a/Magic2/Selection.h b/Magic2/Selection.h
index 092f0ac..aba249a 100644
--- a/Magic2/Selection.h
+++ b/Magic2/Selection.h
@@ -15,11 +15,11 @@
#ifndef Selection_h
#define Selection_h
+#include <vector>
#include "Polygon.h"
#include "Graphic.h"
#include "Video.h"
#include "List.h"
-#include "ArrayList.h"
// +--------------------------------------------------------------------+
@@ -49,7 +49,7 @@ public:
void UseView(ModelView* v){ model_view = v; }
Model* GetModel() const { return model; }
List<Poly>& GetPolys() { return polys; }
- ArrayList& GetVerts() { return verts; }
+ std::vector<DWORD>& GetVerts() { return verts; }
virtual void Clear() { polys.clear();
verts.clear(); }
@@ -65,7 +65,7 @@ protected:
Model* model;
ModelView* model_view;
List<Poly> polys;
- ArrayList verts;
+ std::vector<DWORD> verts;
};
// +--------------------------------------------------------------------+
diff --git a/Magic2/Selector.cpp b/Magic2/Selector.cpp
index c79f813..898355e 100644
--- a/Magic2/Selector.cpp
+++ b/Magic2/Selector.cpp
@@ -232,7 +232,7 @@ Selector::SelectAll(int select_mode)
for (int i = 0; i < s->NumVerts(); i++) {
DWORD value = (iter.index() << 16) | i;
- selection->GetVerts().append(value);
+ selection->GetVerts().push_back(value);
}
}
}
diff --git a/Magic2/UVMapView.cpp b/Magic2/UVMapView.cpp
index 305782b..9e5ac98 100644
--- a/Magic2/UVMapView.cpp
+++ b/Magic2/UVMapView.cpp
@@ -182,8 +182,8 @@ UVMapView::DragBy(double dx, double dy)
float du = (float) (dx/w);
float dv = (float) (dy/h);
- for (int i = 0; i < selverts.size(); i++) {
- DWORD value = selverts[i];
+ for (auto svi = selverts.begin(); svi != selverts.end(); ++svi) {
+ DWORD value = *svi;
DWORD p = value >> 16;
DWORD n = value & 0xffff;
@@ -266,10 +266,21 @@ UVMapView::End()
DWORD value = (p_index << 16) | i;
if (select_mode == SELECT_REMOVE) {
- selverts.remove(value);
+ for (auto svi = selverts.begin(); svi != selverts.end(); ++svi) {
+ if (*svi == value) {
+ selverts.erase(svi);
+ }
+ }
}
- else if (!selverts.contains(value)) {
- selverts.append(value);
+ else {
+ bool contains = false;
+ for (auto svi = selverts.begin(); svi != selverts.end(); ++svi) {
+ if (*svi == value) {
+ contains = true;
+ }
+ }
+ if (!contains)
+ selverts.push_back(value);
}
}
}
@@ -302,10 +313,19 @@ UVMapView::End()
DWORD value = (p_index << 16) | i;
if (select_mode == SELECT_REMOVE) {
- selverts.remove(value);
+ for (auto svi = selverts.begin(); svi != selverts.end(); ++svi) {
+ if (*svi == value)
+ selverts.erase(svi);
+ }
}
- else if (!selverts.contains(value)) {
- selverts.append(value);
+ else {
+ bool contains = false;
+ for (auto svi = selverts.begin(); svi != selverts.end(); ++svi) {
+ if (*svi == value)
+ contains = true;
+ }
+ if (!contains)
+ selverts.push_back(value);
}
}
}
@@ -332,7 +352,7 @@ UVMapView::SelectAll()
for (int i = 0; i < p->nverts; i++) {
WORD p_index = iter.index();
DWORD value = (p_index << 16) | i;
- selverts.append(value);
+ selverts.push_back(value);
}
}
}
@@ -357,10 +377,17 @@ UVMapView::SelectInverse()
WORD p_index = iter.index();
DWORD value = (p_index << 16) | i;
- if (selverts.contains(value))
- selverts.remove(value);
+ bool contains = false;
+ auto svi = selverts.begin();
+ for (; svi != selverts.end(); ++svi) {
+ if (*svi == value) contains = true;
+ break;
+ }
+
+ if (contains)
+ selverts.erase(svi);
else
- selverts.append(value);
+ selverts.push_back(value);
}
}
}
@@ -371,7 +398,13 @@ UVMapView::IsSelected(Poly* poly, WORD v)
WORD p = polys.index(poly);
DWORD value = (p << 16) | v;
- return selverts.contains(value);
+ bool contains = false;
+
+ for (auto svi = selverts.begin(); svi != selverts.end(); ++svi) {
+ return true;
+ }
+
+ return false;
}
bool
diff --git a/Magic2/UVMapView.h b/Magic2/UVMapView.h
index 87b0eeb..fb40cbf 100644
--- a/Magic2/UVMapView.h
+++ b/Magic2/UVMapView.h
@@ -16,10 +16,10 @@
#ifndef UVMapView_h
#define UVMapView_h
+#include <vector>
#include "View.h"
#include "Polygon.h"
#include "List.h"
-#include "ArrayList.h"
// +--------------------------------------------------------------------+
@@ -74,7 +74,7 @@ protected:
int select_mode;
bool active;
- ArrayList selverts;
+ std::vector<DWORD> selverts;
};
// +--------------------------------------------------------------------+