Commit d4ecb00c authored by nanahira's avatar nanahira

skin

parent eea8f007
......@@ -53,6 +53,7 @@
/fonts
/replay
/single
/skin
/sound/*.wav
/sound/custom
/sound/BGM
......
#include "CConfigMap.h"
core::stringc CConfigMap::getConfig( const core::stringc& name )
{
core::map<core::stringc,core::stringc>::Node* node = Map.find(name);
if ( node == 0 )
return core::stringc();
return node->getValue();
}
s32 CConfigMap::getConfigAsInt( const core::stringc& name )
{
core::stringc cfg = getConfig(name);
if ( cfg.size() == 0 )
return 0;
s32 x = 0;
sscanf( cfg.c_str(), "%d", &x );
return x;
}
f32 CConfigMap::getConfigAsFloat( const core::stringc& name )
{
core::stringc cfg = getConfig(name);
if ( cfg.size() == 0 )
return 0;
f32 x = 0.0f;
sscanf( cfg.c_str(), "%f", &x );
return x;
}
core::vector2df CConfigMap::getConfigAsVector2df( const core::stringc& name )
{
core::stringc cfg = getConfig(name);
if ( cfg.size() == 0 )
return core::vector2df(0,0);
core::vector2df vec;
sscanf( cfg.c_str(), "%f , %f", &vec.X, &vec.Y );
return vec;
}
core::vector3df CConfigMap::getConfigAsVector3df( const core::stringc& name )
{
core::stringc cfg = getConfig(name);
if ( cfg.size() == 0 )
return core::vector3df(0,0,0);
core::vector3df vec;
sscanf( cfg.c_str(), "%f , %f , %f", &vec.X, &vec.Y, &vec.Z );
return vec;
}
bool CConfigMap::hasConfig( const core::stringc& name )
{
core::map<core::stringc,core::stringc>::Node* node = Map.find(name);
return ( node != 0 );
}
void CConfigMap::setConfig( const core::stringc& name, const core::stringc& value )
{
Map.set(name,value);
}
#ifndef CCONFIGMAP_H_
#define CCONFIGMAP_H_
#include <irrMap.h>
#include <irrString.h>
#include <irrTypes.h>
#include <vector2d.h>
#include <vector3d.h>
using namespace irr;
class CConfigMap
{
public:
core::stringc getConfig( const core::stringc& name );
s32 getConfigAsInt( const core::stringc& name );
f32 getConfigAsFloat( const core::stringc& name );
core::vector2df getConfigAsVector2df( const core::stringc& name );
core::vector3df getConfigAsVector3df( const core::stringc& name );
bool hasConfig( const core::stringc& name );
void setConfig( const core::stringc& name, const core::stringc& value );
private:
core::map<core::stringc,core::stringc> Map;
};
#endif
#include "CGUIProgressBar.h"
#include <IGUIEnvironment.h>
#include "CImageGUISkin.h"
#include <IGUIFont.h>
namespace irr
{
namespace gui
{
CGUIProgressBar::CGUIProgressBar( IGUIElement* parent, IGUIEnvironment* environment, const core::rect<s32>& rectangle, s32 id,bool bind )
: IGUIElement( EGUIET_ELEMENT, environment, parent, id, rectangle )
{
FilledRatio = 0.0f;
FillColor = video::SColor(255,255,0,0);
EmptyColor = video::SColor();
AutomaticTextFormat = L"%2.0f %%";
bindColorsToSkin = bind;
}
void CGUIProgressBar::setAutomaticText( const wchar_t* text )
{
AutomaticTextFormat = text? text:L"";
if ( AutomaticTextFormat != L"" )
{
wchar_t* buffer = new wchar_t[ AutomaticTextFormat.size() + 10 ];
swprintf( buffer, AutomaticTextFormat.size() + 10, AutomaticTextFormat.c_str(), 100*FilledRatio );
Text = buffer;
delete buffer;
}
}
void CGUIProgressBar::setFillColor( video::SColor fill )
{
FillColor = fill;
}
video::SColor CGUIProgressBar::getFillColor() const
{
return FillColor;
}
void CGUIProgressBar::setEmptyColor( video::SColor empty )
{
EmptyColor = empty;
}
video::SColor CGUIProgressBar::getEmptyColor() const
{
return EmptyColor;
}
void CGUIProgressBar::setProgress( f32 progress )
{
FilledRatio = progress;
if ( AutomaticTextFormat != L"" )
{
wchar_t* buffer = new wchar_t[ AutomaticTextFormat.size() + 10 ];
swprintf( buffer, AutomaticTextFormat.size() + 10, AutomaticTextFormat.c_str(), 100*FilledRatio );
Text = buffer;
delete buffer;
}
}
f32 CGUIProgressBar::getProgress() const
{
return FilledRatio;
}
void CGUIProgressBar::draw()
{
CImageGUISkin* skin = static_cast<CImageGUISkin*>( Environment->getSkin() );
// Madoc added these changes to let the progress bar get its fill colors from the skin
if(bindColorsToSkin) {
EmptyColor = ((gui::SImageGUISkinConfig)skin->getConfig()).ProgressBar.Color;
FillColor = ((gui::SImageGUISkinConfig)skin->getConfig()).ProgressBarFilled.Color;
}
// End Madoc changes
skin->drawHorizontalProgressBar( this, AbsoluteRect, &AbsoluteClippingRect, FilledRatio, FillColor, EmptyColor );
// Draw text in center
skin->getFont(EGDF_DEFAULT)->draw( Text.c_str(), AbsoluteRect, skin->getColor(EGDC_BUTTON_TEXT), true, true, &AbsoluteClippingRect );
}
}
}
#ifndef CGUIPROGRESSBAR_H_
#define CGUIPROGRESSBAR_H_
#include <IGUIElement.h>
#include <SColor.h>
namespace irr
{
namespace gui
{
/*!
* A horizontal progess bar. ONLY works with CImageGUISkin applied - will fail
* if another skin is used.
*/
class CGUIProgressBar : public IGUIElement
{
public:
// If you want your progress bar colors to be independent of the skin set bind to false -- Madoc
CGUIProgressBar( IGUIElement* parent, IGUIEnvironment* environment, const core::rect<s32>& rectangle, s32 id=-1 ,bool bind=true);
//! Automatically updates the progress bar's text every time the progress changes.
//! Set format to NULL or an empty string to disable automatic text.
void setAutomaticText( const wchar_t* format );
void setFillColor( video::SColor fill );
video::SColor getFillColor() const;
void setEmptyColor( video::SColor empty );
video::SColor getEmptyColor() const;
void setProgress( f32 progress );
f32 getProgress() const;
virtual void draw();
private:
video::SColor FillColor;
video::SColor EmptyColor;
bool bindColorsToSkin;
f32 FilledRatio;
core::stringw AutomaticTextFormat;
};
} // namespace gui
} // namespace irr
#endif
#include "CGUISkinSystem.h"
CGUISkinSystem::CGUISkinSystem(core::string<char*> path,IrrlichtDevice *dev) {
device = dev;
skinsPath = path;
fs = dev->getFileSystem();
this->loadSkinList();
}
core::array<core::stringw> CGUISkinSystem::listSkins() {
return skinsList;
}
// This is our version of the skinloader
// Generate a list of all directory names in skinsPath that have a skin.xml in them
// Don't rely on working directory going in.
// Careful with changeworkingdirectoryto and relative paths,
// remember that they are relative to the CURRENT working directory
bool CGUISkinSystem::loadSkinList() {
io::IFileList *fileList;
int i;
io::path oldpath = fs->getWorkingDirectory();
fs->changeWorkingDirectoryTo(skinsPath);
fileList = fs->createFileList();
i = fileList->getFileCount();
core::stringw tmp;
while(i--) {
// Check only directories, skip . and ..
// Side effect, on linux this ignores hidden directories
if(fileList->isDirectory(i) && !fileList->getFileName(i).equalsn(".",1)) {
if(fs->existFile(fileList->getFileName(i) + SKINSYSTEM_SKINFILE)) {
tmp = fileList->getFileName(i);
skinsList.push_back(tmp);
}
}
}
fileList->drop();
fs->changeWorkingDirectoryTo(oldpath);
if(skinsList.size() > 0)
return true;
else
return false;
}
gui::CGUIProgressBar *CGUISkinSystem::addProgressBar(gui::IGUIElement *parent,core::rect<s32> rect, bool bindColorsToSkin) {
gui::CGUIProgressBar* bar = new gui::CGUIProgressBar(parent,device->getGUIEnvironment(), rect,bindColorsToSkin);
//gui::CImageGUISkin* skin = (gui::CImageGUISkin*)device->getGUIEnvironment()->getSkin();
parent->addChild(bar);
bar->drop();
return bar;
}
bool CGUISkinSystem::populateTreeView(gui::IGUITreeView *control,const core::stringc& skinname) {
bool ret = false;
io::path oldpath = fs->getWorkingDirectory();
fs->changeWorkingDirectoryTo(skinsPath);
registry = new CXMLRegistry(fs);
if(!registry->loadFile(SKINSYSTEM_SKINFILE,skinname.c_str())) {
return ret;
}
ret = registry->populateTreeView(control);
delete registry;
registry = NULL;
fs->changeWorkingDirectoryTo(oldpath);
return ret;
}
void CGUISkinSystem::ParseGUIElementStyle(gui::SImageGUIElementStyle& elem, const core::stringc& name, bool nullcolors) {
core::stringw context;
core::stringc ctmp,err = "";
context = L"Skin/";
context += name;
core::rect<u32> box;
video::SColor col;
ctmp = registry->getValueAsCStr(L"texture",context.c_str());
if(!ctmp.size())
err += "Could not load texture property from skin file";
elem.Texture = device->getVideoDriver()->getTexture(ctmp);
box = registry->getValueAsRect((context + "/SrcBorder").c_str());
elem.SrcBorder.Top = box.UpperLeftCorner.X;
elem.SrcBorder.Left = box.UpperLeftCorner.Y;
elem.SrcBorder.Bottom = box.LowerRightCorner.X;
elem.SrcBorder.Right = box.LowerRightCorner.Y;
box = registry->getValueAsRect((context + "/DstBorder").c_str());
elem.DstBorder.Top = box.UpperLeftCorner.X;
elem.DstBorder.Left = box.UpperLeftCorner.Y;
elem.DstBorder.Bottom = box.LowerRightCorner.X;
elem.DstBorder.Right = box.LowerRightCorner.Y;
if(nullcolors) elem.Color = NULL;
col = registry->getValueAsColor((context +"/Color").c_str());
if(col != NULL)
elem.Color = col;
else {
col = registry->getValueAsColor((context +"/Colour").c_str());
if(col != NULL)
elem.Color = col;
}
}
// Because my 'xmlloader/registry', already has the data access components
// We skip the 'configreader and skinloader' steps and just load right from the registry into the skin config
// Then create the skin from that, and set it up
// TO maintain compatability in case of upgrades
// We dont touch the iterface to the skin itself.
gui::CImageGUISkin* CGUISkinSystem::loadSkinFromFile(const c8 *skinname) {
gui::CImageGUISkin* skin ;
gui::SImageGUISkinConfig skinConfig;
gui::EGUI_SKIN_TYPE fallbackType;
gui::IGUISkin *fallbackSkin;
s32 i,x;
core::stringc tmp;
core::stringw wtmp;
core::stringc path = "./";
path += skinname;
if(!registry->loadFile(SKINSYSTEM_SKINFILE,path.c_str())) {
return NULL;
}
// Easiest way to see if an xml is loading correctly
// is to make the registry write out the root node and see what comes out.
//registry->writeFile("Skin",".");
// To switch on the fly, we have to set the skin to the fallback skin first
tmp = registry->getValueAsCStr(L"skin",L"Skin/Properties/Fallback");
// Always default to metalic
fallbackType = gui::EGST_WINDOWS_METALLIC;
if(tmp.equals_ignore_case("EGST_WINDOWS_CLASSIC"))
fallbackType = gui::EGST_WINDOWS_CLASSIC;
else if(tmp.equals_ignore_case("EGST_BURNING_SKIN"))
fallbackType = gui::EGST_BURNING_SKIN;
// I'm not dealing with the 'unknown skin'
fallbackSkin = device->getGUIEnvironment()->createSkin(fallbackType);
device->getGUIEnvironment()->setSkin(fallbackSkin);
fallbackSkin->drop();
skin = new gui::CImageGUISkin(device->getVideoDriver(), device->getGUIEnvironment()->getSkin());
fs->changeWorkingDirectoryTo(path.c_str());
ParseGUIElementStyle(skinConfig.Button,"Button");
ParseGUIElementStyle(skinConfig.ButtonPressed, "Button/Pressed");
ParseGUIElementStyle(skinConfig.ButtonDisabled, "Button/ButtonDisabled");
ParseGUIElementStyle(skinConfig.SunkenPane, "SunkenPane");
ParseGUIElementStyle(skinConfig.Window, "Window");
ParseGUIElementStyle(skinConfig.ProgressBar, "ProgressBar",true);
ParseGUIElementStyle(skinConfig.ProgressBarFilled, "ProgressBar/Filled",true);
ParseGUIElementStyle(skinConfig.TabBody,"TabControl");
ParseGUIElementStyle(skinConfig.TabButton,"TabControl/TabButton");
ParseGUIElementStyle(skinConfig.TabButtonPressed,"TabControl/TabButtonPressed");
ParseGUIElementStyle(skinConfig.MenuBar,"MenuBar");
ParseGUIElementStyle(skinConfig.MenuPane,"MenuBar/MenuPane");
ParseGUIElementStyle(skinConfig.MenuPressed,"MenuBar/MenuPressed");
ParseGUIElementStyle(skinConfig.CheckBox,"CheckBox");
ParseGUIElementStyle(skinConfig.CheckBoxDisabled,"CheckBox/CheckBoxDisabled");
ParseGUIElementStyle(skinConfig.ComboBox,"ComboBox");
ParseGUIElementStyle(skinConfig.ComboBoxDisabled,"ComboBox/ComboBoxDisabled");
skinConfig.CheckBoxColor = registry->getValueAsColor(L"Skin/Global/CheckBoxColor");
// If there was no progress bar colors set, set them in the config to the defaults
// otherwise their 0,0,0,0. This is neccicary for the old klagui.
if(skinConfig.ProgressBar.Color == NULL)
skinConfig.ProgressBar.Color = video::SColor();
if(skinConfig.ProgressBarFilled.Color == NULL)
skinConfig.ProgressBarFilled.Color = video::SColor(255,255,0,0);
// Load in the Info
loadProperty((core::stringw)L"Name",skin);
loadProperty((core::stringw)L"Author",skin);
loadProperty((core::stringw)L"Version",skin);
loadProperty((core::stringw)L"Date",skin);
loadProperty((core::stringw)L"Desc",skin);
skin->loadConfig(skinConfig);
tmp = registry->getValueAsCStr(L"texture",L"Skin/Properties/Font");
gui::IGUIFont *font = device->getGUIEnvironment()->getFont(tmp.c_str());
if(font !=0) {
device->getGUIEnvironment()->getSkin()->setFont(font, gui::EGDF_DEFAULT);
device->getGUIEnvironment()->getSkin()->setFont(font, gui::EGDF_WINDOW);
}
// Get and set global alpha, problem with this, you can't set it to 0
// He does this to make ALL the default stuff completly transparent
// This has the downside that it whipes out things like checkbox and window button colors
video::SColor newCol = video::SColor();
video::SColor oldCol = newCol;
x = registry->getValueAsInt(L"guialpha",L"Skin/Global/");
if(x && x != NULL) {
i = gui::EGDC_COUNT;
while(i--) {
oldCol = skin->getColor((gui::EGUI_DEFAULT_COLOR)i);
newCol = oldCol;
newCol.setAlpha(x);
skin->setColor((gui::EGUI_DEFAULT_COLOR)i, newCol);
}
}
checkSkinColor(gui::EGDC_3D_DARK_SHADOW,L"Skin/Global/EGDC_32_DARK_SHADOW",skin);
checkSkinColor(gui::EGDC_3D_SHADOW,L"Skin/Global/EGDC_3D_SHADOW",skin);
checkSkinColor(gui::EGDC_3D_FACE,L"Skin/Global/EGDC_3D_FACE",skin);
checkSkinColor(gui::EGDC_3D_HIGH_LIGHT,L"Skin/Global/EGDC_3D_HIGH_LIGHT",skin);
checkSkinColor(gui::EGDC_3D_LIGHT,L"Skin/Global/EGDC_3D_LIGHT",skin);
checkSkinColor(gui::EGDC_ACTIVE_BORDER,L"Skin/Global/EGDC_ACTIVE_BORDER",skin);
checkSkinColor(gui::EGDC_ACTIVE_CAPTION,L"Skin/Global/EGDC_ACTIVE_CAPTION",skin);
checkSkinColor(gui::EGDC_APP_WORKSPACE,L"Skin/Global/EGDC_APP_WORKSPACE",skin);
checkSkinColor(gui::EGDC_BUTTON_TEXT,L"Skin/Global/EGDC_BUTTON_TEXT",skin);
checkSkinColor(gui::EGDC_GRAY_TEXT,L"Skin/Global/EGDC_GRAY_TEXT",skin);
checkSkinColor(gui::EGDC_HIGH_LIGHT_TEXT,L"Skin/Global/EGDC_HIGH_LIGHT_TEXT",skin);
checkSkinColor(gui::EGDC_INACTIVE_BORDER,L"Skin/Global/EGDC_INACTIVE_BORDER",skin);
checkSkinColor(gui::EGDC_INACTIVE_CAPTION,L"Skin/Global/EGDC_INACTIVE_CAPTION",skin);
checkSkinColor(gui::EGDC_TOOLTIP,L"Skin/Global/EGDC_TOOLTIP",skin);
checkSkinColor(gui::EGDC_TOOLTIP_BACKGROUND,L"Skin/Global/EGDC_TOOLTIP_BACKGROUND",skin);
checkSkinColor(gui::EGDC_SCROLLBAR,L"Skin/Global/EGDC_SCROLLBAR",skin);
checkSkinColor(gui::EGDC_WINDOW,L"Skin/Global/EGDC_WINDOW",skin);
checkSkinColor(gui::EGDC_WINDOW_SYMBOL,L"Skin/Global/EGDC_WINDOW_SYMBOL",skin);
checkSkinColor(gui::EGDC_ICON,L"Skin/Global/EGDC_ICON",skin);
checkSkinColor(gui::EGDC_ICON_HIGH_LIGHT,L"Skin/Global/EGDC_ICON_HIGH_LIGHT",skin);
checkSkinSize(gui::EGDS_WINDOW_BUTTON_WIDTH, L"Skin/Global/WindowButton",L"width",skin);
checkSkinSize(gui::EGDS_TITLEBARTEXT_DISTANCE_X, L"Skin/Global/Caption",L"tbardistancex",skin);
checkSkinSize(gui::EGDS_TITLEBARTEXT_DISTANCE_Y, L"Skin/Global/Caption",L"tbardistancey",skin);
return skin;
}
core:: stringw CGUISkinSystem::getProperty(core::stringw key) {
gui::CImageGUISkin* skin = (gui::CImageGUISkin*)device->getGUIEnvironment()->getSkin();
return skin->getProperty(key);
}
bool CGUISkinSystem::checkSkinColor(gui::EGUI_DEFAULT_COLOR colToSet,const wchar_t *context,gui::CImageGUISkin *skin) {
video::SColor col = registry->getValueAsColor(context);
if(col != NULL) {
skin->setColor(colToSet,col);
return true;
}
return false;
}
bool CGUISkinSystem::checkSkinSize(gui::EGUI_DEFAULT_SIZE sizeToSet,const wchar_t *context,const wchar_t *key,gui::CImageGUISkin *skin) {
u16 i = registry->getValueAsInt(key,context);
if(i != NULL) {
skin->setSize(sizeToSet,i);
return true;
}
return false;
}
bool CGUISkinSystem::loadProperty(core::stringw key,gui::CImageGUISkin *skin) {
core::stringw wtmp = "Skin/Properties/";
wtmp += key;
wtmp = registry->getValueAsCStr(L"data",wtmp.c_str());
if(wtmp.size()) {
skin->setProperty(key,wtmp);
return true;
}
return false;
}
bool CGUISkinSystem::applySkin(const wchar_t *skinname) {
io::path oldpath = fs->getWorkingDirectory();
core::stringc tmp = skinname;
fs->changeWorkingDirectoryTo(skinsPath);
registry = new CXMLRegistry(fs);
gui::CImageGUISkin* skin = loadSkinFromFile(tmp.c_str());
if(skin == NULL) return false;
device->getGUIEnvironment()->setSkin(skin);
// If we're going to switch skin we need to find all the progress bars and overwrite their colors
skin->drop();
delete registry;
registry = NULL;
fs->changeWorkingDirectoryTo(oldpath);
return true;
}
CGUISkinSystem::~CGUISkinSystem() {
skinsList.clear();
}
\ No newline at end of file
#ifndef __C_GUISKIN_SYSTEM_H_INCLUDED__
#define __C_GUISKIN_SYSTEM_H_INCLUDED__
#ifdef _WIN32
#include <irrlicht.h>
#endif
#include "CImageGUISkin.h"
#include "CGUIProgressBar.h"
//#include "SkinLoader.h"
#include "../CXMLRegistry/CXMLRegistry.h"
#ifndef _WIN32
// gcc dosnt do 'debug'
#ifndef _DEBUG
#define _DEBUG
#endif
#endif
#define SKINSYSTEM_SKINFILE "/skin.xml"
using namespace irr;
class CGUISkinSystem {
private :
IrrlichtDevice *device;
io::IFileSystem *fs;
io::path skinsPath;
core::array<core::stringw> skinsList;
CXMLRegistry *registry;
gui::CImageGUISkin* loadSkinFromFile(const c8 *skinfile);
void ParseGUIElementStyle(gui::SImageGUIElementStyle& elem, const core::stringc& name,bool nullcolors=false);
bool checkSkinColor(gui::EGUI_DEFAULT_COLOR colToSet,const wchar_t *context,gui::CImageGUISkin *skin);
bool checkSkinSize(gui::EGUI_DEFAULT_SIZE sizeToSet,const wchar_t *context,const wchar_t *key,gui::CImageGUISkin *skin);
bool loadProperty(core::stringw key,gui::CImageGUISkin *skin);
public:
// Constructor
// path = Path to skins
// dev = Irrlicht device
CGUISkinSystem(core::string<char*> path,IrrlichtDevice *dev);
~CGUISkinSystem();
core::array<core::stringw> listSkins();
bool loadSkinList();
bool applySkin(const wchar_t *skinname);
gui::CGUIProgressBar *addProgressBar(gui::IGUIElement *parent,core::rect<s32> rect,bool bindColorsToSkin=true);
// Gets property from current skin
core::stringw getProperty(core::stringw key);
bool populateTreeView(gui::IGUITreeView *control,const core::stringc& skinname);
};
#endif
#include "CImageGUISkin.h"
#include <IVideoDriver.h>
#include <ITexture.h>
#include <IGUIElement.h>
#include "clipRects.h"
namespace irr
{
namespace gui
{
CImageGUISkin::CImageGUISkin( video::IVideoDriver* driver, IGUISkin* fallbackSkin )
{
VideoDriver = driver;
FallbackSkin = fallbackSkin;
FallbackSkin->grab();
}
CImageGUISkin::~CImageGUISkin()
{
FallbackSkin->drop();
properties.clear();
}
void CImageGUISkin::setProperty(core::stringw key, core::stringw value) {
properties.set(key,value);
}
core::stringw CImageGUISkin::getProperty(core::stringw key) {
core::map<core::stringw,core::stringw>::Node* node = properties.find(key);
if(node == 0)
return core::stringw("");
else return node->getValue();
}
void CImageGUISkin::loadConfig( const SImageGUISkinConfig& config )
{
Config = config;
}
video::SColor CImageGUISkin::getColor(EGUI_DEFAULT_COLOR color) const
{
return FallbackSkin->getColor(color);
}
void CImageGUISkin::setColor( EGUI_DEFAULT_COLOR which, video::SColor newColor )
{
FallbackSkin->setColor(which, newColor);
}
s32 CImageGUISkin::getSize(EGUI_DEFAULT_SIZE size) const
{
return FallbackSkin->getSize(size);
}
const wchar_t* CImageGUISkin::getDefaultText(EGUI_DEFAULT_TEXT text) const
{
return FallbackSkin->getDefaultText(text);
}
void CImageGUISkin::setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText)
{
FallbackSkin->setDefaultText(which, newText);
}
void CImageGUISkin::setSize(EGUI_DEFAULT_SIZE which, s32 size)
{
FallbackSkin->setSize(which, size);
}
IGUIFont* CImageGUISkin::getFont(EGUI_DEFAULT_FONT defaultFont) const
{
return FallbackSkin->getFont(defaultFont);
}
void CImageGUISkin::setFont(IGUIFont* font, EGUI_DEFAULT_FONT defaultFont)
{
FallbackSkin->setFont(font, defaultFont);
}
IGUISpriteBank* CImageGUISkin::getSpriteBank() const
{
return FallbackSkin->getSpriteBank();
}
void CImageGUISkin::setSpriteBank( IGUISpriteBank* bank )
{
FallbackSkin->setSpriteBank(bank);
}
u32 CImageGUISkin::getIcon( EGUI_DEFAULT_ICON icon ) const
{
return FallbackSkin->getIcon(icon);
}
void CImageGUISkin::setIcon( EGUI_DEFAULT_ICON icon, u32 index )
{
FallbackSkin->setIcon(icon, index);
}
void CImageGUISkin::draw3DButtonPaneStandard( IGUIElement* element, const core::rect<s32>& rect, const core::rect<s32>* clip )
{
if(element->isEnabled())
{
if ( !Config.Button.Texture )
{
FallbackSkin->draw3DButtonPaneStandard( element, rect, clip );
return;
}
drawElementStyle( Config.Button, rect, clip );
}
else
{
if ( !Config.ButtonDisabled.Texture )
{
FallbackSkin->draw3DButtonPaneStandard( element, rect, clip );
return;
}
drawElementStyle( Config.ButtonDisabled, rect, clip );
}
}
void CImageGUISkin::draw3DButtonPanePressed( IGUIElement* element, const core::rect<s32>& rect, const core::rect<s32>* clip )
{
if ( !Config.Button.Texture )
{
FallbackSkin->draw3DButtonPanePressed( element, rect, clip );
return;
}
drawElementStyle( Config.ButtonPressed, rect, clip );
}
void CImageGUISkin::draw3DSunkenPane(IGUIElement* element,
video::SColor bgcolor, bool flat, bool fillBackGround,
const core::rect<s32>& rect,
const core::rect<s32>* clip)
{
if(element->getType() == EGUIET_MENU)
{
if ( !Config.MenuPressed.Texture )
{
FallbackSkin->draw3DSunkenPane(element, bgcolor, flat, fillBackGround, rect, clip);
return;
}
drawElementStyle( Config.MenuPressed, rect, clip );
}
else if (element->getType() == EGUIET_CHECK_BOX)
{
if(element->isEnabled())
{
if ( !Config.CheckBox.Texture )
{
FallbackSkin->draw3DSunkenPane(element, bgcolor, flat, fillBackGround, rect, clip);
return;
}
drawElementStyle( Config.CheckBox, rect, clip );
}
else
{
if ( !Config.CheckBoxDisabled.Texture )
{
FallbackSkin->draw3DSunkenPane(element, bgcolor, flat, fillBackGround, rect, clip);
return;
}
drawElementStyle( Config.CheckBoxDisabled, rect, clip );
}
}
else if (element->getType() == EGUIET_COMBO_BOX)
{
if(element->isEnabled())
{
if ( !Config.ComboBox.Texture )
{
FallbackSkin->draw3DSunkenPane(element, bgcolor, flat, fillBackGround, rect, clip);
return;
}
if(fillBackGround)
FallbackSkin->draw2DRectangle(element, bgcolor, rect, clip);
drawElementStyle( Config.ComboBox, rect, clip );
}
else
{
if ( !Config.ComboBoxDisabled.Texture )
{
FallbackSkin->draw3DSunkenPane(element, bgcolor, flat, fillBackGround, rect, clip);
return;
}
if(fillBackGround)
FallbackSkin->draw2DRectangle(element, bgcolor, rect, clip);
drawElementStyle( Config.ComboBoxDisabled, rect, clip );
}
}
else
{
if ( !Config.SunkenPane.Texture )
{
FallbackSkin->draw3DSunkenPane(element, bgcolor, flat, fillBackGround, rect, clip);
return;
}
if(fillBackGround)
FallbackSkin->draw2DRectangle(element, bgcolor, rect, clip);
drawElementStyle( Config.SunkenPane, rect, clip );
}
}
// 1.7 updates by Mamnarock
core::rect<s32> CImageGUISkin::draw3DWindowBackground(IGUIElement* element,
bool drawTitleBar, video::SColor titleBarColor,
const core::rect<s32>& rect,
const core::rect<s32>* clip,
core::rect<s32>* checkClientArea)
{
if ( !Config.Window.Texture )
{
return FallbackSkin->draw3DWindowBackground(element, drawTitleBar, titleBarColor, rect, clip );
}
drawElementStyle( Config.Window, rect, clip );
return core::rect<s32>( rect.UpperLeftCorner.X+Config.Window.DstBorder.Left, rect.UpperLeftCorner.Y, rect.LowerRightCorner.X-Config.Window.DstBorder.Right, rect.UpperLeftCorner.Y+Config.Window.DstBorder.Top );
}
void CImageGUISkin::draw3DMenuPane(IGUIElement* element,
const core::rect<s32>& rect,
const core::rect<s32>* clip)
{
if ( !Config.MenuPane.Texture )
{
FallbackSkin->draw3DToolBar( element, rect, clip );
return;
}
drawElementStyle( Config.MenuPane, rect, clip );
}
void CImageGUISkin::draw3DToolBar(IGUIElement* element,
const core::rect<s32>& rect,
const core::rect<s32>* clip)
{
if ( !Config.MenuBar.Texture )
{
FallbackSkin->draw3DToolBar( element, rect, clip );
return;
}
drawElementStyle( Config.MenuBar, rect, clip );
}
void CImageGUISkin::draw3DTabButton(IGUIElement* element, bool active,
const core::rect<s32>& rect, const core::rect<s32>* clip, gui::EGUI_ALIGNMENT alignment)
{
if(active)
{
if ( !Config.TabButtonPressed.Texture )
{
FallbackSkin->draw3DTabButton(element, active, rect, clip, alignment);
return;
}
drawElementStyle( Config.TabButtonPressed, rect, clip );
}
else
{
if ( !Config.TabButton.Texture )
{
FallbackSkin->draw3DTabButton(element, active, rect, clip, alignment);
return;
}
drawElementStyle( Config.TabButton, rect, clip );
}
}
void CImageGUISkin::draw3DTabBody(IGUIElement* element, bool border, bool background,
const core::rect<s32>& rect, const core::rect<s32>* clip, s32 tabHeight, gui::EGUI_ALIGNMENT alignment )
{
core::rect<s32> newclip,newrect;
if ( !Config.TabBody.Texture )
{
FallbackSkin->draw3DTabBody(element, border, background, rect, clip, tabHeight, alignment);
return;
}
newclip.LowerRightCorner.set(clip->LowerRightCorner);
newclip.UpperLeftCorner.set(clip->UpperLeftCorner.X,clip->UpperLeftCorner.Y+tabHeight);
newrect.LowerRightCorner.set(rect.LowerRightCorner);
newrect.UpperLeftCorner.set(rect.UpperLeftCorner.X,rect.LowerRightCorner.Y+tabHeight);
drawElementStyle( Config.TabBody, newclip, &newclip );
}
void CImageGUISkin::drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon,
const core::position2di position, u32 starttime, u32 currenttime,
bool loop, const core::rect<s32>* clip)
{
video::SColor Color = getColor(gui::EGDC_WINDOW_SYMBOL);
if(icon == gui::EGDI_CHECK_BOX_CHECKED)
{
if(Config.CheckBoxColor.getAlpha() > 0)
Color = Config.CheckBoxColor;
}
// Patch to make checkbox and radio color come from gui::EGDC_WINDOW_SYMBOL -- Madoc
if(icon == gui::EGDI_CHECK_BOX_CHECKED || icon == gui::EGDI_RADIO_BUTTON_CHECKED)
{
FallbackSkin->getSpriteBank()->draw2DSprite(
FallbackSkin->getIcon(icon),
position,
clip,
Color,
starttime,
currenttime,
loop,
true);
}
else FallbackSkin->drawIcon(element,icon,position,starttime,currenttime,loop,clip);
}
void CImageGUISkin::drawHorizontalProgressBar( IGUIElement* element, const core::rect<s32>& rectangle, const core::rect<s32>* clip,
f32 filledRatio, video::SColor fillColor, video::SColor emptyColor )
{
if ( !Config.ProgressBar.Texture || !Config.ProgressBarFilled.Texture )
{
return;
}
// Draw empty progress bar
drawElementStyle( Config.ProgressBar, rectangle, clip, &emptyColor );
// Draw filled progress bar on top
if ( filledRatio < 0.0f )
filledRatio = 0.0f;
else
if ( filledRatio > 1.0f )
filledRatio = 1.0f;
if ( filledRatio > 0.0f )
{
s32 filledPixels = (s32)( filledRatio * rectangle.getSize().Width );
s32 height = rectangle.getSize().Height;
core::rect<s32> clipRect = clip? *clip:rectangle;
if ( filledPixels < height )
{
if ( clipRect.LowerRightCorner.X > rectangle.UpperLeftCorner.X + filledPixels )
clipRect.LowerRightCorner.X = rectangle.UpperLeftCorner.X + filledPixels;
filledPixels = height;
}
core::rect<s32> filledRect = core::rect<s32>(
rectangle.UpperLeftCorner.X,
rectangle.UpperLeftCorner.Y,
rectangle.UpperLeftCorner.X + filledPixels,
rectangle.LowerRightCorner.Y );
drawElementStyle( Config.ProgressBarFilled, filledRect, &clipRect, &fillColor );
}
}
void CImageGUISkin::drawElementStyle( const SImageGUIElementStyle& elem, const core::rect<s32>& rect, const core::rect<s32>* clip, video::SColor* pcolor )
{
core::rect<s32> srcRect;
core::rect<s32> dstRect;
core::dimension2du tsize = elem.Texture->getSize();
video::ITexture* texture = elem.Texture;
video::SColor color = elem.Color;
if ( pcolor )
color = *pcolor;
video::SColor faceColor = getColor(EGDC_3D_FACE);
color.setRed( (u8)(color.getRed() * faceColor.getRed() / 255) );
color.setGreen( (u8)(color.getGreen() * faceColor.getGreen() / 255) );
color.setBlue( (u8)(color.getBlue() * faceColor.getBlue() / 255) );
color.setAlpha( (u8)(color.getAlpha() * faceColor.getAlpha() / 255 ) );
video::SColor colors [4] = { color, color, color, color };
core::dimension2di dstSize = rect.getSize();
// Scale the border if there is insufficient room
SImageGUIElementStyle::SBorder dst = elem.DstBorder;
f32 scale = 1.0f;
if ( dstSize.Width < dst.Left + dst.Right )
{
scale = dstSize.Width / (f32)( dst.Left + dst.Right );
}
if ( dstSize.Height < dst.Top + dst.Bottom )
{
f32 x = dstSize.Height / (f32)( dst.Top + dst.Bottom );
if ( x < scale )
{
scale = x;
}
}
if ( scale < 1.0f )
{
dst.Left = (s32)( dst.Left * scale );
dst.Right = (s32)( dst.Right * scale );
dst.Top = (s32)( dst.Top * scale );
dst.Bottom = (s32)( dst.Bottom * scale );
}
const SImageGUIElementStyle::SBorder& src = elem.SrcBorder;
// Draw the top left corner
srcRect = core::rect<s32>( 0, 0, src.Left, src.Top );
dstRect = core::rect<s32>( rect.UpperLeftCorner.X, rect.UpperLeftCorner.Y, rect.UpperLeftCorner.X+dst.Left, rect.UpperLeftCorner.Y+dst.Top );
if ( !clip || clipRects( dstRect, srcRect, *clip ) )
VideoDriver->draw2DImage( texture, dstRect, srcRect, clip, colors, true );
// Draw the top right corner
srcRect = core::rect<s32>( tsize.Width-src.Right, 0, tsize.Width, src.Top );
dstRect = core::rect<s32>( rect.LowerRightCorner.X-dst.Right, rect.UpperLeftCorner.Y, rect.LowerRightCorner.X, rect.UpperLeftCorner.Y+dst.Top );
if ( !clip || clipRects( dstRect, srcRect, *clip ) )
VideoDriver->draw2DImage( texture, dstRect, srcRect, clip, colors, true );
// Draw the top border
srcRect = core::rect<s32>( src.Left, 0, tsize.Width-src.Right, src.Top );
dstRect = core::rect<s32>( rect.UpperLeftCorner.X+dst.Left, rect.UpperLeftCorner.Y, rect.LowerRightCorner.X-dst.Right, rect.UpperLeftCorner.Y+dst.Top );
if ( !clip || clipRects( dstRect, srcRect, *clip ) )
VideoDriver->draw2DImage( texture, dstRect, srcRect, clip, colors, true );
// Draw the left border
srcRect = core::rect<s32>( 0, src.Top, src.Left, tsize.Height-src.Bottom );
dstRect = core::rect<s32>( rect.UpperLeftCorner.X, rect.UpperLeftCorner.Y+dst.Top, rect.UpperLeftCorner.X+dst.Left, rect.LowerRightCorner.Y-dst.Bottom );
if ( !clip || clipRects( dstRect, srcRect, *clip ) )
VideoDriver->draw2DImage( texture, dstRect, srcRect, clip, colors, true );
// Draw the right border
srcRect = core::rect<s32>( tsize.Width-src.Right, src.Top, tsize.Width, tsize.Height-src.Bottom );
dstRect = core::rect<s32>( rect.LowerRightCorner.X-dst.Right, rect.UpperLeftCorner.Y+dst.Top, rect.LowerRightCorner.X, rect.LowerRightCorner.Y-dst.Bottom );
if ( !clip || clipRects( dstRect, srcRect, *clip ) )
VideoDriver->draw2DImage( texture, dstRect, srcRect, clip, colors, true );
// Draw the middle section
srcRect = core::rect<s32>( src.Left, src.Top, tsize.Width-src.Right, tsize.Height-src.Bottom );
dstRect = core::rect<s32>( rect.UpperLeftCorner.X+dst.Left, rect.UpperLeftCorner.Y+dst.Top, rect.LowerRightCorner.X-dst.Right, rect.LowerRightCorner.Y-dst.Bottom );
if ( !clip || clipRects( dstRect, srcRect, *clip ) )
VideoDriver->draw2DImage( texture, dstRect, srcRect, clip, colors, true );
// Draw the bottom left corner
srcRect = core::rect<s32>( 0, tsize.Height-src.Bottom, src.Left, tsize.Height );
dstRect = core::rect<s32>( rect.UpperLeftCorner.X, rect.LowerRightCorner.Y-dst.Bottom, rect.UpperLeftCorner.X+dst.Left, rect.LowerRightCorner.Y );
if ( !clip || clipRects( dstRect, srcRect, *clip ) )
VideoDriver->draw2DImage( texture, dstRect, srcRect, clip, colors, true );
// Draw the bottom right corner
srcRect = core::rect<s32>( tsize.Width-src.Right, tsize.Height-src.Bottom, tsize.Width, tsize.Height );
dstRect = core::rect<s32>( rect.LowerRightCorner.X-dst.Right, rect.LowerRightCorner.Y-dst.Bottom, rect.LowerRightCorner.X, rect.LowerRightCorner.Y );
if ( !clip || clipRects( dstRect, srcRect, *clip ) )
VideoDriver->draw2DImage( texture, dstRect, srcRect, clip, colors, true );
// Draw the bottom border
srcRect = core::rect<s32>( src.Left, tsize.Height-src.Bottom, tsize.Width-src.Right, tsize.Height );
dstRect = core::rect<s32>( rect.UpperLeftCorner.X+dst.Left, rect.LowerRightCorner.Y-dst.Bottom, rect.LowerRightCorner.X-dst.Right, rect.LowerRightCorner.Y );
if ( !clip || clipRects( dstRect, srcRect, *clip ) )
VideoDriver->draw2DImage( texture, dstRect, srcRect, clip, colors, true );
}
void CImageGUISkin::draw2DRectangle(IGUIElement* element, const video::SColor &color,
const core::rect<s32>& pos, const core::rect<s32>* clip)
{
FallbackSkin->draw2DRectangle(element, color, pos, clip);
}
} // namespace gui
} // namespace irr
#ifndef CIMAGEGUISKIN_H_
#define CIMAGEGUISKIN_H_
#include <IGUISkin.h>
#include <irrString.h>
#include <irrMap.h>
#include <IGUISpriteBank.h>
namespace irr
{
namespace video
{
class IVideoDriver;
class ITexture;
}
namespace gui
{
struct SImageGUIElementStyle
{
struct SBorder
{
s32 Top, Left, Bottom, Right;
SBorder() : Top(0), Left(0), Bottom(0), Right(0) {}
};
SBorder SrcBorder;
SBorder DstBorder;
video::ITexture* Texture;
video::SColor Color;
SImageGUIElementStyle() : Texture(0), Color(255,255,255,255) {}
};
struct SImageGUISkinConfig
{
SImageGUIElementStyle SunkenPane, Window, Button, ButtonPressed, ButtonDisabled, ProgressBar, ProgressBarFilled, TabButton, TabButtonPressed, TabBody, MenuBar, MenuPane, MenuPressed, CheckBox, CheckBoxDisabled, ComboBox, ComboBoxDisabled;
video::SColor CheckBoxColor;
};
class CImageGUISkin : public IGUISkin
{
public:
CImageGUISkin( video::IVideoDriver* videoDriver, IGUISkin* fallbackSkin );
virtual ~CImageGUISkin();
void loadConfig( const SImageGUISkinConfig& config );
//! returns default color
virtual video::SColor getColor(EGUI_DEFAULT_COLOR color) const;
//! sets a default color
virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor);
//! returns default color
virtual s32 getSize(EGUI_DEFAULT_SIZE size) const;
//! Returns a default text.
virtual const wchar_t* getDefaultText(EGUI_DEFAULT_TEXT text) const;
//! Sets a default text.
virtual void setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText);
//! sets a default size
virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size);
//! returns the default font
virtual IGUIFont* getFont(EGUI_DEFAULT_FONT defaultFont) const;
//! sets a default font
virtual void setFont(IGUIFont* font, EGUI_DEFAULT_FONT defaultFont);
//! returns the sprite bank
virtual IGUISpriteBank* getSpriteBank() const;
//! sets the sprite bank
virtual void setSpriteBank(IGUISpriteBank* bank);
virtual u32 getIcon(EGUI_DEFAULT_ICON icon) const;
virtual void setIcon(EGUI_DEFAULT_ICON icon, u32 index);
virtual void draw3DButtonPaneStandard(IGUIElement* element,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0);
virtual void draw3DButtonPanePressed(IGUIElement* element,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0);
virtual void draw3DSunkenPane(IGUIElement* element,
video::SColor bgcolor, bool flat, bool fillBackGround,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0);
/* Updates for irrlicht 1.7 by Mamnarock
virtual core::rect<s32> draw3DWindowBackground(IGUIElement* element,
bool drawTitleBar, video::SColor titleBarColor,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0);
*/
virtual core::rect<s32> draw3DWindowBackground(IGUIElement* element,
bool drawTitleBar, video::SColor titleBarColor,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0,
core::rect<s32>* checkClientArea=0);
virtual void draw3DMenuPane(IGUIElement* element,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0);
virtual void draw3DToolBar(IGUIElement* element,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0);
virtual void draw3DTabButton(IGUIElement* element, bool active,
const core::rect<s32>& rect, const core::rect<s32>* clip=0, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT);
virtual void draw3DTabBody(IGUIElement* element, bool border, bool background,
const core::rect<s32>& rect, const core::rect<s32>* clip=0,s32 tabHeight=-1, gui::EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT );
virtual void drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon,
const core::position2di position, u32 starttime=0, u32 currenttime=0,
bool loop=false, const core::rect<s32>* clip=0);
// Madoc - I had to add some things
// Exposes config so we can get the progress bar colors
virtual SImageGUISkinConfig getConfig() { return Config; }
// End Madoc adds
virtual void drawHorizontalProgressBar( IGUIElement* element, const core::rect<s32>& rectangle, const core::rect<s32>* clip,
f32 filledRatio, video::SColor fillColor, video::SColor emptyColor );
virtual void draw2DRectangle(IGUIElement* element, const video::SColor &color,
const core::rect<s32>& pos, const core::rect<s32>* clip = 0);
virtual void setProperty(core::stringw key, core::stringw value);
virtual core::stringw getProperty(core::stringw key);
private:
void drawElementStyle( const SImageGUIElementStyle& elem, const core::rect<s32>& rect, const core::rect<s32>* clip, video::SColor* color=0 );
video::IVideoDriver* VideoDriver;
IGUISkin* FallbackSkin;
SImageGUISkinConfig Config;
core::map<core::stringw,core::stringw> properties;
};
}
}
#endif
#ifndef _CLIP_RECTS_H_
#define _CLIP_RECTS_H_
#include <rect.h>
namespace irr
{
//! Workaround for a bug in IVideoDriver::draw2DImage( ITexture* tex, rect<s32> dstRect, rect<s32> srcRect, rect<s32>* clip, SColor* colors, bool alpha )
//! It modifies dstRect and srcRect so the resulting dstRect is entirely inside the clipping rect.
//! srcRect is scaled so the same part of the image is displayed.
//! Returns false if dstRect is entirely outside clip, or true if at least some of it is inside.
inline bool clipRects( core::rect<s32>& dstRect, core::rect<s32>& srcRect, const core::rect<s32>& clip )
{
// Clip left side
if ( dstRect.UpperLeftCorner.X < clip.UpperLeftCorner.X )
{
s32 w = clip.UpperLeftCorner.X - dstRect.UpperLeftCorner.X;
f32 percentRemoved = (f32)w / (f32)dstRect.getWidth();
dstRect.UpperLeftCorner.X = clip.UpperLeftCorner.X;
srcRect.UpperLeftCorner.X += (s32)(percentRemoved * srcRect.getWidth());
}
// Clip top side
if ( dstRect.UpperLeftCorner.Y < clip.UpperLeftCorner.Y )
{
s32 w = clip.UpperLeftCorner.Y - dstRect.UpperLeftCorner.Y;
f32 percentRemoved = (f32)w / (f32)dstRect.getHeight();
dstRect.UpperLeftCorner.Y = clip.UpperLeftCorner.Y;
srcRect.UpperLeftCorner.Y += (s32)(percentRemoved * srcRect.getHeight());
}
// Clip right side
if ( dstRect.LowerRightCorner.X > clip.LowerRightCorner.X )
{
s32 w = dstRect.LowerRightCorner.X - clip.LowerRightCorner.X;
f32 percentRemoved = (f32)w / (f32)dstRect.getWidth();
dstRect.LowerRightCorner.X = clip.LowerRightCorner.X;
srcRect.LowerRightCorner.X -= (s32)(percentRemoved * srcRect.getWidth());
}
// Clip bottom side
if ( dstRect.LowerRightCorner.Y > clip.LowerRightCorner.Y )
{
s32 w = dstRect.LowerRightCorner.Y - clip.LowerRightCorner.Y;
f32 percentRemoved = (f32)w / (f32)dstRect.getHeight();
dstRect.LowerRightCorner.Y = clip.LowerRightCorner.Y;
srcRect.LowerRightCorner.Y -= (s32)(percentRemoved * srcRect.getHeight());
}
return ( dstRect.getWidth() > 0 && dstRect.getHeight() > 0 );
}
} // namespace irr
#endif
......@@ -9,6 +9,7 @@
#include "duelclient.h"
#include "netserver.h"
#include "single_mode.h"
#include <sstream>
#ifndef _WIN32
#include <sys/types.h>
......@@ -34,6 +35,15 @@ bool Game::Initialize() {
device = irr::createDeviceEx(params);
if(!device)
return false;
// Apply skin
if(gameConf.skin_index >= 0) {
skinSystem = new CGUISkinSystem("skin", device);
core::array<core::stringw> skins = skinSystem->listSkins();
if((size_t)gameConf.skin_index < skins.size()) {
int index = skins.size() - gameConf.skin_index - 1; // reverse index
skinSystem->applySkin(skins[index].c_str());
}
}
linePatternD3D = 0;
linePatternGL = 0x0f0f;
waitFrame = 0;
......@@ -1109,6 +1119,7 @@ void Game::LoadConfig() {
gameConf.window_height = 640;
gameConf.resize_popup_menu = false;
gameConf.chkEnablePScale = 1;
gameConf.skin_index = -1;
if(fp) {
while(fgets(linebuf, 256, fp)) {
sscanf(linebuf, "%s = %s", strbuf, valbuf);
......@@ -1194,6 +1205,8 @@ void Game::LoadConfig() {
gameConf.resize_popup_menu = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "enable_pendulum_scale")) {
gameConf.chkEnablePScale = atoi(valbuf);
} else if (!strcmp(strbuf, "skin_index")) {
gameConf.skin_index = atoi(valbuf);
} else {
// options allowing multiple words
sscanf(linebuf, "%s = %240[^\n]", strbuf, valbuf);
......@@ -1297,6 +1310,8 @@ void Game::LoadConfig() {
gameConf.resize_popup_menu = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "enable_pendulum_scale")) {
gameConf.chkEnablePScale = atoi(valbuf);
} else if (!strcmp(strbuf, "skin_index")) {
gameConf.skin_index = atoi(valbuf);
} else {
// options allowing multiple words
sscanf(linebuf, "%s = %240[^\n]", strbuf, valbuf);
......@@ -1381,6 +1396,7 @@ void Game::SaveConfig() {
fprintf(fp, "window_height = %d\n", gameConf.window_height);
fprintf(fp, "resize_popup_menu = %d\n", gameConf.resize_popup_menu ? 1 : 0);
fprintf(fp, "enable_pendulum_scale = %d\n", ((mainGame->chkEnablePScale->isChecked()) ? 1 : 0));
fprintf(fp, "skin_index = %d\n", gameConf.skin_index);
fclose(fp);
}
void Game::ShowCardInfo(int code, bool resize) {
......
......@@ -8,6 +8,7 @@
#include <unordered_map>
#include <vector>
#include <list>
#include "CGUISkinSystem/CGUISkinSystem.h"
namespace ygo {
......@@ -52,6 +53,7 @@ struct Config {
double music_volume;
int music_mode;
int chkEnablePScale;
int skin_index;
};
struct DuelInfo {
......@@ -220,6 +222,8 @@ public:
float xScale;
float yScale;
CGUISkinSystem *skinSystem;
ClientField dField;
DeckBuilder deckBuilder;
MenuHandler menuHandler;
......
......@@ -42,3 +42,4 @@ window_width = 1024
window_height = 640
resize_popup_menu = 0
enable_pendulum_scale = 1
skin_index = 1
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