Commit 07e3e353 authored by D-AIRY's avatar D-AIRY

Crosshair fixed; settings updated

parent eb49d0b1
......@@ -30,6 +30,6 @@ r_pssm_shadowed 1
r_shadow_soft 1
pssm_4or3 0
exec ../config_game_user_auto.cfg
exec user_settings.cfg
spawn
\ No newline at end of file
......@@ -3,7 +3,7 @@
gui_main.ps
*/
#include <../struct.h>
#include "../struct.h"
//##########################################################################
......@@ -12,14 +12,13 @@ Texture2D g_txDiffuse : register(t0); // basetexture
//##########################################################################
half4 g_vColor: register(b0);
float4 g_vColor: register(b0);
//##########################################################################
half4 main(VSO_GUITextured IN):COLOR0
float4 main(VSO_GUITextured IN):COLOR0
{
// half4 vFinalColor = tex2D(g_sDiffuse, IN.vTexUV);
half4 vFinalColor = g_txDiffuse.Sample(g_sDiffuse, IN.vTexUV);
float4 vFinalColor = g_txDiffuse.Sample(g_sDiffuse, IN.vTexUV);
vFinalColor *= g_vColor;
return(vFinalColor);
......
......@@ -4,15 +4,16 @@ pp_quad_render.ps
Отрисовка полноэкранного квадрата (full screen quad)
*/
#include <../struct.h>
#include "../struct.h"
//##########################################################################
sampler2D g_sTexture:register(s0);
SamplerState g_sDiffuse: register(s0);
Texture2D g_txDiffuse : register(t0); // basetexture
//##########################################################################
half4 main(VSO_PP IN):COLOR0
float4 main(VSO_PP IN):COLOR0
{
return tex2D(g_sTexture,IN.vTexUV);
}
\ No newline at end of file
return(g_txDiffuse.Sample(g_sDiffuse, IN.vTexUV));
}
......@@ -14,4 +14,4 @@ VSO_PP main(VSI_PP IN)
OUT.vPosition = float4(IN.vPosition, 1.0);
OUT.vTexUV = IN.vTexUV;
return OUT;
}
\ No newline at end of file
}
......@@ -352,21 +352,22 @@ void echo(int argc, const char ** argv)
printf("\n");
}
void exec(int argc, const char ** argv)
void exec(int argc, const char **argv)
{
if(argc != 2)
{
puts(COLOR_LRED "[exec]: Expected filename" COLOR_RESET);
return;
}
IFile * f = Core_CrFile();
if(f->open(argv[1], CORE_FILE_BIN) < 0)
IFile *f = Core_GetIXCore()->getFileSystem()->openFile(argv[1]);
if(!f)
{
printf(COLOR_LRED "Couldn't exec '%s'\n" COLOR_RESET, argv[1]);
return;
}
size_t len = f->getSize() + 1;
char * buf, *cbuf = NULL;
char *buf, *cbuf = NULL;
if(len <= 4096)
{
buf = (char*)alloca(sizeof(char) * len);
......@@ -381,7 +382,7 @@ void exec(int argc, const char ** argv)
ConsolePushBuffer();
Core_0ConsoleExecCmd("%s", buf);
f->Release();
mem_release(f);
mem_delete_a(cbuf);
}
......
......@@ -807,8 +807,10 @@ GameData::GameData(HWND hWnd, bool isGame):
m_pGUI->registerCallback("settings_commit", [](gui::IEvent * ev){
CSettingsWriter settingsWriter;
settingsWriter.loadFile("../config_game_user_auto.cfg");
bool isNewExists = Core_GetIXCore()->getFileSystem()->fileExists("user_settings.cfg");
CSettingsWriter settingsWriter(Core_GetIXCore()->getFileSystem());
settingsWriter.loadFile(isNewExists ? "user_settings.cfg" : "../config_game_user_auto.cfg");
gui::IDesktop * pSettingsDesktop = GameData::m_pGUI->getActiveDesktop();
gui::dom::IDOMdocument * doc = pSettingsDesktop->getDocument();
......@@ -842,15 +844,17 @@ GameData::GameData(HWND hWnd, bool isGame):
}
}
settingsWriter.saveFile("../config_game_user_auto.cfg");
settingsWriter.saveFile("user_settings.cfg");
GameData::m_pGUI->popDesktop();
});
m_pGUI->registerCallback("controls_commit", [](gui::IEvent * ev){
CSettingsWriter settingsWriter;
settingsWriter.loadFile("../config_game_user_auto.cfg");
bool isNewExists = Core_GetIXCore()->getFileSystem()->fileExists("user_settings.cfg");
CSettingsWriter settingsWriter(Core_GetIXCore()->getFileSystem());
settingsWriter.loadFile(isNewExists ? "user_settings.cfg" : "../config_game_user_auto.cfg");
gui::IDesktop * pSettingsDesktop = GameData::m_pGUI->getActiveDesktop();
gui::dom::IDOMdocument * doc = pSettingsDesktop->getDocument();
auto pItems = doc->getElementsByClass(L"cctable_row");
......@@ -894,7 +898,7 @@ GameData::GameData(HWND hWnd, bool isGame):
}
settingsWriter.saveFile("../config_game_user_auto.cfg");
settingsWriter.saveFile("config_game_user_auto.cfg");
GameData::m_pGUI->popDesktop();
});
......
......@@ -2,10 +2,16 @@
#include "SettingsWriter.h"
#include <core/sxcore.h>
CSettingsWriter::CSettingsWriter(IFileSystem *pFileSystem):
m_pFileSystem(pFileSystem)
{
assert(pFileSystem);
}
void CSettingsWriter::loadFile(const char *szFile)
{
IFile * f = Core_CrFile();
if(f->open(szFile, CORE_FILE_BIN) < 0)
IFile *f = m_pFileSystem->openFile(szFile);
if(!f)
{
printf(COLOR_LRED "Couldn't exec '%s'\n" COLOR_RESET, szFile);
return;
......@@ -67,7 +73,7 @@ void CSettingsWriter::loadFile(const char *szFile)
}
}
f->Release();
mem_release(f);
mem_delete_a(cbuf);
}
......@@ -89,8 +95,8 @@ void CSettingsWriter::unBind(const char *szKey)
void CSettingsWriter::saveFile(const char *szFile)
{
IFile * f = Core_CrFile();
if(f->create(szFile, CORE_FILE_BIN) < 0)
IFile *f = m_pFileSystem->openFile(szFile, FILE_MODE_WRITE);
if(!f)
{
printf(COLOR_LRED "Couldn't save file '%s'\n" COLOR_RESET, szFile);
return;
......@@ -113,5 +119,5 @@ void CSettingsWriter::saveFile(const char *szFile)
}
}
f->Release();
mem_release(f);
}
......@@ -4,10 +4,13 @@
#include <gdefines.h>
#include <common/assotiativearray.h>
#include <common/string.h>
#include <xcommon/IFileSystem.h>
class CSettingsWriter
{
public:
CSettingsWriter(IFileSystem *pFileSystem);
void loadFile(const char *szName);
void saveFile(const char *szFile);
......@@ -16,7 +19,7 @@ public:
void unBind(const char *szKey);
protected:
IFileSystem *m_pFileSystem;
AssotiativeArray<String, String> m_mCvarList;
AssotiativeArray<String, String> m_mBindList;
};
......
......@@ -54,8 +54,10 @@ CCrosshair::CCrosshair():
m_idShaderKit = SGCore_ShaderCreateKit(m_idVS, m_idPS);
GXBlendDesc blendDesc;
blendDesc.renderTarget[0].blendSrcColor = blendDesc.renderTarget[0].blendSrcAlpha = GXBLEND_SRC_ALPHA;
blendDesc.renderTarget[0].blendDestColor = blendDesc.renderTarget[0].blendDestAlpha = GXBLEND_INV_SRC_ALPHA;
//blendDesc.renderTarget[0].blendSrcColor = blendDesc.renderTarget[0].blendSrcAlpha = GXBLEND_SRC_ALPHA;
//blendDesc.renderTarget[0].blendDestColor = blendDesc.renderTarget[0].blendDestAlpha = GXBLEND_INV_SRC_ALPHA;
blendDesc.renderTarget[0].blendSrcColor = blendDesc.renderTarget[0].blendSrcAlpha = GXBLEND_ONE;
blendDesc.renderTarget[0].blendDestColor = blendDesc.renderTarget[0].blendDestAlpha = GXBLEND_ONE;
blendDesc.renderTarget[0].useBlend = TRUE;
m_pBlendState = m_pDev->createBlendState(&blendDesc);
......@@ -63,10 +65,15 @@ CCrosshair::CCrosshair():
dsDesc.useDepthTest = FALSE;
dsDesc.useDepthWrite = FALSE;
m_pDepthState = m_pDev->createDepthStencilState(&dsDesc);
GXSamplerDesc sampDesc;
sampDesc.filter = GXFILTER_MIN_MAG_MIP_LINEAR;
m_pSamplerState = m_pDev->createSamplerState(&sampDesc);
}
CCrosshair::~CCrosshair()
{
mem_release(m_pSamplerState);
mem_release(m_pBlendState);
mem_release(m_pVertexBuffer);
mem_release(m_pIndexBuffer);
......@@ -167,7 +174,7 @@ void CCrosshair::update()
pIndices[iCurIdx++] = iCurVtx - 1;
pVertices[iCurVtx++] = {
float3_t(fXradius * sinf(angle) + fOX, fYradius * -cosf(angle) + fOY, 0.0f),
float2_t(lerpf(f2TexMin.x, f2TexMax.x, sinf(angle) * 0.5f + 0.5f), -lerpf(f2TexMax.y, f2TexMin.y, -cosf(angle) * 0.5f + 0.5f))
float2_t(lerpf(f2TexMin.x, f2TexMax.x, sinf(angle) * 0.5f + 0.5f), 1.0f - lerpf(f2TexMax.y, f2TexMin.y, -cosf(angle) * 0.5f + 0.5f))
}; // circle
}
......@@ -178,7 +185,7 @@ void CCrosshair::update()
iStopIdx = iCurVtx;
pVertices[iCurVtx++] = {
float3_t(fOX, fOY, 0.0f),
float2_t(lerpf(f2TexMin.x, f2TexMax.x, 0.5f), -lerpf(f2TexMax.y, f2TexMin.y, 0.5f))
float2_t(lerpf(f2TexMin.x, f2TexMax.x, 0.5f), 1.0f - lerpf(f2TexMax.y, f2TexMin.y, 0.5f))
}; // center
}
else
......@@ -189,7 +196,7 @@ void CCrosshair::update()
}
pVertices[iCurVtx++] = {
float3_t(fXradius * sinf(angle) + fOX, fYradius * -cosf(angle) + fOY, 0.0f),
float2_t(lerpf(f2TexMin.x, f2TexMax.x, sinf(angle) * 0.5f + 0.5f), -lerpf(f2TexMax.y, f2TexMin.y, -cosf(angle) * 0.5f + 0.5f))
float2_t(lerpf(f2TexMin.x, f2TexMax.x, sinf(angle) * 0.5f + 0.5f), 1.0f - lerpf(f2TexMax.y, f2TexMin.y, -cosf(angle) * 0.5f + 0.5f))
}; // circle
//a=0 x=0 y=-1
}
......@@ -218,11 +225,11 @@ void CCrosshair::update()
pVertices[iCurVtx++] = {
float3_t(fXFixedRadius * sinf(angle) + fOX, fYFixedRadius * -cosf(angle) + fOY, 0.0f),
float2_t(lerpf(f2TexMin.x, f2TexMax.x, (fTexFRX * sinf(angle) * 0.5f + 0.5f)), -lerpf(f2TexMax.y, f2TexMin.y, (fTexFRY * -cosf(angle) * 0.5f + 0.5f)))
float2_t(lerpf(f2TexMin.x, f2TexMax.x, (fTexFRX * sinf(angle) * 0.5f + 0.5f)), 1.0f - lerpf(f2TexMax.y, f2TexMin.y, (fTexFRY * -cosf(angle) * 0.5f + 0.5f)))
}; // circle inner
pVertices[iCurVtx++] = {
float3_t(fXradius * sinf(angle) + fOX, fYradius * -cosf(angle) + fOY, 0.0f),
float2_t(lerpf(f2TexMin.x, f2TexMax.x, sinf(angle) * 0.5f + 0.5f), -lerpf(f2TexMax.y, f2TexMin.y, -cosf(angle) * 0.5f + 0.5f))
float2_t(lerpf(f2TexMin.x, f2TexMax.x, sinf(angle) * 0.5f + 0.5f), 1.0f - lerpf(f2TexMax.y, f2TexMin.y, -cosf(angle) * 0.5f + 0.5f))
}; // circle
}
......@@ -248,11 +255,11 @@ void CCrosshair::update()
}
pVertices[iCurVtx++] = {
float3_t(fXFixedRadius * sinf(angle) + fOX, fYFixedRadius * -cosf(angle) + fOY, 0.0f),
float2_t(lerpf(f2TexMin.x, f2TexMax.x, (fTexFRX * sinf(angle) * 0.5f + 0.5f)), -lerpf(f2TexMax.y, f2TexMin.y, (fTexFRY * -cosf(angle) * 0.5f + 0.5f)))
float2_t(lerpf(f2TexMin.x, f2TexMax.x, (fTexFRX * sinf(angle) * 0.5f + 0.5f)), 1.0f - lerpf(f2TexMax.y, f2TexMin.y, (fTexFRY * -cosf(angle) * 0.5f + 0.5f)))
}; // circle inner
pVertices[iCurVtx++] = {
float3_t(fXradius * sinf(angle) + fOX, fYradius * -cosf(angle) + fOY, 0.0f),
float2_t(lerpf(f2TexMin.x, f2TexMax.x, sinf(angle) * 0.5f + 0.5f), -lerpf(f2TexMax.y, f2TexMin.y, -cosf(angle) * 0.5f + 0.5f))
float2_t(lerpf(f2TexMin.x, f2TexMax.x, sinf(angle) * 0.5f + 0.5f), 1.0f-lerpf(f2TexMax.y, f2TexMin.y, -cosf(angle) * 0.5f + 0.5f))
}; // circle
//a=0 x=0 y=-1
}
......@@ -271,7 +278,7 @@ void CCrosshair::update()
}
pVertices[iCurVtx++] = {
float3_t(fXFixedRadius * sinf(angle), fYFixedRadius * -cosf(angle), 0.0f),
float2_t(lerpf(f2TexMin.x, f2TexMax.x, (fTexFRX * sinf(angle) * 0.5f + 0.5f)), -lerpf(f2TexMax.y, f2TexMin.y, (fTexFRY * -cosf(angle) * 0.5f + 0.5f)))
float2_t(lerpf(f2TexMin.x, f2TexMax.x, (fTexFRX * sinf(angle) * 0.5f + 0.5f)), 1.0f - lerpf(f2TexMax.y, f2TexMin.y, (fTexFRY * -cosf(angle) * 0.5f + 0.5f)))
}; // circle inner
}
}
......@@ -297,7 +304,7 @@ void CCrosshair::update()
}
pVertices[iCurVtx++] = {
float3_t((fXradius + fXoffset) * sinf(angle), (fYradius + fYoffset) * -cosf(angle), 0.0f),
float2_t(lerpf(f2TexMin.x, f2TexMax.x, sinf(angle) * 0.5f + 0.5f), -lerpf(f2TexMax.y, f2TexMin.y, -cosf(angle) * 0.5f + 0.5f))
float2_t(lerpf(f2TexMin.x, f2TexMax.x, sinf(angle) * 0.5f + 0.5f), 1.0f - lerpf(f2TexMax.y, f2TexMin.y, -cosf(angle) * 0.5f + 0.5f))
}; // circle
}
......@@ -325,11 +332,11 @@ void CCrosshair::update()
pVertices[iCurVtx++] = {
float3_t(fXFixedRadius * sinf(angle) + fOX, fYFixedRadius * -cosf(angle) + fOY, 0.0f),
float2_t(lerpf(f2TexMin.x, f2TexMax.x, (fTexFRX * sinf(angle) * 0.5f + 0.5f)), -lerpf(f2TexMax.y, f2TexMin.y, (fTexFRY * -cosf(angle) * 0.5f + 0.5f)))
float2_t(lerpf(f2TexMin.x, f2TexMax.x, (fTexFRX * sinf(angle) * 0.5f + 0.5f)), 1.0f - lerpf(f2TexMax.y, f2TexMin.y, (fTexFRY * -cosf(angle) * 0.5f + 0.5f)))
}; // circle inner
pVertices[iCurVtx++] = {
float3_t((fXradius + fXoffset) * sinf(angle), (fYradius + fYoffset) * -cosf(angle), 0.0f),
float2_t(lerpf(f2TexMin.x, f2TexMax.x, sinf(angle) * 0.5f + 0.5f), -lerpf(f2TexMax.y, f2TexMin.y, -cosf(angle) * 0.5f + 0.5f))
float2_t(lerpf(f2TexMin.x, f2TexMax.x, sinf(angle) * 0.5f + 0.5f), 1.0f - lerpf(f2TexMax.y, f2TexMin.y, -cosf(angle) * 0.5f + 0.5f))
}; // circle
}
......@@ -347,7 +354,7 @@ void CCrosshair::update()
}
pVertices[iCurVtx++] = {
float3_t(fXFixedRadius * sinf(angle), fYFixedRadius * -cosf(angle), 0.0f),
float2_t(lerpf(f2TexMin.x, f2TexMax.x, (fTexFRX * sinf(angle) * 0.5f + 0.5f)), -lerpf(f2TexMax.y, f2TexMin.y, (fTexFRY * -cosf(angle) * 0.5f + 0.5f)))
float2_t(lerpf(f2TexMin.x, f2TexMax.x, (fTexFRX * sinf(angle) * 0.5f + 0.5f)), 1.0f - lerpf(f2TexMax.y, f2TexMin.y, (fTexFRY * -cosf(angle) * 0.5f + 0.5f)))
}; // circle inner
}
}
......@@ -382,6 +389,7 @@ void CCrosshair::render()
}
SGCore_ShaderBind(m_idShaderKit);
m_pDev->setBlendState(m_pBlendState);
m_pDev->setSamplerState(m_pSamplerState, 0);
m_pDev->setIndexBuffer(m_pIndexBuffer);
m_pDev->setRenderBuffer(m_pRenderBuffer);
m_pDev->setTexture(m_pTexture);
......
/***********************************************************
Copyright Vitaliy Buturlin, Evgeny Danilovich, 2017, 2018
Copyright © Vitaliy Buturlin, Evgeny Danilovich, 2017, 2018
See the license in LICENSE
***********************************************************/
......@@ -88,6 +88,7 @@ protected:
ID m_idShaderKit = -1;
IGXBlendState *m_pBlendState = NULL;
IGXSamplerState *m_pSamplerState = NULL;
IGXDepthStencilState *m_pDepthState = NULL;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment