About Store Forum Documentation Contact



Post Reply 
D.text problem
Author Message
1991mirec Offline
Member

Post: #1
D.text problem
hi i need an advice

a month or so ago i have asked how can i make D.text to be on the gui for example if i create a health bar and i want to have health there something out of something how can i make it to be on that progress bar.. it was simple as take a gui.draw() and put it before the line it says to draw the text... ok i got it.. but what if i want to have at the same time that text to be behind some other guis. for example my inventory.. when i grab and move my inventory on the place where the text with health is .. text is above the inventory.. and i don t want to see that text there..
thank you
mirec wink
12-29-2013 11:40 PM
Find all posts by this user Quote this message in a reply
Marbasoft Offline
Member

Post: #2
RE: D.text problem
You can make a custom gui object where you can draw what you want in the draw method (tutorial 5.9 in Esenthel tutorials or 5.10 to use the gui editor ).


PHP Code:
class Button2 Button // Create a new class extending the default Gui Button
{
   
virtual void update(C GuiPC &gpc// extend updating object
   
{
      
super.update(gpc); // call default method
   
}
   
virtual void draw(C GuiPC &gpc// extend drawing object
   
{
      if(
gpc.visible && visible()) // if parents are visible and this object is visible too
      
{
         
D.clip(gpc.clip); // clip display drawing to given clipping rectangle, this is needed for example when object is inside a window, and is partially hidden because the parent's rectangle doesn't fully cover this object

         //here you draw your progress bar

         //and then your text
         
D.text(rect().center()+gpc.offsettext); // draw button's text, at center of rectangle and again moved by 'gpc.offset'
      
}
   }


this example is from 5.10 of esenthel Tutorials, you can inherit from a progress bar rather than a button smile
(This post was last modified: 12-31-2013 11:45 AM by Marbasoft.)
12-31-2013 11:43 AM
Find all posts by this user Quote this message in a reply
1991mirec Offline
Member

Post: #3
RE: D.text problem
thank you very much. you have been helpfull
12-31-2013 12:17 PM
Find all posts by this user Quote this message in a reply
Marbasoft Offline
Member

Post: #4
RE: D.text problem
(12-31-2013 12:17 PM)1991mirec Wrote:  thank you very much. you have been helpfull

You're welcomed smile
12-31-2013 01:52 PM
Find all posts by this user Quote this message in a reply
1991mirec Offline
Member

Post: #5
RE: D.text problem
hey i entered on another problem now..
now that i have created it that way it overwrites my progressimage and i don t see it any more... how can it be done ? how can i insert progress image,...thx
12-31-2013 03:30 PM
Find all posts by this user Quote this message in a reply
Rofar Offline
Member

Post: #6
RE: D.text problem
If you want the progress bar to be drawn by the base class draw method then you would need to call super.draw(gpc). You would probably want to do this where the code above has the comment about "here you draw your progress bar".
12-31-2013 07:23 PM
Find all posts by this user Quote this message in a reply
1991mirec Offline
Member

Post: #7
RE: D.text problem
thank you very much... that s what happens when i don t read the whole think cause i think i know how to do it and skip some things... thx again.. smile
01-02-2014 06:52 PM
Find all posts by this user Quote this message in a reply
1991mirec Offline
Member

Post: #8
RE: D.text problem
ok i thought that i got it but at the same time i don t

i am trying to do progress bar for health using custom gui objects.. but if i creat it i can t set or i don t know how to set the progress

this is what i got so far...
Code:
class Progress2 : Progress // Create a new class extending the default Gui Button
{
   virtual void update(C GuiPC &gpc) // extend updating object
   {
      super.update(gpc); // call default method
   }
   virtual void draw(C GuiPC &gpc) // extend drawing object
   {
      if(gpc.visible && visible()) // if parents are visible and this object is visible too
      {
         D.clip(gpc.clip); // clip display drawing to given clipping rectangle, this is needed for example when object is inside a window, and is partially hidden because the parent's rectangle doesn't fully cover this object

TextStyle ts; ts.scale=0.04; ts.color = BLACK;
Str line;
    line =S+TextReal(Players[0].health, 1)+" / "+TextReal(Players[0].healthMax, 1);
      
  D.rect(WHITE, rect()+gpc.offset); // draw a background rectangle, moved by 'gpc.offset' (parents offset)
  
         D.text(ts, rect().center().x+gpc.offset.x, rect().center().y+gpc.offset.y, line); // draw progress's text, at center of rectangle and again moved by 'gpc.offset'
      }
   }
}

Progress2 HealthBar;

bool InitGame() // in here i have it created
{
  Gui+=HealthBar.create(Rect_C(0.13, -0.68, 1.34, 0.03));

    HealthBar.prog_image =UID(2379844899, 1163462508, 1573894308, 1353377412);
and in player update function i have
Code:
HealthBar.set(health, healthmax);
it shows progress bar as gui and text just fine... there is just no progress.. if i have half health the whole rectangle is still white.. how can i make the progress to work???
kinda depressed here.... but still trying.. please help
thank you
01-03-2014 06:04 PM
Find all posts by this user Quote this message in a reply
Rofar Offline
Member

Post: #9
RE: D.text problem
You are drawing the bar with D.rect(...) and it looks to me like you are drawing it to fill the entire rect all the time. This would need to only draw the portion that represents the value.

Can't you just let the parent class draw the bar and then you draw your text on top?

In other words just call super.draw(gpc) instead of doing the D.rect(...).
01-03-2014 10:33 PM
Find all posts by this user Quote this message in a reply
1991mirec Offline
Member

Post: #10
RE: D.text problem
well thx it works.. i just tested it.. i didn t get first time... i m still newbie to this program.. and didn t know that it can be called like this.. thank you again..
01-04-2014 01:10 PM
Find all posts by this user Quote this message in a reply
Post Reply