About Store Forum Documentation Contact



Post Reply 
Adding elements into region / GuiImage
Author Message
Harry Offline
Member

Post: #1
Adding elements into region / GuiImage
Hi. I want to add some Text gui objects into region, but I have problems with position:

Code:
region+=text.create(Vec2(region.crect.w()/2,region.pos().y),"Level");

How can I put text exactly in the center of region?
(This post was last modified: 03-06-2010 04:31 PM by Harry.)
03-01-2010 08:52 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Adding elements into region
Vec2( ok , -region.crect.h()/2)
03-02-2010 12:04 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #3
RE: Adding elements into region
Ok thanks smile I tried use region.crect.h()/2 and I didn't think to add "-" xd
03-02-2010 02:05 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #4
RE: Adding elements into region / GuiImage
How can I draw minimap from tutorial in Gui Window? Now I have sth like this:

Code:
GuiImage imageT;
Window winMap;

winMap+=imageT.create(&image);
imageT.image->drawMask(WHITE,0,map_image_rect,*Images("Gfx/MiniMap/miniMapAlpha.gfx"),winMap.crect);

but it works a bit strange:

http://img695.imageshack.us/i/scrsh2.jpg/ - I have small image on the corner
http://img3.imageshack.us/i/scrsh.jpg/ - mini map isn't drawing as GuiImage in Map window.

Could somebody give me some tips?
03-06-2010 04:37 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: Adding elements into region / GuiImage
you should use GuiCustom for example, add it to the window, and extend the drawing methods, inside it draw as in tutorial
03-06-2010 04:39 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #6
RE: Adding elements into region / GuiImage
Ok. I made it, but I have only one strange thing. When I set barVisible(true) my mini map is draw on this bar, but when i set barVisible(false) everything is draw properly. Do you know why?
03-07-2010 10:39 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: Adding elements into region / GuiImage
if you're using GuiCustom::draw method it shouldn't be a problem
if you're using GuiCustom::draw function you should use window.crect instead of rect
03-07-2010 03:51 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #8
RE: Adding elements into region / GuiImage
I have this code:

Code:
struct MiniMap : GuiCustom
{
    virtual void draw(GuiPC &gpc);
    
    void drawMiniMap(...){...}
}
cpp file
void MiniMap::draw(GuiPC &gpc)
{
    drawMiniMap(ExpGui.winMap.crect,Players[0].pos().xz(),32);
}
...
MiniMap custMap;
void ExperienceGui::create()
{    
   Gui+=winMap .create(Rect_C(0,0,1,1),"Map").barVisible(false).hide();
   winMap+=custMap.create(winMap.crect);
}

Is there something wrong?
(This post was last modified: 03-07-2010 04:33 PM by Harry.)
03-07-2010 04:32 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #9
RE: Adding elements into region / GuiImage
make use of 'gpc'
ExpGui.winMap.crect + gpc.offset
03-07-2010 06:25 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #10
RE: Adding elements into region / GuiImage
Thanks, I fixed this smile
03-07-2010 07:14 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #11
RE: Adding elements into region / GuiImage
I add in the center of minimap an image which should rotate when i rotate my player. So I draw this image by drawRotate method. As angle parameter I use this code:

Players[0].matrix().angles().y

but I'm not sure that this is ok, because sometimes (especially when I fly) my image rotate very strange (slower than it should or in wrong direction). Am I doing something wrong?
(This post was last modified: 03-10-2010 08:41 PM by Harry.)
03-10-2010 08:28 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply