From 56a3380b46f406ffaf093405ac2db4515b0a4f80 Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Mon, 28 May 2012 16:44:39 +0000 Subject: Removes the ArrayList classes, and replaces all instances with std::vector implementations. --- FoundationEx/ArrayList.cpp | 453 ------------------------------------------ FoundationEx/ArrayList.h | 170 ---------------- Magic2/Magic.vcxproj | 1 - Magic2/Magic.vcxproj.filters | 3 - Magic2/Selection.cpp | 33 ++- Magic2/Selection.h | 6 +- Magic2/Selector.cpp | 2 +- Magic2/UVMapView.cpp | 59 ++++-- Magic2/UVMapView.h | 4 +- Stars45/Mission.cpp | 4 +- libpng/Debug/libpng.lib | Bin 991614 -> 991614 bytes nGenEx/ActiveWindow.cpp | 17 +- nGenEx/ActiveWindow.h | 28 +-- nGenEx/FormDef.h | 10 +- nGenEx/Layout.cpp | 115 ++++++----- nGenEx/Layout.h | 27 ++- nGenEx/ParseUtil.cpp | 8 +- nGenEx/ParseUtil.h | 6 +- nGenEx/VideoDX9Enum.cpp | 54 ++--- nGenEx/VideoDX9Enum.h | 18 +- nGenEx/nGenEx.vcxproj | 2 - nGenEx/nGenEx.vcxproj.filters | 6 - zlib/Debug/Zlib.lib | Bin 228696 -> 228696 bytes 23 files changed, 229 insertions(+), 797 deletions(-) delete mode 100644 FoundationEx/ArrayList.cpp delete mode 100644 FoundationEx/ArrayList.h diff --git a/FoundationEx/ArrayList.cpp b/FoundationEx/ArrayList.cpp deleted file mode 100644 index 64a164f..0000000 --- a/FoundationEx/ArrayList.cpp +++ /dev/null @@ -1,453 +0,0 @@ -/* Project FoundationEx - Destroyer Studios LLC - Copyright © 1997-2004. All Rights Reserved. - - SUBSYSTEM: FoundationEx - FILE: ArrayList.cpp - AUTHOR: John DiCamillo - - - OVERVIEW - ======== - Implementation of the untyped ArrayList class -*/ - -#include "MemDebug.h" -#include "ArrayList.h" -#include - -// +-------------------------------------------------------------------+ - -void Print(const char* fmt, ...); - -// +-------------------------------------------------------------------+ - -ArrayList::ArrayList(const ArrayList& l) -{ - for (auto ali = l.array.begin(); ali != l.array.end(); ++ali) - array.push_back(*ali); - -} - -void ArrayList::clear() -{ - array.clear(); -} - -// +-------------------------------------------------------------------+ - -bool ArrayList::check(int& index) const -{ - if (index > array.size()) { - Print("Bounds error in ArrayList(%08x) index=%d min=0\n", (int)this, index); - index = 0; - } - - return (index >= 0 && index < array.size()); -} - -// +-------------------------------------------------------------------+ - -DWORD ArrayList::operator[](int index) const -{ - if (check(index)) - return array[index]; - return 0; -} - -DWORD& ArrayList::operator[](int index) -{ - if (check(index)) - return array[index]; - - return array[0]; -} - -DWORD ArrayList::at(int index) const -{ - if (check(index)) - return array[index]; - return 0; -} - -DWORD& ArrayList::at(int index) -{ - if (check(index)) - return array[index]; - - return array[0]; -} - -// +-------------------------------------------------------------------+ - -void ArrayList::resize(int newsize) -{ - array.resize(newsize); -} - -// +-------------------------------------------------------------------+ - -void ArrayList::append(DWORD item) -{ - array.push_back(item); -} - -void ArrayList::append(const ArrayList& list) -{ - for (auto li = list.array.begin(); li != list.array.end(); ++li) - array.push_back(*li); -} - -// +-------------------------------------------------------------------+ - -void ArrayList::insert(DWORD item, int index) -{ - auto it = array.begin(); - array.insert(it + index, item); -} - -// +-------------------------------------------------------------------+ - -void ArrayList::insertSort(DWORD item) -{ - for (auto arrit = array.begin(); arrit != array.end(); arrit++) { - if (*arrit < item) { - array.insert(arrit, item); - return; - } - } -} - -// +-------------------------------------------------------------------+ - -void ArrayList::remove(DWORD item) -{ - if (array.size() < 1) - return; - - for (auto it = array.begin(); it != array.end(); ++it) { - if (*it == item) - array.erase(it); - } -} - -// +-------------------------------------------------------------------+ - -void ArrayList::removeIndex(int index) -{ - if (array.size() < 1 || !check(index)) - return; - - array.erase(array.begin()+index); -} - -// +-------------------------------------------------------------------+ - -bool ArrayList::contains(DWORD val) const -{ - for (auto it = array.begin(); it != array.end(); ++it) { - if (*it == val) - return true; - } - - return false; -} - -// +-------------------------------------------------------------------+ - -int ArrayList::count(DWORD val) const -{ - int c = 0; - - for (auto it = array.begin(); it != array.end(); ++it) { - if (*it == val) - c++; - } - - return c; -} - -// +-------------------------------------------------------------------+ - -int ArrayList::index(DWORD val) const -{ - for (size_t i = 0; i < array.size(); i++) { - if (array[i] == val) - return i; - } - - return -1; -} - -// +-------------------------------------------------------------------+ - -void ArrayList::swap(int i, int j) -{ - if (i >= 0 && i < array.size() && j >= 0 && j < array.size() && i != j) { - DWORD t = array[i]; - array[i] = array[j]; - array[j] = t; - } -} - -void ArrayList::sort() -{ - if (array.size() < 2) - return; - - std::sort(array.begin(), array.end()); -} - -void ArrayList::shuffle() -{ - if (array.size() < 3) - return; - - for (int s = 0; s < 5; s++) { - for (int i = 0; i < array.size(); i++) { - int j = (rand()>>4) % array.size(); - swap(i, j); - } - } -} - - -// +===================================================================+ - -DWORD ArrayListIter::value() -{ - if (list && step >= 0) - return list->array[step]; - - return 0; -} - -// +-------------------------------------------------------------------+ - -void ArrayListIter::removeItem() -{ - if (list && step >= 0) - list->removeIndex(step--); -} - -// +-------------------------------------------------------------------+ - -DWORD ArrayListIter::next() -{ - if (list && step >= -1) - return list->array[++step]; - - return 0; -} - -DWORD ArrayListIter::prev() -{ - if (list && step > 0) - return list->array[--step]; - - return 0; -} - -// +-------------------------------------------------------------------+ - -void ArrayListIter::attach(ArrayList& l) -{ - list = &l; - step = -1; -} - -// +-------------------------------------------------------------------+ - -int ArrayListIter::size() -{ - if (!list) return 0; - return list->size(); -} - -// +-------------------------------------------------------------------+ - -ArrayList& ArrayListIter::container() -{ - return *list; -} - - - - -// +-------------------------------------------------------------------+ -// +-------------------------------------------------------------------+ -// +-------------------------------------------------------------------+ - -FloatList::FloatList(const FloatList& l) -{ - for (auto lit = l.array.begin(); lit != l.array.end(); lit++) - array.push_back(*lit); -} - -float FloatList::operator[](int index) const -{ - if (check(index)) - return array[index]; - return 0; -} - -float& FloatList::operator[](int index) -{ - if (check(index)) - return array[index]; - - return array[0]; -} - -float FloatList::at(int index) const -{ - if (check(index)) - return array[index]; - return 0; -} - -float& FloatList::at(int index) -{ - if (check(index)) - return array[index]; - - return array[0]; -} - -void FloatList::append(float value) { - array.push_back(value); -} - -void FloatList::append(const FloatList& list) -{ - for (auto li = list.array.begin(); li != list.array.end(); ++li) - array.push_back(*li); -} - - -void FloatList::insert(float item, int index) -{ - auto it = array.begin(); - array.insert(it + index, item); -} - -// +-------------------------------------------------------------------+ - -void FloatList::insertSort(float item) -{ - for (auto arrit = array.begin(); arrit != array.end(); arrit++) { - if (*arrit < item) { - array.insert(arrit, item); - return; - } - } -} - -// +-------------------------------------------------------------------+ - -void FloatList::remove(float item) -{ - if (array.size() < 1) - return; - - for (auto it = array.begin(); it != array.end(); ++it) { - if (*it == item) - array.erase(it); - } -} - -// +===================================================================+ - -float FloatListIter::value() -{ - if (list && step >= 0) - return list->array[step]; - - return 0; -} - -// +-------------------------------------------------------------------+ - -void FloatListIter::removeItem() -{ - if (list && step >= 0) - list->removeIndex(step--); -} - -// +-------------------------------------------------------------------+ - -float FloatListIter::next() -{ - if (list && step >= -1) - return list->array[++step]; - - return 0; -} - -float FloatListIter::prev() -{ - if (list && step > 0) - return list->array[--step]; - - return 0; -} - -bool FloatList::contains(float val) const -{ - for (auto it = array.begin(); it != array.end(); ++it) { - if (*it == val) - return true; - } - - return false; -} - -// +-------------------------------------------------------------------+ - -int FloatList::count(float val) const -{ - int c = 0; - - for (auto it = array.begin(); it != array.end(); ++it) { - if (*it == val) - c++; - } - - return c; -} - -// +-------------------------------------------------------------------+ - -int FloatList::index(float val) const -{ - for (size_t i = 0; i < array.size(); i++) { - if (array[i] == val) - return i; - } - - return -1; -} - -// +-------------------------------------------------------------------+ - -void FloatListIter::attach(FloatList& l) -{ - list = &l; - step = -1; -} - -// +-------------------------------------------------------------------+ - -int FloatListIter::size() -{ - if (!list) return 0; - return list->size(); -} - -// +-------------------------------------------------------------------+ - -FloatList& FloatListIter::container() -{ - return *list; -} - diff --git a/FoundationEx/ArrayList.h b/FoundationEx/ArrayList.h deleted file mode 100644 index c0985c3..0000000 --- a/FoundationEx/ArrayList.h +++ /dev/null @@ -1,170 +0,0 @@ -/* Project FoundationEx - Destroyer Studios LLC - Copyright © 1997-2004. All Rights Reserved. - - SUBSYSTEM: FoundationEx - FILE: ArrayList.h - AUTHOR: John DiCamillo - - - OVERVIEW - ======== - Simple untyped array list - - The E: That is going to be removed very very soon. For now, it has been aliased to std::vector - (or std::vector for FloatList). Full conversion to std::vector is still needed. -*/ - -#ifndef ArrayList_h -#define ArrayList_h - -#ifdef WIN32 -#include -#include -#endif - -#include - -// +-------------------------------------------------------------------+ - -class ArrayList -{ -public: - ArrayList() { array.clear(); } - ArrayList(const ArrayList& l); - ~ArrayList() { } - - DWORD operator[](int i) const; - DWORD& operator[](int i); - DWORD at(int i) const; - DWORD& at(int i); - - void append(const ArrayList& list); - void append(const DWORD val); - void insert(const DWORD val, int index=0); - void insertSort(DWORD val); - - DWORD first() const { return *array.begin(); } - DWORD last() const { return array.back(); } - void remove(DWORD val); - void removeIndex(int index); - - void clear(); - - int size() const { return array.size(); } - bool isEmpty() const { return array.size() == 0; } - - bool contains(DWORD val) const; - int count(DWORD val) const; - int index(DWORD val) const; - - void sort(); - void shuffle(); - - bool check(int& index) const; - -private: - void swap(int i, int j); - void resize(int newsize); - - - std::vector array; - - friend class ArrayListIter; -}; - -// +-------------------------------------------------------------------+ - -class ArrayListIter -{ -public: - ArrayListIter() : list(0), step(-1) { } - ArrayListIter(const ArrayListIter& i) : list(i.list), step(i.step) { } - ArrayListIter(ArrayList& l) : list(&l), step(-1) { } - - int operator++() { return next() != 0; } - int operator--() { return prev() != 0; } - - void reset() { step = -1; } - DWORD next(); - DWORD prev(); - DWORD value(); - void removeItem(); - - void attach(ArrayList& l); - ArrayList& container(); - int size(); - int index() { return step; } - -private: - ArrayList* list; - int step; -}; - - -// +-------------------------------------------------------------------+ -// +-------------------------------------------------------------------+ -// +-------------------------------------------------------------------+ - -class FloatList : public ArrayList -{ -public: - FloatList() { array.clear(); } - FloatList(const FloatList& l); - ~FloatList() {} - - float operator[](int i) const; - float& operator[](int i); - float at(int i) const; - float& at(int i); - - void append(const float val); - void append(const FloatList& list); - void insert(const float val, int index=0); - void insertSort(float val); - - float first() const { return *array.begin(); } - float last() const { return array.back(); } - void remove(float val); - - bool contains(float val) const; - int count(float val) const; - int index(float val) const; - -private: - - std::vector array; - - friend class FloatListIter; -}; - -// +-------------------------------------------------------------------+ - -class FloatListIter -{ -public: - FloatListIter() : list(0), step(-1) { } - FloatListIter(const FloatListIter& i) : list(i.list), step(i.step) { } - FloatListIter(FloatList& l) : list(&l), step(-1) { } - - int operator++() { return next() != 0; } - int operator--() { return prev() != 0; } - - void reset() { step = -1; } - float next(); - float prev(); - float value(); - void removeItem(); - - void attach(FloatList& l); - FloatList& container(); - int size(); - int index() { return step; } - -private: - FloatList* list; - int step; -}; - -#endif ArrayList_h - 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 @@ - 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 @@ Source Files - - Source Files - Source Files 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 #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& GetPolys() { return polys; } - ArrayList& GetVerts() { return verts; } + std::vector& GetVerts() { return verts; } virtual void Clear() { polys.clear(); verts.clear(); } @@ -65,7 +65,7 @@ protected: Model* model; ModelView* model_view; List polys; - ArrayList verts; + std::vector 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 #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 selverts; }; // +--------------------------------------------------------------------+ diff --git a/Stars45/Mission.cpp b/Stars45/Mission.cpp index a43a345..b9bceac 100644 --- a/Stars45/Mission.cpp +++ b/Stars45/Mission.cpp @@ -841,7 +841,7 @@ Mission::ParseEvent(TermStruct* val) } else if (pdef->term()->isArray()) { - FloatList plist; + std::vector plist; GetDefArray(plist, pdef, filename); for (int i = 0; i < 10 && i < plist.size(); i++) { @@ -861,7 +861,7 @@ Mission::ParseEvent(TermStruct* val) } else if (pdef->term()->isArray()) { - FloatList plist; + std::vector plist; GetDefArray(plist, pdef, filename); for (int i = 0; i < 10 && i < plist.size(); i++) { diff --git a/libpng/Debug/libpng.lib b/libpng/Debug/libpng.lib index b9a116a..3baaef9 100644 Binary files a/libpng/Debug/libpng.lib and b/libpng/Debug/libpng.lib differ diff --git a/nGenEx/ActiveWindow.cpp b/nGenEx/ActiveWindow.cpp index 2830325..756912b 100644 --- a/nGenEx/ActiveWindow.cpp +++ b/nGenEx/ActiveWindow.cpp @@ -12,6 +12,7 @@ Window class */ +#include #include "MemDebug.h" #include "ActiveWindow.h" #include "EventDispatch.h" @@ -174,10 +175,10 @@ ActiveWindow::DoLayout() // +--------------------------------------------------------------------+ void -ActiveWindow::UseLayout(const ArrayList& min_x, -const ArrayList& min_y, -const FloatList& weight_x, -const FloatList& weight_y) +ActiveWindow::UseLayout(const std::vector& min_x, +const std::vector& min_y, +const std::vector& weight_x, +const std::vector& weight_y) { if (!layout) layout = new(__FILE__,__LINE__) Layout; @@ -187,10 +188,10 @@ const FloatList& weight_y) } void -ActiveWindow::UseLayout(const FloatList& min_x, -const FloatList& min_y, -const FloatList& weight_x, -const FloatList& weight_y) +ActiveWindow::UseLayout(const std::vector& min_x, +const std::vector& min_y, +const std::vector& weight_x, +const std::vector& weight_y) { if (!layout) layout = new(__FILE__,__LINE__) Layout; diff --git a/nGenEx/ActiveWindow.h b/nGenEx/ActiveWindow.h index 6be3bfb..b08cd26 100644 --- a/nGenEx/ActiveWindow.h +++ b/nGenEx/ActiveWindow.h @@ -15,13 +15,13 @@ #ifndef ActiveWindow_h #define ActiveWindow_h +#include #include "Types.h" #include "Color.h" #include "Geometry.h" #include "Bitmap.h" #include "Window.h" #include "EventTarget.h" -#include "ArrayList.h" #include "List.h" #include "Text.h" @@ -132,20 +132,20 @@ public: virtual void Show(); virtual void Hide(); virtual void MoveTo(const Rect& r); - virtual void UseLayout(const ArrayList& min_x, - const ArrayList& min_y, - const FloatList& weight_x, - const FloatList& weight_y); - virtual void UseLayout(const FloatList& min_x, - const FloatList& min_y, - const FloatList& weight_x, - const FloatList& weight_y); + virtual void UseLayout(const std::vector& min_x, + const std::vector& min_y, + const std::vector& weight_x, + const std::vector& weight_y); + virtual void UseLayout(const std::vector& min_x, + const std::vector& min_y, + const std::vector& weight_x, + const std::vector& weight_y); virtual void UseLayout(int ncols, - int nrows, - int* min_x, - int* min_y, - float* weight_x, - float* weight_y); + int nrows, + int* min_x, + int* min_y, + float* weight_x, + float* weight_y); virtual void DoLayout(); // Event Target Interface: diff --git a/nGenEx/FormDef.h b/nGenEx/FormDef.h index c483a35..1fad78d 100644 --- a/nGenEx/FormDef.h +++ b/nGenEx/FormDef.h @@ -15,11 +15,11 @@ #ifndef FormDef_h #define FormDef_h +#include #include "Types.h" #include "Geometry.h" #include "Color.h" #include "Text.h" -#include "ArrayList.h" #include "List.h" // +--------------------------------------------------------------------+ @@ -66,10 +66,10 @@ class LayoutDef public: static const char* TYPENAME() { return "LayoutDef"; } - ArrayList x_mins; - ArrayList y_mins; - FloatList x_weights; - FloatList y_weights; + std::vector x_mins; + std::vector y_mins; + std::vector x_weights; + std::vector y_weights; }; // +--------------------------------------------------------------------+ diff --git a/nGenEx/Layout.cpp b/nGenEx/Layout.cpp index b7a38bb..afca9e7 100644 --- a/nGenEx/Layout.cpp +++ b/nGenEx/Layout.cpp @@ -34,8 +34,8 @@ Layout::DoLayout(ActiveWindow* panel) if (cols.size() < 1 || rows.size() < 1) return false; - ArrayList cell_x; - ArrayList cell_y; + std::vector cell_x; + std::vector cell_y; ScaleWeights(); CalcCells(panel->Width(), panel->Height(), cell_x, cell_y); @@ -94,31 +94,30 @@ Layout::DoLayout(ActiveWindow* panel) void Layout::ScaleWeights() { - int i; float total = 0; - for (i = 0; i < col_weights.size(); i++) - total += col_weights[i]; + for (auto cwi = col_weights.begin(); cwi != col_weights.end(); ++cwi) + total += *cwi; if (total > 0) { - for (i = 0; i < col_weights.size(); i++) - col_weights[i] = col_weights[i] / total; + for (auto cwi = col_weights.begin(); cwi != col_weights.end(); ++cwi) + *cwi = *cwi / total; } total = 0; - for (i = 0; i < row_weights.size(); i++) - total += row_weights[i]; + for (auto rwi = row_weights.begin(); rwi != row_weights.end(); ++rwi) + total += *rwi; if (total > 0) { - for (i = 0; i < row_weights.size(); i++) - row_weights[i] = row_weights[i] / total; + for (auto rwi = row_weights.begin(); rwi != row_weights.end(); ++rwi) + *rwi = *rwi / total; } } // +--------------------------------------------------------------------+ void -Layout::CalcCells(DWORD w, DWORD h, ArrayList& cell_x, ArrayList& cell_y) + Layout::CalcCells(DWORD w, DWORD h, std::vector& cell_x, std::vector& cell_y) { DWORD x = 0; DWORD y = 0; @@ -126,30 +125,29 @@ Layout::CalcCells(DWORD w, DWORD h, ArrayList& cell_x, ArrayList& cell_y) DWORD min_y = 0; DWORD ext_x = 0; DWORD ext_y = 0; - int i; - for (i = 0; i < cols.size(); i++) - min_x += cols[i]; + for (auto cit = cols.begin(); cit != cols.end(); ++cit) + min_x += *cit; - for (i = 0; i < rows.size(); i++) - min_y += rows[i]; + for (auto rit = rows.begin(); rit != rows.end(); ++rit) + min_y += *rit; if (min_x < w) - ext_x = w - min_x; + ext_x = w - min_x; if (min_y < h) - ext_y = h - min_y; + ext_y = h - min_y; - cell_x.append(x); - for (i = 0; i < cols.size(); i++) { - x += cols[i] + (DWORD) (ext_x * col_weights[i]); - cell_x.append(x); + cell_x.push_back(x); + for (auto cit = cols.begin(); cit != cols.end(); ++cit) { + x += *cit + (DWORD) (ext_x * col_weights[cit - cols.begin()]); + cell_x.push_back(x); } - cell_y.append(y); - for (i = 0; i < rows.size(); i++) { - y += rows[i] + (DWORD) (ext_y * row_weights[i]); - cell_y.append(y); + cell_y.push_back(y); + for (auto rit = rows.begin(); rit != rows.end(); ++rit) { + y += *rit + (DWORD) (ext_y * row_weights[rit - rows.begin()]); + cell_y.push_back(y); } } @@ -168,55 +166,62 @@ Layout::Clear() void Layout::AddCol(DWORD min_width, float col_factor) { - cols.append(min_width); - col_weights.append(col_factor); + cols.push_back(min_width); + col_weights.push_back(col_factor); } void Layout::AddRow(DWORD min_height, float row_factor) { - rows.append(min_height); - row_weights.append(row_factor); + rows.push_back(min_height); + row_weights.push_back(row_factor); } void -Layout::SetConstraints(const ArrayList& min_x, -const ArrayList& min_y, -const FloatList& weight_x, -const FloatList& weight_y) +Layout::SetConstraints(const std::vector& min_x, +const std::vector& min_y, +const std::vector& weight_x, +const std::vector& weight_y) { Clear(); - if (min_x.size() == weight_x.size() && - min_y.size() == weight_y.size()) { + if (min_x.size() == weight_x.size() && min_y.size() == weight_y.size()) { + for (auto iter = min_x.begin(); iter != min_x.end(); ++iter) + cols.push_back(*iter); - cols.append(min_x); - rows.append(min_y); + for (auto iter = min_y.begin(); iter != min_y.end(); ++iter) + rows.push_back(*iter); - col_weights.append(weight_x); - row_weights.append(weight_y); + for (auto iter = weight_x.begin(); iter != weight_x.end(); ++iter) + col_weights.push_back(*iter); + + for (auto iter = weight_y.begin(); iter != weight_y.end(); ++iter) + row_weights.push_back(*iter); } } void -Layout::SetConstraints(const FloatList& min_x, -const FloatList& min_y, -const FloatList& weight_x, -const FloatList& weight_y) +Layout::SetConstraints(const std::vector& min_x, +const std::vector& min_y, +const std::vector& weight_x, +const std::vector& weight_y) { Clear(); if (min_x.size() == weight_x.size() && min_y.size() == weight_y.size()) { - for (int i = 0; i < min_x.size(); i++) - cols.append((DWORD) min_x[i]); + for (auto iter = min_x.begin(); iter != min_x.begin(); ++iter) + cols.push_back((DWORD) *iter); + + for (auto iter = min_y.begin(); iter != min_y.begin(); ++iter) + rows.push_back((DWORD) *iter); - for (int i = 0; i < min_y.size(); i++) - rows.append((DWORD) min_y[i]); + for (auto iter = weight_x.begin(); iter != weight_x.end(); ++iter) + col_weights.push_back(*iter); - col_weights.append(weight_x); - row_weights.append(weight_y); + for (auto iter = weight_y.begin(); iter != weight_y.end(); ++iter) + row_weights.push_back(*iter); } } @@ -234,13 +239,13 @@ const float* weight_y) int i = 0; for (i = 0; i < ncols; i++) { - cols.append(min_x[i]); - col_weights.append(weight_x[i]); + cols.push_back(min_x[i]); + col_weights.push_back(weight_x[i]); } for (i = 0; i < nrows; i++) { - rows.append(min_y[i]); - row_weights.append(weight_y[i]); + rows.push_back(min_y[i]); + row_weights.push_back(weight_y[i]); } } } diff --git a/nGenEx/Layout.h b/nGenEx/Layout.h index 8986719..94fd627 100644 --- a/nGenEx/Layout.h +++ b/nGenEx/Layout.h @@ -16,7 +16,6 @@ #define Layout_h #include "ActiveWindow.h" -#include "ArrayList.h" // +--------------------------------------------------------------------+ @@ -34,15 +33,15 @@ public: virtual void AddCol(DWORD min_width, float col_factor); virtual void AddRow(DWORD min_height, float row_factor); - virtual void SetConstraints(const ArrayList& min_x, - const ArrayList& min_y, - const FloatList& weight_x, - const FloatList& weight_y); + virtual void SetConstraints(const std::vector& min_x, + const std::vector& min_y, + const std::vector& weight_x, + const std::vector& weight_y); - virtual void SetConstraints(const FloatList& min_x, - const FloatList& min_y, - const FloatList& weight_x, - const FloatList& weight_y); + virtual void SetConstraints(const std::vector& min_x, + const std::vector& min_y, + const std::vector& weight_x, + const std::vector& weight_y); virtual void SetConstraints(int ncols, int nrows, @@ -54,12 +53,12 @@ public: protected: virtual void ScaleWeights(); - virtual void CalcCells(DWORD w, DWORD h, ArrayList& cell_x, ArrayList& cell_y); + virtual void CalcCells(DWORD w, DWORD h, std::vector& cell_x, std::vector& cell_y); - ArrayList cols; - ArrayList rows; - FloatList col_weights; - FloatList row_weights; + std::vector cols; + std::vector rows; + std::vector col_weights; + std::vector row_weights; }; #endif Layout_h diff --git a/nGenEx/ParseUtil.cpp b/nGenEx/ParseUtil.cpp index 6e64e39..01e8370 100644 --- a/nGenEx/ParseUtil.cpp +++ b/nGenEx/ParseUtil.cpp @@ -390,7 +390,7 @@ bool GetDefArray(double* dst, int size, TermDef* def, const char* file) // +--------------------------------------------------------------------+ -bool GetDefArray(ArrayList& array, TermDef* def, const char* file) +bool GetDefArray(std::vector& array, TermDef* def, const char* file) { if (!def || !def->term()) { Print("WARNING: missing ARRAY TermDef in '%s'\n", file); @@ -404,7 +404,7 @@ bool GetDefArray(ArrayList& array, TermDef* def, const char* file) array.clear(); for (int i = 0; i < nelem; i++) - array.append((DWORD) (val->elements()->at(i)->isNumber()->value())); + array.push_back((DWORD) (val->elements()->at(i)->isNumber()->value())); return true; } @@ -415,7 +415,7 @@ bool GetDefArray(ArrayList& array, TermDef* def, const char* file) return false; } -bool GetDefArray(FloatList& array, TermDef* def, const char* file) +bool GetDefArray(std::vector& array, TermDef* def, const char* file) { if (!def || !def->term()) { Print("WARNING: missing ARRAY TermDef in '%s'\n", file); @@ -429,7 +429,7 @@ bool GetDefArray(FloatList& array, TermDef* def, const char* file) array.clear(); for (int i = 0; i < nelem; i++) - array.append((float) (val->elements()->at(i)->isNumber()->value())); + array.push_back((float) (val->elements()->at(i)->isNumber()->value())); return true; } diff --git a/nGenEx/ParseUtil.h b/nGenEx/ParseUtil.h index 4f43a02..701bc18 100644 --- a/nGenEx/ParseUtil.h +++ b/nGenEx/ParseUtil.h @@ -15,10 +15,10 @@ #ifndef ParseUtil_h #define ParseUtil_h +#include #include "Types.h" #include "Geometry.h" #include "Color.h" -#include "ArrayList.h" #include "Text.h" #include "Parser.h" @@ -44,8 +44,8 @@ bool GetDefTime(int& dst, TermDef* def, const char* file); bool GetDefArray(int* dst, int size, TermDef* def, const char* file); bool GetDefArray(float* dst, int size, TermDef* def, const char* file); bool GetDefArray(double* dst, int size, TermDef* def, const char* file); -bool GetDefArray(ArrayList& array, TermDef* def, const char* file); -bool GetDefArray(FloatList& array, TermDef* def, const char* file); +bool GetDefArray(std::vector& array, TermDef* def, const char* file); +bool GetDefArray(std::vector& array, TermDef* def, const char* file); // +--------------------------------------------------------------------+ diff --git a/nGenEx/VideoDX9Enum.cpp b/nGenEx/VideoDX9Enum.cpp index 9ec92b5..68f5264 100644 --- a/nGenEx/VideoDX9Enum.cpp +++ b/nGenEx/VideoDX9Enum.cpp @@ -258,13 +258,13 @@ VideoDX9Enum::Enumerate() Print("----------------------------------------\n\n"); } - allowed_adapter_format_list.append(D3DFMT_X8R8G8B8); - allowed_adapter_format_list.append(D3DFMT_X1R5G5B5); - allowed_adapter_format_list.append(D3DFMT_R5G6B5); - allowed_adapter_format_list.append(D3DFMT_A2R10G10B10); + allowed_adapter_format_list.push_back(D3DFMT_X8R8G8B8); + allowed_adapter_format_list.push_back(D3DFMT_X1R5G5B5); + allowed_adapter_format_list.push_back(D3DFMT_R5G6B5); + allowed_adapter_format_list.push_back(D3DFMT_A2R10G10B10); VideoDX9AdapterInfo* adapter_info = 0; - ArrayList adapter_format_list; + std::vector adapter_format_list; UINT num_adapters = d3d->GetAdapterCount(); for (UINT ordinal = 0; ordinal < num_adapters; ordinal++) { @@ -279,8 +279,8 @@ VideoDX9Enum::Enumerate() // Also build a temporary list of all display adapter formats. adapter_format_list.clear(); - for (int iaaf = 0; iaaf < allowed_adapter_format_list.size(); iaaf++) { - D3DFORMAT allowed_adapter_format = (D3DFORMAT) allowed_adapter_format_list[iaaf]; + for (size_t iaaf = 0; iaaf < allowed_adapter_format_list.size(); iaaf++) { + D3DFORMAT allowed_adapter_format = allowed_adapter_format_list[iaaf]; UINT num_adapter_modes = d3d->GetAdapterModeCount(ordinal, allowed_adapter_format); for (UINT mode = 0; mode < num_adapter_modes; mode++) { @@ -302,8 +302,16 @@ VideoDX9Enum::Enumerate() adapter_info->display_mode_list.append(dx9_display_mode); - if (!adapter_format_list.contains(display_mode.Format)) - adapter_format_list.append(display_mode.Format); + bool contains_display_mode = false; + for (auto afli = adapter_format_list.begin(); afli != adapter_format_list.end(); ++afli) { + if (*afli == display_mode.Format) { + contains_display_mode = true; + break; + } + } + if (!contains_display_mode) + adapter_format_list.push_back(display_mode.Format); + } } @@ -350,7 +358,7 @@ VideoDX9Enum::Enumerate() // +--------------------------------------------------------------------+ HRESULT -VideoDX9Enum::EnumerateDevices(VideoDX9AdapterInfo* adapter_info, ArrayList& adapter_format_list) +VideoDX9Enum::EnumerateDevices(VideoDX9AdapterInfo* adapter_info, std::vector& adapter_format_list) { HRESULT hr = E_FAIL; const D3DDEVTYPE dtypes[3] = { D3DDEVTYPE_HAL, D3DDEVTYPE_SW, D3DDEVTYPE_REF }; @@ -399,7 +407,7 @@ VideoDX9Enum::EnumerateDevices(VideoDX9AdapterInfo* adapter_info, ArrayList& ada // +--------------------------------------------------------------------+ HRESULT -VideoDX9Enum::EnumerateDeviceCombos(VideoDX9DeviceInfo* device_info, ArrayList& adapter_format_list) +VideoDX9Enum::EnumerateDeviceCombos(VideoDX9DeviceInfo* device_info, std::vector& adapter_format_list) { const D3DFORMAT back_buffer_formats[] = { D3DFMT_A8R8G8B8, @@ -414,8 +422,8 @@ VideoDX9Enum::EnumerateDeviceCombos(VideoDX9DeviceInfo* device_info, ArrayList& // See which adapter formats are supported by this device D3DFORMAT a_fmt; - for (int i = 0; i < adapter_format_list.size(); i++) { - a_fmt = (D3DFORMAT) adapter_format_list[i]; + for (size_t i = 0; i < adapter_format_list.size(); i++) { + a_fmt = adapter_format_list[i]; D3DFORMAT b_fmt; for (int n = 0; n < 6; n++) { @@ -524,7 +532,7 @@ VideoDX9Enum::BuildDepthStencilFormatList(VideoDX9DeviceCombo* device_combo) device_combo->back_buffer_format, fmt))) { - device_combo->depth_stencil_fmt_list.append(fmt); + device_combo->depth_stencil_fmt_list.push_back(fmt); } } } @@ -564,8 +572,8 @@ VideoDX9Enum::BuildMultiSampleTypeList(VideoDX9DeviceCombo* device_combo) multisample_type, &multisample_qual))) { - device_combo->multisample_type_list.append(multisample_type); - device_combo->multisample_qual_list.append(multisample_qual); + device_combo->multisample_type_list.push_back(multisample_type); + device_combo->multisample_qual_list.push_back(multisample_qual); } } } @@ -573,10 +581,10 @@ VideoDX9Enum::BuildMultiSampleTypeList(VideoDX9DeviceCombo* device_combo) void VideoDX9Enum::BuildDSMSConflictList(VideoDX9DeviceCombo* device_combo) { - for (int i = 0; i < device_combo->depth_stencil_fmt_list.size(); i++) { + for (size_t i = 0; i < device_combo->depth_stencil_fmt_list.size(); i++) { D3DFORMAT depth_format = (D3DFORMAT) device_combo->depth_stencil_fmt_list[i]; - for (int n = 0; n < device_combo->multisample_type_list.size(); n++) { + for (size_t n = 0; n < device_combo->multisample_type_list.size(); n++) { D3DMULTISAMPLE_TYPE multisample_type = (D3DMULTISAMPLE_TYPE) device_combo->multisample_type_list[n]; if (FAILED(d3d->CheckDeviceMultiSampleType(device_combo->adapter_ordinal, @@ -602,17 +610,17 @@ VideoDX9Enum::BuildVertexProcessingTypeList(VideoDX9DeviceInfo* device_info, Vid { if ((device_info->caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) != 0) { if ((device_info->caps.DevCaps & D3DDEVCAPS_PUREDEVICE) != 0) { - device_combo->vertex_processing_list.append(PURE_HARDWARE_VP); + device_combo->vertex_processing_list.push_back(PURE_HARDWARE_VP); } - device_combo->vertex_processing_list.append(HARDWARE_VP); + device_combo->vertex_processing_list.push_back(HARDWARE_VP); if (uses_mixed_vp) { - device_combo->vertex_processing_list.append(MIXED_VP); + device_combo->vertex_processing_list.push_back(MIXED_VP); } } - device_combo->vertex_processing_list.append(SOFTWARE_VP); + device_combo->vertex_processing_list.push_back(SOFTWARE_VP); } void @@ -641,7 +649,7 @@ VideoDX9Enum::BuildPresentIntervalList(VideoDX9DeviceInfo* device_info, VideoDX9 if (interval == D3DPRESENT_INTERVAL_DEFAULT || (device_info->caps.PresentationIntervals & interval)) { - device_combo->present_interval_list.append(interval); + device_combo->present_interval_list.push_back(interval); } } } diff --git a/nGenEx/VideoDX9Enum.h b/nGenEx/VideoDX9Enum.h index 57e00cd..e4e6f54 100644 --- a/nGenEx/VideoDX9Enum.h +++ b/nGenEx/VideoDX9Enum.h @@ -18,8 +18,8 @@ #include #include "Video.h" -#include "ArrayList.h" #include "List.h" +#include // +--------------------------------------------------------------------+ @@ -72,8 +72,8 @@ public: bool req_fullscreen; private: - HRESULT EnumerateDevices(VideoDX9AdapterInfo* adapter_info, ArrayList& adapter_format_list); - HRESULT EnumerateDeviceCombos(VideoDX9DeviceInfo* device_info, ArrayList& adapter_format_list); + HRESULT EnumerateDevices(VideoDX9AdapterInfo* adapter_info, std::vector& adapter_format_list); + HRESULT EnumerateDeviceCombos(VideoDX9DeviceInfo* device_info, std::vector& adapter_format_list); void BuildDepthStencilFormatList(VideoDX9DeviceCombo* device_combo); void BuildMultiSampleTypeList(VideoDX9DeviceCombo* device_combo); @@ -82,7 +82,7 @@ private: void BuildPresentIntervalList(VideoDX9DeviceInfo* device_info, VideoDX9DeviceCombo* device_combo); IDirect3D9* d3d; - ArrayList allowed_adapter_format_list; + std::vector allowed_adapter_format_list; List adapter_info_list; int adapter_index; @@ -170,11 +170,11 @@ struct VideoDX9DeviceCombo D3DFORMAT back_buffer_format; bool is_windowed; - ArrayList vertex_processing_list; - ArrayList depth_stencil_fmt_list; - ArrayList multisample_type_list; - ArrayList multisample_qual_list; - ArrayList present_interval_list; + std::vector vertex_processing_list; + std::vector depth_stencil_fmt_list; + std::vector multisample_type_list; + std::vector multisample_qual_list; + std::vector present_interval_list; List conflict_list; }; diff --git a/nGenEx/nGenEx.vcxproj b/nGenEx/nGenEx.vcxproj index 29d4c0a..ddb89e3 100644 --- a/nGenEx/nGenEx.vcxproj +++ b/nGenEx/nGenEx.vcxproj @@ -346,7 +346,6 @@ - @@ -430,7 +429,6 @@ - diff --git a/nGenEx/nGenEx.vcxproj.filters b/nGenEx/nGenEx.vcxproj.filters index e5049f1..3b4e538 100644 --- a/nGenEx/nGenEx.vcxproj.filters +++ b/nGenEx/nGenEx.vcxproj.filters @@ -17,9 +17,6 @@ Source Files - - Source Files - Source Files @@ -265,9 +262,6 @@ Header Files - - Header Files - Header Files diff --git a/zlib/Debug/Zlib.lib b/zlib/Debug/Zlib.lib index 932b8ae..fdf5921 100644 Binary files a/zlib/Debug/Zlib.lib and b/zlib/Debug/Zlib.lib differ -- cgit v1.1