-- [Add] Added fonts, I am using SDL_ttf for now as it is quick and easy.
This is the last you are getting from me untill I have something at least visible to demo.
This commit is contained in:
parent
ae43dab131
commit
41979df693
BIN
Data/Media/Fonts/Enigma_2.ttf
Normal file
BIN
Data/Media/Fonts/Enigma_2.ttf
Normal file
Binary file not shown.
BIN
Data/Media/Fonts/Enigma_2i.ttf
Normal file
BIN
Data/Media/Fonts/Enigma_2i.ttf
Normal file
Binary file not shown.
203
Data/Media/Fonts/Enigma_legal_en.txt
Normal file
203
Data/Media/Fonts/Enigma_legal_en.txt
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
The font included in this zip file:
|
||||||
|
|
||||||
|
Enigma__2.ttf (Enigmatic)
|
||||||
|
Enigma_2i.ttf (Enigmatic Italic)
|
||||||
|
|
||||||
|
is freeware, and can be used for any sort of work, from websites to term
|
||||||
|
papers to ad campaigns. If you use it in anything I'm likely to see and
|
||||||
|
recognize, I'd appreciate hearing about it.
|
||||||
|
|
||||||
|
This zip file can also be distributed freely, so long as no files are
|
||||||
|
removed from it, and so long as the files are not altered.
|
||||||
|
|
||||||
|
Otherwise, you can modify the font however you like, but you must
|
||||||
|
completely rename the new font, and the resulting font must be
|
||||||
|
freeware, as stated in Part 4 of the DSL below.
|
||||||
|
|
||||||
|
My name is Darren Rigby, and I created Enigmatic and Enigmatic Italic.
|
||||||
|
I've copylefted them. You can contact me at dart@puzzlers.org.
|
||||||
|
|
||||||
|
|
||||||
|
FULL LICENCE
|
||||||
|
------------
|
||||||
|
DESIGN SCIENCE LICENSE
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
Copyright © 1999-2001 Michael Stutz <stutz@dsl.org>
|
||||||
|
Verbatim copying of this document is permitted, in any medium.
|
||||||
|
|
||||||
|
0. PREAMBLE.
|
||||||
|
|
||||||
|
Copyright law gives certain exclusive rights to the author of a work,
|
||||||
|
including the rights to copy, modify and distribute the work (the
|
||||||
|
"reproductive," "adaptative," and "distribution" rights).
|
||||||
|
|
||||||
|
The idea of "copyleft" is to willfully revoke the exclusivity of those
|
||||||
|
rights under certain terms and conditions, so that anyone can copy and
|
||||||
|
distribute the work or properly attributed derivative works, while all
|
||||||
|
copies remain under the same terms and conditions as the original.
|
||||||
|
|
||||||
|
The intent of this license is to be a general "copyleft" that can be
|
||||||
|
applied to any kind of work that has protection under copyright. This
|
||||||
|
license states those certain conditions under which a work published
|
||||||
|
under its terms may be copied, distributed, and modified.
|
||||||
|
|
||||||
|
Whereas "design science" is a strategy for the development of
|
||||||
|
artifacts as a way to reform the environment (not people) and
|
||||||
|
subsequently improve the universal standard of living, this Design
|
||||||
|
Science License was written and deployed as a strategy for promoting
|
||||||
|
the progress of science and art through reform of the environment.
|
||||||
|
|
||||||
|
1. DEFINITIONS.
|
||||||
|
|
||||||
|
"License" shall mean this Design Science License. The License applies
|
||||||
|
to any work which contains a notice placed by the work's copyright
|
||||||
|
holder stating that it is published under the terms of this Design
|
||||||
|
Science License.
|
||||||
|
|
||||||
|
"Work" shall mean such an aforementioned work. The License also
|
||||||
|
applies to the output of the Work, only if said output constitutes a
|
||||||
|
"derivative work" of the licensed Work as defined by copyright law.
|
||||||
|
|
||||||
|
"Object Form" shall mean an executable or performable form of the
|
||||||
|
Work, being an embodiment of the Work in some tangible medium.
|
||||||
|
|
||||||
|
"Source Data" shall mean the origin of the Object Form, being the
|
||||||
|
entire, machine-readable, preferred form of the Work for copying and
|
||||||
|
for human modification (usually the language, encoding or format in
|
||||||
|
which composed or recorded by the Author); plus any accompanying
|
||||||
|
files, scripts or other data necessary for installation, configuration
|
||||||
|
or compilation of the Work.
|
||||||
|
|
||||||
|
(Examples of "Source Data" include, but are not limited to, the
|
||||||
|
following: if the Work is an image file composed and edited in PNG
|
||||||
|
format, then the original PNG source file is the Source Data; if the
|
||||||
|
Work is an MPEG 1.0 layer 3 digital audio recording made from a WAV
|
||||||
|
format audio file recording of an analog source, then the original WAV
|
||||||
|
file is the Source Data; if the Work was composed as an unformatted
|
||||||
|
plaintext file, then that file is the Source Data; if the Work was
|
||||||
|
composed in LaTeX, the LaTeX file(s) and any image files and/or custom
|
||||||
|
macros necessary for compilation constitute the Source Data.)
|
||||||
|
|
||||||
|
"Author" shall mean the copyright holder(s) of the Work.
|
||||||
|
|
||||||
|
The individual licensees are referred to as "you."
|
||||||
|
|
||||||
|
2. RIGHTS AND COPYRIGHT.
|
||||||
|
|
||||||
|
The Work is copyrighted by the Author. All rights to the Work are
|
||||||
|
reserved by the Author, except as specifically described below. This
|
||||||
|
License describes the terms and conditions under which the Author
|
||||||
|
permits you to copy, distribute and modify copies of the Work.
|
||||||
|
|
||||||
|
In addition, you may refer to the Work, talk about it, and (as
|
||||||
|
dictated by "fair use") quote from it, just as you would any
|
||||||
|
copyrighted material under copyright law.
|
||||||
|
|
||||||
|
Your right to operate, perform, read or otherwise interpret and/or
|
||||||
|
execute the Work is unrestricted; however, you do so at your own risk,
|
||||||
|
because the Work comes WITHOUT ANY WARRANTY -- see Section 7 ("NO
|
||||||
|
WARRANTY") below.
|
||||||
|
|
||||||
|
3. COPYING AND DISTRIBUTION.
|
||||||
|
|
||||||
|
Permission is granted to distribute, publish or otherwise present
|
||||||
|
verbatim copies of the entire Source Data of the Work, in any medium,
|
||||||
|
provided that full copyright notice and disclaimer of warranty, where
|
||||||
|
applicable, is conspicuously published on all copies, and a copy of
|
||||||
|
this License is distributed along with the Work.
|
||||||
|
|
||||||
|
Permission is granted to distribute, publish or otherwise present
|
||||||
|
copies of the Object Form of the Work, in any medium, under the terms
|
||||||
|
for distribution of Source Data above and also provided that one of
|
||||||
|
the following additional conditions are met:
|
||||||
|
|
||||||
|
(a) The Source Data is included in the same distribution, distributed
|
||||||
|
under the terms of this License; or
|
||||||
|
|
||||||
|
(b) A written offer is included with the distribution, valid for at
|
||||||
|
least three years or for as long as the distribution is in print
|
||||||
|
(whichever is longer), with a publicly-accessible address (such as a
|
||||||
|
URL on the Internet) where, for a charge not greater than
|
||||||
|
transportation and media costs, anyone may receive a copy of the
|
||||||
|
Source Data of the Work distributed according to the section above; or
|
||||||
|
|
||||||
|
(c) A third party's written offer for obtaining the Source Data at no
|
||||||
|
cost, as described in paragraph (b) above, is included with the
|
||||||
|
distribution. This option is valid only if you are a non-commercial
|
||||||
|
party, and only if you received the Object Form of the Work along with
|
||||||
|
such an offer.
|
||||||
|
|
||||||
|
You may copy and distribute the Work either gratis or for a fee, and
|
||||||
|
if desired, you may offer warranty protection for the Work.
|
||||||
|
|
||||||
|
The aggregation of the Work with other works that are not based on the
|
||||||
|
Work -- such as but not limited to inclusion in a publication,
|
||||||
|
broadcast, compilation, or other media -- does not bring the other
|
||||||
|
works in the scope of the License; nor does such aggregation void the
|
||||||
|
terms of the License for the Work.
|
||||||
|
|
||||||
|
4. MODIFICATION.
|
||||||
|
|
||||||
|
Permission is granted to modify or sample from a copy of the Work,
|
||||||
|
producing a derivative work, and to distribute the derivative work
|
||||||
|
under the terms described in the section for distribution above,
|
||||||
|
provided that the following terms are met:
|
||||||
|
|
||||||
|
(a) The new, derivative work is published under the terms of this
|
||||||
|
License.
|
||||||
|
|
||||||
|
(b) The derivative work is given a new name, so that its name or title
|
||||||
|
cannot be confused with the Work, or with a version of the Work, in
|
||||||
|
any way.
|
||||||
|
|
||||||
|
(c) Appropriate authorship credit is given: for the differences
|
||||||
|
between the Work and the new derivative work, authorship is attributed
|
||||||
|
to you, while the material sampled or used from the Work remains
|
||||||
|
attributed to the original Author; appropriate notice must be included
|
||||||
|
with the new work indicating the nature and the dates of any
|
||||||
|
modifications of the Work made by you.
|
||||||
|
|
||||||
|
5. NO RESTRICTIONS.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the Work or any of its
|
||||||
|
derivative works beyond those restrictions described in this License.
|
||||||
|
|
||||||
|
6. ACCEPTANCE.
|
||||||
|
|
||||||
|
Copying, distributing or modifying the Work (including but not limited
|
||||||
|
to sampling from the Work in a new work) indicates acceptance of these
|
||||||
|
terms. If you do not follow the terms of this License, any rights
|
||||||
|
granted to you by the License are null and void. The copying,
|
||||||
|
distribution or modification of the Work outside of the terms
|
||||||
|
described in this License is expressly prohibited by law.
|
||||||
|
|
||||||
|
If for any reason, conditions are imposed on you that forbid you to
|
||||||
|
fulfill the conditions of this License, you may not copy, distribute
|
||||||
|
or modify the Work at all.
|
||||||
|
|
||||||
|
If any part of this License is found to be in conflict with the law,
|
||||||
|
that part shall be interpreted in its broadest meaning consistent with
|
||||||
|
the law, and no other parts of the License shall be affected.
|
||||||
|
|
||||||
|
7. NO WARRANTY.
|
||||||
|
|
||||||
|
THE WORK IS PROVIDED "AS IS," AND COMES WITH ABSOLUTELY NO WARRANTY,
|
||||||
|
EXPRESS OR IMPLIED, TO THE EXTENT PERMITTED BY APPLICABLE LAW,
|
||||||
|
INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
8. DISCLAIMER OF LIABILITY.
|
||||||
|
|
||||||
|
IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||||
|
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
IN ANY WAY OUT OF THE USE OF THIS WORK, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
BIN
Data/Media/error.png
Normal file
BIN
Data/Media/error.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 235 B |
@ -1,6 +1,6 @@
|
|||||||
#############################################################################
|
#############################################################################
|
||||||
# Makefile for building: Unuk-QT
|
# Makefile for building: Unuk-QT
|
||||||
# Generated by qmake (2.01a) (Qt 4.7.3) on: Wed Nov 9 13:10:07 2011
|
# Generated by qmake (2.01a) (Qt 4.7.3) on: Wed Nov 9 15:15:42 2011
|
||||||
# Project: Unuk-QT.pro
|
# Project: Unuk-QT.pro
|
||||||
# Template: app
|
# Template: app
|
||||||
# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro
|
# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro
|
||||||
@ -53,7 +53,8 @@ SOURCES = ../src/libUnuk/Debug.cpp \
|
|||||||
../src/libUnuk/Rect.cpp \
|
../src/libUnuk/Rect.cpp \
|
||||||
../src/libUnuk/ImageLoader.cpp \
|
../src/libUnuk/ImageLoader.cpp \
|
||||||
../src/libUnuk/TextureManager.cpp \
|
../src/libUnuk/TextureManager.cpp \
|
||||||
../src/libUnuk/Texture.cpp
|
../src/libUnuk/Texture.cpp \
|
||||||
|
../src/libUnuk/Text.cpp
|
||||||
OBJECTS = Debug.o \
|
OBJECTS = Debug.o \
|
||||||
main.o \
|
main.o \
|
||||||
Input.o \
|
Input.o \
|
||||||
@ -64,7 +65,8 @@ OBJECTS = Debug.o \
|
|||||||
Rect.o \
|
Rect.o \
|
||||||
ImageLoader.o \
|
ImageLoader.o \
|
||||||
TextureManager.o \
|
TextureManager.o \
|
||||||
Texture.o
|
Texture.o \
|
||||||
|
Text.o
|
||||||
DIST = /usr/share/qt4/mkspecs/common/g++.conf \
|
DIST = /usr/share/qt4/mkspecs/common/g++.conf \
|
||||||
/usr/share/qt4/mkspecs/common/unix.conf \
|
/usr/share/qt4/mkspecs/common/unix.conf \
|
||||||
/usr/share/qt4/mkspecs/common/linux.conf \
|
/usr/share/qt4/mkspecs/common/linux.conf \
|
||||||
@ -167,7 +169,7 @@ qmake: FORCE
|
|||||||
|
|
||||||
dist:
|
dist:
|
||||||
@$(CHK_DIR_EXISTS) .tmp/Unuk-QT1.0.0 || $(MKDIR) .tmp/Unuk-QT1.0.0
|
@$(CHK_DIR_EXISTS) .tmp/Unuk-QT1.0.0 || $(MKDIR) .tmp/Unuk-QT1.0.0
|
||||||
$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/Unuk-QT1.0.0/ && $(COPY_FILE) --parents ../src/libUnuk/Debug.h ../src/Libs/wglext.h ../src/Libs/glxext.h ../src/libUnuk/Input.h ../src/libUnuk/Rect.h ../src/libUnuk/Timer.h ../src/libUnuk/Font.h ../Constants.h ../src/Unuk/Constants.h ../src/libUnuk/ApplySurface.h ../src/Unuk/Globals.h ../src/libUnuk/ImageLoader.h ../src/libUnuk/TextureManager.h ../src/libUnuk/Texture.h .tmp/Unuk-QT1.0.0/ && $(COPY_FILE) --parents ../src/libUnuk/Debug.cpp ../src/Unuk/main.cpp ../src/libUnuk/Input.cpp ../src/libUnuk/Timer.cpp ../src/libUnuk/Font.cpp ../src/libUnuk/ApplySurface.cpp ../src/Unuk/Globals.cpp ../src/libUnuk/Rect.cpp ../src/libUnuk/ImageLoader.cpp ../src/libUnuk/TextureManager.cpp ../src/libUnuk/Texture.cpp .tmp/Unuk-QT1.0.0/ && (cd `dirname .tmp/Unuk-QT1.0.0` && $(TAR) Unuk-QT1.0.0.tar Unuk-QT1.0.0 && $(COMPRESS) Unuk-QT1.0.0.tar) && $(MOVE) `dirname .tmp/Unuk-QT1.0.0`/Unuk-QT1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/Unuk-QT1.0.0
|
$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/Unuk-QT1.0.0/ && $(COPY_FILE) --parents ../src/libUnuk/Debug.h ../src/Libs/wglext.h ../src/Libs/glxext.h ../src/libUnuk/Input.h ../src/libUnuk/Rect.h ../src/libUnuk/Timer.h ../src/libUnuk/Font.h ../Constants.h ../src/Unuk/Constants.h ../src/libUnuk/ApplySurface.h ../src/Unuk/Globals.h ../src/libUnuk/ImageLoader.h ../src/libUnuk/TextureManager.h ../src/libUnuk/Texture.h ../src/libUnuk/Text.h .tmp/Unuk-QT1.0.0/ && $(COPY_FILE) --parents ../src/libUnuk/Debug.cpp ../src/Unuk/main.cpp ../src/libUnuk/Input.cpp ../src/libUnuk/Timer.cpp ../src/libUnuk/Font.cpp ../src/libUnuk/ApplySurface.cpp ../src/Unuk/Globals.cpp ../src/libUnuk/Rect.cpp ../src/libUnuk/ImageLoader.cpp ../src/libUnuk/TextureManager.cpp ../src/libUnuk/Texture.cpp ../src/libUnuk/Text.cpp .tmp/Unuk-QT1.0.0/ && (cd `dirname .tmp/Unuk-QT1.0.0` && $(TAR) Unuk-QT1.0.0.tar Unuk-QT1.0.0 && $(COMPRESS) Unuk-QT1.0.0.tar) && $(MOVE) `dirname .tmp/Unuk-QT1.0.0`/Unuk-QT1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/Unuk-QT1.0.0
|
||||||
|
|
||||||
|
|
||||||
clean:compiler_clean
|
clean:compiler_clean
|
||||||
@ -259,6 +261,13 @@ Texture.o: ../src/libUnuk/Texture.cpp ../src/libUnuk/Texture.h \
|
|||||||
../src/libUnuk/ApplySurface.h
|
../src/libUnuk/ApplySurface.h
|
||||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Texture.o ../src/libUnuk/Texture.cpp
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Texture.o ../src/libUnuk/Texture.cpp
|
||||||
|
|
||||||
|
Text.o: ../src/libUnuk/Text.cpp ../src/libUnuk/Text.h \
|
||||||
|
../src/Unuk/Globals.h \
|
||||||
|
../src/libUnuk/ApplySurface.h \
|
||||||
|
../src/libUnuk/Debug.h \
|
||||||
|
../src/libUnuk/Font.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Text.o ../src/libUnuk/Text.cpp
|
||||||
|
|
||||||
####### Install
|
####### Install
|
||||||
|
|
||||||
install: FORCE
|
install: FORCE
|
||||||
|
@ -18,7 +18,8 @@ HEADERS += ../src/libUnuk/Debug.h \
|
|||||||
../src/Unuk/Globals.h \
|
../src/Unuk/Globals.h \
|
||||||
../src/libUnuk/ImageLoader.h \
|
../src/libUnuk/ImageLoader.h \
|
||||||
../src/libUnuk/TextureManager.h \
|
../src/libUnuk/TextureManager.h \
|
||||||
../src/libUnuk/Texture.h
|
../src/libUnuk/Texture.h \
|
||||||
|
../src/libUnuk/Text.h
|
||||||
SOURCES += ../src/libUnuk/Debug.cpp \
|
SOURCES += ../src/libUnuk/Debug.cpp \
|
||||||
../src/Unuk/main.cpp \
|
../src/Unuk/main.cpp \
|
||||||
../src/libUnuk/Input.cpp \
|
../src/libUnuk/Input.cpp \
|
||||||
@ -29,4 +30,5 @@ SOURCES += ../src/libUnuk/Debug.cpp \
|
|||||||
../src/libUnuk/Rect.cpp \
|
../src/libUnuk/Rect.cpp \
|
||||||
../src/libUnuk/ImageLoader.cpp \
|
../src/libUnuk/ImageLoader.cpp \
|
||||||
../src/libUnuk/TextureManager.cpp \
|
../src/libUnuk/TextureManager.cpp \
|
||||||
../src/libUnuk/Texture.cpp
|
../src/libUnuk/Texture.cpp \
|
||||||
|
../src/libUnuk/Text.cpp
|
||||||
|
112
src/libUnuk/Text.cpp
Normal file
112
src/libUnuk/Text.cpp
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
#include "Text.h"
|
||||||
|
|
||||||
|
TTF_Font* Text::verySmallFont = NULL;
|
||||||
|
TTF_Font* Text::smallFont = NULL;
|
||||||
|
TTF_Font* Text::mediumFont = NULL;
|
||||||
|
TTF_Font* Text::largeFont = NULL;
|
||||||
|
|
||||||
|
Text::Text(void) {
|
||||||
|
m_text = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Text::~Text(void) {
|
||||||
|
assert(m_text != NULL);
|
||||||
|
SDL_FreeSurface(m_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Text::LoadFonts(void) {
|
||||||
|
// Load the fonts if they are not already in memory.
|
||||||
|
assert(verySmallFont == NULL);
|
||||||
|
assert(smallFont == NULL);
|
||||||
|
assert(mediumFont == NULL);
|
||||||
|
assert(largeFont == NULL);
|
||||||
|
|
||||||
|
verySmallFont = Font("../Data/Media/Fonts/Enigma_2.ttf", 16);
|
||||||
|
smallFont = Font("../Data/Media/Fonts/Enigma_2.ttf", 23);
|
||||||
|
mediumFont = Font("../Data/Media/Fonts/Enigma_2.ttf", 27);
|
||||||
|
largeFont = Font("../Data/Media/Fonts/Enigma_2.ttf", 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Text::FreeFonts(void) {
|
||||||
|
// If the fonts are loaded, then free them.
|
||||||
|
assert(verySmallFont != NULL);
|
||||||
|
assert(smallFont != NULL);
|
||||||
|
assert(mediumFont != NULL);
|
||||||
|
assert(largeFont != NULL);
|
||||||
|
|
||||||
|
TTF_CloseFont(verySmallFont);
|
||||||
|
TTF_CloseFont(smallFont);
|
||||||
|
TTF_CloseFont(mediumFont);
|
||||||
|
TTF_CloseFont(largeFont);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Text::SetXY(int xArg, int yArg) {
|
||||||
|
x = xArg;
|
||||||
|
y = yArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Text::SetTextBlended(string textArg, string size, SDL_Color colour) {
|
||||||
|
m_textContents = textArg;
|
||||||
|
|
||||||
|
if(m_text != NULL) {
|
||||||
|
SDL_FreeSurface(m_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(size == "vsmall") {
|
||||||
|
m_text = TTF_RenderText_Blended(verySmallFont, textArg.c_str(), colour);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if(size == "small") {
|
||||||
|
m_text = TTF_RenderText_Blended(smallFont, textArg.c_str(), colour);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if(size == "medium") {
|
||||||
|
m_text = TTF_RenderText_Blended(mediumFont, textArg.c_str(), colour);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if(size == "large") {
|
||||||
|
m_text = TTF_RenderText_Blended(largeFont, textArg.c_str(), colour);
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
Debug::logger->message("Text::SetTextBlended(): Invalid size argument %s. Defaulted to small.", size.c_str());
|
||||||
|
m_text = TTF_RenderText_Blended(smallFont, textArg.c_str(), colour);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int Text::SetTextShaded(string textArg, string size, SDL_Color colour, SDL_Color bgColour) {
|
||||||
|
m_textContents = textArg;
|
||||||
|
|
||||||
|
if(m_text != NULL) {
|
||||||
|
SDL_FreeSurface(m_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(size == "vsmall") {
|
||||||
|
m_text = TTF_RenderText_Shaded(verySmallFont, textArg.c_str(), colour, bgColour);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if(size == "small") {
|
||||||
|
m_text = TTF_RenderText_Shaded(smallFont, textArg.c_str(), colour, bgColour);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if(size == "medium") {
|
||||||
|
m_text = TTF_RenderText_Shaded(mediumFont, textArg.c_str(), colour, bgColour);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if(size == "large") {
|
||||||
|
m_text = TTF_RenderText_Shaded(largeFont, textArg.c_str(), colour, bgColour);
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
Debug::logger->message("Text::SetTextBlended(): Invalid size argument %s. Defaulted to small.", size.c_str());
|
||||||
|
m_text = TTF_RenderText_Shaded(smallFont, textArg.c_str(), colour, bgColour);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Text::Render(void) {
|
||||||
|
ApplySurface(x, y, m_text, screen);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Text::RenderLiteral(void) {
|
||||||
|
ApplySurfaceLiteral(x, y, m_text, screen);
|
||||||
|
}
|
50
src/libUnuk/Text.h
Normal file
50
src/libUnuk/Text.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef _TEXT_H_
|
||||||
|
#define _TEXT_H_
|
||||||
|
#include <SDL/SDL.h>
|
||||||
|
#include <SDL/SDL_ttf.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "../Unuk/Globals.h"
|
||||||
|
#include "ApplySurface.h"
|
||||||
|
#include "Font.h"
|
||||||
|
#include "Debug.h"
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class Text {
|
||||||
|
public:
|
||||||
|
Text(void);
|
||||||
|
~Text(void);
|
||||||
|
|
||||||
|
static void LoadFonts(void);
|
||||||
|
static void FreeFonts(void);
|
||||||
|
|
||||||
|
int GetWidth(void) { return m_text->w; }
|
||||||
|
int GetHeight(void) { return m_text->h; }
|
||||||
|
int GetX(void) { return x; }
|
||||||
|
int GetY(void) { return y; }
|
||||||
|
|
||||||
|
string GetText(void) { return m_textContents; }
|
||||||
|
SDL_Color GetColour(void) { return m_textColour; }
|
||||||
|
|
||||||
|
void SetXY(int xArg, int yArg);
|
||||||
|
|
||||||
|
int SetTextBlended(string textArg, string size, SDL_Color);
|
||||||
|
int SetTextShaded(string textArg, string size, SDL_Color, SDL_Color);
|
||||||
|
|
||||||
|
void Render(void);
|
||||||
|
void RenderLiteral(void);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int x, y, w, h;
|
||||||
|
|
||||||
|
string m_textContents;
|
||||||
|
SDL_Color m_textColour;
|
||||||
|
SDL_Surface* m_text;
|
||||||
|
|
||||||
|
static TTF_Font* verySmallFont;
|
||||||
|
static TTF_Font* smallFont;
|
||||||
|
static TTF_Font* mediumFont;
|
||||||
|
static TTF_Font* largeFont;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user