Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F145165
guiwindow.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
guiwindow.cpp
View Options
#include
"guiwindow.h"
void
GuiWindow::setTitle
(
std
::
string
newTitle
)
{
title
=
newTitle
;
guiTitleTxt
.
setString
(
title
);
}
GuiWindow
::
GuiWindow
(
TextureHolder
*
textures
)
{
// spriteClose.setTexture(textures->textureGui);
// spriteClose.setTextureRect(sf::IntRect(0,0,16,16));
// spriteClose.move(sf::Vector2f(150-16,0));
if
(
!
guiElemFont
.
loadFromFile
(
"assets/fnt/metal-macabre.regular.ttf"
))
{
std
::
exit
(
1
);
};
bgdDark
.
setTexture
(
textures
->
backgroundDark
);
// bgdDark.setColor(sf::Color(160, 160, 160, 200));
bgdDark
.
setTextureRect
((
sf
::
IntRect
)
rectangle
.
getLocalBounds
());
title
=
"Choose building:"
;
guiTitleTxt
.
setFont
(
guiElemFont
);
guiTitleTxt
.
setCharacterSize
(
58
);
guiTitleTxt
.
setColor
(
sf
::
Color
(
255
,
255
,
255
,
200
));
guiTitleTxt
.
move
(
2
,
0
);
guiTitleTxt
.
setString
(
title
);
setPosition
(
150
,
100
);
}
GuiWindow
::
GuiWindow
(){
if
(
!
guiElemFont
.
loadFromFile
(
"assets/fnt/metal-macabre.regular.ttf"
))
{
std
::
exit
(
1
);
};
setPosition
(
150
,
100
);
}
//void GuiWindow::setTextureHolder(TextureHolder *textures)
//{
//// spriteClose.setTexture(textures->textureGui);
//}
void
GuiWindow
::
init
(){
}
void
GuiWindow
::
draw
(
sf
::
RenderTarget
&
target
,
sf
::
RenderStates
states
)
const
{
sf
::
RenderStates
states2
=
states
;
states2
.
transform
*=
getTransform
();
Hover
::
draw
(
target
,
states
);
target
.
draw
(
bgdDark
,
states2
);
target
.
draw
(
spriteClose
,
states2
);
target
.
draw
(
guiTitleTxt
,
states2
);
}
std
::
string
GuiWindow
::
getElem
(
sf
::
Vector2f
mousePosition
)
{
sf
::
Vector2f
hoverPos
=
getPosition
();
sf
::
FloatRect
spriteBounds
=
spriteClose
.
getLocalBounds
();
sf
::
FloatRect
closeRect
;
closeRect
.
left
=
spriteClose
.
getPosition
().
x
;
closeRect
.
top
=
spriteClose
.
getPosition
().
y
;
closeRect
.
width
=
spriteBounds
.
width
;
closeRect
.
height
=
spriteBounds
.
height
;
if
(
closeRect
.
contains
(
mousePosition
.
x
-
hoverPos
.
x
,
mousePosition
.
y
-
hoverPos
.
y
))
{
return
"close_gui"
;
}
else
return
""
;
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Sun, Aug 16, 1:53 AM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
77354
Default Alt Text
guiwindow.cpp (2 KB)
Attached To
Mode
R82 deerportal
Attached
Detach File
Event Timeline