Merge pull request #1031 from tomangelo2/dev

Added fonts configurability by a separate file
1008-fix
tomangelo 2018-07-25 19:51:55 +02:00 committed by GitHub
commit 5080cb46b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 262 additions and 60 deletions

View File

@ -149,6 +149,8 @@ set(BASE_SOURCES
common/error.h common/error.h
common/event.cpp common/event.cpp
common/event.h common/event.h
common/font_loader.h
common/font_loader.cpp
common/global.h common/global.h
common/image.cpp common/image.cpp
common/image.h common/image.h

115
src/common/font_loader.cpp Normal file
View File

@ -0,0 +1,115 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.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 "common/font_loader.h"
#include "common/logger.h"
#include "common/make_unique.h"
#include "common/resources/inputstream.h"
#include "common/resources/outputstream.h"
#include "common/system/system.h"
#include "graphics/engine/text.h"
#include <map>
#include <memory>
#include <utility>
#include <cstring>
#include <boost/property_tree/ini_parser.hpp>
#include <boost/regex.hpp>
namespace bp = boost::property_tree;
const std::map<Gfx::FontType, std::string> DEFAULT_FONT =
{
{ Gfx::FONT_COMMON, "dvu_sans.ttf" },
{ Gfx::FONT_COMMON_BOLD, "dvu_sans_bold.ttf" },
{ Gfx::FONT_COMMON_ITALIC, "dvu_sans_italic.ttf" },
{ Gfx::FONT_STUDIO, "dvu_sans_mono.ttf" },
{ Gfx::FONT_STUDIO_BOLD, "dvu_sans_mono_bold.ttf" },
{ Gfx::FONT_STUDIO_ITALIC, "dvu_sans_mono.ttf" }, //placeholder for future use, DejaVu Sans Mono doesn't have italic variant
{ Gfx::FONT_SATCOM, "dvu_sans.ttf" },
{ Gfx::FONT_SATCOM_BOLD, "dvu_sans_bold.ttf" },
{ Gfx::FONT_SATCOM_ITALIC, "dvu_sans_italic.ttf" },
};
const std::map<Gfx::FontType, std::string> FONT_TYPE =
{
{ Gfx::FONT_COMMON, "FontCommon" },
{ Gfx::FONT_COMMON_BOLD, "FontCommonBold" },
{ Gfx::FONT_COMMON_ITALIC, "FontCommonItalic" },
{ Gfx::FONT_STUDIO, "FontStudio" },
{ Gfx::FONT_STUDIO_BOLD, "FontStudioBold" },
{ Gfx::FONT_STUDIO_ITALIC, "FontStudioItalic" },
{ Gfx::FONT_SATCOM, "FontSatCom" },
{ Gfx::FONT_SATCOM_BOLD, "FontSatComBold" },
{ Gfx::FONT_SATCOM_ITALIC, "FontSatComItalic" },
};
CFontLoader::CFontLoader()
{
}
CFontLoader::~CFontLoader()
{
}
bool CFontLoader::Init()
{
try
{
std::unique_ptr<std::istream> stream;
auto inputStream = MakeUnique<CInputStream>("/fonts/fonts.ini");
bool good = inputStream->is_open();
stream = std::move(inputStream);
if (good)
{
bp::ini_parser::read_ini(*stream, m_propertyTree);
GetLogger()->Debug("Fonts config file loaded correctly. \n");
}
else
{
return false;
}
}
catch (std::exception & e)
{
GetLogger()->Error("Error on parsing config file: %s\n", e.what());
return false;
}
return true;
}
std::string CFontLoader::GetFont(Gfx::FontType type)
{
return std::string("/fonts/") + m_propertyTree.get<std::string>(GetFontType(type), GetDefaultFont(type));
}
std::string CFontLoader::GetDefaultFont(Gfx::FontType type) const
{
return DEFAULT_FONT.at(type);
}
std::string CFontLoader::GetFontType(Gfx::FontType type) const
{
return FONT_TYPE.at(type);
}

72
src/common/font_loader.h Normal file
View File

@ -0,0 +1,72 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.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
*/
/**
* \file common/font_loader.h
* \brief Class for loading fonts from /data/fonts/fonts.ini
*/
#pragma once
#include "common/singleton.h"
#include "graphics/engine/text.h"
#include <boost/property_tree/ptree.hpp>
#include <string>
/**
* \class CFontLoader
*
* \brief Class for loading config file
*
*/
class CFontLoader
{
public:
CFontLoader();
virtual ~CFontLoader();
/** Loads fonts.ini
* \return return true on success
*/
bool Init();
/** Reads given font from file
* \return return path to font file
*/
std::string GetFont(Gfx::FontType type);
/** Const type method to read filenames of fonts from defaultFont map
* used as a fallback if it wasn't possible to read font from fonts.ini
* \return return filename of default path
*/
std::string GetDefaultFont(Gfx::FontType type) const;
/** Const type method converting Gfx::FontType to string
* \return return id of font used in fonts.ini file
*/
std::string GetFontType(Gfx::FontType type) const;
private:
boost::property_tree::ptree m_propertyTree;
};

View File

@ -5118,7 +5118,7 @@ void CEngine::DrawStats()
if (!m_showStats) if (!m_showStats)
return; return;
float height = m_text->GetAscent(FONT_COLOBOT, 13.0f); float height = m_text->GetAscent(FONT_COMMON, 13.0f);
float width = 0.4f; float width = 0.4f;
const int TOTAL_LINES = 22; const int TOTAL_LINES = 22;
@ -5145,13 +5145,13 @@ void CEngine::DrawStats()
auto drawStatsLine = [&](const std::string& name, const std::string& value, const std::string& value2) auto drawStatsLine = [&](const std::string& name, const std::string& value, const std::string& value2)
{ {
if (!name.empty()) if (!name.empty())
m_text->DrawText(name+":", FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f)); m_text->DrawText(name+":", FONT_COMMON, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
pos.x += 0.25f; pos.x += 0.25f;
if (!value.empty()) if (!value.empty())
m_text->DrawText(value, FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f)); m_text->DrawText(value, FONT_COMMON, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
pos.x += 0.15f; pos.x += 0.15f;
if (!value2.empty()) if (!value2.empty())
m_text->DrawText(value2, FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_RIGHT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f)); m_text->DrawText(value2, FONT_COMMON, 12.0f, pos, 1.0f, TEXT_ALIGN_RIGHT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
pos.x -= 0.4f; pos.x -= 0.4f;
pos.y -= height; pos.y -= height;
}; };
@ -5219,8 +5219,8 @@ void CEngine::DrawTimer()
{ {
SetState(ENG_RSTATE_TEXT); SetState(ENG_RSTATE_TEXT);
Math::Point pos(0.98f, 0.98f-m_text->GetAscent(FONT_COLOBOT, 15.0f)); Math::Point pos(0.98f, 0.98f-m_text->GetAscent(FONT_COMMON, 15.0f));
m_text->DrawText(m_timerText, FONT_COLOBOT, 15.0f, pos, 1.0f, TEXT_ALIGN_RIGHT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f)); m_text->DrawText(m_timerText, FONT_COMMON, 15.0f, pos, 1.0f, TEXT_ALIGN_RIGHT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
} }
void CEngine::AddBaseObjTriangles(int baseObjRank, const std::vector<Gfx::ModelTriangle>& triangles) void CEngine::AddBaseObjTriangles(int baseObjRank, const std::vector<Gfx::ModelTriangle>& triangles)

View File

@ -3301,7 +3301,7 @@ void CParticle::DrawParticleCylinder(int i)
void CParticle::DrawParticleText(int i) void CParticle::DrawParticleText(int i)
{ {
CharTexture tex = m_engine->GetText()->GetCharTexture(static_cast<UTF8Char>(m_particle[i].text), FONT_COURIER, FONT_SIZE_BIG*2.0f); CharTexture tex = m_engine->GetText()->GetCharTexture(static_cast<UTF8Char>(m_particle[i].text), FONT_STUDIO, FONT_SIZE_BIG*2.0f);
if (tex.id == 0) return; if (tex.id == 0) return;
m_device->SetTexture(0, tex.id); m_device->SetTexture(0, tex.id);

View File

@ -22,6 +22,7 @@
#include "app/app.h" #include "app/app.h"
#include "common/font_loader.h"
#include "common/image.h" #include "common/image.h"
#include "common/logger.h" #include "common/logger.h"
#include "common/stringutils.h" #include "common/stringutils.h"
@ -174,7 +175,7 @@ CText::CText(CEngine* engine)
m_defaultSize = 12.0f; m_defaultSize = 12.0f;
m_tabSize = 4; m_tabSize = 4;
m_lastFontType = FONT_COLOBOT; m_lastFontType = FONT_COMMON;
m_lastFontSize = 0; m_lastFontSize = 0;
m_lastCachedFont = nullptr; m_lastCachedFont = nullptr;
@ -189,18 +190,23 @@ CText::~CText()
bool CText::Create() bool CText::Create()
{ {
CFontLoader fontLoader;
if (!fontLoader.Init())
{
GetLogger()->Warn("Error on parsing fonts config file: failed to open file\n");
}
if (TTF_Init() != 0) if (TTF_Init() != 0)
{ {
m_error = std::string("TTF_Init error: ") + std::string(TTF_GetError()); m_error = std::string("TTF_Init error: ") + std::string(TTF_GetError());
return false; return false;
} }
m_fonts[FONT_COLOBOT] = MakeUnique<MultisizeFont>("fonts/dvu_sans.ttf"); for (auto type : {FONT_COMMON, FONT_STUDIO, FONT_SATCOM})
m_fonts[FONT_COLOBOT_BOLD] = MakeUnique<MultisizeFont>("fonts/dvu_sans_bold.ttf"); {
m_fonts[FONT_COLOBOT_ITALIC] = MakeUnique<MultisizeFont>("fonts/dvu_sans_italic.ttf"); m_fonts[static_cast<Gfx::FontType>(type)] = MakeUnique<MultisizeFont>(fontLoader.GetFont(type));
m_fonts[static_cast<Gfx::FontType>(type|FONT_BOLD)] = MakeUnique<MultisizeFont>(fontLoader.GetFont(static_cast<Gfx::FontType>(type|FONT_BOLD)));
m_fonts[FONT_COURIER] = MakeUnique<MultisizeFont>("fonts/dvu_sans_mono.ttf"); m_fonts[static_cast<Gfx::FontType>(type|FONT_ITALIC)] = MakeUnique<MultisizeFont>(fontLoader.GetFont(static_cast<Gfx::FontType>(type|FONT_ITALIC)));
m_fonts[FONT_COURIER_BOLD] = MakeUnique<MultisizeFont>("fonts/dvu_sans_mono_bold.ttf"); }
for (auto it = m_fonts.begin(); it != m_fonts.end(); ++it) for (auto it = m_fonts.begin(); it != m_fonts.end(); ++it)
{ {
@ -218,7 +224,7 @@ void CText::Destroy()
m_fonts.clear(); m_fonts.clear();
m_lastCachedFont = nullptr; m_lastCachedFont = nullptr;
m_lastFontType = FONT_COLOBOT; m_lastFontType = FONT_COMMON;
m_lastFontSize = 0; m_lastFontSize = 0;
TTF_Quit(); TTF_Quit();
@ -253,7 +259,7 @@ void CText::FlushCache()
} }
m_lastCachedFont = nullptr; m_lastCachedFont = nullptr;
m_lastFontType = FONT_COLOBOT; m_lastFontType = FONT_COMMON;
m_lastFontSize = 0; m_lastFontSize = 0;
} }
@ -336,8 +342,8 @@ void CText::SizeText(const std::string &text, std::vector<FontMetaChar>::iterato
end.x -= sw; end.x -= sw;
} }
start.y -= GetDescent(FONT_COLOBOT, size); start.y -= GetDescent(FONT_COMMON, size);
end.y += GetAscent(FONT_COLOBOT, size); end.y += GetAscent(FONT_COMMON, size);
} }
void CText::SizeText(const std::string &text, FontType font, void CText::SizeText(const std::string &text, FontType font,
@ -417,7 +423,7 @@ float CText::GetStringWidth(const std::string &text,
unsigned int fmtIndex = 0; unsigned int fmtIndex = 0;
while (index < text.length()) while (index < text.length())
{ {
FontType font = FONT_COLOBOT; FontType font = FONT_COMMON;
if (format + fmtIndex != end) if (format + fmtIndex != end)
font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT); font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);
@ -464,7 +470,7 @@ float CText::GetCharWidth(UTF8Char ch, FontType font, float size, float offset)
if (font == FONT_BUTTON) if (font == FONT_BUTTON)
{ {
Math::IntPoint windowSize = m_engine->GetWindowSize(); Math::IntPoint windowSize = m_engine->GetWindowSize();
float height = GetHeight(FONT_COLOBOT, size); float height = GetHeight(FONT_COMMON, size);
float width = height*(static_cast<float>(windowSize.y)/windowSize.x); float width = height*(static_cast<float>(windowSize.y)/windowSize.x);
return width; return width;
} }
@ -506,7 +512,7 @@ int CText::GetCharWidthInt(UTF8Char ch, FontType font, float size, float offset)
if (font == FONT_BUTTON) if (font == FONT_BUTTON)
{ {
Math::IntPoint windowSize = m_engine->GetWindowSize(); Math::IntPoint windowSize = m_engine->GetWindowSize();
int height = GetHeightInt(FONT_COLOBOT, size); int height = GetHeightInt(FONT_COMMON, size);
int width = height*(static_cast<float>(windowSize.y)/windowSize.x); int width = height*(static_cast<float>(windowSize.y)/windowSize.x);
return width; return width;
} }
@ -552,7 +558,7 @@ int CText::Justify(const std::string &text, std::vector<FontMetaChar>::iterator
unsigned int fmtIndex = 0; unsigned int fmtIndex = 0;
while (index < text.length()) while (index < text.length())
{ {
FontType font = FONT_COLOBOT; FontType font = FONT_COMMON;
if (format + fmtIndex != end) if (format + fmtIndex != end)
font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT); font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);
@ -636,7 +642,7 @@ int CText::Detect(const std::string &text, std::vector<FontMetaChar>::iterator f
unsigned int fmtIndex = 0; unsigned int fmtIndex = 0;
while (index < text.length()) while (index < text.length())
{ {
FontType font = FONT_COLOBOT; FontType font = FONT_COMMON;
if (format + fmtIndex != end) if (format + fmtIndex != end)
font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT); font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);
@ -773,7 +779,7 @@ void CText::DrawString(const std::string &text, std::vector<FontMetaChar>::itera
StringToUTFCharList(text, chars, format, end); StringToUTFCharList(text, chars, format, end);
for (auto it = chars.begin(); it != chars.end(); ++it) for (auto it = chars.begin(); it != chars.end(); ++it)
{ {
FontType font = FONT_COLOBOT; FontType font = FONT_COMMON;
if (format + fmtIndex != end) if (format + fmtIndex != end)
font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT); font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);
@ -846,7 +852,7 @@ void CText::DrawString(const std::string &text, std::vector<FontMetaChar>::itera
if (eol != 0) if (eol != 0)
{ {
FontType font = FONT_COLOBOT; FontType font = FONT_COMMON;
UTF8Char ch = TranslateSpecialChar(eol); UTF8Char ch = TranslateSpecialChar(eol);
color = Color(1.0f, 0.0f, 0.0f); color = Color(1.0f, 0.0f, 0.0f);
DrawCharAndAdjustPos(ch, font, size, pos, color); DrawCharAndAdjustPos(ch, font, size, pos, color);
@ -887,7 +893,7 @@ void CText::StringToUTFCharList(const std::string &text, std::vector<UTF8Char> &
{ {
UTF8Char ch; UTF8Char ch;
FontType font = FONT_COLOBOT; FontType font = FONT_COMMON;
if (format + index != end) if (format + index != end)
font = static_cast<FontType>(*(format + index) & FONT_MASK_FONT); font = static_cast<FontType>(*(format + index) & FONT_MASK_FONT);
@ -993,7 +999,7 @@ void CText::DrawCharAndAdjustPos(UTF8Char ch, FontType font, float size, Math::I
if (font == FONT_BUTTON) if (font == FONT_BUTTON)
{ {
Math::IntPoint windowSize = m_engine->GetWindowSize(); Math::IntPoint windowSize = m_engine->GetWindowSize();
int height = GetHeightInt(FONT_COLOBOT, size); int height = GetHeightInt(FONT_COMMON, size);
int width = height * (static_cast<float>(windowSize.y)/windowSize.x); int width = height * (static_cast<float>(windowSize.y)/windowSize.x);
Math::IntPoint p1(pos.x, pos.y - height); Math::IntPoint p1(pos.x, pos.y - height);

View File

@ -77,18 +77,25 @@ enum FontType
FONT_ITALIC = 0x08, FONT_ITALIC = 0x08,
//! Default colobot font used for interface //! Default colobot font used for interface
FONT_COLOBOT = 0x00, FONT_COMMON = 0x00,
//! Alias for bold colobot font //! Alias for bold colobot font
FONT_COLOBOT_BOLD = FONT_COLOBOT | FONT_BOLD, FONT_COMMON_BOLD = FONT_COMMON | FONT_BOLD,
//! Alias for italic colobot font //! Alias for italic colobot font
FONT_COLOBOT_ITALIC = FONT_COLOBOT | FONT_ITALIC, FONT_COMMON_ITALIC = FONT_COMMON | FONT_ITALIC,
//! Courier (monospace) font used mainly in code editor (only regular & bold) //! Studio font used mainly in code editor
FONT_COURIER = 0x01, FONT_STUDIO = 0x01,
//! Alias for bold courier font //! Alias for bold studio font
FONT_COURIER_BOLD = FONT_COURIER | FONT_BOLD, FONT_STUDIO_BOLD = FONT_STUDIO | FONT_BOLD,
//! Alias for italic studio font (at this point not used anywhere)
FONT_STUDIO_ITALIC = FONT_STUDIO | FONT_ITALIC,
// 0x02 left for possible another font //! SatCom font used for interface (currently bold and italic wariants aren't used anywhere)
FONT_SATCOM = 0x02,
//! Alias for bold satcom font
FONT_SATCOM_BOLD = FONT_SATCOM | FONT_BOLD,
//! Alias for italic satcom font
FONT_SATCOM_ITALIC = FONT_SATCOM | FONT_ITALIC,
//! Pseudo-font loaded from textures for buttons, icons, etc. //! Pseudo-font loaded from textures for buttons, icons, etc.
FONT_BUTTON = 0x03, FONT_BUTTON = 0x03,

View File

@ -589,7 +589,7 @@ void CRobotMain::ChangePhase(Phase phase)
ddim.x = dim.x*15; ddim.y = dim.y*3.0f; ddim.x = dim.x*15; ddim.y = dim.y*3.0f;
pe = m_interface->CreateEdit(pos, ddim, 0, EVENT_EDIT0); pe = m_interface->CreateEdit(pos, ddim, 0, EVENT_EDIT0);
pe->SetGenericMode(true); pe->SetGenericMode(true);
pe->SetFontType(Gfx::FONT_COLOBOT); pe->SetFontType(Gfx::FONT_COMMON);
pe->SetEditCap(false); pe->SetEditCap(false);
pe->SetHighlightCap(false); pe->SetHighlightCap(false);
pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/win.txt")); pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/win.txt"));
@ -2127,7 +2127,7 @@ void CRobotMain::CreateTooltip(Math::Point pos, const std::string& text)
Math::Point start, end; Math::Point start, end;
m_engine->GetText()->SizeText(text, Gfx::FONT_COLOBOT, Gfx::FONT_SIZE_SMALL, m_engine->GetText()->SizeText(text, Gfx::FONT_COMMON, Gfx::FONT_SIZE_SMALL,
corner, Gfx::TEXT_ALIGN_LEFT, corner, Gfx::TEXT_ALIGN_LEFT,
start, end); start, end);
@ -2162,7 +2162,7 @@ void CRobotMain::CreateTooltip(Math::Point pos, const std::string& text)
pw->SetState(Ui::STATE_SHADOW); pw->SetState(Ui::STATE_SHADOW);
pw->SetTrashEvent(false); pw->SetTrashEvent(false);
pos.y -= m_engine->GetText()->GetHeight(Gfx::FONT_COLOBOT, Gfx::FONT_SIZE_SMALL) / 2.0f; pos.y -= m_engine->GetText()->GetHeight(Gfx::FONT_COMMON, Gfx::FONT_SIZE_SMALL) / 2.0f;
pw->CreateLabel(pos, dim, -1, EVENT_LABEL2, text); pw->CreateLabel(pos, dim, -1, EVENT_LABEL2, text);
} }
} }
@ -5913,7 +5913,7 @@ void CRobotMain::CreateCodeBattleInterface()
int numTeams = m_scoreboard ? GetAllTeams().size() : 0; int numTeams = m_scoreboard ? GetAllTeams().size() : 0;
assert(numTeams < EVENT_SCOREBOARD_MAX-EVENT_SCOREBOARD+1); assert(numTeams < EVENT_SCOREBOARD_MAX-EVENT_SCOREBOARD+1);
float textHeight = m_engine->GetText()->GetHeight(Gfx::FONT_COLOBOT, Gfx::FONT_SIZE_SMALL); float textHeight = m_engine->GetText()->GetHeight(Gfx::FONT_COMMON, Gfx::FONT_SIZE_SMALL);
//window //window
ddim.x = 100.0f/640.0f; ddim.x = 100.0f/640.0f;

View File

@ -44,7 +44,7 @@ CControl::CControl()
m_eventType = EVENT_NULL; m_eventType = EVENT_NULL;
m_state = STATE_ENABLE|STATE_VISIBLE|STATE_GLINT; m_state = STATE_ENABLE|STATE_VISIBLE|STATE_GLINT;
m_fontSize = Gfx::FONT_SIZE_SMALL; m_fontSize = Gfx::FONT_SIZE_SMALL;
m_fontType = Gfx::FONT_COLOBOT; m_fontType = Gfx::FONT_COMMON;
m_textAlign = Gfx::TEXT_ALIGN_CENTER; //instead m_justify m_textAlign = Gfx::TEXT_ALIGN_CENTER; //instead m_justify
m_bFocus = false; m_bFocus = false;
m_bCapture = false; m_bCapture = false;

View File

@ -109,7 +109,7 @@ CEdit::CEdit()
{ {
m_len = 0; m_len = 0;
m_fontType = Gfx::FONT_COURIER; m_fontType = Gfx::FONT_STUDIO;
m_bEdit = true; m_bEdit = true;
m_bHilite = true; m_bHilite = true;
m_bInsideScroll = true; m_bInsideScroll = true;
@ -1326,13 +1326,13 @@ void CEdit::SetText(const std::string& text, bool bNew)
if ( text[i+1] == 'n' ) // normal ? if ( text[i+1] == 'n' ) // normal ?
{ {
font &= ~Gfx::FONT_MASK_FONT; font &= ~Gfx::FONT_MASK_FONT;
font |= Gfx::FONT_COLOBOT; font |= Gfx::FONT_COMMON;
i += 2; i += 2;
} }
else if ( text[i+1] == 'c' ) // cbot ? else if ( text[i+1] == 'c' ) // cbot ?
{ {
font &= ~Gfx::FONT_MASK_FONT; font &= ~Gfx::FONT_MASK_FONT;
font |= Gfx::FONT_COURIER; font |= Gfx::FONT_STUDIO;
i += 2; i += 2;
} }
else if ( text[i+1] == 'b' ) // big title ? else if ( text[i+1] == 'b' ) // big title ?
@ -1522,7 +1522,7 @@ bool CEdit::ReadText(std::string filename)
if ( m_bSoluce || !bInSoluce ) if ( m_bSoluce || !bInSoluce )
{ {
font &= ~Gfx::FONT_MASK_FONT; font &= ~Gfx::FONT_MASK_FONT;
font |= Gfx::FONT_COLOBOT; font |= Gfx::FONT_COMMON;
inCbot = false; inCbot = false;
} }
i += 3; i += 3;
@ -1532,7 +1532,7 @@ bool CEdit::ReadText(std::string filename)
if ( m_bSoluce || !bInSoluce ) if ( m_bSoluce || !bInSoluce )
{ {
font &= ~Gfx::FONT_MASK_FONT; font &= ~Gfx::FONT_MASK_FONT;
font |= Gfx::FONT_COURIER; font |= Gfx::FONT_STUDIO;
if (!inCbot) if (!inCbot)
{ {
if (inCbotBackground) if (inCbotBackground)
@ -1636,7 +1636,7 @@ bool CEdit::ReadText(std::string filename)
//? iWidth = m_lineHeight*RetValueParam(buffer.data()+i+7, 1); //? iWidth = m_lineHeight*RetValueParam(buffer.data()+i+7, 1);
iWidth = static_cast<float>(GetValueParam(buffer.data()+i+7, 1)); iWidth = static_cast<float>(GetValueParam(buffer.data()+i+7, 1));
iWidth *= m_engine->GetText()->GetHeight(Gfx::FONT_COLOBOT, Gfx::FONT_SIZE_SMALL); iWidth *= m_engine->GetText()->GetHeight(Gfx::FONT_COMMON, Gfx::FONT_SIZE_SMALL);
iLines = GetValueParam(buffer.data()+i+7, 2); iLines = GetValueParam(buffer.data()+i+7, 2);
// A part of image per line of text. // A part of image per line of text.

View File

@ -65,7 +65,7 @@ void CDebugMenu::ToggleInterface()
{ {
CreateInterface(); CreateInterface();
CLabel* pl = m_interface->CreateLabel(Math::Point(0.0f, 0.9f), Math::Point(1.0f, 0.1f), -1, EVENT_LABEL19, "??"); CLabel* pl = m_interface->CreateLabel(Math::Point(0.0f, 0.9f), Math::Point(1.0f, 0.1f), -1, EVENT_LABEL19, "??");
pl->SetFontType(Gfx::FONT_COURIER); pl->SetFontType(Gfx::FONT_STUDIO);
} }
else else
{ {

View File

@ -383,7 +383,7 @@ void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluc
edit->SetState(STATE_SHADOW); edit->SetState(STATE_SHADOW);
edit->SetMultiFont(true); edit->SetMultiFont(true);
edit->SetMaxChar(10000); edit->SetMaxChar(10000);
edit->SetFontType(Gfx::FONT_COLOBOT); edit->SetFontType(Gfx::FONT_SATCOM);
edit->SetSoluceMode(bSoluce); edit->SetSoluceMode(bSoluce);
edit->ReadText(filename.c_str()); edit->ReadText(filename.c_str());
edit->HyperHome(filename.c_str()); edit->HyperHome(filename.c_str());

View File

@ -197,7 +197,7 @@ void CDisplayText::DisplayText(const char *text, Math::Vector goal, float height
} }
hBox = 0.045f; hBox = 0.045f;
hLine = m_engine->GetText()->GetHeight(Gfx::FONT_COLOBOT, FONTSIZE); hLine = m_engine->GetText()->GetHeight(Gfx::FONT_COMMON, FONTSIZE);
nLine = 0; nLine = 0;
for ( i=0 ; i<MAXDTLINE ; i++ ) for ( i=0 ; i<MAXDTLINE ; i++ )

View File

@ -323,7 +323,7 @@ void CMainDialog::StartInformation(const std::string& title, const std::string&
ddim.x = 1.00f; ddim.x = 1.00f;
ddim.y = 0.05f; ddim.y = 0.05f;
pl = pw->CreateLabel(pos, ddim, -1, EVENT_DIALOG_LABEL, text); pl = pw->CreateLabel(pos, ddim, -1, EVENT_DIALOG_LABEL, text);
pl->SetFontType(Gfx::FONT_COLOBOT_BOLD); pl->SetFontType(Gfx::FONT_COMMON_BOLD);
//TODO: Add \n support in CLabel //TODO: Add \n support in CLabel
pos.y -= ddim.y; pos.y -= ddim.y;
pl = pw->CreateLabel(pos, ddim, -1, EVENT_DIALOG_LABEL1, details); pl = pw->CreateLabel(pos, ddim, -1, EVENT_DIALOG_LABEL1, details);

View File

@ -71,7 +71,7 @@ void CScreen::CreateVersionDisplay()
ddim.x = 90.0f/640.0f; ddim.x = 90.0f/640.0f;
ddim.y = 10.0f/480.0f; ddim.y = 10.0f/480.0f;
CLabel* pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, COLOBOT_VERSION_DISPLAY); CLabel* pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, COLOBOT_VERSION_DISPLAY);
pl->SetFontType(Gfx::FONT_COURIER); pl->SetFontType(Gfx::FONT_STUDIO);
pl->SetFontSize(9.0f); pl->SetFontSize(9.0f);
} }
} }

View File

@ -85,7 +85,7 @@ void CScreenIOWrite::CreateInterface()
ddim.y = 18.0f/480.0f; ddim.y = 18.0f/480.0f;
pe = pw->CreateEdit(pos, ddim, 0, EVENT_INTERFACE_IONAME); pe = pw->CreateEdit(pos, ddim, 0, EVENT_INTERFACE_IONAME);
pe->SetState(STATE_SHADOW); pe->SetState(STATE_SHADOW);
pe->SetFontType(Gfx::FONT_COLOBOT); pe->SetFontType(Gfx::FONT_COMMON);
pe->SetMaxChar(35); pe->SetMaxChar(35);
IOReadName(); IOReadName();

View File

@ -159,7 +159,7 @@ void CScreenMainMenu::CreateInterface()
pg->SetState(STATE_SHADOW); pg->SetState(STATE_SHADOW);
pos.y -= 5.0f/480.0f; pos.y -= 5.0f/480.0f;
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, "TerranovaTeam"); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, "TerranovaTeam");
pl->SetFontType(Gfx::FONT_COURIER); pl->SetFontType(Gfx::FONT_STUDIO);
pl->SetFontSize(Gfx::FONT_SIZE_SMALL); pl->SetFontSize(Gfx::FONT_SIZE_SMALL);
// SatCom button // SatCom button

View File

@ -61,7 +61,7 @@ void CScreenQuit::CreateInterface()
pe->SetGenericMode(true); pe->SetGenericMode(true);
pe->SetEditCap(false); pe->SetEditCap(false);
pe->SetHighlightCap(false); pe->SetHighlightCap(false);
pe->SetFontType(Gfx::FONT_COURIER); pe->SetFontType(Gfx::FONT_STUDIO);
pe->SetFontSize(Gfx::FONT_SIZE_SMALL); pe->SetFontSize(Gfx::FONT_SIZE_SMALL);
pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/authors.txt")); pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/authors.txt"));
@ -71,13 +71,13 @@ void CScreenQuit::CreateInterface()
ddim.y = 16.0f/480.0f; ddim.y = 16.0f/480.0f;
GetResource(RES_TEXT, RT_GENERIC_DEV1, name); GetResource(RES_TEXT, RT_GENERIC_DEV1, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name);
pl->SetFontType(Gfx::FONT_COURIER); pl->SetFontType(Gfx::FONT_STUDIO);
pl->SetFontSize(Gfx::FONT_SIZE_SMALL); pl->SetFontSize(Gfx::FONT_SIZE_SMALL);
pos.y = 13.0f/480.0f; pos.y = 13.0f/480.0f;
GetResource(RES_TEXT, RT_GENERIC_DEV2, name); GetResource(RES_TEXT, RT_GENERIC_DEV2, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL2, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL2, name);
pl->SetFontType(Gfx::FONT_COURIER); pl->SetFontType(Gfx::FONT_STUDIO);
pl->SetFontSize(Gfx::FONT_SIZE_SMALL); pl->SetFontSize(Gfx::FONT_SIZE_SMALL);
pos.x = 355.0f/640.0f; pos.x = 355.0f/640.0f;
@ -86,13 +86,13 @@ void CScreenQuit::CreateInterface()
ddim.y = 16.0f/480.0f; ddim.y = 16.0f/480.0f;
GetResource(RES_TEXT, RT_GENERIC_EDIT1, name); GetResource(RES_TEXT, RT_GENERIC_EDIT1, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL3, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL3, name);
pl->SetFontType(Gfx::FONT_COURIER); pl->SetFontType(Gfx::FONT_STUDIO);
pl->SetFontSize(Gfx::FONT_SIZE_SMALL); pl->SetFontSize(Gfx::FONT_SIZE_SMALL);
pos.y = 13.0f/480.0f; pos.y = 13.0f/480.0f;
GetResource(RES_TEXT, RT_GENERIC_EDIT2, name); GetResource(RES_TEXT, RT_GENERIC_EDIT2, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL4, name); pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL4, name);
pl->SetFontType(Gfx::FONT_COURIER); pl->SetFontType(Gfx::FONT_STUDIO);
pl->SetFontSize(Gfx::FONT_SIZE_SMALL); pl->SetFontSize(Gfx::FONT_SIZE_SMALL);
pos.x = 306.0f/640.0f; pos.x = 306.0f/640.0f;

View File

@ -627,7 +627,7 @@ void CStudio::StartEditScript(CScript *script, std::string name, Program* progra
edit->SetState(STATE_SHADOW); edit->SetState(STATE_SHADOW);
edit->SetInsideScroll(false); edit->SetInsideScroll(false);
//? if ( m_bRunning ) edit->SetEdit(false); //? if ( m_bRunning ) edit->SetEdit(false);
edit->SetFontType(Gfx::FONT_COURIER); edit->SetFontType(Gfx::FONT_STUDIO);
edit->SetFontStretch(1.0f); edit->SetFontStretch(1.0f);
edit->SetDisplaySpec(true); edit->SetDisplaySpec(true);
edit->SetAutoIndent(m_engine->GetEditIndentMode()); edit->SetAutoIndent(m_engine->GetEditIndentMode());
@ -639,7 +639,7 @@ void CStudio::StartEditScript(CScript *script, std::string name, Program* progra
list = pw->CreateList(pos, dim, 1, EVENT_STUDIO_LIST, 1.2f); list = pw->CreateList(pos, dim, 1, EVENT_STUDIO_LIST, 1.2f);
list->SetState(STATE_SHADOW); list->SetState(STATE_SHADOW);
list->SetFontType(Gfx::FONT_COURIER); list->SetFontType(Gfx::FONT_STUDIO);
list->SetSelectCap(false); list->SetSelectCap(false);
list->SetFontSize(Gfx::FONT_SIZE_SMALL*0.85f); list->SetFontSize(Gfx::FONT_SIZE_SMALL*0.85f);
//? list->SetFontStretch(1.0f); //? list->SetFontStretch(1.0f);