ManaPlus
Public Member Functions | Private Member Functions | Private Attributes
ModeListModel Class Reference

#include <modelistmodel.h>

Inheritance diagram for ModeListModel:
ListModel

Public Member Functions

 ModeListModel ()
 
int getNumberOfElements ()
 
std::string getElementAt (int i)
 
int getIndexOf (const std::string &widthXHeightMode)
 
- Public Member Functions inherited from ListModel
 ListModel ()
 
virtual ~ListModel ()
 

Private Member Functions

void addCustomMode (const std::string &mode)
 

Private Attributes

StringVect mVideoModes
 

Detailed Description

Definition at line 34 of file modelistmodel.h.

Constructor & Destructor Documentation

◆ ModeListModel()

ModeListModel::ModeListModel ( )

Definition at line 57 of file modelistmodel.cpp.

57  :
58  ListModel(),
59  mVideoModes()
60 {
62 #ifndef ANDROID
63  addCustomMode("640x480");
64  addCustomMode("800x600");
65  addCustomMode("1024x768");
66  addCustomMode("1280x1024");
67  addCustomMode("1400x900");
68  addCustomMode("1500x990");
71 
72  std::sort(mVideoModes.begin(), mVideoModes.end(), &modeSorter);
73  mVideoModes.push_back("custom");
74 #endif // ANDROID
75 }
int mActualHeight
Definition: graphics.h:487
int mActualWidth
Definition: graphics.h:486
ListModel()
Definition: listmodel.h:82
StringVect mVideoModes
Definition: modelistmodel.h:65
void addCustomMode(const std::string &mode)
Graphics * mainGraphics
Definition: graphics.cpp:109
static bool modeSorter(const std::string &mode1, const std::string &mode2)
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
bool getAllVideoModes(StringVect &modeList)
Definition: sdlhelper.cpp:44

References addCustomMode(), SDL::getAllVideoModes(), Graphics::mActualHeight, Graphics::mActualWidth, mainGraphics, modeSorter(), mVideoModes, and Catch::toString().

Member Function Documentation

◆ addCustomMode()

void ModeListModel::addCustomMode ( const std::string &  mode)
private

Definition at line 78 of file modelistmodel.cpp.

79 {
80  StringVectCIter it = mVideoModes.begin();
81  const StringVectCIter it_end = mVideoModes.end();
82  while (it != it_end)
83  {
84  if (*it == mode)
85  return;
86  ++ it;
87  }
88  mVideoModes.push_back(mode);
89 }
StringVect::const_iterator StringVectCIter
Definition: stringvector.h:31

References mVideoModes.

Referenced by ModeListModel().

◆ getElementAt()

std::string ModeListModel::getElementAt ( int  i)
inlinevirtual

Returns element from container.

Implements ListModel.

Definition at line 50 of file modelistmodel.h.

51  { return mVideoModes[CAST_SIZE(i)]; }
#define CAST_SIZE
Definition: cast.h:34

References CAST_SIZE, and mVideoModes.

Referenced by Setup_Video::action(), and getIndexOf().

◆ getIndexOf()

int ModeListModel::getIndexOf ( const std::string &  widthXHeightMode)

Returns the index corresponding to the given video mode. E.g.: "800x600". or -1 if not found.

Definition at line 92 of file modelistmodel.cpp.

93 {
94  std::string currentMode;
95  for (int i = 0; i < getNumberOfElements(); i++)
96  {
97  currentMode = getElementAt(i);
98  if (currentMode == widthXHeightMode)
99  return i;
100  }
101  return -1;
102 }
std::string getElementAt(int i)
Definition: modelistmodel.h:50
int getNumberOfElements()
Definition: modelistmodel.h:44

References getElementAt(), and getNumberOfElements().

Referenced by Setup_Video::cancel(), and Setup_Video::Setup_Video().

◆ getNumberOfElements()

int ModeListModel::getNumberOfElements ( )
inlinevirtual

Returns the number of elements in container.

Implements ListModel.

Definition at line 44 of file modelistmodel.h.

45  { return CAST_S32(mVideoModes.size()); }
#define CAST_S32
Definition: cast.h:30

References CAST_S32, and mVideoModes.

Referenced by getIndexOf().

Field Documentation

◆ mVideoModes

StringVect ModeListModel::mVideoModes
private

Definition at line 65 of file modelistmodel.h.

Referenced by addCustomMode(), getElementAt(), getNumberOfElements(), and ModeListModel().


The documentation for this class was generated from the following files: