Rise
The Vieneo Province
Toggle main menu visibility
Loading...
Searching...
No Matches
ControlArray.h
Go to the documentation of this file.
1
#pragma once
2
#include <Windows.h>
3
#include <algorithm>
4
#include <vector>
5
#include <new>
6
7
// The controls expose stable integer indices; ownership remains with their
8
// dialog/resource manager just as it does for the game's other UI objects.
9
template
<
class
T>
class
ControlArray
10
{
11
public
:
12
int
GetSize
()
const
{
return
int
(
values
.size());}
13
T&
GetAt
(
int
index){
return
values
.at(
size_t
(index));}
14
const
T&
GetAt
(
int
index)
const
{
return
values
.at(
size_t
(index));}
15
T&
operator[]
(
int
index){
return
GetAt
(index);}
16
const
T&
operator[]
(
int
index)
const
{
return
GetAt
(index);}
17
T*
GetData
(){
return
values
.data();}
18
const
T*
GetData
()
const
{
return
values
.data();}
19
HRESULT
Add
(
const
T& value){
try
{
values
.push_back(value);
return
S_OK;}
catch
(
const
std::bad_alloc&){
return
E_OUTOFMEMORY;}}
20
HRESULT
SetSize
(
int
count){
if
(count<0)
return
E_INVALIDARG;
try
{
values
.resize(
size_t
(count));
return
S_OK;}
catch
(
const
std::bad_alloc&){
return
E_OUTOFMEMORY;}}
21
HRESULT
SetAt
(
int
index,
const
T& value){
if
(index<0 || index>=
GetSize
())
return
E_INVALIDARG;
values
[size_t(index)]=value;
return
S_OK;}
22
HRESULT
Insert
(
int
index,
const
T& value){
if
(index<0 || index>
GetSize
())
return
E_INVALIDARG;
try
{
values
.insert(
values
.begin()+index,value);
return
S_OK;}
catch
(
const
std::bad_alloc&){
return
E_OUTOFMEMORY;}}
23
HRESULT
Remove
(
int
index){
if
(index<0 || index>=
GetSize
())
return
E_INVALIDARG;
values
.erase(
values
.begin()+index);
return
S_OK;}
24
void
RemoveAll
(){
values
.clear();}
25
bool
Contains
(
const
T& value)
const
{
return
IndexOf
(value)>=0;}
26
int
IndexOf
(
const
T& value)
const
{
const
auto
found=std::find(
values
.begin(),
values
.end(),value);
return
found==
values
.end() ? -1 :
int
(found-
values
.begin());}
27
private
:
28
std::vector<T>
values
;
29
};
int
SCRIPT_CONTROL SCRIPT_STATE const void int
Definition
Controls.cpp:5032
HRESULT
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
ControlArray
Definition
ControlArray.h:10
ControlArray::RemoveAll
void RemoveAll()
Definition
ControlArray.h:24
ControlArray::GetAt
T & GetAt(int index)
Definition
ControlArray.h:13
ControlArray::GetData
T * GetData()
Definition
ControlArray.h:17
ControlArray::Contains
bool Contains(const T &value) const
Definition
ControlArray.h:25
ControlArray::GetData
const T * GetData() const
Definition
ControlArray.h:18
ControlArray::SetAt
HRESULT SetAt(int index, const T &value)
Definition
ControlArray.h:21
ControlArray::GetSize
int GetSize() const
Definition
ControlArray.h:12
ControlArray::operator[]
const T & operator[](int index) const
Definition
ControlArray.h:16
ControlArray::GetAt
const T & GetAt(int index) const
Definition
ControlArray.h:14
ControlArray::operator[]
T & operator[](int index)
Definition
ControlArray.h:15
ControlArray::values
std::vector< T > values
Definition
ControlArray.h:28
ControlArray::SetSize
HRESULT SetSize(int count)
Definition
ControlArray.h:20
ControlArray::Add
HRESULT Add(const T &value)
Definition
ControlArray.h:19
ControlArray::Remove
HRESULT Remove(int index)
Definition
ControlArray.h:23
ControlArray::Insert
HRESULT Insert(int index, const T &value)
Definition
ControlArray.h:22
ControlArray::IndexOf
int IndexOf(const T &value) const
Definition
ControlArray.h:26
UI
ControlArray.h
Generated on
for Rise by
1.18.0