Added FilterMode, MipmapLevel and Anisotropy to settings screen

master
krzys-h 2015-07-20 13:56:45 +02:00
parent a879e496f5
commit 90756f8b34
22 changed files with 408 additions and 85 deletions

View File

@ -213,6 +213,7 @@ set(BASE_SOURCES
ui/displaytext.cpp ui/displaytext.cpp
ui/edit.cpp ui/edit.cpp
ui/editvalue.cpp ui/editvalue.cpp
ui/enumslider.cpp
ui/gauge.cpp ui/gauge.cpp
ui/group.cpp ui/group.cpp
ui/image.cpp ui/image.cpp

View File

@ -243,6 +243,10 @@ enum EventType
EVENT_INTERFACE_AUTOSAVE_ENABLE = 780, EVENT_INTERFACE_AUTOSAVE_ENABLE = 780,
EVENT_INTERFACE_AUTOSAVE_INTERVAL = 781, EVENT_INTERFACE_AUTOSAVE_INTERVAL = 781,
EVENT_INTERFACE_AUTOSAVE_SLOTS = 782, EVENT_INTERFACE_AUTOSAVE_SLOTS = 782,
// new
EVENT_INTERFACE_TEXTURE_FILTER = 783,
EVENT_INTERFACE_TEXTURE_MIPMAP = 784,
EVENT_INTERFACE_TEXTURE_ANISOTROPY = 785,
EVENT_INTERFACE_KINFO1 = 500, EVENT_INTERFACE_KINFO1 = 500,
EVENT_INTERFACE_KINFO2 = 501, EVENT_INTERFACE_KINFO2 = 501,

View File

@ -213,6 +213,9 @@ void InitializeRestext()
stringsEvent[EVENT_INTERFACE_AUTOSAVE_ENABLE] = TR("Autosave\\Enables autosave"); stringsEvent[EVENT_INTERFACE_AUTOSAVE_ENABLE] = TR("Autosave\\Enables autosave");
stringsEvent[EVENT_INTERFACE_AUTOSAVE_INTERVAL] = TR("Autosave interval\\How often your game will autosave"); stringsEvent[EVENT_INTERFACE_AUTOSAVE_INTERVAL] = TR("Autosave interval\\How often your game will autosave");
stringsEvent[EVENT_INTERFACE_AUTOSAVE_SLOTS] = TR("Autosave slots\\How many autosave slots you'll have"); stringsEvent[EVENT_INTERFACE_AUTOSAVE_SLOTS] = TR("Autosave slots\\How many autosave slots you'll have");
stringsEvent[EVENT_INTERFACE_TEXTURE_FILTER] = TR("Texture filtering\\Texture filtering");
stringsEvent[EVENT_INTERFACE_TEXTURE_MIPMAP] = TR("Mipmap level\\Mipmap level");
stringsEvent[EVENT_INTERFACE_TEXTURE_ANISOTROPY]= TR("Anisotropy level\\Anisotropy level");
stringsEvent[EVENT_INTERFACE_KDEF] = TR("Standard controls\\Standard key functions"); stringsEvent[EVENT_INTERFACE_KDEF] = TR("Standard controls\\Standard key functions");
assert(INPUT_SLOT_MAX < EVENT_INTERFACE_KEY_END-EVENT_INTERFACE_KEY); assert(INPUT_SLOT_MAX < EVENT_INTERFACE_KEY_END-EVENT_INTERFACE_KEY);

View File

@ -435,8 +435,13 @@ public:
//! Deletes framebuffer //! Deletes framebuffer
virtual void DeleteFramebuffer(std::string name) = 0; virtual void DeleteFramebuffer(std::string name) = 0;
//! Checks if anisotropy is supported
virtual bool IsAnisotropySupported() = 0;
//! Returns max anisotropy level supported
virtual int GetMaxAnisotropyLevel() = 0;
}; };
} // namespace Gfx } // namespace Gfx

View File

@ -382,6 +382,14 @@ void CNullDevice::DeleteFramebuffer(std::string name)
{ {
} }
bool CNullDevice::IsAnisotropySupported()
{
return false;
}
int CNullDevice::GetMaxAnisotropyLevel()
{
return 1;
}
} // namespace Gfx } // namespace Gfx

View File

@ -152,6 +152,9 @@ public:
virtual void DeleteFramebuffer(std::string name); virtual void DeleteFramebuffer(std::string name);
virtual bool IsAnisotropySupported();
virtual int GetMaxAnisotropyLevel();
private: private:
Math::Matrix m_matrix; Math::Matrix m_matrix;
Material m_material; Material m_material;
@ -160,4 +163,3 @@ private:
} // namespace Gfx } // namespace Gfx

View File

@ -169,17 +169,7 @@ CEngine::CEngine(CApplication *app)
m_lastFrameTime = GetSystemUtils()->CreateTimeStamp(); m_lastFrameTime = GetSystemUtils()->CreateTimeStamp();
m_currentFrameTime = GetSystemUtils()->CreateTimeStamp(); m_currentFrameTime = GetSystemUtils()->CreateTimeStamp();
TexFilter filter = TEX_FILTER_BILINEAR;
bool mipmaps = false;
int value; int value;
if (GetConfigFile().GetIntProperty("Setup", "FilterMode", value))
{
if (value == 1) filter = TEX_FILTER_NEAREST;
else if (value == 2) filter = TEX_FILTER_BILINEAR;
else if (value == 3) filter = TEX_FILTER_TRILINEAR, mipmaps = true;
}
if (GetConfigFile().GetIntProperty("Setup", "ShadowMapping", value)) if (GetConfigFile().GetIntProperty("Setup", "ShadowMapping", value))
{ {
m_shadowMapping = (value > 0); m_shadowMapping = (value > 0);
@ -190,12 +180,10 @@ CEngine::CEngine(CApplication *app)
m_shadowColor = 0.5f; m_shadowColor = 0.5f;
m_defaultTexParams.format = TEX_IMG_AUTO; m_defaultTexParams.format = TEX_IMG_AUTO;
m_defaultTexParams.mipmap = mipmaps; m_defaultTexParams.filter = TEX_FILTER_BILINEAR;
m_defaultTexParams.filter = filter;
m_terrainTexParams.format = TEX_IMG_AUTO; m_terrainTexParams.format = TEX_IMG_AUTO;
m_terrainTexParams.mipmap = mipmaps; m_terrainTexParams.filter = TEX_FILTER_BILINEAR;
m_terrainTexParams.filter = filter;
// Compute bias matrix for shadow mapping // Compute bias matrix for shadow mapping
Math::Matrix temp1, temp2; Math::Matrix temp1, temp2;
@ -2838,8 +2826,14 @@ float CEngine::GetGadgetQuantity()
void CEngine::SetTextureFilterMode(TexFilter value) void CEngine::SetTextureFilterMode(TexFilter value)
{ {
m_defaultTexParams.filter = value; bool changed = m_defaultTexParams.filter != value || m_terrainTexParams.filter != value;
m_terrainTexParams.filter = value; m_defaultTexParams.filter = m_terrainTexParams.filter = value;
m_defaultTexParams.mipmap = m_terrainTexParams.mipmap = (value == TEX_FILTER_TRILINEAR);
if(changed)
{
FlushTextureCache();
LoadAllTextures();
}
} }
TexFilter CEngine::GetTextureFilterMode() TexFilter CEngine::GetTextureFilterMode()
@ -2852,7 +2846,13 @@ void CEngine::SetTextureMipmapLevel(int value)
if (value < 1) value = 1; if (value < 1) value = 1;
if (value > 16) value = 16; if (value > 16) value = 16;
bool changed = m_textureMipmapLevel != value;
m_textureMipmapLevel = value; m_textureMipmapLevel = value;
if(changed)
{
FlushTextureCache();
LoadAllTextures();
}
} }
int CEngine::GetTextureMipmapLevel() int CEngine::GetTextureMipmapLevel()
@ -2865,7 +2865,13 @@ void CEngine::SetTextureAnisotropyLevel(int value)
if (value < 1) value = 1; if (value < 1) value = 1;
if (value > 16) value = 16; if (value > 16) value = 16;
bool changed = m_textureAnisotropy != value;
m_textureAnisotropy = value; m_textureAnisotropy = value;
if(changed)
{
FlushTextureCache();
LoadAllTextures();
}
} }
int CEngine::GetTextureAnisotropyLevel() int CEngine::GetTextureAnisotropyLevel()

View File

@ -1761,4 +1761,14 @@ void CGL21Device::DeleteFramebuffer(std::string name)
} }
} }
bool CGL21Device::IsAnisotropySupported()
{
return m_anisotropyAvailable;
}
int CGL21Device::GetMaxAnisotropyLevel()
{
return m_maxAnisotropy;
}
} // namespace Gfx } // namespace Gfx

View File

@ -147,6 +147,9 @@ public:
virtual void DeleteFramebuffer(std::string name) override; virtual void DeleteFramebuffer(std::string name) override;
virtual bool IsAnisotropySupported() override;
virtual int GetMaxAnisotropyLevel() override;
private: private:
//! Updates position for given light based on transformation matrices //! Updates position for given light based on transformation matrices
void UpdateLightPosition(int index); void UpdateLightPosition(int index);

View File

@ -1954,4 +1954,14 @@ inline void CGL33Device::BindVAO(GLuint vao)
m_currentVAO = vao; m_currentVAO = vao;
} }
bool CGL33Device::IsAnisotropySupported()
{
return m_anisotropyAvailable;
}
int CGL33Device::GetMaxAnisotropyLevel()
{
return m_maxAnisotropy;
}
} // namespace Gfx } // namespace Gfx

View File

@ -146,6 +146,9 @@ public:
virtual void DeleteFramebuffer(std::string name) override; virtual void DeleteFramebuffer(std::string name) override;
virtual bool IsAnisotropySupported() override;
virtual int GetMaxAnisotropyLevel() override;
private: private:
//! Updates position for given light based on transformation matrices //! Updates position for given light based on transformation matrices
void UpdateLightPosition(int index); void UpdateLightPosition(int index);

View File

@ -1893,5 +1893,14 @@ void CGLDevice::DeleteFramebuffer(std::string name)
} }
} }
} // namespace Gfx bool CGLDevice::IsAnisotropySupported()
{
return m_anisotropyAvailable;
}
int CGLDevice::GetMaxAnisotropyLevel()
{
return m_maxAnisotropy;
}
} // namespace Gfx

View File

@ -166,6 +166,9 @@ public:
virtual void DeleteFramebuffer(std::string name) override; virtual void DeleteFramebuffer(std::string name) override;
virtual bool IsAnisotropySupported() override;
virtual int GetMaxAnisotropyLevel() override;
private: private:
//! Updates internal modelview matrix //! Updates internal modelview matrix
void UpdateModelviewMatrix(); void UpdateModelviewMatrix();
@ -254,4 +257,3 @@ private:
} // namespace Gfx } // namespace Gfx

74
src/ui/enumslider.cpp Normal file
View File

@ -0,0 +1,74 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#include "ui/enumslider.h"
#include "common/stringutils.h"
namespace Ui {
CEnumSlider::CEnumSlider() : CSlider()
{
}
void CEnumSlider::SetPossibleValues(const std::vector<float>& values)
{
m_values = values;
}
void CEnumSlider::SetPossibleValues(const std::map<float, std::string>& values)
{
m_values.clear();
for(auto it = values.begin(); it != values.end(); ++it) {
m_values.push_back(it->first);
}
m_labels = values;
}
void CEnumSlider::SetVisibleValue(float value)
{
for(unsigned int i = 0; i < m_values.size(); i++)
{
if(value == m_values[i])
{
m_visibleValue = static_cast<float>(i) / (m_values.size()-1);
}
}
}
int CEnumSlider::GetVisibleValueIndex()
{
return round(m_visibleValue * (m_values.size()-1));
}
float CEnumSlider::GetVisibleValue()
{
return m_values[GetVisibleValueIndex()];
}
std::string CEnumSlider::GetLabel()
{
float value = GetVisibleValueIndex();
if(m_labels.find(value) != m_labels.end())
{
return m_labels.at(value);
}
return StrUtils::ToString<int>(GetVisibleValue());
}
}

48
src/ui/enumslider.h Normal file
View File

@ -0,0 +1,48 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#pragma once
#include "ui/slider.h"
#include <vector>
#include <map>
namespace Ui {
class CEnumSlider : public CSlider
{
public:
CEnumSlider();
void SetPossibleValues(const std::vector<float>& values);
void SetPossibleValues(const std::map<float, std::string>& values);
void SetVisibleValue(float value);
float GetVisibleValue();
int GetVisibleValueIndex();
protected:
std::string GetLabel();
protected:
std::vector<float> m_values;
std::map<float, std::string> m_labels;
};
}

View File

@ -200,6 +200,11 @@ CSlider* CInterface::CreateSlider(Math::Point pos, Math::Point dim, int icon, Ev
return CreateControl<CSlider>(pos, dim, icon, eventMsg); return CreateControl<CSlider>(pos, dim, icon, eventMsg);
} }
CEnumSlider* CInterface::CreateEnumSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
return CreateControl<CEnumSlider>(pos, dim, icon, eventMsg);
}
// Creates a new list. // Creates a new list.
// if expand is less then zero, then the list would try to use expand's absolute value, // if expand is less then zero, then the list would try to use expand's absolute value,
// and try to scale items to some size, so that dim of the list would not change after // and try to scale items to some size, so that dim of the list would not change after
@ -348,4 +353,3 @@ void CInterface::SetFocus(CControl* control)
} // namespace Ui } // namespace Ui

View File

@ -39,6 +39,7 @@
#include "ui/label.h" #include "ui/label.h"
#include "ui/edit.h" #include "ui/edit.h"
#include "ui/editvalue.h" #include "ui/editvalue.h"
#include "ui/enumslider.h"
#include "ui/scroll.h" #include "ui/scroll.h"
#include "ui/slider.h" #include "ui/slider.h"
#include "ui/list.h" #include "ui/list.h"
@ -75,6 +76,7 @@ public:
CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CEnumSlider* CreateEnumSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
@ -104,4 +106,3 @@ protected:
} }

View File

@ -1067,8 +1067,6 @@ void CMainDialog::ChangePhase(Phase phase)
{ {
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_GROUND); pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_GROUND);
pc->SetState(STATE_SHADOW); pc->SetState(STATE_SHADOW);
// TODO: video 8 MB?
//if ( m_engine->IsVideo8MB() ) pc->ClearState(STATE_ENABLE);
} }
pos.y -= 0.048f; pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_DIRTY); pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_DIRTY);
@ -1076,8 +1074,6 @@ void CMainDialog::ChangePhase(Phase phase)
pos.y -= 0.048f; pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_SKY); pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_SKY);
pc->SetState(STATE_SHADOW); pc->SetState(STATE_SHADOW);
// TODO: video 8 MB?
//if ( m_engine->IsVideo8MB() ) pc->ClearState(STATE_ENABLE);
pos.y -= 0.048f; pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_LENS); pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_LENS);
pc->SetState(STATE_SHADOW); pc->SetState(STATE_SHADOW);
@ -1157,6 +1153,59 @@ void CMainDialog::ChangePhase(Phase phase)
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
} }
CEnumSlider* pes;
pos.x = ox+sx*8.5f;
pos.y = 0.385f;
ddim.x = dim.x*2.2f;
ddim.y = 18.0f/480.0f;
pes = pw->CreateEnumSlider(pos, ddim, 0, EVENT_INTERFACE_TEXTURE_FILTER);
pes->SetState(STATE_SHADOW);
pes->SetPossibleValues({
{ Gfx::TEX_FILTER_NEAREST, "Nearest" },
{ Gfx::TEX_FILTER_BILINEAR, "Bilinear" },
{ Gfx::TEX_FILTER_TRILINEAR, "Trilinear" }
});
pos.y += ddim.y/2;
pos.x += 0.005f;
ddim.x = 0.40f;
GetResource(RES_EVENT, EVENT_INTERFACE_TEXTURE_FILTER, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL12, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.x = ox+sx*8.5f;
pos.y = 0.315f;
ddim.x = dim.x*2.2f;
ddim.y = 18.0f/480.0f;
pes = pw->CreateEnumSlider(pos, ddim, 0, EVENT_INTERFACE_TEXTURE_MIPMAP);
pes->SetState(STATE_SHADOW);
pes->SetPossibleValues({1, 4, 8, 16});
pos.y += ddim.y/2;
pos.x += 0.005f;
ddim.x = 0.40f;
GetResource(RES_EVENT, EVENT_INTERFACE_TEXTURE_MIPMAP, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL12, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.x = ox+sx*8.5f;
pos.y = 0.245f;
ddim.x = dim.x*2.2f;
ddim.y = 18.0f/480.0f;
pes = pw->CreateEnumSlider(pos, ddim, 0, EVENT_INTERFACE_TEXTURE_ANISOTROPY);
pes->SetState(STATE_SHADOW);
std::vector<float> anisotropyOptions;
for(int i = 1; i <= m_engine->GetDevice()->GetMaxAnisotropyLevel(); i *= 2)
anisotropyOptions.push_back(i);
pes->SetPossibleValues(anisotropyOptions);
if(!m_engine->GetDevice()->IsAnisotropySupported())
pes->ClearState(STATE_ENABLE);
pos.y += ddim.y/2;
pos.x += 0.005f;
ddim.x = 0.40f;
GetResource(RES_EVENT, EVENT_INTERFACE_TEXTURE_ANISOTROPY, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL12, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
ddim.x = dim.x*2; ddim.x = dim.x*2;
ddim.y = dim.y*1; ddim.y = dim.y*1;
pos.x = ox+sx*10; pos.x = ox+sx*10;
@ -2413,6 +2462,13 @@ bool CMainDialog::EventProcess(const Event &event)
ChangeSetupButtons(); ChangeSetupButtons();
break; break;
case EVENT_INTERFACE_TEXTURE_FILTER:
case EVENT_INTERFACE_TEXTURE_MIPMAP:
case EVENT_INTERFACE_TEXTURE_ANISOTROPY:
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_MIN: case EVENT_INTERFACE_MIN:
ChangeSetupQuality(-1); ChangeSetupQuality(-1);
UpdateSetupButtons(); UpdateSetupButtons();
@ -4470,6 +4526,7 @@ void CMainDialog::UpdateSetupButtons()
CCheck* pc; CCheck* pc;
CEditValue* pv; CEditValue* pv;
CSlider* ps; CSlider* ps;
CEnumSlider* pes;
float value; float value;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
@ -4592,6 +4649,25 @@ void CMainDialog::UpdateSetupButtons()
ps->SetVisibleValue(m_main->GetAutosaveSlots()); ps->SetVisibleValue(m_main->GetAutosaveSlots());
} }
pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE_FILTER));
if ( pes != 0 )
{
pes->SetVisibleValue(m_engine->GetTextureFilterMode());
}
pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE_MIPMAP));
if ( pes != 0 )
{
pes->SetState(STATE_ENABLE, m_engine->GetTextureFilterMode() == Gfx::TEX_FILTER_TRILINEAR);
pes->SetVisibleValue(m_engine->GetTextureMipmapLevel());
}
pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE_ANISOTROPY));
if ( pes != 0 )
{
pes->SetVisibleValue(m_engine->GetTextureAnisotropyLevel());
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SHADOW)); pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SHADOW));
if ( pc != 0 ) if ( pc != 0 )
{ {
@ -4697,6 +4773,7 @@ void CMainDialog::ChangeSetupButtons()
CWindow* pw; CWindow* pw;
CEditValue* pv; CEditValue* pv;
CSlider* ps; CSlider* ps;
CEnumSlider* pes;
float value; float value;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
@ -4757,6 +4834,27 @@ void CMainDialog::ChangeSetupButtons()
value = ps->GetVisibleValue(); value = ps->GetVisibleValue();
m_main->SetAutosaveSlots(static_cast<int>(value)); m_main->SetAutosaveSlots(static_cast<int>(value));
} }
pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE_FILTER));
if ( pes != 0 )
{
value = pes->GetVisibleValue();
m_engine->SetTextureFilterMode(static_cast<Gfx::TexFilter>(value));
}
pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE_MIPMAP));
if ( pes != 0 )
{
value = pes->GetVisibleValue();
m_engine->SetTextureMipmapLevel(static_cast<int>(value));
}
pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE_ANISOTROPY));
if ( pes != 0 )
{
value = pes->GetVisibleValue();
m_engine->SetTextureAnisotropyLevel(static_cast<int>(value));
}
} }
@ -4804,6 +4902,7 @@ void CMainDialog::SetupMemorize()
GetConfigFile().SetFloatProperty("Setup", "ShadowColor", m_engine->GetShadowColor()); GetConfigFile().SetFloatProperty("Setup", "ShadowColor", m_engine->GetShadowColor());
GetConfigFile().SetFloatProperty("Setup", "ShadowRange", m_engine->GetShadowRange()); GetConfigFile().SetFloatProperty("Setup", "ShadowRange", m_engine->GetShadowRange());
GetConfigFile().SetIntProperty("Setup", "MSAA", m_engine->GetMultiSample()); GetConfigFile().SetIntProperty("Setup", "MSAA", m_engine->GetMultiSample());
GetConfigFile().SetIntProperty("Setup", "FilterMode", m_engine->GetTextureFilterMode());
/* screen setup */ /* screen setup */
GetConfigFile().SetIntProperty("Setup", "Fullscreen", m_setupFull ? 1 : 0); GetConfigFile().SetIntProperty("Setup", "Fullscreen", m_setupFull ? 1 : 0);
@ -5089,6 +5188,11 @@ void CMainDialog::SetupRecall()
{ {
m_engine->SetMultiSample(iValue); m_engine->SetMultiSample(iValue);
} }
if (GetConfigFile().GetIntProperty("Setup", "FilterMode", iValue))
{
m_engine->SetTextureFilterMode(static_cast<Gfx::TexFilter>(iValue));
}
} }

View File

@ -22,6 +22,7 @@
#include "common/event.h" #include "common/event.h"
#include "common/misc.h" #include "common/misc.h"
#include "common/stringutils.h"
#include "graphics/engine/engine.h" #include "graphics/engine/engine.h"
#include "graphics/engine/text.h" #include "graphics/engine/text.h"
@ -389,7 +390,6 @@ void CSlider::Draw()
Math::Point pos, dim, ppos, ddim, spos; Math::Point pos, dim, ppos, ddim, spos;
int icon; int icon;
float h; float h;
char text[100];
if ( (m_state & STATE_VISIBLE) == 0 ) return; if ( (m_state & STATE_VISIBLE) == 0 ) return;
@ -471,7 +471,7 @@ void CSlider::Draw()
{ {
if ( m_state & STATE_ENABLE ) if ( m_state & STATE_ENABLE )
{ {
sprintf(text, "%d", static_cast<int>(m_min+m_visibleValue*(m_max-m_min))); std::string text = GetLabel();
h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize); h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize);
pos.x = m_pos.x+m_dim.x+(10.0f/640.0f); pos.x = m_pos.x+m_dim.x+(10.0f/640.0f);
pos.y = m_pos.y+(m_dim.y-h)/2.0f; pos.y = m_pos.y+(m_dim.y-h)/2.0f;
@ -488,12 +488,17 @@ void CSlider::Draw()
pos.y += (h-CURSOR_WIDTH)*m_visibleValue; pos.y += (h-CURSOR_WIDTH)*m_visibleValue;
dim.x = 50.0f/640.0f; dim.x = 50.0f/640.0f;
dim.y = 16.0f/480.0f; dim.y = 16.0f/480.0f;
sprintf(text, "%d", static_cast<int>(m_min+(m_visibleValue*(m_max-m_min)))); std::string text = GetLabel();
m_engine->GetText()->DrawText(text, m_fontType, m_fontSize, pos, dim.x, Gfx::TEXT_ALIGN_RIGHT, 0); m_engine->GetText()->DrawText(text, m_fontType, m_fontSize, pos, dim.x, Gfx::TEXT_ALIGN_RIGHT, 0);
} }
} }
} }
std::string CSlider::GetLabel()
{
return StrUtils::ToString<int>(static_cast<int>(m_min+(m_visibleValue*(m_max-m_min))));
}
// Draws a rectangle. // Draws a rectangle.
void CSlider::DrawVertex(Math::Point pos, Math::Point dim, int icon) void CSlider::DrawVertex(Math::Point pos, Math::Point dim, int icon)
@ -586,4 +591,3 @@ float CSlider::GetArrowStep()
} }

View File

@ -25,6 +25,8 @@
#include "ui/control.h" #include "ui/control.h"
#include "common/event.h" #include "common/event.h"
#include <string>
namespace Ui { namespace Ui {
class CButton; class CButton;
@ -59,6 +61,7 @@ protected:
void MoveAdjust(); void MoveAdjust();
void AdjustGlint(); void AdjustGlint();
void DrawVertex(Math::Point pos, Math::Point dim, int icon); void DrawVertex(Math::Point pos, Math::Point dim, int icon);
virtual std::string GetLabel();
protected: protected:
CButton* m_buttonLeft; CButton* m_buttonLeft;
@ -82,4 +85,3 @@ protected:
} }

View File

@ -342,6 +342,26 @@ CSlider* CWindow::CreateSlider(Math::Point pos, Math::Point dim, int icon, Event
return 0; return 0;
} }
CEnumSlider* CWindow::CreateEnumSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
CEnumSlider* pc;
int i;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ )
{
if ( m_table[i] == 0 )
{
m_table[i] = new CEnumSlider();
pc = static_cast<CEnumSlider*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
}
return 0;
}
// Creates a new list. // Creates a new list.
// if expand is less then zero, then the list would try to use expand's absolute value, // if expand is less then zero, then the list would try to use expand's absolute value,
// and try to scale items to some size, so that dim of the list would not change after // and try to scale items to some size, so that dim of the list would not change after
@ -1555,4 +1575,3 @@ void CWindow::DrawHach(Math::Point pos, Math::Point dim)
} }
} }

View File

@ -36,6 +36,7 @@
#include "ui/label.h" #include "ui/label.h"
#include "ui/edit.h" #include "ui/edit.h"
#include "ui/editvalue.h" #include "ui/editvalue.h"
#include "ui/enumslider.h"
#include "ui/scroll.h" #include "ui/scroll.h"
#include "ui/slider.h" #include "ui/slider.h"
#include "ui/list.h" #include "ui/list.h"
@ -72,6 +73,7 @@ public:
CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CEnumSlider* CreateEnumSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand=1.2f); CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand=1.2f);
CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
@ -153,4 +155,3 @@ protected:
} }