...
 
Commits (2)
......@@ -92,15 +92,13 @@ struct stGlobalPVars {
*/
uint32_t *scm_gVars = reinterpret_cast<uint32_t *>( 0x00A49960 );
/// Имя плагина
std::string pluginName;
std::string_view pluginName;
/// Путь до плагина
std::string pluginPath;
std::string_view pluginPath;
};
/// Название проекта, которое было указано при разворачивание проекта из шаблона
extern std::string PROJECT_NAME;
/// Тип проекта: dll/asi
extern std::string PROJECT_TYPE;
extern std::string_view PROJECT_NAME;
/// Содержит указатели на базовые хендлы
extern stGlobalHandles g_handle;
......
#include "ImWithText.h"
ImWithText::ImWithText( const std::string &str ) : text( str ) {}
ImWithText::ImWithText( std::string_view str ) : text( str ) {}
......@@ -2,11 +2,12 @@
#define IMWITHTEXT_H
#include <string>
#include <string_view>
class ImWithText
{
public:
ImWithText(const std::string &str);
ImWithText( std::string_view str );
virtual ~ImWithText(){}
std::string text;
......
#include "ImButton.h"
ImButton::ImButton( const std::string &str ) : ImWithText( str ) {}
ImButton::ImButton( std::string_view str ) : ImWithText( str ) {}
void ImButton::draw() {
if ( ImGui::Button( text.data(), size ) ) onClick();
......
......@@ -13,7 +13,7 @@ class ImButton : public ImBase,
public ImWithAllEvents,
public ImWithTooltip {
public:
ImButton( const std::string &str );
ImButton( std::string_view str );
SRSignal<> onClick;
......
#include "ImCheckBox.h"
ImCheckBox::ImCheckBox( const std::string &str, bool checked )
ImCheckBox::ImCheckBox( std::string_view str, bool checked )
: ImWithText( str ), checked( checked ), _checked( checked ) {}
ImCheckBox::ImCheckBox( const std::string &str, bool *pChecked )
ImCheckBox::ImCheckBox( std::string_view str, bool *pChecked )
: ImWithText( str ), _pChecked( pChecked ), checked( *pChecked ), _checked( *pChecked ) {}
void ImCheckBox::setPointer( bool *pChecked ) {
......
......@@ -11,8 +11,8 @@ class ImCheckBox : public ImBase, public ImWithText, public ImWithAllEvents, pub
bool _checked = false;
public:
ImCheckBox( const std::string &str, bool checked = false );
ImCheckBox( const std::string &str, bool *pChecked );
ImCheckBox( std::string_view str, bool checked = false );
ImCheckBox( std::string_view str, bool *pChecked );
virtual void setPointer( bool *pChecked );
......
#include "ImChield.h"
ImChield::ImChield( const char *id, const bool &border )
: _id( const_cast<char *>( id ) ), border( border ) {}
ImChield::ImChield( std::string_view id, const bool &border )
: _id( std::string( id ) + "\0" ), border( border ) {}
void ImChield::draw() {
ImGui::BeginChild( _id, size, border, flags );
ImGui::BeginChild( _id.data(), size, border, flags );
ImChieldsBase::draw();
ImGui::EndChild();
processEvent();
......
......@@ -7,10 +7,10 @@
#include "../components/ImWithAllEvents.h"
class ImChield : public ImChieldsBase, public ImWithSize, public ImWithWindowFlags, public ImWithAllEvents {
char *_id;
std::string _id;
public:
ImChield( const char *id, const bool &border = false );
ImChield( std::string_view id, const bool &border = false );
bool border;
......
#include "ImDragFloat.h"
ImDragFloat::ImDragFloat( const std::string &name, const float &v ) : name( name ), _value( v ) {}
ImDragFloat::ImDragFloat( std::string_view name, const float &v ) : _value( v ), name( name ) {}
ImDragFloat::ImDragFloat( const std::string &name, float *v ) : name( name ), _pValue( v ) {}
ImDragFloat::ImDragFloat( std::string_view name, float *v ) : _pValue( v ), name( name ) {}
void ImDragFloat::setPointer( float *pValue ) { _pValue = pValue; }
......
......@@ -10,8 +10,8 @@ class ImDragFloat : public ImBase, public ImWithAllEvents, public ImWithTooltip
float _value;
float *_pValue = nullptr;
public:
ImDragFloat(const std::string &name, const float &v = 0.0f);
ImDragFloat(const std::string &name, float *v);
ImDragFloat( std::string_view name, const float &v = 0.0f );
ImDragFloat( std::string_view name, float *v );
virtual void setPointer(float *pValue);
......
#include "ImInputFloat.h"
ImInputFloat::ImInputFloat( const std::string &name, const float &v ) : name( name ), _value( v ) {}
ImInputFloat::ImInputFloat( std::string_view name, const float &v ) : _value( v ), name( name ) {}
ImInputFloat::ImInputFloat( const std::string &name, float *v ) : name( name ), _pValue( v ) {}
ImInputFloat::ImInputFloat( std::string_view name, float *v ) : _pValue( v ), name( name ) {}
void ImInputFloat::setPointer( float *pValue ) {
_pValue = pValue;
......
......@@ -10,8 +10,8 @@ class ImInputFloat : public ImBase, public ImWithAllEvents, public ImWithTooltip
float _value;
float *_pValue = nullptr;
public:
ImInputFloat(const std::string &name, const float &v = 0);
ImInputFloat(const std::string &name, float *v);
ImInputFloat( std::string_view name, const float &v = 0 );
ImInputFloat( std::string_view name, float *v );
virtual void setPointer(float *pValue);
......
#include "ImInputInt.h"
ImInputInt::ImInputInt( const std::string &name, const int &v ) : name( name ), _value( v ) {}
ImInputInt::ImInputInt( std::string_view name, const int &v ) : _value( v ), name( name ) {}
ImInputInt::ImInputInt( const std::string &name, int *v ) : name( name ), _pValue( v ) {}
ImInputInt::ImInputInt( std::string_view name, int *v ) : _pValue( v ), name( name ) {}
void ImInputInt::setPointer( int *pValue ) {
_pValue = pValue;
......
......@@ -10,8 +10,8 @@ class ImInputInt : public ImBase, public ImWithAllEvents, public ImWithTooltip
int _value;
int *_pValue = nullptr;
public:
ImInputInt(const std::string &name, const int &v = 0);
ImInputInt(const std::string &name, int *v);
ImInputInt( std::string_view name, const int &v = 0 );
ImInputInt( std::string_view name, int *v );
virtual void setPointer(int *pValue);
......
#include "ImInputText.h"
ImInputText::ImInputText( const std::string &name, const std::string &text, size_t limit )
: name( name ), _limit( limit ) {
if ( text.capacity() > _limit ) _limit = text.capacity() + 1;
ImInputText::ImInputText( std::string_view name, std::string_view text, size_t limit )
: _limit( limit ), name( name ) {
if ( text.length() > _limit ) _limit = text.length() + 1;
_buffer = new char[_limit];
strcpy( _buffer, text.c_str() );
strncpy( _buffer, text.data(), text.length() );
}
ImInputText::~ImInputText() { delete[] _buffer; }
......@@ -17,11 +17,13 @@ void ImInputText::resize( size_t size ) {
_buffer = _new;
}
std::string ImInputText::text() { return _buffer; }
std::string_view ImInputText::text() {
return _buffer;
}
void ImInputText::setText( const std::string &text ) {
if ( text.capacity() > _limit ) resize( text.capacity() + 1 );
strcpy( _buffer, text.data() );
void ImInputText::setText( std::string_view text ) {
if ( text.length() > _limit ) resize( text.length() + 1 );
strncpy( _buffer, text.data(), text.length() );
onTextChanged( _buffer );
}
......
......@@ -10,18 +10,18 @@ class ImInputText : public ImBase, public ImWithAllEvents, public ImWithTooltip
size_t _limit = 0;
char *_buffer;
public:
ImInputText(const std::string &name, const std::string &text = "", size_t limit = 1024);
ImInputText( std::string_view name, std::string_view text = "", size_t limit = 1024 );
virtual ~ImInputText();
virtual void resize(size_t size);
virtual std::string text();
virtual void setText(const std::string &text);
virtual std::string_view text();
virtual void setText( std::string_view text );
std::string name;
ImGuiInputTextFlags flags = 0;
SRSignal<std::string> onTextEdited;
SRSignal<std::string> onTextChanged;
SRSignal<std::string_view> onTextEdited;
SRSignal<std::string_view> onTextChanged;
SRSignal<> onReturnPressed;
protected:
......
#include "ImMenu.h"
#include "../../../base.hpp"
ImMenu::ImMenu( const std::string &str ) : ImWithText( str ) {
ImMenu::ImMenu( std::string_view str ) : ImWithText( str ) {
_ImGuiDraw = g_class.DirectX->onImGuiDraw.connect( this, &ImMenu::draw );
}
......
......@@ -21,7 +21,7 @@ class ImMenu : public ImChieldsBase, public ImWithText, public ImWithWindowFlags
std::atomic_bool _focusUsed = true;
bool _show = false;
public:
ImMenu(const std::string &str);
ImMenu( std::string_view str );
virtual ~ImMenu();
virtual void setSize(const ImVec2 &size);
......
#include "ImText.h"
ImText::ImText( const std::string &str ) : ImWithText( str ) {}
ImText::ImText( std::string_view str ) : ImWithText( str ) {}
void ImText::draw() {
ImGui::Text( "%s", text.data() );
......
......@@ -8,7 +8,7 @@
class ImText : public ImBase, public ImWithText, public ImWithAllEvents, public ImWithTooltip {
public:
ImText( const std::string &str );
ImText( std::string_view str );
protected:
void draw() override;
......
......@@ -3,9 +3,9 @@
#include "ImSameLine.h"
#include "../../../sys/SRString.hpp"
ImTextColored::ImTextColored( const std::string &str, const SRColor &clr ) : ImText( str ), color( clr ) {}
ImTextColored::ImTextColored( std::string_view str, const SRColor &clr ) : ImText( str ), color( clr ) {}
std::deque<ImBase *> ImTextColored::fromFormatedString( std::string str, SRColor clr ) {
std::deque<ImBase *> ImTextColored::fromFormatedString( const std::string &str, SRColor clr ) {
std::deque<ImBase *> result;
auto space = ImGui::CalcTextSize( " " ).x;
auto lines = SRString::split( str, '\n' );
......
......@@ -7,11 +7,11 @@
class ImTextColored : public ImText
{
public:
ImTextColored( const std::string &str, const SRColor &clr = eCdOrange );
ImTextColored( std::string_view str, const SRColor &clr = eCdOrange );
SRColor color;
static std::deque<ImBase *> fromFormatedString( std::string str, SRColor clr = eCdOrange );
static std::deque<ImBase *> fromFormatedString( const std::string &str, SRColor clr = eCdOrange );
protected:
void draw() override;
......
......@@ -141,7 +141,7 @@ DWORD hex_to_uint( const char *hexstr )
return out;
}
bool HexIsValid( const std::string_view &hex ) {
bool HexIsValid( std::string_view hex ) {
if ( hex.empty() )
return false;
for ( size_t i = 0; i < hex.length(); i++ )
......@@ -152,7 +152,7 @@ bool HexIsValid( const std::string_view &hex ) {
return true;
}
bool hex_is_valid( const std::string_view &hex ) {
bool hex_is_valid( std::string_view hex ) {
return HexIsValid(hex);
}
......@@ -561,7 +561,7 @@ bool CD3DFont::setActiveFont(eFontType type)
}
stColorTag GetColorTag( const std::string_view &text, size_t maxLen ) {
stColorTag GetColorTag( std::string_view text, size_t maxLen ) {
stColorTag color = { 0, false, false };
const int minLen = 8; // { + XXXXXX + } = 8
......@@ -589,7 +589,7 @@ stColorTag GetColorTag( const std::string_view &text, size_t maxLen ) {
return color;
}
bool isChangeType( const std::string_view &text, eFontType &type ) {
bool isChangeType( std::string_view text, eFontType &type ) {
const int minLen = 3; // { + X + } = 3
if (text[0] != '{' || text.length() < minLen)
......@@ -616,7 +616,7 @@ bool isChangeType( const std::string_view &text, eFontType &type ) {
return false;
}
HRESULT CD3DFont::Print( float x, float y, SRColor color, const std::string_view &text, bool noFormat ) {
HRESULT CD3DFont::Print( float x, float y, SRColor color, std::string_view text, bool noFormat ) {
if ( !m_isReady || text.empty() ) {
m_type = m_defaultType;
return E_FAIL;
......@@ -746,7 +746,7 @@ HRESULT CD3DFont::Print( float x, float y, SRColor color, const std::string_view
return S_OK;
}
HRESULT CD3DFont::PrintShadow( float x, float y, SRColor color, const std::string_view &text, bool noFormat ) {
HRESULT CD3DFont::PrintShadow( float x, float y, SRColor color, std::string_view text, bool noFormat ) {
m_isShadow = true;
if (color.red >= 0x80 && color.green >= 0x80 && color.blue >= 0x80)
Print(x + 1, y + 1, SRColor(eCdBlack, color.alpha), text, noFormat);
......@@ -755,7 +755,7 @@ HRESULT CD3DFont::PrintShadow( float x, float y, SRColor color, const std::strin
return Print(x, y, color, text, noFormat);
}
float CD3DFont::DrawLength( const std::string_view &text, bool noFormat ) {
float CD3DFont::DrawLength( std::string_view text, bool noFormat ) {
if ( !setActiveFont( m_type ) ){
m_font = m_font_R;
m_type = m_defaultType = eFt_regular;
......@@ -789,7 +789,7 @@ float CD3DFont::DrawLength( const std::string_view &text, bool noFormat ) {
return len;
}
size_t CD3DFont::GetCharPos( const std::string_view &text, float x, bool noFormat ) {
size_t CD3DFont::GetCharPos( std::string_view text, float x, bool noFormat ) {
if ( !setActiveFont( m_type ) ){
m_font = m_font_R;
m_type = m_defaultType = eFt_regular;
......
......@@ -142,8 +142,8 @@ struct stFontInfo {
enum eFontType { eFt_regular, eFt_bold, eFt_italic, eFt_under, eFt_strike };
stColorTag GetColorTag( const std::string_view &text, size_t maxLen );
bool isChangeType( const std::string_view &text, eFontType &type );
stColorTag GetColorTag( std::string_view text, size_t maxLen );
bool isChangeType( std::string_view text, eFontType &type );
class CD3DFont : public CD3DBaseRender {
friend class hookIDirect3DDevice9;
......@@ -154,12 +154,11 @@ public:
CD3DFont( const char *szFontName, int fontHeight, bool isBorder, eFontType defaultType = eFt_regular );
~CD3DFont();
HRESULT Print( float x, float y, SRColor color, const std::string_view &text, bool noFormat = false );
HRESULT PrintShadow( float x, float y, SRColor color, const std::string_view &text,
bool noFormat = false );
HRESULT Print( float x, float y, SRColor color, std::string_view text, bool noFormat = false );
HRESULT PrintShadow( float x, float y, SRColor color, std::string_view text, bool noFormat = false );
float DrawLength( const std::string_view &text, bool noFormat = false );
size_t GetCharPos( const std::string_view &text, float x, bool noFormat = false );
float DrawLength( std::string_view text, bool noFormat = false );
size_t GetCharPos( std::string_view text, float x, bool noFormat = false );
float DrawHeight();
bool setType( eFontType type );
......
......@@ -15,7 +15,6 @@ SRNotifications::SRNotifications( SRDescent *parent, CD3DFont *font ) : SRDescen
} else
_fontIsCreated = false;
// g_class.DirectX->connect(this, &SRNotifications::Present, proxyIDirect3DDevice9_Present);
_present = g_class.DirectX->onDraw.connect( this, &SRNotifications::Present );
}
......@@ -25,10 +24,11 @@ SRNotifications::~SRNotifications() {
if ( _fontIsCreated ) g_class.DirectX->releaseFont( _font );
}
void SRNotifications::addText( std::string text, int additionalTime ) {
void SRNotifications::addText( std::string_view text, int additionalTime ) {
if ( _queue.size() == _limit ) _queue.pop_front();
_queue.push_back( {text, GetTickCount() + additionalTime + _reactionTime + _readTime * text.length()} );
_queue.push_back(
{std::string( text ), GetTickCount() + additionalTime + _reactionTime + _readTime * text.length()} );
}
void SRNotifications::setPosition( POINT pos ) { _pos = pos; }
......
......@@ -24,7 +24,7 @@ public:
* @param text Текст который будет выведен
* @param additionalTime Дополнительное время показа в миллисекундах
*/
virtual void addText( std::string text, int additionalTime = 0 );
virtual void addText( std::string_view text, int additionalTime = 0 );
/**
* @brief Устанавливает позицию для вывода уведомлений
......
......@@ -236,12 +236,12 @@ bool SRTexture::Clear() {
return true;
}
HRESULT SRTexture::Save( std::string fileName ) {
HRESULT SRTexture::Save( std::string_view fileName ) {
if ( isReleased ) {
return E_FAIL;
}
return D3DXSaveTextureToFileA( fileName.c_str(), D3DXIFF_JPG, pTexture, NULL );
return D3DXSaveTextureToFileA( fileName.data(), D3DXIFF_JPG, pTexture, NULL );
}
HRESULT SRTexture::Save( ID3DXBuffer *buffer ) {
......
......@@ -52,7 +52,7 @@ public:
* \param fileName название файла
* \return HRESULT
*/
virtual HRESULT Save( std::string fileName );
virtual HRESULT Save( std::string_view fileName );
/**
* \brief Сохранение текстуры в память
* \param buffer буффер для текстуры в памяти
......